Let’s take a closer look at the program and see how it was done.
For me, the first step in just about every DotBASIC program is designing an
FTS screen. In fact, I’ll admit that I enjoy creating things with DBDesign about as much as writing the programs themselves. I’ll often load in DBDesign and just play around with fonts and layouts, often getting ideas for programs in the process.
If you take a look at
ATARI.FTS, you’ll notice that the background is actually black, not light blue, and that I simply cover the screen with reversed light blue spaces. This is a little trick I learned from Dave Moorman that creates an effective illusion.
The fonts, with the exception of the Pac-Man characters at the top of the screen, can all be found on the
FONTS.D81 disk that is available in the Download Section.
Before we leave DBDesign, there’s one more thing to explore. Draw a box around the first menu item (Battlezone) by selecting Edit/Box. After drawing the box, notice the numbers in the top right corner of the screen:
22 7 16 1. This is the location and dimensions of the box. X=22, Y=7, 16 characters long, and 1 character deep. I wrote this down to make defining regions easier when writing the program. If you have a program that defines lots of regions, this is a very useful feature.

Let’s move on.
After creating the new project, I copied ATARI.FTS to my work disk, and now I’m ready to begin.
LISTing
ATARI.DBS, here are the DotCommands I used.
10 rem begin list
11 rem.fts,.bl,.edrtext,.dreg,.areg,.prtext,.rk,.ri,.pc,.sid
20 rem.endlistRemember, you don’t have to list all the DotCommands here at once. Just sit down and start banging out your code. When you get to a point where you realize you need a new DotCommand, just add it to the list above, save your work (
GOTO 60000) and then run
B.DEV from you DB+ Library disk. Whammo, in a few seconds you will be right where you left off, armed with a new DotCommand. BASIC has a lot of limitations, but what makes it such a fun language is that you can just sit down and start coding without having to do a lot of pre-planning. DotBASIC carries on that philosophy.
Let’s approach the program line-by-line now:
44 .qsI decided I didn’t want to use the mouse pointer for this program. After all, it’s a menu for Atarisoft games, none of which, of course, use a mouse. So, I turned off the mouse pointer (and all other sprites) with the
.QS command. Turning sprites back on is done with
.QR50 .bl,"atari.fts",d,224*256:.fts,224Now I BLOAD the FTS screen. ‘d’ is the default drive number, which DotBASIC keeps track of for you. As long as you don’t redefine ‘d’, it will always have the value of your active disk drive. That means you can run most DB+ programs from any drive, as long as you use ‘d’.
The FTS will be loaded into Page 224 (224*256=57344), and then I display it with the
.FTS,224 command. Note that once you display your FTS screen, you can then use those 16 pages of memory for other things.
54 .bl,"names",d,240*256This BLOADS a
Mr.Edstar text file into Page 240. “names” contains the actual filenames of the programs on the menu. In this case, the real filenames are all identical to the names listed in the menu, so maybe this seems unnecessary. But what if one of the programs on the menu is “B.C.’s Quest For Tires”? In this case you can print the full name in your menu, but have the corresponding entry in the “names” file be “bcs qft” or whatever the real filename is.
56 .bl,"regiontxt",d,224*256This is another Mr.Edstar file that contains the info for each game that is displayed at the bottom of the menu. Note that I re-used the memory that I had previously loaded the FTS screen into. Since the FTS screen is now displayed, I can use this RAM for other things.
58 .bl,"m.album leaf",d,144*256This is the SID file that plays in the background.
59 gm=1:.sid,144*256GM is the current Game Number that is highlighted. When the program is first run, I want the first game (Battlezone) to be highlighted. Thus, GM=1. Then I start playing music with .SID.
60 .edrtext,224*256This sets up the Region Text that will be displayed at the bottom of the screen. With
.EDRTEXT, I'm simply telling DB+ where the data is located.
75 x=1:.do:.dreg,x,22,6+x,16,1:x=x+1:.unx=13:.areg,1,255,13Each menu item will be defined as a Region. Here is where the
22 7 16 1 that we wrote down when using DBDesign comes in. So I set up my Do Loop with x=1, I define each Region, incrementing x until I define all 12 regions. Then, I use .AREG to go ahead and “light up” Region 1 (Battlezone) in light green.
80 pokemv+22,7+128+32:pokemv+23,23:.prtext,1Define the color and location of the Region Text.
MV+22 is color—7 (yellow) + 128 (reversed) + 32 (centered). By default, DotBASIC places Region Text on row 24, the very bottom line of the screen. Since my text will be displayed on line 23, I need to POKE a 23 into
MV+23.
Refer to pages 72-73 in the manual for a complete list of MV values. Next, I go ahead and print the Region Text for the first menu item (Battlezone).
100 .do:.kp,"{down}{up}”+chr$(13)+"msq":.uni%The Main Loop. This line waits for a keypress of down, up, RETURN, m, s, or q and keeps looping forever otherwise.
105 oni%goto150,155,175,200,200,10000This line branches the program off to react to whatever keypress is detected.
150 .areg,gm,255,05:gm=gm+1:ifgm=13thengm=1
152 .areg,gm,255,13:.prtext,gm:goto100These two lines are executed if a {down} key is detected. Using .AREG, I first color the current menu item green (not selected) and then I increment the GM variable by one. We only have 12 games, so if GM = 13 I need to go back to game 1 (Battlezone).
The next line uses .AREG to highlight the new menu selection, prints the appropriate Region Text for that game, and then returns to the main loop on line 100.
155 .areg,gm,255,05:gm=gm-1:ifgm=00thengm=12
157 .areg,gm,255,13:.prtext,gm:goto100These lines are executed when {up} is pressed, and is thus very similar to the two lines of code previous.
175 .rk,240*256:.ri,gm:goto1000If RETURN is pressed, the filename data we loaded from the “names” file is racked up. Then I retrieve the appropriate filename from that racked data with .RI,GM. DotBASIC stores that retrieved item in the variable
W$.
Racking data is a lot like creating a string array in plain BASIC 2.0. .RI is then used to access an element in that array.
200 x=peek(49152):.sidoff:ifx=0then:.sid,144*256
202 goto100If either M or S is pressed the music is toggled on or off. I do that by first PEEKing 49152. If there is a non-zero value there, that means music is playing and that the user must want to turn in off. If there is a 0 there, that means music is NOT playing and that the user wants to turn it on.
1000 print"{CLR}":.tx,7:.pc,12,"loading "+w$:.tx,0
1009 print"{home}{down}{down}{down}load"+chr$(34)+w$+chr$(34)+",8"This sets up the screen to use the dynamic keyboard technique to LOAD and RUN the selected game. Remember, W$ is the name of the game that was assigned by the .RI DotCommand in line 175. Note the .PC Dotcommand. This prints the string centered on row 12.
1010 .sidoff:.of:poke53272,22:poke44,8:poke8*256,0:poke56,160:clrRemember this line. It totally deactivates DotBASIC Plus and resets memory pointers to where they should be. I’d suggest you always use this line when using a DB+ program to LOAD and RUN a non-DB+ program.
1020 print"{down}{down}{down}{down}run"+chr$(142)+"{home}"
1030 poke631,13:poke632,13:poke198,2:endThis is the remainder of the dynamic keyboard routine. If you aren’t familiar with this trick, I'm basically setting up by PRINTing the LOAD and RUN commands on the screen, then I {home} the cursor and put two RETURNs (CHR$(13)) into the keyboard buffer. When the program ends, those two RETURNs in the buffer are dumped out, thereby LOADing and RUNning the game.
I have lines 1000 - 1030 saved to a different file that I call 'LOAD AND RUN". Then I can quickly insert them into whatever program I may be writing that needs it. If you use the dynamic keyboard technique a lot, you might want to do that too.
10000 sys64738Finally, if ‘Q” is pressed, the system does a reset.
And there you have it. Feel free to post any questions or ideas about how to improve this.