native-platform-porting

指导在不同硬件架构和操作系统之间进行原生源码级移植(不使用模拟或解释执行)。适用于将主机或遗留源码(如 PlayStation、N64、嵌入式系统或 DOS)移植到现代平台(如 Windows、Linux 或 macOS),包括替换硬件专用 SDK 或协处理器为原生 API、构建硬件抽象层(HAL),以及在代码库迁移过程中避免隐蔽的模拟行为。

仓库最近推送
GitHub Stars
257
Forks
18
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "native-platform-porting":https://skillpi.com/zh/skills/deepskill-9320d192cc19c072659112db93ab513dd52b4eea69493587ed49d75db5712269。安装前核对上游来源和版本:https://github.com/lemiur/Game-Decompilation-Skill-For-Claude。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

指导在不同硬件架构和操作系统之间进行原生源码级移植(不使用模拟或解释执行)。适用于将主机或遗留源码(如 PlayStation、N64、嵌入式系统或 DOS)移植到现代平台(如 Windows、Linux 或 macOS),包括替换硬件专用 SDK 或协处理器为原生 API、构建硬件抽象层(HAL),以及在代码库迁移过程中避免隐蔽的模拟行为。

0 下载

介绍来源: third_party · lemiur · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: native-platform-porting
description: Guide native source-level porting of software and games across hardware architectures and operating systems without emulation or interpretation. Use when the user asks to port console or legacy source code (such as PlayStation, N64, embedded, or DOS) to modern platforms (such as Windows, Linux, or macOS), replace hardware-specific SDKs or coprocessors with native APIs, build a Hardware Abstraction Layer (HAL), or avoid stealth emulation during codebase migration.

Native Platform Porting

Port software natively from a source architecture to a target platform by translating hardware-coupled logic into idiomatic host abstractions rather than emulating registers, memory maps, or coprocessor instructions.

When to Use

  • Porting legacy or console source code (e.g., Sony PlayStation PsyQ/MIPS, Nintendo, DOS, or embedded C/C++) to modern desktop OSes like Windows, Linux, or macOS.
  • Replacing hardware-level interfaces (DMA channels, custom coprocessors, memory-mapped I/O, or fixed-function pipelines) with native OS, audio, and graphics APIs (Win32, SDL, DirectX, Vulkan, OpenGL).
  • Refactoring 32-bit, fixed-memory-layout C/C++ codebases to compile cleanly on 64-bit native toolchains.
  • Preventing "stealth emulation" where an agent wraps old hardware packets or register states in an interpreter loop instead of rewriting the subsystem natively.

Steps

1. Audit Hardware Coupling and Identify Semantic Intent

Before modifying source files, catalog every direct hardware dependency and classify whether it lives in game/application logic or low-level driver code.

  • Locate inline assembly, coprocessor macros (such as PS1 GTE gte_* macros), memory-mapped register reads/writes, and proprietary SDK headers (such as libgpu.h, libgte.h, libspu.h).
  • Determine the high-level mathematical or structural intent behind low-level calls. Understanding the semantic goal prevents translating hardware workarounds literally onto the target platform.
  • Verification: Produce a dependency map listing each source hardware subsystem alongside its target native API equivalent before writing replacement code.

2. Enforce the Anti-Emulation Boundary

Define a Hardware Abstraction Layer (HAL) driven by application concepts (meshes, transforms, audio streams, input actions) rather than source hardware primitives (DMA linked lists, ordering tables, register bitfields, or Scratchpad RAM offsets).

  • Replace custom coprocessor routines with native math types and functions. For example, replace PlayStation GTE fixed-point COP2 instruction sequences with native matrix/vector math functions operating on standard structs, preserving fixed-point arithmetic only where deterministic gameplay physics require it.
  • Convert command-packet graphics submission (such as PS1 GPU ordering tables and packet buffers) into high-level draw calls accepted by a native rendering backend (DirectX, Vulkan, or OpenGL) rather than parsing binary GPU packets at runtime.
  • Replace raw CD-ROM sector reads and DMA transfers with asynchronous or standard host filesystem streams and native asset deserializers.
  • Verification: Grep the target platform layer for register bitmasks, virtual VRAM arrays, opcode switch-statements, or raw hardware address offsets (such as 0x1F800000). If present, refactor them into high-level interface calls.

3. Decouple Memory Layout and Data Representation

