74
65
int bit0,bit1,bit2,r,g,b;
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 */
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;
92
83
palette_set_color(machine,16 + (2 * i) + 1,MAKE_RGB(r,g,b));
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 */
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;
119
110
palette_set_color(machine,48+i,MAKE_RGB(r,g,b));
240
237
static TILE_GET_INFO( get_fg_tile_info )
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;
245
243
SET_TILE_INFO(0, code, color, 0);
248
246
VIDEO_START( skyskipr )
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? */
253
bitmap_type = TYPE_SKYSKIPR;
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);
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? */
252
state->m_bitmap_type = TYPE_SKYSKIPR;
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);
257
state->m_lastflip = 0;
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);
265
264
VIDEO_START( popeye )
267
popeye_bitmapram = auto_alloc_array(machine, UINT8, popeye_bitmapram_size);
268
tmpbitmap2 = auto_bitmap_alloc(machine,512,512,machine->primary_screen->format());
270
bitmap_type = TYPE_POPEYE;
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);
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());
270
state->m_bitmap_type = TYPE_POPEYE;
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);
275
state->m_lastflip = 0;
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);
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)
284
popeye_state *state = machine.driver_data<popeye_state>();
285
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
286
address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
287
if (lastflip != flip_screen_get(machine))
288
if (state->m_lastflip != flip_screen_get(machine))
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]);
292
lastflip = flip_screen_get(machine);
293
state->m_lastflip = flip_screen_get(machine);
295
set_background_palette(machine, (*popeye_palettebank & 0x08) >> 3);
296
set_background_palette(machine, (*state->m_palettebank & 0x08) >> 3);
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);
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]);
305
if (bitmap_type == TYPE_SKYSKIPR)
306
if (state->m_bitmap_type == TYPE_SKYSKIPR)
306
307
scrollx = 2*scrollx - 512;
308
309
if (flip_screen_get(machine))
310
if (bitmap_type == TYPE_POPEYE)
311
if (state->m_bitmap_type == TYPE_POPEYE)
311
312
scrollx = -scrollx;
312
313
scrolly = -scrolly;
315
copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,1,&scrolly,cliprect);
316
copyscrollbitmap(bitmap,state->m_tmpbitmap2,1,&scrollx,1,&scrolly,cliprect);
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)
321
UINT8 *spriteram = machine->generic.spriteram.u8;
322
popeye_state *state = machine.driver_data<popeye_state>();
323
UINT8 *spriteram = state->m_spriteram;
324
for (offs = 0;offs < machine->generic.spriteram_size;offs += 4)
326
for (offs = 0;offs < state->m_spriteram_size;offs += 4)
326
328
int code,color,flipx,flipy,sx,sy;