You play as Detective Chuck Jones (no relation to the animator of the same name), a rough and tumble LA cop in the year 1976. While involved in a high-speed chase you have a car accident and are heavily wounded. To avoid death you are cryogenically frozen, many years in the future you are unfrozen and must track down and apprehend a dangerous criminal in a strange time by flying around the galaxy in your rocket powered El Camino, meeting interesting characters and solving puzzles.

  • View media
  • View media
  • View media
  • View media
  • View media
  • View media
Post article RSS Articles

Creating a Custom Scripting Language For In-Game Events

Client Side Coding Tutorial

This article was originally posted on my blog.

pdp-10_1090


Let's start by going back to the late 1970s, shortly after Chuck Jones himself was frozen. In 1977 a bunch of guys at MIT were working on the groundbreaking text adventure game ZORK. ZORK was written originally for the big mainframe computers at MIT such as the DEC PDP-10. Eventually these guys decided to form a company called Infocom in order to sell their games, but they had one big problem: There were very few mainframe computers in the world and the people who owned them were generally not interested in buying Video Games. If Infocom wanted to sell games, they would have to make them run on the small personal computers that were entering the consumer market at the time. However this presented an interesting challenge: the mainframe version of ZORK required 1MB of memory (1 MB = 1024 KB) but the personal computers of the day often had less than 32KB of memory, so how on earth were the going to get the giant world of ZORK on a personal computer!? The answer: A custom scripting language! The guys at Infocom were some seriously smart dudes and realized that most of the core logic of the game could be broken down into a series of game specific instructions such as move object to room, write message, etc. each one of these in game instructions could correspond to tens or even hundreds of machine code instructions making the game tiny. They essentially created a Virtual Machine, which they called the Z-Machine which was highly specialized for playing text adventures. The program to execute the Z-Machine instructions could be very small, and it being the only part of the game that was specific the computer it was running on, made conversions of the game to other systems a breeze. Because writing Z-Machine instructions by hand had many of the drawbacks of assembly code, Infocom also created a compiler for a Z-Machine high level language which made it easy to implement new games.

zork


Now what does ZORK have to do with Chuck Jones? Well everything actually. In Chuck Jones: Space Cop of the Future, I use the exact same approach. I created a Virtual Machine which executes byte-code that is specifically designed to play graphical adventure games and in doing so I save time, memory and disk space. I call this somewhat unimaginatively: The Chuck-Machine! On top of this I built a high level but specialized language for controlling what happens in the game. Well at this point, if you're brave enough, we'd better dive into the implementation details.

Chuck-Machine


The above diagram gives a simplified overview of how my interpreter is structured, we have several processes each with their own set of registers which are cooperatively juggled on the single CPU that the game is running on. Additionally the interpreter maintains a global list of objects, rooms and sounds that are dealt with by the scripts as well as provides 128 global registers for inter-process communication. Now lets move on to the language itself.

Chuckscript


Here's a screenshot of me editing one of the scripts in the wonderful Notepad++ editor. The language is very much like a structured BASIC but with quite a bit of influence from C and C++. Because of the design of the underlying Chuck-Machine the language manages to compile to usually one or two byte-code instructions per line (with the obvious exception of macros and procedure calls), this is because complex operations can be built into the Chuck-Machine itself as special instructions.

basm.png


Once a script is written it is compiled using the somewhat confusingly named BASM tool (the Bytecode ASseMbler), because this tool is actually a compiler and not an assembler. BASM is written in C++, when I wrote BASM I was moving really quickly and as such it's pretty inelegant and is a bit of a hack. Despite this it works.

In summary creating a custom language doesn't have to be that complicated and you can save yourself a lot of time and memory if you do it right.


Check out the Dev Blog

Check out the Dev Blog

News

Check out my new blog, its chocked of technical information for those who are brave enough.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Chuck Jones: Space Cop of the Future
Platforms
Windows, Mac, Linux, DOS
Creator
JakeDel
Engine
Custom
Contact
Send Message
Release date
Game watch
Follow
Share
Style
Theme
Sci-Fi
Players
Single Player
Project
Indie
Embed Buttons
Link to Chuck Jones: Space Cop of the Future by selecting a button and using the embed code provided more...
Chuck Jones: Space Cop of the Future
Statistics
Visits
497 (4 today)
Last Update
Watchers
2 members
Articles
2
You may also like
Luna City: Codename 39
Luna City: Codename 39 Point and Click
J.U.L.I.A.: Among the Stars
J.U.L.I.A.: Among the Stars Point and Click
Castaway Kirk
Castaway Kirk Point and Click
Too Big For This World
Too Big For This World Point and Click
Nando's World
Nando's World Point and Click