Updated LazyUSF library

CQTexperiment
Chris Moeller 2014-02-15 23:38:46 -08:00
parent b02a0db5a4
commit 1d3770757b
46 changed files with 140 additions and 111 deletions

View File

@ -7,7 +7,7 @@
#include "usf_internal.h"
void AddBuffer(usf_state_t *state, unsigned char *buf, unsigned int length) {
int32_t i, do_max;
unsigned int i, do_max;
int16_t * sample_buffer = state->sample_buffer;
if(!state->cpu_running)

View File

@ -90,4 +90,6 @@ enum SaveType {
FlashRam
};
void StartEmulationFromSave ( usf_state_t * state, void * savestate );
#endif

View File

@ -3,7 +3,6 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "usf.h"
#include "cpu.h"
#include "memory.h"

View File

@ -25,9 +25,7 @@
*/
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include "usf.h"
#include "main.h"
@ -41,6 +39,39 @@ uint8_t * PageROM(usf_state_t * state, uint32_t addr) {
return (state->ROMPages[addr/0x10000])?state->ROMPages[addr/0x10000]+(addr%0x10000):&state->EmptySpace;
}
void * large_alloc(size_t);
void large_free(void *, size_t);
#ifdef _WIN32
#include <Windows.h>
void * large_alloc(size_t size)
{
return VirtualAlloc( NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE );
}
void large_free(void * p, size_t size)
{
VirtualFree( p, size, MEM_RELEASE );
}
#else
#include <sys/mman.h>
#ifdef __APPLE__
#define MAP_ANONYMOUS MAP_ANON
#endif
void * large_alloc(size_t size)
{
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
}
void large_free(void * p, size_t size)
{
munmap( p, size );
}
#endif
int32_t Allocate_Memory ( void * state ) {
uint32_t i = 0;
//RdramSize = 0x800000;
@ -51,7 +82,7 @@ int32_t Allocate_Memory ( void * state ) {
// the mmap technique works craptacular when the regions don't overlay
USF_STATE->MemChunk = mmap(NULL, 0x100000 * sizeof(uintptr_t) + 0x1D000 + USF_STATE->RdramSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0);
USF_STATE->MemChunk = (uint8_t *) large_alloc( 0x100000 * sizeof(uintptr_t) + 0x1D000 + USF_STATE->RdramSize );
USF_STATE->TLB_Map = (uintptr_t*)USF_STATE->MemChunk;
if (USF_STATE->TLB_Map == NULL) {
@ -60,7 +91,7 @@ int32_t Allocate_Memory ( void * state ) {
memset(USF_STATE->TLB_Map, 0, 0x100000 * sizeof(uintptr_t) + 0x10000);
USF_STATE->N64MEM = mmap((uintptr_t)USF_STATE->MemChunk + 0x100000 * sizeof(uintptr_t) + 0x10000, 0xD000 + USF_STATE->RdramSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, 0, 0);
USF_STATE->N64MEM = USF_STATE->MemChunk + 0x100000 * sizeof(uintptr_t) + 0x10000;
if(USF_STATE->N64MEM == NULL) {
DisplayError("Failed to allocate N64MEM");
return 0;
@ -68,7 +99,7 @@ int32_t Allocate_Memory ( void * state ) {
//memset(state->N64MEM, 0, state->RdramSize);
USF_STATE->NOMEM = mmap((uintptr_t)USF_STATE->N64MEM + USF_STATE->RdramSize, 0xD000, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, 0, 0);
USF_STATE->NOMEM = USF_STATE->N64MEM + USF_STATE->RdramSize;
if(USF_STATE->RdramSize == 0x400000)
{
@ -98,7 +129,7 @@ int PreAllocate_Memory(usf_state_t * state) {
int i = 0;
// Moved the savestate allocation here :) (for better management later)
state->savestatespace = malloc(0x80275C);
state->savestatespace = (uint8_t *) malloc(0x80275C);
if(state->savestatespace == 0)
return 0;
@ -124,9 +155,7 @@ void Release_Memory ( usf_state_t * state ) {
state->MemoryState = 0;
if (state->MemChunk != 0) {munmap(state->MemChunk, 0x100000 * sizeof(uintptr_t) + 0x10000); state->MemChunk=0;}
if (state->N64MEM != 0) {munmap(state->N64MEM, state->RdramSize); state->N64MEM=0;}
if (state->NOMEM != 0) {munmap(state->NOMEM, 0xD000); state->NOMEM=0;}
if (state->MemChunk != 0) { large_free( state->MemChunk, 0x100000 * sizeof(uintptr_t) + 0x1D000 + USF_STATE->RdramSize ); state->MemChunk=0; }
if(state->savestatespace)
free(state->savestatespace);

View File

@ -15,7 +15,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include "../usf.h"

View File

@ -219,10 +219,10 @@ static void MT_CMD_CLOCK(usf_state_t * state, int rt)
}
static void MT_READ_ONLY(usf_state_t * state, int rt)
{
char text[64];
//char text[64];
sprintf(text, "MTC0\nInvalid write attempt.\nstate->SR[%i] = 0x%08X", rt, state->SR[rt]);
message(text, 2);
//sprintf(text, "MTC0\nInvalid write attempt.\nstate->SR[%i] = 0x%08X", rt, state->SR[rt]);
//message(text, 2);
return;
}
@ -1089,11 +1089,11 @@ static void LHV(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? */
char debugger[32];
/*char debugger[32];
sprintf(debugger, "%s $v%i[0x%X], 0x%03X($%i)", "LFV",
vt, element, offset & 0xFFF, base);
message(debugger, 3);
message(debugger, 3);*/
return;
}
static void SHV(usf_state_t * state, int vt, int element, int offset, int base)
@ -1308,7 +1308,7 @@ INLINE static void SQV(usf_state_t * state, int vt, int element, int offset, int
{ /* happens with "Mia Hamm Soccer 64" */
register int i;
for (i = 0; i < 16 - addr%16; i++)
for (i = 0; i < (int)(16 - addr%16); i++)
state->DMEM[BES((addr + i) & 0xFFF)] = VR_B(vt, (e + i) & 0xF);
return;
}
@ -1455,11 +1455,11 @@ INLINE static void LTV(usf_state_t * state, int vt, int element, int offset, int
}
NOINLINE static void SWV(usf_state_t * state, int vt, int element, int offset, int 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",
vt, element, offset & 0xFFF, base);
message(debugger, 3);
message(debugger, 3);*/
return;
}
INLINE static void STV(usf_state_t * state, int vt, int element, int offset, int base)

View File

@ -47,7 +47,7 @@ static INLINE void merge(short* VD, short* cmp, short* pass, short* fail)
for (i = 0; i < N; i++)
VD[i] = (cmp[i] != 0) ? pass[i] : fail[i];
#else
short diff[N];
ALIGNED short diff[N];
for (i = 0; i < N; i++)
diff[i] = pass[i] - fail[i];
@ -73,8 +73,8 @@ static INLINE void vector_copy(short* VD, short* VS)
static INLINE void SIGNED_CLAMP_ADD(usf_state_t * state, short* VD, short* VS, short* VT)
{
int32_t sum[N];
short hi[N], lo[N];
ALIGNED int32_t sum[N];
ALIGNED short hi[N], lo[N];
register int i;
for (i = 0; i < N; i++)
@ -94,8 +94,8 @@ static INLINE void SIGNED_CLAMP_ADD(usf_state_t * state, short* VD, short* VS, s
}
static INLINE void SIGNED_CLAMP_SUB(usf_state_t * state, short* VD, short* VS, short* VT)
{
int32_t dif[N];
short hi[N], lo[N];
ALIGNED int32_t dif[N];
ALIGNED short hi[N], lo[N];
register int i;
for (i = 0; i < N; i++)
@ -115,7 +115,7 @@ static INLINE void SIGNED_CLAMP_SUB(usf_state_t * state, short* VD, short* VS, s
}
static INLINE void SIGNED_CLAMP_AM(usf_state_t * state, short* VD)
{ /* typical sign-clamp of accumulator-mid (bits 31:16) */
short hi[N], lo[N];
ALIGNED short hi[N], lo[N];
register int i;
for (i = 0; i < N; i++)
@ -225,8 +225,8 @@ static INLINE void SIGNED_CLAMP_AM(usf_state_t * state, short* VD)
static INLINE void UNSIGNED_CLAMP(usf_state_t * state, short* VD)
{ /* sign-zero hybrid clamp of accumulator-mid (bits 31:16) */
short cond[N];
short temp[N];
ALIGNED short cond[N];
ALIGNED short temp[N];
register int i;
SIGNED_CLAMP_AM(state, temp); /* no direct map in SSE, but closely based on this */
@ -240,8 +240,8 @@ static INLINE void UNSIGNED_CLAMP(usf_state_t * state, short* VD)
}
static INLINE void SIGNED_CLAMP_AL(usf_state_t * state, short* VD)
{ /* sign-clamp accumulator-low (bits 15:0) */
short cond[N];
short temp[N];
ALIGNED short cond[N];
ALIGNED short temp[N];
register int i;
SIGNED_CLAMP_AM(state, temp); /* no direct map in SSE, but closely based on this */

View File

@ -56,7 +56,7 @@ int sub_mask[16] = {
INLINE static void SHUFFLE_VECTOR(short* VD, short* VT, const int e)
{
short SV[8];
ALIGNED short SV[8];
register int i, j;
#if (0 == 0)
j = sub_mask[e];

View File

@ -21,9 +21,9 @@
*/
INLINE static void do_abs(usf_state_t * state, short* VD, short* VS, short* VT)
{
short neg[N], pos[N];
short nez[N], cch[N]; /* corner case hack -- abs(-32768) == +32767 */
short res[N];
ALIGNED short neg[N], pos[N];
ALIGNED short nez[N], cch[N]; /* corner case hack -- abs(-32768) == +32767 */
ALIGNED short res[N];
register int i;
vector_copy(res, VT);
@ -69,7 +69,7 @@ INLINE static void do_abs(usf_state_t * state, short* VD, short* VS, short* VT)
static void VABS(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_abs(state, state->VR[vd], state->VR[vs], ST);

View File

@ -29,7 +29,7 @@ INLINE static void clr_ci(usf_state_t * state, short* VD, short* VS, short* VT)
static void VADD(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
clr_ci(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,7 +15,7 @@
INLINE static void set_co(usf_state_t * state, short* VD, short* VS, short* VT)
{ /* set CARRY and carry out from sum */
int32_t sum[N];
ALIGNED int32_t sum[N];
register int i;
for (i = 0; i < N; i++)
@ -32,7 +32,7 @@ INLINE static void set_co(usf_state_t * state, short* VD, short* VS, short* VT)
static void VADDC(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
set_co(state, state->VR[vd], state->VR[vs], ST);

View File

@ -25,7 +25,7 @@ INLINE void do_and(usf_state_t * state, short* VD, short* VS, short* VT)
static void VAND(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_and(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,10 +15,10 @@
INLINE static void do_ch(usf_state_t * state, short* VD, short* VS, short* VT)
{
short eq[N], ge[N], le[N];
short sn[N];
short VC[N];
short diff[N];
ALIGNED short eq[N], ge[N], le[N];
ALIGNED short sn[N];
ALIGNED short VC[N];
ALIGNED short diff[N];
register int i;
for (i = 0; i < N; i++)
@ -76,7 +76,7 @@ INLINE static void do_ch(usf_state_t * state, short* VD, short* VS, short* VT)
static void VCH(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_ch(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,11 +15,11 @@
INLINE static void do_cl(usf_state_t * state, short* VD, short* VS, short* VT)
{
short eq[N], ge[N], le[N];
short gen[N], len[N], lz[N], uz[N], sn[N];
short diff[N];
short cmp[N];
unsigned short VB[N], VC[N];
ALIGNED short eq[N], ge[N], le[N];
ALIGNED short gen[N], len[N], lz[N], uz[N], sn[N];
ALIGNED short diff[N];
ALIGNED short cmp[N];
ALIGNED unsigned short VB[N], VC[N];
register int i;
for (i = 0; i < N; i++)
@ -92,7 +92,7 @@ INLINE static void do_cl(usf_state_t * state, short* VD, short* VS, short* VT)
static void VCL(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_cl(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,9 +15,9 @@
INLINE static void do_cr(usf_state_t * state, short* VD, short* VS, short* VT)
{
short ge[N], le[N], sn[N];
short VC[N];
short cmp[N];
ALIGNED short ge[N], le[N], sn[N];
ALIGNED short VC[N];
ALIGNED short cmp[N];
register int i;
for (i = 0; i < N; i++)
@ -59,7 +59,7 @@ INLINE static void do_cr(usf_state_t * state, short* VD, short* VS, short* VT)
static void VCR(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_cr(state, state->VR[vd], state->VR[vs], ST);

View File

@ -39,7 +39,7 @@ INLINE static void do_eq(usf_state_t * state, short* VD, short* VS, short* VT)
static void VEQ(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_eq(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,8 +15,8 @@
INLINE static void do_ge(usf_state_t * state, short* VD, short* VS, short* VT)
{
short ce[N];
short eq[N];
ALIGNED short ce[N];
ALIGNED short eq[N];
register int i;
for (i = 0; i < N; i++)
@ -43,7 +43,7 @@ INLINE static void do_ge(usf_state_t * state, short* VD, short* VS, short* VT)
static void VGE(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_ge(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,8 +15,8 @@
INLINE static void do_lt(usf_state_t * state, short* VD, short* VS, short* VT)
{
short cn[N];
short eq[N];
ALIGNED short cn[N];
ALIGNED short eq[N];
register int i;
for (i = 0; i < N; i++)
@ -43,7 +43,7 @@ INLINE static void do_lt(usf_state_t * state, short* VD, short* VS, short* VT)
static void VLT(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_lt(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,8 +15,8 @@
INLINE static void do_macf(usf_state_t * state, short* VD, short* VS, short* VT)
{
int32_t product[N];
uint32_t addend[N];
ALIGNED int32_t product[N];
ALIGNED uint32_t addend[N];
register int i;
for (i = 0; i < N; i++)
@ -43,7 +43,7 @@ INLINE static void do_macf(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMACF(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_macf(state, state->VR[vd], state->VR[vs], ST);

View File

@ -13,7 +13,7 @@
\******************************************************************************/
#include "vu.h"
static void VMACQ(int vd, int vs, int vt, int e)
static void VMACQ(usf_state_t * state, int vd, int vs, int vt, int e)
{
vd &= vs &= vt &= e &= 0; /* unused */
if (vd != vs || vt != e)

View File

@ -15,8 +15,8 @@
INLINE static void do_macu(usf_state_t * state, short* VD, short* VS, short* VT)
{
int32_t product[N];
uint32_t addend[N];
ALIGNED int32_t product[N];
ALIGNED uint32_t addend[N];
register int i;
for (i = 0; i < N; i++)
@ -43,7 +43,7 @@ INLINE static void do_macu(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMACU(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_macu(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,8 +15,8 @@
INLINE static void do_madh(usf_state_t * state, short* VD, short* VS, short* VT)
{
int32_t product[N];
uint32_t addend[N];
ALIGNED int32_t product[N];
ALIGNED uint32_t addend[N];
register int i;
for (i = 0; i < N; i++)
@ -33,7 +33,7 @@ INLINE static void do_madh(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMADH(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_madh(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,8 +15,8 @@
INLINE static void do_madl(usf_state_t * state, short* VD, short* VS, short* VT)
{
int32_t product[N];
uint32_t addend[N];
ALIGNED int32_t product[N];
ALIGNED uint32_t addend[N];
register int i;
for (i = 0; i < N; i++)
@ -41,7 +41,7 @@ INLINE static void do_madl(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMADL(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_madl(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,7 +15,7 @@
INLINE static void do_madm(usf_state_t * state, short* VD, short* VS, short* VT)
{
uint32_t addend[N];
ALIGNED uint32_t addend[N];
register int i;
for (i = 0; i < N; i++)
@ -36,7 +36,7 @@ INLINE static void do_madm(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMADM(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_madm(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,7 +15,7 @@
INLINE static void do_madn(usf_state_t * state, short* VD, short* VS, short* VT)
{
uint32_t addend[N];
ALIGNED uint32_t addend[N];
register int i;
for (i = 0; i < N; i++)
@ -36,7 +36,7 @@ INLINE static void do_madn(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMADN(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_madn(state, state->VR[vd], state->VR[vs], ST);

View File

@ -22,7 +22,7 @@ INLINE static void do_mrg(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMRG(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_mrg(state, state->VR[vd], state->VR[vs], ST);

View File

@ -29,7 +29,7 @@ INLINE static void do_mudh(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMUDH(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_mudh(state, state->VR[vd], state->VR[vs], ST);

View File

@ -29,7 +29,7 @@ INLINE static void do_mudl(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMUDL(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_mudl(state, state->VR[vd], state->VR[vs], ST);

View File

@ -29,7 +29,7 @@ INLINE static void do_mudm(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMUDM(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_mudm(state, state->VR[vd], state->VR[vs], ST);

View File

@ -29,7 +29,7 @@ INLINE static void do_mudn(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMUDN(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_mudn(state, state->VR[vd], state->VR[vs], ST);

View File

@ -47,7 +47,7 @@ INLINE static void do_mulf(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMULF(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_mulf(state, state->VR[vd], state->VR[vs], ST);

View File

@ -49,7 +49,7 @@ INLINE static void do_mulu(usf_state_t * state, short* VD, short* VS, short* VT)
static void VMULU(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_mulu(state, state->VR[vd], state->VR[vs], ST);

View File

@ -25,7 +25,7 @@ INLINE void do_nand(usf_state_t * state, short* VD, short* VS, short* VT)
static void VNAND(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_nand(state, state->VR[vd], state->VR[vs], ST);

View File

@ -39,7 +39,7 @@ INLINE static void do_ne(usf_state_t * state, short* VD, short* VS, short* VT)
static void VNE(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_ne(state, state->VR[vd], state->VR[vs], ST);

View File

@ -13,7 +13,7 @@
\******************************************************************************/
#include "vu.h"
static void VNOP(int vd, int vs, int vt, int e)
static void VNOP(usf_state_t * state, int vd, int vs, int vt, int e)
{
const int WB_inhibit = vd = vs = vt = e = 1;

View File

@ -25,7 +25,7 @@ INLINE void do_nor(usf_state_t * state, short* VD, short* VS, short* VT)
static void VNOR(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_nor(state, state->VR[vd], state->VR[vs], ST);

View File

@ -25,7 +25,7 @@ INLINE void do_nxor(usf_state_t * state, short* VD, short* VS, short* VT)
static void VNXOR(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_nxor(state, state->VR[vd], state->VR[vs], ST);

View File

@ -25,7 +25,7 @@ INLINE void do_or(usf_state_t * state, short* VD, short* VS, short* VT)
static void VOR(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_or(state, state->VR[vd], state->VR[vs], ST);

View File

@ -16,7 +16,7 @@
#ifdef VU_EMULATE_SCALAR_ACCUMULATOR_READ
static void VSAR(int vd, int vs, int vt, int e)
{
short oldval[N];
ALIGNED short oldval[N];
register int i;
for (i = 0; i < N; i++)

View File

@ -29,7 +29,7 @@ INLINE static void clr_bi(usf_state_t * state, short* VD, short* VS, short* VT)
static void VSUB(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
clr_bi(state, state->VR[vd], state->VR[vs], ST);

View File

@ -15,7 +15,7 @@
INLINE static void set_bo(usf_state_t * state, short* VD, short* VS, short* VT)
{ /* set CARRY and borrow out from difference */
int32_t dif[N];
ALIGNED int32_t dif[N];
register int i;
for (i = 0; i < N; i++)
@ -32,7 +32,7 @@ INLINE static void set_bo(usf_state_t * state, short* VD, short* VS, short* VT)
static void VSUBC(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
set_bo(state, state->VR[vd], state->VR[vs], ST);

View File

@ -25,7 +25,7 @@ INLINE void do_xor(usf_state_t * state, short* VD, short* VS, short* VT)
static void VXOR(usf_state_t * state, int vd, int vs, int vt, int e)
{
short ST[N];
ALIGNED short ST[N];
SHUFFLE_VECTOR(ST, state->VR[vt], e);
do_xor(state, state->VR[vd], state->VR[vs], ST);

View File

@ -73,7 +73,7 @@ test=(BYTE *) VirtualAlloc( 0x10, 0x70000, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
*/
void SetupTLB_Entry (usf_state_t * state, int Entry) {
uint32_t FastIndx;
int32_t FastIndx;
if (!state->tlb[Entry].EntryDefined) { return; }
@ -157,7 +157,7 @@ uint32_t TranslateVaddr ( usf_state_t * state, uintptr_t * Addr) {
}
void WriteTLBEntry (usf_state_t * state, int32_t index) {
uint32_t FastIndx;
int32_t FastIndx;
FastIndx = index << 1;
if ((state->PROGRAM_COUNTER >= state->FastTlb[FastIndx].VSTART &&

View File

@ -13,14 +13,14 @@
#include "usf_internal.h"
ssize_t get_usf_state_size()
size_t get_usf_state_size()
{
return sizeof(usf_state_t) + 8192;
}
void usf_clear(void * state)
{
ssize_t offset;
size_t offset;
memset(state, 0, get_usf_state_size());
offset = 4096 - (((uintptr_t)state) & 4095);
USF_STATE_HELPER->offset_to_structure = offset;
@ -85,7 +85,7 @@ static uint32_t get_le32( const void * _p )
return p[0] + p[1] * 0x100 + p[2] * 0x10000 + p[3] * 0x1000000;
}
int usf_upload_section(void * state, const uint8_t * data, ssize_t size)
int usf_upload_section(void * state, const uint8_t * data, size_t size)
{
uint32_t temp;
@ -103,8 +103,8 @@ int usf_upload_section(void * state, const uint8_t * data, ssize_t size)
start = get_le32( data ); data += 4; size -= 4;
while(len) {
int page = start >> 16;
int readLen = ( ((start + len) >> 16) > page) ? (((page + 1) << 16) - start) : len;
uint32_t page = start >> 16;
uint32_t readLen = ( ((start + len) >> 16) > page) ? (((page + 1) << 16) - start) : len;
if( USF_STATE->ROMPages[page] == 0 ) {
USF_STATE->ROMPages[page] = malloc(0x10000);
@ -172,14 +172,14 @@ static void usf_startup(void * state)
StartEmulationFromSave(USF_STATE, USF_STATE->savestatespace);
}
void usf_render(void * state, int16_t * buffer, ssize_t count, int32_t * sample_rate)
void usf_render(void * state, int16_t * buffer, size_t count, int32_t * sample_rate)
{
if ( !USF_STATE->MemoryState )
usf_startup( USF_STATE );
if ( USF_STATE->samples_in_buffer )
{
ssize_t do_max = USF_STATE->samples_in_buffer;
size_t do_max = USF_STATE->samples_in_buffer;
if ( do_max > count )
do_max = count;

View File

@ -21,16 +21,16 @@ typedef struct usf_state_helper usf_state_helper_t;
extern "C" {
#endif
ssize_t get_usf_state_size();
size_t get_usf_state_size();
void usf_clear(void * state);
void usf_set_compare(void * state, int enable);
void usf_set_fifo_full(void * state, int enable);
int usf_upload_section(void * state, const uint8_t * data, ssize_t size);
int usf_upload_section(void * state, const uint8_t * data, size_t size);
void usf_render(void * state, int16_t * buffer, ssize_t count, int32_t * sample_rate);
void usf_render(void * state, int16_t * buffer, size_t count, int32_t * sample_rate);
void usf_shutdown(void * state);

View File

@ -3,7 +3,7 @@
struct usf_state_helper
{
ssize_t offset_to_structure;
size_t offset_to_structure;
};
typedef uint32_t RCPREG;
@ -46,13 +46,13 @@ struct usf_state
uint32_t enablecompare, enableFIFOfull;
// buffering for rendered sample data
ssize_t sample_buffer_count;
size_t sample_buffer_count;
int16_t * sample_buffer;
// audio.c
int32_t SampleRate;
int16_t samplebuf[16384];
ssize_t samples_in_buffer;
size_t samples_in_buffer;
// cpu.c
uint32_t NextInstruction, JumpToLocation, AudioIntrReg;