~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mame/video/wolfpack.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
Atari Wolf Pack (prototype) video emulation
4
 
 
5
 
***************************************************************************/
6
 
 
7
 
#include "emu.h"
8
 
#include "includes/wolfpack.h"
9
 
 
10
 
 
11
 
PALETTE_INIT( wolfpack )
12
 
{
13
 
        int i;
14
 
 
15
 
        /* allocate the colortable */
16
 
        machine.colortable = colortable_alloc(machine, 8);
17
 
 
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));
22
 
 
23
 
        for (i = 0; i < 4; i++)
24
 
        {
25
 
                rgb_t color = colortable_palette_get_color(machine.colortable, i);
26
 
 
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));
31
 
        }
32
 
 
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);
45
 
}
46
 
 
47
 
 
48
 
WRITE8_HANDLER( wolfpack_ship_size_w )
49
 
{
50
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
51
 
        state->m_ship_size = data;
52
 
}
53
 
WRITE8_HANDLER( wolfpack_video_invert_w )
54
 
{
55
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
56
 
        state->m_video_invert = data & 1;
57
 
}
58
 
WRITE8_HANDLER( wolfpack_ship_reflect_w )
59
 
{
60
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
61
 
        state->m_ship_reflect = data & 1;
62
 
}
63
 
WRITE8_HANDLER( wolfpack_pt_pos_select_w )
64
 
{
65
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
66
 
        state->m_pt_pos_select = data & 1;
67
 
}
68
 
WRITE8_HANDLER( wolfpack_pt_horz_w )
69
 
{
70
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
71
 
        state->m_pt_horz = data;
72
 
}
73
 
WRITE8_HANDLER( wolfpack_pt_pic_w )
74
 
{
75
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
76
 
        state->m_pt_pic = data & 0x3f;
77
 
}
78
 
WRITE8_HANDLER( wolfpack_ship_h_w )
79
 
{
80
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
81
 
        state->m_ship_h = data;
82
 
}
83
 
WRITE8_HANDLER( wolfpack_torpedo_pic_w )
84
 
{
85
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
86
 
        state->m_torpedo_pic = data;
87
 
}
88
 
WRITE8_HANDLER( wolfpack_ship_h_precess_w )
89
 
{
90
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
91
 
        state->m_ship_h_precess = data & 0x3f;
92
 
}
93
 
WRITE8_HANDLER( wolfpack_ship_pic_w )
94
 
{
95
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
96
 
        state->m_ship_pic = data & 0x0f;
97
 
}
98
 
WRITE8_HANDLER( wolfpack_torpedo_h_w )
99
 
{
100
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
101
 
        state->m_torpedo_h = data;
102
 
}
103
 
WRITE8_HANDLER( wolfpack_torpedo_v_w )
104
 
{
105
 
        wolfpack_state *state = space->machine().driver_data<wolfpack_state>();
106
 
        state->m_torpedo_v = data;
107
 
}
108
 
 
109
 
 
110
 
VIDEO_START( wolfpack )
111
 
{
112
 
        wolfpack_state *state = machine.driver_data<wolfpack_state>();
113
 
        UINT16 val = 0;
114
 
 
115
 
        int i;
116
 
 
117
 
        state->m_LFSR = auto_alloc_array(machine, UINT8, 0x8000);
118
 
 
119
 
        state->m_helper = machine.primary_screen->alloc_compatible_bitmap();
120
 
 
121
 
        for (i = 0; i < 0x8000; i++)
122
 
        {
123
 
                int bit = (val >> 0x0) ^ (val >> 0xe) ^ 1;
124
 
 
125
 
                val = (val << 1) | (bit & 1);
126
 
 
127
 
                state->m_LFSR[i] = (val & 0xc00) == 0xc00;
128
 
        }
129
 
 
130
 
        state->m_current_index = 0x80;
131
 
}
132
 
 
133
 
 
134
 
static void draw_ship(running_machine &machine, bitmap_t* bitmap, const rectangle* cliprect)
135
 
{
136
 
        wolfpack_state *state = machine.driver_data<wolfpack_state>();
137
 
        static const UINT32 scaler[] =
138
 
        {
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
155
 
        };
156
 
 
157
 
        int chop = (scaler[state->m_ship_size >> 2] * state->m_ship_h_precess) >> 16;
158
 
 
159
 
        drawgfxzoom_transpen(bitmap, cliprect,
160
 
                machine.gfx[1],
161
 
                state->m_ship_pic,
162
 
                0,
163
 
                state->m_ship_reflect, 0,
164
 
                2 * (state->m_ship_h - chop),
165
 
                128,
166
 
                2 * scaler[state->m_ship_size >> 2], scaler[state->m_ship_size >> 2], 0);
167
 
}
168
 
 
169
 
 
170
 
static void draw_torpedo(running_machine &machine, bitmap_t* bitmap, const rectangle* cliprect)
171
 
