cake
/
libg1m
Archived
1
0
Fork 0

Corrected a few more things.

This commit is contained in:
Thomas Touhey 2017-03-18 08:39:47 +01:00
parent a527c64591
commit a3d0564904
6 changed files with 53 additions and 20 deletions

View File

@ -195,7 +195,7 @@ struct _classpad_subheader {
uint8_t _unknown3[0xC54];
};
/* Also, if there is a Standard Subheader, there is a footer at the end of the
/* Also, if the platform is the Prizm, there is a footer at the end of the
* file, which is only made of a 32-bit checksum that should be equal to
* the subheader checksum.
*

View File

@ -24,22 +24,28 @@ extern "C" {
/* picture format */
typedef int g1m_pictureformat_t;
# define g1m_pictureformat_1bit_packed 0x0101
# define g1m_pictureformat_1bit_reverse 0x0102
# define g1m_pictureformat_2bit_dual 0x0201
# define g1m_pictureformat_4bit_rgb 0x0401
# define g1m_pictureformat_4bit_code 0x0402
# define g1m_pictureformat_4bit_color 0x0403
# define g1m_pictureformat_4bit_mono 0x0404
# define g1m_pictureformat_16bit 0x1000
# define g1m_pictureformat_1bit 0x0100
# define g1m_pictureformat_1bit_packed 0x0110
# define g1m_pictureformat_1bit_packed_r 0x0111
# define g1m_pictureformat_1bit_packed_old 0x0120
# define g1m_pictureformat_2bit_dual 0x0200
# define g1m_pictureformat_4bit_rgb 0x0400
# define g1m_pictureformat_4bit_code 0x0410
# define g1m_pictureformat_4bit_color 0x0420
# define g1m_pictureformat_4bit_mono 0x0430
# define g1m_pictureformat_16bit 0x1000
/* get size of the raw buffer */
# define g1m_picturesize_1bit(W, H) \
((((W) / 8) + !!((W) % 8)) * (H))
# define g1m_picturesize_1bit_packed(W, H) \
((W) * (H) / 8)
# define g1m_picturesize_1bit_reverse(W, H) \
# define g1m_picturesize_1bit_packed_r(W, H) \
g1m_picturesize_1bit_packed(W, H)
# define g1m_picturesize_1bit_packed_old(W, H) \
g1m_picturesize_1bit_packed(W, H)
# define g1m_picturesize_4bit_color(W, H) \
(4 * g1m_picturesize_1bit_reverse(W, H))
(4 * g1m_picturesize_1bit_packed_old(W, H))
# define g1m_picturesize_4bit_mono(W, H) \
g1m_picturesize_4bit_color(W, H)

View File

@ -64,7 +64,7 @@ int g1m_decode_std_addin(g1m_t **h, g1m_buffer_t *buffer,
/* fill icon */
g1m_decode_picture(handle->icon_unsel, g1m_pictureformat_1bit_packed,
hd.icon, handle->width, handle->height);
g1m_decode_picture(handle->icon_sel, g1m_pictureformat_1bit_packed,
g1m_decode_picture(handle->icon_sel, g1m_pictureformat_1bit_packed_r,
hd.icon, handle->width, handle->height);
/* skip size */
@ -117,7 +117,7 @@ int g1m_decode_std_cp_addin(g1m_t **h, g1m_buffer_t *buffer,
/* decode pictures */
g1m_decode_picture(handle->icon_unsel, g1m_pictureformat_1bit_packed,
cphd.icon, handle->width, handle->height);
g1m_decode_picture(handle->icon_sel, g1m_pictureformat_1bit_packed,
g1m_decode_picture(handle->icon_sel, g1m_pictureformat_1bit_packed_r,
cphd.icon, handle->width, handle->height);
/* log */

View File

@ -40,6 +40,7 @@ int g1m_make_picture(g1m_t **h, unsigned int width, unsigned int height)
memset(handle, 0, sizeof(g1m_t));
/* allocate the pixels */
handle->type = g1m_type_picture;
handle->width = width;
handle->height = height;
handle->pixels = alloc_pixels(width, height);

View File

@ -129,13 +129,26 @@ struct ext_corresp {
/* Extension correspondances */
static struct ext_corresp ext_types[] = {
/* fx types with non-checked header */
{"g1l", "fx language file", g1m_platform_fx, g1m_type_lang, 0},
{"g1n", "fx fkeys file", g1m_platform_fx, g1m_type_fkey, 0},
/* fx types */
{"g1l", "fx language file", g1m_platform_fx, g1m_type_lang, 0},
{"g1n", "fx fkeys file", g1m_platform_fx, g1m_type_fkey, 0},
{"g1m", "fx mcs archive", g1m_platform_fx, g1m_type_mcs, 0},
{"g1r", "fx mcs backup", g1m_platform_fx, g1m_type_mcs, 0},
{"g2m", "fx OS2 mcs archive", g1m_platform_fx, g1m_type_mcs, 0},
{"g2r", "fx OS2 mcs backup", g1m_platform_fx, g1m_type_mcs, 0},
{"g1a", "fx add-in", g1m_platform_fx, g1m_type_addin, 0},
{"g1e", "fx e-activity", g1m_platform_fx, g1m_type_eact, 0},
/* cg types with non-checked header */
{"g3l", "fx-CG language file", g1m_platform_cg, g1m_type_lang, f_sub},
{"g3n", "fx-CG fkeys file", g1m_platform_cg, g1m_type_fkey, f_sub},
/* fx-CP types */
{"c2p", "classpad picture", g1m_platform_cp, g1m_type_pict, 0},
{"c1a", "classpad add-in", g1m_platform_cp, g1m_type_addin, f_sub},
/* fx-CG types */
{"g3l", "fx-CG language file", g1m_platform_cg, g1m_type_lang, f_sub},
{"g3n", "fx-CG fkeys file", g1m_platform_cg, g1m_type_fkey, f_sub},
{"g3a", "fx-CG add-in", g1m_platform_cg, g1m_type_addin, f_sub},
{"g3e", "fx-CG e-activity", g1m_platform_cg, g1m_type_eact, 0},
{"g3p", "fx-CG picture", g1m_platform_cg, g1m_type_pict, 0},
/* sentinel */
{NULL, NULL, 0, 0, 0}

View File

@ -73,7 +73,20 @@ int g1m_decode_picture(uint32_t **pixels, g1m_pictureformat_t format,
}
break;
case g1m_pictureformat_1bit_reverse:
case g1m_pictureformat_1bit_packed_r:
msk = 0x80;
for (unsigned int y = 0; y < height; y++)
for (unsigned int x = 0; x < width; x++) {
/* get pixel */
pixels[y][x] = (*raw & msk) ? 0xFFFFFF : 0x000000;
/* go to next */
raw += msk & 1;
msk = (msk >> 1) | ((msk & 1) << 7);
}
break;
case g1m_pictureformat_1bit_packed_old:
for (unsigned int bx = width - 8; bx != (unsigned int)-8; bx -= 8)
for (unsigned int y = height - 1; y != (unsigned int)-1; y--) {
msk = 0x80;