src/mess/drivers/mz2500.c
| r7653 | r7654 | |
| 2 | 2 | |
| 3 | 3 | Sharp MZ-2500 (c) 1985 Sharp Corporation |
| 4 | 4 | |
| 5 | | 26/03/2010 Skeleton driver. |
| 5 | preliminary driver by Angelo Salese |
| 6 | 6 | |
| 7 | 7 | memory map: |
| 8 | 8 | |
| 9 | 9 | 0x00000-0x3ffff Work RAM |
| 10 | 10 | 0x40000-0x5ffff CG RAM (bitswapped!) |
| 11 | | 0x60000-0x67fff NOP? |
| 11 | 0x60000-0x67fff "Read modify write" area (related to the CG RAM) |
| 12 | 12 | 0x68000-0x6ffff IPL ROM |
| 13 | 13 | 0x70000-0x71fff TVRAM |
| 14 | 14 | 0x72000-0x73fff PCG / Kanji RAM |
| r7653 | r7654 | |
| 23 | 23 | #include "emu.h" |
| 24 | 24 | #include "cpu/z80/z80.h" |
| 25 | 25 | |
| 26 | /* machine stuff */ |
| 26 | 27 | static UINT8 bank_val[8],bank_addr; |
| 28 | static UINT8 irq_sel,irq_vector[4]; |
| 27 | 29 | |
| 30 | /* video stuff*/ |
| 31 | static UINT8 text_reg[0x100], text_reg_index; |
| 32 | |
| 28 | 33 | static VIDEO_START( mz2500 ) |
| 29 | 34 | { |
| 30 | 35 | } |
| 31 | 36 | |
| 32 | 37 | static VIDEO_UPDATE( mz2500 ) |
| 33 | 38 | { |
| 39 | UINT8 *vram = memory_region(screen->machine, "maincpu"); |
| 40 | int x,y,count; |
| 41 | const gfx_element *gfx = screen->machine->gfx[0]; |
| 42 | |
| 43 | count = 0x70000; |
| 44 | |
| 45 | for (y=0;y<32;y+=2) |
| 46 | { |
| 47 | for (x=0;x<32;x++) |
| 48 | { |
| 49 | int tile = vram[count+0x000] & 0xfe; |
| 50 | //int attr = vram[count+0x800]; |
| 51 | int tile_bank = vram[count+0x1000] & 0x3f; |
| 52 | |
| 53 | tile|= tile_bank << 8; |
| 54 | |
| 55 | drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*8,(y)*8); |
| 56 | drawgfx_opaque(bitmap,cliprect,gfx,tile+1,0,0,0,x*8,(y+1)*8); |
| 57 | |
| 58 | count++; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | |
| 34 | 63 | return 0; |
| 35 | 64 | } |
| 36 | 65 | |
| r7653 | r7654 | |
| 63 | 92 | |
| 64 | 93 | bank_val[bank_addr] = data & 0x3f; |
| 65 | 94 | |
| 66 | | printf("%s %02x\n",bank_name[bank_addr],bank_val[bank_addr]*2); |
| 95 | // printf("%s %02x\n",bank_name[bank_addr],bank_val[bank_addr]*2); |
| 67 | 96 | |
| 68 | 97 | memory_set_bankptr(space->machine, bank_name[bank_addr], &ROM[bank_val[bank_addr]*0x2000]); |
| 69 | 98 | |
| r7653 | r7654 | |
| 71 | 100 | bank_addr&=7; |
| 72 | 101 | } |
| 73 | 102 | |
| 103 | static READ8_HANDLER( mz2500_crtc_r ) |
| 104 | { |
| 105 | static UINT8 vblank_bit, hblank_bit; |
| 74 | 106 | |
| 107 | /* TODO */ |
| 108 | vblank_bit^= 1;//video_screen_get_vblank(space->machine->primary_screen) ? 0 : 1; |
| 109 | hblank_bit = video_screen_get_hblank(space->machine->primary_screen) ? 0 : 2; |
| 110 | |
| 111 | return vblank_bit | hblank_bit; |
| 112 | } |
| 113 | |
| 114 | static WRITE8_HANDLER( mz2500_crtc_w ) |
| 115 | { |
| 116 | switch(offset) |
| 117 | { |
| 118 | case 0: text_reg_index = data; break; |
| 119 | case 1: |
| 120 | text_reg[text_reg_index] = data; |
| 121 | //printf("[%02x]<- %02x\n",text_reg[text_reg_index],text_reg_index); |
| 122 | break; |
| 123 | case 2: /* CG MASK reg */ break; |
| 124 | case 3: |
| 125 | /* Font size reg */ |
| 126 | printf("%02x FONT\n",data); |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | static WRITE8_HANDLER( mz2500_irq_sel_w ) |
| 132 | { |
| 133 | irq_sel = data; |
| 134 | // FIXME: bit 0-3 are irq masks? |
| 135 | // printf("%02x\n",irq_sel); |
| 136 | } |
| 137 | |
| 138 | static WRITE8_HANDLER( mz2500_irq_data_w ) |
| 139 | { |
| 140 | if(irq_sel & 0x80) |
| 141 | irq_vector[0] = data; //CRTC |
| 142 | if(irq_sel & 0x40) |
| 143 | irq_vector[1] = data; //i8253 |
| 144 | if(irq_sel & 0x20) |
| 145 | irq_vector[2] = data; //printer |
| 146 | if(irq_sel & 0x10) |
| 147 | irq_vector[3] = data; //RP5c15 |
| 148 | } |
| 149 | |
| 75 | 150 | static ADDRESS_MAP_START(mz2500_map, ADDRESS_SPACE_PROGRAM, 8) |
| 76 | 151 | AM_RANGE(0x0000, 0x1fff) AM_RAMBANK("bank0") |
| 77 | 152 | AM_RANGE(0x2000, 0x3fff) AM_RAMBANK("bank1") |
| r7653 | r7654 | |
| 83 | 158 | AM_RANGE(0xe000, 0xffff) AM_RAMBANK("bank7") |
| 84 | 159 | ADDRESS_MAP_END |
| 85 | 160 | |
| 161 | #if 0 |
| 162 | |
| 163 | static READ8_HANDLER( kludge_r ) |
| 164 | { |
| 165 | return mame_rand(space->machine); |
| 166 | } |
| 167 | #endif |
| 168 | |
| 86 | 169 | static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8) |
| 87 | 170 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 88 | 171 | // AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w) |
| r7653 | r7654 | |
| 99 | 182 | AM_RANGE(0xb5, 0xb5) AM_READWRITE(mz2500_bank_data_r,mz2500_bank_data_w) |
| 100 | 183 | // AM_RANGE(0xb8, 0xb9) AM_READWRITE(kanji_r,kanji_w) |
| 101 | 184 | // AM_RANGE(0xbc, 0xbd) AM_READWRITE(crtc_r,crtc_w) |
| 102 | | // AM_RANGE(0xc6, 0xc7) AM_WRITE(irq_w) |
| 185 | AM_RANGE(0xc6, 0xc6) AM_WRITE(mz2500_irq_sel_w) |
| 186 | AM_RANGE(0xc7, 0xc7) AM_WRITE(mz2500_irq_data_w) |
| 103 | 187 | // AM_RANGE(0xc8, 0xc9) AM_READWRITE(opn_r,opn_w) |
| 104 | 188 | // AM_RANGE(0xca, 0xca) AM_READWRITE(voice_r,voice_w) |
| 105 | 189 | // AM_RANGE(0xcc, 0xcc) AM_READWRITE(calendar_r,calendar_w) |
| r7653 | r7654 | |
| 111 | 195 | // AM_RANGE(0xe8, 0xeb) AM_READWRITE(pio1_r,pio1_w) |
| 112 | 196 | // AM_RANGE(0xef, 0xef) AM_READWRITE(joystick_r,joystick_w) |
| 113 | 197 | // AM_RANGE(0xf0, 0xf3) AM_WRITE(timer_w) |
| 114 | | // AM_RANGE(0xf4, 0xf7) AM_READWRITE(crtc_r,crtc_w) |
| 198 | AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_r) AM_WRITE(mz2500_crtc_w) |
| 115 | 199 | // AM_RANGE(0xf8, 0xf9) AM_READWRITE(extrom_r,extrom_w) |
| 116 | 200 | ADDRESS_MAP_END |
| 117 | 201 | |
| r7653 | r7654 | |
| 141 | 225 | memory_set_bankptr(machine, "bank5", &ROM[bank_val[5]*0x2000]); |
| 142 | 226 | memory_set_bankptr(machine, "bank6", &ROM[bank_val[6]*0x2000]); |
| 143 | 227 | memory_set_bankptr(machine, "bank7", &ROM[bank_val[7]*0x2000]); |
| 228 | |
| 229 | irq_vector[0] = 0xef; /* RST 28h - vblank */ |
| 144 | 230 | } |
| 145 | 231 | |
| 146 | 232 | static const gfx_layout mz2500_cg_layout = |
| 147 | 233 | { |
| 148 | 234 | 8, 8, /* 8 x 8 graphics */ |
| 149 | | 256, /* 512 codes */ |
| 235 | RGN_FRAC(1,1), /* 512 codes */ |
| 150 | 236 | 1, /* 1 bit per pixel */ |
| 151 | 237 | { 0 }, /* no bitplanes */ |
| 152 | 238 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| r7653 | r7654 | |
| 169 | 255 | static const gfx_layout mz2500_16_layout = |
| 170 | 256 | { |
| 171 | 257 | 16, 16, /* 16 x 16 graphics */ |
| 172 | | 8192, /* 8192 codes */ |
| 258 | RGN_FRAC(1,1), /* 8192 codes */ |
| 173 | 259 | 1, /* 1 bit per pixel */ |
| 174 | 260 | { 0 }, /* no bitplanes */ |
| 175 | 261 | { 0, 1, 2, 3, 4, 5, 6, 7, 128, 129, 130, 131, 132, 133, 134, 135 }, |
| r7653 | r7654 | |
| 178 | 264 | }; |
| 179 | 265 | |
| 180 | 266 | static GFXDECODE_START( mz2500 ) |
| 181 | | GFXDECODE_ENTRY("cgrom", 0, mz2500_cg_layout, 0, 256) |
| 267 | GFXDECODE_ENTRY("gfx1", 0, mz2500_cg_layout, 0, 256) |
| 182 | 268 | GFXDECODE_ENTRY("gfx1", 0x4400, mz2500_8_layout, 0, 256) // for viewer only |
| 183 | 269 | GFXDECODE_ENTRY("gfx1", 0, mz2500_16_layout, 0, 256) // for viewer only |
| 184 | 270 | GFXDECODE_END |
| 185 | 271 | |
| 272 | static INTERRUPT_GEN( mz2500_vbl ) |
| 273 | { |
| 274 | cpu_set_input_line_and_vector(device, 0, HOLD_LINE, irq_vector[0]); |
| 275 | } |
| 276 | |
| 186 | 277 | static MACHINE_DRIVER_START( mz2500 ) |
| 187 | 278 | /* basic machine hardware */ |
| 188 | 279 | MDRV_CPU_ADD("maincpu", Z80, 6000000) |
| 189 | 280 | MDRV_CPU_PROGRAM_MAP(mz2500_map) |
| 190 | 281 | MDRV_CPU_IO_MAP(mz2500_io) |
| 282 | MDRV_CPU_VBLANK_INT("screen", mz2500_vbl) |
| 191 | 283 | |
| 192 | 284 | MDRV_MACHINE_RESET(mz2500) |
| 193 | 285 | |
| r7653 | r7654 | |
| 212 | 304 | ROM_LOAD( "ipl.rom", 0x00000, 0x8000, CRC(7a659f20) SHA1(ccb3cfdf461feea9db8d8d3a8815f7e345d274f7) ) |
| 213 | 305 | ROM_RELOAD( 0x68000, 0x8000 ) |
| 214 | 306 | |
| 307 | /* this is probably an hand made ROM, will be removed in the end ...*/ |
| 215 | 308 | ROM_REGION( 0x1000, "cgrom", 0 ) |
| 216 | 309 | ROM_LOAD( "cg.rom", 0x0000, 0x0800, CRC(a082326f) SHA1(dfa1a797b2159838d078650801c7291fa746ad81) ) |
| 217 | 310 | |