notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
misc: Use GCC builtins for byte-swap operations
[pcsx_rearmed.git]
/
libpcsxcore
/
misc.c
diff --git
a/libpcsxcore/misc.c
b/libpcsxcore/misc.c
index
1b38e28
..
7aa4fef
100644
(file)
--- a/
libpcsxcore/misc.c
+++ b/
libpcsxcore/misc.c
@@
-21,6
+21,7
@@
* Miscellaneous functions, including savestates and CD-ROM loading.
*/
* Miscellaneous functions, including savestates and CD-ROM loading.
*/
+#include <stddef.h>
#include "misc.h"
#include "cdrom.h"
#include "mdec.h"
#include "misc.h"
#include "cdrom.h"
#include "mdec.h"
@@
-57,14
+58,7
@@
struct iso_directory_record {
void mmssdd( char *b, char *p )
{
int m, s, d;
void mmssdd( char *b, char *p )
{
int m, s, d;
-#if defined(__arm__)
- unsigned char *u = (void *)b;
- int block = (u[3] << 24) | (u[2] << 16) | (u[1] << 8) | u[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);
-#endif
+ int block = SWAP32(*((uint32_t*) b));
block += 150;
m = block / 4500; // minutes
block += 150;
m = block / 4500; // minutes
@@
-244,6
+238,7
@@
int LoadCdrom() {
tmpHead.t_addr = SWAP32(tmpHead.t_addr);
psxCpu->Clear(tmpHead.t_addr, tmpHead.t_size / 4);
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) {
// Read the rest of the main executable
while (tmpHead.t_size & ~2047) {
@@
-291,6
+286,7
@@
int LoadCdromFile(const char *filename, EXE_HEADER *head) {
addr = head->t_addr;
psxCpu->Clear(addr, size / 4);
addr = head->t_addr;
psxCpu->Clear(addr, size / 4);
+ psxCpu->Reset();
while (size & ~2047) {
incTime();
while (size & ~2047) {
incTime();
@@
-600,7
+596,8
@@
int SaveState(const char *file) {
SaveFuncs.write(f, psxM, 0x00200000);
SaveFuncs.write(f, psxR, 0x00080000);
SaveFuncs.write(f, psxH, 0x00010000);
SaveFuncs.write(f, psxM, 0x00200000);
SaveFuncs.write(f, psxR, 0x00080000);
SaveFuncs.write(f, psxH, 0x00010000);
- SaveFuncs.write(f, (void *)&psxRegs, sizeof(psxRegs));
+ // only partial save of psxRegisters to maintain savestate compat
+ SaveFuncs.write(f, &psxRegs, offsetof(psxRegisters, gteBusyCycle));
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
@@
-664,7
+661,8
@@
int LoadState(const char *file) {
SaveFuncs.read(f, psxM, 0x00200000);
SaveFuncs.read(f, psxR, 0x00080000);
SaveFuncs.read(f, psxH, 0x00010000);
SaveFuncs.read(f, psxM, 0x00200000);
SaveFuncs.read(f, psxR, 0x00080000);
SaveFuncs.read(f, psxH, 0x00010000);
- SaveFuncs.read(f, (void *)&psxRegs, sizeof(psxRegs));
+ SaveFuncs.read(f, &psxRegs, offsetof(psxRegisters, gteBusyCycle));
+ psxRegs.gteBusyCycle = psxRegs.cycle;
if (Config.HLE)
psxBiosFreeze(0);
if (Config.HLE)
psxBiosFreeze(0);
@@
-675,7
+673,7
@@
int LoadState(const char *file) {
GPU_freeze(0, gpufP);
free(gpufP);
if (HW_GPU_STATUS == 0)
GPU_freeze(0, gpufP);
free(gpufP);
if (HW_GPU_STATUS == 0)
- HW_GPU_STATUS =
GPU_readStatus(
);
+ HW_GPU_STATUS =
SWAP32(GPU_readStatus()
);
// spu
SaveFuncs.read(f, &Size, 4);
// spu
SaveFuncs.read(f, &Size, 4);