| Load routines

24055: After the program 'samcruise' has loaded, this is where it all starts...

| This is the initial loader program for Contact Sam Cruise (as it appears after doing 'POKE 23762,0' to change the INK for the BASIC listing from white to black). Don't be fooled by the 'RANDOMIZE USR 23794': the floating point number stored underneath is actually 24055.
Entering the code here from BASIC means that C=247 (the LSB of 24055); this value is used later on in the routine at 32815.
24055 | JP 23831 | Jump to where it really starts
And this is where it really starts.
23831 | DI | Disable interrupts
23832 | LD B,49 |
23834 | LD DE,65487 |
23837 | CALL 24047 |
And so begins the misdirection.
24047 | POP HL | HL=23840
24048 | ADD HL,DE | HL=23791
24049 | PUSH HL |
24050 | LD DE,7 |
24053 | ADD HL,DE | HL=23798
24054 | RET | Jump to 23791
Undo some code obfuscation before continuing.
23791 | LD A,(HL) | Do some XOR-ing on the 49 bytes from 23798 to 23846
23792 | XOR H
23793 | XOR L
23794 | LD (HL),A
23795 | INC HL
23796 | DJNZ 23791
After the XOR-ing:
23798 | EXX |
23799 | EX (SP),HL | HL'=11563
23800 | LD A,H | A=45
23801 | AND L | A=41
23802 | ADD A,L | A=84
23803 | ADD A,L | A=127
23804 | LD H,A | H'=127
23805 | ADD A,78 | A=205
23807 | LD L,A | HL'=32717
23808 | EXX |
23809 | LD HL,23551 | INK 1: PAPER 1
23812 | LD (HL),9
23814 | DEC HL
23815 | BIT 3,H
23817 | JR NZ,23812
23819 | LD (HL),0 | Clear the display file
23821 | DEC HL
23822 | BIT 6,H
23824 | JR NZ,23819
23826 | INC E | DE=9
23827 | INC E
23828 | CALL 24047 |
More misdirection.
24047 | POP HL | HL=23831
24048 | ADD HL,DE | HL=23840
24049 | PUSH HL |
24050 | LD DE,7 |
24053 | ADD HL,DE | HL=23847
24054 | RET | Jump to 23840
Undo some more code obfuscation before continuing.
23840 | LD A,(HL) | Do some XOR-ing and RLC-ing on the 217 bytes from 23847 to 24063
23841 | XOR E
23842 | RLCA
23843 | LD (HL),A
23844 | INC L
23845 | JR NZ,23840
After the XOR-ing and RLC-ing:
23847 | PUSH HL | HL=23808
23848 | EXX |
23849 | POP DE | DE'=23808
23850 | EX DE,HL | DE'=32717
23851 | LD BC,255 | Copy 255 bytes from 23808-24062 to 32717-32971
23854 | LDIR
23856 | LD E,A | E'=47
23857 | EX DE,HL | HL'=32815
23858 | JP (HL) | Jump to 32815