Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions platform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,22 @@ list builds stayed byte-identical. Not yet run on a board.

## Changes since the copies were taken

- 2026-10-08: the three libraries link from archives (`dot_a_linkage=true`
in CHGfx's, CHGame's and CHSd's `library.properties`). A developer using
only `audio::` and the buttons, with their own display code, found every
sketch that includes `CHGame.h` carrying CHGfx's framebuffer: Arduino
links a library's objects whole, and the DMA interrupt handler in
`CHGfx.cpp` (a strong `DMA1_Channel3_IRQHandler` over the core's weak
one) keeps `gfx_fb`, the chunk buffers and the SRAM converters with it.
From an archive an object is linked only when something calls into it,
so that sketch is 352 B of RAM instead of 9,712 B, and the two hooks the
libraries override (that handler, and `osSystickHandler` in `Audio.cpp`)
sit in the same objects as `gfx_begin()` and `audio::begin()`, so a
sketch that uses the feature always gets them. Plain `riscv-none-embed-ar`
indexes GCC 8's slim LTO objects, so the `-Os -flto` builds need no
`gcc-ar`. All 23 examples' release images are byte-identical
(board/CHANGELOG.md, "Unreleased"). The simulator does not read the flag.

- 2026-10-07: an API reference for every library the board package ships.
The public headers of CHGame, CHGfx, CHSd, SPI, Wire and EEPROM carry
Doxygen comments (a brief, every parameter, the return value, and the
Expand Down
13 changes: 13 additions & 0 deletions platform/board/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ file as the GitHub release notes.
function, class and constant of CHGame, CHGfx, CHSd, SPI, Wire and EEPROM,
documented in their headers with Doxygen.

### Changed

- **CHGfx, CHGame and CHSd link from archives** (`dot_a_linkage=true` in
their `library.properties`), so an object of theirs is linked only when
the sketch calls into it. Arduino otherwise links every object of an
included library whole, and CHGfx's DMA interrupt handler (its
`DMA1_Channel3_IRQHandler` replaces the core's weak default) kept the 8 KB
framebuffer, the 1 KB chunk buffers and the SRAM converters alive in any
sketch that included `CHGame.h`, drawing with it or not. A sketch that
uses `audio::` and `chgame_readButtons()` and draws through its own code
now takes 352 B of static RAM instead of 9,712 B. The 20 games' and the
3 apps' release images are byte-identical. (Reported by a developer.)

### Fixed

- **EEPROM no longer writes the CH32X035's option bytes.** The library is
Expand Down
5 changes: 4 additions & 1 deletion platform/board/arduino/CHGame/libraries/CHGame/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ include just the one it needs, e.g. `<chgame/Fmt.h>`.
what fills it. Unused parts of the library cost nothing (link-time optimisation
drops them).
- **RAM is 18,416 B** for statics, plus a 2 KB stack. The framebuffer takes
8 KB of it.
8 KB of it when the sketch draws with CHGfx. A sketch that includes
`CHGame.h` for its sound, buttons or saves and draws through its own code
does not carry it: the libraries link from archives, so an object is
linked only when something calls into it.
- **`static const` tables of 8 bytes or less** are copied into SRAM by this
core's link script; sound steps use `AUDIO_STEPS` to stay in flash.
- **Integer maths only.** Soft-float costs kilobytes and frame rate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ url=https://github.com/bateske/CHGame
architectures=ch32v
includes=CHGame.h
depends=CHGfx
dot_a_linkage=true
5 changes: 4 additions & 1 deletion platform/board/arduino/CHGame/libraries/CHGame/src/CHGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
/// | chgame/Debug.h | dbg:: the serial debug protocol the simulator and the tools drive a game through (CHGAME_DEBUG builds) |
/// | chgame/Config.h | the library's build switches (CHGAME_DEBUG ...) |
///
/// The casino games in this library's examples are built from these.
/// The casino games in this library's examples are built from these. Only
/// what a sketch calls is linked: CHGfx's framebuffer and DMA handler come
/// with the first drawing call, not with the include, so a sketch that uses
/// this library for its sound, buttons or saves alone pays nothing for them.
/// chgame/Sizzle.h (particles, banners, floating texts) is not included
/// here: a game configures and compiles it itself.
#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ category=Display
url=https://github.com/bateske/CHGame
architectures=ch32v
includes=CHGfx.h
dot_a_linkage=true
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ url=https://github.com/bateske/CHGame
architectures=ch32v
includes=Fat.h,SdSpi.h
depends=
dot_a_linkage=true