-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72911a6
commit a378ba0
Showing
983 changed files
with
124,717 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Build/ | ||
__pycache__/ | ||
.cache/ | ||
.vscode/ | ||
|
||
code.bin | ||
compile_commands.json | ||
|
||
baserom | ||
asm | ||
*.3ds | ||
*.elf | ||
*.o | ||
*.s | ||
*.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "Library/nnsdk"] | ||
path = Library/nnsdk | ||
url = [email protected]:gamestabled/auto_nnsdk.git | ||
[submodule "Tools/asm-differ"] | ||
path = Tools/asm-differ | ||
url = https://github.com/3dsdecomp/asm-differ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
if(_ARMCC_CMAKE_LOADED) | ||
return() | ||
endif() | ||
set(_ARMCC_CMAKE_LOADED TRUE) | ||
|
||
# See ARM Compiler documentation at: | ||
# http://infocenter.arm.com/help/topic/com.arm.doc.set.swdev/index.html | ||
|
||
get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) | ||
get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) | ||
|
||
set(CMAKE_EXECUTABLE_SUFFIX ".axf") | ||
|
||
find_program(CMAKE_ARMCC_LINKER armlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) | ||
find_program(CMAKE_ARMCC_AR armar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) | ||
|
||
set(CMAKE_LINKER "${CMAKE_ARMCC_LINKER}" CACHE FILEPATH "The ARMCC linker" FORCE) | ||
mark_as_advanced(CMAKE_ARMCC_LINKER) | ||
set(CMAKE_AR "${CMAKE_ARMCC_AR}" CACHE FILEPATH "The ARMCC archiver" FORCE) | ||
mark_as_advanced(CMAKE_ARMCC_AR) | ||
|
||
macro(__compiler_armcc lang) | ||
string(APPEND CMAKE_${lang}_FLAGS_INIT " ") | ||
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") | ||
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Ospace -DNDEBUG") | ||
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Otime -DNDEBUG") | ||
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") | ||
|
||
set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") | ||
set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) | ||
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "--via=") | ||
|
||
set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --list <TARGET_BASE>.map") | ||
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>") | ||
|
||
set(CMAKE_DEPFILE_FLAGS_${lang} "--depend=<DEP_FILE> --no_depend_system_headers") | ||
|
||
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ") | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/ARMCC.cmake) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
if(NOT DEFINED ENV{ARMCC_PATH}) | ||
message(FATAL_ERROR "please set ARMCC_PATH") | ||
endif() | ||
|
||
find_program(ARM_ASM NAMES armasm.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH) | ||
find_program(ARM_AR NAMES armar.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH) | ||
find_program(ARM_CC NAMES armcc.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH) | ||
find_program(ARM_LINK NAMES armlink.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH) | ||
find_program(ARM_FROMELF NAMES fromelf.exe PATHS $ENV{ARMCC_PATH}/bin REQUIRED NO_DEFAULT_PATH) | ||
|
||
macro (set_compilers) | ||
set(CMAKE_CXX_COMPILER_ID ARMCC) | ||
|
||
set(CMAKE_AR ${ARM_AR}) | ||
set(CMAKE_C_COMPILER ${ARM_CC}) | ||
set(CMAKE_CXX_COMPILER ${ARM_CC}) | ||
set(CMAKE_ASM_COMPILER ${ARM_ASM}) | ||
set(CMAKE_LINKER ${ARM_LINK}) | ||
endmacro() | ||
|
||
if (WIN32) | ||
set_compilers() | ||
set(CMAKE_C_COMPILER_WORKS TRUE) | ||
set(CMAKE_CXX_COMPILER_WORKS TRUE) | ||
set(CMAKE_ASM_COMPILER_WORKS TRUE) | ||
endif() | ||
|
||
project(oot3d C CXX ASM) | ||
|
||
if (NOT WIN32) | ||
set_compilers() | ||
endif() | ||
|
||
set(CMAKE_EXECUTABLE_SUFFIX ".axf") | ||
|
||
__compiler_armcc(C) | ||
__compiler_armcc(CXX) | ||
__compiler_armcc(ASM) | ||
|
||
add_subdirectory(Library) | ||
add_subdirectory(Disassembly) | ||
|
||
file(GLOB_RECURSE csourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/Source/*.c) | ||
file(GLOB_RECURSE cxxsourcefiles ${CMAKE_CURRENT_SOURCE_DIR}/Source/*.cpp) | ||
|
||
SET(CXX_FLAGS "--apcs=//interwork --cpu=MPCore --fpmode=fast --vfe --no_rtti --no_rtti_data --cpp --arm --force_new_nothrow --signed_chars --multibyte-chars --locale=japanese --data-reorder --split_sections --forceinline -O3 -Otime") | ||
|
||
SET_SOURCE_FILES_PROPERTIES( | ||
${cxxsourcefiles} | ||
PROPERTIES | ||
COMPILE_FLAGS "${CXX_FLAGS}" | ||
) | ||
|
||
SET_SOURCE_FILES_PROPERTIES( | ||
${CMAKE_SOURCE_DIR}/data/conststring.cpp | ||
PROPERTIES | ||
COMPILE_FLAGS | ||
"${CXX_FLAGS} --no_data_reorder" | ||
) | ||
|
||
add_executable(oot3d ${csourcefiles} ${cxxsourcefiles}) | ||
|
||
add_custom_command( | ||
DEPENDS oot3d ${CMAKE_CURRENT_BINARY_DIR}/oot3d.axf | ||
COMMAND ${ARM_FROMELF} --bincombined --bincombined_padding=1,0x00 ${CMAKE_CURRENT_BINARY_DIR}/oot3d.axf --output ${CMAKE_CURRENT_BINARY_DIR}/code.bin | ||
COMMAND python -c "with open('${CMAKE_CURRENT_BINARY_DIR}/code.bin', 'a') as code: code.truncate(0x45B000)" | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/code.bin | ||
COMMENT "Creating code.bin..." | ||
) | ||
|
||
add_custom_target( | ||
code | ||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/code.bin | ||
) | ||
|
||
add_custom_target( | ||
check | ||
DEPENDS code ${CMAKE_CURRENT_BINARY_DIR}/code.bin | ||
COMMENT "Checking for match..." | ||
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && md5sum -c ${CMAKE_CURRENT_SOURCE_DIR}/Data/checksum.md5 | ||
) | ||
|
||
set(NON_MATCH_ASM_FILES ${CMAKE_CURRENT_BINARY_DIR}/nonmatch) | ||
set(DISASSEMBLY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Disassembly) | ||
file(MAKE_DIRECTORY ${NON_MATCH_ASM_FILES}) | ||
|
||
foreach(CPP_FILE ${cxxsourcefiles}) | ||
get_filename_component(FILE_NAME ${CPP_FILE} NAME_WE) | ||
add_custom_command( | ||
OUTPUT ${NON_MATCH_ASM_FILES}/${FILE_NAME}.s | ||
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/tools/preproc.py ${CPP_FILE} ${NON_MATCH_ASM_FILES}/${FILE_NAME}.s "${DISASSEMBLY_DIR}/" | ||
DEPENDS ${CPP_FILE} | ||
) | ||
set_source_files_properties(${NON_MATCH_ASM_FILES}/${FILE_NAME}.s PROPERTIES COMPILE_FLAGS "--cpu=MPCore") | ||
target_sources(oot3d PUBLIC ${NON_MATCH_ASM_FILES}/${FILE_NAME}.s) | ||
endforeach() | ||
|
||
target_link_libraries(oot3d PUBLIC nnsdk) | ||
|
||
target_link_options(oot3d PUBLIC | ||
--cpu=MPCore --entry=__ctr_start --startup=__ctr_start --library_type=standardlib | ||
--ref_cpp_init --scanlib --legacyalign | ||
--tailreorder --remove --datacompressor=off | ||
--inline --via ${CMAKE_CURRENT_SOURCE_DIR}/Data/keep_symbols.txt | ||
--verbose --mangled --symbols --vfemode=force | ||
--scatter=${CMAKE_CURRENT_SOURCE_DIR}/Data/oot3d.ld | ||
--diag_suppress=6238,6306 | ||
) | ||
|
||
target_include_directories(oot3d PUBLIC ${CMAKE_SOURCE_DIR}/Include ${CMAKE_SOURCE_DIR}/Library/nnsdk/Include ${CMAKE_SOURCE_DIR}/Source/Game) | ||
|
||
add_dependencies(oot3d disasm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20c7ec6288ba0af4feb6db646c6cc6d5 Build/code.bin |
Oops, something went wrong.