cake
/
libg1m
Archived
1
0
Fork 0

Implemented place holder for fx language

This commit is contained in:
Thomas Touhey 2016-11-24 23:23:43 +01:00
parent 8790934f6f
commit ebb674e304
7 changed files with 36 additions and 8 deletions

View File

@ -4,6 +4,7 @@
- G1N (???);
- G3L (languages for cg calculators);
- G3M (like G1M?);
- G1K/G3K (keys?).
## Correct the parsing of these formats
- G1M (BCD, other subtypes);

View File

@ -25,11 +25,14 @@
* MCS, e-acts), some data that will be useful for the MCS type, and some
* magic and control bytes.
*
* For some reason, this StandardHeader is INVERTED on every file it's on,
* you will have to apply a NOT operation on its bytes for it to make sense.
*
* Keep in mind that, everywhere in the header, multi-bytes integers
* are BIG ENDIAN.
*
* The LSB is the Least Significant Byte: once adapted to the host endianness,
* it can simply be obtained bitwise-AND-ing with 0xff. */
* it can simply be obtained by bitwise-AND-ing with 0xff. */
struct standard_header {
/* the file identifier - see below */
@ -79,9 +82,12 @@ enum g1m_main_id {
g1m_mid_ly755,
};
/* Here are USBPower types: */
/* Each main ID have their own types. Here are the USBPower types: */
enum g1m_usbpower_type {
/* fx language file */
g1m_usbpower_type_lang = 0x12,
/* fx-CG add-in */
g1m_usbpower_type_addin_cg = 0x2c,

View File

@ -13,7 +13,7 @@
/* These are pictures for fx-CG. They only have one part.
* This mysteries over this format have been unraveled by many, but I'm using
* Simon Lothar's and Kerm Martian's documentations.
* Simon Lothar's documentation and Kerm Martian's articles.
*
* Some color depth things: */
@ -90,7 +90,7 @@ struct g3p_imageheader {
*
* Which, simplified and with our structures, is:
*
* std.obfuscated + 8 != (std.filesize & 0xff00) >> 8
* (std.obfuscated + 8) & 0xff != (std.filesize & 0xff00) >> 8
*
* then the deflated image is encrypted.
*

View File

@ -64,6 +64,7 @@ int g1m_parse_eact(g1m_t * handle, FILE *stream);
int g1m_parse_addin(g1m_t *handle, FILE *stream);
int g1m_parse_addin_cg(g1m_t *handle, FILE *stream,
struct standard_header *std);
int g1m_parse_lang(g1m_t *handle, FILE *stream);
int g1m_parse_lang_cg(g1m_t *handle, FILE *stream);
/* ************************************************************************** */

View File

@ -9,9 +9,26 @@
/* ************************************************************************** */
#include <libg1m/internals.h>
/**
* g1m_parse_lang:
* Parse fx language files.
*
* @arg handle the libg1m handle.
* @arg stream the stream to parse from.
* @return the error code (0 if ok).
*/
int g1m_parse_lang(g1m_t *handle, FILE *stream)
{
(void)handle;
(void)stream;
log_info("Language type isn't managed yet.");
return (0);
}
/**
* g1m_parse_lang_cg:
* Parse fx-CG lang files.
* Parse fx-CG language files.
*
* @arg handle the libg1m handle.
* @arg stream the stream to parse from.
@ -22,6 +39,6 @@ int g1m_parse_lang_cg(g1m_t *handle, FILE *stream)
{
(void)handle;
(void)stream;
log_info("Lang type isn't managed yet.");
log_info("Language type isn't managed yet.");
return (0);
}

View File

@ -86,6 +86,9 @@ int g1m_parse(g1m_t *handle, FILE *stream)
switch (main_id) {
case g1m_mid_usbpower:
switch (hd.type) {
case g1m_usbpower_type_lang:
handle->type = g1m_type_lang;
return (g1m_parse_lang(handle, stream));
case g1m_usbpower_type_addin:
handle->type = g1m_type_addin;
return (g1m_parse_addin(handle, stream));

View File

@ -59,8 +59,8 @@ int g1m_parse_g3p(g1m_t *handle, FILE *stream,
ihd.data_size = be32toh(ihd.data_size);
/* check some little things */
int is_obfuscated = ((uint8_t)(std->obfuscated + 8)
!= (uint8_t)((std->filesize & 0xff00) >> 8));
int is_obfuscated =
(std->obfuscated + 8) & 0xff != ((std->filesize & 0xff00) >> 8);
int has_footer = 1; /* might change? */
size_t deflated_image_size = ihd.data_size - has_footer * 0x4;