Creates a new game note
#include <ultra64.h> /* os.h */
s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name,
u8 *ext_name, int length, s32 *file_no);
osPfsAllocateFile creates a new game note (file) in a Controller Pak. The company_code (company code), game_code (game code), game_name (note name), ext_name (note extension), and length (size) arguments must be specified as the information for the game note.
The company_code and game_code are specified as ASCII character strings. The game_name and ext_name are specified by N64 font code.
The size of game_name is PFS_FILE_NAME_LEN(16) bytes. If the size is less than 16 bytes, fill the rest with 0x00. Be sure to make the length 16 bytes.
The size of ext_name is PFS_FILE_EXT_LEN(4) bytes. However, only the first byte is actually used. For this code, use '0' - '9', 'A' ~ 'Z' (0x10~0x33) of N64 font code. The second through fourth bytes are reserved, so use 0x00.
The size is specified by length, in bytes. Since the smallest internal unit is a page (256 bytes), if length is not specified in multiples of 256, the length will be rounded up to the nearest multiple of 256.
The newly created game note's note number (file descriptor) will be returned to file_no. Up to 16 game notes can be created. Therefore, file_no ranges from 0 to 15.
The OSPfs structure pointed to by pfs is the file handle to be initialized by the function osPfsInitPak. Please refer to osPfsInitPak to determine how to create this handle.
If this function is called successfully, 0 is returned. If an error occurs, one of the following error codes is returned:
- 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 osContStartQuery or osContGetQuery.
- A different Controller Pak has been inserted. To use the inserted Controller Pak, initialize it by calling osPfsInitPak.
- 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 by calling osPfsInitPak. If this error is returned, either the Controller Pak is not connected properly, or the Controller Pak itself is damaged.
- Data transfer to or from the Controller has failed. If a transfer error occurs, up to three tries will be done internally. Therefore, it is rather rare to see this error. If this error has returned, it is possible that either the Controller is not connected properly, or the Controller Pak or Controller Socket is damaged.
- If this error is returned, an incorrect argument was specified when this function was called, the specified game note does not exist, or the Pfs function has been called without being initialized using osPfsInitPak. Also, if the functions for the Controller were executed after the file handle structure pfs was initialized by other than osPfsInitPak, this error occurs.For instance, if osPfsAllocateFile is executed after the initialization function for rumble pak osMotorInit is used to initialize OSPfs structure, then this error occurs.
- Although the creation of a new game note was attempted, one could not be created because there was not enough space in the Controller Pak.
- Although the creation of a new game note was attempted, it could not be done because the maximum (16) number of game notes have been stored in the Controller Pak.
- Although the creation of a new game note was attempted, it could not be done because the same game note already exists in the Controller Pak.
osContInit, osContStartQuery, osContGetQuery, osPfsChecker, osPfsDeleteFile, osPfsFileState, osPfsFindFile, osPfsFreeBlocks, osPfsInitPak, osPfsIsPlug, and osPfsReadWriteFile
1999/02/01 Completely revised
1999/04/30 Changed format