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

## osGbpackCheckConnector

Syntax

    #include <ultra64.h>
    s32 osGbpakCheckConnector(OSPfs *pfs, u8 *status);

Explanation
The osGbpakCheckConnector() function confirms that the N64 Game Boy Pak and the Game Boy game pak are firmly connected together. It checks whether each Game Boy cartridge address line is properly connected.

If you call osGbpakReadWrite() function without first calling this function, data could be read or written to the wrong address because of a poor connection. Therefore, please make sure to call the osGbpakCheckConnector() function before calling the osGbpakReadWrite() function.

Before this function is called, the functions osGbpakInit() and osGbpakReadId() must always be called. osGbpakCheckConnector internally performs a status check with osGbpakGetStatus() and turns the power on with osGbpakPower(). Thus, these functions do not need to be called.

osGbpakCheckConnector() supports only the following Game Boy game paks. Note that its operation is not guaranteed with other game paks.

- No memory controller
- MBC1
- MBC2
- MBC3

The OSpfs structure pfs is used for N64 Game Boy Pak control. Before being used, it must initialized by the function osGbpakInit(). The status of the 64GB Pak is returned as *status. For information on status, see the osGbpakGetStatus() function.

The internal operations performed by the osGbpakCheckConnector() function are as follows.

- Checks the ROM area addresses of the Game Boy cartridge and performs the following processing for 0x0000, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, and 0x4000.

  1. Compares data starting at the above addresses with neighboring data in 32-byte units.

  2. If the data are identical, compares the next 32 bytes, and if this is also the same, compares the next 32 bytes. Up to 4 comparisons (i.e.,, 128 bytes) are performed. If all data are identical, the address line is considered insecurely connected and an error is returned.
  If different data are detected even once, it is determined that the data are being read properly and the function advances.

- Data at cache of the above addresses are compared with the data starting at 0x0000 in 32-byte units.

- As in 2., up to 4 comparisons (128 bytes) are made. If all the data are identical, an error is returned.
  If different data are detected even once, it is determined that the data are being read properly and the function advances.

- If a RAM area exists, the function checks the address of the Game Boy cartridge RAM area and performs the following processing for 0x2000 and 0xa000.

  1. Compares the data starting at the above addresses in 32-byte units.

  2. If the data are identical, compares the next 32 bytes, and if this is also the same, compares the next 32 bytes. Up to 4 comparisons (ie, 128 bytes) are performed. If all the data are the same, the address line is evaluated to be insecurely connected and an error is returned.
     If different data are detected even once, it is determined that the data are being read properly and the function advances.

Because osGbpakCheckConnector() performs the processing above, it does not support all Game Boy cartridges. It may not operate properly in some Game Boy cartridges. Examples are as follows.

- The cartridge uses a special memory controller.
  (osGbpakCheckConnector() does not swap banks internally)

- The 128 bytes beginning from 0x0000 and the 128 bytes beginning from 0x0080 by chance contain the same data.

- The 128 bytes beginning from ROM address 0x2000 contain the data at the start of SRAM.

- During play, the data at the start of SRAM become the same as those in the 128 bytes starting from address 0x2000.

When using osGbpakCheckConnector(), be careful to note whether the above conditions occur. If they are unavoidable, osGbpakCheckConnector() should not be used, and the connector-check function supported by the application should be used instead.

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 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)

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