summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2024-12-14 01:28:28 +0000
committerGitHub <noreply@github.com>2024-12-13 20:28:28 -0500
commit9170902f8d4375a145b513963646dbf58949fb9a (patch)
tree17ae52ae639847b1ad35ba3d550e187c75905a0f /src
parentdf5d4cb4673bc74d1e2f4d11cf6f5fe8376cd1df (diff)
Move build.c definitions to the makefile, introduce and use libultra version defines in libultra instead of PLATFORM defines (#2353)
* Move build.c definitions to the makefile, introduce and use libultra version defines in libultra instead of PLATFORM defines * MAJOR+MINOR versions -> VERSION+PATCH, stringify build defines in makefile, let the libultra version determine the OPTFLAGS for libultra files * Clang format moment * Remove LIBULTRA_VERSION_ID, tweak OS_VERSION and libultra version definitions * Better fix for formatting problems
Diffstat (limited to 'src')
-rw-r--r--src/boot/build.c38
-rw-r--r--src/libultra/gu/rotate.c12
-rw-r--r--src/libultra/os/exceptasm.s5
-rw-r--r--src/libultra/os/initialize.c14
-rw-r--r--src/libultra/os/settimer.c14
-rw-r--r--src/libultra/os/timerintr.c2
-rw-r--r--src/makerom/rom_header.h6
-rw-r--r--src/makerom/rom_header.s17
8 files changed, 35 insertions, 73 deletions
diff --git a/src/boot/build.c b/src/boot/build.c
index 49992adc5..31e48096b 100644
--- a/src/boot/build.c
+++ b/src/boot/build.c
@@ -1,39 +1,5 @@
#include "versions.h"
-#if PLATFORM_N64
-const char gBuildCreator[] = "zelda@srd44";
-#else
-const char gBuildCreator[] = "zelda@srd022j";
-#endif
-
-#if OOT_VERSION == NTSC_1_0
-const char gBuildDate[] = "98-10-21 04:56:31";
-#elif OOT_VERSION == NTSC_1_1
-const char gBuildDate[] = "98-10-26 10:58:45";
-#elif OOT_VERSION == PAL_1_0
-const char gBuildDate[] = "98-11-10 14:34:22";
-#elif OOT_VERSION == NTSC_1_2
-const char gBuildDate[] = "98-11-12 18:17:03";
-#elif OOT_VERSION == PAL_1_1
-const char gBuildDate[] = "98-11-18 17:36:49";
-#elif OOT_VERSION == GC_JP
-const char gBuildDate[] = "02-10-29 23:49:53";
-#elif OOT_VERSION == GC_JP_MQ
-const char gBuildDate[] = "02-10-30 00:15:15";
-#elif OOT_VERSION == GC_US
-const char gBuildDate[] = "02-12-19 13:28:09";
-#elif OOT_VERSION == GC_US_MQ
-const char gBuildDate[] = "02-12-19 14:05:42";
-#elif OOT_VERSION == GC_EU_MQ_DBG
-const char gBuildDate[] = "03-02-21 00:16:31";
-#elif OOT_VERSION == GC_EU
-const char gBuildDate[] = "03-02-21 20:12:23";
-#elif OOT_VERSION == GC_EU_MQ
-const char gBuildDate[] = "03-02-21 20:37:19";
-#elif OOT_VERSION == GC_JP_CE
-const char gBuildDate[] = "03-10-08 21:53:00";
-#else
-#error "Unsupported OOT_VERSION"
-#endif
-
+const char gBuildCreator[] = BUILD_CREATOR;
+const char gBuildDate[] = BUILD_DATE " " BUILD_TIME;
const char gBuildMakeOption[] = "";
diff --git a/src/libultra/gu/rotate.c b/src/libultra/gu/rotate.c
index b9108e1bc..7d495e98e 100644
--- a/src/libultra/gu/rotate.c
+++ b/src/libultra/gu/rotate.c
@@ -8,7 +8,7 @@ void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
f32 bc;
f32 ca;
f32 t;
-#if !PLATFORM_N64
+#if LIBULTRA_VERSION >= LIBULTRA_VERSION_K
f32 xs;
f32 ys;
f32 zs;
@@ -27,14 +27,14 @@ void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
guMtxIdentF(m);
-#if PLATFORM_N64
-#define xs (x * sine)
-#define ys (y * sine)
-#define zs (z * sine)
-#else
+#if LIBULTRA_VERSION >= LIBULTRA_VERSION_K
xs = x * sine;
ys = y * sine;
zs = z * sine;
+#else
+#define xs (x * sine)
+#define ys (y * sine)
+#define zs (z * sine)
#endif
t = x * x;
diff --git a/src/libultra/os/exceptasm.s b/src/libultra/os/exceptasm.s
index 6b8003fd2..3c55d66ac 100644
--- a/src/libultra/os/exceptasm.s
+++ b/src/libultra/os/exceptasm.s
@@ -4,6 +4,7 @@
#include "ultra64/message.h"
#include "ultra64/thread.h"
#include "ultra64/exception.h"
+#include "ultra64/version.h"
.set noat
.set noreorder
@@ -448,7 +449,7 @@ pi:
andi $t1, $s1, MI_INTR_PI
beqz $t1, dp
nop
-#if PLATFORM_N64
+#if LIBULTRA_VERSION < LIBULTRA_VERSION_J
// Clear interrupt and mask out pi interrupt
li $t1, PI_STATUS_CLR_INTR
lui $at, %hi(PHYS_TO_K1(PI_STATUS_REG))
@@ -855,7 +856,7 @@ LEAF(__osPopThread)
sw $t9, ($a0)
END(__osPopThread)
-#if !PLATFORM_N64
+#if LIBULTRA_VERSION >= LIBULTRA_VERSION_K
LEAF(__osNop)
jr $ra
nop
diff --git a/src/libultra/os/initialize.c b/src/libultra/os/initialize.c
index e985d551d..427a51771 100644
--- a/src/libultra/os/initialize.c
+++ b/src/libultra/os/initialize.c
@@ -16,12 +16,14 @@ OSHWIntr __OSGlobalIntMask = OS_IM_ALL;
u32 __osFinalrom;
-#if PLATFORM_N64
+#if LIBULTRA_VERSION < LIBULTRA_VERSION_K
#define OSINITIALIZE_FUNC osInitialize
#define SPEED_PARAM_FUNC createSpeedParam
+#if (LIBULTRA_VERSION == LIBULTRA_VERSION_I && LIBULTRA_PATCH == 1) || (LIBULTRA_VERSION == LIBULTRA_VERSION_J)
static void SPEED_PARAM_FUNC(void);
+#endif
#else
@@ -46,14 +48,14 @@ void SPEED_PARAM_FUNC(void) {
void OSINITIALIZE_FUNC(void) {
u32 pifdata;
-#if PLATFORM_N64
+#if LIBULTRA_VERSION < LIBULTRA_VERSION_K
u32 clock = 0;
#endif
__osFinalrom = true;
__osSetSR(__osGetSR() | SR_CU1);
__osSetFpcCsr(FPCSR_FS | FPCSR_EV);
-#if !PLATFORM_N64
+#if LIBULTRA_VERSION >= LIBULTRA_VERSION_K
__osSetWatchLo(0x04900000);
#endif
@@ -71,9 +73,11 @@ void OSINITIALIZE_FUNC(void) {
osWritebackDCache((void*)K0BASE, E_VEC - K0BASE + sizeof(__osExceptionVector));
osInvalICache((void*)K0BASE, E_VEC - K0BASE + sizeof(__osExceptionVector));
+#if (LIBULTRA_VERSION == LIBULTRA_VERSION_I && LIBULTRA_PATCH == 1) || (LIBULTRA_VERSION > LIBULTRA_VERSION_I)
SPEED_PARAM_FUNC();
osUnmapTLBAll();
osMapTLBRdb();
+#endif
osClockRate = osClockRate * 3 / 4;
@@ -89,19 +93,21 @@ void OSINITIALIZE_FUNC(void) {
osViClock = VI_NTSC_CLOCK;
}
+#if (LIBULTRA_VERSION == LIBULTRA_VERSION_I && LIBULTRA_PATCH == 1) || (LIBULTRA_VERSION >= LIBULTRA_VERSION_J)
// If PreNMI is pending, loop until reset
if (__osGetCause() & CAUSE_IP5) {
while (true) {
;
}
}
+#endif
IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON);
IO_WRITE(AI_DACRATE_REG, AI_MAX_DAC_RATE - 1);
IO_WRITE(AI_BITRATE_REG, AI_MAX_BIT_RATE - 1);
}
-#if PLATFORM_N64
+#if (LIBULTRA_VERSION == LIBULTRA_VERSION_I && LIBULTRA_PATCH == 1) || (LIBULTRA_VERSION == LIBULTRA_VERSION_J)
static void SPEED_PARAM_FUNC(void) {
__Dom1SpeedParam.type = DEVICE_TYPE_INIT;
__Dom1SpeedParam.latency = IO_READ(PI_BSD_DOM1_LAT_REG);
diff --git a/src/libultra/os/settimer.c b/src/libultra/os/settimer.c
index 194f4eff7..a876641e8 100644
--- a/src/libultra/os/settimer.c
+++ b/src/libultra/os/settimer.c
@@ -2,7 +2,7 @@
s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg) {
UNUSED OSTime time;
-#if !PLATFORM_N64
+#if LIBULTRA_VERSION >= LIBULTRA_VERSION_K
OSTimer* next;
u32 count;
u32 value;
@@ -21,12 +21,7 @@ s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* m
timer->mq = mq;
timer->msg = msg;
-#if PLATFORM_N64
- time = __osInsertTimer(timer);
- if (__osTimerList->next == timer) {
- __osSetTimerIntr(time);
- }
-#else
+#if LIBULTRA_VERSION >= LIBULTRA_VERSION_K
prevInt = __osDisableInt();
if (__osTimerList->next != __osTimerList) {
if (1) {}
@@ -46,6 +41,11 @@ s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* m
__osSetTimerIntr(__osTimerList->next->value);
__osRestoreInt(prevInt);
+#else
+ time = __osInsertTimer(timer);
+ if (__osTimerList->next == timer) {
+ __osSetTimerIntr(time);
+ }
#endif
return 0;
diff --git a/src/libultra/os/timerintr.c b/src/libultra/os/timerintr.c
index 943aca0ff..ce5c12fc5 100644
--- a/src/libultra/os/timerintr.c
+++ b/src/libultra/os/timerintr.c
@@ -63,7 +63,7 @@ void __osSetTimerIntr(OSTime time) {
OSTime newTime;
u32 prevInt;
-#if !PLATFORM_N64
+#if LIBULTRA_VERSION >= LIBULTRA_VERSION_K
if (time < 468) {
time = 468;
}
diff --git a/src/makerom/rom_header.h b/src/makerom/rom_header.h
index 1069ae86f..65cfc89da 100644
--- a/src/makerom/rom_header.h
+++ b/src/makerom/rom_header.h
@@ -54,13 +54,13 @@
* and what libultra version (os_ver) it uses.
*
* The hardware revision for a retail N64 is (2,0).
- * The libultra version may be a single letter, without quotes.
+ * The libultra version must be a single char, in quotes.
*/
-#define LIBULTRA_VERSION(hw_major, hw_minor, os_ver) \
+#define OS_VERSION(hw_major, hw_minor, os_ver) \
.half 0; \
.byte (hw_major) * 10 + (hw_minor); \
_os_ver_start = .; \
- .ascii #os_ver ; \
+ .byte (os_ver) ; \
.if (. - _os_ver_start) != 1; \
.error "OS version should be just one letter"; \
.endif
diff --git a/src/makerom/rom_header.s b/src/makerom/rom_header.s
index 525bee6e8..d3d938cda 100644
--- a/src/makerom/rom_header.s
+++ b/src/makerom/rom_header.s
@@ -1,4 +1,5 @@
#include "rom_header.h"
+#include "ultra64/version.h"
#include "region.h"
#include "versions.h"
@@ -6,11 +7,7 @@
/* 0x01 */ PI_DOMAIN_1_CFG(64, 18, 7, 3)
/* 0x04 */ SYSTEM_CLOCK_RATE_SETTING(0xF)
/* 0x08 */ ENTRYPOINT(0x80000400)
-#if PLATFORM_N64
-/* 0x0C */ LIBULTRA_VERSION(2, 0, I)
-#else
-/* 0x0C */ LIBULTRA_VERSION(2, 0, L)
-#endif
+/* 0x0C */ OS_VERSION(2, 0, LIBULTRA_VERSION)
/* 0x10 */ CHECKSUM()
/* 0x18 */ PADDING(8)
/* 0x20 */ ROM_NAME("THE LEGEND OF ZELDA")
@@ -28,12 +25,4 @@
#elif OOT_REGION == REGION_EU
/* 0x3E */ REGION(PAL)
#endif
-#if OOT_VERSION == NTSC_1_0 || OOT_VERSION == PAL_1_0
-/* 0x3F */ GAME_REVISION(0)
-#elif OOT_VERSION == NTSC_1_1 || OOT_VERSION == PAL_1_1
-/* 0x3F */ GAME_REVISION(1)
-#elif OOT_VERSION == NTSC_1_2
-/* 0x3F */ GAME_REVISION(2)
-#else
-/* 0x3F */ GAME_REVISION(15)
-#endif
+/* 0x3F */ GAME_REVISION(OOT_REVISION)