60 lines
2.2 KiB
C
60 lines
2.2 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->g1m_mcshead_size];
|
|
READ(content, head->g1m_mcshead_size)
|
|
|
|
/* make final head and file */
|
|
int err = g1m_make_mcsfile(handle, head);
|
|
if (err) return (err);
|
|
g1m_setup_t *sp = &(*handle)->g1m_mcsfile_setup;
|
|
|
|
/* get input flags */
|
|
switch (content[0x14]) {
|
|
case 0x84: sp->g1m_setup_iflags |= g1m_setupiflag_alpha;
|
|
case 0x01: sp->g1m_setup_iflags |= g1m_setupiflag_shift; break;
|
|
case 0x04: sp->g1m_setup_iflags |= g1m_setupiflag_alpha; break; }
|
|
if (content[0x15] == 0x02) sp->g1m_setup_iflags |= g1m_setupiflag_insert;
|
|
if (content[0x53] == 0x00) sp->g1m_setup_iflags |= g1m_setupiflag_math;
|
|
|
|
/* get window flags */
|
|
if (content[0x1C]) sp->g1m_setup_wflags |= g1m_setupwflag_grid;
|
|
if (content[0x1D]) sp->g1m_setup_wflags |= g1m_setupwflag_axes;
|
|
if (content[0x19]) sp->g1m_setup_wflags |= g1m_setupwflag_plot;
|
|
|
|
/* TODO: decode more options! */
|
|
/* no error! */
|
|
return (0);
|
|
}
|