Prev: B16F Up: Map Next: B312
B234: Steer the ship: its speed across and up, and this pass's scroll
Used by the routine at ship_pass.
Called first thing in a pass (ship_pass). The ship never moves on the screen across, and up and down only with its height: the landscape moves under it. This works out how far, in pixels, up and across (scroll_down and the byte after it), for the landscape (draw_landscape) and, negated, for the ship's position in the world (ship_speed_from_scroll).
Across, accelerate_across does the work: this gives it the push in DE, in 256ths of a pixel a pass a pass: $40 left or -$40 right, plus a drag of 12 against the way the ship was going (the step across last pass) -- but only when pushing against it; pushing the way the ship goes ignores the drag. With nothing pushed the drag alone slows the ship. Nothing is pushed while fuel_saver is set (knocked sideways). steer_push says which way it was pushed ($80 left, 3 right, 0 not), for accelerate_across and the ship's drawing.
Up: gravity takes $40 a pass from the climb speed (the ship's record +$1B +$1C), or, while thrusting, thrust adds $50 instead -- one or the other is loaded, never both. The speed is clamped (clamp_climb): no faster than half the top climb (top_climb, 2 or 4) up, and -3 down. It is added to a fraction kept in climb_fraction, and the change in the whole part, doubled, is the step: the screen moves 2 lines a unit. A step one unit too big upwards, or down by 6, is cut to the top climb, or 4. At a step of 4 either way, every other fine-scroll position (origin_y bit 1) moves only 2.
While the special beam is on (special_beam_on) the ship hangs still. Once it has docked with the finished rocket (launch_state set) it thrusts by itself at the fast climb until the view reaches y page 0, then stops.
The second entry, at the adding of the speed to the fraction, works the step out from a speed in HL; bounce_up_down and hit_block (a bounce) use it.
Input
IX the ship's record
move_ship B234 CALL read_controls the controls, and fuel (read_controls)
B237 XOR A not pushed yet; no drag
B238 LD (steer_push),A
B23B LD DE,(no_push)
B23F LD A,(launch_state) docked with the rocket: thrust on and the fast climb; at the top page, stop
B242 AND A
B243 JR Z,move_ship_0
B245 LD A,$08
B247 LD (controls_now),A
B24A LD A,$04
B24C LD (top_climb),A
B24F LD A,(view_row)
B252 AND A
B253 JR NZ,move_ship_1
B255 LD (scroll_down),A
B258 RET
move_ship_0 B259 LD A,(IX+$07) the drag: 12 against last pass's way across, if it moved
B25C NEG
B25E AND A
B25F JR Z,move_ship_1
B261 LD DE,(drag_going_right)
B265 BIT 7,A
B267 JR NZ,move_ship_1
B269 LD DE,(drag_going_left)
move_ship_1 B26D LD A,(controls_now) left: $40, with the drag if the ship was going right
B270 BIT 1,A
B272 JR Z,move_ship_2
B274 EX DE,HL
B275 LD DE,(push_left)
B279 LD A,$80
B27B LD (steer_push),A
B27E LD A,H
B27F CP $FF
B281 JR Z,move_ship_3
B283 ADD HL,DE
B284 EX DE,HL
B285 JR move_ship_3
move_ship_2 B287 BIT 0,A right: -$40, with the drag if the ship was going left
B289 JR Z,move_ship_3
B28B EX DE,HL
B28C LD DE,(push_right)
B290 LD A,$03
B292 LD (steer_push),A
B295 LD A,H
B296 AND A
B297 JR Z,move_ship_3
B299 ADD HL,DE
B29A EX DE,HL
move_ship_3 B29B LD A,(fuel_saver) knocked sideways this pass: no push
B29E AND A
B29F JR Z,move_ship_4
B2A1 LD DE,$0000
move_ship_4 B2A4 CALL accelerate_across the speed across, the position across and the step across (accelerate_across)
B2A7 LD DE,(gravity) gravity, or thrust
B2AB LD A,(controls_now)
B2AE AND $08
B2B0 JR Z,move_ship_5
B2B2 LD DE,(thrust)
move_ship_5 B2B6 LD H,(IX+$1B) the climb speed
B2B9 LD L,(IX+$1C)
B2BC LD A,(special_beam_on) the special beam on: no climb, no fall
B2BF AND A
B2C0 JR Z,move_ship_6
B2C2 LD HL,$0000
B2C5 LD DE,$0000
B2C8 LD (climb_fraction),HL
move_ship_6 B2CB ADD HL,DE add, clamp (clamp_climb) and keep
B2CC CALL clamp_climb
B2CF LD (IX+$1B),H
B2D2 LD (IX+$1C),L
This entry point is used by the routines at bounce_up_down and hit_block.
move_ship_7 B2D5 LD DE,(climb_fraction) the second entry: add the speed to the fraction in climb_fraction
B2D9 ADD HL,DE
B2DA LD (climb_fraction),HL
B2DD LD A,H the whole lines moved, doubled
B2DE SUB D
B2DF ADD A,A
B2E0 LD H,A
B2E1 BIT 7,A upwards: one unit too many (the top climb + 2) becomes the top climb
B2E3 JR NZ,move_ship_8
B2E5 LD A,(top_climb)
B2E8 ADD A,$02
B2EA CP H
B2EB LD A,H
B2EC JR NZ,move_ship_9
B2EE LD A,(top_climb)
B2F1 JR move_ship_9
move_ship_8 B2F3 CP $FA downwards: -6 becomes -4
B2F5 JR NZ,move_ship_9
B2F7 LD A,$FC
move_ship_9 B2F9 LD (scroll_down),A the step up this pass
B2FC CP $04 4 either way: halved when origin_y bit 1 is set
B2FE JR Z,move_ship_10
B300 CP $FC
B302 RET NZ
move_ship_10 B303 LD A,(origin_y)
B306 AND $02
B308 RET Z
B309 LD A,(scroll_down)
B30C SRA A
B30E LD (scroll_down),A
B311 RET
Prev: B16F Up: Map Next: B312