merge PC port onto the decompile

master
Jan200101 2 years ago
parent 9a40d86f6a
commit e87c070517
No known key found for this signature in database
GPG Key ID: 5B71B1D78B882E05
  1. 246
      Makefile
  2. 0
      asmdiff.jp.sh
  3. 18
      bin/segment2.c
  4. 4
      extract_assets.py
  5. 2618
      include/GL/eglew.h
  6. 23686
      include/GL/glew.h
  7. 1775
      include/GL/glxew.h
  8. 1447
      include/GL/wglew.h
  9. 84
      include/PR/gbi.h
  10. 6
      include/PR/os_cont.h
  11. 3
      include/PR/os_pi.h
  12. 2
      include/PR/ultratypes.h
  13. 5
      include/config.h
  14. 20
      include/gfx_dimensions.h
  15. 6
      include/level_commands.h
  16. 2
      include/level_misc_macros.h
  17. 7
      include/macros.h
  18. 10
      include/segment_symbols.h
  19. 7
      levels/intro/script.c
  20. 13
      levels/menu/script.c
  21. 13
      lib/src/guMtxF2L.c
  22. 4
      lib/src/osContInit.c
  23. 4
      lib/src/osContStartReadData.c
  24. 4
      readme2.txt
  25. 52
      sound/sequences/00_sound_player.s
  26. 19
      src/audio/external.c
  27. 2
      src/audio/heap.c
  28. 4
      src/audio/load.c
  29. 4
      src/audio/port_eu.c
  30. 4
      src/audio/synthesis.c
  31. 7
      src/buffers/buffers.c
  32. 7
      src/buffers/buffers.h
  33. 67
      src/engine/level_script.c
  34. 51
      src/engine/surface_load.c
  35. 3
      src/engine/surface_load.h
  36. 12
      src/game/area.c
  37. 2
      src/game/crash_screen.c
  38. 26
      src/game/display.h
  39. 32
      src/game/game_init.c
  40. 4
      src/game/geo_misc.c
  41. 6
      src/game/geo_misc.h
  42. 38
      src/game/hud.c
  43. 38
      src/game/ingame_menu.c
  44. 3
      src/game/level_update.c
  45. 46
      src/game/macro_special_objects.c
  46. 3
      src/game/macro_special_objects.h
  47. 20
      src/game/mario_actions_cutscene.c
  48. 23
      src/game/memory.c
  49. 8
      src/game/memory.h
  50. 1
      src/game/paintings.c
  51. 7
      src/game/print.c
  52. 12
      src/game/rendering_graph_node.c
  53. 29
      src/game/screen_transition.c
  54. 13
      src/game/skybox.c
  55. 4
      src/goddard/debug_utils.c
  56. 15
      src/goddard/draw_objects.c
  57. 35
      src/goddard/renderer.c
  58. 17
      src/goddard/skin.c
  59. 24
      src/menu/intro_geo.c
  60. 35
      src/menu/level_select_menu.c
  61. 15
      src/pc/audio/audio_api.h
  62. 23
      src/pc/audio/audio_null.c
  63. 8
      src/pc/audio/audio_null.h
  64. 48
      src/pc/audio/audio_sdl.c
  65. 6
      src/pc/audio/audio_sdl.h
  66. 236
      src/pc/configfile.c
  67. 22
      src/pc/configfile.h
  68. 11
      src/pc/controller/controller_api.h
  69. 151
      src/pc/controller/controller_emscripten_keyboard.c
  70. 8
      src/pc/controller/controller_emscripten_keyboard.h
  71. 36
      src/pc/controller/controller_entry_point.c
  72. 88
      src/pc/controller/controller_keyboard.c
  73. 19
      src/pc/controller/controller_keyboard.h
  74. 29
      src/pc/controller/controller_recorded_tas.c
  75. 8
      src/pc/controller/controller_recorded_tas.h
  76. 98
      src/pc/controller/controller_sdl.c
  77. 8
      src/pc/controller/controller_sdl.h
  78. 25
      src/pc/gfx/gfx_cc.h
  79. 503
      src/pc/gfx/gfx_opengl.c
  80. 8
      src/pc/gfx/gfx_opengl.h
  81. 1547
      src/pc/gfx/gfx_pc.c
  82. 19
      src/pc/gfx/gfx_pc.h
  83. 32
      src/pc/gfx/gfx_rendering_api.h
  84. 7
      src/pc/gfx/gfx_screen_config.h
  85. 8
      src/pc/gfx/gfx_sdl.h
  86. 183
      src/pc/gfx/gfx_sdl2.c
  87. 18
      src/pc/gfx/gfx_window_manager_api.h
  88. 490
      src/pc/mixer.c
  89. 39
      src/pc/mixer.h
  90. 162
      src/pc/pc_main.c
  91. 160
      src/pc/ultra_reimplementation.c
  92. 2
      tools/Makefile
  93. 25
      tools/audiofile-0.3.6/ACKNOWLEDGEMENTS
  94. 5
      tools/audiofile-0.3.6/AUTHORS
  95. 502
      tools/audiofile-0.3.6/COPYING
  96. 339
      tools/audiofile-0.3.6/COPYING.GPL
  97. 1953
      tools/audiofile-0.3.6/ChangeLog
  98. 182
      tools/audiofile-0.3.6/INSTALL
  99. 897
      tools/audiofile-0.3.6/Makefile
  100. 58
      tools/audiofile-0.3.6/Makefile.am
  101. Some files were not shown because too many files have changed in this diff Show More

