Prev: 6022 Up: Map Next: 6047
602E: Decrypt Game
Copied to 5B80 by Copy_Loader. After the game has been loaded to 5E80 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 602E LD SP,$FE00 Set the stack pointer to FE00.
6031 DI Disable interrupts.
6032 CALL $FC00 Call FC00 to move the game down to 5C80.
Decrypt every byte from FA00 down to 5C01.
6035 LD HL,$FA00 Set the start address in HL to FA00.
6038 XOR A Clear the nibble carried between bytes in A.
6039 LD BC,$9E00 Set the byte count in BC to 9E00.
Start rotating each byte through A to decrypt it.
Decrypt_Game_Loop 603C RRD Rotate the nibbles of the current byte through A.
603E DEC HL Move down to the previous byte.
603F DEC C Decrease the low byte of the counter by one and loop back to Decrypt_Game_Loop until none remain.
6040 JR NZ,Decrypt_Game_Loop
6042 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.
6044 JP $5C80 Jump to StartGame.
Prev: 6022 Up: Map Next: 6047