Added PSX_PollPad_Fast_Ex() from psxsdk-20150729 fork

Also, added extern "C" on some header files. Some are still  missing.
This commit is contained in:
Xavi Del Campo 2020-01-31 13:13:14 +01:00
parent 08ca71f289
commit 78128c8058
4 changed files with 250 additions and 170 deletions

View File

@ -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

View File

@ -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

View File

@ -53,12 +53,12 @@ void QueryPAD(int pad_n, unsigned char *in, unsigned char *out, int len)
int i;
unsigned char TempData;
int EmuFlag = 0;
PADSIO_MODE(0) = 0xD;
PADSIO_BAUD(0) = 0x88;
if(pad_n == 1) PADSIO_CTRL(0) = 0x3003; else PADSIO_CTRL(0) = 0x1003;
/*Get the initial command (usually 0x01 or 0x81)*/
TempData = *in;
@ -75,7 +75,7 @@ void QueryPAD(int pad_n, unsigned char *in, unsigned char *out, int len)
if(PADSIO_STATUS(0) & 4)break;
}
}
PADSIO_DATA(0) = *in;
in++;
@ -90,48 +90,48 @@ void QueryPAD(int pad_n, unsigned char *in, unsigned char *out, int len)
if(PADSIO_STATUS(0) & 128)break;
}
}
for(i=0;i<100;i++)
{
/*Read RX status flag, required for Xebra*/
if(PADSIO_STATUS(0) & 2)break;
}
}
*out = PADSIO_DATA(0);
/*This is emulator, valid data was received without ACK, ePSXe and PCSX*/
if(x == 0 && y > 1900 && *out != 0xFF)EmuFlag = 1;
out++;
}
PADSIO_CTRL(0) = 0;
}
void pad_read_raw(int pad_n, unsigned char *arr)
{
// arr must be at least 16 bytes long...
unsigned char pad_cmd[PAD_READ_RAW_SIZE] = {1,0x42,0,0,0};
pad_cmd[3] = readpad_vibrations[pad_n][0];
pad_cmd[4] = readpad_vibrations[pad_n][1];
QueryPAD(pad_n, pad_cmd, arr, sizeof(pad_cmd));
}
void pad_escape_mode(int pad_n, int enable)
{
unsigned char pad_cmd[] = {1,0x43,0,enable?1:0,0};
QueryPAD(pad_n, pad_cmd, NULL, sizeof(pad_cmd));
}
void pad_enable_vibration(int pad_n)
{
unsigned char pad_cmd[] = {1, 0x4d, 0, 0, 1, 0xff, 0xff, 0xff, 0xff};
pad_escape_mode(pad_n, 1); // Enter escape / configuration mode
QueryPAD(pad_n, pad_cmd, NULL, sizeof(pad_cmd));
pad_escape_mode(pad_n, 0); // Exit escape / configuration mode
@ -154,10 +154,10 @@ void pad_set_analog(int pad_n, int lock)
{1, 0x44, 0, 1, lock?3:0, 0, 0, 0, 0};
unsigned char pad_cmd2[9] =
{1, 0x4f, 0, 0xff, 0xff, 3, 0, 0, 0};
pad_escape_mode(pad_n, 1);
QueryPAD(pad_n, pad_cmd, NULL, sizeof(pad_cmd));
QueryPAD(pad_n, pad_cmd2, NULL, sizeof(pad_cmd));
QueryPAD(pad_n, pad_cmd2, NULL, sizeof(pad_cmd));
pad_escape_mode(pad_n, 0);
}*/

View File

