Prev: 35931 Up: Map Next: 36173
35993: Update position of odd ball, display, and decrease Magic Knight's strength if in contact
Used by the routines at 29776 and 29874.
Input
A Ball number (0, 1, 2 or 3)
35993 ADD A,A Multiply value of A by eight...
35994 ADD A,A ...
35995 ADD A,A ...
35996 LD C,A Store in C
35997 LD B,0 Set B to zero
35999 LD IX,36183 Set IX to point to data for balls
36003 ADD IX,BC Add eight times ball number as offset to IX pointer
36005 LD C,(IX+0) Load ball's x-coordinate into C
36008 LD B,(IX+1) Load ball's y-coordinate into B
36011 PUSH BC Store BC
36012 LD (23677),BC Load BC into coordinate storage
36016 LD A,(IX+4) Load A with ball's current frame number
36019 PUSH IX Store IX
36021 CALL 39125 Draw Odd Ball to screen
36024 POP IX Restore IX
36026 POP BC Restore BC
36027 LD A,(IX+2) Load x-velocity into A
36030 ADD A,C Add x-coordinate to A
36031 LD C,A Load new x-coordinate back into C
36032 LD A,(IX+3) Load y-velocity into A
36035 ADD A,B Add y-coordinate to A
36036 LD B,A Load new y-coordinate back into B
36037 LD (IX+0),C Update data with new x-...
36040 LD (IX+1),B ...and y-coordinates
36043 LD (23677),BC Update coordinate storage
36047 LD A,(IX+4) Load A with Odd Ball frame data
36050 SUB 116 Subtract 116 (frame number of first Odd Ball frame) to get "absolute frame number" (see trivia)
36052 INC A Advance absolute frame number by one
36053 AND 3 Cap absolute frame number to 3, and wrap round from 3 to 0 as there are only four frames
36055 ADD A,116 Add 116 to absolute frame number to give relative frame number again
36057 LD (IX+4),A Store new frame number
36060 PUSH IX Store IX
36062 CALL 39125 Draw Odd Ball to screen
36065 POP IX Restore IX
36067 LD A,(IX+0) Load x-coordinate of ball
36070 OR A If x-coordinate is zero...
36071 CALL Z,36173 ...multiply x "velocity" by minus one
36074 CP 244 If x-coordinate is 244...
36076 CALL Z,36173 ...multiply x "velocity" by minus one
36079 INC IX Temporarily advance IX pointer to work with y "velocities"
36081 LD A,(IX+0) Load y-coordinate of ball
36084 CP 172 If y-coordinate is 172...
36086 CALL Z,36173 ...multiply y "velocity" by minus one
36089 CP 40 If y-coordinate is 40...
36091 CALL Z,36173 ...multiply y "velocity" by minus one
36094 DEC IX Move IX back one again (reversing instruction at 36079)
36096 LD A,(25387) Load A with Magic Knight's current x-coordinate
36099 LD B,A Copy into B
36100 LD A,(IX+0) Load A with x-coordinate of ball
36103 ADD A,6 Add 6 to x-coordinate of ball
36105 SUB B Subtract B to get x-distance between Magic Knight and the ball, plus 6
36106 CP 21 If this value is not less than 21 then...
36108 JP NC,36172 ...return
36111 LD A,(25388) Else, load B with Magic Knight's y-coordinate...
36114 LD B,A ...
36115 LD A,(IX+1) Load A with y-coordinate of ball (uses same coordinate system as PLOT command, i.e. y=0 is at bottom of screen)
36118 SUB 175 Subtract y-coordinate from 175 to change y-origin to top of screen...
36120 NEG ...and have y-coordinate increase downwards rather than upwards
36122 ADD A,6 Add 6 to y-coordinate of ball
36124 SUB B Subtract B to get y-distance between Magic Knight and the ball, plus 6
36125 CP 39 If this value is not less than 39 then...
36127 JP NC,36172 ...return
36130 LD A,(25315) Else, decrease Magic Knight's current strength by one...
36133 DEC A ...
36134 LD (25315),A ...
36137 CALL 36215 Draw health bar at bottom of screen
36140 LD A,(25315) Load Magic Knight's current strength into A...
36143 OR A If Magic Knight's strength is zero...
36144 LD HL,43960 ...point HL to "YOU DIED OF EXHAUSTION" text...
36147 JP Z,35101 ...and jump to "game over" window routine and exit
36150 LD C,32 Set C to 32 (number of times to repeat loop below)
36152 LD A,16 Set speaker bit...
36154 OUT (254),A ...
36156 LD A,R Load A with random number between 0 - 15 (as R register increases with each instruction executed)...
36158 AND 15 ...
36160 LD B,A Load value into B
36161 DJNZ 36161 Pause by repeating this line B times
36163 XOR A Set A to zero
36164 OUT (254),A Reset speaker bit
36166 DEC C Decrease C...
36167 JR NZ,36152 ...and repeat loop if C is not zero
36169 XOR A Reset speaker bit...
36170 OUT (254),A ...
36172 RET Return
Prev: 35931 Up: Map Next: 36173