diff options
author | Rémi Calixte <remicalixte.rmc@gmail.com> | 2021-05-20 11:46:25 +0200 |
---|---|---|
committer | Rémi Calixte <remicalixte.rmc@gmail.com> | 2021-05-20 11:46:25 +0200 |
commit | 571d9a8d7cff6158e9fcd6327db602349e267d56 (patch) | |
tree | 3950d2a1a5b085c4a61b9e821684e47a3cf04492 | |
parent | 8af497a617e45668f7c3c0badc1324ce45308183 (diff) | |
parent | 98f11489806b6dba4c6080c5429b2368d3092541 (diff) |
Merge branch 'master' into unk_02016B94
92 files changed, 1889 insertions, 2026 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e21a731a..92d8aea2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 3.15) +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") project(PokeDiamond) set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_STANDARD 11) @@ -13,10 +15,7 @@ endif(APPLE) add_compile_options(-fms-extensions) -file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "*.c" "*.cpp") - -add_executable(PokeDiamond ${SOURCES}) -target_include_directories(PokeDiamond PRIVATE include include-mw arm9/lib/include arm7/lib/include arm9/modules/05/include arm9/modules/21/include arm9/modules/59/include arm9/modules/63/include) +add_subdirectory(arm9) add_executable(calcrom .github/calcrom/calcrom.cpp) target_include_directories(calcrom PRIVATE /usr/local/include) diff --git a/arm9/CMakeLists.txt b/arm9/CMakeLists.txt new file mode 100644 index 00000000..9170d823 --- /dev/null +++ b/arm9/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required (VERSION 3.15) +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") +project(DP_Arm9) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_C_STANDARD 11) + +# TODO: Add commands + +enable_language(ASM) + +add_compile_options(-fms-extensions) + +file(GLOB_RECURSE SOURCES "*.c" "*.cpp") +file(GLOB MODULE_INC modules/*/include) + +add_executable(DP_Arm9 ${SOURCES}) +target_include_directories(DP_Arm9 PRIVATE ../include ../include-mw lib/include ${MODULE_INC}) diff --git a/arm9/Makefile b/arm9/Makefile index 8b84a135..6f05d1c5 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -110,7 +110,7 @@ ASM_PROCESSOR := $(ASM_PROCESSOR_DIR)/compile.sh # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o ASFLAGS = -proc arm5te -i ../include -i .. -D$(GAME_VERSION) -D$(GAME_LANGUAGE) -CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE) +CFLAGS = -O4,p -gccext,on -proc arm946e -ipa file -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -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 $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE) LDFLAGS = -nodead -w off -proc v5te -interworking -map closure,unused -symtab sort -m _start LIBS := -Llib -lsyscall @@ -192,6 +192,10 @@ ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(LIB # TODO: Move out to lib/Makefile $(BUILD_DIR)/lib/%.o: MWCCVERSION = 1.2/sp2p3 +$(BUILD_DIR)/lib/%.o: CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off -interworking -DFS_IMPLEMENT -enum int -W all -i ../include -ir ../include-mw -ir lib/include + +# FIXME: Using -ipa file breaks .rodata alignment +$(BUILD_DIR)/src/math_util.o: CFLAGS = -O4,p -gccext,on -proc arm946e -fp soft -lang c99 -Cpp_exceptions off $(foreach dir,$(INCLUDE_DIRS),-i $(dir)) $(foreach dir,$(INCLUDE_RECURSIVE_DIRS),-ir $(dir)) -interworking -DFS_IMPLEMENT -enum int -W all -D$(GAME_VERSION) -D$(GAME_LANGUAGE) ####################### Everything Else ###################### diff --git a/arm9/arm9.lsf b/arm9/arm9.lsf index 1abf5a52..898904d3 100644 --- a/arm9/arm9.lsf +++ b/arm9/arm9.lsf @@ -157,7 +157,7 @@ Static arm9 Object scrcmd_3.o Object scrcmd_names.o Object scrcmd_5.o - Object scrcmd_6.o + Object scrcmd_sound.o Object scrcmd_7.o Object scrcmd_8.o Object scrcmd_9.o diff --git a/arm9/asm/RTC_internal.s b/arm9/asm/RTC_internal.s deleted file mode 100644 index 408b630c..00000000 --- a/arm9/asm/RTC_internal.s +++ /dev/null @@ -1,53 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - arm_func_start RtcSendPxiCommand -RtcSendPxiCommand: ; 0x020D61D4 - stmdb sp!, {lr} - sub sp, sp, #0x4 - mov r0, r0, lsl #0x8 - and r1, r0, #0x7f00 - mov r0, #0x5 - mov r2, #0x0 - bl PXI_SendWordByFifo -_020D61F0: ; 0x020D61F0 - cmp r0, #0x0 - movge r0, #0x1 - movlt r0, #0x0 - add sp, sp, #0x4 - ldmia sp!, {lr} - bx lr - - arm_func_start RTCi_WriteRawStatus2Async -RTCi_WriteRawStatus2Async: - ldr ip, _020D6214 ; =RtcSendPxiCommand - mov r0, #0x27 - bx r12 - .balign 4 -_020D6214: .word RtcSendPxiCommand - - arm_func_start RTCi_ReadRawTimeAsync -RTCi_ReadRawTimeAsync: - ldr ip, _020D6224 ; =RtcSendPxiCommand - mov r0, #0x12 - bx r12 - .balign 4 -_020D6224: .word RtcSendPxiCommand - - arm_func_start RTCi_ReadRawDateAsync -RTCi_ReadRawDateAsync: - ldr ip, _020D6234 ; =RtcSendPxiCommand - mov r0, #0x11 - bx r12 - .balign 4 -_020D6234: .word RtcSendPxiCommand - - arm_func_start RTCi_ReadRawDateTimeAsync -RTCi_ReadRawDateTimeAsync: - ldr ip, _020D6244 ; =RtcSendPxiCommand - mov r0, #0x10 - bx r12 - .balign 4 -_020D6244: .word RtcSendPxiCommand diff --git a/arm9/asm/WIFI_stubsmd5_dummy.s b/arm9/asm/WIFI_stubsmd5_dummy.s deleted file mode 100644 index dd3f79a7..00000000 --- a/arm9/asm/WIFI_stubsmd5_dummy.s +++ /dev/null @@ -1,25 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - arm_func_start MD5Final -MD5Final: ; 0x020A8BA4 - ldr ip, _020A8BAC ; =DGT_Hash1GetDigest_R - bx r12 - .balign 4 -_020A8BAC: .word DGT_Hash1GetDigest_R - - arm_func_start MD5Update -MD5Update: ; 0x020A8BB0 - ldr ip, _020A8BB8 ; =DGT_Hash1SetSource - bx r12 - .balign 4 -_020A8BB8: .word DGT_Hash1SetSource - - arm_func_start MD5Init -MD5Init: ; 0x020A8BBC - ldr ip, _020A8BC4 ; =DGT_Hash1Reset - bx r12 - .balign 4 -_020A8BC4: .word DGT_Hash1Reset diff --git a/arm9/asm/nonmatchings/GenerateFontHalfRowLookupTable.s b/arm9/asm/nonmatchings/GenerateFontHalfRowLookupTable.s deleted file mode 100644 index a590ef02..00000000 --- a/arm9/asm/nonmatchings/GenerateFontHalfRowLookupTable.s +++ /dev/null @@ -1,92 +0,0 @@ -.section .text - -glabel GenerateFontHalfRowLookupTable - -.extern UNK_021C570C -.extern UNK_021C5734 - - push {r3-r7, lr} - sub sp, #0x30 - ldr r3, _0201C0F8 ; =UNK_021C570C - mov r5, #0x0 - str r5, [sp, #0x20] - str r0, [sp, #0x24] - str r2, [sp, #0x28] - str r1, [sp, #0x2c] - strh r1, [r3, #0x6] - strh r0, [r3, #0x2] - add r0, sp, #0x20 - strh r2, [r3, #0x4] - str r5, [sp, #0x14] - str r0, [sp, #0x8] - mov r12, r0 - mov lr, r0 - str r0, [sp, #0x18] -_0201C07E: - mov r0, #0x0 - str r0, [sp, #0x10] - ldr r0, [sp, #0x18] - str r0, [sp, #0x4] - ldr r0, [sp, #0x8] - ldr r0, [r0, #0x0] - str r0, [sp, #0x1c] -_0201C08C: - mov r0, #0x0 - str r0, [sp, #0xc] - mov r0, lr - str r0, [sp, #0x0] - ldr r0, [sp, #0x4] - ldr r0, [r0, #0x0] - lsl r7, r0, #0x4 -_0201C09A: - ldr r0, [sp, #0x0] - mov r3, #0x0 - ldr r0, [r0, #0x0] - mov r4, r12 - lsl r6, r0, #0x8 -_0201C0A4: - ldr r0, [r4, #0x0] - add r1, r7, #0x0 - lsl r0, r0, #0xc - orr r0, r6 - orr r1, r0 - ldr r0, [sp, #0x1c] - add r3, r3, #0x1 - add r2, r0, #0x0 - orr r2, r1 - lsl r1, r5, #0x1 - ldr r0, _0201C0FC ; =UNK_021C5734 - add r5, r5, #0x1 - add r4, r4, #0x4 - strh r2, [r0, r1] - cmp r3, #0x4 - blt _0201C0A4 - ldr r0, [sp, #0x0] - add r0, r0, #0x4 - str r0, [sp, #0x0] - ldr r0, [sp, #0xc] - add r0, r0, #0x1 - str r0, [sp, #0xc] - cmp r0, #0x4 - blt _0201C09A - ldr r0, [sp, #0x4] - add r0, r0, #0x4 - str r0, [sp, #0x4] - ldr r0, [sp, #0x10] - add r0, r0, #0x1 - str r0, [sp, #0x10] - cmp r0, #0x4 - blt _0201C08C - ldr r0, [sp, #0x8] - add r0, r0, #0x4 - str r0, [sp, #0x8] - ldr r0, [sp, #0x14] - add r0, r0, #0x1 - str r0, [sp, #0x14] - cmp r0, #0x4 - blt _0201C07E - add sp, #0x30 - pop {r3-r7, pc} - .balign 4 -_0201C0F8: .word UNK_021C570C -_0201C0FC: .word UNK_021C5734 diff --git a/arm9/asm/scrcmd_24.s b/arm9/asm/scrcmd_24.s deleted file mode 100644 index b9569382..00000000 --- a/arm9/asm/scrcmd_24.s +++ /dev/null @@ -1,316 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - thumb_func_start FUN_02045D88 -FUN_02045D88: ; 0x02045D88 - push {r4-r6, lr} - add r5, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r4, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - mov r1, #0x13 - bl FUN_02039438 - add r1, r5, #0x0 - add r1, #0x80 - lsl r2, r4, #0x18 - add r6, r0, #0x0 - ldr r1, [r1, #0x0] - mov r0, #0x20 - lsr r2, r2, #0x18 - bl FUN_02037CF0 - str r0, [r6, #0x0] - ldr r1, _02045DCC ; =FUN_0203BC04 - add r0, r5, #0x0 - bl SetupNativeScript - mov r0, #0x1 - pop {r4-r6, pc} - nop -_02045DCC: .word FUN_0203BC04 - - thumb_func_start FUN_02045DD0 -FUN_02045DD0: ; 0x02045DD0 - push {r3-r5, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r4, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl GetVarPointer - add r4, #0x80 - add r5, r0, #0x0 - ldr r0, [r4, #0x0] - mov r1, #0x13 - bl FUN_02039438 - add r4, r0, #0x0 - ldr r0, [r4, #0x0] - cmp r0, #0x0 - bne _02045DFC - bl ErrorHandling -_02045DFC: - ldr r0, [r4, #0x0] - bl FUN_02037D5C - strh r0, [r5, #0x0] - ldrh r0, [r5, #0x0] - cmp r0, #0x4 - bne _02045E0E - mov r0, #0xff - strh r0, [r5, #0x0] -_02045E0E: - ldr r0, [r4, #0x0] - bl FreeToHeap - mov r0, #0x0 - str r0, [r4, #0x0] - pop {r3-r5, pc} - .balign 4 - - thumb_func_start FUN_02045E1C -FUN_02045E1C: ; 0x02045E1C - mov r0, #0x0 - bx lr - - thumb_func_start FUN_02045E20 -FUN_02045E20: ; 0x02045E20 - push {r4-r6, lr} - add r5, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl GetVarPointer - add r4, r0, #0x0 - add r0, r5, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r5, #0x80 - add r6, r0, #0x0 - ldr r0, [r5, #0x0] - ldr r0, [r0, #0xc] - bl SavArray_PlayerParty_get - add r1, r6, #0x0 - bl GetPartyMonByIndex - mov r1, #0x20 - bl FUN_02088DF8 - add r5, r0, #0x0 - bl FUN_02088EF8 - strh r0, [r4, #0x0] - add r0, r5, #0x0 - bl FreeToHeap - mov r0, #0x0 - pop {r4-r6, pc} - .balign 4 - - thumb_func_start FUN_02045E74 -FUN_02045E74: ; 0x02045E74 - push {r3-r7, lr} - sub sp, #0x8 - add r5, r0, #0x0 - add r0, #0x80 - add r7, r1, #0x0 - ldr r0, [r0, #0x0] - mov r1, #0x13 - str r2, [sp, #0x0] - add r6, r3, #0x0 - bl FUN_02039438 - str r0, [sp, #0x4] - mov r0, #0x20 - bl FUN_02088DD8 - add r4, r0, #0x0 - ldr r0, [sp, #0x4] - str r4, [r0, #0x0] - ldr r0, [sp, #0x0] - str r0, [r4, #0x0] - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl ScriptEnvironment_GetSav2Ptr - bl Sav2_PlayerData_GetProfileAddr - str r0, [r4, #0x4] - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - ldr r0, [r0, #0xc] - bl Sav2_PlayerData_GetOptionsAddr - str r0, [r4, #0x8] - str r6, [r4, #0xc] - add r0, r5, #0x0 - strb r7, [r4, #0x15] - add r0, #0x80 - ldr r0, [r0, #0x0] - add r1, r4, #0x0 - bl FUN_02038864 - ldr r1, _02045EDC ; =FUN_0203BC04 - add r0, r5, #0x0 - bl SetupNativeScript - add r0, r6, #0x0 - bl FreeToHeap - add sp, #0x8 - pop {r3-r7, pc} - .balign 4 -_02045EDC: .word FUN_0203BC04 - - thumb_func_start FUN_02045EE0 -FUN_02045EE0: ; 0x02045EE0 - mov r0, #0x1 - bx lr - - thumb_func_start FUN_02045EE4 -FUN_02045EE4: ; 0x02045EE4 - push {r3-r5, lr} - add r5, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r4, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - ldr r0, [r0, #0xc] - bl SavArray_PlayerParty_get - add r1, r4, #0x0 - bl GetPartyMonByIndex - add r4, r0, #0x0 - mov r1, #0x20 - bl FUN_02088DF8 - add r3, r0, #0x0 - add r0, r5, #0x0 - mov r1, #0x1 - add r2, r4, #0x0 - bl FUN_02045E74 - mov r0, #0x1 - pop {r3-r5, pc} - - thumb_func_start FUN_02045F24 -FUN_02045F24: ; 0x02045F24 - push {r4-r6, lr} - add r5, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r6, r0, #0x0 - add r0, r5, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r4, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - ldr r0, [r0, #0xc] - bl SavArray_PlayerParty_get - add r1, r6, #0x0 - bl GetPartyMonByIndex - add r6, r0, #0x0 - mov r0, #0x20 - mov r1, #0x4 - bl AllocFromHeap - add r3, r0, #0x0 - ldr r0, _02045F80 ; =0x0000FFFF - strh r4, [r3, #0x0] - strh r0, [r3, #0x2] - add r0, r5, #0x0 - mov r1, #0x0 - add r2, r6, #0x0 - bl FUN_02045E74 - mov r0, #0x1 - pop {r4-r6, pc} - .balign 4 -_02045F80: .word 0x0000FFFF - - thumb_func_start FUN_02045F84 -FUN_02045F84: ; 0x02045F84 - mov r0, #0x0 - bx lr - - thumb_func_start FUN_02045F88 -FUN_02045F88: ; 0x02045F88 - push {r3-r5, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r4, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl GetVarPointer - add r4, #0x80 - add r5, r0, #0x0 - ldr r0, [r4, #0x0] - mov r1, #0x13 - bl FUN_02039438 - ldr r4, [r0, #0x0] - cmp r4, #0x0 - bne _02045FB2 - bl ErrorHandling -_02045FB2: - ldrb r0, [r4, #0x16] - cmp r0, #0x0 - bne _02045FBC - mov r0, #0x0 - b _02045FBE -_02045FBC: - mov r0, #0xff -_02045FBE: - strh r0, [r5, #0x0] - add r0, r4, #0x0 - bl FUN_02088DF0 - mov r0, #0x0 - pop {r3-r5, pc} - .balign 4 - - thumb_func_start FUN_02045FCC -FUN_02045FCC: ; 0x02045FCC - push {r3-r5, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r4, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl GetVarPointer - add r4, #0x80 - add r5, r0, #0x0 - ldr r0, [r4, #0x0] - mov r1, #0x13 - bl FUN_02039438 - ldr r4, [r0, #0x0] - cmp r4, #0x0 - bne _02045FF6 - bl ErrorHandling -_02045FF6: - ldrb r0, [r4, #0x16] - cmp r0, #0x0 - bne _02046000 - mov r0, #0x0 - b _02046002 -_02046000: - mov r0, #0xff -_02046002: - strh r0, [r5, #0x0] - add r0, r4, #0x0 - bl FUN_02088DF0 - mov r0, #0x0 - pop {r3-r5, pc} - .balign 4 diff --git a/arm9/asm/scrcmd_6.s b/arm9/asm/scrcmd_6.s deleted file mode 100644 index 10b41ff7..00000000 --- a/arm9/asm/scrcmd_6.s +++ /dev/null @@ -1,399 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - thumb_func_start FUN_020413C0 -FUN_020413C0: ; 0x020413C0 - push {r3-r5, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r5, r0, #0x0 - add r0, r4, #0x0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0x0 - ldr r0, [r4, #0x0] - bl GetVarPointer - add r4, r0, #0x0 - add r0, r5, #0x0 - bl FUN_02005410 - strh r0, [r4, #0x0] - mov r0, #0x0 - pop {r3-r5, pc} - - thumb_func_start FUN_020413E8 -FUN_020413E8: ; 0x020413E8 - push {r3, lr} - bl ScriptReadHalfword - bl FUN_0200521C - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_020413F8 -FUN_020413F8: ; 0x020413F8 - push {r3, lr} - bl ScriptReadHalfword - bl FUN_02004124 - mov r1, #0x0 - bl FUN_02005350 - mov r0, #0x0 - pop {r3, pc} - - thumb_func_start FUN_0204140C -FUN_0204140C: ; 0x0204140C - push {r3, lr} - add r0, #0x80 - ldr r0, [r0, #0x0] - ldr r1, [r0, #0x1c] - ldr r1, [r1, #0x0] - bl FUN_0204ABA8 - bl FUN_0200521C - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_02041424 -FUN_02041424: ; 0x02041424 - push {r4, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0x0 - ldr r0, [r4, #0x0] - bl FUN_0204AB20 - mov r0, #0x0 - pop {r4, pc} - .balign 4 - - thumb_func_start FUN_0204143C -FUN_0204143C: ; 0x0204143C - push {r3-r5, lr} - add r5, r0, #0x0 - bl ScriptReadHalfword - add r4, r0, #0x0 - add r0, r5, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r4, #0x0 - bl FUN_020053CC - ldr r1, _02041460 ; =FUN_02041464 - add r0, r5, #0x0 - bl SetupNativeScript - mov r0, #0x1 - pop {r3-r5, pc} - .balign 4 -_02041460: .word FUN_02041464 - - thumb_func_start FUN_02041464 -FUN_02041464: ; 0x02041464 - push {r3, lr} - bl FUN_02005404 - cmp r0, #0x0 - bne _02041472 - mov r0, #0x1 - pop {r3, pc} -_02041472: - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_02041478 -FUN_02041478: ; 0x02041478 - push {r4, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - mov r0, #0x7f - mov r2, #0x0 - bl FUN_0200538C - ldr r1, _02041498 ; =FUN_02041464 - add r0, r4, #0x0 - bl SetupNativeScript - mov r0, #0x1 - pop {r4, pc} - nop -_02041498: .word FUN_02041464 - - thumb_func_start FUN_0204149C -FUN_0204149C: ; 0x0204149C - push {r3, lr} - ldr r1, [r0, #0x8] - add r3, r1, #0x1 - str r3, [r0, #0x8] - ldrb r2, [r1, #0x0] - add r1, r3, #0x1 - str r1, [r0, #0x8] - ldrb r1, [r3, #0x0] - add r0, r2, #0x0 - bl FUN_020047C8 - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_020414B8 -FUN_020414B8: ; 0x020414B8 - push {r3, lr} - bl ScriptReadHalfword - add r1, r0, #0x0 - mov r0, #0x4 - bl FUN_02005308 - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_020414CC -FUN_020414CC: ; 0x020414CC - push {r3, lr} - ldr r2, [r0, #0x8] - add r1, r2, #0x1 - str r1, [r0, #0x8] - ldrb r0, [r2, #0x0] - bl FUN_020040F4 - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_020414E0 -FUN_020414E0: ; 0x020414E0 - push {r4, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0x0 - ldr r0, [r4, #0x0] - bl VarGet - bl FUN_020054C8 - mov r0, #0x0 - pop {r4, pc} - .balign 4 - - thumb_func_start FUN_020414FC -FUN_020414FC: ; 0x020414FC - push {r4, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0x0 - ldr r0, [r4, #0x0] - bl VarGet - mov r1, #0x0 - bl FUN_020054F0 - mov r0, #0x0 - pop {r4, pc} - - thumb_func_start FUN_02041518 -FUN_02041518: ; 0x02041518 - push {r4, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r4, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - str r0, [r4, #0x64] - ldr r1, _0204153C ; =FUN_02041540 - add r0, r4, #0x0 - bl SetupNativeScript - mov r0, #0x1 - pop {r4, pc} - nop -_0204153C: .word FUN_02041540 - - thumb_func_start FUN_02041540 -FUN_02041540: ; 0x02041540 - push {r3, lr} - ldr r0, [r0, #0x64] - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - bl FUN_02005508 - cmp r0, #0x0 - bne _02041554 - mov r0, #0x1 - pop {r3, pc} -_02041554: - mov r0, #0x0 - pop {r3, pc} - - thumb_func_start FUN_02041558 -FUN_02041558: ; 0x02041558 - push {r3-r5, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r4, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r5, r0, #0x0 - add r0, r4, #0x0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0x0 - ldr r0, [r4, #0x0] - bl VarGet - add r0, r5, #0x0 - bl FUN_02005578 - mov r0, #0x0 - pop {r3-r5, pc} - - thumb_func_start ScrCmd_waitcry -ScrCmd_waitcry: ; 0x02041588 - push {r3, lr} - ldr r1, _02041594 ; =FUN_02041598 - bl SetupNativeScript - mov r0, #0x1 - pop {r3, pc} - .balign 4 -_02041594: .word FUN_02041598 - - thumb_func_start FUN_02041598 -FUN_02041598: ; 0x02041598 - push {r3, lr} - bl FUN_02005670 - cmp r0, #0x0 - bne _020415A6 - mov r0, #0x1 - pop {r3, pc} -_020415A6: - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start ScrCmd_playbgm -ScrCmd_playbgm: ; 0x020415AC - push {r3, lr} - bl ScriptReadHalfword - bl PlayBGM - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_020415BC -FUN_020415BC: ; 0x020415BC - push {r3, lr} - ldr r1, _020415C8 ; =FUN_020415CC - bl SetupNativeScript - mov r0, #0x1 - pop {r3, pc} - .balign 4 -_020415C8: .word FUN_020415CC - - thumb_func_start FUN_020415CC -FUN_020415CC: ; 0x020415CC - push {r3, lr} - bl FUN_02005CBC - cmp r0, #0x0 - bne _020415DA - mov r0, #0x1 - pop {r3, pc} -_020415DA: - mov r0, #0x0 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_020415E0 -FUN_020415E0: ; 0x020415E0 - push {r3-r5, lr} - add r5, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl GetVarPointer - add r5, #0x80 - add r4, r0, #0x0 - ldr r0, [r5, #0x0] - ldr r0, [r0, #0xc] - bl FUN_02029EF8 - bl FUN_02005D20 - cmp r0, #0x1 - bne _02041610 - mov r0, #0x1 - strh r0, [r4, #0x0] - mov r0, #0x0 - pop {r3-r5, pc} -_02041610: - mov r0, #0x0 - strh r0, [r4, #0x0] - pop {r3-r5, pc} - .balign 4 - - thumb_func_start FUN_02041618 -FUN_02041618: ; 0x02041618 - push {r4, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0x0 - ldr r0, [r4, #0x0] - bl GetVarPointer - add r4, r0, #0x0 - bl FUN_02005E28 - cmp r0, #0x0 - bne _0204163C - mov r0, #0x1 - strh r0, [r4, #0x0] - mov r0, #0x0 - pop {r4, pc} -_0204163C: - mov r0, #0x0 - strh r0, [r4, #0x0] - pop {r4, pc} - .balign 4 - - thumb_func_start FUN_02041644 -FUN_02041644: ; 0x02041644 - push {r3, lr} - bl FUN_02005E64 - mov r0, #0x1 - pop {r3, pc} - .balign 4 - - thumb_func_start FUN_02041650 -FUN_02041650: ; 0x02041650 - push {r3, lr} - add r0, #0x80 - ldr r0, [r0, #0x0] - ldr r0, [r0, #0xc] - bl FUN_02029EF8 - bl FUN_02005E6C - mov r0, #0x1 - pop {r3, pc} - - thumb_func_start FUN_02041664 -FUN_02041664: ; 0x02041664 - push {r3, lr} - mov r1, #0x0 - mov r0, #0x3f - add r2, r1, #0x0 - bl FUN_0200433C - mov r0, #0x1 - pop {r3, pc} - - thumb_func_start FUN_02041674 -FUN_02041674: ; 0x02041674 - push {r3-r5, lr} - add r4, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r4, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r5, r0, #0x0 - add r0, r4, #0x0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0x0 - ldr r0, [r4, #0x0] - bl VarGet - add r1, r0, #0x0 - add r0, r5, #0x0 - bl FUN_0200488C - mov r0, #0x0 - pop {r3-r5, pc} - .balign 4 diff --git a/arm9/asm/scrcmd_asm.s b/arm9/asm/scrcmd_asm.s index 3d6645c2..c1e91c9f 100644 --- a/arm9/asm/scrcmd_asm.s +++ b/arm9/asm/scrcmd_asm.s @@ -14,50 +14,6 @@ UNK_021C5A0C: ; 0x021C5A0C .text - thumb_func_start FUN_0203AFC4 -FUN_0203AFC4: ; 0x0203AFC4 - push {r4-r6, lr} - add r5, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r6, r0, #0x0 - add r0, r5, #0x0 - bl ScriptReadWord - add r4, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - add r1, r6, #0x0 - bl FUN_0203B120 - add r6, r0, #0x0 - bne _0203AFF6 - bl ErrorHandling -_0203AFF6: - ldr r1, [r5, #0x8] - add r0, r6, #0x0 - add r1, r1, r4 - bl FUN_0205AEA4 - add r4, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - mov r1, #0x4 - bl FUN_02039438 - ldrb r1, [r0, #0x0] - add r5, #0x80 - mov r2, #0x0 - add r1, r1, #0x1 - strb r1, [r0, #0x0] - ldr r0, [r5, #0x0] - add r1, r4, #0x0 - bl FUN_0203B174 - mov r0, #0x0 - pop {r4-r6, pc} - thumb_func_start FUN_0203B024 FUN_0203B024: ; 0x0203B024 push {r3-r7, lr} diff --git a/arm9/asm/unk_02022504.s b/arm9/asm/unk_02022504.s deleted file mode 100644 index e3463538..00000000 --- a/arm9/asm/unk_02022504.s +++ /dev/null @@ -1,53 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - thumb_func_start FUN_02022504 -FUN_02022504: ; 0x02022504 - ldr r3, _0202250C ; =SavArray_get - mov r1, #0x1b - bx r3 - nop -_0202250C: .word SavArray_get - - thumb_func_start GetStoragePCPointer -GetStoragePCPointer: ; 0x02022510 - ldr r3, _02022518 ; =SavArray_get - mov r1, #0x23 - bx r3 - nop -_02022518: .word SavArray_get - - thumb_func_start FUN_0202251C -FUN_0202251C: ; 0x0202251C - ldr r3, _02022524 ; =SavArray_get - mov r1, #0x1f - bx r3 - nop -_02022524: .word SavArray_get - - thumb_func_start FUN_02022528 -FUN_02022528: ; 0x02022528 - ldr r3, _02022530 ; =SavArray_get - mov r1, #0x20 - bx r3 - nop -_02022530: .word SavArray_get - - thumb_func_start LoadHallOfFame -LoadHallOfFame: ; 0x02022534 - push {r3, lr} - add r3, r2, #0x0 - mov r2, #0x0 - bl ReadSaveFileFromFlash - pop {r3, pc} - - thumb_func_start SaveHallOfFame -SaveHallOfFame: ; 0x02022540 - ldr r3, _02022548 ; =WriteSaveFileToFlash - add r2, r1, #0x0 - mov r1, #0x0 - bx r3 - .balign 4 -_02022548: .word WriteSaveFileToFlash diff --git a/arm9/asm/unk_02038C78.s b/arm9/asm/unk_02038C78.s index a43768aa..b60088a5 100644 --- a/arm9/asm/unk_02038C78.s +++ b/arm9/asm/unk_02038C78.s @@ -222,28 +222,28 @@ gScriptCmdTable: ; 0x020F355C .word ScrCmd_Unk0046 .word ScrCmd_Unk0047 .word ScrCmd_Unk0048 - .word FUN_020414E0 - .word FUN_020414FC - .word FUN_02041518 - .word FUN_02041558 - .word ScrCmd_waitcry - .word ScrCmd_playbgm - .word FUN_020415BC - .word FUN_020413E8 - .word FUN_020413F8 - .word FUN_0204140C - .word FUN_02041424 - .word FUN_0204143C - .word FUN_02041478 - .word FUN_0204149C - .word FUN_020414B8 - .word FUN_020414CC - .word FUN_020415E0 - .word FUN_02041618 - .word FUN_02041644 - .word FUN_02041650 - .word FUN_02041664 - .word FUN_0203AFC4 + .word ScrCmd_Unk0049 + .word ScrCmd_Unk004A + .word ScrCmd_Unk004B + .word ScrCmd_Unk004C + .word ScrCmd_PlayCryWait + .word ScrCmd_PlayBgm + .word ScrCmd_Unk004F + .word ScrCmd_Unk0050 + .word ScrCmd_Unk0051 + .word ScrCmd_Unk0052 + .word ScrCmd_Unk0053 + .word ScrCmd_Unk0054 + .word ScrCmd_Unk0055 + .word ScrCmd_Unk0056 + .word ScrCmd_Unk0057 + .word ScrCmd_Unk0058 + .word ScrCmd_Unk0059 + .word ScrCmd_Unk005A + .word ScrCmd_Unk005B + .word ScrCmd_Unk005C + .word ScrCmd_Unk005D + .word ScrCmd_Unk005E .word FUN_0203B148 .word FUN_0203B1F0 .word FUN_0203B3B0 @@ -603,8 +603,8 @@ gScriptCmdTable: ; 0x020F355C .word FUN_0203E078 .word FUN_0203E0CC .word FUN_0203E120 - .word FUN_02045D88 - .word FUN_02045DD0 + .word ScrCmd_Unk01C6 + .word ScrCmd_Unk01C7 .word FUN_02044D8C .word FUN_02044E34 .word FUN_02044E78 @@ -691,14 +691,14 @@ gScriptCmdTable: ; 0x020F355C .word FUN_0203E848 .word FUN_0203E858 .word ScrCmd_Unk021D - .word FUN_02045E1C - .word FUN_02045E20 - .word FUN_02045EE0 - .word FUN_02045EE4 - .word FUN_02045F84 - .word FUN_02045F88 - .word FUN_02045F24 - .word FUN_02045FCC + .word ScrCmd_Unk021E + .word ScrCmd_Unk021F + .word ScrCmd_Unk0220 + .word ScrCmd_Unk0221 + .word ScrCmd_Unk0222 + .word ScrCmd_Unk0223 + .word ScrCmd_Unk0224 + .word ScrCmd_Unk0225 .word FUN_0203E870 .word FUN_0203E894 .word FUN_0203E8C4 @@ -792,7 +792,7 @@ gScriptCmdTable: ; 0x020F355C .word ScrCmd_Unk0280 .word FUN_02044A0C .word FUN_0203F484 - .word FUN_02041674 + .word ScrCmd_Unk0283 .word FUN_0203F4D8 .word FUN_0203F508 .word FUN_0203F5D4 @@ -835,7 +835,7 @@ gScriptCmdTable: ; 0x020F355C .word FUN_0203B7F0 .word FUN_0203FB4C .word FUN_0203B790 - .word FUN_020413C0 + .word ScrCmd_Unk02AE .word FUN_0203FB64 .word FUN_0203FB94 .word FUN_0203FBA0 diff --git a/arm9/global.inc b/arm9/global.inc index 05ba01a7..71b29db9 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -2783,7 +2783,7 @@ .extern ScrCmd_Unk0048 .extern ScrCmd_Unk02CF .extern ScrCmd_Unk02D0 -.extern FUN_0203AFC4 +.extern ScrCmd_Unk005E .extern FUN_0203B024 .extern FUN_0203B148 .extern FUN_0203B1F0 @@ -3196,29 +3196,29 @@ .extern FUN_02041194 .extern FUN_020411C4 .extern FUN_02041340 -.extern FUN_020413C0 -.extern FUN_020413E8 -.extern FUN_020413F8 -.extern FUN_0204140C -.extern FUN_02041424 -.extern FUN_0204143C -.extern FUN_02041478 -.extern FUN_0204149C -.extern FUN_020414B8 -.extern FUN_020414CC -.extern FUN_020414E0 -.extern FUN_020414FC -.extern FUN_02041518 -.extern FUN_02041558 -.extern ScrCmd_waitcry -.extern ScrCmd_playbgm -.extern FUN_020415BC -.extern FUN_020415E0 -.extern FUN_02041618 -.extern FUN_02041644 -.extern FUN_02041650 -.extern FUN_02041664 -.extern FUN_02041674 +.extern ScrCmd_Unk02AE +.extern ScrCmd_Unk0050 +.extern ScrCmd_Unk0051 +.extern ScrCmd_Unk0052 +.extern ScrCmd_Unk0053 +.extern ScrCmd_Unk0054 +.extern ScrCmd_Unk0055 +.extern ScrCmd_Unk0056 +.extern ScrCmd_Unk0057 +.extern ScrCmd_Unk0058 +.extern ScrCmd_Unk0049 +.extern ScrCmd_Unk004A +.extern ScrCmd_Unk004B +.extern ScrCmd_Unk004C +.extern ScrCmd_PlayCryWait +.extern ScrCmd_PlayBgm +.extern ScrCmd_Unk004F +.extern ScrCmd_Unk0059 +.extern ScrCmd_Unk005A +.extern ScrCmd_Unk005B +.extern ScrCmd_Unk005C +.extern ScrCmd_Unk005D +.extern ScrCmd_Unk0283 .extern FUN_020416A8 .extern FUN_02041770 .extern FUN_020417E0 @@ -3402,16 +3402,16 @@ .extern ScrCmd_Unk0090 .extern ScrCmd_Unk0091 .extern ScrCmd_Unk0092 -.extern FUN_02045D88 -.extern FUN_02045DD0 -.extern FUN_02045E1C -.extern FUN_02045E20 -.extern FUN_02045EE0 -.extern FUN_02045EE4 -.extern FUN_02045F24 -.extern FUN_02045F84 -.extern FUN_02045F88 -.extern FUN_02045FCC +.extern ScrCmd_Unk01C6 +.extern ScrCmd_Unk01C7 +.extern ScrCmd_Unk021E +.extern ScrCmd_Unk021F +.extern ScrCmd_Unk0220 +.extern ScrCmd_Unk0221 +.extern ScrCmd_Unk0224 +.extern ScrCmd_Unk0222 +.extern ScrCmd_Unk0223 +.extern ScrCmd_Unk0225 .extern ScrCmd_Unk023F .extern ScrCmd_Unk0240 .extern ScrCmd_Unk0241 @@ -8518,3 +8518,4 @@ .extern FUN_02025490 .extern FUN_020254A0 .extern FUN_020254B4 +.extern FUN_02041464 diff --git a/arm9/lib/include/RTC_internal.h b/arm9/lib/include/RTC_internal.h new file mode 100644 index 00000000..440d8b95 --- /dev/null +++ b/arm9/lib/include/RTC_internal.h @@ -0,0 +1,11 @@ +#ifndef NITRO_RTC_INTERNAL_H_ +#define NITRO_RTC_INTERNAL_H_ + +#include "nitro/types.h" + +BOOL RTCi_WriteRawStatus2Async(void); +BOOL RTCi_ReadRawTimeAsync(void); +BOOL RTCi_ReadRawDateAsync(void); +BOOL RTCi_ReadRawDateTimeAsync(void); + +#endif //NITRO_RTC_INTERNAL_H_ diff --git a/arm9/lib/src/RTC_internal.c b/arm9/lib/src/RTC_internal.c new file mode 100644 index 00000000..c7a5f2aa --- /dev/null +++ b/arm9/lib/src/RTC_internal.c @@ -0,0 +1,31 @@ +#include "function_target.h" +#include "PXI_fifo.h" +#include "RTC_internal.h" + +static BOOL RtcSendPxiCommand(u8 command); + +ARM_FUNC BOOL RTCi_ReadRawDateTimeAsync(void) +{ + return RtcSendPxiCommand(16); +} + +ARM_FUNC BOOL RTCi_ReadRawDateAsync(void) +{ + return RtcSendPxiCommand(17); +} + +ARM_FUNC BOOL RTCi_ReadRawTimeAsync(void) +{ + return RtcSendPxiCommand(18); +} + +ARM_FUNC BOOL RTCi_WriteRawStatus2Async(void) +{ + return RtcSendPxiCommand(39); +} + +ARM_FUNC static BOOL RtcSendPxiCommand(u8 command) +{ + s32 data = command << 8 & 0x7f00; + return PXI_SendWordByFifo(PXI_FIFO_TAG_RTC, data, FALSE) >= 0; +} diff --git a/arm9/modules/52/include/module_52.h b/arm9/modules/52/include/module_52.h index 4c47a82d..0adedc62 100644 --- a/arm9/modules/52/include/module_52.h +++ b/arm9/modules/52/include/module_52.h @@ -13,30 +13,24 @@ #include "unk_02024E64.h" #include "unk_020286F8.h" -const u8 MOD52_021D76F8[]; +extern const struct Unk21DBE18 MOD52_021D76E8; +extern const struct Unk21DBE18 MOD52_021D76D8; +extern const struct Unk21DBE18 MOD52_021D76C8; -THUMB_FUNC int MOD52_021D74E0(); -THUMB_FUNC int MOD52_021D74F8(struct UnkStruct_02006234 *param0); -THUMB_FUNC int MOD52_021D750C(); +THUMB_FUNC BOOL MOD52_021D74E0(struct UnkStruct_02006234 *arg1, u32 *arg2); +THUMB_FUNC BOOL MOD52_021D74F8(struct UnkStruct_02006234 *param0, u32 *unused); +THUMB_FUNC BOOL MOD52_021D750C(struct UnkStruct_02006234 *arg1, u32 *arg2); -THUMB_FUNC int MOD52_021D7528(); -THUMB_FUNC int MOD52_021D7540(struct UnkStruct_02006234 *param0); -THUMB_FUNC int MOD52_021D7560(); +THUMB_FUNC BOOL MOD52_021D7528(struct UnkStruct_02006234 *arg1, u32 *arg2); +THUMB_FUNC BOOL MOD52_021D7540(struct UnkStruct_02006234 *param0, u32 *unused); +THUMB_FUNC BOOL MOD52_021D7560(struct UnkStruct_02006234 *arg1, u32 *arg2); -THUMB_FUNC int MOD52_021D757C(); -THUMB_FUNC int MOD52_021D7594(struct UnkStruct_02006234 *param0); -THUMB_FUNC int MOD52_021D75E8(); +THUMB_FUNC BOOL MOD52_021D757C(struct UnkStruct_02006234 *arg1, u32 *arg2); +THUMB_FUNC BOOL MOD52_021D7594(struct UnkStruct_02006234 *param0, u32 *unused); +THUMB_FUNC BOOL MOD52_021D75E8(struct UnkStruct_02006234 *arg1, u32 *arg2); THUMB_FUNC void MOD52_021D7604(u32 heap_id, struct SaveBlock2 *sav2, BOOL set_trainerid); THUMB_FUNC void MOD52_021D7688(u32 param0, struct SaveBlock2 *sav2); THUMB_FUNC void MOD52_021D769C(u32 param0, struct SaveBlock2 *sav2); -struct MOD52_Struct -{ - int (*func1)(void); - int (*func2)(struct UnkStruct_02006234 *param0); - int (*func3)(void); - u32 terminator; -}; - #endif // POKEDIAMOND_MODULE_52_H
\ No newline at end of file diff --git a/arm9/modules/52/src/module_52.c b/arm9/modules/52/src/module_52.c index 1f74c77f..41f2706a 100644 --- a/arm9/modules/52/src/module_52.c +++ b/arm9/modules/52/src/module_52.c @@ -1,28 +1,173 @@ #include "module_52.h" #include "heap.h" #include "unk_0205FA2C.h" +#include "unk_02015E30.h" extern struct Unk21DBE18 UNK_020FD144; extern struct Unk21DBE18 UNK_020F2B7C; extern struct Unk21DBE18 UNK_020F2B8C; -extern void FUN_02015E3C(struct IGT *igt); extern int FUN_02053678(u32 random, u32 gender, u32 param2); -extern void FUN_020250C4(void *sav_ptr, u32 heap_id, const u8 param2[], u32 param3); +extern void FUN_020250C4(void *sav_ptr, u32 heap_id, const u16 param2[], u32 param3); extern void FUN_020377E0(struct SaveBlock2 *sav2); extern void FUN_0205ECD4(struct ScriptState *script_state); -THUMB_FUNC int MOD52_021D74E0() +const struct Unk21DBE18 MOD52_021D76E8 = { + MOD52_021D74E0, + MOD52_021D74F8, + MOD52_021D750C, + 0xFFFFFFFF, +}; + +const struct Unk21DBE18 MOD52_021D76D8 = { + MOD52_021D7528, + MOD52_021D7540, + MOD52_021D7560, + 0xFFFFFFFF, +}; + +const struct Unk21DBE18 MOD52_021D76C8 = { + MOD52_021D757C, + MOD52_021D7594, + MOD52_021D75E8, + 0xFFFFFFFF, +}; + +const u16 MOD52_021D76F8[] = { + ITEM_ORAN_BERRY, 1, + ITEM_CHERI_BERRY, 1, + ITEM_CHESTO_BERRY, 1, + ITEM_PECHA_BERRY, 1, + ITEM_ORAN_BERRY, 1, + ITEM_PECHA_BERRY, 1, + ITEM_RAZZ_BERRY, 2, + ITEM_BLUK_BERRY, 2, + ITEM_CHERI_BERRY, 1, + ITEM_ORAN_BERRY, 2, + ITEM_SITRUS_BERRY, 1, + ITEM_WEPEAR_BERRY, 2, + ITEM_WEPEAR_BERRY, 2, + ITEM_KELPSY_BERRY, 1, + ITEM_CHERI_BERRY, 1, + ITEM_PECHA_BERRY, 1, + ITEM_ORAN_BERRY, 1, + ITEM_ORAN_BERRY, 1, + ITEM_RAWST_BERRY, 1, + ITEM_RAWST_BERRY, 1, + ITEM_RAZZ_BERRY, 1, + ITEM_RAZZ_BERRY, 1, + ITEM_CHERI_BERRY, 1, + ITEM_ORAN_BERRY, 1, + ITEM_ORAN_BERRY, 1, + ITEM_BLUK_BERRY, 1, + ITEM_NANAB_BERRY, 2, + ITEM_RAZZ_BERRY, 2, + ITEM_BLUK_BERRY, 2, + ITEM_PINAP_BERRY, 2, + ITEM_LEPPA_BERRY, 1, + ITEM_CHESTO_BERRY, 1, + ITEM_RAZZ_BERRY, 1, + ITEM_RAZZ_BERRY, 1, + ITEM_PERSIM_BERRY, 1, + ITEM_NANAB_BERRY, 1, + ITEM_NANAB_BERRY, 1, + ITEM_FIGY_BERRY, 1, + ITEM_ASPEAR_BERRY, 1, + ITEM_ASPEAR_BERRY, 1, + ITEM_RAZZ_BERRY, 1, + ITEM_PINAP_BERRY, 1, + ITEM_SITRUS_BERRY, 1, + ITEM_CHESTO_BERRY, 1, + ITEM_WIKI_BERRY, 1, + ITEM_AGUAV_BERRY, 1, + ITEM_PECHA_BERRY, 1, + ITEM_ASPEAR_BERRY, 1, + ITEM_IAPAPA_BERRY, 1, + ITEM_GREPA_BERRY, 1, + ITEM_SITRUS_BERRY, 1, + ITEM_ASPEAR_BERRY, 1, + ITEM_TAMATO_BERRY, 1, + ITEM_LUM_BERRY, 1, + ITEM_PECHA_BERRY, 1, + ITEM_PINAP_BERRY, 1, + ITEM_PINAP_BERRY, 1, + ITEM_PINAP_BERRY, 1, + ITEM_PERSIM_BERRY, 1, + ITEM_PERSIM_BERRY, 1, + ITEM_NANAB_BERRY, 1, + ITEM_NANAB_BERRY, 1, + ITEM_AGUAV_BERRY, 1, + ITEM_IAPAPA_BERRY, 1, + ITEM_RAWST_BERRY, 1, + ITEM_RAWST_BERRY, 1, + ITEM_CHERI_BERRY, 1, + ITEM_SITRUS_BERRY, 1, + ITEM_CHESTO_BERRY, 1, + ITEM_POMEG_BERRY, 1, + ITEM_PECHA_BERRY, 2, + ITEM_BLUK_BERRY, 2, + ITEM_WIKI_BERRY, 1, + ITEM_MAGO_BERRY, 1, + ITEM_RAWST_BERRY, 1, + ITEM_PERSIM_BERRY, 1, + ITEM_FIGY_BERRY, 1, + ITEM_PINAP_BERRY, 2, + ITEM_LEPPA_BERRY, 1, + ITEM_PECHA_BERRY, 1, + ITEM_MAGO_BERRY, 1, + ITEM_HONDEW_BERRY, 1, + ITEM_WIKI_BERRY, 2, + ITEM_MAGO_BERRY, 2, + ITEM_AGUAV_BERRY, 2, + ITEM_QUALOT_BERRY, 1, + ITEM_SITRUS_BERRY, 2, + ITEM_BLUK_BERRY, 3, + ITEM_NANAB_BERRY, 3, + ITEM_WEPEAR_BERRY, 3, + ITEM_POMEG_BERRY, 1, + ITEM_POMEG_BERRY, 1, + ITEM_HONDEW_BERRY, 2, + ITEM_HONDEW_BERRY, 2, + ITEM_KELPSY_BERRY, 1, + ITEM_KELPSY_BERRY, 1, + ITEM_TAMATO_BERRY, 1, + ITEM_TAMATO_BERRY, 1, + ITEM_QUALOT_BERRY, 1, + ITEM_QUALOT_BERRY, 1, + ITEM_POMEG_BERRY, 1, + ITEM_POMEG_BERRY, 1, + ITEM_HONDEW_BERRY, 1, + ITEM_HONDEW_BERRY, 1, + ITEM_TAMATO_BERRY, 1, + ITEM_TAMATO_BERRY, 1, + ITEM_GREPA_BERRY, 1, + ITEM_GREPA_BERRY, 1, + ITEM_QUALOT_BERRY, 1, + ITEM_QUALOT_BERRY, 1, + ITEM_LUM_BERRY, 1, + ITEM_LEPPA_BERRY, 1, + ITEM_QUALOT_BERRY, 2, + ITEM_GREPA_BERRY, 2, + ITEM_KELPSY_BERRY, 2, + ITEM_KELPSY_BERRY, 2, + ITEM_GREPA_BERRY, 1, + ITEM_GREPA_BERRY, 1, +}; + +THUMB_FUNC BOOL MOD52_021D74E0(struct UnkStruct_02006234 *arg1, u32 *arg2) { +#pragma unused(arg1) +#pragma unused(arg2) FUN_0201681C(3, 0x4d, 2 << 16); InitializeMainRNG(); return 1; } -THUMB_FUNC int MOD52_021D74F8(struct UnkStruct_02006234 *param0) +THUMB_FUNC BOOL MOD52_021D74F8(struct UnkStruct_02006234 *param0, u32 *unused) { +#pragma unused(unused) struct SaveBlock2 *sav2 = (struct SaveBlock2 *)OverlayManager_GetField18(param0)[2]; // weird MOD52_021D769C(0x4d, sav2); @@ -30,24 +175,29 @@ THUMB_FUNC int MOD52_021D74F8(struct UnkStruct_02006234 *param0) return 1; } -THUMB_FUNC int MOD52_021D750C() +THUMB_FUNC BOOL MOD52_021D750C(struct UnkStruct_02006234 *arg1, u32 *arg2) { +#pragma unused(arg1) +#pragma unused(arg2) FUN_020168D0(0x4d); RegisterMainOverlay(0XFFFFFFFF, &UNK_020FD144); return 1; } -THUMB_FUNC int MOD52_021D7528() +THUMB_FUNC BOOL MOD52_021D7528(struct UnkStruct_02006234 *arg1, u32 *arg2) { +#pragma unused(arg1) +#pragma unused(arg2) FUN_0201681C(3, 0x4d, 2 << 16); InitializeMainRNG(); return 1; } -THUMB_FUNC int MOD52_021D7540(struct UnkStruct_02006234 *param0) +THUMB_FUNC BOOL MOD52_021D7540(struct UnkStruct_02006234 *param0, u32 *unused) { +#pragma unused(unused) struct SaveBlock2 *sav2 = (struct SaveBlock2 *)OverlayManager_GetField18(param0)[2]; // weird MOD52_021D7604(0x4d, sav2, 1); @@ -57,24 +207,29 @@ THUMB_FUNC int MOD52_021D7540(struct UnkStruct_02006234 *param0) return 1; } -THUMB_FUNC int MOD52_021D7560() +THUMB_FUNC BOOL MOD52_021D7560(struct UnkStruct_02006234 *arg1, u32 *arg2) { +#pragma unused(arg1) +#pragma unused(arg2) FUN_020168D0(0x4d); RegisterMainOverlay(0xFFFFFFFF, &UNK_020F2B7C); return 1; } -THUMB_FUNC int MOD52_021D757C() +THUMB_FUNC BOOL MOD52_021D757C(struct UnkStruct_02006234 *arg1, u32 *arg2) { +#pragma unused(arg1) +#pragma unused(arg2) FUN_0201681C(3, 0x4d, 2 << 16); InitializeMainRNG(); return 1; } -THUMB_FUNC int MOD52_021D7594(struct UnkStruct_02006234 *param0) +THUMB_FUNC BOOL MOD52_021D7594(struct UnkStruct_02006234 *param0, u32 *unused) { +#pragma unused(unused) struct SaveBlock2 *sav2 = (struct SaveBlock2 *)OverlayManager_GetField18(param0)[2]; // weird struct SavSysInfo *sav2_info = Sav2_SysInfo_get(sav2); @@ -93,8 +248,10 @@ THUMB_FUNC int MOD52_021D7594(struct UnkStruct_02006234 *param0) return 1; } -THUMB_FUNC int MOD52_021D75E8() +THUMB_FUNC BOOL MOD52_021D75E8(struct UnkStruct_02006234 *arg1, u32 *arg2) { +#pragma unused(arg1) +#pragma unused(arg2) FUN_020168D0(0x4d); RegisterMainOverlay(0XFFFFFFFF, &UNK_020F2B8C); @@ -124,7 +281,7 @@ THUMB_FUNC void MOD52_021D7604(u32 heap_id, struct SaveBlock2 *sav2, BOOL set_tr PlayerProfile_SetAvatar(player_data, (u8)avatar); - FUN_020250C4(FUN_02024ECC(sav2), heap_id, MOD52_021D76F8, 0x76); + FUN_020250C4(FUN_02024ECC(sav2), heap_id, MOD52_021D76F8, NELEMS(MOD52_021D76F8) / 2); } THUMB_FUNC void MOD52_021D7688(u32 unused, struct SaveBlock2 *sav2) @@ -149,499 +306,3 @@ THUMB_FUNC void MOD52_021D769C(u32 unused, struct SaveBlock2 *sav2) PlayerProfile_SetMoney(player_data, 3000); FUN_0205ECD4(SavArray_Flags_get(sav2)); } - -const struct MOD52_Struct MOD52_021D76C8 = { - MOD52_021D757C, - MOD52_021D7594, - MOD52_021D75E8, - 0xFFFFFFFF, -}; - -const struct MOD52_Struct MOD52_021D76D8 = { - MOD52_021D7528, - MOD52_021D7540, - MOD52_021D7560, - 0xFFFFFFFF, -}; - -const struct MOD52_Struct MOD52_021D76E8 = { - MOD52_021D74E0, - MOD52_021D74F8, - MOD52_021D750C, - 0xFFFFFFFF, -}; - -const u8 MOD52_021D76F8[] = { - 0x9B, - 0x00, - 0x01, - 0x00, - 0x95, - 0x00, - 0x01, - 0x00, - 0x96, - 0x00, - 0x01, - 0x00, - 0x97, - 0x00, - 0x01, - 0x00, - 0x9B, - 0x00, - 0x01, - 0x00, - 0x97, - 0x00, - 0x01, - 0x00, - 0xA4, - 0x00, - 0x02, - 0x00, - 0xA5, - 0x00, - 0x02, - 0x00, - 0x95, - 0x00, - 0x01, - 0x00, - 0x9B, - 0x00, - 0x02, - 0x00, - 0x9E, - 0x00, - 0x01, - 0x00, - 0xA7, - 0x00, - 0x02, - 0x00, - 0xA7, - 0x00, - 0x02, - 0x00, - 0xAA, - 0x00, - 0x01, - 0x00, - 0x95, - 0x00, - 0x01, - 0x00, - 0x97, - 0x00, - 0x01, - 0x00, - 0x9B, - 0x00, - 0x01, - 0x00, - 0x9B, - 0x00, - 0x01, - 0x00, - 0x98, - 0x00, - 0x01, - 0x00, - 0x98, - 0x00, - 0x01, - 0x00, - 0xA4, - 0x00, - 0x01, - 0x00, - 0xA4, - 0x00, - 0x01, - 0x00, - 0x95, - 0x00, - 0x01, - 0x00, - 0x9B, - 0x00, - 0x01, - 0x00, - 0x9B, - 0x00, - 0x01, - 0x00, - 0xA5, - 0x00, - 0x01, - 0x00, - 0xA6, - 0x00, - 0x02, - 0x00, - 0xA4, - 0x00, - 0x02, - 0x00, - 0xA5, - 0x00, - 0x02, - 0x00, - 0xA8, - 0x00, - 0x02, - 0x00, - 0x9A, - 0x00, - 0x01, - 0x00, - 0x96, - 0x00, - 0x01, - 0x00, - 0xA4, - 0x00, - 0x01, - 0x00, - 0xA4, - 0x00, - 0x01, - 0x00, - 0x9C, - 0x00, - 0x01, - 0x00, - 0xA6, - 0x00, - 0x01, - 0x00, - 0xA6, - 0x00, - 0x01, - 0x00, - 0x9F, - 0x00, - 0x01, - 0x00, - 0x99, - 0x00, - 0x01, - 0x00, - 0x99, - 0x00, - 0x01, - 0x00, - 0xA4, - 0x00, - 0x01, - 0x00, - 0xA8, - 0x00, - 0x01, - 0x00, - 0x9E, - 0x00, - 0x01, - 0x00, - 0x96, - 0x00, - 0x01, - 0x00, - 0xA0, - 0x00, - 0x01, - 0x00, - 0xA2, - 0x00, - 0x01, - 0x00, - 0x97, - 0x00, - 0x01, - 0x00, - 0x99, - 0x00, - 0x01, - 0x00, - 0xA3, - 0x00, - 0x01, - 0x00, - 0xAD, - 0x00, - 0x01, - 0x00, - 0x9E, - 0x00, - 0x01, - 0x00, - 0x99, - 0x00, - 0x01, - 0x00, - 0xAE, - 0x00, - 0x01, - 0x00, - 0x9D, - 0x00, - 0x01, - 0x00, - 0x97, - 0x00, - 0x01, - 0x00, - 0xA8, - 0x00, - 0x01, - 0x00, - 0xA8, - 0x00, - 0x01, - 0x00, - 0xA8, - 0x00, - 0x01, - 0x00, - 0x9C, - 0x00, - 0x01, - 0x00, - 0x9C, - 0x00, - 0x01, - 0x00, - 0xA6, - 0x00, - 0x01, - 0x00, - 0xA6, - 0x00, - 0x01, - 0x00, - 0xA2, - 0x00, - 0x01, - 0x00, - 0xA3, - 0x00, - 0x01, - 0x00, - 0x98, - 0x00, - 0x01, - 0x00, - 0x98, - 0x00, - 0x01, - 0x00, - 0x95, - 0x00, - 0x01, - 0x00, - 0x9E, - 0x00, - 0x01, - 0x00, - 0x96, - 0x00, - 0x01, - 0x00, - 0xA9, - 0x00, - 0x01, - 0x00, - 0x97, - 0x00, - 0x02, - 0x00, - 0xA5, - 0x00, - 0x02, - 0x00, - 0xA0, - 0x00, - 0x01, - 0x00, - 0xA1, - 0x00, - 0x01, - 0x00, - 0x98, - 0x00, - 0x01, - 0x00, - 0x9C, - 0x00, - 0x01, - 0x00, - 0x9F, - 0x00, - 0x01, - 0x00, - 0xA8, - 0x00, - 0x02, - 0x00, - 0x9A, - 0x00, - 0x01, - 0x00, - 0x97, - 0x00, - 0x01, - 0x00, - 0xA1, - 0x00, - 0x01, - 0x00, - 0xAC, - 0x00, - 0x01, - 0x00, - 0xA0, - 0x00, - 0x02, - 0x00, - 0xA1, - 0x00, - 0x02, - 0x00, - 0xA2, - 0x00, - 0x02, - 0x00, - 0xAB, - 0x00, - 0x01, - 0x00, - 0x9E, - 0x00, - 0x02, - 0x00, - 0xA5, - 0x00, - 0x03, - 0x00, - 0xA6, - 0x00, - 0x03, - 0x00, - 0xA7, - 0x00, - 0x03, - 0x00, - 0xA9, - 0x00, - 0x01, - 0x00, - 0xA9, - 0x00, - 0x01, - 0x00, - 0xAC, - 0x00, - 0x02, - 0x00, - 0xAC, - 0x00, - 0x02, - 0x00, - 0xAA, - 0x00, - 0x01, - 0x00, - 0xAA, - 0x00, - 0x01, - 0x00, - 0xAE, - 0x00, - 0x01, - 0x00, - 0xAE, - 0x00, - 0x01, - 0x00, - 0xAB, - 0x00, - 0x01, - 0x00, - 0xAB, - 0x00, - 0x01, - 0x00, - 0xA9, - 0x00, - 0x01, - 0x00, - 0xA9, - 0x00, - 0x01, - 0x00, - 0xAC, - 0x00, - 0x01, - 0x00, - 0xAC, - 0x00, - 0x01, - 0x00, - 0xAE, - 0x00, - 0x01, - 0x00, - 0xAE, - 0x00, - 0x01, - 0x00, - 0xAD, - 0x00, - 0x01, - 0x00, - 0xAD, - 0x00, - 0x01, - 0x00, - 0xAB, - 0x00, - 0x01, - 0x00, - 0xAB, - 0x00, - 0x01, - 0x00, - 0x9D, - 0x00, - 0x01, - 0x00, - 0x9A, - 0x00, - 0x01, - 0x00, - 0xAB, - 0x00, - 0x02, - 0x00, - 0xAD, - 0x00, - 0x02, - 0x00, - 0xAA, - 0x00, - 0x02, - 0x00, - 0xAA, - 0x00, - 0x02, - 0x00, - 0xAD, - 0x00, - 0x01, - 0x00, - 0xAD, - 0x00, - 0x01, - 0x00, -};
\ No newline at end of file diff --git a/arm9/src/WIFI_stubsmd5_dummy.c b/arm9/src/WIFI_stubsmd5_dummy.c new file mode 100644 index 00000000..6de2edca --- /dev/null +++ b/arm9/src/WIFI_stubsmd5_dummy.c @@ -0,0 +1,17 @@ +#include "function_target.h" +#include "WIFI_stubsmd5_dummy.h" + +ARM_FUNC void MD5Final(u8 *digest, struct DGTHash1Context *context) +{ + DGT_Hash1GetDigest_R(digest, context); +} + +ARM_FUNC void MD5Update(struct DGTHash1Context *context, u8 *input, u32 length) +{ + DGT_Hash1SetSource(context, input, length); +} + +ARM_FUNC void MD5Init(struct DGTHash1Context *context) +{ + DGT_Hash1Reset(context); +} diff --git a/arm9/src/main.c b/arm9/src/main.c index f7bcf7f0..117535b2 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -14,7 +14,7 @@ #include "timer3.h" #include "unk_02031734.h" #include "unk_0202F150.h" - +#include "module_52.h" FS_EXTERN_OVERLAY(MODULE_52); @@ -24,10 +24,6 @@ FS_EXTERN_OVERLAY(MODULE_63); struct Unk2106FA0 gBacklightTop; -extern BOOL OverlayManager_new(struct Unk21DBE18 *, s32 *, int); -extern BOOL OverlayManager_Run(int); -extern void OverlayManager_delete(int); - extern void InitSystemForTheGame(void); extern void InitGraphicMemory(void); extern void FUN_02022294(void); @@ -50,12 +46,11 @@ extern void FUN_0200A318(void); extern void FUN_0200E2D8(void); extern struct Unk21DBE18 MOD63_021DBE18; -extern struct Unk21DBE18 MOD52_021D76C8; extern u8 SDK_STATIC_BSS_START[]; -const int gGameVersion = GAME_VERSION; const int gGameLanguage = GAME_LANGUAGE; +const int gGameVersion = GAME_VERSION; THUMB_FUNC void NitroMain(void) { @@ -174,7 +169,7 @@ THUMB_FUNC void Main_RunOverlayManager(void) } } -THUMB_FUNC void RegisterMainOverlay(FSOverlayID id, struct Unk21DBE18 * arg1) +THUMB_FUNC void RegisterMainOverlay(FSOverlayID id, const struct Unk21DBE18 * arg1) { if (gBacklightTop.unk14 != NULL) ErrorHandling(); diff --git a/arm9/src/math_util.c b/arm9/src/math_util.c index 5aeb4f8e..4ecee59c 100644 --- a/arm9/src/math_util.c +++ b/arm9/src/math_util.c @@ -6,124 +6,461 @@ extern const s16 UNK_020FFA38[]; // temporary until further notice /* * Constant tables */ -const s32 gSineTable[] = +const fx32 gSineTable[] = { - 0x00000000, 0x00000047, 0x0000008F, 0x000000D6, - 0x0000011E, 0x00000165, 0x000001AC, 0x000001F3, - 0x0000023A, 0x00000281, 0x000002C7, 0x0000030E, - 0x00000354, 0x00000399, 0x000003DF, 0x00000424, - 0x00000469, 0x000004AE, 0x000004F2, 0x00000536, - 0x00000579, 0x000005BC, 0x000005FE, 0x00000640, - 0x00000682, 0x000006C3, 0x00000704, 0x00000744, - 0x00000783, 0x000007C2, 0x00000800, 0x0000083E, - 0x0000087B, 0x000008B7, 0x000008F2, 0x0000092D, - 0x00000968, 0x000009A1, 0x000009DA, 0x00000A12, - 0x00000A49, 0x00000A7F, 0x00000AB5, 0x00000AE9, - 0x00000B1D, 0x00000B50, 0x00000B82, 0x00000BB4, - 0x00000BE4, 0x00000C13, 0x00000C42, 0x00000C6F, - 0x00000C9C, 0x00000CC7, 0x00000CF2, 0x00000D1B, - 0x00000D44, 0x00000D6B, 0x00000D92, 0x00000DB7, - 0x00000DDB, 0x00000DFE, 0x00000E21, 0x00000E42, - 0x00000E61, 0x00000E80, 0x00000E9E, 0x00000EBA, - 0x00000ED6, 0x00000EF0, 0x00000F09, 0x00000F21, - 0x00000F38, 0x00000F4D, 0x00000F61, 0x00000F74, - 0x00000F86, 0x00000F97, 0x00000FA6, 0x00000FB5, - 0x00000FC2, 0x00000FCE, 0x00000FD8, 0x00000FE1, - 0x00000FEA, 0x00000FF0, 0x00000FF6, 0x00000FFA, - 0x00000FFE, 0x00000FFF, 0x00001000, 0x00000FFF, - 0x00000FFE, 0x00000FFA, 0x00000FF6, 0x00000FF0, - 0x00000FEA, 0x00000FE1, 0x00000FD8, 0x00000FCE, - 0x00000FC2, 0x00000FB5, 0x00000FA6, 0x00000F97, - 0x00000F86, 0x00000F74, 0x00000F61, 0x00000F4D, - 0x00000F38, 0x00000F21, 0x00000F09, 0x00000EF0, - 0x00000ED6, 0x00000EBA, 0x00000E9E, 0x00000E80, - 0x00000E61, 0x00000E42, 0x00000E21, 0x00000DFE, - 0x00000DDB, 0x00000DB7, 0x00000D92, 0x00000D6B, - 0x00000D44, 0x00000D1B, 0x00000CF2, 0x00000CC7, - 0x00000C9C, 0x00000C6F, 0x00000C42, 0x00000C13, - 0x00000BE4, 0x00000BB4, 0x00000B82, 0x00000B50, - 0x00000B1D, 0x00000AE9, 0x00000AB5, 0x00000A7F, - 0x00000A49, 0x00000A12, 0x000009DA, 0x000009A1, - 0x00000968, 0x0000092D, 0x000008F2, 0x000008B7, - 0x0000087B, 0x0000083E, 0x00000800, 0x000007C2, - 0x00000783, 0x00000744, 0x00000704, 0x000006C3, - 0x00000682, 0x00000640, 0x000005FE, 0x000005BC, - 0x00000579, 0x00000536, 0x000004F2, 0x000004AE, - 0x00000469, 0x00000424, 0x000003DF, 0x00000399, - 0x00000354, 0x0000030E, 0x000002C7, 0x00000281, - 0x0000023A, 0x000001F3, 0x000001AC, 0x00000165, - 0x0000011E, 0x000000D6, 0x0000008F, 0x00000047, - 0x00000000, 0xFFFFFFB9, 0xFFFFFF71, 0xFFFFFF2A, - 0xFFFFFEE2, 0xFFFFFE9B, 0xFFFFFE54, 0xFFFFFE0D, - 0xFFFFFDC6, 0xFFFFFD7F, 0xFFFFFD39, 0xFFFFFCF2, - 0xFFFFFCAC, 0xFFFFFC67, 0xFFFFFC21, 0xFFFFFBDC, - 0xFFFFFB97, 0xFFFFFB52, 0xFFFFFB0E, 0xFFFFFACA, - 0xFFFFFA87, 0xFFFFFA44, 0xFFFFFA02, 0xFFFFF9C0, - 0xFFFFF97E, 0xFFFFF93D, 0xFFFFF8FC, 0xFFFFF8BC, - 0xFFFFF87D, 0xFFFFF83E, 0xFFFFF800, 0xFFFFF7C2, - 0xFFFFF785, 0xFFFFF749, 0xFFFFF70E, 0xFFFFF6D3, - 0xFFFFF698, 0xFFFFF65F, 0xFFFFF626, 0xFFFFF5EE, - 0xFFFFF5B7, 0xFFFFF581, 0xFFFFF54B, 0xFFFFF517, - 0xFFFFF4E3, 0xFFFFF4B0, 0xFFFFF47E, 0xFFFFF44C, - 0xFFFFF41C, 0xFFFFF3ED, 0xFFFFF3BE, 0xFFFFF391, - 0xFFFFF364, 0xFFFFF339, 0xFFFFF30E, 0xFFFFF2E5, - 0xFFFFF2BC, 0xFFFFF295, 0xFFFFF26E, 0xFFFFF249, - 0xFFFFF225, 0xFFFFF202, 0xFFFFF1DF, 0xFFFFF1BE, - 0xFFFFF19F, 0xFFFFF180, 0xFFFFF162, 0xFFFFF146, - 0xFFFFF12A, 0xFFFFF110, 0xFFFFF0F7, 0xFFFFF0DF, - 0xFFFFF0C8, 0xFFFFF0B3, 0xFFFFF09F, 0xFFFFF08C, - 0xFFFFF07A, 0xFFFFF069, 0xFFFFF05A, 0xFFFFF04B, - 0xFFFFF03E, 0xFFFFF032, 0xFFFFF028, 0xFFFFF01F, - 0xFFFFF016, 0xFFFFF010, 0xFFFFF00A, 0xFFFFF006, - 0xFFFFF002, 0xFFFFF001, 0xFFFFF000, 0xFFFFF001, - 0xFFFFF002, 0xFFFFF006, 0xFFFFF00A, 0xFFFFF010, - 0xFFFFF016, 0xFFFFF01F, 0xFFFFF028, 0xFFFFF032, - 0xFFFFF03E, 0xFFFFF04B, 0xFFFFF05A, 0xFFFFF069, - 0xFFFFF07A, 0xFFFFF08C, 0xFFFFF09F, 0xFFFFF0B3, - 0xFFFFF0C8, 0xFFFFF0DF, 0xFFFFF0F7, 0xFFFFF110, - 0xFFFFF12A, 0xFFFFF146, 0xFFFFF162, 0xFFFFF180, - 0xFFFFF19F, 0xFFFFF1BE, 0xFFFFF1DF, 0xFFFFF202, - 0xFFFFF225, 0xFFFFF249, 0xFFFFF26E, 0xFFFFF295, - 0xFFFFF2BC, 0xFFFFF2E5, 0xFFFFF30E, 0xFFFFF339, - 0xFFFFF364, 0xFFFFF391, 0xFFFFF3BE, 0xFFFFF3ED, - 0xFFFFF41C, 0xFFFFF44C, 0xFFFFF47E, 0xFFFFF4B0, - 0xFFFFF4E3, 0xFFFFF517, 0xFFFFF54B, 0xFFFFF581, - 0xFFFFF5B7, 0xFFFFF5EE, 0xFFFFF626, 0xFFFFF65F, - 0xFFFFF698, 0xFFFFF6D3, 0xFFFFF70E, 0xFFFFF749, - 0xFFFFF785, 0xFFFFF7C2, 0xFFFFF800, 0xFFFFF83E, - 0xFFFFF87D, 0xFFFFF8BC, 0xFFFFF8FC, 0xFFFFF93D, - 0xFFFFF97E, 0xFFFFF9C0, 0xFFFFFA02, 0xFFFFFA44, - 0xFFFFFA87, 0xFFFFFACA, 0xFFFFFB0E, 0xFFFFFB52, - 0xFFFFFB97, 0xFFFFFBDC, 0xFFFFFC21, 0xFFFFFC67, - 0xFFFFFCAC, 0xFFFFFCF2, 0xFFFFFD39, 0xFFFFFD7F, - 0xFFFFFDC6, 0xFFFFFE0D, 0xFFFFFE54, 0xFFFFFE9B, - 0xFFFFFEE2, 0xFFFFFF2A, 0xFFFFFF71, 0xFFFFFFB9, - 0x00000000, 0x00000047, 0x0000008F, 0x000000D6, - 0x0000011E, 0x00000165, 0x000001AC, 0x000001F3, - 0x0000023A, 0x00000281, 0x000002C7, 0x0000030E, - 0x00000354, 0x00000399, 0x000003DF, 0x00000424, - 0x00000469, 0x000004AE, 0x000004F2, 0x00000536, - 0x00000579, 0x000005BC, 0x000005FE, 0x00000640, - 0x00000682, 0x000006C3, 0x00000704, 0x00000744, - 0x00000783, 0x000007C2, 0x00000800, 0x0000083E, - 0x0000087B, 0x000008B7, 0x000008F2, 0x0000092D, - 0x00000968, 0x000009A1, 0x000009DA, 0x00000A12, - 0x00000A49, 0x00000A7F, 0x00000AB5, 0x00000AE9, - 0x00000B1D, 0x00000B50, 0x00000B82, 0x00000BB4, - 0x00000BE4, 0x00000C13, 0x00000C42, 0x00000C6F, - 0x00000C9C, 0x00000CC7, 0x00000CF2, 0x00000D1B, - 0x00000D44, 0x00000D6B, 0x00000D92, 0x00000DB7, - 0x00000DDB, 0x00000DFE, 0x00000E21, 0x00000E42, - 0x00000E61, 0x00000E80, 0x00000E9E, 0x00000EBA, - 0x00000ED6, 0x00000EF0, 0x00000F09, 0x00000F21, - 0x00000F38, 0x00000F4D, 0x00000F61, 0x00000F74, - 0x00000F86, 0x00000F97, 0x00000FA6, 0x00000FB5, - 0x00000FC2, 0x00000FCE, 0x00000FD8, 0x00000FE1, - 0x00000FEA, 0x00000FF0, 0x00000FF6, 0x00000FFA, - 0x00000FFE, 0x00000FFF + FX32_CONST(0.0), // sin(0) + FX32_CONST(0.017333984375), // sin(1) + FX32_CONST(0.034912109375), // sin(2) + FX32_CONST(0.05224609375), // sin(3) + FX32_CONST(0.06982421875), // sin(4) + FX32_CONST(0.087158203125), // sin(5) + FX32_CONST(0.1044921875), // sin(6) + FX32_CONST(0.121826171875), // sin(7) + FX32_CONST(0.13916015625), // sin(8) + FX32_CONST(0.156494140625), // sin(9) + FX32_CONST(0.173583984375), // sin(10) + FX32_CONST(0.19091796875), // sin(11) + FX32_CONST(0.2080078125), // sin(12) + FX32_CONST(0.224853515625), // sin(13) + FX32_CONST(0.241943359375), // sin(14) + FX32_CONST(0.2587890625), // sin(15) + FX32_CONST(0.275634765625), // sin(16) + FX32_CONST(0.29248046875), // sin(17) + FX32_CONST(0.30908203125), // sin(18) + FX32_CONST(0.32568359375), // sin(19) + FX32_CONST(0.342041015625), // sin(20) + FX32_CONST(0.3583984375), // sin(21) + FX32_CONST(0.37451171875), // sin(22) + FX32_CONST(0.390625), // sin(23) + FX32_CONST(0.40673828125), // sin(24) + FX32_CONST(0.422607421875), // sin(25) + FX32_CONST(0.4384765625), // sin(26) + FX32_CONST(0.4541015625), // sin(27) + FX32_CONST(0.469482421875), // sin(28) + FX32_CONST(0.48486328125), // sin(29) + FX32_CONST(0.5), // sin(30) + FX32_CONST(0.51513671875), // sin(31) + FX32_CONST(0.530029296875), // sin(32) + FX32_CONST(0.544677734375), // sin(33) + FX32_CONST(0.55908203125), // sin(34) + FX32_CONST(0.573486328125), // sin(35) + FX32_CONST(0.587890625), // sin(36) + FX32_CONST(0.601806640625), // sin(37) + FX32_CONST(0.61572265625), // sin(38) + FX32_CONST(0.62939453125), // sin(39) + FX32_CONST(0.642822265625), // sin(40) + FX32_CONST(0.656005859375), // sin(41) + FX32_CONST(0.669189453125), // sin(42) + FX32_CONST(0.681884765625), // sin(43) + FX32_CONST(0.694580078125), // sin(44) + FX32_CONST(0.70703125), // sin(45) + FX32_CONST(0.71923828125), // sin(46) + FX32_CONST(0.7314453125), // sin(47) + FX32_CONST(0.7431640625), // sin(48) + FX32_CONST(0.754638671875), // sin(49) + FX32_CONST(0.76611328125), // sin(50) + FX32_CONST(0.777099609375), // sin(51) + FX32_CONST(0.7880859375), // sin(52) + FX32_CONST(0.798583984375), // sin(53) + FX32_CONST(0.80908203125), // sin(54) + FX32_CONST(0.819091796875), // sin(55) + FX32_CONST(0.8291015625), // sin(56) + FX32_CONST(0.838623046875), // sin(57) + FX32_CONST(0.84814453125), // sin(58) + FX32_CONST(0.857177734375), // sin(59) + FX32_CONST(0.865966796875), // sin(60) + FX32_CONST(0.87451171875), // sin(61) + FX32_CONST(0.883056640625), // sin(62) + FX32_CONST(0.89111328125), // sin(63) + FX32_CONST(0.898681640625), // sin(64) + FX32_CONST(0.90625), // sin(65) + FX32_CONST(0.91357421875), // sin(66) + FX32_CONST(0.92041015625), // sin(67) + FX32_CONST(0.92724609375), // sin(68) + FX32_CONST(0.93359375), // sin(69) + FX32_CONST(0.939697265625), // sin(70) + FX32_CONST(0.945556640625), // sin(71) + FX32_CONST(0.951171875), // sin(72) + FX32_CONST(0.956298828125), // sin(73) + FX32_CONST(0.961181640625), // sin(74) + FX32_CONST(0.9658203125), // sin(75) + FX32_CONST(0.97021484375), // sin(76) + FX32_CONST(0.974365234375), // sin(77) + FX32_CONST(0.97802734375), // sin(78) + FX32_CONST(0.981689453125), // sin(79) + FX32_CONST(0.98486328125), // sin(80) + FX32_CONST(0.98779296875), // sin(81) + FX32_CONST(0.990234375), // sin(82) + FX32_CONST(0.992431640625), // sin(83) + FX32_CONST(0.99462890625), // sin(84) + FX32_CONST(0.99609375), // sin(85) + FX32_CONST(0.99755859375), // sin(86) + FX32_CONST(0.99853515625), // sin(87) + FX32_CONST(0.99951171875), // sin(88) + FX32_CONST(0.999755859375), // sin(89) + FX32_CONST(1.0), // sin(90) + FX32_CONST(0.999755859375), // sin(91) + FX32_CONST(0.99951171875), // sin(92) + FX32_CONST(0.99853515625), // sin(93) + FX32_CONST(0.99755859375), // sin(94) + FX32_CONST(0.99609375), // sin(95) + FX32_CONST(0.99462890625), // sin(96) + FX32_CONST(0.992431640625), // sin(97) + FX32_CONST(0.990234375), // sin(98) + FX32_CONST(0.98779296875), // sin(99) + FX32_CONST(0.98486328125), // sin(100) + FX32_CONST(0.981689453125), // sin(101) + FX32_CONST(0.97802734375), // sin(102) + FX32_CONST(0.974365234375), // sin(103) + FX32_CONST(0.97021484375), // sin(104) + FX32_CONST(0.9658203125), // sin(105) + FX32_CONST(0.961181640625), // sin(106) + FX32_CONST(0.956298828125), // sin(107) + FX32_CONST(0.951171875), // sin(108) + FX32_CONST(0.945556640625), // sin(109) + FX32_CONST(0.939697265625), // sin(110) + FX32_CONST(0.93359375), // sin(111) + FX32_CONST(0.92724609375), // sin(112) + FX32_CONST(0.92041015625), // sin(113) + FX32_CONST(0.91357421875), // sin(114) + FX32_CONST(0.90625), // sin(115) + FX32_CONST(0.898681640625), // sin(116) + FX32_CONST(0.89111328125), // sin(117) + FX32_CONST(0.883056640625), // sin(118) + FX32_CONST(0.87451171875), // sin(119) + FX32_CONST(0.865966796875), // sin(120) + FX32_CONST(0.857177734375), // sin(121) + FX32_CONST(0.84814453125), // sin(122) + FX32_CONST(0.838623046875), // sin(123) + FX32_CONST(0.8291015625), // sin(124) + FX32_CONST(0.819091796875), // sin(125) + FX32_CONST(0.80908203125), // sin(126) + FX32_CONST(0.798583984375), // sin(127) + FX32_CONST(0.7880859375), // sin(128) + FX32_CONST(0.777099609375), // sin(129) + FX32_CONST(0.76611328125), // sin(130) + FX32_CONST(0.754638671875), // sin(131) + FX32_CONST(0.7431640625), // sin(132) + FX32_CONST(0.7314453125), // sin(133) + FX32_CONST(0.71923828125), // sin(134) + FX32_CONST(0.70703125), // sin(135) + FX32_CONST(0.694580078125), // sin(136) + FX32_CONST(0.681884765625), // sin(137) + FX32_CONST(0.669189453125), // sin(138) + FX32_CONST(0.656005859375), // sin(139) + FX32_CONST(0.642822265625), // sin(140) + FX32_CONST(0.62939453125), // sin(141) + FX32_CONST(0.61572265625), // sin(142) + FX32_CONST(0.601806640625), // sin(143) + FX32_CONST(0.587890625), // sin(144) + FX32_CONST(0.573486328125), // sin(145) + FX32_CONST(0.55908203125), // sin(146) + FX32_CONST(0.544677734375), // sin(147) + FX32_CONST(0.530029296875), // sin(148) + FX32_CONST(0.51513671875), // sin(149) + FX32_CONST(0.5), // sin(150) + FX32_CONST(0.48486328125), // sin(151) + FX32_CONST(0.469482421875), // sin(152) + FX32_CONST(0.4541015625), // sin(153) + FX32_CONST(0.4384765625), // sin(154) + FX32_CONST(0.422607421875), // sin(155) + FX32_CONST(0.40673828125), // sin(156) + FX32_CONST(0.390625), // sin(157) + FX32_CONST(0.37451171875), // sin(158) + FX32_CONST(0.3583984375), // sin(159) + FX32_CONST(0.342041015625), // sin(160) + FX32_CONST(0.32568359375), // sin(161) + FX32_CONST(0.30908203125), // sin(162) + FX32_CONST(0.29248046875), // sin(163) + FX32_CONST(0.275634765625), // sin(164) + FX32_CONST(0.2587890625), // sin(165) + FX32_CONST(0.241943359375), // sin(166) + FX32_CONST(0.224853515625), // sin(167) + FX32_CONST(0.2080078125), // sin(168) + FX32_CONST(0.19091796875), // sin(169) + FX32_CONST(0.173583984375), // sin(170) + FX32_CONST(0.156494140625), // sin(171) + FX32_CONST(0.13916015625), // sin(172) + FX32_CONST(0.121826171875), // sin(173) + FX32_CONST(0.1044921875), // sin(174) + FX32_CONST(0.087158203125), // sin(175) + FX32_CONST(0.06982421875), // sin(176) + FX32_CONST(0.05224609375), // sin(177) + FX32_CONST(0.034912109375), // sin(178) + FX32_CONST(0.017333984375), // sin(179) + FX32_CONST(0.0), // sin(180) + FX32_CONST(-0.017333984375), // sin(181) + FX32_CONST(-0.034912109375), // sin(182) + FX32_CONST(-0.05224609375), // sin(183) + FX32_CONST(-0.06982421875), // sin(184) + FX32_CONST(-0.087158203125), // sin(185) + FX32_CONST(-0.1044921875), // sin(186) + FX32_CONST(-0.121826171875), // sin(187) + FX32_CONST(-0.13916015625), // sin(188) + FX32_CONST(-0.156494140625), // sin(189) + FX32_CONST(-0.173583984375), // sin(190) + FX32_CONST(-0.19091796875), // sin(191) + FX32_CONST(-0.2080078125), // sin(192) + FX32_CONST(-0.224853515625), // sin(193) + FX32_CONST(-0.241943359375), // sin(194) + FX32_CONST(-0.2587890625), // sin(195) + FX32_CONST(-0.275634765625), // sin(196) + FX32_CONST(-0.29248046875), // sin(197) + FX32_CONST(-0.30908203125), // sin(198) + FX32_CONST(-0.32568359375), // sin(199) + FX32_CONST(-0.342041015625), // sin(200) + FX32_CONST(-0.3583984375), // sin(201) + FX32_CONST(-0.37451171875), // sin(202) + FX32_CONST(-0.390625), // sin(203) + FX32_CONST(-0.40673828125), // sin(204) + FX32_CONST(-0.422607421875), // sin(205) + FX32_CONST(-0.4384765625), // sin(206) + FX32_CONST(-0.4541015625), // sin(207) + FX32_CONST(-0.469482421875), // sin(208) + FX32_CONST(-0.48486328125), // sin(209) + FX32_CONST(-0.5), // sin(210) + FX32_CONST(-0.51513671875), // sin(211) + FX32_CONST(-0.530029296875), // sin(212) + FX32_CONST(-0.544677734375), // sin(213) + FX32_CONST(-0.55908203125), // sin(214) + FX32_CONST(-0.573486328125), // sin(215) + FX32_CONST(-0.587890625), // sin(216) + FX32_CONST(-0.601806640625), // sin(217) + FX32_CONST(-0.61572265625), // sin(218) + FX32_CONST(-0.62939453125), // sin(219) + FX32_CONST(-0.642822265625), // sin(220) + FX32_CONST(-0.656005859375), // sin(221) + FX32_CONST(-0.669189453125), // sin(222) + FX32_CONST(-0.681884765625), // sin(223) + FX32_CONST(-0.694580078125), // sin(224) + FX32_CONST(-0.70703125), // sin(225) + FX32_CONST(-0.71923828125), // sin(226) + FX32_CONST(-0.7314453125), // sin(227) + FX32_CONST(-0.7431640625), // sin(228) + FX32_CONST(-0.754638671875), // sin(229) + FX32_CONST(-0.76611328125), // sin(230) + FX32_CONST(-0.777099609375), // sin(231) + FX32_CONST(-0.7880859375), // sin(232) + FX32_CONST(-0.798583984375), // sin(233) + FX32_CONST(-0.80908203125), // sin(234) + FX32_CONST(-0.819091796875), // sin(235) + FX32_CONST(-0.8291015625), // sin(236) + FX32_CONST(-0.838623046875), // sin(237) + FX32_CONST(-0.84814453125), // sin(238) + FX32_CONST(-0.857177734375), // sin(239) + FX32_CONST(-0.865966796875), // sin(240) + FX32_CONST(-0.87451171875), // sin(241) + FX32_CONST(-0.883056640625), // sin(242) + FX32_CONST(-0.89111328125), // sin(243) + FX32_CONST(-0.898681640625), // sin(244) + FX32_CONST(-0.90625), // sin(245) + FX32_CONST(-0.91357421875), // sin(246) + FX32_CONST(-0.92041015625), // sin(247) + FX32_CONST(-0.92724609375), // sin(248) + FX32_CONST(-0.93359375), // sin(249) + FX32_CONST(-0.939697265625), // sin(250) + FX32_CONST(-0.945556640625), // sin(251) + FX32_CONST(-0.951171875), // sin(252) + FX32_CONST(-0.956298828125), // sin(253) + FX32_CONST(-0.961181640625), // sin(254) + FX32_CONST(-0.9658203125), // sin(255) + FX32_CONST(-0.97021484375), // sin(256) + FX32_CONST(-0.974365234375), // sin(257) + FX32_CONST(-0.97802734375), // sin(258) + FX32_CONST(-0.981689453125), // sin(259) + FX32_CONST(-0.98486328125), // sin(260) + FX32_CONST(-0.98779296875), // sin(261) + FX32_CONST(-0.990234375), // sin(262) + FX32_CONST(-0.992431640625), // sin(263) + FX32_CONST(-0.99462890625), // sin(264) + FX32_CONST(-0.99609375), // sin(265) + FX32_CONST(-0.99755859375), // sin(266) + FX32_CONST(-0.99853515625), // sin(267) + FX32_CONST(-0.99951171875), // sin(268) + FX32_CONST(-0.999755859375), // sin(269) + FX32_CONST(-1.0), // sin(270) + FX32_CONST(-0.999755859375), // sin(271) + FX32_CONST(-0.99951171875), // sin(272) + FX32_CONST(-0.99853515625), // sin(273) + FX32_CONST(-0.99755859375), // sin(274) + FX32_CONST(-0.99609375), // sin(275) + FX32_CONST(-0.99462890625), // sin(276) + FX32_CONST(-0.992431640625), // sin(277) + FX32_CONST(-0.990234375), // sin(278) + FX32_CONST(-0.98779296875), // sin(279) + FX32_CONST(-0.98486328125), // sin(280) + FX32_CONST(-0.981689453125), // sin(281) + FX32_CONST(-0.97802734375), // sin(282) + FX32_CONST(-0.974365234375), // sin(283) + FX32_CONST(-0.97021484375), // sin(284) + FX32_CONST(-0.9658203125), // sin(285) + FX32_CONST(-0.961181640625), // sin(286) + FX32_CONST(-0.956298828125), // sin(287) + FX32_CONST(-0.951171875), // sin(288) + FX32_CONST(-0.945556640625), // sin(289) + FX32_CONST(-0.939697265625), // sin(290) + FX32_CONST(-0.93359375), // sin(291) + FX32_CONST(-0.92724609375), // sin(292) + FX32_CONST(-0.92041015625), // sin(293) + FX32_CONST(-0.91357421875), // sin(294) + FX32_CONST(-0.90625), // sin(295) + FX32_CONST(-0.898681640625), // sin(296) + FX32_CONST(-0.89111328125), // sin(297) + FX32_CONST(-0.883056640625), // sin(298) + FX32_CONST(-0.87451171875), // sin(299) + FX32_CONST(-0.865966796875), // sin(300) + FX32_CONST(-0.857177734375), // sin(301) + FX32_CONST(-0.84814453125), // sin(302) + FX32_CONST(-0.838623046875), // sin(303) + FX32_CONST(-0.8291015625), // sin(304) + FX32_CONST(-0.819091796875), // sin(305) + FX32_CONST(-0.80908203125), // sin(306) + FX32_CONST(-0.798583984375), // sin(307) + FX32_CONST(-0.7880859375), // sin(308) + FX32_CONST(-0.777099609375), // sin(309) + FX32_CONST(-0.76611328125), // sin(310) + FX32_CONST(-0.754638671875), // sin(311) + FX32_CONST(-0.7431640625), // sin(312) + FX32_CONST(-0.7314453125), // sin(313) + FX32_CONST(-0.71923828125), // sin(314) + FX32_CONST(-0.70703125), // sin(315) + FX32_CONST(-0.694580078125), // sin(316) + FX32_CONST(-0.681884765625), // sin(317) + FX32_CONST(-0.669189453125), // sin(318) + FX32_CONST(-0.656005859375), // sin(319) + FX32_CONST(-0.642822265625), // sin(320) + FX32_CONST(-0.62939453125), // sin(321) + FX32_CONST(-0.61572265625), // sin(322) + FX32_CONST(-0.601806640625), // sin(323) + FX32_CONST(-0.587890625), // sin(324) + FX32_CONST(-0.573486328125), // sin(325) + FX32_CONST(-0.55908203125), // sin(326) + FX32_CONST(-0.544677734375), // sin(327) + FX32_CONST(-0.530029296875), // sin(328) + FX32_CONST(-0.51513671875), // sin(329) + FX32_CONST(-0.5), // sin(330) + FX32_CONST(-0.48486328125), // sin(331) + FX32_CONST(-0.469482421875), // sin(332) + FX32_CONST(-0.4541015625), // sin(333) + FX32_CONST(-0.4384765625), // sin(334) + FX32_CONST(-0.422607421875), // sin(335) + FX32_CONST(-0.40673828125), // sin(336) + FX32_CONST(-0.390625), // sin(337) + FX32_CONST(-0.37451171875), // sin(338) + FX32_CONST(-0.3583984375), // sin(339) + FX32_CONST(-0.342041015625), // sin(340) + FX32_CONST(-0.32568359375), // sin(341) + FX32_CONST(-0.30908203125), // sin(342) + FX32_CONST(-0.29248046875), // sin(343) + FX32_CONST(-0.275634765625), // sin(344) + FX32_CONST(-0.2587890625), // sin(345) + FX32_CONST(-0.241943359375), // sin(346) + FX32_CONST(-0.224853515625), // sin(347) + FX32_CONST(-0.2080078125), // sin(348) + FX32_CONST(-0.19091796875), // sin(349) + FX32_CONST(-0.173583984375), // sin(350) + FX32_CONST(-0.156494140625), // sin(351) + FX32_CONST(-0.13916015625), // sin(352) + FX32_CONST(-0.121826171875), // sin(353) + FX32_CONST(-0.1044921875), // sin(354) + FX32_CONST(-0.087158203125), // sin(355) + FX32_CONST(-0.06982421875), // sin(356) + FX32_CONST(-0.05224609375), // sin(357) + FX32_CONST(-0.034912109375), // sin(358) + FX32_CONST(-0.017333984375), // sin(359) + FX32_CONST(0.0), // sin(360) + FX32_CONST(0.017333984375), // sin(361) + FX32_CONST(0.034912109375), // sin(362) + FX32_CONST(0.05224609375), // sin(363) + FX32_CONST(0.06982421875), // sin(364) + FX32_CONST(0.087158203125), // sin(365) + FX32_CONST(0.1044921875), // sin(366) + FX32_CONST(0.121826171875), // sin(367) + FX32_CONST(0.13916015625), // sin(368) + FX32_CONST(0.156494140625), // sin(369) + FX32_CONST(0.173583984375), // sin(370) + FX32_CONST(0.19091796875), // sin(371) + FX32_CONST(0.2080078125), // sin(372) + FX32_CONST(0.224853515625), // sin(373) + FX32_CONST(0.241943359375), // sin(374) + FX32_CONST(0.2587890625), // sin(375) + FX32_CONST(0.275634765625), // sin(376) + FX32_CONST(0.29248046875), // sin(377) + FX32_CONST(0.30908203125), // sin(378) + FX32_CONST(0.32568359375), // sin(379) + FX32_CONST(0.342041015625), // sin(380) + FX32_CONST(0.3583984375), // sin(381) + FX32_CONST(0.37451171875), // sin(382) + FX32_CONST(0.390625), // sin(383) + FX32_CONST(0.40673828125), // sin(384) + FX32_CONST(0.422607421875), // sin(385) + FX32_CONST(0.4384765625), // sin(386) + FX32_CONST(0.4541015625), // sin(387) + FX32_CONST(0.469482421875), // sin(388) + FX32_CONST(0.48486328125), // sin(389) + FX32_CONST(0.5), // sin(390) + FX32_CONST(0.51513671875), // sin(391) + FX32_CONST(0.530029296875), // sin(392) + FX32_CONST(0.544677734375), // sin(393) + FX32_CONST(0.55908203125), // sin(394) + FX32_CONST(0.573486328125), // sin(395) + FX32_CONST(0.587890625), // sin(396) + FX32_CONST(0.601806640625), // sin(397) + FX32_CONST(0.61572265625), // sin(398) + FX32_CONST(0.62939453125), // sin(399) + FX32_CONST(0.642822265625), // sin(400) + FX32_CONST(0.656005859375), // sin(401) + FX32_CONST(0.669189453125), // sin(402) + FX32_CONST(0.681884765625), // sin(403) + FX32_CONST(0.694580078125), // sin(404) + FX32_CONST(0.70703125), // sin(405) + FX32_CONST(0.71923828125), // sin(406) + FX32_CONST(0.7314453125), // sin(407) + FX32_CONST(0.7431640625), // sin(408) + FX32_CONST(0.754638671875), // sin(409) + FX32_CONST(0.76611328125), // sin(410) + FX32_CONST(0.777099609375), // sin(411) + FX32_CONST(0.7880859375), // sin(412) + FX32_CONST(0.798583984375), // sin(413) + FX32_CONST(0.80908203125), // sin(414) + FX32_CONST(0.819091796875), // sin(415) + FX32_CONST(0.8291015625), // sin(416) + FX32_CONST(0.838623046875), // sin(417) + FX32_CONST(0.84814453125), // sin(418) + FX32_CONST(0.857177734375), // sin(419) + FX32_CONST(0.865966796875), // sin(420) + FX32_CONST(0.87451171875), // sin(421) + FX32_CONST(0.883056640625), // sin(422) + FX32_CONST(0.89111328125), // sin(423) + FX32_CONST(0.898681640625), // sin(424) + FX32_CONST(0.90625), // sin(425) + FX32_CONST(0.91357421875), // sin(426) + FX32_CONST(0.92041015625), // sin(427) + FX32_CONST(0.92724609375), // sin(428) + FX32_CONST(0.93359375), // sin(429) + FX32_CONST(0.939697265625), // sin(430) + FX32_CONST(0.945556640625), // sin(431) + FX32_CONST(0.951171875), // sin(432) + FX32_CONST(0.956298828125), // sin(433) + FX32_CONST(0.961181640625), // sin(434) + FX32_CONST(0.9658203125), // sin(435) + FX32_CONST(0.97021484375), // sin(436) + FX32_CONST(0.974365234375), // sin(437) + FX32_CONST(0.97802734375), // sin(438) + FX32_CONST(0.981689453125), // sin(439) + FX32_CONST(0.98486328125), // sin(440) + FX32_CONST(0.98779296875), // sin(441) + FX32_CONST(0.990234375), // sin(442) + FX32_CONST(0.992431640625), // sin(443) + FX32_CONST(0.99462890625), // sin(444) + FX32_CONST(0.99609375), // sin(445) + FX32_CONST(0.99755859375), // sin(446) + FX32_CONST(0.99853515625), // sin(447) + FX32_CONST(0.99951171875), // sin(448) + FX32_CONST(0.999755859375), // sin(449) }; -const u16 UNK_020EDC7E[] = // rotations? +static const u16 UNK_020EDC7E[] = // rotations? { 0x0000, 0x00B7, 0x016D, 0x0223, 0x02D9, 0x038F, 0x0445, 0x04FB, 0x05B1, 0x0667, 0x071D, 0x07D3, 0x0889, 0x093F, 0x09F5, 0x0AAB, 0x0B61, 0x0C17, 0x0CCD, 0x0D83, @@ -255,31 +592,41 @@ THUMB_FUNC s32 Sin32(s32 degrees) * Random number generators */ static u32 sMTRNG_State[624]; // Mersenne Twister seed storage/buffer +#ifdef NONMATCHING +// Using -ipa file makes the following hack unnecessary, +// but for some reason forces UNK_020EDC7E to align to +// word rather than short... +static u32 sLCRNG_State; +#define sMTRNG_State_2 sMTRNG_State +#else static union { u32 LC_State; // Linear-congruential seed storage/buffer u32 MTRNG_State[]; // Don't bother asking why Game Freak did this. Just don't. } sRNGHack; +#define sLCRNG_State sRNGHack.LC_State +#define sMTRNG_State_2 (sRNGHack.MTRNG_State + 1) +#endif // Returns the Linear-congruential buffer in full. THUMB_FUNC u32 GetLCRNGSeed() { - return sRNGHack.LC_State; + return sLCRNG_State; } // Initializes the Linear-congruential buffer with a 32-bit seed. THUMB_FUNC void SetLCRNGSeed(u32 seed) { - sRNGHack.LC_State = seed; + sLCRNG_State = seed; } // Calculates an unsigned 16-bit random integer using the Linear-congruential algorithm. THUMB_FUNC u16 LCRandom(void) { // cycle the RNG - sRNGHack.LC_State *= 0x41C64E6D; - sRNGHack.LC_State += 0x6073; - return (u16)(sRNGHack.LC_State / 65536); // shut up the compiler + sLCRNG_State *= 0x41C64E6D; + sLCRNG_State += 0x6073; + return (u16)(sLCRNG_State / 65536); // shut up the compiler } // Returns a cheap, psuedo-random unsigned 32-bit random integer from a seed. @@ -294,7 +641,7 @@ static u32 sMTRNG_XOR[2] = {0, 0x9908b0df}; // Mersenne Twister XOR mask table // Initializes the Mersenne Twister buffer with a 32-bit seed. THUMB_FUNC void SetMTRNGSeed(u32 seed) { - sRNGHack.MTRNG_State[0+1] = seed; + sMTRNG_State_2[0] = seed; for (sMTRNG_Cycles = 1; sMTRNG_Cycles < 624; sMTRNG_Cycles++) sMTRNG_State[sMTRNG_Cycles] = 1812433253 * (sMTRNG_State[sMTRNG_Cycles - 1] ^ (sMTRNG_State[sMTRNG_Cycles - 1] >> 30)) + sMTRNG_Cycles; @@ -310,7 +657,7 @@ THUMB_FUNC u32 MTRandom(void) { if (sMTRNG_Cycles == 625) SetMTRNGSeed(5489); - + for (i = 0; i < 227; i++) { val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff); @@ -321,20 +668,20 @@ THUMB_FUNC u32 MTRandom(void) val = (sMTRNG_State[i] & 0x80000000) | (sMTRNG_State[i + 1] & 0x7fffffff); sMTRNG_State[i] = sMTRNG_State[i + -227] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1]; } - - val = (sRNGHack.MTRNG_State[623+1] & 0x80000000) | (sRNGHack.MTRNG_State[0+1] & 0x7fffffff); - sRNGHack.MTRNG_State[623+1] = sRNGHack.MTRNG_State[396+1] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1]; + + val = (sMTRNG_State_2[623] & 0x80000000) | (sMTRNG_State_2[0] & 0x7fffffff); + sMTRNG_State_2[623] = sMTRNG_State_2[396] ^ (val >> 1) ^ sMTRNG_XOR[val & 0x1]; sMTRNG_Cycles = 0; } - + val = sMTRNG_State[sMTRNG_Cycles++]; // has to be this way in order to match - + val ^= val >> 11; val ^= (val << 7) & 0x9d2c5680; val ^= (val << 15) & 0xefc60000; val ^= val >> 18; - + return val; } diff --git a/arm9/src/overlay_manager.c b/arm9/src/overlay_manager.c index a59e15ac..0a03a87d 100644 --- a/arm9/src/overlay_manager.c +++ b/arm9/src/overlay_manager.c @@ -4,7 +4,7 @@ #include "heap.h" #include "overlay_manager.h" -THUMB_FUNC struct UnkStruct_02006234 * OverlayManager_new(struct Unk21DBE18 * ovly_mgr, int * a1, u32 heap_id) +THUMB_FUNC struct UnkStruct_02006234 * OverlayManager_new(const struct Unk21DBE18 * ovly_mgr, s32 * a1, u32 heap_id) { struct UnkStruct_02006234 * ret = (struct UnkStruct_02006234 *)AllocFromHeap(heap_id, sizeof(struct UnkStruct_02006234)); ret->ovly_mgr = *ovly_mgr; @@ -38,7 +38,7 @@ THUMB_FUNC void OverlayManager_FreeData(struct UnkStruct_02006234 * a0) a0->unk1C = NULL; } -THUMB_FUNC int * OverlayManager_GetField18(struct UnkStruct_02006234 * a0) +THUMB_FUNC s32 * OverlayManager_GetField18(struct UnkStruct_02006234 * a0) { return a0->unk18; } diff --git a/arm9/src/pokedex.c b/arm9/src/pokedex.c index bd1ea254..d86afa6a 100644 --- a/arm9/src/pokedex.c +++ b/arm9/src/pokedex.c @@ -226,12 +226,11 @@ void Pokedex_InitSeenDeoxysFormesArray(struct Pokedex * pokedex) static inline BOOL HasUnownLetterBeenSeen(struct Pokedex * pokedex, u8 letter) { - u8 * arr; s32 i; + u8 * arr; for (i = 0, arr = (u8 *)pokedex; i < 28; i++, arr++) { - u8 val = arr[0x010C]; - if (letter == val) + if (letter == *(arr + 0x10C)) return TRUE; } return FALSE; @@ -239,12 +238,11 @@ static inline BOOL HasUnownLetterBeenSeen(struct Pokedex * pokedex, u8 letter) static inline s32 FindFirstAvailableUnownLetterSlot(struct Pokedex * pokedex) { - u8 * arr; s32 i; + u8 * arr; for (i = 0, arr = (u8 *)pokedex; i < 28; i++, arr++) { - u8 val = arr[0x010C]; - if (val == 0xFF) + if (*(arr + 0x10C) == 0xFF) break; } return i; @@ -320,26 +318,26 @@ s32 FUN_020242C8(struct Pokedex * pokedex, u16 species, s32 r4) return r1; } -const u16 sSinnohDexMythicalMons[] = { - SPECIES_MANAPHY -}; - -const u16 sNationalDexMythicalMons[] = { - SPECIES_MEW, - SPECIES_LUGIA, - SPECIES_HO_OH, - SPECIES_CELEBI, - SPECIES_JIRACHI, - SPECIES_DEOXYS, - SPECIES_PHIONE, - SPECIES_MANAPHY, - SPECIES_DARKRAI, - SPECIES_SHAYMIN, - SPECIES_ARCEUS -}; - BOOL Pokedex_SpeciesIsNotMythical(u16 species) { + static const u16 sSinnohDexMythicalMons[] = { + SPECIES_MANAPHY + }; + + static const u16 sNationalDexMythicalMons[] = { + SPECIES_MEW, + SPECIES_LUGIA, + SPECIES_HO_OH, + SPECIES_CELEBI, + SPECIES_JIRACHI, + SPECIES_DEOXYS, + SPECIES_PHIONE, + SPECIES_MANAPHY, + SPECIES_DARKRAI, + SPECIES_SHAYMIN, + SPECIES_ARCEUS + }; + s32 i; BOOL ret = TRUE; for (i = 0; i < (s32)NELEMS(sNationalDexMythicalMons); i++) diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index 4ad17e51..fb88da54 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -55,6 +55,10 @@ extern void MOD05_021E26CC(u32 param0, u8 param1); extern void MOD05_021E2B80(u32 param0, u8 param1); extern void MOD05_021E2B9C(u32 param0, u8 param1); +extern u32 FUN_0203B120(struct UnkSavStruct80 *arg, u16 param1); +extern u32 FUN_0205AEA4(u32 param0, const u8 *ptr); +extern void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, u32 param2); + extern u8 *UNK_020F34E0; static BOOL RunPauseTimer(struct ScriptContext *ctx); @@ -1298,3 +1302,19 @@ THUMB_FUNC BOOL ScrCmd_Unk02D0(struct ScriptContext *ctx) MOD05_021E2B9C(*unk, ScriptReadByte(ctx)); return TRUE; } + +THUMB_FUNC BOOL ScrCmd_Unk005E(struct ScriptContext *ctx) +{ + u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u32 unk2 = ScriptReadWord(ctx); + + u32 unk3 = FUN_0203B120(ctx->unk80, unk); + GF_ASSERT(unk3); + + u32 unk4 = FUN_0205AEA4(unk3, ctx->scriptPtr + unk2); + u8 *unk5 = FUN_02039438(ctx->unk80, 4); + (*unk5)++; + + FUN_0203B174(ctx->unk80, unk4, 0); + return FALSE; +} diff --git a/arm9/src/scrcmd_24.c b/arm9/src/scrcmd_24.c new file mode 100644 index 00000000..d3f955d0 --- /dev/null +++ b/arm9/src/scrcmd_24.c @@ -0,0 +1,276 @@ +#include "scrcmd.h" +#include "heap.h" +#include "party.h" +#include "unk_020377F0.h" +#include "unk_02088DD8.h" + +extern void* FUN_02039438(struct UnkSavStruct80*, int idx); + +extern struct UnkStruct_02037CF0* FUN_02037CF0(u32 heap_id, struct UnkSavStruct80*, u8); +extern u8 FUN_02037D5C(struct UnkStruct_02037CF0*); +extern void FUN_02038864(struct UnkSavStruct80*, struct UnkStruct_02088DD8*); +extern BOOL FUN_0203BC04(struct ScriptContext* ctx); +extern struct UnkStruct_02088DD8* FUN_02088DD8(u32 heap_id); +extern void FUN_02088DF0(struct UnkStruct_02037CF0*); +extern void* FUN_02088DF8(struct Pokemon* pokemon, u32 heap_id); +extern BOOL FUN_02088EF8(void*); + +THUMB_FUNC BOOL ScrCmd_Unk01C6(struct ScriptContext* ctx) +{ + u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + struct UnkStruct_02037CF0** unk_ret_ptr = FUN_02039438(ctx->unk80, 19); + *unk_ret_ptr = FUN_02037CF0(32, ctx->unk80, (u8)unk); + + SetupNativeScript(ctx, FUN_0203BC04); + return TRUE; +} + +#ifdef NONMATCHING +THUMB_FUNC BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct UnkStruct_02037CF0** unk_ptr = FUN_02039438(ctx->unk80, 19); + GF_ASSERT(*unk_ptr != NULL); + + *ret_ptr = FUN_02037D5C(*unk_ptr); + if (*ret_ptr == 4) + { + *ret_ptr = 0xFF; + } + + FreeToHeap(*unk_ptr); + *unk_ptr = NULL; + return FALSE; +} +#else +THUMB_FUNC asm BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx) +{ + push {r3-r5, lr} + add r4, r0, #0x0 + bl ScriptReadHalfword + add r1, r0, #0x0 + add r0, r4, #0x0 + add r0, #0x80 + ldr r0, [r0, #0x0] + bl GetVarPointer + add r4, #0x80 + add r5, r0, #0x0 + ldr r0, [r4, #0x0] + mov r1, #0x13 + bl FUN_02039438 + add r4, r0, #0x0 + ldr r0, [r4, #0x0] + cmp r0, #0x0 + bne _02045DFC + bl ErrorHandling +_02045DFC: + ldr r0, [r4, #0x0] + bl FUN_02037D5C + strh r0, [r5, #0x0] + ldrh r0, [r5, #0x0] + cmp r0, #0x4 + bne _02045E0E + mov r0, #0xff + strh r0, [r5, #0x0] +_02045E0E: + ldr r0, [r4, #0x0] + bl FreeToHeap + mov r0, #0x0 + str r0, [r4, #0x0] + pop {r3-r5, pc} +} +#endif + +THUMB_FUNC BOOL ScrCmd_Unk021E(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk021F(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2); + struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx); + void* unk_ptr = FUN_02088DF8(pokemon, 32); + + *ret_ptr = (u16)FUN_02088EF8(unk_ptr); + FreeToHeap(unk_ptr); + + return FALSE; +} + +THUMB_FUNC void FUN_02045E74(struct ScriptContext* ctx, u8 a1, struct Pokemon* pokemon, void* a3) +{ + struct UnkStruct_02088DD8** unk = FUN_02039438(ctx->unk80, 19); + struct UnkStruct_02088DD8* unk2 = FUN_02088DD8(32); + *unk = unk2; + + unk2->pokemon = pokemon; + + struct SaveBlock2* sav2 = ScriptEnvironment_GetSav2Ptr(ctx->unk80); + unk2->player = Sav2_PlayerData_GetProfileAddr(sav2); + + unk2->options = Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2); + unk2->unkC = a3; + unk2->unk15 = a1; + FUN_02038864(ctx->unk80, unk2); + + SetupNativeScript(ctx, FUN_0203BC04); + FreeToHeap(a3); +} + +THUMB_FUNC BOOL ScrCmd_Unk0220(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0221(struct ScriptContext* ctx) +{ + u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2); + struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx); + void* unk_ptr = FUN_02088DF8(pokemon, 32); + + FUN_02045E74(ctx, 1, pokemon, unk_ptr); + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0224(struct ScriptContext* ctx) +{ + u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2); + struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx); + + u16* unk_array = AllocFromHeap(32, 2 * sizeof(u16)); + unk_array[0] = unk2; + unk_array[1] = 0xFFFF; + + FUN_02045E74(ctx, 0, pokemon, unk_array); + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0222(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + return FALSE; +} + +#ifdef NONMATCHING +THUMB_FUNC BOOL ScrCmd_Unk0223(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct UnkStruct_02037CF0** unk = FUN_02039438(ctx->unk80, 19); + struct UnkStruct_02037CF0* unk_sub = *unk; + + GF_ASSERT(unk_sub != NULL); + + if (unk_sub->unk16 == 0) + { + *ret_ptr = 0; + } + else + { + *ret_ptr = 0xFF; + } + + FUN_02088DF0(unk_sub); + return FALSE; +} +#else +THUMB_FUNC asm BOOL ScrCmd_Unk0223(struct ScriptContext* ctx) +{ + push {r3-r5, lr} + add r4, r0, #0x0 + bl ScriptReadHalfword + add r1, r0, #0x0 + add r0, r4, #0x0 + add r0, #0x80 + ldr r0, [r0, #0x0] + bl GetVarPointer + add r4, #0x80 + add r5, r0, #0x0 + ldr r0, [r4, #0x0] + mov r1, #0x13 + bl FUN_02039438 + ldr r4, [r0, #0x0] + cmp r4, #0x0 + bne _02045FB2 + bl ErrorHandling +_02045FB2: + ldrb r0, [r4, #0x16] + cmp r0, #0x0 + bne _02045FBC + mov r0, #0x0 + b _02045FBE +_02045FBC: + mov r0, #0xff +_02045FBE: + strh r0, [r5, #0x0] + add r0, r4, #0x0 + bl FUN_02088DF0 + mov r0, #0x0 + pop {r3-r5, pc} +} +#endif + +#ifdef NONMATCHING +THUMB_FUNC BOOL ScrCmd_Unk0225(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct UnkStruct_02037CF0** unk = FUN_02039438(ctx->unk80, 19); + struct UnkStruct_02037CF0* unk_sub = *unk; + + GF_ASSERT(unk_sub != NULL); + + if (unk_sub->unk16 == 0) + { + *ret_ptr = 0; + } + else + { + *ret_ptr = 0xFF; + } + + FUN_02088DF0(unk_sub); + return FALSE; +} +#else +THUMB_FUNC asm BOOL ScrCmd_Unk0225(struct ScriptContext* ctx) +{ + push {r3-r5, lr} + add r4, r0, #0x0 + bl ScriptReadHalfword + add r1, r0, #0x0 + add r0, r4, #0x0 + add r0, #0x80 + ldr r0, [r0, #0x0] + bl GetVarPointer + add r4, #0x80 + add r5, r0, #0x0 + ldr r0, [r4, #0x0] + mov r1, #0x13 + bl FUN_02039438 + ldr r4, [r0, #0x0] + cmp r4, #0x0 + bne _02045FB2 + bl ErrorHandling +_02045FB2: + ldrb r0, [r4, #0x16] + cmp r0, #0x0 + bne _02045FBC + mov r0, #0x0 + b _02045FBE +_02045FBC: + mov r0, #0xff +_02045FBE: + strh r0, [r5, #0x0] + add r0, r4, #0x0 + bl FUN_02088DF0 + mov r0, #0x0 + pop {r3-r5, pc} +} +#endif diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c new file mode 100644 index 00000000..5acaae1e --- /dev/null +++ b/arm9/src/scrcmd_sound.c @@ -0,0 +1,266 @@ +#include "scrcmd.h" + +extern void* FUN_02029EF8(struct SaveBlock2* sav2); +extern u32 FUN_02005D20(void *); +extern void FUN_02005E6C(void *); +extern void FUN_0200433C(u32, u32, u32); +extern u32 FUN_02005E28(void); +extern void FUN_02005E64(void); +extern BOOL FUN_02005CBC(void); +extern void PlayBGM(u16); +extern u32 FUN_02004124(u16); +extern void FUN_0204AB20(struct UnkSavStruct80 *ctx, u16); +extern u16 FUN_0204ABA8(struct UnkSavStruct80 *ctx, u32); +extern void FUN_0200521C(u16); +extern void FUN_02005308(u32, u16); +extern void FUN_02005350(u32, u32); +extern void FUN_0200538C(u32, u16, u32); +extern void FUN_020053CC(u16, u16); +extern BOOL FUN_02005404(void); +extern u16 FUN_02005410(u16); +extern void FUN_020054C8(u16); +extern void FUN_020054F0(u16, u32); +extern void FUN_020047C8(u8, u8); +extern void FUN_020040F4(u8); +extern BOOL FUN_02005508(u16); +extern void FUN_02005578(u16); +extern BOOL FUN_02005670(void); +extern void FUN_0200488C(u16, u16); + + +THUMB_FUNC BOOL ScrCmd_Unk02AE(struct ScriptContext *ctx) +{ + u16 unk0 = ScriptReadHalfword(ctx); + u16 *unk1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + + *unk1 = FUN_02005410(unk0); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0050(struct ScriptContext *ctx) +{ + FUN_0200521C(ScriptReadHalfword(ctx)); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0051(struct ScriptContext *ctx) +{ + u32 unk0 = FUN_02004124(ScriptReadHalfword(ctx)); + FUN_02005350(unk0, 0); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0052(struct ScriptContext *ctx) +{ + u16 unk0 = FUN_0204ABA8(ctx->unk80, *ctx->unk80->mapId); + FUN_0200521C(unk0); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0053(struct ScriptContext *ctx) +{ + FUN_0204AB20(ctx->unk80, ScriptReadHalfword(ctx)); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0054(struct ScriptContext *ctx) +{ + u16 unk1 = ScriptReadHalfword(ctx); + u16 unk2 = ScriptReadHalfword(ctx); + + FUN_020053CC(unk1, unk2); + SetupNativeScript(ctx, FUN_02041464); + + return TRUE; +} + +THUMB_FUNC BOOL FUN_02041464(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + + if(!FUN_02005404()) + return TRUE; + else + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0055(struct ScriptContext* ctx) +{ + u16 unk = ScriptReadHalfword(ctx); + + FUN_0200538C(0x7F, unk, 0); + SetupNativeScript(ctx, FUN_02041464); + + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0056(struct ScriptContext* ctx) +{ + + u8 PtrIndx0 = ScriptReadByte(ctx); + + u8 PtrIndx1 = ScriptReadByte(ctx); + + FUN_020047C8(PtrIndx0, PtrIndx1); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0057(struct ScriptContext* ctx) +{ + FUN_02005308(4, ScriptReadHalfword(ctx)); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0058(struct ScriptContext* ctx) +{ + u8 PtrIndx0 = ScriptReadByte(ctx); + FUN_020040F4(PtrIndx0); + return FALSE; +} + + +THUMB_FUNC BOOL ScrCmd_Unk0049(struct ScriptContext* ctx) +{ + u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + FUN_020054C8(unk); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk004A(struct ScriptContext* ctx) +{ + u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + FUN_020054F0(unk, 0); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk004B(struct ScriptContext* ctx) +{ + u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + + ctx->data[0] = unk; + SetupNativeScript(ctx, FUN_02041540); + + return TRUE; +} + +THUMB_FUNC BOOL FUN_02041540(struct ScriptContext* ctx) +{ + if(!FUN_02005508((u16)ctx->data[0])) + return TRUE; + else + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk004C(struct ScriptContext* ctx) +{ + u16 unk0 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 unused = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + FUN_02005578(unk0); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_PlayCryWait(struct ScriptContext* ctx) +{ + SetupNativeScript(ctx, FUN_02041598); + return TRUE; +} + +THUMB_FUNC BOOL FUN_02041598(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + + if(!FUN_02005670()) + return TRUE; + else + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_PlayBgm(struct ScriptContext* ctx) +{ + u16 bgm_id = ScriptReadHalfword(ctx); + PlayBGM(bgm_id); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk004F(struct ScriptContext* ctx) +{ + SetupNativeScript(ctx, FUN_020415CC); + return TRUE; +} + +THUMB_FUNC BOOL FUN_020415CC(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + if (!FUN_02005CBC()) + return TRUE; + else + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0059(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + + void* unk = FUN_02029EF8(ctx->unk80->saveBlock2); + if (FUN_02005D20(unk) == 1) + { + *ret_ptr = 1; + return FALSE; + } + else + { + *ret_ptr = 0; + return FALSE; + } +} + +THUMB_FUNC BOOL ScrCmd_Unk005A(struct ScriptContext* ctx) +{ + u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + + if (FUN_02005E28() == 0) + { + *ret_ptr = 1; + return FALSE; + } + else + { + *ret_ptr = 0; + return FALSE; + } +} + +THUMB_FUNC BOOL ScrCmd_Unk005B(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + FUN_02005E64(); + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk005C(struct ScriptContext* ctx) +{ + void* unk = FUN_02029EF8(ctx->unk80->saveBlock2); + FUN_02005E6C(unk); + + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk005D(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + FUN_0200433C(0x3F, 0, 0); + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0283(struct ScriptContext* ctx) +{ + u16 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + + FUN_0200488C(unk1, unk2); + + return FALSE; +} + diff --git a/arm9/src/text.c b/arm9/src/text.c index aadb84c0..3034baab 100644 --- a/arm9/src/text.c +++ b/arm9/src/text.c @@ -7,7 +7,10 @@ const struct FontInfo *gFonts = NULL; u16 UNK_021C5734[0x100]; u32 UNK_021C5714[8]; -u8 UNK_021C570C[8]; +u16 UNK_021C570E; +u16 UNK_021C5710; +u16 UNK_021C5712; +u8 UNK_021C570C; extern u32 FUN_0200CA7C(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2); @@ -187,7 +190,7 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s printer->printerTemplate = *printerTemplate; printer->printerTemplate.currentChar = String_c_str((struct String *)printer->printerTemplate.currentChar); //TODO clean up printer->callback = callback; - UNK_021C570C[0] = 0; + UNK_021C570C = 0; FUN_0201C1A8(printer); if (speed != 0xff && speed != 0) { @@ -222,7 +225,7 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s THUMB_FUNC void RunTextPrinter(u32 param0, struct TextPrinter *printer) { #pragma unused(param0) - if (UNK_021C570C[0] == 0) + if (UNK_021C570C == 0) { if (printer->Unk29 == 0) { @@ -268,156 +271,39 @@ THUMB_FUNC u32 RenderFont(struct TextPrinter *printer) } } -#ifdef NONMATCHING THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) { - u32 fg12, bg12, shadow12; - u32 temp; - - u16 *current = UNK_021C570C; - - bg12 = bgColor << 12; - fg12 = fgColor << 12; - shadow12 = shadowColor << 12; - - temp = (bgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; + s32 r5 = 0; + u32 sp20[4]; + s32 i; // sp14 + s32 j; // sp10 + s32 k; // spC + s32 l; // r3 + + sp20[0] = 0; + sp20[1] = fgColor; + sp20[2] = shadowColor; + sp20[3] = bgColor; + + // FIXME: Need these to be accessed by a pointer to UNK_021C570C + UNK_021C5712 = bgColor; + UNK_021C570E = fgColor; + UNK_021C5710 = shadowColor; + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + for (k = 0; k < 4; k++) + { + for (l = 0; l < 4; l++) + { + UNK_021C5734[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0)); + } + } + } + } } -#else -GLOBAL_ASM("asm/nonmatchings/GenerateFontHalfRowLookupTable.s") -#endif THUMB_FUNC void DecompressGlyphTile(const u16 *src, u16 *dst) { diff --git a/arm9/src/unk_02015E30.c b/arm9/src/unk_02015E30.c index 8be466fb..2f7b5bb5 100644 --- a/arm9/src/unk_02015E30.c +++ b/arm9/src/unk_02015E30.c @@ -1,35 +1,37 @@ #include "unk_02015E30.h" -struct UnkStruct_02015E30 UNK_021C4898; +u64 UNK_021C48B0; +u64 UNK_021C48A8; +u64 UNK_021C48A0; +struct IGT * UNK_021C489C; +u32 UNK_021C4898; THUMB_FUNC void FUN_02015E30() { - UNK_021C4898.unk00 = 0; + UNK_021C4898 = 0; } THUMB_FUNC void FUN_02015E3C(struct IGT *igt) { - struct UnkStruct_02015E30 *unk1 = &UNK_021C4898; - UNK_021C4898.unk00 = 1; - UNK_021C4898.unk10 = 0; - UNK_021C4898.unk14 = 0; - UNK_021C4898.unk08 = 0; - UNK_021C4898.unk04 = igt; + UNK_021C4898 = 1; + UNK_021C48A8 = 0; + UNK_021C48A0 = 0; + UNK_021C489C = igt; - UNK_021C4898.unk18 = GetTimer3Count(); + UNK_021C48B0 = GetTimer3Count(); } THUMB_FUNC void FUN_02015E60() { - if (UNK_021C4898.unk00 != 0) + if (UNK_021C4898 != 0) { - u64 res = Timer3CountToSeconds(GetTimer3Count() - UNK_021C4898.unk18); + u64 res = Timer3CountToSeconds(GetTimer3Count() - UNK_021C48B0); - if (UNK_021C4898.unk08 < res) + if (UNK_021C48A0 < res) { - AddIGTSeconds(UNK_021C4898.unk04, (u32)(res - UNK_021C4898.unk08)); - UNK_021C4898.unk08 = res; + AddIGTSeconds(UNK_021C489C, (u32)(res - UNK_021C48A0)); + UNK_021C48A0 = res; } } } diff --git a/arm9/src/unk_02021934.c b/arm9/src/unk_02021934.c index cd66a136..ebc600fa 100644 --- a/arm9/src/unk_02021934.c +++ b/arm9/src/unk_02021934.c @@ -109,31 +109,31 @@ struct String * StringDup(struct String * src, u32 heap_id) return dest; } -static const u16 sCharset_JP[10] = { - 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, - 0xA7, 0xA8, 0xA9, 0xAA, 0xAB -}; - -static const u16 sCharset_EN[10] = { - 0x121, 0x122, 0x123, 0x124, 0x125, - 0x126, 0x127, 0x128, 0x129, 0x12A -}; - -static const u32 sPowersOfTen[10] = { - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000 -}; - void String16_FormatInteger(struct String * str, int num, u32 ndigits, int strConvMode, BOOL whichCharset) { + static const u16 sCharset_EN[10] = { + 0x121, 0x122, 0x123, 0x124, 0x125, + 0x126, 0x127, 0x128, 0x129, 0x12A + }; + + static const u16 sCharset_JP[10] = { + 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + 0xA7, 0xA8, 0xA9, 0xAA, 0xAB + }; + + static const u32 sPowersOfTen[10] = { + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000 + }; + ASSERT_STR16(str); const u16 * charbase; diff --git a/arm9/src/unk_02022504.c b/arm9/src/unk_02022504.c new file mode 100644 index 00000000..0267a87c --- /dev/null +++ b/arm9/src/unk_02022504.c @@ -0,0 +1,32 @@ +#include "global.h" +#include "unk_02022504.h" + +THUMB_FUNC void *FUN_02022504(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 27); +} + +THUMB_FUNC struct PCStorage *GetStoragePCPointer(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 35); +} + +THUMB_FUNC void *FUN_0202251C(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 31); +} + +THUMB_FUNC void *FUN_02022528(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 32); +} + +THUMB_FUNC u8 *LoadHallOfFame(struct SaveBlock2 *sav2, u32 heap_id, int *ret_p) +{ + return ReadSaveFileFromFlash(sav2, heap_id, 0, ret_p); +} + +THUMB_FUNC s32 *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data) +{ + return WriteSaveFileToFlash(sav2, 0, data); +} diff --git a/arm9/src/unk_0202E29C.c b/arm9/src/unk_0202E29C.c index 36c18b16..5f99ca8f 100644 --- a/arm9/src/unk_0202E29C.c +++ b/arm9/src/unk_0202E29C.c @@ -247,21 +247,20 @@ THUMB_FUNC void FUN_0202E538() THUMB_FUNC void FUN_0202E56C(u32 param0) { - UNK_021C59E8.unk8->unkDAD = - (UNK_021C59E8.unk8->unkDAD & ~8 | (u32)((u8)param0 << 0x1f) >> 0x1c); + UNK_021C59E8.unk8->unkDAD_3 = (u8)param0; } THUMB_FUNC void FUN_0202E594() { UNK_021C59E8.unk8->unkCB4 = 0; - UNK_021C59E8.unk8->unkDAD &= ~1; + UNK_021C59E8.unk8->unkDAD_0 = 0; - UNK_021C59E8.unk8->unkDAD &= ~4; + UNK_021C59E8.unk8->unkDAD_2 = 0; UNK_021C59E8.unk8->unkDAA = 0; - UNK_021C59E8.unk8->unkDAD &= ~0x10; + UNK_021C59E8.unk8->unkDAD_4 = 0; UNK_021C59E8.unk8->unkDAC = 0; @@ -281,8 +280,7 @@ THUMB_FUNC BOOL FUN_0202E5F8(u32 param0, u32 param1, u32 param2) UNK_021C59E8.unk8->unkDAB = 1; } - UNK_021C59E8.unk8->unkDAD = - (UNK_021C59E8.unk8->unkDAD & ~0x20 | (u32)((u8)param2 << 0x1f) >> 0x1a); + UNK_021C59E8.unk8->unkDAD_5 = (u8)param2; if (FUN_0202CBD4() == 1 && FUN_0202CBFC() != 0) { return TRUE; @@ -659,10 +657,9 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) FUN_0202DF54(); FUN_0202EB7C(); - if (FUN_0202D19C() == 0 && FUN_0202EE24() == 0 && - ((u32)(UNK_021C59E8.unk8->unkDAD << 0x1d) >> 0x1f) != 0) + if (FUN_0202D19C() == 0 && FUN_0202EE24() == 0 && UNK_021C59E8.unk8->unkDAD_2) { - UNK_021C59E8.unk8->unkDAD = (UNK_021C59E8.unk8->unkDAD & ~1) | 1; + UNK_021C59E8.unk8->unkDAD_0 = 1; } if (UNK_021C59E8.unk8->unkDA6 == 0xFFFF) @@ -670,10 +667,10 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) UNK_021C59E8.unk8->unkDA6 = param0; } - if (((u32)(UNK_021C59E8.unk8->unkDAD << 0x1e) >> 0x1f) != 0 && + if (UNK_021C59E8.unk8->unkDAD_1 && UNK_021C59E8.unk8->unkDA6 > param0) { - UNK_021C59E8.unk8->unkDAD = (UNK_021C59E8.unk8->unkDAD & ~1) | 1; + UNK_021C59E8.unk8->unkDAD_0 = 1; } if (FUN_0202CBE8() == 25) @@ -713,7 +710,7 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) if (UNK_021C59E8.unk8 != NULL) { - UNK_021C59E8.unk8->unkDAD = (UNK_021C59E8.unk8->unkDAD & ~1) | 1; + UNK_021C59E8.unk8->unkDAD_0 = 1; return; } break; @@ -731,7 +728,7 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) } u16 r5 = UNK_021C59E8.unk8->unkDA4; - if ((u32)(UNK_021C59E8.unk8->unkDAD << 0x1c) >> 0x1f != 0) + if (UNK_021C59E8.unk8->unkDAD_3) { UNK_021C59E8.unk0++; } @@ -743,7 +740,7 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) r5, FUN_0202D858((u16)FUN_02033534()), FUN_0202EEE8((u16)FUN_02033534()), - (u32)(UNK_021C59E8.unk8->unkDAD << 0x1a) >> 0x1f); + UNK_021C59E8.unk8->unkDAD_5); UNK_021C59E8.unk8->unkDA8 = (u8)r5; @@ -848,7 +845,7 @@ THUMB_FUNC BOOL FUN_0202EE44() THUMB_FUNC BOOL FUN_0202EE60() { - if (UNK_021C59E8.unk8 != NULL && (u32)(UNK_021C59E8.unk8->unkDAD << 0x1f) >> 0x1f != 0) + if (UNK_021C59E8.unk8 != NULL && UNK_021C59E8.unk8->unkDAD_0) { return TRUE; } @@ -860,8 +857,7 @@ THUMB_FUNC void FUN_0202EE84(u32 param0) { if (UNK_021C59E8.unk8 != NULL) { - UNK_021C59E8.unk8->unkDAD = - (UNK_021C59E8.unk8->unkDAD & ~4) | (u32)((u8)param0 << 0x1f) >> 0x1d; + UNK_021C59E8.unk8->unkDAD_2 = (u8)param0; } } @@ -869,8 +865,7 @@ THUMB_FUNC void FUN_0202EEB0(u32 param0) { if (UNK_021C59E8.unk8 != NULL) { - UNK_021C59E8.unk8->unkDAD = - (UNK_021C59E8.unk8->unkDAD & ~2) | (u32)((u8)param0 << 0x1f) >> 0x1e; + UNK_021C59E8.unk8->unkDAD_1 = (u8)param0; UNK_021C59E8.unk8->unkDA6 = 0xFFFF; } @@ -1038,7 +1033,7 @@ THUMB_FUNC u32 FUN_0202F03C() { if (UNK_021C59E8.unk8 != NULL) { - return (u32)(UNK_021C59E8.unk8->unkDAD << 0x1b) >> 0x1f; + return UNK_021C59E8.unk8->unkDAD_4; } return 0; @@ -1048,7 +1043,7 @@ THUMB_FUNC void FUN_0202F05C() { if (UNK_021C59E8.unk8 != NULL) { - UNK_021C59E8.unk8->unkDAD |= 0x10; + UNK_021C59E8.unk8->unkDAD_4 = 1; } } diff --git a/arm9/src/unk_0202F150.c b/arm9/src/unk_0202F150.c index d52857c1..1586dae5 100644 --- a/arm9/src/unk_0202F150.c +++ b/arm9/src/unk_0202F150.c @@ -10,8 +10,8 @@ struct struct UnkStruct0202F150 *unk04; } UNK_021C59F4; -vu8 UNK_02105D58 = 4; vu8 UNK_02105D59 = 4; +vu8 UNK_02105D58 = 4; extern void FUN_0202D7D8(u8 *param0, u32 param1, struct UnkStruct0202F150_sub1 *param2); extern u32 FUN_0200CA60(void (*param0)(), u32 param1, u32 param2); @@ -336,9 +336,9 @@ THUMB_FUNC void FUN_0202F910(int param0) FUN_0202F820(param0); } -THUMB_FUNC u32 FUN_0202F918(u32 param0, u32 param1, u32 param2, u32 param3) +THUMB_FUNC BOOL FUN_0202F918(u32 param0, u32 param1, u32 param2, u32 param3) { - u32 ret = 1; + BOOL ret = TRUE; if (FUN_02033534() < 0x13) { ret = FUN_0202E5F8(param0, param1, param3); diff --git a/arm9/src/unk_02031734.c b/arm9/src/unk_02031734.c index 65ed3bc4..57764b82 100644 --- a/arm9/src/unk_02031734.c +++ b/arm9/src/unk_02031734.c @@ -18,12 +18,10 @@ const struct UnkStruct_02031734_const1 UNK_020EEC5C = { { (u32)FUN_02032234, (u32)FUN_0203234C, 0 } }; +char UNK_02105D64[] = " FULL"; char UNK_02105D5C[] = "FREAK"; - char UNK_02105D6C[] = " GAME"; -char UNK_02105D64[] = " FULL"; - struct UnkStruct_02031734 *UNK_021C5A00; extern void FUN_0202D8D0(u32 param0, u32 param1, u32 param2); diff --git a/files/poketool/icongra/poke_icon/.gitignore b/files/poketool/icongra/poke_icon/.gitignore index 8f4afa7f..fccab7c8 100644 --- a/files/poketool/icongra/poke_icon/.gitignore +++ b/files/poketool/icongra/poke_icon/.gitignore @@ -1,6 +1,5 @@ narc_0000.NCLR -narc_0002.NCER -narc_0004.NCER +*.NCER narc_0007.NCGR narc_0008.NCGR narc_0009.NCGR @@ -11,4 +10,24 @@ narc_0013.NCGR narc_0014.NCGR narc_0015.NCGR narc_0016.NCGR +narc_0017.NCGR +narc_0018.NCGR +narc_0019.NCGR +narc_0020.NCGR +narc_0021.NCGR +narc_0022.NCGR +narc_0023.NCGR +narc_0024.NCGR +narc_0025.NCGR +narc_0026.NCGR +narc_0027.NCGR +narc_0028.NCGR +narc_0029.NCGR +narc_0030.NCGR +narc_0031.NCGR +narc_0032.NCGR +narc_0033.NCGR +narc_0034.NCGR +narc_0035.NCGR +narc_0036.NCGR narc_0402.NCGR diff --git a/files/poketool/icongra/poke_icon/narc_0002.json b/files/poketool/icongra/poke_icon/narc_0002.json index defb5b41..1750fa55 100644 --- a/files/poketool/icongra/poke_icon/narc_0002.json +++ b/files/poketool/icongra/poke_icon/narc_0002.json @@ -4,6 +4,7 @@ "imageHeight": 32, "imageWidth": 32, "cellCount": 2, + "mappingType": 0, "cells": [ { "readOnly": 2054, diff --git a/files/poketool/icongra/poke_icon/narc_0004.json b/files/poketool/icongra/poke_icon/narc_0004.json index 3d8b8b80..b8cae63a 100644 --- a/files/poketool/icongra/poke_icon/narc_0004.json +++ b/files/poketool/icongra/poke_icon/narc_0004.json @@ -4,6 +4,7 @@ "imageHeight": 32, "imageWidth": 32, "cellCount": 2, + "mappingType": 0, "cells": [ { "readOnly": 2054, diff --git a/files/poketool/icongra/poke_icon/narc_0006.NCER b/files/poketool/icongra/poke_icon/narc_0006.NCER Binary files differdeleted file mode 100644 index 19e6e054..00000000 --- a/files/poketool/icongra/poke_icon/narc_0006.NCER +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0006.json b/files/poketool/icongra/poke_icon/narc_0006.json new file mode 100644 index 00000000..ce7f1d83 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0006.json @@ -0,0 +1,68 @@ +{ + "labelEnabled": true, + "extended": true, + "imageHeight": 32, + "imageWidth": 32, + "cellCount": 2, + "mappingType": 1, + "cells": [ + { + "readOnly": 2054, + "maxX": 15, + "maxY": 15, + "minX": 65520, + "minY": 65520, + "OAM": { + "Attr0": { + "YCoordinate": 240, + "Rotation": false, + "SizeDisable": false, + "Mode": 0, + "Mosaic": false, + "Colours": 16, + "Shape": 0 + }, + "Attr1": { + "XCoordinate": 496, + "RotationScaling": 0, + "Size": 2 + }, + "Attr2": { + "CharName": 0, + "Priority": 0, + "Palette": 0 + } + } + }, + { + "readOnly": 2054, + "maxX": 15, + "maxY": 15, + "minX": 65520, + "minY": 65520, + "OAM": { + "Attr0": { + "YCoordinate": 240, + "Rotation": false, + "SizeDisable": false, + "Mode": 0, + "Mosaic": false, + "Colours": 16, + "Shape": 0 + }, + "Attr1": { + "XCoordinate": 496, + "RotationScaling": 0, + "Size": 2 + }, + "Attr2": { + "CharName": 8, + "Priority": 0, + "Palette": 0 + } + } + } + ], + "labels": ["CellAnime0", "CellAnime1", "CellAnime2", "CellAnime3", "CellAnime4", "CellAnime5"], + "labelCount": 6 +} diff --git a/files/poketool/icongra/poke_icon/narc_0017.NCGR b/files/poketool/icongra/poke_icon/narc_0017.NCGR Binary files differdeleted file mode 100644 index 8676315a..00000000 --- a/files/poketool/icongra/poke_icon/narc_0017.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0017.png b/files/poketool/icongra/poke_icon/narc_0017.png Binary files differnew file mode 100644 index 00000000..2b8dbd37 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0017.png diff --git a/files/poketool/icongra/poke_icon/narc_0018.NCGR b/files/poketool/icongra/poke_icon/narc_0018.NCGR Binary files differdeleted file mode 100644 index 6401655c..00000000 --- a/files/poketool/icongra/poke_icon/narc_0018.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0018.png b/files/poketool/icongra/poke_icon/narc_0018.png Binary files differnew file mode 100644 index 00000000..fe17c1e7 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0018.png diff --git a/files/poketool/icongra/poke_icon/narc_0019.NCGR b/files/poketool/icongra/poke_icon/narc_0019.NCGR Binary files differdeleted file mode 100644 index 46d342ae..00000000 --- a/files/poketool/icongra/poke_icon/narc_0019.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0019.png b/files/poketool/icongra/poke_icon/narc_0019.png Binary files differnew file mode 100644 index 00000000..11ad963d --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0019.png diff --git a/files/poketool/icongra/poke_icon/narc_0020.NCGR b/files/poketool/icongra/poke_icon/narc_0020.NCGR Binary files differdeleted file mode 100644 index db6cb323..00000000 --- a/files/poketool/icongra/poke_icon/narc_0020.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0020.png b/files/poketool/icongra/poke_icon/narc_0020.png Binary files differnew file mode 100644 index 00000000..6efbd041 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0020.png diff --git a/files/poketool/icongra/poke_icon/narc_0021.NCGR b/files/poketool/icongra/poke_icon/narc_0021.NCGR Binary files differdeleted file mode 100644 index f0e4eb2b..00000000 --- a/files/poketool/icongra/poke_icon/narc_0021.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0021.png b/files/poketool/icongra/poke_icon/narc_0021.png Binary files differnew file mode 100644 index 00000000..1c857d44 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0021.png diff --git a/files/poketool/icongra/poke_icon/narc_0022.NCGR b/files/poketool/icongra/poke_icon/narc_0022.NCGR Binary files differdeleted file mode 100644 index 3d83aea4..00000000 --- a/files/poketool/icongra/poke_icon/narc_0022.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0022.png b/files/poketool/icongra/poke_icon/narc_0022.png Binary files differnew file mode 100644 index 00000000..d5e6471a --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0022.png diff --git a/files/poketool/icongra/poke_icon/narc_0023.NCGR b/files/poketool/icongra/poke_icon/narc_0023.NCGR Binary files differdeleted file mode 100644 index b84b867e..00000000 --- a/files/poketool/icongra/poke_icon/narc_0023.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0023.png b/files/poketool/icongra/poke_icon/narc_0023.png Binary files differnew file mode 100644 index 00000000..c3c8f5d8 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0023.png diff --git a/files/poketool/icongra/poke_icon/narc_0024.NCGR b/files/poketool/icongra/poke_icon/narc_0024.NCGR Binary files differdeleted file mode 100644 index a0bb2fad..00000000 --- a/files/poketool/icongra/poke_icon/narc_0024.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0024.png b/files/poketool/icongra/poke_icon/narc_0024.png Binary files differnew file mode 100644 index 00000000..c0348df5 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0024.png diff --git a/files/poketool/icongra/poke_icon/narc_0025.NCGR b/files/poketool/icongra/poke_icon/narc_0025.NCGR Binary files differdeleted file mode 100644 index e3945760..00000000 --- a/files/poketool/icongra/poke_icon/narc_0025.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0025.png b/files/poketool/icongra/poke_icon/narc_0025.png Binary files differnew file mode 100644 index 00000000..fc77716e --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0025.png diff --git a/files/poketool/icongra/poke_icon/narc_0026.NCGR b/files/poketool/icongra/poke_icon/narc_0026.NCGR Binary files differdeleted file mode 100644 index f40adfe7..00000000 --- a/files/poketool/icongra/poke_icon/narc_0026.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0026.png b/files/poketool/icongra/poke_icon/narc_0026.png Binary files differnew file mode 100644 index 00000000..ae7b2225 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0026.png diff --git a/files/poketool/icongra/poke_icon/narc_0027.NCGR b/files/poketool/icongra/poke_icon/narc_0027.NCGR Binary files differdeleted file mode 100644 index 690c7ab2..00000000 --- a/files/poketool/icongra/poke_icon/narc_0027.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0027.png b/files/poketool/icongra/poke_icon/narc_0027.png Binary files differnew file mode 100644 index 00000000..b9959d1c --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0027.png diff --git a/files/poketool/icongra/poke_icon/narc_0028.NCGR b/files/poketool/icongra/poke_icon/narc_0028.NCGR Binary files differdeleted file mode 100644 index 4adf4b97..00000000 --- a/files/poketool/icongra/poke_icon/narc_0028.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0028.png b/files/poketool/icongra/poke_icon/narc_0028.png Binary files differnew file mode 100644 index 00000000..b7f3a1eb --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0028.png diff --git a/files/poketool/icongra/poke_icon/narc_0029.NCGR b/files/poketool/icongra/poke_icon/narc_0029.NCGR Binary files differdeleted file mode 100644 index 7db15dcf..00000000 --- a/files/poketool/icongra/poke_icon/narc_0029.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0029.png b/files/poketool/icongra/poke_icon/narc_0029.png Binary files differnew file mode 100644 index 00000000..a52ea031 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0029.png diff --git a/files/poketool/icongra/poke_icon/narc_0030.NCGR b/files/poketool/icongra/poke_icon/narc_0030.NCGR Binary files differdeleted file mode 100644 index 9eba4fa4..00000000 --- a/files/poketool/icongra/poke_icon/narc_0030.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0030.png b/files/poketool/icongra/poke_icon/narc_0030.png Binary files differnew file mode 100644 index 00000000..3c81efd6 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0030.png diff --git a/files/poketool/icongra/poke_icon/narc_0031.NCGR b/files/poketool/icongra/poke_icon/narc_0031.NCGR Binary files differdeleted file mode 100644 index ed436770..00000000 --- a/files/poketool/icongra/poke_icon/narc_0031.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0031.png b/files/poketool/icongra/poke_icon/narc_0031.png Binary files differnew file mode 100644 index 00000000..8967d44a --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0031.png diff --git a/files/poketool/icongra/poke_icon/narc_0032.NCGR b/files/poketool/icongra/poke_icon/narc_0032.NCGR Binary files differdeleted file mode 100644 index 3424a464..00000000 --- a/files/poketool/icongra/poke_icon/narc_0032.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0032.png b/files/poketool/icongra/poke_icon/narc_0032.png Binary files differnew file mode 100644 index 00000000..feb77f7d --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0032.png diff --git a/files/poketool/icongra/poke_icon/narc_0033.NCGR b/files/poketool/icongra/poke_icon/narc_0033.NCGR Binary files differdeleted file mode 100644 index ca90981b..00000000 --- a/files/poketool/icongra/poke_icon/narc_0033.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0033.png b/files/poketool/icongra/poke_icon/narc_0033.png Binary files differnew file mode 100644 index 00000000..67543933 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0033.png diff --git a/files/poketool/icongra/poke_icon/narc_0034.NCGR b/files/poketool/icongra/poke_icon/narc_0034.NCGR Binary files differdeleted file mode 100644 index 9fa16d27..00000000 --- a/files/poketool/icongra/poke_icon/narc_0034.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0034.png b/files/poketool/icongra/poke_icon/narc_0034.png Binary files differnew file mode 100644 index 00000000..5919f109 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0034.png diff --git a/files/poketool/icongra/poke_icon/narc_0035.NCGR b/files/poketool/icongra/poke_icon/narc_0035.NCGR Binary files differdeleted file mode 100644 index 0fbd78f8..00000000 --- a/files/poketool/icongra/poke_icon/narc_0035.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0035.png b/files/poketool/icongra/poke_icon/narc_0035.png Binary files differnew file mode 100644 index 00000000..08198e6b --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0035.png diff --git a/files/poketool/icongra/poke_icon/narc_0036.NCGR b/files/poketool/icongra/poke_icon/narc_0036.NCGR Binary files differdeleted file mode 100644 index 109becc0..00000000 --- a/files/poketool/icongra/poke_icon/narc_0036.NCGR +++ /dev/null diff --git a/files/poketool/icongra/poke_icon/narc_0036.png b/files/poketool/icongra/poke_icon/narc_0036.png Binary files differnew file mode 100644 index 00000000..a2483ae6 --- /dev/null +++ b/files/poketool/icongra/poke_icon/narc_0036.png diff --git a/filesystem.mk b/filesystem.mk index 4264c367..f06a5429 100644 --- a/filesystem.mk +++ b/filesystem.mk @@ -2589,6 +2589,7 @@ files/poketool/icongra/poke_icon.narc: \ files/poketool/icongra/poke_icon/narc_0000.NCLR \ files/poketool/icongra/poke_icon/narc_0002.NCER \ files/poketool/icongra/poke_icon/narc_0004.NCER \ + files/poketool/icongra/poke_icon/narc_0006.NCER \ files/poketool/icongra/poke_icon/narc_0007.NCGR \ files/poketool/icongra/poke_icon/narc_0008.NCGR \ files/poketool/icongra/poke_icon/narc_0009.NCGR \ @@ -2599,6 +2600,26 @@ files/poketool/icongra/poke_icon.narc: \ files/poketool/icongra/poke_icon/narc_0014.NCGR \ files/poketool/icongra/poke_icon/narc_0015.NCGR \ files/poketool/icongra/poke_icon/narc_0016.NCGR \ + files/poketool/icongra/poke_icon/narc_0017.NCGR \ + files/poketool/icongra/poke_icon/narc_0018.NCGR \ + files/poketool/icongra/poke_icon/narc_0019.NCGR \ + files/poketool/icongra/poke_icon/narc_0020.NCGR \ + files/poketool/icongra/poke_icon/narc_0021.NCGR \ + files/poketool/icongra/poke_icon/narc_0022.NCGR \ + files/poketool/icongra/poke_icon/narc_0023.NCGR \ + files/poketool/icongra/poke_icon/narc_0024.NCGR \ + files/poketool/icongra/poke_icon/narc_0025.NCGR \ + files/poketool/icongra/poke_icon/narc_0026.NCGR \ + files/poketool/icongra/poke_icon/narc_0027.NCGR \ + files/poketool/icongra/poke_icon/narc_0028.NCGR \ + files/poketool/icongra/poke_icon/narc_0029.NCGR \ + files/poketool/icongra/poke_icon/narc_0030.NCGR \ + files/poketool/icongra/poke_icon/narc_0031.NCGR \ + files/poketool/icongra/poke_icon/narc_0032.NCGR \ + files/poketool/icongra/poke_icon/narc_0033.NCGR \ + files/poketool/icongra/poke_icon/narc_0034.NCGR \ + files/poketool/icongra/poke_icon/narc_0035.NCGR \ + files/poketool/icongra/poke_icon/narc_0036.NCGR \ files/poketool/icongra/poke_icon/narc_0402.NCGR files/msgdata/msg.narc: \ diff --git a/graphics_rules.mk b/graphics_rules.mk index 8abbbbaa..d20020cd 100644 --- a/graphics_rules.mk +++ b/graphics_rules.mk @@ -86,6 +86,26 @@ CLOBBER_SIZE_VERSION101_NCGR_FILES := files/graphic/bag_gra/narc_0002.NCGR \ files/poketool/icongra/poke_icon/narc_0014.NCGR \ files/poketool/icongra/poke_icon/narc_0015.NCGR \ files/poketool/icongra/poke_icon/narc_0016.NCGR \ + files/poketool/icongra/poke_icon/narc_0017.NCGR \ + files/poketool/icongra/poke_icon/narc_0018.NCGR \ + files/poketool/icongra/poke_icon/narc_0019.NCGR \ + files/poketool/icongra/poke_icon/narc_0020.NCGR \ + files/poketool/icongra/poke_icon/narc_0021.NCGR \ + files/poketool/icongra/poke_icon/narc_0022.NCGR \ + files/poketool/icongra/poke_icon/narc_0023.NCGR \ + files/poketool/icongra/poke_icon/narc_0024.NCGR \ + files/poketool/icongra/poke_icon/narc_0025.NCGR \ + files/poketool/icongra/poke_icon/narc_0026.NCGR \ + files/poketool/icongra/poke_icon/narc_0027.NCGR \ + files/poketool/icongra/poke_icon/narc_0028.NCGR \ + files/poketool/icongra/poke_icon/narc_0029.NCGR \ + files/poketool/icongra/poke_icon/narc_0030.NCGR \ + files/poketool/icongra/poke_icon/narc_0031.NCGR \ + files/poketool/icongra/poke_icon/narc_0032.NCGR \ + files/poketool/icongra/poke_icon/narc_0033.NCGR \ + files/poketool/icongra/poke_icon/narc_0034.NCGR \ + files/poketool/icongra/poke_icon/narc_0035.NCGR \ + files/poketool/icongra/poke_icon/narc_0036.NCGR \ files/poketool/icongra/poke_icon/narc_0402.NCGR 4BPP_NCLR_FILES := files/application/wifi_earth/wifi_earth/narc_0006.NCLR \ @@ -498,6 +518,26 @@ NCGR_CLEAN_LIST := files/application/wifi_earth/wifi_earth/narc_0005.NCGR \ files/poketool/icongra/poke_icon/narc_0014.NCGR \ files/poketool/icongra/poke_icon/narc_0015.NCGR \ files/poketool/icongra/poke_icon/narc_0016.NCGR \ + files/poketool/icongra/poke_icon/narc_0017.NCGR \ + files/poketool/icongra/poke_icon/narc_0018.NCGR \ + files/poketool/icongra/poke_icon/narc_0019.NCGR \ + files/poketool/icongra/poke_icon/narc_0020.NCGR \ + files/poketool/icongra/poke_icon/narc_0021.NCGR \ + files/poketool/icongra/poke_icon/narc_0022.NCGR \ + files/poketool/icongra/poke_icon/narc_0023.NCGR \ + files/poketool/icongra/poke_icon/narc_0024.NCGR \ + files/poketool/icongra/poke_icon/narc_0025.NCGR \ + files/poketool/icongra/poke_icon/narc_0026.NCGR \ + files/poketool/icongra/poke_icon/narc_0027.NCGR \ + files/poketool/icongra/poke_icon/narc_0028.NCGR \ + files/poketool/icongra/poke_icon/narc_0029.NCGR \ + files/poketool/icongra/poke_icon/narc_0030.NCGR \ + files/poketool/icongra/poke_icon/narc_0031.NCGR \ + files/poketool/icongra/poke_icon/narc_0032.NCGR \ + files/poketool/icongra/poke_icon/narc_0033.NCGR \ + files/poketool/icongra/poke_icon/narc_0034.NCGR \ + files/poketool/icongra/poke_icon/narc_0035.NCGR \ + files/poketool/icongra/poke_icon/narc_0036.NCGR \ files/poketool/icongra/poke_icon/narc_0402.NCGR \ files/poketool/pokegra/pokegra/narc_0006.NCGR \ files/poketool/pokegra/pokegra/narc_0007.NCGR \ @@ -881,7 +921,8 @@ NCLR_CLEAN_LIST := files/application/wifi_earth/wifi_earth/narc_0006.NCLR \ files/poketool/trgra/trfgra/narc_0194.NCLR \ NCER_CLEAN_LIST := files/poketool/icongra/poke_icon/narc_0002.NCER \ - files/poketool/icongra/poke_icon/narc_0004.NCER + files/poketool/icongra/poke_icon/narc_0004.NCER \ + files/poketool/icongra/poke_icon/narc_0006.NCER NSCR_CLEAN_LIST := files/demo/title/titledemo/narc_0000.NSCR \ files/demo/title/titledemo/narc_0008.NSCR \ diff --git a/include/WIFI_stubsmd5_dummy.h b/include/WIFI_stubsmd5_dummy.h new file mode 100644 index 00000000..d82b55c5 --- /dev/null +++ b/include/WIFI_stubsmd5_dummy.h @@ -0,0 +1,11 @@ +#ifndef POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H +#define POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H + +#include "nitro/types.h" +#include "dgt.h" + +void MD5Final(u8 *digest, struct DGTHash1Context *context); +void MD5Update(struct DGTHash1Context *context, u8 *input, u32 length); +void MD5Init(struct DGTHash1Context *context); + +#endif //POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H diff --git a/include/main.h b/include/main.h index d40e22f9..2e424e09 100644 --- a/include/main.h +++ b/include/main.h @@ -20,7 +20,7 @@ struct UnkStruct_02006234 struct Unk21DBE18 ovly_mgr; u32 unk10; u32 unk14; - int * unk18; + s32 * unk18; void * unk1C; struct SaveBlock2 * unk20; u32 unk24; @@ -31,9 +31,9 @@ struct Unk2106FA0 PMBackLightSwitch unk0; s32 unk4; FSOverlayID unk8; - s32 unkC; + struct UnkStruct_02006234 *unkC; FSOverlayID unk10; - struct Unk21DBE18 * unk14; + const struct Unk21DBE18 * unk14; s32 unk18; s32 unk1C; struct SaveBlock2 * unk20; @@ -113,7 +113,7 @@ extern struct Main gMain; void FUN_02000DF4(void); void Main_RunOverlayManager(void); -void RegisterMainOverlay(FSOverlayID id, struct Unk21DBE18 * arg1); +void RegisterMainOverlay(FSOverlayID id, const struct Unk21DBE18 * arg1); void FUN_02000E9C(void); void FUN_02000EC8(u32 parameter); void FUN_02000EE8(void); diff --git a/include/overlay_manager.h b/include/overlay_manager.h index 193bc7e8..8d9bd6e3 100644 --- a/include/overlay_manager.h +++ b/include/overlay_manager.h @@ -5,12 +5,12 @@ struct Unk21DBE18; -struct UnkStruct_02006234 * OverlayManager_new(struct Unk21DBE18 * ovly_mgr, int * a1, u32 heap_id); +struct UnkStruct_02006234 * OverlayManager_new(const struct Unk21DBE18 * ovly_mgr, s32 * a1, u32 heap_id); void OverlayManager_delete(struct UnkStruct_02006234 * a0); void * OverlayManager_CreateAndGetData(struct UnkStruct_02006234 * a0, u32 size, u32 heap_id); void * OverlayManager_GetData(struct UnkStruct_02006234 * a0); void OverlayManager_FreeData(struct UnkStruct_02006234 * a0); -int * OverlayManager_GetField18(struct UnkStruct_02006234 * a0); +s32 * OverlayManager_GetField18(struct UnkStruct_02006234 * a0); BOOL OverlayManager_Run(struct UnkStruct_02006234 * a0); #endif //POKEDIAMOND_OVERLAY_MANAGER_H diff --git a/include/scrcmd.h b/include/scrcmd.h index 86bb4f51..226bbb8c 100644 --- a/include/scrcmd.h +++ b/include/scrcmd.h @@ -105,6 +105,7 @@ BOOL ScrCmd_Unk0047(struct ScriptContext *ctx); BOOL ScrCmd_Unk0048(struct ScriptContext *ctx); BOOL ScrCmd_Unk02CF(struct ScriptContext *ctx); BOOL ScrCmd_Unk02D0(struct ScriptContext *ctx); +BOOL ScrCmd_Unk005E(struct ScriptContext *ctx); //scrcmd_4.c BOOL ScrCmd_GetPlayerName(struct ScriptContext* ctx); @@ -150,6 +151,34 @@ BOOL ScrCmd_Unk02CC(struct ScriptContext* ctx); BOOL ScrCmd_GetSealNamePlural(struct ScriptContext* ctx); BOOL ScrCmd_CapitalizeFirstChar(struct ScriptContext* ctx); +//scrcmd_sound.c +BOOL ScrCmd_Unk02AE(struct ScriptContext *ctx); +BOOL ScrCmd_Unk0050(struct ScriptContext *ctx); +BOOL ScrCmd_Unk0051(struct ScriptContext *ctx); +BOOL ScrCmd_Unk0052(struct ScriptContext *ctx); +BOOL ScrCmd_Unk0053(struct ScriptContext *ctx); +BOOL ScrCmd_Unk0054(struct ScriptContext *ctx); +BOOL FUN_02041464(struct ScriptContext *ctx); +BOOL ScrCmd_Unk0055(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0056(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0058(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0049(struct ScriptContext* ctx); +BOOL ScrCmd_Unk004A(struct ScriptContext* ctx); +BOOL ScrCmd_Unk004B(struct ScriptContext* ctx); +BOOL FUN_02041540(struct ScriptContext* ctx); +BOOL ScrCmd_Unk004C(struct ScriptContext* ctx); +BOOL ScrCmd_PlayCryWait(struct ScriptContext* ctx); +BOOL FUN_02041598(struct ScriptContext* ctx); +BOOL ScrCmd_Unk004F(struct ScriptContext* ctx); +BOOL FUN_020415CC(struct ScriptContext* ctx); +BOOL ScrCmd_PlayBgm(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0059(struct ScriptContext* ctx); +BOOL ScrCmd_Unk005A(struct ScriptContext* ctx); +BOOL ScrCmd_Unk005B(struct ScriptContext* ctx); +BOOL ScrCmd_Unk005C(struct ScriptContext* ctx); +BOOL ScrCmd_Unk005D(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0283(struct ScriptContext *ctx); + //scrcmd_8.c BOOL ScrCmd_Unk021D(struct ScriptContext* ctx); @@ -273,6 +302,19 @@ BOOL ScrCmd_Unk0090(struct ScriptContext* ctx); BOOL ScrCmd_Unk0091(struct ScriptContext* ctx); BOOL ScrCmd_Unk0092(struct ScriptContext* ctx); +//scrcmd_24.c +BOOL ScrCmd_Unk01C6(struct ScriptContext* ctx); +BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx); +BOOL ScrCmd_Unk021E(struct ScriptContext* ctx); +BOOL ScrCmd_Unk021F(struct ScriptContext* ctx); +void FUN_02045E74(struct ScriptContext* ctx, u8 a1, struct Pokemon* pokemon, void* a3); +BOOL ScrCmd_Unk0220(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0221(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0224(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0222(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0223(struct ScriptContext* ctx); +BOOL ScrCmd_Unk0225(struct ScriptContext* ctx); + //scrcmd_25.c BOOL ScrCmd_Unk023F(struct ScriptContext* ctx); BOOL ScrCmd_Unk0240(struct ScriptContext* ctx); diff --git a/include/unk_02022504.h b/include/unk_02022504.h new file mode 100644 index 00000000..aa541f85 --- /dev/null +++ b/include/unk_02022504.h @@ -0,0 +1,14 @@ +#ifndef POKEDIAMOND_UNK_02022504_H +#define POKEDIAMOND_UNK_02022504_H + +#include "save_block_2.h" +#include "pokemon_storage_system.h" + +void *FUN_02022504(struct SaveBlock2 *sav2); +struct PCStorage *GetStoragePCPointer(struct SaveBlock2 *sav2); +void *FUN_0202251C(struct SaveBlock2 *sav2); +void *FUN_02022528(struct SaveBlock2 *sav2); +u8 *LoadHallOfFame(struct SaveBlock2 *sav2, u32 heap_id, int *ret_p); +s32 *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data); + +#endif //POKEDIAMOND_UNK_02022504_H diff --git a/include/unk_0202E29C.h b/include/unk_0202E29C.h index d4316336..92998f7c 100644 --- a/include/unk_0202E29C.h +++ b/include/unk_0202E29C.h @@ -68,7 +68,12 @@ struct UnkStruct_0202E29C u8 unkDAA; u8 unkDAB; u8 unkDAC; - u8 unkDAD; + u8 unkDAD_0:1; + u8 unkDAD_1:1; + u8 unkDAD_2:1; + u8 unkDAD_3:1; + u8 unkDAD_4:1; + u8 unkDAD_5:1; u8 unkDAE[0x2]; }; diff --git a/include/unk_0202F150.h b/include/unk_0202F150.h index ea0846c6..8f5cdd3e 100644 --- a/include/unk_0202F150.h +++ b/include/unk_0202F150.h @@ -93,7 +93,7 @@ THUMB_FUNC void FUN_0202F5A4(); THUMB_FUNC void FUN_0202F820(int param0); THUMB_FUNC void FUN_0202F8D4(); THUMB_FUNC void FUN_0202F910(int param0); -THUMB_FUNC u32 FUN_0202F918(u32 param0, u32 param1, u32 param2, u32 param3); +THUMB_FUNC BOOL FUN_0202F918(u32 param0, u32 param1, u32 param2, u32 param3); THUMB_FUNC u32 FUN_0202F950(u32 param0, u32 param1, u32 param2); THUMB_FUNC void FUN_0202F984(); THUMB_FUNC void FUN_0202F9E0(u32 param0); diff --git a/include/unk_020377F0.h b/include/unk_020377F0.h new file mode 100644 index 00000000..91276889 --- /dev/null +++ b/include/unk_020377F0.h @@ -0,0 +1,30 @@ +#ifndef POKEDIAMOND_UNK_020377F0_H +#define POKEDIAMOND_UNK_020377F0_H + +struct Options; +struct PlayerParty; + +// This struct gets created from a bunch of places, not just 0x02037CF0. This was +// just the first place I (tgsm) found it being created. +struct UnkStruct_02037CF0 +{ + struct PlayerParty* party; + struct Options* options; + u16* name_buf; + u32 trainer_id; + u8 gender; + u8 unk11; + u8 unk12; + u8 party_count; + u8 unk14; + u8 unk15; + u8 unk16; + u8 padding; + u16 unk18; + u8 padding2[0x2]; + BOOL has_national_dex; + u8 padding3[0xC]; + BOOL unk2C; +}; + +#endif diff --git a/include/unk_02088DD8.h b/include/unk_02088DD8.h new file mode 100644 index 00000000..318a98fb --- /dev/null +++ b/include/unk_02088DD8.h @@ -0,0 +1,19 @@ +#ifndef POKEDIAMOND_UNK_02088DD8_H +#define POKEDIAMOND_UNK_02088DD8_H + +struct Options; +struct PlayerData; +struct Pokemon; + +struct UnkStruct_02088DD8 +{ + struct Pokemon* pokemon; + struct PlayerData* player; + struct Options* options; + void* unkC; + u8 padding[0x5]; + u8 unk15; + u8 padding2[0x2]; +}; + +#endif diff --git a/tools/fixrom/fixrom.c b/tools/fixrom/fixrom.c index 6c5f5da1..59fbd327 100644 --- a/tools/fixrom/fixrom.c +++ b/tools/fixrom/fixrom.c @@ -6,8 +6,12 @@ #include <stdnoreturn.h> #include <stdarg.h> -#define HEADER_SIZE 0x4000 +#define HEADER_SIZE 0x4000 +#define HEADER_CODE_OFFSET 0xC +#define HEADER_SECURE_CRC_OFFSET 0x6C +#define HEADER_CRC_OFFSET 0x15E +// ROM header buffer uint8_t RomHeader[HEADER_SIZE]; static inline noreturn __attribute__((format(printf, 1, 2))) void fatal_error(const char * message, ...) @@ -21,6 +25,9 @@ static inline noreturn __attribute__((format(printf, 1, 2))) void fatal_error(co exit(EXIT_FAILURE); } +// Pedantic check to make sure you're writing to or reading from a valid range +// within the ROM header buffer. +// Call twice, once with the first offset and again with the last address. static inline void OffsetCheck(int offset) { if (offset < 0 || offset >= HEADER_SIZE) @@ -29,80 +36,77 @@ static inline void OffsetCheck(int offset) } } +// Wrapper for memcpy that writes to the ROM header buffer +static inline uint8_t * SafeCopyToHeader(int offset, const void * src, size_t size) +{ + OffsetCheck(offset); + OffsetCheck(offset + size - 1); + return memcpy(RomHeader + offset, src, size); +} + +// Read a 16-bit word from the header buffer static inline uint16_t HeaderReadU16LE(int offset) { OffsetCheck(offset); + OffsetCheck(offset + 1); return RomHeader[offset] | (RomHeader[offset + 1] << 8); } +// Read a 32-bit word from the header buffer static inline uint32_t HeaderReadU32LE(int offset) { OffsetCheck(offset); + OffsetCheck(offset + 3); return RomHeader[offset] | (RomHeader[offset + 1] << 8) | (RomHeader[offset + 2] << 16) | (RomHeader[offset + 3] << 24); } +// Write a 16-bit word to the header buffer static inline void HeaderWriteU16LE(int offset, uint16_t value) { OffsetCheck(offset); + OffsetCheck(offset + 1); RomHeader[offset] = value; RomHeader[offset + 1] = value >> 8; } +// Write a 32-bit word to the header buffer static inline void HeaderWriteU32LE(int offset, uint32_t value) { OffsetCheck(offset); + OffsetCheck(offset + 3); RomHeader[offset] = value; RomHeader[offset + 1] = value >> 8; RomHeader[offset + 2] = value >> 16; RomHeader[offset + 3] = value >> 24; } +// Standard CRC16 routine +#define CRC16_POLYNOMIAL 0xA001 + static uint16_t Calc_CRC16(uint8_t * data, size_t length, uint16_t crc) { - static uint16_t CrcTable[16] = { - 0x0000, - 0xCC01, - 0xD801, - 0x1400, - 0xF001, - 0x3C00, - 0x2800, - 0xE401, - 0xA001, - 0x6C00, - 0x7800, - 0xB401, - 0x5000, - 0x9C01, - 0x8801, - 0x4400, - }; - - uint16_t x = 0; - uint16_t y; - uint16_t bit = 0; - uint8_t * end = data + length; - while (data < end) - { - if (bit == 0) - { - x = data[0] | (data[1] << 8); - } - y = CrcTable[crc & 15]; - crc >>= 4; - crc ^= y; - y = CrcTable[(x >> bit) & 15]; - crc ^= y; - bit += 4; - if (bit == 16) - { - data += 2; - bit = 0; + static uint16_t CrcTable[256] = {}; + static int initialized = 0; + int i; + + if (!initialized) { + for (i = 0; i < 256; i++) { + int c = i; + for (int j = 0; j < 8; j++) { + c = (c >> 1) ^ ((c & 1) ? CRC16_POLYNOMIAL : 0); + } + CrcTable[i] = c; } + initialized = 1; } + + for (i = 0; i < length; i++) { + crc = (crc >> 8) ^ CrcTable[(uint8_t)crc] ^ CrcTable[data[i]]; + } + return crc; } @@ -114,20 +118,24 @@ int main(int argc, char ** argv) int override_code = 0; FILE * rom = NULL; + // Parse arguments for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "--secure-crc") == 0) { + // Enforce zero or one if (override_crc) { fatal_error("multiple --secure-crc options specified"); } + // Parse integer char * endptr; unsigned long secure_crc_l = strtoul(argv[++i], &endptr, 0); if (secure_crc_l == 0 && endptr == argv[i]) { fatal_error("argument to --secure-crc must be an integer"); } - if (secure_crc_l >= 0x10000) + // Enforce width + if (secure_crc_l > UINT16_MAX) { fatal_error("argument to --secure-crc must be a 16-bit integer"); } @@ -136,55 +144,66 @@ int main(int argc, char ** argv) } else if (strcmp(argv[i], "--game-code") == 0) { + // Enforce zero or one if (override_code) { fatal_error("multiple --game-code options specified"); } - if (strlen(argv[++i]) > 4) + // Enforce max length + if (strlen(argv[++i]) > sizeof(game_code)) { fatal_error("argument to --game-code must be 4 characters or fewer"); } - strncpy(game_code, argv[i], 4); + memset(game_code, 0, sizeof(game_code)); + strncpy(game_code, argv[i], sizeof(game_code)); override_code = 1; } - else + // Positional arguments + else if (rom == NULL) { - if (rom != NULL) - { - fatal_error("unrecognized %s argument: %s", argv[i][0] == '-' ? "flag" : "positional", argv[i]); - } rom = fopen(argv[i], "r+b"); if (rom == NULL) { fatal_error(argv[i][0] == '-' ? "unrecognized flag argument: %s" : "unable to open file '%s' for reading", argv[i]); } } + else + { + // Invalid argument, complain about it + fatal_error("unrecognized %s argument: %s", argv[i][0] == '-' ? "flag" : "positional", argv[i]); + } } + // Read header to buffer if (fread(RomHeader, 1, HEADER_SIZE, rom) != HEADER_SIZE) { fatal_error("error reading the ROM header"); } + // Update CRC if (override_crc) { - HeaderWriteU16LE(0x6C, secure_crc); + HeaderWriteU16LE(HEADER_SECURE_CRC_OFFSET, secure_crc); } - + + // Update code if (override_code) { - memcpy(RomHeader + 0xC, game_code, 4); + SafeCopyToHeader(HEADER_CODE_OFFSET, game_code, sizeof(game_code)); } - uint16_t header_crc = Calc_CRC16((uint8_t *)RomHeader, 0x15E, 0xFFFF); - HeaderWriteU16LE(0x15E, header_crc); + // Recompute CRC of header not including the crc offset + uint16_t header_crc = Calc_CRC16((uint8_t *)RomHeader, HEADER_CRC_OFFSET, 0xFFFF); + HeaderWriteU16LE(HEADER_CRC_OFFSET, header_crc); + // Write the header back fseek(rom, 0, SEEK_SET); if (fwrite(RomHeader, 1, HEADER_SIZE, rom) != HEADER_SIZE) { fatal_error("error writing the ROM header"); } + // Hooray, we done did it! fclose(rom); return EXIT_SUCCESS; } diff --git a/tools/nitrogfx/gfx.c b/tools/nitrogfx/gfx.c index 305fbeb2..f5ff30e7 100644 --- a/tools/nitrogfx/gfx.c +++ b/tools/nitrogfx/gfx.c @@ -774,8 +774,9 @@ void WriteNtrCell(char *path, struct JsonToCellOptions *options) KBECHeader[4] = (size + 0x20) & 0xFF; //size KBECHeader[5] = (size + 0x20) >> 8; //unlikely to be more than 16 bits, but there are 32 allocated, change if necessary - fwrite(KBECHeader, 1, 0x20, fp); + KBECHeader[16] = (options->mappingType & 0xFF); //not possible to be more than 8 bits, though 32 are allocated + fwrite(KBECHeader, 1, 0x20, fp); unsigned char *KBECContents = malloc(size); diff --git a/tools/nitrogfx/json.c b/tools/nitrogfx/json.c index aad325be..b825c363 100644 --- a/tools/nitrogfx/json.c +++ b/tools/nitrogfx/json.c @@ -51,16 +51,17 @@ struct JsonToCellOptions *ParseNCERJson(char *path) cJSON *imageHeight = cJSON_GetObjectItemCaseSensitive(json, "imageHeight"); cJSON *imageWidth = cJSON_GetObjectItemCaseSensitive(json, "imageWidth"); cJSON *cellCount = cJSON_GetObjectItemCaseSensitive(json, "cellCount"); + cJSON *mappingType = cJSON_GetObjectItemCaseSensitive(json, "mappingType"); options->labelEnabled = GetBool(labelBool); options->extended = GetBool(extended); options->imageHeight = GetInt(imageHeight); options->imageWidth = GetInt(imageWidth); options->cellCount = GetInt(cellCount); + options->mappingType = GetInt(mappingType); options->cells = malloc(sizeof(struct Cell *) * options->cellCount); - if (options->labelEnabled) { cJSON *labelCount = cJSON_GetObjectItemCaseSensitive(json, "labelCount"); diff --git a/tools/nitrogfx/options.h b/tools/nitrogfx/options.h index 780c83e6..66e9895d 100644 --- a/tools/nitrogfx/options.h +++ b/tools/nitrogfx/options.h @@ -74,6 +74,7 @@ struct Cell { struct JsonToCellOptions { bool labelEnabled; bool extended; + int mappingType; int imageHeight; int imageWidth; int cellCount; |