Merged in DR v1.4.1.6

This commit is contained in:
codemann8
2024-02-23 10:57:24 -06:00
235 changed files with 30100 additions and 17937 deletions

View File

@@ -13,31 +13,31 @@ pullpc
CheckKholdShellCoordinates:
LDA.w $0D30, X
LDA.w SpritePosXHigh, X
XBA
LDA.w $0D10, X ; full 16 bit X coordinate of sprite
LDA.w SpritePosXLow, X ; full 16 bit X coordinate of sprite
REP #$21
REP #$21 ; carry is guaranteed clear
SBC.w #$0020
CMP.b $22
CMP.b LinkPosX
BCS .not_colliding
ADC.w #$0040
CMP.b $22
ADC.w #$0040 ; carry is guaranteed clear
CMP.b LinkPosX
BCC .not_colliding
SEP #$20
LDA.w $0D20, X
LDA.w SpritePosYHigh, X
XBA
LDA.w $0D00, X ; full 16 bit Y coordinate of sprite
LDA.w SpritePosYLow, 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
REP #$21 ; carry is guaranteed clear
SBC.w #$001F ; could go to 27 and still let link squeeze in
CMP.b LinkPosY
BCS .not_colliding
ADC.w #$0037
CMP.b $20
ADC.w #$0037 ; carry is guaranteed clear
CMP.b LinkPosY
BCC .not_colliding
SEP #$20 ; collision detected

View File

@@ -593,8 +593,9 @@ CompassBossIndicator:
dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000
TotalKeys: ;27f020
db $04, $04, $02, $04, $04, $06, $06, $06, $05, $06, $01, $03, $06, $08, $00, $00
ChestKeys: ;27f030
db $01, $01, $00, $01, $02, $01, $06, $03, $03, $02, $01, $01, $04, $04, $00, $00
skip $10
;ChestKeys: ;27f030 - moved to B0F010
;db $01, $01, $00, $01, $02, $01, $06, $03, $03, $02, $01, $01, $04, $04, $00, $00
BigKeyStatus: ;27f040 (status 2 indicate BnC guard)
dw $0002, $0002, $0001, $0001, $0000, $0001, $0001, $0001, $0001, $0001, $0001, $0001, $0001, $0001, $0000, $0000
DungeonReminderTable: ;27f060

View File

@@ -1,14 +1,14 @@
CheckDarkWorldSpawn:
PHP
STA $A0 : STA $048E ; what we wrote over
STA.b RoomIndex : STA.w RoomIndexMirror ; what we wrote over
JSL SetDefaultWorld
LDA.l LinksHouseDarkWorld : CMP.b $A0 : BEQ ++
LDA.l SanctuaryDarkWorld : CMP.b $A0 : BEQ ++
LDA.l OldManDarkWorld : CMP.b $A0 : BNE +
++ SEP #$20 : LDA CurrentWorld : EOR.b #$40 : STA CurrentWorld
LDA.l DRFlags+1 : AND #$02 : BEQ + ; skip if the flag isn't set
LDA.l LinksHouseDarkWorld : CMP.b RoomIndex : BEQ ++
LDA.l SanctuaryDarkWorld : CMP.b RoomIndex : BEQ ++
LDA.l OldManDarkWorld : CMP.b RoomIndex : BNE +
++ SEP #$20 : LDA.l CurrentWorld : EOR.b #$40 : STA.l CurrentWorld
LDA.l DRFlags+1 : AND.b #$02 : BEQ + ; skip if the flag isn't set
LDA.l MoonPearlEquipment : BNE + ; moon pearl?
LDA #$17 : STA $5D : INC $02E0
LDA #$17 : STA.b LinkState : INC.w BunnyFlag
+ PLP : RTL
SetDefaultWorld:

View File

