注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

深夜是徘徊在潮湿睫毛上的我的梦以及他的梦

是直到最后都无法放手的一种气息,是我们生命中最后的思念……

 
 
 

日志

 
 

我想在程序中加入音乐,但是对nes的音乐编程完全不懂  

2009-12-12 20:47:48|  分类: FC网友经验 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

作者 LIUBINGYH

我这是群里的一个朋友告诉我的,我把程序写在下面,不是全部,只是程序的主要部分,供大家参考:
sound_data2:
        .db        $1c,$09,$52,$09,$ab,$09,$1c,$09,$52,$09,$ab,$09,$1c,$09,$52,$09,$ab,$09,$1c,$09
        .db        $fd,$08,$3f,$09,$ab,$09,$fd,$08,$3f,$09,$ab,$09,$fd,$08,$3f,$09,$ab,$09,$fd,$08
        .db        $1c,$09,$52,$09,$ab,$09,$1c,$09,$52,$09,$ab,$09
        .db        $7c,$09,$3a,$0a,$7c,$09,$1c,$09,$e1,$08,$bd,$08
        .db        $8d,$08,$a8,$08,$d4,$08,$8d,$08,$a8,$08,$d4,$08,$8d,$08,$a8,$08,$d4,$08,$8d,$08
        .db        $7e,$08,$9f,$08,$d4,$08,$7e,$08,$9f,$08,$d4,$08,$7e,$08,$9f,$08,$d4,$08,$7e,$08
        .db        $8d,$08,$a8,$08,$d4,$08,$8d,$08,$a8,$08,$d4,$08
        .db        $bd,$08,$1c,$09,$bd,$08,$8d,$08,$70,$08,$5e,$08

        .db        $53,$08,$69,$08,$8d,$08,$69,$08,$8d,$08,$a8,$08
        .db        $8d,$08,$a8,$08,$d4,$08,$a8,$08,$d4,$08,$1c,$09
        .db        $d4,$08,$1c,$09,$52,$09,$1c,$09,$52,$09,$ab,$09,$7c,$09
        .db        $5e,$08,$70,$08,$8d,$08,$70,$08,$8d,$08,$bd,$08
        .db        $8d,$08,$bd,$08,$e1,$08,$bd,$08,$e1,$08,$1c,$09
        .db        $e1,$08,$1c,$09,$7c,$09,$1c,$09,$7c,$09,$c4,$09,$ab,$09
        .db        $53,$08,$69,$08,$8d,$08,$69,$08,$8d,$08,$a8,$08
        .db        $8d,$08,$a8,$08,$d4,$08,$a8,$08,$d4,$08,$1c,$09
        .db        $d4,$08,$1c,$09,$52,$09,$1c,$09,$52,$09,$ab,$09,$7c,$09
        .db        $5e,$08,$70,$08,$8d,$08,$70,$08,$8d,$08,$bd,$08
        .db        $8d,$08,$bd,$08,$e1,$08,$bd,$08,$e1,$08,$1c,$09
        .db        $e1,$08,$1c,$09,$7c,$09,$1c,$09,$7c,$09,$c4,$09,$ab,$09
        .db        $ff

data2:
        .db        $0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e
        .db        $0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e
        .db        $0e,$0e,$0e,$0e,$0e,$0e
        .db        $0e,$0e,$0e,$0e,$0e,$0e
        .db        $0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e
        .db        $0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e
        .db        $0e,$0e,$0e,$0e,$0e,$0e
        .db        $0e,$0e,$0e,$0e,$0e,$0e

        .db        $07,$07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07,$2a
        .db        $07,$07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07,$2a
        .db        $07,$07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07,$2a
        .db        $07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07
        .db        $07,$07,$07,$07,$07,$07,$2a
        .db        $ff
nmi:                ;这里是在中断中添加声音
        pha
        txa
        pha
        tya
        pha
        inc        8                        ;时值计数器
        ldx        9                        ;时值数组指针
        lda        data2,x
        cmp        8
        beq        c1                        ;时值用完则跳
        cmp        #255
        beq        c2
 `        jmp        c3
c2:        ldx        #0
        stx        9
        jmp        c3
c1:
        lda        #0
        sta        8                        ;清空时值计数器
        lda        10                        ;音调数组指针
        tay
        lda        sound_data2,y
        cmp        #255
        beq        c4
        sta        $4002
        iny
        lda        sound_data2,y
        cmp        #255
        beq        c4
        sta        $4003
        iny                                ;指向下一个音符
        sty        10                        ;保存
        inx                                ;指向下一个时值
        stx        9                        ;保存
        jmp        c3
c4:        ldy        #0
        sty        10
c3:        pla
        tay
        pla
        tax
        pla
        rti

------------------------------------------

曹老

sound—dat2:应该是音乐的频率,第一个byte是低位,第二个byte是高位。data2是音符的发音长度(用中断来计数)。

这是一段最核心的,经过编译得到的数据。一般写音乐已经可以用汇编来写了,然后编译后得到这样的数据。直接看频率是很吃力的。

  评论这张
 
阅读(622)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017