Legacy and console codebases frequently assume a 32-bit flat address space, specific endianness, and unaligned pointer casting that corrupts memory when compiled natively on 64-bit Windows or modern OSes.

  • Replace raw int, long, and pointer-cast fields in serialized structs with fixed-width integer types (int32_t, uint32_t, uint16_t) from <stdint.h>.
  • Separate in-memory runtime structs from on-disk binary formats. Write explicit deserialization routines instead of casting raw file buffers directly to C structs Containing pointers.
  • Eliminate Scratchpad RAM (fast local memory mapped at fixed addresses) by replacing fixed-address pointers with standard stack or heap allocations.
  • Verification: Compile the codebase targeting 64-bit (x86_64) with -Wall -Wextra -Wconversion (or /W4 on MSVC) and run with AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan) enabled to confirm zero pointer-truncation or alignment faults.

4. Re-architect Timing, Interrupts, and Control Flow

Console and embedded software often tie execution speed and state updates directly to hardware interrupts (VBlank, HBlank, hardware timers, or CD read callbacks).

  • Replace busy-wait loops polling hardware status bits with native OS synchronization primitives, callbacks, or event queues.
  • Decouple simulation tick rates from rendering frame rates using a delta-time accumulator or a fixed-timestep update loop so the software runs accurately regardless of monitor refresh rate.
  • Convert hardware interrupt service routines (ISRs) into standard thread-safe callbacks or main-loop polling hooks.
  • Verification: Run the compiled native binary with VSync disabled and confirm that simulation speed, audio pitch, and state transitions remain constant at arbitrary frame rates.

5. Incrementally Compile and Verify Subsystem Parity

Port one subsystem at a time using stubbed interfaces so the application compiles and links natively as early as possible.

  • Stub non-essential subsystems (audio, FMV playback, peripherals) with no-op native functions that return valid status codes so core logic and rendering can be verified first.
  • Write unit tests comparing the output of converted math/physics functions against known-good input/output pairs captured from the original source logic.
  • Verification: Build and execute the native binary after each subsystem replacement, confirming clean compilation and passing functional parity checks before moving to the next module.

Gotchas

  • Stealth Emulation via Packet/Register Shims: Agents often take the path of least resistance by allocating a fake uint8_t vram[1024*512] buffer or writing a switch(opcode) interpreter for hardware packets so they do not have to touch call sites. Avoid this by refactoring call sites to pass high-level primitives (vertices, texture handles, transform matrices) to the rendering interface.
  • Pointer-in-Struct Serialization: Console code frequently loads a binary file into RAM and patches raw 32-bit offsets into memory pointers in-place. On 64-bit Windows, a void* is 8 bytes while the file offset is 4 bytes, shifting every subsequent struct field. Always define separate DiskStruct (using uint32_t offsets) and RuntimeStruct (using native pointers).
  • Blindly Converting Fixed-Point to Float: While rendering transforms benefit from floating-point precision on PC, gameplay physics, collision detection, and deterministic state machines (like replays or AI thresholds) often rely on exact 16.16 or 20.12 fixed-point integer truncation. Keep fixed-point math in gameplay logic using standard integer arithmetic, and convert to float only at the rendering boundary.
  • Hidden SDK Macros: Proprietary SDK macros often hide direct hardware register mutations behind innocent-looking function names. Always expand or inspect macro definitions before deciding whether to reimplement a macro or replace its caller.

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值75/100

亮点

  • 针对遗留主机/嵌入式系统向现代平台移植的明确技术需求
  • 提供完整的原生移植方法论,避免模拟行为
  • 适用于开发者与逆向工程场景,具有实际工程价值
触发精准90/100

亮点

  • 触发描述清晰覆盖 PlayStation、N64、DOS 等源平台及 Windows/Linux/macOS 目标平台
  • 明确定义使用场景:替换硬件SDK、构建HAL、避免隐蔽模拟
  • 边界清晰,不易与其他 Skill 重叠
结构规范95/100

待提升项

  • When to Use 章节排版 原报告严重程度:轻微

    When to Use 内容实质存在但未作为独立一级标题突出显示

    改进建议:建议将 When to Use 提升为独立一级章节以增强可读性

亮点

  • Phase 划分清晰(5个步骤),每步含具体操作与验证方法
  • 包含端到端示例(如 GTE 固定点转换、命令包转绘制调用)
  • Gotchas 部分有效预警常见陷阱
  • frontmatter 完整,文档长度适中
执行可靠90/100

亮点

  • 工具链建议明确(SDL、DirectX、Vulkan、ASan/UBSan)
  • 编译参数具体(-Wall -Wextra -Wconversion, /W4)
  • 覆盖内存布局、指针截断、时序解耦等关键异常场景
  • 提供多维度验证手段(grep检查、编译测试、运行时检测)
证据可验 (前四项均值)88/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。