I think I see what's happening in the emulator. In r42, support for raster effects was added to the video rendering code.
The way it works is, anytime a VERA register is updated which would change what's on the screen, the emulator will partially render the current scanline with the old VERA state based on how many pixels would've made it to the display already, then update the VERA state so when the scanline is rendered the rest of the way, it reflects the changed state.
The way it does a partial render is, it renders a full scanline first, then copies the relevant pixels into the line buffer which eventually gets painted to the window.
The problem is, when you use MACPTR to write 10240 bytes to the VERA's data port, the emulator will end up rendering 10240 full scanlines in a vain attempt to try to support any raster-effects it might cause, but MACPTR in the emulator is instant, so 10240 scanlines get rendered and zero pixels actually get used.
I think this is what's causing the emulator to lag so much on this program, but the way you'd improve this would probably require an overhaul of the rendering code so that the VERA's state is only actually looked at when the next pixel of the scanline needs to be output, versus trying to pre-empt it by rendering a full scanline and only sometimes copying pixels from it. I've written a software rendering pipeline like this before, so I can offer some suggestions if needed.
EDIT: I'm pretty sure this is what it is, so I posted a thread about it in the bug report forum.
PCM audio streaming error
Re: PCM audio streaming error
Last edited by DragWx on Sat Apr 08, 2023 7:14 am, edited 1 time in total.
- desertfish
- Posts: 1098
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: PCM audio streaming error
One extra observation:
Streaming stuff from SD card image generally works better in x16emu, than using the hostfs. Hostfs seems to support all operations, but the timings seem off. So you may want to try copying the stuff to sdcard image and run it from there, even though it mostly works on hostfs.
(box16 *requires* SD card image because its hostfs support is not yet on the level of x16emu)
Streaming stuff from SD card image generally works better in x16emu, than using the hostfs. Hostfs seems to support all operations, but the timings seem off. So you may want to try copying the stuff to sdcard image and run it from there, even though it mostly works on hostfs.
(box16 *requires* SD card image because its hostfs support is not yet on the level of x16emu)
-
- Posts: 503
- Joined: Sat Jul 11, 2020 3:30 pm
Re: PCM audio streaming error
I tried uploading this to test out the Try It Now feature. Well, it sure didn't like that. I think maybe it's the file folder structure that's the problem. Gonna rewrite some code and try it again with everything in the same folder.
-
- Posts: 503
- Joined: Sat Jul 11, 2020 3:30 pm
Re: PCM audio streaming error
OK, trying this again in the hopes that the web assembler version of the emulator works better than the windows version. I changed the code so there's no subfolders anymore. Here's the zip file:
Try It Now!
...and whaddya know, it works! The sound isn't perfect, a few very quiet hisses and pops, but it's way better than on the windows emulator. Now I think I want to try again at double the horizontal resolution, and see just what the limits of the X16 really are.
And to try it now:Try It Now!
...and whaddya know, it works! The sound isn't perfect, a few very quiet hisses and pops, but it's way better than on the windows emulator. Now I think I want to try again at double the horizontal resolution, and see just what the limits of the X16 really are.
-
- Posts: 34
- Joined: Sat Feb 19, 2022 4:44 pm
Re: PCM audio streaming error
I think this is an issue particular to hostfs emulation on x16emu. Running it from an sdcard image is much closer to how it behaves on hardware.
It does run smoothly on hardware btw.
R42 does have an issue with the emu warping after a load which causes audio to bunch up and play fast for the first split second. This has been fixed in current master, but there are still problems that show up in situations like this demo. Lazy load in Calliope also stutters while it's loading the song in the background.
It does run smoothly on hardware btw.
R42 does have an issue with the emu warping after a load which causes audio to bunch up and play fast for the first split second. This has been fixed in current master, but there are still problems that show up in situations like this demo. Lazy load in Calliope also stutters while it's loading the song in the background.
-
- Posts: 503
- Joined: Sat Jul 11, 2020 3:30 pm
Re: PCM audio streaming error
Thanks for verifying that it works on the real hardware. Did you just try the version in this thread, or the one with double the video resolution in the r42 video demo thread?MooingLemur wrote: ↑Mon Apr 10, 2023 7:44 am I think this is an issue particular to hostfs emulation on x16emu. Running it from an sdcard image is much closer to how it behaves on hardware.
It does run smoothly on hardware btw.
R42 does have an issue with the emu warping after a load which causes audio to bunch up and play fast for the first split second. This has been fixed in current master, but there are still problems that show up in situations like this demo. Lazy load in Calliope also stutters while it's loading the song in the background.
-
- Posts: 34
- Joined: Sat Feb 19, 2022 4:44 pm
Re: PCM audio streaming error
I've found the issue. I mentioned the resolution in the "bug" thread, but I'll duplicate it here.
The hostfs intercept will advance the 6502 clock count by a value based on the elapsed wall clock time. MACPTR often exceeds 255 clocks worth of time, and *may* exceed 65535, however unlikely. This change fixes running INDY.PRG from hostfs.
This change has been merged into master.
The hostfs intercept will advance the 6502 clock count by a value based on the elapsed wall clock time. MACPTR often exceeds 255 clocks worth of time, and *may* exceed 65535, however unlikely. This change fixes running INDY.PRG from hostfs.
This change has been merged into master.
Last edited by MooingLemur on Wed Apr 12, 2023 6:57 am, edited 1 time in total.
-
- Posts: 34
- Joined: Sat Feb 19, 2022 4:44 pm
Re: PCM audio streaming error
Only the version from this thread so far.Ed Minchau wrote: ↑Wed Apr 12, 2023 5:31 am
Thanks for verifying that it works on the real hardware. Did you just try the version in this thread, or the one with double the video resolution in the r42 video demo thread?