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 »

Addendum
I compiled using this:
zcc +zx81 -create-app -startup=4 -O2 -o dstar dstar.c
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Hello Siggi,
in my intention zx_hardcopy() is bound to the graphics library currently in use and varies depending on the graphics mode.
The graphics buffer being printed is the one defined by, e.g. the wrx driver. Since the buffer is memory demanding I tested it with the #pragma directive:
#pragma output hrgpage = 36096

ZX_LPRINTC is much simpler, it just calls RST 16 after enabling the printer flag, (then resets the printer flag in case the ROM will be used elsewhere).

I tested it all on eightyone and all looked in working order, but we all know that there are relevant differences when you try the code on the real hardware :(
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I suggest to use the compiler presets, eg: -clib=wrx, -subtype=wrx (or wrx64 if you wish to save memory and run faster)
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

ps: Hey, if it will ever work I'd love to see a picture of the real printer outputting dstar !
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Stefano
I noticed that DSTAR heavily plays aroound with the I register ans uses its own font. When I pressed 0 I got the standard char set and got block graphics on screen. Then pressing z gave the same character pattern on printer :-)

I then added a line (before the I regiser is modified) to print a startup message

Code: Select all

#ifdef __ZX80__
        gen_tv_field_init(0);
#endif
        zx_lprints("Startup main program");
but nothing is LPRINTed at startup. But when I press z for hardcopy I get a (probably buffered) text string printed above the hardcopied screen. Thus the end character to trigger printout of the buffered data seems to be wrong? I am using 0x0A and 0x0D:

Code: Select all

void zx_lprints(char *s)
{
        int i;
        for (i=0; i < strlen(s); i++)
                zx_lprintc(i);
        zx_lprintc(10);
        zx_lprintc(13);
}
Siggi
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

I compiled using this
zcc +zx81 -clib=wrx -subtype=wrx -create-app -startup=4 -O2 -o dstarwrx dstar.c
zcc +zx81 -create-app -startup=4 -O2 -o dstar dstar.c

and

// added by SE 21-07-2018
#include <zx81.h>
#include <string.h>
#pragma output hrgpage = 8192

DSTAR.P shows the correct screen, hardcopy prints wrong block graphics
DSTARWRX.P shows a weird pixel screen, which is not affected by any key press. But z (hardcopy) copies the same weird pixel pattern to printer :)
Thus hardcopy seems to work in a WRX environment. But not DSTAR.

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

Post by siggi »

Opps, that version of DSTAR seems to use UDG (which is supported bey ZxMore and EO, but not by a standard Zeddy). Thus no HIRES -> no output to HIRES screen ....
Perhaps I should use a different version????

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

Post by siggi »

That means for me:
- DSTAR uses UDG, but hardcopy does use standard charset: -> should use I register also in that mode
- hardcopy works in true HIRES mode (wrx)
- zx_lprintc seems to handle 0x0a/0x0d not correct (at least in the DSTAR environment)
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

If I understood the source code of zx_lprintc correct, the handling of 0x0D or 0x0A is wrong: in that case A is loaded with $76n (end of line in ZEDDY CHARSET). Then this char is put into the conversion routine asctozx81, which does lead to another character, which does not trigger printing the buffered data!

IMHO that conversion may not be done in this case.

Siggi

Code: Select all

.doput
IF STANDARDESCAPECHARS
        cp  10                ; CR?
        jr  nz,NoLF
ELSE
        cp  13                ; CR?
        jr  nz,NoLF
ENDIF
        ld        a,$76
.NoLF

        
IF FORzx80
;; LPRINT-CH
ELSE
        ;ld        ix,16384
        call    restore81
        set 1,(ix+1)        ; Set "printer in use" flag
ENDIF
        
.charpos
        ld         hl,0
        call asctozx81
        ;bit         6,a                ; filter out the dangerous codes
        ;ret         nz        

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

Post by stefano »

got it, either include gfx81udg, or use the generic dstar version
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Now the hardcopy gives the same picture :-)
Only the zx_lprintc function needs to be corrected.

