How Prince of Persia Creator Overcomes Apple II's Memory Limits


“I developed the storyline of The Shadow Man. He appears in the game at predetermined points. In one case, he steals a potion. When the player is ready to grab the bubble, the Shadow man runs in, drinks it and runs away. Another time, when the player is about to go through the gate, a Shadow Man appears, clicks on the stove and closes the gate. After that, the player falls three levels down, and he again has to go all the way up. I recorded these clashes in the plot so that the player would hate the Shadow man and consider him his enemy. So that at the moment when he would have to cross swords with him at the end of the game, he really wanted to get even, because he prevented the player so many times. It was my way of creating an emotional connection between a player and an adversary through gameplay, rather than cinematic insertions. ”

Hi, I'm Jordan Mekner, author of Prince of Persia. This is a story about how I drove myself into a corner with animations, and then I was able to get out of it thanks to the battles.

I was a child who grew up in New York in the mid-70s. A comic book fan. I loved the movie. Grew up on the magazine "MAD", and if there were no computers, I could do comics and animation. But when Apple II appeared in 1978, I took it as a machine on which I can primarily play games at home, which was completely impossible before. Instead of spending quarters in local slot machines, I could stay home and play as much as I wanted in Space Invaders on Apple II. In addition, the computer allowed me to create my own games, and it delighted me. This happened before the advent of the Internet, so almost everyone was self-taught. I subscribed to Creative Computing magazine, and a little later, to Softalk magazine, which included articles on how to program. I started sharing experiences with friends,who also loved computers.

My first games were copies of existing arcade games: the player always had three lives, and the goal was to get a record number of points. But then I already went to college, and wanted to write a game that will tell a story, and therefore began to program “Karateka”. She had a very simple plot. An evil general kidnapped the princess and imprisoned her in his castle. The player controls a hero who must win several karate fights of the soldiers guarding the fortress. In fact, he ran from left to right and defeated one warrior after another until he got to the end, and then fought with a big bad guy and saved the princess. I wrote the game on Apple II, and at that time Apple was actually the number one gaming platform, but it had its limitations. Apple II’s music features weren’t very good,the computer had only four colors and a screen with a resolution of 280 × 192, and the entire program had to fit in 48 KB of memory. It was a tight restriction.


In those days, Photoshop has not yet been created, there were no graphic packages and tools for animation, and if you wanted to draw a character on the screen, you had to do it pixel by pixel. When I tried to realize the animation of the character, it turned out that he looks awkward and far from the realism that I imagined. So I used a technique called rotoscoping, which had a long history. She appeared at the dawn of animated films.

The first Disney animators used film footage as a reference. In Snow White, human characters, such as Snow White and the prince herself, were actually animated using rotoscoping, that is, Disney animators shot live actors who performed the actions that needed to be animated, and then projected these frames and copied or outlined them frame by frame. . I did the same for “Karateka.” I recorded on Super 8 film how my karate teacher kicks and kicks, as well as other movements that the character needs to make on the screen, then I scribbled each frame of the Super 8 film with pencil on tracing paper and turned them into pixels for display on the screen. This is a kind of rotoscoping 1.0.


“Karateka” came out in 1984 and became the number one bestseller, and I was very lucky that it happened so: instead of starting to look for work after college, I found the luxury to think about what I want to do next? And I got the idea of ​​another game. The first ten minutes of the film “In Search of the Lost Ark” became one of the sources of inspiration. In this scene, Indiana Jones jumps over a hole and almost falls, spikes jump out of the wall, the gate closes, and all these actions reminded me of what I saw in platform games like “Lode Runner” and “The Castles of Doctor Creep”: if you get up on the stove, she opens the gate. I thought that if you combine this gameplay with a human character, the player will feel that if you miss the jump and fall, it will really hurt.The characters of the first platform games seemed to have no weight. The player understood that even if he missed, the character would go downstairs and not feel pain. And I decided to combine the basic gameplay of the platform puzzle in a modular world with very smooth animations of running and jumping, trying to convey the delight of the first minutes of “In Search of the Lost Ark”.

The plot of "Prince of Persia" was also simple. As in Karateka, the player needed to save the princess. In this, I was inspired by the tales of “A Thousand and One Nights,” as well as films like the “Baghdad Thief” of 1940, in which the evil great vizier seizes power and imprisons the princess. I knew that for Prince of Persia I would need a lot more animations. Running, jumping, climbing, falling: all the movements of a small character that he must perform on the screen. And by the time I was doing animations for "Prince of Persia" in 1985, a new technology appeared - VHS. Using one of the first VHS cameras, I shot how my brother runs, jumps and performs all the other actions in the parking lot near our school.


