LPRINT on ZX81?

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Done.
Please check your spam folder. Somewhere between e-mails about penis enlargement and viagra offers is a picture made by my printer ;-)

Siggi
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

interesting, the real printout looks very different, the readability is very good. I'll add the blank row.
the V letter was like that to limit the characters touching with no space between them, but I think it can be made symmetric somehow.
and. . yes you were filtered out by the anti spam :(
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Image

Font updated and line spacing added. The full ASCII font is a hidden option, which can be enabled, tuned and integrated with extra characters for special needs. There is a problem on a single pixel, so a vertical pixel line shows the glitch .. I don't know if it will happen on the real HW, but if so it is a problem on the buffer printing code rather than on lprintc5().
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:The full ASCII font is a hidden option, which can be enabled, tuned and integrated with extra characters for special needs.
Could these extra characters also be used for Olli's ZEDIT, where some special characters are multi-byte characters (>0x80)?
... but if so it is a problem on the buffer printing code rather than on lprintc5().
Do you mean the "buffer printing code" in ROM?

Some of us have rom-patches for own printers (like Centronics printers or my "network printer" via ZeddyNet).
So if that rom code is used (at least in TEXT mode 32 chars/line), lprintc will probably work also with a patched rom for other printers (if the patched rom code has the same entry points).
Which lprint variants use the rom code for printing?

Siggi
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

zx_lprintc() ROM based. zx_lprintc5() calls a custom driver printing 256 graphics bytes from a buffer at once. this driver could need more tuning (e.g I notice the bottom row in a text line in your photo not being regular and on the emulator I noticed some error of few pixels) but I think I'm lucky it works on the real hw
I'll probably write the whole zx printer driver for zedit, there is so little to add :)
The fonts are my own creations,
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Stefano
using the build date Aug. 8 printing does not woek perfectly:
using this code the ZX81 (also EO) the program the screen get flickering and the program does not continue

Code: Select all

void lprint(unsigned char *text)
{
        while (*text)
        {
                zx_lprintc(*text++);
        }
}


        fgets(message, 100, stdin);
        lprint(message);
        printk("Done\n");
Everything works perfectly, when I call zx_fast() before and zx_slow() after lprint.


And: the Z88DK print routines should not call zx_slow/zx_fast!
They should switch only temporarily to FAST and should return to the same mode before print has been calledd (could also be FAST!)
The original rom print routines use this calls:

Code: Select all

CALL        02E7,SET-FAST
..
CALL        0207,SlOW-FAST
Siggi
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

PS: zx_lprintc5 and zx_lprintc gives a funny pixel pattern at printer, when called during WRX ANSI mode (64 chars/line) ;-)
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

hello Siggi, I can't understand the reason for the pattern oddity, I'll investigate (slowly because I'll be on holiday for a while) .
also the slow/ fast issue requires some work, because there are many different versions of zx_fast / zx_slow depending on the current clib configuration. it is strange that forcing fast is solving the problem this is one more thing to understand
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I still need to check the WRX case, but the test program works correctly for me on EO with both zx_lprintc and zx_lprintc5.


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

void lprint(unsigned char *text)
{
while (*text)
{
zx_lprintc5(*text++);
}
}

void main()
{
char message[100];
fputc_cons("___ ");
fgets(message, 100, stdin);
lprint(message);
printk("Done\n");
}
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

I have downloaded the current nightly z88dk build.
Nevertheless the program fails (EO V0.52) after the first lprint ("DONE" is still printed):

Code: Select all

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

void lprint(unsigned char *text)
{
    while (*text)
    {
        zx_lprintc(*text++);
    }
}

void main()
{
    unsigned int i;
    char message[100];
//        fputc_cons("___ ");

    fgets(message, 100, stdin);

    for (i = 0; i < strlen(message); i++)
            printk("%u:%u\n", i, (unsigned int) message[i]);
    in_Wait(2000);
    lprint(message);
    printk("Done\n");
    in_Wait(2000);
    lprint("longlonglonglonglonglonglonglonglong\r");
    printk("done CR\n");
    in_Wait(2000);
    lprint("longlonglonglonglonglonglonglonglong\n");
    printk("done LF\n");
    in_Wait(2000);
}
compiled using
zcc +zx81 -startup=2 -Cz--disable-autorun -create-app -vn -O3 -o ptest.bin printtest.c

I have entered the text "huhu". The text is terminated by <LF> (10)

???
Siggi
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

When I surround lprint by zx_fast/slow, everthing works as expected:

Code: Select all

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

void lprint(unsigned char *text)
{
    while (*text)
    {
        zx_lprintc(*text++);
    }
}

void main()
{
    unsigned int i;
    char message[100];
//        fputc_cons("___ ");

    fgets(message, 100, stdin);

    for (i = 0; i < strlen(message); i++)
            printk("%u:%u\n", i, (unsigned int) message[i]);
    in_Wait(2000);
    zx_fast();
    lprint(message);
    zx_slow();
    printk("Done\n");
    in_Wait(2000);
    zx_fast();
    lprint("longlonglonglonglonglonglonglonglong\r");
    zx_slow();
    printk("done CR\n");
    in_Wait(2000);
    zx_fast();
    lprint("longlonglonglonglonglonglonglonglong\n");
    zx_slow();
    printk("done LF\n");
    in_Wait(2000);
}
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:hello Siggi, I can't understand the reason for the pattern oddity, I'll investigate
Hi Stefano
I have downloaded Z88DK (ZIP for WINDOOFS) and used it as is. I did not MAKE any ZX81 specific lib, because WIN does not MAKE anything ;)
Is that the reason that I get different results like you have?

