Skip to content

Commit e706bef

Browse files
committed
Add the retail transport panel to the C99 world
1 parent 81ea037 commit e706bef

31 files changed

Lines changed: 848 additions & 60 deletions

‎documentation/data-files.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ scenario zero, entry 50. The transport panel only displays enabled rows and
677677
packs them into ten visible slots per page; disabled rows do not leave gaps.
678678
For a same-scenario single-player move, the executable looks up the MCT entry
679679
key as `local player number + entry * 4`, so row zero resolves entry key 200.
680+
The small C99 runtime streams exactly these 51 records into a fixed catalog;
681+
it does not retain the rest of `Table.Tbd`. The UI reads names and enabled-row
682+
state from that catalog, while `game/world_transport.c` resolves the selected
683+
entry through the active MCT. Cross-scenario rows deliberately wait for the
684+
shared scenario-reload boundary instead of pretending they are local entries.
680685
681686
Scenario folders use zero-padded decimal IDs, not hexadecimal IDs. For
682687
example, Table 40 row one names scenario `6`, which lives at

‎documentation/script-engine.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,13 @@ service cleanup. It closes transport only when its argument matches the
548548
script-opened selector, leaving an independently open right-side inventory
549549
and its camera layout untouched.
550550

551+
The C99 runtime now follows that split directly. The interpreter only forwards
552+
37 and 38 through its native hook. The world records a one-shot typed request,
553+
the screen-side service controller opens or closes UI state, and the selected
554+
same-scenario row is resolved through the MCT by `game/world_transport.c`.
555+
Panel artwork, paging, hover, and click consumption stay in `ui/`; no script
556+
opcode includes a UI header or knows a screen rectangle.
557+
551558
The one shipped nonzero opcode-41 call is scenario `99000013`, sentence 10.
552559
Its object `10000900` is named `Giant Warehouse` in the Tower of Ordeal 12F
553560
MCT and passes argument one. The executable uses that value to select a

‎roadmap.md‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ the retail interaction range instead of leaking into movement. The Warehouse
3333
now runs its authored status-zero sentence and opcode 41 through a one-shot
3434
game-service request. Its existing left Special Item panel opens without
3535
closing an independent right Inventory; only the UI layer changes panel state.
36+
The transport object now follows that same route. Opcode 37 opens its authored
37+
left panel, all 51 destination records come from Table 40, enabled rows are
38+
packed into ten slots per page, and a right Inventory stays independent.
39+
Remote Town's default row resolves MCT entry 200 and relocates the hero without
40+
leaking its click into movement. Opcode 38 only closes the matching service.
3641
Ostare's opening chain reaches its four opcode 10 starter
3742
drops, with the original item definitions, artwork, palettes, bounce, and
3843
landing sounds.
@@ -120,12 +125,11 @@ A slice is only done after the C99/TWL/TAL tests, a release build, a practical
120125
check when visible behavior changed, and a fresh measured budget when assets
121126
changed.
122127

123-
The immediate C99 target is the matching transport interaction. Reuse the
124-
proven object-status and one-shot service boundary for opcode 37, load the
125-
enabled destination rows from retail Table 40, and keep the live shifted world
126-
beside a UI-owned transport panel. Opcode 38 should close only that matching
127-
service. Discovery and travel can then grow from the same authored script path
128-
instead of hardcoded Remote Town destinations.
128+
The immediate C99 target is the rest of the authored transport path. Periodic
129+
teleporter status should discover and save its Table 40 row, opcode 27 should
130+
draw the activation label, and cross-scenario selection should go through one
131+
clean screen-runtime reload rather than a map-specific shortcut. That same
132+
transition seam can then serve the ordinary opcode 17 exits around Remote Town.
129133

130134
## Where we are now
131135

