| |
MrElijahGardner Account closed
Registered: Jul 2019 Posts: 7 |
Adding SID Music to Compiled Basic
I'm working on a new game. Here is an older video clip as the game has progressed quite a bit since then.
https://youtube.com/watch?v=o9wBsf8FM88
It is written in basic and then compiled. How can I go about adding Sid Music to it? Any suggestions?
Thanks in Advance |
|
| |
TheRyk
Registered: Mar 2009 Posts: 2244 |
If you want to do the music in BASIC too, I suggest playing around with the examples on C64-Demo Disk. Doing music in BASIC (and sometimes listening even more) is quite painful, though ^^
But as you compile it anyway, it makes much more sense to do your music in whatever tracker you like and build a mini ML routine that initializes the .SID file and sets up an IRQ ensuring stable playing once per frame. Make sure that neither that little ML routine nor your music data collides with RAM used by main code (which depends on what compiler you use). Normally $C000 to $CFFF is the easiest/safest area for such ML code assessed by BASIC programmes. Also don't f--k up zero page registers which are used as BASIC vectors (or make sure to save and restore those ZP regs in case they are clobbered). |
| |
Count Zero
Registered: Jan 2003 Posts: 1932 |
If you plan on composing the music yourself - Soundmonitor V1.0 (or one of the Rockmonitor versions) - sys49152 and you are ready to go :)
Just sayin' as Soundmonitor was likely done with BASIC in mind. Other composers surely outperform Soundmonitor and it's horrible raster time usage :) |
| |
TheRyk
Registered: Mar 2009 Posts: 2244 |
sound monitor also wastes a lot of RAM, 12kB is pretty normal, even for shorter tunes, modern trackers waste normally less than one third, and Sound Mon range is normally $a000-$cfff, especially the RAM from $a000-$bfff can be used way more efficiently, e.g. for gfx data.
but it's true, those files are pretty easy to handle from BASIC, and (no matter how bulky, complicated and antiquated they are from today's perspective) there's a bunch of old tunes to pick from some of which are quite cool. (iAN will disagree hehe) |
| |
MrElijahGardner Account closed
Registered: Jul 2019 Posts: 7 |
I already have a Sid file
The raw SID data, which loads to 4096 ($1000)
To initialise the tune, you JSR $1000 (or SYS 4096)
To play once per frame, you JSR $1003 (SYS 4099)
My compiled program starts at 8200.
My next two questions are what is the best way to load the SID program into memory. Data Statements?
Then how to do that once per frame in compiled BASIC |
| |
TheRyk
Registered: Mar 2009 Posts: 2244 |
We need to know which compiler you use.
With Blitz!/Austro etc. $1000 is an area you can't use easily.
You'd need to relocate your music somewhere higher than $9fff, e.g. by using Sidreloc V1.0
Basic Boss is a different story, there you can manipulate range of BASIC memory, i.e. set basic start higher, thus $1000 would be possible area for music. |
| |
MrElijahGardner Account closed
Registered: Jul 2019 Posts: 7 |
I'm using Basic 64 It will let me change the program start memory |
| |
TheRyk
Registered: Mar 2009 Posts: 2244 |
Doing sth exactly once a frame in BASIC (even compiled) is tricky at least. That's why some mini ML part called only once via SYS and then setting up an IRQ would help.
An uncompiled example how to load ML code (and a .SID-file is nothing but ML code plus data) into areas outside of BASIC memory can be found here:
http://c64games.de/phpseiten/spieledetail.php?filnummer=336
Check out the very first 2 blocks file in the first disk image of the ZIP
It does nothing but loading 5 files ML, Charset ("Zeichen"), Sprites and Sounds and title screen into RAM higher than $9FFF and finally loading the MAIN code ("MF-PRG") |
| |
MrElijahGardner Account closed
Registered: Jul 2019 Posts: 7 |
Thanks for the example of loading the multiple files. That is easy I can handle that no problem.
My assembly skills are garbage. I know there isnt much to doing an IRQ but not really sure where to start. Is there an example you can point me to.
It would be really awesome if there was an easy way just to poke the IRQ routine into memory to then call the play once per frame part. |
| |
TWW
Registered: Jul 2009 Posts: 545 |
Well documented IRQ routine:
https://codebase64.org/doku.php?id=base:introduction_to_raster_..
EDIT: Use 0315/0315 instead of fffe/ffff and #$37 insted of #$35 for setting $01. |
| |
MrElijahGardner Account closed
Registered: Jul 2019 Posts: 7 |
#$35 for setting $01? This is because we don't want to turn the rom and kernal off correct? I'm not sure why we even need to mess with this address?
Use 0315/0315 instead of fffe/ffff? What is the address of interrupt code referring too?
I wasn't kidding when I said assembly isn't one of my strong point. I'm going to keep plugging away. All the help so far has been great. |
... 5 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 - Next |