Refactor book code, close namespaces, housekeeping

This commit is contained in:
scawful
2023-02-05 01:28:35 -06:00
parent d114a90fd2
commit 41fa5a5ec7
11 changed files with 116 additions and 110 deletions

View File

@@ -120,3 +120,4 @@ namespace Debug
RTL RTL
} }
} }
namespace off

View File

@@ -156,3 +156,4 @@ namespace LostSea
} ; label LOST_WOOD_HOOK } ; label LOST_WOOD_HOOK
} ; label Main } ; label Main
} ; namespace LostSea } ; namespace LostSea
namespace off

View File

@@ -1,10 +1,57 @@
;=========================================================== ; =============================================================================
; Book of Secrets ; Book of Secrets (Reveal Secrets with Book of Mudora)
; Makes BG2 Disappear when pressing X+R
; Based on the Parallel Worlds feature
; ;
; Bank 0x3C used for whole code
; Layer Flags: xxxsabcd (i count BG from 1 to 4 - MathOnNapkins RAM-Map counts from 0 to 3)
; s - Sprite layer enabled
; a - BG4 enabled
; b - BG3 enabled
; c - BG2 enabled
; d - (BG1 disabled) --> only works properly if the room uses the feature "BG2 on Top"
; ;
;=========================================================== ; Written by XaserLE
; Edited by scawful
; =============================================================================
namespace Book ; =============================================================================
{ ; code that branches behind the dungeon map load if player didn't press X
incsrc "reveal_secrets.asm" org $0288FD
} ; namespace Book BRA $1C ; make it always branch, so map isn't loaded anymore
; =============================================================================
; long subroutine that is executed every frame
org $068365
JSL $3CA600 ; overwrite it (originally JSL $099F91)
; =============================================================================
; go to expanded space to write our routine
; (keep EveryFrame.asm in mind for the right adresses)
org $3CA600
LDA $1B ; load data that tells us whether we are in a building or not
AND #$01 ; are we in a building?
BEQ END ; if not, don't use the x-button-secret
; ----------
LDA $7EF34D ; load book of mudora slot
CMP #$01 ; do we have the moon pearl?
BNE $0F ; if not, go to enable BG2
LDA $F2 ; load unfiltered joypad 1 register (AXLR|????)
AND #$50 ; delete all bits except those for X and R
SEC ; set carry for the following subtraction
SBC #$50 ; X+R button pressed? (if yes, zero flag is set)
BNE $06 ; if not, go to enable BG2
LDA $1C ; load layer flags
AND #$FD ; disable BG2 (0xFD = 11111101)
BRA $04 ; go to store layer flags
LDA $1C ; load layer flags
ORA #$02 ; enable BG2 (0x02 = 00000010)
STA $1C ; store layer flags
; ----------
END:
JSL $099F91 ; at least execute original code
RTL
; =============================================================================

View File

@@ -162,3 +162,4 @@ namespace IceRod
STA $1D,s STA $1D,s
} }
} ; namespace IceRod } ; namespace IceRod
namespace off

View File

@@ -1,53 +0,0 @@
;===========================================================
; Reveal Secrets with Book of Mudora
; Makes BG2 Disappear when pressing X+R
; Based on the Parallel Worlds feature
;
; Bank 0x3C used for whole code
; Layer Flags: xxxsabcd (i count BG from 1 to 4 - MathOnNapkins RAM-Map counts from 0 to 3)
; s - Sprite layer enabled
; a - BG4 enabled
; b - BG3 enabled
; c - BG2 enabled
; d - (BG1 disabled) --> only works properly if the room uses the feature "BG2 on Top"
;
; Written by XaserLE
; Edited by scawful
;===========================================================
Reveal_Secrets:
{
lorom
ORG $0288FD ; go to the code that branches behind the dungeon map load if player didn't press X
BRA $1C ; make it always branch, so map isn't loaded anymore
ORG $068365 ; go to an originally JSL that is executed every frame
JSL $3CA600 ; overwrite it (originally JSL $099F91)
ORG $3CA600 ; go to expanded space to write our routine (keep EveryFrame.asm in mind for the right adresses)
LDA $1B ; load data that tells us whether we are in a building or not
AND #$01 ; are we in a building?
BEQ END ; if not, don't use the x-button-secret
; ----------
LDA $7EF34D ; load book of mudora slot
CMP #$01 ; do we have the moon pearl?
BNE $0F ; if not, go to enable BG2
LDA $F2 ; load unfiltered joypad 1 register (AXLR|????)
AND #$50 ; delete all bits except those for X and R
SEC ; set carry for the following subtraction
SBC #$50 ; X+R button pressed? (if yes, zero flag is set)
BNE $06 ; if not, go to enable BG2
LDA $1C ; load layer flags
AND #$FD ; disable BG2 (0xFD = 11111101)
BRA $04 ; go to store layer flags
LDA $1C ; load layer flags
ORA #$02 ; enable BG2 (0x02 = 00000010)
STA $1C ; store layer flags
; ----------
END:
JSL $099F91 ; at least execute original code
RTL
}

