Merge branch 'OWMain' into overworld_kara

This commit is contained in:
2023-09-04 15:03:18 -05:00
38 changed files with 1581 additions and 466 deletions

View File

@@ -0,0 +1,51 @@
pushpc
org $9E9463
JSL CheckKholdShellCoordinates
BCC Sprite_A3_KholdstareShell_link_not_close
BRA Sprite_A3_KholdstareShell_link_close
NOP #13
Sprite_A3_KholdstareShell_link_close = $9E9478
Sprite_A3_KholdstareShell_link_not_close = $9E9480
pullpc
CheckKholdShellCoordinates:
LDA.w $0D30, X
XBA
LDA.w $0D10, X ; full 16 bit X coordinate of sprite
REP #$21
SBC.w #$0020
CMP.b $22
BCS .not_colliding
ADC.w #$0040
CMP.b $22
BCC .not_colliding
SEP #$20
LDA.w $0D20, X
XBA
LDA.w $0D00, X ; full 16 bit Y coordinate of sprite
REP #$21
SBC.w #$001F ; could go to 27 and let link squeeze in at Lanmo 2 (please adjust the following one)
CMP.b $20
BCS .not_colliding
ADC.w #$0037
CMP.b $20
BCC .not_colliding
SEP #$20 ; collision detected
SEC
RTL
.not_colliding
SEP #$30
CLC
RTL

View File

@@ -41,6 +41,11 @@ DRScroll:
db 0
OffsetTable:
dw -8, 8
org $A78010
DRVersionInfo:
dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000
org $A78020
incsrc normal.asm
incsrc scroll.asm
@@ -53,6 +58,7 @@ incsrc math.asm
incsrc hudadditions.asm
incsrc dr_lobby.asm
incsrc entrance_fixes.asm
incsrc bugfix/kholdstare_shell_collision.asm
warnpc $A79C00
incsrc doortables.asm

View File

@@ -693,4 +693,6 @@ dw $ffff
SanctuaryDarkWorld:
dw $ffff
OldManDarkWorld:
dw $ffff
dw $ffff
OldManRetrievalWorld:
dw $0000

View File

