diff --git a/src/const.h b/src/const.h index 22bdb6e1..c038f45b 100644 --- a/src/const.h +++ b/src/const.h @@ -123,6 +123,7 @@ enum FILE_FORMATS FORMAT_PKM, FORMAT_LBM, FORMAT_PBM, + FORMAT_ACBM, FORMAT_IMG, FORMAT_SCx, FORMAT_PI1, diff --git a/src/fileformats.c b/src/fileformats.c index d06aa550..c9668b20 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -327,6 +327,10 @@ void Test_LBM(T_IO_Context * context) { Test_IFF(context, "ILBM"); } +void Test_ACBM(T_IO_Context * context) +{ + Test_IFF(context, "ACBM"); +} // -- Lire un fichier au format IFF ----------------------------------------- @@ -620,6 +624,8 @@ void Load_IFF(T_IO_Context * context) iff_format = FORMAT_LBM; else if(memcmp(format,"PBM ",4) == 0) iff_format = FORMAT_PBM; + else if(memcmp(format,"ACBM",4) == 0) + iff_format = FORMAT_ACBM; else { char tmp_msg[60]; @@ -828,6 +834,51 @@ printf("%d x %d = %d %d\n", tiny_width, tiny_height, tiny_width*tiny_height, s section_size -= length; fseek(IFF_file, section_size, SEEK_CUR); } + else if (memcmp(section, "ABIT", 4) == 0) + { + // ACBM format : ABIT = Amiga BITplanes + // The ABIT chunk contains contiguous bitplane data. + // The chunk contains sequential data for bitplane 0 through bitplane n. + Pre_load(context, header.Width, header.Height, file_size, iff_format, ratio, truecolor); + // compute row size + real_line_size = (context->Width+15) & ~15; + plane_line_size = real_line_size >> 3; // 8bits per byte + line_size = plane_line_size * header.BitPlanes; + buffer = malloc(line_size * context->Height); + if ((dword)(line_size * context->Height) == section_size) + header.Compression = 0; // size is of uncompressed data. Forcing. + for (plane = 0; plane < header.BitPlanes; plane++) + { + for (y_pos = 0; y_pos < context->Height; y_pos++) + { + if (header.Compression == 0) + { + if (!Read_bytes(IFF_file,buffer+line_size*y_pos+plane_line_size*plane,plane_line_size)) + { + File_error = 21; + break; + } + } + else + { + Warning("Unhandled compression for ACBM ABIT chunk"); + File_error = 32; + break; + } + } + } + if (File_error == 0) + { + for (y_pos = 0; y_pos < context->Height; y_pos++) + { + if (Image_HAM <= 1) + Draw_IFF_line(context, buffer+y_pos*line_size, y_pos,real_line_size, header.BitPlanes); + else + Draw_IFF_line_HAM(context, buffer+y_pos*line_size, y_pos,real_line_size, header.BitPlanes, SHAM_palettes, SHAM_palette_count); + } + } + free(buffer); + } else if (memcmp(section, "BODY", 4) == 0) { Original_screen_X = header.X_screen; diff --git a/src/loadsave.c b/src/loadsave.c index dfac6471..7d68cd15 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -60,6 +60,7 @@ void Save_PKM(T_IO_Context *); // -- IFF ------------------------------------------------------------------- void Test_LBM(T_IO_Context *); void Test_PBM(T_IO_Context *); +void Test_ACBM(T_IO_Context *); void Load_IFF(T_IO_Context *); void Save_IFF(T_IO_Context *); @@ -163,7 +164,7 @@ void Load_SDL_Image(T_IO_Context *); // ENUM Name TestFunc LoadFunc SaveFunc PalOnly Comment Layers Ext Exts const T_Format File_formats[] = { - {FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;2bp;pcx;pkm;iff;lbm;ilbm;sham;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;c64;koa;koala;fli;bml;cdu;prg;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico;ic2;cur;cm5;pph"}, + {FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;2bp;pcx;pkm;iff;lbm;ilbm;sham;acbm;pic;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;c64;koa;koala;fli;bml;cdu;prg;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico;ic2;cur;cm5;pph"}, {FORMAT_ALL_PALETTES, "(pal)", NULL, NULL, NULL, 1, 0, 0, "", "kcf;pal;gpl"}, {FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"}, {FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 0, 1, 1, "gif", "gif"}, @@ -175,6 +176,7 @@ const T_Format File_formats[] = { {FORMAT_PKM, " pkm", Test_PKM, Load_PKM, Save_PKM, 0, 1, 0, "pkm", "pkm"}, {FORMAT_LBM, " lbm", Test_LBM, Load_IFF, Save_IFF, 0, 0, 0, "iff", "iff;lbm;ilbm;sham"}, {FORMAT_PBM, " pbm", Test_PBM, Load_IFF, Save_IFF, 0, 0, 0, "iff", "iff;pbm;lbm"}, + {FORMAT_ACBM," acbm",Test_ACBM,Load_IFF, NULL, 0, 0, 0, "iff", "iff;pic;acbm"}, {FORMAT_IMG, " img", Test_IMG, Load_IMG, Save_IMG, 0, 0, 0, "img", "img"}, {FORMAT_SCx, " sc?", Test_SCx, Load_SCx, Save_SCx, 0, 0, 0, "sc?", "sci;scq;scf;scn;sco"}, {FORMAT_PI1, " pi1", Test_PI1, Load_PI1, Save_PI1, 0, 0, 0, "pi1", "pi1"},