Added AlphaMem parsing, corrected SMEM notes.
This commit is contained in:
parent
aefd2d0e30
commit
63c5f29818
|
@ -18,7 +18,9 @@
|
|||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
# define g1m_ans 27
|
||||
# define g1m_theta 27
|
||||
# define g1m_r 28
|
||||
# define g1m_ans 29
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Errors */
|
||||
|
@ -110,6 +112,9 @@ typedef struct {
|
|||
unsigned int columns, rows;
|
||||
g1m_mcs_cell_t **cells;
|
||||
|
||||
/* variables */
|
||||
g1m_mcs_cell_t *vars;
|
||||
|
||||
/* for pictures and captures */
|
||||
unsigned int width, height;
|
||||
uint32_t **image; /* 0x0RGB */
|
||||
|
|
|
@ -50,14 +50,17 @@ enum storage_entry_type {
|
|||
storage_entrytype_fragment = 0x130,
|
||||
};
|
||||
|
||||
/* There is no count of the entries, but there is a terminating entry,
|
||||
* identified by its type being 0xFFFF. */
|
||||
/* The list has 0x800 entries, and occupies the two first sectors (or maybe
|
||||
* just one, but it looks like data storage starts at sector 3). Entries with
|
||||
* a type being 0xFFFF should not be read. */
|
||||
/* ************************************************************************** */
|
||||
/* Sectors */
|
||||
/* ************************************************************************** */
|
||||
/* Sectors represent the physical sectors of the storage memory (space!).
|
||||
* Simon Lothar says that there are 27 entries for them (or 25 "not on the
|
||||
* AU" in the other documentation, whatever that means).
|
||||
* AU" in the other documentation, whatever that means). If the logical number
|
||||
* is 0xFFFFFFFF, the sector is unused. First sector contains gibberish in the
|
||||
* logical number field, as it's occupied by the directory.
|
||||
*
|
||||
* Their special nibble is either 0x04 or 0x00, I don't know why yet.
|
||||
* Here is their subheader structure: */
|
||||
|
|
|
@ -547,10 +547,41 @@ static int mcs_parse_setup(g1m_mcsfile_t *handle, FILE *stream,
|
|||
static int mcs_parse_alphamem(g1m_mcsfile_t *handle, FILE *stream,
|
||||
uint_fast32_t length)
|
||||
{
|
||||
(void)handle;
|
||||
log_info("Alpha Memory MCS file is not managed yet.");
|
||||
/* TODO */
|
||||
SKIP(length)
|
||||
/* read the data */
|
||||
uint8_t buf[length];
|
||||
READ(buf, length)
|
||||
|
||||
/* allocate the vars table */
|
||||
handle->vars = malloc(29 * sizeof(g1m_mcs_cell_t));
|
||||
if (!handle->vars) return (g1m_error_alloc);
|
||||
bzero(handle->vars, 29 * sizeof(g1m_mcs_cell_t));
|
||||
|
||||
/* copy */
|
||||
size_t tocopy = length - length % sizeof(g1m_mcs_cell_t);
|
||||
memcpy(handle->vars, buf, tocopy);
|
||||
|
||||
/* log */
|
||||
#if LOGLEVEL <= ll_inf
|
||||
for (int i = 0; i < 29; i++) {
|
||||
const char *var_name = (const char*[]){
|
||||
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
||||
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
||||
"Theta", "r", "Ans"
|
||||
}[i];
|
||||
|
||||
char *real_string = g1m_bcdtoa(&handle->vars[i].real);
|
||||
if (!g1m_bcd_has_complex(&handle->vars[i].real))
|
||||
log_info("%s is (%s).", var_name, real_string);
|
||||
else {
|
||||
char *imgn_string = g1m_bcdtoa(&handle->vars[i].imgn);
|
||||
log_info("%s is (%s)+(%s)i.", var_name, real_string, imgn_string);
|
||||
free(imgn_string);
|
||||
}
|
||||
free(real_string);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* no problem, woop woop */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -643,13 +674,13 @@ int g1m_parse_mcsfile_content(g1m_mcsfile_t **handle, FILE *stream,
|
|||
h->name[8] = 0; strncpy(h->name, (char*)filename, 8);
|
||||
|
||||
/* look for the raw type */
|
||||
unsigned int type; int id;
|
||||
unsigned int type;
|
||||
if (g1m_mcstype_getlib(h->_group, h->name, raw_type, &type, &h->id))
|
||||
goto notparsing;
|
||||
log_info("libg1m file type is 0x%02x", type);
|
||||
if (g1m_mcstype_uses_id(type)) {
|
||||
log_info("libg1m file id is (%d, %d)", g1m_get_id_major(id),
|
||||
g1m_get_id_minor(id));
|
||||
log_info("libg1m file id is (%d, %d)", g1m_get_id_major(h->id),
|
||||
g1m_get_id_minor(h->id));
|
||||
}
|
||||
|
||||
/* look for the parsing function */
|
||||
|
|
|
@ -60,6 +60,10 @@ void g1m_free_mcsfile_content(g1m_mcsfile_t *handle)
|
|||
free(handle->second_image);
|
||||
}
|
||||
|
||||
/* free the vars */
|
||||
if (handle->type & g1m_mcstype_alphamem)
|
||||
free(handle->vars);
|
||||
|
||||
/* free the content */
|
||||
if (handle->type & g1m_mcstype_program)
|
||||
free(handle->content);
|
||||
|
|
Reference in New Issue