Skip to content
Projects

About

用 TypeScript 从零重写《仙剑奇侠传》(1995),浏览器里能通关,附可视化编辑器 · A from-scratch TypeScript remake of PAL (1995) with a visual editor. Unofficial fan project.

Learning & Education

How these counts are measured

Measured star growth

in 24h
0
in 7 days
+3
in 15 days
+12
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.en.md

Original

Type PAL

简体中文 | English

A from-scratch TypeScript rewrite of the 1995 RPG The Legend of Sword and Fairy (仙剑奇侠传, also known as PAL / Chinese Paladin) for the browser. Phase 1 can be played through to the ending. Phase 2 is a new runtime and a visual editor.

License: GPL-3.0 Live demo TypeScript

▶ Play in the browser

The phase-1 game can be played in Simplified Chinese or English. Open Tools with the backtick key, go to System, and choose a language. Story text, character names, and menus follow that choice. The browser stores the choice locally.

On a phone, in a narrow window, or in a short wide window, the game draws an on-screen direction pad plus OK and Back. Those labels follow the language. The same System page can hide the pad, and the browser stores that choice locally too. A normal desktop window leaves the pad hidden.

From editing a map to playing it: map, scene, NPC script, then in-editor play

Map editing, scene editing, an NPC script, then play preview. The burned-in captions are Chinese.

English dialogue in the inn
Phase 1 · English dialogue in the inn
English in-game menu
Phase 1 · English menu
English battle commands
Phase 1 · English battle commands
On-screen direction pad and buttons on a phone
Phase 1 · On-screen controls on a phone
Dialogue in the Yuhang inn
Phase 1 · Dialogue in the Yuhang inn
Turn-based battle
Phase 1 · Turn-based battle
Developer tools panel
Phase 1 · Scene, coordinates, and scripts
Speedrun timer
Phase 1 · Speedrun timer
Suzhou city map
Phase 2 · Suzhou city map
Character stats
Phase 2 · Character stats
Battle simulator
Phase 2 · Battle simulator
Reference diagnostics
Phase 2 · Reference diagnostics
In-editor play preview
Phase 2 · In-editor play preview

What it is

Phase Status What you get
Phase 1 · faithful recreation v1.1.0 is live The browser runtime @type-pal/game, with English, mobile and gamepad support. v1.0.0 remains the first complete-playthrough milestone.
Phase 2 · Reforge In development A new runtime @type-pal/reforge, a React visual editor @type-pal/editor, and an offline migrator @type-pal/migrate.
Phase 3 · productization Planned Replace copyrighted assets for a public release, plus a site and offline desktop builds. See docs/phase3/README.md.

Phase 1 features, from the v1.1.0 release notes and the current implementation:

  • @type-pal/pal-extract unpacks data tables, sprites, and event bytecode from the original MKF archives. YJ1 decompression corresponds to yj1.c in the reference tree (reference/README.md).
  • A TypeScript bytecode interpreter drives dialogue, cutscenes, scene changes, and battle triggers.
  • A 320×200 indexed-color software framebuffer. Bitmaps store palette indexes and are colored at blit time.
  • Turn-based battles: action queue, damage formulas, spells, status, enemy AI, and animation timelines.
  • Music defaults to MIDI synthesized with SpessaSynth and TimGM6mb. Choose DOS FM (RIX) under Tools → System → Audio → Music source for live WebAssembly + AudioWorklet synthesis. The browser remembers the selection; see the source and license notes below.
  • Simplified Chinese or English, under Tools → System → Language. Story text, names, and menus follow the choice, and the browser stores it locally.
  • An on-screen direction pad and OK / Back on a phone, a narrow window, or a short wide window. That layout’s System page can show or hide them. A normal desktop window leaves them hidden.
  • Standard gamepad support. System offers an optional clockwise 45° rotation for the on-screen direction pad and left stick, off by default and remembered locally. Keyboard and hardware D-pad mappings stay unchanged.

Phase 2 pieces that are already in the tree (live detail is the capability map and the task board):

  • Edit scenes, maps, scripts, characters, items, battles, assets, and project settings.
  • Open and save a local project, undo/redo, reference diagnostics, in-editor play, and a standalone battle simulator.
  • PAL content is published into the current project with a transactional publish and a three-way merge.
  • A standalone playable package that does not need this source checkout is still an open phase-2 exit item.

How this differs from sdlpal compiled to WebAssembly

reference/sdlpal/ is a copy of the sdlpal C sources. It is a reference spec. It is not compiled or run as a complete engine. Unpacking, the script VM, the 320×200 palette renderer, the battle system, and the editor are TypeScript. For phase 1, original game data and observed behavior come first; sdlpal is the reference implementation.

The DOS FM option separately compiles an adapted RIX player and Nuked OPL core to WebAssembly. Its C/C++ sources, patches, licenses, and rebuild instructions are in packages/game/vendor/rix/.

Quickstart

