Commit graph

169 commits

Author SHA1 Message Date
Christophe de Dinechin
e24546b87a simulator: Add I/O wrapper
Put some common code for saving and restoring files in a wrapper.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
8f2fc58497 simulator: Add interface to report file errors
When writing to a file and there is an error, make sure we see it.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
b1c9856611 simulator: Add F8 key to save state in the simulator
This is a shortcut to save the current state.
Note that you can also get that with RSHIFT-EXIT.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
79760be3e4 dmcp: Avoid double return in the code
Two returns one after another are one too many.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
dbdca4f69b simulator: Accept numeric keys in DMCP menus
When hitting 1-9, trigger the corresponding DMCP menu.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Kjell Christenson
3a93d07788 Fixed problem in simulator missing quick mouse clicks
If two mouse clicks are issued quickly, the second one has the type
QEvent::MouseButtonDblClick.  This leads to the event being ignored.
This is now fixed.

Signed-off-by: Kjell Christenson <kjell.christenson@gmail.com>
Reviewed-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
eb4757bb69 tests: Run command-line tests silently
Do not simulate sound while running tests from the command-line.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:42 +01:00
Christophe de Dinechin
21151aaf60 dmcp: Do not treat the buzzer as error
Do not show `recorder` entries for calls to buzzer functions in DMCP.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-15 21:37:58 +01:00
Christophe de Dinechin
0255b867ad audio: Try to ensure audio always works
There is a problem with repeating error messages.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-15 21:37:58 +01:00
Christophe de Dinechin
dbd6886660 linux: Rewrite the audio-generation code to avoid crashes
The old audio-generation code was crashing on Linux deep in Qt.
Took the audiooutput example from Qt and tweaked it to match.
2024-03-14 18:37:52 +01:00
Christophe de Dinechin
cfe94ca0e0 linux: Add -s option for screen scaling
The `qApp->primaryScreen()->devicePixelRatio()` method no longer
returns the correct pixel ratio at least on X11 over the network.

Add the `-s` option as a workaround to be able to auto-scale the
window for testing purpose.
2024-03-14 01:08:53 +01:00
Christophe de Dinechin
b271555841 linux: Try to avoid a crash in audio
In reality, the problem is inside `audio->stop()`. `Beep` crashes.
2024-03-14 00:42:53 +01:00
Christophe de Dinechin
51c254b298 linux: Address warnings about missing initializers
It looks like gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4) thinks it's a good
idea to complain about every single zero-initialized C structure.

This is widely acknowledged as a (rather annoying)
[GCC bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119)

Add a constructor to silence the warning where possible.
For DMCP C structures where this is not possible, well, add ugly code.
2024-03-13 23:25:15 +01:00
Christophe de Dinechin
483a591986 linux: Remove warning about fall-through switch statement
With gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4), there is a message about
fall-through switch statements. Add comment to silence the warning when the
fall-through is intentional.

There was one case where the fall-through was not intentional.
Missing `break` added.

Fixes: #853
2024-03-13 23:25:15 +01:00
Christophe de Dinechin
f06d17afab linux: Remove warnings about unused arguments
On Fedora 38, GCC incorrectly warns about unused arguments despite the
`__attribute__((unused)))` that should silence the warning.

Observed with gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4).

Fixes: #853
2024-03-13 21:23:55 +01:00
Christophe de Dinechin
745b7227aa simulator: Do not try to create directory if it exists
This is just to avoid setting `errno` when we are just trying to
make sure that the directory exists.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-12 09:49:54 +01:00
Christophe de Dinechin
9e95425850 library: Add equations library and object library
These are two catalogs that behave much like the constants catalog,
and inherit most of the code.

The equations library is intended to store standard equations.

The library is for standard objects and various useful objects or
programs.

Both can be organized by topics.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 11:20:42 +01:00
Christophe de Dinechin
784f07b2c7 tests: Add extra delay in the wait for update
Instead of proactively wait, add a wait loop checking for the result.
This allows the tests to run significantly faster.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:10 +01:00
Christophe de Dinechin
c62b792b19 characterss: Add dynamic characters menu
Same principle as constants and units, but simpler.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:09 +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
97cc7f90bd simulator: Add sound support
Add basic sound simulation in Qt

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
a5493f1e1c simulator: Lazy screen refresh
Perform screen refresh on demand instead of timer-based.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
75478a90e3 dmcp: Add UI refresh callback
Add a callback to explicitly refresh the screen instead of relying on
a volatile counter indicating that the screen is dirty.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
84764d71b1 simulator: Move QT-dependent code out of dmcp.cpp
Split the user-interface portion and the execution portion

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
4fc7e9c5b3 runtime: Various changes to isolate QT build from the rest
Being able to isolate parts that actually use QT is important
to build other platforms.
2024-03-05 12:36:42 +01:00
Christophe de Dinechin
3c48208759 dmcp: Day of week convention adjustment
By convention, 0 is Monday for DMCP, but Sunday for Unix.
I managed to not notice until now...

Fixes: #838

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 22:04:09 +01:00
Christophe de Dinechin
b0efb0ab44 simulator: Add screenshot keys
When hitting the F9 key, take a partial screen snapshot directly
(partial meaning no header).

When hitting the F8 key, take a screen snapshot using the `Screenshot`
command, which is now implemented on the simulator.

