Commit d243a050 authored by Over_score's avatar Over_score

Resolve "For the time being, IDIVR can't be tested since it is inaccessible."

parent a85ff1ec
......@@ -68,7 +68,7 @@ SRC_WP43S = \
fonts.c fractions.c gui.c integers.c items.c keyboard.c \
rasterFontsData.c registerValueConversions.c registers.c \
saveRestoreCalcState.c screen.c softmenus.c sort.c stack.c \
stats.c statusBar.c testFunctions.c timer.c \
stats.c statusBar.c timer.c \
wp43s.c memory.c) \
$(addprefix src/wp43s/mathematics/, \
10pow.c 2pow.c addition.c arccos.c arccosh.c arcsin.c arcsinh.c arctan.c arctanh.c \
......
......@@ -24,8 +24,10 @@
#include <stdio.h>
#include <string.h>
// needed for chdir:
#include<unistd.h>
#ifdef __APPLE__
// needed for chdir:
#include<unistd.h>
#endif // __APPLE__
#define DIGITS_FOR_34_DIGITS_INTERMEDIATE_CALCULATIONS 39
......@@ -200,7 +202,7 @@ void generateAllConstants(void) {
generateConstantArray("1on2", "+5.000000000000000000000000000000000000000000000000000000e-01"); c++; // math constant 1/2
generateConstantArray("a", "+3.652425000000000000000000000000000000000000000000000000e+02"); c++; // per definition
generateConstantArray("a0", "+5.291772109030000000000000000000000000000000000000000000e-11"); c++;
generateConstantArray("aM", "+3.844000000000000000000000000000000000000000000000000000e+08"); c++;
generateConstantArray("aMoon", "+3.844000000000000000000000000000000000000000000000000000e+08"); c++;
generateConstantArray("aEarth", "+1.495979000000000000000000000000000000000000000000000000e+11"); c++;
generateConstantArray("c", "+2.997924580000000000000000000000000000000000000000000000e+08"); c++; // per definition
......@@ -209,7 +211,7 @@ void generateAllConstants(void) {
generateConstantArray("e", "+1.602176634000000000000000000000000000000000000000000000e-19"); c++;
generateConstantArray("eE", "+2.718281828459045235360287471352662497757247093699959575e+00"); c++; // math constant e
generateConstantArray("eme", "+1.758820024000000000000000000000000000000000000000000000e+11"); c++;
generateConstantArray("F", "+9.6485332123310018400000000000000000000000000000000000000+04"); c++;
generateConstantArray("F", "+9.648533212331001840000000000000000000000000000000000000e+04"); c++;
generateConstantArray("Falpha", "+2.502907875095892822283902873218215786381271376727149977e+00"); c++; // math constant Falpha
generateConstantArray("Fdelta", "+4.669201609102990671853203820466201617258185577475768633e+00"); c++; // math constant Fdelta
......
This diff is collapsed.
......@@ -23,7 +23,7 @@
//This variable is to store in flash memory
const calcKey_t kbd_std[37] = {
//keyId primary fShifted gShifted keyLblAim primaryAim fShiftedAim gShiftedAim primaryTam
{21, ITM_1X, ITM_PROFRC, ITM_IMPFRC, ITM_NULL, CHR_A, ITM_NULL, CHR_ALPHA, ITM_ST_A },
{21, ITM_1ONX, ITM_PROFRC, ITM_IMPFRC, ITM_NULL, CHR_A, ITM_NULL, CHR_ALPHA, ITM_ST_A },
{22, ITM_YX, ITM_toINT, -MNU_EXP, ITM_NULL, CHR_B, ITM_NULL, CHR_BETA, ITM_ST_B },
{23, -MNU_TRI, ITM_DMS, ITM_pi, ITM_NULL, CHR_C, ITM_NULL, CHR_GAMMA, ITM_ST_C },
{24, ITM_LN, KEY_dotD, ITM_LOG10, ITM_NULL, CHR_D, ITM_NULL, CHR_DELTA, ITM_ST_D }, // if f or g are changed: adapt the function btnClicked section if(calcMode == CM_NIM) in keyboard.c. Case D for decimal base
......@@ -33,7 +33,7 @@ const calcKey_t kbd_std[37] = {
{31, ITM_STO, ITM_ASSIGN, ITM_SAVE, ITM_NULL, CHR_G, ITM_ASSIGN, CHR_GAMMA, ITM_NULL },
{32, ITM_RCL, ITM_VIEW, -MNU_CNST, ITM_NULL, CHR_H, ITM_NULL, CHR_CHI, ITM_HEX },
{33, ITM_Rdown, ITM_Rup, -MNU_CPX, ITM_NULL, CHR_I, CHR_DOWN_ARROW, CHR_IOTA, ITM_REGI }, // if f or g are changed: adapt the function btnClicked section if(calcMode == CM_NIM) in keyboard.c. Case H for hexadecimal base
{34, KEY_CC, ITM_MAGNITUDE, ITM_ANGLE, ITM_NULL, CHR_J, ITM_NULL, CHR_ETA, ITM_REGJ },
{34, KEY_CC, ITM_MAGNITUDE, ITM_VANGLE, ITM_NULL, CHR_J, ITM_NULL, CHR_ETA, ITM_REGJ },
{35, KEY_f, ITM_NULL, ITM_NULL, KEY_f, KEY_f, ITM_NULL, ITM_NULL, KEY_f },
{36, KEY_g, ITM_NULL, ITM_NULL, KEY_g, KEY_g, ITM_NULL, ITM_NULL, KEY_g },
......
......@@ -28,7 +28,7 @@ const uint8_t constants[] = {
0x27,0x00,0x00,0x00,0xd9,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf4,0x01, // const_1on2
0x27,0x00,0x00,0x00,0xdc,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf4,0x01,0xf2,0x00,0x6d,0x01, // const_a
0x27,0x00,0x00,0x00,0xcf,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x87,0x03,0xd2,0x00,0xb1,0x00,0x11,0x02, // const_a0
0x27,0x00,0x00,0x00,0xe2,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x80,0x01, // const_aM
0x27,0x00,0x00,0x00,0xe2,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x80,0x01, // const_aMoon
0x27,0x00,0x00,0x00,0xe5,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x03,0x55,0x02,0x95,0x00, // const_aEarth
0x27,0x00,0x00,0x00,0xe2,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xca,0x01,0x18,0x03,0x2b,0x01, // const_c
0x27,0x00,0x00,0x00,0xca,0xff,0xff,0xff,0x00,0x00,0x36,0x03,0x01,0x02,0xe6,0x03,0x50,0x02,0x2b,0x02,0xcb,0x02,0x88,0x00,0x21,0x03,0x13,0x01,0xdb,0x00,0xb9,0x00,0xb1,0x00,0x76,0x01, // const_c1
......@@ -36,7 +36,7 @@ const uint8_t constants[] = {
0x27,0x00,0x00,0x00,0xc7,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x97,0x02,0xd9,0x00,0xa0,0x00, // const_e
0x27,0x00,0x00,0x00,0xda,0xff,0xff,0xff,0x00,0x00,0x08,0x03,0xf9,0x00,0x0a,0x01,0x87,0x00,0xeb,0x02,0x1c,0x00,0x18,0x02,0x0b,0x02,0x88,0x03,0x4d,0x03,0xb6,0x00,0x3c,0x03,0x0f,0x01, // const_eE
0x27,0x00,0x00,0x00,0xe5,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x02,0x00,0x72,0x03,0xaf,0x00, // const_eme
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // const_F
0x27,0x00,0x00,0x00,0xde,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0x00,0x64,0x00,0xe9,0x00,0x41,0x01,0x55,0x03,0xc4,0x03, // const_F
0x27,0x00,0x00,0x00,0xda,0xff,0xff,0xff,0x00,0x00,0x7e,0x02,0x42,0x02,0x35,0x03,0x41,0x01,0x1f,0x01,0x86,0x01,0xe4,0x00,0x1a,0x01,0x4d,0x02,0xfd,0x01,0x13,0x03,0x22,0x01,0xfa,0x00, // const_Falpha
0x27,0x00,0x00,0x00,0xda,0xff,0xff,0xff,0x00,0x00,0xd6,0x02,0xa1,0x00,0x6c,0x02,0x2e,0x00,0x7e,0x01,0x40,0x01,0xb9,0x00,0x43,0x00,0x2b,0x01,0x8e,0x03,0xa0,0x00,0x98,0x03,0xd2,0x01, // const_Fdelta
0x27,0x00,0x00,0x00,0xcf,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xae,0x01,0x9b,0x02, // const_G
......@@ -237,7 +237,7 @@ const uint8_t constants[] = {
const realIc_t * const const_1on2 = (realIc_t *)(constants + 0);
const realIc_t * const const_a = (realIc_t *)(constants + 36);
const realIc_t * const const_a0 = (realIc_t *)(constants + 72);
const realIc_t * const const_aM = (realIc_t *)(constants + 108);
const realIc_t * const const_aMoon = (realIc_t *)(constants + 108);
const realIc_t * const const_aEarth = (realIc_t *)(constants + 144);
const realIc_t * const const_c = (realIc_t *)(constants + 180);
const realIc_t * const const_c1 = (realIc_t *)(constants + 216);
......
......@@ -107,7 +107,7 @@ extern const uint8_t constants[];
extern const realIc_t * const const_1on2;
extern const realIc_t * const const_a;
extern const realIc_t * const const_a0;
extern const realIc_t * const const_aM;
extern const realIc_t * const const_aMoon;
extern const realIc_t * const const_aEarth;
extern const realIc_t * const const_c;
extern const realIc_t * const const_c1;
......
......@@ -133,12 +133,6 @@ typedef struct {realIc_t real, imag;} complexIc_t;
#define complex16Copy(source, destination) {*(uint64_t *)(destination) = *(uint64_t *)(source); \
*(((uint64_t *)(destination))+1) = *(((uint64_t *)(source))+1); \
}
#define complex16SetPositiveSign(operand) {real16SetPositiveSign((real16_t *)(operand)); \
real16SetPositiveSign((real16_t *)((char *)(operand) + REAL16_SIZE)); \
}
#define complex16SetNegativeSign(operand) {real16SetNegativeSign((real16_t *)(operand)); \
real16SetNegativeSign((real16_t *)((char *)(operand) + REAL16_SIZE)); \
}
......@@ -190,12 +184,6 @@ typedef struct {realIc_t real, imag;} complexIc_t;
*(((uint64_t *)(destination))+2) = *(((uint64_t *)(source))+2); \
*(((uint64_t *)(destination))+3) = *(((uint64_t *)(source))+3); \
}
#define complex34SetPositiveSign(operand) {real34SetPositiveSign((real34_t *)(operand)); \
real34SetPositiveSign((real34_t *)((char *)(operand) + REAL34_SIZE)); \
}
#define complex34SetNegativeSign(operand) {real34SetNegativeSign((real34_t *)(operand)); \
real34SetNegativeSign((real34_t *)((char *)(operand) + REAL34_SIZE)); \
}
......
......@@ -140,7 +140,7 @@ void fnDisplayFormatAll(uint16_t displayFormatN) {
* \param[in] displayFormatN uint16_t Display format
* \return void
***********************************************/
void fnDisplayFormatDsp(uint16_t displayFormatN) {
/*void fnDisplayFormatDsp(uint16_t displayFormatN) {
displayFormatDigits = displayFormatN;
displayRealAsFraction = false;
......@@ -154,7 +154,7 @@ void fnDisplayFormatDsp(uint16_t displayFormatN) {
#endif
refreshStack();
}
}*/
......
......@@ -21,7 +21,7 @@ void fnDisplayFormatFix (uint16_t displayFormat);
void fnDisplayFormatSci (uint16_t displayFormat);
void fnDisplayFormatEng (uint16_t displayFormat);
void fnDisplayFormatAll (uint16_t displayFormat);
void fnDisplayFormatDsp (uint16_t displayFormat);
//void fnDisplayFormatDsp (uint16_t displayFormat);
void fnDisplayFormatGap (uint16_t gap);
void real16ToDisplayString (const real16_t *real16, uint32_t tag, char *displayString, const font_t *font, int16_t maxWidth);
void real34ToDisplayString (const real34_t *real34, uint32_t tag, char *displayString, const font_t *font, int16_t maxWidth);
......
......@@ -234,7 +234,6 @@ void generateNotFoundGlyph(const int16_t font, uint16_t charCode);
#define STD_RIGHT_CURLY_BRACKET "\x7d"
#define NUM_TILDE "\x7e"
#define STD_TILDE "\x7e"
#define STD_INVERTED_EXCLAMATION_MARK "\x80\xa1"
#define STD_INVERTED_EXCLAMATION_MARK "\x80\xa1"
#define STD_CENT "\x80\xa2"
#define STD_POUND "\x80\xa3"
......
This diff is collapsed.
......@@ -32,7 +32,7 @@
#define ITM_10x 3
#define ITM_1COMPL 4
#define CST_00 5
#define ITM_1X 6
#define ITM_1ONX 6
#define ITM_2COMPL 7
#define ITM_2X 8
#define ITM_CUBEROOT 9
......@@ -157,7 +157,7 @@
#define ITM_DROPY 128
#define ITM_DSE 129
#define ITM_DSL 130
#define ITM_DSP 131
#define ITM_0131 131
#define ITM_DSTACK 132
#define ITM_DSZ 133
#define ITM_DMS 134
......@@ -1611,8 +1611,17 @@
#define ITM_SIGMAx4 1575
#define ITM_HEX 1576
#define ITM_IDIVR 1577
#define ITM_ACOS 1578
#define ITM_ASIN 1579
#define ITM_ATAN 1580
#define ITM_DET 1581
#define ITM_INVRT 1582
#define ITM_TRANS 1583
#define ITM_XIN 1584
#define ITM_XOUT 1585
#define ITM_ALPHASR 1586
#define LAST_ITEM 1578
#define LAST_ITEM 1587
#define CHR_PROD_SIGN 9999
......@@ -1620,11 +1629,19 @@
* \typedef item_t
* \brief Structure keeping the information for one item
***********************************************/
#define CAT_NO 0
#define CAT_FNCT 1 // Function
#define CAT_MENU 2 // Menu
#define CAT_CNST 3 // Constant
#define CAT_FREE 4 // To identify and find the free items
#define CAT_RVAR 5 // Reserved variable
#define CAT_DUPL 6 // Duplicate of another item e.g. acus->m^2
typedef struct {
void (*func)(uint16_t); ///< Function called to execute the item
uint16_t param; ///< 1st parameter to the above function
char *itemName; ///< Name of the item
char *itemPrinted; ///< Representation of the item in the menus or on the keyboard
char catalog; ///< Menu of CATALOG in which the item is located: see #define CAT_*
uint8_t stackLiftStatus; ///< Stack lift status after item execution.
} item_t;
......
......@@ -65,22 +65,22 @@ void resetShiftState(void) {
* \brief Executes one function from a softmenu
*
* \param[in] fn int16_t Function key from 1 to 6
* \param[in] shift int16_t Shift status
* * 0 = not shifted
* * 1 = f shifted
* * 2 = g shifted
* \param[in] itemShift int16_t Shift status
* * 0 = not shifted
* * 6 = f shifted
* * 12 = g shifted
* \return void
***********************************************/
void executeFunction(int16_t fn, int16_t shift) {
int16_t row, func;
void executeFunction(int16_t fn, int16_t itemShift) {
int16_t row, func;
const softmenu_t *sm;
if(softmenuStackPointer > 0) {
sm = &softmenu[softmenuStack[softmenuStackPointer - 1].softmenu];
row = min(3, sm->numRows - softmenuStack[softmenuStackPointer - 1].row) - 1;
row = min(3, sm->numItems/6 - softmenuStack[softmenuStackPointer - 1].firstItem/6) - 1;
if(shift <= row) {
func = (sm->softkeyRow)[6*(softmenuStack[softmenuStackPointer - 1].row + shift) + (fn-1)];
if(itemShift/6 <= row) {
func = (sm->softkeyItem)[softmenuStack[softmenuStackPointer - 1].firstItem + itemShift + (fn - 1)];
if(func == CHR_PROD_SIGN) {
func = (productSign == PS_CROSS ? CHR_DOT : CHR_CROSS);
......@@ -142,11 +142,11 @@ void btnFnClicked(void *w, void *data) {
if(softmenuStackPointer > 0) {
if(shiftF) {
resetShiftState();
executeFunction(fn, 1);
executeFunction(fn, 6);
}
else if(shiftG) {
resetShiftState();
executeFunction(fn, 2);
executeFunction(fn, 12);
}
else {
executeFunction(fn, 0);
......@@ -218,6 +218,7 @@ void btnPressed(GtkWidget *notUsed, gpointer data) {
void btnPressed(void *notUsed, void *data) {
#endif
const calcKey_t *key;
int16_t itemShift;
key = userModeEnabled ? (kbd_usr + (*((char *)data) - '0')*10 + *(((char *)data)+1) - '0') : (kbd_std + (*((char *)data) - '0')*10 + *(((char *)data)+1) - '0');
......@@ -697,14 +698,19 @@ void btnPressed(void *notUsed, void *data) {
else if(item == KEY_UP) {
if(calcMode == CM_NORMAL || calcMode == CM_AIM || calcMode == CM_NIM) {
if(softmenuStackPointer > 0 && softmenuStack[softmenuStackPointer - 1].softmenu != MY_ALPHA_MENU) {
if((softmenuStack[softmenuStackPointer - 1].row + 3) < softmenu[softmenuStack[softmenuStackPointer-1].softmenu].numRows) {
softmenuStack[softmenuStackPointer - 1].row += 3;
itemShift = alphaSelectionMenu == ASM_NONE ? 18 : 6;
if((softmenuStack[softmenuStackPointer - 1].firstItem + itemShift) < softmenu[softmenuStack[softmenuStackPointer-1].softmenu].numItems) {
softmenuStack[softmenuStackPointer - 1].firstItem += itemShift;
showSoftmenuCurrentPart();
}
else {
softmenuStack[softmenuStackPointer - 1].row = 0;
softmenuStack[softmenuStackPointer - 1].firstItem = 0;
showSoftmenuCurrentPart();
}
if(alphaSelectionMenu == ASM_CNST) lastCnstMenuPos = softmenuStack[softmenuStackPointer - 1].firstItem;
else if(alphaSelectionMenu == ASM_FCNS) lastFcnsMenuPos = softmenuStack[softmenuStackPointer - 1].firstItem;
}
else if(calcMode == CM_AIM) {
alphaCase = AC_UPPER;
......@@ -756,14 +762,19 @@ void btnPressed(void *notUsed, void *data) {
else if(item == KEY_DOWN) {
if(calcMode == CM_NORMAL || calcMode == CM_AIM || calcMode == CM_NIM) {
if(softmenuStackPointer > 0 && softmenuStack[softmenuStackPointer - 1].softmenu != MY_ALPHA_MENU) {
if((softmenuStack[softmenuStackPointer - 1].row - 3) >= 0) {
softmenuStack[softmenuStackPointer - 1].row -= 3;
itemShift = alphaSelectionMenu == ASM_NONE ? 18 : 6;
if((softmenuStack[softmenuStackPointer - 1].firstItem - itemShift) >= 0) {
softmenuStack[softmenuStackPointer - 1].firstItem -= itemShift;
showSoftmenuCurrentPart();
}
else {
softmenuStack[softmenuStackPointer - 1].row = (softmenu[softmenuStack[softmenuStackPointer-1].softmenu].numRows - 1) / 3 * 3;
softmenuStack[softmenuStackPointer - 1].firstItem = (softmenu[softmenuStack[softmenuStackPointer-1].softmenu].numItems/6 - 1) / (itemShift/6) * itemShift; // doesn't work if numItems is not a multiple of 6
showSoftmenuCurrentPart();
}
if(alphaSelectionMenu == ASM_CNST) lastCnstMenuPos = softmenuStack[softmenuStackPointer - 1].firstItem;
else if(alphaSelectionMenu == ASM_FCNS) lastFcnsMenuPos = softmenuStack[softmenuStackPointer - 1].firstItem;
}
else if(calcMode == CM_AIM) {
alphaCase = AC_LOWER;
......
......@@ -99,7 +99,7 @@ void chsRe16(void) {
real16ChangeSign(REGISTER_REAL16_DATA(REGISTER_X));
if(real16IsZero(REGISTER_REAL16_DATA(REGISTER_X))) {
if(real16IsZero(REGISTER_REAL16_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real16SetPositiveSign(REGISTER_REAL16_DATA(REGISTER_X));
}
}
......@@ -135,11 +135,11 @@ void chsCo16(void) {
complex16ChangeSign(REGISTER_COMPLEX16_DATA(REGISTER_X));
if(real16IsZero(REGISTER_REAL16_DATA(REGISTER_X))) {
if(real16IsZero(REGISTER_REAL16_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real16SetPositiveSign(REGISTER_REAL16_DATA(REGISTER_X));
}
if(real16IsZero(REGISTER_IMAG16_DATA(REGISTER_X))) {
if(real16IsZero(REGISTER_IMAG16_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real16SetPositiveSign(REGISTER_IMAG16_DATA(REGISTER_X));
}
}
......@@ -183,7 +183,7 @@ void chsRe34(void) {
real34ChangeSign(REGISTER_REAL34_DATA(REGISTER_X));
if(real34IsZero(REGISTER_REAL34_DATA(REGISTER_X))) {
if(real34IsZero(REGISTER_REAL34_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real34SetPositiveSign(REGISTER_REAL34_DATA(REGISTER_X));
}
}
......@@ -219,11 +219,11 @@ void chsCo34(void) {
complex34ChangeSign(REGISTER_COMPLEX34_DATA(REGISTER_X));
if(real34IsZero(REGISTER_REAL34_DATA(REGISTER_X))) {
if(real34IsZero(REGISTER_REAL34_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real34SetPositiveSign(REGISTER_REAL34_DATA(REGISTER_X));
}
if(real34IsZero(REGISTER_IMAG34_DATA(REGISTER_X))) {
if(real34IsZero(REGISTER_IMAG34_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real34SetPositiveSign(REGISTER_IMAG34_DATA(REGISTER_X));
}
}
......@@ -80,7 +80,7 @@ void conjCo16(void) {
}
real16ChangeSign(REGISTER_IMAG16_DATA(REGISTER_X));
if(real16IsZero(REGISTER_IMAG16_DATA(REGISTER_X))) {
if(real16IsZero(REGISTER_IMAG16_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real16SetPositiveSign(REGISTER_IMAG16_DATA(REGISTER_X));
}
}
......@@ -103,7 +103,7 @@ void conjCo34(void) {
}
real34ChangeSign(REGISTER_IMAG34_DATA(REGISTER_X));
if(real34IsZero(REGISTER_IMAG34_DATA(REGISTER_X))) {
if(real34IsZero(REGISTER_IMAG34_DATA(REGISTER_X)) && !getFlag(FLAG_DANGER)) {
real34SetPositiveSign(REGISTER_IMAG34_DATA(REGISTER_X));
}
}
......@@ -72,7 +72,7 @@ void fnIDivR(uint16_t unusedParamButMandatory) {
idivr[getRegisterDataType(REGISTER_X)][getRegisterDataType(REGISTER_Y)]();
adjustResult(REGISTER_X, false, false, REGISTER_X, REGISTER_Y, -1);
refreshRegisterLine(REGISTER_Y);
adjustResult(REGISTER_Y, false, false, REGISTER_X, REGISTER_Y, -1);
}
......
......@@ -120,7 +120,9 @@ void WP34S_Cvt2RadSinCosTan(const realIc_t *an, uint32_t angularMode, realIc_t *
if(tan != NULL) realIcSetNegativeSign(tan);
}
if(realIcIsZero(sin)) {
realIcSetPositiveSign(sin);
if(!getFlag(FLAG_DANGER)) {
realIcSetPositiveSign(sin);
}
if(tan != NULL) {
realIcSetPositiveSign(tan);
}
......@@ -132,7 +134,7 @@ void WP34S_Cvt2RadSinCosTan(const realIc_t *an, uint32_t angularMode, realIc_t *
realIcSetNegativeSign(cos);
if(tan != NULL) realIcChangeSign(tan);
}
if(realIcIsZero(cos)) {
if(realIcIsZero(cos) && !getFlag(FLAG_DANGER)) {
realIcSetPositiveSign(cos);
}
}
......
......@@ -191,7 +191,6 @@ void convertShortIntegerRegisterToReal16Register(calcRegister_t source, calcRegi
if(sign) {
real16SetNegativeSign(REGISTER_REAL16_DATA(destination));
}
//printf("destination = "); printRegisterToConsole(destination); printf("\n");
}
......
......@@ -1011,36 +1011,54 @@ void adjustResult(calcRegister_t res, bool_t dropY, bool_t setCpxRes, calcRegist
resultDataType = getRegisterDataType(res);
if(getFlag(FLAG_DANGER) == false) {
// D is clear: test infinite values
// D is clear: test infinite values and -0 values
switch(resultDataType) {
case dtReal16:
if(real16IsInfinite(REGISTER_REAL16_DATA(res))) {
displayCalcErrorMessage(real16IsPositive(REGISTER_REAL16_DATA(res)) ? ERROR_OVERFLOW_PLUS_INF : ERROR_OVERFLOW_MINUS_INF , ERR_REGISTER_LINE, res);
}
else if(real16IsZero(REGISTER_REAL16_DATA(res))) {
real16SetPositiveSign(REGISTER_REAL16_DATA(res));
}
break;
case dtReal34:
if(real34IsInfinite(REGISTER_REAL34_DATA(res))) {
displayCalcErrorMessage(real34IsPositive(REGISTER_REAL34_DATA(res)) ? ERROR_OVERFLOW_PLUS_INF : ERROR_OVERFLOW_MINUS_INF , ERR_REGISTER_LINE, res);
}
else if(real34IsZero(REGISTER_REAL34_DATA(res))) {
real34SetPositiveSign(REGISTER_REAL34_DATA(res));
}
break;
case dtComplex16:
if(real16IsInfinite(REGISTER_REAL16_DATA(res))) {
displayCalcErrorMessage(real16IsPositive(REGISTER_REAL16_DATA(res)) ? ERROR_OVERFLOW_PLUS_INF : ERROR_OVERFLOW_MINUS_INF , ERR_REGISTER_LINE, res);
}
else if(real16IsZero(REGISTER_REAL16_DATA(res))) {
real16SetPositiveSign(REGISTER_REAL16_DATA(res));
}
else if(real16IsInfinite(REGISTER_IMAG16_DATA(res))) {
displayCalcErrorMessage(real16IsPositive(REGISTER_IMAG16_DATA(res)) ? ERROR_OVERFLOW_PLUS_INF : ERROR_OVERFLOW_MINUS_INF , ERR_REGISTER_LINE, res);
}
else if(real16IsZero(REGISTER_IMAG16_DATA(res))) {
real16SetPositiveSign(REGISTER_IMAG16_DATA(res));
}
break;
case dtComplex34:
if(real34IsInfinite(REGISTER_REAL34_DATA(res))) {
displayCalcErrorMessage(real34IsPositive(REGISTER_REAL34_DATA(res)) ? ERROR_OVERFLOW_PLUS_INF : ERROR_OVERFLOW_MINUS_INF , ERR_REGISTER_LINE, res);
}
else if(real34IsZero(REGISTER_REAL34_DATA(res))) {
real34SetPositiveSign(REGISTER_REAL34_DATA(res));
}
else if(real34IsInfinite(REGISTER_IMAG34_DATA(res))) {
displayCalcErrorMessage(real34IsPositive(REGISTER_IMAG34_DATA(res)) ? ERROR_OVERFLOW_PLUS_INF : ERROR_OVERFLOW_MINUS_INF , ERR_REGISTER_LINE, res);
}
else if(real34IsZero(REGISTER_IMAG34_DATA(res))) {
real34SetPositiveSign(REGISTER_IMAG34_DATA(res));
}
break;
default:
......@@ -1063,10 +1081,6 @@ void adjustResult(calcRegister_t res, bool_t dropY, bool_t setCpxRes, calcRegist
realIc_t tmp;
case dtReal16:
if(real16IsZero(REGISTER_REAL16_DATA(res))) {
real16SetPositiveSign(REGISTER_REAL16_DATA(res));
}
if(significantDigits == 0 || significantDigits >= 16) {
break;
}
......@@ -1078,10 +1092,6 @@ void adjustResult(calcRegister_t res, bool_t dropY, bool_t setCpxRes, calcRegist
break;
case dtReal34:
if(real34IsZero(REGISTER_REAL34_DATA(res))) {
real34SetPositiveSign(REGISTER_REAL34_DATA(res));
}
if(significantDigits == 0 || significantDigits >= 34) {
break;
}
......@@ -1093,14 +1103,6 @@ void adjustResult(calcRegister_t res, bool_t dropY, bool_t setCpxRes, calcRegist
break;
case dtComplex16:
if(real16IsZero(REGISTER_REAL16_DATA(res))) {
real16SetPositiveSign(REGISTER_REAL16_DATA(res));
}
if(real16IsZero(REGISTER_IMAG16_DATA(res))) {
real16SetPositiveSign(REGISTER_IMAG16_DATA(res));
}
if(significantDigits == 0 || significantDigits >= 16) {
break;
}
......@@ -1114,14 +1116,6 @@ void adjustResult(calcRegister_t res, bool_t dropY, bool_t setCpxRes, calcRegist
break;
case dtComplex34:
if(real34IsZero(REGISTER_REAL34_DATA(res))) {
real34SetPositiveSign(REGISTER_REAL34_DATA(res));
}
if(real34IsZero(REGISTER_IMAG34_DATA(res))) {
real34SetPositiveSign(REGISTER_IMAG34_DATA(res));
}
if(significantDigits == 0 || significantDigits >= 34) {
break;
}
......
......@@ -21,7 +21,7 @@
#include "wp43s.h"
#ifdef PC_BUILD
#define BACKUP_VERSION 21 // 21 = Fixed statisticalSumsPointer problem
#define BACKUP_VERSION 23 // 23 = alpha selection mode
void saveCalc(void) {
size_t size;
......@@ -161,6 +161,10 @@ void saveCalc(void) {
size += fwrite(&lastIntegerBase, 1, sizeof(lastIntegerBase), backup); //printf("%8lu lastIntegerBase\n", (unsigned long)size);
size += fwrite(&wp43sMemInBytes, 1, sizeof(wp43sMemInBytes), backup); //printf("%8lu wp43sMemInBytes\n", (unsigned long)size);
size += fwrite(&gmpMemInBytes, 1, sizeof(gmpMemInBytes), backup); //printf("%8lu gmpMemInBytes\n", (unsigned long)size);
size += fwrite(&alphaSelectionMenu, 1, sizeof(alphaSelectionMenu), backup); //printf("%8lu alphaSelectionMenu\n", (unsigned long)size);
size += fwrite(&lastFcnsMenuPos, 1, sizeof(lastFcnsMenuPos), backup); //printf("%8lu lastFcnsMenuPos\n", (unsigned long)size);
size += fwrite(&lastMenuMenuPos, 1, sizeof(lastMenuMenuPos), backup); //printf("%8lu lastMenuMenuPos\n", (unsigned long)size);
size += fwrite(&lastCnstMenuPos, 1, sizeof(lastCnstMenuPos), backup); //printf("%8lu lastCnstMenuPos\n", (unsigned long)size);
printf("%" FMT32U " bytes saved\n", (uint32_t)size);
......@@ -324,6 +328,10 @@ void restoreCalc(void) {
size += fread(&lastIntegerBase, 1, sizeof(lastIntegerBase), backup); //printf("%8lu lastIntegerBase\n", (unsigned long)size);
size += fread(&wp43sMemInBytes, 1, sizeof(wp43sMemInBytes), backup); //printf("%8lu wp43sMemInBytes\n", (unsigned long)size);
size += fread(&gmpMemInBytes, 1, sizeof(gmpMemInBytes), backup); //printf("%8lu gmpMemInBytes\n", (unsigned long)size);
size += fread(&alphaSelectionMenu, 1, sizeof(alphaSelectionMenu), backup); //printf("%8lu alphaSelectionMenu\n", (unsigned long)size);
size += fread(&lastFcnsMenuPos, 1, sizeof(lastFcnsMenuPos), backup); //printf("%8lu lastFcnsMenuPos\n", (unsigned long)size);
size += fread(&lastMenuMenuPos, 1, sizeof(lastMenuMenuPos), backup); //printf("%8lu lastMenuMenuPos\n", (unsigned long)size);
size += fread(&lastCnstMenuPos, 1, sizeof(lastCnstMenuPos), backup); //printf("%8lu lastCnstMenuPos\n", (unsigned long)size);
printf("%" FMT32U " bytes restored\n", (uint32_t)size);
......
This diff is collapsed.
/* This file is part of 43S.
*
* 43S 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 3 of the License, or
* (at your option) any later version.
*
* 43S 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 43S. If not, see <http://www.gnu.org/licenses/>.
*/
/********************************************//**
* \file softmenuFCNS.c
***********************************************/
/***********************************************************************************************
* Do not edit this file manually! It's automagically generated by the program generateMenuFCNS *
************************************************************************************************/
/*<--------- 6 functions --------->*/
/*<---- 6 f shifted functions ---->*/
/*<---- 6 g shifted functions ---->*/
const int16_t menu_FCNS[] = {
1, 2, 3, 4, 6, 7,
8, 9, 13, 1578, 18, 19,
20, 22, 1579, 30, 31, 1580,
16, 15, 24, 25, 26, 27,
28, 29, 32, 33, 38, 40,
41, 42, 43, 44, 45, 47,
46, 48, 51, 52, 53, 54,
39, 1543, 60, 62, 64, 1563,
63, 65, 67, 68, 69, 71,
72, 73, 75, 76, 77, 78,
79, 80, 82, 83, 84, 85,
87, 88, 89, 90, 91, 94,
96, 97, 98, 100, 101, 103,
59, 92, 93, 840, 102, 105,
107, 108, 110, 111, 112, 109,
115, 116, 117, 118, 119, 120,
121, 122, 1581, 125, 127, 128,
129, 130, 132, 133, 134, 135,
1533, 136, 799, 137, 138, 113,
114, 141, 142, 143, 144, 145,
146, 147, 148, 149, 151, 152,
153, 156, 157, 159, 167, 161,
162, 164, 163, 165, 154, 155,
158, 168, 172, 173, 874, 175,
176, 177, 178, 193, 180, 181,
182, 185, 188, 189, 190, 191,
192, 197, 198, 199, 200, 194,
195, 1535, 196, 201, 179, 203,
204, 210, 211, 215, 1562, 217,
221, 223, 222, 224, 229, 230,
231, 232, 218, 219, 226, 227,
235, 236, 240, 242, 241, 243,
1565, 237, 238, 239, 247, 1577,
251, 250, 252, 253, 255, 257,
1582, 259, 260, 261, 262, 263,
264, 265, 266, 267, 248, 258,
271, 272, 273, 274, 275, 276,
277, 278, 281, 282, 283, 284,
294, 855, 285, 286, 287, 288,
289, 290, 291, 292, 296, 298,
299, 301, 302, 303, 305, 304,
306, 308, 309, 311, 313, 310,
314, 315, 312, 316, 317, 318,
319, 320, 324, 331, 323, 321,
322, 325, 326, 328, 327, 329,
335, 336, 337, 297, 300, 334,
344, 345, 346, 348, 352, 355,
356, 359, 364, 366, 370, 373,
374, 375, 820, 376, 380, 381,
382, 383, 384, 385, 387, 388,
389, 390, 391, 392, 393, 394,
395, 396, 397, 398, 338, 339,
1545, 340, 341, 342, 343, 1529,
353, 358, 360, 400, 1537, 402,
401, 403, 404, 405, 406, 407,
408, 409, 414, 415, 416, 418,
417, 419, 421, 422, 424, 425,
431, 426, 428, 427, 429, 434,
423, 433, 435, 436, 437, 439,
438, 440, 442, 1564, 443, 444,
445, 446, 447, 450, 452, 453,
454, 455, 457, 458, 464, 459,
461, 460, 462, 465, 466, 468,
469, 471, 474, 476, 449, 467,
473, 475, 481, 1528, 483, 484,
486, 487, 488, 489, 490, 491,
492, 493, 494, 495, 496, 497,
498, 499, 500, 501, 504, 506,
507, 509, 510, 511, 503, 512,
513, 515, 516, 518, 520, 519,
521, 522, 523, 1566, 524, 525,
526, 527, 528, 529, 530, 531,
532, 533, 534, 535, 536, 542,
543, 545, 547, 548, 549, 550,
552, 553, 554, 555, 556, 557,
558, 559, 560, 561, 562, 564,
1531, 566, 567, 568, 572, 573,
574, 575, 577, 579, 581, 582,
583, 584, 585, 587, 589, 590,
591, 592, 593, 594, 595, 596,
597, 598, 599, 600, 602, 612,
540, 546, 569, 570, 571, 576,
578, 601, 613, 614, 615, 616,
620, 622, 623, 624, 626, 627,
629, 1583, 618, 619, 634, 628,
630, 633, 638, 635, 641, 636,
642, 644, 645, 643, 647, 649,
650, 1534, 653, 654, 656, 655,