khdays-port

khdays-port is a native PC port of Kingdom Hearts 358/2 Days with modern controls, resolutions, and mod support.

README

khdays-port

Discord

A native PC port of Kingdom Hearts 358/2 Days, built on khdays-decomp.

The game is the decompilation's C, compiled for the PC; the port supplies what the Nintendo DS hardware did underneath it -- graphics, sound, input, the card, interrupts and the system calls of its SDK -- and, around it, what a PC version wants: modern controls, rendering, resolutions, a single-screen mode and replaceable content. This is how other decompilation-based ports work: the game code is the original's, readable and moddable; the platform layer is new.

Important

This repository contains no ROM, game assets, audio, video, text, SDK files or game binaries. You need your own legally obtained copy of the game.

Warning

The port is a work in progress and may have bugs. Reports are very welcome, in the issues or on Discord: what happened and what you were doing when it did.

AI-assisted coding tools were used to help make this possible.

Status

The whole game runs natively from the decompilation: the title and its menus, Story Mode (opening movie, days, cutscenes, the field), Mission Mode (character select, camp, missions, results), combat and magic, the shop, and a player's save loaded, played and saved again. Crashes found while playing are fixed as classes in the build's source preparation, and what they show about the C goes back to the decompilation (docs/DECOMP_FINDINGS.md).

Today it builds for Windows x64 (64-bit). It plays with the keyboard, the mouse or a gamepad, with remappable controls and optional enhancements (an analog camera among them). The picture is the port's own: the 2D composed by the port on the graphics card from what the game asks for, and the 3D's geometry answered by the port and drawn there too -- at up to eight times the DS's resolution, in widescreen, and with HD textures, models and 2D graphics from mods; the DS's own engines remain only as the reference the port is checked against. The sound is the port's own: the ARM7's sound driver in C, mixed at the PC's rate, with its own volumes and every sound replaceable from mods. So are the movies: decoded by the port, shown at full colour, their sound at its own volume, each replaceable by a video from a mod. No machine code of the DS runs: the port has no ARM interpreter, and what the decompilation keeps as assembly and the game calls is C the port wrote from it. The game's files reach it from the port as well: each read copied at once from a mod's file or the extracted data, with no card in between (the emulated card stays as the reference). The game's time is the port's too: its frames, its tick and alarms on the PC's clock, its interrupts taken where the game waits or unmasks them, nothing simulating the DS's timers or its display; and the 3D is drawn at the monitor's refresh rate, between the game's frames, which still come 30 a second as on the DS. The game's memory is the port's: a range Windows places, with each DS region at its DS address from its start, the game's pointers kept as references into it -- the DS's own addresses hold nothing. The HUD, the menus and the game's text are drawn anew by the port, each element placeable. Underneath, the game still sees a DS -- two screens one above the other, and the ARM7's services, which the port answers on the PC: the clock from the PC's, the save from its files.

On top of the game, a new edition from content the user provides: HD textures, models and 2D graphics, new rooms, sounds and videos, a single-screen mode, and Mission Mode's multiplayer.

Restored from what the game left unfinished: Stop, its sixth magic (Stop, Stopra and Stopga; in Spanish Paro, Paro+ and Paro++). Days kept its effect, its animations and its names in two languages, but no panels, no words and no code that casts it; the port casts it with the game's own pieces and makes the rest: enemies in its reach stand still for a time that grows with its level, and the damage they take meanwhile lands at once as it ends. Its panels show in the deck and the camp with an unused clock picture of the game's, take Magic LV and Doublecast like the other magics, are made at the moogle's shop (dearer than any other magic) and work in multiplayer, where with friendly fire on Stop also holds the other players. Its numbers, prices, recipes and words are in an open file, port/runtime/battle/stop_magic.txt. It is on unless turned off in Settings → General → Stop magic ([gameplay] stop_magic = off, read as the game starts): the game is then the DS's, and a save's Stop panels stay in it, unseen, until it is on again. In a room every player must have it the same.

Planned: the port on other systems -- Linux first, then, from one ARM64 build, macOS, Windows on ARM and the Nintendo Switch.

Installing

