source: thomson/elec/CrO2/software/cro2.cpp@ e017851

main
Last change on this file since e017851 was e017851, checked in by Adrien Destugues <pulkomandy@…>, 11 years ago

Port to Haiku. Untested.

git-svn-id: svn://localhost/thomson@28 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/* CrO2 datassette emulator
2 * Copyright 2012, Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
3 *
4 * Distributed under the terms of the MIT licence.
5 */
6
7#include <iostream>
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <stdint.h>
12#include <unistd.h>
13
14
15#include "device.h"
16#include "k5.h"
17#include "gui.h"
18
19int main(int argc, char **argv)
20{
21 if(argc < 2){
22 Gui gui(&argc, &argv);
23 exit(0);
24 }
25
26 try {
27 Device& dev = Device::getDevice(); // Constructor inits communication.
28
29 if(strcmp(argv[1], "get") == 0){
30 int nBytes = 0;
31 unsigned char buffer[275];
32 memset(buffer, 0, 275);
33 nBytes = dev.read(buffer, sizeof(buffer));
34 // FIXME move error gathering to Device (and throw the string maybe ?)
35 //if (nBytes < 0) fprintf(stderr, "USB error %s\n", usb_strerror());
36 }else if(strcmp(argv[1], "put") == 0){
37
38 // load file
39 Tape* file = Tape::load(argv[2]);
40
41 dev.write(*file);
42
43 delete file;
44 }else{
45 // TODO print usage
46 exit(2);
47 }
48
49 return 0;
50 }
51 catch(const char* error)
52 {
53 std::cerr << error << std::endl;
54 }
55
56 exit(0);
57}
58
Note: See TracBrowser for help on using the repository browser.