Prev: 6657 Up: Map Next: 66C8
6658: Initialise Next Phase
Used by the routine at Update_Frame.
Picks a random letter for *Model_Letter, fills the object and target slots, then sweeps *View_Pitch and *View_Yaw before the next phase.
Pick a random letter from "A" to "G".
Initialise_Next_Phase 6658 LD A,$0D Call Random_Number and clamp the maximum value to 0D.
665A CALL Random_Number
665D SRL A Halve the result.
665F ADD A,$41 Convert the result into a letter from "A" to "G".
6661 LD ($E1F7),A Write the letter to *Model_Letter.
Seed the background, target and object slots.
6664 CALL Initialise_Slot_Table Call Initialise_Slot_Table.
6667 LD A,$15 Write 15 to *Object_Slot_Count.
6669 LD ($EE2C),A
666C CALL $70B2 Call 70B2.
666F CALL Initialise_Object_Slots Call Initialise_Object_Slots.
Wait 19 frames.
6672 LD B,$19 Set the frame counter to 19 in B.
Initialise_Next_Phase_Wait 6674 HALT Halt, and loop back to Initialise_Next_Phase_Wait until the frame counter is zero.
6675 DJNZ Initialise_Next_Phase_Wait
Sweep the view for 23 frames.
6677 LD A,$96 Write 96 to *E17A.
6679 LD ($E17A),A
667C LD B,$23 Set the frame counter to 23 in B.
667E LD HL,$EE15 Point HL at EE15.
6681 PUSH HL Stash the pointer on the stack.
6682 SET 5,(HL) Set bit 5 of *EE15.
Update one frame of the sweep.
Initialise_Next_Phase_Sweep 6684 PUSH BC Stash the frame counter on the stack.
6685 CALL Plot_Slot_Table Call Plot_Slot_Table.
6688 CALL Plot_Target_Slots Call Plot_Target_Slots.
668B CALL Advance_Object_Slots Call Advance_Object_Slots.
668E LD A,($EE7F) Decrease *View_Pitch by 0C.
6691 SUB $0C
6693 LD ($EE7F),A
6696 LD A,($EE80) Decrease *View_Yaw by 0C.
6699 SUB $0C
669B LD ($EE80),A
669E LD A,$01 Write 01 to *Frame_Flag.
66A0 LD ($EED5),A
66A3 HALT Halt.
66A4 POP BC Restore the frame counter from the stack.
66A5 DJNZ Initialise_Next_Phase_Sweep Decrease the frame counter by one and loop back to Initialise_Next_Phase_Sweep until it is zero.
Restore the view bound.
66A7 POP HL Restore the pointer from the stack.
66A8 RES 5,(HL) Reset bit 5 of *EE15.
Wait, draw the graphic, then wait again.
66AA LD A,$08 Set the delay to 08 in A.
66AC CALL Wait_Slot_Frames Call Wait_Slot_Frames.
66AF LD A,$01 Write 01 to *E1F6.
66B1 LD ($E1F6),A
66B4 CALL Rotate_Coordinates_5 Call Rotate_Coordinates_5.
66B7 LD A,$32 Set the delay to 32 in A.
66B9 CALL Wait_Slot_Frames Call Wait_Slot_Frames.
66BC CALL Process_Draw_List_41 Call Process_Draw_List_41.
66BF XOR A Write 00 to *E1F6.
66C0 LD ($E1F6),A
Wait 0A frames.
66C3 LD A,$0A Set the delay to 0A in A.
66C5 JP Wait_Slot_Frames Jump to Wait_Slot_Frames.
Prev: 6657 Up: Map Next: 66C8