Prev: 38844 Up: Map Next: 38961
38884: Animate starfield until a key is pressed
Used by the routines at 27118 and 33180.
Input
IY 23610
38884 XOR A Clear last pressed key (LAST K system variable)...
38885 LD (23560),A ...
38888 SET 0,(IY+87) Set P FLAG system variable bits 0 and 1 (OVER 1)
38892 SET 1,(IY+87)
38896 CALL 38961 Reset all stars to point of origin and generate new velocities and movement data
38899 LD A,(23560) If last pressed key is not zero (i.e. a key has been pressed)...
38902 OR A ...
38903 RET NZ ...then return...
38904 LD IX,25614 ...else point IX at start of table of stars' movement data
38908 LD B,50 Load B with 50, as we are dealing with 50 "stars"
38910 PUSH BC Store BC (B = remaining number of stars to process)
38911 LD B,(IX+1) Load old y-coordinate from star's movement data into B
38914 LD C,(IX+0) Load old x-coordinate from star's movement data into C
38917 CALL 8933 Un-PLOT the pixel (x=C, y=B - star's old position) (as "OVER" flag is set, so PLOTting an already PLOTted point removes it)
38920 CALL 39081 Load BC with new (y,x) coordinates of a star depending upon the signs and magnitudes of its direction
38923 LD A,B Load new y-coordinate into A
38924 CP 48 If new y-coordinate is less than 48... (how far down the star goes)
38926 JR C,38932 ...then skip ahead to 38932
38928 CP 175 If new y-coordinate is less than 175... (how far up the star goes)
38930 JR C,38937 ...then skip ahead to 38937
38932 CALL 38795 Reset star to point of origin and generate a new direction and movement data
38935 JR 38950 Skip ahead to 38950
38937 LD A,C Load x-coordinate into A
38938 AND A If x-coordinate is zero...
38939 JR Z,38932 ...then jump to 38932
38941 LD (IX+0),C Store new x- and y-coordinates in star's movement data table entry...
38944 LD (IX+1),B ...
38947 CALL 8933 PLOT the star's new position (x=C, y=B)
38950 POP BC Restore BC (B = remaining number of stars to process)
38951 LD DE,9 Advance IX by nine bytes to next entry in table of star movement data...
38954 ADD IX,DE ...
38956 DJNZ 38910 Loop back to 38910 for next star
38958 JP 38899 Jump back to 38899 to repeat routine again
Prev: 38844 Up: Map Next: 38961