![]() |
Routines |
| Prev: 16384 | Up: Map | Next: 23728 |
|
The stub that the tape loader runs after loading the game, which arrives scrambled at 24576 (34816 bytes of it). It unscrambles the game in place, moves it down by 512 bytes so that it starts at GameEntry, and jumps there.
Each pair of bytes is unscrambled by a single RLD: the low nibble of the first byte of the pair is replaced by the high nibble of the second byte, the high nibble of the second byte by its low nibble, and the low nibble of the second byte by the old low nibble of the first byte.
The routine also sets bit 7 of the memory refresh register R. Nothing in the game ever clears that bit, and the game resets the computer if it is clear when the check at BuildRandomTable runs, which defeats any attempt to start the game without going through this stub. The random number generator at RandomNumber also reads R, so that bit keeps those values in the range 128 to 255.
|
||||
|
Set bit 7 of the memory refresh register for the random number generator.
|
||||
| Decryption | 23424 | DI | Disable interrupts. | |
| 23425 | LD A,R | Fetch the memory refresh register into A. | ||
| 23427 | OR %10000000 | Set bit 7. The Z80 leaves that bit as it is written, so RandomNumber always mixes a value from 128 to 255 into the random number. | ||
| 23429 | LD R,A | Write A back to the memory refresh register. | ||
|
Unscramble the whole game, a pair of bytes at a time.
|
||||
| 23431 | LD DE,24576 | Set DE to 24576, the first byte of the first pair. | ||
| 23434 | LD HL,24577 | Set HL to 24577, the second byte of the first pair. | ||
| 23437 | LD BC,17408 | Set a pair counter in BC to 17408. | ||
| Decryption_Loop | 23440 | LD A,(DE) | Fetch the first byte of the pair. | |
| 23441 | RLD | Rotate the nibbles of the pair. | ||
| 23443 | LD (DE),A | Write the unscrambled first byte back. | ||
| 23444 | INC DE | Move DE on to the first byte of the next pair. | ||
| 23445 | INC DE | |||
| 23446 | INC HL | Move HL on to the second byte of the next pair. | ||
| 23447 | INC HL | |||
| 23448 | DEC BC | Decrease the pair counter by one. | ||
| 23449 | LD A,B | Jump to Decryption_Loop until every pair has been unscrambled. | ||
| 23450 | OR C | |||
| 23451 | JR NZ,Decryption_Loop | |||
|
Move the unscrambled game down so that it starts at GameEntry.
|
||||
| 23453 | LD HL,24576 | Move 34816 bytes from 24576 down to GameEntry. | ||
| 23456 | LD DE,24064 | |||
| 23459 | LD BC,34816 | |||
| 23462 | LDIR | |||
| 23464 | JP GameEntry | Jump to GameEntry to start the game. | ||
|
View the equivalent code in;
|
||||
| Prev: 16384 | Up: Map | Next: 23728 |