X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fmisc.c;h=2fe5600a10127c1d3e9a3abbd921954be4ab810a;hp=ef4924407991e6f24ef74e4632e764d928d5a53c;hb=f3a78e7ea779e6187d571056e0c97823b09a7bb0;hpb=ef79bbde537d6b9c745a7d86cb9df1d04c35590d diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index ef492440..2fe5600a 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -24,6 +24,7 @@ #include "misc.h" #include "cdrom.h" #include "mdec.h" +#include "gpu.h" #include "ppf.h" char CdromId[10] = ""; @@ -54,7 +55,9 @@ struct iso_directory_record { void mmssdd( char *b, char *p ) { int m, s, d; -#if defined(__BIGENDIAN__) +#if defined(__arm__) + int block = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0]; +#elif defined(__BIGENDIAN__) int block = (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | (b[3] << 24); #else int block = *((int*)b); @@ -139,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; @@ -146,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; } @@ -207,8 +237,10 @@ int LoadCdrom() { tmpHead.t_size = SWAP32(tmpHead.t_size); tmpHead.t_addr = SWAP32(tmpHead.t_addr); + psxCpu->Clear(tmpHead.t_addr, tmpHead.t_size / 4); + // Read the rest of the main executable - while (tmpHead.t_size) { + while (tmpHead.t_size & ~2047) { void *ptr = (void *)PSXM(tmpHead.t_addr); incTime(); @@ -250,7 +282,9 @@ int LoadCdromFile(const char *filename, EXE_HEADER *head) { size = head->t_size; addr = head->t_addr; - while (size) { + psxCpu->Clear(addr, size / 4); + + while (size & ~2047) { incTime(); READTRACK(); @@ -331,7 +365,7 @@ int CheckCdrom() { } if (Config.PsxAuto) { // autodetect system (pal or ntsc) - if (strstr(exename, "ES") != NULL) + if (CdromId[2] == 'e' || CdromId[2] == 'E') Config.PsxType = PSX_TYPE_PAL; // pal else Config.PsxType = PSX_TYPE_NTSC; // ntsc } @@ -379,6 +413,7 @@ int Load(const char *ExePath) { int retval = 0; u8 opcode; u32 section_address, section_size; + void *mem; strncpy(CdromId, "SLUS99999", 9); strncpy(CdromLabel, "SLUS_999.99", 11); @@ -392,8 +427,14 @@ int Load(const char *ExePath) { switch (type) { case PSX_EXE: fread(&tmpHead,sizeof(EXE_HEADER),1,tmpFile); - fseek(tmpFile, 0x800, SEEK_SET); - fread((void *)PSXM(SWAP32(tmpHead.t_addr)), SWAP32(tmpHead.t_size),1,tmpFile); + section_address = SWAP32(tmpHead.t_addr); + section_size = SWAP32(tmpHead.t_size); + mem = PSXM(section_address); + if (mem != NULL) { + fseek(tmpFile, 0x800, SEEK_SET); + fread(mem, section_size, 1, tmpFile); + psxCpu->Clear(section_address, section_size / 4); + } fclose(tmpFile); psxRegs.pc = SWAP32(tmpHead.pc0); psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0); @@ -415,7 +456,11 @@ int Load(const char *ExePath) { #ifdef EMU_LOG EMU_LOG("Loading %08X bytes from %08X to %08X\n", section_size, ftell(tmpFile), section_address); #endif - fread(PSXM(section_address), section_size, 1, tmpFile); + mem = PSXM(section_address); + if (mem != NULL) { + fread(mem, section_size, 1, tmpFile); + psxCpu->Clear(section_address, section_size / 4); + } break; case 3: /* register loading (PC only?) */ fseek(tmpFile, 2, SEEK_CUR); /* unknown field */ @@ -456,7 +501,7 @@ static const char PcsxHeader[32] = "STv4 PCSX v" PACKAGE_VERSION; // Savestate Versioning! // If you make changes to the savestate version, please increment the value below. -static const u32 SaveVersion = 0x8b410004; +static const u32 SaveVersion = 0x8b410006; int SaveState(const char *file) { gzFile f; @@ -468,6 +513,8 @@ int SaveState(const char *file) { f = gzopen(file, "wb"); if (f == NULL) return -1; + new_dyna_save(); + gzwrite(f, (void *)PcsxHeader, 32); gzwrite(f, (void *)&SaveVersion, sizeof(u32)); gzwrite(f, (void *)&Config.HLE, sizeof(boolean)); @@ -511,6 +558,8 @@ int SaveState(const char *file) { gzclose(f); + new_dyna_after_save(); + return 0; } @@ -530,10 +579,14 @@ int LoadState(const char *file) { gzread(f, &version, sizeof(u32)); gzread(f, &hle, sizeof(boolean)); - if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion || hle != Config.HLE) { + if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion) { gzclose(f); return -1; } + Config.HLE = hle; + + if (Config.HLE) + psxBiosInit(); psxCpu->Reset(); gzseek(f, 128 * 96 * 3, SEEK_CUR); @@ -551,6 +604,8 @@ int LoadState(const char *file) { gzread(f, gpufP, sizeof(GPUFreeze_t)); GPU_freeze(0, gpufP); free(gpufP); + if (HW_GPU_STATUS == 0) + HW_GPU_STATUS = GPU_readStatus(); // spu gzread(f, &Size, 4); @@ -566,6 +621,7 @@ int LoadState(const char *file) { mdecFreeze(f, 0); gzclose(f); + new_dyna_restore(); return 0; } @@ -585,7 +641,7 @@ int CheckState(const char *file) { gzclose(f); - if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion || hle != Config.HLE) + if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion) return -1; return 0;