@@ -67,7 +67,7 @@ jsl QuadrantLoadOrderAfterScroll
org $82895d ; Bank 02 line 1812 (JSL Dungeon_LoadRoom : JSL Dungeon_InitStarTileChr : JSL $00D6F9 : INC $B0)
Splicer:
jsl GfxFixer
lda $b1 : beq .done
lda.b $b1 : beq .done
rts
nop #5
.done
@@ -98,7 +98,7 @@ org $8ffd65 ;(PC: 07fd65)
Dungeon_LoadCustomTileAttr:
org $81feb0
Dungeon_ApproachFixedColor:
;org $01fec1
;org $81fec1
;Dungeon_ApproachFixedColor_variable:
;org $a0f972 ; Rando version
;LoadRoomHook:
@@ -120,7 +120,7 @@ jsl MirrorCheckOverride
org $85ef47
Sprite_HeartContainer_Override: ;sprite_heart_upgrades.asm : 96-100 (LDA $040C : CMP.b #$1A : BNE .not_in_ganons_tower)
jsl GtBossHeartCheckOverride : bcs .not_in_ganons_tower
nop : stz $0dd0, X : rts
nop : stz.w SpriteAITable, X : rts
.not_in_ganons_tower
@@ -136,7 +136,7 @@ jsl EGFixOnMirror
org $82b82a
jsl FixShopCode
org $9ddeea ; <- Bank1D.asm : 286 (JSL Sprite_LoadProperties)
org $9ddeea ; <- Bank1D.asm : 286 (JSL SpritePrep_LoadProperties)
jsl VitreousKeyReset
org $9ed024 ; f5024 sprite_guruguru_bar.asm : 27 (LDA $040C : CMP.b #$12 : INY #2
@@ -169,8 +169,8 @@ jsl CutoffEntranceRug : bra .nextTile : nop
org $8799de ; <- Bank07.asm : 4088 (LDA.b #$15 : STA $5D)
JSL StoreTempBunnyState
;
org $88c450 ; <- ancilla_receive_item.asm : 146-148 (STY $5D : STZ $02D8)
JSL RetrieveBunnyState : NOP
org $88C450 ; <- ancilla_receive_item.asm : 146-148 (STY $5D : STZ $02D8)
JSL RetrieveBunnyState : JMP.w + : NOP : +
org $82d9ce ; <- Bank02.asm : Dungeon_LoadEntrance 10829 (STA $A0 : STA $048E)
JSL CheckDarkWorldSpawn : NOP
@@ -188,7 +188,7 @@ Main_ShowTextMessage:
; Conditionally disable UW music changes in Door Rando
org $828ADB ; <- Bank02.asm:2088-2095 (LDX.b #$14 : LDA $A0 ...)
JSL.l Underworld_DoorDown_Entry : CPX #$FF
JSL Underworld_DoorDown_Entry : CPX #$FF
BEQ + : db $80, $1C ; BRA $028B04
NOP #6 : +
@@ -219,7 +219,7 @@ JSL AlwaysPushThroughFDoors
; Modified from OWR - will need to remove once merged
; org $85AF75
; Sprite_6C_MirrorPortal:
; JSL FixOvalFadeOutMirror : NOP #2 ; LDA $7EF3CA : BNE $05AFDF
; JSL FixOvalFadeOutMirror : NOP #2 ; LDA $7EF3CA : BNE $85AFDF
; org $85AFDF
; Sprite_6C_MirrorPortal_missing_mirror:

View File

@@ -2,12 +2,12 @@
; Ram usage
HorzEdge:
cpy #$ff : beq +
jsr DetectWestEdge : ldy #$02 : bra ++
cpy.b #$ff : beq +
jsr DetectWestEdge : ldy.b #$02 : bra ++
+ jsr DetectEastEdge
++ cmp #$ff : beq +
sta $00 : asl : !add $00 : tax
cpy #$ff : beq ++
sta.b Scrap00 : asl : !add.b Scrap00 : tax
cpy.b #$ff : beq ++
jsr LoadWestData : bra .main
++ jsr LoadEastData
.main
@@ -16,12 +16,12 @@ HorzEdge:
+ clc : rts
VertEdge:
cpy #$ff : beq +
cpy.b #$ff : beq +
jsr DetectNorthEdge : bra ++
+ jsr DetectSouthEdge
++ cmp #$ff : beq +
sta $00 : asl : !add $00 : tax
cpy #$ff : beq ++
++ cmp.b #$ff : beq +
sta.b Scrap00 : asl : !add.b Scrap00 : tax
cpy.b #$ff : beq ++
jsr LoadNorthData : bra .main
++ jsr LoadSouthData
.main
@@ -30,20 +30,20 @@ VertEdge:
+ clc : rts
LoadEdgeRoomHorz:
lda $03 : sta $a0
sty $06
and.b #$0f : asl a : !sub $23 : !add $06 : sta $02
lda.b Scrap03 : sta.b RoomIndex
sty.b Scrap06
and.b #$0f : asl a : !sub.b LinkPosX+1 : !add.b Scrap06 : sta.b Scrap02
ldy #$00 : jsr ShiftVariablesMainDir
lda $04 : and #$80 : bne .edge
lda $04 : sta $01 ; load up flags in $01
lda.b Scrap04 : and.b #$80 : bne .edge
lda.b Scrap04 : sta.b Scrap01 ; load up flags in $01
jsr PrepScrollToNormal
bra .scroll
.edge
lda $04 : and #$10 : beq +
lda #$01
+ sta $ee ; layer stuff
lda.b Scrap04 : and.b #$10 : beq +
lda.b #$01
+ sta.b LinkLayer ; layer stuff
jsr MathHorz
@@ -52,14 +52,14 @@ LoadEdgeRoomHorz:
rts
LoadEdgeRoomVert:
lda $03 : sta $a0
sty $06
and.b #$f0 : lsr #3 : !sub $21 : !add $06 : sta $02
lda.b Scrap03 : sta.b RoomIndex
sty.b Scrap06
and.b #$f0 : lsr #3 : !sub.b LinkPosY+1 : !add.b Scrap06 : sta.b Scrap02
lda $04 : and #$80 : bne .edge
lda $04 : sta $01 ; load up flags in $01
and #$03 : cmp #$03 : beq .inroom
ldy #$01 : jsr ShiftVariablesMainDir
lda.b Scrap04 : and.b #$80 : bne .edge
lda.b Scrap04 : sta.b Scrap01 ; load up flags in $01
and.b #$03 : cmp.b #$03 : beq .inroom
ldy.b #$01 : jsr ShiftVariablesMainDir
jsr PrepScrollToNormal
bra .scroll
@@ -68,13 +68,13 @@ LoadEdgeRoomVert:
rts
.edge
ldy #$01 : jsr ShiftVariablesMainDir
lda $04 : and #$10 : beq +
lda #$01
+ sta $ee ; layer stuff
ldy.b #$01 : jsr ShiftVariablesMainDir
lda.b Scrap04 : and.b #$10 : beq +
lda.b #$01
+ sta.b LinkLayer ; layer stuff
jsr MathVert
lda $03
lda.b Scrap03
.scroll
jsr ScrollX
@@ -82,220 +82,220 @@ LoadEdgeRoomVert:
MathHorz:
jsr MathStart : lda $20
jsr MathMid : and #$0040
jsr MathStart : lda.b LinkPosY
jsr MathMid : and.w #$0040
jsr MathEnd
rts
MathVert:
jsr MathStart : lda $22
jsr MathMid : and #$0020
jsr MathStart : lda.b LinkPosX
jsr MathMid : and.w #$0020
jsr MathEnd
rts
MathStart:
rep #$30
lda $08 : and #$00ff : sta $00
lda.b Scrap08 : and.w #$00ff : sta.b Scrap00
rts
MathMid:
and #$01ff : !sub $00 : and #$00ff : sta $00
and.w #$01ff : !sub.b Scrap00 : and.w #$00ff : sta.b Scrap00
; nothing should be bigger than $a0 at this point
lda $05 : and #$00f0 : lsr #4 : tax
lda MultDivInfo, x : and #$00ff : tay
lda $00 : jsr MultiplyByY : sta $02
lda.b Scrap05 : and.w #$00f0 : lsr #4 : tax
lda.w MultDivInfo, x : and.w #$00ff : tay
lda.b Scrap00 : jsr MultiplyByY : sta.b Scrap02
lda $07 : and #$00ff : jsr MultiplyByY : tax
lda.b Scrap07 : and.w #$00ff : jsr MultiplyByY : tax
lda $05 : and #$000f : tay
lda MultDivInfo, y : and #$00ff : tay
lda $02 : jsr DivideByY : sta $00
lda $0c : and #$00ff : sta $02
lda $04
lda.b Scrap05 : and.w #$000f : tay
lda.w MultDivInfo, y : and.w #$00ff : tay
lda.b Scrap02 : jsr DivideByY : sta.b Scrap00
lda.b Scrap0C : and.w #$00ff : sta.b Scrap02
lda.b Scrap04
rts
MathEnd:
beq +
lda #$0100
+ !add $02 : !add $00
sta $04
lda.w #$0100
+ !add.b Scrap02 : !add.b Scrap00
sta.b Scrap04
sep #$30
rts
; don't need midpoint of edge Link is leaving (formerly in $06 - used by dir indicator)
; don't need width of edge Link is going to (currently in $0b)
LoadNorthData:
lda NorthOpenEdge, x : sta $03 : inx ; target room
lda NorthEdgeInfo, x : sta $07 ; needed for maths - (divide by 2 anyway)
lda NorthOpenEdge, x : sta $04 : inx ; bit field
lda NorthEdgeInfo, x : sta $08 ; needed for maths
lda NorthOpenEdge, x : sta $05 ; ratio
lda $04 : jsr LoadSouthMidpoint : inx ; needed now, and for nrml transition
lda SouthEdgeInfo, x : sta $0b : inx ; probably not needed todo: remove
lda SouthEdgeInfo, x : sta $0c ; needed for maths
lda.w NorthOpenEdge, x : sta.b Scrap03 : inx ; target room
lda.w NorthEdgeInfo, x : sta.b Scrap07 ; needed for maths - (divide by 2 anyway)
lda.w NorthOpenEdge, x : sta.b Scrap04 : inx ; bit field
lda.w NorthEdgeInfo, x : sta.b Scrap08 ; needed for maths
lda.w NorthOpenEdge, x : sta.b Scrap05 ; ratio
lda.b Scrap04 : jsr LoadSouthMidpoint : inx ; needed now, and for nrml transition
lda.w SouthEdgeInfo, x : sta.b Scrap0B : inx ; probably not needed todo: remove
lda.w SouthEdgeInfo, x : sta.b Scrap0C ; needed for maths
rts
LoadSouthMidpoint:
and #$0f : sta $00 : asl : !add $00 : tax
lda SouthEdgeInfo, x : sta $0a ; needed now, and for nrml transition
and.b #$0f : sta.b Scrap00 : asl : !add.b Scrap00 : tax
lda.w SouthEdgeInfo, x : sta.b Scrap0A ; needed now, and for nrml transition
rts
LoadSouthData:
lda SouthOpenEdge, x : sta $03 : inx
lda SouthEdgeInfo, x : sta $07
lda SouthOpenEdge, x : sta $04 : inx
lda SouthEdgeInfo, x : sta $08
lda SouthOpenEdge, x : sta $05
lda $04 : jsr LoadNorthMidpoint : inx
lda NorthEdgeInfo, x : sta $0b : inx
lda NorthEdgeInfo, x : sta $0c
lda.w SouthOpenEdge, x : sta.b Scrap03 : inx
lda.w SouthEdgeInfo, x : sta.b Scrap07
lda.w SouthOpenEdge, x : sta.b Scrap04 : inx
lda.w SouthEdgeInfo, x : sta.b Scrap08
lda.w SouthOpenEdge, x : sta.b Scrap05
lda.b Scrap04 : jsr LoadNorthMidpoint : inx
lda.w NorthEdgeInfo, x : sta.b Scrap0B : inx
lda.w NorthEdgeInfo, x : sta.b Scrap0C
rts
LoadNorthMidpoint:
and #$0f : sta $00 : asl : !add $00 : tax
lda NorthEdgeInfo, x : sta $0a ; needed now, and for nrml transition
and.b #$0f : sta.b Scrap00 : asl : !add.b Scrap00 : tax
lda.w NorthEdgeInfo, x : sta.b Scrap0A ; needed now, and for nrml transition
rts
LoadWestData:
lda WestOpenEdge, x : sta $03 : inx
lda WestEdgeInfo, x : sta $07
lda WestOpenEdge, x : sta $04 : inx
lda WestEdgeInfo, x : sta $08
lda WestOpenEdge, x : sta $05
lda $04 : jsr LoadEastMidpoint : inx
lda EastEdgeInfo, x : sta $0b : inx
lda EastEdgeInfo, x : sta $0c
lda.w WestOpenEdge, x : sta.b Scrap03 : inx
lda.w WestEdgeInfo, x : sta.b Scrap07
lda.w WestOpenEdge, x : sta.b Scrap04 : inx
lda.w WestEdgeInfo, x : sta.b Scrap08
lda.w WestOpenEdge, x : sta.b Scrap05
lda.b Scrap04 : jsr LoadEastMidpoint : inx
lda.w EastEdgeInfo, x : sta.b Scrap0B : inx
lda.w EastEdgeInfo, x : sta.b Scrap0C
rts
LoadEastMidpoint:
and #$0f : sta $00 : asl : !add $00 : tax
lda EastEdgeInfo, x : sta $0a ; needed now, and for nrml transition
and.b #$0f : sta.b Scrap00 : asl : !add.b Scrap00 : tax
lda.w EastEdgeInfo, x : sta.b Scrap0A ; needed now, and for nrml transition
rts
LoadEastData:
lda EastOpenEdge, x : sta $03 : inx
lda EastEdgeInfo, x : sta $07
lda EastOpenEdge, x : sta $04 : inx
lda EastEdgeInfo, x : sta $08
lda EastOpenEdge, x : sta $05
lda $04 : jsr LoadWestMidpoint : inx
lda WestEdgeInfo, x : sta $0b : inx
lda WestEdgeInfo, x : sta $0c
lda.w EastOpenEdge, x : sta.b Scrap03 : inx
lda.w EastEdgeInfo, x : sta.b Scrap07
lda.w EastOpenEdge, x : sta.b Scrap04 : inx
lda.w EastEdgeInfo, x : sta.b Scrap08
lda.w EastOpenEdge, x : sta.b Scrap05
lda.b Scrap04 : jsr LoadWestMidpoint : inx
lda.w WestEdgeInfo, x : sta.b Scrap0B : inx
lda.w WestEdgeInfo, x : sta.b Scrap0C
LoadWestMidpoint:
and #$0f : sta $00 : asl : !add $00 : tax
lda WestEdgeInfo, x : sta $0a ; needed now, and for nrml transition
and.b #$0f : sta.b Scrap00 : asl : !add.b Scrap00 : tax
lda.w WestEdgeInfo, x : sta.b Scrap0A ; needed now, and for nrml transition
rts
DetectNorthEdge:
ldx #$ff
lda $a2
cmp #$82 : bne +
lda $22 : cmp #$50 : bcs ++
ldx #$01 : bra .end
++ ldx #$00 : bra .end
+ cmp #$83 : bne +
ldx #$02 : bra .end
+ cmp #$84 : bne +
lda $a9 : beq ++
lda $22 : cmp #$78 : bcs +++
ldx #$04 : bra .end
+++ ldx #$05 : bra .end
++ lda $22 : cmp #$78 : bcs ++
ldx #$03 : bra .end
++ ldx #$04 : bra .end
+ cmp #$85 : bne +
ldx #$06 : bra .end
+ cmp #$db : bne +
lda $a9 : beq ++
lda $22 : beq ++
ldx #$08 : bra .end
++ ldx #$07 : bra .end
+ cmp #$dc : bne .end
lda $a9 : bne ++
lda $22 : cmp #$b0 : bcs ++
ldx #$09 : bra .end
++ ldx #$0a
ldx.b #$ff
lda.b PreviousRoom
cmp.b #$82 : bne +
lda.b LinkPosX : cmp.b #$50 : bcs ++
ldx.b #$01 : bra .end
++ ldx.b #$00 : bra .end
+ cmp.b #$83 : bne +
ldx.b #$02 : bra .end
+ cmp.b #$84 : bne +
lda.b $a9 : beq ++
lda.b LinkPosX : cmp.b #$78 : bcs +++
ldx.b #$04 : bra .end
+++ ldx.b #$05 : bra .end
++ lda.b LinkPosX : cmp.b #$78 : bcs ++
ldx.b #$03 : bra .end
++ ldx.b #$04 : bra .end
+ cmp.b #$85 : bne +
ldx.b #$06 : bra .end
+ cmp.b #$db : bne +
lda.b $a9 : beq ++
lda.b LinkPosX : beq ++
ldx.b #$08 : bra .end
++ ldx.b #$07 : bra .end
+ cmp.b #$dc : bne .end
lda.b $a9 : bne ++
lda.b LinkPosX : cmp.b #$b0 : bcs ++
ldx.b #$09 : bra .end
++ ldx.b #$0a
.end txa : rts
DetectSouthEdge:
ldx #$ff
lda $a2
cmp #$72 : bne +
lda $22 : cmp #$50 : bcs ++
ldx #$01 : bra .end
++ ldx #$00 : bra .end
+ cmp #$73 : bne +
ldx #$02 : bra .end
+ cmp #$74 : bne +
lda $a9 : beq ++
lda $22 : cmp #$78 : bcs +++
ldx #$04 : bra .end
+++ ldx #$05 : bra .end
++ lda $22 : cmp #$78 : bcs ++
ldx #$03 : bra .end
++ ldx #$04 : bra .end
+ cmp #$75 : bne +
ldx #$06 : bra .end
+ cmp #$cb : bne +
lda $a9 : beq ++
lda $22 : beq ++
ldx #$08 : bra .end
++ ldx #$07 : bra .end
+ cmp #$cc : bne .end
lda $a9 : bne ++
lda $22 : cmp #$b0 : bcs ++
ldx #$09 : bra .end
++ ldx #$0a
ldx.b #$ff
lda.b PreviousRoom
cmp.b #$72 : bne +
lda.b LinkPosX : cmp.b #$50 : bcs ++
ldx.b #$01 : bra .end
++ ldx.b #$00 : bra .end
+ cmp.b #$73 : bne +
ldx.b #$02 : bra .end
+ cmp.b #$74 : bne +
lda.b $a9 : beq ++
lda.b LinkPosX : cmp.b #$78 : bcs +++
ldx.b #$04 : bra .end
+++ ldx.b #$05 : bra .end
++ lda.b LinkPosX : cmp.b #$78 : bcs ++
ldx.b #$03 : bra .end
++ ldx.b #$04 : bra .end
+ cmp.b #$75 : bne +
ldx.b #$06 : bra .end
+ cmp.b #$cb : bne +
lda.b $a9 : beq ++
lda.b LinkPosX : beq ++
ldx.b #$08 : bra .end
++ ldx.b #$07 : bra .end
+ cmp.b #$cc : bne .end
lda.b $a9 : bne ++
lda.b LinkPosX : cmp.b #$b0 : bcs ++
ldx.b #$09 : bra .end
++ ldx.b #$0a
.end txa : rts
DetectWestEdge:
ldx #$ff
lda $a2
cmp #$65 : bne +
ldx #$00 : bra .end
+ cmp #$74 : bne +
ldx #$01 : bra .end
+ cmp #$75 : bne +
ldx #$02 : bra .end
+ cmp #$82 : bne +
lda $aa : beq ++
ldx #$03 : bra .end
++ ldx #$04 : bra .end
+ cmp #$85 : bne +
ldx #$05 : bra .end
+ cmp #$cc : bne +
lda $aa : beq ++
ldx #$06 : bra .end
++ ldx #$07 : bra .end
+ cmp #$dc : bne .end
ldx #$08
ldx.b #$ff
lda.b PreviousRoom
cmp.b #$65 : bne +
ldx.b #$00 : bra .end
+ cmp.b #$74 : bne +
ldx.b #$01 : bra .end
+ cmp.b #$75 : bne +
ldx.b #$02 : bra .end
+ cmp.b #$82 : bne +
lda.b LinkQuadrantV : beq ++
ldx.b #$03 : bra .end
++ ldx.b #$04 : bra .end
+ cmp.b #$85 : bne +
ldx.b #$05 : bra .end
+ cmp.b #$cc : bne +
lda.b LinkQuadrantV : beq ++
ldx.b #$06 : bra .end
++ ldx.b #$07 : bra .end
+ cmp.b #$dc : bne .end
ldx.b #$08
.end txa : rts
DetectEastEdge:
ldx #$ff
lda $a2
cmp #$64 : bne +
ldx #$00 : bra .end
+ cmp #$73 : bne +
ldx #$01 : bra .end
+ cmp #$74 : bne +
ldx #$02 : bra .end
+ cmp #$81 : bne +
lda $aa : beq ++
ldx #$04 : bra .end
++ ldx #$03 : bra .end
+ cmp #$84 : bne +
ldx.b #$ff
lda.b PreviousRoom
cmp.b #$64 : bne +
ldx.b #$00 : bra .end
+ cmp.b #$73 : bne +
ldx.b #$01 : bra .end
+ cmp.b #$74 : bne +
ldx.b #$02 : bra .end
+ cmp.b #$81 : bne +
lda.b LinkQuadrantV : beq ++
ldx.b #$04 : bra .end
++ ldx.b #$03 : bra .end
+ cmp.b #$84 : bne +
ldx #$05 : bra .end
+ cmp #$cb : bne +
lda $aa : beq ++
ldx #$06 : bra .end
++ ldx #$07 : bra .end
+ cmp #$db : bne .end
ldx #$08
+ cmp.b #$cb : bne +
lda.b LinkQuadrantV : beq ++
ldx.b #$06 : bra .end
++ ldx.b #$07 : bra .end
+ cmp.b #$db : bne .end
ldx.b #$08
.end txa : rts
AlwaysPushThroughFDoors:

View File

@@ -20,10 +20,10 @@
;===================================================================================================
pushpc
org $01B0E6
org $81B0E6
JSL StoreDoorInfo
org $01892F
org $81892F
DoorDrawJankMove:
JML PrepDoorDraw
@@ -33,12 +33,12 @@ DoorDrawJankMove:
; we don't want to overwrite the JMP ($000E) that's already there
; Well, we could, but we don't need to
warnpc $018939
warnpc $818939
org $01BF43
org $81BF43
JSL AdjustEscapeDoorCollision
org $01C132 ; ADC.w #$0040 : TAX : LDA.b $00
org $81C132 ; ADC.w #$0040 : TAX : LDA.b $00
JSL AdjustEscapeDoorCollision_LowEntrance : NOP #2
pullpc
@@ -59,18 +59,18 @@ 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
LDA.b Scrap00
STA.w $19EE ; for current routine
; copy vanilla code (but fast rom)
LDA.l $8186F0,X
STA.b $0E
STA.b Scrap0E
LDX.b $02
LDA.b $04
LDX.b Scrap02
LDA.b Scrap04
; and to execute the jump, we'll use the JMP ($000E) we carefully avoided overwriting
JML.l $818939
JML $818939
;===================================================================================================
@@ -106,20 +106,20 @@ AdjustEscapeDoorGraphics:
; row 1
LDA.w #$8838
STA.l $7E2000+$080,X
STA.l TileMapA+$080,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$086,X
STA.l TileMapA+$086,X
; row 2
LDA.w #$8828
STA.l $7E2000+$100,X
STA.l TileMapA+$100,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$106,X
STA.l TileMapA+$106,X
LDA.w #$8829
STA.l $7E2000+$102,X
STA.l TileMapA+$102,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$104,X
STA.l TileMapA+$104,X
JSR IdentifySwampEntrance
BCS .fix_swamp_entrance_alternate
@@ -134,26 +134,26 @@ AdjustEscapeDoorGraphics:
; row 0
LDA.w #$14C4
STA.l $7E2000+$000,X ; sanity check = should calculate to 7e3bbc
STA.l TileMapA+$000,X ; sanity check = should calculate to 7e3bbc
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$006,X
STA.l TileMapA+$006,X
LDA.w #$14C5
STA.l $7E2000+$002,X
STA.l TileMapA+$002,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$004,X
STA.l TileMapA+$004,X
; row 1
LDA.w #$14E8
STA.l $7E2000+$082,X
STA.l TileMapA+$082,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$084,X
STA.l TileMapA+$084,X
; row 2
LDA.w #$14F8
STA.l $7E2000+$102,X
STA.l TileMapA+$102,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$104,X
STA.l TileMapA+$104,X
RTL
.fix_swamp_entrance
@@ -162,56 +162,56 @@ AdjustEscapeDoorGraphics:
; row 1 - outer section
LDA.w #$0908
STA.l $7E2000+$080,X
STA.l TileMapA+$080,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$086,X
STA.l TileMapA+$086,X
; row 2
LDA.w #$0918
STA.l $7E2000+$100,X
STA.l TileMapA+$100,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$106,X
STA.l TileMapA+$106,X
LDA.w #$14F8
STA.l $7E2000+$102,X
STA.l TileMapA+$102,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$104,X
STA.l TileMapA+$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
STA.l TileMapA+$000,X
STA.l TileMapA+$002,X
STA.l TileMapA+$004,X
STA.l TileMapA+$006,X
; row 1 - mid section
LDA.w #$14E8
STA.l $7E2000+$082,X
STA.l TileMapA+$082,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$084,X
STA.l TileMapA+$084,X
; row 3
LDA.w #$A82C
STA.l $7E2000+$180,X
STA.l TileMapA+$180,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$186,X
STA.l TileMapA+$186,X
LDA.w #$A82D
STA.l $7E2000+$182,X
STA.l TileMapA+$182,X
ORA.w #$4000 ; horizontally flip
STA.l $7E2000+$184,X
STA.l TileMapA+$184,X
RTL
IdentifySancEntrance:
LDA.b $A0 : CMP.w #$0012 : BNE +
LDA.b $0A : CMP.w #$0010 : BNE +
LDA.b RoomIndex : CMP.w #$0012 : BNE +
LDA.b Scrap0A : CMP.w #$0010 : BNE +
SEC : RTS
+ CLC : RTS
IdentifySwampEntrance:
LDA.b $A0 : CMP.w #$0036 : BNE +
LDA.b $0A : CMP.w #$0010 : BNE +
LDA.b RoomIndex : CMP.w #$0036 : BNE +
LDA.b Scrap0A : CMP.w #$0010 : BNE +
SEC : RTS
+ CLC : RTS
@@ -250,7 +250,7 @@ AdjustEscapeDoorCollisionShared:
BCS .block_entrance
; vanilla value
LDA.b $00
LDA.b Scrap00
RTL
@@ -274,21 +274,21 @@ IdentifyBlockedEntrance:
LDA.l ProgressIndicator : AND.w #$00FF : CMP.w #$0002 : BCS .leave_alone ; only in rain states (0 or 1)
LDA.l ProgressFlags : AND.w #$0004 : BNE .leave_alone ; zelda's been rescued
LDA.l BlockSanctuaryDoorInRain : BEQ + ;flagged
LDA.b $A0 : CMP.w #$0012 : BNE +
LDA.b RoomIndex : CMP.w #$0012 : BNE +
; we're in the sanctuary
; this code could be removed because you can't reach sanc without zelda currently
; but that's enforced in the logic, so this is to catch that case in case some mode allows it
LDA.l FollowerIndicator : AND.w #$00FF : CMP.w #$0001 : BEQ .leave_alone ; zelda is following
LDA.b $0A
LDA.b Scrap0A
CMP.w #$000A : BCC .leave_alone
CMP.w #$0014 : BCS .leave_alone
.block_door
SEC : RTS
+ LDA.l BlockCastleDoorsInRain : AND.w #$00FF : BEQ .leave_alone
LDX #$FFFE
LDX.w #$FFFE
- INX #2
LDA.l RemoveRainDoorsRoom, X : CMP.w #$FFFF : BEQ .leave_alone
CMP $A0 : BNE -
CMP.b RoomIndex : BNE -
LDA.l RainDoorMatch, X
CMP.w $19EE : BNE .leave_alone
BRA .block_door

View File

@@ -4,60 +4,60 @@ GfxFixer:
jsl LoadRoomHook ;this is the code we overwrote
jsl Dungeon_InitStarTileCh
jsl LoadTransAuxGfx_Alt
inc $b0
inc.b SubSubModule
rtl
+ lda $b1 : bne .stage2
+ lda.b $b1 : bne .stage2
jsl LoadRoomHook ; this is the rando version - let's only call this guy once - may fix star tiles and slower loads
jsl Dungeon_InitStarTileCh
jsl LoadTransAuxGfx
jsl Dungeon_LoadCustomTileAttr
jsl PrepTransAuxGfx
lda.l DRMode : cmp #$02 : bne + ; only do this in crossed mode
ldx $a0 : lda.l TilesetTable, x
cmp $0aa1 : beq + ; already eq no need to decomp
sta $0aa1
tax : lda $02802e, x : tay
lda.l DRMode : cmp.b #$02 : bne + ; only do this in crossed mode
ldx.b RoomIndex : lda.l TilesetTable, x
cmp.w $0aa1 : beq + ; already eq no need to decomp
sta.w $0aa1
tax : lda.l AnimatedTileSheets, x : tay
jsl DecompDungAnimatedTiles
+
lda #$09 : sta $17 : sta $0710
lda.b #$09 : sta.b NMIINCR : sta.w SkipOAM
jsl Palette_SpriteAux3
jsl Palette_SpriteAux2
jsl Palette_SpriteAux1
jsl Palette_DungBgMain
jsr CgramAuxToMain
inc $b1
inc.b $b1
rtl
.stage2
lda #$0a : sta $17 : sta $0710
stz $b1 : inc $b0
lda.b #$0a : sta.b NMIINCR : sta.w SkipOAM
stz.b $b1 : inc.b SubSubModule
rtl
}
FixAnimatedTiles:
LDA.L DRMode : CMP #$02 : BNE +
LDA $040C : CMP.b #$FF : BEQ +
LDA.l DRMode : CMP.b #$02 : BNE +
LDA.w DungeonID : CMP.b #$FF : BEQ +
PHX
LDX $A0 : LDA.l TilesetTable, x
CMP $0AA1 : beq ++
LDX.b RoomIndex : LDA.l TilesetTable, x
CMP.w $0AA1 : beq ++
TAX : PLA : BRA +
++
PLX
+ LDA $02802E, X ; what we wrote over
+ LDA.l AnimatedTileSheets, X ; what we wrote over
RTL
FixCloseDungeonMap:
LDA.l DRMode : CMP #$02 : BNE .vanilla
LDA $040C : BMI .vanilla
LDA.l DRMode : CMP.b #$02 : BNE .vanilla
LDA.w DungeonID : BMI .vanilla
LSR : TAX
LDA.l DungeonTilesets,x
RTL
.vanilla
LDA $7EC20E
LDA.l $7EC20E
RTL
FixWallmasterLamp:
ORA $0458
STY $1C : STA $1D : RTL ; what we wrote over
ORA.w $0458
STY.b MAINDESQ : STA.b SUBDESQ : RTL ; what we wrote over
CgramAuxToMain: ; ripped this from bank02 because it ended with rts
@@ -66,36 +66,36 @@ CgramAuxToMain: ; ripped this from bank02 because it ended with rts
ldx.b #$00
.loop
lda $7EC300, X : sta $7EC500, x
lda $7EC340, x : sta $7EC540, x
lda $7EC380, x : sta $7EC580, x
lda $7EC3C0, x : sta $7EC5C0, x
lda $7EC400, x : sta $7EC600, x
lda $7EC440, x : sta $7EC640, x
lda $7EC480, x : sta $7EC680, x
lda $7EC4C0, x : sta $7EC6C0, x
lda.l $7EC300, X : sta.l $7EC500, x
lda.l $7EC340, x : sta.l $7EC540, x
lda.l $7EC380, x : sta.l $7EC580, x
lda.l $7EC3C0, x : sta.l $7EC5C0, x
lda.l $7EC400, x : sta.l $7EC600, x
lda.l $7EC440, x : sta.l $7EC640, x
lda.l $7EC480, x : sta.l $7EC680, x
lda.l $7EC4C0, x : sta.l $7EC6C0, x
inx #2 : cpx.b #$40 : bne .loop
sep #$20
; tell NMI to upload new CGRAM data
inc $15
inc.b NMICGRAM
rts
}
OverridePaletteHeader:
lda.l DRMode : cmp #$02 : bne +
lda.l DRFlags : and #$20 : bne +
cpx #$01c2 : !bge +
lda.l DRMode : cmp.b #$02 : bne +
lda.l DRFlags : and.b #$20 : bne +
cpx.w #$01c2 : !bge +
rep #$20
txa : lsr : tax
lda.l PaletteTable, x
iny : rtl
+ rep #$20 : iny : lda [$0D], Y ; what we wrote over
+ rep #$20 : iny : lda.b [Scrap0D], Y ; what we wrote over
rtl
Sprite_ConditionalPrepOAMCoord:
LDA.w $0E20,X : CMP.b #$62 : BNE .notMasterSword
LDA.w SpriteTypeTable,X : CMP.b #$62 : BNE .notMasterSword
LDA.w $0D90,X : BNE .specialCutscene
.notMasterSword
JML Sprite_PrepOAMCoordLong ; what we wrote over

View File

@@ -1,80 +1,103 @@
!BlankTile = $207F
!SlashTile = $2830
!HyphenTile = $2405
!PTile = $296C
!CTile = $295F
!LTile = $2D68
!DTile = $2D60
!RedSquare = $345E
!BlueSquare = $2C5E
DrHudOverride:
{
jsl.l NewDrawHud
jsr HudAdditions
rtl
}
PHB
SEP #$30
LDA.b #$7E
PHA
PLB
HudAdditions:
{
SEP #$10
LDA.l DRFlags : AND #$0008 : BNE + : JMP .end_item_count : +
LDA.l TotalItemCounter : PHA : CMP #1000 : !BLT +
JSL HexToDec4Digit_fast
LDX.b $04 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS ; draw 1000's digit
BRA .skip
+ JSL HexToDec_fast
.skip
LDA #$207F : STA !GOAL_DRAW_ADDRESS+2 : STA !GOAL_DRAW_ADDRESS+4
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
+ LDX.b $07 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+6 ; draw 1's digit
LDA.w #$2830 : STA !GOAL_DRAW_ADDRESS+8 ; draw slash
LDA.l DRFlags : AND #$0100 : BNE +
LDA.l MultiClientFlagsWRAM+1 : CMP #1000 : !BLT .three_digit_goal
JSL HexToDec4Digit_fast
LDX.b $04 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+10 ; draw 1000's digit
LDX.b $05 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+12 ; draw 100's digit
LDX.b $06 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+14 ; draw 10's digit
LDX.b $07 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+16 ; draw 1's digit
BRA .end_item_count
.three_digit_goal
JSL HexToDec_fast
LDX.b $05 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit
LDX.b $06 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit
LDX.b $07 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit
BRA .end_item_count
+ LDA.w #$2405 : STA !GOAL_DRAW_ADDRESS+10 : STA !GOAL_DRAW_ADDRESS+12
STA !GOAL_DRAW_ADDRESS+14 : STA !GOAL_DRAW_ADDRESS+16
.end_item_count
DRHUD_DrawItemCounter:
; hides total for mystery seeds
LDA.l ItemCounterHUD : BEQ DRHUD_DrawIndicators
LDA.l DRFlags+1 : LSR : BCC DRHUD_DrawIndicators
REP #$30
LDY.w #!HyphenTile : STY.w HUDGoalIndicator+$0A : STY.w HUDGoalIndicator+$0C
STY.w HUDGoalIndicator+$0E : STY.w HUDGoalIndicator+$10
SEP #$30
LDX $1B : BNE + ; if outdoors
lda.l OWMode : and.w #((!FLAG_OW_CROSSED+!FLAG_OW_MIXED)<<8)+$ff : bne ++ : rts ; Skip if vanilla ow rando
++ lda CurrentHealth : and #$00ff : beq ++
lda CurrentWorld : and #$00ff : beq +++
lda #$2d60 : bra .owdisplay
+++ lda #$2d68 : bra .owdisplay
++ lda #$207f
.owdisplay sta $7ec702 : rts
+ ldx $040c : cpx #$ff : bne + : rts : + ; Skip if not in dungeon
lda.l DRMode : bne + : rts : + ; Skip if not door rando
phb : phk : plb
lda CompassField : and.l $0098c0, x : beq +
lda.w CompassBossIndicator, x : and #$00ff : cmp $a0 : bne +
lda $1a : and #$0010 : beq +
lda #$345e : sta $7ec790 : bra .next
+ lda #$207f : sta $7ec790
.next lda.w DRMode : and #$0002 : bne + : plb : rts : +
lda CurrentHealth : and #$00ff : beq +
lda.w DungeonReminderTable, x : bra .reminder
+ lda #$207f
.reminder sta $7ec702
+ lda.w DRFlags : and #$0004 : beq .restore
lda MapField : and.l $0098c0, x : beq .restore
txa : lsr : tax
DRHUD_DrawIndicators:
LDA.b IndoorsFlag : BNE .continue
JMP OWRHUD_DrawWorldIndicator
.continue
LDA.b FrameCounter : AND.b #$10 : BEQ DRHUD_EnemyDropIndicator
lda.l GenericKeys : and #$00ff : bne +
lda DungeonCollectedKeys, x : jsr ConvertToDisplay : sta $7ec7a2
lda #$2830 : sta $7ec7a4
+
lda.w ChestKeys, x : jsr ConvertToDisplay : sta $7ec7a6
; todo 4b0 no longer in use
DRHUD_BossIndicator:
LDA.l DRMode : BNE .continue
.early_exit
REP #$10
LDY.w #!BlankTile : STY.w HUDMultiIndicator
JMP DRHUD_Finished
.continue
LDA.w DungeonID : CMP.b #$1B : BCS .early_exit
.restore
plb : rts
}
SEP #$10 ; clears the high byte of X and prevents it from getting B register
TAX
REP #$30
LDY.w #!BlankTile
LDA.w CompassField : AND.l DungeonMask, x
SEP #$20
BEQ .draw_indicator
LDA.l CompassBossIndicator, x : CMP.b RoomIndex : BNE .draw_indicator
LDY.w #!RedSquare
.draw_indicator
STY.w HUDMultiIndicator
BRA DRHUD_DrawCurrentDungeonIndicator
DRHUD_EnemyDropIndicator:
REP #$30
LDA.l DRFlags : BIT.w #$0800 : BEQ +
LDA.w EnemyDropIndicator : STA.w HUDMultiIndicator
+ SEP #$20
LDA.w DungeonID : CMP.b #$1B : BCS DRHUD_Finished
SEP #$10 : TAX : REP #$10
DRHUD_DrawCurrentDungeonIndicator: ; mX
LDA.l DRMode : BIT.b #$02 : BEQ DRHUD_Finished
LDY.w #!BlankTile
LDA.w CurrentHealth : BEQ .draw_indicator
REP #$20 : LDA.l DungeonReminderTable,X : TAY
SEP #$20
.draw_indicator
STY.w HUDCurrentDungeonWorld
DRHUD_DrawKeyCounter:
LDA.l DRFlags : AND.b #$04 : BEQ DRHUD_Finished
REP #$20
LDA.w MapField : AND.l DungeonMask, X : BEQ DRHUD_Finished
TXA : LSR : TAX
LDA.l GenericKeys : AND.w #$00FF : BNE .total_only
LDA.w DungeonCollectedKeys, X : JSR ConvertToDisplay : STA.w HUDKeysObtained
LDA.w #!SlashTile : STA.w HUDKeysSlash
.total_only
LDA.l ChestKeys, x : JSR ConvertToDisplay : STA.w HUDKeysTotal
JMP DRHUD_Finished
OWRHUD_DrawWorldIndicator:
LDA.l OWMode+1 : AND.b #(!FLAG_OW_CROSSED+!FLAG_OW_MIXED) : BEQ DRHUD_Finished
REP #$10
LDY.w #!BlankTile
LDA.w CurrentHealth : BEQ .draw_indicator
LDA.w CurrentWorld : BEQ +
LDY.w #!DTile : BRA .draw_indicator
+ LDY.w #!LTile
.draw_indicator
STY.w HUDCurrentDungeonWorld ; uses same slot as DR Dungeon Indicator
DRHUD_Finished:
PLB : RTL
;===================================================================================================
;column distance for BK/Smalls
HudOffsets:
@@ -92,96 +115,94 @@ dw $0000, $0000, $0000, $0000, $000a, $000a, $000a, $0014, $000a, $0014, $0000,
DrHudDungeonItemsAdditions:
{
jsl DrawHUDDungeonItems
lda.l HUDDungeonItems : and #$ff : bne + : rtl : +
lda.l DRMode : cmp #$02 : beq + : rtl : +
lda.l HUDDungeonItems : and.b #$ff : bne + : rtl : +
lda.l DRMode : cmp.b #$02 : beq + : rtl : +
phx : phy : php
rep #$30
lda.w #$24f5 : sta $1606 : sta $1610 : sta $161a : sta $1624
sta $1644 : sta $164a : sta $1652 : sta $1662 : sta $1684 : sta $16c4
ldx #$0000
- sta $1704, x : sta $170e, x : sta $1718, x
inx #2 : cpx #$0008 : !blt -
lda.w #$24f5 : sta.w $1606 : sta.w $1610 : sta.w $161a : sta.w $1624
sta.w $1644 : sta.w $164a : sta.w $1652 : sta.w $1662 : sta.w $1684 : sta.w $16c4
ldx.w #$0000
- sta.w $1704, x : sta.w $170e, x : sta.w $1718, x
inx #2 : cpx.w #$0008 : !blt -
lda HudFlag : and.w #$0020 : beq + : JMP ++ : +
lda HUDDungeonItems : and.w #$0007 : bne + : JMP ++ : +
lda.l HudFlag : and.w #$0020 : beq + : JMP ++ : +
lda.l HUDDungeonItems : and.w #$0007 : bne + : JMP ++ : +
; bk symbols
lda.w #$2811 : sta $1606 : sta $1610 : sta $161a : sta $1624
lda.w #$2811 : sta.w $1606 : sta.w $1610 : sta.w $161a : sta.w $1624
; sm symbols
lda.w #$2810 : sta $160a : sta $1614 : sta $161e : sta $16e4
lda.w #$2810 : sta.w $160a : sta.w $1614 : sta.w $161e : sta.w $16e4
; blank out stuff
lda.w #$24f5 : sta $1724
lda.w #$24f5 : sta.w $1724
ldx #$0002
- lda #$0000 : !addl RowOffsets,x : !addl ColumnOffsets, x : tay
lda.l DungeonReminderTable, x : sta $1644, y : iny #2
lda.w #$24f5 : sta $1644, y
lda MapField : and.l $0098c0, x : beq + ; must have map
jsr BkStatus : sta $1644, y : bra .smallKey ; big key status
+ lda BigKeyField : and.l $0098c0, x : beq .smallKey
lda.w #$2826 : sta $1644, y
ldx.w #$0002
- lda.w #$0000 : !addl RowOffsets,x : !addl ColumnOffsets, x : tay
lda.l DungeonReminderTable, x : sta.w $1644, y : iny #2
lda.w #$24f5 : sta.w $1644, y
lda.l MapField : and.l DungeonMask, x : beq + ; must have map
jsr BkStatus : sta.w $1644, y : bra .smallKey ; big key status
+ lda.l BigKeyField : and.l DungeonMask, x : beq .smallKey
lda.w #$2826 : sta.w $1644, y
.smallKey
+ iny #2
cpx #$001a : bne +
tya : !add #$003c : tay
+ stx $00
cpx.w #$001a : bne +
tya : !add.w #$003c : tay
+ stx.b Scrap00
txa : lsr : tax
lda.w #$24f5 : sta $1644, y
lda.l GenericKeys : and #$00FF : bne +
lda.l DungeonKeys, x : and #$00FF : beq +
jsr ConvertToDisplay2 : sta $1644, y
+ iny #2 : lda.w #$24f5 : sta $1644, y
phx : ldx $00
lda MapField : and.l $0098c0, x : beq + ; must have map
plx : sep #$30 : lda.l ChestKeys, x : sta $02
lda.w #$24f5 : sta.w $1644, y
lda.l GenericKeys : and.w #$00FF : bne +
lda.l DungeonKeys, x : and.w #$00FF : beq +
jsr ConvertToDisplay2 : sta.w $1644, y
+ iny #2 : lda.w #$24f5 : sta.w $1644, y
phx : ldx.b Scrap00
lda.l MapField : and.l DungeonMask, x : beq + ; must have map
plx : sep #$30 : lda.l ChestKeys, x : sta.b Scrap02
lda.l GenericKeys : bne +++
lda $02 : !sub DungeonCollectedKeys, x : sta $02
+++ lda $02
lda.b Scrap02 : !sub.l DungeonCollectedKeys, x : sta.b Scrap02
+++ lda.b Scrap02
rep #$30
jsr ConvertToDisplay2 : sta $1644, y ; small key totals
jsr ConvertToDisplay2 : sta.w $1644, y ; small key totals
bra .skipStack
+ plx
.skipStack iny #2
cpx #$000d : beq +
lda.w #$24f5 : sta $1644, y
cpx.w #$000d : beq +
lda.w #$24f5 : sta.w $1644, y
+
ldx $00
+ inx #2 : cpx #$001b : bcs ++ : JMP -
ldx.b Scrap00
+ inx #2 : cpx.w #$001b : bcs ++ : JMP -
++
lda HudFlag : and.w #$0020 : bne + : JMP ++ : +
lda HUDDungeonItems : and.w #$000c : bne + : JMP ++ : +
lda.l HudFlag : and.w #$0020 : bne + : JMP ++ : +
lda.l HUDDungeonItems : and.w #$000c : bne + : JMP ++ : +
; map symbols (do I want these) ; note compass symbol is 2c20
lda.w #$2821 : sta $1606 : sta $1610 : sta $161a : sta $1624
lda.w #$2821 : sta.w $1606 : sta.w $1610 : sta.w $161a : sta.w $1624
; blank out a couple thing from old hud
lda.w #$24f5 : sta $16e4 : sta $1724
sta $160a : sta $1614 : sta $161e ; blank out sm key indicators
ldx #$0002
- lda #$0000 ; start of hud area
lda.w #$24f5 : sta.w $16e4 : sta.w $1724
sta.w $160a : sta.w $1614 : sta.w $161e ; blank out sm key indicators
ldx.w #$0002
- lda.w #$0000 ; start of hud area
!addl RowOffsets, x : !addl ColumnOffsets, x : tay
lda.l DungeonReminderTable, x : sta $1644, y
lda.l DungeonReminderTable, x : sta.w $1644, y
iny #2
lda.w #$24f5 : sta $1644, y ; blank out map spot
lda MapField : and.l $0098c0, x : beq + ; must have map
JSR MapIndicatorShort : STA $1644, Y
lda.w #$24f5 : sta.w $1644, y ; blank out map spot
lda.l MapField : and.l DungeonMask, x : beq + ; must have map
JSR MapIndicatorShort : STA.w $1644, Y
+ iny #2
cpx #$001a : bne +
tya : !add #$003c : tay
+ lda CompassField : and.l $0098c0, x : beq + ; must have compass
cpx.w #$001a : bne +
tya : !add.w #$003c : tay
+ lda.l CompassField : and.l DungeonMask, x : beq + ; must have compass
phx ; total chest counts
txa : lsr : tax
sep #$30
lda.l TotalLocations, x : !sub DungeonLocationsChecked, x : JSR HudHexToDec2DigitCopy
rep #$30
lda $06 : jsr ConvertToDisplay2 : sta $1644, y : iny #2
lda $07 : jsr ConvertToDisplay2 : sta $1644, y
LDA.l CompassTotalsWRAM, x : !sub.l DungeonLocationsChecked, x
SEP #$30 : JSR HudHexToDec2DigitCopy : REP #$30
lda.b Scrap06 : jsr ConvertToDisplay2 : sta.w $1644, y : iny #2
lda.b Scrap07 : jsr ConvertToDisplay2 : sta.w $1644, y
plx
bra .skipBlanks
+ lda.w #$24f5 : sta $1644, y : iny #2 : sta $1644, y
+ lda.w #$24f5 : sta.w $1644, y : iny #2 : sta.w $1644, y
.skipBlanks iny #2
cpx #$001a : beq +
lda.w #$24f5 : sta $1644, y ; blank out spot
+ inx #2 : cpx #$001b : !bge ++ : JMP -
cpx.w #$001a : beq +
lda.w #$24f5 : sta.w $1644, y ; blank out spot
+ inx #2 : cpx.w #$001b : !bge ++ : JMP -
++
plp : ply : plx : rtl
}
@@ -208,72 +229,35 @@ IndicatorCharacters:
dw $2426, $2817, $2818, $2819, $281A, $281B, $281C, $281D, $2590, $258B, $259B
MapIndicator:
LDA.l CrystalPendantFlags_3, X : AND #$00FF
LDA.l CrystalPendantFlags_3, X : AND.w #$00FF
PHX
ASL : TAX : LDA.l IndicatorCharacters, X
PLX
RTS
BkStatus:
lda BigKeyField : and.l $0098c0, x : bne +++ ; has the bk already
lda.l BigKeyField : and.l DungeonMask, x : bne +++ ; has the bk already
lda.l BigKeyStatus, x : bne ++
lda #$2827 : rts ; 0/O for no BK
++ cmp #$0002 : bne +
lda #$2420 : rts ; symbol for BnC
+ lda #$24f5 : rts ; black otherwise
+++ lda #$2826 : rts ; check mark
lda.w #$2827 : rts ; 0/O for no BK
++ cmp.w #$0002 : bne +
lda.w #$2420 : rts ; symbol for BnC
+ lda.w #$24f5 : rts ; black otherwise
+++ lda.w #$2826 : rts ; check mark
ConvertToDisplay:
and.w #$00ff : cmp #$000a : !blt +
!add #$2553 : rts
+ !add #$2490 : rts
and.w #$00ff : cmp.w #$000a : !blt +
!add.w #$2553 : rts
+ !add.w #$2490 : rts
ConvertToDisplay2:
and.w #$00ff : beq ++
cmp #$000a : !blt +
!add #$2553 : rts ; 2580 with 258A as "A" for non transparent digits
+ !add #$2816 : rts
++ lda #$2827 : rts ; 0/O for 0 or placeholder digit ;2483
cmp.w #$000a : !blt +
!add.w #$2553 : rts ; 2580 with 258A as "A" for non transparent digits
+ !add.w #$2816 : rts
++ lda.w #$2827 : rts ; 0/O for 0 or placeholder digit ;2483
CountAbsorbedKeys:
jsl IncrementSmallKeysNoPrimary : phx
lda $040c : cmp #$ff : beq +
lsr : tax
lda DungeonAbsorbedKeys, x : inc : sta DungeonAbsorbedKeys, x
+ plx : rtl
;================================================================================
; 16-bit A, 8-bit X
; in: A(b) - Byte to Convert
; out: $04 - $07 (high - low)
;================================================================================
HudHexToDec4DigitCopy:
LDY.b #$90
-
CMP.w #1000 : !BLT +
INY
SBC.w #1000 : BRA -
+
STY $04 : LDY #$90 ; Store 1000s digit & reset Y
-
CMP.w #100 : !BLT +
INY
SBC.w #100 : BRA -
+
STY $05 : LDY #$90 ; Store 100s digit & reset Y
-
CMP.w #10 : !BLT +
INY
SBC.w #10 : BRA -
+
STY $06 : LDY #$90 ; Store 10s digit & reset Y
CMP.w #1 : !BLT +
-
INY
DEC : BNE -
+
STY $07 ; Store 1s digit
RTS
JML IncrementSmallKeysNoPrimary
;================================================================================
; 8-bit registers
@@ -288,12 +272,12 @@ HudHexToDec2DigitCopy: ; modified
INY
SBC.b #10 : BRA -
+
STY $06 : LDY #$00 ; Store 10s digit and reset Y
STY.b Scrap06 : LDY.b #$00 ; Store 10s digit and reset Y
CMP.b #1 : !BLT +
-
INY
DEC : BNE -
+
STY $07 ; Store 1s digit
STY.b Scrap07 ; Store 1s digit
PLY
RTS

View File

@@ -13,24 +13,24 @@ CheckIfDoorsOpen: {
jsr TrapDoorFixer ; see normal.asm
; note we are 16bit mode right now
lda.l DRMode : beq +
lda $040c : cmp #$00ff : bne .gtg
+ lda $a0 : dec : tax : and #$000f ; hijacked code
lda.w DungeonID : cmp.w #$00ff : bne .gtg
+ lda.b RoomIndex : dec : tax : and.w #$000f ; hijacked code
sec : rtl ; set carry to indicate normal behavior
.gtg
phb : phk : plb
stx $00 : ldy #$0000
stx.b Scrap00 : ldy.w #$0000
.nextDoor
lda $a0 : asl : tax
lda.b RoomIndex : asl : tax
lda.w KeyDoorOffset, x : beq .skipDoor
asl : sty $05 : !add $05 : tax
asl : sty.b Scrap05 : !add.b Scrap05 : tax
lda.w PairedDoorTable, x : beq .skipDoor
sta $02 : and #$00ff : asl a : tax
lda $02 : and #$ff00 : sta $03
lda RoomDataWRAM.l, X : and #$f000 : and $03 : beq .skipDoor
tyx : lda $068c : ora $0098c0,x : sta $068c
sta.b Scrap02 : and.w #$00ff : asl a : tax
lda.b Scrap02 : and.w #$ff00 : sta.b Scrap03
lda RoomDataWRAM.l, X : and.w #$f000 : and.b Scrap03 : beq .skipDoor
tyx : lda.w $068c : ora.l DungeonMask,x : sta.w $068c
.skipDoor
iny #2 : cpy $00 : bne .nextDoor
iny #2 : cpy.b Scrap00 : bne .nextDoor
plb : clc : rtl
}

View File

@@ -7,60 +7,60 @@
;00 00 01 01 01 02 02 02 03 03 03 04 04 04 05 05 05 06 06 06 07 07 07 08 08
MultiplyByY:
.loop cpy #$0001 : beq .done
cpy #$0003 : bne ++
.loop cpy.w #$0001 : beq .done
cpy.w #$0003 : bne ++
jsr MultiBy3 : bra .done
++ cpy #$0005 : bne ++
++ cpy.w #$0005 : bne ++
jsr MultiBy5 : bra .done
++ asl : sta $00 : tya : lsr : tay : lda $00 : bra .loop
++ asl : sta.b Scrap00 : tya : lsr : tay : lda.b Scrap00 : bra .loop
.done rts
;Divisor in Y. Width of division is in X for rounding toward middle
DivideByY:
.loop
cpy #$0000 : beq .done
cpy #$0001 : beq .done
cpy #$0003 : bne ++
cpy.w #$0000 : beq .done
cpy.w #$0001 : beq .done
cpy.w #$0003 : bne ++
jsr DivideBy3 : bra .done
++ cpy #$0005 : bne ++
++ cpy.w #$0005 : bne ++
jsr DivideBy5 : bra .done
++ jsr DivideBy2 : sta $00
++ jsr DivideBy2 : sta.b Scrap00
tya : lsr : tay
txa : lsr : tax
lda $00 : bra .loop
lda.b Scrap00 : bra .loop
.done rts
MultiBy3:
sta $00 : asl : !add $00
sta.b Scrap00 : asl : !add.b Scrap00
rts
MultiBy5:
sta $00 : asl #2 : !add $00
sta.b Scrap00 : asl #2 : !add.b Scrap00
rts
;width of divison in x: rounds toward X/2
DivideBy2:
sta $00
sta.b Scrap00
lsr : bcc .done
sta $02 : txa : lsr : cmp $00 : !blt +
lda $02 : inc : bra .done
+ lda $02
sta.b Scrap02 : txa : lsr : cmp.b Scrap00 : !blt +
lda.b Scrap02 : inc : bra .done
+ lda.b Scrap02
.done rts
DivideBy3:
sta $00
ldx #$0000
lda #$0002
.loop cmp $00 : !bge .store
inx : !add #$0003 : bra .loop
sta.b Scrap00
ldx.w #$0000
lda.w #$0002
.loop cmp.b Scrap00 : !bge .store
inx : !add.w #$0003 : bra .loop
.store txa
rts
DivideBy5:
sta $00
ldx #$0000
lda #$0003
.loop cmp $00 : !bge .store
inx : !add #$0005 : bra .loop
sta.b Scrap00
ldx.w #$0000
lda.w #$0003
.loop cmp.b Scrap00 : !bge .store
inx : !add.w #$0005 : bra .loop
.store txa
rts

View File

@@ -1,9 +1,9 @@
WarpLeft:
lda.l DRMode : beq .end
JSR CheckIfCave : BCS .end
lda $20 : ldx $aa
lda.b LinkPosY : ldx.b LinkQuadrantV
jsr CalcIndex
!add #$06 : ldy #$01 ; offsets in A, Y
!add.b #$06 : ldy.b #$01 ; offsets in A, Y
jsr LoadRoomHorz
.end
jsr Cleanup
@@ -12,9 +12,9 @@ WarpLeft:
WarpRight:
lda.l DRMode : beq .end
JSR CheckIfCave : BCS .end
lda $20 : ldx $aa
lda.b LinkPosY : ldx.b LinkQuadrantV
jsr CalcIndex
!add #$12 : ldy #$ff ; offsets in A, Y
!add.b #$12 : ldy.b #$ff ; offsets in A, Y
jsr LoadRoomHorz
.end
jsr Cleanup
@@ -23,9 +23,9 @@ WarpRight:
WarpUp:
lda.l DRMode : beq .end
JSR CheckIfCave : BCS .end
lda $22 : ldx $a9
lda.b LinkPosX : ldx.b LinkQuadrantH
jsr CalcIndex
ldy #$02 ; offsets in A, Y
ldy.b #$02 ; offsets in A, Y
jsr LoadRoomVert
.end
jsr Cleanup
@@ -33,17 +33,17 @@ WarpUp:
; Checks if $a0 is equal to <Room>. If it is, opens its stonewall if it's there
macro StonewallCheck(Room)
lda $a0 : cmp.b #<Room> : bne ?end
lda.l <Room>*2+$7ef000 : ora #$80 : sta.l <Room>*2+$7ef000
lda.b RoomIndex : cmp.b #<Room> : bne ?end
lda.l <Room>*2+$7ef000 : ora.b #$80 : sta.l <Room>*2+$7ef000
?end
endmacro
WarpDown:
lda.l DRMode : beq .end
JSR CheckIfCave : BCS .end
lda $22 : ldx $a9
lda.b LinkPosX : ldx.b LinkQuadrantH
jsr CalcIndex
!add #$0c : ldy #$ff ; offsets in A, Y
!add.b #$0c : ldy.b #$ff ; offsets in A, Y
jsr LoadRoomVert
%StonewallCheck($43)
.end
@@ -54,35 +54,35 @@ WarpDown:
; carry clear = we are in dr mode, never use linking doors
CheckLinkDoorR:
lda.l DRMode : bne +
lda $7ec004 : sta $a0 ; what we wrote over
lda.l $7ec004 : sta.b RoomIndex ; what we wrote over
sec : rtl
+ clc : rtl
CheckLinkDoorL:
lda.l DRMode : bne +
lda $7ec003 : sta $a0 ; what we wrote over
lda.l $7ec003 : sta.b RoomIndex ; what we wrote over
sec : rtl
+ clc : rtl
TrapDoorFixer:
lda $fe : and #$0038 : beq .end
xba : asl #2 : sta $00
stz $0468 : lda $068c : ora $00 : sta $068c
lda.b $fe : and #$0038 : beq .end
xba : asl #2 : sta.b Scrap00
stz.w $0468 : lda.w $068c : ora.b Scrap00 : sta.w $068c
.end
stz $fe ; clear our fe here because we don't need it anymore
stz.b $fe ; clear our fe here because we don't need it anymore
rts
Cleanup:
lda.l DRFlags : and #$10 : beq +
stz $047a
+ inc $11
lda $ef
lda.l DRFlags : and.b #$10 : beq +
stz.w LayerAdjustment
+ inc.b GameSubMode
lda.b $ef
rts
; carry set if cave, clear otherwise
CheckIfCave:
REP #$30
LDA.b $A2 : CMP.w #$00E1 : BCS .invalid
LDA.b PreviousRoom : CMP.w #$00E1 : BCS .invalid
SEP #$30 : CLC : RTS
.invalid
SEP #$30 : SEC : RTS
@@ -92,11 +92,11 @@ CheckIfCave:
CalcIndex: ; A->low byte of Link's Coord, X-> Link's quadrant, DoorOffset x 2 -> A, DoorOffset -> $04 (vert/horz agnostic)
cpx.b #00 : bne .largeDoor
cmp.b #$d0 : bcc .smallDoor
lda #$01 : bra .done ; Middle Door
.smallDoor lda #$00 : bra .done
.largeDoor lda #$02
lda.b #$01 : bra .done ; Middle Door
.smallDoor lda.b #$00 : bra .done
.largeDoor lda.b #$02
.done
sta $04
sta.b Scrap04
asl
rts
@@ -105,30 +105,30 @@ CalcIndex: ; A->low byte of Link's Coord, X-> Link's quadrant, DoorOffset x 2 ->
LoadRoomHorz:
{
phb : phk : plb
sty $06 : sta $07 : lda $a0 : pha ; Store normal room on stack
lda $07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00-$01
lda $00 : cmp #$03 : bne .gtg
sty.b Scrap06 : sta.b Scrap07 : lda.b RoomIndex : pha ; Store normal room on stack
lda.b Scrap07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00-$01
lda.b Scrap00 : cmp.b #$03 : bne .gtg
jsr HorzEdge : pla : bcs .end
sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
sta.b RoomIndex : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
.gtg ;Good to Go!
pla ; Throw away normal room (don't fill up the stack)
lda $a0 : and.b #$0F : asl a : !sub $23 : !add $06 : sta $02
ldy #$00 : jsr ShiftVariablesMainDir
lda.b RoomIndex : and.b #$0F : asl a : !sub.b LinkPosX+1 : !add.b Scrap06 : sta.b Scrap02
ldy.b #$00 : jsr ShiftVariablesMainDir
lda $01 : and #$80 : beq .normal
ldy $06 : cpy #$ff : beq +
lda $01 : jsr LoadEastMidpoint : bra ++
+ lda $01 : jsr LoadWestMidpoint
lda.b Scrap01 : and.b #$80 : beq .normal
ldy.b Scrap06 : cpy.b #$ff : beq +
lda.b Scrap01 : jsr LoadEastMidpoint : bra ++
+ lda.b Scrap01 : jsr LoadWestMidpoint
++ jsr PrepScrollToEdge : bra .scroll
.normal
jsr PrepScrollToNormal
.scroll
lda $01 : and #$40 : pha
lda.b Scrap01 : and.b #$40 : pha
jsr ScrollY
pla : beq .end
ldy #$06 : jsr ApplyScroll
ldy.b #$06 : jsr ApplyScroll
.end
plb ; restore db register
rts
@@ -139,32 +139,32 @@ LoadRoomHorz:
LoadRoomVert:
{
phb : phk : plb
sty $06 : sta $07 : lda $a0 : pha ; Store normal room on stack
lda $07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00-$01
lda $00 : cmp #$03 : bne .gtg
sty.b Scrap06 : sta.b Scrap07 : lda.b RoomIndex : pha ; Store normal room on stack
lda.b Scrap07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00-$01
lda.b Scrap00 : cmp.b #$03 : bne .gtg
jsr VertEdge : pla : bcs .end
sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
sta.b RoomIndex : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
.gtg ;Good to Go!
pla ; Throw away normal room (don't fill up the stack)
lda $a0 : and.b #$F0 : lsr #3 : !sub $21 : !add $06 : sta $02
lda.b RoomIndex : and.b #$F0 : lsr #3 : !sub.b LinkPosY+1 : !add.b Scrap06 : sta.b Scrap02
lda $01 : and #$80 : beq .notEdge
ldy #$01 : jsr ShiftVariablesMainDir
ldy $06 : cpy #$ff : beq +
lda $01 : jsr LoadSouthMidpoint : bra ++
+ lda $01 : jsr LoadNorthMidpoint
lda.b Scrap01 : and.b #$80 : beq .notEdge
ldy.b #$01 : jsr ShiftVariablesMainDir
ldy.b Scrap06 : cpy.b #$ff : beq +
lda.b Scrap01 : jsr LoadSouthMidpoint : bra ++
+ lda.b Scrap01 : jsr LoadNorthMidpoint
++ jsr PrepScrollToEdge : bra .scroll
.notEdge
lda $01 : and #$03 : cmp #$03 : bne .normal
lda.b Scrap01 : and.b #$03 : cmp.b #$03 : bne .normal
jsr ScrollToInroomStairs
stz $046d
stz.w $046d
bra .end
.normal
ldy #$01 : jsr ShiftVariablesMainDir
ldy.b #$01 : jsr ShiftVariablesMainDir
jsr PrepScrollToNormal
.scroll
lda $01 : and #$40 : sta $046d
lda.b Scrap01 : and.b #$40 : sta.w $046d
jsr ScrollX
.end
plb ; restore db register
@@ -174,13 +174,13 @@ LoadRoomVert:
LookupNewRoom: ; expects data offset to be in A
{
rep #$30 : and #$00FF ;sanitize A reg (who knows what is in the high byte)
sta $00 ; offset in 00
lda $a2 : tax ; probably okay loading $a3 in the high byte
lda.w DoorOffset,x : and #$00FF ;we only want the low byte
asl #3 : sta $02 : !add $02 : !add $02 ;multiply by 24 (data size)
!add $00 ; should now have the offset of the address I want to load
tax : lda.w DoorTable,x : sta $00
and #$00FF : sta $a0 ; assign new room
sta.b Scrap00 ; offset in 00
lda.b PreviousRoom : tax ; probably okay loading $a3 in the high byte
lda.w DoorOffset,x : and.w #$00FF ;we only want the low byte
asl #3 : sta.b Scrap02 : !add.b Scrap02 : !add.b Scrap02 ;multiply by 24 (data size)
!add.b Scrap00 ; should now have the offset of the address I want to load
tax : lda.w DoorTable,x : sta.b Scrap00
and.w #$00FF : sta.b RoomIndex ; assign new room
sep #$30
rts
}
@@ -190,14 +190,14 @@ LookupNewRoom: ; expects data offset to be in A
ShiftVariablesMainDir:
{
lda.w CoordIndex,y : tax
lda $21,x : !add $02 : sta $21,x ; coordinate update
lda.b LinkPosY+1,x : !add.b Scrap02 : sta.b LinkPosY+1,x ; coordinate update
lda.w CameraIndex,y : tax
lda $e3,x : !add $02 : sta $e3,x ; scroll register high byte
lda.b $e3,x : !add.b Scrap02 : sta.b $e3,x ; scroll register high byte
lda.w CamQuadIndex,y : tax
lda $0605,x : !add $02 : sta $0605,x ; high bytes of these guys
lda $0607,x : !add $02 : sta $0607,x
lda $0601,x : !add $02 : sta $0601,x
lda $0603,x : !add $02 : sta $0603,x
lda.w $0605,x : !add.b Scrap02 : sta.w $0605,x ; high bytes of these guys
lda.w $0607,x : !add.b Scrap02 : sta.w $0607,x
lda.w $0601,x : !add.b Scrap02 : sta.w $0601,x
lda.w $0603,x : !add.b Scrap02 : sta.w $0603,x
rts
}
@@ -205,12 +205,12 @@ ShiftVariablesMainDir:
ScrollToInroomStairs:
{
jsr PrepScrollToInroomStairs
ldy #$01 : jsr ShiftVariablesMainDir
ldy.b #$01 : jsr ShiftVariablesMainDir
jsr ScrollX
ldy #$00 : jsr ApplyScroll
lda $a0 : and #$0f : cmp #$0f : bne +
stz $e0 : stz $e2 ; special case camera fix
lda #$1f : sta $e1 : sta $e3
ldy.b #$00 : jsr ApplyScroll
lda.b RoomIndex : and.b #$0f : cmp.b #$0f : bne +
stz.b BG1H : stz.b BG2H ; special case camera fix
lda.b #$1f : sta.b BG1H+1 : sta.b BG2H+1
+
rts
}
@@ -219,48 +219,48 @@ ScrollToInroomStairs:
; Sets $02, $04, $05, $ee, $045e, $045f and things related to Y coordinate
PrepScrollToInroomStairs:
{
lda $01 : and #$30 : lsr #3 : tay
lda.w InroomStairsX,y : sta $04
lda.w InroomStairsX+1,y : sta $05
lda $06 : cmp #$ff : beq .south
lda.b Scrap01 : and.b #$30 : lsr #3 : tay
lda.w InroomStairsX,y : sta.b Scrap04
lda.w InroomStairsX+1,y : sta.b Scrap05
lda.b Scrap06 : cmp.b #$ff : beq .south
lda.w InroomStairsY+1,y : bne +
inc $045f ; flag indicating special screen transition
dec $02 ; shift variables further
stz $aa
lda $a8 : and #%11111101 : sta $a8
stz $0613 ; North scroll target
inc $0603 : inc $0607
dec $0619 : dec $061b
inc.w $045f ; flag indicating special screen transition
dec.b Scrap02 ; shift variables further
stz.b LinkQuadrantV
lda.b $a8 : and.b #%11111101 : sta.b $a8
stz.w CameraTargetS+1 ; North scroll target
inc.w $0603 : inc.w $0607
dec.w CameraScrollN+1 : dec.w CameraScrollS+1
+
lda.w InroomStairsY,y : !add #$20 : sta $20
!sub #$38 : sta $045e
lda $01 : and #$40 : beq +
lda $20 : !add #$20 : sta $20
stz $045f
lda.w InroomStairsY,y : !add.b #$20 : sta.b LinkPosY
!sub.b #$38 : sta.w $045e
lda.b Scrap01 : and.b #$40 : beq +
lda.b LinkPosY : !add.b #$20 : sta.b LinkPosY
stz.w $045f
+
dec $21
dec.b LinkPosY+1
%StonewallCheck($1b)
bra ++
.south
lda.w InroomStairsY+1,y : beq +
inc $045f ; flag indicating special screen transition
inc $02 ; shift variables further
lda #$02 : sta $aa
lda $a8 : ora #%00000010 : sta $a8
inc $0611 ; South scroll target
dec $0603 : dec $0607
inc $0619 : inc $061b
inc.w $045f ; flag indicating special screen transition
inc.b Scrap02 ; shift variables further
lda.b #$02 : sta.b LinkQuadrantV
lda.b $a8 : ora.b #%00000010 : sta.b $a8
inc.w CameraTargetN+1 ; South scroll target
dec.w $0603 : dec.w $0607
inc.w CameraScrollN+1 : inc.w CameraScrollS+1
+
lda.w InroomStairsY,y : !sub #$20 : sta $20
!add #$38 : sta $045e
lda $01 : and #$40 : beq +
lda $20 : !sub #$20 : sta $20
stz $045f
lda.w InroomStairsY,y : !sub.b #$20 : sta.b LinkPosY
!add.b #$38 : sta.w $045e
lda.b Scrap01 : and.b #$40 : beq +
lda.b LinkPosY : !sub.b #$20 : sta.b LinkPosY
stz.w $045f
+
inc $21
inc.b LinkPosY+1
++
lda $01 : and #$04 : lsr #2 : sta $ee : bne +
stz $0476
lda.b Scrap01 : and.b #$04 : lsr #2 : sta.b LinkLayer : bne +
stz.w $0476
+ rts
}
@@ -268,13 +268,13 @@ PrepScrollToInroomStairs:
; Sets $04 $05 and $ee
PrepScrollToEdge:
{
sta $04 : lda $01 : and #$20 : beq +
lda #01
+ sta $05
lda $01 : and #$10 : beq +
lda #01
+ sta $ee : bne +
stz $0476
sta.b Scrap04 : lda.b Scrap01 : and.b #$20 : beq +
lda.b #01
+ sta.b Scrap05
lda.b Scrap01 : and.b #$10 : beq +
lda.b #01
+ sta.b LinkLayer : bne +
stz.w $0476
+ rts
}
@@ -282,56 +282,56 @@ PrepScrollToEdge:
; Sets $04 $05 and $ee, and $fe
PrepScrollToNormal:
{
lda $01 : sta $fe : and #$04 : lsr #2 : sta $ee ; trap door and layer
lda.b Scrap01 : sta.b $fe : and.b #$04 : lsr #2 : sta.b LinkLayer ; trap door and layer
bne +
stz $0476
+ stz $05 : lda #$78 : sta $04
lda $01 : and #$03 : beq .end
cmp #$02 : !bge +
lda #$f8 : sta $04 : bra .end
+ inc $05
stz.w $0476
+ stz.b Scrap05 : lda.b #$78 : sta.b Scrap04
lda.b Scrap01 : and.b #$03 : beq .end
cmp.b #$02 : !bge +
lda.b #$f8 : sta.b Scrap04 : bra .end
+ inc.b Scrap05
.end rts
}
StraightStairsAdj:
{
stx $0464 : sty $012e ; what we wrote over
stx.w $0464 : sty.w SFX2 ; what we wrote over
lda.l DRMode : beq +
lda $045e : bne .toInroom
lda $046d : beq .noScroll
sta $22
ldy #$00 : jsr ApplyScroll
stz $046d
lda.w $045e : bne .toInroom
lda.w $046d : beq .noScroll
sta.b LinkPosX
ldy.b #$00 : jsr ApplyScroll
stz.w $046d
.noScroll
jsr GetTileAttribute : tax
lda $11 : cmp #$12 : beq .goingNorth
lda $a2 : cmp #$51 : bne ++
rep #$20 : lda #$0018 : !add $20 : sta $20 : sep #$20 ; special fix for throne room
lda.b GameSubMode : cmp.b #$12 : beq .goingNorth
lda.b PreviousRoom : cmp.b #$51 : bne ++
rep #$20 : lda.w #$0018 : !add.b LinkPosY : sta.b LinkPosY : sep #$20 ; special fix for throne room
jsr GetTileAttribute : tax
++ lda.l StepAdjustmentDown, X : bra .end
; lda $ee : beq .end
; rep #$20 : lda #$ffe0 : !add $20 : sta $20 : sep #$20
; lda.b LinkLayer : beq .end
; rep #$20 : lda.w #$ffe0 : !add.b LinkPosY : sta.b LinkPosY : sep #$20
.goingNorth
cpx #$00 : bne ++
lda $a0 : cmp #$51 : bne ++
lda #$36 : bra .end ; special fix for throne room
++ ldy $ee : cpy #$00 : beq ++
cpx.b #$00 : bne ++
lda.b RoomIndex : cmp.b #$51 : bne ++
lda.b #$36 : bra .end ; special fix for throne room
++ ldy.b LinkLayer : cpy.b #$00 : beq ++
inx
++ lda.l StepAdjustmentUp, X
.end
pha : lda $0462 : and #$04 : bne ++
pla : !add #$f6 : pha
++ pla : !add $0464 : sta $0464
pha : lda.w $0462 : and.b #$04 : bne ++
pla : !add.b #$f6 : pha
++ pla : !add.w $0464 : sta.w $0464
+ rtl
.toInroom
lda #$32 : sta $0464 : stz $045e
lda.b #$32 : sta.w $0464 : stz.w $045e
rtl
}
GetTileAttribute:
{
phk : pea.w .jslrtsreturn-1
pea.w $02802c
pea.w $82802c
jml CalculateTransitionLanding ; mucks with x/y sets a to Tile Attribute, I think
.jslrtsreturn
rts
@@ -352,15 +352,15 @@ StraightStairsFix:
{
pha
lda.l DRMode : bne +
pla : !add $20 : sta $20 : rtl ;what we wrote over
pla : !add.b LinkPosY : sta.b LinkPosY : rtl ;what we wrote over
+ pla : rtl
}
StraightStairLayerFix:
{
lda.l DRMode : beq +
lda $ee : rtl
+ lda $01c322, x : rtl ; what we wrote over
lda.b LinkLayer : rtl
+ lda.l LayerOfDestination+3, x : rtl ; what we wrote over
}
DoorToStraight:
@@ -369,61 +369,61 @@ DoorToStraight:
lda.l DRMode : beq .skip
pla : bne .end
pha
lda $a0 : cmp #$51 : bne .skip
lda #$04 : sta $4e
lda.b RoomIndex : cmp.b #$51 : bne .skip
lda.b #$04 : sta.b $4e
.skip pla
.end LDX.w $0418 : CMP.b #$02 ; what we wrote over
.end LDX.w TransitionDirection : CMP.b #$02 ; what we wrote over
rtl
}
DoorToInroom:
{
ldx $045e : bne .end
sta $0020, y ; what we wrote over
ldx.w $045e : bne .end
sta.w $0020, y ; what we wrote over
.end
ldx #$00 ; what we wrote over
ldx.b #$00 ; what we wrote over
rtl
}
DoorToInroomEnd:
{
ldy $045e : beq .vanilla
cmp $045e : bne .return
stz $045e ; clear
ldy.w $045e : beq .vanilla
cmp.w $045e : bne .return
stz.w $045e ; clear
.return
rtl
.vanilla
cmp $02c034, x ; what we wrote over
cmp.l UnderworldTransitionLandingCoordinate, x ; what we wrote over
rtl
}
StraightStairsTrapDoor:
{
lda $0464 : bne +
lda.w $0464 : bne +
; reset function
.reset phk : pea.w .jslrtsreturn-1
pea.w $02802c
jml $028c73 ; $10D71 .reset label of Bank02
pea.w $82802c
jml ResetThenCacheRoomEntryProperties ; $10D71 .reset label of Bank02
.jslrtsreturn
lda $0468 : bne ++
lda $a0 : cmp.b #$ac : bne .animateTraps
lda $0403 : and.b #$20 : bne .animateTraps
lda $0403 : and.b #$10 : beq ++
lda.w $0468 : bne ++
lda.b RoomIndex : cmp.b #$ac : bne .animateTraps
lda.w $0403 : and.b #$20 : bne .animateTraps
lda.w $0403 : and.b #$10 : beq ++
.animateTraps
lda #$05 : sta $11
inc $0468 : stz $068e : stz $0690
lda.b #$05 : sta.b GameSubMode
inc.w $0468 : stz.w $068e : stz.w $0690
++ JML Underworld_SetBossOrSancMusicUponEntry_long
+ JML Dungeon_ApproachFixedColor ; what we wrote over
}
InroomStairsTrapDoor:
{
lda $0200 : cmp #$05 : beq .reset
lda $b0 : jml $008781 ; what we wrote over (essentially)
lda.w SubModuleInterface : cmp.b #$05 : beq .reset
lda.b SubSubModule : jml JumpTableLocal ; what we wrote over (essentially)
.reset
pla : pla : pla
jsl StraightStairsTrapDoor_reset
jml $028b15 ; just some RTS in bank 02
jml $828b15 ; just some RTS in bank 02
}
HandleSpecialDoorLanding: {
@@ -436,7 +436,7 @@ HandleSpecialDoorLanding: {
LDA.b 1,S : AND.b #$FA : CMP.b #$80 : bne .noDoor
.setDoorState
LDA.w $0418 : AND.b #$02 : BNE + : INC
LDA.w TransitionDirection : AND.b #$02 : BNE + : INC
+ STA.b $6C
.noDoor

View File

@@ -1,9 +1,9 @@
GtBossHeartCheckOverride:
lda $a0 : cmp #$1c : beq ++
cmp #$6c : beq ++
cmp #$4d : bne +
++ lda.l DRFlags : and #$01 : bne ++ ;skip if flag on
lda $403 : ora #$80 : sta $403
lda.b RoomIndex : cmp.b #$1c : beq ++
cmp.b #$6c : beq ++
cmp.b #$4d : bne +
++ lda.l DRFlags : and.b #$01 : bne ++ ;skip if flag on
lda.w RoomItemsTaken : ora.b #$80 : sta.w RoomItemsTaken
++ clc
rtl
+ sec
@@ -11,99 +11,102 @@ rtl
OnFileLoadOverride:
jsl OnFileLoad ; what I wrote over
+ lda.l DRFlags : and #$02 : beq + ; Mirror Scroll
lda MirrorEquipment : bne +
lda #$01 : sta MirrorEquipment
+ lda.l DRFlags : and.b #$02 : beq + ; Mirror Scroll
lda.l MirrorEquipment : bne +
lda.b #$01 : sta.l MirrorEquipment
+ rtl
MirrorCheckOverride:
lda.l DRFlags : and #$02 : beq ++
lda MirrorEquipment : cmp #$01 : beq +
;++ lda $8A : and #$40 ; what I wrote over
++ phx : ldx $8A : lda.l OWTileWorldAssoc,x : plx : and.b #$ff
lda.l DRFlags : and.b #$02 : beq ++
lda.l MirrorEquipment : cmp.b #$01 : beq +
;++ lda.b OverworldIndex : and.b #$40 ; what I wrote over
++ phx : ldx.b OverworldIndex : lda.l OWTileWorldAssoc,x : plx : and.b #$ff
rtl
+ lda.l DRScroll : rtl
EGFixOnMirror:
lda.l DRFlags : and #$10 : beq +
stz $047a
lda.l DRFlags : and.b #$10 : beq +
stz.w LayerAdjustment
+ jsl Mirror_SaveRoomData
rtl
BlockEraseFix:
lda MirrorEquipment : and #$02 : beq +
stz $05fc : stz $05fd
lda.l MirrorEquipment : and.b #$02 : beq +
stz.w $05fc : stz.w $05fd
+ rtl
FixShopCode:
cpx #$300 : !bge +
sta RoomDataWRAM[$00].l, x
cpx.w #$0300 : !bge +
sta.l RoomDataWRAM[$00].l, x
+ rtl
VitreousKeyReset:
lda.l DRMode : beq +
stz $0cba, x
+ JML $0db818 ;restore old code
LDA.l FixPrizeOnTheEyes : BEQ +
STZ.w SpriteForceDrop, X
+ JML SpritePrep_LoadProperties ; what we wrote over
GuruguruFix:
lda $a0 : cmp #$df : !bge +
and #$0f : cmp #$0e : !blt +
lda.b RoomIndex : cmp.b #$df : !bge +
and.b #$0f : cmp.b #$0e : !blt +
iny #2
+ rtl
BlindAtticFix:
lda.l DRMode : beq +
lda #$01 : rtl
+ lda FollowerIndicator : cmp.b #$06
lda.b #$01 : rtl
+ lda.l FollowerIndicator : cmp.b #$06
rtl
SuctionOverworldFix:
stz $50 : stz $5e
stz.b LinkStrafe : stz.b LinkSpeed
lda.l DRMode : beq +
stz $49
stz.b ForceMove
+ rtl
!CutoffTable = "$27E000"
CutoffEntranceRug:
PHA : PHX
LDA.l DRMode : BEQ .norm
LDA $04 : cmp #$000A : BEQ + ; only affect A & C objects
cmp #$000C : BNE .norm
+ LDX #$0000 : LDA !CutoffTable, x
- CMP.W $A0 : BEQ .check
INX #2 : LDA !CutoffTable, x : CMP.w #$FFFF : BNE -
.norm PLX : PLA : LDA $9B52, y : STA $7E2000, x ; what we wrote over
RTL
.check
LDA $0c : CMP #$0004 : !BGE .skip
LDA $0e : CMP #$0008 : !BGE .skip
CMP.l #$0004 : !BLT .skip
BRA .norm
.skip PLX : PLA : RTL
LDA.b Scrap04 : CMP.w #$000A : BEQ + ; only affect A & C objects
CMP.w #$000C : BNE .norm
+ LDX.w #$0000 : LDA.l CutoffRooms, x
- CMP.b RoomIndex : BEQ .check
INX #2 : LDA.l CutoffRooms, x : CMP.w #$FFFF : BNE -
.norm
PLX : PLA : LDA.w $9B52, Y : STA.l TileMapA, X ; what we wrote over
RTL
.check
LDA.b Scrap0C : CMP.w #$0004 : !BGE .skip
LDA.b Scrap0E : CMP.w #$0008 : !BGE .skip
CMP.w #$0004 : !BLT .skip
BRA .norm
.skip
PLX : PLA : RTL
StoreTempBunnyState:
LDA $5D : CMP #$1C : BNE +
STA $5F
+ LDA #$15 : STA $5D ; what we wrote over
LDA.b LinkState : CMP.b #$1C : BNE +
STA.b ManipTileField
+ LDA.b #$15 : STA.b LinkState ; what we wrote over
RTL
RetrieveBunnyState:
STY $5D : STZ $02D8 ; what we wrote over
LDA $5F : BEQ +
STA $5D
+ RTL
STY.b LinkState : STZ.w ItemReceiptID ; what we wrote over
LDA.b ManipTileField : BEQ +
STA.b LinkState
+ JML MaybeKeepLootID
; A should be how much dmg to do to Aga when leaving this function
; A should be how much dmg to do to Aga when leaving this function, 0 if prevented
StandardAgaDmg:
LDX.b #$00 ; part of what we wrote over
LDA.l ProgressFlags : AND #$04 : BEQ + ; zelda's not been rescued
LDA.l ProgressFlags : AND.b #$04 : BNE .enableDamage ; zelda's been rescued, no further checks needed
; zelda's not been rescued
LDA.l AllowAgaDamageBeforeZeldaRescued : BEQ + ; zelda needs to be rescued if not allowed
.enableDamage
LDA.b #$10 ; hurt him!
+ RTL ; A is zero if the AND results in zero and then Agahnim's invincible!
+ RTL
StandardSaveAndQuit:
LDA.b #$0F : STA.b $95 ; what we wrote over
LDA.l ProgressFlags : AND #$04 : BNE +
LDA.b #$0F : STA.b MOSAICQ ; what we wrote over
LDA.l ProgressFlags : AND.b #$04 : BNE +
LDA.l DRMode : BEQ +
LDA.l StartingEntrance : CMP.b #$02 : BCC +
LDA.b #$03 : STA.l StartingEntrance ; set spawn to uncle if >=
@@ -113,24 +116,24 @@ StandardSaveAndQuit:
BlindsAtticHint:
REP #$20
CMP.w #$0122 : BNE +
LDA RoomDataWRAM[$65].low : AND.w #$0100 : BEQ +
LDA.l RoomDataWRAM[$65].low : AND.w #$0100 : BEQ +
SEP #$20 : RTL ; skip the dialog box if the hole is already open
+ SEP #$20 : JML Main_ShowTextMessage
BlindZeldaDespawnFix:
CMP.b #06 : BEQ +
LDA.w $0D00,X : BEQ + ; don't despawn follower if maiden isn't "present"
LDA.w SpritePosYLow,X : BEQ + ; don't despawn follower if maiden isn't "present"
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.l DRFlags : AND.w #$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.b GameMode : CMP.b #$0F : BEQ .skip_activation
; LDA.l InvertedMode : BNE +
; LDA.l CurrentWorld : BNE .skip_activation
; RTL

View File

@@ -1,98 +1,98 @@
AdjustTransition:
{
lda $ab : and #$01ff : beq .reset
phy : ldy #$06 ; operating on vertical registers during horizontal trans
lda.b $ab : and.w #$01ff : beq .reset
phy : ldy.b #$06 ; operating on vertical registers during horizontal trans
cpx.b #$02 : bcs .horizontalScrolling
ldy #$00 ; operate on horizontal regs during vert trans
ldy.b #$00 ; operate on horizontal regs during vert trans
.horizontalScrolling
cmp #$0008 : bcs +
pha : lda $ab : and #$0200 : beq ++
cmp.w #$0008 : bcs +
pha : lda.b $ab : and.w #$0200 : beq ++
pla : bra .add
++ pla : eor #$ffff : inc ; convert to negative
++ pla : eor.w #$ffff : inc ; convert to negative
.add jsr AdjustCamAdd : ply : bra .reset
+ lda $ab : and #$0200 : xba : tax
+ lda.b $ab : and.w #$0200 : xba : tax
lda.l OffsetTable,x : jsr AdjustCamAdd
lda $ab : !sub #$0008 : sta $ab
lda.b $ab : !sub.w #$0008 : sta.b $ab
ply : bra .done
.reset ; clear the $ab variable so to not disturb intra-tile doors
stz $ab
stz.b $ab
.done
lda $00 : and #$01fc
lda.b Scrap00 : and.w #$01fc
rtl
}
AdjustCamAdd:
!add $00E2,y : pha
and #$01ff : cmp #$0111 : !blt +
cmp #$01f8 : !bge ++
pla : and #$ff10 : pha : bra +
++ pla : and #$ff00 : !add #$0100 : pha
+ pla : sta $00E2,y : sta $00E0,y : rts
!add.w $00E2,y : pha
and.w #$01ff : cmp.w #$0111 : !blt +
cmp.w #$01f8 : !bge ++
pla : and.w #$ff10 : pha : bra +
++ pla : and.w #$ff00 : !add.w #$0100 : pha
+ pla : sta.w $00E2,y : sta.w $00E0,y : rts
; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0
; $06 is either $ff or $01/02
; uses $00-$03 and $0e for calculation
; also set up $ac
ScrollY: ;change the Y offset variables
lda $a0 : and.b #$f0 : lsr #3 : sta $0603 : inc : sta $0607
lda.b RoomIndex : and.b #$f0 : lsr #3 : sta.w $0603 : inc : sta.w $0607
lda $05 : bne +
lda $603 : sta $00 : stz $01 : bra ++
+ lda $607 : sta $00 : lda #$02 : sta $01
lda.b Scrap05 : bne +
lda.w $0603 : sta.b Scrap00 : stz.b Scrap01 : bra ++
+ lda.w $0607 : sta.b Scrap00 : lda.b #$02 : sta.b Scrap01
++ ; $01 now contains 0 or 2 and $00 contains the correct lat
stz $0e
stz.b Scrap0E
rep #$30
lda $00 : pha
lda.b Scrap00 : pha
lda $e8 : and #$01ff : sta $02
lda $04 : jsr LimitYCamera : sta $00
lda.b BG2V : and #$01ff : sta.b Scrap02
lda.b Scrap04 : jsr LimitYCamera : sta.b Scrap00
jsr CheckRoomLayoutY : bcc +
lda $00 : cmp #$0080 : !bge ++
cmp #$0010 : !blt .cmpSrll
lda #$0010 : bra .cmpSrll
++ cmp #$0100 : !bge .cmpSrll
lda #$0100
.cmpSrll sta $00
lda.b Scrap00 : cmp.w #$0080 : !bge ++
cmp.w #$0010 : !blt .cmpSrll
lda.w #$0010 : bra .cmpSrll
++ cmp.w #$0100 : !bge .cmpSrll
lda.w #$0100
.cmpSrll sta.b Scrap00
; figures out scroll amt
+ lda $00 : cmp $02 : bne +
lda #$0000 : bra .next
+ lda.b Scrap00 : cmp.b Scrap02 : bne +
lda.w #$0000 : bra .next
+ !blt +
!sub $02 : inc $0e : bra .next
+ lda $02 : !sub $00
!sub.b Scrap02 : inc.b Scrap0E : bra .next
+ lda.b Scrap02 : !sub.b Scrap00
.next
sta $ab
sta.b $ab
jsr AdjustCameraBoundsY
pla : sta $00
pla : sta.b Scrap00
sep #$30
lda $04 : sta $20
lda $00 : sta $21 : sta $0601 : sta $0605
lda $01 : sta $aa
lda $0e : asl : ora $ac : sta $ac
lda $e9 : and #$01 : asl #2 : tax : lda $0603, x : sta $e9
lda.b Scrap04 : sta.b $20
lda.b Scrap00 : sta.b $21 : sta.w $0601 : sta.w $0605
lda.b Scrap01 : sta.b $aa
lda.b Scrap0E : asl : ora.b $ac : sta.b $ac
lda.b BG2V+1 : and.b #$01 : asl #2 : tax : lda.w $0603, x : sta.b BG2V+1
rts
LimitYCamera:
cmp #$006c : !bge +
lda #$0000 : bra .end
+ cmp #$017d : !blt +
lda #$0110 : bra .end
+ !sub #$006c
cmp.w #$006c : !bge +
lda.w #$0000 : bra .end
+ cmp.w #$017d : !blt +
lda.w #$0110 : bra .end
+ !sub.w #$006c
.end rts
CheckRoomLayoutY:
jsr LoadRoomLayout ;switches to 8-bit
cmp #$00 : beq .lock
cmp #$07 : beq .free
cmp #$01 : beq .free
cmp #$04 : !bge .lock
cmp #$02 : bne +
lda $06 : cmp #$ff : beq .lock
+ cmp #$03 : bne .free
lda $06 : cmp #$ff : bne .lock
cmp.b #$00 : beq .lock
cmp.b #$07 : beq .free
cmp.b #$01 : beq .free
cmp.b #$04 : !bge .lock
cmp.b #$02 : bne +
lda.b Scrap06 : cmp.b #$ff : beq .lock
+ cmp.b #$03 : bne .free
lda.b Scrap06 : cmp.b #$ff : bne .lock
.free rep #$30 : clc : rts
.lock rep #$30 : sec : rts
@@ -100,123 +100,123 @@ AdjustCameraBoundsY:
jsr CheckRoomLayoutY : bcc .free
; layouts that are camera locked (quads only)
lda $04 : and #$00ff : cmp #$007d : !blt +
lda #$0088 : bra ++
+ cmp #$006d : !bge +
lda #$0078 : bra ++
+ !add #$000b
lda.b Scrap04 : and.w #$00ff : cmp.w #$007d : !blt +
lda.w #$0088 : bra ++
+ cmp.w #$006d : !bge +
lda.w #$0078 : bra ++
+ !add.w #$000b
; I think we no longer need the $02 variable
++ sta $02 : lda $04 : and #$0100 : !add $02 : bra .setBounds
++ sta.b Scrap02 : lda.b Scrap04 : and.w #$0100 : !add.b Scrap02 : bra .setBounds
; layouts where the camera is free
.free lda $04 : cmp #$006c : !bge +
lda #$0077 : bra .setBounds
+ cmp #$017c : !blt +
lda #$0187 : bra .setBounds
+ !add #$000b
.setBounds sta $0618 : inc #2 : sta $061a
.free lda.b Scrap04 : cmp.w #$006c : !bge +
lda.w #$0077 : bra .setBounds
+ cmp.w #$017c : !blt +
lda.w #$0187 : bra .setBounds
+ !add.w #$000b
.setBounds sta.w $0618 : inc #2 : sta.w $061a
rts
LoadRoomLayout:
lda $a0 : asl : !add $a0 : tax
lda $1f8001, x : sta $b8
lda $1f8000, x : sta $b7
lda.b RoomIndex : asl : !add.b RoomIndex : tax
lda.l RoomData_ObjectDataPointers+1, x : sta.b $b8
lda.l RoomData_ObjectDataPointers, x : sta.b $b7
sep #$30
ldy #$01 : lda [$b7], y : and #$1c : lsr #2
ldy.b #$01 : lda.b [$b7], y : and.b #$1c : lsr #2
rts
; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0
; uses $00-$03 and $0e for calculation
; also set up $ac
ScrollX: ;change the X offset variables
lda $a0 : and.b #$0f : asl : sta $060b : inc : sta $060f
lda.b RoomIndex : and.b #$0f : asl : sta.w $060b : inc : sta.w $060f
lda $05 : bne +
lda $60b : sta $00 : stz $01 : bra ++
+ lda $60f : sta $00 : lda #$01 : sta $01
lda.b Scrap05 : bne +
lda.w $060b : sta.b Scrap00 : stz.b Scrap01 : bra ++
+ lda.w $060f : sta.b Scrap00 : lda.b #$01 : sta.b Scrap01
++ ; $01 now contains 0 or 1 and $00 contains the correct long
stz $0e ; pos/neg indicator
stz.b Scrap0E ; pos/neg indicator
rep #$30
lda $00 : pha
lda.b Scrap00 : pha
lda $e2 : and #$01ff : sta $02
lda $04 : jsr LimitXCamera : sta $00
lda.b BG2H : and.w #$01ff : sta.b Scrap02
lda.b Scrap04 : jsr LimitXCamera : sta.b Scrap00
jsr CheckRoomLayoutX : bcc +
lda $00 : cmp #$0080 : !bge ++
lda #$0000 : bra .cmpSrll
++ lda #$0100
.cmpSrll sta $00
lda.b Scrap00 : cmp.w #$0080 : !bge ++
lda.w #$0000 : bra .cmpSrll
++ lda.w #$0100
.cmpSrll sta.b Scrap00
;figures out scroll amt
+ lda $00 : cmp $02 : bne +
lda #$0000 : bra .next
+ lda.b Scrap00 : cmp.b Scrap02 : bne +
lda.w #$0000 : bra .next
+ !blt +
!sub $02 : inc $0e : bra .next
+ lda $02 : !sub $00
!sub.b Scrap02 : inc.b Scrap0E : bra .next
+ lda.b Scrap02 : !sub.b Scrap00
.next
sta $ab : lda $04
sta.b $ab : lda.b Scrap04
cmp #$0078 : !bge +
lda #$007f : bra ++
+ cmp #$0178 : !blt +
lda #$017f : bra ++
+ !add #$0007
++ sta $061c : inc #2 : sta $061e
cmp.w #$0078 : !bge +
lda.w #$007f : bra ++
+ cmp.w #$0178 : !blt +
lda.w #$017f : bra ++
+ !add.w #$0007
++ sta.w $061c : inc #2 : sta.w $061e
pla : sta $00
pla : sta.b Scrap00
sep #$30
lda $04 : ldx $046d : bne .straight
sta $22 : bra +
lda.b Scrap04 : ldx.w $046d : bne .straight
sta.b LinkPosX : bra +
.straight
sta $046d ; set X position later
sta.w $046d ; set X position later
+
lda $00 : sta $23 : sta $0609 : sta $060d
lda $01 : sta $a9
lda $0e : asl : ora $ac : sta $ac
lda $e3 : and #$01 : asl #2 : tax : lda $060b, x : sta $e3
lda.b Scrap00 : sta.b LinkPosX+1 : sta.w $0609 : sta.w $060d
lda.b Scrap01 : sta.b LinkQuadrantH
lda.b Scrap0E : asl : ora.b $ac : sta.b $ac
lda.b BG2H+1 : and.b #$01 : asl #2 : tax : lda.w $060b, x : sta.b BG2H+1
rts
LimitXCamera:
cmp #$0079 : !bge +
lda #$0000 : bra .end
+ cmp #$0178 : !blt +
lda #$0178
+ !sub #$0078
cmp.w #$0079 : !bge +
lda.w #$0000 : bra .end
+ cmp.w #$0178 : !blt +
lda.w #$0178
+ !sub.w #$0078
.end rts
CheckRoomLayoutX:
jsr LoadRoomLayout ;switches to 8-bit
cmp #$04 : !blt .lock
cmp #$05 : bne +
lda $06 : cmp #$ff : beq .lock
cmp.b #$04 : !blt .lock
cmp.b #$05 : bne +
lda.b Scrap06 : cmp.b #$ff : beq .lock
+ cmp #$06 : bne .free
lda $06 : cmp #$ff : bne .lock
lda.b Scrap06 : cmp.b #$ff : bne .lock
.free rep #$30 : clc : rts
.lock rep #$30 : sec : rts
ApplyScroll:
rep #$30
lda $ab : and #$01ff : sta $00
lda $ab : and #$0200 : beq +
lda $00e2, y : !add $00 : bra .end
+ lda $00e2, y : !sub $00
lda.b $ab : and.w #$01ff : sta.b Scrap00
lda.b $ab : and.w #$0200 : beq +
lda.w $00e2, y : !add.b Scrap00 : bra .end
+ lda.w $00e2, y : !sub.b Scrap00
.end
sta $00e2, y
sta $00e0, y
stz $ab : sep #$30 : rts
sta.w $00e2, y
sta.w $00e0, y
stz.b $ab : sep #$30 : rts
QuadrantLoadOrderBeforeScroll:
lda $045f : beq .end
lda #$08 : sta $045c ; start with opposite quadrant row
lda.w $045f : beq .end
lda.b #$08 : sta.w $045c ; start with opposite quadrant row
.end
JML $0091c4 ; what we overwrote
JML WaterFlood_BuildOneQuadrantForVRAM ; what we overwrote
QuadrantLoadOrderAfterScroll:
lda $045f : beq .end
stz $045c : stz $045f ; draw other row and clear flag
lda.w $045f : beq .end
stz.w $045c : stz.w $045f ; draw other row and clear flag
.end
JML $0091c4 ; what we overwrote
JML WaterFlood_BuildOneQuadrantForVRAM ; what we overwrote

View File

@@ -1,103 +1,103 @@
RecordStairType: {
pha
lda.l DRMode : beq .norm
REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .norm
REP #$30 : LDA.b PreviousRoom : CMP.w #$00E1 : BCS .norm
CMP #$00DF : BEQ .norm
SEP #$30
lda $0e
cmp #$25 : bcc ++ ; don't record straight staircases
sta $045e
lda.b Scrap0E
cmp.b #$25 : bcc ++ ; don't record straight staircases
sta.w $045e
++ pla : bra +
.norm SEP #$30 : pla : sta $a0
+ lda $063d, x
.norm SEP #$30 : pla : sta.b RoomIndex
+ lda.w $063d, x
rtl
}
SpiralWarp: {
lda.l DRMode : beq .abort ; abort if not DR
REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .abort
CMP #$00DF : BEQ .abort
REP #$30 : LDA.b PreviousRoom : CMP.w #$00E1 : BCS .abort
CMP.w #$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
lda.w $045e : cmp.b #$5e : beq .gtg ; abort if not spiral - intended room is in A!
cmp.b #$5f : beq .gtg
cmp.b #$26 : beq .inroom
.abort
SEP #$30 : stz $045e : lda $a2 : and.b #$0f : rtl ; clear,run hijacked code and get out
SEP #$30 : stz.w $045e : lda.b PreviousRoom : 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
lda.b PreviousRoom : and.b #$0f ; this is the code we are hijacking
rtl
.gtg
phb : phk : plb : phx : phy ; push stuff
jsr LookupSpiralOffset
rep #$30 : and #$00FF : asl #2 : tax
lda.w SpiralTable, x : sta $00
lda.w SpiralTable+2, x : sta $02
rep #$30 : and.w #$00FF : asl #2 : tax
lda.w SpiralTable, x : sta.b Scrap00
lda.w SpiralTable+2, x : sta.b Scrap02
sep #$30
lda $00 : sta $a0
lda.b Scrap00 : sta.b RoomIndex
; shift quadrant if necessary
stz $07 ; this is a x quad adjuster for those blasted staircase on the edges
lda $01 : and #$01 : !sub $a9
stz.b Scrap07 ; this is a x quad adjuster for those blasted staircase on the edges
lda.b Scrap01 : and.b #$01 : !sub.b LinkQuadrantH
bne .xQuad
lda $0462 : and #$04 : bne .xqCont
inc $07
.xqCont lda $22 : bne .skipXQuad ; this is an edge case
dec $23 : bra .skipXQuad ; need to -1 if $22 is 0
.xQuad sta $06 : !add $a9 : sta $a9
lda $0462 : and #$04 : bne .xCont
inc $07 ; up stairs are going to -1 the quad anyway during transition, need to add this back
.xCont ldy #$00 : jsr ShiftQuadSimple
lda.w $0462 : and.b #$04 : bne .xqCont
inc.b Scrap07
.xqCont lda.b LinkPosX : bne .skipXQuad ; this is an edge case
dec.b LinkPosX+1 : bra .skipXQuad ; need to -1 if $22 is 0
.xQuad sta.b Scrap06 : !add.b LinkQuadrantH : sta.b LinkQuadrantH
lda.w $0462 : and.b #$04 : bne .xCont
inc.b Scrap07 ; up stairs are going to -1 the quad anyway during transition, need to add this back
.xCont ldy.b #$00 : jsr ShiftQuadSimple
.skipXQuad
lda $aa : lsr : sta $06 : lda $01 : and #$02 : lsr : !sub $06
lda.b LinkQuadrantV : lsr : sta.b Scrap06 : lda.b Scrap01 : and.b #$02 : lsr : !sub.b Scrap06
beq .skipYQuad
sta $06 : asl : !add $aa : sta $aa
ldy #$01 : jsr ShiftQuadSimple
sta.b Scrap06 : asl : !add.b LinkQuadrantV : sta.b LinkQuadrantV
ldy.b #$01 : jsr ShiftQuadSimple
.skipYQuad
lda $01 : and #$04 : lsr : sta $048a ;fix layer calc 0->0 2->1
lda $01 : and #$08 : lsr #2 : sta $0492 ;fix from layer calc 0->0 2->1
lda.b Scrap01 : and.b #$04 : lsr : sta.w $048a ;fix layer calc 0->0 2->1
lda.b Scrap01 : and.b #$08 : lsr #2 : sta.w $0492 ;fix from layer calc 0->0 2->1
; shift lower coordinates
lda $02 : sta $22 : bne .adjY : lda $23 : !add $07 : sta $23
.adjY lda $03 : sta $20 : bne .upDownAdj : inc $21
.upDownAdj ldx #$08
lda $0462 : and #$04 : beq .upStairs
ldx #$fd
lda $01 : and #$80 : bne .set53
lda.b Scrap02 : sta.b LinkPosX : bne .adjY : lda.b LinkPosX+1 : !add.b Scrap07 : sta.b LinkPosX+1
.adjY lda.b Scrap03 : sta.b LinkPosY : bne .upDownAdj : inc.b LinkPosY+1
.upDownAdj ldx.b #$08
lda.w $0462 : and.b #$04 : beq .upStairs
ldx.b #$fd
lda.b Scrap01 : and.b #$80 : bne .set53
; if target is also down adjust by (6,-15)
lda #$06 : !add $20 : sta $20 : lda #$eb : !add $22 : sta $22 : bra .set53
lda.b #$06 : !add.b LinkPosY : sta.b LinkPosY : lda.b #$eb : !add.b LinkPosX : sta.b LinkPosX : bra .set53
.upStairs
lda $01 : and #$80 : beq .set53
lda.b Scrap01 : and.b #$80 : beq .set53
; if target is also up adjust by (-6, 14)
lda #$fa : !add $20 : sta $20 : lda #$14 : !add $22 : sta $22
bne .set53 : inc $23
lda.b #$fa : !add.b LinkPosY : sta.b LinkPosY : lda.b #$14 : !add.b LinkPosX : sta.b LinkPosX
bne .set53 : inc.b LinkPosX+1
.set53
txa : !add $22 : sta $53
txa : !add.b LinkPosX : sta.b $53
lda $01 : and #$10 : sta $07 ; zeroHzCam check
ldy #$00 : jsr SetCamera
lda $01 : and #$20 : sta $07 ; zeroVtCam check
ldy #$01 : jsr SetCamera
lda.b Scrap01 : and.b #$10 : sta.b Scrap07 ; zeroHzCam check
ldy.b #$00 : jsr SetCamera
lda.b Scrap01 : and.b #$20 : sta.b Scrap07 ; zeroVtCam check
ldy.b #$01 : jsr SetCamera
jsr StairCleanup
ply : plx : plb ; pull the stuff we pushed
lda $a2 : and #$0f ; this is the code we are hijacking
lda.b PreviousRoom : and.b #$0f ; this is the code we are hijacking
rtl
}
StairCleanup: {
stz $045e ; clear the staircase flag
stz.w $045e ; clear the staircase flag
; animated tiles fix
lda.l DRMode : cmp #$02 : bne + ; only do this in crossed mode
ldx $a0 : lda.l TilesetTable, x
cmp $0aa1 : beq + ; already eq no need to decomp
sta $0aa1
tax : lda $02802e, x : tay
ldx.b RoomIndex : lda.l TilesetTable, x
cmp.w $0aa1 : beq + ; already eq no need to decomp
sta.w $0aa1
tax : lda.l AnimatedTileSheets, x : tay
jsl DecompDungAnimatedTiles
+
stz $047a
stz.w LayerAdjustment
rts
}
@@ -110,58 +110,58 @@ LookupSpiralOffset_long:
LookupSpiralOffset: {
;where link currently is in $a2: quad in a8 & #$03
;count doors
stz $00 : ldx #$00 : stz $01
stz.b Scrap00 : ldx.b #$00 : stz.b Scrap01
.loop
lda $047e, x : cmp $00 : bcc .continue
sta $00
lda.w $047e, x : cmp.b Scrap00 : bcc .continue
sta.b Scrap00
.continue inx #2
cpx #$08 : bcc .loop
cpx.b #$08 : bcc .loop
lda $00 : lsr
cmp #$01 : beq .done
lda.b Scrap00 : lsr
cmp.b #$01 : beq .done
; look up the quad
lda $a9 : ora $aa : and #$03 : beq .quad0
cmp #$01 : beq .quad1
cmp #$02 : beq .quad2
lda.b LinkQuadrantH : ora.b LinkQuadrantV : and.b #$03 : beq .quad0
cmp.b #$01 : beq .quad1
cmp.b #$02 : beq .quad2
bra .quad3
.quad0
inc $01 : lda $a2
cmp #$0c : beq .q0diff ;gt ent
cmp #$70 : bne .done ;hc stairwell
.q0diff lda $22 : cmp #$00 : beq .secondDoor
cmp #$98 : bcc .done ;gt ent and hc stairwell
.secondDoor inc $01 : bra .done
inc.b Scrap01 : lda.b PreviousRoom
cmp.b #$0c : beq .q0diff ;gt ent
cmp.b #$70 : bne .done ;hc stairwell
.q0diff lda.b LinkPosX : cmp.b #$00 : beq .secondDoor
cmp.b #$98 : bcc .done ;gt ent and hc stairwell
.secondDoor inc.b Scrap01 : bra .done
.quad1
lda $a2
cmp #$1a : beq .q1diff ;pod compass
cmp #$26 : beq .q1diff ;swamp elbows
cmp #$6a : beq .q1diff ;pod dark basement
cmp #$76 : bne .done ;swamp drain
.q1diff lda $22 : cmp #$98 : bcc .done
inc $01 : bra .done
lda.b PreviousRoom
cmp.b #$1a : beq .q1diff ;pod compass
cmp.b #$26 : beq .q1diff ;swamp elbows
cmp.b #$6a : beq .q1diff ;pod dark basement
cmp.b #$76 : bne .done ;swamp drain
.q1diff lda.b LinkPosX : cmp.b #$98 : bcc .done
inc.b Scrap01 : bra .done
.quad2
lda #$03 : sta $01 : lda $a2
cmp #$5f : beq .iceu ;ice u room
cmp #$3f : bne .done ;hammer ice exception
stz $01 : bra .done
.iceu lda $22 : cmp #$78 : bcc .done
inc $01 : bra .done
lda.b #$03 : sta.b Scrap01 : lda.b PreviousRoom
cmp.b #$5f : beq .iceu ;ice u room
cmp.b #$3f : bne .done ;hammer ice exception
stz.b Scrap01 : bra .done
.iceu lda.b LinkPosX : cmp.b #$78 : bcc .done
inc.b Scrap01 : bra .done
.quad3
lda $a2 : cmp #$40 : beq .done ; top of aga exception
lda #$02 : sta $01 ; always 2
lda.b PreviousRoom : cmp.b #$40 : beq .done ; top of aga exception
lda.b #$02 : sta.b Scrap01 ; always 2
.done
lda $a2 : tax : lda.w SpiralOffset,x
!add $01 ;add a thing (0 in easy case)
lda.b PreviousRoom : tax : lda.w SpiralOffset,x
!add.b Scrap01 ;add a thing (0 in easy case)
rts
}
InroomStairsWarp: {
phb : phk : plb : phx : phy ; push stuff
; find stairs by room and store index in X
lda $a0 : ldx #$07
lda.b RoomIndex : ldx.b #$07
.loop
cmp.w InroomStairsRoom,x
beq .found
@@ -169,94 +169,94 @@ InroomStairsWarp: {
bne .loop
.found
rep #$30
txa : and #$00ff : asl : tay
lda.w InroomStairsTable,y : sta $00
txa : and.w #$00ff : asl : tay
lda.w InroomStairsTable,y : sta.b Scrap00
sep #$30
sta $a0
sta.b RoomIndex
; set position and everything else based on target door type
txa : and #$01 : eor #$01 : sta $07
txa : and.b #$01 : eor.b #$01 : sta.b Scrap07
; should be the same as lda $0462 : and #$04 : lsr #2 : eor #$01 : sta $07
lda $01 : and #$80 : beq .notEdge
lda $07 : sta $03 : beq +
lda $01 : jsr LoadSouthMidpoint : sta $22 : lda #$f4
lda.b Scrap01 : and.b #$80 : beq .notEdge
lda.b Scrap07 : sta.b Scrap03 : beq +
lda.b Scrap01 : jsr LoadSouthMidpoint : sta.b LinkPosX : lda.b #$f4
bra ++
+
lda $01 : jsr LoadNorthMidpoint : sta $22 : dec $21 : lda #$f7
lda.b Scrap01 : jsr LoadNorthMidpoint : sta.b LinkPosX : dec.b LinkPosY+1 : lda.b #$f7
++
sta $20
lda $01 : and #$20 : beq +
lda #$01
sta.b LinkPosY
lda.b Scrap01 : and.b #$20 : beq +
lda.b #$01
+
sta $02
stz $07
lda $01 : and #$10 : lsr #4
sta.b Scrap02
stz.b Scrap07
lda.b Scrap01 : and.b #$10 : lsr #4
JMP .layer
.notEdge
lda $01 : and #$03 : cmp #$03 : bne .normal
txa : and #$06 : sta $07
lda $01 : and #$30 : lsr #3 : tay
lda.w InroomStairsX+1,y : sta $02
lda.w InroomStairsY+1,y : sta $03
cpy $07 : beq .vanillaTransition
lda.w InroomStairsX,y : sta $22
lda.b Scrap01 : and.b #$03 : cmp.b #$03 : bne .normal
txa : and.b #$06 : sta.b Scrap07
lda.b Scrap01 : and.b #$30 : lsr #3 : tay
lda.w InroomStairsX+1,y : sta.b Scrap02
lda.w InroomStairsY+1,y : sta.b Scrap03
cpy.b Scrap07 : beq .vanillaTransition
lda.w InroomStairsX,y : sta.b LinkPosX
lda.w InroomStairsY,y
ldy $07 : beq +
ldy.b Scrap07 : beq +
!add #$07
+
sta $20
inc $07
sta.b LinkPosY
inc.b Scrap07
bra ++
.vanillaTransition
lda #$c0 : sta $07 ; leave camera
lda.b #$c0 : sta.b Scrap07 ; leave camera
++
%StonewallCheck($1b)
lda $01 : and #$04 : lsr #2
lda.b Scrap01 : and.b #$04 : lsr #2
bra .layer
.normal
lda $01 : sta $fe ; trap door
lda $07 : sta $03 : beq +
lda $01 : and #$04 : bne .specialFix
lda #$e0 : bra ++
lda.b Scrap01 : sta.b $fe ; trap door
lda.b Scrap07 : sta.b Scrap03 : beq +
lda.b Scrap01 : and.b #$04 : bne .specialFix
lda.b #$e0 : bra ++
.specialFix
lda #$c8 : bra ++
lda.b #$c8 : bra ++
+
%StonewallCheck($43)
lda $01 : and #$04 : bne +
lda #$1b : bra ++
+ lda #$33
++ sta $20
inc $07 : stz $02 : lda #$78 : sta $22
lda $01 : and #$03 : beq ++
cmp #$02 : !bge +
lda #$f8 : sta $22 : stz $07 : bra ++
+ inc $02
lda.b Scrap01 : and.b #$04 : bne +
lda.b #$1b : bra ++
+ lda.b #$33
++ sta.b LinkPosY
inc.b Scrap07 : stz.b Scrap02 : lda.b #$78 : sta.b LinkPosX
lda.b Scrap01 : and.b #$03 : beq ++
cmp.b #$02 : !bge +
lda.b #$f8 : sta.b LinkPosX : stz.b Scrap07 : bra ++
+ inc.b Scrap02
++
lda $01 : and #$04 : lsr #2
lda.b Scrap01 : and.b #$04 : lsr #2
.layer
sta $ee
sta.b LinkLayer
bne +
stz $0476
stz.w $0476
+
lda $02 : !sub $a9
lda.b Scrap02 : !sub.b LinkQuadrantH
beq .skipXQuad
sta $06 : !add $a9 : sta $a9
ldy #$00 : jsr ShiftQuadSimple
sta.b Scrap06 : !add.b LinkQuadrantH : sta.b LinkQuadrantH
ldy.b #$00 : jsr ShiftQuadSimple
.skipXQuad
lda $aa : lsr : sta $06 : lda $03 : !sub $06
lda.b LinkQuadrantV : lsr : sta.b Scrap06 : lda.b Scrap03 : !sub.b Scrap06
beq .skipYQuad
sta $06 : asl : !add $aa : sta $aa
ldy #$01 : jsr ShiftQuadSimple
sta.b Scrap06 : asl : !add.b LinkQuadrantV : sta.b LinkQuadrantV
ldy.b #$01 : jsr ShiftQuadSimple
.skipYQuad
lda $07 : bmi .skipCamera
ldy #$00 : jsr SetCamera ; horizontal camera
ldy #$01 : sty $07 : jsr SetCamera ; vertical camera
lda $20 : cmp #$e0 : bcc +
lda $e8 : bne +
lda #$10 : sta $e8 ; adjust vertical camera at bottom
lda.b Scrap07 : bmi .skipCamera
ldy.b #$00 : jsr SetCamera ; horizontal camera
ldy.b #$01 : sty.b Scrap07 : jsr SetCamera ; vertical camera
lda.b LinkPosY : cmp.b #$e0 : bcc +
lda.b BG2V : bne +
lda.b #$10 : sta.b BG2V ; adjust vertical camera at bottom
+
.skipCamera
@@ -267,72 +267,72 @@ InroomStairsWarp: {
ShiftQuadSimple: {
lda.w CoordIndex,y : tax
lda $20,x : beq .skip
lda $21,x : !add $06 : sta $21,x ; coordinate update
lda.b LinkPosY,x : beq .skip
lda.b LinkPosY+1,x : !add.b Scrap06 : sta.b LinkPosY+1,x ; coordinate update
.skip
lda.w CamQuadIndex,y : tax
lda $0601,x : !add $06 : sta $0601,x
lda $0605,x : !add $06 : sta $0605,x ; high bytes of these guys
lda.w $0601,x : !add.b Scrap06 : sta.w $0601,x
lda.w $0605,x : !add.b Scrap06 : sta.w $0605,x ; high bytes of these guys
rts
}
SetCamera: {
stz $04
tyx : lda $a9,x : bne .nonZeroHalf
lda.w CamQuadIndex,y : tax : lda $607,x : pha
lda.w CameraIndex,y : tax : pla : cmp $e3, x : bne .noQuadAdj
dec $e3,x
stz.b Scrap04
tyx : lda.b LinkQuadrantH,x : bne .nonZeroHalf
lda.w CamQuadIndex,y : tax : lda.w $0607,x : pha
lda.w CameraIndex,y : tax : pla : cmp.b BG2H+1, x : bne .noQuadAdj
dec.b BG2H+1,x
.noQuadAdj
lda $07 : bne .adj0
lda.b Scrap07 : bne .adj0
lda.w CoordIndex,y : tax
lda $20,x : beq .oddQuad
cmp #$79 : bcc .adj0
!sub #$78 : sta $04
tya : asl : !add #$04 : tax : jsr AdjCamBounds : bra .done
lda.b LinkPosY,x : beq .oddQuad
cmp.b #$79 : bcc .adj0
!sub.b #$78 : sta.b Scrap04
tya : asl : !add.b #$04 : tax : jsr AdjCamBounds : bra .done
.oddQuad
lda #$80 : sta $04 : bra .adj1 ; this is such a weird case - quad cross boundary
lda.b #$80 : sta.b Scrap04 : bra .adj1 ; this is such a weird case - quad cross boundary
.adj0
tya : asl : tax : jsr AdjCamBounds : bra .done
.nonZeroHalf ;meaning either right half or bottom half
lda $07 : bne .setQuad
lda.b Scrap07 : bne .setQuad
lda.w CoordIndex,y : tax
lda $20,x : cmp #$78 : bcs .setQuad
!add #$78 : sta $04
lda.w CamQuadIndex,y : tax : lda $0603, x : pha
lda.w CameraIndex,y : tax : pla : sta $e3, x
lda.b LinkPosY,x : cmp.b #$78 : bcs .setQuad
!add.b #$78 : sta.b Scrap04
lda.w CamQuadIndex,y : tax : lda.w $0603, x : pha
lda.w CameraIndex,y : tax : pla : sta.b BG2H+1, x
.adj1
tya : asl : !add #$08 : tax : jsr AdjCamBounds : bra .done
tya : asl : !add.b #$08 : tax : jsr AdjCamBounds : bra .done
.setQuad
lda.w CamQuadIndex,y : tax : lda $0607, x : pha
lda.w CameraIndex,y : tax : pla : sta $e3, x
tya : asl : !add #$0c : tax : jsr AdjCamBounds : bra .done
lda.w CamQuadIndex,y : tax : lda.w $0607, x : pha
lda.w CameraIndex,y : tax : pla : sta.b BG2H+1, x
tya : asl : !add.b #$0c : tax : jsr AdjCamBounds : bra .done
.done
lda.w CameraIndex,y : tax
lda $04 : sta $e2, x
lda.b Scrap04 : sta.b BG2H, x
rts
}
; input, expects X to be an appropriate offset into the CamBoundBaseLine table
; when $04 is 0 no coordinate are added
AdjCamBounds: {
rep #$20 : lda.w CamBoundBaseLine, x : sta $05
lda $04 : and #$00ff : beq .common
rep #$20 : lda.w CamBoundBaseLine, x : sta.b Scrap05
lda.b Scrap04 : and.w #$00ff : beq .common
lda.w CoordIndex,y : tax
lda $20, x : and #$00ff : !add $05 : sta $05
lda.b LinkPosY, x : and.w #$00ff : !add.b Scrap05 : sta.b Scrap05
.common
lda.w OppCamBoundIndex,y : tax
lda $05 : sta $0618, x
inc #2 : sta $061A, x : sep #$20
lda.b Scrap05 : sta.w CameraScrollN, x
inc #2 : sta.w CameraScrollS, x : sep #$20
rts
}
SpiralPriorityHack: {
lda.l DRMode : beq +
lda #$01 : rtl ; always skip the priority code - until I figure out how to fix it
+ lda $0462 : and #$04 ; what we wrote over
lda.b #$01 : rtl ; always skip the priority code - until I figure out how to fix it
+ lda.w $0462 : and.b #$04 ; what we wrote over
rtl
}