* Programm zum Drucken von ASCII-Texten
* (c) Jens Mller 14.08.1992

	output .PRG

	include "C:\TOSDEF.S"
	include "C:\AESDEF.S"


BCON	equ	2
esc	equ	27


*** Menu-Objekt-Struktur **********************************

E_Info		equ	9
E_DRUCKEN	equ	18
E_Ende		equ	20
E_PROP		equ	22
E_FETT		equ	23
E_DOPPELT	equ	24
E_KURSIV	equ	25
E_SCHATTEN	equ	26
E_UMRISS	equ	27
E_RAND		equ	29
E_USA		equ	31
E_DEUTSCH	equ	32
E_KLEIN		equ	34
E_HOCH		equ	35
E_SCHMAL	equ	36
E_BREIT		equ	37
E_ZEIL_V	equ	39
E_SPALT_V	equ	40
E_LINKS		equ	42
E_ZENTR		equ	43
E_RECHTS	equ	44
E_BLOCK		equ	45


	data

_o0	dc.w	-1,1,7,25,0,0,0,0,0,0,80,25
_o1	dc.w	7,2,2,20,0,0
	dc.l	$1181
	dc.w	0,0,80,513
_o2	dc.w	1,3,6,25,0,0,0,0,1,0,28,769
_o3	dc.w	4,-1,-1,32,0,0
	dc.l	_s0				* Desk
	dc.w	0,0,4,769
_o4	dc.w	5,-1,-1,32,0,0
	dc.l	_s1				* Datei
	dc.w	4,0,7,769
_o5	dc.w	6,-1,-1,32,0,0
	dc.l	_s2				* Schrift
	dc.w	11,0,9,769
_o6	dc.w	2,-1,-1,32,0,0
	dc.l	_s3				* Extras
	dc.w	20,0,8,769
_o7	dc.w	0,8,28,25,128,0,0,0,1,769,128,3351
_o8	dc.w	17,9,16,20,0,0
	dc.l	$FFFF1181
	dc.w	0,0,20,8
_o9	dc.w	10,-1,-1,28,0,0
	dc.l	_s4				* Info
	dc.w	0,0,20,1
_o10	dc.w	11,-1,-1,28,0,8
	dc.l	_s5
	dc.w	0,1,20,1
_o11	dc.w	12,-1,-1,28,0,0
	dc.l	_s6
	dc.w	0,2,20,1
_o12	dc.w	13,-1,-1,28,0,0
	dc.l	_s7
	dc.w	0,3,20,1
_o13	dc.w	14,-1,-1,28,0,0
	dc.l	_s8
	dc.w	0,4,20,1
_o14	dc.w	15,-1,-1,28,0,0
	dc.l	_s9
	dc.w	0,5,20,1
_o15	dc.w	16,-1,-1,28,0,0
	dc.l	_s10
	dc.w	0,6,20,1
_o16	dc.w	8,-1,-1,28,0,0
	dc.l	_s11
	dc.w	0,7,20,1
_o17	dc.w	21,18,20,20,0,0
	dc.l	$FFFF1181
	dc.w	4,0,11,3
_o18	dc.w	19,-1,-1,28,0,0
	dc.l	_s12				* Drucken
	dc.w	0,0,11,1
_o19	dc.w	20,-1,-1,28,0,8
	dc.l	_s13
	dc.w	0,1,11,1
_o20	dc.w	17,-1,-1,28,0,0
	dc.l	_s14				* Ende
	dc.w	0,2,11,1
_o21	dc.w	28,22,27,20,0,0
	dc.l	$FFFF1181
	dc.w	11,0,16,6
_o22	dc.w	23,-1,-1,28,0,0
	dc.l	_s15				* proportional
	dc.w	0,0,16,1
_o23	dc.w	24,-1,-1,28,0,0
	dc.l	_s16				* fett
	dc.w	0,1,16,1
_o24	dc.w	25,-1,-1,28,0,0
	dc.l	_s17				* doppelt
	dc.w	0,2,16,1
_o25	dc.w	26,-1,-1,28,0,0
	dc.l	_s18				* kursiv
	dc.w	0,3,16,1
_o26	dc.w	27,-1,-1,28,0,0
	dc.l	_s19				* Schatten
	dc.w	0,4,16,1
_o27	dc.w	21,-1,-1,28,0,0
	dc.l	_s20				* Umriž
	dc.w	0,5,16,1
_o28	dc.w	7,29,45,20,0,0
	dc.l	$FFFF1181
	dc.w	16,0,22,17
_o29	dc.w	30,-1,-1,28,0,0
	dc.l	_s21				* Rand
	dc.w	0,0,22,1
_o30	dc.w	31,-1,-1,28,0,8
	dc.l	_s22
	dc.w	0,1,22,1
