diff --git a/maxFormat.pas b/maxFormat.pas index 156d4e7..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 @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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 @@ -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; @@ -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. @@ -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); @@ -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; @@ -972,4 +980,3 @@ function TMaxSave.getFileNameforFile(itemNum : integer): nameArray; end; end. - \ No newline at end of file