Prev: 9143 Up: Map Next: 929C
917C: Test the current object against the player's four shots
Used by the routine at update_objects.
The object's box is at collision_box (object_box). The shots are four records of 24 bytes at shot_records (updated by update_shots). Two kinds: a homing missile (bit 7 of its +$16; update_missile) is a box 8 wide and 5 high at its drawn position (+$11, +$12), tested only while drawn. The other kind, the laser, is a line: x in its +$0B (0 when there is none), line in +$0C, length in characters in +$0E; when bit 7 of its +$15 is set it is 8 lines high and the line test is skipped. The test is boxes_overlap.
A hit marks the shot (bit 7 of +$10; a missile is also freed) and the object shot (bit 5 of +$10), which its update routine turns into a score and debris (check_shot). A missile hitting type $19 counts a hit on it directly (+$16) and scores it. A shot with bit 7 of +$15 set destroys any object outright instead (bit 3 of +$17), scoring it double; type $19 gives its points that way only when it is already worn down (+$D = $FF), and then also credits ore to the part being carried (the second entry point of load_ore). Only the first shot that hits counts.
score_object adds an object's points to the score: 250 for types $0D and $1B, otherwise from type_points, doubled for one destroyed outright. add_score adds BC (BCD, B the high pair) to the current player's score (the first three bytes of the player record, score, BCD, low first), and prints it on the panel with print_string: the digits are font codes $1A-$23 (font), written into the panel's text (p1_score_digits, the record in front).
Input
IX The object's record
D The height it was drawn with (from object_box)
test_player_shots 917C LD A,D Not drawn: no test
917D DEC A
917E RET M
917F PUSH IX Four shots (shot_records), the object's box at collision_box
9181 LD IX,collision_box
9185 LD A,$04
9187 LD IY,shot_records
This entry point is used by the routine at test_shot_box.
test_shot_list 918B EX AF,AF' A missile, or the laser
918C BIT 7,(IY+$16)
9190 JR NZ,test_player_shots_0
9192 LD L,(IY+$0B) The laser: its x, 0 when there is none
9195 LD A,L
9196 AND A
9197 JR Z,test_player_shots_6
9199 JR test_player_shots_1
test_player_shots_0 919B BIT 7,(IY+$10) A missile, only while drawn: its x and line
919F JR Z,test_player_shots_6
91A1 LD L,(IY+$11)
91A4 LD H,(IY+$12)
91A7 JR test_player_shots_2
test_player_shots_1 91A9 LD H,(IY+$0C) The laser's line; a tall one skips the line test
91AC INC H
91AD BIT 7,(IY+$15)
91B1 JR NZ,test_player_shots_3
test_player_shots_2 91B3 LD A,(row_count) The line within the object's height: 5 high
91B6 INC H
91B7 CP H
91B8 JR NC,test_player_shots_6
91BA DEC H
91BB LD A,(IX+$01)
91BE ADD A,$03
91C0 CP H
91C1 JR C,test_player_shots_6
91C3 LD E,$05
91C5 JR test_player_shots_4
test_player_shots_3 91C7 LD E,$08 Tall: 8
test_player_shots_4 91C9 LD D,$08 Missile: 8 wide; laser: its length in characters times 8
91CB BIT 7,(IY+$16)
91CF JR NZ,test_player_shots_5
91D1 LD A,(IY+$0E)
91D4 ADD A,A
91D5 ADD A,A
91D6 ADD A,A
91D7 JR Z,test_player_shots_6
91D9 LD D,A
test_player_shots_5 91DA CALL boxes_overlap The test
91DD LD A,(scratch_count)
91E0 AND A
91E1 JR NZ,test_player_shots_7
test_player_shots_6 91E3 LD BC,$0018 Next shot
91E6 ADD IY,BC
91E8 EX AF,AF'
91E9 DEC A
91EA JR NZ,test_shot_list
91EC POP IX
91EE RET
test_player_shots_7 91EF POP IX A missile hit: it is freed; on type $19 a hit counted, with a sound and the points
91F1 BIT 7,(IY+$16)
91F5 JR Z,test_player_shots_8
91F7 SET 4,(IY+$10)
91FB LD A,(IX+$00)
91FE CP $19
9200 JR NZ,test_player_shots_8
9202 INC (IX+$16)
9205 CALL sound_zap
9208 CALL score_object
test_player_shots_8 920B SET 7,(IY+$10) The shot has hit; the object is shot
920F SET 5,(IX+$10)
9213 BIT 7,(IY+$15) A heavy shot destroys it outright
9217 RET Z
9218 SET 3,(IX+$17)
921C RES 5,(IX+$10)
9220 LD A,(IX+$00) Type $19 scores...
9223 CP $19
9225 JR NZ,score_object
9227 LD A,(IX+$0D) ...only when worn down: points, and ore for part 6
922A INC A
922B RET NZ
922C CALL score_object
922F LD A,R
9231 JP load_ore_0
This entry point is used by the routines at check_shot and update_tough_attacker.
score_object 9234 LD A,(IX+$00) Types $0D and $1B: 250
9237 CP $0D
9239 JR Z,test_player_shots_9
923B CP $1B
923D JR NZ,test_player_shots_10
test_player_shots_9 923F LD BC,$0250
9242 JR add_score
test_player_shots_10 9244 SUB $13 The rest from the table, by type
9246 ADD A,A
9247 LD HL,type_points
924A CALL add_a_to_hl
924D LD B,(HL)
924E INC HL
924F LD C,(HL)
9250 BIT 3,(IX+$17) Doubled when destroyed outright
9254 JR Z,add_score
9256 LD A,C
9257 ADD A,A
9258 DAA
9259 LD C,A
925A LD A,B
925B ADC A,B
925C DAA
925D LD B,A
This entry point is used by the routines at planet_secured, update_rocket_part and collect_pickup.
add_score 925E LD HL,score Add BC to the score
9261 LD A,C
9262 ADD A,(HL)
9263 DAA
9264 LD (HL),A
9265 INC HL
9266 LD A,B
9267 ADC A,(HL)
9268 DAA
9269 LD (HL),A
926A INC HL
926B LD A,$00
926D ADC A,(HL)
926E DAA
926F LD (HL),A
9270 LD DE,p1_score_digits Six digits, high first, as font codes
9273 LD B,$03
test_player_shots_11 9275 LD A,(HL)
9276 RRCA
9277 RRCA
9278 RRCA
9279 RRCA
927A AND $0F
927C ADD A,$1A
927E LD (DE),A
927F INC DE
9280 LD A,(HL)
9281 AND $0F
9283 ADD A,$1A
9285 LD (DE),A
9286 INC DE
9287 DEC HL
9288 DJNZ test_player_shots_11
928A LD DE,p1_score_text Print them
928D EXX
928E PUSH HL
928F PUSH DE
9290 PUSH BC
9291 LD DE,p1_score_text
9294 CALL print_string
9297 POP BC
9298 POP DE
9299 POP HL
929A EXX
929B RET
Prev: 9143 Up: Map Next: 929C