Archive for September, 2007

Past Programs – Cannons for Windows 1.5

Saturday, September 29th, 2007

Past Programs - Cannons for Windows 1.5

Cannons for Windows is one of those classic “tank firing a cannon ball at a target” game. This is one of the older versions of the game which was based off of code handed to students attending a after-school computer club when I was 5th grade. We were told to follow a series of directions on paper and copy down the source code into a form in Microsoft Visual Basic. Most of the code dealt with the projectile motion and the target hit detection, something that you wouldn’t expect an elementary school student to come up with on his or her own.

My version added a few “features” such as wind which would push the shell back toward the cannon. The wind was adjusted by sliding the scroll bar to the desired wind strength. Also, a picture box was added next to the wind scroll bar which would show a drawing of wind blowing on a house. The problem with that feature was that it only changed the drawing when the user clicked on the box and had a floppy disk with the drawings of the house in various wind levels. Of course, all these were a result of not really knowing much about events, properties of controls, etc. (But then again, can you expect too much out of a 11 year old kid?)

  • Language: Microsoft Visual Basic 3.0
  • Date: March 1995
  • Platform: Microsoft Windows 3.1

Past Programs – Luckfinder 2

Friday, September 28th, 2007

Past program thumbnail 1

Luckfinder 2 was a text adventure game where the player goes through a pretty much pre-determined route with very little deviations from the one-dimensional game play. (Basically one had to just remember not to go back the same direction, i.e. if you went south in the last move, just don’t go back north.)

At the time, I was playing a text adventure game called Wishbringer by Infocom, and was influenced into writing a game that was similar.

The game was written in QBasic around 1994. I remember writing this on my father’s 386 Toshiba laptop, back in the days when 486 desktops were prominent. Pentium-based computers were available, but those computers were top-of-the-line and were very expensive. If memory serves right, the fastest x86 processor at the time was a 66 MHz Pentium.

(If it weren’t for the horribly broken English, I would show the introduction, but as I said, it’s horribly broken English, so I’m too embarrassed to show the introduction screen. End of story.)

  • Language: Microsoft QBasic
  • Date: 1994?

Past Programs Gallery

Friday, September 28th, 2007

Past program thumbnail 1Programming has been my hobby since I was in elementary school. I started out watching my friends who were writing programs by pecking at the keyboard of the 386 machines at school. This is back in the days of DOS, where most programs were still being written in text mode and graphics were primative. (In retrospect, graphics in DOS was really awesome. The ability to directly manipulate the graphics adapter is not possible with modern operating systems.)

Past program thumbnail 3I haven’t had much formal education in computer programming except for a semester here and few quarters here, but it has been an activity that I’ve enjoyed for a long time. Most of my programming knowledge has been self-taught, but I really think I’ve benefitted from the few classes I’ve taken.

I’ll be posting some of the programs I’ve worked on over the years, along with some thoughts that come up.

Pitacalc (Part 3)

Friday, September 28th, 2007

As mentioned in the previous post, Pitacalc is able to adjust the number of registers the calculator uses. This register bank resizing feature can be performed by using the rrb instruction.

Pitacalc - Resizing the registers

As one can see above, using the reg command, there are ten registers by default. By typing in rrb 5 to perform a register resize, the subsequent reg command shows there are five registers. The rrb 12 and the following reg shows 12 registers. It is possible have anywhere from 1 to 100 registers with Pitacalc.

More features have been added since the last post. The current build, 309, contains new features such as color mode for the console and output in HTML format.

Pitacalc is not a particularly useful tool that has many uses, but it does demonstrate how a computer performs calculations at the low level. Using Pitacalc is similar to programming a computer to do calculations in assembly language. Although actual computers don’t work exactly like Pitacalc, having to enter instructions to perform calculations are similar.

Pitacalc (Part 2)

Thursday, September 27th, 2007

There are certain aspects that regular calculators do not have that Pitacalc does. For example, Pitacalc has multiple registers which can be used to store values. These values can be set by using an appropriately named set instruction.

Pitacalc - Setting registersBy typing specifying the register when performing the set instruction, one can set a value of the register. For example, to set the register r0 to the value 10, type set r0 10 and press enter. As can be seen on the right, the line after the set instruction is a 0. This zero is the value stored in the accumilator. After executing any instruction, the value stored in the accumilator is returned. This is unaffected by the setting of register r0, hence the accumilator stays zero.

To check that register r0 was set to 10, we can use the reg instruction to show all the registers and their stored values. We can see that r0 is indeed set to 10. Another way to check the value of a specific register, just type in the name of the register. Here, typing in r0 gives us the value 10.

Pitacalc also allows renaming of registers. Any practical reasons? Perhaps the following image may illustrate one use:

Pitacalc - 42

Here, the registers which had the default name of r0 through r6 were renamed to words. In this aspect, the registers work a little bit like variables in computer programming.

Renaming a register is performed by the ren instruction. By typing the register name to change followed by a new name, a register can be renamed. For example, in the above example, register r6 was renamed to Everything. The instruction executed to perform the rename was ren r6 Everything.

Are ten registers not enough? No need to worry. Unlike a real world calculator, it’s possible to increase the number of registers with Pitacalc, up to 100. (Even this is an artificial limit that can be changed with minor changes in the program.) We’ll get into resizing the register bank next time.

Pitacalc – a command line interface calculator

Thursday, September 27th, 2007

Pitacalc is a command line interface calculator program. It’s works like a regular calculator by performing arithmetic operations and having an accumilator that keeps the running total. It also has several registers that can be used to temporarily store values.

For those who are interested, the calculator is a Win32 console application, so it should run on Windows 95 and higher. Maybe even NT 4; not that I’ve tried.

Pitacalc Image 1Arithmetic operations are performed by typing in instructions. For example, to set the accumilator to 100, one would type in set 100. To add 200 to that value, one would type in add 200. The result of 300 shows up on the line following the add 200 line.

Although the example only shows adding one value to the accumilator, it is possible to add more than one value at a time to the accumilator. For example, by typing sub 100 200, the result of 0 will be returned.

Basically I was writing this calculator as practice programming in C. After programming in Java fairly exclusively for the past year or so, I thought it was time to brush up on some good ol’ C. Having to juggle around pointers between functions and calling malloc at every corner was loads of fun. (Please note the sarcasm in the previous sentence.)

Just to add useless features, the program accepts “scripts” of instructions to execute. Conversely, the output of the program can be dumped into an external file. I can’t think of any real use for this feature. Pitacalc has many features that really don’t have any real purpose.

Over the next few posts, I will introduce the great features (yes, that’s an overstatement) of Pitacalc. The current version 0.0.1 build 257. I’ll be adding more features (yes!) so the current version in the future will probably not be build 257.