mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
srlヘッダからA9 オーバレイの未検証サイズを表示するWinツール
Delphi6 用プロジェクト git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@584 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
2c40d3da3b
commit
0a8fc3efdc
35
build/tools/A9Ovl_Chk/a9ovlchk.cfg
Normal file
35
build/tools/A9Ovl_Chk/a9ovlchk.cfg
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
-$A8
|
||||||
|
-$B-
|
||||||
|
-$C+
|
||||||
|
-$D+
|
||||||
|
-$E-
|
||||||
|
-$F-
|
||||||
|
-$G+
|
||||||
|
-$H+
|
||||||
|
-$I+
|
||||||
|
-$J-
|
||||||
|
-$K-
|
||||||
|
-$L+
|
||||||
|
-$M-
|
||||||
|
-$N+
|
||||||
|
-$O+
|
||||||
|
-$P+
|
||||||
|
-$Q-
|
||||||
|
-$R-
|
||||||
|
-$S-
|
||||||
|
-$T-
|
||||||
|
-$U-
|
||||||
|
-$V+
|
||||||
|
-$W-
|
||||||
|
-$X+
|
||||||
|
-$YD
|
||||||
|
-$Z1
|
||||||
|
-cg
|
||||||
|
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||||
|
-H+
|
||||||
|
-W+
|
||||||
|
-M
|
||||||
|
-$M16384,1048576
|
||||||
|
-K$00400000
|
||||||
|
-LE"c:\program files\borland\delphi6\Projects\Bpl"
|
||||||
|
-LN"c:\program files\borland\delphi6\Projects\Bpl"
|
||||||
87
build/tools/A9Ovl_Chk/a9ovlchk.dof
Normal file
87
build/tools/A9Ovl_Chk/a9ovlchk.dof
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
[FileVersion]
|
||||||
|
Version=6.0
|
||||||
|
[Compiler]
|
||||||
|
A=8
|
||||||
|
B=0
|
||||||
|
C=1
|
||||||
|
D=1
|
||||||
|
E=0
|
||||||
|
F=0
|
||||||
|
G=1
|
||||||
|
H=1
|
||||||
|
I=1
|
||||||
|
J=0
|
||||||
|
K=0
|
||||||
|
L=1
|
||||||
|
M=0
|
||||||
|
N=1
|
||||||
|
O=1
|
||||||
|
P=1
|
||||||
|
Q=0
|
||||||
|
R=0
|
||||||
|
S=0
|
||||||
|
T=0
|
||||||
|
U=0
|
||||||
|
V=1
|
||||||
|
W=0
|
||||||
|
X=1
|
||||||
|
Y=1
|
||||||
|
Z=1
|
||||||
|
ShowHints=1
|
||||||
|
ShowWarnings=1
|
||||||
|
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||||
|
[Linker]
|
||||||
|
MapFile=0
|
||||||
|
OutputObjs=0
|
||||||
|
ConsoleApp=1
|
||||||
|
DebugInfo=0
|
||||||
|
RemoteSymbols=0
|
||||||
|
MinStackSize=16384
|
||||||
|
MaxStackSize=1048576
|
||||||
|
ImageBase=4194304
|
||||||
|
ExeDescription=
|
||||||
|
[Directories]
|
||||||
|
OutputDir=
|
||||||
|
UnitOutputDir=
|
||||||
|
PackageDLLOutputDir=
|
||||||
|
PackageDCPOutputDir=
|
||||||
|
SearchPath=
|
||||||
|
Packages=
|
||||||
|
Conditionals=
|
||||||
|
DebugSourceDirs=
|
||||||
|
UsePackages=0
|
||||||
|
[Parameters]
|
||||||
|
RunParams=
|
||||||
|
HostApplication=
|
||||||
|
Launcher=
|
||||||
|
UseLauncher=0
|
||||||
|
DebugCWD=
|
||||||
|
[Language]
|
||||||
|
ActiveLang=
|
||||||
|
ProjectLang=
|
||||||
|
RootDir=
|
||||||
|
[Version Info]
|
||||||
|
IncludeVerInfo=0
|
||||||
|
AutoIncBuild=0
|
||||||
|
MajorVer=1
|
||||||
|
MinorVer=0
|
||||||
|
Release=0
|
||||||
|
Build=0
|
||||||
|
Debug=0
|
||||||
|
PreRelease=0
|
||||||
|
Special=0
|
||||||
|
Private=0
|
||||||
|
DLL=0
|
||||||
|
Locale=1041
|
||||||
|
CodePage=932
|
||||||
|
[Version Info Keys]
|
||||||
|
CompanyName=
|
||||||
|
FileDescription=
|
||||||
|
FileVersion=1.0.0.0
|
||||||
|
InternalName=
|
||||||
|
LegalCopyright=
|
||||||
|
LegalTrademarks=
|
||||||
|
OriginalFilename=
|
||||||
|
ProductName=
|
||||||
|
ProductVersion=1.0.0.0
|
||||||
|
Comments=
|
||||||
13
build/tools/A9Ovl_Chk/a9ovlchk.dpr
Normal file
13
build/tools/A9Ovl_Chk/a9ovlchk.dpr
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
program a9ovlchk;
|
||||||
|
|
||||||
|
uses
|
||||||
|
Forms,
|
||||||
|
main in 'main.pas' {Form1};
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
|
||||||
|
begin
|
||||||
|
Application.Initialize;
|
||||||
|
Application.CreateForm(TForm1, Form1);
|
||||||
|
Application.Run;
|
||||||
|
end.
|
||||||
BIN
build/tools/A9Ovl_Chk/a9ovlchk.exe
Executable file
BIN
build/tools/A9Ovl_Chk/a9ovlchk.exe
Executable file
Binary file not shown.
BIN
build/tools/A9Ovl_Chk/a9ovlchk.res
Normal file
BIN
build/tools/A9Ovl_Chk/a9ovlchk.res
Normal file
Binary file not shown.
13
build/tools/A9Ovl_Chk/a9ovlchk.~dpr
Normal file
13
build/tools/A9Ovl_Chk/a9ovlchk.~dpr
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
program a9ovlchk;
|
||||||
|
|
||||||
|
uses
|
||||||
|
Forms,
|
||||||
|
main in 'main.pas' {Form1};
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
|
||||||
|
begin
|
||||||
|
Application.Initialize;
|
||||||
|
Application.CreateForm(TForm1, Form1);
|
||||||
|
Application.Run;
|
||||||
|
end.
|
||||||
BIN
build/tools/A9Ovl_Chk/main.dcu
Normal file
BIN
build/tools/A9Ovl_Chk/main.dcu
Normal file
Binary file not shown.
BIN
build/tools/A9Ovl_Chk/main.ddp
Normal file
BIN
build/tools/A9Ovl_Chk/main.ddp
Normal file
Binary file not shown.
86
build/tools/A9Ovl_Chk/main.dfm
Normal file
86
build/tools/A9Ovl_Chk/main.dfm
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
object Form1: TForm1
|
||||||
|
Left = 310
|
||||||
|
Top = 126
|
||||||
|
Width = 574
|
||||||
|
Height = 259
|
||||||
|
Caption = 'Form1'
|
||||||
|
Color = clBtnFace
|
||||||
|
Font.Charset = SHIFTJIS_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -12
|
||||||
|
Font.Name = #65325#65331' '#65328#12468#12471#12483#12463
|
||||||
|
Font.Style = []
|
||||||
|
OldCreateOrder = False
|
||||||
|
OnCreate = FormCreate
|
||||||
|
PixelsPerInch = 96
|
||||||
|
TextHeight = 12
|
||||||
|
object ListBox_log: TListBox
|
||||||
|
Left = 16
|
||||||
|
Top = 16
|
||||||
|
Width = 353
|
||||||
|
Height = 129
|
||||||
|
ItemHeight = 12
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object Button1: TButton
|
||||||
|
Left = 48
|
||||||
|
Top = 168
|
||||||
|
Width = 75
|
||||||
|
Height = 25
|
||||||
|
Caption = #38283#22987
|
||||||
|
TabOrder = 1
|
||||||
|
OnClick = Button1Click
|
||||||
|
end
|
||||||
|
object DriveBox: TDriveComboBox
|
||||||
|
Left = 392
|
||||||
|
Top = 40
|
||||||
|
Width = 145
|
||||||
|
Height = 18
|
||||||
|
TabOrder = 2
|
||||||
|
OnChange = DriveBoxChange
|
||||||
|
end
|
||||||
|
object DirListBox: TDirectoryListBox
|
||||||
|
Left = 392
|
||||||
|
Top = 64
|
||||||
|
Width = 145
|
||||||
|
Height = 97
|
||||||
|
ItemHeight = 16
|
||||||
|
TabOrder = 3
|
||||||
|
OnChange = DirListBoxChange
|
||||||
|
end
|
||||||
|
object StatusBar: TStatusBar
|
||||||
|
Left = 0
|
||||||
|
Top = 210
|
||||||
|
Width = 566
|
||||||
|
Height = 19
|
||||||
|
Panels = <>
|
||||||
|
SimplePanel = True
|
||||||
|
end
|
||||||
|
object StaticText1: TStaticText
|
||||||
|
Left = 184
|
||||||
|
Top = 176
|
||||||
|
Width = 283
|
||||||
|
Height = 16
|
||||||
|
Caption = #65288#27880#24847#65289#12525#12464#12399#23455#34892#12501#12449#12452#12523#12398#12354#12427#12487#12451#12524#12463#12488#12522#12395#20986#12375#12414#12377
|
||||||
|
TabOrder = 5
|
||||||
|
end
|
||||||
|
object StaticText2: TStaticText
|
||||||
|
Left = 416
|
||||||
|
Top = 16
|
||||||
|
Width = 95
|
||||||
|
Height = 16
|
||||||
|
BevelInner = bvLowered
|
||||||
|
BevelOuter = bvRaised
|
||||||
|
BorderStyle = sbsSingle
|
||||||
|
Caption = 'srl'#12288#12398#22580#25152#12434#25351#23450
|
||||||
|
TabOrder = 6
|
||||||
|
end
|
||||||
|
object StaticText3: TStaticText
|
||||||
|
Left = 184
|
||||||
|
Top = 192
|
||||||
|
Width = 254
|
||||||
|
Height = 16
|
||||||
|
Caption = #65288#27880#24847#65298#65289#25351#23450#12487#12451#12524#12463#12488#12522#12395'srl'#20197#22806#12399#32622#12363#12394#12356#12371#12392
|
||||||
|
TabOrder = 7
|
||||||
|
end
|
||||||
|
end
|
||||||
213
build/tools/A9Ovl_Chk/main.pas
Normal file
213
build/tools/A9Ovl_Chk/main.pas
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
unit main;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
|
Dialogs, StdCtrls, FileCtrl, ComCtrls, ShellCtrls;
|
||||||
|
|
||||||
|
type
|
||||||
|
TForm1 = class(TForm)
|
||||||
|
ListBox_log: TListBox;
|
||||||
|
Button1: TButton;
|
||||||
|
DriveBox: TDriveComboBox;
|
||||||
|
DirListBox: TDirectoryListBox;
|
||||||
|
StatusBar: TStatusBar;
|
||||||
|
StaticText1: TStaticText;
|
||||||
|
StaticText2: TStaticText;
|
||||||
|
StaticText3: TStaticText;
|
||||||
|
procedure Button1Click(Sender: TObject);
|
||||||
|
procedure DriveBoxChange(Sender: TObject);
|
||||||
|
procedure DirListBoxChange(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
private
|
||||||
|
{ Private 宣言 }
|
||||||
|
function CheckSrlHeader:integer;
|
||||||
|
public
|
||||||
|
{ Public 宣言 }
|
||||||
|
end;
|
||||||
|
|
||||||
|
TRom_Fat = record
|
||||||
|
top:Longword; // file region start
|
||||||
|
bottom:Longword; // end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TRomh = record
|
||||||
|
title: array[1..12] of Char;
|
||||||
|
game_code: array[1..4] of Byte;
|
||||||
|
//0x10
|
||||||
|
dumy:array[1..16]of Byte;//ツールで使用しない部分
|
||||||
|
|
||||||
|
//
|
||||||
|
// 0x020 for Static modules (Section:B)
|
||||||
|
//ARM9
|
||||||
|
A9_main_rom_offset: Longword; // ROM offset
|
||||||
|
A9_main_entry_address: Longword; // Entry point
|
||||||
|
A9_main_ram_address: Longword; // RAM address
|
||||||
|
A9_main_size: Longword; // Module size
|
||||||
|
|
||||||
|
//ARM7
|
||||||
|
A7_main_rom_offset: Longword; // ROM offset
|
||||||
|
A7_main_entry_address: Longword; // Entry point
|
||||||
|
A7_main_ram_address: Longword; // RAM address
|
||||||
|
A7_main_size: Longword; // Module size
|
||||||
|
|
||||||
|
//0x40
|
||||||
|
dumy2:array[1..8] of Byte;//ツールで使用しない部分
|
||||||
|
|
||||||
|
//
|
||||||
|
// 0x048 for File Allocation Table[FAT] (Section:E)
|
||||||
|
//
|
||||||
|
fat_offset: Longword; // ROM offset
|
||||||
|
fat_size:Longword; // Table size
|
||||||
|
|
||||||
|
//
|
||||||
|
// 0x050 for Overlay Tables[OVT] (Section:D)
|
||||||
|
//
|
||||||
|
// ARM9
|
||||||
|
main_ovt_offset: Longword; // ROM offset
|
||||||
|
main_ovt_size:Longword; // Table size
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Form1: TForm1;
|
||||||
|
SrlDir: String;//srlファイルの存在するディレクトリ名
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
function TForm1.CheckSrlHeader: integer;
|
||||||
|
var
|
||||||
|
Rec: TSearchRec;
|
||||||
|
s: String;
|
||||||
|
i,n,Count: integer;
|
||||||
|
fsrl: file;
|
||||||
|
romh: TRomh;
|
||||||
|
noc_size,noc_sectors,size,sectors,nums,max_sectors,total_sectors: integer;
|
||||||
|
fat: TRom_Fat;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{$I-}
|
||||||
|
Count :=0;
|
||||||
|
//指定ディレクトリからファイルを取り出す
|
||||||
|
// ** 内容で判別しないので違うファイル置かないよう注意 **
|
||||||
|
if FindFirst(SrlDir + '*.*', faAnyFile, Rec) = 0 then
|
||||||
|
try
|
||||||
|
repeat
|
||||||
|
//フォルダやカレントディレクトリや親ディレクトリは対象外で
|
||||||
|
if not((Rec.Attr and faDirectory > 0)) and
|
||||||
|
(Rec.Name <> '.') and (Rec.Name <> '..') then
|
||||||
|
begin
|
||||||
|
Inc(Count);
|
||||||
|
ListBox_log.Items.Add('file: '+Rec.Name);
|
||||||
|
AssignFile (fsrl,SrlDir+Rec.Name);
|
||||||
|
FileMode := fmOpenRead;//リード専用指定
|
||||||
|
Reset(fsrl,1);//ファイル開く
|
||||||
|
if IOResult = 0 then begin
|
||||||
|
BlockRead(fsrl,romh,SizeOf(TRomh),n);
|
||||||
|
if SizeOf(TRomh) <> n then
|
||||||
|
s := ' size too small'
|
||||||
|
else begin
|
||||||
|
SetLength(s,12);
|
||||||
|
for i:=1 to 12 do begin
|
||||||
|
if romh.title[i] = char(0) then break;
|
||||||
|
s[i] := romh.title[i];
|
||||||
|
end;
|
||||||
|
if i<12 then Setlength(s,i);
|
||||||
|
ListBox_log.Items.Add('title = '+s);
|
||||||
|
|
||||||
|
//オーバレイチェック
|
||||||
|
if romh.main_ovt_size >0 then begin
|
||||||
|
//DHT_OVERLAY_MAX (512*1024)
|
||||||
|
total_sectors := 0;
|
||||||
|
nums := romh.main_ovt_size div 32;// 32 = Nitro用(Twlは33)
|
||||||
|
noc_size :=0;
|
||||||
|
noc_sectors := 0;
|
||||||
|
for i := 0 to nums-1 do begin
|
||||||
|
seek( fsrl,romh.fat_offset+sizeof(TRom_Fat)*i);
|
||||||
|
BlockRead( fsrl,fat,sizeof(fat),n);
|
||||||
|
size := fat.bottom - fat.top;
|
||||||
|
if total_sectors >= 1024 then begin//MAX超えたファイルは検証外に加算
|
||||||
|
s := 'OL['+inttostr(i)+'] $'+ inttohex(fat.top,8)+' - $'+
|
||||||
|
inttohex(fat.bottom,8)+' :size '+ inttostr(size);
|
||||||
|
noc_size := noc_size + size;
|
||||||
|
noc_sectors := noc_sectors + ((size+511) and $fffffe00) div 512;
|
||||||
|
next;
|
||||||
|
end;
|
||||||
|
//max_sectors = (DHT_OVERLAY_MAX/512 - total_sectors) / (nums-i);
|
||||||
|
max_sectors := (1024 - total_sectors) div (nums-i);
|
||||||
|
if n <> sizeof(fat) then begin
|
||||||
|
s := s+'Cannot read fat id='+ inttostr(i);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
sectors := ( ((fat.bottom+511) and $fffffe00)- fat.top) div 512;
|
||||||
|
if sectors > max_sectors then begin
|
||||||
|
size := size - max_sectors*512;//検証されない残りサイズ
|
||||||
|
s := 'OL['+inttostr(i)+'] $'+ inttohex(fat.top+max_sectors*512,8)+' - $'+
|
||||||
|
inttohex(fat.bottom,8)+' :size '+ inttostr(size);
|
||||||
|
ListBox_log.Items.Add(s);
|
||||||
|
noc_size := noc_size+size;
|
||||||
|
noc_sectors := noc_sectors + (max_sectors-sectors);
|
||||||
|
end;
|
||||||
|
total_sectors := total_sectors + sectors;
|
||||||
|
end;
|
||||||
|
if i = nums then begin
|
||||||
|
ListBox_log.Items.Add('total sectors = '+inttostr(total_sectors));
|
||||||
|
ListBox_log.Items.Add('no check sectors = '+inttostr(noc_sectors));
|
||||||
|
ListBox_log.Items.Add('no check size = '+inttostr(noc_size));
|
||||||
|
if noc_size > 0 then s:= 'NG'
|
||||||
|
else s:= 'OK';
|
||||||
|
end;
|
||||||
|
end else s := 'no OVL';
|
||||||
|
end;
|
||||||
|
end else s := ' Open Error';
|
||||||
|
CloseFile(fsrl);
|
||||||
|
ListBox_log.Items.Add(s);
|
||||||
|
|
||||||
|
end;
|
||||||
|
until (FindNext(Rec) <> 0);
|
||||||
|
finally
|
||||||
|
FindClose(Rec);
|
||||||
|
end;
|
||||||
|
{$I+}
|
||||||
|
Result :=Count;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$R *.dfm}
|
||||||
|
|
||||||
|
procedure TForm1.Button1Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
FileCount :integer;
|
||||||
|
begin
|
||||||
|
ListBox_log.Clear;
|
||||||
|
//指定ディレクトリのsrlファイルをチェック
|
||||||
|
FileCount := CheckSrlHeader;
|
||||||
|
if FileCount>0 then begin
|
||||||
|
ListBox_log.Items.Add(' ------------------------ ');
|
||||||
|
ListBox_log.Items.Add('total '+inttostr(FileCount)+' files');
|
||||||
|
end else
|
||||||
|
ListBox_log.Items.Add(' file not ditect');
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
procedure TForm1.DriveBoxChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DirListBox.Drive := DriveBox.Drive;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.DirListBoxChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SrlDir := IncludeTrailingPathDelimiter(DirListBox.Directory);
|
||||||
|
StatusBar.SimpleText := '[Target Dir] ' + DirListBox.Directory;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
//イベント利用してSrlDirNameとステータスバーの設定
|
||||||
|
DirListBox.Drive := DriveBox.Drive;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
BIN
build/tools/A9Ovl_Chk/main.~ddp
Normal file
BIN
build/tools/A9Ovl_Chk/main.~ddp
Normal file
Binary file not shown.
86
build/tools/A9Ovl_Chk/main.~dfm
Normal file
86
build/tools/A9Ovl_Chk/main.~dfm
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
object Form1: TForm1
|
||||||
|
Left = 310
|
||||||
|
Top = 126
|
||||||
|
Width = 574
|
||||||
|
Height = 259
|
||||||
|
Caption = 'Form1'
|
||||||
|
Color = clBtnFace
|
||||||
|
Font.Charset = SHIFTJIS_CHARSET
|
||||||
|
Font.Color = clWindowText
|
||||||
|
Font.Height = -12
|
||||||
|
Font.Name = #65325#65331' '#65328#12468#12471#12483#12463
|
||||||
|
Font.Style = []
|
||||||
|
OldCreateOrder = False
|
||||||
|
OnCreate = FormCreate
|
||||||
|
PixelsPerInch = 96
|
||||||
|
TextHeight = 12
|
||||||
|
object ListBox_log: TListBox
|
||||||
|
Left = 16
|
||||||
|
Top = 16
|
||||||
|
Width = 353
|
||||||
|
Height = 129
|
||||||
|
ItemHeight = 12
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object Button1: TButton
|
||||||
|
Left = 48
|
||||||
|
Top = 168
|
||||||
|
Width = 75
|
||||||
|
Height = 25
|
||||||
|
Caption = #38283#22987
|
||||||
|
TabOrder = 1
|
||||||
|
OnClick = Button1Click
|
||||||
|
end
|
||||||
|
object DriveBox: TDriveComboBox
|
||||||
|
Left = 392
|
||||||
|
Top = 40
|
||||||
|
Width = 145
|
||||||
|
Height = 18
|
||||||
|
TabOrder = 2
|
||||||
|
OnChange = DriveBoxChange
|
||||||
|
end
|
||||||
|
object DirListBox: TDirectoryListBox
|
||||||
|
Left = 392
|
||||||
|
Top = 64
|
||||||
|
Width = 145
|
||||||
|
Height = 97
|
||||||
|
ItemHeight = 16
|
||||||
|
TabOrder = 3
|
||||||
|
OnChange = DirListBoxChange
|
||||||
|
end
|
||||||
|
object StatusBar: TStatusBar
|
||||||
|
Left = 0
|
||||||
|
Top = 210
|
||||||
|
Width = 566
|
||||||
|
Height = 19
|
||||||
|
Panels = <>
|
||||||
|
SimplePanel = True
|
||||||
|
end
|
||||||
|
object StaticText1: TStaticText
|
||||||
|
Left = 184
|
||||||
|
Top = 176
|
||||||
|
Width = 283
|
||||||
|
Height = 16
|
||||||
|
Caption = #65288#27880#24847#65289#12525#12464#12399#23455#34892#12501#12449#12452#12523#12398#12354#12427#12487#12451#12524#12463#12488#12522#12395#20986#12375#12414#12377
|
||||||
|
TabOrder = 5
|
||||||
|
end
|
||||||
|
object StaticText2: TStaticText
|
||||||
|
Left = 416
|
||||||
|
Top = 16
|
||||||
|
Width = 95
|
||||||
|
Height = 16
|
||||||
|
BevelInner = bvLowered
|
||||||
|
BevelOuter = bvRaised
|
||||||
|
BorderStyle = sbsSingle
|
||||||
|
Caption = 'srl'#12288#12398#22580#25152#12434#25351#23450
|
||||||
|
TabOrder = 6
|
||||||
|
end
|
||||||
|
object StaticText3: TStaticText
|
||||||
|
Left = 184
|
||||||
|
Top = 192
|
||||||
|
Width = 254
|
||||||
|
Height = 16
|
||||||
|
Caption = #65288#27880#24847#65298#65289#25351#23450#12487#12451#12524#12463#12488#12522#12395'srl'#20197#22806#12399#32622#12363#12394#12356#12371#12392
|
||||||
|
TabOrder = 7
|
||||||
|
end
|
||||||
|
end
|
||||||
213
build/tools/A9Ovl_Chk/main.~pas
Normal file
213
build/tools/A9Ovl_Chk/main.~pas
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
unit main;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
|
Dialogs, StdCtrls, FileCtrl, ComCtrls, ShellCtrls;
|
||||||
|
|
||||||
|
type
|
||||||
|
TForm1 = class(TForm)
|
||||||
|
ListBox_log: TListBox;
|
||||||
|
Button1: TButton;
|
||||||
|
DriveBox: TDriveComboBox;
|
||||||
|
DirListBox: TDirectoryListBox;
|
||||||
|
StatusBar: TStatusBar;
|
||||||
|
StaticText1: TStaticText;
|
||||||
|
StaticText2: TStaticText;
|
||||||
|
StaticText3: TStaticText;
|
||||||
|
procedure Button1Click(Sender: TObject);
|
||||||
|
procedure DriveBoxChange(Sender: TObject);
|
||||||
|
procedure DirListBoxChange(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
private
|
||||||
|
{ Private 宣言 }
|
||||||
|
function CheckSrlHeader:integer;
|
||||||
|
public
|
||||||
|
{ Public 宣言 }
|
||||||
|
end;
|
||||||
|
|
||||||
|
TRom_Fat = record
|
||||||
|
top:Longword; // file region start
|
||||||
|
bottom:Longword; // end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TRomh = record
|
||||||
|
title: array[1..12] of Char;
|
||||||
|
game_code: array[1..4] of Byte;
|
||||||
|
//0x10
|
||||||
|
dumy:array[1..16]of Byte;//ツールで使用しない部分
|
||||||
|
|
||||||
|
//
|
||||||
|
// 0x020 for Static modules (Section:B)
|
||||||
|
//ARM9
|
||||||
|
A9_main_rom_offset: Longword; // ROM offset
|
||||||
|
A9_main_entry_address: Longword; // Entry point
|
||||||
|
A9_main_ram_address: Longword; // RAM address
|
||||||
|
A9_main_size: Longword; // Module size
|
||||||
|
|
||||||
|
//ARM7
|
||||||
|
A7_main_rom_offset: Longword; // ROM offset
|
||||||
|
A7_main_entry_address: Longword; // Entry point
|
||||||
|
A7_main_ram_address: Longword; // RAM address
|
||||||
|
A7_main_size: Longword; // Module size
|
||||||
|
|
||||||
|
//0x40
|
||||||
|
dumy2:array[1..8] of Byte;//ツールで使用しない部分
|
||||||
|
|
||||||
|
//
|
||||||
|
// 0x048 for File Allocation Table[FAT] (Section:E)
|
||||||
|
//
|
||||||
|
fat_offset: Longword; // ROM offset
|
||||||
|
fat_size:Longword; // Table size
|
||||||
|
|
||||||
|
//
|
||||||
|
// 0x050 for Overlay Tables[OVT] (Section:D)
|
||||||
|
//
|
||||||
|
// ARM9
|
||||||
|
main_ovt_offset: Longword; // ROM offset
|
||||||
|
main_ovt_size:Longword; // Table size
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Form1: TForm1;
|
||||||
|
SrlDir: String;//srlファイルの存在するディレクトリ名
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
function TForm1.CheckSrlHeader: integer;
|
||||||
|
var
|
||||||
|
Rec: TSearchRec;
|
||||||
|
s: String;
|
||||||
|
i,n,Count: integer;
|
||||||
|
fsrl: file;
|
||||||
|
romh: TRomh;
|
||||||
|
noc_size,noc_sectors,size,sectors,nums,max_sectors,total_sectors: integer;
|
||||||
|
fat: TRom_Fat;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{$I-}
|
||||||
|
Count :=0;
|
||||||
|
//指定ディレクトリからファイルを取り出す
|
||||||
|
// ** 内容で判別しないので違うファイル置かないよう注意 **
|
||||||
|
if FindFirst(SrlDir + '*.*', faAnyFile, Rec) = 0 then
|
||||||
|
try
|
||||||
|
repeat
|
||||||
|
//フォルダやカレントディレクトリや親ディレクトリは対象外で
|
||||||
|
if not((Rec.Attr and faDirectory > 0)) and
|
||||||
|
(Rec.Name <> '.') and (Rec.Name <> '..') then
|
||||||
|
begin
|
||||||
|
Inc(Count);
|
||||||
|
ListBox_log.Items.Add('file: '+Rec.Name);
|
||||||
|
AssignFile (fsrl,SrlDir+Rec.Name);
|
||||||
|
FileMode := fmOpenRead;//リード専用指定
|
||||||
|
Reset(fsrl,1);//ファイル開く
|
||||||
|
if IOResult = 0 then begin
|
||||||
|
BlockRead(fsrl,romh,SizeOf(TRomh),n);
|
||||||
|
if SizeOf(TRomh) <> n then
|
||||||
|
s := ' size too small'
|
||||||
|
else begin
|
||||||
|
SetLength(s,12);
|
||||||
|
for i:=1 to 12 do begin
|
||||||
|
if romh.title[i] = char(0) then break;
|
||||||
|
s[i] := romh.title[i];
|
||||||
|
end;
|
||||||
|
if i<12 then Setlength(s,i);
|
||||||
|
ListBox_log.Items.Add('title = '+s);
|
||||||
|
|
||||||
|
//オーバレイチェック
|
||||||
|
if romh.main_ovt_size >0 then begin
|
||||||
|
//DHT_OVERLAY_MAX (512*1024)
|
||||||
|
total_sectors := 0;
|
||||||
|
nums := romh.main_ovt_size div 32;// 32 = Nitro用(Twlは33)
|
||||||
|
noc_size :=0;
|
||||||
|
noc_sectors := 0;
|
||||||
|
for i := 0 to nums-1 do begin
|
||||||
|
seek( fsrl,romh.fat_offset+sizeof(TRom_Fat)*i);
|
||||||
|
BlockRead( fsrl,fat,sizeof(fat),n);
|
||||||
|
size := fat.bottom - fat.top;
|
||||||
|
if total_sectors >= 1024 then begin//MAX超えたファイルは検証外に加算
|
||||||
|
s := 'OL['+inttostr(i)+'] $'+ inttohex(fat.top,8)+' - $'+
|
||||||
|
inttohex(fat.bottom,8)+' :size '+ inttostr(size);
|
||||||
|
noc_size := noc_size + size;
|
||||||
|
noc_sectors := noc_sectors + ((size+511) and $fffffe00) div 512;
|
||||||
|
next;
|
||||||
|
end;
|
||||||
|
//max_sectors = (DHT_OVERLAY_MAX/512 - total_sectors) / (nums-i);
|
||||||
|
max_sectors := (1024 - total_sectors) div (nums-i);
|
||||||
|
if n <> sizeof(fat) then begin
|
||||||
|
s := s+'Cannot read fat id='+ inttostr(i);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
sectors := ( ((fat.bottom+511) and $fffffe00)- fat.top) div 512;
|
||||||
|
if sectors > max_sectors then begin
|
||||||
|
size := size - max_sectors*512;//検証されない残りサイズ
|
||||||
|
s := 'OL['+inttostr(i)+'] $'+ inttohex(fat.top+max_sectors*512,8)+' - $'+
|
||||||
|
inttohex(fat.bottom,8)+' :size '+ inttostr(size);
|
||||||
|
ListBox_log.Items.Add(s);
|
||||||
|
noc_size := noc_size+size;
|
||||||
|
noc_sectors := noc_sectors + (max_sectors-sectors);
|
||||||
|
end;
|
||||||
|
total_sectors := total_sectors + sectors;
|
||||||
|
end;
|
||||||
|
if i = nums then begin
|
||||||
|
ListBox_log.Items.Add('total sectors = '+inttostr(total_sectors));
|
||||||
|
ListBox_log.Items.Add('no check sectors = '+inttostr(noc_sectors));
|
||||||
|
ListBox_log.Items.Add('no check size = '+inttostr(noc_size));
|
||||||
|
if noc_size > 0 then s:= 'NG'
|
||||||
|
else s:= 'OK';
|
||||||
|
end;
|
||||||
|
end else s := 'no OVL';
|
||||||
|
end;
|
||||||
|
end else s := ' Open Error';
|
||||||
|
CloseFile(fsrl);
|
||||||
|
ListBox_log.Items.Add(s);
|
||||||
|
|
||||||
|
end;
|
||||||
|
until (FindNext(Rec) <> 0);
|
||||||
|
finally
|
||||||
|
FindClose(Rec);
|
||||||
|
end;
|
||||||
|
{$I+}
|
||||||
|
Result :=Count;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$R *.dfm}
|
||||||
|
|
||||||
|
procedure TForm1.Button1Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
FileCount :integer;
|
||||||
|
begin
|
||||||
|
ListBox_log.Clear;
|
||||||
|
//指定ディレクトリのsrlファイルをチェック
|
||||||
|
FileCount := CheckSrlHeader;
|
||||||
|
if FileCount>0 then begin
|
||||||
|
ListBox_log.Items.Add(' ------------------------ ');
|
||||||
|
ListBox_log.Items.Add('total '+inttostr(FileCount)+' files');
|
||||||
|
end else
|
||||||
|
ListBox_log.Items.Add(' file not ditect');
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
procedure TForm1.DriveBoxChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
DirListBox.Drive := DriveBox.Drive;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.DirListBoxChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SrlDir := IncludeTrailingPathDelimiter(DirListBox.Directory);
|
||||||
|
StatusBar.SimpleText := '[Target Dir] ' + DirListBox.Directory;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
//イベント利用してSrlDirNameとステータスバーの設定
|
||||||
|
DirListBox.Drive := DriveBox.Drive;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
Loading…
Reference in New Issue
Block a user