@@ -44,6 +44,8 @@ org $8293d1 ; <- 113d1 - Bank02.asm : 3683 (ADD $20 : STA $20 BRANCH_IOTA)
jsl StraightStairsFix : nop
org $829396 ; <- 11396 - Bank02.asm : 3641 (LDA $01C322, X)
jsl StraightStairLayerFix
org $82c06d ; <- Bank02.asm : 9874 (LDX $0418, CMP.b #$02)
jsl DoorToStraight : nop
org $82c092 ; STA $0020, Y : LDX #$00
jsl DoorToInroom : nop
org $82c0f8 ; CMP $02C034, X
@@ -190,10 +192,9 @@ JSL.l Underworld_DoorDown_Entry : CPX #$FF
BEQ + : db $80, $1C ; BRA $028B04
NOP #6 : +
org $82C3F2 ; <- Bank02.asm:10521 Unused call
Underworld_DoorDown_Call:
org $82C3F3
dw $8AD9 ; address of Bank02.asm:2085
org $82FD00 ; unreachable code
Underworld_SetBossOrSancMusicUponEntry_long:
JSR Underworld_SetBossOrSancMusicUponEntry : RTL
org $81AA90
JSL BigKeyDoorCheck : NOP
@@ -212,9 +213,16 @@ bcs .normal
rts
.normal
; fixes an issue with edges -> normal doors (bombable, dashable, keydoor)
org $82C06A
JSL TransitionCalculateLanding_Fix : NOP #2
org $82C157
JSL AlwaysPushThroughFDoors
; Modified from OWR - will need to remove once merged
; org $85AF75
; Sprite_6C_MirrorPortal:
; JSL FixOvalFadeOutMirror : NOP #2 ; LDA $7EF3CA : BNE $05AFDF
; org $85AFDF
; Sprite_6C_MirrorPortal_missing_mirror:
org $80E766
JML ConditionalLoadCommonSprites_Do3To4Low : NOP #2
LoadCommonSprites_Prep3To4Low:

View File

@@ -1,9 +1,7 @@
; defines
; Ram usage
EdgeToNormalFlag = $7E1200
HorzEdge:
LDA.b #$00 : STA.l EdgeToNormalFlag
cpy #$ff : beq +
jsr DetectWestEdge : ldy #$02 : bra ++
+ jsr DetectEastEdge
@@ -18,7 +16,6 @@ HorzEdge:
+ clc : rts
VertEdge:
LDA.b #$00 : STA.l EdgeToNormalFlag
cpy #$ff : beq +
jsr DetectNorthEdge : bra ++
+ jsr DetectSouthEdge
@@ -62,7 +59,6 @@ LoadEdgeRoomVert:
lda $04 : and #$80 : bne .edge
lda $04 : sta $01 ; load up flags in $01
and #$03 : cmp #$03 : beq .inroom
LDA.b #$01 : STA.l EdgeToNormalFlag
ldy #$01 : jsr ShiftVariablesMainDir
jsr PrepScrollToNormal
bra .scroll
@@ -302,22 +298,6 @@ DetectEastEdge:
ldx #$08
.end txa : rts
TransitionCalculateLanding_Fix:
LDA.l EdgeToNormalFlag : BEQ +
LDX.w $0418 : CPX.b #$01 : BNE +
LDA.b $20 : SBC #$08 : STA.b $20
+ PHK : PEA.w .jslrtsreturn-1
PEA.w $02802C
JML CalculateTransitionLanding
.jslrtsreturn
LDX.w $0418 : CPX.b #$01 : BNE .zero ; the LDX is vanilla and needs to always run
LDA.l EdgeToNormalFlag : BEQ +
LDA.b $20 : ADC #$08 : STA.b $20
.zero LDA.b #$00 : STA.l EdgeToNormalFlag
+ JSL DoorToStraight
RTL
AlwaysPushThroughFDoors:
PHA : AND.b #$F0 : CMP.b #$F0 : BNE +
PLA : RTL

View File

@@ -12,9 +12,17 @@
; 2) Draw over what vanilla just drew
; 3) Hijack the door tile type routine
; and replace the vanilla value with that of solid collision
; For door dection free RAM at $19EE-$19FF has been co-opted to door each drawn doors position and type bytes
; 19EE is for the "current" door for the IdentifyBlockedEntrance routine
; The array at 19F0 is for the collision routine to retrieve that information as it is no longer
; available by that point
;===================================================================================================
pushpc
org $01B0E6
JSL StoreDoorInfo
org $01892F
DoorDrawJankMove:
JML PrepDoorDraw
@@ -30,9 +38,17 @@ warnpc $018939
org $01BF43
JSL AdjustEscapeDoorCollision
org $01C132 ; ADC.w #$0040 : TAX : LDA.b $00
JSL AdjustEscapeDoorCollision_LowEntrance : NOP #2
pullpc
;===================================================================================================
StoreDoorInfo:
STA.w $1980,X
LDA.b $00 : STA.w $19F0,X
TXA
RTL
PrepDoorDraw:
; first off, we need this routine to return to our jank hook
@@ -43,6 +59,8 @@ PrepDoorDraw:
; Much easier to just tell you to look at $01890D in the disassembly
; and you should understand the vanilla program flow we need to reject
PEA.w DoorDrawJankMove_return-1
LDA.b $00
STA.w $19EE ; for current routine
; copy vanilla code (but fast rom)
LDA.l $8186F0,X
@@ -103,6 +121,9 @@ AdjustEscapeDoorGraphics:
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$104,X
JSR IdentifySwampEntrance
BCS .fix_swamp_entrance_alternate
; the state of the A, X, and Y registers is irrelevant when we exit
; they're all subsequently loaded with new values
RTL
@@ -133,29 +154,18 @@ AdjustEscapeDoorGraphics:
STA.l $7E2000+$102,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$104,X
RTL
.fix_swamp_entrance
LDY.w $0460 ; get door index
LDX.w $19A0-2,Y ; get tilemap index
; row 0
LDA.w #$9DfC
STA.l $7E2000+$000,X
STA.l $7E2000+$002,X
STA.l $7E2000+$004,X
STA.l $7E2000+$006,X
; row 1
; row 1 - outer section
LDA.w #$0908
STA.l $7E2000+$080,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$086,X
LDA.w #$14E8
STA.l $7E2000+$082,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$084,X
; row 2
LDA.w #$0918
STA.l $7E2000+$100,X
@@ -167,6 +177,20 @@ AdjustEscapeDoorGraphics:
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$104,X
.fix_swamp_entrance_alternate
; row 0
LDA.w #$9DFC
STA.l $7E2000+$000,X
STA.l $7E2000+$002,X
STA.l $7E2000+$004,X
STA.l $7E2000+$006,X
; row 1 - mid section
LDA.w #$14E8
STA.l $7E2000+$082,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$084,X
; row 3
LDA.w #$A82C
STA.l $7E2000+$180,X
@@ -210,15 +234,15 @@ BlockedEntrance:
AdjustEscapeDoorCollision:
LSR ; vanilla shift
AdjustEscapeDoorCollisionShared:
; save our parameters
; but one or both of these may not be necessary depending on how you detect these doors
; all that matters is that after identifying blockage, we have:
; Y is the same as what we entered with
; X has A>>1, for whatever A entered with
PHA
LDA.w $1980, Y ; grab door info (type)
AND.w #$00FF
STA.b $0A ; store in temporary variable
LDA.w $19F0, Y ; grab door info (type, position)
STA.w $19EE ; store in temporary variable
JSR IdentifyBlockedEntrance
PLX ; this is a TAX in vanilla, just have X pull A instead
@@ -235,11 +259,14 @@ AdjustEscapeDoorCollision:
RTL
AdjustEscapeDoorCollision_LowEntrance:
ADC.w #$0040 ; vanilla add
JMP AdjustEscapeDoorCollisionShared
;===================================================================================================
; Enter with:
; $0A containing the door information: position and type bytes
; which should be from $1980, Y or [$B7], Y depending on where in the door process we are
; $19EE containing the door information: position and type bytes
; Exit with:
; carry clear - leave door alone
; carry set - block door
@@ -262,9 +289,8 @@ IdentifyBlockedEntrance:
- INX #2
LDA.l RemoveRainDoorsRoom, X : CMP.w #$FFFF : BEQ .leave_alone
CMP $A0 : BNE -
LDA.b $0A
CMP.w #$000A : BCC .continue
CMP.w #$0014 : BCS .continue
LDA.l RainDoorMatch, X
CMP.w $19EE : BNE .leave_alone
BRA .block_door
.continue
BRA -

