lufia2ac: prevent "door stairs" and "rare stairs" (#2341)

This commit is contained in:
el-u 2023-10-23 22:20:27 +02:00 committed by GitHub
parent e394c316f5
commit 8109d4a1af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 1 deletions

View File

@ -1127,6 +1127,53 @@ pullpc
; door stairs fix
pushpc
org $839453
; DB=$7F, x=0, m=1
JSL DoorStairsFix ; overwrites JSR $9B18 : JSR $9D11
NOP #2
pullpc
DoorStairsFix:
CLC
LDY.w #$0000
--: LDX.w #$00FF ; loop through floor layout starting from the bottom right
-: LDA $EA00,X ; read node contents
BEQ + ; always skip empty nodes
BCC ++ ; 1st pass: skip all blocked nodes (would cause door stairs or rare stairs)
LDA $E9F0,X ; 2nd pass: skip only if the one above is also blocked (would cause door stairs)
++: BMI +
INY ; count usable nodes
+: DEX
BPL -
TYA
BNE ++ ; all nodes blocked?
SEC ; set up 2nd, less restrictive pass
BRA --
++: JSL $8082C7 ; advance RNG
STA $00211B
TDC
STA $00211B ; M7A; first factor = random number from 0 to 255
TYA
STA $00211C ; M7B; second factor = number of possible stair positions
LDA $002135 ; MPYM; calculate random number from 0 to number of possible stair positions - 1
TAY
LDX.w #$00FF ; loop through floor layout starting from the bottom right
-: LDA $EA00,X ; read node contents
BEQ + ; always skip empty nodes
BCC ++ ; if 1st pass was sufficient: skip all blocked nodes (prevent door stairs and rare stairs)
LDA $E9F0,X ; if 2nd pass was needed: skip only if the one above is also blocked (prevent door stairs)
++: BMI +
DEY ; count down to locate the (Y+1)th usable node
BMI ++
+: DEX
BPL -
++: TXA ; return selected stair node coordinate
RTL
; equipment text fix
pushpc
org $81F2E3

View File

@ -76,7 +76,7 @@ Your Party Leader will hold up the item they received when not in a fight or in
###### Bug fixes:
- Vanilla game bugs that could result in softlocks or save file corruption have been fixed
- Vanilla game bugs that could result in anomalous floors, softlocks, or save file corruption have been fixed
- (optional) Bugfix for the algorithm that determines the item pool for red chest gear. Enabling this allows the cave to
generate shields, headgear, rings, and jewels in red chests even after floor B9
- (optional) Bugfix for the outlandish cravings of capsule monsters in the US version. Enabling this makes feeding work