Prev: 04519 Up: Map Next: 04770
04535: THE 'NEW' COMMAND ROUTINE
The address of this routine is found in the parameter table.
NEW 04535 DI Disable the maskable interrupt.
04536 LD A,255 The NEW flag.
04538 LD DE,(23730) The existing value of RAMTOP is preserved.
04542 EXX Load the alternate registers with the following system variables (P-RAMT, RASP, PIP, UDG). All of which will also be preserved.
04543 LD BC,(23732)
04547 LD DE,(23608)
04551 LD HL,(23675)
04554 EXX
This entry point is used by the routine at START.
The main entry point.
START_NEW 04555 LD B,A Save the flag for later.
04556 LD A,7 Make the border white in colour.
04558 OUT (254),A
04560 LD A,63 Set the I register to hold the value of 63.
04562 LD I,A
04564 NOP Wait 24 T states.
04565 NOP
04566 NOP
04567 NOP
04568 NOP
04569 NOP
Now the memory is checked.
04570 LD H,D Transfer the value in DE (START=65535, NEW=RAMTOP).
04571 LD L,E
RAM_FILL 04572 LD (HL),2 Enter the value of 2 into every location above 16383.
04574 DEC HL
04575 CP H
04576 JR NZ,RAM_FILL
RAM_READ 04578 AND A Prepare for true subtraction.
04579 SBC HL,DE The carry flag will become reset when the top is reached.
04581 ADD HL,DE
04582 INC HL Update the pointer.
04583 JR NC,RAM_DONE Jump when at top.
04585 DEC (HL) 2 goes to 1.
04586 JR Z,RAM_DONE But if zero then RAM is faulty. Use current HL as top.
04588 DEC (HL) 1 goes to 0.
04589 JR Z,RAM_READ Step to the next test unless it fails.
RAM_DONE 04591 DEC HL HL points to the last actual location in working order.
Next restore the 'preserved' system variables. (Meaningless when coming from START.)
04592 EXX Restore P-RAMT, RASP, PIP and UDG.
04593 LD (23732),BC
04597 LD (23608),DE
04601 LD (23675),HL
04604 EXX
04605 INC B Test the START/NEW flag.
04606 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.
04608 LD (23732),HL Top of physical RAM (P-RAMT).
04611 LD DE,16047 Last byte of 'U' in character set.
04614 LD BC,168 There are this number of bytes in twenty one letters.
04617 EX DE,HL Switch the pointers.
04618 LDDR Now copy the character forms of the letters 'A' to 'U'.
04620 EX DE,HL Switch the pointers back.
04621 INC HL Point to the first byte.
04622 LD (23675),HL Now set UDG.
04625 DEC HL Down one location.
04626 LD BC,64 Set the system variables RASP and PIP.
04629 LD (23608),BC
The remainder of the routine is common to both the START and the NEW operations.
RAM_SET 04633 LD (23730),HL Set RAMTOP.
04636 LD HL,15360 Initialise the system variable CHARS.
04639 LD (23606),HL
Next the machine stack is set up.
04642 LD HL,(23730) The top location (RAMTOP) is made to hold 62.
04645 LD (HL),62
04647 DEC HL The next location is left holding zero.
04648 LD SP,HL These two locations represent the 'last entry'.
04649 DEC HL Step down two locations to find the correct value for ERR-SP.
04650 DEC HL
04651 LD (23613),HL
The initialisation routine continues with:
04654 IM 1 Interrupt mode 1 is used.
04656 LD IY,23610 IY holds +ERR-NR always.
04660 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.
04661 LD HL,23734 The system variable CHANS is set to the base address of the channel information area.
04664 LD (23631),HL
04667 LD DE,5551 The initial channel data is moved from the table (CHANINFO) to the channel information area.
04670 LD BC,21
04673 EX DE,HL
04674 LDIR
04676 EX DE,HL The system variable DATADD is made to point to the last location of the channel data.
04677 DEC HL
04678 LD (23639),HL
04681 INC HL And PROG and VARS to the the location after that.
04682 LD (23635),HL
04685 LD (23627),HL
04688 LD (HL),128 The end-marker of the variables area.
04690 INC HL Move on one location to find the value for E-LINE.
04691 LD (23641),HL
04694 LD (HL),13 Make the edit-line be a single 'carriage return' character.
04696 INC HL
04697 LD (HL),128 Now enter an end marker.
04699 INC HL Move on one location to find the value for WORKSP, STKBOT and STKEND.
04700 LD (23649),HL
04703 LD (23651),HL
04706 LD (23653),HL
04709 LD A,56 Initialise the colour system variables (ATTR-P, ATTR-T, BORDCR) to FLASH 0, BRIGHT 0, PAPER 7, INK 0, BORDER 7.
04711 LD (23693),A
04714 LD (23695),A
04717 LD (23624),A
04720 LD HL,1315 Initialise the system variables REPDEL and REPPER.
04723 LD (23561),HL
04726 DEC (IY-58) Make KSTATE0 hold 255.
04729 DEC (IY-54) Make KSTATE4 hold 255.
04732 LD HL,5574 Next move the initial stream data from its table to the streams area.
04735 LD DE,23568
04738 LD BC,14
04741 LDIR
04743 SET 1,(IY+1) Signal 'printer in use' (set bit 1 of FLAGS) and clear the printer buffer.
04747 CALL CLEAR_PRB
04750 LD (IY+49),2 Set the size of the lower part of the display (DF-SZ) and clear the whole display.
04754 CALL CLS
04757 XOR A Now print the message '© 1982 Sinclair Research Ltd' on the bottom line.
04758 LD DE,5432
04761 CALL PO_MSG
04764 SET 5,(IY+2) Signal 'the lower part will required to be cleared' (set bit 5 of TV-FLAG).
04768 JR MAIN_1 Jump forward into the main execution loop.
Prev: 04519 Up: Map Next: 04770