void vsystem_spr_device::common_sprite_drawgfx( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect) { gfx_element *gfx = machine.gfx[m_gfx_region]; int priority_mask = 0x00; curr_sprite.oy += m_yoffs; curr_sprite.ox += m_xoffs; if (m_pdraw) { switch (curr_sprite.pri) { default: case 0: priority_mask = 0x00; break; case 3: priority_mask = 0xfe; break; case 2: priority_mask = 0xfc; break; case 1: priority_mask = 0xf0; break; } } curr_sprite.zoomx = 32 - curr_sprite.zoomx; curr_sprite.zoomy = 32 - curr_sprite.zoomy; int ystart, yend, yinc; if (!curr_sprite.flipy) { ystart = 0; yend = curr_sprite.ysize+1; yinc = 1; } else { ystart = curr_sprite.ysize; yend = -1; yinc = -1; } int ycnt = ystart; while (ycnt != yend) { int xstart, xend, xinc; if (!curr_sprite.flipx) { xstart = 0; xend = curr_sprite.xsize+1; xinc = 1; } else { xstart = curr_sprite.xsize; xend = -1; xinc = -1; } int xcnt = xstart; while (xcnt != xend) { int startno = m_newtilecb(curr_sprite.map++); if (m_pdraw) { pdrawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, curr_sprite.ox + xcnt * curr_sprite.zoomx/2, curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, machine.priority_bitmap,priority_mask, m_transpen); pdrawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, -0x200+curr_sprite.ox + xcnt * curr_sprite.zoomx/2, curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, machine.priority_bitmap,priority_mask, m_transpen); pdrawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, curr_sprite.ox + xcnt * curr_sprite.zoomx/2, -0x200+curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, machine.priority_bitmap,priority_mask, m_transpen); pdrawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, -0x200+curr_sprite.ox + xcnt * curr_sprite.zoomx/2, -0x200+curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, machine.priority_bitmap,priority_mask, m_transpen); } else { drawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, curr_sprite.ox + xcnt * curr_sprite.zoomx/2, curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, m_transpen); drawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, -0x200+curr_sprite.ox + xcnt * curr_sprite.zoomx/2, curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, m_transpen); drawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, curr_sprite.ox + xcnt * curr_sprite.zoomx/2, -0x200+curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, m_transpen); drawgfxzoom_transpen(bitmap, cliprect, gfx, startno, curr_sprite.color + m_pal_base, curr_sprite.flipx, curr_sprite.flipy, -0x200+curr_sprite.ox + xcnt * curr_sprite.zoomx/2, -0x200+curr_sprite.oy + ycnt * curr_sprite.zoomy/2, curr_sprite.zoomx << 11, curr_sprite.zoomy << 11, m_transpen); } xcnt+=xinc; } ycnt+=yinc; } }
static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, const int *primasks, int priority) { galastrm_state *state = machine.driver_data<galastrm_state>(); struct tempsprite *sprite_ptr = state->m_sprite_ptr_pre; while (sprite_ptr != state->m_spritelist) { sprite_ptr--; if ((priority != 0 && sprite_ptr->primask != 0) || (priority == 0 && sprite_ptr->primask == 0)) { pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy, machine.priority_bitmap,primasks[sprite_ptr->primask],0); } } }
static void f1gp_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int primask ) { f1gp_state *state = machine.driver_data<f1gp_state>(); int attr_start, first; UINT16 *spram = chip ? state->m_spr2vram : state->m_spr1vram; first = 4 * spram[0x1fe]; for (attr_start = 0x0200 - 8; attr_start >= first; attr_start -= 4) { int map_start; int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color/*, pri*/; /* table hand made by looking at the ship explosion in attract mode */ /* it's almost a logarithmic scale but not exactly */ static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 }; if (!(spram[attr_start + 2] & 0x0080)) continue; ox = spram[attr_start + 1] & 0x01ff; xsize = (spram[attr_start + 2] & 0x0700) >> 8; zoomx = (spram[attr_start + 1] & 0xf000) >> 12; oy = spram[attr_start + 0] & 0x01ff; ysize = (spram[attr_start + 2] & 0x7000) >> 12; zoomy = (spram[attr_start + 0] & 0xf000) >> 12; flipx = spram[attr_start + 2] & 0x0800; flipy = spram[attr_start + 2] & 0x8000; color = (spram[attr_start + 2] & 0x000f);// + 16 * spritepalettebank; //pri = spram[attr_start + 2] & 0x0010; map_start = spram[attr_start + 3]; zoomx = 16 - zoomtable[zoomx] / 8; zoomy = 16 - zoomtable[zoomy] / 8; for (y = 0; y <= ysize; y++) { int sx, sy; if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16; else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16; for (x = 0; x <= xsize; x++) { int code; if (flipx) sx = ((ox + zoomx * (xsize - x) + 16) & 0x1ff) - 16; else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16; if (chip == 0) code = state->m_spr1cgram[map_start % (state->m_spr1cgram_size / 2)]; else code = state->m_spr2cgram[map_start % (state->m_spr2cgram_size / 2)]; pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[1 + chip], code, color, flipx,flipy, sx,sy, 0x1000 * zoomx,0x1000 * zoomy, machine.priority_bitmap, // pri ? 0 : 0x2); primask,15); map_start++; } if (xsize == 2) map_start += 1; if (xsize == 4) map_start += 3; if (xsize == 5) map_start += 2; if (xsize == 6) map_start += 1; } } }
static void draw_sprites(running_machine &machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int x_offs,int y_offs) { gunbustr_state *state = machine.driver_data<gunbustr_state>(); UINT32 *spriteram32 = state->m_spriteram; UINT16 *spritemap = (UINT16 *)machine.region("user1")->base(); int offs, data, tilenum, color, flipx, flipy; int x, y, priority, dblsize, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk,map_offset,code,j,k,px,py; int dimension,total_chunks,bad_chunks; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ struct tempsprite *sprite_ptr = state->m_spritelist; for (offs = (state->m_spriteram_size/4-4);offs >= 0;offs -= 4) { data = spriteram32[offs+0]; flipx = (data & 0x00800000) >> 23; zoomx = (data & 0x007f0000) >> 16; tilenum = (data & 0x00007fff); data = spriteram32[offs+2]; priority = (data & 0x000c0000) >> 18; color = (data & 0x0003fc00) >> 10; x = (data & 0x000003ff); data = spriteram32[offs+3]; dblsize = (data & 0x00040000) >> 18; flipy = (data & 0x00020000) >> 17; zoomy = (data & 0x0001fc00) >> 10; y = (data & 0x000003ff); color |= 0x80; if (!tilenum) continue; flipy = !flipy; zoomx += 1; zoomy += 1; y += y_offs; /* treat coords as signed */ if (x>0x340) x -= 0x400; if (y>0x340) y -= 0x400; x -= x_offs; bad_chunks = 0; dimension = ((dblsize*2) + 2); // 2 or 4 total_chunks = ((dblsize*3) + 1) << 2; // 4 or 16 map_offset = tilenum << 2; { for (sprite_chunk=0;sprite_chunk<total_chunks;sprite_chunk++) { j = sprite_chunk / dimension; /* rows */ k = sprite_chunk % dimension; /* chunks per row */ px = k; py = j; /* pick tiles back to front for x and y flips */ if (flipx) px = dimension-1-k; if (flipy) py = dimension-1-j; code = spritemap[map_offset + px + (py<<(dblsize+1))]; if (code==0xffff) { bad_chunks += 1; continue; } curx = x + ((k*zoomx)/dimension); cury = y + ((j*zoomy)/dimension); zx= x + (((k+1)*zoomx)/dimension) - curx; zy= y + (((j+1)*zoomy)/dimension) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } sprite_ptr->gfx = 0; sprite_ptr->code = code; sprite_ptr->color = color; sprite_ptr->flipx = !flipx; sprite_ptr->flipy = flipy; sprite_ptr->x = curx; sprite_ptr->y = cury; sprite_ptr->zoomx = zx << 12; sprite_ptr->zoomy = zy << 12; if (primasks) { sprite_ptr->primask = primasks[priority]; sprite_ptr++; } else { drawgfxzoom_transpen(bitmap,cliprect,machine.gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy,0); } } } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } /* this happens only if primsks != NULL */ while (sprite_ptr != state->m_spritelist) { sprite_ptr--; pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy, machine.priority_bitmap,sprite_ptr->primask,0); } }
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { inufuku_state *state = (inufuku_state *)machine->driver_data; int offs; for (offs = (state->spriteram1_size / 16) - 1; offs >= 0; offs--) { if ((state->spriteram1[offs] & 0x8000) == 0x0000) { int attr_start; int map_start; int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color; int priority, priority_mask; attr_start = 4 * (state->spriteram1[offs] & 0x03ff); /* attr_start + 0x0000 ---- ---x xxxx xxxx oy ---- xxx- ---- ---- ysize xxxx ---- ---- ---- zoomy attr_start + 0x0001 ---- ---x xxxx xxxx ox ---- xxx- ---- ---- xsize xxxx ---- ---- ---- zoomx attr_start + 0x0002 -x-- ---- ---- ---- flipx x--- ---- ---- ---- flipy --xx xxxx ---- ---- color --xx ---- ---- ---- priority? ---- ---- xxxx xxxx unused? attr_start + 0x0003 -xxx xxxx xxxx xxxx map start x--- ---- ---- ---- unused? */ ox = (state->spriteram1[attr_start + 1] & 0x01ff) + 0; xsize = (state->spriteram1[attr_start + 1] & 0x0e00) >> 9; zoomx = (state->spriteram1[attr_start + 1] & 0xf000) >> 12; oy = (state->spriteram1[attr_start + 0] & 0x01ff) + 1; ysize = (state->spriteram1[attr_start + 0] & 0x0e00) >> 9; zoomy = (state->spriteram1[attr_start + 0] & 0xf000) >> 12; flipx = state->spriteram1[attr_start + 2] & 0x4000; flipy = state->spriteram1[attr_start + 2] & 0x8000; color = (state->spriteram1[attr_start + 2] & 0x3f00) >> 8; priority = (state->spriteram1[attr_start + 2] & 0x3000) >> 12; map_start = (state->spriteram1[attr_start + 3] & 0x7fff) << 1; switch (priority) { default: case 0: priority_mask = 0x00; break; case 3: priority_mask = 0xfe; break; case 2: priority_mask = 0xfc; break; case 1: priority_mask = 0xf0; break; } ox += (xsize * zoomx + 2) / 4; oy += (ysize * zoomy + 2) / 4; zoomx = 32 - zoomx; zoomy = 32 - zoomy; for (y = 0; y <= ysize; y++) { int sx, sy; if (flipy) sy = (oy + zoomy * (ysize - y) / 2 + 16) & 0x1ff; else sy = (oy + zoomy * y / 2 + 16) & 0x1ff; for (x = 0; x <= xsize; x++) { int code; if (flipx) sx = (ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff; else sx = (ox + zoomx * x / 2 + 16) & 0x1ff; code = ((state->spriteram2[map_start] & 0x0007) << 16) + state->spriteram2[map_start + 1]; pdrawgfxzoom_transpen(bitmap, cliprect, machine->gfx[2], code, color, flipx, flipy, sx - 16, sy - 16, zoomx << 11, zoomy << 11, machine->priority_bitmap,priority_mask, 15); map_start += 2; } } } }
static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int do_hack,int x_offs,int y_offs) { groundfx_state *state = machine.driver_data<groundfx_state>(); UINT32 *spriteram32 = state->m_spriteram; UINT16 *spritemap = (UINT16 *)state->memregion("user1")->base(); int offs, data, tilenum, color, flipx, flipy; int x, y, priority, dblsize, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk,map_offset,code,j,k,px,py; int dimension,total_chunks; static const int primasks[4] = {0xffff, 0xfffc, 0xfff0, 0xff00 }; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ struct tempsprite *sprite_ptr = state->m_spritelist; for (offs = (state->m_spriteram.bytes()/4-4);offs >= 0;offs -= 4) { data = spriteram32[offs+0]; flipx = (data & 0x00800000) >> 23; zoomx = (data & 0x007f0000) >> 16; tilenum = (data & 0x00007fff); data = spriteram32[offs+2]; priority = (data & 0x000c0000) >> 18; color = (data & 0x0003fc00) >> 10; x = (data & 0x000003ff); data = spriteram32[offs+3]; dblsize = (data & 0x00040000) >> 18; flipy = (data & 0x00020000) >> 17; zoomy = (data & 0x0001fc00) >> 10; y = (data & 0x000003ff); // color |= (0x100 + (priority << 6)); /* priority bits select color bank */ color /= 2; /* as sprites are 5bpp */ flipy = !flipy; y = (-y &0x3ff); if (!tilenum) continue; flipy = !flipy; zoomx += 1; zoomy += 1; y += y_offs; /* treat coords as signed */ if (x>0x340) x -= 0x400; if (y>0x340) y -= 0x400; x -= x_offs; dimension = ((dblsize*2) + 2); // 2 or 4 total_chunks = ((dblsize*3) + 1) << 2; // 4 or 16 map_offset = tilenum << 2; { for (sprite_chunk=0;sprite_chunk<total_chunks;sprite_chunk++) { j = sprite_chunk / dimension; /* rows */ k = sprite_chunk % dimension; /* chunks per row */ px = k; py = j; /* pick tiles back to front for x and y flips */ if (flipx) px = dimension-1-k; if (flipy) py = dimension-1-j; code = spritemap[map_offset + px + (py<<(dblsize+1))]; if (code==0xffff) { continue; } curx = x + ((k*zoomx)/dimension); cury = y + ((j*zoomy)/dimension); zx= x + (((k+1)*zoomx)/dimension) - curx; zy= y + (((j+1)*zoomy)/dimension) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } sprite_ptr->gfx = 0; sprite_ptr->code = code; sprite_ptr->color = color; sprite_ptr->flipx = !flipx; sprite_ptr->flipy = flipy; sprite_ptr->x = curx; sprite_ptr->y = cury; sprite_ptr->zoomx = zx << 12; sprite_ptr->zoomy = zy << 12; sprite_ptr->pri = priority; sprite_ptr++; } } } /* this happens only if primsks != NULL */ while (sprite_ptr != state->m_spritelist) { const rectangle *clipper; sprite_ptr--; if (do_hack && sprite_ptr->pri==1 && sprite_ptr->y<100) clipper=&state->m_hack_cliprect; else clipper=&cliprect; pdrawgfxzoom_transpen(bitmap,*clipper,machine.gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy, machine.priority_bitmap,primasks[sprite_ptr->pri],0); } }
static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) { topspeed_state *state = machine.driver_data<topspeed_state>(); UINT16 *spriteram = state->m_spriteram; int offs, map_offset, x, y, curx, cury, sprite_chunk; UINT16 *spritemap = state->m_spritemap; UINT16 data, tilenum, code, color; UINT8 flipx, flipy, priority, bad_chunks; UINT8 j, k, px, py, zx, zy, zoomx, zoomy; static const int primasks[2] = { 0xff00, 0xfffc }; /* Sprites are over bottom layer or under top layer */ /* Most of spriteram is not used by the 68000: rest is scratch space for the h/w perhaps ? */ for (offs = 0; offs < (0x2c0 / 2); offs += 4) { data = spriteram[offs + 2]; tilenum = spriteram[offs + 3] & 0xff; color = (spriteram[offs + 3] & 0xff00) >> 8; flipx = (data & 0x4000) >> 14; flipy = (spriteram[offs + 1] & 0x8000) >> 15; x = data & 0x1ff; y = spriteram[offs] & 0x1ff; zoomx = (spriteram[offs + 1]& 0x7f); zoomy = (spriteram[offs] & 0xfe00) >> 9; priority = (data & 0x8000) >> 15; // unknown = (data & 0x2000) >> 13; if (y == 0x180) continue; /* dead sprite */ map_offset = tilenum << 7; zoomx += 1; zoomy += 1; y += 3 + (128-zoomy); /* treat coords as signed */ if (x > 0x140) x -= 0x200; if (y > 0x140) y -= 0x200; bad_chunks = 0; for (sprite_chunk = 0; sprite_chunk < 128; sprite_chunk++) { k = sprite_chunk % 8; /* 8 sprite chunks per row */ j = sprite_chunk / 8; /* 16 rows */ /* pick tiles back to front for x and y flips */ px = (flipx) ? (7 - k) : (k); py = (flipy) ? (15 - j) : (j); code = spritemap[map_offset + (py << 3) + px]; if (code & 0x8000) { bad_chunks += 1; continue; } curx = x + ((k * zoomx) / 8); cury = y + ((j * zoomy) / 16); zx = x + (((k + 1) * zoomx) / 8) - curx; zy = y + (((j + 1) * zoomy) / 16) - cury; pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0], code, color, flipx,flipy, curx,cury, zx<<12,zy<<13, machine.priority_bitmap,primasks[priority],0); } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } }
void undrfire_state::draw_sprites_cbombers(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,const int *primasks,int x_offs,int y_offs) { UINT32 *spriteram32 = m_spriteram; UINT16 *spritemap = (UINT16 *)memregion("user1")->base(); UINT8 *spritemapHibit = (UINT8 *)memregion("user2")->base(); int offs, data, tilenum, color, flipx, flipy; int x, y, priority, dblsize, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk,map_offset,code,j,k,px,py; int dimension,total_chunks; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ struct tempsprite *sprite_ptr = m_spritelist; for (offs = (m_spriteram.bytes()/4-4);offs >= 0;offs -= 4) { data = spriteram32[offs+0]; flipx = (data & 0x00800000) >> 23; zoomx = (data & 0x007f0000) >> 16; tilenum = (data & 0x0000ffff); data = spriteram32[offs+2]; priority = (data & 0x000c0000) >> 18; color = (data & 0x0003fc00) >> 10; x = (data & 0x000003ff); data = spriteram32[offs+3]; dblsize = (data & 0x00040000) >> 18; flipy = (data & 0x00020000) >> 17; zoomy = (data & 0x0001fc00) >> 10; y = (data & 0x000003ff); color |= (/*0x100 +*/ (priority << 6)); /* priority bits select color bank */ color /= 2; /* as sprites are 5bpp */ flipy = !flipy; if (!tilenum) continue; zoomx += 1; zoomy += 1; y += y_offs; /* treat coords as signed */ if (x>0x340) x -= 0x400; if (y>0x340) y -= 0x400; x -= x_offs; dimension = ((dblsize*2) + 2); // 2 or 4 total_chunks = ((dblsize*3) + 1) << 2; // 4 or 16 map_offset = tilenum << 2; for (sprite_chunk = 0; sprite_chunk < total_chunks; sprite_chunk++) { int map_addr; j = sprite_chunk / dimension; /* rows */ k = sprite_chunk % dimension; /* chunks per row */ px = k; py = j; /* pick tiles back to front for x and y flips */ if (flipx) px = dimension-1-k; if (flipy) py = dimension-1-j; map_addr = map_offset + px + (py << (dblsize + 1)); code = (spritemapHibit[map_addr] << 16) | spritemap[map_addr]; curx = x + ((k*zoomx)/dimension); cury = y + ((j*zoomy)/dimension); zx= x + (((k+1)*zoomx)/dimension) - curx; zy= y + (((j+1)*zoomy)/dimension) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } sprite_ptr->gfx = 0; sprite_ptr->code = code; sprite_ptr->color = color; sprite_ptr->flipx = !flipx; sprite_ptr->flipy = flipy; sprite_ptr->x = curx; sprite_ptr->y = cury; sprite_ptr->zoomx = zx << 12; sprite_ptr->zoomy = zy << 12; if (primasks) { sprite_ptr->primask = primasks[priority]; sprite_ptr++; } else { drawgfxzoom_transpen(bitmap,cliprect,machine().gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy,0); } } } /* this happens only if primsks != NULL */ while (sprite_ptr != m_spritelist) { sprite_ptr--; pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[sprite_ptr->gfx], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy, screen.priority(),sprite_ptr->primask,0); } }
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const int *primasks, int y_offs ) { othunder_state *state = machine->driver_data<othunder_state>(); UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); UINT16 tile_mask = (machine->gfx[0]->total_elements) - 1; UINT16 *spriteram16 = state->spriteram; int offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk, map_offset, code, j, k, px, py; int bad_chunks; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ struct othunder_tempsprite *sprite_ptr = state->spritelist; for (offs = (state->spriteram_size / 2) - 4; offs >= 0; offs -= 4) { data = spriteram16[offs + 0]; zoomy = (data & 0xfe00) >> 9; y = data & 0x1ff; data = spriteram16[offs + 1]; flipx = (data & 0x4000) >> 14; priority = (data & 0x8000) >> 15; x = data & 0x1ff; data = spriteram16[offs + 2]; color = (data & 0xff00) >> 8; zoomx = (data & 0x7f); data = spriteram16[offs + 3]; tilenum = data & 0x1fff; // $80000 spritemap rom maps up to $2000 64x64 sprites flipy = (data & 0x8000) >> 15; if (!tilenum) continue; map_offset = tilenum << 5; zoomx += 1; zoomy += 1; y += y_offs; /* treat coords as signed */ if (x > 0x140) x -= 0x200; if (y > 0x140) y -= 0x200; bad_chunks = 0; for (sprite_chunk = 0; sprite_chunk < 32; sprite_chunk++) { k = sprite_chunk % 4; /* 4 chunks per row */ j = sprite_chunk / 4; /* 8 rows */ px = k; py = j; if (flipx) px = 3 - k; /* pick tiles back to front for x and y flips */ if (flipy) py = 7 - j; code = spritemap[map_offset + px + (py << 2)] & tile_mask; if (code == 0xffff) { bad_chunks += 1; continue; } curx = x + ((k * zoomx) / 4); cury = y + ((j * zoomy) / 8); zx= x + (((k + 1) * zoomx) / 4) - curx; zy= y + (((j + 1) * zoomy) / 8) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } sprite_ptr->code = code; sprite_ptr->color = color; sprite_ptr->flipx = flipx; sprite_ptr->flipy = flipy; sprite_ptr->x = curx; sprite_ptr->y = cury; sprite_ptr->zoomx = zx << 12; sprite_ptr->zoomy = zy << 13; if (primasks) { sprite_ptr->primask = primasks[priority]; sprite_ptr++; } else { drawgfxzoom_transpen(bitmap,cliprect,machine->gfx[0], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy,0); } } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } /* this happens only if primsks != NULL */ while (sprite_ptr != state->spritelist) { sprite_ptr--; pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[0], sprite_ptr->code, sprite_ptr->color, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, sprite_ptr->zoomx,sprite_ptr->zoomy, machine->priority_bitmap,sprite_ptr->primask,0); } }
static void spacegun_draw_sprites_16x8(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int y_offs) { taitoz_state *state = machine->driver_data<taitoz_state>(); UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); UINT16 *spriteram = state->spriteram; int offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk, map_offset, code, j, k, px, py; int bad_chunks; static const int primasks[2] = { 0xf0, 0xfc }; for (offs = 0; offs < state->spriteram_size / 2 - 4; offs += 4) { data = spriteram[offs + 0]; zoomy = (data & 0xfe00) >> 9; y = data & 0x1ff; data = spriteram[offs + 1]; priority = (data & 0x8000) >> 15; flipx = (data & 0x4000) >> 14; x = data & 0x1ff; // correct mask? data = spriteram[offs + 2]; color = (data & 0xff00) >> 8; zoomx = (data & 0x7f); data = spriteram[offs + 3]; flipy = (data & 0x8000) >> 15; // ??? tilenum = data & 0x1fff; /* $80000 spritemap rom maps up to $2000 64x64 sprites */ if (!tilenum) continue; map_offset = tilenum << 5; zoomx += 1; zoomy += 1; y += y_offs; /* treat coords as signed */ if (x > 0x140) x -= 0x200; if (y > 0x140) y -= 0x200; bad_chunks = 0; for (sprite_chunk = 0; sprite_chunk < 32; sprite_chunk++) { k = sprite_chunk % 4; /* 4 sprite chunks per row */ j = sprite_chunk / 4; /* 8 rows */ px = flipx ? (3 - k) : k; /* pick tiles back to front for x and y flips */ py = flipy ? (7 - j) : j; code = spritemap[map_offset + px + (py << 2)]; if (code == 0xffff) bad_chunks++; curx = x + ((k * zoomx) / 4); cury = y + ((j * zoomy) / 8); zx = x + (((k + 1) * zoomx) / 4) - curx; zy = y + (((j + 1) * zoomy) / 8) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[0], code, color, flipx,flipy, curx,cury, zx<<12,zy<<13, machine->priority_bitmap,primasks[priority],0); } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } }
static void sci_draw_sprites_16x8( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int y_offs ) { taitoz_state *state = machine->driver_data<taitoz_state>(); UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); UINT16 *spriteram = state->spriteram; int offs, start_offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk, map_offset, code, j, k, px, py; int bad_chunks; static const int primasks[2] = { 0xf0, 0xfc }; /* SCI alternates between two areas of its spriteram */ // This gave back to front frames causing bad flicker... but // reversing it now only gives us sprite updates on alternate // frames. So we probably have to partly buffer spriteram? start_offs = (state->sci_spriteframe & 1) * 0x800; start_offs = 0x800 - start_offs; for (offs = (start_offs + 0x800 - 4); offs >= start_offs; offs -= 4) { data = spriteram[offs + 0]; zoomy = (data & 0x7e00) >> 9; y = data & 0x1ff; data = spriteram[offs + 1]; priority = (data & 0x8000) >> 15; color = (data & 0x7f80) >> 7; zoomx = (data & 0x3f); data = spriteram[offs + 2]; flipy = (data & 0x8000) >> 15; flipx = (data & 0x4000) >> 14; x = data & 0x1ff; data = spriteram[offs + 3]; tilenum = data & 0x1fff; /* $80000 spritemap rom maps up to $2000 64x64 sprites */ if (!tilenum) continue; map_offset = tilenum << 5; zoomx += 1; zoomy += 1; y += y_offs; y += (64 - zoomy); /* treat coords as signed */ if (x > 0x140) x -= 0x200; if (y > 0x140) y -= 0x200; bad_chunks = 0; for (sprite_chunk = 0; sprite_chunk < 32; sprite_chunk++) { j = sprite_chunk / 4; /* 8 rows */ k = sprite_chunk % 4; /* 4 sprite chunks per row */ px = flipx ? (3 - k) : k; /* pick tiles back to front for x and y flips */ py = flipy ? (7 - j) : j; code = spritemap[map_offset + px + (py << 2)]; if (code == 0xffff) bad_chunks++; curx = x + ((k * zoomx) / 4); cury = y + ((j * zoomy) / 8); zx = x + (((k + 1) * zoomx) / 4) - curx; zy = y + (((j + 1) * zoomy) / 8) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[0], code, color, flipx,flipy, curx,cury, zx<<12,zy<<13, machine->priority_bitmap,primasks[priority],0); } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } }
static void chasehq_draw_sprites_16x16( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int y_offs ) { taitoz_state *state = machine->driver_data<taitoz_state>(); UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); UINT16 *spriteram = state->spriteram; int offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; int sprite_chunk, map_offset, code, j, k, px, py; int bad_chunks; static const int primasks[2] = { 0xf0, 0xfc }; for (offs = state->spriteram_size / 2 - 4; offs >= 0; offs -= 4) { data = spriteram[offs + 0]; zoomy = (data & 0xfe00) >> 9; y = data & 0x1ff; data = spriteram[offs + 1]; priority = (data & 0x8000) >> 15; color = (data & 0x7f80) >> 7; zoomx = (data & 0x7f); data = spriteram[offs + 2]; flipy = (data & 0x8000) >> 15; flipx = (data & 0x4000) >> 14; x = data & 0x1ff; data = spriteram[offs + 3]; /* higher bits are sometimes used... e.g. sign over flashing enemy car...! */ tilenum = data & 0x7ff; if (!tilenum) continue; zoomx += 1; zoomy += 1; y += y_offs; y += (128 - zoomy); /* treat coords as signed */ if (x > 0x140) x -= 0x200; if (y > 0x140) y -= 0x200; bad_chunks = 0; if ((zoomx - 1) & 0x40) /* 128x128 sprites, $0-$3ffff in spritemap rom, OBJA */ { map_offset = tilenum << 6; for (sprite_chunk = 0; sprite_chunk < 64; sprite_chunk++) { j = sprite_chunk / 8; /* 8 rows */ k = sprite_chunk % 8; /* 8 sprite chunks per row */ px = flipx ? (7 - k) : k; /* pick tiles back to front for x and y flips */ py = flipy ? (7 - j) : j; code = spritemap[map_offset + px + (py << 3)]; if (code == 0xffff) bad_chunks++; curx = x + ((k * zoomx) / 8); cury = y + ((j * zoomy) / 8); zx = x + (((k + 1) * zoomx) / 8) - curx; zy = y + (((j + 1) * zoomy) / 8) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[0], code, color, flipx,flipy, curx,cury, zx<<12,zy<<12, machine->priority_bitmap,primasks[priority],0); } } else if ((zoomx - 1) & 0x20) /* 64x128 sprites, $40000-$5ffff in spritemap rom, OBJB */ { map_offset = (tilenum << 5) + 0x20000; for (sprite_chunk = 0; sprite_chunk < 32; sprite_chunk++) { j = sprite_chunk / 4; /* 8 rows */ k = sprite_chunk % 4; /* 4 sprite chunks per row */ px = flipx ? (3 - k) : k; /* pick tiles back to front for x and y flips */ py = flipy ? (7 - j) : j; code = spritemap[map_offset + px + (py << 2)]; if (code == 0xffff) bad_chunks++; curx = x + ((k * zoomx) / 4); cury = y + ((j * zoomy) / 8); zx = x + (((k + 1) * zoomx) / 4) - curx; zy = y + (((j + 1) * zoomy) / 8) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[2], code, color, flipx,flipy, curx,cury, zx<<12,zy<<12, machine->priority_bitmap,primasks[priority],0); } } else if (!((zoomx - 1) & 0x60)) /* 32x128 sprites, $60000-$7ffff in spritemap rom, OBJB */ { map_offset = (tilenum << 4) + 0x30000; for (sprite_chunk = 0; sprite_chunk < 16; sprite_chunk++) { j = sprite_chunk / 2; /* 8 rows */ k = sprite_chunk % 2; /* 2 sprite chunks per row */ px = flipx ? (1 - k) : k; /* pick tiles back to front for x and y flips */ py = flipy ? (7 - j) : j; code = spritemap[map_offset + px + (py << 1)]; if (code == 0xffff) bad_chunks ++; curx = x + ((k * zoomx) / 2); cury = y + ((j * zoomy) / 8); zx = x + (((k + 1) * zoomx) / 2) - curx; zy = y + (((j + 1) * zoomy) / 8) - cury; if (sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when screen is flipped; so we must correct the coords ourselves. */ curx = 320 - curx - zx; cury = 256 - cury - zy; flipx = !flipx; flipy = !flipy; } pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[2], code, color, flipx,flipy, curx,cury, zx<<12,zy<<12, machine->priority_bitmap,primasks[priority],0); } } if (bad_chunks) logerror("Sprite number %04x had %02x invalid chunks\n", tilenum, bad_chunks); } }