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/src/decode/mcs/setup.c

60 lines
2.1 KiB
C

/* *****************************************************************************
* decode/mcs/setup.c -- decode an MCS setup file.
* 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/>.
* ************************************************************************** */
#include <libg1m/internals.h>
/**
* g1m_decode_mcs_setup:
* Decode settings.
*
* @arg handle the handle to make.
* @arg buffer the buffer to read from.
* @arg head the pre-filled head to complete and use.
* @return the error code (0 if ok).
*/
int g1m_decode_mcs_setup(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
g1m_mcshead_t *head)
{
/* read content */
uint8_t content[head->size];
READ(content, head->size)
/* make final head and file */
int err = g1m_make_mcsfile(handle, head);
if (err) return (err);
g1m_setup_t *sp = &(*handle)->setup;
/* get input flags */
switch (content[0x14]) {
case 0x84: sp->iflags |= g1m_setupiflag_alpha;
case 0x01: sp->iflags |= g1m_setupiflag_shift; break;
case 0x04: sp->iflags |= g1m_setupiflag_alpha; break; }
if (content[0x15] == 0x02) sp->iflags |= g1m_setupiflag_insert;
if (!content[0x53]) sp->iflags |= g1m_setupiflag_math;
/* get window flags */
if (content[0x1C]) sp->wflags |= g1m_setupwflag_grid;
if (content[0x1D]) sp->wflags |= g1m_setupwflag_axes;
if (content[0x19]) sp->wflags |= g1m_setupwflag_plot;
/* TODO: decode more options! */
/* no error! */
return (0);
}