/*
 *  Xfcalc version 1.1 - A multi-base calculator for X
 *  Copyright (C) 2026 Christopher John Purnell
 *                     cjp@lost.org.uk
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not see <https://www.gnu.org/licenses/>.
 */

#ifndef XFCALC_CALC_H
#define XFCALC_CALC_H

#define DIGITS 15

extern void fn_ac(int, int);
extern void fn_clr(int, int);
extern void fn_min(int, int);
extern void fn_mr(int, int);
extern void fn_mp(int, int);
extern void fn_swp(int, int);
extern void fn_rnd(int, int);
extern void fn_del(int, int);
extern void fn_rcp(int, int);
extern void fn_fct(int, int);
extern void fn_pow(int, int);
extern void fn_sqr(int, int);
extern void fn_opn(int, int);
extern void fn_cls(int, int);
extern void fn_sin(int, int);
extern void fn_cos(int, int);
extern void fn_tan(int, int);
extern void fn_bin(int, int);
extern void fn_log(int, int);
extern void fn_ln(int, int);
extern void fn_e(int, int);
extern void fn_pi(int, int);
extern void fn_not(int, int);
extern void fn_num(int, int);
extern void fn_pnt(int, int);
extern void fn_exp(int, int);
extern void fn_equ(int, int);
extern void fn_sgn(int, int);

#define ED_NUM 1
#define ED_PNT 2
#define ED_EXP 4

extern char bra_str[], num_str[];
extern double value, mem_val;
extern double drg, base;
extern int edit, edit_len, exp_max;
extern int braket;
extern char last;
extern int tok_ptr, num_ptr;
extern char tok_stack[];
extern double num_stack[];

extern const char digit[16];

extern void start_edit(char);
extern void stop_edit(void);
extern void redraw(void);
extern void refresh(void);
extern void set_value(double);

#define BRAKET   0x00
#define BIN_SUB  0x10
#define BIN_ADD  0x11
#define BIN_OR   0x12
#define BIN_MUL  0x23
#define BIN_DIV  0x24
#define BIN_MOD  0x25
#define BIN_AND  0x26
#define BIN_POW  0x37
#define BIN_ROOT 0x38
#define BIN_XOR  0x39

#define LVL_MASK 0xF0
#define FN_MASK  0x0F

extern void add_fn(int);
extern void open_bra(void);
extern void close_bra(void);
extern void evaluate(void);

extern double m_and(double, double);
extern double m_or(double, double);
extern double m_xor(double, double);

#endif
