Skip to content

Commit

Permalink
Merge pull request #958 from r-burns/praise-ninji
Browse files Browse the repository at this point in the history
 Remove frank, build with 1.2.5n
  • Loading branch information
r-burns authored Jul 15, 2023
2 parents 96f654e + 9d687d4 commit c7ef3e6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 210 deletions.
55 changes: 9 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

GENERATE_MAP ?= 0
NON_MATCHING ?= 0
EPILOGUE_PROCESS ?= 1
SKIP_CHECK ?= 0
REQUIRE_PROTOS ?= 1
MSG_STYLE ?= gcc
Expand Down Expand Up @@ -32,9 +31,6 @@ else
BUILD_DIR := build/$(TARGET)
endif

VANILLA_DIR := $(BUILD_DIR)/vanilla
PROFILE_DIR := $(BUILD_DIR)/profile

# Inputs
LDSCRIPT := ldscript.lcf

Expand All @@ -54,10 +50,7 @@ DEP_FILES := $(O_FILES:.o=.dep)
#-------------------------------------------------------------------------------

MWCC_VERSION := 1.2.5
ifeq ($(EPILOGUE_PROCESS),1)
MWCC_EPI_VERSION := 1.2.5e
MWCC_EPI_EXE := mwcceppc.exe
endif
MWCC_EPI_VERSION := 1.2.5n
MWCC_LD_VERSION := 1.1

# Programs
Expand All @@ -83,17 +76,13 @@ else
endif

CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe
ifeq ($(EPILOGUE_PROCESS),1)
CC_EPI = $(WINE) tools/mwcc_compiler/$(MWCC_EPI_VERSION)/$(MWCC_EPI_EXE)
endif
CC_EPI := $(WINE) tools/mwcc_compiler/$(MWCC_EPI_VERSION)/mwcceppc.exe
LD := $(WINE) tools/mwcc_compiler/$(MWCC_LD_VERSION)/mwldeppc.exe
ELF2DOL := tools/elf2dol
HOSTCC := gcc
PYTHON := python
FORMAT := clang-format -i -style=file

FRANK := tools/frank.py

# Options
INCLUDE_DIRS = src/melee src/melee/ft/chara
# TODO dolphin and sysdolphin as system includes
Expand Down Expand Up @@ -147,9 +136,6 @@ ifeq ($(WIP),1)
CFLAGS += -DWIP
endif

$(BUILD_DIR)/src/melee/pl/player.c.o: CC_EPI := $(CC)
$(BUILD_DIR)/src/melee/lb/lbtime.c.o: CC_EPI := $(CC)

HOSTCFLAGS := -Wall -O3 -s

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -181,8 +167,6 @@ clean:
rm -f -d -r $(BUILD_DIR) build/o_files $(ELF2DOL)

ALL_DIRS := $(sort $(dir $(O_FILES)))
ALL_DIRS += $(patsubst $(BUILD_DIR)/%,$(VANILLA_DIR)/%,$(ALL_DIRS)) \
$(patsubst $(BUILD_DIR)/%,$(PROFILE_DIR)/%,$(ALL_DIRS))

# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $(ALL_DIRS)
Expand All @@ -206,37 +190,16 @@ $(BUILD_DIR)/%.s.o: %.s

$(BUILD_DIR)/%.c.dep: %.c
$(QUIET) $(HOSTCC) -E $(addprefix -I ,$(INCLUDE_DIRS) $(SYSTEM_INCLUDE_DIRS)) -MMD -MF $(@:.o=.dep) \
-MT "$(VANILLA_DIR)/$<.o $(PROFILE_DIR)/$<.o" $< >/dev/null

$(BUILD_DIR)/%.c.o: $(VANILLA_DIR)/%.c.o
cp $< $@
-MT "$(BUILD_DIR)/$<.o" $< >/dev/null

$(VANILLA_DIR)/%.c.o: %.c $(BUILD_DIR)/%.c.dep
@echo "Compiling (vanilla)" $<
$(BUILD_DIR)/%.c.o: %.c $(BUILD_DIR)/%.c.dep
@echo "Compiling " $<
$(QUIET) $(CC) $(CFLAGS) -c -o $@ $<

# Overrides for targets using frank to simulate patched MWCC 1.2.5
ifeq ($(EPILOGUE_PROCESS),1)
$(PROFILE_DIR)/%.c.o: %.c $(BUILD_DIR)/%.c.dep
@echo "Compiling (profile)" $<
$(QUIET) $(CC_EPI) $(CFLAGS) -c -o $@ $<

$(BUILD_DIR)/src/melee/%.c.o: $(VANILLA_DIR)/src/melee/%.c.o $(PROFILE_DIR)/src/melee/%.c.o $(FRANK)
@echo Frank is fixing $@
$(QUIET) $(PYTHON) $(FRANK) $(word 1,$^) $(word 2,$^) $@

$(BUILD_DIR)/src/sysdolphin/%.c.o: $(VANILLA_DIR)/src/sysdolphin/%.c.o $(PROFILE_DIR)/src/sysdolphin/%.c.o $(FRANK)
@echo Frank is fixing $@
$(QUIET) $(PYTHON) $(FRANK) $(word 1,$^) $(word 2,$^) $@

$(BUILD_DIR)/src/dolphin/card/%.c.o: $(VANILLA_DIR)/src/dolphin/card/%.c.o $(PROFILE_DIR)/src/dolphin/card/%.c.o $(FRANK)
@echo Frank is fixing $@
$(QUIET) $(PYTHON) $(FRANK) $(word 1,$^) $(word 2,$^) $@

$(BUILD_DIR)/src/dolphin/pad/%.c.o: $(VANILLA_DIR)/src/dolphin/pad/%.c.o $(PROFILE_DIR)/src/dolphin/pad/%.c.o $(FRANK)
@echo Frank is fixing $@
$(QUIET) $(PYTHON) $(FRANK) $(word 1,$^) $(word 2,$^) $@
endif
$(BUILD_DIR)/src/melee/%.c.o: CC := $(CC_EPI)
$(BUILD_DIR)/src/sysdolphin/%.c.o: CC := $(CC_EPI)
$(BUILD_DIR)/src/dolphin/card/%.c.o: CC := $(CC_EPI)
$(BUILD_DIR)/src/dolphin/pad/%.c.o: CC := $(CC_EPI)

-include $(DEP_FILES)

Expand Down
60 changes: 0 additions & 60 deletions src/melee/gm/gmmain_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,41 +256,11 @@ s32* gmMainLib_8015D06C(u8 arg0)
return &base[arg0].x84;
}

#ifdef MUST_MATCH

#pragma push
asm s32* gmMainLib_8015D084(s32 arg0)
{
// clang-format off
nofralloc
/* 8015D084 00159C64 7C 08 02 A6 */ mflr r0
/* 8015D088 00159C68 90 01 00 04 */ stw r0, 4(r1)
/* 8015D08C 00159C6C 94 21 FF E8 */ stwu r1, -0x18(r1)
/* 8015D090 00159C70 93 E1 00 14 */ stw r31, 0x14(r1)
/* 8015D094 00159C74 7C 7F 1B 78 */ mr r31, r3
/* 8015D098 00159C78 48 00 1D 25 */ bl gmMainLib_8015EDBC
/* 8015D09C 00159C7C 57 E4 15 BA */ rlwinm r4, r31, 2, 0x16, 0x1d
/* 8015D0A0 00159C80 83 E1 00 14 */ lwz r31, 0x14(r1)
/* 8015D0A4 00159C84 38 03 00 00 */ addi r0, r3, 0
/* 8015D0A8 00159C88 38 64 00 B0 */ addi r3, r4, 0xb0
/* 8015D0AC 00159C8C 7C 60 1A 14 */ add r3, r0, r3
/* 8015D0B0 00159C90 80 01 00 1C */ lwz r0, 0x1c(r1)
/* 8015D0B4 00159C94 38 21 00 18 */ addi r1, r1, 0x18
/* 8015D0B8 00159C98 7C 08 03 A6 */ mtlr r0
/* 8015D0BC 00159C9C 4E 80 00 20 */ blr
} // clang-format on
#pragma pop