The next problem was the transfer of all these recorded frames to the computer. Through trial and error, I finally found a technique suitable for Prince of Persia; it consisted of converting from analog to digital and consisted of several stages. I started a video tape with my brother on a television screen in a darkened room, put a 35 mm camera on a tripod, directed it to the screen, and then took a picture, rewound to the next frame in the VCR, took another shot, forward again, and so much times until I got a roll of film with about 35 frames. I took it to the local Fotomat instant printing shop, in one hour they showed the film and returned to me a set of pictures that I glued together with tape. Using a marker and corrector, I selected the contours of each character, and then put the pictures in the copier,having received one clear sheet of paper with a series of frames of a distinct white character on a black background. The contrast was strong enough to place this sheet on the animation machine, point the camcorder at it and display the image in Apple II, which did not have a video input. I used a special digitizer board that could only make one clear, still image. She could not perform motion capture, but after receiving 9-12 separate frames of the character’s animation, I could already work with the pixels and cut them out on the screen using my animation tool, and then play the sequence of frames. It took weeks of work to transfer the runs or jumps recorded on the video to a sequence of frames on a computer screen.The contrast was strong enough to place this sheet on the animation machine, point the camcorder at it and display the image in Apple II, which did not have a video input. I used a special digitizer board that could only make one clear, still image. She could not perform motion capture, but after receiving 9-12 separate frames of the character’s animation, I could already work with the pixels and cut them out on the screen using my animation tool, and then play the sequence of frames. It took weeks of work to transfer the runs or jumps recorded on the video to a sequence of frames on a computer screen.The contrast was strong enough to place this sheet on the animation machine, point the camcorder at it and display the image in Apple II, which did not have a video input. I used a special digitizer board that could only make one clear, still image. She could not perform motion capture, but after receiving 9-12 separate frames of the character’s animation, I could already work with the pixels and cut them out on the screen using my animation tool, and then play the sequence of frames. It took weeks of work to transfer the runs or jumps recorded on the video to a sequence of frames on a computer screen.I used a special digitizer board that could only make one clear, still image. She could not perform motion capture, but after receiving 9-12 separate frames of the character’s animation, I could already work with the pixels and cut them out on the screen using my animation tool, and then play the sequence of frames. It took weeks of work to transfer the runs or jumps recorded on the video to a sequence of frames on a computer screen.I used a special digitizer board that could only make one clear, still image. She could not perform motion capture, but after receiving 9-12 separate frames of the character’s animation, I could already work with the pixels and cut them out on the screen using my animation tool, and then play the sequence of frames. It took weeks of work to transfer the runs or jumps recorded on the video to a sequence of frames on a computer screen.It took weeks of work to transfer the runs or jumps recorded on the video to a sequence of frames on a computer screen.It took weeks of work to transfer the runs or jumps recorded on the video to a sequence of frames on a computer screen.

When I first saw the character running and jumping on the screen, he had a gross illusion of vitality and weight. It was the time of eight-bit graphics. Each frame of the Prince of Persia animation was a set of bytes representing a fixed image on the screen, and the next frame was another set of bytes. To implement, for example, a jump, it took 12 frames, and for a jump in running it took up to 15, and the more frames, the smoother the animation. After adding jumps, running, turns, hanging, swinging and all that, each individual movement occupied memory. And here, the difference between those computers and modern ones turned out to be very important, because Apple II had only 48 KB. This is less than the average text email, but everything should fit into this volume: all images, backgrounds, frames of animation, the logic of the program,all sound effects, music, everything. And all this, along with the animations that the character needs to move through the dungeons, filled all the available computer memory.

So, June 1988, I’ve been working on Prince of Persia for two years, and at this stage the most difficult part has already been done. I have a smoothly moving character running through the dungeons, he climbs, falls, clicks on the plates to open the doors, and jumps over the abyss, almost falling into spikes. Everyone who sees my game groans and sighs in delight. This result was a confirmation of the concept, but the game is not very interesting to play, and I am tormented by the vague feeling that I have already realized almost everything that I wanted, but I can not achieve the admiration for which I was hoping. In addition, there are signs that the Apple II platform is dying. When I started developing Price of Persia, the Apple II was still the number one platform for gaming. But by 1988, new cars appeared, with more colors and resolution,more advanced sound features. I was at the very end of the Apple II life cycle, but I felt that having switched to another platform, I had to start all over again. I was worried that I would create a magnificent, exciting game, but there would be nobody to play in it.

Yes, a problem arose: I reached that stage in development when I began to doubt my initial vision of the game. Sometimes the right answer is: just believe in the original vision, realize it, and everything will be fine. But sometimes in the process of work you make discoveries that make you realize that the original vision was just the first draft. Initially, I thought that the main character will not fight, he does not use violence and just tries to survive in a dungeon in a cruel world, where there are spikes popping out of the floor, there are gates and falling slabs that can crush him, but he himself is not cruel. The goal was to overcome these traps and save the princess, and to implement this, I used all the resources available from Apple II. I had no place to insert another character.


At that time, I shared the office with friends who also worked on their own projects. Robert Cook worked on the D / Generation game. Tommy Pearce created educational software, and every time she, passing by, saw “Prince of Persia” on my screen, she repeated “Fights, fights, fights”. “You need battles, or this game will not be interesting,” and it bothered me, because I did not plan the battles. Karateka was a fighting game. The whole game was to meet the guard, fight with him, and then proceed to the next battle. I explained to Tomi: “I can’t make them because I don’t have enough memory, and besides, I need a smoothly animated enemy that can do everything the enemy needs.” But when an idea comes to Tomi, she doesn’t let her go, so I had to say: “Now there are torches on the walls. And now I added jaw traps,which cut the hero and increase tension. Isn’t that better? ” Tomi evaluated the new feature and said: "Fights, fights, fights." [takes a deep breath] And I realized in despair that there was something in her words. No matter how much I wanted the game to be almost ready, it simply didn’t carry away, and that was the problem: two years of development, I used almost all the available memory, but the game lacks the tension, delight and the feeling of conflict that made Karateka "So simple and very interesting. What should I do?but the game lacks the tension, delight and the feeling of conflict that made Karateka so simple and very interesting. What should I do?but the game lacks the tension, delight and the feeling of conflict that made Karateka so simple and very interesting. What should I do?

I can tell you exactly what happened. That day in June 1988 (I know, because I wrote it in my journal), Tomi came back again, looked at the screen and said: “Fights, you need fights.” And again I rolled out my usual argument: firstly, this does not correspond to the concept of the game, and secondly, there is not enough memory. She said: “In Karateka, you used the same figures for the hero and for the enemy, can you do the same?” I replied: “No, because the hero looks like an attractive, indestructible character. The enemy should not look like that. ” And she said: “Well, what if you make enemies of a different color?” And the idea came to me: what if I execute XOR for each byte with myself shifted by one bit?

Apple II, as I understand it now, had no image processing capabilities because all the graphics were bitmaps. But one of the assembler instructions called "exclusive OR" (XOR) took two bits, and if they are the same, then it returns zero, and if they differ, then one. And when I explained to Tomi for the tenth time why I can’t draw the character in the wrong color, I realized that if you use the “exclusive OR” instruction with a shift of one bit, this will create a flickering, ghostly outline Main character. And as soon as I said these words, the name of this character arose: Shadow Man ("Shadow Man"). While Tomi and Robert looked over my shoulder, it took me only five minutes to write a code that turns the main character into a ghostly version of himself.As soon as we saw the Shadow man running, jumping and climbing the dungeon, it became obvious that he was the enemy that the game needed.


Robert suggested that a Shadow Man might arise when a hero jumps through a mirror: at that moment his ghostly copy jumps in the other direction, and then, lost in the dungeon, she becomes an enemy - steals potions, closes the gates that the player wanted to open, and generally creates all kinds of chaos. So, this character was forcedly born, which as a result became one of the best features of the game. This is an example of how constraints can sometimes push you to more creative solutions than you could find from the start, if they were available. If my limitation was not memory, then I might have created various monsters and enemies in Prince of Persia for a change, but since there was no room for them, I had to dig deeper and come up with the Shadow Man, who as if it turned out to be deeper and more convincing.

At the end of the game, when a player encounters his shadow self and fights with his swords, with each hit on the Shadow man, the player loses a point of strength. The player realizes that if you continue to fight, you will kill yourself as a result, so the solution is not to win the sword fight, but to remove the sword. And when you remove the sword, the Shadow man does the same. If you turn to him and run, then the Shadow man will run towards him. Two will merge and reunite, and the player will get back all the health points that the Shadow Man stole from him during the game. Thanks to this restored power and integrity, he will be able to fight the great vizier and complete the game. I would never have come up with this if I hadn't had to.

As soon as the Shadow Man appeared in the game, it became obvious that this was correct, so I managed to put a few more frames into my memory for the implementation of sword fights so that the player could fight with a shadow copy of himself. It turned out to be very convincing, and now I needed to populate the dungeon with guards in any way. At this late stage of development, I found a way to borrow 12 KB of memory, which was hidden in an additional Apple II memory card, and add a guard. But at the same time, a new problem arose - how to create animations for enemies?

