aPong

aPong is a Pong game written in x86 Assembly language.
aPong is a Pong game written in x86 Assembly language.

As I run Linux on my own machine, I don't do a lot with intel syntax. I needed to learn this for a lab. After scouring the internet for a few hours, I came across NASM. This looked as though I'd be able to just code in this, take it into the Windows computers and have it just work.

No such luck. So, that's beside the point now, but I wrote this in order to get to grips with the syntax (which turned out to be the wrong one.)

Here are some key features of "aPong":

2-player

The left one uses Q/A to go up/down, the second one uses P/L. Escape to quit.

Uses SDL from assembly language

I quite like SDL. I quite dislike x86. I already know SDL. It was already a learning exercise, I wasn't going to go off learning xlib or something at the same time. This gave me a way to quickly get the code written.

Avoids the use of frame pointers

Why do you need frame pointers if you're not going to be running it in a debugger. It's not difficult to keep track of the stack frame if you're writing it yourself. You don't need to keep moving the stack pointer inside a function, just once at the start and once at the end. Then all you need is to take offsets from esp (so long as you remember how big the frame is at the time.)

This really gets on my nerves. People don't seem to realise the amount of overhead (in terms of 'lost' cycles) that a function call has. To say global variables are BAD is just plain wrong. Sure, it can lend itself to abuse, but that's like saying you shouldn't code in C or use UNIX because they don't hold your hand.

The input system isn't great.

Because I was trying to keep the code size down, I went the way of using SDL_GetKeyState and SDL_PumpEvents. These mean that if the key is not actually down at the time of the PumpEvents call, it drops the keypress. (if you want to see how you should do it, look at the events system in STP

Requirements:

NASM
GCC (for linking)
libSDL (for graphics and input)

Compilation:

nasm -f elf pong.o
gcc -o pong pong.o -lSDL

Controls:

Player one Q (up), A (down)
Player two P (up), L (down)
Escape - quit

last updated on:
March 5th, 2007, 15:05 GMT
price:
FREE!
developed by:
Richard Whitty
homepage:
www.csc.liv.ac.uk
license type:
GPL (GNU General Public License) 
category:
ROOT \ Games \ Arcade
aPong
Download Button

In a hurry? Add it to your Download Basket!

user rating 15

3.3/5
 

0/5

Rate it!

Add your review!

SUBMIT