start:
	lea	source,a1
	lea	destination,a0
	moveq	#0,d0		;offset start, source
	move.w	#2,d1		;bf width for set = magnification
	moveq	#0,d2		;offset destination
	moveq	#0,d6		;height of source
	moveq	#15,d3
magloop1:
	move.w	d3,d7		;number of bits to test=width of source
magloop2:
p0test:
	dc.w	%1110100011010001	;bftst	a1{d0:1}
	dc.w	%0000100000000001
	beq.s	p0clear			;bit was 0 so go clear in dest
	dc.w	%1110111011010000	;bfset	a0{d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	bra.s	p1test
p0clear:
	dc.w	%1110110011010000	;bfclr	a1{d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
p1test:
	dc.w	%1110100011101001	;bftst	2(a1){d0:1}
	dc.w	%0000100000000001
	dc.w	2
	beq.s	p1clear			;bit was 0 so go clear in dest
	dc.w	%1110111011101000	;bfset	2(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	2
	bra.s	p2test
p1clear:
	dc.w	%1110110011101000	;bfclr	2(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	2
p2test:
	dc.w	%1110100011101001	;bftst	4(a1){d0:1}
	dc.w	%0000100000000001
	dc.w	4
	beq.s	p2clear			;bit was 0 so go clear in dest
	dc.w	%1110111011101000	;bfset	4(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	4
	bra.s	p3test
p2clear:
	dc.w	%1110110011101000	;bfclr	4(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	4
p3test:
	dc.w	%1110100011101001	;bftst	6(a1){d0:1}
	dc.w	%0000100000000001
	dc.w	6
	beq.s	p3clear			;bit was 0 so go clear in dest
	dc.w	%1110111011101000	;bfset	6(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	6
	bra.s	p4test
p3clear:
	dc.w	%1110110011101000	;bfclr	6(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	6
p4test:
	dc.w	%1110100011101001	;bftst	8(a1){d0:1}
	dc.w	%0000100000000001
	dc.w	8
	beq.s	p4clear			;bit was 0 so go clear in dest
	dc.w	%1110111011101000	;bfset	8(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	8
	bra.s	p5test
p4clear:
	dc.w	%1110110011101000	;bfclr	8(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	8
p5test:
	dc.w	%1110100011101001	;bftst	10(a1){d0:1}
	dc.w	%0000100000000001
	dc.w	10
	beq.s	p5clear			;bit was 0 so go clear in dest
	dc.w	%1110111011101000	;bfset	10(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	10
	bra.s	p6test
p5clear:
	dc.w	%1110110011101000	;bfclr	10(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	10
p6test:
	dc.w	%1110100011101001	;bftst	12(a1){d0:1}
	dc.w	%0000100000000001
	dc.w	12
	beq.s	p6clear			;bit was 0 so go clear in dest
	dc.w	%1110111011101000	;bfset	12(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	12
	bra.s	p7test
p6clear:
	dc.w	%1110110011101000	;bfclr	12(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	12
p7test:
	dc.w	%1110100011101001	;bftst	14(a1){d0:1}
	dc.w	%0000100000000001
	dc.w	14
	beq.s	p7clear			;bit was 0 so go clear in dest
	dc.w	%1110111011101000	;bfset	14(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	14
	bra.s	p8test
p7clear:
	dc.w	%1110110011101000	;bfclr	14(a0){d2:d1}
	dc.w	%0000100010100001	;set dest with proper width
	dc.w	14
p8test:					;All planes done
	addq.w	#1,d0		;advance source offset by 1
*	cmpi.w	#15,d0
	andi.w	#15,d0
	bne.s	offok
	lea	16(a1),a1	;advance the address
offok:
	add.w	d1,d2		;advance destination by magnification
	andi.w	#15,d2
	bne	offok2
	lea	16(a0),a0
offok2:
	dbf	d7,magloop2
	dbf	d6,magloop1



	nop
	nop

	clr.w	-(sp)
	trap	#1




source:
	dc.w	%1000000000000001
	dc.w	%1100000000000000
	dc.w	%1110000000000001
	dc.w	%1111000000000000
	dc.w	%1111100000000001
	dc.w	%1111110000000000
	dc.w	%1111111000000001
	dc.w	%1111111100000000



destination:
	ds.w	16
	DC.W	-1