{
172
 
        wolfpack_state *state = machine.driver_data<wolfpack_state>();
173
 
        int count = 0;
174
 
 
175
 
        int x;
176
 
        int y;
177
 
 
178
 
        drawgfx_transpen(bitmap, cliprect,
179
 
                machine.gfx[3],
180
 
                state->m_torpedo_pic,
181
 
                0,
182
 
                0, 0,
183
 
                2 * (244 - state->m_torpedo_h),
184
 
                224 - state->m_torpedo_v, 0);
185
 
 
186
 
        for (y = 16; y < 224 - state->m_torpedo_v; y++)
187
 
        {
188
 
                int x1;
189
 
                int x2;
190
 
 
191
 
                if (y % 16 == 1)
192
 
                        count = (count - 1) & 7;
193
 
 
194
 
                x1 = 248 - state->m_torpedo_h - count;
195
 
                x2 = 248 - state->m_torpedo_h + count;
196
 
 
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;
200
 
        }
201
 
}
202
 
 
203
 
 
204
 
static void draw_pt(running_machine &machine, bitmap_t* bitmap, const rectangle* cliprect)
205
 
{
206
 
        wolfpack_state *state = machine.driver_data<wolfpack_state>();
207
 
        rectangle rect = *cliprect;
208
 
 
209
 
        if (!(state->m_pt_pic & 0x20))
210
 
                rect.min_x = 256;
211
 
 
212
 
        if (!(state->m_pt_pic & 0x10))
213
 
                rect.max_x = 255;
214
 
 
215
 
        drawgfx_transpen(bitmap, &rect,
216
 
                machine.gfx[2],
217
 
                state->m_pt_pic,
218
 
                0,
219
 
                0, 0,
220
 
                2 * state->m_pt_horz,
221
 
                state->m_pt_pos_select ? 0x70 : 0xA0, 0);
222
 
 
223
 
        drawgfx_transpen(bitmap, &rect,
224
 
                machine.gfx[2],
225
 
                state->m_pt_pic,
226
 
                0,
227
 
                0, 0,
228
 
                2 * state->m_pt_horz - 512,
229
 
                state->m_pt_pos_select ? 0x70 : 0xA0, 0);
230
 
}
231
 
 
232
 
 
233
 
static void draw_water(colortable_t *colortable, bitmap_t* bitmap, const rectangle* cliprect)
234
 
{
235
 
        rectangle rect = *cliprect;
236
 
 
237
 
        int x;
238
 
        int y;
239
 
 
240
 
        if (rect.max_y > 127)
241
 
                rect.max_y = 127;
242
 
 
243
 
        for (y = rect.min_y; y <= rect.max_y; y++)
244
 
        {
245
 
                UINT16* p = BITMAP_ADDR16(bitmap, y, 0);
246
 
 
247
 
                for (x = rect.min_x; x <= rect.max_x; x++)
248
 
                        p[x] = colortable_entry_get_value(colortable, p[x]) | 0x08;
249
 
        }
250
 
}
251
 
 
252
 
 
253
 
SCREEN_UPDATE( wolfpack )
254
 
{
255
 
        wolfpack_state *state = screen->machine().driver_data<wolfpack_state>();
256
 
        int i;
257
 
        int j;
258
 
 
259
 
        UINT8 color = 0x48;
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;
264
 
 
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));
269
 
 
270
 
        bitmap_fill(bitmap, cliprect, state->m_video_invert);
271
 
 
272
 
        for (i = 0; i < 8; i++)
273
 
                for (j = 0; j < 32; j++)
274
 
                {
275
 
                        int code = state->m_alpha_num_ram[32 * i + j];
276
 
 
277
 
                        drawgfx_opaque(bitmap, cliprect,
278
 
                                screen->machine().gfx[0],
279
 
                                code,
280
 
                                state->m_video_invert,
281
 
                                0, 0,
282
 
                                16 * j,
283
 
                                192 + 8 * i);
284
 
                }
285
 
 
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);
290
 
        return 0;
291
 
}
292
 
 
293
 
 
294
 
SCREEN_EOF( wolfpack )
295
 
{
296
 
        wolfpack_state *state = machine.driver_data<wolfpack_state>();
297
 
        rectangle rect;
298
 
 
299
 
        int x;
300
 
        int y;
301
 
 
302
 
        rect.min_x = 0;
303
 
        rect.min_y = 0;
304
 
        rect.max_x = state->m_helper->width - 1;
305
 
        rect.max_y = state->m_helper->height - 1;
306
 
 
307
 
        bitmap_fill(state->m_helper, &rect, 0);
308
 
 
309
 
        draw_ship(machine, state->m_helper, &rect);
310
 
 
311
 
        for (y = 128; y < 224 - state->m_torpedo_v; y++)
312
 
        {
313
 
                int x1 = 248 - state->m_torpedo_h - 1;
314
 
                int x2 = 248 - state->m_torpedo_h + 1;
315
 
 
316
 
                for (x = 2 * x1; x < 2 * x2; x++)
317
 
                {
318
 
                        if (x < 0 || x >= state->m_helper->width)
319
 
                                continue;
320
 
                        if (y < 0 || y >= state->m_helper->height)
321
 
                                continue;
322
 
 
323
 
                        if (*BITMAP_ADDR16(state->m_helper, y, x))
324
 
                                state->m_collision = 1;
325
 
                }
326
 
        }
327
 
 
328
 
        state->m_current_index += 0x300 * 262;
329
 
}