Prev: 75BA Up: Map Next: 7627
75D0: Reverse enemy direction at river bank
Reverses the direction of a ship or helicopter when it approaches a river bank. Inverts the orientation bit and re-renders with new facing. Ignores objects in top half of screen (Y >= $80).
Input
BC Object coordinates
reverse_enemy_direction 75D0 LD ($8B0A),BC
75D4 LD A,B Return if Y >= $80 (object in top half, might be player).
75D5 SUB $80
75D7 RET P
75D8 LD BC,($8B0A) Reload position, pop return address, load current_slot_ptr, get object definition.
75DC POP HL
75DD LD HL,($5F60)
75E0 DEC HL
75E1 LD D,(HL)
75E2 CALL ld_enemy_sprites Get sprite pointer, reload position.
75E5 LD BC,($8B0A)
75E9 LD A,C Calculate animation frame offset from X position.
75EA AND $07
75EC LD BC,$0018 Set frame size, shift and increment offset.
75EF SRL A
75F1 OR A
75F2 INC A
75F3 SBC HL,BC Subtract frame size for pre-decrement.
reverse_enemy_direction_frame_loop 75F5 ADD HL,BC Loop to add frame offset to sprite pointer, store to render_sprite_ptr.
75F6 DEC A
75F7 JR NZ,reverse_enemy_direction_frame_loop
75F9 LD ($8B0E),HL
75FC LD BC,($8B0A) Reload position, store to object_coordinates.
7600 LD ($8B0C),BC
7604 LD A,D Invert object orientation.
7605 XOR $40
7607 LD D,A
7608 LD HL,($5F60) Update orientation in viewport array, get new sprite pointer.
760B DEC HL
760C LD (HL),A
760D CALL ld_enemy_sprites
7610 LD E,$0E
7612 LD A,D
7613 AND $07
7615 CP $02
7617 CALL Z,ld_attributes_ship
761A LD D,$08
761C LD A,$03
761E LD BC,$0018
7621 CALL render_object
7624 JP operate_viewport_slots
Prev: 75BA Up: Map Next: 7627