Apple ][ Graphic Adventure Part III

Posted on

The previous post in this series explained how to get Graphics Magician images to display from Applesoft. Now, I’d like to go over the structure of the program listed in Write your Own Adventure Programs. The bulk of the program listing consists of the game data including objects, room descriptions, verbs and state flags. Most of the remaining code is comprised of a series of conditions that check how the player’s actions affect the objects in the game world.

Verbs

Haunted House used a simple, two-word input parser: VERB NOUN. But I wanted this new game to simplify the number of verb choices in the same way the LucasArts adventures streamlined the interface of Sierra-style adventure games. The player will be limited to around a dozen verbs that are entered with a single keystroke.

Apple II Adventure Parser Help List

The verb list is largely based on the options in Monkey Island. PUSH and PULL have been combined into MOVE. To move you must hit Go then enter either North, South, East, West, Up or Down. This is a little annoying, but there are only so many letters in on the keyboard and I needed that D, U and S elsewhere. Other commands require you to hit the keystroke, then type out an object NOUN and then hit Return. “Guess the verb” will no longer be an issue… welcome to 21st century “guess the noun” technology!

Each verb then get’s its own subroutine which contains the logic that triggers the various game actions (or provides a default message if nothing special happens). By assigning a number value VB to each verb, I can use the following to branch to the various subroutines: ON VB GOSUB 1000,600,800,850, ...

Game Data

The game data is set in the program by assigning strings and numbers to several arrays. In Applesoft you need to declare the size of an array by dimensioning it with the DIM command. For the rooms I will set the size of the rooms array to the number of rooms RM by declaring DIM RM$(RM). Then, near the start of my program I read data into the array by using GOSUB to a loop like this:

5000 DATA "Room description 1","Room Description 2", [...]
5005 FOR I = 1 to RM : READ RM$(I) : NEXT
5010 RETURN

The DATA can be listed anywhere in the code and it’s important to make sure that there are exactly as many data strings as READ commands. Otherwise, you might get OUT OF DATA errors.

This method of declaring rooms and object will eventually make your Applesoft program very long and hard to edit. I was pretty sure that I could figure out a way to read the data in from an external text file. But more on that later.

Continued in Part IV

Apple ][ Graphic Adventure Part II

Posted on

In my previous post I wrote about the impetus behind this project. To start, I knew that my code was going to be structured around the Haunted House program in the excellent book Write your Own Adventure Programs for your Microcomputer. As I have written before, this book was crucial in my development as a programmer (I haven’t developed much beyond it). I would love to do this project in 6502 machine code and I have been trying very hard to learn 6502 assembly programming. But, although I’ve gotten a better understanding of machine code, there’s serious lack of noob-friendly practical learning exercises available out there. Sure I can draw pixels at lightning speed, but, after reading most of Assembly Lines, I still have no idea how to do a simple INPUT command or mimic an array.

So, Applesoft BASIC it is! With emulation and modern computing I have been able to develop my code on a Windows PC and then quickly run it in emulation. My workflow isn’t nearly as fancy as some other retro-programmers. I type my Applesoft in a text editor, then in AppleWin I paste the entire code listing into an emulated apple using SHIFT+INSERT. The benefit of using emulation as a development environment is that you can throttle the emulation to run hundreds of times faster (hit ScrLK) than real hardware. This makes testing small changes a breeze.

My first task was to see if I could successfully load a Graphics Magician image into a program. The program itself is a bit of a UI nightmare. Without a manual or reference card, it’s nearly impossible to know what keys do what. On top of that, the program requires that you use a joystick to move the drawing cursor on the screen. Fortunately, the manual can be found online and you can use a PC mouse as a joystick within AppleWin. I managed to crank out a couple of silly images for testing and save them to my game disk.

I then used to code provided in the manual to write a simple Applesoft program that displays the image:

1 PRINT CHR$ (4);"MAXFILES1"5 HIMEM: 32768
10 PRINT CHR$ (4);"BLOAD PICDRAWH"
20 PRINT CHR$ (4);"BLOAD ROOM1.SPC,A32768"
30 HGR
40 A = 32768:HI = INT (A / 256):LO = A - HI * 256: POKE 0,LO: POKE 1,HI50 CALL 36096

In order for this code to work, you are required to copy PICDRAWH from the Graphics Magician disk to your disk. This is the machine code rendering engine that is loaded into memory at the top of this program. The MAXFILES1 DOS command apparently frees up some memory by limiting the amount of open files. This command needs to be the first one in your code, before any string assignments, etc. I think HIMEM does something similar with allocating memory locations. I have never written an Applesoft program so large that it required memory management so the purpose of these commands alludes me somewhat. As this project grows, I may have to familiarize myself with them.

You will see CHR$(4) often in Applesoft programs. CHR$() is a function that retrieves the keyboard character in assigned to the numerical value in then parenthesis. For example, PRINT CHR$(65) prints the letter A. In this case, character number four is the equivalent of keying in CTRL+D. That instructs the computer that the next PRINTed string should be executed as a DOS command rather than PRINTed to the screen.

The Graphics Magician file is ROOM1.SPC. BLOAD ROOM1.SPC,A32768 loads the drawing code into memory location 32768. That seems like a crazy random number but it is actually $8000 in hexidecimal. HGR switches to high-resolution graphics mode and then line 40 stores the memory address of the picture into a location PICDRAWH will know to look. Finally, the CALL 36096 triggers the PICDRAWH draw routines.

There’s a lot of fancy stuff going on here, but it does the job as advertised. The Graphics Magician manual also goes deeper with more code that shows how to string multiple images into slide shows and how to overlay objects over backgrounds. More on that when I get to my object code. For now, this proof-of-concept was enough to get a simple working prototype up and running.

Continued in Part III

Apple ][ Graphic Adventure Part I

Posted on

Having recently played the Apple ][ game Transylvania and its sequel, I was inspired to mess with the art program which those games used. The Graphics Magician was a huge hit for Penguin Software, but I never actually had a chance to use it when we had an Apple ][. I just remember it being advertised in every computer magazine I had.

My go to art program back in the day was always Alpha Plot from Beagle Bros. It wasn’t the easiest software to use. In fact, it came bundled with a cardboard overlay for your keyboard so you had an immediate reference as to what the various keys did. Still, I managed to draw pixel by pixel and create masterpieces like this:

The Graphics Magician is something altogether different though. Instead of meticulously drawing each point on the screen, you create images programatically using a language of lines, fills and brushes. The end product is what today we would call vector art.

The advantage of vector art is that file sizes are small. The other advantage is that these drawing routines can be used within one’s own Apple ][ programs.

This gave me an idea for a project. Take the text-based adventure game I had made years ago, and use these routines to add graphics to the game. As I type this, I am already pretty far along in the project, but I will be going back and documenting my progress. Hopefully someone might find this informative and, if I am able to follow through, maybe I will have a releasable game in the end. It’s doing more than I ever imagined already:

Continue to Part II

Some Yamaha DX100 / DX27 Synth Patches

Posted on

I’ve owned a Yamaha DX100 synthesizer for decades and never really had a strong grasp as to how the heck you build sounds with it. The last few months I have been immersing myself in FM synthesis and I think I finally have a handle on the concept now. Here is set of twenty-four patches that I created:

They all sound better and less brittle with a little reverb and chorus, but you get the idea. I especially like “Astro Pong” and “LoocySynth”. If you like what you hear, you can download a .WAV file of the cassette dump and load these patches on to your DX100/27 via the cassette port hooked to your PC. Just make sure your PC’s volume is turned way up or the DX won’t hear the data stream.

UPDATE: I have finally saved these patches as sysex files (see below). Here is information on loading sysex on to a DX100 (also contains separate sysex files for each of the individual patches).

Site Update 2017

Posted on

Today I did a revamp of the site’s theme. Mostly this was because Prepros no longer supports Compass in its Sass implementation. I had to go through all my sass code and remove any Compass references and write my own mixins based on them.

In the process I managed to reorganize much of my code and make some style tweaks across the site. I am going to go with slightly bigger fonts and am now using a grid system based on the Bootstrap grid instead of the confusing Zen grid. The biggest change to the site is that now the most recent post appears in full at the top of the homepage with a little “New” label in the corner. Future is now!

You Can Now Buy My Art on Etsy

Posted on

I’ve been using this Web site as a place to show and sell my art for nearly twenty years. In that time I have sold exactly zero prints. I know I haven’t exactly been P.T. Barnum when it comes to self-promotion, but seriously, zero? I have even offered prints for free with no takers.

Well, today is the day that all changes. I am now selling my prints on Etsy.com! This means they’ll handle the billing and shipping calculations and you can sit back, relax and send me all your money!

You can still browse my work on this site and if the art happens to be for sale there will be a big old link in the sidebar for you to click. Impulse buying is allowed.

The Music Studio Instrument Samples

Posted on

I recently took the time to sample all of the default sounds from the Apple IIgs music composition program The Music Studio for use with my new sampler. The sounds were recorded directly out of my IIgs via an Applied Engineering sound card and into the Octatrack. I then took the WAV files into my PC and cleaned up the audio a bit. The IIgs outputs a rather noisy signal.

The samples are organized into four sets: Jazz, Rock, Classical and Voices. Each set has about fifteen instruments and each instrument was sampled at six octaves of C. Jazz also contains a couple drum kits which I broke apart and sliced into eight notes each. I tried to create nice evenly sliced sample chains but they are a tad off so they require a little manual tweaking after auto-slicing them.

The Music Studio was one of the first music composition programs I ever used. Certainly, it was the best one I had used up until that time. Technically, the first would have been Will Harvey’s Music Construction Set on the Apple ][+ with a Mockingboard sound card, but I don’t think any of my compositions from that program have survived (I’ll have to dig around my old disks one of these days). Fortunately(?), my IIgs compositions have survived and have been imaged and archived. Now such classics as “Kill Your Mama” and “Robert is Coll” have been preserved for the ages. Most of what we did in The Music Studio was transcribe my brother’s heavy metal guitar tab sheet music. So there’s a lot of G’n’R and Metallica riffs.

What made the program so cool (or “coll” if your are my typo prone teen aged self) was the inclusion of drum sounds. In hindsight, really bad drum sounds but drums nonetheless. It was my first real go at creating electronic music. I had no idea how performers like Cabaret Voltaire or even Devo were able to program their keyboards to play music automatically. There was that Jan Hammer Miami Vice video where you actually got a glimpse of a computerized rig (probably a Fairlight or something else that cost more than a car) and this seemed about as close to that as I could ever get.

Unfortunately, The Music Studio had a lot of quirks that made it really difficult to use. Although it uses a standard music staff for notation, it really plays notes like a piano roll. Meaning, if you have a whole note you want to ring out under several quarter notes you have to insert a bunch of redundant looking rests above the whole note. Otherwise, it plays the entirety of that long note before playing the quarter notes that are after it. Confusing, yes. Practically speaking, what this means for the composer is they have to put a bunch of evenly spaced rests across the top of the song scroll to insure the play head keeps moving along. The other major limitation is that you can’t have two instruments play the same note at the same time. That made any sort of complex arrangement a matter of spacing instruments across the staff all while avoiding your kludge of rests.

Until I was exposed to MOD files and tracking software on my PC this is how I thought music was made on a computer. Even Q-Bob’s music was created using a similar looking MIDI composition program. FastTracker and MadTracker freed me of this notion and from there on I began to make music more in line with what I wanted to do as a teen.

The Music Studio did have a very recognizable sound though. If you ever played Dream Zone you know exactly what I mean. These samples now allow us to get some of that distinctive sound into modern music apps and hardware. So, use the link at the bottom to download the set for yourself. In the meantime, here’s the first composition I made using the samples:

The Podcast Report

Posted on

Today is supposedly International Podcast Day. Well, let’s celebrate this phony-baloney holiday by taking a look at some of the podcasts that I’ve been listening to lately. I feel like this list will change as time goes by so I wanted to document it here for future reference. These are in no particular order so here goes.

The Fifth Column – This is probably the most recent show that I have started listening to. In it Kmele Foster, Michael Moynihan and Matt Welch review the week’s news from a mostly libertarian perspective. I’ve tried a few libertarian podcasts in the past and most, like the Tom Woods Show, were just simply lame. The Fifth Column manages to be extremely informative, entertaining, and, dare I say, hip.

Gilbert Gottfried’s Amazing Colossal Podcast – The strength of each episode depends on the guest and their willingness to talk dirt on old-time Hollywood actors or to play along with Gilbert’s over-the-top niche impressions. The show can sometimes descend into the hosts just saying “I remember that movie” and not much else but overall it’s entertaining week after week.

The Red Eye Podcast – There have been three incarnations of this podcast. All three have been loosely based around the cast of Fox News’ Red Eye chatting about the goings-on around the show. The first version was Greg Gutfeld, Bill Shulz and Andy Levy and it was usually specific to that night’s show and the topics they were going to cover. Then after a hiatus, it reemerged with Bill Shulz, Tommy O’Connor and Lauren Sivan. I loved that version (I think at this point they called the show, Not Live). Not Live was much more focused on pop culture and celebrity happenings and it was awesome. That show vanished, then all of the sudden, it returned this year with Andy Levy, Tom Shillue, Ben Kissel and Tim Dimond (the current Red Eye writing team). They avoid politics  and it’s much more like a short, funny, free form conversation about random topics. This might be my favorite podcast these days.

No Agenda – I started listening to this after I heard John C. Dvorak was banned from TWIT (a podcast I gave up on years ago when it became evident that it would only be about phones and apps). The show consists of Dvorak and Adam Curry (of Headbangers’ Ball fame… oh, and he invented podcasting) “deconstructing” the news. They play clips from various news outlets and then talk about how the stories are either slanted, planted or just plain stupid. There can be some great insight here, but I feel the two are just a little too cynical for my tastes. In the words of Sigmund Freud, “Sometimes a cigar is just a cigar.” In their universe, every story is a front for some external power when, in reality, the sloppy reportage is more a result of the fact that everyone is horrible at their job (and lazy). I tune out when they start drifting into Alex Jones territory, but still, they have a 70-80% success rate… if that’s even a thing.

The Bryan Callen Show – Hosted by comedian Bryan Callen along with Hunter Maats, this is almost more of a self-help podcast. There is lots of talk of the neuroscience, behavior, personal improvement and a dash of politics. Maats does most of the brainy commentary (and punctuates every proclamation with an annoying, “Right?”) while Callen provides humor and an everyman’s perspective.

EconTalk – Russ Robert’s long-running economics podcast is a treasure trove of insight and knowledge. Every once and a while the conversation is over my head but I have learned quite a bit about markets, statistics, and intellectual bias from the always skeptical Roberts and his guests.

The Open Apple Podcast – A monthly podcast about the Apple ][ computer that’s both heavy on nostalgia and current projects that push the limits of that ancient computing platform.

Lastly, here are a couple podcasts that I will still occasionally listen to but are gradually fading out of rotation for whatever reasons: Penn’s Sunday School, still don’t mind it but I guess some of the recent weight-loss talk has not been entertaining for me. Race Wars, Kurt and Sherrod are great, but it can be a bit much when there are half a dozen people in the room all talking at once. Getting On With James Urbaniak, entertaining short stories read by the voice of Dr. Venture… the episodes have stopped so this one may be over.

Political Word Trends

Posted on

The current presidential election cycle has made Facebook insufferable these days. As the various screeds flow across my feed from people who would normally be reasonable friends, I am noticing what I am calling, “political word trends.” Out-of-the-blue people start using the exact same words to describe something with which they have a political beef. I know this is essentially the same thing as talking points (like when every Democratic operative on the planet described Hillary “powering through” her illness), but what I am seeing is just a little more subtle.

I first noticed this when, over the course of a few unrelated discussion threads, libertarianism came up and, in addition to the usual “they hate firemen” arguments, someone would refer to libertarians as “children.” Maybe there was a huge write up in The Nation that used this term? I don’t know. It just seemed odd that it suddenly appeared 3 or 4 times without any prompting. Next, I began to hear the term “ghouls” used over and over to describe pro-gun advocates. Again, maybe John Oliver had a witty diatribe about these “ghouls” but this seemed weirdly coincidental to me. Or maybe I’m just jealous that I am not being invited to all the hip parties. Instead I sulk at home with like a ghoulish child. I will keep my eyes open for more. Stay tuned.

My Fleetwood Mac Cover

Posted on

For the past half-year or so I have been participating in the PRF Monthly Tribute series where various artists and friends cover a different band each month. This month I did a cover of Fleetwood Mac’s “Big Love.” I thought there were not enough references to Zardoz in the Fleetwood Mac oeuvre, so I fixed that.