Update BookOfSecrets to use L button, re-enable DUNGEON MAPS

This commit is contained in:
scawful
2024-03-07 17:10:16 -05:00
parent 54995e965c
commit 8e5a17384d

View File

@@ -1,9 +1,8 @@
; ============================================================================= ; =========================================================
; Book of Secrets (Reveal Secrets with Book of Mudora) ; Book of Secrets (Reveal Secrets with Book of Mudora)
; Makes BG2 Disappear when pressing X+R ; Makes BG2 Disappear when holding L in a building
; Based on the Parallel Worlds feature ; 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) ; Layer Flags: xxxsabcd (i count BG from 1 to 4 - MathOnNapkins RAM-Map counts from 0 to 3)
; s - Sprite layer enabled ; s - Sprite layer enabled
; a - BG4 enabled ; a - BG4 enabled
@@ -11,45 +10,39 @@
; c - BG2 enabled ; c - BG2 enabled
; d - (BG1 disabled) --> only works properly if the room uses the feature "BG2 on Top" ; d - (BG1 disabled) --> only works properly if the room uses the feature "BG2 on Top"
; ;
; Written by XaserLE ; Originally by XaserLE, updated by scawful
; Edited by scawful
; =============================================================================
; ============================================================================= ; =========================================================
; 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 ; long subroutine that is executed every frame
org $068365
JSL LinkItem_SecretsBook ; overwrite it (originally JSL $099F91)
; ============================================================================= org $068365
JSL LinkItem_SecretsBook ; overwrite it (originally JSL $099F91)
; =========================================================
pullpc pullpc
LinkItem_SecretsBook: LinkItem_SecretsBook:
{ {
LDA $1B ; load data that tells us whether we are in a building or not ; Check if we are in a building
AND #$01 ; are we in a building? LDA $1B : AND #$01 : BEQ .end
BEQ .end ; if not, don't use the x-button-secret
; ---------- ; ----------
LDA $7EF34D ; load book of mudora slot ; Check if we have the book of secrets
CMP #$01 ; do we have the moon pearl? LDA $7EF34D : CMP #$01 : BNE $0F ; if not, go to enable BG2
BNE $0F ; if not, go to enable BG2
LDA $F2 ; load unfiltered joypad 1 register (AXLR|????) ; load unfiltered joypad 1 register (AXLR|????)
AND #$50 ; delete all bits except those for X and R ; delete all bits except those for L
SEC ; set carry for the following subtraction LDA $F2 : AND #$20
SBC #$50 ; X+R button pressed? (if yes, zero flag is set)
BNE $06 ; if not, go to enable BG2 ; L button pressed? (if yes, zero flag is set)
LDA $1C ; load layer flags SEC : SBC #$20 : BNE $06 ; if not, go to enable BG2
AND #$FD ; disable BG2 (0xFD = 11111101)
BRA $04 ; go to store layer flags ; load layer flags and disable BG2 (0xFD = 11111101)
LDA $1C ; load layer flags LDA $1C : AND #$FD : BRA $04 ; go to store layer flags
ORA #$02 ; enable BG2 (0x02 = 00000010)
STA $1C ; store layer flags ; enable BG2 (0x02 = 00000010)
LDA $1C : ORA #$02 : STA $1C
; ---------- ; ----------
.end .end
@@ -59,6 +52,3 @@ LinkItem_SecretsBook:
print "End of Items/book_of_secrets.asm ", pc print "End of Items/book_of_secrets.asm ", pc
pushpc pushpc
; =============================================================================