
; Example 1. -- Printing Text --

; When run, press the left mouse button to view the text.

		include		hardware.i
		include		HW_Macros.i
		include		HW_Start.i

; 'poke' address of bit plane into Copper list

Main		move.l		#bitplane,d0		d0=addr of bitplane
		lea		CopPlanes,a0		a0->into Copper list

		move.w		d0,6(a0)		low word of address
		swap		d0
		move.w		d0,2(a0)		high word of address

; Enable bitplane and Copper DMA.

		move.w		#SETIT!DMAEN!COPEN!BPLEN,DMACON(a5)

; Now strobe the Copper list.

		move.l		#MyCopper,COP1LCH(a5)	address of list
		move.w		#0,COPJMP1(a5)		strobe Copper

; Wait for user to press the left mouse button

mouse		btst		#6,CIAAPRA
		bne.s		mouse

		lea		TestText,a0
		bsr		PrintString

; Wait for right mouse button to be pressed

mouse1		btst		#2,$dff016
		bne.s		mouse1

; And exit.

		rts

;		*************************
;		* Text Printing Routine *
;		*************************

; Entry	a0->start of string to print

; Corrupt	a0,a1,a2,d0

PrintString	move.l		a0,a2		move address into safe reg

; Get ASCII code of next character from the string

prt_loop	moveq.l		#0,d0		clear work register
		move.b		(a2)+,d0	d0=ASCII code of next char
		beq		prt_done	exit when code = 0

; Calculate address of character data

		sub.b		#' ',d0		subtract ASCII code for space
		asl.w		#3,d0		multiply by 8
		add.l		#FontData,d0	add start address of font
		move.l		d0,a0		a0->character graphics

; Calculate address in bit plane to start copying the character graphics

		moveq.l		#0,d0		clear work register
		move.w		prt_Y,d0	get Y coordinate
		mulu		#40,d0		x width of bit plane
		add.w		prt_X,d0	add X coordinate
		add.l		#bitplane,d0	add bit plane start address
		move.l		d0,a1		a1->destination in bit plane

; Copy character graphics into the bit plane.

		moveq.l		#40,d0		width of bit plane

		move.b		(a0)+,(a1)	copy 1st byte of character
		add.l		d0,a1		bump bit plane pointer

		move.b		(a0)+,(a1)	Copy 2nd byte of character
		add.l		d0,a1		bump bit plane pointer

		move.b		(a0)+,(a1)	Copy 3rd byte of character
		add.l		d0,a1		bump bit plane pointer

		move.b		(a0)+,(a1)	Copy 4th byte of character
		add.l		d0,a1		bump bit plane pointer

		move.b		(a0)+,(a1)	Copy 5th byte of character
		add.l		d0,a1		bump bit plane pointer

		move.b		(a0)+,(a1)	Copy 6th byte of character
		add.l		d0,a1		bump bit plane pointer

		move.b		(a0)+,(a1)	Copy 7th byte of character
		add.l		d0,a1		bump bit plane pointer

		move.b		(a0)+,(a1)	Copy 8th byte of character

; Update the X,Y print position

		move.w		prt_X,d0	get X
		addq.w		#1,d0		bump X
		cmp.w		#40,d0		boundary check
		blt.s		prt_doneX	skip if in range
		moveq.l		#0,d0		reset X
		addq.w		#8,prt_Y	bump Y

prt_doneX	move.w		d0,prt_X	update X
		bra		prt_loop	and loop for next character

prt_done	rts

prt_X		dc.w		0		X coordinate
prt_Y		dc.w		0		Y coordinate

;		**************************
;		* The text to be printed *
;		**************************

TestText	dc.b		'Press the right mouse button to exit!',0
		
		even

;		***************************
;		*     The Font Data       *
;		***************************

