From 776d203252af9aee69600cae2b3e04778ace161b Mon Sep 17 00:00:00 2001 From: Oliver Bell Date: Wed, 17 Sep 2025 00:58:46 +0100 Subject: [PATCH] vc: start vc match --- Makefile | 6 ++++++ config.mk | 5 +++++ sa2_japan_vc.sha1 | 1 + src/game/stage/item_tasks.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 sa2_japan_vc.sha1 diff --git a/Makefile b/Makefile index e0610b254..b025020d3 100644 --- a/Makefile +++ b/Makefile @@ -203,6 +203,10 @@ FORMAT_H_PATHS := $(shell find . -name "*.h" ! -path '*/build/*' ! -path '*/ex CPPFLAGS ?= $(INCLUDE_CPP_ARGS) -D $(GAME_REGION) CC1FLAGS ?= -Wimplicit -Wparentheses -Werror +ifneq ($(GAME_VARIANT), 0) + CPPFLAGS += -D $(GAME_VARIANT) +endif + # These have to(?) be defined this way, because # the C-preprocessor cannot resolve stuff like: # #if (PLATFORM == gba), where PLATFORM is defined via -D. @@ -397,6 +401,8 @@ tidy: japan: ; @$(MAKE) GAME_REGION=JAPAN +japan_vc: ; @$(MAKE) GAME_REGION=JAPAN GAME_VARIANT=VIRTUAL_CONSOLE + europe: ; @$(MAKE) GAME_REGION=EUROPE sdl: ; @$(MAKE) PLATFORM=sdl diff --git a/config.mk b/config.mk index 6356e68a1..56c3db577 100644 --- a/config.mk +++ b/config.mk @@ -53,6 +53,7 @@ endif # Default game variables GAME_REVISION ?= 0 GAME_REGION ?= USA +GAME_VARIANT ?= 0 DEBUG ?= 0 # For gbafix @@ -92,6 +93,10 @@ endif endif endif +ifeq ($(GAME_VARIANT), VIRTUAL_CONSOLE) + BUILD_NAME := $(BUILD_NAME)_vc +endif + # Debug ifeq ($(DEBUG), 1) BUILD_NAME := $(BUILD_NAME)_debug diff --git a/sa2_japan_vc.sha1 b/sa2_japan_vc.sha1 new file mode 100644 index 000000000..872469d4d --- /dev/null +++ b/sa2_japan_vc.sha1 @@ -0,0 +1 @@ +2aa6ee2cf2b0ebfafbea6d6d24165b252a7e329e sa2_japan_vc.gba diff --git a/src/game/stage/item_tasks.c b/src/game/stage/item_tasks.c index 623871fcd..7606146fe 100644 --- a/src/game/stage/item_tasks.c +++ b/src/game/stage/item_tasks.c @@ -149,6 +149,9 @@ void Task_Item_Shield_Normal(void) if (!(gPlayer.itemEffect & PLAYER_ITEM_EFFECT__INVINCIBILITY)) { bool32 b; s32 screenX, screenY; +#ifdef VIRTUAL_CONSOLE + u32 r0; +#endif screenX = I(gPlayer.qWorldX) - cam->x; item->s.x = screenX + gPlayer.unk7C; @@ -161,6 +164,10 @@ void Task_Item_Shield_Normal(void) UpdateSpriteAnimation(&item->s); +#ifdef VIRTUAL_CONSOLE + r0 = Mod(gStageTime, 6); +#endif + #ifndef NON_MATCHING asm("mov %0, %2\n" "and %0, %1\n" @@ -169,15 +176,38 @@ void Task_Item_Shield_Normal(void) // Make the compiler "forget" that itemEffect is 0x1 asm("" : "=r"(itemEffect)); +#ifdef VIRTUAL_CONSOLE + { + register u32 r2 asm("r2") = 6; + r0 &= r2; + } +#endif #else b = (param & 0x1); +#ifdef VIRTUAL_CONSOLE + r0 &= 6; #endif +#endif + +#ifdef VIRTUAL_CONSOLE + if ((!r0 && (b != itemEffect)) || (r0 && (b != 0))) { +#else if (((gStageTime & 0x2) && (b != itemEffect)) || (!(gStageTime & 0x2) && (b != 0))) { +#endif DisplaySprite(&item->s); } } } +#ifndef NON_MATCHING +// Looks like they may have manually edited the rom for the virtual console +// to keep all the functions in the same alignment as the original rom. +// Maybe they couldn't reexport the anims? +#ifdef VIRTUAL_CONSOLE +asm(".byte 0x00, 0x00, 0x00, 0x00"); +#endif +#endif + void Task_Item_Shield_Magnetic(void) { s8 param = ITEMTASK_GET_PLAYER_NUM();