_o31	dc.w	32,-1,-1,28,0,0
	dc.l	_s23				* USA
	dc.w	0,2,22,1
_o32	dc.w	33,-1,-1,28,0,0
	dc.l	_s24				* Deutschland
	dc.w	0,3,22,1
_o33	dc.w	34,-1,-1,28,0,8
	dc.l	_s25
	dc.w	0,4,22,1
_o34	dc.w	35,-1,-1,28,0,0
	dc.l	_s26				* klein
	dc.w	0,5,22,1
_o35	dc.w	36,-1,-1,28,0,0
	dc.l	_s27				* hoch
	dc.w	0,6,22,1
_o36	dc.w	37,-1,-1,28,0,0
	dc.l	_s28				* schmal
	dc.w	0,7,22,1
_o37	dc.w	38,-1,-1,28,0,0
	dc.l	_s29				* breit
	dc.w	0,8,22,1
_o38	dc.w	39,-1,-1,28,0,8
	dc.l	_s30
	dc.w	0,9,22,1
_o39	dc.w	40,-1,-1,28,0,0
	dc.l	_s31				* Zeilen verdichtet
	dc.w	0,10,22,1
_o40	dc.w	41,-1,-1,28,0,0
	dc.l	_s32				* Zeichen verdichtet
	dc.w	0,11,22,1
_o41	dc.w	42,-1,-1,28,0,8
	dc.l	_s33
	dc.w	0,12,22,1
_o42	dc.w	43,-1,-1,28,0,0
	dc.l	_s34				* linksbndig
	dc.w	0,13,22,1
_o43	dc.w	44,-1,-1,28,0,0
	dc.l	_s35				* zentriert
	dc.w	0,14,22,1
_o44	dc.w	45,-1,-1,28,0,0
	dc.l	_s36				* rechtsbndig
	dc.w	0,15,22,1
_o45	dc.w	28,-1,-1,28,32,0
	dc.l	_s37				* Blocksatz
	dc.w	0,16,22,1

_s0	dc.b	32,14,15,32,0
_s1	dc.b	' Datei ',0
_s2	dc.b	' Schrift ',0
_s3	dc.b	' Extras ',0
_s4	dc.b	'  Info...',0
_s5	dc.b	'--------------------',0
_s6	dc.b	'',0
_s7	dc.b	'',0
_s8	dc.b	'',0
_s9	dc.b	'',0
_s10	dc.b	'',0
_s11	dc.b	'',0
_s12	dc.b	'  Drucken',0
_s13	dc.b	'-----------',0
_s14	dc.b	'  Ende',0
_s15	dc.b	'  Proportional  ',0
_s16	dc.b	'  Fett',0
_s17	dc.b	'  Doppelt',0
_s18	dc.b	'  Kursiv',0
_s19	dc.b	'  Schatten',0
_s20	dc.b	'  Umriž',0
_s21	dc.b	'  Rand',0
_s22	dc.b	'---- Zeichensatz -----',0
_s23	dc.b	'  USA',0
_s24	dc.b	'  Deutschland',0
_s25	dc.b	'---- Zeichengr”že ----',0
_s26	dc.b	'  Klein',0
_s27	dc.b	'  Hoch',0
_s28	dc.b	'  Schmal',0
_s29	dc.b	'  Breit',0
_s30	dc.b	'----------------------',0
_s31	dc.b	'  Zeilen verdichten',0
_s32	dc.b	'  Spalten verdichten',0
_s33	dc.b	'----------------------',0
_s34	dc.b	'  Linksbndig',0
_s35	dc.b	'  Zentriert',0
_s36	dc.b	'  Rechtsbndig',0
_s37	dc.b	'  Blocksatz',0


*** Objekbaum fr Dialogbox "Rand" ************************

B0_OK	equ	5

_d0s0		dc.b	'linker Rand:',0
_d0s1		dc.b	'rechter Rand:',0
_d0_left	dc.b	'___',0
_d0s3		dc.b	'___',0
_d0s4		dc.b	'999',0
_d0_right	dc.b	'___',0
_d0s_ok		dc.b	'OK',0
_d0s_break	dc.b	'Abbruch',0

_d0t0	dc.l	_d0_left,_d0s3,_d0s4
	dc.w	3,6,0,$1180,0,-1,4,4
_d0t1	dc.l	_d0_right,_d0s3,_d0s4
	dc.w	3,6,0,$1180,0,-1,4,4

_d0o0	dc.w	-1,1,6,G_BOX,LASTOB,OUTLINED
	dc.l	$11100
	dc.w	0,0,24,7
_d0o1	dc.w	2,-1,-1,G_STRING,NONE,NORMAL
	dc.l	_d0s0
	dc.w	4,1,12,1
_d0o2	dc.w	3,-1,-1,G_STRING,NONE,NORMAL
	dc.l	_d0s1
	dc.w	3,2,13,1
