9 Commits
Author SHA1 Message Date
Thomas MartinandClaude Opus 5.5 a7869c0af8 CHANGELOG: 0.3.2 (Story: start at, Black Vista Highway's road, movie sound volume)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:27:25 +01:00
Thomas MartinandClaude Opus 5.5 e189cb3b23 PS2Recomp: VP2S's native libsd fix (the sound data input's volume is BVOL, not AVOL); TMB writes BVOL 0x7efa when its movie streams start and 0 when they stop
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:14:59 +01:00
Thomas MartinandClaude Opus 5.5 a11583c0bf Mesh pack: a hierobject's packet may start up to 0x100 bytes after its texture blocks, zeros between (LOOP pads some to an alignment): 1730 objects of LOOP.NGP (Black Vista Highway's road and walls) and 87 each of DEATH1/2/5 were left out; every object packed before is byte-identical. TMB_NATIVE_MESHES_LOG_MISSING names the objects a loaded file's pack lacks
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:12:38 +01:00
Thomas MartinandClaude Opus 5.5 1152e7fca0 Cheats: Story: start at (TMB_STORY_LEVEL), a new story begins at the chosen level of the game's level table (Shell + 0x18000 + 0x2354, replaced when a new story sets the Junkyard), labelled by the stage card each one shows; TMB_LOG_PROGRESS logs the Shell's progress words
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:04:18 +01:00
Thomas MartinandClaude Opus 5.5 abf529224c make_build_kit: FFmpeg's tarball falls back to the same file on the build-deps pre-release when ffmpeg.org does not answer (same pinned SHA-256)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 13:19:07 +01:00
Thomas MartinandClaude Opus 5.5 82f5b47119 make_build_kit: a download is tried five times, further apart each time (ffmpeg.org dropped the release runner's connections twice; a tag's run starts with an empty download cache)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 13:15:29 +01:00
Thomas MartinandClaude Opus 5.5 257401cbbb CHANGELOG: 0.3.1 (about a third less processor time per frame)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 13:06:11 +01:00
Thomas MartinandClaude Opus 5.5 06b9261112 PS2Recomp: guest loads and stores inlined with a main-RAM fast path, one function lookup per guest call (1P match: 7.5 -> 6.1 ms of work per frame; 639/639 fork tests)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 11:51:06 +01:00
Thomas MartinandClaude Opus 5.5 dc653bb996 Fewer allocations per frame: the fork's frame arrays recycled and its key map only when interpolating; TMB's per-object vertex arrays and strip buffer reused (the allocation waits in Renderer::draw and buildStrips: 8.3% -> 2.8% of the game thread)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 11:11:13 +01:00
8 changed files with 204 additions and 11 deletions

No files matched your search

