Started adding G1L support
This commit is contained in:
parent
1db76edb8f
commit
8fafb74ff2
|
@ -53,7 +53,6 @@
|
|||
# - All C compiling flags
|
||||
CFLAGS := -I $(INCDIR) $(CHKFLAGS) -std=gnu11 -fPIC -O2 \
|
||||
-fstack-protector-strong -D LOGLEVEL="ll_$(LOG_LEVEL)" \
|
||||
-D_GNU_SOURCE -D_USE_GNU \
|
||||
-D AUTHOR="$(AUTHOR)" -D AUTHOR_MAIL="$(AUTHOR_MAIL)" \
|
||||
-D LICENSE="$(LICENSE)" -D VERSION="$(VERSION)" \
|
||||
$(CMOREFLAGS)
|
||||
|
|
|
@ -21,8 +21,7 @@ int g1m_fctomb(char *s, FONTCHARACTER fc);
|
|||
DESCRIPTION
|
||||
-----------
|
||||
Convert a FONTCHARACTER character to its multibyte representation,
|
||||
and stores it at the beginning of the character array pointed to by
|
||||
*s*.
|
||||
and stores it at the beginning of the character array pointed to by *s*.
|
||||
|
||||
The programmer must ensure that there is room for at least FC_MB_MAX bytes
|
||||
at *s*.
|
||||
|
|
|
@ -12,6 +12,39 @@
|
|||
# include <libg1m.h>
|
||||
# pragma pack(1)
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* G1L - Language files for fx calculators */
|
||||
/* ************************************************************************** */
|
||||
/* It all starts with a header: */
|
||||
|
||||
struct g1l_subheader {
|
||||
/* identifier: is "PowerUSB" on original things */
|
||||
uint8_t identifier[8];
|
||||
|
||||
/* unknown: 0x01 for SimLo, 0x02 for Cake */
|
||||
uint8_t w0t;
|
||||
|
||||
/* unknown : {0x00, 0x00, 0x00} */
|
||||
uint8_t magic[3];
|
||||
|
||||
/* message count */
|
||||
uint16_t message_count;
|
||||
|
||||
/* unknown */
|
||||
uint16_t unknown;
|
||||
};
|
||||
|
||||
/* Then comes a list of offsets, and the messages.
|
||||
*
|
||||
* Each element of the offsets list is 16-bytes long.
|
||||
* It is relative to the first element (which starts right after the
|
||||
* offsets list - no alignment).
|
||||
*
|
||||
* The messages are null-terminated - once you get the offsets, you get
|
||||
* them completely. */
|
||||
/* ************************************************************************** */
|
||||
/* G3L - Language files for Prizm */
|
||||
/* ************************************************************************** */
|
||||
/* Thanks to amazonka for his (minimalist) description of the G3L format
|
||||
* at Cemetech. So the G3L format starts off with a header: */
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ static const uint32_t colors[16] = {
|
|||
[g1m_color_red] = 0xff0000,
|
||||
[g1m_color_magenta] = 0xff00ff,
|
||||
[g1m_color_yellow] = 0xffff00,
|
||||
[g1m_color_white] = 0xffffff
|
||||
[g1m_color_white] = 0xffffff,
|
||||
/* RESERVED */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,14 +21,45 @@
|
|||
int g1m_parse_lang(g1m_t *handle, FILE *stream,
|
||||
struct standard_header *std)
|
||||
{
|
||||
(void)std;
|
||||
(void)handle;
|
||||
/* set handle type */
|
||||
//handle->type = g1m_type_lang;
|
||||
|
||||
(void)handle;
|
||||
(void)stream;
|
||||
/* TODO */
|
||||
log_info("Language type isn't managed yet.");
|
||||
/* read the subheader */
|
||||
DREAD(hd, g1l_subheader)
|
||||
logm_info(&hd, sizeof(struct g1l_subheader));
|
||||
|
||||
/* correct the endianness */
|
||||
uint_fast32_t num = be16toh(hd.message_count);
|
||||
|
||||
/* log */
|
||||
log_info("%lu messages to read", num);
|
||||
|
||||
/* beat the best, read the rest! */
|
||||
size_t data_size = std->filesize - sizeof(struct standard_header)
|
||||
- sizeof(struct g1l_subheader);
|
||||
uint8_t data[data_size];
|
||||
READ(data, data_size)
|
||||
|
||||
/* get the offset table */
|
||||
uint16_t *offsets = (uint16_t*)data;
|
||||
char *messages = (char*)(offsets + num);
|
||||
|
||||
/* read messages */
|
||||
for (uint_fast32_t i = 0; i < num; i++) {
|
||||
if (offsets[i] == (uint16_t)-1) {
|
||||
log_info("[#%lu] -", i);
|
||||
continue ;
|
||||
}
|
||||
|
||||
/* correct offset */
|
||||
offsets[i] = be16toh(offsets[i]);
|
||||
|
||||
/* log */
|
||||
log_info("[#%lu] '%s'", i, &messages[offsets[i]]);
|
||||
}
|
||||
|
||||
/* no error */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -119,7 +150,7 @@ int g1m_parse_lang_cg(g1m_t *handle, FILE *stream,
|
|||
offsets[i] = be32toh(offsets[i]);
|
||||
|
||||
/* log */
|
||||
log_info("[#%ld] message: '%s'", i, &messages[offsets[i]]);
|
||||
log_info("[#%ld] '%s'", i, &messages[offsets[i]]);
|
||||
}
|
||||
|
||||
/* no error */
|
||||
|
|
Reference in New Issue