13
13
WRITE8_HANDLER( arkanoid_videoram_w )
15
arkanoid_state *state = space->machine->driver_data<arkanoid_state>();
16
state->videoram[offset] = data;
17
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
15
arkanoid_state *state = space->machine().driver_data<arkanoid_state>();
16
state->m_videoram[offset] = data;
17
tilemap_mark_tile_dirty(state->m_bg_tilemap, offset / 2);
20
20
WRITE8_HANDLER( arkanoid_d008_w )
22
arkanoid_state *state = space->machine->driver_data<arkanoid_state>();
22
arkanoid_state *state = space->machine().driver_data<arkanoid_state>();
25
25
/* bits 0 and 1 flip X and Y, I don't know which is which */
26
if (flip_screen_x_get(space->machine) != (data & 0x01))
26
if (flip_screen_x_get(space->machine()) != (data & 0x01))
28
flip_screen_x_set(space->machine, data & 0x01);
29
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
28
flip_screen_x_set(space->machine(), data & 0x01);
29
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
32
if (flip_screen_y_get(space->machine) != (data & 0x02))
32
if (flip_screen_y_get(space->machine()) != (data & 0x02))
34
flip_screen_y_set(space->machine, data & 0x02);
35
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
34
flip_screen_y_set(space->machine(), data & 0x02);
35
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
38
38
/* bit 2 selects the input paddle */
39
state->paddle_select = data & 0x04;
39
state->m_paddle_select = data & 0x04;
41
41
/* bit 3 is coin lockout (but not the service coin) */
42
coin_lockout_w(space->machine, 0, !(data & 0x08));
43
coin_lockout_w(space->machine, 1, !(data & 0x08));
42
coin_lockout_w(space->machine(), 0, !(data & 0x08));
43
coin_lockout_w(space->machine(), 1, !(data & 0x08));
45
45
/* bit 4 is unknown */
48
48
/* so I don't know which is which. */
49
49
bank = (data & 0x20) >> 5;
51
if (state->gfxbank != bank)
51
if (state->m_gfxbank != bank)
53
state->gfxbank = bank;
54
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
53
state->m_gfxbank = bank;
54
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
57
57
bank = (data & 0x40) >> 6;
59
if (state->palettebank != bank)
59
if (state->m_palettebank != bank)
61
state->palettebank = bank;
62
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
61
state->m_palettebank = bank;
62
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
65
65
/* BM: bit 7 is suspected to be MCU reset, the evidence for this is that
68
68
leaving the tilt screen (as the MCU is now out of sync with main CPU
69
69
which resets itself). This bit is the likely candidate as it is flipped
70
70
early in bootup just prior to accessing the MCU for the first time. */
71
if (state->mcu != NULL) // Bootlegs don't have the MCU but still set this bit
72
cpu_set_input_line(state->mcu, INPUT_LINE_RESET, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
71
if (state->m_mcu != NULL) // Bootlegs don't have the MCU but still set this bit
72
device_set_input_line(state->m_mcu, INPUT_LINE_RESET, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
75
75
/* different hook-up, everything except for bits 0-1 and 7 aren't tested afaik. */
76
76
WRITE8_HANDLER( tetrsark_d008_w )
78
arkanoid_state *state = space->machine->driver_data<arkanoid_state>();
78
arkanoid_state *state = space->machine().driver_data<arkanoid_state>();
81
81
/* bits 0 and 1 flip X and Y, I don't know which is which */
82
if (flip_screen_x_get(space->machine) != (data & 0x01))
82
if (flip_screen_x_get(space->machine()) != (data & 0x01))
84
flip_screen_x_set(space->machine, data & 0x01);
85
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
84
flip_screen_x_set(space->machine(), data & 0x01);
85
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
88
if (flip_screen_y_get(space->machine) != (data & 0x02))
88
if (flip_screen_y_get(space->machine()) != (data & 0x02))
90
flip_screen_y_set(space->machine, data & 0x02);
91
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
90
flip_screen_y_set(space->machine(), data & 0x02);
91
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
94
94
/* bit 2 selects the input paddle? */
95
state->paddle_select = data & 0x04;
95
state->m_paddle_select = data & 0x04;
97
97
/* bit 3-4 is unknown? */
100
100
/* so I don't know which is which.? */
101
101
bank = (data & 0x20) >> 5;
103
if (state->gfxbank != bank)
103
if (state->m_gfxbank != bank)
105
state->gfxbank = bank;
106
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
105
state->m_gfxbank = bank;
106
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
109
109
bank = (data & 0x40) >> 6;
111
if (state->palettebank != bank)
111
if (state->m_palettebank != bank)
113
state->palettebank = bank;
114
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
113
state->m_palettebank = bank;
114
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
117
117
/* bit 7 is coin lockout (but not the service coin) */
118
coin_lockout_w(space->machine, 0, !(data & 0x80));
119
coin_lockout_w(space->machine, 1, !(data & 0x80));
118
coin_lockout_w(space->machine(), 0, !(data & 0x80));
119
coin_lockout_w(space->machine(), 1, !(data & 0x80));
123
123
WRITE8_HANDLER( hexa_d008_w )
125
arkanoid_state *state = space->machine->driver_data<arkanoid_state>();
125
arkanoid_state *state = space->machine().driver_data<arkanoid_state>();
127
127
/* bit 0 = flipx (or y?) */
128
if (flip_screen_x_get(space->machine) != (data & 0x01))
128
if (flip_screen_x_get(space->machine()) != (data & 0x01))
130
flip_screen_x_set(space->machine, data & 0x01);
131
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
130
flip_screen_x_set(space->machine(), data & 0x01);
131
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
134
134
/* bit 1 = flipy (or x?) */
135
if (flip_screen_y_get(space->machine) != (data & 0x02))
135
if (flip_screen_y_get(space->machine()) != (data & 0x02))
137
flip_screen_y_set(space->machine, data & 0x02);
138
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
137
flip_screen_y_set(space->machine(), data & 0x02);
138
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
141
141
/* bit 2 - 3 unknown */
143
143
/* bit 4 could be the ROM bank selector for 8000-bfff (not sure) */
144
memory_set_bank(space->machine, "bank1", ((data & 0x10) >> 4));
144
memory_set_bank(space->machine(), "bank1", ((data & 0x10) >> 4));
146
146
/* bit 5 = gfx bank */
147
if (state->gfxbank != ((data & 0x20) >> 5))
147
if (state->m_gfxbank != ((data & 0x20) >> 5))
149
state->gfxbank = (data & 0x20) >> 5;
150
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
149
state->m_gfxbank = (data & 0x20) >> 5;
150
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
153
153
/* bit 6 - 7 unknown */
156
156
static TILE_GET_INFO( get_bg_tile_info )
158
arkanoid_state *state = machine->driver_data<arkanoid_state>();
158
arkanoid_state *state = machine.driver_data<arkanoid_state>();
159
159
int offs = tile_index * 2;
160
int code = state->videoram[offs + 1] + ((state->videoram[offs] & 0x07) << 8) + 2048 * state->gfxbank;
161
int color = ((state->videoram[offs] & 0xf8) >> 3) + 32 * state->palettebank;
160
int code = state->m_videoram[offs + 1] + ((state->m_videoram[offs] & 0x07) << 8) + 2048 * state->m_gfxbank;
161
int color = ((state->m_videoram[offs] & 0xf8) >> 3) + 32 * state->m_palettebank;
163
163
SET_TILE_INFO(0, code, color, 0);
166
166
VIDEO_START( arkanoid )
168
arkanoid_state *state = machine->driver_data<arkanoid_state>();
168
arkanoid_state *state = machine.driver_data<arkanoid_state>();
170
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
170
state->m_bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
173
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
173
static void draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
175
arkanoid_state *state = machine->driver_data<arkanoid_state>();
175
arkanoid_state *state = machine.driver_data<arkanoid_state>();
178
for (offs = 0; offs < state->spriteram_size; offs += 4)
178
for (offs = 0; offs < state->m_spriteram_size; offs += 4)
180
180
int sx, sy, code;
182
sx = state->spriteram[offs];
183
sy = 248 - state->spriteram[offs + 1];
182
sx = state->m_spriteram[offs];
183
sy = 248 - state->m_spriteram[offs + 1];
184
184
if (flip_screen_x_get(machine))
186
186
if (flip_screen_y_get(machine))
189
code = state->spriteram[offs + 3] + ((state->spriteram[offs + 2] & 0x03) << 8) + 1024 * state->gfxbank;
189
code = state->m_spriteram[offs + 3] + ((state->m_spriteram[offs + 2] & 0x03) << 8) + 1024 * state->m_gfxbank;
191
drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
191
drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
193
((state->spriteram[offs + 2] & 0xf8) >> 3) + 32 * state->palettebank,
193
((state->m_spriteram[offs + 2] & 0xf8) >> 3) + 32 * state->m_palettebank,
194
194
flip_screen_x_get(machine),flip_screen_y_get(machine),
195
195
sx,sy + (flip_screen_y_get(machine) ? 8 : -8),0);
196
drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
196
drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
198
((state->spriteram[offs + 2] & 0xf8) >> 3) + 32 * state->palettebank,
198
((state->m_spriteram[offs + 2] & 0xf8) >> 3) + 32 * state->m_palettebank,
199
199
flip_screen_x_get(machine),flip_screen_y_get(machine),
205
VIDEO_UPDATE( arkanoid )
205
SCREEN_UPDATE( arkanoid )
207
arkanoid_state *state = screen->machine->driver_data<arkanoid_state>();
207
arkanoid_state *state = screen->machine().driver_data<arkanoid_state>();
209
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
210
draw_sprites(screen->machine, bitmap, cliprect);
209
tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);
210
draw_sprites(screen->machine(), bitmap, cliprect);
214
SCREEN_UPDATE( hexa )
216
arkanoid_state *state = screen->machine->driver_data<arkanoid_state>();
216
arkanoid_state *state = screen->machine().driver_data<arkanoid_state>();
218
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
218
tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);