;----------------------------------------------------------
bpl1=$70000
bpl2=$70000+8000
bpl3=$70000+16000
bpl4=$70000+24000
bpl5=$70000+32000

openlibrary=-408
closelibrary=-414
initrastport=-198
initbitmap=-390
setapen=-342
move=-240
text=-60
draw=-246
opendiskfont=-30
setfont=-66
closefont=-78

;----------------------------------------------------------

begin:	move.l 4,a6
;	lea dfname,a1
;	moveq #0,d0
;	jsr openlibrary(a6)
;	move.l d0,dfbase
;	move.l d0,a5

;font:	lea textattr,a0
;	jsr opendiskfont(a5)
;	move.l d0,font

	lea gfxname,a1
	moveq #0,d0
	jsr openlibrary(a6)
	move.l d0,gfxbase
	move.l d0,a6

	jsr inbm
;	jsr setint
	jsr figs

click:	btst #6,$bfe001
	bne click	

initout:
	move.w #$000f,$dff096
;	jsr endint
;	move.l font,a1
;	jsr closefont(a6)
	move.l copinit,8(a6)
	move.l bplcon0,50(a6)
	move.l a6,a1
	move.l 4,a6
	jsr closelibrary(a6)
;	move.l dfbase,a1
;	jsr closelibrary(a6)
	rts

;----------------------------------------------------------

figs:	move.l fdel,d0
	subi.l #1,d0
	move.l d0,fdel
	beq frame
	rts

fdel:	dc.l 50
fads:   dc.l $40000,$40000+3700,$40000+7400,$40000+11100
	dc.l $40000+14800,0

dess:	dc.l bpl1,bpl2,bpl3,bpl4,bpl5
frame:	lea fads,a0
	lea dess,a1

frm:	move.l (a0)+,source
	beq fdone
	move.l (a1)+,dest
	jsr okr
	bra.s frm

fdone:	rts
	
okr:	move.l #$09f0,bltcon0
	move.l #$0,bltcon1
	move.w #0,smodulo
	move.w #20,dmodulo
	move.w #%0010111001001010,stize
	jsr blitit
	move.l #50,fdel
	rts

blitit:
	lea $dff000,a4
	btst #14,$dff002
	bne.s blitit
	move.l bltcon0,$40(a4)
	move.l bltcon1,$44(a4)
	move.l source,$50(a4)
	move.w smodulo,$64(a4)
	move.l dest,$54(a4)
	move.w dmodulo,$66(a4)
	move.w stize,$58(a4)
	rts

	even
	
bltcon0: dc.l 0
bltcon1: dc.l 0
source:	 dc.l 0
dest:	 dc.l 0
smodulo: dc.w 0
dmodulo: dc.w 0
stize:	 dc.w 0

;----------------------------------------------------------

	org $60000
	load $60000

mycop:
	dc.w	$00e0,$0007,$00e2,$0000
	dc.w	$00e4,$0007,$00e6,$1f40
	dc.w 	$00e8,$0007,$00ea,$3e80
	dc.w	$00ec,$0007,$00ee,$5dc0
	dc.w 	$00f0,$0007,$00f2,$7d00
	
	dc.w	$008e,$2c7a
	dc.w	$0090,$f4c1
	dc.w	$0100,%0101000000000000
cols:	dc.w	$0180,$0,$0182,$0111,$0184,$0222
	dc.w	$0186,$0333,$0188,$0444
	dc.w 	$018a,$0555,$018c,$0666,$018e,$0777
	dc.w 	$0190,$0888,$0192,$0999
	dc.w	$0194,$0aaa,$0196,$0bbb,$0198,$0ccc
	dc.w	$019a,$0ddd,$019c,$0eee
	dc.w	$019e,$0fff,$01a0,$0,$01a2,$0,$01a4,$0,$01a6,$0
	dc.w	$01a8,$0,$01aa,$0,$01ac,$0,$01ae,$0,$01b0,$0
	dc.w	$01b2,$0,$01b4,$0,$01b6,$0,$01b8,$0,$01ba,$0
	dc.w	$01bc,$0,$01be
ecol:	dc.w 	0

	dc.w	$ffff,$fffe

;----------------------------------------------------------

rp:	blk.b	110,0
bm:	blk.w	30,0
copinit: blk.l	1,0

;----------------------------------------------------------

gfxname: dc.b	'graphics.library',0,0
gfxbase: blk.l	1,0
dfname:	 dc.b 'diskfont.library',0,0
dfbase:	 dc.l 0
bplcon0: dc.l 0
;----------------------------------------------------------

