~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/mame/video/popeye.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#include "emu.h"
10
10
#include "includes/popeye.h"
11
11
 
12
 
UINT8 *popeye_videoram;
13
 
UINT8 *popeye_colorram;
14
 
UINT8 *popeye_background_pos;
15
 
UINT8 *popeye_palettebank;
16
 
static UINT8 *popeye_bitmapram;
17
12
static const size_t popeye_bitmapram_size = 0x2000;
18
13
 
19
 
static bitmap_t *tmpbitmap2;
20
 
static UINT8 invertmask;
21
 
static UINT8 bitmap_type;
22
14
enum { TYPE_SKYSKIPR, TYPE_POPEYE };
23
15
 
24
 
static tilemap_t *fg_tilemap;
25
16
 
26
 
static UINT8 lastflip;
27
17
 
28
18
/***************************************************************************
29
19
 
59
49
  The bootleg is the same, but the outputs are not inverted.
60
50
 
61
51
***************************************************************************/
62
 
static void convert_color_prom(running_machine *machine,const UINT8 *color_prom)
 
52
static void convert_color_prom(running_machine &machine,const UINT8 *color_prom)
63
53
{
 
54
        popeye_state *state = machine.driver_data<popeye_state>();
64
55
        int i;
65
56
 
66
57
 
74
65
                int bit0,bit1,bit2,r,g,b;
75
66
 
76
67
                /* red component */
77
 
                bit0 = ((color_prom[prom_offs] ^ invertmask) >> 0) & 0x01;
78
 
                bit1 = ((color_prom[prom_offs] ^ invertmask) >> 1) & 0x01;
79
 
                bit2 = ((color_prom[prom_offs] ^ invertmask) >> 2) & 0x01;
 
68
                bit0 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 0) & 0x01;
 
69
                bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 1) & 0x01;
 
70
                bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 2) & 0x01;
80
71
                r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
81
72
                /* green component */
82
 
                bit0 = ((color_prom[prom_offs] ^ invertmask) >> 3) & 0x01;
83
 
                bit1 = ((color_prom[prom_offs] ^ invertmask) >> 4) & 0x01;
84
 
                bit2 = ((color_prom[prom_offs] ^ invertmask) >> 5) & 0x01;
 
73
                bit0 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 3) & 0x01;
 
74
                bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 4) & 0x01;
 
75
                bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 5) & 0x01;
85
76
                g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
86
77
                /* blue component */
87
78
                bit0 = 0;
88
 
                bit1 = ((color_prom[prom_offs] ^ invertmask) >> 6) & 0x01;
89
 
                bit2 = ((color_prom[prom_offs] ^ invertmask) >> 7) & 0x01;
 
79
                bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 6) & 0x01;
 
80
                bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 7) & 0x01;
90
81
                b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
91
82
 
92
83
                palette_set_color(machine,16 + (2 * i) + 1,MAKE_RGB(r,g,b));
101
92
 
102
93
 
103
94
                /* red component */
104
 
                bit0 = ((color_prom[0] ^ invertmask) >> 0) & 0x01;
105
 
                bit1 = ((color_prom[0] ^ invertmask) >> 1) & 0x01;
106
 
                bit2 = ((color_prom[0] ^ invertmask) >> 2) & 0x01;
 
95
                bit0 = ((color_prom[0] ^ state->m_invertmask) >> 0) & 0x01;
 
96
                bit1 = ((color_prom[0] ^ state->m_invertmask) >> 1) & 0x01;
 
97
                bit2 = ((color_prom[0] ^ state->m_invertmask) >> 2) & 0x01;
107
98
                r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
108
99
                /* green component */
109
 
                bit0 = ((color_prom[0] ^ invertmask) >> 3) & 0x01;
110
 
                bit1 = ((color_prom[256] ^ invertmask) >> 0) & 0x01;
111
 
                bit2 = ((color_prom[256] ^ invertmask) >> 1) & 0x01;
 
100
                bit0 = ((color_prom[0] ^ state->m_invertmask) >> 3) & 0x01;
 
101
                bit1 = ((color_prom[256] ^ state->m_invertmask) >> 0) & 0x01;
 
102
                bit2 = ((color_prom[256] ^ state->m_invertmask) >> 1) & 0x01;
112
103
                g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
113
104
                /* blue component */
114
105
                bit0 = 0;
115
 
                bit1 = ((color_prom[256] ^ invertmask) >> 2) & 0x01;
116
 
                bit2 = ((color_prom[256] ^ invertmask) >> 3) & 0x01;
 
106
                bit1 = ((color_prom[256] ^ state->m_invertmask) >> 2) & 0x01;
 
107
                bit2 = ((color_prom[256] ^ state->m_invertmask) >> 3) & 0x01;
117
108
                b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
118
109
 
119
110
                palette_set_color(machine,48+i,MAKE_RGB(r,g,b));
124
115
 
125
116
PALETTE_INIT( popeye )
126
117
{
127
 
        invertmask = 0xff;
 
118
        popeye_state *state = machine.driver_data<popeye_state>();
 
119
        state->m_invertmask = 0xff;
128
120
 
129
121
        convert_color_prom(machine,color_prom);
130
122
}
131
123
 
132
124
PALETTE_INIT( popeyebl )
133
125
{
134
 
        invertmask = 0x00;
 
126
        popeye_state *state = machine.driver_data<popeye_state>();
 
127
        state->m_invertmask = 0x00;
135
128
 
136
129
        convert_color_prom(machine,color_prom);
137
130
}
138
131
 
139
 
static void set_background_palette(running_machine *machine,int bank)
 
