src/mess/drivers/mz2500.c
| r8925 | r8926 | |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | 8 | - floppy device; |
| 9 | - graphics are really a bare minimum, this thing is very complex; |
| 9 | 10 | - keyboard inputs (needs something that actually works); |
| 10 | 11 | |
| 11 | 12 | memory map: |
| r8925 | r8926 | |
| 39 | 40 | static UINT8 kanji_bank; |
| 40 | 41 | static UINT8 fdc_reverse; |
| 41 | 42 | static UINT8 key_mux; |
| 43 | static UINT8 crtc_reg_index; |
| 44 | static UINT8 crtc_reg[0x20]; |
| 42 | 45 | |
| 43 | 46 | #define WRAM_RESET 0 |
| 44 | 47 | #define IPL_RESET 1 |
| r8925 | r8926 | |
| 69 | 72 | |
| 70 | 73 | if(text_font_reg) |
| 71 | 74 | { |
| 72 | | for (y=0;y<25;y++) |
| 75 | for (y=0;y<25*2;y++) |
| 73 | 76 | { |
| 74 | | for (x=0;x<text_col_size;x++) |
| 77 | for (x=0;x<80/*text_col_size*/;x++) |
| 75 | 78 | { |
| 76 | 79 | int tile = vram[count+0x0000] & 0xff; |
| 77 | 80 | int attr = vram[count+0x0800]; |
| r8925 | r8926 | |
| 80 | 83 | //int gfx_num; |
| 81 | 84 | int color = attr & 7; |
| 82 | 85 | |
| 83 | | if(gfx_sel == 0x00) |
| 86 | if(gfx_sel == 0x80 || gfx_sel == 0xc0) |
| 87 | gfx_data = memory_region(screen->machine,"kanji"); //TODO |
| 88 | else |
| 84 | 89 | gfx_data = memory_region(screen->machine,"pcg"); |
| 85 | | else |
| 86 | | gfx_data = memory_region(screen->machine,"kanji"); //TODO |
| 87 | 90 | |
| 88 | 91 | tile|= tile_bank << 8; |
| 89 | 92 | |
| r8925 | r8926 | |
| 91 | 94 | { |
| 92 | 95 | for(xi=0;xi<8;xi++) |
| 93 | 96 | { |
| 94 | | UINT8 pen; |
| 97 | UINT8 pen_bit[3],pen; |
| 95 | 98 | |
| 96 | | pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? color : 0; |
| 99 | if(gfx_sel & 0x8) |
| 100 | { |
| 101 | pen_bit[0] = ((gfx_data[tile*8+yi+0x1800]>>(7-xi)) & 1) ? 4 : 0; //G |
| 102 | pen_bit[1] = ((gfx_data[tile*8+yi+0x1000]>>(7-xi)) & 1) ? 2 : 0; //R |
| 103 | pen_bit[2] = ((gfx_data[tile*8+yi+0x0800]>>(7-xi)) & 1) ? 1 : 0; //B |
| 97 | 104 | |
| 105 | pen = pen_bit[0]|pen_bit[1]|pen_bit[2]; |
| 106 | } |
| 107 | else |
| 108 | pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? color : 0; |
| 109 | |
| 98 | 110 | *BITMAP_ADDR16(bitmap, (y*8+yi), x*8+xi) = screen->machine->pens[pen]; |
| 99 | 111 | } |
| 100 | 112 | } |
| r8925 | r8926 | |
| 117 | 129 | //int gfx_num; |
| 118 | 130 | int color = attr & 7; |
| 119 | 131 | |
| 120 | | if(gfx_sel == 0x00) |
| 132 | if(gfx_sel == 0x80 || gfx_sel == 0xc0) |
| 133 | gfx_data = memory_region(screen->machine,"kanji"); //TODO |
| 134 | else |
| 121 | 135 | gfx_data = memory_region(screen->machine,"pcg"); |
| 122 | | else |
| 123 | | gfx_data = memory_region(screen->machine,"kanji"); //TODO |
| 124 | 136 | |
| 125 | 137 | tile|= tile_bank << 8; |
| 126 | 138 | |
| r8925 | r8926 | |
| 202 | 214 | { |
| 203 | 215 | UINT8 *pcg_ram = memory_region(machine, "pcg"); |
| 204 | 216 | pcg_ram[offset] = data; |
| 205 | | gfx_element_mark_dirty(machine->gfx[3], (offset) >> 3); |
| 217 | if((offset & 0x1800) == 0x0000) |
| 218 | gfx_element_mark_dirty(machine->gfx[3], (offset) >> 3); |
| 219 | else |
| 220 | gfx_element_mark_dirty(machine->gfx[4], (offset & 0x7ff) >> 3); |
| 206 | 221 | } |
| 207 | 222 | } |
| 208 | 223 | break; |
| r8925 | r8926 | |
| 275 | 290 | } |
| 276 | 291 | |
| 277 | 292 | /* 0xf4 - 0xf7 all returns vblank / hblank states */ |
| 278 | | static READ8_HANDLER( mz2500_crtc_r ) |
| 293 | static READ8_HANDLER( mz2500_crtc_hvblank_r ) |
| 279 | 294 | { |
| 280 | 295 | static UINT8 vblank_bit, hblank_bit; |
| 281 | 296 | |
| r8925 | r8926 | |
| 285 | 300 | return vblank_bit | hblank_bit; |
| 286 | 301 | } |
| 287 | 302 | |
| 288 | | static WRITE8_HANDLER( mz2500_crtc_w ) |
| 303 | static WRITE8_HANDLER( mz2500_txt_crtc_w ) |
| 289 | 304 | { |
| 290 | 305 | switch(offset) |
| 291 | 306 | { |
| r8925 | r8926 | |
| 447 | 462 | wd17xx_w(device, offset, data ^ fdc_reverse); |
| 448 | 463 | } |
| 449 | 464 | |
| 465 | static WRITE8_HANDLER( mz2500_crtc_addr_w ) |
| 466 | { |
| 467 | crtc_reg_index = data & 0x1f; |
| 468 | } |
| 469 | |
| 470 | static WRITE8_HANDLER( mz2500_crtc_data_w ) |
| 471 | { |
| 472 | crtc_reg[crtc_reg_index & 0x1f] = data; |
| 473 | |
| 474 | popmessage("%02x",crtc_reg[0x0e]); |
| 475 | } |
| 476 | |
| 450 | 477 | static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8) |
| 451 | 478 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 452 | 479 | // AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w) |
| r8925 | r8926 | |
| 462 | 489 | AM_RANGE(0xb4, 0xb4) AM_READWRITE(mz2500_bank_addr_r,mz2500_bank_addr_w) |
| 463 | 490 | AM_RANGE(0xb5, 0xb5) AM_READWRITE(mz2500_bank_data_r,mz2500_bank_data_w) |
| 464 | 491 | // AM_RANGE(0xb8, 0xb9) AM_READWRITE(kanji_r,kanji_w) |
| 465 | | // AM_RANGE(0xbc, 0xbd) AM_READWRITE(crtc_r,crtc_w) |
| 492 | AM_RANGE(0xbc, 0xbc) AM_WRITE(mz2500_crtc_addr_w) |
| 493 | AM_RANGE(0xbd, 0xbd) AM_WRITE(mz2500_crtc_data_w) |
| 494 | // AM_RANGE(0xbc, 0xbf) AM_READ(mz2500_crtc_cg_r) //reads plane |
| 466 | 495 | AM_RANGE(0xc6, 0xc6) AM_WRITE(mz2500_irq_sel_w) |
| 467 | 496 | AM_RANGE(0xc7, 0xc7) AM_WRITE(mz2500_irq_data_w) |
| 468 | 497 | AM_RANGE(0xc8, 0xc9) AM_DEVREADWRITE("ym", ym2203_r, ym2203_w) |
| r8925 | r8926 | |
| 478 | 507 | AM_RANGE(0xea, 0xeb) AM_DEVREADWRITE("z80pio_1", z80pio_d_r, z80pio_d_w) |
| 479 | 508 | // AM_RANGE(0xef, 0xef) AM_READWRITE(joystick_r,joystick_w) |
| 480 | 509 | // AM_RANGE(0xf0, 0xf3) AM_WRITE(timer_w) |
| 481 | | AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_r) AM_WRITE(mz2500_crtc_w) |
| 510 | AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_hvblank_r) AM_WRITE(mz2500_txt_crtc_w) |
| 482 | 511 | // AM_RANGE(0xf8, 0xf9) AM_READWRITE(extrom_r,extrom_w) |
| 483 | 512 | ADDRESS_MAP_END |
| 484 | 513 | |
| r8925 | r8926 | |
| 891 | 920 | 16 * 16 /* code takes 16 times 16 bits */ |
| 892 | 921 | }; |
| 893 | 922 | |
| 923 | static const gfx_layout mz2500_pcg_layout_1bpp = |
| 924 | { |
| 925 | 8, 8, |
| 926 | RGN_FRAC(1,4), |
| 927 | 1, |
| 928 | { 0 }, |
| 929 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 930 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 931 | 8 * 8 |
| 932 | }; |
| 933 | |
| 934 | static const gfx_layout mz2500_pcg_layout_3bpp = |
| 935 | { |
| 936 | 8, 8, |
| 937 | RGN_FRAC(1,4), |
| 938 | 3, |
| 939 | { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4) }, |
| 940 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 941 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 942 | 8 * 8 |
| 943 | }; |
| 944 | |
| 945 | |
| 894 | 946 | static GFXDECODE_START( mz2500 ) |
| 895 | 947 | GFXDECODE_ENTRY("kanji", 0, mz2500_cg_layout, 0, 256) |
| 896 | 948 | GFXDECODE_ENTRY("kanji", 0x4400, mz2500_8_layout, 0, 256) // for viewer only |
| 897 | 949 | GFXDECODE_ENTRY("kanji", 0, mz2500_16_layout, 0, 256) // for viewer only |
| 898 | | GFXDECODE_ENTRY("pcg", 0, mz2500_cg_layout, 0, 256) |
| 950 | GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_1bpp, 0, 1) |
| 951 | GFXDECODE_ENTRY("pcg", 0, mz2500_pcg_layout_3bpp, 0, 1) |
| 899 | 952 | GFXDECODE_END |
| 900 | 953 | |
| 901 | 954 | static INTERRUPT_GEN( mz2500_vbl ) |
| r8925 | r8926 | |
| 1062 | 1115 | /* video hardware */ |
| 1063 | 1116 | MDRV_SCREEN_ADD("screen", RASTER) |
| 1064 | 1117 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 1065 | | MDRV_SCREEN_RAW_PARAMS(XTAL_17_73447MHz/2, 568, 0, 320, 312, 0, 200) |
| 1118 | //MDRV_SCREEN_RAW_PARAMS(XTAL_17_73447MHz/2, 568, 0, 320, 312, 0, 200) |
| 1119 | MDRV_SCREEN_RAW_PARAMS(XTAL_17_73447MHz, 640+108, 0, 640, 480, 0, 400) //TODO: fix this |
| 1066 | 1120 | MDRV_PALETTE_LENGTH(0x200+4096) // TODO: it needs more than this |
| 1067 | 1121 | MDRV_PALETTE_INIT(mz2500) |
| 1068 | 1122 | |