Prev: 16384 Up: Map Next: 23460
23424: Decrypt Game
The stub which the tape loader runs once the game has been loaded at 24576. It decrypts the whole game, 32768 bytes, two bytes at a time, and then moves the game down by 512 bytes to its real home at GameStart before starting it.
The tape loader sets up this stub, and the game checks for the loader's signature in the frame counter (see InitialiseGame).
Set up the first pair and the number of pairs to decrypt.
DecryptGame 23424 LD DE,24576 Set DE to 24576, the address of the first byte of the pair to decrypt.
23427 LD HL,24577 Set HL to 24577, the address of the second byte of the pair.
23430 LD BC,16384 Set BC to 16384, the number of byte pairs to decrypt.
Start rotating each byte through A to decrypt it.
DecryptGame_Loop 23433 LD A,(DE) Fetch the first byte of the pair.
23434 RLD Rotate the nibbles of the two bytes through A.
23436 LD (DE),A Write the decrypted byte back.
23437 INC DE Move on to the first byte of the next pair.
23438 INC DE
23439 INC HL Move HL onto the second byte of the next pair.
23440 INC HL
23441 DEC BC Decrease the pair counter by one.
23442 LD A,B Loop back to DecryptGame_Loop until every pair has been decrypted.
23443 OR C
23444 JR NZ,DecryptGame_Loop
Move the decrypted game down to its real address and start it.
23446 LD HL,24576 Copy 32768 bytes of the game from 24576 to GameStart.
23449 LD DE,24064
23452 LD BC,32768
23455 LDIR
23457 JP GameStart Jump to GameStart to start the game.
Prev: 16384 Up: Map Next: 23460