Commit graph

56 commits

Author SHA1 Message Date
Christophe de Dinechin
4d7cbf0b3a equations: Add graphical rendering for integrate
Render integrals graphically, in line with sums and products.

Fixes: #1174

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-12 00:50:35 +02:00
Christophe de Dinechin
60236d8fc5 font: Fix v glyph vertical placement, add dot and cross glyphs
Fix the vertical bearing of the `v` glyph so that it does not appear
to be one pixel above the others.

Also add glyphs for

* dot-product (`⋅`, U8901)
* cross-product (`⨯`, 10799)

These can be used to refer to the `CROSS` and `DOT` commands.

Fixes: #1117

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 17:19:56 +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
1ee54c9662 constants: Fix numerical value for G constant
The G constant had a bad definition with `2•kg` instead of `2*kg`.

Fixes; #1128

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 11:55:32 +02:00
Christophe de Dinechin
84cc30a81d solver: Add tests for testing with units
Add test to check that we correctly take the units from

Tests: #1049

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-30 11:44:24 +02:00
Christophe de Dinechin
d64fdb3452 config: Use config files only for user configuration
Switch to using the built-in data files by default, and extending them
with teh configuration file.

The `ShowBuiltinConstants`, `ShowBuiltinCharacters` and
`ShowBuiltinUnits` are not on by default. The size of the
corresponding `config/*.csv` files are reduced to a really simple
example.

Fixes: #1052

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-27 17:34:02 +02:00
Christophe de Dinechin
b00a1c3154 help: Record position for history even without a \n
The `shown` variable should be set even without a `\n`, so that
history records position correctly.

Fixes: #1044

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-27 10:11:44 +02:00
Christophe de Dinechin
dba8aad3fa blitter: Adjust the right margin
The right margin only needs to be rounded to the nearest byte.

Using the scanline is wrong for the hardware screens, where the value
is artificially inflated (416 for 400 actual pixels) because DMCP uses
the extra two bytes for its own internal processing. Swapping
coordinates with 416 instead of 400 ends up messing up that data.

Fixes: #1053

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-27 02:01:43 +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
c9c770b981 ui: Add Edit feature to interactive stack
Add the `Edit` feature to the interactive stack.
When editing an object and replacing it with multiple objects, the
objects are inserted at the interactive stack location.

Add the `Info` button to show information about the stack level.

Separate the `Sort` feature into `MemSort` (sort by memory
representation) and `ValSort` (sort by value).

Add the `EchoNSp` to echo without spaces the way the HP48 does.

Fixes: #1031

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-20 23:57:42 +02:00
Christophe de Dinechin
4febac76d7 ui: Add history menu entries to EditMenu
Add commands to the `EditMenu` to go both up and down in the history,
and to enter the interactive stack.

Switch to the `EditMenu` automatically when we use the history command.

Fixes: #1028

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-20 04:28:29 +02:00
Christophe de Dinechin
3c1dd5afd2 ui: Replace interactive stack "Edit" with "Echo"
This is more consistent with the HP user interfaces.

Fixes: #1027

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-20 02:36:35 +02:00
Christophe de Dinechin
7234b918c5 help: Adjust help area to new height for menus
The menus are now 3 pixels higher than before.
Adjust the help display area to match.

