📄 awfaxcvt.pas
字号:
(Code : $0035; Sig : 6),
(Code : $002A; Sig : 6),
(Code : $002B; Sig : 6),
(Code : $0027; Sig : 7),
(Code : $000C; Sig : 7),
(Code : $0008; Sig : 7),
(Code : $0017; Sig : 7),
(Code : $0003; Sig : 7),
(Code : $0004; Sig : 7),
(Code : $0028; Sig : 7),
(Code : $002B; Sig : 7),
(Code : $0013; Sig : 7),
(Code : $0024; Sig : 7),
(Code : $0018; Sig : 7),
(Code : $0002; Sig : 8),
(Code : $0003; Sig : 8),
(Code : $001A; Sig : 8),
(Code : $001B; Sig : 8),
(Code : $0012; Sig : 8),
(Code : $0013; Sig : 8),
(Code : $0014; Sig : 8),
(Code : $0015; Sig : 8),
(Code : $0016; Sig : 8),
(Code : $0017; Sig : 8),
(Code : $0028; Sig : 8),
(Code : $0029; Sig : 8),
(Code : $002A; Sig : 8),
(Code : $002B; Sig : 8),
(Code : $002C; Sig : 8),
(Code : $002D; Sig : 8),
(Code : $0004; Sig : 8),
(Code : $0005; Sig : 8),
(Code : $000A; Sig : 8),
(Code : $000B; Sig : 8),
(Code : $0052; Sig : 8),
(Code : $0053; Sig : 8),
(Code : $0054; Sig : 8),
(Code : $0055; Sig : 8),
(Code : $0024; Sig : 8),
(Code : $0025; Sig : 8),
(Code : $0058; Sig : 8),
(Code : $0059; Sig : 8),
(Code : $005A; Sig : 8),
(Code : $005B; Sig : 8),
(Code : $004A; Sig : 8),
(Code : $004B; Sig : 8),
(Code : $0032; Sig : 8),
(Code : $0033; Sig : 8),
(Code : $0034; Sig : 8));
WhiteMUTable : TMakeUpCodeArray = (
(Code : $001B; Sig : 5),
(Code : $0012; Sig : 5),
(Code : $0017; Sig : 6),
(Code : $0037; Sig : 7),
(Code : $0036; Sig : 8),
(Code : $0037; Sig : 8),
(Code : $0064; Sig : 8),
(Code : $0065; Sig : 8),
(Code : $0068; Sig : 8),
(Code : $0067; Sig : 8),
(Code : $00CC; Sig : 9),
(Code : $00CD; Sig : 9),
(Code : $00D2; Sig : 9),
(Code : $00D3; Sig : 9),
(Code : $00D4; Sig : 9),
(Code : $00D5; Sig : 9),
(Code : $00D6; Sig : 9),
(Code : $00D7; Sig : 9),
(Code : $00D8; Sig : 9),
(Code : $00D9; Sig : 9),
(Code : $00DA; Sig : 9),
(Code : $00DB; Sig : 9),
(Code : $0098; Sig : 9),
(Code : $0099; Sig : 9),
(Code : $009A; Sig : 9),
(Code : $0018; Sig : 6),
(Code : $009B; Sig : 9),
(Code : $0008; Sig : 11),
(Code : $000C; Sig : 11),
(Code : $000D; Sig : 11),
(Code : $0012; Sig : 12),
(Code : $0013; Sig : 12),
(Code : $0014; Sig : 12),
(Code : $0015; Sig : 12),
(Code : $0016; Sig : 12),
(Code : $0017; Sig : 12),
(Code : $001C; Sig : 12),
(Code : $001D; Sig : 12),
(Code : $001E; Sig : 12),
(Code : $001F; Sig : 12));
BlackTable : TTermCodeArray = (
(Code : $0037; Sig : 10),
(Code : $0002; Sig : 3),
(Code : $0003; Sig : 2),
(Code : $0002; Sig : 2),
(Code : $0003; Sig : 3),
(Code : $0003; Sig : 4),
(Code : $0002; Sig : 4),
(Code : $0003; Sig : 5),
(Code : $0005; Sig : 6),
(Code : $0004; Sig : 6),
(Code : $0004; Sig : 7),
(Code : $0005; Sig : 7),
(Code : $0007; Sig : 7),
(Code : $0004; Sig : 8),
(Code : $0007; Sig : 8),
(Code : $0018; Sig : 9),
(Code : $0017; Sig : 10),
(Code : $0018; Sig : 10),
(Code : $0008; Sig : 10),
(Code : $0067; Sig : 11),
(Code : $0068; Sig : 11),
(Code : $006C; Sig : 11),
(Code : $0037; Sig : 11),
(Code : $0028; Sig : 11),
(Code : $0017; Sig : 11),
(Code : $0018; Sig : 11),
(Code : $00CA; Sig : 12),
(Code : $00CB; Sig : 12),
(Code : $00CC; Sig : 12),
(Code : $00CD; Sig : 12),
(Code : $0068; Sig : 12),
(Code : $0069; Sig : 12),
(Code : $006A; Sig : 12),
(Code : $006B; Sig : 12),
(Code : $00D2; Sig : 12),
(Code : $00D3; Sig : 12),
(Code : $00D4; Sig : 12),
(Code : $00D5; Sig : 12),
(Code : $00D6; Sig : 12),
(Code : $00D7; Sig : 12),
(Code : $006C; Sig : 12),
(Code : $006D; Sig : 12),
(Code : $00DA; Sig : 12),
(Code : $00DB; Sig : 12),
(Code : $0054; Sig : 12),
(Code : $0055; Sig : 12),
(Code : $0056; Sig : 12),
(Code : $0057; Sig : 12),
(Code : $0064; Sig : 12),
(Code : $0065; Sig : 12),
(Code : $0052; Sig : 12),
(Code : $0053; Sig : 12),
(Code : $0024; Sig : 12),
(Code : $0037; Sig : 12),
(Code : $0038; Sig : 12),
(Code : $0027; Sig : 12),
(Code : $0028; Sig : 12),
(Code : $0058; Sig : 12),
(Code : $0059; Sig : 12),
(Code : $002B; Sig : 12),
(Code : $002C; Sig : 12),
(Code : $005A; Sig : 12),
(Code : $0066; Sig : 12),
(Code : $0067; Sig : 12));
BlackMUTable : TMakeUpCodeArray = (
(Code : $000F; Sig : 10),
(Code : $00C8; Sig : 12),
(Code : $00C9; Sig : 12),
(Code : $005B; Sig : 12),
(Code : $0033; Sig : 12),
(Code : $0034; Sig : 12),
(Code : $0035; Sig : 12),
(Code : $006C; Sig : 13),
(Code : $006D; Sig : 13),
(Code : $004A; Sig : 13),
(Code : $004B; Sig : 13),
(Code : $004C; Sig : 13),
(Code : $004D; Sig : 13),
(Code : $0072; Sig : 13),
(Code : $0073; Sig : 13),
(Code : $0074; Sig : 13),
(Code : $0075; Sig : 13),
(Code : $0076; Sig : 13),
(Code : $0077; Sig : 13),
(Code : $0052; Sig : 13),
(Code : $0053; Sig : 13),
(Code : $0054; Sig : 13),
(Code : $0055; Sig : 13),
(Code : $005A; Sig : 13),
(Code : $005B; Sig : 13),
(Code : $0064; Sig : 13),
(Code : $0065; Sig : 13),
(Code : $0008; Sig : 11),
(Code : $000C; Sig : 11),
(Code : $000D; Sig : 11),
(Code : $0012; Sig : 12),
(Code : $0013; Sig : 12),
(Code : $0014; Sig : 12),
(Code : $0015; Sig : 12),
(Code : $0016; Sig : 12),
(Code : $0017; Sig : 12),
(Code : $001C; Sig : 12),
(Code : $001D; Sig : 12),
(Code : $001E; Sig : 12),
(Code : $001F; Sig : 12));
{Sizes for small font used for header line}
SmallFontRec : TFontRecord = (
Bytes : 16;
PWidth : 12;
Width : 2;
Height : 8);
{Sizes for standard font}
StandardFontRec : TFontRecord = (
Bytes : 48;
PWidth : 20;
Width : 3;
Height : 16);
{$IFNDEF Win32}
procedure RotateCode(var Code : Word; Sig : Word); assembler;
{-Flip code MSB for LSB}
asm
les di,Code
mov dx,es:[di]
xor ax,ax
mov cx,16
@1: shr dx,1
rcl ax,1
loop @1
mov cx,16
sub cx,Sig
shr ax,cl
mov es:[di],ax
end;
{$ELSE}
procedure RotateCode(var Code : Word; Sig : Word); assembler; register;
{-Flip code MSB for LSB}
asm
push edi
push ebx
{load parameters}
mov edi,eax {edi = Code}
mov ebx,edx {ebx = Sig }
mov dx,word ptr [edi]
xor ax,ax
mov ecx,16
@1: shr dx,1
rcl ax,1
dec ecx
jnz @1
mov cx,16
sub cx,bx
shr ax,cl
mov [edi],ax
pop ebx
pop edi
end;
{$ENDIF}
{Miscellaneous}
function awIsAnAPFFile(FName : PChar) : Bool;
{-Return TRUE if the file FName is a valid APF file}
var
F : File;
Sig : TSigArray;
SaveFileMode : Word;
begin
awIsAnAPFFile := False;
{open the file}
Assign(F, FName);
SaveFileMode := FileMode;
FileMode := fmOpenRead or fmShareDenyWrite;
Reset(F, 1);
FileMode := SaveFileMode;
if (IoResult <> 0) then
Exit;
{read in what ought top be a signature}
BlockRead(F, Sig, SizeOf(Sig));
if (IoResult <> 0) then begin
Close(F); if (IoResult = 0) then ;
Exit;
end;
Close(F); if (IoResult = 0) then ;
awIsAnAPFFile := (DefAPFSig = Sig);
end;
{$IFNDEF Win32}
procedure FastZero(var Buf; Len : Cardinal); assembler;
asm
cld {go forward}
les di,Buf {ES:DI->Buf}
mov cx,Len {CX = length of buffer}
xor ax,ax {store zeros}
shr cx,1 {CX = CX/2}
rep stosw {store zeros by word}
adc cx,cx {any leftover}
rep stosb {store zeros by byte}
end;
function MaxCardinal(A, B : Cardinal) : Cardinal; assembler;
asm
mov ax,a
cmp ax,b
jae @1
mov ax,b
@1:
end;
{$ELSE}
procedure FastZero(var Buf; Len : Cardinal); assembler; register;
asm
push edi
cld
{load parameters}
mov edi,eax {eax = Buf}
mov ecx,edx {edx = Len}
and edx,3
shr ecx,2
xor eax,eax {store zeros}
{store by dword}
rep stosd
{store by byte}
mov ecx,edx
rep stosb
pop edi
end;
function MaxCardinal(A, B : Cardinal) : Cardinal; assembler; register;
asm
cmp eax,edx {eax = A, edx = B}
jae @1
mov eax,edx
@1:
end;
{$ENDIF}
{Buffered file code}
const
CvtOutBufSize = 4096;
function InitOutFile(var F : PBufferedOutputFile; Name : PChar) : Integer;
var
Code : Integer;
begin
F := AllocMem(SizeOf(TBufferedOutputFile));
FastZero(F^, SizeOf(TBufferedOutputFile));
with F^ do begin
{initialize buffer}
Buffer := AllocMem(CvtOutBufSize);
FastZero(Buffer^, CvtOutBufSize);
{create the output file}
Assign(OutFile, Name);
Rewrite(OutFile, 1);
Code := -IoResult;
if (Code < ecOK) then begin
FreeMem(Buffer, CvtOutBufSize);
FreeMem(F, SizeOf(TBufferedOutputFile));
InitOutFile := Code;
Exit;
end;
InitOutFile := ecOK;
end;
end;
procedure CleanupOutFile(var F : PBufferedOutputFile);
begin
Close(F^.OutFile); if (IoResult = 0) then ;
Erase(F^.OutFile); if (IoResult = 0) then ;
FreeMem(F^.Buffer, CvtOutBufSize);
FreeMem(F, SizeOf(TBufferedOutputFile));
end;
function FlushOutFile(var F : PBufferedOutputFile) : Integer;
var
Code : Integer;
begin
FlushOutFile := ecOK;
with F^ do begin
if (BufPos = 0) then
Exit;
BlockWrite(OutFile, Buffer^, BufPos);
Code := -IoResult;
if (Code < ecOK) then begin
CleanupOutFile(F);
FlushOutFile := Code;
end else
BufPos := 0;
end;
end;
function WriteOutFile(var F : PBufferedOutputFile; var Data; Len : Cardinal) : Integer;
var
Code : Integer;
InPosn : Cardinal;
BytesLeft : Cardinal;
BytesToWrite : Cardinal;
begin
WriteOutFile := ecOK;
with F^ do
{will all the new data fit into the output buffer?}
if ((BufPos + Len) < CvtOutBufSize) then begin
Move(Data, Buffer^[BufPos], Len);
Inc(BufPos, Len);
end else begin
if (BufPos > 0) then begin
{move as much data as possible into the buffer and flush it}
BytesToWrite := CvtOutBufSize - BufPos;
InPosn := BytesToWrite;
Move(Data, Buffer^[BufPos], BytesToWrite);
BufPos := CvtOutBufSize;
Code := FlushOutFile(F);
if (Code < ecOK) then begin
WriteOutFile := Code;
Exit;
end;
end else begin
BytesToWrite := 0;
InPosn := 0;
end;
{if there's very little data remaining, buffer it and exit}
BytesLeft := Len - BytesToWrite;
if (BytesLeft < CvtOutBufSize) then begin
Move(TByteArray(Data)[BytesToWrite], Buffer^, BytesLeft);
BufPos := BytesLeft;
Exit;
end;
{round down to nearest multiple of CvtOutBufSize}
BytesToWrite := BytesLeft and (not Pred(CvtOutBufSize));
Dec(BytesLeft, BytesToWrite);
{write out as many chunks of CvtOutBufSize as we can}
BlockWrite(OutFile, TByteArray(Data)[InPosn], BytesToWrite);
Code := -IoResult;
if (Code < ecOK) then begin
CleanupOutFile(F);
WriteOutFile := Code;
Exit;
end;
Inc(InPosn, BytesToWrite);
{move the rest of the data into the buffer}
Move(TByteArray(Data)[InPosn], Buffer^, BytesLeft);
BufPos := BytesLeft;
end;
end;
function SeekOutFile(var F : PBufferedOutputFile; Posn : LongInt) : Integer;
var
Code : Integer;
begin
Code := FlushOutFile(F);
if (Code < ecOK) then begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -