-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuNBTapes.pas
More file actions
218 lines (189 loc) · 4.8 KB
/
uNBTapes.pas
File metadata and controls
218 lines (189 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{
Grundy NewBrain Emulator Pro Made by Despsoft
Copyright (c) 2004-Today , Despoinidis Chris
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
}
unit uNBTapes;
interface
uses classes;
Type
TTapeInfo = Class
private
FCurrentFile: Integer;
FDirectory: String;
FTapeName: String;
procedure UpdateVI;
procedure SetDirectory(const Value: String);
procedure setCurrentFile(const Value: Integer);
procedure setTapeName(const Value: String);
public
Files: Tstringlist;
TapeNo: Integer;
Constructor Create;
Destructor Destroy; Override;
Function GetFileName: string;
Procedure NextFile;
Procedure PrevFile;
Procedure FirstFile;
Procedure Lastfile;
procedure LoadTape(Tpnm: String);
function TapeLoaded: Boolean;
procedure Eject;
function GetNextFileName: string;
procedure AddFile(fn: String);
property TapeName: string read FTapeName write setTapeName;
property CurrentFile: Integer read FCurrentFile write setCurrentFile;
property Directory: String read FDirectory write SetDirectory;
End;
// Var TapeInfo:TTapeInfo=nil;
implementation
uses sysutils, new, forms, dialogs;
constructor TTapeInfo.Create;
begin
Files := Tstringlist.Create;
Directory := '';
FCurrentFile := -1;
end;
destructor TTapeInfo.Destroy;
begin
Files.free;
inherited;
end;
procedure TTapeInfo.setCurrentFile(const Value: Integer);
begin
if FCurrentFile <> Value then
begin
FCurrentFile := Value;
UpdateVI;
end;
end;
procedure TTapeInfo.setTapeName(const Value: String);
begin
if FTapeName <> Value then
begin
FTapeName := Value;
UpdateVI;
end;
end;
procedure TTapeInfo.AddFile(fn: String);
begin
if Files.indexof(fn) = -1 then
Begin
Files.Add(ExtractFileName(fn));
Files.SaveToFile(Directory + '\_Dir.txt');
End;
end;
procedure TTapeInfo.Eject;
begin
LoadTape('');
Directory := '';
if TapeNo = 1 then
fnewbrain.lblTape1Info2.Caption := 'No Tape'
else
fnewbrain.lblTape2Info2.Caption := 'No Tape';
end;
procedure TTapeInfo.FirstFile;
begin
CurrentFile := 0;
end;
function TTapeInfo.GetFileName: string;
begin
Result := Directory + '\' + Files[CurrentFile];
end;
function TTapeInfo.GetNextFileName: string;
begin
if CurrentFile = -1 then
Result := 'Noname'
else
begin
if Files.Count > 0 then
Result := Files[CurrentFile]
else
Result := '';
end;
end;
procedure TTapeInfo.Lastfile;
begin
CurrentFile := Files.Count - 1;
end;
procedure TTapeInfo.UpdateVI;
Begin
if TapeNo = 1 then
begin
fnewbrain.lblTape1Info.Caption := GetNextFileName;
fnewbrain.lblTape1Info.Hint := fnewbrain.lblTape1Info.Caption;
fnewbrain.lblTape1Info2.Caption := TapeName;
fnewbrain.lblTape1Info2.Hint := fnewbrain.lblTape1Info2.Caption;
end
else
Begin
fnewbrain.lblTape2Info.Caption := GetNextFileName;
fnewbrain.lblTape2Info.Hint := fnewbrain.lblTape2Info.Caption;
fnewbrain.lblTape2Info2.Caption := TapeName;
fnewbrain.lblTape2Info2.Hint := fnewbrain.lblTape2Info2.Caption;
End;
End;
// Load the _dir.txt that has the order of the files on virtual tape
procedure TTapeInfo.LoadTape(Tpnm: String);
var
fnm: String;
begin
Files.clear;
TapeName := Tpnm;
if Tpnm <> '' then
Begin
Directory := extractfilepath(Application.exename) + 'Basic\' + Tpnm;
fnm := Directory + '\_Dir.txt';
if fileexists(fnm) then
Begin
Files.LoadFromFile(fnm);
CurrentFile := 0;
End
else
Begin
ShowMessage('Invalid Tape Directory');
Directory := '';
End;
// else create a default maybe
End
Else
CurrentFile := -1;
end;
procedure TTapeInfo.NextFile;
begin
if CurrentFile < (Files.Count - 1) then
CurrentFile := CurrentFile + 1
else
CurrentFile := 0;
end;
procedure TTapeInfo.PrevFile;
begin
if CurrentFile > 0 then
CurrentFile := CurrentFile - 1
else
CurrentFile := Files.Count - 1;
end;
procedure TTapeInfo.SetDirectory(const Value: String);
begin
if FDirectory <> Value then
begin
if (Value <> '') and (Value[Length(Value)] <> '\') then
FDirectory := Value + '\'
else
FDirectory := Value;
end;
end;
function TTapeInfo.TapeLoaded: Boolean;
begin
Result := Directory <> '';
end;
end.