ROM	B30970
005	samples to utilize
38	segment size
38	number of segments
8	decompression routine

7F0C91D0	called by FCEBC
10:	initial
	00FF	0023	000E	0006	0002	0001	0001	0001
	0001	0001	0001	0001	0002	0006	000E	001E

7F0C9618 tables
@ 0x78:
2710	0009	2711	271F	000E	0007	2713	000C
2714	0008	2715	2716	000B	0004	0003	000D
2718	2717	0001	0002	271A	2719	271B	0005
271C	000A	271D	0006	271E	2712

@ 0x2078
0173	270F	270F	270F	270F	270F	270F	270F
270F	270F	270F	270F	270F	270F	270F	270F


+-+
order:
1) get first 3 bits: subroutine used for sample extracto
2) A0=target
   T5=t1val	->	A1=t1val * seg * segnum
   A2=t3val	size of buf2078
	send all three to 7F0C91D0

7F0C91D0:
1) buffer2078[0x800]	buffer78[0x1000]
2) fill buffer2078 with bytes from data
3) init buffer78 to -1
4) c@prevL & c@prevH maybe start at 0? unsure...
5) prevL & prevH =270F

determine smallest pair
6) save count and value of 1st smallest of each
for(x=0;x<max;x+=2)
	{if(table[x] >= *preH)	/*7F0C958C*/
		{if(table[x] < *preL)
			{*preL=table[x];
			*CpreL=x;
			}
		}
	else if(*preL >= preH)	/*7F0C9580*/
		{*preL=table[x];
		*CpreL=x;
		}
	else 
		{*preH=table[x];
		*CpreH=x;
		}
	if(table[x+1] >= *preH)	/*7F0C95D8*/
		{if(table[x+1] < *preL)
			{*preL=table[x+1];
			*CpreL=x+1;
			}
		}
	else if(*preL >= *preH)	/*7F0C95D0*/
		{*preL=table[x+1];
		*CpreL=x+1;
		}
	else
		{*preH=table[x+1];
		*CpreH=x+1;
		}
	}

use	
7) T2=preH+preL (if 0, set to 1)
8) small[Cpre1]=9999, small[Cpre2]=9999
9) large[Cpre1]
   if(large[CpreH]!=-1 || large[CpreH+1]!=-1)	/*7F0C942C*/
	{if(Lbuf[CpreL]!=-1 || Lbuf[CpreL+1]!=-1)	/*7F0C9480*/
		{for(S2=0; ;S2++)	/*7F0C94A8*/
			{if(Lbuf[S2*2]!=-1)  continue
			if(Lbuf[S2*2+1]!=-1) continue
			if(Sbuf[S2]<0x270F) continue
			}
		/*7F0C94E8*/
		Sbuf[S2]    =T2
		Lbuf[S2*2]  =CpreH
		Lbuf[S2*2+1]=CpreL
		}
	else	/*7F0C9444*/
		{Lbuf[CpreL]=CpreL+2710
		Sbuf[CpreL] =T2

		if(Lbuf[CpreH]!=-1 || Lbuf[CpreH+1]!=-1)	/*7F0C9478*/
			{Lbuf[CpreL+1]=CpreH}
		else
			{Lbuf[CpreL+1]=CpreH+0x2710}
		}
	}
   else	/*7F0C93F4*/
	{Lbuf[CpreH]= 2710+CpreH
	 Sbuf[CpreH]= T2
		if(Lbuf[CpreL]!=-1 || Lbuf[CpreL+1]!=-1)	/*7F0C9420*/
			{Lbuf[CpreH+1]= CpreL}
		else	/*7F0C9408*/
			{Lbuf[CpreH+1]= 0x2710+CpreL}
	}
   /*7F0C94F8*/
   loopus! get smallest again

10) if tsize==0, bail
11) x=0	/*position in target*/
12) for(tpos=0;tpos<tsize;tpos++)
	{x=0;
	do	{/*retrieve 1bit from data*/
		x=Lbuf[x*2 + helper(1,in,fcur,fmax,data,bitcount)];
	  	}while(x<10000);
	x-=10000;
	if(sampcount>0x100) /*granted, GE doesn't actually use these...*/
		{fseek(target,tpos,SEEK_SET);
		fwrite(&x,2,1,target);
		tpos++;               /*effectively the same as tpos*2*/
		}
	else /*normal write*/
		{fseek(target,tpos,SEEK_SET);
		fputc(x,target);
		}
	}

+-+-+	samples now generated correctly
Huffman8
after generating sample table:

A0=	p->samples (target from before)
A1=	width
A2=	t#1val * height;	fieldsize
A3=	3bit treatment value
SP+10=	t#3val	(bitsample num)



if(fieldsize<=0) return 0;
for(fieldcount=0;fieldcount<fieldsize;fieldcount++)
   {if(width<=0) continue;
   pre=0;	/*previous val=0*/
   for(c=0;c!=width;c++)
	{fseek(sample,fieldcount*width + c,SEEK_SET);
	cur=fgetc(sample);
	if(fieldcount<=0) 
	  {bcur=0;
	  bpre=0;
	  }
	else
		{bpre=bcur;
		fseek(sample,(fieldcount-1)*width + c,SEEK_SET);
		bcur=fgetc(sample);
		if(c<=0) bpre=0;
		}
	
	/*A0=fseek(sample,bitsamplesize*2,SEEK_SET);*/
	case(treatment)
	    {case 0: img0(); break;
	     case 1: img1(); break;
	     case 2: img2(); break;
	     case 3: img3(); break;
	     case 4: img4(); break;
	     case 5: img5(); break;
	     case 6: img6(); break;
	     case 7: img7(); break;
	     default: break;
	    }
	
	pre=cur;	/*set new previous value*/
	}/*7F0CBACC*/
   }/*7F0CBAD4*/

img routines:
   A0=cur+bitsamplesize*2	index in 16bit palette, most likely
   A3=
   S0=
   T1='bitsamplesize'
   T3=pre
   T4=bcur
   T5=bpre
   T6=cur

img0
	x=(cur + bitsamplesize*2 + pre)%bitsamplesize;
	fseek(target,fieldcount*width + c,SEEK_SET);
	fputc(x,target);
img1
	x=(cur + bitsamplesize*2 + bcur)%bitsamplesize;
	fseek(target,fieldcount*width + c,SEEK_SET);
	fputc(x,target);
img2
	x=(cur + bitsamplesize*2 + bpre)%bitsamplesize;
	fseek(target,fieldcount*width + c,SEEK_SET);
	fputc(x,target);
img3
	x=(cur + bitsamplesize*2 + pre + bcur - bpre)%bitsamplesize;
	fseek(target,fieldcount*width + c,SEEK_SET);
	fputc(x,target);
img4
	x=bcur-bpre;
	if(x<0) x++;
	x=(cur + bitsamplesize*2 + pre + x/2)%bitsamplesize;
	fseek(target,fieldcount*width + c,SEEK_SET);
	fputc(x,target);
img5
	x=pre-bpre;
	if(x<0) x++;
	x=(cur + bitsamplesize*2 + bcur + x/2)%bitsamplesize;
	fseek(target,fieldcount*width + c,SEEK_SET);
	fputc(x,target);
img6
	x=pre+bcur;
	if(x<0) x++;
	x=(cur + bitsamplesize*2 + x/2)%bitsamplesize;
	fseek(target,fieldcount*width + c,SEEK_SET);
	fputc(x,target);

	
	
	