From a04e46d2bcace091aee25b6605f10567aee99176 Mon Sep 17 00:00:00 2001 From: Nahuel Gaitan <45178494+bkragnarok@users.noreply.github.com> Date: Sat, 1 Jun 2024 22:57:58 -0300 Subject: [PATCH 1/4] Update maxFormat.pas Fix the size and names for output files --- maxFormat.pas | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/maxFormat.pas b/maxFormat.pas index 156d4e7..8ac0acc 100644 --- a/maxFormat.pas +++ b/maxFormat.pas @@ -59,7 +59,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; @@ -213,12 +213,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; @@ -234,7 +234,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; @@ -337,7 +337,7 @@ procedure TMaxSave.buildClump; procedure TMaxSave.buildHeader; begin maxHeader.magic := 'Ps2PowerSave'; - maxHeader.compressedSize := compressedClump.Size; + maxHeader.compressedSize := compressedClump.Size + 4; maxHeader.origSize := clump.Size; //origSize := clump.Size; maxHeader.numFiles := files.Count; @@ -350,7 +350,7 @@ procedure TMaxSave.buildHeader; StrPCopy(maxHeader.iconSysName, getIcon_SysName); //maxHeader.iconSysName := getIcon_SysName; end else begin - maxHeader.iconSysName := 'New File'; + maxHeader.iconSysName := 'New File'; end; end; @@ -771,10 +771,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); @@ -855,7 +858,8 @@ function TMaxSave.ShiftJistoAscii(input: word): char; $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 := '?'; end; @@ -972,4 +976,3 @@ function TMaxSave.getFileNameforFile(itemNum : integer): nameArray; end; end. - \ No newline at end of file From a4c5d01a487bab4b1653b582a5d119ccd282d6ec Mon Sep 17 00:00:00 2001 From: Nahuel Gaitan <45178494+bkragnarok@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:39:43 -0300 Subject: [PATCH 2/4] changed the output for unkown characters --- maxFormat.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxFormat.pas b/maxFormat.pas index 8ac0acc..bc73fdd 100644 --- a/maxFormat.pas +++ b/maxFormat.pas @@ -861,7 +861,7 @@ function TMaxSave.ShiftJistoAscii(input: word): char; $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; From b009725f8fc38376d801477b173ee873ecd4c6eb Mon Sep 17 00:00:00 2001 From: Nahuel Gaitan <45178494+bkragnarok@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:42:46 -0300 Subject: [PATCH 3/4] changed some strings to tbytes strings stops at null characters, so I needed to change it to tbyte --- maxFormat.pas | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/maxFormat.pas b/maxFormat.pas index bc73fdd..b43cfd0 100644 --- a/maxFormat.pas +++ b/maxFormat.pas @@ -102,7 +102,7 @@ TMaxSave = class procedure buildClump; procedure buildHeader; procedure updateChecksum; - function getIcon_SysName : string; + function getIcon_SysName : TBytes; function CalculateCRCFromStream(aStream: TStream): Cardinal; protected files : Tlist; //list of all the files (inc data) @@ -335,7 +335,10 @@ procedure TMaxSave.buildClump; end; procedure TMaxSave.buildHeader; +var + a : integer; begin + a := 0; maxHeader.magic := 'Ps2PowerSave'; maxHeader.compressedSize := compressedClump.Size + 4; maxHeader.origSize := clump.Size; @@ -343,14 +346,16 @@ procedure TMaxSave.buildHeader; 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] := AnsiChar(getIcon_SysName[a]); + end; end else begin - maxHeader.iconSysName := 'New File'; + maxHeader.iconSysName := 'New File'; end; end; @@ -650,14 +655,14 @@ function TMaxSave.getHeaderDirname2: nameArray; result := temp; end; -function TMaxsave.getIcon_SysName : string; +function TMaxsave.getIcon_SysName : TBytes; var iconFile: TIcon_Sys; a : integer; aFile : PFileDetails; - buffer : string; + buffer : TBytes; begin - buffer := ''; + SetLength(buffer, 34); for a := 0 to files.count - 1 do begin aFile := files.items[a]; if aFile^.name = 'icon.sys' then begin @@ -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] := Byte(ShiftJistoAscii(iconFile.titleName[a])); end; result := buffer; end; @@ -771,13 +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 "*" + $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 "/" + $4481 : result := Char($2E); //Added "." + $5E81 : result := Char($2F); //Added "/" $4F82 : result := Char($30); $5082 : result := Char($31); $5182 : result := Char($32); @@ -856,7 +861,6 @@ 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 $3F81 : result := char($20); //bug fix From 8ba6639cc99748f14b35762053793b721e35cd9e Mon Sep 17 00:00:00 2001 From: Nahuel Gaitan <45178494+bkragnarok@users.noreply.github.com> Date: Tue, 4 Jun 2024 02:37:30 -0300 Subject: [PATCH 4/4] Tbytes replaced for AnsiChars Reverted the Tbytes and replaced all to AnsiChars for better readability --- maxFormat.pas | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/maxFormat.pas b/maxFormat.pas index b43cfd0..b5392e5 100644 --- a/maxFormat.pas +++ b/maxFormat.pas @@ -19,6 +19,7 @@ interface type nameArray = array[0..31] of AnsiChar; + iconArray = array[0..33] of AnsiChar; type TMaxheader = record @@ -102,13 +103,13 @@ TMaxSave = class procedure buildClump; procedure buildHeader; procedure updateChecksum; - function getIcon_SysName : TBytes; + 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; @@ -352,7 +353,7 @@ procedure TMaxSave.buildHeader; fillchar(maxHeader.iconSysName, 32, $0); //ensure remaining space is blank //StrPCopy(maxHeader.iconSysName, getIcon_SysName); for a := 0 to 31 do begin - maxHeader.iconSysName[a] := AnsiChar(getIcon_SysName[a]); + maxHeader.iconSysName[a] := getIcon_SysName[a]; end; end else begin maxHeader.iconSysName := 'New File'; @@ -655,14 +656,13 @@ function TMaxSave.getHeaderDirname2: nameArray; result := temp; end; -function TMaxsave.getIcon_SysName : TBytes; +function TMaxsave.getIcon_SysName : iconArray; var iconFile: TIcon_Sys; a : integer; aFile : PFileDetails; - buffer : TBytes; + buffer : iconArray; begin - SetLength(buffer, 34); for a := 0 to files.count - 1 do begin aFile := files.items[a]; if aFile^.name = 'icon.sys' then begin @@ -671,7 +671,7 @@ function TMaxsave.getIcon_SysName : TBytes; end; end; for a := 0 to 33 do begin - buffer[a] := Byte(ShiftJistoAscii(iconFile.titleName[a])); + buffer[a] := ShiftJistoAscii(iconFile.titleName[a]); end; result := buffer; end; @@ -761,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.