War Stories - How Prince of Persia Defeated Apple II's Memory Limitations

24 min read Original article ↗

00:00

[disk drives beeping]

00:02

[deep electronic music]

00:07

I developed a storyline for Shadow Man.

00:09

He comes back at predetermined moments through the game.

00:13

There's one point where he steals a potion.

00:15

Just as you're about to reach it,

00:17

Shadow Man comes running in,

00:18

drinks it and runs off.

00:20

There's another moment where you're about

00:22

to get through a gate,

00:23

Shadow Man walks up,

00:24

steps on the pressure plate,

00:25

and closes the gate.

00:27

At that point, you fall back down three levels,

00:29

and you're gonna have to work your way back up.

00:31

These encounters were scripted

00:33

to make you hate Shadow Man

00:35

and see him as your enemy,

00:36

so that by the time you face him with crossed swords

00:39

at the end of the game,

00:40

you really wanna get this guy

00:41

because he's set you back so many times.

00:43

It's a way to build an emotional relationship

00:45

between the player and an opponent

00:47

through the actual gameplay

00:48

rather than just telling it in a cinematic.

00:51

Hi, I am Jordan Mechner,

00:52

creator of Prince of Persia.

00:53

This is how I animated myself into a corner

00:56

and had to fight my way out.

01:02

So I was a kid in New York in the mid '70s.

01:07

I grew up on MAD Magazine,

01:08

and if computers hadn't come along when they did,

01:11

you know I might have ended up doing comics, animation,

01:14

but when the Apple II came in 1978,

01:16

I saw this as a machine that I could

01:18

first of all use to play games at home

01:20

which was never possible before.

01:21

Instead of taking rolls of quarters down to the local arcade

01:24

I could stay at home and play Space Invaders

01:26

on the Apple II as much as I wanted.

01:28

The computer was also a way that I could

01:31

and I became fascinated with that.

01:33

This is before the Internet,

01:34

so pretty much everybody was self taught.

01:37

I subscribed to Creative Computing magazine,

01:39

and then a little later Softalk magazine

01:41

which had articles about how to program,

01:43

and then I would trade tips

01:44

with my friends who were also into computers.

01:57

So my first games were copies of existing arcade games,

02:00

and you always had three lives,

02:01

and the goal was to get a high score,

02:03

but now I was a freshman in college,

02:04

and I wanted to do a game that would tell a story,

02:07

so that's when I started programming the game

02:09

that would become Karateka.

02:10

[bright synthesizer music]

02:14

It was a very simple story.

02:15

The princess has been kidnapped by the evil warlord

02:18

who has taken her to his castle,

02:19

and so as the hero you have to

02:21

fight a series of karate battles

02:23

with the warriors who are guarding the fortress.

02:26

So you're basically running from left to right,

02:28

you fight one warrior after another

02:29

until you reach the end,

02:30

and then you fight the big bad guy

02:33

and rescue the princess,

02:34

so the computer that I was working on was the Apple II,

02:37

and at that time the Apple was actually

02:39

the number one game platform,

02:40

but it had limitations.

02:41

The Apple II's music capabilities weren't that great,

02:43

it only had four colors,

02:45

the screen was 280×192 pixels,

02:47

and everything had to fit into 48K of memory.

02:50

That was pretty much a hard limit.

02:52

In those days this was before Photoshop,

02:53

this was before we had graphics and animation tools,

02:56

if you wanted to put a character up on the screen,

02:58

you pretty much had to do it pixel by pixel,

03:00

so when I tried to do the animation for the character,

03:03

I found out pretty quickly that it just looked stiff,

03:05

and it didn't just have the lifelike quality

03:08

that I was imagining in my head,

03:10

so I used a technique called rotoscoping

03:12

which actually has a long history.

03:13

It goes back to the early days of film animation.

03:15

Early Disney animators used film footage

03:18

as reference for the animation in the early films.

03:21

If you look at Snow White,

03:22

the human characters like Snow White and the Prince

03:24

were actually animated using rotoscoping,

