PSXSDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
psx.h
Go to the documentation of this file.
1 /*
2  * PSXSDK Library include
3  */
4 
5 #ifndef _PSX_H
6 #define _PSX_H
7 
8 #include <stdarg.h>
9 
10 #ifndef true
11 #define true 1
12 #endif
13 
14 #ifndef TRUE
15 #define TRUE 1
16 #endif
17 
18 #ifndef false
19 #define false 0
20 #endif
21 
22 #ifndef FALSE
23 #define FALSE 0
24 #endif
25 
45 #define PSXSDK_VERSION 0x0599
46 
51 #define PSXSDK_VERSION_STRING "0.5.99"
52 
57 #define PSXSDK_VERSION_DATE 0x20150729
58 
59 
60 /*
61  * Include some GCC builtin includes
62  */
63 
64 #ifndef _PSXSDK_WRAPPER
65 
66 #include <psxbios.h>
67 
68 #endif
69 
70 #include <psxgpu.h>
71 #include <memcard.h>
72 
73 #include <psxpad.h>
74 #include <psxspu.h>
75 #include <psxcdrom.h>
76 #include <psxsio.h>
77 //#include <adpcm.h>
78 #include <psxgte.h>
79 
84 extern unsigned char __scratchpad[1024];
85 
91 {
97  COP0_SR = 12,
99  COP0_CAUSE = 13,
101  COP0_EPC = 14,
103  COP0_PRID = 15,
104 };
105 
111 {
113  RCntCNT0 = 0xf2000000,
115  RCntCNT1 = 0xf2000001,
117  RCntCNT2 = 0xf2000002,
119  RCntCNT3 = 0xf2000003,
120 };
121 
127 {
129  RCntIntr = 0x1000,
131  RCntNotar = 0x0100,
133  RCntStop = 0x0010,
135  RCntSC = 0x0001,
136 };
137 
138 struct psx_info
139 {
140  struct kernel
141  {
142  const char *version; // Kernel version
143  int year; // Kernel year
144  int month; // Kernel month
145  int day; // Kernel day
146  }kernel;
147 
148  struct system
149  {
150  int memory; // RAM memory size
151  }system;
152 };
153 
158 void PSX_Init(void);
159 
165 {
172 };
173 
178 void PSX_DeInit(void);
179 
189 void PSX_InitEx(unsigned int flags);
190 
208 void PSX_ReadPad(unsigned short *padbuf, unsigned short *padbuf2);
209 
219 void PSX_PollPad(int pad_num, psx_pad_state *pad_state);
220 
227 void PSX_GetSysInfo(struct psx_info *info);
228 
234 unsigned int get_cop0_status(void);
235 
242 unsigned int set_cop0_status(unsigned int sreg);
243 
250 unsigned int get_cop0_epc(void);
251 
258 unsigned int get_cop0_register(unsigned char register_num);
259 
266 void set_cop0_register(unsigned char register_num, unsigned int value);
267 
275 unsigned int get_cop_register(unsigned char cop_num,
276  unsigned char register_num);
277 
278 
286 unsigned int get_cop_ctrl_register(unsigned char cop_num,
287  unsigned char register_num);
288 
296  void set_cop_register(unsigned char cop_num,
297  unsigned char register_num, unsigned int value);
298 
306  void set_cop_ctrl_register(unsigned char cop_num,
307  unsigned char register_num, unsigned int value);
308 
314 void run_cop_instruction(unsigned char cop_num,
315  unsigned int operation);
316 
317 // Root counter functions
318 
326 int SetRCnt(int spec, unsigned short target, unsigned int mode);
327 
334 int GetRCnt(int spec);
335 
342 int StartRCnt(int spec);
343 
350 int StopRCnt(int spec);
351 
362 int PSX_RestoreBiosState(void);
363 
369 unsigned int PSX_GetInitFlags(void);
370 
384 void SetVBlankHandler(void (*h)());
385 
392 void RemoveVBlankHandler(void);
393 
394 #endif