Type EepromBlockStruct: Difference between revisions

From Uzebox Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
Line 21: Line 21:
     return hiScore
     return hiScore
  }
  }
* '''Video Modes''': All

Latest revision as of 22:20, 25 February 2010

EepromBlockStruct represents a Uzebox Eeprom data block that can be used in conjunction with EepromReadBlock and EepromWriteBlock for preservation of data between Uzebox resets.

struct EepromBlockStruct {
    unsigned int id;         // Unique block id. 0xffff if block is free (assuming formatted eeprom)
    unsigned char data[30];  // Application specific data (cast to your own types)
};

Example:

u32 LoadHighScore(void) {
    struct EepromBlockStruct ebs;

    ebs.id = 99;

    if (!isEepromFormatted() || EepromReadBlock(99, &ebs))
        return;
    u32 hiScore = 0;

    for (u8 i = 0; i < 4; i++)
        hiScore |= ((u32)(ebs.data[i]))<<(24-(i<<3));
    return hiScore
}
  • Video Modes: All