Function
nuContGBPakRegWrite
Syntax:
s32 nuContGBPakRegWrite(NUContPakFile* handle, u16 addr, u8 data)
Arguments:
handle GB Pak control structure (shared with Controller Pak structure) addr CPU address of Game Boy Game Pak data Data value to write
Return Value:
Error
Explanation:
Writes to the Memory Controller register
Writes the "data" value to the memory bank controller register (MBC1, MBC2, MBC3) specified by "addr." One byte is sufficient when writing to the memory bank controller register, but due to hardware restrictions with the GB Pak, data is written 32 bytes at a time. This function writes 0 for the first 31 bytes and writes the "data" value at the end. Please be careful, because the "data" value is written to an address that is 31 bytes larger than the address specified by "addr."
nusys.h has the following variable definitions.
Register 0 NU_CONT_GBPAK_MBC_REG0_ADDR 0x0000
Register 1 NU_CONT_GBPAK_MBC_REG1_ADDR 0x2100
Register 2 NU_CONT_GBPAK_MBC_REG2_ADDR 0x4000
Register 3 NU_CONT_GBPAK_MBC_REG3_ADDR 0x6000
This function is for MBC1, MBC2, and MBC3. If using other memory controllers, please refer to this function.
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. |