Bring up to date with PCSX-R master (97809)

This commit is contained in:
iCatButler 2016-03-30 15:07:35 +01:00
parent e3df273095
commit 8b4350fee7
37 changed files with 2643 additions and 2306 deletions

File diff suppressed because it is too large Load Diff

View File

@ -899,6 +899,12 @@ void OnCpu_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
sscanf(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "GtkEntry_RewindInterval"))), "%lu", &tmp);
Config.RewindInterval = tmp;
sscanf(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "GtkEntry_AltSpeed1"))), "%lu", &tmp);
Config.AltSpeed1 = tmp;
sscanf(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "GtkEntry_AltSpeed2"))), "%lu", &tmp);
Config.AltSpeed2 = tmp;
Config.Xa = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "GtkCheckButton_Xa")));
Config.SioIrq = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "GtkCheckButton_SioIrq")));
Config.Mdec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "GtkCheckButton_Mdec")));
@ -981,6 +987,14 @@ void OnConf_Cpu() {
// Enabled only if interpreter
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(builder, "frame_rew")), Config.Cpu);
snprintf(buf, sizeof(buf), "%u", Config.AltSpeed1);
widget = GTK_WIDGET(gtk_builder_get_object(builder, "GtkEntry_AltSpeed1"));
gtk_entry_set_text(GTK_ENTRY(widget), buf);
snprintf(buf, sizeof(buf), "%u", Config.AltSpeed2);
widget = GTK_WIDGET(gtk_builder_get_object(builder, "GtkEntry_AltSpeed2"));
gtk_entry_set_text(GTK_ENTRY(widget), buf);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "GtkCheckButton_Xa")), Config.Xa);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "GtkCheckButton_SioIrq")), Config.SioIrq);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "GtkCheckButton_Mdec")), Config.Mdec);

View File

