コード例 #1
0
ファイル: DynamicSprite.c プロジェクト: beletsky/pvsneslib
//---------------------------------------------------------------------------------
int main(void) {
    // Initialize SNES 
	consoleInit();
	
	// Put current handler to our function
	spr_queue = 0xff; spr_mutex = 0;
	__nmi_handler=myconsoleVblank; 

	// Init Sprites gfx and palette with default size of 16x16 (and don't load sprite tiles)
	oamInitGfxSet(&gfxpsrite, 2, &palsprite, 16*2, 0, ADRGFXSPR, OBJ_SIZE16);

	// Define sprites parmaters
	oamSet(0,  100, 100, 3, 0, 0, 0, 0); // Put sprite in 100,100, with maximum priority 3 from tile entry 0, palette 0
	oamSetEx(0, OBJ_SMALL, OBJ_SHOW);
	
	// Now Put in 16 color mode and disable all backgrounds
	setMode(BG_MODE1,0); bgSetDisable(0); bgSetDisable(1); bgSetDisable(2);

	// add new sprite to queue
	addSprite(&gfxpsrite, ADRGFXSPR);
	
	// Wait for nothing :P
	while(1) {
			// Refresh pad values in VBL and Get current #0 pad
		pad0 = padsCurrent(0);
		
		if (pad0) {
			// Key A pressed
			if(pad0 & KEY_A) {
				// if not yet pressed
				if (padkeya == 0) {
					padkeya=1;  // avoid adding new sprite continuisly
					// add new sprite to queue
					addSprite((&gfxpsrite)+8*4*2, ADRGFXSPR);
				}
				
			}
			else
				padkeya=0;
		}
		
		// Wait VBL 'and update sprites too ;-) )
		WaitForVBlank();
	}
	return 0;
}
コード例 #2
0
ファイル: sprites.c プロジェクト: GEMISIS/Death-Match
void DummySprites()
{
	setBrightness(0);
	setSpriteData(0, TEMP_SPRITE1_PAL_ID, 2, &Link, &testgfx, &testgfx_end, &testpal);
	dmaCopyCGram(&spritepal, 128+(1<<4), (16<<1)); //16 colors per palette, 2 bytes per color.
	oamInitGfxSet(Link.gfx, Link.gfxSize, Link.pal, Link.palId, SPRITE1_ADDR_OFFSET + (Link.gfxId), OBJ_SIZE16);
	
	u8 i, x = 0, y = 0;
	for(i = 0; i < 129; ++i){
		x=(i-1)&0xF;
		if(((i-1)&0xF) == 0){
			++y;
		}
		//Link.priority = (i-1)&3;
		Link.gfxId = (i-1);
		Link.palId = y&x&1;//;(i-1)&1;
		Link.x = (x<<4);
		Link.y = (y<<4)+32;//((i<<2)+0x10)&0xFF;
		loadSpriteData(&Link);
		//WaitForVBlank(); //Why was this necessary? Seemed to only slow things down
		//UpdateSprite(i, (x<<4)&0xFF, (y<<4)&0xFF);
	}
	i = 0;

	/*setSpriteData(1, 3, &Link, &spritegfx, &spritegfx_end, &testpal, 0);
	Link.x = 32;
	Link.y = 64;
	loadSpriteData(&Link, OBJ_SIZE16);
	WaitForVBlank();

	setSpriteData(2, 3, &Link, &testgfx, &testgfx_end, &spritepal, 1);
	Link.x = 32;
	Link.y = 96;
	loadSpriteData(&Link, OBJ_SIZE16);
	WaitForVBlank();*/
}