Browse Source

initial commit

puppycam
Cadey Ratio 11 months ago
commit
880e8a953e
  1. 18
      .clang-format
  2. 6
      .clang-tidy
  3. 23
      .gitattributes
  4. 73
      .gitignore
  5. 2482
      Doxyfile
  6. 35
      Jenkinsfile
  7. 716
      Makefile
  8. 248
      Makefile.split
  9. 115
      README.md
  10. 54
      actors/amp/anims/anim_0800401C.inc.c
  11. 1
      actors/amp/anims/data.inc.c
  12. 4
      actors/amp/anims/table.inc.c
  13. 56
      actors/amp/geo.inc.c
  14. 530
      actors/amp/model.inc.c
  15. 36
      actors/bird/anims/anim_050008D0.inc.c
  16. 36
      actors/bird/anims/anim_050009D0.inc.c
  17. 2
      actors/bird/anims/data.inc.c
  18. 5
      actors/bird/anims/table.inc.c
  19. 25
      actors/bird/geo.inc.c
  20. 215
      actors/bird/model.inc.c
  21. 48
      actors/blargg/anims/anim_05006070.inc.c
  22. 34
      actors/blargg/anims/anim_05006154.inc.c
  23. 2
      actors/blargg/anims/data.inc.c
  24. 7
      actors/blargg/anims/table.inc.c
  25. 20
      actors/blargg/geo.inc.c
  26. 507
      actors/blargg/model.inc.c
  27. 29
      actors/blue_coin_switch/collision.inc.c
  28. 10
      actors/blue_coin_switch/geo.inc.c
  29. 92
      actors/blue_coin_switch/model.inc.c
  30. 35
      actors/blue_fish/anims/anim_0301C298.inc.c
  31. 1
      actors/blue_fish/anims/data.inc.c
  32. 5
      actors/blue_fish/anims/table.inc.c
  33. 32
      actors/blue_fish/geo.inc.c
  34. 116
      actors/blue_fish/model.inc.c
  35. 68
      actors/bobomb/anims/anim_080237FC.inc.c
  36. 43
      actors/bobomb/anims/anim_08023954.inc.c
  37. 2
      actors/bobomb/anims/data.inc.c
  38. 6
      actors/bobomb/anims/table.inc.c
  39. 99
      actors/bobomb/geo.inc.c
  40. 341
      actors/bobomb/model.inc.c
  41. 15
      actors/bomb/geo.inc.c
  42. 214
      actors/bomb/model.inc.c
  43. 17
      actors/boo/geo.inc.c
  44. 355
      actors/boo/model.inc.c
  45. 17
      actors/boo_castle/geo.inc.c
  46. 355
      actors/boo_castle/model.inc.c
  47. 8
      actors/book/geo.inc.c
  48. 94
      actors/book/model.inc.c
  49. 32
      actors/bookend/anims/anim_050023F4.inc.c
  50. 40
      actors/bookend/anims/anim_05002510.inc.c
  51. 12
      actors/bookend/anims/anim_05002528.inc.c
  52. 3
      actors/bookend/anims/data.inc.c
  53. 7
      actors/bookend/anims/table.inc.c
  54. 29
      actors/bookend/geo.inc.c
  55. 434
      actors/bookend/model.inc.c
  56. 27
      actors/bowling_ball/geo.inc.c
  57. 269
      actors/bowser/anims/anim_060445EC.inc.c
  58. 251
      actors/bowser/anims/anim_060453C8.inc.c
  59. 179
      actors/bowser/anims/anim_06045D28.inc.c
  60. 188
      actors/bowser/anims/anim_0604671C.inc.c
  61. 22
      actors/bowser/anims/anim_0604675C.inc.c
  62. 455
      actors/bowser/anims/anim_06048200.inc.c
  63. 389
      actors/bowser/anims/anim_06049880.inc.c
  64. 291
      actors/bowser/anims/anim_0604A8E4.inc.c
  65. 166
      actors/bowser/anims/anim_0604B178.inc.c
  66. 146
      actors/bowser/anims/anim_0604B8CC.inc.c
  67. 425
      actors/bowser/anims/anim_0604D184.inc.c
  68. 351
      actors/bowser/anims/anim_0604E5A0.inc.c
  69. 198
      actors/bowser/anims/anim_0604F030.inc.c
  70. 271
      actors/bowser/anims/anim_0604FF4C.inc.c
  71. 123
      actors/bowser/anims/anim_06050530.inc.c
  72. 281
      actors/bowser/anims/anim_060514E8.inc.c
  73. 149
      actors/bowser/anims/anim_06051C68.inc.c
  74. 191
      actors/bowser/anims/anim_06052680.inc.c
  75. 142
      actors/bowser/anims/anim_06052D94.inc.c
  76. 147
      actors/bowser/anims/anim_060534F4.inc.c
  77. 135
      actors/bowser/anims/anim_06053B8C.inc.c
  78. 141
      actors/bowser/anims/anim_06054290.inc.c
  79. 137
      actors/bowser/anims/anim_06054950.inc.c
  80. 169
      actors/bowser/anims/anim_06055210.inc.c
  81. 148
      actors/bowser/anims/anim_06055984.inc.c
  82. 252
      actors/bowser/anims/anim_06056774.inc.c
  83. 269
      actors/bowser/anims/anim_06057678.inc.c
  84. 27
      actors/bowser/anims/data.inc.c
  85. 30
      actors/bowser/anims/table.inc.c
  86. 96
      actors/bowser/flames_pos.inc.c
  87. 423
      actors/bowser/geo.inc.c
  88. 4157
      actors/bowser/model.inc.c
  89. 24
      actors/bowser_flame/geo.inc.c
  90. 283
      actors/bowser_flame/model.inc.c
  91. 128
      actors/bowser_key/anims/anim_course_exit.inc.c
  92. 128
      actors/bowser_key/anims/anim_unlock_door.inc.c
  93. 2
      actors/bowser_key/anims/data.inc.c
  94. 5
      actors/bowser_key/anims/table.inc.c
  95. 31
      actors/bowser_key/geo.inc.c
  96. 294
      actors/bowser_key/model.inc.c
  97. 34
      actors/breakable_box/collision.inc.c
  98. 28
      actors/breakable_box/geo.inc.c
  99. 102
      actors/breakable_box/model.inc.c
  100. 73
      actors/bub/anims/anim_0601233C.inc.c

18
.clang-format

@ -0,0 +1,18 @@
IndentWidth: 4
Language: Cpp
AlignAfterOpenBracket: Align
SortIncludes: false
ColumnLimit: 104
PointerAlignment: Right
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
BinPackArguments: true
BinPackParameters: true
SpaceAfterCStyleCast: true
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: NonAssignment
Cpp11BracedListStyle: false
IndentCaseLabels: true
AlignTrailingComments: true
UseTab: Never

6
.clang-tidy

@ -0,0 +1,6 @@
---
Checks: '-*,readability-braces-around-statements'
WarningsAsErrors: ''
HeaderFilterRegex: '(src|include|enhancements)\/.*\.h$'
FormatStyle: 'file'
CheckOptions:

23
.gitattributes

@ -0,0 +1,23 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# List text files in case git doesn't characterize correctly
*.c text
*.h text
*.s text
*.in text
*.js text
*.md text
*.py text
*.sh text
*.ld text
*.inc text
*.txt text
*.json text
*.yaml text
# Same for binary
*.bin binary
*.m64 binary
*.png binary
*.aiff binary

73
.gitignore

@ -0,0 +1,73 @@
# Object files
*.o
*.obj
*.elf
# Linker output
*.ilk
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# datadump
/tools/ddump/*
# Text editor remnants
*.swp
.vscode/*
# General project-specific ignores
doxygen/doxygen/*
build/*
*.dump
*.mio0
*.z64
*.map
.assets-local.txt
sm64_save_file.bin
sm64config.txt
# Assets. Generally ignored, but ones with "custom" in the name are fine.
/levels/**/*.png
/actors/**/*.png
/textures/**/*.png
/assets/**/*.bin
/sound/**/*.m64
/sound/**/*.aiff
!/levels/**/*custom*.png
!/levels/**/*custom*/**/*.png
!/actors/**/*custom*.png
!/actors/**/*custom*/**/*.png
!/textures/**/*custom*.png
!/textures/**/*custom*/**/*.png
!/sound/**/*custom*.m64
!/sound/**/*custom*/**/*.m64
!/sound/**/*custom*.aiff
!/sound/**/*custom*/**/*.aiff
!/assets/**/*custom*.bin
!/assets/**/*custom*/**/*.bin

2482
Doxyfile
File diff suppressed because it is too large
View File

35
Jenkinsfile

@ -0,0 +1,35 @@
pipeline {
agent any
stages {
stage('Build Tools') {
steps {
sh 'make -j4 -C tools/'
}
}
stage('Extract Assets') {
steps {
sh 'ln -s "$ROMS_DIR/Super Mario 64 (J) [!].z64" baserom.jp.z64'
sh 'ln -s "$ROMS_DIR/Super Mario 64 (U) [!].z64" baserom.us.z64'
sh 'ln -s "$ROMS_DIR/Super Mario 64 (E) (M3) [!].z64" baserom.eu.z64'
// verify no assets were committed to repo
sh '[ -z "$(find {actors,levels,textures}/ -name \'*.png\')" ]'
sh '[ -z "$(find assets/ -name \'*.m64\' -or \'*.bin\')" ]'
sh './extract_assets.py jp us eu'
}
}
stage('Build J Source') {
steps {
sh 'make -j4 VERSION=jp'
}
}
stage('Build U Source') {
steps {
sh 'make -j4 VERSION=us'
}
}
}
environment {
QEMU_IRIX = credentials('qemu-irix')
ROMS_DIR = credentials('roms')
}
}

716
Makefile

@ -0,0 +1,716 @@
# Makefile to rebuild SM64 split image
### Default target ###
default: all
### Build Options ###
# These options can either be changed by modifying the makefile, or
# by building with 'make SETTING=value'. 'make clean' may be required.
# Version of the game to build
VERSION ?= us
# Graphics microcode used
GRUCODE ?= f3d_old
# If COMPARE is 1, check the output sha1sum when building 'all'
COMPARE ?= 1
# If NON_MATCHING is 1, define the NON_MATCHING and AVOID_UB macros when building (recommended)
NON_MATCHING ?= 0
# Build for the N64 (turn this off for ports)
TARGET_N64 ?= 0
# Build for Emscripten/WebGL
TARGET_WEB ?= 0
# Automatic settings only for ports
ifeq ($(TARGET_N64),0)
NON_MATCHING := 1
GRUCODE := f3dex2e
WINDOWS_BUILD := 0
ifeq ($(TARGET_WEB),0)
ifeq ($(OS),Windows_NT)
WINDOWS_BUILD := 1
endif
endif
endif
# Release
ifeq ($(VERSION),jp)
VERSION_CFLAGS := -DVERSION_JP
VERSION_ASFLAGS := --defsym VERSION_JP=1
GRUCODE_CFLAGS := -DF3D_OLD
GRUCODE_ASFLAGS := --defsym F3D_OLD=1
TARGET := sm64.jp
else
ifeq ($(VERSION),us)
VERSION_CFLAGS := -DVERSION_US
VERSION_ASFLAGS := --defsym VERSION_US=1
GRUCODE_CFLAGS := -DF3D_OLD
GRUCODE_ASFLAGS := --defsym F3D_OLD=1
TARGET := sm64.us
else
ifeq ($(VERSION),eu)
$(warning Building EU is experimental and is prone to breaking. Try at your own risk.)
VERSION_CFLAGS := -DVERSION_EU
VERSION_ASFLAGS := --defsym VERSION_EU=1
GRUCODE_CFLAGS := -DF3D_NEW
GRUCODE_ASFLAGS := --defsym F3D_NEW=1
TARGET := sm64.eu
else
$(error unknown version "$(VERSION)")
endif
endif
endif
# Microcode
ifeq ($(GRUCODE),f3dex) # Fast3DEX
GRUCODE_CFLAGS := -DF3DEX_GBI
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI=1
TARGET := $(TARGET).f3dex
COMPARE := 0
else
ifeq ($(GRUCODE), f3dex2) # Fast3DEX2
GRUCODE_CFLAGS := -DF3DEX_GBI_2
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI_2=1
TARGET := $(TARGET).f3dex2
COMPARE := 0
else
ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (for PC)
GRUCODE_CFLAGS := -DF3DEX_GBI_2E
TARGET := $(TARGET).f3dex2e
COMPARE := 0
else
ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H (Shindou)
GRUCODE_CFLAGS := -DF3D_NEW
GRUCODE_ASFLAGS := --defsym F3D_NEW=1
TARGET := $(TARGET).f3d_new
COMPARE := 0
else
ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori)
$(warning Fast3DZEX is experimental. Try at your own risk.)
GRUCODE_CFLAGS := -DF3DEX_GBI_2
GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DZEX_GBI=1
TARGET := $(TARGET).f3dzex
COMPARE := 0
endif
endif
endif
endif
endif
ifeq ($(NON_MATCHING),1)
VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB
COMPARE := 0
endif
ifeq ($(TARGET_WEB),1)
VERSION_CFLAGS := $(VERSION_CFLAGS) -DTARGET_WEB
endif
################### Universal Dependencies ###################
# (This is a bit hacky, but a lot of rules implicitly depend
# on tools and assets, and we use directory globs further down
# in the makefile that we want should cover assets.)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
# Make sure assets exist
NOEXTRACT ?= 0
ifeq ($(NOEXTRACT),0)
DUMMY != ./extract_assets.py $(VERSION) >&2 || echo FAIL
ifeq ($(DUMMY),FAIL)
$(error Failed to extract assets)
endif
endif
# Make tools if out of date
DUMMY != make -s -C tools >&2 || echo FAIL
ifeq ($(DUMMY),FAIL)
$(error Failed to build tools)
endif
endif
endif
################ Target Executable and Sources ###############
# BUILD_DIR is location where all build artifacts are placed
BUILD_DIR_BASE := build
ifeq ($(TARGET_N64),1)
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)
else
ifeq ($(TARGET_WEB),1)
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_web
else
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_pc
endif
endif
LIBULTRA := $(BUILD_DIR)/libultra.a
ifeq ($(TARGET_WEB),1)
EXE := $(BUILD_DIR)/$(TARGET).html
else
ifeq ($(WINDOWS_BUILD),1)
EXE := $(BUILD_DIR)/$(TARGET).exe
else
EXE := $(BUILD_DIR)/$(TARGET)
endif
endif
ROM := $(BUILD_DIR)/$(TARGET).z64
ELF := $(BUILD_DIR)/$(TARGET).elf
LD_SCRIPT := sm64.ld
MIO0_DIR := $(BUILD_DIR)/bin
SOUND_BIN_DIR := $(BUILD_DIR)/sound
TEXTURE_DIR := textures
ACTOR_DIR := actors
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
# Directories containing source files
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets
ASM_DIRS := lib
ifeq ($(TARGET_N64),1)
ASM_DIRS := asm $(ASM_DIRS)
else
SRC_DIRS := $(SRC_DIRS) src/pc src/pc/gfx src/pc/audio src/pc/controller
ASM_DIRS :=
endif
BIN_DIRS := bin bin/$(VERSION)
ULTRA_SRC_DIRS := lib/src lib/src/math
ULTRA_ASM_DIRS := lib/asm lib/data
ULTRA_BIN_DIRS := lib/bin
GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists
MIPSISET := -mips2 -32
ifeq ($(VERSION),eu)
OPT_FLAGS := -O2
else
OPT_FLAGS := -g -m32
endif
ifeq ($(TARGET_WEB),1)
OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/
endif
# File dependencies and variables for specific files
include Makefile.split
# Source code files
LEVEL_C_FILES := $(wildcard levels/*/leveldata.c) $(wildcard levels/*/script.c) $(wildcard levels/*/geo.c)
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C_FILES)
CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
ULTRA_C_FILES := $(foreach dir,$(ULTRA_SRC_DIRS),$(wildcard $(dir)/*.c))
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
ifeq ($(TARGET_N64),1)
ULTRA_S_FILES := $(foreach dir,$(ULTRA_ASM_DIRS),$(wildcard $(dir)/*.s))
endif
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c \
$(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png)))))
ifeq ($(WINDOWS_BUILD),0)
CXX_FILES :=
endif
ifneq ($(TARGET_N64),1)
ULTRA_C_FILES_SKIP := \
sqrtf.c \
string.c \
sprintf.c \
_Printf.c \
kdebugserver.c \
osInitialize.c \
osCreateThread.c \
osDestroyThread.c \
osStartThread.c \
osSetThreadPri.c \
osPiStartDma.c \
osPiRawStartDma.c \
osPiRawReadIo.c \
osPiGetCmdQueue.c \
osJamMesg.c \
osSendMesg.c \
osRecvMesg.c \
osSetEventMesg.c \
osTimer.c \
osSetTimer.c \
osSetTime.c \
osCreateViManager.c \
osViSetSpecialFeatures.c \
osVirtualToPhysical.c \
osViBlack.c \
osViSetEvent.c \
osViSetMode.c \
osViSwapBuffer.c \
osSpTaskLoadGo.c \
osCreatePiManager.c \
osGetTime.c \
osEepromProbe.c \
osEepromWrite.c \
osEepromLongWrite.c \
osEepromRead.c \
osEepromLongRead.c \
osContInit.c \
osContStartReadData.c \
osAiGetLength.c \
osAiSetFrequency.c \
osAiSetNextBuffer.c \
__osViInit.c \
__osSyncPutChars.c \
__osAtomicDec.c \
__osSiRawStartDma.c \
__osViSwapContext.c \
__osViGetCurrentContext.c
C_FILES := $(filter-out src/game/main.c,$(C_FILES))
ULTRA_C_FILES := $(filter-out $(addprefix lib/src/,$(ULTRA_C_FILES_SKIP)),$(ULTRA_C_FILES))
endif
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/$(VERSION)/*.m64) \
$(wildcard sound/sequences/*.m64) \
$(foreach file,$(wildcard sound/sequences/$(VERSION)/*.s),$(BUILD_DIR)/$(file:.s=.m64)) \
$(foreach file,$(wildcard sound/sequences/*.s),$(BUILD_DIR)/$(file:.s=.m64))
SOUND_SAMPLE_DIRS := $(wildcard sound/samples/*)
SOUND_SAMPLE_AIFFS := $(foreach dir,$(SOUND_SAMPLE_DIRS),$(wildcard $(dir)/*.aiff))
SOUND_SAMPLE_TABLES := $(foreach file,$(SOUND_SAMPLE_AIFFS),$(BUILD_DIR)/$(file:.aiff=.table))
SOUND_SAMPLE_AIFCS := $(foreach file,$(SOUND_SAMPLE_AIFFS),$(BUILD_DIR)/$(file:.aiff=.aifc))
SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.ctl.o \
$(SOUND_BIN_DIR)/sound_data.tbl.o \
$(SOUND_BIN_DIR)/sequences.bin.o \
$(SOUND_BIN_DIR)/bank_sets.o
# Object files
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
$(foreach file,$(CXX_FILES),$(BUILD_DIR)/$(file:.cpp=.o)) \
$(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \
$(foreach file,$(GENERATED_C_FILES),$(file:.c=.o))
ULTRA_O_FILES := $(foreach file,$(ULTRA_S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \
$(foreach file,$(ULTRA_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
GODDARD_O_FILES := $(foreach file,$(GODDARD_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
# Automatic dependency files
DEP_FILES := $(O_FILES:.o=.d) $(ULTRA_O_FILES:.o=.d) $(GODDARD_O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d
# Files with GLOBAL_ASM blocks
ifneq ($(NON_MATCHING),1)
GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(wildcard src/audio/*.c) $(wildcard src/game/*.c)
GLOBAL_ASM_O_FILES = $(foreach file,$(GLOBAL_ASM_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
GLOBAL_ASM_DEP = $(BUILD_DIR)/src/audio/non_matching_dep
endif
# Segment elf files
SEG_FILES := $(SEGMENT_ELF_FILES) $(ACTOR_ELF_FILES) $(LEVEL_ELF_FILES)
##################### Compiler Options #######################
INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I .
ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth
ifeq ($(TARGET_N64),1)
IRIX_ROOT := tools/ido5.3_compiler
ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
CROSS := mips-linux-gnu-
else
CROSS := mips64-elf-
endif
# check that either QEMU_IRIX is set or qemu-irix package installed
ifndef QEMU_IRIX
QEMU_IRIX := $(shell which qemu-irix)
ifeq (, $(QEMU_IRIX))
$(error Please install qemu-irix package or set QEMU_IRIX env var to the full qemu-irix binary path)
endif
endif
AS := $(CROSS)as
CC := $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
CPP := cpp -P -Wno-trigraphs
LD := $(CROSS)ld
AR := $(CROSS)ar
OBJDUMP := $(CROSS)objdump
OBJCOPY := $(CROSS)objcopy
PYTHON := python3
ifeq ($(TARGET_N64),1)
TARGET_CFLAGS := -nostdinc -I include/libc -DTARGET_N64
CC_CFLAGS := -fno-builtin
endif
# Check code syntax with host compiler
CC_CHECK := gcc -fsyntax-only -fsigned-char $(CC_CFLAGS) $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -DNON_MATCHING -DAVOID_UB $(VERSION_CFLAGS) $(GRUCODE_CFLAGS)
ASFLAGS := -march=vr4300 -mabi=32 -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) $(GRUCODE_ASFLAGS)
CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn -signed $(OPT_FLAGS) $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(MIPSISET) $(GRUCODE_CFLAGS)
OBJCOPYFLAGS := --pad-to=0x800000 --gap-fill=0xFF
SYMBOL_LINKING_FLAGS := $(addprefix -R ,$(SEG_FILES))
LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(SYMBOL_LINKING_FLAGS)
ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth
ifeq ($(shell getconf LONG_BIT), 32)
# Work around memory allocation bug in QEMU
export QEMU_GUEST_BASE := 1
else
# Ensure that gcc treats the code as 32-bit
CC_CHECK += -m32
endif
else # TARGET_N64
AS := as
ifneq ($(TARGET_WEB),1)
CC := gcc
CXX := g++
else
CC := emcc
endif
ifeq ($(WINDOWS_BUILD),1)
LD := $(CXX)
else
LD := $(CC)
endif
CPP := cpp -P
OBJDUMP := objdump
OBJCOPY := objcopy
PYTHON := python3
ifeq ($(WINDOWS_BUILD),1)
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `sdl2-config --cflags`
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `sdl2-config --cflags`
else ifeq ($(TARGET_WEB),1)
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2
else
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `pkg-config --cflags libusb-1.0 glfw3` `sdl2-config --cflags`
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `pkg-config --cflags libusb-1.0 glfw3` `sdl2-config --cflags`
endif
ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS)
ifeq ($(TARGET_WEB),1)
LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']"
else
ifeq ($(WINDOWS_BUILD),1)
LDFLAGS := -m32 -march=i686 -Llib -lpthread -lglew32 `sdl2-config --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static
else
LDFLAGS := -m32 -march=i686 -lm -lGL `sdl2-config --libs` -no-pie -lpthread `pkg-config --libs libusb-1.0 glfw3` -lasound -lX11 -lXrandr -lpulse
endif
endif
endif
####################### Other Tools #########################
# N64 tools
TOOLS_DIR = tools
MIO0TOOL = $(TOOLS_DIR)/mio0
N64CKSUM = $(TOOLS_DIR)/n64cksum
N64GRAPHICS = $(TOOLS_DIR)/n64graphics
N64GRAPHICS_CI = $(TOOLS_DIR)/n64graphics_ci
TEXTCONV = $(TOOLS_DIR)/textconv
IPLFONTUTIL = $(TOOLS_DIR)/iplfontutil
AIFF_EXTRACT_CODEBOOK = $(TOOLS_DIR)/aiff_extract_codebook
VADPCM_ENC = $(TOOLS_DIR)/vadpcm_enc
EXTRACT_DATA_FOR_MIO = $(TOOLS_DIR)/extract_data_for_mio
SKYCONV = $(TOOLS_DIR)/skyconv
EMULATOR = mupen64plus
EMU_FLAGS = --noosd
LOADER = loader64
LOADER_FLAGS = -vwf
SHA1SUM = sha1sum
###################### Dependency Check #####################
ifeq ($(TARGET_N64),1)
BINUTILS_VER_MAJOR := $(shell $(LD) --version | grep ^GNU | sed 's/^.* //; s/\..*//g')
BINUTILS_VER_MINOR := $(shell $(LD) --version | grep ^GNU | sed 's/^[^.]*\.//; s/\..*//g')
BINUTILS_DEPEND := $(shell expr $(BINUTILS_VER_MAJOR) \>= 2 \& $(BINUTILS_VER_MINOR) \>= 27)
ifeq ($(BINUTILS_DEPEND),0)
$(error binutils version 2.27 required, version $(BINUTILS_VER_MAJOR).$(BINUTILS_VER_MINOR) detected)
endif
endif
######################## Targets #############################
ifeq ($(TARGET_N64),1)
all: $(ROM)
ifeq ($(COMPARE),1)
@$(SHA1SUM) -c $(TARGET).sha1 || (echo 'The build succeeded, but did not match the official ROM. This is expected if you are making changes to the game.\nTo silence this message, use "make COMPARE=0"'. && false)
endif
else
all: $(EXE)
endif
clean:
$(RM) -r $(BUILD_DIR_BASE)
distclean:
$(RM) -r $(BUILD_DIR_BASE)
./extract_assets.py --clean
test: $(ROM)
$(EMULATOR) $(EMU_FLAGS) $<
load: $(ROM)
$(LOADER) $(LOADER_FLAGS) $<
libultra: $(BUILD_DIR)/libultra.a
asm/boot.s: $(BUILD_DIR)/lib/bin/ipl3_font.bin
$(BUILD_DIR)/lib/bin/ipl3_font.bin: lib/ipl3_font.png
$(IPLFONTUTIL) e $< [email protected]
$(BUILD_DIR)/include/text_strings.h: include/text_strings.h.in
$(TEXTCONV) charmap.txt $< [email protected]
$(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in
$(TEXTCONV) charmap_menu.txt $< [email protected]
ifeq ($(VERSION),eu)
TEXT_DIRS := text/de text/us text/fr
# EU encoded text inserted into individual segment 0x19 files
$(BUILD_DIR)/bin/eu/translation_en.o: $(BUILD_DIR)/text/us/define_text.inc.c
$(BUILD_DIR)/bin/eu/translation_de.o: $(BUILD_DIR)/text/de/define_text.inc.c
$(BUILD_DIR)/bin/eu/translation_fr.o: $(BUILD_DIR)/text/fr/define_text.inc.c
else
TEXT_DIRS := text/$(VERSION)
# non-EU encoded text inserted into segment 0x02
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/$(VERSION)/define_text.inc.c
endif
$(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h text/%/dialogs.h
$(CPP) $(VERSION_CFLAGS) $< -o [email protected] -I text/$*/
$(TEXTCONV) charmap.txt [email protected] [email protected]
ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(GODDARD_SRC_DIRS) $(ULTRA_SRC_DIRS) $(ULTRA_ASM_DIRS) $(ULTRA_BIN_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION)
# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $(ALL_DIRS)
$(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h
$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h
$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h
$(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h
################################################################
# TEXTURE GENERATION #
################################################################
# RGBA32, RGBA16, IA16, IA8, IA4, IA1, I8, I4
$(BUILD_DIR)/%: %.png
$(N64GRAPHICS) -i [email protected] -g $< -f $(lastword $(subst ., ,[email protected]))
$(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/% %.png
hexdump -v -e '1/1 "0x%X,"' $< > [email protected]
echo >> [email protected]
# Color Index CI8
$(BUILD_DIR)/%.ci8: %.ci8.png
$(N64GRAPHICS_CI) -i [email protected] -g $< -f ci8
# Color Index CI4
$(BUILD_DIR)/%.ci4: %.ci4.png
$(N64GRAPHICS_CI) -i [email protected] -g $< -f ci4
################################################################
# compressed segment generation
ifeq ($(TARGET_N64),1)
# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address
$(BUILD_DIR)/bin/%.elf: $(BUILD_DIR)/bin/%.o
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map [email protected].map -o [email protected] $<
$(BUILD_DIR)/actors/%.elf: $(BUILD_DIR)/actors/%.o
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map [email protected].map -o [email protected] $<
# Override for level.elf, which otherwise matches the above pattern
.SECONDEXPANSION:
$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map [email protected].map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o [email protected] $<
$(BUILD_DIR)/bin/%.bin: $(BUILD_DIR)/bin/%.elf
$(EXTRACT_DATA_FOR_MIO) $< [email protected]
$(BUILD_DIR)/actors/%.bin: $(BUILD_DIR)/actors/%.elf
$(EXTRACT_DATA_FOR_MIO) $< [email protected]
$(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf
$(EXTRACT_DATA_FOR_MIO) $< [email protected]
$(BUILD_DIR)/%.mio0: $(BUILD_DIR)/%.bin
$(MIO0TOOL) $< [email protected]
$(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0.s
$(AS) $(ASFLAGS) -o [email protected] $<
$(BUILD_DIR)/%.mio0.s: $(BUILD_DIR)/%.mio0
printf ".section .data\n\n.incbin \"$<\"\n" > [email protected]
endif
$(BUILD_DIR)/%.table: %.aiff
$(AIFF_EXTRACT_CODEBOOK) $< >[email protected]
$(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff
$(VADPCM_ENC) -c $^ [email protected]
$(ENDIAN_BITWIDTH): tools/determine-endian-bitwidth.c
$(CC) -c $(CFLAGS) -o [email protected].dummy2 $< 2>[email protected].dummy1; true
grep -o 'msgbegin --endian .* --bitwidth .* msgend' [email protected].dummy1 > [email protected].dummy2
head -n1 <[email protected].dummy2 | cut -d' ' -f2-5 > [email protected]
@rm [email protected].dummy1
@rm [email protected].dummy2
$(SOUND_BIN_DIR)/sound_data.ctl: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS) $(ENDIAN_BITWIDTH)
$(PYTHON) tools/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl $(SOUND_BIN_DIR)/sound_data.tbl $(VERSION_CFLAGS) $$(cat $(ENDIAN_BITWIDTH))
$(SOUND_BIN_DIR)/sound_data.tbl: $(SOUND_BIN_DIR)/sound_data.ctl
@true
$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json sound/sequences/ sound/sequences/$(VERSION)/ $(SOUND_SEQUENCE_FILES) $(ENDIAN_BITWIDTH)
$(PYTHON) tools/assemble_sound.py --sequences [email protected] $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(VERSION_CFLAGS) $$(cat $(ENDIAN_BITWIDTH))
$(SOUND_BIN_DIR)/bank_sets: $(SOUND_BIN_DIR)/sequences.bin
@true
$(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o
$(OBJCOPY) -j .rodata $< -O binary [email protected]
$(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s
$(AS) $(ASFLAGS) -o [email protected] $<
ifeq ($(TARGET_N64),1)
$(SOUND_BIN_DIR)/%.s: $(SOUND_BIN_DIR)/%
printf ".section .data\n\n.incbin \"$<\"\n" > [email protected]
else
$(SOUND_BIN_DIR)/sound_data.ctl.c: $(SOUND_BIN_DIR)/sound_data.ctl
echo "unsigned char gSoundDataADSR[] = {" > [email protected]
hexdump -v -e '1/1 "0x%X,"' $< >> [email protected]
echo "};" >> [email protected]
$(SOUND_BIN_DIR)/sound_data.tbl.c: $(SOUND_BIN_DIR)/sound_data.tbl
echo "unsigned char gSoundDataRaw[] = {" > [email protected]
hexdump -v -e '1/1 "0x%X,"' $< >> [email protected]
echo "};" >> [email protected]
$(SOUND_BIN_DIR)/sequences.bin.c: $(SOUND_BIN_DIR)/sequences.bin
echo "unsigned char gMusicData[] = {" > [email protected]
hexdump -v -e '1/1 "0x%X,"' $< >> [email protected]
echo "};" >> [email protected]
$(SOUND_BIN_DIR)/bank_sets.c: $(SOUND_BIN_DIR)/bank_sets
echo "unsigned char gBankSetsData[] = {" > [email protected]
hexdump -v -e '1/1 "0x%X,"' $< >> [email protected]
echo "};" >> [email protected]
endif
$(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h
$(BUILD_DIR)/include/level_headers.h: levels/level_headers.h.in
$(CPP) -I . levels/level_headers.h.in | $(PYTHON) tools/output_level_headers.py > $(BUILD_DIR)/include/level_headers.h
$(BUILD_DIR)/assets/mario_anim_data.c: $(wildcard assets/anims/*.inc.c)
$(PYTHON) tools/mario_anims_converter.py > [email protected]
$(BUILD_DIR)/assets/demo_data.c: assets/demo_data.json $(wildcard assets/demos/*.bin)
$(PYTHON) tools/demo_data_converter.py assets/demo_data.json $(VERSION_CFLAGS) > [email protected]
# Source code
$(BUILD_DIR)/src/goddard/%.o: OPT_FLAGS := -g
$(BUILD_DIR)/src/goddard/%.o: MIPSISET := -mips1
$(BUILD_DIR)/src/audio/%.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
$(BUILD_DIR)/src/audio/load.o: OPT_FLAGS := -O2 -framepointer -Wo,-loopunroll,0
$(BUILD_DIR)/lib/src/%.o: OPT_FLAGS :=
$(BUILD_DIR)/lib/src/math/ll%.o: MIPSISET := -mips3 -32
$(BUILD_DIR)/lib/src/math/%.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/math/ll%.o: OPT_FLAGS :=
$(BUILD_DIR)/lib/src/ldiv.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/string.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/gu%.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/al%.o: OPT_FLAGS := -O3
ifeq ($(VERSION),eu)
$(BUILD_DIR)/lib/src/_Litob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Ldtob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Printf.o: OPT_FLAGS := -O3
endif
ifeq ($(NON_MATCHING),0)
$(GLOBAL_ASM_O_FILES): CC := $(PYTHON) tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
endif
# Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes.
$(GLOBAL_ASM_O_FILES): $(GLOBAL_ASM_DEP).$(NON_MATCHING)
$(GLOBAL_ASM_DEP).$(NON_MATCHING):
@rm -f $(GLOBAL_ASM_DEP).*
touch [email protected]
$(BUILD_DIR)/%.o: %.cpp
@$(CXX) -fsyntax-only $(CFLAGS) -MMD -MP -MT [email protected] -MF $(BUILD_DIR)/$*.d $<
$(CXX) -c $(CFLAGS) -o [email protected] $<
$(BUILD_DIR)/%.o: %.c
@$(CC_CHECK) -MMD -MP -MT [email protected] -MF $(BUILD_DIR)/$*.d $<
$(CC) -c $(CFLAGS) -o [email protected] $<
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
@$(CC_CHECK) -MMD -MP -MT [email protected] -MF $(BUILD_DIR)/$*.d $<
$(CC) -c $(CFLAGS) -o [email protected] $<
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o [email protected] $<
ifeq ($(TARGET_N64),1)
$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
$(CPP) $(VERSION_CFLAGS) -MMD -MP -MT [email protected] -MF [email protected].d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o [email protected] $<
$(BUILD_DIR)/libultra.a: $(ULTRA_O_FILES)
$(AR) rcs -o [email protected] $(ULTRA_O_FILES)
tools/patch_libultra_math [email protected]
$(BUILD_DIR)/libgoddard.a: $(GODDARD_O_FILES)
$(AR) rcs -o [email protected] $(GODDARD_O_FILES)
$(ELF): $(O_FILES) $(MIO0_OBJ_FILES) $(SOUND_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libgoddard.a
$(LD) -L $(BUILD_DIR) $(LDFLAGS) -o [email protected] $(O_FILES)$(LIBS) -lultra -lgoddard
$(ROM): $(ELF)
$(OBJCOPY) $(OBJCOPYFLAGS) $< $(@:.z64=.bin) -O binary
$(N64CKSUM) $(@:.z64=.bin) [email protected]
$(BUILD_DIR)/$(TARGET).objdump: $(ELF)
$(OBJDUMP) -D $< > [email protected]
else
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
$(LD) -L $(BUILD_DIR) -o [email protected] $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
endif
.PHONY: all clean distclean default diff test load libultra
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
.DELETE_ON_ERROR:
# Remove built-in rules, to improve performance
MAKEFLAGS += --no-builtin-rules
-include $(DEP_FILES)
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true

248
Makefile.split

@ -0,0 +1,248 @@
# --------------------------------------
# General Rules
# --------------------------------------
# obtain a list of segments from the *.c files in bin directory
SEGMENTS := $(notdir $(basename $(wildcard bin/*.c))) $(addprefix $(VERSION)/,$(notdir $(basename $(wildcard bin/$(VERSION)/*.c)))) $(addsuffix _skybox,$(notdir $(basename $(wildcard textures/skyboxes/*.png))))
ACTORS := $(filter %/,$(wildcard actors/*/))
TEXTURE_DIRS := $(addprefix textures/,$(SEGMENTS)) $(ACTORS) textures/intro_raw
# NOTE: textures assume naming convention "texture.<encoding>.png" generates "texture.<encoding>"
ACTOR_GROUPS := \
group0 \
group1 \
group2 \
group3 \
group4 \
group5 \
group6 \
group7 \
group8 \
group9 \
group10 \
group11 \
group12 \
group13 \
group14 \
group15 \
group16 \
group17 \
common0 \
common1
LEVEL_FILES := $(addsuffix leveldata,$(LEVEL_DIRS))
MIO0_FILES := $(addprefix $(MIO0_DIR)/,$(addsuffix .mio0,$(SEGMENTS))) $(addprefix $(BUILD_DIR)/actors/,$(addsuffix .mio0,$(ACTOR_GROUPS))) $(addprefix $(BUILD_DIR)/levels/,$(addsuffix .mio0,$(LEVEL_FILES)))
MIO0_OBJ_FILES := $(MIO0_FILES:.mio0=.mio0.o)
SEGMENT_ELF_FILES := $(addprefix $(BUILD_DIR)/bin/,$(addsuffix .elf,$(SEGMENTS)))
ACTOR_ELF_FILES := $(addprefix $(BUILD_DIR)/actors/,$(addsuffix .elf,$(ACTOR_GROUPS)))
LEVEL_ELF_FILES := $(addprefix $(BUILD_DIR)/levels/,$(addsuffix .elf,$(LEVEL_FILES)))
# --------------------------------------
# Actor Rules
# --------------------------------------
# Actor Directories
KOOPA_DIRS := koopa_flag poundable_pole koopa piranha_plant whomp chain_ball chain_chomp
CAPSWITCH_DIRS := capswitch springboard
CHILLYCHIEF_DIRS := chillychief moneybag
BULLY_DIRS := bully blargg
SPINDRIFT_DIRS := spindrift penguin snowman
KING_BOBOMB_DIRS := king_bobomb water_bubble
BOO_DIRS := bookend book chair small_key mad_piano boo haunted_cage
MR_I_DIRS := mr_i_eyeball mr_i_iris swoop snufit dorrie scuttlebug
HOOT_DIRS := yellow_sphere_small hoot yoshi_egg thwomp bullet_bill heave_ho
COINS_DIRS := mist explosion butterfly coin warp_pipe door bowser_key flame blue_fish pebble leaves warp_collision mario_cap power_meter mushroom_1up star sand dirt transparent_star white_particle wooden_signpost tree
BUBBA_DIRS := bubba wiggler wiggler_body_part lakitu_enemy spiny_egg spiny
SKEETER_DIRS := skeeter seaweed water_mine cyan_fish bub water_ring treasure_chest
KLEPTO_DIRS := klepto eyerok pokey tornado
SEA_DIRS := clam_shell manta sushi unagi whirlpool
AMP_DIRS := blue_coin_switch amp cannon_lid cannon_base cannon_barrel chuckya purple_switch checkerboard_platform heart flyguy breakable_box exclamation_box goomba bobomb metal_box exclamation_box_outline test_platform koopa_shell
MOLE_DIRS := monty_mole_hole monty_mole smoke ukiki fwoosh
LAKITU_DIRS := lakitu_cameraman toad mips boo_castle
PEACH_DIRS := bird peach yoshi
BOWSER_DIRS := bowser_flame impact_ring yellow_sphere bowser bomb impact_smoke
MARIO_DIRS := mario bubble walk_smoke burn_smoke stomp_smoke water_waves sparkle water_splash white_particle_small sparkle_animation
# Actor Files
AMP_CHUCKYA_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(AMP_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
BOBOMBS_BUBBLE_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(KING_BOBOMB_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
BOO_BOOKEND_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BOO_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
CAPSWITCH_SPRINGBOARD_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(CAPSWITCH_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
COINS_PIPE_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(COINS_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
BOWSER_FLAMES_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BOWSER_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
BUBBA_WIGGLER_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BUBBA_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
BULLY_BLARGG_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BULLY_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
CHILLYCHIEF_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(CHILLYCHIEF_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
HOOT_THWOMP_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(HOOT_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
KOOPA_LOG_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(KOOPA_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
KLEPTO_EYEROK_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(KLEPTO_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
LAKITU_TOAD_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(LAKITU_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
MARIO_WATER_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(MARIO_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
MOLE_UKIKI_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(MOLE_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
MR_I_SWOOP_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(MR_I_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
PEACH_TOADSTOOL_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(PEACH_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
SEA_CREATURES_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(SEA_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
SKEETER_FISH_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(SKEETER_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
SPINDRIFT_PENGUIN_FILES := $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(SPINDRIFT_DIRS)),$(patsubst %.png,%.inc.c,$(wildcard $(dir)/*.png)))
# Actor dependencies
$(BUILD_DIR)/actors/group0.o: $(addprefix $(BUILD_DIR)/,$(MARIO_WATER_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(MARIO_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group1.o: $(addprefix $(BUILD_DIR)/,$(HOOT_THWOMP_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(HOOT_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group2.o: $(addprefix $(BUILD_DIR)/,$(BULLY_BLARGG_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BULLY_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group3.o: $(addprefix $(BUILD_DIR)/,$(BOBOMBS_BUBBLE_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(KING_BOBOMB_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group4.o: $(addprefix $(BUILD_DIR)/,$(SEA_CREATURES_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(SEA_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group5.o: $(addprefix $(BUILD_DIR)/,$(KLEPTO_EYEROK_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(KLEPTO_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group6.o: $(addprefix $(BUILD_DIR)/,$(MOLE_UKIKI_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(MOLE_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group7.o: $(addprefix $(BUILD_DIR)/,$(SPINDRIFT_PENGUIN_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(SPINDRIFT_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group8.o: $(addprefix $(BUILD_DIR)/,$(CAPSWITCH_SPRINGBOARD_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(CAPSWITCH_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group9.o: $(addprefix $(BUILD_DIR)/,$(BOO_BOOKEND_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BOO_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group10.o: $(addprefix $(BUILD_DIR)/,$(PEACH_TOADSTOOL_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(PEACH_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group11.o: $(addprefix $(BUILD_DIR)/,$(BUBBA_WIGGLER_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BUBBA_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group12.o: $(addprefix $(BUILD_DIR)/,$(BOWSER_FLAMES_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(BOWSER_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group13.o: $(addprefix $(BUILD_DIR)/,$(SKEETER_FISH_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(SKEETER_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group14.o: $(addprefix $(BUILD_DIR)/,$(KOOPA_LOG_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(KOOPA_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group15.o: $(addprefix $(BUILD_DIR)/,$(LAKITU_TOAD_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(LAKITU_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group16.o: $(addprefix $(BUILD_DIR)/,$(CHILLYCHIEF_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(CHILLYCHIEF_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/group17.o: $(addprefix $(BUILD_DIR)/,$(MR_I_SWOOP_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(MR_I_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/common0.o: $(addprefix $(BUILD_DIR)/,$(AMP_CHUCKYA_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(AMP_DIRS)),$(wildcard $(dir)/*.c))
$(BUILD_DIR)/actors/common1.o: $(addprefix $(BUILD_DIR)/,$(COINS_PIPE_FILES)) $(foreach dir,$(addprefix $(ACTOR_DIR)/,$(COINS_DIRS)),$(wildcard $(dir)/*.c))
# Actor Elf Files
$(BUILD_DIR)/actors/group0.elf: SEGMENT_ADDRESS := 0x04000000
$(BUILD_DIR)/actors/group1.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group2.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group3.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group4.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group5.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group6.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group7.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group8.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group9.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group10.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group11.elf: SEGMENT_ADDRESS := 0x05000000
$(BUILD_DIR)/actors/group12.elf: SEGMENT_ADDRESS := 0x06000000
$(BUILD_DIR)/actors/group13.elf: SEGMENT_ADDRESS := 0x06000000
$(BUILD_DIR)/actors/group14.elf: SEGMENT_ADDRESS := 0x06000000
$(BUILD_DIR)/actors/group15.elf: SEGMENT_ADDRESS := 0x06000000
$(BUILD_DIR)/actors/group16.elf: SEGMENT_ADDRESS := 0x06000000
$(BUILD_DIR)/actors/group17.elf: SEGMENT_ADDRESS := 0x06000000
$(BUILD_DIR)/actors/common0.elf: SEGMENT_ADDRESS := 0x08000000
$(BUILD_DIR)/actors/common1.elf: SEGMENT_ADDRESS := 0x03000000
# --------------------------------------
# Level Rules
# --------------------------------------
$(BUILD_DIR)/levels/%/leveldata.elf: SEGMENT_ADDRESS := 0x07000000
# TODO: Generate these rules from the level configs?
define level_rules =
$(1)_SEG7_FILES := $$(patsubst %.png,%.inc.c,$$(wildcard levels/$(1)/*.png))
$$(BUILD_DIR)/levels/$(1)/leveldata.o: $$(addprefix $$(BUILD_DIR)/,$$($(1)_SEG7_FILES))
$$(BUILD_DIR)/levels/$(1)/leveldata.elf: TEXTURE_BIN := $(2)
endef
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
$(BUILD_DIR)/level_rules.mk: levels/level_rules.mk levels/level_defines.h
$(CPP) $(VERSION_CFLAGS) -I . -o [email protected] $<
include $(BUILD_DIR)/level_rules.mk
endif
endif
# --------------------------------------
# Extra Level Rules
# --------------------------------------
$(eval $(call level_rules,intro,generic)) # Intro (Super Mario 64 Logo)
$(eval $(call level_rules,menu,generic)) # Menu (File Select)
# --------------------------------------
# Cake Texture Rules
# --------------------------------------
# Ending cake textures are generated in a special way
$(BUILD_DIR)/levels/ending/cake_eu.inc.c: levels/ending/cake_eu.png
$(SKYCONV) --type cake-eu --split $^ $(BUILD_DIR)/levels/ending
$(BUILD_DIR)/levels/ending/cake.inc.c: levels/ending/cake.png
$(SKYCONV) --type cake --split $^ $(BUILD_DIR)/levels/ending
# --------------------------------------
# Texture Bin Rules
# --------------------------------------
# Others
SEGMENT2_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/segment2/*.png))
TITLE_SCREEN_BG_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/title_screen_bg/*.png))
SPOOKY_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/spooky/*.png))
GENERIC_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/generic/*.png))
OUTSIDE_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/outside/*.png))
SNOW_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/snow/*.png))
EFFECT_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/effect/*.png))
CAVE_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/cave/*.png))
INSIDE_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/inside/*.png))
WATER_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/water/*.png))
FIRE_TEXTURES_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/fire/*.png))
SKY_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/sky/*.png))
MACHINE_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/machine/*.png))
MOUNTAIN_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/mountain/*.png))
GRASS_FILES := $(patsubst %.png,%.inc.c,$(wildcard $(TEXTURE_DIR)/grass/*.png))
# Texture Files
$(BUILD_DIR)/bin/segment2.o: $(addprefix $(BUILD_DIR)/,$(SEGMENT2_FILES))
$(BUILD_DIR)/bin/title_screen_bg.o: $(addprefix $(BUILD_DIR)/,$(TITLE_SCREEN_BG_FILES))
$(BUILD_DIR)/bin/spooky.o: $(addprefix $(BUILD_DIR)/,$(SPOOKY_FILES))
$(BUILD_DIR)/bin/generic.o: $(addprefix $(BUILD_DIR)/,$(GENERIC_FILES))
$(BUILD_DIR)/bin/outside.o: $(addprefix $(BUILD_DIR)/,$(OUTSIDE_FILES))
$(BUILD_DIR)/bin/snow.o: $(addprefix $(BUILD_DIR)/,$(SNOW_FILES))
$(BUILD_DIR)/bin/effect.o: $(addprefix $(BUILD_DIR)/,$(EFFECT_FILES))
$(BUILD_DIR)/bin/cave.o: $(addprefix $(BUILD_DIR)/,$(CAVE_FILES))
$(BUILD_DIR)/bin/inside.o: $(addprefix $(BUILD_DIR)/,$(INSIDE_FILES))
$(BUILD_DIR)/bin/water.o: $(addprefix $(BUILD_DIR)/,$(WATER_FILES))
$(BUILD_DIR)/bin/fire.o: $(addprefix $(BUILD_DIR)/,$(FIRE_TEXTURES_FILES))
$(BUILD_DIR)/bin/sky.o: $(addprefix $(BUILD_DIR)/,$(SKY_FILES))
$(BUILD_DIR)/bin/machine.o: $(addprefix $(BUILD_DIR)/,$(MACHINE_FILES))
$(BUILD_DIR)/bin/mountain.o: $(addprefix $(BUILD_DIR)/,$(MOUNTAIN_FILES))
$(BUILD_DIR)/bin/grass.o: $(addprefix $(BUILD_DIR)/,$(GRASS_FILES))
# Others
$(BUILD_DIR)/bin/segment2.elf: SEGMENT_ADDRESS := 0x02000000
$(BUILD_DIR)/bin/title_screen_bg.elf: SEGMENT_ADDRESS := 0x0A000000
$(BUILD_DIR)/bin/debug_level_select.elf: SEGMENT_ADDRESS := 0x07000000
$(BUILD_DIR)/bin/effect.elf: SEGMENT_ADDRESS := 0x0B000000
$(BUILD_DIR)/bin/spooky.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/generic.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/outside.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/snow.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/cave.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/inside.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/water.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/fire.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/sky.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/machine.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/mountain.elf: SEGMENT_ADDRESS := 0x09000000
$(BUILD_DIR)/bin/grass.elf: SEGMENT_ADDRESS := 0x09000000
# EU segment 19 translations
$(BUILD_DIR)/bin/eu/translation_de.elf: SEGMENT_ADDRESS := 0x19000000
$(BUILD_DIR)/bin/eu/translation_en.elf: SEGMENT_ADDRESS := 0x19000000
$(BUILD_DIR)/bin/eu/translation_fr.elf: SEGMENT_ADDRESS := 0x19000000
# --------------------------------------
# Skybox Rules
# --------------------------------------
$(BUILD_DIR)/bin/%_skybox.c: textures/skyboxes/%.png
$(SKYCONV) --type sky --split $^ $(BUILD_DIR)/bin
$(BUILD_DIR)/bin/%_skybox.elf: SEGMENT_ADDRESS := 0x0A000000
# --------------------------------------
# Misc Rules
# --------------------------------------
# intro_raw textures are not compressed
INTRO_RAW_FILES := $(wildcard $(TEXTURE_DIR)/intro_raw/*.png)
$(BUILD_DIR)/src/goddard/renderer.o: $(addprefix $(BUILD_DIR)/,$(patsubst %.png,%.inc.c,$(INTRO_RAW_FILES)))

115
README.md

@ -0,0 +1,115 @@
# Super Mario 64
This repo contains a full decompilation of Super Mario 64 (J) and (U).
The source and data have been decompiled but complete naming and documentation
all of the code and data is still a work in progress. Decompiling the (E) ROM
is also an ongoing effort.
It builds the following ROMs:
* sm64.jp.z64 `sha1: 8a20a5c83d6ceb0f0506cfc9fa20d8f438cafe51`
* sm64.us.z64 `sha1: 9bef1128717f958171a4afac3ed78ee2bb4e86ce`
This repo does not include all assets necessary for compiling the ROMs.
A prior copy of the game is required to extract the required assets.
## Installation
### Linux
#### 1. Copy baserom(s) for asset extraction
For each version (jp/us/eu) that you want to build a ROM for, put an existing ROM at
`./baserom.<version>.z64` for asset extraction.
#### 2. Install build dependencies
The build system has the following package requirements:
* binutils-mips >= 2.27
* python3 >= 3.6
* libaudiofile
* qemu-irix
__Debian / Ubuntu__
```
sudo apt install build-essential pkg-config git binutils-mips-linux-gnu python3 zlib1g-dev libaudiofile-dev
```
Download latest package from [qemu-irix Releases](https://github.com/n64decomp/qemu-irix/releases)
```
sudo dpkg -i qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb
```
(Optional) Clone https://github.com/n64decomp/qemu-irix and follow the install instructions in the README.
__Arch Linux__
```
sudo pacman -S base-devel python audiofile
```
Install the following AUR packages:
* [mips64-elf-binutils](https://aur.archlinux.org/packages/mips64-elf-binutils) (AUR)
* [qemu-irix-git](https://aur.archlinux.org/packages/qemu-irix-git) (AUR)
#### 3. Build ROM
Run `make` to build the ROM (defaults to `VERSION=us`). Make sure your path to the repo
is not too long or else this process will error, as the emulated IDO compiler cannot
handle paths longer than 255 characters.
Examples:
```
make VERSION=jp -j4 # build (J) version instead with 4 jobs
make VERSION=eu COMPARE=0 # non-matching EU version still WIP
```
## Windows
For Windows, install WSL and a distro of your choice following
[Windows Subsystem for Linux Installation Guide for Windows 10](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
We recommend either Debian or Ubuntu 18.04 Linux distributions under WSL.
Then follow the directions in the [Linux](#linux) installation section above.
## macOS
macOS is currently unsupported as qemu-irix is unable to be built for macOS host.
The recommended path is installing a Linux distribution under a VM.
## Project Structure
```
sm64
├── actors: object behaviors, geo layout, and display lists
├── asm: handwritten assembly code, rom header
│   └── non_matchings: asm for non-matching sections
├── assets: animation and demo data
│   ├── anims: animation data
│   └── demos: demo data
├── bin: asm files for ordering display lists and textures
├── build: output directory
├── data: behavior scripts, misc. data
├── doxygen: documentation infrastructure
├── enhancements: example source modifications
├── include: header files
├── levels: level scripts, geo layout, and display lists
├── lib: SDK library code
├── sound: sequences, sound samples, and sound banks
├── src: C source code for game
│   ├── audio: audio code
│   ├── buffers: stacks, heaps, and task buffers
│   ├── engine: script processing engines and utils
│   ├── game: behaviors and rest of game source
│   ├── goddard: Mario intro screen
│   └── menu: title screen and file, act, and debug level selection menus
├── text: dialog, level names, act names
├── textures: skybox and generic texture data
└── tools: build tools
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.
Run clang-format on your code to ensure it meets the project's coding standards.
Official discord: https://discord.gg/27JtCWs

54
actors/amp/anims/anim_0800401C.inc.c

@ -0,0 +1,54 @@
// 0x08003E30
static const s16 amp_seg8_animvalue_08003E30[] = {
0x0000, 0x0000, 0x0D79, 0x1AF2, 0x286B, 0x35E4, 0x435D, 0x50D6,
0x5E50, 0x6BC9, 0x7942, 0x86BE, 0x9437, 0xA1B0, 0xAF2A, 0xBCA3,
0xCA1C, 0xD795, 0xE50E, 0xF287, 0x1872, 0x0000, 0x1AF2, 0x35E4,
0x50D6, 0x6BC9, 0x86BE, 0xA1B0, 0xBCA3, 0xD795, 0xF287, 0x0D79,
0x286B, 0x435D, 0x5E50, 0x7942, 0x9437, 0xAF2A, 0xCA1C, 0xE50E,
0x0000, 0x1AF2, 0x35E4, 0x50D6, 0x6BC9, 0x86BE, 0xA1B0, 0xBCA3,
0xD795, 0xF287, 0x0D79, 0x286B, 0x435D, 0x5E50, 0x7942, 0x9437,
0xAF2A, 0xCA1C, 0xE50E, 0x8001, 0x5793, 0x2F28, 0x06BC, 0xDE52,
0xB5E6, 0x8D7B, 0x650C, 0x3CA1, 0x1435, 0xEBCB, 0xC35F, 0x9AF4,
0x7285, 0x4A1A, 0x21AE, 0xF944, 0xD0D8, 0xA86D, 0x3FFF, 0x0000,
0x0D7C, 0x1AF9, 0x2876, 0x35F3, 0x4370, 0x50ED, 0x5E6A, 0x6BE7,
0x7964, 0x86E3, 0x9460, 0xA1DD, 0xAF5A, 0xBCD7, 0xCA54, 0xD7D1,
0xE54E, 0xF2CB, 0xC001, 0x3FFF, 0x0000, 0x0D7B, 0x1AF7, 0x2873,
0x35EF, 0x436B, 0x50E6, 0x5E62, 0x6BDE, 0x795A, 0x86D9, 0x9455,
0xA1D0, 0xAF4C, 0xBCC8, 0xCA44, 0xD7C0, 0xE53B, 0xF2B7, 0xC001,
0x3FFF, 0xC001, 0xCD7A, 0xDAF2, 0xE86B, 0xF5E3, 0x035B, 0x10D3,
0x1E4C, 0x2BC4, 0x393D, 0x46B5, 0x542E, 0x61A6, 0x6F1F, 0x7C97,
0x8A13, 0x978B, 0xA504, 0xB27D, 0xC001, 0x3FFF, 0x4D79, 0x5AF2,
0x686C, 0x75E5, 0x8362, 0x90DB, 0x9E55, 0xABCF, 0xB948, 0xC6C2,
0xD43B, 0xE1B5, 0xEF2F, 0xFCA8, 0x0A21, 0x179A, 0x2514, 0x328D,
0xC001, 0x3FFF,
};
// 0x08003F74
static const u16 amp_seg8_animindex_08003F74[] = {
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x00A1,
0x0001, 0x0000, 0x0013, 0x008D, 0x0001, 0x00A0,
0x0001, 0x0000, 0x0001, 0x0000, 0x0013, 0x0001,
0x0001, 0x0000, 0x0013, 0x0079, 0x0001, 0x008C,
0x0001, 0x0014, 0x0001, 0x0000, 0x0013, 0x0015,
0x0001, 0x0000, 0x0013, 0x0064, 0x0001, 0x0077,
0x0001, 0x0000, 0x0001, 0x0000, 0x0013, 0x0028,
0x0001, 0x0000, 0x0013, 0x004F, 0x0001, 0x0062,
0x0001, 0x0000, 0x0001, 0x0000, 0x0013, 0x003B,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0078,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0063,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x004E,
};
// 0x0800401C
static const struct Animation amp_seg8_anim_0800401C = {
0,
0,
0,
0,
0x13,
ANIMINDEX_NUMPARTS(amp_seg8_animindex_08003F74),
amp_seg8_animvalue_08003E30,
amp_seg8_animindex_08003F74,
0,
};

1
actors/amp/anims/data.inc.c

@ -0,0 +1 @@
#include "anim_0800401C.inc.c"

4
actors/amp/anims/table.inc.c

@ -0,0 +1,4 @@
// 0x08004034
const struct Animation *const amp_seg8_anims_08004034[] = {
&amp_seg8_anim_0800401C,
};

56
actors/amp/geo.inc.c

@ -0,0 +1,56 @@
// 0x0F000028
const GeoLayout amp_geo[] = {
GEO_SHADOW(SHADOW_CIRCLE_4_VERTS, 0xC8, 100),
GEO_OPEN_NODE(),
GEO_SCALE(0x00, 16384),
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_ALPHA, 0, 0, 0, amp_seg8_dl_08002C88),
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_OPEN_NODE(),
GEO_SWITCH_CASE(2, geo_switch_anim_state),
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_ANIMATED_PART(LAYER_ALPHA, 0, 0, 0, amp_seg8_dl_08002BA0),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_OPEN_NODE(),
GEO_SWITCH_CASE(2, geo_switch_anim_state),
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_ANIMATED_PART(LAYER_ALPHA, 0, 0, 0, amp_seg8_dl_08002BA0),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_OPEN_NODE(),
GEO_SWITCH_CASE(2, geo_switch_anim_state),
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_ANIMATED_PART(LAYER_ALPHA, 0, 0, 0, amp_seg8_dl_08002BA0),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_OPEN_NODE(),
GEO_SWITCH_CASE(2, geo_switch_anim_state),
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_ANIMATED_PART(LAYER_ALPHA, 0, 0, 0, amp_seg8_dl_08002BA0),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_ANIMATED_PART(LAYER_ALPHA, 0, 0, 0, amp_seg8_dl_08002D70),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, NULL),
GEO_OPEN_NODE(),
GEO_BILLBOARD(),
GEO_OPEN_NODE(),
GEO_DISPLAY_LIST(LAYER_ALPHA, amp_seg8_dl_08002E58),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_END(),
};

530
actors/amp/model.inc.c

@ -0,0 +1,530 @@
// Amp
// 0x08000F18
ALIGNED8 static const u8 amp_seg8_texture_08000F18[] = {
#include "actors/amp/amp_electricity.rgba16.inc.c"
};
// 0x08001318
ALIGNED8 static const u8 amp_seg8_texture_08001318[] = {
#include "actors/amp/amp_eyes.rgba16.inc.c"
};
// 0x08001B18
ALIGNED8 static const u8 amp_seg8_texture_08001B18[] = {
#include "actors/amp/amp_body.rgba16.inc.c"
};
// 0x08002318
ALIGNED8 static const u8 amp_seg8_texture_08002318[] = {
#include "actors/amp/amp_mouth.rgba16.inc.c"
};
// 0x08002B18
static const Vtx amp_seg8_vertex_08002B18[] = {
{{{ 224, 0, -89}, 0, { 0, 480}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 187, 149, 0}, 0, { 223, 1078}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 224, 0, 90}, 0, { 479, 478}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 187, -148, 0}, 0, { 224, -122}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 224, 0, -89}, 0, { 0, 478}, {0xff, 0xff, 0xff, 0xff}}},
};
// 0x08002B68 - 0x08002BA0
const Gfx amp_seg8_dl_08002B68[] = {
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, amp_seg8_texture_08000F18),
gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 16 * 32 - 1, CALC_DXT(16, G_IM_SIZ_16b_BYTES)),
gsSPVertex(amp_seg8_vertex_08002B18, 5, 0),
gsSP2Triangles( 0, 1, 2, 0x0, 2, 3, 4, 0x0),
gsSPEndDisplayList(),
};
// 0x08002BA0 - 0x08002C10
const Gfx amp_seg8_dl_08002BA0[] = {
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
gsSPClearGeometryMode(G_LIGHTING | G_CULL_BACK),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
gsDPTileSync(),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 4, G_TX_NOLOD),
gsDPSetTileSize(0, 0, 0, (16 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC),
gsSPDisplayList(amp_seg8_dl_08002B68),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
gsSPSetGeometryMode(G_LIGHTING | G_CULL_BACK),
gsSPEndDisplayList(),
};
// 0x08002C10
static const Vtx amp_seg8_vertex_08002C10[] = {
{{{ 68, 72, 158}, 0, { 0, 0}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -27, -71, 164}, 0, { 990, 990}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 68, -71, 158}, 0, { 990, 0}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -27, 72, 164}, 0, { 0, 990}, {0xff, 0xff, 0xff, 0xff}}},
};
// 0x08002C50 - 0x08002C88
const Gfx amp_seg8_dl_08002C50[] = {
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, amp_seg8_texture_08001318),
gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
gsSPVertex(amp_seg8_vertex_08002C10, 4, 0),
gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0),
gsSPEndDisplayList(),
};
// 0x08002C88 - 0x08002CF8
const Gfx amp_seg8_dl_08002C88[] = {
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
gsSPClearGeometryMode(G_LIGHTING),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
gsDPTileSync(),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD),
gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC),
gsSPDisplayList(amp_seg8_dl_08002C50),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
gsSPSetGeometryMode(G_LIGHTING),
gsSPEndDisplayList(),
};
// 0x08002CF8
static const Vtx amp_seg8_vertex_08002CF8[] = {
{{{ -29, 72, 164}, 0, { 0, 0}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -124, -71, 121}, 0, { 990, 990}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -29, -71, 164}, 0, { 990, 0}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -124, 72, 121}, 0, { 0, 990}, {0xff, 0xff, 0xff, 0xff}}},
};
// 0x08002D38 - 0x08002D70
const Gfx amp_seg8_dl_08002D38[] = {
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, amp_seg8_texture_08002318),
gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
gsSPVertex(amp_seg8_vertex_08002CF8, 4, 0),
gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0),
gsSPEndDisplayList(),
};
// 0x08002D70 - 0x08002DE0
const Gfx amp_seg8_dl_08002D70[] = {
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
gsSPClearGeometryMode(G_LIGHTING),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
gsDPTileSync(),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD),
gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC),
gsSPDisplayList(amp_seg8_dl_08002D38),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
gsDPPipeSync(),
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
gsSPSetGeometryMode(G_LIGHTING),
gsSPEndDisplayList(),
};
// 0x08002DE0
static const Vtx amp_seg8_vertex_08002DE0[] = {
{{{ -39, -39, 0}, 0, { 0, 990}, {0xff, 0xff, 0xff, 0xff}}},
{{{ 40, 40, 0}, 0, { 990, 0}, {0xff, 0xff, 0xff, 0xff}}},
{{{ -39, 40, 0}, 0, { 0,