Prev: E931 Up: Map Next: E99F
E933: Run Bootstrap
One-shot startup trampoline. BASIC line 1 enters here via USR(VARS-74). It is not game logic: it finishes the load, replaces the decoy line 1 at PROG with the real opening from Bootstrap_Workspace, points BASIC at line 270F via NEWPPC (that line GO TOs 15, then reclaims this stub with RECLAIM-1 and falls into the interpreter. It never returns from USR.
Point IX at the machine stack and read the USR return word.
Run_Bootstrap E933 LD IX,$0000 Clear IX.
E937 ADD IX,SP Point IX at the machine stack.
E939 LD A,(IX+$14) Fetch the low byte of the USR return address into A.
Shuffle the USR return address and stash the reclaim start.
E93C DI Disable interrupts.
E93D SLA (IX+$15) Shift the high byte of the USR return address right.
E941 SLA A Shift the low byte of the USR return address left.
E943 LD (IX+$14),A Write the shuffled low byte back to the stack frame.
E946 XOR (IX+$15) Mix in the high byte of the USR return address.
E949 PUSH BC Stash the reclaim start address on the stack.
Prepare flags and timing for the pilot-tone search.
E94A LD IX,$0001 Set IX to 0001.
E94E AND A Clear the carry flag.
E94F SCF Set the carry flag.
E950 EX AF,AF' Switch to the shadow flags.
E951 LD C,$22 Set the EAR/border state in C to 22.
Listen for six double edges that look like a pilot pulse.
Run_Bootstrap_Detect_Pilot E953 LD E,$06 Set the pilot pair count in E to 06.
Timing loop body.
Run_Bootstrap_Detect_Pilot_Loop E955 LD B,$9C Set the timing constant in B to 9C.
E957 CALL $05E3 Call LD-EDGE-2.
E95A JR NC,Run_Bootstrap_Detect_Pilot Jump back to Run_Bootstrap_Detect_Pilot if the carry flag is reset.
E95C LD A,$C6 Jump back to Run_Bootstrap_Detect_Pilot if B is at least C6.
E95E CP B
E95F JR NC,Run_Bootstrap_Detect_Pilot
E961 DEC E Decrease the pilot pair count by one.
E962 JR NZ,Run_Bootstrap_Detect_Pilot_Loop Jump to Run_Bootstrap_Detect_Pilot_Loop until the pilot pair count is zero.
E964 INC E Increase the pilot pair count by one.
Prepare the data-block load into Bootstrap_Workspace.
E965 LD A,$FF Set A to FF to indicate this is a data block, not a header.
E967 SCF Set the carry flag (load, do not verify).
E968 EX AF,AF' Switch to the shadow flags.
E969 LD DE,$0047 Set the block length in DE to 0047 bytes.
E96C LD IX,$5B01 Point the load destination in IX at Bootstrap_Workspace.
Load the data block via LD-SYNC.
E970 CALL $058F Call LD-SYNC.
Apply the workspace patch and hand control back to BASIC.
Run_Bootstrap_Apply E973 DI Disable interrupts.
E974 LD DE,($5B3F) Fetch the reclaim end address into DE from Bootstrap_Reclaim_End.
E978 JR Run_Bootstrap_Apply_Body Jump to Run_Bootstrap_Apply_Body.
Set NEWPPC from the loaded workspace.
Run_Bootstrap_Apply_Body E97A LD HL,($5C53) Fetch PROG into HL.
E97D EX DE,HL Exchange DE and HL.
E97E LD BC,($5B41) Write *Bootstrap_New_Line to *NEWPPC.
E982 LD ($5C42),BC
E986 LD (IY+$0A),$00 Clear NSPPC.
Copy the workspace over PROG.
E98A LD HL,$5B01 Copy 3E bytes from Bootstrap_Workspace over *PROG.
E98D LD BC,$003E
E990 LDIR
Seed HL' and enable interrupts.
E992 EXX Switch to the shadow registers.
E993 LD HL,$2758 Set HL' to 2758.
E996 EXX Switch back to the normal registers.
E997 EI Enable interrupts.
Reclaim this stub via RECLAIM-1.
E998 POP DE Restore the reclaim start address into DE from the stack.
E999 LD HL,($5C4B) Fetch VARS into HL (reclaim end).
E99C JP $19E5 Jump to RECLAIM-1.
Prev: E931 Up: Map Next: E99F