housekeeping

This commit is contained in:
scawful
2022-10-01 02:53:32 -05:00
parent 55ed3943fd
commit 30f2afad04
10 changed files with 53 additions and 64 deletions

10
Items/book_of_secrets.asm Normal file
View File

@@ -0,0 +1,10 @@
;===========================================================
; Book of Secrets
;
;
;===========================================================
namespace Book
{
incsrc "reveal_secrets.asm"
} ; namespace Book

164
Items/ice_rod.asm Normal file
View File

@@ -0,0 +1,164 @@
;===========================================================
; Ice Rod freezes water
; Written by Conn
;
;===========================================================
namespace IceRod
{
Main:
{
lorom
org $088a5d ; jsl to main code
jsl $0efba0
org $0efba0 ; main code
STA $03E4,x ; load native value
TAY
LDA $008C ; check if you're on overworld
BNE $01
RTL
LDA $03A3 ; disable other flying object icing water (boomerang, sword beam)
CMP #$06
BEQ $01
RTL
CPX #$04 ; check if ice shot #1 only is used (disable 2nd shot to ice)
BEQ $01
RTL
LDA $03E8 ; check if ice shot is on water tiles
CMP #$08
BEQ $08
LDA $03E8 ; check if ice shot is on native unused, edited blocks
CMP #$03
BEQ $01
RTL
LDA $0303 ; double check if really ice shot is used
CMP #$06
BEQ $01
RTL
LDA $0304
CMP #$06
BEQ $01
RTL
TXA
STA $7ED004 ; store native x value into ram to regain after code
LDA $4212 ; wait for vblank to enable dma transfer
AND #$80
BEQ $F9
REP #$30
LDA $2116
STA $7ED005 ; store native value to regain later
LDA $00 ; calculation procedure to get correct x,y coordinates for new tile
SEC
SBC $0708
AND $070A
ASL A
ASL A
ASL A
STA $06
LDA $02
SEC
SBC $070C
AND $070E
ORA $06
TAX
LDA #$00B7
STA $7E2000,x ; store new 16x16 ice tile into ram (property of tile!)
CLC
STZ $02 ; calculation procedure to get 8x8 vram map address (look of tile)
TXA
AND #$003F
CMP #$0020
BCC $05
LDA #$0400
STA $02
TXA
AND #$0FFF
CMP #$0800
BCC $07
LDA $02
ADC #$07FF
STA $02
TXA
AND #$001F
ADC $02
STA $02
TXA
AND #$0780
LSR A
ADC $02
STA $2116 ; store vram address for upper tile part (8x16) to $2116
STA $7ED007
LDA #$1D83 ; load new ice tiles
STA $7ED000
STA $7ED002
JSR $FD00 ; jsr to dma vram transfer for upper ice tile part
REP #$30
LDA $7ED007 ; regain vram address
ADC #$0020 ; add 20 for lower part (8x16) and store to $2116
STA $2116
JSR $FD00 ; jsr to dma vram transfer for lower ice tile part
LDA $7ED005 ; regain native register value
STA $2116
SEP #$30
LDA $7ED004 ; regain native x-value
TAX
RTL
org $0efd00 ; vram dma transfer
LDA #$007E ; load origin of bytes to transfer (7E/d000)
STA $4304
LDA #$D000
STA $4302
SEP #$30
LDA #$18 ; bus
STA $4301
LDA #$04 ; transfer 4 bytes
STA $4305
LDA #$01
STA $4300
STA $420B ; make dma transfer
RTS
; bug fix to not swim through tiles but jump onto them
org $07dc9e
jsl $0efc80
nop
org $0efc80
LDA $0A
TSB $0343
TSB $0348
RTL
; bug fix to stop gliding on shallow water when leaving ice tile
org $07dd1b
jsl $0efc90
nop
org $0efc90
LDA $0A
TSB $0359
LDA $0350
CMP #$0100
BNE $03
STZ $034A
RTL
org $0e95dc ; get a 0e written here (first byte) to enable gliding on new tiles
ASL $5757
org $0f85b8 ; get new tile values (83 1d) written 4 times here
STA $1D,s
STA $1D,s
STA $1D,s
STA $1D,s
}
} ; namespace IceRod

53
Items/reveal_secrets.asm Normal file
View File

@@ -0,0 +1,53 @@
;===========================================================
; 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
}