_d0o3	dc.w	4,-1,-1,G_FTEXT,EDITABLE,NORMAL
	dc.l	_d0t0
	dc.w	18,1,3,1
_d0o4	dc.w	5,-1,-1,G_FTEXT,EDITABLE,NORMAL
	dc.l	_d0t1
	dc.w	18,2,3,1
_d0o5	dc.w	6,-1,-1,G_BUTTON,SELECTABLE+DEFAULT+EXIT,NORMAL
	dc.l	_d0s_ok
	dc.w	3,5,8,1
_d0o6	dc.w	0,-1,-1,G_BUTTON,SELECTABLE+EXIT+LASTOB,NORMAL
	dc.l	_d0s_break
	dc.w	13,5,8,1


	bss

d0x	ds.w	1		* zentrierte Koordinaten der Box
d0y	ds.w	1
d0w	ds.w	1
d0h	ds.w	1


*** Objektbaum fr Dialogbox "Anzahl der Kopien" **********

	data

B1_OK	equ	5

_d1s0	dc.b	'Datei:',0
_d1s1	dc.b	'Anzahl der Kopien:',0
_d1_num	dc.b	'__',0
_d1s2	dc.b	'__',0
_d1s3	dc.b	'99',0
_d1s4	dc.b	'Drucken',0

_d1t0	dc.l	_d1_num,_d1s2,_d1s3
	dc.w	3,6,0,$1180,0,-1,3,3

_d1o0	dc.w	-1,1,6,G_BOX,LASTOB,OUTLINED
	dc.l	$11100
	dc.w	0,0,28,8
_d1o1	dc.w	2,-1,-1,G_STRING,NONE,NORMAL
	dc.l	_d1s0
	dc.w	3,1,6,1
_d1o2	dc.w	3,-1,-1,G_STRING,NONE,NORMAL
	dc.l	fname
	dc.w	12,1,12,1
_d1o3	dc.w	4,-1,-1,G_STRING,NONE,NORMAL
	dc.l	_d1s1
	dc.w	3,3,18,1
_d1o4	dc.w	5,-1,-1,G_FTEXT,EDITABLE,NORMAL
	dc.l	_d1t0
	dc.w	23,3,2,1
_d1o5	dc.w	6,-1,-1,G_BUTTON,SELECTABLE+DEFAULT+EXIT,NORMAL
	dc.l	_d1s4
	dc.w	4,6,8,1
_d1o6	dc.w	0,-1,-1,G_BUTTON,SELECTABLE+EXIT+LASTOB,NORMAL
	dc.l	_d0s_break
	dc.w	16,6,8,1


	bss

d1x	ds.w	1		* zentrierte Koordinaten der Box
d1y	ds.w	1
d1w	ds.w	1
d1h	ds.w	1


*** Objektbaum fr Dialogbox "Drucken" ********************

	data

NO_PRN	equ	4
PRN_OK	equ	3


_d2s0	dc.b	'Ich drucke...',0
_d2s1	dc.b	'Abbruch mit UNDO oder ^C.',0
_d2s2	dc.b	'...nur der Drucker will nicht!',0

_d2o0	dc.w	-1,1,3,G_BOX,LASTOB,SHADOWED
	dc.l	$21100
	dc.w	0,0,35,6
_d2o1	dc.w	2,-1,-1,G_STRING,NONE,NORMAL
	dc.l	_d2s0
	dc.w	11,1,14,1
_d2o2	dc.w	3,-1,-1,G_STRING,NONE,NORMAL
	dc.l	_d2s1
	dc.w	5,4,26,1
_d2o3	dc.w	0,4,4,G_BOX,LASTOB,NORMAL
	dc.l	$1100
	dc.w	2,2,31,1
_d2o4	dc.w	3,-1,-1,G_STRING,LASTOB,NORMAL
	dc.l	_d2s2
	dc.w	0,0,31,1


	bss

d2x	ds.w	1		* zentrierte Koordinaten der Box
d2y	ds.w	1
d2w	ds.w	1
d2h	ds.w	1


*** Start *************************************************

	text

	do_start			* Programmstart
	appl_init			* beim AES anmelden
	move.w	d0,ap_id
	lea	_o0(pc),a0		* Objektb„ume anpassen
	move.w	#45,d0
	bsr	init_obj		* Menu
	lea	_d0o0(pc),a0
	move.w	#6,d0
	bsr	init_obj		* Dialogbox fr Rand
	lea	_d1o0(pc),a0
	move.w	#6,d0
	bsr	init_obj		* Dialogbox fr Anzahl
	lea	_d2o0(pc),a0
	move.w	#4,d0
	bsr	init_obj		* Dialogbox fr Drucken

