![]() |
Routines |
Prev: 30760 | Up: Map | Next: 30995 |
March the aliens along and down. This is called from the main game loop. It deals with one row of aliens at a time and is called repeatedly which keeps things smooth (bullets moving etc.) as the aliens move left, right and down.
The argument is is _ALIEN_BAND_ARG and is the row to move. It's maintained by this piece of code.
Used by the routine at dec_timer_move_aliens.
There's a chunk of unused code near the top of this function.
|
||||||||||||
move_aliens | 30857 | LD A,(_ALIEN_BAND_ARG) | Pick up band to deal with this iteration | |||||||||
30860 | LD B,A | If the band to deal with is lower than the lowest band with aliens, then the band to deal with has no aliens in it. We're not going to have to draw the row so skip the preparation code. In practise this routine is never called with args which cause this jump not to be taken. | ||||||||||
30861 | LD A,(_LOWEST_ACTIVE_ALIEN_ROW) | |||||||||||
30864 | CP B | |||||||||||
30865 | JR NC,ma_jump_always_taken | |||||||||||
In theory this code should be preparing the data for the row to move, but in practise this doesn't seem to get called.
|
||||||||||||
30867 | LD (_ALIEN_BAND_ARG),A | Code not used | ||||||||||
30870 | LD A,(_MOVING_ALIENS_DOWN_FLAG) | |||||||||||
30873 | OR A | |||||||||||
30874 | JR NZ,ma_jump_always_taken | |||||||||||
30876 | LD A,(_ALIEN_BAND_ARG) | |||||||||||
30879 | CALL find_alien_row_data | |||||||||||
30882 | CALL prep_alien_row_data | |||||||||||
30885 | CALL ma_check_horde_left | |||||||||||
The above is not used, resume here.
|
||||||||||||
ma_jump_always_taken | 30888 | LD A,(_ALIEN_BAND_ARG) | Which row are we moving sidewards? If it's the 0th (top) row we make the noise. Otherwise jump over the noise call. | |||||||||
30891 | OR A | |||||||||||
30892 | JR NZ,ma_skip_noise | |||||||||||
Top row of aliens has to move along. Make "dit" noise. Sound for moving alien rows down is in move_one_row_aliens_down.
|
||||||||||||
30894 | CALL sound_burbler | Sound burbler | ||||||||||
30897 | DEFB 10,250,0 | Aliens marching sound | ||||||||||
We need to move a row, prep the row data
|
||||||||||||
ma_skip_noise | 30900 | CALL find_alien_row_data | Address of alien row 'A's data | |||||||||
30903 | CALL prep_alien_row_data | Work out this row's left side space, the width of the horde, and the right side space. Prime all values ready for the print routine. | ||||||||||
30906 | LD A,(_MOVING_ALIENS_DOWN_FLAG) | Are we in the process of moving the rows downwards? If not jump to the sideways movement code | ||||||||||
30909 | OR A | |||||||||||
30910 | JR Z,ma_move_row_sideways | |||||||||||
We're moving the rows of aliens downwards. We iterate from bottom row (row 4) to top row (row 0).
|
||||||||||||
30912 | CALL move_one_row_aliens_down | Move this row down, then come back here. This call contains the code to print the row in its new place | ||||||||||
30915 | LD A,(_ALIEN_BAND_ARG) | Was that the 0th row? If not we branch to exit, ready to do the next row next time. | ||||||||||
30918 | OR A | |||||||||||
30919 | JR NZ,ma_ready_next_row_and_exit | |||||||||||
Moving the horde downwards is complete, we've just done the top row. Change the horde's direction, then exit
|
||||||||||||
30921 | LD (_MOVING_ALIENS_DOWN_FLAG),A | A contains row 0 - handy, reset moving downwards flag | ||||||||||
30924 | LD A,(_HORDE_DIRECTION) | Invert direction | ||||||||||
30927 | NEG | |||||||||||
30929 | LD (_HORDE_DIRECTION),A | |||||||||||
30932 | RET | |||||||||||
This is the exit point for when moving the rows downwards. It updates the arg with the next row up.
|
||||||||||||
ma_ready_next_row_and_exit | 30933 | DEC A | Decrement the arg value ready to do the next row next time and return | |||||||||
30934 | LD (_ALIEN_BAND_ARG),A | |||||||||||
30937 | RET | |||||||||||
We're moving the rows sideways. Move the current one then check if it's the lowest one on screen. If it isn't we go set the arg to be the next band down and exit ready for the next call.. If it is the lowest on screen we branch off to check if the horde can move sideways next time or whether we need to switch to moving them all downwards.
|
||||||||||||
ma_move_row_sideways | 30938 | CALL position_and_print_moved_row | Move this row of aliens down one. If this is the lowest row of aliens jump out to the sideways movement check routine. Otherwise drop through to prepare to move the next row sideways next time round. | |||||||||
30941 | LD A,(_ALIEN_BAND_ARG) | |||||||||||
30944 | LD B,A | |||||||||||
30945 | LD A,(_LOWEST_ACTIVE_ALIEN_ROW) | |||||||||||
30948 | CP B | |||||||||||
30949 | JR Z,ma_check_horde_left | |||||||||||
30951 | LD A,(_ALIEN_BAND_ARG) | Increment band to check next time round and return | ||||||||||
30954 | INC A | |||||||||||
30955 | LD (_ALIEN_BAND_ARG),A | |||||||||||
30958 | RET | |||||||||||
Which way is the horde moving? Branch to check if there's still room to go sideways.
|
||||||||||||
ma_check_horde_left | 30959 | LD A,(_HORDE_DIRECTION) | Pick up horde direction. Is it going left to right? Jump to the check for space on the right side if so. | |||||||||
30962 | CP 1 | |||||||||||
30964 | JR Z,ma_check_right | |||||||||||
Horde is moving right to left. Is there room on the left side to move that way? If so we exit via the still-going-sideways branch. Otherwise drop through to switch to downwards movement.
|
||||||||||||
30966 | LD A,(_ALIEN_ROW_LEFT_MARGIN) | If this row's left side isn't zero there's still room to move so we exit going sideways. Otherwise drop through to start them heading downwards. | ||||||||||
30969 | OR A | |||||||||||
30970 | JR NZ,ma_exit_looping_sideways | |||||||||||
Loop is now dealing with aliens moving downwards. Set that flag and exit.
|
||||||||||||
ma_exit_looping_downwards | 30972 | LD A,1 | Set _MOVING_ALIENS_DOWN_FLAG to 1 and return | |||||||||
30974 | LD (_MOVING_ALIENS_DOWN_FLAG),A | |||||||||||
30977 | RET | |||||||||||
Horde is moving left to right. Is there room on the right side to move that way? If not we need to switch to moving them downwards.
|
||||||||||||
ma_check_right | 30978 | LD A,(_ALIEN_ROW_LEFT_MARGIN) | Add left side to horde width. If that's off the right side of the screen there's no right side space so we have to switch to moving them all downwards. Otherwise drop through. | |||||||||
30981 | LD B,A | |||||||||||
30982 | LD A,(_ALIEN_ROW_BANK_WIDTH) | |||||||||||
30985 | ADD A,B | |||||||||||
30986 | CP 32 | |||||||||||
30988 | JR Z,ma_exit_looping_downwards | |||||||||||
ma_exit_looping_sideways | 30990 | XOR A | We're now moving sideways so set _ALIEN_BAND_ARG to 0 and return | |||||||||
30991 | LD (_ALIEN_BAND_ARG),A | |||||||||||
30994 | RET |
Prev: 30760 | Up: Map | Next: 30995 |