Changeset 53c4be3 in thomson for elec/CrO2/software/device.cpp


Ignore:
Timestamp:
Feb 5, 2012, 3:25:32 PM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
1b74fa2
Parents:
c2a9854
Message:
  • Support for ZX spectrup TAP files.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • elec/CrO2/software/device.cpp

    rc2a9854 r53c4be3  
    99#include "device.h"
    1010#include "k5.h"
     11
     12#include <typeinfo>
    1113
    1214bool Device::initOnce = false;
     
    134136
    135137
    136 int Device::write(uint8_t* buffer, size_t size, int blktype)
     138int Device::write(const uint8_t* buffer, size_t size, int blktype)
    137139{
    138140        int rqtype = (size == 0) ? USB_ENDPOINT_IN:USB_ENDPOINT_OUT;
     
    143145
    144146
    145 void Device::write(K5& file)
     147void Device::write(const Tape& file) throw (const char*)
    146148{
    147149        for (int k = 0; k < file.getBlockCount(); k++)
     
    151153                        Sleep(1000);
    152154
    153                 K5::Block block = file.getBlock(k);
    154 
    155                 int nBytes = write(block.data, block.length - 1, block.type);
    156                         // TODO error handling
     155                const Tape::Block& block = file.getBlock(k);
     156                try {
     157                        const K5::Block& moblock = dynamic_cast<const K5::Block&>(block);
     158                        write(moblock.data, moblock.length - 1, moblock.type);
     159                                // TODO error handling on write
     160                } catch (std::bad_cast x) {
     161                        throw "Only MO5 files supported so far. Sorry!";
     162                };
    157163
    158164                // TODO wait for correct time (read status from usb OR compute from size+type)
Note: See TracChangeset for help on using the changeset viewer.