Commit graph

194 commits

Author SHA1 Message Date
Christophe de Dinechin
444bd8a3d1 simulator: Add macOS icons for DB48X and DB50X
This is just because I'm tired of the default icon.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-03 18:06:58 +02:00
Christophe de Dinechin
dee4501d7e tests: Add keyboard shortcuts to launch the demos
F7, F8 and F9 directly invoke the appropriate demos.

Fixes: #1121

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-19 14:19:15 +02:00
Christophe de Dinechin
fa62f3f275 tests: Add three 30 second demo of DB48X features
Separated the demo in three sections of 30 seconds each:
- Basics of RPL and user interface (RPL, function keys, online help, catalog,
  unicode, text editor)
- Mathematics (complex, vector, matrix, symbolic, based)
- Programming

Fixes: #1104

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-14 12:00:05 +02:00
Christophe de Dinechin
4ddbd8e862 simulator: Add tweak to show RPL object details
Showing the address, type and size of RPL objects is not often useful.
It is generally sufficient to just show the object rendering.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-07-28 14:20:54 +02:00
Christophe de Dinechin
b80be478a6 simulator: Avoid Cancel in file save dialog
The Qt file selector returns a null string for Cancel
In that case, don't attempt to save or load an empty file.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-29 14:40:49 +02:00
Christophe de Dinechin
35e189dcd8 build: Fix the clean build
Fix clean build of simulator with `make sim`:

- Pass `TARGET=opt` instead of `TARGET=` when building tools
  to ensure the tool gets properly built irrespective of environment

- Remove reference to obsolete Intel decimal library, which was still
  hanging around in my build directories.

Fixes: #999

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-28 01:33:03 +02:00
Christophe de Dinechin
de7ac35ab4 simulator: Avoid high CPU usage when a timer is active
An active timer when calling `sys_sleep()` would keep bringing the
function out of the loop without calling `nanosleep`, which defeats
the purpose of that function to actually sleep.

The solution is to only take a timer into account if it triggered
while the function was running.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-27 17:55:59 +02:00
Christophe de Dinechin
329800f219 wasm: Run the RPL thread in a separate thread
Reserve the main thread for display updates and keyboard interaction,
like for the Qt version. This allows the web simulator to work
correctly when you run a program or when you access the firwmare
interface.

The downside is that you need to run that on a web server that is able
to set the following [HTTP headers][coop]:

```
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
```

Unfortunately, it is not entirely clear if this can be made to work
easily with [GitHub pages][ghp].

Fixes: #994

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>

[coop]: https://web.dev/articles/coop-coep
[ghp]: https://github.com/orgs/community/discussions/13309
2024-06-24 21:14:06 +02:00
Christophe de Dinechin
b21f211038 simulator: Use the correct color for firmware text
The color used to draw firmware text was backwards.
Compute it correctly from the `inv` field (and rename it `color`).

Fixes: #995

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-06-24 21:14:06 +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
2ca01b758d build: Remove any leftover references to Intel decimal library
That library has not been used since 0.6.0, it's time to wipe it out.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-13 19:17:34 +02:00
Christophe de Dinechin
b05453ad25 polynomials: Add support for polynomials as a separate type
Enough algorithms need a separate notion of polynomials.
Devise a space-efficient representation for them.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-29 20:42:38 +02:00
Christophe de Dinechin
18b22ce7f4 simulator: Separator color and dm32 support
Make it possible to run the DM42 configuration with color and the DM32
configuration in black-and-white.

Fixes: #907

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-17 00:23:47 +02:00
Christophe de Dinechin
0c1abf2689 simulator: Separate db50x and db48x builds
Put the object files in different locations, since they use different
configuration parameters that widely impact the generated code.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-11 13:05:30 +02:00
Christophe de Dinechin
80e94a38d4 tests: Add colorized images to testing
Add a color-images directory to record color reference images

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-11 13:05:30 +02:00
Christophe de Dinechin
927cb623d2 simulator: Convert simulator code to support color
Use the blitter code to manage the LCD buffer instead of ad-hoc
bit-manipulation.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-04-08 21:28:16 +02:00
Christophe de Dinechin
0df86b131f simulator: Avoid crash rendering %t in recorder
If we print a really large value, we need to cut off what we print.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
838938336e menus: Place ListMenu as a keyboard-accesisble menu
Remove the `DataMenu`.

Replace `PrintMenu` with `ListMenu` as keyboard-accessible menu
(we can tuck the rarely used `PrintMenu` under `I/O`)

Add list product, sum, etc to `ListMenu`

Modify `ProgramMenu` to add special program entry characters.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
30fdb68279 tests: Additional key processing in Wait and Show commands
The new sync between tests and RPL theads was not working correctly in
the case of `Wait` and `Show` commands because they were popping keys
without correctly updating `last_key`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
3bdafe49b5 tests: Increase memory size to avoid failing tests
Some tests fail running out of memory:

```
../src/tests.cc:2669:  Test #21: highp: High-precision computations (60 digits)
../src/tests.cc:2669:  21:045.001: cbrt
../src/tests.cc:2669:    Expected output [0.68470 21277 57224 16184 09277 32646 81496 28057 14749 53139 45950 35873 52977 73009 35191 71304 84396 28932 73625 07589 02266 77954 73690 2353], got error [Out of memory] instead
```

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
a7f9fd4cab tests: Another refactoring of the test interface with RPL thread
Split the recorders between `tests` and `tests_rpl`.
Separate the handling of commands into `process_test_commands` and
`process_test_key`, with the key handling happening before we actually
run the code.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
189abcf40c tests: Timing information
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
88207e7eff simulator: Accelerate sys_sleep when running tests
This significantly improves the performance of tests by avoiding
delays waiting to process keys.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
1f6f148634 tests: Reorganize synchronization between RPL thread and tests
Use a separate channel for the communication of test commands with
the RPL thread, in order to make it simpler to deal with corner cases
such as an error being displayed.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
1e71991af2 tests: Add a delay before launching the test thread
This delay is necessary to avoid an occasional crash at startup when
running with `-Tall` and loading a large demo file.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:14 +01:00
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