Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroNick2020 committed May 19, 2023
1 parent 11246b9 commit 33c29f4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
4 changes: 2 additions & 2 deletions rtbinsrcfm.lfm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Form1: TForm1
Left = 513
Left = 502
Height = 560
Top = 401
Top = 400
Width = 858
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsDialog
Expand Down
38 changes: 32 additions & 6 deletions rtbinsrcfm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface
LazFileUtils, SpinEx,rtcodegen;

Const
ProgramName = 'RtBinSrc v1.1 By RetroNick - Released May 9 - 2023';
ProgramName = 'RtBinSrc v1.2 By RetroNick - Released May 19 - 2023';

type

Expand Down Expand Up @@ -52,6 +52,7 @@ TForm1 = class(TForm)
Lan : integer;
Format : integer;
NumType : integer;
Processing : boolean;

procedure SetBasicTypes;
procedure SetGWBasicTypes;
Expand Down Expand Up @@ -122,11 +123,17 @@ procedure TForm1.SaveAsClick(Sender: TObject);
procedure FMemoAppend(msg : string);
begin
Form1.MemoWithCode.Append(msg);
if (Form1.CG.LineCount Mod 50) = 0 then
begin
Form1.InfoLabel.Caption:='Imported '+IntToStr(Form1.CG.LineCount)+' Lines';
Application.ProcessMessages;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Caption:=ProgramName;
Processing:=False;
SetBasicTypes;
CGInit(CG);
CGSetLineNumber(CG,LineStartSpinEdit.Value,LineStepsSpinEdit.Value);
Expand All @@ -137,12 +144,26 @@ procedure TForm1.ImportClick(Sender: TObject);
var
error : word;
begin
if Processing then
begin
//ShowMessage('Processing Previous Import');
//InfoLabel.Caption:='Import Canceled';
Import.Caption:='Import'; //rename cancel back to import
CGSetImportStatus(CG,FALSE);
Processing:=FALSE;
exit;
end;

if EditArrayName.Text='' then
begin
ShowMessage('Array Name Field Cannot be blank');
exit;
end;

Import.Caption:='Cancel'; //rename import button to cancel
Processing:=True;
CGReset(CG);
//CGSetImportStatus(CG,TRUE);
CGSetIndent(CG,indentSpinedit.Value);
CGSetValuesPerLine(CG,ItemsPerLineSpinEdit.Value);
InfoLabel.Caption:='';
Expand All @@ -156,14 +177,19 @@ procedure TForm1.ImportClick(Sender: TObject);
if error<>0 then
begin
ShowMessage('Error Importing File ');
exit;
end
else
begin
if CG.ImportStatus then InfoLabel.Caption:='File Imported Successfully' else InfoLabel.Caption:='File Import Canceled';
end;

InfoLabel.Caption:='File Imported';
Processing:=False;
Import.Caption:='Import'; //rename cancel back to import
end;

procedure TForm1.InFileClick(Sender: TObject);
begin
if Processing then exit;

// 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|*.*';
if OpenDialog.Execute then
begin
Expand All @@ -176,6 +202,7 @@ procedure TForm1.InFileClick(Sender: TObject);

procedure TForm1.LanRadioGroupClick(Sender: TObject);
begin
if Processing then exit;
case LanRadioGroup.ItemIndex of 0:SetBasicTypes;
1:SetGWBasicTypes;
2:SetCTypes;
Expand All @@ -185,11 +212,11 @@ procedure TForm1.LanRadioGroupClick(Sender: TObject);

procedure TForm1.CopyToClipboardClick(Sender: TObject);
begin
if Processing then exit;
MemoWithCode.SelectAll;
MemoWithCode.CopyToClipboard;
MemoWithCode.SelLength:=0;
InfoLabel.Caption:='Code Copied to Clipboard';

end;

procedure TForm1.FormatRadioGroupClick(Sender: TObject);
Expand Down Expand Up @@ -223,7 +250,6 @@ procedure TForm1.SetGWBasicTypes;
IndentSpinEdit.Enabled:=false;
LineStartSpinEdit.Enabled:=true;
LineStepsSpinEdit.Enabled:=true;

end;

procedure TForm1.SetPascalTypes;
Expand Down
32 changes: 20 additions & 12 deletions rtcodegen.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ interface
ValueFormatDecimal = 0;
ValueFormatHex = 1;




c_char_signed = 1;
c_char_unsigned = 2;
c_int_signed = 3;
Expand Down Expand Up @@ -54,9 +51,10 @@ interface
LineCount : integer; //line counter
LanId : integer;

LineBufStr : String;
NextLineNumber : integer;
StepNumber : integer;
LineBufStr : String;
NextLineNumber : integer;
StepNumber : integer;
ImportStatus : boolean;

end;

Expand All @@ -79,6 +77,8 @@ procedure CGSetMemoProc(MP : MemoProc);
procedure CGWrite(var mc : CodeGenRec ; Msg : string);
procedure CGWriteLn(var mc : CodeGenRec);

procedure CGSetImportStatus(var mc : CodeGenRec;status : boolean);

function ImportBinFile(var mc : CodeGenRec;filename,aname : string;Lan,DataType,nformat : integer) : word;

implementation
Expand Down Expand Up @@ -141,6 +141,7 @@ procedure CGInit(var mc : CodeGenRec);
mc.LineBufStr:='';
mc.NextLineNumber:=1000;
mc.StepNumber:=10;
mc.ImportStatus:=TRUE;
CGSetIndent(mc,10);
CGSetIndentOnFirstLine(mc,true);
CGSetValuesPerLine(mc,10);
Expand All @@ -153,16 +154,22 @@ procedure CGInit(var mc : CodeGenRec);
//Reset VC and VCL - used for Repeated Imports for GWBASIC
procedure CGReset(var mc : CodeGenRec);
begin
mc.VC:=0;
mc.VCL:=0;
mc.LineCount:=0;
mc.LineBufStr:='';
mc.VC:=0;
mc.VCL:=0;
mc.LineCount:=0;
mc.LineBufStr:='';
mc.ImportStatus:=True;
end;

procedure CGSetImportStatus(var mc : CodeGenRec;status : boolean);
begin
mc.ImportStatus:=Status;
end;

Procedure CGSetLineNumber(var mc : CodeGenRec;Num : integer;StepNum : integer);
begin
mc.NextLineNumber:=Num;
mc.StepNumber:=StepNum;
mc.NextLineNumber:=Num;
mc.StepNumber:=StepNum;
end;

function CGGetGWNextLineNumber(var mc :CodeGenRec) : integer;
Expand Down Expand Up @@ -408,6 +415,7 @@ procedure ConvertToCode(var mc : CodeGenRec;aname : string;var data; asize : lon

for i:=0 to asize-1 do
begin
if mc.ImportStatus = FALSE then exit;
Case BitSize of BitSize8:CGWriteNumber(mc,BData[i],DataType);
BitSize16:CGWriteNumber(mc,WData[i],DataType);
BitSize32:CGWriteNumber(mc,LData[i],DataType);
Expand Down

0 comments on commit 33c29f4

Please sign in to comment.