catzng

catzng

A modern C++ engine that brings PF Magic's virtual pets back to life

Reverse-engineered reimplementation of the Catz, Dogz, and Oddballz engines (1995-1996)

Features • Quick Start • How It Works • File Formats • Building • Research

--- ## What is this? **catzng** is a from-scratch C++17 reimplementation of the engine behind PF Magic's beloved 1990s virtual pet games. It reads the original game data files and renders the creatures using the same ball-and-stick technique that made these games iconic. ``` ╭──── earL earR ────╮ │ ◉ head ◉ │ whiskers ◉ snout ◉ whiskers ◉ chin ◉ │ ◉ neck ◉ │ shoulder ◉─chest─◉ shoulder elbow ◉ │ ◉ elbow hand ◉ belly ◉ hand │ ◉ butt ◉ / \ hip ◉ ◉ hip knee ◉ ◉ knee ankle ◉ ◉ ankle sole ◉ ◉ sole tail ◉──◉──◉──◉──◉──◉ ``` Every creature is built from **spheres** connected by **lines** — no polygons, no textures (well, Oddballz added texture-mapped balls). The engine computes spring-based physics to give creatures their signature squishy, organic movement. --- ## Features ### Supported Games | Game | Status | Breeds/Creatures | |------|--------|-----------------| | **Catz** (1996) | Full support | Clown, Hunter, Persian, Scaredy Cat, Siamese | | **Dogz** (1995) | Partial | Bulldog, Chihuahua, Mastiff, Scottie, Terrier | | **Oddballz** (1996) | Research phase | Dynaroo, Honker, Lips, Modvark, Quadrapus, Walret, Zott | ### Engine Capabilities - **LNZ breed file parser** — Complete parsing of all breed definition sections - **BHD/BDT animation loader** — Binary animation header and frame data - **Ball-and-stick renderer** — Depth-sorted rendering with fuzz, outlines, whiskers - **Spring physics** — Glue-ball based physics for organic movement - **Dual palette support** — Both 256-color and 16-color modes - **Playscene backgrounds** — Load and display environment textures - **NE resource extraction** — Read game data from 16-bit Windows DLL resources - **Cross-platform** — Win32 GDI (native) or SDL2 (Linux/macOS) --- ## Quick Start ### 1. Build ```bash # Windows (Visual Studio) cmake -B build cmake --build build --config Release # Windows (MinGW) cmake -B build -G "MinGW Makefiles" cmake --build build # Linux / macOS (requires SDL2) cmake -B build -DUSE_SDL2=ON cmake --build build ``` ### 2. Add Game Files Place your legally obtained game files in the `catz/` directory: ``` catzng/ ├── catz/ │ ├── PTZFILES/ │ │ ├── CAT/RESOURCE/ ← LNZ, BHD, BDT, SCP files │ │ ├── DOG/RESOURCE/ │ │ ├── MOUSE/RESOURCE/ │ │ └── BOTTLE/RESOURCE/ │ └── playpenz/ ← Background BMP textures └── build/ └── catzng.exe ``` ### 3. Run ```bash ./build/catzng ``` ### Controls | Action | Input | |--------|-------| | Pet the creature | Left click and drag | | Pick up | Right click and hold | | Drop | Release right click | --- ## How It Works ### The Ball-and-Stick Engine PF Magic pioneered this rendering technique in their 1994 game *Ballz*. Every creature is composed of: 1. **Balls** — Spheres of varying sizes and colors, representing joints and body parts 2. **Lines** — Connections between balls, drawn with optional "fuzz" for fur texture 3. **Whiskers** — Thin tapered lines for facial features The rendering pipeline: ``` ┌─────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ Load LNZ │───▶│ Animate │───▶│ Physics │───▶│ Render │ │ (breed) │ │ (BHD/BDT)│ │ (springs)│ │ (balls) │ └─────────┘ └──────────┘ └──────────┘ └──────────┘ ``` ### Skeleton Architecture Each creature type has a unique skeleton: | Creature | Balls | Notable Features | |----------|-------|-----------------| | Cat | 67 | 6 whisker balls, 6 tail segments, 6 ear points | | Dog | 67+ | 6 eyebrow balls, nostril balls, more facial detail | | Mouse (toy) | 16 | Minimal: body, head, 4 limbs, tail | | Bottle (toy) | ~8 | Simple cylindrical shape | | Oddballz | Varies | Each creature is completely unique | ### Physics: The Glue Ball The "glue ball" (typically the chest) serves as the physics anchor. All other balls are connected through spring dynamics: ``` ╭─spring─╮ │ │ ball ◉──┤ GLUE ├──◉ ball │ BALL │ ╰─spring─╯ ``` This creates the signature squishy, bouncy movement. When the creature walks, the glue ball moves first, and all other balls follow with springy delay. --- ## File Formats ### Overview | Format | Type | Purpose | Parser Status | |--------|------|---------|:---:| | **LNZ** | Text INI | Breed definition (skeleton, colors, sizes) | ✅ | | **BHD** | Binary | Animation index header | ✅ | | **BDT** | Binary | Animation frame data (ball positions) | ✅ | | **SCP** | Binary | Behavior scripts (state machine) | ⚠️ | | **CAT** | Text INI | Pet save file (name, mood, colors) | ✅ | | **WAV** | Binary | Standard PCM audio | ✅ | | **WVV** | Binary | Compressed audio (ADPCM variant) | ⚠️ | | **WAD** | NE DLL | Resource container (legacy) | ✅ | | **ODD** | NE DLL | Oddballz creature bundle | ⚠️ | | **BMP** | Binary | Playscene backgrounds, textures | ✅ | | **PBT** | Text | Brain/behavior tree (Dogz) | ⬜ | ### LNZ Format Deep Dive LNZ is the heart of the breed system. Each file defines everything about a creature's appearance: ```ini [256 Ball Color] ; Per-ball color in 256-color palette 92 eBall_head ; Gray head 92 eBall_chest ; Gray chest 42 eBall_chin ; Light chin 0 eBall_nose ; Black nose 118 eBall_tongue1 ; Pink tongue [Linez] ; Connections between balls ; start, end, fuzz, color, leftColor, rightColor, startThick, endThick 6, 36, 1, -1, -1, -1, 95, 95 ; chest to neck (fuzzy) 3, 43, 1, -1, -1, -1, 100, 100 ; butt to tail1 (fuzzy) 55, 56, 1, -1, -1, -1, 100, 100 ; tongue segments [Fuzz] ; Fur texture per ball (0=smooth, 3=very fuzzy) 3 eBall_belly ; Fluffy belly 2 eBall_chest ; Moderate chest fuzz 0 eBall_nose ; Smooth nose ``` > For complete format documentation, see [docs/RESEARCH.md](docs/RESEARCH.md) --- ## Project Structure ``` catzng/ ├── include/catzng/ Headers │ ├── types.h Core data structures (Vec3, Ball, Line, Color) │ ├── lnz_parser.h LNZ breed file parser │ ├── skeleton.h 67-ball skeleton model │ ├── animation.h Animation playback system │ ├── animation_loader.h BHD/BHT animation loader │ ├── bdt_loader.h BDT frame data loader │ ├── pet.h Pet entity (state, mood, interaction) │ ├── physics.h Spring-based physics engine │ ├── renderer.h Abstract renderer interface │ ├── behavior.h AI behavior system │ └── interaction.h Mouse interaction manager ├── src/ │ ├── core/ File format parsers │ ├── engine/ Game engine (skeleton, animation, physics) │ ├── render/ Rendering backends (Win32 GDI, SDL2) │ └── game/ Game logic (behavior, interaction) ├── docs/ │ ├── RESEARCH.md Comprehensive reverse-engineering analysis │ ├── TECHNICAL.md Architecture and format specifications │ └── CONTRIBUTING.md Development guidelines ├── research/ Original game data analysis │ ├── downloads/ Archived game ISOs │ ├── extracted/ Extracted game files │ └── extract_resources.py NE resource extraction tool └── tests/ Unit tests ``` --- ## Static Recompilation (In Progress) We are pursuing **static recompilation** of the original game binaries using the [pcrecomp](https://github.com/sp00nznet) toolbox — lifting the original 16-bit x86 machine code directly to compilable C. ### Why Static Recomp? Rather than guessing at engine behavior through observation, static recompilation gives us **ground truth** — the exact original algorithms for physics, rendering, palette construction, fuzz textures, and AI behavior. ### Feasibility Analysis (Complete) The original binaries are 16-bit Windows NE (New Executable) format, compiled with MSVC 6.1: | Binary | Code Size | Functions | Instructions | Role | |--------|----------|-----------|-------------|------| | **CATZDLL.DLL** | 615 KB | 1,431 | 233,762 | Game engine (physics, rendering, AI) | | **CATZ.EXE** | 31 KB | 79+ | ~12K | Window shell, loader | | **SOSLIB03.DLL** | 58 KB | 96 | ~20K | Sound library (SOS/HMI) | | **DOGZ.EXE** | 29 KB | ~75 | ~11K | Dogz window shell | | **NEURON.DLL** | 6 KB | 4 | ~2K | Neural network AI (Dogz) | The entire game engine disassembles cleanly with only **4 unresolved far calls** out of thousands — these are indirect vtable calls, not missing data. ### Import Surface CATZDLL.DLL imports from 8 modules (120 unique API ordinals total): | Module | Refs | What | |--------|------|------| | KERNEL | 468 | Memory, files, segments | | GDI | 235 | Graphics (SelectObject, BitBlt, palettes) | | USER | 200 | Windows, messages, input | | SOSLIB03 | 48 | Digital audio + MIDI (replaceable with SDL2) | | WIN87EM | 6 | FPU emulation (skip on modern hardware) | | TOOLHELP | 5 | Debug (stub out) | | WING | 5 | Fast sprite blitting (replace with SDL2) | | MMSYSTEM | 4 | Multimedia timers | ### Pipeline Using the el-fish NE recompilation pipeline (adapted): ``` ne_parse.py → ne_decode.py → ne_lift.py → C source (Parse NE) (Disassemble) (Lift to C) (Compile) ``` ### Status - [x] Binary format analysis — all game executables parsed - [x] Feasibility confirmed — code lifts cleanly to C - [x] Import surface mapped — 120 unique Win16 API ordinals identified - [x] SOSLIB03 identified as sound-only library (not game framework) - [ ] Fix relocation chaining in NE parser (~60% more fixups) - [ ] Create Win16 API ordinal mappings (KERNEL/GDI/USER) - [ ] Build Win16 runtime shim (backed by SDL2) - [ ] Lift all segments and integrate build system - [ ] Match exported function names to C++ class methods (1,263 XApt exports) --- ## Research This project involved extensive reverse-engineering of three games from archive.org: | Source | Archive | |--------|---------| | Catz (1996) ISO | [archive.org](https://archive.org/details/Catz_Your_Computer_Petz_PF_Magic_1996) | | Dogz (1995) Floppies | [archive.org](https://archive.org/details/Dogz-ComputerPet) | | Oddballz (1996) ISO | [archive.org](https://archive.org/details/oddballz-1996) | | Combined Petz CD (1997) | [archive.org](https://archive.org/details/your-computer-petz-catz-dogz-oddballz-1997-pf-magic-cd) | ### Key Findings 1. **All three games share the same engine** — ball-and-stick rendering, spring physics, LNZ breed definitions 2. **Game resources are packed in 16-bit NE DLLs** — Bitmaps, sprites, palettes, and custom data are Windows resources 3. **Oddballz extends the engine** with texture-mapped balls and self-contained creature ODD files 4. **The skeleton system is remarkably flexible** — from 16-ball mice to 67+ ball dogs, all using the same LNZ format > Full research documentation: [docs/RESEARCH.md](docs/RESEARCH.md) ### Community Resources - [petz-file-formats](https://github.com/thenickdude/petz-file-formats) — Definitive file format documentation - [Petz Wiki](https://petz.miraheze.org/wiki/) — Community knowledge base - [myabandonware.com](https://www.myabandonware.com/) — Additional game archives --- ## Building from Source ### Requirements - **C++17** compiler (MSVC, GCC, Clang) - **CMake** 3.16+ - **SDL2** (optional, for cross-platform rendering) ### Build Options | Option | Default | Description | |--------|---------|-------------| | `USE_SDL2` | OFF | Use SDL2 instead of Win32 GDI | | `BUILD_TESTS` | ON | Build test executables | ### Platform-Specific Notes **Windows**: Uses Win32 GDI by default for authentic rendering. No additional dependencies needed. **Linux/macOS**: Requires SDL2. Install via your package manager: ```bash # Ubuntu/Debian sudo apt install libsdl2-dev # macOS brew install sdl2 # Fedora sudo dnf install SDL2-devel ``` --- ## Legal This is a clean-room reimplementation of the Petz engine. No copyrighted game code or assets are included in this repository. To use catzng, you need original game files from a legally obtained copy of Catz (1996/1997), Dogz (1995), or Oddballz (1996). **Catz**, **Dogz**, and **Oddballz** are trademarks of PF Magic / Ubisoft. This project is not affiliated with or endorsed by them. ---

Made with love for the Petz community