1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Switched to std::ostringstream to avoid the need to make a string length count (and I was one off when loading a disk).

This commit is contained in:
Thomas Harte 2017-05-06 19:55:42 -04:00
parent 5998123868
commit 6a37a02eee

View File

@ -13,6 +13,8 @@
#include "Disk.hpp" #include "Disk.hpp"
#include "../../Storage/Cartridge/Encodings/CommodoreROM.hpp" #include "../../Storage/Cartridge/Encodings/CommodoreROM.hpp"
#include <sstream>
using namespace StaticAnalyser::Commodore; using namespace StaticAnalyser::Commodore;
static std::list<std::shared_ptr<Storage::Cartridge::Cartridge>> static std::list<std::shared_ptr<Storage::Cartridge::Cartridge>>
@ -75,15 +77,15 @@ void StaticAnalyser::Commodore::AddTargets(
if(files.size()) { if(files.size()) {
target.vic20.memory_model = Vic20MemoryModel::Unexpanded; target.vic20.memory_model = Vic20MemoryModel::Unexpanded;
std::ostringstream string_stream;
string_stream << "LOAD\"" << (is_disk ? "*" : "") << "\"," << device << ",";
if(files.front().is_basic()) { if(files.front().is_basic()) {
char command[16]; string_stream << "0";
snprintf(command, 16, "LOAD\"%s\",%d,0\nRUN\n", is_disk ? "*" : "", device);
target.loadingCommand = command;
} else { } else {
char command[16]; string_stream << "1";
snprintf(command, 16, "LOAD\"%s\",%d,1\nRUN\n", is_disk ? "*" : "", device);
target.loadingCommand = command;
} }
string_stream << "\nRUN\n";
target.loadingCommand = string_stream.str();
// make a first guess based on loading address // make a first guess based on loading address
switch(files.front().starting_address) { switch(files.front().starting_address) {