printf() position move - loaded from tape or microdrive!

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
cha05e90
Member
Posts: 21
Joined: Fri Jan 04, 2019 11:06 am

printf() position move - loaded from tape or microdrive!

Post by cha05e90 »

Hi,

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).

Am I doing something dumb or is it a bug? ;-)

Code: Select all

/* 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!");
        
 }
cha05e90
Member
Posts: 21
Joined: Fri Jan 04, 2019 11:06 am

Post by cha05e90 »

By the way: I came to the described behaviour while playing with

https://www.z88dk.org/wiki/doku.php?id= ... um:mdvtest
stefano
Well known member
Posts: 1628
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

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 ;)
User avatar
dom
Well known member
Posts: 1303
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

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.
cha05e90
Member
Posts: 21
Joined: Fri Jan 04, 2019 11:06 am

Post by cha05e90 »

stefano wrote:depending on the console driver you are linking
Hmm - I don't know which "console driver" I'm linking, looking at my compile line I suppose it uses the "default" one - whatever that might be! :-)
cha05e90
Member
Posts: 21
Joined: Fri Jan 04, 2019 11:06 am

Post by cha05e90 »

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.
User avatar
dom
Well known member
Posts: 1303
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

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.
cha05e90
Member
Posts: 21
Joined: Fri Jan 04, 2019 11:06 am

Post by cha05e90 »

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!
Post Reply