@ -148,6 +148,13 @@ int LoadConfig(PcsxConfig *Conf) {
Config.RewindCount = GetValuel(data, "RewindCount");
Config.RewindInterval = GetValuel(data, "RewindInterval");
Config.AltSpeed1 = GetValuel(data, "AltSpeed1");
if (!Config.AltSpeed1)
Config.AltSpeed1 = 50;
Config.AltSpeed2 = GetValuel(data, "AltSpeed2");
if (!Config.AltSpeed2)
Config.AltSpeed2 = 250;
Config.HackFix = GetValuel(data, "HackFix");
free(data);
@ -199,6 +206,9 @@ void SaveConfig() {
SetValuel("RewindCount", Config.RewindCount);
SetValuel("RewindInterval", Config.RewindInterval);
SetValuel("AltSpeed1", Config.AltSpeed1);
SetValuel("AltSpeed2", Config.AltSpeed2);
SetValuel("HackFix", Config.HackFix);
fclose(f);

View File

@ -229,7 +229,11 @@ gchar* get_state_filename(int i) {
trimlabel = get_cdrom_label_trim();
sprintf(SStateFile, "%.32s-%.9s.%3.3d", trimlabel, CdromId, i);
if (i >= OLD_SLOT && i <= LAST_OLD_SLOT) {
sprintf(SStateFile, "%.32s-%.9s.old_%d", trimlabel, CdromId, i - OLD_SLOT);
} else {
sprintf(SStateFile, "%.32s-%.9s.%3.3d", trimlabel, CdromId, i);
}
state_filename = g_build_filename (getenv("HOME"), STATES_DIR, SStateFile, NULL);
g_free(trimlabel);

View File

@ -37,6 +37,10 @@
#define CHEATS_DIR "/.pcsxr/cheats/"
#define PATCHES_DIR "/.pcsxr/patches/"
#define OLD_SLOT 1000
#define NUM_OLD_SLOTS 2
#define LAST_OLD_SLOT (OLD_SLOT + NUM_OLD_SLOTS - 1)
extern gboolean UseGui;
extern int StatesC;
char cfgfile[MAXPATHLEN]; /* ADB Comment this out - make a local var, or at least use gchar funcs */

View File

@ -137,7 +137,7 @@ static gchar* MCDStatusToChar(McdBlock *Info) {
state = _("Link");
else if (ISLINKENDBLOCK(Info))
state = _("End link");
} else
} else
state = _("Free");
return state;
}
@ -203,8 +203,20 @@ static void LoadListItems(int mcd, boolean newstore) {
if (newstore) gtk_list_store_append(store, &iter);
GError *error=NULL;
title = g_convert(Info->sTitle, strlen(Info->sTitle), "UTF-8",
"Shift-JIS", NULL, NULL, NULL);
"Shift-JIS", NULL, NULL, &error);
if (error)
{
// Some characters caused problems because of custom encoding.
// Let's use the ASCII title as fallback.
// Otherwise custom decoding from that region
// of BIOS needed which is way overkill here.
title = g_convert(Info->Title, strlen(Info->Title), "UTF-8",
"Shift-JIS", NULL, NULL, NULL);
g_clear_error(&error);
}
gtk_list_store_set(store, &iter,
CL_ICON, pixbuf,

View File

@ -42,6 +42,8 @@ extern void LidInterrupt();
unsigned long gpuDisp;
int StatesC = 0;
unsigned char loadedOld = FALSE;
int speed = 100;
extern int UseGui;
void gpuShowPic() {
@ -77,9 +79,23 @@ void gpuShowPic() {
void KeyStateSave(int i) {
gchar *state_filename;
gchar *oldname, *newname;
int j;
state_filename = get_state_filename (i);
if (i < OLD_SLOT && !loadedOld) {
newname = get_state_filename (LAST_OLD_SLOT);
for (j = LAST_OLD_SLOT - 1; j >= OLD_SLOT; --j) {
oldname = get_state_filename (j);
rename(oldname, newname);
g_free (newname);
newname = oldname;
}
rename(state_filename, newname);
g_free (newname);
}
state_save (state_filename);
loadedOld = FALSE;
g_free (state_filename);
}
@ -87,6 +103,8 @@ void KeyStateSave(int i) {
void KeyStateLoad(int i) {
gchar *state_filename;
loadedOld = (i >= OLD_SLOT && i <= LAST_OLD_SLOT);
state_filename = get_state_filename (i);
state_load (state_filename);
@ -108,6 +126,7 @@ void PADhandleKey(int key) {
char Text[MAXPATHLEN];
gchar *state_filename;
time_t now;
int slot;
short rel = 0; //released key flag
@ -155,69 +174,20 @@ void PADhandleKey(int key) {
if (modalt) KeyStateLoad(10);
break;
case XK_1:
case XK_1: case XK_2: case XK_3: case XK_4: case XK_5:
case XK_6: case XK_7: case XK_8: case XK_9:
slot = key - XK_1;
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(0);
if (modctrl) KeyStateSave(0);
break;
case XK_2:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(1);
if (modctrl) KeyStateSave(1);
break;
case XK_3:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(2);
if (modctrl) KeyStateSave(2);
break;
case XK_4:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(3);
if (modctrl) KeyStateSave(3);
break;
case XK_5:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(4);
if (modctrl) KeyStateSave(4);
break;
case XK_6:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(5);
if (modctrl) KeyStateSave(5);
break;
case XK_7:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(6);
if (modctrl) KeyStateSave(6);
break;
case XK_8:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(7);
if (modctrl) KeyStateSave(7);
break;
case XK_9:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(8);
if (modctrl) KeyStateSave(8);
if (modalt) KeyStateLoad(slot);
else if (modctrl) KeyStateSave(slot);
else KeyStateLoad(OLD_SLOT + slot);
break;
case XK_F1:
GPU_freeze(2, (GPUFreeze_t *)&StatesC);
state_filename = get_state_filename (StatesC);
state_save (state_filename);
g_free (state_filename);
KeyStateSave(StatesC);
gpuShowPic();
break;
case XK_F2:
if (StatesC < (MAX_SLOTS - 1)) StatesC++;
@ -226,15 +196,7 @@ void PADhandleKey(int key) {
gpuShowPic();
break;
case XK_F3:
state_filename = get_state_filename (StatesC);
state_load (state_filename);
g_free (state_filename);
// HACKHACK: prevent crash when using recompiler due to execution not
// returned from compiled code. This WILL cause memory leak, however a
// large amount of refactor is needed for a proper fix.
if (Config.Cpu == CPU_DYNAREC) psxCpu->Execute();
KeyStateLoad(StatesC);
gpuShowPic();
break;
case XK_F4:
@ -290,6 +252,22 @@ void PADhandleKey(int key) {
tslastpressed = now;
RewindState();
break;
case XK_bracketleft:
if (speed == Config.AltSpeed1) {
speed = 100;
} else {
speed = Config.AltSpeed1;
}
GPU_setSpeed(speed / 100.0);
break;
case XK_bracketright:
if (speed == Config.AltSpeed2) {
speed = 100;
} else {
speed = Config.AltSpeed2;
}
GPU_setSpeed(speed / 100.0);
break;
case XK_Escape:
// TODO
// the architecture is too broken to actually restart the GUI
@ -298,8 +276,10 @@ void PADhandleKey(int key) {
// Fixing this would probably require a complete reworking of
// all functions, so that they return 0 or 1 for success
// that way, execution wouldn't continue
if (CdromId[0] != '\0')
if (CdromId[0] != '\0') {
loadedOld = TRUE;
KeyStateSave(10);
}
ClosePlugins();
UpdateMenuSlots();
if (!UseGui) OnFile_Exit();

View File

@ -1328,7 +1328,7 @@ void cdrWrite1(unsigned char rt) {
set_loc[i] = btoi(cdr.Param[i]);
i = msf2sec(cdr.SetSectorPlay);
i = abs(i - msf2sec(set_loc));
i = abs(i - (int)msf2sec(set_loc));
if (i > 16)
cdr.Seeked = SEEK_PENDING;

View File

@ -418,6 +418,8 @@ static int recInit() {
for (i = 0; i < 0x08; i++) psxRecLUT[i + 0xbfc0] = (u32)&recROM[i << 16];
x86Init();
return 0;
}
@ -425,8 +427,6 @@ static void recReset() {
memset(recRAM, 0, 0x200000);
memset(recROM, 0, 0x080000);
x86Init();
x86SetPtr(recMem);
branch = 0;

View File

@ -482,6 +482,9 @@ static int recInit() {
for (i=0; i<0x08; i++) psxRecLUT[i + 0xbfc0] = (uptr)&recROM[PTRMULT*(i << 16)];
//x86Init();
cpudetectInit();
return 0;
}
@ -489,8 +492,6 @@ static void recReset() {
memset(recRAM, 0, 0x200000 * PTRMULT);
memset(recROM, 0, 0x080000 * PTRMULT);
//x86Init();
cpudetectInit();
x86SetPtr(recMem);
branch = 0;

View File

@ -229,8 +229,17 @@ int LoadCdromFile(const char *filename, EXE_HEADER *head) {
u8 time[4],*buf;
u8 mdir[4096], exename[256];
u32 size, addr;
void *psxaddr;
sscanf(filename, "cdrom:\\%255s", exename);
if (sscanf(filename, "cdrom:\\%255s", exename) <= 0)
{
// Some games omit backslash (NFS4)
if (sscanf(filename, "cdrom:%255s", exename) <= 0)
{
SysPrintf("LoadCdromFile: EXE NAME PARSING ERROR (%s (%u))\n", filename, strlen(filename));
exit (1);
}
}
time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10);
@ -259,7 +268,9 @@ int LoadCdromFile(const char *filename, EXE_HEADER *head) {
incTime();
READTRACK();
memcpy((void *)PSXM(addr), buf + 12, 2048);
psxaddr = (void *)PSXM(addr);
assert(psxaddr != NULL);
memcpy(psxaddr, buf + 12, 2048);
size -= 2048;
addr += 2048;
@ -360,13 +371,15 @@ int CheckCdrom() {
static int PSXGetFileType(FILE *f) {
unsigned long current;
u8 mybuf[2048];
u8 mybuf[sizeof(EXE_HEADER)]; // EXE_HEADER currently biggest
EXE_HEADER *exe_hdr;
FILHDR *coff_hdr;
size_t amt;
memset(mybuf, 0, sizeof(mybuf));
current = ftell(f);
fseek(f, 0L, SEEK_SET);
fread(mybuf, 2048, 1, f);
amt = fread(mybuf, sizeof(mybuf), 1, f);
fseek(f, current, SEEK_SET);
exe_hdr = (EXE_HEADER *)mybuf;
@ -408,6 +421,7 @@ int Load(const char *ExePath) {
int retval = 0;
u8 opcode;
u32 section_address, section_size;
void* psxmaddr;
strncpy(CdromId, "SLUS99999", 9);
strncpy(CdromLabel, "SLUS_999.99", 11);
@ -479,7 +493,9 @@ int Load(const char *ExePath) {
fseek(tmpFile, SWAP32(section.s_scnptr), SEEK_SET);
fread(PSXM(SWAP32(section.s_paddr)), SWAP32(section.s_size), 1, tmpFile);
} else {
memset(PSXM(SWAP32(section.s_paddr)), 0, SWAP32(section.s_size));
psxmaddr = PSXM(SWAP32(section.s_paddr));
assert(psxmaddr != NULL);
memset(psxmaddr, 0, SWAP32(section.s_size));
}
}
break;

View File

@ -54,6 +54,7 @@ GPUvBlank GPU_vBlank;
GPUvisualVibration GPU_visualVibration;
GPUcursor GPU_cursor;
GPUaddVertex GPU_addVertex;
GPUsetSpeed GPU_setSpeed;
GPUpgxpMemory GPU_pgxpMemory;
CDRinit CDR_init;
@ -215,6 +216,7 @@ void CALLBACK GPU__vBlank(int val) {}
void CALLBACK GPU__visualVibration(unsigned long iSmall, unsigned long iBig) {}
void CALLBACK GPU__cursor(int player, int x, int y) {}
void CALLBACK GPU__addVertex(short sx,short sy,s64 fx,s64 fy,s64 fz) {}
void CALLBACK GPU__setSpeed(float newSpeed) {}
void CALLBACK GPU__pgxpMemory(unsigned char* pMem, unsigned int count, unsigned int addr, unsigned char* pVRAM) {}
#define LoadGpuSym1(dest, name) \
@ -261,6 +263,7 @@ static int LoadGPUplugin(const char *GPUdll) {
LoadGpuSym0(visualVibration, "GPUvisualVibration");
LoadGpuSym0(cursor, "GPUcursor");
LoadGpuSym0(addVertex, "GPUaddVertex");
LoadGpuSym0(setSpeed, "GPUsetSpeed");
LoadGpuSym0(pgxpMemory, "GPUpgxpMemory");
LoadGpuSym0(configure, "GPUconfigure");
LoadGpuSym0(test, "GPUtest");

View File

@ -96,6 +96,7 @@ typedef void (CALLBACK* GPUvBlank)(int);
typedef void (CALLBACK* GPUvisualVibration)(uint32_t, uint32_t);
typedef void (CALLBACK* GPUcursor)(int, int, int);
typedef void (CALLBACK* GPUaddVertex)(short,short,s64,s64,s64);
typedef void (CALLBACK* GPUsetSpeed)(float); // 1.0 = natural speed
typedef void (CALLBACK* GPUpgxpMemory)(unsigned int, unsigned char*);
// GPU function pointers
@ -126,6 +127,7 @@ extern GPUvBlank GPU_vBlank;
extern GPUvisualVibration GPU_visualVibration;
extern GPUcursor GPU_cursor;
extern GPUaddVertex GPU_addVertex;
extern GPUsetSpeed GPU_setSpeed;
extern GPUpgxpMemory GPU_pgxpMemory;
// CD-ROM Functions

View File

@ -165,12 +165,21 @@ char *biosC0n[256] = {
#define ra (psxRegs.GPR.n.ra)
#define pc0 (psxRegs.pc)
#ifdef __NO_ASSERTS__
#define Ra0 ((char *)PSXM(a0))
#define Ra1 ((char *)PSXM(a1))
#define Ra2 ((char *)PSXM(a2))
#define Ra3 ((char *)PSXM(a3))
#define Rv0 ((char *)PSXM(v0))
#define Rsp ((char *)PSXM(sp))
#else
#define Ra0 (assert(PSXM(a0) != NULL), (char *)PSXM(a0))
#define Ra1 (assert(PSXM(a1) != NULL), (char *)PSXM(a1))
#define Ra2 (assert(PSXM(a2) != NULL), (char *)PSXM(a2))
#define Ra3 (assert(PSXM(a3) != NULL), (char *)PSXM(a3))
#define Rv0 (assert(PSXM(v0) != NULL), (char *)PSXM(v0))
#define Rsp (assert(PSXM(sp) != NULL), (char *)PSXM(sp))
#endif
typedef struct {
u32 desc;
@ -655,7 +664,7 @@ void psxBios_memset() { // 0x2b
while((s32)a2 > 0)
{
a2--;
psxMu8ref(a0) = a1;
*PSXM(a0) = a1;
a0++;
}
}
@ -964,7 +973,7 @@ void psxBios_printf() { // 0x3f
char *ptmp = tmp;
int n=1, i=0, j;
memcpy(save, (char*)PSXM(sp), 4 * 4);
memcpy(save, Rsp, 4 * 4);
psxMu32ref(sp) = SWAP32((u32)a0);
psxMu32ref(sp + 4) = SWAP32((u32)a1);
psxMu32ref(sp + 8) = SWAP32((u32)a2);
@ -1018,7 +1027,7 @@ _start:
}
*ptmp = 0;
memcpy((char*)PSXM(sp), save, 4 * 4);
memcpy(Rsp, save, 4 * 4);
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: %s\n", biosA0n[0x3f], tmp);
@ -1273,16 +1282,34 @@ void psxBios_SetMem() { // 9f
}
void psxBios__card_info() { // ab
// COTS password option
boolean nocard = (Config.NoMemcard || ((strlen(Config.Mcd1) <=0) && (strlen(Config.Mcd2) <=0)));
u32 ret;
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: %x\n", biosA0n[0xab], a0);
PSXBIOS_LOG("psxBios_%s: 0x%x\n", biosA0n[0xab], a0);
#endif
card_active_chan = a0;
switch (card_active_chan) {
case 0x00: case 0x01: case 0x02: case 0x03:
ret = Config.Mcd1[0] ? 0x2 : 0x8;
break;
case 0x10: case 0x11: case 0x12: case 0x13:
ret = Config.Mcd2[0] ? 0x2 : 0x8;
break;
default:
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: UNKNOWN PORT 0x%x\n", biosA0n[0xab], card_active_chan);
#endif
ret = 0x11;
break;
}
// COTS password option
if (Config.NoMemcard)
ret = 0x8;
// DeliverEvent(0x11, 0x2); // 0xf0000011, 0x0004
DeliverEvent(0x81, nocard ? 0x8 : 0x2); // 0xf4000001, 0x0004
DeliverEvent(0x81, ret); // 0xf4000001, 0x0004
v0 = 1; pc0 = ra;
}
@ -1673,43 +1700,68 @@ void psxBios_UnDeliverEvent() { // 0x20
pc0 = ra;
}
#define buopen(mcd) { \
strcpy(FDesc[1 + mcd].name, Ra0+5); \
FDesc[1 + mcd].offset = 0; \
FDesc[1 + mcd].mode = a1; \
\
for (i=1; i<16; i++) { \
ptr = Mcd##mcd##Data + 128 * i; \
if ((*ptr & 0xF0) != 0x50) continue; \
if (strcmp(FDesc[1 + mcd].name, ptr+0xa)) continue; \
FDesc[1 + mcd].mcfile = i; \
SysPrintf("open %s\n", ptr+0xa); \
v0 = 1 + mcd; \
break; \
} \
if (a1 & 0x200 && v0 == -1) { /* FCREAT */ \
for (i=1; i<16; i++) { \
int j, xor = 0; \
\
ptr = Mcd##mcd##Data + 128 * i; \
if ((*ptr & 0xF0) == 0x50) continue; \
ptr[0] = 0x50 | (u8)(a1 >> 16); \
ptr[4] = 0x00; \
ptr[5] = 0x20; \
ptr[6] = 0x00; \
ptr[7] = 0x00; \
ptr[8] = 'B'; \
ptr[9] = 'I'; \
strcpy(ptr+0xa, FDesc[1 + mcd].name); \
for (j=0; j<127; j++) xor^= ptr[j]; \
ptr[127] = xor; \
FDesc[1 + mcd].mcfile = i; \
SysPrintf("openC %s\n", ptr); \
v0 = 1 + mcd; \
SaveMcd(Config.Mcd##mcd, Mcd##mcd##Data, 128 * i, 128); \
break; \
} \
} \
static void buopen(int mcd, u8 *ptr, u8 *cfg)
{
int i;
u8 *fptr = ptr;
strcpy(FDesc[1 + mcd].name, Ra0+5);
FDesc[1 + mcd].offset = 0;
FDesc[1 + mcd].mode = a1;
for (i=1; i<16; i++) {
fptr += 128;
if ((*fptr & 0xF0) != 0x50) continue;
if (strcmp(FDesc[1 + mcd].name, fptr+0xa)) continue;
FDesc[1 + mcd].mcfile = i;
SysPrintf("open %s\n", fptr+0xa);
v0 = 1 + mcd;
break;
}
if (a1 & 0x200 && v0 == -1) { /* FCREAT */
fptr = ptr;
for (i=1; i<16; i++) {
int j, xor, nblk = a1 >> 16;
u8 *pptr, *fptr2;
fptr += 128;
if ((*fptr & 0xF0) != 0xa0) continue;
FDesc[1 + mcd].mcfile = i;
fptr[0] = 0x51;
fptr[4] = 0x00;
fptr[5] = 0x20 * nblk;
fptr[6] = 0x00;
fptr[7] = 0x00;
strcpy(fptr+0xa, FDesc[1 + mcd].name);
pptr = fptr2 = fptr;
for(j=2; j<=nblk; j++) {
int k;
for(i++; i<16; i++) {
fptr2 += 128;
memset(fptr2, 0, 128);
fptr2[0] = j < nblk ? 0x52 : 0x53;
pptr[8] = i - 1;
pptr[9] = 0;
for (k=0, xor=0; k<127; k++) xor^= pptr[k];
pptr[127] = xor;
pptr = fptr2;
break;
}
/* shouldn't this return ENOSPC if i == 16? */
}
pptr[8] = pptr[9] = 0xff;
for (j=0, xor=0; j<127; j++) xor^= pptr[j];
pptr[127] = xor;
SysPrintf("openC %s %d\n", ptr, nblk);
v0 = 1 + mcd;
/* just go ahead and resave them all */
SaveMcd(cfg, ptr, 128, 128 * 15);
break;
}
/* shouldn't this return ENOSPC if i == 16? */
}
}
/*
@ -1717,8 +1769,7 @@ void psxBios_UnDeliverEvent() { // 0x20
*/
void psxBios_open() { // 0x32
int i;
char *ptr;
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: %s,%x\n", biosB0n[0x32], Ra0, a1);
@ -1727,11 +1778,11 @@ void psxBios_open() { // 0x32
v0 = -1;
if (!strncmp(Ra0, "bu00", 4)) {
buopen(1);
buopen(1, Mcd1Data, Config.Mcd1);
}
if (!strncmp(Ra0, "bu10", 4)) {
buopen(2);
buopen(2, Mcd2Data, Config.Mcd2);
}
pc0 = ra;
@ -1770,7 +1821,7 @@ void psxBios_lseek() { // 0x33
if (FDesc[1 + mcd].mode & 0x8000) v0 = 0; \
else v0 = a2; \
FDesc[1 + mcd].offset += v0; \
DeliverEvent(0x11, 0x2); /* 0xf0000011, 0x0004 */ \
DeliverEvent(0x11, 0x2); /* 0xf0000011, 0x0004 */ \
DeliverEvent(0x81, 0x2); /* 0xf4000001, 0x0004 */ \
}
@ -1791,7 +1842,7 @@ void psxBios_read() { // 0x34
case 2: buread(1); break;
case 3: buread(2); break;
}
pc0 = ra;
}
@ -1804,7 +1855,7 @@ void psxBios_read() { // 0x34
SaveMcd(Config.Mcd##mcd, Mcd##mcd##Data, offset, a2); \
if (FDesc[1 + mcd].mode & 0x8000) v0 = 0; \
else v0 = a2; \
DeliverEvent(0x11, 0x2); /* 0xf0000011, 0x0004 */ \
DeliverEvent(0x11, 0x2); /* 0xf0000011, 0x0004 */ \
DeliverEvent(0x81, 0x2); /* 0xf4000001, 0x0004 */ \
}
@ -1855,21 +1906,21 @@ char psxstrbuf[PSXSTRBUFMAX+1];
unsigned short psxstrbuf_count = 0;
void psxBios_putchar() { // 3d
char logchar = ( a0 == 0xa ? '>' : (char)a0 );
if (psxstrbuf_count < PSXSTRBUFMAX) psxstrbuf[psxstrbuf_count++] = logchar;
char logchar = ( a0 == 0xa ? '>' : (char)a0 );
if (psxstrbuf_count < PSXSTRBUFMAX) psxstrbuf[psxstrbuf_count++] = logchar;
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: %x (%c)\n", biosB0n[0x3d], a0, logchar);
#else
SysPrintf("%c", (char)a0);
#endif
if ((a0 == 0xa && psxstrbuf_count >= 2) || psxstrbuf_count >= PSXSTRBUFMAX) {
psxstrbuf[psxstrbuf_count++] = '\0';
if ((a0 == 0xa && psxstrbuf_count >= 2) || psxstrbuf_count >= PSXSTRBUFMAX) {
psxstrbuf[psxstrbuf_count++] = '\0';
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: string_[%d]_cr: %s\n", biosB0n[0x3d], psxstrbuf_count, psxstrbuf);
PSXBIOS_LOG("psxBios_%s: string_[%d]_cr: %s\n", biosB0n[0x3d], psxstrbuf_count, psxstrbuf);
#endif
psxstrbuf_count = 0;
}
psxstrbuf_count = 0;
}
pc0 = ra;
}
@ -1890,17 +1941,18 @@ int nfile;
while (nfile < 16) { \
int match=1; \
\
ptr = Mcd##mcd##Data + 128 * nfile; \
ptr = Mcd##mcd##Data + 128 * (nfile + 1); \
nfile++; \
if ((*ptr & 0xF0) != 0x50) continue; \
/* Bug link files show up as free block. */ \
if (!ptr[0xa]) continue; \
ptr+= 0xa; \
if (pfile[0] == 0) { \
strncpy(dir->name, ptr, sizeof(dir->name)); \
dir->name[sizeof(dir->name) - 1] = '\0'; \
dir->name[sizeof(dir->name)] = '\0'; \
} else for (i=0; i<20; i++) { \
if (pfile[i] == ptr[i]) { \
dir->name[i] = ptr[i]; \
if (ptr[i] == 0) break; else continue; } \
dir->name[i] = ptr[i]; continue; } \
if (pfile[i] == '?') { \
dir->name[i] = ptr[i]; continue; } \
if (pfile[i] == '*') { \
@ -1908,7 +1960,7 @@ int nfile;
match = 0; break; \
} \
SysPrintf("%d : %s = %s + %s (match=%d)\n", nfile, dir->name, pfile, ptr, match); \
if (match == 0) continue; \
if (match == 0) { continue; } \
dir->size = 8192; \
v0 = _dir; \
break; \
@ -1933,10 +1985,13 @@ void psxBios_firstfile() { // 42
strcpy(ffile, Ra0);
pfile = ffile+5;
nfile = 1;
nfile = 0;
if (!strncmp(Ra0, "bu00", 4)) {
DeliverEvent(0x11, 0x2);
bufile(1);
} else if (!strncmp(Ra0, "bu10", 4)) {
DeliverEvent(0x11, 0x2);
bufile(2);
}
@ -2082,21 +2137,21 @@ void psxBios_StopCARD() { // 4c
}
void psxBios__card_write() { // 0x4e
int port;
int const port = a0 >> 4;
u32 const sect = a1 % (MCD_SIZE/8); // roll on range 0...3FFF
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: %x,%x,%x\n", biosB0n[0x4e], a0, a1, a2);
PSXBIOS_LOG("psxBios_%s, PORT=%i, SECT=%u(%u), DEST=%p\n", biosB0n[0x4e], port, sect, a1, a2);
#endif
card_active_chan = a0;
port = a0 >> 4;
if (port == 0) {
memcpy(Mcd1Data + a1 * 128, Ra2, 128);
SaveMcd(Config.Mcd1, Mcd1Data, a1 * 128, 128);
memcpy(Mcd1Data + (sect * MCD_SECT_SIZE), Ra2, MCD_SECT_SIZE);
SaveMcd(Config.Mcd1, Mcd1Data, sect * MCD_SECT_SIZE, MCD_SECT_SIZE);
} else {
memcpy(Mcd2Data + a1 * 128, Ra2, 128);
SaveMcd(Config.Mcd2, Mcd2Data, a1 * 128, 128);
memcpy(Mcd2Data + (sect * MCD_SECT_SIZE), Ra2, MCD_SECT_SIZE);
SaveMcd(Config.Mcd2, Mcd2Data, sect * MCD_SECT_SIZE, MCD_SECT_SIZE);
}
DeliverEvent(0x11, 0x2); // 0xf0000011, 0x0004
@ -2106,19 +2161,19 @@ void psxBios__card_write() { // 0x4e
}
void psxBios__card_read() { // 0x4f
int port;
int const port = a0 >> 4;
u32 const sect = a1 % (MCD_SIZE/8); // roll on range 0...3FFF
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s\n", biosB0n[0x4f]);
PSXBIOS_LOG("psxBios_%s, PORT=%i, SECT=%u(%u), DEST=%p\n", biosB0n[0x4f], port, sect, a1, a2);
#endif
card_active_chan = a0;
port = a0 >> 4;
if (port == 0) {
memcpy(Ra2, Mcd1Data + a1 * 128, 128);
memcpy(Ra2, Mcd1Data + (sect * MCD_SECT_SIZE), MCD_SECT_SIZE);
} else {
memcpy(Ra2, Mcd2Data + a1 * 128, 128);
memcpy(Ra2, Mcd2Data + (sect * MCD_SECT_SIZE), MCD_SECT_SIZE);
}
DeliverEvent(0x11, 0x2); // 0xf0000011, 0x0004
@ -2178,6 +2233,15 @@ void psxBios_Krom2RawAdd() { // 0x51
pc0 = ra;
}
// stub?
void psxBios__get_error() { // 55
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s\n", biosB0n[0x55]);
#endif
v0 = 0; pc0 = ra;
}
void psxBios_GetC0Table() { // 56
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s\n", biosB0n[0x56]);
@ -2566,7 +2630,7 @@ void psxBiosInit() {
//biosB0[0x52] = psxBios_sys_b0_52;
//biosB0[0x53] = psxBios_sys_b0_53;
//biosB0[0x54] = psxBios__get_errno;
//biosB0[0x55] = psxBios__get_error;
biosB0[0x55] = psxBios__get_error;
biosB0[0x56] = psxBios_GetC0Table;
biosB0[0x57] = psxBios_GetB0Table;
biosB0[0x58] = psxBios__card_chan;

View File

@ -159,6 +159,8 @@ typedef struct {
u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL
u32 RewindCount;
u32 RewindInterval;
u32 AltSpeed1; // Percent relative to natural speed.
u32 AltSpeed2;
u8 HackFix;
#ifdef _WIN32
char Lang[256];

View File

@ -59,6 +59,10 @@ void SaveDongle( char *str );
static unsigned char buf[ BUFFER_SIZE ];
//[0] -> dummy
//[1] -> memory card status flag
//[2] -> card 1 id, 0x5a->plugged, any other not plugged
//[3] -> card 2 id, 0x5d->plugged, any other not plugged
unsigned char cardh[4] = { 0x00, 0x08, 0x5a, 0x5d };
// Transfer Ready and the Buffer is Empty
@ -722,10 +726,12 @@ void sioWrite8(unsigned char value) {
StatReg |= RX_RDY;
// Chronicles of the Sword - no memcard = password options
if( Config.NoMemcard || ((strlen(Config.Mcd1) <=0) && (strlen(Config.Mcd2) <=0)) ) {
if( Config.NoMemcard || (!Config.Mcd1[0] && !Config.Mcd2[0])) {
memset(buf, 0x00, 4);
} else {
memcpy(buf, cardh, 4);
if (!Config.Mcd1[0]) buf[2]=0; // is card 1 plugged? (Codename Tenka)
if (!Config.Mcd2[0]) buf[3]=0; // is card 2 plugged?
}
parp = 0;
@ -883,8 +889,8 @@ void LoadMcd(int mcd, char *str) {
if (mcd == 2) data = Mcd2Data;
if (*str == 0) {
sprintf(str, "%s/.pcsxr/memcards/card%d.mcd", getenv("HOME"), mcd); // TODO: maybe just whine and quit..
SysPrintf(_("No memory card value was specified - using a default card %s\n"), str);
SysPrintf(_("No memory card value was specified - card %i is not plugged.\n"), mcd);
return;
}
f = fopen(str, "rb");
if (f == NULL) {

View File

@ -31,7 +31,8 @@ extern "C" {
#include "plugins.h"
#include "psemu_plugin_defs.h"
#define MCD_SIZE (1024 * 8 * 16)
#define MCD_SECT_SIZE (8 * 16)
#define MCD_SIZE (1024 * MCD_SECT_SIZE)
extern char Mcd1Data[MCD_SIZE], Mcd2Data[MCD_SIZE];

View File

@ -118,7 +118,7 @@ static OSStatus GeneratePreviewForMemCard(void *thisInterface, QLPreviewRequestR
NSDictionary *imgProps = @{(NSString *)kQLPreviewPropertyAttachmentDataKey: pngData,
(NSString *)kQLPreviewPropertyMIMETypeKey: @"image/png"};
NSString *imgName = [[@(i++) stringValue] stringByAppendingPathExtension:@"png"];
[htmlStr appendFormat:@"\t\t\t<tr><td><img src=\"cid:%@\"></td> <td>%@</td> <td>%i</td></tr>\n", imgName, obj.name, obj.blockSize];
[htmlStr appendFormat:@"\t\t\t<tr><td><img src=\"cid:%@\"></td> <td>%@</td> <td>%i</td></tr>\n", imgName, obj.title, obj.blockSize];
htmlDict[imgName] = imgProps;
continue;
}
@ -135,7 +135,7 @@ static OSStatus GeneratePreviewForMemCard(void *thisInterface, QLPreviewRequestR
NSDictionary *imgProps = @{(NSString *)kQLPreviewPropertyAttachmentDataKey: gifData,
(NSString *)kQLPreviewPropertyMIMETypeKey: @"image/gif"};
NSString *imgName = [[@(i++) stringValue] stringByAppendingPathExtension:@"gif"];
[htmlStr appendFormat:@"\t\t\t<tr><td><img src=\"cid:%@\"></td> <td>%@</td> <td>%i</td></tr>\n", imgName, obj.name, obj.blockSize];
[htmlStr appendFormat:@"\t\t\t<tr><td><img src=\"cid:%@\"></td> <td>%@</td> <td>%i</td></tr>\n", imgName, obj.title, obj.blockSize];
htmlDict[imgName] = imgProps;
}

View File

@ -98,31 +98,31 @@ static void GetSoloBlockInfo(unsigned char *data, int block, McdBlock *Info)
Info->Flags = *ptr;
ptr += 0xa;
strlcpy(Info->ID, ptr, 12);
strlcpy(Info->ID, ptr, 13);
ptr += 12;
strlcpy(Info->Name, ptr, 16);
strlcpy(Info->Name, ptr, 17);
}
static inline PCSXRMemFlag MemBlockFlag(unsigned char blockFlags)
{
if ((blockFlags & 0xF0) == 0xA0) {
if ((blockFlags & 0xF) >= 1 && (blockFlags & 0xF) <= 3)
return memFlagDeleted;
return PCSXRMemFlagDeleted;
else
return memFlagFree;
return PCSXRMemFlagFree;
} else if ((blockFlags & 0xF0) == 0x50) {
if ((blockFlags & 0xF) == 0x1)
return memFlagUsed;
return PCSXRMemFlagUsed;
else if ((blockFlags & 0xF) == 0x2)
return memFlagLink;
return PCSXRMemFlagLink;
else if ((blockFlags & 0xF) == 0x3)
return memFlagEndLink;
return PCSXRMemFlagEndLink;
} else
return memFlagFree;
return PCSXRMemFlagFree;
//Xcode complains unless we do this...
//NSLog(@"Unknown flag %x", blockFlags);
return memFlagFree;
return PCSXRMemFlagFree;
}
@ -151,7 +151,7 @@ NSArray *CreateArrayByEnumeratingMemoryCardAtURL(NSURL *location)
McdBlock memBlock;
GetSoloBlockInfo((unsigned char *)memPtr, i + 1, &memBlock);
if (MemBlockFlag(memBlock.Flags) == memFlagFree) {
if (MemBlockFlag(memBlock.Flags) == PCSXRMemFlagFree) {
//Free space: ignore
i++;
continue;
@ -170,7 +170,7 @@ NSArray *CreateArrayByEnumeratingMemoryCardAtURL(NSURL *location)
};
PcsxrMemoryObject *obj = [[PcsxrMemoryObject alloc] initWithMcdBlock:&memBlock startingIndex:i size:x];
i += x;
if (MemBlockFlag(memBlock.Flags) == memFlagDeleted) {
if (MemBlockFlag(memBlock.Flags) == PCSXRMemFlagDeleted) {
continue;
}
[memArray addObject:obj];

View File

@ -28,19 +28,19 @@
//
//==============================================================================
typedef NS_ENUM(NSInteger, PCSXRMemFlags) {
memFlagDeleted,
memFlagFree,
memFlagUsed,
memFlagLink,
memFlagEndLink
typedef NS_ENUM(char, PCSXRMemFlags) {
PCSXRMemFlagDeleted = 0,
PCSXRMemFlagFree,
PCSXRMemFlagUsed,
PCSXRMemFlagLink,
PCSXRMemFlagEndLink
};
static void GetSoloBlockInfo(unsigned char *data, int block, McdBlock *Info)
{
unsigned char *ptr = data + block * 8192 + 2;
unsigned char *str = Info->Title;
unsigned char * sstr = Info->sTitle;
unsigned char *sstr = Info->sTitle;
unsigned short c;
int i, x = 0;
@ -103,31 +103,31 @@ static void GetSoloBlockInfo(unsigned char *data, int block, McdBlock *Info)
Info->Flags = *ptr;
ptr += 0xa;
strlcpy(Info->ID, ptr, 12);
strlcpy(Info->ID, ptr, 13);
ptr += 12;
strlcpy(Info->Name, ptr, 16);
strlcpy(Info->Name, ptr, 17);
}
static inline PCSXRMemFlags MemBlockFlag(unsigned char blockFlags)
{
if ((blockFlags & 0xF0) == 0xA0) {
if ((blockFlags & 0xF) >= 1 && (blockFlags & 0xF) <= 3)
return memFlagDeleted;
return PCSXRMemFlagDeleted;
else
return memFlagFree;
return PCSXRMemFlagFree;
} else if ((blockFlags & 0xF0) == 0x50) {
if ((blockFlags & 0xF) == 0x1)
return memFlagUsed;
return PCSXRMemFlagUsed;
else if ((blockFlags & 0xF) == 0x2)
return memFlagLink;
return PCSXRMemFlagLink;
else if ((blockFlags & 0xF) == 0x3)
return memFlagEndLink;
return PCSXRMemFlagEndLink;
} else
return memFlagFree;
return PCSXRMemFlagFree;
//Xcode complains unless we do this...
//NSLog(@"Unknown flag %x", blockFlags);
return memFlagFree;
return PCSXRMemFlagFree;
}
Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attributes, CFStringRef contentTypeUTI, CFStringRef pathToFile)
@ -167,7 +167,7 @@ Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attribute
GetSoloBlockInfo((unsigned char *)fileCData, i + 1, &memBlock);
if (MemBlockFlag(memBlock.Flags) == memFlagFree) {
if (MemBlockFlag(memBlock.Flags) == PCSXRMemFlagFree) {
//Free space: ignore
i++;
continue;
@ -184,9 +184,9 @@ Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attribute
break;
}
};
// Ignore deleted blocks
i += x;
if (MemBlockFlag(memBlock.Flags) == memFlagDeleted) {
// Ignore deleted blocks
if (MemBlockFlag(memBlock.Flags) == PCSXRMemFlagDeleted) {
continue;
}
memCount++;

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7702"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="CheatController">
@ -47,7 +47,7 @@
</button>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="23">
<rect key="frame" x="20" y="61" width="658" height="276"/>
<clipView key="contentView" misplaced="YES" id="6pF-og-es3">
<clipView key="contentView" id="6pF-og-es3">
<rect key="frame" x="1" y="17" width="656" height="258"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
@ -55,7 +55,7 @@
<rect key="frame" x="0.0" y="0.0" width="656" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="Enabled" width="48.40234375" minWidth="40" maxWidth="1000" id="29">
@ -184,6 +184,7 @@
</buttonCell>
<connections>
<action selector="removeCheats:" target="-2" id="are-w2-Cx9"/>
<binding destination="237" name="enabled" keyPath="canRemove" id="3pC-QD-cnV"/>
</connections>
</button>
</subviews>
@ -223,7 +224,7 @@
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="136">
<rect key="frame" x="20" y="53" width="302" height="192"/>
<clipView key="contentView" misplaced="YES" id="COc-Cf-C5K">
<clipView key="contentView" id="COc-Cf-C5K">
<rect key="frame" x="1" y="17" width="300" height="174"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
@ -231,7 +232,7 @@
<rect key="frame" x="0.0" y="0.0" width="300" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="Address" width="150" minWidth="40" maxWidth="1000" id="141">
@ -352,6 +353,7 @@ Gw
</buttonCell>
<connections>
<action selector="removeCheatValue:" target="-2" id="215"/>
<binding destination="219" name="enabled" keyPath="canRemove" id="0Ve-Bf-kaw"/>
</connections>
</button>
</subviews>

View File

@ -192,7 +192,7 @@
- (IBAction)closeCheatEdit:(id)sender
{
[NSApp endSheet:editCheatWindow returnCode:[sender tag] == 1 ? NSCancelButton : NSOKButton];
[[self window] endSheet:editCheatWindow returnCode:[sender tag] == 1 ? NSCancelButton : NSOKButton];
}
- (IBAction)changeCheat:(id)sender

View File

@ -103,7 +103,7 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
McdBlock memBlock;
GetMcdBlockInfo(carNum, i + 1, &memBlock);
if ([PcsxrMemoryObject memFlagsFromBlockFlags:memBlock.Flags] == memFlagFree) {
if ([PcsxrMemoryObject memFlagsFromBlockFlags:memBlock.Flags] == PCSXRMemFlagFree) {
//Free space: ignore
i++;
continue;
@ -220,7 +220,7 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
{
int memSize = MAX_MEMCARD_BLOCKS;
for (PcsxrMemoryObject *memObj in rawArray) {
if (memObj.flag != memFlagDeleted) {
if (memObj.flag != PCSXRMemFlagDeleted) {
memSize -= memObj.blockSize;
}
}
@ -272,9 +272,9 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
GetMcdBlockInfo(cardNumber, i+1, &baseBlock);
PCSXRMemFlag theFlags = [PcsxrMemoryObject memFlagsFromBlockFlags:baseBlock.Flags];
if (theFlags == memFlagDeleted || theFlags == memFlagFree) {
if (theFlags == PCSXRMemFlagDeleted || theFlags == PCSXRMemFlagFree) {
PCSXRMemFlag up1Flags = theFlags;
while ((up1Flags == memFlagDeleted || up1Flags == memFlagFree) && x < MAX_MEMCARD_BLOCKS) {
while ((up1Flags == PCSXRMemFlagDeleted || up1Flags == PCSXRMemFlagFree) && x < MAX_MEMCARD_BLOCKS) {
x++;
McdBlock up1Block;
GetMcdBlockInfo(cardNumber, x+1, &up1Block);
@ -300,7 +300,6 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
- (void)deleteMemoryBlocksAtIndex:(int)slotnum
{
int xor = 0, i, j;
char *data, *ptr, *filename;
if (cardNumber == 1) {
filename = Config.Mcd1;
@ -321,8 +320,9 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
McdBlock flagBlock;
for(i = theObj.startingIndex + 1; i < (theObj.startingIndex + theObj.blockSize + 1); i++)
for(int i = theObj.startingIndex + 1; i < (theObj.startingIndex + theObj.blockSize + 1); i++)
{
char xor = 0;
GetMcdBlockInfo(cardNumber, i, &flagBlock);
ptr = data + i * 128;
@ -335,7 +335,7 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
*ptr = 0xA0 | (flagBlock.Flags & 0xF);
} else { continue; }
for (j = 0; j < 127; j++) xor ^= *ptr++;
for (unsigned char j = 0; j < 127; j++) xor ^= *ptr++;
*ptr = xor;
SaveMcd(filename, data, i * 128, 128);

View File

@ -115,7 +115,7 @@
int cardSize, freeConsBlocks, availBlocks;
if ([[fromCard memoryArray][selectedIndex] flag] == memFlagFree) {
if ([[fromCard memoryArray][selectedIndex] flag] == PCSXRMemFlagFree) {
NSBeep();
return;
}
@ -193,7 +193,7 @@
PcsxrMemoryObject *tmpObj = [curCard memoryArray][selectedIndex];
if (tmpObj.flag == memFlagFree) {
if (tmpObj.flag == PCSXRMemFlagFree) {
NSBeep();
return;
}

View File

@ -10,11 +10,11 @@
#include "sio.h"
typedef NS_ENUM(char, PCSXRMemFlag) {
memFlagDeleted,
memFlagFree,
memFlagUsed,
memFlagLink,
memFlagEndLink
PCSXRMemFlagDeleted,
PCSXRMemFlagFree,
PCSXRMemFlagUsed,
PCSXRMemFlagLink,
PCSXRMemFlagEndLink
};
@interface PcsxrMemoryObject : NSObject

View File

@ -22,32 +22,37 @@
@property (readwrite) BOOL hasImages;
@end
#pragma pack(push,2)
struct PSXRGBColor {
UInt8 r;
UInt8 g;
UInt8 b;
};
#pragma pack(pop)
@implementation PcsxrMemoryObject
+ (NSArray *)imagesFromMcd:(McdBlock *)block
{
NSMutableArray *imagesArray = [[NSMutableArray alloc] initWithCapacity:block->IconCount];
for (int i = 0; i < block->IconCount; i++) {
NSImage *memImage;
@autoreleasepool {
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:16 pixelsHigh:16 bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
short *icon = block->Icon;
int x, y, c, v, r, g, b;
for (v = 0; v < 256; v++) {
x = (v % 16);
y = (v / 16);
c = icon[(i * 256) + v];
r = (c & 0x001f) << 3;
g = ((c & 0x03e0) >> 5) << 3;
b = ((c & 0x7c00) >> 10) << 3;
[imageRep setColor:[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] atX:x y:y];
}
memImage = [[NSImage alloc] init];
[memImage addRepresentation:imageRep];
[memImage setSize:NSMakeSize(32, 32)];
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:16 pixelsHigh:16 bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:16*3 bitsPerPixel:24];
struct PSXRGBColor *cocoaImageData = (struct PSXRGBColor *)imageRep.bitmapData;
short *icon = block->Icon;
for (int v = 0; v < 256; v++) {
int c = icon[(i * 256) + v];
int r = (c & 0x001f) << 3;
int g = ((c & 0x03e0) >> 5) << 3;
int b = ((c & 0x7c00) >> 10) << 3;
struct PSXRGBColor *colorItem = &cocoaImageData[v];
colorItem->r = r;
colorItem->g = g;
colorItem->b = b;
}
NSImage *memImage = [[NSImage alloc] init];
[memImage addRepresentation:imageRep];
[memImage setSize:NSMakeSize(32, 32)];
[imagesArray addObject:memImage];
}
return [NSArray arrayWithArray:imagesArray];
@ -86,23 +91,23 @@ static NSString *MemLabelMultiSave;
{
switch (flagNameIndex) {
default:
case memFlagFree:
case PCSXRMemFlagFree:
return MemLabelFree;
break;
case memFlagEndLink:
case PCSXRMemFlagEndLink:
return MemLabelEndLink;
break;
case memFlagLink:
case PCSXRMemFlagLink:
return MemLabelLink;
break;
case memFlagUsed:
case PCSXRMemFlagUsed:
return MemLabelUsed;
break;
case memFlagDeleted:
case PCSXRMemFlagDeleted:
return MemLabelDeleted;
break;
}
@ -126,22 +131,22 @@ static NSString *MemLabelMultiSave;
{
if ((blockFlags & 0xF0) == 0xA0) {
if ((blockFlags & 0xF) >= 1 && (blockFlags & 0xF) <= 3)
return memFlagDeleted;
return PCSXRMemFlagDeleted;
else
return memFlagFree;
return PCSXRMemFlagFree;
} else if ((blockFlags & 0xF0) == 0x50) {
if ((blockFlags & 0xF) == 0x1)
return memFlagUsed;
return PCSXRMemFlagUsed;
else if ((blockFlags & 0xF) == 0x2)
return memFlagLink;
return PCSXRMemFlagLink;
else if ((blockFlags & 0xF) == 0x3)
return memFlagEndLink;
return PCSXRMemFlagEndLink;
} else
return memFlagFree;
return PCSXRMemFlagFree;
//Xcode complains unless we do this...
NSLog(@"Unknown flag %x", blockFlags);
return memFlagFree;
return PCSXRMemFlagFree;
}
- (instancetype)initWithMcdBlock:(McdBlock *)infoBlock startingIndex:(uint8_t)startIdx size:(uint8_t)memSize
@ -150,7 +155,7 @@ static NSString *MemLabelMultiSave;
self.startingIndex = startIdx;
self.blockSize = memSize;
self.flag = [PcsxrMemoryObject memFlagsFromBlockFlags:infoBlock->Flags];
if (self.flag == memFlagFree) {
if (self.flag == PCSXRMemFlagFree) {
self.imageArray = @[];
self.hasImages = NO;
self.title = @"Free block";
@ -279,23 +284,23 @@ static inline void SetupAttrStr(NSMutableAttributedString *mutStr, NSColor *txtc
switch (flag) {
default:
case memFlagFree:
case PCSXRMemFlagFree:
return attribMemLabelFree;
break;
case memFlagEndLink:
case PCSXRMemFlagEndLink:
return attribMemLabelEndLink;
break;
case memFlagLink:
case PCSXRMemFlagLink:
return attribMemLabelLink;
break;
case memFlagUsed:
case PCSXRMemFlagUsed:
return attribMemLabelUsed;
break;
case memFlagDeleted:
case PCSXRMemFlagDeleted:
return attribMemLabelDeleted;
break;
}
@ -303,7 +308,7 @@ static inline void SetupAttrStr(NSMutableAttributedString *mutStr, NSColor *txtc
- (BOOL)showCount
{
if (flag == memFlagFree) {
if (flag == PCSXRMemFlagFree) {
//Always show the size of the free blocks
return YES;
} else {

View File

@ -242,20 +242,15 @@
#define PluginSymbolNameConfigure(type) PluginSymbolName(type, @"configure")
#define PluginSymbolNameAbout(type) PluginSymbolName(type, @"about")
- (void)runCommand:(id)arg
- (void)runCommandNamed:(NSString*)arg
{
@autoreleasepool {
NSString *funcName = arg[0];
long (*func)(void);
func = SysLoadSym(pluginRef, [funcName cStringUsingEncoding:NSASCIIStringEncoding]);
if (SysLibError() == NULL) {
func();
} else {
NSBeep();
}
return;
long (*func)(void);
func = SysLoadSym(pluginRef, [arg cStringUsingEncoding:NSASCIIStringEncoding]);
if (SysLibError() == NULL) {
func();
} else {
NSBeep();
}
}
@ -336,26 +331,24 @@
- (void)aboutAs:(int)aType
{
NSArray *arg;
NSString *aboutSym = PluginSymbolNameAbout(aType);
arg = @[aboutSym, @0];
//NSArray *arg = @[aboutSym, @0];
// detach a new thread
[NSThread detachNewThreadSelector:@selector(runCommand:) toTarget:self
withObject:arg];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self runCommandNamed:aboutSym];
});
}
- (void)configureAs:(int)aType
{
NSArray *arg;
NSString *configSym = PluginSymbolNameConfigure(aType);
arg = @[configSym, @1];
//NSArray *arg = @[configSym, @1];
// detach a new thread
[NSThread detachNewThreadSelector:@selector(runCommand:) toTarget:self
withObject:arg];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self runCommandNamed:configSym];
});
}
- (NSString *)displayVersion
@ -376,7 +369,7 @@
if (_name == nil)
return [path lastPathComponent];
return [NSString stringWithFormat:@"%@ %@ [%@]", self.name, [self displayVersion], [path lastPathComponent]];
return [NSString stringWithFormat:@"%@ %@ [%@]", self.name, self.displayVersion, path.lastPathComponent];
}
- (NSString*)debugDescription
@ -384,7 +377,7 @@
if (_name == nil) {
return fullPlugPath;
}
return [NSString stringWithFormat:@"%@, %@ [%@]", self.name, [self displayVersion], fullPlugPath];
return [NSString stringWithFormat:@"%@, %@ [%@]", self.name, self.displayVersion, fullPlugPath];
}
// the plugin will check if it's still valid and return the status

View File

@ -11,7 +11,9 @@
// Apple deprecated __private_extern__ in Xcode 4.6.
// This is a convenience declaration to retain the old behavior.
#ifndef __private_extern
#define __private_extern __attribute__((visibility("hidden")))
#endif
#include <sys/time.h>
#include <unistd.h>

View File

@ -61,7 +61,9 @@ const char *EmuKeyText[EMU_TOTAL] = {
N_("Save state"),
N_("Screenshot"),
N_("Escape"),
N_("Rewind")
N_("Rewind"),
N_("Alt Speed 1"),
N_("Alt Speed 2")
};
const char *DPadText[DKEY_TOTAL] = {

View File

@ -126,6 +126,8 @@ static void SetDefaultConfig() {
g.cfg.E.EmuDef[EMU_SCREENSHOT].EmuKeyEvent = XK_F8;
g.cfg.E.EmuDef[EMU_ESCAPE].EmuKeyEvent = XK_Escape;
g.cfg.E.EmuDef[EMU_REWIND].EmuKeyEvent = XK_BackSpace;
g.cfg.E.EmuDef[EMU_ALTSPEED1].EmuKeyEvent = XK_bracketleft;
g.cfg.E.EmuDef[EMU_ALTSPEED2].EmuKeyEvent = XK_bracketright;
}
void LoadPADConfig() {
@ -199,6 +201,16 @@ void LoadPADConfig() {
g.cfg.E.EmuDef[EMU_REWIND].Mapping.Key = a;
g.cfg.E.EmuDef[EMU_REWIND].Mapping.JoyEvType = b;
g.cfg.E.EmuDef[EMU_REWIND].Mapping.J.d = c;
} else if (strncmp(buf, "EMU_ALTSPEED1=", 14) == 0) {
sscanf(buf, "EMU_ALTSPEED1=%d,%d,%d", &a, &b, &c);
g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.Key = a;
g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.JoyEvType = b;
g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.J.d = c;
} else if (strncmp(buf, "EMU_ALTSPEED2=", 14) == 0) {
sscanf(buf, "EMU_ALTSPEED2=%d,%d,%d", &a, &b, &c);
g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.Key = a;
g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.JoyEvType = b;
g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.J.d = c;
} else if (strncmp(buf, "Select=", 7) == 0) {
sscanf(buf, "Select=%d,%d,%d", &a, &b, &c);
g.cfg.PadDef[current].KeyDef[DKEY_SELECT].Key = a;
@ -437,5 +449,13 @@ void SavePADConfig() {
fprintf(fp, "EMU_REWIND=%d,%d,%d\n", g.cfg.E.EmuDef[EMU_REWIND].Mapping.Key,
g.cfg.E.EmuDef[EMU_REWIND].Mapping.JoyEvType,
g.cfg.E.EmuDef[EMU_REWIND].Mapping.J.d);
fprintf(fp, "EMU_ALTSPEED1=%d,%d,%d\n",
g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.Key,
g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.JoyEvType,
g.cfg.E.EmuDef[EMU_ALTSPEED1].Mapping.J.d);
fprintf(fp, "EMU_ALTSPEED2=%d,%d,%d\n",
g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.Key,
g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.JoyEvType,
g.cfg.E.EmuDef[EMU_ALTSPEED2].Mapping.J.d);
fclose(fp);
}

View File

@ -121,6 +121,8 @@ enum {
EMU_SCREENSHOT,
EMU_ESCAPE,
EMU_REWIND,
EMU_ALTSPEED1,
EMU_ALTSPEED2,
EMU_TOTAL
};

View File

@ -902,11 +902,10 @@ static XVisualInfo *myvisual;
Display *display;
static Colormap colormap;
Window window;
Window overlay;
static GC hGC;
static XImage * Ximage;
static XvImage * XCimage;
static XImage * XPimage=0;
char * Xpixels;
char * pCaptionText;
static int fx=0;
@ -949,15 +948,15 @@ void DestroyDisplay(void)
XFreeGC(display,hGC);
hGC = 0;
}
if (overlay)
{
XDestroyWindow(display, overlay);
overlay = 0;
}
if(Ximage)
{
XDestroyImage(Ximage);
Ximage=0;
}
if(XCimage)
{
XFree(XCimage);
XCimage=0;
}
XShmDetach(display,&shminfo);
@ -1254,6 +1253,22 @@ void CreateDisplay(void)
return;
}
overlay=XCreateWindow(display,window,
iResX - 128,0,128,96,
0,myvisual->depth,
InputOutput,myvisual->visual,
CWBorderPixel | CWBackPixel |
CWEventMask | CWDontPropagate |
CWColormap | CWCursor | CWEventMask,
&winattr);
if(!overlay)
{
fprintf(stderr,"Failed in XCreateWindow()!!!\n");
DestroyDisplay();
return;
}
delwindow = XInternAtom(display,"WM_DELETE_WINDOW",0);
XSetWMProtocols(display, window, &delwindow, 1);
@ -1352,14 +1367,6 @@ void CreateDisplay(void)
else
color = 0;
Xpixels = (char *)malloc(8*8*4);
for(i = 0; i < 8*8; ++i)
((uint32_t *)Xpixels)[i] = color;
XCimage = XvCreateImage(display,xv_port,xv_id,
(char *)Xpixels, 8, 8);
/*
Allocate max that could be needed:
Big(est?) PSX res: 640x512
@ -1676,6 +1683,7 @@ void DoBufferSwap(void)
_w, _h, //dst w,h
1
);
DisplayPic();
if(ulKeybits&KEY_SHOWFPS) //DisplayText(); c // paint menu text
{
@ -1695,7 +1703,6 @@ void DoBufferSwap(void)
XDrawImageString(display,window,hGC,2,13,szDispBuf,strlen(szDispBuf));
}
//if(XPimage) DisplayPic();
XFree(xvi);
}
@ -1707,15 +1714,11 @@ void DoClearScreenBuffer(void) // CLEAR DX BUFFER
XGetGeometry(display, window, &_dw, (int *)&_d, (int *)&_d, &_w, &_h, &_d, &_d);
XvPutImage(display, xv_port, window, hGC, XCimage,
0, 0, 8, 8, 0, 0, _w, _h);
//XSync(display,False);
}
void DoClearFrontBuffer(void) // CLEAR DX BUFFER
{/*
XPutImage(display,window,hGC, XCimage,
0, 0, 0, 0, iResX, iResY);
XSync(display,False);*/
}
@ -1877,9 +1880,7 @@ void CreatePic(unsigned char * pMem)
void DestroyPic(void)
{
if(XPimage)
{ /*
XPutImage(display,window,hGC, XCimage,
0, 0, 0, 0, iResX, iResY);*/
{
XDestroyImage(XPimage);
XPimage=0;
}
@ -1887,8 +1888,20 @@ void DestroyPic(void)
void DisplayPic(void)
{
XPutImage(display,window,hGC, XPimage,
0, 0, iResX-128, 0,128,96);
static int mapped = 0;
if (XPimage) {
if (!mapped) {
XMapWindow(display, overlay);
mapped = 1;
}
XPutImage(display,overlay,hGC, XPimage,
0,0, 0,0, 128,96);
} else {
if (mapped) {
XUnmapWindow(display, overlay);
mapped = 0;
}
}
}
void ShowGpuPic(void)

View File

@ -36,8 +36,16 @@ BOOL bInitCap = TRUE;
float fps_skip = 0;
float fps_cur = 0;
float speed = 1;
#define MAXLACE 16
void CALLBACK GPUsetSpeed(float newSpeed) {
if (newSpeed > 0 && newSpeed <= 1000) {
speed = newSpeed;
}
}
void CheckFrameRate(void)
{
if(UseFrameSkip) // skipping mode?
@ -74,6 +82,7 @@ void FrameCap (void)
{
static unsigned long curticks, lastticks, _ticks_since_last_update;
static unsigned int TicksToWait = 0;
unsigned int frTicks = dwFrameRateTicks / speed;
int overslept=0, tickstogo=0;
BOOL Waiting = TRUE;
@ -86,10 +95,10 @@ void FrameCap (void)
{
lastticks = curticks;
overslept = _ticks_since_last_update - TicksToWait;
if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks)
if((_ticks_since_last_update-TicksToWait) > frTicks)
TicksToWait=0;
else
TicksToWait=dwFrameRateTicks - overslept;
TicksToWait=frTicks - overslept;
}
else
{
@ -104,7 +113,7 @@ void FrameCap (void)
Waiting = FALSE;
lastticks = curticks;
overslept = _ticks_since_last_update - TicksToWait;
TicksToWait = dwFrameRateTicks - overslept;
TicksToWait = frTicks - overslept;
return;
}
if (tickstogo >= 200 && !(dwActFixes&16))
@ -123,6 +132,7 @@ void FrameSkip(void)
static DWORD curticks, lastticks, _ticks_since_last_update;
int tickstogo=0;
static int overslept=0;
unsigned int frTicks = dwFrameRateTicks / speed;
if(!dwLaceCnt) return; // important: if no updatelace happened, we ignore it completely
@ -146,12 +156,12 @@ void FrameSkip(void)
curticks = timeGetTime(); // -> now we calc the time of the last drawn frame + the time we spent skipping
_ticks_since_last_update= dwT+curticks - lastticks;
dwWaitTime=dwLastLace*dwFrameRateTicks; // -> and now we calc the time the real psx would have needed
dwWaitTime=dwLastLace*frTicks; // -> and now we calc the time the real psx would have needed
if(_ticks_since_last_update<dwWaitTime) // -> we were too fast?
{
if((dwWaitTime-_ticks_since_last_update)> // -> some more security, to prevent
(60*dwFrameRateTicks)) // wrong waiting times
(60*frTicks)) // wrong waiting times
_ticks_since_last_update=dwWaitTime;
while(_ticks_since_last_update<dwWaitTime) // -> loop until we have reached the real psx time
@ -188,7 +198,7 @@ void FrameSkip(void)
_ticks_since_last_update = curticks - lastticks;
dwLastLace=dwLaceCnt; // store curr count (frame limitation helper)
dwWaitTime=dwLaceCnt*dwFrameRateTicks; // calc the 'real psx lace time'
dwWaitTime=dwLaceCnt*frTicks; // calc the 'real psx lace time'
if (dwWaitTime >= overslept)
dwWaitTime-=overslept;

View File

@ -2219,46 +2219,53 @@ void CALLBACK GPUgetScreenPic(unsigned char * pMem)
// LINUX version:
extern char * Xpixels;
void GPUgetScreenPic(unsigned char * pMem)
{
/*
unsigned short c;unsigned char * pf;int x,y;
unsigned char *pf=pMem;
unsigned char *buf, *line, *pD;
float XS=(float)iResX/128;
float YS=(float)iResY/96;
pf=pMem;
memset(pMem, 0, 128*96*3);
if(Xpixels)
{
unsigned char * ps=(unsigned char *)Xpixels;
{
long lPitch=iResX<<2;
uint32_t sx;
for(y=0;y<96;y++)
{
for(x=0;x<128;x++)
{
sx=*((uint32_t *)((ps)+
(((int)((float)y*YS))*lPitch)+
((int)((float)x*XS))*4));
*(pf+0)=(sx&0xff);
*(pf+1)=(sx&0xff00)>>8;
*(pf+2)=(sx&0xff0000)>>16;
pf+=3;
}
int w = PreviousPSXDisplay.Range.x1, h = PreviousPSXDisplay.DisplayMode.y;
int x, y;
float XS = w / 128.0, YS = h / 96.0;
line = pf;
for (y = 0; y < 96; ++y) {
for (x = 0; x < 128; ++x) {
float r = 0, g = 0, b = 0, sr, sg, sb;
uint32_t cnt = 0, i, j;
for (j = 0; j < (int)((y+1)*YS) - (int)(y*YS); ++j) {
for (i = 0; i < (int)((x+1)*XS) - (int)(x*XS); ++i) {
pD = (unsigned char *)&psxVuw[(int)(y*YS +
PSXDisplay.DisplayPosition.y - 1 + j) * 1024 +
PSXDisplay.DisplayPosition.x] +
(PSXDisplay.RGB24 ? 3 : 2) * (int)(x*XS + i);
if (PSXDisplay.RGB24) {
uint32_t lu = *(uint32_t *)pD;
sr = RED(lu);
sg = GREEN(lu);
sb = BLUE(lu);
} else {
int32_t color = GETLE16(pD);
sr = (color << 3) & 0xf1;
sg = (color >> 2) & 0xf1;
sb = (color >> 7) & 0xf1;
}
r += sr * sr;
g += sg * sg;
b += sb * sb;
cnt += 1;
}
line[x * 3 + 2] = sqrt(r / cnt);
line[x * 3 + 1] = sqrt(g / cnt);
line[x * 3 + 0] = sqrt(b / cnt);
}
}
line += 128 * 3;
}
/////////////////////////////////////////////////////////////////////
// generic number/border painter
unsigned short c;
pf=pMem+(103*3); // offset to number rect
for(y=0;y<20;y++) // loop the number rect pixel
@ -2289,7 +2296,6 @@ void GPUgetScreenPic(unsigned char * pMem)
*(pf+(127*3))=0xff;*pf++=0xff;
pf+=127*3; // offset to next line
}
*/
}
#endif

View File

@ -36,6 +36,7 @@
BOOL bIsPerformanceCounter=FALSE;
float fFrameRateHz=0;
float speed=1;
DWORD dwFrameRateTicks=16;
float fFrameRate;
int iFrameLimit;
@ -64,7 +65,9 @@ void FrameCap(void)
{
static unsigned long curticks, lastticks, _ticks_since_last_update;
static unsigned long TicksToWait = 0;
double remTime;
bool Waiting = TRUE;
DWORD frTicks=(DWORD)(dwFrameRateTicks / speed);
{
curticks = timeGetTime();
@ -75,9 +78,9 @@ void FrameCap(void)
{
lastticks = curticks;
if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks)
if((_ticks_since_last_update-TicksToWait) > frTicks)
TicksToWait=0;
else TicksToWait=dwFrameRateTicks-(_ticks_since_last_update-TicksToWait);
else TicksToWait=frTicks-(_ticks_since_last_update-TicksToWait);
}
else
{
@ -85,13 +88,18 @@ void FrameCap(void)
{
curticks = timeGetTime();
_ticks_since_last_update = curticks - lastticks;
remTime = (TicksToWait - _ticks_since_last_update) * 1e6 / TIMEBASE;
if ((_ticks_since_last_update > TicksToWait) ||
(curticks < lastticks))
{
Waiting = FALSE;
lastticks = curticks;
TicksToWait = dwFrameRateTicks;
TicksToWait = frTicks;
}
else if (remTime > 2)
{
usleep(remTime - 2);
}
}
}
}
@ -105,9 +113,15 @@ void FrameSkip(void)
static int iNumSkips=0,iAdditionalSkip=0; // number of additional frames to skip
static DWORD dwLastLace=0; // helper var for frame limitation
static DWORD curticks, lastticks, _ticks_since_last_update;
DWORD frTicks=(DWORD)(dwFrameRateTicks / speed);
double remTime;
DWORD maxSkipTicks = 0;
if(!dwLaceCnt) return; // important: if no updatelace happened, we ignore it completely
if (speed > 1) {
maxSkipTicks = 1/30. * TIMEBASE;
}
if(iNumSkips) // we are in skipping mode?
{
dwLastLace+=dwLaceCnt; // -> calc frame limit helper (number of laces)
@ -128,23 +142,28 @@ void FrameSkip(void)
curticks = timeGetTime();
_ticks_since_last_update= dwT+curticks - lastticks;
dwWaitTime=dwLastLace*dwFrameRateTicks; // -> and now we calc the time the real psx would have needed
dwWaitTime=dwLastLace*frTicks; // -> and now we calc the time the real psx would have needed
if(_ticks_since_last_update<dwWaitTime) // -> we were too fast?
{
if((dwWaitTime-_ticks_since_last_update)> // -> some more security, to prevent
(60*dwFrameRateTicks)) // wrong waiting times
(60*frTicks)) // wrong waiting times
_ticks_since_last_update=dwWaitTime;
while(_ticks_since_last_update<dwWaitTime) // -> loop until we have reached the real psx time
{ // (that's the additional limitation, yup)
remTime = (dwWaitTime - _ticks_since_last_update) * 1e6 / TIMEBASE;
if (remTime > 2) {
usleep(remTime - 2);
}
curticks = timeGetTime();
_ticks_since_last_update = dwT+curticks - lastticks;
}
}
else // we were still too slow ?!!?
{
if(iAdditionalSkip<MAXSKIP) // -> well, somewhen we really have to stop skipping on very slow systems
if(iAdditionalSkip<MAXSKIP &&
_ticks_since_last_update<maxSkipTicks) // -> well, somewhen we really have to stop skipping on very slow systems
{
iAdditionalSkip++; // -> inc our watchdog var
dwLaceCnt=0; // -> reset lace count
@ -170,7 +189,7 @@ void FrameSkip(void)
_ticks_since_last_update = curticks - lastticks;
dwLastLace=dwLaceCnt; // store curr count (frame limitation helper)
dwWaitTime=dwLaceCnt*dwFrameRateTicks; // calc the 'real psx lace time'
dwWaitTime=dwLaceCnt*frTicks; // calc the 'real psx lace time'
if(_ticks_since_last_update>dwWaitTime) // hey, we needed way too long for that frame...
{
@ -194,6 +213,10 @@ void FrameSkip(void)
while(_ticks_since_last_update<dwWaitTime) // just do a waiting loop...
{
remTime = (dwWaitTime - _ticks_since_last_update) * 1e6 / TIMEBASE;
if (remTime > 2) {
usleep(remTime - 2);
}
curticks = timeGetTime();
_ticks_since_last_update = curticks - lastticks;
}
@ -247,8 +270,8 @@ void calcfps(void)
fps_cnt = 0;
fps_tck = 1;
if(bUseFrameLimit && fps_cur>fFrameRateHz) // optical adjust ;) avoids flickering fps display
fps_cur=fFrameRateHz;
if(bUseFrameLimit && fps_cur>fFrameRateHz * speed) // optical adjust ;) avoids flickering fps display
fps_cur=fFrameRateHz * speed;
}
}
@ -267,7 +290,7 @@ void PCFrameCap (void)
{
Waiting = FALSE;
lastticks = curticks;
TicksToWait = (TIMEBASE / (unsigned long)fFrameRateHz);
TicksToWait = (TIMEBASE / (unsigned long)(fFrameRateHz * speed));
}
}
}
@ -380,6 +403,12 @@ void CheckFrameRate(void) // called in updatelace (
}
}
void CALLBACK GPUsetSpeed(float newSpeed) {
if (newSpeed > 0 && newSpeed <= 1000) {
speed = newSpeed;
}
}
void CALLBACK GPUsetframelimit(unsigned long option) // new EPSXE interface func: main emu can enable/disable fps limitation this way
{
bInitCap = TRUE;

View File

@ -98,7 +98,7 @@ BEGIN
CTEXT "PCSXR EMU\nVersion x.x",IDC_PCSXR_ABOUT_TEXT,22,10,112,15,0,WS_EX_TRANSPARENT
CTEXT "PCSXR a psx emulator...",IDC_PCSXR_ABOUT_AUTHORS,10,35,135,63,0,WS_EX_TRANSPARENT
CTEXT "Greets to...",IDC_PCSXR_ABOUT_GREETS,45,110,232,65
CONTROL SPLASH_LOGO,IDC_STATIC,"Static",SS_BITMAP | WS_BORDER,155,10,171,101
CONTROL 113,IDC_STATIC,"Static",SS_BITMAP | WS_BORDER,155,10,171,101
GROUPBOX "",IDC_STATIC,5,25,145,77
GROUPBOX "",IDC_STATIC,43,100,234,79
END
@ -350,16 +350,20 @@ END
// remains consistent on all systems.
IDI_APP_ICON ICON "gui\\pcsxr.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
SPLASH_LOGO BITMAP "gui\\about.bmp"
MAIN_LOGO BITMAP "gui\\pcsxr.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//
1 RT_MANIFEST "gui\\pcsxr.exe.manifest"
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -55,6 +55,9 @@
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>