1
/***************************************************************************
3
Atari Wolf Pack (prototype) video emulation
5
***************************************************************************/
8
#include "includes/wolfpack.h"
11
PALETTE_INIT( wolfpack )
15
/* allocate the colortable */
16
machine.colortable = colortable_alloc(machine, 8);
18
colortable_palette_set_color(machine.colortable, 0, MAKE_RGB(0x00, 0x00, 0x00));
19
colortable_palette_set_color(machine.colortable, 1, MAKE_RGB(0xc1, 0xc1, 0xc1));
20
colortable_palette_set_color(machine.colortable, 2, MAKE_RGB(0x81, 0x81, 0x81));
21
colortable_palette_set_color(machine.colortable, 3, MAKE_RGB(0x48, 0x48, 0x48));
23
for (i = 0; i < 4; i++)
25
rgb_t color = colortable_palette_get_color(machine.colortable, i);
27
colortable_palette_set_color(machine.colortable, 4 + i,
28
MAKE_RGB(RGB_RED(color) < 0xb8 ? RGB_RED(color) + 0x48 : 0xff,
29
RGB_GREEN(color) < 0xb8 ? RGB_GREEN(color) + 0x48 : 0xff,
30
RGB_BLUE(color) < 0xb8 ? RGB_BLUE(color) + 0x48 : 0xff));
33
colortable_entry_set_value(machine.colortable, 0x00, 0);
34
colortable_entry_set_value(machine.colortable, 0x01, 1);
35
colortable_entry_set_value(machine.colortable, 0x02, 1);
36
colortable_entry_set_value(machine.colortable, 0x03, 0);
37
colortable_entry_set_value(machine.colortable, 0x04, 0);
38
colortable_entry_set_value(machine.colortable, 0x05, 2);
39
colortable_entry_set_value(machine.colortable, 0x06, 0);
40
colortable_entry_set_value(machine.colortable, 0x07, 3);
41
colortable_entry_set_value(machine.colortable, 0x08, 4);
42
colortable_entry_set_value(machine.colortable, 0x09, 5);
43
colortable_entry_set_value(machine.colortable, 0x0a, 6);
44
colortable_entry_set_value(machine.colortable, 0x0b, 7);
48
WRITE8_HANDLER( wolfpack_ship_size_w )
50
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
51
state->m_ship_size = data;
53
WRITE8_HANDLER( wolfpack_video_invert_w )
55
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
56
state->m_video_invert = data & 1;
58
WRITE8_HANDLER( wolfpack_ship_reflect_w )
60
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
61
state->m_ship_reflect = data & 1;
63
WRITE8_HANDLER( wolfpack_pt_pos_select_w )
65
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
66
state->m_pt_pos_select = data & 1;
68
WRITE8_HANDLER( wolfpack_pt_horz_w )
70
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
71
state->m_pt_horz = data;
73
WRITE8_HANDLER( wolfpack_pt_pic_w )
75
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
76
state->m_pt_pic = data & 0x3f;
78
WRITE8_HANDLER( wolfpack_ship_h_w )
80
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
81
state->m_ship_h = data;
83
WRITE8_HANDLER( wolfpack_torpedo_pic_w )
85
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
86
state->m_torpedo_pic = data;
88
WRITE8_HANDLER( wolfpack_ship_h_precess_w )
90
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
91
state->m_ship_h_precess = data & 0x3f;
93
WRITE8_HANDLER( wolfpack_ship_pic_w )
95
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
96
state->m_ship_pic = data & 0x0f;
98
WRITE8_HANDLER( wolfpack_torpedo_h_w )
100
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
101
state->m_torpedo_h = data;
103
WRITE8_HANDLER( wolfpack_torpedo_v_w )
105
wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
106
state->m_torpedo_v = data;
110
VIDEO_START( wolfpack )
112
wolfpack_state *state = machine.driver_data<wolfpack_state>();
117
state->m_LFSR = auto_alloc_array(machine, UINT8, 0x8000);
119
state->m_helper = machine.primary_screen->alloc_compatible_bitmap();
121
for (i = 0; i < 0x8000; i++)
123
int bit = (val >> 0x0) ^ (val >> 0xe) ^ 1;
125
val = (val << 1) | (bit & 1);
127
state->m_LFSR[i] = (val & 0xc00) == 0xc00;
130
state->m_current_index = 0x80;
134
static void draw_ship(running_machine &machine, bitmap_t* bitmap, const rectangle* cliprect)
136
wolfpack_state *state = machine.driver_data<wolfpack_state>();
137
static const UINT32 scaler[] =
139
0x00000, 0x00500, 0x00a00, 0x01000,
140
0x01000, 0x01200, 0x01500, 0x01800,
141
0x01800, 0x01d00, 0x02200, 0x02800,
142
0x02800, 0x02800, 0x02800, 0x02800,
143
0x02800, 0x03000, 0x03800, 0x04000,
144
0x04000, 0x04500, 0x04a00, 0x05000,
145
0x05000, 0x05500, 0x05a00, 0x06000,
146
0x06000, 0x06a00, 0x07500, 0x08000,
147
0x08000, 0x08a00, 0x09500, 0x0a000,
148
0x0a000, 0x0b000, 0x0c000, 0x0d000,
149
0x0d000, 0x0e000, 0x0f000, 0x10000,
150
0x10000, 0x11a00, 0x13500, 0x15000,
151
0x15000, 0x17500, 0x19a00, 0x1c000,
152
0x1c000, 0x1ea00, 0x21500, 0x24000,
153
0x24000, 0x26a00, 0x29500, 0x2c000,
154
0x2c000, 0x2fa00, 0x33500, 0x37000
157
int chop = (scaler[state->m_ship_size >> 2] * state->m_ship_h_precess) >> 16;
159
drawgfxzoom_transpen(bitmap, cliprect,
163
state->m_ship_reflect, 0,
164
2 * (state->m_ship_h - chop),
166
2 * scaler[state->m_ship_size >> 2], scaler[state->m_ship_size >> 2], 0);
170
static void draw_torpedo(running_machine &machine, bitmap_t* bitmap, const rectangle* cliprect)
172
wolfpack_state *state = machine.driver_data<wolfpack_state>();
178
drawgfx_transpen(bitmap, cliprect,
180
state->m_torpedo_pic,
183
2 * (244 - state->m_torpedo_h),
184
224 - state->m_torpedo_v, 0);
186
for (y = 16; y < 224 - state->m_torpedo_v; y++)
192
count = (count - 1) & 7;
194
x1 = 248 - state->m_torpedo_h - count;
195
x2 = 248 - state->m_torpedo_h + count;
197
for (x = 2 * x1; x < 2 * x2; x++)
198
if (state->m_LFSR[(state->m_current_index + 0x300 * y + x) % 0x8000])
199
*BITMAP_ADDR16(bitmap, y, x) = 1;
204
static void draw_pt(running_machine &machine, bitmap_t* bitmap, const rectangle* cliprect)
206
wolfpack_state *state = machine.driver_data<wolfpack_state>();
207
rectangle rect = *cliprect;
209
if (!(state->m_pt_pic & 0x20))
212
if (!(state->m_pt_pic & 0x10))
215
drawgfx_transpen(bitmap, &rect,
220
2 * state->m_pt_horz,
221
state->m_pt_pos_select ? 0x70 : 0xA0, 0);
223
drawgfx_transpen(bitmap, &rect,
228
2 * state->m_pt_horz - 512,
229
state->m_pt_pos_select ? 0x70 : 0xA0, 0);
233
static void draw_water(colortable_t *colortable, bitmap_t* bitmap, const rectangle* cliprect)
235
rectangle rect = *cliprect;
240
if (rect.max_y > 127)
243
for (y = rect.min_y; y <= rect.max_y; y++)
245
UINT16* p = BITMAP_ADDR16(bitmap, y, 0);
247
for (x = rect.min_x; x <= rect.max_x; x++)
248
p[x] = colortable_entry_get_value(colortable, p[x]) | 0x08;
253
SCREEN_UPDATE( wolfpack )
255
wolfpack_state *state = screen->machine().driver_data<wolfpack_state>();
260
if (state->m_ship_size & 0x10) color += 0x13;
261
if (state->m_ship_size & 0x20) color += 0x22;
262
if (state->m_ship_size & 0x40) color += 0x3a;
263
if (state->m_ship_size & 0x80) color += 0x48;
265
colortable_palette_set_color(screen->machine().colortable, 3, MAKE_RGB(color,color,color));
266
colortable_palette_set_color(screen->machine().colortable, 7, MAKE_RGB(color < 0xb8 ? color + 0x48 : 0xff,
267
color < 0xb8 ? color + 0x48 : 0xff,
268
color < 0xb8 ? color + 0x48 : 0xff));
270
bitmap_fill(bitmap, cliprect, state->m_video_invert);
272
for (i = 0; i < 8; i++)
273
for (j = 0; j < 32; j++)
275
int code = state->m_alpha_num_ram[32 * i + j];
277
drawgfx_opaque(bitmap, cliprect,
278
screen->machine().gfx[0],
280
state->m_video_invert,
286
draw_pt(screen->machine(), bitmap, cliprect);
287
draw_ship(screen->machine(), bitmap, cliprect);
288
draw_torpedo(screen->machine(), bitmap, cliprect);
289
draw_water(screen->machine().colortable, bitmap, cliprect);
294
SCREEN_EOF( wolfpack )
296
wolfpack_state *state = machine.driver_data<wolfpack_state>();
304
rect.max_x = state->m_helper->width - 1;
305
rect.max_y = state->m_helper->height - 1;
307
bitmap_fill(state->m_helper, &rect, 0);
309
draw_ship(machine, state->m_helper, &rect);
311
for (y = 128; y < 224 - state->m_torpedo_v; y++)
313
int x1 = 248 - state->m_torpedo_h - 1;
314
int x2 = 248 - state->m_torpedo_h + 1;
316
for (x = 2 * x1; x < 2 * x2; x++)
318
if (x < 0 || x >= state->m_helper->width)
320
if (y < 0 || y >= state->m_helper->height)
323
if (*BITMAP_ADDR16(state->m_helper, y, x))
324
state->m_collision = 1;
328
state->m_current_index += 0x300 * 262;