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
|
uhReadGameFormat#include <ultrahost.h> int uhReadGame(int fd, void *addr, int nbytes); What This Function Does The host-to-target IO routines allow a host application to set up a communications channel for the transfer of raw data between the host and the game. They work in concert with OS routines (osReadHost, osWriteHost, osTestHost, osAckRamromRead, and osAckRamromWrite) on the game side. These routines are part of the Ultra 64 host-side library libultrahost.a, so they are available to the application by adding -lultrahost on the link line. The uhReadGame routine attempts to read nbytes of data from the game and copy it to the memory region beginning at addr. For correct operation, it should be paired from the game side with a osWriteHost with exactly the same number of bytes. If the read is attempted from the host side before the game has executed the write, the host process will block. Conversely, if the write is attempted from the game side before the host has executed a read, the game thread will block. When both sides have correctly made the corresponding procedure call, the transfer will take place and the blocking side will proceed. Return Value The number of bytes successfully read is returned. Example The following example shows how a host application can initiate the game and establish a connection to transfer data. This particular sequence guarantees that no handshaking events are lost. By the time the game sends its first packet of data, the host device driver is ready to acknowledge it. Furthermore, the host side application does not attempt to send data to the game before it has booted. /* Host side code */ main(int argc, char **argv) { pid_t pid; int fd, status; if ((fd = uhOpenGame("/dev/u64_data")) == -1) { perror("uhOpenGame"); return(-1); } if ((pid = fork()) == -1) { perror("fork); return(-1); } else if (pid == 0) { (void)execl("/usr/sbin/gload", "/usr/sbin/gload", 0); fprintf(stderr, "host: execl( return(-1); } if (uhReadGame(fd, hostBuffer, 4) == -1) { fprintf(stderr, "uhReadGame %s0, sys_errlist[errno]); return(1); } if (uhCloseGame(fd) != 0) { perror("uhCloseGame"); return(-1); } if (waitpid(pid, status, WUNTRACED) == -1) { perror("waitpid"); return(-1); } } /* Game side code */ mainproc(void *arg) { osWriteHost(gameBuffer, 4); osExit(); }See Also uhOpenGame uhCloseGame uhWriteGame uhReadRamrom uhWriteRamrom osReadHost osWriteHost osTestHost osAckRamromRead osAckRamromWrite
|