01-14-2023, 04:56 AM
(07-23-2019, 02:46 PM)hi mate. did you manage to solve the problem? Your function works perfectly although with the problem you say. You can't mix the PRINT function with CALL 8252 because it corrupts the printout. I have tried to change the channel to try to restore the flow to the screen but it doesn't work. Wrote: I also modified one of the arguments of the function
printOnChannel ( 3, bufferAddress , LEN(text) ) function where I have changed
that 3 that appears there, by numChannel to reuse the argument (without success).
I need to communicate my program with the printer. If you know something new I would appreciate it if you could let us know.
Thank you very much.
fito
maeloterkimHi![]()
I tried this program below, that works if i don't use PRINT instruction. I don't know why
There is a note on the program next to the PRINT instruction
maybe is a workaround wiith the compiling or something and streams
If i try directly with the s$ variable with @s$ the zx spectrum resets itself
I don't know how access to the memory address of the s$ for sending directly to the LPRINT routine
For this i did a intermediate variable printerStringBuffer that seems "to work" if i don't use PRINT
Maybe you can adjust to do a little library file with this example
You can try with the print and without the print for example on ZX Spin
You must first open the ZX printer output on ZXSpin, before running the example to see the output
This is good for example for debugging big list of numbers that don't fit on one screen
----------------------------------------------------------------------------------------------------------
' ROUTINE FOR TEST LPRINT
' PROGRAM BEGIN HERE
bufferPrinter:
DIM printerStringBuffer (32) AS UBYTE ' Buffer FOR PRINT 32 BYTES LINES
CLS ' CLEAR SCREEN
' TEST LPRINT
s$ = "PRINTER Routine Example"
printStringOnChannel(3, s$ , @printerStringBuffer(0))
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' If I put the following print the program does not work. Just do, the screen print.
' I don't know why. But if I don't put the print it works
' Just uncomment the print instruction to see it
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' PRINT "LPRINT done"
STOP ' PROGRAM END HERE
' SUBROUTINES BEGIN HERE
' SUBROUTINE THAT OPENS CHANEL 3 FOR LPRINT
' CHANNEL = 3 FOR "p" => "PRINTER"
SUB fastcall printOnChannel ( channel AS UBYTE, bufferAddress AS UINTEGER , lengthString AS UINTEGER )
ASM
;' A = CHANNEL CHOOSE
CALL 5633 ;' SelecT CHANNEL
POP HL ;' Return Address
POP DE ;' String Address
POP BC ;' String Length
PUSH HL ;' Save Return Address
CALL 8252 ;' print our string on the channel
END ASM
END SUB
' SUBROUTINE THAT COPY STRING s$ TO printerStringBuffer AND ADD END OF STRING
SUB stringToBuffer( text AS STRING, bufferAddress AS UINTEGER )
DIM index AS UBYTE
FOR f = 0 TO LEN (text) - 1
POKE ( bufferAddress + f ) , CODE ( text ( f ) )
index = f
NEXT f
POKE (bufferAddress+index+1),0 ' END of string
END SUB
' SUBROUTINE THAT Print a string on printer max length 31 characters
SUB printStringOnChannel(numChannel AS UBYTE, text AS STRING, bufferAddress AS UINTEGER)
' put the string on the buffer
stringToBuffer( text, bufferAddress )
' LPRINT string buffer
printOnChannel ( 3, bufferAddress , LEN(text) )
END SUB
' SUBROUTINES END HERE