01Can one prompt do it?
You've probably seen the claim: with today's AI, you can hand over a single prompt and get an old game taken apart and rebuilt for the web.
I was skeptical, but curious enough to try. The game I picked was Knights of Xentar, a Japanese RPG with a goofy story and a handful of risqué pictures. Let's be honest: plenty of teenage boys played it for exactly that reason. It's a DOS game, so playing it today means setting up an emulator and fiddling with settings. If one prompt really could do it all, so much the better.
It wasn't that simple, of course.
My first attempt didn't produce anything playable. The AI had pulled some pictures and map tiles out of the game files, and that was it.
The second attempt looked more promising: the first town, a few people in the street, and a hero you could walk around. Except every one of those people was in the wrong place, and the hero wasn't Desmond. The AI had grabbed a random character sprite.
So AI could help a lot, just not at the press of a button. The real work happened in small steps. Unpack the original's files and see what's actually in them. Write a little. Compare it with the original. If it's wrong, keep digging, all the way into the original program if that's what it takes. A single small question, like "why can't I see the final boss?", could take a good while to answer.
This page is the story of that work: what went smoothly, where I got stuck, and a few things that surprised even me. You don't need to know any programming to follow it. The technical details are folded away in "Behind the scenes" boxes, for anyone who wants them.
What kind of game is it?
Knights of Xentar is a PC role-playing game made by ELF. In Japan it's called ドラゴンナイトIII (Dragon Knight III). In Taiwan, 微波 translated and published it in Chinese as 《龍騎士3》, and for many players there, that was the version they grew up with.
You see the world from above in 2D, and battles aren't turn-based. The whole party fights at once, in real time: you decide how each member attacks, then watch them go. The hero, Desmond, is a wandering swordsman who gets robbed of his money and gear in the very first scene and has to start again from nothing…
My goal was simple: a version you can play in the browser, in English or Chinese, that plays like the game did back then. Not something close. The real thing.
02Why not just use an emulator?
You can still play the game today. An emulator like DOSBox runs the original, mouse controls included: click somewhere to walk there, click someone to talk. Some websites even run DOSBox inside the browser, so it's one click away.
So why go to the trouble of rewriting it?
Because playing it that way has real problems. DOSBox in a browser often feels off: clicks don't quite respond right, and the game speeds up and slows down. Worst of all are saves. Play for an evening, close the browser, and everything's gone. Next time, you start over. Installing an emulator yourself fixes the saving, but then you're downloading and configuring software, and on a phone it's even more of a chore.
A web version is different. Open the browser and play. Your saves stay in the browser for next time, and you can export them as a backup. The interface can be redesigned too: clearer menus, switching between English and Chinese whenever you like, a larger picture, all while keeping the original pixel art. An emulator can't do any of that.
There was one more reason. I wanted to know how the game actually works. An emulator imitates the whole old computer: the game runs, but what happens inside stays hidden. A rewrite is different, because you can't write a rule until you understand it. And once it's written, it's on record. For a game that's thirty years old, that's a kind of preservation in itself.
03Opening the time capsule
Step one was simply looking at what's in the game's folder.
What you find is a handful of large files with strange names. Once I'd unpacked them one by one, it turned out they're neatly organised: some hold maps, some hold pictures of people and monsters, some hold the story pictures, some hold the music, and some hold the dialogue.
Map tiles
Townspeople walking
A monster's frames
A dialogue portrait[7:DM] Oh, am I hung over!A line of dialogue, as stored
The most interesting one was full of scripts. Every town and every cave has a little script of its own, saying who stands where, what happens when you talk to someone, and what you need before you can move on. Think of a director's notes for a stage play.
The game's main program was a different story. At first I couldn't read it at all, because it had been compressed to save space, as programs often were back then. It had to be unpacked before any of the instructions inside made sense.
Behind the scenes
The game's data lives in more than ten .VOL files, each a series of records: maps, tiles, pictures, music, text and scripts. The main program, K.EXE, is packed with PKLITE, a common compressor at the time, and has to be unpacked before it can be read. The scripts are written in the game's own little programming language, so the first job was writing tools to "translate" them into something readable.
04Letting the original scripts play on
With everything unpacked, I had a big decision to make: rewrite the story myself, or keep using the original scripts?
Rewriting looks easier. You follow the original scripts and rebuild the story one scene at a time, and that's how I started. But one town in, I could see how easy it was to get things wrong. Who shows up when, which line they say, what you have to do before a door opens… The details never end, and if you miss one, it's no longer the original game. (Case six tells that part of the story.)
So I changed course. The original scripts would keep running the show, and I'd just build them a new stage.
Think of an old play being revived. The script doesn't change by a single word, but the lighting, sets and costumes are all new. The original scripts still decide how the story unfolds. How the screen is drawn, what the menus look like and how battles are shown: that's the part I rebuilt.
The upside is that the story is always the original's. The downside is that first I had to build a machine that could read those old scripts, and if it misreads even one small thing, very strange bugs appear. One of the detective stories below started exactly that way.
Behind the scenes
I wrote an interpreter that runs the original scripts in the browser, one statement at a time. The scripts handle the story and your progress; the screen, menus, shop screens and battle screen are my own code.
05Detective stories: six puzzles
A lot of this rewrite felt less like programming and more like detective work. Something on screen looks wrong, so you hunt for clues, make a guess, then go back to the original to check it. Here are the six cases I remember best.
Case one: the hero's paper doll
Swap your sword or put on new armour, and Desmond's appearance changes with it, both on the map and in battle.
When I took the game apart, I discovered there's no complete picture of Desmond anywhere in it.
Instead, the original works like a paper doll. It starts with a body wearing no gear, then lays the armour, helmet, shield and weapon on top, one layer at a time. Every piece of gear has two sets of pictures: a small one for walking around and a large one for battle. Rolf is assembled the same way, from his own set of parts.
Getting the layers right wasn't the end of it. In battle, Desmond's poses came out jumbled: when he should have been standing ready, he was shown taking a hit and leaning back. It turned out the original counts its battle poses from the right, so the standing pose is on the far right and the "hit" pose on the far left. I'd been counting from the left, which reversed the whole order. Once I counted from the right, he stood up properly.
A fun detail: the base picture differs between releases. In the English version, the hero wears a pair of briefs underneath; in the original Japanese one, he doesn't.
Body
+ Armour
+ Helmet
+ Shield
+ Sword
Behind the scenes
The original has a script called EQCHIP whose only job is dressing the hero. Whenever the gear changes, it looks up each piece in its tables and builds two sprites at once: the small walking figure and the large battle figure. The walking sprite has eight frames (four directions, two steps each) of 32 × 32 pixels; the battle sprite has nine poses of 48 × 64 pixels.
Case two: how Rolf follows you
Once Rolf joins, he walks along behind Desmond. Nothing special, you'd think, but the way the original does it is rather clever.
Rolf isn't working out a route at all. The game keeps a record of where Desmond is at every moment, like a trail of footprints, and Rolf simply stands where Desmond was a moment ago. When Luna joins later, she stands where he was a little before that.
That's why Rolf is always half a step behind. When you stop, the trail keeps recording, so he walks along it until he's standing right where you are, hidden behind you.
The party never gets split up and never walks through walls, because they only ever go where you've already been.
- Luna
- Rolf
- Desmond
Behind the scenes
The original keeps the hero's positions for the last 11 moments. Rolf takes the position from two moments back, Luna the one from four moments back.
Case three: rebuilding a music box
Most people assume game music is a recording that simply gets played back. Not in Knights of Xentar.
The game doesn't store sound at all. It stores sheet music: when to play, on which instrument, which note, and for how long. Computers back then had a sound card plugged in, and the chip on that card read the sheet music and synthesised the sound on the spot.
Browsers today obviously don't come with that card. So I had to build a small synthesiser into the web page to imitate the chip, then write a "conductor" to play the original sheet music, beat by beat.
The first time I heard it, the melodies were right, but everything was too fast. The tricky part was that "how much too fast" is hard to pin down, so I listened again and again until the speed and rhythm felt right.
Later I read through the original's music program and confirmed that it steps 128 times a second, which matched the speed I had arrived at by ear. While reading it, I also noticed I'd missed the ties: some notes have to carry on into the next one instead of being struck again. Ties alone appear about 2,770 times across the game's 55 pieces. With those added, the music sounds much more like it did back then.
One small detour: the Village of the Fairies had no music, and I assumed I'd broken something. It turned out to be deliberate. After the demons attack, the village falls silent.
Behind the scenes
The music is sheet music written for an FM synthesis chip. Browsers won't let a page make any sound until you press a key or click, so the opening starts silently and the music comes in the first time you do either.
Case four: the shop's secret
An old walkthrough says that if you spend 50,000 gold in one go at Tristrap's second weapon shop, it starts selling a Magic Helmet and a Lightning Gem.
When I checked my version, that shop didn't do it at all. However much you bought, nothing changed.
So I went back to the original's shop program, and found the walkthrough was only half right. The original doesn't care what you spend in one go. It keeps a running total of everything you've spent in that shop, so it doesn't matter how many trips it takes: once the total reaches 50,000, the new stock appears. The Lightning Gem is sold only once; buy it and it's gone from the shelf. And another shop has the same secret: the item shop in Phoenix, which the walkthrough passage I had doesn't mention.
Along the way I caught a bug that was buried deep. The original program says "50000", but my script-reading machine read it as a negative number. One small misreading, and a number turns into something else entirely.
Case five: the missing final boss
One day I reached the last battle and found the final boss wasn't there.
The battle screen showed his name and his health bar, but there was no one there.
When I opened the picture he uses, it wasn't a complete monster. It was a pile of loose pieces: some tentacles, a face, a mouth. They didn't add up to a body.
When I followed the trail deeper into the original program, the answer surprised me. The final boss, Deimos, isn't an ordinary character at all. The original paints him straight into the battle background: the whole cave, with his body in it, is one background picture. Those loose tentacles, the face and the mouth are moving parts placed on top of it. As the fight goes on they keep changing pose, so the tentacles sway and the mouth opens to breathe.
To make sure I hadn't guessed wrong, I found a full playthrough video and skipped to the final battle. The Deimos on screen matched what I'd worked out from the program.
Behind the scenes
Deimos has six moving parts, including a face, a mouth and several sets of tentacles. Each time the mouth's animation comes round, he breathes on Desmond for 3 to 10 points of damage.
Case six: who stands where, and who says what
Most of a role-playing game isn't really the fighting. It's the story: who's standing in the street, what they say when you talk to them, and whether anything changes afterwards.
The original has 161 small scripts, and every place has one of its own. Each takes care of three things:
- which group of people is in town when you arrive;
- what happens when you talk to someone or step onto a certain spot;
- what to remember once it has happened.
The game tracks your progress with lots of switches: whether you've rescued Mona, whether you've collected that money, who you've met. Almost every line of dialogue checks them first.
Same town, different rosters
The first one that gave me a headache was the opening town, Squalor Hollow. For the same map, the original has several rosters: lists of who's in town this time, where they stand, and how they wander about.
- one for the start of a new game, when only the gang who rob you are there;
- one for when you wake up with nothing to your name;
- one for after you rescue Mona;
- and later in the story, yet another.
The scripts pick a roster based on your progress. Pick the wrong one, and people who should be there are missing, and paths can end up blocked. Take the steward: before Mona's rescue he stands in your way, and after it he steps one tile aside, which opens the only way through to Frump.
Before the rescue
After the rescueAt first, I wrote it by hand
To begin with, I took Squalor Hollow's script apart, worked through it line by line, and rewrote it myself: which line each townsperson says in which situation, and which switch it sets. This one small town alone filled a very long table. Larrouse says one thing while you're naked and something else the second time round; the tavern master says different things before and after the rescue…
One town in, I knew it was a dead end. The game has dozens of places, and writing every one by hand like that was bound to introduce mistakes that would be hard to spot.
The turning point: let the original scripts run
So I switched approach and built a machine that could read the original scripts directly, letting them decide the story for themselves.
Before making the switch, I ran a comparison. I had the machine run Squalor Hollow's script in 5,161 different situations: different points in the story, dressed or undressed, walking in from each direction. Each time, I compared the result with my hand-written version: the lines spoken, the switches set, the money handed over.
Nearly everything matched. The one difference: during Mona's rescue, the original calls a separate script to shake the screen like an earthquake. But the comparison also caught a mistake of mine. I'd assumed some spots only trigger if you walk onto them facing a particular way, but the original doesn't care which way you face. The south gate, Frump's door and the exit to the world map all trigger from any side.
From then on, the story belonged entirely to the original scripts. My code only does what they can't do in a browser: the screen, walking, the dialogue box, shops and battles.
A small secret in the rosters
A roster holds more than positions. It also says how each person moves about: two steps up, a pause, three steps left… The first time I followed those instructions, the townspeople kept walking into walls. I'd read "up" and "down" the wrong way round. After the fix, the patrolling townspeople bumped into a wall just 48 times in 1,848 steps, down from 327. And the gang in the opening finally formed a ring around you, trapping you in the middle, just as in the original.
Another time, I found two extra people in Phoenix: Mimi and Cherry. It turned out the English release's script gives them a "hidden" mark, so they're skipped when the screen is drawn. I hadn't been reading that mark, so they stood there in every version.
The walkthrough only gave me the order
Finally, I took an old walkthrough from the internet and turned the story into a checklist, stop by stop, to make sure nothing was missing. But I only used it for the order of events and for what the player sees. For the details, the original program always has the final say, and wherever the two disagree, I note it on the list.
Behind the scenes
Squalor Hollow's four rosters are numbers 94, 95, 91 and 96 in the original's data. The comparison combined the town's 15 switches into 5,161 situations. When it came to choosing a roster, the machine and my hand-written version agreed every time, in all 80 cases.
06How do I know it's right?
When you rewrite an old game, the biggest risk isn't failing. It's ending up with something that's almost right: correct nearly everywhere, but quietly wrong in some corner nobody notices.
So whenever I finished something, I had to answer one question: "How do I know this is right?" I have four ways of checking.
1. The original program has the final say
The most important source is always the original itself: its scripts and its main program. Walkthroughs, videos and my own memory can all be wrong, but the program can't be. Whatever it says is what players got back then.
That sounds obvious, but in practice it often means overruling your own instincts. The shop case is a good example: the walkthrough says "spend 50,000 in one go", but the program keeps a running total. When the two disagree, I go with the program and make a note of the difference.
2. An old walkthrough and a playthrough video
The program tells me how things work, but not what the player actually sees on screen. For that, I rely on two things:
- An English walkthrough from 2003: I turned the story into a checklist, stop by stop. Each time I finish a place, I check it against the walkthrough: what's in the chests, what the shops sell and for how much, who you should meet where.
- A complete playthrough video of the DOS version: whenever I need to check how something looks, I skip to that part. That's how I checked what the basement looks like and how the final boss appears.
3. Let the computer replay it for me
The game is long, and I can't play it from the beginning every time I change a line of code. So I wrote lots of automated tests that play it for me.
One of them uses the original scripts to play from the opening to the end of the first chapter: getting drunk, getting robbed, rescuing Mona, beating the bosses, without skipping a step. At every step it checks that your progress was recorded properly and that the right paths opened up. The project now has more than fifty test files with over three hundred checks, and they all run again after every change. If I break something, I find out straight away.
The same goes for the text. The game has more than six thousand pieces of text (dialogue, item names, menus), and every one needs English, Traditional Chinese and Simplified Chinese. I wrote a checker to make sure none of them is missing.
4. Actually playing it
No amount of testing beats a real person playing. Plenty of problems only turned up while I was playing in the browser myself, usually in places the tests hadn't thought of:
- after beating the final boss, going back to read a stone tablet showed an item number instead of the item's name;
- while I was in the arena, the Journal told me to "go and find Rolf", because Rolf had left the party for a while.
When I find a problem like that, I go back to the original program to understand it first. Once it's fixed, I add a test so the same mistake can't creep back in.
Behind the scenes
I also built a scene inspector, a tool page just for me. Pick a place and you see all its rosters, when each one is used, and every line each person says at each point in the story. A lot of mistakes jumped out at me there.
07Same content, new interface
For this rewrite, I set myself one rule:
Story, maps, music, art and numbers: exactly as in the original.
How you play and how you find information: rebuilt for today.
The story, the dialogue, what's in the chests, shop prices and monster stats are all read straight from the original. Nothing is made up.
The interface is another matter. A game interface from 1994 was designed for the computers and players of its day, and playing it now, a lot of it feels clumsy. So the interface is where this version changes the most.
What you need, at a glance
- Party status: the top-left corner always shows each member's portrait, level, HP and MP, plus the gold you're carrying. HP turns yellow below half and red, pulsing, below a quarter. When your gold changes, a "+100" or "−50" pops up beside it.
- Shops: show how many of each item you already have, and let you buy potions several at a time instead of one by one.
- Place names: when you enter a town or a dungeon, its name appears briefly at the top of the screen.
Fewer clicks
- Walking with the mouse: the original could already be played with a mouse, and I kept that. The difference is that if you click somewhere further away, the hero now finds his own way around obstacles.
- Clicking doors, people and things: doorways, stairs, chests, people to talk to. Click, and the hero walks over and takes care of it.
- Item belt: four slots at the bottom of the screen for potions and the like, used with keys 1 to 4 or a click, in battle and on the map.
- Battles: click a party member to open their commands. The most useful key hints sit along the top of the screen, so you never need the manual.
No more getting lost
- Journal: back in the day, if you got stuck, your only options were a walkthrough or going round town asking everyone again. The Journal looks at your progress, tells you roughly where to head next, and keeps a record of the story so far. It reads the progress the original scripts record; it doesn't make up a story of its own.
- Hidden treasure hints: the original hides treasure in jars and corners with no hint whatsoever. Now you can have spots that still hold something give off a sparkle. If you'd rather not, switch it off and it's back to the original.
Saving
Saves live in the browser. You can name them, export them to a file, and import them on another computer. I also added autosaves that keep the latest five, so forgetting to save won't cost you an evening.
What stays the same
A new interface doesn't mean throwing everything out. The portrait beside the dialogue, where the dialogue box sits, and the key items page with its grid and pictures all follow the original. Many of the new features can also be switched off in the settings, if you'd like something closer to the original.
Beyond the interface, just one rule changed: battle balance
In the original's battles, the hero can pick from several tactics. I ran a simulation, having the computer fight lots of battles with each one, and the gaps were enormous: in many fights, the worst tactic needed ten to seventeen more levels than the best one to win.
So I made a balanced set of rules that gives every tactic a purpose. In most fights, the best and worst tactics are now only three to six levels apart. The balanced rules are the default, but the original's rules are kept with every number unchanged, and you can switch back in the settings any time.
Changes because it's a browser
- Opening music: browsers won't let a page make any sound until you press a key or click. So the opening starts silently, and the music comes in the first time you do either.
- Story pictures: you can choose to show them, blur them, or hide them completely.
- Display: choose "Smooth" for something close to how it looked on a CRT monitor back then, or "Sharp" to see every pixel of the original art.
Not done yet
The original's sound effects (swords swinging, hits landing, chests opening) aren't in the game yet. The music, though, is all original.
08What the AI did, and what I did
Back to the question I started with: can one prompt take an old game apart and rebuild it?
Having been through it, my answer is: no. But without AI, I couldn't have done it on my own either.
What the AI is good at
Nearly every change to this project's code was made together with AI. Where it really earned its keep was the work that's enormous, tedious, and has to be exact:
- Reading machine code: the original's main program is a thirty-year-old DOS program. The AI can read through it piece by piece and tell me which part draws the battle screen and which part works out damage.
- Writing tools: little tools to unpack files, convert pictures, read the sheet music and read the scripts, one after another. Many were used only once, but without them, I couldn't have seen anything.
- Writing tests: most of the fifty-odd test files I mentioned were written by the AI, and it runs them itself after changing the code.
- Comparing: running the original script in over five thousand situations and checking each one against my hand-written version would drive a person mad. The AI does it without blinking.
I also tried handing part of the work to a different AI, then having the first one review the code it wrote.
The mistakes AI makes
The AI is fast, but it does get things wrong, and it sounds exactly as sure of itself when it's wrong as when it's right. Many of the "I read it wrong" moments in the cases above were really the AI misreading something the first time, which the AI and I then tracked down together:
- the order of the battle poses, read completely backwards;
- "up" and "down" swapped for the townspeople's walking;
- the "50000" in the original program, read as a negative number.
The biggest surprise came while writing this page. I asked the AI to help me write up these cases, and it wrote fluently, but several parts were invented: that I'd "spent days" on something, that I'd "compared it with recordings of the original", that the final boss was painted into the background "because he was too big". None of it was true. I had to send it back through every sentence, checking against the code and the commit history, and cut anything without a basis.
What I did
Since the AI makes mistakes, the human's job is to set the direction, and to judge what's right.
Setting the rules. I made many of the important decisions at the very start:
- the story is always left to the original scripts, while the screen, menus, shops and battle screen are all my own code;
- the battle rules have to be read from the original's main program and rebuilt faithfully, not invented;
- walkthroughs and videos are only for reference; on the details, the original program decides.
Being its eyes and ears. I'm the one who heard, over and over, that the music was too fast. Wherever the screen looked odd or a Journal line was wrong, I found it while playing. The AI can't see the screen or hear the sound; that part takes a person.
Saying "that's not right". When the AI says it's done, it isn't necessarily done. I look at every change and try it myself before I agree to keep it.
So, can AI help you take apart an old game?
Yes, but it isn't a machine that works at the press of a button. It's more like a tireless assistant who reads incredibly fast, but now and then tells you something wrong with total confidence.
The clearer the direction you give it, the better it does, and the more carefully you check its work, the more you can trust the result. What one prompt can't do, hundreds of rounds of conversation and constant checking can.
09Why keep old games alive
A lot of people think an old game can't disappear as long as its files are still around. Unfortunately, it can.
The files survive, but the game can still be lost
DOS games like Knights of Xentar were written for one particular kind of computer:
- they run on DOS;
- their music depends on a sound card of the time, synthesising it on the spot;
- their graphics were designed for the monitors of the time.
Today's computers have none of that. The files are sitting right there, yet a typical computer today can't play them directly. To play now, you need an emulator: a program that pretends to be a thirty-year-old computer.
Emulators matter, because they keep games playable. But what they preserve is a black box. The game runs, yet how it works inside remains a mystery.
Easier to lose than files: knowledge
The people who made this game knew every detail: why that shop suddenly stocks two extra items, why the final boss is painted into the background, how the hero's armour is stacked up layer by layer. Most of that knowledge was never written down publicly.
Thirty years on, the team has long since scattered, and the source code is probably gone for good. Unless someone takes the game apart and works it out piece by piece, that knowledge disappears with it.
So with this rewrite, I wanted to leave behind not just a playable web version, but a record of how the game works:
- Notes: every time I worked something out, I wrote it down: how battles are calculated, how the story moves forward, how characters are put together, how maps are drawn, how the music plays. There are now more than 1,500 lines of notes, most of them citing where in the original program each fact comes from.
- Tools: I built a few tool pages that let you look inside the original directly:
- a map viewer, to page through all 116 maps;
- a sound room, where every piece of the original's music can be played on its own, along with where the game uses it;
- a scene inspector, showing who's in each place, when they appear and what they say.
- Tests: the tests are a record too. Each one says, "in this situation, the original does this". Even if someone rewrites my code one day, they'll show what mustn't break.
One person can do more than before
Taking a game apart like this used to take a group of enthusiasts fluent in assembly language, and a great deal of time.
This time, it was one person plus AI. That doesn't mean it was easy: in every case above, each answer had to be checked against the original. But it does mean that many old games on the edge of being forgotten might still get a chance to be properly understood and documented.
I hope this page inspires more people to try, and to save the games they played as kids.
10About the adult content
Knights of Xentar was a game with adult content: the story includes some risqué pictures, and that was part of what drew so many players to it at the time.
This web version plays the uncut edition. So:
- The game is for adults only.
- The "Story images" setting lets you show those pictures, blur them, or hide them completely. With them hidden, the story and dialogue are still complete; you just don't see the pictures.
Neither the text nor the pictures on this page include any of that adult material.