Play custom music

Go down

20130731

Post 

Play custom music Empty Play custom music




Information: Load custom overworld music, without the reseting when changing screens. (Original Alttp always resets it to Overworld music when exiting most entrances).
Rom: expanded ALTTP rom (US), without header; pc w/o header ALTTP (US)
Screenshot:

Play custom music Play_c10

Ups Patch: http://bszelda.zeldalegends.net/stuff/Con/custom_music.zip

Code Addresses: main code at $11A200, new music table at $11A300.

ASM
Code:

;CUSTOM MUSIC, ASM BY CONN


;Goal: load custom overworld music, without the reseting when changing screens. (Original Alttp always resets it to Overworld music).


lorom

org $008100
jsr $89d5  ;pc: 00/09d5 (after your sword charge no move)

org $0089d5
jsl $23a200
RTS

org $23a200
TAX ; transfer native value to X
SBC #$0F ; check if theme is in range 00-0F (overworld themes)
BCC $04 ; continue if yes
STZ $012C ; if no, set 012c to 00 and return to game
RTL
LDA $008c ; check overworld
cmp #$00
BNE $0b
LDA $008a
cmp #$00
BNE $04
STZ $012C ; if you are in dungeon/cave, set 012c to 00 and return to game
RTL
TXA ; regain native value X transfer to A
; now a comparison starts of themes you want to have replaced, this is overworld 02, lost woods 05, kakariko 07, dark world 09, skull woods 0d. This is necessary to not replace title screen, introduction, minigame, character selection, rabbit, rain, which is not on the map!
CMP #$02 ; if overworld theme is about to play jump to $A231 and replace, if not check if it is 05 and so forth.
BNE $03
JMP $A243
CMP #$05
BNE $03
JMP $A243
CMP #$07
BNE $03
JMP $A243
CMP #$09
BNE $03
JMP $A243
CMP #$0D
BNE $03
JMP $A243
STZ $012C ; if it is another theme (introduction, title screen -> return to game)
RTL
LDA $012C ; if theme is already loaded return to game (address is loaded twice)
CMP $0131
BNE $04
STZ $012C
RTL
LDX $040A ; load screen number to X
LDA $23A300,x ; select theme from table, in dependence of screen in X
STA $012C ; play theme
STA $2140
STA $0132
RTL

;The table at 11/a300 contains all 07 (kakariko). You simply need to replace these number by the number you like to have played.

;The table beginning at 01/4343 needs to be an exact copy of the table 11/a300 to avoid a music reset everytime you switch screens.


Last edited by Puzzledude on Tue 25 Feb 2014 - 16:47; edited 2 times in total
Puzzledude
Puzzledude

Play custom music Image213

Since : 2012-06-20

Back to top Go down

Share this post on: reddit

Play custom music :: Comments

Conn

Post Sun 14 Nov 2021 - 6:11 by Conn

This patch lets you play custom msu1 music on the overworld and indoors

Code:
; Zelda ALTTP MSU1 patch by Conn
; no video
; should work on all Zelda versions (PAL, NTSC), no header


;header
lorom


org $0080f3
JSL newTrack
NOP
NOP

org $0080d7
JSL msuBusy
NOP



org $A2F700
newTrack:
STA $0133
cmp #$13
bne $03
jmp fanfare
PHA
LDA $2002      ;check if msu found
CMP #$53    
BEQ msuFound
PLA
STA $2140
RTL
msuFound:
LDA #$01
STA $0129  ; set msu busy
PLA
STA $0127  ;store track number
PHA
AND #$F0
CMP #$F0
BEQ endTrack
PLA
PHA
; beginn custom code
PHX
TAX
LDA $A2F900,x
PLX
CMP #$00
BEQ noCustom
CMP #$01
BNE customDungeon
PHX
LDX $040A ; load screen number to X
LDA $A2Fa00,x
PLX
cmp #$FF
BEQ noCustom
XBA
LDA #$02
STA $0129  ; set msu busy
PLA
XBA
BRA playTrack

