Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions maxFormat.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface

type
nameArray = array[0..31] of AnsiChar;
iconArray = array[0..33] of AnsiChar;

type
TMaxheader = record
Expand Down Expand Up @@ -59,7 +60,7 @@ type sceVu0FVECTOR = record
end;

type Ticon_sys = record
header : array[0..3] of char;
header : array[0..3] of AnsiChar;
reserved : word;
titleBreak : word;
reserved2 : integer;
Expand Down Expand Up @@ -102,13 +103,13 @@ TMaxSave = class
procedure buildClump;
procedure buildHeader;
procedure updateChecksum;
function getIcon_SysName : string;
function getIcon_SysName : iconArray;
function CalculateCRCFromStream(aStream: TStream): Cardinal;
protected
files : Tlist; //list of all the files (inc data)
function cleanString (input : string): string;
function asciiToShiftJis(input : char) : word;
function ShiftJistoAscii(input : word) : char;
function ShiftJistoAscii(input : word) : AnsiChar;
public
procedure loadSave(fileName : string);
//function ListFiles;
Expand Down Expand Up @@ -213,12 +214,12 @@ function TMaxSave.asciiToShiftJis(input : char) : word;
$27 : result := $AD81;
$28 : result := $6981;
$29 : result := $6A81;
$2A : result := $4081; //banned char, return a space
$2A : result := $9681; //Added "*"
$2B : result := $7B81;
$2C : result := $4181;
$2D : result := $7C81;
$2E : result := $4281;
$2F : result := $4081; //banned char, return a space
$2E : result := $4481; //Fixed "."
$2F : result := $5E81; //Added "/"
$30 : result := $4F82;
$31 : result := $5082;
$32 : result := $5182;
Expand All @@ -234,7 +235,7 @@ function TMaxSave.asciiToShiftJis(input : char) : word;
$3C : result := $8381;
$3D : result := $8181;
$3E : result := $8481;
$3F : result := $4081; //banned char, return a space
$3F : result := $4881; //Added "?"
$40 : result := $9781;
$41 : result := $6082;
$42 : result := $6182;
Expand Down Expand Up @@ -335,22 +336,27 @@ procedure TMaxSave.buildClump;
end;

procedure TMaxSave.buildHeader;
var
a : integer;
begin
a := 0;
maxHeader.magic := 'Ps2PowerSave';
maxHeader.compressedSize := compressedClump.Size;
maxHeader.compressedSize := compressedClump.Size + 4;
maxHeader.origSize := clump.Size;
//origSize := clump.Size;
maxHeader.numFiles := files.Count;
maxHeader.checksum := 0;
if maxHeader.dirName = '' then begin
maxHeader.dirName := 'New Directory';
maxHeader.dirName := 'New Directory';
end;
if fileExists('icon.sys') then begin
fillchar(maxHeader.iconSysName, 32, $0); //ensure remaining space is blank
StrPCopy(maxHeader.iconSysName, getIcon_SysName);
//maxHeader.iconSysName := getIcon_SysName;
//StrPCopy(maxHeader.iconSysName, getIcon_SysName);
for a := 0 to 31 do begin
maxHeader.iconSysName[a] := getIcon_SysName[a];
end;
end else begin
maxHeader.iconSysName := 'New File';
maxHeader.iconSysName := 'New File';
end;
end;

Expand Down Expand Up @@ -650,14 +656,13 @@ function TMaxSave.getHeaderDirname2: nameArray;
result := temp;
end;

function TMaxsave.getIcon_SysName : string;
function TMaxsave.getIcon_SysName : iconArray;
var
iconFile: TIcon_Sys;
a : integer;
aFile : PFileDetails;
buffer : string;
buffer : iconArray;
begin
buffer := '';
for a := 0 to files.count - 1 do begin
aFile := files.items[a];
if aFile^.name = 'icon.sys' then begin
Expand All @@ -666,7 +671,7 @@ function TMaxsave.getIcon_SysName : string;
end;
end;
for a := 0 to 33 do begin
buffer := buffer + ShiftJistoAscii(iconFile.titleName[a]);
buffer[a] := ShiftJistoAscii(iconFile.titleName[a]);
end;
result := buffer;
end;
Expand Down Expand Up @@ -756,7 +761,7 @@ procedure TMaxSave.setHeaderDirName(dirName : string);
//maxHeader.dirName := dirName;
end;

function TMaxSave.ShiftJistoAscii(input: word): char;
function TMaxSave.ShiftJistoAscii(input: word): AnsiChar;
begin
case input of
//SJIS bytes are reversed, this was cheaper than a byteswap.
Expand All @@ -771,10 +776,13 @@ function TMaxSave.ShiftJistoAscii(input: word): char;
$AD81 : result := Char($27);
$6981 : result := Char($28);
$6A81 : result := Char($29);
$9681 : result := Char($2A); //Added "*"
$7B81 : result := Char($2B);
$4181 : result := Char($2C);
$7C81 : result := Char($2D);
$4281 : result := Char($2E);
$4481 : result := Char($2E); //Added "."
$5E81 : result := Char($2F); //Added "/"
$4F82 : result := Char($30);
$5082 : result := Char($31);
$5182 : result := Char($32);
Expand Down Expand Up @@ -853,11 +861,11 @@ function TMaxSave.ShiftJistoAscii(input: word): char;
$6281 : result := Char($7C);
$7081 : result := Char($7D);
$6081 : result := Char($7E);
$0000 : result := Char($00);
$0081 : result := Char($20); //bug fix for faulty PS2 Save Builder made/edited icon.sys files
$3F82 : result := char($20); //bug fix for faulty mcIconSysGen made
$3F82 : result := char($20); //bug fix for faulty mcIconSysGen made
$3F81 : result := char($20); //bug fix
//icon.sys files
else result := '?';
else result := char($00);
end;
end;

Expand Down Expand Up @@ -972,4 +980,3 @@ function TMaxSave.getFileNameforFile(itemNum : integer): nameArray;
end;

end.