#+TITLE: Chapter 8: The Modern Palm OS Ecosystem & Alternative Technologies #+AUTHOR: Hermes & Claude #+DATE: 2026-10-07 #+PARENT: [[file:index.org][Index]] #+INCLUDE: goback.org * Beyond C++: When Another Tool Is the Right Choice While writing C++20 with modern GCC 14 is the state of the art for zero-cost abstraction, systems code, and native performance, Palm OS has a remarkably rich software ecosystem. Thanks to twenty-five years of community preservation, several other mature technologies remain outstanding choices today depending on your goals. * 1. FreePascal (~ppcross68k~): Modern Pascal with Native Trap Interop For developers who enjoy strong typing, Pascal readability, and native compilation without manual C assembly filter passes, *FreePascal* has an active Motorola 68000 cross-compiler (~ppcross68k~ v3.3.x). ** What Makes FPC on Palm OS Unique? - *Direct Syscall Traps*: FPC supports the ~syscall~ function modifier, enabling you to declare and invoke Palm OS ROM traps directly from Pascal code with zero assembly glue: #+BEGIN_SRC pascal function FrmAlert(alertId: Word): Word; syscall sysTrapFrmAlert; function FtrGet(creator: LongInt; featureNum: Word; var value: LongInt): Integer; syscall sysTrapFtrGet; #+END_SRC - *SysLib Loading*: FreePascal is proven to dynamically link and load Palm OS shared libraries (~SysLibFind~, ~SysLibLoad~, and dispatch table invocation). - *Caveat (The 16-bit Assembly Overflow)*: FPC's standard library ~system.pp~ emits >57,000 lines of code that overflow the 68000's 16-bit A5 data displacement limit. Projects resolve this by linking against a lightweight hand-crafted ~system.o~ assembly stub. * 2. Plua 2 (Lua 5.0.3): High-Level On-Device Scripting & Standalone PRCs If your goal is rapid prototyping, on-device scripting, or writing an interactive utility without any cross-compilation pipeline, *Plua 2* is the crowning achievement of Palm OS scripting environments. ** Why Plua 2 Stands Out: - *Full Lua 5.0.3 Engine*: Coroutines, metatables, closures, lexical scoping, string buffers, and math libraries. - *Native Widget Abstraction (~gui.*~)*: Unlike other mobile basics that draw raw pixel graphics, Plua provides a direct object-oriented abstraction over native Palm OS forms, buttons, text fields, lists, popup triggers, and menus: #+BEGIN_SRC lua gui.title("Plua NotePad") gui.label("Enter your text:") local f = gui.field(1, 20, 80, "Initial content") gui.button("Save", function() gui.alert("Saved successfully!") end) gui.main() #+END_SRC - *Standalone PRC Generation*: You can compile Lua scripts directly into standalone application PRCs on the device or using the desktop ~plua2c~ tool. The resulting PRC contains a small \\~200-byte launcher stub and bytecode, backed by the shared runtime ~Plua2RT.prc~. * 3. OnBoardC: True Self-Hosting C Development on Device Can you develop, compile, assemble, and link authentic C applications entirely on the Palm OS device itself while sitting on a train or couch? Yes, with *OnBoardC*: - Includes an on-device C compiler, an integrated resource compiler, an assembler, and a linker. - Emits standard ~.prc~ files directly to the Palm OS Storage Heap. - Uses the authentic Palm OS C API. If you have an external keyboard (such as the legendary Palm Portable Folding Keyboard), OnBoardC turns a Palm Vx or Sony CLIÉ into a completely self-contained programming workstation. * 4. Embedded Bytecode VMs: Wren on Palm OS A fascinating modern direction is embedding modern bytecode virtual machines inside a native Palm OS host application: - *Wren* is a fast, class-based, concurrent scripting language whose core VM is written in clean ANSI C99. - By compiling the Wren VM using our GCC 14 freestanding m68k pipeline and embedding it into an app shell compiled with Palm OS binutils, you gain a tiny (~83 KB code footprint) object-oriented scripting environment. - Wren uses fiber green threads that cooperate without preemption—mapping 1:1 onto Palm OS's single-threaded cooperative execution model. * 5. Hardware Interfacing: The Palm Vx Serial & BLE Appliance Ecosystem Palm devices are not just software platforms; their hardware interfaces make them exceptional ultra-low-power serial terminals and appliance controllers: - *The Serial Port*: Connected to the Universal Serial Bus or RS-232 serial UART (~sysFileCUart328~). - *Modern BLE Bridges*: Connecting an ESP32 or nRF52 BLE module to the Palm serial port turns a monochrome Palm V into an ultra-low-power, sunlight-readable Bluetooth Low Energy display terminal that lasts a month on a single battery charge. - Software interfaces via the Palm OS Serial Manager (~SrmOpen~, ~SrmSend~, ~SrmReceive~). * Summary: Choosing Your Technology | Use Case | Recommended Technology | Primary Benefit | |----------|------------------------|-----------------| | Modern C++ systems code, highest performance, smallest size | *GCC 14 + C++20* | 201-byte PRCs, zero overhead, modern type safety | | Structured imperative programming with clean syntax | *FreePascal (ppcross68k)* | Native trap binding, strong typing, clean RTL | | Fast GUI utility, no desktop toolchain required | *Plua 2 (Lua 5.0)* | Native UI widgets, event loop handled by runtime | | 100% on-device standalone hacking | *OnBoardC* | Compiles directly on Palm hardware with portable keyboard | | High-level embedded scripting VM inside C++ | *Wren VM* | Small footprint, fibers, lightweight bytecode | | Hardware sensor / terminal appliance | *Palm V Serial + C/C++* | 160x160 reflective LCD, instant-on, serial UART | #+LF * Further Reading & Reference Resources - **FreePascal on Motorola 68000 & Palm OS:** - FreePascal Official Wiki: /m68k/: https://wiki.freepascal.org/M68k - FPC Palm OS Target & RTL Traps Documentation: https://www.freepascal.org/docs.var - **On-Device Languages & Tools:** - Plua 2 Historical Archive and Manual: https://oldvcr.blogspot.com/2021/08/plua-revisited-lua-for-palmos-and.html - OnBoardC SourceForge Archive: https://sourceforge.net/projects/onboardc/ - PocketC & MathLib Reference on PalmDB: https://palmdb.net - **Hardware Interfacing & BLE Projects:** - Palm Vx Serial Pinouts & Hardware Specifications: https://pinouts.ru/PDA/palm_v_pinout.shtml - ESP32 BLE to Serial Bridges for Classic PDAs: https://github.com/topics/esp32-serial-bridge