From 5f236d558aa37918f0286383ba9489a550283d7f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jun 2020 15:29:42 -0400 Subject: libsyscall.a source --- CMakeLists.txt | 2 + Makefile | 17 +++--- arm9/Makefile | 18 ++++-- arm9/arm9.lcf | 3 +- arm9/lib/Makefile | 89 ++++++++++++++++++++++++++++ arm9/lib/syscall/_svc_mw.s | 121 ++++++++++++++++++++++++++++++++++++++ arm9/modules/01/src/module_01.cpp | 14 ++--- include/nitro/types.h | 2 + include/sinit.h | 10 ++++ 9 files changed, 252 insertions(+), 24 deletions(-) create mode 100644 arm9/lib/Makefile create mode 100644 arm9/lib/syscall/_svc_mw.s create mode 100644 include/sinit.h diff --git a/CMakeLists.txt b/CMakeLists.txt index aac9651e..abf430db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_CXX_STANDARD 11) enable_language(ASM) +add_compile_options(-fms-extensions) + file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "*.c" "*.cpp") add_executable(PokeDiamond ${SOURCES}) diff --git a/Makefile b/Makefile index 4cb2b845..4180f456 100644 --- a/Makefile +++ b/Makefile @@ -204,6 +204,7 @@ TOOLS = $(foreach tool,$(TOOLBASE),$(TOOLS_DIR)/$(tool)/$(tool)$(EXE)) export LM_LICENSE_FILE := $(TOOLS_DIR)/mwccarm/license.dat export MWCIncludes := arm9/lib/include +export MWLibraries := arm9/lib ######################### Targets ########################### @@ -220,7 +221,7 @@ endif .SECONDARY: .DELETE_ON_ERROR: .SECONDEXPANSION: -.PHONY: all clean mostlyclean tidy tools $(TOOLDIRS) patch_mwasmarm arm9 arm7 +.PHONY: all libs clean mostlyclean tidy tools $(TOOLDIRS) patch_mwasmarm arm9 arm7 MAKEFLAGS += --no-print-directory @@ -230,18 +231,18 @@ ifeq ($(COMPARE),1) endif clean: mostlyclean - make -C arm9 clean - make -C arm7 clean - make -C tools/mwasmarm_patcher clean + $(MAKE) -C arm9 clean + $(MAKE) -C arm7 clean + $(MAKE) -C tools/mwasmarm_patcher clean mostlyclean: tidy - make -C arm9 mostlyclean - make -C arm7 mostlyclean + $(MAKE) -C arm9 mostlyclean + $(MAKE) -C arm7 mostlyclean find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' \) -exec $(RM) {} + tidy: - make -C arm9 tidy - make -C arm7 tidy + $(MAKE) -C arm9 tidy + $(MAKE) -C arm7 tidy $(RM) -r $(BUILD_DIR) tools: $(TOOLDIRS) diff --git a/arm9/Makefile b/arm9/Makefile index df04770c..0b880bd3 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -186,7 +186,8 @@ OBJCOPY := $(CROSS)objcopy ASFLAGS = -proc arm5te -i .. CFLAGS = -O4,p -proc arm946e -fp soft -lang c99 -Cpp_exceptions off -i ../include -ir ../include-mw -ir lib/include -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE) CXXFLAGS = -O4,p -proc arm946e -fp soft -lang c99 -Cpp_exceptions off -i ../include -ir ../include-mw -ir lib/include -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -LDFLAGS = -map -nodead -w off -proc v5te -interworking -map -symtab -m _start +LDFLAGS = -nodead -w off -proc v5te -interworking -map closure,unused -symtab sort -m _start +# LIBS := -Llib -lsyscall ####################### Other Tools ######################### @@ -202,7 +203,8 @@ TOOLBASE = $(TOOLDIRS:$(TOOLS_DIR)/%=%) TOOLS = $(foreach tool,$(TOOLBASE),$(TOOLS_DIR)/$(tool)/$(tool)$(EXE)) export LM_LICENSE_FILE := $(TOOLS_DIR)/mwccarm/license.dat -export MWCIncludes := lib/include +export MWCIncludes := $(CURDIR)/lib/include +export MWLibraries := $(CURDIR)/lib ######################### Targets ########################### @@ -217,24 +219,28 @@ NODEP := 1 endif .PRECIOUS: $(ROM) -.PHONY: all clean mostlyclean tidy tools $(TOOLDIRS) patch_mwasmarm +.PHONY: all libs clean mostlyclean tidy tools $(TOOLDIRS) patch_mwasmarm MAKEFLAGS += --no-print-directory -all: $(ROM) +all: libs $(ROM) ifeq ($(COMPARE),1) @$(SHA1SUM) -c $(TARGET).sha1 @echo $(ROM): OK endif +libs: + $(MAKE) -C lib + clean: mostlyclean - make -C $(TOOLS_DIR)/mwasmarm_patcher clean + $(MAKE) -C $(TOOLS_DIR)/mwasmarm_patcher clean mostlyclean: tidy find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' \) -exec $(RM) {} + tidy: $(RM) -r $(BUILD_DIR) + $(MAKE) clean -C lib tools: $(TOOLDIRS) @@ -277,7 +283,7 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) $(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $< $(ROM): $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) $(BIN_FILES) - $(LD) $(LDFLAGS) $(BUILD_DIR)/$(LD_SCRIPT) -o $(ELF) $(O_FILES) $(BIN_FILES) + $(LD) $(LDFLAGS) $(LIBS) $(BUILD_DIR)/$(LD_SCRIPT) -o $(ELF) $(O_FILES) $(BIN_FILES) $(OBJCOPY) --update-section arm9=$@ -j arm9 $(foreach ov,$(OVERLAYS),--update-section $(ov)=$(BUILD_DIR)/$(ov).sbin -j $(ov)) $(ELF) 2>/dev/null # Make sure build directory exists before compiling anything diff --git a/arm9/arm9.lcf b/arm9/arm9.lcf index fced9d86..9fb4de49 100644 --- a/arm9/arm9.lcf +++ b/arm9/arm9.lcf @@ -117,7 +117,8 @@ SECTIONS { ALIGNALL(4); . = ALIGN(32); SDK_STATIC_START = .; SDK_STATIC_TEXT_START = .; - secure.o (.text) + /* libsyscall.a (.text) */ + secure.o (.text) /* is actually libsyscall with nitro encryption */ crt0.o (.text) crt0.o (.rodata) * (.version) diff --git a/arm9/lib/Makefile b/arm9/lib/Makefile new file mode 100644 index 00000000..c0e95ade --- /dev/null +++ b/arm9/lib/Makefile @@ -0,0 +1,89 @@ + + +# Try to include devkitarm if installed +TOOLCHAIN := $(DEVKITARM) + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +endif + +### Default target ### + +default: all + +# If you are using WSL, it is recommended you build with NOWINE=1. +WSLENV ?= no +ifeq ($(WSLENV),) +NOWINE = 1 +else +NOWINE = 0 +endif + +ifeq ($(OS),Windows_NT) +EXE := .exe +WINE := +else +EXE := +WINE := wine +endif + +ifeq ($(NOWINE),1) +WINE := +endif + +# Compare result of arm9, arm7, and ROM to sha1 hash(s) +COMPARE ?= 1 + +##################### Compiler Options ####################### + +MWCCVERSION = 1.2/sp2p3 + +CROSS := arm-none-eabi- + +MWCCARM = ../../tools/mwccarm/$(MWCCVERSION)/mwccarm.exe +# Argh... due to EABI version shenanigans, we can't use GNU LD to link together +# MWCC built objects and GNU built ones. mwldarm, however, doesn't care, so we +# have to use mwldarm for now. +# TODO: Is there a hack workaround to let us go back to GNU LD? Ideally, the +# only dependency should be MWCCARM. +MWLDARM = ../../tools/mwccarm/$(MWCCVERSION)/mwldarm.exe +MWASMARM = ../../tools/mwccarm/$(MWCCVERSION)/mwasmarm.exe +NARCCOMP = ../../tools/narccomp/narccomp$(EXE) +SCANINC = ../../tools/scaninc/scaninc$(EXE) + +AS = $(WINE) $(MWASMARM) +CC = $(WINE) $(MWCCARM) +CPP := cpp -P +LD = $(WINE) $(MWLDARM) +AR := $(CROSS)ar +OBJDUMP := $(CROSS)objdump +OBJCOPY := $(CROSS)objcopy + +# ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o +ASFLAGS = -proc arm5te -ir ../.. +CFLAGS = -O4,p -proc arm946e -fp soft -lang c99 -Cpp_exceptions off -i include -ir include-mw -ir arm9/lib/include -W all +LDFLAGS = -library -nodead -w off -proc v5te -interworking -pic +ARFLAGS = rcS + +export MWCIncludes := include + +################ Targets ################# + +LIBS := libsyscall.a +.PHONY: all clean + +all: $(LIBS) + +clean: + $(RM) $(LIBS) $(LIBS:%.a=%/*.o) + +libsyscall.a: syscall/_svc_mw.o + +%.a: + $(AR) $(ARFLAGS) -o $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) -o $@ $< + +%.o: %.s + $(AS) $(ASFLAGS) -o $@ $< diff --git a/arm9/lib/syscall/_svc_mw.s b/arm9/lib/syscall/_svc_mw.s new file mode 100644 index 00000000..c1e36b4b --- /dev/null +++ b/arm9/lib/syscall/_svc_mw.s @@ -0,0 +1,121 @@ + .include "asm/macros.inc" + + .text + ; NITRO SYSCALL LIBRARY + ; VERSION 3.2 + + ; Secure area + .space 0x800 + + non_word_aligned_thumb_func_start SVC_SoftReset +SVC_SoftReset: + swi 0 + bx lr + thumb_func_end SVC_SoftReset + + non_word_aligned_thumb_func_start SVC_WaitByLoop +SVC_WaitByLoop: + swi 3 + bx lr + thumb_func_end SVC_WaitByLoop + + non_word_aligned_thumb_func_start SVC_WaitIntr +SVC_WaitIntr: + mov r2, #0 + swi 4 + bx lr + thumb_func_end SVC_WaitIntr + + non_word_aligned_thumb_func_start SVC_WaitVBlankIntr +SVC_WaitVBlankIntr: + mov r2, #0 + swi 5 + bx lr + thumb_func_end SVC_WaitVBlankIntr + + non_word_aligned_thumb_func_start SVC_Halt +SVC_Halt: + swi 6 + bx lr + thumb_func_end SVC_Halt + + non_word_aligned_thumb_func_start SVC_Div +SVC_Div: + swi 9 + bx lr + thumb_func_end SVC_Div + + non_word_aligned_thumb_func_start SVC_DimRem +SVC_DivRem: + swi 9 + add r0, r1, #0 + bx lr + thumb_func_end SVC_DivRem + + non_word_aligned_thumb_func_start SVC_CpuSet +SVC_CpuSet: + swi 11 + bx lr + thumb_func_end SVC_CpuSet + + non_word_aligned_thumb_func_start SVC_CpuFastSet +SVC_CpuFastSet: + swi 12 + bx lr + thumb_func_end SVC_CpuFastSet + + non_word_aligned_thumb_func_start SVC_Sqrt +SVC_Sqrt: + swi 13 + bx lr + thumb_func_end SVC_Sqrt + + non_word_aligned_thumb_func_start SVC_GetCRC16 +SVC_GetCRC16: + swi 14 + bx lr + thumb_func_end SVC_GetCRC16 + + non_word_aligned_thumb_func_start IsMemExpanded +IsMemExpanded: + swi 15 + bx lr + thumb_func_end IsMemExpanded + + non_word_aligned_thumb_func_start SVC_UnpackBits +SVC_UnpackBits: + swi 16 + bx lr + thumb_func_end SVC_UnpackBits + + non_word_aligned_thumb_func_start SVC_UncompressLZ8 +SVC_UncompressLZ8: + swi 17 + bx lr + thumb_func_end SVC_UncompressLZ8 + + non_word_aligned_thumb_func_start SVC_UncompressLZ16FromDevice +SVC_UncompressLZ16FromDevice: + swi 18 + bx lr + thumb_func_end SVC_UncompressLZ16FromDevice + + non_word_aligned_thumb_func_start SVC_UncompressHuffmanFromDevice +SVC_UncompressHuffmanFromDevice: + swi 19 + bx lr + thumb_func_end SVC_UncompressHuffmanFromDevice + + non_word_aligned_thumb_func_start SVC_UncompressRL8 +SVC_UncompressRL8: + swi 20 + bx lr + thumb_func_end SVC_UncompressRL8 + + non_word_aligned_thumb_func_start SVC_UncompressRL16FromDevice +SVC_UncompressRL16FromDevice: + swi 21 + bx lr + thumb_func_end SVC_UncompressRL16FromDevice + + .balign 4, 0 ; Don't pad with nop diff --git a/arm9/modules/01/src/module_01.cpp b/arm9/modules/01/src/module_01.cpp index 9da5f8d5..1f9f0edc 100644 --- a/arm9/modules/01/src/module_01.cpp +++ b/arm9/modules/01/src/module_01.cpp @@ -1,11 +1,7 @@ #include "global.h" -#include "FS_overlay.h" +#include "sinit.h" -class Unk021D7500 { - u32 unk0; - u32 unk4; -public: - THUMB_FUNC Unk021D7500() { unk4++; } -}; - -static Unk021D7500 UNK_021D7500; +THUMB_FUNC static void NitroStaticInit(void) { + static u32 var[2]; + var[1]++; +} diff --git a/include/nitro/types.h b/include/nitro/types.h index 190d9eae..dfa5ba87 100644 --- a/include/nitro/types.h +++ b/include/nitro/types.h @@ -54,4 +54,6 @@ typedef int BOOL; #endif // __cplusplus #endif +#define SDK_FORCE_EXPORT __declspec(force_export) + #endif //POKEDIAMOND_TYPES_H diff --git a/include/sinit.h b/include/sinit.h new file mode 100644 index 00000000..47fe4438 --- /dev/null +++ b/include/sinit.h @@ -0,0 +1,10 @@ +#ifndef GUARD_SINIT_H +#define GUARD_SINIT_H + +static void NitroStaticInit(void); +#pragma define_section SINIT ".sinit" abs32 RWX +#pragma section SINIT begin +SDK_FORCE_EXPORT static void (*NitroStaticInit_[])(void) = { NitroStaticInit }; +#pragma section SINIT end + +#endif //GUARD_SINIT_H -- cgit v1.2.3 From c576367217f71a5e81d767d6ae77c4d21e836de4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jun 2020 19:15:06 -0400 Subject: .gitignore narcs; remove narcs on clean --- .gitignore | 5 +++++ Makefile | 1 + 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 6e1fa301..be9199b6 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,8 @@ asmdiff.sh # Symbols CSV symbols.csv + +# NARCs +*.narc +*.arc +!files/poketool/personal/pms.narc diff --git a/Makefile b/Makefile index 4180f456..fba80bac 100644 --- a/Makefile +++ b/Makefile @@ -234,6 +234,7 @@ clean: mostlyclean $(MAKE) -C arm9 clean $(MAKE) -C arm7 clean $(MAKE) -C tools/mwasmarm_patcher clean + $(RM) $(filter-out poketool/personal/pms.narc,$(filter %.narc %.arc,$(NITROFS_FILES))) mostlyclean: tidy $(MAKE) -C arm9 mostlyclean -- cgit v1.2.3 From 2f9f37bc7c8575ad535d97cf9ad0d3a84e6592dd Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jun 2020 19:49:29 -0400 Subject: Document NARC access in pokemon.s --- arm9/asm/pokemon.s | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/arm9/asm/pokemon.s b/arm9/asm/pokemon.s index 8bcaa0c7..3b50e07b 100644 --- a/arm9/asm/pokemon.s +++ b/arm9/asm/pokemon.s @@ -4103,12 +4103,12 @@ FUN_02068758: ; 0x02068758 mov r1, #0x15 bl FUN_02068678 add r1, r4, #0x0 - bl FUN_02068788 + bl GetExpByGrowthRateAndLevel pop {r4, pc} .balign 4 - thumb_func_start FUN_0206876C -FUN_0206876C: ; 0x0206876C + thumb_func_start LoadGrowthTable +LoadGrowthTable: ; 0x0206876C push {r3-r5, lr} add r5, r0, #0x0 add r4, r1, #0x0 @@ -4117,14 +4117,14 @@ FUN_0206876C: ; 0x0206876C bl ErrorHandling _0206877A: add r0, r4, #0x0 - mov r1, #0x3 + mov r1, #0x3 ; NARC_POKETOOL_PERSONAL_GROWTBL add r2, r5, #0x0 bl ReadWholeNarcMemberByIdPair pop {r3-r5, pc} .balign 4 - thumb_func_start FUN_02068788 -FUN_02068788: ; 0x02068788 + thumb_func_start GetExpByGrowthRateAndLevel +GetExpByGrowthRateAndLevel: ; 0x02068788 push {r4-r6, lr} add r6, r0, #0x0 add r5, r1, #0x0 @@ -4143,7 +4143,7 @@ _0206879E: add r4, r0, #0x0 add r0, r6, #0x0 add r1, r4, #0x0 - bl FUN_0206876C + bl LoadGrowthTable lsl r0, r5, #0x2 ldr r5, [r4, r0] add r0, r4, #0x0 @@ -4209,7 +4209,7 @@ FUN_02068824: ; 0x02068824 add r4, r2, #0x0 bl FUN_02068538 ldr r1, _0206884C ; =UNK_021C5AC0 - bl FUN_0206876C + bl LoadGrowthTable ldr r2, _02068850 ; =UNK_021C5AC0 + 4 mov r1, #0x1 _02068838: @@ -5169,7 +5169,7 @@ _02068F1A: lsr r1, r2, #0x1 add r1, #0x48 lsl r0, r3, #0x1 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r1, r0 b _02068FCA _02068F26: @@ -5180,7 +5180,7 @@ _02068F2C: lsr r1, r2, #0x1 add r1, #0x4e lsl r0, r3, #0x1 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r1, r0 b _02068FCA _02068F38: @@ -5189,7 +5189,7 @@ _02068F38: mov r3, #0x0 _02068F3E: add r2, #0x54 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r2, r3 b _02068FCA _02068F46: @@ -5198,7 +5198,7 @@ _02068F46: mov r3, #0x0 _02068F4C: add r2, #0x58 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r2, r3 b _02068FCA _02068F54: @@ -5207,7 +5207,7 @@ _02068F54: mov r3, #0x0 _02068F5A: add r2, #0x5c - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r2, r3 b _02068FCA _02068F62: @@ -5218,7 +5218,7 @@ _02068F68: lsr r1, r2, #0x1 add r1, #0x60 lsl r0, r3, #0x1 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r1, r0 b _02068FCA _02068F74: @@ -5228,7 +5228,7 @@ _02068F74: _02068F7A: lsl r0, r2, #0x1 add r0, #0x40 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r3, r0 b _02068FCA _02068F84: @@ -5238,7 +5238,7 @@ _02068F84: _02068F8A: lsr r1, r2, #0x1 lsl r0, r3, #0x1 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r1, r0 b _02068FCA _02068F94: @@ -5249,7 +5249,7 @@ _02068F9A: lsr r1, r2, #0x1 add r1, #0x8 lsl r0, r3, #0x1 - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, r1, r0 b _02068FCA _02068FA6: @@ -5257,15 +5257,15 @@ _02068FA6: bls _02068FAC mov r3, #0x0 _02068FAC: - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O add r3, #0x84 b _02068FCA _02068FB2: - mov r4, #0x79 + mov r4, #0x79 ; NARC_POKETOOL_POKEGRA_HEIGHT_O mov r3, #0x84 b _02068FCA _02068FB8: - mov r4, #0x5 + mov r4, #0x5 ; NARC_POKETOOL_POKEGRA_HEIGHT cmp r1, #0x1 beq _02068FC2 mov r1, #0x1 @@ -5324,7 +5324,7 @@ FUN_02069010: ; 0x02069010 add r4, r0, #0x0 str r3, [sp, #0x0] add r0, sp, #0x4 - mov r1, #0x72 + mov r1, #0x72 ; NARC_POKETOOL_POKEANM_POKEANM mov r2, #0x0 mul r3, r5 bl ReadFromNarcMemberByIdPair @@ -5348,7 +5348,7 @@ FUN_02069038: ; 0x02069038 add r7, r1, #0x0 str r3, [sp, #0x0] add r0, #0x2 - mov r1, #0x72 + mov r1, #0x72 ; NARC_POKETOOL_POKEANM_POKEANM mov r2, #0x0 mul r3, r6 bl ReadFromNarcMemberByIdPair @@ -5470,7 +5470,7 @@ FUN_020690E8: ; 0x020690E8 bl FUN_02068678 mov r1, #0x64 add r5, r0, #0x0 - bl FUN_02068788 + bl GetExpByGrowthRateAndLevel ldr r1, [sp, #0x4] cmp r1, r0 bls _02069138 @@ -5489,7 +5489,7 @@ _02069138: pop {r3-r5, pc} _02069146: add r0, r5, #0x0 - bl FUN_02068788 + bl GetExpByGrowthRateAndLevel ldr r1, [sp, #0x4] cmp r1, r0 blo _02069162 @@ -6781,7 +6781,7 @@ FUN_02069B40: ; 0x02069B40 mov r0, #0x2 str r0, [sp, #0x0] add r0, sp, #0x4 - mov r1, #0x6d + mov r1, #0x6d ; NARC_POKETOOL_POKEZUKAN mov r2, #0x0 lsl r3, r3, #0x1 bl ReadFromNarcMemberByIdPair @@ -6804,7 +6804,7 @@ FUN_02069B60: ; 0x02069B60 mov r0, #0x2 str r0, [sp, #0x0] add r0, sp, #0x4 - mov r1, #0x91 + mov r1, #0x91 ; NARC_POKETOOL_SHINZUKAN lsl r3, r3, #0x1 bl ReadFromNarcMemberByIdPair _02069B7E: @@ -7396,7 +7396,7 @@ FUN_02069F9C: ; 0x02069F9C bl ConvertUnownOrArceusSpecies add r2, r0, #0x0 add r0, r4, #0x0 - mov r1, #0x21 + mov r1, #0x21 ; NARC_POKETOOL_PERSONAL_WOTBL bl ReadWholeNarcMemberByIdPair pop {r4, pc} @@ -7875,7 +7875,7 @@ FUN_0206A370: ; 0x0206A370 ldr r3, _0206A37C ; =ReadWholeNarcMemberByIdPair add r2, r0, #0x0 add r0, r1, #0x0 - mov r1, #0x2 + mov r1, #0x2 ; NARC_POKETOOL_PERSONAL_PERSONAL bx r3 nop _0206A37C: .word ReadWholeNarcMemberByIdPair @@ -7887,7 +7887,7 @@ FUN_0206A380: ; 0x0206A380 bl ConvertUnownOrArceusSpecies add r2, r0, #0x0 add r0, r4, #0x0 - mov r1, #0x2 + mov r1, #0x2 ; NARC_POKETOOL_PERSONAL_PERSONAL bl ReadWholeNarcMemberByIdPair pop {r4, pc} @@ -7896,7 +7896,7 @@ FUN_0206A394: ; 0x0206A394 ldr r3, _0206A3A0 ; =ReadWholeNarcMemberByIdPair add r2, r0, #0x0 add r0, r1, #0x0 - mov r1, #0x22 + mov r1, #0x22 ; NARC_POKETOOL_PERSONAL_EVO bx r3 nop _0206A3A0: .word ReadWholeNarcMemberByIdPair -- cgit v1.2.3 From 04f767c06d9e5702cdbb41bd49a2791164e021f1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 7 Jun 2020 10:41:08 -0400 Subject: Decompile growth rate tables --- Makefile | 20 ++++- files/poketool/personal/growtbl/.gitignore | 2 + files/poketool/personal/growtbl/Makefile | 19 +++++ files/poketool/personal/growtbl/grow2bin.c | 27 +++++++ files/poketool/personal/growtbl/narc_0000.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0000.txt | 101 ++++++++++++++++++++++++++ files/poketool/personal/growtbl/narc_0001.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0001.txt | 101 ++++++++++++++++++++++++++ files/poketool/personal/growtbl/narc_0002.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0002.txt | 101 ++++++++++++++++++++++++++ files/poketool/personal/growtbl/narc_0003.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0003.txt | 101 ++++++++++++++++++++++++++ files/poketool/personal/growtbl/narc_0004.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0004.txt | 101 ++++++++++++++++++++++++++ files/poketool/personal/growtbl/narc_0005.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0005.txt | 101 ++++++++++++++++++++++++++ files/poketool/personal/growtbl/narc_0006.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0006.txt | 101 ++++++++++++++++++++++++++ files/poketool/personal/growtbl/narc_0007.bin | Bin 404 -> 0 bytes files/poketool/personal/growtbl/narc_0007.txt | 101 ++++++++++++++++++++++++++ filesystem.mk | 2 + 21 files changed, 875 insertions(+), 3 deletions(-) create mode 100644 files/poketool/personal/growtbl/.gitignore create mode 100644 files/poketool/personal/growtbl/Makefile create mode 100644 files/poketool/personal/growtbl/grow2bin.c delete mode 100644 files/poketool/personal/growtbl/narc_0000.bin create mode 100644 files/poketool/personal/growtbl/narc_0000.txt delete mode 100644 files/poketool/personal/growtbl/narc_0001.bin create mode 100644 files/poketool/personal/growtbl/narc_0001.txt delete mode 100644 files/poketool/personal/growtbl/narc_0002.bin create mode 100644 files/poketool/personal/growtbl/narc_0002.txt delete mode 100644 files/poketool/personal/growtbl/narc_0003.bin create mode 100644 files/poketool/personal/growtbl/narc_0003.txt delete mode 100644 files/poketool/personal/growtbl/narc_0004.bin create mode 100644 files/poketool/personal/growtbl/narc_0004.txt delete mode 100644 files/poketool/personal/growtbl/narc_0005.bin create mode 100644 files/poketool/personal/growtbl/narc_0005.txt delete mode 100644 files/poketool/personal/growtbl/narc_0006.bin create mode 100644 files/poketool/personal/growtbl/narc_0006.txt delete mode 100644 files/poketool/personal/growtbl/narc_0007.bin create mode 100644 files/poketool/personal/growtbl/narc_0007.txt diff --git a/Makefile b/Makefile index fba80bac..b7b31dbb 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ include config.mk include filesystem.mk +HOSTCC = $(CC) +HOSTCXX = $(CXX) +HOSTCFLAGS = $(CFLAGS) +HOSTCXXFLAGS = $(CXXFLAGS) + .PHONY: clean tidy all default patch_mwasmarm # Try to include devkitarm if installed @@ -234,7 +239,8 @@ clean: mostlyclean $(MAKE) -C arm9 clean $(MAKE) -C arm7 clean $(MAKE) -C tools/mwasmarm_patcher clean - $(RM) $(filter-out poketool/personal/pms.narc,$(filter %.narc %.arc,$(NITROFS_FILES))) + $(RM) $(filter-out files/poketool/personal/pms.narc,$(filter %.narc %.arc,$(HOSTFS_FILES))) + $(MAKE) -C files/poketool/personal/growtbl clean mostlyclean: tidy $(MAKE) -C arm9 mostlyclean @@ -310,16 +316,24 @@ DUMMY != mkdir -p $(ALL_DIRS) %.png: ; %.pal: ; -%.narc: members = $(wildcard $(@D)/$*/*) +##################### Filesystem ##################### + +%.narc: members = $(wildcard $(@D)/$*/*.bin) %.narc: $$(members) $(NARCCOMP) -o $@ -p 255 $^ -%.arc: members = $(wildcard $(@D)/$*/*) +%.arc: members = $(wildcard $(@D)/$*/*.bin) %.arc: $$(members) $(NARCCOMP) -o $@ -p 255 $^ files/poketool/personal/pms.narc: ; +files/poketool/personal/growtbl.narc: $(wildcard files/poketool/personal/growtbl/*.txt) + $(MAKE) -C $( +#include +#include +#include + +int main(int argc, char ** argv) { + FILE * infile = fopen(argv[1], "r"); + char * infname_ext = strrchr(argv[1], '.'); + char * outfname = malloc(infname_ext - argv[1] + 5); + char * outfname_ext = stpncpy(outfname, argv[1], infname_ext - argv[1]); + strcpy(outfname_ext, ".bin"); + FILE * outfile = fopen(outfname, "wb"); + uint32_t value; + size_t size = 0; + char * line = NULL; + char * end = NULL; + while (getline(&line, &size, infile) > 0) { + value = strtoul(line, &end, 10); + if (value == 0 && end == line) break; + fwrite(&value, 1, 4, outfile); + } + free(line); + free(outfname); + fclose(outfile); + fclose(infile); + return 0; +} diff --git a/files/poketool/personal/growtbl/narc_0000.bin b/files/poketool/personal/growtbl/narc_0000.bin deleted file mode 100644 index 8d99bafb..00000000 Binary files a/files/poketool/personal/growtbl/narc_0000.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0000.txt b/files/poketool/personal/growtbl/narc_0000.txt new file mode 100644 index 00000000..04923607 --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0000.txt @@ -0,0 +1,101 @@ +0 +0 +8 +27 +64 +125 +216 +343 +512 +729 +1000 +1331 +1728 +2197 +2744 +3375 +4096 +4913 +5832 +6859 +8000 +9261 +10648 +12167 +13824 +15625 +17576 +19683 +21952 +24389 +27000 +29791 +32768 +35937 +39304 +42875 +46656 +50653 +54872 +59319 +64000 +68921 +74088 +79507 +85184 +91125 +97336 +103823 +110592 +117649 +125000 +132651 +140608 +148877 +157464 +166375 +175616 +185193 +195112 +205379 +216000 +226981 +238328 +250047 +262144 +274625 +287496 +300763 +314432 +328509 +343000 +357911 +373248 +389017 +405224 +421875 +438976 +456533 +474552 +493039 +512000 +531441 +551368 +571787 +592704 +614125 +636056 +658503 +681472 +704969 +729000 +753571 +778688 +804357 +830584 +857375 +884736 +912673 +941192 +970299 +1000000 diff --git a/files/poketool/personal/growtbl/narc_0001.bin b/files/poketool/personal/growtbl/narc_0001.bin deleted file mode 100644 index 9b8b6f43..00000000 Binary files a/files/poketool/personal/growtbl/narc_0001.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0001.txt b/files/poketool/personal/growtbl/narc_0001.txt new file mode 100644 index 00000000..5ddc38f2 --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0001.txt @@ -0,0 +1,101 @@ +0 +0 +15 +52 +122 +237 +406 +637 +942 +1326 +1800 +2369 +3041 +3822 +4719 +5737 +6881 +8155 +9564 +11111 +12800 +14632 +16610 +18737 +21012 +23437 +26012 +28737 +31610 +34632 +37800 +41111 +44564 +48155 +51881 +55737 +59719 +63822 +68041 +72369 +76800 +81326 +85942 +90637 +95406 +100237 +105122 +110052 +115015 +120001 +125000 +131324 +137795 +144410 +151165 +158056 +165079 +172229 +179503 +186894 +194400 +202013 +209728 +217540 +225443 +233431 +241496 +249633 +257834 +267406 +276458 +286328 +296358 +305767 +316074 +326531 +336255 +346965 +357812 +367807 +378880 +390077 +400293 +411686 +423190 +433572 +445239 +457001 +467489 +479378 +491346 +501878 +513934 +526049 +536557 +548720 +560922 +571333 +583539 +591882 +600000 diff --git a/files/poketool/personal/growtbl/narc_0002.bin b/files/poketool/personal/growtbl/narc_0002.bin deleted file mode 100644 index 04f551d2..00000000 Binary files a/files/poketool/personal/growtbl/narc_0002.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0002.txt b/files/poketool/personal/growtbl/narc_0002.txt new file mode 100644 index 00000000..d2f6f13a --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0002.txt @@ -0,0 +1,101 @@ +0 +0 +4 +13 +32 +65 +112 +178 +276 +393 +540 +745 +967 +1230 +1591 +1957 +2457 +3046 +3732 +4526 +5440 +6482 +7666 +9003 +10506 +12187 +14060 +16140 +18439 +20974 +23760 +26811 +30146 +33780 +37731 +42017 +46656 +50653 +55969 +60505 +66560 +71677 +78533 +84277 +91998 +98415 +107069 +114205 +123863 +131766 +142500 +151222 +163105 +172697 +185807 +196322 +210739 +222231 +238036 +250562 +267840 +281456 +300293 +315059 +335544 +351520 +373744 +390991 +415050 +433631 +459620 +479600 +507617 +529063 +559209 +582187 +614566 +639146 +673863 +700115 +737280 +765275 +804997 +834809 +877201 +908905 +954084 +987754 +1035837 +1071552 +1122660 +1160499 +1214753 +1254796 +1312322 +1354652 +1415577 +1460276 +1524731 +1571884 +1640000 diff --git a/files/poketool/personal/growtbl/narc_0003.bin b/files/poketool/personal/growtbl/narc_0003.bin deleted file mode 100644 index ba00db15..00000000 Binary files a/files/poketool/personal/growtbl/narc_0003.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0003.txt b/files/poketool/personal/growtbl/narc_0003.txt new file mode 100644 index 00000000..77c5640e --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0003.txt @@ -0,0 +1,101 @@ +0 +0 +9 +57 +96 +135 +179 +236 +314 +419 +560 +742 +973 +1261 +1612 +2035 +2535 +3120 +3798 +4575 +5460 +6458 +7577 +8825 +10208 +11735 +13411 +15244 +17242 +19411 +21760 +24294 +27021 +29949 +33084 +36435 +40007 +43808 +47846 +52127 +56660 +61450 +66505 +71833 +77440 +83335 +89523 +96012 +102810 +109923 +117360 +125126 +133229 +141677 +150476 +159635 +169159 +179056 +189334 +199999 +211060 +222522 +234393 +246681 +259392 +272535 +286115 +300140 +314618 +329555 +344960 +360838 +377197 +394045 +411388 +429235 +447591 +466464 +485862 +505791 +526260 +547274 +568841 +590969 +613664 +636935 +660787 +685228 +710266 +735907 +762160 +789030 +816525 +844653 +873420 +902835 +932903 +963632 +995030 +1027103 +1059860 diff --git a/files/poketool/personal/growtbl/narc_0004.bin b/files/poketool/personal/growtbl/narc_0004.bin deleted file mode 100644 index 5e43ed24..00000000 Binary files a/files/poketool/personal/growtbl/narc_0004.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0004.txt b/files/poketool/personal/growtbl/narc_0004.txt new file mode 100644 index 00000000..c8ceec25 --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0004.txt @@ -0,0 +1,101 @@ +0 +0 +6 +21 +51 +100 +172 +274 +409 +583 +800 +1064 +1382 +1757 +2195 +2700 +3276 +3930 +4665 +5487 +6400 +7408 +8518 +9733 +11059 +12500 +14060 +15746 +17561 +19511 +21600 +23832 +26214 +28749 +31443 +34300 +37324 +40522 +43897 +47455 +51200 +55136 +59270 +63605 +68147 +72900 +77868 +83058 +88473 +94119 +100000 +106120 +112486 +119101 +125971 +133100 +140492 +148154 +156089 +164303 +172800 +181584 +190662 +200037 +209715 +219700 +229996 +240610 +251545 +262807 +274400 +286328 +298598 +311213 +324179 +337500 +351180 +365226 +379641 +394431 +409600 +425152 +441094 +457429 +474163 +491300 +508844 +526802 +545177 +563975 +583200 +602856 +622950 +643485 +664467 +685900 +707788 +730138 +752953 +776239 +800000 diff --git a/files/poketool/personal/growtbl/narc_0005.bin b/files/poketool/personal/growtbl/narc_0005.bin deleted file mode 100644 index b5461078..00000000 Binary files a/files/poketool/personal/growtbl/narc_0005.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0005.txt b/files/poketool/personal/growtbl/narc_0005.txt new file mode 100644 index 00000000..8f8dca5b --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0005.txt @@ -0,0 +1,101 @@ +0 +0 +10 +33 +80 +156 +270 +428 +640 +911 +1250 +1663 +2160 +2746 +3430 +4218 +5120 +6141 +7290 +8573 +10000 +11576 +13310 +15208 +17280 +19531 +21970 +24603 +27440 +30486 +33750 +37238 +40960 +44921 +49130 +53593 +58320 +63316 +68590 +74148 +80000 +86151 +92610 +99383 +106480 +113906 +121670 +129778 +138240 +147061 +156250 +165813 +175760 +186096 +196830 +207968 +219520 +231491 +243890 +256723 +270000 +283726 +297910 +312558 +327680 +343281 +359370 +375953 +393040 +410636 +428750 +447388 +466560 +486271 +506530 +527343 +548720 +570666 +593190 +616298 +640000 +664301 +689210 +714733 +740880 +767656 +795070 +823128 +851840 +881211 +911250 +941963 +973360 +1005446 +1038230 +1071718 +1105920 +1140841 +1176490 +1212873 +1250000 diff --git a/files/poketool/personal/growtbl/narc_0006.bin b/files/poketool/personal/growtbl/narc_0006.bin deleted file mode 100644 index 8d99bafb..00000000 Binary files a/files/poketool/personal/growtbl/narc_0006.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0006.txt b/files/poketool/personal/growtbl/narc_0006.txt new file mode 100644 index 00000000..04923607 --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0006.txt @@ -0,0 +1,101 @@ +0 +0 +8 +27 +64 +125 +216 +343 +512 +729 +1000 +1331 +1728 +2197 +2744 +3375 +4096 +4913 +5832 +6859 +8000 +9261 +10648 +12167 +13824 +15625 +17576 +19683 +21952 +24389 +27000 +29791 +32768 +35937 +39304 +42875 +46656 +50653 +54872 +59319 +64000 +68921 +74088 +79507 +85184 +91125 +97336 +103823 +110592 +117649 +125000 +132651 +140608 +148877 +157464 +166375 +175616 +185193 +195112 +205379 +216000 +226981 +238328 +250047 +262144 +274625 +287496 +300763 +314432 +328509 +343000 +357911 +373248 +389017 +405224 +421875 +438976 +456533 +474552 +493039 +512000 +531441 +551368 +571787 +592704 +614125 +636056 +658503 +681472 +704969 +729000 +753571 +778688 +804357 +830584 +857375 +884736 +912673 +941192 +970299 +1000000 diff --git a/files/poketool/personal/growtbl/narc_0007.bin b/files/poketool/personal/growtbl/narc_0007.bin deleted file mode 100644 index 8d99bafb..00000000 Binary files a/files/poketool/personal/growtbl/narc_0007.bin and /dev/null differ diff --git a/files/poketool/personal/growtbl/narc_0007.txt b/files/poketool/personal/growtbl/narc_0007.txt new file mode 100644 index 00000000..04923607 --- /dev/null +++ b/files/poketool/personal/growtbl/narc_0007.txt @@ -0,0 +1,101 @@ +0 +0 +8 +27 +64 +125 +216 +343 +512 +729 +1000 +1331 +1728 +2197 +2744 +3375 +4096 +4913 +5832 +6859 +8000 +9261 +10648 +12167 +13824 +15625 +17576 +19683 +21952 +24389 +27000 +29791 +32768 +35937 +39304 +42875 +46656 +50653 +54872 +59319 +64000 +68921 +74088 +79507 +85184 +91125 +97336 +103823 +110592 +117649 +125000 +132651 +140608 +148877 +157464 +166375 +175616 +185193 +195112 +205379 +216000 +226981 +238328 +250047 +262144 +274625 +287496 +300763 +314432 +328509 +343000 +357911 +373248 +389017 +405224 +421875 +438976 +456533 +474552 +493039 +512000 +531441 +551368 +571787 +592704 +614125 +636056 +658503 +681472 +704969 +729000 +753571 +778688 +804357 +830584 +857375 +884736 +912673 +941192 +970299 +1000000 diff --git a/filesystem.mk b/filesystem.mk index 8c7dc7ab..e5d2731d 100644 --- a/filesystem.mk +++ b/filesystem.mk @@ -271,3 +271,5 @@ NITROFS_FILES := data/UTF16.dat \ ifeq ($(GAME_VERSION),PEARL) NITROFS_FILES = $(NITROFS_FILES:poketool/personal/personal.narc=poketool/personal_pearl/personal.narc) endif + +HOSTFS_FILES = $(NITROFS_FILES:%=files/%) -- cgit v1.2.3