* Dialogboxen zentrieren

	form_center #_d0o0
	move.w	int_out+2,d0x
	move.w	int_out+4,d0y
	move.w	int_out+6,d0w
	move.w	int_out+8,d0h

	form_center #_d1o0
	move.w	int_out+2,d1x
	move.w	int_out+4,d1y
	move.w	int_out+6,d1w
	move.w	int_out+8,d1h

	form_center #_d2o0
	move.w	int_out+2,d2x
	move.w	int_out+4,d2y
	move.w	int_out+6,d2w
	move.w	int_out+8,d2h

* Anfangsinitialisierung

	clr.b	esc_0		* Zeilenabstand 1/8 inaktiv
	clr.b	esc_l_n		* linker Rand = 0
	move.b	#79,esc_GQ_n	* rechter Rand = 79
	clr.b	esc_Att_n	* normaler Druckmodi
	move.b	#'0',esc_w_n	* Doppelthoch aus
	clr.b	esc_S0		* Hochstellung inaktiv
	clr.b	esc_kq_n	* Schriftstil normal (Schatten, Umriž)
	clr.b	esc_a_n		* Textausrichtung linksbndig
	clr.b	esc_R_n		* USA

* Pfad ermitteln

	call_gemdos Dgetdrv		* aktuelles LW ermitteln
	addq.l	#2,sp
	add.w	#'A',d0
	lea	path(pc),a0
	move.b	d0,(a0)+
	move.b	#':',(a0)+
	clr.w	-(sp)			* aktueller Pfad
	move.l	a0,-(sp)
	call_gemdos Dgetpath
	addq.l	#8,sp
	lea	t_all(pc),a0
	lea	path(pc),a1
	bsr.w	strcat

	menu_icheck #_o0,#E_USA,#1
	menu_icheck #_o0,#E_LINKS,#1

	graf_mouse #ARROW,#0	* Maus als Zeiger
	menu_bar #_o0,#1	* Menu darstellen

wait_for_event			* Hauptschleife
	evnt_mesag #mbuf
	cmp.w	#MN_SELECTED,mbuf
	bne.s	wait_for_event

* Abfrage des angeklickten Eintrages

	move.w	mbuf+8,d0
	pea	next_event	* alle Routinen mit RTS abgeschlossen
	cmp.w	#E_Info,d0
	beq	r_info
	cmp.w	#E_DRUCKEN,d0
	beq	print
	cmp.w	#E_Ende,d0
	beq	prg_end
	cmp.w	#E_PROP,d0
	beq	r_switch
	cmp.w	#E_FETT,d0
	beq	r_switch
	cmp.w	#E_DOPPELT,d0
	beq	r_switch
	cmp.w	#E_KURSIV,d0
	beq	r_switch
	cmp.w	#E_UMRISS,d0
	beq	r_switch
	cmp.w	#E_SCHATTEN,d0
	beq	r_switch
	cmp.w	#E_RAND,d0
	beq	r_rand
	cmp.w	#E_USA,d0
	beq	r_select
	cmp.w	#E_DEUTSCH,d0
	beq	r_select
	cmp.w	#E_ZEIL_V,d0
	beq	r_switch
	cmp.w	#E_SPALT_V,d0
	beq	r_switch
	cmp.w	#E_KLEIN,d0
	beq	r_klein
	cmp.w	#E_HOCH,d0
	beq	r_hoch
	cmp.w	#E_SCHMAL,d0
	beq	r_schmal
	cmp.w	#E_BREIT,d0
	beq	r_breit
	cmp.w	#E_LINKS,d0
	beq	r_select
	cmp.w	#E_ZENTR,d0
	beq	r_select
	cmp.w	#E_RECHTS,d0
	beq	r_select
	cmp.w	#E_BLOCK,d0
	beq	r_select
	rts

next_event
	menu_tnormal #_o0,mbuf+6,#1
	bra	wait_for_event


prg_end	form_alert #1,#alert_end
	cmp.w	#1,d0
	beq.s	prg_end1
	rts
prg_end1
	menu_bar #_o0,#0	* Menu abschalten
	appl_exit		* beim AES abmelden
	call_gemdos Pterm0


	data

alert_end
	dc.b	'[2][ | Programm verlassen?  ][Ja| Nein ]',0
alert_info
	dc.b	'[0]'
	dc.b	'[------- Puplic Domain -------  '
	dc.b	'|Drucken  von ASCII-Texten mit'
	dc.b	'|EPSON-LQ-kompatiblen Druckern'
	dc.b	'|   (c) Jens Mller 08/1992]'
	dc.b	'[  OK  ]',0
t_all	dc.b	'\*.*',0


	bss

esc_0		ds.b	1	* Zeilenabstand 1/8
esc_l_n		ds.b	1	* linker Rand
esc_GQ_n	ds.b	1	* rechter Rand
esc_Att_n	ds.b	1	* kombinierte Druckmodi
esc_w_n		ds.b	1	* Doppelthoch
esc_S0		ds.b	1	* Hochstellung
esc_kq_n	ds.b	1	* Schriftstil (Schatten, Umriž)
esc_a_n		ds.b	1	* Textausrichtung
esc_R_n		ds.b	1	* Land