Fixes: #1026

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-20 00:55:27 +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
e32f001ea2 tests: Add tests for interactive stack
The tests for the interactive stack involved a change in the code to
show an object, in order to process test commands correctly and to not
overwrite the screen content with the stack.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-13 00:28:19 +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
5c6d3ed13d expressions: Parse negation after parentheses
When parsing `'xroot(a;-b)'` we were incorrectly returning
'-xroot(a;b)'` because we were treating `-` specially and before
treating parentheses or arguments.

Fixes: #959 (first comment)

Reported-by: mahi2003@users.github.com
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-14 19:23:59 +02:00
Christophe de Dinechin
761c4216c3 xroot: Reverse xroot arguments in algebraic parsing
The `xroot` command is a special case on HP50, in that `A B XROOT`
returns `XROOT(B;A)` and not `XROOT(A;B)` like for other commands.

Special-case the parsing and rendering of that command.

(This is super-ugly, all the more so that the HP50G advanced user
manual actually indicates the order depends on algebraic vs. RPN mode)

Fixes: #959

Reported-by: mahi2003@users.github.com
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-14 19:23:50 +02:00
Christophe de Dinechin
e6a7d2c1e8 functions: Automatic simplification of expressions
Automatically apply some common simplification rules, like `-(-X)`
being converted to `X`.

Fixes: #952

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-30 10:33:13 +02:00
Christophe de Dinechin
e57c310ccd menus: Adjust size of menus to make descenders visible
Descenders in softkey menus were not really visible. This meant that a
unit like `kg` would be visually equivalent to `kq`.

This adjusts the size of menus by one pixel to make it visible, and
extends the clipping area by another pixel, which gives two extra
pixels when drawing in white on a black background.

This is not visually perfect, because as a result, menu entries
without a descender, e.g. 'mol' now appear to be a bit shifted up.

Fixes: #939

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-15 18:57:28 +02:00
Christophe de Dinechin
b404eddd1b arithmetic: Add space around mod and rem in rendering
Add spaces around `mod` and `rem` during rendering.

Fixes: #906

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-16 21:04:00 +02:00
Christophe de Dinechin
d1bd1a813c menus: Replace EquationsMenu with the correct one
Depending on the context, we either want another menu, e.g. `SymbolicMenu`, or
the editor menu when using the `ToolsMenu` with an empty command line.

Fixes: #902

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-15 22:20:31 +02:00
Christophe de Dinechin
0ffafba65f graph: Add space when rendering simple function
When we don't add parentheses around a function's argument, insert a
space to make it look better.

Fixes: #900

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-15 21:09:57 +02:00
Christophe de Dinechin
88009cc619 ui: Add colorization parameters for the user interface
Add configuration parameters that lets you choose the color for the
various elements in the user interface.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-11 13:05:30 +02:00
Christophe de Dinechin
3e59f5febe graphics: ToGrob command
Also reorganize the graphics menu to add a few missing commands.

Fixes: #876

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00
Christophe de Dinechin
6218993e11 variables: Store and recall BMP files
Store files and objects as BMP files.
Recall BMP files as graphical objects.

Also adjust `Show` to not add a border to input graphical objects.

Fixes: #867

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00
Christophe de Dinechin
e33a9accff tests: Change the height of ignored header
We need to ignore a few additional rows of pixels at the top,
otherwise the test images depend on the month name, e.g. "April",
which has a descender for "p", modifies pixesl at the top.

Fixes: #873

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:15 +02:00
Christophe de Dinechin
b8d1f2c429 graphics: Add pixon, pixoff and pix? commands
Also add a `PixColor` command that returns the RGB values for the pixel.

Fixes: #849

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:14 +02:00
Christophe de Dinechin
2fad76ce6c graph: Sum and product graphical rendering
Render sum and product grpahically on the stack.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
fb6c7b69e2 graph: Graphical rendering of combinations and permutations
Render `comb` and `perm` using the traditional mathematical notation.

Note that this is different from the way the HP48 and HP50G do it:

- The HP48 gives an `Undefined name` error for `N M COMB`

- The HP50 expands this to a factorial-based expression.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
5362dd634c graph: Improve rendering of exp, exp2, exp10
Use a smaller font for the argument of these functions.

Also add tests for `sqrt`, `cbrt` and `xroot`

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
6df12cd583 characters: Add music characters menu
The `Boxes` menu is a replication of the `Blocks` menu.
Replace it with a `Music` menu.

Add four missing music glyphs to the font.

Also add the reference file for `chars-menu.png`, which was missing.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
10f8135a3c tests: Adjust image for constants
We are now displaying constants in bold

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
7ccea31843 tests: Fix mismatch on help-exit.png and help-keyboard.png
The `Lib` menu was added, which changes the default screen. This
explains the observed change in `help-exit.png`.

There was a minor change in clipping for the help that causes a
mismatch on `help-keyboard.png`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:54 +01:00
Christophe de Dinechin
a1f3cf8392 constants: Add prefix to identify constants, equations and xlib
There was a prefix in the editor in the first iteration of the
implementation for constants. This was actually a good idea, since it
lets us distinguish if you really want a constant or a normal symbol.

One of the main benefits is that there is no namespace clash. For
example, you can again use the `g` name, since the g constant will
actually be (cst) g. This was breaking the part in the Demo that used
`g` as a value for the level of green.

Visually, added three characters that show as (cst), (eq) and (lib) in
the text editor, in order to know what kind of name we are dealing
with.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 11:20:42 +01:00
Christophe de Dinechin
7bcf3de37c stack: Do not save stack in plot, integration or solver
Make sure that `Undo` and `LastArg` work correctly for plotting
functions, integration and solver.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 16:24:53 +01:00
Christophe de Dinechin
9be0f00eb6 simulator: Avoid piling up QT draw requests
Make sure that we capture consistent pixmaps, which we can do on the
RPL thread, and only defer the transfer of the pixmap to the main
thread, which is fast.

Additionally, optimize updates by doing a byte-by-byte xor comparison
in order to see which bytes actually changed. This minimizes the cost
on the RPL thread to update the pixmap.

This makes it possible to have a much better screen behaviour for the
`CBench` benchmark, where it updates it regularly on the screen while
not slowing things down too much.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 16:18:11 +01:00
Christophe de Dinechin
dd7e692cfd ui: Insert commands for unit conversions, constants and variables
When typing a program, insert commands for unit conversion, constants
and variable menu entries.

For variables, it used to work, but the way this was happening was
fragile, and had been broken by changes in what commands were seen as
"immediate".

Add tests for all these cases to make sure we catch future breakage.

Also emit an error if trying to insert `ConvertToUnitPrefix in a
program.

