Monday, August 24, 2015

Chief Execututor

  This is another program that does little more than allow you to move a cursor around a screen. At least the screen has some Print Shop images of the presidents -- and there are two screens of them.

  I was learning how to use tools better; tools that were written by Jeff or Scott or another assembly programmer who would send them in to us. I also was learning the architecture of the C-64 and the Read It below shows how the program is laid out in memory. There are 256 pages in a C-6 and each page has 256 bytes, give or take a few. Organizing all the tools and data can be challenging. Don't be surprised if I lay out "memory maps" in future Read Its. One of the main goals of LOADSTAR was to show readers how to program in BASIC.



Graphics by Paul Arsenault
  We all know what George Washington and Abraham Lincoln looked like — we carry pictures of them around in our wallets or purses. Some of us even know what Ulysses S. Grant looked like. And try as we may, we’ll never forget Nixon, Carter, Ford, Reagan and Bush, since they show up on the tube from time to time. But what about the dashing Millard Fillmore, or that handsome devil, Warren G. Harding? Well, thanks to Paul Arsenault and a host of LOADSTAR routines, we can learn to recognize all of the forty Presidents of the United States. It may come in handy should you ever find a picture of Grover Cleveland in your pocket.
The program is straightforward. There are two hi-res screens with portraits of the presidents on them, in the order in which they served. Imagine them as side by side, ten across and four down. If you move “off” the screen, you’ll go to the other picture. Move the cursor from face to face and press RETURN to see some information about the man under the cursor. If you want the president’s name displayed as you move around you can press SPACE. Press SPACE again to turn off the name display.
The information that’s shown when you press RETURN includes the president’s name, birth and death dates, years of service, state, party, wife’s maiden name and a rather dubious nickname. I used the 1989 Information Please Almanac for most of the data. As a journalist, I’m afraid I cannot reveal the source of the nicknames. 2015 hint: Knees Calhoon.
After you have studied the information a bit, you may want to test yourself. Press T and you’ll go to the test mode. Here you’ll be asked to choose a particular president according to the information given. The president’s wife’s name, his state, or his nickname will be shown. You then go back to the presidents’ screens where you are to try to pick the president. Try to answer ten correctly before you answer ten wrong. You may press Q at anytime to exit the test mode. You can tell if you’re in the test mode — there’ll be a little “T” in the bottom right corner of the screen.
The program uses Dave Johannsen’s MR JOYSTICK (from LOADSTAR #76) so you can use a joystick in either port rather than the cursor keys. Press the firebutton in place of RETURN.
Press Q to return to LOADSTAR.
That’s all there is to it. It’s no big deal. I found it to be a learning experience putting this simple program together, not only because I learned what the presidents looked like, but because of the many ML routines I had to juggle to get the program to work.
Look at lines 20 - 102 where I load in all of the stuff. The important numbers are POKEd into 782. These are the high bytes of the locations of each of the ML routines. A tip for BASIC programmers who want to use some of the great ML routines we’ve published — whenever possible, keep the low byte at zero. If you think in hex (and you should), this means that you’re using addresses like $9C00, $C400, etc. The last two digits are 00.
Here is a memory map of the program’s routines, in terms of the high bytes. You can think of these as “pages” in a 256-page book.

003-004       INPUT ANY.O
004-008       Text screen
008-139       BASIC area
139-140       Cursor sprites for pic 2
140-144       Color memory for pic 2
157-160       MR JOYSTICK
160-192       Bit map for pic 2
192-196       EXEC FONT
196-200       SCRIPTER
200-201       Cursor sprites for pic 1
201-203       UNPACKER.89
204-208       Color memory for pic 1
224-256       Bit map for pic 1

And here’s a thumbnail description of each routine. For more details, you’ll have to read the ZERO PAGE article that introduced each one.
INPUT ANY.O - Reads a PETASCII file and puts it into strings for easy BASIC handling. The cassette buffer doesn’t begin at the beginning of a “page”. The high byte is 3 and the low byte is 60. In hex, $033C.
MR JOYSTICK - Allows me to use two simple SYSes to activate the joystick. It saves a LOT of code, and works better than BASIC.
EXEC FONT - This is only half of a font. The reversed half of the font isn’t needed by SCRIPTER.
SCRIPTER - This great routine allows me to print on a hi-res screen. Check out BITS on this issue for details.
UNPACKER.89 - Takes a packed hi-res (or multi-color) picture from disk and displays it with only three POKEs and a SYS. See line 40 for pic1 and line 60 for pic 2. This also saves a lot of code and headaches. Each packed file was loaded into 100 - 130 and unpacked into the locations above. Then the 100 area can be used by BASIC — its work is done.
I’ve never worked with hi-res screens much before and I found that by using the tools we’ve published, it wasn’t too difficult. I also developed an appreciation for the cleverness of C-64 programmers who program games and other graphic-intensive programs in the relatively small 64K we have to work with.
Whenever I look at IBM disks with their programs that take up 256K+ (and don’t really do more than our programs) I get the feeling that maybe some IBM programmers have gotten lazy and extravagant in their techniques. Or maybe it’s just the nature of the IBM beast.
Give me a C-64 with its built-in BASIC and ML tools, anytime.

Back here in 2015: Tomorrow's program doesn't do much more than this one but for those of us born in the 40s it might bring back a memory or two of a little road we called ROUTE 66.
 

No comments:

Post a Comment