-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathextend.c
More file actions
77 lines (73 loc) · 2.06 KB
/
extend.c
File metadata and controls
77 lines (73 loc) · 2.06 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
/*
* Simple program to modify the volume directory (block 2) of a ProDOS
* volume to make the directory extensible to more than four blocks (51
* entries) when using ProDOS 2.5 or later. This program can also revert
* a volume with an extensible volume directory back to fixed-size directory
* provided the directory is still exactly 4 blocks in length.
*
* Bobbi
* March 2020
*/
#include <prodos.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
char buf[512];
char str[128]; /* Should be enough */
int main(int argc, char *argv[]) {
puts("ProDOS 2.5+ Volume Directory Patching Utility");
puts("---------------------------------------------");
fputs("\nEnter device number> ", stdout);
int dev;
scanf("%u", &dev);
BlockRec br;
br.blockDevNum = dev;
br.blockDataBuffer = buf;
br.blockNum = 2;
READ_BLOCK(&br);
int rc = toolerror();
if (rc) {
printf("Block read failed, err=%x\n", rc);
exit(255);
}
if ((buf[0x14] == 0) && (buf[0x15] == 0)) {
puts("Fixed-size (4 block, 51 entry) volume directory");
printf("Change to ProDOS 2.5+ extensible volume "
"directory ('yes' to confirm)?");
scanf("%s", str);
if (strcasecmp(str, "yes") == 0) {
buf[0x14] = 4;
buf[0x15] = 0;
WRITE_BLOCK(&br);
int rc = toolerror();
if (rc) {
printf("Block write failed, err=%x\n", rc);
exit(255);
}
puts("** Changed to extensible **");
} else
puts("No change made.");
} else {
printf("Extensible volume directory, currently %u blocks\n",
buf[0x14] + 256U * buf[0x15]);
if ((buf[0x14] == 4) && (buf[0x15] == 0)) {
printf("Revert to classic ProDOS fixed-size volume "
"directory ('yes' to confirm)?");
scanf("%s", str);
if (strcasecmp(str, "yes") == 0) {
buf[0x14] = 0;
buf[0x15] = 0;
WRITE_BLOCK(&br);
int rc = toolerror();
if (rc) {
printf("Block write failed, err=%x\n",
rc);
exit(255);
}
puts("** Changed to fixed-size **");
} else
puts("No change made.");
}
}
return 0;
}