Implement disabled spaces through east/west connections (#33)

This commit is contained in:
xCrystal 2023-12-21 19:56:52 +01:00
parent fc6f496254
commit 1cc65f4255
2 changed files with 87 additions and 2 deletions

15
engine/board/spaces.asm Executable file → Normal file
View File

@ -569,6 +569,17 @@ _LoadDisabledSpaces:
ret
.WestConnectedMap:
.EastConnectedMap:
xor a
ld a, [wTempSpaceXCoord]
ld d, a
ld a, [wTempSpaceYCoord]
ld e, a
call GetWestConnectedBlockLocation
ret
.EastConnectedMap:
ld a, [wTempSpaceXCoord]
ld d, a
ld a, [wTempSpaceYCoord]
ld e, a
call GetEastConnectedBlockLocation
ret

View File

@ -464,6 +464,7 @@ CopyMapPartialAndAttributes::
ret
CopyMapPartialAndAttributesPartial::
; used by LoadDisabledSpaces only
ld a, [hROMBank]
push af
call CopyMapPartial
@ -2061,7 +2062,80 @@ GetNorthConnectedBlockLocation::
.done
scf
ret ; c
.nope
xor a
ret ; nc
GetEastConnectedBlockLocation::
; xcoord / 2 <= 2
ld a, d
srl a
cp 3
ret nc
; [wEastConnectionStripLocation]
ld hl, wEastConnectionStripLocation
ld a, [hli]
ld h, [hl]
ld l, a
; + (xcoord / 2)
srl d
ld b, 0
ld c, d
add hl, bc
; + ([wMapWidth] + 6) * ycoord / 2
ld a, [wMapWidth]
add 6
ld c, a
ld b, 0
srl e
ld a, e
and a
jr z, .done
.loop
add hl, bc
dec a
jr nz, .loop
.done
scf
ret ; c
GetWestConnectedBlockLocation::
; wWestConnectedMapWidth >= 3
; xcoord / 2 >= ([wWestConnectedMapWidth] - 3)
ld a, [wWestConnectedMapWidth]
sub 3
jr c, .nope
ld c, a
ld a, d
srl a
sub c
jr c, .nope
ld d, a ; d = xcoord / 2 - ([wWestConnectedMapWidth] - 3)
; [wWestConnectionStripLocation]
ld hl, wWestConnectionStripLocation
ld a, [hli]
ld h, [hl]
ld l, a
; + xcoord / 2 - ([wWestConnectedMapWidth] - 3) --> + d
ld c, d
ld b, 0
add hl, bc
; + ([wMapWidth] + 6) * ycoord / 2
ld a, [wMapWidth]
add 6
ld c, a
ld b, 0
srl e
ld a, e
and a
jr z, .done
.loop
add hl, bc
dec a
jr nz, .loop
.done
scf
ret ; c
.nope
xor a
ret ; nc