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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
The `key_tail()` function should return the last key written, not the
first one.
Fixes: #356
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When the shift key is held, send UP key to the RPL thread.
When the alt key is held. send DOWN key to the RPL thread.
Fixes: #215
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
After a lot of experimentation, it turns out that it's not really
possible to use the shift key as originally planned, because it is not
reliably visible when two keys are simultaneously visible. It can only
be combined with key N and O (and maybe a few others), and these
combinations are clearly treated specially (they give some magic
keycode, e.g. screen snapshot with Shift-DISP on the DM42).
It turns out only three keys seem somewhat reliable in combination
with alphabetic keys: ON, UP and DOWN. On works with _almost_ all
keys, but apparently B or C is missing (forgot which one). Up and Down
work with all alphabetic keys. This turns out to be a good thing,
because it gives us an additional option that was not originally
planned: quick access to lowercases.
The behavior implemented in this commit is therefore the following:
- "Up" held with any key gives an uppercase letter
- "Down" held with any key gives a lowercase letter.
A minor side effect is that up and down are now active on release and
not on key press. In practice, this is barely noticeable.
Fixes: #204
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Now that we display the name of the saved state in the header,
we get tons of messages from a debug message in `get_reset_state_file`
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Only draw elements of the user interface that are individually dirty.
This notably disables the slow and expensive redrawing of menus
while editing, which improves the user experience on battery
(and probably battery life too).
Fixes: #153
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
With the new alpha-shifting logic, the test suite runs much faster
than before, and as a result, ran into many more synchronization issues.
Ensure that we wait for the stack to actually update before we
proceed with evaluating its content. This required a change in logic
where we expect the stack to actually change value, so some tests
have to be changed accordingly.
The net result is that the tests can now pass reliably at full speed.
Fixes: #77
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
There are some slight differences between the structure of the DM42
program and the structure implemented here. Not sure whether the
differences matter, but better follow a known-good model.
Also add missing DMCP critical section functions that appear used
in the DM42 code: `sys_critical_start()` and `sys_critical_end()`.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The application dialog is in a loop processing keys, so send a special "exit"
keycopde (-1) to force it out.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `QSettings` class is only used to store the path to the actual state.
The use of the file dialog seems to cause some trouble with the current working
directory, and this impacts the display of the help file.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Not sure I got this right, but better to see some voltage reading on the actual machine.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
If multiple consumers need to check if the screen has changed, a simple flag
does not do it. Instead, increment a counter that each client will be able to
check indepdendently.
This will be useful for an upcoming test framework
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
I wanted to do something smart with QTimer, but it fails because they interact
with QT's event loop, making timers across threads annoyingly difficult.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>