From 41fa5a5ec737a68b8a642da180e2d62d0b96f777 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 5 Feb 2023 01:28:35 -0600 Subject: [PATCH] Refactor book code, close namespaces, housekeeping --- Debug/debug.asm | 3 +- Events/lostsea.asm | 1 + Items/book_of_secrets.asm | 61 ++++++++++++++++++++++++++++++++++----- Items/ice_rod.asm | 3 +- Items/reveal_secrets.asm | 53 ---------------------------------- KeyBlock/keyblock.asm | 58 +++++++++++++++++-------------------- Masks/bunny_hood.asm | 17 ++++++++--- Masks/deku_mask.asm | 8 +++-- Masks/wolf_mask.asm | 14 ++++----- Masks/zora_mask.asm | 6 +++- Menu/menu.asm | 2 +- 11 files changed, 116 insertions(+), 110 deletions(-) delete mode 100644 Items/reveal_secrets.asm diff --git a/Debug/debug.asm b/Debug/debug.asm index 120a3bc..05b190b 100644 --- a/Debug/debug.asm +++ b/Debug/debug.asm @@ -119,4 +119,5 @@ namespace Debug RTL } -} \ No newline at end of file +} +namespace off \ No newline at end of file diff --git a/Events/lostsea.asm b/Events/lostsea.asm index 404b74f..04a3853 100644 --- a/Events/lostsea.asm +++ b/Events/lostsea.asm @@ -156,3 +156,4 @@ namespace LostSea } ; label LOST_WOOD_HOOK } ; label Main } ; namespace LostSea +namespace off \ No newline at end of file diff --git a/Items/book_of_secrets.asm b/Items/book_of_secrets.asm index 4177623..fbbb004 100644 --- a/Items/book_of_secrets.asm +++ b/Items/book_of_secrets.asm @@ -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 -{ - incsrc "reveal_secrets.asm" -} ; namespace Book \ No newline at end of file +; ============================================================================= +; code that branches behind the dungeon map load if player didn't press X +org $0288FD +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 + +; ============================================================================= \ No newline at end of file diff --git a/Items/ice_rod.asm b/Items/ice_rod.asm index c837d56..830e7bb 100644 --- a/Items/ice_rod.asm +++ b/Items/ice_rod.asm @@ -161,4 +161,5 @@ namespace IceRod STA $1D,s STA $1D,s } -} ; namespace IceRod \ No newline at end of file +} ; namespace IceRod +namespace off \ No newline at end of file diff --git a/Items/reveal_secrets.asm b/Items/reveal_secrets.asm deleted file mode 100644 index 88208f9..0000000 --- a/Items/reveal_secrets.asm +++ /dev/null @@ -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 -} diff --git a/KeyBlock/keyblock.asm b/KeyBlock/keyblock.asm index 2e23bbd..fe78ead 100644 --- a/KeyBlock/keyblock.asm +++ b/KeyBlock/keyblock.asm @@ -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. ;=========================================================== -namespace KeyBlock -{ - Main: { - lorom +lorom - ORG $01EB8C ; go to the code that loads the big key holding variable - LDA $7EF36F ; load the small key counter - 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 - ; otherwise we will decrement the small key counter and branch to the code that opens the prison door - LDA $7EF36F ; reload small key counter - DEC A ; remove one key - STA $7EF36F ; save the new value at small key counter position - BRA $05 ; branch to the code that opens the prison door +ORG $01EB8C ; go to the code that loads the big key holding variable +LDA $7EF36F ; load the small key counter +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 + ; otherwise we will decrement the small key counter and branch to the code that opens the prison door +LDA $7EF36F ; reload small key counter +DEC A ; remove one key +STA $7EF36F ; save the new value at small key counter position +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 - ORG $01EBC8 - LDA.w $9B5A,y - ORG $01EBD1 - LDA.w $9B54,y - ORG $01EBDA - LDA.w $9B5C,y - ; draw values representation - ; 50- / - ; 52- normal - ; 54- x mirror - ; 56- normal - ; 58- x mirror - ; 5A- y mirror - ; 5C- xy mirror - ; 5E- y mirror - } ; label Main -} ; namespace KeyBlock -namespace off \ No newline at end of file +; now correct a drawing bug in the original game that causes the floor tile under the door drawed odd +ORG $01EBC8 +LDA.w $9B5A,y +ORG $01EBD1 +LDA.w $9B54,y +ORG $01EBDA +LDA.w $9B5C,y +; draw values representation +; 50- / +; 52- normal +; 54- x mirror +; 56- normal +; 58- x mirror +; 5A- y mirror +; 5C- xy mirror +; 5E- y mirror \ No newline at end of file diff --git a/Masks/bunny_hood.asm b/Masks/bunny_hood.asm index 9287d90..4431bf4 100644 --- a/Masks/bunny_hood.asm +++ b/Masks/bunny_hood.asm @@ -1,4 +1,4 @@ -;=========================================================== +; ============================================================================= ; Bunny Hood Item ; Makes Link run quicker when holding ; Written by Conn (I think) @@ -17,7 +17,7 @@ ; (Default = 0D) ; db (10) $40 - Pegasus boots speed (Default = 40) ; -;=========================================================== +; ============================================================================= org $07A494 LinkItem_Ether: @@ -46,9 +46,13 @@ LinkItem_Ether: RTS } +; ============================================================================= + org $378000 incbin gfx/bunny_link.4bpp +; ============================================================================= + UpdateBunnyPalette: { REP #$30 ; change 16bit mode @@ -65,10 +69,15 @@ UpdateBunnyPalette: 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 CLC diff --git a/Masks/deku_mask.asm b/Masks/deku_mask.asm index a5cba45..a31abf0 100644 --- a/Masks/deku_mask.asm +++ b/Masks/deku_mask.asm @@ -1,6 +1,10 @@ -; Hooks -incsrc "../Sprites/sprite_functions_hooks.asm" ; ============================================================================= +; Deku Mask + +; ============================================================================= +; Hooks + +incsrc "../Sprites/sprite_functions_hooks.asm" org $008A01 LDA $BC diff --git a/Masks/wolf_mask.asm b/Masks/wolf_mask.asm index 528a369..8d9fec1 100644 --- a/Masks/wolf_mask.asm +++ b/Masks/wolf_mask.asm @@ -1,4 +1,5 @@ ; ============================================================================= +; Wolf Mask org $07A3DB LinkItem_Flute: @@ -58,7 +59,7 @@ UpdateWolfPalette: LDX #$001E .loop - LDA.l mypalette, X : STA $7EC6E0, X + LDA.l WolfPalette, X : STA $7EC6E0, X DEX : DEX : BPL .loop SEP #$30 ; go back to 8 bit mode @@ -68,13 +69,10 @@ UpdateWolfPalette: ; ============================================================================= -mypalette: - dw #$7BDE, #$7FFF, #$2F7D, #$19B5 - dw #$3A9C, #$14A5, #$1A3D, #$14B6 - dw #$4650, #$362A, #$3F4E, #$162B - dw #$318A, #$39CC, #$1CE7, #$76D1 - dw #$6565, #$7271, #$14B5, #$459B - dw #$3D95, #$22D0, #$567C, #$1890 +WolfPalette: + dw #$7BDE, #$7FFF, #$2F7D, #$19B5, #$3A9C, #$14A5, #$1A3D, #$14B6 + dw #$4650, #$362A, #$3F4E, #$162B, #$318A, #$39CC, #$1CE7, #$76D1 + dw #$6565, #$7271, #$14B5, #$459B, #$3D95, #$22D0, #$567C, #$1890 dw #$7616, #$0000 ; ============================================================================= \ No newline at end of file diff --git a/Masks/zora_mask.asm b/Masks/zora_mask.asm index 3607a16..2acf404 100644 --- a/Masks/zora_mask.asm +++ b/Masks/zora_mask.asm @@ -26,5 +26,9 @@ LinkItem_ZoraMask: RTS } +; ============================================================================= + org $368000 -incbin gfx/zora_link.4bpp \ No newline at end of file +incbin gfx/zora_link.4bpp + +; ============================================================================= \ No newline at end of file diff --git a/Menu/menu.asm b/Menu/menu.asm index e9f9228..71471ac 100644 --- a/Menu/menu.asm +++ b/Menu/menu.asm @@ -11,7 +11,7 @@ ; Significant thanks to Kan for helping me craft this menu! ; ; ============================================================================= -incsrc "Util/ram.asm" + pushpc ; update in game hud colors