Can I switch off the ASCII->ZX conversion, when I want to print ZX-chars (e. g. peeked from screen to print out only a part of the screen) when using zx_lprintc ?
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:ps: Hey, if it will ever work I'd love to see a picture of the real printer outputting dstar !
Sent by e-mail (hope your address I have is still valid) ...
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I try to elaborate what I meant, I worked on three different driver types, a simple jump into the ROM, character based variants and graphics based variants.
dstar on the zx81 can be run in all the possible graphics mode, moreover the version provided in the zx81 folder works in text mode, either using the normal font or by redefining the characters (or , iirc also by using graphics symbols available with the quicksilva expansion). the rom driver points always to the original rom font location, but I provided a variant for the mid resolution graphics (gfx81udg) which uses the ? register to find the font position. I that way it still works in text mode but the graphics symbols should be printed. the graphics mode is yet another option (well many options, they depend on the hrg mod in use...)
mixing text and graphics is still possible up to a certain level, but you must know what you are doing, e.g. copytxt() could move your text to gfx, the the zx_hardcopy in wrx mode could fit
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

answering to your last question: yes, the ascii conversion should be active and it should be possible to exclude it as usual
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

my email: name_surname at hotmail dot com
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

I have sent an e-mail at 21.07.2018 19:48 to this address ...
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

never got it, :(
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

found, you may guess where itwas :(
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:got it, either include gfx81udg, or use the generic dstar version
Where can I get this generic version?
When I search on github for DSTAR, I find page

https://github.com/z88dk/z88dk/wiki/dstar

When I click at "Click here to view the source code of dstar.c or its header file" I get "404: Not Found" :(

When I search in the old WIKI for DSTAR, I find page

https://www.z88dk.org/wiki/doku.php?id= ... ects:dstar

When I click at "Click here to view the source code of dstar.c ..." I get
The z88dk project's CVS data is in read-only mode, so the project may have switched over to another source-code-management system. To check, visit the Project Summary Page for z88dk and see if the menubar lists a newer code repository, such as SVN or Git.

The CVS data can be accessed as follows. You can run a per-module CVS checkout via pserver protocol:
cvs -z3 -d:pserver:anonymous@a.cvs.sourceforge.net:/cvsroot/z88dk co -P z88dk
cvs -z3 -d:pserver:anonymous@a.cvs.sourceforge.net:/cvsroot/z88dk co -P z88dk-bin

You can view a list of files or copy all the CVS repository data via rsync (the 1st command lists the files, the 2nd copies):
rsync -a a.cvs.sourceforge.net::cvsroot/z88dk/
rsync -ai a.cvs.sourceforge.net::cvsroot/z88dk/ /my/local/dest/dir/

If you are a project admin for z88dk, you can request that this page redirect to another repo on your project by submitting a support request.
which does not really help ....

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

Post by stefano »

z88dk/examples/dstar.c ;)
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

there can be similar confusion with Othello.c, it also works in both pure graphics mode or by redefining the characters
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Stefano
one more idea: would it also be possible to zx_lprintc 64 chars/line, using the ANSI character set (e. g during ANSI mode)? Of course buffering by the ROM routines would not work (handles only space for 32 characters).

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

Post by stefano »

well, the way I used to print wrx graphics can is very close to the Spectrum one. its core loop output 8 rows in graphics mode, and it shouldn't be difficult to feed a buffer with a different font .
that inner loop will surely become a function available to all the Sinclair clones. I'd like to create also a tiny variant for a single graphics row, which could be handy for direct driving the zx printer graphics from within a C program, but I don't know if the timing will be correct.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

another nice thing to do (not difficult) is to alter a text driver to provide also lowercase characters and few symbols ('@...) as they are remapped with z88dk. The hardcopy will look better than the video printout!
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:I'd like to create also a tiny variant for a single graphics row, which could be handy for direct driving the zx printer graphics from within a C program, but I don't know if the timing will be correct.
Such a function would also be nice to do a hardcopy of a single line (or several lines as a "window") of a HIRES screen. Then its paramters should be the address of the graphics and its length, because such a graphic line within the HIRES screen is NOT a null-terminated C string.
Post Reply