#else

// needs a @frank patch
s32* gmMainLib_8015D084(s32 arg0)
{
return &gmMainLib_8015EDBC()->xB0[arg0 & 0xFF];
}

#endif

s32* gmMainLib_8015D0C0(u8 arg0)
{
struct gmm_x1F2C* base = &gmMainLib_804D3EE0->thing.x1F2C[0];
Expand Down Expand Up @@ -441,41 +411,11 @@ s32* gmMainLib_8015D438(u8 arg0)
return &base[arg0].x94;
}

#ifdef MUST_MATCH

#pragma push
asm s32* gmMainLib_8015D450(s32 arg0)
{
// clang-format off
nofralloc
/* 8015D450 0015A030 7C 08 02 A6 */ mflr r0
/* 8015D454 0015A034 90 01 00 04 */ stw r0, 4(r1)
/* 8015D458 0015A038 94 21 FF E8 */ stwu r1, -0x18(r1)
/* 8015D45C 0015A03C 93 E1 00 14 */ stw r31, 0x14(r1)
/* 8015D460 0015A040 7C 7F 1B 78 */ mr r31, r3
/* 8015D464 0015A044 48 00 19 59 */ bl gmMainLib_8015EDBC
/* 8015D468 0015A048 57 E4 15 BA */ rlwinm r4, r31, 2, 0x16, 0x1d
/* 8015D46C 0015A04C 83 E1 00 14 */ lwz r31, 0x14(r1)
/* 8015D470 0015A050 38 03 00 00 */ addi r0, r3, 0
/* 8015D474 0015A054 38 64 00 4C */ addi r3, r4, 0x4c
/* 8015D478 0015A058 7C 60 1A 14 */ add r3, r0, r3
/* 8015D47C 0015A05C 80 01 00 1C */ lwz r0, 0x1c(r1)
/* 8015D480 0015A060 38 21 00 18 */ addi r1, r1, 0x18
/* 8015D484 0015A064 7C 08 03 A6 */ mtlr r0
/* 8015D488 0015A068 4E 80 00 20 */ blr
} // clang-format on
#pragma pop

#else

// needs a @frank patch
s32* gmMainLib_8015D450(s32 arg0)
{
return &gmMainLib_8015EDBC()->x4C[arg0 & 255];
}

#endif

s32 gmMainLib_8015D48C(u8 arg0)
{
struct gmm_x1F2C* base = &gmMainLib_804D3EE0->thing.x1F2C[0];
Expand Down
70 changes: 0 additions & 70 deletions src/melee/it/it_26B1.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,38 +537,7 @@ bool it_8026B894(HSD_GObj* gobj, HSD_GObj* ref_gobj)
return result;
}

/// @todo Inlined ASM due to compiler version generating mismatch
#ifdef MUST_MATCH
#pragma push
asm s32 it_8026B924(register HSD_GObj* gobj)
{ // clang-format off
// Get Item Data
lwz r4, 0x2C(gobj);
// Default return value
li r3, -1;
// Get Item ID
lwz r0, 0x10(r4);
// Item ID Switch
cmpwi r0, 0x17;
bge - lbl_compare;
cmpwi r0, 0x10;
beq - lbl_getVar;
bltlr - ;
cmpwi r0, 0x15;
bge - lbl_getVar;
blr;
lbl_compare:
cmpwi r0, 0x19;
bnelr - ;
lbl_getVar:
lwz r3, 0xD4C(r4);
} // clang-format on
#pragma pop

#else

/// Return result of unk item check
/// @todo Requires @c -g compiler flag / Frank modifications to match.
s32 it_8026B924(HSD_GObj* gobj)
{
s32 result;
Expand All @@ -592,44 +561,7 @@ s32 it_8026B924(HSD_GObj* gobj)
return result;
}

#endif