03:26

which means that the Disney animators

03:28

filmed live actors doing the moves

03:30

that they needed to animate onscreen,

03:31

and then they would actually project these frames,

03:34

and copy or trace them frame-by-frame

03:37

to create the animation that we've seen.

03:39

So I did that for Karateka.

03:40

I used Super 8 film to film my karate teacher

03:43

doing the kicks and punches,

03:46

that I needed the character to do on screen,

03:47

and then I traced each Super 8 film frame

03:50

with tracing paper and pencil,

03:52

and then translated those into pixels

03:54

to get it up on the screen.

03:55

That was kind of the rotoscope 1.0.

03:57

[synthesized electronic music]

04:00

Karateka came out in 1984,

04:02

and it became a number one bestseller,

04:04

so this was really lucky for me

04:06

that it happened when it did,

04:07

because as I graduated from college

04:09

instead of going out and getting a job

04:11

I actually had the luxury of thinking,

04:12

What do I wanna do next?

04:14

And I had an idea to do another game.

04:16

One of the inspirations was the first 10 minutes

04:18

of the movie Raiders of the Lost Ark.

04:20

[suspenseful orchestra music]

04:23

If you remember Indiana Jones in the opening sequence

04:25

runs jumps over a pit almost misses,

04:29

spikes spring out of the wall,

04:30

there's a gate that's closing,

04:32

and to me, those actions kind of matched

04:34

what I was seeing in platform games,

04:36

like Lode Runner and The Castles of Doctor Creep

04:38

where you'd step on the pressure plate,

04:40

it would open a gate.

04:41

I thought what if we combined that gameplay

04:43

with a character who's so human feeling

04:45

that you feel like if you miss the jump

04:47

and you fall it's really gonna hurt.

04:48

Because in the early platform games

04:50

characters were kind of weightless.

04:51

You know you would jump, and you would make it or not,

04:53

but you would float down to the bottom

04:56

It didn't feel like you could really get hurt.

04:58

So my idea was to kind of combine

04:59

the basic platform puzzle type gameplay

05:02

in sort of a modular environment

05:03

with very smooth visceral running and jumping animation

05:07

that would capture the excitement

05:08

of the opening minutes of Raiders of the Lost Ark

05:10

[dramatic orchestral music] [man grunting]

05:17

The story of Prince of Persia was also simple.

05:20

Like Karateka, it involved rescuing a princess.

05:22

And it was really inspired by

05:25

the Thousand and One Nights

05:26

and by movies like the 1940 The Thief of Bagdad

05:29

in which an evil grand vizier has seized power

05:32

and imprisoned the princess.

05:34

For Prince of Persia I knew

05:35

I was gonna need so much more animation

05:37

Running, jumping, climbing, falling:

05:39

all the movements that the little character

05:41

would have to do on screen.

05:42

And by the the time I did the animation

05:43

for Prince of Persia in '85,

05:45

a new technology had come along, VHS.

05:47

So using one of the early VHS cameras,

05:50

I videotaped my brother running and jumping

05:52

and doing all those things in the parking lot

05:53

across the street from our high school

06:01

Get up get, up get up!

06:03

And then the problem was

06:04

how to get these videotaped frames into the computer.

06:06

After a bit of trial and error,

06:08

the technique that I finally settled on

06:09

for Prince of Persia

06:10

was a kind of analog-to-digital to analog-to-digital

06:13

and involved several steps.

06:15

I took the video tape of my brother

06:17

and put that on a TV screen in a darkened room

06:20

put a 35mm camera on a tripod

06:23

aimed it at the TV screen

06:24

and then took a picture,

06:26

did a frame advance on the VCR,

06:27

took another picture,

06:29

frame advance, frame advance, frame advance

06:31

then I took that roll of film containing about 35 frames

06:35

down to the local Fotomat, the one hour photo

06:37

had the film developed

06:38

and then got back a sheaf of snapshots

06:40

which I then Scotch taped together

06:42

and using a Sharpie and Wite-Out

06:45

