void fcrash_render_sprites(mame_bitmap *bitmap,const rectangle *cliprect) { int pos; int base=0x50c8/2; // and 10c8/2 for the buffer? for (pos=0x1f9c;pos>=0x0000;pos-=4) { int tileno; int xpos; int ypos; int flipx,flipy; int colour; tileno = cps1_gfxram[base+pos]; xpos = cps1_gfxram[base+pos+2]; ypos = cps1_gfxram[base+pos-1]; flipx = cps1_gfxram[base+pos+1]&0x20; flipy = cps1_gfxram[base+pos+1]&0x40; colour = cps1_gfxram[base+pos+1]&0x1f; ypos = 256-ypos; pdrawgfx(bitmap,Machine->gfx[2],tileno,colour,flipx,flipy,xpos+48,ypos-16,cliprect,TRANSPARENCY_PEN,15,0x02); } }
static void draw_sprites(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect,int x_offs,int y_offs) { int offs, data, data2, tilenum, color, flipx, flipy; int x, y, priority, pri_mask; #ifdef MAME_DEBUG int unknown=0; #endif /* pdrawgfx() needs us to draw sprites front to back */ for (offs = 0;offs < spriteram_size/2;offs += 4) { data = spriteram16[offs+1]; tilenum = data & 0x7fff; data = spriteram16[offs+0]; y = (-(data &0x1ff) - 24) & 0x1ff; /* (inverted y adjusted for vis area) */ flipy = (data & 0x200) >> 9; data2 = spriteram16[offs+2]; /* 8,4 also seen in msbyte */ priority = (data2 & 0x0100) >> 8; // 1 = low if(priority) pri_mask = 0xfffe; else pri_mask = 0; color = (data2 & 0x7f); data = spriteram16[offs+3]; x = (data & 0x3ff); flipx = (data & 0x400) >> 10; #ifdef MAME_DEBUG if (data2 & 0xf280) unknown |= (data2 &0xf280); #endif x -= x_offs; y += y_offs; /* sprite wrap: coords become negative at high values */ if (x>0x3c0) x -= 0x400; if (y>0x180) y -= 0x200; pdrawgfx(bitmap,machine->gfx[0], tilenum, color, flipx,flipy, x,y, cliprect,TRANSPARENCY_PEN,0,pri_mask); } #ifdef MAME_DEBUG if (unknown) popmessage("unknown sprite bits: %04x",unknown); #endif }
static void unico_draw_sprites32(mame_bitmap *bitmap,const rectangle *cliprect) { int offs; /* Draw them backwards, for pdrawgfx */ for ( offs = (spriteram_size-8)/4; offs >= 0 ; offs -= 8/4 ) { int x, startx, endx, incx; int sx = spriteram32[ offs + 0 ] >> 16; int sy = spriteram32[ offs + 0 ] & 0xffff; int code = spriteram32[ offs + 1 ] >> 16; int attr = spriteram32[ offs + 1 ] & 0xffff; int flipx = attr & 0x020; int flipy = attr & 0x040; /* not sure */ int dimx = ((attr >> 8) & 0xf) + 1; int priority = ((attr >> 12) & 0x3); int pri_mask; switch( priority ) { case 0: pri_mask = 0xfe; break; /* below all */ case 1: pri_mask = 0xf0; break; /* above layer 0 */ case 2: pri_mask = 0xfc; break; /* above layer 1 */ default: case 3: pri_mask = 0x00; /* above all */ } sx += sprites_scrolldx; sy += sprites_scrolldy; sx = (sx & 0x1ff) - (sx & 0x200); sy = (sy & 0x1ff) - (sy & 0x200); if (flipx) { startx = sx+(dimx-1)*16; endx = sx-16; incx = -16; } else { startx = sx; endx = sx+dimx*16; incx = +16; } for (x = startx ; x != endx ; x += incx) { pdrawgfx( bitmap, Machine->gfx[0], code++, attr & 0x1f, flipx, flipy, x, sy, cliprect, TRANSPARENCY_PEN,0x00, pri_mask ); } } }
static void yunsun16_draw_sprites(mame_bitmap *bitmap,const rectangle *cliprect) { int offs; int max_x = Machine->screen[0].visarea.max_x+1; int max_y = Machine->screen[0].visarea.max_y+1; int pri = *yunsun16_priority & 3; int pri_mask; switch( pri ) { case 1: pri_mask = (1<<1)|(1<<2)|(1<<3); break; case 2: pri_mask = (1<<2)|(1<<3); break; case 3: default: pri_mask = 0; } for ( offs = (spriteram_size-8)/2 ; offs >= 0; offs -= 8/2 ) { int x = spriteram16[offs + 0]; int y = spriteram16[offs + 1]; int code = spriteram16[offs + 2]; int attr = spriteram16[offs + 3]; int flipx = attr & 0x20; int flipy = attr & 0x40; x += sprites_scrolldx; y += sprites_scrolldy; if (flip_screen) // not used? { flipx = !flipx; x = max_x - x - 16; flipy = !flipy; y = max_y - y - 16; } pdrawgfx( bitmap,Machine->gfx[1], code, attr & 0x1f, flipx, flipy, x,y, cliprect,TRANSPARENCY_PEN,15, pri_mask ); } }
static void draw_sprites(struct osd_bitmap *bitmap) { int offs,sx,sy; for (offs = 0;offs < 4096;offs += 32) { int code; int attr = stfight_sprite_ram[offs+1]; int flipx = attr & 0x10; int color = attr & 0x0f; int pri = (attr & 0x20) >> 5; sy = stfight_sprite_ram[offs+2]; sx = stfight_sprite_ram[offs+3]; // non-active sprites have zero y coordinate value if( sy > 0 ) { // sprites which wrap onto/off the screen have // a sign extension bit in the sprite attribute if( sx >= 0xf0 ) { if (attr & 0x80) sx -= 0x100; } if (flip_screen) { sx = 240 - sx; sy = 240 - sy; flipx = !flipx; } code = stfight_sprite_base + stfight_sprite_ram[offs]; pdrawgfx(bitmap,Machine->gfx[4], code, color, flipx,flip_screen, sx,sy, &Machine->visible_area,TRANSPARENCY_PEN,0x0f, pri ? 0x02 : 0); } } }
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { int offs,sx,sy; for (offs = 0;offs < 4096;offs += 32) { int code; int attr = stfight_sprite_ram[offs+1]; int flipx = attr & 0x10; int color = attr & 0x0f; int pri = (attr & 0x20) >> 5; sy = stfight_sprite_ram[offs+2]; sx = stfight_sprite_ram[offs+3]; // non-active sprites have zero y coordinate value if( sy > 0 ) { // sprites which wrap onto/off the screen have // a sign extension bit in the sprite attribute if( sx >= 0xf0 ) { if (attr & 0x80) sx -= 0x100; } if (flip_screen_get()) { sx = 240 - sx; sy = 240 - sy; flipx = !flipx; } code = stfight_sprite_base + stfight_sprite_ram[offs]; pdrawgfx(bitmap,machine->gfx[4], code, color, flipx,flip_screen_get(), sx,sy, cliprect,TRANSPARENCY_PEN,0x0f, pri ? 0x02 : 0); } } }
static void blmbycar_draw_sprites(mame_bitmap *bitmap, const rectangle *cliprect) { UINT16 *source, *finish; source = spriteram16 + 0x6/2; // ! finish = spriteram16 + spriteram_size/2 - 8/2; /* Find "the end of sprites" marker */ for ( ; source < finish; source += 8/2 ) if (source[0] & 0x8000) break; /* Draw sprites in reverse order for pdrawfgfx */ source -= 8/2; finish = spriteram16; for ( ; source >= finish; source -= 8/2 ) { int y = source[0]; int code = source[1]; int attr = source[2]; int x = source[3]; int flipx = attr & 0x4000; int flipy = attr & 0x8000; int pri = (~attr >> 3) & 0x1; // Priority (1 = Low) int pri_mask = ~((1 << (pri+1)) - 1); // Above the first "pri" levels if (x & 0x4000) continue; // ? To get rid of the "shadow" blocks x = (x & 0x1ff) - 0x10; y = 0xf0 - ((y & 0xff) - (y & 0x100)); pdrawgfx( bitmap, Machine->gfx[0], code, 0x20 + (attr & 0xf), flipx, flipy, x, y, cliprect, TRANSPARENCY_PEN,0, pri_mask ); } }
static void draw_sprites( struct mame_bitmap *bitmap, const struct rectangle *cliprect, int bank_bits ){ static int bFlicker; const struct GfxElement *gfx = Machine->gfx[1]; const UINT8 *source = spriteram+127*4; int count; bFlicker = !bFlicker; for( count=0; count<128; count++ ){ int attributes = source[1]; /* 76543210 xxx----- bank ---x---- vertical size ----x--- priority -----x-- horizontal flip ------x- flicker -------x enable */ if ( attributes & 0x01 ){ /* visible */ if( bFlicker || (attributes&0x02)==0 ){ int priority_mask = (attributes&0x08)?0x2:0; int sx = (240 - source[2])&0xff; int sy = (240 - source[0])&0xff; int vx, vy; int number = source[3] | ((attributes<<bank_bits)&0x700); int flipx = (attributes & 0x04); int flipy = 0; if (flip_screen) { flipx = !flipx; flipy = !flipy; } if( attributes & 0x10 ){ /* double height */ number = number&(~1); sy -= 16; vx = sx; vy = sy; if (flip_screen) { vx = 240 - vx; vy = 240 - vy; } pdrawgfx(bitmap,gfx, number, 0 /*color*/, flipx,flipy, vx,vy, cliprect,TRANSPARENCY_PEN,0, priority_mask); number++; sy += 16; } vx = sx; vy = sy; if (flip_screen) { vx = 240 - vx; vy = 240 - vy; } pdrawgfx(bitmap,gfx, number, 0 /*color*/, flipx,flipy, vx,vy, cliprect,TRANSPARENCY_PEN,0, priority_mask); } } source -= 4; } }
static void draw_sprites(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect,int y_offs) { int offs,chain_pos; int x,y,curx,cury; int priority=0; UINT8 col,flipx,flipy,chain; UINT16 code; /* According to Raine, word in ioc_ram determines sprite/tile priority... */ priority = (gcpinbal_ioc_ram[0x68/2] & 0x8800) ? 0 : 1; for (offs = spriteram_size/2-8;offs >= 0;offs -= 8) { code = ((spriteram16[offs+5])&0xff) + (((spriteram16[offs+6]) &0xff) << 8); code &= 0x3fff; if (!(spriteram16[offs+4] &0x80)) /* active sprite ? */ { x = ((spriteram16[offs+0]) &0xff) + (((spriteram16[offs+1]) &0xff) << 8); y = ((spriteram16[offs+2]) &0xff) + (((spriteram16[offs+3]) &0xff) << 8); /* Treat coords as signed */ if (x & 0x8000) x -= 0x10000; if (y & 0x8000) y -= 0x10000; col = ((spriteram16[offs+7]) &0x0f) | 0x60; chain = (spriteram16[offs+4]) &0x07; flipy = (spriteram16[offs+4]) &0x10; flipx = 0; curx = x; cury = y; if (((spriteram16[offs+4]) &0x08) && flipy) cury += (chain * 16); for (chain_pos = chain;chain_pos >= 0;chain_pos--) { pdrawgfx(bitmap, machine->gfx[0], code, col, flipx, flipy, curx,cury, cliprect,TRANSPARENCY_PEN,0, priority ? 0xfc : 0xf0); code++; if ((spriteram16[offs+4]) &0x08) /* Y chain */ { if (flipy) cury -= 16; else cury += 16; } else /* X chain */ { curx += 16; } } } } #if 0 if (rotate) { char buf[80]; sprintf(buf,"sprite rotate offs %04x ?",rotate); popmessage(buf); } #endif }
static void draw_sprites(running_machine* machine, mame_bitmap *bitmap,const rectangle *cliprect) { int offs,fx,fy,x,y,color,sprite; int dx,dy,ax,ay,inc,pri_mask = 0; for (offs = 0;offs < 0x400;offs += 4) { if ((spriteram16[offs+0]&0x8000)!=0x8000) continue; sprite = spriteram16[offs+1]; switch((sprite>>14) & 3) { case 0: pri_mask = 0xf0; // above foreground layer break; case 1: pri_mask = 0xfc; // above midground layer break; case 2: pri_mask = 0xfe; // above background layer break; case 3: pri_mask = 0; // above text layer break; } sprite &= 0x3fff; y = spriteram16[offs+3]; x = spriteram16[offs+2]; if (x&0x8000) x=0-(0x200-(x&0x1ff)); else x&=0x1ff; if (y&0x8000) y=0-(0x200-(y&0x1ff)); else y&=0x1ff; color = spriteram16[offs+0]&0x3f; fx = spriteram16[offs+0]&0x4000; fy = spriteram16[offs+0]&0x2000; dy=((spriteram16[offs+0]&0x0380)>>7)+1; dx=((spriteram16[offs+0]&0x1c00)>>10)+1; inc = 0; for (ax=0; ax<dx; ax++) for (ay=0; ay<dy; ay++) { if (!fx && !fy) { pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+ax*16,y+ay*16, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+ax*16,y+ay*16 + 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+ax*16,y+ay*16 - 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); } else if (fx && !fy) { pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+(dx-1-ax)*16,y+ay*16, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+(dx-1-ax)*16,y+ay*16 + 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+(dx-1-ax)*16,y+ay*16 - 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); } else if (!fx && fy) { pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+ax*16,y+(dy-1-ay)*16, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+ax*16,y+(dy-1-ay)*16 + 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+ax*16,y+(dy-1-ay)*16 - 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); } else { pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+(dx-1-ax)*16,y+(dy-1-ay)*16, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+(dx-1-ax)*16,y+(dy-1-ay)*16 + 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); // wrap around y pdrawgfx(bitmap,machine->gfx[4], sprite + inc, color,fx,fy,x+(dx-1-ax)*16,y+(dy-1-ay)*16 - 512, cliprect,TRANSPARENCY_PEN,15,pri_mask); } inc++; } } }
static void draw_sprites( mame_bitmap *bitmap, const rectangle *cliprect ) { const unsigned char *source = spriteram; const unsigned char *finish = source+0x60; while( source<finish ) { int attributes = source[2]; /* 0x01: horizontal flip * 0x02: vertical flip * 0x04: bank select * 0x08: sprite size * 0x70: color * 0x80: priority */ int priority_mask = 0; int color = (attributes>>4)&7; int flipx = attributes&0x01; int flipy = attributes&0x02; int height = (attributes&0x08) ? 2 : 1; int sx = source[0]-15; int sy = 256-16*height-source[1]; int sprite_number = source[3] + ((attributes & 0x04) << 6); int y; if( attributes&0x80 ) { priority_mask = (0xf0|0xcc ); } else { priority_mask = (0xf0); } if (flip_screen_x) { sx = 239 - sx - 24; flipx = !flipx; } if( flip_screen_y ) { sy = 254 - 16*height - sy; flipy = !flipy; } if (height == 2 && !flipy) { sprite_number ^= 1; } for (y = 0;y < height;y++) { pdrawgfx( bitmap, Machine->gfx[1], sprite_number ^ y, color, flipx,flipy, sx&0xff, sy + 16*y, cliprect, TRANSPARENCY_PEN,0, priority_mask ); } source+=4; } } /* draw_sprites */
static void draw_sprites(struct osd_bitmap *bitmap) { int offs; const UINT8 layout[8][8] = { {0,1,4,5,16,17,20,21}, {2,3,6,7,18,19,22,23}, {8,9,12,13,24,25,28,29}, {10,11,14,15,26,27,30,31}, {32,33,36,37,48,49,52,53}, {34,35,38,39,50,51,54,55}, {40,41,44,45,56,57,60,61}, {42,43,46,47,58,59,62,63} }; for (offs = spriteram_size-8;offs >= 0;offs -= 8) { int flags = spriteram[offs+3]; int priority = flags>>6; int bank = spriteram[offs+0]; if (bank & 4) { /* visible */ int which = spriteram[offs+1]; int code,xpos,ypos,flipx,flipy,priority_mask,x,y; int size = spriteram[offs + 2] & 3; if (tecmo_video_type != 0) /* gemini, silkworm */ code = which + ((bank & 0xf8) << 5); else /* rygar */ code = which + ((bank & 0xf0) << 4); code &= ~((1 << (size*2)) - 1); size = 1 << size; xpos = spriteram[offs + 5] - ((flags & 0x10) << 4); ypos = spriteram[offs + 4] - ((flags & 0x20) << 3); flipx = bank & 1; flipy = bank & 2; if (flip_screen) { xpos = 256 - (8 * size) - xpos; ypos = 256 - (8 * size) - ypos; flipx = !flipx; flipy = !flipy; } /* bg: 1; fg:2; text: 4 */ switch (priority) { default: case 0x0: priority_mask = 0; break; case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ case 0x2: priority_mask = 0xf0|0xcc; break; /* obscured by foreground */ case 0x3: priority_mask = 0xf0|0xcc|0xaa; break; /* obscured by bg and fg */ } for (y = 0;y < size;y++) { for (x = 0;x < size;x++) { int sx = xpos + 8*(flipx?(size-1-x):x); int sy = ypos + 8*(flipy?(size-1-y):y); pdrawgfx(bitmap,Machine->gfx[1], code + layout[y][x], flags & 0xf, flipx,flipy, sx,sy, &Machine->visible_area,TRANSPARENCY_PEN,0, priority_mask); } } } } }
static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect) { int offs; fillbitmap(priority_bitmap,1,NULL); for (offs = spriteram_size - 4;offs >= 0;offs -= 4) { int sx,sy,flipx,flipy,code,color; if (machine->gfx[1]->total_elements > 256) { /* spriteram indoor soccer appears to have a slightly different spriteram format to the other games, allowing a larger number of sprite tiles yyyy yyyy xxxx xxxx TX-T pppp tttt tttt y = ypos x = xpos X = x-flip T = extra tile number bits p = palette t = tile number */ code = spriteram[offs + 3]; color = spriteram[offs + 2] & 0x0f; sx = ((spriteram[offs + 1] + 8) & 0xff) - 8; sy = spriteram[offs]; flipx = spriteram[offs + 2] & 0x40; flipy = 0; if (spriteram[offs + 2] & 0x10) code += 0x100; if (spriteram[offs + 2] & 0x80) code += 0x200; } else { /* spriteram this is the standard spriteram layout, used by most games yyyy yyyy xxxx xxxx YX-p pppp tttt tttt y = ypos x = xpos X = x-flip Y = y-flip p = palette t = tile number */ code = spriteram[offs + 3]; color = spriteram[offs + 2] & 0x1f; sx = ((spriteram[offs + 1] + 8) & 0xff) - 8; sy = spriteram[offs]; flipx = spriteram[offs + 2] & 0x40; flipy = spriteram[offs + 2] & 0x80; } if (flip_screen) { sx = 240 - sx; sy = 240 - sy; flipx = !flipx; flipy = !flipy; } /* first draw the sprite, visible */ pdrawgfx(bitmap,machine->gfx[1], code, color, flipx,flipy, sx,sy, cliprect,TRANSPARENCY_PENS,0x80ff, 0x00); /* then draw the mask, behind the background but obscuring following sprites */ pdrawgfx(bitmap,machine->gfx[1], code, color, flipx,flipy, sx,sy, cliprect,TRANSPARENCY_PENS,0x7fff, 0x02); } }