Commit graph

261 commits

Author SHA1 Message Date
Lephe
97ca5ba82f
display: add a dfont_default() function to get the default font 2021-02-28 22:28:12 +01:00
Lephe
bd40a0a41c
display: add more text size options dnsize() and drsize()
* dnsize() works like dsize() but a limit on the number of bytes is
  specified. This is useful to obtain the length of a substring.
* drsize() has a reverse limit; the input specifies a number of pixels
  and the function determines how much of the input fits. This is useful
  for word wrapping algorithms.
2021-02-22 16:43:02 +01:00
Lephe
a086510885
display: add a maximum size parameter to dtext_opt()
This parameter controls the maximum number of glyphs to print.

For backwards compatibility, it is automatically inserted by a macro in
older calls with only 7 parameters.
2021-02-15 18:37:06 +01:00
Lephe
cb2d067967
std/string: add strchr(), strrchr(), and strchrnul() 2021-02-15 17:28:11 +01:00
Lephe
553982a445
std/stdio: support asprintf() and vasprintf() 2021-02-15 09:48:10 +01:00
Lephe
3885f10ee1
kernel: move VBR at the end of the user RAM area on fx-9860G
This leaves more space available for the heap.
2021-02-15 09:46:59 +01:00
Lephe
2c9ff901d1
mmu: add an mmu_uram_size() function detecting static RAM size
This function performs a more rigorous analysis of the mapped region by
checking continuity. So far all pages mapped in userpsace have been
contiguous, so the results are identical to gint[HWURAM].

Page size is now optionnaly provided in mmu_translate() and its
subfunctions; programs that use this function need to add a second NULL
parameter.
2021-02-05 18:20:16 +01:00
Lephe
bbf6401213
kprint: add floating-point formatting based in Grisu2b 59,56 2021-02-02 22:18:15 +01:00
Lephe
023675d449
improve structure of sources and formatted printer
* Create an `src/3rdparty` folder for third-party code (to add the
  Grisu2B alfogithm soon).
* Split the formatted printer into gint's kprint (src/kprint), its
  extension and interface (include/gint/kprint.h), and its use in the
  standard stdio functions (src/std/print.c).
* Slightly improve the interface of kformat_geometry() to avoid relying
  on knowing format specifiers.
* Add a function to register more formatters, to allow floating-point
  formatters without requiring them.
2021-02-02 18:19:10 +01:00
Lephe
ee7b4f27b8
add a dynamic setting for keyboard scan frequency
The repeat delays of getkey() are adjusted automatically, however a
repeat that is currently going on might be affected.

Also, repeat delays are always approximated as a whole number of
keyboard scans so an increase in scan frequency can impact the speed at
which repeats are emitted.
2021-02-02 18:19:10 +01:00
Lephe
6440527527
rtc: add an rtc_ticks() function similar to RTC_GetTicks() 2021-02-02 18:19:08 +01:00
Lephe
7e1becbd79
cmake: only require version 3.16 2021-02-02 18:18:06 +01:00
Lephe
293532024d
kernel: fix gint[HWURAM] not being set on fx-9860G
When switching to dynamic TLB the counting of mapped memory was no
longer required at boot time. This was restored weirdly for fx-CG 50 and
not at all for fx-9860G; this is now fixed.
2021-02-02 18:18:02 +01:00
Lephe
dce5ade4e1
build: fix uninstall command for sh-based OSes 2021-02-02 18:17:36 +01:00
Lephe
deeaaa499f
update README 2021-01-29 18:22:55 +01:00
Lephe
e5a7d968a6
cmake: declare assets through the fxSDK utility 2021-01-27 20:48:59 +01:00
Lephe
815d479ab7
cmake: install FindGint.cmake (previously in the fxSDK) 2021-01-27 08:57:23 +01:00
Lephe
0ed5ead0a0
update README 2021-01-25 21:52:42 +01:00
Lephe
8157f4b2ab
cmake: restore options USER_VRAM and STATIC_GRAY 2021-01-25 19:06:42 +01:00
Lephe
0525b51ba5
switch build system to CMake
This factors the burden of compiler specification in the fxSDK while
providing substantially more support through CMake modules.
2021-01-25 15:31:20 +01:00
Lephe
15ec46d11c
add GiteaPC support 2021-01-16 18:29:32 +01:00
Lephe
5dbbe76f01
install all headers 2021-01-12 17:11:12 +01:00
Lephe
7a68070bac
show version in header for static version resolution
This change moves the gint version declaration from a symbol in a
compile-time generated object file to a preprocessed header installed in
the library tree.

