Compare commits
42
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56230dd340 | ||
|
|
df9fdf26c8 | ||
|
|
8f8fa8f8d1 | ||
|
|
07f98c119a | ||
|
|
d49194fc4d | ||
|
|
e61914bad4 | ||
|
|
015d90519f | ||
|
|
7b4f0abfb8 | ||
|
|
0667a44e14 | ||
|
|
0852b8463b | ||
|
|
1436fda858 | ||
|
|
0826908068 | ||
|
|
7ceb9e571d | ||
|
|
38c2f6b6f9 | ||
|
|
b9f06fef7a | ||
|
|
373f1c1010 | ||
|
|
e80d693d85 | ||
|
|
ef60ddf6a8 | ||
|
|
de0ff2e263 | ||
|
|
13a435e9c1 | ||
|
|
725338cd5a | ||
|
|
acd14f46a8 | ||
|
|
ef78f023ed | ||
|
|
85b6109792 | ||
|
|
6c5738c863 | ||
|
|
1174e471f6 | ||
|
|
a618ff46fe | ||
|
|
1fa5cd316e | ||
|
|
11e5d37563 | ||
|
|
9f86c20129 | ||
|
|
8fb1c9fb42 | ||
|
|
5f08337726 | ||
|
|
0bc80d5df3 | ||
|
|
2432443ea6 | ||
|
|
fa138971e7 | ||
|
|
d7982599d1 | ||
|
|
f16c80aa0f | ||
|
|
ef5adf8274 | ||
|
|
2ffc65b1b1 | ||
|
|
d4a17bd98d | ||
|
|
dcf5f434c5 | ||
|
|
78cd973a33 |
No files matched your search
@@ -0,0 +1,858 @@
|
||||
# Dusk Code Check
|
||||
|
||||
A working checklist for walking through `src/dusk/` (the core, platform-
|
||||
agnostic engine layer) one subsystem at a time and reviewing how it
|
||||
actually looks today -- not just what it's supposed to do. Pairs with
|
||||
`STATUS.md` (maturity snapshot) and `ROADMAP.md` (forward-looking work);
|
||||
this doc is about auditing what's already there.
|
||||
|
||||
Each section below: **Purpose**, **Key files**, and a **Review status**
|
||||
line to fill in as each system gets walked through (e.g. `Not started` /
|
||||
`In progress` / `Reviewed 2026-08-01: <one-line finding>`).
|
||||
|
||||
First full pass completed 2026-08-01 (all 23 sections below reviewed).
|
||||
See "Top cross-cutting findings" right after the index for the
|
||||
highest-priority items across all of them before diving into any one
|
||||
section -- this doc is long, don't make someone read all 23 to find
|
||||
the load-bearing bugs.
|
||||
|
||||
Game-specific code lives in `src/duskrpg/` (not covered here) and
|
||||
platform-specific implementations live in `src/dusk<platform>/` /
|
||||
`src/duskgl/` / `src/dusksdl2/` (also not covered here) -- see `CLAUDE.md`
|
||||
for the layer structure.
|
||||
|
||||
---
|
||||
|
||||
## Index
|
||||
|
||||
- [error](#error)
|
||||
- [assert](#assert)
|
||||
- [util](#util)
|
||||
- [event](#event)
|
||||
- [time](#time)
|
||||
- [thread](#thread)
|
||||
- [log](#log)
|
||||
- [system](#system)
|
||||
- [console](#console)
|
||||
- [asset](#asset)
|
||||
- [locale](#locale)
|
||||
- [save](#save)
|
||||
- [network](#network)
|
||||
- [display](#display)
|
||||
- [ui](#ui)
|
||||
- [entity](#entity)
|
||||
- [scene](#scene)
|
||||
- [physics](#physics)
|
||||
- [animation](#animation)
|
||||
- [script](#script)
|
||||
- [input](#input)
|
||||
- [engine](#engine)
|
||||
- [game](#game)
|
||||
|
||||
---
|
||||
|
||||
## Top cross-cutting findings
|
||||
|
||||
Ranked roughly by real-world impact, not by section order. Each links
|
||||
to its full writeup below.
|
||||
|
||||
1. **Bounds/capacity checks that matter at runtime are `assert*` calls,
|
||||
which compile to no-ops in release (`DUSK_ASSERTIONS_FAKED`, set
|
||||
whenever `NDEBUG` is defined) -- confirmed by reading `assert.h`
|
||||
directly.** This shows up in [entity](#entity) (`entitymanager.c`,
|
||||
`component.c` -- reachable from JerryScript via `moduleentity.c`
|
||||
with no return-value check) and [scene](#scene) (`sceneCreate`'s
|
||||
pool-exhaustion path, reachable from `new Scene()`). Untrusted
|
||||
script input can silently get back an invalid ID that later indexes
|
||||
a fixed array out of bounds in a release build -- the exact
|
||||
"validate untrusted data with errorThrow, not asserts" case
|
||||
CLAUDE.md/project memory already calls out, just not applied here.
|
||||
2. **FIXED 2026-08-01.** `util/ref.c`'s `refUnlock` decremented an
|
||||
unsigned `count` guarded only by a tautological `count >= 0` assert
|
||||
([util](#util)) -- a double-unlock silently underflowed to
|
||||
`UINT32_MAX` instead of tripping an assert. This wasn't just a
|
||||
`util/` nit: it's the lock/unlock primitive `asset/loader/assetentry.c`
|
||||
builds on (see [asset](#asset)), so an over-unlocked asset entry
|
||||
became permanently un-reapable rather than erroring loudly. Now
|
||||
asserts `count > 0` before decrementing; the pointless
|
||||
`count >= 0` check in `refLock` was removed too.
|
||||
3. **`texture.c:42-52`'s `textureInit()` reads `texture->format` to
|
||||
decide which `data` fields to validate *before* the struct is
|
||||
zeroed a few lines later** ([display](#display)) -- it's validating
|
||||
whatever stale value happened to be in the caller's (possibly
|
||||
stack) memory, not the `format` parameter actually being requested.
|
||||
4. **FIXED 2026-08-01 (confirmed real before fixing).** PSP's
|
||||
`timeGetRealTimeZonePSP` returned hours; every other platform
|
||||
(`timeGetRealTimeZoneLinux`/Dolphin) returns seconds, and
|
||||
`timeEpochInit`/`timeEpochGetHours` etc. add the timezone value
|
||||
directly to a Unix-epoch-seconds timestamp -- confirmed by reading
|
||||
all three platform implementations plus `timeepoch.c` directly, not
|
||||
just trusting the review agent's claim. The PSP function's own
|
||||
comment even said "Return timezone offset in hours". Now divides by
|
||||
`1000000.0` only (microseconds -> seconds), matching the other
|
||||
platforms. See [time](#time).
|
||||
5. **Discussed, not changed.** `consolePrint` aborts the process (via
|
||||
`stringFormatVA`'s `assert(ret < destSize)`) instead of truncating
|
||||
when a single debug line exceeds 511 bytes. This is a real, if rare,
|
||||
crash risk (any format producing >511 bytes of runtime-variable
|
||||
content -- a long path, a long error string -- takes the whole
|
||||
process down over a debug print), but changing `stringFormatVA`
|
||||
itself would affect every caller in the codebase, and a
|
||||
console-local truncating rewrite is easy to do wrong (vsnprintf
|
||||
directly, bypassing the project's string-utils convention) without
|
||||
more time to get right. Left as-is pending a decision on which
|
||||
fix shape is wanted. See [console](#console).
|
||||
6. **FIXED 2026-08-01.** `thread.c`'s `threadHandler` signaled
|
||||
`THREAD_STATE_STOPPED` before resetting `threadId = 0`, and
|
||||
`threadStartRequest` wasn't synchronized against that reset -- a
|
||||
real (if rare-window) race, not hypothetical: the test suite was
|
||||
already working around it by re-calling `threadInit()` instead of
|
||||
exercising true stop/start reuse. `threadId` is now reset inside the
|
||||
same mutex-locked section before the STOPPED signal/unlock;
|
||||
`test_thread_restart` now loops 20x on the same `thread_t` without
|
||||
re-initializing, which would have caught the old race. See
|
||||
[thread](#thread).
|
||||
7. **FIXED 2026-08-01.** `tools/color.py` emitted invalid C float
|
||||
literals (`0f`, `1f`, etc.) for any whole-number CSV channel --
|
||||
confirmed by actually running the generator against `color.csv`
|
||||
before and after. Was dormant only because `COLOR_*_3F`/`_4F` were
|
||||
unreferenced anywhere in the repo; the first real use of a float
|
||||
color variant wouldn't have compiled. Now routes channel values
|
||||
through Python `float()` before interpolating (always stringifies
|
||||
with a decimal point, e.g. `0.0`/`1.0`), and `test/display/test_color.c`
|
||||
gained two tests that reference `COLOR_BLACK_3F`/`COLOR_WHITE_4F`/
|
||||
`COLOR_RED_3B`/`COLOR_GRAY_3F` directly -- giving the previously-dead
|
||||
generated macros real compile-time + value coverage instead of
|
||||
silently bit-rotting again. See [display](#display).
|
||||
8. **`assetModelLoaderAsync` is confirmed fully dead** -- model loading
|
||||
is genuinely synchronous end-to-end (verified by tracing the state
|
||||
machine, not just repeating STATUS.md's claim). See [asset](#asset).
|
||||
9. **No cycle guard on prefab `extends` chains** in
|
||||
`scenePrefabResolveAndApply` -- a self-referencing or A->B->A prefab
|
||||
table is a stack-overflow crash from what looks like a harmless
|
||||
typo in hand-authored data. See [scene](#scene).
|
||||
10. **Untested-code hot spots worth prioritizing** if test investment
|
||||
is on the table: `util/ref.c`/`random.c`/`crypt.c`/`endian.c`
|
||||
(zero tests), `animation/easing.c` (13 of 16 functions untested),
|
||||
`event/`, `console/`, `system/`, `log/`, `input/`, `engine/`,
|
||||
`locale/`, `save/`, and most of `display/` (mesh, shader, texture,
|
||||
tileset, text, screen, framebuffer) have no dedicated tests at
|
||||
all.
|
||||
|
||||
Convention-only items (real, but lower stakes than the above): raw
|
||||
stdlib string functions (`strlen`/`strchr`/`strstr`/etc.) show up
|
||||
instead of `util/string.h` wrappers in `network/http/` and
|
||||
`asset/loader/locale/assetlocaleloader.c` ([network](#network),
|
||||
[asset](#asset)); several `display/mesh/` files use `//` header
|
||||
comments and `/* */` inline comments where CLAUDE.md wants the
|
||||
opposite ([display](#display)); `animation/`'s core files all use `//`
|
||||
copyright headers instead of `/** */` ([animation](#animation)).
|
||||
|
||||
---
|
||||
|
||||
## error
|
||||
|
||||
**Purpose:** The engine's single error-handling convention. Every
|
||||
fallible function returns `errorret_t`, built with `errorOk()` /
|
||||
`errorThrow(fmt, ...)` / `errorChain(call)` and consumed with
|
||||
`errorIsOk()`/`errorIsNotOk()`/`errorCatch()`. No `errno`, no raw error
|
||||
codes anywhere else in the engine.
|
||||
|
||||
**Key files:** `error.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Solid, and tested unusually well
|
||||
(`test/error/test_error.c` covers thread isolation and concurrent
|
||||
throws, not just happy path). Two issues: `errorChainImpl` (error.c:86-91)
|
||||
hand-rolls `snprintf`/`strlen` instead of `util/string.h`'s
|
||||
`stringFormat`/`stringFormatVA` wrappers that `errorThrowImpl` uses one
|
||||
function above it -- an inconsistency, not just a style nit, since
|
||||
CLAUDE.md requires the wrappers everywhere. `errorThrowWithCode`
|
||||
(error.h:100) is dead code -- zero call sites anywhere in `src/`/`test/`.
|
||||
|
||||
---
|
||||
|
||||
## assert
|
||||
|
||||
**Purpose:** Debug-time invariant checks -- `assertNotNull`, `assertTrue`,
|
||||
`assertFalse`, `assertUnreachable`, `assertIsMainThread`. Distinct from
|
||||
`error/`: asserts are for programmer mistakes/invariants, `errorret_t` is
|
||||
for runtime-recoverable failures (see `CLAUDE.md`'s note on validating
|
||||
untrusted data with `errorThrow` rather than asserting).
|
||||
|
||||
**Key files:** `assert.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Clean, no issues found. Impl
|
||||
functions + macros wrapping `__FILE__`/`__LINE__` and a proper
|
||||
`DUSK_ASSERTIONS_FAKED` no-op path for release builds;
|
||||
`assertNotNullImpl` (assert.c:109-111) does a real "touch" dereference
|
||||
after the null check as a belt-and-braces addition. Test coverage
|
||||
exercises both success and `expect_assert_failure` failure paths for
|
||||
every variant, including `assertDeprecated`/`assertIsMainThread`.
|
||||
|
||||
---
|
||||
|
||||
## util
|
||||
|
||||
**Purpose:** Small stand-alone helpers with no engine-state dependencies:
|
||||
`array` (dynamic array), `crypt` (hashing/checksum), `endian` (byte-order
|
||||
swap), `math` (clamp/lerp/pow2/etc.), `memory` (`memoryAllocate`/`Free`/
|
||||
`Zero`/`Copy`/`Compare` -- the only allocator the rest of the engine is
|
||||
allowed to call directly), `random`, `ref` (refcounted handle with
|
||||
lock/unlock callbacks), `sort` (bubble sort used for one-time static list
|
||||
ordering), `string` (`stringCopy`/`Compare`/`Format`/etc. -- required in
|
||||
place of libc `str*` functions per `CLAUDE.md`).
|
||||
|
||||
**Key files:** `array.c/h`, `crypt.c/h`, `endian.c/h`, `math.c/h`,
|
||||
`memory.c/h`, `random.c/h`, `ref.c/h`, `sort.c/h`, `string.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Several real issues, worst was
|
||||
in `ref.c`: `refUnlock` (ref.c:37-39) decremented `count` (`uint32_t`)
|
||||
guarded only by `assertTrue(ref->count >= 0, ...)` -- tautologically
|
||||
always true on an unsigned type, so a double-unlock silently underflowed
|
||||
to `UINT32_MAX` and kept invoking `onUnlock` instead of tripping an
|
||||
assert (confirmed by reading ref.c directly). **Fixed 2026-08-01** --
|
||||
`refUnlock` now asserts `count > 0` before decrementing; also fixed
|
||||
`refInit`'s doc comment, which claimed a fresh ref starts at count 1
|
||||
when the code has always started it at 0. Same tautological unsigned
|
||||
`>= 0` assert remains in `memory.c:98` (lower stakes -- `memoryFree`'s
|
||||
own counter, not a shared lock/unlock primitive other subsystems build
|
||||
on -- left as-is). `memory.h:11` declares
|
||||
`static size_t MEMORY_POINTERS_IN_USE = 0;` directly in the header --
|
||||
confirmed present -- meaning every TU including it gets its own private
|
||||
copy (only "works" because the accessors all live in memory.c).
|
||||
`random.c`'s `randomInt` (confirmed, random.c:15-16) does
|
||||
`rand() % (max - min)` with no `max > min` check (UB on `max <= min`),
|
||||
and `srand()` is never called anywhere in the repo -- unseeded,
|
||||
deterministic RNG. `sort.c:1` has `#include <stdlib.h>` before the
|
||||
copyright header (confirmed). Test coverage: array/math/memory/sort/
|
||||
string are thorough; `ref.c`, `random.c`, `crypt.c`, `endian.c` have
|
||||
**zero** tests. `randomInt`/`randomFloat` also appear unused
|
||||
engine-wide (dead code, not just untested).
|
||||
|
||||
---
|
||||
|
||||
## event
|
||||
|
||||
**Purpose:** Generic pub/sub primitive -- `event_t` wraps a caller-owned
|
||||
array of `eventcallback_t`/user-pointer pairs; `eventInit`/`eventSubscribe`/
|
||||
`eventInvoke`. Used for things like `uifullbox_t`'s transition-end
|
||||
callback and `uiloading_t`'s show/hide callbacks. Per `STATUS.md`: "Clean,
|
||||
small, finished", built to replace the old input system's callback
|
||||
pattern.
|
||||
|
||||
**Key files:** `event.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Well-formed -- correctly uses
|
||||
swap-with-last for O(1) unsubscribe, asserts on capacity overflow and
|
||||
duplicate-subscribe, no dead code (`eventUnsubscribe` used in 3 other
|
||||
files). No `errorret_t` needed here since these are programmer-error
|
||||
assertions rather than runtime-data validation, consistent with
|
||||
CLAUDE.md's assert-vs-error guidance. One gap: `test/event/` doesn't
|
||||
exist -- zero unit coverage, including the capacity-exceeded and
|
||||
double-subscribe assert paths.
|
||||
|
||||
---
|
||||
|
||||
## time
|
||||
|
||||
**Purpose:** Frame delta/elapsed time (`TIME.delta`, exposed to JS via
|
||||
`moduleTime`) plus `timeepoch_t` wall-clock timestamps (used by
|
||||
`uifps.c` for the FPS counter).
|
||||
|
||||
**Key files:** `time.c/h`, `timeepoch.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. `time.c:52-56` unconditionally
|
||||
formats an epoch string into a 256-byte stack buffer every single
|
||||
`timeUpdate()` call purely to feed a commented-out `consolePrint` --
|
||||
burns the leap-year/day-counting loop three times a frame for a
|
||||
discarded value. `timeepoch.c`'s day-counting loops have no
|
||||
handling/guard for negative epoch/timezone values (pre-1970). Test
|
||||
coverage is solid for `time.c` (mocked ticks, boundary/backwards-time
|
||||
cases) but `timeepoch.c`'s date math (leap year, rollover, format
|
||||
specifiers) has no dedicated tests despite being the more bug-prone
|
||||
half. The PSP-specific timezone unit bug flagged in the cross-cutting
|
||||
findings (#4) was confirmed and fixed 2026-08-01 --
|
||||
`timeGetRealTimeZonePSP` was returning hours where `timeepoch.c`
|
||||
expects seconds.
|
||||
|
||||
---
|
||||
|
||||
## thread
|
||||
|
||||
**Purpose:** Thin cross-platform thread/mutex/thread-local wrappers.
|
||||
Used by the asset system's background loading and the POSIX console's
|
||||
input-polling thread.
|
||||
|
||||
**Key files:** `thread.c/h`, `threadmutex.c/h`, `threadlocal.h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Conventions followed
|
||||
throughout. Real race condition, **fixed 2026-08-01**: `threadHandler`
|
||||
used to unlock `stateMutex` and signal `THREAD_STATE_STOPPED` *before*
|
||||
resetting `thread->threadId = 0`, but `threadStartRequest` asserts
|
||||
`threadId == 0` with no synchronization against that reset --
|
||||
`threadStop()` immediately followed by `threadStart()` on the same
|
||||
struct could intermittently trip the assert. Telling sign it was real,
|
||||
not theoretical: `test/thread/test_thread.c` already re-called
|
||||
`threadInit()` before restarting specifically "so threadId/state are
|
||||
reset" -- the test suite was working around the bug rather than
|
||||
exercising true reuse. `threadId` is now reset inside the same
|
||||
mutex-locked section, before the signal/unlock; the test now loops
|
||||
stop/start 20x on the same `thread_t` with no `threadInit()` in
|
||||
between. Otherwise test coverage is good (real pthreads, try-lock
|
||||
coordination, a 4-thread x 10k-iteration mutex contention test).
|
||||
|
||||
---
|
||||
|
||||
## log
|
||||
|
||||
**Purpose:** `logDebug`/`logError` -- the engine's only print/debug-output
|
||||
path. Header-only declarations; each platform provides the actual
|
||||
implementation (see `src/dusk<platform>/log/`).
|
||||
|
||||
**Key files:** `log.h` (declarations only, no `.c` in core).
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Clean 2-function API; all
|
||||
three platform implementations (`dusklinux`, `duskpsp`, `duskdolphin`)
|
||||
match the declared signatures with correct `va_copy` usage for the
|
||||
dual stdout+file writes. Dolphin's `logError` correctly falls back to
|
||||
raw VIDEO/console init when the framebuffer isn't ready yet and blocks
|
||||
on a START-button dismiss loop; PSP writes to
|
||||
`ms0:/PSP/GAME/Dusk/*.log`. No bugs found. No `test/log/` exists --
|
||||
understandable for I/O/side-effect code, but zero coverage.
|
||||
|
||||
---
|
||||
|
||||
## system
|
||||
|
||||
**Purpose:** Very early engine init (`systemInit`), the
|
||||
`systemplatform_t` enum (via the `systemplatformlist.h` X-macro pattern),
|
||||
and native OS dialog boxes (`systemdialogtype_t`: render-blocking vs
|
||||
tick-blocking).
|
||||
|
||||
**Key files:** `system.c/h`, `systemplatformlist.h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. X-macro platform enum and
|
||||
compile-time `#error` guards for missing platform macros used
|
||||
correctly; all three platforms define the required
|
||||
`systemInitPlatform`/`systemGetActiveDialogTypePlatform`/
|
||||
`systemGetCyclesPlatform`. Dead code confirmed: `systemPSPGetLanguage()`
|
||||
(`duskpsp/system/systempsp.c:51`) and `systemGetLanguageDolphin()`
|
||||
(`duskdolphin/system/systemdolphin.c:40`) are defined but never called
|
||||
anywhere -- likely intended for locale wiring that hasn't landed. No
|
||||
`test/system/` exists.
|
||||
|
||||
---
|
||||
|
||||
## console
|
||||
|
||||
**Purpose:** In-engine dev console: fixed-size scrollback
|
||||
(`CONSOLE_HISTORY_MAX` lines x `CONSOLE_LINE_MAX` chars), `consolePrint`,
|
||||
a `dirty` flag consumers (namely `ui/debug/uiconsole.c`) watch to know
|
||||
when to rebuild their own cached representation. POSIX builds also poll
|
||||
stdin on a background thread for interactive script execution.
|
||||
|
||||
**Key files:** `console.c/h`, `consoledefs.h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Two real issues. `consolePrint`
|
||||
(console.c:32-44) gets its length from `stringFormatVA(buffer,
|
||||
CONSOLE_LINE_MAX, ...)`, and `stringFormatVA` (util/string.c:100)
|
||||
**asserts** `ret < destSize` rather than truncating -- so any single
|
||||
debug line over 511 bytes aborts the process instead of just getting
|
||||
cut off, a harsh failure mode for a dev console. Separately,
|
||||
`consoleUpdate`'s doc ("Processes pending queued script lines") and
|
||||
`CONSOLE_EXEC_BUFFER_MAX` (consoledefs.h:12) describe a queued-script-
|
||||
execution feature that doesn't exist -- `console_t` has no exec-queue
|
||||
fields, `consoleUpdate` only toggles `visible`, and
|
||||
`CONSOLE_EXEC_BUFFER_MAX` is unreferenced elsewhere (dead constant,
|
||||
stale doc). No `test/console/` exists.
|
||||
|
||||
---
|
||||
|
||||
## asset
|
||||
|
||||
**Purpose:** The asset pipeline: `dusk.dsk` zip archive reading
|
||||
(`assetfile.c/h`), lock/ref-counted entries (`asset/loader/assetentry.c/h`,
|
||||
built on `util/ref.h`), batch loading (`assetbatch.c/h`), and the loader
|
||||
registry (`asset/loader/assetloader.c/h`, plus one subfolder per loader
|
||||
type: `dmf/` mesh+model, `display/` texture+tileset, `locale/`, `json/`,
|
||||
`animation/`). See `CLAUDE.md`'s "Adding a new asset loader type" for the
|
||||
extension pattern. Per `STATUS.md`: model loading's "async" path is
|
||||
actually synchronous -- the one known stub in core.
|
||||
|
||||
**Key files:** `asset.c/h`, `assetfile.c/h`, `assetbatch.c/h`,
|
||||
`loader/assetentry.c/h`, `loader/assetloader.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Core is well-structured and the
|
||||
multi-pass reaper correctly handles parent/child dependency chains.
|
||||
Found: `assetFileInit` (assetfile.c:29) has `if(!zip_stat(...) == 0)` --
|
||||
precedence makes this `(!zip_stat(...)) == 0`, which happens to
|
||||
evaluate correctly for zip's 0/nonzero convention but reads as broken
|
||||
and should just be `zip_stat(...) != 0`. More seriously,
|
||||
`assetEntryLock`/`Unlock` sit on top of `util/ref.c`'s confirmed
|
||||
double-unlock underflow bug (see **util** above) -- an over-unlocked
|
||||
asset entry silently becomes un-reapable forever instead of asserting.
|
||||
**Confirmed via code-trace** (not just citing STATUS.md):
|
||||
`assetModelLoaderAsync` (assetmodelloader.c:19-23) is genuinely dead --
|
||||
`assetEntryStartLoading` unconditionally sets
|
||||
`ASSET_ENTRY_STATE_PENDING_SYNC`, and `assetModelLoaderSync`'s state
|
||||
machine never transitions to `PENDING_ASYNC` the way mesh/texture/
|
||||
tileset/locale/json/animation all do, so model loading runs fully
|
||||
synchronously via `assetRequireLoaded`'s busy-loop; grep confirms
|
||||
`assetModelLoaderAsync` has no callers. `assetlocaleloader.c` uses raw
|
||||
stdlib (`strstr`/`strncmp`/`strchr`/`strtol`/`atoi`) instead of
|
||||
`util/string.h` wrappers throughout, and tests line-prefixes via
|
||||
`memoryCompare(lineBuffer, "msgid", 5)` without confirming the reused
|
||||
stack buffer actually holds 5 valid bytes at that point -- a short line
|
||||
could spuriously prefix-match against stale buffer contents. Test
|
||||
coverage: good breadth for entry lifecycle, tileset/JSON/animation
|
||||
loaders, and locale parsing; no dedicated tests for mesh/model/texture
|
||||
loader internals or `assetfile.c`'s line reader.
|
||||
|
||||
---
|
||||
|
||||
## locale
|
||||
|
||||
**Purpose:** Active-locale tracking (`LOCALE.locale`/`LOCALE.entry`) over
|
||||
`.po`-derived locale assets loaded through the asset system. See
|
||||
`assets/locale/en_US.po` -- per memory, currently placeholder/test
|
||||
content, not real shipped game text.
|
||||
|
||||
**Key files:** `localemanager.c/h`, `localeinfo.h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Clean, no bugs found --
|
||||
correctly balances `assetEntryLock`/`Unlock` in both `SetLocale` and
|
||||
`Dispose` (unlocks the old entry before adopting the new one). Minor
|
||||
nit: `localeinfo.h` declares `static const localeinfo_t` globals
|
||||
(`LOCALE_EN_US` etc.) directly in the header, so every including TU
|
||||
gets its own duplicate copy -- harmless given how few TUs include it.
|
||||
No `test/locale/` directory; `test/asset/test_assetlocale.c` tests the
|
||||
loader, not `localemanager.c` itself.
|
||||
|
||||
---
|
||||
|
||||
## save
|
||||
|
||||
**Purpose:** Slot-based save data (`SAVE_FILE_COUNT_MAX` fixed slots),
|
||||
yyjson documents persisted with size + CRC32 checksum. `saveLoad`/
|
||||
`saveSave` read/write JSON fresh every call; callers own the returned
|
||||
doc and must free it. Actual file I/O goes through platform stream hooks
|
||||
(`saveplatform_t`, one impl per platform) -- core `save.c` must never
|
||||
touch the filesystem directly. `savesettings.c/h` layers engine settings
|
||||
(display/audio/input/general) on top. Per `CLAUDE.md`: "mature, but
|
||||
undocumented" beyond the one paragraph there -- no tests.
|
||||
|
||||
**Key files:** `save.c/h`, `savefile.h`, `savestream.c/h`,
|
||||
`savesettings.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Clean and convention-compliant
|
||||
-- `save.c` genuinely never touches the filesystem directly (every I/O
|
||||
path goes through `saveXxxPlatform` macros, all three platforms define
|
||||
them), yyjson doc ownership is honored at every call site checked, and
|
||||
CRC32 is validated before parsing with every error path freeing `buf`.
|
||||
One real gap: `saveFileLoad`'s `memoryAllocate(file->size)`
|
||||
(savestream.c:122) allocates straight from an on-disk size field with
|
||||
no sanity bound before the allocation -- a corrupted/tampered save
|
||||
could request an oversized allocation, worth a max-size guard given the
|
||||
"never trust incoming data" principle (arguably applies to save files,
|
||||
not just network packets). Confirmed no `test/save/` exists. `saveDelete`/
|
||||
`saveExists`/`saveGet` are public API not yet called anywhere in the
|
||||
repo -- likely just unconsumed so far, not truly dead.
|
||||
|
||||
---
|
||||
|
||||
## network
|
||||
|
||||
**Purpose:** Connection-state layer only (`networkstate_t`:
|
||||
`DISCONNECTED`/`CONNECTING`/`CONNECTED`/`DISCONNECTING`) plus a one-off
|
||||
HTTP client (`network/http/`: request/header/URL/thread/process split
|
||||
across files). **Not** a multiplayer/replication protocol yet -- that's
|
||||
`ROADMAP.md` items 8-17. Platform-specific connection polling (PSP's
|
||||
`sceNetApctl`, GameCube/Wii's `if_config()`) lives under
|
||||
`src/dusk<platform>/network/`. Has HTTP tests only (`test/network/http/`).
|
||||
|
||||
**Key files:** `network.c/h`, `networkinfo.c/h`, `http/networkhttp.c/h`,
|
||||
`http/networkhttprequest.c/h`, `http/networkhttpthread.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Genuinely stays a thin
|
||||
connection-state layer (grepped for "packet"/"replicat"/"multiplayer"/
|
||||
"udp" -- no hits, no scope creep). The HTTP client correctly validates
|
||||
untrusted server input with `errorThrow` rather than trusting it
|
||||
(malformed status lines, oversized headers, bad `Content-Length`,
|
||||
early-closed connections all throw) -- exactly what CLAUDE.md calls
|
||||
out. `networkhttpthread.c`'s request handoff is actually correct
|
||||
despite request fields being written outside the mutex: the final
|
||||
`state = PENDING` write happens under the same mutex the worker
|
||||
acquires, giving a valid release/acquire handoff (worth a comment, not
|
||||
a bug). One recurring convention violation:
|
||||
`networkhttpprocess.c`/`networkhttpurl.c` use raw stdlib
|
||||
`strlen`/`strchr`/`strstr`/`strncasecmp`/`strcspn` instead of
|
||||
`util/string.h` wrappers in several places -- `util/string.h` currently
|
||||
has no direct substitute for `strchr`/`strstr`/`strcspn`, so this may
|
||||
be a missing-utility gap rather than pure oversight. No leaks found
|
||||
(request/response bodies freed exactly once via
|
||||
`networkHttpRequestReset`, redirect loop frees the intermediate body).
|
||||
Real test coverage exists: `test/network/http/test_networkhttp.c` runs
|
||||
six tests against a fake loopback server (GET/POST/PUT, query encoding,
|
||||
redirects, connection-refused), each asserting zero leaked allocations.
|
||||
|
||||
---
|
||||
|
||||
## display
|
||||
|
||||
**Purpose:** The engine's most mature, most-optimized subsystem --
|
||||
platform-agnostic rendering built on top of `duskgl`/`duskdolphin`.
|
||||
Subfolders: `mesh/` (primitive builders: cube/sphere/capsule/plane/
|
||||
triprism/quad, plus the shared `meshvertex_t`/`mesh_t` API), `shader/`
|
||||
(currently one material type, unlit), `spritebatch/` (the shared
|
||||
`SPRITEBATCH_SPRITES_MAX`-capacity quad batcher everything 2D goes
|
||||
through -- flushes on shader/material change), `texture/` (texture +
|
||||
tileset + palette), `text/` (`font_t`/`FONT_DEFAULT`'s baked-in bitmap
|
||||
glyphs, `textBuildSpriteCache`/`textDrawSpriteCache`'s build-once/
|
||||
translate-per-frame pattern), `screen/` (scan-safe area), `framebuffer/`.
|
||||
`color.csv` + `tools/color/csv/__main__.py` code-generate `color.h` --
|
||||
never hand-edit the generated header.
|
||||
|
||||
**Key files:** `display.c/h`, `mesh/mesh.c/h`, `spritebatch/spritebatch.c/h`,
|
||||
`spritebatch/spritebatchsprite.c/h`, `text/font.c/h`, `text/text.c/h`,
|
||||
`texture/texture.c/h`, `texture/tileset.c/h`, `shader/shader.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. "Most mature" oversold it
|
||||
slightly -- real bugs found, several confirmed by direct read:
|
||||
- **texture.c:42-52 (confirmed)** -- `textureInit()` branches on
|
||||
`texture->format` to validate the incoming `data` union *before*
|
||||
`memoryZero(texture, ...)` runs a few lines later, so it's reading
|
||||
whatever stale/uninitialized value was already in the caller's
|
||||
struct, not the `format` parameter actually being requested.
|
||||
Validation is effectively checking garbage.
|
||||
- `spritebatchsprite.c:20-25` -- `spriteBatchSpriteTilesetPosition`'s
|
||||
zero-width/height early return zeroes `sprite.min`/`max` but leaves
|
||||
`uvMin`/`uvMax` uninitialized (stack garbage); the existing
|
||||
zero-size test doesn't check uv fields, so this isn't caught.
|
||||
- `mesh.c:43` -- `meshFlush`'s offset assert (`vertexOffset <
|
||||
vertCount - 1`) wrongly rejects a valid offset at the very last
|
||||
vertex; off-by-one.
|
||||
- `text.c:34-37` -- bounds assert uses `tileIndex <= tileCount`
|
||||
(should be `<`), currently unreachable in practice since a preceding
|
||||
clamp already guards it, but the assert itself is wrong.
|
||||
- `framebuffer.c:23-28` -- `frameBufferBind(NULL)` recurses into
|
||||
binding the backbuffer without `errorChain`, discarding any failure
|
||||
and unconditionally returning `errorOk()`.
|
||||
- `displayInit()`'s six static "SIMPLE" primitive meshes
|
||||
(quad/cube/sphere/plane/capsule/triprism) are never disposed in
|
||||
`displayDispose()` -- one VBO+VAO leaked per primitive on the
|
||||
non-legacy GL path.
|
||||
- **Confirmed and fixed 2026-08-01.** `tools/color.py` (not the
|
||||
`tools/color/csv/__main__.py` path CLAUDE.md's doc comment names --
|
||||
that's a stale path, only a `__pycache__/` remnant exists there; the
|
||||
live script is `tools/color.py`) emitted invalid C float literals
|
||||
for whole-number CSV channels (`0`, `1` -- every black/white/primary
|
||||
color), e.g. `color3f(0f, 0f, 0f)`. Was harmless *only* because
|
||||
`COLOR_*_3F`/`_4F` were never referenced anywhere in `src/`/`test/`
|
||||
-- confirmed by actually running the generator before and after the
|
||||
fix, not just reading the source. Now routes channel values through
|
||||
Python `float()` first (always stringifies with a decimal point);
|
||||
`test/display/test_color.c` gained tests referencing
|
||||
`COLOR_BLACK_3F`/`COLOR_WHITE_4F`/`COLOR_RED_3B`/`COLOR_GRAY_3F`
|
||||
directly so the previously-dead macros now have real compile-time +
|
||||
value coverage.
|
||||
- Style drift: `mesh.h` uses `//` header comments instead of `/** */`;
|
||||
sphere/capsule/triprism use `/* */` block comments inside function
|
||||
bodies where CLAUDE.md mandates `//`; every primitive builder's
|
||||
JSDoc still documents a `@param color` that no longer exists in the
|
||||
signature (leftover from before color moved out of `meshvertex_t`).
|
||||
- The primitive `*Buffer()` flexible-geometry functions (sphereBuffer,
|
||||
capsuleBuffer, etc.) are confirmed unused outside their own
|
||||
`*Init()` -- only the fixed default mesh instances are actually
|
||||
consumed (via `script/module/display/modulemesh.c`).
|
||||
|
||||
Test coverage: `test/display/` only registers `test_color.c` and
|
||||
`test_spritebatchsprite.c` -- mesh/shader/texture/tileset/palette/text/
|
||||
font/screen/framebuffer all have zero unit tests.
|
||||
|
||||
---
|
||||
|
||||
## ui
|
||||
|
||||
**Purpose:** Flat, static, singleton-driven widget framework -- no scene
|
||||
graph. Top level is a compile-time X-macro registry
|
||||
(`uielementlist.h`/`uielement.c/h`) of `{init, update, draw, dispose,
|
||||
order}` tuples (screens: frame/confirm/settings/overlays/console/fps),
|
||||
spliced with `duskrpg`'s own list. Composition below that is `uimenu_t`
|
||||
(`widget/uimenu.c/h`) -- a flat tagged-union array of widgets laid out in
|
||||
a simple row/column grid via the `MENU_*` authoring macros; no nesting.
|
||||
Widgets: `uilabel`/`uiwidgetlabel` (cached glyph sprites, the pattern
|
||||
every other widget's text now uses), `uibutton`, `uicheckbox`,
|
||||
`uislider`, `uidropdown`, `uitab`, `uiscrolling` (empty placeholder).
|
||||
`focus/` is the gamepad/keyboard directional-navigation stack (no mouse/
|
||||
pointer hit-testing exists anywhere). `frame/` is the 9-slice box plus
|
||||
the confirm dialog and settings screens. `overlay/` is fullscreen
|
||||
fades/loading/crop bars. `debug/` is the FPS counter and dev console
|
||||
renderer.
|
||||
|
||||
As of 2026-07-31: slider/tab/frame (`uiFrameDrawCached`)/duskrpg's
|
||||
textbox all cache their sprite geometry instead of rebuilding it every
|
||||
frame; console uses a fixed-size vertex buffer instead of alloc/free.
|
||||
Still open: sprite-batch flushes are keyed on material/color, so
|
||||
per-widget highlight-color changes still force a flush per widget (see
|
||||
`ROADMAP.md` item 5 in the debt backlog). No JS bindings exist for UI
|
||||
yet. `test/ui/`/`test/display/test_spritebatchsprite.c` cover the new
|
||||
caching *logic* only -- nothing exercises real `uiXxxDraw()` calls, since
|
||||
those need a live GL context (`FONT_DEFAULT`/`UI_FRAME` textures) this
|
||||
repo's test binaries don't have.
|
||||
|
||||
**Key files:** `ui.c/h`, `uielement.c/h`, `focus/uifocus.c/h`,
|
||||
`widget/uimenu.c/h`, `widget/uilabel.c/h`, `frame/uiframe.c/h`,
|
||||
`debug/uiconsole.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-07-31 (this session's sprite-caching
|
||||
pass) -- see notes above; per-material flush granularity and hit-testing
|
||||
still open.
|
||||
|
||||
---
|
||||
|
||||
## entity
|
||||
|
||||
**Purpose:** Fixed-size-array ECS. `entitymanager_t` owns
|
||||
`ENTITY_COUNT_MAX` entities, each with up to `ENTITY_COMPONENT_COUNT_MAX`
|
||||
components stored in a tagged union (`componentdata_t` -- flagged in
|
||||
`PSP_OPTIMIZATION_PLAN.md` as the biggest PSP memory-waste candidate,
|
||||
since every entity reserves space for every component type's largest
|
||||
variant). `componentlist.h`'s `X()` macro auto-generates the component
|
||||
enum/union/dispatch table from `entity/component/**`; engine-level
|
||||
`entityprefablist.h` is an empty sentinel (real prefabs live in
|
||||
`duskrpg/entity/entityprefablist.h`, resolved via
|
||||
`entityPrefabResolveAndApply`). No JSON serialize/deserialize (removed by
|
||||
design in favor of C-coded prefabs or JerryScript `Entity`/`Component`).
|
||||
|
||||
**Key files:** `entitymanager.c/h`, `entity.c/h`, `component.c/h`,
|
||||
`componentlist.h`, `entityprefab.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Structurally sound (sentinel
|
||||
prefab list, X-macro shape both match CLAUDE.md), but there's a real
|
||||
security-relevant gap: **every capacity/bounds guard
|
||||
(`entitymanager.c:35`, `entity.c:56`, `component.c:37-39,58-62,75-76,
|
||||
140-141`) is an `assert*` call**, and `assert.h` compiles these to
|
||||
`((void)0)` under `DUSK_ASSERTIONS_FAKED` (auto-set whenever `NDEBUG`
|
||||
is defined -- confirmed by reading assert.h directly, this is a real
|
||||
release-mode no-op, not a hypothetical). `moduleentity.c:30,67` create
|
||||
entities/components from JerryScript with no return-value check, so a
|
||||
script that exceeds `ENTITY_COUNT_MAX`/the per-entity component cap
|
||||
silently gets back an invalid ID in release builds, which then indexes
|
||||
fixed arrays out-of-bounds later. This directly contradicts the
|
||||
project's own "untrusted-data limits need errorThrow, not asserts"
|
||||
guidance -- and script input is about as untrusted as it gets. Minor:
|
||||
`component.h:100`/`component.c:52` misplace the `*` in `void *
|
||||
componentGetData(`. Dead code: `entityUpdateRemove`/
|
||||
`entityDisposeRemove`/`entityDisposeAdd` have zero call sites.
|
||||
|
||||
---
|
||||
|
||||
## scene
|
||||
|
||||
**Purpose:** Same shape as `entity/` one level up -- `SCENE_COUNT_MAX`
|
||||
fixed-count scenes, each an isolated entity-manager pool; engine-level
|
||||
`sceneprefablist.h` is an empty sentinel (real prefabs in
|
||||
`duskrpg/scene/`). As of the `Scene.set()` work (2026-07-31), JerryScript
|
||||
can install a `{init, update, dispose}` module as the active scene via
|
||||
`modulescene.c`'s `moduleSceneSetStatic`/`moduleSceneUpdateCurrent`/
|
||||
`moduleSceneTeardownCurrent` (see `script` below) -- scene IDs are reused
|
||||
from a small pool immediately after `sceneDestroy`, so don't assume a
|
||||
freshly created scene has a "new" ID.
|
||||
|
||||
**Key files:** `scene.c/h`, `scenebase.h`, `sceneprefab.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Shares entity/'s assert-not-
|
||||
errorThrow bounds gap (`sceneCreate` hits `assertUnreachable` then
|
||||
falls through to `SCENE_ID_INVALID` on pool exhaustion in release --
|
||||
reachable from `new Scene()` in JS). Additional finding:
|
||||
`scenePrefabResolveAndApply`/`scenePrefabInit` (sceneprefab.c:31-54)
|
||||
recurse through a prefab's `extends` chain with **no cycle guard** -- a
|
||||
self-referencing or A→B→A prefab table causes unbounded recursion/
|
||||
stack overflow from what's otherwise a one-typo mistake in a
|
||||
hand-authored prefab list. No dead code, no use-after-free. Tests cover
|
||||
create/destroy/isolation/update cadence well but have zero coverage for
|
||||
pool exhaustion, `sceneRender()`, or `sceneprefab.c` (no prefab test
|
||||
file exists at all).
|
||||
|
||||
---
|
||||
|
||||
## physics
|
||||
|
||||
**Purpose:** `physicsworld_t` step simulation over `physicsbodytype_t`
|
||||
(static/dynamic/kinematic) and `physicshapetype_t` (cube/sphere/capsule/
|
||||
plane/custom, plus mesh shapes via `physicsshapemesh.c/h`).
|
||||
`triggersystem.c/h` layers trigger-volume enter/exit events on top. Per
|
||||
`STATUS.md`: "mature, recently churned" -- a revert/re-disable of "old
|
||||
ent code" suggests component wiring isn't fully settled yet. Well
|
||||
tested (`test/physics/`).
|
||||
|
||||
**Key files:** `physicsworld.c/h`, `physicsbodytype.h`, `physicsshape.h`,
|
||||
`physicsshapemesh.c/h`, `triggersystem.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. `STATUS.md`'s "component
|
||||
wiring isn't fully settled" caveat looks stale on closer look:
|
||||
`physicsWorldStep`/`triggerSystemStep` are live-wired in `scene.c:89-90`
|
||||
and `duskrpg`'s player prefab actively uses both PHYSICS and TRIGGER --
|
||||
no `#if 0`/TODO/commented-out code found; the disable-then-revert in
|
||||
history reads like a same-day whole-ECS revert, not something
|
||||
physics-specific. Two real bugs found instead:
|
||||
`physicsbodytype.h:23-27` documents kinematic bodies as capable of
|
||||
being a player controller, but `physicsworld.c:124,166-167` only ever
|
||||
writes `onGround` for the dynamic side of a collision pair -- a
|
||||
kinematic controller's `onGround` is permanently false (latent today,
|
||||
since the one existing player prefab uses DYNAMIC, not KINEMATIC).
|
||||
`physicstest.c:213`'s barycentric interior-test branch has no guard
|
||||
against a zero-area triangle (divide-by-zero/NaN risk in mesh-sphere
|
||||
collision). Dead code: `physicsShapeMeshCreate` (mesh-terrain
|
||||
collision) has zero production callers despite being well-tested in
|
||||
isolation; `entityPhysicsGetShape`/`GetCollideMask` are unwired to the
|
||||
JS module. Test depth is genuinely strong for what's implemented
|
||||
(gravity convergence, dynamic-vs-dynamic separation, mask filtering,
|
||||
mesh sphere/capsule resting) -- "well tested" is earned for the
|
||||
features that exist, though the unused mesh-collision path and
|
||||
missing trigger→JS bridge mean the subsystem's *integration* maturity
|
||||
is a bit narrower than its test depth suggests.
|
||||
|
||||
---
|
||||
|
||||
## animation
|
||||
|
||||
**Purpose:** Keyframe + easing only -- no blend trees or state machines
|
||||
yet. `keyframe_t`/`keyframeset_t` interpolate values over time via
|
||||
`easing.c/h`'s easing functions; `animation.c/h` ties a keyframe set to
|
||||
playback state. Per `STATUS.md`: terse commit history ("ANIM") suggests
|
||||
still iterating.
|
||||
|
||||
**Key files:** `animation.c/h`, `easing.c/h`, `keyframe.c/h`,
|
||||
`keyframeset.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. All 8 core files use `//`
|
||||
copyright headers instead of the required `/** */` block, inconsistent
|
||||
with the correctly-formatted `entityanimation.{c,h}` next door. Math
|
||||
checks out: all 16 easing functions satisfy f(0)=0/f(1)=1 with no
|
||||
precision issues, and keyframe interpolation clamps (doesn't
|
||||
extrapolate) outside the time range with no reachable divide-by-zero
|
||||
-- though it doesn't validate that keyframe times are ascending. 15 of
|
||||
16 `easing.h` declarations lack Javadoc. Biggest gap: **no
|
||||
`test_easing.c` exists** -- only linear/in-quad get incidental coverage
|
||||
via `test_keyframe.c`, so 13 of 16 easing functions are completely
|
||||
untested. Dead code (test-only, unused by any `duskrpg` game code):
|
||||
`keyframeSetGetValues`, `keyframeSetFireCallback`, `animationSetEvent`,
|
||||
`entityAnimationSetKeyframes`/`GetValue`.
|
||||
|
||||
---
|
||||
|
||||
## script
|
||||
|
||||
**Purpose:** Embedded JerryScript integration. `scriptmanager.c/h` owns
|
||||
the JerryScript context lifecycle and the exec/call helpers
|
||||
(`scriptManagerExec`/`ExecFile`/`CallGlobal`/`CallValue`, the last two
|
||||
sharing exception + promise-draining logic). `scriptproto.c/h` is the
|
||||
`scriptproto_t` prototype-wrapping helper every module builds on.
|
||||
`module/` holds each registered JS-facing module:
|
||||
- `modulebase.h` -- the shared macro toolkit (`moduleBaseFunction`,
|
||||
`moduleBaseRequireArgs`/`RequireString`/etc., `moduleBaseDefineProp`/
|
||||
`Func`/`StaticFunc`, `moduleBaseSetWrappedPointer`, `moduleBaseThrowError`).
|
||||
- `moduleplatform.h`, `entity/moduleentity.c/h` +
|
||||
`entity/component/*` (generic `Component` plus typed Position/Physics/
|
||||
Renderable wrappers via `modulecomponentlist.c/h`), `scene/modulescene.c/h`
|
||||
(`Scene`, including `Scene.set()`), `display/modulemesh.c/h`,
|
||||
`time/moduletime.c/h`, `require/modulerequire.c/h` (CommonJS-style
|
||||
`require()`/`module.exports`, with a directory stack for relative
|
||||
resolution -- `scriptManagerExecFile` now pushes its own file's
|
||||
directory before exec so a top-level entry script's relative
|
||||
`require()` calls resolve correctly).
|
||||
- `modulelist.c/h` -- registers/disposes every module above in order;
|
||||
`moduleListDispose()` is now actually called from
|
||||
`scriptManagerDispose()` (was a latent bug -- it wasn't, until
|
||||
2026-07-31).
|
||||
|
||||
Entry point convention: `assets/scripts/init.js` does
|
||||
`require('./scenefile.js')` + `Scene.set(module)`. Has unit tests
|
||||
(`test/script/`), including one that reads the real shipped
|
||||
`overworldscene.js` off disk rather than an embedded copy.
|
||||
|
||||
**Key files:** `scriptmanager.c/h`, `scriptproto.c/h`,
|
||||
`module/modulebase.h`, `module/modulelist.c/h`,
|
||||
`module/require/modulerequire.c/h`, `module/scene/modulescene.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-07-31 (this session's Scene.set() +
|
||||
require()-dir-stack work) -- see notes above.
|
||||
|
||||
---
|
||||
|
||||
## input
|
||||
|
||||
**Purpose:** Bind-based input (`inputaction.c/h` maps
|
||||
`INPUT_BIND_*` names to raw `inputbutton_t`s per platform), with a
|
||||
configurable analog deadzone. Platform button/axis backends live under
|
||||
`src/dusk<platform>/input/`; capability macros (`DUSK_INPUT_GAMEPAD`/
|
||||
`KEYBOARD`/`POINTER`) gate what's available per target. Pointer axis
|
||||
values are plumbed through (`DUSK_INPUT_POINTER`), but nothing in `ui/`
|
||||
consumes them yet -- no hit-testing exists (see `ui` above).
|
||||
|
||||
**Key files:** `input.c/h`, `inputaction.c/h`, `inputbutton.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Clean and convention-compliant;
|
||||
deadzone math (`inputDeadzone`, input.c:244) is correct and safe. One
|
||||
naming nit: `inputBind`'s param is named `act` in input.h:216 while its
|
||||
own doc comment calls it `action`. **Confirmed, not just cited from
|
||||
STATUS.md**: pointer input is genuinely wired end-to-end, not a
|
||||
dead-end at the platform layer -- SDL2's `inputUpdateSDL2` populates
|
||||
`INPUT.platform.mouseX/Y`/scroll from `SDL_GetMouseState`,
|
||||
`inputButtonGetValueSDL2` handles the pointer-axis cases, and
|
||||
`duskrpg/input/inputbindmap.h` binds `mouse_x`/`mouse_y` to
|
||||
`INPUT_BIND_POINTERX/Y`. The dead end is specifically at the
|
||||
*consumption* layer: grepping `src/dusk/ui/` for those binds or any
|
||||
pointer-axis read turns up nothing -- exactly as STATUS.md says, just
|
||||
now confirmed rather than assumed. No tests exist for `input/`.
|
||||
|
||||
---
|
||||
|
||||
## engine
|
||||
|
||||
**Purpose:** Top-level init/update/dispose orchestration
|
||||
(`engineInit`/`engineUpdate`/`engineDispose`) -- the thing `main.c` calls,
|
||||
which in turn calls into every subsystem above plus `game/gameInit` etc.
|
||||
`ENGINE.running`/`ENGINE.version` are the only bits of global state
|
||||
outside the per-subsystem structs.
|
||||
|
||||
**Key files:** `engine.c/h`.
|
||||
|
||||
**Review status:** Reviewed 2026-08-01, confirmed by direct read of
|
||||
`engineInit`/`engineDispose`. Init order is safe (time -> console ->
|
||||
system -> input -> asset -> scriptManager -> save/saveSettings ->
|
||||
locale -> display -> ui -> network -> scene -> game), with display
|
||||
before UI and scriptManager before scene/game so JS `Entity`/`Scene`
|
||||
wrappers exist before any script runs. `engineDispose` is **not** a
|
||||
clean reverse of that order, though: `localeManagerDispose()` runs
|
||||
*before* `uiDispose()`/`displayDispose()`, even though locale was
|
||||
initialized *before* both -- correct reverse order would tear down
|
||||
UI/display first, and as written there's a real risk of UI/display
|
||||
teardown code touching already-freed locale data (e.g. any localized
|
||||
string still held/logged during dispose). Separately, `void
|
||||
engineExit(void)` (engine.c:95) is defined but **not declared in
|
||||
engine.h**, and a repo-wide grep finds no caller anywhere -- dead,
|
||||
unreachable, and in violation of the "every public function must be
|
||||
declared in its header" rule. No tests exist for `engine/`.
|
||||
|
||||
---
|
||||
|
||||
## game
|
||||
|
||||
**Purpose:** Intentionally header-only in core -- just declares
|
||||
`gameInit`/`gameUpdate`/`gameDispose`. The real implementation is
|
||||
`src/duskrpg/game/game.c` (currently: runs `scripts/init.js` on init).
|
||||
|
||||
**Key files:** `game.h` (no `.c` in core).
|
||||
|
||||
**Review status:** Reviewed 2026-08-01. Confirmed: no `.c` file exists
|
||||
in `src/dusk/game/` (only `game.h` + `CMakeLists.txt`) -- a pure
|
||||
interface, as intended. The real `src/duskrpg/game/game.c`
|
||||
implementation is a thin JS-bootstrap shim: `gameInit` just does
|
||||
`errorChain(scriptManagerExecFile("scripts/init.js", NULL))`, while
|
||||
`gameUpdate`/`gameDispose` are both empty (`errorOk()` only). Not a
|
||||
bug -- consistent with the ongoing migration of game logic into JS --
|
||||
but worth flagging as "not yet fleshed out" rather than broken if
|
||||
anything is expected to happen there per-frame at the C layer. No
|
||||
tests exist for this layer.
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
git \
|
||||
libssl-dev
|
||||
- name: Build Linux
|
||||
run: ./scripts/linux/build-linux.sh
|
||||
run: ./scripts/build-linux.sh
|
||||
- name: Upload Linux binary
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
- name: Setup pspdev
|
||||
uses: ./.github/actions/setup-pspdev
|
||||
- name: Build PSP
|
||||
run: ./scripts/psp/build-psp.sh
|
||||
run: ./scripts/build-psp.sh
|
||||
- name: Move EBOOT.PBP to Dusk subfolder
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk/PSP/GAME/Dusk
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
libgles2:arm64 \
|
||||
libgl1-mesa-dev:arm64
|
||||
- name: Build Knulli
|
||||
run: ./scripts/knulli/build-knulli.sh
|
||||
run: ./scripts/build-knulli.sh
|
||||
- name: Move output to Dusk subfolder
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
||||
- name: Build GameCube
|
||||
run: ./scripts/gamecube/build-gamecube.sh
|
||||
run: ./scripts/build-gamecube.sh
|
||||
- name: Copy output files
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk
|
||||
@@ -166,7 +166,7 @@ jobs:
|
||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
||||
- name: Build GameCube ISO
|
||||
run: ./scripts/gamecube/build-gamecube-iso.sh
|
||||
run: ./scripts/build-gamecube-iso.sh
|
||||
- name: Copy output files
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk
|
||||
@@ -199,7 +199,7 @@ jobs:
|
||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
||||
- name: Build Wii
|
||||
run: ./scripts/wii/build-wii.sh
|
||||
run: ./scripts/build-wii.sh
|
||||
- name: Copy output files
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
||||
@@ -232,7 +232,7 @@ jobs:
|
||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
||||
- name: Build Wii ISO
|
||||
run: ./scripts/wii/build-wii-iso.sh
|
||||
run: ./scripts/build-wii-iso.sh
|
||||
- name: Copy output files
|
||||
run: |
|
||||
mkdir -p ./git-artifcats/Dusk
|
||||
|
||||
@@ -32,4 +32,75 @@ jobs:
|
||||
git \
|
||||
libssl-dev
|
||||
- name: Run tests
|
||||
run: ./scripts/linux/test-linux.sh
|
||||
run: ./scripts/test-linux.sh
|
||||
|
||||
# Emulator smoke tests: boot the built disc/EBOOT for a fixed window and
|
||||
# confirm the emulator doesn't crash. Not yet verified against a real
|
||||
# runner (no CI run has exercised these) -- continue-on-error so a
|
||||
# flaky/broken emulator step doesn't block the required Linux test job.
|
||||
run-tests-gamecube-dolphin:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ghcr.io/extremscorner/libogc2:latest
|
||||
steps:
|
||||
- name: Install Node.js
|
||||
run: apt-get update && apt-get install -y nodejs
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Install additional dependencies
|
||||
run: |
|
||||
apt-get install -y \
|
||||
python3-pip python3-polib python3-pil \
|
||||
python3-dotenv python3-pyqt5 python3-opengl xorriso \
|
||||
dolphin-emu xvfb
|
||||
dkp-pacman -Syu --noconfirm
|
||||
dkp-pacman -S --needed --noconfirm \
|
||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
||||
- name: Build GameCube ISO and boot it in Dolphin
|
||||
run: ./scripts/test-gamecube-dolphin.sh
|
||||
|
||||
run-tests-wii-dolphin:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ghcr.io/extremscorner/libogc2:latest
|
||||
steps:
|
||||
- name: Install Node.js
|
||||
run: apt-get update && apt-get install -y nodejs
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Install additional dependencies
|
||||
run: |
|
||||
apt-get install -y \
|
||||
python3-pip python3-polib python3-pil \
|
||||
python3-dotenv python3-pyqt5 python3-opengl xorriso \
|
||||
dolphin-emu xvfb
|
||||
dkp-pacman -Syu --noconfirm
|
||||
dkp-pacman -S --needed --noconfirm \
|
||||
gamecube-sdl2 ppc-liblzma ppc-libzip \
|
||||
gamecube-tools ppc-libmad ppc-zlib-ng ppc-bzip2 ppc-zstd
|
||||
- name: Build Wii ISO and boot it in Dolphin
|
||||
run: ./scripts/test-wii-dolphin.sh
|
||||
|
||||
run-tests-psp-ppsspp:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup pspdev
|
||||
uses: ./.github/actions/setup-pspdev
|
||||
- name: Install PPSSPPHeadless build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y git cmake ninja-build libsdl2-dev zlib1g-dev
|
||||
- name: Build PPSSPPHeadless
|
||||
run: |
|
||||
git clone --recursive --depth 1 https://github.com/hrydgard/ppsspp.git /tmp/ppsspp
|
||||
cmake -S /tmp/ppsspp -B /tmp/ppsspp/build -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build /tmp/ppsspp/build --target PPSSPPHeadless -- -j$(nproc)
|
||||
echo "PPSSPP_HEADLESS_BIN=/tmp/ppsspp/build/PPSSPPHeadless" >> "$GITHUB_ENV"
|
||||
- name: Build PSP EBOOT and boot it in PPSSPPHeadless
|
||||
run: ./scripts/test-psp-ppsspp.sh
|
||||
+1
-2
@@ -106,5 +106,4 @@ yarn.lock
|
||||
/build*
|
||||
/assets/test
|
||||
/tools_old
|
||||
/assets/test.png
|
||||
/assets/audio/boa.mp3
|
||||
/assets/test.png
|
||||
@@ -0,0 +1,549 @@
|
||||
# Dusk — Claude Code rules
|
||||
|
||||
See `STATUS.md` for a periodically-refreshed inventory of subsystem
|
||||
maturity, test coverage gaps, and known open issues — check it before
|
||||
assuming a subsystem is fully wired up or before picking a next task.
|
||||
|
||||
## File headers
|
||||
Every C, H, and JS file starts with:
|
||||
|
||||
```c
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
```
|
||||
|
||||
JS files use `//` comment style instead.
|
||||
|
||||
---
|
||||
|
||||
## C conventions
|
||||
|
||||
### Types
|
||||
Always use the project-defined aliases instead of bare C primitives:
|
||||
|
||||
| Use | Not |
|
||||
|-----------|--------------|
|
||||
| `bool_t` | `bool` |
|
||||
| `int_t` | `int` |
|
||||
| `float_t` | `float` |
|
||||
| `char_t` | `char` |
|
||||
|
||||
Use `uint8_t`, `uint16_t`, `int32_t`, etc. for fixed-width integers.
|
||||
All struct and enum types end in `_t` (`animation_t`, `errorret_t`, …).
|
||||
|
||||
### Naming
|
||||
- **Functions** — snake_case, prefixed with their module:
|
||||
`assetLock()`, `entityPositionInit()`, `moduleAssetBatchCtor()`
|
||||
- **Struct fields** — camelCase: `keyframeCount`, `localPosition`
|
||||
- **Macros / constants** — UPPER_SNAKE_CASE:
|
||||
`ENTITY_ID_INVALID`, `ERROR_OK`, `COMPONENT_TYPE_COUNT`
|
||||
- **Files** — snake_case matching the primary type: `entityposition.c`,
|
||||
`moduleassetbatch.c`
|
||||
|
||||
### Header files (`.h`)
|
||||
- Use `#pragma once` — no include guards.
|
||||
- Declare every public function, `#define`, and `extern` global.
|
||||
- Write a JSDoc block (`/** … */`) above every declaration explaining
|
||||
purpose, `@param`s, and `@returns`.
|
||||
- Only include headers that the `.h` file itself strictly requires for
|
||||
the types it exposes. Move everything else to the `.c` file.
|
||||
Do not use forward declarations as a workaround — use the real
|
||||
include in the `.c` file instead.
|
||||
|
||||
### Implementation files (`.c`)
|
||||
- Contain function bodies only; no declarations.
|
||||
- Pull in whatever additional includes the implementation needs.
|
||||
- Do not use `static` or `inline` on **functions**. Every function,
|
||||
including internal helpers, must be declared in the matching `.h` and
|
||||
defined in the `.c` file. Internal helpers belong near the bottom of
|
||||
the `.c` file, not at the top with a `static` qualifier.
|
||||
`static` and `inline` on functions are only appropriate when the
|
||||
function body is written directly inside a `.h` file.
|
||||
`static` on **variables** (file-scope state) is fine and expected.
|
||||
|
||||
### Formatting
|
||||
- Hard-wrap all lines at **80 characters**.
|
||||
|
||||
### Error handling
|
||||
Return `errorret_t` from fallible functions. Use these macros:
|
||||
|
||||
```c
|
||||
errorOk(); // return success
|
||||
errorThrow("msg %d", val); // return failure with message
|
||||
errorChain(someCall()); // propagate failure, continue on success
|
||||
errorIsOk(ret) / errorIsNotOk(ret) // test a result
|
||||
errorCatch(ret); // handle + free an error
|
||||
```
|
||||
|
||||
Never return raw error codes or use `errno` for in-engine errors.
|
||||
|
||||
### Memory
|
||||
Use the project allocator — never raw `malloc`/`free`:
|
||||
|
||||
```c
|
||||
memoryAllocate(size) // allocate
|
||||
memoryFree(ptr) // free
|
||||
memoryZero(dest, size) // zero a block
|
||||
memoryCopy(dest, src, size) // copy
|
||||
```
|
||||
|
||||
### Asserts
|
||||
Prefer specific assert macros over bare `assert()`:
|
||||
|
||||
```c
|
||||
assertNotNull(ptr, "msg");
|
||||
assertTrue(cond, "msg");
|
||||
assertFalse(cond, "msg");
|
||||
assertUnreachable("msg");
|
||||
assertIsMainThread("msg");
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Build system
|
||||
Each subdirectory has its own `CMakeLists.txt` that adds sources with:
|
||||
|
||||
```cmake
|
||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
myfile.c
|
||||
)
|
||||
```
|
||||
|
||||
Never add source files to the root `CMakeLists.txt` directly.
|
||||
|
||||
---
|
||||
|
||||
## Platform support
|
||||
|
||||
### Targets
|
||||
Set `DUSK_TARGET_SYSTEM` at CMake configure time to select a platform:
|
||||
|
||||
| `DUSK_TARGET_SYSTEM` | Macro defined | Platform |
|
||||
|----------------------|-------------------|------------------|
|
||||
| `linux` | `DUSK_LINUX` | Linux desktop |
|
||||
| `knulli` | `DUSK_KNULLI` | Knulli (handheld)|
|
||||
| `psp` | `DUSK_PSP` | Sony PSP |
|
||||
| `gamecube` | `DUSK_GAMECUBE` | Nintendo GameCube|
|
||||
| `wii` | `DUSK_WII` | Nintendo Wii |
|
||||
|
||||
### Layer structure
|
||||
```
|
||||
src/dusk/ core, platform-agnostic game logic
|
||||
src/duskgl/ OpenGL abstraction (Linux, Knulli, PSP)
|
||||
src/dusksdl2/ SDL2 window + input (Linux, Knulli, PSP)
|
||||
src/dusklinux/ Linux + Knulli platform impl
|
||||
src/duskpsp/ PSP platform impl
|
||||
src/duskdolphin/ GameCube / Wii platform impl (no SDL2/OpenGL)
|
||||
```
|
||||
|
||||
Dolphin is the only target that bypasses SDL2 and OpenGL entirely —
|
||||
it uses native GameCube/Wii rendering and input APIs.
|
||||
|
||||
### Platform guards
|
||||
Use the compile-time macros for platform-specific code:
|
||||
|
||||
```c
|
||||
#ifdef DUSK_PSP
|
||||
// PSP-only path
|
||||
#elif defined(DUSK_GAMECUBE) || defined(DUSK_WII)
|
||||
// GameCube / Wii path
|
||||
#else
|
||||
// Generic / Linux fallback
|
||||
#endif
|
||||
```
|
||||
|
||||
Additional capability macros set per-target:
|
||||
`DUSK_SDL2`, `DUSK_OPENGL`, `DUSK_OPENGL_ES`, `DUSK_OPENGL_LEGACY`,
|
||||
`DUSK_INPUT_GAMEPAD`, `DUSK_INPUT_KEYBOARD`, `DUSK_INPUT_POINTER`,
|
||||
`DUSK_PLATFORM_ENDIAN_BIG` / `DUSK_PLATFORM_ENDIAN_LITTLE`.
|
||||
|
||||
### Abstraction pattern
|
||||
Platform-specific implementations are wired in via `#define` macros in
|
||||
each platform's `displayplatform.h` / `inputplatform.h` etc., which
|
||||
the core calls through. Functions that a platform does not support are
|
||||
simply left undefined — the core guards calls with `#ifdef`.
|
||||
|
||||
### Adding platform-specific code
|
||||
- Put it under `src/dusk<platform>/` in the matching subsystem folder.
|
||||
- Gate any core call-site with the appropriate `#ifdef DUSK_<PLATFORM>`
|
||||
or capability macro.
|
||||
- Keep the `src/dusk/` core free of platform ifdefs — delegate through
|
||||
the platform header macros instead.
|
||||
|
||||
---
|
||||
|
||||
## Adding a new asset loader type
|
||||
1. Add an enum value to `assetloadertype_t` (before `_COUNT`) in
|
||||
`src/dusk/asset/loader/assetloader.h`.
|
||||
2. Add fields to the input/loading/output unions in `assetloader.h`.
|
||||
3. Implement `assetXxxLoaderSync`, `assetXxxLoaderAsync`, and
|
||||
`assetXxxDispose` in a new `src/dusk/asset/loader/xxx/` directory.
|
||||
4. Register the three callbacks in `ASSET_LOADER_CALLBACKS[]` in
|
||||
`src/dusk/asset/loader/assetloader.c`.
|
||||
5. If user-facing, create a JS module (see below) and a `.d.ts` file.
|
||||
|
||||
---
|
||||
|
||||
## Adding a new entity component
|
||||
1. Create `src/dusk/entity/component/<category>/entityMyComp.h/.c` with
|
||||
struct `entityMyComp_t`, `entityMyCompInit()`, and optionally
|
||||
`entityMyCompDispose()`, `entityMyCompRender()`.
|
||||
2. Add the include to `src/dusk/entity/componentlist.h` header block
|
||||
(or `src/duskrpg/entity/gamecomponentlist.h` for a game-specific
|
||||
component, appended after the engine's inbuilt ones).
|
||||
3. Add a row:
|
||||
```c
|
||||
X(MYCOMP, entityMyComp_t, myComp, entityMyCompInit, NULL, NULL)
|
||||
```
|
||||
Params are `(enumName, type, field, init, dispose, render)` — pass
|
||||
`NULL` for any callback the component doesn't need. This
|
||||
auto-generates the enum, union field, and definition entry.
|
||||
4. If JS-facing, create the script module and `.d.ts` (see below).
|
||||
|
||||
Entities/components/scenes have no JSON serialize/deserialize path —
|
||||
that was removed in favor of building scenes from C-coded prefabs
|
||||
(below) or from JerryScript (`Entity`/`Component`/`Scene`, see
|
||||
"Adding a new script (JS) module").
|
||||
|
||||
---
|
||||
|
||||
## Adding a new entity/scene prefab
|
||||
Entity prefabs (`src/dusk/entity/entityprefab.h`) and scene prefabs
|
||||
(`src/dusk/scene/sceneprefab.h`) follow the same pattern:
|
||||
1. Write an apply function: `errorret_t entityPrefabXxxApply(mgr,
|
||||
entityId)` (or `errorret_t scenePrefabXxxApply(sceneId)`), building
|
||||
up the entity/scene with the normal component/entity APIs.
|
||||
2. Add an entry to the sentinel-terminated `ENTITY_PREFABS[]` (in
|
||||
`src/dusk/entity/entityprefablist.h`, or a game-specific list it
|
||||
includes) or `SCENE_PREFABS[]`:
|
||||
```c
|
||||
{ .name = "MY_PREFAB", .extends = "", .apply = entityPrefabXxxApply }
|
||||
```
|
||||
`extends` names another prefab to apply first (recurses through
|
||||
`entityPrefabResolveAndApply`/`scenePrefabResolveAndApply`), or `""`
|
||||
for none. Do not add an enum or count field — the array is iterated
|
||||
until `.name[0] == '\0'`.
|
||||
3. `entityPrefabResolveAndApply`/`scenePrefabResolveAndApply` only
|
||||
resolve names against the C-coded registry above — there is no JSON
|
||||
asset fallback. Throws if no prefab with that name is registered.
|
||||
|
||||
---
|
||||
|
||||
## Adding a new cutscene item type
|
||||
1. Create `src/duskrpg/cutscene/item/<category>/cutsceneMyItem.h/.c`
|
||||
with a data struct (e.g. `cutscenemyitem_t`) and
|
||||
`cutsceneMyItemStart(item, data)` / `cutsceneMyItemUpdate(item,
|
||||
data)` (the latter returns `true` once the item has completed). Add
|
||||
a matching `cutscenemyitemdata_t` runtime-data struct only if the
|
||||
item needs per-run state across ticks (most don't).
|
||||
2. Add `CUTSCENE_ITEM_TYPE_MY_ITEM` to the enum and a union member to
|
||||
`cutsceneitem_t` (and `cutsceneitemdata_t` if it has runtime data) in
|
||||
`src/duskrpg/cutscene/item/cutsceneitem.h`.
|
||||
3. Register the `{ start, update }` pair in `CUTSCENE_ITEM_CALLBACKS[]`
|
||||
in `cutsceneitem.c`.
|
||||
4. Add an authoring macro to `src/duskrpg/cutscene/cutscene.h`:
|
||||
```c
|
||||
#define CUTSCENE_MY_ITEM(ARGS...) \
|
||||
{ .type = CUTSCENE_ITEM_TYPE_MY_ITEM, .myItem = { ARGS } }
|
||||
```
|
||||
used inside a `CUTSCENE(NAME, SIZE, PAUSE_TYPE, ...)` block.
|
||||
|
||||
---
|
||||
|
||||
## Save system
|
||||
Save data lives under `src/dusk/save/` (`save.h`/`savefile.h`/
|
||||
`saveplatform.h`). Slots are fixed-count (`SAVE_FILE_COUNT_MAX`), each
|
||||
holding a yyjson document persisted with its byte size and a CRC32
|
||||
checksum. `saveLoad`/`saveSave` read/write the JSON fresh every call —
|
||||
callers own the returned/passed `yyjson_doc`/`yyjson_mut_doc` and must
|
||||
free it themselves. Actual file I/O goes through platform-specific
|
||||
`saveplatform_t`/stream hooks (one implementation per platform under
|
||||
`src/dusk<platform>/save/`) — do not add direct filesystem calls to the
|
||||
core `save.c`, extend the platform stream hooks instead.
|
||||
|
||||
## Network system
|
||||
`src/dusk/network/` (`network.h`) is a connection-state layer only — a
|
||||
`networkstate_t` state machine (`DISCONNECTED`/`CONNECTING`/`CONNECTED`/
|
||||
`DISCONNECTING`) plus an HTTP client (`network/http/`) used for one-off
|
||||
requests. It is not a multiplayer/replication protocol — that layer
|
||||
doesn't exist yet (see `ROADMAP.md` items on the socket server/client
|
||||
and packet handlers). Platform-specific connection logic (e.g. PSP's
|
||||
`sceNetApctl` polling, GameCube/Wii's `if_config()`) lives under
|
||||
`src/dusk<platform>/network/`, wired through `networkplatform.h` macros
|
||||
the same way display/input are. Whenever this eventually grows a
|
||||
multiplayer protocol, apply `ROADMAP.md`'s principle: never trust
|
||||
incoming packet data — validate defensively with `errorret_t`/
|
||||
`errorThrow()`, not asserts.
|
||||
|
||||
## Adding a new script (JS) module
|
||||
Dusk embeds JerryScript (`src/dusk/script/`, fetched via
|
||||
`cmake/modules/Findjerryscript.cmake`). Today only `Entity`, the
|
||||
generic `Component` wrapper, and `Scene` are registered (see
|
||||
`src/dusk/script/module/modulelist.c`) — no per-component-type typed
|
||||
wrappers exist yet (e.g. no `.position` on a `POSITION` component);
|
||||
`entity.add(TYPE)`/`entity.getComponent(TYPE)` always return the
|
||||
generic `Component`.
|
||||
|
||||
1. Create `src/dusk/script/module/<category>/moduleMyMod.h/.c`.
|
||||
- Declare `extern scriptproto_t MODULE_MYMOD_PROTO;` in the header.
|
||||
- Use `moduleBaseFunction(name)` to define JS-callable functions —
|
||||
these are the one exception to "no `static` in `.c` files": the
|
||||
macro itself expands to a `static jerry_value_t name(...)`
|
||||
JerryScript external-handler trampoline, never called by name
|
||||
from other C files, so it isn't declared in the `.h`.
|
||||
- Register props/funcs in `moduleMyModInit()` with
|
||||
`scriptProtoDefineProp` / `scriptProtoDefineFunc` /
|
||||
`scriptProtoDefineStaticFunc`.
|
||||
2. `#include` the header in
|
||||
`src/dusk/script/module/modulelist.c` and call
|
||||
`moduleMyModInit()` in `moduleListInit()` (and `Dispose` in
|
||||
`moduleListDispose()`).
|
||||
3. For a component module that adds a *typed* wrapper for a specific
|
||||
component type, create
|
||||
`src/dusk/script/module/entity/component/modulecomponentlist.c` (it
|
||||
doesn't exist yet — the first such module creates it) so
|
||||
`entity.add()` can return the typed wrapper instead of the generic
|
||||
`Component`.
|
||||
4. Create `types/<category>/mymod.d.ts` and add a
|
||||
`/// <reference path="..." />` line to `types/index.d.ts`.
|
||||
|
||||
---
|
||||
|
||||
## Script module type declarations
|
||||
Whenever a `src/dusk/script/module/**/*.c` file is created or modified,
|
||||
check whether the corresponding `types/**/*.d.ts` needs updating and
|
||||
apply any changes before finishing the task.
|
||||
|
||||
---
|
||||
|
||||
## JavaScript (asset scripts)
|
||||
- Use `var` for module-level state; `const` for values that never
|
||||
change.
|
||||
- Always use semicolons.
|
||||
- Scene objects are plain objects (`var scene = {}`) with assigned
|
||||
methods.
|
||||
- Export via `module.exports = scene`.
|
||||
- Async scene init should use `async function` and `await`.
|
||||
|
||||
---
|
||||
|
||||
## Coding style
|
||||
|
||||
### ASCII only
|
||||
Source files (`.c`, `.h`, `.js`) must contain only ASCII characters (U+0000–U+007F).
|
||||
Non-ASCII characters are banned even in comments and string literals.
|
||||
Use ASCII-only substitutes instead:
|
||||
- `--` or `-` instead of `—` (em dash)
|
||||
- `->` instead of `→` (arrow)
|
||||
- `x` or `*` instead of `×` (multiplication)
|
||||
|
||||
Only non-script asset files (e.g. `.po` locale files) may contain non-ASCII text.
|
||||
|
||||
### Indentation
|
||||
2 spaces. No tabs.
|
||||
|
||||
### Keyword and operator spacing
|
||||
No space between a keyword or function name and its opening parenthesis:
|
||||
|
||||
```c
|
||||
if(!ptr) return;
|
||||
for(uint8_t i = 0; i < count; i++) {
|
||||
while(entry->state != DONE) {
|
||||
switch(type) {
|
||||
sizeof(assetbatch_t)
|
||||
memoryZero(ptr, size)
|
||||
```
|
||||
|
||||
Spaces around all binary operators and after every comma:
|
||||
|
||||
```c
|
||||
pos->flags |= ENTITY_POSITION_FLAG_WORLD_DIRTY;
|
||||
(size_t)end - (size_t)start
|
||||
foo(a, b, c)
|
||||
```
|
||||
|
||||
### Braces
|
||||
Opening brace on the **same line** as the statement (K&R style) for all
|
||||
constructs — functions, `if`, `else`, `for`, `while`, `switch`:
|
||||
|
||||
```c
|
||||
void assetEntryLock(assetentry_t *entry) {
|
||||
...
|
||||
}
|
||||
|
||||
if(dirty) {
|
||||
...
|
||||
} else {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Guard returns
|
||||
Short guards go on one line with no braces:
|
||||
|
||||
```c
|
||||
if(!ptr) return;
|
||||
if(!b || !b->batch) return jerry_undefined();
|
||||
if(!(flags & DIRTY)) return;
|
||||
```
|
||||
|
||||
### Blank lines
|
||||
- One blank line between functions; no blank line at the start or end of
|
||||
a function body.
|
||||
- One blank line between logical blocks inside a function body.
|
||||
- No trailing blank lines at the end of a file.
|
||||
|
||||
### Pointer placement
|
||||
`*` is attached to the variable name, not the type:
|
||||
|
||||
```c
|
||||
assetentry_t *entry
|
||||
const char_t *name
|
||||
void *ptr
|
||||
uint8_t *d = (uint8_t *)dest;
|
||||
```
|
||||
|
||||
### Casts
|
||||
Space between cast and operand:
|
||||
|
||||
```c
|
||||
(assetbatch_t *)user
|
||||
(uint8_t *)dest
|
||||
(textureformat_t)v
|
||||
```
|
||||
|
||||
### Return
|
||||
No parentheses around the return value:
|
||||
|
||||
```c
|
||||
return ptr;
|
||||
return MEMORY_POINTERS_IN_USE;
|
||||
```
|
||||
|
||||
### switch / case
|
||||
`case` indented 2 spaces from `switch`; body indented 2 more from `case`:
|
||||
|
||||
```c
|
||||
switch(type) {
|
||||
case ASSET_LOADER_TYPE_TEXTURE:
|
||||
descs[i].input.texture = (textureformat_t)v;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
```
|
||||
|
||||
### Multi-line function signatures
|
||||
When parameters don't fit on one line, put each on its own line indented
|
||||
2 spaces; the closing `) {` (definition) or `);` (declaration) goes on
|
||||
its own line at column 0:
|
||||
|
||||
```c
|
||||
void assetEntryInit(
|
||||
assetentry_t *entry,
|
||||
const char_t *name,
|
||||
const assetloadertype_t type,
|
||||
assetloaderinput_t *input
|
||||
) {
|
||||
|
||||
errorret_t memoryCompare(
|
||||
const void *a,
|
||||
const void *b,
|
||||
const size_t size
|
||||
);
|
||||
```
|
||||
|
||||
### Structs and enums
|
||||
Anonymous inner struct or enum with a `typedef`, `_t` suffix, closing
|
||||
brace and name on the same line:
|
||||
|
||||
```c
|
||||
typedef struct {
|
||||
errorcode_t code;
|
||||
char_t *message;
|
||||
} errorstate_t;
|
||||
|
||||
typedef enum {
|
||||
ASSET_LOADER_TYPE_NULL,
|
||||
ASSET_LOADER_TYPE_COUNT
|
||||
} assetloadertype_t;
|
||||
```
|
||||
|
||||
### Designated initialisers
|
||||
Spaces inside braces; `.field = value`:
|
||||
|
||||
```c
|
||||
jsassetentry_t e = { .entry = entry };
|
||||
assetbatchloadedpend_t init = { .batch = batch };
|
||||
```
|
||||
|
||||
### Ternary operator
|
||||
Spaces around `?` and `:`:
|
||||
|
||||
```c
|
||||
const float val = psx > 0.0f ? pt[0][0] / psx : 0.0f;
|
||||
```
|
||||
|
||||
### const placement
|
||||
`const` before the type, `*` attached to the variable:
|
||||
|
||||
```c
|
||||
const char_t *name
|
||||
const void *src
|
||||
const size_t size
|
||||
```
|
||||
|
||||
### Comments in `.c` files
|
||||
- Do not use section dividers (`/* ---- ... ---- */`). Just let the
|
||||
functions follow one another with a single blank line between them.
|
||||
- Multi-line explanatory comments inside function bodies use `//` lines:
|
||||
```c
|
||||
// Script modules are freed; orphaned JS wrapper objects now get GC'd
|
||||
// so their finalizers fire before assetDispose() checks ref counts.
|
||||
jerry_heap_gc(JERRY_GC_PRESSURE_HIGH);
|
||||
```
|
||||
- Do not use `/* */` for inline or inline-block comments inside `.c`
|
||||
function bodies.
|
||||
|
||||
### Comments in `.h` files
|
||||
Every public declaration gets a Javadoc block (`/** … */`) with
|
||||
`@param` and `@returns` where relevant. Keep it on the lines immediately
|
||||
above the declaration with no blank line in between.
|
||||
|
||||
---
|
||||
|
||||
## Color system
|
||||
|
||||
Colors are defined in `src/dusk/display/color.csv` and code-generated
|
||||
into a `color.h` header by `tools/color/csv/__main__.py`.
|
||||
|
||||
Each row in the CSV has `name,r,g,b,a` with channel values in `[0.0, 1.0]`.
|
||||
The script emits four `#define` variants per color plus a bare alias:
|
||||
|
||||
```
|
||||
COLOR_<NAME>_4B color4b(r8, g8, b8, a8) // default alias target
|
||||
COLOR_<NAME>_3B color3b(r8, g8, b8)
|
||||
COLOR_<NAME>_3F color3f(rf, gf, bf)
|
||||
COLOR_<NAME>_4F color4f(rf, gf, bf, af)
|
||||
COLOR_<NAME> COLOR_<NAME>_4B
|
||||
```
|
||||
|
||||
`color_t` is `color4b_t` (four `uint8_t` channels).
|
||||
|
||||
To add a new color, append a row to `color.csv` and rebuild — do not
|
||||
hand-edit the generated header.
|
||||
|
||||
---
|
||||
|
||||
## Tests
|
||||
- Tests live in `test/` mirroring `src/dusk/` structure.
|
||||
- Use cmocka; include `dusktest.h`.
|
||||
- Test functions: `static void test_something(void **state)`.
|
||||
- After each test, assert `memoryGetAllocatedCount() == 0` to catch
|
||||
leaks.
|
||||
- Build with `-DDUSK_BUILD_TESTS=ON`.
|
||||
+15
-40
@@ -8,22 +8,16 @@ cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MODULE_PATH
|
||||
${CMAKE_MODULE_PATH}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
|
||||
)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
cmake_policy(SET CMP0079 NEW)
|
||||
# set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
|
||||
|
||||
option(DUSK_BUILD_TESTS "Enable tests" OFF)
|
||||
option(DUSK_NETWORK "Enable network support" ON)
|
||||
|
||||
set(DUSK_GAME_NAME "Dusk" CACHE STRING "Game display name")
|
||||
set(DUSK_GAME_AUTHOR "YourWishes" CACHE STRING "Game author / coder")
|
||||
set(DUSK_GAME_SHORT_DESCRIPTION "Dusk game" CACHE STRING "One-line description")
|
||||
set(DUSK_GAME_LONG_DESCRIPTION
|
||||
"No description yet." CACHE STRING "Full description"
|
||||
)
|
||||
set(DUSK_GAME_LONG_DESCRIPTION "No description yet." CACHE STRING "Full description")
|
||||
|
||||
# Prep cache
|
||||
set(DUSK_CACHE_TARGET "dusk-target")
|
||||
@@ -37,19 +31,13 @@ set(DUSK_TEMP_DIR "${DUSK_BUILD_DIR}/temp")
|
||||
set(DUSK_TOOLS_DIR "${DUSK_ROOT_DIR}/tools")
|
||||
set(DUSK_DATA_DIR "${DUSK_ROOT_DIR}/data")
|
||||
set(DUSK_ASSETS_DIR "${DUSK_ROOT_DIR}/assets")
|
||||
set(DUSK_BUILT_ASSETS_DIR "${DUSK_BUILD_DIR}/built_assets"
|
||||
CACHE INTERNAL ${DUSK_CACHE_TARGET}
|
||||
)
|
||||
set(DUSK_BUILT_ASSETS_DIR "${DUSK_BUILD_DIR}/built_assets" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
set(DUSK_GENERATED_HEADERS_DIR "${DUSK_BUILD_DIR}/generated")
|
||||
set(DUSK_BUILD_BINARY ${DUSK_BUILD_DIR}/Dusk
|
||||
CACHE INTERNAL ${DUSK_CACHE_TARGET}
|
||||
)
|
||||
set(DUSK_BUILD_BINARY ${DUSK_BUILD_DIR}/Dusk CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
set(DUSK_ASSETS "" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
set(DUSK_LIBRARY_TARGET_NAME "DuskCore" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
set(DUSK_BINARY_TARGET_NAME "Dusk" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
set(DUSK_ASSETS_ZIP "${DUSK_BUILD_DIR}/dusk.dsk"
|
||||
CACHE INTERNAL ${DUSK_CACHE_TARGET}
|
||||
)
|
||||
set(DUSK_ASSETS_ZIP "${DUSK_BUILD_DIR}/dusk.dsk" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
|
||||
if(NOT DEFINED DUSK_TARGET_SYSTEM)
|
||||
set(DUSK_TARGET_SYSTEM "linux")
|
||||
@@ -84,9 +72,7 @@ if(DUSK_BUILD_TESTS)
|
||||
${DUSK_LIBRARY_TARGET_NAME}
|
||||
)
|
||||
else()
|
||||
set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}"
|
||||
CACHE INTERNAL ${DUSK_CACHE_TARGET}
|
||||
)
|
||||
set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED DUSK_VERSION)
|
||||
@@ -104,12 +90,6 @@ target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME}
|
||||
DUSK_VERSION="${DUSK_VERSION}"
|
||||
)
|
||||
|
||||
if(DUSK_NETWORK)
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_NETWORK
|
||||
)
|
||||
endif()
|
||||
|
||||
# Toolchains
|
||||
include(cmake/targets/${DUSK_TARGET_SYSTEM}.cmake)
|
||||
|
||||
@@ -135,21 +115,16 @@ if(DUSK_BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
# Build assets. Runs unconditionally on every build (rather than being
|
||||
# gated behind a custom_command's file-level DEPENDS list) because
|
||||
# CONFIGURE_DEPENDS globs only pick up added/removed files on the next
|
||||
# CMake configure, so that approach could miss/lag a rebuild behind an
|
||||
# asset edit. tools.asset.pack itself decides whether anything actually
|
||||
# changed (see its manifest check) and no-ops quickly when nothing did,
|
||||
# so this stays cheap on a build where assets are untouched.
|
||||
add_custom_target(DUSK_ASSETS_BUILT ALL
|
||||
# Build assets
|
||||
file(GLOB_RECURSE DUSK_ASSET_FILES CONFIGURE_DEPENDS "${DUSK_ASSETS_DIR}/*")
|
||||
add_custom_command(
|
||||
OUTPUT "${DUSK_ASSETS_ZIP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${DUSK_ASSETS_DIR}"
|
||||
COMMAND ${Python3_EXECUTABLE} -m tools.asset.pack
|
||||
--input "${DUSK_ASSETS_DIR}"
|
||||
--output "${DUSK_ASSETS_ZIP}"
|
||||
WORKING_DIRECTORY "${DUSK_ROOT_DIR}"
|
||||
BYPRODUCTS "${DUSK_ASSETS_ZIP}"
|
||||
COMMENT "Packing assets into dusk.dsk"
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -f "${DUSK_ASSETS_ZIP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${DUSK_ASSETS_ZIP}" --format=zip -- .
|
||||
WORKING_DIRECTORY "${DUSK_ASSETS_DIR}"
|
||||
DEPENDS ${DUSK_ASSET_FILES}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(DUSK_ASSETS_BUILT DEPENDS "${DUSK_ASSETS_ZIP}")
|
||||
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT)
|
||||
@@ -0,0 +1,260 @@
|
||||
# PSP Optimization Plan
|
||||
|
||||
A survey of concrete memory and CPU (especially floating-point) optimization
|
||||
opportunities for the PSP target, done 2026-07-31 on branch `ac2` at commit
|
||||
`e61914ba` + this session's scripting work. Point-in-time findings, not a
|
||||
substitute for reading the referenced source before acting on it.
|
||||
|
||||
## Why this exists
|
||||
|
||||
The PSP (Allegrex MIPS CPU, 222-333MHz, single core, 32-64MB main RAM, 2MB
|
||||
eDRAM, 16KB I-cache / 16KB D-cache, no virtual memory or memory protection)
|
||||
is the tightest-constrained target this engine ships to. Two rules guide
|
||||
everything below, both already correctly applied in one place in this
|
||||
codebase (`entityposition_t` caching its transform matrices instead of
|
||||
recomputing them from position/rotation/scale every read — see "Already
|
||||
correct" below):
|
||||
|
||||
- **Memory is finite and cannot be compacted.** No VM means a fragmented
|
||||
heap after a few minutes of play can fail an allocation even with
|
||||
"enough" total free bytes. Prefer static/pool allocation over
|
||||
malloc/free churn; prefer trading memory for CPU only when the memory
|
||||
cost is bounded and paid once.
|
||||
- **CPU is finite and floating-point math is not free**, especially
|
||||
trig/sqrt on the plain scalar FPU. Prefer caching a computed result
|
||||
behind a dirty flag over recomputing it unconditionally; prefer
|
||||
avoiding a sqrt via squared-distance comparison wherever only a
|
||||
yes/no or ordering result is needed.
|
||||
|
||||
## Priority 1 — Entity/component memory: a union tax paid on every slot, times 4 scenes
|
||||
|
||||
**The single biggest finding.** `entitymanager_t` (`src/dusk/entity/entitymanager.h:11-15`)
|
||||
is a flat, statically-sized struct:
|
||||
|
||||
```c
|
||||
typedef struct entitymanager_t {
|
||||
entity_t entities[ENTITY_COUNT_MAX]; // 64
|
||||
component_t components[ENTITY_COUNT_MAX * ENTITY_COMPONENT_COUNT_MAX]; // 64*16 = 1024
|
||||
componentid_t entitiesWithComponent[COMPONENT_TYPE_COUNT * ENTITY_COUNT_MAX];
|
||||
} entitymanager_t;
|
||||
```
|
||||
|
||||
`component_t` (`src/dusk/entity/component.h:69-72`) holds a **tagged union**
|
||||
(`componentdata_t`) sized to its largest variant. That variant is
|
||||
`entityrenderable_t`'s spritebatch payload (`entityrenderable.h:25-66`):
|
||||
`spritebatchsprite_t sprites[64]` at 40 bytes each (`vec3 min + vec3 max +
|
||||
vec2 uvMin + vec2 uvMax`) = **2560 bytes**, versus ~28-300 bytes for every
|
||||
other component type (camera, physics, animation, position, trigger).
|
||||
|
||||
Because the union is embedded by value in a flat array — not behind a
|
||||
pointer, not sparse — **every one of the 1024 component slots in every
|
||||
entity manager costs ~2580 bytes, whether it holds a 28-byte camera or
|
||||
nothing at all.** `1024 * 2580 ≈ 2.52MB` per `entitymanager_t`, confirmed
|
||||
by the engine's own startup log every run: `Entity manager size: 2684992
|
||||
bytes (2622.06 KB)`.
|
||||
|
||||
`scene_t` (`src/dusk/scene/scene.h:14-18`) embeds `entitymanager_t` by
|
||||
value too, and `SCENE_COUNT_MAX = 4` (`scene/scenebase.h:11`) with
|
||||
`SCENE_MANAGER` declared as a plain global (`scene/scene.c:20`) — so this
|
||||
~2.52MB exists as static BSS from process start for **all 4 scene slots**,
|
||||
used or not. **Total: ~10.1MB reserved permanently for entity storage
|
||||
alone** — 16-31% of PSP main RAM — before a single texture, mesh, or audio
|
||||
asset is loaded.
|
||||
|
||||
**Options to fix (roughly increasing effort/risk):**
|
||||
1. Pull `entityrenderablespritebatch_t` out of the component union entirely
|
||||
— store spritebatch entities via a pointer/handle into a separate,
|
||||
smaller fixed pool sized to how many spritebatch-renderable entities
|
||||
actually coexist (almost certainly far fewer than 64 per entity, and
|
||||
far fewer entities need spritebatch at all vs. mesh/material
|
||||
rendering). This alone would shrink the union's dominant variant from
|
||||
~2560 bytes to whatever the next-largest variant is (~300 bytes,
|
||||
`entitytrigger_t`) — an ~88% reduction, dropping the ~10.1MB down to
|
||||
roughly ~1.2MB.
|
||||
2. Reduce `SCENE_COUNT_MAX` from 4 if 4 concurrent scenes were never a
|
||||
deliberate requirement (check with the project owner — this may just
|
||||
be a round-number default nobody revisited), or make scene storage
|
||||
pointer-based/lazily allocated so unused scene slots cost ~0 instead
|
||||
of a full `entitymanager_t`.
|
||||
3. Reduce `ENTITY_COMPONENT_COUNT_MAX` (16) if entities realistically use
|
||||
far fewer distinct component types simultaneously — check actual
|
||||
usage across `entityprefablist.h`/`gameprefablist.h` prefabs.
|
||||
|
||||
Do (1) first — it's the highest-leverage, most contained change (touches
|
||||
`entityrenderable.h`'s data layout and its render/dispose paths, not the
|
||||
general entity/component system), and re-measure via the same startup
|
||||
log line before deciding whether (2)/(3) are still worth doing.
|
||||
|
||||
## Priority 2 — VFPU is completely unused; all vec/mat math is scalar
|
||||
|
||||
The PSP's Allegrex CPU has a **VFPU** (vector floating-point unit) capable
|
||||
of fast SIMD-style 4-wide float ops and hardware-accelerated matrix
|
||||
operations, exposed by pspsdk's `pspvfpu`/GU "Geometry Utility" (`gum_*`)
|
||||
helpers. This engine links `pspvfpu` (`cmake/targets/psp.cmake`) but
|
||||
**never calls into it** — confirmed via a zero-hit grep for
|
||||
`vfpu|pspmath|gum_|vcst|gu_matrix` across `src/duskpsp/` and `src/duskgl/`.
|
||||
|
||||
All vector/matrix math instead goes through cglm (`glm_vec3_*`,
|
||||
`glm_mat4_*`), which auto-detects SIMD only for x86 (`CGLM_SSE2`/`AVX`) or
|
||||
ARM (`CGLM_NEON`) — neither applies to MIPS, and no `CGLM_*` macros are
|
||||
set anywhere in this repo (confirmed zero hits). **Every `glm_mat4_mul`,
|
||||
every position/rotation rebuild, every physics vector op runs on the
|
||||
plain scalar MIPS FPU with the VFPU sitting idle.**
|
||||
|
||||
This is the single largest *available* CPU win identified in this survey
|
||||
— larger than any specific hot-path fix below, because it's a multiplier
|
||||
on all of them. Concretely: route `entityposition.c`'s matrix
|
||||
rebuild/multiply path and `physicsworld.c`'s per-body vector math through
|
||||
`pspvfpu`/`gum_*` on the PSP build specifically (behind `#ifdef DUSK_PSP`,
|
||||
matching the project's existing platform-guard convention), while keeping
|
||||
cglm as the portable fallback for Linux/Knulli/GameCube/Wii. This is a
|
||||
genuinely large effort (new platform-specific math backend, careful
|
||||
correctness verification since VFPU has its own quirks around
|
||||
pipelining/hazards) — scope it as its own project, not a quick pass.
|
||||
|
||||
## Priority 3 — UI/spritebatch rebuilds and redraws every vertex, every frame
|
||||
|
||||
Already flagged in `STATUS.md`/`ROADMAP.md` (item 4/5) as a known open
|
||||
issue; this session's research adds concrete numbers. `meshvertex_t`
|
||||
(`display/mesh/meshvertex.h:14-17`) is `{ float uv[2]; float pos[3]; }` =
|
||||
**20 bytes/vertex**, no packing. `SPRITEBATCH_SPRITES_MAX = 512`,
|
||||
`SPRITEBATCH_FLUSH_COUNT = 16` → 32 sprites/flush = 192 vertices = **3,840
|
||||
bytes rebuilt and redrawn per flush**, with a flush forced on every
|
||||
shader/material change (`spritebatch.c:38-50`) and used unconditionally
|
||||
by every widget except `uiconsole.c` (`uitab.c:56`, `uislider.c:183/199/231`,
|
||||
final flush in `ui.c:51`). A UI screen with ~50-100 sprites and 2-3
|
||||
material changes costs an estimated **8-15KB of vertex rebuild + GU
|
||||
submission every single frame**, regardless of whether the UI changed
|
||||
since the last frame.
|
||||
|
||||
Confirmed on the PSP legacy-GL path specifically: there's no GPU buffer
|
||||
re-upload cost (`meshFlushGL` is a literal no-op comment: "we use the
|
||||
glClientState stuff" — `meshgl.c:91-93`; `meshDrawGL` just points
|
||||
`glVertexPointer` at the CPU-side array each call), so the real cost is
|
||||
(a) the CPU-side per-sprite vertex rewrite every frame and (b) GU
|
||||
re-transforming the full vertex stream from RAM on every draw with no
|
||||
skip for unchanged geometry.
|
||||
|
||||
**Fix direction** (already captured in `ROADMAP.md`'s debt backlog item 5):
|
||||
extend `uiconsole.c`'s cached-mesh, dirty-flag-gated rebuild pattern to
|
||||
the rest of the widget tree. This plan adds one refinement: also consider
|
||||
packing `meshvertex_t` down (next item) since it multiplies this cost.
|
||||
|
||||
## Priority 4 — All-float vertex format wastes bandwidth and T&L cost
|
||||
|
||||
`meshvertex_t` uses two `float` fields (20 bytes) for every mesh and
|
||||
sprite vertex, mesh-wide, with no normal or per-vertex color (color is
|
||||
already handled at the material level, so that part is already optimal).
|
||||
GU natively supports fixed-point 16-bit positions/UVs
|
||||
(`GU_VERTEX_16BIT`/`GU_TEXTURE_16BIT`), which would roughly halve
|
||||
per-vertex size and the corresponding vertex-fetch/transform cost, at the
|
||||
cost of position precision (fine for UI/sprite work and most world
|
||||
geometry at this engine's scale; worth checking against the largest
|
||||
world coordinates actually used before committing). Pair with Priority 3
|
||||
so the packing benefit compounds with the dirty-tracking benefit instead
|
||||
of just reducing the cost of a rebuild that still happens every frame.
|
||||
|
||||
## Priority 5 — Running gameplay logic in JerryScript has a real per-frame cost on PSP
|
||||
|
||||
This is new since last session's work, not a pre-existing issue: `assets/
|
||||
scripts/overworldscene.js`'s `update()` is now called every frame via
|
||||
`scriptManagerCallGlobal("update")` (wired into `engine.c`'s
|
||||
`engineUpdate()`), replacing what used to be a direct `cosf`/`sinf` C
|
||||
callback (`entityUpdateAdd`). Per call, `scriptManagerCallGlobal`
|
||||
(`scriptmanager.c:91-144`) does: a global-object property lookup (key is
|
||||
cached, but the `jerry_object_get` dispatch still runs), full JS
|
||||
interpreter call dispatch (frame setup, argument marshaling) for what's a
|
||||
two-line function, and an unconditional `jerry_value_is_promise` check
|
||||
every call even though `update()` is synchronous. Inside, `Math.cos`/
|
||||
`Math.sin` run as JS builtin calls rather than direct libm calls.
|
||||
|
||||
Additionally: this project's JerryScript fork is already patched to use
|
||||
32-bit float internally (`JERRY_NUMBER_TYPE_FLOAT64=0`,
|
||||
`Findjerryscript.cmake`) — a deliberate, already-correct optimization for
|
||||
this exact concern — but the *public* engine API (`jerry_value_as_number()`)
|
||||
still returns `double`, so every native↔JS boundary crossing (every
|
||||
`moduleBaseArgFloat`, every `moduleBaseVec3ToObject`) still pays a
|
||||
float→double→float round trip. Also note `JERRY_MATH` is off, so
|
||||
`Math.sin`/`cos` fall through to whatever generic libm the platform
|
||||
provides rather than JerryScript's own fdlibm implementation — worth
|
||||
checking whether turning it on changes anything measurable on PSP.
|
||||
|
||||
**This is one `update()` call for one scene-level script today — cheap in
|
||||
absolute terms.** It becomes a real problem only if the pattern scales:
|
||||
giving many individual entities their own per-frame JS update callback
|
||||
would multiply all of the above per entity. **Recommendation: keep
|
||||
high-frequency, hot per-entity logic (movement, camera math, physics
|
||||
response) in native C update callbacks (`entityUpdateAdd`, the existing
|
||||
mechanism), and reserve JS for one-time setup, infrequent/event-driven
|
||||
logic, and coarse-grained per-scene orchestration** — which is exactly
|
||||
what `require()` and the typed component wrappers built this session are
|
||||
suited for, not a per-entity-per-frame hot path. This is a design
|
||||
guideline to apply going forward, not a regression to fix in the current
|
||||
`overworldscene.js` (one scene-level `update()` call per frame is fine).
|
||||
|
||||
## Priority 6 — No pooling/arena allocator; plain malloc/free everywhere
|
||||
|
||||
`memoryAllocate`/`memoryFree` (`util/memory.c`) are direct `malloc`/`free`
|
||||
passthroughs (`memoryAlign`→`memalign`, `memoryReallocate`/`memoryResize`→
|
||||
`realloc`), with the only extra behavior being a global allocation-count
|
||||
tracker used solely for test leak detection. No pool, arena, free-list,
|
||||
or size-class allocator exists anywhere.
|
||||
|
||||
This survey found **no rogue per-frame heap allocations** in the hot
|
||||
paths checked (render dispatch in `entityrenderable.c`, all of
|
||||
`physics/*.c`) — so this is not an active bug today. But it's a
|
||||
structural risk for a no-VM platform over a long play session: any future
|
||||
code that does frequent small alloc/free (dynamic lists, string
|
||||
building, temp buffers) will fragment the 32-64MB heap with no OS-level
|
||||
recovery mechanism. **Recommendation: before adding any new subsystem
|
||||
that allocates/frees frequently at runtime (not just at load time),
|
||||
default to a fixed-size pool or arena for it**, following the same
|
||||
"static, bounded" philosophy already used for `ENTITY_COUNT_MAX`/
|
||||
`SCENE_COUNT_MAX`/`ASSET_ENTRY_COUNT_MAX` elsewhere in the engine, rather
|
||||
than reaching for `memoryAllocate` per-instance.
|
||||
|
||||
## Already correct — don't touch without new evidence
|
||||
|
||||
- **`entityposition_t`'s matrix caching** (the pattern the project owner
|
||||
called out as the reason for writing this plan). Verified: a full
|
||||
"dirty" recompute chain (decompose + rebuild local + rebuild world) is
|
||||
~10 trig calls (`asinf`/`cosf`/`atan2f`) plus at most one 4x4 matrix
|
||||
multiply, and `entityPositionEnsurePRS`/`EnsureLocal`/`EnsureWorld`
|
||||
(`entityposition.c:596-669`) all early-return on a flag check, only
|
||||
doing that work when something actually changed. The cache is correct
|
||||
and clearly worth its ~128-byte-per-entity matrix storage cost.
|
||||
- **Physics narrow-phase sqrt avoidance.** All three `sqrtf` call sites
|
||||
in `physicstest.c`/`physicsshapemesh.c` already sit behind a
|
||||
squared-distance early-reject and only compute the real (linear)
|
||||
distance once, when actually needed for penetration depth — no further
|
||||
"use squared distance instead" opportunity was found here.
|
||||
- **No allocations in the render/physics hot loop** (Priority 6) — this
|
||||
is good and worth preserving as new code is added to those files.
|
||||
- **Asset decompression already runs off the main thread.** Assets are
|
||||
DEFLATE-compressed (not stored) in `dusk.dsk`, so loading pays a real
|
||||
CPU cost for decompression — but every `*LoaderAsync` function
|
||||
(`asset/loader/*/*.c`) runs via `ASSET.loadThread`
|
||||
(`assertNotMainThread` in `asset.c:365`), so this cost is already kept
|
||||
off the main thread. Low priority to change; if load-time CPU cost
|
||||
becomes a measured problem later, revisit stored-vs-compressed as a
|
||||
build-time flag rather than assuming compression is free.
|
||||
|
||||
## Suggested approach
|
||||
|
||||
1. **Measure before changing.** None of the above have been profiled on
|
||||
real PSP hardware in this pass — this is a source-level survey, not a
|
||||
profile. Before investing in Priority 1 or 2 especially, confirm with
|
||||
an actual PSP build/run (or at minimum the existing "Entity manager
|
||||
size" startup log plus a frame-time counter) that these are the real
|
||||
bottlenecks, not just the largest numbers on paper.
|
||||
2. **Priority 1 first** — it's the most contained (one component's data
|
||||
layout), has the clearest before/after metric (the startup log line),
|
||||
and doesn't require new platform-specific code.
|
||||
3. **Priority 3 next** (extend the console's dirty-tracking pattern to
|
||||
the rest of the UI) — already scoped in `ROADMAP.md`, no new design
|
||||
needed, just implementation.
|
||||
4. **Priority 2 (VFPU) as a dedicated project**, not a quick pass — it's
|
||||
the largest potential win but touches core math plumbing and needs
|
||||
careful correctness verification on real hardware.
|
||||
5. Treat Priority 5 as a standing design guideline for all future
|
||||
scripting work, not a one-time fix.
|
||||
@@ -9,18 +9,15 @@ following packages, depending on your system;
|
||||
|
||||
Fedora;
|
||||
```
|
||||
sudo dnf install git make gcc cmake python python-polib python3-pillow python3-dotenv python3-numpy python-qt5 python3-pyopengl SDL2-devel zlib-devel libzip-devel bzip2-devel openssl-devel lzma-sdk-devel xz xz-devel lua-devel libmad-devel
|
||||
sudo dnf install git make gcc cmake python python-polib python3-pillow python3-dotenv python3-numpy python-qt5 python3-pyopengl SDL2-devel zlib-devel libzip-devel bzip2-devel openssl-devel lzma-sdk-devel xz xz-devel lua-devel
|
||||
```
|
||||
`libmad-devel` (used for MP3 decoding) is GPL-licensed and ships in the
|
||||
[RPM Fusion](https://rpmfusion.org/) free repository rather than Fedora's
|
||||
base repos - make sure RPM Fusion is enabled first.
|
||||
|
||||
Ubuntu;
|
||||
```
|
||||
sudo apt-get install git build-essential gcc python python-polib python3-pillow python3-dotenv python3-numpy python3-pyqt5 python3-opengl libmad0-dev
|
||||
sudo apt-get install git build-essential gcc python python-polib python3-pillow python3-dotenv python3-numpy python3-pyqt5 python3-opengl
|
||||
```
|
||||
|
||||
Arch Linux;
|
||||
```
|
||||
sudo pacman -S git base-devel gcc python python-polib python-pillow python-dotenv python-numpy python-pyqt5 python-opengl libmad
|
||||
sudo pacman -S git base-devel gcc python python-polib python-pillow python-dotenv python-numpy python-pyqt5 python-opengl
|
||||
```
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
# Dusk Roadmap
|
||||
|
||||
Tracking upcoming milestones for the engine. See `PSP_OPTIMIZATION_PLAN.md`
|
||||
for a memory/CPU optimization survey specifically targeting the PSP build
|
||||
(milestone 4 below is its Priority 3).
|
||||
|
||||
## Upcoming milestones
|
||||
|
||||
1. Add a very basic physics engine, moving away from the current
|
||||
tile-based movement.
|
||||
2. Give entities full freedom of movement (no longer locked to tile
|
||||
grid positions).
|
||||
3. Update entity interaction, triggers, chunk management, and other
|
||||
systems that currently assume tile-based positioning so they work
|
||||
with the new 3D positioning/movement code.
|
||||
4. Investigate and fix poor UI rendering performance. First pass done
|
||||
(2026-07-31): slider/tab/frame/textbox now cache their sprite
|
||||
geometry instead of rebuilding it every frame, and the console's
|
||||
vertex buffer is fixed-size instead of alloc/free churn (see
|
||||
`STATUS.md`'s "UI rendering performance" note for detail). Still
|
||||
open: per-widget material/color changes still force a sprite-batch
|
||||
flush each time (color is per-material, not per-vertex), so a row of
|
||||
alternating highlighted widgets still costs one draw call per
|
||||
widget.
|
||||
5. Create UI elements for displaying status indicators, e.g. network
|
||||
connection state and save-in-progress.
|
||||
6. Fully test saving end-to-end on all supported platforms.
|
||||
7. Remove the tile system from chunks in favor of meshes, with
|
||||
dynamic hitboxes per chunk loaded in from the chunk file data.
|
||||
8. Create UI elements for network status: a connecting modal, an
|
||||
error state, and a connected flag. Retire the test HTTP request
|
||||
once these are in place.
|
||||
9. Build the socket server and client implementation, including
|
||||
handlers for the different packet types.
|
||||
10. Add a dedicated multiplayer entity type, `clientplayer`, alongside
|
||||
the existing `npc` and `player` types. Limit to 8 (defined
|
||||
constant) for now.
|
||||
11. Send and receive `clientplayer` position over the network.
|
||||
12. Create a UI menu for creating a server and joining a server. For
|
||||
now, join IPs are hard-coded (testing against a fixed IP of
|
||||
10.0.0.94).
|
||||
13. Create "handshake" packets. For now, just send the username,
|
||||
enforced to be under 10 characters long.
|
||||
14. Server tracks all players' positions and broadcasts them to all
|
||||
connected clients.
|
||||
15. Server sends disconnect packets for users who leave.
|
||||
16. Server assigns each client a UUID; all clients know every other
|
||||
client's UUID (used to reference them across position updates,
|
||||
disconnect packets, etc).
|
||||
17. Server notifies all clients (by UUID) when a user joins, leaves,
|
||||
or is disconnected, so clients can spawn or remove the
|
||||
corresponding `clientplayer` entity in the world.
|
||||
|
||||
## Infrastructure / debt backlog
|
||||
|
||||
Found during a full-codebase inventory pass (2026-07-30, see `STATUS.md`
|
||||
for the full survey). These aren't new feature milestones so much as
|
||||
loose ends worth closing, roughly in order of how cheap/safe they are to
|
||||
fix:
|
||||
|
||||
1. Re-enable `test/item` (currently commented out in
|
||||
`test/CMakeLists.txt`) -- confirm it still passes and turn it back on.
|
||||
2. Restore `itemgive.c/h` in `src/duskrpg/item/CMakeLists.txt` -- the
|
||||
textbox UI dependency it was waiting on (`ui/textbox/`) is already
|
||||
back.
|
||||
3. Decide the fate of the `vita` target: `scripts/build-vita.sh` and
|
||||
`docker/vita/` reference `-DDUSK_TARGET_SYSTEM=vita`, but no
|
||||
`cmake/targets/vita.cmake` exists, so the build is currently broken.
|
||||
Either implement it or remove the dangling scripts/Dockerfile.
|
||||
4. Per-PR CI build coverage for non-Linux targets: first pass added
|
||||
2026-07-31 as `run-tests-gamecube-dolphin`/`run-tests-wii-dolphin`
|
||||
(build the ISO, boot it in Dolphin under Xvfb) and
|
||||
`run-tests-psp-ppsspp` (build the EBOOT, boot it in PPSSPPHeadless)
|
||||
in `.github/workflows/test.yml`, plus matching
|
||||
`scripts/test-*-dolphin.sh`/`scripts/test-psp-ppsspp.sh` (+ `-docker`
|
||||
variants). Marked `continue-on-error: true` since none of these have
|
||||
actually been exercised on a real runner yet -- verify they pass
|
||||
before relying on them, and drop the flag once they do. Knulli still
|
||||
has no per-PR coverage at all.
|
||||
5. Milestone 4 above (poor UI rendering performance) has a first pass
|
||||
in (2026-07-31, see `STATUS.md`) -- remaining concrete lead: sprite
|
||||
batch flushes are keyed on shader+material (including tint color),
|
||||
so per-widget color changes (e.g. focus highlight) still force a
|
||||
flush per widget; moving tint to per-vertex color would let a whole
|
||||
row of widgets batch into one draw call regardless of highlight
|
||||
state.
|
||||
6. Revisit the GameCube/Wii networking static-IP workaround in
|
||||
`networkdolphin.c` -- it's standing in for an unresolved suspected
|
||||
memory-corruption bug in `if_config()`'s DHCP path.
|
||||
7. Decide whether the PSP dialog-based network connect UI needs to come
|
||||
back -- it was removed entirely (not fixed) when the original
|
||||
dialog-tearing bug proved hard to resolve.
|
||||
8. Backfill unit tests for the biggest untested surfaces: `ui/` (whole
|
||||
widget framework), `save/`, `script/` (JerryScript bindings), `event/`.
|
||||
|
||||
## Principles
|
||||
|
||||
- Never trust the network implicitly. Neither side (server or client)
|
||||
should assume the other's packets are well-formed or benign --
|
||||
validate all incoming packet data defensively, since either side
|
||||
may send garbage or malicious data. Use `errorret_t` /
|
||||
`errorThrow()` for these runtime checks, not assert macros --
|
||||
asserts are debug-only and won't guard release builds against
|
||||
malformed or malicious packet data.
|
||||
@@ -0,0 +1,120 @@
|
||||
# Dusk Engine - Status Snapshot
|
||||
|
||||
This is a point-in-time inventory of the codebase's maturity, test coverage,
|
||||
and known gaps. It is not auto-maintained -- re-survey periodically (or
|
||||
whenever picking a new roadmap milestone) rather than trusting it blindly.
|
||||
See `ROADMAP.md` for the ordered feature milestones this status feeds into,
|
||||
and `CLAUDE.md` for coding conventions.
|
||||
|
||||
Last surveyed: 2026-07-31, at commit `8f8fa8f8`.
|
||||
|
||||
## Core engine (`src/dusk/`)
|
||||
|
||||
| Subsystem | Maturity | Notes |
|
||||
|------------|------------------------------------|-------|
|
||||
| asset | Mature, fully wired | Model loading's "async" path is actually synchronous (`assetmodelloader.h`) -- only real stub found in core. |
|
||||
| script | Mature for its current scope | Registered modules: `modulePlatform`, `moduleComponent`/`moduleComponentList` (typed Position/Physics/Renderable wrappers), `moduleEntity`, `moduleScene` (with `Scene.set()` module lifecycle), `moduleMesh`, `moduleTime`, `moduleRequire` (CommonJS-style `require()`/`module.exports`). Entry point is `scripts/init.js`, which does `require('./overworldscene.js')` + `Scene.set()`. Has unit tests (`test/script/`). |
|
||||
| entity | Mature | Engine-level prefab lists are empty sentinels; all real prefabs live in `duskrpg`. |
|
||||
| scene | Mature | Same prefab-delegation pattern as entity. No JSON serialize/deserialize (removed by design). |
|
||||
| save | Mature, but undocumented | Slot-based, yyjson + CRC32, platform stream hooks. Not covered in `CLAUDE.md`, no tests. |
|
||||
| network | Connection-state layer only | HTTP client + connection state machine; no multiplayer/replication protocol (expected -- that's roadmap items 8-17). Not covered in `CLAUDE.md`, has HTTP tests only. |
|
||||
| physics | Mature, recently churned | Recent revert/re-disable of "old ent code" suggests component wiring around physics isn't fully settled. Well tested. |
|
||||
| animation | Early/mid-stage | Keyframes + easing only, no blend trees or state machines. Terse commit history ("ANIM") suggests still iterating. |
|
||||
| display | Most mature/battle-tested | Backbone of the engine; dominated by platform optimization commits. |
|
||||
| ui | Actively churning, perf pass done | Widget framework has had features added and ripped out repeatedly (story/battle UI added then removed). No JS bindings yet (from-scratch surface if that's picked up). Sprite-cache pass landed for slider/tab/frame/textbox (see roadmap item 4 below); still no scripted pointer/hit-testing. Has unit tests for the new caching logic (`test/ui/`), but nothing exercises actual draw calls -- see below. |
|
||||
| console | Small, finished for its scope | Fixed-size cached mesh (no more alloc/free churn), same pattern the rest of `ui/` now follows. |
|
||||
| event | Clean, small, finished | Pub/sub, rebuilt to replace the old input system. |
|
||||
| game | Intentionally header-only | Real implementation lives in `duskrpg/game/game.c`. |
|
||||
|
||||
### UI rendering performance (roadmap item 4)
|
||||
First pass landed 2026-07-31: `uislider`/`uitab` now cache their non-text
|
||||
quads (track/fill/markers, tab background) relative to origin and only
|
||||
rebuild on state change, translating into position at draw time.
|
||||
`uiframe.c` grew `uiFrameDrawCached()`, which skips rebuilding its 9-slice
|
||||
sprites when x/y/width/height match the last call; wired into the
|
||||
confirm dialog, settings panel, and textbox (each owns its own
|
||||
`uiframecache_t`). `uitextbox` no longer does one `spriteBatchBuffer` call
|
||||
per visible glyph -- it builds a per-page glyph cache once and slices a
|
||||
prefix by scroll each frame. `uiconsole` dropped its alloc/free vertex
|
||||
buffer for a fixed 512-glyph array. `uifps` skips its label rebuild when
|
||||
the formatted FPS string hasn't changed.
|
||||
|
||||
Still open: every widget still issues its own `spriteBatchBuffer` call
|
||||
per material/color, so a row of alternating highlighted/plain widgets
|
||||
still forces a GPU flush per widget (color is applied via material, not
|
||||
per-vertex) -- that's the next real win if PSP framerate is still an
|
||||
issue. No scripted pointer/hit-testing exists either; input is still
|
||||
100% gamepad/keyboard directional-focus (`ui/focus/`).
|
||||
|
||||
Test coverage caveat: `test/ui/` and `test/display/test_spritebatchsprite.c`
|
||||
cover the new caching *logic* (geometry math, exercised by constructing
|
||||
widget structs directly) but cannot exercise `uiXxxDraw()`/`uiFrameDraw()`
|
||||
themselves -- those need `FONT_DEFAULT`/`UI_FRAME`'s GL texture, which
|
||||
needs a live GL context this test binary doesn't have (confirmed: calling
|
||||
`fontInitDefault()` in a test asserts in `texturegl.c`). This is true of
|
||||
the whole rendering layer, not something newly introduced -- there's no
|
||||
GL-backed test harness anywhere in the repo yet.
|
||||
|
||||
## Game layer (`src/duskrpg/`)
|
||||
|
||||
Actively maintained, not orphaned (despite an old "remove rpg" commit deep
|
||||
in history) -- last touched the same day as this survey.
|
||||
|
||||
- **cutscene/** -- actively developed, matches `CLAUDE.md`'s documented
|
||||
recipe exactly. 16 registered item types.
|
||||
- **entity/, scene/** -- overworld player/camera/interactable components
|
||||
and prefabs, active.
|
||||
- **item/** -- `item.c`/`inventory.c`/`backpack.c` built via a working
|
||||
`item.json` -> `itemdef.h` codegen pipeline. `itemgive.c/h` exist on
|
||||
disk but are explicitly excluded from the CMake build pending textbox
|
||||
UI restoration -- **that UI (`ui/textbox/`) is already restored**, so
|
||||
this looks like an overdue follow-up, not a real blocker.
|
||||
- **input/** -- headers only, no implementation. Contains the one
|
||||
genuine TODO found in the whole `duskrpg` tree: `// TODO: Wiimote, USB
|
||||
Keyboard, probably more.`
|
||||
- **ui/** -- textbox restored and built; `uitestlabel.c/h` is an
|
||||
intentional smoke-test scaffold, not dead code.
|
||||
|
||||
## Platform layers
|
||||
|
||||
| Platform | Status |
|
||||
|--------------|--------|
|
||||
| duskgl / dusksdl2 | Complete, shared by Linux/Knulli/PSP, no gaps found. |
|
||||
| dusklinux | Complete, well-trodden. |
|
||||
| duskpsp | Complete for current design. The historical dialog/tearing bug (see memory `project_psp_dialog_tearing` etc.) was **not fixed -- the dialog-based connect UI was removed entirely** (commit `d7982599`, "Simplified PSP network") in favor of a silent profile-based connect. Revisit if the dialog UX is still wanted. |
|
||||
| duskdolphin (GameCube/Wii) | Functional, not a stub -- real GX-based display/mesh/shader/texture. Wii input uses only the GameCube `PAD_*` library; no WPAD/Wiimote support (`inputdolphin.h` has `#error "Wii not implemented"` gated behind macros that are never defined, so currently dormant, not a live build break). `networkdolphin.c` hardcodes a static IP as an explicit temporary workaround for a suspected DHCP-related memory-corruption bug in `if_config()` -- root cause still open. |
|
||||
| vita | **Referenced by `scripts/build-vita.sh` and `docker/vita/` but no `cmake/targets/vita.cmake` exists** -- the build target is broken/unfinished at the CMake level. |
|
||||
|
||||
### CI coverage gap
|
||||
`.github/workflows/test.yml` only builds+tests Linux, on PRs to `main`.
|
||||
`build.yml` builds all other platforms (PSP, Knulli, GameCube, Wii +
|
||||
ISO variants) but **only on tag push** (release time). Vita and Dolphin
|
||||
aren't in CI at all. Net effect: regressions on 4+ platforms can land
|
||||
silently until a release tag is cut.
|
||||
|
||||
## Test coverage gaps
|
||||
|
||||
Core `src/dusk/` subsystems with **zero** unit tests: `console`,
|
||||
`engine`, `event`, `game`, `input`, `log`, `save`, `script` (+ all JS
|
||||
module bindings), `system`, `ui` (entire widget framework).
|
||||
|
||||
`src/duskrpg/` has almost no test coverage: `test/item/test_inventory.c`
|
||||
exists but **`add_subdirectory(item)` is commented out in
|
||||
`test/CMakeLists.txt`**, so even that one test never runs. `cutscene`,
|
||||
`entity`, `game`, `input`, `scene`, `ui` under `duskrpg` have no tests at
|
||||
all.
|
||||
|
||||
No stale tests were found referencing deleted systems (old JSON
|
||||
serialize/deserialize, old event/cutscene modules) -- the test suite is
|
||||
internally consistent with current code, just incomplete in coverage.
|
||||
|
||||
## Build/tooling gaps worth knowing about
|
||||
|
||||
- `assetsraw/` -> `assets/` (chunk JSON -> `.dcf`) is a manual/editor-only
|
||||
step (`tools.asset.chunk`), not part of the CMake build -- committed
|
||||
`.dcf` files can silently drift from their raw source.
|
||||
- Several Python tool packages exist but aren't wired into any build:
|
||||
`tools/color/csv/`, `tools/asset/chunk_json/`, `tools/asset/dmf/`,
|
||||
`tools/asset/tiles/`, `tools/input/csv/`. Some may be superseded by
|
||||
`tools/color.py`/`tools/item.py`; worth a pass to confirm which are
|
||||
live vs leftover.
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"moves": {
|
||||
"fire": {
|
||||
// Target flags
|
||||
"enemies": true,
|
||||
"allies": true,
|
||||
"multiple": false,
|
||||
"self": true,
|
||||
"default": "enemy",
|
||||
"target": "SINGLE_ENEMY"
|
||||
},
|
||||
|
||||
"slash": {
|
||||
"enemies": true,
|
||||
"allies": true,
|
||||
"self": false,
|
||||
"default": "enemy",
|
||||
"target": "SINGLE_ENEMY"
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "MODAL",
|
||||
"title": "Fire",
|
||||
"message": "A burst of flame scorches the target."
|
||||
},
|
||||
{
|
||||
"type": "WAIT",
|
||||
"seconds": 2
|
||||
},
|
||||
{
|
||||
"type": "MODAL_CLOSE"
|
||||
},
|
||||
{
|
||||
"type": "BATTLE_FIGHTER_DAMAGE",
|
||||
"fighter": "target",
|
||||
"amount": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "MODAL",
|
||||
"title": "Slash",
|
||||
"message": "A quick blade strike cuts across the target."
|
||||
},
|
||||
{
|
||||
"type": "WAIT",
|
||||
"seconds": 2
|
||||
},
|
||||
{
|
||||
"type": "MODAL_CLOSE"
|
||||
},
|
||||
{
|
||||
"type": "BATTLE_FIGHTER_DAMAGE",
|
||||
"fighter": "target",
|
||||
"amount": 8
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "BATTLE_START",
|
||||
"enemies": [
|
||||
{
|
||||
"attack": 8, "defense": 4, "magic": 0, "speed": 5, "luck": 2,
|
||||
"healthMax": 30, "mpMax": 0,
|
||||
"abilities": ["fire"]
|
||||
},
|
||||
{
|
||||
"attack": 6, "defense": 3, "magic": 0, "speed": 7, "luck": 2,
|
||||
"healthMax": 20, "mpMax": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
// First thing, try and find a save device, used for settings and what not.
|
||||
{
|
||||
"type": "MODAL",
|
||||
"title": "initial.checking_save.title",
|
||||
"message": "initial.checking_save.message"
|
||||
},
|
||||
{
|
||||
"type": "WAIT",
|
||||
"seconds": 0.2
|
||||
},
|
||||
{
|
||||
"type": "SAVE_DEVICE_CHECK",
|
||||
"successMarker": "CONTINUE",
|
||||
"failureMarker": "SAVE_DEVICE_NOT_FOUND"
|
||||
},
|
||||
|
||||
// No save device found
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "SAVE_DEVICE_NOT_FOUND"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_CLOSE"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_OPTIONS_MARKERS",
|
||||
"title": "initial.no_device.title",
|
||||
"message": "initial.no_device.message",
|
||||
"options": [
|
||||
{
|
||||
"text": "initial.no_device.retry",
|
||||
"marker": "SAVE_DEVICE_RETRY"
|
||||
},
|
||||
{
|
||||
"text": "initial.no_device.continue",
|
||||
"marker": "CONTINUE"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// Save device not found, user to retry, just close modal and loop
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "SAVE_DEVICE_RETRY"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_CLOSE"
|
||||
},
|
||||
{
|
||||
"type": "RESTART"
|
||||
},
|
||||
|
||||
// Save device found (or continuing without one)
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "CONTINUE"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_CLOSE"
|
||||
},
|
||||
{
|
||||
"type": "CUTSCENE",
|
||||
"name": "cutscenes/main_menu.jsonc"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
{
|
||||
"items": [
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "MAIN_MENU_IDLE"
|
||||
},
|
||||
{
|
||||
"type": "UI_SHOW",
|
||||
"name": "main_menu"
|
||||
},
|
||||
|
||||
// Options button goes here - no options screen yet, so this is just
|
||||
// an alias landing right back on the idle loop below.
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "OPTIONS"
|
||||
},
|
||||
{
|
||||
"type": "IDLE"
|
||||
},
|
||||
|
||||
// New Game button goes here.
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "NEW_GAME"
|
||||
},
|
||||
{
|
||||
"type": "MODAL",
|
||||
"title": "main_menu.checking_save.title",
|
||||
"message": "main_menu.checking_save.message"
|
||||
},
|
||||
{
|
||||
"type": "WAIT",
|
||||
"seconds": 0.2
|
||||
},
|
||||
{
|
||||
"type": "SAVE_DEVICE_CHECK",
|
||||
"successMarker": "SAVE_DEVICE_FOUND",
|
||||
"failureMarker": "SAVE_DEVICE_NOT_FOUND"
|
||||
},
|
||||
|
||||
// Save device not found
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "SAVE_DEVICE_NOT_FOUND"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_CLOSE"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_OPTIONS_MARKERS",
|
||||
"title": "main_menu.no_device.title",
|
||||
"message": "main_menu.no_device.message",
|
||||
"options": [
|
||||
{
|
||||
"text": "main_menu.no_device.retry",
|
||||
"marker": "NEW_GAME"
|
||||
},
|
||||
{
|
||||
"text": "main_menu.no_device.continue",
|
||||
"marker": "SAVE_DEVICE_FOUND"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// Save data failed to load (e.g. corrupt/unreadable) - only option is
|
||||
// to retry, no "continue without saving" here since we already know a
|
||||
// device is present.
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "LOAD_ERROR"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_OPTIONS_MARKERS",
|
||||
"title": "main_menu.save_load_error.title",
|
||||
"message": "main_menu.save_load_error.message",
|
||||
"options": [
|
||||
{
|
||||
"text": "main_menu.save_load_error.retry",
|
||||
"marker": "NEW_GAME"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// Quit Game button goes here. Cancelling jumps back to
|
||||
// MAIN_MENU_IDLE; confirming falls through to QUIT_GAME, which
|
||||
// ends the process directly.
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "QUIT"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_OPTIONS_MARKERS",
|
||||
"title": "main_menu.quit_confirm",
|
||||
"options": [
|
||||
{
|
||||
"text": "ui.confirm.confirm",
|
||||
"marker": "QUIT_CONFIRMED"
|
||||
},
|
||||
{
|
||||
"text": "ui.confirm.cancel",
|
||||
"marker": "MAIN_MENU_IDLE"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "QUIT_CONFIRMED"
|
||||
},
|
||||
{
|
||||
"type": "QUIT_GAME"
|
||||
},
|
||||
|
||||
// main menu just listens for cutscene ending to show the select save modal
|
||||
// so we have that here.
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "SAVE_DEVICE_FOUND"
|
||||
},
|
||||
{
|
||||
"type": "MODAL_CLOSE"
|
||||
},
|
||||
{
|
||||
"type": "SAVE_LOAD_ALL_SLOTS",
|
||||
"successMarker": "LOADED",
|
||||
"failureMarker": "LOAD_ERROR"
|
||||
},
|
||||
|
||||
// Must be the very last item - falling off the end here is what
|
||||
// completes the cutscene and fires uiMainMenuOpenSelectSave (see
|
||||
// cutsceneSystemSetOnComplete in ui/screen/mainmenu/uimainmenu.c).
|
||||
// Placing this anywhere earlier would fall through into whatever
|
||||
// comes next instead (e.g. the QUIT block, if placed just before it).
|
||||
{
|
||||
"type": "MARKER",
|
||||
"name": "LOADED"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
// Placeholder for the new-game intro flow - just shows a modal for now.
|
||||
"items": [
|
||||
{
|
||||
"type": "MODAL",
|
||||
"title": "New Game",
|
||||
"message": "This is a placeholder for the new game intro.",
|
||||
"blocking": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"items": {
|
||||
"potion": { "type": "MEDICINE" },
|
||||
"potato": { "type": "FOOD" },
|
||||
"apple": { "type": "FOOD" }
|
||||
}
|
||||
}
|
||||
+1
-224
@@ -5,113 +5,11 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n==2 ? 1 : (n<7 ? 2 : 3));\n"
|
||||
|
||||
# Initial Scene
|
||||
msgid "initial.checking_save.title"
|
||||
msgstr "Checking for save data"
|
||||
|
||||
msgid "initial.checking_save.message"
|
||||
msgstr "Please wait..."
|
||||
|
||||
msgid "initial.no_device.title"
|
||||
msgstr "No Save Device Found"
|
||||
|
||||
msgid "initial.no_device.message"
|
||||
msgstr "Could not find a save device, ensure it is connected and try again. You can continue, but progress will not be saved."
|
||||
|
||||
msgid "initial.no_device.retry"
|
||||
msgstr "Try again"
|
||||
|
||||
msgid "initial.no_device.continue"
|
||||
msgstr "Continue without saving"
|
||||
|
||||
|
||||
# Main Menu Scene
|
||||
msgid "main_menu.start_game"
|
||||
msgstr "Start Game"
|
||||
|
||||
msgid "main_menu.options"
|
||||
msgstr "Options"
|
||||
|
||||
msgid "main_menu.quit"
|
||||
msgstr "Quit Game"
|
||||
|
||||
msgid "main_menu.quit_confirm"
|
||||
msgstr "Are you sure you want to quit?"
|
||||
|
||||
msgid "main_menu.checking_save.title"
|
||||
msgstr "Checking for save data"
|
||||
|
||||
msgid "main_menu.checking_save.message"
|
||||
msgstr "Please wait..."
|
||||
|
||||
msgid "main_menu.no_device.title"
|
||||
msgstr "No Save Device Found"
|
||||
|
||||
msgid "main_menu.no_device.message"
|
||||
msgstr "Could not find a save device, ensure it is connected and try again. You can continue, but progress will not be saved."
|
||||
|
||||
msgid "main_menu.no_device.retry"
|
||||
msgstr "Try again"
|
||||
|
||||
msgid "main_menu.no_device.continue"
|
||||
msgstr "Continue without saving"
|
||||
|
||||
msgid "main_menu.save_load_error.title"
|
||||
msgstr "Error"
|
||||
|
||||
msgid "main_menu.save_load_error.message"
|
||||
msgstr "Failed to load save data. Please try again."
|
||||
|
||||
msgid "main_menu.save_load_error.retry"
|
||||
msgstr "Try Again"
|
||||
|
||||
|
||||
# Select Save Screen
|
||||
msgid "ui.select_save.title"
|
||||
msgstr "Select Save"
|
||||
|
||||
msgid "ui.select_save.empty"
|
||||
msgstr "Empty Slot"
|
||||
|
||||
msgid "ui.select_save.corrupt"
|
||||
msgstr "Corrupted Save"
|
||||
|
||||
msgid "ui.select_save.corrupt_warning"
|
||||
msgstr "This save file is corrupted and could not be loaded. Please contact support if this issue persists."
|
||||
|
||||
msgid "ui.select_save.slot_format"
|
||||
msgstr "%s Lv.%d %s"
|
||||
|
||||
msgid "ui.select_save.delete_mode"
|
||||
msgstr "Delete a Save"
|
||||
|
||||
msgid "ui.select_save.delete_confirm"
|
||||
msgstr "Are you sure you want to delete this save?"
|
||||
|
||||
msgid "ui.select_save.name_title"
|
||||
msgstr "Enter game save file name"
|
||||
|
||||
msgid "ui.save_slot.number_format"
|
||||
msgstr "Slot %d"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#: ui/menu.c:10
|
||||
msgid "ui.title"
|
||||
msgstr ""
|
||||
"Welcome"
|
||||
|
||||
msgid "save.linux.mkdirp_failed"
|
||||
msgstr "Failed to create save directory, check the disk is not full or write-protected."
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.general"
|
||||
msgstr "General"
|
||||
@@ -158,118 +56,6 @@ msgstr "Items"
|
||||
msgid "ui.game_menu.settings"
|
||||
msgstr "Settings"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save"
|
||||
msgstr "Save"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save_success"
|
||||
msgstr "Game saved."
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save_cancelled"
|
||||
msgstr "Save cancelled."
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save_unavailable"
|
||||
msgstr "Can't save - no save device found."
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save_temporary"
|
||||
msgstr "This session is temporary - no save device was found, so saving is disabled."
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save_create_confirm"
|
||||
msgstr "No save data found. Create a new save?"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save_failed_format"
|
||||
msgstr "Save failed: %s"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.save_check_failed_format"
|
||||
msgstr "Can't save: %s"
|
||||
|
||||
#: src/dusk/ui/frame/initial/uiinitialnocard.c
|
||||
msgid "ui.initial.no_card.message"
|
||||
msgstr "No save device found. You can continue, but\nprogress will not be saved."
|
||||
|
||||
#: src/dusk/ui/frame/initial/uiinitialnocard.c
|
||||
msgid "ui.initial.no_card.retry"
|
||||
msgstr "Retry"
|
||||
|
||||
#: src/dusk/ui/frame/initial/uiinitialnocard.c
|
||||
msgid "ui.initial.no_card.continue"
|
||||
msgstr "Continue Anyway"
|
||||
|
||||
#: src/dusk/ui/frame/initial/uiinitialcreatesave.c
|
||||
msgid "ui.initial.create_save.message"
|
||||
msgstr "No save data found. Create a new save?"
|
||||
|
||||
#: src/dusk/ui/frame/initial/uiinitialcreatesave.c
|
||||
msgid "ui.initial.create_save.yes"
|
||||
msgstr "Yes"
|
||||
|
||||
#: src/dusk/ui/frame/initial/uiinitialcreatesave.c
|
||||
msgid "ui.initial.create_save.no"
|
||||
msgstr "No"
|
||||
|
||||
#: src/dusk/ui/frame/uiconfirm.c
|
||||
msgid "ui.confirm.confirm"
|
||||
msgstr "Confirm"
|
||||
|
||||
#: src/dusk/ui/frame/uiconfirm.c
|
||||
msgid "ui.confirm.cancel"
|
||||
msgstr "Cancel"
|
||||
|
||||
#: src/dusk/ui/frame/battle/uibattlemenu.c
|
||||
msgid "ui.battle.menu.attack"
|
||||
msgstr "Attack"
|
||||
|
||||
#: src/dusk/ui/frame/battle/uibattlemenu.c
|
||||
msgid "ui.battle.menu.flee"
|
||||
msgstr "Flee"
|
||||
|
||||
#: src/dusk/ui/frame/battle/uibattlemenu.c
|
||||
msgid "ui.battle.menu.target_format"
|
||||
msgstr "Enemy %u (%u/%u HP)"
|
||||
|
||||
#: src/dusk/ui/frame/battle/uibattlehud.c
|
||||
msgid "ui.battle.hud.hp_format"
|
||||
msgstr "HP %u/%u"
|
||||
|
||||
#: src/dusk/ui/frame/battle/uibattlehud.c
|
||||
msgid "ui.battle.hud.mp_format"
|
||||
msgstr "MP %u/%u"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettingsaudio.c
|
||||
msgid "ui.settings.audio.placeholder"
|
||||
msgstr "No audio settings yet"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettingsdisplay.c
|
||||
msgid "ui.settings.display.placeholder"
|
||||
msgstr "No display settings yet"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettingsinput.c
|
||||
msgid "ui.settings.input.placeholder"
|
||||
msgstr "No input settings yet"
|
||||
|
||||
#: src/dusk/ui/frame/backpack/uibackpack.c
|
||||
msgid "ui.backpack.category_format"
|
||||
msgstr "Category %u"
|
||||
|
||||
#: src/dusk/ui/overlay/uiloading.c
|
||||
msgid "ui.loading.text"
|
||||
msgstr "loading"
|
||||
|
||||
#: src/dusk/ui/overlay/uiautosave.c
|
||||
msgid "ui.autosave.saving"
|
||||
msgstr "SAVING"
|
||||
|
||||
|
||||
#
|
||||
# Items
|
||||
#
|
||||
msgid "item.potion.name"
|
||||
msgstr "Potion"
|
||||
|
||||
@@ -277,13 +63,4 @@ msgid "item.potato.name"
|
||||
msgstr "Potato"
|
||||
|
||||
msgid "item.apple.name"
|
||||
msgstr "Apple"
|
||||
|
||||
#
|
||||
# Moves
|
||||
#
|
||||
msgid "move.fire.name"
|
||||
msgstr "Fire"
|
||||
|
||||
msgid "move.slash.name"
|
||||
msgstr "Slash"
|
||||
msgstr "Apple"
|
||||
@@ -0,0 +1,70 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: ExampleApp 1.0\n"
|
||||
"Language: es\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n==1 ? 0 : 1);\n"
|
||||
|
||||
#: ui/menu.c:10
|
||||
msgid "ui.title"
|
||||
msgstr ""
|
||||
"Bienvenido"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.general"
|
||||
msgstr "General"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.input"
|
||||
msgstr "Entrada"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.display"
|
||||
msgstr "Pantalla"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.audio"
|
||||
msgstr "Audio"
|
||||
|
||||
msgid "ui.settings.input.deadzone"
|
||||
msgstr "Deadzone"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
||||
msgid "ui.settings.general.language"
|
||||
msgstr "Idioma"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
||||
msgid "ui.settings.general.language_detail"
|
||||
msgstr "Se aplica después de reiniciar la aplicación."
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.apply"
|
||||
msgstr "Aplicar"
|
||||
|
||||
#: src/dusk/ui/frame/uiconfirm.c
|
||||
msgid "ui.confirm.discard_changes"
|
||||
msgstr "¿Descartar los cambios no guardados?"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.characters"
|
||||
msgstr "Personajes"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.items"
|
||||
msgstr "Objetos"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.settings"
|
||||
msgstr "Configuración"
|
||||
|
||||
#: src/dusk/rpg/item/item.json
|
||||
msgid "item.potion.name"
|
||||
msgstr "Poción"
|
||||
|
||||
#: src/dusk/rpg/item/item.json
|
||||
msgid "item.potato.name"
|
||||
msgstr "Papa"
|
||||
|
||||
#: src/dusk/rpg/item/item.json
|
||||
msgid "item.apple.name"
|
||||
msgstr "Manzana"
|
||||
@@ -0,0 +1,70 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: ExampleApp 1.0\n"
|
||||
"Language: ja\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Plural-Forms: nplurals=1; plural=(0);\n"
|
||||
|
||||
#: ui/menu.c:10
|
||||
msgid "ui.title"
|
||||
msgstr ""
|
||||
"歓迎"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.general"
|
||||
msgstr "一般"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.input"
|
||||
msgstr "入力"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.display"
|
||||
msgstr "表示"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.tabs.audio"
|
||||
msgstr "オーディオ"
|
||||
|
||||
msgid "ui.settings.input.deadzone"
|
||||
msgstr "デッドゾーン"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
||||
msgid "ui.settings.general.language"
|
||||
msgstr "言語"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettingsgeneral.c
|
||||
msgid "ui.settings.general.language_detail"
|
||||
msgstr "アプリケーションを再起動すると適用されます。"
|
||||
|
||||
#: src/dusk/ui/frame/settings/uisettings.c
|
||||
msgid "ui.settings.apply"
|
||||
msgstr "適用"
|
||||
|
||||
#: src/dusk/ui/frame/uiconfirm.c
|
||||
msgid "ui.confirm.discard_changes"
|
||||
msgstr "未保存の変更を破棄しますか?"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.characters"
|
||||
msgstr "キャラクター"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.items"
|
||||
msgstr "アイテム"
|
||||
|
||||
#: src/dusk/ui/frame/game/uigamemenu.c
|
||||
msgid "ui.game_menu.settings"
|
||||
msgstr "設定"
|
||||
|
||||
#: src/dusk/rpg/item/item.json
|
||||
msgid "item.potion.name"
|
||||
msgstr "ポーション"
|
||||
|
||||
#: src/dusk/rpg/item/item.json
|
||||
msgid "item.potato.name"
|
||||
msgstr "ジャガイモ"
|
||||
|
||||
#: src/dusk/rpg/item/item.json
|
||||
msgid "item.apple.name"
|
||||
msgstr "リンゴ"
|
||||
@@ -1 +0,0 @@
|
||||
{"meshes":[{"file":"house_4_4.dmf","pos":[2,1,0]},{"file":"house_6_3.dmf","pos":[1,9,0]},{"file":"house_2_2.dmf","pos":[12,6,0]}],"tiles":[[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0]]}
|
||||
@@ -1 +0,0 @@
|
||||
{"tiles":[[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[6,0],[2,0],[2,0],[2,0],[2,0],[2,0],[2,0],[7,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[3,0],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[5,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[3,0],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[5,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[3,0],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[5,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[8,0],[4,0],[4,0],[4,0],[12,0],[1,1],[1,1],[5,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[3,0],[1,1],[1,1],[5,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[3,0],[1,1],[1,1],[5,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[8,0],[4,0],[4,0],[9,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0]],"meshes":[{"file":"house_5_3.dmf","pos":[1,1,0]}],"entities":[{"type":"global","globalId":3,"pos":[8,8,1]},{"type":"global","globalId":4,"pos":[12,2,0]}],"areas":[{"min":[11,3,0],"max":[16,9,10],"callbackId":1,"notify":3,"trigger":6}]}
|
||||
@@ -1 +0,0 @@
|
||||
{"meshes":[{"file":"house_8_4.dmf","pos":[1,1,0]},{"file":"house_3_3.dmf","pos":[11,2,0]},{"file":"house_2_2.dmf","pos":[3,11,0]}],"tiles":[[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,null,null,null,[1,0],[1,0],null,null,null,[1,0],[1,0],[1,0],null,null,null,null,null,null,null,null,[1,0],[1,0],null,null,null,[1,0],[1,0],[1,0],null,null,null,null,null,null,null,null,[1,0],[1,0],null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0]]}
|
||||
@@ -1 +0,0 @@
|
||||
{"meshes":[{"file":"house_3_2.dmf","pos":[1,1,0]},{"file":"house_2_3.dmf","pos":[7,2,0]},{"file":"house_4_2.dmf","pos":[1,8,0]},{"file":"house_1_1.dmf","pos":[11,10,0]},{"file":"house_5_2.dmf","pos":[13,6,0]}],"tiles":[[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,[1,0],null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0]]}
|
||||
@@ -1 +0,0 @@
|
||||
{"meshes":[{"file":"house_5_5.dmf","pos":[3,2,0]},{"file":"house_2_3.dmf","pos":[10,3,0]},{"file":"house_3_1.dmf","pos":[1,12,0]}],"tiles":[[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],null,null,null,[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0]]}
|
||||
@@ -1 +0,0 @@
|
||||
{"tiles":[[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,3],[1,3],[1,3],[1,3],[1,3],[1,3],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,3],[1,3],[1,3],[1,3],[1,3],[1,3],[1,0],[1,0],[1,0],[1,0],null,null,[1,0],[1,0],[1,0],[1,0],[1,3],[1,3],[1,3],[1,3],[1,3],[1,3],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[4,1],[4,1],[4,1],[4,1],[4,1],[4,1],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0]],"meshes":[]}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"mesh": "meshes/chunks/chunk_-1_0_0_0.dmf",
|
||||
"color": [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"texture": "tiles.png"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"mesh": "meshes/chunks/chunk_0_0_0_0.dmf",
|
||||
"color": [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"texture": "tiles.png"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"mesh": "meshes/chunks/chunk_0_1_0_0.dmf",
|
||||
"color": [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"texture": "tiles.png"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"mesh": "meshes/chunks/chunk_1_0_0_0.dmf",
|
||||
"color": [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"texture": "tiles.png"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"mesh": "meshes/chunks/chunk_1_1_0_0.dmf",
|
||||
"color": [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"texture": "tiles.png"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"mesh": "meshes/chunks/chunk_2_0_0_0.dmf",
|
||||
"color": [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
],
|
||||
"texture": "tiles.png"
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"members": {
|
||||
"hero": {
|
||||
"attack": 10,
|
||||
"defense": 5,
|
||||
"magic": 0,
|
||||
"speed": 10,
|
||||
"luck": 0,
|
||||
"healthMax": 30,
|
||||
"mpMax": 10
|
||||
},
|
||||
"companion": {
|
||||
"attack": 8,
|
||||
"defense": 6,
|
||||
"magic": 4,
|
||||
"speed": 8,
|
||||
"luck": 1,
|
||||
"healthMax": 25,
|
||||
"mpMax": 15
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
// Entry point run once at startup (see game.c). Swap which scene module
|
||||
// gets passed to Scene.set() here to change what the game boots into.
|
||||
var overworldScene = require('./overworldscene.js');
|
||||
Scene.set(overworldScene);
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
// Radius must stay well outside the floor's footprint (a 20x20 plane has a
|
||||
// corner-to-center distance of 10*sqrt(2) =~ 14.1) -- orbiting inside that
|
||||
// puts parts of the floor's own geometry near/behind the camera's view
|
||||
// direction, which the PSP's legacy GU pipeline can't clip properly and
|
||||
// drops the whole triangle instead of clipping it.
|
||||
var CAMERA_ORBIT_RADIUS = 18.0;
|
||||
var CAMERA_ORBIT_HEIGHT = 10.0;
|
||||
var CAMERA_ORBIT_SPEED = 0.5;
|
||||
|
||||
var cameraOrbitAngle = 0.0;
|
||||
var cameraPosition = null;
|
||||
|
||||
// Orbits the camera around the world origin at a fixed radius/height/
|
||||
// speed, always looking back at the origin. Called once up front (so the
|
||||
// very first rendered frame is already positioned correctly) and then
|
||||
// once per frame via update() below.
|
||||
function updateCameraOrbit() {
|
||||
cameraOrbitAngle += Time.delta * CAMERA_ORBIT_SPEED;
|
||||
|
||||
var eyeX = Math.cos(cameraOrbitAngle) * CAMERA_ORBIT_RADIUS;
|
||||
var eyeY = CAMERA_ORBIT_HEIGHT;
|
||||
var eyeZ = Math.sin(cameraOrbitAngle) * CAMERA_ORBIT_RADIUS;
|
||||
|
||||
cameraPosition.lookAt(eyeX, eyeY, eyeZ, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// Called once by Scene.set(), right after it creates and activates the
|
||||
// scene this module owns.
|
||||
init: function() {
|
||||
// Camera, orbiting the origin (see updateCameraOrbit above).
|
||||
var camera = new Entity();
|
||||
cameraPosition = camera.add(POSITION);
|
||||
camera.add(CAMERA);
|
||||
updateCameraOrbit();
|
||||
|
||||
// Static ground plane. Physics ignores the entity's position
|
||||
// component -- the shape's own normal/distance fully define the
|
||||
// plane in world space.
|
||||
var plane = new Entity();
|
||||
var planePosition = plane.add(POSITION);
|
||||
planePosition.setLocalPosition(-10.0, 0.0, -10.0);
|
||||
planePosition.setLocalScale(20.0, 1.0, 20.0);
|
||||
|
||||
var planePhysics = plane.add(PHYSICS);
|
||||
planePhysics.setBodyType(PHYSICS_BODY_STATIC);
|
||||
planePhysics.setShape(PHYSICS_SHAPE_PLANE, 0.0, 1.0, 0.0, 0.0);
|
||||
|
||||
var planeRenderable = plane.add(RENDERABLE);
|
||||
planeRenderable.setMesh(0, MESH_PLANE);
|
||||
planeRenderable.setColor(128, 128, 128, 255);
|
||||
|
||||
// Player: dynamic capsule body, moved relative to the camera by
|
||||
// PLAYER's own update callback (see entityplayer.c).
|
||||
var player = new Entity();
|
||||
var playerPosition = player.add(POSITION);
|
||||
playerPosition.setLocalPosition(0.0, 2.0, 0.0);
|
||||
|
||||
var playerPhysics = player.add(PHYSICS);
|
||||
playerPhysics.setShape(PHYSICS_SHAPE_CAPSULE, 0.5, 0.5);
|
||||
|
||||
var playerRenderable = player.add(RENDERABLE);
|
||||
playerRenderable.setMesh(0, MESH_CAPSULE);
|
||||
playerRenderable.setColor(0, 0, 255, 255);
|
||||
|
||||
player.add(PLAYER);
|
||||
},
|
||||
|
||||
// Called once per engine frame while this module is the active scene
|
||||
// (see Scene.set(), engineUpdate() -> moduleSceneUpdateCurrent()).
|
||||
update: function() {
|
||||
if(cameraPosition) updateCameraOrbit();
|
||||
},
|
||||
|
||||
// Called once by Scene.set() when this module is replaced by another,
|
||||
// right before the scene it owns is destroyed.
|
||||
dispose: function() {
|
||||
cameraPosition = null;
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"flags": {
|
||||
"test": {
|
||||
"initial": true
|
||||
},
|
||||
"test2": {
|
||||
"initial": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,96 @@
|
||||
# Copyright (c) 2026 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Turn things off we don't need
|
||||
set(JERRY_CMDLINE OFF CACHE BOOL "" FORCE)
|
||||
set(JERRY_EXT ON CACHE BOOL "" FORCE)
|
||||
set(JERRY_DEBUGGER OFF CACHE BOOL "" FORCE)
|
||||
set(JERRY_BUILTIN_DATE OFF CACHE BOOL "" FORCE)
|
||||
set(ENABLE_LTO OFF CACHE BOOL "" FORCE)
|
||||
|
||||
# Fetch Jerry
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
jerryscript
|
||||
GIT_REPOSITORY https://git.wish.moe/YourWishes/jerryscript
|
||||
GIT_TAG float32-fix
|
||||
)
|
||||
FetchContent_MakeAvailable(jerryscript)
|
||||
|
||||
# Mark found
|
||||
set(jerryscript_FOUND ON)
|
||||
|
||||
# Define targets
|
||||
if(TARGET jerryscript-core)
|
||||
set(JERRY_CORE_TARGET jerryscript-core)
|
||||
elseif(TARGET jerry-core)
|
||||
set(JERRY_CORE_TARGET jerry-core)
|
||||
endif()
|
||||
|
||||
if(TARGET jerryscript-ext)
|
||||
set(JERRY_EXT_TARGET jerryscript-ext)
|
||||
elseif(TARGET jerry-ext)
|
||||
set(JERRY_EXT_TARGET jerry-ext)
|
||||
endif()
|
||||
|
||||
if(TARGET jerryscript-port-default)
|
||||
set(JERRY_PORT_TARGET jerryscript-port-default)
|
||||
elseif(TARGET jerry-port-default)
|
||||
set(JERRY_PORT_TARGET jerry-port-default)
|
||||
elseif(TARGET jerryscript-port)
|
||||
set(JERRY_PORT_TARGET jerryscript-port)
|
||||
elseif(TARGET jerry-port)
|
||||
set(JERRY_PORT_TARGET jerry-port)
|
||||
endif()
|
||||
|
||||
if(NOT JERRY_CORE_TARGET)
|
||||
message(FATAL_ERROR "JerryScript core target not found")
|
||||
endif()
|
||||
|
||||
if(NOT JERRY_EXT_TARGET)
|
||||
message(FATAL_ERROR "JerryScript ext target not found")
|
||||
endif()
|
||||
|
||||
if(NOT JERRY_PORT_TARGET)
|
||||
message(FATAL_ERROR "JerryScript port target not found")
|
||||
endif()
|
||||
|
||||
foreach(tgt IN ITEMS
|
||||
${JERRY_CORE_TARGET}
|
||||
${JERRY_EXT_TARGET}
|
||||
${JERRY_PORT_TARGET}
|
||||
)
|
||||
if(TARGET ${tgt})
|
||||
set_property(TARGET ${tgt} PROPERTY INTERPROCEDURAL_OPTIMIZATION OFF)
|
||||
target_compile_definitions(${JERRY_CORE_TARGET} PRIVATE
|
||||
JERRY_NUMBER_TYPE_FLOAT64=0
|
||||
JERRY_BUILTIN_DATE=0
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Export include dirs through the targets
|
||||
target_include_directories(${JERRY_CORE_TARGET} INTERFACE
|
||||
${jerryscript_SOURCE_DIR}/jerry-core/include
|
||||
)
|
||||
|
||||
target_include_directories(${JERRY_EXT_TARGET} INTERFACE
|
||||
${jerryscript_SOURCE_DIR}/jerry-ext/include
|
||||
)
|
||||
|
||||
target_include_directories(${JERRY_PORT_TARGET} INTERFACE
|
||||
${jerryscript_SOURCE_DIR}/jerry-port/default/include
|
||||
)
|
||||
|
||||
# Suppress JerryScript-only warning
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
|
||||
target_compile_options(${JERRY_CORE_TARGET} PRIVATE
|
||||
-Wno-error
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(jerryscript::core ALIAS ${JERRY_CORE_TARGET})
|
||||
add_library(jerryscript::ext ALIAS ${JERRY_EXT_TARGET})
|
||||
add_library(jerryscript::port ALIAS ${JERRY_PORT_TARGET})
|
||||
@@ -1,32 +0,0 @@
|
||||
# Copyright (c) 2026 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# NOTE: libmad itself is GPL-licensed (see https://www.underbit.com/products/mad/),
|
||||
# not MIT like the rest of this project. Any binary linking it must comply
|
||||
# with the GPL - a deliberate tradeoff accepted for MP3 decode correctness
|
||||
# (see audiostreammp3decodersw.c's own comment on why minimp3 wasn't enough).
|
||||
|
||||
find_path(LIBMAD_INCLUDE_DIR NAMES mad.h)
|
||||
mark_as_advanced(LIBMAD_INCLUDE_DIR)
|
||||
|
||||
find_library(LIBMAD_LIBRARY NAMES mad)
|
||||
mark_as_advanced(LIBMAD_LIBRARY)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
libmad
|
||||
REQUIRED_VARS
|
||||
LIBMAD_LIBRARY
|
||||
LIBMAD_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(libmad_FOUND AND NOT TARGET libmad::mad)
|
||||
add_library(libmad::mad UNKNOWN IMPORTED)
|
||||
set_target_properties(libmad::mad
|
||||
PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${LIBMAD_INCLUDE_DIR}
|
||||
IMPORTED_LOCATION ${LIBMAD_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
@@ -61,8 +61,6 @@ target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
zstd
|
||||
z
|
||||
lzma
|
||||
asnd
|
||||
mad
|
||||
)
|
||||
|
||||
if(DUSK_DOLPHIN_BUILD_TYPE STREQUAL "ISO")
|
||||
|
||||
@@ -6,7 +6,7 @@ target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
# bba
|
||||
bba
|
||||
)
|
||||
|
||||
# ISO post-build: produce NTSC-J, NTSC-U and PAL disc images
|
||||
|
||||
@@ -27,7 +27,6 @@ target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
)
|
||||
|
||||
set(DUSK_BACKTRACE ON CACHE BOOL "Enable backtrace support for assert failures.")
|
||||
set(DUSK_TRACK_MEMORY ON CACHE BOOL "Track memoryAllocate() call sites to help find memory leaks.")
|
||||
|
||||
# Define platform-specific macros.
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
|
||||
+5
-68
@@ -1,3 +1,7 @@
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_RANLIB "$ENV{PSPDEV}/bin/psp-ranlib" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_C_COMPILER_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
||||
@@ -30,7 +34,6 @@ target_link_libraries(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||
pspgu
|
||||
pspaudio
|
||||
pspaudiolib
|
||||
pspmp3
|
||||
psputility
|
||||
pspvfpu
|
||||
pspvram
|
||||
@@ -56,46 +59,9 @@ target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||
DUSK_DISPLAY_WIDTH=480
|
||||
DUSK_DISPLAY_HEIGHT=272
|
||||
DUSK_THREAD_PTHREAD
|
||||
DUSK_TIME_DYNAMIC
|
||||
DUSK_DISPLAY_OVERSCAN=6
|
||||
)
|
||||
|
||||
# logDebug()/logError() additionally write every call to a file on the
|
||||
# Memory Stick (ms0:/PSP/GAME/Dusk/*.log) - a real, measured source of
|
||||
# per-call hitching (fopen+write+fclose every log line), not just a
|
||||
# theoretical cost. Default off so a normal build doesn't pay it; opt in
|
||||
# with -DDUSK_PSP_LOG_FILE=ON when the log file itself is actually needed
|
||||
# (e.g. no way to see stdout on real hardware).
|
||||
set(DUSK_PSP_LOG_FILE OFF CACHE BOOL "Also write PSP debug/error logs to ms0:/PSP/GAME/Dusk/*.log (slow - Memory Stick I/O per call).")
|
||||
if(DUSK_PSP_LOG_FILE)
|
||||
target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||
DUSK_PSP_LOG_FILE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||
DUSK_ASSERTIONS_FAKED
|
||||
)
|
||||
endif()
|
||||
|
||||
# Generate PARAM.SFO as a normal tracked build output (instead of letting
|
||||
# create_pbp_file() auto-generate + delete it) so it can be reused below by
|
||||
# a properly dependency-tracked EBOOT.PBP repack step.
|
||||
set(DUSK_PSP_PARAM_SFO "${DUSK_BUILD_DIR}/PARAM.SFO")
|
||||
add_custom_command(
|
||||
OUTPUT "${DUSK_PSP_PARAM_SFO}"
|
||||
COMMAND "$ENV{PSPDEV}/bin/mksfoex" "-d" "MEMSIZE=1" "-s" "APP_VER=01.00"
|
||||
"${DUSK_BINARY_TARGET_NAME}" "${DUSK_PSP_PARAM_SFO}"
|
||||
COMMENT "Generating PARAM.SFO for ${DUSK_BINARY_TARGET_NAME}"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(DuskPspParamSfo DEPENDS "${DUSK_PSP_PARAM_SFO}")
|
||||
|
||||
# create_pbp_file()'s own POST_BUILD chain (below) also consumes
|
||||
# DUSK_PSP_PARAM_SFO, so make sure it exists before that chain runs.
|
||||
add_dependencies(${DUSK_BINARY_TARGET_NAME} DuskPspParamSfo)
|
||||
|
||||
# Postbuild, create .pbp file for PSP.
|
||||
create_pbp_file(
|
||||
TARGET "${DUSK_BINARY_TARGET_NAME}"
|
||||
@@ -105,33 +71,4 @@ create_pbp_file(
|
||||
TITLE "${DUSK_BINARY_TARGET_NAME}"
|
||||
PSAR_PATH ${DUSK_ASSETS_ZIP}
|
||||
VERSION 01.00
|
||||
SFO_PATH "${DUSK_PSP_PARAM_SFO}"
|
||||
OUTPUT_DIR "${DUSK_BUILD_DIR}"
|
||||
)
|
||||
|
||||
# CreatePBP.cmake's pack-pbp step is a POST_BUILD command tied to the
|
||||
# executable target, so it only reruns when the ELF itself relinks. That
|
||||
# means regenerating dusk.dsk (assets) alone, without touching any C
|
||||
# source, silently leaves EBOOT.PBP embedding a stale asset pak. Repack it
|
||||
# here as a normal file-tracked custom command depending on both the
|
||||
# executable and the asset zip, so EBOOT.PBP always reflects the current
|
||||
# assets even when nothing else about the build changed.
|
||||
set(DUSK_PSP_EBOOT "${DUSK_BUILD_DIR}/EBOOT.PBP")
|
||||
if(BUILD_PRX)
|
||||
set(DUSK_PSP_EXECUTABLE "$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>.prx")
|
||||
else()
|
||||
set(DUSK_PSP_EXECUTABLE "$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>")
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT "${DUSK_PSP_EBOOT}"
|
||||
COMMAND "$ENV{PSPDEV}/bin/pack-pbp" "${DUSK_PSP_EBOOT}" "${DUSK_PSP_PARAM_SFO}"
|
||||
"NULL" "NULL" "NULL" "NULL" "NULL"
|
||||
"${DUSK_PSP_EXECUTABLE}" "${DUSK_ASSETS_ZIP}"
|
||||
DEPENDS
|
||||
"$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>"
|
||||
"${DUSK_PSP_PARAM_SFO}"
|
||||
"${DUSK_ASSETS_ZIP}"
|
||||
COMMENT "Repacking EBOOT.PBP (tracks executable + asset pak freshness)"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(DuskPspEbootRepack ALL DEPENDS "${DUSK_PSP_EBOOT}")
|
||||
)
|
||||
@@ -1,88 +0,0 @@
|
||||
# Copyright (c) 2026 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
if(NOT DEFINED ENV{VITASDK})
|
||||
message(FATAL_ERROR "VITASDK environment variable is not set.")
|
||||
endif()
|
||||
|
||||
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
|
||||
|
||||
set(VITA_APP_NAME "Dusk")
|
||||
set(VITA_TITLEID "DUSK00001")
|
||||
set(VITA_VERSION "01.00")
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
# Custom flags for cglm
|
||||
set(CGLM_SHARED OFF CACHE BOOL "Build cglm shared" FORCE)
|
||||
set(CGLM_STATIC ON CACHE BOOL "Build cglm static" FORCE)
|
||||
find_package(cglm REQUIRED)
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
${SDL2_LIBRARIES}
|
||||
cglm
|
||||
SDL2
|
||||
SDL2main
|
||||
zip
|
||||
bz2
|
||||
z
|
||||
zstd
|
||||
crypto
|
||||
lzma
|
||||
m
|
||||
pthread
|
||||
stdc++
|
||||
vitaGL
|
||||
mathneon
|
||||
vitashark
|
||||
kubridge_stub
|
||||
SceAppMgr_stub
|
||||
SceAudio_stub
|
||||
SceCtrl_stub
|
||||
SceCommonDialog_stub
|
||||
SceDisplay_stub
|
||||
SceKernelDmacMgr_stub
|
||||
SceGxm_stub
|
||||
SceShaccCg_stub
|
||||
SceSysmodule_stub
|
||||
ScePower_stub
|
||||
SceTouch_stub
|
||||
SceVshBridge_stub
|
||||
SceIofilemgr_stub
|
||||
SceShaccCgExt
|
||||
libtaihen_stub.a
|
||||
|
||||
|
||||
# SceKernel_stub
|
||||
SceAppUtil_stub
|
||||
SceHid_stub
|
||||
SceRtc_stub
|
||||
)
|
||||
|
||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||
${SDL2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_SDL2
|
||||
DUSK_OPENGL
|
||||
DUSK_VITA
|
||||
DUSK_INPUT_GAMEPAD
|
||||
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||
DUSK_OPENGL_LEGACY
|
||||
DUSK_DISPLAY_WIDTH=960
|
||||
DUSK_DISPLAY_HEIGHT=544
|
||||
)
|
||||
|
||||
# Post-build: create SELF from the ELF binary (UNSAFE = homebrew, no signing)
|
||||
vita_create_self(${DUSK_BINARY_TARGET_NAME}.self ${DUSK_BINARY_TARGET_NAME} UNSAFE)
|
||||
|
||||
# Post-build: package SELF + assets into a .vpk installable on the Vita
|
||||
vita_create_vpk(${DUSK_BINARY_TARGET_NAME}.vpk ${VITA_TITLEID} ${DUSK_BINARY_TARGET_NAME}.self
|
||||
VERSION ${VITA_VERSION}
|
||||
NAME ${VITA_APP_NAME}
|
||||
FILE ${DUSK_ASSETS_ZIP} dusk.dsk
|
||||
)
|
||||
@@ -4,17 +4,6 @@ target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_WII
|
||||
)
|
||||
|
||||
# Wii save storage method - see src/duskdolphin/save/savedeviceplatform.h.
|
||||
set(DUSK_SAVE_WII_METHOD "SD" CACHE STRING
|
||||
"Wii save storage: NAND (internal storage via ISFS), CARD (GameCube-\
|
||||
compatible memory card emulation), or SD (SD card via libfat)"
|
||||
)
|
||||
set_property(CACHE DUSK_SAVE_WII_METHOD PROPERTY STRINGS "NAND" "CARD" "SD")
|
||||
|
||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||
DUSK_SAVE_WII_METHOD_${DUSK_SAVE_WII_METHOD}
|
||||
)
|
||||
|
||||
# Generate Homebrew Channel meta.xml from project identity variables
|
||||
string(TIMESTAMP DUSK_BUILD_DATE "%Y%m%d000000" UTC)
|
||||
configure_file(
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM ghcr.io/extremscorner/libogc2
|
||||
WORKDIR /workdir
|
||||
RUN apt update && \
|
||||
dkp-pacman -Syu --noconfirm && \
|
||||
apt install -y python3 python3-pip python3-polib python3-pil python3-dotenv python3-pyqt5 python3-opengl xorriso dolphin-emu xvfb && \
|
||||
dkp-pacman -S --needed --noconfirm gamecube-sdl2 ppc-liblzma ppc-libzip libogc2 gamecube-tools ppc-libmad ppc-zlib-ng ppc-liblzma ppc-bzip2 ppc-zstd
|
||||
VOLUME ["/workdir"]
|
||||
@@ -0,0 +1,28 @@
|
||||
FROM pspdev/pspdev:latest
|
||||
WORKDIR /workdir
|
||||
RUN apk add --no-cache \
|
||||
python3 \
|
||||
py3-pip \
|
||||
py3-dotenv \
|
||||
git \
|
||||
cmake \
|
||||
make \
|
||||
g++ \
|
||||
sdl2-dev \
|
||||
zlib-dev \
|
||||
linux-headers
|
||||
|
||||
# PPSSPP has no Alpine/Linux distro package -- build the "PPSSPPHeadless"
|
||||
# target (the CLI/no-window build PPSSPP's own CI uses for automated runs)
|
||||
# from source instead. The target name and exact CMake options have moved
|
||||
# around across PPSSPP versions -- if this breaks, check
|
||||
# https://github.com/hrydgard/ppsspp's CMakeLists.txt for the current name.
|
||||
RUN git clone --recursive --depth 1 \
|
||||
https://github.com/hrydgard/ppsspp.git /opt/ppsspp && \
|
||||
cd /opt/ppsspp && \
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=Release && \
|
||||
cmake --build build --target PPSSPPHeadless -- -j$(nproc) && \
|
||||
cp build/PPSSPPHeadless /usr/local/bin/PPSSPPHeadless && \
|
||||
rm -rf /opt/ppsspp
|
||||
|
||||
VOLUME ["/workdir"]
|
||||
@@ -0,0 +1,159 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
"use strict";
|
||||
|
||||
// ChunkTerrain - JS port of the terrain-quad generation performed by
|
||||
// tools/asset/chunk/__main__.py (build_terrain_verts / _tile_quad /
|
||||
// _RAMP_CORNERS) so the editor's 3D preview can show the same geometry the
|
||||
// Python compiler will bake into the chunk's terrain mesh, without waiting
|
||||
// for a compile pass. Vertex layout matches DMF: interleaved [u, v, x, y, z].
|
||||
|
||||
const ChunkTerrain = (() => {
|
||||
const CHUNK_WIDTH = 16;
|
||||
const CHUNK_HEIGHT = 16;
|
||||
const CHUNK_DEPTH = 4;
|
||||
const TILE_COUNT = CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH;
|
||||
|
||||
// World-space Z distance of one Z-layer/story, in world-float space.
|
||||
// Must match WORLD_LAYER_HEIGHT in src/dusk/rpg/overworld/worldpos.h.
|
||||
const WORLD_LAYER_HEIGHT = Math.SQRT1_2;
|
||||
|
||||
const TILE_SHAPE_NULL = 0;
|
||||
const TILE_SHAPE_GROUND = 1;
|
||||
const TILE_SHAPE_RAMP_NORTH = 2;
|
||||
const TILE_SHAPE_RAMP_EAST = 3;
|
||||
const TILE_SHAPE_RAMP_SOUTH = 4;
|
||||
const TILE_SHAPE_RAMP_WEST = 5;
|
||||
const TILE_SHAPE_RAMP_NORTHEAST = 6;
|
||||
const TILE_SHAPE_RAMP_NORTHWEST = 7;
|
||||
const TILE_SHAPE_RAMP_SOUTHEAST = 8;
|
||||
const TILE_SHAPE_RAMP_SOUTHWEST = 9;
|
||||
const TILE_SHAPE_RAMP_NORTHEAST_INNER = 10;
|
||||
const TILE_SHAPE_RAMP_NORTHWEST_INNER = 11;
|
||||
const TILE_SHAPE_RAMP_SOUTHEAST_INNER = 12;
|
||||
const TILE_SHAPE_RAMP_SOUTHWEST_INNER = 13;
|
||||
|
||||
// Per-shape corner heights as [sw, se, ne, nw] offsets from tile base Z.
|
||||
// NORTH=+Y, EAST=+X. Cardinal ramps: low face at 0, high face at 1.
|
||||
// Diagonal outer-corner ramps: only the named corner raised, rest at 0.
|
||||
// Diagonal inner-corner ramps: only the corner opposite the named one is
|
||||
// lowered to 0, the rest (including the named corner) stay raised at 1.
|
||||
const RAMP_CORNERS = {
|
||||
[TILE_SHAPE_GROUND]: [0.0, 0.0, 0.0, 0.0],
|
||||
[TILE_SHAPE_RAMP_NORTH]: [0.0, 0.0, 1.0, 1.0],
|
||||
[TILE_SHAPE_RAMP_SOUTH]: [1.0, 1.0, 0.0, 0.0],
|
||||
[TILE_SHAPE_RAMP_EAST]: [0.0, 1.0, 1.0, 0.0],
|
||||
[TILE_SHAPE_RAMP_WEST]: [1.0, 0.0, 0.0, 1.0],
|
||||
[TILE_SHAPE_RAMP_NORTHEAST]: [0.0, 0.0, 1.0, 0.0],
|
||||
[TILE_SHAPE_RAMP_NORTHWEST]: [0.0, 0.0, 0.0, 1.0],
|
||||
[TILE_SHAPE_RAMP_SOUTHEAST]: [0.0, 1.0, 0.0, 0.0],
|
||||
[TILE_SHAPE_RAMP_SOUTHWEST]: [1.0, 0.0, 0.0, 0.0],
|
||||
[TILE_SHAPE_RAMP_NORTHEAST_INNER]: [0.0, 1.0, 1.0, 1.0],
|
||||
[TILE_SHAPE_RAMP_NORTHWEST_INNER]: [1.0, 0.0, 1.0, 1.0],
|
||||
[TILE_SHAPE_RAMP_SOUTHEAST_INNER]: [1.0, 1.0, 1.0, 0.0],
|
||||
[TILE_SHAPE_RAMP_SOUTHWEST_INNER]: [1.0, 1.0, 0.0, 1.0],
|
||||
};
|
||||
|
||||
function tileIndex(x, y, z) {
|
||||
return x + y * CHUNK_WIDTH + z * CHUNK_WIDTH * CHUNK_HEIGHT;
|
||||
}
|
||||
|
||||
// Six vertices (2 CCW triangles) for a quad with per-corner Z heights.
|
||||
// Corner order: SW=(fx,fy), SE=(fx+1,fy), NE=(fx+1,fy+1), NW=(fx,fy+1).
|
||||
function pushTileQuad(out, u0, u1, v0, v1, fx, fy, swZ, seZ, neZ, nwZ) {
|
||||
out.push(
|
||||
u0, v0, fx, fy, swZ,
|
||||
u1, v0, fx + 1, fy, seZ,
|
||||
u1, v1, fx + 1, fy + 1, neZ,
|
||||
u0, v0, fx, fy, swZ,
|
||||
u1, v1, fx + 1, fy + 1, neZ,
|
||||
u0, v1, fx, fy + 1, nwZ,
|
||||
);
|
||||
}
|
||||
|
||||
// Generate terrain quads for every non-null tile in a flat tiles array
|
||||
// (length TILE_COUNT, indexed via tileIndex). Returns a Float32Array of
|
||||
// interleaved [u, v, x, y, z] vertices, matching DMF.VERTEX_FLOATS.
|
||||
function buildTerrainVerts(tiles) {
|
||||
const out = [];
|
||||
for(let z = 0; z < CHUNK_DEPTH; z++) {
|
||||
for(let y = 0; y < CHUNK_HEIGHT; y++) {
|
||||
for(let x = 0; x < CHUNK_WIDTH; x++) {
|
||||
const type = tiles[tileIndex(x, y, z)] || TILE_SHAPE_NULL;
|
||||
const corners = RAMP_CORNERS[type];
|
||||
if(!corners) continue;
|
||||
|
||||
const u0 = x / CHUNK_WIDTH;
|
||||
const u1 = (x + 1) / CHUNK_WIDTH;
|
||||
const v0 = y / CHUNK_HEIGHT;
|
||||
const v1 = (y + 1) / CHUNK_HEIGHT;
|
||||
const [sw, se, ne, nw] = corners;
|
||||
|
||||
pushTileQuad(
|
||||
out, u0, u1, v0, v1, x, y,
|
||||
(z + sw) * WORLD_LAYER_HEIGHT,
|
||||
(z + se) * WORLD_LAYER_HEIGHT,
|
||||
(z + ne) * WORLD_LAYER_HEIGHT,
|
||||
(z + nw) * WORLD_LAYER_HEIGHT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Float32Array(out);
|
||||
}
|
||||
|
||||
// Four edges (SW-SE, SE-NE, NE-NW, NW-SW) of a tile's quad as line
|
||||
// segments, lifted slightly above the terrain surface to avoid
|
||||
// z-fighting - same corner-height convention as pushTileQuad().
|
||||
function pushTileGridLines(out, fx, fy, swZ, seZ, neZ, nwZ) {
|
||||
const eps = 0.01;
|
||||
const sw = [fx, fy, swZ + eps];
|
||||
const se = [fx + 1, fy, seZ + eps];
|
||||
const ne = [fx + 1, fy + 1, neZ + eps];
|
||||
const nw = [fx, fy + 1, nwZ + eps];
|
||||
const edges = [sw, se, se, ne, ne, nw, nw, sw];
|
||||
for(const [x, y, z] of edges) out.push(0, 0, x, y, z);
|
||||
}
|
||||
|
||||
// Generate grid-outline line segments for every non-null tile, following
|
||||
// the same per-corner heights as buildTerrainVerts() so lines hug ramps
|
||||
// instead of cutting through them. Returns a Float32Array of interleaved
|
||||
// [u, v, x, y, z] vertices meant to be drawn with gl.LINES (pairs).
|
||||
function buildGridLines(tiles) {
|
||||
const out = [];
|
||||
for(let z = 0; z < CHUNK_DEPTH; z++) {
|
||||
for(let y = 0; y < CHUNK_HEIGHT; y++) {
|
||||
for(let x = 0; x < CHUNK_WIDTH; x++) {
|
||||
const type = tiles[tileIndex(x, y, z)] || TILE_SHAPE_NULL;
|
||||
const corners = RAMP_CORNERS[type];
|
||||
if(!corners) continue;
|
||||
|
||||
const [sw, se, ne, nw] = corners;
|
||||
pushTileGridLines(
|
||||
out, x, y,
|
||||
(z + sw) * WORLD_LAYER_HEIGHT,
|
||||
(z + se) * WORLD_LAYER_HEIGHT,
|
||||
(z + ne) * WORLD_LAYER_HEIGHT,
|
||||
(z + nw) * WORLD_LAYER_HEIGHT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Float32Array(out);
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH, TILE_COUNT, WORLD_LAYER_HEIGHT,
|
||||
TILE_SHAPE_NULL, TILE_SHAPE_GROUND,
|
||||
TILE_SHAPE_RAMP_NORTH, TILE_SHAPE_RAMP_EAST,
|
||||
TILE_SHAPE_RAMP_SOUTH, TILE_SHAPE_RAMP_WEST,
|
||||
TILE_SHAPE_RAMP_NORTHEAST, TILE_SHAPE_RAMP_NORTHWEST,
|
||||
TILE_SHAPE_RAMP_SOUTHEAST, TILE_SHAPE_RAMP_SOUTHWEST,
|
||||
TILE_SHAPE_RAMP_NORTHEAST_INNER, TILE_SHAPE_RAMP_NORTHWEST_INNER,
|
||||
TILE_SHAPE_RAMP_SOUTHEAST_INNER, TILE_SHAPE_RAMP_SOUTHWEST_INNER,
|
||||
RAMP_CORNERS, tileIndex, buildTerrainVerts, buildGridLines,
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
"use strict";
|
||||
|
||||
// DMF - Dusk Mesh Format
|
||||
//
|
||||
// Header (12 bytes):
|
||||
// [0-3] "DMF\0" magic
|
||||
// [4-7] uint32 version (little-endian)
|
||||
// [8-11] uint32 vertCount (little-endian)
|
||||
//
|
||||
// Followed by vertCount vertices, each 20 bytes:
|
||||
// [0-7] float32[2] uv (little-endian)
|
||||
// [8-19] float32[3] pos (little-endian)
|
||||
|
||||
const DMF = (() => {
|
||||
const MAGIC = [0x44, 0x4d, 0x46, 0x00]; // "DMF\0"
|
||||
const VERSION = 1;
|
||||
const HEADER_SIZE = 12;
|
||||
const VERTEX_FLOATS = 5; // uv[2] + pos[3]
|
||||
const VERTEX_SIZE = VERTEX_FLOATS * 4;
|
||||
|
||||
// Decode a DMF ArrayBuffer into { version, vertexCount, floats }, where
|
||||
// floats is a Float32Array of tightly interleaved [u, v, x, y, z] per
|
||||
// vertex - ready to hand straight to gl.bufferData().
|
||||
function decode(buffer) {
|
||||
const bytes = new Uint8Array(buffer);
|
||||
const view = new DataView(buffer);
|
||||
|
||||
if(bytes.length < HEADER_SIZE) throw new Error("File too small to be a valid DMF");
|
||||
if(
|
||||
bytes[0] !== MAGIC[0] || bytes[1] !== MAGIC[1] ||
|
||||
bytes[2] !== MAGIC[2] || bytes[3] !== MAGIC[3]
|
||||
) {
|
||||
throw new Error("Invalid DMF magic bytes - not a DMF file");
|
||||
}
|
||||
|
||||
const version = view.getUint32(4, true);
|
||||
if(version !== VERSION) {
|
||||
throw new Error(`Unsupported DMF version: ${version}`);
|
||||
}
|
||||
|
||||
const vertexCount = view.getUint32(8, true);
|
||||
const expected = HEADER_SIZE + vertexCount * VERTEX_SIZE;
|
||||
if(bytes.length < expected) {
|
||||
throw new Error(`DMF vertex data truncated (expected ${expected} bytes, got ${bytes.length})`);
|
||||
}
|
||||
|
||||
const floats = new Float32Array(vertexCount * VERTEX_FLOATS);
|
||||
for(let i = 0; i < floats.length; i++) {
|
||||
floats[i] = view.getFloat32(HEADER_SIZE + i * 4, true);
|
||||
}
|
||||
|
||||
return { version, vertexCount, floats };
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
decode,
|
||||
VERSION, HEADER_SIZE, VERTEX_FLOATS, VERTEX_SIZE,
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>Dusk Map Editor</h1>
|
||||
<p class="text-muted">Browse and edit project assets.</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,92 @@
|
||||
<link rel="stylesheet" href="/map/map.css">
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-12">
|
||||
<div class="d-flex flex-wrap align-items-end gap-2 mb-2">
|
||||
<div>
|
||||
<label class="form-label mb-0">X</label>
|
||||
<input type="number" id="coordX" class="form-control form-control-sm" style="width:5rem" value="0">
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label mb-0">Y</label>
|
||||
<input type="number" id="coordY" class="form-control form-control-sm" style="width:5rem" value="0">
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label mb-0">Z</label>
|
||||
<input type="number" id="coordZ" class="form-control form-control-sm" style="width:5rem" value="0">
|
||||
</div>
|
||||
<button id="btnLoad" type="button" class="btn btn-sm btn-secondary">Load</button>
|
||||
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="btn btn-sm btn-outline-secondary dropdown-toggle"
|
||||
type="button" data-bs-toggle="dropdown"
|
||||
>Browse</button>
|
||||
<ul class="dropdown-menu" id="chunkBrowseList"></ul>
|
||||
</div>
|
||||
|
||||
<div class="dpad" title="Navigate to the neighboring chunk">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-n" id="navN" title="North (+Y)">N</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-w" id="navW" title="West (-X)">W</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-e" id="navE" title="East (+X)">E</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary dpad-s" id="navS" title="South (-Y)">S</button>
|
||||
</div>
|
||||
<div class="d-flex flex-column gap-1">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="navUp" title="Up (+Z)">Up</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="navDown" title="Down (-Z)">Down</button>
|
||||
</div>
|
||||
|
||||
<button id="btnSave" type="button" class="btn btn-sm btn-primary ms-auto">
|
||||
Save & Compile
|
||||
</button>
|
||||
</div>
|
||||
<div id="statusLine" class="small text-muted mb-2"> </div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="d-flex align-items-center gap-2 mb-2">
|
||||
<label class="form-label mb-0">Z-Level</label>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="zLevelDown">-</button>
|
||||
<input type="range" id="zLevel" class="form-range" style="width:150px" min="0" max="3" value="0">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="zLevelUp">+</button>
|
||||
<span id="zLevelLabel">0</span>
|
||||
</div>
|
||||
<div class="d-flex gap-3">
|
||||
<div id="toolPalette" class="tile-palette"></div>
|
||||
<div id="tilePalette" class="tile-palette"></div>
|
||||
<canvas id="gridCanvas" class="border tile-grid" width="512" height="512"></canvas>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-3">Meshes</h5>
|
||||
<ul id="meshList" class="list-group mb-2"></ul>
|
||||
<div class="d-flex gap-2 align-items-end flex-wrap">
|
||||
<div style="min-width:220px">
|
||||
<label class="form-label mb-0">Model</label>
|
||||
<select id="meshPicker" class="form-select form-select-sm"></select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label mb-0">X</label>
|
||||
<input id="meshX" type="number" class="form-control form-control-sm" style="width:5rem" value="0">
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label mb-0">Y</label>
|
||||
<input id="meshY" type="number" class="form-control form-control-sm" style="width:5rem" value="0">
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label mb-0">Z</label>
|
||||
<input id="meshZ" type="number" class="form-control form-control-sm" style="width:5rem" value="0">
|
||||
</div>
|
||||
<button id="btnAddMesh" type="button" class="btn btn-sm btn-outline-primary">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-lg-6">
|
||||
<p class="small text-muted mb-2">Preview (scroll to zoom)</p>
|
||||
<canvas id="previewCanvas" class="border" width="512" height="512"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/common/dmf.js"></script>
|
||||
<script src="/common/chunkterrain.js"></script>
|
||||
<script src="/map/renderer.js"></script>
|
||||
<script src="/map/map.js"></script>
|
||||
@@ -0,0 +1,65 @@
|
||||
/* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
.tile-palette {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
max-height: 600px;
|
||||
}
|
||||
|
||||
.tile-swatch {
|
||||
position: relative;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.tile-swatch.active {
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.tile-swatch-icon {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.dpad {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 2rem);
|
||||
grid-template-rows: repeat(3, 2rem);
|
||||
grid-template-areas:
|
||||
". n ."
|
||||
"w . e"
|
||||
". s .";
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.dpad-n { grid-area: n; }
|
||||
.dpad-w { grid-area: w; }
|
||||
.dpad-e { grid-area: e; }
|
||||
.dpad-s { grid-area: s; }
|
||||
.dpad button { padding: 0; }
|
||||
|
||||
.tile-grid {
|
||||
image-rendering: pixelated;
|
||||
cursor: crosshair;
|
||||
touch-action: none;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
#previewCanvas {
|
||||
width: 100%;
|
||||
aspect-ratio: 1 / 1;
|
||||
height: auto;
|
||||
}
|
||||
@@ -0,0 +1,918 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
"use strict";
|
||||
|
||||
(() => {
|
||||
const SHAPES = [
|
||||
{ type: ChunkTerrain.TILE_SHAPE_NULL, name: "Erase", color: "#20232a" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_GROUND, name: "Ground", color: "#4caf50" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTH, name: "Ramp North", color: "#2196f3" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_EAST, name: "Ramp East", color: "#03a9f4" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTH, name: "Ramp South", color: "#00bcd4" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_WEST, name: "Ramp West", color: "#009688" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST, name: "Ramp NE", color: "#ff9800" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST, name: "Ramp NW", color: "#ff5722" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST, name: "Ramp SE", color: "#9c27b0" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST, name: "Ramp SW", color: "#e91e63" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST_INNER, name: "Ramp NE Inner", color: "#795548" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST_INNER, name: "Ramp NW Inner", color: "#607d8b" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST_INNER, name: "Ramp SE Inner", color: "#8bc34a" },
|
||||
{ type: ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST_INNER, name: "Ramp SW Inner", color: "#ffc107" },
|
||||
];
|
||||
const SHAPE_COLORS = Object.fromEntries(SHAPES.map((s) => [s.type, s.color]));
|
||||
|
||||
// Arrow direction per ramp, in canvas/screen space: north is up (dy < 0),
|
||||
// east is right (dx > 0) - matches renderGrid()'s north-is-up convention.
|
||||
const SHAPE_DIRECTIONS = {
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTH]: { dx: 0, dy: -1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTH]: { dx: 0, dy: 1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_EAST]: { dx: 1, dy: 0 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_WEST]: { dx: -1, dy: 0 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST]: { dx: 1, dy: -1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST]: { dx: -1, dy: -1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST]: { dx: 1, dy: 1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST]: { dx: -1, dy: 1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST_INNER]: { dx: 1, dy: -1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST_INNER]: { dx: -1, dy: -1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST_INNER]: { dx: 1, dy: 1 },
|
||||
[ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST_INNER]: { dx: -1, dy: 1 },
|
||||
};
|
||||
|
||||
const INNER_CORNER_SHAPES = new Set([
|
||||
ChunkTerrain.TILE_SHAPE_RAMP_NORTHEAST_INNER,
|
||||
ChunkTerrain.TILE_SHAPE_RAMP_NORTHWEST_INNER,
|
||||
ChunkTerrain.TILE_SHAPE_RAMP_SOUTHEAST_INNER,
|
||||
ChunkTerrain.TILE_SHAPE_RAMP_SOUTHWEST_INNER,
|
||||
]);
|
||||
|
||||
// Draws a single-headed arrow from (tailX, tailY) to (tipX, tipY).
|
||||
function drawArrowSegment(ctx, tailX, tailY, tipX, tipY, size) {
|
||||
ctx.strokeStyle = "#ffffff";
|
||||
ctx.fillStyle = "#ffffff";
|
||||
ctx.lineWidth = Math.max(1, size * 0.08);
|
||||
ctx.lineCap = "round";
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tailX, tailY);
|
||||
ctx.lineTo(tipX, tipY);
|
||||
ctx.stroke();
|
||||
|
||||
const headLen = size * 0.18;
|
||||
const angle = Math.atan2(tipY - tailY, tipX - tailX);
|
||||
const leftAngle = angle + Math.PI * 0.8;
|
||||
const rightAngle = angle - Math.PI * 0.8;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tipX, tipY);
|
||||
ctx.lineTo(tipX + Math.cos(leftAngle) * headLen, tipY + Math.sin(leftAngle) * headLen);
|
||||
ctx.lineTo(tipX + Math.cos(rightAngle) * headLen, tipY + Math.sin(rightAngle) * headLen);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
// Draws an arrow centered at (cx, cy) pointing toward the ramp's high
|
||||
// side, so ramp direction is visible at a glance on both the palette
|
||||
// swatches and the tile grid. Used for cardinal ramps and outer-corner
|
||||
// ramps (a single raised corner).
|
||||
function drawArrow(ctx, cx, cy, size, dx, dy) {
|
||||
const mag = Math.hypot(dx, dy) || 1;
|
||||
const ux = dx / mag, uy = dy / mag;
|
||||
const len = size * 0.32;
|
||||
drawArrowSegment(ctx, cx - ux * len, cy - uy * len, cx + ux * len, cy + uy * len, size);
|
||||
}
|
||||
|
||||
// Draws a plain right-angle bracket - two line segments meeting at 90
|
||||
// degrees at the tile's corner, one running along each of the two edges
|
||||
// adjacent to it - so inner-corner ramps (three corners raised, one
|
||||
// dropped) read as "the adjacent sides meeting in a 90-degree corner",
|
||||
// distinct from the single diagonal arrow used for outer-corner ramps.
|
||||
function drawCornerBracket(ctx, cx, cy, size, dx, dy) {
|
||||
const cornerDist = size * 0.42;
|
||||
const armLen = size * 0.34;
|
||||
const cornerX = cx + dx * cornerDist;
|
||||
const cornerY = cy + dy * cornerDist;
|
||||
|
||||
ctx.strokeStyle = "#ffffff";
|
||||
ctx.lineWidth = Math.max(1, size * 0.08);
|
||||
ctx.lineCap = "round";
|
||||
ctx.lineJoin = "round";
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(cornerX - dx * armLen, cornerY);
|
||||
ctx.lineTo(cornerX, cornerY);
|
||||
ctx.lineTo(cornerX, cornerY - dy * armLen);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Draws the direction icon for a ramp tile `type` in a `size`x`size` area
|
||||
// centered at (cx, cy): a diagonal arrow for cardinal/outer-corner ramps,
|
||||
// or a right-angle bracket for inner-corner ramps. No-op for shapes with
|
||||
// no direction (ground, erase).
|
||||
function drawShapeIcon(ctx, cx, cy, size, type) {
|
||||
const dir = SHAPE_DIRECTIONS[type];
|
||||
if(!dir) return;
|
||||
if(INNER_CORNER_SHAPES.has(type)) {
|
||||
drawCornerBracket(ctx, cx, cy, size, dir.dx, dir.dy);
|
||||
} else {
|
||||
drawArrow(ctx, cx, cy, size, dir.dx, dir.dy);
|
||||
}
|
||||
}
|
||||
|
||||
// Draws a small pencil icon centered in a `size`x`size` canvas.
|
||||
function drawPencilIcon(ctx, size) {
|
||||
ctx.save();
|
||||
ctx.translate(size / 2, size / 2);
|
||||
ctx.rotate(-Math.PI / 4);
|
||||
|
||||
const shaftW = size * 0.18;
|
||||
const shaftH = size * 0.62;
|
||||
|
||||
ctx.fillStyle = "#e0e0e0";
|
||||
ctx.fillRect(-shaftW / 2, shaftH * 0.28, shaftW, shaftH * 0.22);
|
||||
|
||||
ctx.fillStyle = "#f0c419";
|
||||
ctx.fillRect(-shaftW / 2, -shaftH * 0.5, shaftW, shaftH * 0.78);
|
||||
|
||||
ctx.fillStyle = "#8d6e63";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-shaftW / 2, -shaftH * 0.5);
|
||||
ctx.lineTo(shaftW / 2, -shaftH * 0.5);
|
||||
ctx.lineTo(0, -shaftH * 0.5 - shaftW);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// Draws a small paint bucket icon centered in a `size`x`size` canvas.
|
||||
function drawBucketIcon(ctx, size) {
|
||||
ctx.save();
|
||||
ctx.translate(size / 2, size / 2);
|
||||
|
||||
const w = size * 0.5, h = size * 0.34;
|
||||
|
||||
ctx.strokeStyle = "#e0e0e0";
|
||||
ctx.lineWidth = Math.max(1, size * 0.06);
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, -h * 0.4, w * 0.4, Math.PI, 0);
|
||||
ctx.stroke();
|
||||
|
||||
ctx.fillStyle = "#03a9f4";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-w / 2, -h * 0.2);
|
||||
ctx.lineTo(w / 2, -h * 0.2);
|
||||
ctx.lineTo(w * 0.32, h * 0.6);
|
||||
ctx.lineTo(-w * 0.32, h * 0.6);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.arc(-w * 0.55, h * 0.75, size * 0.06, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
const TOOLS = [
|
||||
{ id: "pencil", name: "Pencil", draw: drawPencilIcon },
|
||||
{ id: "bucket", name: "Paint Bucket", draw: drawBucketIcon },
|
||||
];
|
||||
|
||||
let coord = { x: 0, y: 0, z: 0 };
|
||||
let tiles = new Int32Array(ChunkTerrain.TILE_COUNT);
|
||||
let meshes = [];
|
||||
let chunkExists = false;
|
||||
let currentZLevel = 0;
|
||||
let selectedShape = ChunkTerrain.TILE_SHAPE_GROUND;
|
||||
let zoomWorldH = 20;
|
||||
let dirty = false;
|
||||
let hoverTile = null;
|
||||
let activeTool = "pencil";
|
||||
|
||||
let mapRenderer = null;
|
||||
let terrainMesh = null;
|
||||
let gridLinesMesh = null;
|
||||
let terrainTexturePromise = null;
|
||||
let modelIndex = null;
|
||||
let neighborChunks = [];
|
||||
const modelCache = new Map();
|
||||
|
||||
const UNDO_LIMIT = 100;
|
||||
let undoStack = [];
|
||||
|
||||
function markDirty() {
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
function snapshotState() {
|
||||
return {
|
||||
tiles: tiles.slice(),
|
||||
meshes: meshes.map((m) => ({ file: m.file, pos: m.pos.slice() })),
|
||||
};
|
||||
}
|
||||
|
||||
function pushUndo() {
|
||||
undoStack.push(snapshotState());
|
||||
if(undoStack.length > UNDO_LIMIT) undoStack.shift();
|
||||
}
|
||||
|
||||
function undo() {
|
||||
if(!undoStack.length) return;
|
||||
const snap = undoStack.pop();
|
||||
tiles = snap.tiles;
|
||||
meshes = snap.meshes;
|
||||
dirty = true;
|
||||
renderGrid();
|
||||
renderMeshList();
|
||||
renderPreview();
|
||||
updateStatus("Undid last change.");
|
||||
}
|
||||
|
||||
// Returns true if it's OK to proceed (no unsaved changes, or the user
|
||||
// confirmed discarding them).
|
||||
function confirmDiscardIfDirty() {
|
||||
if(!dirty) return true;
|
||||
return window.confirm("You have unsaved changes to this chunk. Discard them?");
|
||||
}
|
||||
|
||||
function statusLine() {
|
||||
return document.getElementById("statusLine");
|
||||
}
|
||||
|
||||
function updateStatus(msg, isError) {
|
||||
const el = statusLine();
|
||||
el.textContent = msg;
|
||||
el.classList.toggle("text-danger", !!isError);
|
||||
el.classList.toggle("text-muted", !isError);
|
||||
}
|
||||
|
||||
async function apiReadJson(path) {
|
||||
const res = await fetch(`/api/read?path=${encodeURIComponent(path)}`);
|
||||
const data = await res.json();
|
||||
return { ok: res.ok, data };
|
||||
}
|
||||
|
||||
async function apiWrite(path, content) {
|
||||
return fetch(`/api/write?path=${encodeURIComponent(path)}`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ content }),
|
||||
});
|
||||
}
|
||||
|
||||
async function apiDelete(path) {
|
||||
return fetch(`/api/delete?path=${encodeURIComponent(path)}`, { method: "POST" });
|
||||
}
|
||||
|
||||
async function apiCompileChunk(x, y, z) {
|
||||
const res = await fetch(`/api/compile-chunk?x=${x}&y=${y}&z=${z}`, { method: "POST" });
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function apiLs(path) {
|
||||
const res = await fetch(`/api/ls?path=${encodeURIComponent(path)}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function apiFind(path, ext) {
|
||||
const res = await fetch(`/api/find?path=${encodeURIComponent(path)}&ext=${encodeURIComponent(ext)}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
function base64ToBuffer(base64) {
|
||||
const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
||||
return bytes.buffer;
|
||||
}
|
||||
|
||||
async function loadImageTexture(assetPath) {
|
||||
const { ok, data } = await apiReadJson(assetPath);
|
||||
if(!ok || data.error) return null;
|
||||
const blob = new Blob([base64ToBuffer(data.content)], { type: "image/png" });
|
||||
const bitmap = await createImageBitmap(blob);
|
||||
return mapRenderer.createTextureFromImage(bitmap);
|
||||
}
|
||||
|
||||
async function readDmfVertices(assetPath) {
|
||||
const { ok, data } = await apiReadJson(assetPath);
|
||||
if(!ok || data.error) throw new Error(`Failed to read ${assetPath}`);
|
||||
return DMF.decode(base64ToBuffer(data.content)).floats;
|
||||
}
|
||||
|
||||
async function ensureModelIndex() {
|
||||
if(modelIndex) return modelIndex;
|
||||
const res = await apiFind("assets/models", ".json");
|
||||
modelIndex = new Map();
|
||||
for(const file of res.files || []) {
|
||||
const base = file.split("/").pop().replace(/\.json$/, "");
|
||||
modelIndex.set(base, file);
|
||||
}
|
||||
return modelIndex;
|
||||
}
|
||||
|
||||
// Scales a mesh's stored [x, y, z] offset for preview, matching the
|
||||
// Z scaling mapChunkLoaded() applies at runtime (chunk.meshOffsets[m][2]
|
||||
// * WORLD_LAYER_HEIGHT) - x/y stay 1:1 since only Z is height-scaled.
|
||||
function scaledMeshOffset(pos) {
|
||||
return [pos[0], pos[1], pos[2] * ChunkTerrain.WORLD_LAYER_HEIGHT];
|
||||
}
|
||||
|
||||
// Resolves a chunk mesh entry's bare filename (e.g. "house_5_3.dmf") to
|
||||
// its model JSON by basename, mirroring find_model() in
|
||||
// tools/asset/chunk/__main__.py - the chunk JSON only ever stores a bare
|
||||
// filename, not a path.
|
||||
async function resolveModelForMeshFile(file) {
|
||||
await ensureModelIndex();
|
||||
const base = file.replace(/\.[^.]+$/, "");
|
||||
const rel = modelIndex.get(base);
|
||||
if(!rel) return null;
|
||||
|
||||
const modelPath = `assets/models/${rel}`;
|
||||
if(modelCache.has(modelPath)) return modelCache.get(modelPath);
|
||||
|
||||
const promise = (async () => {
|
||||
const { ok, data } = await apiReadJson(modelPath);
|
||||
if(!ok || data.error) throw new Error(`Failed to read model ${modelPath}`);
|
||||
const modelDef = JSON.parse(data.content);
|
||||
const meshFloats = await readDmfVertices(`assets/${modelDef.mesh}`);
|
||||
const mesh = mapRenderer.createMesh(meshFloats);
|
||||
const texture = modelDef.texture ? await loadImageTexture(`assets/${modelDef.texture}`) : null;
|
||||
const colorBytes = modelDef.color || [255, 255, 255, 255];
|
||||
const color = colorBytes.map((c) => c / 255);
|
||||
return { mesh, texture, color };
|
||||
})();
|
||||
modelCache.set(modelPath, promise);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function chunkPaths(x, y, z) {
|
||||
return {
|
||||
raw: `assetsraw/chunks/chunk_${x}_${y}_${z}.json`,
|
||||
dcf: `assets/chunks/${x}_${y}_${z}.dcf`,
|
||||
terrainDmf: `assets/meshes/chunks/chunk_${x}_${y}_${z}_0.dmf`,
|
||||
terrainModel: `assets/models/chunks/chunk_${x}_${y}_${z}_0.json`,
|
||||
};
|
||||
}
|
||||
|
||||
// Loads the 8 same-Z neighbors around `coord` (read-only, for context in
|
||||
// the 3D preview) and pre-builds their render data so renderPreview()
|
||||
// doesn't have to rebuild GL buffers on every paint stroke.
|
||||
async function loadNeighborChunks() {
|
||||
const offsets = [];
|
||||
for(let dy = -1; dy <= 1; dy++) {
|
||||
for(let dx = -1; dx <= 1; dx++) {
|
||||
if(dx || dy) offsets.push({ dx, dy });
|
||||
}
|
||||
}
|
||||
|
||||
const results = await Promise.all(offsets.map(async ({ dx, dy }) => {
|
||||
const nx = coord.x + dx, ny = coord.y + dy, nz = coord.z;
|
||||
const { ok, data } = await apiReadJson(chunkPaths(nx, ny, nz).raw);
|
||||
if(!ok || data.error) return null;
|
||||
|
||||
const json = JSON.parse(data.content);
|
||||
const neighborTiles = new Int32Array(ChunkTerrain.TILE_COUNT);
|
||||
for(const t of json.tiles || []) {
|
||||
const [tx, ty, tz] = t.pos;
|
||||
neighborTiles[ChunkTerrain.tileIndex(tx, ty, tz)] = t.type;
|
||||
}
|
||||
const neighborMeshes = (json.meshes || []).map((m) => ({ file: m.file, pos: m.pos || [0, 0, 0] }));
|
||||
|
||||
const floats = ChunkTerrain.buildTerrainVerts(neighborTiles);
|
||||
const terrain = floats.length ? { mesh: mapRenderer.createMesh(floats) } : null;
|
||||
|
||||
const models = [];
|
||||
for(const m of neighborMeshes) {
|
||||
try {
|
||||
const resolved = await resolveModelForMeshFile(m.file);
|
||||
if(resolved) models.push({ ...resolved, offset: scaledMeshOffset(m.pos) });
|
||||
} catch(e) {
|
||||
console.warn("Failed to load neighbor mesh preview", m.file, e);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
offset: [dx * ChunkTerrain.CHUNK_WIDTH, dy * ChunkTerrain.CHUNK_HEIGHT, 0],
|
||||
terrain,
|
||||
models,
|
||||
};
|
||||
}));
|
||||
|
||||
neighborChunks = results.filter(Boolean);
|
||||
}
|
||||
|
||||
async function loadChunk(x, y, z) {
|
||||
coord = { x, y, z };
|
||||
tiles = new Int32Array(ChunkTerrain.TILE_COUNT);
|
||||
meshes = [];
|
||||
chunkExists = false;
|
||||
|
||||
const { ok, data } = await apiReadJson(chunkPaths(x, y, z).raw);
|
||||
if(ok && !data.error) {
|
||||
chunkExists = true;
|
||||
const json = JSON.parse(data.content);
|
||||
for(const t of json.tiles || []) {
|
||||
const [tx, ty, tz] = t.pos;
|
||||
tiles[ChunkTerrain.tileIndex(tx, ty, tz)] = t.type;
|
||||
}
|
||||
meshes = (json.meshes || []).map((m) => ({ file: m.file, pos: m.pos || [0, 0, 0] }));
|
||||
}
|
||||
|
||||
await loadNeighborChunks();
|
||||
dirty = false;
|
||||
undoStack = [];
|
||||
|
||||
renderGrid();
|
||||
renderMeshList();
|
||||
renderPreview();
|
||||
updateStatus(chunkExists
|
||||
? `Loaded chunk_${x}_${y}_${z}.json`
|
||||
: `New (empty) chunk at ${x}, ${y}, ${z} - paint a tile and save to create it.`);
|
||||
}
|
||||
|
||||
async function saveChunk() {
|
||||
const tilesArr = [];
|
||||
for(let z = 0; z < ChunkTerrain.CHUNK_DEPTH; z++) {
|
||||
for(let y = 0; y < ChunkTerrain.CHUNK_HEIGHT; y++) {
|
||||
for(let x = 0; x < ChunkTerrain.CHUNK_WIDTH; x++) {
|
||||
const type = tiles[ChunkTerrain.tileIndex(x, y, z)];
|
||||
if(type && type !== ChunkTerrain.TILE_SHAPE_NULL) {
|
||||
tilesArr.push({ pos: [x, y, z], type, tile: 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const paths = chunkPaths(coord.x, coord.y, coord.z);
|
||||
|
||||
if(tilesArr.length === 0 && meshes.length === 0) {
|
||||
await Promise.all(Object.values(paths).map((p) => apiDelete(p)));
|
||||
chunkExists = false;
|
||||
dirty = false;
|
||||
updateStatus(`Chunk ${coord.x}, ${coord.y}, ${coord.z} is empty - deleted.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const json = { tiles: tilesArr, meshes: meshes.map((m) => ({ file: m.file, pos: m.pos })) };
|
||||
await apiWrite(paths.raw, JSON.stringify(json, null, 2));
|
||||
chunkExists = true;
|
||||
dirty = false;
|
||||
updateStatus("Saved. Compiling...");
|
||||
|
||||
const result = await apiCompileChunk(coord.x, coord.y, coord.z);
|
||||
if(result.ok) {
|
||||
updateStatus(`Compiled OK.\n${result.stdout}`);
|
||||
} else {
|
||||
updateStatus(`Compile FAILED (code ${result.returncode}):\n${result.stderr}`, true);
|
||||
}
|
||||
}
|
||||
|
||||
function buildPalette() {
|
||||
const el = document.getElementById("tilePalette");
|
||||
el.innerHTML = "";
|
||||
for(const s of SHAPES) {
|
||||
const btn = document.createElement("button");
|
||||
btn.type = "button";
|
||||
btn.className = "tile-swatch" + (s.type === selectedShape ? " active" : "");
|
||||
btn.style.background = s.color;
|
||||
btn.title = s.name;
|
||||
btn.addEventListener("click", () => {
|
||||
selectedShape = s.type;
|
||||
buildPalette();
|
||||
});
|
||||
|
||||
if(SHAPE_DIRECTIONS[s.type]) {
|
||||
const icon = document.createElement("canvas");
|
||||
icon.width = 32;
|
||||
icon.height = 32;
|
||||
icon.className = "tile-swatch-icon";
|
||||
drawShapeIcon(icon.getContext("2d"), 16, 16, 32, s.type);
|
||||
btn.appendChild(icon);
|
||||
}
|
||||
|
||||
el.appendChild(btn);
|
||||
}
|
||||
}
|
||||
|
||||
function buildToolPalette() {
|
||||
const el = document.getElementById("toolPalette");
|
||||
el.innerHTML = "";
|
||||
for(const tool of TOOLS) {
|
||||
const btn = document.createElement("button");
|
||||
btn.type = "button";
|
||||
btn.className = "tile-swatch" + (tool.id === activeTool ? " active" : "");
|
||||
btn.style.background = "#2a2d33";
|
||||
btn.title = tool.name;
|
||||
btn.addEventListener("click", () => {
|
||||
activeTool = tool.id;
|
||||
buildToolPalette();
|
||||
});
|
||||
|
||||
const icon = document.createElement("canvas");
|
||||
icon.width = 32;
|
||||
icon.height = 32;
|
||||
icon.className = "tile-swatch-icon";
|
||||
tool.draw(icon.getContext("2d"), 32);
|
||||
btn.appendChild(icon);
|
||||
|
||||
el.appendChild(btn);
|
||||
}
|
||||
}
|
||||
|
||||
function canvasToTile(e, canvas) {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const cell = canvas.width / ChunkTerrain.CHUNK_WIDTH;
|
||||
const px = (e.clientX - rect.left) * (canvas.width / rect.width);
|
||||
const py = (e.clientY - rect.top) * (canvas.height / rect.height);
|
||||
const x = Math.floor(px / cell);
|
||||
const yFromTop = Math.floor(py / cell);
|
||||
const y = ChunkTerrain.CHUNK_HEIGHT - 1 - yFromTop;
|
||||
if(x < 0 || x >= ChunkTerrain.CHUNK_WIDTH || y < 0 || y >= ChunkTerrain.CHUNK_HEIGHT) return null;
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
function renderGrid() {
|
||||
const canvas = document.getElementById("gridCanvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
const cell = canvas.width / ChunkTerrain.CHUNK_WIDTH;
|
||||
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
for(let y = 0; y < ChunkTerrain.CHUNK_HEIGHT; y++) {
|
||||
for(let x = 0; x < ChunkTerrain.CHUNK_WIDTH; x++) {
|
||||
const type = tiles[ChunkTerrain.tileIndex(x, y, currentZLevel)];
|
||||
const sy = (ChunkTerrain.CHUNK_HEIGHT - 1 - y) * cell;
|
||||
ctx.fillStyle = SHAPE_COLORS[type] || "#15171b";
|
||||
ctx.fillRect(x * cell, sy, cell, cell);
|
||||
ctx.strokeStyle = "rgba(255, 255, 255, 0.25)";
|
||||
ctx.strokeRect(x * cell, sy, cell, cell);
|
||||
|
||||
drawShapeIcon(ctx, x * cell + cell / 2, sy + cell / 2, cell, type);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.fillStyle = "#ffffff";
|
||||
for(const m of meshes) {
|
||||
const [mx, my, mz] = m.pos;
|
||||
if(Math.round(mz) !== currentZLevel) continue;
|
||||
const sy = (ChunkTerrain.CHUNK_HEIGHT - 1 - my) * cell;
|
||||
ctx.beginPath();
|
||||
ctx.arc(mx * cell + cell / 2, sy + cell / 2, cell * 0.3, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
if(hoverTile) {
|
||||
const sy = (ChunkTerrain.CHUNK_HEIGHT - 1 - hoverTile.y) * cell;
|
||||
ctx.strokeStyle = "#ffeb3b";
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeRect(hoverTile.x * cell + 1, sy + 1, cell - 2, cell - 2);
|
||||
}
|
||||
}
|
||||
|
||||
function hitTestMesh(e, canvas) {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const cell = canvas.width / ChunkTerrain.CHUNK_WIDTH;
|
||||
const px = (e.clientX - rect.left) * (canvas.width / rect.width);
|
||||
const py = (e.clientY - rect.top) * (canvas.height / rect.height);
|
||||
|
||||
let closest = -1;
|
||||
let closestDist = cell * 0.5;
|
||||
meshes.forEach((m, i) => {
|
||||
const [mx, my, mz] = m.pos;
|
||||
if(Math.round(mz) !== currentZLevel) return;
|
||||
const cx = mx * cell + cell / 2;
|
||||
const cy = (ChunkTerrain.CHUNK_HEIGHT - 1 - my) * cell + cell / 2;
|
||||
const dist = Math.hypot(px - cx, py - cy);
|
||||
if(dist < closestDist) { closestDist = dist; closest = i; }
|
||||
});
|
||||
return closest;
|
||||
}
|
||||
|
||||
function moveMeshTo(e, index) {
|
||||
const canvas = document.getElementById("gridCanvas");
|
||||
const t = canvasToTile(e, canvas);
|
||||
if(!t) return;
|
||||
meshes[index].pos[0] = t.x;
|
||||
meshes[index].pos[1] = t.y;
|
||||
markDirty();
|
||||
renderGrid();
|
||||
renderMeshList();
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
function paintAt(e) {
|
||||
const canvas = document.getElementById("gridCanvas");
|
||||
const t = canvasToTile(e, canvas);
|
||||
if(!t) return;
|
||||
tiles[ChunkTerrain.tileIndex(t.x, t.y, currentZLevel)] = selectedShape;
|
||||
markDirty();
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
// 4-connected flood fill of same-type tiles at the current Z-level,
|
||||
// starting from (startX, startY), replacing them with selectedShape.
|
||||
function floodFill(startX, startY) {
|
||||
const targetType = tiles[ChunkTerrain.tileIndex(startX, startY, currentZLevel)];
|
||||
if(targetType === selectedShape) return;
|
||||
|
||||
const stack = [[startX, startY]];
|
||||
const visited = new Set();
|
||||
while(stack.length) {
|
||||
const [x, y] = stack.pop();
|
||||
const key = `${x},${y}`;
|
||||
if(visited.has(key)) continue;
|
||||
if(x < 0 || x >= ChunkTerrain.CHUNK_WIDTH || y < 0 || y >= ChunkTerrain.CHUNK_HEIGHT) continue;
|
||||
visited.add(key);
|
||||
|
||||
const idx = ChunkTerrain.tileIndex(x, y, currentZLevel);
|
||||
if(tiles[idx] !== targetType) continue;
|
||||
tiles[idx] = selectedShape;
|
||||
stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
function fillAt(e) {
|
||||
const canvas = document.getElementById("gridCanvas");
|
||||
const t = canvasToTile(e, canvas);
|
||||
if(!t) return;
|
||||
pushUndo();
|
||||
floodFill(t.x, t.y);
|
||||
markDirty();
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
function rebuildTerrainMesh() {
|
||||
const floats = ChunkTerrain.buildTerrainVerts(tiles);
|
||||
terrainMesh = floats.length ? mapRenderer.createMesh(floats) : null;
|
||||
|
||||
const lineFloats = ChunkTerrain.buildGridLines(tiles);
|
||||
gridLinesMesh = lineFloats.length ? mapRenderer.createMesh(lineFloats) : null;
|
||||
}
|
||||
|
||||
// Keeps the preview canvas's backing-store resolution matched to its
|
||||
// actual displayed CSS size (times devicePixelRatio) - the canvas
|
||||
// otherwise stays at its fixed width/height attributes (512x512) while
|
||||
// CSS stretches it to fill the column, which upscales and blurs the
|
||||
// WebGL output on wider or high-DPI screens.
|
||||
function resizePreviewCanvas() {
|
||||
const canvas = document.getElementById("previewCanvas");
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
const displayWidth = Math.max(1, Math.round(canvas.clientWidth * dpr));
|
||||
const displayHeight = Math.max(1, Math.round(canvas.clientHeight * dpr));
|
||||
if(canvas.width !== displayWidth || canvas.height !== displayHeight) {
|
||||
canvas.width = displayWidth;
|
||||
canvas.height = displayHeight;
|
||||
}
|
||||
}
|
||||
|
||||
async function renderPreview() {
|
||||
if(!mapRenderer) return;
|
||||
resizePreviewCanvas();
|
||||
rebuildTerrainMesh();
|
||||
|
||||
const models = [];
|
||||
for(const m of meshes) {
|
||||
try {
|
||||
const resolved = await resolveModelForMeshFile(m.file);
|
||||
if(resolved) models.push({ ...resolved, offset: scaledMeshOffset(m.pos) });
|
||||
} catch(e) {
|
||||
console.warn("Failed to load mesh preview", m.file, e);
|
||||
}
|
||||
}
|
||||
|
||||
let terrainTexture = null;
|
||||
if(terrainMesh || neighborChunks.some((n) => n.terrain)) {
|
||||
if(!terrainTexturePromise) terrainTexturePromise = loadImageTexture("assets/tiles.png");
|
||||
terrainTexture = await terrainTexturePromise;
|
||||
}
|
||||
|
||||
const neighbors = neighborChunks.map((n) => ({
|
||||
offset: n.offset,
|
||||
terrain: n.terrain ? { mesh: n.terrain.mesh, texture: terrainTexture } : null,
|
||||
models: n.models,
|
||||
}));
|
||||
|
||||
const zLevelHeight = currentZLevel * ChunkTerrain.WORLD_LAYER_HEIGHT;
|
||||
mapRenderer.render({
|
||||
target: [ChunkTerrain.CHUNK_WIDTH / 2, ChunkTerrain.CHUNK_HEIGHT / 2, zLevelHeight],
|
||||
worldH: zoomWorldH,
|
||||
terrain: terrainMesh ? { mesh: terrainMesh, texture: terrainTexture } : null,
|
||||
gridLines: gridLinesMesh ? { mesh: gridLinesMesh } : null,
|
||||
models,
|
||||
neighbors,
|
||||
highlight: hoverTile ? { x: hoverTile.x, y: hoverTile.y, z: zLevelHeight } : null,
|
||||
});
|
||||
}
|
||||
|
||||
function renderMeshList() {
|
||||
const ul = document.getElementById("meshList");
|
||||
ul.innerHTML = "";
|
||||
meshes.forEach((m, i) => {
|
||||
const li = document.createElement("li");
|
||||
li.className = "list-group-item d-flex align-items-center gap-2 flex-wrap";
|
||||
|
||||
const label = document.createElement("span");
|
||||
label.className = "me-auto";
|
||||
label.textContent = m.file;
|
||||
li.appendChild(label);
|
||||
|
||||
["X", "Y", "Z"].forEach((axis, axisIndex) => {
|
||||
const input = document.createElement("input");
|
||||
input.type = "number";
|
||||
input.className = "form-control form-control-sm";
|
||||
input.style.width = "5rem";
|
||||
input.title = axis;
|
||||
input.value = m.pos[axisIndex];
|
||||
input.addEventListener("change", () => {
|
||||
pushUndo();
|
||||
m.pos[axisIndex] = parseFloat(input.value) || 0;
|
||||
markDirty();
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
});
|
||||
li.appendChild(input);
|
||||
});
|
||||
|
||||
const btn = document.createElement("button");
|
||||
btn.type = "button";
|
||||
btn.className = "btn btn-sm btn-outline-danger";
|
||||
btn.textContent = "Remove";
|
||||
btn.addEventListener("click", () => {
|
||||
pushUndo();
|
||||
meshes.splice(i, 1);
|
||||
markDirty();
|
||||
renderMeshList();
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
});
|
||||
|
||||
li.appendChild(btn);
|
||||
ul.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
async function buildMeshPicker() {
|
||||
await ensureModelIndex();
|
||||
const select = document.getElementById("meshPicker");
|
||||
select.innerHTML = "";
|
||||
for(const [base, rel] of [...modelIndex.entries()].sort()) {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = base;
|
||||
opt.textContent = rel;
|
||||
select.appendChild(opt);
|
||||
}
|
||||
}
|
||||
|
||||
async function buildChunkBrowseList() {
|
||||
const list = document.getElementById("chunkBrowseList");
|
||||
list.innerHTML = "";
|
||||
const res = await apiLs("assetsraw/chunks");
|
||||
for(const entry of res.entries || []) {
|
||||
const m = entry.name.match(/^chunk_(-?\d+)_(-?\d+)_(-?\d+)\.json$/);
|
||||
if(!m) continue;
|
||||
const [, x, y, z] = m;
|
||||
|
||||
const li = document.createElement("li");
|
||||
const a = document.createElement("a");
|
||||
a.className = "dropdown-item";
|
||||
a.href = "#";
|
||||
a.textContent = `${x}, ${y}, ${z}`;
|
||||
a.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
goToChunk(parseInt(x, 10), parseInt(y, 10), parseInt(z, 10));
|
||||
});
|
||||
|
||||
li.appendChild(a);
|
||||
list.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
||||
function setCoordInputs(x, y, z) {
|
||||
document.getElementById("coordX").value = x;
|
||||
document.getElementById("coordY").value = y;
|
||||
document.getElementById("coordZ").value = z;
|
||||
}
|
||||
|
||||
function goToChunk(x, y, z) {
|
||||
if(!confirmDiscardIfDirty()) return;
|
||||
setCoordInputs(x, y, z);
|
||||
loadChunk(x, y, z);
|
||||
}
|
||||
|
||||
function bindEvents() {
|
||||
const gridCanvas = document.getElementById("gridCanvas");
|
||||
let painting = false;
|
||||
let draggingMeshIndex = -1;
|
||||
|
||||
gridCanvas.addEventListener("mousedown", (e) => {
|
||||
if(activeTool === "bucket") {
|
||||
fillAt(e);
|
||||
return;
|
||||
}
|
||||
|
||||
const hit = hitTestMesh(e, gridCanvas);
|
||||
pushUndo();
|
||||
if(hit !== -1) {
|
||||
draggingMeshIndex = hit;
|
||||
return;
|
||||
}
|
||||
painting = true;
|
||||
paintAt(e);
|
||||
});
|
||||
window.addEventListener("mouseup", () => { painting = false; draggingMeshIndex = -1; });
|
||||
gridCanvas.addEventListener("mousemove", (e) => {
|
||||
hoverTile = canvasToTile(e, gridCanvas);
|
||||
if(draggingMeshIndex !== -1) { moveMeshTo(e, draggingMeshIndex); return; }
|
||||
if(painting) { paintAt(e); return; }
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
});
|
||||
gridCanvas.addEventListener("mouseleave", () => {
|
||||
hoverTile = null;
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
});
|
||||
|
||||
function setZLevel(z) {
|
||||
currentZLevel = Math.max(0, Math.min(ChunkTerrain.CHUNK_DEPTH - 1, z));
|
||||
document.getElementById("zLevel").value = currentZLevel;
|
||||
document.getElementById("zLevelLabel").textContent = currentZLevel;
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
document.getElementById("zLevel").addEventListener("input", (e) => {
|
||||
setZLevel(parseInt(e.target.value, 10));
|
||||
});
|
||||
document.getElementById("zLevelDown").addEventListener("click", () => setZLevel(currentZLevel - 1));
|
||||
document.getElementById("zLevelUp").addEventListener("click", () => setZLevel(currentZLevel + 1));
|
||||
|
||||
document.getElementById("btnLoad").addEventListener("click", () => {
|
||||
const x = parseInt(document.getElementById("coordX").value, 10) || 0;
|
||||
const y = parseInt(document.getElementById("coordY").value, 10) || 0;
|
||||
const z = parseInt(document.getElementById("coordZ").value, 10) || 0;
|
||||
goToChunk(x, y, z);
|
||||
});
|
||||
|
||||
// NORTH=+Y, EAST=+X (matches tile-shape convention used by the tile
|
||||
// grid and tools/asset/chunk/__main__.py).
|
||||
document.getElementById("navN").addEventListener("click", () => goToChunk(coord.x, coord.y + 1, coord.z));
|
||||
document.getElementById("navS").addEventListener("click", () => goToChunk(coord.x, coord.y - 1, coord.z));
|
||||
document.getElementById("navE").addEventListener("click", () => goToChunk(coord.x + 1, coord.y, coord.z));
|
||||
document.getElementById("navW").addEventListener("click", () => goToChunk(coord.x - 1, coord.y, coord.z));
|
||||
document.getElementById("navUp").addEventListener("click", () => goToChunk(coord.x, coord.y, coord.z + 1));
|
||||
document.getElementById("navDown").addEventListener("click", () => goToChunk(coord.x, coord.y, coord.z - 1));
|
||||
|
||||
function runSave() {
|
||||
saveChunk().catch((e) => updateStatus(`Save failed: ${e.message}`, true));
|
||||
}
|
||||
|
||||
document.getElementById("btnSave").addEventListener("click", runSave);
|
||||
|
||||
document.getElementById("btnAddMesh").addEventListener("click", () => {
|
||||
const base = document.getElementById("meshPicker").value;
|
||||
if(!base) return;
|
||||
const pos = [
|
||||
parseFloat(document.getElementById("meshX").value) || 0,
|
||||
parseFloat(document.getElementById("meshY").value) || 0,
|
||||
parseFloat(document.getElementById("meshZ").value) || 0,
|
||||
];
|
||||
pushUndo();
|
||||
meshes.push({ file: `${base}.dmf`, pos });
|
||||
markDirty();
|
||||
renderMeshList();
|
||||
renderGrid();
|
||||
renderPreview();
|
||||
});
|
||||
|
||||
document.getElementById("previewCanvas").addEventListener("wheel", (e) => {
|
||||
e.preventDefault();
|
||||
zoomWorldH = Math.min(60, Math.max(4, zoomWorldH + Math.sign(e.deltaY)));
|
||||
renderPreview();
|
||||
}, { passive: false });
|
||||
|
||||
window.addEventListener("resize", () => renderPreview());
|
||||
|
||||
window.addEventListener("keydown", (e) => {
|
||||
if(!(e.ctrlKey || e.metaKey)) return;
|
||||
const key = e.key.toLowerCase();
|
||||
if(key === "z") {
|
||||
e.preventDefault();
|
||||
undo();
|
||||
} else if(key === "s") {
|
||||
e.preventDefault();
|
||||
runSave();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
buildPalette();
|
||||
buildToolPalette();
|
||||
mapRenderer = MapRenderer.create(document.getElementById("previewCanvas"));
|
||||
bindEvents();
|
||||
await Promise.all([buildChunkBrowseList(), buildMeshPicker()]);
|
||||
await loadChunk(coord.x, coord.y, coord.z);
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,298 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
"use strict";
|
||||
|
||||
// MapRenderer - a minimal, dependency-free WebGL renderer for the chunk
|
||||
// preview pane. The camera formula is ported 1:1 from
|
||||
// src/dusk/scene/overworld/sceneoverworld.c (lines 62-81) so the preview
|
||||
// approximates the game's own fixed-angle 3rd-person camera: the eye sits
|
||||
// worldH units "behind" the target along Y and a proportional distance
|
||||
// "above" along Z, always looking at the target, up = (0, 1, 0).
|
||||
//
|
||||
// The material model mirrors SHADER_UNLIT: a texture sampler multiplied by
|
||||
// a flat RGBA tint, with a 1x1 white fallback texture standing in for
|
||||
// untextured models.
|
||||
|
||||
const MapRenderer = (() => {
|
||||
const VERT_SRC = `
|
||||
attribute vec2 aUV;
|
||||
attribute vec3 aPos;
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
varying vec2 vUV;
|
||||
void main() {
|
||||
vUV = aUV;
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPos, 1.0);
|
||||
}
|
||||
`;
|
||||
|
||||
const FRAG_SRC = `
|
||||
precision mediump float;
|
||||
varying vec2 vUV;
|
||||
uniform sampler2D uTexture;
|
||||
uniform vec4 uColor;
|
||||
void main() {
|
||||
gl_FragColor = texture2D(uTexture, vUV) * uColor;
|
||||
}
|
||||
`;
|
||||
|
||||
function mat4Identity(out) {
|
||||
out.fill(0);
|
||||
out[0] = out[5] = out[10] = out[15] = 1;
|
||||
return out;
|
||||
}
|
||||
|
||||
function mat4Translation(out, v) {
|
||||
mat4Identity(out);
|
||||
out[12] = v[0];
|
||||
out[13] = v[1];
|
||||
out[14] = v[2];
|
||||
return out;
|
||||
}
|
||||
|
||||
function mat4Perspective(out, fovy, aspect, near, far) {
|
||||
const f = 1.0 / Math.tan(fovy / 2);
|
||||
out.fill(0);
|
||||
out[0] = f / aspect;
|
||||
out[5] = f;
|
||||
out[10] = (far + near) / (near - far);
|
||||
out[11] = -1;
|
||||
out[14] = (2 * far * near) / (near - far);
|
||||
return out;
|
||||
}
|
||||
|
||||
function vec3Sub(a, b) {
|
||||
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
||||
}
|
||||
|
||||
function vec3Cross(a, b) {
|
||||
return [
|
||||
a[1] * b[2] - a[2] * b[1],
|
||||
a[2] * b[0] - a[0] * b[2],
|
||||
a[0] * b[1] - a[1] * b[0],
|
||||
];
|
||||
}
|
||||
|
||||
function vec3Normalize(a) {
|
||||
const len = Math.hypot(a[0], a[1], a[2]) || 1;
|
||||
return [a[0] / len, a[1] / len, a[2] / len];
|
||||
}
|
||||
|
||||
function mat4LookAt(out, eye, center, up) {
|
||||
const zAxis = vec3Normalize(vec3Sub(eye, center));
|
||||
const xAxis = vec3Normalize(vec3Cross(up, zAxis));
|
||||
const yAxis = vec3Cross(zAxis, xAxis);
|
||||
|
||||
out[0] = xAxis[0]; out[1] = yAxis[0]; out[2] = zAxis[0]; out[3] = 0;
|
||||
out[4] = xAxis[1]; out[5] = yAxis[1]; out[6] = zAxis[1]; out[7] = 0;
|
||||
out[8] = xAxis[2]; out[9] = yAxis[2]; out[10] = zAxis[2]; out[11] = 0;
|
||||
out[12] = -(xAxis[0] * eye[0] + xAxis[1] * eye[1] + xAxis[2] * eye[2]);
|
||||
out[13] = -(yAxis[0] * eye[0] + yAxis[1] * eye[1] + yAxis[2] * eye[2]);
|
||||
out[14] = -(zAxis[0] * eye[0] + zAxis[1] * eye[1] + zAxis[2] * eye[2]);
|
||||
out[15] = 1;
|
||||
return out;
|
||||
}
|
||||
|
||||
// Ported from sceneoverworld.c:62-81. Returns { eye, view }.
|
||||
function computeCamera(target, worldH) {
|
||||
const fov = Math.PI / 4; // glm_rad(45.0f)
|
||||
const zDist = (worldH * 0.5) / Math.tan(fov * 0.5);
|
||||
const offset = -worldH;
|
||||
|
||||
const eye = [target[0], target[1] + offset, target[2] + zDist];
|
||||
const view = mat4LookAt(new Float32Array(16), eye, target, [0, 1, 0]);
|
||||
return { eye, view, fov };
|
||||
}
|
||||
|
||||
function compileShader(gl, type, src) {
|
||||
const shader = gl.createShader(type);
|
||||
gl.shaderSource(shader, src);
|
||||
gl.compileShader(shader);
|
||||
if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
||||
const info = gl.getShaderInfoLog(shader);
|
||||
gl.deleteShader(shader);
|
||||
throw new Error(`Shader compile failed: ${info}`);
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
function create(canvas) {
|
||||
const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
||||
if(!gl) throw new Error("WebGL is not available in this browser");
|
||||
|
||||
const program = gl.createProgram();
|
||||
gl.attachShader(program, compileShader(gl, gl.VERTEX_SHADER, VERT_SRC));
|
||||
gl.attachShader(program, compileShader(gl, gl.FRAGMENT_SHADER, FRAG_SRC));
|
||||
gl.linkProgram(program);
|
||||
if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
||||
throw new Error(`Program link failed: ${gl.getProgramInfoLog(program)}`);
|
||||
}
|
||||
|
||||
const attribs = {
|
||||
aUV: gl.getAttribLocation(program, "aUV"),
|
||||
aPos: gl.getAttribLocation(program, "aPos"),
|
||||
};
|
||||
const uniforms = {
|
||||
uModel: gl.getUniformLocation(program, "uModel"),
|
||||
uView: gl.getUniformLocation(program, "uView"),
|
||||
uProjection: gl.getUniformLocation(program, "uProjection"),
|
||||
uTexture: gl.getUniformLocation(program, "uTexture"),
|
||||
uColor: gl.getUniformLocation(program, "uColor"),
|
||||
};
|
||||
|
||||
const whiteTexture = gl.createTexture();
|
||||
gl.bindTexture(gl.TEXTURE_2D, whiteTexture);
|
||||
gl.texImage2D(
|
||||
gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
|
||||
new Uint8Array([255, 255, 255, 255]),
|
||||
);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
||||
|
||||
gl.enable(gl.DEPTH_TEST);
|
||||
gl.enable(gl.BLEND);
|
||||
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
||||
// Terrain/mesh winding isn't guaranteed consistent relative to this
|
||||
// preview's fixed camera angle, so backface culling stays off - this
|
||||
// is an authoring preview, not a performance-sensitive renderer, and
|
||||
// an invisible mesh is a worse failure mode than a visible backface.
|
||||
|
||||
// Uploads interleaved [u, v, x, y, z] float data (DMF/terrain layout)
|
||||
// into a GL buffer. Returns { buffer, vertexCount }.
|
||||
function createMesh(floats) {
|
||||
const buffer = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, floats, gl.STATIC_DRAW);
|
||||
return { buffer, vertexCount: floats.length / 5 };
|
||||
}
|
||||
|
||||
function createTextureFromImage(image) {
|
||||
const texture = gl.createTexture();
|
||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
return texture;
|
||||
}
|
||||
|
||||
function drawMesh(mesh, model, texture, color, depthWrite, mode) {
|
||||
gl.depthMask(depthWrite !== false);
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer);
|
||||
gl.enableVertexAttribArray(attribs.aUV);
|
||||
gl.vertexAttribPointer(attribs.aUV, 2, gl.FLOAT, false, 20, 0);
|
||||
gl.enableVertexAttribArray(attribs.aPos);
|
||||
gl.vertexAttribPointer(attribs.aPos, 3, gl.FLOAT, false, 20, 8);
|
||||
|
||||
gl.uniformMatrix4fv(uniforms.uModel, false, model);
|
||||
gl.uniform4f(uniforms.uColor, color[0], color[1], color[2], color[3]);
|
||||
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, texture || whiteTexture);
|
||||
gl.uniform1i(uniforms.uTexture, 0);
|
||||
|
||||
gl.drawArrays(mode || gl.TRIANGLES, 0, mesh.vertexCount);
|
||||
}
|
||||
|
||||
// Builds a 4-vertex outline of the tile at (x, y, z), lifted slightly
|
||||
// to avoid z-fighting with the terrain surface beneath it.
|
||||
function buildHighlightMesh(x, y, z) {
|
||||
const eps = 0.02;
|
||||
return createMesh(new Float32Array([
|
||||
0, 0, x, y, z + eps,
|
||||
0, 0, x + 1, y, z + eps,
|
||||
0, 0, x + 1, y + 1, z + eps,
|
||||
0, 0, x, y + 1, z + eps,
|
||||
]));
|
||||
}
|
||||
|
||||
// Neighboring chunks are drawn dimmer and semi-transparent, so they
|
||||
// read as context rather than part of the chunk being edited.
|
||||
const NEIGHBOR_ALPHA = 0.35;
|
||||
const NEIGHBOR_DARKEN = 0.5;
|
||||
|
||||
// scene = {
|
||||
// target: [x, y, z], worldH: number,
|
||||
// terrain: { mesh, texture } | null,
|
||||
// gridLines: { mesh } | null,
|
||||
// models: [{ mesh, texture, color: [r,g,b,a in 0..1], offset: [x,y,z] }],
|
||||
// neighbors: [{
|
||||
// offset: [x,y,z],
|
||||
// terrain: { mesh, texture } | null,
|
||||
// models: [{ mesh, texture, color, offset }],
|
||||
// }],
|
||||
// highlight: { x, y, z } | null,
|
||||
// }
|
||||
function render(scene) {
|
||||
const width = canvas.width, height = canvas.height;
|
||||
gl.viewport(0, 0, width, height);
|
||||
gl.clearColor(0.16, 0.18, 0.22, 1);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
gl.useProgram(program);
|
||||
gl.depthMask(true);
|
||||
|
||||
const { view, fov } = computeCamera(scene.target, scene.worldH);
|
||||
const projection = mat4Perspective(new Float32Array(16), fov, width / height, 0.1, 1000);
|
||||
gl.uniformMatrix4fv(uniforms.uProjection, false, projection);
|
||||
gl.uniformMatrix4fv(uniforms.uView, false, view);
|
||||
|
||||
const identity = mat4Identity(new Float32Array(16));
|
||||
|
||||
if(scene.terrain) {
|
||||
drawMesh(scene.terrain.mesh, identity, scene.terrain.texture, [1, 1, 1, 1], true);
|
||||
}
|
||||
|
||||
if(scene.gridLines) {
|
||||
drawMesh(scene.gridLines.mesh, identity, null, [0, 0, 0, 0.35], false, gl.LINES);
|
||||
}
|
||||
|
||||
for(const model of scene.models) {
|
||||
const modelMatrix = mat4Translation(new Float32Array(16), model.offset);
|
||||
drawMesh(model.mesh, modelMatrix, model.texture, model.color, true);
|
||||
}
|
||||
|
||||
for(const neighbor of scene.neighbors || []) {
|
||||
if(neighbor.terrain) {
|
||||
const modelMatrix = mat4Translation(new Float32Array(16), neighbor.offset);
|
||||
drawMesh(
|
||||
neighbor.terrain.mesh, modelMatrix, neighbor.terrain.texture,
|
||||
[NEIGHBOR_DARKEN, NEIGHBOR_DARKEN, NEIGHBOR_DARKEN, NEIGHBOR_ALPHA], false,
|
||||
);
|
||||
}
|
||||
|
||||
for(const model of neighbor.models) {
|
||||
const worldOffset = [
|
||||
neighbor.offset[0] + model.offset[0],
|
||||
neighbor.offset[1] + model.offset[1],
|
||||
neighbor.offset[2] + model.offset[2],
|
||||
];
|
||||
const modelMatrix = mat4Translation(new Float32Array(16), worldOffset);
|
||||
const color = [
|
||||
model.color[0] * NEIGHBOR_DARKEN,
|
||||
model.color[1] * NEIGHBOR_DARKEN,
|
||||
model.color[2] * NEIGHBOR_DARKEN,
|
||||
model.color[3] * NEIGHBOR_ALPHA,
|
||||
];
|
||||
drawMesh(model.mesh, modelMatrix, model.texture, color, false);
|
||||
}
|
||||
}
|
||||
|
||||
if(scene.highlight) {
|
||||
const { x, y, z } = scene.highlight;
|
||||
const highlightMesh = buildHighlightMesh(x, y, z);
|
||||
drawMesh(highlightMesh, identity, null, [1, 0.92, 0.23, 1], false, gl.LINE_LOOP);
|
||||
}
|
||||
}
|
||||
|
||||
return { gl, createMesh, createTextureFromImage, render };
|
||||
}
|
||||
|
||||
return Object.freeze({ create, computeCamera });
|
||||
})();
|
||||
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dusk Map Editor</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">Dusk Map Editor</a>
|
||||
<ul class="navbar-nav flex-row">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/map">Map Editor</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="editor" class="container-fluid py-3"></div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,295 @@
|
||||
"""
|
||||
Map Editor HTTP Server
|
||||
|
||||
Serves editor/client/public/ as static files with smart routing:
|
||||
/ -> index.html
|
||||
/page -> page.html or page/index.html
|
||||
/index -> index.html
|
||||
|
||||
API endpoints (all paths relative to project root):
|
||||
GET /api/ls?path=<dir> directory listing
|
||||
GET /api/read?path=<file> file contents
|
||||
GET /api/find?path=<dir>&ext=<.json> recursive file listing by extension
|
||||
POST /api/write?path=<file> write file (JSON body: {"content":"..."})
|
||||
POST /api/mkdir?path=<dir> create directory
|
||||
POST /api/delete?path=<file> delete a file
|
||||
POST /api/compile-chunk?x=&y=&z= recompile a chunk JSON to .dcf
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import json
|
||||
import mimetypes
|
||||
import subprocess
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
from urllib.parse import urlparse, parse_qs, unquote
|
||||
from pathlib import Path
|
||||
|
||||
CHUNK_COORD_RE = re.compile(r"^-?\d+$")
|
||||
|
||||
PORT = 3000
|
||||
SCRIPT_DIR = Path(__file__).parent.resolve()
|
||||
PUBLIC_DIR = SCRIPT_DIR.parent / "client" / "public"
|
||||
PROJECT_ROOT = SCRIPT_DIR.parent.parent.resolve()
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
parsed = urlparse(self.path)
|
||||
path = unquote(parsed.path)
|
||||
if path.startswith("/api/"):
|
||||
params = parse_qs(parsed.query)
|
||||
if path == "/api/ls":
|
||||
self.api_ls(params)
|
||||
elif path == "/api/read":
|
||||
self.api_read(params)
|
||||
elif path == "/api/find":
|
||||
self.api_find(params)
|
||||
else:
|
||||
self.send_error(404)
|
||||
else:
|
||||
self.serve_static(path)
|
||||
|
||||
def do_POST(self):
|
||||
parsed = urlparse(self.path)
|
||||
params = parse_qs(parsed.query)
|
||||
if parsed.path == "/api/write":
|
||||
self.api_write(params)
|
||||
elif parsed.path == "/api/mkdir":
|
||||
self.api_mkdir(params)
|
||||
elif parsed.path == "/api/delete":
|
||||
self.api_delete(params)
|
||||
elif parsed.path == "/api/compile-chunk":
|
||||
self.api_compile_chunk(params)
|
||||
else:
|
||||
self.send_error(404)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def resolve_project_path(self, rel):
|
||||
rel = rel.lstrip("/")
|
||||
target = (PROJECT_ROOT / rel).resolve()
|
||||
if not str(target).startswith(str(PROJECT_ROOT)):
|
||||
return None
|
||||
return target
|
||||
|
||||
def send_json(self, data, code=200):
|
||||
body = json.dumps(data, indent=2).encode("utf-8")
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", len(body))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def read_body(self):
|
||||
length = int(self.headers.get("Content-Length", 0))
|
||||
return self.rfile.read(length)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# API handlers
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def api_ls(self, params):
|
||||
rel = params.get("path", [""])[0]
|
||||
target = self.resolve_project_path(rel)
|
||||
if target is None:
|
||||
self.send_json({"error": "invalid path"}, 400)
|
||||
return
|
||||
if not target.exists():
|
||||
self.send_json({"error": "path not found"}, 404)
|
||||
return
|
||||
if not target.is_dir():
|
||||
self.send_json({"error": "not a directory"}, 400)
|
||||
return
|
||||
|
||||
entries = []
|
||||
for entry in sorted(target.iterdir(), key=lambda e: (e.is_file(), e.name)):
|
||||
entries.append({
|
||||
"name": entry.name,
|
||||
"type": "dir" if entry.is_dir() else "file",
|
||||
"size": entry.stat().st_size if entry.is_file() else None,
|
||||
})
|
||||
self.send_json({
|
||||
"path": str(target.relative_to(PROJECT_ROOT)),
|
||||
"entries": entries,
|
||||
})
|
||||
|
||||
def api_read(self, params):
|
||||
rel = params.get("path", [""])[0]
|
||||
target = self.resolve_project_path(rel)
|
||||
if target is None:
|
||||
self.send_json({"error": "invalid path"}, 400)
|
||||
return
|
||||
if not target.exists():
|
||||
self.send_json({"error": "file not found"}, 404)
|
||||
return
|
||||
if not target.is_file():
|
||||
self.send_json({"error": "not a file"}, 400)
|
||||
return
|
||||
|
||||
try:
|
||||
content = target.read_text(encoding="utf-8")
|
||||
self.send_json({
|
||||
"path": str(target.relative_to(PROJECT_ROOT)),
|
||||
"content": content,
|
||||
})
|
||||
except UnicodeDecodeError:
|
||||
import base64
|
||||
content = base64.b64encode(target.read_bytes()).decode("ascii")
|
||||
self.send_json({
|
||||
"path": str(target.relative_to(PROJECT_ROOT)),
|
||||
"content": content,
|
||||
"encoding": "base64",
|
||||
})
|
||||
|
||||
def api_write(self, params):
|
||||
rel = params.get("path", [""])[0]
|
||||
target = self.resolve_project_path(rel)
|
||||
if target is None:
|
||||
self.send_json({"error": "invalid path"}, 400)
|
||||
return
|
||||
|
||||
body = self.read_body()
|
||||
try:
|
||||
data = json.loads(body)
|
||||
content = data.get("content", "")
|
||||
except (json.JSONDecodeError, UnicodeDecodeError):
|
||||
content = body.decode("utf-8")
|
||||
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(content, encoding="utf-8")
|
||||
self.send_json({"ok": True, "path": str(target.relative_to(PROJECT_ROOT))})
|
||||
|
||||
def api_mkdir(self, params):
|
||||
rel = params.get("path", [""])[0]
|
||||
target = self.resolve_project_path(rel)
|
||||
if target is None:
|
||||
self.send_json({"error": "invalid path"}, 400)
|
||||
return
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
self.send_json({"ok": True, "path": str(target.relative_to(PROJECT_ROOT))})
|
||||
|
||||
def api_delete(self, params):
|
||||
rel = params.get("path", [""])[0]
|
||||
target = self.resolve_project_path(rel)
|
||||
if target is None:
|
||||
self.send_json({"error": "invalid path"}, 400)
|
||||
return
|
||||
if target.is_file():
|
||||
target.unlink()
|
||||
self.send_json({"ok": True, "path": str(target.relative_to(PROJECT_ROOT))})
|
||||
|
||||
def api_find(self, params):
|
||||
rel = params.get("path", [""])[0]
|
||||
ext = params.get("ext", [""])[0]
|
||||
target = self.resolve_project_path(rel)
|
||||
if target is None:
|
||||
self.send_json({"error": "invalid path"}, 400)
|
||||
return
|
||||
if not target.is_dir():
|
||||
self.send_json({"error": "not a directory"}, 400)
|
||||
return
|
||||
|
||||
pattern = f"*{ext}" if ext else "*"
|
||||
paths = sorted(
|
||||
str(p.relative_to(target)).replace(os.sep, "/")
|
||||
for p in target.rglob(pattern)
|
||||
if p.is_file()
|
||||
)
|
||||
self.send_json({"path": str(target.relative_to(PROJECT_ROOT)), "files": paths})
|
||||
|
||||
def api_compile_chunk(self, params):
|
||||
x = params.get("x", [""])[0]
|
||||
y = params.get("y", [""])[0]
|
||||
z = params.get("z", [""])[0]
|
||||
if not (CHUNK_COORD_RE.match(x) and CHUNK_COORD_RE.match(y) and CHUNK_COORD_RE.match(z)):
|
||||
self.send_json({"error": "invalid chunk coordinates"}, 400)
|
||||
return
|
||||
|
||||
json_path = PROJECT_ROOT / "assetsraw" / "chunks" / f"chunk_{x}_{y}_{z}.json"
|
||||
if not json_path.is_file():
|
||||
self.send_json({"error": "chunk json not found"}, 404)
|
||||
return
|
||||
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "tools.asset.chunk", str(json_path)],
|
||||
cwd=str(PROJECT_ROOT),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
self.send_json({
|
||||
"ok": result.returncode == 0,
|
||||
"returncode": result.returncode,
|
||||
"stdout": result.stdout,
|
||||
"stderr": result.stderr,
|
||||
})
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Static file serving
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def serve_static(self, path):
|
||||
clean = path.lstrip("/")
|
||||
candidates = []
|
||||
|
||||
if clean == "" or clean == "index" or clean == "index.html":
|
||||
candidates = ["index.html"]
|
||||
else:
|
||||
candidates.append(clean)
|
||||
if "." not in Path(clean).name:
|
||||
candidates.append(clean + ".html")
|
||||
candidates.append(clean + "/index.html")
|
||||
|
||||
for candidate in candidates:
|
||||
file_path = PUBLIC_DIR / candidate
|
||||
if file_path.is_file():
|
||||
self.serve_file(file_path)
|
||||
return
|
||||
|
||||
self.send_error(404)
|
||||
|
||||
def serve_file(self, file_path):
|
||||
mime, _ = mimetypes.guess_type(str(file_path))
|
||||
mime = mime or "application/octet-stream"
|
||||
|
||||
template = PUBLIC_DIR / "template.html"
|
||||
if (
|
||||
mime == "text/html"
|
||||
and file_path.name != "template.html"
|
||||
and template.is_file()
|
||||
):
|
||||
fragment = file_path.read_text(encoding="utf-8")
|
||||
shell = template.read_text(encoding="utf-8")
|
||||
marker = shell.find('id="editor"')
|
||||
if marker == -1:
|
||||
content = shell.encode("utf-8")
|
||||
else:
|
||||
tag_end = shell.index(">", marker) + 1
|
||||
close_idx = shell.index("</div>", tag_end)
|
||||
content = (shell[:tag_end] + fragment + shell[close_idx:]).encode("utf-8")
|
||||
else:
|
||||
content = file_path.read_bytes()
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", mime)
|
||||
self.send_header("Content-Length", len(content))
|
||||
self.end_headers()
|
||||
self.wfile.write(content)
|
||||
|
||||
def log_message(self, fmt, *args):
|
||||
print(f" {self.address_string()} {fmt % args}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"Map Editor")
|
||||
print(f" http://localhost:{PORT}")
|
||||
print(f" public : {PUBLIC_DIR}")
|
||||
print(f" project: {PROJECT_ROOT}")
|
||||
server = HTTPServer(("", PORT), Handler)
|
||||
try:
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\nStopped.")
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
python3 server/server.py
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/gamecube/build-gamecube.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-gamecube.sh"
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/gamecube/build-gamecube-iso.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-gamecube-iso.sh"
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-knulli -f docker/knulli/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-knulli /bin/bash -c "./scripts/knulli/build-knulli.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-knulli /bin/bash -c "./scripts/build-knulli.sh"
|
||||
File renamed without changes.
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-linux -f docker/linux/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-linux /bin/bash -c "./scripts/linux/build-linux.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-linux /bin/bash -c "./scripts/build-linux.sh"
|
||||
File renamed without changes.
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-psp -f docker/psp/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-psp /bin/bash -c "./scripts/psp/build-psp.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-psp /bin/bash -c "./scripts/build-psp.sh"
|
||||
File renamed without changes.
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-vita -f docker/vita/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-vita /bin/bash -c "./scripts/vita/build-vita.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-vita /bin/bash -c "./scripts/build-vita.sh"
|
||||
File renamed without changes.
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/wii/build-wii.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-wii.sh"
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-dolphin -f docker/dolphin/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/wii/build-wii-iso.sh"
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin /bin/bash -c "./scripts/build-wii-iso.sh"
|
||||
File renamed without changes.
File renamed without changes.
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-dolphin-test -f docker/dolphin-test/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-dolphin-test /bin/bash -c "./scripts/test-gamecube-dolphin.sh"
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ -z "$DEVKITPRO" ]; then
|
||||
echo "DEVKITPRO environment variable is not set. Please set it to the path of your DEVKITPRO installation."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOLPHIN_BIN="${DOLPHIN_BIN:-dolphin-emu}"
|
||||
if ! command -v "$DOLPHIN_BIN" >/dev/null 2>&1; then
|
||||
echo "$DOLPHIN_BIN not found. Install Dolphin Emulator (e.g. 'apt install dolphin-emu')"
|
||||
echo "or set DOLPHIN_BIN to its path."
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v xvfb-run >/dev/null 2>&1; then
|
||||
echo "xvfb-run not found. Install it (e.g. 'apt install xvfb') -- Dolphin's"
|
||||
echo "Qt frontend needs a display even in batch mode."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/build-gamecube-iso.sh
|
||||
|
||||
DUSK_TEST_DOLPHIN_SECONDS="${DUSK_TEST_DOLPHIN_SECONDS:-20}"
|
||||
ISO="build-gamecube-iso/Dusk-NTSC-U.iso"
|
||||
|
||||
echo "Booting $ISO in Dolphin for up to ${DUSK_TEST_DOLPHIN_SECONDS}s (batch mode, headless via Xvfb)..."
|
||||
|
||||
# Dolphin's batch mode (-b -e) runs the disc until told to stop -- there's
|
||||
# no "the game exited cleanly" signal to wait for, so we bound it with
|
||||
# timeout and treat "still running when the clock ran out" as success.
|
||||
set +e
|
||||
xvfb-run -a timeout "${DUSK_TEST_DOLPHIN_SECONDS}" "$DOLPHIN_BIN" -b -e "$ISO"
|
||||
status=$?
|
||||
set -e
|
||||
|
||||
# timeout returns 124 when it had to kill Dolphin after the duration
|
||||
# elapsed -- that means the disc booted and kept running, the expected
|
||||
# smoke-test-passed outcome, not a failure. Any other non-zero status
|
||||
# means Dolphin crashed or refused to boot the disc.
|
||||
if [ "$status" -ne 0 ] && [ "$status" -ne 124 ]; then
|
||||
echo "Dolphin exited with unexpected status $status -- treating as a failure."
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
echo "GameCube smoke test passed (Dolphin ran $ISO for ${DUSK_TEST_DOLPHIN_SECONDS}s without crashing)."
|
||||
@@ -4,4 +4,4 @@ docker run \
|
||||
--rm \
|
||||
-v "${GITHUB_WORKSPACE}:/workdir" \
|
||||
dusk-linux \
|
||||
/bin/bash -c "./scripts/linux/test-linux.sh"
|
||||
/bin/bash -c "./scripts/test-linux.sh"
|
||||
File renamed without changes.
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
docker build -t dusk-psp-test -f docker/psp-test/Dockerfile .
|
||||
docker run --rm -v "$(pwd):/workdir" dusk-psp-test /bin/bash -c "./scripts/test-psp-ppsspp.sh"
|
||||
Loaded 100 of 674 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user