Prev: 55786 Up: Map Next: 55959
55850: Cycle Border from Screen
Drives the per-frame border colour cycling effect. Reads successive pixel bytes from the screen buffer pointer at 50467 ANDs each byte with 24 to extract the paper colour bits, and writes the result to the border port 254. Between each byte a variable delay is run, its period advanced by the step value at 50475. After the outer loop the frame counter at 50471 is decremented; when it reaches the threshold at 50477 Entity_State_Flag is set to 1 (step complete). When the frame counter reaches zero, Entity_State_Flag is set to 2 (all complete). The alternate entry at Cycle_Border_Toggle_Loop drives the same counter machinery without sampling screen data, instead XOR-toggling the border between two colours.
Cycle_Border_From_Screen 55850 LD HL,(50467) Load the screen data pointer from 50467 and the outer loop count from 50473 into B.
55853 LD A,(50473)
55856 LD B,A
Cycle_Border_Loop 55857 LD A,24 Read the next pixel byte, mask to paper bits with 24 and write to the border port 254.
55859 AND (HL)
55860 OUT (254),A
55862 INC HL Advance the screen data pointer.
55863 LD A,(50469) Load the current delay count from 50469 into C.
55866 LD C,A
Cycle_Border_Delay 55867 DEC C Busy-wait for the delay period.
55868 JR NZ,Cycle_Border_Delay
55870 LD C,A Reload C, add the step increment from 50475 and store the updated delay back to 50469.
55871 LD A,(50475)
55874 ADD A,C
55875 LD (50469),A
55878 DJNZ Cycle_Border_Loop Loop back to Cycle_Border_Loop for the next pixel byte.
55880 LD (50467),HL Save the updated screen data pointer back to 50467.
55883 LD A,(50471) Decrement the frame counter at 50471 and jump to Cycle_Border_Complete if it has reached zero.
55886 DEC A
55887 JR Z,Cycle_Border_Complete
55889 LD (50471),A Save the decremented frame counter; return if it has not yet reached the completion threshold at 50477.
55892 LD B,A
55893 LD A,(50477)
55896 CP B
55897 RET NZ
55898 LD A,1 Set Entity_State_Flag to 1 (step complete) and return.
55900 LD (50479),A
55903 RET
Cycle_Border_Complete 55904 LD A,2 Set Entity_State_Flag to 2 (all complete) and return.
55906 LD (50479),A
55909 RET
Alternate entry: toggle the border colour on each pass without reading screen data.
Cycle_Border_Toggle 55910 LD A,(50473) Load the outer loop count from 50473 into B and clear A.
55913 LD B,A
55914 XOR A
Cycle_Border_Toggle_Loop 55915 XOR %00011000 XOR the border value with 24 to toggle between two colours.
55917 OUT (254),A Write the toggled value to the border port 254 and stash it in D.
55919 LD D,A
55920 LD A,(50469) Load the delay count from 50469 into C.
55923 LD C,A
Cycle_Border_Toggle_Delay 55924 DEC C Busy-wait for the delay period.
55925 JR NZ,Cycle_Border_Toggle_Delay
55927 LD C,A Reload C, add the step increment from 50475 and store the updated delay back to 50469.
55928 LD A,(50475)
55931 ADD A,C
55932 LD (50469),A
55935 LD A,D Reload the toggled border value from D and loop back to Cycle_Border_Toggle_Loop.
55936 DJNZ Cycle_Border_Toggle_Loop
55938 LD A,(50471) Decrement the frame counter at 50471 and jump to Cycle_Border_Complete if it has reached zero.
55941 DEC A
55942 JR Z,Cycle_Border_Complete
55944 LD (50471),A Save the decremented frame counter; return if it has not yet reached the completion threshold at 50477.
55947 LD B,A
55948 LD A,(50477)
55951 CP B
55952 RET NZ
55953 LD A,1 Set Entity_State_Flag to 1 (step complete) and return.
55955 LD (50479),A
55958 RET
Prev: 55786 Up: Map Next: 55959