cake
/
libg1m
Archived
1
0
Fork 0

g1m_mcs_cell_t -> g1m_mcscell_t

This commit is contained in:
Thomas Touhey 2017-03-23 17:42:59 +01:00
parent 658e70d5f9
commit d85d45f0fa
6 changed files with 36 additions and 37 deletions

View File

@ -29,24 +29,25 @@
/* Main Memory Types */
/* ************************************************************************** */
/* MCS file type */
# define PRIXMCSTYPE "lX"
# define PRIxMCSTYPE "lx"
# define PRIuMCSTYPE "lu"
# define PRIxMCSTYPE "lx"
# define PRIXMCSTYPE "lX"
typedef long unsigned int g1m_mcsfile_type_t;
typedef g1m_mcsfile_type_t g1m_mcstype_t;
# define g1m_mcstype_unknown 0x00000000
# define g1m_mcstype_program 0x00000001
# define g1m_mcstype_list 0x00000002
# define g1m_mcstype_mat 0x00000004
# define g1m_mcstype_pict 0x00000008
# define g1m_mcstype_capt 0x00000010
# define g1m_mcstype_ssheet 0x00000020
# define g1m_mcstype_string 0x00000040
# define g1m_mcstype_setup 0x00000080
# define g1m_mcstype_var 0x00000100
# define g1m_mcstype_vct 0x00000200
# define g1m_mcstype_end 0x00000400
/* MCS file types */
# define g1m_mcstype_unknown 0x00000000
# define g1m_mcstype_program 0x00000001
# define g1m_mcstype_list 0x00000002
# define g1m_mcstype_mat 0x00000004
# define g1m_mcstype_pict 0x00000008
# define g1m_mcstype_capt 0x00000010
# define g1m_mcstype_ssheet 0x00000020
# define g1m_mcstype_string 0x00000040
# define g1m_mcstype_setup 0x00000080
# define g1m_mcstype_var 0x00000100
# define g1m_mcstype_vct 0x00000200
# define g1m_mcstype_end 0x00000400
/* MCS file type aliases */
# define g1m_mcstype_matrix g1m_mcstype_mat
@ -67,7 +68,6 @@ typedef g1m_mcsfile_type_t g1m_mcstype_t;
((H)->type == g1m_mcstype_var && (H)->count == 1)))
# define g1m_get_id_major(I) ((I) >> 5)
# define g1m_get_id_minor(I) ((I) & 31)
/* ************************************************************************** */
/* Helpers */
/* ************************************************************************** */
@ -76,8 +76,7 @@ typedef struct g1m_mcs_cell_s {
g1m_bcd_t real;
g1m_bcd_t imgn;
int used;
} g1m_mcs_cell_t;
} g1m_mcscell_t;
/* ************************************************************************** */
/* Main structures */
/* ************************************************************************** */
@ -132,9 +131,9 @@ typedef struct g1m_mcsfile_s {
char *content;
/* variables */
g1m_mcs_cell_t var;
g1m_mcs_cell_t *vars;
g1m_mcs_cell_t **cells;
g1m_mcscell_t var;
g1m_mcscell_t *vars;
g1m_mcscell_t **cells;
/* for pictures and captures */
uint32_t **pic; /* 0x0RGB */

View File

@ -204,7 +204,7 @@ static int read_matrix(g1m_mcsfile_t **pfile, g1m_buffer_t *buffer,
if (err) return (err);
/* read the matrix */
g1m_mcs_cell_t **cells = (*pfile)->cells;
g1m_mcscell_t **cells = (*pfile)->cells;
for (unsigned int y = 0; y < height; y++)
for (unsigned int x = 0; x < width; x++) {
/* read the bcd */
@ -218,7 +218,7 @@ static int read_matrix(g1m_mcsfile_t **pfile, g1m_buffer_t *buffer,
#endif
/* make the cell */
cells[y][x] = (g1m_mcs_cell_t){
cells[y][x] = (g1m_mcscell_t){
.real = bcd,
.imgn = {},
.used = 1
@ -269,7 +269,7 @@ static int read_list(g1m_mcsfile_t **pfile, g1m_buffer_t *buffer,
if (err) return (err);
/* read the list */
g1m_mcs_cell_t **cells = (*pfile)->cells;
g1m_mcscell_t **cells = (*pfile)->cells;
for (int x = 0; x < len; x++) {
/* read bcd */
g1m_bcd_t bcd; g1m_bcd_fromdouble(*raw++, &bcd);
@ -282,7 +282,7 @@ static int read_list(g1m_mcsfile_t **pfile, g1m_buffer_t *buffer,
#endif
/* set the cell */
cells[x][0] = (g1m_mcs_cell_t){
cells[x][0] = (g1m_mcscell_t){
.real = bcd,
.imgn = {},
.used = 1

View File

@ -43,13 +43,13 @@ int g1m_decode_mcs_list(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
if (err) return (err);
/* main copying loop */
g1m_mcs_cell_t **tab = (*handle)->cells; int one_imgn = 0;
g1m_mcscell_t **tab = (*handle)->cells; int one_imgn = 0;
for (uint_fast32_t y = 0; y < elcount; y++) {
g1m_bcd_t bcd; GDREAD(rawbcd, bcd)
one_imgn |= g1m_bcd_frommcs(&rawbcd, &bcd);
/* prepare index and store */
tab[y][0] = (g1m_mcs_cell_t){
tab[y][0] = (g1m_mcscell_t){
.real = bcd,
.imgn = {},
.used = 1

View File

@ -49,7 +49,7 @@ int g1m_decode_mcs_matrix(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
return (err);
/* main copying loop */
g1m_mcs_cell_t **tab = (*handle)->cells; int one_imgn = 0;
g1m_mcscell_t **tab = (*handle)->cells; int one_imgn = 0;
for (uint_fast32_t y = 0; y < h; y++)
for (uint_fast32_t x = 0; x < w; x++) {
/* read the cell */
@ -57,7 +57,7 @@ int g1m_decode_mcs_matrix(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
one_imgn |= g1m_bcd_frommcs(&rawbcd, &bcd);
/* store it */
tab[y][x] = (g1m_mcs_cell_t){
tab[y][x] = (g1m_mcscell_t){
.real = bcd,
.imgn = {},
.used = 1
@ -128,7 +128,7 @@ int g1m_decode_caspart_matrix(g1m_mcsfile_t *handle, g1m_buffer_t *buffer)
cell.y = be16toh(cell.y);
cell.x = be16toh(cell.x);
g1m_bcd_t bcd; g1m_bcd_fromcas(&cell.val, &bcd);
handle->cells[cell.y][cell.x] = (g1m_mcs_cell_t){
handle->cells[cell.y][cell.x] = (g1m_mcscell_t){
.real = bcd,
.imgn = {},
.used = 1

View File

@ -43,8 +43,8 @@ int g1m_decode_mcs_spreadsheet(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
shd.defs_size = be32toh(shd.defs_size);
/* prepare */
g1m_mcs_cell_t cells[1000 * colcount];
bzero(cells, sizeof(g1m_mcs_cell_t) * 1000 * colcount);
g1m_mcscell_t cells[1000 * colcount];
bzero(cells, sizeof(g1m_mcscell_t) * 1000 * colcount);
int cells_count = 0;
uint_fast32_t rows = 0;
uint_fast32_t cols = 0;
@ -81,7 +81,7 @@ int g1m_decode_mcs_spreadsheet(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
g1m_bcd_frommcs(&rawcell, &cell);
/* store it */
cells[c * 1000 + i] = (g1m_mcs_cell_t){
cells[c * 1000 + i] = (g1m_mcscell_t){
.used = 1,
.real = cell,
.imgn = (g1m_bcd_t){}
@ -110,7 +110,7 @@ int g1m_decode_mcs_spreadsheet(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
if (err) return (err);
/* main copying loop */
g1m_mcs_cell_t **tab = (*handle)->cells;
g1m_mcscell_t **tab = (*handle)->cells;
for (uint_fast32_t y = 0; y < head->height; y++)
for (uint_fast32_t x = 0; x < head->width; x++)
tab[y][x] = cells[x * 1000 + y];

View File

@ -49,9 +49,9 @@ int g1m_make_mcsfile(g1m_mcsfile_t **handle, const g1m_mcshead_t *rawhead)
log_info("Preparing %d*%d matrix", head->width, head->height);
unsigned int wd = head->width, ht = head->height;
if (wd && ht) {
h->cells = malloc(sizeof(g1m_mcs_cell_t*) * ht);
h->cells = malloc(sizeof(g1m_mcscell_t*) * ht);
if (!h->cells) goto fail;
h->cells[0] = malloc(sizeof(g1m_mcs_cell_t) * wd * ht);
h->cells[0] = malloc(sizeof(g1m_mcscell_t) * wd * ht);
if (!h->cells[0]) { free(h->cells); goto fail; }
for (unsigned int y = 1; y < ht; y++)
@ -63,9 +63,9 @@ int g1m_make_mcsfile(g1m_mcsfile_t **handle, const g1m_mcshead_t *rawhead)
case g1m_mcstype_alphamem:
if (head->count <= 1) h->vars = &h->var;
else {
h->vars = malloc(sizeof(g1m_mcs_cell_t) * head->count);
h->vars = malloc(sizeof(g1m_mcscell_t) * head->count);
if (!h->vars) goto fail;
memset(h->vars, 0, sizeof(g1m_mcs_cell_t) * head->count);
memset(h->vars, 0, sizeof(g1m_mcscell_t) * head->count);
}
break;