;			Ver 2.0
;
;	This is an example of the source of the data file "prtctl.cfg"
;	which fits for ESC/P dots matrix printer with 24 pins
;
;	Get "prtctl.cfg" as in the following example
;
;	masm prtctl,,,,
;	link prtctl,,,,
;	exe2bin prtctl prtctl.cfg


ESC		equ	01bh	; This will be used in the following

	; This defines a format to send an integer
NO_NUM		equ	0	; no data of a number for the control sequence
BINARY_LTOH	equ	1	; send an integer by binary from low byte
BINARY_HTOL	equ	2	; send an integer by binary from high byte
DECIMAL_3	equ	3	; send an integer by 3 digits decimal figures
DECIMAL_4	equ	4	; send an integer by 4 digits decimal figures
DECIMAL_5	equ	5	; send an integer by 5 digits decimal figures
DECIMAL_V	equ	6	: send an integer by decimal figures

TOTAL_BYTE	equ	0x80	; multiply by VERT_BYTES
ISO_NUMBER	equ	0x40	; indicate the last digit character adding 10h
DIVIDEBY_2	equ	0x10	; devide by 2^j: j=0,1,2,3 -> DIVIDEBY_2*j
MULT_CONST	equ	0x08	; multiplied by constant

	; This defines the arrangement of 8 bits dots data into a byte
TOP_IS_LOW	equ	80h	; This is for PC-PR etc. not for ESC/P
				; The upper position in dots image corresponds
				;  to the lower position of bits in a byte data
TOP_IS_HIGH	equ	0	; This is the converse of the above

LEFT_IS_HIGH	equ	40h	; The first byte is a line
				; The left is higher bit
LEFT_IS_LOW	equ	0c0h	; The first byte is a line
				; The left is lower bit

VER_2_0		equ	'Q'	; Version 2.0

;--------- 1st part to be modified ---
DOT_TYPE	equ	TOP_IS_HIGH
				; Define the arrangement of dots
VERT_BYTES	equ	3	; This is for VERT_BYTES*8 pins printer
				; Should be smaller than 16
H_WMIN		equ	1	; The minimal width of horizontal skip is
				;  H_MIN*8 dots
H_WMAX		equ   (1440/8)	; The maximal width of horizontal skip and
				; the maximal width to send dots image data
				; in one time are H_MAX*8 dots width
;----------------------------------------------------------------------------

_code	segment

	org	0
begin	label byte

;---------------- 2nd part -----------
;	Any , but should be shorter than 16 bytes
;
	db	'ESC/P 24 pin',0
;----------------------------------------------------------------------

	org	16			; Here begins the data part
	db	VER_2_0			; ID
	db	VERT_BYTES+DOT_TYPE
	db	ad_last - dot_cr	; this is 0ffh in VER_2_28
	db	dot_cr - begin
	db	nrm_cr - begin		; ignored in VER_2_28
	db	dotg - begin		; ignored in VER_2_28
	db	dots - begin		; ignored in VER_2_28
	dw	H_WMIN
	dw	H_WMAX

dot_cr	db	nrm_cr - dot_cr - 4	; length of the control sequence
	db	0
	db	?			; ignored
	db	NO_NUM			; no number

;---------------- 3rd part  ----------
; The control sequence to initialize to print, may be modified

	db	ESC, '3', 24		; LF means a line feed by 24/180 inch
	db	ESC, '?', 'Z', 27h	; ESC Z ... -> ESC * m 27h ...
;-----------------------------------------------------------------------

nrm_cr	db	dotg - nrm_cr - 4
	db	0
	db	?			; ignored
	db	NO_NUM			; no number

;---------------- 4th part -----------
; The control sequence to the orignal situation, may be modified
;
	db	ESC, '2'		; LF means a line feed by 1/6 inch
;-----------------------------------------------------------------------

dotg	db	dots - dotg - 4
	db	0
	db	dotgn - dotgt		; position of number to send (top=0)

;---------------- 5th part -----------
; The control sequence to print dots image, may be modified
;
	db	BINARY_LTOH		; send number by binary data from the
					;  low byte
dotgt	db	ESC, 'Z'		; sends bits image data
dotgn	db	?, ?			; a data for an integer number
					; Here more data may exists
;------------------------------------------------------------------------

;---------------- 6th part -----------
;	This part equals 0 if the horizontal skip by dots units is not 
;	supported.  Inn this case the 7-th part has no meaning.
;
dots	db	cr_lf - dots - 3
;------------------------------------------------------------------------
	db	0
	db	dotsn - dotst		; position of number to send (top=0)

;---------------- 7th part -----------
;	The control sequence for horizontal skip, may be modified
;
	db	BINARY_LTOH		; send number by binary data from the
					; low byte
dotst	db	ESC, '\'		; horizontal skip by dots units
dotsn	db	?, ?			; a data for an integer number
					; Here more data may exist

;---------------- 8 th part ----------------------------------------------
;	This part defines a line feed

l_f	db	f_f - l_f - 4
;-------------------------------------------------------------------------
	db	0
	db	?			; ignored
	db	NO_NUM			; no number

;---------------- 9 th part ----------
;
	db	0dh, 0ah

;--------------- 11 th part -----------------------------------------------
	This part defines a form feed

f_f	db	after_bit - f_f - 4
;--------------------------------------------------------------------------
	db	0
	db	?			; ignored
	db	NO_NUM			; no number

;--------------- 12 th part -----------
;
	db	0dh, 0ch

;--------------- 13 th part -----------------------------------------------
	The control sequence after sending bit image block

after_bit	db	ad_last - f_f - 4
;--------------------------------------------------------------------------
	db	0
	db	?			; ignored
	db	NO_NUM			; no number

;--------------- 14 th part -----------
;
;--------------------------------------------------------------------------
ad_last	db	0
_code	ends
	end

