mirror of
https://github.com/patchzyy/wiicompiled
synced 2026-09-30 07:51:54 -04:00
0d04be19d6
* macos: add x86_64 Intel support * aurora: construct texture replacement index entries * Switch back to LLVM 22 so build can succeed on at least some systems (#141) two upstream LLVM bugs currently prevent building on some of the newest distros. There is no current LLVM release that works on them so we are pending fixes from LLVM https://github.com/patchzyy/Wiicompiled/issues/136 * Fix GC Pocket+ rumble stop handling (#148) * macos: package universal setup tools * ci: build macOS input expression tests * runtime: Do not force 14.0 minimum anymore new minimum is 12.0 * Update network_socket.cpp * fix(macos): increase guest fiber stack size (#154) * v0.2.28 * Update settings_overlay.cpp * macos: support older libc++ algorithms * Load console identity from NAND setting.txt (#164) * Add synthetic recompilation CI workflow (#161) * version * macos: allow undefined MTLLogStateDescriptor for older SDKs * tests: deflake input expression timing window test * import setting.txt (#169) * import setting.txt * coderabbit ugh * Treat empty MKW save as missing rather than corrupt (#168) * treat empty mkw save as missing first-run format zero-fills rksys.dat before any real save; a quit before the first save left an all-zero file that read back as corrupt and trapped the user in a delete/recreate loop. read opens now treat an all-zero rksys.dat as absent (a real save always begins with the RKSD0006 header), so the game recreates it from scratch. also ignore native build output. * shorten * I dont really want to change this to be honest. * extra safety --------- Co-authored-by: patchzyy <64382339+patchzyy@users.noreply.github.com> * version 0.2.30 * csnum fix * update * build: Fix mac tests * translator: emit null statement after continuation labels for C++17 compatibility * review fixes --------- Co-authored-by: theofficialgman <28281419+theofficialgman@users.noreply.github.com> Co-authored-by: Cristian Boehm <75502884+GalaxisBeast@users.noreply.github.com> Co-authored-by: patchzyy <64382339+patchzyy@users.noreply.github.com> Co-authored-by: Wubbzee <41394708+JGM01@users.noreply.github.com>
82 lines
4.0 KiB
C++
82 lines
4.0 KiB
C++
#include "sc_serial_contract.h"
|
|
#include "nand_settings.h"
|
|
|
|
#include <algorithm>
|
|
#include <array>
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
static void Require(bool condition, const char* message) {
|
|
if (!condition) throw std::runtime_error(message);
|
|
}
|
|
|
|
static uint32_t ReadWord(const unsigned char* bytes) {
|
|
return (uint32_t(bytes[0]) << 24) | (uint32_t(bytes[1]) << 16) |
|
|
(uint32_t(bytes[2]) << 8) | uint32_t(bytes[3]);
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
try {
|
|
// Feed real generator + SC ABI outputs to the upstream bot decoder.
|
|
// Usage: mkw_sc_serial_tests --timestamp-vectors <unix-seconds> ...
|
|
if (argc > 1 && std::string(argv[1]) == "--timestamp-vectors") {
|
|
for (int i = 2; i < argc; ++i) {
|
|
const auto timestamp = std::stoll(argv[i]);
|
|
const auto serial = RuntimeNandSettings::GenerateSerial(static_cast<std::time_t>(timestamp));
|
|
std::array<unsigned char, 4> output{};
|
|
Require(RuntimeScSerial::Write(serial, 4,
|
|
[](uint32_t address, size_t size) { return address == 4 && size == 4; },
|
|
[&](uint32_t, uint32_t value) {
|
|
for (unsigned j = 0; j < 4; ++j)
|
|
output[j] = static_cast<unsigned char>(value >> (24 - 8 * j));
|
|
}) == 1, "Generated serial must pass SC ABI");
|
|
std::cout << timestamp << '\t' << serial << "\tLEH"
|
|
<< std::setfill('0') << std::setw(9) << ReadWord(output.data()) << '\n';
|
|
}
|
|
return 0;
|
|
}
|
|
// Reproduce the reported csnums from the old string-writing override.
|
|
const unsigned char old7886[] = {'7', '8', '8', '6'};
|
|
const unsigned char old7618[] = {'7', '6', '1', '8'};
|
|
Require(ReadWord(old7886) == 926431286, "Reproduce shared LEH926431286");
|
|
Require(ReadWord(old7618) == 926298424, "Reproduce shared LEH926298424");
|
|
|
|
std::array<unsigned char, 16> memory;
|
|
size_t available = 4;
|
|
unsigned writes = 0;
|
|
const auto contains = [&](uint32_t address, size_t size) {
|
|
return address == 4 && size <= available;
|
|
};
|
|
const auto write32 = [&](uint32_t address, uint32_t value) {
|
|
++writes;
|
|
for (unsigned i = 0; i < 4; ++i)
|
|
memory[address + i] = static_cast<unsigned char>(value >> (24 - 8 * i));
|
|
};
|
|
for (const auto& pair : {std::pair{"788600001", 788600001u}, {"788699999", 788699999u},
|
|
{"761800001", 761800001u}, {"761899999", 761899999u},
|
|
{"012345678", 12345678u}, {"000000001", 1u}, {"999999999", 999999999u}}) {
|
|
memory.fill(0xa5);
|
|
writes = 0;
|
|
Require(RuntimeScSerial::Write(pair.first, 4, contains, write32) == 1, "Accept an exactly four-byte output buffer");
|
|
Require(writes == 1 && ReadWord(memory.data() + 4) == pair.second, "Return full numeric serial, including digits after common prefix");
|
|
for (size_t i = 0; i < memory.size(); ++i)
|
|
if (i < 4 || i >= 8) Require(memory[i] == 0xa5, "Do not overwrite adjacent guest stack data");
|
|
}
|
|
for (const char* serial : {"", "1234567890", "7886x1234", "-12345678", "+12345678"}) {
|
|
writes = 0;
|
|
Require(RuntimeScSerial::Write(serial, 4, contains, write32) == 0 && writes == 0, "Reject malformed serial without a write");
|
|
}
|
|
writes = 0;
|
|
Require(RuntimeScSerial::Write("788600001", 0, contains, write32) == 0 && writes == 0, "Reject null output");
|
|
available = 3;
|
|
Require(RuntimeScSerial::Write("788600001", 4, contains, write32) == 0 && writes == 0, "Reject undersized output");
|
|
std::cout << "SC serial collision reproduction, numeric output and memory-boundary tests passed\n";
|
|
return 0;
|
|
} catch (const std::exception& error) {
|
|
std::cerr << error.what() << '\n';
|
|
return 1;
|
|
}
|
|
}
|