Rollback Detection Demo

Description

This sample code represents a sample implementation of rollback detection using the fs library.
From the user's perspective, this sample demo mimics a game that appears to have multiple (in this case three) slots (files) to be saved.

Required Environment

How to Use

Input Operation
A Button Writes the data specified by "Data on memory" to a file specified using "File index."
A random number, used as the version number for the data to be saved, is generated and written to save data and internal system memory.
Y Button Loads saved data in the file specified as "File index."
The version number of the data is also loaded and checked against the value saved in internal system memory.
If verification is successful, the data is treated as valid and "Data on memory" is updated to the value loaded.
X Button Initializes data in memory (sets "Data on memory" to 'A') and initializes the version number to a random value.
This is equivalent to resetting the game state.
Data is not saved to save data.
Up/Down Buttons Switches the data to be input between "File index" and "Data on memory."
L/R Buttons Updates the value of "File index" or "Data on memory."
Modification of "Data on memory" is equivalent to the user actually playing a game and changing the game state.

Execution Procedure

When launching immediately after importing, the log SaveData was formatted is displayed on the upper screen. Select the corresponding file slot for "File index" and press A to save the data.
Use the Y Button to read the data.
If the version value saved in save data is not the same as the version value saved in the device, Loading Failed is displayed on the upper screen.

To confirm the behavior of an actual rollback, you must take the content that has been saved to the SD Card and make a backup copy of it on a computer or elsewhere.
Restart the application, save the save data, and then write the backup that was prepared in advance. This enables you to verify that the rollback is detected the next time data is loaded.

Revision History

2012/04/27
Compliance with changes to API specifications.
2012/02/16
Initial version.

CONFIDENTIAL