2
我想在cc65程序中包含和播放.sid文件(用于C64 chiptunes的音乐)。通常,sid文件包含一个以1000美元开始的播放例程,我如何将其链接到我的cc65程序?如何在C64上将一个SID文件包含到cc65程序中?
cl65 -O -o C64test.prg -t c64 C64test.c
我想在cc65程序中包含和播放.sid文件(用于C64 chiptunes的音乐)。通常,sid文件包含一个以1000美元开始的播放例程,我如何将其链接到我的cc65程序?如何在C64上将一个SID文件包含到cc65程序中?
cl65 -O -o C64test.prg -t c64 C64test.c
我找到了一个解决方案:
创建生成以下代码的.asm文件:
.export _setupAndStartPlayer
sid_init = $2000
sid_play = $2003
siddata = $2000
.segment "CODE"
.proc _setupAndStartPlayer: near
jsr sid_init; init music
; now set the new interrupt pointer
sei
lda #<_interrupt ; point IRQ Vector to our custom irq routine
ldx #>_interrupt
sta $314 ; store in $314/$315
stx $315
cli ; clear interrupt disable flag
rts
.endproc
.proc _interrupt
jsr sid_play
dec 53280 ; flash border to see we live
jmp $EA31 ; do the normal interrupt service routine
.endproc
从C调用asm函数:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <c64.h>
extern int setupAndStartPlayer();
int main(void) {
printf("Setting up player\n");
setupAndStartPlayer();
return 0;
}
使用标准cc65
Makefile
编译这两个文件,这给你一个.c64
文件与您的代码,但没有SID数据
重新定位使用sidreloc
的SID文件(该选项-p
定义新的开始页面,在这种情况下20
意味着$ 2000)
./sidreloc -r 10-1f -p 20 sidfile.sid sidfile2000.sid
使用psid64
转换的SID文件C64 .prg
:
psid –n sidfile2000.sid
链接文件sidfile2000.prg
使用exomizer
编译C程序一起(数2061
是程序的开始地址,2061是用于cc65
默认值):
exomizer sfx 2061 music.c64 sidfile2000.prg -o final.prg