line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "diskimage.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#define DIRECTORY_FILENAME_LENGTH 16 |
8
|
|
|
|
|
|
|
#define DISKDRIVE_STATUS_LENGTH 80 |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
MODULE = D64::Disk::Image PACKAGE = D64::Disk::Image |
11
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# my $diskImage = di_load_image($name); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
DiskImage* |
16
|
|
|
|
|
|
|
di_load_image(name) |
17
|
|
|
|
|
|
|
char *name |
18
|
|
|
|
|
|
|
CODE: |
19
|
1
|
|
|
|
|
|
RETVAL = di_load_image(name); |
20
|
|
|
|
|
|
|
OUTPUT: |
21
|
|
|
|
|
|
|
RETVAL |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# my $diskImage = di_create_image($name, $size); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
DiskImage* |
26
|
|
|
|
|
|
|
di_create_image(name, size); |
27
|
|
|
|
|
|
|
char *name |
28
|
|
|
|
|
|
|
int size |
29
|
|
|
|
|
|
|
CODE: |
30
|
28
|
|
|
|
|
|
RETVAL = di_create_image(name, size); |
31
|
|
|
|
|
|
|
OUTPUT: |
32
|
|
|
|
|
|
|
RETVAL |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# di_free_image($diskImage); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
void |
37
|
|
|
|
|
|
|
di_free_image(di) |
38
|
|
|
|
|
|
|
DiskImage *di |
39
|
|
|
|
|
|
|
CODE: |
40
|
29
|
|
|
|
|
|
di_free_image(di); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# di_sync($diskImage); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
void |
45
|
|
|
|
|
|
|
di_sync(di) |
46
|
|
|
|
|
|
|
DiskImage *di |
47
|
|
|
|
|
|
|
CODE: |
48
|
1
|
|
|
|
|
|
di_sync(di); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# my ($numstatus, $status) = di_status($diskImage); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
SV* |
53
|
|
|
|
|
|
|
di_status(di) |
54
|
|
|
|
|
|
|
DiskImage *di |
55
|
|
|
|
|
|
|
PREINIT: |
56
|
|
|
|
|
|
|
char *status; |
57
|
|
|
|
|
|
|
int numstatus, statuslen; |
58
|
|
|
|
|
|
|
PPCODE: |
59
|
3
|
|
|
|
|
|
New(1, status, DISKDRIVE_STATUS_LENGTH + 1, char); |
60
|
3
|
50
|
|
|
|
|
if (status == NULL) { |
61
|
0
|
|
|
|
|
|
Safefree(status); |
62
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
63
|
|
|
|
|
|
|
} |
64
|
3
|
|
|
|
|
|
memset(status, '\0', DISKDRIVE_STATUS_LENGTH + 1); |
65
|
3
|
|
|
|
|
|
PUSHs(sv_2mortal(newSViv(numstatus = di_status(di, status)))); |
66
|
3
|
|
|
|
|
|
statuslen = strlen(status); |
67
|
3
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv(status, statuslen))); |
68
|
3
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVnv(numstatus))); |
69
|
3
|
|
|
|
|
|
Safefree(status); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# my $numstatus = di_format($diskImage, $rawname, $rawid); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
int |
74
|
|
|
|
|
|
|
di_format(di, rawname, rawid) |
75
|
|
|
|
|
|
|
DiskImage *di |
76
|
|
|
|
|
|
|
unsigned char *rawname |
77
|
|
|
|
|
|
|
unsigned char *rawid |
78
|
|
|
|
|
|
|
CODE: |
79
|
23
|
|
|
|
|
|
RETVAL = di_format(di, rawname, rawid); |
80
|
|
|
|
|
|
|
OUTPUT: |
81
|
|
|
|
|
|
|
RETVAL |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# my $status = di_delete($diskImage, $rawPattern, $fileType); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
int |
86
|
|
|
|
|
|
|
di_delete(di, rawpattern, type) |
87
|
|
|
|
|
|
|
DiskImage *di |
88
|
|
|
|
|
|
|
unsigned char *rawpattern |
89
|
|
|
|
|
|
|
FileType type |
90
|
|
|
|
|
|
|
CODE: |
91
|
1
|
|
|
|
|
|
RETVAL = di_delete(di, rawpattern, type); |
92
|
|
|
|
|
|
|
OUTPUT: |
93
|
|
|
|
|
|
|
RETVAL |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# my $status = di_rename($diskImage, $oldRawName, $newRawName, $fileType); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
int |
98
|
|
|
|
|
|
|
di_rename(di, oldrawname, newrawname, type) |
99
|
|
|
|
|
|
|
DiskImage *di |
100
|
|
|
|
|
|
|
unsigned char *oldrawname |
101
|
|
|
|
|
|
|
unsigned char *newrawname |
102
|
|
|
|
|
|
|
FileType type |
103
|
|
|
|
|
|
|
CODE: |
104
|
2
|
|
|
|
|
|
RETVAL = di_rename(di, oldrawname, newrawname, type); |
105
|
|
|
|
|
|
|
OUTPUT: |
106
|
|
|
|
|
|
|
RETVAL |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# my $sectors = di_sectors_per_track($imageType, $track); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
int |
111
|
|
|
|
|
|
|
di_sectors_per_track(type, track) |
112
|
|
|
|
|
|
|
ImageType type |
113
|
|
|
|
|
|
|
int track |
114
|
|
|
|
|
|
|
CODE: |
115
|
6
|
|
|
|
|
|
RETVAL = di_sectors_per_track(type, track); |
116
|
|
|
|
|
|
|
OUTPUT: |
117
|
|
|
|
|
|
|
RETVAL |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# my $tracks = di_tracks($imageType); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
int |
122
|
|
|
|
|
|
|
di_tracks(type) |
123
|
|
|
|
|
|
|
ImageType type |
124
|
|
|
|
|
|
|
CODE: |
125
|
3
|
|
|
|
|
|
RETVAL = di_tracks(type); |
126
|
|
|
|
|
|
|
OUTPUT: |
127
|
|
|
|
|
|
|
RETVAL |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# my ($title, $id) = di_title($diskImage); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
SV* |
132
|
|
|
|
|
|
|
di_title(di) |
133
|
|
|
|
|
|
|
DiskImage *di |
134
|
|
|
|
|
|
|
PREINIT: |
135
|
|
|
|
|
|
|
unsigned char *title; |
136
|
|
|
|
|
|
|
unsigned char *id; |
137
|
|
|
|
|
|
|
PPCODE: |
138
|
2
|
|
|
|
|
|
title = di_title(di); |
139
|
2
|
|
|
|
|
|
id = title + 18; |
140
|
2
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv((const char *)title, 16))); |
141
|
2
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv((const char *)id, 5))); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# my $track_blocks_free = di_track_blocks_free($diskImage, $track); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
int |
146
|
|
|
|
|
|
|
di_track_blocks_free(di, track) |
147
|
|
|
|
|
|
|
DiskImage *di |
148
|
|
|
|
|
|
|
int track |
149
|
|
|
|
|
|
|
CODE: |
150
|
3
|
|
|
|
|
|
RETVAL = di_track_blocks_free(di, track); |
151
|
|
|
|
|
|
|
OUTPUT: |
152
|
|
|
|
|
|
|
RETVAL |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# my $is_ts_free = di_is_ts_free($diskImage, $track, $sector); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
int |
157
|
|
|
|
|
|
|
di_is_ts_free(di, track, sector) |
158
|
|
|
|
|
|
|
DiskImage *di |
159
|
|
|
|
|
|
|
int track |
160
|
|
|
|
|
|
|
int sector |
161
|
|
|
|
|
|
|
CODE: |
162
|
|
|
|
|
|
|
TrackSector ts; |
163
|
3
|
|
|
|
|
|
ts.track = (unsigned char)track; |
164
|
3
|
|
|
|
|
|
ts.sector = (unsigned char)sector; |
165
|
3
|
|
|
|
|
|
RETVAL = di_is_ts_free(di, ts); |
166
|
|
|
|
|
|
|
OUTPUT: |
167
|
|
|
|
|
|
|
RETVAL |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# di_alloc_ts($diskImage, $track, $sector); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
void |
172
|
|
|
|
|
|
|
di_alloc_ts(di, track, sector) |
173
|
|
|
|
|
|
|
DiskImage *di |
174
|
|
|
|
|
|
|
int track |
175
|
|
|
|
|
|
|
int sector |
176
|
|
|
|
|
|
|
CODE: |
177
|
|
|
|
|
|
|
TrackSector ts; |
178
|
4
|
|
|
|
|
|
ts.track = (unsigned char)track; |
179
|
4
|
|
|
|
|
|
ts.sector = (unsigned char)sector; |
180
|
4
|
|
|
|
|
|
di_alloc_ts(di, ts); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# di_free_ts($diskImage, $track, $sector); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
void |
185
|
|
|
|
|
|
|
di_free_ts(di, track, sector) |
186
|
|
|
|
|
|
|
DiskImage *di |
187
|
|
|
|
|
|
|
int track |
188
|
|
|
|
|
|
|
int sector |
189
|
|
|
|
|
|
|
CODE: |
190
|
|
|
|
|
|
|
TrackSector ts; |
191
|
2
|
|
|
|
|
|
ts.track = (unsigned char)track; |
192
|
2
|
|
|
|
|
|
ts.sector = (unsigned char)sector; |
193
|
2
|
|
|
|
|
|
di_free_ts(di, ts); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# my $rawname = di_rawname_from_name($name); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
SV* |
198
|
|
|
|
|
|
|
di_rawname_from_name(name) |
199
|
|
|
|
|
|
|
char *name |
200
|
|
|
|
|
|
|
PREINIT: |
201
|
|
|
|
|
|
|
int rawnamelen; |
202
|
|
|
|
|
|
|
unsigned char *rawname; |
203
|
|
|
|
|
|
|
PPCODE: |
204
|
57
|
|
|
|
|
|
New(1, rawname, DIRECTORY_FILENAME_LENGTH + 1, unsigned char); |
205
|
57
|
50
|
|
|
|
|
if (rawname == NULL) { |
206
|
0
|
|
|
|
|
|
Safefree(rawname); |
207
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
208
|
|
|
|
|
|
|
} |
209
|
57
|
|
|
|
|
|
PUSHs(sv_2mortal(newSViv(rawnamelen = di_rawname_from_name(rawname, name)))); |
210
|
57
|
|
|
|
|
|
rawname[DIRECTORY_FILENAME_LENGTH] = '\0'; |
211
|
57
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv((const char *)rawname, 0))); |
212
|
57
|
|
|
|
|
|
Safefree(rawname); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# my $name = di_name_from_rawname($rawname); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
SV* |
217
|
|
|
|
|
|
|
di_name_from_rawname(rawname) |
218
|
|
|
|
|
|
|
unsigned char *rawname |
219
|
|
|
|
|
|
|
PREINIT: |
220
|
|
|
|
|
|
|
int namelen; |
221
|
|
|
|
|
|
|
char *name; |
222
|
|
|
|
|
|
|
PPCODE: |
223
|
25
|
|
|
|
|
|
New(1, name, DIRECTORY_FILENAME_LENGTH + 1, char); |
224
|
25
|
50
|
|
|
|
|
if (name == NULL) { |
225
|
0
|
|
|
|
|
|
Safefree(name); |
226
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
227
|
|
|
|
|
|
|
} |
228
|
25
|
|
|
|
|
|
PUSHs(sv_2mortal(newSViv(namelen = di_name_from_rawname(name, rawname)))); |
229
|
25
|
|
|
|
|
|
name[DIRECTORY_FILENAME_LENGTH] = '\0'; |
230
|
25
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv(name, 0))); |
231
|
25
|
|
|
|
|
|
Safefree(name); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# my $blocksfree = _di_blocksfree($diskImage); |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
int |
236
|
|
|
|
|
|
|
_di_blocksfree(di) |
237
|
|
|
|
|
|
|
DiskImage *di |
238
|
|
|
|
|
|
|
CODE: |
239
|
0
|
|
|
|
|
|
RETVAL = di->blocksfree; |
240
|
|
|
|
|
|
|
OUTPUT: |
241
|
|
|
|
|
|
|
RETVAL |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# my $imageType = _di_type($diskImage); |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
ImageType |
246
|
|
|
|
|
|
|
_di_type(di) |
247
|
|
|
|
|
|
|
DiskImage *di |
248
|
|
|
|
|
|
|
CODE: |
249
|
0
|
|
|
|
|
|
RETVAL = di->type; |
250
|
|
|
|
|
|
|
OUTPUT: |
251
|
|
|
|
|
|
|
RETVAL |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
MODULE = D64::Disk::Image PACKAGE = D64::Disk::Image::File |
254
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# my $imageFile = di_open($diskImage, $rawname, $fileType, $mode); |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
ImageFile* |
259
|
|
|
|
|
|
|
di_open(di, rawname, type, mode) |
260
|
|
|
|
|
|
|
DiskImage *di |
261
|
|
|
|
|
|
|
unsigned char *rawname |
262
|
|
|
|
|
|
|
FileType type |
263
|
|
|
|
|
|
|
char *mode |
264
|
|
|
|
|
|
|
CODE: |
265
|
20
|
|
|
|
|
|
RETVAL = di_open(di, rawname, type, mode); |
266
|
20
|
100
|
|
|
|
|
if (RETVAL == NULL) |
267
|
3
|
|
|
|
|
|
XSRETURN_UNDEF; |
268
|
|
|
|
|
|
|
OUTPUT: |
269
|
|
|
|
|
|
|
RETVAL |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
# di_close($imageFile); |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
void |
274
|
|
|
|
|
|
|
di_close(imgfile) |
275
|
|
|
|
|
|
|
ImageFile *imgfile |
276
|
|
|
|
|
|
|
CODE: |
277
|
16
|
|
|
|
|
|
di_close(imgfile); |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
# my ($counter, $buffer) = di_read($imageFile, $maxlength); |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
SV* |
282
|
|
|
|
|
|
|
di_read(imgfile, len); |
283
|
|
|
|
|
|
|
ImageFile *imgfile |
284
|
|
|
|
|
|
|
int len |
285
|
|
|
|
|
|
|
PREINIT: |
286
|
|
|
|
|
|
|
unsigned char *buffer; |
287
|
|
|
|
|
|
|
int counter; |
288
|
|
|
|
|
|
|
PPCODE: |
289
|
3
|
|
|
|
|
|
New(1, buffer, len + 1, unsigned char); |
290
|
3
|
50
|
|
|
|
|
if (buffer == NULL) { |
291
|
0
|
|
|
|
|
|
Safefree(buffer); |
292
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
293
|
|
|
|
|
|
|
} |
294
|
3
|
|
|
|
|
|
memset(buffer, '\0', len + 1); |
295
|
3
|
|
|
|
|
|
PUSHs(sv_2mortal(newSViv(counter = di_read(imgfile, buffer, len)))); |
296
|
3
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv((const char *)buffer, counter))); |
297
|
3
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVnv(counter))); |
298
|
3
|
|
|
|
|
|
Safefree(buffer); |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# my $counter = di_write($imageFile, $buffer, $length); |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
int |
303
|
|
|
|
|
|
|
di_write(imgfile, buffer, len); |
304
|
|
|
|
|
|
|
ImageFile *imgfile |
305
|
|
|
|
|
|
|
unsigned char *buffer |
306
|
|
|
|
|
|
|
int len |
307
|
|
|
|
|
|
|
CODE: |
308
|
12
|
|
|
|
|
|
RETVAL = di_write(imgfile, buffer, len); |
309
|
|
|
|
|
|
|
OUTPUT: |
310
|
|
|
|
|
|
|
RETVAL |