Siggi
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

no, hopefully the libraries are updated and pre-built, so the only expected difference is the one we discussed for lp.c
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Stefano
using the nightly build the state is the same: printing works, when printing is done in fast mode, like this:

Code: Select all

void lprintc (unsigned char c)
{
    if (c == '\n')
            zx_fast(); /* Workaround for Z88DK problem during print */
    zx_lprintc(c);
    if (c == '\n')
            zx_slow();
}
What must I do to get 64 chars/line on printer, like the ANSI mode does on screen?
Currently I get 32 chars/line using the code above. I compile using this:
zcc +zx81 -DHIRES_SCREEN=49152 -O3 -vn -clib=ansi -subtype=_wrx -create-app -llibsocket -o irc-ansi.bin irc.c inputline.c statusline.c output.c ircsvrmsg.c usercmd.c -DUSE_ANSI_MODE

The "funny pixel pattern " I noticed before might be caused by a rom patch of my ZX81 rom. Are the rom printer routines used during ANSIMODE printing?

Siggi
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Hello Siggi,
the direct text output on the ZX_PRINTER at the moment permit only 32 columns (zx_lprintc) and 51 columns (zx_lprintc5) only, with the standard ZX81 text characters.
The hardcopy function will work in the current graphics mode, though. A possible approach for a long printed banner trying to save memory could be, in example, to work in 64 rows WRX mode and split your artwork/text into pieces printing them sequentially.

So, the ANSIMODE printing is still absent but feasible. To extend the library furtherly we must first decide how we want it to work.. probably it is just a matter of providing yet another function in parallel to zx_lprintc, say zx_glprintc, which could pick the text settings from the ANSI VT engine.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I'm also thinking at the zx_fast() workaround. zx_lprintc should have been safe, because it is restoring the registers before doing ROM related stuff but obviously something is not working.. is zx_fast() needed also when you run in other modes than WRX ?
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Yes, zx_fast() is also necessary for usual text mode (EO also shows the problem).
Maybe its not a problem or registers, but system variables (which are also set/reset by zx_slow/zx_fast)?

I thought, that zx_lprintc() would use the same font/characters that are used for current screen output. So only one function would be needed for text and ANSI mode.

My current project is the IRC chat program, where each char written to screen should also be printed (if the user is absent, he could later read on the printer, what has been discussed meanwhile).
Hardcopy would be possible, but prints more things than necessary (e. g. bottom status line and the input line of the chat program).

IRC chat is available in lowres text version and ANSI mode.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

zx_lprintc is just a bridge to the rom function, so the used font is the rom one
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

zx_lprintc5 aims to be a compact text output of zx_lprintc, it uses few tricks to compress the font
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:zx_lprintc is just a bridge to the rom function, so the used font is the rom one
Thus it's not possible to lprint UDG like zx_hardcopy does?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

yes, you're right, the zx_lprintc was my very first attempt and is quite straightforward
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Stefano
why does zx_lprintc.asm contain a special handling of LF? I think, the normal coversion function asctozx81() would also cover this special char.

Siggi
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:I'm also thinking at the zx_fast() workaround. zx_lprintc should have been safe, because it is restoring the registers before doing ROM related stuff but obviously something is not working.. is zx_fast() needed also when you run in other modes than WRX ?
Hi Stefano,
the routine "SLOW/FAST" called at end of printing in ROM:

Code: Select all

08DE COPY-END        CALL        0207,SlOW-FAST
                POP        BC
behaves differently when called in SLOW vs. FAST:

Code: Select all

THE DISPLAY ROUTINES:

i) Test for SLOW or FAST Mode.

The SLOW flag, Bit 6 of CDFLAG is tested, and a return is made if the program is in FAST mode or 'SLOW' display is not available.

0207 SLOW/FAST        LD        HL,+CDFLAG
                LD        A,(HL)
                RLA
                XOR        (HL)
                RLA
                RET        NC
                LD        A,+7F
                EX        AF,A'F'
                LD        B,+ll
                OUT        (+FE),A
0216 LOOP-11        DJNZ        0216,LOOP-11
                OUT        (+FD),A
                EX        AF,A'F'
                RLA
                JR        NC,0226,NO-SLOW
                SET        7,(HL)
                PUSH        AF
                PUSH        BC
                PUSH        DE
                PUSH        HL
                JR        0229,DISPLAY-1
0226 NO-SLOW        RES        6,(HL)
                RET
In SLOW mode, it jumps to DISPLAY-1. Maybe this causes trouble?????

Siggi
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I'm not sure but it is a good hint.

I'm thinking at the way to improve the zx printer support, I think I found a quick win in a simple hardcopy function to copy a single given line, then a zx_glprintc is probably needed.
Post Reply