@ -18,13 +18,35 @@ 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 ?= 1
TARGET_N64 ?= 0
# Compiler to use (ido or gcc)
COMPILER ?= ido
ifeq ($(COMPILER),gcc)
NON_MATCHING := 1
endif
# Build for Emscripten/WebGL
TARGET_WEB ?= 0
# Specify the target you are building for, 0 means native
TARGET_ARCH ?= native
TARGET_BITS ?= 0
ifneq ($(TARGET_BITS),0)
BITS := -m$(TARGET_BITS)
else
BITS :=
endif
# 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
# Release
@ -79,6 +101,11 @@ ifeq ($(GRUCODE), f3dex2) # Fast3DEX2
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
@ -95,6 +122,7 @@ endif
endif
endif
endif
endif
ifeq ($(TARGET_N64),0)
NON_MATCHING := 1
@ -106,6 +134,10 @@ ifeq ($(NON_MATCHING),1)
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
@ -137,9 +169,26 @@ endif
# BUILD_DIR is location where all build artifacts are placed
BUILD_DIR_BASE := build
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)
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
@ -151,7 +200,13 @@ 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 := asm lib
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
@ -177,6 +232,15 @@ else
endif
endif
ifeq ($(TARGET_N64),0)
OPT_FLAGS += $(BITS)
endif
ifeq ($(TARGET_WEB),1)
OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/
endif
endif
# Use a default opt flag for gcc
ifeq ($(COMPILER),gcc)
OPT_FLAGS := -O2
@ -188,11 +252,80 @@ 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))
ULTRA_S_FILES := $(foreach dir,$(ULTRA_ASM_DIRS),$(wildcard $(dir)/*.s))
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.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 \
func_802F7140.c \
func_802F71F0.c \
func_802F4A20.c \
EU_D_802f4330.c \
D_802F4380.c \
osLeoDiskInit.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 \
__osDevMgrMain.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
ifeq ($(VERSION),sh)
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
@ -220,6 +353,7 @@ SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.ctl.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))
@ -232,21 +366,27 @@ GODDARD_O_FILES := $(foreach file,$(GODDARD_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
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/**/*.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 ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
CROSS := mips64-linux-gnu-
else
else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
CROSS := mips64-elf-
endif
@ -277,8 +417,6 @@ ifeq ($(TARGET_N64),1)
CC_CFLAGS := -fno-builtin
endif
INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I .
# 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 -Wno-main -DNON_MATCHING -DAVOID_UB $(VERSION_CFLAGS) $(GRUCODE_CFLAGS)
@ -300,7 +438,51 @@ ifeq ($(shell getconf LONG_BIT), 32)
export QEMU_GUEST_BASE := 1
else
# Ensure that gcc treats the code as 32-bit
CC_CHECK += -m32
CC_CHECK += $(BITS)
endif
else # TARGET_N64
AS := as
ifneq ($(TARGET_WEB),1)
CC := $(CROSS)gcc
CXX := $(CROSS)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) `$(CROSS)sdl2-config --cflags`
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)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) `$(CROSS)pkg-config --cflags libusb-1.0 glfw3` `$(CROSS)sdl2-config --cflags`
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)pkg-config --cflags libusb-1.0 glfw3` `$(CROSS)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 := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(CROSS)sdl2-config --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static
else
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(CROSS)sdl2-config --libs` -no-pie -lpthread `$(CROSS)pkg-config --libs libusb-1.0 glfw3` -lasound -lX11 -lXrandr -lpulse
endif
endif
endif
# Prevent a crash with -sopt
@ -333,23 +515,32 @@ endif
###################### 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)
cleantools:
$(MAKE) -s -C tools clean
distclean:
$(RM) -r $(BUILD_DIR_BASE)
./extract_assets.py --clean
@ -402,6 +593,7 @@ $(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/$(VERSION)/define_text.inc.c
endif
endif
$(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h
$(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/
$(TEXTCONV) charmap.txt $@ $@
@ -410,6 +602,8 @@ $(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h t
$(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/
$(TEXTCONV) charmap.txt $@ $@
O_FILES += $(wildcard $(BUILD_DIR)/bin/$(VERSION)/*.o)
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
@ -444,6 +638,7 @@ $(BUILD_DIR)/%.ci4: %.ci4.png
# 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
@ -473,6 +668,7 @@ $(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0.s
$(BUILD_DIR)/%.mio0.s: $(BUILD_DIR)/%.mio0
printf ".section .data\n\n.incbin \"$<\"\n" > $@
endif
$(BUILD_DIR)/%.table: %.aiff
$(AIFF_EXTRACT_CODEBOOK) $< >$@
@ -510,8 +706,30 @@ $(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o
$(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s
$(AS) $(ASFLAGS) -o $@ $<
ifeq ($(TARGET_N64),1)
$(SOUND_BIN_DIR)/%.s: $(SOUND_BIN_DIR)/%
printf ".section .data\n\n.incbin \"$<\"\n" > $@
else
$(SOUND_BIN_DIR)/sound_data.ctl.c: $(SOUND_BIN_DIR)/sound_data.ctl
echo "unsigned char gSoundDataADSR[] = {" > $@
hexdump -v -e '1/1 "0x%X,"' $< >> $@
echo "};" >> $@
$(SOUND_BIN_DIR)/sound_data.tbl.c: $(SOUND_BIN_DIR)/sound_data.tbl
echo "unsigned char gSoundDataRaw[] = {" > $@
hexdump -v -e '1/1 "0x%X,"' $< >> $@
echo "};" >> $@
$(SOUND_BIN_DIR)/sequences.bin.c: $(SOUND_BIN_DIR)/sequences.bin
echo "unsigned char gMusicData[] = {" > $@
hexdump -v -e '1/1 "0x%X,"' $< >> $@
echo "};" >> $@
$(SOUND_BIN_DIR)/bank_sets.c: $(SOUND_BIN_DIR)/bank_sets
echo "unsigned char gBankSetsData[] = {" > $@
hexdump -v -e '1/1 "0x%X,"' $< >> $@
echo "};" >> $@
endif
$(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h
@ -578,6 +796,10 @@ $(GLOBAL_ASM_DEP).$(NON_MATCHING):
@rm -f $(GLOBAL_ASM_DEP).*
touch $@
$(BUILD_DIR)/%.o: %.cpp
@$(CXX) -fsyntax-only $(CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
$(CXX) -c $(CFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
@$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
$(CC) -c $(CFLAGS) -o $@ $<
@ -590,6 +812,7 @@ $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
ifeq ($(TARGET_N64),1)
$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
$(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<
@ -610,6 +833,11 @@ $(ROM): $(ELF)
$(BUILD_DIR)/$(TARGET).objdump: $(ELF)
$(OBJDUMP) -D $< > $@
else
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
endif
.PHONY: all clean distclean default diff test load libultra

@ -2499,6 +2499,7 @@ static const Lights1 segment2_lights_unused = gdSPDefLights1(
// 0x02014470 - 0x020144B0
static const Mtx matrix_identity = {
#ifdef TARGET_N64
{{0x00010000, 0x00000000,
0x00000001, 0x00000000},
{0x00000000, 0x00010000,
@ -2507,19 +2508,32 @@ static const Mtx matrix_identity = {
0x00000000, 0x00000000},
{0x00000000, 0x00000000,
0x00000000, 0x00000000}}
#else
{{1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}}
#endif
};
// 0x020144B0 - 0x020144F0
static const Mtx matrix_fullscreen = {
#if TARGET_N64
{{0x00000000, 0x00000000,
0x00000000, 0x00000000},
{0x00000000, 0xffff0000,
0xffffffff, 0xffff0001},
{0x01990000, 0x00000000,
0x00000222, 0x00000000},
{((65536 * 2 / SCREEN_WIDTH) << 16) | 0, 0x00000000,
(0 << 16) | (65536 * 2 / SCREEN_HEIGHT), 0x00000000},
{0x00000000, 0x00000000,
0x00000000, 0x00000000}}
#else
{{2.0f / SCREEN_WIDTH, 0.0f, 0.0f, 0.0f},
{0.0f, 2.0f / SCREEN_HEIGHT, 0.0f, 0.0f},
{0.0f, 0.0f, -1.0f, 0.0f},
{-1.0f, -1.0f, -1.0f, 1.0f}}
#endif
};

@ -215,7 +215,7 @@ def main():
input = image[pos : pos + size]
os.makedirs(os.path.dirname(asset), exist_ok=True)
if asset.endswith(".png"):
with tempfile.NamedTemporaryFile(prefix="asset") as png_file:
with tempfile.NamedTemporaryFile(prefix="asset", delete=False) as png_file:
png_file.write(input)
png_file.flush()
if asset.startswith("textures/skyboxes/") or asset.startswith("levels/ending/cake"):
@ -278,4 +278,4 @@ def main():
f.write(output)
main()
main()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -87,6 +87,12 @@
*
*/
#ifdef F3DEX_GBI_2E
# ifndef F3DEX_GBI_2
# define F3DEX_GBI_2
# endif
#endif
#ifdef F3DEX_GBI_2
# ifndef F3DEX_GBI
# define F3DEX_GBI
@ -1103,7 +1109,11 @@
* Vertex (set up for use with colors)
*/
typedef struct {
#ifdef TARGET_N64
short ob[3]; /* x, y, z */
#else
float ob[3]; /* x, y, z */
#endif
unsigned short flag;
short tc[2]; /* texture coord */
unsigned char cn[4]; /* color & alpha */
@ -1113,7 +1123,11 @@ typedef struct {
* Vertex (set up for use with normals)
*/
typedef struct {
#ifdef TARGET_N64
short ob[3]; /* x, y, z */
#else
float ob[3]; /* x, y, z */
#endif
unsigned short flag;
short tc[2]; /* texture coord */
signed char n[3]; /* normal */
@ -1162,6 +1176,7 @@ typedef struct {
unsigned char v[3];
} Tri;
#ifdef TARGET_N64
/*
* 4x4 matrix, fixed point s15.16 format.
* First 8 words are integer portion of the 4x4 matrix
@ -1173,6 +1188,11 @@ typedef union {
Mtx_t m;
long long int force_structure_alignment;
} Mtx;
#else
typedef struct {
float m[4][4];
} Mtx;
#endif
/*
* Viewport
@ -4396,6 +4416,26 @@ typedef union {
}}
/* Fraction never used in fill */
#ifdef F3DEX_GBI_2E
#define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \
{ \
Gfx *_g0 = (Gfx *)(pkt), *_g1 = (Gfx *)(pkt); \
_g0->words.w0 = _SHIFTL(G_FILLRECT, 24, 8) | \
_SHIFTL((lrx), 2, 22); \
_g0->words.w1 = _SHIFTL((lry), 2, 22); \
_g1->words.w0 = _SHIFTL((ulx), 2, 22); \
_g1->words.w1 = _SHIFTL((uly), 2, 22); \
}
#define gsDPFillRectangle(ulx, uly, lrx, lry) \
{{ \
(_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 2, 22)), \
_SHIFTL((lry), 2, 22), \
}}, \
{{ \
_SHIFTL((ulx), 2, 22), \
_SHIFTL((uly), 2, 22), \
}}
#else
#define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \
{ \
Gfx *_g = (Gfx *)(pkt); \
@ -4404,15 +4444,16 @@ typedef union {
_SHIFTL((lrx), 14, 10) | _SHIFTL((lry), 2, 10));\
_g->words.w1 = (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10));\
}
#define gsDPFillRectangle(ulx, uly, lrx, lry) \
{{ \
(_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 14, 10) | \
_SHIFTL((lry), 2, 10)), \
(_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10)) \
}}
#endif
/* like gDPFillRectangle but accepts negative arguments */
#ifndef F3DEX_GBI_2E
#define gDPScisFillRectangle(pkt, ulx, uly, lrx, lry) \
{ \
Gfx *_g = (Gfx *)(pkt); \
@ -4423,6 +4464,7 @@ typedef union {
_g->words.w1 = (_SHIFTL(MAX((ulx),0), 14, 10) | \
_SHIFTL(MAX((uly),0), 2, 10)); \
}
#endif
#define gDPSetConvert(pkt, k0, k1, k2, k3, k4, k5) \
{ \
@ -4620,6 +4662,46 @@ typedef union {
gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \
gImmp1(pkt, G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \
}
#elif defined(F3DEX_GBI_2E)
# define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\
{ \
Gfx *_g0 = (Gfx *)(pkt), *_g1 = (Gfx *)(pkt), *_g2 = (Gfx *)(pkt); \
\
_g0->words.w0 = _SHIFTL(G_TEXRECT, 24, 8) | \
_SHIFTL((xh), 0, 24); \
_g0->words.w1 = _SHIFTL((yh), 0, 24); \
_g1->words.w0 = (_SHIFTL(tile, 24, 3) | _SHIFTL((xl), 0, 24)); \
_g1->words.w1 = _SHIFTL((yl), 0, 24); \
_g2->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \
_g2->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \
}
# define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
{{ \
(_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL((xh), 0, 24)), \
_SHIFTL((yh), 0, 24), \
}}, \
{{ \
(_SHIFTL((tile), 24, 3) | _SHIFTL((xl), 0, 24)), \
_SHIFTL((yl), 0, 24), \
}}, \
{{ \
_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \
_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \
}}
# define gSPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
{ \
Gfx *_g0 = (Gfx *)(pkt), *_g1 = (Gfx *)(pkt), *_g2 = (Gfx *)(pkt); \
\
_g0->words.w0 = _SHIFTL(G_TEXRECTFLIP, 24, 8) | \
_SHIFTL((xh), 0, 24); \
_g0->words.w1 = _SHIFTL((yh), 0, 24); \
_g1->words.w0 = (_SHIFTL(tile, 24, 3) | _SHIFTL((xl), 0, 24)); \
_g1->words.w1 = _SHIFTL((yl), 0, 24); \
_g2->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \
_g2->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \
}
#else
# define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\
{ \

@ -53,14 +53,14 @@ extern "C" {
typedef struct {
u16 type; /* Controller Type */
u8 status; /* Controller status */
u8 errno;
u8 errnum;
}OSContStatus;
typedef struct {
u16 button;
s8 stick_x; /* -80 <= stick_x <= 80 */
s8 stick_y; /* -80 <= stick_y <= 80 */
u8 errno;
u8 errnum;
} OSContPad;
typedef struct {
@ -68,7 +68,7 @@ typedef struct {
u8 databuffer[32]; /* address of the data buffer */
u8 addressCrc; /* CRC code for address */
u8 dataCrc; /* CRC code for data */
u8 errno;
u8 errnum;
} OSContRamIo;

@ -81,7 +81,4 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC
OSMesgQueue *osPiGetCmdQueue(void);
s32 osPiWriteIo(uintptr_t devAddr, u32 data);
s32 osPiReadIo(uintptr_t devAddr, u32 *data);
s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size);
s32 osEPiRawStartDma(OSPiHandle *piHandle, s32 dir, u32 cart_addr, void *dram_addr, size_t size);
#endif

@ -37,6 +37,8 @@ typedef s32 intptr_t;
typedef s32 ptrdiff_t;
#else
#include <stddef.h>
#include <stdint.h>
typedef ptrdiff_t ssize_t;
#endif
#endif

@ -28,10 +28,15 @@
#define SCREEN_HEIGHT 240
// Border Height Define for NTSC Versions
#ifdef TARGET_N64
#ifndef VERSION_EU
#define BORDER_HEIGHT 8
#else
#define BORDER_HEIGHT 1
#endif
#else
// What's the point of having a border?
#define BORDER_HEIGHT 0
#endif
#endif

@ -0,0 +1,20 @@
#ifndef GFX_DIMENSIONS_H
#define GFX_DIMENSIONS_H
#ifndef TARGET_N64
#include <math.h>
#include "pc/gfx/gfx_pc.h"
#define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio + (v))
#define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH / 2 + SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio - (v))
#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v))
#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v))
#define GFX_DIMENSIONS_ASPECT_RATIO (gfx_current_dimensions.aspect_ratio)
#else
#define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (v)
#define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH - (v))
#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) (v)
#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH - (v))
#define GFX_DIMENSIONS_ASPECT_RATIO (4.0f / 3.0f)
#endif
#endif

@ -275,4 +275,10 @@
#define GET_OR_SET(op, var) \
CMD_BBBB(0x3C, 0x04, op, var)
#define ADV_DEMO() \
CMD_BBH(0x3D, 0x04, 0x0000)
#define CLEAR_DEMO_PTR() \
CMD_BBH(0x3E, 0x04, 0x0000)
#endif

@ -2,7 +2,7 @@
#define LEVEL_MISC_MACROS_H
#define MACRO_OBJECT_WITH_BEH_PARAM(preset, yaw, posX, posY, posZ, behParam) \
(((yaw * 0x10 / 45) << 9) | (preset + 0x1F)), posX, posY, posZ, behParam
((s16)((yaw * 0x10 / 45) << 9) | (preset + 0x1F)), posX, posY, posZ, behParam
#define MACRO_OBJECT(preset, yaw, posX, posY, posZ) \
MACRO_OBJECT_WITH_BEH_PARAM(preset, yaw, posX, posY, posZ, 0)

@ -46,6 +46,7 @@
#define ALIGNED16
#endif
#ifdef TARGET_N64
// convert a virtual address to physical.
#define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr) & 0x1FFFFFFF)
@ -54,5 +55,11 @@
// another way of converting virtual to physical
#define VIRTUAL_TO_PHYSICAL2(addr) ((u8 *)(addr) - 0x80000000U)
#else
// no conversion for pc port other than cast
#define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr))
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr))
#define VIRTUAL_TO_PHYSICAL2(addr) ((void *)(addr))
#endif
#endif

@ -1,9 +1,15 @@
#ifndef SEGMENT_SYMBOLS_H
#define SEGMENT_SYMBOLS_H
#ifdef TARGET_N64
#define DECLARE_SEGMENT(name) \
extern u8 _##name##SegmentRomStart[]; \
extern u8 _##name##SegmentRomEnd[];
#else
#define DECLARE_SEGMENT(name) \
static u8 _##name##SegmentRomStart[1]; \
static u8 _##name##SegmentRomEnd[1];
#endif
#define DECLARE_ACTOR_SEGMENT(name) \
DECLARE_SEGMENT(name##_mio0) \
@ -37,7 +43,11 @@ DECLARE_ACTOR_SEGMENT(group17)
DECLARE_SEGMENT(behavior)
DECLARE_SEGMENT(scripts)
DECLARE_SEGMENT(goddard)
#ifdef TARGET_N64
extern u8 _goddardSegmentStart[];
#else
static u8 _goddardSegmentStart[1];
#endif
DECLARE_LEVEL_SEGMENT(menu)
DECLARE_LEVEL_SEGMENT(intro)

@ -44,17 +44,24 @@ const LevelScript level_intro_entry_2[] = {
INIT_LEVEL(),
BLACKOUT(/*active*/ TRUE),
FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd),
//LOAD_MARIO_HEAD(/*loadHeadID*/ REGULAR_FACE),
LOAD_MARIO_HEAD(/*loadHeadID*/ REGULAR_FACE),
LOAD_RAW(/*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd),
LOAD_MIO0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_mio0SegmentRomStart, _title_screen_bg_mio0SegmentRomEnd),
ALLOC_LEVEL_POOL(),
//AREA(/*index*/ 1, intro_geo_00035C),
//END_AREA(),
AREA(/*index*/ 1, intro_geo_00035C),
END_AREA(),
FREE_LEVEL_POOL(),
SLEEP(/*frames*/ 2),
BLACKOUT(/*active*/ FALSE),
//LOAD_AREA(/*area*/ 1),
CLEAR_DEMO_PTR(), // we need to do this or else file select will be tainted with inputs
GET_OR_SET(/*op*/ OP_GET, /*var*/ 5),
JUMP_IF(/*op*/ OP_EQ, /*arg*/ 1, script_intro_L1), // was start pressed when demo ended last time?
LOAD_AREA(/*area*/ 1),
SET_MENU_MUSIC(/*seq*/ 0x0002),
TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_STAR, /*time*/ 20, /*color*/ 0x00, 0x00, 0x00),

@ -50,7 +50,7 @@ const LevelScript level_main_menu_entry_1[] = {
GET_OR_SET(/*op*/ OP_SET, /*var*/ VAR_CURR_SAVE_FILE_NUM),
STOP_MUSIC(/*fadeOutTime*/ 0x00BE),
TRANSITION(/*transType*/ WARP_TRANSITION_FADE_INTO_COLOR, /*time*/ 16, /*color*/ 0xFF, 0xFF, 0xFF),
SLEEP(/*frames*/ 16),
SLEEP(/*frames*/ 24),
CLEAR_LEVEL(),
SLEEP_BEFORE_EXIT(/*frames*/ 1),
SET_REG(/*value*/ LEVEL_CASTLE_GROUNDS),
@ -72,15 +72,24 @@ const LevelScript level_main_menu_entry_2[] = {
/*25*/ FREE_LEVEL_POOL(),
/*26*/ LOAD_AREA(/*area*/ 2),
#ifndef TARGET_N64
// sVisibleStars is set to 0 during FIXED_LOAD above on N64, but not on PC-port.
// lvl_init_act_selector_values_and_stars must be called here otherwise the
// previous value is retained and causes incorrect drawing during the 16 transition
// frames.
CALL(/*arg*/ 0, /*func*/ lvl_init_act_selector_values_and_stars),
#endif
/*27*/ TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_COLOR, /*time*/ 16, /*color*/ 0xFF, 0xFF, 0xFF),
/*29*/ SLEEP(/*frames*/ 16),
/*30*/ SET_MENU_MUSIC(/*seq*/ 0x000D),
#ifdef TARGET_N64
/*31*/ CALL(/*arg*/ 0, /*func*/ lvl_init_act_selector_values_and_stars),
#endif
/*33*/ CALL_LOOP(/*arg*/ 0, /*func*/ lvl_update_obj_and_load_act_button_actions),
/*35*/ GET_OR_SET(/*op*/ OP_SET, /*var*/ VAR_CURR_ACT_NUM),
/*36*/ STOP_MUSIC(/*fadeOutTime*/ 0x00BE),
/*37*/ TRANSITION(/*transType*/ WARP_TRANSITION_FADE_INTO_COLOR, /*time*/ 16, /*color*/ 0xFF, 0xFF, 0xFF),
/*39*/ SLEEP(/*frames*/ 16),
/*39*/ SLEEP(/*frames*/ 24),
/*40*/ CLEAR_LEVEL(),
/*41*/ SLEEP_BEFORE_EXIT(/*frames*/ 1),
// L1:

@ -1,5 +1,9 @@
#include "libultra_internal.h"
#ifndef TARGET_N64
#include <string.h>
#endif
#ifdef TARGET_N64
void guMtxF2L(float mf[4][4], Mtx *m) {
int r, c;
s32 tmp1;
@ -35,6 +39,11 @@ void guMtxL2F(float mf[4][4], Mtx *m) {
}
}
}
#else
void guMtxF2L(float mf[4][4], Mtx *m) {
memcpy(m, mf, sizeof(Mtx));
}
#endif
void guMtxIdentF(float mf[4][4]) {
int r, c;
@ -49,7 +58,11 @@ void guMtxIdentF(float mf[4][4]) {
}
}
void guMtxIdent(Mtx *m) {
#ifdef TARGET_N64
float mf[4][4];
guMtxIdentF(mf);
guMtxF2L(mf, m);
#else
guMtxIdentF(m->m);
#endif
}

@ -61,8 +61,8 @@ void __osContGetInitData(u8 *a0, OSContStatus *status) {
sp14 = &(D_80365CE0[0].request);
for (i = 0; i < _osCont_numControllers; i++, sp14++, status++) {
spc = *(OSContPackedRequest *) sp14;
status->errno = (spc.unk02 & 0xc0) >> 4;
if (status->errno == 0) {
status->errnum = (spc.unk02 & 0xc0) >> 4;
if (status->errnum == 0) {
status->type = spc.unk05 << 8 | spc.unk04;
status->status = spc.unk06;

@ -41,8 +41,8 @@ void osContGetReadData(OSContPad *pad) {
spc = &D_80365CE0[0].read;
for (i = 0; i < _osCont_numControllers; i++, spc++, pad++) {
sp4 = *spc;
pad->errno = (sp4.unk02 & 0xc0) >> 4;
if (pad->errno == 0) {
pad->errnum = (sp4.unk02 & 0xc0) >> 4;
if (pad->errnum == 0) {
pad->button = sp4.button;
pad->stick_x = sp4.rawStickX;
pad->stick_y = sp4.rawStickY;

@ -0,0 +1,4 @@
You need audiofile, sdl2, glew, glfw
for Windows you also need mingw32
>https://packages.msys2.org/base/mingw-w64-SDL2
>https://packages.msys2.org/base/mingw-w64-glew

@ -66,7 +66,7 @@ chan_stereoheadseteffects 1
chan_setdyntable .channel59_table
chan_jump .main_loop_023589
# Main loop for standard, non-continuous sound effects
.main_loop_023589:
chan_delay1
chan_ioreadval 0
@ -80,17 +80,17 @@ chan_iowriteval 5
chan_ioreadval 4
chan_dyncall
# keep looping until layer 0 finishes or we are told to stop or to play something else
.poll_023589:
chan_delay1
chan_ioreadval 0
chan_bltz .skip_023589 # if we have a signal:
chan_beqz .force_stop_023589 # told to stop
chan_jump .start_playing_023589 # told to play something else
chan_bltz .skip_023589
chan_beqz .force_stop_023589
chan_jump .start_playing_023589
.skip_023589:
chan_testlayerfinished 0
chan_beqz .poll_023589 # if layer 0 hasn't finished, keep polling
chan_jump .main_loop_023589 # otherwise go back to the main loop
chan_beqz .poll_023589
chan_jump .main_loop_023589
.force_stop_023589:
chan_freelayer 0
chan_freelayer 1
@ -133,7 +133,7 @@ chan_stereoheadseteffects 1
chan_setdyntable .channel6_table
chan_jump .main_loop_146
# Main loop for moving, env and air sound effects, which play continuously
.main_loop_146:
chan_delay1
chan_ioreadval 0
@ -148,7 +148,7 @@ chan_iowriteval 5
chan_ioreadval 4
chan_dyncall
# keep looping until we are told to stop or to play something else
.poll_146:
chan_delay1
chan_ioreadval 0
@ -170,7 +170,7 @@ chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channel7_table
# Loop for menu sound effects
.main_loop_7:
chan_delay1
chan_ioreadval 0
@ -187,19 +187,19 @@ chan_setpanmix 127
chan_ioreadval 4
chan_dyncall
# keep looping until layer 0 finishes or we are told to stop or to play something else
.poll_7:
chan_delay1
chan_ioreadval 0
chan_bltz .skip_7 # if we have a signal:
chan_beqz .force_stop_7 # told to stop
chan_bltz .skip_7
chan_beqz .force_stop_7
chan_unreservenotes
chan_jump .start_playing_7 # told to play something else
chan_jump .start_playing_7
.skip_7:
chan_testlayerfinished 0
chan_beqz .poll_7 # if layer 0 hasn't finished, keep polling
chan_beqz .poll_7
chan_unreservenotes
chan_jump .main_loop_7 # otherwise go back to the main loop
chan_jump .main_loop_7
.force_stop_7:
chan_freelayer 0
chan_freelayer 1
@ -207,7 +207,7 @@ chan_freelayer 2
chan_unreservenotes
chan_jump .main_loop_7
# Delay for a number of ticks (1-255) in an interruptible manner.
.delay:
chan_writeseq_nextinstr 0, 1
chan_loop 20
@ -222,15 +222,15 @@ chan_end
chan_setpanmix 127
chan_setvolscale 127
chan_setvibratoextent 0
chan_ioreadval 1 # IO slots 0-3 are reset to -1 when read; restore the value
chan_ioreadval 1
chan_iowriteval 0
chan_break # break out of the loop
chan_break # force the caller to return immediately
chan_break
chan_break
chan_end
# Set reverb in way that takes area echo level and volume into account. This
# is done by writing to IO slot 5 and letting get_sound_reverb in external.c
# do the necessary math.
.set_reverb:
chan_writeseq_nextinstr 0, 1
chan_setreverb 10
@ -977,7 +977,7 @@ layer_portamento 0x81, 42, 255
layer_note1 37, 0x1e, 105
layer_end
.sound_action_climb_down_tree: # unused
.sound_action_climb_down_tree:
chan_setbank 0
chan_setinstr 1
chan_setlayer 0, .layer_579
@ -988,7 +988,7 @@ layer_portamento 0x81, 44, 255
layer_note1 40, 0xb4, 100
layer_end
.chan_582: # unused
.chan_582:
chan_setbank 0
chan_setinstr 2
chan_setlayer 0, .layer_58A
@ -1408,7 +1408,7 @@ layer_note1 42, 0x8, 127
layer_end
.ifndef VERSION_JP
.chan_828: # unused
.chan_828:
chan_setbank 7
chan_setinstr 3
chan_setlayer 0, .layer_83C

@ -765,6 +765,7 @@ void func_eu_802e9bec(s32 player, s32 channel, s32 arg2) {
#else
#ifdef TARGET_N64
struct SPTask *create_next_audio_frame_task(void) {
u32 samplesRemainingInAI;
s32 writtenCmds;
@ -868,6 +869,24 @@ struct SPTask *create_next_audio_frame_task(void) {
return gAudioTask;
}
#endif
#endif
#ifndef TARGET_N64
struct SPTask *create_next_audio_frame_task(void) {
return NULL;
}
void create_next_audio_buffer(s16 *samples, u32 num_samples) {
gAudioFrameCount++;
if (sGameLoopTicked != 0) {
update_game_sound();
sGameLoopTicked = 0;
}
s32 writtenCmds;
synthesis_execute(gAudioCmdBuffers[0], &writtenCmds, samples, num_samples);
gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount);
decrease_sample_dma_ttls();
}
#endif
void play_sound(s32 soundBits, f32 *pos) {
sSoundRequests[sSoundRequestCount].soundBits = soundBits;