Macrosoft at KansasFest 2010

I presented a tutorial introduction at KansasFest 2010 on the Mindcraft Macrosoft programming language, a macro assembler package that allows the programmer to achieve machine language speed with a high-level Applesoft BASIC-like syntax.  Macrosoft and its companion Assembler run on you favorite 8-bit Apple II.  The presentation was well received, and several people left motivated to try Macrosoft for themselves. Don’t miss the history of Macrosoft from the author, Alan Floeter, that’s part of the presentation slides (page 11).

Ken Gagne has kindly shared a recording of my presentation and posted the slides.  Watch the presentation, buy a copy of the Mindcraft Assembler & Macrosoft, and write the next blockbuster Apple II software.

USE MACROSOFT.3.1
UEN
MUL
BEGIN
PRINT "Macrosoft Rocks."
CLEANUP
END

There’s a working Macrosoft example in the presentation slides.  Also, check out my “hello world” program in Macrosoft and with the Assembler.  Finally, don’t forget my winning KansasFest 2009 HackFest entry written with Macrosoft.

KansasFest 2010 HackFest

My KansasFest 2010 HackFest entry with source code is now available for your enjoyment.  This entry took second place behind Martin’s Wizardy crack.  I used Complete Pascal 2.0 with Pegasoft Draw Tools 3.1, both of which are freely available, to create my first 16-bit Apple II program.  The program displays pictures from KansasFest and asks related trivia questions.

The photographs are used with permission from Henry Courbis of Reactive Micro.  I converted the original JPEG images to GIF files on a modern Macbook then used Super Convert on a IIgs to produce packed SHR image files.

I hope some budding programmer will find the software to be a useful starting place for the next brilliant Apple II software!

Hackfest Day 2

There are just so many fabulous things to see and do at KansasFest that Hackfest has not gotten much attention!  Where else do you get to see the worst Apple product and a disk operating system almost twice as fast as ProDOS?

I want to include full-screen bitmapped images in my entry, and I’m figuring out how to load and display images.  The toolbox does not offer a convenient “load image from file” call so I must provide code to load, parse, and decompress the image file.  I found a CSA2 post with sample code and the Pegasoft Draw Tools package.  Draw Tools provides numerous handy drawing tools, including fades, wipes, animation, and image loading.  So, I’ve installed Draw Tools and have the sample code working.  The TML Pascal samples work well with Complete Pascal since Complete Pascal is really version 2 of TML Pascal.  Work continues …

Hackfest Day 1

The annual KansasFest HackFest is on!  I’ve heard rumors of Wizardy cracking and a Rockhurst text adventure.  I’m learning Complete Pascal, learning IIGS toolbox programming, and, just in case I run out of things to do, using those skills to write a graphical Apple II/KFest trivia adventure.  I have Complete Pascal running and am ready to crank out a bit of code.  Stay tuned for more …

Saying “Hello” with Macrosoft

Following the model of Eric Shepherd’s “Some Assembly Required: Hello World” article on A2Central and my last post on the Mindcraft Assembler, I’d like to present the traditional “Hello World” program for 8-bit Apple II using Macrosoft.

Macrosoft allows the programmer to achieve machine language speed with a familiar BASIC-like syntax.  Technically, Macrosoft is a macro library for the Mindcraft Assembler.

First, follow the directions included with Macrosoft to create a working disk with The Assembler and Macrosoft.  Next, just like last week’s tutorial, slide the disk into your drive and run the BOOT.SYSTEM program.  Press “E” to enter the editor.  Press “enter” once to get a “!” insert mode prompt.  Type in the following program.  Case does matter, so watch the capitalization.  Also, make sure to begin each line with a space; otherwise, the assembler will interpret your entry as a label.  Notice that, except for a few extra “boilerplate” lines, the program appears similar to BASIC.

USE MACROSOFT.3.1
UEN
MUL
BEGIN $2000
PRINT "Hello world."
CLEANUP
END

Press the “Escape” key and enter “Hello” for the “Save Pathname.”  Press “A” to assemble to program.  If you get errors, return to the editor and correct them.

Finally, press “!” to exit back to BASIC.  Change to the directory containing the HELLO program and type “BRUN HELLO”.

Saying “Hello” with the Mindcraft Assembler

Following the model of Eric Shepherd’s “Some Assembly Required: Hello World” article on A2Central, I’d like to present the traditional “Hello World” program for 8-bit Apple II using the Mindcraft Assembler.

Slide the Assembler disk into your drive or run the BOOT.SYSTEM program.  Press “E” to enter the editor.  Press “enter” once to get a “!” insert mode prompt.  Type in the following program.  Case does matter, so watch the capitalization.

            ORG       $2000
COUT        EQU       $FDED         ;Apple II character out func.

            LDX       #0            ;Offset to first character
loop        LDA       msg,X         ;Get the next character
            BEQ       done          ;->Yes!
            JSR       COUT          ;Print it out
            INX                     ;Move on to the next character
            JMP       loop          ;And continue printing
done        RTS                     ;All finished!

msg         ASC       "Hello world."
            DSC       $8D
            DSC       $00

Press the “Escape” key and enter “Hello” for the “Save Pathname.”  Press “A” to assemble to program.  If you get errors, return to the editor and correct them.

Finally, press “!” to exit back to BASIC.  Change to the directory containing the HELLO program and type “BRUN HELLO”.

Apple IIgs development with MPW – Setup

The Apple IIgs is a great platform for software development.  Compared to 8-bit Apple II machines, the IIgs offers a faster processor, more memory, higher resolution video, and a more modern desktop graphical user interface (GUI).  The operating system, GS/OS, offers features found in modern desktop operating systems, such as a relocating system loader, dynamic memory management, networking, modular file systems, and event-driven user interfaces.

The platform has a number of excellent software development packages.  Whether you favor C, Pascal, Logo, Modula-2, Forth, BASIC, or assembly, you’re covered.

But, compared to software development on newer computers, the IIgs screen resolution and processor speed are unavoidable limitations.  A large screen allows you to see more of your code.  A fast processor cuts compile time and debugging.  Apple felt the pain of developing large programs on the IIgs and created add-ons for the Macintosh Programmer’s Workshop (MPW) that allow IIgs software development from the relatively advanced Macintosh platform.  Apple used these MPW-based development tools for some of its most complicated IIgs software projects, including GS/OS itself and Hypercard.

Let’s get MPW setup and running.

Get a Mac that runs classic MacOS or a Mac emulator

I choose the Basilisk II emulator.  Follow the directions at E-Maculation to install and setup Basilisk II with Mac OS System 7.5.5.

MPW and the IIgs add-ons run under classic MacOS, so you’ll need a suitable machine with either a PowerPC or 680×0 processor.  Your fancy new Intel-based Mac won’t work.  OSX won’t work either.  I’m not very knowledgeable about classic Macs, so I’m not sure of the “best” machine, processor, and OS version.

Given that these IIgs tools were written for a 680×0 based Mac, I figure such a Mac is the best place to start.  I don’t have the desk room or the inclination to start a classic Mac hobby, so I turn to emulation.  The E-Maculation site does a great job of identifying the options for Mac emulation.  Mini vMac and Basilisk II look to be my best options.  I choose Basilisk II because, compared to Mini vMac, Basilisk II offers higher resolution color display and networking, which I believe will be valuable for software development.

Install MPW and DiskCopy

Download MPW and Disk Copy from Apple.  Use the HFVExplorer tool included with Basilisk II to transfer to software to your emulated Mac.  You will also want StuffIt Expander, which is useful for de-compressing certain software.

Disk Copy is a self-extracting archive, so double-click the downloaded file on your emulated Mac to open the file.  Then, copy the program to a convenient location on your emulated hard drive.  Then, use Disk Copy to open the MPW image.  Copy the entire MPW folder to your emulated hard drive.  I find the Software Downloads article from Apple helpful in understanding the various Mac file formats.

Install the MPW IIgs software

Purchase the MPW IIgs Tools and MPW IIgs Assembler from Syndicomm.  Optionally, also purchase MPW IIgs Pascal, MPW IIgs C, or MPW IIgs Orca/C from Syndicomm.  Jump through a few overly complex hoops to get the software transferred to the emulated Mac.  Follow the directions in the MPW IIgs manuals (included with your purchase from Syndicomm) to install the software.

While Apple freely distributes the old MPW tools, the MPW IIgs add-ons are not free.  Syndicomm is the only authorized retailer and sells the pieces both individually and part of a package.  The APDA Software Library seems to be a good deal if you’re interested in some of the other included software.  If you only care about MPW, the MPW IIgs Collection is the best deal.

For reasons I don’t understand, the Disk Copy disk images from Syndicomm are difficult to use with Basilisk II.  The emulator does not support mounting these disk images as emulated disks.  I tried, and Mac OS offered to format the unrecognized volumes.  Next, I tried transferring the images into another disk image with HFVExplorer.  Disk Copy 6, unfortunately, fails to mount the images complaining that the images are corrupt.  Third, I tried creating a new image on my OSX laptop and copying the contents of the MPW images to the new image, but OSX 10.6 does not support writing to HFS disk images so this approach didn’t get very far.  OSX 10.6 does mount the MPW add-on images read-only, so I know the images are usable.  Finally, I used Sweet16 to create a Disk Copy 6 image, mounted the image in Sweet16, booted GS/OS, formatted the image with HFS, mounted the MPW images in Sweet16, and copied the MPW IIgs software to the new disk image.  Then, I transferred the new disk image containing all of the MPW IIgs collection to the emulated Mac filesystem with HFVExplorer.  Disk Copy 6 on the emulated Mac finally opened the image.

Sweet16 Create Image dialog

The manuals for the MPW IIgs software describe the installation steps.  I did have a minor problem with the install script for the MPW IIgs Tools.  The script contains a reference to a directory named “SR.71″, and I had to edit the script to remove that reference.

Use MPW to develop IIgs software

There are plenty of documentation and samples.  I’m still learning.

MPW with the IIgs add-ons running in Basilisk II

MPW and the MPW IIgs software include excellent documentation.  There are a few example programs included with MPW IIgs, but they’re generally outdated and probably not very good models.  The IIgs Source Code Sampler package, available from Syndicomm and elsewhere on the Internet, is more up to date and provides several good assembly language examples.

What’s Next

I’m left with a few questions that I’m still exploring:

  1. Is Basilisk II stable enough?  I’ve had a few emulator crashes, but, so far, Basilisk II seems sufficiently stable.
  2. How will I transfer compiled/assembled software to the IIgs?  There are several options, including networking, but I haven’t experimented to find the best option yet.
  3. I’m using an emulated classic Mac to develop software for the Apple IIgs.  Does this make any sense?  Will I be happier developing directly on the IIgs?  A2Central just started a series on selecting a IIgs assembler.

Overall, I’m pleased with using MPW to develop software for the IIgs.  I still have a lot to learn, and I’m not yet certain I’ll stick with using MPW.  My next post will be a tutorial “writing your first IIgs program with MPW.”

BlueBot Brings Home the Rookie Award

BlueBot brought home the Rookie Award!  Check out the classy styrene rain jacket, too.  A local authority (Peter’s Wife) observes that “Peter’s robot is awesome.”

BlueBot did well in the AVC but did not finish.  The ‘bot successfully extricated itself from encounters with rocks, sticks, dirt clods, pine needles, and curbs.  The wheels, however, ended up being too small and too slick to keep going.  The software and basic approach are sound.  Next year, BlueBot will return with better wheels, bigger motors, and a few more sensors to help detect obstacles from greater distance.

Here’s a nifty flyer about BlueBot:  BlueBot Flyer

Thank you to everybody, both SparkFun employees and other participants, who made the AVC possible.

Compass Integration

After far too much pain and effort, the magnetic compass is integrated with the robot.  Calibration is a bit finicky, and I don’t think the SYNC signal is implemented properly.  But, the compass works, and the heading matches my mechanical compass.  Here are a few lessons learned:

  1. RTFM.  Set the pin data direction (DDRQS) because inputs don’t work well as outputs and outputs don’t work well as inputs.  The QSPI hardware will halt with “mode faults” if the pin directions are wrong.  Set the PORTQS register to the inactive pin state.  The slave select pins are active low, and don’t forget that when setting the PCS bits in the COMMAND bytes.
  2. RTFM.  The Vector V2Xe compass has a response timeout, and trying to write out a bunch of debug information in the middle of reading the response is ill-advised.  Also, the compass does not respond immediately, so look for the 0xAA synchronization byte.  The compass manual is, unfortunately, vague in a few areas.  The manual mentions the response delay for GetData commands but not for other commands.  Also, the manual does not give full timing specifications (e.g. setup and hold times) for the SPI bus or the SYNC signal.  The manual doesn’t say if the slave select may temporarily go inactive in the middle of a command or response.

I’m busy tweaking navigation and obstacle avoidance behaviors.  The Sharp IR range finders give false positive readings when moving into the sun, so the ‘bot can develop heliophobia.  I just finished implementing a simple low-pass filter for the IR ranges, and I’ll see if performance improves.  I’m considering the addition of tactile bumper — the IR filtering and the elevated sonar (to avoid ground reflections) make the robot blind to short obstacles.

I’m ready for the AVC.  Are you?

So much to do, so little time

Here’s a new video showing off obstacle avoidance. The robot manages to avoid walls, chairs, tables, couches, and a dog (although the dog usually runs away, probably because it knows the robot’s secret world domination plans).

Much work remains, and not enough time remains.

  • I’ve replaced the motors to increase torque.  The old, faster, lower torque motors tended to stall.  The new motors work well although they produce more electrical noise.  Next time I have the robot apart, I’ll add the vendor’s recommend filter caps to the motors.  As an interim solution, I limit the acceleration, which keeps to noise to a manageable level.
  • The wheels tend to fall off.  That would be embarrassing during competition.  I cannot get the set screws on the wheel hubs to stay put.  I’ll drill out the hubs a bit so the wheel sit further on the motor shaft.  If that doesn’t help, I’ll try a thread locking compound.
  • The micro-controller appears to radiate interference that affects the GPS receiver.  I experimented with tin-foil shielding and didn’t observe improved reception.  I added a 3.3V regulator dedicated to the GPS, and performance is now acceptable.
  • The software has grown substantially.  The robot sports an interactive serial monitor.  The monitor allows configuring various parameters and saving those parameters in battery-backed RAM, which allows me to tune behaviors without the time consuming compile/load cycle.  Also, the monitor permits checking sensor values, watching raw NMEA data from the GPS, and restarting the GPS.
  • Waypoint seeking and route following code is done and working.  Unfortunately, the GPS doesn’t provide reliable heading data at the robot’s typical speeds.  I’m not really surprised and planned from the beginning to include a magnetic compass, but I never got around to integrating the compass.
  • The tail wheel is too small and tends to catch on obstacles.  I have several new candidate wheels in the mail.

Next up:

  • Integrate the compass and update the navigation code to use the compass.
  • Replace the tail wheel with something less likely to get stuck.
  • Improve main wheel mounting.
  • Use the buttons on the top of the robot for something.
  • Implement a data logger to permit better analysis of robot performance.