highlighted the outlines of each character

06:47

then put that on a Xerox machine

06:49

and came out with one clean sheet of paper

06:51

with a series of frames of a clean white character

06:55

against a black background

06:56

so that contrast was sharp enough

06:58

that I could then put that piece of paper

06:59

on an animation stand,

07:01

pointed a video camera at it,

07:02

and ran that into the Apple II which had no video in.

07:05

This was a special digitizer card

07:06

that could get one clean still image.

07:09

It couldn't capture motion,

07:10

but once I had that sheet of nine or 12 individual frames

07:15

I could then go in pixel by pixel and cut them out

07:17

on screen using my animation tool

07:19

and then run those frame in sequence,

07:20

and so all of this took weeks of work

07:23

to get from that video tape run or jump

07:26

to the point where the game was actually playing back

07:28

those frames in sequence on screen.

07:34

When I first saw that character running

07:35

and jumping on the screen,

07:36

it had the rough illusion of life and of weight,

07:40

but these were the days of eight-bit graphics.

07:42

Each frame of animation in Prince of Persia

07:44

was a series of bytes that represented

07:47

a fixed image on the screen,

07:48

and then the next frame of animation

07:50

was another set of bytes,

07:52

so to do something like jump in place took 12 frames,

07:55

to do a running jump might take 15 frames,

07:58

and the number of frames made the animation smoother.

08:02

So once you add the jumping, the running, the turning,

08:05

the hanging, the swinging, all of these things,

08:08

each individual movement took memory.

08:10

This is where one difference between computers then

08:13

and now became very important

08:14

because the Apple II's memory was 48K.

08:18

That's less than a normal text email,

08:21

so that had to contain everything:

08:22

all of the images, all of the backgrounds,

08:24

all of the frames of animation,

08:26

all of the logic to make it work,

08:27

all of the sound effects, all of the music, everything.

08:30

So with all of the basic animations

08:32

that the character needed to navigate,

08:34

through the dungeons, that had filled up

08:35

all of the computer's available memory.

08:50

So it was June of 1988,

08:52

and I was two years into making Prince of Persia

08:54

and at this point I had done most of the heavy lifting

08:56

to get the game working.

08:57

I had a smoothly animated character

08:59

that was running through these dungeons

09:01

climbing and falling and stepping on pressure plates

09:04

to open gates and jumping over pits

09:06

almost falling on spikes.

09:07

Everybody who saw the game oohed and ahhed.

09:09

It was like a great proof of concept,

09:12

but it wasn't that much fun to play,

09:14

and I kind of had the sinking feeling as I realized

09:16

that I've done almost everything I meant to do,

09:19

but it just doesn't have that excitement

09:21

that I was hoping for.

09:22

Also there was a ticking clock

09:24

which is that the Apple II platform was dying.

09:26

When I started to make Price of Persia,

09:28

the Apple II was still the number one games platform.

09:30

By 1988, there were new machines that were coming out

09:33

that had more colors, higher resolution,

09:36

better sound capability,

09:37

and I was really at the tail end

09:39

of the Apple II's life cycle,

09:40

but I felt that switching to a different platform

09:43

would have been like starting over,

09:44

so the worry was that I could come out with a game

09:47

that was great, that was fun,

09:48

but nobody would ever play it.

09:51

Yeah so it was a problem when you reach a point

09:52

in development that makes you question your initial vision.

09:55

Sometimes the answer is to say,

09:57

you know just believe in the initial vision,

09:59

execute it, it's gonna be fine.

10:01

But sometimes you discover things along the way

10:04

that make you realize

10:05

that the initial vision is just a first draft.

10:07

From the beginning,

10:08

I had the idea that the main character would not fight

10:11

that this was a nonviolent character

10:13

just trying to survive in a dungeon in a violent world

10:16

that is there's spikes that spring out of the floor,

10:18

there's you know gates and falling blocks

10:20

that can crush you,

10:21

but this is not a violent character.

10:23

The point is just to get through these traps

10:25

and get to the end and rescue the princess,

