Wonderful Toolchain project update - June 2025

Published on June 15, 2025

As usual, it’s been a while. I haven’t felt the retro homebrew spirit in me as much as I used to over the past eight months, admittedly.

There aren’t that many changes this time around, but there have been some (semi-)breaking ones over on the WonderSwan side of things, so I feel they’re worth discussing.

target-wswan-syslibs 0.2.0

This release of the WonderSwan target’s system libraries contains many changes, including some breaking ones:

  • Cleaned up and unified the naming of functions, constants and definitions across the library. This is the main breaking change and affects… pretty much everything.
  • Added partial implementations of <stdbit.h> and <stdcountof.h> - however, as the toolchain’s GCC version is only compliant up to C11, they are explicitly not gated behind a C23 version.
  • Added many hardware helper functions, particularly for CPU, display, sound and DMA operations.
  • Added ws_delay_ms() to compliment ws_delay_us().
  • Added wsx_utf8_encode_next() and wsx_utf8_decode_next() as a low-level way to encode/decode UTF-8 code points.

One change I’d like to highlight in particular is the addition of new macro-based idioms to make certain “wrapped” operations easier and more readable, inspired by the Pascal with keyword. For example, code which is to run with IRQs disabled:

    ia16_disable_irq();
    critical_operation_1();
    critical_operation_2();
    ia16_enable_irq();

can now be written as:

    ia16_critical({
        critical_operation_1();
        critical_operation_2();
    });

More notably, it is now easier to access resources stored in banks outside the main program’s linear ROM bank:

    // provide a specific bank index and address:
    ws_bank_with_rom0(0xF0, {
        memcpy(..., WS_ROM0_MEM, 0x1000);
    });

    // ... or just reference a variable directly:
    ws_bank_within_rom0(data_array, {
        memcpy(..., data_array, sizeof(data_array));
    });

Most of the changes are reflected in the online documentation, particularly in the Doxygen references.

To compile old 0.1.0 code for the time being, you can add -DLIBWS_API_COMPAT=202504L to DEFINES in your project’s Makefile. This will most likely be supported for a while, as I’d have to port many projects of my own first ^^; Here’s to hoping this is the final breaking change of this magnitude!

hardware-definitions

The I/O port surface of any given console can be quite large. As such, it can be annoying to ensure consistency in naming, avoid typos, or write out the same definitions in another language again and again. As part of the renaming performed in target-wswan-syslibs, I decided to try and lessen this problem for the Wonderful toolchain.

For this reason, I developed hardware-definitions, a small repository of XML documents which outline the I/O port surface of a few platforms and can be processed by an included Python script into code headers. Taking advantage of this solution’s benefits, I’ve done a few other things that benefit the toolchain:

  • Added NASM support for the WonderSwan toolchain’s headers, providing an assembly definition file for all of the console’s ports that can be used even by developers not on board with the whole GNU toolchain thing.
  • Added preliminary GBA headers, now exposed in target-gba-syslibs as <gba/mmio.h>. These are subject to change.

AthenaOS

While this is not strictly part of the Wonderful toolchain, it’s worth bringing up: I have tagged the first production-ready builds of an open-source, clean room reimplementation of the WonderWitch BIOS called AthenaBIOS. This is useful for the toolchain, as it will allow people to develop and distribute programs built for this platform while being able to interoperate with modern cartridges and emulators; it might even lead to the deprecation of my solution for this from the last blog post, that is libwwcl.

The source code is available here. Contributions welcome!

Miscellaneous changes

  • New documentation on the toolchain’s architecture has been written:
    • File system hierarchy, including codifying an installation directory for third-party repositories, as well as local user-provided code.
    • Coding style guide, which I will hopefully adhere to myself eventually.
  • wonderful-packages has been improved, both in code and in documentation, to make the toolchain easier to fork.
  • psxavenc, a PS1 video/audio encoder developed by GreaseMonkey and spicyjpeg which I happen to distribute, received a long-awaited 0.3.0 upgrade with many bug fixes and improvements.