On Windows, the installer from the releases page is all you need besides your own copy of the game: it asks for your ROM (the European or North American release of KINGDOM HEARTS 358/2 Days; it finds it by itself where KH Melon Mix keeps one in your KINGDOM HEARTS HD 1.5+2.5 ReMIX folder), prepares the game's data from it, and can also make the HD pack from your HD collections, add the port to Steam (PC and Steam Deck), and install the mod studio. Nothing of the game comes with it. The port tells you when a newer release is out, and its Download updates your copy by itself: it fetches the new installer, checks it, closes the game, updates it with your choices (Windows asks for the administrator's permission) and opens it again. More: installer/README.md.

Getting started

To build the port from source instead:

  1. Check and extract your copy of the game (Python 3.11+):

    py .\tools\verify_rom.py "E:\path\game.nds"
    py .\tools\extract_data.py "E:\path\game.nds"
    

    The data goes to data/extracted/<hash>/, which is never committed.

  2. Build (Windows, Visual Studio 2026 with the C++ workload, CMake, Ninja, and for the preparation Python's pycparser):

    py -m pip install pycparser
    py .\port\build.py --config Release
    

    port/tools/prepare.py generates the build's sources from the decompilation -- the game's C rewritten with every pointer a reference (build/port/gen-x64); the executable is build/port/obj-release-x64/khdays-native.exe (--config Debug: build/port/obj-x64/).

  3. Run it from the repository root, so it finds data/ and keeps the save in saves/khdays.sav:

    .\build\port\obj-release-x64\khdays-native.exe 2> khdays.log
    

    The runtime reports to stderr; 2> keeps it for a bug report. Started without the data (or with it incomplete), it says so in a message box in the system's language, with the folder it looked in.

    The save is the DS's backup memory as a file, in the same format as a DS save (a 64 KB raw backup), so a save from the DS loads. It is written whole each time the game saves -- a new file beside it, then put in its place -- so a crash of the game or the PC while saving leaves the save as it was before, or as it is after, never half of one.

  4. When something seems wrong -- music late, the game stopping for a moment -- the session log says what the game was doing: the Debug build writes one for every session in saves/logs/ (Release: turn on Session log in the settings, or KHDAYS_LOG=1): its scenes, the files it read and how long they took, when each music was asked for and when it was heard, and every stretch over 50 ms without a frame. Press F12 when you see it happen: the log gets a mark there, and what the DS's two screens show then is saved in saves/marks/ (mark_<n>_frame_<frame>.bmp, with the upper screen's layer registers and the pause's pieces in the log). Send the log and the pictures with the bug report.

Controls

By default the game is played as on the DS.

  • Keyboard and mouse: W A S D = D-pad, left button = A, Space = B, C = X, right button = Y, left Shift or Left = L, middle button or Right = R, M or Enter = START, N = SELECT; in a field, with the command menu on the D-pad, the wheel moves the command menu up and down and Q and E left and right. Any key or mouse button (left, middle, right, the side buttons X1 and X2, the wheel) can be bound to any action in Settings -> Controls; a notch of the wheel is a short press. The pointer hides over the game while its window has the focus (the touch screen is not used).
  • Gamepad (Xbox, PlayStation, Switch Pro, Steam Deck, or any controller your system recognises as a gamepad): connect it whenever you like, even in the middle of a battle. The buttons follow the DS's layout by position, whatever is printed on them: the right-hand face button is A, the bottom one B, the left one Y and the top one X; the shoulders are L and R; Start or Options is START; Select, Share or View is SELECT. The left stick moves like the D-pad (the DS's eight directions). With several gamepads connected, the first one plays.

Settings. Press Esc, the gamepad's Guide / Home button or L3 (click the left stick in; Steam and the Steam Deck keep Guide for themselves), or click the title's settings key where the title is the theater's. The menu covers the window, the game dimmed and paused behind it (in a multiplayer session the game goes on). Every section is on one screen -- Controls, Enhancements, Sticks and camera, Video, Sound, Multiplayer, Language, General -- and works with the mouse alone, the keyboard alone or a gamepad alone (its shoulders move between the sections). A change takes effect when you make it: the picture behind the menu follows the video settings, each volume plays a sample of its kind (the game is heard at it when it resumes), and a new binding works from the first press after the menu closes. The Controls section shows every action with its two keys and two gamepad buttons side by side: choose a cell and press the new input; the Kingdom Hearts II layout and the defaults of each section are there too. A setting that waits for something says so beside it (the movies' choice from the next movie; the nickname, online play and the server from the next multiplayer session while one is open).

Language. The game and the settings menu follow your system's language when the game has it (English, French, German, Italian or Spanish; English otherwise). Settings → Language chooses one of the five instead: the menu changes at once, the game's own text when the screen you are on ends (a mission, a menu of the game, the title) -- a screen of the game loads its text when it is built, so every one is built whole in one language. KHDAYS_LANGUAGE=es (or en, fr, de, it) wins over both. Where the screen names one of the game's Config options, it uses the game's own words in that language.

Your choices are kept in saves/settings.ini, a text file you may also edit by hand (KHDAYS_SETTINGS=<path> uses another file). If the port cannot read it, it starts with the defaults and keeps the old file as settings.ini.bad.

Enhancements (Settings → Enhancements). The control enhancements below are off by default. Each uses the game's own controls through the same parts of the game:

  • Analog camera: the right stick turns the field camera and tilts it, as far as the tilt of the stick, at up to the game's own turning speed (adjustable, and invertible, under Sticks and camera). On the DS the camera is turned by dragging on the touch screen, by Select's look view, or with L/R when the game's Config sets them to the camera.
  • KH2 camera: the field camera moves as Kingdom Hearts II's: further back the higher it is, and free to turn while locked on, the view kept between you and the target. Cutscenes keep the game's camera, and it needs the game's Controls on Type A (docs/KH2_CAMERA.md).
  • KH2 first person view: with the KH2 camera on, Select switches to first person as in Kingdom Hearts II: the player fades out, and you can look around and strafe.
  • KH2 models: with the HD menus' HD PACK, Roxas and his keyblades are KH2's, with their motions and cloth, from your own 1.5+2.5 (docs/KH2_MODELS.md). On by default; off shows Days' own models.
  • Mouse camera: moving the mouse turns and tilts the field camera, through the same part of the game as the analog camera, at a speed of its own (Sticks and camera -> Mouse camera speed) and with the camera's inversions. While you play the window holds the mouse; Esc frees it with the settings menu.
  • Command menu on the D-pad: in a field, the gamepad's D-pad moves through the command deck instead of moving Roxas, by making the presses the DS itself uses (X, or X held with a direction); menus, dialogs and open panels keep the D-pad. Which directions work depends on the game's own Config option for the command deck: with X alone moving it (the new-game default), only Down can.
  • Analog movement: Roxas moves in the exact direction of the left stick; pushed less than the run threshold (75 % by default) he walks, at half his speed by default, his steps slowed to match. Fully pushed he runs at the game's own speed, never faster.
  • Separate lock-on: lock on (and off) and switch to the next target on buttons of their own, by making the presses the game uses: its lock-on is R pressed twice quickly, a single R moves to the next target once locked (with Controls: Type B, L tapped goes to the previous one). The game takes two R presses within 9 of its frames (0.3 s) as the double press that lets go, so switching quickly on the DS drops the lock: here the next target waits for that window instead, and a quick series of switches keeps the lock. On the DS a single R press also resets the camera and a long one switches the chase cam; the DS's R stays available for those. Out of the field -- menus, tutorials, the pause -- there is no lock-on, and these buttons are the DS's R (lock on, next target) and L (previous target), so they turn pages as R and L do there.
  • Chase Camera: Free: on the camp's Config page drawn on one screen, Chase Camera has a third value after the game's Auto and Manual. Free is the game's Manual, except that walking no longer pulls the camera's tilt back to its preset's: the tilt set by hand stays (its distance still follows, and the events' cameras and the lock-on are the game's). The game keeps Manual in its save; the settings file keeps Free ([enhancements] chase_free), which the settings' enhancements also turn on and off (Free camera) -- there with two screens too, where the game draws its own Config page. Off unless chosen.

