BitPlane1=$50000	;Adresse Bitplane 1
BitPlane2=$52000	;Adresse Bitplane 2
BitPlane3=$54000	;Adresse Bitplane 3
BitPlane4=$56000	;Adresse Bitplane 4
BitPlane5=$58000	;Adresse BItplane 5
Exec=4			;Basisadresse Execbase
Permit=-138		;Stop Multitasking
Open= -30
Close= -30 -6
Read= -30 -12
text= -30 -30
Forbid=-132		;Start Multitasking
OpenLibrary=-408	
CloseLibrary=-414
InitRastPort=-198
InitBitMap=-390
SetRast= -30 -204
Move= -30 -210
Draw= -30 -216
RectFill= -30 -276
ScrollRaster= -30 -366
WritePixel= -30 -294
SetAPen= -30 -312
WaitTOF= -30 -240

start:
	jsr setup	;Initialisiert die Bitmaps und
			;oeffnet benoetigte Libraries
grafik:
	jsr setcopper
	move.w #%1000000000100000,$dff096
	jmp start1

keyboard:
	move.l gfxbase,a6
	lea rastport,a1
	move.l col,d0
	jsr setapen(a6)
	move.l gfxbase,a6
	lea rastport,a1
	move.l xin,d0
	move.l yin,d1
	jsr move(a6)
	move.l gfxbase,a6
	lea rastport,a1
	move.l textbuf,a0
	move.l lenbuf,d0
	jsr text(a6)
	move.l gfxbase,a6
	lea rastport,a1
	move.l col2,d0
	jsr setapen(a6)
	move.l lenbuf,d0
	rol.l #3,d0
	add.l d0,xin
warten:	jsr holdkey
	cmp.b #$68,d1
	bcs warten
make:	jsr holdkey
	cmp.b #$44,d1
	beq mo
	cmp.b #$41,d1
	beq del
	cmp.b #$68,d1
	bcc make
	jsr print
	jmp warten
holdkey:move.b $bfec01,d0
	move.b #$ff,d1	
	sub.b d0,d1
	ror.b #1,d1
mo:	rts
del:	sub.l #8,xpos
	sub.l #1,xpos1
	move.b #32,text1
	jsr ok1
	sub.l #8,xpos
	sub.l #1,xpos1
	jmp warten
print:	move.l #69,d3
no1:	move.l #key1,a0
	move.l #key2,a1
	move.l buffer,a2
	add.l d3,a0
	add.l d3,a1
	cmp.b (a0),d1
	beq print1	
	sub.l #1,d3
	bne no1
print1:	move.b (a1),text1
ok1:	move.l gfxbase,a6
	lea rastport,a1
	move.l xin,d0
	add.l xpos1,a2
	add.l xpos,d0
	move.l yin,d1
	jsr move(a6)
	move.l gfxbase,a6
	lea rastport,a1
	move.l #text1,a0
	move.l #1,d0
	jsr text(a6)
	move.b text1,(a2)
	add.l #8,xpos
	add.l #1,xpos1
	rts

start1:
	move.l #buffer1,buffer
	move.l #text2,textbuf
	move.l lent2,lenbuf
	move.l #3,col
	move.l #1,col2
	jsr keyboard
	move.l xpos1,len2
	move.l #buffer2,buffer
	move.l #0,xin
	move.l #0,xpos
	move.l #0,xpos1
	move.l #30,yin
	move.l #text3,textbuf
	move.l lent3,lenbuf
	move.l #5,col
	move.l #1,col2
	jsr keyboard
	move.l xpos1,len3

wait:



make5:	andi.b	#64,$bfe001	;Bit 7 (linke Maustaste)
	bne make5

	move.l copptr,a0
	move.l	oldcop,(a0)	;Alte Copperliste wieder bereit-
	move.l exec,a6
	move.l	GfxBase,a1	;stellen und Gfxlibrary
	jsr	CloseLibrary(a6);schliessen
	move.l dos_base,a1
	jsr closelibrary(a6)
	jsr	Permit(a6)	;Multitasking wieder zulassen
	ILLEGAL			;Rueckkehr zum SEKA
	rts			;ende

