| 1 |
/***************************************************************************** |
| 2 |
* Free42 -- an HP-42S calculator simulator |
| 3 |
* Copyright (C) 2004-2026 Thomas Okken |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License, version 2, |
| 7 |
* as published by the Free Software Foundation. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, see http://www.gnu.org/licenses/. |
| 16 |
*****************************************************************************/ |
| 17 |
|
| 18 |
#ifndef CORE_GLOBALS_H |
| 19 |
#define CORE_GLOBALS_H 1 |
| 20 |
|
| 21 |
|
| 22 |
#include <stdio.h> |
| 23 |
|
| 24 |
#include "free42.h" |
| 25 |
#include "core_phloat.h" |
| 26 |
#include "core_tables.h" |
| 27 |
#include "core_variables.h" |
| 28 |
|
| 29 |
extern FILE *gfile; |
| 30 |
|
| 31 |
/**********/ |
| 32 |
/* Errors */ |
| 33 |
/**********/ |
| 34 |
|
| 35 |
#define ERR_NONE 0 |
| 36 |
#define ERR_ALPHA_DATA_IS_INVALID 1 |
| 37 |
#define ERR_OUT_OF_RANGE 2 |
| 38 |
#define ERR_DIVIDE_BY_0 3 |
| 39 |
#define ERR_INVALID_TYPE 4 |
| 40 |
#define ERR_INVALID_DATA 5 |
| 41 |
#define ERR_NONEXISTENT 6 |
| 42 |
#define ERR_DIMENSION_ERROR 7 |
| 43 |
#define ERR_TOO_FEW_ARGUMENTS 8 |
| 44 |
#define ERR_SIZE_ERROR 9 |
| 45 |
#define ERR_STACK_DEPTH_ERROR 10 |
| 46 |
#define ERR_RESTRICTED_OPERATION 11 |
| 47 |
#define ERR_YES 12 |
| 48 |
#define ERR_NO 13 |
| 49 |
#define ERR_STOP 14 |
| 50 |
#define ERR_LABEL_NOT_FOUND 15 |
| 51 |
#define ERR_NO_REAL_VARIABLES 16 |
| 52 |
#define ERR_NO_COMPLEX_VARIABLES 17 |
| 53 |
#define ERR_NO_MATRIX_VARIABLES 18 |
| 54 |
#define ERR_NO_MENU_VARIABLES 19 |
| 55 |
#define ERR_STAT_MATH_ERROR 20 |
| 56 |
#define ERR_INVALID_FORECAST_MODEL 21 |
| 57 |
#define ERR_SINGULAR_MATRIX 22 |
| 58 |
#define ERR_SOLVE_SOLVE 23 |
| 59 |
#define ERR_INTEG_INTEG 24 |
| 60 |
#define ERR_RUN 25 |
| 61 |
#define ERR_INTERRUPTED 26 |
| 62 |
#define ERR_PRINTING_IS_DISABLED 27 |
| 63 |
#define ERR_INTERRUPTIBLE 28 |
| 64 |
#define ERR_NO_VARIABLES 29 |
| 65 |
#define ERR_INSUFFICIENT_MEMORY 30 |
| 66 |
#define ERR_NOT_YET_IMPLEMENTED 31 |
| 67 |
#define ERR_INTERNAL_ERROR 32 |
| 68 |
#define ERR_SUSPICIOUS_OFF 33 |
| 69 |
#define ERR_RTN_STACK_FULL 34 |
| 70 |
#define ERR_NUMBER_TOO_LARGE 35 |
| 71 |
#define ERR_NUMBER_TOO_SMALL 36 |
| 72 |
#define ERR_BIG_STACK_DISABLED 37 |
| 73 |
#define ERR_INVALID_CONTEXT 38 |
| 74 |
#define ERR_NAME_TOO_LONG 39 |
| 75 |
#define ERR_PROGRAM_LOCKED 40 |
| 76 |
#define ERR_NEXT_PROGRAM_LOCKED 41 |
| 77 |
|
| 78 |
#define RTNERR_MAX 8 |
| 79 |
|
| 80 |
struct error_spec { |
| 81 |
const char *text; |
| 82 |
int length; |
| 83 |
}; |
| 84 |
|
| 85 |
extern const error_spec errors[]; |
| 86 |
|
| 87 |
|
| 88 |
/*************/ |
| 89 |
/* Key codes */ |
| 90 |
/*************/ |
| 91 |
|
| 92 |
#define KEY_SIGMA 1 |
| 93 |
#define KEY_INV 2 |
| 94 |
#define KEY_SQRT 3 |
| 95 |
#define KEY_LOG 4 |
| 96 |
#define KEY_LN 5 |
| 97 |
#define KEY_XEQ 6 |
| 98 |
#define KEY_STO 7 |
| 99 |
#define KEY_RCL 8 |
| 100 |
#define KEY_RDN 9 |
| 101 |
#define KEY_SIN 10 |
| 102 |
#define KEY_COS 11 |
| 103 |
#define KEY_TAN 12 |
| 104 |
#define KEY_ENTER 13 |
| 105 |
#define KEY_SWAP 14 |
| 106 |
#define KEY_CHS 15 |
| 107 |
#define KEY_E 16 |
| 108 |
#define KEY_BSP 17 |
| 109 |
#define KEY_UP 18 |
| 110 |
#define KEY_7 19 |
| 111 |
#define KEY_8 20 |
| 112 |
#define KEY_9 21 |
| 113 |
#define KEY_DIV 22 |
| 114 |
#define KEY_DOWN 23 |
| 115 |
#define KEY_4 24 |
| 116 |
#define KEY_5 25 |
| 117 |
#define KEY_6 26 |
| 118 |
#define KEY_MUL 27 |
| 119 |
#define KEY_SHIFT 28 |
| 120 |
#define KEY_1 29 |
| 121 |
#define KEY_2 30 |
| 122 |
#define KEY_3 31 |
| 123 |
#define KEY_SUB 32 |
| 124 |
#define KEY_EXIT 33 |
| 125 |
#define KEY_0 34 |
| 126 |
#define KEY_DOT 35 |
| 127 |
#define KEY_RUN 36 |
| 128 |
#define KEY_ADD 37 |
| 129 |
|
| 130 |
|
| 131 |
/*********/ |
| 132 |
/* Menus */ |
| 133 |
/*********/ |
| 134 |
|
| 135 |
#define MENU_NONE -1 |
| 136 |
#define MENU_ALPHA1 0 |
| 137 |
#define MENU_ALPHA2 1 |
| 138 |
#define MENU_ALPHA_ABCDE1 2 |
| 139 |
#define MENU_ALPHA_ABCDE2 3 |
| 140 |
#define MENU_ALPHA_FGHI 4 |
| 141 |
#define MENU_ALPHA_JKLM 5 |
| 142 |
#define MENU_ALPHA_NOPQ1 6 |
| 143 |
#define MENU_ALPHA_NOPQ2 7 |
| 144 |
#define MENU_ALPHA_RSTUV1 8 |
| 145 |
#define MENU_ALPHA_RSTUV2 9 |
| 146 |
#define MENU_ALPHA_WXYZ 10 |
| 147 |
#define MENU_ALPHA_PAREN 11 |
| 148 |
#define MENU_ALPHA_ARROW 12 |
| 149 |
#define MENU_ALPHA_COMP 13 |
| 150 |
#define MENU_ALPHA_MATH 14 |
| 151 |
#define MENU_ALPHA_PUNC1 15 |
| 152 |
#define MENU_ALPHA_PUNC2 16 |
| 153 |
#define MENU_ALPHA_MISC1 17 |
| 154 |
#define MENU_ALPHA_MISC2 18 |
| 155 |
#define MENU_ST 19 |
| 156 |
#define MENU_IND_ST 20 |
| 157 |
#define MENU_IND 21 |
| 158 |
#define MENU_MODES1 22 |
| 159 |
#define MENU_MODES2 23 |
| 160 |
#define MENU_MODES3 24 |
| 161 |
#define MENU_MODES4 25 |
| 162 |
#define MENU_MODES_MENUS 26 |
| 163 |
#define MENU_DISP 27 |
| 164 |
#define MENU_CLEAR1 28 |
| 165 |
#define MENU_CLEAR2 29 |
| 166 |
#define MENU_CONVERT1 30 |
| 167 |
#define MENU_CONVERT2 31 |
| 168 |
#define MENU_FLAGS 32 |
| 169 |
#define MENU_PROB 33 |
| 170 |
#define MENU_CUSTOM1 34 |
| 171 |
#define MENU_CUSTOM2 35 |
| 172 |
#define MENU_CUSTOM3 36 |
| 173 |
#define MENU_PGM_FCN1 37 |
| 174 |
#define MENU_PGM_FCN2 38 |
| 175 |
#define MENU_PGM_FCN3 39 |
| 176 |
#define MENU_PGM_FCN4 40 |
| 177 |
#define MENU_PGM_XCOMP0 41 |
| 178 |
#define MENU_PGM_XCOMPY 42 |
| 179 |
#define MENU_PRINT1 43 |
| 180 |
#define MENU_PRINT2 44 |
| 181 |
#define MENU_PRINT3 45 |
| 182 |
#define MENU_TOP_FCN 46 |
| 183 |
#define MENU_CATALOG 47 |
| 184 |
#define MENU_BLANK 48 |
| 185 |
#define MENU_PROGRAMMABLE 49 |
| 186 |
#define MENU_VARMENU 50 |
| 187 |
#define MENU_STAT1 51 |
| 188 |
#define MENU_STAT2 52 |
| 189 |
#define MENU_STAT_CFIT 53 |
| 190 |
#define MENU_STAT_MODL 54 |
| 191 |
#define MENU_STAT_SUMS1 55 |
| 192 |
#define MENU_STAT_SUMS2 56 |
| 193 |
#define MENU_STAT_SUMS3 57 |
| 194 |
#define MENU_MATRIX1 58 |
| 195 |
#define MENU_MATRIX2 59 |
| 196 |
#define MENU_MATRIX3 60 |
| 197 |
#define MENU_MATRIX_SIMQ 61 |
| 198 |
#define MENU_MATRIX_EDIT1 62 |
| 199 |
#define MENU_MATRIX_EDIT2 63 |
| 200 |
#define MENU_BASE1 64 |
| 201 |
#define MENU_BASE2 65 |
| 202 |
#define MENU_BASE3 66 |
| 203 |
#define MENU_BASE4 67 |
| 204 |
#define MENU_BASE5 68 |
| 205 |
#define MENU_BASE_A_THRU_F 69 |
| 206 |
#define MENU_BASE_LOGIC 70 |
| 207 |
#define MENU_BASE_FLOAT1 71 |
| 208 |
#define MENU_BASE_FLOAT2 72 |
| 209 |
#define MENU_BASE_MODES 73 |
| 210 |
#define MENU_BASE_DISP 74 |
| 211 |
#define MENU_SOLVE 75 |
| 212 |
#define MENU_INTEG 76 |
| 213 |
#define MENU_INTEG_PARAMS 77 |
| 214 |
|
| 215 |
|
| 216 |
struct menu_item_spec { |
| 217 |
int2 menuid; |
| 218 |
unsigned char title_length; |
| 219 |
const char *title; |
| 220 |
}; |
| 221 |
|
| 222 |
struct menu_spec { |
| 223 |
int2 parent; |
| 224 |
int2 next; |
| 225 |
int2 prev; |
| 226 |
menu_item_spec child[6]; |
| 227 |
}; |
| 228 |
|
| 229 |
extern const menu_spec menus[]; |
| 230 |
|
| 231 |
|
| 232 |
/******************/ |
| 233 |
/* Emulator state */ |
| 234 |
/******************/ |
| 235 |
|
| 236 |
/* Suppress menu updates while state loading is in progress */ |
| 237 |
extern bool loading_state; |
| 238 |
|
| 239 |
/* Registers */ |
| 240 |
#define REG_T 0 |
| 241 |
#define REG_Z 1 |
| 242 |
#define REG_Y 2 |
| 243 |
#define REG_X 3 |
| 244 |
extern vartype **stack; |
| 245 |
extern int sp; |
| 246 |
extern int stack_capacity; |
| 247 |
extern vartype *lastx; |
| 248 |
extern int reg_alpha_length; |
| 249 |
extern char reg_alpha[44]; |
| 250 |
|
| 251 |
/* FLAGS |
| 252 |
* Note: flags whose names start with VIRTUAL_ are named here for reference |
| 253 |
* only; they are actually handled by virtual_flag_handler(). Setting or |
| 254 |
* clearing them in 'flags' has no effect. |
| 255 |
* Flags whose names are the letter 'f' followed by two digits have no |
| 256 |
* specified meaning according to the HP-42S manual; they are either user flags |
| 257 |
* or reserved. |
| 258 |
*/ |
| 259 |
typedef union { |
| 260 |
char farray[100]; |
| 261 |
struct { |
| 262 |
char f00; char f01; char f02; char f03; char f04; |
| 263 |
char f05; char f06; char f07; char f08; char f09; |
| 264 |
char f10; |
| 265 |
char auto_exec; |
| 266 |
char double_wide_print; |
| 267 |
char lowercase_print; |
| 268 |
char f14; |
| 269 |
char trace_print; /* 'normal_print' ignored if this is set */ |
| 270 |
char normal_print; |
| 271 |
char f17; char f18; char f19; char f20; |
| 272 |
char printer_enable; |
| 273 |
char numeric_data_input; |
| 274 |
char alpha_data_input; |
| 275 |
char range_error_ignore; |
| 276 |
char error_ignore; |
| 277 |
char audio_enable; |
| 278 |
char VIRTUAL_custom_menu; |
| 279 |
char decimal_point; |
| 280 |
char thousands_separators; |
| 281 |
char stack_lift_disable; |
| 282 |
char dmy; /* Time Module DMY mode */ |
| 283 |
char f32; char f33; |
| 284 |
char agraph_control1; /* 0 (default): dst = dst | src, 1: dst = src, */ |
| 285 |
char agraph_control0; /* 2: dst = dst & ~src, 3: dst = dst ^ src */ |
| 286 |
char digits_bit3; |
| 287 |
char digits_bit2; |
| 288 |
char digits_bit1; |
| 289 |
char digits_bit0; |
| 290 |
char fix_or_all; |
| 291 |
char eng_or_all; |
| 292 |
char grad; |
| 293 |
char rad; |
| 294 |
char VIRTUAL_continuous_on; |
| 295 |
char VIRTUAL_solving; |
| 296 |
char VIRTUAL_integrating; |
| 297 |
char VIRTUAL_variable_menu; |
| 298 |
char VIRTUAL_alpha_mode; |
| 299 |
char VIRTUAL_low_battery; |
| 300 |
char message; |
| 301 |
char two_line_message; |
| 302 |
char prgm_mode; |
| 303 |
char VIRTUAL_input; |
| 304 |
char f54; |
| 305 |
char printer_exists; |
| 306 |
char lin_fit; |
| 307 |
char log_fit; |
| 308 |
char exp_fit; |
| 309 |
char pwr_fit; |
| 310 |
char all_sigma; |
| 311 |
char log_fit_invalid; |
| 312 |
char exp_fit_invalid; |
| 313 |
char pwr_fit_invalid; |
| 314 |
char shift_state; /* For use by MENU handlers */ |
| 315 |
char VIRTUAL_matrix_editor; |
| 316 |
char grow; |
| 317 |
char ymd; /* Programming extension YMD mode; overrides dmy flag */ |
| 318 |
char base_bit0; /* Note: dec=0, bin=1, oct=7, hex=15 */ |
| 319 |
char base_bit1; |
| 320 |
char base_bit2; |
| 321 |
char base_bit3; |
| 322 |
char local_label; |
| 323 |
char polar; |
| 324 |
char real_result_only; |
| 325 |
char VIRTUAL_programmable_menu; |
| 326 |
char matrix_edge_wrap; |
| 327 |
char matrix_end_wrap; |
| 328 |
char base_signed; /* Programming extension */ |
| 329 |
char base_wrap; /* Programming extension */ |
| 330 |
char big_stack; /* Big Stack extension */ |
| 331 |
char f81; char f82; char f83; char f84; |
| 332 |
char f85; char f86; char f87; char f88; char f89; |
| 333 |
char f90; char f91; char f92; char f93; char f94; |
| 334 |
char f95; char f96; char f97; char f98; char f99; |
| 335 |
} f; |
| 336 |
} flags_struct; |
| 337 |
extern flags_struct flags; |
| 338 |
extern const char *virtual_flags; |
| 339 |
|
| 340 |
/* For var_struct.flags */ |
| 341 |
#define VAR_HIDDEN 1 |
| 342 |
#define VAR_HIDING 2 |
| 343 |
#define VAR_PRIVATE 4 |
| 344 |
|
| 345 |
/* Variables */ |
| 346 |
struct var_struct { |
| 347 |
unsigned char length; |
| 348 |
char name[7]; |
| 349 |
int2 level; |
| 350 |
int2 flags; |
| 351 |
vartype *value; |
| 352 |
}; |
| 353 |
extern int vars_capacity; |
| 354 |
extern int vars_count; |
| 355 |
extern var_struct *vars; |
| 356 |
|
| 357 |
/* Programs */ |
| 358 |
struct prgm_struct { |
| 359 |
int4 capacity; |
| 360 |
int4 size; |
| 361 |
bool lclbl_invalid; |
| 362 |
bool locked; |
| 363 |
unsigned char *text; |
| 364 |
inline bool is_end(int4 pc) { |
| 365 |
return text[pc] == CMD_END && (text[pc + 1] & 112) == 0; |
| 366 |
} |
| 367 |
}; |
| 368 |
extern int prgms_capacity; |
| 369 |
extern int prgms_count; |
| 370 |
extern prgm_struct *prgms; |
| 371 |
struct label_struct { |
| 372 |
unsigned char length; |
| 373 |
char name[7]; |
| 374 |
int prgm; |
| 375 |
int4 pc; |
| 376 |
}; |
| 377 |
extern int labels_capacity; |
| 378 |
extern int labels_count; |
| 379 |
extern label_struct *labels; |
| 380 |
|
| 381 |
extern int current_prgm; |
| 382 |
extern int4 pc; |
| 383 |
extern int prgm_highlight_row; |
| 384 |
|
| 385 |
extern int varmenu_length; |
| 386 |
extern char varmenu[7]; |
| 387 |
extern int varmenu_rows; |
| 388 |
extern int varmenu_row; |
| 389 |
extern int varmenu_labellength[6]; |
| 390 |
extern char varmenu_labeltext[6][7]; |
| 391 |
extern int varmenu_role; |
| 392 |
|
| 393 |
|
| 394 |
/****************/ |
| 395 |
/* More globals */ |
| 396 |
/****************/ |
| 397 |
|
| 398 |
extern bool mode_clall; |
| 399 |
extern int (*mode_interruptible)(bool); |
| 400 |
extern bool mode_stoppable; |
| 401 |
extern bool mode_command_entry; |
| 402 |
extern char mode_number_entry; |
| 403 |
extern bool mode_alpha_entry; |
| 404 |
extern bool mode_shift; |
| 405 |
extern int mode_appmenu; |
| 406 |
extern int mode_plainmenu; |
| 407 |
extern bool mode_plainmenu_sticky; |
| 408 |
extern int mode_transientmenu; |
| 409 |
extern int mode_alphamenu; |
| 410 |
extern int mode_commandmenu; |
| 411 |
extern bool mode_running; |
| 412 |
extern bool mode_getkey; |
| 413 |
extern bool mode_getkey1; |
| 414 |
extern bool mode_pause; |
| 415 |
extern bool mode_disable_stack_lift; |
| 416 |
extern bool mode_varmenu; |
| 417 |
extern bool mode_updown; |
| 418 |
extern int4 mode_sigma_reg; |
| 419 |
extern int mode_goose; |
| 420 |
extern bool mode_time_clktd; |
| 421 |
extern bool mode_time_clk24; |
| 422 |
extern int mode_wsize; |
| 423 |
extern bool mode_carry; |
| 424 |
extern bool mode_dec_int; |
| 425 |
extern bool mode_bin_sep; |
| 426 |
extern bool mode_oct_sep; |
| 427 |
extern bool mode_dec_sep; |
| 428 |
extern bool mode_hex_sep; |
| 429 |
extern bool mode_menu_caps; |
| 430 |
extern bool mode_menu_static; |
| 431 |
#if defined(ANDROID) || defined(IPHONE) |
| 432 |
extern bool mode_popup_unknown; |
| 433 |
#endif |
| 434 |
|
| 435 |
extern phloat entered_number; |
| 436 |
extern int entered_string_length; |
| 437 |
extern char entered_string[15]; |
| 438 |
|
| 439 |
extern int pending_command; |
| 440 |
extern arg_struct pending_command_arg; |
| 441 |
extern int xeq_invisible; |
| 442 |
|
| 443 |
/* Multi-keystroke commands -- edit state */ |
| 444 |
/* Relevant when mode_command_entry != 0 */ |
| 445 |
extern int incomplete_command; |
| 446 |
extern bool incomplete_ind; |
| 447 |
extern bool incomplete_alpha; |
| 448 |
extern int incomplete_length; |
| 449 |
extern int incomplete_maxdigits; |
| 450 |
extern int incomplete_argtype; |
| 451 |
extern int incomplete_num; |
| 452 |
extern char incomplete_str[22]; |
| 453 |
extern int4 incomplete_saved_pc; |
| 454 |
extern int4 incomplete_saved_highlight_row; |
| 455 |
|
| 456 |
#define CATSECT_TOP 0 |
| 457 |
#define CATSECT_FCN 1 |
| 458 |
#define CATSECT_PGM 2 |
| 459 |
#define CATSECT_REAL 3 |
| 460 |
#define CATSECT_CPX 4 |
| 461 |
#define CATSECT_MAT 5 |
| 462 |
#define CATSECT_PGM_ONLY 6 |
| 463 |
#define CATSECT_REAL_ONLY 7 |
| 464 |
#define CATSECT_MAT_ONLY 8 |
| 465 |
#define CATSECT_VARS_ONLY 9 |
| 466 |
#define CATSECT_PGM_SOLVE 10 |
| 467 |
#define CATSECT_PGM_INTEG 11 |
| 468 |
#define CATSECT_PGM_MENU 12 |
| 469 |
#define CATSECT_EXT_1 13 |
| 470 |
#define CATSECT_EXT_TIME 14 |
| 471 |
#define CATSECT_EXT_XFCN 15 |
| 472 |
#define CATSECT_EXT_BASE 16 |
| 473 |
#define CATSECT_EXT_PRGM 17 |
| 474 |
#define CATSECT_EXT_STR 18 |
| 475 |
#define CATSECT_EXT_STK 19 |
| 476 |
#define CATSECT_EXT_2 20 |
| 477 |
#define CATSECT_EXT_STAT 21 |
| 478 |
#define CATSECT_EXT_MISC 22 |
| 479 |
#define CATSECT_EXT_0_CMP 23 |
| 480 |
#define CATSECT_EXT_X_CMP 24 |
| 481 |
#define CATSECT_LIST_STR_ONLY 25 |
| 482 |
#define CATSECT_MAT_LIST 26 |
| 483 |
#define CATSECT_MAT_LIST_ONLY 27 |
| 484 |
#define CATSECT_LIST 28 |
| 485 |
#define CATSECT_LIST_ONLY 29 |
| 486 |
|
| 487 |
/* Command line handling temporaries */ |
| 488 |
extern char cmdline[100]; |
| 489 |
extern int cmdline_length; |
| 490 |
extern int cmdline_row; |
| 491 |
|
| 492 |
/* Matrix editor / matrix indexing */ |
| 493 |
extern int matedit_mode; /* 0=off, 1=index, 2=edit, 3=editn */ |
| 494 |
extern int matedit_level; |
| 495 |
extern char matedit_name[7]; |
| 496 |
extern int matedit_length; |
| 497 |
extern vartype *matedit_x; |
| 498 |
extern int4 matedit_i; |
| 499 |
extern int4 matedit_j; |
| 500 |
extern int matedit_prev_appmenu; |
| 501 |
extern int4 *matedit_stack; |
| 502 |
extern int matedit_stack_depth; |
| 503 |
extern bool matedit_is_list; |
| 504 |
|
| 505 |
/* INPUT */ |
| 506 |
extern char input_name[11]; |
| 507 |
extern int input_length; |
| 508 |
extern arg_struct input_arg; |
| 509 |
|
| 510 |
/* ERRMSG/ERRNO */ |
| 511 |
extern int lasterr; |
| 512 |
extern int lasterr_length; |
| 513 |
extern char lasterr_text[22]; |
| 514 |
|
| 515 |
/* BASE application */ |
| 516 |
extern int baseapp; |
| 517 |
|
| 518 |
/* Random number generator */ |
| 519 |
extern int8 random_number_low, random_number_high; |
| 520 |
|
| 521 |
/* NORM & TRACE mode: number waiting to be printed */ |
| 522 |
extern int deferred_print; |
| 523 |
|
| 524 |
/* Keystroke buffer - holds keystrokes received while |
| 525 |
* there is a program running. |
| 526 |
*/ |
| 527 |
extern int keybuf_head; |
| 528 |
extern int keybuf_tail; |
| 529 |
extern int keybuf[16]; |
| 530 |
|
| 531 |
extern int remove_program_catalog; |
| 532 |
|
| 533 |
#define NUMBER_FORMAT_BINARY 0 |
| 534 |
#define NUMBER_FORMAT_BCD20_OLD 1 // obsolete |
| 535 |
#define NUMBER_FORMAT_BCD20_NEW 2 // obsolete |
| 536 |
#define NUMBER_FORMAT_BID128 3 |
| 537 |
extern int state_file_number_format; |
| 538 |
|
| 539 |
extern bool no_keystrokes_yet; |
| 540 |
|
| 541 |
|
| 542 |
/*********************/ |
| 543 |
/* Utility functions */ |
| 544 |
/*********************/ |
| 545 |
|
| 546 |
void clear_all_prgms(); |
| 547 |
int clear_prgm(const arg_struct *arg); |
| 548 |
int clear_prgm_by_index(int prgm_index); |
| 549 |
void clear_prgm_lines(int4 count); |
| 550 |
bool goto_dot_dot(bool force_new); |
| 551 |
bool mvar_prgms_exist(); |
| 552 |
bool label_has_mvar(int lblindex); |
| 553 |
int get_command_length(int prgm, int4 pc); |
| 554 |
void get_next_command(int4 *pc, int *command, arg_struct *arg, int find_target, const char **num_str); |
| 555 |
void rebuild_label_table(); |
| 556 |
void delete_command(int4 pc); |
| 557 |
bool store_command(int4 pc, int command, arg_struct *arg, const char *num_str); |
| 558 |
bool store_command_after(int4 *pc, int command, arg_struct *arg, const char *num_str); |
| 559 |
int x2line(); |
| 560 |
int a2line(bool append); |
| 561 |
int prgm_lock(bool lock); |
| 562 |
int4 pc2line(int4 pc); |
| 563 |
int4 line2pc(int4 line); |
| 564 |
int4 global_pc2line(int prgm, int4 pc); |
| 565 |
int4 global_line2pc(int prgm, int4 line); |
| 566 |
int4 find_local_label(const arg_struct *arg); |
| 567 |
bool find_global_label(const arg_struct *arg, int *prgm, int4 *pc); |
| 568 |
bool find_global_label_index(const arg_struct *arg, int *idx); |
| 569 |
int push_rtn_addr(int prgm, int4 pc); |
| 570 |
int push_indexed_matrix(); |
| 571 |
void maybe_pop_indexed_matrix(const char *name, int len); |
| 572 |
int push_func_state(int n); |
| 573 |
int push_stack_state(bool big); |
| 574 |
int pop_func_state(bool error); |
| 575 |
void step_out(); |
| 576 |
void step_over(); |
| 577 |
bool should_i_stop_at_this_level(); |
| 578 |
int rtn(int err); |
| 579 |
int rtn_with_error(int err); |
| 580 |
void pop_rtn_addr(int *prgm, int4 *pc, bool *stop); |
| 581 |
void clear_all_rtns(); |
| 582 |
int get_rtn_level(); |
| 583 |
void save_csld(); |
| 584 |
bool is_csld(); |
| 585 |
bool solve_active(); |
| 586 |
bool integ_active(); |
| 587 |
bool unwind_stack_until_solve(); |
| 588 |
|
| 589 |
bool read_bool(bool *b); |
| 590 |
bool write_bool(bool b); |
| 591 |
bool read_char(char *c); |
| 592 |
bool write_char(char c); |
| 593 |
bool read_int(int *n); |
| 594 |
bool write_int(int n); |
| 595 |
bool read_int2(int2 *n); |
| 596 |
bool write_int2(int2 n); |
| 597 |
bool read_int4(int4 *n); |
| 598 |
bool write_int4(int4 n); |
| 599 |
bool read_int8(int8 *n); |
| 600 |
bool write_int8(int8 n); |
| 601 |
bool read_phloat(phloat *d); |
| 602 |
bool write_phloat(phloat d); |
| 603 |
bool read_arg(arg_struct *arg); |
| 604 |
bool write_arg(const arg_struct *arg); |
| 605 |
|
| 606 |
bool load_state(int4 version, bool *clear, bool *too_new); |
| 607 |
void save_state(bool *success); |
| 608 |
// Reason: |
| 609 |
// 0 = Memory Clear |
| 610 |
// 1 = State File Corrupt |
| 611 |
// 2 = State File Too New |
| 612 |
void hard_reset(int reason); |
| 613 |
|
| 614 |
#ifdef IPHONE |
| 615 |
bool off_enabled(); |
| 616 |
#endif |
| 617 |
|
| 618 |
#endif |