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

## uhGLoad

Syntax

    #include <ultrahost.h>
    int uhPartnerCmd(int fd,char * cmd);
    int uhGLoad(int fd,char * gamename);

Return Values

- uhPartnerCmd
  When succcessful, returns the length of the command sent to PARTNER. With failure, returns an error code with a negative value.

- uhGLoad
  Returns 0 when succesful and -1 when it fails.

Explanation
The uhGLoad and usPartnerCmd routines set up and use communication channels for data transfer between PARTNER and 64 on the host application. The device handler that is passed to the commands, fd, is obtained from uhOpenGame(). For more information, please see uhOpenGame.

uhPartnerCmd issues the various commands that PARTNER can use. For more information, see the PARTNER manual.

uhGLoad uses PARTNER to load and execute the 64 game specified bygamename.

Following is an example of the uh functions used for Partner.

This example is a host application that responds to instructions from the game once it is loaded. In this example, instructions from the game are received and passed after being stored in the structure TCommandPacket. PARTNER must be started before the application is executed.

    #include <ultrahost.h>

        #define DEV_U64_DATA    "PARTNER-N64"

        typedef TCommandPacket int;
        TCommandPacket cmdpkt;
        extern s32 errStop(char *);

        main(int argc, char **argv) /* Host side code */
            {
              int     cmd,done;

        /* Open the device. */
                if ((fd = uhOpenGame(DEV_U64_DATA)) < 0)
                    errStop("device open error");

        /* Load the game.  */
               if( uhGLoad(fd ,0) != 0 ) errStop("gload failed");

               while (!done)
                    {
                          cmd = catchCommand(); // Receive a command from the 64 game.

                          switch(cmd)   // Process according to the command.
                            {
                                case CMD_A:
                                    ....
                                case CMD_B:
                                    ...
                            }
                    }

                uhCloseGame(fd);
            }

        int
        catchCommand(void) // Receive 64 data.  Take care to avoid using the wrong endian format.

          {
            TCommandPacket cmdpkt;
            if ( uhReadGame(fd, (void *)&cmdpkt, sizeof(TCommandPacket)) < 0)
                  errStop("fail uhReadGame");

        #ifdef __PARTNER_PC__
            rev((unsigned *)&cmdpkt);    // Reverse the endian format for PC.
        #endif

            return (int)cmdpkt;
          }

See Also
uhCloseGame
uhOpenGame
uhReadGame
uhWriteGame
osReadHost
osWriteHost

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