Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Play a SID in ACME
2010-03-03 19:42
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Play a SID in ACME

Hi All,

I wanted to first thank stranger so much for his help with adding a Koala picture into a program. It worked beautify. I am also interested into adding music to the program. I went to code base and they had two examples. I found a few SIDs using Pokefinder and made sure they had a start address of $1000. Anyway, when I tried them I got nothing coming from the good old commodore speakers. I loaded the SID up in a player and it played fine. Just curious if anyone here (which I know the answer to) :) has any experience with adding SID music to some assembler code and can point me into the right direction.

Thanks,
MisterMsk


2010-03-03 20:35
Stryyker

Registered: Dec 2001
Posts: 468
Can you include example code of what you're doing along with a link to the in HVSC to the tune?
2010-03-03 21:24
chatGPZ

Registered: Dec 2001
Posts: 11386
first of all make sure you have a correctly working binary... load it, and do something like

10 sys4096
20 sys4096+3:goto20

that should make some (ugly) noise :)

and if that works, then doing

lda #0
jsr $1000

for init, and

jsr $1003

for playing (once per frame) should do the trick
2010-03-03 21:39
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Each one can be found here and here.

The Sample SID I found was Bubble Trouble.
I'll list the first one for you with the modification.

;--------------------------------
;JCH, DMC, Whatever IRQ music plr (Modified)
;================================

             !to "workdarnit.prg",cbm
             * = $0810 ;Remember SYS 2064 to enable it

             sei
             lda #<irq
             ldx #>irq
             sta $314
             stx $315
             lda #$1b
             ldx #$00
             ldy #$7f 
             sta $d011
             stx $d012
             sty $dc0d
             lda #$01
             sta $d01a
             sta $d019 ; ACK any raster IRQs
             lda #$00
             jsr $1000 ;Initialize Richard's music
             cli
hold         jmp hold ;We don't want to do anything else here. :)
                      ; we could also RTS here, when also changing $ea81 to $ea31
irq
             lda #$01
             sta $d019 ; ACK any raster IRQs
             jsr $1003 ;Play the music
             jmp $ea31
            

             * = $1000-2
             !binary "BubbleTrouble.sid" 


2010-03-03 21:48
Mace

Registered: May 2002
Posts: 1799
A SID file holds more than just the binary of the music routine. It has a header, which, in your case, is at $1000.
The code part start higher up in the memory.

You need to truncate the SID so that you only have the real binary in the memory.
Check here for more information: SID header information.
2010-03-03 22:01
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Mace,

Thank you. I had to remove the first 124 (7C) bytes off of that SID and it worked perfectly with the code. Would of been nice on Codebase64 to mention something like that, I guess instead of saying.

Quote:
Rip one of my tunes from the HVSC and save as music.dat if you like


Thanks Again,
MisterMsk
2010-03-03 22:04
chatGPZ

Registered: Dec 2001
Posts: 11386
try this:

*=$1000
!bin "BubbleTrouble.sid",,$007c+2
2010-03-04 05:47
Inge

Registered: Nov 2003
Posts: 144
Quote: Mace,

Thank you. I had to remove the first 124 (7C) bytes off of that SID and it worked perfectly with the code. Would of been nice on Codebase64 to mention something like that, I guess instead of saying.

Quote:
Rip one of my tunes from the HVSC and save as music.dat if you like


Thanks Again,
MisterMsk


I'll explain what "save as music.dat" means.

In Sidplay2/Win you can choose File->Save As. Choose to save as C64 data (.dat). You'll then get a C64 binary without the PSID header.
2010-03-04 09:16
Frantic

Registered: Mar 2003
Posts: 1648
I added some additional notes in this article, in order to make these things clearer for beginners:

http://codebase64.org/doku.php?id=base:simple_irq_music_player

..and while I am at it, I should also remind all the coders out there to keep adding stuff to codebase! (Well, there is in fact some contributions every now and then, so I am not complaining, but there could always be more. :)
2010-03-04 14:21
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Quote: I added some additional notes in this article, in order to make these things clearer for beginners:

http://codebase64.org/doku.php?id=base:simple_irq_music_player

