2
0
mirror of https://github.com/dpethes/rerogue.git synced 2025-06-07 18:58:32 +02:00

hmt parser: split into main program & parsing unit

--HG--
rename : hmt_parser/hmt_parser.lpr => hmt_parser/hmt_parser.pas
This commit is contained in:
dpethes 2014-10-15 22:54:25 +02:00
parent d65a060e5e
commit b670be61fe
2 changed files with 20 additions and 24 deletions

View File

@ -5,6 +5,7 @@
<PathDelim Value="\"/>
<General>
<Flags>
<SaveOnlyProjectUnits Value="True"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
</Flags>
@ -31,12 +32,17 @@
<FormatVersion Value="1"/>
</local>
</RunParams>
<Units Count="1">
<Units Count="2">
<Unit0>
<Filename Value="hmt_parser.lpr"/>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="parse_hmt"/>
</Unit0>
<Unit1>
<Filename Value="hmt_parser.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="hmt_parser"/>
</Unit0>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -1,7 +1,10 @@
program hmt_parser;
unit hmt_parser;
{$mode objfpc}{$H+}
interface
uses
Classes;
sysutils, Classes;
type
THmtMaterial = record
@ -25,6 +28,10 @@ type
textures: array of THmtTexture;
end;
procedure ParseHmtFile(const fname: string);
//**************************************************************************************************
implementation
function NameToString(name: array of byte): string;
var
@ -82,7 +89,7 @@ begin
//read textures
if hmt.texture_count = 0 then
exit;
f.Seek(hmt.texture_offset + sizeof(hmt.texture_count), TSeekOrigin.soBeginning);
f.Seek(hmt.texture_offset + sizeof(hmt.texture_count), fsFromCurrent);
SetLength(hmt.textures, hmt.texture_count);
for i := 0 to hmt.texture_count - 1 do begin
tex.data_offset := f.ReadDWord;
@ -92,22 +99,5 @@ begin
f.Free;
end;
var
fname: string;
begin
if ParamCount < 1 then begin
writeln ('no input file specified');
exit;
end;
fname := ParamStr(1);
writeln('parsing file: ', fname);
try
ParseHmtFile(fname);
except
writeln('parsing failed!');
end;
writeln('done.');
end.