Install Node.js 22, pnpm, and Git.

Without original game data, run the self-contained demo or create a blank project in the editor. The demo’s runtime dependencies are in the repo. It still includes a small amount of PAL-derived sample material:

pnpm install

# Reforge loads the self-contained demo
pnpm --filter @type-pal/reforge dev      # http://localhost:6050

# Editor start page. Create a blank project or open a local current-format project.
# This command does not auto-load the demo.
pnpm --filter @type-pal/editor dev:demo  # http://localhost:6011

To run the full PAL content, place a legally obtained copy of the original data in data/raw/ (file list: data/raw/README.md), then extract and migrate:

pnpm install
pnpm extract
pnpm --filter @type-pal/migrate migrate:content --write

Start one app:

pnpm --filter @type-pal/editor dev      # editor + PAL, http://localhost:6010
pnpm --filter @type-pal/reforge dev:pal # Reforge + PAL, http://localhost:6051
pnpm --filter @type-pal/game dev        # phase-1 runtime, https://localhost:6005

migrate:content is a dry run unless you pass --write. The phase-1 dev server uses a local self-signed HTTPS certificate; the first visit to port 6005 needs a manual exception. Maintainer commands, debug entry points, and working rules are in CONTRIBUTING.md. That guide’s long sections are in Chinese.

Layout

App Package Role Local port
Phase-1 runtime @type-pal/game The shipped faithful browser game, and the behavior/UX reference for phase 2. 6005
Reforge @type-pal/reforge The new runtime for modern content projects. 6050 / 6051
Editor @type-pal/editor Visual editing for maps, scenes, scripts, characters, items, battles, assets, and project settings. 6010 / 6011

Other packages: packages/shared (shared types and decoding), packages/pal-extract (offline extract), packages/content (phase-2 content contract), packages/migrate (offline migration). The doc index is docs/README.md (Chinese).

Where to read status

Capability cells, task state, and the content-format version move. This page does not copy that ledger.

Question Entry
Phase 1 docs/phase1/README.md
Phase 2 rules docs/phase2/READ-FIRST.md
Phase 2 progress docs/phase2/capability-map.md
Phase 2 roadmap docs/phase2/roadmap.md
Phase 3 docs/phase3/README.md
Current tasks docs/tasks/board.md

How it is built

The repository is written with AI coding agents working with the maintainer. The agreement is AGENTS.md: task cards, one coding owner per implementation file at a time, and independent review. The current mode is assign / implement / independent acceptance. Older three-party sign-off notes remain in that file as history; they are not a gate for new work.

License and disclaimer

Unofficial fan project. Not affiliated with, endorsed by, or authorized by Softstar (大宇 / 软星) or the other rights holders of The Legend of Sword and Fairy. Original assets and the live demo are for study and exchange only, and will be taken down on request. Please support the official game.

For a takedown or other rights request, open a GitHub issue in this repository.

  • Code written for this project is released under the GNU General Public License v3.0, the same license as the sdlpal reference.
  • The full original game data is not in Git. The live demo is a hosted build. Running the full PAL content locally requires your own legally obtained copy.
  • Checked-in demos, regression fixtures, and part of Reforge’s default UI art include a small amount of PAL-derived material. That is not a cleared asset pack, and the GPL on the code does not relicense the original artwork. See PROVENANCE.md.
  • Third-party components keep their own licenses. The repository GPL-3.0 does not relicense them.

Third-party licenses

Source License Note
reference/sdlpal/ GPL-3.0 (LICENSE) Upstream snapshot, reference only.
reference/sdlpal/timidity/ COPYING is the Artistic License; the README in that directory says the upstream author also allows GPL or LGPL Reference tree only. Not built by this repo.
reference/sdlpal/adplug/ NOTES/COPYING is LGPL-2.1 The notes describe the bundled older LGPL OPL emulator. They also mention a newer MAME-licensed emulator that restricts commercial redistribution; that newer emulator is not the copy included here.
packages/game/vendor/rix/ AdPlug LGPL-2.1-or-later; SDLPAL portions GPL-3.0-or-later; Nuked GPL-2.0-or-later Built DOS FM kernel. Its README links the sources, adaptation patch, bundled licenses, and rebuild instructions.
reference/sdlpal/overlay/ CC BY 4.0 (COPYING) libretro overlay art, reference tree only.
GNU Unifont OFL-1.1, or GPL-2.0-or-later with the font embedding exception See PROVENANCE.md, OFL-1.1.txt, and COPYING.
TimGM6mb soundfont The in-repo notice says GPL-2 and links the GPL version 2 text, with no “or later” grant packages/game/public/soundfont-LICENSE.txt and the same file under Reforge. The bank stays under that notice. This repository’s GPL-3.0 does not relicense it.

Maintainers

Commands, debug entry points, data flow, and working rules: CONTRIBUTING.md. Agent protocol: AGENTS.md.

Explore related projects

Loading…