Lunar Porter, rung three and a half: fuel

Every thruster costs a unit every tick it fires, so holding two at once
costs two - the honest price, and it makes a drift you corrected expensive
in a way a drift you avoided is not.

AN EMPTY TANK IS NOT AN ENDING. There is no message and nothing stops: a
lander with no fuel is still flying, it just cannot do anything about
where. What happens next is gravity, and gravity is patient. The test for
it holds the thruster from the first frame to the last and crashes anyway,
which is what says the fuel is real - a lander that could hold Up for ever
would land every time, and the economy this is the first half of would
have nothing to buy.

The gauge is in the window, which is what the window was built for two
commits ago: a bar at a SCREEN position, so the moon turning underneath
does not carry it off. Thirty five cells after a label, redrawn whole
every frame because seventy bytes out of one port is cheaper than working
out which of them changed.

A byte of fuel, and a byte is enough. Over eight it is a bar of up to
thirty one cells - a shift, because there is no divide - and at a unit a
thruster a tick it is about forty seconds of holding the engine open.
Sixteen bits would be more arithmetic for a number nobody reads to the
unit.

Cargo and the bases are the other half.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-03 00:35:34 -04:00
co-authored by Claude Opus 5
parent 17c8da111f
commit 2274be4b68
17 changed files with 199 additions and 12 deletions
+136
View File
@@ -70,6 +70,7 @@ start:
CALL makeMoon
CALL drawMoon
CALL putLander
CALL putGauge
INIA 0x01
OUTA 0x02 ; Key mode.
@@ -94,6 +95,7 @@ everyFrame:
CALL touchdown
CALL showLander
CALL showDrift
CALL showFuel
SETD.0 Flying
LDA.0
BNA everyFrame
@@ -340,6 +342,97 @@ putLander:
OUTA 0xE9 ; No flags, natural size, no depth.
RET
; ---- The gauge, which lives where the moon cannot scroll it away ----
;
; The window is a layer at a SCREEN position rather than a position in the world, so a bar
; drawn in it stays where it is put however far the moon turns underneath. One row, at the
; top, and the label written once because it never changes.
;
; The letters are ordinary tiles. The character generator starts at the space, so glyph n is
; character n plus thirty two - which makes F, U, E and L into 38, 53, 37 and 44.
putGauge:
INIA 0x01
OUTA 0x3D ; One row tall.
RSTA
OUTA 0x3E ; At the top of the screen.
INIA 0d5
OUTA 0xE3
INIA 0xC0
OUTA 0xE4
RSTA
OUTA 0xE5 ; The window begins at 0xC000 of the screen bank.
INIA 0d38
OUTA 0xE9
RSTA
OUTA 0xE9 ; F
INIA 0d53
OUTA 0xE9
RSTA
OUTA 0xE9 ; U
INIA 0d37
OUTA 0xE9
RSTA
OUTA 0xE9 ; E
INIA 0d44
OUTA 0xE9
RSTA
OUTA 0xE9 ; L
RET
; ---- And how much of it is left ----
;
; A byte of fuel makes a bar of up to 31 cells, which is the byte over eight: a shift, because
; there is no divide. Thirty five cells of room after the label, so a full tank does not quite
; fill the row and there is somewhere for it to be seen to stop.
;
; Redrawn whole every frame. Thirty five cells is seventy bytes out of one port with the
; address named once, which is cheaper than working out which of them changed.
showFuel:
RSTA
SETD.1 Fuel
LDB.1
CALL eighth ; Q is the fuel over eight, in the low half where it belongs.
MVQA
SETD.1 GaugeLeft
STA.1
INIA 0d5
OUTA 0xE3
INIA 0xC0
OUTA 0xE4
INIA 0x0A
OUTA 0xE5 ; Cell five of the window row, just past the label.
RSTA
SETD.1 GaugeAt
STA.1
gaugeCell:
; Solid while there is bar left to draw, blank after it.
SETD.1 GaugeLeft
LDA.1
BRA gaugeEmpty
DECA
STA.1
INIA 0xC8
OUTA 0xE9 ; The solid block, which is the ground's tile.
INIA 0x02
OUTA 0xE9 ; Scheme two, so the bar is not the colour of the moon.
BRI gaugeNext
gaugeEmpty:
OUTA 0xE9
OUTA 0xE9 ; A is nought here: no tile and no colour.
gaugeNext:
SETD.1 GaugeAt
LDA.1
INCA
STA.1
INIB 0d35
CCF
SUB
BNQ gaugeCell
RET
; ---- What the pad is holding ----
;
; One read, every button at once, and it does not go away when it is looked at. THIS IS THE
@@ -474,6 +567,8 @@ fall:
INIB 0x08 ; Up
AND
BRQ fallNotUp
CALL takeFuel
BRQ fallNotUp ; Nothing in the tank, so nothing out of the engine.
SETD.0 SpeedDown
SETD.1 PadUp
CALL addWord
@@ -483,6 +578,8 @@ fallNotUp:
INIB 0x02 ; Left
AND
BRQ fallNotLeft
CALL takeFuel
BRQ fallNotLeft
SETD.0 SpeedAcross
SETD.1 PadLeft
CALL addWord
@@ -492,12 +589,39 @@ fallNotLeft:
INIB 0x01 ; Right
AND
BRQ fallDone
CALL takeFuel
BRQ fallDone
SETD.0 SpeedAcross
SETD.1 PadRight
CALL addWord
fallDone:
RET
; ---- One unit, if there is one ----
;
; Q comes back nought when the tank is empty, and the thruster that asked does not fire. There
; is no message and no ending: a lander with no fuel is still flying, it just cannot do
; anything about where. What happens next is gravity, and gravity is patient.
;
; Charged PER THRUSTER PER TICK, so holding two at once costs two - which is the honest price
; and makes a drift you corrected expensive in a way a drift you avoided is not.
takeFuel:
SETD.1 Fuel
LDA.1
BRA takeFuelNone
DECA
STA.1
INIA 0x01
RSTB
CCF
ADD ; Q is one, which the caller reads as yes.
RET
takeFuelNone:
RSTB
CCF
ADD ; A is nought here, so Q is too, which is no.
RET
; ---- Where it is now ----
;
; Across first, and the wrap is an AND rather than a comparison: the moon is 2^14 sixteenths
@@ -1001,6 +1125,18 @@ DriftAt:
0x00
DriftSize:
0x00
; ---- The tank ----
;
; One byte, and a byte is enough: over eight it is a bar of up to 31 cells, and at one unit a
; thruster a tick it is about forty seconds of holding the engine open. Sixteen bits would be
; more arithmetic for a number nobody reads to the unit.
Fuel:
0xFF
GaugeLeft:
0x00
GaugeAt:
0x00
SurfaceAt:
0x00