10:27

and I had used all of the resources

10:30

that the Apple II offered to try to create this.

10:33

I didn't have room to put in another character,

10:37

so I was sharing an office with friends

10:39

who were also working on their own projects.

10:41

Robert Cook was working on a game

10:42

that became D/Generation.

10:43

Tomi Pierce was creating educational software,

10:46

and every time Tomi saw Prince of Persia on my screen

10:49

as she walked by my desk,

10:51

she would say, Combat, combat, combat.

10:54

or this game is not going to be fun.

10:55

and this frustrated me because I hadn't planned for combat.

10:58

Karateka was a fighting game.

11:02

you fight the guard,

11:03

and then on to the next battle,

11:05

and so I would explain to Tomi,

11:06

I can't do that because there's not enough memory

11:08

in the computer to also have a smoothly animated enemy

11:11

that does everything that I would need an enemy to do.

11:14

But when Tomi got an idea,

11:15

she wouldn't let it go,

11:17

and so I would add a new feature to the game,

11:19

I would say, Now there's torches on my wall.

11:21

Now I've got jaw traps that chomp and add suspense.

11:24

Isn't it better now?

11:25

Tomi would look at the new feature I added and say,

11:28

Combat, combat, combat.

11:31

And with frustration I realized that

11:33

there was something to what she was saying.

11:35

As much as I wish that it was almost done,

11:37

it just wasn't that much fun,

11:38

so this was the problem:

11:40

two years into development,

11:41

I'd used up all the memory to get as far as I'd gotten,

11:44

but the game was missing that suspense and excitement

11:46

and sense of conflict that had made Karateka

11:49

so simple and so much fun.

11:50

What was I gonna do?

12:04

So I can tell you exactly what happened.

12:06

On that day in June 1988,

12:08

because I wrote about it in my journal,

12:10

it was another day in which

12:12

Tomi had come and looked at my screen and said,

12:15

Combat, you need combat.

12:16

And again I'd rolled out my usual argument about how

12:19

first of all that's not the concept of the game

12:21

second of all there's no memory,

12:23

and she said, Well in 'Karateka,'

12:25

you used the same shapes for the hero and the enemy,

12:27

couldn't you do that?

12:29

I said, No, because the hero looks like a likable

12:32

enduring kind of character.

12:34

The enemy shouldn't look like that.

12:35

And she said, Well,

12:36

what if you made the enemies a different color?

12:38

And then the idea came to me,

12:40

what if I exclusive-or'd each byte with itself

12:43

shifted one bit over?

12:44

[keyboard clacking]

12:46

So the Apple II didn't have image processing

12:48

in any kind of sense that we understand it now

12:50

'cause the graphics were all bitmapped,

12:52

but one of the assembly language instructions

12:54

was called exclusive-or

12:55

which basically means if the the two bits are the same,

12:59

if the two bits are different,

13:01

so as I was telling Tomi for the 10th time

13:05

why I couldn't draw a character in a different color

13:07

than the one I originally created,

13:09

I realized that if I used the exclusive-or instruction

13:12

shifted one bit over,

13:13

this would create kind of a shimmery, ghostly outline

13:16

of the main character,

13:17

and as soon as I said those words,

13:19

the character's name popped into being: Shadow Man.

13:22

So with Tomi and Robert looking over my shoulder,

13:25

it actually look me all of five minutes

13:27

to write the code that would turn the main character

13:29

into a shimmery, ghostly version of itself,

13:33

and as soon as we saw Shadow Man running, jumping,

13:36

and climbing through the dungeon,

13:38

it became obvious that this was

13:39

this was the opponent that the game needed.

13:42

It was Robert who suggested

13:43

that Shadow Man could come into being

13:45

when you jump through a mirror,

13:47

your ghostly self jumps out the other direction

13:49

and then once it's loose in the dungeons,

13:51

it becomes your enemy,

13:53

closing gates that you wanted open,

13:55

and just kind of wreaking all kind of havoc,

13:57

so out of necessity was born this character

