![]() |
Different result than expected when poking to screen - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +--- Thread: Different result than expected when poking to screen (/showthread.php?tid=763) |
Different result than expected when poking to screen - emook - 12-10-2016 Hello, In normal basic we can do this following code : Code: 10 BORDER 0: PAPER 0: INK 6: CLS ![]() To fill the screen with the desired colour (I know this example seems pointless, but the same method to poke a screen char is used quite a bit for me) however, in ZXB it only seems to pokes to the top third of the screen : Code: border 0 ![]() Anyone know what I am doing wrong here? Thanks! Re: Different result than expected when poking to screen - emook - 12-10-2016 OK - even though X and Y never exceed 255 they also have to be defined as Integers. dim x as uinteger dim y as uinteger Fixes the issue! I suspect this is due to the internal calculations done in ZXB. Re: Different result than expected when poking to screen - emook - 12-10-2016 Additionally - This seems to be massively slower than Hisoft basic compiler. In the following GIF I compile with HISOFT, then ZXB - you will see the difference in speeds. ![]() Re: Different result than expected when poking to screen - boriel - 12-25-2016 Yes, the 1st problem is for Uinteger overflow. But you can do this: Code: dim i as ubyte For example, 8 = 2^3, so to multiply per 8 you do (x << 3). The same applies to integer division with >>. Normally ZX Basic does this automatically, but for some reason it's not working in this case, so I put it explicitly. Compile this code with -O3 (optimize for speed) and tell me if it goes fast. Use -O3 (might have bugs!) when you have tested your program, to get a faster optimized code. Re: Different result than expected when poking to screen - emook - 12-27-2016 Yes much quicker! Thanks! ![]() Re: Different result than expected when poking to screen - britlion - 12-28-2016 [quote="emook"]Additionally - This seems to be massively slower than Hisoft basic compiler. See <!-- l --><a class="postlink-local" href="http://www.boriel.com/forum/zx-basic-compiler/topic385.html">zx-basic-compiler/topic385.html</a><!-- l --> for all the testing I did on this. Hisoft doesn't let you drop to hand coded assembly for where you really want the best speed, or allow you to add in stuff from the a library ( <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Library">http://www.boriel.com/wiki/en/index.php ... IC:Library</a><!-- m --> ) either! |