workaround pandora hugetlb bug, revert this later
[pcsx_rearmed.git] / libpcsxcore / misc.c
index 034e5e0..27b9499 100644 (file)
@@ -142,6 +142,28 @@ int GetCdromFile(u8 *mdir, u8 *time, s8 *filename) {
        return 0;
 }
 
+static const unsigned int gpu_ctl_def[] = {
+       0x00000000, 0x01000000, 0x03000000, 0x04000000,
+       0x05000800, 0x06c60260, 0x0703fc10, 0x08000027,
+};
+
+static const unsigned int gpu_data_def[] = {
+       0xe100360b, 0xe2000000, 0xe3000800, 0xe4077e7f,
+       0xe5001000, 0xe6000000,
+       0x02000000, 0x00000000, 0x01ff03ff,
+};
+
+static void fake_bios_gpu_setup(void)
+{
+       int i;
+
+       for (i = 0; i < sizeof(gpu_ctl_def) / sizeof(gpu_ctl_def[0]); i++)
+               GPU_writeStatus(gpu_ctl_def[i]);
+
+       for (i = 0; i < sizeof(gpu_data_def) / sizeof(gpu_data_def[0]); i++)
+               GPU_writeData(gpu_data_def[i]);
+}
+
 int LoadCdrom() {
        EXE_HEADER tmpHead;
        struct iso_directory_record *dir;
@@ -149,7 +171,12 @@ int LoadCdrom() {
        u8 mdir[4096];
        s8 exename[256];
 
+       // not the best place to do it, but since BIOS boot logo killer
+       // is just below, do it here
+       fake_bios_gpu_setup();
+
        if (!Config.HLE) {
+               // skip BIOS logos
                psxRegs.pc = psxRegs.GPR.n.ra;
                return 0;
        }
@@ -337,6 +364,9 @@ int CheckCdrom() {
                }
        }
 
+       if (CdromId[0] == '\0')
+               strcpy(CdromId, "SLUS99999");
+
        if (Config.PsxAuto) { // autodetect system (pal or ntsc)
                if (CdromId[2] == 'e' || CdromId[2] == 'E')
                        Config.PsxType = PSX_TYPE_PAL; // pal
@@ -379,6 +409,22 @@ static int PSXGetFileType(FILE *f) {
        return INVALID_EXE;
 }
 
+// temporary pandora workaround..
+// FIXME: remove
+size_t fread_to_ram(void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+       void *tmp;
+       size_t ret = 0;
+       
+       tmp = malloc(size * nmemb);
+       if (tmp) {
+               ret = fread(tmp, size, nmemb, stream);
+               memcpy(ptr, tmp, size * nmemb);
+               free(tmp);
+       }
+       return ret;
+}
+
 int Load(const char *ExePath) {
        FILE *tmpFile;
        EXE_HEADER tmpHead;
@@ -405,7 +451,7 @@ int Load(const char *ExePath) {
                                mem = PSXM(section_address);
                                if (mem != NULL) {
                                        fseek(tmpFile, 0x800, SEEK_SET);                
-                                       fread(mem, section_size, 1, tmpFile);
+                                       fread_to_ram(mem, section_size, 1, tmpFile);
                                        psxCpu->Clear(section_address, section_size / 4);
                                }
                                fclose(tmpFile);
@@ -431,7 +477,7 @@ int Load(const char *ExePath) {
 #endif
                                                        mem = PSXM(section_address);
                                                        if (mem != NULL) {
-                                                               fread(mem, section_size, 1, tmpFile);
+                                                               fread_to_ram(mem, section_size, 1, tmpFile);
                                                                psxCpu->Clear(section_address, section_size / 4);
                                                        }
                                                        break;