1
/***************************************************************************
5
Functions to emulate the video hardware of the machine.
7
***************************************************************************/
10
#include "includes/firetrap.h"
13
/***************************************************************************
15
Convert the color PROMs into a more useable format.
17
Fire Trap has one 256x8 and one 256x4 palette PROMs.
18
I don't know for sure how the palette PROMs are connected to the RGB
19
output, but it's probably the usual:
21
bit 7 -- 220 ohm resistor -- GREEN
22
-- 470 ohm resistor -- GREEN
23
-- 1 kohm resistor -- GREEN
24
-- 2.2kohm resistor -- GREEN
25
-- 220 ohm resistor -- RED
26
-- 470 ohm resistor -- RED
27
-- 1 kohm resistor -- RED
28
bit 0 -- 2.2kohm resistor -- RED
30
bit 3 -- 220 ohm resistor -- BLUE
31
-- 470 ohm resistor -- BLUE
32
-- 1 kohm resistor -- BLUE
33
bit 0 -- 2.2kohm resistor -- BLUE
35
***************************************************************************/
37
PALETTE_INIT( firetrap )
42
for (i = 0; i < machine.total_colors(); i++)
44
int bit0, bit1, bit2, bit3, r, g, b;
47
bit0 = (color_prom[i] >> 0) & 0x01;
48
bit1 = (color_prom[i] >> 1) & 0x01;
49
bit2 = (color_prom[i] >> 2) & 0x01;
50
bit3 = (color_prom[i] >> 3) & 0x01;
51
r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
52
bit0 = (color_prom[i] >> 4) & 0x01;
53
bit1 = (color_prom[i] >> 5) & 0x01;
54
bit2 = (color_prom[i] >> 6) & 0x01;
55
bit3 = (color_prom[i] >> 7) & 0x01;
56
g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
57
bit0 = (color_prom[i + machine.total_colors()] >> 0) & 0x01;
58
bit1 = (color_prom[i + machine.total_colors()] >> 1) & 0x01;
59
bit2 = (color_prom[i + machine.total_colors()] >> 2) & 0x01;
60
bit3 = (color_prom[i + machine.total_colors()] >> 3) & 0x01;
61
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
63
palette_set_color(machine, i, MAKE_RGB(r,g,b));
68
/***************************************************************************
70
Callbacks for the TileMap code
72
***************************************************************************/
74
static TILEMAP_MAPPER( get_fg_memory_offset )
76
return (row ^ 0x1f) + (col << 5);
79
static TILEMAP_MAPPER( get_bg_memory_offset )
81
return ((row & 0x0f) ^ 0x0f) | ((col & 0x0f) << 4) |
83
((row & 0x10) << 5) | ((col & 0x10) << 6);
86
static TILE_GET_INFO( get_fg_tile_info )
88
firetrap_state *state = machine.driver_data<firetrap_state>();
89
int code = state->m_fgvideoram[tile_index];
90
int color = state->m_fgvideoram[tile_index + 0x400];
93
code | ((color & 0x01) << 8),
98
INLINE void get_bg_tile_info(running_machine &machine, tile_data *tileinfo, int tile_index, UINT8 *bgvideoram, int gfx_region)
100
int code = bgvideoram[tile_index];
101
int color = bgvideoram[tile_index + 0x100];
104
code + ((color & 0x03) << 8),
106
TILE_FLIPXY((color & 0x0c) >> 2));
109
static TILE_GET_INFO( get_bg1_tile_info )
111
firetrap_state *state = machine.driver_data<firetrap_state>();
112
get_bg_tile_info(machine, tileinfo, tile_index, state->m_bg1videoram, 1);
115
static TILE_GET_INFO( get_bg2_tile_info )
117
firetrap_state *state = machine.driver_data<firetrap_state>();
118
get_bg_tile_info(machine, tileinfo, tile_index, state->m_bg2videoram, 2);
122
/***************************************************************************
124
Start the video hardware emulation.
126
***************************************************************************/
128
VIDEO_START( firetrap )
130
firetrap_state *state = machine.driver_data<firetrap_state>();
131
state->m_fg_tilemap = tilemap_create(machine, get_fg_tile_info, get_fg_memory_offset, 8, 8, 32, 32);
132
state->m_bg1_tilemap = tilemap_create(machine, get_bg1_tile_info, get_bg_memory_offset, 16, 16, 32, 32);
133
state->m_bg2_tilemap = tilemap_create(machine, get_bg2_tile_info, get_bg_memory_offset, 16, 16, 32, 32);
135
tilemap_set_transparent_pen(state->m_fg_tilemap, 0);
136
tilemap_set_transparent_pen(state->m_bg1_tilemap, 0);
140
/***************************************************************************
144
***************************************************************************/
146
WRITE8_HANDLER( firetrap_fgvideoram_w )
148
firetrap_state *state = space->machine().driver_data<firetrap_state>();
149
state->m_fgvideoram[offset] = data;
150
tilemap_mark_tile_dirty(state->m_fg_tilemap, offset & 0x3ff);
153
WRITE8_HANDLER( firetrap_bg1videoram_w )
155
firetrap_state *state = space->machine().driver_data<firetrap_state>();
156
state->m_bg1videoram[offset] = data;
157
tilemap_mark_tile_dirty(state->m_bg1_tilemap, offset & 0x6ff);
160
WRITE8_HANDLER( firetrap_bg2videoram_w )
162
firetrap_state *state = space->machine().driver_data<firetrap_state>();
163
state->m_bg2videoram[offset] = data;
164
tilemap_mark_tile_dirty(state->m_bg2_tilemap, offset & 0x6ff);
168
WRITE8_HANDLER( firetrap_bg1_scrollx_w )
170
firetrap_state *state = space->machine().driver_data<firetrap_state>();
171
state->m_scroll1_x[offset] = data;
172
tilemap_set_scrollx(state->m_bg1_tilemap, 0, state->m_scroll1_x[0] | (state->m_scroll1_x[1] << 8));
175
WRITE8_HANDLER( firetrap_bg1_scrolly_w )
177
firetrap_state *state = space->machine().driver_data<firetrap_state>();
178
state->m_scroll1_y[offset] = data;
179
tilemap_set_scrolly(state->m_bg1_tilemap, 0, -(state->m_scroll1_y[0] | (state->m_scroll1_y[1] << 8)));
182
WRITE8_HANDLER( firetrap_bg2_scrollx_w )
184
firetrap_state *state = space->machine().driver_data<firetrap_state>();
185
state->m_scroll2_x[offset] = data;
186
tilemap_set_scrollx(state->m_bg2_tilemap, 0, state->m_scroll2_x[0] | (state->m_scroll2_x[1] << 8));
189
WRITE8_HANDLER( firetrap_bg2_scrolly_w )
191
firetrap_state *state = space->machine().driver_data<firetrap_state>();
192
state->m_scroll2_y[offset] = data;
193
tilemap_set_scrolly(state->m_bg2_tilemap, 0, -(state->m_scroll2_y[0] | (state->m_scroll2_y[1] << 8)));
197
/***************************************************************************
201
***************************************************************************/
203
static void draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
205
firetrap_state *state = machine.driver_data<firetrap_state>();
208
for (offs = 0; offs < state->m_spriteram_size; offs += 4)
210
int sx, sy, flipx, flipy, code, color;
213
/* the meaning of bit 3 of [offs] is unknown */
215
sy = state->m_spriteram[offs];
216
sx = state->m_spriteram[offs + 2];
217
code = state->m_spriteram[offs + 3] + 4 * (state->m_spriteram[offs + 1] & 0xc0);
218
color = ((state->m_spriteram[offs + 1] & 0x08) >> 2) | (state->m_spriteram[offs + 1] & 0x01);
219
flipx = state->m_spriteram[offs + 1] & 0x04;
220
flipy = state->m_spriteram[offs + 1] & 0x02;
221
if (flip_screen_get(machine))
229
if (state->m_spriteram[offs + 1] & 0x10) /* double width */
231
if (flip_screen_get(machine)) sy -= 16;
233
drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
237
sx,flipy ? sy : sy + 16,0);
238
drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
242
sx,flipy ? sy + 16 : sy,0);
244
/* redraw with wraparound */
245
drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
249
sx - 256,flipy ? sy : sy + 16,0);
250
drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
254
sx - 256,flipy ? sy + 16 : sy,0);
258
drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
264
/* redraw with wraparound */
265
drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
274
SCREEN_UPDATE( firetrap )
276
firetrap_state *state = screen->machine().driver_data<firetrap_state>();
277
tilemap_draw(bitmap, cliprect, state->m_bg2_tilemap, 0, 0);
278
tilemap_draw(bitmap, cliprect, state->m_bg1_tilemap, 0, 0);
279
draw_sprites(screen->machine(), bitmap, cliprect);
280
tilemap_draw(bitmap, cliprect, state->m_fg_tilemap, 0, 0);