I just did my first steps with z88dk - my "target" should be the ZX Spectrum and maybe later the ZX Spectrum Next. I must admit that my C knowledge is "basic" at most. Same is true for Z80 assembler...nevertheless the first things I usally do is to look into other peoples code and try to learn. I played a littlebit with example sources from the dk and from the web site and found something puzzeling. If I compile the appended code it behaves different if I load the code from tape or from microdrive. I tested this with Fuse, Spectaculator and (really!) with a real ZX Spectrum/ZX Interface 1/ZX Microdrive.
The microdrive-loaded code starts printing somewhere in the middle of the screen, which is obviously wrong (or somewhere else, if you omit some of the \n's).
/* Funny printf() test...
load the m-code from tape or...
load m-code from microdrive!
Remark: it does not make a difference
whether the BASIC loader is loaded from
tape or microdrive as well...
compiled with:
zcc +zx -lndos -create-app pload.c -opload */
#include <stdio.h>
#include <graphics.h>
#include <spectrum.h>
int main(void)
{
clg();
printf("\n\n\nSome text..\n");
printf("Even more text.\n\n");
printf("This program has been loaded - somehow!");
}
Hello, the clg() function does not reset the text position.
depending on the console driver you are linking the text output behaviour may change, nevertheless it is an odd thing that the default text position is affected ! the shadow rom dirties a lot of ram space, but it shouldn't create problems at your code, as long as you keep it at 32768 or high enough
As Stefano says, clg() doesn't reset the text position.
However, running your example with the latest code doesn't show the problem you've reported - the 64 column text starts from line 0 if the \n are deleted.
dom wrote:running your example with the latest code doesn't show the problem you've reported - the 64 column text starts from line 0 if the \n are deleted.
Ah, ok. I assume with "lastest code" you mean the lastest nightly build of z88dk? I'm was using v1.99B here.
cha05e90 wrote:Ah, ok. I assume with "lastest code" you mean the lastest nightly build of z88dk? I'm was using v1.99B here.
Yes, we're really, really bad at actually releasing. It'll be time to try again after the pending sdcc update. Until then, the nightlies are the best builds to take. There's been quite a few changes since 1.99B, https://github.com/z88dk/z88dk/blob/mas ... ngelog.txt is an incomplete summary of the changes.
I just downloaded the nightly build for Windows and - voil? - the resulting executable prints nice at the correct position, regardless from which media it was loaded (or whether Interface 1 ROM kicked in or not...). Thanks!