Gigaleak - Original F-Zero Source Code (SNES)

Edit on Github | Updated: 8th May 2023

Root directory (SFC.7z/ソースデータ/FZERO)

When the Gigaleak SFC.7z archive (located inside Other.7z) is extracted it contains the source code for a bunch of Super Nintendo games, F-Zero is one of them, this post will cover evertthing in the FZERO directory from the extracted archive.

This folder contains the following sub-directories:

  • Game - Assembly source code for the game
  • Tools - C Source code for the tools used to make the game

Game (/Game)

/Game

This folder contains the main game source code for the PAL version of F-Zero for the Super Nintendo which is also called SFX CAR RACE in some of the source files.

The files in this folder are described in the table below:

File Name Extension Description
ALPHA N/A Header file defining Alpha constants SP,RO,QU etc, unsure of purpose (18th June 1990)
ALPHA2 N/A Header file defining Alpha constants N0, N1 etc, unsure of purpose (5th December 1989)
ANK N/A ANK character font graphics in assembly format
ANK8 N/A Header file defining Alpha constants N0, N1 etc, unsure of purpose (5th December 1989)
BUFFER N/A Header file defining the main game buffer variables such as car acceleration etc (24th July 1990)
RP5A22_ N/A Header file defining SFX CPU registers
RP5C77_ N/A Header file defining SFX PPU registers
TITLE .DOC Just has some meta data information such as the dates this game was worked on, the programmers and copyright information
VARIABLE N/A Header file defining the main game variables such as game_level (23rd April 1990)
WORK N/A Header file defining variables stored in WORK RAM
calculate .asm Contains functions such as Calculate_score
calculate_usa .asm Same as calculate.asm with a change to the Demo_stick_data variable
car_control .asm Car movement functions such as Drift_ctrl
control_data .asm Data for each of the cars such as maximum speed
data-5 .asm Contains Course (Track) data (no actual code)
data-6 .asm Contains Rival speed data (no actual code)
effect .asm Contains functions for special effects like shadows and lazers
en-check .asm Contains enemy check functions such as if they are on screen
en-data-1 .asm Contains enemy OAM data (no code)
en-data-2 .asm Second part of enemy OAM data
en-drive .asm Contains Ememy driving functions, controlling speed and acceleration
en-init-1 .asm enemy car Initialize Routine
en-init-3 .asm Open drive data sub routine
en-init-4 .asm enemy car Initialize Routine
fzero_main .asm Program entry for the game
fzero_main_pal .asm Program entry for the PAL version of the game
fzero_main_usa2 .asm Same as fzero_main.asm but fixes a few bugs
fzero_pal .make Makefile for the PAL version of the game
game_over .asm Contains game pause functions and the game over logic
game_over_usa .asm Same as game_over.asm but changes the Roll Data
makefile N/A Used to build the source code in the folder (run make)
play_main .asm Functions for screen select and initialization
play_main_pal .asm Same as play_main.asm but changes the frame count timer logic (50hz)
player .asm Player control functions such as Player_explode
set-obj .asm Obj functions like Smoke and explosions
set_back , .asm Background setup functions
set_bg1 .asm functions for transferring world and slit data
set_bg2 .asm functions for calculating perspective
set_bg2_usa .asm Same as set_bg1.asm with slightly different title data
sound .asm sound and music functions
title_main .asm title and car select screens
title_main_usa .asm same as title_main.asm with slightly different cusrsor values

All the .asm files get assembled with the official SNES SDK assember (as65c) and then linked together with the link tool.


Tools (/Tools)

/Tools

This folder contains the source code for various C-program that were used to help develop the game, such as file format converters for maps.

They read and write a number of file formats:

  • .MTB - Possible Map Table?
  • .MAP - Game Map (Track?) data
  • .TBL - Possible Table data?
  • .SCR - Screen data
  • .SLT - Slit data
  • .OBJ - Sprite character data
  • .CHR - Character data
  • .CGX - 8-bit character data
  • .PCK - Panel Check File
  • .PNL - Panel Data file
  • .WTB - World Table?

The files in this folder are described in the table below:

File Name Extension Description
armap .c Map data archiver, seems to read a .MTB file and exports a .MAP file
carmap .c Map data generator, seems to read a .TBL and .SCR file and exports a .MAP file
chrar .c Character data archiver, takes in a table (.TBL?) and CHR files and exports a ?
cmpbuf .s Assembly source file containing an efficient buffer comparison routine
cmppnl .s Assembly source file containing an implementation of a function int cmppnl( char* pnlbuf, char* panel, int pnlcnt ) , compare panels?
enemy .c OBJ character data archiver, takes in a .TBL and writes to a .CHR file
mkback .c Back screen data compress
mkbgchr .c Convert 8bit mode file into screen mode 7 file, takes in a .CGX file and exports to a .CHR file
mkenemy .c Enemy car character data archiver takes in a .TBL and exports to a .CHR file
mkmap .c Map data generator takes in .PCK and .WTB files and exports to SLT and WLD files
mkpanel .c Map panel data generator takes in a .TBL and generates a .PCK and .PNL file
mkpers .c Demo pers data compress
mkrival .c Rival car character data archiver, reads a .TBL file and exports a .CHR file
mkselect .c Car select screen data compress
mkspchr .c OBJ character data compress takes in OBJ and CHR files and creates a OBJECT.CHR file
schpnl .s Assembly source file containing implementation for int schpnl(char* pnlofs, char* pnlbuf, char* panel, int pnlcnt )
setbomb .c Set bomb data takes in a slit address and a Panel data file (.PNL), Map (.WLD) and a slit data file (.SLT)
slitpress .c Slit data compress takes in .SLT and compresses to .SLT2
Code Files

armap.c

  • unshort pointer[32]
  • unshort length[32]
  • int counter
  • int address
  • int datasize
  • main(int argc, char* argv)
  • set_mapname(char* ss)
  • archive(char* fname, FILE wp)
  • save_pointer(char* fname)
4
7
136

carmap.c

  • arptr sltptr[MAXSLT]
  • unchar pnlbuf[MAXPNL][4]
  • unshort sltbuf[MAXSLT][16]
  • unshort rombuf[MAXROM][16]
  • unshort wldbuf[WLDLNY][WLDLNX]
  • unshort sltofs[MAXSLT]
  • int pnlcnt
  • int sltcnt
  • int romcnt
  • int wldcnt
  • int sltlen
  • int clrcode
  • main(int argc, char* argv)
  • set_sname(char* ss)
  • makemap(int nn, char fname)
  • chkclr(unchar *buf)
  • setpnl(unchar *pnl)
  • setslt(unshort *slt)
  • setroom(unshort *rom)
  • setwld(unshort wld)
  • memcmp(register unchar *s1, register unchar *s2, register intnn)
  • memcpy(register unchar *dd, register unchar *ss, register int)
  • arslit()
  • fit_slit(int ln, int sc)
  • int_slpt()
  • st_slofs()
  • genmap(char *fname)
  • genpnl(FILE *wp, int ad)
  • genslt(FILE *wp, int ad)
  • genrom(FILE *wp, int ad)
  • genwld(FILE *wp, int ad)
19
20
500

chrar.c

  • int chrlen[6]
  • int chralc[6][40]
  • char chrbuf[DSIZE][32]
  • main(int argc, char* argv)
  • archive(int mo,FILE *tp, FILE *wp)
  • flip(unchar *dat, *buf, int len)
  • getnum(FILE *fp)
  • readchar(int argc,char **argv, buf)
5
7
156

enemy.c

  • struct patndata pat[12]
  • short patn00[24]
  • short patn01[20]
  • short patn02[12]
  • short patn03[9]
  • short patn04[6]
  • short patn05[4]
  • short patn06[2]
  • short patn07[1]
  • short patn08[12]
  • short patn09[6]
  • short patn10[4]
  • short patn11[2]
  • unchar chrbuf[DSIZE][32]
  • int chrcnt
  • int total
  • main(int argc, char* argv)
  • init_ptr()
  • set_cname(char* ss)
  • archive(FILE *wp, char dat)
  • getnum(char* dat)
  • readchar(char* fname)
6
18
221

mkback.c

  • int bincnt
  • int norcnt
  • int comcnt2
  • int comcnt3
  • int nulcnt
  • main(int argc, char * argv)
  • void make_data(FILE *rp,*wp)
  • write_data(int code, int cnt, FILE wp)
3
7
127

mkbgchr.c

  • unchar chrdat[DATSIZE]
  • unchar chrbuf[BUFSIZE]
  • main(int argc, char * argv)
  • chread(char *fname,*buff, int size)
  • chwrite(char *fname,*buff, int size)
  • convert(unchar *data,int size)
  • archive(unchar *data,*buff,int size)
  • getbnk(unchar *data)
6
7
150

mkenemy.c

  • struct patndata pat[10]
  • short patn00[24]
  • short patn01[15]
  • short patn02[12]
  • short patn03[6]
  • short patn04[4]
  • short patn05[1]
  • short patn06[12]
  • short patn07[6]
  • short patn08[2]
  • short patn09[9]
  • unchar chrbuf[DSIZE][32]
  • int chrcnt
  • int total
  • main(int argc, char* argv)
  • init_ptr()
  • set_cname(char* ss)
  • archive(FILE *wp, char dat)
  • getnum(char* dat)char *dat
  • readchar(char* fname)
6
16
212

mkmap.c

  • arptr sltptr[MAXSLT]
  • unshort sltofs[MAXSLT]
  • unshort pnlofs[MAXPNL]
  • unchar pnlbuf[MAXPNL *4]
  • unshort sltbuf[MAXSLT][16]
  • unshort rombuf[MAXROM][16]
  • unshort wldbuf[WLDLNY][WLDLNX]
  • int pnlcnt
  • int sltcnt
  • int romcnt
  • int wldcnt
  • int pnllen
  • int sltlen
  • int errcnt
  • int slttop
  • int clrcode
  • main(int argc, char* argv)
  • set_sname(char* ss)
  • int getaddr(char* str)
  • readpnl(char* fname)
  • makemap(int nn, char fname)
  • chkclr(unchar *buf)
  • chkpnl(unchar *pnl)
  • setslt(unshort *slt)
  • setroom(unshort *rom)
  • setwld(unshort wld)
  • prsslt()
  • fit_slit(int ln, int sc)
  • int_slpt()
  • st_slofs()
  • genmap(char* wld_name, char* slt_name)
  • genslt(FILE *wp)
  • genrom(FILE *wp)
  • genwld(FILE *wp)
18
18
475

mkpanel.c

  • arptr pnlptr[MAXPNL]
  • unshort pnlofs[MAXPNL]
  • unchar pnlbuf[MAXPNL][4]
  • int pnllen
  • int pnlcnt
  • int clrcode
  • main(int argc, char* argv)
  • set_sname(char* ss)
  • mkpanel(int nn, char fname)
  • chkclr(unchar *buf)
  • setpnl(unchar *pnl)
  • prspnl()
  • fit_panel(int ln, int sc)
  • int_pnpt()
  • st_pnofs()
  • genpck(char *fname)
  • genpnl(char *fname)
11
8
325

mkpers.c

  • int bincnt
  • main(int argc, char* argv)
  • void make_data(FILE *rp,*wp)
  • fgetnum(unshort *num, FILE rp)
  • fputnum(int num, FILE wp)
4
4
98

mkrival.c

  • struct patndata pat[10]
  • short patn00[24]
  • short patn01[15]
  • short patn02[12]
  • short patn03[6]
  • short patn04[4]
  • short patn05[1]
  • short patn06[12]
  • short patn07[6]
  • short patn08[2]
  • short patn09[9]
  • unchar chrbuf[DSIZE][32]
  • int chrcnt
  • int total
  • main(int argc, char * argv)
  • init_ptr()
  • set_cname(char* ss)
  • archive(FILE *wp, char dat)
  • getnum(dat)char *dat
  • readchar(fname)char *fname
6
16
209

mkselect.c

  • int bincnt
  • int norcnt
  • int chrcnt
  • int atrcnt
  • main(argc,argv)int argc
  • char * argv
  • void make_data(FILE *rp,*wp)
  • int write_char(FILE *wp, int len)
  • int write_attr(FILE *wp, int len, unchar buf)
4
8
120

mkspchr.c

  • struct data header[34]
  • unchar chrbuf[DSIZE][32]
  • int chrcnt
  • int bincnt
  • main(int argc, char* argv)
  • void make_data(FILE *fp)
  • int make1(FILE *fp, int code, int cnum, int leng)
  • int make2(FILE *fp,int code, int cnum, int leng)
  • int make3(FILE *fp, int code,int cnum, int leng)
  • int make4(FILE *fp, int code,int cnum, int leng)
  • int wthalf(char *buff, FILE fp)
  • int read_char(char* fname, int code, int size)
8
11
234

setbomb.c

  • unchar pnlbuf[MAXPNL]
  • unchar sltbuf[MAXSLT]
  • unchar wldbuf[MAXWLD]
  • unchar rombuf[MAXROM]
  • struct STACK bomb[MAXBOMB]
  • int bombct
  • int romcnt
  • int romptr
  • int sltptr
  • int pnlptr
  • int sltofs
  • main(int argc, char* argv)
  • set_bomb()
  • push_pos()
  • search(int loc_x, int loc_y)
  • sch_room(int loc_x, int loc_y)
  • int getaddr(char *str)
  • readpnl(char *fname)
  • readwld(char *fname)
  • readslt(char *fname)
  • makewld(char *fname)
10
12
291

slitpress.c

  • main(int argc, char* argv)
  • void press_slit(FILE *rp, FILE *wp)
  • void fputw(int data, FILE fp)
  • int fgetw(FILE *fp)
4
2
97