..and while I am at it, I should also remind all the coders out there to keep adding stuff to codebase! (Well, there is in fact some contributions every now and then, so I am not complaining, but there could always be more. :)


Thanks, Frantic. It looks great. Nice instructions. Step-by-Step and everything.

Inge, Thank you for explaining the saving of the .DAT stuff. It helps. I tend to use HxD for Hex-Editing in Windows, quick and easy goto 7C and delete all before and save.

Ok... Lets gets a little deeper into this playing music code. I kinda' want to play the SID while the users choices from a menu. Since I have a menu in code already, I could put a routine around there. With the above code, Would I remove the hold statement and put the menu in between where the hold statement was?
2010-03-04 14:41
Frantic

Registered: Mar 2003
Posts: 1648
Yes... If you want some sort of main loop running in your program, it should be instead of that jmp hold stuff.
2010-03-04 19:50
Mace

Registered: May 2002
Posts: 1799
Quote:
(...) saving of the .DAT stuff. It helps. I tend to use HxD for Hex-Editing in Windows, quick and easy goto 7C and delete all before and save.
As Groepaz explained extremely briefly: you can also load a SID file with an offset of $7c+2 (header + load address).
This way there's no need to alter the file or convert it to another format.
You can just tell the assembler to only load the part you need.
2010-03-04 21:40
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
And of course, I run into another stumbling block. I created a SID, actually a MUS, using SID-EDITOR. Reading up on it, I found out why the SID/MUS was so small, it was that it did not put the player in it. Per the reference sheet posted earlier, it says you'll have to find code for an external player. So, looking through my books, Codebase64, and Google I am unable to come up with any. Codebase64 had one artical but it was not a MUS player. So does anyone know how I can get a MUS file playing? I see players so its got to be possible still. I even tried Sidplay2/w and converting it to a DAT but when you look at the file, it did nothing really to it.
2010-03-04 21:46
Frantic

Registered: Mar 2003
Posts: 1648
No.. :)

The code in your original post should be the only "external player" required. Are you sure the .sid you're trying to play is actually supposed to be located at $1000? You can see that somewhere (probably in sidplay) if you check the info of the tune. It should say init address = $1000 and play address = $1003. Does it do that?

Also, I recommend using the !bin "file",,$7c+2 command (from within your ACME source) to be sure that you're not screwing the file up somehow.

...and change that $1000-2 to $1000 in the code of your first post in this thread.
2010-03-08 18:04
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Frantic,

When I pull it up in Sidplay2/w, it shows as $0900. Which Sidplay2/w plays it fine. However, I was recomended Sid Player64 v0.5 and it does not play them. Other players seem to fine as long as they support that type of sid. You can download mskintro.mus and try for your self. Everyhing I have been reading says it needs player code but I do not see any listed anywhere.

MisterMsk
2010-03-08 20:45
iopop

Registered: Dec 2001
Posts: 317
Contents of mskintro.mus,
00000000 90 71 0c 00 02 00 02 00 14 9d 14 9c 14 9d 14 91 .q..............
00000010 14 92 01 4f 01 4f 01 4f 20 20 20 20 20 20 20 20 ...O.O.O        
00000020 4f 52 49 47 49 4e 41 4c 20 50 49 45 43 45 0d 20 ORIGINAL PIECE. 
00000030 20 20 20 20 20 20 20 20 42 59 20 4d 52 2e 4d 53         BY MR.MS
00000040 4b 0d 20 20 20 20 20 20 20 20 20 4d 41 52 43 48 K.         MARCH
00000050 20 33 52 44 20 32 30 31 30 0d 0d 00              3RD 2010...


Don't think any re-player apart from the "SID-EDITOR" will give correct playback on that data.
2010-03-08 22:16
iAN CooG

Registered: May 2002
Posts: 3195
(self censor about sidplayer) :D
2010-03-09 09:53
Frantic

Registered: Mar 2003
Posts: 1648
@MisterMSK:

What you have there is the header of the file, not the file, so to speak. (I am not even sure that it was a complete header actually.) ...and as Iopop says, that will of course not be possible to play anywhere. No song data in there whatsoever.

You should use the "other part" of the file.

Seriously.. Do what we suggested instead of using these weird programs. Just do a binary include of a playsid file ("*.sid") directly from ACME instead. You will notice that it actually works (as long as you include it on the correct adress).