knopf	ds.w	1
mbuf	ds.w	8
ap_id	ds.w	1
	ds.l	100
mystack	ds.l	1


	include "C:\AESLIB.S"

***********************************************************

* Wandelt Koordinatendarstellung von Zeichen in Pixel
* a0: Zeiger auf Objektbaum, d0.w: Anzahl der Objekte minus eins

	text

init_obj
	move.l	a0,-(sp)
	move.w	d0,-(sp)
	rsrc_obfix a0,d0
	move.w	(sp)+,d0
	move.l	(sp)+,a0
	dbf	d0,init_obj
	rts


* Info angeklickt

r_info	form_alert #1,#alert_info
	rts


* Routine fr Setzen/Rcksetzen eines einzelnen Menupunktes

r_switch
	moveq.w	#7,d1
	lea	tab1(pc),a0
	lea	tab2(pc),a1
	lea	tab3(pc),a2
r_switch1
	move.w	(a0)+,d2
	cmp.w	d2,d0
	beq.s	r_switch2
	addq.l	#1,a1
	addq.l	#4,a2
	dbf	d1,r_switch1
	rts
r_switch2
	move.b	(a1),d1
	move.l	(a2),a2
	move.b	(a2),d2
	and.b	d1,d2
	beq.s	r_switch3
	eor.b	d1,(a2)
	menu_icheck #_o0,d0,#0
	rts
r_switch3
	or.b	d1,(a2)
	menu_icheck #_o0,d0,#1
	rts


	data

	even
tab1	dc.w	E_PROP,E_FETT,E_DOPPELT,E_KURSIV,E_UMRISS,E_SCHATTEN
	dc.w	E_ZEIL_V,E_SPALT_V
tab2	dc.b	2,8,$10,$40,1,2,$FF,1
	even
tab3	dc.l	esc_Att_n,esc_Att_n,esc_Att_n,esc_Att_n
	dc.l	esc_kq_n,esc_kq_n,esc_0,esc_Att_n


	text

* Dialogbox fr "Rand" bearbeiten

r_rand	clr.l	d0
	move.b	esc_l_n,d0		* alte Werte in String wandeln
	lea	_d0_left(pc),a0
	bsr	dtoa
	clr.l	d0
	move.b	esc_GQ_n,d0
	lea	_d0_right(pc),a0
	bsr	dtoa

r_rand1	form_dial #FMD_START,d0x,d0y,d0w,d0h,d0x,d0y,d0w,d0h
	objc_draw #_d0o0,#0,#MAX_DEPTH,d0x,d0y,d0w,d0h
	form_do #_d0o0,#3
	move.w	d0,knopf
	form_dial #FMD_FINISH,d0x,d0y,d0w,d0h,d0x,d0y,d0w,d0h
	objc_change #_d0o0,knopf,d0x,d0y,d0w,d0h,#NORMAL,#0
	cmp.w	#B0_OK,knopf
	beq.s	r_rand2
	rts

r_rand2	lea	_d0_left(pc),a0		* Eingaben umwandeln
	bsr	atod
	cmp.w	#$FF,d0
	bhi	r_rand1
	move.w	d0,d3
	lea	_d0_right(pc),a0
	bsr	atod
	cmp.w	#$FF,d0
	bhi	r_rand1
	cmp.w	d0,d3
	bcc	r_rand1
	move.b	d3,esc_l_n
	move.b	d0,esc_GQ_n
	rts


* Routine fr Ausw„hlen eines aus mehreren Menupunkte

r_select
	moveq.w	#5,d1
	lea	tab4(pc),a0
	lea	tab5(pc),a1
	lea	tab6(pc),a2
	lea	tab7(pc),a3
r_select1
	cmp.w	(a1)+,d0		* Gruppennummer suchen
	beq.s	r_select2
	addq.l	#1,a0
	addq.l	#1,a2
	addq.l	#4,a3
	dbf	d1,r_select1
	rts
r_select2
	move.b	(a2),d6			* neuer Flag-Wert
	move.l	(a3),a6			* Zeiger auf Flag
	move.b	(a0),d2			* Gruppennummer

* bisher eingeschaltetes Objekt suchen
	move.w	d0,d3			* neues Objekt
	moveq.w	#5,d1
	lea	tab4(pc),a0
	lea	tab5(pc),a1
	lea	tab6(pc),a2
	lea	tab7(pc),a3
r_select3
	cmp.b	(a0)+,d2		* gleiche Gruppe?
	bne.s	r_select4
	move.b	(a2),d4
	move.l	(a3),a4
	cmp.b	(a4),d4			* war Objekt eingeschaltet?
	bne.s	r_select4
	move.w	(a1),d3			* ja -> Objektnummer holen
	bra.s	r_select5