The same menu has live switches for HD fonts, KH2 minimap presentation, HUD sequences, the pause-menu target, and HUD/control during INFORMATION messages. All but the HD fonts are off until the player turns them on. These switches require the corresponding enabled mod assets and preserve native fallback when an asset is unavailable. Mission-panel visibility and its gameplay and pause anchors are saved here too. UI padding, off by default, removes the outer inset from an active HD HUD in single-screen mode. Changes use saves/settings.ini; they never rewrite mod JSON. See the HUD preference reference for defaults, precedence, and the INFORMATION transition exception.

The Kingdom Hearts II layout (Settings → Gamepad preset; Kingdom Hearts III uses the same buttons for these actions) puts attack on the bottom face button, jump on the right, guard on the left, DS X on the top, the shortcuts on L1, lock-on on R1, the next target on R2, the camera's reset on R3 (the DS's R), the command menu on the D-pad, the camera on the right stick and SELECT on View / the touch pad, and switches on the enhancements it uses. The keyboard is not changed.

Picture

By default the picture is the DS's: each screen 256x192, drawn exactly as the DS draws it, its pixels scaled up sharp to fill the window at 4:3. The port draws it through the graphics card (Direct3D 12 or Vulkan, whichever the system offers), and needs one: without, it says why in a message box and its log, and does not start.

Settings → Video changes it; the picture behind the screen follows at once:

  • Display mode: a window (the default) you can move and resize, a borderless window over the whole screen, or full screen (the screen for the game alone, at your desktop's resolution). Alt+Enter switches between the window and the full screen you chose last (the borderless window if none) while the settings menu is closed, and keeps it.
  • Screen resolution: the desktop's (the default) or one of your screen's own resolutions: full screen switches the screen to it, a window takes that size (a borderless window always covers the screen at the desktop's). With the internal resolution "The window's", the game is drawn at it.
  • Internal resolution (1x, 2x, 3x, 4x, 6x, 8x, or the window's own size): the 3D -- the field, the characters, the effects -- drawn at that many times the DS's pixels. "The window's" draws at the next whole multiple up and shrinks it on the graphics card to the window's own pixels (with sharp scaling, the largest that fits, its pixels square); a picture drawn larger than the window is always shrunk so, each pixel the average of what is under it, never stretched. The 2D -- the HUD, the menus, the text, the lower screen -- stays the DS's pixels, as the game drew them, unless a mod replaces it (below). It is the same picture, only sharper: the 3D follows the same rules as at 1x, and wherever the 2D covers or blends with it, it does so as on the DS.
  • Antialiasing (off, FXAA): the 3D's edges smoothed once it is drawn, at its own resolution -- each pixel on an edge blended with the one across it by where it lies along the edge, so the edges come out smooth instead of in steps, for little of the graphics card's time. The HUD, the menus and the text stay sharp. Off by default. (A 3D drawn larger and shrunk, the old way, is an internal resolution above the window's.) (A mod's textures, and the HD replacements, are read at the size they are drawn whatever this says: smaller copies of each are kept, so a model far away does not break into steps that flicker.)
  • Aspect ratio (4:3, 16:9, 16:10, or the window's): the 3D view of the upper screen widens to it, and the field's HUD keeps to the corners of the wider picture as it does on the DS -- the command deck bottom left, the portrait and gauge bottom right, the hearts counter top left. What the game centres (dialogs, menus) and what follows the 3D (markers over targets) stays where it was, and the lower screen stays 4:3 in the middle. The game sees nothing different: it still computes its 4:3 view.
  • Two screens (with two screens): stacked, the upper above the lower as on the DS, or side by side, the upper on the left and the lower on the right, each at the DS's width (the aspect ratio widens stacked screens only); side by side, a 16:9 window shows each screen a third larger.
  • Screen scaling: sharp (the DS's pixels as squares) or smooth.
  • 3D texture smoothing: off as on the DS, or blended between texels.
  • HD graphics: the replacements in your mods (below), on by default.
  • Dump graphics: each texture and 2D tile sheet written out the first