coastline 0.0.4
Loading...
Searching...
No Matches
os_cont.h
Go to the documentation of this file.
1#ifndef PR_OS_CONT_H
2#define PR_OS_CONT_H
3
8
9#include <PR/os.h>
10#include <PR/ultratypes.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
17#define MAXCONTROLLERS 4
18
19/* Bits of OSContStatus.type. */
20#define CONT_ABSOLUTE 0x0001
21#define CONT_RELATIVE 0x0002
22#define CONT_JOYPORT 0x0004
23
24/* Bits of OSContStatus.status. */
25#define CONT_CARD_ON 0x01
26#define CONT_CARD_PULL 0x02
27#define CONT_ADDR_CRC_ER 0x04
28
29/* Results of the Controller Pak routines. */
30#define PFS_ERR_NOPACK 1
31#define PFS_ERR_NEW_PACK 2
32#define PFS_ERR_INCONSISTENT 3
33#define PFS_ERR_CONTRFAIL 4
34#define PFS_ERR_INVALID 5
35#define PFS_ERR_BAD_DATA 6
36#define PFS_DATA_FULL 7
37#define PFS_DIR_FULL 8
38#define PFS_ERR_EXIST 9
39#define PFS_ERR_ID_FATAL 10
40#define PFS_ERR_DEVICE 11
41
42/* Directions of osPfsReadWriteFile(). */
43#define PFS_READ 0
44#define PFS_WRITE 1
45
46/* Bits of OSContPad.button. */
47#define CONT_A 0x8000
48#define CONT_B 0x4000
49#define CONT_G 0x2000
50#define CONT_START 0x1000
51#define CONT_UP 0x0800
52#define CONT_DOWN 0x0400
53#define CONT_LEFT 0x0200
54#define CONT_RIGHT 0x0100
55#define CONT_L 0x0020
56#define CONT_R 0x0010
57#define CONT_E 0x0008
58#define CONT_D 0x0004
59#define CONT_C 0x0002
60#define CONT_F 0x0001
61
62/* The names of the buttons the SDK documents. */
63#define A_BUTTON CONT_A
64#define B_BUTTON CONT_B
65#define L_TRIG CONT_L
66#define R_TRIG CONT_R
67#define Z_TRIG CONT_G
68#define START_BUTTON CONT_START
69#define U_JPAD CONT_UP
70#define L_JPAD CONT_LEFT
71#define R_JPAD CONT_RIGHT
72#define D_JPAD CONT_DOWN
73#define U_CBUTTONS CONT_E
74#define L_CBUTTONS CONT_C
75#define R_CBUTTONS CONT_F
76#define D_CBUTTONS CONT_D
77
79#define CONT_NO_RESPONSE_ERROR 8
80
81/*
82 * The name of the channel error of OSContStatus and OSContPad. The C runtimes of the hosts define
83 * errno as a macro, and the member takes another name there.
84 */
85#if TGR_BOSS_RALLY
87#define CONT_ERRNO errnum
88#else
90#define CONT_ERRNO errno
91#endif
92
93/* Bits of OSPfs.status. */
94#define PFS_INITIALIZED 0x01
95#define PFS_CORRUPTED 0x02
96
105
113
130
139
155s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *data);
156
169
184
196s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern);
197
211s32 osPfsInit(OSMesgQueue *queue, OSPfs *pfs, int channel);
212
227s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, int channel);
228
240
253
270 OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, s32 *file_no);
271
289 OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in_bytes, u8 *data_buffer);
290
302s32 osPfsFreeBlocks(OSPfs *pfs, s32 *bytes_not_used);
303
322 u16 company_code,
323 u32 game_code,
324 u8 *game_name,
325 u8 *ext_name,
326 int file_size_in_bytes,
327 s32 *file_no);
328
341s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used);
342
355s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state);
356
371s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name);
372
386s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel);
387
399
411
412#if TGR_REGION == TGR_REGION_JP || TGR_REGION == TGR_REGION_EU
414#define CONT_EEPROM 0x8000
416#define CONT_EEPROM_BUSY 0x80
418#define EEPROM_MAXBLOCKS 64
420#define EEPROM_BLOCK_SIZE 8
421
431
443s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length);
444
456s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int length);
457
469s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer);
470
482s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer);
483#endif /* TGR_REGION == TGR_REGION_JP || TGR_REGION == TGR_REGION_EU */
484
485#ifdef __cplusplus
486}
487#endif
488
489#endif /* PR_OS_CONT_H */
Public interface of the libultra operating system, as the game links it.
struct OSMesgQueue_s OSMesgQueue
A message queue: a ring of messages and the threads blocked sending or receiving.
s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length)
Read consecutive blocks of the EEPROM, waiting 12 ms after each block.
s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *data)
Wait until the controllers have powered up, then find which are present.
s32 osEepromProbe(OSMesgQueue *mq)
Find whether the cartridge has an EEPROM.
s32 osMotorStart(OSPfs *pfs)
Start the motor of a Rumble Pak.
s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used)
Count the directory entries and the files that use them.
s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name)
Delete a file and free its pages.
s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer)
Read a block of the EEPROM once it is no longer busy.
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 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int length)
Write consecutive blocks of the EEPROM, waiting 12 ms after each block.
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 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 osContStartReadData(OSMesgQueue *mq)
Start reading the buttons and sticks of every controller.
s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer)
Write a block of the EEPROM once it is no longer busy.
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 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 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern)
Find which controllers have a Controller Pak inserted.
s32 osPfsFreeBlocks(OSPfs *pfs, s32 *bytes_not_used)
Return the bytes of the pages no file uses.
s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state)
Report the size, codes and names of a file.
s32 osMotorStop(OSPfs *pfs)
Stop the motor of a Rumble Pak.
s32 osPfsChecker(OSPfs *pfs)
Remove directory entries whose page chains are broken, and rebuild the page tables from the chains th...
void osContGetReadData(OSContPad *data)
Copy the buttons and sticks of the read osContStartReadData() started.
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 ...
s32 osPfsRepairId(OSPfs *pfs)
Read the ID block again, repairing it if needed.
The buttons and stick of a controller.
Definition os_cont.h:107
u16 button
Definition os_cont.h:108
u8 CONT_ERRNO
Definition os_cont.h:111
s8 stick_y
Definition os_cont.h:110
s8 stick_x
Definition os_cont.h:109
What osContInit() learns of a controller.
Definition os_cont.h:98
u8 status
Definition os_cont.h:101
u8 CONT_ERRNO
Definition os_cont.h:103
u16 type
Definition os_cont.h:99
What osPfsFileState() reports of a file.
Definition os_cont.h:132
char ext_name[4]
Definition os_cont.h:136
u16 company_code
Definition os_cont.h:135
char game_name[16]
Definition os_cont.h:137
u32 file_size
Definition os_cont.h:133
u32 game_code
Definition os_cont.h:134
An open Controller Pak.
Definition os_cont.h:115
OSMesgQueue * queue
Definition os_cont.h:117
u8 label[32]
Definition os_cont.h:120
int dir_table
Definition os_cont.h:125
int inode_start_page
Definition os_cont.h:126
int status
Definition os_cont.h:116
u8 activebank
Definition os_cont.h:128
int dir_size
Definition os_cont.h:122
int version
Definition os_cont.h:121
int minode_table
Definition os_cont.h:124
u8 banks
Definition os_cont.h:127
int channel
Definition os_cont.h:118
int inode_table
Definition os_cont.h:123
Integer and floating-point types of libultra.
unsigned int u32
Definition ultratypes.h:20
signed char s8
Definition ultratypes.h:23
unsigned short u16
Definition ultratypes.h:19
int s32
Definition ultratypes.h:25
unsigned char u8
Definition ultratypes.h:18