@ -3,7 +3,7 @@
*
* Free and open source library to develop for the Sony PlayStation
*/
#include <psx.h>
#include <stdio.h>
#include <stdlib.h>
@ -25,8 +25,8 @@ extern int *rcnt_handler();
(unsigned int)vblank_handler, // func2
0x0, // pad
};*/
static int vblank_handler_set = 0;
static int vblank_handler_set = 0;
static unsigned int vblank_handler_event_id = 0;
static int rcnt_handler_set = 0;
@ -37,7 +37,7 @@ void _internal_cdromlib_init(void);
static unsigned int psxSdkFlags = 0;
static unsigned char *psxBiosState;
static unsigned char *psxBiosState;
extern void _96_remove(void);
extern void _96_init(void);
@ -46,40 +46,40 @@ extern void StartCARD(void);
extern void StopCARD(void);
extern void _bu_init(void);
extern void BIOSWarmReboot(void);
void PSX_InitEx(unsigned int flags)
{
{
if(flags & PSX_INIT_NOBIOS)
{
printf("Entering No BIOS mode...\n");
__PSX_Init_NoBios();
goto _initex_end;
}
if(flags & PSX_INIT_SAVESTATE)
{
// Save BIOS state
// This simply copies the entire section of RAM used by the BIOS
// in a buffer.
// in a buffer.
EnterCriticalSection();
psxBiosState = malloc(0x10000);
memcpy(psxBiosState, (void*)0x80000000, 0x10000);
ExitCriticalSection();
}
/* Reinitialize ISO 9660 filesystem driver */
if(flags & PSX_INIT_CD)
{
EnterCriticalSection();
_96_remove();
ExitCriticalSection();
_96_init();
}
/*This is needed, otherwise PSX will crash when VBlank handler is set*/
/*InitCARD(1);
StartCARD();
@ -89,7 +89,7 @@ void PSX_InitEx(unsigned int flags)
_internal_cdromlib_init();
printf("PSXSDK testing version !!!\n");
vblank_handler_set = 0;
_initex_end:
psxSdkFlags = flags;
@ -108,9 +108,9 @@ void PSX_DeInit(void)
_96_remove();
ExitCriticalSection();
}
RemoveVBlankHandler();
if(psxSdkFlags & PSX_INIT_SAVESTATE)// This must always be the last to be called!
PSX_RestoreBiosState();
}
@ -120,15 +120,15 @@ void PSX_ReadPad(unsigned short *padbuf, unsigned short *padbuf2)
int x;
unsigned char arr[PAD_READ_RAW_SIZE];
unsigned short *padbuf_a[2];
// Now uses low level pad routines...
// Now uses low level pad routines...
padbuf_a[0] = padbuf;
padbuf_a[1] = padbuf2;
for(x = 0; x < 2; x++)
{
pad_read_raw(x, arr);
if(arr[2] == 0x5a)
{
*padbuf_a[x] = (arr[3]<<8)|arr[4];
@ -139,21 +139,78 @@ void PSX_ReadPad(unsigned short *padbuf, unsigned short *padbuf2)
}
}
unsigned char psxsdkPadArr[PAD_READ_RAW_SIZE];
unsigned char psxsdkPadArr[PAD_READ_RAW_SIZE][2];
void PSX_PollPad_Fast_Ex(const unsigned char* const arr, psx_pad_state* const pad_state)
{
//Rely on pad_read_raw being called AFTER PSX_ReadPad(),
//so that pad_read_raw is only called once.
pad_state->status = arr[0];
pad_state->id = arr[1];
pad_state->buttons = (arr[3]<<8)|arr[4];
pad_state->buttons = ~pad_state->buttons;
//dprintf("Pad Status: 0x%.2X\n",pad_state->status);
switch(pad_state->id)
{
case 0xFF:
pad_state->type = PADTYPE_NONE;
break;
case 0x41:
pad_state->type = PADTYPE_NORMALPAD;
break;
case 0x53:
pad_state->type = PADTYPE_ANALOGJOY;
pad_state->extra.analogJoy.x[0] = arr[5]-128;
pad_state->extra.analogJoy.y[0] = arr[6]-128;
pad_state->extra.analogJoy.x[1] = arr[7]-128;
pad_state->extra.analogJoy.y[1] = arr[8]-128;
break;
case 0x73:
pad_state->type = PADTYPE_ANALOGPAD;
pad_state->extra.analogPad.x[0] = arr[5]-128;
pad_state->extra.analogPad.y[0] = arr[6]-128;
pad_state->extra.analogPad.x[1] = arr[7]-128;
pad_state->extra.analogPad.y[1] = arr[8]-128;
break;
case 0x23:
pad_state->type = PADTYPE_NEGCON;
pad_state->extra.negCon.steering = arr[5]-128;
pad_state->extra.negCon.one = arr[6];
pad_state->extra.negCon.two = arr[7];
pad_state->extra.negCon.shoulder = arr[8];
break;
case 0x31:
pad_state->type = PADTYPE_KONAMIGUN;
break;
case 0x12:
pad_state->type = PADTYPE_MOUSE;
break;
default:
pad_state->type = PADTYPE_UNKNOWN;
}
}
void PSX_PollPad_Fast(int pad_num, psx_pad_state *pad_state)
{
PSX_PollPad_Fast_Ex(psxsdkPadArr[pad_num], pad_state);
}
void PSX_PollPad(int pad_num, psx_pad_state *pad_state)
{
// int x;
/*unsigned short *padbuf_a[2];
// Now uses low level pad routines...
// Now uses low level pad routines...
padbuf_a[0] = padbuf;
padbuf_a[1] = padbuf2;
for(x = 0; x < 2; x++)
{
pad_read_raw(x, arr);
if(arr[2] == 0x5a)
{
*padbuf_a[x] = (arr[3]<<8)|arr[4];
@ -162,17 +219,17 @@ void PSX_PollPad(int pad_num, psx_pad_state *pad_state)
else
*padbuf_a[x] = 0;
}*/
unsigned char *arr = psxsdkPadArr;
unsigned char *arr = psxsdkPadArr[pad_num];
pad_read_raw(pad_num, arr);
pad_state->status = arr[0];
pad_state->id = arr[1];
pad_state->buttons = (arr[3]<<8)|arr[4];
pad_state->buttons = ~pad_state->buttons;
switch(pad_state->id)
{
case 0xFF:
@ -211,10 +268,10 @@ void PSX_PollPad(int pad_num, psx_pad_state *pad_state)
}
/*int PSX_GetPadType(unsigned int pad_num)
//{
//{
//#warning "Function does not currently work!"
// unsigned char arr[16];
pad_read_raw(pad_num, arr);
switch(arr[1])
@ -232,7 +289,7 @@ void PSX_PollPad(int pad_num, psx_pad_state *pad_state)
return PADTYPE_ANALOGPAD;
break;
}
return PADTYPE_UNKNOWN;
}*/
@ -242,33 +299,33 @@ void PSX_GetSysInfo(struct psx_info *info)
unsigned long i,i2;
info->kernel.version = GetKernelRomVersion();
i = GetKernelDate();
/*
* Convert year from BCD to decimal
*/
i2 = i >> 16;
info->kernel.year = i2 & 0xf;
info->kernel.year+= ((i2>>4)&0xf)*10;
info->kernel.year+= ((i2>>8)&0xf)*100;
info->kernel.year+= ((i2>>12)&0xf)*1000;
/*
* Convert month from BCD to decimal
*/
i2 = (i >> 8) & 0xff;
info->kernel.month = i2 & 0xf;
info->kernel.month+= (i2>>4) * 10;
info->kernel.month+= (i2>>4) * 10;
/*
* Convert day from BCD to decimal
*/
i2 = i & 0xff;
info->kernel.day = i2 & 0xf;
info->kernel.day+= (i2>>4) * 10;
@ -276,21 +333,21 @@ void PSX_GetSysInfo(struct psx_info *info)
* Unless we receive something in the range >= 1 && <= 16,
* RAM size will be reported as 2 Megabytes
*/
i = GetRamSize();
if(i == 0 || i > 16)
info->system.memory = 2<<20; /* 2 Megabytes */
else
info->system.memory <<= 20;
}
int get_real_file_size(const char *name)
{
struct DIRENTRY dirent_buf;
if(firstfile(name, &dirent_buf) == &dirent_buf)
return dirent_buf.size;
else
@ -300,7 +357,7 @@ int get_real_file_size(const char *name)
int get_file_size(const char *name)
{
int i = get_real_file_size(name);
if(strncmp(name, "cdrom:", 6) == 0)
{
if(i & 0x7ff)
@ -316,58 +373,58 @@ int get_file_size(const char *name)
i &= ~0x7f;
}
}
return i;
}
int SetRCnt(int spec, unsigned short target, unsigned int mode)
{
spec &= 0xf;
if(spec >= 3)
return 0;
RCNT_MODE(spec)=0;
RCNT_TARGET(spec)=target;
RCNT_MODE(spec)=mode;
return 1;
}
int GetRCnt(int spec)
{
spec &= 0xf;
if(spec >= 4)
return -1;
return (RCNT_COUNT(spec) & 0xffff);
}
int StartRCnt(int spec)
{
spec &= 0xf;
if(spec >= 3)
return 0;
IMASK |= 1 << (spec + 4);
return 1;
}
int StopRCnt(int spec)
{
spec &= 0xf;
if(spec >= 3)
return 0;
IMASK ^= 1 << (spec + 4);
return 1;
}
void SetVBlankHandler(void (*callback)())
{
if(psxSdkFlags & PSX_INIT_NOBIOS)
@ -377,32 +434,32 @@ void SetVBlankHandler(void (*callback)())
_EXC_vblank_handler_set = 1;
return;
}
if(vblank_handler_set == 1)
{
EnterCriticalSection();
vblank_handler_callback = callback;
ExitCriticalSection();
return;
}
// Enter critical section
EnterCriticalSection();
IMASK|=1;
vblank_handler_event_id = OpenEvent(RCntCNT3, 2, 0x1000, vblank_handler);
EnableEvent(vblank_handler_event_id);
vblank_handler_callback = callback;
vblank_handler_set = 1;
// Exit critical section
ExitCriticalSection();
}
@ -414,19 +471,19 @@ void RemoveVBlankHandler(void)
_EXC_vblank_handler = NULL;
return;
}
if(vblank_handler_set)
{
EnterCriticalSection();
DisableEvent(vblank_handler_event_id);
CloseEvent(vblank_handler_event_id);
//IMASK^=1;
// ^ commented because masking out vblank could give problems to other bios functions
vblank_handler_set = 0;
ExitCriticalSection();
}
}
@ -435,27 +492,27 @@ void SetRCntHandler(void (*callback)(), int spec, unsigned short target)
{
if(psxSdkFlags & PSX_INIT_NOBIOS)
return; // Not yet supported in No-Bios Mode
if(rcnt_handler_set)
{
EnterCriticalSection();
rcnt_handler_callback = callback;
ExitCriticalSection();
return;
}
// Enter critical section
SetRCnt(spec, target, RCntIntr | 0x08 | 0x10 | 0x40);
StartRCnt(spec);
EnterCriticalSection();
rcnt_handler_event_id = OpenEvent(spec, 2, 0x1000, rcnt_handler);
EnableEvent(rcnt_handler_event_id);
rcnt_handler_callback = callback;
rcnt_handler_set = spec;
@ -466,9 +523,9 @@ void SetRCntHandler(void (*callback)(), int spec, unsigned short target)
case RCntCNT2: rcnt_handler_evfield = 1 << 6; break;
case RCntCNT3: rcnt_handler_evfield = 1; break;
}
// Exit critical section
ExitCriticalSection();
}
@ -476,16 +533,16 @@ void RemoveRCntHandler(int spec)
{
if(psxSdkFlags & PSX_INIT_NOBIOS)
return; // Not yet supported in No-Bios Mode
if(rcnt_handler_set)
{
EnterCriticalSection();
DisableEvent(rcnt_handler_event_id);
CloseEvent(rcnt_handler_event_id);
rcnt_handler_set = 0;
ExitCriticalSection();
}
}
@ -496,13 +553,13 @@ const char *GetSystemRomVersion(void)
// most PlayStation BIOSes.
// If getting the pointer is not possible, a pointer to a string saying "System ROM Unavailable" is returned.
int x;
for(x = 0x7ffee; x >= 0; x--)
if(memcmp("System ROM Version", (void*)(0xbfc00000 + x), 18) == 0)
return (char*)(0xbfc00000 + x);
return sysromver_unavail;
}
@ -510,11 +567,11 @@ int PSX_RestoreBiosState(void)
{
if(!(psxSdkFlags & PSX_INIT_SAVESTATE))
return 0; // can't restore BIOS state if it was not saved previously
EnterCriticalSection();
memcpy((void*)0x80000000, psxBiosState, 0x10000);
ExitCriticalSection();
return 1;
}
@ -535,8 +592,8 @@ psx_warmreboot_nobios:
else
{
if(!(psxSdkFlags & PSX_INIT_CD))
goto psx_warmreboot_nobios;
goto psx_warmreboot_nobios;
BIOSWarmReboot();
}
}