Added disk extractor

This commit is contained in:
Mixac1 2016-02-10 14:58:01 +03:00
commit 9588b4dfb5
4 changed files with 82 additions and 0 deletions

BIN
2.0_System Disk.dsk Normal file

Binary file not shown.

BIN
copy.dsk Normal file

Binary file not shown.

BIN
disk Executable file

Binary file not shown.

82
disk.cpp Normal file
View File

@ -0,0 +1,82 @@
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#define SECTOR_SIZE 256
#define SECTOR_COUNT 16
#define VTOC_OFFSET SECTOR_COUNT * 17 * SECTOR_SIZE
using namespace std;
class Disk {
struct VTOC {
int track;
int sector;
init() {
track = read(VTOC_OFFSET + 1);
}
};
VTOC s;
fstream disk;
public:
Disk() {
disk.open("copy.dsk", ios_base::binary | ios_base::in);
s.init();
}
~Disk() {
disk.close();
}
Disk(const Disk&) = delete;
Disk& operator=(const Disk&) = delete;
int read(int offset) {
disk.seekg(offset);
return disk.get();
}
/*int getNextSector(int this_sector) {
disk.seekg(this_sector + 1);
int track = disk.get();
int sector = disk.get();
return ((track * SECTOR_COUNT) + sector) * SECTOR_SIZE;
}
int getName(int this_sector) {
disk.seekg(this_sector + 14);
char name[31];
disk.get(name, 30);
string s(name);
for (int i=0; i<30; i++) cout << name[i];
cout << s << endl;
return 0;
}*/
void printSector(int offset, int size, int strsize) {
disk.seekg(offset);
size /= 2;
for (int i = 1; i <= size; ++i) {
cout << hex << setw(2) << setfill('0') << disk.get();
cout << hex << setw(2) << setfill('0') << disk.get() << " ";
if (!(i % strsize)) {
cout << endl;
}
}
cout << endl;
}
};
int main() {
Disk disk;
disk.printSector(VTOC_OFFSET, SECTOR_SIZE, 8);
return 1;
}