Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matched 2.0I and 2.0J, fixed matched object count calculation #53

Merged
merged 6 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci_gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [K, L] # [H, I, I_patch, J, K, L]
version: [I, J, K, L] # [H, I, I_patch, J, K, L]
suffix: [~, _d, _rom]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_ido.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [K, L] # [E, F, G, H, I, I_patch, J, K, L]
version: [I, J, K, L] # [E, F, G, H, I, I_patch, J, K, L]
suffix: [~, _rom] # [~, _d, _rom]

steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ tools/ido

# Tool artifacts
ctx.c

libultra_collection/
41 changes: 27 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ VERSION_L := 9

VERSION_DEFINE := -DBUILD_VERSION=$(VERSION_$(VERSION)) -DBUILD_VERSION_STRING=\"2.0$(VERSION)\"

ifeq ($(findstring _d,$(TARGET)),_d)
DEBUGFLAG := -D_DEBUG
else
DEBUGFLAG := -DNDEBUG
endif

ifeq ($(findstring libgultra,$(TARGET)),libgultra)
-include Makefile.gcc
else ifeq ($(findstring libultra,$(TARGET)),libultra)
Expand All @@ -38,12 +44,6 @@ else
$(error Invalid Target)
endif

ifeq ($(findstring _d,$(TARGET)),_d)
CPPFLAGS += -D_DEBUG
else
CPPFLAGS += -DNDEBUG
endif

ifeq ($(findstring _rom,$(TARGET)),_rom)
CPPFLAGS += -D_FINALROM
endif
Expand All @@ -52,11 +52,24 @@ SRC_DIRS := $(shell find src -type d)
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)

# Versions J and below used the C matrix math implementations
MGU_MATRIX_FILES := mtxcatf normalize scale translate
ifneq ($(filter $(VERSION),D E F G H I J),)
S_FILES := $(filter-out $(addprefix src/mgu/,$(MGU_MATRIX_FILES:=.s)),$(S_FILES))
else
C_FILES := $(filter-out $(addprefix src/gu/,$(MGU_MATRIX_FILES:=.c)),$(C_FILES))
endif

C_O_FILES := $(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f)
S_O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f)
O_FILES := $(S_O_FILES) $(C_O_FILES)
# 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)
C_MARKER_FILES := $(C_O_FILES:.o=.marker)
S_MARKER_FILES := $(S_O_FILES:.o=.marker)
S_MARKER_FILES := $(filter-out $(MDEBUG_FILES),$(S_MARKER_FILES))
MARKER_FILES := $(C_MARKER_FILES) $(S_MARKER_FILES)

ifneq ($(NON_MATCHING),1)
COMPARE_OBJ = cmp $(BASE_DIR)/$(@F:.marker=.o) $(@:.marker=.o) && echo "$(@:.marker=.o): OK"
Expand Down Expand Up @@ -85,8 +98,8 @@ 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))
AR_ORDER = $(foreach f,$(shell $(AR) t $(BASE_AR)),$(shell find $(BUILD_DIR)/src $(BUILD_DIR)/asm $(BASE_DIR) -iname $f -type f -print -quit))
MATCHED_OBJS = $(filter-out $(BASE_DIR)/%,$(AR_ORDER))
UNMATCHED_OBJS = $(filter-out $(MATCHED_OBJS),$(AR_ORDER))
NUM_OBJS = $(words $(AR_ORDER))
NUM_OBJS_MATCHED = $(words $(MATCHED_OBJS))
Expand Down Expand Up @@ -131,7 +144,7 @@ ifneq ($(NON_MATCHING),1)
@touch $@
endif

GBIDEFINE := -DF3DEX_GBI_2
GBIDEFINE := -DF3DEX_GBI

