Reads the Game Boy Game Pak Registration Area
#include <ultra64.h> /* ultra64.h */ s32 osGbpakReadId(OSPfs *pfs, u8 *id, u8 *status);
The osGbpakReadId function reads the data in the registration area (0x100 ~ 0x14f) of the Game Boy Game Pak ROM and checks the data to confirm that the Game Boy Game Pak can be accessed correctly.
This function should always be called after N64 Transfer Pak is initialized and before reading or writing data. The function uses osGbpakGetStatus to check the status of the N64 Transfer Pak and osGbpakPower to turn on the power. Thus, it is not necessary to call these functions.
The OSpfs structure pfs is the N64 Transfer Pak control structure. It must first be initialized by osGbpakInit.
Registration data in ROM are stored in the OSGbpakId structure *id. The elements of the OSGbpakId structure are as follows. For more information, see references such as Submitting Game Boy Master ROM.
typedef struct { u16 fixed1; /* Fixed data (0x00, 0xc3) */ u16 start_address; /* Program start address */ u8 nintendo_chr[0x30]; /* "Nintendo" character data */ u8 game_title[16]; /* Game title */ u16 company_code; /* Company code */ u8 body_code; /* Body code */ u8 cart_type; /* Game pak type */ (see note below) u8 rom_size; /* ROM size */ u8 ram_size; /* RAM size */ u8 country_code; /* country code */ u8 fixed_data; /* fixed data(0x33) */ u8 version; /* Mask ROM version number */ u8 isum; /* Complement check */ u16 sum; /* Sum check */ } OSGbpakId;
Note: Please refer to the Game Boy Programming Manual, Chapter 8 "Game Boy Memory Controllers" for additional information.
The N64 Transfer Pak status is returned to *status. Please refer to osGbpakGetStatus function for more detail for status.
The following processes are performed internally in osGbpakReadId function.
First, the N64 Transfer Pak status is examined and the value is returned to status. Next, the status is checked, and if things are normal, then power is turned ON to the Game Boy Game Pak.
The function then checks whether the Game Boy Game Pak data are read normally. It reads the registration area data and checks whether the "Nintendo" character data area and the complement check are correct. When proper reading of the data is confirmed, the registration data in ROM are stored in *id. If there is an error in reading, the PFS_ERR_CONTRFAIL error is returned.
After this function is called, the inserted Game Boy Game Pak should always be confirmed to be one supported by the application. This should usually be checked by examining both the manufacturer code (company_code) and the game title (game_title). This is necessary because developers can give a game any name they desire, so more than one game may have the same game title. Note that the Game Boy Game Paks that were first sold did not contain a manufacturer code.
Return value is an error code. If the function terminates normally, a value of 0 is returned. If an error occurs, one of the following error codes is returned:
PFS_ERR_NOPACK
Nothing is inserted in the specified Controller.
PFS_ERR_DEVICE
A device other than the N64 Transfer Pak is inserted in the Controller.
PFS_ERR_CONTRFAIL
The Controller may not be connected correctly, or there may be some problem with the N64 Transfer Pak or the Controller connector.
If this error is issued, display a message such as the following to the screen: The Game Boy Game Pak connection is abnormal. Please turn off power to the N64 Control Deck and refer to the N64 Transfer Pak User's Manual.
PFS_ERR_NO_GBCART
No Game Boy Game Pak is inserted in the N64 Transfer Pak.
osGbpakInit, osGbpakGetStatus, osGbpakPower, osGbpakReadWrite, osGbpakReadId, and osGbpakCheckConnector
1999/04/30 Changed format