Re: ZXSimulator
Posted: Sat Apr 04, 2020 9:32 am
Another new version:
This one adds both the PAUSE and the INKEY$ command. The latter is kind of important for writing anything interactive. Had to use a trap call for make that work but it does. Also fixed a few small bugs.
Also, I figured out how ZX81 does its PLOT and UNPLOT commands. It basically scans screen memory before plotting a 4x4 pixel block and if any of the 4x4 pixel blocks (so 16 bits) in the 8x8 pixel block are neither all 0's or all 1's then it clears the entire 8x8 pixel block as it has "detected" a character. However, this causes weird behavior when plotting over character graphics. If it's one of the all black graphics, it leaves is alone since those graphics pass its detection test (i.e. it doesn't detected characters) but if its one of the grey or partial-grey ones it clears them out (so it thinks those are characters).
If I want the same behavior I will have to get to the QL's screen memory to figure out what is already there using a similar algorithm (except that it won't be 16 bits for a 4x4 pixel block since the QL adds color). Or, I could keep track of all 8x8 blocks to see if they contain a character. With 22 rows by 32 columns of characters, that would lead to 704 possible characters or 704 bytes to fix that problem. That's likely too big of a memory hit to just fix that problem (seeing I want it to work on an unexpanded QL).
BTW, all these small incremental changes are me just pushing off finally adding floating point. That's really the final hurdle. To that point I also added the PI function except if you try it you'll see that for now it prints 3 instead of 3.1415927. I have some other inefficiencies in the interpreter that I may remove eventually. One example, instead of doing this: str = ch, I instead write a function setchp(str, i, ch) and I'm not quite sure why I did that. It adds an extra function call where none is needed.
This one adds both the PAUSE and the INKEY$ command. The latter is kind of important for writing anything interactive. Had to use a trap call for make that work but it does. Also fixed a few small bugs.
Also, I figured out how ZX81 does its PLOT and UNPLOT commands. It basically scans screen memory before plotting a 4x4 pixel block and if any of the 4x4 pixel blocks (so 16 bits) in the 8x8 pixel block are neither all 0's or all 1's then it clears the entire 8x8 pixel block as it has "detected" a character. However, this causes weird behavior when plotting over character graphics. If it's one of the all black graphics, it leaves is alone since those graphics pass its detection test (i.e. it doesn't detected characters) but if its one of the grey or partial-grey ones it clears them out (so it thinks those are characters).
If I want the same behavior I will have to get to the QL's screen memory to figure out what is already there using a similar algorithm (except that it won't be 16 bits for a 4x4 pixel block since the QL adds color). Or, I could keep track of all 8x8 blocks to see if they contain a character. With 22 rows by 32 columns of characters, that would lead to 704 possible characters or 704 bytes to fix that problem. That's likely too big of a memory hit to just fix that problem (seeing I want it to work on an unexpanded QL).
BTW, all these small incremental changes are me just pushing off finally adding floating point. That's really the final hurdle. To that point I also added the PI function except if you try it you'll see that for now it prints 3 instead of 3.1415927. I have some other inefficiencies in the interpreter that I may remove eventually. One example, instead of doing this: str = ch, I instead write a function setchp(str, i, ch) and I'm not quite sure why I did that. It adds an extra function call where none is needed.