‎shadowflare/CMakeLists.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ add_library(
7979
data/scs.c
8080
data/spell_parameters.c
8181
data/table.c
82+
data/transport.c
8283
data/voc.c
8384
game/character_create.c
8485
game/companion.c
@@ -115,6 +116,7 @@ add_library(
115116
game/world_magic.c
116117
game/world_save.c
117118
game/world_script.c
119+
game/world_transport.c
118120
interpreter/scenario_actor_script.c
119121
interpreter/scenario_script_commands.c
120122
interpreter/scenario_script_values.c
@@ -157,6 +159,7 @@ add_library(
157159
ui/gameplay_status.c
158160
ui/gameplay_special_items.c
159161
ui/gameplay_service_controller.c
162+
ui/gameplay_transport.c
160163
ui/ground_item_nameplate.c
161164
ui/scenario_object_nameplate.c
162165
ui/world_pointer.c

‎shadowflare/README.md‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,17 @@ object pixels also participate in hover and click selection, including the
6868
MCT-owned nameplate. Clicking the Warehouse now routes into range, starts its
6969
authored status-zero sentence, and lets opcode 41 toggle the existing Special
7070
Item panel. The script emits a one-shot game request; the UI owns the panel and
71-
keeps an independent right Inventory open. The transport objects are the next
72-
service case rather than a special branch in object rendering.
71+
keeps an independent right Inventory open. The matching transport object now
72+
uses the same boundary: its real status-zero sentence reaches opcode 37 and
73+
opens the retail left-hand destination panel while an independent Inventory
74+
can remain open on the right. All 51 names and scenario/entry pairs are
75+
streamed from Table 40, enabled rows are compacted into ten slots per page,
76+
and the arrows, hover rows, frame, and sample 58 come from the original game.
77+
Selecting Remote Town resolves entry key 200 through the active MCT instead of
78+
hardcoding world coordinates, consumes the panel click before world movement,
79+
and closes only the transport panel. Opcode 38 supplies the matching scripted
80+
close request. Cross-scenario reloads and discovery presentation remain the
81+
next transport slice.
7382
The default retail click-range square now selects opaque PEOPLE pixels, hover
7483
adds the pale tint and authored nameplate, and clicking a distant actor routes
7584
the player to the recovered `0x9f` interaction distance without issuing a
@@ -269,8 +278,8 @@ it is invalid.
269278

270279
## Current screen budgets
271280

272-
The complete title currently uses 1,485,989 bytes of the 7 MiB main arena,
273-
leaving 5,854,043 bytes free. Its screen-scoped artwork accounts for 1,101,182
281+
The complete title currently uses 1,488,877 bytes of the 7 MiB main arena,
282+
leaving 5,851,155 bytes free. Its screen-scoped artwork accounts for 1,101,182
274283
bytes. The rest includes TWL/TAL state, game and screen metadata, persistent
275284
8-bit menu music and effects, and one reusable 60,000-byte decode buffer. The
276285
video pool contains only the 614,400-byte RGB555 framebuffer, leaving 3,579,904
@@ -283,23 +292,23 @@ nonblank case, all ten smoke streams together decode at most 57,864 bytes into
283292
the same reusable buffer during one rendered frame.
284293

285294
Character creation releases all title-only artwork before loading its own
286-
assets. It uses 798,912 bytes of the main arena, leaving 6,541,120 bytes free;
295+
assets. It uses 801,800 bytes of the main arena, leaving 6,538,232 bytes free;
287296
414,105 bytes of that total are character-screen artwork and font data. Shared
288297
NJP parts are decoded only once even when several patterns reference them, and
289298
a static character screen is not filled again until a visible state changes.
290299

291-
The load-game screen uses 759,128 bytes of the main arena, leaving 6,580,904
300+
The load-game screen uses 762,016 bytes of the main arena, leaving 6,578,016
292301
bytes free. Its screen-scoped artwork, font, and selected save preview account
293302
for 374,321 bytes. Save headers stay in a fixed six-entry catalog, while only
294303
the selected 391x114 thumbnail occupies memory. Changing selection decodes the
295304
new preview into the same 89,148-byte RGB555 buffer; idle frames perform no
296305
file access and do not refill the framebuffer.
297306

298-
The complete Remote Town gameplay screen uses 7,076,380 bytes of the main
299-
arena, leaving 263,652 bytes free. Its screen-owned scenario, script, map,
307+
The complete Remote Town gameplay screen uses 7,213,588 bytes of the main
308+
arena, leaving 126,444 bytes free. Its screen-owned scenario, script, map,
300309
player, owned companion, PEOPLE, type-zero objects, ground-item,
301-
inventory-panel, equipment, and UI data and artwork account for 6,691,573
302-
bytes. GND rendering data is decoded directly from its compressed three-plane
310+
inventory-panel, transport, equipment, and UI data and artwork account for
311+
6,825,893 bytes. GND rendering data is decoded directly from its compressed three-plane
303312
stream into two bytes
304313
per tile, so the 300x300 town grid occupies 180,000 bytes instead of retaining
305314
the 540,000-byte source layout.
@@ -362,7 +371,7 @@ The owned companion is prepared just as narrowly. The active save row chooses
362371
one PARTNER resource, and its loader keeps only charts zero through two for the
363372
eight ordinary directions, deduplicating every referenced NJP and SDW pattern.
364373
That companion slice accounts for most of the latest gameplay increase, so the
365-
remaining 267,244-byte headroom is now a hard warning for upcoming combat and
374+
remaining 126,444-byte headroom is now a hard warning for upcoming combat and
366375
effect work: later slices must retire or stream existing screen data rather
367376
than quietly raising the arena limit.
368377

@@ -404,7 +413,7 @@ grid placement, single-item swaps, invalid-placement rollback, and partial
404413
Gold merges all stay in `game/inventory.c`.
405414

406415
The inventory and character panels follow the same lifetime. `Status.njp` is
407-
streamed to retain only 37 required patterns, without constructing
416+
streamed to retain only 43 required patterns, without constructing
408417
metadata for its other 115 patterns. Item definitions provide the inventory
409418
group, pattern, and optional palette directly; only groups and cells referenced
410419
by the active map's retained definitions are decoded.

‎shadowflare/assets/gameplay_assets.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,12 @@ bool sf_gameplay_assets_load(
239239
19u, 20u, 21u, 22u, 23u, 24u, 25u, 26u, 27u, 28u,
240240
29u, 30u, 31u, 32u
241241
};
242-
static const uint8_t inventory_patterns[37] = {
242+
static const uint8_t inventory_patterns[43] = {
243243
0u, 1u, 2u, 3u, 5u, 6u, 14u, 15u, 16u, 32u,
244244
36u, 37u, 38u, 39u, 40u, 41u, 42u, 43u, 44u, 45u, 46u,
245245
47u, 48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u, 56u, 57u,
246-
67u, 69u, 70u, 116u, 117u
246+
67u, 69u, 70u, 116u, 117u,
247+
11u, 12u, 13u, 22u, 23u, 24u
247248
};
248249
static const uint8_t magic_icon_patterns[23] = {
249250
0u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u, 12u,
@@ -309,7 +310,7 @@ bool sf_gameplay_assets_load(
309310
!sf_retail_path_join(
310311
path, sizeof(path), data_root, sf_retail_game_paths.status) ||
311312
!sf_njp_stream_decoded_patterns(
312-
path, inventory_patterns, 37u, arena, &assets->inventory_panel) ||
313+
path, inventory_patterns, 43u, arena, &assets->inventory_panel) ||
313314
!sf_retail_path_join(
314315
path, sizeof(path), data_root, sf_retail_game_paths.magic_icons) ||
315316
!sf_njp_stream_decoded_patterns(
@@ -327,6 +328,7 @@ bool sf_gameplay_assets_load(
327328
!sf_companion_profile_load(
328329
path, companion_type, companion_level, &assets->companion_profile) ||
329330
!sf_spell_parameters_load(path, assets->spell_parameters) ||
331+
!sf_transport_catalog_load(path, &assets->transports) ||
330332
!sf_gameplay_sound_assets_load(
331333
&assets->sounds, data_root, arena) ||
332334
!sf_ground_item_assets_load(

‎shadowflare/assets/gameplay_assets.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "data/player_parameters.h"
3636
#include "data/scs.h"
3737
#include "data/spell_parameters.h"
38+
#include "data/transport.h"
3839
#include "data/companion_parameters.h"
3940

4041
#include <stdbool.h>
@@ -63,6 +64,7 @@ typedef struct SfGameplayAssets {
6364
SfPlayerInitialParameters player_parameters;
6465
SfCompanionProfile companion_profile;
6566
SfSpellParameters *spell_parameters;
67+
SfTransportCatalog transports;
6668
SfPlayerAssets player;
6769
SfCompanionAssets companion;
6870
SfScenarioActorAssets actors;

‎shadowflare/data/transport.c‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright (C) 2026 Michael Binder and contributors
3+
*
4+
* This file is part of OpenShadowFlare.
5+
*
6+
* OpenShadowFlare is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License as published by the Free
8+
* Software Foundation, either version 3 of the License, or (at your option) any
9+
* later version.
10+
*
11+
* OpenShadowFlare is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14+
* details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with OpenShadowFlare. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include "data/transport.h"
21+
22+
#include "data/table.h"
23+
24+
#include <string.h>
25+
26+
typedef struct SfTransportScan {
27+
SfTransportCatalog *catalog;
28+
uint8_t fields[SF_TRANSPORT_DESTINATION_COUNT];
29+
} SfTransportScan;
30+
31+
static bool sf_transport_number(
32+
void *user, int32_t table, int32_t row,
33+
int32_t column, int32_t value) {
34+
SfTransportScan *scan = (SfTransportScan *) user;
35+
SfTransportDestination *destination;
36+
if (table != 40) return true;
37+
if (row < 0 || row >= (int32_t) SF_TRANSPORT_DESTINATION_COUNT ||
38+
column < 0 || column > 2) return false;
39+
destination = &scan->catalog->destinations[row];
40+
if (column == 1) {
41+
destination->scenario_id = value;
42+
scan->fields[row] |= 1u;
43+
} else if (column == 2) {
44+
destination->entry_value = value;
45+
scan->fields[row] |= 2u;
46+
}
47+
if (scan->catalog->count <= (uint8_t) row)
48+
scan->catalog->count = (uint8_t) row + 1u;
49+
return true;
50+
}
51+
52+
static bool sf_transport_text(
53+
void *user, int32_t table, int32_t row, int32_t column,
54+
uint32_t byte_index, uint32_t byte_count, uint8_t value) {
55+
SfTransportScan *scan = (SfTransportScan *) user;
56+
char *name;
57+
if (table != 40 || column != 0) return true;
58+
if (row < 0 || row >= (int32_t) SF_TRANSPORT_DESTINATION_COUNT ||
59+
byte_count == 0u || byte_count >= SF_TRANSPORT_NAME_CAPACITY)
60+
return false;
61+
if (byte_index >= byte_count) return false;
62+
name = scan->catalog->destinations[row].name;
63+
name[byte_index] = (char) value;
64+
if (byte_index + 1u == byte_count) {
65+
name[byte_count] = '\0';
66+
scan->fields[row] |= 4u;
67+
}
68+
return true;
69+
}
70+
71+
bool sf_transport_catalog_load(
72+
const char *table_path, SfTransportCatalog *catalog) {
73+
SfTransportScan scan;
74+
uint8_t row;
75+
if (!table_path || !catalog) return false;
76+
memset(catalog, 0, sizeof(*catalog));
77+
memset(&scan, 0, sizeof(scan));
78+
scan.catalog = catalog;
79+
if (!sf_table_scan(
80+
table_path, sf_transport_number, &scan,
81+
sf_transport_text, &scan) ||
82+
catalog->count != SF_TRANSPORT_DESTINATION_COUNT) goto failed;
83+
for (row = 0u; row < catalog->count; ++row)
84+
if (scan.fields[row] != 7u || !catalog->destinations[row].name[0] ||
85+
catalog->destinations[row].scenario_id < 0 ||
86+
catalog->destinations[row].entry_value < 0) goto failed;
87+
return true;
88+
failed:
89+
memset(catalog, 0, sizeof(*catalog));
90+
return false;
91+
}
92+
93+
const SfTransportDestination *sf_transport_destination(
94+
const SfTransportCatalog *catalog, int32_t row) {
95+
return catalog && row >= 0 && row < catalog->count
96+
? &catalog->destinations[row] : NULL;
97+
}

‎shadowflare/data/transport.h‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2026 Michael Binder and contributors
3+
*
4+
* This file is part of OpenShadowFlare.
5+
*
6+
* OpenShadowFlare is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License as published by the Free
8+
* Software Foundation, either version 3 of the License, or (at your option) any
9+
* later version.
10+
*
11+
* OpenShadowFlare is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14+
* details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with OpenShadowFlare. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifndef SHADOWFLARE_DATA_TRANSPORT_H
21+
#define SHADOWFLARE_DATA_TRANSPORT_H
22+
23+
#include <stdbool.h>
24+
#include <stdint.h>
25+
26+
#define SF_TRANSPORT_DESTINATION_COUNT 51u
27+
#define SF_TRANSPORT_NAME_CAPACITY 48u
28+
29+
typedef struct SfTransportDestination {
30+
char name[SF_TRANSPORT_NAME_CAPACITY];
31+
int32_t scenario_id;
32+
int32_t entry_value;
33+
} SfTransportDestination;
34+
35+
typedef struct SfTransportCatalog {
36+
SfTransportDestination destinations[SF_TRANSPORT_DESTINATION_COUNT];
37+
uint8_t count;
38+
} SfTransportCatalog;
39+
40+
bool sf_transport_catalog_load(
41+
const char *table_path, SfTransportCatalog *catalog);
42+
const SfTransportDestination *sf_transport_destination(
43+
const SfTransportCatalog *catalog, int32_t row);
44+
45+
#endif

‎shadowflare/game/gameplay_service.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525

2626
typedef enum SfGameplayServiceKind {
2727
SF_GAMEPLAY_SERVICE_NONE = 0,
28-
SF_GAMEPLAY_SERVICE_TOGGLE_SPECIAL_ITEMS
28+
SF_GAMEPLAY_SERVICE_TOGGLE_SPECIAL_ITEMS,
29+
SF_GAMEPLAY_SERVICE_OPEN_TRANSPORT,
30+
SF_GAMEPLAY_SERVICE_CLOSE_TRANSPORT
2931
} SfGameplayServiceKind;
3032

3133
typedef struct SfGameplayServiceRequest {

0 commit comments

Comments
 (0)