I try make nsf play code on nesasm.. But doesnt work.
http://www.nullsleep.com/treasure/nsf_cart_guide/
http://www.speedyshare.com/672725504.html (files)
I cut NSF file header (no need minus $80 from load address)
(nsf header i put to music.hdr file separately)
http://www.nullsleep.com/treasure/nsf_cart_guide/
http://www.speedyshare.com/672725504.html (files)
I cut NSF file header (no need minus $80 from load address)
(nsf header i put to music.hdr file separately)
Code:
.inesprg 1 ; 1x 16KB PRG code
.ineschr 0 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 0 ; background mirroring
.bank 0
.org $C000
RESET:
cld ; clear decimal flag
sei ; disable interrupts
lda #%00000000 ; disable vblank interrupts by clearing
sta $2000 ; the most significant bit of $2000
WaitV1:
lda $2002 ; give the PPU a little time to initialize
bpl WaitV1 ; by waiting for a vblank
WaitV2:
lda $2002 ; wait for a second vblank to be safe
bpl WaitV2 ; and now the PPU should be initialized
lda #$00 ; clear all the sound registers by setting
ldx #$00 ; everything to 0 in the Clear_Sound loop
Clear_Sound:
sta $4000,x ; store accumulator at $4000 offset by x
inx ; increment x
cpx #$0F ; compare x to $0F
bne Clear_Sound ; branch back to Clear_Sound if x != $0F
lda #$10 ; load accumulator with $10
sta $4010 ; store accumulator in $4010
lda #$00 ; load accumulator with 0
sta $4011 ; clear these 3 registers that are
sta $4012 ; associated with the delta modulation
sta $4013 ; channel of the NES
lda #%00001111 ; enable all sound channels except
sta $4015 ; the delta modulation channel
lda #$C0 ; synchronize the sound playback routine
sta $4017 ; to the internal timing of the NES
lda #$01 ; replace dashes with song number
ldx #$01 ; replace with $00 for NTSC or $01 for PAL
jsr $F780 ; replace dashes with init address
lda #%10000000 ; enable vblank interrupts by setting the
sta $2000 ; most significant bit of $2000
NMI_Routine:
lda $2002 ; read $2002 to reset the vblank flag
lda #%00000000 ; clear the first PPU control register
sta $2000 ; writing 0 to it
lda #%10000000 ; reenable vblank interrupts by setting
sta $2000 ; the most significant bit of $2000
jsr $F844 ; replace dashes with play address
rti ; return from interrupt routine
Forever:
JMP Forever ;jump back to Forever, infinite loop
.bank 1
.org $80F7
.incbin "music.nsf"
.org $FFFA
.dw NMI_Routine
.dw RESET
.dw 0
[/code].ineschr 0 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 0 ; background mirroring
.bank 0
.org $C000
RESET:
cld ; clear decimal flag
sei ; disable interrupts
lda #%00000000 ; disable vblank interrupts by clearing
sta $2000 ; the most significant bit of $2000
WaitV1:
lda $2002 ; give the PPU a little time to initialize
bpl WaitV1 ; by waiting for a vblank
WaitV2:
lda $2002 ; wait for a second vblank to be safe
bpl WaitV2 ; and now the PPU should be initialized
lda #$00 ; clear all the sound registers by setting
ldx #$00 ; everything to 0 in the Clear_Sound loop
Clear_Sound:
sta $4000,x ; store accumulator at $4000 offset by x
inx ; increment x
cpx #$0F ; compare x to $0F
bne Clear_Sound ; branch back to Clear_Sound if x != $0F
lda #$10 ; load accumulator with $10
sta $4010 ; store accumulator in $4010
lda #$00 ; load accumulator with 0
sta $4011 ; clear these 3 registers that are
sta $4012 ; associated with the delta modulation
sta $4013 ; channel of the NES
lda #%00001111 ; enable all sound channels except
sta $4015 ; the delta modulation channel
lda #$C0 ; synchronize the sound playback routine
sta $4017 ; to the internal timing of the NES
lda #$01 ; replace dashes with song number
ldx #$01 ; replace with $00 for NTSC or $01 for PAL
jsr $F780 ; replace dashes with init address
lda #%10000000 ; enable vblank interrupts by setting the
sta $2000 ; most significant bit of $2000
NMI_Routine:
lda $2002 ; read $2002 to reset the vblank flag
lda #%00000000 ; clear the first PPU control register
sta $2000 ; writing 0 to it
lda #%10000000 ; reenable vblank interrupts by setting
sta $2000 ; the most significant bit of $2000
jsr $F844 ; replace dashes with play address
rti ; return from interrupt routine
Forever:
JMP Forever ;jump back to Forever, infinite loop
.bank 1
.org $80F7
.incbin "music.nsf"
.org $FFFA
.dw NMI_Routine
.dw RESET
.dw 0