Updated to latest LazyUSF
parent
5e39b592d5
commit
5bf11d551e
|
@ -16,13 +16,16 @@ void AddBuffer(usf_state_t *state, unsigned char *buf, unsigned int length) {
|
||||||
do_max = length >> 2;
|
do_max = length >> 2;
|
||||||
if ( do_max > state->sample_buffer_count )
|
if ( do_max > state->sample_buffer_count )
|
||||||
do_max = (unsigned int) state->sample_buffer_count;
|
do_max = (unsigned int) state->sample_buffer_count;
|
||||||
|
|
||||||
for (i = 0; i < do_max; ++i)
|
if ( sample_buffer )
|
||||||
{
|
for (i = 0; i < do_max; ++i)
|
||||||
*sample_buffer++ = ((int16_t*)buf)[1];
|
{
|
||||||
*sample_buffer++ = ((int16_t*)buf)[0];
|
*sample_buffer++ = ((int16_t*)buf)[1];
|
||||||
buf += 4;
|
*sample_buffer++ = ((int16_t*)buf)[0];
|
||||||
}
|
buf += 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
buf += 4 * do_max;
|
||||||
|
|
||||||
state->sample_buffer_count -= do_max;
|
state->sample_buffer_count -= do_max;
|
||||||
state->sample_buffer = sample_buffer;
|
state->sample_buffer = sample_buffer;
|
||||||
|
|
|
@ -89,6 +89,7 @@ void R4300i_opcode_COP1_L (usf_state_t * state) {
|
||||||
|
|
||||||
|
|
||||||
void BuildInterpreter (usf_state_t * state) {
|
void BuildInterpreter (usf_state_t * state) {
|
||||||
|
(void)state;
|
||||||
R4300i_Opcode[ 0] = R4300i_opcode_SPECIAL;
|
R4300i_Opcode[ 0] = R4300i_opcode_SPECIAL;
|
||||||
R4300i_Opcode[ 1] = R4300i_opcode_REGIMM;
|
R4300i_Opcode[ 1] = R4300i_opcode_REGIMM;
|
||||||
R4300i_Opcode[ 2] = r4300i_J;
|
R4300i_Opcode[ 2] = r4300i_J;
|
||||||
|
|
|
@ -482,6 +482,7 @@ void r4300i_SWR (usf_state_t * state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void r4300i_CACHE (usf_state_t * state) {
|
void r4300i_CACHE (usf_state_t * state) {
|
||||||
|
(void)state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void r4300i_LL (usf_state_t * state) {
|
void r4300i_LL (usf_state_t * state) {
|
||||||
|
@ -618,6 +619,7 @@ void r4300i_SPECIAL_BREAK (usf_state_t * state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void r4300i_SPECIAL_SYNC (usf_state_t * state) {
|
void r4300i_SPECIAL_SYNC (usf_state_t * state) {
|
||||||
|
(void)state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void r4300i_SPECIAL_MFHI (usf_state_t * state) {
|
void r4300i_SPECIAL_MFHI (usf_state_t * state) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ void StopEmulation(usf_state_t * state)
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayError (char * Message, ...) {
|
void DisplayError (char * Message, ...) {
|
||||||
|
(void)Message;
|
||||||
//char Msg[1000];
|
//char Msg[1000];
|
||||||
//va_list ap;
|
//va_list ap;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void large_free(void * p, size_t size)
|
||||||
|
|
||||||
void * large_alloc(size_t size)
|
void * large_alloc(size_t size)
|
||||||
{
|
{
|
||||||
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
|
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void large_free(void * p, size_t size)
|
void large_free(void * p, size_t size)
|
||||||
|
@ -204,6 +204,8 @@ uint32_t r4300i_LD_VAddr ( usf_state_t * state, uint32_t VAddr, uint64_t * Value
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t r4300i_LH_NonMemory ( usf_state_t * state, uint32_t PAddr, uint32_t * Value, int32_t SignExtend ) {
|
int32_t r4300i_LH_NonMemory ( usf_state_t * state, uint32_t PAddr, uint32_t * Value, int32_t SignExtend ) {
|
||||||
|
(void)state;
|
||||||
|
(void)SignExtend;
|
||||||
switch (PAddr & 0xFFF00000) {
|
switch (PAddr & 0xFFF00000) {
|
||||||
default:
|
default:
|
||||||
* Value = 0;
|
* Value = 0;
|
||||||
|
|
|
@ -93,5 +93,7 @@ void PifRamWrite (usf_state_t * state) {
|
||||||
|
|
||||||
// always return failure
|
// always return failure
|
||||||
void ProcessControllerCommand ( usf_state_t * state, int32_t Control, uint8_t * Command) {
|
void ProcessControllerCommand ( usf_state_t * state, int32_t Control, uint8_t * Command) {
|
||||||
|
(void)state;
|
||||||
|
(void)Control;
|
||||||
Command[1] |= 0x80;
|
Command[1] |= 0x80;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
void real_run_rsp(usf_state_t * state, uint32_t cycles)
|
void real_run_rsp(usf_state_t * state, uint32_t cycles)
|
||||||
{
|
{
|
||||||
|
(void)cycles;
|
||||||
|
|
||||||
if (SP_STATUS_REG & 0x00000003)
|
if (SP_STATUS_REG & 0x00000003)
|
||||||
{
|
{
|
||||||
message("SP_STATUS_HALT", 3);
|
message("SP_STATUS_HALT", 3);
|
||||||
|
|
|
@ -44,6 +44,8 @@ typedef uint32_t RCPREG;
|
||||||
|
|
||||||
NOINLINE void message(const char* body, int priority)
|
NOINLINE void message(const char* body, int priority)
|
||||||
{
|
{
|
||||||
|
(void)body;
|
||||||
|
(void)priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -53,6 +55,7 @@ NOINLINE void message(const char* body, int priority)
|
||||||
/* typical standard DOS text file limit per line */
|
/* typical standard DOS text file limit per line */
|
||||||
NOINLINE void update_conf(const char* source)
|
NOINLINE void update_conf(const char* source)
|
||||||
{
|
{
|
||||||
|
(void)source;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "su.h"
|
#include "su.h"
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
NOINLINE static void res_S(usf_state_t * state)
|
NOINLINE static void res_S(usf_state_t * state)
|
||||||
{
|
{
|
||||||
|
(void)state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +220,8 @@ static void MT_CMD_CLOCK(usf_state_t * state, int rt)
|
||||||
}
|
}
|
||||||
static void MT_READ_ONLY(usf_state_t * state, int rt)
|
static void MT_READ_ONLY(usf_state_t * state, int rt)
|
||||||
{
|
{
|
||||||
|
(void)state;
|
||||||
|
(void)rt;
|
||||||
//char text[64];
|
//char text[64];
|
||||||
|
|
||||||
//sprintf(text, "MTC0\nInvalid write attempt.\nstate->SR[%i] = 0x%08X", rt, state->SR[rt]);
|
//sprintf(text, "MTC0\nInvalid write attempt.\nstate->SR[%i] = 0x%08X", rt, state->SR[rt]);
|
||||||
|
@ -1088,7 +1091,13 @@ static void LHV(usf_state_t * state, int vt, int element, int offset, int base)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NOINLINE static void LFV(usf_state_t * state, int vt, int element, int offset, int base)
|
NOINLINE static void LFV(usf_state_t * state, int vt, int element, int offset, int base)
|
||||||
{ /* Dummy implementation only: Do any games execute this? */
|
{
|
||||||
|
(void)state;
|
||||||
|
(void)vt;
|
||||||
|
(void)element;
|
||||||
|
(void)offset;
|
||||||
|
(void)base;
|
||||||
|
/* Dummy implementation only: Do any games execute this? */
|
||||||
/*char debugger[32];
|
/*char debugger[32];
|
||||||
|
|
||||||
sprintf(debugger, "%s $v%i[0x%X], 0x%03X($%i)", "LFV",
|
sprintf(debugger, "%s $v%i[0x%X], 0x%03X($%i)", "LFV",
|
||||||
|
@ -1454,7 +1463,13 @@ INLINE static void LTV(usf_state_t * state, int vt, int element, int offset, int
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NOINLINE static void SWV(usf_state_t * state, int vt, int element, int offset, int base)
|
NOINLINE static void SWV(usf_state_t * state, int vt, int element, int offset, int base)
|
||||||
{ /* Dummy implementation only: Do any games execute this? */
|
{
|
||||||
|
(void)state;
|
||||||
|
(void)vt;
|
||||||
|
(void)element;
|
||||||
|
(void)offset;
|
||||||
|
(void)base;
|
||||||
|
/* Dummy implementation only: Do any games execute this? */
|
||||||
/*char debugger[32];
|
/*char debugger[32];
|
||||||
|
|
||||||
sprintf(debugger, "%s $v%i[0x%X], 0x%03X($%i)", "SWV",
|
sprintf(debugger, "%s $v%i[0x%X], 0x%03X($%i)", "SWV",
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
static void VMACQ(usf_state_t * state, int vd, int vs, int vt, int e)
|
static void VMACQ(usf_state_t * state, int vd, int vs, int vt, int e)
|
||||||
{
|
{
|
||||||
|
(void)state;
|
||||||
vd &= vs &= vt &= e &= 0; /* unused */
|
vd &= vs &= vt &= e &= 0; /* unused */
|
||||||
if (vd != vs || vt != e)
|
if (vd != vs || vt != e)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,6 +17,8 @@ static void VNOP(usf_state_t * state, int vd, int vs, int vt, int e)
|
||||||
{
|
{
|
||||||
const int WB_inhibit = vd = vs = vt = e = 1;
|
const int WB_inhibit = vd = vs = vt = e = 1;
|
||||||
|
|
||||||
|
(void)state;
|
||||||
|
|
||||||
if (WB_inhibit)
|
if (WB_inhibit)
|
||||||
return; /* message("VNOP", WB_inhibit); */
|
return; /* message("VNOP", WB_inhibit); */
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -182,8 +182,9 @@ void usf_render(void * state, int16_t * buffer, size_t count, int32_t * sample_r
|
||||||
size_t do_max = USF_STATE->samples_in_buffer;
|
size_t do_max = USF_STATE->samples_in_buffer;
|
||||||
if ( do_max > count )
|
if ( do_max > count )
|
||||||
do_max = count;
|
do_max = count;
|
||||||
|
|
||||||
memcpy( buffer, USF_STATE->samplebuf, sizeof(int16_t) * 2 * do_max );
|
if ( buffer )
|
||||||
|
memcpy( buffer, USF_STATE->samplebuf, sizeof(int16_t) * 2 * do_max );
|
||||||
|
|
||||||
USF_STATE->samples_in_buffer -= do_max;
|
USF_STATE->samples_in_buffer -= do_max;
|
||||||
|
|
||||||
|
@ -196,7 +197,8 @@ void usf_render(void * state, int16_t * buffer, size_t count, int32_t * sample_r
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer += 2 * do_max;
|
if ( buffer )
|
||||||
|
buffer += 2 * do_max;
|
||||||
count -= do_max;
|
count -= do_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +214,12 @@ void usf_render(void * state, int16_t * buffer, size_t count, int32_t * sample_r
|
||||||
*sample_rate = USF_STATE->SampleRate;
|
*sample_rate = USF_STATE->SampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usf_restart(void * state)
|
||||||
|
{
|
||||||
|
if ( USF_STATE->MemoryState )
|
||||||
|
StartEmulationFromSave(USF_STATE, USF_STATE->savestatespace);
|
||||||
|
}
|
||||||
|
|
||||||
void usf_shutdown(void * state)
|
void usf_shutdown(void * state)
|
||||||
{
|
{
|
||||||
Release_Memory(USF_STATE);
|
Release_Memory(USF_STATE);
|
||||||
|
|
|
@ -32,6 +32,8 @@ int usf_upload_section(void * state, const uint8_t * data, size_t size);
|
||||||
|
|
||||||
void usf_render(void * state, int16_t * buffer, size_t count, int32_t * sample_rate);
|
void usf_render(void * state, int16_t * buffer, size_t count, int32_t * sample_rate);
|
||||||
|
|
||||||
|
void usf_restart(void * state);
|
||||||
|
|
||||||
void usf_shutdown(void * state);
|
void usf_shutdown(void * state);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -14,22 +14,34 @@ typedef uint32_t RCPREG;
|
||||||
struct usf_state
|
struct usf_state
|
||||||
{
|
{
|
||||||
// RSP vector registers, need to be aligned to 16 bytes
|
// RSP vector registers, need to be aligned to 16 bytes
|
||||||
|
// when SSE2 or SSSE3 is enabled, or for any hope of
|
||||||
|
// auto vectorization
|
||||||
|
|
||||||
|
// usf_clear takes care of aligning the structure within
|
||||||
|
// the memory block passed into it, treating the pointer
|
||||||
|
// as usf_state_helper, and storing an offset from the
|
||||||
|
// pointer to the actual usf_state structure. The size
|
||||||
|
// which is indicated for allocation accounts for this
|
||||||
|
// with two pages of padding.
|
||||||
|
|
||||||
short VR[32][8];
|
short VR[32][8];
|
||||||
short VACC[3][8];
|
short VACC[3][8];
|
||||||
|
|
||||||
// RSP virtual registers
|
// RSP virtual registers, also needs alignment
|
||||||
int SR[32];
|
int SR[32];
|
||||||
|
|
||||||
// rsp/rsp.c
|
// rsp/rsp.c, not necessarily in need of alignment
|
||||||
RCPREG* CR[16];
|
RCPREG* CR[16];
|
||||||
|
|
||||||
// rsp/vu/cf.h
|
// rsp/vu/cf.h, all need alignment
|
||||||
short ne[8]; /* $vco: high byte "NOTEQUAL" */
|
short ne[8]; /* $vco: high byte "NOTEQUAL" */
|
||||||
short co[8]; /* $vco: low byte "carry/borrow in/out" */
|
short co[8]; /* $vco: low byte "carry/borrow in/out" */
|
||||||
short clip[8]; /* $vcc: high byte (clip tests: VCL, VCH, VCR) */
|
short clip[8]; /* $vcc: high byte (clip tests: VCL, VCH, VCR) */
|
||||||
short comp[8]; /* $vcc: low byte (VEQ, VNE, VLT, VGE, VCL, VCH, VCR) */
|
short comp[8]; /* $vcc: low byte (VEQ, VNE, VLT, VGE, VCL, VCH, VCR) */
|
||||||
short vce[8]; /* $vce: vector compare extension register */
|
short vce[8]; /* $vce: vector compare extension register */
|
||||||
|
|
||||||
|
// All further members of the structure need not be aligned
|
||||||
|
|
||||||
// rsp/vu/divrom.h
|
// rsp/vu/divrom.h
|
||||||
int DivIn; /* buffered numerator of division read from vector file */
|
int DivIn; /* buffered numerator of division read from vector file */
|
||||||
int DivOut; /* global division result set by VRCP/VRCPL/VRSQ/VRSQH */
|
int DivOut; /* global division result set by VRCP/VRCPL/VRSQ/VRSQH */
|
||||||
|
|
Loading…
Reference in New Issue