src/mess/drivers/super80.c
| r2297 | r2298 | |
| 10 | 10 | #include "sound/speaker.h" |
| 11 | 11 | #include "deprecat.h" /* "Machine" needed for z80pio interrupt */ |
| 12 | 12 | |
| 13 | | #define video_screen_get_refresh(screen) (((screen_config *)(screen)->inline_config)->refresh) |
| 14 | | |
| 15 | 13 | static UINT8 super80_mhz=2; /* state of bit 2 of port F0 */ |
| 16 | 14 | static UINT16 vidpg=0xfe00; /* Home position of video page being displayed */ |
| 17 | 15 | static UINT8 int_sw; /* internal 1 mhz flipflop */ |
| r2297 | r2298 | |
| 21 | 19 | |
| 22 | 20 | /* the rest are for super80v */ |
| 23 | 21 | static UINT8 *pcgram; |
| 24 | | static int off_x = 0; |
| 25 | | static int off_y = 0; |
| 26 | 22 | static UINT8 framecnt = 0; |
| 27 | 23 | static UINT8 super80v_vid_col=1; // 0 = color ram ; 1 = video ram |
| 28 | 24 | static UINT8 super80v_rom_pcg=1; // 0 = prom ; 1 = pcg |
| 29 | 25 | static UINT8 mc6845_cursor[16]; // cursor shape |
| 30 | | static UINT8 mc6845[20]; /* registers */ |
| 31 | | static UINT8 mc6845_reg; /* register index */ |
| 26 | static UINT8 mc6845_reg[20]; /* registers */ |
| 27 | static UINT8 mc6845_ind; /* register index */ |
| 32 | 28 | static UINT8 mc6845_mask[]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0}; |
| 33 | 29 | |
| 34 | 30 | #define MASTER_CLOCK (XTAL_12MHz) |
| r2297 | r2298 | |
| 171 | 167 | |
| 172 | 168 | for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++) mc6845_cursor[i] = 0; // prepare cursor by erasing old one |
| 173 | 169 | |
| 174 | | r9 = mc6845[9]; // number of scan lines - 1 |
| 175 | | r10 = mc6845[10] & 0x1f; // cursor start line = last 5 bits |
| 176 | | r11 = mc6845[11]+1; // cursor end line incremented to suit for-loops below |
| 170 | r9 = mc6845_reg[9]; // number of scan lines - 1 |
| 171 | r10 = mc6845_reg[10] & 0x1f; // cursor start line = last 5 bits |
| 172 | r11 = mc6845_reg[11]+1; // cursor end line incremented to suit for-loops below |
| 177 | 173 | |
| 178 | 174 | /* decide the curs_type by examining the registers */ |
| 179 | 175 | if (r10 < r11) curs_type=1; // start less than end, show start to end |
| r2297 | r2298 | |
| 198 | 194 | static void mc6845_screen_configure(running_machine *machine) |
| 199 | 195 | { |
| 200 | 196 | rectangle visarea; |
| 201 | | UINT16 width, height, bytes; |
| 202 | | UINT8 dyn = readinputportbytag("CONFIG") & 0x10; // read dipswitch |
| 203 | | visarea.min_x = 0; |
| 204 | | visarea.max_x = SUPER80V_SCREEN_WIDTH-1; |
| 205 | | visarea.min_y = 0; |
| 206 | | visarea.max_y = SUPER80V_SCREEN_HEIGHT-1; |
| 207 | 197 | |
| 208 | | /* calculate the effect of sync and vertical adjustments */ |
| 209 | | if ( mc6845[2] ) off_x = mc6845[0] - mc6845[2] - 23; else off_x = -24; |
| 198 | UINT16 width = mc6845_reg[1]*7-1; // width in pixels |
| 199 | UINT16 height = mc6845_reg[6]*(mc6845_reg[9]+1)-1; // height in pixels |
| 200 | UINT16 bytes = mc6845_reg[1]*mc6845_reg[6]-1; // video ram needed -1 |
| 210 | 201 | |
| 211 | | off_y = (mc6845[4] - mc6845[7]) * (mc6845[9] + 1) + mc6845[5]; |
| 212 | | |
| 213 | | if( off_y < 0 ) off_y = 0; |
| 214 | | |
| 215 | | if( off_y > 128 ) off_y = 128; |
| 216 | | |
| 217 | | if (dyn) |
| 218 | | { |
| 219 | | off_x = 0; |
| 220 | | off_y = 0; |
| 221 | | } |
| 222 | | |
| 223 | | width = mc6845[1]*7-1; // width in pixels |
| 224 | | height = mc6845[6]*(mc6845[9]+1)-1; // height in pixels |
| 225 | | bytes = mc6845[1]*mc6845[6]-1; // video ram needed -1 |
| 226 | | |
| 227 | | /* Physically resize the screen now */ |
| 228 | | if (dyn) |
| 229 | | { |
| 230 | | visarea.min_x = 0; |
| 231 | | visarea.max_x = width; |
| 232 | | visarea.min_y = 0; |
| 233 | | visarea.max_y = height; |
| 234 | | if ((width < 610) |
| 235 | | && (height < 460) /* bounds checking to prevent an assert or violation */ |
| 236 | | && (bytes < 0x1000)) |
| 237 | | video_screen_configure(machine->primary_screen, width+1, height+1, &visarea, video_screen_get_refresh(machine->primary_screen)); |
| 238 | | } |
| 239 | | else |
| 240 | | video_screen_configure(machine->primary_screen, SUPER80V_SCREEN_WIDTH, SUPER80V_SCREEN_HEIGHT, &visarea, video_screen_get_refresh(machine->primary_screen)); // in case dipswitch was just turned to NO |
| 202 | /* Resize the screen */ |
| 203 | visarea.min_x = 0; |
| 204 | visarea.max_x = width; |
| 205 | visarea.min_y = 0; |
| 206 | visarea.max_y = height; |
| 207 | if ((width < 610) && (height < 460) && (bytes < 0x1000)) /* bounds checking to prevent an assert or violation */ |
| 208 | video_screen_set_visarea(machine->primary_screen, 0, width+1, 0, height+1); |
| 241 | 209 | } |
| 242 | 210 | |
| 243 | 211 | static VIDEO_EOF( super80m ) |
| r2297 | r2298 | |
| 319 | 287 | |
| 320 | 288 | static VIDEO_UPDATE( super80v ) |
| 321 | 289 | { |
| 322 | | UINT16 i, bytes = mc6845[1]*mc6845[6]; |
| 323 | | UINT8 speed = mc6845[10]&0x20, flash = mc6845[10]&0x40; // cursor modes |
| 324 | | UINT16 cursor = (mc6845[14]<<8) | mc6845[15]; // get cursor position |
| 325 | | UINT16 screen_home = (mc6845[12]<<8) | mc6845[13]; // screen home offset (usually zero) |
| 290 | UINT16 i, bytes = mc6845_reg[1]*mc6845_reg[6]; |
| 291 | UINT8 speed = mc6845_reg[10]&0x20, flash = mc6845_reg[10]&0x40; // cursor modes |
| 292 | UINT16 cursor = (mc6845_reg[14]<<8) | mc6845_reg[15]; // get cursor position |
| 293 | UINT16 screen_home = (mc6845_reg[12]<<8) | mc6845_reg[13]; // screen home offset (usually zero) |
| 326 | 294 | UINT8 options=readinputportbytag("CONFIG"); |
| 327 | 295 | framecnt++; |
| 328 | 296 | |
| r2297 | r2298 | |
| 340 | 308 | for( i = screen_home; (i < (bytes + screen_home)) & (i < 0x1000); i++ ) |
| 341 | 309 | { |
| 342 | 310 | int sx, sy, chr, col; |
| 343 | | sy = off_y + ((i - screen_home) / mc6845[1]) * (mc6845[9] + 1); |
| 344 | | sx = (off_x + ((i - screen_home) % mc6845[1])) * 7; |
| 311 | sy = ((i - screen_home) / mc6845_reg[1]) * (mc6845_reg[9] + 1); |
| 312 | sx = ((i - screen_home) % mc6845_reg[1]) * 7; |
| 345 | 313 | chr = videoram[i]; |
| 346 | 314 | |
| 347 | 315 | /* get colour or b&w */ |
| r2297 | r2298 | |
| 464 | 432 | |
| 465 | 433 | static READ8_HANDLER( super80v_11_r ) |
| 466 | 434 | { |
| 467 | | if ((mc6845_reg > 13) && (mc6845_reg < 18)) /* determine readable registers */ |
| 468 | | return mc6845[mc6845_reg]; |
| 435 | if ((mc6845_ind > 13) && (mc6845_ind < 18)) /* determine readable registers */ |
| 436 | return mc6845_reg[mc6845_ind]; |
| 469 | 437 | else |
| 470 | 438 | return 0; |
| 471 | 439 | } |
| r2297 | r2298 | |
| 480 | 448 | |
| 481 | 449 | static WRITE8_HANDLER( super80v_10_w ) |
| 482 | 450 | { |
| 483 | | if (data < 18) mc6845_reg = data; else mc6845_reg = 19; /* make sure if you try using an invalid register your write will go nowhere */ |
| 451 | if (data < 18) mc6845_ind = data; else mc6845_ind = 19; /* make sure if you try using an invalid register your write will go nowhere */ |
| 484 | 452 | } |
| 485 | 453 | |
| 486 | 454 | static WRITE8_HANDLER( super80v_11_w ) |
| 487 | 455 | { |
| 488 | | if (mc6845_reg < 16) mc6845[mc6845_reg] = data & mc6845_mask[mc6845_reg]; /* save data in register */ |
| 489 | | if (mc6845_reg < 10) mc6845_screen_configure(machine); /* adjust screen size */ |
| 490 | | if ((mc6845_reg > 8) && (mc6845_reg < 12)) mc6845_cursor_configure(); /* adjust cursor shape */ |
| 456 | if (mc6845_ind < 16) mc6845_reg[mc6845_ind] = data & mc6845_mask[mc6845_ind]; /* save data in register */ |
| 457 | if ((mc6845_ind == 1) || (mc6845_ind == 6) || (mc6845_ind == 9)) mc6845_screen_configure(machine); /* adjust screen size */ |
| 458 | if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure(); /* adjust cursor shape */ |
| 491 | 459 | } |
| 492 | 460 | |
| 493 | 461 | static UINT8 last_data; |
| r2297 | r2298 | |
| 713 | 681 | PORT_INCLUDE( super80m ) |
| 714 | 682 | |
| 715 | 683 | PORT_MODIFY("CONFIG") |
| 716 | | |
| 717 | | /* Enhanced options not available on real hardware */ |
| 718 | | PORT_BIT( 0x6, 0x6, IPT_UNUSED ) |
| 719 | | PORT_CONFNAME( 0x10, 0x10, "Auto-Resize?") |
| 720 | | PORT_CONFSETTING( 0x00, DEF_STR(No)) |
| 721 | | PORT_CONFSETTING( 0x10, DEF_STR(Yes)) |
| 684 | PORT_BIT( 0x16, 0x16, IPT_UNUSED ) |
| 722 | 685 | INPUT_PORTS_END |
| 723 | 686 | |
| 724 | 687 | /**************************** GRAPHICS DECODE *****************************************************************/ |