Printer programming
This page was last modified 15:26, 1 December 2019 by Gdx.

This page groups the system routines and various things related to the printer programming especially in assembler language.


Contents

Bios routines from the Main-ROM

There are routines designed to allow the programmer to access to the printer.

0018h (OUTDO)

Function: Sends one character to current device.
Entry: A = Character to sent.
PRTFLG (0F416h) = Must be different from zero to sends output to the printer or disk.
PTRFIL (0F864h) = Address of data file to sends the character. If 0000h, the character is sent to printer.
Output: None
Modify: None
Note: Call the Hook H.OUTD (0FEE4h).

00A5h (LPTOUT)

Function: Sends one character to the printer
Entry: A = Character code to send
Output: F = CY flag is set if the routine was interrupted by a CTRL+STOP
Modify: F
Notes:
  • Calls the hook H.LPTO (0FFB6h).
  • CTRL+STOP allows you to exit the routine if there is a problem with the printer.

00A8h (LPTSTT)

Function: Tests the printer status.
Entry: None
Output: A = 255 and the Z flag is reset when the printer is ready. A = 0 and the Z flag is set when not ready.
Modify: AF
Note: Call the Hook H.LPTS (FFBBh).

014Dh (OUTDLP)

Function: printer output.
Entry: A for data
Output: None
Modify: F
Note: Different from LPTOUT in the following points:
1. TAB is expanded to spaces
2. For non-MSX printers, hiragana is transformed to katakana and graphic characters are transformed to 1-byte characters.
3. If failed, device I/O error occurs.

System variables for the printer

F415h LPTPOS 1 Position of printer head.
F416h PRTFLG 1 Flag whether to send to printer. (0 = Print to screen / other = Print to printer)
F417h NTMSXP 1 0 If MSX printer (This converts Hiragana to Katakana on Japanese MSX)


Hooks called by printer routines of the system

Some system routine can be modified by using following hooks.

FEE4h H.OUTD Call: At the beginning of the Bios routine OUTDO, output a screen character or printer.

Usage: Process the routine.

FEE9h H.CRDO Call: At the beginning of the CRDO routine that sends a CR (0Dh) and a LF (code 0Ah).

Usage: Allows you to use a printer with an automatic line feed, for example.

FFB6h H.LPTO Call: At the beginning of the routine LPTOUT (Main-ROM at 00A5h).

Usage: Use of a non-MSX printer.

FFBBh H.LPTS Call: At the beginning of the routine LPTSTT (Main-ROM at 00A5h).

Usage: Use of a non-MSX printer.


Printer I/O ports

Related I/O ports to access the are below.

  • 90h (R) Bit 1 = 0 = Printer ready
  • 90h (W) Bit 0 = Strobe
  • 91h (W) Data bits 0-7
  • 93h (W) Direction control for bidirectional printer port (optional). This is unstandardized, only a few MSXs use this port. When used only bits 0 and 1 are take in account. (00 for Z state, 01/11 for Output, 10 for Input)

Sending data to printer

  • Check that I/O port 90h bit 1 = 0
  • Write data to I/O port 91h
  • Write 0 to I/O port 90h bit 0
  • Write 1 to I/O port 90h bit 1

Example:

SendChar:
	in	a,(90h)
	rrca
	rrca
	jr	c,SendChar
	ld	a,0Dh		;CR code
	out	(91h),a		;Set CR to output port
	xor	a
	out	(90h),a		;Generate strobe
	dec	a
	out	(90h),a		;Send CR code
	ret

Detection

N/A