From 09c1816e2d6c4da8468c59d69454aa3e6a9ef27f Mon Sep 17 00:00:00 2001 From: cadmic Date: Thu, 12 Sep 2024 02:24:31 -0700 Subject: [PATCH] Add OOT_PAL_N64 and move other shorthands to versions.h (#2188) * Move definitions of OOT_NTSC/OOT_PAL/OOT_MQ to versions.h * Add PAL_N64 shorthand --- Makefile | 30 ------------------- assets/text/nes_message_data_static.c | 1 + docs/c_cpp_properties.json | 18 ----------- docs/vscode.md | 2 -- include/macros.h | 2 ++ include/message_data_static.h | 1 + include/regs.h | 2 ++ include/segment_symbols.h | 1 + include/versions.h | 23 ++++++++++++++ include/z64.h | 1 + include/z64message.h | 1 + include/z64save.h | 1 + src/code/z_actor.c | 1 + src/code/z_construct.c | 1 + src/code/z_kanfont.c | 1 + src/code/z_parameter.c | 1 + src/code/z_scene_table.c | 2 +- src/code/z_sram.c | 1 + src/n64dd/n64dd_801C9440.c | 1 + src/overlays/actors/ovl_Fishing/z_fishing.c | 1 + .../ovl_file_choose/z_file_nameset.c | 1 + 21 files changed, 42 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 8c5c0159a9..eac3532953 100644 --- a/Makefile +++ b/Makefile @@ -51,57 +51,39 @@ ifeq ($(VERSION),ntsc-1.2) REGIONAL_CHECKSUM := 1 REGION ?= JP PLATFORM := N64 - PAL := 0 - MQ := 0 DEBUG := 0 COMPARE := 0 else ifeq ($(VERSION),gc-jp) REGION ?= JP PLATFORM := GC - PAL := 0 - MQ := 0 DEBUG := 0 else ifeq ($(VERSION),gc-jp-mq) REGION ?= JP PLATFORM := GC - PAL := 0 - MQ := 1 DEBUG := 0 else ifeq ($(VERSION),gc-jp-ce) REGION ?= JP PLATFORM := GC - PAL := 0 - MQ := 0 DEBUG := 0 else ifeq ($(VERSION),gc-us) REGION ?= US PLATFORM := GC - PAL := 0 - MQ := 0 DEBUG := 0 else ifeq ($(VERSION),gc-us-mq) REGION ?= US PLATFORM := GC - PAL := 0 - MQ := 1 DEBUG := 0 else ifeq ($(VERSION),gc-eu) REGION ?= EU PLATFORM := GC - PAL := 1 - MQ := 0 DEBUG := 0 else ifeq ($(VERSION),gc-eu-mq) REGION ?= EU PLATFORM := GC - PAL := 1 - MQ := 1 DEBUG := 0 else ifeq ($(VERSION),gc-eu-mq-dbg) REGION ?= EU PLATFORM := GC - PAL := 1 - MQ := 1 DEBUG := 1 else $(error Unsupported version $(VERSION)) @@ -147,18 +129,6 @@ else $(error Unsupported platform $(PLATFORM)) endif -ifeq ($(PAL),0) - CPP_DEFINES += -DOOT_NTSC=1 -else - CPP_DEFINES += -DOOT_PAL=1 -endif - -ifeq ($(MQ),0) - CPP_DEFINES += -DOOT_MQ=0 -else - CPP_DEFINES += -DOOT_MQ=1 -endif - ifeq ($(DEBUG),1) CPP_DEFINES += -DOOT_DEBUG=1 OPTFLAGS := -O2 diff --git a/assets/text/nes_message_data_static.c b/assets/text/nes_message_data_static.c index 6124e07f75..06c415118b 100644 --- a/assets/text/nes_message_data_static.c +++ b/assets/text/nes_message_data_static.c @@ -1,6 +1,7 @@ #define MESSAGE_DATA_STATIC #include "message_data_fmt.h" +#include "versions.h" #define DEFINE_MESSAGE(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \ const char _message_##textId##_nes[] = nesMessage; diff --git a/docs/c_cpp_properties.json b/docs/c_cpp_properties.json index 8f3d0ea556..b863d21c63 100644 --- a/docs/c_cpp_properties.json +++ b/docs/c_cpp_properties.json @@ -19,8 +19,6 @@ "OOT_REGION=REGION_JP", "PLATFORM_N64=1", "PLATFORM_GC=0", - "OOT_NTSC=1", - "OOT_MQ=0", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2" @@ -46,8 +44,6 @@ "OOT_REGION=REGION_JP", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_NTSC=1", - "OOT_MQ=0", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2", @@ -75,8 +71,6 @@ "OOT_REGION=REGION_JP", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_NTSC=1", - "OOT_MQ=1", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2", @@ -104,8 +98,6 @@ "OOT_REGION=REGION_US", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_NTSC=1", - "OOT_MQ=0", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2", @@ -133,8 +125,6 @@ "OOT_REGION=REGION_US", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_NTSC=1", - "OOT_MQ=1", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2", @@ -162,8 +152,6 @@ "OOT_REGION=REGION_EU", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_PAL=1", - "OOT_MQ=1", "OOT_DEBUG=1", "F3DEX_GBI_2", "F3DEX_GBI_PL", @@ -191,8 +179,6 @@ "OOT_REGION=REGION_EU", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_PAL=1", - "OOT_MQ=0", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2", @@ -220,8 +206,6 @@ "OOT_REGION=REGION_EU", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_PAL=1", - "OOT_MQ=1", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2", @@ -249,8 +233,6 @@ "OOT_REGION=REGION_JP", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_NTSC=1", - "OOT_MQ=0", "OOT_DEBUG=0", "NDEBUG", "F3DEX_GBI_2", diff --git a/docs/vscode.md b/docs/vscode.md index 44b1e6837f..6450e0020e 100644 --- a/docs/vscode.md +++ b/docs/vscode.md @@ -64,8 +64,6 @@ A more complete `c_cpp_properties.json` with configurations for all supported ve "OOT_REGION=REGION_EU", "PLATFORM_N64=0", "PLATFORM_GC=1", - "OOT_PAL=1", - "OOT_MQ=1", "OOT_DEBUG=1", "F3DEX_GBI_2", "F3DEX_GBI_PL", diff --git a/include/macros.h b/include/macros.h index 48bc94c8a5..5a34933c9d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,6 +1,8 @@ #ifndef MACROS_H #define MACROS_H +#include "versions.h" + #ifndef AVOID_UB #define BAD_RETURN(type) type #else diff --git a/include/message_data_static.h b/include/message_data_static.h index 6b6824966a..2b08302731 100644 --- a/include/message_data_static.h +++ b/include/message_data_static.h @@ -3,6 +3,7 @@ #include "ultra64.h" #include "message_data_fmt.h" +#include "versions.h" typedef enum TextBoxType { /* 0 */ TEXTBOX_TYPE_BLACK, diff --git a/include/regs.h b/include/regs.h index 9d98e971e9..8abc2e3f04 100644 --- a/include/regs.h +++ b/include/regs.h @@ -1,6 +1,8 @@ #ifndef REGS_H #define REGS_H +#include "versions.h" + #define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc. #define REG_PAGES 6 #define REGS_PER_PAGE 16 diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 9a03e3c575..95e44a51b5 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1,6 +1,7 @@ #ifndef SEGMENT_SYMBOLS_H #define SEGMENT_SYMBOLS_H +#include "versions.h" #include "z64.h" #define DECLARE_SEGMENT(name) \ diff --git a/include/versions.h b/include/versions.h index b135ae390c..6362545b96 100644 --- a/include/versions.h +++ b/include/versions.h @@ -16,4 +16,27 @@ #define GC_EU_MQ 12 #define GC_JP_CE 13 +// NTSC/PAL +#if OOT_VERSION == PAL_1_0 || OOT_VERSION == PAL_1_1 || OOT_VERSION == GC_EU || OOT_VERSION == GC_EU_MQ || OOT_VERSION == GC_EU_MQ_DBG +#define OOT_NTSC 0 +#define OOT_PAL 1 +#else +#define OOT_NTSC 1 +#define OOT_PAL 0 +#endif + +// PAL N64 (50 Hz) +#if OOT_VERSION == PAL_1_0 || OOT_VERSION == PAL_1_1 +#define OOT_PAL_N64 1 +#else +#define OOT_PAL_N64 0 +#endif + +// Master Quest +#if OOT_VERSION == GC_JP_MQ || OOT_VERSION == GC_US_MQ || OOT_VERSION == GC_EU_MQ || OOT_VERSION == GC_EU_MQ_DBG +#define OOT_MQ 1 +#else +#define OOT_MQ 0 +#endif + #endif diff --git a/include/z64.h b/include/z64.h index a6e4cc4d4a..2d36ccd436 100644 --- a/include/z64.h +++ b/include/z64.h @@ -6,6 +6,7 @@ #include "attributes.h" #include "audiomgr.h" #include "controller.h" +#include "versions.h" #include "z64save.h" #include "z64light.h" #include "z64bgcheck.h" diff --git a/include/z64message.h b/include/z64message.h index 9a073cfa03..609f737fb7 100644 --- a/include/z64message.h +++ b/include/z64message.h @@ -2,6 +2,7 @@ #define Z64MESSAGE_H #include "z64view.h" +#include "versions.h" struct OcarinaStaff; struct Actor; diff --git a/include/z64save.h b/include/z64save.h index 33066fdd12..4b7513e53a 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -2,6 +2,7 @@ #define Z64SAVE_H #include "ultra64.h" +#include "versions.h" #include "z64math.h" typedef enum Language { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 273add47c5..e0d1c50420 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3,6 +3,7 @@ #include "quake.h" #include "rand.h" #include "terminal.h" +#include "versions.h" #include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h" #include "overlays/actors/ovl_En_Part/z_en_part.h" diff --git a/src/code/z_construct.c b/src/code/z_construct.c index e758757774..104b048fd5 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -1,4 +1,5 @@ #include "global.h" +#include "versions.h" void Interface_Destroy(PlayState* play) { Map_Destroy(play); diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c index 81c83ce346..a4ae98c5b1 100644 --- a/src/code/z_kanfont.c +++ b/src/code/z_kanfont.c @@ -1,5 +1,6 @@ #include "global.h" #include "message_data_static.h" +#include "versions.h" /** * Loads a texture from kanji for the requested `character` into the character texture buffer diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 9e4a009936..b1bbf7c8a3 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,5 +1,6 @@ #include "global.h" #include "terminal.h" +#include "versions.h" #include "assets/textures/parameter_static/parameter_static.h" #include "assets/textures/do_action_static/do_action_static.h" #include "assets/textures/icon_item_static/icon_item_static.h" diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index 2a7082b783..d9e238e759 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -1,6 +1,6 @@ #include "global.h" #include "quake.h" - +#include "versions.h" #include "z64frame_advance.h" #if PLATFORM_N64 #include "n64dd.h" diff --git a/src/code/z_sram.c b/src/code/z_sram.c index ffcd516d42..b5d93f9902 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -1,5 +1,6 @@ #include "global.h" #include "terminal.h" +#include "versions.h" #define SLOT_SIZE (sizeof(SaveContext) + 0x28) #define CHECKSUM_SIZE (sizeof(Save) / 2) diff --git a/src/n64dd/n64dd_801C9440.c b/src/n64dd/n64dd_801C9440.c index 28ab8b5625..2d0b1b5c01 100644 --- a/src/n64dd/n64dd_801C9440.c +++ b/src/n64dd/n64dd_801C9440.c @@ -1,6 +1,7 @@ // Some text-handling functions #include "global.h" #include "n64dd.h" +#include "versions.h" void (*D_801D2EC0)(void*, uintptr_t, size_t) = NULL; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 23f356bae2..0c6c4d5b0e 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -11,6 +11,7 @@ #include "assets/objects/object_fish/object_fish.h" #include "ichain.h" #include "terminal.h" +#include "versions.h" #if PLATFORM_N64 #include "cic6105.h" #endif diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c index 1e5e12505a..634c0e3679 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c @@ -1,5 +1,6 @@ #include "file_select.h" #include "terminal.h" +#include "versions.h" #include "assets/textures/title_static/title_static.h" #include "assets/overlays/ovl_file_choose/ovl_file_choose.h"