osGbpakGetStatus (function)

Gets status of the N64 Transfer Pak

Syntax

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

Description

The osGbpakGetStatus function is used to detect the status of the N64 Transfer Pak.

OSPfs structure pfs must be initialized first with osGbpakInit function.

The detected result is returned to status. Determines the status according to whether the following bits are set.

OS_GBPAK_GBCART_ON

This bit indicates that a Game Boy Game Pak is inserted. It is returned when a Game Boy Game Pak is inserted into the N64 Transfer Pak.

OS_GBPAK_GBCART_PULL

This bit indicates that removal of a Game Boy Game Pak has been detected. It is returned once the Game Boy Game Pak has been removed.
When there is a Game Boy Game Pak in the N64 Transfer Pak and the osGbpakGetStatus or osGbpakReadId function is called, this bit becomes 0.

OS_GBPAK_POWER

This bit indicates the state of power supply to the Game Boy Game Pak. When this bit is 1, power is ON; when this bit is 0, power is OFF.
Note that this only checks for power on the software side, and does not confirm that the hardware has a stable power supply. The status of the latter cannot be checked on the software side. For details, please refer to osGbpakPower.

OS_GBPAK_RSTB_DETECTION

This bit indicates that the Reset signal has been detected. When the Game Boy Game Pak is reset, this bit becomes 1. If either the osGbpakGetStatus or the osGbpakReadId function is called when a Game Boy Game Pak is inserted, this bit returns to 0. Since this bit becomes 1 when the power is turned on, you need to clear it back to 0 after the power is turned on by calling the osGbpakGetStatus or the osGbpakReadId function so the bit status can be used to detect a Reset signal.


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

Data transfers with the Controller have failed. The Controller may not be connected correctly, or there may be some problem with the N64 Transfer Pak or the Controller connector.

PFS_ERR_NO_GBCART

No Game Boy Game Pak is inserted in the N64 Transfer Pak.

PFS_ERR_NEW_GBCART

A Game Boy Game Pak has been removed and reinserted. A different Game Boy Game Pak may have been inserted.

If you remove and reinsert a Game Boy Game Pak and then reset N64, the flag for insertion and removal of the Game Boy Game Pak will remain up. Therefore you need to be careful, because a PFS_ERR_NEW_GBCART error will be returned if osGbpakInit and then osGbpakGetStatus are executed after resetting N64. If osGbpakReadId is called instead of osGbpakGetStatus, the PFS_ERR_NEW_GBCART error will not be issued. Thus, osGbpakReadId should be used to check the status of the N64 Transfer Pak after initialization.

See Also

osGbpakInit, osGbpakPower, osGbpakReadWrite, osGbpakReadId, and osGbpakCheckConnector

Revision History

1998/10/29 Added OS_GBPAK_RSTB_DETECTION to the detected statuses
1999/04/30 Changed format