N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

## osGbpakReadId

Syntax

    #include <ultra64.h>

    s32 osGbpakReadId(OSPfs *pfs, u8 *id, u8 *status);

Explanation
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 Game Boy Pak is initialized and before reading or writing data. The function uses osGbpakGetStatus() to check the status of the Game Boy Pak and osGbpakPower() to turn on the power. Thus, it is not necessary to call these functions.

The OSpfs structure pfs is the N64 Game Boy 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 */
      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;

The N64 Game Boy Pak status is returned to *status. Please refer to osGbpakGetStatus() for additional information.

The following processes are performed internally in osGbpakReadId() function.

First, the N64 Game Boy 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 cartridge 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 cartridge 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 cartridges 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 Game Boy 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 Game Boy Pak or the controller connector.

If this error is issued, display a message such as the following to the screen: The Game Boy cartridge connection is abnormal. Please turn off power to the 64 unit and refer to the 64GB User's Manual.

PFS_ERR_NO_GBCART
No Game Boy game pak is inserted in the N64 Game Boy Pak.

See Also
osGbpakInit (3P)
osGbpakGetStatus (3P)
osGbpakPower (3P)
osGbpakReadWrite (3P)
osGbpakReadId (3P)
osGbpakCheckConnector (3P)

Nintendo® Confidential Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.
Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated March 1998