trunk/src/mame/drivers/atarisy2.c
| r241740 | r241741 | |
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | #include "emu.h" |
| 129 | | #include "includes/slapstic.h" |
| 130 | 129 | #include "includes/atarisy2.h" |
| 131 | 130 | #include "sound/tms5220.h" |
| 132 | 131 | #include "sound/2151intf.h" |
| r241740 | r241741 | |
| 222 | 221 | MACHINE_RESET_MEMBER(atarisy2_state,atarisy2) |
| 223 | 222 | { |
| 224 | 223 | atarigen_state::machine_reset(); |
| 225 | | slapstic_reset(); |
| 224 | m_slapstic->slapstic_reset(); |
| 226 | 225 | scanline_timer_reset(*m_screen, 64); |
| 227 | 226 | |
| 228 | 227 | m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(atarisy2_state::atarisy2_direct_handler), this)); |
| r241740 | r241741 | |
| 1208 | 1207 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| 1209 | 1208 | MCFG_DEVICE_PERIODIC_INT_DEVICE("soundcomm", atari_sound_comm_device, sound_irq_gen, (double)MASTER_CLOCK/2/16/16/16/10) |
| 1210 | 1209 | |
| 1210 | MCFG_SLAPSTIC_ADD("slapstic") |
| 1211 | |
| 1211 | 1212 | MCFG_MACHINE_START_OVERRIDE(atarisy2_state,atarisy2) |
| 1212 | 1213 | MCFG_MACHINE_RESET_OVERRIDE(atarisy2_state,atarisy2) |
| 1213 | 1214 | |
| r241740 | r241741 | |
| 3143 | 3144 | int i; |
| 3144 | 3145 | UINT8 *cpu1 = memregion("maincpu")->base(); |
| 3145 | 3146 | |
| 3146 | | slapstic_init(machine(), 105); |
| 3147 | m_slapstic->slapstic_init(machine(), 105); |
| 3147 | 3148 | |
| 3148 | 3149 | /* expand the 16k program ROMs into full 64k chunks */ |
| 3149 | 3150 | for (i = 0x10000; i < 0x90000; i += 0x20000) |
| r241740 | r241741 | |
| 3164 | 3165 | /* without the default EEPROM, 720 hangs at startup due to communication |
| 3165 | 3166 | issues with the sound CPU; temporarily increasing the sound CPU frequency |
| 3166 | 3167 | to ~2.2MHz "fixes" the problem */ |
| 3167 | | slapstic_init(machine(), 107); |
| 3168 | m_slapstic->slapstic_init(machine(), 107); |
| 3168 | 3169 | |
| 3169 | 3170 | m_pedal_count = -1; |
| 3170 | 3171 | m_has_tms5220 = 1; |
| r241740 | r241741 | |
| 3177 | 3178 | int i; |
| 3178 | 3179 | UINT8 *cpu1 = memregion("maincpu")->base(); |
| 3179 | 3180 | |
| 3180 | | slapstic_init(machine(), 108); |
| 3181 | m_slapstic->slapstic_init(machine(), 108); |
| 3181 | 3182 | |
| 3182 | 3183 | /* expand the 32k program ROMs into full 64k chunks */ |
| 3183 | 3184 | for (i = 0x10000; i < 0x90000; i += 0x20000) |
| r241740 | r241741 | |
| 3193 | 3194 | int i; |
| 3194 | 3195 | UINT8 *cpu1 = memregion("maincpu")->base(); |
| 3195 | 3196 | |
| 3196 | | slapstic_init(machine(), 109); |
| 3197 | m_slapstic->slapstic_init(machine(), 109); |
| 3197 | 3198 | |
| 3198 | 3199 | /* expand the 32k program ROMs into full 64k chunks */ |
| 3199 | 3200 | for (i = 0x10000; i < 0x90000; i += 0x20000) |
| r241740 | r241741 | |
| 3206 | 3207 | |
| 3207 | 3208 | DRIVER_INIT_MEMBER(atarisy2_state,apb) |
| 3208 | 3209 | { |
| 3209 | | slapstic_init(machine(), 110); |
| 3210 | m_slapstic->slapstic_init(machine(), 110); |
| 3210 | 3211 | |
| 3211 | 3212 | m_pedal_count = 2; |
| 3212 | 3213 | m_has_tms5220 = 1; |
trunk/src/mame/drivers/atetris.c
| r241740 | r241741 | |
| 49 | 49 | |
| 50 | 50 | #include "emu.h" |
| 51 | 51 | #include "cpu/m6502/m6502.h" |
| 52 | | #include "includes/slapstic.h" |
| 53 | 52 | #include "includes/atetris.h" |
| 54 | 53 | #include "sound/sn76496.h" |
| 55 | 54 | #include "sound/pokey.h" |
| r241740 | r241741 | |
| 115 | 114 | void atetris_state::machine_reset() |
| 116 | 115 | { |
| 117 | 116 | /* reset the slapstic */ |
| 118 | | slapstic_reset(); |
| 119 | | m_current_bank = slapstic_bank() & 1; |
| 117 | m_slapstic_device->slapstic_reset(); |
| 118 | m_current_bank = m_slapstic_device->slapstic_bank() & 1; |
| 120 | 119 | reset_bank(); |
| 121 | 120 | |
| 122 | 121 | /* start interrupts going (32V clocked by 16V) */ |
| r241740 | r241741 | |
| 134 | 133 | READ8_MEMBER(atetris_state::atetris_slapstic_r) |
| 135 | 134 | { |
| 136 | 135 | int result = m_slapstic_base[0x2000 + offset]; |
| 137 | | int new_bank = slapstic_tweak(space, offset) & 1; |
| 136 | int new_bank = m_slapstic_device->slapstic_tweak(space, offset) & 1; |
| 138 | 137 | |
| 139 | 138 | /* update for the new bank */ |
| 140 | 139 | if (new_bank != m_current_bank) |
| r241740 | r241741 | |
| 308 | 307 | MCFG_CPU_ADD("maincpu", M6502,MASTER_CLOCK/8) |
| 309 | 308 | MCFG_CPU_PROGRAM_MAP(main_map) |
| 310 | 309 | |
| 310 | MCFG_SLAPSTIC_ADD("slapstic") |
| 311 | |
| 311 | 312 | MCFG_NVRAM_ADD_1FILL("nvram") |
| 312 | 313 | |
| 313 | 314 | /* video hardware */ |
| r241740 | r241741 | |
| 456 | 457 | { |
| 457 | 458 | UINT8 *rgn = memregion("maincpu")->base(); |
| 458 | 459 | |
| 459 | | slapstic_init(machine(), 101); |
| 460 | m_slapstic_device->slapstic_init(machine(), 101); |
| 460 | 461 | m_slapstic_source = &rgn[0x10000]; |
| 461 | 462 | m_slapstic_base = &rgn[0x04000]; |
| 462 | 463 | } |
trunk/src/mame/drivers/harddriv.c
| r241740 | r241741 | |
| 209 | 209 | Notes: |
| 210 | 210 | 68000 clock input - 8.000MHz [16/2] |
| 211 | 211 | |
| 212 | | |
| 212 | |
| 213 | 213 | DSK |
| 214 | 214 | A047724-01 |
| 215 | 215 | |-----------------------------------------------| |
| r241740 | r241741 | |
| 1232 | 1232 | MCFG_DEVICE_VBLANK_INT_DRIVER("screen", atarigen_state, video_int_gen) |
| 1233 | 1233 | MCFG_CPU_PERIODIC_INT_DRIVER(harddriv_state, hd68k_irq_gen, (double)HARDDRIV_MASTER_CLOCK/16/16/16/16/2) |
| 1234 | 1234 | |
| 1235 | MCFG_SLAPSTIC_ADD("slapstic") |
| 1236 | MCFG_SLAPSTIC_68K_ACCESS(1) |
| 1237 | |
| 1235 | 1238 | MCFG_CPU_ADD("gsp", TMS34010, HARDDRIV_GSP_CLOCK) |
| 1236 | 1239 | MCFG_CPU_PROGRAM_MAP(driver_gsp_map) |
| 1237 | 1240 | MCFG_TMS340X0_HALT_ON_RESET(TRUE) /* halt on reset */ |
| r241740 | r241741 | |
| 4403 | 4406 | init_driver_sound(); |
| 4404 | 4407 | |
| 4405 | 4408 | /* set up the slapstic */ |
| 4406 | | slapstic_init(machine(), 117); |
| 4409 | m_slapstic_device->slapstic_init(machine(), 117); |
| 4407 | 4410 | m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this)); |
| 4408 | 4411 | |
| 4409 | 4412 | /* synchronization */ |
| r241740 | r241741 | |
| 4424 | 4427 | init_driver_sound(); |
| 4425 | 4428 | |
| 4426 | 4429 | /* set up the slapstic */ |
| 4427 | | slapstic_init(machine(), 117); |
| 4430 | m_slapstic_device->slapstic_init(machine(), 117); |
| 4428 | 4431 | m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this)); |
| 4429 | 4432 | |
| 4430 | 4433 | /* synchronization */ |
| r241740 | r241741 | |
| 4523 | 4526 | init_dsk(); |
| 4524 | 4527 | |
| 4525 | 4528 | /* set up the slapstic */ |
| 4526 | | slapstic_init(machine(), 117); |
| 4529 | m_slapstic_device->slapstic_init(machine(), 117); |
| 4527 | 4530 | m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this)); |
| 4528 | 4531 | |
| 4529 | 4532 | m_maincpu->space(AS_PROGRAM).install_read_handler(0xa80000, 0xafffff, read16_delegate(FUNC(harddriv_state::hda68k_port1_r), this)); |
trunk/src/mame/drivers/starwars.c
| r241740 | r241741 | |
| 62 | 62 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 63 | 63 | |
| 64 | 64 | /* reset the slapstic */ |
| 65 | | slapstic_reset(); |
| 66 | | m_slapstic_current_bank = slapstic_bank(); |
| 65 | m_slapstic_device->slapstic_reset(); |
| 66 | m_slapstic_current_bank = m_slapstic_device->slapstic_bank(); |
| 67 | 67 | memcpy(m_slapstic_base, &m_slapstic_source[m_slapstic_current_bank * 0x2000], 0x2000); |
| 68 | 68 | |
| 69 | 69 | /* reset all the banks */ |
| r241740 | r241741 | |
| 97 | 97 | |
| 98 | 98 | void starwars_state::esb_slapstic_tweak(address_space &space, offs_t offset) |
| 99 | 99 | { |
| 100 | | int new_bank = slapstic_tweak(space, offset); |
| 100 | int new_bank = m_slapstic_device->slapstic_tweak(space, offset); |
| 101 | 101 | |
| 102 | 102 | /* update for the new bank */ |
| 103 | 103 | if (new_bank != m_slapstic_current_bank) |
| r241740 | r241741 | |
| 331 | 331 | MCFG_CPU_PERIODIC_INT_DRIVER(starwars_state, irq0_line_assert, CLOCK_3KHZ / 12) |
| 332 | 332 | MCFG_WATCHDOG_TIME_INIT(attotime::from_hz(CLOCK_3KHZ / 128)) |
| 333 | 333 | |
| 334 | MCFG_SLAPSTIC_ADD("slapstic") |
| 335 | |
| 334 | 336 | MCFG_CPU_ADD("audiocpu", M6809, MASTER_CLOCK / 8) |
| 335 | 337 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| 336 | 338 | |
| r241740 | r241741 | |
| 524 | 526 | UINT8 *rom = memregion("maincpu")->base(); |
| 525 | 527 | |
| 526 | 528 | /* init the slapstic */ |
| 527 | | slapstic_init(machine(), 101); |
| 529 | m_slapstic_device->slapstic_init(machine(), 101); |
| 528 | 530 | m_slapstic_source = &rom[0x14000]; |
| 529 | 531 | m_slapstic_base = &rom[0x08000]; |
| 530 | 532 | |
trunk/src/mame/includes/atarisy2.h
| r241740 | r241741 | |
| 10 | 10 | #include "video/atarimo.h" |
| 11 | 11 | #include "cpu/m6502/m6502.h" |
| 12 | 12 | #include "cpu/t11/t11.h" |
| 13 | #include "slapstic.h" |
| 13 | 14 | |
| 14 | 15 | class atarisy2_state : public atarigen_state |
| 15 | 16 | { |
| r241740 | r241741 | |
| 25 | 26 | m_alpha_tilemap(*this, "alpha"), |
| 26 | 27 | m_rombank1(*this, "rombank1"), |
| 27 | 28 | m_rombank2(*this, "rombank2"), |
| 28 | | m_generic_paletteram_16(*this, "paletteram") { } |
| 29 | m_generic_paletteram_16(*this, "paletteram"), |
| 30 | m_slapstic(*this, "slapstic") |
| 31 | { } |
| 29 | 32 | |
| 30 | 33 | required_device<t11_device> m_maincpu; |
| 31 | 34 | required_device<m6502_device> m_audiocpu; |
| r241740 | r241741 | |
| 50 | 53 | required_shared_ptr<UINT16> m_rombank1; |
| 51 | 54 | required_shared_ptr<UINT16> m_rombank2; |
| 52 | 55 | required_shared_ptr<UINT16> m_generic_paletteram_16; |
| 56 | required_device<atari_slapstic_device> m_slapstic; |
| 53 | 57 | |
| 54 | 58 | UINT8 m_sound_reset_state; |
| 55 | 59 | |
trunk/src/mame/includes/atetris.h
| r241740 | r241741 | |
| 4 | 4 | |
| 5 | 5 | *************************************************************************/ |
| 6 | 6 | |
| 7 | #include "includes/slapstic.h" |
| 8 | |
| 7 | 9 | class atetris_state : public driver_device |
| 8 | 10 | { |
| 9 | 11 | public: |
| r241740 | r241741 | |
| 13 | 15 | m_videoram(*this, "videoram"), |
| 14 | 16 | m_maincpu(*this, "maincpu"), |
| 15 | 17 | m_gfxdecode(*this, "gfxdecode"), |
| 16 | | m_screen(*this, "screen") { } |
| 18 | m_screen(*this, "screen"), |
| 19 | m_slapstic_device(*this, "slapstic") |
| 20 | { } |
| 17 | 21 | |
| 18 | 22 | required_shared_ptr<UINT8> m_nvram; |
| 19 | 23 | required_shared_ptr<UINT8> m_videoram; |
| r241740 | r241741 | |
| 40 | 44 | required_device<cpu_device> m_maincpu; |
| 41 | 45 | required_device<gfxdecode_device> m_gfxdecode; |
| 42 | 46 | required_device<screen_device> m_screen; |
| 47 | optional_device<atari_slapstic_device> m_slapstic_device; |
| 43 | 48 | }; |
trunk/src/mame/includes/slapstic.h
| r241740 | r241741 | |
| 9 | 9 | |
| 10 | 10 | *************************************************************************/ |
| 11 | 11 | |
| 12 | | /*----------- defined in machine/slapstic.c -----------*/ |
| 12 | #pragma once |
| 13 | 13 | |
| 14 | | void slapstic_init(running_machine &machine, int chip); |
| 15 | | void slapstic_reset(void); |
| 14 | #ifndef __SLAPSTIC__ |
| 15 | #define __SLAPSTIC__ |
| 16 | 16 | |
| 17 | | int slapstic_bank(void); |
| 18 | | int slapstic_tweak(address_space &space, offs_t offset); |
| 17 | #include "emu.h" |
| 18 | #include "cpu/m6800/m6800.h" |
| 19 | #include "cpu/m68000/m68000.h" |
| 20 | |
| 21 | |
| 22 | extern const device_type SLAPSTIC; |
| 23 | |
| 24 | #define MCFG_SLAPSTIC_ADD(_tag) \ |
| 25 | MCFG_DEVICE_ADD(_tag, SLAPSTIC, 0) |
| 26 | |
| 27 | |
| 28 | /************************************* |
| 29 | * |
| 30 | * Debugging |
| 31 | * |
| 32 | *************************************/ |
| 33 | |
| 34 | #define LOG_SLAPSTIC (0) |
| 35 | |
| 36 | |
| 37 | |
| 38 | /************************************* |
| 39 | * |
| 40 | * Structure of slapstic params |
| 41 | * |
| 42 | *************************************/ |
| 43 | |
| 44 | struct mask_value |
| 45 | { |
| 46 | int mask, value; |
| 47 | }; |
| 48 | |
| 49 | |
| 50 | struct slapstic_data |
| 51 | { |
| 52 | int bankstart; |
| 53 | int bank[4]; |
| 54 | |
| 55 | struct mask_value alt1; |
| 56 | struct mask_value alt2; |
| 57 | struct mask_value alt3; |
| 58 | struct mask_value alt4; |
| 59 | int altshift; |
| 60 | |
| 61 | struct mask_value bit1; |
| 62 | struct mask_value bit2c0; |
| 63 | struct mask_value bit2s0; |
| 64 | struct mask_value bit2c1; |
| 65 | struct mask_value bit2s1; |
| 66 | struct mask_value bit3; |
| 67 | |
| 68 | struct mask_value add1; |
| 69 | struct mask_value add2; |
| 70 | struct mask_value addplus1; |
| 71 | struct mask_value addplus2; |
| 72 | struct mask_value add3; |
| 73 | }; |
| 74 | |
| 75 | |
| 76 | |
| 77 | /************************************* |
| 78 | * |
| 79 | * Shorthand |
| 80 | * |
| 81 | *************************************/ |
| 82 | |
| 83 | #define UNKNOWN 0xffff |
| 84 | #define NO_BITWISE \ |
| 85 | { UNKNOWN,UNKNOWN }, \ |
| 86 | { UNKNOWN,UNKNOWN }, \ |
| 87 | { UNKNOWN,UNKNOWN }, \ |
| 88 | { UNKNOWN,UNKNOWN }, \ |
| 89 | { UNKNOWN,UNKNOWN }, \ |
| 90 | { UNKNOWN,UNKNOWN } |
| 91 | #define NO_ADDITIVE \ |
| 92 | { UNKNOWN,UNKNOWN }, \ |
| 93 | { UNKNOWN,UNKNOWN }, \ |
| 94 | { UNKNOWN,UNKNOWN }, \ |
| 95 | { UNKNOWN,UNKNOWN }, \ |
| 96 | { UNKNOWN,UNKNOWN } |
| 97 | |
| 98 | #define MATCHES_MASK_VALUE(val, maskval) (((val) & (maskval).mask) == (maskval).value) |
| 99 | |
| 100 | |
| 101 | |
| 102 | /************************************* |
| 103 | * |
| 104 | * Constants |
| 105 | * |
| 106 | *************************************/ |
| 107 | |
| 108 | enum |
| 109 | { |
| 110 | DISABLED, |
| 111 | ENABLED, |
| 112 | ALTERNATE1, |
| 113 | ALTERNATE2, |
| 114 | ALTERNATE3, |
| 115 | BITWISE1, |
| 116 | BITWISE2, |
| 117 | BITWISE3, |
| 118 | ADDITIVE1, |
| 119 | ADDITIVE2, |
| 120 | ADDITIVE3 |
| 121 | }; |
| 122 | |
| 123 | |
| 124 | #define MCFG_SLAPSTIC_68K_ACCESS(_type) \ |
| 125 | atari_slapstic_device::static_set_access68k(*device, _type); |
| 126 | |
| 127 | |
| 128 | |
| 129 | class atari_slapstic_device : public device_t |
| 130 | { |
| 131 | public: |
| 132 | // construction/destruction |
| 133 | atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 134 | |
| 135 | void slapstic_init(running_machine &machine, int chip); |
| 136 | void slapstic_reset(void); |
| 137 | |
| 138 | int slapstic_bank(void); |
| 139 | int slapstic_tweak(address_space &space, offs_t offset); |
| 140 | |
| 141 | int alt2_kludge(address_space &space, offs_t offset); |
| 142 | |
| 143 | static void static_set_access68k(device_t &device, int type) |
| 144 | { |
| 145 | atari_slapstic_device &dev = downcast<atari_slapstic_device &>(device); |
| 146 | dev.access_68k = type; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | UINT8 state; |
| 151 | UINT8 current_bank; |
| 152 | int access_68k; |
| 153 | |
| 154 | UINT8 alt_bank; |
| 155 | UINT8 bit_bank; |
| 156 | UINT8 add_bank; |
| 157 | UINT8 bit_xor; |
| 158 | |
| 159 | struct slapstic_data slapstic; |
| 160 | |
| 161 | |
| 162 | void slapstic_log(running_machine &machine, offs_t offset); |
| 163 | FILE *slapsticlog; |
| 164 | |
| 165 | |
| 166 | protected: |
| 167 | virtual void device_start(); |
| 168 | virtual void device_reset(); |
| 169 | |
| 170 | |
| 171 | private: |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | }; |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | #endif |
trunk/src/mame/machine/atarigen.c
| r241740 | r241741 | |
| 16 | 16 | #include "sound/okim6295.h" |
| 17 | 17 | #include "sound/pokey.h" |
| 18 | 18 | #include "video/atarimo.h" |
| 19 | | #include "includes/slapstic.h" |
| 20 | 19 | #include "atarigen.h" |
| 21 | 20 | |
| 22 | 21 | |
| r241740 | r241741 | |
| 975 | 974 | m_gfxdecode(*this, "gfxdecode"), |
| 976 | 975 | m_screen(*this, "screen"), |
| 977 | 976 | m_palette(*this, "palette"), |
| 978 | | m_generic_paletteram_16(*this, "paletteram") |
| 977 | m_generic_paletteram_16(*this, "paletteram"), |
| 978 | m_slapstic_device(*this, ":slapstic") |
| 979 | 979 | { |
| 980 | 980 | } |
| 981 | 981 | |
| r241740 | r241741 | |
| 1022 | 1022 | // reset the slapstic |
| 1023 | 1023 | if (m_slapstic_num != 0) |
| 1024 | 1024 | { |
| 1025 | | slapstic_reset(); |
| 1026 | | slapstic_update_bank(slapstic_bank()); |
| 1025 | if (!m_slapstic_device) |
| 1026 | fatalerror("Slapstic device is missing?\n"); |
| 1027 | |
| 1028 | m_slapstic_device->slapstic_reset(); |
| 1029 | slapstic_update_bank(m_slapstic_device->slapstic_bank()); |
| 1027 | 1030 | } |
| 1028 | 1031 | } |
| 1029 | 1032 | |
| r241740 | r241741 | |
| 1192 | 1195 | |
| 1193 | 1196 | void atarigen_state::device_post_load() |
| 1194 | 1197 | { |
| 1195 | | slapstic_update_bank(slapstic_bank()); |
| 1198 | if (!m_slapstic_device) |
| 1199 | fatalerror("Slapstic device is missing?\n"); |
| 1200 | |
| 1201 | slapstic_update_bank(m_slapstic_device->slapstic_bank()); |
| 1196 | 1202 | } |
| 1197 | 1203 | |
| 1198 | 1204 | |
| r241740 | r241741 | |
| 1232 | 1238 | // if we have a chip, install it |
| 1233 | 1239 | if (chipnum != 0) |
| 1234 | 1240 | { |
| 1241 | if (!m_slapstic_device) |
| 1242 | fatalerror("Slapstic device is missing\n"); |
| 1243 | |
| 1235 | 1244 | // initialize the slapstic |
| 1236 | | slapstic_init(machine(), chipnum); |
| 1245 | m_slapstic_device->slapstic_init(machine(), chipnum); |
| 1237 | 1246 | |
| 1238 | 1247 | // install the memory handlers |
| 1239 | 1248 | address_space &program = device.space(AS_PROGRAM); |
| r241740 | r241741 | |
| 1262 | 1271 | |
| 1263 | 1272 | WRITE16_MEMBER(atarigen_state::slapstic_w) |
| 1264 | 1273 | { |
| 1265 | | slapstic_update_bank(slapstic_tweak(space, offset)); |
| 1274 | if (!m_slapstic_device) |
| 1275 | fatalerror("Slapstic device is missing?\n"); |
| 1276 | |
| 1277 | slapstic_update_bank(m_slapstic_device->slapstic_tweak(space, offset)); |
| 1266 | 1278 | } |
| 1267 | 1279 | |
| 1268 | 1280 | |
| r241740 | r241741 | |
| 1273 | 1285 | |
| 1274 | 1286 | READ16_MEMBER(atarigen_state::slapstic_r) |
| 1275 | 1287 | { |
| 1288 | if (!m_slapstic_device) |
| 1289 | fatalerror("Slapstic device is missing?\n"); |
| 1290 | |
| 1276 | 1291 | // fetch the result from the current bank first |
| 1277 | 1292 | int result = m_slapstic[offset & 0xfff]; |
| 1278 | 1293 | |
| 1279 | 1294 | // then determine the new one |
| 1280 | | slapstic_update_bank(slapstic_tweak(space, offset)); |
| 1295 | slapstic_update_bank(m_slapstic_device->slapstic_tweak(space, offset)); |
| 1281 | 1296 | return result; |
| 1282 | 1297 | } |
| 1283 | 1298 | |
trunk/src/mame/machine/slapstic.c
| r241740 | r241741 | |
| 180 | 180 | |
| 181 | 181 | *************************************************************************/ |
| 182 | 182 | |
| 183 | | #include "emu.h" |
| 184 | | #include "cpu/m6800/m6800.h" |
| 183 | |
| 185 | 184 | #include "includes/slapstic.h" |
| 186 | | #include "cpu/m68000/m68000.h" |
| 187 | 185 | |
| 188 | 186 | |
| 189 | | /************************************* |
| 190 | | * |
| 191 | | * Debugging |
| 192 | | * |
| 193 | | *************************************/ |
| 187 | extern const device_type SLAPSTIC = &device_creator<atari_slapstic_device>; |
| 194 | 188 | |
| 195 | | #define LOG_SLAPSTIC (0) |
| 189 | atari_slapstic_device::atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 190 | : device_t(mconfig, SLAPSTIC, "Atari Slapstic", tag, owner, clock, "slapstic", __FILE__), |
| 191 | state(0), |
| 192 | current_bank(0), |
| 193 | access_68k(-1), |
| 194 | alt_bank(0), |
| 195 | bit_bank(0), |
| 196 | add_bank(0), |
| 197 | bit_xor(0) |
| 198 | { |
| 199 | slapstic.bankstart = 0; |
| 200 | slapstic.bank[0] = slapstic.bank[1] = slapstic.bank[2] = slapstic.bank[3] = 0; |
| 201 | slapstic.alt1.mask = 0; |
| 202 | slapstic.alt1.value = 0; |
| 203 | slapstic.alt2.mask = 0; |
| 204 | slapstic.alt2.value = 0; |
| 205 | slapstic.alt3.mask = 0; |
| 206 | slapstic.alt3.value = 0; |
| 207 | slapstic.alt4.mask = 0; |
| 208 | slapstic.alt4.value = 0; |
| 209 | slapstic.altshift = 0; |
| 210 | slapstic.bit1.mask = 0; |
| 211 | slapstic.bit1.value = 0; |
| 212 | slapstic.bit2c0.mask = 0; |
| 213 | slapstic.bit2c0.value = 0; |
| 214 | slapstic.bit2s0.mask = 0; |
| 215 | slapstic.bit2s0.value = 0; |
| 216 | slapstic.bit2c1.mask = 0; |
| 217 | slapstic.bit2c1.value = 0; |
| 218 | slapstic.bit2s1.mask = 0; |
| 219 | slapstic.bit2s1.value = 0; |
| 220 | slapstic.bit3.mask = 0; |
| 221 | slapstic.bit3.value = 0; |
| 222 | slapstic.add1.mask = 0; |
| 223 | slapstic.add1.value = 0; |
| 224 | slapstic.add2.mask = 0; |
| 225 | slapstic.add2.value = 0; |
| 226 | slapstic.addplus1.mask = 0; |
| 227 | slapstic.addplus1.value = 0; |
| 228 | slapstic.addplus2.mask = 0; |
| 229 | slapstic.addplus2.value = 0; |
| 230 | slapstic.add3.mask = 0; |
| 231 | slapstic.add3.value = 0; |
| 232 | } |
| 196 | 233 | |
| 197 | 234 | |
| 198 | 235 | |
| 199 | | /************************************* |
| 200 | | * |
| 201 | | * Structure of slapstic params |
| 202 | | * |
| 203 | | *************************************/ |
| 204 | | |
| 205 | | struct mask_value |
| 236 | void atari_slapstic_device::device_start() |
| 206 | 237 | { |
| 207 | | int mask, value; |
| 208 | | }; |
| 209 | 238 | |
| 239 | } |
| 210 | 240 | |
| 211 | | struct slapstic_data |
| 241 | void atari_slapstic_device::device_reset() |
| 212 | 242 | { |
| 213 | | int bankstart; |
| 214 | | int bank[4]; |
| 215 | 243 | |
| 216 | | struct mask_value alt1; |
| 217 | | struct mask_value alt2; |
| 218 | | struct mask_value alt3; |
| 219 | | struct mask_value alt4; |
| 220 | | int altshift; |
| 244 | } |
| 221 | 245 | |
| 222 | | struct mask_value bit1; |
| 223 | | struct mask_value bit2c0; |
| 224 | | struct mask_value bit2s0; |
| 225 | | struct mask_value bit2c1; |
| 226 | | struct mask_value bit2s1; |
| 227 | | struct mask_value bit3; |
| 228 | | |
| 229 | | struct mask_value add1; |
| 230 | | struct mask_value add2; |
| 231 | | struct mask_value addplus1; |
| 232 | | struct mask_value addplus2; |
| 233 | | struct mask_value add3; |
| 234 | | }; |
| 235 | | |
| 236 | | |
| 237 | | |
| 238 | 246 | /************************************* |
| 239 | 247 | * |
| 240 | | * Shorthand |
| 241 | | * |
| 242 | | *************************************/ |
| 243 | | |
| 244 | | #define UNKNOWN 0xffff |
| 245 | | #define NO_BITWISE \ |
| 246 | | { UNKNOWN,UNKNOWN }, \ |
| 247 | | { UNKNOWN,UNKNOWN }, \ |
| 248 | | { UNKNOWN,UNKNOWN }, \ |
| 249 | | { UNKNOWN,UNKNOWN }, \ |
| 250 | | { UNKNOWN,UNKNOWN }, \ |
| 251 | | { UNKNOWN,UNKNOWN } |
| 252 | | #define NO_ADDITIVE \ |
| 253 | | { UNKNOWN,UNKNOWN }, \ |
| 254 | | { UNKNOWN,UNKNOWN }, \ |
| 255 | | { UNKNOWN,UNKNOWN }, \ |
| 256 | | { UNKNOWN,UNKNOWN }, \ |
| 257 | | { UNKNOWN,UNKNOWN } |
| 258 | | |
| 259 | | #define MATCHES_MASK_VALUE(val, maskval) (((val) & (maskval).mask) == (maskval).value) |
| 260 | | |
| 261 | | |
| 262 | | |
| 263 | | /************************************* |
| 264 | | * |
| 265 | | * Constants |
| 266 | | * |
| 267 | | *************************************/ |
| 268 | | |
| 269 | | enum |
| 270 | | { |
| 271 | | DISABLED, |
| 272 | | ENABLED, |
| 273 | | ALTERNATE1, |
| 274 | | ALTERNATE2, |
| 275 | | ALTERNATE3, |
| 276 | | BITWISE1, |
| 277 | | BITWISE2, |
| 278 | | BITWISE3, |
| 279 | | ADDITIVE1, |
| 280 | | ADDITIVE2, |
| 281 | | ADDITIVE3 |
| 282 | | }; |
| 283 | | |
| 284 | | |
| 285 | | |
| 286 | | /************************************* |
| 287 | | * |
| 288 | 248 | * Slapstic definitions |
| 289 | 249 | * |
| 290 | 250 | *************************************/ |
| r241740 | r241741 | |
| 779 | 739 | |
| 780 | 740 | |
| 781 | 741 | |
| 782 | | /************************************* |
| 783 | | * |
| 784 | | * Statics |
| 785 | | * |
| 786 | | *************************************/ |
| 787 | 742 | |
| 788 | | static UINT8 state; |
| 789 | | static UINT8 current_bank; |
| 790 | | static UINT8 access_68k; |
| 791 | | |
| 792 | | static UINT8 alt_bank; |
| 793 | | static UINT8 bit_bank; |
| 794 | | static UINT8 add_bank; |
| 795 | | static UINT8 bit_xor; |
| 796 | | |
| 797 | | static struct slapstic_data slapstic; |
| 798 | | |
| 799 | | |
| 800 | | static void slapstic_log(running_machine &machine, offs_t offset); |
| 801 | | static FILE *slapsticlog; |
| 802 | | |
| 803 | | |
| 804 | 743 | /************************************* |
| 805 | 744 | * |
| 806 | 745 | * Initialization |
| 807 | 746 | * |
| 808 | 747 | *************************************/ |
| 809 | 748 | |
| 810 | | void slapstic_init(running_machine &machine, int chip) |
| 749 | void atari_slapstic_device::slapstic_init(running_machine &machine, int chip) |
| 811 | 750 | { |
| 812 | | device_type cputype = machine.device("maincpu")->type(); |
| 751 | if (access_68k == -1) |
| 752 | { |
| 753 | device_type cputype = machine.device(":maincpu")->type(); |
| 754 | access_68k = (cputype == M68000 || cputype == M68010); |
| 755 | } |
| 813 | 756 | |
| 814 | 757 | /* only a small number of chips are known to exist */ |
| 815 | 758 | if (chip < 101 || chip > 118) |
| r241740 | r241741 | |
| 824 | 767 | slapstic_reset(); |
| 825 | 768 | |
| 826 | 769 | /* see if we're 68k or 6502/6809 based */ |
| 827 | | access_68k = (cputype == M68000 || cputype == M68010); |
| 828 | 770 | |
| 829 | 771 | /* save state */ |
| 830 | 772 | state_save_register_item(machine, "slapstic", NULL, 0, state); |
| r241740 | r241741 | |
| 836 | 778 | } |
| 837 | 779 | |
| 838 | 780 | |
| 839 | | void slapstic_reset(void) |
| 781 | void atari_slapstic_device::slapstic_reset(void) |
| 840 | 782 | { |
| 841 | 783 | /* reset the chip */ |
| 842 | 784 | state = DISABLED; |
| r241740 | r241741 | |
| 853 | 795 | * |
| 854 | 796 | *************************************/ |
| 855 | 797 | |
| 856 | | int slapstic_bank(void) |
| 798 | int atari_slapstic_device::slapstic_bank(void) |
| 857 | 799 | { |
| 858 | 800 | return current_bank; |
| 859 | 801 | } |
| r241740 | r241741 | |
| 866 | 808 | * |
| 867 | 809 | *************************************/ |
| 868 | 810 | |
| 869 | | static int alt2_kludge(address_space &space, offs_t offset) |
| 811 | int atari_slapstic_device::alt2_kludge(address_space &space, offs_t offset) |
| 870 | 812 | { |
| 871 | 813 | /* Of the 3 alternate addresses, only the middle one needs to actually hit |
| 872 | 814 | in the slapstic region; the first and third ones can be anywhere in the |
| r241740 | r241741 | |
| 913 | 855 | * |
| 914 | 856 | *************************************/ |
| 915 | 857 | |
| 916 | | int slapstic_tweak(address_space &space, offs_t offset) |
| 858 | int atari_slapstic_device::slapstic_tweak(address_space &space, offs_t offset) |
| 917 | 859 | { |
| 918 | 860 | /* reset is universal */ |
| 919 | 861 | if (offset == 0x0000) |
| r241740 | r241741 | |
| 1137 | 1079 | * |
| 1138 | 1080 | *************************************/ |
| 1139 | 1081 | |
| 1140 | | static void slapstic_log(running_machine &machine, offs_t offset) |
| 1082 | void atari_slapstic_device::slapstic_log(running_machine &machine, offs_t offset) |
| 1141 | 1083 | { |
| 1142 | 1084 | static attotime last_time; |
| 1143 | 1085 | |