
		org	jvec-8800	;size of zip file + a bit)
	
start		orcc	#$50

		ldx	#file
		ldd	#filend
		ldu	#$1000		;DEMO LOCATION SPUDZ !!!
		jmp	jvec

**********************************
* PACKED DEMO FILE
**********************************

file		includebin	demo.dz
filend		equ	*


**********************************
* UNZIP ROUTINE
**********************************

jvec		org	$7e60
**********************************************
* generic unzip X=start/D=end/U=depack address
* big thx to @sixxie for this one + the packer
**********************************************


dunzip		std	f80+1
dunz_loop	ldd	,x++
		bpl	dunz_run	; run of 1-128 bytes
		tstb
		bpl	dunz_7_7
dunz_14_8	lslb			; drop top bit of byte 2
		asra
		rorb			; asrd
		leay	d,u
		ldb	,x+
		bra	f10		; copy 1-256 bytes (0 == 256)
dunz_7_7	leay	a,u		; copy 1-128 bytes
f10		lda	,y+
		sta	,u+
		incb
		bvc	f10		; count UP until B == 128
		bra	f80
f1		ldb	,x+
dunz_run	stb	,u+
		inca
		bvc	f1		; count UP until B == 128
f80		cmpx	#$0000
		blo	dunz_loop
**********************************
* JUMP TO DEMO ORIGIN
**********************************
		jmp	$1000


		end	start

