
 Include "expequ.h"
 Include "equ.h"

	.text

***************************************************
***						***
***************************************************
dumbentry:
	clr.l	d0
	rts

	dc.l	"EXPP"
	dc.w	200
	dc.l	0

table:	dc.l	0
	dc.l	name,special,check,degas

check:	rts

*
* Uncompressed Degas
*
degas:	move.l	table,a0
	move.l	f_openw(a0),a0
	jsr	(a0)
	beq	rrts

	moveq	#2,d0			;hires
	bsr	putword

	move.l	table,a4
	move.l	cwptr(a4),a4
	move.l	(a4),a4
	move.l	(a4),a4
	move.l	a4,wptr
	move.l	pi_Ptr(a4),a0
	move.l	(a0),a0

	move.w	#2,temp1
dgsp2:	bsr	getcolor
	move.l	a0,-(sp)
	bsr	putword
	move.l	(sp)+,a0
	subq.w	#1,temp1
	bne	dgsp2

	move.w	#16-2,temp1
dgsp40:	moveq	#0,d0
	bsr	putword
	subq.w	#1,temp1
	bne	dgsp40


	move.w	#80,d0
	moveq	#0,d1
	cmp.w	pi_Width(a4),d0
	bls	dgsp50
	move.w	d0,d1
	move.w	pi_Width(a4),d0
	sub.w	d0,d1
dgsp50:	lsr.w	#1,d0
	lsr.w	#1,d1
	move.w	d0,tocopy
	move.w	d1,tozero

	move.w	#400,d0
	moveq	#0,d1
	cmp.w	pi_H(a4),d0
	bls	dgsp51
	move.w	d0,d1
	move.w	pi_H(a4),d0
	sub.w	d0,d1
dgsp51:	move.w	d0,rtocopy
	move.w	d1,rtozero

	move.l	wptr,a4
	move.l	pi_Ptr(a4),a0
	move.l	(a0),a0
	move.w	pi_Palet(a4),d0
	mulu	#pl_Sizeof,d0
	add.l	d0,a0
	move.l	a0,pptr

dgsp6:	move.w	tocopy,temp1
dgsp7:	move.w	(a0)+,d0
	move.l	a0,tpptr
	bsr	putword
	move.l	tpptr,a0
	subq.w	#1,temp1
	bne	dgsp7
	move.w	tozero,temp1
	bra	dgsp9
dgsp8:	moveq	#0,d0
	bsr	putword
dgsp9:	subq.w	#1,temp1
	bcc	dgsp8

	move.l	pptr,a0
	move.l	wptr,a4
	add.w	pi_Width(a4),a0
	move.l	a0,pptr

	subq.w	#1,rtocopy
	bne	dgsp6

	bra	dgsp12
dgsp10:	move.w	#40,temp1
dgsp11:	moveq	#0,d0
	bsr	putword
	subq.w	#1,temp1
	bne	dgsp11
dgsp12:	subq.w	#1,rtozero
	bcc	dgsp10

	move.l	table,a0
	move.l	f_closew(a0),a0
	jmp	(a0)

*
*
*
getcolor:
	move.w	(a0)+,d0
	move.w	(a0)+,d1
	move.w	(a0)+,d2
	addq.l	#2,a0

	mulu	#7,d0
	mulu	#7,d1
	mulu	#7,d2
	divu	#65535,d0
	divu	#65535,d1
	divu	#65535,d2
	and.w	#%0000000000000111,d0
	and.w	#%0000000000000111,d1
	and.w	#%0000000000000111,d2
	lsl.w	#8,d0
	lsl.w	#4,d1
	or.w	d1,d0
	or.w	d2,d0
rrts:	rts

*
*
*****************************************
*					*
*****************************************
putbyte:
	move.l	table,a1
	move.l	f_put(a1),a1
	jmp	(a1)

*****************************************
*					*
*****************************************
putword:
	move.l	table,a1
	move.l	f_putw(a1),a1
	jmp	(a1)

*************************************************************
*************************************************************

	.data

special:
	dc.w	1
	dc.l	spc1

name:	dc.b	"Degas Picture v2.0.0",0
spc1:	dc.b	"640x400 Monochrome",0


	.bss

temp1:		ds.w	1
temp2:		ds.w	1
temp3:		ds.w	1

bitpln:		ds.w	1
pwidth:		ds.w	1

tocopy:		ds.w	1
tozero:		ds.w	1
rtocopy:	ds.w	1
rtozero:	ds.w	1

wptr:		ds.l	1
plane:		ds.l	1
pptr:		ds.l	1
tpptr:		ds.l	1
