Skip to content

hali-coding/megadriveinvaders

Repository files navigation

snesgame2

Small SNES homebrew project built with PVSnesLib. The game ROM is generated as snesgame2.sfc and can be run in a SNES emulator after building.

What This Project Uses

  • C for game logic in src/main.c
  • PVSnesLib for the SNES SDK and build rules
  • GNU Make under a Linux or WSL shell
  • PVSnesLib graphics conversion tools during make
  • Python helper scripts in tools/ for regenerating source BMP art

Project Layout

  • src/main.c: main game code
  • Makefile: build rules and graphics conversion steps
  • tools/: helper scripts to regenerate some sprite BMP assets
  • *.bmp / pvsneslibfont.png: authored source graphics used by the build
  • *.pic, *.pal, *.inc, *_data.as: generated SNES graphics data consumed by the game
  • snesgame2.sfc: built ROM output

Required Tools

The build targets a Linux or WSL shell with GNU Make.

1. PVSnesLib

Install PVSnesLib and set PVSNESLIB_HOME to point at it, using a Unix-style path. Add it to your shell profile (e.g. ~/.bashrc) so every shell has it:

export PVSNESLIB_HOME=/opt/pvsneslib

The Makefile reads PVSNESLIB_HOME and stops with an error if it isn't set.

2. Python 3

Needed to run the helper scripts in tools/ that regenerate some BMP assets. They use only the standard library (no pip install required).

3. SNES Emulator

Any emulator that can load .sfc ROMs should work.

Build Process

The build works in two stages:

  1. Convert image assets into SNES graphics data.
  2. Compile and link the game into snesgame2.sfc.

The Makefile target flow is:

all: artifacts snesgame2.sfc

artifacts groups the asset-conversion steps (bitmaps, musics, brrsound). The bitmaps target regenerates SNES-ready graphics data from the source images:

  • pvsneslibfont.png -> pvsneslibfont.pic, pvsneslibfont.pal
  • sprites.bmp -> sprites.pic, sprites.pal
  • enemy.bmp -> enemy.pic, enemy.pal
  • tac2.bmp -> tac2.pic, tac2.pal
  • bullet.bmp -> bullet.pic, bullet.pal

From those assets, the PVSnesLib build rules generate the final ROM.

Build Commands

With PVSNESLIB_HOME set (see Required Tools), build from the project directory:

make

To rebuild just the converted assets without linking the ROM:

make artifacts

To remove all build output and generated asset data:

make clean

Make Targets

  • make / make all: convert assets, compile code, and produce snesgame2.sfc
  • make artifacts: convert source art/sound into SNES data, without linking the ROM
  • make clean: remove the ROM, build intermediates, and generated asset data through the PVSnesLib clean rules

Asset Workflow

This project keeps source art in standard image formats and converts them during the build.

Source assets used by make

  • sprites.bmp: player sprite sheet
  • enemy.bmp: enemy sprite sheet (Genesis console; one hit to destroy)
  • tac2.bmp: tough enemy sprite (TAC-2 joystick; takes three hits to destroy)
  • bullet.bmp: bullet sprite
  • pvsneslibfont.png: font image

Generated outputs

The conversion step produces files such as:

  • .pic: tile graphics
  • .pal: palettes
  • .inc: include symbols for the game code
  • *_data.as: assembler data blobs used by the linker

These generated files are already present in the repository, but they can be regenerated by rebuilding.

Helper Scripts

The Python scripts in tools/ are not part of the normal make target. They are helper utilities for regenerating the source BMP files before running the build. They share tools/snesbmp.py (a small standard-library helper that draws onto an indexed canvas and writes the 8bpp BMP), and they use only the Python standard library, so they run the same on Windows, Linux, and WSL.

tools/make_player_bmp.py

  • Rebuilds sprites.bmp
  • Preserves an original backup at tools/sprites_src.bmp
  • Downscales the player art to roughly 21x21 inside a 32x32 sprite cell

Run it with:

python3 tools/make_player_bmp.py

tools/make_enemy_bmp.py

  • Generates enemy.bmp
  • Creates an 8bpp 32x32 enemy sprite with a fixed palette
  • Downscales the art to roughly 21x21 inside a 32x32 sprite cell

Run it with:

python3 tools/make_enemy_bmp.py

tools/make_tac2_bmp.py

  • Generates tac2.bmp
  • Creates an 8bpp 32x32 sprite of a Suncom TAC-2 arcade joystick (red ball-top stick, chrome shaft, black base with a red fire button)
  • Draws the art in the top-left 21x21 of the 32x32 cell so it lines up with the enemy hit-box
  • This is the tougher enemy: it takes three hits to destroy (a screen-clearing bomb still flattens it in one), descends more slowly, and is worth more points

Run it with:

python3 tools/make_tac2_bmp.py

tools/make_bullet_bmp.py

  • Generates bullet.bmp
  • Creates an 8bpp 8x8 bullet sprite with a small fixed palette

Run it with:

python3 tools/make_bullet_bmp.py

After running any of these scripts, rebuild the project so the .bmp changes are converted into SNES asset data.

Output

Successful builds produce:

snesgame2.sfc

Other intermediate files such as object files, symbol files, and converted graphics data may also be produced or refreshed.

Troubleshooting

PVSNESLIB_HOME is not set

If make stops immediately with a message about PVSNESLIB_HOME, export the variable so it points at your PVSnesLib install (a Unix-style path), e.g. export PVSNESLIB_HOME=/opt/pvsneslib, and add it to your shell profile so it persists.

PVSnesLib path errors

PVSNESLIB_HOME must be a Unix-style path (PVSnesLib's build rules reject paths containing a backslash). Under WSL, point it at a Linux path or a /mnt/c/... mount, not a C:\... path.

Asset changes do not appear in the ROM

If you edited or regenerated a BMP or the font PNG, rebuild the ROM so the graphics conversion step runs again.

Typical Workflow

python3 tools/make_enemy_bmp.py
python3 tools/make_bullet_bmp.py
make

If you did not change the source art, only make is needed.

About

Represents a repository for a homebrew SNES (Famicom) space shooter game

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors