ZX81: C console print position does not match BASIC print position

Bug reports (if you don't/won't have a Github account)
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Oops: error in BASIC program. Should be

Code: Select all

10 input a
20 print at a,0;peek 16442
User avatar
dom
Well known member
Posts: 1195
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

What's your compile line?

The "native" console output does keep the system variables updated, but the others don't.
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

"Same procedure as last year" (and the years before) ;-)

zcc +zx81 -Cz--disable-autorun -startup=2 -create-app -vn -O3 -o gmail.bin mini_getmail.c -llibsocket
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

But now I use:
"#define printf printk"
to save some bytes.

Does this make a difference?
Siggi
User avatar
dom
Well known member
Posts: 1195
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Thanks, it looks like it should be okay. The following:

Code: Select all

#include <stdio.h>
#include <input.h>
#include <zx81.h>

char lines @ 16442;

// Pause when screen gets full
int main(void)
{
    int ret_val = 0;
        zx_cls();
        for ( int i = 0; i < 10; i++ ) {
        printf("\n<cr>");
        printf("%d",lines);
        }
    return ret_val;
}
produces a nice countdown
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Indeed, it counts down.
But: this code does not work:

Code: Select all

        int ret_val = 0;
        zx_cls();
        printf("<4-test\n");
        for ( int i = 0; i < 30; i++ )
        {
        printk("\n<cr>");

        if (lines < 4)
        {
                zx_cls();
                printf("<4 found\n");
        }
        printk("%d",lines);
        }
The "<4" condition is never met ...
Siggi
User avatar
dom
Well known member
Posts: 1195
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

That?s because it was idiotically comparing to 0. Hopefully sorted in the next build.
User avatar
dom
Well known member
Posts: 1195
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

BTW it?s probably best as an unsigned char rather than a char - the generated code is better.
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Now it works :-)
Thanks
Siggi
Post Reply