QBasic programs

These are some old QBasic programs I had in a backup of a computer my family used to have. (We used the computer to connect to the Internet over AOL at the time.) According to the file modification dates and comments inside the files I wrote them between 1996 and 1999.

I was amazed when I found that FreeBASIC could compile and run them, even the graphical programs, some with no modification. So I packaged them up and put them here. Despite what the files may claim, I now put them in the public domain.

In middle school and high school I did a lot of programming on my TI-82 graphing calculator in TI-BASIC. Calculator games was its own little scene back then. Some of these programs are ports from the calculator.

You can download all the files together:

They come with a makefile to build them all. To get a Bazaar branch do
bzr get http://www.bamsoftware.com/bzr/qbasic
Revision 1 contains the original files as I found them, before making any changes required by FreeBASIC.

While looking at these screenshots, remember that at 320 × 200 or 640 × 480 they took up the whole screen. A few of the programs are not listed here because I couldn't get them to compile. See the README for more.

Fractal.bas. Generates a Mandelbrot fractal and saves it to a bitmap.
ant2.bas. Draws several Langton's ants, written before I knew what they were called. This one grew out of a calculator program. On the calculator the graphics were so slow it took a long time for the ant to build its first highway.

bamnit.bas. Bamn It! A program that transmits a file over a telephone modem. I can't remember if it worked; I would be impressed if it did.

I took the menu subroutine from a program called BASTerm.BAS by Mark Kim, whose web site was once http://members.aol.com/markkkim but now appears to be http://markuskimi.us/. It is a trivial subroutine but there was a time when I didn't have a concept of a function returning a value; it was mystical to me.

I think the file sending code is based on that of a program called "Little Bastard" Modem WarFare (MWARFARE.BAS) by Molnar \ Kucalaba Productions, whose web site was once http://members.aol.com/blood225 but now appears to be http://mk-home.com/. At least that's what one variable name sflag suggests; I do remember reading the code and not knowing what using a variable as a "flag" meant.

bamstart.bas. An animated intro for BAM Software. I think I once planned on running the animation at the start of all of our programs. The code was translated from a TI-82 program with the same effects.

This intro has some sweet visuals. See them all: 1 2 3 4 5.

boom.bas. Models an explosion of hundreds of colored pixels. I must have written this after I learned about data structures (TYPE Dot), because previously I would have managed it with parallel arrays. The velocity variables are declared as integers, so there are only a few discrete initial horizontal velocities. This causes the pixels to sort themselves into visible bins after the explosion has progressed a bit. I remember this program being noticeably slow back when I wrote it, but I had to go back and add a delay to make it watchable on a newer computer.
bootcamp.bas. This is just a menu subroutine designed to emulate the one on the TI-82. I wrote it for my friend Hyun Gu Lee so that he could port his BOOTCAMP menu-adventure game from the TI-82 to QBasic.
box.bas. An experiment with subpixel rendering. The arrow keys move the box. Its edge pixels are colored shades of gray depending on how much of the pixel the box notionally occupies.
col.bas. A color displayer. Hit the left and right arrow keys to see all the colors. The comments at the bottom refer to colors for ramismak.bas.
fire.bas. This is a little demo of a "going up in smoke" effect.
firework.bas. A fireworks physics demo. Press enter to clear the screen or + to save a bitmap (uses the same code as bmper.bas).
fonter.bas. This is a test program for the fonts made by fontmake.bas. It displays the contents of a file using a custom font. I think this was inspired by a program called FONTLOAD.BAS. This code is more economical in that it stores one pixel per bit in the font file, not one pixel per byte.
fractpix.bas. Another experiment with subpixel rendering. Two progress bars fill up; one aliased and one antialiased. After that aliased and antialiased columns move across the screen. I think the file name is short for "fractional pixel."
golf.bas. I'm not sure, but I think this was a test of intersecting two line segments, as part of the physics of a golf game.
grapher.bas. Draws a graph of one or more functions (yv(1).equ and so on) and saves it to a bitmap. I used this program to generate a graph for a report in middle or high school. The teacher asked what program I had used; he was impressed when I said I wrote it myself.

graphics.bas. An image editor. When I was experimenting with game programming I wanted a way to draw graphics that was easier than typing the commands to draw points and lines. However I didn't know how to load bitmapped graphics. This program lets you draw images using several paint tools. Its output is executable QBasic code that you just paste in your program. For example, the spraypaint tool colors random pixels within some distance of the cursor; for every pixel it draws it writes a PSET statement to the output file. dude.bas was made with this program. I couldn't find any better examples.

When the program starts it prompts you for a drive and a file name. On Unix you can use something like "a" and "image" to write to the file "A:IMAGE.BAS" in the current directory. Next you must choose the variable names for the X and Y reference points around which the image will be drawn. So if in your program the player's location is stored in the variables playerx and playery, enter "playerx, playery" and those variable names will be used in the output file.

You must then set the initial values of the centerx and centery variables. Use the 2, 4, 6, and 8 to move the cursor and hit 5 when you are over where you want the picture to begin.

Drawing tools. The current tool is indicated by an icon in the lower left corner.

  • 0: Change color.
  • space: Draw a pixel at the cursor.
  • e: Copy a rectangle with GET. Use the spacebar to mark the two corners of the rectangle, then type in its name.
  • d: Paste the most recent copied rectangle. Use the spacebar to place it.
  • r: Add a REM comment in the output file.
  • c: Draw a circle. Use the spacebar to mark its center and a point on its circumference.
  • l: Draw a line segment. Use the spacebar to mark the two endpoints.
  • p: Paint bucket fill at the cursor.
  • q: Pen drawing mode. Use q again to go back to normal mode.
  • s: Spraypaint: use the spacebar to draw a random number of pixels near the cursor.
  • g: Turn on and off grid points. Doesn't affect the output file.
  • x: Exit.

Source for the images at left: abstract.bas, space.bas.

pong.bas. A graphics demo something like a 3-D game of pong. A circle bounces around inside a room. Press t to toggle tracking lines.
quadrati.c. A quadratic formula program, ported directly from the TI-82. It's not a C program; the strange file name is I think an artifact of QBasic's naming algorithm—anything past the eighth character just became the extension.

spaceman.bas. A great action game ported from the TI-82. The mission description: "You are a pilot for the Space Division of the United States Marine Corps. Your mission is to escort a transport to the next station. If you meet any hostile ships, open fire." You have to blast enemy ships with a laser before they crash into you until a timer expires. This is a direct port from the TI-82, leading to a GOTO-based program flow. If you select option 5 at the main menu you can set your callsign and get personalized messages when you score enough kills.

All Spaceman screenshots: main menu, briefing, blasting alien scum, successful mission, game over. The blood-down-the-windshield effect when you die is just rad.

stars.bas. An animated starfield.
virus.bas. A phony computer virus that pretends to erase all your files. This came from a TI-82 program as well.