From 51a142aaf89fc5231b5a7b390ede08b1f7f1e08d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Jun 2019 20:16:19 -0700 Subject: [PATCH] GLK: ALAN2: Loading fixes --- engines/glk/alan2/glkio.h | 1 - engines/glk/alan2/inter.cpp | 2 +- engines/glk/alan2/main.cpp | 16 +++++++--------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/engines/glk/alan2/glkio.h b/engines/glk/alan2/glkio.h index 151bb7a3b55..8c1dee2ff5e 100644 --- a/engines/glk/alan2/glkio.h +++ b/engines/glk/alan2/glkio.h @@ -36,7 +36,6 @@ extern winid_t glkStatusWin; /* NB: this header must be included in any file which calls print() */ -#define print glkio_printf #undef printf #define printf glkio_printf diff --git a/engines/glk/alan2/inter.cpp b/engines/glk/alan2/inter.cpp index 02b4f4819f2..dd3ee9e0bd0 100644 --- a/engines/glk/alan2/inter.cpp +++ b/engines/glk/alan2/inter.cpp @@ -257,7 +257,7 @@ void interpret(adr) printf("PRINT \t%5ld, %5ld\t\"", fpos, len); col = 34; /* To format it better! */ } - print((char *)fpos, len); + print(fpos, len); if (stpflg) printf("\""); break; diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp index 2a1b884b3d7..a508041f7df 100644 --- a/engines/glk/alan2/main.cpp +++ b/engines/glk/alan2/main.cpp @@ -1519,18 +1519,15 @@ static void load() int i; char err[100]; - Aword *ptr = (Aword *)&tmphdr; + Aword *ptr = (Aword *)&tmphdr + 1; codfil->seek(0); - for (i = 0; i < sizeof(tmphdr) / sizeof(Aword); ++i, ++ptr) - *ptr = codfil->readUint32LE(); + codfil->read(&tmphdr.vers[0], 4); + for (i = 1; i < sizeof(tmphdr) / sizeof(Aword); ++i, ++ptr) + *ptr = codfil->readUint32BE(); checkvers(&tmphdr); /* Allocate and load memory */ -#ifdef REVERSED - reverseHdr(&tmphdr); -#endif - /* No memory allocated yet? */ if (memory == NULL) { #ifdef V25COMPATIBLE @@ -1548,7 +1545,8 @@ static void load() ::error("Header size is greater than filesize"); codfil->seek(0); - for (i = 0, ptr = memory; i < tmphdr.size; ++i, ++ptr) + codfil->read(&header->vers[0], 4); + for (i = 1, ptr = memory + 1; i < tmphdr.size; ++i, ++ptr) *ptr = codfil->readUint32LE(); /* Calculate checksum */ @@ -1573,7 +1571,7 @@ static void load() } } -#ifdef REVERSED +#if defined(SCUMM_LITTLE_ENDIAN) if (dbgflg||trcflg||stpflg) output("