Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions worlds/lufia2ac/basepatch/basepatch.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified worlds/lufia2ac/basepatch/basepatch.bsdiff4
Binary file not shown.
2 changes: 1 addition & 1 deletion worlds/lufia2ac/docs/en_Lufia II Ancient Cave.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down