132
static void set_background_palette(running_machine &machine,int bank)
140
133
{
 
134
        popeye_state *state = machine.driver_data<popeye_state>();
141
135
        int i;
142
 
        UINT8 *color_prom = machine->region("proms")->base() + 16 * bank;
 
136
        UINT8 *color_prom = machine.region("proms")->base() + 16 * bank;
143
137
 
144
138
        for (i = 0;i < 16;i++)
145
139
        {
147
141
                int r,g,b;
148
142
 
149
143
                /* red component */
150
 
                bit0 = ((*color_prom ^ invertmask) >> 0) & 0x01;
151
 
                bit1 = ((*color_prom ^ invertmask) >> 1) & 0x01;
152
 
                bit2 = ((*color_prom ^ invertmask) >> 2) & 0x01;
 
144
                bit0 = ((*color_prom ^ state->m_invertmask) >> 0) & 0x01;
 
145
                bit1 = ((*color_prom ^ state->m_invertmask) >> 1) & 0x01;
 
146
                bit2 = ((*color_prom ^ state->m_invertmask) >> 2) & 0x01;
153
147
                r = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2;
154
148
                /* green component */
155
 
                bit0 = ((*color_prom ^ invertmask) >> 3) & 0x01;
156
 
                bit1 = ((*color_prom ^ invertmask) >> 4) & 0x01;
157
 
                bit2 = ((*color_prom ^ invertmask) >> 5) & 0x01;
 
149
                bit0 = ((*color_prom ^ state->m_invertmask) >> 3) & 0x01;
 
150
                bit1 = ((*color_prom ^ state->m_invertmask) >> 4) & 0x01;
 
151
                bit2 = ((*color_prom ^ state->m_invertmask) >> 5) & 0x01;
158
152
                g = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2;
159
153
                /* blue component */
160
154
                bit0 = 0;
161
 
                bit1 = ((*color_prom ^ invertmask) >> 6) & 0x01;
162
 
                bit2 = ((*color_prom ^ invertmask) >> 7) & 0x01;
163
 
                if (bitmap_type == TYPE_SKYSKIPR)
 
155
                bit1 = ((*color_prom ^ state->m_invertmask) >> 6) & 0x01;
 
156
                bit2 = ((*color_prom ^ state->m_invertmask) >> 7) & 0x01;
 
157
                if (state->m_bitmap_type == TYPE_SKYSKIPR)
164
158
                {
165
159
                        /* Sky Skipper has different weights */
166
160
                        bit0 = bit1;
176
170
 
177
171
WRITE8_HANDLER( popeye_videoram_w )
178
172
{
179
 
        popeye_videoram[offset] = data;
180
 
        tilemap_mark_tile_dirty(fg_tilemap, offset);
 
173
        popeye_state *state = space->machine().driver_data<popeye_state>();
 
174
        state->m_videoram[offset] = data;
 
175
        tilemap_mark_tile_dirty(state->m_fg_tilemap, offset);
181
176
}
182
177
 
183
178
WRITE8_HANDLER( popeye_colorram_w )
184
179
{
185
 
        popeye_colorram[offset] = data;
186
 
        tilemap_mark_tile_dirty(fg_tilemap, offset);
 
180
        popeye_state *state = space->machine().driver_data<popeye_state>();
 
181
        state->m_colorram[offset] = data;
 
182
        tilemap_mark_tile_dirty(state->m_fg_tilemap, offset);
187
183
}
188
184
 
189
185
WRITE8_HANDLER( popeye_bitmap_w )
190
186
{
 
187
        popeye_state *state = space->machine().driver_data<popeye_state>();
191
188
        int sx,sy,x,y,colour;
192
189
 
193
 
        popeye_bitmapram[offset] = data;
 
190
        state->m_bitmapram[offset] = data;
194
191
 
195
 
        if (bitmap_type == TYPE_SKYSKIPR)
 
192
        if (state->m_bitmap_type == TYPE_SKYSKIPR)
196
193
        {
197
194
                sx = 8 * (offset % 128);
198
195
                sy = 8 * (offset / 128);
199
196
 
200
 
                if (flip_screen_get(space->machine))
 
197
                if (flip_screen_get(space->machine()))
201
198
                        sy = 512-8 - sy;
202
199
 
203
200
                colour = data & 0x0f;
205
202
                {
206
203
                        for (x = 0; x < 8; x++)
207
204
                        {
208
 
                                *BITMAP_ADDR16(tmpbitmap2, sy+y, sx+x) = colour;
 
205
                                *BITMAP_ADDR16(state->m_tmpbitmap2, sy+y, sx+x) = colour;
209
206
                        }
210
207
                }
211
208
        }
214
211
                sx = 8 * (offset % 64);
215
212
                sy = 4 * (offset / 64);
216
213
 
217
 
                if (flip_screen_get(space->machine))
 
214
                if (flip_screen_get(space->machine()))
218
215
                        sy = 512-4 - sy;
219
216
 
220
217
                colour = data & 0x0f;
222
219
                {
223
220
                        for (x = 0; x < 8; x++)
224
221
                        {
225
 
                                *BITMAP_ADDR16(tmpbitmap2, sy+y, sx+x) = colour;
 
222
                                *BITMAP_ADDR16(state->m_tmpbitmap2, sy+y, sx+x) = colour;
226
223
                        }
227
224
                }
228
225
        }
239
236
 
240
237
static TILE_GET_INFO( get_fg_tile_info )
241
238
{
242
 
        int code = popeye_videoram[tile_index];
243
 
        int color = popeye_colorram[tile_index] & 0x0f;
 
239
        popeye_state *state = machine.driver_data<popeye_state>();
 
240
        int code = state->m_videoram[tile_index];
 
241
        int color = state->m_colorram[tile_index] & 0x0f;
244
242
 
245
243
        SET_TILE_INFO(0, code, color, 0);
246
244
}
247
245
 
248
246
VIDEO_START( skyskipr )
249
247
{
250
 
        popeye_bitmapram = auto_alloc_array(machine, UINT8, popeye_bitmapram_size);
251
 
        tmpbitmap2 = auto_bitmap_alloc(machine,1024,1024,machine->primary_screen->format());    /* actually 1024x512 but not rolling over vertically? */
252
 
 
253
 
        bitmap_type = TYPE_SKYSKIPR;
254
 
 
255
 
        fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
256
 
        tilemap_set_transparent_pen(fg_tilemap, 0);
257
 
 
258
 
    lastflip = 0;
259
 
 
260
 
    state_save_register_global(machine, lastflip);
261
 
    state_save_register_global_bitmap(machine, tmpbitmap2);
262
 
    state_save_register_global_pointer(machine, popeye_bitmapram, popeye_bitmapram_size);
 
248
        popeye_state *state = machine.driver_data<popeye_state>();
 
249
        state->m_bitmapram = auto_alloc_array(machine, UINT8, popeye_bitmapram_size);
 
250
        state->m_tmpbitmap2 = auto_bitmap_alloc(machine,1024,1024,machine.primary_screen->format());    /* actually 1024x512 but not rolling over vertically? */
 
251
 
 
252
        state->m_bitmap_type = TYPE_SKYSKIPR;
 
253
 
 
254
        state->m_fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
 
255
        tilemap_set_transparent_pen(state->m_fg_tilemap, 0);
 
256
 
 
257
    state->m_lastflip = 0;
 
258
 
 
259
    state_save_register_global(machine, state->m_lastflip);
 
260
    state_save_register_global_bitmap(machine, state->m_tmpbitmap2);
 
261
    state_save_register_global_pointer(machine, state->m_bitmapram, popeye_bitmapram_size);
263
262
}
264
263
 
265
264
VIDEO_START( popeye )
266
265
{
267
 
        popeye_bitmapram = auto_alloc_array(machine, UINT8, popeye_bitmapram_size);
268
 
        tmpbitmap2 = auto_bitmap_alloc(machine,512,512,machine->primary_screen->format());
269
 
 
270
 
        bitmap_type = TYPE_POPEYE;
271
 
 
272
 
        fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
273
 
        tilemap_set_transparent_pen(fg_tilemap, 0);
274
 
 
275
 
    lastflip = 0;
276
 
 
277
 
    state_save_register_global(machine, lastflip);
278
 
    state_save_register_global_bitmap(machine, tmpbitmap2);
279
 
    state_save_register_global_pointer(machine, popeye_bitmapram, popeye_bitmapram_size);
 
266
        popeye_state *state = machine.driver_data<popeye_state>();
 
267
        state->m_bitmapram = auto_alloc_array(machine, UINT8, popeye_bitmapram_size);
 
268
        state->m_tmpbitmap2 = auto_bitmap_alloc(machine,512,512,machine.primary_screen->format());
 
269
 
 
270
        state->m_bitmap_type = TYPE_POPEYE;
 
271
 
 
272
        state->m_fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
 
273
        tilemap_set_transparent_pen(state->m_fg_tilemap, 0);
 
274
 
 
275
    state->m_lastflip = 0;
 
276
 
 
277
    state_save_register_global(machine, state->m_lastflip);
 
278
    state_save_register_global_bitmap(machine, state->m_tmpbitmap2);
 
279
    state_save_register_global_pointer(machine, state->m_bitmapram, popeye_bitmapram_size);
280
280
}
281
281
 
282
 
static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
 
282
static void draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
283
283
{
 
284
        popeye_state *state = machine.driver_data<popeye_state>();
284
285
        int offs;
285
 
        address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
 
286
        address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
286
287
 
287
 
        if (lastflip != flip_screen_get(machine))
 
288
        if (state->m_lastflip != flip_screen_get(machine))
288
289
        {
289
290
                for (offs = 0;offs < popeye_bitmapram_size;offs++)
290
 
                        popeye_bitmap_w(space,offs,popeye_bitmapram[offs]);
 
291
                        popeye_bitmap_w(space,offs,state->m_bitmapram[offs]);
291
292
 
292
 
                lastflip = flip_screen_get(machine);
 
293
                state->m_lastflip = flip_screen_get(machine);
293
294
        }
294
295
 
295
 
        set_background_palette(machine, (*popeye_palettebank & 0x08) >> 3);
 
296
        set_background_palette(machine, (*state->m_palettebank & 0x08) >> 3);
296
297
 
297
 
        if (popeye_background_pos[1] == 0)      /* no background */
 
298
        if (state->m_background_pos[1] == 0)    /* no background */
298
299
                bitmap_fill(bitmap,cliprect,0);
299
300
        else
300
301
        {
301
302
                /* copy the background graphics */
302
 
                int scrollx = 200 - popeye_background_pos[0] - 256*(popeye_background_pos[2]&1); /* ??? */
303
 
                int scrolly = 2 * (256 - popeye_background_pos[1]);
 
303
                int scrollx = 200 - state->m_background_pos[0] - 256*(state->m_background_pos[2]&1); /* ??? */
 
304
                int scrolly = 2 * (256 - state->m_background_pos[1]);
304
305
 
305
 
                if (bitmap_type == TYPE_SKYSKIPR)
 
306
                if (state->m_bitmap_type == TYPE_SKYSKIPR)
306
307
                        scrollx = 2*scrollx - 512;
307
308
 
308
309
                if (flip_screen_get(machine))
309
310
                {
310
 
                        if (bitmap_type == TYPE_POPEYE)
 
311
                        if (state->m_bitmap_type == TYPE_POPEYE)
311
312
                                scrollx = -scrollx;
312
313
                        scrolly = -scrolly;
313
314
                }
314
315
 
315
 
                copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,1,&scrolly,cliprect);
 
316
                copyscrollbitmap(bitmap,state->m_tmpbitmap2,1,&scrollx,1,&scrolly,cliprect);
316
317
        }
317
318
}
318
319
 
319
 
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
 
320
static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
320
321
{
321
 
        UINT8 *spriteram = machine->generic.spriteram.u8;
 
322
        popeye_state *state = machine.driver_data<popeye_state>();
 
323
        UINT8 *spriteram = state->m_spriteram;
322
324
        int offs;
323
325
 
324
 
        for (offs = 0;offs < machine->generic.spriteram_size;offs += 4)
 
326
        for (offs = 0;offs < state->m_spriteram_size;offs += 4)
325
327
        {
326
328
                int code,color,flipx,flipy,sx,sy;
327
329
 
339
341
 
340
342
                code = (spriteram[offs + 2] & 0x7f) + ((spriteram[offs + 3] & 0x10) << 3)
341
343
                                                        + ((spriteram[offs + 3] & 0x04) << 6);
342
 
                color = (spriteram[offs + 3] & 0x07) + 8*(*popeye_palettebank & 0x07);
343
 
                if (bitmap_type == TYPE_SKYSKIPR)
 
344
                color = (spriteram[offs + 3] & 0x07) + 8*(*state->m_palettebank & 0x07);
 
345
                if (state->m_bitmap_type == TYPE_SKYSKIPR)
344
346
                {
345
347
                        /* Two of the PROM address pins are tied together and one is not connected... */
346
348
                        color = (color & 0x0f) | ((color & 0x08) << 1);
361
363
                }
362
364
 
363
365
                if (spriteram[offs] != 0)
364
 
                        drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
 
366
                        drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
365
367
                                        code ^ 0x1ff,
366
368
                                        color,
367
369
                                        flipx,flipy,
369
371
        }
370
372
}
371
373
 
372
 
VIDEO_UPDATE( popeye )
 
374
SCREEN_UPDATE( popeye )
373
375
{
374
 
        draw_background(screen->machine, bitmap, cliprect);
375
 
        draw_sprites(screen->machine, bitmap, cliprect);
376
 
        tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
 
376
        popeye_state *state = screen->machine().driver_data<popeye_state>();
 
377
        draw_background(screen->machine(), bitmap, cliprect);
 
378
        draw_sprites(screen->machine(), bitmap, cliprect);
 
379
        tilemap_draw(bitmap, cliprect, state->m_fg_tilemap, 0, 0);
377
380
        return 0;
378
381
}