Re: ZXSimulator
Posted: Tue Oct 20, 2020 2:41 am
Another new version:
So whenever I try out a new ZX81 BASIC program I find some small bug or idiosyncrasy. If you gave the ZX81 Vroom clone a try you might have noticed that during change of track you saw a white streak...well what I did, whenever printing out either a full black block or a quarter-, half-, or three-quarter block I would first clear the screen with a block inverted (so usually that means a full white block as circled in red in picture) but that caused this side effect, plus it was inefficient code.
I was doing this in both block and grey routines, passing in 1 or 0 for true and false and then figuring out what to plot.
Why not instead pass in the color/pattern that I need and get rid of all that conditional. Then, I never have to invert the entire screen and just plot each quater-block (or pixel as they are seen in ZX81) as white or black.
So in the end less code. Not clear if it's faster or slower since I always do 4 block calls now whereas before I may have only done at minimum 2 and at maximum 5. But in the latter case I also had to do 4 conditionals, so it depends on how slow the block call is and if doing an 8x8 block takes more time than a 4x4 block (Update: new code is faster...)
But now the flicker in the Vroom clone is gone and it behaves exactly like it does on the ZX81.
P.S. qlforum wouldn't let me insert the code this time so I had to use pictures...kept giving me this page:
So whenever I try out a new ZX81 BASIC program I find some small bug or idiosyncrasy. If you gave the ZX81 Vroom clone a try you might have noticed that during change of track you saw a white streak...well what I did, whenever printing out either a full black block or a quarter-, half-, or three-quarter block I would first clear the screen with a block inverted (so usually that means a full white block as circled in red in picture) but that caused this side effect, plus it was inefficient code.
I was doing this in both block and grey routines, passing in 1 or 0 for true and false and then figuring out what to plot.
Why not instead pass in the color/pattern that I need and get rid of all that conditional. Then, I never have to invert the entire screen and just plot each quater-block (or pixel as they are seen in ZX81) as white or black.
So in the end less code. Not clear if it's faster or slower since I always do 4 block calls now whereas before I may have only done at minimum 2 and at maximum 5. But in the latter case I also had to do 4 conditionals, so it depends on how slow the block call is and if doing an 8x8 block takes more time than a 4x4 block (Update: new code is faster...)
But now the flicker in the Vroom clone is gone and it behaves exactly like it does on the ZX81.
P.S. qlforum wouldn't let me insert the code this time so I had to use pictures...kept giving me this page: