#define __MARK(s) asm(".ascii \"" #s "\"");
//----------------------------------------------------------------
// this file is used to generate the hexcode array unpack function
//----------------------------------------------------------------
short tt_unpack(unsigned char*,unsigned char*);
__MARK(TOM1);
asm("
.even
tt_unpack:   
	movem.l %d1-%d7/%a0-%a4/%a6,-(%sp)
	lea (-24,%sp),%sp
	move.l 80(%sp),%a0
	
	cmp.b #84,2(%a0)
	jbne __L4
	cmp.b #80,3(%a0)
	jbeq __L3
__L4:
	move.w #252,%d0
	jbra __L38
__L3:
	clr.l %d6
	move.b 6(%a0),%d6
	clr.w %d7
	move.b 9(%a0),%d7
	clr.w %d5
	move.b 10(%a0),%d5
	subq.w #1,%d5
	clr.w %d0
	move.b 12(%a0),%d0
	move.w %d0,%a6
	moveq.l #1,%d1
	lsl.w %d5,%d1
	move.w %d1,14(%sp)
	moveq.l #2,%d0
	lsl.w %d5,%d0
	move.w %d0,12(%sp)
	moveq.l #8,%d1
	sub.w %d5,%d1
	move.w %d1,10(%sp)
	moveq.l #8,%d0
	sub.w %d7,%d0
	move.w %d0,%a4
	move.w #249,%d0
	cmp.w #8,%d7
	jbhi __L38
	clr.w %d0
	move.b 11(%a0),%d0
	cmp.w 14(%sp),%d0
	jbne __L7
	cmp.w #4,%d5
	jbls __L7
	cmp.w #7,%d5
	jbls __L6
__L7:
	move.w #250,%d0
	jbra __L38
__L6:
	moveq.l #4,%d1
	cmp.w %a6,%d1
	jbcc __L8
	move.w #251,%d0
	jbra __L38
__L8:
	lea (15,%a0),%a1
	move.l %a1,16(%sp)
	move.l 84(%sp),%a3
	lea (_tt_InBuffer,%pc),%a1
	move.l %a1,6(%sp)
	move.l 16(%sp),%a1
	clr.l %d0
	move.b (%a1),%d0
	lea 16(%a0,%d0.l),%a0
	move.l 6(%sp),%a1
	move.l %a0,(%a1)
	lea (_tt_InMask,%pc),%a0
	move.l %a0,2(%sp)
	move.w #128,(%a0)
__L11:
	move.w %d6,%d3
	tst.w %d7
	jbeq __L12
	move.w %d7,-(%sp)
	lea (_tt_GetBits,%pc),%a0
	jsr (%a0)
	move.w %d0,%d3
	addq.l #2,%sp
__L12:
	move.w %d3,%a0
	cmp.l %a0,%d6
	jbne __L13
	move.w %d5,-(%sp)
	lea (_tt_GetValue,%pc),%a2
	jsr (%a2)
	move.w %d0,%d4
	clr.w 2(%sp)
	addq.l #2,%sp
	cmp.w #1,%d4
	jbeq __L14
	move.w %d5,-(%sp)
	jsr (%a2)
	move.w %d0,%d3
	subq.w #1,%d3
	move.w 14(%sp),%d0
	subq.w #2,%d0
	addq.l #2,%sp
	cmp.w %d3,%d0
	jbne __L15
	cmp.w #3,%d4
	jbls __L10
	lea (_tt_Get8Bit,%pc),%a2
	jsr (%a2)
	move.w %d0,0(%sp)
	jsr (%a2)
	jbra __L39
__L15:
	move.w %a6,%d0
	jbeq __L19
	move.w %a6,-(%sp)
	lea (_tt_GetBits,%pc),%a0
	jsr (%a0)
	move.w %a6,%d1
	lsl.w %d1,%d3
	or.w %d0,%d3
	addq.l #2,%sp
__L19:
	lea (_tt_Get8Bit,%pc),%a0
	jsr (%a0)
	eor.w #255,%d0
	move.w %d3,%d1
	lsl.w #8,%d1
	or.w %d0,%d1
	jbra __L20
__L14:
	move.l 6(%sp),%a1
	move.l (%a1),%a0
	clr.w %d0
	move.b (%a0),%d0
	move.l 2(%sp),%a0
	move.w (%a0),%d1
	and.w %d1,%d0
	jbeq __L21
	ror.b  #1,%d1
	bcc.s  __inl_tt_cim_skip0
	addq.l #1,(%a1)
__inl_tt_cim_skip0:
	move.w %d1,(%a0)
	move.l (%a1),%a0
	clr.w %d0
	move.b (%a0),%d0
	and.w %d1,%d0
	jbne __L22
	move.w %d1,%d0
	ror.b  #1,%d0
	bcc.s  __inl_tt_cim_skip1
	addq.l #1,(%a1)
__inl_tt_cim_skip1:
	move.l 2(%sp),%a1
	move.w %d0,(%a1)
	move.w %d7,-(%sp)
	lea (_tt_GetBits,%pc),%a2
	jsr (%a2)
	move.w %d0,%d3
	move.w %a4,-(%sp)
	jsr (%a2)
	move.w %a4,%d1
	ext.l %d1
	lsl.l %d1,%d6
	or.b %d0,%d6
	move.b %d6,(%a3)+
	clr.l %d6
	move.w %d3,%d6
	addq.l #4,%sp
	jbra __L11
__L22:
	move.w %d1,%d0
	ror.b  #1,%d0
	bcc.s  __inl_tt_cim_skip2
	addq.l #1,(%a1)
__inl_tt_cim_skip2:
	move.l 2(%sp),%a0
	move.w %d0,(%a0)
	move.w %d5,-(%sp)
	jsr (%a2)
	move.w %d0,%d3
	addq.l #2,%sp
	cmp.w 14(%sp),%d3
	jbcs __L23
	move.w 10(%sp),-(%sp)
	lea (_tt_GetBits,%pc),%a0
	jsr (%a0)
	sub.w 16(%sp),%d3
	move.w 12(%sp),%d1
	lsl.w %d1,%d3
	or.w %d0,%d3
	move.w %d5,-(%sp)
	jsr (%a2)
	subq.w #1,%d0
	lsl.w #8,%d0
	or.w %d0,%d3
	addq.l #4,%sp
__L23:
	move.w %d5,-(%sp)
	jsr (%a2)
	move.w %d0,%d4
	addq.l #2,%sp
	cmp.w #31,%d4
	jbhi __L24
	clr.l %d0
	move.w %d4,%d0
	move.l 16(%sp),%a0
	move.b (%a0,%d0.l),%d1
	ext.w %d1
	jbra __L25
__L24:
	move.w #3,-(%sp)
	lea (_tt_GetBits,%pc),%a0
	jsr (%a0)
	move.w %d4,%d1
	add.w #-32,%d1
	lsl.w #3,%d1
	or.w %d0,%d1
	addq.l #2,%sp
__L25:
	clr.w %d2
	cmp.w %d2,%d3
	jbcs __L11
__L29:
	move.b %d1,(%a3)+
	addq.w #1,%d2
	cmp.w %d2,%d3
	jbcc __L29
	jbra __L11
__L21:
	move.w %d1,%d0
	move.l 6(%sp),%a1
	ror.b  #1,%d0
	bcc.s  __inl_tt_cim_skip3
	addq.l #1,(%a1)
__inl_tt_cim_skip3:
	move.l 2(%sp),%a0
	move.w %d0,(%a0)
	lea (_tt_Get8Bit,%pc),%a0
	jsr (%a0)
__L39:
	move.w %d0,%d1
	eor.w #255,%d1
__L20:
	clr.w %d2
	cmp.w %d2,%d4
	jbcs __L11
__L34:
	clr.l %d0
	move.w %d1,%d0
	move.l %a3,%a0
	sub.l %d0,%a0
	move.b 1(%sp),%d0
	add.b -1(%a0),%d0
	move.b %d0,(%a3)+
	addq.w #1,%d2
	cmp.w %d2,%d4
	jbcc __L34
	jbra __L11
__L13:
	move.w %a4,-(%sp)
	lea (_tt_GetBits,%pc),%a0
	jsr (%a0)
	move.w %a4,%d1
	lsl.w %d1,%d3
	or.b %d0,%d3
	move.b %d3,(%a3)+
	addq.l #2,%sp
	jbra __L11
__L10:
	clr.w %d0
__L38:
	lea (24,%sp),%sp
	movem.l (%sp)+,%d1-%d7/%a0-%a4/%a6
	rts
/*---------------------------------------------------------------------------*/
/*                                                                           */
/*---------------------------------------------------------------------------*/
	.even
_tt_InBuffer:
	.long 0
	.even
_tt_InMask:
	.word 0
	
_tt_Get8Bit:
    lea     _tt_InBuffer(%pc),%a0
    movea.l (%a0),%a1           /* address of current byte */
    clr.w   %d0
    move.b  (%a1)+,%d0          /* anyway, read first byte */
    move.l  %a1,(%a0)           /* and increment pointer   */
    move.w  _tt_InMask(%pc),%d1
    cmpi.b  #0x80,%d1
    bne.s   __inl_tries
    rts
__inl_tries:
    lsl.w   #8,%d0              /* v = *(_tt_InBuffer++) << 8; */
    move.b  (%a1),%d0           /* v |= *_tt_InBuffer;         */
    cmpi.b  #0x08,%d1
    bhi.s   __inl_try20
    bne.s   __inl_try02
    andi.w  #0x0fff,%d0
    lsr.w   #4,%d0
    rts
__inl_try40:
    andi.w  #0x7fff,%d0
    lsr.w   #7,%d0
    rts
__inl_try20:
    cmpi.b  #0x20,%d1
    bhi.s   __inl_try40
    bcs.s   __inl_try10
    andi.w  #0x3fff,%d0
    lsr.w   #6,%d0
    rts
__inl_try10:
    andi.w  #0x1fff,%d0
    lsr.w   #5,%d0
    rts
__inl_try04:
    andi.w  #0x07ff,%d0
    lsr.w   #3,%d0
    rts
__inl_try02:
    cmpi.b  #0x02,%d1
    bhi.s   __inl_try04
    bne.s   __inl_try01
    andi.w  #0x03ff,%d0
    lsr.w   #2,%d0
    rts
__inl_try01:
    andi.w  #0x01ff,%d0
    lsr.w   #1,%d0
    rts
_tt_GetValue:
    move.l  %d3,-(%sp)
    clr.l   %d1                   /* i        */
    move.w  8(%sp),%d0            /* maxgamma */
    move.l  _tt_InBuffer(%pc),%a0
    move.w  _tt_InMask(%pc),%d2

__inl_loop1:
    cmp.w   %d1,%d0
    bls.s   __inl_exitloop
    move.w  %d2,%d3
    and.b   (%a0),%d3
    ror.b   #1,%d2                /* thx tom for the ror with carry trick ;) */
    bcc.s   __inl_samebyte1
    addq.l  #1,%a0
__inl_samebyte1:
    /* test if next bit set only now */
    tst.b   %d3
    beq.s   __inl_exitloop
    addq.w  #1,%d1
    bra.s   __inl_loop1
__inl_exitloop:
    move.l  %a0,%d3
    lea     _tt_InBuffer(%pc),%a0
    move.l  %d3,(%a0)
    lea     _tt_InMask(%pc),%a0
    move.w  %d2,(%a0)
    move.l  %d3,%a0
    moveq   #1,%d3
    lsl.w   %d1,%d3
    move.w  %d1,-(%sp)
    bsr.s   _tt_GetBits
    addq    #2,%sp
    or.w    %d3,%d0
    move.l  (%sp)+,%d3
    rts
_tt_GetBits:
    clr.w   %d0
    move.w  4(%sp),%d1
    beq.s   __inl_exit               /* just in case ;)                                           */
    movea.l _tt_InBuffer(%pc),%a0    /* _tt_InBuffer, gcc makes it pc relative :)                 */
    movea.l %d3,%a1                  /* use a1 to save d3: 4 cycles better than move.w %d3,-(%sp) */
    move.w  _tt_InMask(%pc),%d2      /* pc relative too :))                                       */
    subq.w  #1,%d1
__inl_loop0:
    lsl.w   #1, %d0
    move.w  %d2,%d3
    and.b   (%a0),%d3
    beq.s   __inl_correct0
    addq.b  #1,%d0                   
__inl_correct0:
    ror.b   #1,%d2
    bcc.s   __inl_samebyte0
    addq.l  #1,%a0
__inl_samebyte0:
    dbra    %d1,__inl_loop0
    move.l  %a1,%d3                 /* restores d3 (4 cycles again :) */
    lea     _tt_InMask(%pc),%a1
    move.w  %d2,(%a1)               /* saves _tt_InMask               */
    lea     _tt_InBuffer(%pc),%a1   /* saves _tt_InBuffer             */
    move.l  %a0,(%a1)
    move.l  %d3,%a1
__inl_exit:
    rts
");
__MARK(TOM2);

void _main() {
tt_unpack(0,0);
}    

int _ti89;