Commit dead0310 authored by Sergio Costas's avatar Sergio Costas

Allows to save data in both TAP and TZX files

parent f0eb825b
......@@ -671,6 +671,7 @@ void create_tapfile() {
case 0:
ordenador->tape_write = true; // allow to write
ordenador->current_tap = nombre2;
OOTape->load_file(nombre2);
break;
case -1:
llscreen->print_string("File already exists",-1,5,10,0);
......
......@@ -575,8 +575,33 @@ public:
TZXBlock() {
}
TZXBlock(uint8_t *data, uint16_t size) {
TZXBlock(uint8_t *data, uint16_t size) : FullBlock() {
size_t retval;
this->next = NULL;
this->data = new uint8_t[size];
memcpy(this->data, data, size);
this->allow_fast_load = true;
this->data_size = size;
this->pilot = 2168;
this->sync0 = 667;
this->sync1 = 735;
this->zero = 855;
this->one = 1710;
if (!(0x80 & this->data[0])) {
this->lpilot = 8063; // 5 seconds (aprox)
} else {
this->lpilot = 3223; // 2 seconds (aprox)
}
this->bits_at_end = 8;
this->pause = 1000;
this->loop = this->lpilot;
this->pointer = 0;
this->bit = 0x80;
this->bit_counter = 8;
this->set_state(TURBOBLOCK_GUIDE);
}
~TZXBlock() {
......@@ -1255,6 +1280,7 @@ bool Tape::load_file(string filename) {
this->paused = true;
this->current_file = "";
ifstream file (filename.c_str(),ios::in|ios::binary);
if (!file.is_open()) {
......@@ -1513,9 +1539,11 @@ bool Tape::add_block(uint8_t *data, uint16_t size) {
return true;
}
if (this->tzx) {
return true;
block = new TZXBlock(data,size);
} else {
block = new TAPBlock(data,size);
}
block = new TAPBlock(data,size);
this->add_block(block);
if (this->current_block == NULL) {
this->current_block = this->blocks;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment