diff options
author | YamaArashi <shadow962@live.com> | 2017-05-05 20:02:16 -0700 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2017-05-05 20:04:15 -0700 |
commit | 08725a4773d8530fe3a58824b647f6c2e90b2771 (patch) | |
tree | 2ac2ffcca4ef132e2009bea1ffbc57a233a2b751 | |
parent | 084dc5134cedbb7e1b2ae280ecbcb3884993a7be (diff) |
German ProcessRecvCmds
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | common_syms/link.txt | 4 | ||||
-rw-r--r-- | src/link.c | 46 | ||||
-rw-r--r-- | tools/ramscrgen/main.cpp | 26 | ||||
-rw-r--r-- | tools/ramscrgen/sym_file.cpp | 67 | ||||
-rw-r--r-- | tools/ramscrgen/sym_file.h | 3 |
6 files changed, 125 insertions, 30 deletions
@@ -142,14 +142,17 @@ $$($1_DATA_ASM_OBJS): LANGUAGE := $4 build/$1/data/%.o: data/%.s $$$$(asm_dep) $$(PREPROC) $$< charmap.txt | $$(AS) $$(ASFLAGS) --defsym $$(VERSION)=1 --defsym REVISION=$$(REVISION) --defsym $$(LANGUAGE)=1 -o $$@ +build/$1/sym_bss.ld: LANGUAGE := $4 build/$1/sym_bss.ld: sym_bss.txt - cd build/$1 && ../../$$(RAMSCRGEN) .bss ../../sym_bss.txt >sym_bss.ld + cd build/$1 && ../../$$(RAMSCRGEN) .bss ../../sym_bss.txt $$(LANGUAGE) >sym_bss.ld +build/$1/sym_common.ld: LANGUAGE := $4 build/$1/sym_common.ld: sym_common.txt $$($1_C_OBJS) $$(wildcard common_syms/*.txt) - cd build/$1 && ../../$$(RAMSCRGEN) COMMON ../../sym_common.txt -c src,../../common_syms >sym_common.ld + cd build/$1 && ../../$$(RAMSCRGEN) COMMON ../../sym_common.txt $$(LANGUAGE) -c src,../../common_syms >sym_common.ld +build/$1/sym_ewram.ld: LANGUAGE := $4 build/$1/sym_ewram.ld: sym_ewram.txt - cd build/$1 && ../../$$(RAMSCRGEN) ewram_data ../../sym_ewram.txt >sym_ewram.ld + cd build/$1 && ../../$$(RAMSCRGEN) ewram_data ../../sym_ewram.txt $$(LANGUAGE) >sym_ewram.ld build/$1/ld_script.ld: ld_script.txt build/$1/sym_bss.ld build/$1/sym_common.ld build/$1/sym_ewram.ld cd build/$1 && sed -f ../../ld_script.sed ../../ld_script.txt | sed "s#tools/#../../tools/#g" | sed "s#sound/#../../sound/#g" >ld_script.ld diff --git a/common_syms/link.txt b/common_syms/link.txt index bca63a8d2..faafda4d0 100644 --- a/common_syms/link.txt +++ b/common_syms/link.txt @@ -5,6 +5,10 @@ gLinkErrorOccurred 4 gLinkDebugValue2 4 +#begin GERMAN +deUnkValue1 +deUnkValue2 +#end gLinkPlayerPending gLinkPlayers gBlockReceived diff --git a/src/link.c b/src/link.c index 783f6aecd..e8bbaab2b 100644 --- a/src/link.c +++ b/src/link.c @@ -149,6 +149,11 @@ struct Link gLink; u8 gLastRecvQueueCount; u16 gLinkSavedIme; +#ifdef GERMAN +u8 deUnkValue1; +u8 deUnkValue2; +#endif + EWRAM_DATA bool8 gLinkTestDebugValuesEnabled = {0}; EWRAM_DATA bool8 gLinkTestDummyBool = {0}; EWRAM_DATA u32 gFiller_20238B8 = {0}; @@ -479,6 +484,9 @@ static void ProcessRecvCmds(u8 unusedParam) memcpy(localLinkPlayerBlock.magic2, sMagic, sizeof(localLinkPlayerBlock.magic2) - 1); InitBlockSend(&localLinkPlayerBlock, sizeof(localLinkPlayerBlock)); break; + case 0x4444: + word_3002910[i] = gRecvCmds[1][i]; + break; case 0x5555: byte_3002A68 = 1; break; @@ -549,23 +557,28 @@ static void ProcessRecvCmds(u8 unusedParam) sub_80516C4(i, gRecvCmds[1][i]); break; case 0xCCCC: - { - const u32 *addresses; - const u32 *sizes; - void *data; - u16 size; - - addresses = sBlockRequestLookupTable; - data = (void *)addresses[gRecvCmds[1][i] * 2]; - - sizes = addresses + 1; - size = sizes[gRecvCmds[1][i] * 2]; +#if defined(ENGLISH) + SendBlock(0, (void *)(sBlockRequestLookupTable)[gRecvCmds[1][i] * 2], (sBlockRequestLookupTable + 1)[gRecvCmds[1][i] * 2]); +#elif defined(GERMAN) + if (deUnkValue2 == 1) + { + deUnkValue2 = 2; + deUnkValue1 = gRecvCmds[1][i]; + } + else if (deUnkValue2 == 2 || deUnkValue2 == 3) + { + SendBlock(0, (void *)(sBlockRequestLookupTable)[gRecvCmds[1][i] * 2], (sBlockRequestLookupTable + 1)[gRecvCmds[1][i] * 2]); - SendBlock(0, data, size); - break; - } - case 0x4444: - word_3002910[i] = gRecvCmds[1][i]; + if (deUnkValue2 == 2) + deUnkValue2 = 1; + else + deUnkValue2 = 0; + } + else + { + SendBlock(0, (void *)(sBlockRequestLookupTable)[gRecvCmds[1][i] * 2], (sBlockRequestLookupTable + 1)[gRecvCmds[1][i] * 2]); + } +#endif break; case 0xCAFE: word_3002910[i] = gRecvCmds[1][i]; @@ -676,6 +689,7 @@ void OpenLinkTimed(void) { sPlayerDataExchangeStatus = EXCHANGE_NOT_STARTED; gLinkTimeOutCounter = 0; + ResetBlockSend(); OpenLink(); } diff --git a/tools/ramscrgen/main.cpp b/tools/ramscrgen/main.cpp index 5c803c31f..6c4f4bbd7 100644 --- a/tools/ramscrgen/main.cpp +++ b/tools/ramscrgen/main.cpp @@ -25,7 +25,7 @@ #include "sym_file.h" #include "elf.h" -void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath) +void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath, std::string lang) { auto commonSymbols = GetCommonSymbols(sourcePath + "/" + filename); @@ -40,6 +40,8 @@ void HandleCommonInclude(std::string filename, std::string sourcePath, std::stri while (!symFile.IsAtEnd()) { + symFile.HandleLangConditional(lang); + std::string label = symFile.GetLabel(false); if (label.length() == 0) @@ -71,12 +73,14 @@ void HandleCommonInclude(std::string filename, std::string sourcePath, std::stri } } -void ConvertSymFile(std::string filename, std::string sectionName, bool common, std::string sourcePath, std::string commonSymPath) +void ConvertSymFile(std::string filename, std::string sectionName, std::string lang, bool common, std::string sourcePath, std::string commonSymPath) { SymFile symFile(filename); while (!symFile.IsAtEnd()) { + symFile.HandleLangConditional(lang); + Directive directive = symFile.GetDirective(); switch (directive) @@ -87,10 +91,9 @@ void ConvertSymFile(std::string filename, std::string sectionName, bool common, symFile.ExpectEmptyRestOfLine(); printf(". = ALIGN(4);\n"); if (common) - HandleCommonInclude(incFilename, sourcePath, commonSymPath); + HandleCommonInclude(incFilename, sourcePath, commonSymPath, lang); else printf("%s(%s);\n", incFilename.c_str(), sectionName.c_str()); - printf(". = ALIGN(4);\n"); break; } case Directive::Space: @@ -133,28 +136,29 @@ void ConvertSymFile(std::string filename, std::string sectionName, bool common, int main(int argc, char **argv) { - if (argc < 3) + if (argc < 4) { - fprintf(stderr, "Usage: %s SECTION_NAME SYM_FILE [-c SRC_PATH,COMMON_SYM_PATH]", argv[0]); + fprintf(stderr, "Usage: %s SECTION_NAME SYM_FILE LANG [-c SRC_PATH,COMMON_SYM_PATH]", argv[0]); return 1; } bool common = false; std::string sectionName = std::string(argv[1]); std::string symFileName = std::string(argv[2]); + std::string lang = std::string(argv[3]); std::string sourcePath; std::string commonSymPath; - if (argc > 3) + if (argc > 4) { - if (std::strcmp(argv[3], "-c") != 0) + if (std::strcmp(argv[4], "-c") != 0) FATAL_ERROR("error: unrecognized argument \"%s\"\n", argv[4]); - if (argc < 5) + if (argc < 6) FATAL_ERROR("error: missing SRC_PATH,COMMON_SYM_PATH after \"-c\"\n"); common = true; - std::string paths = std::string(argv[4]); + std::string paths = std::string(argv[5]); std::size_t commaPos = paths.find(','); if (commaPos == std::string::npos) @@ -164,6 +168,6 @@ int main(int argc, char **argv) commonSymPath = paths.substr(commaPos + 1); } - ConvertSymFile(symFileName, sectionName, common, sourcePath, commonSymPath); + ConvertSymFile(symFileName, sectionName, lang, common, sourcePath, commonSymPath); return 0; } diff --git a/tools/ramscrgen/sym_file.cpp b/tools/ramscrgen/sym_file.cpp index 9d9e4a064..5379bd93f 100644 --- a/tools/ramscrgen/sym_file.cpp +++ b/tools/ramscrgen/sym_file.cpp @@ -53,6 +53,7 @@ SymFile::SymFile(std::string filename) : m_filename(filename) m_pos = 0; m_lineNum = 1; m_lineStart = 0; + m_inLangConditional = false; RemoveComments(); } @@ -387,12 +388,78 @@ void SymFile::ExpectEmptyRestOfLine() } } + +void SymFile::SkipLine() +{ + while (m_buffer[m_pos] != 0 && m_buffer[m_pos] != '\n') + m_pos++; + + if (m_buffer[m_pos] == '\n') + m_pos++; +} + // Checks if we're at the end of the file. bool SymFile::IsAtEnd() { return (m_pos >= m_size); } +void SymFile::HandleLangConditional(std::string lang) +{ + if (m_buffer[m_pos] != '#') + return; + + m_pos++; + + if (CheckForDirective("begin")) + { + if (m_inLangConditional) + RaiseError("already inside language conditional"); + + SkipWhitespace(); + + std::string label = GetLabel(false); + + if (label.length() == 0) + RaiseError("no language name after #begin"); + + ExpectEmptyRestOfLine(); + + if (lang == label) + { + m_inLangConditional = true; + } + else + { + while (!IsAtEnd() && m_buffer[m_pos] != '#') + SkipLine(); + + if (m_buffer[m_pos] != '#') + RaiseError("unterminated language conditional"); + + m_pos++; + + if (!CheckForDirective("end")) + RaiseError("expected #end"); + + ExpectEmptyRestOfLine(); + } + } + else if (CheckForDirective("end")) + { + if (!m_inLangConditional) + RaiseError("not inside language conditional"); + + m_inLangConditional = false; + + ExpectEmptyRestOfLine(); + } + else + { + RaiseError("unknown # directive"); + } +} + // Reports a diagnostic message. void SymFile::ReportDiagnostic(const char* type, const char* format, std::va_list args) { diff --git a/tools/ramscrgen/sym_file.h b/tools/ramscrgen/sym_file.h index 5b3cedb3b..bb0c8038d 100644 --- a/tools/ramscrgen/sym_file.h +++ b/tools/ramscrgen/sym_file.h @@ -46,7 +46,9 @@ public: std::string ReadPath(); bool ReadInteger(unsigned long& value); void ExpectEmptyRestOfLine(); + void SkipLine(); bool IsAtEnd(); + void HandleLangConditional(std::string lang); void RaiseError(const char* format, ...); void RaiseWarning(const char* format, ...); @@ -57,6 +59,7 @@ private: long m_lineNum; long m_lineStart; std::string m_filename; + bool m_inLangConditional; bool ConsumeComma(); void RemoveComments(); |