Saturday, September 17, 2011

Simple Language Compiler

One of our projects that I have worked on for my Advanced Computer Science class at the Governor's School is a simple machine language assembler and compiler.

For the first part of my project, I coded an assembler that takes in four digit numeric commands and executes them. It can store up to a hundred lines of code, variables, and constants.

There is a set of instructions available for the assembler. They are very simple commands, hence the name of the project. The instructions are as follows:

10 Read – reads a word from the keyboard into the specified location in memory
11 Write – writes a word from the specified location in memory to the monitor screen
20 Load – loads a word from the specified location in memory to the accumulator
21 Store – stores a word from the accumulator into the specified location in memory
30 Add – adds a word from the specified location in memory to the accumulator
31 Subtract – subtracts a word from the specified location in memory from the accumulator
32 Divide – divides a word from the specified location in memory into the accumulator
33 Multiply – multiplies a word from the specified location in memory by the accumulator
40 Branch – sets the instruction pointer to go to the specified location in memory. ( branches or jumps)
41 BranchNegative – branches to the specified location in memory if the accumulator is negative
42 BranchZero - branches to the specified location in memory if the accumulator is zero.
43 HALT - the program execution is stopped.
For example, 1090 instruction orders the machine to get input from the keyboard and store it into address 90.

Once this was coded, my next task was to create a compiler that would take human language and covert it into machine-level language that make up the instructions that are passed into the assembler.

The compiler has several instructions that can be passed:


rem: Basically a comment function

input: Reads input from the keyboard. Serves the same purpose as the machine-level instruction 10.

print: Prints a variable onto the screen so that the user can read. Serves the same purpose as the machine-level instruction 11.

let: Computes a mathematical expression and makes it equal to the specified variable.

goto: Branches to a specific line denoted by its number.

if: Mandates a specific condition to be met in order to branch to the specified line.

end: Ends the program.
Bug testing and showing appropriate error messages were painful to accomplish. The let function of the compiler was also very difficult to manage, but it worked out in the end.

Here is the link that takes you to the code for the compiler, if any of you are interested in taking a look: CLICK HERE!

In case it wasn't clear as to what this program actually does:  The Simple Language Compiler is something like BlueJ (java), Microsoft Visual Studio compiler (C), and even basic command prompt compiler batches.  You can type commands in a text file and put that into the compiler.  The compiler will then parse through your code and write it out in a language that the machine, or the computer, can read and execute.

Anyways, thanks for reading! 

Monday, September 5, 2011

Guild of Mercenaries - A Video Game

Guild of Mercenaries was a two-week project that I worked on with a friend of mine during the Interim period in January.

My friend worked on level and model design as well as the storyline.

I was responsible for the programming, animating, and gameplay design.

We were quite satisfied with our results. The game itself is really simple, but still provides about 4-5 hours of fun.

The game features two computer-controlled teammates who will assist you all the way to the end. As of current version, they do not die, so you can use them as human shields if you need to. The game features four levels of armor, three weapons, and a shield that can be purchased at the shop. There are four towns, with three quests in each, as well as an overworld area that serves as a pathway from one town to another.

Your goal is to defeat the final boss. You will be able to take on the quest that requires you to defeat him as soon as you've finished all other quests. There are two types of enemies: Melee and Ranged. Some quest-specific enemies exist as well, and they tend to be more challenging than the regular enemies. Boss enemies appear for final quests in each town.

On a side note, all sounds were obtained from Oblivion and Mount and Blade.

SPOILER:
The final boss music is from Call of Duty: Modern Warfare 2.

Gameplay Video:




And here are some screenshots:

Main Menu:

Game Start:

Quest Select:

Shop Menu:

Combat Aftermath:

Combat with Computer-Controlled Allies:

Scenery:

New Game Project

On September 3rd, the video game development club that I founded for my school has officially begun a project.

It's going to be a real-time tactics game with emphasis on unit micromanagement. As the designer, I wanted to take features from games like Frozen Synapse and merge them together with games like Company of Heroes.

I'll post more details to come as we continue to develop the project. For now, our goal is to have a playable version by the end of the year. Stay tuned!

Sunday, September 4, 2011

Beginning

Whew! It wasn't that hard to get this running. This blog will be dedicated to showcase my programs, games, and anything tech-related that I've worked on in the past few years. Although this was created with college applications in mind, others are always welcome to see what I've been doing!