trunk/src/mame/drivers/decocass.c
| r19790 | r19791 | |
| 37 | 37 | #include "includes/decocass.h" |
| 38 | 38 | #include "machine/decocass_tape.h" |
| 39 | 39 | #include "sound/ay8910.h" |
| 40 | #include "machine/deco222.h" |
| 40 | 41 | |
| 41 | 42 | #define MASTER_CLOCK XTAL_12MHz |
| 42 | 43 | #define HCLK (MASTER_CLOCK/2) |
| r19790 | r19791 | |
| 51 | 52 | * |
| 52 | 53 | ***************************************************************************/ |
| 53 | 54 | |
| 54 | | INLINE int swap_bits_5_6(int data) |
| 55 | | { |
| 56 | | return (data & 0x9f) | ((data & 0x20) << 1) | ((data & 0x40) >> 1); |
| 57 | | } |
| 58 | 55 | |
| 59 | | WRITE8_MEMBER(decocass_state::ram_w) |
| 60 | | { |
| 61 | | m_decrypted[0x0000 + offset] = swap_bits_5_6(data); |
| 62 | | m_rambase[0x0000 + offset] = data; |
| 63 | | } |
| 64 | | |
| 65 | 56 | WRITE8_MEMBER(decocass_state::charram_w) |
| 66 | 57 | { |
| 67 | | m_decrypted[0x6000 + offset] = swap_bits_5_6(data); |
| 68 | 58 | decocass_charram_w(space, offset, data); |
| 69 | 59 | } |
| 70 | 60 | |
| 71 | 61 | WRITE8_MEMBER(decocass_state::fgvideoram_w) |
| 72 | 62 | { |
| 73 | | m_decrypted[0xc000 + offset] = swap_bits_5_6(data); |
| 74 | 63 | decocass_fgvideoram_w(space, offset, data); |
| 75 | 64 | } |
| 76 | 65 | |
| 77 | 66 | WRITE8_MEMBER(decocass_state::fgcolorram_w) |
| 78 | 67 | { |
| 79 | | m_decrypted[0xc400 + offset] = swap_bits_5_6(data); |
| 80 | 68 | decocass_colorram_w(space, offset, data); |
| 81 | 69 | } |
| 82 | 70 | |
| 83 | 71 | WRITE8_MEMBER(decocass_state::tileram_w) |
| 84 | 72 | { |
| 85 | | m_decrypted[0xd000 + offset] = swap_bits_5_6(data); |
| 86 | 73 | decocass_tileram_w(space, offset, data); |
| 87 | 74 | } |
| 88 | 75 | |
| 89 | 76 | WRITE8_MEMBER(decocass_state::objectram_w) |
| 90 | 77 | { |
| 91 | | m_decrypted[0xd800 + offset] = swap_bits_5_6(data); |
| 92 | 78 | decocass_objectram_w(space, offset, data); |
| 93 | 79 | } |
| 94 | 80 | |
| r19790 | r19791 | |
| 109 | 95 | |
| 110 | 96 | |
| 111 | 97 | static ADDRESS_MAP_START( decocass_map, AS_PROGRAM, 8, decocass_state ) |
| 112 | | AM_RANGE(0x0000, 0x5fff) AM_RAM_WRITE(ram_w) AM_SHARE("rambase") |
| 98 | AM_RANGE(0x0000, 0x5fff) AM_RAM AM_SHARE("rambase") |
| 113 | 99 | AM_RANGE(0x6000, 0xbfff) AM_RAM_WRITE(charram_w) AM_SHARE("charram") /* still RMS3 RAM */ |
| 114 | 100 | AM_RANGE(0xc000, 0xc3ff) AM_RAM_WRITE(fgvideoram_w) AM_SHARE("fgvideoram") /* DSP3 RAM */ |
| 115 | 101 | AM_RANGE(0xc400, 0xc7ff) AM_RAM_WRITE(fgcolorram_w) AM_SHARE("colorram") |
| r19790 | r19791 | |
| 755 | 741 | static MACHINE_CONFIG_START( decocass, decocass_state ) |
| 756 | 742 | |
| 757 | 743 | /* basic machine hardware */ |
| 758 | | MCFG_CPU_ADD("maincpu", M6502, HCLK4) |
| 744 | MCFG_CPU_ADD("maincpu", DECO_222, HCLK4) /* the earlier revision board doesn't have the 222 but must have the same thing implemented in logic for the M6502 */ |
| 759 | 745 | MCFG_CPU_PROGRAM_MAP(decocass_map) |
| 760 | 746 | |
| 761 | 747 | MCFG_CPU_ADD("audiocpu", M6502, HCLK1/3/2) |
| r19790 | r19791 | |
| 778 | 764 | MCFG_GFXDECODE(decocass) |
| 779 | 765 | MCFG_PALETTE_LENGTH(32+2*8+2*4) |
| 780 | 766 | |
| 781 | | |
| 782 | 767 | /* sound hardware */ |
| 783 | 768 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 784 | 769 | |
| r19790 | r19791 | |
| 1620 | 1605 | |
| 1621 | 1606 | DRIVER_INIT_MEMBER(decocass_state,decocass) |
| 1622 | 1607 | { |
| 1623 | | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 1624 | | UINT8 *rom = memregion("maincpu")->base(); |
| 1625 | | int A; |
| 1626 | | |
| 1627 | | /* allocate memory and mark all RAM regions with their decrypted pointers */ |
| 1628 | | m_decrypted = auto_alloc_array(machine(), UINT8, 0x10000); |
| 1629 | | space.set_decrypted_region(0x0000, 0xc7ff, &m_decrypted[0x0000]); |
| 1630 | | space.set_decrypted_region(0xd000, 0xdbff, &m_decrypted[0xd000]); |
| 1631 | | space.set_decrypted_region(0xf000, 0xffff, &m_decrypted[0xf000]); |
| 1632 | | |
| 1633 | | /* Swap bits 5 & 6 for opcodes */ |
| 1634 | | for (A = 0xf000; A < 0x10000; A++) |
| 1635 | | m_decrypted[A] = swap_bits_5_6(rom[A]); |
| 1636 | | |
| 1637 | | save_pointer(NAME(m_decrypted), 0x10000); |
| 1638 | | |
| 1639 | 1608 | /* Call the state save setup code in machine/decocass.c */ |
| 1640 | 1609 | decocass_machine_state_save_init(); |
| 1641 | 1610 | /* and in video/decocass.c, too */ |
| r19790 | r19791 | |
| 1644 | 1613 | |
| 1645 | 1614 | DRIVER_INIT_MEMBER(decocass_state,decocrom) |
| 1646 | 1615 | { |
| 1647 | | int romlength = memregion("user3")->bytes(); |
| 1648 | | UINT8 *rom = memregion("user3")->base(); |
| 1649 | | int i; |
| 1650 | | |
| 1651 | | m_decrypted2 = auto_alloc_array(machine(), UINT8, romlength); |
| 1652 | | |
| 1653 | 1616 | /* standard init */ |
| 1654 | 1617 | DRIVER_INIT_CALL(decocass); |
| 1655 | 1618 | |
| 1656 | | /* decrypt the ROMs */ |
| 1657 | | for (i = 0; i < romlength; i++) |
| 1658 | | m_decrypted2[i] = swap_bits_5_6(rom[i]); |
| 1659 | | |
| 1660 | 1619 | /* convert charram to a banked ROM */ |
| 1661 | 1620 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x6000, 0xafff, "bank1"); |
| 1662 | 1621 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x6000, 0xafff, write8_delegate(FUNC(decocass_state::decocass_de0091_w),this)); |
| 1663 | 1622 | membank("bank1")->configure_entry(0, m_charram); |
| 1664 | 1623 | membank("bank1")->configure_entry(1, memregion("user3")->base()); |
| 1665 | | membank("bank1")->configure_decrypted_entry(0, &m_decrypted[0x6000]); |
| 1666 | | membank("bank1")->configure_decrypted_entry(1, m_decrypted2); |
| 1667 | 1624 | membank("bank1")->set_entry(0); |
| 1668 | 1625 | |
| 1669 | 1626 | /* install the bank selector */ |
| 1670 | 1627 | machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xe900, 0xe900, write8_delegate(FUNC(decocass_state::decocass_e900_w),this)); |
| 1671 | | |
| 1672 | | save_pointer(NAME(m_decrypted2), romlength); |
| 1673 | 1628 | } |
| 1674 | 1629 | |
| 1675 | 1630 | READ8_MEMBER(decocass_state::cdsteljn_input_r ) |
trunk/src/mame/drivers/dec8.c
| r19790 | r19791 | |
| 52 | 52 | #include "video/decbac06.h" |
| 53 | 53 | #include "video/decmxc06.h" |
| 54 | 54 | #include "video/deckarn.h" |
| 55 | #include "machine/deco222.h" |
| 55 | 56 | |
| 57 | |
| 56 | 58 | /******************************************************************************/ |
| 57 | 59 | |
| 58 | | class deco_222_device : public m6502_device { |
| 59 | | public: |
| 60 | | deco_222_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 61 | 60 | |
| 62 | | protected: |
| 63 | | class mi_decrypt : public mi_default_normal { |
| 64 | | public: |
| 65 | | bool had_written; |
| 66 | | |
| 67 | | virtual ~mi_decrypt() {} |
| 68 | | virtual UINT8 read_decrypted(UINT16 adr); |
| 69 | | }; |
| 70 | | |
| 71 | | virtual void device_start(); |
| 72 | | virtual void device_reset(); |
| 73 | | |
| 74 | | }; |
| 75 | | |
| 76 | | static const device_type DECO_222 = &device_creator<deco_222_device>; |
| 77 | | |
| 78 | | deco_222_device::deco_222_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 79 | | m6502_device(mconfig, DECO_222, "DECO 222", tag, owner, clock) |
| 80 | | { |
| 81 | | } |
| 82 | | |
| 83 | | void deco_222_device::device_start() |
| 84 | | { |
| 85 | | mintf = new mi_decrypt; |
| 86 | | init(); |
| 87 | | } |
| 88 | | |
| 89 | | void deco_222_device::device_reset() |
| 90 | | { |
| 91 | | m6502_device::device_reset(); |
| 92 | | static_cast<mi_decrypt *>(mintf)->had_written = false; |
| 93 | | } |
| 94 | | |
| 95 | | UINT8 deco_222_device::mi_decrypt::read_decrypted(UINT16 adr) |
| 96 | | { |
| 97 | | return BITSWAP8(direct->read_raw_byte(adr) ,7,5,6,4,3,2,1,0);; |
| 98 | | } |
| 99 | | |
| 100 | | |
| 101 | 61 | WRITE8_MEMBER(dec8_state::dec8_mxc06_karn_buffer_spriteram_w) |
| 102 | 62 | { |
| 103 | 63 | UINT8* spriteram = m_spriteram->live(); |