Prev: 59697 Up: Map Next: 59807
59699: Run Bootstrap
One-shot startup trampoline. BASIC line 1 enters here via USR(VARS-116). 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 9999 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 59699 LD IX,0 Clear IX.
59703 ADD IX,SP Point IX at the machine stack.
59705 LD A,(IX+20) Fetch the low byte of the USR return address into A.
Shuffle the USR return address and stash the reclaim start.
59708 DI Disable interrupts.
59709 SLA (IX+21) Shift the high byte of the USR return address right.
59713 SLA A Shift the low byte of the USR return address left.
59715 LD (IX+20),A Write the shuffled low byte back to the stack frame.
59718 XOR (IX+21) Mix in the high byte of the USR return address.
59721 PUSH BC Stash the reclaim start address on the stack.
Prepare flags and timing for the pilot-tone search.
59722 LD IX,1 Set IX to 0001.
59726 AND A Clear the carry flag.
59727 SCF Set the carry flag.
59728 EX AF,AF' Switch to the shadow flags.
59729 LD C,34 Set the EAR/border state in C to 34.
Listen for six double edges that look like a pilot pulse.
Run_Bootstrap_Detect_Pilot 59731 LD E,6 Set the pilot pair count in E to 6.
Timing loop body.
Run_Bootstrap_Detect_Pilot_Loop 59733 LD B,156 Set the timing constant in B to 156.
59735 CALL 1507 Call LD-EDGE-2.
59738 JR NC,Run_Bootstrap_Detect_Pilot Jump back to Run_Bootstrap_Detect_Pilot if the carry flag is reset.
59740 LD A,198 Jump back to Run_Bootstrap_Detect_Pilot if B is at least 198.
59742 CP B
59743 JR NC,Run_Bootstrap_Detect_Pilot
59745 DEC E Decrease the pilot pair count by one.
59746 JR NZ,Run_Bootstrap_Detect_Pilot_Loop Jump to Run_Bootstrap_Detect_Pilot_Loop until the pilot pair count is zero.
59748 INC E Increase the pilot pair count by one.
Prepare the data-block load into Bootstrap_Workspace.
59749 LD A,255 Set A to 255 to indicate this is a data block, not a header.
59751 SCF Set the carry flag (load, do not verify).
59752 EX AF,AF' Switch to the shadow flags.
59753 LD DE,71 Set the block length in DE to 0071 bytes.
59756 LD IX,23297 Point the load destination in IX at Bootstrap_Workspace.
Load the data block via LD-SYNC.
59760 CALL 1423 Call LD-SYNC.
Apply the workspace patch and hand control back to BASIC.
Run_Bootstrap_Apply 59763 DI Disable interrupts.
59764 LD DE,(23359) Fetch the reclaim end address into DE from Bootstrap_Reclaim_End.
59768 JR Run_Bootstrap_Apply_Body Jump to Run_Bootstrap_Apply_Body.
Set NEWPPC from the loaded workspace.
Run_Bootstrap_Apply_Body 59770 LD HL,(23635) Fetch PROG into HL.
59773 EX DE,HL Exchange DE and HL.
59774 LD BC,(23361) Write *Bootstrap_New_Line to *NEWPPC.
59778 LD (23618),BC
59782 LD (IY+10),0 Clear NSPPC.
Copy the workspace over PROG.
59786 LD HL,23297 Copy 62 bytes from Bootstrap_Workspace over *PROG.
59789 LD BC,62
59792 LDIR
Seed HL' and enable interrupts.
59794 EXX Switch to the shadow registers.
59795 LD HL,10072 Set HL' to 10072.
59798 EXX Switch back to the normal registers.
59799 EI Enable interrupts.
Reclaim this stub via RECLAIM-1.
59800 POP DE Restore the reclaim start address into DE from the stack.
59801 LD HL,(23627) Fetch VARS into HL (reclaim end).
59804 JP 6629 Jump to RECLAIM-1.
Prev: 59697 Up: Map Next: 59807