A fast-falling character can cross a thin platform between two updates without ever having its feet exactly on the top. Compare the old and proposed bottom edges, then snap the feet to the surface when the downward path crosses it.

Include, initialise and call
Reserve LANDED, SNAP, ACTOR_X, ACTOR_W, PREV_BOTTOM, NEW_BOTTOM, PLATFORM_X, PLATFORM_W, PLATFORM_Y, DROP as 10 contiguous private bytes in that order. Include the helper once. Call one_way_platform_init at the intended reset boundary: it clears every named byte, including input fields. Set the starting values afterwards, then call one_way_platform_step for each intended service.
Initialise once, supply the old and proposed geometry, then service before committing a fall. On LANDED, place the bottom at SNAP and let the caller decide vertical velocity and grounded state. Test each candidate platform as needed; selecting among several surfaces requires the nearest valid top along the path, not an arbitrary last result.
ACTOR_X/ACTOR_W and PLATFORM_X/PLATFORM_W describe unsigned horizontal half-open intervals. Each span includes X and stops just before X + width, so touching edges alone do not overlap. Width zero rejects contact; widened endpoints may reach 510. PREV_BOTTOM and NEW_BOTTOM are unsigned old/proposed bottom coordinates, increasing downwards. Landing requires horizontal overlap and PREV_BOTTOM ≤ PLATFORM_Y ≤ NEW_BOTTOM, with DROP zero. LANDED is replaced with 1 on contact; SNAP becomes PLATFORM_Y on contact and otherwise NEW_BOTTOM. Stationary feet exactly on top count as contact. All inputs survive.
Reusable initialisation and service
; SPDX-License-Identifier: MIT
; Land on a One-way Platform. Contiguous private bytes: LANDED, SNAP, ACTOR_X, ACTOR_W, PREV_BOTTOM, NEW_BOTTOM, PLATFORM_X, PLATFORM_W, PLATFORM_Y, DROP.
; init clears all fields; set inputs afterwards. No I/O, waits or IRQ ownership.
; AF/BC/DE/HL change; IX/IY survive.
one_way_platform_init:
xor a
ld (LANDED),a
ld (SNAP),a
ld (ACTOR_X),a
ld (ACTOR_W),a
ld (PREV_BOTTOM),a
ld (NEW_BOTTOM),a
ld (PLATFORM_X),a
ld (PLATFORM_W),a
ld (PLATFORM_Y),a
ld (DROP),a
ret
one_way_platform_step:
xor a
ld (LANDED),a
ld a,(NEW_BOTTOM)
ld (SNAP),a
ld a,(DROP)
or a
ret nz
ld a,(ACTOR_W)
or a
ret z
ld a,(PLATFORM_W)
or a
ret z
ld a,(PLATFORM_Y)
ld b,a
ld a,(PREV_BOTTOM)
cp b
jr c,platform_new
ret nz
platform_new:
ld a,(NEW_BOTTOM)
cp b
ret c
ld a,(PLATFORM_X)
ld b,a
ld a,(PLATFORM_W)
add a,b
jr c,platform_actor_end
ld b,a
ld a,(ACTOR_X)
cp b
ret nc
platform_actor_end:
ld a,(ACTOR_X)
ld b,a
ld a,(ACTOR_W)
add a,b
jr c,platform_land
ld b,a
ld a,(PLATFORM_X)
cp b
ret nc
platform_land:
ld a,1
ld (LANDED),a
ld a,(PLATFORM_Y)
ld (SNAP),a
ret
component_end:State, registers and ownership
Ten bytes, with LANDED and SNAP first for inspection. Both horizontal intervals use widened arithmetic. The vertical coordinates do not wrap: crossing the byte coordinate seam is outside this contract and needs a wider world representation.
AF/BC/DE/HL may change; IX/IY survive. A direct CALL needs two return-address stack bytes.
The implementation binds fixed symbols and has one mutation owner. Independent users need separate state blocks and scoped/renamed labels, including routine labels; sharing the same bindings means sharing the state. Do not let an interrupt and the main loop mutate the same block without an explicit ownership policy.
The standalone tape program enters at $8000, disables interrupts and owns bitmap/attribute RAM. It does not restore BASIC. Those choices belong to the test program; the helper itself never takes over the display.
A caller you can adapt
The buildable program supplies bindings and include order. Its separate client retains state between calls. checked_step calls the public one_way_platform_step entry and checks register sentinels; emit_state records diagnostics. Your game can call the public entry directly, remove the diagnostics and consume the documented outputs.
Bindings, buildable caller and include order
org $8000
CUSTOM equ 0
BROKEN equ 0
COYOTE_STEPS equ 4
BUFFER_STEPS equ 4
TEXT_CAP equ 8
PROPERTY_COUNT equ 16
STREAM_BYTES equ 13
CRC_POLY equ 7
include "caller.inc"
include "exercise.inc"
component_start:
include "component.inc"
include "data.inc"
include "cases.inc"
include "../../physics/rectangle-overlap/display.inc"
code_end:
STATE:
LANDED: defb 0
SNAP: defb 0
ACTOR_X: defb 0
ACTOR_W: defb 0
PREV_BOTTOM: defb 0
NEW_BOTTOM: defb 0
PLATFORM_X: defb 0
PLATFORM_W: defb 0
PLATFORM_Y: defb 0
DROP: defb 0
input_ptr: defw 0
output_ptr: defw 0
cases_left: defb 0
ready: defb 0
preview: defs 8,0
OUTPUT: defs 1300,0
end startA separate client retaining state between calls
preview_rules:
if CUSTOM
ld a,20
ld (ACTOR_X),a
ld a,16
ld (ACTOR_W),a
ld a,90
ld (PREV_BOTTOM),a
ld a,110
ld (NEW_BOTTOM),a
ld a,10
ld (PLATFORM_X),a
ld a,64
ld (PLATFORM_W),a
ld a,100
ld (PLATFORM_Y),a
ld a,1
ld (DROP),a
if BROKEN
call checked_step
ld a,(PLATFORM_Y)
ld b,a
ld a,(NEW_BOTTOM)
cp b
jr z,bad_platform_done_0_custom
ld (SNAP),a
xor a
ld (LANDED),a
bad_platform_done_0_custom:
else
call checked_step
endif
call emit_state
else
ld a,20
ld (ACTOR_X),a
ld a,16
ld (ACTOR_W),a
ld a,90
ld (PREV_BOTTOM),a
ld a,110
ld (NEW_BOTTOM),a
ld a,10
ld (PLATFORM_X),a
ld a,64
ld (PLATFORM_W),a
ld a,100
ld (PLATFORM_Y),a
ld a,0
ld (DROP),a
if BROKEN
call checked_step
ld a,(PLATFORM_Y)
ld b,a
ld a,(NEW_BOTTOM)
cp b
jr z,bad_platform_done_0
ld (SNAP),a
xor a
ld (LANDED),a
bad_platform_done_0:
else
call checked_step
endif
call emit_state
endif
retThe display fields are LANDED, SNAP, ACTOR_X, ACTOR_W, PREV_BOTTOM, NEW_BOTTOM, PLATFORM_X, PLATFORM_W; later state bytes are retained in the full packet. Each is one hexadecimal byte. The normal row is 01 64 14 10 5A 6E 0A 40. This is a completed state observation, not a recording of an actual character jumping, a camera scrolling or an asset being displayed.
Make it your own
The custom caller sets DROP to 1. The same downward crossing now passes through the platform, returning LANDED zero and SNAP equal to the proposed bottom 110. The caller decides how long drop-through remains active.
Maintained custom configuration or caller
org $8000
CUSTOM equ 1
BROKEN equ 0
COYOTE_STEPS equ 2
BUFFER_STEPS equ 2
TEXT_CAP equ 4
PROPERTY_COUNT equ 16
STREAM_BYTES equ 13
CRC_POLY equ 49
include "caller.inc"
include "exercise.inc"
component_start:
include "component.inc"
include "data.inc"
include "cases.inc"
include "../../physics/rectangle-overlap/display.inc"
code_end:
STATE:
LANDED: defb 0
SNAP: defb 0
ACTOR_X: defb 0
ACTOR_W: defb 0
PREV_BOTTOM: defb 0
NEW_BOTTOM: defb 0
PLATFORM_X: defb 0
PLATFORM_W: defb 0
PLATFORM_Y: defb 0
DROP: defb 0
input_ptr: defw 0
output_ptr: defw 0
cases_left: defb 0
ready: defb 0
preview: defs 8,0
OUTPUT: defs 1300,0
end startThe custom row is 00 6E 14 10 5A 6E 0A 40. These records qualify the named builds and inputs; another layout, format or input domain needs explicit bounds and fresh execution evidence.
Common mistake and repair
The wrong client retains a contact only when the proposed bottom equals the platform top. It discards the correctly detected 90→110 crossing of top 100, so a fast fall misses the surface. Compare the interval crossed, not just equality at the endpoint.
Select the deliberately wrong client
org $8000
CUSTOM equ 0
BROKEN equ 1
COYOTE_STEPS equ 4
BUFFER_STEPS equ 4
TEXT_CAP equ 8
PROPERTY_COUNT equ 16
STREAM_BYTES equ 13
CRC_POLY equ 7
include "caller.inc"
include "exercise.inc"
component_start:
include "component.inc"
include "data.inc"
include "cases.inc"
include "../../physics/rectangle-overlap/display.inc"
code_end:
STATE:
LANDED: defb 0
SNAP: defb 0
ACTOR_X: defb 0
ACTOR_W: defb 0
PREV_BOTTOM: defb 0
NEW_BOTTOM: defb 0
PLATFORM_X: defb 0
PLATFORM_W: defb 0
PLATFORM_Y: defb 0
DROP: defb 0
input_ptr: defw 0
output_ptr: defw 0
cases_left: defb 0
ready: defb 0
preview: defs 8,0
OUTPUT: defs 1300,0
end start
The BROKEN branch is visible in the client. repaired.asm restores the normal selection; its executable matches demo exactly. Spectrum tape filenames may differ while loaded CODE remains identical. The fault is a labelled experiment, not a suggested alternative.
Cost, limits and verification
The measured layout has 117 code bytes, 0 immutable data bytes and 10 private state bytes. Alignment, stack usage, diagnostic tables and display machinery are additional. The extents come from the loaded program’s symbols, not from counting source lines.
Two horizontal interval comparisons and two vertical comparisons, with no per-pixel stepping. On 6502/Z80 a carry from an endpoint addition represents an endpoint beyond 255; 68000 uses widened words. The caller’s search over platforms is additional work.
This tests a horizontal one-way top, not walls, ceilings, slopes or a full swept-AABB solver. Teleports and large coordinate jumps need an explicit policy. Moving platforms also need relative motion and carried movement. The static rectangle-overlap routines remain useful for other contact tests.
Four native runs use Spectrum 48K with stock ROM tape loading and USR entry; Asm198x 0.0.72 and Emu198x 0.44.2. Each checks 64 boundary/varied/error cases, dirty initialisation and every state of a separate sequential client against an independent integer model. This is not exhaustive coverage of every possible byte combination. Source/tool/firmware hashes, immutable loaded code/data, native startup/completion, preserved-register sentinels, helper/data sizes, screenshot bytes/pixels and exact repair are checked. Deliberately altered observations must fail. Firmware is hashed, never distributed.