📄 unit1.pas
字号:
hwversion:=$0001;
bootversion:=$1001;
write1:=$7FE00000;
write2:=$7FF7FF90;
write3:=$7FFC0000;
end;
if form2.combobox1.ItemIndex=5 then
begin
{CT 2100}
hwtype:=$1010;
hwversion:=$1001;
bootversion:=$1002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
if form2.combobox1.ItemIndex=6 then
begin
{Coolsat 4000}
hwtype:=$0509;
hwversion:=$5001;
bootversion:=$2001;
write1:=$7FE00000;
write2:=$7FF7FF90;
write3:=$7FFC0000;
end;
if form2.combobox1.ItemIndex=7 then
begin
{Coolsat 5000}
hwtype:=$1409;
hwversion:=$1001;
bootversion:=$1002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
if form2.combobox1.ItemIndex=8 then
begin
{Coolsat 6000}
hwtype:=$1409;
hwversion:=$1002;
bootversion:=$1002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
if form2.combobox1.ItemIndex=9 then
begin
{Strong 4620II}
hwtype:=$130b;
hwversion:=$1001;
bootversion:=$5002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
if form2.combobox1.ItemIndex=10 then
begin
{Strong 4820II}
hwtype:=$120b;
hwversion:=$1001;
bootversion:=$5002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
if form2.combobox1.ItemIndex=11 then
begin
{RT 1000}
hwtype:=$1111;
hwversion:=$1001;
bootversion:=$1002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
if form2.combobox1.ItemIndex=12 then
begin
{RT 2000}
hwtype:=$1011;
hwversion:=$1001;
bootversion:=$1002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
if form2.combobox1.ItemIndex=13 then
begin
{RT 3000}
hwtype:=$0411;
hwversion:=$0001;
bootversion:=$3001;
write1:=$7FE00000;
write2:=$7FF7FF90;
write3:=$7FFC0000;
end;
if form2.combobox1.ItemIndex=14 then
begin
{Benjamin 8000}
hwtype:=$0204;
hwversion:=$0001;
bootversion:=$1001;
write1:=$7FE00000;
write2:=$7FF7FF90;
write3:=$7FFC0000;
end;
if form2.combobox1.ItemIndex=15 then
begin
{SkyX}
hwtype:=$0103;
hwversion:=$0001;
bootversion:=$4001;
write1:=$7FE00000;
write2:=$7FF7FF90;
write3:=$7FFC0000;
end;
if form2.combobox1.ItemIndex=16 then
begin
{Maxplus 2100}
hwtype:=$1001;
hwversion:=$1001;
bootversion:=$1002;
write1:=$7F020000;
write2:=$7F17FF90;
write3:=$7F1E0000;
end;
AssignFile(F, opendialog1.filename);
reset(f,1);
Uncomp:=filesize(F);
GetMem(p, Uncomp);
GetMem(p2, 2000000);
n:=0;
w:=0;
chaddr:=0;
while not eof(f) do
begin
n:=n+1;
blockread(f,s,1);
if (W=2) and (chr(s)='F') then begin chaddr:=n-3; w:=0; end;
if (W=1) and (chr(s)='D') then w:=2 else w:=0;
if chr(s)='N' then w:=1;
q:=q+s;
p^:=s;
inc(p);
end;
closefile(f);
dec(p,n);
if chaddr=0 then begin showmessage('Wrong file!'); freemem(p); freemem(p2); exit; end;
if form2.checkbox1.Checked then
begin
found:=false;
i:=0;
while (i<n-4) and (found=false) do
begin
w1:=p^; inc(p);
w2:=p^; inc(p);
w3:=p^; inc(p);
w4:=p^;
if (w1=$1) and (w2=$1b) and (w3=$0) and (w4=$22) then
begin
dec(p,3);
p^:=$0;
inc(p);
p^:=$21;
inc(p,2);
found:=true;
end;
i:=i+1;
dec(p,2);
end;
dec(p,i);
end;
k:=0;
calculate:=0;
if form2.checkbox1.enabled then
begin
apsize:=apsize-4;
if apsize/4 <> round(apsize/4) then begin apsize:=apsize-1; k:=1; end;
if apsize/4 <> round(apsize/4) then begin apsize:=apsize-1; k:=2; end;
if apsize/4 <> round(apsize/4) then begin apsize:=apsize-1; k:=3; end;
for i:=1 to round(apsize/4) do
begin
if i=3 then inc(p,4);
calculate:=calculate+p^;
inc(p);
calculate:=calculate+p^*$100;
inc(p);
calculate:=calculate+p^*$100*$100;
inc(p);
calculate:=calculate+p^*$100*$100*$100;
inc(p);
end;
for i:=1 to k do
begin
calculate:=calculate+p^;
inc(p);
end;
dec(p,apsize+k+4);
end;
if form2.checkbox2.Checked then
begin
inc (p,8);
p^:=lo(calculate);
inc (p);
p^:=hi(calculate);
inc (p);
p^:=lo(calculate div $10000);
inc (p);
p^:=hi(calculate div $10000);
dec(p,11);
end;
crcvalue:=0;
for i:=1 to n do
begin
s:=p^;
{This is to calculate CRC16 value of uncompressed file }
CRCvalue := Hi(CRCvalue) XOR Table[s XOR Lo(CRCvalue) ];
inc (p);
end;
dec(p,n);
inc (p,chaddr-48);
sw:=p^;
inc (p);
sw:=sw+p^*$100;
dec (p,chaddr-47);
t:=LH5Compress(p, n, p2);
AssignFile(F2, opendialog1.filename+'.stb');
rewrite(f2,1);
tmp:=$425453;
blockwrite(f2,tmp,4); {Write STB }
if (chaddr=$160000) or (chaddr=$180000) then headerlen:=$34 else headerlen:=$40;
blockwrite(f2,headerlen,4); {Write header length}
if headerlen=$34 then tmp:=$1010001 else tmp:=$1020001;
blockwrite(f2,tmp,4); {Write ?}
tmp:=$CDCDCDCD;
if (form2.combobox1.ItemIndex=8) or (form2.combobox1.ItemIndex=7) then tmp:=0; {Coolsat 5/6000 value 0) }
blockwrite(f2,tmp,4); {Write ?}
blockwrite(f2,hwtype,2);
blockwrite(f2,hwversion,2);
blockwrite(f2,bootversion,2);
blockwrite(f2,sw,2);
if headerlen=$34 then tmp:=$FF010102 else tmp:=$FF010103;
blockwrite(f2,tmp,4); {Write ?}
blockwrite(f2,write1,4); {Address where to write 1st part}
tmp:=$0;
blockwrite(f2,tmp,4); {Where to start}
tmp:=chaddr-$70;
if chaddr=$160000 then tmp:=chaddr;
if chaddr=$180000 then tmp:=chaddr;
blockwrite(f2,tmp,4); {How many bytes}
if headerlen=$40 then
begin
blockwrite(f2,write2,4); {Address where to write 2nd part}
tmp:=chaddr-$70;
blockwrite(f2,tmp,4); {Where to start}
tmp:=$70;
blockwrite(f2,tmp,4); {How many bytes}
end;
blockwrite(f2,write3,4); {Address where to write 3rd part}
tmp:=chaddr;
blockwrite(f2,tmp,4); {Where to start}
tmp:=uncomp-chaddr;
if form2.combobox1.itemindex<3 then tmp:=tmp-1; {TM patches doesn't write last byte to receiver}
if form2.combobox1.itemindex=14 then tmp:=tmp-1; {Same here, (Benjamin 8000). These two rows can be removed, it doesn't matter. But then stb file is different than original (If you compare)}
blockwrite(f2,tmp,4); {How many bytes}
s:=$19;
blockwrite(f2,s,1); {Write header size}
s:=lo(uncomp div $10000 + hi(uncomp) + lo(uncomp) + t div $10000 + hi(t) + lo(t)+ $163 + $20 +$1 + $20 + lo(CRCvalue)+hi(CRCvalue));
blockwrite(f2,s,1); {Write header checksum}
blockwrite(f2,'-lh5-',5);
blockwrite(f2,t,4); {Write compressed size}
blockwrite(f2,uncomp,4); {Write uncompressed size}
q:=0;
blockwrite(f2,q,4);
q:=$120;
blockwrite(f2,q,3);
blockwrite(f2,CRCvalue,2); {Write uncompressed data CRC}
q:=$20;
blockwrite(f2,q,3);
for i:=0 to t do
begin
blockwrite(f2,p2^,1);
inc(p2);
end;
closefile(f2);
freemem(p);
dec(p2,t+1);
freemem(p2);
showmessage('Done, '+ opendialog1.filename+'.stb created!');
screen.cursor:=crarrow;
end;
procedure TForm1.About1Click(Sender: TObject);
begin
showmessage('Version 1.03 (Beta)'+chr(13)+chr(13)+'** By Timewarp **'+chr(13)+chr(13)+'http://www.sataid.net/forum/');
end;
procedure TForm1.ChangeNDFChannellist1Click(Sender: TObject);
begin
form3.visible:=true;
end;
END.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -