Skip to content

Commit

Permalink
autotester: add saveVar command
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Dec 4, 2024
1 parent 910f4ed commit 91b32f4
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/autotester/autotester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,47 @@ static const std::unordered_map<std::string, seq_cmd_func_t> valid_seq_commands
std::cerr << "\t[Error] unknown key \"" << which_key << "\" was not released." << std::endl;
};
}
},
{
"saveVar", [](const std::string& wanted_var_name) {
using namespace cemucore;

bool found = false;
calc_var_t var;
const char* readableName = nullptr;

vat_search_init(&var);
while (vat_search_next(&var))
{
if (var.named || var.size > 2)
{
if (calc_var_is_list(&var))
{
// Remove any linked formula before generating filename
var.name[var.namelen - 1] = 0;
}
readableName = calc_var_name_to_utf8(var.name, var.namelen, var.named);
if (readableName == wanted_var_name)
{
found = true;
break;
}
}
}

if (!found)
{
std::cerr << "Could not save var, it wasn't found!" << std::endl;
return;
}

const std::string filename = oldCWD + readableName + std::string(".") + varExtensions[var.type];
if (emu_receive_variable(filename.c_str(), &var, 1) != LINK_GOOD) {
std::cerr << "saveVar error, see console for information. File: " << filename << std::endl;
} else {
std::cout << "saveVar completed successfully. File: " << filename << std::endl;
}
}
}
};

Expand Down
44 changes: 44 additions & 0 deletions tests/autotester/autotester.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,50 @@ namespace autotester
{ "cursorImage", 0xE30800 }, { "cursorImage_size", 1024 }
};

static const char* varExtensions[] = {

Check warning on line 76 in tests/autotester/autotester.h

View workflow job for this annotation

GitHub Actions / Build: ubuntu-20.04 - Qt6-Dynamic

‘autotester::varExtensions’ defined but not used [-Wunused-variable]

Check warning on line 76 in tests/autotester/autotester.h

View workflow job for this annotation

GitHub Actions / Build: ubuntu-20.04 - Qt6

‘autotester::varExtensions’ defined but not used [-Wunused-variable]
"8xn", // 00
"8xl",
"8xm",
"8xy",
"8xs",
"8xp",
"8xp",
"8ci",
"8xd", // 08
"",
"",
"8xw", // 0B
"8xc",
"8xl", // 0D
"",
"8xw", // 0F
"8xz", // 10
"8xt", // 11
"",
"",
"",
"8xv", // 15
"",
"8cg", // 17
"8xn", // 18
"",
"8ca", // 1A
"8xc",
"8xn",
"8xc",
"8xc",
"8xc",
"8xn",
"8xn", // 21
"",
"8pu", // 23
"8ek", // 24
"",
"",
"",
"",
};

void sendCSC(uint8_t csc);
void sendKey(uint16_t key);
void sendLetterKeyPress(char letter);
Expand Down

0 comments on commit 91b32f4

Please sign in to comment.