1
/***************************************************************************
5
***************************************************************************/
11
INT8 mcr12_sprite_xoffs;
12
INT8 mcr12_sprite_xoffs_flip;
14
static tilemap *bg_tilemap;
17
/*************************************
21
*************************************/
24
The 90009 board uses 1 byte per tile:
27
pppppppp = picture index
29
static void mcr_90009_get_tile_info(int tile_index)
31
SET_TILE_INFO(0, videoram[tile_index], 0, 0);
33
/* sprite color base is constant 0x10 */
34
tile_info.priority = 1;
39
The 90010 board uses 2 adjacent bytes per tile:
42
pppppppp = picture index (low 8 bits)
45
ss------ = sprite palette bank
46
---cc--- = tile palette bank
49
-------p = picture index (high 1 bit)
51
static void mcr_90010_get_tile_info(int tile_index)
53
int data = videoram[tile_index * 2] | (videoram[tile_index * 2 + 1] << 8);
54
int code = data & 0x1ff;
55
int color = (data >> 11) & 3;
56
SET_TILE_INFO(0, code, color, TILE_FLIPYX((data >> 9) & 3));
58
/* sprite color base comes from the top 2 bits */
59
tile_info.priority = (data >> 14) & 3;
64
The 91490 board uses 2 adjacent bytes per tile:
67
pppppppp = picture index (low 8 bits)
70
ss------ = sprite palette bank (can be disabled via jumpers)
71
--cc---- = tile palette bank
74
------pp = picture index (high 2 bits)
76
static void mcr_91490_get_tile_info(int tile_index)
78
int data = videoram[tile_index * 2] | (videoram[tile_index * 2 + 1] << 8);
79
int code = data & 0x3ff;
80
int color = (data >> 12) & 3;
81
SET_TILE_INFO(0, code, color, TILE_FLIPYX((data >> 10) & 3));
83
/* sprite color base might come from the top 2 bits */
84
tile_info.priority = (data >> 14) & 3;
89
/*************************************
91
* Common video startup/shutdown
93
*************************************/
97
/* the tilemap callback is based on the CPU board */
98
switch (mcr_cpu_board)
101
bg_tilemap = tilemap_create(mcr_90009_get_tile_info, tilemap_scan_rows, TILEMAP_OPAQUE, 16,16, 32,30);
105
bg_tilemap = tilemap_create(mcr_90010_get_tile_info, tilemap_scan_rows, TILEMAP_OPAQUE, 16,16, 32,30);
109
bg_tilemap = tilemap_create(mcr_90010_get_tile_info, tilemap_scan_rows, TILEMAP_OPAQUE, 16,16, 32,30);
113
bg_tilemap = tilemap_create(mcr_91490_get_tile_info, tilemap_scan_rows, TILEMAP_OPAQUE, 16,16, 32,30);
123
/*************************************
127
*************************************/
129
static void mcr_set_color(int index, int data)
131
/* 3 bits each, RGB */
132
int r = (data >> 6) & 7;
133
int g = (data >> 0) & 7;
134
int b = (data >> 3) & 7;
137
r = (r << 5) | (r << 2) | (r >> 1);
138
g = (g << 5) | (g << 2) | (g >> 1);
139
b = (b << 5) | (b << 2) | (b >> 1);
142
palette_set_color(index, r, g, b);
146
static void journey_set_color(int index, int data)
148
/* 3 bits each, RGB */
149
int r = (data >> 6) & 7;
150
int g = (data >> 0) & 7;
151
int b = (data >> 3) & 7;
154
r = (r << 5) | (r << 1);
155
g = (g << 5) | (g << 1);
156
b = (b << 5) | (b << 1);
158
/* set the BG color */
159
palette_set_color(index, r, g, b);
161
/* if this is an odd entry in the upper palette bank, the hardware */
162
/* hard-codes a low 1 bit -- this is used for better grayscales */
163
if ((index & 0x31) == 0x31)
170
/* set the FG color */
171
palette_set_color(index + 64, r, g, b);
175
WRITE8_HANDLER( mcr_91490_paletteram_w )
177
paletteram[offset] = data;
179
mcr_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8));
184
/*************************************
188
*************************************/
190
WRITE8_HANDLER( mcr_90009_videoram_w )
192
videoram[offset] = data;
193
tilemap_mark_tile_dirty(bg_tilemap, offset);
197
WRITE8_HANDLER( mcr_90010_videoram_w )
199
videoram[offset] = data;
200
tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
202
/* palette RAM is mapped into the upper 0x80 bytes here */
203
if ((offset & 0x780) == 0x780)
205
if (mcr_cpu_board != 91475)
206
mcr_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8));
208
journey_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8));
213
READ8_HANDLER( twotiger_videoram_r )
215
/* Two Tigers swizzles the address bits on videoram */
216
int effoffs = ((offset << 1) & 0x7fe) | ((offset >> 10) & 1);
217
return videoram[effoffs];
220
WRITE8_HANDLER( twotiger_videoram_w )
222
/* Two Tigers swizzles the address bits on videoram */
223
int effoffs = ((offset << 1) & 0x7fe) | ((offset >> 10) & 1);
225
videoram[effoffs] = data;
226
tilemap_mark_tile_dirty(bg_tilemap, effoffs / 2);
228
/* palette RAM is mapped into the upper 0x80 bytes here */
229
if ((effoffs & 0x780) == 0x780)
230
mcr_set_color(((offset & 0x400) >> 5) | ((offset >> 1) & 0x1f), data | ((offset & 1) << 8));
234
WRITE8_HANDLER( mcr_91490_videoram_w )
236
videoram[offset] = data;
237
tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
242
/*************************************
244
* 91399 Video Gen sprite renderer
247
* 90009 CPU -> fixed palette @ 1
248
* 90010 CPU -> palette specified by tiles
250
*************************************/
252
static void render_sprites_91399(mame_bitmap *bitmap, const rectangle *cliprect)
254
const gfx_element *gfx = Machine->gfx[1];
257
/* render the sprites into the bitmap, ORing together */
258
for (offs = 0; offs < spriteram_size; offs += 4)
260
int code, x, y, sx, sy, hflip, vflip;
262
/* extract the bits of information */
263
code = spriteram[offs + 1] & 0x3f;
264
hflip = (spriteram[offs + 1] & 0x40) ? 31 : 0;
265
vflip = (spriteram[offs + 1] & 0x80) ? 31 : 0;
266
sx = (spriteram[offs + 2] - 4) * 2;
267
sy = (240 - spriteram[offs]) * 2;
269
/* apply cocktail mode */
270
if (mcr_cocktail_flip)
274
sx = 466 - sx + mcr12_sprite_xoffs_flip;
278
sx += mcr12_sprite_xoffs;
280
/* clamp within 512 */
284
/* loop over lines in the sprite */
285
for (y = 0; y < 32; y++, sy = (sy + 1) & 0x1ff)
286
if (sy >= cliprect->min_y && sy <= cliprect->max_y)
288
UINT8 *src = gfx->gfxdata + gfx->char_modulo * code + gfx->line_modulo * (y ^ vflip);
289
UINT16 *dst = (UINT16 *)bitmap->line[sy];
290
UINT8 *pri = priority_bitmap->line[sy];
292
/* loop over columns */
293
for (x = 0; x < 32; x++)
295
int tx = (sx + x) & 0x1ff;
296
int pix = pri[tx] | src[x ^ hflip];
298
/* update the effective sprite pixel */
301
/* only draw if the low 3 bits are set */
311
/*************************************
313
* 91464 Super Video Gen sprite renderer
316
* 91442 CPU -> fixed palette @ 1 (upper half) or 3 (lower half)
317
* 91475 CPU -> palette specified by sprite board; sprites have extra implicit colors
318
* 91490 CPU -> palette specified by sprite board or by tiles (select via jumpers)
319
* 91721 CPU -> palette specified by sprite board
321
*************************************/
323
static void render_sprites_91464(mame_bitmap *bitmap, const rectangle *cliprect, int primask, int sprmask, int colormask)
325
const gfx_element *gfx = Machine->gfx[1];
328
/* render the sprites into the bitmap, working from topmost to bottommost */
329
for (offs = spriteram_size - 4; offs >= 0; offs -= 4)
331
int code, color, x, y, sx, sy, hflip, vflip;
333
/* extract the bits of information */
334
code = (spriteram[offs + 2] + 256 * ((spriteram[offs + 1] >> 3) & 0x01)) % gfx->total_elements;
335
color = (((~spriteram[offs + 1] & 3) << 4) & sprmask) | colormask;
336
hflip = (spriteram[offs + 1] & 0x10) ? 31 : 0;
337
vflip = (spriteram[offs + 1] & 0x20) ? 31 : 0;
338
sx = (spriteram[offs + 3] - 3) * 2;
339
sy = (241 - spriteram[offs]) * 2;
341
/* apply cocktail mode */
342
if (mcr_cocktail_flip)
350
/* clamp within 512 */
354
/* loop over lines in the sprite */
355
for (y = 0; y < 32; y++, sy = (sy + 1) & 0x1ff)
356
if (sy >= cliprect->min_y && sy <= cliprect->max_y)
358
UINT8 *src = gfx->gfxdata + gfx->char_modulo * code + gfx->line_modulo * (y ^ vflip);
359
UINT16 *dst = (UINT16 *)bitmap->line[sy];
360
UINT8 *pri = priority_bitmap->line[sy];
362
/* loop over columns */
363
for (x = 0; x < 32; x++)
365
int tx = (sx + x) & 0x1ff;
369
/* compute the final value */
370
pix = (pix & primask) | color | src[x ^ hflip];
372
/* if non-zero, draw */
375
/* mark this pixel so we don't draw there again */
378
/* only draw if the low 3 bits are set */
390
/*************************************
392
* Main refresh routines
394
*************************************/
398
/* update the flip state */
399
tilemap_set_flip(bg_tilemap, mcr_cocktail_flip ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
401
/* draw the background */
402
fillbitmap(priority_bitmap, 0, cliprect);
403
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0x00);
404
tilemap_draw(bitmap, cliprect, bg_tilemap, 1, 0x10);
405
tilemap_draw(bitmap, cliprect, bg_tilemap, 2, 0x20);
406
tilemap_draw(bitmap, cliprect, bg_tilemap, 3, 0x30);
408
/* update the sprites and render them */
409
switch (mcr_sprite_board)
412
render_sprites_91399(bitmap, cliprect);
416
if (mcr_cpu_board == 91442)
417
render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00);
418
else if (mcr_cpu_board == 91475)
419
render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x40);
420
else if (mcr_cpu_board == 91490)
421
render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00);
422
else if (mcr_cpu_board == 91721)
423
render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00);