Fixes: #848

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-03 23:46:45 +01:00
Christophe de Dinechin
4dd72a73c5 tests: Adjust help screen snapshot for authors
The author list was updated in 0.7.0, need to adjust the test.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-03 23:37:10 +01:00
Christophe de Dinechin
b06c1cf9d1 menus: Do not clip text for hierarchical menus
When we have a hierarchical menu, do not clip the text.
Use case: `Length` unit menu now shows its `h`.

Fixes: #846

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-03 23:37:10 +01:00
Christophe de Dinechin
022c6cd8de help: Avoid skipping rows when scrolling through text
When scrolling down through the text, an optimization was avoiding
drawing glyphs until we had reached a displayable point. However, the
computation of the width of each text row was done incorrectly in that
case, leading to undesirable large skips in the text being displayed.

Fixes: #836

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
51e56ad2c7 doc: Improve documentation for sin, cos and tan.
Add documentation inspired by the HP50G reference manual.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
dd5db54d97 arithmetic: Symbolic and numeric infinity
Add support for the `InfinityValue` (-22) flag, described in the
HP50G as the "Infinite result exception" flag.

When the flag is set, infinite results are returned either as symbolic
constant infinity `∞` or as its value, currently defined as
`9.99999E999999`.

Whether the infinity value is returned symbolically or numerially
depends on the `NumericalConstants` (-2) and `NumericalResults` (-3)
flags.

Fixes: #835

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
2236055ae1 flags: Make mixed fractions the default
Display mixed fractions by default instead of improper fractions.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
4c32480ed6 graphs: Graphical list rendering
When the `VerticalLists` setting is on, render lists vertically.

Fixes: #47

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
05d690712a array: Graphic rendering of vectors and arrays
Graphic rendering of arrays and vectors like on the HP50

Fixes: #47

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
2782e32e42 expressions: Graphics rendering
Graphics rendering of expressions

Fixes: #47

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
54244e3297 tests: Repair last regression test
The last regression tests was failing because `XSHIFT` was incorrectly
clearing the `alpha` settting.

Add special keys to reach any of the shift states, e.g. `ALPHA_LS` for
`ALPHA` with left shift.

Fixes: #796

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 19:26:45 +01:00
Christophe de Dinechin
969c5325a3 tests: Add tests for on-line help
Add tests for the various on-line help features.

Fixes: #791

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 23:28:30 +01:00
Christophe de Dinechin
2d0d129ee2 test: Add test for plotting flags
Check the `CurveFilling` and `NoPlotAxes` setting, as well as numeric
flags -31 and -29.

Fixes: #778

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 21:49:53 +01:00