diff --git a/cores/Oric/tools/tap2bin/CMakeLists.txt b/cores/Oric/tools/tap2bin/CMakeLists.txt new file mode 100644 index 0000000..4cd249d --- /dev/null +++ b/cores/Oric/tools/tap2bin/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.0) +add_definitions(-std=c++11) +set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") +add_executable(tap2bin tap2bin.cpp) + diff --git a/cores/Oric/tools/tap2bin/readme.txt b/cores/Oric/tools/tap2bin/readme.txt new file mode 100644 index 0000000..0b4ea2b --- /dev/null +++ b/cores/Oric/tools/tap2bin/readme.txt @@ -0,0 +1,13 @@ +written by byrtolet@parallel.bas.bg + +This program converst files in oric .tap format to +files swittable to be written with dos33 program from +http://www.deater.net/weave/vmwprod/apple/dos33fs.html + +To write binary file do: +dos33 image.dsk B file_binary.bam DOS_FILENAME +To write basic file do: +dos33 image.dsk A file_basic.bam DOS_FILENAME + + +The provided .exe file is build on linus with mingw and is not tested on windows. diff --git a/cores/Oric/tools/tap2bin/tap2bin.cpp b/cores/Oric/tools/tap2bin/tap2bin.cpp new file mode 100644 index 0000000..e7c711d --- /dev/null +++ b/cores/Oric/tools/tap2bin/tap2bin.cpp @@ -0,0 +1,119 @@ +// written by byrtolet@parallel.bas.bg +// this program converst files in oric .tap format to +// files swittable to be written with dos33 program from +// http://www.deater.net/weave/vmwprod/apple/dos33fs.html +// to write binary file do +// dos33 image.dsk B file_binary.bam DOS_FILENAME +// To write basic file do: +// dos33 image.dsk A file_basic.bam DOS_FILENAME + + + +#include +#include + +void writetwobyte(std::ofstream&of, int a) +{ + char ch = a & 0xff; + of.write(&ch, 1); + ch = (a >>8) &0xff; + of.write(&ch, 1); +} + +int main(int argc, char **argv) +{ + try{ + if (argc<3) + { + std::cerr << "Usage " << argv[0] << " file.tap output_name_base" << std::endl; + return 1; + } + std::string tap_file = argv[1]; + std::string filename_base = argv[2]; + + int filenum = 0; + std::ifstream file; + file.exceptions(std::ios::failbit | std::ios::badbit |std::ios::eofbit); + file.open(tap_file.c_str(), std::ios::binary | std::ios::in); + + while (true) // if more than one tape record + { + // 16 + // 16 + //... + // 16 + // 24 + // 0 + // 0 + // type 0 basic 80 assembler + // autorun 0 - no 80 basic c7 assm + // end addr high + // end addr lo + // start addr high + // start addr lo + // 0 + // filename up to 16 chars + // 0 + // data + + char ch; + + // skip sync + do + { + file.read(&ch, 1); + } while (0x24 != ch); + file.read(&ch, 1); // first zero + file.read(&ch, 1); // second zero + file.read(&ch, 1); // type + bool basic = ch == 0; + file.read(&ch, 1); // autostart + int start_addr = 0; + int end_addr = 0; + file.read(&ch, 1); // autostart + end_addr = (end_addr << 8) + (unsigned char)ch; + file.read(&ch, 1); // autostart + end_addr = (end_addr << 8) + (unsigned char)ch; + file.read(&ch, 1); // autostart + start_addr = (start_addr << 8) + (unsigned char)ch; + file.read(&ch, 1); // autostart + start_addr = (start_addr << 8) + (unsigned char)ch; + file.read(&ch, 1); // skip zero + + std::string filename; + do + { + file.read(&ch, 1); // skip zero + if (ch) + filename += ch; + } while (ch); + int size = end_addr - start_addr + 1; + + filename = filename_base; + filename += basic ? "_basic" : "_binary"; + filename += std::to_string(filenum); + filename += ".bam"; + std::cout << "writing " << filename << " " << std::flush; + std::ofstream of(filename, std::ios::binary |std::ios::out); + if (!basic) + { + writetwobyte(of, start_addr); + writetwobyte(of, size); + }else + writetwobyte(of, size); + + for (; size--;) + { + file.read(&ch, 1); // skip zero + of.write(&ch, 1); + } + + filenum++; + std::cout << " done." << std::endl; + } + } catch (std::exception& e) + { + // let's hope it's just endo of file + } + return 0; +} diff --git a/cores/Oric/tools/tap2bin/tap2bin.exe b/cores/Oric/tools/tap2bin/tap2bin.exe new file mode 100755 index 0000000..9c06f62 Binary files /dev/null and b/cores/Oric/tools/tap2bin/tap2bin.exe differ