Open Fabrizio-Caruso opened 3 years ago
@polluks Thanks. I am not sure I understand the explainations and they seem to refer to a different bios routine as I see a different address. CC65 uses jmp $FBED.
The subroutines that are described in that forum thread are for "songlists". A songlist is an array of a struct that has two members:
The songlist must sit at a fixed location in a cart. A game would choose one of the elements of that array, then call one of those ROM subroutines.
The cc65 function bios_playsound()
bypasses that part of the ROM code. Instead, it passes the two members of one struct directly to an entry point that's inside one of those ROM subroutines.
@greg-king5 so for the CC65 function, could the pointer have any value? For instance "song" where song is defined as static const char song[SONG_LENGTH] = ... ? How is a song defined? I read it is made of multiple note triples and a tempo. Is the tempo common for all triples? Are note triples, just 3 bytes? One byte per note per voice? So only 256 values for the frequency? Or rather 16 bit per note?
@greg-king5 What does psg_outb
do?
I see it also listed in the doc at https://cc65.github.io/doc/creativision.html
but I have not been able to find any doc elsewhere.
I only see it takes an unsigned char as input but what does it do with it?
A da65 bios/bioscv.rom
says this is just a single poke to the PIA:
LFE77: sta PIA1_DATA
: lda PIA1_STATUS
bpl :-
lda PIA1_DATA
rts
"The 76489 is wired into port B of the PIA. You just write single bytes to it. It's a relatively slow access device so this is undoubtedly why they wired it to the PIA rather than straight to the data bus. I think they configure the PIA to automatically send a strobe signal when you write to $1002."
This thread is a goldmine! http://www.madrigaldesign.it/forum/viewtopic.php?f=13&t=129
With some help from madrigaldesign forum I have managed to give some very initial sound support to all my Cross-Lib games on the Creativision and I might use this knowledge to do the same with other targets with different CPUs (Motorola 6809 and Zilog 80) that use the same PSG chip: https://github.com/Fabrizio-Caruso/CROSS-LIB/tree/master/src/cross_lib/sound/cc65/creativision
If you think cc65 docs could be improved in this regard, please do so. Remember, the cc65 docs aren't supposed to teach the workings of a system, but cc65 specific usage. Maybe create a sound-playing sample?
@groessler sure, I asked about the CC65 interfaces and not about the PSG.
For example psg_outb
seems to write into the PSG port. This information should be part of CC65 doc. The details of PSG maybe not but simple short examples could he.lp both understand CC65 interfaces and PSG.
I don't know much about that. I took this machine support from the original author and adapted it to be merge-able. I learned about the controller and screen parts, but the sound part I just left as-is.
@groessler my current suggestion for improvement is to just say something about psg_outb
("it writes into the PSG port" would be good enough). It is the most important command as all PSG commands are sent through it.
psg_delay
does not seem to be a real a PSG command but it is a convenient one to have. It seems it is just pausing the CPU.
No need to say something as its name is self-explanatory.
bios_playsound
may be clear for people who know the Creativision bios. A trivial example would help a lot for people who want to use it. I am not, yet, capable of writing an example with it.
bios_playsound()
may be clear for people who know the Creativision BIOS. A trivial example would help a lot for people who want to use it. I am not, yet, capable of writing an example with it.
The "goldmine" thread has an example.
The answer I got here explains clearly the format of the notes: http://www.madrigaldesign.it/forum/viewtopic.php?f=13&t=322
I see that some PSG functions are provided in the lib: https://github.com/cc65/cc65/blob/master/include/creativision.h https://github.com/cc65/cc65/blob/master/libsrc/creativision/psg.s
but most of them are not documented at all and no example is provided.
For example, What does
psg_outb
do exactly? Can it be used to write into PSG registers?It would be nice to have an example that shows how to use
bios_playsound
? What is a note tripple? 3 notes? Do I have to play 3 notes? How do I play a single note?