diff --git a/.github/workflows/ci_gcc.yml b/.github/workflows/ci_gcc.yml index 054270ab..2927759b 100644 --- a/.github/workflows/ci_gcc.yml +++ b/.github/workflows/ci_gcc.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - version: [L] # [H, I, I_patch, J, K, L] + version: [K, L] # [H, I, I_patch, J, K, L] suffix: [~, _d, _rom] steps: @@ -32,7 +32,7 @@ jobs: token: ${{ secrets.SECRETTOKEN }} path: deps_repo - name: Get the dependency - run: cp deps_repo/libultra/${{ matrix.version }}/* . + run: cp deps_repo/libultra/${{ matrix.version }}/* base/${{ matrix.version }} - name: Setup run: make setup -j $(nproc) TARGET=libgultra${{ matrix.suffix }} VERSION=${{ matrix.version }} diff --git a/.github/workflows/ci_ido.yml b/.github/workflows/ci_ido.yml index 4d7f8dca..dd12a67a 100644 --- a/.github/workflows/ci_ido.yml +++ b/.github/workflows/ci_ido.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - version: [L] # [E, F, G, H, I, I_patch, J, K, L] + version: [K, L] # [E, F, G, H, I, I_patch, J, K, L] suffix: [~, _rom] # [~, _d, _rom] steps: @@ -32,7 +32,7 @@ jobs: token: ${{ secrets.SECRETTOKEN }} path: deps_repo - name: Get the dependency - run: cp deps_repo/libultra/${{ matrix.version }}/* . + run: cp deps_repo/libultra/${{ matrix.version }}/* base/${{ matrix.version }} - name: Setup run: make setup -j $(nproc) TARGET=libultra${{ matrix.suffix }} VERSION=${{ matrix.version }} diff --git a/Makefile b/Makefile index cf87da47..6ef95ed8 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,13 @@ NON_MATCHING ?= 0 # libgultra_rom, libgultra_d, libgultra # libultra_rom, libultra_d, libultra TARGET ?= libgultra_rom +VERSION ?= L CROSS ?= mips-linux-gnu- -BASE_DIR := base_$(TARGET) -BASE_AR := $(TARGET).a +BASE_DIR := extracted/$(VERSION)/$(TARGET) +BASE_AR := base/$(VERSION)/$(TARGET).a BUILD_ROOT := build -BUILD_DIR := $(BUILD_ROOT)/$(TARGET) +BUILD_DIR := $(BUILD_ROOT)/$(VERSION)/$(TARGET) BUILD_AR := $(BUILD_DIR)/$(TARGET).a WORKING_DIR := $(shell pwd) @@ -17,6 +18,18 @@ WORKING_DIR := $(shell pwd) CPP := cpp -P AR := ar +VERSION_D := 1 +VERSION_E := 2 +VERSION_F := 3 +VERSION_G := 4 +VERSION_H := 5 +VERSION_I := 6 +VERSION_J := 7 +VERSION_K := 8 +VERSION_L := 9 + +VERSION_DEFINE := -DBUILD_VERSION=$(VERSION_$(VERSION)) -DBUILD_VERSION_STRING=\"2.0$(VERSION)\" + ifeq ($(findstring libgultra,$(TARGET)),libgultra) -include Makefile.gcc else ifeq ($(findstring libultra,$(TARGET)),libultra) @@ -40,8 +53,7 @@ ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) S_FILES := $(foreach dir,$(SRC_DIRS) $(ASM_DIRS),$(wildcard $(dir)/*.s)) O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \ - $(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \ - $(foreach f,$(wildcard $(BASE_DIR)/*),$(BUILD_DIR)/$f) + $(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) # Because we patch the object file timestamps, we can't use them as the targets since they'll always be older than the C file # Therefore instead we use marker files that have actual timestamps as the dependencies for the archive MARKER_FILES := $(O_FILES:.o=.marker) @@ -61,6 +73,17 @@ AR_OLD := $(AR) endif BASE_OBJS := $(wildcard $(BASE_DIR)/*.o) + +# Check to make sure the current version has been set up +ifneq ($(NON_MATCHING),1) +ifeq ($(BASE_OBJS),) +# Ignore this check if the user is currently running setup, clean or distclean +ifeq ($(filter $(MAKECMDGOALS),setup clean distclean),) +$(error Current version ($(TARGET) 2.0$(VERSION)) has not been setup!) +endif +endif +endif + # Try to find a file corresponding to an archive file in any of src/ asm/ or the base directory, prioritizing src then asm then the original file AR_ORDER = $(foreach f,$(shell $(AR) t $(BASE_AR)),$(shell find $(BUILD_DIR)/src $(BUILD_DIR)/asm $(BUILD_DIR)/$(BASE_DIR) -iname $f -type f -print -quit)) MATCHED_OBJS = $(filter-out $(BUILD_DIR)/$(BASE_DIR)/%,$(AR_ORDER)) @@ -69,7 +92,7 @@ NUM_OBJS = $(words $(AR_ORDER)) NUM_OBJS_MATCHED = $(words $(MATCHED_OBJS)) NUM_OBJS_UNMATCHED = $(words $(UNMATCHED_OBJS)) -$(shell mkdir -p asm $(BASE_DIR) src $(BUILD_DIR)/$(BASE_DIR) $(foreach dir,$(ASM_DIRS) $(SRC_DIRS),$(BUILD_DIR)/$(dir))) +$(shell mkdir -p asm $(BASE_DIR) src $(foreach dir,$(ASM_DIRS) $(SRC_DIRS),$(BUILD_DIR)/$(dir))) .PHONY: all clean distclean setup all: $(BUILD_AR) @@ -85,15 +108,15 @@ ifneq ($(NON_MATCHING),1) endif clean: - $(RM) -rf $(BUILD_ROOT) + $(RM) -rf $(BUILD_DIR) -distclean: clean +distclean: $(MAKE) -C tools distclean - $(RM) -rf $(BASE_DIR) + $(RM) -rf extracted/ $(BUILD_ROOT) setup: $(MAKE) -C tools - cd $(BASE_DIR) && $(AR) xo ../$(BASE_AR) + cd $(BASE_DIR) && $(AR) xo $(WORKING_DIR)/$(BASE_AR) chmod -R +rw $(BASE_DIR) ifeq ($(COMPILER),ido) export CROSS=$(CROSS) && ./tools/strip_debug.sh $(BASE_DIR) diff --git a/Makefile.gcc b/Makefile.gcc index dce908b0..0cb3f6ee 100644 --- a/Makefile.gcc +++ b/Makefile.gcc @@ -9,7 +9,7 @@ export COMPILER_PATH := $(WORKING_DIR)/tools/gcc CFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -D_LANGUAGE_C ASFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64 -x assembler-with-cpp -CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) +CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE) IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/gcc -I $(WORKING_DIR)/include/PR MIPS_VERSION := -mips3 ASOPTFLAGS := diff --git a/Makefile.ido b/Makefile.ido index 54c8ff78..8cfb28fe 100644 --- a/Makefile.ido +++ b/Makefile.ido @@ -9,7 +9,7 @@ export COMPILER_PATH := $(WORKING_DIR)/tools/ido CFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -Xcpluscomm -fullwarn -woff 516,649,838,712 ASFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -woff 516,649,838,712 -CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(PICFLAGS) +CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(VERSION_DEFINE) $(PICFLAGS) IINC = -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/ido -I $(WORKING_DIR)/include/PR MIPS_VERSION := -mips2 -o32 PICFLAGS := -non_shared diff --git a/README.md b/README.md index ce88d5cb..0f7eaddb 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,15 @@ Currently this repo supports building the following versions: | 2.0I | :x: / :x: | :x: / :x: | :x: / :x: | | 2.0I_patch | :x: / :x: | :x: / :x: | :x: / :x: | | 2.0J | :x: / :x: | :x: / :x: | :x: / :x: | -| 2.0K | :x: / :x: | :x: / :x: | :x: / :x: | +| 2.0K | :heavy_check_mark: / :heavy_check_mark: | :x: / :heavy_check_mark: | :heavy_check_mark: / :heavy_check_mark: | | 2.0L | :heavy_check_mark: / :heavy_check_mark: | :x: / :heavy_check_mark: | :heavy_check_mark: / :heavy_check_mark: | | ique_v1.5 | :x: | :x: | :x: | ## Preparation -After cloning the repo, put a copy of the target archive on the root of this directory. +After cloning the repo, put a copy of the target archive(s) in their correct version folder in `base/`. +For example, if your target archive is libgultra_rom.a 2.0L then you'd place it in `base/L/`. +If you will be building without a target archive by setting `NON_MATCHING` then you can skip this step. ## Build dependencies @@ -46,5 +48,12 @@ sudo apt install binutils-mips-linux-gnu ## Building -- `make setup` -- `make` +Run make setup with the proper flags set followed by make with optional jobs. +For example, if building the 2.0L PC archive you'd do the following: + +- `make VERSION=L TARGET=libgultra_rom setup` +- `make VERSION=L TARGET=libgultra_rom` + +Every target flag combination requires separate a setup command. + +If building without a target archive using `NON_MATCHING` then you can skip the setup command. diff --git a/base/J/.gitkeep b/base/J/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/base/K/.gitkeep b/base/K/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/base/L/.gitkeep b/base/L/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/include/PR/os_version.h b/include/PR/os_version.h index c485a438..aa10d20e 100644 --- a/include/PR/os_version.h +++ b/include/PR/os_version.h @@ -10,7 +10,17 @@ #ifndef _OS_VERSION_H_ #define _OS_VERSION_H_ -#define OS_MAJOR_VERSION "2.0K" /* major version */ -#define OS_MINOR_VERSION 0 /* patch level */ +#define VERSION_D 1 +#define VERSION_E 2 +#define VERSION_F 3 +#define VERSION_G 4 +#define VERSION_H 5 +#define VERSION_I 6 +#define VERSION_J 7 +#define VERSION_K 8 +#define VERSION_L 9 + +#define OS_MAJOR_VERSION BUILD_VERSION_STRING /* major version */ +#define OS_MINOR_VERSION 0 /* patch level */ #endif /* !_OS_VERSION_H_ */ diff --git a/src/debug/threadprofilestop.c b/src/debug/threadprofilestop.c index 7cc20e7a..4803620b 100644 --- a/src/debug/threadprofilestop.c +++ b/src/debug/threadprofilestop.c @@ -10,8 +10,13 @@ void osThreadProfileStop(void) { #ifndef NDEBUG if (__osThprofFlag == 0) { +#if BUILD_VERSION >= VERSION_L __osRestoreInt(saveMask); __osError(138, 0); +#else + __osError(138, 0); + __osRestoreInt(saveMask); +#endif return; } #endif @@ -23,9 +28,13 @@ void osThreadProfileStop(void) { thprof[id].time += now_time - __osThprofLastTimer; } else { #ifndef NDEBUG +#if BUILD_VERSION >= VERSION_L __osRestoreInt(saveMask); +#endif __osError(147, 1, id); +#if BUILD_VERSION >= VERSION_L saveMask = __osDisableInt(); +#endif #endif } } diff --git a/src/io/conteepprobe.c b/src/io/conteepprobe.c index 5bee6a4b..b19dc495 100644 --- a/src/io/conteepprobe.c +++ b/src/io/conteepprobe.c @@ -26,7 +26,9 @@ s32 osEepromProbe(OSMesgQueue* mq) { } } +#if BUILD_VERSION >= VERSION_L __osEepromRead16K = 0; +#endif __osSiRelAccess(); return ret; } diff --git a/src/io/conteepread.c b/src/io/conteepread.c index 708a9768..8334382a 100644 --- a/src/io/conteepread.c +++ b/src/io/conteepread.c @@ -4,7 +4,9 @@ #include "siint.h" OSPifRam __osEepPifRam ALIGNED(16); +#if BUILD_VERSION >= VERSION_L s32 __osEepromRead16K; +#endif static void __osPackEepReadData(u8 address); s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) { @@ -31,9 +33,12 @@ s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) { if (address >= EEP16K_MAXBLOCKS) { // not technically possible ret = CONT_RANGE_ERROR; - } else { + } +#if BUILD_VERSION >= VERSION_L + else { __osEepromRead16K = 1; } +#endif break; default: ret = CONT_NO_RESPONSE_ERROR; diff --git a/src/io/conteepwrite.c b/src/io/conteepwrite.c index 5c4f4e2e..ba8210f7 100644 --- a/src/io/conteepwrite.c +++ b/src/io/conteepwrite.c @@ -10,7 +10,9 @@ s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) { u8* ptr = (u8*)&__osEepPifRam.ramarray; __OSContEepromFormat eepromformat; OSContStatus sdata; +#if BUILD_VERSION > VERSION_K u8 temp[8]; +#endif __osSiGetAccess(); ret = __osEepStatus(mq, &sdata); @@ -28,12 +30,15 @@ s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) { if (address >= EEP16K_MAXBLOCKS) { // not technically possible ret = CONT_RANGE_ERROR; - } else if (__osEepromRead16K) { + } +#if BUILD_VERSION >= VERSION_L + else if (__osEepromRead16K) { __osEepromRead16K = 0; __osSiRelAccess(); osEepromRead(mq, (address ^ 1), temp); __osSiGetAccess(); } +#endif break; default: ret = CONT_NO_RESPONSE_ERROR;