Skip to content

Commit 2df15c5

Browse files
committed
drag and drop support
1 parent 50021d4 commit 2df15c5

File tree

4 files changed

+52
-30
lines changed

4 files changed

+52
-30
lines changed

cofflib.pas

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,13 @@ implementation
5050
end;
5151

5252
TCOFFSymbolTableArray = array[1..2] of TCOFFSymbolTable;
53-
var
54-
coff_header: TCOFFHeader;
55-
section_headers: TCOFFSectionHeader;
56-
section_data: TMemoryStream;
57-
section_data_size: LongWord;
58-
out_file: TFileStream;
59-
string_symbol_table : TCOFFSymbolTableArray;
60-
string_table : TCOFFStringTable;
6153

6254
procedure SetHeader(var H : TCOFFHeader;fsize : LongWord;UseFileSizeSymbol : boolean);
6355
begin
6456
// Set the COFF header fields
65-
H.Machine := $14C;
57+
H.Machine :=$14C; // for 64bit $8664
6658
H.NumberOfSections := 1;
67-
H.TimeDateStamp := DateTimeToUnix(Now);
59+
H.TimeDateStamp :=DateTimeToUnix(Now);
6860
H.PointerToSymbolTable := SizeOf(TCOFFHeader) + SizeOf(TCOFFSectionHeader)+((4+fsize+15) div 16)*16; // rounded to LongWords
6961
if UseFileSizeSymbol then H.NumberOfSymbols := 2 else H.NumberOfSymbols := 1; //name and name_size
7062
H.SizeOfOptionalHeader := 0;
@@ -83,7 +75,7 @@ procedure setsectionheader(var SH : TCOFFSectionHeader; fsize : LongWord);
8375
SH.PointerToLinenumbers := 0;
8476
SH.NumberOfRelocations := 0;
8577
SH.NumberOfLinenumbers := 0;
86-
SH.Characteristics := $40;
78+
SH.Characteristics :=$40;
8779
end;
8880

8981
procedure SetStringValues(var STA : TCOFFSymbolTableArray;stable : word;offset,value : longword;sectionnumber,stype :word; StorageClass,AuxSymbols : byte);
@@ -153,7 +145,6 @@ procedure WriteStringTable(var F:File;var STRT : TCOFFStringTable);
153145
Function CreateCOFF(inFile,OutFile,PublicName,publicsizename : String; UseFileSizeSymbol : Boolean) : word;
154146
var
155147
inF,OutF : File;
156-
error : word;
157148
InFileSize : Longword;
158149
H : TCOFFHeader;
159150
SH : TCOFFSectionHeader;

rtbinobj.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
objlib,hunklib,bsavelib,cofflib;
1212

1313
Const
14-
ProgramName = 'RtBinObj v1.5 - Released May 17 - 2023 By RetroNick';
14+
ProgramName = 'RtBinObj v1.6 - Released May 22 - 2023 By RetroNick';
1515

1616
CompTP = 0;
1717
CompTC = 1;

rtbinobjform.lfm

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ object Form1: TForm1
22
Left = 491
33
Height = 431
44
Top = 358
5-
Width = 669
5+
Width = 746
6+
AllowDropFiles = True
7+
BorderIcons = [biSystemMenu, biMinimize]
68
ClientHeight = 431
7-
ClientWidth = 669
9+
ClientWidth = 746
810
Color = clForm
911
OnCreate = FormCreate
12+
OnDropFiles = FormDropFiles
1013
LCLVersion = '2.0.10.0'
1114
object InFileButton: TButton
1215
Left = 24
@@ -21,7 +24,7 @@ object Form1: TForm1
2124
Left = 120
2225
Height = 23
2326
Top = 56
24-
Width = 248
27+
Width = 352
2528
Enabled = False
2629
TabOrder = 1
2730
end
@@ -50,7 +53,7 @@ object Form1: TForm1
5053
Left = 0
5154
Height = 32
5255
Top = 0
53-
Width = 669
56+
Width = 746
5457
Alignment = taCenter
5558
Anchors = [akTop, akLeft, akRight]
5659
AutoSize = False
@@ -63,7 +66,7 @@ object Form1: TForm1
6366
OptimalFill = True
6467
end
6568
object SaveAsButton: TButton
66-
Left = 552
69+
Left = 640
6770
Height = 25
6871
Top = 376
6972
Width = 75
@@ -125,10 +128,10 @@ object Form1: TForm1
125128
TabOrder = 5
126129
end
127130
object ObjModeRadioGroup: TRadioGroup
128-
Left = 384
131+
Left = 491
129132
Height = 177
130133
Hint = 'Turbo Pascal Mode compatible with QuickPascal and FreePascal 8086'#13#10'Turbo C Mode compatible QuickC'
131-
Top = 56
134+
Top = 64
132135
Width = 224
133136
AutoFill = True
134137
Caption = 'OBJ Mode'
@@ -170,9 +173,9 @@ object Form1: TForm1
170173
TabOrder = 6
171174
end
172175
object AmigaMemRadioGroup: TRadioGroup
173-
Left = 384
176+
Left = 491
174177
Height = 96
175-
Top = 248
178+
Top = 256
176179
Width = 185
177180
AutoFill = True
178181
Caption = 'Amiga Memory Type'

