From 4eddae4fa3f20f0a2d1e1d35308d9cefc88ef081 Mon Sep 17 00:00:00 2001 From: Thomas Martin <304581853+boubou666@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:26:03 +0100 Subject: [PATCH 1/3] WIP: hidden-window test runs (--hidden, --capture-scene) on BozoEngine master 3222624 Not qualified yet: the bumped engine's 1P/4P headless replays and a 4P save-state round trip match; the hidden window routes ran (the 4P one paced slowly, to recheck). Co-Authored-By: Claude Opus 5.5 --- BozoEngine | 2 +- bozo/tmb_window.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/BozoEngine b/BozoEngine index 6cf6faf..3222624 160000 --- a/BozoEngine +++ b/BozoEngine @@ -1 +1 @@ -Subproject commit 6cf6fafcbe1d9d106f60813ded96fd10a76a13e3 +Subproject commit 322262439168321ffd8818af0aea68e04833b065 diff --git a/bozo/tmb_window.cpp b/bozo/tmb_window.cpp index 4f4a012..88ea7c1 100644 --- a/bozo/tmb_window.cpp +++ b/bozo/tmb_window.cpp @@ -7,7 +7,11 @@ // // tmb [--iso image] [--elf SCUS_971.01] [--card-dir dir] [--width w --height h] [--fullscreen] [--no-vsync] // [--render-scale s] [--capture-dir dir] [--capture-frames n,n,...] [--quit-after n] [--pad-script [n=]file]... -// [--no-sound] [--audio-latency ms] [--audio-stats] [--wav file] +// [--no-sound] [--audio-latency ms] [--audio-stats] [--wav file] [--hidden] [--capture-scene] +// [--save-state file --save-state-at n] [--load-state file [--load-state-at n]] +// +// --hidden: a test run that shows nothing (the window is never shown; --capture-frames reads the game's offscreen +// picture). --capture-scene: captures read that picture (no overlays) in a shown window too. // // The user folder (%APPDATA%\TMB_Recomp, as the fork's TMB; PS2X_USER_DIR overrides it) holds input.ini, the memory // cards (mc0, mc1; --card-dir overrides) and the logs (logs/TMB_Recomp.log). Without --elf the game data is looked for @@ -119,6 +123,10 @@ int main(int argc, char **argv) if (!item.empty()) window.captureFrames.push_back(std::stoull(item)); } + else if (a == "--hidden") + window.hidden = true; // a test run that shows nothing: captures read the game's offscreen picture + else if (a == "--capture-scene") + window.captureScene = true; // captures read the game's picture (no overlays) even in a shown window else if (a == "--quit-after") window.quitAfterFrames = std::stoull(value()); else if (a == "--print") @@ -142,7 +150,7 @@ int main(int argc, char **argv) else { std::fprintf(stderr, "usage: tmb [--iso image] [--elf path] [--card-dir dir] [--width w] [--height h] [--fullscreen] " - "[--no-vsync] [--render-scale s] [--capture-dir dir] [--capture-frames n,n,...] [--quit-after n] " + "[--no-vsync] [--render-scale s] [--capture-dir dir] [--capture-frames n,n,...] [--quit-after n] [--hidden] [--capture-scene] " "[--pad-script [n=]file]... [--print] [--no-sound] [--audio-latency ms] [--audio-stats] [--wav file] " "[--save-state file --save-state-at n] [--load-state file [--load-state-at n]]\n"); return 2; From cd5262a7a0455950630d17fc03ef7b89c15f05fa Mon Sep 17 00:00:00 2001 From: Thomas Martin <304581853+boubou666@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:02:21 +0100 Subject: [PATCH 2/3] Hidden test runs: tmb-check --window --hidden; the native suites on engine master's float shortcuts - BozoEngine at claude/ps2f-mul-min-normal (7521b3e, BozoEngine #131 on master 3222624): hidden windows, and the fix for products that rounded up to the smallest normals in ps2f's and VU0's host shortcuts. - tmb-check --window --hidden: the pinned pixel captures without showing the window (the offscreen picture). - README: --hidden, --capture-scene; --no-sound keeps --wav. - Native suites (tests/host_control.h): engine master's ps2f and VU0 shortcuts use the host's arithmetic, exact only when the host rounds to nearest (the game's word) and leaving SSE's sticky status flags. The original now runs at the caller's word rounding to nearest, native code still at the varied caller word (generated callers on both sides at nearest), and the control word is compared without the status flags. Co-Authored-By: Claude Opus 5.5 --- BozoEngine | 2 +- README.md | 4 +++- bozo/tmb_check.cpp | 5 ++++- tests/host_control.h | 16 ++++++++++++++++ tests/native_contact_tests.cpp | 14 ++++++++------ tests/native_direction_callers.cpp | 15 ++++++++------- tests/native_hierarchy_callers.cpp | 7 ++++--- tests/native_hierarchy_tests.cpp | 18 +++++++++++------- tests/native_hud_tests.cpp | 8 +++++--- tests/native_math_tests.cpp | 8 +++++--- tests/native_projection_tests.cpp | 13 +++++++------ tests/native_sphere_lod_callers.cpp | 13 +++++++------ tests/native_vehicle_tests.cpp | 14 ++++++++------ 13 files changed, 87 insertions(+), 50 deletions(-) create mode 100644 tests/host_control.h diff --git a/BozoEngine b/BozoEngine index 3222624..7521b3e 160000 --- a/BozoEngine +++ b/BozoEngine @@ -1 +1 @@ -Subproject commit 322262439168321ffd8818af0aea68e04833b065 +Subproject commit 7521b3ee073c342dc65402051c02f7ae6769601b diff --git a/README.md b/README.md index f15a4d0..1d3beb2 100644 --- a/README.md +++ b/README.md @@ -449,13 +449,15 @@ screen); the variables give their state at launch (`runtime/tmb_cheats.cpp`). | `--pad-script [n=]` | Frame-keyed scripted input for player n (1–4); repeat for multiple players | | `--quit-after ` | End an unattended windowed run | | `--capture-dir --capture-frames n,n` | Capture chosen game frames | +| `--hidden` | Test run that never shows the window: captures read the game's offscreen picture (add `--no-sound` so nothing plays; `--wav` still records) | +| `--capture-scene` | Captures read the game's picture without overlays, in a shown window | | `PS2X_CAPTURE_WINDOW_DIR=` | F8/F9 capture destination | | `PS2X_CAPTURE_SEQUENCE=`, `PS2X_CAPTURE_SEQUENCE_AT=[,...]` | Consecutive presents at F8 or the chosen times, with interpolation timing metadata | | `PS2X_CAPTURE_BURST_AT=[,...]` | Start/stop an F9-style burst at the chosen times | | `PS2X_CAPTURE_DIR=`, `PS2X_CAPTURE_INTERVAL=` | Periodic picture captures | | `--audio-stats`, `--audio-latency ` | Audio queue/underrun diagnostics and queue target | | `--wav `, `PS2X_AUDIO_RECORD=` | Record the native mixer output | -| `--no-sound` | Disable device playback for a diagnostic run | +| `--no-sound` | Disable device playback (test runs; `--wav` still records) | | `PS2X_SETTINGS_OPEN=Controls\|Video\|Cheats` | Open F2 directly on a tab for UI tests | | `PS2X_LOG_FILE=\|0`, `PS2X_NO_DIALOGS=1`, `PS2X_TEST_CRASH=` | Another log/none, suppress unattended dialogs, or intentionally test crash handling | | `TMB_CHEATS_LOG=1`, `TMB_CHEATS_TOGGLE=` | Cheat diagnostics and periodic switching for tests | diff --git a/bozo/tmb_check.cpp b/bozo/tmb_check.cpp index a82f9b6..ded6265 100644 --- a/bozo/tmb_check.cpp +++ b/bozo/tmb_check.cpp @@ -6,10 +6,11 @@ // --window (builds with TMB_WINDOW): the same pinned run, its frames shown in a window as they are made (BozoEngine's // window, the renderer's present), to capture the pictures of chosen frames (milestone M5's pixel comparison): // tmb-check ... --window --capture-frames n,n,... [--capture-dir dir] [--width w --height h] -// [--render-scale s] [--aspect a] +// [--render-scale s] [--aspect a] [--hidden] // --capture-frames n: the picture once n frames have ended, i.e. the reference record n - 1's frame (frame_.png). The // run is held at that frame's end until the window has read it back, so the picture is exactly that frame's. The window // is 640x448 at render scale 1 by default; --aspect is the picture's shape inside it (4:3 by default, letterboxed). +// --hidden: the window is never shown, and the captures read the game's offscreen picture (the same pixels). #include "run_main.h" #if TMB_CHECK_WINDOW @@ -86,6 +87,8 @@ namespace window.renderScale = std::stof(value()); else if (a == "--aspect") window.aspect = std::stof(value()); + else if (a == "--hidden") + window.hidden = true; else rest.push_back(args[k]); } diff --git a/tests/host_control.h b/tests/host_control.h new file mode 100644 index 0000000..b052e1f --- /dev/null +++ b/tests/host_control.h @@ -0,0 +1,16 @@ +// The host's floating-point control word (MXCSR) in the native tests. +// +// BozoEngine's ps2f takes the host's own float add / mul where it gives the PS2's bits (operands and result normal, +// rounded to nearest: BozoEngine e1518bf). So the game's original code is exact only when the host rounds to nearest, +// as the game runs, and it leaves the sticky status flags set as SSE does. The tests run the original at the caller's +// word rounding to nearest (its flush-to-zero and denormals-are-zero kept, which both sides follow), the native code at +// the caller's varied word, and compare the control word without the six status flags (nothing reads them). +#pragma once + +namespace tmb::test +{ + // The word the original runs at: the caller's, rounding to nearest, the status flags clear. + inline unsigned referenceControl(unsigned control) { return control & ~0x603fu; } + // The control part equal: rounding, flush to zero, denormals-are-zero, the masks (not the status flags). + inline bool sameControl(unsigned a, unsigned b) { return ((a ^ b) & ~0x3fu) == 0; } +} diff --git a/tests/native_contact_tests.cpp b/tests/native_contact_tests.cpp index ccaa592..95585c3 100644 --- a/tests/native_contact_tests.cpp +++ b/tests/native_contact_tests.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT // Compare actual generated original blocks against the production instruction dispatcher, including ordered aliases. +#include "host_control.h" #include "tmb_contact_math.h" #include "tmb_native_math.h" #include "tmb_contact_original.h" @@ -201,7 +202,7 @@ namespace if (kind == 6 && ctx.pc == 0xbad0000) return; throw std::runtime_error("contact continuation did not reach query boundary"); }; - const auto control = ((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u); + const auto control = tmb::test::referenceControl(((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u)); // generated code on both sides: the game's rounding auto a = initial, b = initial; _mm_setcsr(control); run(false, a); const auto refControl = _mm_getcsr(); const auto refYields = services.yields; for (unsigned i = 0; i < outputs; ++i) std::memcpy(ram + output[i] + 12, payload(output[i]) + 12, 4); @@ -215,10 +216,10 @@ namespace const bool untouched = !std::memcmp(reinterpret_cast(&initial) + vuAt, reinterpret_cast(&b) + vuAt, vuBytes); std::memset(reinterpret_cast(&a) + vuAt, 0, vuBytes); std::memset(reinterpret_cast(&b) + vuAt, 0, vuBytes); - if (std::memcmp(&a, &b, sizeof(a)) || !untouched || after != refControl || refYields != services.yields || + if (std::memcmp(&a, &b, sizeof(a)) || !untouched || !tmb::test::sameControl(after, refControl) || refYields != services.yields || std::memcmp(expectedAll.get(), ram + base, bytes) || std::memcmp(expectedAll.get() + bytes, ram + globals, globalBytes) || (n < 4 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) - { std::fprintf(stderr, "FAIL contact continuation %u case %u mode %u CPU%d VU%d FP%d data%d globals%d\n",kind,n,mode,std::memcmp(&a,&b,sizeof(a)),untouched,after==refControl,std::memcmp(expectedAll.get(),ram+base,bytes),std::memcmp(expectedAll.get()+bytes,ram+globals,globalBytes)); throw std::runtime_error("contact continuation differs"); } + { std::fprintf(stderr, "FAIL contact continuation %u case %u mode %u CPU%d VU%d FP%d data%d globals%d\n",kind,n,mode,std::memcmp(&a,&b,sizeof(a)),untouched,tmb::test::sameControl(after, refControl),std::memcmp(expectedAll.get(),ram+base,bytes),std::memcmp(expectedAll.get()+bytes,ram+globals,globalBytes)); throw std::runtime_error("contact continuation differs"); } ++cases; } host.enabled = true; rt.services = nullptr; @@ -279,11 +280,12 @@ int main() if (site.translation) setRegU32(&initial, site.translation, (translation | alias) + ((n >> 8u) & 15u)); R5900Context original = initial, native = initial; const unsigned control = ((savedControl | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1u ? 0x8040u : 0u); - _mm_setcsr(control); + _mm_setcsr(tmb::test::referenceControl(control)); originalBlock(index, ram, original, rt.get()); std::memcpy(expected.data(), arena, arenaBytes); if (n < 8) { std::memcpy(whole.get(), ram, bozo::kFlatBytes); ++wholeCases; } std::memcpy(arena, input.data(), arenaBytes); + _mm_setcsr(control); for (uint32_t pc = site.first; pc <= site.last; pc += 4) { if (!handler(ram, &native, rt.get(), pc)) return 2; @@ -292,10 +294,10 @@ int main() const unsigned after = _mm_getcsr(); _mm_setcsr(savedControl); if (std::memcmp(arena, expected.data(), arenaBytes) || std::memcmp(&native, &initial, sizeof(initial)) || - after != control || (n < 8 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) + !tmb::test::sameControl(after, control) || (n < 8 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) { std::fprintf(stderr, "FAIL contact block %u case %u mode %u: memory %d CPU/VU %d host %d\n", index, n, mode, - std::memcmp(arena, expected.data(), arenaBytes), std::memcmp(&native, &initial, sizeof(initial)), after == control); + std::memcmp(arena, expected.data(), arenaBytes), std::memcmp(&native, &initial, sizeof(initial)), tmb::test::sameControl(after, control)); return 4; } host.enabled = false; diff --git a/tests/native_direction_callers.cpp b/tests/native_direction_callers.cpp index fe1d157..1c7b84c 100644 --- a/tests/native_direction_callers.cpp +++ b/tests/native_direction_callers.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT // Run the generated BSP collision setup through its real XYZ consumers. No copied game code is committed. +#include "host_control.h" #include "tmb_port.h" #include "tmb_native_math.h" #include "bozo/libs/libraries.h" @@ -123,7 +124,7 @@ void testDirectionCallers() const float radius = 6.5f; std::memcpy(&initial.fu[20], &radius, 4); std::memcpy(input.get(), ram + 0x10000, arenaBytes); std::memcpy(input.get() + arenaBytes, ram + globals, globalBytes); - const unsigned control = ((saved | 0x1f80) & ~0xe040u) | (mode << 13) | (n & 1 ? 0x8040 : 0); + const unsigned control = tmb::test::referenceControl(((saved | 0x1f80) & ~0xe040u) | (mode << 13) | (n & 1 ? 0x8040 : 0)); // generated code on both sides: the game's rounding const auto run = [&](RecompiledFunction direction, R5900Context &ctx) { services.yields = 0; rt->functions.setOverride(0x1da298, direction); @@ -145,7 +146,7 @@ void testDirectionCallers() std::memcpy(ram + 0x10000, input.get(), arenaBytes); std::memcpy(ram + globals, input.get() + arenaBytes, globalBytes); run(nativeDirection, b); const unsigned after = _mm_getcsr(); _mm_setcsr(saved); - if (!cpuEqual(a, b) || !vuUntouched(initial, b) || after != control || referenceYields != services.yields || + if (!cpuEqual(a, b) || !vuUntouched(initial, b) || !tmb::test::sameControl(after, control) || referenceYields != services.yields || std::memcmp(expected.get(), ram + 0x10000, arenaBytes) || std::memcmp(expected.get() + arenaBytes, ram + globals, globalBytes) || (n < 4 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) @@ -248,7 +249,7 @@ void testDirectionCallers() setRegU32(&initial, 6, address(output)); word(output + 12, bits()); // Both light directions may execute in one continuation; both opaque W words must stay untouched. std::memcpy(input.get(), ram + 0x10000, arenaBytes); - const unsigned control = ((saved | 0x1f80) & ~0xe040u) | (mode << 13) | (n & 1 ? 0x8040 : 0); + const unsigned control = tmb::test::referenceControl(((saved | 0x1f80) & ~0xe040u) | (mode << 13) | (n & 1 ? 0x8040 : 0)); // generated code on both sides: the game's rounding const auto run = [&](RecompiledFunction direction, R5900Context &ctx) { services.yields = 0; rt->functions.setOverride(0x1da298, direction); @@ -269,12 +270,12 @@ void testDirectionCallers() _mm_setcsr(control); run(nativeDirection, b); const unsigned after = _mm_getcsr(); _mm_setcsr(saved); // Original scalar normalization can raise host exception flags; compare its complete FP effects too. - if (!cpuEqual(a, b) || !vuUntouched(initial, b) || after != referenceControl || referenceYields != services.yields || + if (!cpuEqual(a, b) || !vuUntouched(initial, b) || !tmb::test::sameControl(after, referenceControl) || referenceYields != services.yields || std::memcmp(expected.get(), ram + 0x10000, arenaBytes) || (n < 4 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) { std::fprintf(stderr, "FAIL vehicle/light caller %x case %u mode %u CPU%d data%d FP%d yields %u/%u\n", - caller, n, mode, cpuEqual(a, b), std::memcmp(expected.get(), ram + 0x10000, arenaBytes), after == referenceControl, + caller, n, mode, cpuEqual(a, b), std::memcmp(expected.get(), ram + 0x10000, arenaBytes), tmb::test::sameControl(after, referenceControl), referenceYields, services.yields); throw std::runtime_error("vehicle/light direction consumer differs"); } @@ -307,7 +308,7 @@ void testDirectionCallers() const uint32_t alias = n % 3 == 0 ? 0x80000000 : n % 3 == 1 ? 0x20000000 : 0; setRegU32(&initial, 4, vehicle | alias); setRegU32(&initial, 5, n % 4); setRegU32(&initial, 29, sp | alias); initial.pc = 0x118178; initial.cycleLimit = 0; - const unsigned control = ((saved | 0x1f80) & ~0xe040u) | (mode << 13) | (n & 1 ? 0x8040 : 0); + const unsigned control = tmb::test::referenceControl(((saved | 0x1f80) & ~0xe040u) | (mode << 13) | (n & 1 ? 0x8040 : 0)); // generated code on both sides: the game's rounding const auto run = [&](R5900Context &ctx) { services.yields = 0; @@ -324,7 +325,7 @@ void testDirectionCallers() const uint32_t poisonedW = bits(); std::memcpy(ram + result + 12, &poisonedW, 4); _mm_setcsr(control); run(b); const auto after = _mm_getcsr(); _mm_setcsr(saved); std::memcpy(ram + result + 12, input.get() + result - 0x10000 + 12, 4); - require(!std::memcmp(&a, &b, sizeof(a)) && after == referenceControl && services.yields == referenceYields && + require(!std::memcmp(&a, &b, sizeof(a)) && tmb::test::sameControl(after, referenceControl) && services.yields == referenceYields && !std::memcmp(expected.get(), ram + 0x10000, arenaBytes) && (n >= 4 || !std::memcmp(whole.get(), ram, bozo::kFlatBytes)), "contact position W affected XYZ consumer"); ++contactCases; diff --git a/tests/native_hierarchy_callers.cpp b/tests/native_hierarchy_callers.cpp index 52a0599..28cb607 100644 --- a/tests/native_hierarchy_callers.cpp +++ b/tests/native_hierarchy_callers.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT // Real hierarchy helper consumers compiled from the local game ELF; no copied game implementation. +#include "host_control.h" #include "tmb_port.h" #include "tmb_native_math.h" #include "tmb_hierarchy_math.h" @@ -2826,7 +2827,7 @@ void testHierarchyHelperCallers() require(ctx.pc==0xbad0000,"peel-out coordinate-system consumer returned early"); } }; - const unsigned control = ((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u); + const unsigned control = tmb::test::referenceControl(((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u)); // generated code on both sides: the game's rounding auto a = initial, b = initial; _mm_setcsr(control); try { run(false, a); } catch (...) { std::fprintf(stderr, "hierarchy original kind %u case %u\n", kind, n); throw; } @@ -3467,10 +3468,10 @@ void testHierarchyHelperCallers() // Full rear-view entries retain the original rotation producer's identity-helper VU writes. const auto &expectedVu=kind == 148 && sawDirectionEntry ? directionEntry : kind==195 && sawForceInverseEntry ? forceInverseEntry : initial; if(kind==195 && sawForceInverseEntry) require(vuUntouched(forceReferenceEntry,forceInverseEntry),"force-field original producer effects differ"); - if (!cpuEqual(a,b) || !(kind>=236 ? weaponVuRetired(initial,a,b) : vuUntouched(expectedVu,b)) || after != refControl || services.yields != refYields || services.randomCalls != refRandomCalls || + if (!cpuEqual(a,b) || !(kind>=236 ? weaponVuRetired(initial,a,b) : vuUntouched(expectedVu,b)) || !tmb::test::sameControl(after, refControl) || services.yields != refYields || services.randomCalls != refRandomCalls || services.weatherPoints != refWeatherPoints || services.weatherIdentities != refWeatherIdentities || services.spatialCalls != refSpatialCalls || auditedInverseCalls != refAuditedInverseCalls || services.aiActions != refAiActions || services.vehicleLightActions != refVehicleLightActions || services.finalActions != refFinalActions || services.rigidActions != refRigidActions || rigidDirectionCalls != refRigidDirections || driverDirectionCalls != refDriverDirections || services.driverActions != refDriverActions || services.driverQueryEndpoints != refDriverEndpoints || services.collisionActions != refCollisionActions || services.collisionVelocities != refCollisionVelocities || collisionDirectionCalls != refCollisionDirections || attachmentDirectionCalls != refAttachmentDirections || services.attachmentActions != refAttachmentActions || minionDirectionCalls != refMinionDirections || services.minionActions != refMinionActions || services.minionPoints != refMinionPoints || weaponDirectionCalls != refWeaponDirections || services.weaponInputs != refWeaponInputs || services.weaponBases != refWeaponBases || services.weaponOutputs != refWeaponOutputs || services.weaponTargets != refWeaponTargets || !dataEqual() || (wholeCase && std::memcmp(whole.get(),ram,bozo::kFlatBytes))) - { std::fprintf(stderr,"FAIL hierarchy %x case %u mode %u CPU%d VU%d FP%d data%d\n",callers[kind],n,mode,cpuEqual(a,b),vuUntouched(initial,b),after==refControl,dataEqual()); throw std::runtime_error("hierarchy consumer differs"); } + { std::fprintf(stderr,"FAIL hierarchy %x case %u mode %u CPU%d VU%d FP%d data%d\n",callers[kind],n,mode,cpuEqual(a,b),vuUntouched(initial,b),tmb::test::sameControl(after, refControl),dataEqual()); throw std::runtime_error("hierarchy consumer differs"); } ++cases; } require(aiShotPublications[0] && aiShotPublications[1],"AI fixtures did not publish front/rear attack states"); diff --git a/tests/native_hierarchy_tests.cpp b/tests/native_hierarchy_tests.cpp index c422ca0..a315780 100644 --- a/tests/native_hierarchy_tests.cpp +++ b/tests/native_hierarchy_tests.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT // Differential checks against complete generated helpers, including the original VCALLMS library path. +#include "host_control.h" #include "tmb_port.h" #include "tmb_hierarchy_math.h" #include "bozo/ee/dispatcher.h" @@ -107,7 +108,7 @@ int main() d.updateLimit(&initial); // the dispatcher supplies this scheduler cache before executing a helper R5900Context original=initial,native=initial; const unsigned control = ((saved|0x1f80u)&~0xe040u)|(mode<<13)|(n&1 ? 0x8040u : 0); - _mm_setcsr(control); + _mm_setcsr(tmb::test::referenceControl(control)); if (kind == 2) bspPlaneTest2Vec__FP6_planeP8_fvectorT1T1_0x201660(ram,&original,&rt); else if (kind) mathfMulVec__FPA3_fP8_fvectorT1_0x1da1e8(ram,&original,&rt); else hdHatSphereTestAsm__FP8_fvectorfT0T0_0x1cf7c0(ram,&original,&rt); @@ -119,10 +120,11 @@ int main() if (n<32) { std::memcpy(full.get(),ram,bozo::kFlatBytes); ++memoryCases; } std::memcpy(arena,input.data(),input.size()); const auto before=host.microCalls; + _mm_setcsr(control); (kind == 2 ? plane : kind ? inverse : sphere)(ram,&native,&rt); nativeMicros += host.microCalls-before; const unsigned after=_mm_getcsr(); _mm_setcsr(saved); - if (!compareCpu(original,native,initial) || std::memcmp(arena,expected.data(),input.size()) || after!=control || + if (!compareCpu(original,native,initial) || std::memcmp(arena,expected.data(),input.size()) || !tmb::test::sameControl(after,control) || (n<32 && std::memcmp(full.get(),ram,bozo::kFlatBytes))) { if(!kind) { @@ -130,7 +132,7 @@ int main() for(unsigned v:{14u,15u,17u,18u,20u,21u,22u,23u,24u,27u})std::fprintf(stderr,"vf%u %08x %08x %08x %08x\n",v,original.vu0_vf[v].u[0],original.vu0_vf[v].u[1],original.vu0_vf[v].u[2],original.vu0_vf[v].u[3]); } std::fprintf(stderr,"FAIL kind %u mode %u case %u: CPU %d data %d host %d return %x/%x\n",kind,mode,n, - compareCpu(original,native,initial),std::memcmp(arena,expected.data(),input.size()),after==control, + compareCpu(original,native,initial),std::memcmp(arena,expected.data(),input.size()),tmb::test::sameControl(after,control), getRegU32(&native,2),getRegU32(&original,2)); for (size_t i=0;i=vuAt+vuBytes) && ((uint8_t *)&original)[i]!=((uint8_t *)&native)[i]) std::fprintf(stderr,"CPU byte %zu original %02x native %02x\n",i,((uint8_t *)&original)[i],((uint8_t *)&native)[i]); @@ -155,11 +157,12 @@ int main() setRegU32(&initial,28,0x14854);setRegU32(&initial,31,0xbad0000);d.updateLimit(&initial); auto original=initial,native=initial; const unsigned control=((saved|0x1f80u)&~0xe040u)|(mode<<13)|(n&1 ? 0x8040u : 0); - _mm_setcsr(control); + _mm_setcsr(tmb::test::referenceControl(control)); hdHatSphereTestAsm__FP8_fvectorfT0T0_0x1cf7c0(ram,&original,&rt); + _mm_setcsr(control); const auto before=host.microCalls;sphere(ram,&native,&rt); const auto after=_mm_getcsr();_mm_setcsr(saved); - if (!compareCpu(original,native,initial) || after!=control || host.microCalls!=before) { + if (!compareCpu(original,native,initial) || !tmb::test::sameControl(after,control) || host.microCalls!=before) { std::fprintf(stderr,"FAIL sphere edge %u mode %u return %x/%x\n",n,mode,getRegU32(&native,2),getRegU32(&original,2));return 5; } ++edges; @@ -196,7 +199,7 @@ int main() for(auto &v:initial.vu0_vf)for(auto &b:v.u)b=randomBits();initial.vu0_vf[0]={};initial.vu0_vf[0].u[3]=0x3f800000; d.updateLimit(&initial);auto original=initial,native=initial; const unsigned control=((saved|0x1f80u)&~0xe040u)|(mode<<13)|(n&1 ? 0x8040u : 0); - _mm_setcsr(control); + _mm_setcsr(tmb::test::referenceControl(control)); rt.functions.setOverride(0x201660,&referencePlane); try { bspVecTestIn__FP8_hierbspP8_fvectorT1_0x201318(ram,&original,&rt); } catch(const bozo::ee::StopGuest &) { if(original.pc!=0xbad0000)throw; } // recursive root return to dispatcher @@ -204,10 +207,11 @@ int main() if(n<8)std::memcpy(full.get(),ram,bozo::kFlatBytes); std::memcpy(ram+0x10000,callerInput.get(),callerBytes); rt.functions.setOverride(0x201660,plane); + _mm_setcsr(tmb::test::referenceControl(control)); // the generated caller runs on both sides: the game's rounding try { bspVecTestIn__FP8_hierbspP8_fvectorT1_0x201318(ram,&native,&rt); } catch(const bozo::ee::StopGuest &) { if(native.pc!=0xbad0000)throw; } const unsigned after=_mm_getcsr();_mm_setcsr(saved); - if(!compareCpu(original,native,initial)||std::memcmp(callerExpected.get(),ram+0x10000,callerBytes)||after!=control|| + if(!compareCpu(original,native,initial)||std::memcmp(callerExpected.get(),ram+0x10000,callerBytes)||!tmb::test::sameControl(after,tmb::test::referenceControl(control))|| (n<8&&std::memcmp(full.get(),ram,bozo::kFlatBytes))||native.pc!=0xbad0000) { std::fprintf(stderr,"FAIL complete BSP caller %u mode %u CPU %d data %d pc %x\n",n,mode,compareCpu(original,native,initial),std::memcmp(callerExpected.get(),ram+0x10000,callerBytes),native.pc);return 6; } diff --git a/tests/native_hud_tests.cpp b/tests/native_hud_tests.cpp index 717fa38..b3a4100 100644 --- a/tests/native_hud_tests.cpp +++ b/tests/native_hud_tests.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT // Compare actual generated original blocks against the production instruction dispatcher, including ordered aliases. +#include "host_control.h" #include "tmb_hud_math.h" #include "tmb_native_math.h" #include "tmb_hud_original.h" @@ -92,11 +93,12 @@ int main() if (site.translation) setRegU32(&initial, site.translation, (translation | alias) + ((n >> 8u) & 15u)); R5900Context original = initial, native = initial; const unsigned control = ((savedControl | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1u ? 0x8040u : 0u); - _mm_setcsr(control); + _mm_setcsr(tmb::test::referenceControl(control)); originalBlock(index, ram, original, rt.get()); std::memcpy(expected.data(), arena, arenaBytes); if (n < 8) { std::memcpy(whole.get(), ram, bozo::kFlatBytes); ++wholeCases; } std::memcpy(arena, input.data(), arenaBytes); + _mm_setcsr(control); for (uint32_t pc = site.first; pc <= site.last; pc += 4) { if (!handler(ram, &native, rt.get(), pc)) return 2; @@ -105,10 +107,10 @@ int main() const unsigned after = _mm_getcsr(); _mm_setcsr(savedControl); if (std::memcmp(arena, expected.data(), arenaBytes) || std::memcmp(&native, &initial, sizeof(initial)) || - after != control || (n < 8 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) + !tmb::test::sameControl(after, control) || (n < 8 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) { std::fprintf(stderr, "FAIL HUD block %u case %u mode %u: memory %d CPU/VU %d host %d\n", index, n, mode, - std::memcmp(arena, expected.data(), arenaBytes), std::memcmp(&native, &initial, sizeof(initial)), after == control); + std::memcmp(arena, expected.data(), arenaBytes), std::memcmp(&native, &initial, sizeof(initial)), tmb::test::sameControl(after, control)); return 4; } host.enabled = false; diff --git a/tests/native_math_tests.cpp b/tests/native_math_tests.cpp index bea80d3..2db2e59 100644 --- a/tests/native_math_tests.cpp +++ b/tests/native_math_tests.cpp @@ -1,4 +1,5 @@ // Exact, independent-original comparisons: record values, overlapping memory, the complete CPU ABI and untouched VU state. +#include "host_control.h" #include "tmb_port.h" #include "tmb_native_math.h" #include "bozo/libs/libraries.h" @@ -99,7 +100,7 @@ int main() R5900Context original = initial, native = initial; // Deliberately vary caller rounding and denormal settings. Native code must restore the whole word. const unsigned control = ((savedControl | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1u ? 0x8040u : 0u); - _mm_setcsr(control); + _mm_setcsr(tmb::test::referenceControl(control)); helper.original(rt->memory.flat(), &original, rt.get()); if (helper.direction) // direction outputs are XYZ; the native record contract retains destination W std::memcpy(arena + (output - physicalBase) + 12, input.data() + (output - physicalBase) + 12, 4); @@ -110,6 +111,7 @@ int main() ++fullMemoryCases; } std::memcpy(arena, input.data(), input.size()); + _mm_setcsr(control); registry.find(helper.address)(rt->memory.flat(), &native, rt.get()); const unsigned after = _mm_getcsr(); _mm_setcsr(savedControl); @@ -119,11 +121,11 @@ int main() std::memset(reinterpret_cast(&original) + vuAt, 0, vuBytes); std::memset(reinterpret_cast(&native) + vuAt, 0, vuBytes); if (std::memcmp(arena, expected.data(), expected.size()) || std::memcmp(&original, &native, sizeof(native)) || - !untouched || after != control || (n < 32 && std::memcmp(rt->memory.flat(), wholeRam.get(), bozo::kFlatBytes))) + !untouched || !tmb::test::sameControl(after, control) || (n < 32 && std::memcmp(rt->memory.flat(), wholeRam.get(), bozo::kFlatBytes))) { std::fprintf(stderr, "FAIL %s case %u host mode %u: data %d, CPU %d, untouched VU %d, host control %d\n", helper.name, n, mode, std::memcmp(arena, expected.data(), expected.size()), - std::memcmp(&original, &native, sizeof(native)), untouched, after == control); + std::memcmp(&original, &native, sizeof(native)), untouched, tmb::test::sameControl(after, control)); for (size_t i = 0; i < arenaBytes; i += 4) if (std::memcmp(arena + i, expected.data() + i, 4)) { diff --git a/tests/native_projection_tests.cpp b/tests/native_projection_tests.cpp index cfa057e..8ed73fc 100644 --- a/tests/native_projection_tests.cpp +++ b/tests/native_projection_tests.cpp @@ -1,4 +1,5 @@ // SPDX-License-Identifier: MIT +#include "host_control.h" #include "tmb_port.h" #include "tmb_projection_math.h" #include "tmb_vehicle_math.h" @@ -78,17 +79,17 @@ int main() setRegU32(&initial,31,caller); initial.pc=kind==2?0x1db0f0:0x1da238; if(kind==2)setRegU32(&initial,4,(output+(n&15))|alias); const unsigned control=((saved|0x1f80)&~0xe040u)|(mode<<13)|(n&1?0x8040:0); - _mm_setcsr(control); auto original=initial,native=initial; + _mm_setcsr(tmb::test::referenceControl(control)); auto original=initial,native=initial; const auto fn=kind==2?mathfUnitMatrixAsm__FPA3_f_0x1db0f0:mathfMulVec4x4__FPA3_fP8_fvectorT1_0x1da238; fn(ram,&original,&rt); std::memcpy(expected,ram+flat,512); if(n<16){std::memcpy(full.get(),ram,bozo::kFlatBytes);++memoryCases;} - std::memcpy(ram+flat,input,512); (kind==2?identity:point)(ram,&native,&rt); + std::memcpy(ram+flat,input,512); _mm_setcsr(control); (kind==2?identity:point)(ram,&native,&rt); const unsigned after=_mm_getcsr(); _mm_setcsr(saved); - if(std::memcmp(expected,ram+flat,512)||!cpu(original,native,initial)||after!=control|| + if(std::memcmp(expected,ram+flat,512)||!cpu(original,native,initial)||!tmb::test::sameControl(after, control)|| (n<16&&std::memcmp(full.get(),ram,bozo::kFlatBytes))) { std::fprintf(stderr,"FAIL projection kind%u case%u mode%u data%d CPU%d FP%d\n",kind,n,mode, - std::memcmp(expected,ram+flat,512),cpu(original,native,initial),after==control);return 1; + std::memcmp(expected,ram+flat,512),cpu(original,native,initial),tmb::test::sameControl(after, control));return 1; } ++cases; } @@ -136,7 +137,7 @@ int main() const uint64_t ret=0xbad0000;std::memcpy(ram+0x30000+0x120,&ret,8); } d.updateLimit(&initial); std::memcpy(arenaInput.get(),ram+0x10000,0x40000); - const unsigned control=((saved|0x1f80)&~0xe040u)|(mode<<13)|(n&1?0x8040:0); + const unsigned control=tmb::test::referenceControl(((saved|0x1f80)&~0xe040u)|(mode<<13)|(n&1?0x8040:0)); // generated code on both sides: the game's rounding _mm_setcsr(control); auto a=initial,b=initial; rt.functions.setOverride(0x1da238,mathfMulVec4x4__FPA3_fP8_fvectorT1_0x1da238); rt.functions.setOverride(0x1db0f0,mathfUnitMatrixAsm__FPA3_f_0x1db0f0); @@ -146,7 +147,7 @@ int main() rt.functions.setOverride(0x1da238,point);rt.functions.setOverride(0x1db0f0,identity); try{caller(ram,&b,&rt);}catch(const bozo::ee::StopGuest&){require(b.pc==0xbad0000,"native caller stopped early");} const unsigned after=_mm_getcsr();_mm_setcsr(saved); - if(!cpu(a,b,initial)||std::memcmp(arenaExpected.get(),ram+0x10000,0x40000)||after!=control|| + if(!cpu(a,b,initial)||std::memcmp(arenaExpected.get(),ram+0x10000,0x40000)||!tmb::test::sameControl(after, control)|| (n<8&&std::memcmp(full.get(),ram,bozo::kFlatBytes))) {std::fprintf(stderr,"FAIL caller kind%u case%u mode%u CPU%d\n",kind,n,mode,cpu(a,b,initial));return 2;} ++callers; diff --git a/tests/native_sphere_lod_callers.cpp b/tests/native_sphere_lod_callers.cpp index 5b15cc5..7f9fd9b 100644 --- a/tests/native_sphere_lod_callers.cpp +++ b/tests/native_sphere_lod_callers.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT // Actual sphere/LOD decisions and hierarchy-helper consumers, compiled from the local game ELF. +#include "host_control.h" #include "tmb_port.h" #include "tmb_native_math.h" #include "tmb_hierarchy_math.h" @@ -145,7 +146,7 @@ void testSphereLodCallers() std::memset(ram + 0x13000, 0, 12); word(0x14000, 0x40400000); word(0x14004, 0x40800000); word(0x14008, 0); } snapshot(input.get()); auto a = initial, b = initial; - const unsigned control = ((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u); + const unsigned control = tmb::test::referenceControl(((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u)); // generated code on both sides: the game's rounding host.enabled = false; services.yields = 0; services.stop = 0xffffffff; _mm_setcsr(control); try { function(ram, &a, rt.get()); } @@ -156,9 +157,9 @@ void testSphereLodCallers() snapshot(expected.get()); if (n < 4) { std::memcpy(whole.get(), ram, bozo::kFlatBytes); ++memoryCases; } restore(); host.enabled = true; services.yields = 0; _mm_setcsr(control); function(ram, &b, rt.get()); const auto after = _mm_getcsr(); _mm_setcsr(saved); - if (!cpuEqual(a, b) || !vuUntouched(initial, b) || after != refControl || services.yields != refYields || !dataEqual() || + if (!cpuEqual(a, b) || !vuUntouched(initial, b) || !tmb::test::sameControl(after, refControl) || services.yields != refYields || !dataEqual() || (n < 4 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) - { std::fprintf(stderr, "FAIL sphere/LOD kind %u case %u mode %u CPU%d VU%d FP%d data%d\n", kind,n,mode,cpuEqual(a,b),vuUntouched(initial,b),after==refControl,dataEqual()); throw std::runtime_error("sphere/LOD caller differs"); } + { std::fprintf(stderr, "FAIL sphere/LOD kind %u case %u mode %u CPU%d VU%d FP%d data%d\n", kind,n,mode,cpuEqual(a,b),vuUntouched(initial,b),tmb::test::sameControl(after, refControl),dataEqual()); throw std::runtime_error("sphere/LOD caller differs"); } require(b.pc == 0xbad0000 && getRegU32(&b, 29) == address(sp), "sphere/LOD return ABI"); ++cases; } std::printf("sphere/LOD: %u complete generated callers, %u whole-memory checks; complete CPU/clock/FP/selection exact outside retired VU/local W; native VU untouched\n", cases, memoryCases); @@ -221,16 +222,16 @@ void testSphereLodCallers() throw std::runtime_error("hierarchy helper continuation did not reach its query boundary"); }; auto a = initial, b = initial; - const auto control = ((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u); + const auto control = tmb::test::referenceControl(((saved | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1 ? 0x8040u : 0u)); // generated code on both sides: the game's rounding _mm_setcsr(control); try { run(false, a); } catch (...) { std::fprintf(stderr, "hierarchy original kind %u case %u\n", kind, n); throw; } const auto refControl = _mm_getcsr(); const auto refYields = services.yields; snapshot(expected.get()); if (n < 4) { std::memcpy(whole.get(), ram, bozo::kFlatBytes); ++helperMemory; } restore(); _mm_setcsr(control); run(true, b); const auto after = _mm_getcsr(); _mm_setcsr(saved); - if (!cpuEqual(a,b) || !vuUntouched(initial,b) || after != refControl || services.yields != refYields || !dataEqual() || + if (!cpuEqual(a,b) || !vuUntouched(initial,b) || !tmb::test::sameControl(after, refControl) || services.yields != refYields || !dataEqual() || (n < 4 && std::memcmp(whole.get(),ram,bozo::kFlatBytes))) - { std::fprintf(stderr,"FAIL hierarchy helper %x case %u mode %u CPU%d VU%d FP%d data%d\n",caller,n,mode,cpuEqual(a,b),vuUntouched(initial,b),after==refControl,dataEqual()); throw std::runtime_error("hierarchy helper consumer differs"); } + { std::fprintf(stderr,"FAIL hierarchy helper %x case %u mode %u CPU%d VU%d FP%d data%d\n",caller,n,mode,cpuEqual(a,b),vuUntouched(initial,b),tmb::test::sameControl(after, refControl),dataEqual()); throw std::runtime_error("hierarchy helper consumer differs"); } ++helperCases; } _mm_setcsr(saved); diff --git a/tests/native_vehicle_tests.cpp b/tests/native_vehicle_tests.cpp index f636c70..7640b9d 100644 --- a/tests/native_vehicle_tests.cpp +++ b/tests/native_vehicle_tests.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT // Compare actual generated original blocks against the production instruction dispatcher, including ordered aliases. +#include "host_control.h" #include "tmb_vehicle_math.h" #include "tmb_native_math.h" #include "tmb_vehicle_original.h" @@ -100,11 +101,12 @@ int main() if (site.translation) setRegU32(&initial, site.translation, (translation | alias) + ((n >> 8u) & 15u)); R5900Context original = initial, native = initial; const unsigned control = ((savedControl | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1u ? 0x8040u : 0u); - _mm_setcsr(control); + _mm_setcsr(tmb::test::referenceControl(control)); originalBlock(index, ram, original, rt.get()); std::memcpy(expected.data(), arena, arenaBytes); if (n < 8) { std::memcpy(whole.get(), ram, bozo::kFlatBytes); ++wholeCases; } std::memcpy(arena, input.data(), arenaBytes); + _mm_setcsr(control); for (uint32_t pc = site.first; pc <= site.last; pc += 4) { if (!handler(ram, &native, rt.get(), pc)) return 2; @@ -113,10 +115,10 @@ int main() const unsigned after = _mm_getcsr(); _mm_setcsr(savedControl); if (std::memcmp(arena, expected.data(), arenaBytes) || std::memcmp(&native, &initial, sizeof(initial)) || - after != control || (n < 8 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) + !tmb::test::sameControl(after, control) || (n < 8 && std::memcmp(whole.get(), ram, bozo::kFlatBytes))) { std::fprintf(stderr, "FAIL vehicle block %u case %u mode %u: memory %d CPU/VU %d host %d\n", index, n, mode, - std::memcmp(arena, expected.data(), arenaBytes), std::memcmp(&native, &initial, sizeof(initial)), after == control); + std::memcmp(arena, expected.data(), arenaBytes), std::memcmp(&native, &initial, sizeof(initial)), tmb::test::sameControl(after, control)); return 4; } host.enabled = false; @@ -177,7 +179,7 @@ int main() for (auto &v : initial.vu0_vf) for (auto &bits : v.u) bits = randomBits(); initial.vu0_vf[0] = Vu0Vector{}; initial.vu0_vf[0].u[3] = 0x3f800000; R5900Context original = initial, native = initial; - const unsigned control = ((savedControl | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1u ? 0x8040u : 0u); + const unsigned control = tmb::test::referenceControl(((savedControl | 0x1f80u) & ~0xe040u) | (mode << 13u) | (n & 1u ? 0x8040u : 0u)); // generated code on both sides: the game's rounding _mm_setcsr(control); host.enabled = false; vehicleSetCsMat__7Vehicle_0x1ab250(ram, &original, rt.get()); @@ -195,10 +197,10 @@ int main() std::memset(reinterpret_cast(&native) + vuAt, 0, vuBytes); std::memset(reinterpret_cast(&original) + vuAt, 0, vuBytes); if (std::memcmp(ram + vehicle, callerExpected.get(), callerBytes) || std::memcmp(&original, &native, sizeof(native)) || - !untouched || after != control || (n < 4 && std::memcmp(ram, whole.get(), bozo::kFlatBytes))) + !untouched || !tmb::test::sameControl(after, control) || (n < 4 && std::memcmp(ram, whole.get(), bozo::kFlatBytes))) { std::fprintf(stderr, "FAIL complete vehicleSetCsMat case %u mode %u: memory %d CPU %d VU %d host %d\n", n, mode, - std::memcmp(ram + vehicle, callerExpected.get(), callerBytes), std::memcmp(&original, &native, sizeof(native)), untouched, after == control); + std::memcmp(ram + vehicle, callerExpected.get(), callerBytes), std::memcmp(&original, &native, sizeof(native)), untouched, tmb::test::sameControl(after, control)); return 8; } if (native.cycles != 16 || native.checkpoints != 2 || native.pc != 0xbad0000) return 9; From b1aa812ed731d26354e8d3f85e70f59710bc0801 Mon Sep 17 00:00:00 2001 From: Thomas Martin <304581853+boubou666@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:13:46 +0100 Subject: [PATCH 3/3] BozoEngine at master e15775a (#131 merged; same tree as 7521b3e) Co-Authored-By: Claude Opus 5.5 --- BozoEngine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BozoEngine b/BozoEngine index 7521b3e..e15775a 160000 --- a/BozoEngine +++ b/BozoEngine @@ -1 +1 @@ -Subproject commit 7521b3ee073c342dc65402051c02f7ae6769601b +Subproject commit e15775a22d9c800cd5908b85205d8820958e70c5