P. 1
Retro Game Programming

Retro Game Programming

|Views: 608|Likes:
Published by bryan_letcher

More info:

Published by: bryan_letcher on Sep 16, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less





The last section went into details about the different components in your desktop
computer. The key component for anyone who wants to make games is the CPU since it
controls and manages what is going on in the computer and its speed will pretty much
dictate the constraints of the game you create. Two other key components is the graphics
chip (if any) and sound chip (again, if any). The graphics and sound chips will assist the
CPU in getting the job done of rendering the game to the user.

The CPU executes the program that resides on the game cartridge. The flow of data
within the home computer or game console is the following:

Figure 80- How that game gets on your television

The program and the data elements it displays must be placed into computer memory
(RAM). The CPU then processes the machine instructions. The instructions may

Data on Game



Other Devices

Retro Game Programming Copyright © 2011 by brainycode.com


correspond to reading in the game button just pressed by the user, saving the value for the
number of monsters on the screen, sending data to the video device so the gamer will
actually see something on their screen. The ―other devices‖ will be different for the three
machines we will be studying but the final output to your television set is the same – a
wonderful game!

The data on the game cartridge consists of a program designed to
execute for that CPU28

and data that holds the images and sounds that
we see when we play the game. The data on the cartridge is stored on a
memory device called ROM which stands for read-only memory. The
data remains on the cartridge. The cartridge may also contain another
type of memory that holds your score or save state while playing the
game. This type of memory (e.g. WRAM) may require a battery in
order to sustain the information for a reasonable length of time.

I recently purchased some NES games from eBay. I was rather disappointed to find out
the battery inside the cartridge had died and hence not allowing me to save game state! I
have to keep the NES running so I don‘t have to start all the way from level 1.

Programmers are the folks that create the programs we use in our computers or consoles.
They create computer programs for devices as small as my digital watch, my cell phone,
game boy advance or as big as my microwave, computer, notebook, XBox 360, or
automobile. The programs programmers write to get the machines to do their thing look
like strange incantations that only these wizards can understand.

Below is a small piece of code from a larger program that consumed hours of my time.

// D_DoomMain
void D_DoomMain (void)

int p;
char file[256];

FindResponseFile ();

IdentifyVersion ();

setbuf (stdout, NULL);
modifiedgame = false;

nomonsters = M_CheckParm ("-nomonsters");
respawnparm = M_CheckParm ("-respawn");
fastparm = M_CheckParm ("-fast");
devparm = M_CheckParm ("-devparm");
if (M_CheckParm ("-altdeath"))
deathmatch = 2;
else if (M_CheckParm ("-deathmatch"))
deathmatch = 1;

switch ( gamemode )


Not all CPUs are created equal. Each one has a unique set of instructions that they handle.

Retro Game Programming Copyright © 2011 by brainycode.com


case retail:

sprintf (title,

" "
"The Ultimate DOOM Startup v%i.%i"
" ",

case shareware:
sprintf (title,

" "
"DOOM Shareware Startup v%i.%i"
" ",

case registered:
sprintf (title,

" "
"DOOM Registered Startup v%i.%i"
" ",

case commercial:


You may be able to recognize the program code above as small portion of the game
Doom. So now you know the hours I spent were not spent programming but playing the
game. If you don‘t know the programming language used in the above sample some parts
will be readable and understandable and others more like Greek. The program or code
above is written in the programming language called C. The popular computer
programming languages today are Java, C++ and Visual Basic.

In order to program the games on the systems we plan on using in this book we will need
to learn Assembly Language specifically intended for the 6502 microprocessor.

So let‘s begin.

Retro Game Programming Copyright © 2011 by brainycode.com


You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->