Skip to content

Faxanadu Mantras - Part II


As I had promised in my last update here's a complete discussion of the mantra checking code of the NES game Faxanadu.

If you don't know the 6502 assembler instructions yet now might be the best time to read about them.

Here are some prerequisites you need to know before you can fully understand the code you will find in the rest of this post: The mantra is a password that can be 0 to 32 characters long. There are 64 valid characters (A-Za-z0-9,?) that can be used in mantras. They are represented in memory by their numeric value. The numeric values are between 0 for the character 'A' and 0x3F for the symbol '?'. When a user enters a mantra this numeric data is stored in a 0x20 bytes long field starting at memory offset 0x600. In the following code the data in this array is transformed and stored in another array starting at 0x4CD.

Let's recall what I had already posted last time, the code where the mantra is checked for validity.

CODE:
$914f-> ad 66 06: LDA $0666 ; $0666 = Length of Mantra <br />$9152-> f0 21:    BEQ $9175 ; Branch if no mantra was entered <br />$9154-> 20 50 98: JSR $9850 ; Check checksum of mantra <br />$9157-> b0 06:    BCS $915f ; Branch if wrong checksum <br />$9159-> 20 e9 95: JSR $95e9 ; Check data of mantra <br />$915c-> b0 01:    BCS $915f ; Branch if wrong data <br />$915e-> 60:       RTS       ; If this point is reached <br />                            ; a valid mantra was entered
Continue reading "Faxanadu Mantras - Part II"