A dock that slides into line, and settles squarely on the port
Two things, and the second is the one that was actually wrong. The lander is slid into place at half a pixel a frame rather than put there. A dock is allowed eight pixels out in either direction, so snapping moved it a whole tile in a single frame - a jump, at the very moment the player was being told they had been careful. The worst gap closes in about half a second, which reads as the two of them settling together. And it settles SQUARELY now. It used to come to rest four pixels out however carefully it was flown, because the lander is drawn from half a screen less half a tile - which is what centres an eight pixel lander on the middle - while the station was drawn from half a screen exactly, so its left edge sat where the lander's centre was. Both come off the same origin now, and a gap of nothing puts one exactly above the other. stationGap is factored out along the way. Three callers wanted it: the one that draws the station, the one that decides whether it can be docked with, and now the one that slides the lander in under it. The sideways ease goes through that wrapped gap rather than the raw positions, because a dock made either side of the moon's seam has a raw difference of most of a moon. ---- And the fixtures moved to frame 400 ---- A dock waits to be told its message has been read, and reading a state file costs a disk read, so a placed run starts a good deal later than a plain one. The acknowledgement was at frame 100 and stopped working the day the state file arrived: the program had not reached the dock yet and the press went by unheard, which shows up as every sprite missing and reads like a drawing bug. Everything after it is sampled well clear of both ends. Two checks, each seen to fail on its own break - the alignment settles at 4,-8 without the shared origin, and the slide reads 0,-8 the whole way without the easing. Which of the two axes each one actually watches is written down beside them, because it is not the one you would guess.
This commit is contained in:
+159
-57
@@ -1282,7 +1282,17 @@ moveStation:
|
||||
; Off the edge needs no test. A sprite's X is signed and sixteen bits, so a station three
|
||||
; hundred pixels to the left is asked for at minus a hundred and forty and the device declines
|
||||
; to draw it, which is a comparison this does not have to make.
|
||||
showStation:
|
||||
; ---- How far round the moon the station is from the lander, and which way ----
|
||||
;
|
||||
; Wrapped to fourteen bits like everything else here, which measures the long way round
|
||||
; whenever the station is behind - so anything past the half way point is turned into a
|
||||
; distance BACKWARDS before anybody uses it. Three callers want this now: the one that draws
|
||||
; the station, the one that decides whether it can be docked with, and the one that slides the
|
||||
; lander in under it afterwards.
|
||||
;
|
||||
; Half a moon is 8,192 sixteenths, which is 512 pixels - and that fits in the twelve signed
|
||||
; bits toPixelsSigned hands back, so the drawing side can take this straight.
|
||||
stationGap:
|
||||
SETD.0 StationLow
|
||||
LDA.0
|
||||
SETD.1 AcrossLow
|
||||
@@ -1301,24 +1311,33 @@ showStation:
|
||||
AND
|
||||
SETD.1 GapHigh
|
||||
STQ.1
|
||||
|
||||
SETD.0 GapLow
|
||||
CALL toPixels ; Nought to 1023 pixels, which is the whole moon.
|
||||
SETD.0 PixelHigh
|
||||
LDA.0
|
||||
INIB 0x02
|
||||
LDA.1
|
||||
INIB 0x20
|
||||
AND
|
||||
BRQ stationAhead ; Under 512, so it is ahead and the offset stands.
|
||||
BRQ stationGapDone ; Under half a moon, so it is ahead and the gap stands.
|
||||
SETD.0 GapHigh
|
||||
LDA.0
|
||||
INIB 0d4
|
||||
INIB 0x40
|
||||
CCF
|
||||
SUB
|
||||
STQ.0 ; Less a whole moon, which makes it a distance backwards.
|
||||
stationAhead:
|
||||
stationGapDone:
|
||||
RET
|
||||
|
||||
showStation:
|
||||
CALL stationGap
|
||||
SETD.0 GapLow
|
||||
CALL toPixelsSigned
|
||||
|
||||
; ---- From the lander's own column, not from the middle ----
|
||||
;
|
||||
; ShipX is half a screen LESS HALF A TILE, because that is what centres an eight pixel lander
|
||||
; on the middle. The station was drawn from the middle itself, so its left edge sat where the
|
||||
; lander's centre was and a perfectly aligned dock still looked four pixels out. Same origin
|
||||
; for both, and a gap of nothing puts one exactly above the other.
|
||||
SETD.0 PixelLow
|
||||
LDA.0
|
||||
SETD.1 HalfScreen
|
||||
SETD.1 ShipX
|
||||
LDB.1
|
||||
CCF
|
||||
ADD
|
||||
@@ -1326,7 +1345,7 @@ stationAhead:
|
||||
STQ.1
|
||||
SETD.0 PixelHigh
|
||||
LDA.0
|
||||
SETD.1 HalfScreen
|
||||
SETD.1 ShipX
|
||||
INCD.1
|
||||
LDB.1
|
||||
ADD
|
||||
@@ -1802,41 +1821,9 @@ dock:
|
||||
LDA.0
|
||||
BNA dockRiding
|
||||
|
||||
; ---- Close enough, going round ----
|
||||
;
|
||||
; Wrapped to fourteen bits like everything else on this moon, which measures the long way
|
||||
; round when the station is behind, so past the half way point is turned into a distance
|
||||
; backwards before its size is taken.
|
||||
SETD.0 StationLow
|
||||
LDA.0
|
||||
SETD.1 AcrossLow
|
||||
LDB.1
|
||||
CCF
|
||||
SUB
|
||||
SETD.1 DockGapLow
|
||||
STQ.1
|
||||
SETD.0 StationHigh
|
||||
LDA.0
|
||||
SETD.1 AcrossHigh
|
||||
LDB.1
|
||||
SUB
|
||||
MVQA
|
||||
INIB 0x3F
|
||||
AND
|
||||
SETD.1 DockGapHigh
|
||||
STQ.1
|
||||
LDA.1
|
||||
INIB 0x20
|
||||
AND
|
||||
BRQ dockGapNear
|
||||
SETD.0 DockGapHigh
|
||||
LDA.0
|
||||
INIB 0x40
|
||||
CCF
|
||||
SUB
|
||||
STQ.0
|
||||
dockGapNear:
|
||||
SETD.0 DockGapLow
|
||||
; Close enough, going round, which is the same gap the station is drawn from.
|
||||
CALL stationGap
|
||||
SETD.0 GapLow
|
||||
CALL magnitude
|
||||
SETD.0 DriftHigh
|
||||
LDA.0
|
||||
@@ -1951,27 +1938,35 @@ dockRiding:
|
||||
AND
|
||||
BNQ dockLetGo
|
||||
|
||||
SETD.0 StationLow
|
||||
LDA.0
|
||||
SETD.1 AcrossLow
|
||||
STA.1
|
||||
SETD.0 StationHigh
|
||||
LDA.0
|
||||
SETD.1 AcrossHigh
|
||||
STA.1
|
||||
; ---- Slid into place, not snapped to it ----
|
||||
;
|
||||
; A dock is allowed at up to eight pixels out in either direction, so putting the lander
|
||||
; exactly under the station the instant it takes hold moved it a whole tile in one frame -
|
||||
; a jump, right at the moment the player was being told they had been careful. Half a pixel
|
||||
; a frame closes the worst of it in about half a second, which reads as the two of them
|
||||
; settling together.
|
||||
;
|
||||
; The sideways one goes through the WRAPPED gap rather than the raw positions, because a
|
||||
; dock made either side of the moon's seam has a raw difference of most of a moon.
|
||||
CALL stationGap
|
||||
CALL easeAcross
|
||||
|
||||
SETD.0 StationDownLow
|
||||
LDA.0
|
||||
INIB 0d128
|
||||
CCF
|
||||
ADD
|
||||
SETD.1 DownLow
|
||||
SETD.1 DockTargetLow
|
||||
STQ.1
|
||||
SETD.0 StationDownHigh
|
||||
LDA.0
|
||||
RSTB
|
||||
ADD ; One tile below it, carry included.
|
||||
SETD.1 DownHigh
|
||||
SETD.1 DockTargetHigh
|
||||
STQ.1
|
||||
SETD.0 DownLow
|
||||
SETD.1 DockTargetLow
|
||||
CALL easeToward
|
||||
|
||||
INIA 0d64
|
||||
SETD.0 SpeedAcross
|
||||
@@ -1991,6 +1986,100 @@ dockLetGo:
|
||||
STA.0
|
||||
RET
|
||||
|
||||
; ---- Half a pixel of the way there, or the whole of it if that is nearer ----
|
||||
;
|
||||
; DP0 names the word to move, DP1 the place it should end up. The gap is taken as a signed
|
||||
; sixteen bit number, so "close enough to finish" is two cases and not one: a small gap
|
||||
; forwards has a high byte of nought, and a small gap backwards has one of 0xFF.
|
||||
easeToward:
|
||||
LDA.1
|
||||
LDB.0
|
||||
CCF
|
||||
SUB
|
||||
SETD.2 EaseLow
|
||||
STQ.2
|
||||
INCD.0
|
||||
INCD.1
|
||||
LDA.1
|
||||
LDB.0
|
||||
SUB ; And the borrow, which is the other half of the gap.
|
||||
SETD.2 EaseHigh
|
||||
STQ.2
|
||||
DECD.0
|
||||
DECD.1 ; Both pointers back at the low bytes they came in on.
|
||||
|
||||
LDA.2 ; DP2 still names the high half of the gap.
|
||||
BNA easeBack ; Not nought, so the gap runs backwards or is a long way off.
|
||||
SETD.2 EaseLow
|
||||
LDA.2
|
||||
INIB 0d8
|
||||
CCF
|
||||
SUB
|
||||
BRC easeArrive ; Borrowed: under a step, so put it exactly there.
|
||||
SETD.1 EaseForward
|
||||
CALL addWord
|
||||
RET
|
||||
easeBack:
|
||||
SETD.2 EaseLow
|
||||
LDA.2
|
||||
INIB 0d248
|
||||
CCF
|
||||
SUB
|
||||
BNC easeArrive ; No borrow: within a step of nought, going the other way.
|
||||
SETD.1 EaseBackward
|
||||
CALL addWord
|
||||
RET
|
||||
easeArrive:
|
||||
LDA.1
|
||||
STA.0
|
||||
INCD.0
|
||||
INCD.1
|
||||
LDA.1
|
||||
STA.0
|
||||
RET
|
||||
|
||||
; ---- The same, for a position that has to go round a moon to get there ----
|
||||
;
|
||||
; The gap is already worked out and wrapped, in GapLow. Adding to a position and then wrapping
|
||||
; it is the whole difference from the routine above: on a ring the target is "whatever closes
|
||||
; that gap", not a place, because the place can be on the other side of the seam.
|
||||
easeAcross:
|
||||
SETD.0 GapHigh
|
||||
LDA.0
|
||||
BNA easeAcrossBack ; Not nought, so the gap runs backwards or is a long way off.
|
||||
SETD.0 GapLow
|
||||
LDA.0
|
||||
INIB 0d8
|
||||
CCF
|
||||
SUB
|
||||
BRC easeAcrossWhole ; Borrowed: under a step, so close the whole of it at once.
|
||||
SETD.0 AcrossLow
|
||||
SETD.1 EaseForward
|
||||
CALL addWord
|
||||
BRI easeAcrossWrap
|
||||
easeAcrossBack:
|
||||
SETD.0 GapLow
|
||||
LDA.0
|
||||
INIB 0d248
|
||||
CCF
|
||||
SUB
|
||||
BNC easeAcrossWhole
|
||||
SETD.0 AcrossLow
|
||||
SETD.1 EaseBackward
|
||||
CALL addWord
|
||||
BRI easeAcrossWrap
|
||||
easeAcrossWhole:
|
||||
SETD.0 AcrossLow
|
||||
SETD.1 GapLow
|
||||
CALL addWord
|
||||
easeAcrossWrap:
|
||||
SETD.0 AcrossHigh
|
||||
LDA.0
|
||||
INIB 0x3F
|
||||
AND
|
||||
STQ.0 ; Round the moon, the way every other step along it is.
|
||||
RET
|
||||
|
||||
; ---- A key, or a button ----
|
||||
;
|
||||
; Somebody flying on a controller should not have to reach for the keyboard to say "yes, I
|
||||
@@ -3104,6 +3193,19 @@ Landed:
|
||||
; Holding onto the station, which is the same kind of rest as sitting on the ground.
|
||||
Docked:
|
||||
0x00
|
||||
; Where the lander is sliding to, and how far it has to go to get there.
|
||||
DockTargetLow:
|
||||
0x00
|
||||
DockTargetHigh:
|
||||
0x00
|
||||
EaseLow:
|
||||
0x00
|
||||
EaseHigh:
|
||||
0x00
|
||||
EaseForward:
|
||||
0x08 0x00 ; Half a pixel a frame, which settles the worst gap in about half
|
||||
EaseBackward:
|
||||
0xF8 0xFF ; a second - slow enough to see and fast enough not to wait for.
|
||||
DockGapLow:
|
||||
0x00
|
||||
DockGapHigh:
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user