;	TEXT EDITOR V1.1 PRINT ROUTINE
;
;	     +-----------+
;	     |	WITHOUT  | IFF PICTURES
;	     +-----------+
;
;	read the text in BOBS:
;	read the font in FONT:
;
;
;	coded by GULLY and finished on 25/09/1989
;
	ll=80			;longer of your screen
	hh=256			;height of your screen
	exec=4

o:	bsr	initall

	lea	texte,a6	;adress of text to print
	clr.w	y
	clr.w	x
	bsr	printline

wait:	btst	#6,$bfe001
	bne	wait

	bra	saveall

	>extern "df1:font",font,736
	>extern "df1:info+",bobs,10000
;-----------------------------------------------	PRINTLINE
printline:
	clr.l	d0
	move.b	(a6)+,d0
	cmp.b	#0,d0
	beq	finline
	cmp.b	#32,d0
	blt	cr
	lea	fontchar,a0
	move.l	#-1,d7
find:	add.l	#1,d7
	cmp.b	(a0)+,d0
	bne	find
	lea	font,a0
	add.l	d7,a0
	bsr	affichechar
	lea	longchar,a0
	add.l	d7,a0
	clr.l	d7
	move.b	(a0),d7
	add.w	d7,x
	bra	printline
cr:	cmp.b	#01,d0
	bne	notmov
	add.l	#4,a6
	clr.l	d0
	move.b	1(a6),d0
	lsl.w	#8,d0
	move.b	0(a6),d0
	move.w	d0,x
	clr.l	d0
	move.b	3(a6),d0
	lsl.w	#8,d0
	move.b	2(a6),d0
	move.w	d0,y
	add.l	#5,a6
	bra	printline
notmov:	cmp.b	#05,d0
	bne	notret
	clr.w	x
	add.w	#8,y
	add.l	#5,a6
	bra	printline
notret:	cmp.b	#16,d0
	blt	notcou
	sub.b	#16,d0
	move.b	d0,color
	bra	printline
notcou:	cmp.b	#12,d0
	bne	nottab
	add.w	#ll,x
	bra	printline
nottab:	cmp.b	#7,d0
	bne	notbas
	add.w	#1,y
	bra	printline
notbas:	cmp.b	#6,d0
	bne	notbas
	sub.w	#1,y
	bra	printline
nothaut:bra	printline
finline:rts

;-----------------------------------------------	AFFICHE CHAR
affichechar:
	lea	bitplan1,a1
	move.w	y,d0	
	mulu	#[ll],d0
	add.w	d0,a1
	clr.l	d0
	move.w	x,d0
	and.l	#%1111111111111000,d0
	lsr.w	#3,d0
	add.l	d0,a1
	move.l	a1,a2
	add.l	#[ll*hh],a2
	move.l	a2,a3
	add.l	#[ll*hh],a3
	move.l	a3,a4
	add.l	#[ll*hh],a4
	move.w	x,d0
	and.l	#%111,d0	;decalage

	move.w	#7,d1
lettre:	clr.l	d2
	move.b	(a0),d2
	lsr.l	d0,d2
	bsr	bit
	add.l	#1,a1
	add.l	#1,a2
	add.l	#1,a3
	add.l	#1,a4
	move.b	(a0),d2
	lsl.w	#8,d2
	lsr.w	d0,d2
	bsr	bit
	add.l	#92,a0
	add.l	#79,a1
	add.l	#79,a2
	add.l	#79,a3
	add.l	#79,a4
	dbra	d1,lettre
	rts

bit:	btst	#0,color
	beq	bit0
	ori.b	d2,(a1)
bit0:	btst	#1,color
	beq	bit1
	ori.b	d2,(a2)
bit1:	btst	#2,color
	beq	bit2
	ori.b	d2,(a3)
bit2:	btst	#3,color
	beq	bit3
	ori.b	d2,(a4)
bit3:	rts
;-----------------------------------------------	INIT ALL
initall:move.l	exec,a6
	jsr	-132(a6)
	move.l	#coplist,$dff080

	move.w	#$c200,$dff100	;nbr de bitplans (nbr=5...)
	move.w	#$0088,$dff102	;pas de decalages
	move.w	#$0000,$dff104	;pas de priorite d'affichage
	move.w	#$3081,$dff08e	;coin inf gauche	
	move.w	#$30d1,$dff090	;coin sup droit		
	move.w	#$0038,$dff092	;debut bitplan		
	move.w	#$00d0,$dff094	;fin bitplan	

	move.w	#$84c0,$dff096	;acces dma
	move.w	#$8010,$dff09a	;autorise it copper

	move.w	#$000,$dff088
	move.l	#$0000000f,$dff180
	move.l	#$00f00f00,$dff184
	move.l	#$00ff0f0f,$dff188
	move.l	#$0ff00fff,$dff18c
	move.l	#$08f30008,$dff190
	move.l	#$00800800,$dff194
	move.l	#$00880808,$dff198
	move.l	#$08800888,$dff19c

	move.l	#bitplan1,d0
	lea	coplist,a0
	move.l	#3,d2
install:move.w	d0,6(a0)
	move.l	d0,d1
	swap	d1
	move.w	d1,2(a0)
	add.l	#8,a0
	add.l	#[hh*ll],d0
	dbra	d2,install

	rts
;-----------------------------------------------	SAVE ALL
saveall:move.l	exec,a6
	lea	gfxlib(pc),a1
	clr.l	d0
	jsr	-408(a6)
	move.l	d0,a4
	move.l	38(a4),$dff080
	clr.w	$dff088
	move.w	#$83e0,$dff096
	jsr	-414(a6)
	clr.l	d0
	rts



coplist:dc.w	$00e0,0,$00e2,0,$00e4,0,$00e6,0
	dc.w	$00e8,0,$00ea,0,$00ec,0,$00ee,0
	dc.w	$120,0,$122,0
	dc.w	$124,0,$126,0,$128,0,$12a,0,$12c,0,$12e,0,$130,0
	dc.w	$132,0,$134,0,$136,0,$138,0,$13a,0,$13c,0,$13e,0
	dc.w	$ffff,$fffe
gfxlib:	dc.b	'graphics.library',0
color:	dc.b	1
name:	blk.b	50,0
font:	blk.b	92*8,0
fontchar:
dc.b '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
DC.B '!@#$%&* ()_+|\=-/.,?<>',"'",'"[]{}:;',0
longchar:
dc.b 7,5,7,7,8,7,7,7,7,7
dc.b 7,7,6,7,7,6,7,7,3,7,7,4,8,7,7,7,7,7,7,5,7,7,8,8,7,7
dc.b 8,7,7,7,7,7,8,7,3,7,7,7,8,8,8,7,8,7,7,7,7,8,8,8,8,8
dc.b 5,8,8,7,8,8,8,8,5,5,8,7,3,8,7,7,8,3,4,7,6,6,4,6,5,5,6,6,3,4

even
x:	dc.w	000
y:	dc.w	200


bobs:			;read the text here !
blk.b	12*10,0
texte:
blk.b	10000,0


source:	blk.b	50000		;source 	IFF
dest:	blk.b	50000		;destination	BITMAP
bitplan1:blk.b	[ll*hh],0
bitplan2:blk.b	[ll*hh],0
bitplan3:blk.b	[ll*hh],0
bitplan4:blk.b	[ll*hh],0
