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/format/cas/gmem.h

71 lines
2.7 KiB
C

/* *****************************************************************************
* libg1m/format/cas/gmem.h -- description of the CAS G-MEM format.
* 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_FORMAT_CAS_GMEM_H
# define LIBG1M_FORMAT_CAS_GMEM_H
# include <stdint.h>
# pragma pack(1)
/* You can save some graph function's expression inside a graph memory (G-MEM).
* The data size is stored in CAS50's `length` field.
* TODO: find out the equivalent with CAS40 headers?
*
* It starts with 20 graph entries, which have this format: */
typedef struct g1m_cas_gmem_entry_s {
/* function type code */
uint8_t g1m_cas_gmem_entry_type;
/* flags */
uint8_t g1m_cas_gmem_entry_flags;
} g1m_cas_gmem_entry_t;
/* Where the function types are the following: */
# define cas_gmem_type_ye 0x00 /* Y= */
# define cas_gmem_type_re 0x40 /* r= */
# define cas_gmem_type_yg 0x0C /* Y> */
# define cas_gmem_type_yl 0x0D /* Y< */
# define cas_gmem_type_yge 0x0E /* Y>= */
# define cas_gmem_type_yle 0x0F /* Y<= */
/* And the flags are the following: */
# define cas_gmem_flag_orange 0x01
# define cas_gmem_flag_blue 0x02
# define cas_gmem_flag_green 0x04
# define cas_gmem_flag_sel 0x80
# define cas_gmem_flag_eqsel 0xB0
/* If there are no flags (`entry.flags == 0`), then the function is not defined.
* If the function type is one of: Y=, r=, Param (?)
* Then use `cas_gmem_flag_eqsel` instead of `cas_gmem_flag_sel`.
*
* Then what we have after is the real content of the G-MEM (Y=DATA).
* Each function's expression is separated from the others by a 0xFF character.
* Casetta's documentation says the data is reversed, I don't know what they
* mean (order? bitwise not?).
*
* There are 90 characters at the end of the content. It seems that they don't
* change if you have one or more Y= function defined (independently of the
* function expression).
* TODO: find out what these are. */
# pragma pack()
#endif /* LIBG1M_FORMAT_CAS_GMEM_H */