#include "gpu.h"
#include <zlib.h>
+#if (defined(__GNUC__) && __GNUC__ >= 5) || defined(__clang__)
+#pragma GCC diagnostic ignored "-Wpointer-sign"
+#endif
+
#undef SysPrintf
#define SysPrintf if (Config.PsxOut) printf
ptr = Mcd##mcd##Data + offset; \
memcpy(ptr, Ra1, length); \
FDesc[1 + mcd].offset += length; \
+ SaveMcd(Config.Mcd##mcd, Mcd##mcd##Data, offset, length); \
if (FDesc[1 + mcd].mode & 0x8000) { \
DeliverEvent(0x11, 0x2); /* 0xf0000011, 0x0004 */ \
DeliverEvent(0x81, 0x2); /* 0xf4000001, 0x0004 */ \
}
void psxBios_malloc() { // 0x33
- unsigned int *chunk, *newchunk = NULL;
+ u32 *chunk, *newchunk = NULL;
unsigned int dsize = 0, csize, cstat;
int colflag;
#ifdef PSXBIOS_LOG
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s\n", biosA0n[0x44]);
#endif
-
+ psxCpu->Notify(R3000ACPU_NOTIFY_CACHE_ISOLATED, NULL);
+ psxCpu->Notify(R3000ACPU_NOTIFY_CACHE_UNISOLATED, NULL);
pc0 = ra;
}
void psxBios_GPU_dw() { // 0x46
int size;
- s32 *ptr;
+ u32 *ptr;
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s\n", biosA0n[0x46]);
#endif
GPU_writeData(0xa0000000);
- GPU_writeData((a1<<16)|(a0&0xffff));
- GPU_writeData((a3<<16)|(a2&0xffff));
- size = (a2*a3+1)/2;
- ptr = (s32*)PSXM(Rsp[4]); //that is correct?
- do {
- GPU_writeData(SWAP32(*ptr));
- ptr++;
- } while(--size);
+ GPU_writeData((a1<<0x10)|(a0&0xffff));
+ GPU_writeData((a3<<0x10)|(a2&0xffff));
+ size = (a2*a3)/2;
+ ptr = (u32*)PSXM(Rsp[4]); //that is correct?
+ while(size--)
+ {
+ GPU_writeData(SWAPu32(*ptr++));
+ }
pc0 = ra;
}
void psxBios_mem2vram() { // 0x47
int size;
-
+ gpuSyncPluginSR();
GPU_writeData(0xa0000000);
- GPU_writeData((a1<<16)|(a0&0xffff));
- GPU_writeData((a3<<16)|(a2&0xffff));
- size = (a2*a3+1)/2;
+ GPU_writeData((a1<<0x10)|(a0&0xffff));
+ GPU_writeData((a3<<0x10)|(a2&0xffff));
+ size = ((((a2 * a3) / 2) >> 4) << 16);
GPU_writeStatus(0x04000002);
psxHwWrite32(0x1f8010f4,0);
psxHwWrite32(0x1f8010f0,psxHwRead32(0x1f8010f0)|0x800);
psxHwWrite32(0x1f8010a0,Rsp[4]);//might have a buggy...
- psxHwWrite32(0x1f8010a4,((size/16)<<16)|16);
+ psxHwWrite32(0x1f8010a4, size | 0x10);
psxHwWrite32(0x1f8010a8,0x01000201);
pc0 = ra;
}
void psxBios_GPU_cw() { // 0x49
+ gpuSyncPluginSR();
GPU_writeData(a0);
pc0 = ra;
+ v0 = HW_GPU_STATUS;
}
void psxBios_GPU_cwb() { // 0x4a
- s32 *ptr = (s32*)Ra0;
+ u32 *ptr = (u32*)Ra0;
int size = a1;
- while(size--) {
- GPU_writeData(SWAP32(*ptr));
- ptr++;
+ gpuSyncPluginSR();
+ while(size--)
+ {
+ GPU_writeData(SWAPu32(*ptr++));
}
pc0 = ra;
}
void psxBios_GPU_SendPackets() { //4b:
+ gpuSyncPluginSR();
GPU_writeStatus(0x04000002);
psxHwWrite32(0x1f8010f4,0);
psxHwWrite32(0x1f8010f0,psxHwRead32(0x1f8010f0)|0x800);
char ffile[64], *pfile;
int nfile;
-static void buopen(int mcd, u8 *ptr, u8 *cfg)
+static void buopen(int mcd, char *ptr, char *cfg)
{
int i;
- u8 *fptr = ptr;
+ char *fptr = ptr;
strcpy(FDesc[1 + mcd].name, Ra0+5);
FDesc[1 + mcd].offset = 0;
fptr[6] = 0x00;
fptr[7] = 0x00;
strcpy(fptr+0xa, FDesc[1 + mcd].name);
- pptr = fptr2 = fptr;
+ pptr = fptr2 = (u8 *)fptr;
for(j=2; j<=nblk; j++) {
int k;
for(i++; i<16; i++) {
*/
void psxBios_open() { // 0x32
- int i;
- char *ptr;
void *pa0 = Ra0;
#ifdef PSXBIOS_LOG
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s: %x,%x,%x\n", biosB0n[0x4e], a0, a1, a2);
#endif
- /* Function also accepts sector 400h (a bug) */
- if (!(a1 <= 0x400))
+ /*
+ Function also accepts sector 400h (a bug).
+ But notaz said we shouldn't allow sector 400h because it can corrupt the emulator.
+ */
+ if (!(a1 <= 0x3FF))
{
/* Invalid sectors */
v0 = 0; pc0 = ra;
#ifdef PSXBIOS_LOG
PSXBIOS_LOG("psxBios_%s\n", biosB0n[0x4f]);
#endif
- /* Function also accepts sector 400h (a bug) */
- if (!(a1 <= 0x400))
+ /*
+ Function also accepts sector 400h (a bug).
+ But notaz said we shouldn't allow sector 400h because it can corrupt the emulator.
+ */
+ if (!(a1 <= 0x3FF))
{
/* Invalid sectors */
v0 = 0; pc0 = ra;
/* Some games like R-Types, CTR, Fade to Black read from adress 0x00000000 due to uninitialized pointers.
See Garbage Area at Address 00000000h in Nocash PSX Specfications for more information.
- R-type will work if PsxM[0] is non-zero. (Meaning that it should not be 00000003h as he implies).
- Crash Team Racing will refuse to boot if psxM[2] and psx[3] are not set to 0.
- Fade to Black can crash upon memory card access if byte 5 is set to the wrong value.
+ Here are some examples of games not working with this fix in place :
+ R-type won't get past the Irem logo if not implemented.
+ Crash Team Racing will softlock after the Sony logo.
+ */
+
+ psxMu32ref(0x0000) = SWAPu32(0x00000003);
+ /*
+ But overwritten by 00000003h after soon.
+ psxMu32ref(0x0000) = SWAPu32(0x00001A3C);
*/
- psxM[0] = SWAPu32(0x3C);
- psxM[1] = SWAPu32(0x1A);
- psxM[2] = SWAPu32(0x00);
- psxM[3] = SWAPu32(0x00);
- psxM[4] = SWAPu32(0x27);
- psxM[5] = SWAPu32(0x5A);
- psxM[6] = SWAPu32(0x0C);
- psxM[7] = SWAPu32(0x80);
+ psxMu32ref(0x0004) = SWAPu32(0x800C5A27);
+ psxMu32ref(0x0008) = SWAPu32(0x08000403);
+ psxMu32ref(0x000C) = SWAPu32(0x00000000);
}
void psxBiosShutdown() {