Also reduce the size of the window a little so that we can take video
snapshots that are 720 x 400 pixels and capture the keyboard.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
d5a621bbe7 tests: Interrupt tests when pressing the F11 or F12 key
While the test is running, make it possible to interrupt the test
thread at any time.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
418b5e2919 simulator: Adjust DMCP month off-by-one error
The DMCP convention is for the month field to start at 1.
Integrate that in our emulation.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
9b451d7887 time: Add ChronoTime command
The `ChronoTime` command returns time with centisecond precision.

Fixes: #827

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
bbec0939c8 date/time: Refactor the code and add Julian day number
Refactor the code to put all date and time related functions into the
`datetime.h` and `datetime.cc` files.

Also added Julian day number calculations, which enable the
computation of the day of the week in the date format rendering, and
will make it easier to implement future commands such as `DDAYS`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
13958d1ac1 time: Add commands to set the system date and time
Add the `→Date` command to set the system date,
and the `→Time` command to set the system time.

Fixes: #823

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
beaaee23e4 constants: Evaluate constants from config/constants.csv
Dynamic constants menu, similar to units menu, which is populated
either from an internal table, or from `config/constants.csv`

Fixes: #497

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
c12d27ac8b hwfp: Add support for hardware-accelerated floating-point
The hardware-accelerated floating-point support in the ARM chip is
about 2000 faster than the variable-precision decimal floating point
implementation. It makes sense to use it.

See numbers recorded in `doc/6-Performance.md` for details.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +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
6cffed9615 tests: Add image checking for graphical tests
Add image checking from saved image references as a way to check that
the generated pixmaps are consistent from run to run.

Fixes: #732

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-20 20:43:45 +01:00
Christophe de Dinechin
ae1b04c2be tests: Make it possible to individually run tests.
Each test is controlled by a specific recorder tweak.

The `-T` option can now take a test name, e.g. `-Tkeyboard` to run
only that test in an automated way.

The `-O` option can select a single test for interactive testing with
the F12 key.

In both cases, the name follows the recorder syntax.

Fixes: #728

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:50:47 +01:00
Christophe de Dinechin
1507f36dc5 tests: Replace magic constant -1 with EXIT_PGM
We use `-1` to mark the termination of the RPL thread and request the
state to be saved on disk.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:48:16 +01:00
Christophe de Dinechin
71a4798534 dmcp: Make sure the tests don't block on wait_for_key
A call to `wait_for_key()` would prevent the key sync counters from
being updated, and as a result, the test suite would stop.

Fixes: #731

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:47:52 +01:00
Christophe de Dinechin
6f2158107e decimal: Remove all the BID128 stubs and related decimal types
Remove all the bid128 interfaces to make room for the decimal stuff.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:33:06 +01:00
Christophe de Dinechin
6286deafcf decimal: First baby steps of variable-precision decimal code
The `decimal` class represents a variable-size decimal, similar to
what can be found in newRPL.

This commit implements the base class.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:32:23 +01:00
Christophe de Dinechin
699ce554c9 simulator: Fix day of week shortcut
On simulator, Sunday is day 0.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-01 16:50:23 +01:00
Christophe de Dinechin
20489b6b8a statistics: Initial implementation
Just the infrastructure to be able to build the statistics commands.

This originally exceeded the RAM section on DM42, which is surprising
(RAM, not Flash). It turns out that this was the size of the sorted
commands for the catalog, which was fixed.

Fixes: #495

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-15 01:59:04 +01:00
Christophe de Dinechin
76150c6289 files: Allow STO and RCL to write to filesystem
When the argument describing the variable is a text, interpret that as
a file path on the disk. By default, data is stored in in a directory
named `data`, which will be created if necessary. For example, you can
use `3 "foo.48s" STO` to store the value `3` in a file named
`data/foo.48s` on disk.

How the file is stored depends on the extension given to the file:

* For `.txt` files, the object is stored as text
* For `.48s` files, the object is stored as DB48X source code
* For `.48b` files, the object is stored in binary format
* For `.csv` files, the object is stored in comma-separated format.

The binary format used for `.48b` includes a 4-byte magic number
identifying a DB48X format, and a 4-byte checksum used to ensure
binary compatibility between the firmware and the disk format.

At least during early days of development (prior to 1.0), it is quite
unlikely that the binary format for one version of the firmware would
be readable or writable by another version. If you need to recover
data from another version, you need to install that version and save
the object again in `.48s` (text) format.

Fixes: #375

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-15 01:59:04 +01:00
Christophe de Dinechin
ebb6c8a377 performance: Implement some highly-focused optimizations
Did a few additional focused optimizations that bring back another
100ms on the `NQueens` benchmark on the DM42.

This comes at the expense of about 4K of additional generated code,
which is probably as much as is reasonable to dedicate to this.

The numbers for the DM32 are now the best we ever had.

Fixes: #533

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-03 23:05:09 +01:00
Christophe de Dinechin
d49a9bb478 Rename equation as expression
The `equation` type does not really represent equations (it may)
but arithmetic expressions.

Fixes: #518

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-01 19:54:49 +01:00
Christophe de Dinechin
465725cb55 battery: Automatically switch off with message if vbat < 2.5V
Detect a low-batter situation and, when it happens, automatically
switch the calculator with a message on top of the off-image.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-01 19:54:49 +01:00
Christophe de Dinechin
4fbb346772 simulator: Switch to a more full-featured configuration
Use a configuration similar to DB50X to test all features.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:18:47 +02:00
Christophe de Dinechin
b4eeaa6bb8 unit: Implementation of unit objects
This is a very basic implementation of unit objects.
Unit objects are treated as equations where the outermost object
is an ID_mkunit operator.

Fixes: #16

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:10:03 +02:00