Prev: 11A7 Up: Map Next: 12A2
The address of this routine is found in the parameter table.
NEW 11B7 DI Disable the maskable interrupt.
11B8 LD A,$FF The NEW flag.
11BA LD DE,($5CB2) The existing value of RAMTOP is preserved.
11BE EXX Load the alternate registers with the following system variables (P-RAMT, RASP, PIP, UDG). All of which will also be preserved.
11BF LD BC,($5CB4)
11C3 LD DE,($5C38)
11C7 LD HL,($5C7B)
This entry point is used by the routine at START.
The main entry point.
START_NEW 11CB LD B,A Save the flag for later.
11CC LD A,$07 Make the border white in colour.
11CE OUT ($FE),A
11D0 LD A,$3F Set the I register to hold the value of +3F.
11D2 LD I,A
11D4 NOP Wait 24 T states.
11D5 NOP
11D6 NOP
11D7 NOP
11D8 NOP
11D9 NOP
Now the memory is checked.
11DA LD H,D Transfer the value in DE (START=+FFFF, NEW=RAMTOP).
RAM_FILL 11DC LD (HL),$02 Enter the value of +02 into every location above +3FFF.
RAM_READ 11E2 AND A Prepare for true subtraction.
11E3 SBC HL,DE The carry flag will become reset when the top is reached.
11E6 INC HL Update the pointer.
11E7 JR NC,RAM_DONE Jump when at top.
11E9 DEC (HL) +02 goes to +01.
11EA JR Z,RAM_DONE But if zero then RAM is faulty. Use current HL as top.
11EC DEC (HL) +01 goes to +00.
11ED JR Z,RAM_READ Step to the next test unless it fails.
RAM_DONE 11EF DEC HL HL points to the last actual location in working order.
Next restore the 'preserved' system variables. (Meaningless when coming from START.)
11F0 EXX Restore P-RAMT, RASP, PIP and UDG.
11F1 LD ($5CB4),BC
11F5 LD ($5C38),DE
11F9 LD ($5C7B),HL
11FD INC B Test the START/NEW flag.
11FE JR Z,RAM_SET Jump forward if coming from the NEW command routine.
Overwrite the system variables when coming from START and initialise the user-defined graphics area.
1200 LD ($5CB4),HL Top of physical RAM (P-RAMT).
1203 LD DE,$3EAF Last byte of 'U' in character set.
1206 LD BC,$00A8 There are this number of bytes in twenty one letters.
1209 EX DE,HL Switch the pointers.
120A LDDR Now copy the character forms of the letters 'A' to 'U'.
120C EX DE,HL Switch the pointers back.
120D INC HL Point to the first byte.
120E LD ($5C7B),HL Now set UDG.
1211 DEC HL Down one location.
1212 LD BC,$0040 Set the system variables RASP and PIP.
1215 LD ($5C38),BC
The remainder of the routine is common to both the START and the NEW operations.
RAM_SET 1219 LD ($5CB2),HL Set RAMTOP.
121C LD HL,$3C00 Initialise the system variable CHARS.
121F LD ($5C36),HL
Next the machine stack is set up.
1222 LD HL,($5CB2) The top location (RAMTOP) is made to hold +3E.
1225 LD (HL),$3E
1227 DEC HL The next location is left holding zero.
1228 LD SP,HL These two locations represent the 'last entry'.
1229 DEC HL Step down two locations to find the correct value for ERR-SP.
122B LD ($5C3D),HL
The initialisation routine continues with:
122E IM 1 Interrupt mode 1 is used.
1230 LD IY,$5C3A IY holds +ERR-NR always.
1234 EI The maskable interrupt can now be enabled. The real-time clock will be updated and the keyboard scanned every 1/50th of a second.
1235 LD HL,$5CB6 The system variable CHANS is set to the base address of the channel information area.
1238 LD ($5C4F),HL
123B LD DE,$15AF The initial channel data is moved from the table (CHANINFO) to the channel information area.
123E LD BC,$0015
1241 EX DE,HL
1242 LDIR
1244 EX DE,HL The system variable DATADD is made to point to the last location of the channel data.
1245 DEC HL
1246 LD ($5C57),HL
1249 INC HL And PROG and VARS to the the location after that.
124A LD ($5C53),HL
124D LD ($5C4B),HL
1250 LD (HL),$80 The end-marker of the variables area.
1252 INC HL Move on one location to find the value for E-LINE.
1253 LD ($5C59),HL
1256 LD (HL),$0D Make the edit-line be a single 'carriage return' character.
1258 INC HL
1259 LD (HL),$80 Now enter an end marker.
125B INC HL Move on one location to find the value for WORKSP, STKBOT and STKEND.
125C LD ($5C61),HL
125F LD ($5C63),HL
1262 LD ($5C65),HL
1265 LD A,$38 Initialise the colour system variables (ATTR-P, ATTR-T, BORDCR) to FLASH 0, BRIGHT 0, PAPER 7, INK 0, BORDER 7.
1267 LD ($5C8D),A
126A LD ($5C8F),A
126D LD ($5C48),A
1270 LD HL,$0523 Initialise the system variables REPDEL and REPPER.
1273 LD ($5C09),HL
1276 DEC (IY-$3A) Make KSTATE0 hold +FF.
1279 DEC (IY-$36) Make KSTATE4 hold +FF.
127C LD HL,$15C6 Next move the initial stream data from its table to the streams area.
127F LD DE,$5C10
1282 LD BC,$000E
1285 LDIR
1287 SET 1,(IY+$01) Signal 'printer in use' (set bit 1 of FLAGS) and clear the printer buffer.
128E LD (IY+$31),$02 Set the size of the lower part of the display (DF-SZ) and clear the whole display.
1295 XOR A Now print the message '© 1982 Sinclair Research Ltd' on the bottom line.
1296 LD DE,$1538
129C SET 5,(IY+$02) Signal 'the lower part will required to be cleared' (set bit 5 of TV-FLAG).
12A0 JR MAIN_1 Jump forward into the main execution loop.
Prev: 11A7 Up: Map Next: 12A2