setup:
	move.l	Exec,a6		;Exebase-Adresse nach a6
	jsr	Forbid(a6)	;Stop Multitasking

	move.l exec,a6
	lea.l dosname,a1
	jsr Openlibrary(a6)
	move.l d0,dos_base

	lea	GrName,a1	;Gfxname nach a1
	jsr	OpenLibrary(a6)	;Gfxlibrary oeffnen
	move.l	d0,GfxBase	;Basisadresse buffern
	move.l	d0,a6
	add.l	#$32,d0
	move.l	d0,copptr

	lea	BitMap,a0	;Bitmapstruktur nach a0
	moveq	#5,d0		;Tiefe (5 Bitplanes)
	move.l	#320,d1		;320 Pixel nach x
	move.l	#200,d2		;200 Pixel nach y
	jsr	InitBitMap(a6)	;Bitmap Initialisieren
	lea	RastPort,a1	;erhaltenen Rastport nach a1
	jsr	InitRastPort(a6);Rastport initialisieren	
	move.l	#BitMap,R_BitMap


	move.l	#BitPlane1,d0	;Adresse Bitplane nach d0
	move.l	d0,Plane1	;Adresse auch nach Plane1
	move.l	d0,a0		;und nach Adressregister a0
	move.w	d0,lo1		;sowie in Copperliste speichern
	swap	d0		;Hi-Nibble isolieren und eben-
	move.w	d0,hi1		;falls nach Copperliste
	move.l	#8000,d0	;8000 Bytes fuer Bitplane bele-
	move.b	#$00,d1		;gen
cl1:	move.b	d1,(a0)+
	dbf	d0,cl1

	move.l	#BitPlane2,d0
	move.l d0,Plane2
	move.l d0,a0
	move.w d0,lo2
	swap d0
	move.w d0,hi2
	move.l #8000,d0
	move.b #$00,d1
cl2:	move.b d1,(a0)+
	dbf d0,cl2

	move.l	#BitPlane3,d0
	move.l	d0,Plane3
	move.l	d0,a0
	move.w	d0,lo3
	swap	d0
	move.w	d0,hi3
	move.l	#8000,d0
	move.b	#$00,d1
cl3:	move.b	d1,(a0)+
	dbf	d0,cl3

	move.l	#BitPlane4,d0
	move.l	d0,Plane4
	move.l	d0,a0
	move.w	d0,lo4
	swap	d0
	move.w	d0,hi4
	move.l	#8000,d0
	move.b	#$00,d1
cl4:	move.b	d1,(a0)+
	dbf	d0,cl4

	move.l	#BitPlane5,d0
	move.l	d0,Plane5
	move.l	d0,a0
	move.w	d0,lo5
	swap	d0
	move.w	d0,hi5
	move.l	#8000,d0
	move.b	#$00,d1
cl5:	move.b	d1,(a0)+
	dbf	d0,cl5
	rts

setcopper:
	move.l	copptr,a0	;Adresse der Copperliste nach a0
	move.l	(a0),oldcop	;Alte Liste zwischenspeichern
	move.l	#Copper,(a0)	;Neue Liste fue Copper
	rts


Copper:
	DC.W	$0180
co0:	dc.w	$0000
	DC.W	$0182
co1:	dc.w	$0fff
	DC.W	$0184
co2:	dc.w	$000f
	DC.W	$0186	
co3:	dc.w	$0f00
	DC.W    $0188
co4:	dc.w	$000f
	DC.W	$018a
co5:	dc.w	$0f0f
	DC.W	$018c
co6:	dc.w	$00ff
	DC.W	$018e
co7:	dc.w	$f0ff
	DC.W	$0190
co8:	dc.w	$0620
	DC.W	$0192
co9:	dc.w	$0e50
	DC.W	$0194
co10:	dc.w	$09f1
	DC.W	$0196	
co11:	dc.w	$0eb0
	dc.w	$0198
co12:	dc.w	$055f
	dc.w	$019a
co13:	dc.w	$092f
	dc.w	$019c
co14:	dc.w	$00f8
	dc.w	$019e
co15:	dc.w	$0ccc
	dc.w	$01a0
co16:	dc.w	$0000		
	dc.w	$01a2
co17:	dc.w	$0d22
	dc.w	$01a4
co18:	dc.w	$0000
	dc.w	$01a6
co19:	dc.w	$0fca
	dc.w	$01a8
co20:	dc.w	$0444	
	dc.w	$01aa