$(BUILD_DIR)/src/gu/parse_gbi.marker: GBIDEFINE := -DF3D_GBI
$(BUILD_DIR)/src/gu/us2dex_emu.marker: GBIDEFINE :=
Expand All @@ -142,7 +155,7 @@ $(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE :=
$(BUILD_DIR)/src/voice/%.marker: OPTFLAGS += -DLANG_JAPANESE -I$(WORKING_DIR)/src -I$(WORKING_DIR)/src/voice
$(BUILD_DIR)/src/voice/%.marker: CC := tools/compile_sjis.py -D__CC=$(WORKING_DIR)/$(CC) -D__BUILD_DIR=$(BUILD_DIR)

$(BUILD_DIR)/%.marker: %.c
$(C_MARKER_FILES): $(BUILD_DIR)/%.marker: %.c
cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(OPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(NON_MATCHING),1)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
Expand All @@ -156,7 +169,7 @@ ifneq ($(NON_MATCHING),1)
@touch $@
endif

$(BUILD_DIR)/%.marker: %.s
$(S_MARKER_FILES): $(BUILD_DIR)/%.marker: %.s
cd $(<D) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(ASOPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(NON_MATCHING),1)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
Expand Down
19 changes: 18 additions & 1 deletion Makefile.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,26 @@ 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) $(VERSION_DEFINE)
CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE) $(DEBUGFLAG)
IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/gcc -I $(WORKING_DIR)/include/PR
MIPS_VERSION := -mips3
ASOPTFLAGS :=

ifneq ($(filter $(VERSION),D E F G H I J),)
CFLAGS += -funsigned-char
endif

# 2.0I libgultra_rom was not compiled with -DNDEBUG and instead libgultra had -DNDEBUG
ifneq ($(filter $(VERSION),I),)
ifeq ($(findstring _rom,$(TARGET)),_rom)
DEBUGFLAG :=
else ifeq ($(findstring _d,$(TARGET)),_d)
DEBUGFLAG := -D_DEBUG
else
DEBUGFLAG := -DNDEBUG
endif
endif

ifeq ($(findstring _d,$(TARGET)),_d)
OPTFLAGS := -O0
else
Expand All @@ -33,7 +48,9 @@ export VR4300MUL := ON
$(BUILD_DIR)/src/os/initialize_isv.marker: OPTFLAGS := -O2
$(BUILD_DIR)/src/os/initialize_isv.marker: STRIP = && tools/gcc/strip-2.7 -N initialize_isv.c $(WORKING_DIR)/$(@:.marker=.o)
$(BUILD_DIR)/src/os/assert.marker: OPTFLAGS := -O0
ifeq ($(filter $(VERSION),D E F G H I),)
$(BUILD_DIR)/src/os/seterrorhandler.marker: OPTFLAGS := -O0
endif
$(BUILD_DIR)/src/mgu/%.marker: export VR4300MUL := OFF
$(BUILD_DIR)/src/mgu/rotate.marker: export VR4300MUL := ON
$(BUILD_DIR)/src/debug/%.marker: ASFLAGS += -P
Expand Down
17 changes: 16 additions & 1 deletion Makefile.ido
Original file line number Diff line number Diff line change
Expand Up @@ -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) $(VERSION_DEFINE) $(PICFLAGS)
CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(VERSION_DEFINE) $(PICFLAGS) $(DEBUGFLAG)
IINC = -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/ido -I $(WORKING_DIR)/include/PR
MIPS_VERSION := -mips2 -o32
PICFLAGS := -non_shared
Expand All @@ -18,7 +18,11 @@ ifeq ($(findstring _d,$(TARGET)),_d)
OPTFLAGS := -O1 -g2
ASOPTFLAGS := -O0 -g2
else
ifneq ($(filter $(VERSION),D E F G H I),)
OPTFLAGS := -O1
else
OPTFLAGS := -O2
endif
ASOPTFLAGS := -O1
endif

