src/mess/drivers/multi8.c
| r8622 | r8623 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | Mitsubishi Multi 8 |
| 3 | Multi 8 (c) 1983 Mitsubishi |
| 4 | 4 | |
| 5 | | 13/07/2010 Skeleton driver. |
| 5 | preliminary driver by Angelo Salese |
| 6 | 6 | |
| 7 | TODO: |
| 8 | - can't compile any code snippet out of BASIC, just single commands seems |
| 9 | to work |
| 10 | |
| 7 | 11 | ****************************************************************************/ |
| 8 | 12 | |
| 9 | 13 | #include "emu.h" |
| r8622 | r8623 | |
| 12 | 16 | #include "video/mc6845.h" |
| 13 | 17 | #include "machine/i8255a.h" |
| 14 | 18 | |
| 15 | | static UINT8 *vram; |
| 16 | 19 | static UINT8 mcu_init; |
| 17 | 20 | static UINT8 keyb_press,keyb_press_flag,display_reg; |
| 18 | 21 | static UINT16 cursor_addr,cursor_raster; |
| 22 | static UINT8 vram_bank; |
| 19 | 23 | |
| 20 | 24 | static VIDEO_START( multi8 ) |
| 21 | 25 | { |
| r8622 | r8623 | |
| 25 | 29 | { |
| 26 | 30 | int x,y,count; |
| 27 | 31 | int x_width; |
| 32 | int xi,yi; |
| 33 | static UINT8 *vram = memory_region(screen->machine, "vram"); |
| 34 | static UINT8 *gfx_rom = memory_region(screen->machine, "chargen"); |
| 35 | |
| 28 | 36 | count = 0x0000; |
| 29 | 37 | |
| 38 | x_width = (display_reg & 0x40) ? 640 : 320; |
| 39 | |
| 40 | for(y=0;y<200;y++) |
| 41 | { |
| 42 | for(x=0;x<x_width;x+=8) |
| 43 | { |
| 44 | for(xi=0;xi<8;xi++) |
| 45 | { |
| 46 | int pen_r,pen_g,pen_b,color; |
| 47 | |
| 48 | pen_b = (vram[count | 0x0000] >> (7-xi)) & 1; |
| 49 | pen_r = (vram[count | 0x4000] >> (7-xi)) & 1; |
| 50 | pen_g = (vram[count | 0x8000] >> (7-xi)) & 1; |
| 51 | |
| 52 | color = (pen_b) | (pen_r << 1) | (pen_g << 2); |
| 53 | |
| 54 | *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine->pens[color]; |
| 55 | } |
| 56 | count++; |
| 57 | } |
| 58 | } |
| 59 | |
| 30 | 60 | x_width = (display_reg & 0x40) ? 80 : 40; |
| 61 | count = 0xc000; |
| 31 | 62 | |
| 32 | 63 | for(y=0;y<25;y++) |
| 33 | 64 | { |
| 34 | 65 | for(x=0;x<x_width;x++) |
| 35 | 66 | { |
| 36 | 67 | int tile = vram[count]; |
| 37 | | int color = vram[count+0x800] & 0x20; |
| 68 | int color = (vram[count+0x800] & 0x38) >> 3; |
| 38 | 69 | |
| 39 | | drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[0], tile,color >> 5, 0, 0, x*8, y*8); |
| 70 | if(color == 0) |
| 71 | color = 7; |
| 40 | 72 | |
| 73 | for(yi=0;yi<8;yi++) |
| 74 | { |
| 75 | for(xi=0;xi<8;xi++) |
| 76 | { |
| 77 | int pen; |
| 78 | |
| 79 | pen = (gfx_rom[tile*8+yi] >> (7-xi) & 1) ? color : 0; |
| 80 | |
| 81 | if(pen) |
| 82 | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine->pens[pen]; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | //drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[0], tile,color >> 5, 0, 0, x*8, y*8); |
| 87 | |
| 41 | 88 | // draw cursor |
| 42 | | if(cursor_addr == count) |
| 89 | if(cursor_addr+0xc000 == count) |
| 43 | 90 | { |
| 44 | 91 | int xc,yc,cursor_on; |
| 45 | 92 | |
| r8622 | r8623 | |
| 58 | 105 | { |
| 59 | 106 | for(xc=0;xc<8;xc++) |
| 60 | 107 | { |
| 61 | | *BITMAP_ADDR16(bitmap, y*8+yc+7, x*8+xc) = screen->machine->pens[0x1]; |
| 108 | *BITMAP_ADDR16(bitmap, y*8+yc, x*8+xc) = screen->machine->pens[0x7]; |
| 62 | 109 | } |
| 63 | 110 | } |
| 64 | 111 | } |
| 65 | 112 | } |
| 113 | |
| 66 | 114 | (display_reg & 0x40) ? count++ : count+=2; |
| 67 | 115 | } |
| 68 | 116 | } |
| r8622 | r8623 | |
| 109 | 157 | return keyb_press_flag; |
| 110 | 158 | } |
| 111 | 159 | |
| 160 | static READ8_HANDLER( multi8_vram_r ) |
| 161 | { |
| 162 | static UINT8 *vram = memory_region(space->machine, "vram"); |
| 163 | UINT8 res; |
| 164 | |
| 165 | res = 0xff; |
| 166 | if(!(vram_bank & 1)) { res &= vram[offset | 0x0000]; } |
| 167 | if(!(vram_bank & 2)) { res &= vram[offset | 0x4000]; } |
| 168 | if(!(vram_bank & 4)) { res &= vram[offset | 0x8000]; } |
| 169 | if(!(vram_bank & 8)) { res &= vram[offset | 0xc000]; } |
| 170 | |
| 171 | return res; |
| 172 | } |
| 173 | |
| 174 | static WRITE8_HANDLER( multi8_vram_w ) |
| 175 | { |
| 176 | static UINT8 *vram = memory_region(space->machine, "vram"); |
| 177 | |
| 178 | if(!(vram_bank & 1)) { vram[offset | 0x0000] = data; } |
| 179 | if(!(vram_bank & 2)) { vram[offset | 0x4000] = data; } |
| 180 | if(!(vram_bank & 4)) { vram[offset | 0x8000] = data; } |
| 181 | if(!(vram_bank & 8)) { vram[offset | 0xc000] = data; } |
| 182 | } |
| 183 | |
| 184 | |
| 112 | 185 | static ADDRESS_MAP_START(multi8_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 113 | 186 | ADDRESS_MAP_UNMAP_HIGH |
| 114 | 187 | AM_RANGE(0x0000, 0x7fff) AM_ROM |
| 115 | | AM_RANGE(0x8000, 0x8fff) AM_RAM AM_BASE(&vram) |
| 116 | | AM_RANGE(0x9000, 0xffff) AM_RAM |
| 188 | AM_RANGE(0x8000, 0xbfff) AM_READWRITE( multi8_vram_r, multi8_vram_w ) |
| 189 | AM_RANGE(0xc000, 0xffff) AM_RAM |
| 117 | 190 | ADDRESS_MAP_END |
| 118 | 191 | |
| 119 | 192 | static ADDRESS_MAP_START( multi8_io , ADDRESS_SPACE_IO, 8) |
| r8622 | r8623 | |
| 276 | 349 | if(scancode >= 0x31 && scancode < 0x3a) |
| 277 | 350 | scancode -= 0x10; |
| 278 | 351 | if(scancode == 0x30) |
| 279 | | { |
| 280 | 352 | scancode = 0x3d; |
| 281 | | } |
| 353 | |
| 354 | if(scancode == 0x3b) |
| 355 | scancode = 0x2c; |
| 356 | |
| 357 | if(scancode == 0x3a) |
| 358 | scancode = 0x2e; |
| 282 | 359 | } |
| 283 | 360 | keyb_press = scancode; |
| 284 | 361 | keyb_press_flag = 1; |
| r8622 | r8623 | |
| 333 | 410 | |
| 334 | 411 | static PALETTE_INIT( multi8 ) |
| 335 | 412 | { |
| 336 | | palette_set_color_rgb(machine, 0, 0x00,0x00,0x00); |
| 337 | | palette_set_color_rgb(machine, 1, 0xff,0xff,0xff); |
| 338 | | palette_set_color_rgb(machine, 2, 0xff,0xff,0xff); |
| 339 | | palette_set_color_rgb(machine, 3, 0x00,0x00,0x00); |
| 413 | int i; |
| 340 | 414 | |
| 415 | for(i=0;i<8;i++) |
| 416 | palette_set_color_rgb(machine, i, pal1bit(i >> 1),pal1bit(i >> 2),pal1bit(i >> 0)); |
| 341 | 417 | } |
| 342 | 418 | |
| 343 | 419 | static READ8_DEVICE_HANDLER( porta_r ) |
| r8622 | r8623 | |
| 393 | 469 | static WRITE8_DEVICE_HANDLER( portc_w ) |
| 394 | 470 | { |
| 395 | 471 | // printf("Port C w = %02x\n",data); |
| 472 | vram_bank = data & 0xf; |
| 473 | |
| 474 | // if(data & 0x20) |
| 475 | // fatalerror("Work RAM bank selected"); |
| 396 | 476 | } |
| 397 | 477 | |
| 398 | 478 | |
| r8622 | r8623 | |
| 424 | 504 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 425 | 505 | MDRV_SCREEN_SIZE(640, 200) |
| 426 | 506 | MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 200-1) |
| 427 | | MDRV_PALETTE_LENGTH(4) |
| 507 | MDRV_PALETTE_LENGTH(8) |
| 428 | 508 | MDRV_PALETTE_INIT(multi8) |
| 429 | 509 | MDRV_GFXDECODE(multi8) |
| 430 | 510 | |
| r8622 | r8623 | |
| 444 | 524 | ROM_START( multi8 ) |
| 445 | 525 | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |
| 446 | 526 | ROM_LOAD( "basic.rom", 0x0000, 0x8000, CRC(2131a3a8) SHA1(0f5a565ecfbf79237badbf9011dcb374abe74a57)) |
| 527 | |
| 447 | 528 | ROM_REGION( 0x0800, "chargen", 0 ) |
| 448 | 529 | ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(08f9ed0e) SHA1(57480510fb30af1372df5a44b23066ca61c6f0d9)) |
| 530 | |
| 531 | ROM_REGION( 0x10000, "vram", ROMREGION_ERASEFF ) |
| 449 | 532 | ROM_END |
| 450 | 533 | |
| 451 | 534 | /* Driver */ |