#ifdef MUST_MATCH
#pragma push
f32 it_8026B960(register HSD_GObj* gobj)
{ // clang-format off
register s32 kind;
register f32 unk_timer = -1.0f;

register Item* ip;
ip = GET_ITEM(gobj);
kind = ip->kind;

asm {
cmpwi kind, It_Kind_Link_Bomb
beq- lbl_block
bgelr-
cmpwi kind, It_Kind_BombHei
bnelr-
lwz kind, 0x24(ip);
cmpwi kind, 0xB;
beqlr-
}

return unk_timer = ip->xDD4_itemVar.BobOmb.xDEC;

lbl_block:
if (ip->msid != 0x5) {
return unk_timer = ip->xD44_lifeTimer;
}

return unk_timer;
} // clang-format on
#pragma pop
#else

/// Return float result of item kind and state checks
/// @todo Requires @c -g compiler flag / Frank modifications to match.
f32 it_8026B960(HSD_GObj* gobj)
{
s32 kind;
Expand All @@ -652,8 +584,6 @@ f32 it_8026B960(HSD_GObj* gobj)
return unk_timer;
}

#endif

extern void lb_8000B804(HSD_JObj*, HSD_Joint*);
extern void lb_8000BA0C(HSD_JObj*, f32);
extern void HSD_JObjRemoveAnimAll(HSD_JObj*);
Expand Down
6 changes: 2 additions & 4 deletions src/melee/it/it_26B1.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ void it_8026B7F8(Item_GObj* gobj);
/// Remove all GObj interaction references from item
bool it_8026B894(Item_GObj* gobj, HSD_GObj* referenced_gobj);

/// Return result of unk item check - requires -g compiler flag / Frank
/// modifications to match
/// Return result of unk item check
s32 it_8026B924(Item_GObj* gobj);

/// Return float result of item kind and state checks - requires -g compiler
/// flag / Frank modifications to match
/// Return float result of item kind and state checks
f32 it_8026B960(Item_GObj* gobj);

/// Multiply item's scale
Expand Down
30 changes: 0 additions & 30 deletions src/sysdolphin/baselib/lobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,34 +882,6 @@ void HSD_LObj_803668EC(HSD_LObj* lobj)
LObjReplaceAll(lobj);
}

#ifdef MUST_MATCH

#pragma push
asm HSD_LObj* HSD_LObjGetCurrentByType(u16 type)
{ // clang-format off
nofralloc
/* 80366A44 00363624 80 8D BF 9C */ lwz r4, current_lights(r13)
/* 80366A48 00363628 54 65 07 BE */ clrlwi r5, r3, 0x1e
/* 80366A4C 0036362C 48 00 00 1C */ b lbl_80366A68
lbl_80366A50:
/* 80366A50 00363630 80 64 00 04 */ lwz r3, 4(r4)
/* 80366A54 00363634 A0 03 00 08 */ lhz r0, 8(r3)
/* 80366A58 00363638 54 00 07 BE */ clrlwi r0, r0, 0x1e
/* 80366A5C 0036363C 7C 05 00 40 */ cmplw r5, r0
/* 80366A60 00363640 4D 82 00 20 */ beqlr
/* 80366A64 00363644 80 84 00 00 */ lwz r4, 0(r4)
lbl_80366A68:
/* 80366A68 00363648 28 04 00 00 */ cmplwi r4, 0
/* 80366A6C 0036364C 40 82 FF E4 */ bne lbl_80366A50
/* 80366A70 00363650 38 60 00 00 */ li r3, 0
/* 80366A74 00363654 4E 80 00 20 */ blr
} // clang-format on
#pragma pop

#else

/// @todo Broken by frank.
/// (Profile compiler does not generate beqlr, so instructions do not match)
HSD_LObj* HSD_LObjGetCurrentByType(u16 flags)
{
HSD_SList* cur = current_lights;
Expand All @@ -924,8 +896,6 @@ HSD_LObj* HSD_LObjGetCurrentByType(u16 flags)
return NULL;
}

#endif

s32 HSD_LightID2Index(GXLightID arg0)
{
s32 var_r31;
Expand Down

0 comments on commit c7ef3e6

Please sign in to comment.