31
31
#include "includes/pushman.h"
32
32
#include "sound/2203intf.h"
34
static WRITE16_HANDLER( pushman_flipscreen_w )
34
WRITE16_MEMBER(pushman_state::pushman_flipscreen_w)
36
36
if (ACCESSING_BITS_8_15)
38
flip_screen_set(space->machine(), data & 0x0200);
39
coin_counter_w(space->machine(), 0, data & 0x4000);
40
coin_counter_w(space->machine(), 1, data & 0x8000);
38
flip_screen_set(data & 0x0200);
39
coin_counter_w(machine(), 0, data & 0x4000);
40
coin_counter_w(machine(), 1, data & 0x8000);
44
static WRITE16_HANDLER( pushman_control_w )
44
WRITE16_MEMBER(pushman_state::pushman_control_w)
46
46
if (ACCESSING_BITS_8_15)
47
soundlatch_w(space, 0, (data >> 8) & 0xff);
47
soundlatch_byte_w(space, 0, (data >> 8) & 0xff);
50
static READ16_HANDLER( pushman_68705_r )
50
READ16_MEMBER(pushman_state::pushman_68705_r)
52
pushman_state *state = space->machine().driver_data<pushman_state>();
55
return state->m_latch;
57
if (offset == 3 && state->m_new_latch)
56
if (offset == 3 && m_new_latch)
59
state->m_new_latch = 0;
62
if (offset == 3 && !state->m_new_latch)
61
if (offset == 3 && !m_new_latch)
65
return (state->m_shared_ram[2 * offset + 1] << 8) + state->m_shared_ram[2 * offset];
64
return (m_shared_ram[2 * offset + 1] << 8) + m_shared_ram[2 * offset];
68
static WRITE16_HANDLER( pushman_68705_w )
67
WRITE16_MEMBER(pushman_state::pushman_68705_w)
70
pushman_state *state = space->machine().driver_data<pushman_state>();
72
70
if (ACCESSING_BITS_8_15)
73
state->m_shared_ram[2 * offset] = data >> 8;
71
m_shared_ram[2 * offset] = data >> 8;
74
72
if (ACCESSING_BITS_0_7)
75
state->m_shared_ram[2 * offset + 1] = data & 0xff;
73
m_shared_ram[2 * offset + 1] = data & 0xff;
79
device_set_input_line(state->m_mcu, M68705_IRQ_LINE, HOLD_LINE);
80
device_spin(&space->device());
81
state->m_new_latch = 0;
77
device_set_input_line(m_mcu, M68705_IRQ_LINE, HOLD_LINE);
78
device_spin(&space.device());
85
83
/* ElSemi - Bouncing balls protection. */
86
static READ16_HANDLER( bballs_68705_r )
84
READ16_MEMBER(pushman_state::bballs_68705_r)
88
pushman_state *state = space->machine().driver_data<pushman_state>();
91
return state->m_latch;
92
if (offset == 3 && state->m_new_latch)
89
if (offset == 3 && m_new_latch)
94
state->m_new_latch = 0;
97
if (offset == 3 && !state->m_new_latch)
94
if (offset == 3 && !m_new_latch)
100
return (state->m_shared_ram[2 * offset + 1] << 8) + state->m_shared_ram[2 * offset];
97
return (m_shared_ram[2 * offset + 1] << 8) + m_shared_ram[2 * offset];
103
static WRITE16_HANDLER( bballs_68705_w )
100
WRITE16_MEMBER(pushman_state::bballs_68705_w)
105
pushman_state *state = space->machine().driver_data<pushman_state>();
107
103
if (ACCESSING_BITS_8_15)
108
state->m_shared_ram[2 * offset] = data >> 8;
104
m_shared_ram[2 * offset] = data >> 8;
109
105
if (ACCESSING_BITS_0_7)
110
state->m_shared_ram[2 * offset + 1] = data & 0xff;
106
m_shared_ram[2 * offset + 1] = data & 0xff;
115
if (state->m_shared_ram[0] <= 0xf)
111
if (m_shared_ram[0] <= 0xf)
117
state->m_latch = state->m_shared_ram[0] << 2;
118
if (state->m_shared_ram[1])
120
state->m_new_latch = 1;
113
m_latch = m_shared_ram[0] << 2;
122
else if (state->m_shared_ram[0])
118
else if (m_shared_ram[0])
124
if (state->m_shared_ram[1])
126
state->m_new_latch = 1;
132
static READ8_HANDLER( pushman_68000_r )
128
READ8_MEMBER(pushman_state::pushman_68000_r)
134
pushman_state *state = space->machine().driver_data<pushman_state>();
135
return state->m_shared_ram[offset];
130
return m_shared_ram[offset];
138
static WRITE8_HANDLER( pushman_68000_w )
133
WRITE8_MEMBER(pushman_state::pushman_68000_w)
140
pushman_state *state = space->machine().driver_data<pushman_state>();
142
if (offset == 2 && (state->m_shared_ram[2] & 2) == 0 && data & 2)
136
if (offset == 2 && (m_shared_ram[2] & 2) == 0 && data & 2)
144
state->m_latch = (state->m_shared_ram[1] << 8) | state->m_shared_ram[0];
145
state->m_new_latch = 1;
138
m_latch = (m_shared_ram[1] << 8) | m_shared_ram[0];
147
state->m_shared_ram[offset] = data;
141
m_shared_ram[offset] = data;
150
144
/******************************************************************************/
152
static ADDRESS_MAP_START( pushman_map, AS_PROGRAM, 16 )
146
static ADDRESS_MAP_START( pushman_map, AS_PROGRAM, 16, pushman_state )
153
147
AM_RANGE(0x000000, 0x01ffff) AM_ROM
154
148
AM_RANGE(0x060000, 0x060007) AM_READWRITE(pushman_68705_r, pushman_68705_w)
155
AM_RANGE(0xfe0800, 0xfe17ff) AM_RAM AM_BASE_MEMBER(pushman_state, m_spriteram)
149
AM_RANGE(0xfe0800, 0xfe17ff) AM_RAM AM_SHARE("spriteram")
156
150
AM_RANGE(0xfe4000, 0xfe4001) AM_READ_PORT("INPUTS") AM_WRITE(pushman_flipscreen_w)
157
151
AM_RANGE(0xfe4002, 0xfe4003) AM_READ_PORT("SYSTEM") AM_WRITE(pushman_control_w)
158
152
AM_RANGE(0xfe4004, 0xfe4005) AM_READ_PORT("DSW")
159
153
AM_RANGE(0xfe8000, 0xfe8003) AM_WRITE(pushman_scroll_w)
160
154
AM_RANGE(0xfe800e, 0xfe800f) AM_WRITENOP /* ? */
161
AM_RANGE(0xfec000, 0xfec7ff) AM_RAM_WRITE(pushman_videoram_w) AM_BASE_MEMBER(pushman_state, m_videoram)
162
AM_RANGE(0xff8000, 0xff87ff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
155
AM_RANGE(0xfec000, 0xfec7ff) AM_RAM_WRITE(pushman_videoram_w) AM_SHARE("videoram")
156
AM_RANGE(0xff8000, 0xff87ff) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_word_w) AM_SHARE("paletteram")
163
157
AM_RANGE(0xffc000, 0xffffff) AM_RAM
166
static ADDRESS_MAP_START( mcu_map, AS_PROGRAM, 8 )
160
static ADDRESS_MAP_START( mcu_map, AS_PROGRAM, 8, pushman_state )
167
161
AM_RANGE(0x0000, 0x0007) AM_READWRITE(pushman_68000_r, pushman_68000_w)
168
162
AM_RANGE(0x0010, 0x007f) AM_RAM
169
163
AM_RANGE(0x0080, 0x0fff) AM_ROM
172
static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8 )
166
static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, pushman_state )
173
167
AM_RANGE(0x0000, 0x7fff) AM_ROM
174
168
AM_RANGE(0xc000, 0xc7ff) AM_RAM
175
AM_RANGE(0xe000, 0xe000) AM_READ(soundlatch_r)
169
AM_RANGE(0xe000, 0xe000) AM_READ(soundlatch_byte_r)
178
static ADDRESS_MAP_START( sound_io_map, AS_IO, 8 )
172
static ADDRESS_MAP_START( sound_io_map, AS_IO, 8, pushman_state )
179
173
ADDRESS_MAP_GLOBAL_MASK(0xff)
180
AM_RANGE(0x00, 0x01) AM_DEVWRITE("ym1", ym2203_w)
181
AM_RANGE(0x80, 0x81) AM_DEVWRITE("ym2", ym2203_w)
174
AM_RANGE(0x00, 0x01) AM_DEVWRITE_LEGACY("ym1", ym2203_w)
175
AM_RANGE(0x80, 0x81) AM_DEVWRITE_LEGACY("ym2", ym2203_w)
184
static ADDRESS_MAP_START( bballs_map, AS_PROGRAM, 16 )
178
static ADDRESS_MAP_START( bballs_map, AS_PROGRAM, 16, pushman_state )
185
179
ADDRESS_MAP_GLOBAL_MASK(0xfffff)
186
180
AM_RANGE(0x00000, 0x1ffff) AM_ROM
187
181
AM_RANGE(0x60000, 0x60007) AM_READWRITE(bballs_68705_r, bballs_68705_w)
188
AM_RANGE(0xe0800, 0xe17ff) AM_RAM AM_BASE_MEMBER(pushman_state, m_spriteram)
182
AM_RANGE(0xe0800, 0xe17ff) AM_RAM AM_SHARE("spriteram")
189
183
AM_RANGE(0xe4000, 0xe4001) AM_READ_PORT("INPUTS") AM_WRITE(pushman_flipscreen_w)
190
184
AM_RANGE(0xe4002, 0xe4003) AM_READ_PORT("SYSTEM") AM_WRITE(pushman_control_w)
191
185
AM_RANGE(0xe4004, 0xe4005) AM_READ_PORT("DSW")
192
186
AM_RANGE(0xe8000, 0xe8003) AM_WRITE(pushman_scroll_w)
193
187
AM_RANGE(0xe800e, 0xe800f) AM_WRITENOP /* ? */
194
AM_RANGE(0xec000, 0xec7ff) AM_RAM_WRITE(pushman_videoram_w) AM_BASE_MEMBER(pushman_state, m_videoram)
195
AM_RANGE(0xf8000, 0xf87ff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
188
AM_RANGE(0xec000, 0xec7ff) AM_RAM_WRITE(pushman_videoram_w) AM_SHARE("videoram")
189
AM_RANGE(0xf8000, 0xf87ff) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_word_w) AM_SHARE("paletteram")
196
190
AM_RANGE(0xfc000, 0xfffff) AM_RAM