customDungeon:
LDA $010e
PHX
TAX
LDA $A2Fb00,x
PLX
cmp #$FF
BEQ noCustom
XBA
LDA #$02
STA $0129  ; set msu busy
PLA
XBA
BRA playTrack
noCustom:
PLA
playTrack:
STA $2004
STZ $2005
STZ $2006
PHA
LDA #$F1
STA $2140
PLA
LDA $0127
RTL
endTrack:
LDA $2000
AND #$08
BNE playfade
LDA #$F1
STA $2140
PLA
RTL
playfade:
LDA $0127
STA $2140
PLA
RTL
fanfare:
STA $2140
STZ $2007
wait:
LDA $2140
BEQ wait
STZ $0012
wait2:
LDA $0012
BEQ wait2
RTL

msuBusy:
SEP #$30
LDA $4210
LDA $0129
BNE $01
end:
RTL
LDA $0127
cmp #$f1
beq f1
cmp #$f2
beq f2
cmp #$f3
beq f3
bit $2000
bvs end    ; track not ready
LDA $2000
AND #$08
BNE playSPC

LDA $0127
tax
LDA $0129
cmp #$02
BEQ $06  
lda $A2F980,x ;load loop value
BRA $02
LDA #$03
sta $2007
STZ $0129  
lda #$FF   ; lautstärke
sta $2006
sta $012b ; fade
bra end
f1:
lda $012b
dec
dec
dec
cmp #$10
bcs $05
lda #$00
sta $0129
sta $2006
sta $012b
jmp end
f2:
lda $012b
dec
dec
dec
cmp #$40
bcs $03
stz $0129
sta $012b
sta $2006
jmp end
f3:
lda $012b
inc
inc
inc
cmp #$fb
bcc $05
stz $0129
lda #$FF
sta $2006
sta $012b
jmp end

playSPC:
STZ $0129  ; clear msu busy flag
LDA $0127
STA $2140
RTL


; set the music for substitute: 00= no substitute 01= overworld substitute 02= dungeon substitute
; e.g., intro/ending credits/crystal/name entry aquired cannot be substituted, while 05 is lost woods (overworld substitute possible), 10 Hyrule Castle (dungeon substitute possible  
org $A2F900
;   00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F
db $00,$00,$01,$00,$00,$01,$00,$01,$00,$01,$00,$00,$00,$01,$02,$00 ; themes 00-0f (overworld)
db $02,$02,$02,$00,$02,$00,$02,$02,$02,$00,$00,$02,$00,$00,$00,$00 ; themes 10-1f (indoors)
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; themes 20-2f (credits)

org $A2F980 ; loop table 03:loop, 01 non-loop
;   00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F
db $03,$01,$03,$03,$03,$03,$03,$03,$01,$03,$01,$03,$03,$03,$03,$01 ; themes 00-0f
db $03,$03,$03,$01,$03,$03,$03,$03,$03,$03,$03,$03,$03,$01,$03,$03 ; themes 10-1f
db $03,$01,$01,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03 ; themes 20-2f


org $A2Fa00 ; overworld substitute tracks: replace ff with the overworld screen - works only in combination with https://www.zeldix.net/t380-play-custom-music)
;   00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen 00-0f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  10-1f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  20-2f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  30-3f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  40-4f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen 50-5f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  60-6f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  70-7f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  80-8f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  90-9f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  a0-af
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  b0-bf
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  c0-cf
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  d0-df
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  e0-ef
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; overworld screen  f0-ff

org $A2Fb00 ; dungeon substitute tracks (entrance 00-155 - $00-$FF): replace ff with the entrance number
;   00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  00-0f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  10-1f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  20-2f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  30-3f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  40-4f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  50-5f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  60-6f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  70-7f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  80-8f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  90-9f
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  a0-af
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  b0-bf
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  c0-cf
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  d0-df
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  e0-ef
db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; dungeon entrance  f0-ff

Attachments
Play custom music Attachment
alttp_msu1_custom.zip You don't have permission to download attachments.(2 Kb) Downloaded 3 times

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum