John Bintz a0fbfac5b8 | ||
---|---|---|
bin | ||
cutest-1.5 | ||
old | ||
system | ||
.gitignore | ||
README.md | ||
arena.c | ||
arena.h | ||
bmpload.c | ||
bmpload.h | ||
chicken.bmp | ||
combat.c | ||
combat.h | ||
combat_test.c | ||
const.c | ||
const.h | ||
const_test.c | ||
font8x8_basic.h | ||
game.c | ||
game.h | ||
game.lnk | ||
makefile | ||
movement.c | ||
movement.h | ||
movement_test.c | ||
powerup.c | ||
powerup.h | ||
powerup_test.c | ||
run | ||
screenshot.png | ||
setup.sh | ||
spawn.c | ||
spawn.h | ||
spawn_test.c | ||
sprites.asm | ||
sprites.h | ||
spritesheet.xcf | ||
spritesheet.yml | ||
sprtsht.bmp | ||
test | ||
test.c | ||
timer.c | ||
types.h | ||
unchained.c |
README.md
DOS VGA Arena Shooter Game
A Smash TV/Robotron-like game to help me learn a whole bunch of things about game programming, DOS & PC programming, x86 assembler & C, and VGA graphics!
Video of the game in action here!
Play!
The latest build of the game is under Releases. Send any feedback you wish -- it's appreciated! -- but I really don't know when I'll get back to working on this.
Use WASD to move, left mouse to fire, aim using your mouse. Shooting enemies restores health and gives you coins. If you earn enough coins, you can upgrade:
P
will increase damage per shotO
permanently upgrades your max health and restores all your healthI
will increase the amount of health you can get from shooting enemies
There are two weapon pickups:
- Yellow is a shotgun, firing a spread of three shots
- Red doubles up your shots, potentially making it through more enemies
Much of it is not working:
- The game just starts.
- The game doesn't end when you run out of health. Hit [Escape] to end the game.
- The difficulty needs serious tuning.
- It does not look good.
- If you play for too long the game will likely crash.
Try it out!
Setup
Builds are done on a host Linux system with Open Watcom 2.0 installed to
a local directory. On my machine, that's ~/Applications/open-watcom-v2
.
Tests and game are run in DOSBox-X.
Clone and build Open Watcom 2 for DOS cross-compilation
You'll need to build Open Watcom 2 from source to get DOS compilation on Linux. Follow the directions on their GitHub wiki.
You may need DOSBox installed for the Open Watcom 2 build.
Modify setup.sh
to use your local Open Watcom install
Changing the path of export WATCOM
should be enough
Install Ruby and the RMagick gem
The spritesheet builder uses Ruby and RMagick to produce the x86 assembler
spritesheets from spritesheet.bmp
.
Install DOSBox-X
I used the Flatpak version and created a wrapper script in my PATH
:
#!/bin/sh
flatpak run com.dosbox_x.DOSBox-X "$@"
Try building the game & tests
bin/game
builds and runs game.exe
and bin/test
builds and runs the
unit tests.
Make a release
bin/release
makes release.zip
which contains the game and the DOS/4GW
wrapper.
What's in here?
System access code
Everything in the system
folder is about directly accessing the PC hardware:
keyboard.c
accepts keyboard input using a keyboard interrupt.mouse_io.c
accepts mouse input.pc_stuff.c
does various PC things with interrupts.vga.c
accesses the VGA card and has drawing routines built for 32-bit protected mode code and using the 320x200x256 chained VGA mode (mode 10h).
Unit tests
I'm using the CuTest library to write basic unit tests for the game. I wanted to try out C unit testing and see what libraries could work on retro machines, and CuTest fit the bill. The tests run directly in DOS.
Compiled sprites
I automated the pipeline to building compiled sprites from a bitmap file.
Originally, I was doing memory copies from that bitmap file, and no matter
how much I optimized them, they were slow slow slow. Having Ruby build the
sprites as a series of mov
instructions sped up the game immensely.
Inline assembler
There's some non-trivial inline assembler in system/vga.c
for drawing
font glyphs. https://github.com/dhepper/font8x8 is the source of the
font. I probably could have gotten the performance fast enough in pure C,
but I really wanted to try some inline assembler.
Bitmap loading code
Before switching to compiled sprites, I wrote code to load BMP files to a memory location of your choosing, as well as to extract the palette for feeding to the VGA card.
Open Watcom wmake
Makefiles
The Makefile
s are not sophisticated, but it took me quite a while to
research Open Watcom's slightly different syntax for Makefiles
. The GNU
make docs didn't help too much.
License
MIT License on the code. If you use any code verbatim, or do anything else with this, let me know!
CuTest has its own license.
Any art that's not the spritesheet is (C) John Bintz, all rights reserved. That
should only be the chicken.bmp
file that's used as an example for
bitmap loading code.