| Gyruss | Routines |
| Prev: 96FE | Up: Map | Next: 9845 |
|
Used by the routine at main_loop.
|
||||
| handle_collisions | 9796 | LD A,(allocated_sprites) | Allocated sprites | |
| 9799 | SUB $02 | Return if only the ship sprites are allocated | ||
| 979B | RET Z | ... | ||
| 979C | LD B,A | Loop counter for allocated sprites - 2 | ||
| 979D | LD HL,$7185 | Table address sprite_allocation_table+2 (skip ship sprites) | ||
| 97A0 | XOR A | Reset a flag | ||
| 97A1 | LD (offset_double_shot_flag),A | ... | ||
| handle_collisions_0 | 97A4 | PUSH HL | Loop start; Save table address | |
| 97A5 | PUSH BC | Save counter | ||
| 97A6 | LD L,(HL) | Get sprites allocation table byte | ||
| 97A7 | LD H,$00 | MSB = 0 | ||
| 97A9 | ADD HL,HL | x4 | ||
| 97AA | ADD HL,HL | ... | ||
| 97AB | LD D,H | DE = x4 | ||
| 97AC | LD E,L | ... | ||
| 97AD | ADD HL,HL | x8 | ||
| 97AE | ADD HL,DE | x12 | ||
| 97AF | EX DE,HL | DE = x12 | ||
| 97B0 | LD IX,sprite_data | Sprite data table base | ||
| 97B4 | ADD IX,DE | Add offset so that IX = current sprite data | ||
| 97B6 | LD A,(IX+$00) | Get sprite type | ||
| 97B9 | CP $7F | If deallocated value | ||
| 97BB | JR Z,handle_collisions_1 | Then move to next sprite | ||
| 97BD | BIT 7,(IX+$01) | If bit 7 of polar y is set | ||
| 97C1 | JR NZ,handle_collisions_1 | Then move to next sprite | ||
| 97C3 | CP $02 | Is it a shot? | ||
| 97C5 | JP Z,handle_shot_collision | Then jump to handler | ||
| 97C8 | CP $0D | Is it < $0D (numbers or destroyed enemy)? | ||
| 97CA | JR C,handle_collisions_1 | Then move on to next sprite | ||
| 97CC | LD A,(status_flags) | Is it chance stage? | ||
| 97CF | BIT 3,A | ... | ||
| 97D1 | JR NZ,handle_collisions_1 | Then move to next sprite | ||
| 97D3 | BIT 7,(IX+$07) | If the flag bit 7 set in sprite data | ||
| 97D7 | JR NZ,handle_collisions_1 | Then move to next sprite | ||
| 97D9 | LD IY,sprite_data | Ship sprite data | ||
| 97DD | LD A,(IX+$01) | Is polar x = ship x? | ||
| 97E0 | CP (IY+$01) | ... | ||
| 97E3 | JR NZ,handle_collisions_1 | If not, move to next sprite | ||
| 97E5 | LD A,(IX+$02) | Polar x for sprite | ||
| 97E8 | LD B,(IY+$02) | Polar x for ship | ||
| 97EB | CALL polar_x_distance | Polar x distance | ||
| 97EE | CP $02 | Is distance < 2 | ||
| 97F0 | JP C,ship_hit_sprite | Then jump to collision handler | ||
|
This entry point is used by the routines at handle_shot_collision, add_points_from_enemy and ship_hit_enemy.
|
||||
| handle_collisions_1 | 97F3 | POP BC | Restore counter | |
| 97F4 | POP HL | Restore table address | ||
| 97F5 | INC HL | Next table address | ||
| 97F6 | DJNZ handle_collisions_0 | Loop for each allocated sprites (except ship) | ||
| 97F8 | LD A,(mines_left) | Are there any mines left? | ||
| 97FB | OR A | ... | ||
| 97FC | JR Z,handle_collisions_4 | Skip ahead if not | ||
| 97FE | LD IY,mines_background_data | Mine data address | ||
| 9802 | LD DE,$0009 | Size of each mine structure | ||
| 9805 | LD B,$03 | 3 mines | ||
| 9807 | LD IX,sprite_data | Ship sprite data | ||
| handle_collisions_2 | 980B | PUSH BC | Save counter | |
| 980C | LD A,(IY+$04) | If mine is gone | ||
| 980F | OR (IY+$05) | ... | ||
| 9812 | JR Z,handle_collisions_3 | Then move to next mine | ||
| 9814 | LD A,(IY+$07) | Get mine polar y? | ||
| 9817 | CP $06 | If >= 6 | ||
| 9819 | JR NC,handle_collisions_3 | Then move to next mine | ||
| 981B | LD A,(IX+$02) | Get ship polar x | ||
| 981E | LD B,(IY+$08) | Get mine polar x | ||
| 9821 | CALL polar_x_distance | Polar x distance | ||
| 9824 | CP $07 | If < 7 | ||
| 9826 | CALL C,ship_hit_mine | Then call collision routine | ||
| handle_collisions_3 | 9829 | ADD IY,DE | Next mine | |
| 982B | POP BC | Restore counter | ||
| 982C | DJNZ handle_collisions_2 | Loop for 3 mines | ||
| handle_collisions_4 | 982E | LD A,(offset_double_shot_flag) | Check a flag | |
| 9831 | BIT 0,A | ... | ||
| 9833 | RET Z | Return if not | ||
| 9834 | CALL create_double_shot_sprite | Create double shot sprite | ||
| 9837 | LD (IX+$07),$02 | Polar x velocity | ||
| 983B | RST $30 | Load sprite pattern | ||
| 983C | CALL create_double_shot_sprite | Create double shot sprite | ||
| 983F | LD (IX+$07),$FE | Polar x velocity | ||
| 9843 | RST $30 | Load sprite pattern | ||
| 9844 | RET | |||
| Prev: 96FE | Up: Map | Next: 9845 |