Back to Skool Routines
33013: Save routine
This is the program used to save the fast code block for Back to Skool.
If the load routine at 32815 is modified to set SP to something other than 33020 (so that the bytes in that area are not corrupted by stack operations), this is the result:
33013 LD HL,33204 33204 is where we go after loading has finished
33016 LD (23833),HL
33019 EXX After bytes 16384 to 32956 have been saved, a further 65535 bytes are saved, starting at 32971, moving forward in steps of 23 bytes, and ending at 32925 (32948 is missed out)
33020 LD BC,23
33023 EXX
33024 LD IX,16384 Start saving at 16384 (first byte of display file)
33028 LD DE,16572 16384 to 32956 will be saved first
33031 LD A,255
33033 LD HL,3224
33036 EX AF,AF'
33037 INC DE
33038 DEC IX
33040 DI
33041 LD A,2
33043 LD B,A
33044 DJNZ 33044
33046 OUT (254),A
33048 XOR 15
33050 LD B,164
33052 DEC L
33053 JR NZ,33044
33055 DEC B
33056 DEC H
33057 JP P,33044
33060 LD B,47
33062 DJNZ 33062
33064 OUT (254),A
33066 LD A,13
33068 LD B,55
33070 DJNZ 33070
33072 OUT (254),A
33074 LD BC,6670
33077 EX AF,AF'
33078 LD L,A
33079 JP 33091
33082 LD A,D
33083 LD A,D
33084 JR Z,33098
33086 LD L,(IX+0)
33089 LD A,H
33090 XOR L
33091 LD H,A
33092 LD A,1
33094 SCF
33095 JP 33121
33098 LD L,H
33099 JR 33089
33101 LD A,C
33102 BIT 7,B
33104 DJNZ 33104
33106 JR NC,33112
33108 LD B,32
33110 DJNZ 33110
33112 OUT (254),A
33114 LD B,29
33116 JR NZ,33101
33118 DEC B
33119 XOR A
33120 INC A
33121 RL L
33123 JP NZ,33104
33126 DEC DE
33127 INC IX
33129 LD B,16
33131 LD A,127
33133 IN A,(254)
33135 RRA
33136 RET NC
33137 LD A,D Have we saved 16384 to 32956 yet?
33138 INC A
33139 JP NZ,33082 Jump back if not
33142 LD A,D IX=32957 and DE=65535 the first time we get here
33143 OR E
33144 JR Z,33158 Jump if we have now saved 32971 onwards
33146 LD L,(IX+14) IX+14=32971 the first time we get here
33149 LD A,H
33150 XOR L
33151 LD H,A
33152 LD A,1
33154 SCF
33155 JP 33181
33158 LD L,0
33160 RET
33161 LD A,C
33162 BIT 7,B
33164 DJNZ 33164
33166 JR NC,33172
33168 LD B,32
33170 DJNZ 33170
33172 OUT (254),A
33174 LD B,29
33176 JR NZ,33161
33178 DEC B
33179 XOR A
33180 INC A
33181 RL L
33183 JP NZ,33164
33186 DEC DE
33187 EXX
33188 ADD IX,BC
33190 EXX
33191 LD B,16
33193 LD A,127
33195 IN A,(254)
33197 RRA
33198 JP 33142
The last few bytes of the first group (16384 to 32956) saved are important:
32952 JR NZ,32893 This replaces the "JR NZ,32907" in the load routine
32954 DEFB 32 These bytes will be loaded into addresses 32902, 32925 and 32948 (which already contain 32, 221 and 173) respectively by the load routine
32955 DEFB 221
32956 DEFB 173