all repos — mgba @ 268e9138c6a4e0fb3101c735cd4430f013e38134

mGBA Game Boy Advance Emulator

GBA Video: Deserialization fixes on big endian
Jeffrey Pfau jeffrey@endrift.com
Sun, 04 Oct 2015 21:21:07 -0700
commit

268e9138c6a4e0fb3101c735cd4430f013e38134

parent

2ea44603a810320af7a90d0dd4bb96116aca239d

1 files changed, 9 insertions(+), 6 deletions(-)

jump to
M src/gba/video.csrc/gba/video.c

@@ -91,10 +91,10 @@ video->renderer->vram = video->vram;

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 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;