[cc65] Interrupt driven SID player

From: Maik Merten <maikmerten1googlemail.com>
Date: 2013-07-06 20:32:16
Hi there,

reading the nice tutorials over at 
http://dustlayer.com/c64-coding-tutorials I try to get some insights 
into 6502 assembler. For instance, following 
I was able to hook into the raster interrupt and make the border flash 
in the irq routine (the latter is not part of the tutorial, but a 
shortcut of mine to see the program lives).

The next step I would like to pursue is playing SID tunes. As far as I 
understand this involves three steps:

  * ensure that the SID data (without headers of the .sid file format) 
is loaded at a predefined location, usually $1000
  * invoke the init routine, usually also at $1000
  * once every screen refresh, invoke a play routine, often at $1003

Using a SID file from the HVSC which is reported by xsidplay to have 
$1000 and $1003 as addresses, I try to include the SID data portion into 
my program as follows:

(Complete source code attached, an archive including all files is 
available at 


sid_init = $1000
sid_play = $1003

; ######## include a SID file for which xsidplay reports $1000 and $1003
.org $1000
_siddata: .incbin "Xoo_Divided.sid",$7c+2 ; skip header and two bytes of 
load address


(The offset is calculated as $7c for the SID v2 header and two bytes 
designated as the load address, as indicated by the .sid file format 
specification for the case of 0x08 and 0x09 containing 0x00 respectively)

Anyway, doing a jsr sid_init during setup will freeze the machine or 
terminate the program (depending on the SID file). So apparently I'm 
executing nonsense, and I wonder if, e.g., my way of including the SID 
data is flawed or if I have a more conceptual misunderstanding. Or 
perhaps the way my assembler routines are wired to the C main program is 
problematic? I suspect something stupid :-(

I would greatly appreciate any help!

Best regards,


To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Jul 6 20:32:37 2013

This archive was generated by hypermail 2.1.8 : 2013-07-06 20:32:39 CEST