View File

@@ -92,4 +92,13 @@ OverridePaletteHeader:
lda.l PaletteTable, x
iny : rtl
+ rep #$20 : iny : lda [$0D], Y ; what we wrote over
rtl
rtl
Sprite_ConditionalPrepOAMCoord:
LDA.w $0E20,X : CMP.b #$62 : BNE .notMasterSword
LDA.w $0D90,X : BNE .specialCutscene
.notMasterSword
JML Sprite_PrepOAMCoordLong ; what we wrote over
.specialCutscene
SEC ; this prevents MasterSword sprite from drawing if it is a special cutscene
RTL

View File

@@ -16,7 +16,7 @@ HudAdditions:
+ JSL HexToDec_fast
.skip
LDA #$207F : STA !GOAL_DRAW_ADDRESS+2 : STA !GOAL_DRAW_ADDRESS+4
PLA : PHA : CMP.w #100 : !BLT +
LDA.b 1,S : CMP.w #100 : !BLT +
LDX.b $05 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit
+ PLA : CMP.w #10 : !BLT +
LDX.b $06 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit

View File

@@ -1,6 +1,6 @@
WarpLeft:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $20 : ldx $aa
jsr CalcIndex
!add #$06 : ldy #$01 ; offsets in A, Y
@@ -11,7 +11,7 @@ WarpLeft:
WarpRight:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $20 : ldx $aa
jsr CalcIndex
!add #$12 : ldy #$ff ; offsets in A, Y
@@ -22,7 +22,7 @@ WarpRight:
WarpUp:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $22 : ldx $a9
jsr CalcIndex
ldy #$02 ; offsets in A, Y
@@ -40,7 +40,7 @@ endmacro
WarpDown:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $22 : ldx $a9
jsr CalcIndex
!add #$0c : ldy #$ff ; offsets in A, Y
@@ -79,6 +79,14 @@ Cleanup:
lda $ef
rts
; carry set if cave, clear otherwise
CheckIfCave:
REP #$30
LDA.b $A2 : CMP.w #$00E1 : BCS .invalid
SEP #$30 : CLC : RTS
.invalid
SEP #$30 : SEC : RTS
;A needs be to the low coordinate, x needs to be either 0 for left,upper or non-zero for right,down
; This sets A (00,02,04) and stores half that at $04 for later use, (src door)
CalcIndex: ; A->low byte of Link's Coord, X-> Link's quadrant, DoorOffset x 2 -> A, DoorOffset -> $04 (vert/horz agnostic)
@@ -364,8 +372,7 @@ DoorToStraight:
lda $a0 : cmp #$51 : bne .skip
lda #$04 : sta $4e
.skip pla
; the ldx $0418 is now taken care of by TransitionCalculateLanding_Fix
.end cmp #$02 ;what we wrote over
.end LDX.w $0418 : CMP.b #$02 ; what we wrote over
rtl
}
@@ -405,7 +412,7 @@ StraightStairsTrapDoor:
.animateTraps
lda #$05 : sta $11
inc $0468 : stz $068e : stz $0690
++ JSL Underworld_DoorDown_Call : rtl
++ JML Underworld_SetBossOrSancMusicUponEntry_long
+ JML Dungeon_ApproachFixedColor ; what we wrote over
}
@@ -426,7 +433,7 @@ HandleSpecialDoorLanding: {
HandleIncomingDoorState:
PHA
LDA.l DRMode : BEQ .noDoor
PLA : PHA : AND.b #$FA : CMP.b #$80 : bne .noDoor
LDA.b 1,S : AND.b #$FA : CMP.b #$80 : bne .noDoor
.setDoorState
LDA.w $0418 : AND.b #$02 : BNE + : INC
@@ -434,7 +441,7 @@ HandleSpecialDoorLanding: {
.noDoor
PLA
CMP #$34 : bne + ; inroom stairs
PHA : LDA #$26 : STA $045E : PLA
CMP.b #$34 : BNE + ; inroom stairs
PHA : LDA.b #$26 : STA.w $045E : PLA
+ RTL
}

View File

@@ -123,9 +123,18 @@ BlindZeldaDespawnFix:
PLA : PLA : PEA.w SpritePrep_BlindMaiden_despawn_follower-1 : RTL
+ PLA : PLA : PEA.w SpritePrep_BlindMaiden_kill_the_girl-1 : RTL
BigKeyDoorCheck:
CPY.w #$001E : BNE + ; skip if it isn't a BK door
LDA.l DRFlags : AND #$0400 : BNE + ; skip if the flag is set - bk doors can be double-sided
PLA : PEA.w RoomDraw_OneSidedShutters_South_onesided_shutter_or_big_key_door-1
+ LDA.w #$0000 : RTL
; FixOvalFadeOutMirror:
; LDA.b $10 : CMP.b #$0F : BEQ .skip_activation
; LDA.l InvertedMode : BNE +
; LDA.l CurrentWorld : BNE .skip_activation
; RTL
; + LDA.l CurrentWorld : BEQ .skip_activation
; RTL
; .skip_activation
; PLA : PLA : PLA : JML Sprite_6C_MirrorPortal_missing_mirror

View File

@@ -1,24 +1,28 @@
RecordStairType: {
pha
lda.l DRMode : beq .norm
lda $040c : cmp #$ff : beq .norm
REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .norm
CMP #$00DF : BEQ .norm
SEP #$30
lda $0e
cmp #$25 : bcc ++ ; don't record straight staircases
sta $045e
++ pla : bra +
.norm pla : sta $a0
.norm SEP #$30 : pla : sta $a0
+ lda $063d, x
rtl
}
SpiralWarp: {
lda.l DRMode : beq .abort ; abort if not DR
lda $040c : cmp.b #$ff : beq .abort ; abort if not in dungeon
REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .abort
CMP #$00DF : BEQ .abort
SEP #$30
lda $045e : cmp #$5e : beq .gtg ; abort if not spiral - intended room is in A!
cmp #$5f : beq .gtg
cmp #$26 : beq .inroom
.abort
stz $045e : lda $a2 : and #$0f : rtl ; clear,run hijacked code and get out
SEP #$30 : stz $045e : lda $a2 : and.b #$0f : rtl ; clear,run hijacked code and get out
.inroom
jsr InroomStairsWarp
lda $a2 : and #$0f ; this is the code we are hijacking
@@ -97,6 +101,11 @@ StairCleanup: {
rts
}
LookupSpiralOffset_long:
PHB : PHK : PLB
JSR LookupSpiralOffset
PLB : RTL
;Sets the offset in A
LookupSpiralOffset: {
;where link currently is in $a2: quad in a8 & #$03