mirror of
https://github.com/TheBozos/DC_Recomp.git
synced 2026-12-01 12:53:58 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02a590f184 | ||
|
|
1234cf4f0f | ||
|
|
8a9cf7781d | ||
|
|
767b3e9557 | ||
|
|
851b6244d7 | ||
|
|
95903df0c9 | ||
|
|
6481ee4cb4 | ||
|
|
112cf4152f | ||
|
|
98b2b54de7 | ||
|
|
538902b3c0 | ||
|
|
07ac1d561f | ||
|
|
e61fb960e3 | ||
|
|
1f967b5c75 | ||
|
|
357135cb0a | ||
|
|
c90df9d710 | ||
|
|
13526ac41e | ||
|
|
44e53f9833 | ||
|
|
914284e90e | ||
|
|
ed49582da9 | ||
|
|
57e0ed663f | ||
|
|
65d399ffa6 | ||
|
|
96da183591 | ||
|
|
fccc458694 | ||
|
|
01433f480f | ||
|
|
e596e3e056 |
No files matched your search
@@ -7,8 +7,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- name: The BozoEngine release cmake/bozo_engine.json pins (SHA-256 checked)
|
||||
run: cmake -P cmake/bozo_engine_fetch.cmake
|
||||
- name: Build the pinned native engine and synthetic fixtures
|
||||
run: |
|
||||
cmake -S tests/native_lifetime -B build/ci -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
@@ -62,13 +62,15 @@ jobs:
|
||||
fi
|
||||
echo "WORK=$(cygpath -m "$RUNNER_TEMP")/dc" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Check out the tag or the branch (and the BozoEngine submodule at its recorded commit)
|
||||
- name: Check out the tag or the branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ env.TAG != '' && format('refs/tags/{0}', env.TAG) || '' }}
|
||||
submodules: true
|
||||
persist-credentials: false
|
||||
|
||||
- name: The BozoEngine release cmake/bozo_engine.json pins (SHA-256 checked; the kit reads its library pins)
|
||||
run: cmake -P cmake/bozo_engine_fetch.cmake
|
||||
|
||||
- name: Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
|
||||
@@ -17,6 +17,10 @@ SLUS_*
|
||||
*.irx
|
||||
*.IMG
|
||||
|
||||
# The BozoEngine release cmake/bozo_engine.json pins (cmake/bozo_engine_fetch.cmake)
|
||||
/BozoEngine/
|
||||
/.BozoEngine-unpack/
|
||||
|
||||
# Local build trees
|
||||
build/
|
||||
out/
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "BozoEngine"]
|
||||
path = BozoEngine
|
||||
url = https://github.com/TheBozos/BozoEngine.git
|
||||
-1
Submodule BozoEngine deleted from c27ce41d1e.
@@ -1,5 +1,42 @@
|
||||
# Changelog
|
||||
|
||||
## [0.7.0] - 2026-12-01
|
||||
|
||||
### Added
|
||||
- Game language: French, German and Italian ([#64](https://github.com/TheBozos/DC_Recomp/issues/64)). The USA disc also carries the European release's translations of the text and menus, and the game picks them by a language code it still has; the port sets it when the game starts, from the launcher's **Settings → Game language**, the game's **Options → Language** (applied at the next start), RecompLauncher's **Language** (all three write `game.ini` in the user folder) or `--language en|fr|de|it`. Spanish is not offered: the USA disc lacks about half of its story text.
|
||||
|
||||
### Fixed
|
||||
- Building after an update that moves to a newer BozoEngine release compiles the port's files again: the engine's unpacked files took the archive's old dates, so the build could keep files compiled against the previous engine.
|
||||
|
||||
### Known limits
|
||||
- Some European texts are longer than the boxes the USA layout gives them and run past their edge (the name entry's help).
|
||||
- The Italian text names Circle for confirming in places (the name entry's help and its Yes/No); Cross confirms, as in the USA game.
|
||||
|
||||
## [0.6.1] - 2026-12-01
|
||||
|
||||
### Fixed
|
||||
- The game now writes its log (`logs\` in its user folder: `%APPDATA%\DC_Recomp`, or RecompLauncher's `recompdata`), so the launcher's **Open game logs** and RecompLauncher's **Logs** show it, and a crash leaves a report in `crashes\`. Until now the game started neither, so both stayed empty.
|
||||
|
||||
## [0.6.0] - 2026-12-01
|
||||
|
||||
### Added
|
||||
- RecompLauncher support: releases carry a `recomplauncher.json` ([#63](https://github.com/TheBozos/DC_Recomp/issues/63)). RecompLauncher checks the disc against the USA dump, prepares the game with the release's own build, starts it, shows the video settings (display mode, widescreen, frame rate, render scale, anti-aliasing, texture smoothing) on the game's page and backs up the memory cards. A game set up there keeps its saves, settings and logs in its `recompdata` folder.
|
||||
- Preparing again without a disc image uses the one the earlier preparation kept in the game folder, so an update can be built after the original image was deleted.
|
||||
|
||||
### Changed
|
||||
- BozoEngine comes from its releases instead of a git submodule: `cmake/bozo_engine.json` pins BozoEngine 0.5.0 (the same code as before, commit c27ce41) and the SHA-256 of its archive, which the build downloads once and checks. A release still carries the engine's source, so preparing the game stays offline.
|
||||
|
||||
## [0.5.2] - 2026-11-30
|
||||
|
||||
### Fixed
|
||||
- Preparing a release unzipped over an earlier one no longer fails with "manifest 'build.ninja' still dirty after 100 tries" ([#60](https://github.com/TheBozos/DC_Recomp/issues/60)). The zip dates its files at the release's commit time, which an unzip west of UTC can place hours in the future; preparation now dates those files now. It also dates now every file that changed since the last preparation, so an update is always compiled in full even when its files are dated before the old build. The first preparation after this update builds everything again, once.
|
||||
- The launcher's Update button installs the new release: the installer it runs (`tools/apply_update.py`) was missing from every release so far, so installs of 0.5.1 and earlier still need this one unzipped over them by hand.
|
||||
|
||||
## [0.5.1] - 2026-11-30
|
||||
|
||||
### Fixed
|
||||
- Widescreen: models at the picture's sides (monsters, NPCs, plants, rocks, map pieces) no longer vanish outside the old 4:3 area. The game skipped any model lying wholly outside the 4:3 frame; that test now uses the frame actually drawn. 4:3 is unchanged.
|
||||
|
||||
## [0.5.0] - 2026-11-28
|
||||
|
||||
### Added
|
||||
|
||||
+24
-4
@@ -9,7 +9,19 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
|
||||
option(DC_GUI_SUBSYSTEM "Build the Windows player without a console" OFF)
|
||||
set(DC_GAME_DIR "${CMAKE_SOURCE_DIR}/game" CACHE PATH "User-owned extracted disc files")
|
||||
set(BOZO_ENGINE_DIR "${CMAKE_SOURCE_DIR}/BozoEngine" CACHE PATH "Pinned native engine source")
|
||||
# BozoEngine: the release cmake/bozo_engine.json pins, fetched into BozoEngine/ (cmake/bozo_engine_fetch.cmake), unless
|
||||
# BOZO_ENGINE_DIR names another tree (development: a BozoEngine checkout).
|
||||
set(BOZO_ENGINE_DIR "" CACHE PATH "BozoEngine's source tree (default: the release cmake/bozo_engine.json pins, in BozoEngine/)")
|
||||
set(dc_engine_given "")
|
||||
if(BOZO_ENGINE_DIR)
|
||||
file(REAL_PATH "${BOZO_ENGINE_DIR}" dc_engine_given)
|
||||
endif()
|
||||
file(REAL_PATH "${CMAKE_SOURCE_DIR}/BozoEngine" dc_engine_in_repo)
|
||||
if(NOT BOZO_ENGINE_DIR OR dc_engine_given STREQUAL dc_engine_in_repo)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/bozo_engine_fetch.cmake")
|
||||
set(BOZO_ENGINE_DIR "${bozo_engine_tree}")
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/cmake/bozo_engine.json")
|
||||
endif()
|
||||
option(DC_WINDOW "Build the SDL3 native game window" ON)
|
||||
option(DC_AUDIT_INDIRECT "Instrument generated register transfers for local audit traces" OFF)
|
||||
set(BOZO_APP ${DC_WINDOW} CACHE BOOL "" FORCE)
|
||||
@@ -95,13 +107,15 @@ target_link_libraries(dc_cheats PUBLIC bozo_host)
|
||||
add_library(dc_warp STATIC runtime/dc_warp.cpp)
|
||||
target_link_libraries(dc_warp PUBLIC dc_cheats dc_pad bozo_host)
|
||||
add_library(dc_ingame_cheats STATIC runtime/dc_ingame_cheats.cpp)
|
||||
target_link_libraries(dc_ingame_cheats PUBLIC dc_cheats dc_warp bozo_host)
|
||||
target_link_libraries(dc_ingame_cheats PUBLIC dc_cheats dc_warp dc_language bozo_host)
|
||||
add_library(dc_pad STATIC runtime/dc_pad.cpp)
|
||||
target_link_libraries(dc_pad PUBLIC bozo_host)
|
||||
add_library(dc_language STATIC runtime/dc_language.cpp)
|
||||
target_include_directories(dc_language PUBLIC ${CMAKE_SOURCE_DIR}/runtime)
|
||||
add_library(dc_sound STATIC runtime/dc_sound.cpp)
|
||||
target_link_libraries(dc_sound PUBLIC bozo_host)
|
||||
add_executable(dc-headless runtime/dc_main.cpp runtime/dc_state.cpp runtime/dc_port.cpp runtime/dc_sound.cpp runtime/dc_native.cpp)
|
||||
target_link_libraries(dc-headless PRIVATE dc_game bozo_host dc_cheats dc_ingame_cheats dc_warp dc_pad)
|
||||
target_link_libraries(dc-headless PRIVATE dc_game bozo_host dc_cheats dc_ingame_cheats dc_warp dc_pad dc_language)
|
||||
if(MINGW)
|
||||
target_link_options(dc-headless PRIVATE -static)
|
||||
endif()
|
||||
@@ -136,7 +150,7 @@ add_dependencies(dc-headless dc_native_audio)
|
||||
|
||||
if(DC_WINDOW)
|
||||
add_executable(dc runtime/dc_main.cpp runtime/dc_state.cpp runtime/dc_port.cpp runtime/dc_sound.cpp runtime/dc_native.cpp runtime/dc_audio.cpp runtime/dc_cheats_ui.cpp $<TARGET_OBJECTS:dc_audio_code>)
|
||||
target_link_libraries(dc PRIVATE dc_game bozo_host bozo_app dc_cheats dc_ingame_cheats dc_warp dc_pad)
|
||||
target_link_libraries(dc PRIVATE dc_game bozo_host bozo_app dc_cheats dc_ingame_cheats dc_warp dc_pad dc_language)
|
||||
if(WIN32)
|
||||
enable_language(RC)
|
||||
string(REPLACE "." "," DC_FILEVERSION "${PROJECT_VERSION}.0")
|
||||
@@ -203,6 +217,12 @@ if(DC_ENGINE_TESTS)
|
||||
target_link_options(dc-pad-tests PRIVATE -static)
|
||||
endif()
|
||||
add_test(NAME dc_native_pad COMMAND dc-pad-tests)
|
||||
add_executable(dc-language-tests tests/dc_language_tests.cpp)
|
||||
target_link_libraries(dc-language-tests PRIVATE dc_language)
|
||||
if(MINGW)
|
||||
target_link_options(dc-language-tests PRIVATE -static)
|
||||
endif()
|
||||
add_test(NAME dc_language COMMAND dc-language-tests)
|
||||
add_executable(dc-sound-tests tests/dc_sound_tests.cpp)
|
||||
target_link_libraries(dc-sound-tests PRIVATE dc_sound bozo_host)
|
||||
if(MINGW)
|
||||
|
||||
@@ -24,7 +24,7 @@ SOFTWARE.
|
||||
|
||||
This licence covers DC_Recomp's own files. It does not cover:
|
||||
|
||||
- Git submodules, which have their own licences.
|
||||
- BozoEngine/ (the recompiler and runtime, a separate MIT project, fetched from its releases): see BozoEngine/LICENSE.
|
||||
- Anything from Dark Cloud, such as screenshots. No game data or code is in this repository;
|
||||
players build the port from their own disc.
|
||||
- Third-party components with their own licences.
|
||||
@@ -28,7 +28,7 @@ BozoEngine replaces the PS2Recomp fork completely; there is no emulation fallbac
|
||||
|
||||
## For players (Windows)
|
||||
|
||||
Download **`DC_Recomp-0.5.0-bozo.zip`** from [Releases](https://github.com/TheBozos/DC_Recomp/releases/latest),
|
||||
Download **`DC_Recomp-0.7.0-bozo.zip`** from [Releases](https://github.com/TheBozos/DC_Recomp/releases/latest),
|
||||
check its `.sha256`, and extract it to a writable folder such as `D:\Games\DC_Recomp_Bozo`.
|
||||
Open **DC Launcher.exe**, select your own USA disc image (`.iso` or `.bin`/`.cue`), click **Prepare the game**,
|
||||
then **Play**. Preparation runs locally with the bundled offline tools; no developer software is needed.
|
||||
@@ -38,12 +38,18 @@ You need Windows 10 version 1903 or newer (or Windows 11), an AVX2/FMA CPU, Open
|
||||
Only the unmodified `SCUS-97111` version 1.02 disc is supported; the executable and both overlays are verified.
|
||||
The unsigned launcher may trigger Windows SmartScreen. Game files and generated game code are never distributed.
|
||||
|
||||
Use the launcher's **Settings** for display options, logs, maintenance and updates. **F2** opens the game's
|
||||
Use the launcher's **Settings** for display options, the game's language, logs, maintenance and updates. **F2** opens the game's
|
||||
settings. Saves, controls, video settings and cheats are stored in `%APPDATA%\DC_Recomp` and survive launcher
|
||||
updates. Existing development saves are kept separately; copy only the desired card files into that directory.
|
||||
The in-game pause menu includes **Graphics** (widescreen, anti-aliasing and more), **Cheats**, **Travel** and **Quit Game**. Updates offer a rebuild when the source changes.
|
||||
See [CHANGELOG.md](CHANGELOG.md) for release changes and the checked routes above for current coverage.
|
||||
|
||||
**RecompLauncher.** Releases carry a [`recomplauncher.json`](recomplauncher.json), so
|
||||
[RecompLauncher](https://recomplauncher.com) can install DC_Recomp, check your disc, prepare the game with the
|
||||
same build (its setup step), show the language and video settings on the game's page and back up the memory cards. A game
|
||||
set up there keeps its saves, settings and logs in its own `recompdata` folder, not in `%APPDATA%\DC_Recomp`:
|
||||
copy `mc0` across to bring saves from DC Launcher.
|
||||
|
||||
## Status
|
||||
|
||||
**Playable Windows port, under active gameplay testing.** Checked routes include Norune,
|
||||
@@ -69,6 +75,7 @@ A complete story playthrough and full visual parity remain unverified.
|
||||
| Complete story played by hand, all companions, locations and effects | 🔧 |
|
||||
| Linux build | ⏳ |
|
||||
| Widescreen, with the HUD at the screen's edges | ✅ |
|
||||
| French, German and Italian text and menus, from the disc's own European translations | 🔧 |
|
||||
| Travel: any town, area, dungeon floor and story chapter (cheats, scripted runs) | ✅ |
|
||||
|
||||
**Native port.** Models, textures, camera, lights and drawing routines feed native PC draws.
|
||||
@@ -146,8 +153,13 @@ disc files (game/) ──► tools/dc_bozo_prepare.py ──► resident ELF + T
|
||||
- The top-level build generates code and converts textures automatically, then links the windowed `dc` and
|
||||
`dc-headless` runners. Game-derived output stays in the ignored build directory.
|
||||
|
||||
[BozoEngine](https://github.com/TheBozos/BozoEngine) is the sole engine submodule. Game-specific addresses, formats,
|
||||
hook choices and module layouts stay in DC_Recomp; engine changes must be generic and reusable by other recompiles.
|
||||
[BozoEngine](https://github.com/TheBozos/BozoEngine) is the sole engine. The build uses the BozoEngine release
|
||||
`cmake/bozo_engine.json` pins (version and the SHA-256 of its archive): `cmake/bozo_engine_fetch.cmake` downloads it
|
||||
into `BozoEngine/` once and checks the hash, and a release's `source\BozoEngine` carries it, so a player's build stays
|
||||
offline. An engine bump changes that file to a newer release; engine work not released yet is built on a local
|
||||
BozoEngine checkout with `-DBOZO_ENGINE_DIR=<it>` (or `tools/dc_build.py --engine <it>`, `BOZO_ENGINE_DIR=<it>` for
|
||||
`scripts/`), never by pinning a commit. Game-specific addresses, formats, hook choices and module layouts stay in
|
||||
DC_Recomp; engine changes must be generic and reusable by other recompiles.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -177,8 +189,9 @@ With an extracted release, use `kit/python/python.exe -I -X utf8 source/tools/dc
|
||||
### Developer build and regression suites
|
||||
|
||||
```bash
|
||||
git clone --recurse-submodules https://github.com/TheBozos/DC_Recomp.git
|
||||
git clone https://github.com/TheBozos/DC_Recomp.git
|
||||
cd DC_Recomp
|
||||
cmake -P cmake/bozo_engine_fetch.cmake # the pinned BozoEngine release into BozoEngine/ (configure does it too)
|
||||
scripts/extract_iso.sh "/path/to/Dark Cloud (USA).iso"
|
||||
scripts/bench_run.sh --alone 20 "native build" scripts/build_runtime.sh Release \
|
||||
-DDC_ISO="D:/path/to/Dark Cloud (USA).iso"
|
||||
@@ -214,7 +227,7 @@ an update, use the game's own memory-card saves. `--save-state FILE --save-state
|
||||
`--load-state FILE [--load-state-at FRAME]` do the same from the command line.
|
||||
|
||||
The game's **Options** entry page offers **Game Options** (the original settings), **Graphics**, **Cheats**,
|
||||
**Travel** and **Quit Game**. Up/Down selects rows, Cross confirms and Circle goes back. **Graphics** sets the display
|
||||
**Travel**, **Language** and **Quit Game**. Up/Down selects rows, Cross confirms and Circle goes back. **Graphics** sets the display
|
||||
mode, resolution, render scale, frame rate, widescreen, anti-aliasing and texture smoothing; **Apply and save** writes
|
||||
them to `video.ini` (shared with the launcher's Settings and **F2 → Video**). **Widescreen** shows a 16:9 picture
|
||||
with more of the scene at the sides; the HUD moves to the screen's edges while menus and full-screen pictures stay
|
||||
@@ -253,6 +266,12 @@ ABS at 1× and movement at 100%. See [the cheat reference](docs/CHEATS.md) for l
|
||||
map and advances the story to a chosen chapter. Each request waits until you walk freely, then goes through the
|
||||
game's own fade and loading. Save before advancing the story: it is meant for testing.
|
||||
|
||||
**Language.** The USA disc also carries the European release's French, German and Italian text and menus, and its
|
||||
program still picks them by a language code. The launcher's **Settings → Game language**, the game's own
|
||||
**Options → Language** and RecompLauncher's **Language** write `language = en`, `fr`, `de` or `it` to `game.ini` in
|
||||
the user folder; the game reads it when it starts, so a change made in the game applies at its next start. `--language fr` does the same for one run. Spanish is not offered: the USA disc lacks about half its story
|
||||
text. Some European texts are longer than their English boxes (the name entry's help, for one) and run past them.
|
||||
|
||||
### Memory cards and data paths
|
||||
|
||||
The windowed runner uses BozoEngine's per-user memory-card directory. Existing `game/mc0` saves migrate
|
||||
@@ -304,7 +323,7 @@ licences and corresponding toolchain sources, and audits the archives for game d
|
||||
```bash
|
||||
python tools/make_build_kit.py --out D:/dc_kit/kit
|
||||
scripts/bench_run.sh --alone 20 "release package" python tools/make_release.py \
|
||||
--version 0.5.0 --kit D:/dc_kit/kit --out D:/dc_release --with-sources
|
||||
--version 0.7.0 --kit D:/dc_kit/kit --out D:/dc_release --with-sources
|
||||
```
|
||||
|
||||
Only committed source is exported. Follow [the release checklist](docs/RELEASE_CHECKLIST.md) before publishing;
|
||||
@@ -338,7 +357,7 @@ scripts/bench_run.sh --alone 20 "runner build" scripts/build_runtime.sh
|
||||
|
||||
| Path | Contents |
|
||||
|---|---|
|
||||
| `BozoEngine/` | Sole engine submodule: native recompiler/runtime |
|
||||
| `BozoEngine/` | The pinned BozoEngine release (`cmake/bozo_engine.json`, fetched, not in git): native recompiler/runtime |
|
||||
| `runtime/` | DC render, audio, frame, menu and cheat adapters |
|
||||
| `recomp/` | Function maps and guarded native adaptations |
|
||||
| `scripts/` | Extraction, generation, builds, runs, tests and bench lock |
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": "0.5.0",
|
||||
"sha256": "319cda4ce617638decdcb7d6eff482c94528fb66ab6e14e3e2c5b4e43e214d0f"
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
# The BozoEngine release cmake/bozo_engine.json pins, in BozoEngine/ beside cmake/: the release's archive
|
||||
# (https://github.com/TheBozos/BozoEngine/releases), SHA-256 checked, unpacked, and its version and hash written to
|
||||
# BozoEngine/.release; nothing is downloaded while those match the pin (a release's source\BozoEngine comes with it, so
|
||||
# a player's build stays offline). Included by CMakeLists.txt, launcher/CMakeLists.txt and
|
||||
# tests/native_lifetime/CMakeLists.txt when they are not given another tree, run by tools/dc_build.py in a git checkout
|
||||
# and by tools/make_release.py, or on its own:
|
||||
# cmake [-DBOZO_ENGINE_DOWNLOADS=<dir>] -P cmake/bozo_engine_fetch.cmake
|
||||
# BOZO_ENGINE_DOWNLOADS is where the archive goes (default build/). The same scheme as TMB_Recomp's and
|
||||
# SoulCaliburIII_Recomp's.
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
get_filename_component(bozo_engine_root "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/bozo_engine.json" bozo_engine_pin)
|
||||
string(JSON bozo_engine_version GET "${bozo_engine_pin}" version)
|
||||
string(JSON bozo_engine_sha256 GET "${bozo_engine_pin}" sha256)
|
||||
set(bozo_engine_tree "${bozo_engine_root}/BozoEngine")
|
||||
|
||||
set(bozo_engine_want "${bozo_engine_version} ${bozo_engine_sha256}")
|
||||
set(bozo_engine_have "")
|
||||
if(EXISTS "${bozo_engine_tree}/.release")
|
||||
file(READ "${bozo_engine_tree}/.release" bozo_engine_have)
|
||||
string(STRIP "${bozo_engine_have}" bozo_engine_have)
|
||||
elseif(EXISTS "${bozo_engine_tree}")
|
||||
file(GLOB bozo_engine_entries "${bozo_engine_tree}/*" "${bozo_engine_tree}/.*")
|
||||
if(bozo_engine_entries)
|
||||
message(FATAL_ERROR "BozoEngine: ${bozo_engine_tree} is not a pinned release (the old submodule's checkout?): "
|
||||
"move it away (to build on it there: -DBOZO_ENGINE_DIR=<its new place>, or "
|
||||
"tools/dc_build.py --engine <its new place>)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT bozo_engine_have STREQUAL bozo_engine_want)
|
||||
if(NOT BOZO_ENGINE_DOWNLOADS)
|
||||
set(BOZO_ENGINE_DOWNLOADS "${bozo_engine_root}/build")
|
||||
endif()
|
||||
set(bozo_engine_name "BozoEngine-${bozo_engine_version}")
|
||||
set(bozo_engine_archive "${BOZO_ENGINE_DOWNLOADS}/${bozo_engine_name}.tar.gz")
|
||||
set(bozo_engine_url
|
||||
"https://github.com/TheBozos/BozoEngine/releases/download/v${bozo_engine_version}/${bozo_engine_name}.tar.gz")
|
||||
message(STATUS "BozoEngine ${bozo_engine_version}: ${bozo_engine_url}")
|
||||
file(DOWNLOAD "${bozo_engine_url}" "${bozo_engine_archive}" EXPECTED_HASH SHA256=${bozo_engine_sha256}
|
||||
TLS_VERIFY ON STATUS bozo_engine_status)
|
||||
list(GET bozo_engine_status 0 bozo_engine_code)
|
||||
if(bozo_engine_code)
|
||||
list(GET bozo_engine_status 1 bozo_engine_error)
|
||||
message(FATAL_ERROR "BozoEngine ${bozo_engine_version}: ${bozo_engine_error}")
|
||||
endif()
|
||||
set(bozo_engine_unpack "${bozo_engine_root}/.BozoEngine-unpack")
|
||||
file(REMOVE_RECURSE "${bozo_engine_tree}" "${bozo_engine_unpack}")
|
||||
file(ARCHIVE_EXTRACT INPUT "${bozo_engine_archive}" DESTINATION "${bozo_engine_unpack}")
|
||||
# Its files dated now: unpacked with the archive's own dates (the release's, older than objects built since), a
|
||||
# build made on the last release kept objects compiled against the old headers after a pin bump (Shinobido 0.7.0 ->
|
||||
# 0.7.3: two files built on the old renderer.h, objects and the HUD missing from the picture).
|
||||
file(GLOB_RECURSE bozo_engine_files LIST_DIRECTORIES false "${bozo_engine_unpack}/*")
|
||||
file(TOUCH_NOCREATE ${bozo_engine_files})
|
||||
file(WRITE "${bozo_engine_unpack}/${bozo_engine_name}/.release" "${bozo_engine_want}\n")
|
||||
file(RENAME "${bozo_engine_unpack}/${bozo_engine_name}" "${bozo_engine_tree}")
|
||||
file(REMOVE_RECURSE "${bozo_engine_unpack}")
|
||||
endif()
|
||||
@@ -1,6 +1,6 @@
|
||||
# BozoEngine migration
|
||||
|
||||
Implemented on 2026-11-06. The active build uses only the `BozoEngine` submodule. The previous dirty PS2Recomp checkout is retained locally as an ignored recovery directory; it is not a submodule, source input, include path or linked dependency. Local recovery patches and the previous runner are in `build/migration-baseline`.
|
||||
Implemented on 2026-11-06. The active build uses only BozoEngine (a submodule then; since 2026-11-30 the release `cmake/bozo_engine.json` pins). The previous dirty PS2Recomp checkout is retained locally as an ignored recovery directory; it is not a submodule, source input, include path or linked dependency. Local recovery patches and the previous runner are in `build/migration-baseline`.
|
||||
|
||||
The graphics cleanup includes the DC adapters, regression fixtures, guarded offline adaptations and published
|
||||
BozoEngine pin `4a8f70a` together. References to local/unpublished work in the milestone sections below describe
|
||||
|
||||
+14
-3
@@ -25,10 +25,21 @@ endif()
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# BozoEngine's tree (the submodule beside launcher/): its PNG writer only.
|
||||
set(LAUNCHER_BOZO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../BozoEngine" CACHE PATH "BozoEngine's source tree")
|
||||
# BozoEngine's tree (default: the release cmake/bozo_engine.json pins, in BozoEngine/ beside launcher/): its PNG writer
|
||||
# only.
|
||||
set(LAUNCHER_BOZO_DIR "" CACHE PATH "BozoEngine's source tree (default: the pinned release, in BozoEngine/)")
|
||||
set(launcher_engine_given "")
|
||||
if(LAUNCHER_BOZO_DIR)
|
||||
file(REAL_PATH "${LAUNCHER_BOZO_DIR}" launcher_engine_given)
|
||||
endif()
|
||||
file(REAL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../BozoEngine" launcher_engine_in_repo)
|
||||
if(NOT LAUNCHER_BOZO_DIR OR launcher_engine_given STREQUAL launcher_engine_in_repo)
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/bozo_engine_fetch.cmake")
|
||||
set(LAUNCHER_BOZO_DIR "${bozo_engine_tree}")
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/bozo_engine.json")
|
||||
endif()
|
||||
if(NOT EXISTS "${LAUNCHER_BOZO_DIR}/runtime/app/png.cpp")
|
||||
message(FATAL_ERROR "No BozoEngine at ${LAUNCHER_BOZO_DIR} (git submodule update --init BozoEngine)")
|
||||
message(FATAL_ERROR "No BozoEngine at ${LAUNCHER_BOZO_DIR}")
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
@@ -126,6 +126,26 @@ bool VideoConfig::save(const std::string &file) const
|
||||
return writeAtomically(file, text);
|
||||
}
|
||||
|
||||
bool GameConfig::load(const std::string &file)
|
||||
{
|
||||
std::map<std::string, std::string> v;
|
||||
if (!readIni(file, v, true))
|
||||
return false;
|
||||
const std::string l = v["language"];
|
||||
if (l == "en" || l == "fr" || l == "de" || l == "it")
|
||||
language = l;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameConfig::save(const std::string &file) const
|
||||
{
|
||||
std::string text = "# Dark Cloud's own settings (the launcher and RecompLauncher write this file; the game reads it when it starts).\n"
|
||||
"# language: en (English), fr (French), de (German) or it (Italian), from the disc's own text and menus.\n"
|
||||
"\n[game]\n";
|
||||
text += "language = " + language + "\n";
|
||||
return writeAtomically(file, text);
|
||||
}
|
||||
|
||||
std::vector<std::pair<int, int>> offeredResolutions(int monitorWidth, int monitorHeight)
|
||||
{
|
||||
static const std::pair<int, int> kCommon[] = {
|
||||
|
||||
@@ -36,6 +36,15 @@ struct VideoConfig
|
||||
bool save(const std::string &file) const;
|
||||
};
|
||||
|
||||
// The game's own settings (game.ini in the user folder, read by the game when it starts; RecompLauncher writes it too).
|
||||
struct GameConfig
|
||||
{
|
||||
std::string language = "en"; // en, fr, de, it: the text and menus the game shows (runtime/dc_language.h)
|
||||
|
||||
bool load(const std::string &file);
|
||||
bool save(const std::string &file) const;
|
||||
};
|
||||
|
||||
// The sizes the game's Video tab offers on this monitor (ps2_video::resolutions): common 4:3 and 16:9 ones that fit,
|
||||
// and the monitor's own.
|
||||
std::vector<std::pair<int, int>> offeredResolutions(int monitorWidth, int monitorHeight);
|
||||
+30
-2
@@ -342,7 +342,7 @@ struct Paths
|
||||
{
|
||||
std::string release, source, kit, python, script, buildOut, buildLogs, game, gameExe, elf, iso;
|
||||
std::string releaseIni, builtFrom; // the source's release stamp, and the one of the code the game was built from
|
||||
std::string user, launcherIni, videoIni, logs, crashes;
|
||||
std::string user, launcherIni, videoIni, gameIni, logs, crashes;
|
||||
};
|
||||
|
||||
struct App
|
||||
@@ -350,6 +350,8 @@ struct App
|
||||
Paths p;
|
||||
LauncherConfig cfg;
|
||||
VideoConfig video;
|
||||
GameConfig gameCfg;
|
||||
bool gameCfgSaved = false;
|
||||
Phase phase = Phase::Welcome;
|
||||
Tab tab = Tab::Play;
|
||||
std::string missingPart; // Incomplete: what is not there
|
||||
@@ -440,12 +442,14 @@ struct App
|
||||
const fs::path u = plat::path(p.user);
|
||||
p.launcherIni = plat::str(u / L"launcher.ini");
|
||||
p.videoIni = plat::str(u / L"video.ini");
|
||||
p.gameIni = plat::str(u / L"game.ini");
|
||||
p.logs = plat::str(u / L"logs");
|
||||
p.crashes = plat::str(u / L"crashes");
|
||||
|
||||
cfg.load(p.launcherIni);
|
||||
g_fr = (cfg.language.empty() ? plat::systemLanguage() : cfg.language) == "fr";
|
||||
video.load(p.videoIni);
|
||||
gameCfg.load(p.gameIni);
|
||||
|
||||
if (!exists(p.script))
|
||||
missingPart = "source\\tools\\dc_build.py";
|
||||
@@ -1301,6 +1305,8 @@ static void drawSettings(App &app, float inner)
|
||||
}
|
||||
}
|
||||
gap(6);
|
||||
const float settingsRowY = ImGui::GetCursorPosY();
|
||||
ImGui::BeginGroup(); // Resolution, with Game language beside it
|
||||
ui::text(L("Resolution", "Résolution"), 17, ui::color::inkFaint);
|
||||
const auto sizes = offeredResolutions(win::monitorWidth(), win::monitorHeight());
|
||||
auto label = [&](int w, int h)
|
||||
@@ -1336,6 +1342,28 @@ static void drawSettings(App &app, float inner)
|
||||
}
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
// The game's language (game.ini): the disc's own English, French, German and Italian text and menus, level
|
||||
// with Resolution (placed, not SameLine: a same-line label would take the combo's baseline offset).
|
||||
const float belowResolution = ImGui::GetCursorPosY();
|
||||
ImGui::SetCursorPos(ImVec2(ImGui::GetItemRectMax().x - ImGui::GetWindowPos().x + S(56), settingsRowY));
|
||||
ImGui::BeginGroup();
|
||||
ui::text(L("Game language", "Langue du jeu"), 17, ui::color::inkFaint);
|
||||
static const char *gameLanguages[4][2] = {{"en", "English"}, {"fr", "Français"}, {"de", "Deutsch"}, {"it", "Italiano"}};
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (i)
|
||||
ImGui::SameLine(0, S(8));
|
||||
char langId[64];
|
||||
std::snprintf(langId, sizeof(langId), "%s##game-%s", gameLanguages[i][1], gameLanguages[i][0]);
|
||||
if (ui::pill(langId, app.gameCfg.language == gameLanguages[i][0], 18) && app.gameCfg.language != gameLanguages[i][0])
|
||||
{
|
||||
app.gameCfg.language = gameLanguages[i][0];
|
||||
app.gameCfgSaved = app.gameCfg.save(app.p.gameIni);
|
||||
}
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
ImGui::SetCursorPosY(std::max(belowResolution, ImGui::GetCursorPosY()));
|
||||
if (changed)
|
||||
{
|
||||
VideoConfig out = v;
|
||||
@@ -1347,7 +1375,7 @@ static void drawSettings(App &app, float inner)
|
||||
out.save(app.p.videoIni);
|
||||
app.video.exists = true;
|
||||
}
|
||||
if (v.exists)
|
||||
if (v.exists || app.gameCfgSaved)
|
||||
ui::text(L("Saved. The game uses it the next time it starts.", "Enregistré. Le jeu l'utilisera au prochain démarrage."), 16,
|
||||
ui::color::good);
|
||||
gap(12);
|
||||
|
||||
@@ -438,3 +438,8 @@
|
||||
0x0012c33c 0x0c044b02 0x00000000 # MGInit: no sceGsSetDefDBuff
|
||||
0x0012c510 0xdcc60000 0xdcc60000 # MGInit: native site, draw 0 TEST (guard)
|
||||
0x0012c57c 0xdc840000 0xdc840000 # MGInit: native site, draw 0 ZBUF (guard)
|
||||
# CFrameVu1::DrawVu1 skips a model whose projected bounding box lies wholly outside the frame: x within 320 of the
|
||||
# centre (y within 112). Its two loads of 320.0 are native sites (runtime/dc_port.cpp) giving the frame's half width,
|
||||
# so widescreen draws the models its wider sides show; 4:3 keeps 320.
|
||||
0x00129ab4 0x3c0243a0 0x3c0243a0 # DrawVu1: native site, cull half width (guard)
|
||||
0x00129ae4 0x3c0243a0 0x3c0243a0 # DrawVu1: native site, cull half width (guard)
|
||||
@@ -0,0 +1,142 @@
|
||||
{
|
||||
"$schema": "https://recomplauncher.com/schema/recomplauncher.json",
|
||||
"format": 1,
|
||||
"name": "Dark Cloud",
|
||||
"repo": "TheBozos/DC_Recomp",
|
||||
"inputs": [
|
||||
{
|
||||
"id": "game",
|
||||
"label": "Your disc image of the USA release, serial SCUS-97111 (.iso, or .bin/.cue).",
|
||||
"formats": [{ "type": "file" }],
|
||||
"check": { "iso9660": "SCUS_971.11", "ids": ["SCUS-97111"] },
|
||||
"dumps": [{ "name": "USA", "size": 1797980160, "crc32": "fe4adb70" }]
|
||||
}
|
||||
],
|
||||
"prepare": {
|
||||
"program": ["kit/python/python.exe"],
|
||||
"args": ["-I", "-X", "utf8", "{install}/source/tools/dc_build.py", "--disc={input:game}",
|
||||
"--out", "{install}/build", "--game", "{install}/game", "--progress-lines"],
|
||||
"label": "Building the game from your disc",
|
||||
"done": ["{install}/game/built_from.ini"],
|
||||
"keeps_copy": true
|
||||
},
|
||||
"start": {
|
||||
"program": ["game/dc.exe"],
|
||||
"args": ["--elf", "{install}/game/SCUS_971.11", "--iso", "{install}/game/disc.iso"],
|
||||
"env": { "PS2X_USER_DIR": "{data}" }
|
||||
},
|
||||
"folders": {
|
||||
"game": [{ "path": "{install}/game" }],
|
||||
"saves": [{ "path": "{data}/mc0" }],
|
||||
"logs": [{ "path": "{data}/logs" }]
|
||||
},
|
||||
"saves": ["{data}/mc0", "{data}/mc1"],
|
||||
"config": [
|
||||
{ "format": "ini", "file": [{ "path": "{data}/video.ini" }] },
|
||||
{ "id": "game", "format": "ini", "file": [{ "path": "{data}/game.ini" }] }
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"id": "language", "label": "Language", "in": "game",
|
||||
"help": "The game's text and menus: the disc's own English, or the European release's French, German or Italian, which the USA disc also carries.",
|
||||
"choices": [
|
||||
{ "label": "English", "set": { "game/language": "en" } },
|
||||
{ "label": "Français", "set": { "game/language": "fr" } },
|
||||
{ "label": "Deutsch", "set": { "game/language": "de" } },
|
||||
{ "label": "Italiano", "set": { "game/language": "it" } }
|
||||
],
|
||||
"defaults": { "game/language": "en" }
|
||||
},
|
||||
{
|
||||
"id": "mode", "label": "Display mode",
|
||||
"choices": [
|
||||
{ "label": "Windowed", "set": { "video/mode": "windowed" } },
|
||||
{ "label": "Borderless", "set": { "video/mode": "borderless" } },
|
||||
{ "label": "Full screen", "set": { "video/mode": "fullscreen" } }
|
||||
],
|
||||
"defaults": { "video/mode": "windowed" }
|
||||
},
|
||||
{
|
||||
"id": "widescreen", "label": "Widescreen",
|
||||
"help": "16:9 with more of the scene at the sides; menus and pictures stay centred.",
|
||||
"choices": [
|
||||
{ "label": "Off (4:3)", "set": { "video/widescreen": "off" } },
|
||||
{ "label": "On (16:9)", "set": { "video/widescreen": "on" } }
|
||||
],
|
||||
"defaults": { "video/widescreen": "off" }
|
||||
},
|
||||
{
|
||||
"id": "frame_rate", "label": "Frame rate",
|
||||
"help": "Above 60, frames between the game's are drawn in between; the game itself still runs at its own speed.",
|
||||
"choices": [
|
||||
{ "label": "60 (the game's)", "set": { "video/frame_rate": "game" } },
|
||||
{ "label": "Monitor's refresh", "set": { "video/frame_rate": "monitor" } },
|
||||
{ "label": "120", "set": { "video/frame_rate": "120" } },
|
||||
{ "label": "144", "set": { "video/frame_rate": "144" } },
|
||||
{ "label": "240", "set": { "video/frame_rate": "240" } }
|
||||
],
|
||||
"defaults": { "video/frame_rate": "game" }
|
||||
},
|
||||
{
|
||||
"id": "render_scale", "label": "Render scale",
|
||||
"help": "The 3D drawn at this many times the window's size.",
|
||||
"choices": [
|
||||
{ "label": "1x", "set": { "video/render_scale": "1" } },
|
||||
{ "label": "1.5x", "set": { "video/render_scale": "1.5" } },
|
||||
{ "label": "2x", "set": { "video/render_scale": "2" } },
|
||||
{ "label": "3x", "set": { "video/render_scale": "3" } },
|
||||
{ "label": "4x", "set": { "video/render_scale": "4" } }
|
||||
],
|
||||
"defaults": { "video/render_scale": "1" }
|
||||
},
|
||||
{
|
||||
"id": "anti_aliasing", "label": "Anti-aliasing",
|
||||
"help": "Smooths the edges of the 3D (MSAA).",
|
||||
"choices": [
|
||||
{ "label": "Off", "set": { "video/anti_aliasing": "off" } },
|
||||
{ "label": "2x", "set": { "video/anti_aliasing": "2x" } },
|
||||
{ "label": "4x", "set": { "video/anti_aliasing": "4x" } },
|
||||
{ "label": "8x", "set": { "video/anti_aliasing": "8x" } }
|
||||
],
|
||||
"defaults": { "video/anti_aliasing": "off" }
|
||||
},
|
||||
{
|
||||
"id": "texture_smoothing", "label": "Texture smoothing",
|
||||
"help": "Off samples textures as the PS2 does; the others stop distant textures shimmering.",
|
||||
"choices": [
|
||||
{ "label": "Off", "set": { "video/texture_smoothing": "off" } },
|
||||
{ "label": "Trilinear", "set": { "video/texture_smoothing": "trilinear" } },
|
||||
{ "label": "4x anisotropic", "set": { "video/texture_smoothing": "4x" } },
|
||||
{ "label": "8x anisotropic", "set": { "video/texture_smoothing": "8x" } },
|
||||
{ "label": "16x anisotropic", "set": { "video/texture_smoothing": "16x" } }
|
||||
],
|
||||
"defaults": { "video/texture_smoothing": "off" }
|
||||
},
|
||||
{
|
||||
"id": "pause_in_background", "label": "Pause in the background", "advanced": true,
|
||||
"help": "Holds the game while another window has the focus.",
|
||||
"choices": [
|
||||
{ "label": "Off", "set": { "video/pause_in_background": "off" } },
|
||||
{ "label": "On", "set": { "video/pause_in_background": "on" } }
|
||||
],
|
||||
"defaults": { "video/pause_in_background": "off" }
|
||||
},
|
||||
{
|
||||
"id": "fast_forward", "label": "Fast-forward speed", "advanced": true,
|
||||
"help": "The game's speed while fast forward is held (` on the keyboard, or the touchpad).",
|
||||
"choices": [
|
||||
{ "label": "2x", "set": { "video/fast_forward": "2x" } },
|
||||
{ "label": "3x", "set": { "video/fast_forward": "3x" } },
|
||||
{ "label": "5x", "set": { "video/fast_forward": "5x" } },
|
||||
{ "label": "10x", "set": { "video/fast_forward": "10x" } },
|
||||
{ "label": "Unlimited", "set": { "video/fast_forward": "unlimited" } }
|
||||
],
|
||||
"defaults": { "video/fast_forward": "3x" }
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{ "id": "logs", "label": "Logs", "help": "The game's logs, for a bug report.", "open": "logs" }
|
||||
],
|
||||
"looks": { "graphics": "opengl" },
|
||||
"system": { "windows": { "version": "10", "graphics": { "opengl": "3.3" } } }
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// text buffers, menu-table extensions, save-format changes or console packets.
|
||||
#include "dc_ingame_cheats.h"
|
||||
#include "dc_cheats.h"
|
||||
#include "dc_language.h"
|
||||
#include "dc_warp.h"
|
||||
#include "bozo/port.h"
|
||||
#include "bozo/runtime.h"
|
||||
@@ -14,6 +15,7 @@
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
@@ -28,7 +30,7 @@ constexpr uint32_t kPhase=0x1da8a50,kFade=0x1da8a54,kLoaded=0x1da8ac4,kPad=0x1cb
|
||||
constexpr uint32_t kUp=0x1000,kDown=0x4000,kLeft=0x8000,kRight=0x2000,kCross=0x40,kCircle=0x20;
|
||||
constexpr uint32_t kL1=4,kR1=8,kL2=1,kR2=2;
|
||||
constexpr float identity[16]={1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};
|
||||
enum class Page { Root, Game, Graphics, Cheats, Quit, Travel }; // Travel last: saved states keep their values
|
||||
enum class Page { Root, Game, Graphics, Cheats, Quit, Travel, Language }; // new pages last: saved states keep their values
|
||||
struct Menu {
|
||||
bool active=false,queued=false;
|
||||
Page page=Page::Root;
|
||||
@@ -40,9 +42,14 @@ struct Menu {
|
||||
bozo::app::video::Settings graphics;
|
||||
const char *graphicsStatus="";
|
||||
} menu;
|
||||
constexpr int rootCount=5;
|
||||
const char *const rootLabels[rootCount]={"Game Options","Graphics","Cheats","Travel","Quit Game"};
|
||||
const Page rootPages[rootCount]={Page::Game,Page::Graphics,Page::Cheats,Page::Travel,Page::Quit};
|
||||
constexpr int rootCount=6;
|
||||
const char *const rootLabels[rootCount]={"Game Options","Graphics","Cheats","Travel","Language","Quit Game"};
|
||||
const Page rootPages[rootCount]={Page::Game,Page::Graphics,Page::Cheats,Page::Travel,Page::Language,Page::Quit};
|
||||
// Language: game.ini's choice (dc_language.h), read by the game when it starts; the page saves it for the next start
|
||||
// (what the game has loaded stays in the language it started in). Not in save states: it is set again on opening.
|
||||
std::filesystem::path languageFile; // set by the windowed build before the game thread starts; empty: unavailable
|
||||
struct LanguagePage { int row=0; const language::Choice *running=nullptr,*saved=nullptr; const char *status=""; } languagePage;
|
||||
const char *const languageLabels[]={"English","Francais","Deutsch","Italiano"}; // the menu font is ASCII
|
||||
enum GraphicsRow { Display, Resolution, RenderScale, FrameRate, Widescreen, AntiAliasing, Smoothing, ApplyGraphics, GraphicsRowEnd };
|
||||
constexpr int antiAliasings[]={0,2,4,8},smoothings[]={0,1,2,4,8,16};
|
||||
constexpr float renderScales[]={0.5f,0.75f,1.f,1.5f,2.f};
|
||||
@@ -268,16 +275,30 @@ void travelKey(uint32_t pressed)
|
||||
else if(travel.row==World){dc::warp::requestWorld();travel.note="Queued: opened when play resumes";}
|
||||
else if(travel.row==Advance){dc::warp::requestChapter(travel.chapter);travel.note="Queued: applied when play resumes";}
|
||||
}
|
||||
void drawLanguage(std::vector<bozo::render::Vertex> &v,uint32_t white,uint32_t gold,uint32_t dim)
|
||||
{
|
||||
const auto &list=language::choices();
|
||||
for(int i=0;i<int(list.size());++i){
|
||||
const float y=130.f+i*34;const auto c=i==languagePage.row?gold:white;
|
||||
text(v,languageLabels[i],164,y,1.5f,c);if(i==languagePage.row)text(v,">",132,y,1.5f,c);
|
||||
const char *note=&list[i]==languagePage.running?"in use":&list[i]==languagePage.saved?"next start":"";
|
||||
text(v,note,526-float(std::strlen(note))*10,y+4,1.25f,dim);
|
||||
}
|
||||
text(v,"Text and menus change when the game",128,282,1,white);
|
||||
text(v,"starts again. Spanish is incomplete on disc.",128,300,1,white);
|
||||
const char *help=languageFile.empty()?"Needs the game window; O: Back":*languagePage.status?languagePage.status:"X: Choose for the next start O: Back";
|
||||
text(v,help,112,354,1,white);
|
||||
}
|
||||
void drawPage(int alpha)
|
||||
{
|
||||
if(prepareScene)prepareScene();panel(alpha);
|
||||
std::vector<bozo::render::Vertex> v;
|
||||
const uint32_t white=colour(0x808080,alpha),gold=colour(0x207080,alpha),dim=colour(0x484848,alpha);
|
||||
const auto heading=menu.page==Page::Root?"OPTIONS":menu.page==Page::Quit?"QUIT GAME?":menu.page==Page::Graphics?"GRAPHICS":
|
||||
menu.page==Page::Travel?"TRAVEL":"CHEATS";
|
||||
menu.page==Page::Travel?"TRAVEL":menu.page==Page::Language?"LANGUAGE":"CHEATS";
|
||||
text(v,heading,320-float(std::strlen(heading))*8,76,2,gold);
|
||||
if(menu.page==Page::Root){
|
||||
for(int i=0;i<rootCount;++i){const float y=126.f+i*40;const auto c=i==menu.root?gold:white;text(v,rootLabels[i],164,y,1.5f,c);if(i==menu.root)text(v,">",132,y,1.5f,c);}
|
||||
for(int i=0;i<rootCount;++i){const float y=120.f+i*36;const auto c=i==menu.root?gold:white;text(v,rootLabels[i],164,y,1.5f,c);if(i==menu.root)text(v,">",132,y,1.5f,c);}
|
||||
text(v,"D-pad: Select X: Open O: Back",120,352,1,white);
|
||||
}else if(menu.page==Page::Quit){
|
||||
text(v,"Close the game?",200,150,1.5f,white);
|
||||
@@ -289,6 +310,8 @@ void drawPage(int alpha)
|
||||
drawGraphics(v,white,gold,dim);
|
||||
}else if(menu.page==Page::Travel){
|
||||
drawTravel(v,white,gold,dim);
|
||||
}else if(menu.page==Page::Language){
|
||||
drawLanguage(v,white,gold,dim);
|
||||
}else{
|
||||
const char *labels[]={"Infinite health","Weapon durability","Infinite thirst","Combo stamina",
|
||||
"Equipped weapon ATK","Apply weapon ATK","Weapon ABS multiplier","Gilda","Apply Gilda",
|
||||
@@ -357,6 +380,14 @@ void init(uint8_t *r,R5900Context *c,Runtime *rt)
|
||||
refreshPlayer(r,c);menu={};menu.active=true;menu.font=fontFromGame(r);if(!menu.font)menu.page=Page::Game;
|
||||
originalInit(r,c,rt);
|
||||
}
|
||||
void openLanguage(const uint8_t *r)
|
||||
{
|
||||
languagePage={};languagePage.running=language::current(r);
|
||||
languagePage.saved=languageFile.empty()?nullptr:language::find(language::readIni(languageFile));
|
||||
if(!languagePage.saved)languagePage.saved=languagePage.running;
|
||||
const auto &list=language::choices();
|
||||
for(int i=0;i<int(list.size());++i)if(&list[i]==languagePage.saved)languagePage.row=i;
|
||||
}
|
||||
void exit(uint8_t *r,R5900Context *c,Runtime *rt){applyPlayerEdits(r,c);menu={};originalExit(r,c,rt);}
|
||||
void key(uint8_t *r,R5900Context *c,Runtime *rt)
|
||||
{
|
||||
@@ -367,7 +398,7 @@ void key(uint8_t *r,R5900Context *c,Runtime *rt)
|
||||
return;
|
||||
}
|
||||
if(pressed&kCircle){
|
||||
if(menu.page==Page::Cheats || menu.page==Page::Graphics || menu.page==Page::Quit || menu.page==Page::Travel){menu.page=Page::Root;menu.held=menu.ticks=0;done(c);}
|
||||
if(menu.page==Page::Cheats || menu.page==Page::Graphics || menu.page==Page::Quit || menu.page==Page::Travel || menu.page==Page::Language){menu.page=Page::Root;menu.held=menu.ticks=0;done(c);}
|
||||
else {
|
||||
// The original Circle boundary starts this fade. Do not also run
|
||||
// hidden Game Options navigation if Circle and a direction coincide.
|
||||
@@ -378,7 +409,8 @@ void key(uint8_t *r,R5900Context *c,Runtime *rt)
|
||||
if(menu.page==Page::Root){
|
||||
if(pressed&kUp)menu.root=(menu.root+rootCount-1)%rootCount;else if(pressed&kDown)menu.root=(menu.root+1)%rootCount;
|
||||
if(pressed&kCross){menu.page=rootPages[menu.root];travel.note="";
|
||||
menu.graphics=windowSettings().applied;menu.graphicsRow=0;menu.graphicsStatus="";menu.quitChoice=0;menu.held=menu.ticks=0;menu.attack=std::max(0,equippedWeaponAttack());menu.gold=std::max(0,gilda());menu.capacity=std::clamp(inventorySize(),1,100);menu.quantity=std::max(1,activeConsumable(menu.slot).quantity);menu.queued=false;}
|
||||
menu.graphics=windowSettings().applied;menu.graphicsRow=0;menu.graphicsStatus="";menu.quitChoice=0;menu.held=menu.ticks=0;menu.attack=std::max(0,equippedWeaponAttack());menu.gold=std::max(0,gilda());menu.capacity=std::clamp(inventorySize(),1,100);menu.quantity=std::max(1,activeConsumable(menu.slot).quantity);menu.queued=false;
|
||||
if(menu.page==Page::Language)openLanguage(r);}
|
||||
}else if(menu.page==Page::Graphics){
|
||||
const video::Shared shared=windowSettings();
|
||||
if(shared.open){
|
||||
@@ -394,6 +426,17 @@ void key(uint8_t *r,R5900Context *c,Runtime *rt)
|
||||
}
|
||||
}else if(menu.page==Page::Travel){
|
||||
travelKey(pressed);
|
||||
}else if(menu.page==Page::Language){
|
||||
const int count=int(language::choices().size());
|
||||
if(pressed&kUp)languagePage.row=(languagePage.row+count-1)%count;else if(pressed&kDown)languagePage.row=(languagePage.row+1)%count;
|
||||
if(pressed&(kUp|kDown))languagePage.status="";
|
||||
if((pressed&kCross) && !languageFile.empty()){
|
||||
const language::Choice &choice=language::choices()[languagePage.row];
|
||||
if(language::writeIni(languageFile,choice)){
|
||||
languagePage.saved=&choice;
|
||||
languagePage.status=&choice==languagePage.running?"Saved; already in use":"Saved; restart the game to apply";
|
||||
}else languagePage.status="Could not save game.ini";
|
||||
}
|
||||
}else if(menu.page==Page::Quit){
|
||||
if(pressed&(kUp|kDown|kLeft|kRight))menu.quitChoice^=1;
|
||||
if(pressed&kCross){if(menu.quitChoice)quitRequested.store(true,std::memory_order_relaxed);else menu.page=Page::Root;}
|
||||
@@ -473,8 +516,10 @@ void menuState(bozo::state::Archive &a,const uint8_t *ram)
|
||||
if(!a.loading())return;
|
||||
menu.font=menu.active?fontFromGame(ram):nullptr;
|
||||
menu.graphicsStatus="";
|
||||
if(menu.active && menu.page==Page::Language)openLanguage(ram);
|
||||
quitRequested.store(false,std::memory_order_relaxed);
|
||||
}
|
||||
void setLanguageFile(const std::filesystem::path &file){languageFile=file;}
|
||||
void setGraphicsAccess(bozo::app::video::Shared (*shared)(),void (*post)(const bozo::app::video::Settings &,bool))
|
||||
{videoPost.store(post,std::memory_order_release);videoShared.store(shared,std::memory_order_release);}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "bozo/app/video_settings.h"
|
||||
#include <filesystem>
|
||||
struct Runtime;
|
||||
namespace bozo::port { class Registry; }
|
||||
namespace bozo::state { class Archive; }
|
||||
@@ -11,6 +12,9 @@ namespace dc::cheats {
|
||||
// The windowed build, before the game thread starts: the window's settings for the Graphics page (without them,
|
||||
// as headless, the page says they are unavailable).
|
||||
void setGraphicsAccess(bozo::app::video::Shared (*shared)(), void (*post)(const bozo::app::video::Settings &, bool));
|
||||
// The windowed build, before the game thread starts: game.ini, where the Language page saves the choice for the
|
||||
// next start (without it, as headless, the page says it needs the game window).
|
||||
void setLanguageFile(const std::filesystem::path &gameIni);
|
||||
// Save states: the native Options pages' state; on load the font is decoded again from `ram`.
|
||||
void menuState(bozo::state::Archive &, const uint8_t *ram);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "dc_language.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace dc::language
|
||||
{
|
||||
const std::vector<Choice> &choices()
|
||||
{
|
||||
static const std::vector<Choice> list = {
|
||||
{"en", "English", 1}, {"fr", "Fran\xC3\xA7" "ais", 3}, {"de", "Deutsch", 4}, {"it", "Italiano", 5}};
|
||||
return list;
|
||||
}
|
||||
|
||||
const Choice *find(const std::string &key)
|
||||
{
|
||||
std::string k = key;
|
||||
std::transform(k.begin(), k.end(), k.begin(), [](unsigned char c) { return char(std::tolower(c)); });
|
||||
for (const Choice &c : choices())
|
||||
if (k == c.key)
|
||||
return &c;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string readIni(const std::filesystem::path &file)
|
||||
{
|
||||
std::ifstream in(file);
|
||||
std::string line, value;
|
||||
auto trim = [](std::string s)
|
||||
{
|
||||
const size_t first = s.find_first_not_of(" \t\r");
|
||||
return first == std::string::npos ? std::string() : s.substr(first, s.find_last_not_of(" \t\r") - first + 1);
|
||||
};
|
||||
while (std::getline(in, line))
|
||||
{
|
||||
line = trim(line.substr(0, line.find_first_of("#;")));
|
||||
const size_t equal = line.find('=');
|
||||
if (line.empty() || line.front() == '[' || equal == std::string::npos)
|
||||
continue;
|
||||
if (trim(line.substr(0, equal)) == "language")
|
||||
value = trim(line.substr(equal + 1));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool writeIni(const std::filesystem::path &file, const Choice &choice)
|
||||
{
|
||||
const std::filesystem::path tmp = file.string() + ".tmp";
|
||||
{
|
||||
std::ofstream out(tmp, std::ios::binary | std::ios::trunc);
|
||||
out << "# Dark Cloud's own settings (the launcher and RecompLauncher write this file; the game reads it when it starts).\n"
|
||||
"# language: en (English), fr (French), de (German) or it (Italian), from the disc's own text and menus.\n"
|
||||
"\n[game]\nlanguage = "
|
||||
<< choice.key << "\n";
|
||||
if (!out)
|
||||
return false;
|
||||
}
|
||||
std::error_code ec;
|
||||
std::filesystem::rename(tmp, file, ec);
|
||||
return !ec;
|
||||
}
|
||||
|
||||
const Choice *current(const uint8_t *ram)
|
||||
{
|
||||
uint32_t code = 0;
|
||||
std::memcpy(&code, ram + kLanguageCode, sizeof(code));
|
||||
for (const Choice &c : choices())
|
||||
if (c.code == code)
|
||||
return &c;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void apply(uint8_t *ram, const Choice &choice)
|
||||
{
|
||||
std::memcpy(ram + kLanguageCode, &choice.code, sizeof(choice.code));
|
||||
}
|
||||
} // namespace dc::language
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
// The game's language. The USA disc carries the European release's French, German and Italian text and menus next
|
||||
// to the English ones (message files <name>_<n>.mes, menu folders commenu/a_<lang>), and its program still has the
|
||||
// European language code: LanguageCode (0x2A1E88, 1 on the USA disc) picks the files when the game loads them. The
|
||||
// port sets it at boot from --language or <user folder>/game.ini. Spanish (6) is not offered: the USA disc lacks 42
|
||||
// of its 90 story text files.
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace dc::language
|
||||
{
|
||||
constexpr uint32_t kLanguageCode = 0x2A1E88;
|
||||
|
||||
struct Choice
|
||||
{
|
||||
const char *key; // in game.ini and --language
|
||||
const char *name; // in its own language
|
||||
uint32_t code; // LanguageCode
|
||||
};
|
||||
const std::vector<Choice> &choices(); // English (1), French (3), German (4), Italian (5)
|
||||
|
||||
// A choice by key ("en", "fr", "de", "it"; any case), or nullptr.
|
||||
const Choice *find(const std::string &key);
|
||||
|
||||
// game.ini's "language" value: name = value lines, '#' and ';' start comments, [sections] are skipped; "" when the
|
||||
// file or the key is missing.
|
||||
std::string readIni(const std::filesystem::path &file);
|
||||
|
||||
// Writes game.ini with that language (as the launcher writes it); false when it cannot.
|
||||
bool writeIni(const std::filesystem::path &file, const Choice &choice);
|
||||
|
||||
// The choice LanguageCode in guest memory holds, or nullptr (Spanish, or a code no choice has).
|
||||
const Choice *current(const uint8_t *ram);
|
||||
|
||||
// The game's language for its next loads: LanguageCode in guest memory (before the first frame).
|
||||
void apply(uint8_t *ram, const Choice &choice);
|
||||
} // namespace dc::language
|
||||
+38
-2
@@ -6,6 +6,7 @@
|
||||
#include "dc_functions.h"
|
||||
#include "dc_cheats.h"
|
||||
#include "dc_ingame_cheats.h"
|
||||
#include "dc_language.h"
|
||||
#include "dc_pad.h"
|
||||
#include "dc_state.h"
|
||||
#include "dc_warp.h"
|
||||
@@ -46,6 +47,10 @@ int main(int argc, char **argv)
|
||||
#ifdef DC_WITH_WINDOW
|
||||
window = true;
|
||||
bozo::app::setIdentity({"Dark Cloud", "DC_Recomp", "dc-recomp", "SCUS_971.11"});
|
||||
// What the game prints goes on to its console or pipe as before, and also into <user folder>/logs/<name>.log (the
|
||||
// launcher's "Open game logs", RecompLauncher's Logs); a crash writes <user folder>/crashes/crash-<time>.txt.
|
||||
bozo::app::startLogging();
|
||||
bozo::app::installCrashHandler();
|
||||
bozo::app::WindowOptions windowOptions;
|
||||
windowOptions.title = "Dark Cloud - BozoEngine";
|
||||
windowOptions.width = 960;
|
||||
@@ -55,7 +60,7 @@ int main(int argc, char **argv)
|
||||
options.iso = DC_DEFAULT_ISO;
|
||||
options.frames = window ? 0 : 120;
|
||||
options.printGameOutput = true;
|
||||
std::string wav, livePad, assetDir, dumpRam;
|
||||
std::string wav, livePad, assetDir, dumpRam, language; // language: --language, else game.ini's
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
const std::string a = argv[i];
|
||||
@@ -77,6 +82,8 @@ int main(int argc, char **argv)
|
||||
options.iso = argv[++i];
|
||||
else if (a == "--wav" && i + 1 < argc)
|
||||
wav = argv[++i];
|
||||
else if (a == "--language" && i + 1 < argc) // en, fr, de, it (dc_language.h)
|
||||
language = argv[++i];
|
||||
else if (a == "--headless")
|
||||
window = false;
|
||||
else if (a == "--profile-io")
|
||||
@@ -114,7 +121,7 @@ int main(int argc, char **argv)
|
||||
" [--out FILE] [--capture-dir DIR] [--capture-frame N] [--profile-io]\n"
|
||||
" [--fullscreen] [--hidden] [--mute] [--no-vsync] [--dump-ram FILE]\n"
|
||||
" [--load-state FILE [--load-state-at FRAME]] [--save-state FILE --save-state-at FRAME]\n"
|
||||
" [--cheat-script FILE]\n");
|
||||
" [--cheat-script FILE] [--language en|fr|de|it]\n");
|
||||
return a == "--help" ? 0 : 2;
|
||||
}
|
||||
}
|
||||
@@ -164,6 +171,33 @@ int main(int argc, char **argv)
|
||||
d.runtime().functions.addModule(0x1dabd00, 0x1f00000, d.runtime().memory.ram() + 0x1dabd00, std::move(id),
|
||||
table, count, resume, resumes);
|
||||
};
|
||||
// The game's language (dc_language.h): --language, else <user folder>/game.ini (the launcher's and RecompLauncher's
|
||||
// Game language), else English. The program is in memory now and has not run: its first file loads use it.
|
||||
bool languageFromIni = false;
|
||||
#ifdef DC_WITH_WINDOW
|
||||
if (language.empty() && window && !bozo::app::userDirectory().empty())
|
||||
{
|
||||
language = dc::language::readIni(bozo::app::userDirectory() / "game.ini");
|
||||
languageFromIni = !language.empty();
|
||||
}
|
||||
#endif
|
||||
if (!language.empty())
|
||||
{
|
||||
const dc::language::Choice *choice = dc::language::find(language);
|
||||
if (!choice && !languageFromIni)
|
||||
{
|
||||
std::fprintf(stderr, "--language %s: not one of en, fr, de, it\n", language.c_str());
|
||||
return 2;
|
||||
}
|
||||
if (!choice)
|
||||
std::fprintf(stderr, "[dc] game.ini: language '%s' is not one of en, fr, de, it; English\n", language.c_str());
|
||||
else
|
||||
{
|
||||
dc::language::apply(d.runtime().memory.ram(), *choice);
|
||||
if (choice->code != 1)
|
||||
std::printf("[dc] language: %s (%s)\n", choice->name, choice->key);
|
||||
}
|
||||
}
|
||||
module("title", title_function_table, title_function_count, title_resume_table, title_resume_count);
|
||||
module("dun", dun_function_table, dun_function_count, dun_resume_table, dun_resume_count);
|
||||
bozo::app::FramePacer pacer;
|
||||
@@ -292,6 +326,8 @@ int main(int argc, char **argv)
|
||||
windowOptions.videoSettings = true;
|
||||
bozo::app::video::offerWidescreen(true); // the Video tab's Widescreen (see the frame hook)
|
||||
dc::cheats::setGraphicsAccess(&bozo::app::video::shared, &bozo::app::video::post);
|
||||
if (!bozo::app::userDirectory().empty()) // Options -> Language saves game.ini for the next start
|
||||
dc::cheats::setLanguageFile(bozo::app::userDirectory() / "game.ini");
|
||||
bozo::app::Game game;
|
||||
game.run = run;
|
||||
game.stop = [&] { host.requestStop(); };
|
||||
|
||||
@@ -5470,6 +5470,8 @@ namespace dc::native
|
||||
}
|
||||
|
||||
void setWidescreen(bool on) { g_wideRequest.store(on, std::memory_order_relaxed); }
|
||||
// CFrameVu1::DrawVu1's culling bound (runtime/dc_port.cpp): the drawn frame's half width, 320 or 426.67.
|
||||
float modelCullHalfWidth() { return frameW() / 2.0f; }
|
||||
|
||||
std::string unsaveable()
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace dc::native
|
||||
void publish();
|
||||
void fishLineVertex(uint8_t *, R5900Context *, Runtime *);
|
||||
void debugFontBoundary(uint8_t *, R5900Context *, Runtime *, uint32_t);
|
||||
float modelCullHalfWidth();
|
||||
} // namespace dc::native
|
||||
namespace dc
|
||||
{
|
||||
@@ -32,6 +33,16 @@ namespace dc
|
||||
ctx->r[4].ud[0] = 0x100008Cu;
|
||||
return true;
|
||||
}
|
||||
// CFrameVu1::DrawVu1's model culling, lui v0,0x43a0 (320.0, the frame's half width): the half width of the
|
||||
// frame drawn, wider in widescreen, so models on its wider sides are not skipped.
|
||||
if (pc == 0x00129AB4u || pc == 0x00129AE4u)
|
||||
{
|
||||
const float half = dc::native::modelCullHalfWidth();
|
||||
uint32_t bits;
|
||||
std::memcpy(&bits, &half, 4);
|
||||
ctx->r[2].ud[0] = bits;
|
||||
return true;
|
||||
}
|
||||
if (pc == 0x0013DFA8u || pc == 0x0013DFF0u || pc == 0x0013E314u || pc == 0x0013E420u)
|
||||
{
|
||||
dc::native::debugFontBoundary(ram, ctx, rt, pc);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
# Takes and releases are announced in the c2c f2f lane when the local hook build/announce.sh exists (not committed:
|
||||
# it holds the room connection).
|
||||
source "$(dirname "$0")/common.sh"
|
||||
# The lock tool comes with the pinned BozoEngine release (fetched once into BozoEngine/).
|
||||
[ -f "$ROOT/BozoEngine/tools/bench_lock.sh" ] || cmake -P "$ROOT/cmake/bozo_engine_fetch.cmake" >&2
|
||||
source "$ROOT/BozoEngine/tools/bench_lock.sh"
|
||||
[ -x "$ROOT/build/announce.sh" ] && export PS2X_BENCH_LOCK_ANNOUNCE="$ROOT/build/announce.sh"
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ source "$(dirname "$0")/common.sh"
|
||||
# The lock tool is not written for common.sh's set -euo pipefail: its checks return false while it waits (two-slot
|
||||
# version, main c3524b7), which ended this script silently before the command ran.
|
||||
set +euo pipefail
|
||||
# The lock tool comes with the pinned BozoEngine release (fetched once into BozoEngine/).
|
||||
[ -f "$ROOT/BozoEngine/tools/bench_lock.sh" ] || cmake -P "$ROOT/cmake/bozo_engine_fetch.cmake" >&2
|
||||
source "$ROOT/BozoEngine/tools/bench_lock.sh"
|
||||
[ -x "$ROOT/build/announce.sh" ] && export PS2X_BENCH_LOCK_ANNOUNCE="$ROOT/build/announce.sh"
|
||||
alone=""
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build BozoEngine's static recompiler and native-library binder.
|
||||
source "$(dirname "$0")/common.sh"
|
||||
cmake -S "$ROOT/BozoEngine" -B "$TOOLS_BUILD" -G Ninja -DCMAKE_BUILD_TYPE=Release -DBOZO_BUILD_TOOLS=OFF "$@"
|
||||
fetch_engine
|
||||
cmake -S "$ENGINE" -B "$TOOLS_BUILD" -G Ninja -DCMAKE_BUILD_TYPE=Release -DBOZO_BUILD_TOOLS=OFF "$@"
|
||||
cmake --build "$TOOLS_BUILD" --target bozo-recomp bozo-externals -j "$JOBS"
|
||||
@@ -19,6 +19,13 @@ if [ -z "${TMP:-}" ] || [ -z "${TEMP:-}" ]; then
|
||||
export TMP="$ROOT/build/tmp" TEMP="$ROOT/build/tmp"
|
||||
fi
|
||||
|
||||
# BozoEngine: BOZO_ENGINE_DIR (a checkout, for engine work not released yet), else the release cmake/bozo_engine.json
|
||||
# pins, fetched into BozoEngine/ (nothing is downloaded while BozoEngine/.release matches the pin).
|
||||
ENGINE="${BOZO_ENGINE_DIR:-$ROOT/BozoEngine}"
|
||||
fetch_engine() {
|
||||
[ -n "${BOZO_ENGINE_DIR:-}" ] || cmake -P "$ROOT/cmake/bozo_engine_fetch.cmake"
|
||||
}
|
||||
|
||||
configure_game() {
|
||||
cmake -S "$ROOT" -B "$GAME_BUILD" -G Ninja -DCMAKE_BUILD_TYPE="${BUILD_TYPE:-Release}" "$@"
|
||||
}
|
||||
@@ -3,7 +3,8 @@ source "$(dirname "$0")/common.sh"
|
||||
mkdir -p "$ROOT/build"
|
||||
extra=()
|
||||
[ ! -f "$GAME_BUILD/dc_gen/dc.elf" ] || extra+=("-DBOZO_TEST_ELF=$GAME_BUILD/dc_gen/dc.elf")
|
||||
cmake -S "$ROOT/BozoEngine" -B "$TOOLS_BUILD" -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
fetch_engine
|
||||
cmake -S "$ENGINE" -B "$TOOLS_BUILD" -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_TESTING=ON -DBOZO_BUILD_TOOLS=OFF "${extra[@]}" "$@"
|
||||
cmake --build "$TOOLS_BUILD" -j "$JOBS"
|
||||
ctest --test-dir "$TOOLS_BUILD" --output-on-failure
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "../runtime/dc_ingame_cheats.h"
|
||||
#include "../runtime/dc_cheats.h"
|
||||
#include "../runtime/dc_warp.h"
|
||||
#include "../runtime/dc_language.h"
|
||||
#include <filesystem>
|
||||
#include "bozo/port.h"
|
||||
#include "bozo/runtime.h"
|
||||
#include "bozo/render/renderer.h"
|
||||
@@ -147,6 +149,21 @@ int main(){
|
||||
check(postCalls==2 && posted.mode==video::WindowMode::Borderless && posted.width==1280 && posted.height==960,
|
||||
"Borderless keeps the window size it returns to");
|
||||
const int exitsBefore=exitCalls;tap(*rt,p,0x20);tap(*rt,p,0x20);finishFade(*rt,p);check(exitCalls==exitsBefore+1,"Options still closes after Graphics");
|
||||
// Language: the fifth entry. Without game.ini's place (headless) it only explains; with it, Cross saves the choice
|
||||
// for the next start and leaves the running game's LanguageCode alone.
|
||||
write<uint32_t>(r,dc::language::kLanguageCode,1);
|
||||
call(*rt,p,initPc);finishFade(*rt,p);for(int i=0;i<4;++i)tap(*rt,p,0x4000);tap(*rt,p,0x40); // Root -> Language
|
||||
tap(*rt,p,0x4000);tap(*rt,p,0x40);draw(*rt,p);const auto noFile=bozo::render::Renderer::instance().published();
|
||||
check(noFile && noFile->batches.size()>=2,"Language without game.ini's place draws its notice");
|
||||
const auto ini=std::filesystem::temp_directory_path()/"dc_menu_language_test.ini";std::filesystem::remove(ini);
|
||||
dc::cheats::setLanguageFile(ini);tap(*rt,p,0x20);tap(*rt,p,0x40); // back to Root, Language again: opens on English
|
||||
tap(*rt,p,0x4000);tap(*rt,p,0x40); // Francais
|
||||
check(dc::language::readIni(ini)=="fr","Cross on Francais saves language = fr");
|
||||
check(read<uint32_t>(r,dc::language::kLanguageCode)==1,"the running game keeps its language until it starts again");
|
||||
tap(*rt,p,0x20);tap(*rt,p,0x40); // reopened: the cursor is on the saved choice
|
||||
tap(*rt,p,0x4000);tap(*rt,p,0x40);check(dc::language::readIni(ini)=="de","the page opens on the saved choice (Down from Francais is Deutsch)");
|
||||
draw(*rt,p);const auto langPage=bozo::render::Renderer::instance().published();check(langPage && langPage->batches.size()>=2,"Language page draws native text and board");
|
||||
tap(*rt,p,0x20);tap(*rt,p,0x20);finishFade(*rt,p);std::filesystem::remove(ini);dc::cheats::setLanguageFile({});
|
||||
std::memset(r+record+8,0,32);call(*rt,p,initPc);finishFade(*rt,p);const int fallback=drawCalls;draw(*rt,p);
|
||||
check(drawCalls==fallback+1,"missing font falls back to original Options without trapping input");
|
||||
for(int i=0;i<4;++i)dc::cheats::setEnabled(static_cast<dc::cheats::Cheat>(i),false);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// The game's language setting (dc_language.h): the choices, game.ini's reading and LanguageCode in guest memory.
|
||||
#include "dc_language.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
int failures = 0;
|
||||
void check(bool ok, const char *what)
|
||||
{
|
||||
if (!ok)
|
||||
{
|
||||
++failures;
|
||||
std::printf("FAIL: %s\n", what);
|
||||
}
|
||||
}
|
||||
std::string iniWith(const std::filesystem::path &file, const char *text)
|
||||
{
|
||||
std::ofstream(file, std::ios::binary | std::ios::trunc) << text;
|
||||
return dc::language::readIni(file);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char **argv)
|
||||
{
|
||||
using namespace dc::language;
|
||||
check(choices().size() == 4, "four languages");
|
||||
check(find("en") && find("en")->code == 1, "English is the USA disc's own code 1");
|
||||
check(find("fr") && find("fr")->code == 3, "French 3");
|
||||
check(find("DE") && find("DE")->code == 4, "German 4, any case");
|
||||
check(find("it") && find("it")->code == 5, "Italian 5");
|
||||
check(!find("es") && !find("") && !find("jp") && !find("english"), "Spanish and anything else refused");
|
||||
|
||||
const auto file = std::filesystem::path(argv[0]).parent_path() / "dc_language_test.ini";
|
||||
check(iniWith(file, "# Dark Cloud\n[game]\nlanguage = fr\n") == "fr", "section and comment skipped");
|
||||
check(iniWith(file, "[game]\r\n language=it ; Italiano\r\n") == "it", "CRLF, spaces and a trailing comment");
|
||||
check(iniWith(file, "[game]\nlanguages = de\nlang = de\n") == "", "only the language key");
|
||||
check(iniWith(file, "# language = de\n") == "", "a commented line");
|
||||
std::filesystem::remove(file);
|
||||
check(readIni(file) == "", "no file");
|
||||
|
||||
std::vector<uint8_t> ram(32u << 20, 0);
|
||||
const uint32_t usa = 1;
|
||||
std::memcpy(ram.data() + kLanguageCode, &usa, 4);
|
||||
apply(ram.data(), *find("de"));
|
||||
uint32_t code = 0;
|
||||
std::memcpy(&code, ram.data() + kLanguageCode, 4);
|
||||
check(code == 4, "LanguageCode written");
|
||||
check(ram[kLanguageCode - 1] == 0 && ram[kLanguageCode + 4] == 0, "nothing around it");
|
||||
|
||||
std::printf("%s (%d failures)\n", failures ? "FAILED" : "dc_language: all checks passed", failures);
|
||||
return failures ? 1 : 0;
|
||||
}
|
||||
@@ -6,9 +6,16 @@ get_filename_component(DC_ROOT "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
|
||||
set(BOZO_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
||||
set(BOZO_APP OFF CACHE BOOL "" FORCE)
|
||||
include(CTest)
|
||||
add_subdirectory("${DC_ROOT}/BozoEngine" engine)
|
||||
# BozoEngine: the pinned release (cmake/bozo_engine.json, fetched into BozoEngine/), or BOZO_ENGINE_DIR (a checkout).
|
||||
set(BOZO_ENGINE_DIR "" CACHE PATH "BozoEngine's source tree (default: the pinned release, in BozoEngine/)")
|
||||
if(NOT BOZO_ENGINE_DIR)
|
||||
include("${DC_ROOT}/cmake/bozo_engine_fetch.cmake")
|
||||
set(BOZO_ENGINE_DIR "${bozo_engine_tree}")
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${DC_ROOT}/cmake/bozo_engine.json")
|
||||
endif()
|
||||
add_subdirectory("${BOZO_ENGINE_DIR}" engine)
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory("${DC_ROOT}/BozoEngine/tests" engine_tests)
|
||||
add_subdirectory("${BOZO_ENGINE_DIR}/tests" engine_tests)
|
||||
add_executable(dc-model-lifetime-tests "${DC_ROOT}/tests/dc_model_lifetime_tests.cpp" "${DC_ROOT}/runtime/dc_native.cpp")
|
||||
target_link_libraries(dc-model-lifetime-tests PRIVATE bozo_host)
|
||||
target_compile_definitions(dc-model-lifetime-tests PRIVATE DC_DEFAULT_TEXTURES="")
|
||||
|
||||
+289
-7
@@ -1,5 +1,9 @@
|
||||
"""Player-facing migration and timing regression checks; no game data required."""
|
||||
import configparser
|
||||
import contextlib
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import io
|
||||
@@ -11,6 +15,7 @@ from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools'))
|
||||
import apply_update
|
||||
import make_release
|
||||
import make_build_kit
|
||||
import dc_build
|
||||
@@ -18,7 +23,7 @@ from unittest.mock import patch
|
||||
from types import SimpleNamespace
|
||||
|
||||
REQUIRED = (
|
||||
'DC Launcher.exe', 'README.txt', 'CHANGELOG.md', 'LICENSES/TMB_Recomp/LICENSE',
|
||||
'DC Launcher.exe', 'README.txt', 'CHANGELOG.md', 'recomplauncher.json', 'LICENSES/TMB_Recomp/LICENSE',
|
||||
'LICENSES/BozoEngine/LICENSE', 'LICENSES/DC_Recomp/LICENSE', 'source/VERSION', 'source/release.ini', 'kit/kit_manifest.json',
|
||||
'kit/python/python.exe', 'source/tools/dc_build.py', 'source/BozoEngine/CMakeLists.txt',
|
||||
'kit/deps/sdl3-src/CMakeLists.txt', 'kit/deps/imgui-src/imgui.cpp',
|
||||
@@ -129,11 +134,115 @@ class ReleaseTests(unittest.TestCase):
|
||||
self.assertTrue((root / 'tools/linked').exists())
|
||||
|
||||
|
||||
def test_only_native_engine_is_a_submodule(self):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(ROOT / '.gitmodules')
|
||||
self.assertEqual(config.sections(), ['submodule "BozoEngine"'])
|
||||
self.assertEqual(config[config.sections()[0]]['path'], 'BozoEngine')
|
||||
@staticmethod
|
||||
def release_source(folder, files):
|
||||
"""A release's source folder: the files, dated as an unzip of the release zip dates them, and its listing."""
|
||||
root = Path(folder) / 'source'
|
||||
for name, data in files.items():
|
||||
(root / name).parent.mkdir(parents=True, exist_ok=True)
|
||||
(root / name).write_bytes(data)
|
||||
(root / 'release_files.txt').write_text(''.join(n + '\n' for n in sorted(files)) + 'release_files.txt\n',
|
||||
encoding='utf-8')
|
||||
return root
|
||||
|
||||
@staticmethod
|
||||
def date(root, ns):
|
||||
for p in root.rglob('*'):
|
||||
if p.is_file():
|
||||
os.utime(p, ns=(ns, ns))
|
||||
|
||||
def settle(self, root, out, now, kit=None):
|
||||
with patch.object(dc_build, 'ROOT', str(root)), contextlib.redirect_stdout(io.StringIO()):
|
||||
dc_build.settle_source_times(str(out), kit, now_ns=now)
|
||||
|
||||
def test_source_dated_in_the_future_is_dated_now(self):
|
||||
# Issue 60: the zip's commit time, read as local time west of UTC, is hours ahead; ninja then never settles.
|
||||
now = 1_800_000_000 * 10**9
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = self.release_source(folder, {'CMakeLists.txt': b'project', 'runtime/a.cpp': b'a'})
|
||||
kit = Path(folder) / 'kit'
|
||||
(kit / 'deps/sdl3-src').mkdir(parents=True)
|
||||
(kit / 'deps/sdl3-src/CMakeLists.txt').write_bytes(b'sdl')
|
||||
module = kit / 'ucrt64/share/cmake/Modules/FindPython.cmake' # build.ninja's input too
|
||||
module.parent.mkdir(parents=True)
|
||||
module.write_bytes(b'module')
|
||||
self.date(root, now + 3 * 3600 * 10**9)
|
||||
self.date(kit, now + 3 * 3600 * 10**9)
|
||||
out = Path(folder) / 'build'
|
||||
out.mkdir()
|
||||
self.settle(root, out, now, str(kit))
|
||||
for p in (root / 'CMakeLists.txt', root / 'runtime/a.cpp', kit / 'deps/sdl3-src/CMakeLists.txt', module):
|
||||
self.assertEqual(p.stat().st_mtime_ns, now)
|
||||
record = json.loads((out / dc_build.SOURCE_TIMES).read_text(encoding='utf-8'))
|
||||
self.assertIn('source/runtime/a.cpp', record)
|
||||
self.assertIn('deps/sdl3-src/CMakeLists.txt', record)
|
||||
|
||||
def test_first_build_keeps_past_times(self):
|
||||
now = 1_800_000_000 * 10**9
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = self.release_source(folder, {'runtime/a.cpp': b'a'})
|
||||
self.date(root, now - 10**12)
|
||||
out = Path(folder) / 'build'
|
||||
out.mkdir()
|
||||
self.settle(root, out, now)
|
||||
self.assertEqual((root / 'runtime/a.cpp').stat().st_mtime_ns, now - 10**12)
|
||||
|
||||
def test_update_dates_changed_files_now_and_restores_unchanged_ones(self):
|
||||
# An update unzipped over a game built after the update's commit: its files are older than the build's.
|
||||
built, commit, now = 1_800_000_000 * 10**9, 1_799_990_000 * 10**9, 1_800_100_000 * 10**9
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = self.release_source(folder, {'runtime/same.cpp': b'same', 'runtime/fixed.cpp': b'old'})
|
||||
self.date(root, built - 10**12)
|
||||
out = Path(folder) / 'build'
|
||||
out.mkdir()
|
||||
self.settle(root, out, built)
|
||||
(root / 'runtime/fixed.cpp').write_bytes(b'new')
|
||||
(root / 'runtime/added.cpp').write_bytes(b'added')
|
||||
with open(root / 'release_files.txt', 'a', encoding='utf-8') as f:
|
||||
f.write('runtime/added.cpp\n')
|
||||
self.date(root, commit)
|
||||
self.settle(root, out, now)
|
||||
self.assertEqual((root / 'runtime/same.cpp').stat().st_mtime_ns, built - 10**12)
|
||||
self.assertEqual((root / 'runtime/fixed.cpp').stat().st_mtime_ns, now)
|
||||
self.assertEqual((root / 'runtime/added.cpp').stat().st_mtime_ns, now)
|
||||
|
||||
def test_update_without_a_record_over_a_build_rebuilds_everything(self):
|
||||
# 0.5.1 and earlier wrote no record: an update over their build cannot tell what changed.
|
||||
commit, now = 1_799_990_000 * 10**9, 1_800_100_000 * 10**9
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = self.release_source(folder, {'runtime/a.cpp': b'a'})
|
||||
self.date(root, commit)
|
||||
out = Path(folder) / 'build'
|
||||
(out / 'build').mkdir(parents=True)
|
||||
(out / 'build/build.ninja').write_bytes(b'')
|
||||
self.settle(root, out, now)
|
||||
self.assertEqual((root / 'runtime/a.cpp').stat().st_mtime_ns, now)
|
||||
|
||||
def test_checkout_is_left_alone(self):
|
||||
now = 1_800_000_000 * 10**9
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = Path(folder) / 'source'
|
||||
root.mkdir()
|
||||
(root / 'CMakeLists.txt').write_bytes(b'project')
|
||||
os.utime(root / 'CMakeLists.txt', ns=(now + 10**12, now + 10**12))
|
||||
self.settle(root, Path(folder), now)
|
||||
self.assertEqual((root / 'CMakeLists.txt').stat().st_mtime_ns, now + 10**12)
|
||||
self.assertFalse((Path(folder) / dc_build.SOURCE_TIMES).exists())
|
||||
|
||||
|
||||
def test_engine_is_a_pinned_release(self):
|
||||
# BozoEngine comes from its releases (cmake/bozo_engine.json, fetched by cmake/bozo_engine_fetch.cmake), no
|
||||
# longer from a submodule.
|
||||
self.assertFalse((ROOT / '.gitmodules').exists())
|
||||
pin = json.loads((ROOT / 'cmake/bozo_engine.json').read_text(encoding='utf-8'))
|
||||
self.assertRegex(pin['version'], r'^[0-9]+\.[0-9]+\.[0-9]+$')
|
||||
self.assertRegex(pin['sha256'], r'^[0-9a-f]{64}$')
|
||||
fetch = (ROOT / 'cmake/bozo_engine_fetch.cmake').read_text(encoding='utf-8')
|
||||
self.assertIn('EXPECTED_HASH SHA256=${bozo_engine_sha256}', fetch)
|
||||
self.assertIn('TLS_VERIFY ON', fetch)
|
||||
self.assertIn('/BozoEngine/', (ROOT / '.gitignore').read_text(encoding='utf-8').splitlines())
|
||||
for cmake in ('CMakeLists.txt', 'launcher/CMakeLists.txt', 'tests/native_lifetime/CMakeLists.txt'):
|
||||
self.assertIn('bozo_engine_fetch.cmake', (ROOT / cmake).read_text(encoding='utf-8'), cmake)
|
||||
|
||||
|
||||
def test_release_rejects_game_executables(self):
|
||||
@@ -231,4 +340,177 @@ class CleanEnvironmentTests(unittest.TestCase):
|
||||
self.assertNotIn('MSYSTEM',env)
|
||||
self.assertNotIn('msys64',env['PATH'])
|
||||
|
||||
|
||||
class ApplyUpdateTests(unittest.TestCase):
|
||||
"""tools/apply_update.py, which the launcher's Update button runs from the installed source (launcher/src/main.cpp)."""
|
||||
|
||||
def release_zip(self, folder, version, extra=()):
|
||||
path = Path(folder) / ('DC_Recomp-%s-bozo.zip' % version)
|
||||
with zipfile.ZipFile(path, 'w') as archive:
|
||||
archive.writestr('DC_Recomp_Bozo/DC Launcher.exe', b'launcher ' + version.encode())
|
||||
archive.writestr('DC_Recomp_Bozo/source/release.ini', 'version = %s\ncommit = abc\n' % version)
|
||||
archive.writestr('DC_Recomp_Bozo/source/runtime/a.cpp', b'new code')
|
||||
for name, data in extra:
|
||||
archive.writestr(name, data)
|
||||
sha = Path(str(path) + '.sha256')
|
||||
sha.write_text('%s *%s\n' % (hashlib.sha256(path.read_bytes()).hexdigest(), path.name), encoding='utf-8')
|
||||
return path, sha
|
||||
|
||||
def apply(self, zip_path, sha, version, install):
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
apply_update.main(['--zip', str(zip_path), '--sha256', str(sha), '--version', version, '--install', str(install)])
|
||||
return out.getvalue().splitlines()
|
||||
|
||||
def test_the_launcher_runs_it_from_the_installed_source(self):
|
||||
main_cpp = (ROOT / 'launcher/src/main.cpp').read_text(encoding='utf-8')
|
||||
self.assertIn('L"tools" / L"apply_update.py"', main_cpp)
|
||||
self.assertTrue((ROOT / 'tools/apply_update.py').is_file())
|
||||
self.assertIn('"%s"' % apply_update.ASIDE, main_cpp)
|
||||
self.assertEqual(apply_update.TOP, make_release.TOP + '/')
|
||||
|
||||
def test_update_installs_over_the_release_and_keeps_player_folders(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
install = Path(folder) / 'install'
|
||||
for name, data in (('DC Launcher.exe', b'old'), ('source/runtime/a.cpp', b'old code'),
|
||||
('build/dc_build_state.json', b'{}'), ('game/dc.exe', b'game')):
|
||||
(install / name).parent.mkdir(parents=True, exist_ok=True)
|
||||
(install / name).write_bytes(data)
|
||||
(install / 'update').mkdir()
|
||||
zip_path, sha = self.release_zip(install / 'update', '9.9.9')
|
||||
lines = self.apply(zip_path, sha, '9.9.9', install)
|
||||
self.assertEqual(lines[-1], 'done 9.9.9')
|
||||
self.assertEqual((install / 'DC Launcher.exe').read_bytes(), b'launcher 9.9.9')
|
||||
self.assertEqual((install / 'source/runtime/a.cpp').read_bytes(), b'new code')
|
||||
self.assertEqual((install / 'game/dc.exe').read_bytes(), b'game')
|
||||
self.assertEqual((install / 'build/dc_build_state.json').read_bytes(), b'{}')
|
||||
self.assertFalse(zip_path.exists())
|
||||
self.assertFalse((install / 'update/staging').exists())
|
||||
|
||||
def test_damaged_wrong_or_unsafe_zips_install_nothing(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
install = Path(folder) / 'install'
|
||||
install.mkdir()
|
||||
zip_path, sha = self.release_zip(folder, '9.9.9')
|
||||
with self.assertRaisesRegex(apply_update.UpdateError, 'not \'9.9.8\''):
|
||||
self.apply(zip_path, sha, '9.9.8', install)
|
||||
sha.write_text('0' * 64 + '\n', encoding='utf-8')
|
||||
with self.assertRaisesRegex(apply_update.UpdateError, 'damaged'):
|
||||
self.apply(zip_path, sha, '9.9.9', install)
|
||||
for bad in ('DC_Recomp_Bozo/game/dc.exe', 'DC_Recomp_Bozo/../escape.txt', 'Other/file.txt'):
|
||||
with tempfile.TemporaryDirectory() as sub:
|
||||
zip_path, sha = self.release_zip(sub, '9.9.9', [(bad, b'x')])
|
||||
with self.assertRaises(apply_update.UpdateError):
|
||||
self.apply(zip_path, sha, '9.9.9', install)
|
||||
self.assertEqual(sorted(p.name for p in install.rglob('*') if p.is_file()), [])
|
||||
|
||||
class RecompLauncherTests(unittest.TestCase):
|
||||
"""recomplauncher.json (RecompLauncher's manifest, recomplauncher.com/sdk) and what it runs."""
|
||||
|
||||
def manifest(self):
|
||||
return json.loads((ROOT / 'recomplauncher.json').read_text(encoding='utf-8'))
|
||||
|
||||
def test_progress_lines_follow_the_steps(self):
|
||||
self.assertEqual(dc_build.progress_line(('PROGRESS', 'verify', '1/8', 'Checking the disc')),
|
||||
'progress 0.000 Checking the disc')
|
||||
before = sum(dc_build.STEP_WEIGHTS[s] for s in dc_build.STEPS[:dc_build.STEPS.index('packs')])
|
||||
half = (before + dc_build.STEP_WEIGHTS['packs'] / 2) / sum(dc_build.STEP_WEIGHTS.values())
|
||||
self.assertEqual(dc_build.progress_line(('PERCENT', 'packs', 50)),
|
||||
'progress %.3f Converting textures (50%%)' % half)
|
||||
for other in (('SKIP', 'verify', '1/8'), ('DONE', 'stage', '8/8', 1.0), ('INFO', 'total', '1 s'),
|
||||
('ERROR', 'compile', 'x')):
|
||||
self.assertIsNone(dc_build.progress_line(other))
|
||||
self.assertEqual(set(dc_build.STEP_WEIGHTS), set(dc_build.STEPS))
|
||||
shares = []
|
||||
for step in dc_build.STEPS:
|
||||
for parts in (('PROGRESS', step, '', ''), ('PERCENT', step, 37), ('PERCENT', step, 100)):
|
||||
shares.append(float(dc_build.progress_line(parts).split()[1]))
|
||||
self.assertEqual(shares, sorted(shares))
|
||||
self.assertTrue(0 <= shares[0] and shares[-1] < 1)
|
||||
|
||||
def test_a_missing_disc_says_why_and_an_earlier_build_keeps_one(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
def run(*extra):
|
||||
return subprocess.run([sys.executable, '-I', '-X', 'utf8', str(ROOT / 'tools' / 'dc_build.py'),
|
||||
'--out', str(Path(folder) / 'build'), '--game', str(Path(folder) / 'game')]
|
||||
+ list(extra), capture_output=True, text=True, encoding='utf-8')
|
||||
r = run('--progress-lines')
|
||||
self.assertEqual(r.returncode, 1)
|
||||
self.assertIn('ERROR verify no disc image given', r.stdout.strip().splitlines()[-1])
|
||||
# No --disc: the disc image an earlier build kept in the game folder (keeps_copy). Here it is not a disc.
|
||||
(Path(folder) / 'game').mkdir()
|
||||
(Path(folder) / 'game' / 'disc.iso').write_bytes(b'\0' * 65536)
|
||||
r = run('--check')
|
||||
self.assertEqual(r.returncode, 1)
|
||||
self.assertIn('ERROR verify disc.iso', r.stdout)
|
||||
|
||||
def test_manifest_runs_what_the_release_ships(self):
|
||||
m = self.manifest()
|
||||
self.assertEqual(m['format'], 1)
|
||||
disc = m['inputs'][0]
|
||||
self.assertEqual(disc['id'], 'game')
|
||||
self.assertEqual(disc['check']['iso9660'], dc_build.ELF_NAME)
|
||||
self.assertEqual(disc['check']['ids'], ['SCUS-97111'])
|
||||
# Redump's Dark Cloud (USA), SCUS-97111 v1.02: its one dump, a DVD-5 (redump.org/disc/5435).
|
||||
self.assertEqual(disc['dumps'], [{'name': 'USA', 'size': 1797980160, 'crc32': 'fe4adb70'}])
|
||||
prepare, start = m['prepare'], m['start']
|
||||
self.assertEqual(prepare['program'], ['kit/python/python.exe'])
|
||||
self.assertIn('kit/python/python.exe', REQUIRED)
|
||||
self.assertIn('{install}/source/tools/dc_build.py', prepare['args'])
|
||||
self.assertIn('source/tools/dc_build.py', REQUIRED)
|
||||
# The disc as one argument: RecompLauncher leaves it out when the player's copy is gone (keeps_copy).
|
||||
self.assertTrue(prepare['keeps_copy'])
|
||||
self.assertEqual([a for a in prepare['args'] if '{input:game}' in a], ['--disc={input:game}'])
|
||||
help_text = subprocess.run([sys.executable, '-I', str(ROOT / 'tools' / 'dc_build.py'), '--help'],
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
for flag in (a.split('=', 1)[0] for a in prepare['args'] if a.startswith('--')):
|
||||
self.assertIn(flag, help_text)
|
||||
self.assertIn('--progress-lines', prepare['args'])
|
||||
self.assertEqual(prepare['done'], ['{install}/game/built_from.ini'])
|
||||
self.assertEqual(start['program'], ['game/' + dc_build.GAME_EXE + '.exe'])
|
||||
self.assertEqual(start['args'], ['--elf', '{install}/game/' + dc_build.ELF_NAME, '--iso', '{install}/game/disc.iso'])
|
||||
# Everything the game writes (cards, settings, logs, save states) in RecompLauncher's {data}.
|
||||
self.assertEqual(start['env'], {'PS2X_USER_DIR': '{data}'})
|
||||
self.assertEqual(m['saves'], ['{data}/mc0', '{data}/mc1'])
|
||||
|
||||
def test_settings_are_keys_the_game_reads(self):
|
||||
m = self.manifest()
|
||||
self.assertEqual(m['config'], [{'format': 'ini', 'file': [{'path': '{data}/video.ini'}]},
|
||||
{'id': 'game', 'format': 'ini', 'file': [{'path': '{data}/game.ini'}]}])
|
||||
source = (ROOT / 'BozoEngine' / 'runtime' / 'app' / 'video_settings.cpp').read_text(encoding='utf-8')
|
||||
written = set(re.findall(r'<< "([a-z_]+) = "', source))
|
||||
self.assertIn('widescreen', written)
|
||||
# game.ini (the game's language): the keys runtime/dc_language.cpp reads, the values it accepts.
|
||||
language = (ROOT / 'runtime' / 'dc_language.cpp').read_text(encoding='utf-8')
|
||||
self.assertIn('"language"', language)
|
||||
accepted = set(re.findall(r'\{"([a-z]{2})", "', language))
|
||||
self.assertEqual(accepted, {'en', 'fr', 'de', 'it'})
|
||||
ids = [s['id'] for s in m['settings']]
|
||||
self.assertEqual(len(ids), len(set(ids)))
|
||||
for setting in m['settings']:
|
||||
keys = set(setting['defaults'])
|
||||
for choice in setting['choices']:
|
||||
self.assertEqual(set(choice['set']), keys, setting['id'])
|
||||
for key in keys:
|
||||
section, name = key.split('/')
|
||||
if setting.get('in') == 'game':
|
||||
self.assertEqual(key, 'game/language')
|
||||
self.assertTrue({c['set'][key] for c in setting['choices']} <= accepted)
|
||||
continue
|
||||
self.assertNotIn('in', setting)
|
||||
self.assertEqual(section, 'video')
|
||||
self.assertIn(name, written)
|
||||
values = [c['set'][k] for c in setting['choices'] for k in keys]
|
||||
self.assertEqual(len(values), len(set(values)), setting['id'])
|
||||
self.assertIn(setting['defaults'], [c['set'] for c in setting['choices']], setting['id'])
|
||||
|
||||
def test_release_zip_carries_the_manifest_at_its_top(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
path = Path(folder) / 'no_manifest.zip'
|
||||
with zipfile.ZipFile(path, 'w') as archive:
|
||||
for name in REQUIRED:
|
||||
if name != 'recomplauncher.json':
|
||||
archive.writestr('DC_Recomp_Bozo/' + name, b'fixture')
|
||||
self.assertIn('DC_Recomp_Bozo/recomplauncher.json is missing', make_release.verify_zip(path))
|
||||
|
||||
if __name__ == '__main__': unittest.main()
|
||||
@@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env python3
|
||||
# Adapted from The Bozos TMB_Recomp (MIT); see launcher/LICENSE for original attribution.
|
||||
"""apply_update: installs a downloaded release over this one, for the launcher's Update button.
|
||||
|
||||
python -I tools/apply_update.py --zip <DC_Recomp-x.y.z-bozo.zip> --sha256 <its .sha256 file> --version x.y.z
|
||||
--install <the release folder> [--keep-zip]
|
||||
|
||||
Checks the zip's SHA-256 against the release's .sha256, checks every name in it (one top folder DC_Recomp_Bozo/, no
|
||||
absolute or parent paths, nothing under build/, game/ or update/, the launcher and source/release.ini of the version
|
||||
asked for), extracts it whole to <install>/update/staging, and only then moves its files over the release folder.
|
||||
A file in use (the launcher that started this, the kit's Python running it) is renamed to <name>.dc-old first, as
|
||||
Windows lets a running program's file be renamed but not replaced; those are listed in update/old_files.txt for the
|
||||
launcher to delete at its next start. The player's own folders (build/, game/) and saves (%APPDATA%) are never
|
||||
touched; dc_build removes the source files a release no longer has (source/release_files.txt). The files are written
|
||||
now, so they are newer than the player's last build.
|
||||
|
||||
Prints one line per event for the launcher: "step <verify|extract|install|clean>", "progress <done> <total>" (bytes),
|
||||
"done <version>", or "error <message>" (exit code 1).
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
TOP = 'DC_Recomp_Bozo/' # tools/make_release.py's TOP
|
||||
LAUNCHER = 'DC Launcher.exe'
|
||||
PROTECTED = ('build/', 'game/', 'update/') # the player's build and game, and this update's own folder
|
||||
ASIDE = '.dc-old' # the launcher deletes only these (launcher/src/main.cpp, cleanUpdateLeftovers)
|
||||
|
||||
|
||||
class UpdateError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def say(*parts):
|
||||
print(*parts, flush=True)
|
||||
|
||||
|
||||
def sha256_of(path):
|
||||
h = hashlib.sha256()
|
||||
total = os.path.getsize(path)
|
||||
done = 0
|
||||
with open(path, 'rb') as f:
|
||||
for block in iter(lambda: f.read(1 << 20), b''):
|
||||
h.update(block)
|
||||
done += len(block)
|
||||
if done % (16 << 20) < (1 << 20):
|
||||
say('progress', done, total)
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
def expected_sha256(path):
|
||||
with open(path, 'r', encoding='utf-8', errors='replace') as f:
|
||||
token = f.read().split()
|
||||
if not token or len(token[0]) != 64 or any(c not in '0123456789abcdefABCDEF' for c in token[0]):
|
||||
raise UpdateError('the .sha256 file does not hold a SHA-256')
|
||||
return token[0].lower()
|
||||
|
||||
|
||||
def checked_names(zf, version):
|
||||
"""The zip's file entries as (entry, path under the top folder), after checking every name."""
|
||||
files = []
|
||||
for info in zf.infolist():
|
||||
name = info.filename
|
||||
if not name.startswith(TOP) or '\\' in name or ':' in name or name.startswith('/'):
|
||||
raise UpdateError('unexpected name in the zip: %r' % name)
|
||||
rel = name[len(TOP):]
|
||||
if any(part in ('..', '.') for part in rel.split('/')):
|
||||
raise UpdateError('unexpected name in the zip: %r' % name)
|
||||
if rel.startswith(PROTECTED) or rel.rstrip('/') in ('build', 'game', 'update'):
|
||||
raise UpdateError('the zip holds %r, a folder of the player\'s own' % name)
|
||||
if not name.endswith('/'):
|
||||
files.append((info, rel))
|
||||
rels = {rel for _info, rel in files}
|
||||
if LAUNCHER not in rels or 'source/release.ini' not in rels:
|
||||
raise UpdateError('this is not a DC_Recomp release (no launcher or source/release.ini)')
|
||||
stamp = zf.read(TOP + 'source/release.ini').decode('utf-8', 'replace')
|
||||
found = ''
|
||||
for line in stamp.splitlines():
|
||||
key, _, value = line.partition('=')
|
||||
if key.strip() == 'version':
|
||||
found = value.strip()
|
||||
if found != version:
|
||||
raise UpdateError('the zip is version %r, not %r' % (found, version))
|
||||
return files
|
||||
|
||||
|
||||
def remove_tree(path):
|
||||
def onerror(func, p, _exc):
|
||||
os.chmod(p, 0o666)
|
||||
func(p)
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path, onerror=onerror)
|
||||
|
||||
|
||||
def replace(src, dst, old_files):
|
||||
"""Moves src over dst; a dst in use is renamed aside first (<dst>.dc-old, or .dc-old2... if that one is too)."""
|
||||
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||
try:
|
||||
os.replace(src, dst)
|
||||
return
|
||||
except PermissionError:
|
||||
pass
|
||||
for n in range(1, 100):
|
||||
aside = dst + (ASIDE if n == 1 else '%s%d' % (ASIDE, n))
|
||||
try:
|
||||
if os.path.exists(aside):
|
||||
os.remove(aside)
|
||||
os.rename(dst, aside)
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
else:
|
||||
raise UpdateError('%s is in use and could not be set aside' % dst)
|
||||
old_files.append(aside)
|
||||
os.replace(src, dst)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('--zip', required=True)
|
||||
ap.add_argument('--sha256', required=True)
|
||||
ap.add_argument('--version', required=True)
|
||||
ap.add_argument('--install', required=True)
|
||||
ap.add_argument('--keep-zip', action='store_true')
|
||||
args = ap.parse_args(argv)
|
||||
install = os.path.abspath(args.install)
|
||||
work = os.path.join(install, 'update')
|
||||
staging = os.path.join(work, 'staging')
|
||||
|
||||
say('step verify')
|
||||
want = expected_sha256(args.sha256)
|
||||
got = sha256_of(args.zip)
|
||||
if got != want:
|
||||
raise UpdateError('the download is damaged (SHA-256 %s, expected %s): try again' % (got, want))
|
||||
|
||||
say('step extract')
|
||||
remove_tree(staging)
|
||||
with zipfile.ZipFile(args.zip) as zf:
|
||||
files = checked_names(zf, args.version)
|
||||
total = sum(info.file_size for info, _rel in files)
|
||||
if shutil.disk_usage(install).free < total + (256 << 20):
|
||||
raise UpdateError('not enough free space: %d MB needed' % ((total >> 20) + 256))
|
||||
done = 0
|
||||
for info, rel in files:
|
||||
target = os.path.join(staging, *rel.split('/'))
|
||||
os.makedirs(os.path.dirname(target), exist_ok=True)
|
||||
with zf.open(info) as src, open(target, 'wb') as dst:
|
||||
shutil.copyfileobj(src, dst, 1 << 20)
|
||||
done += info.file_size
|
||||
say('progress', done, total)
|
||||
|
||||
# Everything is extracted and checked: only moves on the same disk from here.
|
||||
say('step install')
|
||||
old_files = []
|
||||
for n, (_info, rel) in enumerate(files):
|
||||
replace(os.path.join(staging, *rel.split('/')), os.path.join(install, *rel.split('/')), old_files)
|
||||
if n % 200 == 0:
|
||||
say('progress', n, len(files))
|
||||
say('progress', len(files), len(files))
|
||||
if old_files:
|
||||
with open(os.path.join(work, 'old_files.txt'), 'a', encoding='utf-8') as f:
|
||||
f.write(''.join(path + '\n' for path in old_files))
|
||||
|
||||
say('step clean')
|
||||
remove_tree(staging)
|
||||
if not args.keep_zip:
|
||||
for path in (args.zip, args.sha256):
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError:
|
||||
pass
|
||||
say('done', args.version)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except (UpdateError, OSError, zipfile.BadZipFile) as e:
|
||||
say('error', e)
|
||||
sys.exit(1)
|
||||
@@ -8,7 +8,7 @@ if sys.argv[1]=='--overrides':
|
||||
native_sites=(0x12C19C,0x15434C,0x12D268,0x1AB290,0x13DFA8,0x13DFF0,0x13E314,0x13E420,0x1DF2A0,0x1DC3F4,
|
||||
0x14797C,0x147998,0x147A70,0x147AB4,0x147B10,0x147B24,0x147B48,
|
||||
0x121264,0x121278,0x121334,0x12134C,0x121530,0x121564,
|
||||
0x12C510,0x12C57C) # guarded port boundaries
|
||||
0x12C510,0x12C57C,0x129AB4,0x129AE4) # guarded port boundaries
|
||||
out.write_text(''.join(f'override 0x{x:x}\n' for x in sorted(addresses) if 0x100000 <= x < 0x245300 and x not in native_sites)
|
||||
+ ''.join(f'native 0x{x:x}\n' for x in native_sites))
|
||||
sys.exit(0)
|
||||
|
||||
+141
-7
@@ -11,7 +11,8 @@ No game data or generated game code is distributed. ISO and BIN/CUE use the engi
|
||||
kit/python/python.exe -I -X utf8 source/tools/dc_build.py --disc IMAGE --out build --game game
|
||||
|
||||
The bundled kit builds offline without MSYS2, git or an installed Python. --check validates a disc
|
||||
without building. PROGRESS/PERCENT/SKIP/DONE/ERROR/RESULT lines use the same launcher protocol as TMB.
|
||||
without building. PROGRESS/PERCENT/SKIP/DONE/ERROR/RESULT lines use the same launcher protocol as TMB;
|
||||
--progress-lines adds RecompLauncher's "progress <0 to 1> <text>" (recomplauncher.json at the repo's top).
|
||||
"""
|
||||
import argparse
|
||||
import glob
|
||||
@@ -42,7 +43,7 @@ def configure_gcc_paths(env, compiler_bin):
|
||||
env['GCC_EXEC_PREFIX'] = gcc.replace('\\', '/') + '/'
|
||||
libraries = versions + [os.path.join(prefix, 'x86_64-w64-mingw32', 'lib'), os.path.join(prefix, 'lib')]
|
||||
env['LIBRARY_PATH'] = os.pathsep.join(p.replace('\\', '/') for p in libraries if os.path.isdir(p))
|
||||
ENGINE = os.path.join(ROOT, 'BozoEngine') # --engine replaces it
|
||||
ENGINE = os.path.join(ROOT, 'BozoEngine') # the release cmake/bozo_engine.json pins; --engine replaces it
|
||||
ps2_disc = None # BozoEngine's tools/native_pack/ps2_disc.py, imported by load_engine()
|
||||
|
||||
ELF_NAME = 'SCUS_971.11'
|
||||
@@ -65,19 +66,47 @@ class BuildError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# --progress-lines: RecompLauncher's setup step (recomplauncher.json's prepare) reads "progress <0 to 1> <text>" lines.
|
||||
PROGRESS_LINES = False
|
||||
# Each step's share of the bar: its usual seconds on a first build (launcher/src/build_model.cpp's kSteps).
|
||||
STEP_WEIGHTS = {'verify': 1, 'extract': 2, 'configure': 60, 'tools': 7, 'recompile': 2, 'packs': 280, 'compile': 55,
|
||||
'stage': 1}
|
||||
|
||||
|
||||
def emit(*parts):
|
||||
print(' '.join(str(p) for p in parts), flush=True)
|
||||
if PROGRESS_LINES:
|
||||
line = progress_line(parts)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
|
||||
|
||||
def progress_line(parts):
|
||||
"""RecompLauncher's line for a PROGRESS (a step starts) or PERCENT (it moves on) line, else None: the share of the
|
||||
whole build done, and the step's title (recomplauncher.com/sdk, prepare)."""
|
||||
if len(parts) < 3 or parts[0] not in ('PROGRESS', 'PERCENT') or parts[1] not in STEP_WEIGHTS:
|
||||
return None
|
||||
step = parts[1]
|
||||
pct = int(parts[2]) if parts[0] == 'PERCENT' else 0
|
||||
before = sum(STEP_WEIGHTS[s] for s in STEPS[:STEPS.index(step)])
|
||||
done = (before + STEP_WEIGHTS[step] * min(max(pct, 0), 100) / 100) / sum(STEP_WEIGHTS.values())
|
||||
return 'progress %.3f %s%s' % (min(done, 0.999), STEP_TITLES[step], ' (%d%%)' % pct if parts[0] == 'PERCENT' else '')
|
||||
|
||||
|
||||
def load_engine(path=None):
|
||||
"""BozoEngine's tree (--engine, else the submodule) and its disc reader."""
|
||||
"""BozoEngine's tree (--engine, else the pinned release, fetched in a git checkout) and its disc reader."""
|
||||
global ENGINE, ps2_disc
|
||||
if path:
|
||||
ENGINE = os.path.abspath(path)
|
||||
tools = os.path.join(ENGINE, 'tools', 'native_pack')
|
||||
fetch = os.path.join(ROOT, 'cmake', 'bozo_engine_fetch.cmake')
|
||||
if not path and os.path.exists(os.path.join(ROOT, '.git')) and shutil.which('cmake'):
|
||||
# A checkout follows cmake/bozo_engine.json (nothing is downloaded while BozoEngine/.release matches it). A
|
||||
# release's source has its BozoEngine already (stamped), so a player's build never downloads it.
|
||||
subprocess.run([shutil.which('cmake'), '-P', fetch], stdout=subprocess.DEVNULL, check=False)
|
||||
if not os.path.isfile(os.path.join(tools, 'ps2_disc.py')):
|
||||
raise SystemExit('ERROR verify BozoEngine is missing (%s): the release is incomplete, or in a git checkout run '
|
||||
'"git submodule update --init BozoEngine"' % ENGINE)
|
||||
'"cmake -P cmake/bozo_engine_fetch.cmake"' % ENGINE)
|
||||
sys.path.insert(0, tools)
|
||||
import ps2_disc as module # noqa: E402
|
||||
ps2_disc = module
|
||||
@@ -672,6 +701,7 @@ class Build:
|
||||
redo_from = STEPS.index(self.args.redo) if self.args.redo else len(STEPS)
|
||||
n = len(STEPS)
|
||||
dirty = False
|
||||
ran = False
|
||||
total_start = time.time()
|
||||
for i, step in enumerate(STEPS, 1):
|
||||
self.step = step
|
||||
@@ -684,7 +714,7 @@ class Build:
|
||||
emit('INFO', 'stopped', 'after ' + step)
|
||||
return 0
|
||||
continue
|
||||
dirty = True # every later step runs again (Ninja only redoes what changed)
|
||||
dirty = ran = True # every later step runs again (Ninja only redoes what changed)
|
||||
emit('PROGRESS', step, '%d/%d' % (i, n), STEP_TITLES[step])
|
||||
t = time.time()
|
||||
self.state[step] = {'done': False}
|
||||
@@ -713,6 +743,8 @@ class Build:
|
||||
launcher = os.path.join(self.game, 'Play Dark Cloud.cmd' if os.name == 'nt' else 'play_dc.sh')
|
||||
emit('INFO', 'total', '%.1f s' % (time.time() - total_start))
|
||||
emit('RESULT', self.game, launcher)
|
||||
if PROGRESS_LINES:
|
||||
print('progress 1 %s' % ('Ready to play' if ran else 'Already built'), flush=True)
|
||||
return 0
|
||||
|
||||
|
||||
@@ -775,12 +807,14 @@ def check_disc(path):
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description='Builds Dark Cloud (USA) as a native PC game from your own disc.')
|
||||
ap.add_argument('--disc', required=True, help='the disc image (.iso, .bin, .cue) or an extracted disc folder')
|
||||
ap.add_argument('--disc', help='the disc image (.iso, .bin, .cue) or an extracted disc folder (default: the '
|
||||
'disc.iso an earlier build left in the game folder)')
|
||||
ap.add_argument('--out', default='dc_build', help='the work folder; the game ends up in <out>/DC')
|
||||
ap.add_argument('--game', help='the game folder to stage (default: <out>/DC)')
|
||||
ap.add_argument('--check', action='store_true', help='only check the disc (no work folder): OK <message> or '
|
||||
'ERROR verify <message>')
|
||||
ap.add_argument('--engine', help='BozoEngine\'s source tree (default: the BozoEngine submodule)')
|
||||
ap.add_argument('--engine', help='BozoEngine\'s source tree (default: the release cmake/bozo_engine.json pins, in '
|
||||
'BozoEngine/)')
|
||||
ap.add_argument('--kit', help='the build kit folder (default: <DC_Recomp>/kit or <its parent>/kit if present)')
|
||||
ap.add_argument('--no-kit', action='store_true', help='do not use a build kit even if one is found')
|
||||
ap.add_argument('--toolchain', help='compiler folder (with bin/g++, cmake, ninja), default: the kit, PATH, '
|
||||
@@ -793,13 +827,28 @@ def main():
|
||||
ap.add_argument('--jobs', type=int, default=os.cpu_count() or 4)
|
||||
ap.add_argument('--redo', choices=STEPS, help='run this step and the ones after it again')
|
||||
ap.add_argument('--stop-after', choices=STEPS, help='stop once this step is done')
|
||||
ap.add_argument('--progress-lines', action='store_true', help='also print "progress <0 to 1> <text>" lines, for '
|
||||
'RecompLauncher (recomplauncher.json)')
|
||||
args = ap.parse_args()
|
||||
global PROGRESS_LINES
|
||||
PROGRESS_LINES = args.progress_lines
|
||||
if not args.disc:
|
||||
# Built before: the game folder keeps the disc image (a link to the player's, or a copy), so an update builds
|
||||
# again without it (RecompLauncher's keeps_copy, after the player deleted their own).
|
||||
kept = os.path.join(os.path.abspath(args.game) if args.game else os.path.join(os.path.abspath(args.out), 'DC'),
|
||||
'disc.iso')
|
||||
if not os.path.isfile(kept):
|
||||
emit('ERROR', 'verify', 'no disc image given (--disc) and none kept from an earlier build: pick your Dark '
|
||||
'Cloud disc image (USA, SCUS-97111)')
|
||||
sys.exit(1)
|
||||
args.disc = kept
|
||||
load_engine(args.engine)
|
||||
if args.check:
|
||||
sys.exit(check_disc(args.disc))
|
||||
os.makedirs(os.path.abspath(args.out), exist_ok=True)
|
||||
if not os.environ.get(ALIAS_ENV):
|
||||
remove_stale_sources()
|
||||
settle_source_times(os.path.abspath(args.out), find_kit(args))
|
||||
if needs_ascii_aliases(args):
|
||||
sys.exit(run_through_aliases(args))
|
||||
sys.exit(Build(args).main())
|
||||
@@ -853,6 +902,91 @@ def remove_stale_sources():
|
||||
emit('INFO', 'update', '%d files of an earlier release removed from %s' % (removed, ROOT))
|
||||
|
||||
|
||||
SOURCE_TIMES = 'source_times.json'
|
||||
|
||||
|
||||
def settle_source_times(out, kit, now_ns=None):
|
||||
"""A release zip dates every file at its commit's time (tools/make_release.py), which an unzip takes as local
|
||||
time. Two failures follow for ninja, which only compares times:
|
||||
- dated in the future (unzipped west of UTC within hours of the commit): build.ninja, regenerated, stays older
|
||||
than CMakeLists.txt forever ("manifest 'build.ninja' still dirty after 100 tries");
|
||||
- dated before the player's last build (an update unzipped over a game built after the commit): a changed file
|
||||
looks older than its object and is not compiled again.
|
||||
So the release's source files (release_files.txt) and the kit's FetchContent sources (deps/) are re-dated here,
|
||||
from <out>/source_times.json (each file's size, time and SHA-1 as the last run left them): a file whose content changed,
|
||||
or new to this release, is dated now; one unchanged gets its time back; nothing stays in the future. Without that
|
||||
record and with a build folder from before, every file is dated now: everything is built again, once. The rest of
|
||||
the kit (the toolchain: CMake's own modules are build.ninja's inputs too, the compiler's headers every object's)
|
||||
only comes back from the future. A git checkout (no release_files.txt) is left alone: git dates the files it
|
||||
writes now."""
|
||||
listing = os.path.join(ROOT, 'release_files.txt')
|
||||
if not os.path.isfile(listing):
|
||||
return
|
||||
now = now_ns if now_ns is not None else time.time_ns()
|
||||
future = 0
|
||||
if kit and os.path.isdir(kit):
|
||||
for dirpath, _dirs, names in os.walk(kit):
|
||||
for n in names:
|
||||
p = os.path.join(dirpath, n)
|
||||
try:
|
||||
if os.stat(p).st_mtime_ns > now:
|
||||
os.utime(p, ns=(now, now))
|
||||
future += 1
|
||||
except OSError:
|
||||
pass
|
||||
files = []
|
||||
with open(listing, encoding='utf-8') as f:
|
||||
files += [('source/' + l.strip(), os.path.join(ROOT, *l.strip().split('/'))) for l in f if l.strip()]
|
||||
deps = os.path.join(kit, 'deps') if kit else None
|
||||
if deps and os.path.isdir(deps):
|
||||
for dirpath, dirs, names in os.walk(deps):
|
||||
dirs.sort()
|
||||
for n in sorted(names):
|
||||
p = os.path.join(dirpath, n)
|
||||
files.append(('deps/' + os.path.relpath(p, deps).replace('\\', '/'), p))
|
||||
record_path = os.path.join(out, SOURCE_TIMES)
|
||||
try:
|
||||
with open(record_path, encoding='utf-8') as f:
|
||||
old = json.load(f)
|
||||
if not isinstance(old, dict):
|
||||
old = None
|
||||
except (OSError, ValueError):
|
||||
old = None
|
||||
built_before = os.path.isfile(os.path.join(out, 'build', 'build.ninja'))
|
||||
record, changed = {}, 0
|
||||
for key, path in files:
|
||||
try:
|
||||
st = os.stat(path)
|
||||
except OSError:
|
||||
continue
|
||||
mtime = st.st_mtime_ns
|
||||
rec = old.get(key) if old else None
|
||||
if rec and rec[0] == st.st_size and rec[1] == mtime:
|
||||
digest, target = rec[2], mtime # untouched since the last build
|
||||
else:
|
||||
digest = sha1_file(path)
|
||||
if rec and rec[2] == digest:
|
||||
target = rec[1] # the same content: its time at the last build
|
||||
elif rec or old is not None or built_before:
|
||||
target = now # changed, new to this release, or unknown with a build from before
|
||||
changed += 1
|
||||
else:
|
||||
target = mtime # a first build: nothing to be older than
|
||||
if target > now:
|
||||
target = now
|
||||
future += 1
|
||||
if target != mtime:
|
||||
os.utime(path, ns=(target, target))
|
||||
record[key] = [st.st_size, target, digest]
|
||||
tmp = record_path + '.tmp'
|
||||
with open(tmp, 'w', encoding='utf-8') as f:
|
||||
json.dump(record, f, separators=(',', ':'))
|
||||
os.replace(tmp, record_path)
|
||||
if changed or future:
|
||||
emit('INFO', 'update', '%d source files dated now (%d changed or new, %d were dated in the future)'
|
||||
% (changed + future, changed, future))
|
||||
|
||||
|
||||
# ---- folders whose path is not ASCII (Windows) ----
|
||||
#
|
||||
# MSYS2's binutils open files in the ANSI code page: ld cannot open an object or library whose path, read from the
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
# Adapted from The Bozos TMB_Recomp (MIT); see launcher/LICENSE for original attribution.
|
||||
"""make_build_kit: assembles the build kit tools/dc_build.py uses on a PC with nothing installed (no MSYS2, git,
|
||||
network or Python): a compiler, CMake and Ninja, a minimal static FFmpeg, the libraries' sources (SDL3, Dear ImGui)
|
||||
and an embeddable Python. The game is built on BozoEngine, whose sources come with DC_Recomp's (the BozoEngine
|
||||
submodule, in a release's source/BozoEngine): its recompiler is built on the player's PC with the rest. Run once on the
|
||||
and an embeddable Python. The game is built on BozoEngine, whose sources come with DC_Recomp's (the release
|
||||
cmake/bozo_engine.json pins, in BozoEngine/ and a release's source/BozoEngine): its recompiler is built on the player's
|
||||
PC with the rest. Run once on the
|
||||
developer's PC (MSYS2 UCRT64 installed, network for the downloads); the kit is build output, never committed.
|
||||
|
||||
python tools/make_build_kit.py --out D:/dc_kit/kit [--downloads D:/dc_kit/downloads] [--zip D:/dc_kit/kit.zip]
|
||||
|
||||
+32
-29
@@ -9,9 +9,10 @@ redistributes.
|
||||
python tools/make_release.py --out D:/dc_release --publish --dry-run (the version from the commit's tag)
|
||||
|
||||
What it does, from <commit> (default HEAD; only committed files count, the working tree is never read):
|
||||
export git archive of the commit and of the BozoEngine submodule at the commit it records (without its
|
||||
reference/ records, which the build never reads) -> source\\ (no .git, no build/, nothing generated);
|
||||
source\\release.ini stamps the version and both commits. The tree is audited: no ELF, IRX, disc image,
|
||||
export git archive of the commit -> source\\ (no .git, no build/, nothing generated), and the BozoEngine
|
||||
release its cmake/bozo_engine.json pins -> source\\BozoEngine (cmake/bozo_engine_fetch.cmake: the
|
||||
release's archive, SHA-256 checked); source\\release.ini stamps the version, the commit and the
|
||||
engine's version. The tree is audited: no ELF, IRX, disc image,
|
||||
pack, generated code or disc file name may be in it.
|
||||
kit the build kit (--kit <dir>: an existing one, hard-linked into the release; else assembled by
|
||||
tools/make_build_kit.py, which needs MSYS2 and the network): a BozoEngine kit (kit_version 2: SDL3 and
|
||||
@@ -28,7 +29,8 @@ What it does, from <commit> (default HEAD; only committed files count, the worki
|
||||
changelog CHANGELOG.md's section for the version (## [x.y.z], Keep a Changelog), from the commit: the release
|
||||
refuses to be made without one (an empty one, or only "Unreleased", too) unless
|
||||
--allow-missing-changelog (test builds). CHANGELOG.md is shipped at the zip's top (the launcher's
|
||||
"What's new" reads it) and the section is the release notes' "What's new".
|
||||
"What's new" reads it) and the section is the release notes' "What's new". recomplauncher.json (the
|
||||
commit's) is shipped at the zip's top too, where RecompLauncher reads it.
|
||||
zip DC_Recomp-<version>-bozo.zip (deflate, entries sorted, every timestamp the commit's), <zip>.sha256,
|
||||
RELEASE_NOTES.md (the changelog section, the hashes, the source offer: the GitHub release's body). The
|
||||
zip's names are audited again.
|
||||
@@ -61,13 +63,13 @@ import zipfile
|
||||
ROOT = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
|
||||
REPO = 'TheBozos/DC_Recomp'
|
||||
ENGINE_REPO = 'TheBozos/BozoEngine'
|
||||
ENGINE_DIR = 'BozoEngine' # the submodule
|
||||
# What BozoEngine's export leaves out (its reference records: hashes of recorded runs, never read by the build).
|
||||
ENGINE_SKIP = ('reference',)
|
||||
ENGINE_DIR = 'BozoEngine' # the release cmake/bozo_engine.json pins
|
||||
NAME = 'DC_Recomp'
|
||||
# Canonical player archive and installation folder, matching the TMB launcher workflow.
|
||||
FLAVOR = 'bozo'
|
||||
TOP = 'DC_Recomp_Bozo'
|
||||
# RecompLauncher's manifest (recomplauncher.com/sdk): at the repo's top, shipped at the zip's top.
|
||||
RECOMPLAUNCHER_JSON = 'recomplauncher.json'
|
||||
VERSION_RE = re.compile(r'^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$')
|
||||
MSYS2_SOURCES = 'https://repo.msys2.org/mingw/sources/'
|
||||
# The launcher's font (launcher/CMakeLists.txt pins the same commit and hash).
|
||||
@@ -377,7 +379,7 @@ class Release:
|
||||
self.zip = os.path.join(self.out, self.name + '.zip')
|
||||
self.sources_zip = os.path.join(self.out, self.name + '-sources.zip')
|
||||
self.commit_date = int(git('show', '-s', '--format=%ct', self.commit))
|
||||
self.engine_commit = None
|
||||
self.engine_version = None
|
||||
self.manifest = None
|
||||
self.msys_sources = [] # (package base, version, licence, url, file, sha256)
|
||||
|
||||
@@ -398,21 +400,18 @@ class Release:
|
||||
rmtree(self.stage)
|
||||
os.makedirs(self.source)
|
||||
extract_tar_stream([find_git(), 'archive', '--format=tar', self.commit], self.source, ROOT)
|
||||
entry = git('ls-tree', self.commit, ENGINE_DIR).split()
|
||||
if len(entry) < 3 or entry[0] != '160000':
|
||||
raise ReleaseError('%s is not a submodule at %s' % (ENGINE_DIR, self.commit))
|
||||
self.engine_commit = entry[2]
|
||||
engine_repo = os.path.join(ROOT, ENGINE_DIR)
|
||||
try:
|
||||
git('cat-file', '-e', self.engine_commit + '^{commit}', cwd=engine_repo)
|
||||
except ReleaseError:
|
||||
raise ReleaseError('the submodule does not have %s: git submodule update --init %s'
|
||||
% (self.engine_commit, ENGINE_DIR))
|
||||
engine_dst = os.path.join(self.source, ENGINE_DIR)
|
||||
os.makedirs(engine_dst, exist_ok=True)
|
||||
extract_tar_stream([find_git(), 'archive', '--format=tar', self.engine_commit], engine_dst, engine_repo)
|
||||
for skip in ENGINE_SKIP:
|
||||
rmtree(os.path.join(engine_dst, skip))
|
||||
# The BozoEngine release the commit's cmake/bozo_engine.json pins, fetched into source\BozoEngine with its
|
||||
# .release stamp (the archive SHA-256 checked), so a player's build finds it and never downloads it.
|
||||
with open(os.path.join(self.source, 'cmake', 'bozo_engine.json'), encoding='utf-8') as f:
|
||||
self.engine_version = json.load(f)['version']
|
||||
cmake = shutil.which('cmake')
|
||||
if not cmake and os.path.isfile(os.path.join(self.args.msys, 'ucrt64', 'bin', 'cmake.exe')):
|
||||
cmake = os.path.join(self.args.msys, 'ucrt64', 'bin', 'cmake.exe')
|
||||
if not cmake:
|
||||
raise ReleaseError('no cmake on PATH: it fetches the BozoEngine release (cmake/bozo_engine_fetch.cmake)')
|
||||
os.makedirs(self.downloads, exist_ok=True)
|
||||
run([cmake, '-DBOZO_ENGINE_DOWNLOADS=' + self.downloads, '-P',
|
||||
os.path.join(self.source, 'cmake', 'bozo_engine_fetch.cmake')])
|
||||
# The list of the source's files: dc_build removes the ones a newer release unzipped over this one no longer
|
||||
# has (CMake globs runtime/*.cpp: a deleted file left behind would still be compiled).
|
||||
files = sorted(os.path.relpath(os.path.join(d, n), self.source).replace('\\', '/')
|
||||
@@ -421,14 +420,14 @@ class Release:
|
||||
write_text(os.path.join(self.source, 'release_files.txt'), '\n'.join(sorted(set(files))) + '\n')
|
||||
write_text(os.path.join(self.source, 'release.ini'),
|
||||
'# The DC_Recomp release this folder is (tools/make_release.py writes this file).\n'
|
||||
'version = %s\ncommit = %s\nengine = BozoEngine\nengine_commit = %s\ndate = %s\n'
|
||||
% (self.version, self.commit, self.engine_commit,
|
||||
'version = %s\ncommit = %s\nengine = BozoEngine\nengine_version = %s\ndate = %s\n'
|
||||
% (self.version, self.commit, self.engine_version,
|
||||
time.strftime('%Y-%m-%d', time.gmtime(self.commit_date))))
|
||||
problems = audit_tree(self.source, rel_prefix='source/')
|
||||
if problems:
|
||||
raise ReleaseError('the source export holds what looks like game data:\n ' + '\n '.join(problems[:20]))
|
||||
n = sum(len(f) for _d, _s, f in os.walk(self.source))
|
||||
log(' source: %s + BozoEngine %s, %d files, %.1f MB, audited' % (self.commit[:12], self.engine_commit[:12], n,
|
||||
log(' source: %s + BozoEngine %s, %d files, %.1f MB, audited' % (self.commit[:12], self.engine_version, n,
|
||||
dir_size(self.source) / 1e6))
|
||||
|
||||
# -- the kit
|
||||
@@ -642,7 +641,7 @@ class Release:
|
||||
'DC_Recomp (source\\, this release\'s code; MIT, LICENSES\\DC_Recomp)',
|
||||
' https://github.com/%s/tree/%s' % (REPO, self.commit),
|
||||
'BozoEngine, the recompiler and runtime the game is built on (source\\BozoEngine; MIT, LICENSES\\BozoEngine)',
|
||||
' https://github.com/%s/tree/%s' % (ENGINE_REPO, self.engine_commit),
|
||||
' https://github.com/%s/releases/tag/v%s' % (ENGINE_REPO, self.engine_version),
|
||||
' The whole source is in source\\ already, the launcher\'s too (source\\launcher).',
|
||||
'',
|
||||
'The build kit (kit\\) redistributes these programs and libraries unmodified. Their corresponding source:',
|
||||
@@ -778,6 +777,10 @@ class Release:
|
||||
at = at + 1 if at >= 0 else len(text)
|
||||
text = text[:at] + '## [%s] - test build\n\n%s\n\n' % (self.version, self.changelog_section) + text[at:]
|
||||
write_text(os.path.join(self.stage, 'CHANGELOG.md'), text, crlf=True)
|
||||
# RecompLauncher's manifest at the top, next to the launcher, where RecompLauncher reads it: the commit's.
|
||||
manifest = git('show', '%s:%s' % (self.commit, RECOMPLAUNCHER_JSON), binary=True)
|
||||
with open(os.path.join(self.stage, RECOMPLAUNCHER_JSON), 'wb') as f:
|
||||
f.write(manifest)
|
||||
|
||||
# -- the changelog
|
||||
|
||||
@@ -842,7 +845,7 @@ class Release:
|
||||
'Saves and settings stay in `%APPDATA%\\DC_Recomp`. The launcher offers future updates and rebuilds.',
|
||||
'',
|
||||
'## Build information', '',
|
||||
'- Code: %s (`%s`), BozoEngine `%s`' % (REPO, self.commit, self.engine_commit),
|
||||
'- Code: %s (`%s`), BozoEngine %s' % (REPO, self.commit, self.engine_version),
|
||||
'- Build kit: GCC %s, CMake %s, Ninja %s (MSYS2 UCRT64), FFmpeg %s (LGPL, static), Python %s'
|
||||
% (self.pkg_version('gcc'), self.pkg_version('cmake'), self.pkg_version('ninja'),
|
||||
self.manifest['ffmpeg']['version'], self.manifest['python']['version']),
|
||||
@@ -985,7 +988,7 @@ def verify_zip(path, top=TOP):
|
||||
problems.append('%s: an ELF file' % n)
|
||||
if len(head) >= 0x8006 and head[0x8001:0x8006] == b'CD001':
|
||||
problems.append('%s: an ISO9660 volume' % n)
|
||||
for need in ('DC Launcher.exe', 'README.txt', 'CHANGELOG.md', 'LICENSES/DC_Recomp/LICENSE',
|
||||
for need in ('DC Launcher.exe', 'README.txt', 'CHANGELOG.md', RECOMPLAUNCHER_JSON, 'LICENSES/DC_Recomp/LICENSE',
|
||||
'LICENSES/BozoEngine/LICENSE', 'LICENSES/TMB_Recomp/LICENSE', 'source/VERSION', 'source/release.ini', 'kit/kit_manifest.json',
|
||||
'kit/python/python.exe', 'source/tools/dc_build.py', 'source/BozoEngine/CMakeLists.txt',
|
||||
'kit/deps/sdl3-src/CMakeLists.txt', 'kit/deps/imgui-src/imgui.cpp'):
|
||||
|
||||
Reference in new issue
Block a user