Skip to content

Commit 89a2010

Browse files
author
Trulio
committed
Merge branch 'master' of https://github.com/RednibCoding/OpenShadowFlare into feature/androidPort
2 parents 06c2378 + 504f4da commit 89a2010

278 files changed

Lines changed: 29471 additions & 194 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎documentation/data-files.md‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,12 @@ Each concrete item stores category, definition ID, an instance value, optional
599599
grid coordinates, its category-sized state-block length, and that state block.
600600
The nine known player equipment slots, backpack, belt, and Special Item
601601
container are restored and rewritten. The extra two equipment records remain
602-
byte-for-byte preserved. Three counted arrays follow for scenario, transport,
603-
and quest/conversation state. After them retail writes the spell state as:
602+
byte-for-byte preserved. Three counted arrays follow in this order: quest
603+
state (operand type 12), unlocked transports (type 10), and persistent script
604+
and conversation values (type 11). The development saves use counts 48, 51,
605+
and up to 1,000 respectively, so the small C99 runtime keeps the full fixed
606+
1,000-value owner and restores it before the scenario's first periodic pass.
607+
After them retail writes the spell state as:
604608
605609
| Field | Size |
606610
|-------|------|
@@ -717,6 +721,7 @@ known offsets are shared by all five field blocks:
717721
| `0x08` | Quality/variant number |
718722
| `0x0c` | Episode mask used by loot profiles |
719723
| `0x10` | Weighted loot-selection value |
724+
| `0x14` | Base purchase price; ordinary sale price starts at one quarter |
720725
| `0x1c` | Inventory width in 32-pixel cells |
721726
| `0x20` | Inventory height in 32-pixel cells |
722727
| `0x24` | Item weight |
@@ -748,12 +753,26 @@ Weapon records also expose the fields used by the first equipment slice:
748753
749754
| Field offset | Meaning |
750755
|--------------|---------|
756+
| `0x64` | Maximum durability |
751757
| `0x68`..`0x8c` | Ten contributions consumed by the derived-stat refresh |
752758
| `0x94` | Required player level |
753759
| `0xa8` | Player CAF appearance part |
754760
| `0xac` | Appearance-part red strength |
755761
| `0xb0` | Appearance-part green strength |
756762
| `0xb4` | Appearance-part blue strength |
763+
| `0xd0`..`0xec` | Eight base elemental strengths |
764+
765+
Armor records use the same durability, contribution, and required-level
766+
offsets. Their eight elemental strengths begin at `0xa8` because their
767+
appearance block is shorter. The small C99 runtime retains these named fields,
768+
plus the active record's name and description, during its existing streaming
769+
scan so item information never needs the complete decoded database.
770+
771+
`Status.njp` pattern 16 is the 16-by-16 item-condition marker. Retail places
772+
its origin at the lower-right 16 pixels of the complete inventory footprint.
773+
It is shown for weapon and armor durability from zero through nine percent,
774+
blinks for eight gameplay updates on and eight off while above zero, and stays
775+
visible when the item is completely broken.
757776
758777
For the Short Sword these values are requirement level 1, CAF part 12, RGB
759778
strengths `1000, 1000, 1000`, and first derived contributions 20 and 100.

‎reverse/shadowflare-exe/status.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,10 @@ ownership unchanged when no complete placement is available.
496496
The first inventory screen follows `0x00404760`, `0x00407170`, and
497497
`0x00408a80`. `I` and the lower ITEM button toggle the live right-hand panel,
498498
move the camera anchor to x=160, and restrict world picking to x=0..319.
499-
`Status.njp` patterns 2, 3, 0/1, and 74/75 supply the original frame, gender
500-
silhouette, and Close tab. Gold is summed from the owned stacks; equipped
499+
`Status.njp` patterns 2, 3, 0/1, and 116/117 supply the original frame, gender
500+
silhouette, and Close tab. The last pair is retail's hexadecimal `0x74/0x75`;
501+
decimal patterns 74/75 belong to the Giant Warehouse page strip. Gold is
502+
summed from the owned stacks; equipped
501503
weight comes from the equipment owner. Backpack
502504
items draw from the separate `Item0000.njp` through `Item0013.njp` groups at
503505
`(336 + grid_x*32, 264 + grid_y*32)`. The inventory and lower HUD regions are

‎roadmap.md‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,109 @@ will move around when the evidence tells us they should.
88
The rule is simple: get one small part behaving like the original, test it,
99
and only then build the next part on top of it.
1010

