@@ -45,6 +45,37 @@ static char* myrealpath(const char* file_name)
4545#endif
4646}
4747
48+ static void dumpScreenshot (const std::string& description)
49+ {
50+ std::string safe_name = description;
51+ for (char & c : safe_name) {
52+ if (c == ' /' || c == ' \\ ' || c == ' :' || c == ' *' || c == ' ?' || c == ' "' || c == ' <' || c == ' >' || c == ' |' ) {
53+ c = ' _' ;
54+ }
55+ }
56+
57+ std::string path = safe_name + " .rgba" ;
58+
59+ uint32_t *frame = static_cast <uint32_t *>(malloc (LCD_SIZE * sizeof (uint32_t )));
60+ if (!frame) {
61+ std::cerr << " \t [Screenshot] Failed to allocate frame buffer" << std::endl;
62+ return ;
63+ }
64+
65+ cemucore::emu_lcd_drawframe (frame);
66+
67+ FILE *f = fopen (path.c_str (), " wb" );
68+ if (f) {
69+ fwrite (frame, sizeof (uint32_t ), LCD_SIZE, f);
70+ fclose (f);
71+ std::cout << " \t [Screenshot] Saved " << path << std::endl;
72+ } else {
73+ std::cerr << " \t [Screenshot] Failed to write " << path << std::endl;
74+ }
75+
76+ free (frame);
77+ }
78+
4879namespace autotester
4980{
5081
@@ -54,6 +85,7 @@ config_t config;
5485std::string oldCWD;
5586
5687bool debugMode = true ;
88+ bool screenshotsMode = false ;
5789bool ignoreROMfield = false ;
5890bool configLoaded = false ;
5991
@@ -217,6 +249,9 @@ static const std::unordered_map<std::string, seq_cmd_func_t> valid_seq_commands
217249 ::free (temp_buffer_dup);
218250 }
219251 hashesTested++;
252+ if (screenshotsMode) {
253+ dumpScreenshot (param.description );
254+ }
220255 } else {
221256 std::cerr << " \t [Error] hash #" << which_hash << " was not declared in the JSON file. Ignoring." << std::endl;
222257 }
0 commit comments