Expand All @@ -43,3 +47,14 @@ $(BUILD_DIR)/src/libc/llcvt.marker: MIPS_VERSION := -mips3 -32
$(BUILD_DIR)/src/os/exceptasm.marker: MIPS_VERSION := -mips3 -32
$(BUILD_DIR)/src/log/delay.marker: MIPS_VERSION := -mips1 -o32
$(BUILD_DIR)/src/log/delay.marker: PICFLAGS := -KPIC

ifneq ($(filter $(VERSION),D E F G H I),)
$(BUILD_DIR)/src/libc/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/sched/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/gu/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/mgu/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/sp/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/audio/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/rg/%.marker: OPTFLAGS := -O3
$(BUILD_DIR)/src/gt/%.marker: OPTFLAGS := -O3
endif
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Currently this repo supports building the following versions:
| 2.0E | :x: / N/A | :x: / N/A | :x: / N/A |
| 2.0F | :x: / N/A | :x: / N/A | :x: / N/A |
| 2.0G | :x: / N/A | :x: / N/A | :x: / N/A |
| 2.0H | :x: / :x: | :x: / :x: | :x: / :x: |
| 2.0I | :x: / :x: | :x: / :x: | :x: / :x: |
| 2.0H | N/A / :x: | N/A / :x: | N/A / :x: |
| 2.0I | :heavy_check_mark: / :heavy_check_mark: | :x: / :heavy_check_mark: | :heavy_check_mark: / :heavy_check_mark: |
| 2.0I_patch | :x: / :x: | :x: / :x: | :x: / :x: |
| 2.0J | :x: / :x: | :x: / :x: | :x: / :x: |
| 2.0J | :heavy_check_mark: / :heavy_check_mark: | :x: / :heavy_check_mark: | :heavy_check_mark: / :heavy_check_mark: |
| 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: |
Expand Down
Empty file added base/I/.gitkeep
Empty file.
3 changes: 2 additions & 1 deletion include/PR/gu.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <PR/mbi.h>
#include <PR/ultratypes.h>
#include <PR/sptask.h>
#include <PR/os_version.h>

#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
Expand Down Expand Up @@ -192,7 +193,7 @@ extern float cosf(float angle);
extern signed short sins (unsigned short angle);
extern signed short coss (unsigned short angle);
extern float sqrtf(float value);
#ifdef __sgi
#if defined(__sgi) && BUILD_VERSION >= VERSION_K
#pragma intrinsic(sqrtf);
#endif

Expand Down
5 changes: 5 additions & 0 deletions include/PR/os_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern "C" {
#endif

#include <PR/ultratypes.h>
#include <PR/os_version.h>

#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)

Expand Down Expand Up @@ -126,6 +127,10 @@ extern void __osInitialize_emu(void);

#endif /* _FINAL_ROM */

#if BUILD_VERSION < VERSION_K
#undef osInitialize
#endif

/**************************************************************************
*
* Extern variables
Expand Down
8 changes: 8 additions & 0 deletions include/PR/os_internal_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ extern "C" {
#endif

#include "os.h"
#include "os_version.h"

#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)

/* Routine for HW interrupt "handler" */
#if BUILD_VERSION >= VERSION_J
extern void __osSetHWIntrRoutine(OSHWIntr interrupt,
s32 (*handler)(void), void *stackEnd);
extern void __osGetHWIntrRoutine(OSHWIntr interrupt,
s32 (**handler)(void), void **stackEnd);
#else
extern void __osSetHWIntrRoutine(OSHWIntr interrupt,
s32 (*handler)(void));
extern void __osGetHWIntrRoutine(OSHWIntr interrupt,
s32 (**handler)(void));
#endif

/* Routine for global interrupt mask */
extern void __osSetGlobalIntMask(OSHWIntr);
Expand Down
3 changes: 2 additions & 1 deletion include/PR/os_motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern "C" {
#include <PR/ultratypes.h>
#include "os_message.h"
#include "os_pfs.h"
#include "os_version.h"


#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
Expand Down Expand Up @@ -62,7 +63,7 @@ extern "C" {
/* Rumble PAK interface */

extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int);
#if 1
#if BUILD_VERSION >= VERSION_J
#define MOTOR_START 1
#define MOTOR_STOP 0
#define osMotorStart(x) __osMotorAccess((x), MOTOR_START)
Expand Down
47 changes: 23 additions & 24 deletions src/audio/csplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *c)
seqp->initOsc = c->initOsc;
seqp->updateOsc = c->updateOsc;
seqp->stopOsc = c->stopOsc;

seqp->nextEvent.type = AL_SEQP_API_EVT; /* this will start the voice handler "spinning" */

/*
* init the channel state
*/
Expand All @@ -104,14 +104,13 @@ void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *c)

