Commit graph

103 commits

Author SHA1 Message Date
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
77c5f57f8a dm42: Restore Intel decimal library by default
It's interesting to prove that we can build without it, but we can't
do a release without it.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 11:51:13 +01:00
Christophe de Dinechin
f7484708ad decimal128: Add ability to disable decimal code
At some point, we will need to shift to variable-precision decimal.
Being able to disable all `decimal128` code will help evaluate
how much room we have for that.

With decimal128 active, sizes are:

   text	   data	    bss	    dec	    hex	filename
2254248	   3840	   2524	2260612	 227e84	build/dm42/release/db48x.elf
wc -c db48x.pgm
  710180 db48x.pgm

Without decimal128, sizes are:
   text	   data	    bss	    dec	    hex	filename
 455864	   2872	   2412	 461148	  7095c	build/dm42/release/db48x.elf
wc -c db48x.pgm
  282236 db48x.pgm

In other words, decimal128 at the moment uses 427944 bytes out of our
716800 budget (i.e. 59.7%) and 1798384 in the total size (79.7%).
Chances that a variable decimal implementation can be made smaller
than that.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-05 18:15:30 +01:00
Christophe de Dinechin
af64992f47 Makefile: Add check-ids target
The `check-ids` target checks if commands are in the menus
or in the help.

The `src/ignored_menus.csv` and `src/ignored_help.csv` indicate what
does not need to be reported by the tools. It was initialized with the
current state of missing things, and can serve as a reference for what
commands need to either be documented or added to menus.

Fixes: #615

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-26 22:46:21 +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
328c2e484f Makefile: install demo state and configuration
Better to update the demo and unit configuration files when updating

Fixes: #547

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-06 00:19:11 +01:00
Christophe de Dinechin
c548d19413 Implement debug_printf
Implement a `debug_printf` that shows something on the screen, and a
`debug_wait` to wait for a given delay or a key.

Fixes: #541

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-05 14:19:59 +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
c8d9f4fb9d Makefile: Add a sync before ejecting
This avoids havinf `hdiutil eject` complaining that the resource is busy

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:18:47 +02:00
Christophe de Dinechin
a5ae7bcbe9 dm32: Generate config-independent font file
The generated font files contained an ID that could depend on the
configuration settings for the build. That caused the font file on
DM32 to be incorrect, which caused a crash when editing text.

Fixes: #458

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
Christophe de Dinechin
76927fcd20 documentation: Distinct sections for DM32 and DM42
Add the ability to have machine-specific text in the on-line help.

Fixes: #450

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:10:03 +02:00
Christophe de Dinechin
572cd55ed2 documentation: Update DM42 to DM32 for DB50X
For the moment, simply perform textual replacements

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-22 23:46:37 +02:00
Christophe de Dinechin
9f5ca3dcd2 help: Skip images in the source file
Allow images in the source markdown files, but skip them on calculator

Note that we need to skip them at runtime if we want to be able to
have them in the GitHub file correctly.

Fixes: #438

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
ba206a6e33 build: Build DB50X with CONFIG_FIXED_BASED_OBJECTS
This is mostly to validate the sanity of that build option
(a compilation bug was actually fixed).

Fixes: #432

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
a9b08b3f52 build: Rename 'simulator' to 'db48x'
The name `simulator` is both long and non-descriptive.
Since the `db48x.pgm` and `db48x.pg5` cannot be confused with either
`db48x.app` (macOS), `db48x.exe` (Losedows) or `db48x` (Linux/BSD), it
seems safe to rename the simulator as `db48x`.

Also always build the files with lowercase names.

Fixes: #417

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
6f3c07e759 integrate: Initial implementation of numerical integration
Implement a really basic algorithm for integration evaluation.
This divides the integration surface by two every time.
This appears much less efficient than the integration done by HP calculators.

Fixes: #42

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-15 22:11:33 +02:00
Christophe de Dinechin
6cce8f9a45 Add root command
Add the `root` command, which implements a numerical solver

Fixes: #36

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-15 22:11:33 +02:00
Christophe de Dinechin
2b8c44c4d7 makefile: Automatically regenerate image files
The PNG image files are easy to generate from Keynote, but getting
from there to the file used in the simulator build was still manual.

Generate the target files automatically from the Keynote output.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-05 18:51:39 +02:00
Christophe de Dinechin
582aba1fda Makefile: Prepare copy on other platforms
In case we want to build on some other platform, make it easier to
copy the file. Also makes it possible to use rsync instead.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-01 14:01:42 +02:00
Christophe de Dinechin
d887eceed1 help: Create simulator help files that are target-specific
Generate different files for DB48X.md and DB50X.md.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 23:54:36 +02:00
Christophe de Dinechin
52d15bda32 Makefile: Move the QSPI CRC in a variant-dependent directory
This makes it easier to rebuild the DM32 and DM42 in parallel
during release.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 23:13:12 +02:00
Christophe de Dinechin
294c6a4664 Call DM32 builds 'DB50X'
In order to properly distinguish the DM32 and DM42 builds, call
the DM32 variant 'DB50X' (both for program and QSPI file).

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 20:09:42 +02:00
Christophe de Dinechin
3b7af3a360 Makefile: Switch to -Os for DM42
We are now reaching the point where we need to use that option to fit
on the DM42. The time has come to switch to `-Os` to compress the code
a little.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 10:41:51 +02:00
Christophe de Dinechin
012ddf2548 grob: Add support for bitmap graphic objects
Graphic objects (GROB in RPL parlance) represent bitsmaps of arbitrary
size. They can be used to represent the screen or any other graphic
surface.

