trunk/src/mame/drivers/dec0.c
r31316 | r31317 | |
166 | 166 | #include "sound/2203intf.h" |
167 | 167 | #include "sound/3812intf.h" |
168 | 168 | #include "sound/okim6295.h" |
169 | | #include "sound/msm5205.h" |
170 | 169 | |
171 | 170 | |
172 | 171 | /******************************************************************************/ |
r31316 | r31317 | |
396 | 395 | |
397 | 396 | */ |
398 | 397 | |
399 | | WRITE16_MEMBER(dec0_state::unmapped_w) |
400 | | { |
401 | | // fall through for unmapped protection areas |
402 | | logerror("unmapped memory write to %04x = %04x in mode %d\n", 0x240000+offset*2, data, m_slyspy_state); |
403 | | } |
404 | | |
405 | | void slyspy_set_protection_map(running_machine& machine, int type); |
406 | | |
407 | 398 | WRITE16_MEMBER(dec0_state::slyspy_state_w) |
408 | 399 | { |
409 | | m_slyspy_state=0; |
410 | | slyspy_set_protection_map(m_slyspy_state); |
| 400 | m_slyspy_state = 0; |
| 401 | m_pfprotect->set_bank(m_slyspy_state); |
411 | 402 | } |
412 | 403 | |
413 | 404 | READ16_MEMBER(dec0_state::slyspy_state_r) |
414 | 405 | { |
415 | | m_slyspy_state++; |
416 | | m_slyspy_state=m_slyspy_state%4; |
417 | | slyspy_set_protection_map(m_slyspy_state); |
| 406 | m_slyspy_state = (m_slyspy_state + 1) % 4; |
| 407 | m_pfprotect->set_bank(m_slyspy_state); |
418 | 408 | |
419 | 409 | return 0; /* Value doesn't mater */ |
420 | 410 | } |
421 | 411 | |
422 | | void dec0_state::slyspy_set_protection_map( int type) |
423 | | { |
424 | | address_space& space = m_maincpu->space(AS_PROGRAM); |
425 | 412 | |
426 | | space.install_write_handler( 0x240000, 0x24ffff, write16_delegate(FUNC(dec0_state::unmapped_w),this)); |
| 413 | static ADDRESS_MAP_START( slyspy_protection_map, AS_PROGRAM, 16, dec0_state ) |
| 414 | AM_RANGE(0x04000, 0x04001) AM_MIRROR(0x30000) AM_READ(slyspy_state_r) |
| 415 | AM_RANGE(0x0a000, 0x0a001) AM_MIRROR(0x30000) AM_WRITE(slyspy_state_w) |
| 416 | // Default state (called by Traps 1, 3, 4, 7, C) |
| 417 | AM_RANGE(0x00000, 0x00007) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_control_0_w) |
| 418 | AM_RANGE(0x00010, 0x00017) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_control_1_w) |
| 419 | AM_RANGE(0x02000, 0x0207f) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_colscroll_w) |
| 420 | AM_RANGE(0x02400, 0x027ff) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_rowscroll_w) |
| 421 | AM_RANGE(0x06000, 0x07fff) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_data_w) |
| 422 | AM_RANGE(0x08000, 0x08007) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_control_0_w) |
| 423 | AM_RANGE(0x08010, 0x08017) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_control_1_w) |
| 424 | AM_RANGE(0x0c000, 0x0c07f) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_colscroll_w) |
| 425 | AM_RANGE(0x0c400, 0x0c7ff) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_rowscroll_w) |
| 426 | AM_RANGE(0x0e000, 0x0ffff) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_data_w) |
| 427 | // State 1 (Called by Trap 9) |
| 428 | AM_RANGE(0x18000, 0x19fff) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_data_w) |
| 429 | AM_RANGE(0x1c000, 0x1dfff) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_data_w) |
| 430 | // State 2 (Called by Trap A) |
| 431 | AM_RANGE(0x20000, 0x21fff) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_data_w) |
| 432 | AM_RANGE(0x22000, 0x23fff) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_data_w) |
| 433 | AM_RANGE(0x2e000, 0x2ffff) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_data_w) |
| 434 | // State 3 (Called by Trap B) |
| 435 | AM_RANGE(0x30000, 0x31fff) AM_DEVWRITE("tilegen1", deco_bac06_device, pf_data_w) |
| 436 | AM_RANGE(0x38000, 0x39fff) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_data_w) |
| 437 | ADDRESS_MAP_END |
427 | 438 | |
428 | | space.install_write_handler( 0x24a000, 0x24a001, write16_delegate(FUNC(dec0_state::slyspy_state_w),this)); |
429 | | space.install_read_handler( 0x244000, 0x244001, read16_delegate(FUNC(dec0_state::slyspy_state_r),this)); |
430 | | |
431 | | switch (type) |
432 | | { |
433 | | case 0: |
434 | | space.install_write_handler(0x240000, 0x240007, write16_delegate(FUNC(deco_bac06_device::pf_control_0_w), (deco_bac06_device*)m_tilegen2)); |
435 | | space.install_write_handler(0x240010, 0x240017, write16_delegate(FUNC(deco_bac06_device::pf_control_1_w), (deco_bac06_device*)m_tilegen2)); |
436 | | |
437 | | space.install_write_handler(0x242000, 0x24207f, write16_delegate(FUNC(deco_bac06_device::pf_colscroll_w), (deco_bac06_device*)m_tilegen2)); |
438 | | space.install_write_handler(0x242400, 0x2427ff, write16_delegate(FUNC(deco_bac06_device::pf_rowscroll_w), (deco_bac06_device*)m_tilegen2)); |
439 | | |
440 | | space.install_write_handler(0x246000, 0x247fff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen2)); |
441 | | |
442 | | space.install_write_handler(0x248000, 0x280007, write16_delegate(FUNC(deco_bac06_device::pf_control_0_w), (deco_bac06_device*)m_tilegen1)); |
443 | | space.install_write_handler(0x248010, 0x280017, write16_delegate(FUNC(deco_bac06_device::pf_control_1_w), (deco_bac06_device*)m_tilegen1)); |
444 | | |
445 | | space.install_write_handler(0x24c000, 0x24c07f, write16_delegate(FUNC(deco_bac06_device::pf_colscroll_w), (deco_bac06_device*)m_tilegen1)); |
446 | | space.install_write_handler(0x24c400, 0x24c7ff, write16_delegate(FUNC(deco_bac06_device::pf_rowscroll_w), (deco_bac06_device*)m_tilegen1)); |
447 | | |
448 | | space.install_write_handler(0x24e000, 0x24ffff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen1)); |
449 | | |
450 | | break; |
451 | | |
452 | | case 1: |
453 | | // 0x240000 - 0x241fff not mapped |
454 | | // 0x242000 - 0x243fff not mapped |
455 | | // 0x246000 - 0x247fff not mapped |
456 | | space.install_write_handler(0x248000, 0x249fff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen1)); |
457 | | space.install_write_handler(0x24c000, 0x24dfff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen2)); |
458 | | // 0x24e000 - 0x24ffff not mapped |
459 | | break; |
460 | | |
461 | | case 2: |
462 | | space.install_write_handler(0x240000, 0x241fff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen2)); |
463 | | space.install_write_handler(0x242000, 0x243fff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen1)); |
464 | | // 0x242000 - 0x243fff not mapped |
465 | | // 0x246000 - 0x247fff not mapped |
466 | | // 0x248000 - 0x249fff not mapped |
467 | | // 0x24c000 - 0x24dfff not mapped |
468 | | space.install_write_handler(0x24e000, 0x24ffff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen1)); |
469 | | break; |
470 | | |
471 | | case 3: |
472 | | space.install_write_handler(0x240000, 0x241fff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen1)); |
473 | | // 0x242000 - 0x243fff not mapped |
474 | | // 0x246000 - 0x247fff not mapped |
475 | | space.install_write_handler(0x248000, 0x249fff, write16_delegate(FUNC(deco_bac06_device::pf_data_w), (deco_bac06_device*)m_tilegen2)); |
476 | | // 0x24c000 - 0x24dfff not mapped |
477 | | // 0x24e000 - 0x24ffff not mapped |
478 | | break; |
479 | | } |
480 | | |
481 | | } |
482 | | |
483 | | |
484 | | |
485 | | |
486 | | |
487 | | |
488 | | |
489 | 439 | static ADDRESS_MAP_START( slyspy_map, AS_PROGRAM, 16, dec0_state ) |
490 | 440 | AM_RANGE(0x000000, 0x05ffff) AM_ROM |
491 | 441 | |
492 | | /* The location of p1 & pf2 can change in the 240000 - 24ffff region according to protection */ |
| 442 | /* The location of pf1 & pf2 can change in the 240000 - 24ffff region according to protection */ |
| 443 | AM_RANGE(0x240000, 0x24ffff) AM_DEVICE("pfprotect", address_map_bank_device, amap16) |
493 | 444 | |
494 | 445 | /* Pf3 is unaffected by protection */ |
495 | 446 | AM_RANGE(0x300000, 0x300007) AM_DEVWRITE("tilegen3", deco_bac06_device, pf_control_0_w) |
r31316 | r31317 | |
1618 | 1569 | MACHINE_RESET_MEMBER(dec0_state,slyspy) |
1619 | 1570 | { |
1620 | 1571 | // set initial memory map |
1621 | | slyspy_set_protection_map(0); |
| 1572 | m_slyspy_state = 0; |
| 1573 | m_pfprotect->set_bank(m_slyspy_state); |
1622 | 1574 | } |
1623 | 1575 | |
1624 | 1576 | static MACHINE_CONFIG_DERIVED( slyspy, dec1 ) |
r31316 | r31317 | |
1631 | 1583 | MCFG_CPU_ADD("audiocpu", H6280, XTAL_12MHz/2/3) /* verified on pcb (6Mhz is XIN on pin 10 of H6280, verified on pcb */ |
1632 | 1584 | MCFG_CPU_PROGRAM_MAP(slyspy_s_map) |
1633 | 1585 | |
| 1586 | MCFG_DEVICE_ADD("pfprotect", ADDRESS_MAP_BANK, 0) |
| 1587 | MCFG_DEVICE_PROGRAM_MAP(slyspy_protection_map) |
| 1588 | MCFG_ADDRESS_MAP_BANK_ENDIANNESS(ENDIANNESS_BIG) |
| 1589 | MCFG_ADDRESS_MAP_BANK_DATABUS_WIDTH(16) |
| 1590 | MCFG_ADDRESS_MAP_BANK_ADDRBUS_WIDTH(18) |
| 1591 | MCFG_ADDRESS_MAP_BANK_STRIDE(0x10000) |
| 1592 | |
1634 | 1593 | /* video hardware */ |
1635 | 1594 | MCFG_SCREEN_MODIFY("screen") |
1636 | 1595 | MCFG_SCREEN_UPDATE_DRIVER(dec0_state, screen_update_slyspy) |