mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-26 14:46:16 +00:00
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
This commit is contained in:
parent
df5d4cb467
commit
9170902f8d
12 changed files with 106 additions and 77 deletions
56
Makefile
56
Makefile
|
@ -66,60 +66,109 @@ ifeq ($(VERSION),ntsc-1.0)
|
|||
REGION ?= JP
|
||||
PLATFORM := N64
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 98-10-21
|
||||
BUILD_TIME := 04:56:31
|
||||
REVISION := 0
|
||||
else ifeq ($(VERSION),ntsc-1.1)
|
||||
REGIONAL_CHECKSUM := 1
|
||||
REGION ?= JP
|
||||
PLATFORM := N64
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 98-10-26
|
||||
BUILD_TIME := 10:58:45
|
||||
REVISION := 1
|
||||
else ifeq ($(VERSION),pal-1.0)
|
||||
REGION ?= EU
|
||||
PLATFORM := N64
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 98-11-10
|
||||
BUILD_TIME := 14:34:22
|
||||
REVISION := 0
|
||||
else ifeq ($(VERSION),ntsc-1.2)
|
||||
REGIONAL_CHECKSUM := 1
|
||||
REGION ?= JP
|
||||
PLATFORM := N64
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 98-11-12
|
||||
BUILD_TIME := 18:17:03
|
||||
REVISION := 2
|
||||
else ifeq ($(VERSION),pal-1.1)
|
||||
REGION ?= EU
|
||||
PLATFORM := N64
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 98-11-18
|
||||
BUILD_TIME := 17:36:49
|
||||
REVISION := 1
|
||||
else ifeq ($(VERSION),gc-jp)
|
||||
REGION ?= JP
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 02-10-29
|
||||
BUILD_TIME := 23:49:53
|
||||
REVISION := 15
|
||||
else ifeq ($(VERSION),gc-jp-mq)
|
||||
REGION ?= JP
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 02-10-30
|
||||
BUILD_TIME := 00:15:15
|
||||
REVISION := 15
|
||||
else ifeq ($(VERSION),gc-us)
|
||||
REGION ?= US
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 02-12-19
|
||||
BUILD_TIME := 13:28:09
|
||||
REVISION := 15
|
||||
else ifeq ($(VERSION),gc-us-mq)
|
||||
REGION ?= US
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 02-12-19
|
||||
BUILD_TIME := 14:05:42
|
||||
REVISION := 15
|
||||
else ifeq ($(VERSION),gc-eu-mq-dbg)
|
||||
REGION ?= EU
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 1
|
||||
BUILD_DATE := 03-02-21
|
||||
BUILD_TIME := 00:16:31
|
||||
REVISION := 15
|
||||
else ifeq ($(VERSION),gc-eu)
|
||||
REGION ?= EU
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 03-02-21
|
||||
BUILD_TIME := 20:12:23
|
||||
REVISION := 15
|
||||
else ifeq ($(VERSION),gc-eu-mq)
|
||||
REGION ?= EU
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 03-02-21
|
||||
BUILD_TIME := 20:37:19
|
||||
REVISION := 15
|
||||
else ifeq ($(VERSION),gc-jp-ce)
|
||||
REGION ?= JP
|
||||
PLATFORM := GC
|
||||
DEBUG_FEATURES ?= 0
|
||||
BUILD_DATE := 03-10-08
|
||||
BUILD_TIME := 21:53:00
|
||||
REVISION := 15
|
||||
else
|
||||
$(error Unsupported version $(VERSION))
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM),N64)
|
||||
BUILD_CREATOR := zelda@srd44
|
||||
LIBULTRA_VERSION := I
|
||||
LIBULTRA_PATCH := 1
|
||||
else
|
||||
BUILD_CREATOR := zelda@srd022j
|
||||
LIBULTRA_VERSION := L
|
||||
LIBULTRA_PATCH := 0
|
||||
endif
|
||||
|
||||
# ORIG_COMPILER cannot be combined with a non-IDO compiler. Check for this case and error out if found.
|
||||
ifneq ($(COMPILER),ido)
|
||||
ifeq ($(ORIG_COMPILER),1)
|
||||
|
@ -149,8 +198,11 @@ CPPFLAGS += -P -xc -fno-dollars-in-identifiers
|
|||
|
||||
# Converts e.g. ntsc-1.0 to NTSC_1_0
|
||||
VERSION_MACRO := $(shell echo $(VERSION) | tr a-z-. A-Z__)
|
||||
CPP_DEFINES += -DOOT_VERSION=$(VERSION_MACRO)
|
||||
CPP_DEFINES += -DOOT_VERSION=$(VERSION_MACRO) -DOOT_REVISION=$(REVISION)
|
||||
CPP_DEFINES += -DOOT_REGION=REGION_$(REGION)
|
||||
CPP_DEFINES += -DBUILD_CREATOR="\"$(BUILD_CREATOR)\"" -DBUILD_DATE="\"$(BUILD_DATE)\"" -DBUILD_TIME="\"$(BUILD_TIME)\""
|
||||
CPP_DEFINES += -DLIBULTRA_VERSION=LIBULTRA_VERSION_$(LIBULTRA_VERSION)
|
||||
CPP_DEFINES += -DLIBULTRA_PATCH=$(LIBULTRA_PATCH)
|
||||
|
||||
ifeq ($(PLATFORM),N64)
|
||||
CPP_DEFINES += -DPLATFORM_N64=1 -DPLATFORM_GC=0
|
||||
|
@ -494,7 +546,7 @@ $(BUILD_DIR)/src/libultra/libc/ll.o: MIPS_VERSION := -mips3 -32
|
|||
$(BUILD_DIR)/src/libultra/libc/llcvt.o: OPTFLAGS := -O1
|
||||
$(BUILD_DIR)/src/libultra/libc/llcvt.o: MIPS_VERSION := -mips3 -32
|
||||
|
||||
ifeq ($(PLATFORM),N64)
|
||||
ifeq ($(LIBULTRA_VERSION),I)
|
||||
$(BUILD_DIR)/src/libultra/gu/%.o: OPTFLAGS := -O3
|
||||
$(BUILD_DIR)/src/libultra/io/%.o: OPTFLAGS := -O1
|
||||
$(BUILD_DIR)/src/libultra/libc/%.o: OPTFLAGS := -O3
|
||||
|
|
|
@ -31,7 +31,7 @@ APPLY_OPTS = "--format --style=file"
|
|||
# Compiler options used with Clang-Tidy
|
||||
# Normal warnings are disabled with -Wno-everything to focus only on tidying
|
||||
INCLUDES = "-Iinclude -Isrc -Ibuild/gc-eu-mq-dbg -I."
|
||||
DEFINES = "-D_LANGUAGE_C -DNON_MATCHING -DF3DEX_GBI_2"
|
||||
DEFINES = "-D_LANGUAGE_C -DNON_MATCHING -DF3DEX_GBI_2 -DBUILD_CREATOR=\"\" -DBUILD_DATE=__DATE__ -DBUILD_TIME=__TIME__"
|
||||
COMPILER_OPTS = f"-fno-builtin -std=gnu90 -m32 -Wno-everything {INCLUDES} {DEFINES}"
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "ultra64/motor.h"
|
||||
#include "ultra64/R4300.h"
|
||||
#include "ultra64/ucode.h"
|
||||
#include "ultra64/version.h"
|
||||
|
||||
union uObjBg;
|
||||
|
||||
|
@ -42,7 +43,7 @@ void osStopThread(OSThread* thread);
|
|||
void osViExtendVStart(u32 value);
|
||||
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag);
|
||||
|
||||
#if PLATFORM_N64
|
||||
#if LIBULTRA_VERSION < LIBULTRA_VERSION_K
|
||||
void osInitialize(void);
|
||||
#else
|
||||
#define osInitialize() \
|
||||
|
|
14
include/ultra64/version.h
Normal file
14
include/ultra64/version.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef ULTRA64_VERSION_H
|
||||
#define ULTRA64_VERSION_H
|
||||
|
||||
#define LIBULTRA_VERSION_D 'D'
|
||||
#define LIBULTRA_VERSION_E 'E'
|
||||
#define LIBULTRA_VERSION_F 'F'
|
||||
#define LIBULTRA_VERSION_G 'G'
|
||||
#define LIBULTRA_VERSION_H 'H'
|
||||
#define LIBULTRA_VERSION_I 'I'
|
||||
#define LIBULTRA_VERSION_J 'J'
|
||||
#define LIBULTRA_VERSION_K 'K'
|
||||
#define LIBULTRA_VERSION_L 'L'
|
||||
|
||||
#endif
|
|
@ -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[] = "";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue