9 ms·
Prince of Persia source code released (Apple II assembly)
- abuzzooz 15y agoI didn't know it was all written in Assembly. Is there any documentation to help with reading the code? Thanks for the code btw. PoP is a landmark in the history of computer games.
- thirdhaf 15y agoOf course, you need only go to the horse's mouth. [1] It's been posted before but Jordan, the creator of both Karateka and Prince of Persia, has a wonderful series of journals documenting his travails with video games and the movie industry. [2] As part of this he has a detailed description of his trek out to California and a lot of details on technical obstacles that make you thankful to live in the second decade of the third millennium. [1] http://jordanmechner.com/wp-content/uploads/1989/10/popsource009.pdf http://jordanmechner.com/wp-content/uploads/1989/10/popsourc... [2] http://jordanmechner.com/ http://jordanmechner.com/
- wildtype 15y agoI can't find the Makefile :D
- vessenes 15y agoCue DCPU-16 port in 3..2..
- chris_wot 15y agoAnyone got any good Apple Assembly manuals? :-)
- vidarh 15y agoDepends. The CPU is "just" a 6502, so there's plenty: * http://www.6502.org/ http://www.6502.org/ * Most of the machine code books here: http://www.bombjack.org/commodore/books-generic.htm http://www.bombjack.org/commodore/books-generic.htm As for Apple-II specific details (graphics chipset etc.) someone else will need to chip in - never even saw an Apple-II during my childhood, Norway like much of Europe was Commodore dominated.
- krevis 15y agoThis made me laugh. The words "Apple II" and "graphics chipset" don't belong in the same sentence! The Apple II graphics were a fantastic, and fantastically weird, low-hardware hack. http://en.wikipedia.org/wiki/Apple_II_graphics#Video_output_on_the_machines http://en.wikipedia.org/wiki/Apple_II_graphics#Video_output_...
- vidarh 15y agoThat does sound rather strange. But fascinating... Stuff like that seems like it might explain some of the mutual disdain that Chuck Peddle and Woz seems to have ended up with after their early encounters (when Peddle was on his 6502 "sales tours"; though maybe interviews and books have exaggerated it). I can totally see this being the type of hack that would excite someone like Woz to pull off but that would make Peddle's straight laced inner formal engineer rage... Combine Commodore / MOS engineerings early problems getting a decent color graphics chip together but cultural refusal to go for something more hacky (the did plenty hacky stuff but only when Tramiel put jobs on the line) to get out the door quicker, with plenty of blame being put allocated to Peddle on a regular basis, and I can see lots of ego getting caught up in it..
- Someone 15y agoI think you will be interested in the design of the Macintosh video/audio hardware, too, then; http://www.folklore.org/StoryView.py?story=Sound_By_Monday.txt http://www.folklore.org/StoryView.py?story=Sound_By_Monday.t... gives some details. IIRC, things were even better. There were two (740 byte, IIRC) buffers from which samples were taken at every horizontal refresh. The sound driver used one to get samples to send to the speaker; the disk driver used the other to control the rotation speed of the disk drive (using pulse-width modulation).
- larrywright 15y agoThat second link is a treasure trove of 80s-era computer books. I'm surprised at how many of those I owned and/or read.
- pooyak 15y agowait! no "megahit" in source? this can't be real...
- wladimir 15y agoMaybe that cheat was only in the PC version? I wonder how the PC version (which I've played and fondly remember) and Apple 2 version differ.
- jipumarino 15y agoJordan, regarding the PC version, 01/26/1990: This is going to be the definitive version of Prince of Persia. With VGA and a sound card, on a fast machine, it'll blow the Apple away. (In contrast, none of the Karateka conversions was as good as the Apple original)
- deleted 15y ago[deleted]
- daeken 15y agoIt's not like there was a choice -- at that time, you had to do a lot in a small space, with very little in the way of computational power. If you wanted to write a game, you had to do so in assembly. Mind you, games were much simpler then. And sure, x86 might be easier to understand, but it's not the original PoP. That's what this is about, not just the code.
- vidarh 15y agox86 might be easier to understand for someone who happens to know x86, but frankly for someone who doesn't have previous exposure to assembly, I'd be willing to bet it'd be far quicker to pick up the 6502...
- daeken 15y agoReally depends on what you mean by x86. If you're talking 16-bit real mode code, it's pretty straightforward -- C in assembly form, largely. If you're talking pmode code, modern asm, I tend to agree. I hope this rekindles an interest in 6502 asm, though!
- deleted 15y ago[deleted]
- vidarh 15y agoI'm an old C64 and Amiga guy - the first time I saw x86 code I was horrified. 16-bit real mode or not, when I finally gave up on my dying Amiga was when I stopped writing assembly as well - x86 assembly was where I drew the line. I didn't want to make that transition. In other words, I don't agree that 16-bit real mode is much better. Now, mdern x86_64 code is starting to get tolerable, with more orthogonal register, for example. But I'd rather chew off my own hand than be forced to write any large amount of 16 or 32 bit x86 assembly.... Then again, I'm horribly opinionated about programming language syntax...
- snprbob86 15y agoI'll have to find some time to settle down in a deep leather chair with my smoking jacket and a snifter of brandy for a fine evening of reading through someone else's code. Sounds like fun!
- angerman 15y agoBrilliant!
- angerman 15y agoSo many down votes? I liked the reference to the recent item "Learn to read the source, Luke"[1] quite a lot! [1]: http://news.ycombinator.com/item?id=3849203 http://news.ycombinator.com/item?id=3849203
- untog 15y agoI think the reason you were downvoted was that your comment didn't really say anything unique- it just agreed with the parent.
- StCroix 15y agoLove it!
- AmarettoAndCode 15y agoOh, how history repeats itself..
- Trufa 15y agoI really hope the YC comment section doesn't become the reddit.
- deleted 15y ago[deleted]
- snprbob86 15y ago
- DanBC 15y agoSee also this (http://news.ycombinator.com/item?id=961713 http://news.ycombinator.com/item?id=961713) discussion about the source code documentation.
- cfontes 15y agoNow just wait 10 minutes to get a port to DCPU-16.
- jcromartie 15y agoI never did assembly on those old machines, just BASIC and Logo in elementary school, and some Turbo C by the time we had a 386. I had heard of assembly and thought it was inherently "scary" and obtuse. But this PoP code is pretty easy to follow, and I probably should have taken the plunge way earlier. Neat.
- pmjordan 15y agoI recently thought about how I started programming and to my dismay I probably held myself back by 6 years or so by lack of confidence: 1. not having the confidence to talk to the 3 or 4 older kids at school who clearly knew about this stuff. 16 & 17-year olds were terrifying to my 10-year-old self. They of course graduated secondary school soon after, so there was a small window and I missed it. 2. I really wish I hadn't believed any adults claiming this stuff was "hard" or "scary". None of them did any real programming, so how would they know? I should have just pestered my parents to find me an x86 instruction and architecture reference - I'm sure I could have worked everything out from there, after all I had enough spare time. I started with BASICA on an 8088 and eventually was given a 486 after my parents got fed up with me hogging their computer; alas, it took years before I picked up C & C++ and assembly language shortly after. As a 10-year old in rural Austria, my possibilities for obtaining this kind of information myself were pretty limited, and everyone (parents, teachers) was constantly encouraging me to focus on science (physics) instead of programming. Still, I shouldn't harp on too much about #2. I was into electronics before I heard about programming and was obsessed with wanting to build my own computer, and tried to get hold of information on doing so, only to be told it was "impossible". (a 6502 plus some manuals would almost certainly have done the trick, and in 1993 couldn't have been that expensive - but I guess by that point the "kit" computers were long dead) So clearly being more assertive about wanting programming information would not have helped much either. I hope I don't fuck this part up if I have kids of my own.
- sliverstorm 15y agoI hope I don't fuck this part up if I have kids of my own. The hard part is the "thing to learn" may not be computers and programming, it may be something entirely new. That's why your elders seem like they were out of touch- tech was so new and all. It looks like a great choice from 2012, but from 1990 it was more of an unknown, and there will be similar developments in the future in other fields that challenge new parents to allow their kids to explore fledgeling prospects.
- _pferreir_ 15y agoI had no idea it had been written in assembly. I am amazed. The awesomeness of this thread is unprecedented.
- eru 15y agoTo give you another example: Transport Tycoon was also written in assembly.
- octotoad 15y agoAlmost all of Rollercoaster Tycoon as well. Blew my mind when I found out.
- _pferreir_ 15y agoCan't they publish the source code for those as well? I'm sure many of the original developers of early games that are now abandonware still have a backup of the source code lying around.
- cdmoyer 15y agoI think this part of the README is relevant: Thanks to Jason Scott and Tony Diaz for successfully extracting the source code from a 22-year-old 3.5" floppy disk archive, a task that took most of a long day and night, and would have taken much longer if not for Tony's incredible expertise, perseverence, and well-maintained collection of vintage Apple hardware. From this we learn that the code, today, only existed in an out-dated medium, readable on vintage hardware, and even meeting those prerequisites, still involved a fair amount of human expertise and time to extract. I'm sure they could, but unless they also have a book to promote, it's probably not worth their time. Well, I think it would be, simply as a contribution to the history/record of the era... but they likely aren't going to recoup the time or effort other than in goodwill. (I also suspect there's probably legal, copyright, and ownership issues involved as well.)
- jasonlotito 15y agoAnd, just as a reminder, there is a wonderful book. It's from the journal Jordan Mechner kept at the time. It's an excellent read. http://jordanmechner.com/ebook/ http://jordanmechner.com/ebook/
- talmand 15y agoI agree, it is quite interesting to read his thoughts as he was going through the process of developing the game and what the industry was like at the time.
- st3fan 15y agoMy first patch https://github.com/st3fan/Prince-of-Persia-Apple-II/commit/d232cb1e279e295ee4396f22d84c84ef7c493925 https://github.com/st3fan/Prince-of-Persia-Apple-II/commit/d...
- deleted 15y ago[deleted]
- acomjean 15y agoLoved that game when I was a kid. love the sound code. Having to write your own "tone" routines to tweak a sound out of the speaker...
- albertzeyer 15y agoI wonder, how was this ported to PC? Completely rewritten from scratch? Or was there some AppleII -> x86 translator?
- TazeTSchnitzel 15y agoIn those days it would have been almost certainly rewritten. Although it would maintain a lot of similarities.
- bonch 15y agoPorts at that time were rewrites in almost all cases.
- famousactress 15y agoEffectively, yes. It sounds like it was basically a rewrite. The book of journals for the game development that lots of other folks have led to talked about the process of finding a programmer to do the work in a fair bit of detail. Like everyone else has said, the journals are well worth reading. Best money I've spent on an e-book this year for sure.
- schiffern 15y agoWow, and the day after the 35th anniversary of the first public showing of the Apple II: http://techland.time.com/2012/04/16/apple-ii-forever-a-35th-anniversary-tribute-to-apples-first-iconic-product/ http://techland.time.com/2012/04/16/apple-ii-forever-a-35th-...
- binarycrusader 15y agoNo license or copyright stated. Doh! (Which technically means we don't have permission to do anything with the source at all, though I doubt that's what Jordan intended.)
- eru 15y agoYou can trade patches. Isn't that how Linux got started, as patches to Minix?
- binarycrusader 15y agoIn the last few hours the author has updated the repository to make it more obvious what the license is and placed this text in README.mkd: We extracted and posted the 6502 code because it was a piece of computer history that could be of interest to others, and because if we hadn't, it might have been lost for all time. We did this for fun, not profit. As the author and copyright holder of this source code, I personally have no problem with anyone studying it, modifying it, attempting to run it, etc. Please understand that this does NOT constitute a grant of rights of any kind in Prince of Persia, which is an ongoing Ubisoft game franchise. Ubisoft alone has the right to make and distribute Prince of Persia games.
- sehugg 15y agoThis is a very interesting thought exercise on "what if you could send modern programming languages back to the 1980s?" http://prog21.dadgum.com/6.html http://prog21.dadgum.com/6.html It would be interesting to analyze early Apple ][ game images and see which didn't use assembly. Wizardry was a notable example for using USCD Pascal, essentially running in a VM. Infocom games of course used Z-code. Applesoft BASIC was fine for some text adventures (Eamon for example). There were also programs like Microsoft's TASC that compiled Applesoft to binary, much of the speedup gained by converting floating point values to integer. The SWEET16 interpreter was also built-in to ROM, but I don't know if any titles used it. But almost every game relied on some kind of special graphics technique to wow the player, and that usually meant at least one neato routine hand-optimized in assembly. Drawing a sprite to the Apple's frame buffer was actually much more complex than blasting RGB values like we do today.
- nevster 15y agoThanks for that link. I never knew Marble Madness was written in C!
- deleted 15y ago[deleted]
- rbanffy 15y agoAztec-C's performance on the II at least was terrible. A colleague explored it for a project and gave up - the program ended up being developed in GraFORTH. Very fast.
- js2 15y agoNot just text adventures, the original version of Ultima I was written in Applesoft BASIC too.
- rbanffy 15y agoI love the 6502. One day I'll finally get to learn VHDL and build myself a 64-bit 6564. x86 is no fun.
- joezydeco 15y agoYou can use the OpenCore 6502 as a start. Cut-and-paste! http://opencores.org/project,6502vhdl http://opencores.org/project,6502vhdl