Status (2026-09-30): mostly done, not all as planned. The C loader (
src/menu_load_json.c,SWOS_MENU_JSON, default-on) is live and verifies 47/47 byte-identical. The "flip" happened as a build-time bake, not by deletingmenu_data.c:scripts/emit_menus.pyregeneratessrc/menu_data.cfrombin/data_json/menus/*.jsonat build (docs/DATA_PIPELINE.md), and the Amiga compiles that C. The 76 scaffolding structs are still ininclude/menu_data.h(§1d's model structs were not added); there is nomenu_json_to_bin.py,menu_reloc.corimport_dos_menus.py. The DOS-menu import (§6) was done for SWOS 2020's online menus instead —scripts/import_swos2020_menus.py, §10. §§0-9 below are the original plan, kept as the record; §10 is current.
Original status: PLAN + early implementation. The bootstrap exporter
(scripts/export_menus.py → bin/data_json/menus/*.json, all 47 menus) and the
name→address symbol registry (scripts/gen_menu_symbols.py →
src/menu_symbols.{c,h}, 663 symbols, compiles clean) are DONE (migration
steps 1–2, §8). The C loader, Python json→bin, and DOS import remain. This
document answers the six menu tasks:
- Consolidate the
menu_data.cstruct families into the fewest possible structs (the same exercise asdocs/STRUCT_CONSOLIDATE.mddid for competitions). - JSON-ify the menu data and write a C loader.
- A Python
json → binaryemitter producing the packed menu format the Amiga build keeps consuming. - (no task 4)
- Reference: how
sws_menu.amiga.pyturns the Amiga asm into structured data, and what it tells us about the format. - The DOS menu-data differences (from
sws_menu_x86.idc). - Importing the DOS menus (
swos-2020/src/menus/*.mnu) into our JSON.
Our JSON menu files live in bin/data_json/menus/ (one file per menu, e.g.
bin/data_json/menus/swosMainMenu.json), mirroring the existing
bin/data_json/{teams,competitions}/ corpus (see docs/DATA_JSON.md).
Imported DOS menus (Task 7) land in the bin/data_json/menus/dos/
subfolder, kept separate from our own (Amiga-derived) menus so the two sets
never collide and the import can be re-run without clobbering hand-tuned files.
Sources read for this plan:
src/menu_data.c(9886 lines, 47 menu instances) +include/menu_data.h(3477 lines, the generated structs).src/menu_system.c_UnpackMenu/_ActivateMenu— the runtime parser (the format's ground truth) — andinclude/menu_system.h(Menu,MenuEntry).C:\Projects\Amiga\SWOS-RE\IDAPro\Scripts\sws_menu.amiga.py(Amiga menu beautifier) and…\sws_menu_x86.idc(DOS beautifier).C:\Projects\GitHub\swos-2020\src\menus\*.mnu(104 DOS-side menu files in a DSL) + the…\swos-2020\mnu2h\Python compiler (Parser.py,CodeGenerator.py,Constants.py, …) andsrc\menus\menuCodes.h.
Every representation in this document (the C structs, the JSON, the Amiga
binary, the DOS data, the swos-2020 DSL) is a different spelling of one
packed byte-stream. That stream is defined by the runtime parser
UnpackMenu(packed, dest) in src/menu_system.c (was _UnpackMenu), which walks packed
and builds the runtime Menu header + a fixed-stride MenuEntry[] array.
Get this section right and the rest is mechanical.
| bytes | field | notes |
|---|---|---|
| ptr | onInit |
function pointer or 0 |
| ptr | onReturn |
function pointer or 0 (becomes Menu.afterDraw) |
| ptr | onDraw |
function pointer or 0 |
| u32 | defaultEntry |
initially-selected entry ordinal (NOT a pointer; resolved later) |
ptr width is target-specific: 4 bytes on Amiga (BE) and DOS (LE), 8
bytes on the SDL 64-bit build. _UnpackMenu reads the header through a typed
PackedHdr and pointers through unpackReadPtr() (memcpy of
sizeof(uintptr_t)), so the static C data uses native pointer width on every
target. Only defaultEntry is fixed at u32.
OpenSWOS extension — the flags word. An optional 0xFC18, u16 flags pair may
follow the header directly; UnpackMenu looks for it only there (where the stream is
in wide-coords mode, so it would otherwise be an entry at x = -1000). Bit 0,
MENU_FLAG_DOS_REDRAW, gives the menu the DOS MenuProc: redraw the whole menu,
onDraw included, every frame. JSON: "menu_flags": {"dos_redraw": true}. No compiled
menu has it. See §10.
After the header comes a stream of markers and entries. A marker is a leading control word; an entry is coords + a command list.
| marker word | name | payload | effect |
|---|---|---|---|
0xFC19 (-999) |
end menu | – | stop |
0xFC1A (-998) |
start menu / set origin | i16 menuX, i16 menuY |
set menuX/menuY added to subsequent entry coords (begins a positioning sub-block) |
0xFC1B (-997) |
start template | (an entry) | parse the next entry into the shared template instead of emitting it; restored on its end |
0xFC1C (-996) |
reset template | – | re-init template to defaults |
0xFFFE |
wide coords | – | subsequent entry coords are i16 x,y,w,h (default) |
0xFFFF |
byte coords | – | subsequent entry coords are i8 x,y,w,h (compact); mode persists until flipped |
Any word that isn't a marker begins an entry:
- Coords —
x,y,w,h, eachi16(wide) ori8(byte) per the current coords mode._UnpackMenustoresx += 24 + menuX,y += 36 + menuY(24/36are the Amiga menu-panel offsets — a runtime detail, not part of the on-disk numbers). - Command list — a sequence of
u16 opcoderecords, terminated by opcode0. Opcodes (verbatim from_UnpackMenucases 0–22):
| op | name | extra bytes | sets on MenuEntry |
|---|---|---|---|
| 0 | end entry | – | finalize entry, ordinal++ |
| 1 | invisible | – | isInvisible=1 |
| 2 | nav | i8 left,right,up,down |
nav links |
| 3 | bg func | ptr |
background=FUNC1, bg=ptr |
| 4 | colors | u16 |
background=COLOR, bgColor=word |
| 5 | bg sprite | u16 |
background=SPRITE1, bgColor=idx |
| 6 | invalid | u16 |
background=4, bgColor=word |
| 7 | fg func | ptr |
content=FUNC2, fg=ptr |
| 8 | string | u16 flags, ptr |
content=STRING, stringFlags, fg=ptr (ptr 1..255 ⇒ deferred 0xFFFFFFFF) |
| 9 | fg sprite | u16 |
content=SPRITE2, fgSpriteIdx=idx |
| 10 | string table | u16 flags, ptr |
content=STRING_TABLE, fg=ptr |
| 11 | multi-line text | u16 flags, ptr |
content=MULTI_LINE_TEXT, fg=ptr |
| 12 | number | u16 flags, u16 value |
content=NUMBER, fgNumber=value |
| 13 | onSelect (fire) | ptr |
controlMask=0x20, onSelect=ptr |
| 14 | input func | u16 mask, ptr |
controlMask=mask, onSelect=ptr |
| 15 | before draw | ptr |
beforeDraw=ptr |
| 16 | after draw | ptr |
afterDrawCb=ptr |
| 17–20 | left/right/up/down skip | u8 skip, u8 dir |
skip + direction bytes |
| 21 | sprite copy | ptr |
content=SPRITE_COPY, fg=ptr |
| 22 | string-no-ptr | u16 flags |
content=STRING, fg=0xFFFFFFFF (deferred) — Amiga only, see §6 |
The same opcode names appear three times in the codebase, all consistent:
menu_data.h (MENU_CMD_* enum + MenuCmd_* structs), the IDA scripts (type N comments), and _UnpackMenu (the switch). The IDA scripts (§5/§6) are the
canonical English description of each opcode's bytes.
Opcodes 3, 7, 8, 10, 11, 13, 14, 15, 16, 21 and the three header slots all carry
a raw pointer to a function, a string, a string-table, or a sprite-copy
struct. In menu_data.c these are C symbols the linker resolves
(_CareerMenuInit, aOptions, &gameLengthStrTable, &editTeamsPrimaryShirts,
managerNameBuffer, …). This is the menu equivalent of the save format's
"pointer-to-disk" problem (CLAUDE.md): a serialized menu must store a
symbolic identity (the name), never an address, and re-resolve it on load.
Exact distinct-symbol counts (from the generated registry, §2c — 663 total):
- 385 callback functions (the
extern void _Xxx(void);block at the top ofmenu_data.cplus its ~18 locally-defined stub callbacks). - 185 string symbols (
aOptions,aEditTactics, …). - 73 string tables (
gameLengthStrTable,diyCupLegsStringTable0, …). - 6 sprite-copy structs (
editTeamsPrimaryShirts, …). - 14 writable / runtime buffers (
managerNameBuffer,saveFileTitle,teamTacticsUSERA..F, the cast-marked(char*)/dotted refs likediyCompetitionStart.base.competitionName).
§2/§3 turn these into a single symbol registry shared by both ports.
menu_data.h defines, exactly as IDA emitted them:
- 16
MenuCmd_*structs — one per opcode payload (MenuCmd_Colors,MenuCmd_TextPtr,MenuCmd_Nav,MenuCmd_Number,MenuCmd_StringTable,MenuCmd_SpriteFg,MenuCmd_InputFunc,MenuCmd_BeforeDraw,MenuCmd_AfterDraw,MenuCmd_SpriteCopy,MenuCmd_FgFunc,MenuCmd_BgFunc,MenuCmd_OnSelect,MenuCmd_Skip2,MenuCmd_Invisible,MenuCmd_TextNoPtr) plusMenuCoords8/16,MenuHeader,MenuMark_StartMenu. These are the genuine, minimal building blocks — keep them (they are the canonical encoding of each opcode). - 25
MenuEntry_*"shape" structs — one per combination of commands an entry happens to use:MenuEntry_Byte_ColorsOnly,MenuEntry_Byte_Nav_Colors_TextPtr_OnSelect,MenuEntry_Wide_NumberOnly,MenuEntry_Byte_Invisible_NavOnly, … (15Byte-coords + 10Wide-coords). Each is justMenuCoords{8,16}+ the subset ofMenuCmd_*it uses +u16 end. - 51
Menu_*structs — 47 per-menu (Menu_SWOSMainMenu,Menu_Options,Menu_Career,Menu_EditTeams, …) + 4 reusable sub-blocks (Menu_DesignDIYCup_OptionRow,Menu_DIYCup_StatsBlock,Menu_DesignDiyTournament_StageBlockA/B). Each isMenuHeader+ a hand-laid concatenation of markers andMenuEntry_*/ inline-MenuCmd_*fields.
These exist for the exact same reason the competition variants did
(STRUCT_CONSOLIDATE.md §intro): IDA can't resize a struct in place, so every
menu and every entry-shape got its own type so the bytes after it stay put.
For the competitions, the merged structs had to survive because game code reads
their fields by name (comp->teamSeedList[i], divisionsCount, …). Menus are
different and much easier:
Nothing in the codebase does typed field access into a
Menu_*orMenuEntry_*struct. Every menu instance is consumed as raw bytes: the definition isMenu_Foo fooMenu = {…}, but every reader declares itextern uint8_t fooMenu[]and passes it to_ActivateMenu(uint8_t*)/_ShowMenu(uint8_t*), which hand it to_UnpackMenu(the opcode walker in §0). A grep forMenu_[A-Z]…*/(Menu_[A-Z]casts or.entryN.field reads outsidemenu_data.hreturns zero hits.
So the 25 MenuEntry_* + 47 Menu_* + 4 sub-block structs (76 types) are
write-only at compile time — they exist only to lay the bytes down in the
right order, then are immediately type-erased to uint8_t*. They are the
direct analogue of the competition *_TEXT/*_ROUNDS EQU symbols that
STRUCT_CONSOLIDATE.md §2a found were "pure layout documentation… zero hits
outside the EQU definitions themselves." They can be deleted outright.
Same question STRUCT_CONSOLIDATE.md §2 asked. Answer for menus:
- Within an entry: the command list is an opcode-tagged stream terminated
by opcode
0(_UnpackMenucase 0). No fixed stride — each opcode knows its own payload width. Self-describing. - Across entries: entries are walked until the
0xFC19end-menu marker;_UnpackMenunever steps "entry N+1 = entry N + sizeof(shape)". The shape structs' sizes are never read by anything. - Coords width is a mode flag (
0xFFFF/0xFFFE), not encoded per entry.
⇒ Exactly like the competitions: no fixed-size record stepping anywhere. Consolidation is safe, and here it's total — we can discard the per-shape and per-menu structs entirely rather than merge-to-max.
Replace the 76 layout structs with a small, generic, authoring model. Keep the
16 MenuCmd_* building blocks as the canonical opcode encodings; add three
model structs that describe a menu the way the JSON and the emitters think about
it:
/* One tagged command (replaces all 25 MenuEntry_* shape combos). */
typedef struct {
uint16_t opcode; /* MENU_CMD_* (0..22) */
/* exactly one of the following is meaningful, per opcode (see §0b table) */
uint16_t flags; /* string/number flags or control mask */
int32_t ints[4]; /* nav bytes / number / sprite idx / color / skip+dir */
int32_t symbol; /* index into the symbol registry (§2c), or -1 */
} MenuCommandModel;
/* One entry (coords + its command list). */
typedef struct {
int16_t x, y, w, h;
uint8_t byteCoords; /* emit i8 vs i16 coords */
uint16_t numCommands;
MenuCommandModel commands[MENU_MAX_CMDS_PER_ENTRY];
} MenuEntryModel;
/* One menu (header + ordered entries/markers). */
typedef struct {
int32_t onInit, onReturn, onDraw; /* symbol registry indices, or -1 */
uint16_t defaultEntry;
uint16_t numItems;
MenuItemModel items[MENU_MAX_ITEMS]; /* entry | set-origin | start/reset-template */
} MenuModel;This is the source of truth at authoring time (and what the JSON
deserializes into). It is not what _UnpackMenu reads — that stays the packed
byte-stream of §0. The C loader (§2d) and Python emitter (§3) both turn a
MenuModel into that byte-stream. So:
menu_data.h: drop the 25MenuEntry_*and 51Menu_*typedefs; keep theMENU_CMD_*/MENU_MARK_*enums, the 16MenuCmd_*structs (still handy for the emitters), and add the 3 model structs above.menu_data.c: the 47 hand-writtenMenu_Foo foo = {…}initializers go away entirely — the menus now come frombin/data_json/menus/*.json. The bigextern void _Xxx(void);block migrates into the symbol registry (§2c).
- The
extern uint8_t fooMenu[]decls at the ~30 call sites (_ShowMenu(contestMenu)etc., inmenus.c,career_init.c,edit_tactics.c,diy_competition.c,chairman_memo.c,game_init.c,file_io.c) must resolve to the loaded packed buffer for that menu, not a static symbol. Provide auint8_t *menu_by_name("contestMenu")(or keep thecontestMenusymbol as a pointer the loader fills at init). Lowest-churn option: at startup, the loader builds every menu's packed buffer and assigns the legacycontestMenu/swosMainMenu/… symbols (nowuint8_t *) to point at them — call sites stay byte-for-byte the same. menu_system.c:160-177already maps the legacy symbols to names for diagnostics; that table becomes the seed formenu_by_name.- Sub-block reuse (
Menu_DIYCup_StatsBlock×6,Menu_DesignDIYCup_OptionRow×6, tournament stage blocks) is just repetition in the byte-stream — the JSON expresses it with arepeat/array, the emitter unrolls it. No struct needed.
Per CLAUDE.md "Save/load is typed JSON of NAMED fields" and docs/DATA_JSON.md:
named fields, no addresses, no raw dumps, pointers as semantic identities.
For menus that means: opcodes by name, coords as numbers, and every pointer as a
symbol name string. The format must survive 32↔64-bit and LE↔BE unchanged
(the Amiga emitter and the SDL loader read the same JSON).
Conventions:
opis the lowercase opcode name (nav,colors,text,text_no_ptr,string_table,multiline,number,sprite_fg,sprite_bg,sprite_copy,bg_func,fg_func,onselect_fire,input_func,before_draw,after_draw,invisible,left_skip/right_skip/…). The end marker (0) is implicit — it's the close of thecommandsarray.- Pointers (
func,str,table,sprite_copy) are symbol-name strings, resolved via the registry (§2c). A deferred/dynamic string is"text_no_ptr"(Amiga) — see §6 — the loader maps it to the0xFFFFFFFFsentinel regardless of target. - Markers are
itemsofkindset_origin/coords_mode/start_template/reset_template/end, interleaved withkind: "entry". - Templates become
"kind": "start_template"followed by the template entry;reset_templateclears it. (Authoring nicety: the importer in §7 can fold a template + N near-identical entries into a"repeat"block; the loader expands it.)
A single generated table maps every menu-referenced name to its address/value, the menu analogue of the save format's identity re-derivation:
/* src/menu_symbols.c (generated; ~620 rows) */
typedef struct { const char *name; void *ptr; uint8_t kind; } MenuSymbol;
const MenuSymbol menuSymbols[] = {
{ "_SWOSMainMenuInit", _SWOSMainMenuInit, SYM_FUNC },
{ "_EditTacticsMenu", _EditTacticsMenu, SYM_FUNC },
{ "aEditTactics", aEditTactics, SYM_STRING },
{ "gameLengthStrTable", &gameLengthStrTable, SYM_TABLE },
{ "editTeamsPrimaryShirts", &editTeamsPrimaryShirts, SYM_SPRITE_COPY },
{ "managerNameBuffer", managerNameBuffer, SYM_BUFFER },
/* … */
};- It is generated, not hand-maintained: a script scans the current
menu_data.c(theexternblock + every symbol that appears as afunc/str/table/sprite_copy/buffer in an initializer) and emits both this.cand theexterndecls. (This is also exactly the set the bootstrap exporter in §7a needs.) menu_resolve(name)is absearch(table sorted by name) returning the pointer; the loader caches a per-menuint32 symbol-index → ptrmap so each JSON name is hashed once.- Both ports keep this table. It is the only place that knows name→address; everything else is layout-free. This satisfies the "no addresses in the serialized form" rule — the addresses live in compiled code, the JSON/binary carry names/indices.
src/menu_load_json.c, modeled on save_format_json.c (uses the in-tree
src/mjson.c):
- At startup, for each
bin/data_json/menus/*.json:mjson_findthe top object, read header symbols via the registry, thenmjson_next-walkitems. - Build the packed byte-stream of §0 directly into a per-menu buffer
(header with native-width pointers resolved through the registry, then the
marker/entry/opcode bytes). Endianness is host-native here (the SDL build
reads its own freshly-built buffer), but all multi-byte writes go through
src/endian_helpers.hso the code is back-port-clean. - Assign the legacy
uint8_t *fooMenusymbols to point at their buffers (§1e), so_ActivateMenu(fooMenu)keeps working unchanged._UnpackMenuthen runs exactly as today.
Why build the packed stream rather than fill Menu/MenuEntry[] directly:
_UnpackMenu already implements every subtlety (template apply/restore, coords
mode persistence, menuX/menuY, deferred-string fixups, the +24/+36 offsets,
ordinal numbering). Reusing it means the JSON path can't drift from the asm
path. The loader's only job is JSON → §0 bytes.
A SWOS_MENU_JSON=1 build flag selects the JSON loader; without it the legacy
static menu_data.c still compiles, so the migration is incremental and
verifiable menu-by-menu (round-trip a menu, diff its packed bytes vs the static
struct's bytes — a zero-diff is the green light, same discipline as
SWOS_SAVE_FORMAT_JSON_VERIFY).
STATUS (2026-06-20): C loader + verify DONE.
src/menu_load_json.c(MenuJson_BuildPacked+MenuJson_VerifyAll) builds the §0 packed stream for every menu andmemcmps it against the compiled static bytes. Gated on envSWOS_MENU_JSON(matching theSWOS_DATA_JSONprecedent, not a compile flag) and wired into_FrontEndPreLoopSetup. Result: 47/47 menus byte-identical, 0 diff. Two corpus subtleties that the round-trip flushed out and the loader now handles: (1) the skip opcodes areUP/DOWN/LEFT/RIGHT = 0x11/0x12/0x13/0x14(the §0b "left/right/up/down" ordering above is misleading — trust theMENU_CMD_*enum); (2) atext/string_table/multilinepointer field may be a SYMBOL name, a literal INTEGER deferred-string sentinel ("str": 4→ fg0xFFFFFFFF), ornull. This is the green light to repoint the legacyuint8_t fooMenu[]call sites at the loaded buffers (§1e) and retire the staticmenu_data.cinitializers.
The Amiga build "continues to use the binary format" = the packed §0
byte-stream that _UnpackMenu reads. We generate it from JSON at build time
instead of hand-writing menu_data.c.
Reads bin/data_json/menus/*.json and emits, per menu, the §0 byte-stream with
Amiga conventions:
- Big-endian multi-byte fields (use the same byte order the existing
.TAC/team-file tooling uses; mirrorendian_helpers.hsemantics). - 4-byte pointers.
- Markers / opcodes / coords exactly per §0.
But a .bin can't bake absolute addresses (only the linker knows them). Two
supported outputs — pick per build need:
- Relocatable blob + symbol table (recommended, true "binary format").
Every pointer slot is written as a u32 index into
menuSymbols(§2c) plus a per-menu relocation list ([offset, symbolIndex]). A tiny Amiga loader (menu_reloc.c, shared with SDL) walks the relocation list at startup and patches each slot withmenuSymbols[idx].ptr. This keeps the on-disk form address-free and identical across targets — only the patch step is per-target. This is the menu analogue of the JSON loader: names→addresses resolved at load, never stored. - Generated C array (fallback / lowest-risk). Emit
menu_data_gen.ccontainingconst uint8_t swosMainMenu_packed[] = { … };with the pointer slots written as the C symbols themselves ((uintptr_t)_SWOSMainMenuInit,(uintptr_t)aOptions, …) via a small#define-free initializer, letting the linker do relocation the way it does today. No runtime patching; the Amiga keeps its current "menus are compiled-in" model, just generated from JSON rather than hand-written.
Both consume the same JSON and the same menuSymbols name set, so they can't
disagree on content. Start with (2) to de-risk (byte-identical to today's
compiled menus → provable), then move to (1) when the relocation loader is
trusted.
Round-trip discipline like docs/DATA_JSON.md: menu_data.c (struct bytes) → JSON → bin → bytes must be 0-diff against the bytes the current
Menu_Foo foo = {…} produces (with pointer slots compared by symbol, not
address). A green round-trip on all 47 menus is the signal the static
menu_data.c can be retired (roadmap step 3/4 for menus).
sws_menu.amiga.py (IDAPython, Ben Baker 2025; port of Zlatko Karakaš's IDC) is
a read-only beautifier: pointed at a menu label it walks the bytes and
annotates IDA with comments — it never renames or restructures. Its main() is
a direct, executable spec of §0 and was the primary cross-check for this
document:
- Header: 3 dwords (on-init / on-return / on-draw, made offsets if non-zero) + 1 dword default entry.
- Then the marker loop:
64537→end,64538→start-menu(+x,+y),64539→template (with the wide/byte-coords sub-handling),64540→init-entry,65534/65535→wide/byte coords. - Per entry: coords (byte or word per
byte_coordsstate) then the opcode loopt == 0..22, with helper annotatorswrite_colors(opcode 4),write_str_flags(opcodes 8/10/11/12/22),write_ctrl_flags(opcode 14).
Two things to lift directly into our tooling:
write_str_flags/write_colors/write_ctrl_flagsdecode the flag words into human strings (text color/font/alignment; background+frame colors; control-mask bit names). Port these into the JSON exporter so the JSON can carry readable flags (e.g."flags": "big|left|white") with the raw hex as a fallback — a big editability win, and they're already written and tested.- The script's
byte_coordshandling and type 22 branch are what make it the Amiga reader (vs the DOS one) — see §6.
This script operates on the original Amiga binary; our menu_data.c is the C
port of that same data, so the script is the authority when our struct layout
and the asm disagree.
sws_menu_x86.idc is the older DOS/x86 beautifier (Zlatko Karakaš, 2002–2021)
and the Amiga .py is a port of it. Diffing the two pins down exactly how the
DOS menu data differs from the Amiga's. All differences are additive on the
Amiga side — the DOS format is a strict subset.
| aspect | DOS (sws_menu_x86.idc) |
Amiga (sws_menu.amiga.py) |
|---|---|---|
| Coords width | Always 16-bit (word). No byte-coords path at all — there is no 65534/65535 handling; every entry reads x,y,w,h as 4 words. |
Adds a byte-coords mode (0xFFFF=byte, 0xFFFE=wide), persisting until flipped, to shrink entries. |
Template (-997) |
Reads x,y,w,h as 4 words inline (advances 10 bytes), always wide. |
Reads the wide/byte-coords marker first, then x,y,w,h as bytes or words. |
| Opcode 22 | Does not exist. Deferred/dynamic text is opcode 8 with pointer 0xFFFFFFFF (the IDC explicitly labels Dword == 0xFFFFFFFF as "STDMENUTEXT - gets filled later"). |
Adds opcode 22 (text_no_ptr, str-flags only, no pointer word) as the compact deferred-text encoding; _UnpackMenu case 22 sets fg=0xFFFFFFFF — same runtime effect, 4 bytes smaller. |
| Pointer endianness | Little-endian 32-bit. | Big-endian 32-bit. |
| Everything else | Header (3 fn-ptrs + default entry), markers -999/-998/-997/-996, opcodes 0–21, the flag-word meanings (write_colors/write_str_flags/write_ctrl_flags are byte-identical between the two scripts). |
Same. |
Consequences for our format:
- The JSON is a superset that covers both: it carries
coords.wide(DOS=always true) and usesop: "text_no_ptr"for deferred text. When the Python emitter targets DOS-compatible output it would (a) force wide coords and (b) lowertext_no_ptr→textwith a0xFFFFFFFFpointer + LE byte order. For our Amiga/SDL targets it keeps byte-coords and opcode 22 + BE. - Because DOS is a subset, a DOS menu imported to JSON (§7) always round-trips to the Amiga binary; the reverse (Amiga→DOS) only round-trips if the menu used no byte-coords and no opcode 22 (the emitter can re-encode both, so it always can in practice, just larger).
The DOS menus live as a text DSL in C:\Projects\GitHub\swos-2020\src\menus\
(104 .mnu files) and are compiled to the binary menu format by the Python
toolchain in …\swos-2020\mnu2h\ (Parser.py, Tokenizer.py,
Preprocessor.py, CodeGenerator.py, Constants.py, Menu.py, Entry.py).
CodeGenerator.py currently emits C++ structs (from menuCodes.h:
MenuHeader + a stream of EntryElement subclasses with the same opcode enum
kEndOfEntry…kColorConvertedSprite = 0..21). We want JSON instead.
Menu mainMenu {
y: 1
onInit: ~SWOSMainMenuInit // ~name = function pointer
onReturn: ~SWOSMainMenuOnReturn
initialEntry: competition // entry name → ordinal
kButtonWidth = 148 // menu-scoped constant
defaultX: kColumn1X // default* → template mechanism
defaultY: @prevEndY + 6 // @name = built-in / relative layout
defaultTextFlags: @kBigText
Entry competition {
y: kStartY
color: @kDarkBlue
downEntry: practice // entry-ref nav (name | ordinal | < | >)
rightEntry: options
text: "COMPETE"
onSelect: ~"SWOS::competitionMainMenu_onSelect" // ~"ns::fn" raw
}
…
}
DSL → opcode mapping (from Constants.py + menuCodes.h):
| DSL property | binary | our JSON |
|---|---|---|
onInit/onReturn/onDraw |
header ptrs | header func names |
initialEntry |
header defaultEntry |
defaultEntry (ordinal) |
x/y/width/height |
entry coords | coords |
color |
op 4 | colors |
text:"…" / text:~sym |
op 8 | text (inline literal → string pool, see 6c) |
number |
op 12 | number |
sprite |
op 9 | sprite_fg |
stringTable:[…] |
op 10 | string_table |
customDrawForeground |
op 7 | fg_func |
customDrawBackground |
op 3 | bg_func |
invisible:true |
op 1 | invisible |
up/down/left/rightEntry |
op 2 (positions) | nav |
skipUp/Down/Left/Right + directionX |
ops 17–20 | *_skip |
onSelect (+controlsMask) |
op 13 / 14 | onselect_fire / input_func |
beforeDraw |
op 15 | before_draw |
onReturn (entry) |
op 16 | after_draw |
(kColorConvertedSprite) |
op 21 | sprite_copy |
Symbol/operator syntax to resolve when importing: ~name and ~"ns::name" =
function pointers; @name = built-in constants (@kDarkBlue, @kBigText,
@kCenterAligned, …) and relative-layout tokens (@prevEndY, @prevX,
@kScreenHeight, …); bare k-names = menu-scoped constants; quoted text =
inline string literal; arithmetic expressions are evaluated by the
preprocessor. Templates: default* properties + TemplateEntry/ResetTemplate
map to the -997/-996 markers and auto-layout (@prevEndY) resolves to
concrete coords at compile time.
The cleanest importer doesn't re-implement the DSL: it reuses
swos-2020/mnu2h/ as a library (it already tokenizes, preprocesses, evaluates
expressions, resolves @/~/k symbols, applies templates, and resolves nav
names→ordinals) and swaps CodeGenerator.py for a JSON emitter that walks
the same Menu/Entry objects (Menu.py/Entry.py) and writes our §2b schema:
scripts/import_dos_menus.py (imports mnu2h as a package)
for each *.mnu:
ast = mnu2h.Parser(...).parse() # existing
model = mnu2h.lower(ast) # existing: Menu + Entry objects,
# constants expanded, navs→ordinals,
# templates/@prevEndY resolved
write_json(model, bin/data_json/menus/dos/<name>.json) # NEW backend
This sidesteps re-writing 100 KB of mature parser/preprocessor code and
guarantees the import matches what swos-2020 actually compiles. Where DSL
constructs have no opcode equivalent (DOS-only @k… symbols, multiplayer-only
menus), the emitter records them and the run logs them — don't silently drop
(per CLAUDE.md's "no silent caps").
- It's a modern superset, not pure DOS. Of the 104 files many are
swos-2020-only (
leaderboard,matchMaking,scenario*,customChallenges*,logIn,ticker, multiplayer lobbies) and several are backups (*_bak,*-old,*_WIP, date-stamped). Import is most useful for the menus that overlap our port (main,options,audioOptions,controlOptions,competition,editing,extras,credits,message, …). Filter to a curated allow-list; log the skipped ones. - Inline string literals (
text: "COMPETE") have no symbol name. The importer interns them into a per-menu string pool and the JSON references the pool key (the loader/emitter materializes the bytes). This is the one place menus carry literal text rather than a symbol — keep it explicit in the schema ({"op":"text","literal":"COMPETE"}vs{"op":"text","str":"aOptions"}). - Function names won't match ours. swos-2020 uses
SWOS::competitionMainMenu_ onSelect; our port uses_CompetitionMenuetc. Importing is a starting point for layout/coords/flags; thefunc/strsymbols need a name-mapping pass (or are left as TODO markers the registry flags as unresolved). The DOS data's value to us is the geometry and structure, not the (different) C symbols. - menuMouse (
menuMouse.cpp/.h) is DOS-only mouse hit-testing layered over the same entry coords — no new menu-data fields, nothing to import.
As planned. What exists today:
bin/data_json/menus/*.json,src/menu_symbols.c(+include/menu_symbols.h),src/menu_load_json.c,scripts/export_menus.py, andscripts/emit_menus.py(JSON →menu_data.c, in place ofmenu_json_to_bin.py).menus/dos/,menu_reloc.c,menu_json_to_bin.pyandimport_dos_menus.pywere never made; imported menus live inmenus/swos2020/(§10).menu_data.hlives ininclude/and still has its scaffolding structs.
| path | role |
|---|---|
bin/data_json/menus/*.json |
the menu corpus (one file per menu) — authoring source of truth |
bin/data_json/menus/dos/*.json |
imported DOS menus (Task 7), kept separate from our own |
src/menu_data.h |
trimmed: keep MENU_CMD_*/MENU_MARK_* enums + 16 MenuCmd_* + the 3 model structs (§1d); drop the 76 scaffolding structs |
src/menu_data.c |
retired once JSON load is proven (its 47 initializers move to JSON) |
src/menu_symbols.c (+.h) |
generated name→address registry (§2c), kept on both ports |
src/menu_load_json.c |
SDL C loader: JSON → §0 packed buffer → legacy fooMenu ptr (§2d) |
src/menu_reloc.c |
shared relocation patcher for the Amiga blob path (§3a-1) |
src/menu_system.c |
unchanged — _UnpackMenu still reads §0 bytes |
scripts/export_menus.py |
bootstrap: parse current menu_data.c initializers → JSON + the symbol list (§7a) |
scripts/menu_json_to_bin.py |
JSON → Amiga binary / generated C (§3) |
scripts/import_dos_menus.py |
swos-2020 .mnu → JSON in menus/dos/, reusing mnu2h/ (§6b) |
Don't hand-write 47 JSON files. Write scripts/export_menus.py to parse the
existing menu_data.c initializers (they're regular, brace-nested
{ MENU_CMD_*, … } lists) and emit both the JSON corpus and the
menuSymbols name set. This is the menu analogue of
scripts/export_competitions.py and the decode_data.py --dump-json exporter.
Cross-check each exported menu by feeding its JSON back through the C loader and
diffing the packed bytes against the static struct (§2d/§3b).
- ✅ DONE — Symbol registry (
scripts/gen_menu_symbols.py→src/menu_symbols.{c,h}, 663 symbols: 385 func / 185 string / 73 table / 6 sprite-copy / 14 buffer). Pure addition, compiles clean against the project flags; givesmenu_resolve(name)and the name set everything else needs. (Re-run it whenever_symbols.jsonchanges.) - ✅ DONE — Bootstrap export (
scripts/export_menus.py) →bin/data_json/menus/*.jsonfor all 47 menus +_symbols.json. No code-path change yet. - ✅ DONE — C loader behind
SWOS_MENU_JSON(§2d; see the 2026-06-20 status note there). Now default-on (SWOS_MENU_JSON=0disables). - ✅ DONE, differently — the flip.
SWOS_MENU_JSONis default-on, andmenu_data.cis generated from the JSON byscripts/emit_menus.pyrather than deleted; the 76 scaffolding structs stay (the emitter needs them as the brace template —docs/DATA_PIPELINE.md, "Menu structural edits need a type change"). - ✅ DONE as the generated-C route (§3a-2) —
emit_menus.pybakes JSON →menu_data.c, which both targets compile from the one tree (merged 2026-08-12; nothing to back-port). The relocatable blob (§3a-1) was not built. - ✅ DONE for SWOS 2020's online menus —
scripts/import_swos2020_menus.py(§10), notimport_dos_menus.py.
Each step round-trips and, where it touches the packed bytes, builds all three
Linux arches (memory project_target_strategy) and the Amiga target.
- Consolidate (Task 1): the 25
MenuEntry_*+ 51Menu_*structs are pure compile-time layout scaffolding — nothing reads their fields; every menu is type-erased touint8_t*and walked by_UnpackMenu. So they don't need merging (the competition fix), they can be deleted in favor of 3 generic model structs + the 16 existingMenuCmd_*opcode encodings. No fixed-stride record stepping exists anywhere → safe. - JSON + C loader (Task 2): one file per menu in
bin/data_json/menus/, opcodes by name, all pointers as symbol-name strings resolved through a generated symbol registry (menu_symbols.c) — the menu cure for the "pointer-to-disk" disease. The loader builds the §0 packed bytes and reuses_UnpackMenuunchanged. - Python
json→bin(Task 3): emits the §0 byte-stream with Amiga (BE, 4-byte-ptr) conventions; pointers as relocations against the same registry (or a generated C file as the de-risking fallback). Verified by 0-diff round-trip. - Amiga reference (Task 5):
sws_menu.amiga.pyis the executable spec of §0; lift itswrite_str_flags/write_colors/write_ctrl_flagsdecoders into the exporter for human-readable flags. - DOS differences (Task 6): DOS is a strict subset — no byte-coords, no
opcode 22 (deferred text = opcode 8 +
0xFFFFFFFF), LE pointers. Our JSON is the superset; the emitter lowers to either dialect. - DOS import (Task 7): reuse the existing
swos-2020/mnu2h/parser as a library and swap in a JSON backend; mind that the corpus is a modern superset with different C symbol names — import for geometry/structure, remap callbacks.
OpenSWOS continues SWOS 2020, and SWOS 2020's online play — login, matchmaking,
lobby, rankings, leagues, match logs — is built out of menus. Rather than redraw them,
they are imported from C:\Projects\GitHub\swos-2020\src\menus\*.mnu and run as they
are, with their handlers ported to C as the features behind them arrive. This is the
§6 plan, done for the online menus. Netplay itself: docs/NETPLAY.md.
scripts/import_swos2020_menus.py imports swos-2020/mnu2h as a library, lets its
Parser digest each .mnu exactly as the SWOS 2020 build does (includes, #repeat,
#join, expressions, delayed defaults, forward entry references), and replaces its
C++ CodeGenerator with a JSON backend.
| Output | |
|---|---|
bin/data_json/menus/swos2020/<menu>.json |
one per menu, loaded at run time |
include/swos2020_menus.h |
entry ordinals (LogInMenu::header -> LogInMenu_header), exported constants (MatchMakingMenu_kGS_MaxRows), SWOS2020_MENUS(X), SWOS2020_MENU_CALLBACKS(X) |
The default set is MULTIPLAYER_MENUS in the script: 30 menus (the 29 online ones and
selectUniform since the UNIFORM button, docs/UNIFORM.md), 1360 entries, 258 handler
names. (credits was imported for the CREDITS button from 8082369 until 2026-10-18, when
the screen became OpenSWOS's own openswos/creditsMenu.) Before selectUniform it was
30 menus, 1352 entries, 233 handler names, from
swos-2020 @ ebf1cc4 (the header's Source: line says which commit; the first import was
29 menus / 1321 entries / 220 names @ 22b96d3). Re-run with
python3 scripts/import_swos2020_menus.py [--swos2020 DIR] [menu ...]. It overwrites
the JSON — edit the .mnu in swos-2020, or stop re-importing that menu.
The files live in a subfolder on purpose: MENU_JSON in the Makefile is
bin/data_json/menus/*.json, and every file there is spliced into menu_data.c.
| SWOS 2020 (DOS dialect) | OpenSWOS | Why |
|---|---|---|
entry coords, ConvertMenu adds x+8, y+0 |
unchanged; UnpackMenu adds x+24, y+36 |
the same 304x200 menu panel, placed differently on screen |
text: @kAlloc = opcode 8 with pointer -1 |
text_no_ptr (opcode 22) |
UnpackMenu's allocation pass looks for the 32-bit 0xFFFFFFFF, which a 64-bit -1 is not |
text: "EXIT" inline |
{"op": "text", "literal": "EXIT"} |
new; the loader interns it |
text: aExit (a SWOS string) |
"str": "_aExit" |
our registry's name; also makes it translatable |
text: @kNull |
"str": null |
|
color: kNone |
0 | kNone is swos-2020 enum Controls' first member; mnu2h passes it through |
skipLeft ... |
opcode 17 ... by number | our JSON names for 17-20 do not match the fields they fill |
| MenuProc redraws the menu every frame | menu_flags.dos_redraw on every imported menu |
SWOS 2020 handlers update entries from onDraw and never redraw them |
entry names, export constants |
JSON name / exports + the header |
the loader ignores them |
Not supported yet: stringTable (the importer stops on one; none in this set).
Fix-ups for the source's own gaps (NAV_FIXUPS in the importer). The .mnu
files are imported faithfully, bugs included, so where SWOS 2020's own definition
is wrong the mend goes in the importer — a re-import keeps it, and the table says
which menu, which entry and why. The one entry so far is logIn:
passwordInput sends the cursor DOWN into rememberLogInInfo, but that entry
and the two toggles under it carry no navigation at all, so the cursor arrived
and could not leave in any direction (reported 2026-09-20). The buttons below
reached back UP to passwordInput, over the toggles — the other half of the same
gap. The fix-up gives the three toggles the column they already look like and
lets the button rows come back to the last of them. showPassword is hidden at
run time (online_menus.c) and the menu walks THROUGH an invisible entry by its
own links, so it needs them as much as the visible two.
To see a menu without playing to it: --menu=swos2020/logInMenu (the folder is
part of the name), with SWOS_KEY_SCRIPT="300:Down 340:Down ..." and
SWOS_SCREENSHOT_INTERVAL=N to drive it and see where the cursor went.
All in the loader and UnpackMenu. None occurs in the 47 compiled menus, and
SWOS_MENU_JSON_VERIFY=1 still reports 47/47 byte-identical.
- Flags word after the header (§0a).
literalontext/multiline— a permanent heap string.- Marker restatement.
UnpackMenutells markers from entries by the entry's first word, so an entry starting with a marker's bytes is misread. DOS never had byte coords, and SWOS 2020 puts entries at x = -1 — 0xFFFF, the byte-coords marker (mLogReaderMenu'sdatetime_00..15: it unpacked as 199 entries instead of 102). The loader now restates the current coords mode before any such entry;UnpackMenuconsumes it and reads the coordinates without looking. Automatic, so JSON can hold any coordinate. - Menus with no compiled counterpart.
MenuJson_Load("swos2020/logInMenu")builds the packed stream into its own heap buffer on first use and caches it, so the pointer stays valid forRestorePreviousMenu. There is nothing to overwrite in place and no size limit. - Run-time symbol tables.
MenuJson_RegisterSymbolsadds a table searched after the generatedmenu_symbols.c. In a JSON-only menu an unresolved handler becomes a no-op, logged once per name, instead of NULL — the menus name handlers that are not ported yet, and a NULL custom-draw function would be called. Compiled menus keep NULL.
- Handlers:
src/online_menus.c, tablek_handlers, SWOS 2020's names.--menu-selftestprints the current "N of 233 ported" (at first import: 35 of 220): the login form (username/password input, the three toggles), LOGIN -> matchmaking in SWOS 2020's own not-connected state (setMatchMakingMenu_Standard,MMM_X_SERVER_NOT_CONNECTED), SETTINGS and RANKINGS from there, and every menu's exit button. Handler code for the rest is in swos-2020src/game.cpp(login, game setup) andsrc/mpgame.cpp(everything else); most of it needs the servers. bin/SWOS.x86_64 --menu=swos2020/logInMenuopens a menu before the main menu; leaving it lands on the main menu.--onlineopens the multiplayer log-in first (the intro skipped), leaving it for the main menu; the online client,make ONLINE_CLIENT=1(SWOS_ONLINE_CLIENT), always starts there and quits when it is left -- a build for playing online and nothing else, SWOS United's. A build flavour, not a fork's default, so every test rig and the career autopilot still start at the main menu.- The main menu's MULTIPLAYER button (entry 14,
MultiplayerMenuSelectedinsrc/menus.c) opens SWOS 2020's online flow,swos2020/logInMenu-- log in to a matchmaking server (src/mm_client.c, docs/NETPLAY.md section 7). OpenSWOS's own direct-IP menu,p2p/p2pMenu(src/p2p_menu.c, docs/NETPLAY.md section 6), still works but is off the main menu:--menu=p2p/p2pMenuopens it. The button was added as a structural row -- the two columns above it moved from 20 to 18 pixels apart to make room -- andSWOSMainMenuInithides it in every build without netplay (SWOS_NETPLAY): the Amiga and any SDL build made withoutNETPLAY=1. (The web build has netplay on by default since 2026-09-24, over the WebSocket gate.) CREDITS (entry 15,CreditsMenuSelected) opens OpenSWOS's ownopenswos/creditsMenu(src/credits_menu.c; the words areinclude/credits_text.h, shared with the native screen the AGA Amiga shows instead); it is hidden on the OCS Amiga. The PLAY MATCH screen's UNIFORM (entry 68,UniformSelected) opensswos2020/selectUniformMenuthe same way (docs/UNIFORM.md), and the matchmaking menu's MY CUSTOM TEAM opensswos2020/selectMyCustomTeams(docs/CUSTOM_TEAMS.md); their handlers are insrc/uniform_menu.candsrc/custom_team.c, each with a symbol table of its own. OPTIONS -> CONTROLS (entries 15 and 16,ShowControlsMenu; a structural row, hidden on the Amiga byOptionsMenuBeforeDraw) is SETTINGS on SDL (§10f), whose CONTROLS -> KEYBOARD KEYS opens OpenSWOS's ownopenswos/controlsMenu(src/controls_menu.c, docs/CONTROLS.md): the player's own keys and the press latch. --menu-selftestloads every JSON-only menu -- the imported ones (SWOS2020_MENUS),p2p/rateMatchMenu(HOW WAS THE MATCH?) andp2p/p2pMenu-- unpacks each into scratch memory and checks its entries' ordinals, rectangles, nav links and text against its JSON, then prints the handler count. Result when written (29 imported + p2pMenu): 30 menus, 1336 entries, 0 failed on x86_64 and on the 32-bit build; it now checks 32 menus.- SDL only:
menu_load_json.c,online_menus.c,p2p_menu.c,controls_menu.candp2p_link.care inSDL_ONLY_SRCS(Makefile.amiga). The Amiga compiles only the sharedUnpackMenu/MenuProc/DrawMenuchanges and has no JSON menus to load.
- Palette. SWOS 2020 menus were designed on the DOS menu palette. Through ours,
kDarkBlue(3) buttons render near-black andkPurple(11) blue. - Mouse. SWOS 2020 menus are also mouse-driven (
src/menus/menuMouse.cpp); ours are keyboard/joystick only. - Literal text is not translated —
tr()is keyed by symbol name. - Blinking text (
kBlinkText) in ados_redrawmenu would add a vsync per blink frame (UpdateBlinkingMenuTextredraws on its own). None of the imported menus blink.
- OPTIONS -> SETTINGS (entries 15/16, the row that was CONTROLS;
ShowControlsMenu, relabelled byOptionsMenuBeforeDraw) opensopenswos/settingsMenu: SWOS 2020's OPTIONS buttons CONTROLS, VIDEO, AUDIO, GAMEPLAY (options.mnu). Each is a page ofopenswos/settingsPage-- twelve label/value rows, aninput_funcmask0xE0so FIRE or RIGHT steps a value on and LEFT back -- filled from a table of rows insrc/settings_menus.c. The rows are settings the game already had in SWOS.ini; SWOS 2020's own screens (videoOptions.mnu's resolution list, audioOptions.mnu) are about its renderer and mixer, so their layout is not imported, their purpose is:- CONTROLS: docs/CONTROLS.md §4 (with SWOS 2020's CONTROLLER SETUP,
openswos/joypadConfigMenu, imported as it is from joypadConfig.mnu). - VIDEO OPTIONS: WINDOW MODE (windowed / fullscreen / exclusive, now:
Platform_SetFullscreenMode), WINDOW SCALE (now), VSYNC, WIDESCREEN, SMOOTH SCROLLING, SCALING, MONITOR, RENDERER (from the next start, said in the note), MENU CURSOR (below). - AUDIO OPTIONS: the four volumes (
AudioSDL_SetKindVolumes, 10% a step), MENU MUSIC (OPTIONS' row), MATCH SOUNDS and MUSIC Amiga/PC, PC MENU MUSIC midi/mp3, COMMENTARY off/on/auto (all now), OUTPUT mono/stereo (next start). - GAMEPLAY OPTIONS: GAME STYLE (
GameplayStyle_Set), AUTO SAVE REPLAYS (next start), HIGHLIGHT DEFAULT SPEED and FRAME INFO OVERLAY (ReplayV2_ViewerConfigure, now) -- the rest of SWOS 2020's gameplayOptions screen is OPTIONS' own rows, or other features (pitch selection, clash kits).
- CONTROLS: docs/CONTROLS.md §4 (with SWOS 2020's CONTROLLER SETUP,
- F6 in a menu (SWOS 2020's controls.cpp:2202): with a game in progress, the main menu's SAVE
(
QuickSave_FromMenu, the body ofSaveContestwithout itsCommonMenuExit, which sets up the MAIN menu's entries) from where the player is. Not on the main menu (it has SAVE), on PLAY MATCH, during the season's turn, in a text field, a dialog or--career-golden.input_sdl.cnotes the key outside a match;SettingsMenus_MenuFrame(MenuProc, SDL) takes it. - MENU CURSOR (
[video] menu_cursor, SWOS 2020's--flashing-menu-cursor): flashing, the game's own, or steady --_kColorTableShineheld at its first colour. - The rest of SWOS 2020's menu look is its renderer's or its 2020 look, not ported: MENU ICONS
and the SWOS TV ICON (its main menu's pictures -- SWOS United's look), MENU SPRITE ANIMATION (its
main menu's animated balls and players), alpha-blended menus (its 32-bit renderer draws the menu
over a picture; ours is 8bpp end to end), mouse cursor images; SCREEN FADE SPEED: SWOS 2020's
DEFAULT is the DOS palette fade with half-frame delays, ours the Amiga's five-frame fade (0.1 s),
already faster than its FAST, and
_fadeInitFlagis match state (sim_state.c). AMIGA STYLE MENU is thedosmenusmod (F5). - MULTIPLAYER SETTINGS (
mmSettingsMenu,src/online_menus.c): COMMENTARY ([audio] commentary), AUTO CLOSE CHATBOX ([chat] auto_close, 1-5 s, SWOS 2020's), ESC PRESSING TO QUIT ([netplay] esc_presses, 1-3 within two seconds, each short press said in the chat box), DISABLE CONTROLLER IN CHAT ([chat] controller_off: nothing of the player's -- keys, pad, touch -- steers while the chat is on) and CHAT WINDOW SCALE ([chat] scale0-8, 1X-5X in halves, as SWOS 2020 and Page Up / Page Down) are shown and work. ACCEPT SOUND stays hidden (a fork's), CHAT WINDOW SCALE moved into its place; VIDEO VSYNC is commented out in SWOS 2020's own menu (it is on VIDEO OPTIONS); PITCH SET and DLC SETTING are its DLC's (here RECORD MATCHES and SEND MATCH REPORTS). Each is this player's own: nothing goes to the other game. --settings-menus-selftestshows and checks every page's rows and loads the three menus;--menu-selftestchecks them against their JSON.
customTacticsWarningMenu (swos-2020 customTacticsWarning.mnu, in MULTIPLAYER_MENUS):
SWOS 2020 shows it after its team screen in a RANKED match not played in the PC style, when
the opponent's team plays a USER tactic (12 and up): "YOUR OPPONENT PLAYS WITH CUSTOM TACTICS.
ONLY PROCEED TO PLAY IF YOU AGREE ... OTHERWISE, CANCEL AND LEAVE LOBBY." Ours: the lobby's
team screen confirmed (lineup_screen, custom_tactics_warning in src/online_menus.c), the
lobby's mode LOBBY_MODE_RANKED (a service with ranked matches), the style not DOS, the other
player's tactic >= TACTIC_USER_A. Only a warning; its OK goes back to the lobby, which it
keeps polling. SWOS_LOBBY_TACTICS_WARNING=1 logs it whatever the match (a test), =2 shows it.
The menus were laid out for 96/97's data. A world's data can outgrow them: World 2026-27's Europe has 55 countries, and its packs' short competition names are often wider than 96/97's. A menu draws whatever it is given, on top of whatever is already there.
SWOS_MENU_OVERLAP=1 (SDL, src/menu_system.c) checks every full redraw and writes each
finding once to SWOS.log as an [overlap] line, naming the menu by its init function:
- boxes: two visible filled entries that cross, neither holding the other (a row inside a backdrop is normal layering);
- text and text: two drawn strings that cross (leading and trailing spaces trimmed);
- text and box: a string that crosses the edge of another entry's box.
SWOS_MENU_OVERLAP_WIDTHS=<file> also measures each line of the file in the small and the
big font, once ([widths] <small> <big> <text>): for names no test run puts on screen.
SWOS_TEXT_FIT=1 checks that every built-in menu's labels fit their own boxes, in one
language (--language=xx, else SWOS.ini's):
-
At the first menu drawn, each of the 47 menus is unpacked into a scratch copy, so the screen is left alone.
-
Each label is measured in its own font against its box less 2 px a side. For an option row, every value of its string table is measured, not only the one showing.
-
Each label that doesn't fit is a
[textfit]line, then the game quits (exit 1 if any). -
Labels set by code at run time (names, numbers) are the overlap check's job.
-
Grep the log with
grep -a: the translations' accents are Latin-1 bytes. -
English, the original layout, gives only DIY's six "*" markers in their 4 px boxes, which is how the game drew them.
SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy SWOS_SKIP_INTRO=1 SWOS_TEXT_FIT=1 \ bin/SWOS.x86_64 --language=de; grep -a textfit ~/.swos/SWOS.log
To sweep a world: a one-season career for a club of every country (--career-golden=new:... --golden-seasons=1), and SWOS_GOLDEN_VIEW_WORLD=<continent> (src/career_autopilot.c)
for VIEW WORLD's continent screen, its competitions above its countries. 96/97 gives none.
Fixed so far:
-
A continent's list taller than its room (
SetTeamsCoordinates,src/teams.c): rows 8 px apart and 7 tall instead of 9 and 8, with no extra gap, only when the list would not fit between the header and EXIT. 96/97's lists keep the original spacing. -
Short competition names in the career's fixture list (
CareerGameListCommon): the name column has 70 px of the small font before a home-and-away row's "(H)"/"(A)"; 133 of World 2026-27's 322 short names were wider and ran into it. The SWOS 96/97 Mod's DOS game has the same column and fits every short name when it builds (itstools/complist.py,fit_short: a hand-picked label, else standard abbreviations last word first, else the widest words cut).src/cal_label.cis that function in C (MIT, its notice kept), applied where the column is drawn, to a name that does not fit only: the labels read as in the Mod (all 560 of the world's strings checked against its Python), and 96/97's names, which all fit, never change.SWOS_MENU_OVERLAP_WIDTHSprints each line's label ([calfit]);SWOS_GOLDEN_SHOT_HUB=<n>screenshots the hub, its fixture list, the n-th time it is up.
After both, a season in each of the world's 91 career countries and VIEW WORLD on every continent report nothing (2026-11-02).
Two things a JSON menu may say that the packed format has no room for, for SWOS 2020's menus (SWOS United's menus2020) and any mod's:
{ "name": "...", "description_entry": 14, "items": [
{ "kind": "entry", "description": "PLAY A MATCH AGAINST A FRIEND OR THE COMPUTER", ... },
{ "kind": "entry", "image": "grafs_2020/menu/tv.bmp", ... } ] }description_entry(the menu): its text entry N shows the selected entry'sdescription(an entry's one line, empty for one without), set before each draw.image(an entry): a.bmpunder the data folder -- a mod's overlay first, as every read -- drawn in the entry's box every menu frame, centred or atimage_x/image_yfrom the box's top left (an icon beside the entry's text), each colour the nearest in the palette on screen, mapped again whenever that palette changes (a menu fades in from black); black and magenta (255, 0, 255) transparent. Loaded at its first draw.
The loader gives them to menu_extras.c as it builds a menu, and they are filed under the menu's
final packed bytes (the pointer ShowMenu gets, _currentMenuPtr): a JSON-installed engine menu
and a dynamic (JSON-only) one alike. Only the picture; the Amiga has neither.
A message the player answers is a screen of the game's, not the OS's message box:
MenuDialog_Show(title, text, buttons, count, default) (include/menu_dialog.h) shows the JSON-only
menu openswos/menuDialog -- a header, four button entries -- and returns the button chosen (or -1,
ESC). Its onInit puts the title and the buttons used in place, stacked from the bottom (the others
hidden, their neighbours set); its onDraw draws the text under the header, wrapped to 300 px, | or
a newline a new paragraph. The menu font has capitals, digits and . , : - !: the text is shown in
capitals, brackets as dashes, quotes and apostrophes left out -- write it as for a message box.
Mods: ModApi_ShowDialog (docs/MODS.md).
Its users: the start-up notice that the game data was made by an older OpenSWOS Setup (UPDATE NOW
/ CONTINUE / DO NOT REMIND ME: UPDATE NOW starts the setup with --headless, which remakes the data
with no window and starts the game again) or that World 2026-27 is missing or other data
(src/assets_check.c, shown by the front end before the main menu); OPTIONS -> WORLD's and LANGUAGE's
notes; OPTIONS -> SETUP -> LAUNCH (entries 27/28, shown only when the setup is beside the game:
openswos-setup(.exe) in the game's folder, or the setup's .app beside SWOS.app). LAUNCH SETUP
starts it (posix_spawn; open -a on a Mac) and closes the game, so the setup can change the data.
A phone and the web never offer it. mobile.c's two boxes stay the OS's: they come before the
game's menus exist.