Incorrect PRINTAT definition

Bug reports (if you don't/won't have a Github account)
Post Reply
einar
Member
Posts: 47
Joined: Fri Sep 06, 2013 4:23 pm

Incorrect PRINTAT definition

Post by einar »

Sample file "z88dk/libsrc/_DEVELOPMENT/EXAMPLES/zx/demo_nirvanap/nirvanadem.c" contains the following definition:

Code: Select all

#define printAt(row, col)    printf("\x16%c%c", col<<1, row)
Sample file "z88dk/libsrc/_DEVELOPMENT/EXAMPLES/zx/demo_nirvanam/nirvanadem.c" contains the following definition:

Code: Select all

#define printAt(row, col)    printf("\x16%c%c", col, row)
Sample files "z88dk/libsrc/_DEVELOPMENT/EXAMPLES/zx/demo_bifrosth/bifrosthdem.c" and "z88dk/libsrc/_DEVELOPMENT/EXAMPLES/zx/demo_bifrostl/bifrostldem.c" contain the following definition:

Code: Select all

#define printAt(row, col)    printf("\x16%c%c", (col), (row))
I vaguely remember z88dk changing this behavior a while ago. Please update the first 2 files mentioned above, to use this last definition too.

Moreover, all 4 files above contain the following definitions:

Code: Select all

#define printInk(k)          printf("\x10%c", '0'+k)
#define printPaper(k)        printf("\x11%c", '0'+k)
It would be better to modify all 4 files as follows:

Code: Select all

#define printInk(k)          printf("\x10%c", '0'+(k))
#define printPaper(k)        printf("\x11%c", '0'+(k))
The lack of parenthesis doesn't make any difference in this case, but since these files are provided as examples for z88dk developers, it's better to provide fail-proof definitions, for programmers that will reuse the same definitions somewhere else.
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Fixed in March 2 build.
I vaguely remember z88dk changing this behavior a while ago.
Yes in the new C library the terminals are completely rewritten and therefore separate. The z88dk_tty terminal defines control codes differently than in a classic compile but there is a lot of overlap so most things work the same way.

Code: Select all

#define printInk(k)          printf("\x10%c", '0'+(k))
#define printPaper(k)        printf("\x11%c", '0'+(k))
should actually be:

Code: Select all

#define printInk(k)          printf("\x10%c", (k))
#define printPaper(k)        printf("\x11%c", (k))
since there is no longer an offset for parameter values. This probably has to be changed to add an offset (consider generating a string containing control codes and trying to encode INK 0) but at the moment there is none.
einar
Member
Posts: 47
Joined: Fri Sep 06, 2013 4:23 pm

Post by einar »

Thanks!
Post Reply