Skip to content

Commit

Permalink
Merge remote-tracking branch 'decomp/main' into decomp_update_3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanis002 committed Jul 18, 2024
2 parents d2001cc + 17a8874 commit 9e7351b
Show file tree
Hide file tree
Showing 51 changed files with 14,584 additions and 405 deletions.
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"OOT_DEBUG=1", // If targeting a debug version
"ENABLE_HACKEROOT=1",
"RELEASE_ROM=0",
"COMPRESS_YAZ=1"
"COMPRESS_YAZ=1",
"OOT_PAL=1"
],
"cStandard": "gnu11",
"cppStandard": "${default}" // Only ZAPD uses C++, so doesn't really matter
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,23 @@ endif
# Version-specific settings
ifeq ($(VERSION),gc-us)
DEBUG := 0
CPP_DEFINES += -DTEXT_LANGUAGE=TEXT_LANG_US_JP
COMPARE := 0
CPP_DEFINES += -DOOT_NTSC=1 -DOOT_PAL=0 -DOOT_MQ=0
else ifeq ($(VERSION),gc-eu)
DEBUG := 0
CPP_DEFINES += -DTEXT_LANGUAGE=TEXT_LANG_EU
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=0
HACKEROOT := 0
else ifeq ($(VERSION),gc-eu-mq)
DEBUG := 0
CPP_DEFINES += -DTEXT_LANGUAGE=TEXT_LANG_EU -DOOT_MQ
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=1
HACKEROOT := 0
else ifeq ($(VERSION),gc-eu-mq-dbg)
DEBUG := 1
CPP_DEFINES += -DTEXT_LANGUAGE=TEXT_LANG_EU -DOOT_MQ
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=1
HACKEROOT := 0
else ifeq ($(VERSION),hackeroot-mq)
DEBUG := 1
CPP_DEFINES += -DTEXT_LANGUAGE=TEXT_LANG_EU -DOOT_MQ
CPP_DEFINES += -DOOT_NTSC=0 -DOOT_PAL=1 -DOOT_MQ=1
HACKEROOT := 1
else
$(error Unsupported version $(VERSION))
Expand Down Expand Up @@ -560,7 +561,7 @@ $(BUILD_DIR)/assets/text/nes_message_data_static.o: $(BUILD_DIR)/assets/text/mes
$(BUILD_DIR)/assets/text/ger_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/fra_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/staff_message_data_static.o: $(BUILD_DIR)/assets/text/message_data_staff.enc.nes.h
$(BUILD_DIR)/src/code/z_message_PAL.o: assets/text/message_data.h assets/text/message_data_staff.h
$(BUILD_DIR)/src/code/z_message.o: assets/text/message_data.h assets/text/message_data_staff.h

$(BUILD_DIR)/assets/text/%.o: assets/text/%.c
$(call print,Compiling:,$<,$@)
Expand Down
6 changes: 3 additions & 3 deletions assets/text/nes_message_data_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#define DEFINE_MESSAGE_JPN(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Not Present */