13:59

who ended up becoming one of the best features of the game.

14:02

It's a case of where constraints can sometimes push you

14:04

to more creative solutions

14:06

than you would have found in the beginning

14:07

if they had been available.

14:09

If memory had not been a constraint,

14:10

I probably would have created all kinds of monsters

14:13

and enemies in Prince of Persia to add a lot of variety,

14:15

but because there was no room for any of that,

14:17

I was forced to dig deeper and came up with Shadow Man

14:20

which ended up actually being kind of deeper

14:22

and more satisfying.

14:23

At the end of the game when you confront your shadow self,

14:26

and you fight him with swords,

14:27

every time you hit Shadow Man,

14:29

you lose a strength point,

14:31

and you realize that if you keep fighting,

14:32

you're eventually gonna kill yourself,

14:34

so the solution is not to win the sword fight,

14:36

but to put away your sword,

14:38

and when you put away the sword,

14:39

Shadow Man does the same,

14:40

and then facing each other,

14:41

you run towards Shadow Man,

14:43

he runs towards you,

14:44

and the two of you merge and are reunited,

14:46

and then you get back all the health points

14:48

that Shadow Man had stolen from you throughout the game,

14:50

and with this restored strength and wholeness,

14:52

you're then able to fight the grand vizier,

14:55

That's something that I wouldn't have come up with

14:57

if I didn't have to.

14:59

Once Shadow Man was in the game,

15:01

it was obvious that that was the right way to go,

15:03

and so I managed to squeeze out of the memory

15:06

enough frames to do sword fighting

15:08

so that you could fight the shadow version of yourself,

15:11

and that was so compelling that it's alright,

15:14

I've got to find a way to populate this dungeon with guards,

15:16

and at this late stage,

15:18

I've found a way to take 12K of memory that was hiding

15:21

in the auxiliary memory card of the Apple II

15:24

but this presented a new problem.

15:26

How do we create the animation for the enemies?

15:28

So the model for the animations in Prince of Persia

15:30

had been my younger brother who at this point

15:32

was 3,000 miles away,

15:34

and he wasn't any good at sword fighting anyway,

15:36

so my first attempt was to film myself

15:39

and my office mate Robert with a sword doing fencing.

15:43

Unfortunately, that didn't work.

15:45

Finally in desperation, I turned to one of my favorite films

15:48

the 1938 Robin Hood with Errol Flynn,

15:50

and it just happened that in this film,

15:51

in his climactic duel with Basil Rathbone,

15:54

there's a sequence of about six seconds

15:55

where the two characters are perfectly in profile,

15:57

fighting each other,

15:58

so with a VHS tape of the 1938 Robin Hood,

16:01

I took photographs of each frame of film,

16:03

and extracted the moves that the characters would need to do

16:07

in order to do sword fighting,

16:08

and once the guards were in there,

16:10

the game felt complete.

16:12

Now as you move through the dungeons,

16:13

you had that feeling of challenge,

16:15

of suspense, of fear

16:16

that had been such an important part

16:18

of what made Karateka successful.

16:29

The lesson, if there is one,

16:30

you know the best way that I've been able to formulate it

16:32

is that when you have these two voices,

16:34

you know two different approaches in your brain,

16:36

giving you two different solutions

16:38

that are diametrically opposed

16:39

to really try to tune into each voice

16:42

and think, Is this the voice you know of the big picture?

16:44

Because sometimes you can have great ideas

16:47

that are kind of taking you off the path

16:49

of what you originally set out to do,

16:50

but sometimes that voice is actually

16:52

putting you back on the path.

16:53

The reason that Shadow Man was the right thing to do

16:55

I think goes back to the original inspiration

16:57

of Prince of Persia.

16:58

It's basically the modern version of a swashbuckling movie,

17:01

and in those old swashbuckling movies

17:03

whether it was Errol Flynn or Douglass Fairbanks

17:05

or Indiana Jones, the hero did fight,

17:07

so it's completely in line with that spirit.

17:11

