trunk/src/mame/machine/megacd.c
r22015 | r22016 | |
4 | 4 | #include "sound/rf5c68.h" |
5 | 5 | |
6 | 6 | |
7 | | |
8 | | // the main MD emulation needs to know the state of these because it appears in the MD regs / affect DMA operations |
9 | | int sega_cd_connected = 0x00; |
10 | | |
11 | | |
12 | 7 | // not in the state because the IRQ_CALLBACK needs it, and that can't be a member function? |
13 | 8 | UINT16 a12000_halt_reset_reg = 0x0000; |
14 | 9 | |
r22015 | r22016 | |
1568 | 1563 | void sega_segacd_device::device_start() |
1569 | 1564 | { |
1570 | 1565 | _segacd_68k_cpu = machine().device<cpu_device>(":segacd:segacd_68k"); |
1571 | | sega_cd_connected = 1; |
1572 | 1566 | |
1573 | 1567 | segacd_gfx_conversion_timer = machine().device<timer_device>(":segacd:stamp_timer"); |
1574 | 1568 | segacd_irq3_timer = machine().device<timer_device>(":segacd:irq3_timer"); |
trunk/src/mame/machine/megadriv.c
r22015 | r22016 | |
33 | 33 | int genesis_other_hacks = 0; // misc hacks |
34 | 34 | |
35 | 35 | timer_device* megadriv_scanline_timer; |
36 | | cpu_device *_svp_cpu; |
37 | 36 | |
38 | 37 | struct genesis_z80_vars |
39 | 38 | { |
r22015 | r22016 | |
380 | 379 | |
381 | 380 | READ16_HANDLER( megadriv_68k_io_read ) |
382 | 381 | { |
| 382 | md_base_state *state = space.machine().driver_data<md_base_state>(); |
383 | 383 | UINT8 retdata; |
384 | 384 | |
385 | 385 | retdata = 0; |
r22015 | r22016 | |
401 | 401 | logerror("%06x read version register\n", space.device().safe_pc()); |
402 | 402 | retdata = megadrive_region_export<<7 | // Export |
403 | 403 | megadrive_region_pal<<6 | // NTSC |
404 | | (sega_cd_connected?0x00:0x20) | // 0x20 = no sega cd |
| 404 | (state->m_segacd ? 0x00 : 0x20) | // 0x20 = no sega cd |
405 | 405 | 0x00 | // Unused (Always 0) |
406 | 406 | 0x00 | // Bit 3 of Version Number |
407 | 407 | 0x00 | // Bit 2 of Version Number |
r22015 | r22016 | |
1201 | 1201 | return 0; // writeback not allowed |
1202 | 1202 | } |
1203 | 1203 | |
| 1204 | // the SVP introduces some kind of DMA 'lag', which we have to compensate for, this is obvious even on gfx DMAd from ROM (the Speedometer) |
| 1205 | // likewise segaCD, at least when reading wordram? we might need to check what mode we're in here.. |
| 1206 | UINT16 vdp_get_word_from_68k_mem_delayed(running_machine &machine, UINT32 source, address_space & space68k) |
| 1207 | { |
| 1208 | if (source <= 0x3fffff) |
| 1209 | { |
| 1210 | source -= 2; // compensate DMA lag |
| 1211 | return space68k.read_word(source); |
| 1212 | } |
| 1213 | else if ((source >= 0xe00000) && (source <= 0xffffff)) |
| 1214 | return space68k.read_word(source); |
| 1215 | else |
| 1216 | { |
| 1217 | printf("DMA Read unmapped %06x\n",source); |
| 1218 | return machine.rand(); |
| 1219 | } |
| 1220 | } |
| 1221 | |
1204 | 1222 | void md_base_state::megadriv_init_common() |
1205 | 1223 | { |
1206 | 1224 | /* Look to see if this system has the standard Sound Z80 */ |
r22015 | r22016 | |
1227 | 1245 | printf("32x SLAVE SH2 cpu found '%s'\n", _32x_slave_cpu->tag() ); |
1228 | 1246 | } |
1229 | 1247 | |
1230 | | _svp_cpu = machine().device<cpu_device>("svp"); |
1231 | | if (_svp_cpu != NULL) |
1232 | | { |
1233 | | printf("SVP (cpu) found '%s'\n", _svp_cpu->tag()); |
1234 | | } |
1235 | | |
1236 | 1248 | machine().device("maincpu")->execute().set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(md_base_state::genesis_int_callback),this)); |
1237 | 1249 | megadriv_backupram = NULL; |
1238 | 1250 | megadriv_backupram_length = 0; |
1239 | 1251 | |
1240 | 1252 | vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_default; |
1241 | 1253 | |
| 1254 | if (machine().device("svp")) |
| 1255 | { |
| 1256 | printf("SVP (cpu) found '%s'\n", machine().device("svp")->tag()); |
| 1257 | vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_delayed; |
| 1258 | } |
| 1259 | if (machine().device("segacd")) |
| 1260 | { |
| 1261 | printf("SegaCD found '%s'\n", machine().device("segacd")->tag()); |
| 1262 | vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_delayed; |
| 1263 | } |
| 1264 | |
1242 | 1265 | m68k_set_tas_callback(machine().device("maincpu"), megadriv_tas_callback); |
1243 | 1266 | |
1244 | 1267 | // the drivers which need 6 buttons pad set this to 1 in their init befare calling the megadrive init |
trunk/src/mame/machine/megavdp.c
r22015 | r22016 | |
9 | 9 | |
10 | 10 | #include "sound/sn76496.h" |
11 | 11 | |
12 | | extern cpu_device *_svp_cpu; |
13 | | extern int sega_cd_connected; |
14 | 12 | extern timer_device* megadriv_scanline_timer; |
15 | 13 | |
16 | 14 | |
17 | | |
18 | | |
19 | 15 | #define MAX_HPOSITION 480 |
20 | 16 | |
21 | 17 | |
r22015 | r22016 | |
470 | 466 | |
471 | 467 | UINT16 (*vdp_get_word_from_68k_mem)(running_machine &machine, UINT32 source, address_space& space68k); |
472 | 468 | |
| 469 | // if either SVP CPU or segaCD is present, there is a lag we have to compensate for |
| 470 | // hence, variants of this call will be defined in megadriv_init_common for segacd and svp |
473 | 471 | UINT16 vdp_get_word_from_68k_mem_default(running_machine &machine, UINT32 source, address_space & space68k) |
474 | 472 | { |
475 | 473 | // should we limit the valid areas here? |
r22015 | r22016 | |
478 | 476 | |
479 | 477 | //printf("vdp_get_word_from_68k_mem_default %08x\n", source); |
480 | 478 | |
481 | | if ( source <= 0x3fffff ) |
482 | | { |
483 | | if (_svp_cpu != NULL) |
484 | | { |
485 | | source -= 2; // the SVP introduces some kind of DMA 'lag', which we have to compensate for, this is obvious even on gfx DMAd from ROM (the Speedometer) |
486 | | } |
487 | | |
488 | | // likewise segaCD, at least when reading wordram? |
489 | | // we might need to check what mode we're in here.. |
490 | | if (sega_cd_connected) |
491 | | { |
492 | | source -= 2; |
493 | | } |
494 | | |
| 479 | if (source <= 0x3fffff) |
495 | 480 | return space68k.read_word(source); |
496 | | } |
497 | | else if (( source >= 0xe00000 ) && ( source <= 0xffffff )) |
498 | | { |
| 481 | else if ((source >= 0xe00000) && (source <= 0xffffff)) |
499 | 482 | return space68k.read_word(source); |
500 | | } |
501 | 483 | else |
502 | 484 | { |
503 | 485 | printf("DMA Read unmapped %06x\n",source); |
504 | 486 | return machine.rand(); |
505 | 487 | } |
506 | | |
507 | | |
508 | 488 | } |
509 | 489 | |
510 | 490 | /* Table from Charles Macdonald |
trunk/src/mame/includes/megadriv.h
r22015 | r22016 | |
25 | 25 | |
26 | 26 | #define MD_CPU_REGION_SIZE 0x800000 |
27 | 27 | |
28 | | extern int sega_cd_connected; |
29 | 28 | |
30 | | |
31 | 29 | /*----------- defined in machine/megadriv.c -----------*/ |
32 | 30 | |
33 | 31 | INPUT_PORTS_EXTERN( md_common ); |
r22015 | r22016 | |
41 | 39 | MACHINE_CONFIG_EXTERN( md_pal ); |
42 | 40 | MACHINE_CONFIG_EXTERN( md_bootleg ); // for topshoot.c & hshavoc.c |
43 | 41 | |
44 | | extern cpu_device *_svp_cpu; |
45 | | |
46 | 42 | extern UINT8 megatech_bios_port_cc_dc_r(running_machine &machine, int offset, int ctrl); |
47 | 43 | extern void megadriv_stop_scanline_timer(running_machine &machine); |
48 | 44 | |
r22015 | r22016 | |
85 | 81 | md_base_state(const machine_config &mconfig, device_type type, const char *tag) |
86 | 82 | : driver_device(mconfig, type, tag), |
87 | 83 | m_vdp(*this,"gen_vdp"), |
| 84 | m_segacd(*this,"segacd"), |
88 | 85 | m_megadrive_ram(*this,"megadrive_ram") |
89 | | { |
90 | | sega_cd_connected = 0; |
91 | | } |
| 86 | { } |
92 | 87 | required_device<sega_genesis_vdp_device> m_vdp; |
| 88 | optional_device<sega_segacd_device> m_segacd; |
93 | 89 | optional_shared_ptr<UINT16> m_megadrive_ram; |
94 | 90 | |
95 | 91 | DECLARE_DRIVER_INIT(megadriv_c2); |
trunk/src/mess/drivers/megadriv.c
r22015 | r22016 | |
271 | 271 | * |
272 | 272 | *************************************/ |
273 | 273 | |
| 274 | |
| 275 | UINT16 vdp_get_word_from_68k_mem_console(running_machine &machine, UINT32 source, address_space & space68k) |
| 276 | { |
| 277 | md_cons_state *state = machine.driver_data<md_cons_state>(); |
| 278 | |
| 279 | if (source <= 0x3fffff) |
| 280 | { |
| 281 | if (state->m_slotcart->get_type() == SEGA_SVP) |
| 282 | { |
| 283 | source -= 2; // the SVP introduces some kind of DMA 'lag', which we have to compensate for, this is obvious even on gfx DMAd from ROM (the Speedometer) |
| 284 | } |
| 285 | return space68k.read_word(source); |
| 286 | } |
| 287 | else if ((source >= 0xe00000) && (source <= 0xffffff)) |
| 288 | return space68k.read_word(source); |
| 289 | else |
| 290 | { |
| 291 | printf("DMA Read unmapped %06x\n",source); |
| 292 | return machine.rand(); |
| 293 | } |
| 294 | } |
| 295 | |
274 | 296 | static MACHINE_START( ms_megadriv ) |
275 | 297 | { |
276 | 298 | md_cons_state *state = machine.driver_data<md_cons_state>(); |
277 | 299 | |
278 | 300 | mess_init_6buttons_pad(machine); |
279 | | |
| 301 | |
280 | 302 | // small hack, until SVP is converted to be a slot device |
281 | 303 | if (machine.device<cpu_device>("svp") != NULL) |
282 | 304 | svp_init(machine); |
283 | 305 | else |
284 | | { |
| 306 | { |
| 307 | vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_console; |
285 | 308 | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x000000, 0x7fffff, read16_delegate(FUNC(base_md_cart_slot_device::read),(base_md_cart_slot_device*)state->m_slotcart), write16_delegate(FUNC(base_md_cart_slot_device::write),(base_md_cart_slot_device*)state->m_slotcart)); |
286 | 309 | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa13000, 0xa130ff, read16_delegate(FUNC(base_md_cart_slot_device::read_a13),(base_md_cart_slot_device*)state->m_slotcart), write16_delegate(FUNC(base_md_cart_slot_device::write_a13),(base_md_cart_slot_device*)state->m_slotcart)); |
287 | 310 | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15000, 0xa150ff, read16_delegate(FUNC(base_md_cart_slot_device::read_a15),(base_md_cart_slot_device*)state->m_slotcart), write16_delegate(FUNC(base_md_cart_slot_device::write_a15),(base_md_cart_slot_device*)state->m_slotcart)); |