void smeMAP_Render(smeMap* map, s16 x, s16 y, u16 w, u16 h) { u16 mx = smeMOD(x, map->Width); u16 my = smeMOD(y, map->Height); u16 px = smeMOD(x, smePLAN_WIDTH); u16 py = smeMOD(y, smePLAN_HEIGHT); u16 mxs[6]; u16 pxs[6]; u16 nx = 0; smeMAP_Slice(mxs, pxs, &nx, mx, px, w, map->Width, smePLAN_WIDTH); u16 mys[6]; u16 pys[6]; u16 ny = 0; smeMAP_Slice(mys, pys, &ny, my, py, h, map->Height, smePLAN_HEIGHT); u16 i, j; for (j=0 ; j<ny ; j+=2) { u16 hs = pys[j+1]; for (i=0 ; i<nx ; i+=2) { u16 ws = pxs[i+1]; VDP_setMapEx(VDP_PLAN_A, map->PlaneA->Data, TILE_ATTR(0, 0, 0, 0), pxs[i], pys[j], mxs[i], mys[j], ws, hs); VDP_setMapEx(VDP_PLAN_B, map->PlaneB->Data, TILE_ATTR(1, 1, 0, 0), pxs[i], pys[j], mxs[i], mys[j], ws, hs); } } }
//Character selection menu //@Fix glitchy BG screen and display of Arrow void ChrselMenu() { Sprite sprites[1]; //Sprite struct DrawBG(0); //Cls DrawBG(8); //Draw "How many players" BG InitMenu(1,0,0,3,_FALSE); //Init a 2 item Menu //Setup the arrow sprite SYS_disableInts(); SPR_init(16); //Sprite tile cache of 16 tiles SYS_enableInts(); // !@ Screws up SPR_initSprite(&sprites[0], &SPR_Arrow, 271, 266, TILE_ATTR(MISCPAL,TRUE,FALSE,FALSE)); //Init the Arrow Sprite VDP_setPalette(MISCPAL, SPR_Arrow.palette->data); //Init pal OBJPAL to Arrow pal echo_play_sfx(SFX_13); //"How many players are going to play today?" JOY_setEventHandler( &BtnHMenu ); //Setup joy handler to HMenu type //While no items are selected while (SItem==0) { //If 1 player hilighted if ((HItem==1) && (Trig==_FALSE)) { SPR_setPosition(&sprites[0],271,266); //Set new arrow position SPR_update(sprites, 1); //Update it } else { SPR_setPosition(&sprites[0],311, 266); SPR_update(sprites, 1); } VDP_waitVSync(); } VDP_resetSprites(); //@Toggle amt of players as appropriately if (SItem==1) { Opts[0]=_FALSE; } else { Opts[0]=PTRUE; } SPR_setPosition(&sprites[0],-128, -128); //@Kill sprite SPR_update(sprites, 1); //Update it SPR_end; //Kill sprite engine echo_wait_sfx(SFX_10); //"Let us play some hockey!" VDP_fadeOutAll(100,_FALSE); }
void explosion_terrain_new ( u16 x, u16 y ) { u16 aux = _find(); u16 sprite = sd_new(); expTerrains[aux].timeout = EXPLOSION_TERRAIN_COUNTER; expTerrains[aux].sprite = sprite; SPR_initSprite(&sprites[sprite], &leo, x*8*2, y*8*2, TILE_ATTR(PAL3, TRUE, FALSE, FALSE)); SPR_setAnim(&sprites[sprite], EXPLOSION_TERRAIN_SPRITE_POS ); }
frameSprite_* getFrameSprite(unsigned char *image8bpp, int wi, int x, int y, int w, int h) { int i, j; int p, pal; int index; unsigned int tile[8]; frameSprite_* result; tileset_* tileset; // get palette for this sprite pal = getTile(image8bpp, tile, 0, 0, wi * 8); // error retrieving tile --> return NULL if (pal == -1) return NULL; // allocate tileset tileset = createTileSet(malloc(w * h * 32), 0); for(i = 0; i < w; i++) { for(j = 0; j < h; j++) { p = getTile(image8bpp, tile, i + x, j + y, wi * 8); // error retrieving tile --> return NULL if (p == -1) { freeTileset(tileset); return NULL; } // different palette in VDP same sprite --> error if (p != pal) { printf("Error: Sprite at position (%d,%d) of size [%d,%d] reference different palette.", x, y, w, h); freeTileset(tileset); return NULL; } index = addTile(tile, tileset, FALSE); // error adding new tile --> return NULL if (index == -1) { freeTileset(tileset); return NULL; } } } // allocate result result = malloc(sizeof(frameSprite_)); // always first index as we result->ind = 0; result->attr = TILE_ATTR(pal, FALSE, FALSE, FALSE); // initialized afterward result->x = 0; result->y = 0; result->w = w; result->h = h; result->tileset = tileset; return result; }