main
Line | |
---|
1 | /* CrO2 datassette emulator
|
---|
2 | * Copyright 2013, Adrien Destugues <pulkomandy@pulkomandy.tk>
|
---|
3 | *
|
---|
4 | * Distributed under the terms of the MIT licence.
|
---|
5 | *
|
---|
6 | * High-level device management functions shared by all implementations.
|
---|
7 | */
|
---|
8 |
|
---|
9 | #include "device.h"
|
---|
10 | #include "k5.h"
|
---|
11 | #include "Tape.h"
|
---|
12 |
|
---|
13 | #include <typeinfo>
|
---|
14 | #include <unistd.h>
|
---|
15 |
|
---|
16 |
|
---|
17 | bool Device::initOnce = false;
|
---|
18 | Device* Device::instance = NULL;
|
---|
19 |
|
---|
20 | const uint32_t Device::vid = 0x16C0;
|
---|
21 | const uint32_t Device::pid = 0x05DC;
|
---|
22 | const char* Device::vendor = "pulkomandy.ath.cx"; // FIXME update
|
---|
23 | const char* Device::product = "CrO2";
|
---|
24 |
|
---|
25 |
|
---|
26 | void Device::write(const Tape& file) throw (const char*)
|
---|
27 | {
|
---|
28 | for (int k = 0; k < file.getBlockCount(); k++)
|
---|
29 | {
|
---|
30 | // wait for motor on
|
---|
31 | while (getStatus() & 8)
|
---|
32 | usleep(1000 * 1000);
|
---|
33 |
|
---|
34 | const Tape::Block& block = file.getBlock(k);
|
---|
35 | try {
|
---|
36 | const K5::Block& moblock = dynamic_cast<const K5::Block&>(block);
|
---|
37 | write(moblock.data, moblock.length - 1, moblock.type);
|
---|
38 | // TODO error handling on write
|
---|
39 | } catch (std::bad_cast x) {
|
---|
40 | throw "Only MO5 files supported so far. Sorry!";
|
---|
41 | };
|
---|
42 |
|
---|
43 | // TODO wait for correct time (read status from usb OR compute from size+type)
|
---|
44 | usleep(1400 * 1000);
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.