textattr:	dc.l fname
		dc.w 20
		dc.l 0,0,0

fname:		dc.b 'diamond.font',0,0
;----------------------------------------------------------

inbm:	lea bm,a0
	move.l #5,d0
	move.l #320,d1
	move.l #200,d2
	jsr initbitmap(a6)
	move.l #bpl1,8(a0)
	move.l #bpl2,12(a0)
	move.l #bpl3,16(a0)
	move.l #bpl4,20(a0)
	move.l #bpl5,24(a0)

	lea rp,a1
	jsr initrastport(a6)

	move.l #bm,rp+4

	lea $dff000,a5
	move.l 8(a6),copinit
	move.l 50(a6),bplcon0
	move.l #mycop,50(a6)
	move.w #$2000,$100(a5)
	move.w #0,$102(a5)
	move.w #0,$108(a5)
	move.w #0,$10a(a5)

	rts

;setf:	lea rp,a1
;	move.l font,a0
;	jsr setfont(a6)
	rts



;----------------------------------------------------------

print:	move.l #1,swit
	move.w #0,cols+6
	lea rp,a1
	move.l #1,d0
	jsr setapen(a6)

	move.l #0,d0
	move.l #20,d1

	lea rp,a1
	jsr move(a6)
	lea rp,a1
	move.l txptr,a0
	move.l #30,d0
	jsr text(a6)
	move.l txptr,d0
	adda.l #30,d0
	move.l d0,txptr
	move.l d0,a0
	move.l (a0),d0
	beq rest

	rts

rest:	lea mess,a0
	move.l a0,txptr
	rts

;----------------------------------------------------------
setint:	lea int,a0
	move.l $6c,xout+2
	move.l a0,$6c

	move.w #$0010,$dff09c
	move.w #$8010,$dff09a
	rts

;----------------------------------------------------------

endint:	move.w #$0010,$dff09a
	move.l xout+2,$6c
	rts

;----------------------------------------------------------

int:	movem.l d0-d7/a0-a6,-(a7)

	move.w $dff01e,d0	;int request Read
	and.w $dff01c,d0	;int enable Read
	btst #5,d0		;test if both bits are set
	beq.s xint		;no, then exit
	move.w #$0010,$dff09c	;switch out request Write
;	jsr figs

xint:	movem.l (a7)+,d0-d7/a0-a6
xout:	jmp $00000000

;----------------------------------------------------------

player:

	move.l coldel,d0
	subi.l #1,d0
	move.l d0,coldel
	beq cycle
	rts

cycle:	move.w ecol,d1
	move.l #29,d0
	move.l #ecol-4,a0
	move.l #ecol,a1

clo:	move.w (a0),(a1)
	suba.l #4,a0
	suba.l #4,a1
	cmpa.l #cols+10,a0
	bge clo
	move.w d1,cols+10
	
	move.l #2,coldel

	move.l tcdel,d0
	subi.l #1,d0
	move.l d0,tcdel
	beq tmin

	rts

tmin:	move.l #2,tcdel
	moveq #0,d0
	move.w cols+6,d0
	move.l swit,d1
	beq minus
	addi.w #$0001,d0
	cmp.w #$000f,d0
	bne oka
	move.l #0,swit
	bra.s oka

minus:	subi.w #$0001,d0
	
oka:	move.w d0,cols+6
	beq lf

	rts

swit:	dc.l 1

lf:	move.l #1,swit
	jsr print
	rts

tcdel:	dc.l 2
coldel:	dc.l 5
	
;----------------------------------------------------------

txptr:	dc.l mess
;	      123456789012345678901234567890
mess:	dc.b '       -  The Ice Age  -      '
	dc.b '   Present their first demo   '
	dc.b ' Polarbear Greetings are for: '
	dc.b '    BAMIGA SECTOR ONE         '
	dc.b '   * * The  Kent Team  * *    '
	dc.b '   * *  LORD BLITTER * *      '
	dc.b '   * * S C A  *  B S T * *    '
	dc.b '   *  * The  Movers *  *	    '
	dc.b '     *  The Man In Black  *   '
	dc.b '     *  The Magic Glass!  *   '
	dc.b '      *    Karl & Rein    *   '
	dc.b '     *   *   F L I P  *   *   '
	dc.b '    *   * The New Coke *  *   '

 	even
	dc.l 0,0,0,0

;----------------------------------------------------------
