uhPartnerCmd (for PARTNER) (function)

uhPartnerCmd, uhGLoad

Passes commands to PARTNER

Syntax

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

Return Values

uhPartnerCmd

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

uhGLoad

Returns 0 when successful and -1 when it fails.

Description

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 by gamename.

Example

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

osReadHost, osWriteHost, uhOpenGame, uhCloseGame, uhReadGame, and uhWriteGame

Revision History

1999/04/30 Changed format