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 > *stupid* ASM Sid Player Example ?
2006-03-23 15:53
Trifox
Account closed

Registered: Mar 2006
Posts: 108
*stupid* ASM Sid Player Example ?

Hi i just started coding on the good old c64 and i am wondering how to play music in an assembler executable,
on some tutorials i found that the music usually is located at $1000 but if i load a sid file to that location and jump

jsr $1009

nothing happens, the c64 exits my programm, i think it is clear, a sid file is not an assembler programm to jump in, but how do i now play a music file ?!?!?!?

thanks for any reply ...
2006-03-23 16:04
Oswald

Registered: Apr 2002
Posts: 5094
trifox, first learn the difference between jsr and jmp.


secondly,

each music has a init adress, and a play adress.

init is used to initialize the player.

play is to play the music, and has to be called 50 times per second. (at most cases)

if the init is at $1000, and play at $1003, the most simple player is :

sei
lda #$00
tax
tay
jsr $1000

again

lda #$40
cmp $d012
bne *-3
inc $d020
jsr $1003
dec $d020

jmp again


probably the music you try to use has no real code at $1009 ? or you thought jsr $1009 will play the music, and you have to do nothing else ?
2006-03-23 16:20
JackAsser

Registered: Jun 2002
Posts: 2014
Also, as you say, .sid files are not directly usable on the C64. They have in most cases a header of $7E bytes. In the beginning of the header you can spot the load and run addresses (google for exact locations). Write those down and then strip your .sid file of the first $7E bytes. Then load the stripped chunk to the load-addy written down, in the C64's memory. Then apply Ozzies code.
2006-03-23 16:31
Trifox
Account closed

Registered: Mar 2006
Posts: 108
ehrm, i have progged asm on the amiga, and yes yes yes sir, the difference between jmp and jsr ist that the PC is Pushed onto the stack when calling a JSR ....

and i have found some tutorials on basic c64 stuff, i am currently using a delay function to wait for a specific raster position, wanting to call the player ... but it not works ...

i have googled and found
http://www.unusedino.de/ec64/technical/formats/sidplay.html
now i am trying to set up my sid file ....

if i get it right, a sid file is actually a asm programm which sets the sid register in the 64 when called periodically(50x a second ) the program outputs nice beautiful sid music ... all i have to do is:

1. Strip The )$/()($/)/($ SID Header informations, extract
tune start and tune init locations, jump to them and listen ...

thank you for fast replies ...
2006-03-23 17:36
Oswald

Registered: Apr 2002
Posts: 5094
sidplay has an option to save only the c64 data, also in sidplay use the tune info menu to find out the init and play locations (also load adress, length, etc), very simple.

yes, the play routine sets sid regs as you think, and the init routine sets up the variables and stuff.

sorry about the jsr/jmp abuse, but from your first post it looked like you're mixing the two.
2006-03-24 10:13
Optimus

Registered: Jan 2002
Posts: 122
And something else I want to notice again even if it's already written there well in Oswald's code.

It's necessary to zero the register A (X and Y too? Maybe..) before making the init call. Else everything might crash!

Believe me, I had spent a twenty minutes to find out what the fuck is going on with some old code, and it was that! I am used to players on CPC where you don't need to care about registers before calling the init routine ;P

Could also be that mistake for your case too :)

p.s. Well, the JSR $1009 should be JSR $1003 too.
2006-03-24 10:18
Steppe

Registered: Jan 2002
Posts: 1510
The A register almost always hands the subtune number to the init routine.

Hence:
LDA subtunenumber (mostly #$00)
JSR init

In some cases it's X or Y, but meanwhile almost all of these cases have been fixed by adding a TAX or TAY on init, so you can safely use A in 99.9% of all cases in HVSC.
2006-03-24 10:25
Optimus

Registered: Jan 2002
Posts: 122
>The A register almost always hands the subtune number to the init routine.

Thanks! I just got it :P
2006-03-25 19:46
Trifox
Account closed

Registered: Mar 2006
Posts: 108
ok, now i am having a sid file playing, it is taking up quite much rasterlines ... ;( around ~20 ? thankyou
2006-03-25 20:15
Tch
Account closed

Registered: Sep 2004
Posts: 512
Quote: ok, now i am having a sid file playing, it is taking up quite much rasterlines ... ;( around ~20 ? thankyou

That´s close to average.
You´ll probably find many demos crashing when you add a song of your choice. ;)
2006-03-25 21:27
Trifox
Account closed

Registered: Mar 2006
Posts: 108
'nkay, what is about interesting sid registers ?!?! any meaningful to display as bars ?!?!?!
 
... 19 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 - Next
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
Didi/Laxity
Freeze/Blazon
Guests online: 120
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (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 Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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