Commit graph

230 commits

Author SHA1 Message Date
Christophe de Dinechin
9d3346e683 array: Implement con (ConstantArray) command
The `con` command (`ConstantArray`) creates a constant array from
dimensions, another array or vector.

Fixes: #1153

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-02 01:53:32 +02:00
Christophe de Dinechin
3bb852224b array: Add Array→ and →Array commands
Add commands to expand and construct an array from stack elements.

Fixes: #1150

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-01 15:11:32 +02:00
Christophe de Dinechin
83d85d91aa doc: Update status
Update the status information in the documentation:
- List of unimplemented features
- STATUS page

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 23:14:50 +02:00
Christophe de Dinechin
f511df292e graphics: Implement DispXY command
The `DispXY` command on the HP50G takes a font ID that takes 2 values,
1 for small font and 2 for regular font.

In order to implement this in a more easy way, reorder the font IDs so
that they "match", except that 0 gives the even smaller help font and
3 gives the larger editor font.

Fixes: #1146

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 01:41:18 +02:00
Christophe de Dinechin
3385ea4b3b doc: Replace references to EEX with ×10ⁿ
The actual label on the keyboard overlays is now `×10ⁿ`.
For completeness, mention in the original description that we have `E`
on the DM42, `EEX` on old overlays.

Also a minor fix regarding bitmap pictures of the stack and command
line.

Fixes: #1123

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-29 22:33:40 +02:00
Christophe de Dinechin
fcbb81dcff Release 0.7.15 "Teaching" - Bug fixes notably on iOS
This release mostly focuses on issues exposed by the iOS releases.
It's a bug-fixes only release.

***Bug fixes***

* ios: Fix a screen refresh bug delaying the display of computation results
* ios: Increase user-accesssible memory for DB50X to match the DM32
* files: Avoid opening two files when a loaded file contains units/constants
* units: Restrict unit expressions further, e.g. forbid `1_km^s`
* build: Do not add unwanted macOS-specific files in release tar files
* build: Remove irrelevant help file from releae tar file
* constants: Fix numerical value for G constant
* tests: Rename `M` demo helper to `D`, since we use `M` in symbolic tests
* makefile: Add `mv` echo to targets doing image comparison
* units: Use pi constant in definition of radians unit
* parser: Detect syntax error on `(inv(x))` in non-expression mode
* units: Avoid infinite loop for bad unit exponents
* files: Avoid crash in `file_closer` if file does not exist
* tests: Add DMS/HMS operations to math demo
* tests: Add keyboard shortcuts to launch the demos

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-25 22:03:42 +02:00
Christophe de Dinechin
104e4b976c Release 0.7.14 "Kids" - Equation-related bug fixes
This release fixes a number of issues that were discovered primarily
through the Columns and Beams equations.

**Features**

* trigonometrics: Add conversion from non-standard angles, so that
  `cos(1_turn)` gives the correct result.
* debug: Debug on error with `DebugOnError` and `KillOnError`
  settings. This makes it easier to debug an RPL program, by making it
  possible to single-step around the instruction that generated the
  error.
* tests: Add three 30 second demo of DB48X features. These are to
  generate marketing videos for the iPhone version on the Apple
  store (to be done).

**Bug fixes**

* ui: Keep a GC pointer in `draw_object` to avoid a memory crash
* equations: Add missing units in some equations, e.g. `I` and `A` in
  second equation of Coilumns and Beams
* equations: Add explicit `radian` unit in Eccentric Columns `cos`,
  which ensures we get the correct result from the HP50G manual even
  when in Degrees mode.
* units: Correctly factor out non-integral powers, so that we can
  compute `1/sqrt(epsilon_0*mu_0)` and get the correct result.
* catalog: Display commands that begin with selection first, so that
  `FORE` shows `Foreground` before `AlphaForeground`.
* stats: When computing a sum, evaluate the expression on all
  terms. The result for `Variance` with single variables was wrong
  because the first term was computed incorrectly due to a misguided
  optimization.
* graphics: Error out in `RGBPattern` for negative input. The negative
  values were generating an error, but it was not reported, so the next
  command was likely to report it.
* help: Render shift keys correctly in the color version. The bitmap
  was interpreted as containing color data. Colorize it instead.

**Improvements**

* ui: Select orange as background color during search. The previous
  setting of showing seardch using white foreground on a white
  background was probably pushing the notion of "blind search" a bit
  too far.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-18 12:14:07 +02:00
Christophe de Dinechin
d7547676d8 debug: Debug on error
When we reach an error during program execution, automatically enter
debugging mode and enable the debug menu.

This is controlled by the `DebugOnError` setting, which is set by
default (the opposite is `KillOnError`)

Fixes: #1109

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-16 15:29:27 +02:00
Christophe de Dinechin
898ca3115c Release 0.7.13 "Murderers" - Solver improvements
This releases focuses on improvements to the solver, with the completion of the
Columns and Beams section from the HP50G equation library.

**Features**

* equations: Add remaining equations from "Columns and Beams"
* loops: For loops on lists and arrays
* menus: Add `R→D`, `D→R`, `→Polar` and `→Rectangular`
* menus: Automatically select tools menu for library equations
* units: Allow `ubase` to work on expressions
* units: Graphic rendering of units

**Bug fixes**

* 48calc.org: Fix mouse click position
* `#ABC #DEF -` now correctly produces a based number with >64-bit wordsize
* conditionals: Parse and evaluate `IFTE` correctly
* equations: Fix Elastic Buckling
* files: Avoid crash in `file_closer` if file was not open
* istack: Enable Swap feature on top two levels
* menu: Update SolvingMenu when updating VariablesMenu
* parser: Deal with negation more "normally", parse `-a²` correctly
* solver: Compute units correctly for inputs
* solver: Do not change unit when storing in a solver variable
* solver: Emit correct error message in `EvalEq` if missing variables
* solver: Preserve errors reported by underlying function
* units: Do not evaluate/render units with names
* units: No longer read variables `m` and `s` while processing `1_m/s`
* units: Simplify units that convert to real numbers

**Improvements**

* Update .gitignore
* build: Add BMP files to the distribution
* complex: Optimize exit conditions for parentheses
* solver: Add test for equation library
* solver: Add tests for solving with units
* solver: Improve behaviour of `EvalEq`
* solver: Keep units and constants as-is in equation
* solver: Make precision relative to equation sides magnitude
* stack: Show vectors vertically by default
* ui: Do not persistently hide stack with current equation
* units: Keep power integral, i.e. avoid getting `1_m^2.0/s`
* units: Strip tags from unit conversion functions
* units: The `EvalEq` command should not evaluate dates
* wasm: Add logos to the repository

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-05 09:10:53 +02:00
Christophe de Dinechin
a62e4425d0 equations: Add missing equations from "Columns and Beams"
Add the missing equations from "Columns and Beams" section of the
HP50G advanced reference manual.

Notice that some of the descriptions are incorrect in the manual, and
that the correct equations had to be fetched from the HP50G itself.

Foe example, the `Simple Moment` example defines `c`, which is not set
in the documented equation. The actual equation contains `IFTE`
expressions, which require the fix for #1093 to work.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-01 17:48:46 +02:00
Christophe de Dinechin
b6b0fa76fe equations: Add Simple Slope equation
Add the equation for Simple Slope from page 5-5/5-6 of the HP50G
advanced reference manual.

Refs: #1040

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-31 21:00:28 +02:00
Christophe de Dinechin
1d7ef89cef equations: Add Simple Deflection
From HP50G advanced reference manual page 5-5

Refs #1040

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-31 20:58:57 +02:00
Christophe de Dinechin
34b6011980 equations: Add Eccentric Columns
Add Eccentric Columns equations from HP50G Advanced Reference Manual

Refs: #1040

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-31 02:26:52 +02:00
Christophe de Dinechin
e4ff20a949 Release 0.7.12 "Multiply" - Multiple equations
This release focuses on the equation solver, notably in interaction
with the equation library. The goal is to get one step closer to the
equation library in the HP50G, including the ability to have graphical
illustration and multiple equations.

**Features**

* doc: Add documentation for the equation library
* doc: Add images from HP50G equation library (to be used later)
* doc: Some help for the elastic buckling equations.
* equations: Accept lists of equations in library
* help: Add documentation for the various constants
* help: Do not exit help when opening URLs or missing topics
* lists: Add a setting to evaluate list as programs
* menu: Add menu entries for solver imprecision and iterations
* solver: Add support for multiple equation solving
* ui: Add settings to hide/show empty menus and clear menu on EXIT
* units: Add flow units (per user request) in Fluid section of units

**Bug fixes**

* blitter: Adjust the right margin
* blitter: Base horizontal adjust on scanline, not width
* characters: Display correct content for built-in menus
* constants: Close current file while parsing values
* constants: Update some outdated values
* doc: Show help for equations and constants
* help: Do not try to load PNG images
* rewrites: Avoid contradictory rules when reordering constants
* solver: Work correctly with units (when in variables but not equation)

**Improvements**

* build: Shorten the size of the version abbrev
* config: Use config files only for user configuration
* doc: Record performance data about unit conversion
* help: Avoid slowing down when scrolling through pages of help
* help: Record position for history even without a `\n`
* simulator: Add tweak to show RPL object details
* tests: Increase wait time for tests with blinking cursor
* units: Do not simplify while in unit mode

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-29 01:45:54 +02:00
Christophe de Dinechin
fc1dace26d documentation: Show the correct index for constants and equations
For constant and equations menus, match the index in the help file.

Fixes: #1039
Fixes: #1048

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-29 00:39:48 +02:00
Christophe de Dinechin
0f51b08e66 doc: Add images from HP50G equation library
Grabbed images from the HP50G advanced reference manual and converted
them to BMP format so that we can show them on DB48X in the help file.

Fixes: #1034

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-28 23:58:08 +02:00
Christophe de Dinechin
024fc5d713 doc: Some help for the elastic buckling equations.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-28 17:42:54 +02:00
Christophe de Dinechin
c736e6a388 doc: Record performance data about unit conversion
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-28 14:14:04 +02:00
Christophe de Dinechin
e060838398 lists: Add a setting to evaluate list as programs
When the `ListAsProgram` flag is set, lists evaluate as programs,
like on the HP48. The opposite (default) setting is `ListAsData`,
which keeps lists as data like on the HP28.

Fixes: #1051

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-27 10:11:44 +02:00
Christophe de Dinechin
2263a012d9 ui: Add settings to hide/show empty menus and clear menu on EXIT
By default, `EXIT` clears the current menu when not editing.
The `ExitDoesNotClearMenu` setting blocks this behaviour.

By default, empty menus are not shown, leaving more room for the
stack. The `ShowEmtyMenus` ensures that empty menus entries are shown
on the screen.

Fixes: #1046

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Suggested-by: spiff72 <mgobluevictor@gmail.com>
2024-07-27 10:11:44 +02:00
Christophe de Dinechin
6ff3e844bb documentation: Add documentation for the equation library
Add some placeholder documentation for the equation library.

Fixes: #1048

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-27 10:11:44 +02:00
Christophe de Dinechin
4fe509691c blitter: Base horizontal adjust on scanline, not width
When we draw a BMP that has a width that is not a multiple of 8, some
black pixels show up on the right, and the left part is truncated.

The root cause is that the horizontal adjustment uses the width and
not the scanline, so we don't get the correct range of pixels.

Code inspection also showed that there was an error in the size of the
datalen being returned from `grob::pixels`, because it returnes the
size of the object, not the size of the data bitmap.

Fixes: #1043

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-24 14:33:54 +02:00
Christophe de Dinechin
928210d80e help: Add documentation for the various constants
Add some basic documentation for many of the basic constants

Fixes: #1039

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-24 14:33:54 +02:00
Christophe de Dinechin
c18a9975aa Release 0.7.11 "Rest" - Refine interactive stack, graphics in help
This release is a refinement minor release. The primary focus is the interactive
stack, which now lets you edit items, sort either according to memory
representation or by value, display information about objects, and jump directly
to a given stack level using digits.

The simple random number generator implemented in 0.7.10 was replaced with an
additive congruential random number generator (ACORN), which can be configured
in number of bits and number of iterations. A side effect is that there is now
regression testing for single-variable statistics.

The history feature was also improved by automatically enabling the `EditMenu`
when selecting history, and then having the (unshifted) word left and word right
commands automatically cycle through history if used at beginning or end of the
editing buffer.

**Features**