The Prince of Persia animation model was my younger brother, who was now three thousand miles from me. In addition, he did not know how to fight with swords, so first I tried to record myself and my colleague in Robert's office, we held swords and fenced. Unfortunately, this did not work. In desperation, I turned on one of my favorite films, 1938 Robin Hood, with Errol Flynn, and it turned out that there was a climactic duel with Basil Rathbone in this film. It contained a scene of about six seconds in which two characters fighting each other were shot perfectly in profile. I took photos of each inventory from the 1938 Robin Hood VHS cassette, received the movements that the characters would need for a sword fight, and as soon as I realized the guards, the game seemed complete to me.

Now, moving through the dungeons, the player felt a sense of rivalry, tension, fear, which became an important part of the success of Karateka. The lesson I learned from this can be formulated as follows: if two voices sound in your head, two approaches that give two different solutions, diametrically opposed to each other, you should try to listen to each of the voices and think, “Does this voice tell me about the big picture? " Because sometimes great ideas can come up that divert you from the intended path, but sometimes this voice actually takes you back on the path. The shadow man was the right decision because it correlates with the original source of inspiration for “Prince of Persia.” In fact, this is a modern version of the “cloak and sword movie,” and in these old films the heroes, whether Errol Flynn,Douglas Fairbanks or Indiana Jones fought, so it was fully in line with the spirit of the game.

"Prince of Persia" was released in late 1989 on the Apple II. As I feared, the race over time was lost. By that time, Apple II was a dying platform, and for about a year I had a painful feeling that the game that I worked so hard on and that everyone who played it would disappear without leaving any traces. Ports to other platforms saved me: on PC, on Mac, as well as on consoles like Sega and Nintendo, which appeared over the next couple of years. This saved the game, turning it from a fiasco into a hit. And this is precisely what showed me that adding the Shadow Man and fights was the right decision, because on these platforms the memory problems, so critical for Apple II, no longer existed.

The inspiration gleaned from action and adventure films turned out to be the most important source that turned Prince of Persia into what it is. The popularity of “Prince of Persia” on PC turned out to be enough to create a sequel, “Prince of Persia 2: The Shadow and the Flame”. And by the time of the game in 1993, we already had a new generation of PCs capable of reproducing sounds and music, as well as displaying color graphics. Its capabilities far exceeded what was available in the late 80s, and we took advantage of this by adding more enemies, more characters and enriching the environment. We sent the prince on a journey around the world, which led him to the dungeon and castle "Prince of Persia 1". But the fundamental gameplay, the formula of traps, shoots, solving puzzles, battles and research, was pretty close tothat was present in "Prince of Persia 1". Since the time of the first Prince of Persia, technology has moved forward, but the basic issues of game design have barely changed. When we did a remake in 2003, “Prince of Persia: The Sands of Time,” we worked with a much later generation of consoles. The game on the PlayStation 2 generation, for the first time ever, had 3D graphics, the ability to rewind time, sound, music - all that Apple II could not afford, but we still had limitations. The first draft of The Sands of Time was much more complex, with all sorts of political intrigues with different factions within the kingdom. But from the finished game we cut it all out and left a much simpler story in which everyone in the kingdom turned into sand monsters. And this decision made it possible to create a game,which is really synchronized with what is possible to do on the controller, because all you come across are sand monsters. So your choice is: acrobatics, fight and escape, and this corresponded well with what the player could do, although we still had the opportunity to implement dialogs, facial animation, and much more. Having a large list of characters would push the game away from its strengths, that is, when creating the plot of the game, you need to plan decisions that emphasize its strengths, not weaknesses.Having a large list of characters would push the game away from its strengths, that is, when creating the plot of the game, you need to plan decisions that emphasize its strengths, not weaknesses.Having a large list of characters would push the game away from its strengths, that is, when creating the plot of the game, you need to plan decisions that emphasize its strengths, not weaknesses.


This year, the first “Prince of Persia” is 30 years old, and much of what I told you today I remember because I kept a magazine, so in honor of the 30th anniversary we again release these magazines in the form of the book “Prince of Persia. " These are the magazines that I kept during the creation of the games, so there are a lot of ups and downs, doubts and enthusiasm in them: “this game will be great”, “this game will be a disaster”, my thoughts are on how to solve specific problems. We also illustrated the magazines with screenshots of the work process and sketches, so I was very interested in this anniversary to return to the past and again look at these magazines, which I spent in the 80s mainly in pencil on paper.

All Articles