seqp->vAllocHead = 0;
seqp->vAllocTail = 0;
/*
* init the event queue
*/
#if BUILD_VERSION < VERSION_J
#line 109
#endif
// init the event queue
items = alHeapAlloc(hp, c->maxEvents, sizeof(ALEventListItem));
alEvtqNew(&seqp->evtq, items, c->maxEvents);


/*
* add ourselves to the driver
*/
Expand Down Expand Up @@ -292,10 +291,10 @@ static ALMicroTime __CSPVoiceHandler(void *node)
break;

case (AL_SEQP_SEQ_EVT):

#ifdef _DEBUG
assert(seqp->state != AL_PLAYING); /* Must be done playing to change sequences. */
#if BUILD_VERSION < VERSION_J
#line 294
#endif
assert(seqp->state != AL_PLAYING); /* Must be done playing to change sequences. */

seqp->target = seqp->nextEvent.msg.spseq.seq;
__setUsptFromTempo (seqp, 500000.0);
Expand All @@ -304,10 +303,10 @@ static ALMicroTime __CSPVoiceHandler(void *node)
break;

case (AL_SEQP_BANK_EVT):

#ifdef _DEBUG
assert(seqp->state == AL_STOPPED); /* Must be fully stopped to change banks. */
#if BUILD_VERSION < VERSION_J
#line 303
#endif
assert(seqp->state == AL_STOPPED); /* Must be fully stopped to change banks. */

seqp->bank = seqp->nextEvent.msg.spbank.bank;
__initFromBank((ALSeqPlayer *)seqp, seqp->bank);
Expand All @@ -317,10 +316,10 @@ static ALMicroTime __CSPVoiceHandler(void *node)
case (AL_SEQ_END_EVT):
case (AL_TEMPO_EVT):
case (AL_SEQ_MIDI_EVT):

#ifdef _DEBUG
assert(FALSE);
#if BUILD_VERSION < VERSION_J
#line 313
#endif
assert(FALSE);

break;
}
Expand Down Expand Up @@ -407,16 +406,16 @@ __CSPHandleNextSeqEvent(ALCSPlayer *seqp)
break;

default:

#ifdef _DEBUG
assert(FALSE); /* Sequence event type not supported. */
#if BUILD_VERSION < VERSION_J
#line 399
#endif

assert(FALSE); /* Sequence event type not supported. */
#if BUILD_VERSION >= VERSION_J
break;
#endif
}
}


static void __CSPHandleMIDIMsg(ALCSPlayer *seqp, ALEvent *event)
{
ALVoice *voice;
Expand Down Expand Up @@ -723,10 +722,10 @@ static void __CSPHandleMIDIMsg(ALCSPlayer *seqp, ALEvent *event)
break;
case (AL_MIDI_ProgramChange):
/* sct 1/16/96 - We must have a valid bank in order to process the program change. */

#ifdef _DEBUG
assert(seqp->bank != NULL);
#if BUILD_VERSION < VERSION_J
#line 710
#endif
assert(seqp->bank != NULL);

if (key < seqp->bank->instCount)
{
Expand Down
Loading