So.. If the tune should be located at $9000, place it there, and use lda #0 / jsr $9000 to init the player and jsr $1003 to do the player calls once per frame. (If this is indeed the two adresses to use for init and player call--you can see this in the sid info too.)

2010-03-09 11:10
Inge

Registered: Nov 2003
Posts: 144
@Frantic: Obviously, as it is a .MUS file, he has made it with the old Compute's Gazette SIDplayer, which doesn't save the player routine, only the music data.

Sidplay2/w has built-in support for playing MUS-files, but Sid Player 64 hasn't.

@MisterMSK: I can just suggest that you
a) track down the sourcecode for sidplayer-playroutine. I'm sure I've seen it on a d64 somewhere.
b) use another, more modern music-program. There are dozens.
2010-03-09 13:35
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Thanks... I am going to have to track it down I guess.

That is the full file, not just the header, by the way. It is MUS SID format not PSID, RSID, etc... If you load it up in Sidplay2/w, you'll see it does play fine (4 notes).

So let me ask another question if I may, since there are a lot of groups that use music in there demos here. What is the best (possibly easiest to use) SID editor/creator that I can get my hands on? With the exception of getting any additional hardware (such as MIDI, 2nd SID chip,etc...).

BTW, Thanks Again for all of your help,
MisterMsk
2010-03-09 14:22
GT
Account closed

Registered: Sep 2008
Posts: 308
Use a hammer.
2010-03-09 14:39
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Quote: Use a hammer.


Nope. That didn't work. Anyone else know of a good music editor/creator that will create the SID files I would need to use with this code?
2010-03-09 14:49
GT
Account closed

Registered: Sep 2008
Posts: 308
Future Composer V1.0

btw: zoom.sid (mc hammer. You'd need 10 years to achive the same result).
2010-03-09 15:48
Frantic

Registered: Mar 2003
Posts: 1648
On C64, SDI seems quite popular in these days. On PC/Mac, Goattracker is the editor to use, I guess.
2010-07-16 13:04
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Hi All,


One last thing. I got the below code embedded in some code. However, when I try to load another program it hangs the music and sometimes crashes. Just curious how I would turn the music off?

*=$0801
entry:
; BASIC stub: "1 SYS 2061"
!by $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00

             sei
             lda #<irq
             ldx #>irq
             sta $314
             stx $315
             lda #$1b
             ldx #$00
             ldy #$7f 
             sta $d011
             stx $d012
             sty $dc0d
             lda #$01
             sta $d01a
             sta $d019 ; ACK any raster IRQs
             lda #$00
             jsr $0A6F ;Initialize
             cli
hold         jmp $0DEE                     
irq
             lda #$01
             sta $d019 ; ACK any raster IRQs
             jsr $0AB4 ;Play
             jmp $ea31

*=$0DEE

rest of code...


      *=$0A6F
      !binary "sound.sid",, $7c+2 

2010-07-16 17:41
Frantic

Registered: Mar 2003
Posts: 1648
I am not quite sure what you are trying to do. You don't really give enough details. ...but it is clear that loading one program over the same memory range as another (while the other one is still running) will crash the previous program.
2010-07-16 18:27
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
The SID I have uses $0A6F to $0DED. So I actually built the code around the SID. Anyway, I am loading a program into higher memory. Then move it to lower memory from $0801. Then I run the program. All works fine without any problems. Even by loading the SID in place but commenting the above code.

So, I am just trying stop the SID from playing.
2010-07-16 19:27
iAN CooG

Registered: May 2002
Posts: 3195
just restore the irq to $ea31 and silence the sid but you should be really sure you don't load anything over the running code before doing so...
sei
jsr $fd15 ; of course if you don't have anything under $fd30-fd50 
lda #0
sta $d418
cli
rts

2010-07-21 18:04
MisterMSK
Account closed

Registered: Jul 2009
Posts: 37
Thank you. It works flawlessly with some tweaks.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Andy/AEG
tlr
Alta
Alakran_64
Unicorn/TWA
iAN CooG/HVSC
sln.pixelrat
DeMOSic/MS^LSD^ONS
Guests online: 110
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.07 sec.