Commit graph

38 commits

Author SHA1 Message Date
Christophe de Dinechin
bd22b47a30 Implement commands for various settings
Implement RPL commands to manipulate various settings:
- Display mode (STD, FIX, SCI, ENG)
- Angle mode (DEG, RAD, GRAD)
- Decimal separator (dot or comma)
- Command display (lowercase, uppercase, capitalized or long-form)

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-24 14:55:29 +02:00
Christophe de Dinechin
1831d93826 Directory parsing and rendering
This will allow us to export and parse a variable that contains directories and
subdirectories.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-23 16:31:36 +02:00
Christophe de Dinechin
512e20e503 Move fonts to QSPI
This saves a bit of space for the more interesting parts of DB48X

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-22 16:00:53 +02:00
Christophe de Dinechin
9e8444e6c3 Implement a fraction type for both integer and bignum
Two representations for fractions, one for small value of numerator and
denominator, one when both values are larger.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-20 19:06:56 +02:00
Christophe de Dinechin
77bc37c58a Reimplement bignum as a separate type
Having a sized type for bignum is more efficient both at runtime and in terms of
memory usage:

- At runtime, we don't need all the 7-bit masking and modulo-7 arithmetic
- In terms of memory, there is a cross-over at 63 bits, which is almost exactly
  where it becomes uninteresting to do in-CPU arithmetic

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:08:33 +02:00
Christophe de Dinechin
7cdf8828e7 Implement rendering of algebraic objects
Render objects like '1+X' as text for now (graphics will be later)

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
f569566ab4 Added ->Text functionality
... with some preparation to be able to render equations

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
094eafd126 Implement missing Stack functions
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
0b771b1993 Add comparison and logic operators
Also add the missing 'abs' function

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
0211a6e341 Another pass at font fine-tuning
Reset the vertical font positions in the table to what they were initially,
add -y option to ttf2font to perform the adjustment in code.

This preserves the relative positions of lowercase 'a' and 'g'  much better,
and allows the guides in the font editor to show at the right position.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
1c9f891713 Add identifiers for True and False
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
210a849418 Distinct functions for is_separator and is_separator_or_digit
The parsing of DUP2 was incorrect because... 2 was interpreted as a separator.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
1864d2fdc2 Add Depth command
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
f028e690c6 Some font adjustments to make it denser vertically
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
3f71099129 Add support for scaling ascenders and descenders
It does not work very well, since it moves g relative to c

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
2de0c8b882 Reduce height of [] {} ()
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
596ebe2e25 Add 'ticks' command for benchmarking
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
d10cd5bc37 Add blocks, i.e. programs with silent delimiters
So that loops don't render with chevrons in them

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
ce14cf30b3 Fonts are now beyond 128, need to adjust LEB128 generation
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 22:05:30 +02:00
Christophe de Dinechin
57dd668716 Start laying out basic menus
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
caa72e8c9e Add markers for herarchical menus
A little triangle in the top-right corner indicates a hierachical menu

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
a5f29872f7 Correctly deal with input modes
Detect input mode at cursor position based on content of command line.

Get rid of the AutoComplete pseudo-command, so that we display the name of
objects correctly e.g. for on-line help.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
3ede997fcd Add function that returns system free memory
This is the result of sys_free_memory, for debugging purpose

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
cc66c86cb1 Automatically insert Store and Recall from command line
When using the command line and the variables menu, have the function keys
insert `Store` and `Recall` statements for a given variable depending on what is
being typed.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
8e8e7f482c Add missing superscript - and triangle characters
The superscript `-` is used for things like `cos⁻¹`.
It showed in menus, but not on the command-line.

