|
coastline 0.0.4
|
The controllers and the Controller Pak file system. More...


Go to the source code of this file.
Classes | |
| struct | OSContStatus |
| What osContInit() learns of a controller. More... | |
| struct | OSContPad |
| The buttons and stick of a controller. More... | |
| struct | OSPfs |
| An open Controller Pak. More... | |
| struct | OSPfsState |
| What osPfsFileState() reports of a file. More... | |
Macros | |
| #define | MAXCONTROLLERS 4 |
| The ports of the console. | |
| #define | CONT_ABSOLUTE 0x0001 |
| #define | CONT_RELATIVE 0x0002 |
| #define | CONT_JOYPORT 0x0004 |
| #define | CONT_CARD_ON 0x01 |
| #define | CONT_CARD_PULL 0x02 |
| #define | CONT_ADDR_CRC_ER 0x04 |
| #define | PFS_ERR_NOPACK 1 |
| #define | PFS_ERR_NEW_PACK 2 |
| #define | PFS_ERR_INCONSISTENT 3 |
| #define | PFS_ERR_CONTRFAIL 4 |
| #define | PFS_ERR_INVALID 5 |
| #define | PFS_ERR_BAD_DATA 6 |
| #define | PFS_DATA_FULL 7 |
| #define | PFS_DIR_FULL 8 |
| #define | PFS_ERR_EXIST 9 |
| #define | PFS_ERR_ID_FATAL 10 |
| #define | PFS_ERR_DEVICE 11 |
| #define | PFS_READ 0 |
| #define | PFS_WRITE 1 |
| #define | CONT_A 0x8000 |
| #define | CONT_B 0x4000 |
| #define | CONT_G 0x2000 |
| #define | CONT_START 0x1000 |
| #define | CONT_UP 0x0800 |
| #define | CONT_DOWN 0x0400 |
| #define | CONT_LEFT 0x0200 |
| #define | CONT_RIGHT 0x0100 |
| #define | CONT_L 0x0020 |
| #define | CONT_R 0x0010 |
| #define | CONT_E 0x0008 |
| #define | CONT_D 0x0004 |
| #define | CONT_C 0x0002 |
| #define | CONT_F 0x0001 |
| #define | A_BUTTON CONT_A |
| #define | B_BUTTON CONT_B |
| #define | L_TRIG CONT_L |
| #define | R_TRIG CONT_R |
| #define | Z_TRIG CONT_G |
| #define | START_BUTTON CONT_START |
| #define | U_JPAD CONT_UP |
| #define | L_JPAD CONT_LEFT |
| #define | R_JPAD CONT_RIGHT |
| #define | D_JPAD CONT_DOWN |
| #define | U_CBUTTONS CONT_E |
| #define | L_CBUTTONS CONT_C |
| #define | R_CBUTTONS CONT_F |
| #define | D_CBUTTONS CONT_D |
| #define | CONT_NO_RESPONSE_ERROR 8 |
| OSContPad.errno of a controller that does not respond. | |
| #define | CONT_ERRNO errno |
| Select the Nintendo 64 controller channel-error member. | |
| #define | PFS_INITIALIZED 0x01 |
| #define | PFS_CORRUPTED 0x02 |
| #define | CONT_EEPROM 0x8000 |
| The device type a 4 Kbit EEPROM reports. | |
| #define | CONT_EEPROM_BUSY 0x80 |
| The status bit of an EEPROM that is still writing. | |
| #define | EEPROM_MAXBLOCKS 64 |
| The highest block address of the EEPROM routines accept. | |
| #define | EEPROM_BLOCK_SIZE 8 |
| The bytes of a block of the EEPROM. | |
Functions | |
| s32 | osContInit (OSMesgQueue *mq, u8 *bitpattern, OSContStatus *data) |
| Wait until the controllers have powered up, then find which are present. | |
| s32 | osContStartReadData (OSMesgQueue *mq) |
| Start reading the buttons and sticks of every controller. | |
| void | osContGetReadData (OSContPad *data) |
| Copy the buttons and sticks of the read osContStartReadData() started. | |
| s32 | osPfsIsPlug (OSMesgQueue *queue, u8 *pattern) |
| Find which controllers have a Controller Pak inserted. | |
| s32 | osPfsInit (OSMesgQueue *queue, OSPfs *pfs, int channel) |
| Open the Controller Pak of a channel, repairing its ID if needed, and check its file system. | |
| s32 | osPfsInitPak (OSMesgQueue *queue, OSPfs *pfs, int channel) |
| Open the Controller Pak of a channel like osPfsInit(), starting from the ID checksum of the caller's stack. | |
| s32 | osPfsRepairId (OSPfs *pfs) |
| Read the ID block again, repairing it if needed. | |
| s32 | osPfsChecker (OSPfs *pfs) |
| Remove directory entries whose page chains are broken, and rebuild the page tables from the chains that remain. | |
| s32 | osPfsFindFile (OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, s32 *file_no) |
| Find a file by its codes, and by its names unless they are NULL. | |
| s32 | osPfsReadWriteFile (OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in_bytes, u8 *data_buffer) |
| Read or write whole blocks of a file. | |
| s32 | osPfsFreeBlocks (OSPfs *pfs, s32 *bytes_not_used) |
| Return the bytes of the pages no file uses. | |
| s32 | osPfsAllocateFile (OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, int file_size_in_bytes, s32 *file_no) |
| Create a file of at least the given size. | |
| s32 | osPfsNumFiles (OSPfs *pfs, s32 *max_files, s32 *files_used) |
| Count the directory entries and the files that use them. | |
| s32 | osPfsFileState (OSPfs *pfs, s32 file_no, OSPfsState *state) |
| Report the size, codes and names of a file. | |
| s32 | osPfsDeleteFile (OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name) |
| Delete a file and free its pages. | |
| s32 | osMotorInit (OSMesgQueue *mq, OSPfs *pfs, int channel) |
| Open the Rumble Pak of a channel and build the commands that start and stop its motor. | |
| s32 | osMotorStart (OSPfs *pfs) |
| Start the motor of a Rumble Pak. | |
| s32 | osMotorStop (OSPfs *pfs) |
| Stop the motor of a Rumble Pak. | |
| s32 | osEepromProbe (OSMesgQueue *mq) |
| Find whether the cartridge has an EEPROM. | |
| s32 | osEepromLongRead (OSMesgQueue *mq, u8 address, u8 *buffer, int length) |
| Read consecutive blocks of the EEPROM, waiting 12 ms after each block. | |
| s32 | osEepromLongWrite (OSMesgQueue *mq, u8 address, u8 *buffer, int length) |
| Write consecutive blocks of the EEPROM, waiting 12 ms after each block. | |
| s32 | osEepromWrite (OSMesgQueue *mq, u8 address, u8 *buffer) |
| Write a block of the EEPROM once it is no longer busy. | |
| s32 | osEepromRead (OSMesgQueue *mq, u8 address, u8 *buffer) |
| Read a block of the EEPROM once it is no longer busy. | |
The controllers and the Controller Pak file system.
| #define MAXCONTROLLERS 4 |
The ports of the console.
| #define CONT_ABSOLUTE 0x0001 |
The device reports absolute positions, as a controller does.
| #define CONT_RELATIVE 0x0002 |
The device reports relative movement, as a mouse does.
| #define CONT_JOYPORT 0x0004 |
The device has a port for a Pak.
| #define CONT_CARD_ON 0x01 |
A Pak is plugged in.
| #define CONT_CARD_PULL 0x02 |
A Pak was pulled out since the last check.
| #define CONT_ADDR_CRC_ER 0x04 |
The CRC of the last address was wrong.
| #define PFS_ERR_NOPACK 1 |
No Pak is plugged in.
| #define PFS_ERR_NEW_PACK 2 |
The Pak was changed.
| #define PFS_ERR_INCONSISTENT 3 |
The file system needs repair.
| #define PFS_ERR_CONTRFAIL 4 |
The transfer with the controller failed.
| #define PFS_ERR_INVALID 5 |
An argument is invalid or the file does not exist.
| #define PFS_ERR_BAD_DATA 6 |
The data read is wrong.
| #define PFS_DATA_FULL 7 |
No pages are free.
| #define PFS_DIR_FULL 8 |
No entries of the directory are free.
| #define PFS_ERR_EXIST 9 |
The file already exists.
| #define PFS_ERR_ID_FATAL 10 |
The identity area cannot be repaired.
| #define PFS_ERR_DEVICE 11 |
The Pak is not a Controller Pak.
| #define PFS_READ 0 |
Read from the file.
| #define PFS_WRITE 1 |
Write to the file.
| #define CONT_A 0x8000 |
The A button.
| #define CONT_B 0x4000 |
The B button.
| #define CONT_G 0x2000 |
The Z trigger.
| #define CONT_START 0x1000 |
The Start button.
| #define CONT_UP 0x0800 |
Up on the directional pad.
| #define CONT_DOWN 0x0400 |
Down on the directional pad.
| #define CONT_LEFT 0x0200 |
Left on the directional pad.
| #define CONT_RIGHT 0x0100 |
Right on the directional pad.
| #define CONT_L 0x0020 |
The L trigger.
| #define CONT_R 0x0010 |
The R trigger.
| #define CONT_E 0x0008 |
The up C button.
| #define CONT_D 0x0004 |
The down C button.
| #define CONT_C 0x0002 |
The left C button.
| #define CONT_F 0x0001 |
The right C button.
| #define A_BUTTON CONT_A |
The A button.
| #define B_BUTTON CONT_B |
The B button.
| #define L_TRIG CONT_L |
The L trigger.
| #define R_TRIG CONT_R |
The R trigger.
| #define Z_TRIG CONT_G |
The Z trigger.
| #define START_BUTTON CONT_START |
The Start button.
| #define U_JPAD CONT_UP |
Up on the directional pad.
| #define L_JPAD CONT_LEFT |
Left on the directional pad.
| #define R_JPAD CONT_RIGHT |
Right on the directional pad.
| #define D_JPAD CONT_DOWN |
Down on the directional pad.
| #define U_CBUTTONS CONT_E |
The up C button.
| #define L_CBUTTONS CONT_C |
The left C button.
| #define R_CBUTTONS CONT_F |
The right C button.
| #define D_CBUTTONS CONT_D |
The down C button.
| #define CONT_NO_RESPONSE_ERROR 8 |
OSContPad.errno of a controller that does not respond.
| #define CONT_ERRNO errno |
Select the Nintendo 64 controller channel-error member.
| #define PFS_INITIALIZED 0x01 |
The file system was initialised.
| #define PFS_CORRUPTED 0x02 |
The file system is corrupted.
| #define CONT_EEPROM 0x8000 |
The device type a 4 Kbit EEPROM reports.
| #define CONT_EEPROM_BUSY 0x80 |
The status bit of an EEPROM that is still writing.
| #define EEPROM_MAXBLOCKS 64 |
The highest block address of the EEPROM routines accept.
| #define EEPROM_BLOCK_SIZE 8 |
The bytes of a block of the EEPROM.
| s32 osContInit | ( | OSMesgQueue * | mq, |
| u8 * | bitpattern, | ||
| OSContStatus * | data ) |
Wait until the controllers have powered up, then find which are present.
Windows returns 1 without changing the output arguments.
| mq | The queue of SI events, registered with osSetEventMesg() for OS_EVENT_SI. |
| bitpattern | Receives a bit for each controller that answered. |
| data | Receives the status of each of the MAXCONTROLLERS controllers. |
| s32 osContStartReadData | ( | OSMesgQueue * | mq | ) |
Start reading the buttons and sticks of every controller.
| mq | The queue of SI events. The routine blocks on it only when the read command must be written first, and the caller waits on it for the end of the read. |
| void osContGetReadData | ( | OSContPad * | data | ) |
Copy the buttons and sticks of the read osContStartReadData() started.
On Windows, update only the first pad and preserve its error byte.
| data | Receives the pad of each of the MAXCONTROLLERS controllers. A pad with a nonzero errno is not otherwise written. |
| s32 osPfsIsPlug | ( | OSMesgQueue * | queue, |
| u8 * | pattern ) |
Find which controllers have a Controller Pak inserted.
| queue | The queue of SI events, blocked on for each transfer. |
| pattern | Receives a bit for each controller with a Pak. |
| s32 osPfsInit | ( | OSMesgQueue * | queue, |
| OSPfs * | pfs, | ||
| int | channel ) |
Open the Controller Pak of a channel, repairing its ID if needed, and check its file system.
| queue | The queue of SI events, blocked on for each transfer. |
| pfs | Receives the description of the open Pak. |
| channel | The controller port, 0 to 3. |
| s32 osPfsInitPak | ( | OSMesgQueue * | queue, |
| OSPfs * | pfs, | ||
| int | channel ) |
Open the Controller Pak of a channel like osPfsInit(), starting from the ID checksum of the caller's stack.
| queue | The queue of SI events, blocked on for each transfer. |
| pfs | Receives the description of the open Pak. |
| channel | The controller port, 0 to 3. |
Read the ID block again, repairing it if needed.
| pfs | The open Pak, updated with the ID, the geometry, and the label. |
Remove directory entries whose page chains are broken, and rebuild the page tables from the chains that remain.
| pfs | The open Pak. PFS_CORRUPTED in its status is set when the check finds damage. |
| s32 osPfsFindFile | ( | OSPfs * | pfs, |
| u16 | company_code, | ||
| u32 | game_code, | ||
| u8 * | game_name, | ||
| u8 * | ext_name, | ||
| s32 * | file_no ) |
Find a file by its codes, and by its names unless they are NULL.
| pfs | The open Pak. |
| company_code | The company code of the file. |
| game_code | The game code of the file. |
| game_name | The 16-byte file name in the Pak character set, or NULL to match every name. |
| ext_name | The 4-byte extension in the Pak character set, or NULL to match every one. |
| file_no | Receives the directory index, or -1. |
| s32 osPfsReadWriteFile | ( | OSPfs * | pfs, |
| s32 | file_no, | ||
| u8 | flag, | ||
| int | offset, | ||
| int | size_in_bytes, | ||
| u8 * | data_buffer ) |
Read or write whole blocks of a file.
| pfs | The open Pak. |
| file_no | The directory index of the file. |
| flag | PFS_READ or PFS_WRITE. |
| offset | The byte offset in the file, a multiple of 32. |
| size_in_bytes | The count of bytes, a positive multiple of 32. |
| data_buffer | The buffer read into or written from. |
Return the bytes of the pages no file uses.
| pfs | The open Pak. |
| bytes_not_used | Receives the free space in bytes, a multiple of 256. |
| s32 osPfsAllocateFile | ( | OSPfs * | pfs, |
| u16 | company_code, | ||
| u32 | game_code, | ||
| u8 * | game_name, | ||
| u8 * | ext_name, | ||
| int | file_size_in_bytes, | ||
| s32 * | file_no ) |
Create a file of at least the given size.
| pfs | The open Pak. |
| company_code | The company code of the file, not 0. |
| game_code | The game code of the file, not 0. |
| game_name | The 16-byte file name in the Pak character set. |
| ext_name | The 4-byte extension in the Pak character set. |
| file_size_in_bytes | The size of the file, rounded up to a whole page of 256 bytes. |
| file_no | Receives the directory index of the new file. |
Count the directory entries and the files that use them.
| pfs | The open Pak. |
| max_files | Receives the number of directory entries. |
| files_used | Receives the number of entries with nonzero codes. |
| s32 osPfsFileState | ( | OSPfs * | pfs, |
| s32 | file_no, | ||
| OSPfsState * | state ) |
Report the size, codes and names of a file.
| pfs | The open Pak. |
| file_no | The directory index of the file. |
| state | Receives the size, codes, and names of the file. |
Delete a file and free its pages.
| pfs | The open Pak. |
| company_code | The company code of the file, not 0. |
| game_code | The game code of the file, not 0. |
| game_name | The 16-byte file name in the Pak character set. |
| ext_name | The 4-byte extension in the Pak character set. |
| s32 osMotorInit | ( | OSMesgQueue * | mq, |
| OSPfs * | pfs, | ||
| int | channel ) |
Open the Rumble Pak of a channel and build the commands that start and stop its motor.
| mq | The queue of SI events, blocked on for each transfer. |
| pfs | Receives the description of the Rumble Pak. |
| channel | The controller port, 0 to 3. |
Start the motor of a Rumble Pak.
| pfs | The Rumble Pak osMotorInit() opened. |
Stop the motor of a Rumble Pak.
| pfs | The Rumble Pak osMotorInit() opened. |
| s32 osEepromProbe | ( | OSMesgQueue * | mq | ) |
Find whether the cartridge has an EEPROM.
| mq | The queue of SI events, blocked on for each transfer. |
| s32 osEepromLongRead | ( | OSMesgQueue * | mq, |
| u8 | address, | ||
| u8 * | buffer, | ||
| int | length ) |
Read consecutive blocks of the EEPROM, waiting 12 ms after each block.
| mq | The queue of SI events, blocked on for each transfer. |
| address | The first block, at most EEPROM_MAXBLOCKS. |
| buffer | Receives the blocks. |
| length | The bytes to read, a multiple of EEPROM_BLOCK_SIZE. |
| s32 osEepromLongWrite | ( | OSMesgQueue * | mq, |
| u8 | address, | ||
| u8 * | buffer, | ||
| int | length ) |
Write consecutive blocks of the EEPROM, waiting 12 ms after each block.
| mq | The queue of SI events, blocked on for each transfer. |
| address | The first block, at most EEPROM_MAXBLOCKS. |
| buffer | The blocks to write. |
| length | The bytes to write, a multiple of EEPROM_BLOCK_SIZE. |
| s32 osEepromWrite | ( | OSMesgQueue * | mq, |
| u8 | address, | ||
| u8 * | buffer ) |
Write a block of the EEPROM once it is no longer busy.
| mq | The queue of SI events, blocked on for each transfer. |
| address | The block, at most EEPROM_MAXBLOCKS. |
| buffer | The EEPROM_BLOCK_SIZE bytes to write. |
| s32 osEepromRead | ( | OSMesgQueue * | mq, |
| u8 | address, | ||
| u8 * | buffer ) |
Read a block of the EEPROM once it is no longer busy.
| mq | The queue of SI events, blocked on for each transfer. |
| address | The block, at most EEPROM_MAXBLOCKS. |
| buffer | Receives the EEPROM_BLOCK_SIZE bytes, written only without an error. |