Esempio n. 1
0
/**
 * \brief Used to setup the game's eeprom block on first run to prevent garbage data. Checks for a magic number to verify formatting.
 *
 * \return 0 if block is formatted correctly for this game, 1 if not.
 */
u8 checkEeprom(void)
{
	struct EepromBlockStruct ebs; //create temp eeprom block struct for use
	ebs.id = save_block; //assign to this game's block id
	if(EepromReadBlock(ebs.id, &ebs)==0) //reads block values into temp struct, if successful, moves on
	{
		if(ebs.data[17] == 0x17) //looks for magic number
			return 0; //block was read, and magic number was present, block is good
	}
	return 1; //something failed along the way, block is bad
}
Esempio n. 2
0
/**
 * \brief Loads saved scores from eeprom.
 *
 * Loads scores from eeprom and saves them into current game memory for use.
 * \param index0 Lower boundary score to load (inclusive)
 * \param index1 Upper boundary score to load (inclusive)
 */
void LoadScore(u8 index0, u8 index1)
{
	//Initialize a struct and define the block id
	struct EepromBlockStruct ebs; //create a temporary eeprom block struct
	ebs.id = save_block; //set it to read this game's block
	if(EepromReadBlock(ebs.id, &ebs)==0) //read data from eeprom into the struct, if it works, proceed
	{
		for(u8 i = index0; i<=index1; i++) //read scores from index0 to index1 and save them into our top score array for use
		    topscores[i]=(u8)ebs.data[i];
	}
}
Esempio n. 3
0
/**
 * Main code
 */
int main() {
	SetTileTable(tiles);
	SetSpritesTileTable(tiles);
	SetFontTilesIndex(TILE_FIRST_FONT);
	InitMusicPlayer(patches);
	TriggerNote(3,SOUND_INTRO_MUSIC,20,0xff);
	SetUserPostVsyncCallback(vsync_callback);

	// read custom configuration from eeprom
	EepromReadBlock(129, &eeprom_data);
	eeprom_data.id = 129;

	game();
}
Esempio n. 4
0
void loadEeprom(){
    //load eeprom savegame
    u8 code=EepromReadBlock(EEPROM_ID,(struct EepromBlockStruct*)&saveGame);
    if(code==EEPROM_ERROR_BLOCK_NOT_FOUND || saveGame.blankMarker==0xffffffff){
    	//setup eeprom save game block
    	saveGame.id=EEPROM_ID;
    	struct EepromBlockStruct* ptr=(struct EepromBlockStruct*)&saveGame;
    	for(u8 i=0;i<30;i++){
    		ptr->data[i]=0;
    	}
    	EepromWriteBlock((struct EepromBlockStruct*)&saveGame);
    }

}