Skip to content

Commit 4f94bd8

Browse files
committed
Update to support TMT Pascal Compiler
1 parent 2df15c5 commit 4f94bd8

File tree

4 files changed

+152
-35
lines changed

4 files changed

+152
-35
lines changed

objlib.pas

Lines changed: 90 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ procedure Write_PubDefRecords(var F : File; BaseGroupIndex: byte; BaseSegmentInd
3939
Function CreateTPObj(infile,outfile,publicname : string) : word;
4040
Function CreateTPObj(infile,outfile,publicname,publicsizename : string) : word;
4141

42+
Function CreateTMTObj(infile,outfile,publicname : string) : word;
43+
Function CreateTMTObj(infile,outfile,publicname,publicsizename : string) : word;
44+
4245
Function CreateTCObj(infile,outfile,publicname,segname,classname : string;UseFswitch : Boolean) : word;
4346
Function CreateTCObj(infile,outfile,publicname,publicsizename,segname,classname : string;UseFswitch : Boolean) : word;
4447

@@ -489,7 +492,7 @@ procedure Write_LeData32(var F : File;SegmentIndex : Byte;EnumeratedDataOffset :
489492
FreeMem(recordPtr, dataLength + 5);
490493
end;
491494

492-
procedure Write_SegmentData32(var F : File; SegmentIndex: byte; EnumeratedDataOffset: longword; dataBytes : PByte; dataLength: word);
495+
procedure Write_SegmentData32(var F : File; SegmentIndex: byte; EnumeratedDataOffset: longword; dataBytes : PByte; dataLength: longword);
493496
begin
494497
while (dataLength > 1024) do
495498
begin
@@ -515,6 +518,19 @@ function GetFileSize(filename : string) : longword;
515518
{$I+}
516519
end;
517520

521+
function GetFileSize32(filename : string) : longword;
522+
var
523+
F : File;
524+
begin
525+
Assign(F,filename);
526+
{$I-}
527+
Reset(F,1);
528+
result:=FileSize(F);
529+
close(F);
530+
{$I+}
531+
end;
532+
533+
518534
Procedure Write_FileContents(var F : File;filename : string;segIdx: byte; dataOffset: word);
519535
var
520536
size : longword;
@@ -603,6 +619,26 @@ function GetFileSize(filename : string) : longword;
603619
end;
604620

605621

622+
procedure ChangePubDefStr(index : byte;var data; PublicName : string; PublicOffset : word; typeindex : byte);
623+
var
624+
DataA : array[1..255] of TPubDefStrRec absolute data;
625+
begin
626+
dataA[index].StringLength:=length(publicname);
627+
dataA[index].PubLicName:=publicname;
628+
dataA[index].PublicOffset:=publicoffset;
629+
dataA[index].TypeIndex:=typeindex;
630+
end;
631+
632+
procedure ChangePubDefStr32(index : byte;var data; PublicName : string; PublicOffset : longword; typeindex : byte);
633+
var
634+
DataA : array[1..255] of TPubDefStrRec32 absolute data;
635+
begin
636+
dataA[index].StringLength:=length(publicname);
637+
dataA[index].PubLicName:=publicname;
638+
dataA[index].PublicOffset:=publicoffset;
639+
dataA[index].TypeIndex:=typeindex;
640+
end;
641+
606642

607643
// create Turbo Pascal Compatile BINOBJ output exactly to the byte level
608644
Function CreateTPObj(infile,outfile,publicname : string) : word;
@@ -625,51 +661,86 @@ function GetFileSize(filename : string) : longword;
625661
result:=IORESULT;
626662
end;
627663

628-
procedure ChangePubDefStr(index : byte;var data; PublicName : string; PublicOffset : word; typeindex : byte);
664+
665+
Function CreateTPObj(infile,outfile,publicname,publicsizename : string) : word;
629666
var
630-
DataA : array[1..255] of TPubDefStrRec absolute data;
667+
size : word;
668+
F : File;
669+
data : array[1..2] of TPubDefStrRec;
631670
begin
632-
dataA[index].StringLength:=length(publicname);
633-
dataA[index].PubLicName:=publicname;
634-
dataA[index].PublicOffset:=publicoffset;
635-
dataA[index].TypeIndex:=typeindex;
671+
size:=WORD(GetFileSize(infile));
672+
{$I-}
673+
assign(F,outfile);
674+
rewrite(F,1);
675+
Write_THeadr(F,#$3a#$3a);
676+
Write_LNames(F,'#CODE##');
677+
Write_SegDef(F,$28,size+2,2,1,1); //+2 is the addtional bytes we will need to include the size information
678+
679+
ChangePubDefStr(1,data,publicname,0,0);
680+
ChangePubDefStr(2,data,publicsizename,size,0);
681+
Write_PubDefRecords(F,0,1,data,2);
682+
683+
Write_FileContentsAndSize(F,infile,1,0);
684+
Write_ModEnd(F);
685+
close(F);
686+
{$I+}
687+
result:=IORESULT;
636688
end;
637689

638-
procedure ChangePubDefStr32(index : byte;var data; PublicName : string; PublicOffset : longword; typeindex : byte);
690+
691+
692+
693+
Function CreateTMTObj(infile,outfile,publicname : string) : word;
639694
var
640-
DataA : array[1..255] of TPubDefStrRec32 absolute data;
695+
size : longword;
696+
F : File;
641697
begin
642-
dataA[index].StringLength:=length(publicname);
643-
dataA[index].PubLicName:=publicname;
644-
dataA[index].PublicOffset:=publicoffset;
645-
dataA[index].TypeIndex:=typeindex;
698+
size:=GetFileSize32(infile);
699+
{$I-}
700+
assign(F,outfile);
701+
rewrite(F,1);
702+
Write_THeadr(F,#$3a#$3a);
703+
Write_LNames(F,'#CODE##');
704+
Write_SegDef32(F,$28,size,2,1,1);
705+
Write_PubDef(F,0,1,publicname,0,0);
706+
Write_FileContents32(F,infile,1,0);
707+
Write_ModEnd(F);
708+
close(F);
709+
{$I+}
710+
result:=IORESULT;
646711
end;
647712

648-
Function CreateTPObj(infile,outfile,publicname,publicsizename : string) : word;
713+
714+
//public size name will not work TMT Pascal. we can only store 2 bytes for size instead of 4
715+
//tmt compiler would need to understand option 91h
716+
Function CreateTMTObj(infile,outfile,publicname,publicsizename : string) : word;
649717
var
650-
size : word;
718+
size : longword;
651719
F : File;
652720
data : array[1..2] of TPubDefStrRec;
653721
begin
654-
size:=WORD(GetFileSize(infile));
722+
size:=GetFileSize32(infile);
655723
{$I-}
656724
assign(F,outfile);
657725
rewrite(F,1);
658726
Write_THeadr(F,#$3a#$3a);
659727
Write_LNames(F,'#CODE##');
660-
Write_SegDef(F,$28,size+2,2,1,1); //+2 is the addtional bytes we will need to include the size information
728+
Write_SegDef32(F,$28,size+4,2,1,1); //+4 is the addtional bytes we will need to include the size information
661729

662730
ChangePubDefStr(1,data,publicname,0,0);
663-
ChangePubDefStr(2,data,publicsizename,size,0);
731+
ChangePubDefStr(2,data,publicsizename,size,0); // <---we are doomed here
664732
Write_PubDefRecords(F,0,1,data,2);
665733

666-
Write_FileContentsAndSize(F,infile,1,0);
734+
Write_FileContentsAndSize32(F,infile,1,0);
667735
Write_ModEnd(F);
668736
close(F);
669737
{$I+}
670738
result:=IORESULT;
671739
end;
672740

741+
742+
743+
673744
// Turbo C's BGIOBJ /F switch inserts another LName that is the same as the public name
674745
// eg default is _TEXT CODE, if public name is _IMAGE, LName section becomes IMAGE_TEXT CODE
675746
// /F switch has not used when segname is provided

rtbinobj.pas

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
{$IFDEF UNIX}{$IFDEF UseCThreads}
88
cthreads,
99
{$ENDIF}{$ENDIF}
10-
Classes, SysUtils, CustApp,
10+
Classes, SysUtils, CustAPP,
1111
objlib,hunklib,bsavelib,cofflib;
1212

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

1616
CompTP = 0;
1717
CompTC = 1;
@@ -20,6 +20,8 @@
2020
CompAmigaHunk = 4;
2121
CompBSAVE = 5;
2222
CompCOFF = 6;
23+
CompTMT = 7;
24+
2325
type
2426
{ RtBinObj }
2527

@@ -43,6 +45,7 @@ function GetCompModeName(Compiler : integer) : string;
4345
CompAmigaHunk:result:='Amiga Hunk Mode';
4446
CompBSAVE:result:='QuickBasic\GWBASIC BSAVE Mode';
4547
CompCOFF:result:='COFF 32bit Mode';
48+
CompTMT:result:='TMT Pascal Obj Mode';
4649

4750
end;
4851
end;
@@ -89,6 +92,7 @@ procedure TRTBinObj.DoRun;
8992
'HUNK':CompilerMode:=CompAmigaHunk;
9093
'BSAVE':CompilerMode:=CompBSAVE;
9194
'COFF':CompilerMode:=CompCOFF;
95+
'TMT':CompilerMode:=CompTMT;
9296

9397
end;
9498

@@ -195,8 +199,13 @@ procedure TRTBinObj.DoRun;
195199
begin
196200
error:=CreateCOFF(infile,outfile,publicname,publicsizename,FALSE);
197201
end;
202+
end
203+
else if CompilerMode = CompTMT then
204+
begin
205+
error:=CreateTMTObj(infile,outfile,publicname);
198206
end;
199207

208+
200209
if error = 0 then writeln('Converted Successfully using ',GetCompModeName(CompilerMode)) else writeln('Looks like we have an error# ',error);
201210

202211
// stop program loop
@@ -220,7 +229,7 @@ procedure TRTBinObj.WriteHelp;
220229
writeln(programname);
221230
writeln('Usage: RtBinObj infile outfile public_name');
222231
writeln(' Optional -PS public size name');
223-
writeln(' -O OBJ Mode {TP,TC,OW16,OW32,HUNK,BSAVE,COFF}');
232+
writeln(' -O OBJ Mode {TP,TC,TMT,OW16,OW32,HUNK,BSAVE,COFF}');
224233
writeln(' -SN segment name');
225234
writeln(' -CN class name');
226235
writeln(' -HN hunk name (Amiga 68k)');

rtbinobjform.lfm

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
object Form1: TForm1
22
Left = 491
3-
Height = 431
3+
Height = 459
44
Top = 358
55
Width = 746
66
AllowDropFiles = True
77
BorderIcons = [biSystemMenu, biMinimize]
8-
ClientHeight = 431
8+
ClientHeight = 459
99
ClientWidth = 746
1010
Color = clForm
1111
OnCreate = FormCreate
@@ -68,7 +68,7 @@ object Form1: TForm1
6868
object SaveAsButton: TButton
6969
Left = 640
7070
Height = 25
71-
Top = 376
71+
Top = 408
7272
Width = 75
7373
Caption = 'Save As'
7474
OnClick = SaveAsButtonClick
@@ -129,7 +129,7 @@ object Form1: TForm1
129129
end
130130
object ObjModeRadioGroup: TRadioGroup
131131
Left = 491
132-
Height = 177
132+
Height = 200
133133
Hint = 'Turbo Pascal Mode compatible with QuickPascal and FreePascal 8086'#13#10'Turbo C Mode compatible QuickC'
134134
Top = 64
135135
Width = 224
@@ -142,7 +142,7 @@ object Form1: TForm1
142142
ChildSizing.ShrinkVertical = crsScaleChilds
143143
ChildSizing.Layout = cclLeftToRightThenTopToBottom
144144
ChildSizing.ControlsPerLine = 1
145-
ClientHeight = 157
145+
ClientHeight = 180
146146
ClientWidth = 220
147147
ItemIndex = 0
148148
Items.Strings = (
@@ -153,6 +153,7 @@ object Form1: TForm1
153153
'Amiga 68k Hunk (vbcc / freepascal)'
154154
'QuickBasic/GWBASIC (bsave)'
155155
'COFF 32 bit'
156+
'TMT Pascal OBJ'
156157
)
157158
OnClick = ObjModeRadioGroupClick
158159
ParentShowHint = False
@@ -173,10 +174,10 @@ object Form1: TForm1
173174
TabOrder = 6
174175
end
175176
object AmigaMemRadioGroup: TRadioGroup
176-
Left = 491
177+
Left = 494
177178
Height = 96
178-
Top = 256
179-
Width = 185
179+
Top = 280
180+
Width = 221
180181
AutoFill = True
181182
Caption = 'Amiga Memory Type'
182183
ChildSizing.LeftRightSpacing = 6
@@ -187,7 +188,7 @@ object Form1: TForm1
187188
ChildSizing.Layout = cclLeftToRightThenTopToBottom
188189
ChildSizing.ControlsPerLine = 1
189190
ClientHeight = 76
190-
ClientWidth = 181
191+
ClientWidth = 217
191192
Enabled = False
192193
ItemIndex = 0
193194
Items.Strings = (
@@ -199,10 +200,10 @@ object Form1: TForm1
199200
TabOrder = 8
200201
end
201202
object OpenDialog: TOpenDialog
202-
Left = 440
203+
Left = 640
203204
end
204205
object SaveDialog: TSaveDialog
205206
Options = [ofOverwritePrompt, ofEnableSizing, ofViewDetail]
206-
Left = 509
207+
Left = 688
207208
end
208209
end

rtbinobjform.pas

Lines changed: 38 additions & 2 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.6 By RetroNick - Released May 22 - 2023';
12+
ProgramName = 'RtBinObj v1.7 By RetroNick - Released December 21 - 2023';
1313

1414
type
1515

@@ -46,6 +46,9 @@ TForm1 = class(TForm)
4646
function ValidFields : boolean;
4747
procedure SetPublicNames;
4848
procedure CreateTPOBJFile;
49+
50+
procedure CreateTMTOBJFile;
51+
4952
procedure CreateTCOBJFile;
5053
procedure CreateOBJFile;
5154
procedure CreateOWDOS32OBJFile;
@@ -241,7 +244,19 @@ procedure TForm1.ObjModeRadioGroupClick(Sender: TObject);
241244
AmigaMemRadioGroup.Enabled:=false;
242245
FarCallCheckbox.Enabled:=false;
243246
FarCallCheckbox.Checked:=false;
244-
end;
247+
end
248+
else if ObjModeRadioGroup.ItemIndex = 7 then
249+
begin
250+
EditPublicName.Enabled:=true;
251+
EditPublicSizeName.Enabled:=false;
252+
EditSegmentName.Enabled:=false;
253+
EditClassName.Enabled:=false;
254+
SegmentNameLabel.Caption:='Segment Name';
255+
256+
AmigaMemRadioGroup.Enabled:=false;
257+
FarCallCheckbox.Enabled:=false;
258+
FarCallCheckbox.Checked:=false;
259+
end;
245260
end;
246261

247262
procedure TForm1.SaveAsButtonClick(Sender: TObject);
@@ -289,6 +304,26 @@ procedure TForm1.CreateTPOBJFile;
289304
end;
290305
end;
291306

307+
procedure TForm1.CreateTMTOBJFile;
308+
var
309+
error : word;
310+
begin
311+
InfoLabel.Caption:='We are In correct area';
312+
if EditPublicSizeName.Text<>'' then
313+
error:=CreateTMTObj(OpenDialog.Filename,SaveDialog.FileName,EditPublicName.Text,EditPublicSizeName.Text)
314+
else
315+
error:=CreateTMTObj(OpenDialog.Filename,SaveDialog.FileName,EditPublicName.Text);
316+
317+
if error=0 then
318+
begin
319+
InfoLabel.Caption:='New Obj successfully created and saved!';
320+
end
321+
else
322+
begin
323+
InfoLabel.Caption:='Ouch it looks like we had booboo #'+IntToStr(error);
324+
end;
325+
end;
326+
292327
procedure TForm1.CreateTCOBJFile;
293328
var
294329
error : word;
@@ -414,6 +449,7 @@ procedure TForm1.CreateOBJFile;
414449
4:CreateAmigaHunkFile;
415450
5:CreateBSaveFile;
416451
6:CreateCOFFFile;
452+
7:CreateTMTObjFile;
417453

418454
end;
419455
end;

0 commit comments

Comments
 (0)