View File

@@ -17,37 +17,31 @@
; HM x and y value of the position of the key block must end with: 0, 2, 4, 6, 8, A, C, E. ; HM x and y value of the position of the key block must end with: 0, 2, 4, 6, 8, A, C, E.
;=========================================================== ;===========================================================
namespace KeyBlock lorom
{
Main: {
lorom
ORG $01EB8C ; go to the code that loads the big key holding variable ORG $01EB8C ; go to the code that loads the big key holding variable
LDA $7EF36F ; load the small key counter LDA $7EF36F ; load the small key counter
AND #$00FF ; check if we have at least one small key (AND will not be zero) AND #$00FF ; check if we have at least one small key (AND will not be zero)
BEQ $4C ; if not (AND is zero), don't do anything and especially don't give this "Eh? It's locked..." - message BEQ $4C ; if not (AND is zero), don't do anything and especially don't give this "Eh? It's locked..." - message
; otherwise we will decrement the small key counter and branch to the code that opens the prison door ; otherwise we will decrement the small key counter and branch to the code that opens the prison door
LDA $7EF36F ; reload small key counter LDA $7EF36F ; reload small key counter
DEC A ; remove one key DEC A ; remove one key
STA $7EF36F ; save the new value at small key counter position STA $7EF36F ; save the new value at small key counter position
BRA $05 ; branch to the code that opens the prison door BRA $05 ; branch to the code that opens the prison door
; now correct a drawing bug in the original game that causes the floor tile under the door drawed odd ; now correct a drawing bug in the original game that causes the floor tile under the door drawed odd
ORG $01EBC8 ORG $01EBC8
LDA.w $9B5A,y LDA.w $9B5A,y
ORG $01EBD1 ORG $01EBD1
LDA.w $9B54,y LDA.w $9B54,y
ORG $01EBDA ORG $01EBDA
LDA.w $9B5C,y LDA.w $9B5C,y
; draw values representation ; draw values representation
; 50- / ; 50- /
; 52- normal ; 52- normal
; 54- x mirror ; 54- x mirror
; 56- normal ; 56- normal
; 58- x mirror ; 58- x mirror
; 5A- y mirror ; 5A- y mirror
; 5C- xy mirror ; 5C- xy mirror
; 5E- y mirror ; 5E- y mirror
} ; label Main
} ; namespace KeyBlock
namespace off

View File

