Prev: BE8E Up: Map Next: BF66
BE8F: Work out where a record's box is, and its part in the first page
Used by the routine at collide_with_landscape.
The box is the record's position after this pass's move (move_across, move_down; the record is not changed), C wide and B high from its bottom line up. The move is kept in moved_x and move_across_kept (across), and moved_y and tile_mirrored_left_right (down).
Then, from the loading of moved_y (where next_part comes in for the other parts): the page's list of boxes (find_page_boxes), and the part of the box inside the page -- its x (box_x), bottom line (box_bottom), height (box_height) and width (box_width) -- with what sticks out past the right (stick_out_right) and above the top (stick_out_up). On the first part, the number of parts to test, 1, 2 or 4, goes into ground_cell.
For the ship, its record's speeds are put back to last pass's for the bounce rules (ship_across_speed, ship_down_speed); for an object, they are negated (negate_velocity) -- the objects' speeds are kept the other way round.
Input
B the box's height
C the box's width
IX the record
Output
IX the page's list of boxes
place_collision_box BE8F LD (piece_page_x),BC the size; nothing sticking out yet, no parts, no hits
BE93 XOR A
BE94 LD (stick_out_right),A
BE97 LD (stick_out_up),A
BE9A LD (ground_cell),A
BE9D LD (piece_ceiling),A
BEA0 LD (direction_flag),A
BEA3 CALL move_across the record's place after its move
BEA6 LD (moved_x),HL
BEA9 LD (move_across_kept),HL
BEAC CALL move_down
BEAF LD (moved_y),HL
BEB2 LD (tile_mirrored_left_right),HL
BEB5 LD A,(piece_step_x) an object: its speeds negated
BEB8 INC A
BEB9 JR Z,place_collision_box_0
BEBB DEC A
BEBC CALL Z,negate_velocity
BEBF JR place_collision_box_1
place_collision_box_0 BEC1 LD HL,(ship_across_speed) the ship: last pass's speeds
BEC4 LD (ship_dx),HL
BEC7 LD HL,(ship_down_speed)
BECA LD (ship_dy),HL
place_collision_box_1 BECD LD A,(IX+$07) the speeds for the bounce rules
BED0 LD (last_speed_across),A
BED3 LD A,(IX+$09)
BED6 NEG
BED8 LD (last_speed_up),A
BEDB LD A,(piece_page_x) the full size
BEDE LD (piece_x),A
BEE1 LD A,(piece_page_y)
BEE4 LD (piece_y),A
This entry point is used by the routine at next_part.
place_collision_box_2 BEE7 LD BC,(moved_y) the page's list (find_page_boxes)
BEEB LD DE,(moved_x)
BEEF CALL find_page_boxes
BEF2 LD A,(moved_x) past the right edge (x + width over $E8)?
BEF5 LD C,A
BEF6 LD A,(piece_x)
BEF9 LD B,A
BEFA LD A,C
BEFB ADD A,$18
BEFD ADD A,B
BEFE LD E,B
BEFF JR NC,place_collision_box_4
BF01 LD B,A yes: on the first part, what sticks out; this part is up to $E8
BF02 LD A,(ground_cell)
BF05 AND A
BF06 JR NZ,place_collision_box_3
BF08 LD A,B
BF09 LD (stick_out_right),A
BF0C LD A,$01
BF0E LD (direction_flag),A
place_collision_box_3 BF11 LD A,$E8
BF13 SUB C
BF14 LD E,A
place_collision_box_4 BF15 LD A,E the part's width and x
BF16 LD (box_width),A
BF19 LD A,C
BF1A LD (box_x),A
BF1D LD A,(moved_y) above the top (line - height under $18)?
BF20 LD C,A
BF21 LD A,(piece_y)
BF24 LD B,A
BF25 LD A,C
BF26 SUB $17
BF28 SUB B
BF29 LD E,B
BF2A JR NC,place_collision_box_6
BF2C LD B,A yes: on the first part, what sticks out; this part is from line $18
BF2D LD A,(ground_cell)
BF30 AND A
BF31 JR NZ,place_collision_box_5
BF33 LD A,B
BF34 NEG
BF36 LD (stick_out_up),A
place_collision_box_5 BF39 LD A,C
BF3A SUB $17
BF3C LD E,A
place_collision_box_6 BF3D LD A,E the part's height and line
BF3E LD (box_height),A
BF41 LD A,C
BF42 LD (box_bottom),A
BF45 LD A,(ground_cell) on the first part: how many parts, 1, 2 or 4
BF48 AND A
BF49 RET NZ
BF4A LD B,$01
BF4C LD A,(stick_out_right)
BF4F AND A
BF50 JR Z,place_collision_box_7
BF52 INC B
BF53 LD A,(stick_out_up)
BF56 AND A
BF57 JR Z,place_collision_box_7
BF59 INC B
place_collision_box_7 BF5A LD A,(stick_out_up)
BF5D AND A
BF5E JR Z,place_collision_box_8
BF60 INC B
place_collision_box_8 BF61 LD A,B
BF62 LD (ground_cell),A
BF65 RET
Prev: BE8E Up: Map Next: BF66