native-platform-porting

Guide native source-level porting between different hardware architectures and operating systems without using emulation or interpretation. Applicable to porting host or legacy source code (e.g., PlayStation, N64, embedded systems, or DOS) to modern platforms (e.g., Windows, Linux, or macOS), including replacing hardware-specific SDKs or coprocessors with native APIs, building hardware abstraction layers (HALs), and avoiding covert emulation during codebase migration.

Last repository push
GitHub Stars
257
Forks
18
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "native-platform-porting" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-9320d192cc19c072659112db93ab513dd52b4eea69493587ed49d75db5712269. Verify the upstream source and version against https://github.com/lemiur/Game-Decompilation-Skill-For-Claude before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Guide native source-level porting between different hardware architectures and operating systems without using emulation or interpretation. Applicable to porting host or legacy source code (e.g., PlayStation, N64, embedded systems, or DOS) to modern platforms (e.g., Windows, Linux, or macOS), including replacing hardware-specific SDKs or coprocessors with native APIs, building hardware abstraction layers (HALs), and avoiding covert emulation during codebase migration.

0 Downloads

Introduction source: third_party · lemiur · 0.0.1 Reference

SkillPi interpretation

Tasks
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.
Audience
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.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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.

Current listing version

0.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

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

Highlights

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

Areas to improve

  • When to Use 章节排版 Reported severity: Minor

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

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

Highlights

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

Highlights

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

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

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

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.