From aa3d0e7c14475354c68402d1e020f392ed6e8144 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 28 Mar 2024 18:10:27 +0200 Subject: [PATCH] Ensure that the first code executed is our decryption routine This pull-request closes #37, by making sure the first code we run in our binary is our decryption code (if that is enabled). Previously we ran some code: call foo [decrypt code] [start of encrypted code] foo: [end of encrypted code] If we called a routine that was after the decryption code we'd be running gibberish. This seemed to work by accident in some systems, but was obviously broken. --- game.z80 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/game.z80 b/game.z80 index c9c2ff2..8ce4360 100644 --- a/game.z80 +++ b/game.z80 @@ -143,9 +143,6 @@ MACRO POP_ALL ; ORG ENTRYPOINT - ; Call system-specific setup routine before we do anything else. - call bios_init - ; ; Our game can be compiled with optional "encryption", which uses ; a simple scheme to hide the strings in our binary. @@ -181,6 +178,10 @@ enc_loop: enc_end: ENDIF + ; Call system-specific setup routine before we do anything else. + call bios_init + + ; Here we're going to copy our game-state to the end of RAM ; ; We do this so that everything "resets" if the player dies/wins