src/mess/drivers/multi8.c
| r8624 | r8625 | |
| 5 | 5 | preliminary driver by Angelo Salese |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | | - can't compile any code snippet out of BASIC, just single commands seems |
| 9 | | to work |
| 8 | - dunno how to trigger the text color mode in BASIC, I just modify |
| 9 | $f0b1 to 1 for now |
| 10 | - bitmap B/W mode is untested |
| 10 | 11 | |
| 11 | 12 | ****************************************************************************/ |
| 12 | 13 | |
| r8624 | r8625 | |
| 20 | 21 | static UINT8 keyb_press,keyb_press_flag,display_reg; |
| 21 | 22 | static UINT16 cursor_addr,cursor_raster; |
| 22 | 23 | static UINT8 vram_bank; |
| 24 | static UINT8 pen_clut[8],bw_mode; |
| 23 | 25 | |
| 24 | 26 | static VIDEO_START( multi8 ) |
| 25 | 27 | { |
| r8624 | r8625 | |
| 49 | 51 | pen_r = (vram[count | 0x4000] >> (7-xi)) & 1; |
| 50 | 52 | pen_g = (vram[count | 0x8000] >> (7-xi)) & 1; |
| 51 | 53 | |
| 52 | | color = (pen_b) | (pen_r << 1) | (pen_g << 2); |
| 54 | if(bw_mode) |
| 55 | { |
| 56 | pen_b = (display_reg & 1) ? pen_b : 0; |
| 57 | pen_r = (display_reg & 2) ? pen_r : 0; |
| 58 | pen_g = (display_reg & 4) ? pen_g : 0; |
| 53 | 59 | |
| 54 | | *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine->pens[color]; |
| 60 | color = ((pen_b) | (pen_r) | (pen_g)) ? 7 : 0; |
| 61 | } |
| 62 | else |
| 63 | color = (pen_b) | (pen_r << 1) | (pen_g << 2); |
| 64 | |
| 65 | *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine->pens[pen_clut[color]]; |
| 55 | 66 | } |
| 56 | 67 | count++; |
| 57 | 68 | } |
| r8624 | r8625 | |
| 65 | 76 | for(x=0;x<x_width;x++) |
| 66 | 77 | { |
| 67 | 78 | int tile = vram[count]; |
| 68 | | int color = (vram[count+0x800] & 0x38) >> 3; |
| 79 | int attr = vram[count+0x800]; |
| 80 | int color = (display_reg & 0x80) ? 7 : (attr & 0x07); |
| 69 | 81 | |
| 70 | | if(color == 0) |
| 71 | | color = 7; |
| 72 | | |
| 73 | 82 | for(yi=0;yi<8;yi++) |
| 74 | 83 | { |
| 75 | 84 | for(xi=0;xi<8;xi++) |
| r8624 | r8625 | |
| 78 | 87 | |
| 79 | 88 | pen = (gfx_rom[tile*8+yi] >> (7-xi) & 1) ? color : 0; |
| 80 | 89 | |
| 90 | if(attr & 0x20) |
| 91 | pen^=7; |
| 92 | |
| 81 | 93 | if(pen) |
| 82 | 94 | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[pen]; |
| 83 | 95 | } |
| r8624 | r8625 | |
| 160 | 172 | static READ8_HANDLER( multi8_vram_r ) |
| 161 | 173 | { |
| 162 | 174 | static UINT8 *vram = memory_region(space->machine, "vram"); |
| 175 | static UINT8 *wram = memory_region(space->machine, "wram"); |
| 163 | 176 | UINT8 res; |
| 164 | 177 | |
| 178 | if(!(vram_bank & 0x10)) //select plain work ram |
| 179 | return wram[offset]; |
| 180 | |
| 165 | 181 | res = 0xff; |
| 166 | 182 | if(!(vram_bank & 1)) { res &= vram[offset | 0x0000]; } |
| 167 | 183 | if(!(vram_bank & 2)) { res &= vram[offset | 0x4000]; } |
| r8624 | r8625 | |
| 174 | 190 | static WRITE8_HANDLER( multi8_vram_w ) |
| 175 | 191 | { |
| 176 | 192 | static UINT8 *vram = memory_region(space->machine, "vram"); |
| 193 | static UINT8 *wram = memory_region(space->machine, "wram"); |
| 177 | 194 | |
| 195 | if(!(vram_bank & 0x10)) //select plain work ram |
| 196 | { |
| 197 | wram[offset] = data; |
| 198 | return; |
| 199 | } |
| 200 | |
| 178 | 201 | if(!(vram_bank & 1)) { vram[offset | 0x0000] = data; } |
| 179 | 202 | if(!(vram_bank & 2)) { vram[offset | 0x4000] = data; } |
| 180 | 203 | if(!(vram_bank & 4)) { vram[offset | 0x8000] = data; } |
| 181 | 204 | if(!(vram_bank & 8)) { vram[offset | 0xc000] = data; } |
| 182 | 205 | } |
| 183 | 206 | |
| 207 | static READ8_HANDLER( pal_r ) |
| 208 | { |
| 209 | return pen_clut[offset]; |
| 210 | } |
| 184 | 211 | |
| 212 | static WRITE8_HANDLER( pal_w ) |
| 213 | { |
| 214 | pen_clut[offset] = data; |
| 215 | |
| 216 | { |
| 217 | int i; |
| 218 | for(i=0;i<8;i++) |
| 219 | { |
| 220 | if(pen_clut[i]) { bw_mode = 0; return; } |
| 221 | } |
| 222 | bw_mode = 1; |
| 223 | } |
| 224 | } |
| 225 | |
| 185 | 226 | static ADDRESS_MAP_START(multi8_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 186 | 227 | ADDRESS_MAP_UNMAP_HIGH |
| 187 | 228 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| r8624 | r8625 | |
| 190 | 231 | ADDRESS_MAP_END |
| 191 | 232 | |
| 192 | 233 | static ADDRESS_MAP_START( multi8_io , ADDRESS_SPACE_IO, 8) |
| 193 | | ADDRESS_MAP_UNMAP_HIGH |
| 234 | // ADDRESS_MAP_UNMAP_HIGH |
| 194 | 235 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 195 | 236 | AM_RANGE(0x00, 0x00) AM_READ(key_input_r) AM_WRITENOP//keyboard |
| 196 | 237 | AM_RANGE(0x01, 0x01) AM_READ(key_status_r) AM_WRITENOP//keyboard |
| r8624 | r8625 | |
| 202 | 243 | // AM_RANGE(0x24, 0x27) //pit |
| 203 | 244 | AM_RANGE(0x28, 0x2b) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w) |
| 204 | 245 | // AM_RANGE(0x2c, 0x2d) //i8259 |
| 205 | | // AM_RANGE(0x30, 0x37) //vdp regs |
| 246 | AM_RANGE(0x30, 0x37) AM_READWRITE(pal_r,pal_w) |
| 206 | 247 | // AM_RANGE(0x40, 0x41) //kanji regs |
| 207 | 248 | // AM_RANGE(0x70, 0x74) //upd765a fdc |
| 208 | 249 | // AM_RANGE(0x78, 0x78) //memory banking |
| r8624 | r8625 | |
| 260 | 301 | PORT_BIT(0x00000100,IP_ACTIVE_HIGH,IPT_UNUSED) //0x28 ( |
| 261 | 302 | PORT_BIT(0x00000200,IP_ACTIVE_HIGH,IPT_UNUSED) //0x29 ) |
| 262 | 303 | PORT_BIT(0x00000400,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2a * |
| 263 | | PORT_BIT(0x00000800,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2b + |
| 304 | PORT_BIT(0x00000800,IP_ACTIVE_HIGH,IPT_UNUSED) |
| 264 | 305 | PORT_BIT(0x00001000,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2c , |
| 265 | 306 | PORT_BIT(0x00002000,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') |
| 266 | 307 | PORT_BIT(0x00004000,IP_ACTIVE_HIGH,IPT_UNUSED) //0x2e . |
| r8624 | r8625 | |
| 356 | 397 | |
| 357 | 398 | if(scancode == 0x3a) |
| 358 | 399 | scancode = 0x2e; |
| 400 | if(scancode == 0x5b) |
| 401 | scancode = 0x2b; |
| 359 | 402 | } |
| 360 | 403 | keyb_press = scancode; |
| 361 | 404 | keyb_press_flag = 1; |
| r8624 | r8625 | |
| 420 | 463 | { |
| 421 | 464 | int vsync = (input_port_read(device->machine, "VBLANK") & 0x1) << 5; |
| 422 | 465 | |
| 423 | | return 0xdf | vsync; |
| 466 | return ~0x60 | vsync; |
| 424 | 467 | } |
| 425 | 468 | |
| 426 | | static READ8_DEVICE_HANDLER( portb_r ) |
| 427 | | { |
| 428 | | // printf("Port B r\n"); |
| 429 | 469 | |
| 430 | | return 0xff; |
| 431 | | } |
| 432 | | |
| 433 | | static READ8_DEVICE_HANDLER( portc_r ) |
| 470 | static WRITE8_DEVICE_HANDLER( portb_w ) |
| 434 | 471 | { |
| 435 | | // printf("Port C r\n"); |
| 472 | /* |
| 473 | x--- ---- color mode |
| 474 | -x-- ---- screen width (80 / 40) |
| 475 | ---- x--- memory bank status |
| 476 | ---- -xxx page screen graphics in B/W mode |
| 477 | */ |
| 478 | // const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 436 | 479 | |
| 437 | | return 0xff; |
| 438 | | } |
| 480 | // printf("Port B w = %02x %04x\n",data,cpu_get_pc(space->cpu)); |
| 439 | 481 | |
| 440 | | static WRITE8_DEVICE_HANDLER( porta_w ) |
| 441 | | { |
| 442 | | // printf("Port A w = %02x\n",data); |
| 443 | | } |
| 444 | | |
| 445 | | static WRITE8_DEVICE_HANDLER( portb_w ) |
| 446 | | { |
| 447 | | // printf("Port B w = %02x\n",data); |
| 448 | | |
| 449 | 482 | { |
| 450 | 483 | if((display_reg & 0x40) != (data & 0x40)) |
| 451 | 484 | { |
| r8624 | r8625 | |
| 462 | 495 | } |
| 463 | 496 | } |
| 464 | 497 | |
| 465 | | |
| 466 | 498 | display_reg = data; |
| 467 | 499 | } |
| 468 | 500 | |
| 469 | 501 | static WRITE8_DEVICE_HANDLER( portc_w ) |
| 470 | 502 | { |
| 471 | 503 | // printf("Port C w = %02x\n",data); |
| 472 | | vram_bank = data & 0xf; |
| 504 | vram_bank = data & 0x1f; |
| 473 | 505 | |
| 474 | | // if(data & 0x20) |
| 506 | if(data & 0x20 && data != 0xff) |
| 507 | printf("Work RAM bank selected!\n"); |
| 475 | 508 | // fatalerror("Work RAM bank selected"); |
| 476 | 509 | } |
| 477 | 510 | |
| r8624 | r8625 | |
| 479 | 512 | static I8255A_INTERFACE( ppi8255_intf_0 ) |
| 480 | 513 | { |
| 481 | 514 | DEVCB_HANDLER(porta_r), /* Port A read */ |
| 482 | | DEVCB_HANDLER(portb_r), /* Port B read */ |
| 483 | | DEVCB_HANDLER(portc_r), /* Port C read */ |
| 484 | | DEVCB_HANDLER(porta_w), /* Port A write */ |
| 515 | DEVCB_NULL, /* Port B read */ |
| 516 | DEVCB_NULL, /* Port C read */ |
| 517 | DEVCB_NULL, /* Port A write */ |
| 485 | 518 | DEVCB_HANDLER(portb_w), /* Port B write */ |
| 486 | 519 | DEVCB_HANDLER(portc_w) /* Port C write */ |
| 487 | 520 | }; |
| r8624 | r8625 | |
| 528 | 561 | ROM_REGION( 0x0800, "chargen", 0 ) |
| 529 | 562 | ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(08f9ed0e) SHA1(57480510fb30af1372df5a44b23066ca61c6f0d9)) |
| 530 | 563 | |
| 564 | ROM_REGION( 0x1000, "fdc_bios", 0 ) |
| 565 | ROM_LOAD( "disk.rom", 0x0000, 0x1000, NO_DUMP ) |
| 566 | |
| 531 | 567 | ROM_REGION( 0x10000, "vram", ROMREGION_ERASEFF ) |
| 568 | |
| 569 | ROM_REGION( 0x4000, "wram", ROMREGION_ERASEFF ) |
| 532 | 570 | ROM_END |
| 533 | 571 | |
| 534 | 572 | /* Driver */ |