70
70
*************************************/
72
static VIDEO_UPDATE( gameplan )
72
static SCREEN_UPDATE( gameplan )
74
gameplan_state *state = screen->machine->driver_data<gameplan_state>();
74
gameplan_state *state = screen->machine().driver_data<gameplan_state>();
75
75
pen_t pens[GAMEPLAN_NUM_PENS];
78
78
gameplan_get_pens(pens);
80
for (offs = 0; offs < state->videoram_size; offs++)
80
for (offs = 0; offs < state->m_videoram_size; offs++)
82
82
UINT8 y = offs >> 8;
83
83
UINT8 x = offs & 0xff;
85
*BITMAP_ADDR32(bitmap, y, x) = pens[state->videoram[offs] & 0x07];
85
*BITMAP_ADDR32(bitmap, y, x) = pens[state->m_videoram[offs] & 0x07];
92
static VIDEO_UPDATE( leprechn )
92
static SCREEN_UPDATE( leprechn )
94
gameplan_state *state = screen->machine->driver_data<gameplan_state>();
94
gameplan_state *state = screen->machine().driver_data<gameplan_state>();
95
95
pen_t pens[LEPRECHN_NUM_PENS];
98
98
leprechn_get_pens(pens);
100
for (offs = 0; offs < state->videoram_size; offs++)
100
for (offs = 0; offs < state->m_videoram_size; offs++)
102
102
UINT8 y = offs >> 8;
103
103
UINT8 x = offs & 0xff;
105
*BITMAP_ADDR32(bitmap, y, x) = pens[state->videoram[offs]];
105
*BITMAP_ADDR32(bitmap, y, x) = pens[state->m_videoram[offs]];
119
119
static WRITE8_DEVICE_HANDLER( video_data_w )
121
gameplan_state *state = device->machine->driver_data<gameplan_state>();
121
gameplan_state *state = device->machine().driver_data<gameplan_state>();
123
state->video_data = data;
123
state->m_video_data = data;
127
127
static WRITE8_DEVICE_HANDLER( gameplan_video_command_w )
129
gameplan_state *state = device->machine->driver_data<gameplan_state>();
129
gameplan_state *state = device->machine().driver_data<gameplan_state>();
131
state->video_command = data & 0x07;
131
state->m_video_command = data & 0x07;
135
135
static WRITE8_DEVICE_HANDLER( leprechn_video_command_w )
137
gameplan_state *state = device->machine->driver_data<gameplan_state>();
137
gameplan_state *state = device->machine().driver_data<gameplan_state>();
139
state->video_command = (data >> 3) & 0x07;
139
state->m_video_command = (data >> 3) & 0x07;
143
143
static TIMER_CALLBACK( clear_screen_done_callback )
145
gameplan_state *state = machine->driver_data<gameplan_state>();
145
gameplan_state *state = machine.driver_data<gameplan_state>();
147
147
/* indicate that the we are done clearing the screen */
148
state->via_0->write_ca1(0);
148
state->m_via_0->write_ca1(0);
152
152
static WRITE_LINE_DEVICE_HANDLER( video_command_trigger_w )
154
gameplan_state *driver_state = device->machine->driver_data<gameplan_state>();
154
gameplan_state *driver_state = device->machine().driver_data<gameplan_state>();
158
switch (driver_state->video_command)
158
switch (driver_state->m_video_command)
162
162
/* auto-adjust X? */
163
if (driver_state->video_data & 0x10)
163
if (driver_state->m_video_data & 0x10)
165
if (driver_state->video_data & 0x40)
166
driver_state->video_x = driver_state->video_x - 1;
165
if (driver_state->m_video_data & 0x40)
166
driver_state->m_video_x = driver_state->m_video_x - 1;
168
driver_state->video_x = driver_state->video_x + 1;
168
driver_state->m_video_x = driver_state->m_video_x + 1;
171
171
/* auto-adjust Y? */
172
if (driver_state->video_data & 0x20)
172
if (driver_state->m_video_data & 0x20)
174
if (driver_state->video_data & 0x80)
175
driver_state->video_y = driver_state->video_y - 1;
174
if (driver_state->m_video_data & 0x80)
175
driver_state->m_video_y = driver_state->m_video_y - 1;
177
driver_state->video_y = driver_state->video_y + 1;
177
driver_state->m_video_y = driver_state->m_video_y + 1;
180
driver_state->videoram[driver_state->video_y * (HBSTART - HBEND) + driver_state->video_x] = driver_state->video_data & 0x0f;
180
driver_state->m_videoram[driver_state->m_video_y * (HBSTART - HBEND) + driver_state->m_video_x] = driver_state->m_video_data & 0x0f;
184
184
/* load X register */
186
driver_state->video_x = driver_state->video_data;
186
driver_state->m_video_x = driver_state->m_video_data;
189
189
/* load Y register */
191
driver_state->video_y = driver_state->video_data;
191
driver_state->m_video_y = driver_state->m_video_data;
194
194
/* clear screen */
196
196
/* indicate that the we are busy */
198
driver_state->via_0->write_ca1(1);
198
driver_state->m_via_0->write_ca1(1);
201
memset(driver_state->videoram, driver_state->video_data & 0x0f, driver_state->videoram_size);
201
memset(driver_state->m_videoram, driver_state->m_video_data & 0x0f, driver_state->m_videoram_size);
203
203
/* set a timer for an arbitrarily short period.
204
204
The real time it takes to clear to screen is not
205
205
important to the software */
206
timer_call_after_resynch(device->machine, NULL, 0, clear_screen_done_callback);
206
device->machine().scheduler().synchronize(FUNC(clear_screen_done_callback));
267
267
static TIMER_CALLBACK( via_0_ca1_timer_callback )
269
gameplan_state *state = machine->driver_data<gameplan_state>();
269
gameplan_state *state = machine.driver_data<gameplan_state>();
271
271
/* !VBLANK is connected to CA1 */
272
state->via_0->write_ca1(param);
272
state->m_via_0->write_ca1(param);
275
timer_adjust_oneshot(state->via_0_ca1_timer, machine->primary_screen->time_until_pos(VBSTART), 0);
275
state->m_via_0_ca1_timer->adjust(machine.primary_screen->time_until_pos(VBSTART));
277
timer_adjust_oneshot(state->via_0_ca1_timer, machine->primary_screen->time_until_pos(VBEND), 1);
277
state->m_via_0_ca1_timer->adjust(machine.primary_screen->time_until_pos(VBEND), 1);
287
287
static VIDEO_START( common )
289
gameplan_state *state = machine->driver_data<gameplan_state>();
291
state->videoram_size = (HBSTART - HBEND) * (VBSTART - VBEND);
292
state->videoram = auto_alloc_array(machine, UINT8, state->videoram_size);
294
state->via_0_ca1_timer = timer_alloc(machine, via_0_ca1_timer_callback, NULL);
289
gameplan_state *state = machine.driver_data<gameplan_state>();
291
state->m_videoram_size = (HBSTART - HBEND) * (VBSTART - VBEND);
292
state->m_videoram = auto_alloc_array(machine, UINT8, state->m_videoram_size);
294
state->m_via_0_ca1_timer = machine.scheduler().timer_alloc(FUNC(via_0_ca1_timer_callback));
296
296
/* register for save states */
297
state_save_register_global_pointer(machine, state->videoram, state->videoram_size);
297
state->save_pointer(NAME(state->m_videoram), state->m_videoram_size);
342
342
MCFG_VIDEO_RESET(gameplan)
344
344
MCFG_VIDEO_START(gameplan)
345
MCFG_VIDEO_UPDATE(gameplan)
347
346
MCFG_SCREEN_ADD("screen", RASTER)
348
347
MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
349
348
MCFG_SCREEN_RAW_PARAMS(GAMEPLAN_PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART)
349
MCFG_SCREEN_UPDATE(gameplan)
350
350
MACHINE_CONFIG_END
353
353
MACHINE_CONFIG_FRAGMENT( leprechn_video )
354
354
MCFG_VIDEO_START(leprechn)
355
MCFG_VIDEO_UPDATE(leprechn)
355
MCFG_SCREEN_MODIFY("screen")
356
MCFG_SCREEN_UPDATE(leprechn)
356
357
MACHINE_CONFIG_END
359
360
MACHINE_CONFIG_DERIVED( trvquest_video, gameplan_video )
360
361
MCFG_VIDEO_START(trvquest)
361
MCFG_VIDEO_UPDATE(gameplan)
362
MCFG_SCREEN_MODIFY("screen")
363
MCFG_SCREEN_UPDATE(gameplan)
362
364
MACHINE_CONFIG_END