![]() |
Routines |
| Prev: 16384 | Up: Map | Next: 23552 |
|
The loader copies this routine here and runs it once the encrypted game has been loaded to 24192. The helper at 24576 copies this stub here and the move routine to 64512. It first moves the game down to its home at 23680 (see CopyGameDown) and then decrypts it, one byte at a time and from the top down, by running RRD over 40448 bytes starting at 64000. Each RRD passes a nibble along from one byte to the next, so the whole game is stored shifted by half a byte. Control then goes to StartGame. Once the game is running the space up to 23551 is reused, for the records of the segments of the four tiles that DrawTerrain makes (starting at 23424, 23461, 23498 and 23535). That routine also sets the stack pointer to 23418.
|
||||
|
Set up the stack and move the game down into place.
|
||||
| GameEntry | 23424 | LD SP,65024 | Set the stack pointer to 65024. | |
| 23427 | DI | Disable interrupts. | ||
| 23428 | CALL CopyGameDown | Call CopyGameDown to move the game down to 23680. | ||
|
Decrypt every byte from 64000 down to 23553.
|
||||
| 23431 | LD HL,64000 | Set the start address in HL to 64000. | ||
| 23434 | XOR A | Clear the nibble carried between bytes in A. | ||
| 23435 | LD BC,40448 | Set the byte count in BC to 40448. | ||
| Decryption_Loop | 23438 | RRD | Rotate the nibbles of the current byte through A. | |
| 23440 | DEC HL | Move down to the previous byte. | ||
| 23441 | DEC C | Decrease the low byte of the counter by one and loop back to Decryption_Loop until none remain. | ||
| 23442 | JR NZ,Decryption_Loop | |||
| 23444 | DJNZ Decryption_Loop | Decrease the high byte of the counter by one and loop back to Decryption_Loop until every byte has been decrypted. | ||
| 23446 | JP StartGame | Jump to StartGame. | ||
| Prev: 16384 | Up: Map | Next: 23552 |