r_select4
	addq.l	#2,a1
	addq.l	#1,a2
	addq.l	#4,a3
	dbf	d1,r_select3
r_select5
	move.b	d6,(a6)			* Flag neu gesetzt
	move.w	d0,-(sp)
	menu_icheck #_o0,d3,#0		* altes Objekt deselektieren
	move.w	(sp)+,d0
	menu_icheck #_o0,d0,#1		* neues Objekt selektieren
	rts


	data

* Kennung, welche Objekte zu einer Schaltergruppe geh”ren
tab4	dc.b	0,0,1,1,1,1
	even
tab5	dc.w	E_USA,E_DEUTSCH,E_LINKS,E_ZENTR,E_RECHTS,E_BLOCK
tab6	dc.b	0,2,0,1,2,3
	even
tab7	dc.l	esc_R_n,esc_R_n,esc_a_n,esc_a_n,esc_a_n,esc_a_n


	text

* Routinen fr Zeichengr”že

r_klein	tst.b	esc_S0			* falls KLEIN an, dann ausschalten
	bne.s	del_klein
	move.b	#-1,esc_s0		* KLEIN anschalten
	menu_icheck #_o0,d0,#1
	cmp.b	#'0',esc_w_n
	bne.s	del_hoch
	rts
del_klein
	clr.b	esc_S0
	menu_icheck #_o0,#E_KLEIN,#0
	rts


r_hoch	cmp.b	#'0',esc_w_n		* falls HOCH an, dann ausschalten
	bne.s	del_hoch
	move.b	#'1',esc_w_n		* HOCH anschalten
	menu_icheck #_o0,d0,#1
	tst.b	esc_S0
	bne.s	del_klein
	rts
del_hoch
	move.b	#'0',esc_w_n
	menu_icheck #_o0,#E_HOCH,#0
	rts


r_schmal
	moveq.w	#4,d1			* falls SCHMAL an, dann ausschalten
	and.b	esc_Att_n,d1
	bne.s	del_schmal
	or.b	#4,esc_Att_n		* SCHMAL anschalten
	menu_icheck #_o0,d0,#1
	move.w	#$20,d1
	and.b	esc_Att_n,d1
	bne.s	del_breit
	rts
del_schmal
	eor.b	#4,esc_Att_n
	menu_icheck #_o0,#E_SCHMAL,#0
	rts


r_breit
	move.w	#$20,d1			* falls BREIT an, dann ausschalten
	and.b	esc_Att_n,d1
	bne.s	del_breit
	or.b	#$20,esc_Att_n		* BREIT anschalten
	menu_icheck #_o0,d0,#1
	moveq.w	#4,d1
	and.b	esc_Att_n,d1
	bne.s	del_schmal
	rts
del_breit
	eor.b	#$20,esc_Att_n
	menu_icheck #_o0,#E_BREIT,#0
	rts


*** Datei drucken *****************************************

print	clr.b	fname
	fsel_input #path,#fname
	tst.w	int_out+2
	beq	print_ret		* Abbruch gedrckt
	lea	path(pc),a0		* vollst„ndigen Name generieren
	lea	file(pc),a1
	bsr	strcpy
	lea	file(pc),a0		* letzten Backslash suchen
	move.w	#'\',d0
	bsr.w	strrchr
	addq.l	#1,a0
	cmp.l	#1,a0
	bne.s	print1			* nicht vorhanden
	lea	file(pc),a0		* -> kein Pfad
print1	move.l	a0,a1
	lea	fname(pc),a0
	tst.b	(a0)			* leerer Dateiname?
	beq	print_ret
	bsr	strcpy

* Dialogbox zum Abfragen der zu druckenden Anzahl

	lea	_d1_num(pc),a0
	move.b	#'1',(a0)+
	clr.b	(a0)

print2	form_dial #FMD_START,d1x,d1y,d1w,d1h,d1x,d1y,d1w,d1h
	objc_draw #_d1o0,#0,#MAX_DEPTH,d1x,d1y,d1w,d1h
	form_do #_d1o0,#4
	move.w	d0,knopf
	form_dial #FMD_FINISH,d1x,d1y,d1w,d1h,d1x,d1y,d1w,d1h
	objc_change #_d1o0,knopf,d1x,d1y,d1w,d1h,#NORMAL,#0
	cmp.w	#B1_OK,knopf
	beq.s	print3
	rts

print3	lea	_d1_num(pc),a0
	bsr	atod
	move.w	d0,num
	beq	print2

* Datei ”ffnen

	clr.w	-(sp)
	pea	file
	call_gemdos Fopen
	addq.l	#8,sp
	move.w	d0,f_handle
	cmp.w	#-33,d0
	bne.s	print4
	form_alert #1,#no_file
	rts
