2016-12-03 35 views

回答

3

我找到了一个解决方案:

  1. 创建生成以下代码的.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 
    
  2. 目前我使用这个命令编译我的代码以cc65
  3. 从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; 
    } 
    
  4. 使用标准cc65Makefile编译这两个文件,这给你一个.c64文件与您的代码,但没有SID数据

  5. 重新定位使用sidreloc的SID文件(该选项-p定义新的开始页面,在这种情况下20意味着$ 2000)

    ./sidreloc -r 10-1f -p 20 sidfile.sid sidfile2000.sid 
    
  6. 使用psid64转换的SID文件C64 .prg

    psid –n sidfile2000.sid 
    
  7. 链接文件sidfile2000.prg使用exomizer编译C程序一起(数2061是程序的开始地址,2061是用于cc65默认值):

    exomizer sfx 2061 music.c64 sidfile2000.prg -o final.prg 
    
相关问题