co21:	dc.w	$0555
	dc.w	$01ac
co22:	dc.w	$0666
	dc.w	$01ae
co23:	dc.w	$0777
	dc.w	$01b0
co24:	dc.w	$0888
	dc.w	$01b2
co25:	dc.w	$0999
	dc.w	$01b4
co26:	dc.w	$0aaa
	dc.w	$01b6
co27:	dc.w	$0bbb
	dc.w	$01b8
co28:	dc.w	$0ccc
	dc.w	$01ba
co29:	dc.w	$0ddd
	dc.w	$01bc
co30:	dc.w	$0eee
	dc.w	$01be
co31:	dc.w	$0fff
	DC.W	$00e0
hi1:	DC.W	$0002
	DC.W	$00e2
lo1:	DC.W	$1000
	DC.W	$00e4
hi2:	DC.W	$0002
	DC.W	$00e6
lo2:	DC.W    $1000
	DC.W	$00e8
hi3:	DC.W	$0002
	DC.W	$00ea
lo3:	DC.W	$1000
	DC.W	$00ec
hi4:	DC.W	$0002
	DC.W	$00ee
lo4:	DC.W	$1000
	DC.W	$00f0
hi5:	DC.W	$0002
	DC.W	$00f2
lo5:	DC.W	$1000
	DC.W	$0100,%0101000000000000
	DC.W	$0102
delay:	DC.W	$00
	DC.W	$0108,0
	DC.W	$010a,0
	DC.W	$0092,$0038
	DC.W	$0094,$00d0
	DC.W	$008e,$3681
	DC.W	$0090,$fdc1
	DC.W	$ffff,$fffe



BitMap:
BytesPerRow: 	blk.w 1,0
Bytes:		blk.w 1,0
Flags: 		blk.b 1,0
Depth: 		blk.b 1,0
Pad:  		blk.w 1,0
Plane1:		blk.l 1,0
Plane2:		blk.l 1,0
Plane3:		blk.l 1,0
Plane4:		blk.l 1,0
Plane5:		blk.l 1,0
Planes:		blk.l 1,0

RastPort:
		blk.l 1,0
R_BitMap:	blk.l 1,0
		blk.b 2+4+4+4+8,0
		blk.b 4,0
cp_x:		blk.w 1,0
cp_y:		blk.w 1,0
   		blk.b 8+22+[7*2]+[2*4]+8,0
		blk.w 6,0
even
GrName:		DC.B 'graphics.library',0
Dosname:	DC.B 'dos.library',0
even

copptr:		blk.l 1,0
oldcop:		blk.l 1,0
GfxBase:	blk.l 1,0
Dos_base:	blk.l 1,0
x:		blk.l 1,0

key1:	dc.b $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0a,$0b,$0c
	dc.b $0d,$41,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19
	dc.b $1a,$1b,$44,$5f,$20,$21,$22,$23,$24,$25,$26,$27,$28
	dc.b $29,$2a,$4c,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39
	dc.b $3a,$4f,$4e,$40,$4d
	dc.b $3d,$3e,$3f,$2d,$2e,$2f,$1d,$1e,$1f,$0f,$3c,$4a,$43
	dc.b $46

key2:	dc.b '`1234567890-=\'
	dc.b 32
	dc.b 'QWERTYUIOP[]'
	dc.b 13
	dc.b '~ASDFGHJKL;'
	dc.b 39,28
	dc.b '<ZXCVBNM,./'
	dc.b 31,30
	dc.b ' '
	dc.b 29
	dc.b '7894561230.-'
	dc.b 12		
	dc.b 32

textbuf:	blk.l 64,0	
text1:	dc.b 1,0
text2:	dc.b 'Source-Filename: ',0
lent2:	dc.l 17,0
text3:	dc.b 'Destination-Filename: ',0
align 4
lent3:	dc.l 22,0
align 4
xin:	dc.l 0,0
yin:	dc.l 10,0
xpos:	dc.l 0,0
xpos1:	dc.l 0,0
buffer:		blk.l 64,0
buffer1:	blk.l 64,0
buffer2:	blk.l 64,0
len3:	dc.l 0,0
len2:	dc.l 0,0
lenbuf:	blk.l 1,0
col:	blk.l 1,0
col2:	blk.l 1,0
