are you using uninitialized memory somewhere?
note that memory is not filled with $00 at startup.
or something else is changing the ram bank.
Prog8 language and compiler topic
- desertfish
- Posts: 1093
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: Prog8 language and compiler topic
I left the rambank(0) command out, it doesn't seem to matter, in the emulator anyway. I fixed the missing files issue in the WIP post.desertfish wrote: ↑Fri Jun 23, 2023 3:33 pm are you using uninitialized memory somewhere?
note that memory is not filled with $00 at startup.
or something else is changing the ram bank.
Re: Prog8 language and compiler topic
Another oddity, I mention only to be....informative...
While experimenting with the .wav files for my project, specifically to see if I could get one to fit in a single bank of hiram...which I did, by chopping it down a bit, I discovered that while the shortened .wav file (time wise) and also encoded at 8000hz, all performed in Audacity, would play fine using streaming (stream-wave), but not using play-adpcm. I haven't pored over the code to see if there's a difference, but there must be. I haven't tried using the 'approved' conversion programs, but figured compatibility in one would carry over to the other program. Well, I'm still happy being able to stream .wav files, period!
While experimenting with the .wav files for my project, specifically to see if I could get one to fit in a single bank of hiram...which I did, by chopping it down a bit, I discovered that while the shortened .wav file (time wise) and also encoded at 8000hz, all performed in Audacity, would play fine using streaming (stream-wave), but not using play-adpcm. I haven't pored over the code to see if there's a difference, but there must be. I haven't tried using the 'approved' conversion programs, but figured compatibility in one would carry over to the other program. Well, I'm still happy being able to stream .wav files, period!
- desertfish
- Posts: 1093
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: Prog8 language and compiler topic
The play-adpcm code is very picky about the encoding format, maybe Audacity encoded it in a different format.
The decoder understands ONLY ima-adpcm encoded files with a block size of 256.
In the code comments of the adpcm.p8 file you can find a couple of commands on how to produce such a file.
The decoder understands ONLY ima-adpcm encoded files with a block size of 256.
In the code comments of the adpcm.p8 file you can find a couple of commands on how to produce such a file.
Re: Prog8 language and compiler topic
Cool! Being a 'soft' gui type user, I tend to shy away from command line only tools, but I just can't decipher Audacity's myriad of export, menu choices....none of them specifying anything as helpful as 'ima-adpcm'. After several attempts failed, I downloaded sox. First attempt success! Any tips on converting files for use with the zsound demo? I tried coverting the same source .wav file, using the sox command line example on the zsound Github docs page and then recompiling play-zsound to use this file. Silence and a page filling raster effect, when activating the digi-sample trigger. I tried with and without adding a dummy 2-byte header as also suggested, but deemed unnecessary. Although, if I recall correctly, it didn't load until I added the dummy header.desertfish wrote: ↑Sun Jun 25, 2023 6:00 pm The play-adpcm code is very picky about the encoding format, maybe Audacity encoded it in a different format.
The decoder understands ONLY ima-adpcm encoded files with a block size of 256.
In the code comments of the adpcm.p8 file you can find a couple of commands on how to produce such a file.
Re: Prog8 language and compiler topic
Irmen,
I know I'm not the sharpest guy, but for the life of me, I can't figure out why this code doesn't work correctly, using version 9.0 on R43. I read a list of top scores (10 scores, 0 to 9) and player initials from a file, into to string arrays, this works fine, printing them gives the expected results. Then I pass a new score to this subroutine. the 'top_score' value is actually the lowest high score, so if score is lower, we exit. Otherwise, find where it fits, move everything down 1 slot from the insertion point, bumping out the lowest hi score. I get a double entry with the new score, and lose the score that was to be the first score moved down, everything else is correct, the old lowest score is gone. I've tried this with both a for loop and a while loop...same result. I'm stumped. Could be bad logic on my part....wouldn't be the first time, or even the 10,000th! Even stranger, there is no double entry in the scores array in memory, although the lowest score is still there....I'm confused!
sub check_score(uword score) -> ubyte {
ubyte n
ubyte i
if score < top_score {
return(10) }
else {
for n in 0 to 9 {
if score > conv.str2uword(scores[n]) {
for i in 8 to n step -1 {
names[i+1] = names
scores[i+1] = scores }
string.copy(p_str,names[n])
conv.str_uw0(score)
string.copy(conv.string_out,scores[n])
return(n)
}
}
}
}
I know I'm not the sharpest guy, but for the life of me, I can't figure out why this code doesn't work correctly, using version 9.0 on R43. I read a list of top scores (10 scores, 0 to 9) and player initials from a file, into to string arrays, this works fine, printing them gives the expected results. Then I pass a new score to this subroutine. the 'top_score' value is actually the lowest high score, so if score is lower, we exit. Otherwise, find where it fits, move everything down 1 slot from the insertion point, bumping out the lowest hi score. I get a double entry with the new score, and lose the score that was to be the first score moved down, everything else is correct, the old lowest score is gone. I've tried this with both a for loop and a while loop...same result. I'm stumped. Could be bad logic on my part....wouldn't be the first time, or even the 10,000th! Even stranger, there is no double entry in the scores array in memory, although the lowest score is still there....I'm confused!
sub check_score(uword score) -> ubyte {
ubyte n
ubyte i
if score < top_score {
return(10) }
else {
for n in 0 to 9 {
if score > conv.str2uword(scores[n]) {
for i in 8 to n step -1 {
names[i+1] = names
scores[i+1] = scores }
string.copy(p_str,names[n])
conv.str_uw0(score)
string.copy(conv.string_out,scores[n])
return(n)
}
}
}
}
- desertfish
- Posts: 1093
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: Prog8 language and compiler topic
can you format the code in mono or pre to fix the indenting? It's kinda hard to read right now
Re: Prog8 language and compiler topic
I came up with a version that works...second snippet. I still don't understand why the first snippet doesn't work though.desertfish wrote: ↑Sun Jul 09, 2023 3:57 pm can you format the code in mono or pre to fix the indenting? It's kinda hard to read right now
non-working:
working:
- desertfish
- Posts: 1093
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: Prog8 language and compiler topic
I think I understand what you're trying to do here. In the first code snippet, is p_str the pointer to the name for the new high score entry?
At first glance I don't see anything wrong with the first snippet. I will have to compile it myself in a small test program to see how it behaves, but this will take a while to figure out.
Maybe you're triggering a prog8 compiler bug! I have fixed a few compiler bugs since the 9.0 version of the compiler came out, so perhaps the code works fine with the current development version of the compiler. If you feel comfortable you can get it from a CI build artefact on the github actions.
(I'm planning to release version 9.1 next week btw.)
P.S.
copying code from a screenshot is ... kinda hard
you can paste the code here and surround it with the mono or pre tags or use those markup buttons above the text entry, this way we can simply copy and paste the program text
At first glance I don't see anything wrong with the first snippet. I will have to compile it myself in a small test program to see how it behaves, but this will take a while to figure out.
Maybe you're triggering a prog8 compiler bug! I have fixed a few compiler bugs since the 9.0 version of the compiler came out, so perhaps the code works fine with the current development version of the compiler. If you feel comfortable you can get it from a CI build artefact on the github actions.
(I'm planning to release version 9.1 next week btw.)
P.S.
copying code from a screenshot is ... kinda hard
you can paste the code here and surround it with the mono or pre tags or use those markup buttons above the text entry, this way we can simply copy and paste the program text
Re: Prog8 language and compiler topic
Here's a zip file with a couple of demo programs.....you'll have to rename them to .p8 from .asm...(my editor only allows .asm files.....I know ).desertfish wrote: ↑Sun Jul 09, 2023 8:00 pm I think I understand what you're trying to do here. In the first code snippet, is p_str the pointer to the name for the new high score entry?
At first glance I don't see anything wrong with the first snippet. I will have to compile it myself in a small test program to see how it behaves, but this will take a while to figure out.
Maybe you're triggering a prog8 compiler bug! I have fixed a few compiler bugs since the 9.0 version of the compiler came out, so perhaps the code works fine with the current development version of the compiler. If you feel comfortable you can get it from a CI build artefact on the github actions.
(I'm planning to release version 9.1 next week btw.)
P.S.
copying code from a screenshot is ... kinda hard
you can paste the code here and surround it with the mono or pre tags or use those markup buttons above the text entry, this way we can simply copy and paste the program text
hiscore doesn't work correctly, hiscore4 does, so far as inserting a new high score into the 'top 10', but I'm working on writing the updated data to a file...which seems to work, but when I go back and try and re-read the updated file, it fails and I haven't figured out why yet. On re-running the emulator and program, it loads/displays fine again. Technically, I might never need re-read the data file during a program run (thinking 'out loud' now), strictly working on already filled arrays....but it seems like this should still work.
- Attachments
-
- hiscores.zip
- (2.91 KiB) Downloaded 443 times