* help: Add ability to display BMP images in help files
* images: Convert help images to BMP
* ui: Add `Edit` feature to interactive stack
* ui: Add history menu entries to `EditMenu`
* ui: Accept `UNDO` while in interactive stack mode
* ui: Have word previous/next cycle through history
* ui: Accept digits to select stack level in interactive stack
* random: ACORN random number generator

**Bug fixes**

* editor: Fix spacing after number followed by `-` sign
* ui: Do not set the `editing` field from interactive stack
* ui: Replace interactive stack "Edit" with "Echo"
* ui: Block user input while using interactive stack
* ui: Do not draw menu markers when displaying interactive stack
* runtime: Avoid crash running above allocated memory in `move_globals`

**Enhancements**

* ui: Reorganize code handling interactive stack keys
* help: Adjust help area to new height for menus

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-22 02:27:41 +02:00
Christophe de Dinechin
28dac54c64 images: Convert help images to BMP
Convert the image files to BMP so that we can display them on the
target calculators.

This will be needed for #1033 (displaying BMP files in help file).

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-22 01:19:41 +02:00
Christophe de Dinechin
196f2ee754 random: ACORN random number generator
Implement an additive congruential random number generator (ACORN),
which is a very simple implementation that can be configured to have
an arbitrary number of random bits.

https://en.wikipedia.org/wiki/ACORN_(random_number_generator)

Fixes: #1019

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-19 22:08:35 +02:00
Christophe de Dinechin
c2235e6045 Release 0.7.10 "Hospitality" - Interactive stack
This release primarily adds the "interactive stack" feature of HP calculators.

**Features**

* stack: Interactive stack and associated menu
* functions: Very basic random number generator
* demo: Add `CountPrimes` and `RandomPlot` examples

**Bug fixes**

* menus: Do not execute if-then-else and similar
* expressions: Avoid error testing for zero/one in power operator
* condidionals: Avoid infinite loop evaluating condition
* menu: Insert `iferr-then-else` correctly from menu
* constants: Skip menu entries

**Improvements**

* menus: Reorganize stack menu to put `Dup` and `Drop` on first page
* menu: Add error functions to `Debug` menu

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-15 01:09:57 +02:00
Christophe de Dinechin
79b1edca30 Release 0.7.9 "Just Asleep" - Online WASM simulator
This release includes a number of bug fixes, facilitates build from
scratch by third-parties, and delivers a WASM-based simulator that
runs on the https://48calc.org web site.

**Features**

* menu: Add `Purge` to the `ClearThingsMenu`
* purge: Add support for lists
* units: Accept units for `sqrt`, `cbrt` and `xroot`
* wasm: Add variant for `48calc.org`
* wasm: Implement WASM support

**Bug fixes**

* complex: Give `Syntax error` for phasor without an angle
* dms/hms: Parse empty numbers in DMS entry
* dms/hms: Protect display against bad input
* editor: Make sure we reposition after shift-up and shift-down
* parser: Parse degrees as an angle unit in phasors
* simulator: Avoid high CPU usage when a timer is active
* simulator: Use the correct color for firmware text
* ui: Compute the correct refresh rate even when nothing is displayed
* ui: Create a non-empty dirty rectangle when clearing annunciators
* ui: Do not refresh beyond LCD size
* ui: Ensure we redraw the shift region to clear busy
* units: Disable simplification during unit definition evaluation

**Improvements**