This makes it possible to determine the gint version statically from the
headers, which is much more robust in complex build systems that use
version information such as CMake's find_package().
2020-12-30 18:35:06 +01:00
Lephe
ad6c108dfc
kernel: always pull the INTC driver
Some very trivial applications might not require its symbols explicitly,
thus the need to force a dependency (otherwise OS interrupts such as the
KEYSC are not disabled and crash the handler very quickly).
2020-10-28 10:01:55 +01:00
Lephe
2c2d1513f9
spu: more complete initialization 2020-10-24 17:40:05 +02:00
Lephe
3694f20d56
spu: starter driver, supporting direct CPU access to SPU memory 2020-10-21 18:29:04 +02:00
Lephe
8ff7d89d33
cpg, tmu: add spin waiting and spin delay functions for drivers
This change adds a new TMU function timer_spinwait() which waits for a
timer to raise its UNF flag. This makes it possible to wait even when
interrupts are disabled.

This is used by the new CPG function sleep_us_spin() which waits for a
given delay without using interrupts. This is currently used in SPU
initialization.
2020-10-21 14:49:34 +02:00
Lephe
858ec8aa12
cpg, power: improve peripheral register descriptions
The POWER and CPG modules have been reverse-engineered by Yatis.
2020-10-21 14:48:04 +02:00
Lephe
19951ccf62
mmu: add MMU registers with a driver context for PASCR and IRMCR 2020-10-21 14:44:47 +02:00
Lephe
3a15340335
topti: improve text positioning
* Specify a line height for the default fx-CG 50 font so that the height
  returned by dsize() is correctly 9, not 11.
* Adjust vertical and horizontal alignment in dtext_opt() and
  dprint_opt() by a full pixel (DTEXT_BOTTOM, DTEXT_RIGHT) and half a
  pixel (DTEXT_MIDDLE, DTEXT_CENTER) to make sure that the specified
  position is within rendered text (as in DTEXT_LEFT and TEXT_TOP) and
  to improve centering of strings with odd width or odd height, for
  which there is only one valid position.
