#include <revolution/wpad.h> #define WPAD_CHAN0 0 #define WPAD_CHAN1 1 #define WPAD_CHAN2 2 #define WPAD_CHAN3 3 #define WPAD_MEM_GAMEDATA_LEN 3888 s32 WPADReadGameData( s32 chan, void *p_buf, u16 len, u16 offset, WPADCallback callback );
| chan | One of the WPAD_CHANn values. |
|---|---|
| p_buf | The leading address for the buffer to which the read game data is copied. |
| len | The size of the game data to be read. |
| offset | The offset from the game data's leading address to the start of the read. |
| callback | Callback function for reporting the result. |
Returns one of the following codes:
WPAD_ERR_NONE
WPAD_ERR_NO_CONTROLLER
WPAD_ERR_BUSY
WPAD_ERR_BROKEN
WPAD_ERR_NOPERM
Reads game data from the memory of the specified channel's Wii Remote. This function registers the commands for reading game data to the library. The WPAD library processes registered commands when other commands are not running.
For saving game data, 4000 bytes are allocated in the Wii Remote memory, but the first 112 bytes are used by the library to manage file information. Even though an application can only save game data to the 3888 bytes from the 112th to the 4000th byte, the 112th byte has an offset value of 0 within the library so there is no need to be particularly aware of it.
The game title set with the WPADSetGameTitleUtf16 function, and the date and time when the file was saved are stored in the file information. The game title can be obtained with the WPADGetGameTitleUtf16 function, and the date and time can be obtained with the WPADGetGameDataTimeStamp function.
Applications can read only the game data that was created by the same application. When attempting to load game data that was created on a different application, WPAD_ERR_NOPERM is returned. In addition, when attempting to read game data that does not have correctly written file information due to causes such as disconnection during writing, WPAD_ERR_BROKEN is returned.
The return values have the following meanings:
| WPAD_ERR_NONE | The WPAD library received a command. |
|---|---|
| WPAD_ERR_BUSY | The WPAD library was unable to receive a command. |
| WPAD_ERR_NO_CONTROLLER | The connection was broken. |
| WPAD_ERR_NOPERM | Could not be read because another game file was saved. |
| WPAD_ERR_BROKEN | The file does not exist, or the file information is corrupted. |
When a callback function has been set, the callback function is called together with the processing result. When the return value is WPAD_ERR_NONE, the callback function is called when the process is completed. Otherwise, it is called before the function escapes. The following error codes are passed to the callback function.
| WPAD_ERR_NONE | The command was processed normally. |
|---|---|
| WPAD_ERR_BUSY | The WPAD library was unable to receive a command. Call it again later. |
| WPAD_ERR_TRANSFER | A communications error prevented normal processing of the command. |
| WPAD_ERR_NO_CONTROLLER | The connection was broken. |
| WPAD_ERR_NOPERM | Could not be read because another game file was saved. |
| WPAD_ERR_BROKEN | The file does not exist or the file information is corrupted. |
WPADWriteGameData
WPADSetGameTitleUtf16
WPADGetGameTitleUtf16
WPADGetGameDataTimeStamp
2009/09/24 Explained the timing of the call to the callback function.
2007/02/08 Revised the offset description.
2006/11/29 Added errors that had been left out of the error codes passed by the callback.
2006/09/23 Added descriptions for WPADSetGameTitleUtf16, WPADGetGameTitleUtf16, and error codes.
2006/09/20 Added WPAD_ERR_BROKEN and WPAD_ERR_NOPERM.
2006/08/15 Initial version.
CONFIDENTIAL