ProjectOptionsUnit.pas 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. unit ProjectOptionsUnit;
  2. interface
  3. uses
  4. MasterUnit, ParsingUnit, ProgramOptionsUnit,
  5. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  6. StdCtrls, ExtCtrls, ComCtrls;
  7. type
  8. TProjectOptionsForm = class(TForm)
  9. OKButton: TButton;
  10. CancelButton: TButton;
  11. PageController: TPageControl;
  12. GeneralSheet: TTabSheet;
  13. CompilationSheet: TTabSheet;
  14. LinkingSheet: TTabSheet;
  15. PostBuildSheet: TTabSheet;
  16. TargetGroupBox: TGroupBox;
  17. PackVarEditLabel: TLabel;
  18. ExecutableRadioButton: TRadioButton;
  19. FlashOSRadioButton: TRadioButton;
  20. FargoRadioButton: TRadioButton;
  21. ArchiveRadioButton: TRadioButton;
  22. PackCheckBox: TCheckBox;
  23. PackVarEdit: TEdit;
  24. SwitchesGroupBox: TGroupBox;
  25. GCCSwitchesEditLabel: TLabel;
  26. GCCSwitchesEdit: TEdit;
  27. AsSwitchesEditLabel: TLabel;
  28. AsSwitchesEdit: TEdit;
  29. AsmSwitchesEditLabel: TLabel;
  30. AsmSwitchesEdit: TEdit;
  31. DebugInfoCheckBox: TCheckBox;
  32. OptimizationGroupBox: TGroupBox;
  33. OptimizeNOPsCheckBox: TCheckBox;
  34. OptimizeReturnsCheckBox: TCheckBox;
  35. OptimizeBranchesCheckBox: TCheckBox;
  36. OptimizeMovesCheckBox: TCheckBox;
  37. OptimizeTestsCheckBox: TCheckBox;
  38. OptimizeCalculationsCheckBox: TCheckBox;
  39. RemoveUnusedSectionsCheckBox: TCheckBox;
  40. ReorderSectionsCheckBox: TCheckBox;
  41. CutUnusedRangesCheckBox: TCheckBox;
  42. StdLibCheckBox: TCheckBox;
  43. OutputBinCheckBox: TCheckBox;
  44. BrowseDialog: TOpenDialog;
  45. ProcessFileGroupBox: TGroupBox;
  46. ProcessFileEditLabel: TLabel;
  47. ProcessFileEdit: TEdit;
  48. BrowseButton: TButton;
  49. ExecutionGroupBox: TGroupBox;
  50. CommandLineEditLabel: TLabel;
  51. CommandLineEdit: TEdit;
  52. DataVarCheckBox: TCheckBox;
  53. DataVarEditLabel: TLabel;
  54. DataVarEdit: TEdit;
  55. DataVarCopyLabel: TLabel;
  56. DataVarCopyPanel: TPanel;
  57. DataVarCopyNeverRadioButton: TRadioButton;
  58. DataVarCopyIfArchivedRadioButton: TRadioButton;
  59. DataVarCopyAlwaysRadioButton: TRadioButton;
  60. ProgramOptionsButton: TButton;
  61. MergeConstantsCheckBox: TCheckBox;
  62. InitBSSCheckBox: TCheckBox;
  63. procedure FormDestroy(Sender: TObject);
  64. procedure FormShow(Sender: TObject);
  65. procedure DataVarCheckBoxClick(Sender: TObject);
  66. procedure PackCheckBoxClick(Sender: TObject);
  67. procedure VarEditChange(Sender: TObject);
  68. procedure TargetRadioButtonClick(Sender: TObject);
  69. procedure BrowseButtonClick(Sender: TObject);
  70. procedure ProgramOptionsButtonClick(Sender: TObject);
  71. private
  72. public
  73. InitialLibOptions: TPredefinedLibOptions;
  74. ProgramOptionsForm: TProgramOptionsForm;
  75. end;
  76. implementation
  77. {$R *.DFM}
  78. uses
  79. CalcUnit,
  80. MainUnit;
  81. procedure TProjectOptionsForm.FormDestroy(Sender: TObject);
  82. begin
  83. if Assigned (ProgramOptionsForm) then
  84. ProgramOptionsForm.Free;
  85. end;
  86. procedure TProjectOptionsForm.FormShow(Sender: TObject);
  87. begin
  88. TargetRadioButtonClick (Sender);
  89. end;
  90. procedure TProjectOptionsForm.DataVarCheckBoxClick(Sender: TObject);
  91. begin
  92. DataVarEdit.Enabled := DataVarCheckBox.Checked;
  93. DataVarEditLabel.Enabled := DataVarEdit.Enabled;
  94. DataVarCopyPanel.Enabled := DataVarEdit.Enabled;
  95. DataVarCopyNeverRadioButton.Enabled := DataVarEdit.Enabled;
  96. DataVarCopyIfArchivedRadioButton.Enabled := DataVarEdit.Enabled;
  97. DataVarCopyAlwaysRadioButton.Enabled := DataVarEdit.Enabled;
  98. DataVarCopyLabel.Enabled := DataVarEdit.Enabled;
  99. VarEditChange (Sender);
  100. end;
  101. procedure TProjectOptionsForm.PackCheckBoxClick(Sender: TObject);
  102. begin
  103. PackVarEdit.Enabled := PackCheckBox.Checked;
  104. PackVarEditLabel.Enabled := PackVarEdit.Enabled;
  105. VarEditChange (Sender);
  106. end;
  107. procedure TProjectOptionsForm.VarEditChange(Sender: TObject);
  108. var
  109. S: string;
  110. I: Integer;
  111. OK,
  112. HasFolder: Boolean;
  113. begin
  114. if PackCheckBox.Checked then begin
  115. S := PackVarEdit.Text;
  116. OK := (Length (S) > 0) and (Length (S) <= 8) and (IsCharAlpha (S [1]) or (S [1] in ['A'..'Z', 'a'..'z'])) and (LowerCase (S) <> LowerCase (MainForm.TopNode.Text));
  117. if OK then
  118. for I := Length (S) downto 1 do
  119. if (not (IsCharAlphaNumeric (S [I]) or (S [I] in ['A'..'Z', 'a'..'z', '0'..'9', '_']))) or ((I = 1) and (S [I] = '_')) then begin
  120. OK := False;
  121. Break;
  122. end;
  123. end else
  124. OK := True;
  125. if OK then begin
  126. if DataVarCheckBox.Checked then begin
  127. S := DataVarEdit.Text;
  128. if PackCheckBox.Checked and (LowerCase (DataVarEdit.Text) = LowerCase (PackVarEdit.Text)) then
  129. OK := False
  130. else begin
  131. OK := (Length (S) > 0) and (IsCharAlpha (S [1]) or (S [1] in ['A'..'Z', 'a'..'z'])) and (LowerCase (S) <> LowerCase (MainForm.TopNode.Text));
  132. if OK then begin
  133. HasFolder := False;
  134. for I := Length (S) downto 1 do begin
  135. if S [I] = '\' then begin
  136. if HasFolder then begin
  137. OK := False;
  138. Break;
  139. end else
  140. HasFolder := True;
  141. end else if (not (IsCharAlphaNumeric (S [I]) or (S [I] in ['A'..'Z', 'a'..'z', '0'..'9', '_']))) or ((I = 1) and (S [I] = '_')) then begin
  142. OK := False;
  143. Break;
  144. end;
  145. end;
  146. I := Pos ('\', S);
  147. if I > 0 then begin
  148. if (I - 1 > MaxNameLength) or (Length (S) - I > MaxNameLength) or (I + 1 > Length (S)) or (not (IsCharAlpha (S [I + 1]) or (S [I + 1] in ['A'..'Z', 'a'..'z']))) then
  149. OK := False;
  150. end else begin
  151. if Length (S) > MaxNameLength then
  152. OK := False;
  153. end;
  154. end;
  155. end;
  156. end;
  157. end;
  158. OKButton.Enabled := OK;
  159. end;
  160. procedure TProjectOptionsForm.TargetRadioButtonClick(Sender: TObject);
  161. begin
  162. LinkingSheet.TabVisible := ExecutableRadioButton.Checked or FlashOSRadioButton.Checked or FargoRadioButton.Checked;
  163. PostBuildSheet.TabVisible := LinkingSheet.TabVisible;
  164. DataVarCheckBox.Enabled := ExecutableRadioButton.Checked and (ssPack in SpecialSupport);
  165. if not DataVarCheckBox.Enabled then
  166. DataVarCheckBox.Checked := False;
  167. PackCheckBox.Enabled := ExecutableRadioButton.Checked and (ssPack in SpecialSupport);
  168. if not PackCheckBox.Enabled then
  169. PackCheckBox.Checked := False;
  170. OutputBinCheckBox.Enabled := not FlashOSRadioButton.Checked;
  171. if not OutputBinCheckBox.Enabled then
  172. OutputBinCheckBox.Checked := True;
  173. DataVarCheckBoxClick (Sender);
  174. PackCheckBoxClick (Sender);
  175. ProgramOptionsButton.Visible := ExecutableRadioButton.Checked;
  176. end;
  177. procedure TProjectOptionsForm.BrowseButtonClick(Sender: TObject);
  178. var
  179. S: string;
  180. begin
  181. with BrowseDialog do begin
  182. S := ProcessFileEdit.Text;
  183. if (Length (S) > 0) and ((S [1] = '"') or (Pos (' ', S) <= 0)) then begin
  184. if S [1] = '"' then begin
  185. Delete (S, 1, 1);
  186. if Pos ('"', S) > 0 then
  187. Delete (S, Pos ('"', S), Length (S));
  188. end;
  189. FileName := S;
  190. end;
  191. if Execute then
  192. ProcessFileEdit.Text := '"' + FileName + '" "($TI89File)" "($TI92PlusFile)" "($V200File)"';
  193. end;
  194. end;
  195. procedure TProjectOptionsForm.ProgramOptionsButtonClick(Sender: TObject);
  196. begin
  197. if not Assigned (ProgramOptionsForm) then begin
  198. ProgramOptionsForm := TProgramOptionsForm.Create(Self);
  199. if Assigned (InitialLibOptions) then
  200. with ProgramOptionsForm, InitialLibOptions do begin
  201. TI89CheckBox.Checked := cdTI89 in CalcDests;
  202. TI92PlusCheckBox.Checked := cdTI92Plus in CalcDests;
  203. V200CheckBox.Checked := cdV200 in CalcDests;
  204. OptimizeCalcConstsCheckBox.Checked := OptimizeCalcConsts;
  205. case KernelFormat of
  206. kfNone: NoStubRadioButton.Checked := True;
  207. kfStandard: DoorsRadioButton.Checked := True;
  208. kfCompressedTables: PreOsRadioButton.Checked := True;
  209. end;
  210. MinAMSCheckBox.Checked := UseMinAMS;
  211. MinAMSEdit.Text := MinAMS;
  212. UnofficialOSSupportCheckBox.Checked := UnofficialOSSupport;
  213. case RelocFormat of
  214. rfAMS: RelocAMSRadioButton.Checked := True;
  215. rfKernel: RelocKernelRadioButton.Checked := True;
  216. rfCompressed: RelocCompressedRadioButton.Checked := True;
  217. rfMlink: RelocMlinkRadioButton.Checked := True;
  218. end;
  219. case ROMCallFormat of
  220. rfDirect: ROMCallDirectRadioButton.Checked := True;
  221. rfKernel: ROMCallKernelRadioButton.Checked := True;
  222. rfCompressed: ROMCallCompressedRadioButton.Checked := True;
  223. rfMlink: ROMCallMlinkRadioButton.Checked := True;
  224. rfFLine: ROMCallFLineRadioButton.Checked := True;
  225. end;
  226. case BSSRefFormat of
  227. rfNone: BSSMergeRadioButton.Checked := True;
  228. rfKernel: BSSKernelRadioButton.Checked := True;
  229. rfCompressed: BSSCompressedRadioButton.Checked := True;
  230. rfMlink: BSSMlinkRadioButton.Checked := True;
  231. end;
  232. case DataRefFormat of
  233. rfKernel: DataVarKernelRadioButton.Checked := True;
  234. rfCompressed: DataVarCompressedRadioButton.Checked := True;
  235. rfMlink: DataVarMlinkRadioButton.Checked := True;
  236. end;
  237. RelocFLineJumpsCheckBox.Checked := UseFLineJumps;
  238. RelocFLineJumps4ByteCheckBox.Checked := Use4ByteFLineJumps;
  239. ROMCallOptimizedCheckBox.Checked := OptimizeROMCalls;
  240. InternalFLineEmulatorCheckBox.Checked := UseInternalFLineEmulator;
  241. if UseReturnValue then
  242. ReturnValueRadioButton.Checked := True
  243. else
  244. ReturnDoneRadioButton.Checked := True;
  245. EnableErrorReturnCheckBox.Checked := EnableErrorReturn;
  246. LCDSaveCheckBox.Checked := SaveScreen;
  247. end;
  248. end;
  249. ProgramOptionsForm.ShowModal;
  250. end;
  251. end.