Skip to content

Commit 91b32f4

Browse files
committed
autotester: add saveVar command
1 parent 910f4ed commit 91b32f4

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

tests/autotester/autotester.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,47 @@ static const std::unordered_map<std::string, seq_cmd_func_t> valid_seq_commands
312312
std::cerr << "\t[Error] unknown key \"" << which_key << "\" was not released." << std::endl;
313313
};
314314
}
315+
},
316+
{
317+
"saveVar", [](const std::string& wanted_var_name) {
318+
using namespace cemucore;
319+
320+
bool found = false;
321+
calc_var_t var;
322+
const char* readableName = nullptr;
323+
324+
vat_search_init(&var);
325+
while (vat_search_next(&var))
326+
{
327+
if (var.named || var.size > 2)
328+
{
329+
if (calc_var_is_list(&var))
330+
{
331+
// Remove any linked formula before generating filename
332+
var.name[var.namelen - 1] = 0;
333+
}
334+
readableName = calc_var_name_to_utf8(var.name, var.namelen, var.named);
335+
if (readableName == wanted_var_name)
336+
{
337+
found = true;
338+
break;
339+
}
340+
}
341+
}
342+
343+
if (!found)
344+
{
345+
std::cerr << "Could not save var, it wasn't found!" << std::endl;
346+
return;
347+
}
348+
349+
const std::string filename = oldCWD + readableName + std::string(".") + varExtensions[var.type];
350+
if (emu_receive_variable(filename.c_str(), &var, 1) != LINK_GOOD) {
351+
std::cerr << "saveVar error, see console for information. File: " << filename << std::endl;
352+
} else {
353+
std::cout << "saveVar completed successfully. File: " << filename << std::endl;
354+
}
355+
}
315356
}
316357
};
317358

tests/autotester/autotester.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,50 @@ namespace autotester
7373
{ "cursorImage", 0xE30800 }, { "cursorImage_size", 1024 }
7474
};
7575

76+
static const char* varExtensions[] = {
77+
"8xn", // 00
78+
"8xl",
79+
"8xm",
80+
"8xy",
81+
"8xs",
82+
"8xp",
83+
"8xp",
84+
"8ci",
85+
"8xd", // 08
86+
"",
87+
"",
88+
"8xw", // 0B
89+
"8xc",
90+
"8xl", // 0D
91+
"",
92+
"8xw", // 0F
93+
"8xz", // 10
94+
"8xt", // 11
95+
"",
96+
"",
97+
"",
98+
"8xv", // 15
99+
"",
100+
"8cg", // 17
101+
"8xn", // 18
102+
"",
103+
"8ca", // 1A
104+
"8xc",
105+
"8xn",
106+
"8xc",
107+
"8xc",
108+
"8xc",
109+
"8xn",
110+
"8xn", // 21
111+
"",
112+
"8pu", // 23
113+
"8ek", // 24
114+
"",
115+
"",
116+
"",
117+
"",
118+
};
119+
76120
void sendCSC(uint8_t csc);
77121
void sendKey(uint16_t key);
78122
void sendLetterKeyPress(char letter);

0 commit comments

Comments
 (0)