1
/***************************************************************************
5
Functions to emulate the video hardware of the machine.
7
***************************************************************************/
10
#include "includes/jack.h"
13
WRITE8_HANDLER( jack_videoram_w )
15
jack_state *state = space->machine().driver_data<jack_state>();
16
state->m_videoram[offset] = data;
17
tilemap_mark_tile_dirty(state->m_bg_tilemap, offset);
20
WRITE8_HANDLER( jack_colorram_w )
22
jack_state *state = space->machine().driver_data<jack_state>();
23
state->m_colorram[offset] = data;
24
tilemap_mark_tile_dirty(state->m_bg_tilemap, offset);
27
WRITE8_HANDLER( jack_paletteram_w )
29
/* RGB output is inverted */
30
paletteram_BBGGGRRR_w(space, offset, ~data);
33
READ8_HANDLER( jack_flipscreen_r )
35
flip_screen_set(space->machine(), offset);
39
WRITE8_HANDLER( jack_flipscreen_w )
41
flip_screen_set(space->machine(), offset);
44
static TILE_GET_INFO( get_bg_tile_info )
46
jack_state *state = machine.driver_data<jack_state>();
47
int code = state->m_videoram[tile_index] + ((state->m_colorram[tile_index] & 0x18) << 5);
48
int color = state->m_colorram[tile_index] & 0x07;
50
// striv: state->m_colorram[tile_index] & 0x80 ???
52
SET_TILE_INFO(0, code, color, 0);
55
static UINT32 tilemap_scan_cols_flipy( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
57
/* logical (col,row) -> memory offset */
58
return (col * num_rows) + (num_rows - 1 - row);
63
jack_state *state = machine.driver_data<jack_state>();
64
state->m_bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_cols_flipy, 8, 8, 32, 32);
67
static void jack_draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
69
jack_state *state = machine.driver_data<jack_state>();
70
UINT8 *spriteram = state->m_spriteram;
73
for (offs = state->m_spriteram_size - 4; offs >= 0; offs -= 4)
75
int sx, sy, num, color, flipx, flipy;
77
sx = spriteram[offs + 1];
79
num = spriteram[offs + 2] + ((spriteram[offs + 3] & 0x08) << 5);
80
color = spriteram[offs + 3] & 0x07;
81
flipx = (spriteram[offs + 3] & 0x80);
82
flipy = (spriteram[offs + 3] & 0x40);
84
if (flip_screen_get(machine))
92
drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
100
SCREEN_UPDATE( jack )
102
jack_state *state = screen->machine().driver_data<jack_state>();
103
tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);
104
jack_draw_sprites(screen->machine(), bitmap, cliprect);
109
Joinem has a bit different video hardware with proms based palette,
110
3bpp gfx and different banking / colors bits
113
PALETTE_INIT( joinem )
117
for (i = 0; i < machine.total_colors(); i++)
119
int bit0, bit1, bit2, r, g, b;
120
bit0 = (color_prom[i] >> 0) & 0x01;
121
bit1 = (color_prom[i] >> 1) & 0x01;
122
bit2 = (color_prom[i] >> 2) & 0x01;
123
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
124
bit0 = (color_prom[i] >> 3) & 0x01;
125
bit1 = (color_prom[i] >> 4) & 0x01;
126
bit2 = (color_prom[i] >> 5) & 0x01;
127
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
129
bit1 = (color_prom[i] >> 6) & 0x01;
130
bit2 = (color_prom[i] >> 7) & 0x01;
131
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
133
palette_set_color(machine, i, MAKE_RGB(r,g,b));
137
static TILE_GET_INFO( joinem_get_bg_tile_info )
139
jack_state *state = machine.driver_data<jack_state>();
140
int code = state->m_videoram[tile_index] + ((state->m_colorram[tile_index] & 0x03) << 8);
141
int color = (state->m_colorram[tile_index] & 0x38) >> 3;
143
SET_TILE_INFO(0, code, color, 0);
146
VIDEO_START( joinem )
148
jack_state *state = machine.driver_data<jack_state>();
149
state->m_bg_tilemap = tilemap_create(machine, joinem_get_bg_tile_info, tilemap_scan_cols_flipy, 8, 8, 32, 32);
152
static void joinem_draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
154
jack_state *state = machine.driver_data<jack_state>();
155
UINT8 *spriteram = state->m_spriteram;
158
for (offs = state->m_spriteram_size - 4; offs >= 0; offs -= 4)
160
int sx, sy, num, color, flipx, flipy;
162
sx = spriteram[offs + 1];
163
sy = spriteram[offs];
164
num = spriteram[offs + 2] + ((spriteram[offs + 3] & 0x01) << 8);
165
color = (spriteram[offs + 3] & 0x38) >> 3;
166
flipx = (spriteram[offs + 3] & 0x80);
167
flipy = (spriteram[offs + 3] & 0x40);
169
if (flip_screen_get(machine))
177
drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
185
SCREEN_UPDATE( joinem )
187
jack_state *state = screen->machine().driver_data<jack_state>();
188
tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);
189
joinem_draw_sprites(screen->machine(), bitmap, cliprect);