11+
## Current track: the small C99 game
12+
13+
The implementation under `shadowflare/` is now the active replacement track.
14+
It uses the mature `src/SF_EXE/` reconstruction as a strong behavioral
15+
reference, checks uncertain details against retail, and is intended to replace
16+
`SF_EXE` once it reaches the same playable coverage.
17+
18+
This version deliberately has a smaller shape: plain C99, fixed caller-owned
19+
memory, integer game math, TWL/TAL at the platform edge, and an 8 MiB main-RAM
20+
plus 4 MiB video-memory ceiling. Rendering primitives stay in `render/`, all
21+
HUD and interface composition stays in `ui/`, and the game must remain easy
22+
enough for a junior contributor to follow without learning a framework first.
23+
The standing details and measured screen budgets live in
24+
`shadowflare/RULES.md` and `shadowflare/README.md`.
25+
26+
The front-end, Remote Town map, player movement, retail PEOPLE actors,
27+
collision, pointing, speech bubbles, and interactive script-driven choices are
28+
live. Ostare's opening chain reaches its four opcode 10 starter drops, with the
29+
original item definitions, artwork, palettes, bounce, and landing sounds.
30+
Those drops can now be hovered, approached, and picked up into the player's
31+
fixed 9x4 inventory, including retail dimensions, gold stacks, failure bounce,
32+
and pickup sounds. Harley's complete `Explanation` branch also runs from the
33+
shipped SCS data. The authored bottom HUD now reads level, life, mana,
34+
experience, and walk/run state from the player owner. Its initial values come
35+
from a streaming scan of retail's parameter tables, and HUD clicks cannot leak
36+
into world movement. The first right-side inventory panel now exposes those
37+
owned items using the authored Status and Item sheets, keeps the left-hand
38+
world live around an x=160 camera anchor, and consumes its own input. Items can
39+
now be taken from that 9x4 owner, carried under the pointer, placed or swapped,
40+
and dropped back into the live world without turning the UI click into a move
41+
command. All nine visible equipment regions now use that same pointer owner.
42+
The new hero starts with the table-backed Leather Cloth in the body slot;
43+
weapons, shields, body armor, and accessories validate their retail slot and
44+
level rules, equipped weight is live, and only the active CAF appearance parts
45+
are drawn with their original color strengths. The lower HUD now has its own
46+
fixed 4x2 belt owner with the original staggered pockets. Pointer pickup,
47+
swapping, the `1` through `8` shortcuts, and right-click medicine use share the
48+
same item-transfer path as the backpack. A new hero receives the full retail
49+
loadout: Leather Cloth, four Tablets and four Capsules in both backpack and
50+
belt, and five mines in the separate 5/10 counter. Full life or mana leaves a
51+
medicine untouched, successful use plays the authored sound, and mine pickups
52+
fill their counter instead of entering the bag. Backpack and equipped items
53+
now share the retail three-update information overlay too. Its active
54+
`Item.Ibn` definition supplies the name, price, combat values, durability,
55+
weight, requirement, and elemental strengths. Pointer-relative placement,
56+
the translucent backing, faint frame, tier color, and wide Gold/medicine
57+
layout stay entirely in `ui/`. Low-condition weapons and armor now compose
58+
`Status.njp` pattern 16 over backpack, equipment, and pointer-held icons too.
59+
The exact 0–9% threshold, eight-update blink halves, and permanently visible
60+
broken state live in a small game rule; only the marker composition lives in
61+
`ui/`.
62+
The left-hand Special Item panel is live now as well. `X` opens its authored
63+
9x10 grid, either side can remain open on its own or beside Inventory, and the
64+
same pointer owner moves items directly between them. Special Item placement,
65+
single-item swaps, partial Gold merges, hover information, and condition
66+
markers use the ordinary shared rules. Its fourth retail save container is
67+
decoded into a separate fixed owner and its required definitions stay in the
68+
active resource request.
69+
The shared Status/Magic window now has both retail tabs. `S` and the HUD button
70+
open Status with the saved identity, current pools, table-backed base values,
71+
valid equipment bonuses, affinities, and elemental marker. `M` or the top tab
72+
opens Magic's four six-spell pages, including availability states, saved
73+
levels and experience, table-backed MP/effect values, help text, arrows, and
74+
the authored large icons. Learned spells drag into eight persistent save-owned
75+
slots, while the small gameplay bar keeps retail's dynamic position beside
76+
left and right panels. Every gameplay load starts on normal attack as retail
77+
does. UI state only emits actions; persistent spell ownership remains in
78+
`game/`, table scanning in `data/`, and samples 57/58 reach TAL through a small
79+
general world event queue. Both tabs coexist with right-side Inventory,
80+
replace Special Item on the left, and share the same camera and input offset.
81+
82+
The player's owned companion has its first complete C99 owner now. Table 60
83+
selects one of the six companion types, tables 800 through 805 build its
84+
level-backed profile, and only that type's idle, walk, run, artwork, and shadow
85+
cells are retained from PARTNER. It enters beside the hero, follows through the
86+
same collision-aware edge controller used by other actors, routes around live
87+
PEOPLE, and keeps following while inactive. Space and the exact bottom-left HUD
88+
strip toggle the retail active/inactive state. The active type, all six level
89+
and experience rows, and the defeated countdown restore from their original
90+
save fields. Combat, death presentation, timed revival, Moon, swapping, and
91+
companion dialogue remain later slices rather than being folded into the
92+
follower.
93+
94+
Selecting a retail save now
95+
streams and verifies its `ShadowFlare0005` envelope without allocating a
96+
payload buffer. The plain player record and exact backpack, belt, visible
97+
equipment, hidden alternate-weapon slots, and Special Item cells all populate
98+
the same fixed game owners used by new characters. The four development saves
99+
currently in the retail tree have been decoded through the complete save path.
100+
Quest state, unlocked transports, and all 1,000 persistent script/conversation
101+
values now reach the interpreter before its first periodic pass, so one-time
102+
handoffs such as Ostare's starter items stay complete. Mine count, walk/run
103+
pace, scenario, and authored entry reach the world owner as well. The three
104+
Remote Town saves also pass the complete asset-and-owner restore path. The
105+
load hand-off now recovers to the same selected row when a save belongs to a
106+
map which has not reached the C99 runtime yet, rather than closing the whole
107+
application after the honest asset-load failure. The
108+
remaining save work belongs to systems which are not in the small runtime yet:
109+
warehouse pages, automatic-item pages, and writing saves.
110+
A slice is only done after the C99/TWL/TAL tests, a release build, a practical
111+
check when visible behavior changed, and a fresh measured budget when assets
112+
changed.
113+
11114
## Where we are now
12115

