@@ -39,6 +39,9 @@ procedure Write_PubDefRecords(var F : File; BaseGroupIndex: byte; BaseSegmentInd
3939Function CreateTPObj (infile,outfile,publicname : string) : word;
4040Function 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+
4245Function CreateTCObj (infile,outfile,publicname,segname,classname : string;UseFswitch : Boolean) : word;
4346Function 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 );
490493end ;
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 );
493496begin
494497 while (dataLength > 1024 ) do
495498 begin
@@ -515,6 +518,19 @@ function GetFileSize(filename : string) : longword;
515518{ $I+}
516519end ;
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+
518534Procedure Write_FileContents (var F : File ;filename : string;segIdx: byte; dataOffset: word);
519535var
520536 size : longword;
@@ -603,6 +619,26 @@ function GetFileSize(filename : string) : longword;
603619end ;
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
608644Function CreateTPObj (infile,outfile,publicname : string) : word;
@@ -625,51 +661,86 @@ function GetFileSize(filename : string) : longword;
625661 result:=IORESULT;
626662end ;
627663
628- procedure ChangePubDefStr (index : byte;var data; PublicName : string; PublicOffset : word; typeindex : byte);
664+
665+ Function CreateTPObj (infile,outfile,publicname,publicsizename : string) : word;
629666var
630- DataA : array [1 ..255 ] of TPubDefStrRec absolute data;
667+ size : word;
668+ F : File ;
669+ data : array [1 ..2 ] of TPubDefStrRec;
631670begin
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;
636688end ;
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;
639694var
640- DataA : array [1 ..255 ] of TPubDefStrRec32 absolute data;
695+ size : longword;
696+ F : File ;
641697begin
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;
646711end ;
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;
649717var
650- size : word ;
718+ size : longword ;
651719 F : File ;
652720 data : array [1 ..2 ] of TPubDefStrRec;
653721begin
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;
671739end ;
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
0 commit comments