* build: Fix the clean build
* object: Remove defaults for `as_uint32` and similar
* parser: Cache parser::length when possible
* parser: Merge the `parser::end` and `parser::length` fields
* parser: Optimize integer parsing early exit
* simulator: Avoid `Cancel` in file save dialog
* simulator: Use `https` as a protocol for git submodules
* tests: Add support for degrees sign
* tests: Add test for polar angle conversion.
* units: Add `factoring` variable to limit simplifications
* wasm: Add link to deployed WASM simulator in the README
* wasm: Add script to add COOP / COEP headers
* wasm: Run the RPL thread in a separate thread

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-01 00:56:18 +02:00
Christophe de Dinechin
378aa9111a wasm: Add link to deployed WASM simulator in the README
Add link to [pre-built WASM simulator](https://c3d.github.io/db48x)
to make it easy for someone to actually try the simulator.

Fixes: #994

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-28 01:33:03 +02:00
Christophe de Dinechin
f858087209 wasm: Implement WASM support
This is an in-tree port of [Franco Trimboli's excellent work][wasm].

The goal is to be able to run the simulator in a browser.
This builds with emscripten, as installed by the `emsdk`.
The `emsdk` is added as a submodule, and initialized on first build.

To build the browser WASM version of the simulator, run `make wasm`.

Fixes: #993

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Suggested-by: Franco Trimboli <sunpazed@gmail.com>
Co-developed-by: Franco Trimboli <sunpazed@gmail.com>

[wasm]: https://github.com/sunpazed/db48x-wasm
2024-06-24 21:12:16 +02:00
Christophe de Dinechin
05b9a6acee Release 0.7.8 "Mustard" - Constants in equations
This release keeps marching towards full support for an equation library.
The primary focus was support for constants in equations, including constants
with units like the speed of light, as well as fixing various user-reported
issues.

**Features**

* cycle: Apply to value of tagged object
* equations: Add units to built-in equations
* equations: Adjust menu label to remove units
* equations: Strip units but not constants when rendering
* expressions: Treat `2X` as an implicit product
* solver: Strip units from constants
* units: Unit prefix should preserve the tag

**Bug fixes**

* clearlcd: Fix erasure of screen when not in graphics mode
* constants: Count number of menu entries correctly for builtin menus
* decimal: Accept leading `.` or `,` for decimal values
* expressions: Parse negation after parentheses
* sum: Do not accept a non-name in a sum or product
* type: Return a type value for decimals
* ui: Fix insertion/editing of infix with alphabetic names
* units: Do not read units from variable if they exist
* xroot: Reverse `xroot` arguments in algebraic parsing

**Improvements**

* editor: Shuft-up returns to beginning of line if on first row
* errors: Add `error_save` class, use it in `constant::value`
* expressions: Use the `SaveAutoSimplify` class in `simplify_products`
* units: Split `Eng` to `Elec` and `Visc`

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-16 23:50:59 +02:00
Christophe de Dinechin
05f60c078c Release 0.7.7 "Forgiving" - Units in equations
This release keeps marching towards full support for an equation library.
The primary focus was support for units in equations.

**New features**

* solver: Accept equations in solver menu
* solver: Add shortcut to solve an equation from the library
* solver: Display the current equation above the stack
* solver: Solve expressions containing units
* solver: Add units for solver variables when entering them
* equations: Add option to list variables with units
* programs: Enforce numerical values for solver / plotter
* constants: Implement programmatic lookup
* fonts: Add support for fixed-width digits
* keyboard: Interpret `ASN` as `AsNumber` (convert to decimal)
* complex: Allow insertion of angle while entering phasors
* complex: Implement auto-complex promotion
* graph: Render abs(X) with bars (e.g. |X|)
* functions: Automatic simplification of expressions

**Bug fixes**

* arithmetic: Avoid null-dereference in complex operations
* help: Close help file if topic not found
* solver: Do not store tag for tagged values
* graph: Gracefully fallback if fraction integral part does not render
* units: Avoid null-dereference if unit simplification fails
* units: Count parentheses while parsing units
* put: Fix null-dereference checking the index
* fractions: Do not render two negative signs in graphical mode

**Improvements**

* cycle: Update behaviour for several data types
* menu: Replace `abs` with `|z|` in complex menu
* ui: Micro-optimization to avoid reading object type twice
* parser: Accelerate and improve object parsing
* recorder: Add recorder entries for evaluation
* build: Remove any leftover references to Intel decimal library
* tests: Add `▶` entry in tests
* tests: Increase default wait time to 1000ms
* tests: do not error out if `teval` takes less than 100ms
* equations: Rename `PerfectGas` equation to `IdealGas`
* menus: Adjust size of menus to make descenders visible
* solver: Replace `SolverPrecision` with `SolverImprecision`

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-03 01:17:40 +02:00
Christophe de Dinechin
5899c782f0 equations: Add option to list variables with units
When listing the variables in an expression, add option to also list
the units if names are associated with a unit. The `XVars` command
returns the units, whereas the `LNAME` command only lists the names.

`'(U_V)=(I_A)*(R_Ω)' LNAME` gives `[ I R U ]`.
`'(U_V)=(I_A)*(R_Ω)' XVars` gives `{ I_A R_Ω U_V }`.

Fixes: #948

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-30 21:02:19 +02:00
Christophe de Dinechin
8e9537feca solver: Replace SolverPrecision with SolverImprecision
The setting `SolverPrecision` was giving an absolute precision. It had
been set to 24 back when the default precision was 36 digits with the
IEEE-754 128-bit format.

When the number of digits was reduced to 24 after switching to the
variable-precision floating-point implementation, getting 24 digits
out of the solver became a game of chance, and unlikely for something
as simple as `sqrt(8)`.

Also add documentation for that setting.

Fixes: #947

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-25 10:41:14 +02:00
Christophe de Dinechin
d68f8b26dc constants: Implement programmatic lookup
Add the `CONST` command to lookup constants,
the `LIBEQ` command to lookup library equations,
the `XLIB` command to lookup library items.

Fixes: #937

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-13 23:30:41 +02:00
Christophe de Dinechin
c29b78c3d8 Release 0.7.6 "United" - Equation Solving Menu
This release is primarily about implementing a dynamic solving menu that makes
it easier to solve equations with multiple variables. This is roughly equivalent
to the "Solve Equation" application in the HP50G.

**New features**

* solver: Implement solving menu
* tag: Graphic rendering for tagged objects
* lists: Implement `lname` and `xvars` commands
* arithmetic: Implement `div2` command
* variables: Implement `vars` and `tvars` commands

**Bug fixes**

* render: Avoid errors while rendering / graphing
* expressions: Avoid consuming stack levels for invalid expressions
* symbols: Avoid ignoring the list of bad characters in symbols
* command: Fix for `x!` parsing
* stack: Correctly set clipping for stack index
* doc: Fix typo in release note

**Improvements**

* menus: Add `PixOn`, `PixOff`, `Pix?` and `PixC?` to `GraphicsMenu`

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-13 01:41:39 +02:00
Christophe de Dinechin
9af934c2dc lists: Implement lname and xvars commands
The `lname` command lists variables in an expression.
It is extended in DB48X to also work on programs, arrays and lists.

The `xvars` command is similar, but is more consistent with the rest
of RPL in that it consumes its argument and returns a list.

Fixes: #931

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-12 19:59:48 +02:00
Christophe de Dinechin
6afee8bf95 arithmetic: Implement div2 command
The DB48X `div2` command merges the HP48 `div2` and `idiv2` commands,
which return the quotient and remainder for a polynomial or integer
respectively, and extends it to fractions and decimal values.

Fixes: #927

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-11 22:50:47 +02:00
Christophe de Dinechin
f820ac178f variables: Implement vars and tvars commands
Implement the two commands.
This involves moving the function evaluating type values to the
`object` class, so that we can leverage it.
The `tvars` command accepts both HP-compatible (positive) and
DB48X (negative) type values for filtering.

Fixes: #924

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-11 13:00:38 +02:00
Christophe de Dinechin
e24d0ca1e9 doc: Fix typo in release note
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-07 22:31:26 +02:00
Christophe de Dinechin
709476169e Release 0.7.5 "Perfect Joy" - Polynomials and symbolic rewrites
This release contains a lot of groundwork in preparation for future work on
symbolic expressions, symbolic solving and symbolic integration, as well as to
improve compatibility with HP calculators. In particular, `rewrite` has been
replaced with the HP equivalents, `↑Match` and `↓Match`, allowing top-down and
bottom-up replacement, as well as support for conditions. Also, these commands
return the number of replacements performed instead of just `0` or `1`.

THe other major user-visible new feature is the addition of a polynomials data
type, which does not exist on HP calculators, exposing polynomial features in a
way that is more consistent with the spirit of RPL. For example, Euclidean
division of polynomials can be achieved using the regular `/` operation on
polynomials instead of requiring a dedicated `DIV2` command.

**New features**

* Support for polynomials as a data type, including Euclidean division
* Arithmetic operations on polynomials, including `sq` and `cubed`
* Conversion functions `→Poly` and `Poly→` to convert to and from polynomials
* Optional case-sensitive symbol matching
* Algebra configuration directory (like `CASDIR` on HP calculators)
* rewrites: Replace `rewrite` command with HP-compatible `↑Match` and `↓Match`
* rewrites: Add `ExplicitWildcards` option to match HP syntax (`&A`)
* rewrites: Add rules to expand powers
* rewrites: Add support for conditions when matching patterns
* rewrites: Add support for step-by-step rewrites
* rewrites: Add support for bottom-up rewrites
* flags: `Purge` now resets system flags to default value

**Bug fixes**

* editor: Fix unresponsive keys after using `EXIT` key while searching
* complex: Avoid emitting syntax errors while parsing
* rewrites: Avoid potential garbage collection corruption problem
* rewrites: Disable auto-simplification during rewrites
* rewrites: Factor out rewrite loop
* expressions: Encode expressions with type ID >= 128 correctly
* arithmetic: Add space around `mod` and `rem` in rendering
* graph: Do not add parentheses for `X*(Y/Z)`
* functions: Make percentage operations binary functions
* functions: Turn `min` and `max` into algebraic functions
* cycle: For expressions, cycle graphic/text rendering correctly
* menus: Replace `EquationsMenu` with `ExpressionMenu` in other menus
* ui: Insert space when inserting array inside function

**Improvements**

* menus: Updates to `PolynomialMenu` to enter polynomials and for conversions
* menus: Add product and sum to symbolic and algebra menus
* menus: Make `ToolsMenu` select `SymbolicMenu` for symbols
* expressions: Reorganize the code for rewrites
* rewrites: Add recorders for rewrites that are actually done
* tests: Some adjustments on color images
* rewrites: Convert algebraics into expression as needed
* complex: Parse `3i` and `i3` in addition to `i`
* tests: Add support for more characters
* simulator: Separator color and dm32 support
* graph: Add space when rendering simple function
* keyboard: Updated SVG files with latest menu labeling changes

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-04 23:25:58 +02:00
Christophe de Dinechin
1b28f6d67d symbols: Support case-sensitive symbol matching
Since HP calculators are case-sensitive for symbols, add a setting
`DistinguishSymbolCase` to make symbol-matching case-sensitive.

The default DB48X behaviour is to ignore symbol case, and can be
activated using `IgnoreSymbolCase`

Fixes: #918

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-04 17:24:23 +02:00
Christophe de Dinechin
86a2d5ae18 expressions: Reorganize the code for rewrites
Add new types for wildcards, including testing for names,
zero vs. non-zero integers, etc.

The rewritten expand and collect are not better than before,
we need to connect them to polynomials first.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-29 20:42:38 +02:00
Christophe de Dinechin
3d6d470ea1 rewrites: Add ExplicitWildcards flag
The `ExplicitWildcards` flag requires a `&` sign at the beginning of
wilcards like on HP calculators. When the flag is clear, variable
names in patterns are wildcards by default.

Fixes: #913

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-22 23:31:54 +02:00
Christophe de Dinechin
48e3e3bb98 rewrites: Enhance ↓Match and ↑Match to return number of changes
The result of `↓Match` and `↑Match` on HP calculators is `0` for no
rewrites, or `1` if a replacement occured.

However, it's possible (rarely) for more than one rewrite to occur
even on HP (it's difficult because the algorithm appears to be
single-pass). DB48X can perform multiple rewrites on the same
expression, so it makes sense to enhance `↓Match` and `↑Match` to
return the number of replacements performed. This can still be used as
a test.

Also document the differences in terms of pattern.

Fixes: #912

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-22 19:06:10 +02:00
Christophe de Dinechin
2e01619d1f Release 0.7.4 "Flesh" - Polishing and refinements
This release is mostly about polishing various aspects of the
implementation to make it more convenient and more efficient. It also
adds user-defined functions parsing and evaluation, pixel-manipulation
commands, bit operations on binary numbers, memory operations like
`sto+` or `incr`, loading and saving BMP files, color support in the
simulator, and more.

**New features**

* editor: Implement configurable word wrapping
* expressions: Add code for n-ary functions like `sum`
* expressions: Parse user-function calls like `F(1;2;3;4)`
* expressions: Ensure funcall objects are evaluated immediately
* functions: Add `sum` and `product` functions
* functions: Add combinations and permutations
* functions: Implement number rounding operations (`rnd` and `trnc`)
* graph: Add graphical rendering for `cbrt` (cube root) and `xroot`
* graph: Graphical rendering of combinations, permutations
* graph: Graphical rendering of sum and product
* graphics: Add `pixon`, `pixoff` and `pix?` commands
* graphics: Store and recall BMP files with `sto` and `rcl`
* graphics: `ToGrob` command converting object to graphic
* logical: Add `SetBit`, `ClearBit` and `FlipBit` commands
* memory: Implement the `Clone` (`NewOb`) function
* menus: Add `log2` and `exp2` to `ExpLogMenu`
* menus: Place `ListMenu` as a keyboard-accesisble menu
* parsing: Parse n-ary functions
* program: Add vertical program rendering mode
* stack: Display error message emitted during stack rendering
* ui: Add colorization parameters for the user interface
* ui: Add some colorization
* variables: Add `Sto+`, `Rcl+` and other variable arithmetic
* variables: Implement `Increment` and `Decrement`

**Bug fixes**

* decimal: Fix precision when computing gamma/lgamma
* decimal: Fix rounding bug when rounding increases exponent
* doc: Add missing dependencies on Fedora (submitted by @vkadlcik)
* files: Do not error when opening constants/equation/library files
* files: Open only one configuration file at a time
* graphics: Fix bug drawing a line of width 0
* graphics: Use foreground color for parenthese and ratio
* lists: Separate list sum/product from regular sum/product
* renderer: Make sure `printf` respects target buffer size
* simulator: process double-clicks correctly (submitted by @kjellc)
* tests: Change the height of ignored header

**Improvements**

* command: Factor out arity for all commands
* constants: Report parse error location for invalid constants
* demo: Add HP-48 style slow walk to `Walk` demo
* demo: Modernize the code a little
* demo: Modify performance benchmarks to use `TEval`
* demo: Replace imaginary unit constant
* doc: Remove reference to Intel Decimal Library
* files: Convert all file names to lowercase (Linux support)
* functions: Make it possible to interrupt a running sum/product
* graph: Improve rendering of `exp`, `exp2`, `exp10`
* graphics: Separate color conversion step
* help: Do not display command name while editing
* ids: Make room for a few additional 1-byte commands
* locals: Document the absence of compiled local variables
* makefile: Add configuration files to the release `.tgz` file
* parsing: Make the error message for sub-expressions more local
* readme: Remove reference to DM42 from top-level readme
* simulator: Avoid crash rendering %t in recorder
* simulator: Convert simulator code to support color
* simulator: Replicate open files limitations
* simulator: Separate db50x and db48x builds
* tests: Add colorized images to testing
* tests: Avoid occasional errors on some long-running tests
* ui: Define cursor position in `SelfInsert` with `\t`
* ui: Ignore EXIT, BSP and ENTER keys when clearing error

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-14 16:40:45 +02:00
Christophe de Dinechin
64b0d6f7ce doc: Remove references to the Intel Decimal library
Since DB48X no longer uses that library, remove references to it from
the help files acknowledgements section.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-14 16:18:52 +02:00
Christophe de Dinechin
00a4a25869 files: Convert all file names to lowercase
For case-sensitive filesystems like on Linux, avoid file errors
when the case does not match.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:16 +02:00
Christophe de Dinechin
d794d986c4 locals: Document the absence of compiled local variables
Compiled local variables is a rather obscure feature with a weird
syntax. It is documented on page 1-10 of the HP50G advanced reference
manual as follows:

  Global variables use up memory, and local variables can’t be used
  outside of the program they were created in. Compiled local
  variables bridge the gap between these two variable types. To
  programs, compiled local variables look like global variables, but
  to the calculator they act like local variables. This means you can
  create a compiled local variable in a local variable structure, use
  it in any other program that is called within that structure, and
  when the program finishes, the variable is gone.

  Compiled local variables have a special naming convention: they must
  begin with a `←`. For example,

    « → ←y 'IFTE(←y<0,BELOW,ABOVE)' »

  The variable `←y` is a compiled local variable that can be used in
  the two programs `BELOW` and `ABOVE`.

There does not seem to be any mention of the feature in the HP48 user
manual.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:16 +02:00
Christophe de Dinechin
f001a3e11c variables: Add Sto+, Rcl+ and other variable arithmetic
Implement `Sto+`, `Sto-`, `Sto*` and `Sto/` like on the HP48.
Implmeent `Rcl+`, `Rcl-`, `Rcl*` and `Rcl/` like on the HP42
(even if for RPL, there is not much to gain compared to separate
operation)

Fixes: #866

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00