MacOS stability fixes. Some code review. Other fixes.
This commit is contained in:
10
tim2view.lpi
10
tim2view.lpi
@@ -21,7 +21,9 @@
|
|||||||
</i18n>
|
</i18n>
|
||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<UseVersionInfo Value="True"/>
|
<UseVersionInfo Value="True"/>
|
||||||
|
<AutoIncrementBuild Value="True"/>
|
||||||
<MajorVersionNr Value="1"/>
|
<MajorVersionNr Value="1"/>
|
||||||
|
<RevisionNr Value="67"/>
|
||||||
<StringTable CompanyName="Lab 313" FileDescription="The best TIMs tool ever!:)" ProductVersion=""/>
|
<StringTable CompanyName="Lab 313" FileDescription="The best TIMs tool ever!:)" ProductVersion=""/>
|
||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
<BuildModes Count="1">
|
<BuildModes Count="1">
|
||||||
@@ -128,7 +130,15 @@
|
|||||||
<UseAnsiStrings Value="False"/>
|
<UseAnsiStrings Value="False"/>
|
||||||
</SyntaxOptions>
|
</SyntaxOptions>
|
||||||
</Parsing>
|
</Parsing>
|
||||||
|
<CodeGeneration>
|
||||||
|
<SmartLinkUnit Value="True"/>
|
||||||
|
<RelocatableUnit Value="True"/>
|
||||||
|
</CodeGeneration>
|
||||||
<Linking>
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<DebugInfoType Value="dsDwarf2Set"/>
|
||||||
|
</Debugging>
|
||||||
|
<LinkSmart Value="True"/>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
<GraphicApplication Value="True"/>
|
<GraphicApplication Value="True"/>
|
||||||
|
|||||||
58
tim2view.lps
58
tim2view.lps
@@ -9,12 +9,11 @@
|
|||||||
<Filename Value="tim2view.lpr"/>
|
<Filename Value="tim2view.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="tim2view"/>
|
<UnitName Value="tim2view"/>
|
||||||
<IsVisibleTab Value="True"/>
|
<EditorIndex Value="5"/>
|
||||||
<EditorIndex Value="3"/>
|
|
||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="1"/>
|
<TopLine Value="1"/>
|
||||||
<CursorPos X="46" Y="9"/>
|
<CursorPos X="52" Y="16"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
@@ -24,11 +23,12 @@
|
|||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="umain"/>
|
<UnitName Value="umain"/>
|
||||||
|
<IsVisibleTab Value="True"/>
|
||||||
<EditorIndex Value="0"/>
|
<EditorIndex Value="0"/>
|
||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="108"/>
|
<TopLine Value="242"/>
|
||||||
<CursorPos X="65" Y="113"/>
|
<CursorPos X="87" Y="265"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
<LoadedDesigner Value="True"/>
|
<LoadedDesigner Value="True"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
@@ -36,32 +36,34 @@
|
|||||||
<Filename Value="edc.pas"/>
|
<Filename Value="edc.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="edc"/>
|
<UnitName Value="edc"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
</Unit2>
|
</Unit2>
|
||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="ecc.pas"/>
|
<Filename Value="ecc.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="ecc"/>
|
<UnitName Value="ecc"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
</Unit3>
|
</Unit3>
|
||||||
<Unit4>
|
<Unit4>
|
||||||
<Filename Value="ucommon.pas"/>
|
<Filename Value="ucommon.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="ucommon"/>
|
<UnitName Value="ucommon"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="1"/>
|
<TopLine Value="1"/>
|
||||||
<CursorPos X="35" Y="6"/>
|
<CursorPos X="56" Y="12"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
</Unit4>
|
</Unit4>
|
||||||
<Unit5>
|
<Unit5>
|
||||||
<Filename Value="utim.pas"/>
|
<Filename Value="utim.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="utim"/>
|
<UnitName Value="utim"/>
|
||||||
<EditorIndex Value="2"/>
|
<EditorIndex Value="3"/>
|
||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="311"/>
|
<TopLine Value="285"/>
|
||||||
<CursorPos X="7" Y="323"/>
|
<CursorPos X="31" Y="299"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit5>
|
</Unit5>
|
||||||
<Unit6>
|
<Unit6>
|
||||||
@@ -71,7 +73,7 @@
|
|||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="81"/>
|
<TopLine Value="81"/>
|
||||||
<CursorPos X="95" Y="89"/>
|
<CursorPos X="95" Y="89"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
</Unit6>
|
</Unit6>
|
||||||
<Unit7>
|
<Unit7>
|
||||||
<Filename Value="usettings.pas"/>
|
<Filename Value="usettings.pas"/>
|
||||||
@@ -80,50 +82,52 @@
|
|||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="17"/>
|
<TopLine Value="17"/>
|
||||||
<CursorPos X="76" Y="31"/>
|
<CursorPos X="76" Y="31"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
</Unit7>
|
</Unit7>
|
||||||
<Unit8>
|
<Unit8>
|
||||||
<Filename Value="uscanresult.pas"/>
|
<Filename Value="uscanresult.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="uscanresult"/>
|
<UnitName Value="uscanresult"/>
|
||||||
<EditorIndex Value="4"/>
|
<EditorIndex Value="6"/>
|
||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="52"/>
|
<TopLine Value="16"/>
|
||||||
<CursorPos X="64" Y="25"/>
|
<CursorPos X="64" Y="25"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit8>
|
</Unit8>
|
||||||
<Unit9>
|
<Unit9>
|
||||||
<Filename Value="uscanthread.pas"/>
|
<Filename Value="uscanthread.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="uscanthread"/>
|
<UnitName Value="uscanthread"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="2"/>
|
||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="79"/>
|
<TopLine Value="79"/>
|
||||||
<CursorPos X="75" Y="120"/>
|
<CursorPos X="75" Y="120"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit9>
|
</Unit9>
|
||||||
<Unit10>
|
<Unit10>
|
||||||
<Filename Value="ucpucount.pas"/>
|
<Filename Value="ucpucount.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="ucpucount"/>
|
<UnitName Value="ucpucount"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
</Unit10>
|
</Unit10>
|
||||||
<Unit11>
|
<Unit11>
|
||||||
<Filename Value="udrawtim.pas"/>
|
<Filename Value="udrawtim.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="udrawtim"/>
|
<UnitName Value="udrawtim"/>
|
||||||
|
<EditorIndex Value="4"/>
|
||||||
<WindowIndex Value="0"/>
|
<WindowIndex Value="0"/>
|
||||||
<TopLine Value="220"/>
|
<TopLine Value="40"/>
|
||||||
<CursorPos X="30" Y="233"/>
|
<CursorPos X="21" Y="45"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
</Unit11>
|
</Unit11>
|
||||||
<Unit12>
|
<Unit12>
|
||||||
<Filename Value="bgrabitmap\bgrabitmap.pas"/>
|
<Filename Value="bgrabitmap\bgrabitmap.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="BGRABitmap"/>
|
<UnitName Value="BGRABitmap"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
</Unit12>
|
</Unit12>
|
||||||
</Units>
|
</Units>
|
||||||
<General>
|
<General>
|
||||||
|
|||||||
BIN
tim2view.res
BIN
tim2view.res
Binary file not shown.
@@ -3,7 +3,7 @@ unit ucommon;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
const
|
const
|
||||||
cProgramName = 'Tim2View SVN.r65 by [Lab 313] (for ' +
|
cProgramName = 'Tim2View SVN.r67 by [Lab 313] (for ' +
|
||||||
{$IFDEF Linux}'Linux' + {$IFEND}
|
{$IFDEF Linux}'Linux' + {$IFEND}
|
||||||
{$IFDEF Darwin}'Mac OS X' + {$IFEND}
|
{$IFDEF Darwin}'Mac OS X' + {$IFEND}
|
||||||
{$IFDEF Windows}'Windows' + {$IFEND}
|
{$IFDEF Windows}'Windows' + {$IFEND}
|
||||||
@@ -14,7 +14,6 @@ const
|
|||||||
|
|
||||||
cAutoExtractionTimFormat = '%s_%.6d_%.2db' + '.tim';
|
cAutoExtractionTimFormat = '%s_%.6d_%.2db' + '.tim';
|
||||||
cAutoExtractionPngFormat = '%s_%.6d_%.2db_%.2dc' + '.png';
|
cAutoExtractionPngFormat = '%s_%.6d_%.2db_%.2dc' + '.png';
|
||||||
cCLUTGridColsCount = 32;
|
|
||||||
|
|
||||||
sStatusBarScanningFile = 'Scanning File...';
|
sStatusBarScanningFile = 'Scanning File...';
|
||||||
sStatusBarTimsExtracting = 'TIMs Extracting...';
|
sStatusBarTimsExtracting = 'TIMs Extracting...';
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ begin
|
|||||||
if (TIM^.HEAD^.bBPP in [cTIM4NC, cTIM8NC]) then
|
if (TIM^.HEAD^.bBPP in [cTIM4NC, cTIM8NC]) then
|
||||||
begin
|
begin
|
||||||
Randomize;
|
Randomize;
|
||||||
for I := 1 to cRandomPaletteSize do
|
for I := 1 to $100 do
|
||||||
Result^[I - 1] := GetCLUTColor(TIM, CLUT_NUM, I - 1);
|
Result^[I - 1] := GetCLUTColor(TIM, CLUT_NUM, I - 1);
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
@@ -51,7 +51,7 @@ var
|
|||||||
P24: Integer;
|
P24: Integer;
|
||||||
begin
|
begin
|
||||||
New(Result);
|
New(Result);
|
||||||
OFFSET := cTIMHeadSize + GetTIMCLUTSize(TIM) + cIMAGEHeadSize;
|
OFFSET := SizeOf(TTIMHeader) + GetTIMCLUTSize(TIM) + SizeOf(TIMAGEHeader);
|
||||||
RW := GetTimRealWidth(TIM);
|
RW := GetTimRealWidth(TIM);
|
||||||
|
|
||||||
case TIM^.HEAD^.bBPP of
|
case TIM^.HEAD^.bBPP of
|
||||||
@@ -227,7 +227,7 @@ var
|
|||||||
COLS, Colors: Integer;
|
COLS, Colors: Integer;
|
||||||
begin
|
begin
|
||||||
Colors := GetTimColorsCount(TIM);
|
Colors := GetTimColorsCount(TIM);
|
||||||
COLS := Min(Colors, cCLUTGridColsCount);
|
COLS := Min(Colors, 32);
|
||||||
Rect := Grid^.CellRect(X, Y);
|
Rect := Grid^.CellRect(X, Y);
|
||||||
|
|
||||||
if (Y * COLS + X) >= Colors then
|
if (Y * COLS + X) >= Colors then
|
||||||
@@ -277,7 +277,7 @@ var
|
|||||||
X, Y, ROWS, COLS, COLORS: Integer;
|
X, Y, ROWS, COLS, COLORS: Integer;
|
||||||
begin
|
begin
|
||||||
COLORS := GetTimColorsCount(TIM);
|
COLORS := GetTimColorsCount(TIM);
|
||||||
COLS := Min(COLORS, cCLUTGridColsCount);
|
COLS := Min(COLORS, 32);
|
||||||
Grid^.ColCount := COLS;
|
Grid^.ColCount := COLS;
|
||||||
ROWS := Ceil(COLORS / COLS);
|
ROWS := Ceil(COLORS / COLS);
|
||||||
|
|
||||||
|
|||||||
16
umain.lfm
16
umain.lfm
@@ -1,13 +1,14 @@
|
|||||||
object frmMain: TfrmMain
|
object frmMain: TfrmMain
|
||||||
Left = 1017
|
Left = 561
|
||||||
Height = 590
|
Height = 590
|
||||||
Top = 147
|
Top = 213
|
||||||
Width = 780
|
Width = 780
|
||||||
HorzScrollBar.Page = 780
|
HorzScrollBar.Page = 780
|
||||||
|
HorzScrollBar.Range = 489
|
||||||
VertScrollBar.Page = 570
|
VertScrollBar.Page = 570
|
||||||
|
VertScrollBar.Range = 344
|
||||||
ActiveControl = pnlList
|
ActiveControl = pnlList
|
||||||
AllowDropFiles = True
|
AllowDropFiles = True
|
||||||
AutoScroll = True
|
|
||||||
ClientHeight = 570
|
ClientHeight = 570
|
||||||
ClientWidth = 780
|
ClientWidth = 780
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
@@ -580,6 +581,7 @@ object frmMain: TfrmMain
|
|||||||
Top = 28
|
Top = 28
|
||||||
Width = 253
|
Width = 253
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
AutoWidthLastColumn = True
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Caption = '# / 0'
|
Caption = '# / 0'
|
||||||
@@ -598,16 +600,16 @@ object frmMain: TfrmMain
|
|||||||
item
|
item
|
||||||
Alignment = taCenter
|
Alignment = taCenter
|
||||||
Caption = 'CLUTs'
|
Caption = 'CLUTs'
|
||||||
Width = 57
|
Width = 84
|
||||||
end>
|
end>
|
||||||
ColumnClick = False
|
ColumnClick = False
|
||||||
GridLines = True
|
GridLines = True
|
||||||
HideSelection = False
|
|
||||||
OwnerData = True
|
OwnerData = True
|
||||||
PopupMenu = pmList
|
PopupMenu = pmList
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
RowSelect = True
|
RowSelect = True
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
ToolTips = False
|
||||||
ViewStyle = vsReport
|
ViewStyle = vsReport
|
||||||
OnData = lvListData
|
OnData = lvListData
|
||||||
OnSelectItem = lvListSelectItem
|
OnSelectItem = lvListSelectItem
|
||||||
@@ -813,13 +815,11 @@ object frmMain: TfrmMain
|
|||||||
item
|
item
|
||||||
Width = 50
|
Width = 50
|
||||||
end
|
end
|
||||||
item
|
|
||||||
Width = 50
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Width = 50
|
Width = 50
|
||||||
end>
|
end>
|
||||||
SimplePanel = False
|
SimplePanel = False
|
||||||
|
SizeGrip = False
|
||||||
end
|
end
|
||||||
object dlgOpenFile: TOpenDialog
|
object dlgOpenFile: TOpenDialog
|
||||||
Title = 'Please, select File...'
|
Title = 'Please, select File...'
|
||||||
|
|||||||
38
umain.pas
38
umain.pas
@@ -254,6 +254,7 @@ begin
|
|||||||
SetTimsListCount(SelectedScanResult.Count);
|
SetTimsListCount(SelectedScanResult.Count);
|
||||||
|
|
||||||
actReturnFocus.Execute;
|
actReturnFocus.Execute;
|
||||||
|
if lvList.Items.Count = 0 then Exit;
|
||||||
lvList.ItemIndex := 0;
|
lvList.ItemIndex := 0;
|
||||||
lvList.Items[0].Focused := True;
|
lvList.Items[0].Focused := True;
|
||||||
lvList.Items[0].Selected := True;
|
lvList.Items[0].Selected := True;
|
||||||
@@ -261,7 +262,7 @@ end;
|
|||||||
|
|
||||||
procedure TfrmMain.actAboutExecute(Sender: TObject);
|
procedure TfrmMain.actAboutExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Application.MessageBox('Some "about strings" should be here!:)', 'About', MB_OK + MB_ICONINFORMATION);
|
Application.MessageBox(cProgramName + #13 + 'Some "about strings" should be here!:)', 'About', MB_OK + MB_ICONINFORMATION);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.actAssocTimsExecute(Sender: TObject);
|
procedure TfrmMain.actAssocTimsExecute(Sender: TObject);
|
||||||
@@ -646,6 +647,7 @@ end;
|
|||||||
|
|
||||||
function TfrmMain.FGetSelectedScanResult: TScanResult;
|
function TfrmMain.FGetSelectedScanResult: TScanResult;
|
||||||
begin
|
begin
|
||||||
|
if cbbFiles.ItemIndex = -1 then Exit;
|
||||||
Result := ScanResults[cbbFiles.ItemIndex];
|
Result := ScanResults[cbbFiles.ItemIndex];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -902,23 +904,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.SetCLUTListToNoCLUT;
|
procedure TfrmMain.SetCLUTListToNoCLUT;
|
||||||
var
|
|
||||||
I: Integer;
|
|
||||||
begin
|
begin
|
||||||
if cbbCLUT.Items.Count > 0 then
|
cbbCLUT.Items.Clear;
|
||||||
begin
|
|
||||||
cbbCLUT.Items.BeginUpdate;
|
|
||||||
|
|
||||||
for I := 0 to cbbCLUT.Items.Count - 2 do
|
|
||||||
cbbCLUT.Items.Delete(I);
|
|
||||||
|
|
||||||
cbbCLUT.Items[0] := sThisTimHasNoClut;
|
|
||||||
|
|
||||||
cbbCLUT.Items.EndUpdate;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
cbbCLUT.Items.Add(sThisTimHasNoClut);
|
cbbCLUT.Items.Add(sThisTimHasNoClut);
|
||||||
|
|
||||||
cbbCLUT.ItemIndex := 0;
|
cbbCLUT.ItemIndex := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -954,7 +942,6 @@ procedure TfrmMain.ShowTimInfo(ShowInfo: Boolean);
|
|||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
TIM: PTIM;
|
TIM: PTIM;
|
||||||
ScanRes: TScanResult;
|
|
||||||
TimInfo: TTimInfo;
|
TimInfo: TTimInfo;
|
||||||
begin
|
begin
|
||||||
for I := 1 to sbMain.Panels.Count do
|
for I := 1 to sbMain.Panels.Count do
|
||||||
@@ -962,15 +949,16 @@ begin
|
|||||||
|
|
||||||
if not ShowInfo then Exit;
|
if not ShowInfo then Exit;
|
||||||
|
|
||||||
ScanRes := SelectedScanResult;
|
|
||||||
TimInfo := SelectedTimInfo;
|
TimInfo := SelectedTimInfo;
|
||||||
TIM := SelectedTim;
|
TIM := SelectedTim;
|
||||||
|
|
||||||
I := 0;
|
I := 0;
|
||||||
|
|
||||||
sbMain.Panels[I].Text := Format('Position: 0x%x', [TimInfo.Position]);
|
sbMain.Panels[I].Text := Format('Pos: 0x%x', [TimInfo.Position]);
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
||||||
sbMain.Panels[I].Text := Format('Version: %d', [GetTimVersion(TIM)]);
|
sbMain.Panels[I].Text := Format('Ver: %d', [GetTimVersion(TIM)]);
|
||||||
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
||||||
|
sbMain.Panels[I].Text := Format('Good: %s', [TIMIsGoodStr(TIM)]);
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
||||||
|
|
||||||
if TIMHasCLUT(TIM) then
|
if TIMHasCLUT(TIM) then
|
||||||
@@ -978,20 +966,16 @@ begin
|
|||||||
sbMain.Panels[I].Alignment := taRightJustify;
|
sbMain.Panels[I].Alignment := taRightJustify;
|
||||||
sbMain.Panels[I].Text := 'CLUT:';
|
sbMain.Panels[I].Text := 'CLUT:';
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 20; Inc(I);
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 20; Inc(I);
|
||||||
sbMain.Panels[I].Text := Format('VRAM.X: %d', [GetTimClutVRAMX(TIM)]);
|
sbMain.Panels[I].Text := Format('X/Y: %dx%d', [GetTimClutVRAMX(TIM), GetTimClutVRAMY(TIM)]);
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
||||||
sbMain.Panels[I].Text := Format('VRAM.Y: %d', [GetTimClutVRAMY(TIM)]);
|
sbMain.Panels[I].Text := Format('Colors: %d', [GetTimColorsCount(TIM)]);
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
|
||||||
sbMain.Panels[I].Text := Format('Colors/CLUT: %d', [GetTimColorsCount(TIM)]);
|
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
sbMain.Panels[I].Alignment := taRightJustify;
|
sbMain.Panels[I].Alignment := taRightJustify;
|
||||||
sbMain.Panels[I].Text := 'IMAGE:';
|
sbMain.Panels[I].Text := 'IMAGE:';
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 20; Inc(I);
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 20; Inc(I);
|
||||||
sbMain.Panels[I].Text := Format('VRAM.X: %d', [GetTimImageVRAMX(TIM)]);
|
sbMain.Panels[I].Text := Format('X/Y: %dx%d', [GetTimImageVRAMX(TIM), GetTimImageVRAMY(TIM)]);
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
|
||||||
sbMain.Panels[I].Text := Format('VRAM.Y: %d', [GetTimImageVRAMY(TIM)]);
|
|
||||||
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I);
|
||||||
|
|
||||||
FreeTIM(TIM);
|
FreeTIM(TIM);
|
||||||
|
|||||||
52
utim.pas
52
utim.pas
@@ -26,16 +26,6 @@ const
|
|||||||
cTIMNOCLUT = [cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix];
|
cTIMNOCLUT = [cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix];
|
||||||
cTIMBpp = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix];
|
cTIMBpp = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix];
|
||||||
|
|
||||||
cCLUTColorsMax = 1024;
|
|
||||||
cCLUTCountMax = 512;
|
|
||||||
cIMAGEWidthMax = 1024;
|
|
||||||
cIMAGEHeightMax = 1024;
|
|
||||||
cCLUTHeadSize = $0C;
|
|
||||||
cIMAGEHeadSize = $0C;
|
|
||||||
cTIMHeadSize = 8;
|
|
||||||
cRandomPaletteSize = $100;
|
|
||||||
cTIMMaxSize = cTIMHeadSize + cCLUTColorsMax * cCLUTCountMax * 2 + cCLUTHeadSize + cIMAGEWidthMax * cIMAGEHeightMax * 2 + cIMAGEHeadSize;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TTIMHeader = packed record // TIM Header (8 bytes)
|
TTIMHeader = packed record // TIM Header (8 bytes)
|
||||||
bMagic: byte; // $10 (1 byte)
|
bMagic: byte; // $10 (1 byte)
|
||||||
@@ -46,7 +36,6 @@ type
|
|||||||
// variants:
|
// variants:
|
||||||
// [$08, $09, $0A, $0B, $02, $03, $00, $01]
|
// [$08, $09, $0A, $0B, $02, $03, $00, $01]
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PTIMHeader = ^TTIMHeader;
|
PTIMHeader = ^TTIMHeader;
|
||||||
|
|
||||||
type
|
type
|
||||||
@@ -57,7 +46,6 @@ type
|
|||||||
wColorsCount: word; // Number of CLUT Colors (2 bytes)
|
wColorsCount: word; // Number of CLUT Colors (2 bytes)
|
||||||
wClutsCount: word; // Count of Palettes (2 bytes)
|
wClutsCount: word; // Count of Palettes (2 bytes)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PCLUTHeader = ^TCLUTHeader;
|
PCLUTHeader = ^TCLUTHeader;
|
||||||
|
|
||||||
type
|
type
|
||||||
@@ -68,9 +56,17 @@ type
|
|||||||
wWidth: word; // Image Width (not Real) (2 bytes)
|
wWidth: word; // Image Width (not Real) (2 bytes)
|
||||||
wHeight: word; // Image Height (Real) (2 bytes)
|
wHeight: word; // Image Height (Real) (2 bytes)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PIMAGEHeader = ^TIMAGEHeader;
|
PIMAGEHeader = ^TIMAGEHeader;
|
||||||
|
|
||||||
|
//Constants
|
||||||
|
const
|
||||||
|
cCLUTColorsMax = 1024;
|
||||||
|
cCLUTCountMax = 512;
|
||||||
|
cIMAGEWidthMax = 1024;
|
||||||
|
cIMAGEHeightMax = 1024;
|
||||||
|
cTIMMaxSize = SizeOf(TTIMHeader) + cCLUTColorsMax * cCLUTCountMax * 2 + SizeOf(TCLUTHeader) + cIMAGEWidthMax * cIMAGEHeightMax * 2 + SizeOf(TIMAGEHeader);
|
||||||
|
//Constants
|
||||||
|
|
||||||
type
|
type
|
||||||
TTIMDataArray = array [0 .. cTIMMaxSize - 1] of byte;
|
TTIMDataArray = array [0 .. cTIMMaxSize - 1] of byte;
|
||||||
PTIMDataArray = ^TTIMDataArray;
|
PTIMDataArray = ^TTIMDataArray;
|
||||||
@@ -114,6 +110,7 @@ function GetTimWidth(TIM: PTIM): word;
|
|||||||
function GetTimRealWidth(TIM: PTIM): word;
|
function GetTimRealWidth(TIM: PTIM): word;
|
||||||
function GetTimHeight(TIM: PTIM): word;
|
function GetTimHeight(TIM: PTIM): word;
|
||||||
function TIMIsGood(TIM: PTIM): Boolean;
|
function TIMIsGood(TIM: PTIM): Boolean;
|
||||||
|
function TIMIsGoodStr(TIM: PTIM): string;
|
||||||
function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean;
|
function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean;
|
||||||
function LoadTimFromFile(const FileName: string; var Position: Integer; ImageScan: Boolean; dwSize: Integer): PTIM;
|
function LoadTimFromFile(const FileName: string; var Position: Integer; ImageScan: Boolean; dwSize: Integer): PTIM;
|
||||||
procedure SaveTimToFile(const FileName: string; TIM: PTIM);
|
procedure SaveTimToFile(const FileName: string; TIM: PTIM);
|
||||||
@@ -170,7 +167,7 @@ begin
|
|||||||
|
|
||||||
CLUT_OFFSET := CLUT_NUM * GetTimColorsCount(TIM) * 2;
|
CLUT_OFFSET := CLUT_NUM * GetTimColorsCount(TIM) * 2;
|
||||||
|
|
||||||
Move(TIM^.DATA^[cTIMHeadSize + cCLUTHeadSize + COLOR_NUM * 2 + CLUT_OFFSET], COLOR, 2);
|
Move(TIM^.DATA^[SizeOf(TTIMHeader) + SizeOf(TCLUTHeader) + COLOR_NUM * 2 + CLUT_OFFSET], COLOR, 2);
|
||||||
|
|
||||||
Result := ConvertTIMColor(COLOR);
|
Result := ConvertTIMColor(COLOR);
|
||||||
end;
|
end;
|
||||||
@@ -184,7 +181,7 @@ begin
|
|||||||
CLUT_OFFSET := CLUT_NUM * GetTimColorsCount(TIM) * 2;
|
CLUT_OFFSET := CLUT_NUM * GetTimColorsCount(TIM) * 2;
|
||||||
|
|
||||||
COLOR_TO_WRITE := ConvertCLUTColor(COLOR);
|
COLOR_TO_WRITE := ConvertCLUTColor(COLOR);
|
||||||
Move(COLOR_TO_WRITE, TIM^.DATA^[cTIMHeadSize + cCLUTHeadSize + COLOR_NUM * 2 + CLUT_OFFSET], 2);
|
Move(COLOR_TO_WRITE, TIM^.DATA^[SizeOf(TTIMHeader) + SizeOf(TCLUTHeader) + COLOR_NUM * 2 + CLUT_OFFSET], 2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetTimHeight(TIM: PTIM): word;
|
function GetTimHeight(TIM: PTIM): word;
|
||||||
@@ -197,17 +194,17 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
|
|
||||||
if not TIMHasCLUT(TIM) then Exit;
|
if not TIMHasCLUT(TIM) then Exit;
|
||||||
Result := TIM^.CLUT^.wColorsCount * TIM^.CLUT^.wClutsCount * 2 + cCLUTHeadSize;
|
Result := TIM^.CLUT^.wColorsCount * TIM^.CLUT^.wClutsCount * 2 + SizeOf(TCLUTHeader);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetTIMIMAGESize(TIM: PTIM): Integer;
|
function GetTIMIMAGESize(TIM: PTIM): Integer;
|
||||||
begin
|
begin
|
||||||
Result := TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight * 2 + cIMAGEHeadSize;
|
Result := TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight * 2 + SizeOf(TIMAGEHeader);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetTIMSize(TIM: PTIM): Integer;
|
function GetTIMSize(TIM: PTIM): Integer;
|
||||||
begin
|
begin
|
||||||
Result := GetTIMCLUTSize(TIM) + GetTIMIMAGESize(TIM) + cTIMHeadSize;
|
Result := GetTIMCLUTSize(TIM) + GetTIMIMAGESize(TIM) + SizeOf(TTIMHeader);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckVersion(TIM: PTIM): Boolean;
|
function CheckVersion(TIM: PTIM): Boolean;
|
||||||
@@ -292,12 +289,17 @@ end;
|
|||||||
|
|
||||||
procedure ClearTIM(TIM: PTIM);
|
procedure ClearTIM(TIM: PTIM);
|
||||||
begin
|
begin
|
||||||
FillChar(TIM^.HEAD^, cTIMHeadSize, 0);
|
FillChar(TIM^.HEAD^, SizeOf(TTIMHeader), 0);
|
||||||
FillChar(TIM^.CLUT^, cCLUTHeadSize, 0);
|
FillChar(TIM^.CLUT^, SizeOf(TCLUTHeader), 0);
|
||||||
FillChar(TIM^.IMAGE^, cIMAGEHeadSize, 0);
|
FillChar(TIM^.IMAGE^, SizeOf(TIMAGEHeader), 0);
|
||||||
FillChar(TIM^.DATA^, cTIMMaxSize, 0);
|
FillChar(TIM^.DATA^, cTIMMaxSize, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TIMIsGoodStr(TIM: PTIM): string;
|
||||||
|
begin
|
||||||
|
if TIMIsGood(TIM) then Result := 'Yes' else Result := 'No';
|
||||||
|
end;
|
||||||
|
|
||||||
function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean;
|
function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean;
|
||||||
var
|
var
|
||||||
P: Integer;
|
P: Integer;
|
||||||
@@ -311,18 +313,18 @@ begin
|
|||||||
|
|
||||||
if TIM = nil then TIM := CreateTIM;
|
if TIM = nil then TIM := CreateTIM;
|
||||||
|
|
||||||
Move(PBytesArray(BUFFER)^[P], TIM^.HEAD^, cTIMHeadSize);
|
Move(PBytesArray(BUFFER)^[P], TIM^.HEAD^, SizeOf(TTIMHeader));
|
||||||
if not CheckHEAD(TIM) then Exit;
|
if not CheckHEAD(TIM) then Exit;
|
||||||
Inc(P, cTIMHeadSize);
|
Inc(P, SizeOf(TTIMHeader));
|
||||||
|
|
||||||
if TIMHasCLUT(TIM) then
|
if TIMHasCLUT(TIM) then
|
||||||
begin
|
begin
|
||||||
Move(PBytesArray(BUFFER)^[P], TIM^.CLUT^, cCLUTHeadSize);
|
Move(PBytesArray(BUFFER)^[P], TIM^.CLUT^, SizeOf(TCLUTHeader));
|
||||||
if not CheckCLUT(TIM) then Exit;
|
if not CheckCLUT(TIM) then Exit;
|
||||||
Inc(P, GetTIMCLUTSize(TIM));
|
Inc(P, GetTIMCLUTSize(TIM));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Move(PBytesArray(BUFFER)^[P], TIM^.IMAGE^, cIMAGEHeadSize);
|
Move(PBytesArray(BUFFER)^[P], TIM^.IMAGE^, SizeOf(TIMAGEHeader));
|
||||||
|
|
||||||
if not CheckIMAGE(TIM) then Exit;
|
if not CheckIMAGE(TIM) then Exit;
|
||||||
if not CheckTIMSize(TIM) then Exit;
|
if not CheckTIMSize(TIM) then Exit;
|
||||||
|
|||||||
Reference in New Issue
Block a user