diff --git a/tim2view.lpi b/tim2view.lpi index bc1c0e6..934cb8c 100644 --- a/tim2view.lpi +++ b/tim2view.lpi @@ -14,6 +14,9 @@ <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> <Icon Value="0"/> </General> <i18n> @@ -23,8 +26,8 @@ <UseVersionInfo Value="True"/> <AutoIncrementBuild Value="True"/> <MajorVersionNr Value="1"/> - <RevisionNr Value="86"/> - <BuildNr Value="1"/> + <RevisionNr Value="88"/> + <BuildNr Value="12"/> <StringTable CompanyName="Lab 313" FileDescription="The best TIMs tool ever!:)" ProductVersion=""/> </VersionInfo> <BuildModes Count="6"> @@ -65,12 +68,6 @@ </Win32> </Options> </Linking> - <Other> - <CompilerMessages> - <MsgFileName Value=""/> - </CompilerMessages> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </Item2> <Item3 Name="Win Release x64"> @@ -109,12 +106,6 @@ </Win32> </Options> </Linking> - <Other> - <CompilerMessages> - <MsgFileName Value=""/> - </CompilerMessages> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </Item3> <Item4 Name="Linux Release x86"> @@ -153,12 +144,6 @@ </Win32> </Options> </Linking> - <Other> - <CompilerMessages> - <MsgFileName Value=""/> - </CompilerMessages> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </Item4> <Item5 Name="Linux Release x64"> @@ -197,12 +182,6 @@ </Win32> </Options> </Linking> - <Other> - <CompilerMessages> - <MsgFileName Value=""/> - </CompilerMessages> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </Item5> <Item6 Name="Mac Release x86"> @@ -241,12 +220,6 @@ </Win32> </Options> </Linking> - <Other> - <CompilerMessages> - <MsgFileName Value=""/> - </CompilerMessages> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </Item6> </BuildModes> @@ -267,7 +240,6 @@ <Unit0> <Filename Value="tim2view.lpr"/> <IsPartOfProject Value="True"/> - <UnitName Value="tim2view"/> </Unit0> <Unit1> <Filename Value="umain.pas"/> @@ -280,12 +252,10 @@ <Unit2> <Filename Value="edc.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="edc"/> </Unit2> <Unit3> <Filename Value="ecc.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="ecc"/> </Unit3> <Unit4> <Filename Value="ucommon.pas"/> @@ -330,7 +300,6 @@ <Unit12> <Filename Value="bgrabitmap\bgrabitmap.pas"/> <IsPartOfProject Value="True"/> - <UnitName Value="BGRABitmap"/> </Unit12> <Unit13> <Filename Value="todos.inc"/> @@ -376,12 +345,6 @@ </Win32> </Options> </Linking> - <Other> - <CompilerMessages> - <MsgFileName Value=""/> - </CompilerMessages> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> <Debugging> <Exceptions Count="3"> @@ -396,4 +359,4 @@ </Item3> </Exceptions> </Debugging> -</CONFIG> \ No newline at end of file +</CONFIG> diff --git a/tim2view.lps b/tim2view.lps index 512dad8..477da6c 100644 --- a/tim2view.lps +++ b/tim2view.lps @@ -1,204 +1,184 @@ -<?xml version="1.0" encoding="UTF-8"?> -<CONFIG> - <ProjectSession> - <PathDelim Value="\"/> - <Version Value="9"/> - <BuildModes Active="Debug"/> - <Units Count="15"> - <Unit0> - <Filename Value="tim2view.lpr"/> - <IsPartOfProject Value="True"/> - <UnitName Value="tim2view"/> - <WindowIndex Value="0"/> - <TopLine Value="1"/> - <CursorPos X="46" Y="13"/> - <UsageCount Value="816"/> - </Unit0> - <Unit1> - <Filename Value="umain.pas"/> - <IsPartOfProject Value="True"/> - <ComponentName Value="frmMain"/> - <HasResources Value="True"/> - <ResourceBaseClass Value="Form"/> - <UnitName Value="umain"/> - <EditorIndex Value="0"/> - <WindowIndex Value="0"/> - <TopLine Value="295"/> - <CursorPos X="66" Y="308"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - <LoadedDesigner Value="True"/> - </Unit1> - <Unit2> - <Filename Value="edc.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="edc"/> - <UsageCount Value="816"/> - </Unit2> - <Unit3> - <Filename Value="ecc.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="ecc"/> - <WindowIndex Value="0"/> - <TopLine Value="13"/> - <CursorPos X="1" Y="1"/> - <UsageCount Value="816"/> - </Unit3> - <Unit4> - <Filename Value="ucommon.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="ucommon"/> - <EditorIndex Value="3"/> - <WindowIndex Value="0"/> - <TopLine Value="1"/> - <CursorPos X="70" Y="9"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit4> - <Unit5> - <Filename Value="utim.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="utim"/> - <EditorIndex Value="10"/> - <WindowIndex Value="0"/> - <TopLine Value="244"/> - <CursorPos X="82" Y="311"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit5> - <Unit6> - <Filename Value="ucdimage.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="ucdimage"/> - <EditorIndex Value="2"/> - <WindowIndex Value="0"/> - <TopLine Value="112"/> - <CursorPos X="50" Y="117"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit6> - <Unit7> - <Filename Value="usettings.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="usettings"/> - <EditorIndex Value="9"/> - <WindowIndex Value="0"/> - <TopLine Value="132"/> - <CursorPos X="1" Y="150"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit7> - <Unit8> - <Filename Value="uscanresult.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="uscanresult"/> - <EditorIndex Value="7"/> - <WindowIndex Value="0"/> - <TopLine Value="54"/> - <CursorPos X="79" Y="80"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit8> - <Unit9> - <Filename Value="uscanthread.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="uscanthread"/> - <EditorIndex Value="8"/> - <WindowIndex Value="0"/> - <TopLine Value="172"/> - <CursorPos X="3" Y="187"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit9> - <Unit10> - <Filename Value="ucpucount.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="ucpucount"/> - <EditorIndex Value="4"/> - <WindowIndex Value="0"/> - <TopLine Value="19"/> - <CursorPos X="87" Y="34"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit10> - <Unit11> - <Filename Value="udrawtim.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="udrawtim"/> - <IsVisibleTab Value="True"/> - <EditorIndex Value="5"/> - <WindowIndex Value="0"/> - <TopLine Value="92"/> - <CursorPos X="58" Y="103"/> - <UsageCount Value="816"/> - <Loaded Value="True"/> - </Unit11> - <Unit12> - <Filename Value="bgrabitmap\bgrabitmap.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="BGRABitmap"/> - <WindowIndex Value="0"/> - <TopLine Value="54"/> - <CursorPos X="3" Y="69"/> - <UsageCount Value="816"/> - </Unit12> - <Unit13> - <Filename Value="todos.inc"/> - <IsPartOfProject Value="True"/> - <EditorIndex Value="1"/> - <WindowIndex Value="0"/> - <TopLine Value="1"/> - <CursorPos X="31" Y="3"/> - <UsageCount Value="802"/> - <Loaded Value="True"/> - </Unit13> - <Unit14> - <Filename Value="uexportimport.pas"/> - <IsPartOfProject Value="True"/> - <UnitName Value="uexportimport"/> - <EditorIndex Value="6"/> - <WindowIndex Value="0"/> - <TopLine Value="7"/> - <CursorPos X="20" Y="16"/> - <UsageCount Value="83"/> - <Loaded Value="True"/> - </Unit14> - </Units> - <General> - <ActiveWindowIndexAtStart Value="0"/> - </General> - </ProjectSession> - <Debugging> - <BreakPoints Count="2"> - <Item1> - <Kind Value="bpkSource"/> - <WatchScope Value="wpsLocal"/> - <WatchKind Value="wpkWrite"/> - <Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fpimage.inc"/> - <Line Value="350"/> - </Item1> - <Item2> - <Kind Value="bpkSource"/> - <WatchScope Value="wpsLocal"/> - <WatchKind Value="wpkWrite"/> - <Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fppalette.inc"/> - <Line Value="159"/> - </Item2> - </BreakPoints> - <Watches Count="3"> - <Item1> - <Expression Value="IDX"/> - <DisplayStyle Value="wdfHex"/> - </Item1> - <Item2> - <Expression Value="TData^[POS]"/> - <DisplayStyle Value="wdfHex"/> - </Item2> - <Item3> - <Expression Value="IDX_INT"/> - <DisplayStyle Value="wdfHex"/> - </Item3> - </Watches> - </Debugging> - <EditorMacros Count="0"/> -</CONFIG> +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectSession> + <PathDelim Value="\"/> + <Version Value="9"/> + <BuildModes Active="Win Release x86"/> + <Units Count="15"> + <Unit0> + <Filename Value="tim2view.lpr"/> + <IsPartOfProject Value="True"/> + <CursorPos X="46" Y="13"/> + <UsageCount Value="816"/> + </Unit0> + <Unit1> + <Filename Value="umain.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="frmMain"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="umain"/> + <IsVisibleTab Value="True"/> + <TopLine Value="691"/> + <CursorPos X="81" Y="710"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + <LoadedDesigner Value="True"/> + </Unit1> + <Unit2> + <Filename Value="edc.pas"/> + <IsPartOfProject Value="True"/> + <UsageCount Value="816"/> + </Unit2> + <Unit3> + <Filename Value="ecc.pas"/> + <IsPartOfProject Value="True"/> + <TopLine Value="13"/> + <UsageCount Value="816"/> + </Unit3> + <Unit4> + <Filename Value="ucommon.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="ucommon"/> + <EditorIndex Value="3"/> + <TopLine Value="15"/> + <CursorPos X="73" Y="11"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit4> + <Unit5> + <Filename Value="utim.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="utim"/> + <EditorIndex Value="10"/> + <TopLine Value="420"/> + <CursorPos Y="401"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit5> + <Unit6> + <Filename Value="ucdimage.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="ucdimage"/> + <EditorIndex Value="2"/> + <TopLine Value="112"/> + <CursorPos X="50" Y="117"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit6> + <Unit7> + <Filename Value="usettings.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="usettings"/> + <EditorIndex Value="9"/> + <TopLine Value="58"/> + <CursorPos X="35" Y="63"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit7> + <Unit8> + <Filename Value="uscanresult.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="uscanresult"/> + <EditorIndex Value="7"/> + <TopLine Value="56"/> + <CursorPos Y="71"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit8> + <Unit9> + <Filename Value="uscanthread.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="uscanthread"/> + <EditorIndex Value="8"/> + <TopLine Value="18"/> + <CursorPos X="37" Y="68"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit9> + <Unit10> + <Filename Value="ucpucount.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="ucpucount"/> + <EditorIndex Value="4"/> + <TopLine Value="19"/> + <CursorPos X="87" Y="34"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit10> + <Unit11> + <Filename Value="udrawtim.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="udrawtim"/> + <EditorIndex Value="5"/> + <CursorPos X="15" Y="212"/> + <UsageCount Value="816"/> + <Loaded Value="True"/> + </Unit11> + <Unit12> + <Filename Value="bgrabitmap\bgrabitmap.pas"/> + <IsPartOfProject Value="True"/> + <TopLine Value="54"/> + <CursorPos X="3" Y="69"/> + <UsageCount Value="816"/> + </Unit12> + <Unit13> + <Filename Value="todos.inc"/> + <IsPartOfProject Value="True"/> + <EditorIndex Value="1"/> + <CursorPos X="31" Y="3"/> + <UsageCount Value="802"/> + <Loaded Value="True"/> + </Unit13> + <Unit14> + <Filename Value="uexportimport.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="uexportimport"/> + <EditorIndex Value="6"/> + <TopLine Value="7"/> + <CursorPos X="32" Y="35"/> + <UsageCount Value="96"/> + <Loaded Value="True"/> + </Unit14> + </Units> + </ProjectSession> + <Debugging> + <BreakPoints Count="3"> + <Item1> + <Kind Value="bpkSource"/> + <WatchScope Value="wpsLocal"/> + <WatchKind Value="wpkWrite"/> + <Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fpimage.inc"/> + <Line Value="350"/> + </Item1> + <Item2> + <Kind Value="bpkSource"/> + <WatchScope Value="wpsLocal"/> + <WatchKind Value="wpkWrite"/> + <Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fppalette.inc"/> + <Line Value="159"/> + </Item2> + <Item3> + <Kind Value="bpkSource"/> + <WatchScope Value="wpsLocal"/> + <WatchKind Value="wpkWrite"/> + <Source Value="usettings.pas"/> + <Line Value="74"/> + </Item3> + </BreakPoints> + <Watches Count="3"> + <Item1> + <Expression Value="IDX"/> + <DisplayStyle Value="wdfHex"/> + </Item1> + <Item2> + <Expression Value="TData^[POS]"/> + <DisplayStyle Value="wdfHex"/> + </Item2> + <Item3> + <Expression Value="IDX_INT"/> + <DisplayStyle Value="wdfHex"/> + </Item3> + </Watches> + </Debugging> +</CONFIG> diff --git a/tim2view.res b/tim2view.res deleted file mode 100644 index 006621b..0000000 Binary files a/tim2view.res and /dev/null differ diff --git a/ucommon.pas b/ucommon.pas index 2554525..57e813d 100644 --- a/ucommon.pas +++ b/ucommon.pas @@ -3,26 +3,26 @@ unit ucommon; interface const - cProgramName = 'Tim2View SVN.r86 by [Lab 313] (for ' + + cProgramName = 'Tim2View SVN.r88 by [Lab 313] (for ' + {$IFDEF Linux}'Linux' + {$IFEND} {$IFDEF Darwin}'Mac OS X' + {$IFEND} {$IFDEF Windows}'Windows' + {$IFEND} ')'; - cExtractedTimsDir = 'TIMS'; + cExtractedFilesDir = 'FILES'; cExtractedPngsDir = 'PNGS'; cMaxFileSize = $2EAEED80; - cAutoExtractionTimFormat = '%s_%.6d_%.2db' + '.tim'; + cAutoExtractionFileFormat = '%s_%.6d_%.2db' + '.%s' {tim|clt|pxl}; cAutoExtractionPngFormat = '%s_%.6d_%.2db_%.2dc' + '.png'; sStatusBarScanningFile = 'Scanning File...'; - sStatusBarTimsExtracting = 'TIMs Extracting...'; + sStatusBarFilesExtracting = 'Files Extracting...'; sStatusBarPngsExtracting = 'PNGs Extracting...'; sStatusBarExtracted = 'Extracted Successfully!'; sStatusBarParsingResult = 'Parsing Result...'; sScanResultGood = 'Scan completed!'; sSelectDirCaption = 'Please, select directory for scan...'; - sThisTimHasNoCLUT = 'No CLUT'; + sThisFileHasNoCLUT = 'No CLUT'; type TBytesArray = array [0 .. cMaxFileSize - 1] of byte; @@ -40,4 +40,4 @@ begin Result := Copy(Result, 1, Length(Result) - Length(ExtractFileExt(Result))); end; -end. \ No newline at end of file +end. diff --git a/udrawtim.pas b/udrawtim.pas index ff536f3..3c391a2 100644 --- a/udrawtim.pas +++ b/udrawtim.pas @@ -219,7 +219,7 @@ begin case TIM^.HEAD^.bBPP of cTIM4C, cTIM4NC, cTIM8C, cTIM8NC: Image^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS; - cTIM16C, cTIM16NC, cTIMMix: + cTIM16C, cTIM16NC, cTIMMixC, cTIMMixNC: begin CW := 0; Move(INDEXES^[IDX], CW, 2); @@ -386,4 +386,4 @@ begin end; end; -end. \ No newline at end of file +end. diff --git a/umain.lfm b/umain.lfm index 4781efa..b64aed5 100644 --- a/umain.lfm +++ b/umain.lfm @@ -9,7 +9,7 @@ object frmMain: TfrmMain VertScrollBar.Range = 344 ActiveControl = pnlList AllowDropFiles = True - ClientHeight = 643 + ClientHeight = 648 ClientWidth = 790 Color = clBtnFace Font.Color = clWindowText @@ -494,11 +494,11 @@ object frmMain: TfrmMain OnCreate = FormCreate OnDropFiles = FormDropFiles Position = poScreenCenter - LCLVersion = '1.2.2.0' + LCLVersion = '1.4.0.2' object pnlStatus: TPanel Left = 0 Height = 30 - Top = 613 + Top = 618 Width = 790 Align = alBottom BevelOuter = bvLowered @@ -538,13 +538,13 @@ object frmMain: TfrmMain end object cbbFiles: TComboBox Left = 0 - Height = 28 + Height = 21 Top = 0 Width = 790 Align = alTop DropDownCount = 30 Enabled = False - ItemHeight = 0 + ItemHeight = 13 OnChange = actChangeFileExecute OnCloseUp = actReturnFocusExecute Style = csDropDownList @@ -552,33 +552,33 @@ object frmMain: TfrmMain end object pnlMain: TPanel Left = 0 - Height = 585 - Top = 28 + Height = 597 + Top = 21 Width = 790 Align = alClient BevelOuter = bvNone - ClientHeight = 585 + ClientHeight = 597 ClientWidth = 790 TabOrder = 1 object splMain: TSplitter Left = 253 - Height = 585 + Height = 597 Top = 0 Width = 5 end object pnlList: TPanel Left = 0 - Height = 585 + Height = 597 Top = 0 Width = 253 Align = alLeft BevelOuter = bvNone - ClientHeight = 585 + ClientHeight = 597 ClientWidth = 253 TabOrder = 0 object lvList: TListView Left = 0 - Height = 372 + Height = 384 Top = 28 Width = 253 Align = alClient @@ -586,25 +586,31 @@ object frmMain: TfrmMain item AutoSize = True Caption = '# / 0' - Width = 41 + Width = 249 end item Alignment = taCenter AutoSize = True Caption = 'BPP' - Width = 35 + Width = 30 end item Alignment = taCenter AutoSize = True Caption = 'CLUTs' - Width = 47 + Width = 42 + end + item + Alignment = taCenter + AutoSize = True + Caption = 'Type' + Width = 37 end item Alignment = taCenter AutoSize = True Caption = 'W x H' - Width = 128 + Width = 41 end> ColumnClick = False OwnerData = True @@ -633,7 +639,7 @@ object frmMain: TfrmMain Height = 26 Top = 1 Width = 100 - Action = actExtractPNGs + Action = actExtractPngs Align = alRight TabOrder = 0 end @@ -642,7 +648,7 @@ object frmMain: TfrmMain Height = 26 Top = 1 Width = 100 - Action = actExtractTIMs + Action = actExtractFiles Align = alLeft TabOrder = 1 end @@ -650,7 +656,7 @@ object frmMain: TfrmMain object tblTimInfo: TStringGrid Left = 0 Height = 185 - Top = 400 + Top = 412 Width = 253 Align = alBottom AutoEdit = False @@ -706,32 +712,32 @@ object frmMain: TfrmMain end object pnlImage: TPanel Left = 258 - Height = 585 + Height = 597 Top = 0 Width = 532 Align = alClient BevelOuter = bvLowered - ClientHeight = 585 + ClientHeight = 597 ClientWidth = 532 Color = clBtnFace ParentColor = False TabOrder = 1 object pnlImageOptions: TPanel Left = 1 - Height = 32 - Top = 552 + Height = 27 + Top = 569 Width = 530 Align = alBottom AutoSize = True BevelOuter = bvLowered - ClientHeight = 32 + ClientHeight = 27 ClientWidth = 530 Color = clBtnFace ParentColor = False TabOrder = 0 object btnShowClut: TButton Left = 476 - Height = 28 + Height = 23 Top = 2 Width = 52 Align = alRight @@ -742,12 +748,12 @@ object frmMain: TfrmMain end object cbbBitMode: TComboBox Left = 2 - Height = 28 + Height = 21 Top = 2 Width = 159 Align = alLeft BorderSpacing.Around = 1 - ItemHeight = 0 + ItemHeight = 13 ItemIndex = 0 Items.Strings = ( 'Real' @@ -766,12 +772,12 @@ object frmMain: TfrmMain end object cbbTranspMode: TComboBox Left = 162 - Height = 28 + Height = 21 Top = 2 Width = 150 Align = alLeft BorderSpacing.Around = 1 - ItemHeight = 0 + ItemHeight = 13 ItemIndex = 1 Items.Strings = ( 'Full transparence' @@ -787,13 +793,13 @@ object frmMain: TfrmMain end object cbbCLUT: TComboBox Left = 366 - Height = 28 + Height = 21 Top = 2 Width = 109 Align = alRight BorderSpacing.Around = 1 DropDownCount = 16 - ItemHeight = 0 + ItemHeight = 13 OnChange = actChangeClutIdxExecute Style = csDropDownList TabOrder = 3 @@ -802,7 +808,7 @@ object frmMain: TfrmMain object pnlClut: TPanel Left = 1 Height = 192 - Top = 360 + Top = 377 Width = 530 Align = alBottom BevelOuter = bvLowered @@ -814,7 +820,7 @@ object frmMain: TfrmMain Visible = False object grdClut: TDrawGrid Left = 1 - Height = 125 + Height = 138 Top = 1 Width = 528 Align = alClient @@ -839,8 +845,8 @@ object frmMain: TfrmMain end object lblClutHint: TLabel Left = 1 - Height = 65 - Top = 126 + Height = 52 + Top = 139 Width = 528 Align = alBottom Alignment = taCenter @@ -852,7 +858,7 @@ object frmMain: TfrmMain end object imgTim: TImage Left = 1 - Height = 359 + Height = 376 Top = 1 Width = 530 AntialiasingMode = amOff @@ -895,13 +901,13 @@ object frmMain: TfrmMain Action = actExit end end - object mnTIM: TMenuItem - Caption = '&TIM' + object mnImage: TMenuItem + Caption = '&Image' object mnSaveTIM: TMenuItem - Action = actExtractTim + Action = actExtractFile end object mnReplaceIn: TMenuItem - Action = actReplaceTim + Action = actReplaceFile end object MenuItem1: TMenuItem Caption = '-' @@ -916,13 +922,14 @@ object frmMain: TfrmMain object mnOptions: TMenuItem Caption = '&Options' object mnAssociate: TMenuItem - Action = actAssocTims + Action = actAddToSendto + AutoCheck = True end object N8: TMenuItem Caption = '-' end object mnShowTimInfo: TMenuItem - Action = actShowTimInfo + Action = actShowFileInfo AutoCheck = True ShowAlwaysCheckable = True end @@ -958,10 +965,11 @@ object frmMain: TfrmMain left = 672 top = 112 end - object dlgSaveTIM: TSaveDialog + object dlgSaveFile: TSaveDialog Title = 'Please, select where to save TIM file...' DefaultExt = '.tim' - Filter = 'PSX TIM Files (*.tim)|*.tim|All Files (*.*)|*.*' + Filter = 'PSX TIM Files (*.tim)|*.tim|PSX CLT Files (*.clt)|*.clt|PSX PXL Files (*.pxl)|*.pxl|All Files (*.*)|*.*' + FilterIndex = 0 Options = [ofOverwritePrompt, ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing] left = 592 top = 112 @@ -1021,9 +1029,9 @@ object frmMain: TfrmMain OnExecute = actExitExecute ShortCut = 121 end - object actExtractTim: TAction - Caption = '&Extract TIM...' - OnExecute = actExtractTimExecute + object actExtractFile: TAction + Caption = '&Extract File...' + OnExecute = actExtractFileExecute ShortCut = 113 end object actPngExport: TAction @@ -1036,9 +1044,9 @@ object frmMain: TfrmMain OnExecute = actPngImportExecute ShortCut = 116 end - object actReplaceTim: TAction - Caption = '&Replace TIM...' - OnExecute = actReplaceTimExecute + object actReplaceFile: TAction + Caption = '&Replace File...' + OnExecute = actReplaceFileExecute ShortCut = 114 end object actOpenRepo: TAction @@ -1058,18 +1066,19 @@ object frmMain: TfrmMain Caption = '&Stretch Image' OnExecute = actStretchExecute end - object actAssocTims: TAction - Caption = '&Open TIMs with T2V' - OnExecute = actAssocTimsExecute + object actAddToSendto: TAction + AutoCheck = True + Caption = '&SendTo Shortcut for Tim2View' + OnExecute = actAddToSendtoExecute end - object actExtractTIMs: TAction - Caption = 'Extract all &TIMs' - OnExecute = actExtractTIMsExecute + object actExtractFiles: TAction + Caption = 'Extract all &Files' + OnExecute = actExtractFilesExecute ShortCut = 8305 end - object actExtractPNGs: TAction + object actExtractPngs: TAction Caption = '&Extract all PNGs' - OnExecute = actExtractPNGsExecute + OnExecute = actExtractPngsExecute ShortCut = 8307 end object actChangeClutIdx: TAction @@ -1090,20 +1099,20 @@ object frmMain: TfrmMain Caption = '&Background Color' OnExecute = actChangeBackColorExecute end - object actShowTimInfo: TAction + object actShowFileInfo: TAction AutoCheck = True - Caption = '&Show Tim Info' - OnExecute = actShowTimInfoExecute + Caption = '&Show File Info' + OnExecute = actShowFileInfoExecute end end object pmList: TPopupMenu left = 432 top = 112 object ExtractTIM1: TMenuItem - Action = actExtractTim + Action = actExtractFile end object ReplaceTIM1: TMenuItem - Action = actReplaceTim + Action = actReplaceFile end object SaveasPNG1: TMenuItem Action = actPngExport @@ -1112,10 +1121,10 @@ object frmMain: TfrmMain Caption = '-' end object mnExtractAllTims2: TMenuItem - Action = actExtractTIMs + Action = actExtractFiles end object mnExtractAllPngs2: TMenuItem - Action = actExtractPNGs + Action = actExtractPngs end end object pmImage: TPopupMenu @@ -1125,7 +1134,7 @@ object frmMain: TfrmMain Action = actPngExport end object mnSaveAsTim: TMenuItem - Action = actExtractTim + Action = actExtractFile end object N5: TMenuItem Caption = '-' @@ -1151,4 +1160,4 @@ object frmMain: TfrmMain left = 640 top = 112 end -end \ No newline at end of file +end diff --git a/umain.pas b/umain.pas index 0969c58..fa3addc 100644 --- a/umain.pas +++ b/umain.pas @@ -18,22 +18,22 @@ type TfrmMain = class(TForm) actAbout: TAction; - actAssocTims: TAction; + actAddToSendto: TAction; actChangeClutIdx: TAction; actCloseFile: TAction; actCloseFiles: TAction; actExit: TAction; - actExtractPNGs: TAction; - actExtractTim: TAction; - actExtractTIMs: TAction; + actExtractPngs: TAction; + actExtractFile: TAction; + actExtractFiles: TAction; actChangeFile: TAction; actChangeBackColor: TAction; - actShowTimInfo: TAction; + actShowFileInfo: TAction; actPngImport: TAction; actStopScan: TAction; actOpenLab: TAction; actOpenRepo: TAction; - actReplaceTim: TAction; + actReplaceFile: TAction; actReturnFocus: TAction; actScanDir: TAction; actScanFile: TAction; @@ -51,7 +51,7 @@ type dlgColor: TColorDialog; dlgOpenFile: TOpenDialog; dlgSavePNG: TSavePictureDialog; - dlgSaveTIM: TSaveDialog; + dlgSaveFile: TSaveDialog; ExtractTIM1: TMenuItem; grdClut: TDrawGrid; imgTim: TImage; @@ -87,7 +87,7 @@ type mnSite: TMenuItem; mnStretch: TMenuItem; mnSVN: TMenuItem; - mnTIM: TMenuItem; + mnImage: TMenuItem; N1: TMenuItem; N3: TMenuItem; N5: TMenuItem; @@ -108,24 +108,24 @@ type splMain: TSplitter; tblTimInfo: TStringGrid; procedure actAboutExecute(Sender: TObject); - procedure actAssocTimsExecute(Sender: TObject); + procedure actAddToSendtoExecute(Sender: TObject); procedure actChangeBackColorExecute(Sender: TObject); procedure actChangeClutIdxExecute(Sender: TObject); procedure actChangeFileExecute(Sender: TObject); procedure actCloseFileExecute(Sender: TObject); procedure actCloseFilesExecute(Sender: TObject); procedure actExitExecute(Sender: TObject); - procedure actExtractPNGsExecute(Sender: TObject); - procedure actExtractTimExecute(Sender: TObject); - procedure actExtractTIMsExecute(Sender: TObject); + procedure actExtractPngsExecute(Sender: TObject); + procedure actExtractFileExecute(Sender: TObject); + procedure actExtractFilesExecute(Sender: TObject); procedure actOpenLabExecute(Sender: TObject); procedure actOpenRepoExecute(Sender: TObject); procedure actPngImportExecute(Sender: TObject); - procedure actReplaceTimExecute(Sender: TObject); + procedure actReplaceFileExecute(Sender: TObject); procedure actReturnFocusExecute(Sender: TObject); procedure actScanDirExecute(Sender: TObject); procedure actScanFileExecute(Sender: TObject); - procedure actShowTimInfoExecute(Sender: TObject); + procedure actShowFileInfoExecute(Sender: TObject); procedure actStopScanExecute(Sender: TObject); procedure actStretchExecute(Sender: TObject); procedure actPngExportExecute(Sender: TObject); @@ -173,7 +173,7 @@ type procedure DrawSelTim; procedure DrawSelClut; procedure SetCLUTListToNoCLUT; - function FormatTimName(const FileName: string; ListIdx_, BitMode: Integer): string; + function FormatFileName(const FileName: string; ListIdx_, BitMode: Integer; Magic: Byte): string; function FormatPngName(const FileName: string; ListIdx_, BitMode, Clut: Integer): string; procedure ShowTim; procedure ShowTimInfo(ShowInfo: Boolean); @@ -212,7 +212,7 @@ begin ScanPath(dlgOpenFile.Files.Strings[I - 1]); end; -procedure TfrmMain.actShowTimInfoExecute(Sender: TObject); +procedure TfrmMain.actShowFileInfoExecute(Sender: TObject); begin Settings.InfoVisible := (Sender as TAction).Checked; tblTimInfo.Visible := (Sender as TAction).Checked; @@ -315,9 +315,9 @@ begin Application.MessageBox(cProgramName + #13#10#13#10 + 'Some "about strings" should be here!:)', 'About', MB_OK + MB_ICONINFORMATION); end; -procedure TfrmMain.actAssocTimsExecute(Sender: TObject); +procedure TfrmMain.actAddToSendtoExecute(Sender: TObject); begin - Settings.AssociateWithTims; + Settings.AddToSendTo(not (Sender as TAction).Checked); end; procedure TfrmMain.actChangeBackColorExecute(Sender: TObject); @@ -368,7 +368,7 @@ begin Close; end; -procedure TfrmMain.actExtractPNGsExecute(Sender: TObject); +procedure TfrmMain.actExtractPngsExecute(Sender: TObject); var I, OFFSET, BIT_MODE, SIZE: Integer; FName, Path: string; @@ -418,29 +418,30 @@ begin pbProgress.Position := 0; end; -procedure TfrmMain.actExtractTimExecute(Sender: TObject); +procedure TfrmMain.actExtractFileExecute(Sender: TObject); var TIM: PTIM; begin - dlgSaveTIM.FileName := FormatTimName(SelectedScanResult.ScanFile, SelectedTimIdx, SelectedTimInfo.BitMode); + dlgSaveFile.FileName := FormatFileName(SelectedScanResult.ScanFile, SelectedTimIdx, SelectedTimInfo.BitMode, SelectedTimInfo.Magic); + dlgSaveFile.FilterIndex := SelectedTimInfo.Magic - cTIMMagic + 1; - if not dlgSaveTIM.Execute then Exit; + if not dlgSaveFile.Execute then Exit; TIM := SelectedTimInMode; - SaveTimToFile(dlgSaveTIM.FileName, TIM); - {$IFDEF Linux}FpChmod(dlgSaveTIM.FileName, &777);{$IFEND} + SaveTimToFile(dlgSaveFile.FileName, TIM); + {$IFDEF Linux}FpChmod(dlgSaveFile.FileName, &777);{$IFEND} FreeTIM(TIM); end; -procedure TfrmMain.actExtractTIMsExecute(Sender: TObject); +procedure TfrmMain.actExtractFilesExecute(Sender: TObject); var - I, OFFSET, BIT_MODE, SIZE: Integer; + I, OFFSET, BIT_MODE, SIZE, MAGIC: Integer; FName, Path: string; IsImage: Boolean; TIM: PTIM; ScanTim: TTimInfo; begin - lblStatus.Caption := sStatusBarTimsExtracting; + lblStatus.Caption := sStatusBarFilesExtracting; FName := SelectedScanResult.ScanFile; IsImage := SelectedScanResult.IsImage; @@ -453,14 +454,15 @@ begin OFFSET := ScanTim.Position; SIZE := ScanTim.Size; BIT_MODE := ScanTim.BitMode; + MAGIC := ScanTim.Magic; - Path := SysToUTF8(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedTimsDir)); + Path := SysToUTF8(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedFilesDir)); CreateDirUTF8(Path); Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName)); CreateDirUTF8(Path); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); - Path := Path + FormatTimName(FName, I - 1, BIT_MODE); + Path := Path + FormatFileName(FName, I - 1, BIT_MODE, MAGIC); SaveTimToFile(Path, TIM); {$IFDEF Linux}FpChmod(Path, &777);{$IFEND} FreeTIM(TIM); @@ -503,7 +505,7 @@ begin Dispose(Image); end; -procedure TfrmMain.actReplaceTimExecute(Sender: TObject); +procedure TfrmMain.actReplaceFileExecute(Sender: TObject); var ScanRes: TScanResult; begin @@ -555,12 +557,14 @@ begin cbbBitMode.Tag := NativeInt($FF); + actAddToSendto.Checked := Settings.SendToShortcutExists; + actStretch.Checked := Settings.StretchMode; cbbTranspMode.ItemIndex := Settings.TranspMode; LastDir := Settings.LastDir; cbbBitMode.ItemIndex := Settings.BitMode; pnlImage.Color := Settings.BackColor; - actShowTimInfo.Checked := Settings.InfoVisible; + actShowFileInfo.Checked := Settings.InfoVisible; ScanThreads := TScanThreadList.Create(False); //False - to able scan thread remove itself from this list ScanResults := TScanResultList.Create(False); @@ -708,6 +712,7 @@ begin Item.Caption := Format('%.6d', [Item.Index + 1]); Item.SubItems.Add(Format('%.2d', [TimInfoByIdx[Item.Index].BitMode])); Item.SubItems.Add(Format('%.2d', [TimInfoByIdx[Item.Index].Cluts])); + Item.SubItems.Add(Format('%s', [AnsiUpperCase(TIMTypeStr(TimInfoByIdx[Item.Index].Magic))])); Item.SubItems.Add(Format('%.3dx%.3d', [W, H])); end; @@ -835,13 +840,13 @@ begin actScanFile.Enabled := ScanThreads.Count = 0; actScanDir.Enabled := ScanThreads.Count = 0; - actReplaceTim.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1); + actReplaceFile.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1); - actPngExport.Enabled := (Surf^ <> nil) and actReplaceTim.Enabled; - actPngImport.Enabled := actReplaceTim.Enabled; - actExtractTim.Enabled := actReplaceTim.Enabled; + actPngExport.Enabled := (Surf^ <> nil) and actReplaceFile.Enabled; + actPngImport.Enabled := actReplaceFile.Enabled; + actExtractFile.Enabled := actReplaceFile.Enabled; - pnlImageOptions.Enabled := actReplaceTim.Enabled; + pnlImageOptions.Enabled := actReplaceFile.Enabled; end; procedure TfrmMain.ScanFinished(Sender: TObject); @@ -970,14 +975,14 @@ end; procedure TfrmMain.SetCLUTListToNoCLUT; begin cbbCLUT.Items.Clear; - cbbCLUT.Items.Add(sThisTimHasNoClut); + cbbCLUT.Items.Add(sThisFileHasNoClut); cbbCLUT.ItemIndex := 0; end; -function TfrmMain.FormatTimName(const FileName: string; ListIdx_, - BitMode: Integer): string; +function TfrmMain.FormatFileName(const FileName: string; ListIdx_, + BitMode: Integer; Magic: Byte): string; begin - Result := Format(cAutoExtractionTimFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode]); + Result := Format(cAutoExtractionFileFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode, TIMTypeStr(Magic)]); end; function TfrmMain.FormatPngName(const FileName: string; ListIdx_, BitMode, @@ -1020,7 +1025,7 @@ begin tblTimInfo.Cells[1, 1] := Format('0x%x', [TimInfo.Position]); - tblTimInfo.Cells[1, 2] := Format('%d', [GetTimVersion(TIM)]); + tblTimInfo.Cells[1, 2] := Format('0x%.2x', [GetTimVersion(TIM)]); tblTimInfo.Cells[1, 3] := Format('%s', [TIMIsGoodStr(TIM)]); if TIMHasCLUT(TIM) then diff --git a/uscanresult.pas b/uscanresult.pas index 76230cd..0bda024 100644 --- a/uscanresult.pas +++ b/uscanresult.pas @@ -6,6 +6,7 @@ uses fgl; type TTimInfo = record + Magic: Byte; Position: Integer; Size: Integer; Width: Integer; @@ -94,4 +95,4 @@ begin end; end; -end. \ No newline at end of file +end. diff --git a/uscanthread.pas b/uscanthread.pas index 71e83fc..77ab927 100644 --- a/uscanthread.pas +++ b/uscanthread.pas @@ -65,6 +65,7 @@ procedure TScanThread.AddResult(TIM: PTIM); var ScanTim: TTimInfo; begin + ScanTim.Magic := TIM^.HEAD^.bMagic; ScanTim.Position := TIM^.dwTimPosition; ScanTim.Size := TIM^.dwSIZE; ScanTim.Width := GetTimRealWidth(TIM); @@ -221,4 +222,4 @@ begin end; end; -end. \ No newline at end of file +end. diff --git a/usettings.pas b/usettings.pas index 405b0d7..72856e8 100644 --- a/usettings.pas +++ b/usettings.pas @@ -26,11 +26,20 @@ type function FBitModeRead(): Integer; procedure FInfoVisibleWrite(Value: Boolean); function FInfoVisibleRead(): Boolean; + + {$IFDEF windows} + function FGetSendtoShortcutPath: WideString; + procedure FCreateSendtoShortcut; + function FSendtoShortcutExists: Boolean; + {$IFEND} public constructor Create(const DirPath: string); destructor Destroy; override; - procedure AssociateWithTims; + {$IFDEF windows} + procedure AddToSendTo(Delete: Boolean); + property SendToShortcutExists: Boolean read FSendtoShortcutExists; + {$IFEND} property TranspMode: Integer read FTranspModeRead write FTranspModeWrite; property StretchMode: Boolean read FStretchModeRead write FStretchModeWrite; @@ -45,44 +54,71 @@ implementation uses FileUtil {$IFDEF windows} -,registry +,windows, shlobj {for special folders}, ActiveX, ComObj {$IFEND} ; -const sMain = 'main'; +const + sMain = 'main'; + sSendtoShortcut : string = 'Open in Tim2View'; { TSettings } -procedure TSettings.AssociateWithTims; +procedure TSettings.AddToSendTo(Delete: Boolean); {$IFDEF windows} var - reg: TRegistry; + path: string; begin - reg := TRegistry.Create; - - try - reg.RootKey := HKEY_CURRENT_USER; - reg.OpenKey('Software\Classes\.tim', True); - reg.WriteString('', 'TimFile'); - reg.CloseKey; - - reg.OpenKey('Software\Classes\TimFile', True); - reg.WriteString('', 'Tim File Format'); - reg.CloseKey; - reg.OpenKey('Software\Classes\TimFile\DefaultIcon', True); - reg.WriteString('', '"' + ParamStr(0) +'",0'); - reg.CloseKey; - reg.OpenKey('Software\Classes\TimFile\shell\Open\Command', True); - reg.WriteString('', '"' + ParamStr(0) + '" "%1"'); - reg.CloseKey; - finally - reg.Free; - end; + if Delete then + begin + path := UTF8Encode(FGetSendtoShortcutPath); + DeleteFile(PChar(Utf8ToSys(path))); + end + else + FCreateSendtoShortcut; {$ELSE} begin {$ENDIF} end; +{$IFDEF windows} +function TSettings.FGetSendtoShortcutPath: WideString; +var + PIDL: PItemIDList; + InFolder: array[0..MAX_PATH] of Char; +begin + SHGetSpecialFolderLocation(0, CSIDL_SENDTO, PIDL); + SHGetPathFromIDList(PIDL, InFolder); + Result := InFolder + PathDelim + UTF8ToSys(sSendtoShortcut)+'.lnk'; +end; + +procedure TSettings.FCreateSendtoShortcut; +var + IObject: IUnknown; + ISLink: IShellLink; + IPFile: IPersistFile; + TargetPath: string; +begin + { Creates an instance of IShellLink } + IObject := CreateComObject(CLSID_ShellLink); + ISLink := IObject as IShellLink; + IPFile := IObject as IPersistFile; + + TargetPath := ParamStr(0); + ISLink.SetPath(pChar(TargetPath)); + ISLink.SetArguments(pChar('')); + ISLink.SetWorkingDirectory(pChar(ExtractFilePath(TargetPath))); + + { Create the link } + IPFile.Save(PWChar(FGetSendtoShortcutPath), false); +end; + +function TSettings.FSendtoShortcutExists: Boolean; +begin + Result := FileExists(FGetSendtoShortcutPath); +end; +{$ENDIF} + procedure TSettings.FTranspModeWrite(Value: Integer); begin FIniFile.WriteInteger(sMain, 'TranspMode', Value); diff --git a/utim.pas b/utim.pas index 261b8da..1fdf91a 100644 --- a/utim.pas +++ b/utim.pas @@ -7,6 +7,9 @@ uses const cTIMMagic = $10; + cCLTMagic = $11; + cPXLMagic = $12; + cMagics = [cTIMMagic, cCLTMagic, cPXLMagic]; cTIM4C = $08; cTIM4NC = $00; cTIM4 = [cTIM4C, cTIM4NC]; @@ -19,12 +22,16 @@ const cTIM24C = $0B; cTIM24NC = $03; cTIM24 = [cTIM24C, cTIM24NC]; - cTIMMix = $04; + cTIMMixC = $0C; + cTIMMixNC = $04; + cTIMMix = [cTIMMixC, cTIMMixNC]; cTIMVersions = [$00, $01]; - cTIMWrongBads = [cTIM4NC, cTIM8NC, cTIMMix]; - cTIMCLUT = [cTIM4C, cTIM8C, cTIM16C, cTIM24C]; - cTIMNOCLUT = [cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix]; - cTIMBpp = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix]; + cTIMWrongBads = [cTIM4NC, cTIM8NC]; + cTIMGoodCLTs = [cTIM16NC]; + cTIMGoodPXLs = [cTIM4NC, cTIM8NC]; + cTIMCLUT = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIMMixC]; + cTIMNOCLUT = [cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMixNC]; + cTIMBpp = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIMMixC, cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMixNC]; type TTIMHeader = packed record // TIM Header (8 bytes) @@ -34,7 +41,7 @@ type bReserved2: byte; // Reserved byte 2 (1 byte) bBPP: Integer; // Bit per Pixel (4 bytes) // variants: - // [$08, $09, $0A, $0B, $02, $03, $00, $01] + // [$08, $09, $0A, $0B, $0C, $00, $01, $02, $03, $04] end; PTIMHeader = ^TTIMHeader; @@ -112,6 +119,7 @@ function GetTimRealWidth(TIM: PTIM): word; function GetTimHeight(TIM: PTIM): word; function TIMIsGood(TIM: PTIM): Boolean; function TIMIsGoodStr(TIM: PTIM): string; +function TIMTypeStr(Magic: Byte): string; function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean; function LoadTimFromFile(const FileName: string; var Position: Integer; ImageScan: Boolean; dwSize: Integer): PTIM; procedure SaveTimToFile(const FileName: string; TIM: PTIM); @@ -198,7 +206,6 @@ end; function GetTIMCLUTSize(TIM: PTIM): Integer; begin Result := 0; - if not TIMHasCLUT(TIM) then Exit; Result := TIM^.CLUT^.wColorsCount * TIM^.CLUT^.wClutsCount * 2 + SizeOf(TCLUTHeader); end; @@ -220,7 +227,7 @@ end; function CheckMagic(TIM: PTIM): Boolean; begin - Result := (TIM^.HEAD^.bMagic = cTIMMagic); + Result := (TIM^.HEAD^.bMagic in cMagics); end; function CheckBpp(TIM: PTIM): Boolean; @@ -263,7 +270,7 @@ begin case TIM^.HEAD^.bBPP of cTIM4C, cTIM4NC: Result := (TIM^.IMAGE^.wWidth * 4) and $FFFF; cTIM8C, cTIM8NC: Result := (TIM^.IMAGE^.wWidth * 2) and $FFFF; - cTIM16C, cTIM16NC, cTIMMix: Result := TIM^.IMAGE^.wWidth; + cTIM16C, cTIM16NC, cTIMMixC, cTIMMixNC: Result := TIM^.IMAGE^.wWidth; cTIM24C, cTIM24NC: Result := (Round(TIM^.IMAGE^.wWidth * 2 / 3)) and $FFFF; else Result := 0; @@ -280,6 +287,11 @@ begin Result := CheckCLUTColors(TIM) and CheckCLUTCount(TIM) and CheckCLUTVramX(TIM) and CheckCLUTVramY(TIM); end; +function TIMIsNotWrongBad(TIM: PTIM): Boolean; +begin + Result := (not(TIM^.HEAD^.bBPP in cTIMWrongBads)) or TIMIsGood(TIM); +end; + function CheckTIMSize(TIM: PTIM): Boolean; begin Result := (GetTIMSize(TIM) <= cTIMMaxSize); @@ -313,8 +325,26 @@ end; function CheckIMAGE(TIM: PTIM): Boolean; begin Result := CheckIMAGEWidth(TIM) and CheckIMAGEHeight(TIM) and CheckIMAGEVramX(TIM) and CheckIMAGEVramY(TIM); +end; - Result := Result and ((not(TIM^.HEAD^.bBPP in cTIMWrongBads)) or TIMIsGood(TIM)); +function CheckTIM(TIM: PTIM): Boolean; +begin + Result := (TIM^.HEAD^.bMagic = cTIMMagic); +end; + +function CheckCLT(TIM: PTIM): Boolean; +begin + Result := (TIM^.HEAD^.bMagic = cCLTMagic) and (TIM^.HEAD^.bBPP in cTIMGoodCLTs); +end; + +function CheckPXL(TIM: PTIM): Boolean; +begin + Result := (TIM^.HEAD^.bMagic = cPXLMagic) and (TIM^.HEAD^.bBPP in cTIMGoodPXLs); +end; + +function CheckTimCltPxl(TIM: PTIM): Boolean; +begin + Result := (CheckTIM(TIM) or CheckCLT(TIM) or CheckPXL(TIM)) and CheckIMAGE(TIM) and TIMIsNotWrongBad(TIM); end; procedure ClearTIM(TIM: PTIM); @@ -330,6 +360,17 @@ begin if TIMIsGood(TIM) then Result := 'Yes' else Result := 'No'; end; +function TIMTypeStr(Magic: Byte): string; +begin + case Magic of + cTIMMagic: Result := 'tim'; + cCLTMagic: Result := 'clt'; + cPXLMagic: Result := 'pxl'; + else + Result := 'unk'; + end; +end; + function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean; var P: Integer; @@ -356,7 +397,7 @@ begin Move(PBytesArray(BUFFER)^[P], TIM^.IMAGE^, SizeOf(TIMAGEHeader)); - if not CheckIMAGE(TIM) then Exit; + if not CheckTimCltPxl(TIM) then Exit; if not CheckTIMSize(TIM) then Exit; TIM^.dwSize := GetTIMSize(TIM); @@ -527,7 +568,7 @@ begin Result := 24; Exit; end; - if (TIM^.HEAD^.bBPP = cTIMMix) then + if (TIM^.HEAD^.bBPP in cTIMMix) then begin Result := 16; Exit; @@ -594,4 +635,4 @@ begin Result := TIM^.IMAGE^.wVRAMY; end; -end. \ No newline at end of file +end.