print4	cmp.w	#-3,d0
	bge.s	print5
	form_alert #1,#no_open
	rts
print5	bsr	prn_os		* Drucker bereit?
	bne.s	print6
	form_alert #1,#no_printer
	cmp.w	#1,d0
	beq.s	print5
	bra	print_break
print6	graf_mouse #BUSYBEE,#0		* Dialogbox zeichnen
	form_dial #FMD_START,d2x,d2y,d2w,d2h,d2x,d2y,d2w,d2h
	move.w	d2w,d0
	asr.w	#1,d0
	add.w	d2x,d0
	move.w	d2w,d1
	asr.w	#1,d1
	add.w	d2x,d1
	form_dial #FMD_GROW,d0,d1,#0,#0,d2x,d2y,d2w,d2h
	objc_draw #_d2o0,#0,#1,d2x,d2y,d2w,d2h

* Drucker programmieren

	bsr	prn_init	* Init
	move.w	#20,zoll60	* Zeilenabstand bei Doppelthoch
	tst.b	esc_0
	beq.s	pm1
	bsr	prn_esc		* 1/8 Zoll Zeilenabstand
	move.w	#'0',d0
	bsr	prn_out
	move.w	#15,zoll60
pm1	bsr	prn_esc		* linker Rand
	move.w	#'l',d0
	bsr	prn_out
	clr.w	d0
	move.b	esc_l_n,d0
	bsr	prn_out
	bsr	prn_esc		* rechter Rand
	move.w	#'Q',d0
	bsr	prn_out
	clr.w	d0
	move.b	esc_GQ_n,d0
	bsr	prn_out
	bsr	prn_esc		* kombinierte Druckmodi
	move.w	#'!',d0
	bsr	prn_out
	clr.w	d0
	move.b	esc_Att_n,d0
	bsr	prn_out
	cmp.b	#'0',esc_w_n	* Doppelthoch
	beq.s	pm2
	bsr	prn_esc
	move.w	#'w',d0
	bsr	prn_out
	move.w	#'1',d0
	bsr	prn_out
	bsr	prn_esc		* Zeilenabstand neu programmieren
	move.w	#'A',d0		* in n/60 Zoll
	bsr	prn_out
	move.w	zoll60,d0
	bsr	prn_out
pm2	tst.b	esc_S0		* Hochstellung (kleine Schrift)
	beq.s	pm3
	bsr	prn_esc
	move.w	#'S',d0
	bsr	prn_out
	move.w	#'0',d0
	bsr	prn_out
pm3	bsr	prn_esc		* Schriftstil (Schatten, Umriž)
	move.w	#'q',d0
	bsr	prn_out
	clr.w	d0
	move.b	esc_kq_n,d0
	bsr	prn_out
	bsr	prn_esc		* Textausrichtung
	move.w	#'a',d0
	bsr	prn_out
	clr.w	d0
	move.b	esc_a_n,d0
	bsr	prn_out
	bsr	prn_esc		* Land
	move.w	#'R',d0
	bsr	prn_out
	clr.w	d0
	move.b	esc_R_n,d0
	bsr	prn_out

	move.w	#2,-(sp)		* Dateil„nge ermitteln
	move.w	f_handle,-(sp)
	clr.l	-(sp)
	call_gemdos Fseek
	lea	$A(sp),sp
	move.l	d0,f_len

print_loop_num				* Schleife fr Anzahl
	clr.w	-(sp)			* Dateizeiger zurcksetzen
	move.w	f_handle,-(sp)
	clr.l	-(sp)
	call_gemdos Fseek
	lea	$A(sp),sp
	move.l	f_len,i_len

print_loop
	pea	sign			 * 1 Byte einlesen
	move.l	#1,-(sp)
	move.w	f_handle,-(sp)
	call_gemdos Fread
	lea	$C(sp),sp
	cmp.l	#1,d0
	beq.s	p1_loop1
	form_alert #1,#no_read
	bra	print_finish
p1_loop1
	cmp.b	#158,sign
	bne.s	p1_sz_ch
	move.b	#225,sign
p1_sz_ch
	bsr	prn_os
	bne	p1_loop3

* Ausschrift ber Nichtbereitschaft des Druckers
	objc_draw #_d2o0,#NO_PRN,#MAX_DEPTH,d2x,d2y,d2w,d2h

p1_loop2
	bsr	tst_break
	beq	print_finish
	bsr	prn_os
	beq.s	p1_loop2
	clr.w	d0			* Zeichen drucken
	move.b	sign,d0
	bsr	prn_out
	objc_draw #_d2o0,#PRN_OK,#0,d2x,d2y,d2w,d2h
	bra.s	p1_next

p1_loop3				* Zeichen drucken
	clr.w	d0
	move.b	sign,d0
	bsr	prn_out
	bsr	tst_break
	beq.s	print_finish
