mirror of
https://github.com/holub/mame
synced 2025-04-25 09:50:04 +03:00
Added new function tilemap_set_pen_data_offset().
While this isn't 'free' as tilemap_set_palette_offset() is (when the offset changes, the pixmap cache needs to be invalidated), it helps removing some redundant code from drivers. Updated snk.c and snk68.c to take advantage of the new function.
This commit is contained in:
parent
dba36cfa30
commit
4ecbf842e9
@ -96,6 +96,7 @@ struct _tilemap
|
||||
UINT8 all_tiles_dirty; /* true if all tiles are dirty */
|
||||
UINT8 all_tiles_clean; /* true if all tiles are clean */
|
||||
UINT32 palette_offset; /* palette offset */
|
||||
UINT32 pen_data_offset; /* pen data offset */
|
||||
|
||||
/* scroll information */
|
||||
UINT32 scrollrows; /* number of independently scrolled rows */
|
||||
@ -344,6 +345,7 @@ tilemap *tilemap_create(tile_get_info_func tile_get_info, tilemap_mapper_func ma
|
||||
state_save_register_item("tilemap", tilemap_instance, tmap->enable);
|
||||
state_save_register_item("tilemap", tilemap_instance, tmap->attributes);
|
||||
state_save_register_item("tilemap", tilemap_instance, tmap->palette_offset);
|
||||
state_save_register_item("tilemap", tilemap_instance, tmap->pen_data_offset);
|
||||
state_save_register_item("tilemap", tilemap_instance, tmap->scrollrows);
|
||||
state_save_register_item("tilemap", tilemap_instance, tmap->scrollcols);
|
||||
state_save_register_item_pointer("tilemap", tilemap_instance, tmap->rowscroll, rows * tileheight);
|
||||
@ -383,6 +385,21 @@ void tilemap_set_palette_offset(tilemap *tmap, UINT32 offset)
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
tilemap_set_pen_data_offset - specify an offset
|
||||
to be added to pen_data while rendering tiles
|
||||
-------------------------------------------------*/
|
||||
|
||||
void tilemap_set_pen_data_offset(tilemap *tmap, UINT32 offset)
|
||||
{
|
||||
if (tmap->pen_data_offset != offset)
|
||||
{
|
||||
tmap->pen_data_offset = offset;
|
||||
tilemap_mark_all_tiles_dirty(tmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
tilemap_set_enable - set an enable flag for
|
||||
the tilemap; if 0, requests to draw the
|
||||
@ -1248,7 +1265,7 @@ profiler_mark(PROFILER_TILEMAP_UPDATE);
|
||||
flags = tmap->tileinfo.flags ^ (tmap->attributes & 0x03);
|
||||
|
||||
/* draw the tile, using either direct or transparent */
|
||||
tmap->tileflags[logindex] = tile_draw(tmap, tmap->tileinfo.pen_data, x0, y0, tmap->tileinfo.palette_base, tmap->tileinfo.category, tmap->tileinfo.group, flags);
|
||||
tmap->tileflags[logindex] = tile_draw(tmap, tmap->tileinfo.pen_data + tmap->pen_data_offset, x0, y0, tmap->tileinfo.palette_base, tmap->tileinfo.category, tmap->tileinfo.group, flags);
|
||||
|
||||
/* if mask data is specified, apply it */
|
||||
if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && tmap->tileinfo.mask_data != NULL)
|
||||
|
@ -131,6 +131,9 @@
|
||||
* setting a global palette offset via
|
||||
tilemap_set_palette_offset()
|
||||
|
||||
* setting a global pen data offset via
|
||||
tilemap_set_pen_data_offset()
|
||||
|
||||
3. In your memory write handlers for the tile memory, anytime tile
|
||||
data is modified, you need to mark the tile dirty so that it is
|
||||
re-rendered with the new data the next time the tilemap is drawn.
|
||||
@ -432,12 +435,17 @@ tilemap *tilemap_create(tile_get_info_func tile_get_info, tilemap_mapper_func ma
|
||||
/* specify a parameter to be passed into the tile_get_info callback */
|
||||
void tilemap_set_user_data(tilemap *tmap, void *user_data);
|
||||
|
||||
/* specify an offset to be added to each pixel before looking up the palette
|
||||
/* specify an offset to be added to each pixel before looking up the palette.
|
||||
* The offset only applies at final rendering time (e.g., tilemap_draw())
|
||||
* It does not apply to the cached pixmap, which is provided by tilemap_get_pixmap().
|
||||
*/
|
||||
void tilemap_set_palette_offset(tilemap *tmap, UINT32 offset);
|
||||
|
||||
/* specify an offset to be added to pen_data while rendering tiles.
|
||||
* This will automatically mark all tiles dirty if the offset changes.
|
||||
*/
|
||||
void tilemap_set_pen_data_offset(tilemap *tmap, UINT32 offset);
|
||||
|
||||
/* set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored */
|
||||
void tilemap_set_enable(tilemap *tmap, int enable);
|
||||
|
||||
|
@ -27,7 +27,6 @@ UINT8 *snk_bg_videoram;
|
||||
|
||||
static tilemap *fg_tilemap;
|
||||
static tilemap *bg_tilemap;
|
||||
static int fg_bank, bg_bank;
|
||||
static int bg_scrollx, bg_scrolly, sp16_scrollx, sp16_scrolly, sp32_scrollx, sp32_scrolly;
|
||||
static UINT8 sprite_split_point;
|
||||
|
||||
@ -88,7 +87,7 @@ static TILE_GET_INFO( tnk3_get_fg_tile_info )
|
||||
int code = snk_fg_videoram[tile_index];
|
||||
int color = code >> 5;
|
||||
SET_TILE_INFO(0,
|
||||
code | (fg_bank << 8),
|
||||
code,
|
||||
color,
|
||||
tile_index & 0x400 ? TILE_FORCE_LAYER0 : 0);
|
||||
}
|
||||
@ -97,7 +96,7 @@ static TILE_GET_INFO( ikari_get_fg_tile_info )
|
||||
{
|
||||
int code = snk_fg_videoram[tile_index];
|
||||
SET_TILE_INFO(0,
|
||||
code | (fg_bank << 8),
|
||||
code,
|
||||
0,
|
||||
tile_index & 0x400 ? TILE_FORCE_LAYER0 : 0);
|
||||
}
|
||||
@ -106,7 +105,7 @@ static TILE_GET_INFO( gwar_get_fg_tile_info )
|
||||
{
|
||||
int code = snk_fg_videoram[tile_index];
|
||||
SET_TILE_INFO(0,
|
||||
code | (fg_bank << 8),
|
||||
code,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
@ -116,7 +115,7 @@ static TILE_GET_INFO( aso_get_bg_tile_info )
|
||||
{
|
||||
int code = snk_bg_videoram[tile_index];
|
||||
SET_TILE_INFO(1,
|
||||
code | (bg_bank << 8),
|
||||
code,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
@ -325,16 +324,10 @@ WRITE8_HANDLER( tnk3_videoattrs_w )
|
||||
-------X scrollx MSB (sprites)
|
||||
*/
|
||||
|
||||
int bank = (data & 0x40) >> 6;
|
||||
|
||||
if (fg_bank != bank)
|
||||
{
|
||||
tilemap_mark_all_tiles_dirty(fg_tilemap);
|
||||
fg_bank = bank;
|
||||
}
|
||||
|
||||
flip_screen_set(data & 0x80);
|
||||
|
||||
tilemap_set_pen_data_offset(fg_tilemap, ((data & 0x40) << 2) * machine->gfx[0]->char_modulo);
|
||||
|
||||
bg_scrolly = (bg_scrolly & 0xff) | ((data & 0x10) << 4);
|
||||
sp16_scrolly = (sp16_scrolly & 0xff) | ((data & 0x08) << 5);
|
||||
bg_scrollx = (bg_scrollx & 0xff) | ((data & 0x02) << 7);
|
||||
@ -365,15 +358,8 @@ WRITE8_HANDLER( aso_videoattrs_w )
|
||||
|
||||
WRITE8_HANDLER( aso_bg_bank_w )
|
||||
{
|
||||
int bank = (data & 0x30) >> 4;
|
||||
|
||||
if (bg_bank != bank)
|
||||
{
|
||||
tilemap_mark_all_tiles_dirty(bg_tilemap);
|
||||
bg_bank = bank;
|
||||
}
|
||||
|
||||
tilemap_set_palette_offset(bg_tilemap, ((data & 0xf) ^ 8) << 4);
|
||||
tilemap_set_pen_data_offset(bg_tilemap, ((data & 0x30) << 4) * machine->gfx[1]->char_modulo);
|
||||
}
|
||||
|
||||
WRITE8_HANDLER( ikari_bg_scroll_msb_w )
|
||||
@ -398,36 +384,19 @@ WRITE8_HANDLER( ikari_unknown_video_w )
|
||||
hard flags test and the test grid.
|
||||
Changing palette bank is necessary to fix colors in test mode. */
|
||||
|
||||
int bank = (data & 0x10) >> 4;
|
||||
|
||||
if (data != 0x20 && // normal
|
||||
data != 0x31 && // ikari test
|
||||
data != 0xaa) // victroad spurious during boot
|
||||
popmessage("attrs %02x contact MAMEDEV", data);
|
||||
|
||||
if (fg_bank != bank)
|
||||
{
|
||||
tilemap_mark_all_tiles_dirty(fg_tilemap);
|
||||
fg_bank = bank;
|
||||
}
|
||||
|
||||
if (data & 1)
|
||||
tilemap_set_palette_offset(fg_tilemap, 16);
|
||||
else
|
||||
tilemap_set_palette_offset(fg_tilemap, 0);
|
||||
tilemap_set_palette_offset(fg_tilemap, (data & 0x01) << 4);
|
||||
tilemap_set_pen_data_offset(fg_tilemap, ((data & 0x10) << 4) * machine->gfx[0]->char_modulo);
|
||||
}
|
||||
|
||||
WRITE8_HANDLER( gwar_fg_bank_w )
|
||||
{
|
||||
int bank = (data & 0x30) >> 4;
|
||||
|
||||
if (fg_bank != bank)
|
||||
{
|
||||
tilemap_mark_all_tiles_dirty(fg_tilemap);
|
||||
fg_bank = bank;
|
||||
}
|
||||
|
||||
tilemap_set_palette_offset(fg_tilemap, (data & 0xf) << 4);
|
||||
tilemap_set_pen_data_offset(fg_tilemap, ((data & 0x30) << 4) * machine->gfx[0]->char_modulo);
|
||||
}
|
||||
|
||||
WRITE8_HANDLER( gwar_videoattrs_w )
|
||||
|
@ -16,7 +16,6 @@ Notes:
|
||||
|
||||
UINT16* pow_fg_videoram;
|
||||
|
||||
static int pow_charbank;
|
||||
static int sprite_flip_axis;
|
||||
static tilemap *fg_tilemap;
|
||||
static int flipscreen;
|
||||
@ -29,7 +28,7 @@ static int flipscreen;
|
||||
|
||||
static TILE_GET_INFO( get_pow_tile_info )
|
||||
{
|
||||
int tile = (pow_fg_videoram[2*tile_index] & 0xff) | (pow_charbank << 8);
|
||||
int tile = (pow_fg_videoram[2*tile_index] & 0xff);
|
||||
int color = pow_fg_videoram[2*tile_index+1] & 0x07;
|
||||
|
||||
SET_TILE_INFO(0, tile, color, 0);
|
||||
@ -140,11 +139,7 @@ WRITE16_HANDLER( pow_flipscreen16_w )
|
||||
|
||||
sprite_flip_axis = data & 0x04; // for streetsm? though might not be present on this board
|
||||
|
||||
if (pow_charbank != ((data & 0x70) >> 4))
|
||||
{
|
||||
pow_charbank = (data & 0x70) >> 4;
|
||||
tilemap_mark_all_tiles_dirty(fg_tilemap);
|
||||
}
|
||||
tilemap_set_pen_data_offset(fg_tilemap, ((data & 0x70) << 4) * machine->gfx[0]->char_modulo);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user