Prev: 24610 Up: Map Next: 24647
24622: Decrypt Game
Copied to 23424 by Copy_Loader. After the game has been loaded to 24192 this moves it down and decrypts it from the top with RRD, then starts the game at StartGame.
Set up the stack and move the game down into place.
Decrypt_Game 24622 LD SP,65024 Set the stack pointer to 65024.
24625 DI Disable interrupts.
24626 CALL 64512 Call 64512 to move the game down to 23680.
Decrypt every byte from 64000 down to 23553.
24629 LD HL,64000 Set the start address in HL to 64000.
24632 XOR A Clear the nibble carried between bytes in A.
24633 LD BC,40448 Set the byte count in BC to 40448.
Start rotating each byte through A to decrypt it.
Decrypt_Game_Loop 24636 RRD Rotate the nibbles of the current byte through A.
24638 DEC HL Move down to the previous byte.
24639 DEC C Decrease the low byte of the counter by one and loop back to Decrypt_Game_Loop until none remain.
24640 JR NZ,Decrypt_Game_Loop
24642 DJNZ Decrypt_Game_Loop Decrease the high byte of the counter by one and loop back to Decrypt_Game_Loop until every byte has been decrypted.
24644 JP 23680 Jump to StartGame.
Prev: 24610 Up: Map Next: 24647