From 268e9138c6a4e0fb3101c735cd4430f013e38134 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 4 Oct 2015 21:21:07 -0700 Subject: [PATCH] GBA Video: Deserialization fixes on big endian --- src/gba/video.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gba/video.c b/src/gba/video.c index 6e9804f36..054476b51 100644 --- a/src/gba/video.c +++ b/src/gba/video.c @@ -91,10 +91,10 @@ void GBAVideoReset(struct GBAVideo* video) { int i; for (i = 0; i < 128; ++i) { - video->oam.raw[i * 4] = 0x0200; - video->oam.raw[i * 4 + 1] = 0x0000; - video->oam.raw[i * 4 + 2] = 0x0000; - video->oam.raw[i * 4 + 3] = 0x0000; + STORE_16(0x0200, i * 8 + 0, video->oam.raw); + STORE_16(0x0000, i * 8 + 2, video->oam.raw); + STORE_16(0x0000, i * 8 + 4, video->oam.raw); + STORE_16(0x0000, i * 8 + 6, video->oam.raw); } video->renderer->deinit(video->renderer); @@ -288,12 +288,15 @@ void GBAVideoSerialize(const struct GBAVideo* video, struct GBASerializedState* void GBAVideoDeserialize(struct GBAVideo* video, const struct GBASerializedState* state) { memcpy(video->renderer->vram, state->vram, SIZE_VRAM); + uint16_t value; int i; for (i = 0; i < SIZE_OAM; i += 2) { - GBAStore16(video->p->cpu, BASE_OAM | i, state->oam[i >> 1], 0); + LOAD_16(value, i, state->oam); + GBAStore16(video->p->cpu, BASE_OAM | i, value, 0); } for (i = 0; i < SIZE_PALETTE_RAM; i += 2) { - GBAStore16(video->p->cpu, BASE_PALETTE_RAM | i, state->pram[i >> 1], 0); + LOAD_16(value, i, state->pram); + GBAStore16(video->p->cpu, BASE_PALETTE_RAM | i, value, 0); } video->nextEvent = state->video.nextEvent; video->eventDiff = state->video.eventDiff;