![]() |
Routines |
| Prev: 64000 | Up: Map | Next: 65060 |
|
Used by the routine at 23820.
|
||||
|
The code here was copied at 23820 after the first tape data block was loaded - the first part here is a copy of this.
Avalon's data (as stored on tape) is encrypted using a simple algorithm.
The game memory from 25001 to 64000 is unencrypted in the instructions from 65023.
|
||||
| 65000 | LD SP,65530 | Put the stack pointer (nearly) at the top of RAM | ||
| 65003 | LD IX,25001 | IX = address pointer at start of data block to LOAD | ||
| 65007 | LD DE,39000 | Data block length (code up to RAM address 64000) | ||
| 65010 | LD A,255 | Indicates a data block to load (rather than header) | ||
| 65012 | SCF | Sets the carry flag, which tells the ROM routine to perform a LOAD | ||
|
The next 4 instructions are in the ROM loading routine just before 1377, executed here just before the jump there at 65020 (as it's not loading a header block)
|
||||
| 65013 | INC D | |||
| 65014 | EX AF,AF' | |||
| 65015 | DEC D | |||
| 65016 | DI | |||
| 65017 | LD HL,65023 | This is the address that the code in the following instructions (starting from 65023) will be at after the copy at the start of this routine. | ||
| 65020 | JP 1377 | Launch the ROM loading routine | ||
|
Unencrypt all game code and data. A reverse encoding of this would've been done before the data was saved to tape.
|
||||
| 65023 | LD HL,25001 | Start address | ||
| 65026 | LD DE,39000 | Number of bytes to work through | ||
|
Unencryption loop:
|
||||
| 65029 | LD A,(HL) | Get byte | ||
| 65030 | XOR %01100110 | XOR to reverse the bits | ||
| 65032 | RRCA | Rotate right/divide by 2 | ||
| 65033 | XOR L | A second XOR to reverse the bytes, using the low byte of the address pointer | ||
| 65034 | LD (HL),A | Re-store the unencrypted byte into memory | ||
| 65035 | INC HL | Move to the next memory address | ||
| 65036 | DEC DE | Decrement the number-of-bytes counter | ||
| 65037 | LD A,D | Check for zero | ||
| 65038 | OR E | |||
| 65039 | JR NZ,65029 | If not, continue to unencrypt the data | ||
|
Data in memory is now unpacked/unencrypted
|
||||
| 65041 | LD A,2 | |||
| 65043 | LD (23659),A | Enable screen character rows 22 & 23 for INPUT/errors | ||
| 65046 | EI | Enable interrupts | ||
| 65047 | JP 62283 | Jump to the code input routine | ||
|
Unused data
|
||||
| 65050 | DEFB 32,32,32,32,32,32,32,32 | |||
| 65058 | DEFB 32,32 | |||
| Prev: 64000 | Up: Map | Next: 65060 |