| Gyruss | Routines |
| Prev: A6EC | Up: Map | Next: A7D5 |
|
Control ship movement and fire using controllers. Used by the routines at entry, stage_completed, stage_completed, perfect_bonus and initial_game_loop.
|
||||
| control_ship | A73C | LD A,(frame_counter) | Get frame counter | |
| A73F | AND $01 | Test bit 0 | ||
| A741 | RET NZ | Return every 2nd frame | ||
| A742 | LD HL,(countdown_to_wave) | Controller: current_player | ||
| A745 | LD L,$00 | Segment 0 | ||
| A747 | CALL $1F79 | DECODER (H = fire, L = joystick (bit 0: up, bit 1: right, bit 2: down, bit 3: left)) | ||
| A74A | LD H,$00 | Reset fire | ||
| A74C | LD DE,movement_table | Movement table | ||
| A74F | ADD HL,DE | Add joystick result (0 - 12, some values not possible) | ||
| A750 | LD IX,sprite_data | Sprite 0 data (ship body) | ||
| A754 | LD B,$01 | Direction = 1 (clockwise) | ||
| A756 | LD A,(HL) | Get table value, which is the value of polar x to move towards | ||
| A757 | CP $FF | Is it an impossible joystick value, e.g. up + down? | ||
| A759 | JR Z,control_ship_2 | Then skip ahead | ||
| A75B | SUB (IX+$02) | Table value - polar x | ||
| A75E | JR Z,control_ship_2 | If zero then skip ahead (already there) | ||
| A760 | JR NC,control_ship_0 | If positive skip ahead | ||
| A762 | LD B,$FF | Direction = -1 (anti-clockwise) | ||
| A764 | NEG | abs(value - polar x) | ||
| control_ship_0 | A766 | CP $21 | Is the difference < 33? | |
| A768 | LD A,B | Direction | ||
| A769 | JR C,control_ship_1 | Then skip ahead | ||
| A76B | NEG | Otherwise reverse direction | ||
| control_ship_1 | A76D | ADD A,(IX+$02) | Polar x + direction | |
| A770 | AND $3F | Mod 64 | ||
| A772 | LD (IX+$02),A | Update polar x | ||
| A775 | LD (IX+$0E),A | Also update sprite 1 | ||
| A778 | RST $30 | Load sprite pattern sprite 0 | ||
| A779 | LD IX,$700E | Sprite 1 | ||
| A77D | RST $30 | Load sprite pattern sprite 1 | ||
| A77E | CALL display_ship_background_patterns | Display ship background patterns | ||
|
Handle fire
|
||||
| control_ship_2 | A781 | LD A,(status_flags) | Test stage init flag | |
| A784 | BIT 4,A | Return if set | ||
| A786 | RET NZ | ... | ||
| A787 | LD HL,(countdown_to_wave) | Controller: current_player | ||
| A78A | PUSH HL | Save current player | ||
| A78B | LD L,$00 | Segment 0 | ||
| A78D | CALL $1F79 | DECODER (H = fire, L = joystick) | ||
| A790 | LD A,H | Fire | ||
| A791 | POP HL | Restore current player | ||
| A792 | PUSH AF | Save fire segment 0 | ||
| A793 | LD L,$01 | Segment 1 | ||
| A795 | CALL $1F79 | DECODER | ||
| A798 | POP AF | Restore fire segment 0 | ||
| A799 | OR H | Combine with fire segment 1 | ||
| A79A | LD HL,other_flags | Flags | ||
| A79D | BIT 6,A | Test fire pressed | ||
| A79F | JR Z,clear_fire_pressed | If not, clear bit for fire pressed, and return | ||
| A7A1 | BIT 0,(HL) | Check if fire was pressed last time | ||
| A7A3 | RET NZ | Then return (must release after each shot) | ||
| A7A4 | LD A,(active_shots) | Get number of active shots | ||
| A7A7 | BIT 1,(HL) | Test for double shot | ||
| A7A9 | JR Z,control_ship_3 | Skip ahead if single shot | ||
| A7AB | SRL A | Divide by 2 (allow twice as many shots) | ||
| control_ship_3 | A7AD | CP $02 | Return if >= 2 | |
| A7AF | RET NC | ... | ||
| A7B0 | LD A,$00 | No effect | ||
| A7B2 | NOP | Some instructions removed here? | ||
| A7B3 | NOP | ... | ||
| A7B4 | NOP | ... | ||
| A7B5 | LD A,(active_shots) | Increment number of active shots | ||
| A7B8 | INC A | ... | ||
| A7B9 | LD (active_shots),A | ... | ||
| A7BC | SET 0,(HL) | Set bit for fire pressed | ||
| A7BE | BIT 1,(HL) | Test for double shot | ||
| A7C0 | JR NZ,fire_double_shot | Jump for double shot | ||
| A7C2 | RST $28 | Allocate sprite | ||
| A7C3 | LD HL,($7003) | Ship's polar coordinates | ||
| A7C6 | LD (IX+$01),L | Shot y = ship y | ||
| A7C9 | LD (IX+$02),H | Shot x = ship x | ||
| A7CC | LD (IX+$00),$02 | Shot type | ||
| A7D0 | LD (IX+$0B),$0A | Set color (yellow) | ||
| A7D4 | RET | Return | ||
| Prev: A6EC | Up: Map | Next: A7D5 |