13116
The compatibility-DLL milestone is complete. All fourteen DLLs build, reproduce

‎shadowflare/CMakeLists.txt‎

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,125 @@ endfunction()
3434

3535
add_library(
3636
shadowflare_core STATIC
37+
assets/character_create_assets.c
38+
assets/companion_assets.c
39+
assets/ground_item_assets.c
40+
assets/ground_item_requests.c
41+
assets/inventory_item_assets.c
42+
assets/gameplay_assets.c
43+
assets/gameplay_sound_assets.c
44+
assets/load_game_assets.c
45+
assets/menu_assets.c
46+
assets/player_assets.c
47+
assets/retail_paths.c
48+
assets/scenario_actor_assets.c
49+
assets/title_assets.c
3750
core/arena.c
51+
core/coordinates.c
52+
core/retail_random.c
53+
data/caf.c
54+
data/companion_parameters.c
55+
data/bmp.c
56+
data/gnd.c
57+
data/item.c
58+
data/item_decode.c
59+
data/item_ground.c
60+
data/item_records.c
61+
data/mct.c
62+
data/mct_reader.c
63+
data/mct_sections.c
64+
data/njp.c
65+
data/njp_stream.c
66+
data/njp_stream_reader.c
67+
data/njp_sparse.c
68+
data/obl.c
69+
data/pattern_list.c
70+
data/player_parameters.c
71+
data/rclib.c
72+
data/save.c
73+
data/save_game.c
74+
data/save_game_progress.c
75+
data/save_payload.c
76+
data/save_player.c
77+
data/save_player_items.c
78+
data/scs.c
79+
data/spell_parameters.c
80+
data/table.c
81+
data/voc.c
82+
game/character_create.c
83+
game/companion.c
84+
game/belt.c
85+
game/collision.c
86+
game/equipment.c
3887
game/game.c
88+
game/ground_item.c
89+
game/inventory.c
90+
game/item_condition.c
91+
game/load_game.c
92+
game/movement.c
93+
game/player.c
94+
game/player_companion.c
95+
game/player_magic.c
96+
game/player_elements.c
97+
game/player_item.c
98+
game/player_loadout.c
99+
game/player_save.c
100+
game/player_profile.c
101+
game/route.c
102+
game/route_tables.c
103+
game/scenario_actor.c
104+
game/sound_event.c
105+
game/special_items.c
106+
game/title.c
107+
game/world.c
108+
game/world_conversation.c
109+
game/world_inventory.c
110+
game/world_magic.c
111+
game/world_save.c
112+
game/world_script.c
113+
interpreter/scenario_actor_script.c
114+
interpreter/scenario_script_commands.c
115+
interpreter/scenario_script_values.c
116+
render/depth.c
117+
render/dirty.c
39118
render/framebuffer.c
40-
render/title.c
119+
render/renderer.c
120+
screens/character_create_screen.c
121+
screens/gameplay_actor.c
122+
screens/gameplay_companion.c
123+
screens/gameplay_ground_item.c
124+
screens/gameplay_scene.c
125+
screens/gameplay_screen.c
126+
screens/gameplay_object_visual.c
127+
screens/gameplay_player.c
128+
screens/load_game_screen.c
129+
screens/title_screen.c
130+
ui/actor_nameplate.c
131+
ui/conversation_bubble.c
132+
ui/conversation_input.c
133+
ui/conversation_layout.c
134+
ui/gameplay_character_panel.c
135+
ui/gameplay_companion_hud.c
136+
ui/gameplay_companion_hud_input.c
137+
ui/gameplay_belt.c
138+
ui/gameplay_equipment_layout.c
139+
ui/gameplay_hud.c
140+
ui/gameplay_hud_input.c
141+
ui/gameplay_inventory.c
142+
ui/gameplay_inventory_input.c
143+
ui/gameplay_magic_input.c
144+
ui/gameplay_magic_layout.c
145+
ui/gameplay_magic.c
146+
ui/gameplay_panels_input.c
147+
ui/gameplay_item_information.c
148+
ui/gameplay_item_icon.c
149+
ui/gameplay_item_condition.c
150+
ui/gameplay_status_pattern.c
151+
ui/gameplay_status.c
152+
ui/gameplay_special_items.c
153+
ui/ground_item_nameplate.c
154+
ui/world_pointer.c
155+
ui/world_pointer_overlay.c
41156
)
42157
add_library(ShadowFlare::Core ALIAS shadowflare_core)
43158
sf_configure_c99_target(shadowflare_core)
@@ -46,13 +161,50 @@ add_executable(
46161
osf
47162
main.c
48163
runtime/application.c
164+
runtime/screen_runtime.c
49165
)
50166
add_executable(ShadowFlare::Game ALIAS osf)
51167
sf_configure_c99_target(osf)
168+
set(
169+
OPENSHADOWFLARE_C99_PRESENTATION_HZ
170+
"60"
171+
CACHE STRING
172+
"Presentation rate for the C99 game (30 or 60 Hz)"
173+
)
174+
set_property(
175+
CACHE OPENSHADOWFLARE_C99_PRESENTATION_HZ PROPERTY STRINGS 30 60)
176+
if(NOT OPENSHADOWFLARE_C99_PRESENTATION_HZ STREQUAL "30" AND
177+
NOT OPENSHADOWFLARE_C99_PRESENTATION_HZ STREQUAL "60")
178+
message(FATAL_ERROR "C99 presentation rate must be 30 or 60 Hz")
179+
endif()
180+
target_compile_definitions(
181+
osf PRIVATE SF_PRESENTATION_HZ=${OPENSHADOWFLARE_C99_PRESENTATION_HZ})
52182
target_link_libraries(
53183
osf
54184
PRIVATE
55185
ShadowFlare::Core
56186
Tal::Tal
57187
Twl::Twl
58188
)
189+
190+
if(OPENSHADOWFLARE_ENABLE_DEBUG_TOOLS)
191+
add_library(shadowflare_profiler STATIC runtime/profiler.c)
192+
add_library(ShadowFlare::Profiler ALIAS shadowflare_profiler)
193+
sf_configure_c99_target(shadowflare_profiler)
194+
target_link_libraries(osf PRIVATE ShadowFlare::Profiler)
195+
target_compile_definitions(osf PRIVATE SF_ENABLE_PROFILING=1)
196+
197+
add_executable(
198+
osf-measure
199+
../utils/osf-measure.c
200+
runtime/screen_runtime.c
201+
)
202+
sf_configure_c99_target(osf-measure)
203+
target_link_libraries(
204+
osf-measure
205+
PRIVATE
206+
ShadowFlare::Core
207+
Tal::Tal
208+
Twl::Twl
209+
)
210+
endif()

0 commit comments

Comments
 (0)