From f5ad5b00d0098f90416192a867f48dda4d607f51 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 26 Jun 2019 22:16:22 -0700 Subject: GLK: ALAN3: Fix endianness of loading temporary header --- engines/glk/alan3/main.cpp | 12 ++++++------ engines/glk/alan3/reverse.cpp | 2 +- engines/glk/alan3/reverse.h | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/glk/alan3/main.cpp b/engines/glk/alan3/main.cpp index 64f701934f..06e5895dcc 100644 --- a/engines/glk/alan3/main.cpp +++ b/engines/glk/alan3/main.cpp @@ -135,8 +135,12 @@ static int crcStart(char version[4]) { /*----------------------------------------------------------------------*/ static void readTemporaryHeader(ACodeHeader *tmphdr) { codfil->seek(0); - codfil->read(tmphdr, sizeof(*tmphdr)); - codfil->seek(0); + codfil->read(&tmphdr->tag[0], 4); + + Aword *ptr = (Aword *)tmphdr + 1; + uint i; + for (i = 1; i < sizeof(ACodeHeader) / sizeof(Aword); ++i, ++ptr) + *ptr = codfil->readUint32BE(); if (strncmp((char *)tmphdr, "ALAN", 4) != 0) playererr("Not an Alan game file, does not start with \"ALAN\""); @@ -365,10 +369,6 @@ static void load(void) { checkVersion(&tmphdr); /* Allocate and load memory */ - - if (littleEndian()) - reverseHdr(&tmphdr); - if (tmphdr.size <= sizeof(ACodeHeader) / sizeof(Aword)) syserr("Malformed game file. Too small."); diff --git a/engines/glk/alan3/reverse.cpp b/engines/glk/alan3/reverse.cpp index ca6db949af..6fa7aa56a3 100644 --- a/engines/glk/alan3/reverse.cpp +++ b/engines/glk/alan3/reverse.cpp @@ -573,7 +573,7 @@ static void reversePreBeta2() { /*======================================================================*/ -void reverseHdr(ACodeHeader *hdr) { +static void reverseHdr(ACodeHeader *hdr) { uint i; /* Reverse all words in the header except the tag and the version marking */ diff --git a/engines/glk/alan3/reverse.h b/engines/glk/alan3/reverse.h index ebcc0f5f8f..cca38c0c27 100644 --- a/engines/glk/alan3/reverse.h +++ b/engines/glk/alan3/reverse.h @@ -32,7 +32,6 @@ namespace Alan3 { /* Functions: */ -extern void reverseHdr(ACodeHeader *hdr); extern void reverseACD(void); extern void reverse(Aword *word); extern Aword reversed(Aword word); -- cgit v1.2.3