Prince of Persia released at the end of 1989

17:14

and as I'd feared, I'd lost the race against time.

17:17

By then, the Apple II was a dying platform,

17:19

and for about a year,

17:20

I had the agonizing experience

17:22

of feeling that this game that I'd work so hard on

17:24

which everybody who played was enjoying,

17:26

that this game was going to sink without a trace.

17:30

What saved it was the ports to other platforms,

17:33

to the PC, to the Mac,

17:35

and also to consoles

17:36

like Sega and Nintendo

17:37

that came out over the next couple of years,

17:40

and kind of rescued this game that had been a flop

17:42

and made it into a hit,

17:44

and that's what actually made it really clear to me

17:47

that adding Shadow Man and combat had been

17:49

the right thing to do

17:50

because on these other platforms,

17:52

the memory issues that had been so critical on the Apple II

17:57

Those swashbuckling cinematic roots turned out

18:00

to be a key part of you know what made Prince of Persia

18:05

Prince of Persia was successful enough on PC

18:07

that we did a sequel.

18:08

Prince of Persia 2: The Shadow and the Flame

18:10

and by the time this game came out in 1993,

18:13

we had a new generation of PCs that could do sound

18:16

and music and color graphics way beyond

18:19

what was possible in the late '80s,

18:22

and we took advantage of this,

18:23

adding more enemies, more characters,

18:25

and richer environments, sending the prince on a journey

18:28

across a world that got us of the dungeon and palace

18:32

of Prince of Persia 1.

18:33

But the basic gameplay,

18:34

the formula of traps,

18:36

fight and flight, puzzle solving,

18:37

and combat and exploration,

18:39

was still pretty close to what it had been

18:41

in Prince of Persia 1.

18:43

Since the original Prince of Persia,

18:44

the technology has advanced,

18:46

but the basic questions of game design

18:48

haven't really changed all that much.

18:49

When we did the remake in 2003,

18:51

Prince of Persia: The Sands of Time,

18:55

a much later generation of consoles.

18:56

The PlayStation 2 generation,

18:58

and so for the first time, we had 3D graphics,

19:01

the ability to rewind time,

19:03

sound, music, you know all these things

19:05

that the Apple II couldn't do,

19:06

but we still had constraints.

19:07

The first draft of the story for The Sands of Time

19:10

had been much more complicated with kind of

19:12

this political intrigue

19:13

and you know different factions within the kingdom,

19:16

so for the final game,

19:17

we ended up stripping all of that out,

19:20

and going with a much simpler story

19:21

in which everybody in the kingdom has been transformed

19:24

into sand monsters,

19:25

and that one decision made it possible to design a game

19:28

that was actually in sync with what you could do

19:30

with a controller in your hands

19:31

because everybody that you met was a sand monster,

19:33

so your only options really were acrobatics,

19:36

combat and running away,

19:38

and that was a good fit with what you could do as a player,

19:42

even though we had the ability to do dialog

19:44

and facial animations and so forth.

19:46

Having a large cast of characters would have taken

19:49

the game away from its strengths,

19:51

so in designing a game story,

19:52

you really want to plan choices that emphasize the strengths

19:56

rather than emphasizing the weaknesses.

20:00

This year is the 30th year anniversary

20:01

of the original Prince of Persia,

20:04

and a lot of what I've told you today

20:06

I remember thanks to the fact that I kept a journal,

20:08

so we're actually re-releasing these journals as a book

20:11

for Prince of Persia's 30th anniversary.

20:13

They're the journals that I kept at the time

20:14

as I was making the games,

20:16

so it's got all of the roller coasters,

20:17

of all the ups and downs of,

20:19

this game is going to be great,

20:20

this game is going to be a disaster,

20:22

and how do I solve this particular problem?

20:24

We've also illustrated the journals with screenshots

20:27

of the work in progress and sketches,

20:30

so it's been a lot of fun for me on this anniversary

20:33

to have a reason to go back

20:34

and look at those little journals again

20:36

which being in the '80s are mostly on pen and paper.