Problem with using 3 different nsf in 3 switchbank codes.

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Problem with using 3 different nsf in 3 switchbank codes.
by on (#64452)
Hi,
I have to a nes file, wherein i have 3 different games and they re kept in switch bank. So now i want to include different kind of music for all 3 games. So how to do it ?
I tried this ->
i made music.nsf from famitracker and loaded the code at the desired address. So in my main code, i put these lines..


.base $8000
.include quiz_level1.asm

LoadAddy = $AB23
InitAddy = $AB23
PlayAddy = $AB26

.org LoadAddy
.incbin "quiz.nsf"

.org $c000

.base $8000
.include malaria.asm

LoadAddy = $9200
InitAddy = $9200
PlayAddy = $9203

.org LoadAddy
.incbin "malaria.nsf"

.org $c000

.base $8000
.include typing.asm

LoadAddy = $A200
InitAddy = $A200
PlayAddy = $A203

.org LoadAddy
.incbin "typing.nsf"

.org $c000


So, here is this the correct method. The sound is not playing in the 3rd game and distortion happens and after sometime, CPU JAM occurs.

Also are the 3 addresses needed to be the some ?
and where i have to put



InitMusic:

lda #$00
ldx #$00
Clear_Sound:
sta $4000,x
inx
cpx #$0F
bne Clear_Sound



lda #%00001111
STA $4015
lda #$C0
STA $4017

LDA SongNumber ; song number
ldx #$0 ; 00 for NTSC or $01 for PAL
jsr InitAddy ; init address
rts


That is for three different games i put in the main code or in their individual codes ?

thanks

by on (#64454)
You really ought to clear RAM (at least, RAM used by the music code) every time you change music banks, too.

by on (#64466)
Can you be more specific ? like everytime i start the nes game, i will choose only 1 game from 3. then also its necessary to clear it ?

by on (#64480)
It's hard to tell why it's not working, but make sure the addresses are correct and that the files fit within the banks. If it's single song NSFs then SongNumber must be 0 for all songs.
I'd also like to point out that you'll waste some space by including three different NSFs since they can share the player code, but I assume that's easier when using bank switching.

by on (#64500)
I tried but i am getting distortion in other sound.
Also i write

jsr InitMusic

Inf:
jmp inf


InitMusic:

lda #$00
ldx #$00
Clear_Sound:
sta $4000,x
inx
cpx #$0F
bne Clear_Sound



lda #%00001111
STA $4015
lda #$C0
STA $4017

LDA SongNumber ; song number
ldx #$0 ; 00 for NTSC or $01 for PAL
jsr InitAddy ; init address
rts


So here InitAddy stands for 1st song only or is the label common to all ?
and in their respective files, i.e. switchbank codes, do i have to call the jsr Initaddy again ?


@jsr also, i am not able to access #nesdev using efnet.org
error :
465: | [0] eni, [1] You are banned from this server- Temporary K-line 1440 min. - DNSBL listed. Check http://cbl.abuseat.org/lookup.cgi?ip=117.196.101.235 for removal, or email irc@umich.edu. (2010/7/20 12.07)

So please help
thanks