
; Check keyboard interrupt routine ..... Press TAB key to exit!

; NOTE: Must call InitKeyboard to initialise the L2 interrupt handler and
;       enable level 2 interrupts: move.l #SETIT!INTEN!PORTS,INTENA(a5)
;	for this code to work! MM.

		incdir		source:include/
		include		hardware.i
		include		HW_Macros.i
		include		HW_Start.i
		include		HW_Input.i
		include		HW_Text.i

; The display used has same dimensions as the default plane. Only define
;the start address of the bit planes.

; 'poke' address of bit plane into Copper list

Main		FONTSCREEN	#screen

		moveq.l		#4-1,d1			num planes - 1		
		move.l		#screen,d0		d0=addr of bitplane
		lea		CopPlanes,a0		a0->into Copper list

bpl_loop	move.w		d0,6(a0)		low word of address
		swap		d0
		move.w		d0,2(a0)		high word of address
		swap		d0
		add.l		#40*256,d0		addr of next plane
		addq.l		#8,a0			next pointer in list
		dbra		d1,bpl_loop

; d0 now holds address of colour data that follows bit plane data. Copy
; this into the Copper list

		move.l		d0,a0			a0->colour data
		moveq.l		#16-1,d0		num colours - 1
		lea		CopColours,a1		a1->into Copper list
colr_loop	move.w		(a0)+,2(a1)		copy colour
		addq.l		#4,a1			next register
		dbra		d0,colr_loop

; 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

; Initialise keyboard interrupt routine

		bsr		InitKeyboard

; Enable Level 2 interrupts, generated by keyboard.

		move.w		#SETIT!INTEN!PORTS,INTENA(a5)

; Get current key pressed

Loopy1		bsr		WaitForChar

; Exit if Q key pressed

		cmp.b		#$09,d0
		beq.s		EgDone
		
; print the char

		lea		TestText,a0
		move.b		d0,(a0)
		bsr		WriteText

		bra.s		Loopy1

; And exit.

EgDone		rts

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

; Note that more than one font is referenced. All font pointers are
;initialised to point to the default font provided in 'HW_Text.i'.

TestText	dc.b		' ',FEND
		even

;		***************************
;		*     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,$4200		3 bitplane & colour
		CMOVE		BPLCON1,$0000		No scrolling
		CMOVE		BPLCON2,$0000		Ignore priority

CopPlanes	CMOVE		BPL1PTH,0		Bit plane pointer
		CMOVE		BPL1PTL,0
		CMOVE		BPL2PTH,0
		CMOVE		BPL2PTL,0
		CMOVE		BPL3PTH,0
		CMOVE		BPL3PTL,0
		CMOVE		BPL4PTH,0
		CMOVE		BPL4PTL,0

CopColours	CMOVE		COLOR00,$0000		The colours will be
		CMOVE		COLOR01,$0000		filled in by the
		CMOVE		COLOR02,$0000		program!
		CMOVE		COLOR03,$0000
		CMOVE		COLOR04,$0000
		CMOVE		COLOR05,$0000
		CMOVE		COLOR06,$0000
		CMOVE		COLOR07,$0000
		CMOVE		COLOR08,$0000
		CMOVE		COLOR09,$0000
		CMOVE		COLOR10,$0000
		CMOVE		COLOR11,$0000
		CMOVE		COLOR12,$0000
		CMOVE		COLOR13,$0000
		CMOVE		COLOR14,$0000
		CMOVE		COLOR15,$0000

		CEND					end of list

screen		ds.b		40*256*4	40 bytes wide by 256 lines

; Below is a simple colour table, hand written.

		dc.w		$000,$d00,$f90,$ff0,$8e0,$0b1,$0bb,$b00
		dc.w		$f00,$2e5,$926,$aeb,$bc0,$ded,$055,$999

		end

		