p1_next					* Ende innere Schleife
	sub.l	#1,i_len
	bne	print_loop
	sub.w	#1,num
	tst.w	num
	beq.s	print_finish
	move.w	#12,d0
	bsr	prn_out
	bra	print_loop_num
print_finish
	bsr	prn_os			* zum Schluž wieder Init
	beq.s	print_f1
	bsr	prn_init
print_f1
	move.w	d2w,d0
	asr.w	#1,d0
	add.w	d2x,d0
	move.w	d2w,d1
	asr.w	#1,d1
	add.w	d2x,d1
	form_dial #FMD_SHRINK,d0,d1,#0,#0,d2x,d2y,d2w,d2h
	form_dial #FMD_FINISH,d2x,d2y,d2w,d2h,d2x,d2y,d2w,d2h

print_break
	move.w	f_handle,-(sp)		* Datei schliežen
	call_gemdos Fclose
	addq.l	#4,sp
	graf_mouse #ARROW,#0
print_ret
	rts


prn_os	call_gemdos Cprnos
	addq.l	#2,sp
	tst.w	d0
	rts


prn_esc	move.w	#esc,d0
prn_out	move.w	d0,-(sp)
	call_gemdos Cprnout
	addq.l	#4,sp
	rts


prn_init
	bsr.s	prn_esc
	move.w	#'@',d0
	bsr.s	prn_out
	rts


	data

no_file		dc.b	'[2][ | Datei nicht gefunden!  ][ Abbruch ]',0
no_open		dc.b	'[2][ | Datei kann nicht  | ge”ffnet werden!][ Abbruch ]',0
no_printer	dc.b	'[2][ | Drucker streikt!  ][OK| Abbruch ]',0
no_read		dc.b	'[2][ | Datei kann nicht  | gelesen werden!][ Abbruch ]',0


	bss

path		ds.b	128
fname		ds.b	128
file		ds.b	128
sign		ds.b	1
		even
zoll60		ds.w	1	* Zeilenabstand in 1/60 Zoll bei Dopplethoch
num		ds.w	1
f_handle	ds.w	1
f_len		ds.l	1
i_len		ds.l	1


*** Grundroutinen *****************************************

	text

* wandelt d0.w in ASCII-String (a0)
dtoa	moveq.w	#-1,d1			* Stellenz„hler
dtoa1	divu	#10,d0
	swap	d0
	move.w	d0,-(sp)
	clr.w	d0			* oberen 16 Bit = 0 wegen DIVU
	swap	d0
	addq.w	#1,d1
	tst.w	d0
	bne.s	dtoa1
dtoa2	move.w	(sp)+,d0
	add.w	#'0',d0
	move.b	d0,(a0)+
	dbf	d1,dtoa2
	clr.b	(a0)
	rts


* wandelt einen ASCII-String (a0) in Dezimalzahl (d0.w)
atod	clr.w	d0
atod1	clr.w	d1
	move.b	(a0)+,d1
	sub.w	#'0',d1
	bcs.s	atod2
	cmp.w	#9,d1
	bhi.s	atod2
	mulu	#10,d0
	add.w	d1,d0
	bra.s	atod1
atod2	rts


* h„ngt den String a0 an den von a1 an
strcat	tst.b	(a1)+
	bne.s	strcat
	subq.l	#1,a1

* kopiert einen String von a0 nach a1
strcpy	move.b	(a0)+,(a1)+
	bne.s	strcpy
	rts


* letztes Vorkommen des Zeichens in d0.b im String a0 suchen
* bei nicht Vorhandensein a0 = 0
strrchr	move.l	a0,a1
	sub.l	a0,a0
	subq.l	#1,a1
chr1	addq.l	#1,a1
	cmp.b	(a1),d0
	bne.s	chr2
	move.l	a1,a0
chr2	tst.b	(a1)
	bne.s	chr1
	rts


* Test auf Abbruch, d0.w=0 -> Abbruch
tst_break
	move.w	#BCON,-(sp)
	call_bios Bconstat
	addq.l	#4,sp
	tst.w	d0
	beq.s	tst_no_brk
	move.w	#BCON,-(sp)
	call_bios Bconin
	addq.l	#4,sp
	cmp.b	#3,d0
	beq.s	tst_1
	cmp.l	#$610000,d0
	bne.s	tst_no_brk
tst_1	form_alert #1,#t_break
	cmp.w	#1,d0
	bne.s	tst_no_brk
	clr.l	d0			* Abbruch
	bra.s	tst_end
tst_no_brk
	moveq.l	#-1,d0			* kein Abbruch
tst_end	tst.w	d0
	rts


	data

t_break	dc.b	'[2][ | Drucken Abbrechen?  ][Ja| Nein ]',0


*** Ende **************************************************

	END
