WPADWriteGameData

Syntax

#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 WPADWriteGameData( s32 chan, void *p_buf, u16 len, u16 offset, WPADCallback callback );

Arguments

chan One of the WPAD_CHANn values.
p_buf The starting address of the game data to save.
len The size of the game data to save.
offset The offset from the ending address of the game data's file information (the starting address for where game data can be actually written) to the starting address for the write process.
callback Callback function to report on the result.

Return Values

Returns one of the following codes:

WPAD_ERR_NONE
WPAD_ERR_NO_CONTROLLER
WPAD_ERR_BUSY

Description

Writes data to the Wii Remote memory at the specified channel. This function registers the commands for writing 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's memory, but the library uses the first 112 bytes 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 file information contains the game title set with the WPADSetGameTitleUtf16 function and the timestamp indicating when the file was last saved. When this function is called, that information is written to Wii Remote memory. Obtain the game title with the WPADGetGameTitleUtf16 function and the "last saved" timestamp with the WPADGetGameDataTimeStamp function.

The return values have the following meanings:

WPAD_ERR_NONEThe WPAD library received a command.
WPAD_ERR_BUSYThe WPAD library was unable to receive a command.
WPAD_ERR_NO_CONTROLLERThe connection was broken.

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.

See Also

WPADReadGameData
WPADSetGameTitleUtf16
WPADGetGameTitleUtf16
WPADGetGameDataTimeStamp

Revision History

2009/09/24 Explained the timing of the call to the callback function.
2008/06/04 Standardized terminology.
2008/03/21 Added that the items set with the WPADSetGameTitleUtf16 function will be included when data is written to internal memory.
2007/02/08 Revised the offset description.
2006/11/29 Added WPAD_ERR_BUSY, which had been left out of the error codes passed by the callback.
2006/09/27 Added descriptions for WPADSetGameTitleUtf16 and WPADGetGameTitleUtf16.
2006/08/15 Initial version.


CONFIDENTIAL