Skip to content

Commit df010d2

Browse files
committed
refactor: SailCollide reuses DockTileIfPort for the soft-landing check
WorldTile already leaves the tile coords in wWX/wGRrow; the open-coded district shift math was a second copy of what DockTileIfPort does.
1 parent 2cf1165 commit df010d2

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

src/sail.asm

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -679,20 +679,15 @@ SailCollide:
679679
SR16 h, l, 3
680680
ld e, l
681681
ld d, h ; de = ty
682-
push bc
683-
push de
682+
ld a, d
683+
ld [wGRrowH], a ; WorldTile stores only ty's low byte
684684
call WorldTile
685-
pop de
686-
pop bc
687685
cp TILE_SAND
688686
ret c ; water: keep sailing
689687
; a port district's shore is a dock, not a rock (the same district
690-
; hash that draws the dock planks): stop the ship, spare the hull
691-
SR16 b, c, 2
692-
ld b, c ; dx = tx / 4
693-
SR16 d, e, 2
694-
ld c, e ; dy = ty / 4
695-
call HasPortHash
688+
; hash that draws the dock planks): stop the ship, spare the hull.
689+
; WorldTile left the tile coords in wWX/wGRrow for DockTileIfPort.
690+
call DockTileIfPort ; a = TILE_DOCK iff a port district
696691
ld c, a ; survives the revert below (a-only)
697692
ld a, [wOldPosX]
698693
ld [wPosX], a
@@ -707,8 +702,8 @@ SailCollide:
707702
ld [wVelY], a
708703
call ComputeShipPx
709704
ld a, c
710-
and a
711-
ret nz ; docking bump: no damage
705+
cp TILE_DOCK
706+
ret z ; docking bump: no damage
712707
; hull damage (with cooldown)
713708
ld a, [wDmgCool]
714709
and a

src/world.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ wFX: db
3737
wFY: db
3838
wWX:: dw ; current tile x (generation/detail)
3939
wGRrow:: db ; current tile y (low byte; detail hash)
40-
wGRrowH: db ; current tile y, high byte (world rows 256-287)
40+
wGRrowH:: db ; current tile y, high byte (world rows 256-287)
4141
wH00: db
4242
wH10: db
4343
wH01: db
@@ -304,7 +304,7 @@ TileAttr:
304304
; in: a = TILE_SAND (a beach tile at wWX/wGRrow); out: a = TILE_DOCK if the
305305
; tile's 4x4 district is a port district, else TILE_SAND. Pure function of
306306
; seed+coords, so streamed and redrawn tiles always agree. clobbers all.
307-
DockTileIfPort:
307+
DockTileIfPort::
308308
ld a, [wWX]
309309
ld l, a
310310
ld a, [wWX+1]

0 commit comments

Comments
 (0)