Prev: 49386 Up: Map Next: 49490
49422: Check Star Position
Used by the routine at UpdateStarLayer.
Finds the position of a star on the screen, from its position and the offset of its layer. It is stored in 41429 and 41430. In the third zone a star is also left out if it is below the level of the ground.
Output
F The zero flag is set if the star is not on the screen
CheckStarPosition 49422 LD HL,(49382) Fetch the word at StarVariables into HL.
49425 LD DE,(49384) Fetch the word at 49384 into DE.
49429 LD A,(DE) Read DE.
49430 AND %11111110 Keep the bits of A that are set in 254.
49432 ADD A,(HL) Add the byte at HL to A.
49433 SUB 8 Subtract 8 from A.
49435 CP 224 Jump to CheckStarPosition_Hidden if A is 224 or more.
49437 JR NC,CheckStarPosition_Hidden
49439 ADD A,8 Add 8 to A.
49441 LD (41429),A The star's horizontal position.
49444 INC DE Advance DE.
49445 INC HL Advance HL.
49446 LD A,(DE) Read DE.
49447 ADD A,(HL) Add the byte at HL to A.
49448 SUB 24 Subtract 24 from A.
49450 CP 161 Jump to CheckStarPosition_Hidden if A is 161 or more.
49452 JR NC,CheckStarPosition_Hidden
49454 ADD A,24 Add 24 to A.
49456 LD (41430),A The star's vertical position.
49459 LD A,(52824) The map row.
49462 CP 3 Jump to CheckStarPosition_Visible if A is not 3.
49464 JR NZ,CheckStarPosition_Visible
49466 LD A,(52806) The position down.
49469 CPL Invert A.
49470 SUB 49 Subtract 49 from A.
49472 LD B,A B=A.
49473 LD A,(41430) The star's vertical position.
49476 CP B Jump to CheckStarPosition_Hidden if A is B or more.
49477 JR NC,CheckStarPosition_Hidden
CheckStarPosition_Visible 49479 LD A,(52412) The star flags.
49482 OR %00000001 Set the bits of A that are set in 1.
49484 LD (52412),A Update the star flags.
49487 RET Return.
CheckStarPosition_Hidden 49488 XOR A Clear A.
49489 RET Return.
Prev: 49386 Up: Map Next: 49490