Wednesday, January 7, 2015

Taking Shape

I'm still plodding along with the Apple II, and getting more comfortable with programming the 6502.  So far, I am having some good fun!  I'm still not committed to any specific programming goal, but an idea is starting to take shape...

Fill In The Blank 

Old-fashioned video monitors (including televisions) literally drew images one line at a time, sweeping across and down the screen in the process.  Image data in a computer generally is stored in RAM, and the contents of that memory is scanned by the video hardware as the video signal is generated and sent to the monitor.  Computer programs that do not account for the timing of those scans while updating image data in memory tend to generate transient video "glitches" when a screen in shown on the monitor while that screen is being updated.  A common technique for avoiding such glitches is to ensure that image data is updated during the vertical blanking interval.  This is a period in the video signal which is literally reserved for the time it takes to move the electron beams in a CRT from one corner of the screen to the other.  During this period, nothing is drawn on the screen.  This is an ideal time for updating image data in memory.

The original Apple II and Apple II+ hardware did not provide any mechanism intended for software to synchronize with the vertical blanking interval, but the later Apple II models were more accommodating.  Unfortunately, dealing with vertical blank synchronization seems to have been a creative outlet for the engineers at Apple back in the day -- the IIe, IIgs, and IIc all do it differently!  I even found a Google Groups discussion about the topic.  For now I am just going to use the method for the machine I am actually using in my coding experiments, the IIe.  Something more robust can come later, if necessary.

Oversize Load

The early coding examples in Assembly Lines: The Complete Book place code into memory starting at address 768, an open area of memory not used either by Applesoft BASIC or by the system monitor.  However, that unused chunk of memory is not unlimited.  As I added code in my own experiments, the size of that code crept slowly up.  At one point, the program would immediately crash when it was run from the monitor -- not cool.  Of course, the tail end of my code was overwriting something important to the proper functioning of the monitor program.  So the lesson is "know where your code lives"... :-)

Serial Killer

As I mentioned in an earlier post, my development environment includes a serial (i.e. RS-232 over Bluetooth) link between the Apple II and my workstation across the room.  This provides me with a number of conveniences, but it has the drawback that I can't touch the Apple II when I'm running code on it.  The only way to interact with a program (including telling it to stop) is over the serial port, which means my code experiments need to know how to talk to the serial port.  So, I figured-out how the 6551 on the Super Serial Card is addressed and I wrote some code to let me poll the serial port for input -- remote access problem solved.


Well, that wraps up this progress report.  I am having fun, and I am expanding my retro computing horizons.  There is still more to come, so I really hope you will stay tuned!

5 comments:

  1. One of the other Retrochallenge competitors, "mmphosis", has a document posted that desribes how to syncronize to the vertical blanking interval on all Apple II machines (i.e. even the old ones with no hardware support for doing so). It is a cool idea, but I'm just not up for that much cycle counting on this project right now... :-)

    http://hoop-la.ca/apple2/2015/vbl/

    ReplyDelete
  2. Is the code your writing compatible with a Apple II+ or is the video much different from the IIe your coding on?

    ReplyDelete
    Replies
    1. The II+ doesn't have the hardware support for detecting the vertical blanking interval (VBI). It shouldn't be too hard to detect a II+, so you could just ignore the VBI and do video updates as they are ready. But if the VBI is used as a 60Hz timer, then the game would run too fast without it.

      So, most likely any game produced would be limited to the IIe, IIgs, or IIc.

      Delete
  3. Bob Bishop's Oct 1982 article in Softalk ("Have an Apple Split") is probably the canonical reference for the VBL by cycle counting trick on the early IIs. Scanned here: https://dl.dropboxusercontent.com/u/391444/Vintage/Magazines/Softalk/articles/softalk-1982-oct-have-an-apple-split.pdf

    ReplyDelete
    Replies
    1. Yes, that is probably the canonical reference.

      Delete