27
UINT8 *wiz_attributesram;
28
UINT8 *wiz_attributesram2;
30
static INT32 flipx, flipy;
33
UINT8 *wiz_sprite_bank;
34
static UINT8 char_bank[2];
35
static UINT8 palbank[2];
36
static int palette_bank;
41
state_save_register_global_array(machine, char_bank);
42
state_save_register_global_array(machine, palbank);
43
state_save_register_global(machine, flipx);
44
state_save_register_global(machine, flipy);
45
state_save_register_global(machine, bgpen);
28
wiz_state *state = machine.driver_data<wiz_state>();
29
state_save_register_global_array(machine, state->m_char_bank);
30
state_save_register_global_array(machine, state->m_palbank);
31
state_save_register_global(machine, state->m_flipx);
32
state_save_register_global(machine, state->m_flipy);
33
state_save_register_global(machine, state->m_bgpen);
48
36
/***************************************************************************
73
61
bit2 = (color_prom[0] >> 2) & 0x01;
74
62
bit3 = (color_prom[0] >> 3) & 0x01;
75
63
r = 0x0e * bit0 + 0x1f * bit1 + 0x42 * bit2 + 0x90 * bit3;
76
bit0 = (color_prom[machine->total_colors()] >> 0) & 0x01;
77
bit1 = (color_prom[machine->total_colors()] >> 1) & 0x01;
78
bit2 = (color_prom[machine->total_colors()] >> 2) & 0x01;
79
bit3 = (color_prom[machine->total_colors()] >> 3) & 0x01;
64
bit0 = (color_prom[machine.total_colors()] >> 0) & 0x01;
65
bit1 = (color_prom[machine.total_colors()] >> 1) & 0x01;
66
bit2 = (color_prom[machine.total_colors()] >> 2) & 0x01;
67
bit3 = (color_prom[machine.total_colors()] >> 3) & 0x01;
80
68
g = 0x0e * bit0 + 0x1f * bit1 + 0x42 * bit2 + 0x90 * bit3;
81
bit0 = (color_prom[2*machine->total_colors()] >> 0) & 0x01;
82
bit1 = (color_prom[2*machine->total_colors()] >> 1) & 0x01;
83
bit2 = (color_prom[2*machine->total_colors()] >> 2) & 0x01;
84
bit3 = (color_prom[2*machine->total_colors()] >> 3) & 0x01;
69
bit0 = (color_prom[2*machine.total_colors()] >> 0) & 0x01;
70
bit1 = (color_prom[2*machine.total_colors()] >> 1) & 0x01;
71
bit2 = (color_prom[2*machine.total_colors()] >> 2) & 0x01;
72
bit3 = (color_prom[2*machine.total_colors()] >> 3) & 0x01;
85
73
b = 0x0e * bit0 + 0x1f * bit1 + 0x42 * bit2 + 0x90 * bit3;
87
75
palette_set_color(machine,i,MAKE_RGB(r,g,b));
93
81
WRITE8_HANDLER( wiz_palettebank_w )
95
palbank[offset] = data & 1;
96
palette_bank = palbank[0] + 2 * palbank[1];
83
wiz_state *state = space->machine().driver_data<wiz_state>();
84
state->m_palbank[offset] = data & 1;
85
state->m_palette_bank = state->m_palbank[0] + 2 * state->m_palbank[1];
99
88
WRITE8_HANDLER( wiz_bgcolor_w )
90
wiz_state *state = space->machine().driver_data<wiz_state>();
91
state->m_bgpen = data;
104
94
WRITE8_HANDLER( wiz_char_bank_select_w )
106
char_bank[offset] = data & 1;
96
wiz_state *state = space->machine().driver_data<wiz_state>();
97
state->m_char_bank[offset] = data & 1;
109
100
WRITE8_HANDLER( wiz_flipx_w )
102
wiz_state *state = space->machine().driver_data<wiz_state>();
103
state->m_flipx = data;
115
107
WRITE8_HANDLER( wiz_flipy_w )
109
wiz_state *state = space->machine().driver_data<wiz_state>();
110
state->m_flipy = data;
120
static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int bank, int colortype)
113
static void draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int bank, int colortype)
122
wiz_state *state = machine->driver_data<wiz_state>();
123
UINT8 *videoram = state->videoram;
115
wiz_state *state = machine.driver_data<wiz_state>();
116
UINT8 *videoram = state->m_videoram;
126
119
/* for every character in the Video RAM, check if it has been modified */
138
col = (wiz_attributesram[2 * sx + 1] & 0x07);
131
col = (state->m_attributesram[2 * sx + 1] & 0x07);
142
col = (wiz_attributesram[2 * (offs % 32) + 1] & 0x04) + (videoram[offs] & 3);
135
col = (state->m_attributesram[2 * (offs % 32) + 1] & 0x04) + (videoram[offs] & 3);
145
scroll = (8*sy + 256 - wiz_attributesram[2 * sx]) % 256;
138
scroll = (8*sy + 256 - state->m_attributesram[2 * sx]) % 256;
148
141
scroll = (248 - scroll) % 256;
150
if (flipx) sx = 31 - sx;
153
drawgfx_transpen(bitmap,cliprect,machine->gfx[bank],
143
if (state->m_flipx) sx = 31 - sx;
146
drawgfx_transpen(bitmap,cliprect,machine.gfx[bank],
155
col + 8 * palette_bank,
148
col + 8 * state->m_palette_bank,
149
state->m_flipx,state->m_flipy,
161
static void draw_foreground(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int colortype)
154
static void draw_foreground(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int colortype)
156
wiz_state *state = machine.driver_data<wiz_state>();
165
159
/* draw the frontmost playfield. They are characters, but draw them as sprites. */
176
col = (wiz_attributesram2[2 * sx + 1] & 0x07);
170
col = (state->m_attributesram2[2 * sx + 1] & 0x07);
180
col = (wiz_colorram2[offs] & 0x07);
174
col = (state->m_colorram2[offs] & 0x07);
183
scroll = (8*sy + 256 - wiz_attributesram2[2 * sx]) % 256;
177
scroll = (8*sy + 256 - state->m_attributesram2[2 * sx]) % 256;
186
180
scroll = (248 - scroll) % 256;
188
if (flipx) sx = 31 - sx;
191
drawgfx_transpen(bitmap,cliprect,machine->gfx[char_bank[1]],
193
col + 8 * palette_bank,
182
if (state->m_flipx) sx = 31 - sx;
185
drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_char_bank[1]],
186
state->m_videoram2[offs],
187
col + 8 * state->m_palette_bank,
188
state->m_flipx,state->m_flipy,
199
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,
193
static void draw_sprites(running_machine &machine, bitmap_t *bitmap,
200
194
const rectangle *cliprect, UINT8* sprite_ram,
197
wiz_state *state = machine.driver_data<wiz_state>();
205
for (offs = machine->generic.spriteram_size - 4;offs >= 0;offs -= 4)
200
for (offs = state->m_spriteram_size - 4;offs >= 0;offs -= 4)
213
208
if (!sx || !sy) continue;
215
if ( flipx) sx = 240 - sx;
216
if (!flipy) sy = 240 - sy;
210
if ( state->m_flipx) sx = 240 - sx;
211
if (!state->m_flipy) sy = 240 - sy;
218
drawgfx_transpen(bitmap,cliprect,machine->gfx[bank],
213
drawgfx_transpen(bitmap,cliprect,machine.gfx[bank],
219
214
sprite_ram[offs + 1],
220
(sprite_ram[offs + 2] & 0x07) + 8 * palette_bank,
215
(sprite_ram[offs + 2] & 0x07) + 8 * state->m_palette_bank,
216
state->m_flipx,state->m_flipy,
227
VIDEO_UPDATE( kungfut )
222
SCREEN_UPDATE( kungfut )
229
bitmap_fill(bitmap,cliprect,bgpen);
230
draw_background(screen->machine, bitmap, cliprect, 2 + char_bank[0] , 0);
231
draw_foreground(screen->machine, bitmap, cliprect, 0);
232
draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram2.u8, 4);
233
draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram.u8 , 5);
224
wiz_state *state = screen->machine().driver_data<wiz_state>();
225
bitmap_fill(bitmap,cliprect,state->m_bgpen);
226
draw_background(screen->machine(), bitmap, cliprect, 2 + state->m_char_bank[0] , 0);
227
draw_foreground(screen->machine(), bitmap, cliprect, 0);
228
draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram2, 4);
229
draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram , 5);
235
wiz_state *state = screen->machine().driver_data<wiz_state>();
240
237
const rectangle* visible_area;
242
bitmap_fill(bitmap,cliprect,bgpen);
243
draw_background(screen->machine, bitmap, cliprect, 2 + ((char_bank[0] << 1) | char_bank[1]), 0);
244
draw_foreground(screen->machine, bitmap, cliprect, 0);
246
visible_area = flipx ? &spritevisibleareaflipx : &spritevisiblearea;
248
bank = 7 + *wiz_sprite_bank;
250
draw_sprites(screen->machine, bitmap, visible_area, screen->machine->generic.spriteram2.u8, 6);
251
draw_sprites(screen->machine, bitmap, visible_area, screen->machine->generic.spriteram.u8 , bank);
239
bitmap_fill(bitmap,cliprect,state->m_bgpen);
240
draw_background(screen->machine(), bitmap, cliprect, 2 + ((state->m_char_bank[0] << 1) | state->m_char_bank[1]), 0);
241
draw_foreground(screen->machine(), bitmap, cliprect, 0);
243
visible_area = state->m_flipx ? &spritevisibleareaflipx : &spritevisiblearea;
245
bank = 7 + *state->m_sprite_bank;
247
draw_sprites(screen->machine(), bitmap, visible_area, state->m_spriteram2, 6);
248
draw_sprites(screen->machine(), bitmap, visible_area, state->m_spriteram , bank);
256
VIDEO_UPDATE( stinger )
253
SCREEN_UPDATE( stinger )
258
bitmap_fill(bitmap,cliprect,bgpen);
259
draw_background(screen->machine, bitmap, cliprect, 2 + char_bank[0], 1);
260
draw_foreground(screen->machine, bitmap, cliprect, 1);
261
draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram2.u8, 4);
262
draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram.u8 , 5);
255
wiz_state *state = screen->machine().driver_data<wiz_state>();
256
bitmap_fill(bitmap,cliprect,state->m_bgpen);
257
draw_background(screen->machine(), bitmap, cliprect, 2 + state->m_char_bank[0], 1);
258
draw_foreground(screen->machine(), bitmap, cliprect, 1);
259
draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram2, 4);
260
draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram , 5);