Page 27 of 39
Re: Prog8 language and compiler topic
Posted: Wed Jun 21, 2023 7:05 pm
by yock1960
Irmen,
I compiled the streaming wave file program, successfully after upgrading 64tass.
Works great with some files that I just happened to have laying around! After futzing about for a while, I finally managed to get it to stream two files consecutively, but only if I did practically nothing in between each file. I'm missing something.
I suspect it has to do with the interrupt handler...not something I'm very experienced with, but perhaps that's not it. I tried saving the old vector and restoring it in between files, but either I'm doing it wrong, or that's not it!
It seems like this should be doable. I'd like to incorporate this into my current project, to play some wave files when not much else is going on. Any insight you can give me would be great!
Re: Prog8 language and compiler topic
Posted: Wed Jun 21, 2023 7:13 pm
by yock1960
yock1960 wrote: ↑Wed Jun 21, 2023 7:05 pm
Irmen,
I compiled the streaming wave file program, successfully after upgrading 64tass.
Works great with some files that I just happened to have laying around! After futzing about for a while, I finally managed to get it to stream two files consecutively, but only if I did practically nothing in between each file. I'm missing something.
I suspect it has to do with the interrupt handler...not something I'm very experienced with, but perhaps that's not it. I tried saving the old vector and restoring it in between files, but either I'm doing it wrong, or that's not it!
It seems like this should be doable. I'd like to incorporate this into my current project, to play some wave files when not much else is going on. Any insight you can give me would be great!
Well, I don't know what I did wrong earlier, but now it's working...at least in the context of the demo program. On to the larger task....stay tuned...
Re: Prog8 language and compiler topic
Posted: Wed Jun 21, 2023 7:23 pm
by desertfish
I was just about to try to give some hints, but great that you managed to proceed already.
I think you could just disable the AFLOW IRQ bit once you detect the end of a wav file, set up reading the next one, and then re-enabling the AFLOW bit again
Re: Prog8 language and compiler topic
Posted: Wed Jun 21, 2023 9:38 pm
by yock1960
desertfish wrote: ↑Wed Jun 21, 2023 7:23 pm
I was just about to try to give some hints, but great that you managed to proceed already.
I think you could just disable the AFLOW IRQ bit once you detect the end of a wav file, set up reading the next one, and then re-enabling the AFLOW bit again
Well, it worked...until I moved this bit:
cx16.rombank(0) ; activate kernal bank for faster calls
:
:
cx16.VERA_AUDIO_RATE = 0 ; halt playback
to a subroutine. Now I'm back to square....one and a half, the first call to the sub works, I restore the old values for the IRQ's, same as before, but the next call fails. I think that saving the original state of cx16.VERA_IEN and restoring it after playing the first file, was what was wrong in my first attempts, now, I don't know. I'll keep trying.
Re: Prog8 language and compiler topic
Posted: Wed Jun 21, 2023 11:02 pm
by desertfish
Are you by any change manipulating Vera registers inside the IRQ handler?
That is super tricky. There are some helper functions in prog8 that can save/restore the vera state in this case. Also make sure the rom and ram banks are set back to their initial values if you manipulate those in the irq handler .
(unless you depend on them changing)
Re: Prog8 language and compiler topic
Posted: Wed Jun 21, 2023 11:44 pm
by yock1960
desertfish wrote: ↑Wed Jun 21, 2023 11:02 pm
Are you by any change manipulating Vera registers inside the IRQ handler?
That is super tricky. There are some helper functions in prog8 that can save/restore the vera state in this case. Also make sure the rom and ram banks are set back to their initial values if you manipulate those in the irq handler .
(unless you depend on them changing)
I haven't changed anything in the 'interrupt' block, I simply copied (cut and pasted) from the line cx16.rombank(0) to the line cx16.VERA_AUDIO_RATE = 0, to it's own sub. Made local variables for size and block size, or even referenced the originals from start(), makes no difference.
If I just repeat this code in start(), only changing the MUSIC_FILENAME and restoring the irq vectors in between playing the two files, it works. If I create a subroutine, call it once, it works, but on the second call it fails. If I play the first .wav file using the original code (no sub) it works, but if I try to use a sub for the second .wav file, it fails. So, there is something that is different after the 1st .wav file is played, that is making the 2nd attempt, using a sub routine, to fail.
In the version where I can play two files consecutively, I have had 2 calls to cx16.rombank(0), 1 call (first file) and none. They all work. Whether or not this would be problematic in the 'real world', I don't know, I have only ever changed rom banks in assembly programs....Prog8 handles this and I'm happy to let it!
I did a bit of nosing around in the debugger, not something I do often, less from the official emulator version....preferring Box16, but it's still on R41 and I'm not interested in learning how to build it for myself. What I looked at looked okay, but, that's the deep end of the pool for me!
Re: Prog8 language and compiler topic
Posted: Thu Jun 22, 2023 12:50 am
by ahenry3068
I'm in a quandary myself.
I've been doing a bunch of BASIC Code.
My favorite language has been Pascal. Borland got me started/
I'm not allergic to C....
I'm trying to make a choice here for when I get more advanced than BASIC
allows without PEEK and POKE
I'm down to CC65, Prog8 and PAS65
I'm currently leaning toward PAS65......... Just because that is "MY" language
Re: Prog8 language and compiler topic
Posted: Thu Jun 22, 2023 9:22 am
by yock1960
Well, I've managed to incorporate playing of .wav files into my project. It's a bit ugly; 'unnecessary' repeating of code and a small hit on memory usage, but it's working.
Do I understand...no, but that's nothing new....and, you don't have to understand something completely in order to use it!
Re: Prog8 language and compiler topic
Posted: Thu Jun 22, 2023 9:34 am
by yock1960
ahenry3068 wrote: ↑Thu Jun 22, 2023 12:50 am
I'm in a quandary myself.
I've been doing a bunch of BASIC Code.
My favorite language has been Pascal. Borland got me started/
I'm not allergic to C....
I'm trying to make a choice here for when I get more advanced than BASIC
allows without PEEK and POKE
I'm down to CC65, Prog8 and PAS65
I'm currently leaning toward PAS65......... Just because that is "MY" language
Well, I'm not allergic to C either, but I have taken against it. I really liked Slang, which was written for the C64 SuperCPU and is compatible with the CX16...to a point...can't use floating point since the routines have moved on the CX16 and sadly it hasn't been maintained for well over a decade.
Prog8 has a very active developer and supports the C64 and CX16 very well. It's not perfect...what is? Any language can become 'your' language, it's just a matter of sticking with it and learning it's in's & out's.
Re: Prog8 language and compiler topic
Posted: Fri Jun 23, 2023 1:16 am
by yock1960
yock1960 wrote: ↑Thu Jun 22, 2023 9:22 am
Well, I've managed to incorporate playing of .wav files into my project. It's a bit ugly; 'unnecessary' repeating of code and a small hit on memory usage, but it's working.
Do I understand...no, but that's nothing new....and, you don't have to understand something completely in order to use it!
Slightly different issue, probably won't matter at all in the long run, but curious and I'm curious about it. The buffer that is established using the memory() function, I replaced it by creating a uword pointer to $a000. Page aligned and nothing else should be there and I'm not altering the ram bank. On starting the program it will either work normally, or I will get garbage or highly distorted sound. I'm wondering if it's an emulator/windows issue or something else? As I said, it probably won't matter, since I will probably need to move the buffer back to 'main' memory in order to use the $a000 area for code. I believe that the 8k will be enough that I won't have to do anything really fancy....if I even need to at all.