release: prepare NESLite 1.0.0 with dual cores and signed packaging

This commit is contained in:
2026-09-14 17:30:37 +08:00
parent e3842c21dc
commit fefca3ca68
68 changed files with 1819 additions and 592 deletions
@@ -0,0 +1,50 @@
#include <array>
#include <iostream>
#include "core_catalog.h"
#include "save_package.h"
#include "save_state.h"
#include "video_buffer.h"
#include "video_conversion.h"
int main() {
using namespace neslite;
CoreKind kind = CoreKind::Fceumm;
if (!parse_core_kind("nestopia", &kind) || kind != CoreKind::Nestopia ||
parse_core_kind("../external.so", &kind)) return 1;
const std::filesystem::path base("saves");
if (core_save_base(base, CoreKind::Fceumm) != base ||
core_save_base(base, CoreKind::Nestopia) != base / "cores" / "nestopia") return 2;
if (!core_package_compatible("", CoreKind::Fceumm) || core_package_compatible("", CoreKind::Nestopia) ||
core_package_compatible(core_package_identity(CoreKind::Nestopia), CoreKind::Fceumm)) return 3;
const std::string identity = core_package_identity(CoreKind::Nestopia);
const auto encoded = encode_save_package(std::string(64, 'a'),
{{"core.txt", {identity.begin(), identity.end()}}, {"battery/battery.sav", {1, 2}}});
DecodedSavePackage package;
std::string error;
if (!decode_save_package(encoded, &package, &error) || package.entries.size() != 2 ||
!core_package_compatible(std::string(package.entries[0].bytes.begin(), package.entries[0].bytes.end()),
CoreKind::Nestopia)) return 4;
SaveStateMetadata metadata;
metadata.rom_hash = std::string(64, 'a');
metadata.core_name = "FCEUmm";
metadata.core_commit = core_descriptor(CoreKind::Fceumm).commit;
if (save_state_compatible(metadata, metadata.rom_hash, "Nestopia",
std::string(core_descriptor(CoreKind::Nestopia).commit), "", &error) || error != "core_name") return 5;
const std::array<std::uint32_t, 4> xrgb{0x00ff0000, 0x0000ff00, 0x000000ff, 0};
std::vector<std::uint16_t> pixels;
if (!convert_to_rgb565(xrgb.data(), 3, 1, 16, 1, &pixels) ||
pixels != std::vector<std::uint16_t>{0xf800, 0x07e0, 0x001f}) return 6;
const std::array<std::uint16_t, 3> rgb1555{0x7c00, 0x03e0, 0x001f};
if (!convert_to_rgb565(rgb1555.data(), 3, 1, 6, 0, &pixels) ||
pixels != std::vector<std::uint16_t>{0xf800, 0x07e0, 0x001f}) return 7;
if (convert_to_rgb565(xrgb.data(), 3, 1, 8, 1, &pixels) ||
convert_to_rgb565(nullptr, 3, 1, 16, 1, &pixels)) return 8;
VideoBuffer video;
VideoFrame before, after;
if (!video.submit(rgb1555.data(), 3, 1, 6, 2, 2) || !video.latest(&before)) return 9;
video.clear();
if (video.latest(&after) || !video.submit(rgb1555.data(), 3, 1, 6, 2, 2) ||
!video.latest(&after) || after.sequence <= before.sequence) return 10;
std::cout << "Core selection, save isolation and pixel conversion passed.\n";
return 0;
}
@@ -0,0 +1,26 @@
#include <iostream>
#include <string>
#include "rom_compatibility.h"
int main() {
using namespace neslite;
const std::string hash = "f2fa5c9e40dc68e25fc9d9a4d5f2d5c9179c393d16c0d4e76f843aa17a6df981";
const auto profile = rom_compatibility_for(hash);
if (profile != RomCompatibility::LongZhuYingXiongDendy ||
compatibility_profile_name(profile) != "long-zhu-ying-xiong-dendy-v1") return 1;
if (compatibility_core_option(profile, CoreKind::Fceumm, "fceumm_region") != "Dendy" ||
compatibility_core_option(profile, CoreKind::Nestopia, "nestopia_force_system") != "dendy") return 2;
// Same title is not identity; neither a filename nor a neighboring hash can opt in.
for (const auto& other : {std::string{}, std::string("Long Zhu Ying Xiong.nes"), hash.substr(1),
std::string("0") + hash.substr(1)}) {
const auto fallback = rom_compatibility_for(other);
if (fallback != RomCompatibility::Default ||
compatibility_core_option(fallback, CoreKind::Fceumm, "fceumm_region") ||
compatibility_core_option(fallback, CoreKind::Nestopia, "nestopia_force_system")) return 3;
}
if (compatibility_core_option(profile, CoreKind::Fceumm, "fceumm_sndquality") ||
compatibility_core_option(profile, CoreKind::Nestopia, "nestopia_favored_system") ||
compatibility_core_option(profile, CoreKind::Nestopia, "fceumm_region")) return 4;
std::cout << "Exact ROM compatibility and per-core option isolation passed.\n";
return 0;
}
@@ -0,0 +1,56 @@
#include <iostream>
#include <vector>
#include "video_buffer.h"
#include "video_viewport.h"
namespace {
bool expect_viewport(const char* label, const neslite::VideoViewport& actual,
int x, int y, int width, int height) {
if (actual.x == x && actual.y == y && actual.width == width && actual.height == height) return true;
std::cerr << label << ": got " << actual.x << ',' << actual.y << ' ' << actual.width << 'x'
<< actual.height << ", expected " << x << ',' << y << ' ' << width << 'x' << height << '\n';
return false;
}
}
int main() {
using namespace neslite;
// Nestopia composite output: 602 texture samples represent 256 NES pixels.
VideoBuffer video;
const std::vector<std::uint16_t> filtered(602 * 224, 0x1234);
VideoFrame frame;
if (!video.submit(filtered.data(), 602, 224, 602 * 2, 2, 2, 256, 224) || !video.latest(&frame)) return 1;
if (frame.width != 602 || frame.height != 224 || frame.pitch != 1204 ||
frame.bytes.size() != filtered.size() * 2 || frame.base_width != 256 || frame.base_height != 224) return 2;
if (!expect_viewport("filtered NES integer", calculate_video_viewport(1664, 1248,
frame.base_width, frame.base_height, true), 192, 64, 1280, 1120)) return 3;
if (!expect_viewport("switch to 4:3", calculate_video_viewport(1920, 1080,
frame.base_width, frame.base_height, false), 240, 0, 1440, 1080)) return 4;
if (!expect_viewport("resized integer", calculate_video_viewport(1000, 750,
frame.base_width, frame.base_height, true), 116, 39, 768, 672)) return 5;
const auto previous_sequence = frame.sequence;
if (video.submit(nullptr, 256, 240, 512, 2, 2, 256, 240) || !video.latest(&frame) ||
frame.sequence != previous_sequence || frame.base_height != 224 || frame.width != 602) return 6;
// A newly submitted frame carries changed geometry; no dimension from the previous core survives.
video.clear();
const std::vector<std::uint16_t> native(256 * 240, 0xabcd);
if (video.latest(&frame) || !video.submit(native.data(), 256, 240, 512, 2, 2, 256, 240) ||
!video.latest(&frame) || frame.sequence <= previous_sequence || frame.base_height != 240) return 7;
if (!expect_viewport("uncropped NES integer", calculate_video_viewport(1664, 1248,
frame.base_width, frame.base_height, true), 192, 24, 1280, 1200)) return 8;
// Missing/incomplete geometry falls back as a pair to the actual frame size.
if (!video.submit(native.data(), 256, 224, 512, 2, 2, 0, 240) || !video.latest(&frame) ||
frame.base_width != 256 || frame.base_height != 224) return 9;
if (!expect_viewport("native NES integer", calculate_video_viewport(1664, 1248,
frame.base_width, frame.base_height, true), 192, 64, 1280, 1120)) return 10;
if (!expect_viewport("exact 1x", calculate_video_viewport(256, 224, 256, 224, true),
0, 0, 256, 224)) return 11;
if (!expect_viewport("smaller than 1x", calculate_video_viewport(200, 150, 256, 224, true),
14, 0, 171, 150)) return 12;
if (!expect_viewport("invalid surface", calculate_video_viewport(0, 150, 256, 224, true),
0, 0, 0, 0) || !expect_viewport("invalid geometry", calculate_video_viewport(200, 150, 0, 224, true),
0, 0, 0, 0)) return 13;
std::cout << "Integer/4:3 viewport, filtered geometry, frame handoff and size boundaries passed.\n";
return 0;
}