Prev: DDF7 Up: Map Next: DEDC
DDF8: Scroll the view, step through the map, and draw the landscape
Used by the routines at ship_pass and start_landscape.
Jumped to at the end of ship_pass (once a play pass) and from start_landscape (the fly-in). scroll_down and scroll_across are this pass's vertical and horizontal scroll in pixels (signed, from the ship's movement). The scroll origins origin_y and origin_x move by them, and the in-cell positions at the play area's bottom and left edges (view_y = $B7 - origin_y, view_x = 8 - origin_x) move the other way. When an edge position leaves its map cell it wraps by a cell -- 160 rows or 224 columns -- and the map row or column (view_row, view_column) moves by one; C counts the wraps into record_ground.
If any happened (or in the fly-in) the window of four map cells is rebuilt (load_map_window) and its colours chosen (set_landscape_colours). The landscape is drawn (draw_landscape) unless the view is in the top three map rows, which hold no landscape (the four collision-box lists are just emptied). The sprites are handled by update_ground_objects before or after the landscape by the scroll's direction, draw_beams and draw_stars run, four rows of the frame below the play area's bottom-left corner are made solid again, and the pass goes on at draw_ship -- or at fly_in_step during the fly-in.
scroll_landscape DDF8 LD A,(scroll_down) vertical_step_size = size of the vertical scroll.
DDFB BIT 7,A
DDFD JR Z,scroll_landscape_0
DDFF NEG
scroll_landscape_0 DE01 LD (vertical_step_size),A
DE04 LD C,$00 No wraps yet; HL = map column and row.
DE06 LD HL,(view_column)
scroll_landscape_1 DE09 LD A,(origin_y) Move vertically.
DE0C LD B,A
DE0D LD A,(scroll_down)
DE10 ADD A,B
DE11 LD (origin_y),A
DE14 LD A,(scroll_down)
DE17 NEG
DE19 LD B,A
DE1A LD A,(view_y)
DE1D ADD A,B
DE1E LD (view_y),A
DE21 CP $B8
DE23 JR NC,scroll_landscape_2
DE25 CP $16 The bottom edge has passed the cell's top: wrap to the cell above (row - 1).
DE27 JR NC,scroll_landscape_3
DE29 LD A,$B7
DE2B LD (view_y),A
DE2E XOR A
DE2F LD (origin_y),A
DE32 DEC H
DE33 INC C
DE34 JP scroll_landscape_1
scroll_landscape_2 DE37 LD A,$17 Past its bottom: wrap to the cell below (row + 1).
DE39 LD (view_y),A
DE3C LD A,$A0
DE3E LD (origin_y),A
DE41 INC H
DE42 INC C
DE43 JP scroll_landscape_1
scroll_landscape_3 DE46 LD A,(scroll_across) Move horizontally.
DE49 LD B,A
DE4A LD A,(origin_x)
DE4D ADD A,B
DE4E LD (origin_x),A
DE51 LD A,(scroll_across)
DE54 NEG
DE56 LD B,A
DE57 LD A,(view_x)
DE5A ADD A,B
DE5B LD (view_x),A
DE5E CP $E9
DE60 JR NC,scroll_landscape_4
DE62 CP $07 The left edge has passed the cell's left: wrap (column - 1).
DE64 JR NC,scroll_landscape_5
DE66 LD A,$E8
DE68 LD (view_x),A
DE6B LD A,$20
DE6D LD (origin_x),A
DE70 DEC L
DE71 INC C
DE72 JP scroll_landscape_3
scroll_landscape_4 DE75 LD A,$08 Past its right: wrap (column + 1).
DE77 LD (view_x),A
DE7A XOR A
DE7B LD (origin_x),A
DE7E INC L
DE7F INC C
DE80 JP scroll_landscape_3
scroll_landscape_5 DE83 LD A,C Rebuild the window if a cell was crossed; colours.
DE84 LD (record_ground),A
DE87 AND A
DE88 CALL NZ,load_map_window
DE8B CALL set_landscape_colours
DE8E LD DE,map_window_tiles Walk the window's four cells from the first.
DE91 LD (map_window_pointer),DE
DE95 LD A,(scroll_down) scroll_down negative (the landscape moving up): sprites first.
DE98 BIT 7,A
DE9A CALL NZ,update_ground_objects
DE9D LD A,(view_row) Map rows 0-2 hold no landscape:
DEA0 CP $03
DEA2 JR NC,scroll_landscape_6
DEA4 XOR A
DEA5 LD (loader_entry),A empty the four collision-box lists instead.
DEA8 LD (ground_cell_bottom_left),A
DEAB LD (ground_cell_top_right),A
DEAE LD (ground_cell_bottom_right),A
DEB1 JR scroll_landscape_7
scroll_landscape_6 DEB3 CALL draw_landscape Draw the landscape.
scroll_landscape_7 DEB6 LD A,(scroll_down) Otherwise sprites after.
DEB9 BIT 7,A
DEBB CALL Z,update_ground_objects
DEBE CALL draw_beams draw_beams, draw_stars.
DEC1 CALL draw_stars
DEC4 LD A,$FF Solid frame bytes at column 1, pixel rows 185, 186, 189 and 190.
DEC6 LD ($56E1),A
DEC9 LD ($55E1),A
DECC LD ($52E1),A
DECF LD ($51E1),A
DED2 LD A,(map_rebuild) On with the play pass, or the fly-in.
DED5 AND A
DED6 JP Z,draw_ship
DED9 JP fly_in_step
Prev: DDF7 Up: Map Next: DEDC