-
Notifications
You must be signed in to change notification settings - Fork 1
/
SCP.bt
176 lines (155 loc) · 3.98 KB
/
SCP.bt
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
//------------------------------------------------
//--- 010 Editor v7.0 Binary Template
//
// File: SCP.bt
// Authors: Vasyl Tsvirkunov
// Natalia Portillo
// Version: 0.3
// Purpose: SuperCard Pro dump file format
// based on official format document.
// Category: Misc
// File Mask: *.scp
// ID Bytes: 53 43 50 //SCP
// History:
// 0.3 2017-12-05 Natalia Portillo: Updated for v1.6 file format
// 0.2 2016-03-29 Vasyl Tsvirkunov: Updated for v7 compliancy
// 0.1 2014-11-08 Vasyl Tsvirkunov: Initial release
//------------------------------------------------
LittleEndian();
char signature[3];
byte version <read=ReadVersion>;
string ReadVersion(byte& v)
{
string s;
SPrintf(s, "%d.%d", v>>4, v&0x0f);
return s;
}
enum <unsigned byte> DiskType
{
disk_C64 = 0x00,
disk_Amiga = 0x04,
disk_AtariFMSS = 0x10,
disk_AtariFMDS = 0x11,
disk_AtariFMEx = 0x12,
disk_AtariSTSS = 0x14,
disk_AtariSTDS = 0x15,
disk_AppleII = 0x20,
disk_AppleIIPro = 0x21,
disk_Apple400K = 0x24,
disk_Apple800K = 0x25,
disk_Apple144 = 0x26,
disk_PC360K = 0x30,
disk_PC720K = 0x31,
disk_PC12M = 0x32,
disk_PC144M = 0x33,
disk_TRS80SSSD = 0x40,
disk_TRS80SSDD = 0x41,
disk_TRS80DSSD = 0x42,
disk_TRS80DSDD = 0x43,
disk_TI994A = 0x50,
disk_D20 = 0x60
};
DiskType disk_type;
byte revolutions;
unsigned byte start_track;
unsigned byte end_track;
unsigned byte flags <read=ReadFlags>;
string ReadFlags(unsigned byte f)
{
string s;
SPrintf(s, "%s, %s, %s, %s, %s, %s",
f & 0x01 ? "flux data starts at index" : "no index reference",
f & 0x02 ? "96TPI" : "48TPI",
f & 0x04 ? "360 RPM" : "300 RPM",
f & 0x08 ? "normalized flux" : "original flux data",
f & 0x10 ? "read/write" : "read only",
f & 0x20 ? "has footer" : "has no footer");
return s;
}
byte cell_width;
byte number_of_heads;
byte reserved;
long checksum;
long track_offset[end_track-start_track+1];
typedef struct
{
long duration;
long cell_count;
long offset;
} RevInfo;
typedef struct
{
char signature[3];
unsigned byte track_num;
RevInfo rev_info[revolutions];
} TrackHeader;
typedef struct
{
BigEndian(); // sic!
if(cell_width == 0 || cell_width == 16)
short flux[track_header.rev_info[rev].cell_count];
else
byte flux[track_header.rev_info[rev].cell_count];
LittleEndian();
} FluxData;
local int track, rev;
for(track=0; track<end_track-start_track+1; track++)
{
FSeek(track_offset[track]);
TrackHeader track_header;
for(rev=0; rev<revolutions; rev++)
{
FSeek(track_offset[track]+track_header.rev_info[rev].offset);
FluxData flux;
}
}
local long timestampPosition = FTell();
local long footerPosition = 0;
wstring ReadPStringUTF8(uint pos)
{
if(pos == 0)
return "";
FSeek(pos);
ushort strLen = ReadUShort();
char str[] = ReadString(pos + 2, strLen);
return StringToWString(str, CHARSET_UTF8);
}
typedef struct
{
uint manufacturer <read=ReadPStringUTF8>;
uint model <read=ReadPStringUTF8>;
uint serial <read=ReadPStringUTF8>;
uint creator <read=ReadPStringUTF8>;
uint application <read=ReadPStringUTF8>;
uint comments <read=ReadPStringUTF8>;
time_t creationTime;
uint ctime_2038;
time_t modificationTime;
uint mtime_2038;
byte applicationVersion <read=ReadVersion>;
byte hardwareVersion <read=ReadVersion>;
byte firmwareVersion <read=ReadVersion>;
byte imageVersion <read=ReadVersion>;
char footerMagic[4];
} Footer;
local uint footerSignature = 0x53435046;
if(flags & 0x20)
{
FSeek(FileSize() - 4);
local int foo;
for(foo = 0;FTell() > timestampPosition; FSkip(-4))
{
local uint sig = ReadUInt();
if(sig == footerSignature)
{
FSkip(-44);
footerPosition = FTell();
Footer footer;
break;
}
}
}
else
{
string timestamp;
}