Prev: 8E2C Up: Map Next: 8F1E
8E2D: Test the current object against the ship and apply its contact effect
Used by the routine at update_objects.
Called by update_objects after each object's update. Nothing happens while the rocket is launching (launch_state), while the ship is dying (death_count), when the object is harmless (contact effect 0, object_load), when it was not drawn this pass, or when it is exploding. Its box -- the screen x and bottom line it was drawn at (+$11, +$12), the width (sprite_width_drawn) and height (in old_sprite_x) it was drawn with -- goes to collision_box, and an object whose x is outside $28-$8D is too far from the ship to touch it. The ship's box is fixed in x: 40 pixels wide from x=100, 16 lines high, its bottom 8 lines below the ship's line (ship_line). boxes_overlap tests the two.
On a touch the effect bits are acted on from bit 7 down (see object_load), IX the object and IY the ship's record (in bare_ship). $FF is different: it starts the shield (shield_timer = $FF, counted down every other pass by ship_pass, so about 25 seconds), and frees the object with a sound.
Without a touch, a cloud may still touch what the ship is carrying (carried_part keeps a flag in the player record, score, while it carries something): the carried thing's box (from carried_part_facing) is tested, and on a touch the ship's X velocity becomes minus half the cloud's, and fuel_saver is set. That branch never ran in the build's sessions; it rests on reading alone.
ship_contact 8E2D LD A,(launch_state) Nothing during the launch or while dying, for a harmless object, or for one not drawn this pass
8E30 AND A
8E31 RET NZ
8E32 LD A,(death_count)
8E35 AND A
8E36 RET NZ
8E37 LD A,(contact_effect)
8E3A AND A
8E3B RET Z
8E3C LD A,(new_sprite_rows)
8E3F AND A
8E40 RET Z
8E41 LD IX,(current_object) Nor while it explodes
8E45 BIT 3,(IX+$17)
8E49 RET NZ
8E4A LD L,(IX+$11) Its box at collision_box: x and bottom line; too far left or right of the ship to touch
8E4D LD H,(IX+$12)
8E50 LD IX,collision_box
8E54 LD (IX+$03),A
8E57 LD A,L
8E58 CP $8E
8E5A RET NC
8E5B CP $28
8E5D RET C
8E5E LD (IX+$00),L Width (the height went in above)
8E61 LD (IX+$01),H
8E64 LD A,(sprite_width_drawn)
8E67 LD (IX+$02),A
8E6A LD A,(ship_line) The ship's box: x=100, 40 wide, 16 high, bottom at the ship's line + 8
8E6D ADD A,$08
8E6F LD H,A
8E70 LD L,$64
8E72 LD D,$28
8E74 LD E,$10
8E76 CALL boxes_overlap
8E79 LD IX,(current_object) IY the ship's record; no touch: the cloud test below
8E7D LD IY,ship_record
8E81 LD A,(scratch_count)
8E84 AND A
8E85 JP Z,ship_contact_1
8E88 LD A,$80 Touched: the ship is to be redrawn (a flag, trail_collision, read by draw_ship)
8E8A LD (trail_collision),A
8E8D LD A,(contact_effect) The effect, $FF the shield
8E90 LD C,A
8E91 INC A
8E92 JR NZ,ship_contact_0
8E94 DEC A The shield (shield_timer) counts down from $FF; the object is freed, with a sound
8E95 LD (shield_timer),A
8E98 SET 4,(IX+$10)
8E9C JP sound_zap
ship_contact_0 8E9F BIT 7,C Slow, damage, refuel, push, collect
8EA1 CALL NZ,contact_slow_ship
8EA4 BIT 6,C
8EA6 CALL NZ,contact_damage
8EA9 BIT 5,C
8EAB CALL NZ,contact_refuel
8EAE BIT 4,C
8EB0 CALL NZ,contact_push
8EB3 BIT 3,C
8EB5 CALL NZ,contact_collect
8EB8 BIT 2,C Drain fuel; an extra life
8EBA CALL NZ,contact_drain_fuel
8EBD PUSH BC
8EBE BIT 1,C
8EC0 CALL NZ,contact_extra_life
8EC3 POP BC
8EC4 BIT 0,C And destroy the object
8EC6 JP NZ,contact_destroy
8EC9 RET
ship_contact_1 8ECA LD A,(IX+$00) No touch: only a cloud, and only while the ship carries something
8ECD CP $13
8ECF RET NZ
8ED0 LD A,(player_count_nine)
8ED3 AND A
8ED4 RET Z
8ED5 LD A,(ship_facing) Only when the ship faces the way the cloud moves (ship_facing)
8ED8 XOR (IX+$07)
8EDB BIT 7,A
8EDD RET NZ
8EDE LD A,(carried_big_y) Test the carried thing's box against the cloud
8EE1 LD H,A
8EE2 LD A,(carried_small_x)
8EE5 ADD A,$08
8EE7 LD L,A
8EE8 LD A,$50
8EEA CALL clip_height_to_top
8EED LD E,B
8EEE LD D,$0C
8EF0 LD IX,collision_box
8EF4 CALL boxes_overlap
8EF7 LD A,(scratch_count) Touched
8EFA AND A
8EFB RET Z
8EFC LD A,$80
8EFE LD (trail_collision),A
8F01 LD IX,(current_object) The ship's X velocity becomes minus half the cloud's
8F05 LD H,(IX+$07)
8F08 LD L,(IX+$08)
8F0B CALL negate_hl
8F0E SRA H
8F10 RR L
8F12 LD (IY+$19),H
8F15 LD (IY+$1A),L
8F18 LD A,$FF Note it for the fuel burn (read_controls) and for the slowing (contact_slow_ship)
8F1A LD (fuel_saver),A
8F1D RET
Prev: 8E2C Up: Map Next: 8F1E