Add TGA output option to the tester, closes #310
This commit is contained in:
parent
027cecde24
commit
bbf609f46b
@ -31,16 +31,23 @@ static unsigned int test_length = 60 * 40;
|
||||
GB_gameboy_t gb;
|
||||
|
||||
static unsigned int frames = 0;
|
||||
const char bmp_header[] = {
|
||||
0x42, 0x4D, 0x48, 0x68, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x38, 0x00,
|
||||
0x00, 0x00, 0xA0, 0x00, 0x00, 0x00, 0x70, 0xFF,
|
||||
0xFF, 0xFF, 0x01, 0x00, 0x20, 0x00, 0x03, 0x00,
|
||||
0x00, 0x00, 0x02, 0x68, 0x01, 0x00, 0x12, 0x0B,
|
||||
0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
static bool use_tga = false;
|
||||
static const uint8_t bmp_header[] = {
|
||||
0x42, 0x4D, 0x48, 0x68, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x38, 0x00,
|
||||
0x00, 0x00, 0xA0, 0x00, 0x00, 0x00, 0x70, 0xFF,
|
||||
0xFF, 0xFF, 0x01, 0x00, 0x20, 0x00, 0x03, 0x00,
|
||||
0x00, 0x00, 0x02, 0x68, 0x01, 0x00, 0x12, 0x0B,
|
||||
0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const uint8_t tga_header[] = {
|
||||
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x90, 0x00,
|
||||
0x20, 0x28,
|
||||
};
|
||||
|
||||
uint32_t bitmap[160*144];
|
||||
@ -139,7 +146,12 @@ static void vblank(GB_gameboy_t *gb)
|
||||
/* Let the test run for extra four seconds if the screen is off/disabled */
|
||||
if (!is_screen_blank || frames >= test_length + 60 * 4) {
|
||||
FILE *f = fopen(bmp_filename, "wb");
|
||||
if (use_tga) {
|
||||
fwrite(&tga_header, 1, sizeof(tga_header), f);
|
||||
}
|
||||
else {
|
||||
fwrite(&bmp_header, 1, sizeof(bmp_header), f);
|
||||
}
|
||||
fwrite(&bitmap, 1, sizeof(bitmap), f);
|
||||
fclose(f);
|
||||
if (!gb->boot_rom_finished) {
|
||||
@ -215,6 +227,9 @@ static char *executable_relative_path(const char *filename)
|
||||
|
||||
static uint32_t rgb_encode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
if (use_tga) {
|
||||
return (r << 16) | (g << 8) | (b);
|
||||
}
|
||||
return (r << 24) | (g << 16) | (b << 8);
|
||||
}
|
||||
|
||||
@ -269,6 +284,12 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[i], "--tga") == 0) {
|
||||
fprintf(stderr, "Using TGA output\n");
|
||||
use_tga = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[i], "--start") == 0) {
|
||||
fprintf(stderr, "Pushing Start and A\n");
|
||||
push_start_a = true;
|
||||
@ -312,7 +333,7 @@ int main(int argc, char **argv)
|
||||
size_t path_length = strlen(filename);
|
||||
|
||||
char bitmap_path[path_length + 5]; /* At the worst case, size is strlen(path) + 4 bytes for .bmp + NULL */
|
||||
replace_extension(filename, path_length, bitmap_path, ".bmp");
|
||||
replace_extension(filename, path_length, bitmap_path, use_tga? ".tga" : ".bmp");
|
||||
bmp_filename = &bitmap_path[0];
|
||||
|
||||
char log_path[path_length + 5];
|
||||
|
Loading…
Reference in New Issue
Block a user