Rem Project: hash decompress
Rem Created: Thursday, March 20, 2014
Rem ***** Main Source File *****
rem setup to hold answers
Dim Answers(3)
rem vector values
xaxa=40
xbxb=40
xcxc=40
minval=10010
lasttotal=1000
total=1000
rem above is starting variables
DecompressVB:
rem when you decompress only yansy is 8bit->40bit or 5 to 1TEV and 5 to 1 2TEV on 16 bit
rem TEVs 3-4
rem 104 bits totalgetans(TEVADD(AngleA,256,AngleA,0,0,2))
Setup fourray which is 4x-4x^2 for[1/256,256/256]
global Dim fourray(256)
for AngC=1 to 256
fourray(AngC)=getans(TEVADD(AngC,256,AngC,0,0,2))
print AngC
next AngC
print "D2"
rem Show it has completed
rem search for value in spherical coordinates that matches (R,U,V) however Sin and Cos are approximated with TEV functions.
for AA=1 to 256
for BB=1 to 256
for CC=1 to 256
if AA<256 and AA>0 and BB<256 and BB>0 and CC<256 and CC>0
rem zansz=(CC*1.0*(256-AA))/256
zansz=CC*TEVSUB(BB,0,BB,0,0,4)
yansy=CC*TEVSUB(AA,256,AA,0,0,2)*TEVSUB(BB,256,BB,0,0,2)
rem yansy=CC*1.0/2*twosincossolved(AA,BB)
rem xansy=(CC*1.0/2*getans(TEVADD(0,fourray(AA),fourray(AA),yansy,0,3))*256/fourray(AA))/256
xansy=CC*TEVSUB(AA,256,AA,0,0,2)*TEVSUB(BB,0,BB,0,0,4)
lastval=total
total=abs(xaxa-xansy)+abs(xbxb-yansy)+abs(xcxc-zansz)
rem compare the total difference with the minimum difference.
if total<minval and AA<256 and AA>0 and BB<256 and BB>0 and CC<256 and CC>0
rem Output what angles it would take to get closest to input vectors
Answers(1)=AA
Answers(2)=BB
Answers(3)=CC
minval=total
rem print error
print minval
endif
endif
rem do for all values of R,U,V
next CC
next BB
next AA
do
rem Print the value that appears at points and allows you to change x,y,z to check. xaxa is to avoid duplicates in other programs.
repeat
text 400,10,str$(xaxa)
text 400,30,str$(xbxb)
text 400,50,str$(xcxc)
text 400,70,str$(Answers(1))
text 400,90,str$(Answers(2))
text 400,110,str$(Answers(3))
if upkey()=1
xaxa=xaxa+1
cls
endif
if downkey()=1
xaxa=xaxa-1
cls
endif
if xaxa>256 then xaxa=1
if leftkey()=1
xbxb=xbxb+1
cls
endif
if rightkey()=1
xbxb=xbxb-1
cls
endif
if xbxb>256 then xbxb=1
if returnkey()=1
xcxc=xcxc+1
cls
endif
if shiftkey()=1
xcxc=xcxc-1
cls
endif
if xcxc>256 then xcxc=1
wait 100
until controlkey()=1
if Answers(1)<256 and Answers(1)>0 and Answers(2)<256 and Answers(2)>0 and Answers(3)<256 and Answers(3)>0
zansz=(Answers(3)*1.0*(256-Answers(1)))/256
yansy=Answers(3)*1.0/2*twosincossolved(Answers(1),Answers(2))
xansy=(Answers(3)*1.0/2*getans(TEVADD(0,fourray(Answers(1)),fourray(Answers(1)),yansy,0,3))*256/fourray(Answers(1)))/256
endif
print zansz
print yansy
print xansy
wait key
loop
function twosincossolved(quadA,quadB)
rem table (4S-4S^2) where needed [1,0]
rem table (remember to half for 2T) (1-(2T-T^2)) where needed [1,0]
rem 2*-1/2*b+a*1/2
ans#=TEVSUB(quadA,quadB,128,256,0,3)
rem ans=getans(ans#)
endfunction ans#
function TEVADD(a,b,c,d,k,l)
a#=a
b#=b
c#=c
d#=d
k#=k
a#=a#*1.0/256
b#=b#*1.0/256
c#=c#*1.0/256
d#=d#*1.0/256
k#=k#*1.0/256
l#=2^(l-2)
stepA#=(1.0-c#)
stepB#=(stepA#*a#)
stepB#=getans(stepB#)*1.0/256
stepBB#=(c#*b#)
stepBB#=getans(stepBB#)*1.0/256
stepBBB#=stepBB#+stepB#
stepBBB#=getans(stepBBB#)*1.0/256
stepC#=d#+stepBBB#
stepC#=getans(stepC#)*1.0/256
stepD#=stepC#+k#
stepD#=getans(stepD#)*1.0/256
stepE#=stepD#*l#
endfunction stepE#
function TEVSUB(a,b,c,d,k,l)
a#=a
b#=b
c#=c
d#=d
k#=k
a#=a#*1.0/256
b#=b#*1.0/256
c#=c#*1.0/256
d#=d#*1.0/256
k#=k#*1.0/256
l#=2^(l-2)
stepA#=(1.0-c#)
stepB#=(stepA#*a#)
stepB#=getans(stepB#)*1.0/256
stepBB#=(c#*b#)
stepBB#=getans(stepBB#)*1.0/256
stepBBB#=stepBB#+stepB#
stepBBB#=getans(stepBBB#)*1.0/256
stepC#=d#-stepBBB#
stepC#=getans(stepC#)*1.0/256
stepD#=stepC#+k#
stepD#=getans(stepD#)*1.0/256
stepE#=stepD#*l#
endfunction stepE#
function getans(z#)
m=0
remstart
while z#*256>m
m=m+1
endwhile
remend
m=ceil(256*z#)
endfunction m
XXX