Further crash fixes. Also optimized st0016 RAM tile behavior to

lazy decode the graphics, giving a big speed boost to some of the
mahjong games.
This commit is contained in:
Aaron Giles 2008-10-09 08:36:16 +00:00
parent 0389171b57
commit 6f77816007
2 changed files with 23 additions and 10 deletions

View File

@ -95,7 +95,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int code = ((egghunt_bgram[tile_index*2+1] << 8) | egghunt_bgram[tile_index*2]) & 0x3fff; int code = ((egghunt_bgram[tile_index*2+1] << 8) | egghunt_bgram[tile_index*2]) & 0x3fff;
int colour = egghunt_atram[tile_index]; int colour = egghunt_atram[tile_index] & 0x3f;
if(code & 0x2000) if(code & 0x2000)
{ {
@ -396,7 +396,7 @@ static MACHINE_DRIVER_START( egghunt )
MDRV_SCREEN_VISIBLE_AREA(8*8, 56*8-1, 1*8, 31*8-1) MDRV_SCREEN_VISIBLE_AREA(8*8, 56*8-1, 1*8, 31*8-1)
MDRV_GFXDECODE(egghunt) MDRV_GFXDECODE(egghunt)
MDRV_PALETTE_LENGTH(0x800) MDRV_PALETTE_LENGTH(0x400)
MDRV_VIDEO_START(egghunt) MDRV_VIDEO_START(egghunt)
MDRV_VIDEO_UPDATE(egghunt) MDRV_VIDEO_UPDATE(egghunt)

View File

@ -14,6 +14,7 @@ UINT32 st0016_game;
static INT32 st0016_spr_bank,st0016_spr2_bank,st0016_pal_bank,st0016_char_bank; static INT32 st0016_spr_bank,st0016_spr2_bank,st0016_pal_bank,st0016_char_bank;
static int spr_dx,spr_dy; static int spr_dx,spr_dy;
static UINT8 *chardirty;
static UINT8 st0016_vregs[0xc0]; static UINT8 st0016_vregs[0xc0];
static int st0016_ramgfx; static int st0016_ramgfx;
@ -116,7 +117,7 @@ READ8_HANDLER(st0016_character_ram_r)
WRITE8_HANDLER(st0016_character_ram_w) WRITE8_HANDLER(st0016_character_ram_w)
{ {
st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data; st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data;
decodechar(machine->gfx[st0016_ramgfx], st0016_char_bank,(UINT8 *) st0016_charram); chardirty[st0016_char_bank] = 1;
} }
READ8_HANDLER(st0016_vregs_r) READ8_HANDLER(st0016_vregs_r)
@ -258,6 +259,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
*/ */
gfx_element *gfx = machine->gfx[st0016_ramgfx];
int i,j,lx,ly,x,y,code,offset,length,sx,sy,color,flipx,flipy,scrollx,scrolly,plx,ply; int i,j,lx,ly,x,y,code,offset,length,sx,sy,color,flipx,flipy,scrollx,scrolly,plx,ply;
@ -353,13 +355,18 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int yloop,xloop; int yloop,xloop;
int ypos, xpos; int ypos, xpos;
int tileno; int tileno;
const gfx_element *gfx = machine->gfx[0];
UINT8 *srcgfx; UINT8 *srcgfx;
int gfxoffs; int gfxoffs;
ypos = sy+y0*8+spr_dy; ypos = sy+y0*8+spr_dy;
xpos = sx+x0*8+spr_dx; xpos = sx+x0*8+spr_dx;
tileno = (code+i0++)&ST0016_CHAR_BANK_MASK ; tileno = (code+i0++)&ST0016_CHAR_BANK_MASK ;
if (chardirty[tileno])
{
chardirty[tileno] = 0;
decodechar(gfx, tileno, (UINT8 *) st0016_charram);
}
gfxoffs = 0; gfxoffs = 0;
srcgfx= gfx->gfxdata+(64*tileno); srcgfx= gfx->gfxdata+(64*tileno);
@ -421,10 +428,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static STATE_POSTLOAD( st0016_postload ) static STATE_POSTLOAD( st0016_postload )
{ {
int i;
st0016_rom_bank_w(machine,0,st0016_rom_bank); st0016_rom_bank_w(machine,0,st0016_rom_bank);
for(i=0;i<ST0016_MAX_CHAR_BANK;i++) memset(chardirty, 1, ST0016_MAX_CHAR_BANK);
decodechar(machine->gfx[st0016_ramgfx], i,(UINT8 *) st0016_charram);
} }
@ -459,6 +464,8 @@ VIDEO_START( st0016 )
/* create the char set (gfx will then be updated dynamically from RAM) */ /* create the char set (gfx will then be updated dynamically from RAM) */
machine->gfx[gfx_index] = allocgfx(&charlayout); machine->gfx[gfx_index] = allocgfx(&charlayout);
chardirty = auto_malloc(ST0016_MAX_CHAR_BANK);
memset(chardirty, 1, ST0016_MAX_CHAR_BANK);
/* set the color information */ /* set the color information */
machine->gfx[gfx_index]->color_base = 0; machine->gfx[gfx_index]->color_base = 0;
@ -506,6 +513,7 @@ VIDEO_START( st0016 )
static void draw_bgmap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int priority) static void draw_bgmap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int priority)
{ {
gfx_element *gfx = machine->gfx[st0016_ramgfx];
int j; int j;
//for(j=0x40-8;j>=0;j-=8) //for(j=0x40-8;j>=0;j-=8)
for(j=0;j<0x40;j+=8) for(j=0;j<0x40;j+=8)
@ -523,9 +531,15 @@ static void draw_bgmap(running_machine *machine, bitmap_t *bitmap,const rectangl
flipx=st0016_spriteram[i+3]&0x80; flipx=st0016_spriteram[i+3]&0x80;
flipy=st0016_spriteram[i+3]&0x40; flipy=st0016_spriteram[i+3]&0x40;
if (chardirty[code])
{
chardirty[code] = 0;
decodechar(gfx, code, (UINT8 *) st0016_charram);
}
if(priority) if(priority)
{ {
drawgfx(bitmap,machine->gfx[0], drawgfx(bitmap,gfx,
code, code,
color, color,
flipx,flipy, flipx,flipy,
@ -537,13 +551,12 @@ static void draw_bgmap(running_machine *machine, bitmap_t *bitmap,const rectangl
UINT16 *destline; UINT16 *destline;
int yloop,xloop; int yloop,xloop;
int ypos, xpos; int ypos, xpos;
const gfx_element *gfx = machine->gfx[0];
UINT8 *srcgfx; UINT8 *srcgfx;
int gfxoffs; int gfxoffs;
ypos = y*8+spr_dy;//+((st0016_vregs[j+2]==0xaf)?0x50:0);//hack for mayjinsen title screen ypos = y*8+spr_dy;//+((st0016_vregs[j+2]==0xaf)?0x50:0);//hack for mayjinsen title screen
xpos = x*8+spr_dx; xpos = x*8+spr_dx;
gfxoffs = 0; gfxoffs = 0;
srcgfx= gfx->gfxdata+(64*code); srcgfx= gfx->gfxdata+(gfx->char_modulo*code);
for (yloop=0; yloop<8; yloop++) for (yloop=0; yloop<8; yloop++)
{ {