FontData
	dc.b	$00,$00,$00,$00,$00,$00,$00,$00	;" "
	dc.b	$18,$3C,$18,$18,$00,$18,$00,$00	;"!"
	dc.b	$36,$36,$6C,$00,$00,$00,$00,$00	;"""
	dc.b	$6C,$FE,$6C,$6C,$FE,$6C,$00,$00	;"#"
	dc.b	$10,$78,$D0,$7C,$16,$FC,$00,$00	;"$"
	dc.b	$C6,$CC,$18,$30,$66,$C6,$00,$00	;"%"
	dc.b	$38,$6C,$38,$6E,$6C,$3A,$00,$00	;"&"
	dc.b	$18,$18,$30,$00,$00,$00,$00,$00	;"'"
	dc.b	$1C,$30,$30,$30,$30,$1C,$00,$00	;"("
	dc.b	$38,$0C,$0C,$0C,$0C,$38,$00,$00	;")"
	dc.b	$00,$6C,$38,$FE,$38,$6C,$00,$00	;"*"
	dc.b	$00,$18,$18,$7E,$18,$18,$00,$00	;"+"
	dc.b	$00,$00,$00,$00,$18,$18,$30,$00	;","
	dc.b	$00,$00,$00,$7E,$00,$00,$00,$00	;"-"
	dc.b	$00,$00,$00,$00,$18,$18,$00,$00	;"."
	dc.b	$06,$0C,$18,$30,$60,$C0,$00,$00	;"/"
	dc.b	$3C,$66,$6E,$76,$66,$3C,$00,$00	;"0"
	dc.b	$18,$18,$38,$18,$18,$3C,$00,$00	;"1"
	dc.b	$3C,$06,$3C,$60,$62,$7E,$00,$00	;"2"
	dc.b	$7E,$4C,$18,$0C,$46,$7C,$00,$00	;"3"
	dc.b	$1C,$3C,$6C,$CC,$FE,$0C,$00,$00	;"4"
	dc.b	$7C,$60,$7C,$06,$4C,$78,$00,$00	;"5"
	dc.b	$3C,$60,$7C,$66,$66,$3C,$00,$00	;"6"
	dc.b	$7E,$46,$0C,$18,$30,$30,$00,$00	;"7"
	dc.b	$3C,$66,$3C,$66,$66,$3C,$00,$00	;"8"
	dc.b	$3C,$66,$66,$3E,$06,$0C,$18,$00	;"9"
	dc.b	$00,$18,$18,$00,$18,$18,$00,$00	;":"
	dc.b	$00,$18,$18,$00,$18,$18,$30,$00	;";"
	dc.b	$0C,$18,$30,$30,$18,$0C,$00,$00	;"<"
	dc.b	$00,$00,$7E,$00,$7E,$00,$00,$00	;"="
	dc.b	$30,$18,$0C,$0C,$18,$30,$00,$00	;">"
	dc.b	$7C,$46,$0C,$38,$00,$18,$00,$00	;"?"
	dc.b	$7C,$C6,$C6,$DE,$C0,$7E,$00,$00	;"@"
	dc.b	$3C,$66,$66,$7E,$66,$66,$00,$00	;"A"
	dc.b	$FC,$66,$7C,$66,$66,$FC,$00,$00	;"B"
	dc.b	$3C,$66,$60,$60,$66,$3C,$00,$00	;"C"
	dc.b	$F8,$6C,$66,$66,$66,$FC,$00,$00	;"D"
	dc.b	$FC,$64,$70,$60,$62,$FE,$00,$00	;"E"
	dc.b	$FE,$62,$78,$60,$60,$F0,$00,$00	;"F"
	dc.b	$7C,$C4,$C0,$CF,$C6,$7E,$00,$00	;"G"
	dc.b	$E7,$66,$7E,$66,$66,$E7,$00,$00	;"H"
	dc.b	$7E,$18,$18,$18,$18,$7E,$00,$00	;"I"
	dc.b	$3E,$26,$06,$06,$46,$7C,$00,$00	;"J"
	dc.b	$E6,$6C,$78,$78,$6C,$E6,$03,$00	;"K"
	dc.b	$F0,$60,$60,$60,$62,$FE,$00,$00	;"L"
	dc.b	$C6,$EE,$FE,$D6,$C6,$C6,$00,$00	;"M"
	dc.b	$E7,$76,$7E,$6E,$66,$E7,$00,$00	;"N"
	dc.b	$3C,$66,$66,$66,$66,$3C,$00,$00	;"O"
	dc.b	$F8,$6C,$66,$7C,$60,$F0,$00,$00	;"P"
	dc.b	$3C,$66,$66,$6E,$6C,$36,$00,$00	;"Q"
	dc.b	$F8,$6C,$66,$7E,$6C,$E6,$03,$00	;"R"
	dc.b	$3E,$60,$3C,$06,$86,$FC,$00,$00	;"S"
	dc.b	$FF,$5A,$18,$18,$18,$3C,$00,$00	;"T"
	dc.b	$66,$66,$66,$66,$66,$3C,$00,$00	;"U"
	dc.b	$66,$66,$66,$3C,$3C,$18,$00,$00	;"V"
	dc.b	$C6,$C6,$D6,$FE,$EE,$C6,$00,$00	;"W"
	dc.b	$E7,$66,$3C,$3C,$66,$E7,$00,$00	;"X"
	dc.b	$E7,$66,$3C,$18,$18,$3C,$00,$00	;"Y"
	dc.b	$FE,$8C,$18,$30,$62,$FE,$00,$00	;"Z"
	dc.b	$3C,$30,$30,$30,$30,$3C,$00,$00	;"["
	dc.b	$C0,$60,$30,$18,$0C,$06,$00,$00	;"\"
	dc.b	$3C,$0C,$0C,$0C,$0C,$3C,$00,$00	;"]"
	dc.b	$10,$38,$6C,$00,$00,$00,$00,$00	;"^"
	dc.b	$00,$00,$00,$00,$00,$00,$FE,$00	;"_"
	dc.b	$30,$30,$18,$00,$00,$00,$00,$00	;"`"
	dc.b	$00,$1C,$06,$3E,$66,$3F,$00,$00	;"a"
	dc.b	$E0,$60,$6C,$76,$66,$FC,$00,$00	;"b"
	dc.b	$00,$3C,$66,$60,$66,$3C,$00,$00	;"c"
	dc.b	$0E,$06,$36,$6E,$66,$3F,$00,$00	;"d"
	dc.b	$00,$3C,$66,$7C,$60,$3E,$00,$00	;"e"
	dc.b	$1C,$34,$30,$78,$30,$78,$00,$00	;"f"
	dc.b	$00,$37,$6E,$66,$3E,$06,$0C,$00	;"g"
	dc.b	$E0,$60,$6C,$76,$66,$E6,$00,$00	;"h"
	dc.b	$18,$00,$38,$18,$18,$18,$0C,$00	;"i"
	dc.b	$18,$00,$38,$18,$18,$30,$60,$00	;"j"
	dc.b	$E0,$64,$6C,$78,$6C,$E6,$00,$00	;"k"
	dc.b	$70,$60,$60,$60,$64,$3C,$00,$00	;"l"
	dc.b	$00,$CC,$FE,$D6,$C6,$C6,$00,$00	;"m"
	dc.b	$00,$6C,$76,$66,$66,$66,$00,$00	;"n"
	dc.b	$00,$3C,$66,$66,$66,$3C,$00,$00	;"o"
	dc.b	$00,$EC,$76,$66,$7C,$60,$C0,$00	;"p"
	dc.b	$00,$3F,$66,$6E,$36,$06,$03,$00	;"q"
	dc.b	$00,$76,$3A,$30,$30,$78,$00,$00	;"r"
	dc.b	$00,$3C,$60,$3C,$06,$FC,$00,$00	;"s"
	dc.b	$10,$30,$78,$30,$34,$1C,$00,$00	;"t"
	dc.b	$00,$66,$66,$66,$66,$3C,$00,$00	;"u"
	dc.b	$00,$66,$66,$3C,$3C,$18,$00,$00	;"v"
	dc.b	$00,$C6,$C6,$D6,$FE,$EC,$00,$00	;"w"
	dc.b	$00,$EE,$6C,$38,$6C,$EE,$00,$00	;"x"
	dc.b	$00,$EE,$6C,$38,$10,$38,$00,$00	;"y"
	dc.b	$00,$7C,$18,$30,$64,$FC,$00,$00	;"z"
	dc.b	$0E,$18,$30,$18,$18,$0E,$00,$00	;"{"
	dc.b	$18,$18,$18,$18,$18,$18,$00,$00	;"|"
	dc.b	$70,$18,$0C,$18,$18,$70,$00,$00	;"}"
	dc.b	$7C,$C6,$6C,$BA,$FE,$92,$38,$00	;"~"
	dc.b	$00,$00,$00,$00,$00,$00,$00,$00	;""

;		***************************
;		*     CHIP Memory Data    *
;		***************************

section		data custom,chip		****  Use this for A68K  ****

;		Section		custom,data_C	**** Use this for Devpac ****

MyCopper	CMOVE		DIWSTRT,$2c81		PAL -- 256 lines
		CMOVE		DIWSTOP,$2cc1
		CMOVE		DDFSTRT,$0038		LoRes
		CMOVE		DDFSTOP,$00d0
		CMOVE		BPL1MOD,$0000		No modulos
		CMOVE		BPL2MOD,$0000
		CMOVE		BPLCON0,$1200		1 bitplane & colour
		CMOVE		BPLCON1,$0000		No scrolling
		CMOVE		BPLCON2,$0000		Ignore priority

CopPlanes	CMOVE		BPL1PTH,0		Bit plane pointer
		CMOVE		BPL1PTL,0

		CMOVE		COLOR00,$0000		black
		CMOVE		COLOR01,$0fff		white

		CEND					end of list

bitplane	ds.b		40*256		40 bytes wide by 256 lines

		end

		
