diff options
Diffstat (limited to 'engines/adl/console.cpp')
-rw-r--r-- | engines/adl/console.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp index ad3277ffaa..e1242fa64f 100644 --- a/engines/adl/console.cpp +++ b/engines/adl/console.cpp @@ -26,6 +26,7 @@ #include "adl/display.h" #include "adl/graphics.h" #include "adl/adl.h" +#include "adl/disk.h" namespace Adl { @@ -42,6 +43,7 @@ Console::Console(AdlEngine *engine) : GUI::Debugger() { registerCmd("give_item", WRAP_METHOD(Console, Cmd_GiveItem)); registerCmd("vars", WRAP_METHOD(Console, Cmd_Vars)); registerCmd("var", WRAP_METHOD(Console, Cmd_Var)); + registerCmd("convert_disk", WRAP_METHOD(Console, Cmd_ConvertDisk)); } Common::String Console::toAscii(const Common::String &str) { @@ -384,4 +386,41 @@ void Console::printWordMap(const WordMap &wordMap) { debugPrintColumns(words); } +bool Console::Cmd_ConvertDisk(int argc, const char **argv) { + if (argc != 3) { + debugPrintf("Usage: %s <source> <dest>\n", argv[0]); + return true; + } + + DiskImage inDisk; + if (!inDisk.open(argv[1])) { + debugPrintf("Failed to open '%s' for reading\n", argv[1]); + return true; + } + + Common::DumpFile outDisk; + if (!outDisk.open(argv[2])) { + debugPrintf("Failed to open '%s' for writing\n", argv[2]); + return true; + } + + const uint sectors = inDisk.getTracks() * inDisk.getSectorsPerTrack(); + const uint size = sectors * inDisk.getBytesPerSector(); + + byte *const buf = new byte[size]; + + StreamPtr stream(inDisk.createReadStream(0, 0, 0, sectors - 1)); + if (stream->read(buf, size) < size) { + debugPrintf("Failed to read from stream"); + delete[] buf; + return true; + } + + if (outDisk.write(buf, size) < size) + debugPrintf("Failed to write to '%s'", argv[2]); + + delete[] buf; + return true; +} + } // End of namespace Adl |