The triangle will be used for directories.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
303ac0ff17 Add Catalog feature
Add catalog and auto-completion

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
190c4197f8 Implement VariablesMenu
The VariablesMenu lists the variables in the current directory.
Clicking on a function directly executes the associated variable
With shift, the variable contents is recalled
With xshift, a new value is stored in the variable

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
2cc9e45ab6 Second pass at menus
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
f789158ea5 First pass at RPL-based menus
Added an RPL menu object and connected it to the input class

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
cac3fe869c Add memory-management operations (sto, rcl, purge, mem)
Also added two non-HP48 commands, AvailableMemory (memory without GC) and
GarbageCollect (run garbage collector, return amount saved)

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
5a730fb549 Management of global variables
Also added more details on the description of the memory map, including planned
organization for local variables.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
0feaf2756f Add the user 'eval' command, map it to R/S
It is unclear if ID_eval and ID_EVAL should be any different.
For now, assume that ID_eval will enforce additional checks.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
0280891dfb Parsing and evaluation of programs
A simple program now evaluates, but a bit too early

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
f29d405b71 Parsing and rendering of list objects
List syntax is { ABC DEF { 12 34 "Hello world" } }

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
9588917e88 Connect the most common scientific functions
Connect functions like sin, cos, tan, log, etc.

The bad news is that the bid128 functions take _a lot_ of space.

I thought that all of the Intel decimal floating point library was put in the
QSPI, but apparently, only some tables are. The total of the Intel
floating-point code is roughly 1.49M, the code in the calculator roughly 423K.

The code is rather on the large-ish side, with some large chunks of code that
are really hard to explain, like bid128_pow taking a whopping 42K, which is over
5% of my total memory budget (unless I want to take over the QSPI).

    00000004 T __bid128_rem
    00000024 T __bid128_from_uint64
    00000048 T __bid128_from_int64
    00000062 T __bid128_isInf
    00000082 T __bid128_copySign
    00000104 T __bid128_fma
    00000108 T __bid128_sub
    00000180 T __bid128_isZero
    00000348 T __bid128_atan
    00000348 T __bid128_tanh
    00000352 T __bid128_erf
    00000376 T __bid32_to_bid128
    00000404 T __bid128_expm1
    00000516 T __bid128_asin
    00000544 T __bid128_log1p
    00000572 T __bid64_to_bid128
    00000576 T __bid128_acos
    00000604 T __bid128_cbrt
    00000608 T __bid128_mul
    00000608 T __bid128_tgamma
    00000640 T __bid128_exp
    00000648 T __bid128_asinh
    00000656 T __bid128_log
    00000668 T __bid128_log2
    00000676 T __bid128_exp2
    00000684 T __bid128_log10
    00000768 T __bid128_cosh
    00000784 T __bid128_atanh
    00000784 r bid_coefflimits_bid128
    00000880 T __bid128_sinh
    00000900 T __bid128_acosh
    00000968 T __bid128_exp10
    00001016 T __bid128_lgamma
    00001048 T __bid128_erfc
    00001628 T __bid128_class
    00001752 T __bid128_round_integral_zero
    00002004 T __bid128_quiet_equal
    00002176 T __bid128_round_integral_nearest_even
    00002740 T __bid128_to_string
    00003208 T __bid128_to_int32_rnint
    00003680 T __bid128_tan
    00003708 T __bid128_cos
    00003728 T __bid128_to_int32_xrnint
    00003736 T __bid128_quiet_greater
    00003740 T __bid128_sin
    00003748 T __bid128_quiet_less
    00003748 T __bid128_quiet_less_equal
    00004400 T __bid128_hypot
    00004440 T __bid128_to_binary128
    00004700 T bid128_to_binary128_2part
    00004864 T __bid128_to_bid32
    00005484 T __bid128_to_bid64
    00005876 T __bid128_fmod
    00008430 T __bid128_sqrt
    00008592 T __bid128_from_string
    00010140 T __binary128_to_bid128
    00017348 T __bid128_div
    00024390 T __bid128_add
    00029524 t bid128_ext_fma
    00042058 T __bid128_pow

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
0826f3f0ba Various minor tweaks to the font
- Adjust the width of the 's' for small sizes
- Adjust the kerning for 'y'

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
d579325960 Add a glyph for ▶
The glyph was missing from original font. Also added the matching left triangle,
though the documentation does not use it yet.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
fa5fe5ad5e Switch to a new font for help
Also use the same font for stack and editor.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00