psx - lag logic
This commit is contained in:
parent
fdc290cc14
commit
b129eab0f9
|
@ -347,11 +347,11 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[FeatureNotImplemented]
|
|
||||||
public void ResetCounters()
|
public void ResetCounters()
|
||||||
{
|
{
|
||||||
// FIXME when all this stuff is implemented
|
|
||||||
Frame = 0;
|
Frame = 0;
|
||||||
|
LagCount = 0;
|
||||||
|
IsLagFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetInput()
|
void SetInput()
|
||||||
|
@ -513,6 +513,15 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
||||||
OctoshockDll.shock_Step(psx, OctoshockDll.eShockStep.Frame);
|
OctoshockDll.shock_Step(psx, OctoshockDll.eShockStep.Frame);
|
||||||
//------------------------
|
//------------------------
|
||||||
|
|
||||||
|
//lag maintenance:
|
||||||
|
int pad1 = OctoshockDll.shock_Peripheral_PollActive(psx, 0x01, true);
|
||||||
|
int pad2 = OctoshockDll.shock_Peripheral_PollActive(psx, 0x02, true);
|
||||||
|
IsLagFrame = true;
|
||||||
|
if (pad1 == OctoshockDll.SHOCK_TRUE) IsLagFrame = false;
|
||||||
|
if (pad2 == OctoshockDll.SHOCK_TRUE) IsLagFrame = false;
|
||||||
|
if (IsLagFrame)
|
||||||
|
LagCount++;
|
||||||
|
|
||||||
//what happens to sound in this case?
|
//what happens to sound in this case?
|
||||||
if (render == false) return;
|
if (render == false) return;
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
||||||
[DllImport(dd, CallingConvention = cc)]
|
[DllImport(dd, CallingConvention = cc)]
|
||||||
public static extern int shock_Peripheral_MemcardTransact(IntPtr psx, int address, ref ShockMemcardTransaction transaction);
|
public static extern int shock_Peripheral_MemcardTransact(IntPtr psx, int address, ref ShockMemcardTransaction transaction);
|
||||||
|
|
||||||
|
[DllImport(dd, CallingConvention = cc)]
|
||||||
|
public static extern int shock_Peripheral_PollActive(IntPtr psx, int address, bool clear);
|
||||||
|
|
||||||
[DllImport(dd, CallingConvention = cc)]
|
[DllImport(dd, CallingConvention = cc)]
|
||||||
public static extern int shock_MountEXE(IntPtr psx, void* exebuf, int size);
|
public static extern int shock_MountEXE(IntPtr psx, void* exebuf, int size);
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -39,7 +39,9 @@
|
||||||
<ClCompile Include="..\psx\input\negcon.cpp" />
|
<ClCompile Include="..\psx\input\negcon.cpp" />
|
||||||
<ClCompile Include="..\psx\irq.cpp" />
|
<ClCompile Include="..\psx\irq.cpp" />
|
||||||
<ClCompile Include="..\psx\mdec.cpp" />
|
<ClCompile Include="..\psx\mdec.cpp" />
|
||||||
<ClCompile Include="..\psx\psx.cpp" />
|
<ClCompile Include="..\psx\psx.cpp">
|
||||||
|
<PreprocessToFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</PreprocessToFile>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\psx\sio.cpp" />
|
<ClCompile Include="..\psx\sio.cpp" />
|
||||||
<ClCompile Include="..\psx\spu.cpp" />
|
<ClCompile Include="..\psx\spu.cpp" />
|
||||||
<ClCompile Include="..\psx\timer.cpp" />
|
<ClCompile Include="..\psx\timer.cpp" />
|
||||||
|
@ -54,6 +56,8 @@
|
||||||
<ClInclude Include="..\emuware\EW_state.h" />
|
<ClInclude Include="..\emuware\EW_state.h" />
|
||||||
<ClInclude Include="..\emuware\msvc\inttypes.h" />
|
<ClInclude Include="..\emuware\msvc\inttypes.h" />
|
||||||
<ClInclude Include="..\emuware\msvc\stdint.h" />
|
<ClInclude Include="..\emuware\msvc\stdint.h" />
|
||||||
|
<ClInclude Include="..\emuware\PACKED.h" />
|
||||||
|
<ClInclude Include="..\emuware\PACKED_END.h" />
|
||||||
<ClInclude Include="..\endian.h" />
|
<ClInclude Include="..\endian.h" />
|
||||||
<ClInclude Include="..\error.h" />
|
<ClInclude Include="..\error.h" />
|
||||||
<ClInclude Include="..\git.h" />
|
<ClInclude Include="..\git.h" />
|
||||||
|
|
|
@ -215,6 +215,12 @@
|
||||||
<ClInclude Include="..\cdrom\CDUtility.h">
|
<ClInclude Include="..\cdrom\CDUtility.h">
|
||||||
<Filter>cdrom</Filter>
|
<Filter>cdrom</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\emuware\PACKED.h">
|
||||||
|
<Filter>emuware</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\emuware\PACKED_END.h">
|
||||||
|
<Filter>emuware</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\psx\spu_fir_table.inc">
|
<None Include="..\psx\spu_fir_table.inc">
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef __GNUC__
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
#pragma warning(disable : 4103)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __PACKED
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __PACKED __attribute__((__packed__))
|
|
||||||
#else
|
|
||||||
#define __PACKED
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -1,3 +0,0 @@
|
||||||
#ifndef __GNUC__
|
|
||||||
#pragma pack(pop)
|
|
||||||
#endif
|
|
|
@ -150,3 +150,10 @@ char (*BLAHBLAHBLAH( UNALIGNED T (&)[N] ))[N];
|
||||||
#else
|
#else
|
||||||
#define EW_EXPORT extern "C" __declspec(dllimport)
|
#define EW_EXPORT extern "C" __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//http://stackoverflow.com/questions/1537964/visual-c-equivalent-of-gccs-attribute-packed
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define EW_PACKED( ... ) __pragma( pack(push, 1) ) __VA_ARGS__ __pragma( pack(pop) )
|
||||||
|
#else
|
||||||
|
#define EW_PACKED( ... ) __Declaration__ __VA_ARGS__ ((__packed__))
|
||||||
|
#endif
|
||||||
|
|
|
@ -537,7 +537,7 @@ void PS_CDC::GetCDAudio(int32 samples[2])
|
||||||
ApplyVolume(samples);
|
ApplyVolume(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "emuware/PACKED.h"
|
EW_PACKED(
|
||||||
struct XA_Subheader
|
struct XA_Subheader
|
||||||
{
|
{
|
||||||
uint8 file;
|
uint8 file;
|
||||||
|
@ -549,16 +549,14 @@ struct XA_Subheader
|
||||||
uint8 channel_dup;
|
uint8 channel_dup;
|
||||||
uint8 submode_dup;
|
uint8 submode_dup;
|
||||||
uint8 coding_dup;
|
uint8 coding_dup;
|
||||||
};
|
});
|
||||||
#include "emuware/PACKED_END.h"
|
|
||||||
|
|
||||||
#include "emuware/PACKED.h"
|
EW_PACKED(
|
||||||
struct XA_SoundGroup
|
struct XA_SoundGroup
|
||||||
{
|
{
|
||||||
uint8 params[16];
|
uint8 params[16];
|
||||||
uint8 samples[112];
|
uint8 samples[112];
|
||||||
};
|
});
|
||||||
#include "emuware/PACKED_END.h"
|
|
||||||
|
|
||||||
#define XA_SUBMODE_EOF 0x80
|
#define XA_SUBMODE_EOF 0x80
|
||||||
#define XA_SUBMODE_REALTIME 0x40
|
#define XA_SUBMODE_REALTIME 0x40
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
namespace MDFN_IEN_PSX
|
namespace MDFN_IEN_PSX
|
||||||
{
|
{
|
||||||
|
|
||||||
InputDevice::InputDevice() : chair_r(0), chair_g(0), chair_b(0), draw_chair(0), chair_x(-1000), chair_y(-1000)
|
InputDevice::InputDevice() : chair_r(0), chair_g(0), chair_b(0), chair_x(-1000), chair_y(-1000)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ class InputDevice
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned chair_r, chair_g, chair_b;
|
unsigned chair_r, chair_g, chair_b;
|
||||||
bool draw_chair;
|
|
||||||
protected:
|
protected:
|
||||||
int32 chair_x, chair_y;
|
int32 chair_x, chair_y;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,13 +46,12 @@ namespace MDFN_IEN_PSX
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "emuware/PACKED.h"
|
EW_PACKED(
|
||||||
struct gtematrix
|
struct gtematrix
|
||||||
{
|
{
|
||||||
int16 MX[3][3];
|
int16 MX[3][3];
|
||||||
int16 dummy;
|
int16 dummy;
|
||||||
};
|
});
|
||||||
#include "emuware/PACKED_END.h"
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,6 +77,9 @@ class InputDevice_DualShock : public InputDevice
|
||||||
|
|
||||||
void CheckManualAnaModeChange(void);
|
void CheckManualAnaModeChange(void);
|
||||||
|
|
||||||
|
//non-serialized state
|
||||||
|
IO_Dualshock* io;
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
bool cur_ana_button_state;
|
bool cur_ana_button_state;
|
||||||
|
@ -261,6 +264,7 @@ void InputDevice_DualShock::Power(void)
|
||||||
|
|
||||||
void InputDevice_DualShock::UpdateInput(const void *data)
|
void InputDevice_DualShock::UpdateInput(const void *data)
|
||||||
{
|
{
|
||||||
|
io = (IO_Dualshock*)data;
|
||||||
uint8 *d8 = (uint8 *)data;
|
uint8 *d8 = (uint8 *)data;
|
||||||
uint8* const rumb_dp = &d8[3 + 16];
|
uint8* const rumb_dp = &d8[3 + 16];
|
||||||
|
|
||||||
|
@ -438,13 +442,15 @@ bool InputDevice_DualShock::Clock(bool TxD, int32 &dsr_pulse_delay)
|
||||||
transmit_buffer[4] = axes[0][1];
|
transmit_buffer[4] = axes[0][1];
|
||||||
transmit_buffer[5] = axes[1][0];
|
transmit_buffer[5] = axes[1][0];
|
||||||
transmit_buffer[6] = axes[1][1];
|
transmit_buffer[6] = axes[1][1];
|
||||||
transmit_count = 7;
|
transmit_count = 7;
|
||||||
|
io->active = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
transmit_buffer[1] = 0xFF ^ buttons[0];
|
transmit_buffer[1] = 0xFF ^ buttons[0];
|
||||||
transmit_buffer[2] = 0xFF ^ buttons[1];
|
transmit_buffer[2] = 0xFF ^ buttons[1];
|
||||||
transmit_count = 3;
|
transmit_count = 3;
|
||||||
|
io->active = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -452,8 +458,8 @@ bool InputDevice_DualShock::Clock(bool TxD, int32 &dsr_pulse_delay)
|
||||||
command_phase = -1;
|
command_phase = -1;
|
||||||
transmit_buffer[1] = 0;
|
transmit_buffer[1] = 0;
|
||||||
transmit_buffer[2] = 0;
|
transmit_buffer[2] = 0;
|
||||||
transmit_pos = 0;
|
transmit_pos = 0;
|
||||||
transmit_count = 0;
|
transmit_count = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -557,12 +563,14 @@ bool InputDevice_DualShock::Clock(bool TxD, int32 &dsr_pulse_delay)
|
||||||
transmit_buffer[4] = axes[1][0];
|
transmit_buffer[4] = axes[1][0];
|
||||||
transmit_buffer[5] = axes[1][1];
|
transmit_buffer[5] = axes[1][1];
|
||||||
transmit_count = 6;
|
transmit_count = 6;
|
||||||
|
io->active = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
transmit_buffer[0] = 0xFF ^ buttons[0];
|
transmit_buffer[0] = 0xFF ^ buttons[0];
|
||||||
transmit_buffer[1] = 0xFF ^ buttons[1];
|
transmit_buffer[1] = 0xFF ^ buttons[1];
|
||||||
transmit_count = 2;
|
transmit_count = 2;
|
||||||
|
io->active = 1;
|
||||||
|
|
||||||
if(!(rumble_magic[2] & 0xFE))
|
if(!(rumble_magic[2] & 0xFE))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,25 @@
|
||||||
#ifndef __MDFN_PSX_INPUT_DUALSHOCK_H
|
#ifndef __MDFN_PSX_INPUT_DUALSHOCK_H
|
||||||
#define __MDFN_PSX_INPUT_DUALSHOCK_H
|
#define __MDFN_PSX_INPUT_DUALSHOCK_H
|
||||||
|
|
||||||
#include <string>
|
#include "octoshock.h"
|
||||||
|
|
||||||
namespace MDFN_IEN_PSX
|
namespace MDFN_IEN_PSX
|
||||||
{
|
{
|
||||||
InputDevice *Device_DualShock_Create();
|
InputDevice *Device_DualShock_Create();
|
||||||
|
|
||||||
|
EW_PACKED(
|
||||||
|
struct IO_Dualshock
|
||||||
|
{
|
||||||
|
u8 buttons[3];
|
||||||
|
u8 right_x, right_y;
|
||||||
|
u8 left_x, left_y;
|
||||||
|
u8 active;
|
||||||
|
u8 pad[8];
|
||||||
|
u8 pad2[3];
|
||||||
|
u16 rumble;
|
||||||
|
u8 pad3[11];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "endian.h"
|
#include "endian.h"
|
||||||
#include "emuware/EW_state.h"
|
#include "emuware/EW_state.h"
|
||||||
|
|
||||||
|
#include "input/dualshock.h"
|
||||||
|
|
||||||
//#include <mednafen/PSFLoader.h>
|
//#include <mednafen/PSFLoader.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -1097,6 +1099,36 @@ struct {
|
||||||
return SHOCK_OK;
|
return SHOCK_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 PollActive(s32 address, bool clear)
|
||||||
|
{
|
||||||
|
//check the port address
|
||||||
|
int portnum = address&0x0F;
|
||||||
|
if(portnum != 1 && portnum != 2)
|
||||||
|
return SHOCK_INVALID_ADDRESS;
|
||||||
|
portnum--;
|
||||||
|
|
||||||
|
s32 ret = SHOCK_FALSE;
|
||||||
|
|
||||||
|
u8* buf = ports[portnum].buffer;
|
||||||
|
switch(ports[portnum].type)
|
||||||
|
{
|
||||||
|
case ePeripheralType_DualShock:
|
||||||
|
{
|
||||||
|
IO_Dualshock* io_dualshock = (IO_Dualshock*)buf;
|
||||||
|
if(io_dualshock->active) ret = SHOCK_TRUE;
|
||||||
|
if(clear) io_dualshock->active = 0;
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ePeripheralType_None:
|
||||||
|
return SHOCK_NOCANDO;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return SHOCK_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s32 SetPadInput(s32 address, u32 buttons, u8 left_x, u8 left_y, u8 right_x, u8 right_y)
|
s32 SetPadInput(s32 address, u32 buttons, u8 left_x, u8 left_y, u8 right_x, u8 right_y)
|
||||||
{
|
{
|
||||||
//check the port address
|
//check the port address
|
||||||
|
@ -1109,14 +1141,17 @@ struct {
|
||||||
switch(ports[portnum].type)
|
switch(ports[portnum].type)
|
||||||
{
|
{
|
||||||
case ePeripheralType_DualShock:
|
case ePeripheralType_DualShock:
|
||||||
buf[0] = (buttons>>0)&0xFF;
|
{
|
||||||
buf[1] = (buttons>>8)&0xFF;
|
IO_Dualshock* io_dualshock = (IO_Dualshock*)buf;
|
||||||
buf[2] = (buttons>>16)&0xFF; //this is only the analog mode button
|
io_dualshock->buttons[0] = (buttons>>0)&0xFF;
|
||||||
buf[3] = right_x;
|
io_dualshock->buttons[1] = (buttons>>8)&0xFF;
|
||||||
buf[4] = right_y;
|
io_dualshock->buttons[2] = (buttons>>16)&0xFF; //this is only the analog mode button
|
||||||
buf[5] = left_x;
|
io_dualshock->right_x = right_x;
|
||||||
buf[6] = left_y;
|
io_dualshock->right_y = right_y;
|
||||||
return SHOCK_OK;
|
io_dualshock->left_x = left_x;
|
||||||
|
io_dualshock->left_y = left_y;
|
||||||
|
return SHOCK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return SHOCK_ERROR;
|
return SHOCK_ERROR;
|
||||||
|
@ -1164,7 +1199,7 @@ struct {
|
||||||
|
|
||||||
EW_EXPORT s32 shock_Peripheral_Connect(void* psx, s32 address, s32 type)
|
EW_EXPORT s32 shock_Peripheral_Connect(void* psx, s32 address, s32 type)
|
||||||
{
|
{
|
||||||
return s_ShockPeripheralState.Connect(address,type);
|
return s_ShockPeripheralState.Connect(address, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
EW_EXPORT s32 shock_Peripheral_SetPadInput(void* psx, s32 address, u32 buttons, u8 left_x, u8 left_y, u8 right_x, u8 right_y)
|
EW_EXPORT s32 shock_Peripheral_SetPadInput(void* psx, s32 address, u32 buttons, u8 left_x, u8 left_y, u8 right_x, u8 right_y)
|
||||||
|
@ -1172,6 +1207,11 @@ EW_EXPORT s32 shock_Peripheral_SetPadInput(void* psx, s32 address, u32 buttons,
|
||||||
return s_ShockPeripheralState.SetPadInput(address, buttons, left_x, left_y, right_x, right_y);
|
return s_ShockPeripheralState.SetPadInput(address, buttons, left_x, left_y, right_x, right_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EW_EXPORT s32 shock_Peripheral_PollActive(void* psx, s32 address, s32 clear)
|
||||||
|
{
|
||||||
|
return s_ShockPeripheralState.PollActive(address, clear!=SHOCK_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
EW_EXPORT s32 shock_Peripheral_MemcardTransact(void* psx, s32 address, ShockMemcardTransaction* transaction)
|
EW_EXPORT s32 shock_Peripheral_MemcardTransact(void* psx, s32 address, ShockMemcardTransaction* transaction)
|
||||||
{
|
{
|
||||||
return s_ShockPeripheralState.MemcardTransact(address, transaction);
|
return s_ShockPeripheralState.MemcardTransact(address, transaction);
|
||||||
|
@ -1731,7 +1771,7 @@ static void LoadEXE(const uint8 *data, const uint32 size, bool ignore_pcsp = fal
|
||||||
po += 4;
|
po += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
EW_EXPORT s32 shock_MountEXE(void* psx, void* exebuf, int size)
|
EW_EXPORT s32 shock_MountEXE(void* psx, void* exebuf, s32 size)
|
||||||
{
|
{
|
||||||
LoadEXE((uint8*)exebuf, (uint32)size);
|
LoadEXE((uint8*)exebuf, (uint32)size);
|
||||||
return SHOCK_OK;
|
return SHOCK_OK;
|
||||||
|
|
|
@ -319,8 +319,17 @@ EW_EXPORT s32 shock_Peripheral_SetPadInput(void* psx, s32 address, u32 buttons,
|
||||||
//Performs one of several transactions on an attached memory card.
|
//Performs one of several transactions on an attached memory card.
|
||||||
EW_EXPORT s32 shock_Peripheral_MemcardTransact(void* psx, s32 address, ShockMemcardTransaction* transaction);
|
EW_EXPORT s32 shock_Peripheral_MemcardTransact(void* psx, s32 address, ShockMemcardTransaction* transaction);
|
||||||
|
|
||||||
|
//Polls the given peripheral address for it's active flag status (inverse of lag flag)
|
||||||
|
//If you want, the lag flag can be cleared
|
||||||
|
//Returns SHOCK_TRUE if the input has been read this frame
|
||||||
|
//Returns SHOCK_FALSE if the input hasnt been read this frame (is lagging)
|
||||||
|
//Returns SHOCK_NOCANDO if there is no peripheral there
|
||||||
|
//Returns SHOCK_INVALID_ADDRESS if address is invalid
|
||||||
|
//Returns SHOCK_ERROR for other errors.
|
||||||
|
EW_EXPORT s32 shock_Peripheral_PollActive(void* psx, s32 address, s32 clear);
|
||||||
|
|
||||||
//Mounts a PS-EXE executable
|
//Mounts a PS-EXE executable
|
||||||
EW_EXPORT s32 shock_MountEXE(void* psx, void* exebuf, int size);
|
EW_EXPORT s32 shock_MountEXE(void* psx, void* exebuf, s32 size);
|
||||||
|
|
||||||
//Sets the power to ON. Returns SHOCK_NOCANDO if already on.
|
//Sets the power to ON. Returns SHOCK_NOCANDO if already on.
|
||||||
EW_EXPORT s32 shock_PowerOn(void* psx);
|
EW_EXPORT s32 shock_PowerOn(void* psx);
|
||||||
|
|
Loading…
Reference in New Issue