viewport.c
changeset 2187 a0e206ce9fbf
parent 2186 db48cf29b983
child 2319 fba7d61df04a
equal deleted inserted replaced
2186:db48cf29b983 2187:a0e206ce9fbf
   359 void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z)
   359 void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z)
   360 {
   360 {
   361 	ViewportDrawer *vd = _cur_vd;
   361 	ViewportDrawer *vd = _cur_vd;
   362 	TileSpriteToDraw *ts;
   362 	TileSpriteToDraw *ts;
   363 
   363 
   364 	assert((image & 0x3FFF) < NUM_SPRITES);
   364 	assert((image & SPRITE_MASK) < MAX_SPRITES);
   365 
   365 
   366 	if (vd->spritelist_mem >= vd->eof_spritelist_mem) {
   366 	if (vd->spritelist_mem >= vd->eof_spritelist_mem) {
   367 		DEBUG(misc, 0) ("Out of sprite mem");
   367 		DEBUG(misc, 0) ("Out of sprite mem");
   368 		return;
   368 		return;
   369 	}
   369 	}
   401 
   401 
   402 static void AddCombinedSprite(uint32 image, int x, int y, byte z)
   402 static void AddCombinedSprite(uint32 image, int x, int y, byte z)
   403 {
   403 {
   404 	const ViewportDrawer *vd = _cur_vd;
   404 	const ViewportDrawer *vd = _cur_vd;
   405 	Point pt = RemapCoords(x, y, z);
   405 	Point pt = RemapCoords(x, y, z);
   406 	const SpriteDimension *sd = GetSpriteDimension(image & 0x3FFF);
   406 	const SpriteDimension *sd = GetSpriteDimension(image & SPRITE_MASK);
   407 
   407 
   408 	if (pt.x + sd->xoffs >= vd->dpi.left + vd->dpi.width ||
   408 	if (pt.x + sd->xoffs >= vd->dpi.left + vd->dpi.width ||
   409 			pt.x + sd->xoffs + sd->xsize <= vd->dpi.left ||
   409 			pt.x + sd->xoffs + sd->xsize <= vd->dpi.left ||
   410 			pt.y + sd->yoffs >= vd->dpi.top + vd->dpi.height ||
   410 			pt.y + sd->yoffs >= vd->dpi.top + vd->dpi.height ||
   411 			pt.y + sd->yoffs + sd->ysize <= vd->dpi.top)
   411 			pt.y + sd->yoffs + sd->ysize <= vd->dpi.top)
   420 	ViewportDrawer *vd = _cur_vd;
   420 	ViewportDrawer *vd = _cur_vd;
   421 	ParentSpriteToDraw *ps;
   421 	ParentSpriteToDraw *ps;
   422 	const SpriteDimension *sd;
   422 	const SpriteDimension *sd;
   423 	Point pt;
   423 	Point pt;
   424 
   424 
   425 	assert((image & 0x3FFF) < NUM_SPRITES);
   425 	assert((image & SPRITE_MASK) < MAX_SPRITES);
   426 
   426 
   427 	if (vd->combine_sprites == 2) {
   427 	if (vd->combine_sprites == 2) {
   428 		AddCombinedSprite(image, x, y, z);
   428 		AddCombinedSprite(image, x, y, z);
   429 		return;
   429 		return;
   430 	}
   430 	}
   460 	ps->tile_z = z;
   460 	ps->tile_z = z;
   461 	ps->tile_z_bottom = z + dz - 1;
   461 	ps->tile_z_bottom = z + dz - 1;
   462 
   462 
   463 	pt = RemapCoords(x, y, z);
   463 	pt = RemapCoords(x, y, z);
   464 
   464 
   465 	sd = GetSpriteDimension(image & 0x3FFF);
   465 	sd = GetSpriteDimension(image & SPRITE_MASK);
   466 	if ((ps->left = (pt.x += sd->xoffs)) >= vd->dpi.left + vd->dpi.width ||
   466 	if ((ps->left = (pt.x += sd->xoffs)) >= vd->dpi.left + vd->dpi.width ||
   467 			(ps->right = (pt.x + sd->xsize)) <= vd->dpi.left ||
   467 			(ps->right = (pt.x + sd->xsize)) <= vd->dpi.left ||
   468 			(ps->top = (pt.y += sd->yoffs)) >= vd->dpi.top + vd->dpi.height ||
   468 			(ps->top = (pt.y += sd->yoffs)) >= vd->dpi.top + vd->dpi.height ||
   469 			(ps->bottom = (pt.y + sd->ysize)) <= vd->dpi.top) {
   469 			(ps->bottom = (pt.y + sd->ysize)) <= vd->dpi.top) {
   470 		return;
   470 		return;
   492 void AddChildSpriteScreen(uint32 image, int x, int y)
   492 void AddChildSpriteScreen(uint32 image, int x, int y)
   493 {
   493 {
   494 	ViewportDrawer *vd = _cur_vd;
   494 	ViewportDrawer *vd = _cur_vd;
   495 	ChildScreenSpriteToDraw *cs;
   495 	ChildScreenSpriteToDraw *cs;
   496 
   496 
   497 	assert((image & 0x3FFF) < NUM_SPRITES);
   497 	assert((image & SPRITE_MASK) < MAX_SPRITES);
   498 
   498 
   499 	if (vd->spritelist_mem >= vd->eof_spritelist_mem) {
   499 	if (vd->spritelist_mem >= vd->eof_spritelist_mem) {
   500 		DEBUG(misc, 0) ("Out of sprite mem");
   500 		DEBUG(misc, 0) ("Out of sprite mem");
   501 		return;
   501 		return;
   502 	}
   502 	}