Fixes: #30

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 10:41:42 +02:00
Christophe de Dinechin
5645c4f8c3 Implement Tag type
The tag type is used to add a label to any arbitrary object.
It is parsed as `:Label:object`, and renders the same, except on the
stack where it renders as `Label:object`.

Note that the HP48 renders a label with an extra space. The space is
apparently gone on the HP50.

Fixes: #21

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-13 16:45:49 +02:00
Christophe de Dinechin
209d202ea7 Implement source-code comments
This commit implements comments that are preserved in the source code.

A comment begins with `@` and ends with the end of line.
It acts as a no-operation during execution.
It is rendered beginning with a new-line.

This commit also adjusts various issues related to rendering of
newlines and indentation in loops or blocks.

Fixes: #94

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 10:23:03 +02:00
Christophe de Dinechin
eb68728c77 Add support for PPAR / PlotParameters special variable
The PPARM variable defines the plotting / drawing range

Fixes: #319

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-13 19:23:30 +02:00
Christophe de Dinechin
3140e71524 makefile: Add version information to output of build
Also integrate the correct version of the QSPI into the release files

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-08 00:12:52 +02:00
Christophe de Dinechin
225de7d7f5 license: Change to GPL v3, disconnect from DMCP
The dmcp code is moved to a submodule, with its own BDS 3-clause license.
The DB48X code uses DMCP, but is not derived from it.
The GPL license will provide better protection against derivatives with
proprietary additions that are not contributed back to the community.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
d043d8a99f makefile: Add 'make clangdb'
Add a rebuild target for the clangd database

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
078563d278 Implement if-then-else and iferr
Implement `if` `then` `else` blocks, as well as the `iferr` variants.

Being able to test `iferr` also required implementing several
secondary error-management commands, like `errm`, `errn` and `doerr`.

Fixes: #290
Fixes: #291

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
412685818d DMCP5 support and DM32 build
Add support for DMCP5 and DM32 build
This is not perfect at the moment. Some glyphs, like the complex-i,
are missing from menus or the help display, as well as from the
editor font, but show on the stack font. This is rather weird.
Displaying some menus, like the STATS menu, cause a crash in
what appears to be sparse_font::glyph.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:56:41 +02:00
Christophe de Dinechin
e8da3016f8 makefile: Cleanup Emacs backup files before packaging
Running `make dist` could package files that do not belong.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-30 15:27:01 +02:00
Christophe de Dinechin
be9e17bf4f list: Split list.h and list.cc into program, equation and array
In preparation for some serious work on arrays, and in order to
accomodate newcomers to the project, it is a good idea to split
`list.h` and `list.cc` into separate files for `program`, `equation`
and `array`. This will also speed up parallel builds a tiny bit.

Fixes: #167

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-22 15:07:19 +02:00
Christophe de Dinechin
19146113c4 ttf2font: Fix dependency on src/ids.tbl
It's actually the `ttf2font` tool itself that has a dependency on `src/ids.tbl`.
Not updating it with the new IDs produces font files that are misinterpreted
as some other object type by the runtime.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-13 23:49:36 +02:00
Christophe de Dinechin
73c3734ae4 Implementation of complex data type
Implement a complex data type, along with complex arithmetic.
Complex functions are not implemented yet.

Fixes: #15

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-13 09:24:04 +02:00
Christophe de Dinechin
ba58919998 build: Fix dependency of objects on correct version.h
A clean build would actually fail because
- version.h was not built unless you built the simulator
- The simulator would not build right because fonts were not rebuilt

While at it, also fixed dependencies for font building:
- typo in one of the paths causing unnecessary rebuilds
- missing dependency on `ids.tbl`

Also fixed creation of help/ directory before generating help file.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-12 22:29:16 +02:00
Christophe de Dinechin
34a98d6b14 Rename 'input' class to 'user_interface'
This is more than just user input, it also deals with menu and editor.

Fixes: #82

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-07 23:46:20 +02:00
Christophe de Dinechin
711bd7c2b9 Update QSPI size for release
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-07 08:37:59 +02:00
Christophe de Dinechin
7118104ea8 Need the build directory before building the version file
This causes a build error on empty build directory

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-05 08:55:24 +02:00
Christophe de Dinechin
dfc45bae92 Use -O2 by default
Based on experiments in #66, select -O2 for default release builds

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-05 08:32:34 +02:00
Christophe de Dinechin
e96d632c8e Add build options to Makefile
Add options to test various sizes for #66

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-04 20:38:13 +02:00
Christophe de Dinechin
4073c8928a Switch to -Ofast when building release
This makes everything much faster, notably text editing.
The downside is that the PGM file takes 613K already, which is
dangerously close to the limit. Another problem to tackle later

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-04 13:03:30 +02:00
Christophe de Dinechin
22befc1a3a Local variables
Block with local variables, e.g. `→ X Y « X Y - X Y + * »`

Local values reside above the stack. They are referenced by an index,
which makes them very efficient (there is no name lookup). Reading
or storing in a local variable is as efficient as accessing the stack.
This is much faster than global variables, which require a rather slow
linear name lookup and, when storing, moving the directory object.

Implements #54

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-03 19:19:01 +02:00
Christophe de Dinechin
bcfc62e9a7 Makefile: Generate version.h file
Instead of passing a -D on the command line, put the version in a
version file. This is more correct, since it will cause a rebuild of
parts that may depend on it.

Also moved several of the commands out of line to reduce header
dependencies.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-03 14:38:27 +02:00
Christophe de Dinechin
d703c44d82 Fix passing of version define to qmake
You have to love the triple quoting in `\\\\\\\"` to get
the correct quote output in the final makefile...

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-03 09:16:52 +02:00
Christophe de Dinechin
caf7484a5d Add make dist target
This will make it easier to build a release

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-01 09:45:10 +02:00