#if (TEXT_LANGUAGE == TEXT_LANG_US_JP)
// On US/JP versions, the font message is with JPN
#if OOT_NTSC
// On NTSC versions, the font message is with JPN
#define DEFINE_MESSAGE_FFFC(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Not Present */
#else
// On EU versions, the font message is with NES
// On PAL versions, the font message is with NES
#define DEFINE_MESSAGE_FFFC(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
/* Present */ const char _message_##textId##_nes[] = nesMessage;
#endif
Expand Down
130 changes: 65 additions & 65 deletions assets/xml/textures/icon_item_static.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/xml/textures/icon_item_static_pal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<Texture Name="gNamePanelRightTex" OutName="name_panel_right" Format="ia8" Width="72" Height="24" Offset="0x88280"/>
<Texture Name="gLButtonTex" OutName="l_button" Format="ia8" Width="24" Height="32" Offset="0x88940"/>
<Texture Name="gRButtonTex" OutName="r_button" Format="ia8" Width="24" Height="32" Offset="0x88C40"/>
<Texture Name="gUnknownJPTex" OutName="unknown_JP" Format="ia8" Width="80" Height="16" Offset="0x88F40"/>
<Texture Name="gUnknownJPNTex" OutName="unknown_jpn" Format="ia8" Width="80" Height="16" Offset="0x88F40"/>
<Texture Name="gSongNoteTex" OutName="song_note" Format="ia8" Width="16" Height="24" Offset="0x89440"/>
<Texture Name="gMagicArrowEquipEffectTex" OutName="magic_arrow_equip_effect" Format="ia8" Width="32" Height="32" Offset="0x895C0"/>
<DList Name="gItemNamePanelDL" Offset="0x899C0"/>
Expand Down
2 changes: 1 addition & 1 deletion assets/xml/textures/parameter_static.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<Texture Name="gOcarinaBtnIconCLeftTex" OutName="ocarina_c_left" Format="ia8" Width="16" Height="16" Offset="0x2C40"/>
<Texture Name="gOcarinaBtnIconCUpTex" OutName="ocarina_c_up" Format="ia8" Width="16" Height="16" Offset="0x2D40"/>
<Texture Name="gOcarinaTrebleClefTex" OutName="ocarina_treble_clef" Format="i4" Width="16" Height="32" Offset="0x2E40"/>
<Texture Name="gNaviCUpJPTex" OutName="navi_c_up_jp" Format="ia4" Width="32" Height="8" Offset="0x2F40"/>
<Texture Name="gNaviCUpJPNTex" OutName="navi_c_up_jpn" Format="ia4" Width="32" Height="8" Offset="0x2F40"/>
<Texture Name="gNaviCUpENGTex" OutName="navi_c_up_eng" Format="ia4" Width="32" Height="8" Offset="0x2FC0"/>
<Texture Name="gCounterDigit0Tex" OutName="counter_digit_0" Format="i8" Width="8" Height="16" Offset="0x3040"/>
<Texture Name="gCounterDigit1Tex" OutName="counter_digit_1" Format="i8" Width="8" Height="16" Offset="0x30C0"/>
Expand Down
2 changes: 1 addition & 1 deletion assets/xml/textures/title_static.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Texture Name="gFileSelShadowMedallionTex" OutName="shadow_medallion" Format="ia8" Width="16" Height="16" Offset="0x2D80"/>
<Texture Name="gFileSelLightMedallionTex" OutName="light_medallion" Format="ia8" Width="16" Height="16" Offset="0x2E80"/>

<Texture Name="gFileSelWhichFile1JPNTex" OutName="which_file_1_jpn" Format="ia8" Width="128" Height="16" Offset="0x2F80"/>
<Texture Name="gFileSelCopyWhichFileJPNTex" OutName="copy_which_file_jpn" Format="ia8" Width="128" Height="16" Offset="0x2F80"/>
<Texture Name="gFileSelCopyToWhichFileJPNTex" OutName="copy_to_which_file_jpn" Format="ia8" Width="128" Height="16" Offset="0x3780"/>
<Texture Name="gFileSelAreYouSureJPNTex" OutName="are_you_sure_jpn" Format="ia8" Width="128" Height="16" Offset="0x3F80"/>
<Texture Name="gFileSelFileCopiedJPNTex" OutName="file_copied_jpn" Format="ia8" Width="128" Height="16" Offset="0x4780"/>
Expand Down
2 changes: 1 addition & 1 deletion extract_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def ExtractFile(assetConfig: version_config.AssetConfig, outputPath: Path, outpu
if exitValue != 0:
globalAbort.set()
print("\n")
print("Error when extracting from file " + xmlPath, file=os.sys.stderr)
print(f"Error when extracting from file {xmlPath}", file=os.sys.stderr)
print("Aborting...", file=os.sys.stderr)
print("\n")

Expand Down
47 changes: 34 additions & 13 deletions format.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import glob
import multiprocessing
import os
from pathlib import Path
import re
import shutil
import subprocess
Expand Down Expand Up @@ -94,14 +95,25 @@ def run_clang_apply_replacements(tmp_dir: str):
subprocess.run(exec_str, shell=True)


def add_final_new_line(file: str):
# https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html
# "gets the last character of the file pipes it into read, which will exit with a nonzero exit
# code if it encounters EOF before newline (so, if the last character of the file isn't a newline).
# If read exits nonzero, then append a newline onto the file using echo (if read exits 0,
# that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616)
exec_str = f"tail -c1 {file} | read -r _ || echo >> {file}"
subprocess.run(exec_str, shell=True)
def cleanup_whitespace(file: str):
"""
Remove whitespace at the end of lines,
ensure the file ends with an empty line.
"""
file_p = Path(file)
contents = file_p.read_text(encoding="UTF-8")
modified = False

contents, n_subst = re.subn(r"[^\S\n]+\n", "\n", contents)
if n_subst != 0:
modified = True

if not contents.endswith("\n"):
contents += "\n"
modified = True

if modified:
file_p.write_text(contents, encoding="UTF-8")


def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int):
Expand Down Expand Up @@ -134,14 +146,24 @@ def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int):
else:
run_clang_tidy(src_files)

