HeadlinesBriefing favicon HeadlinesBriefing.com

The Wizard's Castle BASIC Game Secrets

Hacker News •
×

The first line of the 80s BASIC game "The Wizard's Castle," originally written for the Exidy Sorcerer, contains a cryptic REM statement: "10 REM"_(C2SLFF4. This seemingly garbled string was not a typo but an integral part of the game's pseudo-random number generator (PRNG) seeding process.

Analysis of the source code revealed that the "_(C2SLFF4" part was being interpreted as Z80 machine code by the USR() function, which was called to seed the RND() function. However, the initial disassembly of this "code" produced nonsensical instructions and did not appear to achieve the intended purpose of seeding the PRNG effectively, leading to speculation of a printing error.

Further investigation focused on the PEEK(-2049) command, which reads the last byte of screen text. This value was used to seed the PRNG. It was discovered that the REM statement's machine code was likely intended to place a value at the screen memory address read by PEEK() before the screen was cleared. A note in the original magazine publication confirmed that the first remark was indeed a machine language routine to simulate the RANDOM function, clarifying the purpose of the mysterious string.