New Project: Ultima 1 Revisited

I chanced across this project whilst scouring Google for interesting and hitherto unknown (at least to me) tidbits of information about Ultima 1, in preparation for tomorrow’s launch of the first four Ultima games on Good Old Games.

The project’s mastermind, kingspud, gives a basic synopsis of his intentions with Ultima 1 Revisited here:

…today I embark on a journey to bring back those wonderful days when life was simple and all I worried about was playing and trying to program Richard Garriott’s Ultima 1 adventure.
I dusted off my old Apple IIe computer and pulled out all the old Apple programming books and manuals that I could find. To my ultimate surprise, “no pun intended”, the old girl sparked to life with a single flick of the switch. Once I slid in my DOS 3.3 disk and Reset the system, I was presented with the ultimate gift, “again, no pun intended” the magical ] symbol.

Now that I know I have a working Apple IIe computer I plan on reliving, no… revisiting if you will, those magical days when Richard Garriott had a dream to programming a game unlike no other game out there. Ultima 1 was that game! Those days when he sat in his closet programming in Applesoft Basic to the wee hours of the night! I shall be embarking on the same journey, to not only relearn the Apple IIe computer but to relearn to program in Applesoft Basic and Machine Language! My goal is to recreate the entire Ultima 1 program in Applesoft Basic on my Apple IIe computer! I hope to relive the excitement of creating a masterpiece of code and adventure.

I will be blogging about my progress with learning Basic and Machine Language again. I will be reviewing some of the old Apple programming books that Richard may have read to increase his knowledge in the art of programming. I will also be posting my code and examples as I travel along this quest to recreate the entire Ultima 1 game from scratch.
No code has ever been available on the web and no information has been posted regarding the Applesoft basic code for the Ultima games. I do know that Richard programmed all three of the first Ultima games using only Applesoft Basic. This is what I will follow and will only be using the same Basic and some machine language codes.

So far, in five months, kingspud has made excellent progress, although he has departed somewhat from his goal; the last update to the site for August 2011 demonstrated an improved graphical look for his version of the game.

Naturally, I have added a project entry for his effort, although I am fairly confident that (for various legal reasons) he will never be able to release his work for download by others. There is no harm in his blogging about his progress on the challenge, however, and I’m sure it will prove to be an insightful glimpse into the particular (and peculiar) challenges of writing a top-tier RPG adventure for such an ancient computer system.

39 Responses

  1. Odkin says:

    Hmmm….
    The original Cal Pacific version WAS published in BASIC, and although not as commonly available as the later Origin machine language rewrite, it IS out there. A quick CTRL-C during the boot and the disk image is CATALOGable and LISTable.

    I’m sure a few lines of code from the file ULTIMA would constitute fair use…
    ]LIST

    0 ONERR GOTO 9900
    10 LOMEM: 30730
    20 REM
    30 D$ = CHR$ (13) + CHR$ (4): POKE
    25,1
    50 HOME : VTAB (2): HTAB (14): INVERSE : PRINT “—-ULTIMA—-“: NORMAL
    : PRINT : HTAB (14): PRINT ”
    FROM DARKEST “: PRINT : HTAB
    (14): PRINT ” DUNGEONS, TO ”
    : PRINT : HTAB (14): PRINT ”
    DEEPEST SPACE!”: PRINT : PRINT
    : PRINT ” (C)-1981 BY
    LORD BRITISH,”: PRINT ”
    CALIFORNIA PACIFIC COMPUT
    ER”
    70 PRINT : PRINT : PRINT ”
    0-# OF DISK DRIVES = “;: INVERSE : PRINT PEEK (25): NORMAL : PRINT
    : PRINT ” 1-GENERATE
    NEW CHARACTER”: PRINT : PRINT
    ” 2-CONTINUE PREVIOU
    S GAME”: POKE – 16303,0: POKE
    – 16368,0

    Obviously ETC…..
    There are a number of shape table Binary files, but most of the disk space is APPLESOFT files like INIT DISPLAY, OUT MOVE, TWN MOVE, CAS MOVE, SPA MOVE and DNG MOVE.

    Origin rewrote the game entirely years later, and I;m sure those rights are protected. But I’m not so sure anyone has taken any steps to protect the copyright on the original 1979 APPLESOFT CODE.

  2. Sanctimonia says:

    That’s funny that everyone seemed to agree that the source code for the early Ultimas was lost, as unless this is a hoax I’ll be damned if I’m not looking at it in this post.

    Can someone please clarify if the earlier Ultimas weren’t just interpreted code that the “binary” is fully capable of displaying?

    Please provide links or attachments to kevinfishburne at eightvirtues dot com if you’re concerned about legal stuff, as I don’t give a flying flock about that kind of inanity.

    If this isn’t a hoax, this is the sort of earth shattering event that should be held up as a one-of-a-kind “holy shit” moment. Richard Garriott’s actual code for Ultima? My god.

  3. Sanctimonia says:

    From my quick Google searches on snippets of source code, this is either bullshit or not indexed.

  4. Monotremata Dragon says:

    Kingspud’s just a little bit off with his history.
    The only Ultima written in Applesoft BASIC is the original Cal Pacific version of Ultima 1.
    The rest were in machine language.
    Garriott says in the Official Book of Ultima the first lines of machine language he ever wrote were the first lines of Ultima II and he just jumped right in and learned it.

  5. Odkin says:

    Boy, I didn’t know I was really on to something here. I just sent the Ultima 1 Revisted guy a long email and my disk images, which I fired up in AppleWin and they work fine. This isn’t a hoax or bullshit. I’ve been commenting here for a long time. The original Ultima is listable in Applesoft BASIC.

    I still have my original Cal Pacific disk, which I made a cracked copy of in 1982 or so using Hardcore Computing articles. The “source code” exists on every single original Ultima disk, as it truly was just a series of APPLESOFT files with some binary support picture and shape table files. I think that star animations in the space sequence use some Assembly subroutines.

    I think the problem is that the Origin machine language rewrite was so much more playable that there are very few cracked versions of the original edition game disk. It really was SLOW. Dungeons redrew line by line. You more often than not got resurrected in the middle of the ocean. There were no Up and Down keys (you used “RETURN” and “/”).

    Anyway, I’m not adverse to sharing it if WTF Dragon wants to contact me.

  6. Odkin says:

    Just my luck, this supposed big find gets buried under a barrage of GOG updates. Oh well. More code anyone? 🙂

    3910 PRINT “DO YOU OFFER GOLD,”:
    PRINT “OR SERVICE? “;: GOSUB
    3790: PRINT Q1$: IF Q1$
    “G” AND Q1$ “S” THEN PRINT
    “NEITHER, THEN BEGONE!”: RETURN

    3911 IF Q1$ = “G” THEN 3980
    3912 IF QU%(FA * 2 + TN) > 0 THEN
    PRINT “YOU ARE ON A QUEST”:
    PRINT “FOR ME ALREADY FOOL!
    “: RETURN
    3914 QU%(FA * 2 + TN) = 1: IF TN =
    1 THEN 3935
    3920 SPEED= 35: PRINT “GOOD, GO
    AND FIND”: PRINT TDT$(FA * 2
    0 + 3): PRINT “DO NOT RETURN
    UNTIL”: PRINT “THY QUEST IS
    DONE!”: GOSUB 5000: SPEED=
    255: RETURN
    3935 SPEED= 35: PRINT “GOOD, GO
    NOW AND KILL A”: PRINT MN$(F
    A * 5 + 30): PRINT “DO NOT R
    ETURN UNTIL”: PRINT “THY QUE
    ST IS DONE!”: GOSUB 5000: SPEED=
    255: RETURN

  7. Odkin says:

    Hmmm. I’ve sent proof to three people with no response or contact, and the comments about “hoax” and “bullshit” remain unretracted…

  8. Sanctimonia says:

    I suggested it was a possibility, stating “…this is either bullshit or not indexed [by Google].” I also said, “If this isn’t a hoax…” which isn’t the same as saying it was a hoax. Did you email me a copy? I haven’t received it.

    I believe that it exists and that you have it. What makes me suggest the possibilities of hoaxes/bullshit is that I find it incredible that no one has been all over this before now. Garriott’s source code for Ultima, no matter how buggy or slow, is about as important and historic as things get for this Ultima fan.

  9. Odkin says:

    I did email you, WtF and the Ultima 1 Revisited guy. Will resend to kevinfishburne at eightvirtues dot right now.

  10. Sanctimonia says:

    Got it. =) Damn thing was in my Junk folder for some reason. I’m going to look for utilities and/or use an emulator to try to put together a complete code listing. This is fantastic! Thank you.

  11. Odkin says:

    Great! The Applesoft programs are LISTable to a print file, so that part is easy. The Binary files are just data storage for HGR pictures (boot screen, city and castle interiors), shape tables, or data matrices of the Maps. Be sure to look at the Hardcore Computist PDF for a short article about accessing and deciphering the map files.

    I read somewhere that Garriott said he just reused the Akalabeth dungeon code for Ultima. It would be interesting to hear how close they really are.

  12. Sanctimonia says:

    I dumped the three disk images (the two “player” disks appear to be the same, with one used as an active save disk). I removed the file extensions that were automatically added. The file formats appear to be plain text (.BAS and data files) and bitmap images (MS-style .bmp). Here is the archive I created, which includes the disk images you (Odkin) sent me.

    http://www.eightvirtues.com/misc/ULTIMA%20(1981)%20California%20Pacific%20Computer%20By%20Lord%20British.tar.gz

    Also, WtF, you may want to prepare for a bandwidth spike, if it’s possible to do so. I’m still waiting for someone to tell me, “Oh that shit’s been out forever, you didn’t know?”

  13. Sanctimonia says:

    Haha, yeah. I’ve had the “oh shit” feeling from Odkin’s first post up to the present. I think the editing on /. is slow tonight, so who knows when it’s going to hit. I feel like, I imagine, I’d feel if I found my own lost code on some dusty floppy. I’ve lost so much; at least I can live the feeling of getting it back through the work of someone else. I wonder if Garriott has the code, or if he even cares. Maybe it’s just a curiosity to him since he’s come so far. Nostalgia if nothing else always brings me back to what I’ve lost.

  14. Odkin says:

    Woo-hoo!

    I only wish that the Player Disk was the actual copy of my personal Player Disk copy from 1981. I actually played Ultima under the name “Odkin”, a name I cribbed from Wally Wood’s 1970’s graphic story “The King of the World”. That save game disk is around here somewhere….

  15. Odkin says:

    Sorry – one more thing – the first 6 files on the player disks (all 105k) – add the .PIC extension to them. They are graphics screens for the demo mode that runs when you boot the Player Disk. They aren’t used in the game proper as far as I can tell.

    The Apple had a weird way with graphic page switching that made images sort or venteion-blind transition. Made the “SOME FIND FORTUNE…SOME FIND DEATH !!” transition very cool

  16. Sanctimonia says:

    Are you sure the original files had an extension as part of the file name? The conversion utility I used showed the type of file based on its data but didn’t specify file name extensions other than what was included in the “path”, as it described it. I want to keep the filenames the same if possible.

    For example, did the code files actually have a .BAS extension as part of their file names, or did the OS just recognize the file type based on the data contained within it?

    Also, I remember the transition you’re talking about. It was cool. 😉

  17. Odkin says:

    Apple DOS 3.3 had no such thing as extensions, and you could use “.” freely in the file name. In the DOS CATALOG, next to the file name is a letter that tells you what kind of file it is. A=Applesoft BASIC, B=Binary data, T=text file, and I=Integer Basic (predecessor to Applesoft). When you convert them, they lose these labels, so it’s hard to tell what the right tool is for looking at the file. The * just means the file is Locked. The xxx number is the file size in disk sectors.

    For ease of review, I added extensions onto your converted files as follows:

    Applesoft BASIC files got .txt (COPYA, INTRO, PLAYER DISK, SORRY, TIME MACHINE; CAS MOVE, DNG MOVE 1, INIT DISPLAY, INTRO, OUT MOVE, SPA MOVE, TWN MOVE, ULTIMA). The BASIC code is easily reviewed in Notepad.

    105kb files got .pic (to open open in Quicktime) (PIC.ULTIMATUM; CAS.PIC, TWN.PIC, and the first 6 files on the player disk with names starting with “]” or “[” )

    Everything else is just binary data like character sprites, sound effects, and map matrices.

    Interstingly, PIC.ULTIMATUM is the boot graphic screen. It seems like proof of the anecdote that the game was originally name “ULTIMATUM”.

  18. Odkin says:

    Small update. Decided to use .bmp instead of .pic on the graphic files, since they just converted as ordinary bitmaps.

  19. Sanctimonia says:

    Some like them clean, some like them dirty. Would have been cool if Garriott had written extensive comments in his code. I wonder if the code specifies the order in which the files should be run. So many files, like modules. There’s no doubt an order of execution that starts with a new game.

    Running the code is one thing, but understanding the logic is another.

  20. Odkin says:

    It’s not that difficult. Remember that Apple was a non-multitasking, limited memory machine. The Town, Outside, Space, Castle and Dungeon Applesoft files are truly separate BASIC programs that just share variables. With limited memory, you can’t have Dungeon code eating up RAM when your character is Outside.

    When you’re Outside, you’re running the “Out Move” BASIC program. When you’re on a Town tile and hit “E” to Enter, line 500 of “Out Move” says to Run the “Twn Move’ BASIC program. TWN MOVE overwrites OUT MOVE in BASIC memory. Your character and quest variables persist somewhere in memory or on disk, so you’re still you. But you could make hitting “E” run a checkbook balancing program if you wanted to.

  21. Sanctimonia says:

    Apparently no one gives a flying fuck about the source code for Ultima. I’m done with Slashdot. It’s been pretty shitty for a while now and I guess this was the back-breaking straw. No great loss.

    As to why no one around Aiera gives a crap, that is much more a mystery and certainly more disappointing. Pore over that in its every detail, haha. Resorting to “at least I have a copy” mode and withdrawing myself into other efforts…

    • WtF Dragon says:

      Sanctimonia:

      As to why no one around Aiera gives a crap, that is much more a mystery and certainly more disappointing.

      Like as not it’s my fault. Stuff that happens in the comments is often missed by many who frequent the site, for various reasons. To really draw attention to something, I need to put it in an article.

      And since I seem to have somehow ended up with three separate queues full of potential content, all of which I’m trying now to work through, I haven’t yet managed to get Odkin’s discovery posted to its own article.

      In other words, it’s my fault.

  22. Sanctimonia says:

    When /. fails, Aiera prevails!

    I’m busy too or I’d have sent it to Gamasutra already (someone do that). I just got back from Florida so I haven’t had time to work til tonight.

    My final curiosity is if Garriott has this code, or if he’d want it. What if he hadn’t seen it in years, and looking upon it he had a flashback to what it was like when he coded it. Could be life-changing, although he probably already has the code and dislikes it. Who knows.

  23. Odkin says:

    What’s a Gamasutra?

    I was definitely disappointed to see this conversation scroll down the memory hole with only the three of us even aware of it.

    • WtF Dragon says:

      Gamasutra is a gaming industry news and commentary site, pretty high-end as such things go.

      Update: Odkin, I’m placing this into the queue for tomorrow, but before I post it I’m just going to make sure that it’s…er…legally safe to do so. LOAF, from the Wing Commander CIC has a good head for this sort of thing, and is quite in the know as to how EA will view particular actions.

      So, apologies for the delay, but I want to make sure that when I post this, I’m not going to endanger Aiera (or, let’s be honest, myself) in any way.

  24. kingspud says:

    Hello all,
    Ultima-rev isited guy here,
    After taking a look at Odkin files I have become more driven to complete this project.
    I will now be following the original game look and feel exactly, plus maintaining the options and fnctions tht are used in the original ultima game!
    Since there are some bugs in the original code/game, I will be fixing these for my game. One big difference with my version of the game is that I will be using assembly code as well as basic. I won’t be duplicating richards code in as much as trying to recreate the game in my own coded version. I hope you will all take a look or continue to follow if you can.
    Thanks for any questions or comments.
    Joe

  25. Sanctimonia says:

    Good news. If a “pure” version of Ultima could be created (object-oriented, reusable code, etc.) that would be great, as it would be easily extensible. Any language would do as long as it was simply and logically arranged per the original specifications of gameplay and presentation. Garriott’s codebase would be a “codex” of what it was supposed to do and how it went about it. Modern programming “good practices” would govern its recreation. A legal port, basically (sans any copyrighted graphics).

  26. kingspud says:

    Yes, I have seen the error of my ways and put myself back on track with the original goal. I will be posting a video soon of my new progress which covers the intro, character generation, world map movement with the stats present on the bottom of the screen and castle/town movement!!! I will also be posting a pretty detailed tutorial of the Assembly code broken down to each subroutine as I have written it. This tutorial will cover the world map tile generator and movement routines! This to me was the most intense learning process and also the most fulfilling to complete. With the code I have written so far, you could if you wanted to, create your own tile shapes and build a world map and move around in it that would measure 170+ X 80+ tiles. As I have always said from the beginning, this will all be open source and downloadable to the public. Everything I create in Assembly or Basic will be posted, explained “with tutorial is possible”, and downloadable! I hope everyone will stay tuned for my progress and in the end I hope to have a working program that plays exactly like the original look and feel of the game!
    Happy trails!
    Joe “kingspud”

  27. Sanctimonia says:

    The seeing of the error of your own ways must have been humbling. Good luck.

  28. kingspud says:

    It is very humbling but absolutely necessary! IMHO it is critical as a programmer and as a person, that when we are working on a project that is either for profit or for love, which in my case is the later, we must be able to listen to comments and criticism to make changes accordingly.

    This to me is the only way we can learn to grow.

    With this project I have two main goals.
    1. See if I can accomplish the recreation of Ultima 1 for the apple because no one else did it in assembly + basic and made it freely available.
    2. Give all the code and information I develop to anyone and everyone who wants it so they can understand how it was done!

    This project will work not only on the apple emulator but I plan on putting it on disk and having it work on the original Apple IIe!

    Plus, I will be learning something in the process, which is also what helps us all grow.

    Kingspud

  29. Sanctimonia says:

    Sounds good. I thought you were being facetious with me in the earlier post. This project reminds me of homebrew Atari or NES games. There’s a lot that can be done on older systems when you have knowledge of all that’s happened in the industry up to now.

  30. kingspud says:

    Well, it’s been a while but I finally started posting the tutorial on my Ultima 1 Revisited blog. This tutorial will take the World Map program and detail each subroutine LINE-BY-LINE, explaining how each line works, how it affects the program, and what the program is doing because of the partiular code line.

    I will be updating the tutorial as soon as I have each subroutine marked up and made available.

    Enjoy.

    Joe