I'm working with some of the ZX Spectrum screen functions and stumbled across the different behavior of zx_attr() and zx_screenstr(). While the first one works as expected and returns an usable attribute byte the latter doesn't seem to work at all. Or - to be more precise - it returns usually a "32" (WHITESPACE) for empty screen portions and "0" (ZERO) for anything else, which is not what I expected. Am I doing something wrong here?
Hi, I just downloaded the lastest nightly build which seem to include dom's fix. Nevertheless a re-build of that little code snippet from above does not show any change. Sadly zx_screenstr() still does not return a valid code (except those standard WHITESPACEs for empty screen portions...).
I just tried the <conio.h> alternative, which seems to work (alas you have to switch to the standard ZX Spectrum "32-column-mode"). Thanks for this tip!
Which uses the ROM printer routine (so the same as calling from BASIC), prints 88 as expected so I've no idea what's happening for you unless you've not actually updated the library.
As to why the parameters are reversed on cvpeek() - I think that was to match up with gotoxy() and the other conio.h functions
dom wrote:...for you unless you've not actually updated the library.
Yeah, I checked again and indeed I'll have the new version. I must admit that i'm a littlebit puzzled, 'cos with my "code" it still doesn't work. Using your test code from above (incl. your build line incl. the pragma directive *and* the create-app) I were able to have the zx_screenstr() function working *once*! I assume there's still something fishy there. If you call the code via RANDOMIZE... a second time (after the "autoload" from the TAP file) you'll see that output and test promptly fails.
In the end I fiddled a littlebit and came to the conclusion that you have to (somehow?!?) have to reset the "cursor" position to make zx_screenstr() work again. This can be done for example via a simple BASIC "PRINT" command. So back to using my own "build" line (without pragma and create-app) I had to tweek the cursor position.
Timmy wrote:screen$ and attr functions only works in 32 column mode, as far as i understand.
other modes are not supported (this is not my code obviously, but anything other than 32 column mode does not make sense at all).
Yes, seems so - which is indeed my "use case" (standard ZX Spectrum 32 column screen). But as dom said, the conio functions can do the same even for 64 column screens - really nice!
I spent a while chasing a weird problem and then realised fuse was emulating a Timex machine.
Anyway, I think what happens when you run from the basic prompt is that the K channel is the currently active one - so the wrong things appear on screen, thus you have to reset the cursor. We used to have ld a,2 ; call 5633 in the crt0 but it got removed a long time ago.