src/mame/drivers/genesis.c
| r6094 | r6095 | |
| 1 | | /* Some Generic Sega Genesis stuff used by Megatech / Megaplay etc. */ |
| 2 | | |
| 3 | | /* |
| 4 | | |
| 5 | | Genesis hardware games are in |
| 6 | | |
| 7 | | megatech.c |
| 8 | | megaplay.c |
| 9 | | gene_sm.c |
| 10 | | segac2.c |
| 11 | | |
| 12 | | */ |
| 13 | | |
| 14 | | #include "driver.h" |
| 15 | | #include "cpu/z80/z80.h" |
| 16 | | #include "cpu/m68000/m68000.h" |
| 17 | | #include "sound/2612intf.h" |
| 18 | | #include "sound/sn76496.h" |
| 19 | | |
| 20 | | #include "genesis.h" |
| 21 | | |
| 22 | | #define MASTER_CLOCK 53693100 |
| 23 | | |
| 24 | | |
| 25 | | /******************** Sega Genesis ******************************/ |
| 26 | | |
| 27 | | /* Genesis based */ |
| 28 | | static UINT32 z80_68000_latch = 0; |
| 29 | | static UINT32 z80_latch_bitcount = 0; |
| 30 | | |
| 31 | | /* interrupt states */ |
| 32 | | static UINT8 irq2_int; /* INT2 */ |
| 33 | | static UINT8 scanline_int; /* INT4 - programmable */ |
| 34 | | static UINT8 vblank_int; /* INT6 - on every VBLANK */ |
| 35 | | |
| 36 | | static emu_timer * scan_timer; |
| 37 | | |
| 38 | | |
| 39 | | static int z80running; |
| 40 | | UINT16 *genesis_68k_ram; |
| 41 | | UINT8 *genesis_z80_ram; |
| 42 | | |
| 43 | | |
| 44 | | |
| 45 | | /****************************************************************************** |
| 46 | | Interrupt handling |
| 47 | | ******************************************************************************* |
| 48 | | |
| 49 | | The Genesis uses 2 Different Interrupts, IRQ4 and IRQ6. |
| 50 | | The C2 system uses IRQ2 as well. |
| 51 | | |
| 52 | | IRQ6 = Vblank, this happens after the last visible line of the display has |
| 53 | | been drawn (after line 224) |
| 54 | | |
| 55 | | IRQ4 = H-Int, this happens based upon the value in H-Int Counter. If the |
| 56 | | Horizontal Interrupt is enabled and the Counter Value = 0 there |
| 57 | | will be a Level 4 Interrupt Triggered |
| 58 | | |
| 59 | | IRQ2 = sound int, generated by the YM3438 |
| 60 | | |
| 61 | | -------- |
| 62 | | |
| 63 | | More H-Counter Information: |
| 64 | | |
| 65 | | Providing Horizontal Interrupts are active the H-Counter will be loaded |
| 66 | | with the value stored in register #10 (0x0A) at the following times: |
| 67 | | (1) At the top of the display, before drawing the first line |
| 68 | | (2) When the counter has expired |
| 69 | | (3) During the VBlank Period (lines 224-261) |
| 70 | | The Counter is decreased by 1 after every line. |
| 71 | | |
| 72 | | ******************************************************************************/ |
| 73 | | |
| 74 | | /* call this whenever the interrupt state has changed */ |
| 75 | | static void update_interrupts(running_machine *machine) |
| 76 | | { |
| 77 | | cputag_set_input_line(machine, "maincpu", 2, irq2_int ? ASSERT_LINE : CLEAR_LINE); |
| 78 | | cputag_set_input_line(machine, "maincpu", 4, scanline_int ? ASSERT_LINE : CLEAR_LINE); |
| 79 | | cputag_set_input_line(machine, "maincpu", 6, vblank_int ? ASSERT_LINE : CLEAR_LINE); |
| 80 | | } |
| 81 | | |
| 82 | | |
| 83 | | /* timer callback to turn off the IRQ4 signal after a short while */ |
| 84 | | static TIMER_CALLBACK( vdp_int4_off ) |
| 85 | | { |
| 86 | | scanline_int = 0; |
| 87 | | update_interrupts(machine); |
| 88 | | } |
| 89 | | |
| 90 | | |
| 91 | | /* timer callback to handle reloading the H counter and generate IRQ4 */ |
| 92 | | static TIMER_CALLBACK( vdp_reload_counter ) |
| 93 | | { |
| 94 | | int scanline = param; |
| 95 | | |
| 96 | | /* generate an int if they're enabled */ |
| 97 | | if (genesis_vdp_regs[0] & 0x10)/* && !(misc_io_data[7] & 0x10))*/ |
| 98 | | if (scanline != 0 || genesis_vdp_regs[10] == 0) |
| 99 | | { |
| 100 | | scanline_int = 1; |
| 101 | | update_interrupts(machine); |
| 102 | | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline + 1, 0), NULL, 0, vdp_int4_off); |
| 103 | | } |
| 104 | | |
| 105 | | /* advance to the next scanline */ |
| 106 | | /* behavior 2: 0 count means interrupt after one scanline */ |
| 107 | | /* (this behavior matches the Sega C2 emulator) */ |
| 108 | | scanline += genesis_vdp_regs[10] + 1; |
| 109 | | if (scanline >= 224) |
| 110 | | scanline = 0; |
| 111 | | |
| 112 | | /* set a timer */ |
| 113 | | timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 320), scanline); |
| 114 | | } |
| 115 | | |
| 116 | | |
| 117 | | /* timer callback to turn off the IRQ6 signal after a short while */ |
| 118 | | static TIMER_CALLBACK( vdp_int6_off ) |
| 119 | | { |
| 120 | | vblank_int = 0; |
| 121 | | update_interrupts(machine); |
| 122 | | } |
| 123 | | |
| 124 | | |
| 125 | | /* interrupt callback to generate the VBLANK interrupt */ |
| 126 | | INTERRUPT_GEN( genesis_vblank_interrupt ) |
| 127 | | { |
| 128 | | /* generate the interrupt */ |
| 129 | | vblank_int = 1; |
| 130 | | update_interrupts(device->machine); |
| 131 | | |
| 132 | | /* set a timer to turn it off */ |
| 133 | | timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, video_screen_get_vpos(device->machine->primary_screen), 22), NULL, 0, vdp_int6_off); |
| 134 | | } |
| 135 | | |
| 136 | | |
| 137 | | /* interrupt callback to generate the YM3438 interrupt */ |
| 138 | | void genesis_irq2_interrupt(const device_config *device, int state) |
| 139 | | { |
| 140 | | irq2_int = state; |
| 141 | | update_interrupts(device->machine); |
| 142 | | } |
| 143 | | |
| 144 | | |
| 145 | | MACHINE_START( genesis ) |
| 146 | | { |
| 147 | | state_save_register_global(machine, irq2_int); |
| 148 | | state_save_register_global(machine, scanline_int); |
| 149 | | state_save_register_global(machine, vblank_int); |
| 150 | | } |
| 151 | | |
| 152 | | |
| 153 | | MACHINE_RESET( genesis ) |
| 154 | | { |
| 155 | | /* C2 doesn't have a Z80, so we can't just assume */ |
| 156 | | if (cputag_get_cpu(machine, "genesis_snd_z80") != NULL && cpu_get_type(cputag_get_cpu(machine, "genesis_snd_z80")) == CPU_Z80) |
| 157 | | { |
| 158 | | /* the following ensures that the Z80 begins without running away from 0 */ |
| 159 | | /* 0x76 is just a forced 'halt' as soon as the CPU is initially run */ |
| 160 | | genesis_z80_ram[0] = 0x76; |
| 161 | | genesis_z80_ram[0x38] = 0x76; |
| 162 | | |
| 163 | | cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_HALT, ASSERT_LINE); |
| 164 | | |
| 165 | | z80running = 0; |
| 166 | | } |
| 167 | | |
| 168 | | logerror("Machine init\n"); |
| 169 | | |
| 170 | | /* set the first scanline 0 timer to go off */ |
| 171 | | scan_timer = timer_alloc(machine, vdp_reload_counter, NULL); |
| 172 | | timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 320), 0); |
| 173 | | } |
| 174 | | |
| 175 | | |
| 176 | | /* from MESS */ |
| 177 | | READ16_HANDLER(genesis_ctrl_r) |
| 178 | | { |
| 179 | | /* int returnval; */ |
| 180 | | |
| 181 | | /* logerror("genesis_ctrl_r %x\n", offset); */ |
| 182 | | switch (offset) |
| 183 | | { |
| 184 | | case 0: /* DRAM mode is write only */ |
| 185 | | return 0xffff; |
| 186 | | case 0x80: /* return Z80 CPU Function Stop Accessible or not */ |
| 187 | | /* logerror("Returning z80 state\n"); */ |
| 188 | | return (z80running ? 0x0100 : 0x0); |
| 189 | | case 0x100: /* Z80 CPU Reset - write only */ |
| 190 | | return 0xffff; |
| 191 | | } |
| 192 | | return 0x00; |
| 193 | | |
| 194 | | } |
| 195 | | |
| 196 | | /* from MESS */ |
| 197 | | WRITE16_HANDLER(genesis_ctrl_w) |
| 198 | | { |
| 199 | | data &= mem_mask; |
| 200 | | |
| 201 | | /* logerror("genesis_ctrl_w %x, %x\n", offset, data); */ |
| 202 | | |
| 203 | | switch (offset) |
| 204 | | { |
| 205 | | case 0: /* set DRAM mode... we have to ignore this for production cartridges */ |
| 206 | | return; |
| 207 | | case 0x80: /* Z80 BusReq */ |
| 208 | | if (data == 0x100) |
| 209 | | { |
| 210 | | z80running = 0; |
| 211 | | cputag_set_input_line(space->machine, "genesis_snd_z80", INPUT_LINE_HALT, ASSERT_LINE); /* halt Z80 */ |
| 212 | | /* logerror("z80 stopped by 68k BusReq\n"); */ |
| 213 | | } |
| 214 | | else |
| 215 | | { |
| 216 | | z80running = 1; |
| 217 | | // memory_set_bankptr(space->machine, 1, &genesis_z80_ram[0]); |
| 218 | | |
| 219 | | cputag_set_input_line(space->machine, "genesis_snd_z80", INPUT_LINE_HALT, CLEAR_LINE); |
| 220 | | /* logerror("z80 started, BusReq ends\n"); */ |
| 221 | | } |
| 222 | | return; |
| 223 | | case 0x100: /* Z80 CPU Reset */ |
| 224 | | if (data == 0x00) |
| 225 | | { |
| 226 | | cputag_set_input_line(space->machine, "genesis_snd_z80", INPUT_LINE_HALT, ASSERT_LINE); |
| 227 | | cputag_set_input_line(space->machine, "genesis_snd_z80", INPUT_LINE_RESET, PULSE_LINE); |
| 228 | | |
| 229 | | cputag_set_input_line(space->machine, "genesis_snd_z80", INPUT_LINE_HALT, ASSERT_LINE); |
| 230 | | /* logerror("z80 reset, ram is %p\n", &genesis_z80_ram[0]); */ |
| 231 | | z80running = 0; |
| 232 | | return; |
| 233 | | } |
| 234 | | else |
| 235 | | { |
| 236 | | /* logerror("z80 out of reset\n"); */ |
| 237 | | } |
| 238 | | return; |
| 239 | | } |
| 240 | | } |
| 241 | | |
| 242 | | READ16_HANDLER ( genesis_68k_to_z80_r ) |
| 243 | | { |
| 244 | | offset *= 2; |
| 245 | | offset &= 0x7fff; |
| 246 | | |
| 247 | | /* Shared Ram */ |
| 248 | | if ((offset >= 0x0000) && (offset <= 0x3fff)) |
| 249 | | { |
| 250 | | offset &=0x1fff; |
| 251 | | // logerror("soundram_r returning %x\n",(gen_z80_shared[offset] << 8) + gen_z80_shared[offset+1]); |
| 252 | | return (genesis_z80_ram[offset] << 8) + genesis_z80_ram[offset+1]; |
| 253 | | } |
| 254 | | |
| 255 | | |
| 256 | | /* YM2610 */ |
| 257 | | if ((offset >= 0x4000) && (offset <= 0x5fff)) |
| 258 | | { |
| 259 | | if (ACCESSING_BITS_0_7) |
| 260 | | offset += 1; |
| 261 | | return ym3438_r(devtag_get_device(space->machine, "ym"), offset); |
| 262 | | } |
| 263 | | |
| 264 | | /* Bank Register */ |
| 265 | | if ((offset >= 0x6000) && (offset <= 0x60ff)) |
| 266 | | { |
| 267 | | |
| 268 | | } |
| 269 | | |
| 270 | | /* Unused / Illegal */ |
| 271 | | if ((offset >= 0x6100) && (offset <= 0x7eff)) |
| 272 | | { |
| 273 | | /* nothing */ |
| 274 | | } |
| 275 | | |
| 276 | | /* VDP */ |
| 277 | | if ((offset >= 0x7f00) && (offset <= 0x7fff)) |
| 278 | | { |
| 279 | | |
| 280 | | } |
| 281 | | |
| 282 | | return 0x0000; |
| 283 | | } |
| 284 | | |
| 285 | | |
| 286 | | READ16_HANDLER ( megaplay_68k_to_z80_r ) |
| 287 | | { |
| 288 | | offset *= 2; |
| 289 | | offset &= 0x7fff; |
| 290 | | |
| 291 | | /* Shared Ram */ |
| 292 | | if ((offset >= 0x0000) && (offset <= 0x1fff)) |
| 293 | | { |
| 294 | | offset &=0x1fff; |
| 295 | | // logerror("soundram_r returning %x\n",(gen_z80_shared[offset] << 8) + gen_z80_shared[offset+1]); |
| 296 | | return (genesis_z80_ram[offset] << 8) + genesis_z80_ram[offset+1]; |
| 297 | | } |
| 298 | | |
| 299 | | if ((offset >= 0x2000) && (offset <= 0x3fff)) |
| 300 | | { |
| 301 | | offset &=0x1fff; |
| 302 | | // if(offset == 0) /* this read handler was used around MAME0.82 to read DSWB. Now it's (DSW0 & 0xff) */ |
| 303 | | // return (input_port_read(space->machine, "DSW0") << 8) ^ 0xff00; |
| 304 | | return (ic36_ram[offset] << 8) + ic36_ram[offset+1]; |
| 305 | | } |
| 306 | | |
| 307 | | |
| 308 | | /* YM2610 */ |
| 309 | | if ((offset >= 0x4000) && (offset <= 0x5fff)) |
| 310 | | { |
| 311 | | if (ACCESSING_BITS_0_7) |
| 312 | | offset += 1; |
| 313 | | return ym3438_r(devtag_get_device(space->machine, "ym"), offset); |
| 314 | | } |
| 315 | | |
| 316 | | /* Bank Register */ |
| 317 | | if ((offset >= 0x6000) && (offset <= 0x60ff)) |
| 318 | | { |
| 319 | | |
| 320 | | } |
| 321 | | |
| 322 | | /* Unused / Illegal */ |
| 323 | | if ((offset >= 0x6100) && (offset <= 0x7eff)) |
| 324 | | { |
| 325 | | /* nothing */ |
| 326 | | } |
| 327 | | |
| 328 | | /* VDP */ |
| 329 | | if ((offset >= 0x7f00) && (offset <= 0x7fff)) |
| 330 | | { |
| 331 | | |
| 332 | | } |
| 333 | | |
| 334 | | return 0x0000; |
| 335 | | } |
| 336 | | |
| 337 | | WRITE16_HANDLER ( genesis_68k_to_z80_w ) |
| 338 | | { |
| 339 | | offset *= 2; |
| 340 | | offset &= 0x7fff; |
| 341 | | |
| 342 | | /* Shared Ram */ |
| 343 | | if ((offset >= 0x0000) && (offset <= 0x3fff)) |
| 344 | | { |
| 345 | | offset &=0x1fff; |
| 346 | | |
| 347 | | if (ACCESSING_BITS_0_7) genesis_z80_ram[offset+1] = data & 0xff; |
| 348 | | if (ACCESSING_BITS_8_15) genesis_z80_ram[offset] = (data >> 8) & 0xff; |
| 349 | | } |
| 350 | | |
| 351 | | |
| 352 | | /* YM2612 */ |
| 353 | | if ((offset >= 0x4000) && (offset <= 0x5fff)) |
| 354 | | { |
| 355 | | const device_config *ym = devtag_get_device(space->machine, "ym"); |
| 356 | | switch (offset & 3) |
| 357 | | { |
| 358 | | case 0: |
| 359 | | if (ACCESSING_BITS_8_15) ym3438_control_port_a_w (ym, 0, (data >> 8) & 0xff); |
| 360 | | else ym3438_data_port_a_w (ym, 0, (data >> 0) & 0xff); |
| 361 | | break; |
| 362 | | case 2: |
| 363 | | if (ACCESSING_BITS_8_15) ym3438_control_port_b_w (ym, 0, (data >> 8) & 0xff); |
| 364 | | else ym3438_data_port_b_w (ym, 0, (data >> 0) & 0xff); |
| 365 | | break; |
| 366 | | } |
| 367 | | } |
| 368 | | |
| 369 | | /* Bank Register */ |
| 370 | | if ((offset >= 0x6000) && (offset <= 0x60ff)) |
| 371 | | { |
| 372 | | |
| 373 | | } |
| 374 | | |
| 375 | | /* Unused / Illegal */ |
| 376 | | if ((offset >= 0x6100) && (offset <= 0x7eff)) |
| 377 | | { |
| 378 | | /* nothing */ |
| 379 | | } |
| 380 | | |
| 381 | | /* VDP */ |
| 382 | | if ((offset >= 0x7f00) && (offset <= 0x7fff)) |
| 383 | | { |
| 384 | | offset &= 0x1f; |
| 385 | | |
| 386 | | if ( (offset >= 0x10) && (offset <=0x17) ) |
| 387 | | { |
| 388 | | const device_config *sn = devtag_get_device(space->machine, "sn"); |
| 389 | | if (ACCESSING_BITS_0_7) sn76496_w(sn, 0, data & 0xff); |
| 390 | | if (ACCESSING_BITS_8_15) sn76496_w(sn, 0, (data >>8) & 0xff); |
| 391 | | } |
| 392 | | |
| 393 | | } |
| 394 | | } |
| 395 | | |
| 396 | | /* Gen I/O */ |
| 397 | | |
| 398 | | /* |
| 399 | | cgfm info |
| 400 | | |
| 401 | | $A10001 Version |
| 402 | | $A10003 Port A data |
| 403 | | $A10005 Port B data |
| 404 | | $A10007 Port C data |
| 405 | | $A10009 Port A control |
| 406 | | $A1000B Port B control |
| 407 | | $A1000D Port C control |
| 408 | | $A1000F Port A TxData |
| 409 | | $A10011 Port A RxData |
| 410 | | $A10013 Port A serial control |
| 411 | | $A10015 Port B TxData |
| 412 | | $A10017 Port B RxData |
| 413 | | $A10019 Port B serial control |
| 414 | | $A1001B Port C TxData |
| 415 | | $A1001D Port C RxData |
| 416 | | $A1001F Port C serial control |
| 417 | | |
| 418 | | */ |
| 419 | | |
| 420 | | UINT16 *genesis_io_ram; |
| 421 | | |
| 422 | | /* This handler is still used in hshavoc.c & topshoot.c ; */ |
| 423 | | /* megaplay.c uses a local copy 'OLD_megaplay_genesis_io_w' */ |
| 424 | | WRITE16_HANDLER ( genesis_io_w ) |
| 425 | | { |
| 426 | | // logerror ("write io offset :%02x data %04x PC: 0x%06x\n",offset,data,cpu_get_previouspc(space->cpu)); |
| 427 | | |
| 428 | | switch (offset) |
| 429 | | { |
| 430 | | case 0x00: |
| 431 | | /*??*/ |
| 432 | | break; |
| 433 | | |
| 434 | | case 0x01:/* port A data */ |
| 435 | | genesis_io_ram[offset] = (data & (genesis_io_ram[0x04])) | (genesis_io_ram[offset] & ~(genesis_io_ram[0x04])); |
| 436 | | break; |
| 437 | | |
| 438 | | case 0x02: /* port B data */ |
| 439 | | genesis_io_ram[offset] = (data & (genesis_io_ram[0x05])) | (genesis_io_ram[offset] & ~(genesis_io_ram[0x05])); |
| 440 | | break; |
| 441 | | |
| 442 | | case 0x03: /* port C data */ |
| 443 | | genesis_io_ram[offset] = (data & (genesis_io_ram[0x06])) | (genesis_io_ram[offset] & ~(genesis_io_ram[0x06])); |
| 444 | | bios_6204 = data & 0x07; |
| 445 | | break; |
| 446 | | |
| 447 | | case 0x04: /* port A control */ |
| 448 | | genesis_io_ram[offset] = data; |
| 449 | | break; |
| 450 | | |
| 451 | | case 0x05: /* port B control */ |
| 452 | | genesis_io_ram[offset] = data; |
| 453 | | break; |
| 454 | | |
| 455 | | case 0x06: /* port C control */ |
| 456 | | genesis_io_ram[offset] = data; |
| 457 | | break; |
| 458 | | |
| 459 | | case 0x07: /* port A TxData */ |
| 460 | | genesis_io_ram[offset] = data; |
| 461 | | break; |
| 462 | | |
| 463 | | default: |
| 464 | | genesis_io_ram[offset] = data; |
| 465 | | } |
| 466 | | |
| 467 | | } |
| 468 | | |
| 469 | | #if 0 |
| 470 | | static ADDRESS_MAP_START( genesis_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| 471 | | AM_RANGE(0x000000, 0x3fffff) AM_ROM /* Cartridge Program Rom */ |
| 472 | | AM_RANGE(0xa00000, 0xa0ffff) AM_READWRITE(genesis_68k_to_z80_r, genesis_68k_to_z80_w) |
| 473 | | AM_RANGE(0xa10000, 0xa1001f) AM_READWRITE(genesis_io_r, genesis_io_w) AM_BASE(&genesis_io_ram) /* Genesis Input */ |
| 474 | | AM_RANGE(0xa11000, 0xa11203) AM_WRITE(genesis_ctrl_w) |
| 475 | | AM_RANGE(0xc00000, 0xc0001f) AM_READWRITE(genesis_vdp_r, genesis_vdp_w) /* VDP Access */ |
| 476 | | AM_RANGE(0xfe0000, 0xfeffff) AM_RAMBANK(3) /* Main Ram */ |
| 477 | | AM_RANGE(0xff0000, 0xffffff) AM_RAM AM_BASE(&genesis_68k_ram) /* Main Ram */ |
| 478 | | ADDRESS_MAP_END |
| 479 | | #endif |
| 480 | | |
| 481 | | /* Z80 Sound Hardware - based on MESS code, to be improved, it can do some strange things */ |
| 482 | | |
| 483 | | |
| 484 | | static WRITE8_HANDLER ( genesis_bank_select_w ) /* note value will be meaningless unless all bits are correctly set in */ |
| 485 | | { |
| 486 | | if (offset !=0 ) return; |
| 487 | | // if (!z80running) logerror("undead Z80 latch write!\n"); |
| 488 | | if (z80_latch_bitcount == 0) z80_68000_latch = 0; |
| 489 | | |
| 490 | | z80_68000_latch = z80_68000_latch | ((( ((UINT8)data) & 0x01) << (15+z80_latch_bitcount))); |
| 491 | | logerror("value %x written to latch\n", data); |
| 492 | | z80_latch_bitcount++; |
| 493 | | if (z80_latch_bitcount == 9) |
| 494 | | { |
| 495 | | z80_latch_bitcount = 0; |
| 496 | | logerror("latch set, value %x\n", z80_68000_latch); |
| 497 | | } |
| 498 | | } |
| 499 | | |
| 500 | | READ8_HANDLER ( genesis_z80_r ) |
| 501 | | { |
| 502 | | offset += 0x4000; |
| 503 | | |
| 504 | | /* YM2610 */ |
| 505 | | if ((offset >= 0x4000) && (offset <= 0x5fff)) |
| 506 | | { |
| 507 | | return ym3438_r(devtag_get_device(space->machine, "ym"), offset); |
| 508 | | } |
| 509 | | |
| 510 | | /* Bank Register */ |
| 511 | | if ((offset >= 0x6000) && (offset <= 0x60ff)) |
| 512 | | { |
| 513 | | |
| 514 | | } |
| 515 | | |
| 516 | | /* Unused / Illegal */ |
| 517 | | if ((offset >= 0x6100) && (offset <= 0x7eff)) |
| 518 | | { |
| 519 | | /* nothing */ |
| 520 | | } |
| 521 | | |
| 522 | | /* VDP */ |
| 523 | | if ((offset >= 0x7f00) && (offset <= 0x7fff)) |
| 524 | | { |
| 525 | | |
| 526 | | } |
| 527 | | |
| 528 | | return 0x00; |
| 529 | | } |
| 530 | | |
| 531 | | WRITE8_HANDLER ( genesis_z80_w ) |
| 532 | | { |
| 533 | | offset += 0x4000; |
| 534 | | |
| 535 | | /* YM2610 */ |
| 536 | | if ((offset >= 0x4000) && (offset <= 0x5fff)) |
| 537 | | { |
| 538 | | ym3438_w(devtag_get_device(space->machine, "ym"), offset & 3, data); |
| 539 | | } |
| 540 | | |
| 541 | | /* Bank Register */ |
| 542 | | if ((offset >= 0x6000) && (offset <= 0x60ff)) |
| 543 | | { |
| 544 | | genesis_bank_select_w(space, offset & 0xff, data); |
| 545 | | } |
| 546 | | |
| 547 | | /* Unused / Illegal */ |
| 548 | | if ((offset >= 0x6100) && (offset <= 0x7eff)) |
| 549 | | { |
| 550 | | /* nothing */ |
| 551 | | } |
| 552 | | |
| 553 | | /* VDP */ |
| 554 | | if ((offset >= 0x7f00) && (offset <= 0x7fff)) |
| 555 | | { |
| 556 | | |
| 557 | | } |
| 558 | | } |
| 559 | | |
| 560 | | READ8_HANDLER ( genesis_z80_bank_r ) |
| 561 | | { |
| 562 | | int address = (z80_68000_latch) + (offset & 0x7fff); |
| 563 | | const UINT8 *base = memory_region(space->machine, "soundcpu"); |
| 564 | | |
| 565 | | if (!z80running) logerror("undead Z80->68000 read!\n"); |
| 566 | | |
| 567 | | if (z80_latch_bitcount != 0) logerror("reading whilst latch being set!\n"); |
| 568 | | |
| 569 | | logerror("z80 read from address %x\n", address); |
| 570 | | |
| 571 | | /* Read the data out of the 68k ROM */ |
| 572 | | if (base != NULL && address < 0x400000) return base[BYTE_XOR_BE(address)]; |
| 573 | | /* else read the data out of the 68k RAM */ |
| 574 | | // else if (address > 0xff0000) return genesis_68k_ram[BYTE_XOR_BE(offset)]; |
| 575 | | |
| 576 | | return -1; |
| 577 | | } |
| 578 | | |
| 579 | | |
| 580 | | #if 0 |
| 581 | | static ADDRESS_MAP_START( genesis_z80_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 582 | | AM_RANGE(0x0000, 0x1fff) AM_RAMBANK(1) AM_BASE(&genesis_z80_ram) |
| 583 | | AM_RANGE(0x2000, 0x3fff) AM_RAMBANK(2) /* mirror */ |
| 584 | | AM_RANGE(0x4000, 0x7fff) AM_READWRITE(genesis_z80_r, genesis_z80_w) |
| 585 | | AM_RANGE(0x8000, 0xffff) AM_READ(genesis_z80_bank_r) |
| 586 | | // AM_RANGE(0x8000, 0xffff) AM_WRITE(genesis_z80_bank_w) |
| 587 | | ADDRESS_MAP_END |
| 588 | | |
| 589 | | static MACHINE_DRIVER_START( genesis_base ) |
| 590 | | /*basic machine hardware */ |
| 591 | | MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK / 7) |
| 592 | | MDRV_CPU_PROGRAM_MAP(genesis_map) |
| 593 | | MDRV_CPU_VBLANK_INT("screen", genesis_vblank_interrupt) |
| 594 | | |
| 595 | | MDRV_CPU_ADD("soundcpu", Z80, MASTER_CLOCK / 15) |
| 596 | | MDRV_CPU_PROGRAM_MAP(genesis_z80_map) |
| 597 | | MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) /* from vdp at scanline 0xe0 */ |
| 598 | | |
| 599 | | MDRV_QUANTUM_TIME(HZ(6000)) |
| 600 | | |
| 601 | | MDRV_MACHINE_START(genesis) |
| 602 | | MDRV_MACHINE_RESET(genesis) |
| 603 | | |
| 604 | | /* video hardware */ |
| 605 | | MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS) |
| 606 | | |
| 607 | | MDRV_SCREEN_ADD("screen", RASTER) |
| 608 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 609 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 610 | | MDRV_SCREEN_SIZE(342,262) |
| 611 | | MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 223) |
| 612 | | |
| 613 | | MDRV_PALETTE_LENGTH(2048) |
| 614 | | |
| 615 | | MDRV_VIDEO_START(genesis) |
| 616 | | MDRV_VIDEO_UPDATE(genesis) |
| 617 | | |
| 618 | | /* sound hardware */ |
| 619 | | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 620 | | |
| 621 | | MDRV_SOUND_ADD("ym", YM3438, MASTER_CLOCK/7) |
| 622 | | MDRV_SOUND_ROUTE(0, "mono", 0.50) |
| 623 | | MDRV_SOUND_ROUTE(1, "mono", 0.50) |
| 624 | | MACHINE_DRIVER_END |
| 625 | | #endif |