+41 -1
View File
@@ -7,6 +7,44 @@ under "Unreleased" as they land, then move them under the new version's heading
## [Unreleased]
## [0.3.2] - 2026-11-02
### Added
- **Story: start at** (F2, Cheats): a new story can begin at any of its stages, Midtown Suburbs to Warhawk's Rooftop,
instead of the Junkyard, then goes on from there as usual. Handy to try the later stages without playing through.
### Fixed
- **Black Vista Highway** (story stage 3) had no road: most of the level's ground and walls were not drawn. Some
pieces of three Challenge arenas (DEATH1, DEATH2, DEATH5) were missing for the same reason. "Rebuild now" after
updating fixes them.
- **Movie sound volume**: the movies' sound now plays at the volume the game sets for it (it used a default
volume before; a fix from the Valkyrie Profile 2 port, which shares the sound code).
### Known limits
- Story stages past the first are reachable and load correctly, but most have not been played to the end yet.
- No widescreen yet.
- Only the USA disc (SCUS-97101) is supported.
- The launcher and the game are not signed: Windows SmartScreen asks for "More info", then "Run anyway".
## [0.3.1] - 2026-11-02
### Changed
- **Faster**: the game now needs about a third less processor time per frame than in 0.3.0 (in our tests a busy
match went from about 7.5 to 5 milliseconds of work per frame, out of the 16.7 a frame lasts at 60 frames per
second). Older or slower PCs that dropped below 60 in big fights or in split screen should hold it much better.
Nothing changes in how the game looks or plays.
### Known limits
- Story levels 2 to 8 are not checked to the end yet.
- No widescreen yet.
- Only the USA disc (SCUS-97101) is supported.
- The launcher and the game are not signed: Windows SmartScreen asks for "More info", then "Run anyway".
## [0.3.0] - 2026-11-02
### Added
@@ -85,7 +123,9 @@ The first release. You build the game on your own PC from your own USA disc; not
- Technical: built from TMB_Recomp's code and the PS2Recomp fork (`native/renderer`) with the build kit's GCC 16.2,
FFmpeg 9.0.2 and Python 3.14; the default mode has no GS, VU or SPU2 emulation and no IOP hardware model.
[Unreleased]: https://github.com/TheBozos/TMB_Recomp/compare/v0.3.0...HEAD
[Unreleased]: https://github.com/TheBozos/TMB_Recomp/compare/v0.3.2...HEAD
[0.3.2]: https://github.com/TheBozos/TMB_Recomp/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/TheBozos/TMB_Recomp/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/TheBozos/TMB_Recomp/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/TheBozos/TMB_Recomp/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/TheBozos/TMB_Recomp/releases/tag/v0.1.0
+1
View File
@@ -467,6 +467,7 @@ screen); the variables give their state at launch (`runtime/tmb_cheats.cpp`).
| Cheat | | Variable |
|---|---|---|
| Unlock everything | every level (Freeway, Prison Passage, Skyscrapers, Minion's Stadium...), every vehicle (Yellow Jacket, Axel, Warthog, Manslaughter, Minion...) and every movie, opened in the menus; switched off, put back; saving while it is on keeps them on the card | `TMB_UNLOCK_ALL=1` |
| Story: start at | a new story begins at the chosen level instead of the Junkyard (every stage: Midtown Suburbs or Expressway 104, Downtown or Black Vista Highway, Minion's Stadium, Prison Passage, Blackfield Asylum, Abandoned Skyscrapers, Warhawk's Rooftop; and the other arenas), then goes on as the game chains them; for testing the later stages without playing through | `TMB_STORY_LEVEL=<level number>` (the game's level table: 1 Junkyard, 0 Suburbs, 2 Expressway, 5 Downtown, 6 Black Vista, 14 Stadium, 3 Prison, 16 Asylum, 4 Skyscrapers, 13 their second part, 20 Warhawk's Rooftop) |
| Infinite health | per player: the car's health held at its maximum (the game's own, as its health bar shows it) | `TMB_PLAYER_GOD=<players>` |
| Infinite ammo | per player: pickup weapons and the special are not spent (the HUD's counts stay) | `TMB_INFINITE_AMMO=<players>` |
| Infinite energy | per player: the energy bar (freeze, mines, shield...) held full | `TMB_INFINITE_ENERGY=<players>` |
+76
View File
@@ -64,6 +64,25 @@ namespace tmb::cheats
std::atomic<uint32_t> g_infiniteHealth{0}, g_infiniteAmmo{0}, g_infiniteEnergy{0};
std::atomic<bool> g_noAi{false};
std::atomic<bool> g_unlockAll{false};
// Story: start at a level (-1: off). The story's state is the level being played, Shell + 0x18000 + 0x2354 (the
// index of the game's level table: GetLevelName, LoadLevelDB), the one last won at + 0x2358, the mode at
// + 0x235C (1: one-player story); a new story sets the level to 1, the Junkyard, and each level won sets the
// next (EvaluateOnePlayerStoryStatus).
std::atomic<int> g_storyStart{-1};
constexpr uint32_t kStoryLevel = 0x2354u, kStoryLastWon = 0x2358u, kGameMode = 0x235Cu;
constexpr int kLevelCount = 21;
// The levels by the level table's index (its names at 0x426070, 16 bytes each), with the card the story shows
// when it starts there (the stage, of 8). Two stages have two arenas (the story picks one); ASYLUM and ROOFTOP2
// show no card (reached from inside another level); the others are arenas the story does not use.
constexpr const char *kLevelNames[kLevelCount] = {
"Stage 2: Midtown Suburbs (SUBURB)", "Stage 1: Junkyard (JUNKYARD)", "Stage 2: Midtown Expressway 104 (FREEWAY)",
"Stage 5: Prison Passage to Blackfield Asylum (PRISON)", "Stage 7: Abandoned Skyscrapers (ROOFTOP)",
"Stage 3: Downtown Business District (CITY)", "Stage 3: Black Vista Highway (LOOP)", "Arena DEATH1", "Arena DEATH2",
"Arena DEATH3", "Arena DEATH4", "Arena DEATH5", "Arena DEATH6", "Rooftops, second part (ROOFTOP2)",
"Stage 4: Minion's Stadium (STADIUM)", "Arena SHIP", "Blackfield Asylum (ASYLUM)", "Arena MINICITY", "Arena MINIBURB",
"Arena JUNK2", "Stage 8: Warhawk's Rooftop (ROOFBOSS)"};
// The picker's order: the story's, then the rest.
constexpr int kLevelOrder[kLevelCount] = {1, 0, 2, 5, 6, 14, 3, 16, 4, 13, 20, 7, 8, 9, 10, 11, 12, 15, 17, 18, 19};
std::vector<uint32_t> g_unlocked; // the lock words Unlock everything opened (put back when it goes off)
std::atomic<float> g_enemyCap{-1.0f}; // weak enemies: every computer vehicle's health held at most this; < 0 off
std::atomic<float> g_playerCap{-1.0f}; // TMB_PLAYER_HEALTH_CAP (testing)
@@ -233,6 +252,20 @@ namespace tmb::cheats
g_unlockAll.store(unlock, std::memory_order_relaxed);
ImGui::TextDisabled("Opened in the menus; saving the game while it is on keeps them on the card.");
int start = g_storyStart.load(std::memory_order_relaxed);
ImGui::SetNextItemWidth(420.0f);
if (ImGui::BeginCombo("Story: start at", start < 0 ? "the first level (as the game)" : kLevelNames[start]))
{
if (ImGui::Selectable("the first level (as the game)", start < 0))
start = -1;
for (const int i : kLevelOrder)
if (ImGui::Selectable(kLevelNames[i], start == i))
start = i;
ImGui::EndCombo();
}
g_storyStart.store(start, std::memory_order_relaxed);
ImGui::TextDisabled("For testing: a new story begins at this level, then goes on as the game chains them.");
ImGui::SeparatorText("Players");
perPlayer("Infinite health", g_infiniteHealth, players);
perPlayer("Infinite ammo", g_infiniteAmmo, players);
@@ -267,6 +300,47 @@ namespace tmb::cheats
void setTheGame(uint32_t game) { g_theGame.store(game, std::memory_order_relaxed); }
// Once a frame (timerEndOfRealTimeProcessing, the frame's processing done).
// TMB_LOG_PROGRESS=1 (finding the story's state): each word of Shell + 0x18000 + 0x2180 to + 0x2500 that changes,
// with the time, from every frame end (the menus' too).
void logProgress(uint8_t *rdram, uint32_t gp)
{
const uint32_t shell = word(rdram, gp - kGpShell);
if (shell == 0u)
return;
// Story: start at a level. When a new story sets its first level (the Junkyard, nothing won yet), that level
// is replaced, before the game loads it (it does once the character is chosen); the game's own chain goes on
// from there.
{
const uint32_t progress = shell + kShellProgress;
const int level = static_cast<int32_t>(word(rdram, progress + kStoryLevel));
static int s_lastLevel = -2;
const int start = g_storyStart.load(std::memory_order_relaxed);
if (start >= 0 && level == 1 && s_lastLevel != 1 && word(rdram, progress + kGameMode) == 1u &&
word(rdram, progress + kStoryLastWon) == 0u && start != 1)
{
setWord(rdram, progress + kStoryLevel, static_cast<uint32_t>(start));
std::fprintf(stderr, "[tmb:cheats] story starts at level %s\n", kLevelNames[start]);
}
s_lastLevel = static_cast<int32_t>(word(rdram, progress + kStoryLevel));
}
static const bool s_on = std::getenv("TMB_LOG_PROGRESS") != nullptr;
if (!s_on)
return;
static uint32_t s_last[0xE0] = {};
static bool s_seen = false;
static const auto s_start = std::chrono::steady_clock::now();
const double t = std::chrono::duration<double>(std::chrono::steady_clock::now() - s_start).count();
for (uint32_t i = 0; i < 0xE0u; ++i)
{
const uint32_t value = word(rdram, shell + kShellProgress + 0x2180u + i * 4u);
if (s_seen && value != s_last[i])
std::fprintf(stderr, "[tmb:progress] t=%.1f +0x%x: %d -> %d\n", t, 0x2180u + i * 4u, static_cast<int32_t>(s_last[i]),
static_cast<int32_t>(value));
s_last[i] = value;
}
s_seen = true;
}
void onFrame(uint8_t *rdram)
{
g_rdram.store(rdram, std::memory_order_relaxed);
@@ -368,6 +442,8 @@ namespace tmb::cheats
{
g_noAi.store(std::getenv("TMB_NO_AI") && *std::getenv("TMB_NO_AI") == '1');
g_unlockAll.store(std::getenv("TMB_UNLOCK_ALL") && *std::getenv("TMB_UNLOCK_ALL") == '1');
if (const char *level = std::getenv("TMB_STORY_LEVEL"); level && *level)
g_storyStart.store(std::clamp(std::atoi(level), -1, kLevelCount - 1));
g_infiniteHealth.store(envMask("TMB_PLAYER_GOD"));
g_infiniteAmmo.store(envMask("TMB_INFINITE_AMMO"));
g_infiniteEnergy.store(envMask("TMB_INFINITE_ENERGY"));
+41 -1
View File
@@ -307,6 +307,29 @@ namespace tmb::meshes
bool g_inHier2pFlush = false;
uint64_t g_unsentFlushes = 0; // views submitted at the frame's end (not kicked by hier__Fi)
uint64_t g_listDrops = 0, g_submitted[2] = {}, g_built[2] = {}, g_kicks[2] = {};
// The vertex arrays of the objects drawn last, kept (cleared) for the next objects' batches: each one grew from
// nothing every frame, a few hundred objects' worth of allocations and copies (the game thread only).
std::vector<std::vector<ps2x::native::Vertex>> g_vertexPool;
void recycleVertices(Drawn &drawn)
{
for (auto &batch : drawn.batches)
if (batch.vertices.capacity() != 0u && g_vertexPool.size() < 8192u)
{
batch.vertices.clear();
g_vertexPool.push_back(std::move(batch.vertices));
}
}
std::vector<ps2x::native::Vertex> pooledVertices()
{
if (g_vertexPool.empty())
return {};
std::vector<ps2x::native::Vertex> vertices = std::move(g_vertexPool.back());
g_vertexPool.pop_back();
return vertices;
}
struct ViewList : ps2x::native::MeshViewList<Drawn>
{
// Built by hier2p: sent only by hier2pFlushDma. On the frame a split screen ends hier2p builds its view once
@@ -314,6 +337,11 @@ namespace tmb::meshes
bool hier2p = false;
void clear()
{
for (Drawn &drawn : opaque)
recycleVertices(drawn);
for (std::vector<Drawn> &bucket : buckets)
for (Drawn &drawn : bucket)
recycleVertices(drawn);
MeshViewList<Drawn>::clear();
hier2p = false;
}
@@ -638,7 +666,9 @@ namespace tmb::meshes
bool textured = false;
uint32_t texnum = ~0u;
Batch *batch = nullptr;
std::vector<ps2x::native::Vertex> strip;
static thread_local std::vector<ps2x::native::Vertex> s_strip; // kept from call to call (its capacity)
std::vector<ps2x::native::Vertex> &strip = s_strip;
strip.clear();
static const bool s_check = std::getenv("TMB_NATIVE_MESHES_CHECK") != nullptr;
for (uint32_t si = 0; si < strips; ++si)
{
@@ -691,6 +721,7 @@ namespace tmb::meshes
{
out.batches.emplace_back(std::move(writes));
batch = &out.batches.back();
batch->vertices = pooledVertices();
batch->tex0 = tex0;
batch->textured = textured;
batch->blended = blended;
@@ -1255,6 +1286,15 @@ namespace tmb::meshes
if (!it)
{
++g_stats.noObject;
// TMB_NATIVE_MESHES_LOG_MISSING=1: the first objects of a loaded file the pack does not have.
static const bool s_logMissing = std::getenv("TMB_NATIVE_MESHES_LOG_MISSING") != nullptr;
static std::unordered_map<uint32_t, bool> s_seen;
if (s_logMissing && !s_seen[obj] && s_seen.size() < 40u)
{
s_seen[obj] = true;
std::fprintf(stderr, "[tmb:mesh] object %#x (%s + %#x, setup %#x, flags %#x, %s): not in the pack\n", obj,
file.file->name.c_str(), offset, pc, fp, opaque ? "opaque" : "alpha");
}
stateOnly(ee, extra, opaque);
return;
}
+2
View File
@@ -75,6 +75,7 @@ namespace tmb::cheats
void install(PS2Runtime &runtime);
void setTheGame(uint32_t game);
void onFrame(uint8_t *rdram);
void logProgress(uint8_t *rdram, uint32_t gp);
}
namespace tmb::meshes
@@ -1104,6 +1105,7 @@ namespace
tmb::native::onMenuFrameEnd(); // TMB_NATIVE: publishes a menu frame's native draws (not in a match)
const double step = pacer.frameEnd();
g_lastFrameEndSeconds.store(hitchClock(), std::memory_order_relaxed);
tmb::cheats::logProgress(rdram, gp); // TMB_LOG_PROGRESS
// The fps overlay in the menus (a match's frames are counted at timerEndOfRealTimeProcessing).
if (hitchClock() - g_lastMatchFrameNoted.load(std::memory_order_relaxed) > 0.5)
runtime->noteGameFrame();
+28 -4
View File
@@ -45,6 +45,7 @@ import subprocess
import sys
import tarfile
import time
import urllib.error
import urllib.request
import zipfile
@@ -54,10 +55,13 @@ from tmb_build import pe_imports, cmake_rc_flags # noqa: E402
KIT_VERSION = 1
# ---- pinned downloads (official upstream only) ----
# ---- pinned downloads (official upstream; a mirror of ours only as a fallback, held to the same SHA-256) ----
FFMPEG = {
'version': '9.0.2',
'url': 'https://ffmpeg.org/releases/ffmpeg-9.0.2.tar.xz',
# Tried only when the upstream address fails: the same file on our build-deps pre-release (ffmpeg.org dropped
# the release runner's connections), held to the same SHA-256.
'mirrors': ['https://github.com/TheBozos/TMB_Recomp/releases/download/build-deps/ffmpeg-9.0.2.tar.xz'],
'sha256': '8c3850283eb25fa026482078a04051e0be17347b09ef81a0849bec15a96e002e',
# ffmpeg-9.0.2.tar.xz.asc checked once with gpg against https://ffmpeg.org/ffmpeg-devel.asc:
'signing_key': 'FCF986EA15E6E293A5644F10B4322F04D67658D8 (FFmpeg release signing key)',
@@ -243,10 +247,30 @@ def download(spec, downloads):
os.makedirs(downloads, exist_ok=True)
path = os.path.join(downloads, spec['url'].rsplit('/', 1)[1])
if not (os.path.isfile(path) and sha256_file(path) == spec['sha256']):
log(' downloading %s' % spec['url'])
# A few tries, further apart each time: an upstream site sometimes drops or times out a CI runner's connection
# (GitHub's release runs start with an empty download cache: a tag's run cannot read another tag's cache).
# Then the spec's mirrors, if any; a file from any of them must have the pinned SHA-256.
tmp = path + '.part'
with urllib.request.urlopen(spec['url']) as r, open(tmp, 'wb') as f:
shutil.copyfileobj(r, f, 1 << 20)
tries = [(spec['url'], wait) for wait in (0, 20, 60, 120)]
tries += [(mirror, wait) for mirror in spec.get('mirrors', ()) for wait in (0, 20, 60)]
error = None
for url, wait in tries:
if wait:
log(' %s failed (%s): again in %d s' % (url, error, wait))
time.sleep(wait)
log(' downloading %s' % url)
try:
with urllib.request.urlopen(url, timeout=120) as r, open(tmp, 'wb') as f:
shutil.copyfileobj(r, f, 1 << 20)
except (urllib.error.URLError, OSError) as e:
error = e
continue
digest = sha256_file(tmp)
if digest == spec['sha256']:
break
error = 'SHA-256 %s, expected %s' % (digest, spec['sha256'])
else:
raise KitError('%s: could not download (%s)' % (spec['url'], error))
os.replace(tmp, path)
digest = sha256_file(path)
if digest != spec['sha256']:
+14 -4
View File
@@ -11,7 +11,8 @@ What it reads:
- the NGP files (LVL/*.NGP, SHELL/*.NGP: a zip entry, "IE" instead of "PK", raw deflate after the local header;
ACAR/PCAR car files: raw). Each is a memory image linked at EE 0x980000: a pointer is (value - 0x980000) in the file.
The .PTR file next to it lists the pointer words (its first count, then their byte offsets); a hierobject is a node
of type 0 (word 0 bits 0-5) whose +4 (a listed pointer) is its own prebuilt packet, at obj + 0x70 + 0x30 * ntex.
of type 0 (word 0 bits 0-5) whose +4 (a listed pointer) is its own prebuilt packet, at obj + 0x70 + 0x30 * ntex
or a little after it, zeros between (LOOP pads some packets to an alignment).
- the hierobject: +8 u64 flags (VU1 program choice), +0x10 bounding sphere, +0x50 u16[5] texture numbers (the file's
own, before the game adds the file's texture base), +0x5a ntex, +0x64 skeleton (0 = rigid).
- its packet: DMA tags (REF: data elsewhere in the file, next tag after it; CNT / RET: data after the tag, RET ends;
@@ -104,18 +105,27 @@ def load_pointers(path):
def find_objects(image, pointers):
"""Every hierobject: a type 0 node whose listed +4 pointer is its own packet."""
"""Every hierobject: a type 0 node whose listed +4 pointer is its own packet: right after its texture blocks, or up
to 0x100 bytes later with only zeros between (an aligned packet: LOOP's)."""
found = []
for slot in pointers:
obj = slot - 4
if obj < 0 or obj + 0x70 > len(image) or u32(image, obj) & 0x3f:
continue
ntex = u16(image, obj + 0x5a)
if ntex <= 5 and u32(image, obj + 4) - LINK == obj + 0x70 + 0x30 * ntex:
if ntex > 5:
continue
after, packet = obj + 0x70 + 0x30 * ntex, u32(image, obj + 4) - LINK
if packet == after or (after < packet < after + 0x100 and packet % 16 == 0 and not any(image[after:packet])):
found.append(obj)
return sorted(set(found))
def packet_start(image, obj):
"""Where an object's packet is: its +4 pointer (find_objects checked it)."""
return u32(image, obj + 4) - LINK
def packet_segments(image, start):
"""The DMA chain from start: [(VIF bytes, their offset in the image)] (the tag's two VIF codes first)."""
return dma_chain(image, start, LINK)
@@ -129,7 +139,7 @@ def packet_stream(image, obj):
def packet_stream_mapped(image, obj):
"""The same, with where each piece of it is in the image: (stream, [(stream offset, image offset, length)])."""
return chain_stream(image, obj + 0x70 + 0x30 * u16(image, obj + 0x5a), LINK)
return chain_stream(image, packet_start(image, obj), LINK)
class Strip: