Prev: 8221 Up: Map Next: 8470
83A4: Test In View
Returns zero if *Depth is between *View_Low and *View_High, and the absolute *Rotated_X and *Rotated_Y are inside that range.
Output
A Zero if the point is in view
Test_In_View 83A4 LD HL,($EE12) Fetch *Depth.
83A7 LD DE,($EE16) Fetch *View_Low.
83AB AND A Jump to Test_In_View_2 if *Depth is less than *View_Low.
83AC SBC HL,DE
83AE JR C,Test_In_View_2
83B0 ADD HL,DE Restore *Depth.
83B1 LD DE,($EE14) Fetch *View_High.
83B5 AND A Jump to Test_In_View_2 if *Depth is not less than *View_High.
83B6 SBC HL,DE
83B8 JR NC,Test_In_View_2
83BA ADD HL,DE Restore *Depth.
83BB SRA H Halve the coordinate.
83BD RR L
83BF LD BC,($EE18) Fetch *View_Range.
83C3 ADD HL,BC Add *View_Range.
83C4 EX DE,HL Store the limit in DE.
83C5 LD HL,($EE0E) Fetch *Rotated_X.
83C8 BIT 7,H Jump to Test_In_View_0 if *Rotated_X is positive.
83CA JR Z,Test_In_View_0
83CC LD A,H Take the absolute value.
83CD CPL
83CE LD H,A
83CF LD A,L
83D0 CPL
83D1 LD L,A
83D2 INC HL
Test_In_View_0 83D3 AND A Jump to Test_In_View_2 if *Rotated_X is outside the limit.
83D4 SBC HL,DE
83D6 JR NC,Test_In_View_2
83D8 EX DE,HL Swap the limit with the coordinate.
83D9 ADD HL,BC Add *View_Range.
83DA SRA H Halve the range.
83DC RR L
83DE EX DE,HL Store the limit in DE.
83DF LD HL,($EE10) Fetch *Rotated_Y.
83E2 BIT 7,H Jump to Test_In_View_1 if *Rotated_Y is positive.
83E4 JR Z,Test_In_View_1
83E6 LD A,H Take the absolute value.
83E7 CPL
83E8 LD H,A
83E9 LD A,L
83EA CPL
83EB LD L,A
83EC INC HL
Test_In_View_1 83ED AND A Jump to Test_In_View_2 if *Rotated_Y is outside the limit.
83EE SBC HL,DE
83F0 JR NC,Test_In_View_2
83F2 XOR A Set the result to 00.
83F3 RET Return.
Test_In_View_2 83F4 OR %00000001 Set bit 0.
83F6 RET Return.
83F7 NOP
83F8 NOP
83F9 NOP
83FA NOP
83FB NOP
83FC NOP
83FD NOP
This entry point is used by the routine at Service_Interrupt.
Test_In_View_3 83FE LD DE,$C4CC
8401 LD HL,$D516
8404 LD A,($EF7E)
8407 DEC A
8408 RET Z
8409 LD BC,$F7FE
840C IN A,(C)
840E OR $E0
8410 CP $FE
8412 RET NZ
Test_In_View_4 8413 LD BC,$F7FE
8416 IN A,(C)
8418 RRA
8419 RRA
841A RET NC
841B RRA
841C PUSH DE
841D PUSH HL
841E CALL NC,Set_Phase_Table_7
8421 POP HL
8422 POP DE
8423 RRA
8424 JR NC,Test_In_View_6
8426 PUSH DE
8427 PUSH HL
8428 LD HL,$D516
842B LD ($E17B),HL
842E POP HL
842F CALL Divide_25
8432 EX (SP),HL
8433 LD DE,$C4CC
8436 LD ($E17B),DE
843A CALL Divide_25
843D EX DE,HL
843E POP HL
843F LD A,(HL)
8440 AND A
8441 JR NZ,Test_In_View_5
8443 XOR A
8444 LD ($EFCD),A
8447 LD ($EFCC),A
844A LD ($E1F5),A
844D RET
Test_In_View_5 844E LD A,(DE)
844F AND A
8450 JR NZ,Test_In_View_4
8452 LD A,$04
8454 LD ($EFCC),A
8457 LD ($EFCD),A
845A LD A,$19
845C LD ($E1F5),A
845F RET
Test_In_View_6 8460 LD A,$01
8462 LD ($EF7E),A
8465 RET
8466 NOP
8467 NOP
8468 NOP
8469 NOP
846A NOP
846B NOP
This entry point is used by the routines at Run_Other_Phase and Draw_Phase_Slots.
Test_In_View_7 846C LD IX,$E680
Prev: 8221 Up: Map Next: 8470