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
|
|
osPfsReadWriteFile
Syntax
#include <ultra64.h>
s32 osPfsReadWriteFile(OSPfs *pfs,
s32 file_no, u8 flag,
int offset, int nbytes,
u8 * data_buffer);
Explanation
It reads from and writes to game notes. If PFS_READ is specified for the flag argument, data is read from the game
note; if PFS_WRITE is specified data is written to the game note.
When data is read, the amount of data specified by the nbytes argument is read, beginning
from the offset byte of the game data area specified by the offset argument, and stored in the area pointed to by the data_buffer argument.
When data is written, nbytes of data in the area specified by data_buffer is written to the game data area beginning from the offset byte.
Both the offset and nbytes arguments must be set to a multiple of BLOCKSIZE (32 bytes) and must be smaller than the file size. The arguments cannot, of course, be set so that data is read from or written to areas outside of those that have been assigned.
The file_no argument specifies the note number (file descriptor). To obtain its value, call the osPfsAllocateFile or osPfsFindFile function.
The OSPfs structure pointed to by the pfs argument is a file handle initialized by the osPfsInitPak function. For information
on creating this handle, please see osPfsInitPak.
If the function is successful, 0 is returned as the return value. If an error occurs, one of following error codes is returned:
- PFS_ERR_NOPACK - Some type of PIF error has occurred. Either the Controller Pak is not inserted into the specified Controller or the Controller is not properly connected. To determine which is the case, use the osContStartQuery or osContGetQuery function.
- PFS_ERR_NEW_PACK - A different Controller Pak has been inserted. To use the inserted Controller Pak, initialize it by calling osPfsInitPak.
- PFS_ERR_CONTRFAIL - Data transfer to or from the Controller has failed. If a transfer error occurs, up to three tries are done internally, so this error is rarely seen. If it does occur, it is possible that either the Controller is not connected properly, or the Controller Pak or Controller Socket is damaged.
- PFS_ERR_INCONSISTENT - There is a problem in the file system's management area. Usually this error does not occur because osPfsChecker is called internally when you initialize the file system with osPfsInitPak. If this error is returned, either the Controller Pak is not connected properly, or the Controller Pak itself is damaged.
- PFS_ERR_INVALID - There is an error in the parameter which was specified when the function was called, or the specified game note does not exist, or Pfs function was called without initializing using osPfsInitPak. Also, this error could occur when a function for the Controller Pak is executed after the file handle structure pfs is initialized using any other function than the initialization function for this Controller Pak, osPfsInitPak. For example, when osPfsDeleteFile is executed after OSPfs structure is initialized using the initialization function for the Rumble Pak,osMotorInit. If this error is returned, check the process of the game program.
See Also
osContInit
osContStartQuery
osContGetQuery
osPfsAllocateFile
osPfsChecker
osPfsDeleteFile
osPfsFileState
osPfsFindFile
osPfsFreeBlocks
osPfsInitPak
osPfsIsPlug
osPfsReadWriteFile
Revision History
2/1/1999 Revised entirely
|
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
|
|