@@ -1,4 +1,4 @@
;=========================================================== ; =============================================================================
; Bunny Hood Item ; Bunny Hood Item
; Makes Link run quicker when holding ; Makes Link run quicker when holding
; Written by Conn (I think) ; Written by Conn (I think)
@@ -17,7 +17,7 @@
; (Default = 0D) ; (Default = 0D)
; db (10) $40 - Pegasus boots speed (Default = 40) ; db (10) $40 - Pegasus boots speed (Default = 40)
; ;
;=========================================================== ; =============================================================================
org $07A494 org $07A494
LinkItem_Ether: LinkItem_Ether:
@@ -46,9 +46,13 @@ LinkItem_Ether:
RTS RTS
} }
; =============================================================================
org $378000 org $378000
incbin gfx/bunny_link.4bpp incbin gfx/bunny_link.4bpp
; =============================================================================
UpdateBunnyPalette: UpdateBunnyPalette:
{ {
REP #$30 ; change 16bit mode REP #$30 ; change 16bit mode
@@ -65,8 +69,13 @@ UpdateBunnyPalette:
bunny_palette: bunny_palette:
dw #$7BDE, #$7FFF, #$2F7D, #$19B5, #$3A9C, #$14A5, #$19FD, #$14B6, #$55BB, #$362A, #$3F4E, #$162B, #$22D0, #$2E5A, #$1970, #$7616, #$6565, #$7271, #$2AB7, #$477E, #$1997, #$14B5, #$459B, #$69F2, #$7AB8, #$2609, #$19D8, #$3D95, #$567C, #$1890, #$52F6, #$2357, #$0000 dw #$7BDE, #$7FFF, #$2F7D, #$19B5, #$3A9C, #$14A5, #$19FD, #$14B6
dw #$55BB, #$362A, #$3F4E, #$162B, #$22D0, #$2E5A, #$1970, #$7616
dw #$6565, #$7271, #$2AB7, #$477E, #$1997, #$14B5, #$459B, #$69F2
dw #$7AB8, #$2609, #$19D8, #$3D95, #$567C, #$1890, #$52F6, #$2357, #$0000
; =============================================================================
; Bunny Hood Speed Modification
org $87E330 org $87E330
JSR $FD66 JSR $FD66

View File

@@ -1,6 +1,10 @@
; Hooks
incsrc "../Sprites/sprite_functions_hooks.asm"
; ============================================================================= ; =============================================================================
; Deku Mask
; =============================================================================
; Hooks
incsrc "../Sprites/sprite_functions_hooks.asm"
org $008A01 org $008A01
LDA $BC LDA $BC

View File

@@ -1,4 +1,5 @@
; ============================================================================= ; =============================================================================
; Wolf Mask
org $07A3DB org $07A3DB
LinkItem_Flute: LinkItem_Flute:
@@ -58,7 +59,7 @@ UpdateWolfPalette:
LDX #$001E LDX #$001E
.loop .loop
LDA.l mypalette, X : STA $7EC6E0, X LDA.l WolfPalette, X : STA $7EC6E0, X
DEX : DEX : BPL .loop DEX : DEX : BPL .loop
SEP #$30 ; go back to 8 bit mode SEP #$30 ; go back to 8 bit mode
@@ -68,13 +69,10 @@ UpdateWolfPalette:
; ============================================================================= ; =============================================================================
mypalette: WolfPalette:
dw #$7BDE, #$7FFF, #$2F7D, #$19B5 dw #$7BDE, #$7FFF, #$2F7D, #$19B5, #$3A9C, #$14A5, #$1A3D, #$14B6
dw #$3A9C, #$14A5, #$1A3D, #$14B6 dw #$4650, #$362A, #$3F4E, #$162B, #$318A, #$39CC, #$1CE7, #$76D1
dw #$4650, #$362A, #$3F4E, #$162B dw #$6565, #$7271, #$14B5, #$459B, #$3D95, #$22D0, #$567C, #$1890
dw #$318A, #$39CC, #$1CE7, #$76D1
dw #$6565, #$7271, #$14B5, #$459B
dw #$3D95, #$22D0, #$567C, #$1890
dw #$7616, #$0000 dw #$7616, #$0000
; ============================================================================= ; =============================================================================

View File

@@ -26,5 +26,9 @@ LinkItem_ZoraMask:
RTS RTS
} }
; =============================================================================
org $368000 org $368000
incbin gfx/zora_link.4bpp incbin gfx/zora_link.4bpp
; =============================================================================

View File

@@ -11,7 +11,7 @@
; Significant thanks to Kan for helping me craft this menu! ; Significant thanks to Kan for helping me craft this menu!
; ;
; ============================================================================= ; =============================================================================
incsrc "Util/ram.asm"
pushpc pushpc
; update in game hud colors ; update in game hud colors