print("Adding missing final new lines...")
# Adding final new lines is safe to do in parallel and can be applied to all types of files
print("Cleaning up whitespace...")
# Safe to do in parallel and can be applied to all types of files
with multiprocessing.get_context("fork").Pool(nb_jobs) as pool:
pool.map(add_final_new_line, src_files + extra_files)
pool.map(cleanup_whitespace, src_files + extra_files)

print("Done formatting files.")


def list_files_to_format():
files = glob.glob("src/**/*.c", recursive=True)
extra_files = (
glob.glob("assets/**/*.xml", recursive=True)
+ glob.glob("include/**/*.h", recursive=True)
+ glob.glob("src/**/*.h", recursive=True)
)
return files, extra_files


def main():
parser = argparse.ArgumentParser(description="Format files in the codebase to enforce most style rules")
parser.add_argument(
Expand Down Expand Up @@ -179,8 +201,7 @@ def main():
files = args.files
extra_files = []
else:
files = glob.glob("src/**/*.c", recursive=True)
extra_files = glob.glob("assets/**/*.xml", recursive=True)
files, extra_files = list_files_to_format()

format_files(files, extra_files, nb_jobs)

Expand Down
6 changes: 6 additions & 0 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ extern struct GraphicsContext* __gfxCtx;

#endif /* IS_DEBUG */

#if OOT_NTSC
#define LANGUAGE_ARRAY(jpn, nes, ger, fra) { jpn, nes }
#else
#define LANGUAGE_ARRAY(jpn, nes, ger, fra) { nes, ger, fra }
#endif

/**
* `x` vertex x
* `y` vertex y
Expand Down
3 changes: 0 additions & 3 deletions include/message_data_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include "z64item.h" // For item ids
#include "sfx.h" // For sfx ids

#define TEXT_LANG_US_JP 0
#define TEXT_LANG_EU 1

/*
* Text control characters
*/
Expand Down
2 changes: 1 addition & 1 deletion include/message_data_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct {

/* Non-Credits Messages */

#if (TEXT_LANGUAGE == TEXT_LANG_US_JP)
#if OOT_NTSC
#define DEFINE_MESSAGE_NES(textId, type, yPos, jpnMessage, nesMessage, gerMessage, fraMessage) \
extern const char _message_##textId##_nes[];

Expand Down
19 changes: 19 additions & 0 deletions include/regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,18 @@
#define R_PAUSE_PAGE_SWITCH_FRAME_ADVANCE_ON ZREG(13)
#define R_C_BTN_COLOR(i) ZREG(39 + (i))
#define R_B_BTN_COLOR(i) ZREG(43 + (i))
#if OOT_NTSC
#define R_START_LABEL_SCALE ZREG(48)
#define R_START_LABEL_DD(i) ZREG(49 + (i))
#define R_START_LABEL_WIDTH ZREG(51)
#define R_START_LABEL_HEIGHT ZREG(52)
#define R_START_LABEL_Y(i) ZREG(53 + (i))
#define R_START_LABEL_X(i) ZREG(55 + (i))
#else
#define R_START_LABEL_DD(i) ZREG(48 + (i))
#define R_START_LABEL_Y(i) ZREG(51 + (i))
#define R_START_LABEL_X(i) ZREG(54 + (i))
#endif
#define R_C_UP_BTN_X ZREG(62)
#define R_C_UP_BTN_Y ZREG(63)
#define R_START_BTN_X ZREG(68)
Expand Down Expand Up @@ -167,11 +176,21 @@
#define R_ROOM_CULL_USED_ENTRIES iREG(88)
#define R_ROOM_CULL_DEBUG_TARGET iREG(89)
#define R_B_LABEL_DD WREG(0)
#if OOT_NTSC
#define R_B_LABEL_SCALE(i) WREG(8 + (i))
#define R_B_LABEL_X(i) WREG(10 + (i))
#define R_B_LABEL_Y(i) WREG(12 + (i))
#define R_A_LABEL_Z(i) WREG(14 + (i))
#endif
#define R_OW_MINIMAP_X WREG(29)
#define R_OW_MINIMAP_Y WREG(30)
#define R_MINIMAP_DISABLED WREG(31)
#if OOT_PAL
#define R_B_LABEL_SCALE(i) WREG(37 + (i))
#define R_B_LABEL_X(i) WREG(40 + (i))
#define R_B_LABEL_Y(i) WREG(43 + (i))
#define R_A_LABEL_Z(i) WREG(46 + (i))
#endif
#define R_DGN_MINIMAP_X WREG(68)
#define R_DGN_MINIMAP_Y WREG(69)
#define R_TEXTBOX_X VREG(0)
Expand Down
22 changes: 22 additions & 0 deletions include/segment_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ DECLARE_ROM_SEGMENT(Audiobank)
DECLARE_ROM_SEGMENT(Audioseq)
DECLARE_ROM_SEGMENT(Audiotable)

#if OOT_NTSC
DECLARE_SEGMENT(kanji)
DECLARE_ROM_SEGMENT(kanji)
#endif

DECLARE_SEGMENT(link_animetion)
DECLARE_ROM_SEGMENT(link_animetion)

Expand All @@ -38,22 +43,37 @@ DECLARE_ROM_SEGMENT(icon_item_24_static)
DECLARE_ROM_SEGMENT(icon_item_field_static)
DECLARE_ROM_SEGMENT(icon_item_dungeon_static)
DECLARE_ROM_SEGMENT(icon_item_gameover_static)

#if OOT_NTSC
DECLARE_ROM_SEGMENT(icon_item_jpn_static)
DECLARE_ROM_SEGMENT(icon_item_nes_static)
#else
DECLARE_ROM_SEGMENT(icon_item_nes_static)
DECLARE_ROM_SEGMENT(icon_item_ger_static)
DECLARE_ROM_SEGMENT(icon_item_fra_static)
#endif

DECLARE_ROM_SEGMENT(item_name_static)
DECLARE_ROM_SEGMENT(map_name_static)
DECLARE_ROM_SEGMENT(do_action_static)
DECLARE_ROM_SEGMENT(message_static)
DECLARE_ROM_SEGMENT(message_texture_static)
DECLARE_ROM_SEGMENT(nes_font_static)

#if OOT_NTSC
DECLARE_SEGMENT(jpn_message_data_static)
DECLARE_ROM_SEGMENT(jpn_message_data_static)
DECLARE_SEGMENT(nes_message_data_static)
DECLARE_ROM_SEGMENT(nes_message_data_static)
#else
DECLARE_SEGMENT(nes_message_data_static)
DECLARE_ROM_SEGMENT(nes_message_data_static)
DECLARE_SEGMENT(ger_message_data_static)
DECLARE_ROM_SEGMENT(ger_message_data_static)
DECLARE_SEGMENT(fra_message_data_static)
DECLARE_ROM_SEGMENT(fra_message_data_static)
#endif

DECLARE_SEGMENT(staff_message_data_static)
DECLARE_ROM_SEGMENT(staff_message_data_static)

Expand Down Expand Up @@ -635,6 +655,7 @@ DECLARE_ROM_SEGMENT(spot20_room_0)

DECLARE_ROM_SEGMENT(ganon_tou_room_0)

#if OOT_DEBUG
DECLARE_ROM_SEGMENT(test01_room_0)

DECLARE_ROM_SEGMENT(besitu_room_0)
Expand All @@ -656,5 +677,6 @@ DECLARE_ROM_SEGMENT(testroom_room_1)
DECLARE_ROM_SEGMENT(testroom_room_2)
DECLARE_ROM_SEGMENT(testroom_room_3)
DECLARE_ROM_SEGMENT(testroom_room_4)
#endif

#endif
Loading

0 comments on commit 9e7351b

Please sign in to comment.