KDL3: Version 2.0.0 (#3323)

* initial work on procedure patch

* more flexibility

load default procedure for version 5 patches
add args for procedure
add default extension for tokens and bsdiff
allow specifying additional required extensions for generation

* pushing current changes to go fix tloz bug

* move tokens into a separate inheritable class

* forgot the commit to remove token from ProcedurePatch

* further cleaning from bad commit

* start on docstrings

* further work on docstrings and typing

* improve docstrings

* fix incorrect docstring

* cleanup

* clean defaults and docstring

* define interface that has only the bare minimum required
for `Patch.create_rom_file`

* change to dictionary.get

* remove unnecessary if statement

* update to explicitly check for procedure, restore compatible version and manual override

* Update Files.py

* remove struct uses

* Update Rom.py

* convert KDL3 to APPP

* change class variables to instance variables

* Update worlds/Files.py

Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>

* Update worlds/Files.py

Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>

* move required_extensions to tuple

* fix missing tuple ellipsis

* fix classvar mixup

* rename tokens to _tokens. use hasattr

* type hint cleanup

* Update Files.py

* initial base for local items, need to finish

* coo not clean

* handle local items for real, appp cleanup

* actually make bosses send their locations

* fix cloudy park 4 rule, zero deathlink message

* remove redundant door_shuffle bool

when generic ER gets in, this whole function gets rewritten. So just clean it a little now.

* properly fix deathlink messages, fix fill error

* update docs

* add prefill items

* fix kine fill error

* Update Rom.py

* Update Files.py

* mypy and softlock fix

* Update Gifting.py

* mypy phase 1

* fix rare async client bug

* Update __init__.py

* typing cleanup

* fix stone softlock

because of the way Kine's Stone works, you can't clear the stone blocks before clearing the burning blocks, so we have to bring Burning from outside

* Update Rom.py

* Add option groups

* Rename to lowercase

* finish rename

* whoops broke the world

* fix animal duplication bug

* overhaul filler generation

* add Miku flavor

* Update gifting.py

* fix issues related to max_hs increase

* Update test_locations.py

* fix boss shuffle not working if level shuffle is disabled

* fix bleeding default levels

* Update options.py

* thought this would print seed

* yay bad merges

* forgot options too

* yeah lets just break generation while at it

* this is probably a problem

* cap required heart stars

* Revert "cap required heart stars"

This reverts commit 759efd3e2b14ec2855082de041ac989cb9c5d500.

* fix duplication removal placement, deprecated test option

* forgot that we need to account for what we place

* move location ids

* rewrite trap handling

* further stage renumber fixes

* forgot one more

* basic UT support

* fix local heart star checks

* fix pattern

---------

Co-authored-by: beauxq <beauxq@yahoo.com>
Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
This commit is contained in:
Silvris
2024-08-31 06:15:00 -05:00
committed by GitHub
parent b1be597451
commit 920cffda2d
28 changed files with 2420 additions and 2056 deletions

Binary file not shown.

View File

@@ -58,6 +58,10 @@ org $01AFC8
org $01B013
SEC ; Remove Dedede Bad Ending
org $01B050
JSL HookBossPurify
NOP
org $02B7B0 ; Zero unlock
LDA $80A0
CMP #$0001
@@ -160,7 +164,6 @@ CopyAbilityAnimalOverride:
STA $39DF, X
RTL
org $079A00
HeartStarCheck:
TXA
CMP #$0000 ; is this level 1
@@ -201,7 +204,6 @@ HeartStarCheck:
SEC
RTL
org $079A80
OpenWorldUnlock:
PHX
LDX $900E ; Are we on open world?
@@ -224,7 +226,6 @@ OpenWorldUnlock:
PLX
RTL
org $079B00
MainLoopHook:
STA $D4
INC $3524
@@ -239,16 +240,18 @@ MainLoopHook:
BEQ .Return ; return if we are
LDA $5541 ; gooey status
BPL .Slowness ; gooey is already spawned
LDA $39D1 ; is kirby alive?
BEQ .Slowness ; branch if he isn't
; maybe BMI here too?
LDA $8080
CMP #$0000 ; did we get a gooey trap
BEQ .Slowness ; branch if we did not
JSL GooeySpawn
STZ $8080
DEC $8080
.Slowness:
LDA $8082 ; slowness
BEQ .Eject ; are we under the effects of a slowness trap
DEC
STA $8082 ; dec by 1 each frame
DEC $8082 ; dec by 1 each frame
.Eject:
PHX
PHY
@@ -258,14 +261,13 @@ MainLoopHook:
BEQ .PullVars ; branch if we haven't received eject
LDA #$2000 ; select button press
STA $60C1 ; write to controller mirror
STZ $8084
DEC $8084
.PullVars:
PLY
PLX
.Return:
RTL
org $079B80
HeartStarGraphicFix:
LDA #$0000
PHX
@@ -288,7 +290,7 @@ HeartStarGraphicFix:
ASL
TAX
LDA $07D080, X ; table of original stage number
CMP #$0003 ; is the current stage a minigame stage?
CMP #$0002 ; is the current stage a minigame stage?
BEQ .ReturnTrue ; branch if so
CLC
BRA .Return
@@ -299,7 +301,6 @@ HeartStarGraphicFix:
PLX
RTL
org $079BF0
ParseItemQueue:
; Local item queue parsing
NOP
@@ -336,8 +337,6 @@ ParseItemQueue:
AND #$000F
ASL
TAY
LDA $8080,Y
BNE .LoopCheck
JSL .ApplyNegative
RTL
.ApplyAbility:
@@ -418,35 +417,73 @@ ParseItemQueue:
CPY #$0005
BCS .PlayNone
LDA $8080,Y
BNE .Return
CPY #$0002
BNE .Increment
CLC
LDA #$0384
ADC $8080, Y
BVC .PlayNegative
LDA #$FFFF
.PlayNegative:
STA $8080,Y
LDA #$00A7
BRA .PlaySFXLong
.Increment:
INC
STA $8080, Y
BRA .PlayNegative
.PlayNone:
LDA #$0000
BRA .PlaySFXLong
org $079D00
AnimalFriendSpawn:
PHA
CPX #$0002 ; is this an animal friend?
BNE .Return
XBA
PHA
PHX
PHA
LDX #$0000
.CheckSpawned:
LDA $05CA, X
BNE .Continue
LDA #$0002
CMP $074A, X
BNE .ContinueCheck
PLA
PHA
XBA
CMP $07CA, X
BEQ .AlreadySpawned
.ContinueCheck:
INX
INX
BRA .CheckSpawned
.Continue:
PLA
PLX
ASL
TAY
PLA
INC
CMP $8000, Y ; do we have this animal friend
BEQ .Return ; we have this animal friend
.False:
INX
.Return:
PLY
LDA #$9999
RTL
.AlreadySpawned:
PLA
PLX
ASL
TAY
PLA
BRA .False
org $079E00
WriteBWRAM:
LDY #$6001 ;starting addr
LDA #$1FFE ;bytes to write
@@ -479,7 +516,6 @@ WriteBWRAM:
.Return:
RTL
org $079E80
ConsumableSet:
PHA
PHX
@@ -507,7 +543,6 @@ ConsumableSet:
ASL
TAX
LDA $07D020, X ; current stage
DEC
ASL #6
TAX
PLA
@@ -519,8 +554,16 @@ ConsumableSet:
BRA .LoopHead ; return to loop head
.ApplyCheck:
LDA $A000, X ; consumables index
PHA
ORA #$0001
STA $A000, X
PLA
AND #$00FF
BNE .Return
TXA
ORA #$1000
JSL ApplyLocalCheck
.Return:
PLY
PLX
PLA
@@ -528,7 +571,6 @@ ConsumableSet:
AND #$00FF
RTL
org $079F00
NormalGoalSet:
PHX
LDA $07D012
@@ -549,7 +591,6 @@ NormalGoalSet:
STA $5AC1 ; cutscene
RTL
org $079F80
FinalIcebergFix:
PHX
PHY
@@ -572,7 +613,7 @@ FinalIcebergFix:
ASL
TAX
LDA $07D020, X
CMP #$001E
CMP #$001D
BEQ .ReturnTrue
CLC
BRA .Return
@@ -583,7 +624,6 @@ FinalIcebergFix:
PLX
RTL
org $07A000
StrictBosses:
PHX
LDA $901E ; Do we have strict bosses enabled?
@@ -610,7 +650,6 @@ StrictBosses:
LDA $53CD
RTL
org $07A030
NintenHalken:
LDX #$0005
.Halken:
@@ -628,7 +667,6 @@ NintenHalken:
LDA #$0001
RTL
org $07A080
StageCompleteSet:
PHX
LDA $5AC1 ; completed stage cutscene
@@ -656,9 +694,17 @@ StageCompleteSet:
ASL
TAX
LDA $9020, X ; load the stage we completed
DEC
ASL
TAX
PHX
LDA $8200, X
AND #$00FF
BNE .ApplyClear
TXA
LSR
JSL ApplyLocalCheck
.ApplyClear:
PLX
LDA #$0001
ORA $8200, X
STA $8200, X
@@ -668,7 +714,6 @@ StageCompleteSet:
CMP $53CB
RTL
org $07A100
OpenWorldBossUnlock:
PHX
PHY
@@ -699,7 +744,6 @@ OpenWorldBossUnlock:
.LoopStage:
PLX
LDY $9020, X ; get stage id
DEY
INX
INX
PHA
@@ -732,7 +776,6 @@ OpenWorldBossUnlock:
PLX
RTL
org $07A180
GooeySpawn:
PHY
PHX
@@ -768,7 +811,6 @@ GooeySpawn:
PLY
RTL
org $07A200
SpeedTrap:
PHX
LDX $8082 ; do we have slowness
@@ -780,7 +822,6 @@ SpeedTrap:
EOR #$FFFF
RTL
org $07A280
HeartStarVisual:
CPX #$0000
BEQ .SkipInx
@@ -844,7 +885,6 @@ HeartStarVisual:
.Return:
RTL
org $07A300
LoadFont:
JSL $00D29F ; play sfx
PHX
@@ -915,7 +955,6 @@ LoadFont:
PLX
RTL
org $07A380
HeartStarVisual2:
LDA #$2C80
STA $0000, Y
@@ -1029,14 +1068,12 @@ HeartStarVisual2:
STA $0000, Y
RTL
org $07A480
HeartStarSelectFix:
PHX
TXA
ASL
TAX
LDA $9020, X
DEC
TAX
.LoopHead:
CMP #$0006
@@ -1051,15 +1088,31 @@ HeartStarSelectFix:
AND #$00FF
RTL
org $07A500
HeartStarCutsceneFix:
TAX
LDA $53D3
DEC
STA $5AC3
LDA $53A7, X
AND #$00FF
BNE .Return
PHX
TXA
.Loop:
CMP #$0007
BCC .Continue
SEC
SBC #$0007
DEX
BRA .Loop
.Continue:
TXA
ORA #$0100
JSL ApplyLocalCheck
PLX
.Return
RTL
org $07A510
GiftGiving:
CMP #$0008
.This:
@@ -1075,7 +1128,6 @@ GiftGiving:
PLX
JML $CABC18
org $07A550
PauseMenu:
JSL $00D29F
PHX
@@ -1136,7 +1188,6 @@ PauseMenu:
PLX
RTL
org $07A600
StarsSet:
PHA
PHX
@@ -1166,7 +1217,6 @@ StarsSet:
ASL
TAX
LDA $07D020, X
DEC
ASL
ASL
ASL
@@ -1183,8 +1233,15 @@ StarsSet:
BRA .2LoopHead
.2LoopEnd:
LDA $B000, X
PHA
ORA #$0001
STA $B000, X
PLA
AND #$00FF
BNE .Return
TXA
ORA #$2000
JSL ApplyLocalCheck
.Return:
PLY
PLX
@@ -1199,6 +1256,48 @@ StarsSet:
STA $39D7
BRA .Return
ApplyLocalCheck:
; args: A-address of check following $08B000
TAX
LDA $09B000, X
AND #$00FF
TAY
LDX #$0000
.Loop:
LDA $C000, X
BEQ .Apply
INX
INX
CPX #$0010
BCC .Loop
BRA .Return ; this is dangerous, could lose a check here
.Apply:
TYA
STA $C000, X
.Return:
RTL
HookBossPurify:
ORA $B0
STA $53D5
LDA $B0
LDX #$0000
LSR
.Loop:
BIT #$0001
BNE .Apply
LSR
LSR
INX
CPX #$0005
BCS .Return
BRA .Loop
.Apply:
TXA
ORA #$0200
JSL ApplyLocalCheck
.Return:
RTL
org $07C000
db "KDL3_BASEPATCH_ARCHI"
@@ -1234,4 +1333,7 @@ org $07E040
db $3A, $01
db $3B, $05
db $3C, $05
db $3D, $05
db $3D, $05
org $07F000
incbin "APPauseIcons.dat"