Skip to content

jiangxincode/Native32Emu

Repository files navigation

Native32 Emulator —— A Native32 game emulator written in Rust

Native32 Emulator

Website CI Gitlab Pipeline Status Release Downloads Quality Gate Status License: BSD 3-Clause Discord QQ Group

Native32 is a game format developed by Sunplus for DVD player and TV chipsets (circa 2005–2011). Games use .smf, .sgm, or .ssl file extensions and feature a stack-based, ActionScript-like virtual machine with raster graphics.

Features

  • Full Native32 format support — file loading, header decryption, resource table parsing
  • YUV & ARGB image decoding — with packbits/RLE decompression and color space conversion
  • Action bytecode VM — 36 opcodes covering arithmetic, logic, string ops, control flow, sprites, and I/O
  • Sprite/movie system — animation, cloning, visibility control, depth-sorted rendering
  • Audio playback — finite/infinite-loop MP3 music mixed with raw 16-bit PCM sound effects (11025Hz for YUV games, 22050Hz for ARGB games), output as stereo with mono sources duplicated across both channels
  • MPEG-1 cutscenes — pure-Rust MPEG-1 video + MP2 audio decoder plays SSL_PlayNext logo/cutscene videos (no C dependency); skippable with A/B
  • ZIP archive support — load game packages directly from .zip files (auto-extracts and loads FHUI.smf)
  • Keyboard input — configurable key remapping
  • Save system.ssl_sav file persistence
  • SSL multi-file content — seamless switching between game levels/files
  • CLI controls — scaling, fullscreen, volume adjustment
  • Cheat system — modify VM variables, sprite properties, and frame state at runtime; includes debug logging to discover cheat targets
  • RetroArch integration — libretro core for use with RetroArch frontend

Usage

Standalone Mode

Download the latest binary from the Releases page and run:

native32-emu path/to/game.smf

See the Standalone Emulator guide for installation, ZIP menu behavior, keyboard controls, cheats, display settings, and all command-line options.

RetroArch Mode

Install Native32 (Native32Emu) from RetroArch's Core Downloader, or install the release files manually, then load a supported game through Load Content.

See the RetroArch Core guide for installation, supported platforms and features, RetroPad mapping, core options, and cheats.

Building

Requires Rust (stable).

Standalone Mode (Default)

cargo build -p native32emu --release
cargo run -p native32emu --release -- path/to/game.smf
cargo run -p native32emu --release -- -f path/to/game.smf

The binary is produced at target/release/native32-emu.

Libretro Core (for RetroArch)

cargo build -p native32emu-libretro --release

Cargo names the cdylib after its lib target, so this produces native32emu.dll on Windows (libnative32emu.so on Linux, libnative32emu.dylib on macOS) under target/release/. RetroArch expects the core file to be named native32emu_libretro.<ext>, so rename it accordingly before dropping it into RetroArch's cores/ directory.

For Android cross-compilation, see Android Libretro Core. For iOS, see iOS Libretro Core.

Testing

Run the unit tests:

cargo test --workspace

There is also a smoke test that loads every available game, runs it for a number of frames, and checks that the emulator neither panics nor produces a blank frame. It needs the (non-distributed) game assets, so it is #[ignore]d by default and run on demand:

# Uses <repo>/tmp/native32_game by default, or set NATIVE32_GAME_DIR
cargo test -p native32emu-core --test smoke -- --ignored --nocapture

Architecture

crates/
├── native32emu-core/            # Platform-independent emulator engine (library)
│   └── src/
│       ├── lib.rs               # Crate root (module declarations)
│       ├── emulator.rs          # Shared Emulator + VmHost (both front-ends)
│       ├── actions.rs           # Action opcode enum (36 opcodes)
│       ├── action_vm.rs         # Stack-based virtual machine
│       ├── audio_engine.rs      # MP3/PCM audio (rodio for standalone, buffer for libretro)
│       ├── content_loader.rs    # SSL multi-file content switching
│       ├── dat_loader.rs        # .dat metadata / thumbnail decoder (front-end menu)
│       ├── des_constants.rs     # DES permutation tables and S-boxes
│       ├── error.rs             # Error types
│       ├── file_browser.rs      # FHUI front-end game-list directory enumeration
│       ├── file_loader.rs       # File I/O, header parsing, resource tables
│       ├── frame_player.rs      # Main timeline frame playback (30fps)
│       ├── header_decryptor.rs  # Custom DES ECB header decryption
│       ├── image_decoder.rs     # YUV 4:2:0 and ARGB1555 image decoders
│       ├── input_handler.rs     # Input to keycode mapping (keyboard / RetroPad)
│       ├── renderer.rs          # Frame rendering with depth sorting
│       ├── save_manager.rs      # Save data persistence (.ssl_sav)
│       └── sprite_system.rs     # Movie/sprite instance management
├── native32emu/                 # Standalone binary (-> native32-emu)
│   └── src/
│       ├── main.rs              # Window loop and thin front-end
│       └── standalone/
│           ├── cli.rs           # Command-line argument parsing
│           └── gamepad_overlay.rs  # On-screen virtual gamepad overlay
└── native32emu-libretro/        # libretro cdylib (-> native32emu_libretro.{dll,so,dylib})
    ├── native32emu_libretro.info   # RetroArch core metadata
    └── src/
        ├── lib.rs               # cdylib crate root
        └── libretro/
            ├── api.rs           # Exported libretro functions (retro_init, retro_run, etc.)
            ├── callbacks.rs     # Callback management for video/audio/input
            ├── constants.rs     # libretro constants
            ├── logger.rs        # Bridges the `log` crate to the libretro log interface
            └── types.rs         # libretro type definitions

Game Compatibility

Game resources can be downloaded from Baidu Netdisk.

All 84 Native32 games in the test suite load and run without fatal errors.

Category Count Status
Main Menu 1 ✅ Pass
EACT (Action) 11 ✅ Pass
EELA (Educational) 32 ✅ Pass
EPOP (Hot/Featured) 9 ✅ Pass
EPUZ (Puzzle) 24 ✅ Pass
ESPG (Sport) 3 ✅ Pass
ETAB (Chess/Board) 4 ✅ Pass
Total 84 ✅ All Passed

For detailed game list with screenshots and descriptions, see Game Compatibility.

Contribute

Contributions are welcome! Whether you're interested in fixing bugs, adding features, improving documentation, or testing game compatibility, we'd love your help. See CONTRIBUTING.md for details.

Acknowledgments

License

This project is licensed under the BSD 3-Clause License.

About

A Native32 game emulator written in Rust.

Topics

Resources

License

Contributing

Stars

36 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors