improve C64 formats tests
This commit is contained in:
parent
a5f2989577
commit
7e276e105a
@ -46,6 +46,8 @@
|
|||||||
#define FLAG_16C 1
|
#define FLAG_16C 1
|
||||||
// 16 color 192x272 format. CPC overscan
|
// 16 color 192x272 format. CPC overscan
|
||||||
#define FLAG_CPCO 2
|
#define FLAG_CPCO 2
|
||||||
|
// Commodore 64 format
|
||||||
|
#define FLAG_C64 4
|
||||||
|
|
||||||
// Load/Save
|
// Load/Save
|
||||||
#define TESTFMTF(fmt, sample, flags) { FORMAT_ ## fmt, # fmt, Test_ ## fmt, Load_ ## fmt, Save_ ## fmt, flags, sample },
|
#define TESTFMTF(fmt, sample, flags) { FORMAT_ ## fmt, # fmt, Test_ ## fmt, Load_ ## fmt, Save_ ## fmt, flags, sample },
|
||||||
@ -71,7 +73,7 @@ static const struct {
|
|||||||
TESTFMTL(FLI, "autodesk_FLI_FLC/2noppaa.fli")
|
TESTFMTL(FLI, "autodesk_FLI_FLC/2noppaa.fli")
|
||||||
TESTFMT(BMP, "bmp/test8.bmp")
|
TESTFMT(BMP, "bmp/test8.bmp")
|
||||||
TESTFMTL(ICO, "ico/punzip.ico") // Format with limitations
|
TESTFMTL(ICO, "ico/punzip.ico") // Format with limitations
|
||||||
TESTFMTL(C64, "c64/multicolor/ARKANOID.KOA") // Format with limitations
|
TESTFMTF(C64, "c64/multicolor/ARKANOID.KOA", FLAG_C64)
|
||||||
TESTFMTL(PRG, "c64/multicolor/speedball2_loading_jonegg.prg")
|
TESTFMTL(PRG, "c64/multicolor/speedball2_loading_jonegg.prg")
|
||||||
TESTFMTL(GPX, "c64/pixcen/Cyberbird.gpx")
|
TESTFMTL(GPX, "c64/pixcen/Cyberbird.gpx")
|
||||||
TESTFMTF(SCR, "cpc/scr/DANCEOFF.SCR", FLAG_CPCO)
|
TESTFMTF(SCR, "cpc/scr/DANCEOFF.SCR", FLAG_CPCO)
|
||||||
@ -287,6 +289,8 @@ int Test_Save(void)
|
|||||||
{
|
{
|
||||||
if (formats[i].Save == NULL)
|
if (formats[i].Save == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
if (formats[i].flags & FLAG_C64)
|
||||||
|
continue;
|
||||||
GFX2_Log(GFX2_DEBUG, "Testing format %s (Save)\n", formats[i].name);
|
GFX2_Log(GFX2_DEBUG, "Testing format %s (Save)\n", formats[i].name);
|
||||||
snprintf(path, sizeof(path), "%s/%s.%s", tmpdir, "test", formats[i].name);
|
snprintf(path, sizeof(path), "%s/%s.%s", tmpdir, "test", formats[i].name);
|
||||||
context_set_file_path(&context, path);
|
context_set_file_path(&context, path);
|
||||||
@ -400,6 +404,7 @@ ret:
|
|||||||
|
|
||||||
int Test_C64_Formats(void)
|
int Test_C64_Formats(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
T_IO_Context context;
|
T_IO_Context context;
|
||||||
char path[256];
|
char path[256];
|
||||||
@ -408,7 +413,7 @@ int Test_C64_Formats(void)
|
|||||||
memset(&context, 0, sizeof(context));
|
memset(&context, 0, sizeof(context));
|
||||||
context.Type = CONTEXT_SURFACE;
|
context.Type = CONTEXT_SURFACE;
|
||||||
context.Nb_layers = 1;
|
context.Nb_layers = 1;
|
||||||
// Load EVILNUN.PKM
|
// Load a multicolor picture
|
||||||
context_set_file_path(&context, "../tests/pic-samples/c64/multicolor/STILLIFE.rpm");
|
context_set_file_path(&context, "../tests/pic-samples/c64/multicolor/STILLIFE.rpm");
|
||||||
File_error = 0;
|
File_error = 0;
|
||||||
Load_C64(&context);
|
Load_C64(&context);
|
||||||
@ -420,7 +425,15 @@ int Test_C64_Formats(void)
|
|||||||
testpicmulti = context.Surface;
|
testpicmulti = context.Surface;
|
||||||
context.Surface = NULL;
|
context.Surface = NULL;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/tmp/%s", "test.c64");
|
ok = 1;
|
||||||
|
for (i = 0; ok && formats[i].name != NULL; i++)
|
||||||
|
{
|
||||||
|
if (formats[i].Save == NULL)
|
||||||
|
continue;
|
||||||
|
if (!(formats[i].flags & FLAG_C64))
|
||||||
|
continue;
|
||||||
|
GFX2_Log(GFX2_DEBUG, "Testing format %s (Save)\n", formats[i].name);
|
||||||
|
snprintf(path, sizeof(path), "/tmp/%s.%s", "test", formats[i].name);
|
||||||
context_set_file_path(&context, path);
|
context_set_file_path(&context, path);
|
||||||
|
|
||||||
// save the reference picture
|
// save the reference picture
|
||||||
@ -431,20 +444,20 @@ int Test_C64_Formats(void)
|
|||||||
context.Height = context.Surface->h;
|
context.Height = context.Surface->h;
|
||||||
context.Ratio = PIXEL_WIDE;
|
context.Ratio = PIXEL_WIDE;
|
||||||
memcpy(context.Palette, context.Surface->palette, sizeof(T_Palette));
|
memcpy(context.Palette, context.Surface->palette, sizeof(T_Palette));
|
||||||
context.Format = FORMAT_C64;
|
context.Format = formats[i].format;
|
||||||
File_error = 0;
|
File_error = 0;
|
||||||
Save_C64(&context);
|
formats[i].Save(&context);
|
||||||
context.Surface = NULL;
|
context.Surface = NULL;
|
||||||
if (File_error != 0)
|
if (File_error != 0)
|
||||||
{
|
{
|
||||||
GFX2_Log(GFX2_ERROR, "Save_C64 failed.\n");
|
GFX2_Log(GFX2_ERROR, "Save_%s failed.\n", formats[i].name);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE * f;
|
FILE * f;
|
||||||
// Test the saved file
|
// Test the saved file
|
||||||
f = fopen("/tmp/test.c64", "rb");
|
f = fopen(path, "rb");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
{
|
{
|
||||||
GFX2_Log(GFX2_ERROR, "error opening %s\n", path);
|
GFX2_Log(GFX2_ERROR, "error opening %s\n", path);
|
||||||
@ -453,32 +466,32 @@ int Test_C64_Formats(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
Test_C64(&context, f);
|
formats[i].Test(&context, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if (File_error != 0)
|
if (File_error != 0)
|
||||||
{
|
{
|
||||||
GFX2_Log(GFX2_ERROR, "Test_C64 failed for file %s\n", path);
|
GFX2_Log(GFX2_ERROR, "Test_%s failed for file %s\n", formats[i].name, path);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(context.Palette, -1, sizeof(T_Palette));
|
memset(context.Palette, -1, sizeof(T_Palette));
|
||||||
// load the saved file
|
// load the saved file
|
||||||
Load_C64(&context);
|
formats[i].Load(&context);
|
||||||
if (File_error != 0 || context.Surface == NULL)
|
if (File_error != 0 || context.Surface == NULL)
|
||||||
{
|
{
|
||||||
GFX2_Log(GFX2_ERROR, "Load_C64 failed for file %s\n", path);
|
GFX2_Log(GFX2_ERROR, "Load_%s failed for file %s\n", formats[i].name, path);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ok = 1;
|
|
||||||
if (memcmp(testpicmulti->pixels, context.Surface->pixels, 160*200) != 0)
|
if (memcmp(testpicmulti->pixels, context.Surface->pixels, 160*200) != 0)
|
||||||
{
|
{
|
||||||
GFX2_Log(GFX2_ERROR, "Save_C64/Load_C64: Pixels mismatch\n");
|
GFX2_Log(GFX2_ERROR, "Save_%s/Load_%s: Pixels mismatch\n", formats[i].name, formats[i].name);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret:
|
ret:
|
||||||
if (testpicmulti)
|
if (testpicmulti)
|
||||||
Free_GFX2_Surface(testpicmulti);
|
Free_GFX2_Surface(testpicmulti);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user