rtbinobjform.pas

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface
99
LazFileUtils, objlib,hunklib,bsavelib,cofflib;
1010

1111
Const
12-
ProgramName = 'RtBinObj v1.5 By RetroNick - Released May 17 - 2023';
12+
ProgramName = 'RtBinObj v1.6 By RetroNick - Released May 22 - 2023';
1313

1414
type
1515

@@ -36,13 +36,15 @@ TForm1 = class(TForm)
3636
procedure AmigaMemRadioGroupClick(Sender: TObject);
3737
procedure FarCallCheckBoxChange(Sender: TObject);
3838
procedure FormCreate(Sender: TObject);
39+
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
3940
procedure InFileButtonClick(Sender: TObject);
4041
procedure ObjModeRadioGroupClick(Sender: TObject);
4142
procedure SaveAsButtonClick(Sender: TObject);
4243
private
4344
MemLoad : Longword;
4445

4546
function ValidFields : boolean;
47+
procedure SetPublicNames;
4648
procedure CreateTPOBJFile;
4749
procedure CreateTCOBJFile;
4850
procedure CreateOBJFile;
@@ -65,16 +67,11 @@ implementation
6567

6668
{ TForm1 }
6769

68-
procedure TForm1.InFileButtonClick(Sender: TObject);
70+
procedure TForm1.SetPublicNames;
6971
var
7072
sname : string;
7173
begin
72-
// OpenDialog.Filter := 'Windows BMP|*.bmp|PNG|*.png|PC Paintbrush |*.pcx|DP-Amiga IFF LBM|*.lbm|DP-Amiga IFF BBM Brush|*.bbm|GIF|*.gif|RM RAW Files|*.raw|All Files|*.*';
73-
if OpenDialog.Execute then
74-
begin
75-
InfoLabel.Caption:='';
76-
EditFileName.Text:=OpenDialog.FileName;
77-
if ObjModeRadioGroup.ItemIndex = 0 then
74+
if ObjModeRadioGroup.ItemIndex = 0 then
7875
begin
7976
sname:=UpperCase(ExtractFileName(ExtractFileNameWithoutExt(OpenDialog.FileName)));
8077
EditPublicName.Text:=sname;
@@ -86,6 +83,16 @@ procedure TForm1.InFileButtonClick(Sender: TObject);
8683
EditPublicName.Text:='_'+sname;
8784
EditPublicSizeName.Text:='_'+sname+'size';
8885
end;
86+
end;
87+
88+
procedure TForm1.InFileButtonClick(Sender: TObject);
89+
begin
90+
// OpenDialog.Filter := 'Windows BMP|*.bmp|PNG|*.png|PC Paintbrush |*.pcx|DP-Amiga IFF LBM|*.lbm|DP-Amiga IFF BBM Brush|*.bbm|GIF|*.gif|RM RAW Files|*.raw|All Files|*.*';
91+
if OpenDialog.Execute then
92+
begin
93+
InfoLabel.Caption:='';
94+
EditFileName.Text:=OpenDialog.FileName;
95+
SetPublicNames;
8996
end;
9097
end;
9198

@@ -127,6 +134,27 @@ procedure TForm1.FormCreate(Sender: TObject);
127134
Caption:=ProgramName;
128135
end;
129136

137+
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String);
138+
begin
139+
if High(Filenames) > 0 then
140+
begin
141+
ShowMessage('Drag only one file!');
142+
exit;
143+
end;
144+
145+
if FileExists(FileNames[0]) then
146+
begin
147+
OpenDialog.FileName:=FileNames[0];
148+
EditFileName.Caption:=FileNames[0];
149+
SetPublicNames;
150+
end
151+
else
152+
begin
153+
ShowMessage('Invalid File/Directory!');
154+
exit;
155+
end;
156+
end;
157+
130158
procedure TForm1.ObjModeRadioGroupClick(Sender: TObject);
131159
begin
132160
if ObjModeRadioGroup.ItemIndex = 0 then

0 commit comments

Comments
 (0)