2020-10-21 11:49:12 +02:00
Lephe
e63ff8351b
dsp: enable integrated DSP in SR at startup 2020-10-09 18:58:43 +02:00
Lephe
bc575f1599
intc: update interrupt sources in IPR registers
As per new documentation reverse-engineered from CPU73050.DLL.
https://bible.planet-casio.com/lephenixnoir/sh7305/intc/interrupt-sources.html
2020-10-09 18:03:08 +02:00
Lephe
52d95e72ed
stdlib: force rand() to return a non-negative number
Negative numbers come with tricky modulus results and are excluded from
the return values of the standard rand().
2020-10-09 09:17:48 +02:00
Lephe
078edb50b2
small cleanup 2020-10-05 16:31:37 +02:00
Lephe
240f29f9d5
topti: custom character and word spacing (#13)
This commit introduces custom character spacing with a new fxconv
parameter "char-spacing". Word spacing is also tied to the width of the
space character (0x20). This removes the need for special semantics on
the space character, but requires that its size be specified with gray
pixels for proportional fonts.

This also fixes problems with the size of spaces in dsize() not being
correlated with their size during rendering, since on fx-9860G topti
already used the glyph's with as word spacing.

Since fxconv changes but gint's Makefile does not track updates to
external tools, a full rebuild of gint is required past this commit.
2020-10-05 16:14:12 +02:00
Lephe
2e8b1020cb
display-fx: protect vertical lines against clipping out of bounds 2020-10-05 15:13:38 +02:00
Lephe
9b462deca1
kernel: preload add-in to TLB on SH3 (UNSTABLE) (#12) 2020-09-28 14:09:03 +02:00
Lephe
e66b9083b4
kernel: do not copy data to on-chip memory on SH3
Avoids a crash at startup, but the application needs to be smart enough
to not use the data.
2020-09-28 14:06:29 +02:00
Lephe
744d243265
kernel: do SH3 initialization before context saves
This should be obvious and breaks ctx_save() for the RTC and TMU. Which
apparently never came up during testing.
2020-09-28 14:01:32 +02:00
Lephe
589c25c10c
kernel: do not rely on COMMON sections for GMAPPED refs
Seems to break with binutils 2.35.
2020-09-22 15:17:31 +02:00
Lephe
e5abe03b89
kernel: dynamic loading of GMAPPED functions to user RAM
This commit introduces a large architectural change. Unlike previous
models of the fx-9860G series, the G-III models have a new user RAM
address different from 8801c000. The purpose of this change is to
dynamically load GMAPPED functions to this address by querying the TLB,
and call them through a function pointer whose address is determined
when loading.

Because of the overhead of using a function pointer in both assembly and
C code, changes have been made to avoid GMAPPED functions altogether.
Current, only cpu_setVBR() and gint_inth_callback() are left, the second
being used specifically to enable TLB misses when needed.

* Add a .gint.mappedrel section for the function pointers holding
  addresses to GMAPPED functions; add function pointers for
  cpu_setVBR() and gint_inth_callback()
* Move rram to address 0 instead of the hardcoded 0x8801c000
* Load GMAPPED functions at their linked address + the physical address
  user RAM is mapped, to and compute their function pointers
* Remove the GMAPPED macro since no user function needs it anymore
* Add section flags "ax" (code) or "aw" (data) to every custom .section
  in assembler code, as they default to unpredictable values that can
  cause the section to be marked NOLOAD by the linker
* Update the main kernel, TMU, ETMU and RTC interrupt handlers to use
  the new indirect calling method

This is made possible by new MMU functions giving direct access to the
physical area behind any virtualized page.

* Add an mmu_translate() function to query the TLB
* Add an mmu_uram() function to access user RAM from P1

The exception catching mechanism has been modified to avoid the use of
GMAPPED functions altogether.

* Set SR.BL=0 and SR.IMASK=15 before calling exception catchers
* Move gint_exc_skip() to normal text ROM
* Also fix registers not being popped off the stack before a panic

The timer drivers have also been modified to avoid GMAPPED functions.

* Invoke timer_stop() through gint_inth_callback() and move it to ROM
* Move and expand the ETMU driver to span 3 blocks at 0xd00 (ETMU4)
* Remove the timer_clear() function by inlining it into the ETMU handler
  (TCR is provided within the storage block of each timer)
* Also split src/timer/inth.s into src/timer/inth-{tmu,etmu}.s

Additionally, VBR addresses are now determined at runtime to further
reduce hardcoded memory layout addresses in the linker script.

* Determine fx-9860G VBR addresses dynamically from mmu_uram()
* Determine fx-CG 50 VBR addresses dynamically from mmu_uram()
* Remove linker symbols for VBR addresses

Comments and documentation have been updated throughout the code to
reflect the changes.
2020-09-17 14:48:54 +02:00
Lephe
4288dc27d9
keyboard: add custom repeat filters for full repeat control
This change introduces a new getkey_repeat_filter() function that can be
used to individually accept, deny or delay repeat events for specific
keys and timings.
2020-08-05 11:50:32 +02:00
Lephe
a4d23ef7ad
libc: faster memset 2020-07-28 17:34:25 +02:00
Lephe
492f61f7b2
libc: faster memcpy for on-chip memory
An optimization suggested by TSWilliamson, which pushes not only RAM,
but also on-chip memory and the CPU pipeline to their limits.
2020-07-27 22:47:30 +02:00
Lephe
7b4eb078c4
move src/core to src/kernel 2020-07-26 11:49:33 +02:00
Lephe
d12be8add0
remove features that are deprecated as of v2.1 2020-07-26 11:47:23 +02:00
Lephe
d887423bbb
bopti: more performance improvement for SCSP cases
* Turn on GCC's -O3 for bopti files
* Remove the bopti_render_noclip() step
* Use rbox as early as possible to avoid moving memory around
* A lot of local grinding
2020-07-23 14:03:45 +02:00
Lephe
11dd04243f
bopti: performance improvements for SCSP cases
* Defined the single-column single-position (SCSP) situation where a
  single column of the input is blit on a single position of the VRAM.
  Provided optimized assembly and a specialized bopti_render_scsp()
  function.
* Improved the rendered by reducing the amount of computation and
  clarifying the semantics of the rbox.
* Separated rbox setup from clipping by making bopti_render_clip() a
  purely abstract superset of bopti_render_noclip().
2020-07-23 10:18:46 +02:00
Lephe
39664e9bd2
bopti: fix bouding bugs in bopti_render_noclip()
These errors ironically made the noclip version slower than its
counterpart.
2020-07-21 08:54:34 +02:00
Lephe
4cb1555708
kernel: add an add-in restart mechanism using gint_osmenu()
This new mechanism allows an add-in to be restarted after exiting by
just never exiting in the first place, calling gint_osmenu() instead.
This makes sure that we can relaunch the add-in immediately, which is
normally possible through an option in the OS though no OS-independent
method of setting it is currently known.

Because this is gint_osmenu(), known pitfalls apply. On all platforms,
it is necessary to prepare the first frame before leaving. On fx-CG 50,
the inevitable display border is also there.
2020-07-20 20:37:34 +02:00