LPRINT on ZX81?
LPRINT on ZX81?
Hi
is there any high level support of the printer (Sinclair printer routines in ROM) of a ZX81 in z88dk?
I am thinking of writing a network printer, running on a ZX81+printer (using ZeddyNet)
Siggi
PS: e. g. the BASIC program line interface???
is there any high level support of the printer (Sinclair printer routines in ROM) of a ZX81 in z88dk?
I am thinking of writing a network printer, running on a ZX81+printer (using ZeddyNet)
Siggi
PS: e. g. the BASIC program line interface???
Hi Stefano
I want to use the original Sinclair printer or compatible (Alphacom 32, Seikosha GP50S).
Text mode (zeddy character set incl. graphics!) would be OK. Hires would be nice to have ;-)
Maybe putting the text into a BASIC string variable (A$) and then call the BASIC line "LPRINT A$" would be possible, but is a special ZX81 solution (not portable). Perhaps there is a better solution?
Siggi
I want to use the original Sinclair printer or compatible (Alphacom 32, Seikosha GP50S).
Text mode (zeddy character set incl. graphics!) would be OK. Hires would be nice to have ;-)
Maybe putting the text into a BASIC string variable (A$) and then call the BASIC line "LPRINT A$" would be possible, but is a special ZX81 solution (not portable). Perhaps there is a better solution?
Siggi
The disadvantage of that solution is, that a "real" Basic program is needed (to hold the code line e. g. "100 PRINT A$" and the BASIC variable A$). Thus it would not be possible to run the compiled program above 32K without having its special "help" BASIC program at 16K.
MEMOTECH also uses BASIC-commands within MEMOCALC to "LOAD" and "SAVE" the spreadsheet data as program/variables using the BASIC commands. But they have this Basic-commands stored in EPROM@12K. They call a ROM routine, to which the address of the BASIC line in EPROM is passed and which interprets the BASIC command (starting with the command token and terminated by <CR>) there . Thus they don't need a BASIC line number to find that line in BASIC ram.
AFAIK that is not possible with the Z88DK implementation to run a BASIC line. Correct?
Currently I think calling the LPRINT-CH-routine in ZX81 (passing the ZX81-character to be LPRINTED in A) dircecty would be be best solution (also running above 32K without own BASIC program). Rom disassembly:
Siggi
MEMOTECH also uses BASIC-commands within MEMOCALC to "LOAD" and "SAVE" the spreadsheet data as program/variables using the BASIC commands. But they have this Basic-commands stored in EPROM@12K. They call a ROM routine, to which the address of the BASIC line in EPROM is passed and which interprets the BASIC command (starting with the command token and terminated by <CR>) there . Thus they don't need a BASIC line number to find that line in BASIC ram.
AFAIK that is not possible with the Z88DK implementation to run a BASIC line. Correct?
Currently I think calling the LPRINT-CH-routine in ZX81 (passing the ZX81-character to be LPRINTED in A) dircecty would be be best solution (also running above 32K without own BASIC program). Rom disassembly:
Code: Select all
;THE 'LPRINT-CH' SUBROUTINE
;Characters are added one by one to the printer buffer. Once the buffer is full, or a N/L character is entered the buffer is emptied.
0851 LPRINT-CH
CP +76
JR Z,0871,COPY-BUFF
LD C,A
LD A,(PR-CC)
AND +7F
CP +5C
LD L,A
LD H,+40
CALL Z,0871,COPY-BUFF
LD (HL),C
INC L
LD (PR-CC),L
RET
I prepared a very basic support for the zx81 and ZX Spectrum, zx_lprintc(chr) will, basing on the ROM routine output a single character to the printer buffer, NEWLINE will finalize the line printing.
I chose to avoid FASTCALL to be as close as possible to fputc_cons, in case someone would like to replace the stdout.
On the ZX81 the zx_ascimode() call can alter the character output behavior as it already happens for the console, by default the ASCII conversion is enabled (as usual).
The ZX128 works only in 48Kmode, probably because of the lack of a clean printer buffer area, so ATM I'm avoiding to insert the ROM3 interposer. The TS2068 seems in working order, while the Lambda printer does not seem to be properly emulated (I suppose it works on the real HW, if it ever existed) and the ZX80 does not support a printer at all.
I chose to avoid FASTCALL to be as close as possible to fputc_cons, in case someone would like to replace the stdout.
On the ZX81 the zx_ascimode() call can alter the character output behavior as it already happens for the console, by default the ASCII conversion is enabled (as usual).
The ZX128 works only in 48Kmode, probably because of the lack of a clean printer buffer area, so ATM I'm avoiding to insert the ROM3 interposer. The TS2068 seems in working order, while the Lambda printer does not seem to be properly emulated (I suppose it works on the real HW, if it ever existed) and the ZX80 does not support a printer at all.
fior the record, I was able to call the basic from within a c program:
https://github.com/z88dk/z88dk/blob/mas ... x_line.asm
more detail on zx_lprintc: the zx81 rom is designed to support text only output on the zx printer, so its default small 32 bytes space suffices.. the spectrum will use its 256 byte buffer .
the ringo zx81 clone does not seem to understand the printer redirection, other clones do.
it is definitely possible to provide a low level driver, eg. to support graphics hardcopy, I'll give it a try.
https://github.com/z88dk/z88dk/blob/mas ... x_line.asm
more detail on zx_lprintc: the zx81 rom is designed to support text only output on the zx printer, so its default small 32 bytes space suffices.. the spectrum will use its 256 byte buffer .
the ringo zx81 clone does not seem to understand the printer redirection, other clones do.
it is definitely possible to provide a low level driver, eg. to support graphics hardcopy, I'll give it a try.
Indeed!
Matthias wrote "Power BASIC", an extension to ZX81 Basic. It contains also HIRES and supports also printing an Sinclar printer. Docu and source is there:
http://www.swatosch.de/zx81/
Matthias wrote "Power BASIC", an extension to ZX81 Basic. It contains also HIRES and supports also printing an Sinclar printer. Docu and source is there:
http://www.swatosch.de/zx81/
Hi Stefano
I have been on holidays, so I could not check yet (coming soon ;-) )
I don't have the source of HRG-MS. But you could send an e-mail to Matthias (his address is on his page, link is given above).
And about HIRES printing: Wilf published this some years ago:
Regards
Siggi
I have been on holidays, so I could not check yet (coming soon ;-) )
I don't have the source of HRG-MS. But you could send an e-mail to Matthias (his address is on his page, link is given above).
And about HIRES printing: Wilf published this some years ago:
Code: Select all
I have attached the source code for a simple printer driver which
uses the same protocol as the built ZX LPRINT commands.
I wrote it as part of the WRX16 hires package to print HIRES screens
to the 2040 and similar printers.
It is easier to understand than the ZX ROM code and may shed some
light on the way that the ZX81 sends print data and tests printer
status. Unlike the the ROM code it sends the bitmapped HIRES display
file directly to the printer without converting character codes to
graphics bits. Hope this helps.
Best regards.
PWRX16 - HIRES GRAPHICS ROUTINE FOR THE ZX81 PRINTER
by W.RIGTER
A 52 BYTE PRINTER DRIVER FOR PRINTING A WRX16
BITMAPPED HIRES SCREEN THE ZX AND 2050 PRINTERS.
ILLUSTRATION OF THE ZX81 CORE PRINTER I/O PROTOCOL.
COMPARE THIS ROUTINE TO THE ZX81 ROM ROUTINE WHICH FIRST
CONVERTS CHARACTER CODES TO 64 GRAPHICS BITS BEFORE PRINTING
PWRX16 CALL 0F23 ;SET FAST MODE
LD E,CO ;REGISTER E = 192 LINES (192 X LOOP1)
LD HL,(ARRAY) ;REGISTER HL POINTS TO 256X192 BIT ARRAY
XOR A ;SET REGISTER BITS 0-7 TO ZERO
OUT FB,A ;START PRINTER (BIT 2=0)
LOOP1 IN A,FB ;GET PRINTER STATUS BYTE
RLA ;ROTATE BIT 7 (LF BUSY) TO C FLAG
JR NC,LOOP1 ;LOOP IF LINEFEED IS BUSY (C=0)
LD D,20 ;32 BYTES (256 BITS) PER LINE
LOOP2 LD B,08 ;REGISTER B = 8 X LOOP2 COUNTER
LD C,(HL) ;REGISTER C = 8 BITS TO BE PRINTED
LOOP3 IN A,FE ;GET PRINTER STATUS
RRA ;ROTATE BIT 0 (DATA READY) INTO C FLAG
JR NC LOOP3 ;LOOP IF DATA
LD A,C ;COPY C TO A
AND 80 ;REGISTER A BIT 7 IS PRINTER DATA BIT
OUT FB,A ;SEND DATA BIT TO PRINTER
RL C ;ROTATE NEXT DATA BIT TO BIT 7
DJNZ LOOP3 ;REPEAT 8 TIMES (BYTE = 8 BITS)
INC HL ;INCREMENT ARRAY POINTER TO NEXT BYTE
DEC D ;DECREMENT LOOP2 COUNTER
JR NZ LOOP2 ;REPEAT 32 TIMES
DEC E ;DECREMENT LOOP1 COUNTER
JR NZ LOOP1 ;REPEAT 192 TIMES
LD A,04 ;BIT 2 IS PRINTER ON/OFF BIT
OUT FB,A ;TURN OFF PRINTER
CALL 0F2B ;RESTORE SLOW MODE
RET ;BACK TO THE CALLING PROGRAM
Siggi
I did some experiment, this routine is heavily simplified and lacks the horizontal synchronization which, in my opinion, makes it useless.
On the other side it is very handy to learn how the ZX printer works, because the extra biasing would mess up the program loops: the missing parts are the pixel strobe sync and the speed control biasing (the stylus speed must be reduced in the last 2 of 8 pixel lines), both present in the ZX81 and Spectrum ROMs.
On the other side it is very handy to learn how the ZX printer works, because the extra biasing would mess up the program loops: the missing parts are the pixel strobe sync and the speed control biasing (the stylus speed must be reduced in the last 2 of 8 pixel lines), both present in the ZX81 and Spectrum ROMs.
I MADE IT !!
https://raw.githubusercontent.com/z88dk ... rdcopy.asm
It combines the ZX Spectrum driver and a hint by Wilf on how to wait for the line sync.
It should be easy to adapt it to all the HRG drivers (at the moment it runs on WRX only)
https://raw.githubusercontent.com/z88dk ... rdcopy.asm
It combines the ZX Spectrum driver and a hint by Wilf on how to wait for the line sync.
It should be easy to adapt it to all the HRG drivers (at the moment it runs on WRX only)
progress is here:
https://github.com/z88dk/z88dk/issues/853
I my opinion the results are interesting, the ts2068 hrg screen is printed by rotating it and the zx81 udg graphics mode includes a printer driver able to print redefined fonts
https://github.com/z88dk/z88dk/issues/853
I my opinion the results are interesting, the ts2068 hrg screen is printed by rotating it and the zx81 udg graphics mode includes a printer driver able to print redefined fonts
ZX80 version is ready for the next nightly build
In the link above you can see a screenshot of the zx80 font as it appears on the EO "printer" tool.
Luckily the text driver can work on the D-FILE directly, no need for extra buffers and probably it is also able to deal with a collapsed D-FILE.
The zx_lprintc(chr) is still missing, it would require the a 32 bytes buffer and the code to wrap up the line.
In the link above you can see a screenshot of the zx80 font as it appears on the EO "printer" tool.
Luckily the text driver can work on the D-FILE directly, no need for extra buffers and probably it is also able to deal with a collapsed D-FILE.
The zx_lprintc(chr) is still missing, it would require the a 32 bytes buffer and the code to wrap up the line.
Hi Stefano
I did some tests, using DSTAR.C of the examples\zy81 directory.
I added some code to LPRINT a line of text and to do a hardcopy. But I got unexpected results.
1) The text line "Hardcopy\n" is not printed at all
2) The hardcopy of the hires DSTAR screen shows ZX81 graphic and text characters, not the graphic as seen on screen
The size seems to be correct. And the printed text/graphic character blocks change, when the screen content is changed.
This are the changes I made to the example file:
DSTAR.H
DSTAR.C
Any ideas, what could be wrong?
I tested using a ZxMore running a ZX81 ROM and a Timex 2040 printer.
My question: does zx_hardcopy() only a hires screen copy or does it also a lowres copy (depending on current display mode)
Siggi
PS: Should is send some pictures by e-mail?
I did some tests, using DSTAR.C of the examples\zy81 directory.
I added some code to LPRINT a line of text and to do a hardcopy. But I got unexpected results.
1) The text line "Hardcopy\n" is not printed at all
2) The hardcopy of the hires DSTAR screen shows ZX81 graphic and text characters, not the graphic as seen on screen
The size seems to be correct. And the printed text/graphic character blocks change, when the screen content is changed.
This are the changes I made to the example file:
DSTAR.H
Code: Select all
#define K_SWITCH 'm' /* [SPACE] */
#define K_EXIT 'g' /* [Esc]/[Quit] */
#define K_CLEAR 'h'
// added by SE 21-07-2018
#define K_HARDCOPY 'z' /* COPY */
Code: Select all
#include <sound.h>
// added by SE 21-07-2018
#include <zx81.h>
#include <string.h>
Code: Select all
case K_CLEAR:
#ifdef SOUND
bit_fx4 (3);
#endif
SetupLevel();
break;
// added by SE 21-07-2018
case K_HARDCOPY:
zx_lprints("Hardcopy\r\n");
zx_hardcopy();
break;
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);
}
I tested using a ZxMore running a ZX81 ROM and a Timex 2040 printer.
My question: does zx_hardcopy() only a hires screen copy or does it also a lowres copy (depending on current display mode)
Siggi
PS: Should is send some pictures by e-mail?