| |
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 ... |
|
| |
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 ? |
| |
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. |
| |
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 ... |
| |
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. |
| |
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. |
| |
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. |
| |
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 |
| |
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 |
| |
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. ;) |
| |
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 |