diff options
| author | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 13:13:14 +0100 |
|---|---|---|
| committer | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 13:13:14 +0100 |
| commit | 78128c8058e6f522c55e7945274926d33183634f (patch) | |
| tree | 728add7839e1abc7c29e085e2076ae968e00b7bf /libpsx/include | |
| parent | 08ca71f289cd63090edea06ce9fe1803c20d799b (diff) | |
| download | psxsdk-78128c8058e6f522c55e7945274926d33183634f.tar.gz | |
Added PSX_PollPad_Fast_Ex() from psxsdk-20150729 fork
Also, added extern "C" on some header files. Some are still missing.
Diffstat (limited to 'libpsx/include')
| -rw-r--r-- | libpsx/include/psx.h | 58 | ||||
| -rw-r--r-- | libpsx/include/psxpad.h | 77 |
2 files changed, 79 insertions, 56 deletions
diff --git a/libpsx/include/psx.h b/libpsx/include/psx.h index 881291b..e972e0c 100644 --- a/libpsx/include/psx.h +++ b/libpsx/include/psx.h @@ -1,12 +1,17 @@ /* * PSXSDK Library include */ - + #ifndef _PSX_H #define _PSX_H #include <stdarg.h> +#ifdef __cplusplus +extern "C" +{ +#endif + #ifndef true #define true 1 #endif @@ -47,7 +52,7 @@ * + 0.5.99 (0x0599) * - PSXSDK 2015-07-29 * + 0.6.00 (0x0600) - * - PSXSDK 2016-06-03 + * - PSXSDK 2016-06-03 * + 0.6.1 (0x0601) * - PSXSDK 2018-01-10 * + 0.6.2 (0x0602) @@ -101,8 +106,8 @@ extern unsigned char __scratchpad[1024]; enum cop0_register_numbers { - /** Contains the last invalid program address which caused a trap. - + /** Contains the last invalid program address which caused a trap. + It is set by address errors of all kinds. */ COP0_BADVADDR = 8, /** CPU mode flags (status register) */ @@ -130,7 +135,7 @@ enum psx_rcnt_specs /** VSync (VBlank) */ RCntCNT3 = 0xf2000003, }; - + /** * Root counter modes */ @@ -156,7 +161,7 @@ struct psx_info int month; // Kernel month int day; // Kernel day }kernel; - + struct system { int memory; // RAM memory size @@ -209,9 +214,9 @@ void PSX_InitEx(unsigned int flags); * This function only supplies basic functionality, adequate for a normal digital pad. * * If more advanced functionality is desired, use PSX_PollPad() instead of this function. - * @attention Note that some joypads, like the official ones from Sony, do not like to be polled more than + * @attention Note that some joypads, like the official ones from Sony, do not like to be polled more than * once every 1/60th of a second and if this limitation is not considered the data - * they return is undefined. Other joypads do not have this limitation but in any case err on the safe side. + * they return is undefined. Other joypads do not have this limitation but in any case err on the safe side. * @param padbuf Pointer to 16-bit variable where bitmask for pad #1 will be stored. * If NULL is passed, this argument is ignored. * @param padbuf2 Pointer to 16-bit variable where bitmask for pad #2 will be stored @@ -219,15 +224,18 @@ void PSX_InitEx(unsigned int flags); */ void PSX_ReadPad(unsigned short *padbuf, unsigned short *padbuf2); +void PSX_PollPad_Fast(int pad_num, psx_pad_state *pad_state); +void PSX_PollPad_Fast_Ex(const unsigned char* const arr, psx_pad_state* const pad_state); + /** * Polls a joypad for information. - * @attention Note that some joypads, like the official ones from Sony, do not like to be polled more than + * @attention Note that some joypads, like the official ones from Sony, do not like to be polled more than * once every 1/60th of a second and if this limitation is not considered the data - * they return is undefined. Other joypads do not have this limitation but in any case err on the safe side. + * they return is undefined. Other joypads do not have this limitation but in any case err on the safe side. * @param pad_num Number of the pad to poll (0 = pad #1, 1 = pad #2, etc.) * @param pad_state Pointer to a psx_pad_state structure in which to store information for the pad. */ - + void PSX_PollPad(int pad_num, psx_pad_state *pad_state); /** @@ -242,7 +250,7 @@ void PSX_GetSysInfo(struct psx_info *info); * Gets Coprocessor 0 status register * @return Value of Coprocessor 0 status register */ - + unsigned int get_cop0_status(void); /** @@ -254,11 +262,11 @@ unsigned int get_cop0_status(void); unsigned int set_cop0_status(unsigned int sreg); /** - * Gets the contents of the program counter when the + * Gets the contents of the program counter when the * last exception happened. * @return Value of the program counter at the time of the last exception */ - + unsigned int get_cop0_epc(void); /** @@ -279,22 +287,22 @@ void set_cop0_register(unsigned char register_num, unsigned int value); /** * Get value of the specified (data) register of a specified coprocessor - * @param cop_num Coprocessor number + * @param cop_num Coprocessor number * @param register_num Number of coprocessor register whose value must be retrieved * @return Value of specified coprocessor register */ - + unsigned int get_cop_register(unsigned char cop_num, unsigned char register_num); /** * Get value of the specified control register of a specified coprocessor - * @param cop_num Coprocessor number + * @param cop_num Coprocessor number * @param register_num Number of coprocessor register whose value must be retrieved * @return Value of specified coprocessor register */ - + unsigned int get_cop_ctrl_register(unsigned char cop_num, unsigned char register_num); @@ -304,7 +312,7 @@ unsigned int get_cop_ctrl_register(unsigned char cop_num, * @param register_num Number of Coprocessor 0 register whose value must be set * @param value New value of specified Coprocessor 0 register */ - + void set_cop_register(unsigned char cop_num, unsigned char register_num, unsigned int value); @@ -314,7 +322,7 @@ unsigned int get_cop_ctrl_register(unsigned char cop_num, * @param register_num Number of Coprocessor 0 register whose value must be set * @param value New value of specified Coprocessor 0 register */ - + void set_cop_ctrl_register(unsigned char cop_num, unsigned char register_num, unsigned int value); @@ -325,7 +333,7 @@ unsigned int get_cop_ctrl_register(unsigned char cop_num, void run_cop_instruction(unsigned char cop_num, unsigned int operation); - + // Root counter functions /** @@ -377,7 +385,7 @@ int PSX_RestoreBiosState(void); * Gets the bitmask for the flags passed to PSX_InitEx() * @return Flag bitmask */ - + unsigned int PSX_GetInitFlags(void); /** @@ -385,7 +393,7 @@ unsigned int PSX_GetInitFlags(void); * Used for simple, inaccurate timing - the handler function gets called 60 times a second * in NTSC video mode and 50 times a second in PAL video mode. * - * While most games use the VBlank interrupt for timing as they don't require high precision and + * While most games use the VBlank interrupt for timing as they don't require high precision and * have mechanisms to keep up with the different speed in PAL or NTSC video mode, for precise * timing VBlank is inadequate. It is better to look at root counters if you desire precision. * @@ -403,4 +411,8 @@ void SetVBlankHandler(void (*h)()); void RemoveVBlankHandler(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/libpsx/include/psxpad.h b/libpsx/include/psxpad.h index 3f96861..ae73d7e 100644 --- a/libpsx/include/psxpad.h +++ b/libpsx/include/psxpad.h @@ -1,6 +1,11 @@ #ifndef _PSXPAD_H
#define _PSXPAD_H
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
/* Pad bits defines. */
#define PAD_LEFT (1<<15)
@@ -41,6 +46,8 @@ enum psx_pad_types PADTYPE_NEGCON, // Namco NeGcon
/** Konami Justifier gun controller. Many third party gun controllers implement this protocol. */
PADTYPE_KONAMIGUN,
+ /** Mouse pad. */
+ PADTYPE_MOUSE,
/** Unknown pad type. */
PADTYPE_UNKNOWN
};
@@ -61,18 +68,18 @@ typedef struct unsigned char type;
/** Button bitmask. To be checked by AND'ing with the defines in
psxpad.h for buttons. If a bit is set for a button, it is pressed.
- Checking the pad type to use this bitmask is not necessary at all,
+ Checking the pad type to use this bitmask is not necessary at all,
and if button emulations are set up, this may not represent the
buttons actually pressed. Also reliable when type is PADTYPE_UNKNOWN */
unsigned short buttons;
-
- /** Extra data for non-normal controllers.
+
+ /** Extra data for non-normal controllers.
You should check the value of the type field before accessing any of this data
*/
-
+
union extra
{
- /** Data for analog joysticks.
+ /** Data for analog joysticks.
* @attention Due to the poor calibration of the analog sticks, it is recommended
* that you do not assume "left" for X values lower than zero and
* "right" for X values higher than zero.
@@ -83,22 +90,22 @@ typedef struct *
* @attention The same is valid for Y values, "up" and "down".
**/
-
+
struct analogJoy
{
- /** X coordinates for the left analog stick and the right analog stick
- * @par Value
+ /** X coordinates for the left analog stick and the right analog stick
+ * @par Value
* Totally left: -128, totally right: 127
*/
signed char x[2];
- /** Y coordinates for the left analog stick and the right analog stick
- * @par Value
+ /** Y coordinates for the left analog stick and the right analog stick
+ * @par Value
* Totally up: -128, totally down: 127
- */
+ */
signed char y[2];
}analogJoy;
-
- /** Data for analog joypads (controller).
+
+ /** Data for analog joypads (controller).
* @attention Due to the poor calibration of the analog sticks, it is recommended
* that you do not assume "left" for X values lower than zero and
* "right" for X values higher than zero.
@@ -109,29 +116,29 @@ typedef struct *
* @attention The same is valid for Y values, "up" and "down".
**/
-
+
struct analogPad
{
- /** X coordinates for the left analog stick and the right analog stick
- * @par Value
+ /** X coordinates for the left analog stick and the right analog stick
+ * @par Value
* Totally left: -128, totally right: 127
*/
signed char x[2];
- /** Y coordinates for the left analog stick and the right analog stick
- * @par Value
+ /** Y coordinates for the left analog stick and the right analog stick
+ * @par Value
* Totally up: -128, totally down: 127
- */
+ */
signed char y[2];
}analogPad;
-
- /** Data for Namco NeGcon and steering wheels using its protocol.
+
+ /** Data for Namco NeGcon and steering wheels using its protocol.
* Many steering wheels use this protocol or can switch to it if desired.
*/
-
+
struct negCon
{
/**
- * Steering wheel position.
+ * Steering wheel position.
*
* Unlike analog sticks, the steering is accurate and this value is reliable.
*
@@ -139,31 +146,31 @@ typedef struct * When steering left it is lower than zero, when steering right it is higher than zero
* and when not steering at all it is zero.
*/
-
+
signed char steering;
-
+
/**
* Pressure for button I (1).
- * @par Value
+ * @par Value
* 0 = not pressed, 255 = maximum pressure
*/
-
+
unsigned char one;
-
+
/**
* Pressure for button II (2).
- * @par Value
+ * @par Value
* 0 = not pressed, 255 = maximum pressure
*/
-
+
unsigned char two;
-
+
/**
* Pressure for "L" shoulder button.
- * @par Value
+ * @par Value
* 0 = not pressed, 255 = maximum pressure
*/
-
+
unsigned char shoulder;
}negCon;
}extra;
@@ -175,4 +182,8 @@ void pad_escape_mode(int pad_n, int enable); void pad_enable_vibration(int pad_n);
void pad_set_vibration(int pad_n, unsigned char small, unsigned char big);
+#ifdef __cplusplus
+}
+#endif
+
#endif
|
