cake
/
libg1m
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libg1m/include/libg1m/mcs.h

117 lines
4.0 KiB
C

/* *****************************************************************************
* libg1m/mcs.h -- libg1m main memory header.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libg1m.
* libg1m is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version.
*
* libg1m is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libg1m; if not, see <http://www.gnu.org/licenses/>.
* ************************************************************************** */
#ifndef LIBG1M_MCS_H
# define LIBG1M_MCS_H
# include <libg1m/bcd.h>
# define g1m_theta 27
# define g1m_r 28
# define g1m_ans 29
/* ************************************************************************** */
/* Main Memory Types */
/* ************************************************************************** */
/* MCS file type */
typedef unsigned int g1m_mcsfile_type_t;
typedef unsigned int g1m_mcstype_t;
# define g1m_mcstype_unknown 0x0000
# define g1m_mcstype_program 0x0001
# define g1m_mcstype_list 0x0002
# define g1m_mcstype_mat 0x0004
# define g1m_mcstype_pict 0x0008
# define g1m_mcstype_capt 0x0010
# define g1m_mcstype_spreadsheet 0x0020
# define g1m_mcstype_string 0x0040
# define g1m_mcstype_setup 0x0080
# define g1m_mcstype_alphamem 0x0100
# define g1m_mcstype_vct 0x0200
# define g1m_mcstype_variable 0x0400
/* MCS file type aliases */
# define g1m_mcstype_picture g1m_mcstype_pict
# define g1m_mcstype_capture g1m_mcstype_capt
# define g1m_mcstype_vector g1m_mcstype_vct
/* Macros to check if the type uses the ID, and to interact with it */
# define g1m_mcstype_uses_id(T) ((T) & (\
g1m_mcstype_list | g1m_mcstype_mat | g1m_mcstype_vct | \
g1m_mcstype_pict | g1m_mcstype_capt | g1m_mcstype_string | \
g1m_mcstype_variable))
# define g1m_get_id_major(I) ((I) >> 5)
# define g1m_get_id_minor(I) ((I) & 31)
/* ************************************************************************** */
/* Helpers */
/* ************************************************************************** */
/* List, Matrix, Vector and Spreadsheet cell. */
typedef struct g1m_mcs_cell_s {
g1m_bcd_t real;
g1m_bcd_t imgn;
int used;
} g1m_mcs_cell_t;
/* ************************************************************************** */
/* Main structures */
/* ************************************************************************** */
/* mcs file head flags */
# define g1m_mcshead_complex 0x0001 /* is a complex variable */
/* mcs file head */
typedef struct g1m_mcshead_s {
/* file main information */
g1m_mcstype_t type;
char name[13]; int id;
unsigned int flags;
/* content size */
uint_fast32_t size;
/* raw data */
unsigned int _rawtype;
unsigned char _group[17], _dirname[9];
} g1m_mcshead_t;
/* mcs file */
# define g1m_has_password(F) (F)->password[0]
# define g1m_remove_password(F) (F)->password[0] = 0
typedef struct g1m_mcsfile_s {
/* head */
g1m_mcshead_t head;
/* content (useful when not read) */
char *content;
/* for programs: the password */
char password[9];
/* for spreadsheets, lists and matrixes */
unsigned int columns, rows;
g1m_mcs_cell_t **cells;
/* variables */
int count;
g1m_mcs_cell_t *vars;
/* for pictures and captures */
unsigned int width, height;
uint32_t **image; /* 0x0RGB */
uint32_t **second_image; /* 0x0RGB */
} g1m_mcsfile_t;
#endif /* LIBG1M_MCS_H */