Skip to content

Commit 9cf9e6a

Browse files
committed
amiga app
0 parents  commit 9cf9e6a

File tree

6 files changed

+713
-0
lines changed

6 files changed

+713
-0
lines changed

fmmain.lfm

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
object Form1: TForm1
2+
Left = 745
3+
Height = 285
4+
Top = 419
5+
Width = 585
6+
BorderStyle = bsDialog
7+
Caption = 'HunksterGUI v1.0 By RetroNick'
8+
ClientHeight = 285
9+
ClientWidth = 585
10+
OnCreate = FormCreate
11+
LCLVersion = '2.0.10.0'
12+
object InfoLabel: TLabel
13+
AnchorSideLeft.Control = Owner
14+
AnchorSideTop.Control = Owner
15+
AnchorSideRight.Control = Owner
16+
AnchorSideRight.Side = asrBottom
17+
Left = 0
18+
Height = 28
19+
Top = 0
20+
Width = 585
21+
Alignment = taCenter
22+
Anchors = [akTop, akLeft, akRight]
23+
AutoSize = False
24+
Color = clAppWorkspace
25+
Font.Color = clWhite
26+
Font.Height = 29
27+
ParentColor = False
28+
ParentFont = False
29+
Transparent = False
30+
OptimalFill = True
31+
end
32+
object EditFileName: TEdit
33+
Left = 96
34+
Height = 23
35+
Top = 64
36+
Width = 272
37+
Enabled = False
38+
TabOrder = 1
39+
end
40+
object EditDataName: TEdit
41+
Left = 96
42+
Height = 23
43+
Top = 112
44+
Width = 160
45+
MaxLength = 20
46+
TabOrder = 2
47+
end
48+
object EditSizeName: TEdit
49+
Left = 96
50+
Height = 23
51+
Top = 160
52+
Width = 160
53+
MaxLength = 20
54+
TabOrder = 3
55+
end
56+
object MemoryGroup: TRadioGroup
57+
Left = 400
58+
Height = 130
59+
Top = 62
60+
Width = 168
61+
AutoFill = True
62+
Caption = 'Memory Type'
63+
ChildSizing.LeftRightSpacing = 6
64+
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
65+
ChildSizing.EnlargeVertical = crsHomogenousChildResize
66+
ChildSizing.ShrinkHorizontal = crsScaleChilds
67+
ChildSizing.ShrinkVertical = crsScaleChilds
68+
ChildSizing.Layout = cclLeftToRightThenTopToBottom
69+
ChildSizing.ControlsPerLine = 1
70+
ClientHeight = 110
71+
ClientWidth = 164
72+
ItemIndex = 0
73+
Items.Strings = (
74+
'Any'
75+
'Chip'
76+
'Fast'
77+
)
78+
OnClick = MemoryGroupClick
79+
TabOrder = 5
80+
end
81+
object SaveAs: TButton
82+
Left = 480
83+
Height = 25
84+
Top = 232
85+
Width = 75
86+
Caption = 'Save As'
87+
OnClick = SaveAsClick
88+
TabOrder = 6
89+
end
90+
object InFile: TButton
91+
Left = 8
92+
Height = 25
93+
Top = 64
94+
Width = 75
95+
Caption = 'In File'
96+
OnClick = InFileClick
97+
TabOrder = 0
98+
end
99+
object Label2: TLabel
100+
Left = 31
101+
Height = 15
102+
Top = 120
103+
Width = 59
104+
Caption = 'Data Name'
105+
ParentColor = False
106+
end
107+
object Label3: TLabel
108+
Left = 8
109+
Height = 15
110+
Top = 168
111+
Width = 82
112+
Caption = 'Data Size Name'
113+
ParentColor = False
114+
end
115+
object EditHunkName: TEdit
116+
Left = 96
117+
Height = 23
118+
Top = 203
119+
Width = 160
120+
MaxLength = 20
121+
TabOrder = 4
122+
end
123+
object Label4: TLabel
124+
Left = 26
125+
Height = 15
126+
Top = 208
127+
Width = 64
128+
Caption = 'Hunk Name'
129+
ParentColor = False
130+
end
131+
object OpenDialog: TOpenDialog
132+
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
133+
Left = 544
134+
end
135+
object SaveDialog: TSaveDialog
136+
Options = [ofOverwritePrompt, ofEnableSizing, ofViewDetail]
137+
Left = 472
138+
end
139+
end

