Function


nuContGBPakFread


Syntax

s32 nuContGBPakFread(NUContPakFile *handle, u16 address, u8 *buffer, u16 size)

Arguments

handle      GB Pak control structure (shared with Controller Pak structure)
address     Game Boy Game Pak address
buffer      data buffer
size        byte size

Return Value

Error

Description

Reads data from a high-performance Game Boy Game Pak

Reads "size" bytes of data into the "buffer" from the specified "address" of the Game Boy Game Pak.

This function can read data even when the Game Boy Game Pak's CPU address and the read size are not multiples of 32. It also internally checks the connector and, after the data is read, checks the status. Furthermore, it checks the address, and if access is to a RAM area in MBC 1,2,3 it enables access and then reads the data. After access it write-protects the area.

Since power for the Game Boy Game Pak is not turned on as part of the function before reading, please perform reading or writing after turning power ON and checking the Game Boy Game Pak ID. Also, this function does not turn the power off, so if you are not going to perform a read/write operation after this function, please turn the power OFF with the nuContGBPakPower function.

Since this function uses osGbpakCheckConnector() it only supports Game Paks with MBC 1,2,3 or which do not use a memory controller.

Errors

PFS_ERR_NOPACK Nothing is inserted in the specified Controller.
PFS_ERR_DEVICE Some device other than a GB Pak is inserted in the Controller.
PFS_ERR_CONTRFAIL Data transfer with Controller has failed. Either the Controller is not connected properly,
or there may be some problem with the GB Pak or the Controller connector.
PFS_ERR_NO_GBCART Game Boy Game Pak is not inserted in the GB Pak.
PFS_ERR_NEW_GBCART Game Boy Game Pak has been removed and reinserted.