drc: starting arm64 support
[pcsx_rearmed.git] / libpcsxcore / misc.c
index 3ee9876..cd16c41 100644 (file)
@@ -26,6 +26,7 @@
 #include "mdec.h"
 #include "gpu.h"
 #include "ppf.h"
+#include "database.h"
 #include <zlib.h>
 
 char CdromId[10] = "";
@@ -243,6 +244,7 @@ int LoadCdrom() {
        tmpHead.t_addr = SWAP32(tmpHead.t_addr);
 
        psxCpu->Clear(tmpHead.t_addr, tmpHead.t_size / 4);
+       psxCpu->Reset();
 
        // Read the rest of the main executable
        while (tmpHead.t_size & ~2047) {
@@ -290,6 +292,7 @@ int LoadCdromFile(const char *filename, EXE_HEADER *head) {
        addr = head->t_addr;
 
        psxCpu->Clear(addr, size / 4);
+       psxCpu->Reset();
 
        while (size & ~2047) {
                incTime();
@@ -378,7 +381,13 @@ int CheckCdrom() {
                strcpy(CdromId, "SLUS99999");
 
        if (Config.PsxAuto) { // autodetect system (pal or ntsc)
-               if (CdromId[2] == 'e' || CdromId[2] == 'E')
+               if (
+                       /* Make sure Wild Arms SCUS-94608 is not detected as a PAL game. */
+                       ((CdromId[0] == 's' || CdromId[0] == 'S') && (CdromId[2] == 'e' || CdromId[2] == 'E')) ||
+                       !strncmp(CdromId, "DTLS3035", 8) ||
+                       !strncmp(CdromId, "PBPX95001", 9) || // according to redump.org, these PAL
+                       !strncmp(CdromId, "PBPX95007", 9) || // discs have a non-standard ID;
+                       !strncmp(CdromId, "PBPX95008", 9))   // add more serials if they are discovered.
                        Config.PsxType = PSX_TYPE_PAL; // pal
                else Config.PsxType = PSX_TYPE_NTSC; // ntsc
        }
@@ -389,6 +398,8 @@ int CheckCdrom() {
        SysPrintf(_("CD-ROM Label: %.32s\n"), CdromLabel);
        SysPrintf(_("CD-ROM ID: %.9s\n"), CdromId);
        SysPrintf(_("CD-ROM EXE Name: %.255s\n"), exename);
+       
+       Apply_Hacks_Cdrom();
 
        BuildPPFCache();
 
@@ -573,7 +584,7 @@ int SaveState(const char *file) {
        f = SaveFuncs.open(file, "wb");
        if (f == NULL) return -1;
 
-       new_dyna_save();
+       new_dyna_before_save();
 
        SaveFuncs.write(f, (void *)PcsxHeader, 32);
        SaveFuncs.write(f, (void *)&SaveVersion, sizeof(u32));
@@ -615,6 +626,7 @@ int SaveState(const char *file) {
        psxHwFreeze(f, 1);
        psxRcntFreeze(f, 1);
        mdecFreeze(f, 1);
+       new_dyna_freeze(f, 1);
 
        SaveFuncs.close(f);
 
@@ -679,9 +691,9 @@ int LoadState(const char *file) {
        psxHwFreeze(f, 0);
        psxRcntFreeze(f, 0);
        mdecFreeze(f, 0);
+       new_dyna_freeze(f, 0);
 
        SaveFuncs.close(f);
-       new_dyna_restore();
 
        return 0;
 }
@@ -741,7 +753,7 @@ int RecvPcsxInfo() {
        NET_recvData(&Config.Cpu, sizeof(Config.Cpu), PSE_NET_BLOCKING);
        if (tmp != Config.Cpu) {
                psxCpu->Shutdown();
-#ifdef PSXREC
+#ifndef DRC_DISABLE
                if (Config.Cpu == CPU_INTERPRETER) psxCpu = &psxInt;
                else psxCpu = &psxRec;
 #else