From 2eda7e12120a9ebe774405101840e0ef2023409d Mon Sep 17 00:00:00 2001 From: "Rich O." Date: Mon, 2 Nov 2026 13:12:30 -0500 Subject: [PATCH] palm-client: fourth code segment (map, flood scopes); title status no longer leaves text behind --- docs/progress.md | 1 + palm-client/Makefile | 2 +- palm-client/src/home_form.c | 39 +++++++++++++++++++---------- palm-client/src/map_form.c | 30 +++++++++++----------- palm-client/src/map_form.h | 2 +- palm-client/src/map_geo.c | 6 ++--- palm-client/src/map_geo.h | 10 ++++---- palm-client/src/scope_proto.h | 22 ++++++++-------- palm-client/src/scopes.c | 22 ++++++++-------- palm-client/src/scopes.h | 10 ++++---- palm-client/src/sections.h | 4 ++- palm-client/tools/check_sections.py | 2 +- palm-client/tools/sect2.py | 4 +-- palm-client/visormesh.def | 2 +- 14 files changed, 86 insertions(+), 70 deletions(-) diff --git a/docs/progress.md b/docs/progress.md index 4e37e4a..9865aa3 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -90,3 +90,4 @@ - 2026-11-02: Flood scopes: a list of scope names (Options > Flood Scopes), the radio's default (Set Default / No Default), a per-channel choice (Options > Channel Scope: radio default, none, or a named scope), and Discover, which asks neighbouring repeaters for their regions (SEND_ANON_REQ type 0x01). The session sets the scope override before each flood send and resets it on disconnect. Keys and frames are host-tested (tests/test_scopes.c; the key for "test" matches the radio's #test channel key). Verified on the Neo. Discover only reaches 0-hop repeaters for now. - 2026-11-02: Map screen (Options > Map): an OpenStreetMap basemap of the Philadelphia metro in 4 greys with the contacts that advertise a position plotted on it (no position, not shown). `tools/make_map.py` downloads OSM roads, rail, water and parks (Overpass, cached in tools/map-cache), draws zooms 10-12 for the metro and 13 with residential streets for ~16 km around Center City, and writes build/VisorMeshMap.pdb (290 PackBits tiles, 1,045 KB); `make map`, `make install-map`. Zoom with -/+ or the hard buttons, drag to pan, tap a node for its info, tap again to open it. Fixed on the device: a long node name overflowed the info bar (reset), and the attribution overlapped the buttons. Verified on the Neo. Segment 3 is 24.9 KB. - 2026-11-02: Emoji: 12 common ones have their own glyph in both fonts (thumbs up, tears of joy, heart, crying, folded hands, waving hand, fire, party popper, thinking, eyes, antenna, 100), with close variants mapped onto them and skin tones dropped; the rest stay the generic smiley. Tap an emoji in a message for a 32x32 picture and its name (resources/emoji.bin from gen_font.py). Verified on the Neo. Segments: 12.2 / 28.8 / 25.7 KB; vmcode2 is nearly full. +- 2026-11-02: Fourth code segment (vmcode4: map and flood scopes). Segments: 12.2 / 28.8 / 15.6 / 10.2 KB. Home's title status erases back to where the previous text started (the large font left "Co" of "Connecting..." behind). Verified on the Neo. diff --git a/palm-client/Makefile b/palm-client/Makefile index 4c20b98..0150dd4 100644 --- a/palm-client/Makefile +++ b/palm-client/Makefile @@ -49,7 +49,7 @@ build/%.o: src/%.c src/*.h src/ui/*.h | build @mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@ -# Two code segments (see src/sections.h): multigen turns visormesh.def into a +# Extra code segments (see src/sections.h): multigen turns visormesh.def into a # stub and a linker script that place section vmcode2 in its own code resource. build/$(APP)-sections.s build/$(APP)-sections.ld: $(APP).def | build m68k-palmos-multigen -b build/$(APP)-sections $(APP).def diff --git a/palm-client/src/home_form.c b/palm-client/src/home_form.c index bbda4de..a9b0b45 100644 --- a/palm-client/src/home_form.c +++ b/palm-client/src/home_form.c @@ -18,6 +18,7 @@ static void DrawRow(UInt16 row, const RectangleType *b, void *ctx) VM_SECT2; static Boolean Selectable(UInt16 row, void *ctx) VM_SECT2; static void DrawTitleStatus(void) VM_SECT2; static void ShowStatus(const Char *text) VM_SECT2; +static void TitleRight(const Char *text) VM_SECT2; static void Rebuild(Boolean draw) VM_SECT2; #define HOME_MAX_ROWS 64 @@ -70,32 +71,44 @@ static Boolean Selectable(UInt16 row, void *ctx) } /* Right end of the title bar: unread total and connection state. */ -static void DrawTitleStatus(void) +/* + * Text at the right end of the title bar. Erases back to where the previous + * text started, so a shorter one doesn't leave the start of a longer one + * behind ("Connecting..." is 65 px in the large font). Rows 2-10: above the + * title line, so the large font draws a row higher. + */ +static Coord gTitleLeft = 160; + +static void TitleRight(const Char *text) { RectangleType r; - Char buf[24]; FontID old = FntSetFont(vmSmallFont); + Coord left = 158 - FntCharsWidth(text, StrLen(text)); + + if (left < gTitleLeft) + gTitleLeft = left; + RctSetRectangle(&r, gTitleLeft - 1, 2, 160 - (gTitleLeft - 1), 9); + WinEraseRectangle(&r, 0); + DrawRight(text, 158, gUiFontHeight > 6 ? 3 : 4); + gTitleLeft = left; + FntSetFont(old); +} + +static void DrawTitleStatus(void) +{ + Char buf[24]; UInt16 unread = ConvosUnread(gRows, gCount); - RctSetRectangle(&r, 100, 2, 60, 9); - WinEraseRectangle(&r, 0); if (unread) StrPrintF(buf, "%c%u %s", GLYPH_COMPANION, unread, SessionIsConnected() ? "online" : "offline"); else StrCopy(buf, SessionIsConnected() ? "online" : "offline"); - DrawRight(buf, 158, 4); - FntSetFont(old); + TitleRight(buf); } static void ShowStatus(const Char *text) { - RectangleType r; - FontID old = FntSetFont(vmSmallFont); - - RctSetRectangle(&r, 100, 2, 60, 9); - WinEraseRectangle(&r, 0); - DrawRight(text, 158, 4); - FntSetFont(old); + TitleRight(text); } static void Rebuild(Boolean draw) diff --git a/palm-client/src/map_form.c b/palm-client/src/map_form.c index f8e3be9..f73a6a4 100644 --- a/palm-client/src/map_form.c +++ b/palm-client/src/map_form.c @@ -9,21 +9,21 @@ #include "ui/draw.h" #include "ui/text.h" -static Boolean OpenMap(void) VM_SECT3; -static void CloseMap(void) VM_SECT3; -static void LoadNodes(void) VM_SECT3; -static BitmapType *Tile(UInt16 rec) VM_SECT3; -static void ClampCenter(void) VM_SECT3; -static void Draw(void) VM_SECT3; -static void DrawNodes(const RectangleType *r, Int32 vx, Int32 vy) VM_SECT3; -static void DrawInfo(const RectangleType *r) VM_SECT3; -static void DrawFooter(void) VM_SECT3; -static void Halo(const Char *s, UInt16 len, Coord x, Coord y) VM_SECT3; -static Char TypeGlyph(UInt8 type) VM_SECT3; -static Int16 NodeAt(Coord x, Coord y) VM_SECT3; -static void Zoom(Int16 by) VM_SECT3; -static void SaveView(void) VM_SECT3; -static Int32 FloorDiv(Int32 a, Int32 b) VM_SECT3; +static Boolean OpenMap(void) VM_SECT4; +static void CloseMap(void) VM_SECT4; +static void LoadNodes(void) VM_SECT4; +static BitmapType *Tile(UInt16 rec) VM_SECT4; +static void ClampCenter(void) VM_SECT4; +static void Draw(void) VM_SECT4; +static void DrawNodes(const RectangleType *r, Int32 vx, Int32 vy) VM_SECT4; +static void DrawInfo(const RectangleType *r) VM_SECT4; +static void DrawFooter(void) VM_SECT4; +static void Halo(const Char *s, UInt16 len, Coord x, Coord y) VM_SECT4; +static Char TypeGlyph(UInt8 type) VM_SECT4; +static Int16 NodeAt(Coord x, Coord y) VM_SECT4; +static void Zoom(Int16 by) VM_SECT4; +static void SaveView(void) VM_SECT4; +static Int32 FloorDiv(Int32 a, Int32 b) VM_SECT4; #define MAP_DB_NAME "VisorMeshMap" #define MAP_PREFS_ID 5 diff --git a/palm-client/src/map_form.h b/palm-client/src/map_form.h index 70cf9fb..c3b9d39 100644 --- a/palm-client/src/map_form.h +++ b/palm-client/src/map_form.h @@ -9,6 +9,6 @@ #include #include "sections.h" -Boolean MapFormHandleEvent(EventType *event) VM_SECT3; +Boolean MapFormHandleEvent(EventType *event) VM_SECT4; #endif diff --git a/palm-client/src/map_geo.c b/palm-client/src/map_geo.c index 5659fee..34bb8b7 100644 --- a/palm-client/src/map_geo.c +++ b/palm-client/src/map_geo.c @@ -3,9 +3,9 @@ #define HDR_FIXED 66 /* '>4sHHBBiiiiIHH32s' */ #define HDR_ZOOM 16 /* '>BBHHHii' */ -static UInt16 Be16(const UInt8 *p) VM_SECT3; -static Int32 Be32(const UInt8 *p) VM_SECT3; -static Int32 Lookup(const UInt8 *table, UInt16 count, Int32 v0, UInt32 step, Int32 v, Boolean *ok) VM_SECT3; +static UInt16 Be16(const UInt8 *p) VM_SECT4; +static Int32 Be32(const UInt8 *p) VM_SECT4; +static Int32 Lookup(const UInt8 *table, UInt16 count, Int32 v0, UInt32 step, Int32 v, Boolean *ok) VM_SECT4; static UInt16 Be16(const UInt8 *p) { diff --git a/palm-client/src/map_geo.h b/palm-client/src/map_geo.h index da624c2..ba15102 100644 --- a/palm-client/src/map_geo.h +++ b/palm-client/src/map_geo.h @@ -35,18 +35,18 @@ typedef struct { } VmMapHeader; /* The header record; the tables point into p, which must stay valid. */ -Boolean VmMapParseHeader(const UInt8 *p, UInt32 len, VmMapHeader *h) VM_SECT3; +Boolean VmMapParseHeader(const UInt8 *p, UInt32 len, VmMapHeader *h) VM_SECT4; /* World pixels at the map's max zoom; false outside the map's area. */ -Boolean VmMapWorld(const VmMapHeader *h, Int32 latE6, Int32 lonE6, Int32 *wx, Int32 *wy) VM_SECT3; +Boolean VmMapWorld(const VmMapHeader *h, Int32 latE6, Int32 lonE6, Int32 *wx, Int32 *wy) VM_SECT4; /* World pixels at the max zoom to pixels at zoom index zi, from the zoom's tile (0, 0). */ -void VmMapToZoom(const VmMapHeader *h, UInt8 zi, Int32 wx, Int32 wy, Int32 *x, Int32 *y) VM_SECT3; +void VmMapToZoom(const VmMapHeader *h, UInt8 zi, Int32 wx, Int32 wy, Int32 *x, Int32 *y) VM_SECT4; /* The record holding tile (col, row) at zoom index zi, or 0 if outside the grid. */ -UInt16 VmMapTileRecord(const VmMapHeader *h, UInt8 zi, Int32 col, Int32 row) VM_SECT3; +UInt16 VmMapTileRecord(const VmMapHeader *h, UInt8 zi, Int32 col, Int32 row) VM_SECT4; /* PackBits: false if src runs out or overflows dst before dstLen bytes. */ -Boolean VmUnpackBits(const UInt8 *src, UInt32 srcLen, UInt8 *dst, UInt32 dstLen) VM_SECT3; +Boolean VmUnpackBits(const UInt8 *src, UInt32 srcLen, UInt8 *dst, UInt32 dstLen) VM_SECT4; #endif diff --git a/palm-client/src/scope_proto.h b/palm-client/src/scope_proto.h index 20e9c9f..4fe7d8a 100644 --- a/palm-client/src/scope_proto.h +++ b/palm-client/src/scope_proto.h @@ -47,37 +47,37 @@ #define VM_FW_UNSCOPED 12 /* SET_FLOOD_SCOPE_KEY 1 */ /* Name without a leading '#', as stored; key from "#" + that. */ -const Char *VmScopeBareName(const Char *name) VM_SECT3; -void VmScopeKey(const Char *name, UInt8 key[VM_SCOPE_KEY_SIZE]) VM_SECT3; +const Char *VmScopeBareName(const Char *name) VM_SECT4; +void VmScopeKey(const Char *name, UInt8 key[VM_SCOPE_KEY_SIZE]) VM_SECT4; /* * A name we can derive a key for: 1-30 printable ASCII characters after any * '#', not starting with '$' (private regions have keys only the repeaters * that set them up know). */ -Boolean VmScopeNameValid(const Char *name) VM_SECT3; +Boolean VmScopeNameValid(const Char *name) VM_SECT4; /* key NULL: clear the override, so sends use the radio's default. */ -UInt16 VmBuildSetScopeKey(UInt8 *out, UInt16 outSize, const UInt8 *key) VM_SECT3; -UInt16 VmBuildSetUnscoped(UInt8 *out, UInt16 outSize) VM_SECT3; +UInt16 VmBuildSetScopeKey(UInt8 *out, UInt16 outSize, const UInt8 *key) VM_SECT4; +UInt16 VmBuildSetUnscoped(UInt8 *out, UInt16 outSize) VM_SECT4; /* name NULL: no default. */ -UInt16 VmBuildSetDefaultScope(UInt8 *out, UInt16 outSize, const Char *name) VM_SECT3; -UInt16 VmBuildGetDefaultScope(UInt8 *out, UInt16 outSize) VM_SECT3; +UInt16 VmBuildSetDefaultScope(UInt8 *out, UInt16 outSize, const Char *name) VM_SECT4; +UInt16 VmBuildGetDefaultScope(UInt8 *out, UInt16 outSize) VM_SECT4; /* A zero-hop regions request to the repeater with this key. */ -UInt16 VmBuildRegionsReq(UInt8 *out, UInt16 outSize, const UInt8 *pubKey) VM_SECT3; +UInt16 VmBuildRegionsReq(UInt8 *out, UInt16 outSize, const UInt8 *pubKey) VM_SECT4; /* PUSH_BINARY_RESPONSE: the request's tag, and the names (not NUL-terminated). */ Boolean VmParseRegionsReply(const UInt8 *p, UInt16 len, UInt32 *tag, - const UInt8 **names, UInt16 *namesLen) VM_SECT3; + const UInt8 **names, UInt16 *namesLen) VM_SECT4; /* * The next name in a comma list from *pos (advanced past it), trimmed, into * out[VM_SCOPE_NAME_SIZE] (cut if longer). Returns false at the end. */ -Boolean VmNextRegionName(const UInt8 *names, UInt16 len, UInt16 *pos, Char *out) VM_SECT3; +Boolean VmNextRegionName(const UInt8 *names, UInt16 len, UInt16 *pos, Char *out) VM_SECT4; /* DEFAULT_FLOOD_SCOPE: name[VM_SCOPE_NAME_SIZE] is "" when the radio has none. */ -Boolean VmParseDefaultScope(const UInt8 *p, UInt16 len, Char *name, UInt8 key[VM_SCOPE_KEY_SIZE]) VM_SECT3; +Boolean VmParseDefaultScope(const UInt8 *p, UInt16 len, Char *name, UInt8 key[VM_SCOPE_KEY_SIZE]) VM_SECT4; #endif diff --git a/palm-client/src/scopes.c b/palm-client/src/scopes.c index 2501305..79b304e 100644 --- a/palm-client/src/scopes.c +++ b/palm-client/src/scopes.c @@ -6,17 +6,17 @@ #include "contacts.h" #include "scopes.h" -static Int16 FindChannel(const VmChannel *c) VM_SECT3; -static void SavePrefs(void) VM_SECT3; -static void Error(const Char *msg) VM_SECT3; -static void FillList(FormType *form) VM_SECT3; -static void ShowDefault(FormType *form) VM_SECT3; -static void AddTyped(FormType *form) VM_SECT3; -static void DeleteSelected(FormType *form) VM_SECT3; -static void SetRadioDefault(FormType *form, Boolean clear) VM_SECT3; -static void Discover(FormType *form) VM_SECT3; -static Boolean AddName(const Char *name) VM_SECT3; -static void SetDefaultLabel(FormType *form, const Char *text) VM_SECT3; +static Int16 FindChannel(const VmChannel *c) VM_SECT4; +static void SavePrefs(void) VM_SECT4; +static void Error(const Char *msg) VM_SECT4; +static void FillList(FormType *form) VM_SECT4; +static void ShowDefault(FormType *form) VM_SECT4; +static void AddTyped(FormType *form) VM_SECT4; +static void DeleteSelected(FormType *form) VM_SECT4; +static void SetRadioDefault(FormType *form, Boolean clear) VM_SECT4; +static void Discover(FormType *form) VM_SECT4; +static Boolean AddName(const Char *name) VM_SECT4; +static void SetDefaultLabel(FormType *form, const Char *text) VM_SECT4; #define VM_SCOPES_PREFS_ID 4 #define VM_SCOPES_PREFS_VERSION 1 diff --git a/palm-client/src/scopes.h b/palm-client/src/scopes.h index 732afc6..14cdd0f 100644 --- a/palm-client/src/scopes.h +++ b/palm-client/src/scopes.h @@ -16,16 +16,16 @@ #define VM_SCOPE_NONE 1 /* unscoped (firmware v12+; older ones use the default) */ #define VM_SCOPE_NAMED 2 -void ScopesLoad(void) VM_SECT3; +void ScopesLoad(void) VM_SECT4; /* The channel in slot's choice; for VM_SCOPE_NAMED also its key. */ -UInt8 ScopesForChannel(UInt8 slot, UInt8 key[VM_SCOPE_KEY_SIZE]) VM_SECT3; +UInt8 ScopesForChannel(UInt8 slot, UInt8 key[VM_SCOPE_KEY_SIZE]) VM_SECT4; /* Options > Channel Scope: picks a scope for the channel on screen. */ -void ChannelScopeChooseCurrent(void) VM_SECT3; +void ChannelScopeChooseCurrent(void) VM_SECT4; /* Options > Flood Scopes: the list, and the radio's default. Done goes back to returnForm. */ -void ScopesFormOpen(UInt16 returnForm) VM_SECT3; -Boolean ScopesFormHandleEvent(EventType *event) VM_SECT3; +void ScopesFormOpen(UInt16 returnForm) VM_SECT4; +Boolean ScopesFormHandleEvent(EventType *event) VM_SECT4; #endif diff --git a/palm-client/src/sections.h b/palm-client/src/sections.h index aa883a8..056b1b6 100644 --- a/palm-client/src/sections.h +++ b/palm-client/src/sections.h @@ -1,6 +1,6 @@ /* * Code segments. The app's code is more than the ~32 KB one 68k code resource - * can reach, so modules also live in vmcode2 and vmcode3 (VM_SECT2/VM_SECT3; see + * can reach, so modules also live in vmcode2, vmcode3 and vmcode4 (VM_SECT2-4; see * visormesh.def; multigen makes the stub and linker script). Everything below * applies to any extra section. * @@ -33,9 +33,11 @@ #if defined(__palmos__) && !defined(__clang__) /* clang: the editor's checker, which rejects the section name */ #define VM_SECT2 __attribute__ ((section ("vmcode2"))) #define VM_SECT3 __attribute__ ((section ("vmcode3"))) +#define VM_SECT4 __attribute__ ((section ("vmcode4"))) #else #define VM_SECT2 #define VM_SECT3 +#define VM_SECT4 #endif #endif diff --git a/palm-client/tools/check_sections.py b/palm-client/tools/check_sections.py index 81a4934..37a04e1 100644 --- a/palm-client/tools/check_sections.py +++ b/palm-client/tools/check_sections.py @@ -16,7 +16,7 @@ import re import subprocess import sys -SECTIONS = ('vmcode2', 'vmcode3') +SECTIONS = ('vmcode2', 'vmcode3', 'vmcode4') OBJDUMP = 'm68k-palmos-objdump' diff --git a/palm-client/tools/sect2.py b/palm-client/tools/sect2.py index 08e5129..b6ffaf7 100644 --- a/palm-client/tools/sect2.py +++ b/palm-client/tools/sect2.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 """Puts a C file's static functions in an extra code segment: inserts a -'static VM_SECT2;' (or --sect3: VM_SECT3) forward declaration for +'static VM_SECT2;' (or --sect3 / --sect4: VM_SECT3 / VM_SECT4) forward declaration for each one after the last #include (see src/sections.h). Run once per file moved; idempotent.""" import re import sys -macro = 'VM_SECT3' if '--sect3' in sys.argv else 'VM_SECT2' +macro = 'VM_SECT4' if '--sect4' in sys.argv else 'VM_SECT3' if '--sect3' in sys.argv else 'VM_SECT2' for path in [a for a in sys.argv[1:] if not a.startswith('--')]: src = open(path).read() marker = '/* In an extra code segment (' + macro + '): see sections.h for the rules. */' diff --git a/palm-client/visormesh.def b/palm-client/visormesh.def index 1d83d24..15a41de 100644 --- a/palm-client/visormesh.def +++ b/palm-client/visormesh.def @@ -1,2 +1,2 @@ application { "VisorMesh" VMsh backup } -multiple code { "vmcode2" "vmcode3" } +multiple code { "vmcode2" "vmcode3" "vmcode4" }