fmmain.pas

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
unit fmmain;
2+
3+
{$mode objfpc}{$H+}
4+
5+
interface
6+
7+
uses
8+
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,LazFileUtils,hunklib;
9+
10+
type
11+
12+
{ TForm1 }
13+
14+
TForm1 = class(TForm)
15+
SaveAs: TButton;
16+
InFile: TButton;
17+
EditFileName: TEdit;
18+
EditDataName: TEdit;
19+
EditSizeName: TEdit;
20+
EditHunkName: TEdit;
21+
InfoLabel: TLabel;
22+
Label2: TLabel;
23+
Label3: TLabel;
24+
Label4: TLabel;
25+
OpenDialog: TOpenDialog;
26+
MemoryGroup: TRadioGroup;
27+
SaveDialog: TSaveDialog;
28+
procedure MemoryGroupClick(Sender: TObject);
29+
procedure SaveAsClick(Sender: TObject);
30+
procedure InFileClick(Sender: TObject);
31+
procedure FormCreate(Sender: TObject);
32+
private
33+
MemLoad : Longword;
34+
IncludeFileSize : boolean;
35+
function ValidFields : boolean;
36+
procedure CreateHunkFile;
37+
procedure UpdateHunkInfo;
38+
public
39+
40+
end;
41+
42+
var
43+
Form1: TForm1;
44+
45+
implementation
46+
47+
{$R *.lfm}
48+
49+
{ TForm1 }
50+
51+
function TForm1.ValidFields : boolean;
52+
begin
53+
result:=false;
54+
if EditFileName.Text = '' then
55+
begin
56+
ShowMessage('No File Selected');
57+
end
58+
else if EditDataName.Text = '' then
59+
begin
60+
ShowMessage('Data Name cannot be empty');
61+
end
62+
else if EditHunkName.Text = '' then
63+
begin
64+
ShowMessage('Hunk Name cannot be empty');
65+
end
66+
else
67+
begin
68+
result:=true;
69+
end;
70+
end;
71+
72+
procedure TForm1.UpdateHunkInfo;
73+
begin
74+
case MemoryGroup.ItemIndex of 0:begin
75+
MemLoad:=ANY_MEM;
76+
EditHunkName.Text:='ANYMEM';
77+
end;
78+
1:begin
79+
MemLoad:=CHIP_MEM;
80+
EditHunkName.Text:='CHIPMEM';
81+
end;
82+
2:begin
83+
MemLoad:=FAST_MEM;
84+
EditHunkName.Text:='FASTMEM';
85+
end;
86+
end;
87+
if EditSizeName.Text<>'' then IncludeFileSize:=true else IncludeFileSize:=false;
88+
end;
89+
90+
procedure TForm1.CreateHunkFile;
91+
var
92+
outF : File;
93+
error : word;
94+
size : longword;
95+
begin
96+
if SaveDialog.Execute = false then exit;
97+
{$I-}
98+
System.Assign(outF,SaveDialog.FileName);
99+
System.Rewrite(outF,1);
100+
101+
WriteHunkUnit(outF);
102+
WriteHunkName(outF,EditHunkName.Text);
103+
size:=WriteHunkData(outF,MemLoad,OpenDialog.Filename,IncludeFileSize);
104+
WriteHunkExt(outF,EditDataName.Text);
105+
if IncludeFileSize then WriteHunkExtSize(outF,EditSizeName.Text,size);
106+
WriteHunkEnd(outF);
107+
system.close(outF);
108+
error:=IORESULT;
109+
{$I+}
110+
if error=0 then
111+
begin
112+
InfoLabel.Caption:='New hunk successfully created and saved!';
113+
end
114+
else
115+
begin
116+
InfoLabel.Caption:='Ouch it looks like we had booboo!';
117+
end;
118+
end;
119+
120+
procedure TForm1.FormCreate(Sender: TObject);
121+
begin
122+
end;
123+
124+
procedure TForm1.SaveAsClick(Sender: TObject);
125+
begin
126+
if ValidFields then CreateHunkFile;
127+
end;
128+
129+
procedure TForm1.MemoryGroupClick(Sender: TObject);
130+
begin
131+
UpdateHunkInfo;
132+
end;
133+
134+
procedure TForm1.InFileClick(Sender: TObject);
135+
var
136+
sname : string;
137+
begin
138+
// 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|*.*';
139+
if OpenDialog.Execute then
140+
begin
141+
InfoLabel.Caption:='';
142+
EditFileName.Text:=OpenDialog.FileName;
143+
sname:=LowerCase(ExtractFileName(ExtractFileNameWithoutExt(OpenDialog.FileName)));
144+
EditDataName.Text:='_'+sname;
145+
EditSizeName.Text:='_'+sname+'_size';
146+
UpdateHunkInfo;
147+
end;
148+
end;
149+
150+
151+
152+
end.
153+

0 commit comments

Comments
 (0)