-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ae97720
Showing
78 changed files
with
223,766 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# folders | ||
asm/ | ||
assets/ | ||
build/ | ||
expected/ | ||
junk/ | ||
__pycache__/ | ||
|
||
# files | ||
*.ld | ||
*.ok | ||
*auto.txt | ||
*.z64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[submodule "tools/splat"] | ||
path = tools/splat | ||
url = https://github.com/ethteck/splat.git | ||
[submodule "tools/asm-processor"] | ||
path = tools/asm-processor | ||
url = https://github.com/simonlindholm/asm-processor.git | ||
[submodule "tools/asm-differ"] | ||
path = tools/asm-differ | ||
url = https://github.com/simonlindholm/asm-differ.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
BASENAME = quest64 | ||
VERSION := us | ||
|
||
BUILD_DIR = build | ||
ASM_DIRS = asm | ||
BIN_DIRS = assets | ||
SRC_DIR = src | ||
|
||
SRC_DIRS = $(SRC_DIR) | ||
|
||
TOOLS_DIR := tools | ||
|
||
S_FILES = $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s)) | ||
C_FILES = $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) | ||
# H_FILES = $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) | ||
BIN_FILES = $(foreach dir,$(BIN_DIRS),$(wildcard $(dir)/*.bin)) | ||
|
||
O_FILES := $(foreach file,$(S_FILES),$(BUILD_DIR)/$(file).o) \ | ||
$(foreach file,$(C_FILES),$(BUILD_DIR)/$(file).o) \ | ||
$(foreach file,$(BIN_FILES),$(BUILD_DIR)/$(file).o) | ||
|
||
|
||
TARGET = $(BUILD_DIR)/$(BASENAME).$(VERSION) | ||
LD_SCRIPT = $(BASENAME).ld | ||
|
||
CROSS = mips-linux-gnu- | ||
AS = $(CROSS)as | ||
CPP = cpp | ||
LD = $(CROSS)ld | ||
OBJDUMP = $(CROSS)objdump | ||
OBJCOPY = $(CROSS)objcopy | ||
PYTHON = python3 | ||
|
||
OBJCOPYFLAGS = -O binary | ||
|
||
|
||
CC := $(TOOLS_DIR)/ido5.3_recomp/cc | ||
|
||
OPT_FLAGS := -O2 -g3 | ||
MIPSISET := -mips2 -o32 | ||
|
||
INCLUDE_CFLAGS := -I . -I include -I include/2.0I -I include/2.0I/PR | ||
|
||
ASFLAGS = -EB -mtune=vr4300 -march=vr4300 -mabi=32 -I include | ||
|
||
# Files requiring pre/post-processing | ||
GREP := grep -rl | ||
GLOBAL_ASM_C_FILES := $(shell $(GREP) GLOBAL_ASM $(SRC_DIR) </dev/null 2>/dev/null) | ||
GLOBAL_ASM_O_FILES := $(foreach file,$(GLOBAL_ASM_C_FILES),$(BUILD_DIR)/$(file).o) | ||
|
||
|
||
CFLAGS := -G 0 -Xfullwarn -Xcpluscomm -signed -nostdinc -non_shared -Wab,-r4300_mul | ||
CFLAGS += -D_LANGUAGE_C -D_FINALROM -DF3DEX_GBI -DWIN32 | ||
# ignore compiler warnings about anonymous structs | ||
CFLAGS += -woff 649,838 | ||
CFLAGS += $(INCLUDE_CFLAGS) | ||
|
||
ifeq ($(VERSION),us) | ||
CFLAGS += -DVERSION_US | ||
endif | ||
ifeq ($(VERSION),eu) | ||
CFLAGS += -DVERSION_EU | ||
endif | ||
|
||
LDFLAGS = -T $(LD_SCRIPT) -Map $(TARGET).map -T undefined_syms_auto.txt -T undefined_funcs_auto.txt -T undefined_syms.$(VERSION).txt --no-check-sections | ||
|
||
|
||
ASM_PROCESSOR_DIR := $(TOOLS_DIR)/asm-processor | ||
|
||
### Optimisation Overrides | ||
|
||
### Targets | ||
|
||
default: all | ||
|
||
all: dirs $(TARGET).z64 verify | ||
|
||
dirs: | ||
$(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(BIN_DIRS),$(shell mkdir -p $(BUILD_DIR)/$(dir))) | ||
|
||
check: .baserom.$(VERSION).ok | ||
|
||
verify: $(TARGET).z64 | ||
@echo "$$(cat $(BASENAME).$(VERSION).sha1) $(TARGET).z64" | sha1sum --check | ||
|
||
extract: check | ||
$(PYTHON) $(TOOLS_DIR)/splat/split.py $(BASENAME).$(VERSION).yaml | ||
|
||
clean: | ||
rm -rf asm | ||
rm -rf assets | ||
rm -rf build | ||
rm -f *auto.txt | ||
|
||
### Recipes | ||
|
||
.baserom.$(VERSION).ok: baserom.$(VERSION).z64 | ||
@echo "$$(cat $(BASENAME).$(VERSION).sha1) $<" | sha1sum --check | ||
@touch $@ | ||
|
||
$(TARGET).elf: $(O_FILES) $(LANG_O_FILES) | ||
@$(LD) $(LDFLAGS) -o $@ | ||
|
||
ifndef PERMUTER | ||
$(GLOBAL_ASM_O_FILES): $(BUILD_DIR)/%.c.o: %.c | ||
$(PYTHON) $(ASM_PROCESSOR_DIR)/asm_processor.py $(OPT_FLAGS) $< > $(BUILD_DIR)/$< | ||
$(CC) -c -32 $(CFLAGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $(BUILD_DIR)/$< | ||
$(PYTHON) $(ASM_PROCESSOR_DIR)/asm_processor.py $(OPT_FLAGS) $< --post-process $@ \ | ||
--assembler "$(AS) $(ASFLAGS)" --asm-prelude $(ASM_PROCESSOR_DIR)/prelude.s | ||
endif | ||
|
||
# non asm-processor recipe | ||
$(BUILD_DIR)/%.c.o: %.c | ||
$(CC) -c $(CFLAGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $< | ||
|
||
$(BUILD_DIR)/%.s.o: %.s | ||
$(AS) $(ASFLAGS) -o $@ $< | ||
|
||
$(BUILD_DIR)/%.bin.o: %.bin | ||
$(LD) -r -b binary -o $@ $< | ||
|
||
$(TARGET).bin: $(TARGET).elf | ||
$(OBJCOPY) $(OBJCOPYFLAGS) $< $@ | ||
|
||
$(TARGET).z64: $(TARGET).bin | ||
@cp $< $@ | ||
|
||
### Settings | ||
.SECONDARY: | ||
.PHONY: all clean default | ||
SHELL = /bin/bash -e -o pipefail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Quest 64 Decompilation | ||
|
||
Clone with `--recursive` flag. | ||
|
||
Drop the US ROM into the base of this repo, name it `baserom.us.z64` | ||
|
||
`make extract && make` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
|
||
def apply(config, args): | ||
basename = 'quest64' | ||
if os.path.exists(f'build/{basename}.us.bin'): | ||
version = 'us' | ||
elif os.path.exists(f'build/{basename}.eu.bin'): | ||
version = 'eu' | ||
else: | ||
version = 'us' | ||
|
||
config['baseimg'] = f'baserom.{version}.bin' | ||
config['myimg'] = f'build/{basename}.{version}.bin' | ||
config['mapfile'] = f'build/{basename}.{version}.map' | ||
config['source_directories'] = ['src', 'include'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/************************************************************************** | ||
* | ||
* $Revision: 1.4 $ | ||
* $Date: 1997/11/26 00:30:50 $ | ||
* $Source: /disk6/Master/cvsmdev2/PR/include/PRimage.h,v $ | ||
* | ||
**************************************************************************/ | ||
|
||
#ifndef __GL_IMAGE_H__ | ||
#define __GL_IMAGE_H__ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
|
||
/* | ||
* Defines for image files . . . . | ||
* | ||
* Paul Haeberli - 1984 | ||
* Look in /usr/people/4Dgifts/iristools/imgtools for example code! | ||
* | ||
*/ | ||
|
||
|
||
#define IMAGIC 0732 | ||
|
||
/* colormap of images */ | ||
#define CM_NORMAL 0 /* file contains rows of values which | ||
* are either RGB values (zsize == 3) | ||
* or greyramp values (zsize == 1) */ | ||
#define CM_DITHERED 1 | ||
#define CM_SCREEN 2 /* file contains data which is a screen | ||
* image; getrow returns buffer which | ||
* can be displayed directly with | ||
* writepixels */ | ||
#define CM_COLORMAP 3 /* a colormap file */ | ||
|
||
#define TYPEMASK 0xff00 | ||
#define BPPMASK 0x00ff | ||
#define ITYPE_VERBATIM 0x0000 | ||
#define ITYPE_RLE 0x0100 | ||
#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE) | ||
#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM) | ||
#define BPP(type) ((type) & BPPMASK) | ||
#define RLE(bpp) (ITYPE_RLE | (bpp)) | ||
#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) | ||
#define IBUFSIZE(pixels) (((pixels)+((pixels)>>6))<<2) | ||
#define RLE_NOP 0x00 | ||
|
||
#define ierror(p) (((p)->flags&_IOERR)!=0) | ||
#define ifileno(p) ((p)->file) | ||
#define getpix(p) (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p)) | ||
#define putpix(p,x) (--(p)->cnt>=0 \ | ||
? ((int)(*(p)->ptr++=(unsigned)(x))) \ | ||
: iflsbuf(p,(unsigned)(x))) | ||
|
||
typedef struct { | ||
unsigned short imagic; /* stuff saved on disk . . */ | ||
unsigned short type; | ||
unsigned short dim; | ||
unsigned short xsize; | ||
unsigned short ysize; | ||
unsigned short zsize; | ||
unsigned long min; | ||
unsigned long max; | ||
unsigned long wastebytes; | ||
char name[80]; | ||
unsigned long colormap; | ||
|
||
long file; /* stuff used in core only */ | ||
unsigned short flags; | ||
short dorev; | ||
short x; | ||
short y; | ||
short z; | ||
short cnt; | ||
unsigned short *ptr; | ||
unsigned short *base; | ||
unsigned short *tmpbuf; | ||
unsigned long offset; | ||
unsigned long rleend; /* for rle images */ | ||
unsigned long *rowstart; /* for rle images */ | ||
long *rowsize; /* for rle images */ | ||
} IMAGE; | ||
|
||
IMAGE *icreate(); | ||
/* | ||
* IMAGE *iopen(char *file, char *mode, unsigned int type, unsigned int dim, | ||
* unsigned int xsize, unsigned int ysize, unsigned int zsize); | ||
* IMAGE *fiopen(int f, char *mode, unsigned int type, unsigned int dim, | ||
* unsigned int xsize, unsigned int ysize, unsigned int zsize); | ||
* | ||
* ...while iopen and fiopen can take an extended set of parameters, the | ||
* last five are optional, so a more correct prototype would be: | ||
* | ||
*/ | ||
IMAGE *iopen(char *file, char *mode, ...); | ||
IMAGE *fiopen(int f, char *mode, ...); | ||
|
||
/* | ||
* | ||
* unsigned short *ibufalloc(IMAGE *image); | ||
* int ifilbuf(IMAGE *image); | ||
* int iflush(IMAGE *image); | ||
* unsigned int iflsbuf(IMAGE *image, unsigned int c); | ||
* void isetname(IMAGE *image, char *name); | ||
* void isetcolormap(IMAGE *image, int colormap); | ||
*/ | ||
|
||
int iclose(IMAGE *image); | ||
int putrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); | ||
int getrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); | ||
|
||
/* | ||
IMAGE *iopen(); | ||
IMAGE *icreate(); | ||
*/ | ||
|
||
unsigned short *ibufalloc(); | ||
|
||
#define IMAGEDEF /* for backwards compatibility */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !__GL_IMAGE_H__ */ |
Oops, something went wrong.