diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e91638 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.cia +*.nds +*.o +*.arm7 +Thumbs.db +*.arm9 +*.elf +*.d +*.map +arm9/data/load.bin +BootLoader/load.bin \ No newline at end of file diff --git a/BootLoader/Makefile b/BootLoader/Makefile index cdc31b6..44f5ec7 100755 --- a/BootLoader/Makefile +++ b/BootLoader/Makefile @@ -26,7 +26,6 @@ ARCH := -mthumb-interwork CFLAGS := -g -Wall -O2\ -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ -ffast-math \ - -Wall -Wextra -Werror \ $(ARCH) CFLAGS += $(INCLUDE) -DARM7 diff --git a/BootLoader/source/bios7.s b/BootLoader/source/bios7.s new file mode 100644 index 0000000..db6ecc6 --- /dev/null +++ b/BootLoader/source/bios7.s @@ -0,0 +1,43 @@ +/*--------------------------------------------------------------------------------- + + Copyright (C) 2009 + Dave Murphy (WinterMute) + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + +---------------------------------------------------------------------------------*/ + + .text + .align 4 + + .arm +@--------------------------------------------------------------------------------- + .global swiSoftResetarm7 + .type swiSoftResetarm7 STT_FUNC +@--------------------------------------------------------------------------------- +swiSoftResetarm7: +@--------------------------------------------------------------------------------- + REG_IME = 0; + + ldr r0,=0x2FFFE34 + + + ldr r0,[r0] + bx r0 + + .pool \ No newline at end of file diff --git a/BootLoader/source/bios9.s b/BootLoader/source/bios9.s new file mode 100644 index 0000000..db6f6a3 --- /dev/null +++ b/BootLoader/source/bios9.s @@ -0,0 +1,56 @@ +/*--------------------------------------------------------------------------------- + + Copyright (C) 2009 + Dave Murphy (WinterMute) + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + +---------------------------------------------------------------------------------*/ + + .text + .align 4 + + .arm +@--------------------------------------------------------------------------------- + .global swiSoftResetarm9 + .type swiSoftResetarm9 STT_FUNC +@--------------------------------------------------------------------------------- +swiSoftResetarm9: +@--------------------------------------------------------------------------------- + REG_IME = 0; + + + .arch armv5te + .cpu arm946e-s + ldr r1, =0x00002078 @ disable TCM and protection unit + mcr p15, 0, r1, c1, c0 + @ Disable cache + mov r0, #0 + mcr p15, 0, r0, c7, c5, 0 @ Instruction cache + mcr p15, 0, r0, c7, c6, 0 @ Data cache + + @ Wait for write buffer to empty + mcr p15, 0, r0, c7, c10, 4 + + ldr r0,=0x2FFFE24 + + + ldr r0,[r0] + bx r0 + + .pool \ No newline at end of file diff --git a/BootLoader/source/cheat.c b/BootLoader/source/cheat.c deleted file mode 100755 index 1ef18ca..0000000 --- a/BootLoader/source/cheat.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - NitroHax -- Cheat tool for the Nintendo DS - Copyright (C) 2008 Michael "Chishm" Chisholm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "cheat.h" -#include "common.h" - -extern unsigned long cheat_engine_size; -extern unsigned long intr_orig_return_offset; - -extern const u8 cheat_engine_start[]; -#define CHEAT_CODE_END 0xCF000000 -#define CHEAT_ENGINE_RELOCATE 0xCF000001 -#define CHEAT_ENGINE_HOOK 0xCF000002 - -static const u32 handlerStartSig[5] = { - 0xe92d4000, // push {lr} - 0xe3a0c301, // mov ip, #0x4000000 - 0xe28cce21, // add ip, ip, #0x210 - 0xe51c1008, // ldr r1, [ip, #-8] - 0xe3510000 // cmp r1, #0 -}; - -static const u32 handlerEndSig[4] = { - 0xe59f1008, // ldr r1, [pc, #8] (IRQ Vector table address) - 0xe7910100, // ldr r0, [r1, r0, lsl #2] - 0xe59fe004, // ldr lr, [pc, #4] (IRQ return address) - 0xe12fff10 // bx r0 -}; - -static const int MAX_HANDLER_SIZE = 50; - -static u32* hookInterruptHandler (u32* addr, size_t size) { - u32* end = addr + size/sizeof(u32); - int i; - - // Find the start of the handler - while (addr < end) { - if ((addr[0] == handlerStartSig[0]) && - (addr[1] == handlerStartSig[1]) && - (addr[2] == handlerStartSig[2]) && - (addr[3] == handlerStartSig[3]) && - (addr[4] == handlerStartSig[4])) - { - break; - } - addr++; - } - - if (addr >= end) { - return NULL; - } - - // Find the end of the handler - for (i = 0; i < MAX_HANDLER_SIZE; i++) { - if ((addr[i+0] == handlerEndSig[0]) && - (addr[i+1] == handlerEndSig[1]) && - (addr[i+2] == handlerEndSig[2]) && - (addr[i+3] == handlerEndSig[3])) - { - break; - } - } - - if (i >= MAX_HANDLER_SIZE) { - return NULL; - } - - // Now find the IRQ vector table - // Make addr point to the vector table address pointer within the IRQ handler - addr = addr + i + sizeof(handlerEndSig)/sizeof(handlerEndSig[0]); - - // Use relative and absolute addresses to find the location of the table in RAM - u32 tableAddr = addr[0]; - u32 returnAddr = addr[1]; - u32* actualReturnAddr = addr + 2; - u32* actualTableAddr = actualReturnAddr + (tableAddr - returnAddr)/sizeof(u32); - - // The first entry in the table is for the Vblank handler, which is what we want - return actualTableAddr; -} - -int arm7_hookGame (const tNDSHeader* ndsHeader, const u32* cheatData, u32* cheatEngineLocation) { - u32 oldReturn; - u32 cheatWord1, cheatWord2; - u32* cheatDest; - u32* hookLocation = NULL; - - if (cheatData[0] == CHEAT_CODE_END) { - return ERR_NOCHEAT; - } - - if (cheatData[0] == CHEAT_ENGINE_RELOCATE) { - cheatWord1 = *cheatData++; - cheatWord2 = *cheatData++; - cheatEngineLocation = (u32*)cheatWord2; - } - - if (cheatData[0] == CHEAT_ENGINE_HOOK) { - cheatWord1 = *cheatData++; - cheatWord2 = *cheatData++; - hookLocation = (u32*)cheatWord2; - } - - if (!hookLocation) { - hookLocation = hookInterruptHandler ((u32*)ndsHeader->arm7destination, ndsHeader->arm7binarySize); - } - - if (!hookLocation) { - return ERR_HOOK; - } - - oldReturn = *hookLocation; - - *hookLocation = (u32)cheatEngineLocation; - - copyLoop (cheatEngineLocation, (u32*)cheat_engine_start, cheat_engine_size); - - cheatEngineLocation [intr_orig_return_offset/sizeof(u32)] = oldReturn; - - cheatDest = cheatEngineLocation + (cheat_engine_size/sizeof(u32)); - - // Copy cheat data across - do { - cheatWord1 = *cheatData++; - cheatWord2 = *cheatData++; - *cheatDest++ = cheatWord1; - *cheatDest++ = cheatWord2; - } while (cheatWord1 != CHEAT_CODE_END); - - return ERR_NONE; -} - - diff --git a/BootLoader/source/cheat_engine.s b/BootLoader/source/cheat_engine.s deleted file mode 100755 index 59305b6..0000000 --- a/BootLoader/source/cheat_engine.s +++ /dev/null @@ -1,484 +0,0 @@ -@ NitroHax -- Cheat tool for the Nintendo DS -@ Copyright (C) 2008 Michael "Chishm" Chisholm -@ -@ This program is free software: you can redistribute it and/or modify -@ it under the terms of the GNU General Public License as published by -@ the Free Software Foundation, either version 3 of the License, or -@ (at your option) any later version. -@ -@ This program is distributed in the hope that it will be useful, -@ but WITHOUT ANY WARRANTY; without even the implied warranty of -@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -@ GNU General Public License for more details. -@ -@ You should have received a copy of the GNU General Public License -@ along with this program. If not, see . - -.arm - -.global cheat_engine_start -.global cheat_engine_end -.global intr_orig_return_offset -.global cheat_engine_size - - -cheat_engine_size: - .word cheat_engine_end - cheat_engine_start - -intr_orig_return_offset: - .word intr_orig_return - cheat_engine_start - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - -cheat_engine_start: -@ Hook the return address, then go back to the original function - stmdb sp!, {lr} - adr lr, code_handler_start - ldr r0, intr_orig_return - bx r0 - -code_handler_start: - stmdb sp!, {r0-r12} - mov r9, #0x00000000 @ offset register - mov r8, #0x00000000 @ execution status. bit0: 1 = no exec, 0 = exec. allows nested ifs 32 deep - mov r7, #0x00000000 @ Dx loop start - mov r6, #0x00000000 @ Dx repeat ammount - mov r5, #0x00000000 @ DX data - mov r4, #0x00000000 @ Dx execution status - -@ increment counter - ldrh r0, counter_value - add r0, r0, #1 - strh r0, counter_value - -@ r0-r3 are generic registers for the code processor to use -@ 0xCF000000 0x00000000 indicates the end of the code list -@ r12 points to the next code to load - - adr r12, cheat_data - -main_loop: - ldmia r12!, {r10, r11} @ load a code - cmp r10, #0xCF000000 - beq exit - - mov r0, r10, lsr #28 - cmp r0, #0xE - beq patch_code - cmp r0, #0xD - beq dx_codes - cmp r0, #0xC - beq type_c - -@ check execution status - tst r8, #0x00000001 - bne main_loop - -@ check code group - cmp r0, #0x3 - blt raw_write - cmp r0, #0x6 - ble if_32bit - cmp r0, #0xB - blt if_16bit_mask - beq offset_load - b mem_copy_code - - -counter_value: - .word 0x00000000 - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type 0-2 - -raw_write: - cmp r0, #0x1 - bic r10, r10, #0xf0000000 - strlt r11, [r10, r9] @ type 0 - streqh r11, [r10, r9] @ type 1 - strgtb r11, [r10, r9] @ type 2 - b main_loop - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type 3-6 -@ r0 still contains the code type - -if_32bit: - bic r1, r10, #0xf0000001 - tst r10, #0x00000001 - addne r1, r1, r9 @ add offset to the address if the lowest bit is set - cmp r1, #0x00000000 - moveq r1, r9 @ if address is 0, set address to offset - ldr r1, [r1] @ load word from [0XXXXXXX] - mov r8, r8, lsl #1 @ push execution status - cmp r0, #0x3 - beq if_32bit_bhi - cmp r0, #0x5 - blt if_32bit_bcc - beq if_32bit_beq - @ fall through to if_32bit_bne - -@ type 6 -if_32bit_bne: - cmp r11, r1 - orreq r8, r8, #0x00000001 - b main_loop - -@ type 3 -if_32bit_bhi: - cmp r11, r1 - orrls r8, r8, #0x00000001 - b main_loop - -@ type 4 -if_32bit_bcc: - cmp r11, r1 - orrcs r8, r8, #0x00000001 - b main_loop - -@ type 5 -if_32bit_beq: - cmp r11, r1 - orrne r8, r8, #0x00000001 - b main_loop - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type 7-A -@ r0 still contains the code type - -if_16bit_mask: - bic r1, r10, #0xf0000001 - tst r10, #0x00000001 - addne r1, r1, r9 @ add offset to the address if the lowest bit is set - cmp r1, #0x00000000 - moveq r1, r9 @ if address is 0, set address to offset - ldrh r1, [r1] @ load halfword from [0XXXXXXX] - mov r2, r11, lsr #16 @ bit mask - mov r3, r11, lsl #16 @ compare data - mov r3, r3, lsr #16 - bic r1, r1, r2 @ clear any bit that is set in the mask - - mov r8, r8, lsl #1 @ push execution status - cmp r0, #0x7 - beq if_16bit_bhi - cmp r0, #0x9 - blt if_16bit_bcc - beq if_16bit_beq - @ fall through to if_16bit_bne - -@ type A -if_16bit_bne: - cmp r3, r1 - orreq r8, r8, #0x00000001 - b main_loop - -@ type 7 -if_16bit_bhi: - cmp r3, r1 - orrls r8, r8, #0x00000001 - b main_loop - -@ type 8 -if_16bit_bcc: - cmp r3, r1 - orrcs r8, r8, #0x00000001 - b main_loop - -@ type 9 -if_16bit_beq: - cmp r3, r1 - orrne r8, r8, #0x00000001 - b main_loop - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type B - -offset_load: - bic r10, r10, #0xf0000000 - ldr r9, [r10, r9] - b main_loop - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type C - -type_c: - mov r0, r10, lsr #24 - cmp r0, #0xC1 - beq exec_remote_function - cmp r0, #0xC2 - beq exec_custom_function - - tst r8, #0x00000001 @ make sure execution is enabled - bne main_loop - - cmp r0, #0xC0 - beq loop_start - cmp r0, #0xC5 - beq execution_counter @ type C5 - -offset_data_store: @ type C4 - sublt r9, r12, #0x08 @ Offset = Two words back from current code pointer (ie, word at C4000000 code) - -save_offset: @ type C6 - strgt r9, [r11] @ Save offset to [XXXXXXXX] in C6000000 XXXXXXXX - b main_loop - -loop_start: - mov r4, r8 @ execution status - mov r6, r11 @ loop repeat amount - mov r7, r12 @ loop start - b main_loop - -exec_remote_function: - ldmia r12, {r0, r1, r2, r3} @ load arguments - and r10, r10, #0x00000007 - add r12, r12, r10 @ move code pointer to where it should be - tst r8, #0x00000001 - bne align_cheat_list @ execution disabled - stmdb sp!, {r12} - adr lr, exec_function_return - bx r11 - -exec_custom_function: - and r0, r10, #0x00000001 @ thumb mode? - add r0, r0, r12 @ custom function location - add r12, r12, r11 - tst r8, #0x00000001 - bne align_cheat_list @ execution disabled - stmdb sp!, {r12} - adr lr, exec_function_return - bx r0 - -exec_function_return: - ldmia sp!, {r12} - b align_cheat_list - - -execution_counter: - ldr r0, counter_value @ we only need the low 16 bits but counter_value is out of immediate range for ldrh - mov r1, r11, lsl #16 - and r0, r0, r1, lsr #16 @ mask off counter - mov r8, r8, lsl #1 @ push execution status - cmp r0, r11, lsr #16 @ Compare against compare value component of code - orrne r8, r8, #0x00000001 @ set execution to false - b main_loop - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type D - -dx_codes: - mov r0, r10, lsr #24 - cmp r0, #0xD3 - bcs dx_conditional_exec - - cmp r0, #0xD1 - bgt end_loop_clear - beq end_loop_no_clear - @ fall through to end_if - -@ type D0 -end_if: - mov r8, r8, lsr #1 @ pop exec status - b main_loop - -@ type D2 -end_loop_clear: - mov r8, r4 @ restore the old execution status - cmp r6, #0 @ end of a loop? - @ no - subgt r6, r6, #1 - movgt r12, r7 @ load the Dx loop start - bgt main_loop - @ yes - mov r5, #0 @ clear Dx data register - mov r8, #0 @ clear execution status - mov r9, #0 @ clear offset - b main_loop - -@ type D1 -end_loop_no_clear: - mov r8, r4 @ restore the old execution status - cmp r6, #0 @ end of a loop? - @ no - subgt r6, r6, #1 - movgt r12, r7 @ load the Dx loop start - @ yes - b main_loop - -dx_conditional_exec: - tst r8, #0x00000001 - bne main_loop - - cmp r0, #0xD6 - bcs dx_write - - cmp r0, #0xD4 -@ type D3 - Offset Set - movlt r9, r11 - beq dx_data_op -@ type D5 - Dx Data set - movgt r5, r11 - b main_loop - -dx_write: - cmp r0, #0xD9 - bcs dx_load - - cmp r0, #0xD7 -@ type D6 - Dx Data write 32 bits - strlt r5, [r11, r9] - addlt r9, r9, #4 -@ type D7 - Dx Data write 16 bits - streqh r5, [r11, r9] - addeq r9, r9, #2 -@ type D8 - Dx Data write 8 bits - strgtb r5, [r11, r9] - addgt r9, r9, #1 - b main_loop - -dx_load: - cmp r0, #0xDC - bcs dx_offset_add_addr - - cmp r0, #0xDA -@ type D9 - Dx Data load 32 bits - ldrlt r5, [r11, r9] -@ type DA - Dx Data load 16 bits - ldreqh r5, [r11, r9] -@ type DB - Dx Data load 8 bits - ldrgtb r5, [r11, r9] - b main_loop - -@ type DC -dx_offset_add_addr: - add r9, r9, r11 - b main_loop - -@ type D4 -dx_data_op: - and r0, r10, #0x000000ff - cmp r0, #0x01 -@ type D4000000 - add, use negative values for sub - addlt r5, r5, r11 -@ type D4000001 - or - orreq r5, r5, r11 - ble main_loop - - cmp r0, #0x03 -@ type D4000002 - and - andlt r5, r5, r11 -@ type D4000003 - xor - eoreq r5, r5, r11 - ble main_loop - - cmp r0, #0x05 -@ type D4000004 - lsl - movlt r5, r5, lsl r11 -@ type D4000005 - lsr - moveq r5, r5, lsr r11 - ble main_loop - - cmp r0, #0x07 -@ type D4000006 - ror - movlt r5, r5, ror r11 -@ type D4000007 - asr - moveq r5, r5, asr r11 - ble main_loop - - cmp r0, #0x09 -@ type D4000008 - mul - mullt r5, r11, r5 - - b main_loop - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type E - -patch_code: - @ check execution status - tst r8, #0x00000001 - addne r12, r12, r11 @ skip the data section - bne align_cheat_list - - bic r10, r10, #0xf0000000 @ destination address - add r10, r10, r9 @ add offset to dest - @ r11 is bytes remaining - @ r12 is source - -patch_code_word_loop: - cmp r11, #4 - blt patch_code_byte_loop - ldr r1, [r12], #4 - str r1, [r10], #4 - sub r11, r11, #4 - b patch_code_word_loop - -patch_code_byte_loop: - cmp r11, #1 - blt align_cheat_list @ patch_code_end - ldrb r1, [r12], #1 - strb r1, [r10], #1 - sub r11, r11, #1 - b patch_code_byte_loop - -align_cheat_list: - add r12, r12, #0x7 - bic r12, r12, #0x00000007 @ round up to nearest multiple of 8 - b main_loop - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -@ type F - -mem_copy_code: - bic r10, r10, #0xf0000000 @ destination address - @ r11 is bytes remaining - mov r2, r9 @ source address - -mem_copy_code_word_loop: - cmp r11, #4 - blt mem_copy_code_byte_loop - ldr r1, [r2], #4 - str r1, [r10], #4 - sub r11, r11, #4 - b mem_copy_code_word_loop - -mem_copy_code_byte_loop: - cmp r11, #1 - blt main_loop @ mem_copy_code_end - ldrb r1, [r2], #1 - strb r1, [r10], #1 - sub r11, r11, #1 - b mem_copy_code_byte_loop - - -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - -exit: - ldmia sp!, {r0-r12} - ldmia sp!, {lr} - bx lr - -intr_orig_return: - .word 0x00000000 - -.pool - -cheat_data: - -cheat_engine_end: - -@ Cheat data goes here - - .word 0xCF000000, 0x00000000 - .word 0x00000000, 0x00000000 - .word 0x00000000, 0x00000000 - .word 0x00000000, 0x00000000 - - diff --git a/BootLoader/source/clear_mem.s b/BootLoader/source/clear_mem.s index 2b47517..d853bbc 100755 --- a/BootLoader/source/clear_mem.s +++ b/BootLoader/source/clear_mem.s @@ -32,9 +32,9 @@ arm7_clearmem: mov r8, #0 mov r9, #0 -clearmem_loop: - stmia r0!, {r2-r9} cmp r0, r1 - blt clearmem_loop +clearmem_loop: + stmia r0!, {r2-r9} cmp r0, r1 + blt clearmem_loop ldmfd sp!, {r4-r9} bx lr diff --git a/BootLoader/source/encryption.c b/BootLoader/source/encryption.c index 37523ac..88c0deb 100755 --- a/BootLoader/source/encryption.c +++ b/BootLoader/source/encryption.c @@ -19,6 +19,7 @@ #include #include "encryption.h" #include "read_bios.h" +#include "key1.h" #define KEYSIZE 0x1048 @@ -97,7 +98,7 @@ void apply_keycode (u32 modulo) { } void init_keycode (u32 idcode, u32 level, u32 modulo) { - readBios ((u8*)keybuf, 0x30, KEYSIZE); + memcpy ((u8*)keybuf, gEncrData, KEYSIZE); keycode[0] = idcode; keycode[1] = idcode/2; keycode[2] = idcode*2; diff --git a/BootLoader/source/key1.h b/BootLoader/source/key1.h new file mode 100644 index 0000000..5f39c14 --- /dev/null +++ b/BootLoader/source/key1.h @@ -0,0 +1,264 @@ +const unsigned char gEncrData[] = +{ + 0x99,0xD5,0x20,0x5F,0x57,0x44,0xF5,0xB9,0x6E,0x19,0xA4,0xD9,0x9E,0x6A,0x5A,0x94, + 0xD8,0xAE,0xF1,0xEB,0x41,0x75,0xE2,0x3A,0x93,0x82,0xD0,0x32,0x33,0xEE,0x31,0xD5, + 0xCC,0x57,0x61,0x9A,0x37,0x06,0xA2,0x1B,0x79,0x39,0x72,0xF5,0x55,0xAE,0xF6,0xBE, + 0x5F,0x1B,0x69,0xFB,0xE5,0x9D,0xF1,0xE9,0xCE,0x2C,0xD9,0xA1,0x5E,0x32,0x05,0xE6, + 0xFE,0xD3,0xFE,0xCF,0xD4,0x62,0x04,0x0D,0x8B,0xF5,0xEC,0xB7,0x2B,0x60,0x79,0xBB, + 0x12,0x95,0x31,0x0D,0x6E,0x3F,0xDA,0x2B,0x88,0x84,0xF0,0xF1,0x3D,0x12,0x7E,0x25, + 0x45,0x22,0xF1,0xBB,0x24,0x06,0x1A,0x06,0x11,0xAD,0xDF,0x28,0x8B,0x64,0x81,0x34, + 0x2B,0xEB,0x33,0x29,0x99,0xAA,0xF2,0xBD,0x9C,0x14,0x95,0x9D,0x9F,0xF7,0xF5,0x8C, + 0x72,0x97,0xA1,0x29,0x9D,0xD1,0x5F,0xCF,0x66,0x4D,0x07,0x1A,0xDE,0xD3,0x4A,0x4B, + 0x85,0xC9,0xA7,0xA3,0x17,0x95,0x05,0x3A,0x3D,0x49,0x0A,0xBF,0x0A,0x89,0x8B,0xA2, + 0x4A,0x82,0x49,0xDD,0x27,0x90,0xF1,0x0B,0xE9,0xEB,0x1C,0x6A,0x83,0x76,0x45,0x05, + 0xBA,0x81,0x70,0x61,0x17,0x3F,0x4B,0xDE,0xAE,0xCF,0xAB,0x39,0x57,0xF2,0x3A,0x56, + 0x48,0x11,0xAD,0x8A,0x40,0xE1,0x45,0x3F,0xFA,0x9B,0x02,0x54,0xCA,0xA6,0x93,0xFB, + 0xEF,0x4D,0xFE,0x6F,0xA3,0xD8,0x87,0x9C,0x08,0xBA,0xD5,0x48,0x6A,0x8D,0x2D,0xFD, + 0x6E,0x15,0xF8,0x74,0xBD,0xBE,0x52,0x8B,0x18,0x22,0x8A,0x9E,0xFB,0x74,0x37,0x07, + 0x1B,0x36,0x6C,0x4A,0x19,0xBA,0x42,0x62,0xB9,0x79,0x91,0x10,0x7B,0x67,0x65,0x96, + 0xFE,0x02,0x23,0xE8,0xEE,0x99,0x8C,0x77,0x3E,0x5C,0x86,0x64,0x4D,0x6D,0x78,0x86, + 0xA5,0x4F,0x65,0xE2,0x1E,0xB2,0xDF,0x5A,0x0A,0xD0,0x7E,0x08,0x14,0xB0,0x71,0xAC, + 0xBD,0xDB,0x83,0x1C,0xB9,0xD7,0xA1,0x62,0xCD,0xC6,0x63,0x7C,0x52,0x69,0xC3,0xE6, + 0xBF,0x75,0xCE,0x12,0x44,0x5D,0x21,0x04,0xFA,0xFB,0xD3,0x3C,0x38,0x11,0x63,0xD4, + 0x95,0x85,0x41,0x49,0x46,0x09,0xF2,0x08,0x43,0x11,0xDC,0x1F,0x76,0xC0,0x15,0x6D, + 0x1F,0x3C,0x63,0x70,0xEA,0x87,0x80,0x6C,0xC3,0xBD,0x63,0x8B,0xC2,0x37,0x21,0x37, + 0xDC,0xEE,0x09,0x23,0x2E,0x37,0x6A,0x4D,0x73,0x90,0xF7,0x50,0x30,0xAC,0x1C,0x92, + 0x04,0x10,0x23,0x91,0x4F,0xD2,0x07,0xAA,0x68,0x3E,0x4F,0x9A,0xC9,0x64,0x60,0x6A, + 0xC8,0x14,0x21,0xF3,0xD6,0x22,0x41,0x12,0x44,0x24,0xCF,0xE6,0x8A,0x56,0xDD,0x0D, + 0x53,0x4D,0xE1,0x85,0x1E,0x8C,0x52,0x5A,0x9C,0x19,0x84,0xC2,0x03,0x57,0xF1,0x6F, + 0xE3,0x00,0xBE,0x58,0xF6,0x4C,0xED,0xD5,0x21,0x64,0x9C,0x1F,0xBE,0x55,0x03,0x3C, + 0x4A,0xDC,0xFF,0xAA,0xC9,0xDA,0xE0,0x5D,0x5E,0xBF,0xE6,0xDE,0xF5,0xD8,0xB1,0xF8, + 0xFF,0x36,0xB3,0xB9,0x62,0x67,0x95,0xDB,0x31,0x5F,0x37,0xED,0x4C,0x70,0x67,0x99, + 0x90,0xB5,0x18,0x31,0x6C,0x3D,0x99,0x99,0xE4,0x42,0xDA,0xD3,0x25,0x42,0x13,0xA0, + 0xAE,0xD7,0x70,0x6C,0xB1,0x55,0xCF,0xC7,0xD7,0x46,0xD5,0x43,0x61,0x17,0x3D,0x44, + 0x28,0xE9,0x33,0x85,0xD5,0xD0,0xA2,0x93,0xAA,0x25,0x12,0x1F,0xFB,0xC5,0x0B,0x46, + 0xF5,0x97,0x76,0x56,0x45,0xA6,0xBE,0x87,0xB1,0x94,0x6B,0xE8,0xB1,0xFE,0x33,0x99, + 0xAE,0x1F,0x3E,0x6C,0x39,0x71,0x1D,0x09,0x00,0x90,0x37,0xE4,0x10,0x3E,0x75,0x74, + 0xFF,0x8C,0x83,0x3B,0xB0,0xF1,0xB0,0xF9,0x01,0x05,0x47,0x42,0x95,0xF1,0xD6,0xAC, + 0x7E,0x38,0xE6,0x9E,0x95,0x74,0x26,0x3F,0xB4,0x68,0x50,0x18,0xD0,0x43,0x30,0xB4, + 0x4C,0x4B,0xE3,0x68,0xBF,0xE5,0x4D,0xB6,0x95,0x8B,0x0A,0xA0,0x74,0x25,0x32,0x77, + 0xCF,0xA1,0xF7,0x2C,0xD8,0x71,0x13,0x5A,0xAB,0xEA,0xC9,0x51,0xE8,0x0D,0xEE,0xEF, + 0xE9,0x93,0x7E,0x19,0xA7,0x1E,0x43,0x38,0x81,0x16,0x2C,0xA1,0x48,0xE3,0x73,0xCC, + 0x29,0x21,0x6C,0xD3,0x5D,0xCE,0xA0,0xD9,0x61,0x71,0x43,0xA0,0x15,0x13,0xB5,0x64, + 0x92,0xCF,0x2A,0x19,0xDC,0xAD,0xB7,0xA5,0x9F,0x86,0x65,0xF8,0x1A,0x9F,0xE7,0xFB, + 0xF7,0xFD,0xB8,0x13,0x6C,0x27,0xDB,0x6F,0xDF,0x35,0x1C,0xF7,0x8D,0x2C,0x5B,0x9B, + 0x12,0xAB,0x38,0x64,0x06,0xCC,0xDE,0x31,0xE8,0x4E,0x75,0x11,0x64,0xE3,0xFA,0xEA, + 0xEB,0x34,0x54,0xC2,0xAD,0x3F,0x34,0xEB,0x93,0x2C,0x7D,0x26,0x36,0x9D,0x56,0xF3, + 0x5A,0xE1,0xF6,0xB3,0x98,0x63,0x4A,0x9E,0x32,0x83,0xE4,0x9A,0x84,0x60,0x7D,0x90, + 0x2E,0x13,0x0E,0xEE,0x93,0x4B,0x36,0xA2,0x85,0xEC,0x16,0x38,0xE8,0x88,0x06,0x02, + 0xBF,0xF0,0xA0,0x3A,0xED,0xD7,0x6A,0x9A,0x73,0xE1,0x57,0xCF,0xF8,0x44,0xB8,0xDC, + 0x2E,0x23,0x59,0xD1,0xDF,0x95,0x52,0x71,0x99,0x61,0xA0,0x4B,0xD5,0x7F,0x6E,0x78, + 0xBA,0xA9,0xC5,0x30,0xD3,0x40,0x86,0x32,0x9D,0x32,0x0C,0x9C,0x37,0xB7,0x02,0x2F, + 0xBA,0x54,0x98,0xA9,0xC4,0x13,0x04,0xC9,0x8D,0xBE,0xC8,0xE7,0x5D,0x97,0x50,0x2E, + 0x93,0xD6,0x22,0x59,0x0C,0x27,0xBC,0x22,0x92,0xE0,0xA7,0x20,0x0F,0x93,0x6F,0x7F, + 0x4C,0x9F,0xD3,0xB5,0xA6,0x2A,0x0B,0x74,0x67,0x49,0x7D,0x10,0x26,0xCB,0xD1,0xC5, + 0x86,0x71,0xE7,0x8C,0xA0,0x9C,0xE9,0x5B,0xB2,0x1A,0xF6,0x01,0xEE,0x8C,0x9E,0x5E, + 0x83,0xF2,0x1A,0xDB,0xE6,0xE5,0xEA,0x84,0x59,0x76,0xD2,0x7C,0xF6,0x8D,0xA5,0x49, + 0x36,0x48,0xC2,0x16,0x52,0xBB,0x83,0xA3,0x74,0xB9,0x07,0x0C,0x3B,0xFF,0x61,0x28, + 0xE1,0x61,0xE9,0xE4,0xEF,0x6E,0x15,0xAA,0x4E,0xBA,0xE8,0x5D,0x05,0x96,0xBB,0x32, + 0x56,0xB0,0xFB,0x72,0x52,0x0F,0x0E,0xC8,0x42,0x25,0x65,0x76,0x89,0xAF,0xF2,0xDE, + 0x10,0x27,0xF0,0x01,0x4B,0x74,0xA7,0x97,0x07,0xD5,0x26,0x54,0x54,0x09,0x1F,0x82, + 0x0A,0x86,0x7D,0x30,0x39,0x0E,0xB3,0x26,0x9B,0x0B,0x57,0xBB,0x36,0x06,0x31,0xAF, + 0xFD,0x79,0xFC,0xD9,0x30,0x10,0x2B,0x0C,0xB3,0xE1,0x9B,0xD7,0x7B,0xDC,0x5F,0xEF, + 0xD2,0xF8,0x13,0x45,0x4D,0x47,0x75,0xBD,0x46,0x96,0x3C,0x7E,0x75,0xF3,0x3E,0xB5, + 0x67,0xC5,0x9A,0x3B,0xB0,0x5B,0x29,0x6B,0xDE,0x80,0x5B,0xC8,0x15,0x05,0xB1,0x31, + 0xB6,0xCE,0x49,0xDD,0xAD,0x84,0xB5,0xAE,0x60,0xDC,0x67,0x31,0x34,0x30,0xFE,0x4E, + 0xBD,0x80,0x2F,0xA6,0xBF,0x63,0x39,0x21,0x86,0xD9,0x35,0x7F,0x16,0x68,0x22,0x05, + 0x54,0xE9,0x90,0x26,0x8C,0x07,0x6C,0x51,0xA4,0x31,0x55,0xD7,0x09,0x07,0xA8,0x3E, + 0x2E,0x53,0x66,0xC1,0xF8,0xF2,0x7B,0xC4,0xF2,0x58,0xCF,0xF1,0x87,0xC5,0xA2,0xE7, + 0x27,0x8F,0x30,0x87,0x58,0xA0,0x64,0x62,0x23,0x18,0xB9,0x88,0x7C,0xFA,0xCE,0xC4, + 0x98,0xAE,0xAD,0x17,0xCC,0x4A,0x5B,0xF3,0xE9,0x48,0xD5,0x56,0xD3,0x0D,0xF2,0xC8, + 0x92,0x73,0x8C,0xDB,0xD7,0x2F,0x56,0xAC,0x81,0xF9,0x92,0x69,0x4D,0xC6,0x32,0xF6, + 0xE6,0xC0,0x8D,0x21,0xE2,0x76,0x80,0x61,0x11,0xBC,0xDC,0x6C,0x93,0xAF,0x19,0x69, + 0x9B,0xD0,0xBF,0xB9,0x31,0x9F,0x02,0x67,0xA3,0x51,0xEE,0x83,0x06,0x22,0x7B,0x0C, + 0xAB,0x49,0x42,0x40,0xB8,0xD5,0x01,0x7D,0xCE,0x5E,0xF7,0x55,0x53,0x39,0xC5,0x99, + 0x46,0xD8,0x87,0x9F,0xBA,0xF7,0x64,0xB4,0xE3,0x9A,0xFA,0xA1,0x6D,0x90,0x68,0x10, + 0x30,0xCA,0x8A,0x54,0xA7,0x9F,0x60,0xC3,0x19,0xF5,0x6B,0x0D,0x7A,0x51,0x98,0xE6, + 0x98,0x43,0x51,0xB4,0xD6,0x35,0xE9,0x4F,0xC3,0xDF,0x0F,0x7B,0xD6,0x2F,0x5C,0xBD, + 0x3A,0x15,0x61,0x19,0xF1,0x4B,0xCB,0xAA,0xDC,0x6D,0x64,0xC9,0xD3,0xC6,0x1E,0x56, + 0xEF,0x38,0x4C,0x50,0x71,0x86,0x75,0xCC,0x0D,0x0D,0x4E,0xE9,0x28,0xF6,0x06,0x5D, + 0x70,0x1B,0xAA,0xD3,0x45,0xCF,0xA8,0x39,0xAC,0x95,0xA6,0x2E,0xB4,0xE4,0x22,0xD4, + 0x74,0xA8,0x37,0x5F,0x48,0x7A,0x04,0xCC,0xA5,0x4C,0x40,0xD8,0x28,0xB4,0x28,0x08, + 0x0D,0x1C,0x72,0x52,0x41,0xF0,0x7D,0x47,0x19,0x3A,0x53,0x4E,0x58,0x84,0x62,0x6B, + 0x93,0xB5,0x8A,0x81,0x21,0x4E,0x0D,0xDC,0xB4,0x3F,0xA2,0xC6,0xFC,0xC9,0x2B,0x40, + 0xDA,0x38,0x04,0xE9,0x5E,0x5A,0x86,0x6B,0x0C,0x22,0x25,0x85,0x68,0x11,0x8D,0x7C, + 0x92,0x1D,0x95,0x55,0x4D,0xAB,0x8E,0xBB,0xDA,0xA6,0xE6,0xB7,0x51,0xB6,0x32,0x5A, + 0x05,0x41,0xDD,0x05,0x2A,0x0A,0x56,0x50,0x91,0x17,0x47,0xCC,0xC9,0xE6,0x7E,0xB5, + 0x61,0x4A,0xDB,0x73,0x67,0x51,0xC8,0x33,0xF5,0xDA,0x6E,0x74,0x2E,0x54,0xC3,0x37, + 0x0D,0x6D,0xAF,0x08,0xE8,0x15,0x8A,0x5F,0xE2,0x59,0x21,0xCD,0xA8,0xDE,0x0C,0x06, + 0x5A,0x77,0x6B,0x5F,0xDB,0x18,0x65,0x3E,0xC8,0x50,0xDE,0x78,0xE0,0xB8,0x82,0xB3, + 0x5D,0x4E,0x72,0x32,0x07,0x4F,0xC1,0x34,0x23,0xBA,0x96,0xB7,0x67,0x4E,0xA4,0x28, + 0x1E,0x34,0x62,0xEB,0x2D,0x6A,0x70,0xE9,0x2F,0x42,0xC4,0x70,0x4E,0x5A,0x31,0x9C, + 0xF9,0x5B,0x47,0x28,0xAA,0xDA,0x71,0x6F,0x38,0x1F,0xB3,0x78,0xC4,0x92,0x6B,0x1C, + 0x9E,0xF6,0x35,0x9A,0xB7,0x4D,0x0E,0xBF,0xCC,0x18,0x29,0x41,0x03,0x48,0x35,0x5D, + 0x55,0xD0,0x2B,0xC6,0x29,0xAF,0x5C,0x60,0x74,0x69,0x8E,0x5E,0x9B,0x7C,0xD4,0xBD, + 0x7B,0x44,0x64,0x7D,0x3F,0x92,0x5D,0x69,0xB6,0x1F,0x00,0x4B,0xD4,0x83,0x35,0xCF, + 0x7E,0x64,0x4E,0x17,0xAE,0x8D,0xD5,0x2E,0x9A,0x28,0x12,0x4E,0x2E,0x2B,0x49,0x08, + 0x5C,0xAE,0xC6,0x46,0x85,0xAE,0x41,0x61,0x1E,0x6F,0x82,0xD2,0x51,0x37,0x16,0x1F, + 0x0B,0xF6,0x59,0xA4,0x9A,0xCA,0x5A,0xAF,0x0D,0xD4,0x33,0x8B,0x20,0x63,0xF1,0x84, + 0x80,0x5C,0xCB,0xCF,0x08,0xB4,0xB9,0xD3,0x16,0x05,0xBD,0x62,0x83,0x31,0x9B,0x56, + 0x51,0x98,0x9F,0xBA,0xB2,0x5B,0xAA,0xB2,0x22,0x6B,0x2C,0xB5,0xD4,0x48,0xFA,0x63, + 0x2B,0x5F,0x58,0xFA,0x61,0xFA,0x64,0x09,0xBB,0x38,0xE0,0xB8,0x9D,0x92,0x60,0xA8, + 0x0D,0x67,0x6F,0x0E,0x37,0xF5,0x0D,0x01,0x9F,0xC2,0x77,0xD4,0xFE,0xEC,0xF1,0x73, + 0x30,0x39,0xE0,0x7D,0xF5,0x61,0x98,0xE4,0x2C,0x28,0x55,0x04,0x56,0x55,0xDB,0x2F, + 0x6B,0xEC,0xE5,0x58,0x06,0xB6,0x64,0x80,0x6A,0x2A,0x1A,0x4E,0x5B,0x0F,0xD8,0xC4, + 0x0A,0x2E,0x52,0x19,0xD9,0x62,0xF5,0x30,0x48,0xBE,0x8C,0x7B,0x4F,0x38,0x9B,0xA2, + 0xC3,0xAF,0xC9,0xD3,0xC7,0xC1,0x62,0x41,0x86,0xB9,0x61,0x21,0x57,0x6F,0x99,0x4F, + 0xC1,0xBA,0xCE,0x7B,0xB5,0x3B,0x4D,0x5E,0x8A,0x8B,0x44,0x57,0x5F,0x13,0x5F,0x70, + 0x6D,0x5B,0x29,0x47,0xDC,0x38,0xE2,0xEC,0x04,0x55,0x65,0x12,0x2A,0xE8,0x17,0x43, + 0xE1,0x8E,0xDD,0x2A,0xB3,0xE2,0x94,0xF7,0x09,0x6E,0x5C,0xE6,0xEB,0x8A,0xF8,0x6D, + 0x89,0x49,0x54,0x48,0xF5,0x2F,0xAD,0xBF,0xEA,0x94,0x4B,0xCA,0xFC,0x39,0x87,0x82, + 0x5F,0x8A,0x01,0xF2,0x75,0xF2,0xE6,0x71,0xD6,0xD8,0x42,0xDE,0xF1,0x2D,0x1D,0x28, + 0xA6,0x88,0x7E,0xA3,0xA0,0x47,0x1D,0x30,0xD9,0xA3,0x71,0xDF,0x49,0x1C,0xCB,0x01, + 0xF8,0x36,0xB1,0xF2,0xF0,0x22,0x58,0x5D,0x45,0x6B,0xBD,0xA0,0xBB,0xB2,0x88,0x42, + 0xC7,0x8C,0x28,0xCE,0x93,0xE8,0x90,0x63,0x08,0x90,0x7C,0x89,0x3C,0xF5,0x7D,0xB7, + 0x04,0x2D,0x4F,0x55,0x51,0x16,0xFD,0x7E,0x79,0xE8,0xBE,0xC1,0xF2,0x12,0xD4,0xF8, + 0xB4,0x84,0x05,0x23,0xA0,0xCC,0xD2,0x2B,0xFD,0xE1,0xAB,0xAD,0x0D,0xD1,0x55,0x6C, + 0x23,0x41,0x94,0x4D,0x77,0x37,0x4F,0x05,0x28,0x0C,0xBF,0x17,0xB3,0x12,0x67,0x6C, + 0x8C,0xC3,0x5A,0xF7,0x41,0x84,0x2A,0x6D,0xD0,0x94,0x12,0x27,0x2C,0xB4,0xED,0x9C, + 0x4D,0xEC,0x47,0x82,0x97,0xD5,0x67,0xB9,0x1B,0x9D,0xC0,0x55,0x07,0x7E,0xE5,0x8E, + 0xE2,0xA8,0xE7,0x3E,0x12,0xE4,0x0E,0x3A,0x2A,0x45,0x55,0x34,0xA2,0xF9,0x2D,0x5A, + 0x1B,0xAB,0x52,0x7C,0x83,0x10,0x5F,0x55,0xD2,0xF1,0x5A,0x43,0x2B,0xC6,0xA7,0xA4, + 0x89,0x15,0x95,0xE8,0xB4,0x4B,0x9D,0xF8,0x75,0xE3,0x9F,0x60,0x78,0x5B,0xD6,0xE6, + 0x0D,0x44,0xE6,0x21,0x06,0xBD,0x47,0x22,0x53,0xA4,0x00,0xAD,0x8D,0x43,0x13,0x85, + 0x39,0xF7,0xAA,0xFC,0x38,0xAF,0x7B,0xED,0xFC,0xE4,0x2B,0x54,0x50,0x98,0x4C,0xFC, + 0x85,0x80,0xF7,0xDF,0x3C,0x80,0x22,0xE1,0x94,0xDA,0xDE,0x24,0xC6,0xB0,0x7A,0x39, + 0x38,0xDC,0x0F,0xA1,0xA7,0xF4,0xF9,0x6F,0x63,0x18,0x57,0x8B,0x84,0x41,0x2A,0x2E, + 0xD4,0x53,0xF2,0xD9,0x00,0x0F,0xD0,0xDD,0x99,0x6E,0x19,0xA6,0x0A,0xD0,0xEC,0x5B, + 0x58,0x24,0xAB,0xC0,0xCB,0x06,0x65,0xEC,0x1A,0x13,0x38,0x94,0x0A,0x67,0x03,0x2F, + 0x3F,0xF7,0xE3,0x77,0x44,0x77,0x33,0xC6,0x14,0x39,0xD0,0xE3,0xC0,0xA2,0x08,0x79, + 0xBB,0x40,0x99,0x57,0x41,0x0B,0x01,0x90,0xCD,0xE1,0xCC,0x48,0x67,0xDB,0xB3,0xAF, + 0x88,0x74,0xF3,0x4C,0x82,0x8F,0x72,0xB1,0xB5,0x23,0x29,0xC4,0x12,0x6C,0x19,0xFC, + 0x8E,0x46,0xA4,0x9C,0xC4,0x25,0x65,0x87,0xD3,0x6D,0xBE,0x8A,0x93,0x11,0x03,0x38, + 0xED,0x83,0x2B,0xF3,0x46,0xA4,0x93,0xEA,0x3B,0x53,0x85,0x1D,0xCE,0xD4,0xF1,0x08, + 0x83,0x27,0xED,0xFC,0x9B,0x1A,0x18,0xBC,0xF9,0x8B,0xAE,0xDC,0x24,0xAB,0x50,0x38, + 0xE9,0x72,0x4B,0x10,0x22,0x17,0x7B,0x46,0x5D,0xAB,0x59,0x64,0xF3,0x40,0xAE,0xF8, + 0xBB,0xE5,0xC8,0xF9,0x26,0x03,0x4E,0x55,0x7D,0xEB,0xEB,0xFE,0xF7,0x39,0xE6,0xE0, + 0x0A,0x11,0xBE,0x2E,0x28,0xFF,0x98,0xED,0xC0,0xC9,0x42,0x56,0x42,0xC3,0xFD,0x00, + 0xF6,0xAF,0x87,0xA2,0x5B,0x01,0x3F,0x32,0x92,0x47,0x95,0x9A,0x72,0xA5,0x32,0x3D, + 0xAE,0x6B,0xD0,0x9B,0x07,0xD2,0x49,0x92,0xE3,0x78,0x4A,0xFA,0xA1,0x06,0x7D,0xF2, + 0x41,0xCF,0x77,0x74,0x04,0x14,0xB2,0x0C,0x86,0x84,0x64,0x16,0xD5,0xBB,0x51,0xA1, + 0xE5,0x6F,0xF1,0xD1,0xF2,0xE2,0xF7,0x5F,0x58,0x20,0x4D,0xB8,0x57,0xC7,0xCF,0xDD, + 0xC5,0xD8,0xBE,0x76,0x3D,0xF6,0x5F,0x7E,0xE7,0x2A,0x8B,0x88,0x24,0x1B,0x38,0x3F, + 0x0E,0x41,0x23,0x77,0xF5,0xF0,0x4B,0xD4,0x0C,0x1F,0xFA,0xA4,0x0B,0x80,0x5F,0xCF, + 0x45,0xF6,0xE0,0xDA,0x2F,0x34,0x59,0x53,0xFB,0x20,0x3C,0x52,0x62,0x5E,0x35,0xB5, + 0x62,0xFE,0x8B,0x60,0x63,0xE3,0x86,0x5A,0x15,0x1A,0x6E,0xD1,0x47,0x45,0xBC,0x32, + 0xB4,0xEB,0x67,0x38,0xAB,0xE4,0x6E,0x33,0x3A,0xB5,0xED,0xA3,0xAD,0x67,0xE0,0x4E, + 0x41,0x95,0xEE,0x62,0x62,0x71,0x26,0x1D,0x31,0xEF,0x62,0x30,0xAF,0xD7,0x82,0xAC, + 0xC2,0xDC,0x05,0x04,0xF5,0x97,0x07,0xBF,0x11,0x59,0x23,0x07,0xC0,0x64,0x02,0xE8, + 0x97,0xE5,0x3E,0xAF,0x18,0xAC,0x59,0xA6,0x8B,0x4A,0x33,0x90,0x1C,0x6E,0x7C,0x9C, + 0x20,0x7E,0x4C,0x3C,0x3E,0x61,0x64,0xBB,0xC5,0x6B,0x7C,0x7E,0x3E,0x9F,0xC5,0x4C, + 0x9F,0xEA,0x73,0xF5,0xD7,0x89,0xC0,0x4C,0xF4,0xFB,0xF4,0x2D,0xEC,0x14,0x1B,0x51, + 0xD5,0xC1,0x12,0xC8,0x10,0xDF,0x0B,0x4A,0x8B,0x9C,0xBC,0x93,0x45,0x6A,0x3E,0x3E, + 0x7D,0xC1,0xA9,0xBA,0xCD,0xC1,0xB4,0x07,0xE4,0xE1,0x68,0x86,0x43,0xB2,0x6D,0x38, + 0xF3,0xFB,0x0C,0x5C,0x66,0x37,0x71,0xDE,0x56,0xEF,0x6E,0xA0,0x10,0x40,0x65,0xA7, + 0x98,0xF7,0xD0,0xBE,0x0E,0xC8,0x37,0x36,0xEC,0x10,0xCA,0x7C,0x9C,0xAB,0x84,0x1E, + 0x05,0x17,0x76,0x02,0x1C,0x4F,0x52,0xAA,0x5F,0xC1,0xC6,0xA0,0x56,0xB9,0xD8,0x04, + 0x84,0x44,0x4D,0xA7,0x59,0xD8,0xDE,0x60,0xE6,0x38,0x0E,0x05,0x8F,0x03,0xE1,0x3B, + 0x6D,0x81,0x04,0x33,0x6F,0x30,0x0B,0xCE,0x69,0x05,0x21,0x33,0xFB,0x26,0xBB,0x89, + 0x7D,0xB6,0xAE,0x87,0x7E,0x51,0x07,0xE0,0xAC,0xF7,0x96,0x0A,0x6B,0xF9,0xC4,0x5C, + 0x1D,0xE4,0x44,0x47,0xB8,0x5E,0xFA,0xE3,0x78,0x84,0x55,0x42,0x4B,0x48,0x5E,0xF7, + 0x7D,0x47,0x35,0x86,0x1D,0x2B,0x43,0x05,0x03,0xEC,0x8A,0xB8,0x1E,0x06,0x3C,0x76, + 0x0C,0x48,0x1A,0x43,0xA7,0xB7,0x8A,0xED,0x1E,0x13,0xC6,0x43,0xEE,0x10,0xEF,0xDB, + 0xEC,0xFB,0x3C,0x83,0xB2,0x95,0x44,0xEF,0xD8,0x54,0x51,0x4E,0x2D,0x11,0x44,0x1D, + 0xFB,0x36,0x59,0x1E,0x7A,0x34,0xC1,0xC3,0xCA,0x57,0x00,0x61,0xEA,0x67,0xA5,0x16, + 0x9B,0x55,0xD0,0x55,0xE1,0x7F,0xD9,0x36,0xD2,0x40,0x76,0xAE,0xDC,0x01,0xCE,0xB0, + 0x7A,0x83,0xD5,0xCB,0x20,0x98,0xEC,0x6B,0xC1,0x72,0x92,0x34,0xF3,0x82,0x57,0x37, + 0x62,0x8A,0x32,0x36,0x0C,0x90,0x43,0xAE,0xAE,0x5C,0x9B,0x78,0x8E,0x13,0x65,0x02, + 0xFD,0x68,0x71,0xC1,0xFE,0xB0,0x31,0xA0,0x24,0x82,0xB0,0xC3,0xB1,0x79,0x69,0xA7, + 0xF5,0xD2,0xEB,0xD0,0x82,0xC0,0x32,0xDC,0x9E,0xC7,0x26,0x3C,0x6D,0x8D,0x98,0xC1, + 0xBB,0x22,0xD4,0xD0,0x0F,0x33,0xEC,0x3E,0xB9,0xCC,0xE1,0xDC,0x6A,0x4C,0x77,0x36, + 0x14,0x1C,0xF9,0xBF,0x81,0x9F,0x28,0x5F,0x71,0x85,0x32,0x29,0x90,0x75,0x48,0xC4, + 0xB3,0x4A,0xCE,0xD8,0x44,0x8F,0x14,0x2F,0xFD,0x40,0x57,0xEF,0xAA,0x08,0x75,0xD9, + 0x46,0xD1,0xD6,0x6E,0x32,0x55,0x1F,0xC3,0x18,0xFE,0x84,0x1F,0xFC,0x84,0xD5,0xFF, + 0x71,0x5E,0x1B,0x48,0xC3,0x86,0x95,0x0E,0x28,0x08,0x27,0xD3,0x38,0x83,0x71,0x7B, + 0x4C,0x80,0x63,0x54,0x9A,0x56,0xB0,0xAC,0xCF,0x80,0xCA,0x31,0x09,0xEF,0xFE,0xF3, + 0xBE,0xAF,0x24,0x7E,0xA6,0xFE,0x53,0x3F,0xC2,0x8D,0x4A,0x33,0x68,0xD1,0x22,0xA6, + 0x66,0xAD,0x7B,0xEA,0xDE,0xB6,0x43,0xB0,0xA1,0x25,0x95,0x00,0xA3,0x3F,0x75,0x46, + 0x14,0x11,0x44,0xEC,0xD7,0x95,0xBC,0x92,0xF0,0x4F,0xA9,0x16,0x53,0x62,0x97,0x60, + 0x2A,0x0F,0x41,0xF1,0x71,0x24,0xBE,0xEE,0x94,0x7F,0x08,0xCD,0x60,0x93,0xB3,0x85, + 0x5B,0x07,0x00,0x3F,0xD8,0x0F,0x28,0x83,0x9A,0xD1,0x69,0x9F,0xD1,0xDA,0x2E,0xC3, + 0x90,0x01,0xA2,0xB9,0x6B,0x4E,0x2A,0x66,0x9D,0xDA,0xAE,0xA6,0xEA,0x2A,0xD3,0x68, + 0x2F,0x0C,0x0C,0x9C,0xD2,0x8C,0x4A,0xED,0xE2,0x9E,0x57,0x65,0x9D,0x09,0x87,0xA3, + 0xB4,0xC4,0x32,0x5D,0xC9,0xD4,0x32,0x2B,0xB1,0xE0,0x71,0x1E,0x64,0x4D,0xE6,0x90, + 0x71,0xE3,0x1E,0x40,0xED,0x7D,0xF3,0x84,0x0E,0xED,0xC8,0x78,0x76,0xAE,0xC0,0x71, + 0x27,0x72,0xBB,0x05,0xEA,0x02,0x64,0xFB,0xF3,0x48,0x6B,0xB5,0x42,0x93,0x3F,0xED, + 0x9F,0x13,0x53,0xD2,0xF7,0xFE,0x2A,0xEC,0x1D,0x47,0x25,0xDB,0x3C,0x91,0x86,0xC6, + 0x8E,0xF0,0x11,0xFD,0x23,0x74,0x36,0xF7,0xA4,0xF5,0x9E,0x7A,0x7E,0x53,0x50,0x44, + 0xD4,0x47,0xCA,0xD3,0xEB,0x38,0x6D,0xE6,0xD9,0x71,0x94,0x7F,0x4A,0xC6,0x69,0x4B, + 0x11,0xF4,0x52,0xEA,0x22,0xFE,0x8A,0xB0,0x36,0x67,0x8B,0x59,0xE8,0xE6,0x80,0x2A, + 0xEB,0x65,0x04,0x13,0xEE,0xEC,0xDC,0x9E,0x5F,0xB1,0xEC,0x05,0x6A,0x59,0xE6,0x9F, + 0x5E,0x59,0x6B,0x89,0xBF,0xF7,0x1A,0xCA,0x44,0xF9,0x5B,0x6A,0x71,0x85,0x03,0xE4, + 0x29,0x62,0xE0,0x70,0x6F,0x41,0xC4,0xCF,0xB2,0xB1,0xCC,0xE3,0x7E,0xA6,0x07,0xA8, + 0x87,0xE7,0x7F,0x84,0x93,0xDB,0x52,0x4B,0x6C,0xEC,0x7E,0xDD,0xD4,0x24,0x48,0x10, + 0x69,0x9F,0x04,0x60,0x74,0xE6,0x48,0x18,0xF3,0xE4,0x2C,0xB9,0x4F,0x2E,0x50,0x7A, + 0xDF,0xD4,0x54,0x69,0x2B,0x8B,0xA7,0xF3,0xCE,0xFF,0x1F,0xF3,0x3E,0x26,0x01,0x39, + 0x17,0x95,0x84,0x89,0xB0,0xF0,0x4C,0x4B,0x82,0x91,0x9F,0xC4,0x4B,0xAC,0x9D,0xA5, + 0x74,0xAF,0x17,0x25,0xC9,0xCA,0x32,0xD3,0xBC,0x89,0x8A,0x84,0x89,0xCC,0x0D,0xAE, + 0x7C,0xA2,0xDB,0x9C,0x6A,0x78,0x91,0xEE,0xEA,0x76,0x5D,0x4E,0x87,0x60,0xF5,0x69, + 0x15,0x67,0xD4,0x02,0xCF,0xAF,0x48,0x36,0x07,0xEA,0xBF,0x6F,0x66,0x2D,0x06,0x8F, + 0xC4,0x9A,0xFE,0xF9,0xF6,0x90,0x87,0x75,0xB8,0xF7,0xAD,0x0F,0x76,0x10,0x5A,0x3D, + 0x59,0xB0,0x2E,0xB3,0xC7,0x35,0x2C,0xCC,0x70,0x56,0x2B,0xCB,0xE3,0x37,0x96,0xC5, + 0x2F,0x46,0x1B,0x8A,0x22,0x46,0xC7,0x88,0xA7,0x26,0x32,0x98,0x61,0xDF,0x86,0x22, + 0x8A,0xF4,0x1C,0x2F,0x87,0xA1,0x09,0xAA,0xCC,0xA9,0xAE,0xD3,0xBD,0x00,0x45,0x1C, + 0x9A,0x54,0x87,0x86,0x52,0x87,0xEF,0xFF,0x1E,0x8F,0xA1,0x8F,0xC1,0x89,0x5C,0x35, + 0x1B,0xDA,0x2D,0x3A,0x2C,0x16,0xB2,0xC2,0xF1,0x56,0xE2,0x78,0xC1,0x6B,0x63,0x97, + 0xC5,0x56,0x8F,0xC9,0x32,0x7F,0x2C,0xAA,0xAF,0xA6,0xA8,0xAC,0x20,0x91,0x22,0x88, + 0xDE,0xE4,0x60,0x8B,0xF9,0x4B,0x42,0x25,0x1A,0xE3,0x7F,0x9C,0x2C,0x19,0x89,0x3A, + 0x7E,0x05,0xD4,0x36,0xCC,0x69,0x58,0xC2,0xC1,0x32,0x8B,0x2F,0x90,0x85,0xEB,0x7A, + 0x39,0x50,0xA5,0xA1,0x27,0x92,0xC5,0x66,0xB0,0x20,0x4F,0x58,0x7E,0x55,0x83,0x43, + 0x2B,0x45,0xE2,0x9C,0xE4,0xD8,0x12,0x90,0x2C,0x16,0x83,0x56,0x16,0x79,0x03,0xB3, + 0xAD,0x2D,0x61,0x18,0x1A,0x13,0x1F,0x37,0xE2,0xE1,0x9C,0x73,0x7B,0x80,0xD5,0xFD, + 0x2D,0x51,0x87,0xFC,0x7B,0xAA,0xD7,0x1F,0x2C,0x7A,0x8E,0xAF,0xF4,0x8D,0xBB,0xCD, + 0x95,0x11,0x7C,0x72,0x0B,0xEE,0x6F,0xE2,0xB9,0xAF,0xDE,0x37,0x83,0xDE,0x8C,0x8D, + 0x62,0x05,0x67,0xB7,0x96,0xC6,0x8D,0x56,0xB6,0x0D,0xD7,0x62,0xBA,0xD6,0x46,0x36, + 0xBD,0x8E,0xC8,0xE6,0xEA,0x2A,0x6C,0x10,0x14,0xFF,0x6B,0x5B,0xFA,0x82,0x3C,0x46, + 0xB1,0x30,0x43,0x46,0x51,0x8A,0x7D,0x9B,0x92,0x3E,0x83,0x79,0x5B,0x55,0x5D,0xB2, + 0x6C,0x5E,0xCE,0x90,0x62,0x8E,0x53,0x98,0xC9,0x0D,0x6D,0xE5,0x2D,0x57,0xCD,0xC5, + 0x81,0x57,0xBA,0xE1,0xE8,0xB8,0x8F,0x72,0xE5,0x4F,0x13,0xDC,0xEA,0x9D,0x71,0x15, + 0x10,0xB2,0x11,0x88,0xD5,0x09,0xD4,0x7F,0x5B,0x65,0x7F,0x2C,0x3B,0x38,0x4C,0x11, + 0x68,0x50,0x8D,0xFB,0x9E,0xB0,0x59,0xBF,0x94,0x80,0x89,0x4A,0xC5,0x1A,0x18,0x12, + 0x89,0x53,0xD1,0x4A,0x10,0x29,0xE8,0x8C,0x1C,0xEC,0xB6,0xEA,0x46,0xC7,0x17,0x8B, + 0x25,0x15,0x31,0xA8,0xA2,0x6B,0x43,0xB1,0x9D,0xE2,0xDB,0x0B,0x87,0x9B,0xB0,0x11, + 0x04,0x0E,0x71,0xD2,0x29,0x77,0x89,0x82,0x0A,0x66,0x41,0x7F,0x1D,0x0B,0x48,0xFF, + 0x72,0xBB,0x24,0xFD,0xC2,0x48,0xA1,0x9B,0xFE,0x7B,0x7F,0xCE,0x88,0xDB,0x86,0xD9, + 0x85,0x3B,0x1C,0xB0,0xDC,0xA8,0x33,0x07,0xBF,0x51,0x2E,0xE3,0x0E,0x9A,0x00,0x97, + 0x1E,0x06,0xC0,0x97,0x43,0x9D,0xD8,0xB6,0x45,0xC4,0x86,0x67,0x5F,0x00,0xF8,0x88, + 0x9A,0xA4,0x52,0x9E,0xC7,0xAA,0x8A,0x83,0x75,0xEC,0xC5,0x18,0xAE,0xCE,0xC3,0x2F, + 0x1A,0x2B,0xF9,0x18,0xFF,0xAE,0x1A,0xF5,0x53,0x0B,0xB5,0x33,0x51,0xA7,0xFD,0xE8, + 0xA8,0xE1,0xA2,0x64,0xB6,0x22,0x17,0x43,0x80,0xCC,0x0A,0xD8,0xAE,0x3B,0xBA,0x40, + 0xD7,0xD9,0x92,0x4A,0x89,0xDF,0x04,0x10,0xEE,0x9B,0x18,0x2B,0x6A,0x77,0x69,0x8A, + 0x68,0xF4,0xF9,0xB9,0xA2,0x21,0x15,0x6E,0xE6,0x1E,0x3B,0x03,0x62,0x30,0x9B,0x60, + 0x41,0x7E,0x25,0x9B,0x9E,0x8F,0xC5,0x52,0x10,0x08,0xF8,0xC2,0x69,0xA1,0x21,0x11, + 0x88,0x37,0x5E,0x79,0x35,0x66,0xFF,0x10,0x42,0x18,0x6E,0xED,0x97,0xB6,0x6B,0x1C, + 0x4E,0x36,0xE5,0x6D,0x7D,0xB4,0xE4,0xBF,0x20,0xB9,0xE0,0x05,0x3A,0x69,0xD5,0xB8, + 0xE3,0xD5,0xDC,0xE0,0xB9,0xAC,0x53,0x3E,0x07,0xA4,0x57,0xAD,0x77,0xFF,0x48,0x18, + 0x76,0x2A,0xAC,0x49,0x2A,0x8E,0x47,0x75,0x6D,0x9F,0x67,0x63,0x30,0x35,0x8C,0x39, + 0x05,0x39,0xD5,0x6F,0x64,0x3A,0x5B,0xAD,0xCA,0x0B,0xBB,0x82,0x52,0x99,0x45,0xB1, + 0x93,0x36,0x36,0x99,0xAF,0x13,0x20,0x44,0x36,0xD8,0x02,0x44,0x09,0x39,0x92,0x85, + 0xFF,0x4A,0x4A,0x97,0x87,0xA6,0x63,0xD7,0xC7,0xB5,0xB5,0x24,0xED,0x0F,0xB4,0x6F, + 0x0C,0x58,0x52,0x14,0xD9,0xA6,0x7B,0xD3,0x79,0xBC,0x38,0x58,0xA1,0xBD,0x3B,0x84, + 0x06,0xD8,0x1A,0x06,0xFD,0x6B,0xA8,0xEA,0x4B,0x69,0x28,0x04,0x37,0xAD,0x82,0x99, + 0xFB,0x0E,0x1B,0x85,0xBD,0xA8,0x5D,0x73,0xCD,0xDC,0x58,0x75,0x0A,0xBE,0x63,0x6C, + 0x48,0xE7,0x4C,0xE4,0x30,0x2B,0x04,0x60,0xB9,0x15,0xD8,0xDA,0x86,0x81,0x75,0x8F, + 0x96,0xD4,0x8D,0x1C,0x5D,0x70,0x85,0x7C,0x1C,0x67,0x7B,0xD5,0x08,0x67,0xA6,0xCE, + 0x4B,0x0A,0x66,0x70,0xB7,0xE5,0x63,0xD4,0x5B,0x8A,0x82,0xEA,0x10,0x67,0xCA,0xE2, + 0xF4,0xEF,0x17,0x85,0x2F,0x2A,0x5F,0x8A,0x97,0x82,0xF8,0x6A,0xD6,0x34,0x10,0xEA, + 0xEB,0xC9,0x5C,0x3C,0xE1,0x49,0xF8,0x46,0xEB,0xDE,0xBD,0xF6,0xA9,0x92,0xF1,0xAA, + 0xA6,0xA0,0x18,0xB0,0x3A,0xD3,0x0F,0x1F,0xF3,0x6F,0xFF,0x31,0x45,0x43,0x44,0xD3, + 0x50,0x9A,0xF7,0x88,0x09,0x96,0xC1,0xCE,0x76,0xCC,0xF2,0x2C,0x2C,0xBA,0xAD,0x82, + 0x77,0x8F,0x18,0x84,0xC0,0xD2,0x07,0x9C,0x36,0x90,0x83,0x4E,0x0B,0xA5,0x4F,0x43, + 0x3E,0x04,0xAB,0x78,0x4F,0xD6,0xFB,0x09,0x01,0x24,0x90,0xDA,0x6F,0x3C,0x3A,0x61, + 0x0D,0x7F,0x69,0x4A,0xEB,0x2B,0x30,0x02,0xB4,0xDB,0xE0,0x84,0xA9,0xEC,0xD7,0x35, + 0xBF,0x37,0x7D,0x85,0x58,0xCE,0xA9,0x4E,0xE4,0x80,0xC7,0xA8,0xD3,0x30,0x67,0x48, + 0xEB,0x29,0xAF,0x2F,0x74,0x6A,0xB4,0xA7,0x3F,0x0F,0x3F,0x92,0xAF,0xF3,0xCA,0xAC, + 0xAF,0x4B,0xD9,0x94,0xC0,0x43,0xCA,0x81,0x0D,0x2F,0x48,0xA1,0xB0,0x27,0xD5,0xD2, + 0xEF,0x4B,0x05,0x85,0xA3,0xDE,0x4D,0x93,0x30,0x3C,0xF0,0xBB,0x4A,0x8F,0x30,0x27, + 0x4C,0xEB,0xE3,0x3E,0x64,0xED,0x9A,0x2F,0x3B,0xF1,0x82,0xF0,0xBA,0xF4,0xCF,0x7F, + 0x40,0xCB,0xB0,0xE1,0x7F,0xBC,0xAA,0x57,0xD3,0xC9,0x74,0xF2,0xFA,0x43,0x0D,0x22, + 0xD0,0xF4,0x77,0x4E,0x93,0xD7,0x85,0x70,0x1F,0x99,0xBF,0xB6,0xDE,0x35,0xF1,0x30, + 0xA7,0x5E,0x71,0xF0,0x6B,0x01,0x2D,0x7B,0x64,0xF0,0x33,0x53,0x0A,0x39,0x88,0xF3, + 0x6B,0x3A,0xA6,0x6B,0x35,0xD2,0x2F,0x43,0xCD,0x02,0xFD,0xB5,0xE9,0xBC,0x5B,0xAA, + 0xD8,0xA4,0x19,0x7E,0x0E,0x5D,0x94,0x81,0x9E,0x6F,0x77,0xAD,0xD6,0x0E,0x74,0x93, + 0x96,0xE7,0xC4,0x18,0x5F,0xAD,0xF5,0x19, +}; diff --git a/BootLoader/source/main.arm7.c b/BootLoader/source/main.arm7.c index 4d34947..ffb0646 100755 --- a/BootLoader/source/main.arm7.c +++ b/BootLoader/source/main.arm7.c @@ -1,14 +1,14 @@ -/* - main.arm7.c - - By Michael Chisholm (Chishm) - - All resetMemory and startBinary functions are based - on the MultiNDS loader by Darkain. - Original source available at: - http://cvs.sourceforge.net/viewcvs.py/ndslib/ndslib/examples/loader/boot/main.cpp - - License: +/* + main.arm7.c + + By Michael Chisholm (Chishm) + + All resetMemory and startBinary functions are based + on the MultiNDS loader by Darkain. + Original source available at: + http://cvs.sourceforge.net/viewcvs.py/ndslib/ndslib/examples/loader/boot/main.cpp + + License: NitroHax -- Cheat tool for the Nintendo DS Copyright (C) 2008 Michael "Chishm" Chisholm @@ -23,53 +23,55 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ + along with this program. If not, see . +*/ #ifndef ARM7 # define ARM7 -#endif -#include -#include -#include -#include -#include +#endif +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include + +#ifndef NULL +#define NULL 0 +#endif -#ifndef NULL -#define NULL 0 -#endif - -#include "common.h" +#include "common.h" #include "read_card.h" -#include "cheat.h" void arm7_clearmem (void* loc, size_t len); + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Important things +#define NDS_HEAD 0x027FFE00 +tNDSHeader* ndsHeader = (tNDSHeader*)NDS_HEAD; -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// Important things -#define NDS_HEAD 0x027FFE00 -tNDSHeader* ndsHeader = (tNDSHeader*)NDS_HEAD; - -#define CHEAT_ENGINE_LOCATION 0x027FE000 -#define CHEAT_DATA_LOCATION 0x06010000 - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// Used for debugging purposes -static void errorOutput (u32 code) { - // Wait until the ARM9 is ready +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Used for debugging purposes +/* Disabled for now. Re-enable to debug problems +static void errorOutput (u32 code) { + // Wait until the ARM9 is ready while (arm9_stateFlag != ARM9_READY); // Set the error code, then tell ARM9 to display it arm9_errorCode = code; arm9_errorClearBG = true; arm9_stateFlag = ARM9_DISPERR; // Stop - while(1); -} + while(1); +} +*/ -static void debugOutput (u32 code) { - // Wait until the ARM9 is ready +static void debugOutput (u32 code) { + // Wait until the ARM9 is ready while (arm9_stateFlag != ARM9_READY); // Set the error code, then tell ARM9 to display it arm9_errorCode = code; @@ -78,184 +80,189 @@ static void debugOutput (u32 code) { // Wait for completion while (arm9_stateFlag != ARM9_READY); } - -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// Firmware stuff - -#define FW_READ 0x03 - -void arm7_readFirmware (uint32 address, uint8 * buffer, uint32 size) { - uint32 index; - - // Read command - while (REG_SPICNT & SPI_BUSY); - REG_SPICNT = SPI_ENABLE | SPI_CONTINUOUS | SPI_DEVICE_NVRAM; - REG_SPIDATA = FW_READ; - while (REG_SPICNT & SPI_BUSY); - - // Set the address - REG_SPIDATA = (address>>16) & 0xFF; - while (REG_SPICNT & SPI_BUSY); - REG_SPIDATA = (address>>8) & 0xFF; - while (REG_SPICNT & SPI_BUSY); - REG_SPIDATA = (address) & 0xFF; - while (REG_SPICNT & SPI_BUSY); - - for (index = 0; index < size; index++) { - REG_SPIDATA = 0; - while (REG_SPICNT & SPI_BUSY); - buffer[index] = REG_SPIDATA & 0xFF; - } - REG_SPICNT = 0; -} - -/*------------------------------------------------------------------------- -arm7_resetMemory -Clears all of the NDS's RAM that is visible to the ARM7 -Written by Darkain. -Modified by Chishm: - * Added STMIA clear mem loop ---------------------------------------------------------------------------*/ -void arm7_resetMemory (void) { - int i; - u8 settings1, settings2; - - REG_IME = 0; - - for (i=0; i<16; i++) { - SCHANNEL_CR(i) = 0; - SCHANNEL_TIMER(i) = 0; - SCHANNEL_SOURCE(i) = 0; - SCHANNEL_LENGTH(i) = 0; - } - REG_SOUNDCNT = 0; - - // Clear out ARM7 DMA channels and timers - for (i=0; i<4; i++) { - DMA_CR(i) = 0; - DMA_SRC(i) = 0; - DMA_DEST(i) = 0; - TIMER_CR(i) = 0; - TIMER_DATA(i) = 0; - } + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Firmware stuff + +#define FW_READ 0x03 + +void arm7_readFirmware (uint32 address, uint8 * buffer, uint32 size) { + uint32 index; + + // Read command + while (REG_SPICNT & SPI_BUSY); + REG_SPICNT = SPI_ENABLE | SPI_CONTINUOUS | SPI_DEVICE_NVRAM; + REG_SPIDATA = FW_READ; + while (REG_SPICNT & SPI_BUSY); + + // Set the address + REG_SPIDATA = (address>>16) & 0xFF; + while (REG_SPICNT & SPI_BUSY); + REG_SPIDATA = (address>>8) & 0xFF; + while (REG_SPICNT & SPI_BUSY); + REG_SPIDATA = (address) & 0xFF; + while (REG_SPICNT & SPI_BUSY); + + for (index = 0; index < size; index++) { + REG_SPIDATA = 0; + while (REG_SPICNT & SPI_BUSY); + buffer[index] = REG_SPIDATA & 0xFF; + } + REG_SPICNT = 0; +} + +/*------------------------------------------------------------------------- +arm7_resetMemory +Clears all of the NDS's RAM that is visible to the ARM7 +Written by Darkain. +Modified by Chishm: + * Added STMIA clear mem loop +--------------------------------------------------------------------------*/ +void arm7_resetMemory (void) { + int i; + u8 settings1, settings2; + + REG_IME = 0; + + for (i=0; i<16; i++) { + SCHANNEL_CR(i) = 0; + SCHANNEL_TIMER(i) = 0; + SCHANNEL_SOURCE(i) = 0; + SCHANNEL_LENGTH(i) = 0; + } + SOUND_CR = 0; + + // Clear out ARM7 DMA channels and timers + for (i=0; i<4; i++) { + DMA_CR(i) = 0; + DMA_SRC(i) = 0; + DMA_DEST(i) = 0; + TIMER_CR(i) = 0; + TIMER_DATA(i) = 0; + } // Clear out FIFO REG_IPC_SYNC = 0; REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; REG_IPC_FIFO_CR = 0; - // clear IWRAM - 037F:8000 to 0380:FFFF, total 96KiB + // clear IWRAM - 037F:8000 to 0380:FFFF, total 96KiB arm7_clearmem ((void*)0x037F8000, 96*1024); - - // clear most of EXRAM - except after 0x023FD800, which has the ARM9 code + + // clear most of EXRAM - except after 0x023FD800, which has the ARM9 code arm7_clearmem ((void*)0x02000000, 0x003FD800); - // clear last part of EXRAM, skipping the ARM9's section + // clear last part of EXRAM, skipping the ARM9's section arm7_clearmem ((void*)0x023FE000, 0x2000); - REG_IE = 0; - REG_IF = ~0; - (*(vu32*)(0x04000000-4)) = 0; //IRQ_HANDLER ARM7 version - (*(vu32*)(0x04000000-8)) = ~0; //VBLANK_INTR_WAIT_FLAGS, ARM7 version - REG_POWERCNT = 1; //turn off power to stuffs - - // Reload DS Firmware settings - arm7_readFirmware((u32)0x03FE70, &settings1, 0x1); - arm7_readFirmware((u32)0x03FF70, &settings2, 0x1); - - if (settings1 > settings2) { - arm7_readFirmware((u32)0x03FE00, (u8*)0x027FFC80, 0x70); - arm7_readFirmware((u32)0x03FF00, (u8*)0x027FFD80, 0x70); - } else { - arm7_readFirmware((u32)0x03FF00, (u8*)0x027FFC80, 0x70); - arm7_readFirmware((u32)0x03FE00, (u8*)0x027FFD80, 0x70); - } - - // Load FW header - arm7_readFirmware((u32)0x000000, (u8*)0x027FF830, 0x20); -} - - -int arm7_loadBinary (void) { + REG_IE = 0; + REG_IF = ~0; + (*(vu32*)(0x04000000-4)) = 0; //IRQ_HANDLER ARM7 version + (*(vu32*)(0x04000000-8)) = ~0; //VBLANK_INTR_WAIT_FLAGS, ARM7 version + REG_POWERCNT = 1; //turn off power to stuffs + + // Reload DS Firmware settings + arm7_readFirmware((u32)0x03FE70, &settings1, 0x1); + arm7_readFirmware((u32)0x03FF70, &settings2, 0x1); + + if (settings1 > settings2) { + arm7_readFirmware((u32)0x03FE00, (u8*)0x027FFC80, 0x70); + arm7_readFirmware((u32)0x03FF00, (u8*)0x027FFD80, 0x70); + } else { + arm7_readFirmware((u32)0x03FF00, (u8*)0x027FFC80, 0x70); + arm7_readFirmware((u32)0x03FE00, (u8*)0x027FFD80, 0x70); + } + + // Load FW header + arm7_readFirmware((u32)0x000000, (u8*)0x027FF830, 0x20); +} + +int arm7_loadBinary (void) { u32 chipID; u32 errorCode; - - // Init card + + // Init card errorCode = cardInit(ndsHeader, &chipID); if (errorCode) { return errorCode; } - // Set memory values expected by loaded NDS - *((u32*)0x027ff800) = chipID; // CurrentCardID - *((u32*)0x027ff804) = chipID; // Command10CardID - *((u16*)0x027ff808) = ndsHeader->headerCRC16; // Header Checksum, CRC-16 of [000h-15Dh] - *((u16*)0x027ff80a) = ndsHeader->secureCRC16; // Secure Area Checksum, CRC-16 of [ [20h]..7FFFh] + // Set memory values expected by loaded NDS + *((u32*)0x027ff800) = chipID; // CurrentCardID + *((u32*)0x027ff804) = chipID; // Command10CardID + *((u16*)0x027ff808) = ndsHeader->headerCRC16; // Header Checksum, CRC-16 of [000h-15Dh] + *((u16*)0x027ff80a) = ndsHeader->secureCRC16; // Secure Area Checksum, CRC-16 of [ [20h]..7FFFh] *((u16*)0x027ffc40) = 0x1; // Booted from card -- EXTREMELY IMPORTANT!!! Thanks to cReDiAr - - cardRead(ndsHeader->arm9romOffset, (u32*)ndsHeader->arm9destination, ndsHeader->arm9binarySize); - cardRead(ndsHeader->arm7romOffset, (u32*)ndsHeader->arm7destination, ndsHeader->arm7binarySize); + + cardRead(ndsHeader->arm9romOffset, (u32*)ndsHeader->arm9destination, ndsHeader->arm9binarySize); cardRead(ndsHeader->arm7romOffset, (u32*)ndsHeader->arm7destination, ndsHeader->arm7binarySize); return ERR_NONE; -} - - -/*------------------------------------------------------------------------- -arm7_startBinary -Jumps to the ARM7 NDS binary in sync with the display and ARM9 -Written by Darkain, modified by Chishm. ---------------------------------------------------------------------------*/ -void arm7_startBinary (void) -{ - // Wait until the ARM9 is ready +} + + +/*------------------------------------------------------------------------- +arm7_startBinary +Jumps to the ARM7 NDS binary in sync with the display and ARM9 +Written by Darkain, modified by Chishm. +--------------------------------------------------------------------------*/ +void arm7_startBinary (void) +{ + // Wait until the ARM9 is ready while (arm9_stateFlag != ARM9_READY); - while(REG_VCOUNT!=191); - while(REG_VCOUNT==191); - - // Get the ARM9 to boot - arm9_stateFlag = ARM9_BOOTBIN; - - while(REG_VCOUNT!=191); - while(REG_VCOUNT==191); - // Start ARM7 - resetCpu(); -} - - -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// Main function - -void arm7_main (void) { + while(REG_VCOUNT!=191); + while(REG_VCOUNT==191); + + // Get the ARM9 to boot + arm9_stateFlag = ARM9_BOOTBIN; + + while(REG_VCOUNT!=191); + while(REG_VCOUNT==191); + // Start ARM7 + + void (*foo)() = *(u32*)(0x27FFE34); + + foo(); +} + + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Main function + +void arm7_main (void) { + + // No longer set here. + // volatile u32* SCFG_ROM = (volatile u32*)0x4004000; + // volatile u32* SCFG_CLK = (volatile u32*)0x4004004; + // volatile u32* SCFG_EXT = (volatile u32*)0x4004008; + + + // REG_SCFG_ROM = 0x703; + // REG_SCFG_CLK = 0x180; + // REG_SCFG_EXT = 0x80000000; + // REG_SCFG_EXT=0x12A00000; + int errorCode; - + // Wait for ARM9 to at least start while (arm9_stateFlag < ARM9_START); debugOutput (ERR_STS_CLR_MEM); - - // Get ARM7 to clear RAM - arm7_resetMemory(); + + // Get ARM7 to clear RAM + arm7_resetMemory(); debugOutput (ERR_STS_LOAD_BIN); - // Load the NDS file + // Load the NDS file errorCode = arm7_loadBinary(); if (errorCode) { - errorOutput(errorCode); - } - + debugOutput(errorCode); + } + debugOutput (ERR_STS_HOOK_BIN); - - // Load the cheat engine and hook it into the ARM7 binary - errorCode = arm7_hookGame(ndsHeader, (const u32*)CHEAT_DATA_LOCATION, (u32*)CHEAT_ENGINE_LOCATION); - if (errorCode != ERR_NONE && errorCode != ERR_NOCHEAT) { - errorOutput(errorCode); - } - - debugOutput (ERR_STS_START); - - arm7_startBinary(); - - return; -} - + + arm7_startBinary(); + + return; +} + diff --git a/BootLoader/source/main.arm9.c b/BootLoader/source/main.arm9.c index 04f6e92..4203bef 100755 --- a/BootLoader/source/main.arm9.c +++ b/BootLoader/source/main.arm9.c @@ -1,9 +1,9 @@ /* main.arm9.c - + By Michael Chisholm (Chishm) - - All resetMemory and startBinary functions are based + + All resetMemory and startBinary functions are based on the MultiNDS loader by Darkain. Original source available at: http://cvs.sourceforge.net/viewcvs.py/ndslib/ndslib/examples/loader/boot/main.cpp @@ -54,23 +54,24 @@ arm9_errorOutput Displays an error code on screen. Written by Chishm --------------------------------------------------------------------------*/ +/* Re-enable for debug purposes static void arm9_errorOutput (u32 code, bool clearBG) { int i, j, k; u16 colour; - - REG_POWERCNT = (u16)(POWER_LCD | POWER_2D_A); + + REG_POWERCNT = POWER_LCD | POWER_2D_A; REG_DISPCNT = MODE_FB0; VRAM_A_CR = VRAM_ENABLE; - + if (clearBG) { // Clear display for (i = 0; i < 256*192; i++) { VRAM_A[i] = 0x0000; } } - + // Draw boxes of colour, signifying error codes - + if ((code >> 16) != 0) { // high 16 bits for (i = 0; i < 8; i++) { // Pair of bits to use @@ -127,8 +128,9 @@ static void arm9_errorOutput (u32 code, bool clearBG) { } } } - } + } } +*/ /*------------------------------------------------------------------------- arm9_main @@ -138,14 +140,18 @@ Jumps to the ARM9 NDS binary in sync with the display and ARM7 Written by Darkain, modified by Chishm --------------------------------------------------------------------------*/ void arm9_main (void) { - register int i; + // volatile u32* SCFG_EXT = (volatile u32*)0x4004008; + // volatile u32* SCFG_CLK = (volatile u32*)0x4004004; + + register int i; + //set shared ram to ARM7 WRAM_CR = 0x03; REG_EXMEMCNT = 0xE880; arm9_stateFlag = ARM9_START; - + REG_IME = 0; REG_IE = 0; REG_IF = ~0; @@ -156,7 +162,7 @@ void arm9_main (void) { (*(vu32*)(i+0x00000000)) = 0x00000000; //clear ITCM (*(vu32*)(i+0x00800000)) = 0x00000000; //clear DTCM } - + for (i=16*1024; i<32*1024; i+=4) { //second 16KB (*(vu32*)(i+0x00000000)) = 0x00000000; //clear ITCM } @@ -174,7 +180,7 @@ void arm9_main (void) { TIMER_CR(i) = 0; TIMER_DATA(i) = 0; } - + // Clear out FIFO REG_IPC_SYNC = 0; REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; @@ -217,16 +223,23 @@ void arm9_main (void) { arm9_stateFlag = ARM9_READY; while ( arm9_stateFlag != ARM9_BOOTBIN ) { if (arm9_stateFlag == ARM9_DISPERR) { - arm9_errorOutput (arm9_errorCode, arm9_errorClearBG); + // arm9_errorOutput (arm9_errorCode, arm9_errorClearBG); if ( arm9_stateFlag == ARM9_DISPERR) { arm9_stateFlag = ARM9_READY; } } } - + // wait for vblank then boot while(REG_VCOUNT!=191); while(REG_VCOUNT==191); - resetCpu(); + + u32 first = *(u32*)(0x27FFE34); + + // arm9_errorOutput (*(u32*)(first), true); + + void (*newReset)() = *(u32*)(0x27FFE24); + + newReset(); } diff --git a/BootLoader/source/read_bios.h b/BootLoader/source/read_bios.h index 4de0fcc..c5c93c1 100755 --- a/BootLoader/source/read_bios.h +++ b/BootLoader/source/read_bios.h @@ -15,6 +15,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #include - -void readBios (u8* dest, u32 src, u32 size); + #include + +void readBios (u8* dest, u32 src, u32 size); diff --git a/BootLoader/source/read_card.c b/BootLoader/source/read_card.c index 83e24ff..f799d29 100755 --- a/BootLoader/source/read_card.c +++ b/BootLoader/source/read_card.c @@ -27,12 +27,6 @@ #include "encryption.h" #include "common.h" -typedef union -{ - char title[4]; - u32 key; -} GameCode; - static u32 portFlags = 0; static u32 secureAreaData[CARD_SECURE_AREA_SIZE/sizeof(u32)]; @@ -43,15 +37,15 @@ static u32 getRandomNumber(void) { // guaranteed to be random. } -static void decryptSecureArea (u32 gameCode, u32* secureArea) +static void decryptSecureArea (u32 gameCode, u32* secureArea) { int i; - + init_keycode (gameCode, 2, 8); crypt_64bit_down (secureArea); - + init_keycode (gameCode, 3, 8); - + for (i = 0; i < 0x200; i+= 2) { crypt_64bit_down (secureArea + i); } @@ -65,16 +59,16 @@ static struct { unsigned int mmm; unsigned int nnn; } key1data; - + static void initKey1Encryption (u8* cmdData) { - key1data.iii = getRandomNumber() & 0x00000fff; - key1data.jjj = getRandomNumber() & 0x00000fff; + key1data.iii = getRandomNumber() & 0x00000fff; + key1data.jjj = getRandomNumber() & 0x00000fff; key1data.kkkkk = getRandomNumber() & 0x000fffff; key1data.llll = getRandomNumber() & 0x0000ffff; - key1data.mmm = getRandomNumber() & 0x00000fff; - key1data.nnn = getRandomNumber() & 0x00000fff; - + key1data.mmm = getRandomNumber() & 0x00000fff; + key1data.nnn = getRandomNumber() & 0x00000fff; + cmdData[7] = CARD_CMD_ACTIVATE_BF; cmdData[6] = (u8) (key1data.iii >> 4); cmdData[5] = (u8) ((key1data.iii << 4) | (key1data.jjj >> 8)); @@ -88,12 +82,12 @@ static void initKey1Encryption (u8* cmdData) { // Note: cmdData must be aligned on a word boundary static void createEncryptedCommand (u8 command, u8* cmdData, u32 block) { - unsigned long iii, jjj; - + unsigned long iii, jjj; + if (command != CARD_CMD_SECURE_READ) { block = key1data.llll; } - + if (command == CARD_CMD_ACTIVATE_SEC) { iii = key1data.mmm; jjj = key1data.nnn; @@ -101,7 +95,7 @@ static void createEncryptedCommand (u8 command, u8* cmdData, u32 block) iii = key1data.iii; jjj = key1data.jjj; } - + cmdData[7] = (u8) (command | (block >> 12)); cmdData[6] = (u8) (block >> 4); cmdData[5] = (u8) ((block << 4) | (iii >> 8)); @@ -121,18 +115,18 @@ static void cardDelay (u16 readTimeout) { so we have to wait until one before overflow. This also requires an extra 1 for the timer data. See GBATek for the normal formula used for card timeout. - */ + */ TIMER_DATA(0) = 0 - (((readTimeout & 0x3FFF) + 3)); TIMER_CR(0) = TIMER_DIV_256 | TIMER_ENABLE; while (TIMER_DATA(0) != 0xFFFF); - + // Clear out the timer registers TIMER_CR(0) = 0; TIMER_DATA(0) = 0; } -int cardInit (tNDSHeader* ndsHeader, u32* chipID) +int cardInit (tNDSHeader* ndsHeader, u32* chipID) { u32 portFlagsKey1, portFlagsSecRead; bool normalChip; // As defined by GBAtek, normal chip secure area is accessed in blocks of 0x200, other chip in blocks of 0x1000 @@ -140,56 +134,56 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID) int secureBlockNumber; int i; u8 cmdData[8] __attribute__ ((aligned)); - GameCode* gameCode; - + // Dummy command sent after card reset - cardParamCommand (CARD_CMD_DUMMY, 0, - CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F), + cardParamCommand (CARD_CMD_DUMMY, 0, + CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F), NULL, 0); // Read the header - cardParamCommand (CARD_CMD_HEADER_READ, 0, - CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F), + cardParamCommand (CARD_CMD_HEADER_READ, 0, + CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F), (uint32*)ndsHeader, sizeof(tNDSHeader)); - + // Check header CRC - if (ndsHeader->headerCRC16 != swiCRC16(0xFFFF, (void*)ndsHeader, 0x15E)) { + if (ndsHeader->headerCRC16 != swiCRC16(0xFFFF, ndsHeader, 0x15E)) { return ERR_HEAD_CRC; } - + // Check logo CRC + /* if (ndsHeader->logoCRC16 != 0xCF56) { return ERR_LOGO_CRC; } + */ // Initialise blowfish encryption for KEY1 commands and decrypting the secure area - gameCode = (GameCode*)ndsHeader->gameCode; - init_keycode (gameCode->key, 2, 8); - + init_keycode (*((u32*)&ndsHeader->gameCode), 2, 8); + // Port 40001A4h setting for normal reads (command B7) - portFlags = ndsHeader->cardControl13 & ~CARD_BLK_SIZE(7); + portFlags = ndsHeader->cardControl13 & ~CARD_BLK_SIZE(7); // Port 40001A4h setting for KEY1 commands (usually 001808F8h) portFlagsKey1 = CARD_ACTIVATE | CARD_nRESET | (ndsHeader->cardControl13 & (CARD_WR|CARD_CLK_SLOW)) | - ((ndsHeader->cardControlBF & (CARD_CLK_SLOW|CARD_DELAY1(0x1FFF))) + ((ndsHeader->cardControlBF & CARD_DELAY2(0x3F)) >> 16)); - - // 1st Get ROM Chip ID - cardParamCommand (CARD_CMD_HEADER_CHIPID, 0, - (ndsHeader->cardControl13 & (CARD_WR|CARD_nRESET|CARD_CLK_SLOW)) | CARD_ACTIVATE | CARD_BLK_SIZE(7), - chipID, sizeof(u32)); + ((ndsHeader->cardControlBF & (CARD_CLK_SLOW|CARD_DELAY1(0x1FFF))) + ((ndsHeader->cardControlBF & CARD_DELAY2(0x3F)) >> 16)); + + // 1st Get ROM Chip ID + cardParamCommand (CARD_CMD_HEADER_CHIPID, 0, + (ndsHeader->cardControl13 & (CARD_WR|CARD_nRESET|CARD_CLK_SLOW)) | CARD_ACTIVATE | CARD_BLK_SIZE(7), + chipID, sizeof(u32)); // Adjust card transfer method depending on the most significant bit of the chip ID normalChip = ((*chipID) & 0x80000000) != 0; // ROM chip ID MSB if (!normalChip) { portFlagsKey1 |= CARD_SEC_LARGE; } - + // 3Ciiijjj xkkkkkxx - Activate KEY1 Encryption Mode initKey1Encryption (cmdData); cardPolledTransfer((ndsHeader->cardControl13 & (CARD_WR|CARD_nRESET|CARD_CLK_SLOW)) | CARD_ACTIVATE, NULL, 0, cmdData); - + // 4llllmmm nnnkkkkk - Activate KEY2 Encryption Mode createEncryptedCommand (CARD_CMD_ACTIVATE_SEC, cmdData, 0); - + if (normalChip) { cardPolledTransfer(portFlagsKey1, NULL, 0, cmdData); cardDelay(ndsHeader->readTimeout); @@ -197,7 +191,7 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID) } else { cardPolledTransfer(portFlagsKey1, NULL, 0, cmdData); } - + // Set the KEY2 encryption registers REG_ROMCTRL = 0; CARD_1B0 = cardSeedBytes[ndsHeader->deviceType & 0x07] | (key1data.nnn << 15) | (key1data.mmm << 27) | 0x6000; @@ -205,13 +199,13 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID) CARD_1B8 = key1data.mmm >> 5; CARD_1BA = 0x5c; REG_ROMCTRL = CARD_nRESET | CARD_SEC_SEED | CARD_SEC_EN | CARD_SEC_DAT; - + // Update the DS card flags to suit KEY2 encryption portFlagsKey1 |= CARD_SEC_EN | CARD_SEC_DAT; - + // 1lllliii jjjkkkkk - 2nd Get ROM Chip ID / Get KEY2 Stream createEncryptedCommand (CARD_CMD_SECURE_CHIPID, cmdData, 0); - + if (normalChip) { cardPolledTransfer(portFlagsKey1, NULL, 0, cmdData); cardDelay(ndsHeader->readTimeout); @@ -219,15 +213,15 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID) } else { cardPolledTransfer(portFlagsKey1 | CARD_BLK_SIZE(7), NULL, 0, cmdData); } - + // 2bbbbiii jjjkkkkk - Get Secure Area Block secureArea = secureAreaData; portFlagsSecRead = (ndsHeader->cardControlBF & (CARD_CLK_SLOW|CARD_DELAY1(0x1FFF)|CARD_DELAY2(0x3F))) | CARD_ACTIVATE | CARD_nRESET | CARD_SEC_EN | CARD_SEC_DAT; - + for (secureBlockNumber = 4; secureBlockNumber < 8; secureBlockNumber++) { createEncryptedCommand (CARD_CMD_SECURE_READ, cmdData, secureBlockNumber); - + if (normalChip) { cardPolledTransfer(portFlagsSecRead, NULL, 0, cmdData); cardDelay(ndsHeader->readTimeout); @@ -243,17 +237,17 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID) // Alllliii jjjkkkkk - Enter Main Data Mode createEncryptedCommand (CARD_CMD_DATA_MODE, cmdData, 0); - + if (normalChip) { cardPolledTransfer(portFlagsKey1, NULL, 0, cmdData); cardDelay(ndsHeader->readTimeout); cardPolledTransfer(portFlagsKey1, NULL, 0, cmdData); - } else { + } else { cardPolledTransfer(portFlagsKey1, NULL, 0, cmdData); } - + // Now deal with secure area decryption and verification - decryptSecureArea (gameCode->key, secureAreaData); + decryptSecureArea (*((u32*)&ndsHeader->gameCode), secureAreaData); secureArea = secureAreaData; if (secureArea[0] == 0x72636e65 /*'encr'*/ && secureArea[1] == 0x6a624f79 /*'yObj'*/) { @@ -265,33 +259,35 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID) for (i = 0; i < 0x200; i ++) { *secureArea++ = 0xe7ffdeff; } - return normalChip ? ERR_SEC_NORM : ERR_SEC_OTHR; + // Disabled error checks on secure area. This was able to boot a DS-Xtreme. May increase flashcart compatiblity drastically. + // return normalChip ? ERR_SEC_NORM : ERR_SEC_OTHR; + return normalChip ? ERR_NONE : ERR_NONE; } - + return ERR_NONE; } - -void cardRead (u32 src, u32* dest, size_t size) + +void cardRead (u32 src, u32* dest, size_t size) { size_t readSize; - - if (src < CARD_SECURE_AREA_OFFSET) { + + if (src < CARD_SECURE_AREA_OFFSET) { return; } else if (src < CARD_DATA_OFFSET) { // Read data from secure area readSize = src + size < CARD_DATA_OFFSET ? size : CARD_DATA_OFFSET - src; memcpy (dest, (u8*)secureAreaData + src - CARD_SECURE_AREA_OFFSET, readSize); - src += readSize; + src += readSize; dest += readSize/sizeof(*dest); size -= readSize; } - + while (size > 0) { readSize = size < CARD_DATA_BLOCK_SIZE ? size : CARD_DATA_BLOCK_SIZE; - cardParamCommand (CARD_CMD_DATA_READ, src, + cardParamCommand (CARD_CMD_DATA_READ, src, (portFlags &~CARD_BLK_SIZE(7)) | CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(1), dest, readSize); - src += readSize; + src += readSize; dest += readSize/sizeof(*dest); size -= readSize; } diff --git a/BootLoader/source/read_card.h b/BootLoader/source/read_card.h index 4ca2f39..75c6fae 100755 --- a/BootLoader/source/read_card.h +++ b/BootLoader/source/read_card.h @@ -31,7 +31,7 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID); -void cardRead (u32 src, u32* dest, size_t size); +void cardRead (u32 src, u32* dest, size_t size); #endif // READ_CARD_H diff --git a/LICENSE b/License.txt old mode 100755 new mode 100644 similarity index 100% rename from LICENSE rename to License.txt diff --git a/Makefile b/Makefile index bfad082..e08eb88 100755 --- a/Makefile +++ b/Makefile @@ -7,33 +7,41 @@ endif include $(DEVKITARM)/ds_rules -export TARGET := NitroHax +export TARGET := NTR_Launcher export TOPDIR := $(CURDIR) -export VERSION_MAJOR := 0 -export VERSION_MINOR := 93 +export VERSION_MAJOR := 1 +export VERSION_MINOR := 96 export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR) +#--------------------------------------------------------------------------------- +# path to tools - this can be deleted if you set the path in windows +#--------------------------------------------------------------------------------- +export PATH := $(DEVKITARM)/bin:$(PATH) -.PHONY: arm7/$(TARGET).elf arm9/$(TARGET).elf +.PHONY: $(TARGET).arm7 $(TARGET).arm9 #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- all: $(TARGET).nds -$(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf - ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ - -b $(CURDIR)/icon.bmp "Nitro Hax;DS Game Cheat Tool;Created by Chishm" +$(TARGET).nds : $(TARGET).arm7 $(TARGET).arm9 + ndstool -c $(TARGET).nds -7 arm7/$(TARGET).arm7.elf -9 arm9/$(TARGET).arm9.elf \ + -b $(CURDIR)/icon.bmp "NTR Launcher;NitroHax provided by Chishm;Modified by Apache Thunder" #--------------------------------------------------------------------------------- -# Create boot loader and link raw binary into ARM9 ELF +$(TARGET).arm7 : arm7/$(TARGET).elf +$(TARGET).arm9 : arm9/$(TARGET).elf + #--------------------------------------------------------------------------------- BootLoader/load.bin : BootLoader/source/* $(MAKE) -C BootLoader +#--------------------------------------------------------------------------------- arm9/data/load.bin : BootLoader/load.bin - mkdir -p $(@D) + rm -Rf arm9/data + mkdir arm9/data cp $< $@ #--------------------------------------------------------------------------------- @@ -54,17 +62,25 @@ arm9/$(TARGET).elf : arm9/data/load.bin arm9/source/version.h $(MAKE) -C arm9 #--------------------------------------------------------------------------------- -dist-bin : $(TARGET).nds README.md LICENSE - zip -X -9 $(TARGET)_v$(VERSTRING).zip $^ +dist-bin : $(TARGET).txt $(TARGET).nds License.txt + zip -X -9 $(TARGET)_v$(VERSTRING).zip $(TARGET).txt $(TARGET).nds License.txt dist-src : tar --exclude=*~ -cvjf $(TARGET)_src_v$(VERSTRING).tar.bz2 \ - --transform 's,^,$(TARGET)/,' \ - Makefile icon.bmp LICENSE README.md \ + --transform 's,^,/'$(TARGET)'/,' \ + Makefile icon.bmp License.txt Launcher.txt \ arm7/Makefile arm7/source \ - arm9/Makefile arm9/source arm9/graphics \ + arm9/Makefile arm9/source arm9/data arm9/graphics \ BootLoader/Makefile BootLoader/load.ld BootLoader/source +dist-legal : BootLoader/load.bin + tar --exclude=*~ --exclude=read_card.c -cvjf $(TARGET)_src_v$(VERSTRING).tar.bz2 \ + --transform 's,^,/'$(TARGET)'/,' \ + Makefile icon.bmp License.txt Launcher.txt \ + arm7/Makefile arm7/source \ + arm9/Makefile arm9/source arm9/data arm9/graphics \ + BootLoader/Makefile BootLoader/source BootLoader/load.bin + dist : dist-bin dist-src #--------------------------------------------------------------------------------- @@ -73,4 +89,5 @@ clean: $(MAKE) -C arm7 clean $(MAKE) -C BootLoader clean rm -f arm9/data/load.bin + rm -f arm9/source/version.h rm -f $(TARGET).ds.gba $(TARGET).nds $(TARGET).arm7 $(TARGET).arm9 diff --git a/NTR_Launcher.pnproj b/NTR_Launcher.pnproj new file mode 100644 index 0000000..b92660d --- /dev/null +++ b/NTR_Launcher.pnproj @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/NTR_Launcher.pnps b/NTR_Launcher.pnps new file mode 100644 index 0000000..247a62a --- /dev/null +++ b/NTR_Launcher.pnps @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/NitroHax_screen.png b/NitroHax_screen.png deleted file mode 100755 index 6aff822..0000000 Binary files a/NitroHax_screen.png and /dev/null differ diff --git a/PatchSRL.cmd b/PatchSRL.cmd new file mode 100644 index 0000000..5f72a60 --- /dev/null +++ b/PatchSRL.cmd @@ -0,0 +1,3 @@ +@Echo off +patch_ndsheader_dsiware.py NTR_Launcher.nds --mode dsi --maker 01 --code KKGP --title "TWL LAUNCHER" --out NTR_Launcher_Release.nds +pause \ No newline at end of file diff --git a/README.md b/README.md index 58b20a9..bd9512c 100755 --- a/README.md +++ b/README.md @@ -1,134 +1,8 @@ -Nitro Hax -========= +NTR Launcher (alternate build) - Apache Thunder - Original code from NitroHax but with cheat engine/menu stripped out. -By Chishm +Launcher side of NitroHax without the cheat engine. Nothing much else to say about it. :P -Nitro Hax is a cheat tool for the Nintendo DS. -It works with original games only. +The source to "Launch DS Cart" on FileTrip was never released. I rebuilt it after ahezard ported NitroHax to latest devkitarm. This project is GNU licensed so that original DS Launcher on File Trip should have included source anyways. +That has been corrected here. :D - -Usage -===== - -1. Patch NitroHax.nds with a DLDI file if you need to. -2. Copy the NitroHax.nds file to your media device. -3. Place an Action Replay XML file on your media device. -4. Start NitroHax.nds from your media device - 1. One of the following will be loaded automatically if it is found (in order of preference): - * "cheats.xml" in the current directory - * "/NitroHax/cheats.xml" - * "/data/NitroHax/cheats.xml" - * "/cheats.xml" - 2. If no file is found, browse for and select a file to open. -5. Remove your media device if you want to. -6. Remove any card that is in Slot-1 -7. Insert the DS game into Slot-1 -8. Choose the cheats you want to enable. - 1. Some cheats are enabled by default and others may be always on. This is specified in the XML file. - 2. The keys are: - * **A**: Open a folder or toggle a cheat enabled - * **B**: Go up a folder or exit the cheat menu if at the top level - * **X**: Enable all cheats in current folder - * **Y**: Disable all cheats in current folder - * **L**: Move up half a screen - * **R**: Move down half a screen - * **Up**: Move up one line - * **Down**: Move down one line - * **Start**: Start the game -9. When you are done, exit the cheat menu. -10. The game will then start with cheats running. - - -Copyright -========= - -Copyright (C) 2008 Michael "Chishm" Chisholm - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - - -Acknowledgements -================ - -Thanks to (in no particular order): -* Pink-Lightning - Original skin (v0.5-0.82) -* bLAStY - Memory dumps -* cReDiAr - Last crucial step for running DS Cards -* Parasyte - Tips for hooking the game automagically -* kenobi - Action Replay code document -* Darkain - Memory and cache clearing code -* Martin Korth - GBAtek -* Deathwind / WinterMute - File menu code (v0.2 - v0.4) -* Everyone else who helped me along the way - -Big thanks to Datel (CodeJunkies) for creating the original Action Replay and its cheats - - -Custom Code Types -================= - -``` -CF000000 00000000 - End of code list -CF000001 xxxxxxxx - Relocate cheat engine to xxxxxxxx -CF000002 xxxxxxxx - Change hook address to xxxxxxxx - -C100000x yyyyyyyy - Call function with arguments - x - number of arguments (0 - 4) - yyyyyyyy - Address of function - The argument list follows this code. To call a function at 0x02049A48, - with the arguments r0 = 0x00000010, r1 = 0x134CBA9C, r2 = 0x12345678, - you would use: - C1000003 02049A48 - 00000010 134CBA9C - 12345678 00000000 - -C200000x yyyyyyyy - Run code from cheat list - x - 0 = ARM mode, 1 = THUMB mode - yyyyyyyy - length of function in bytes - EG: - C2000000 00000010 - AAAAAAAA BBBBBBBB - CCCCCCCC E12FFF1E - This will run the code AAAAAAAA BBBBBBBB CCCCCCCC in ARM mode. - The E12FFF1E (bx lr) is needed at the end to return to the cheat engine. - (These instructions are based on those written by kenobi.) - -C4000000 xxxxxxxx - Safe data store (Based on Trainer Toolkit code) - Sets the offset register to point to the first word of this code. - Storing data at [offset+4] will save over the top of xxxxxxxx. - -C5000000 xxxxyyyy - Counter (Based on Trainer Toolkit code) - Each time the cheat engine is executed, the counter is incremented by 1. - If (counter & yyyy) == xxxx then execution status is set to true. - Else it is set to false. - -C6000000 xxxxxxxx - Store offset (Based on Trainer Toolkit code) - Stores the offset register to [xxxxxxxx]. - -D400000x yyyyyyyy - Dx Data operation - Performs the operation Data = Data ? yyyyyyyy where ? is determined by x as follows: - 0 - add - 1 - or - 2 - and - 3 - xor - 4 - logical shift left - 5 - logical shift right - 6 - rotate right - 7 - arithmetic shift right - 8 - multiply - -If type codes - Adds offset to the address if the lowest bit of the address is set. - Sets the address equal to offset if the original address is 0x00000000. -``` +Credits go to Chism for NitroHax which this source is based from. \ No newline at end of file diff --git a/arm7/Makefile b/arm7/Makefile index 72b8744..0a85e54 100755 --- a/arm7/Makefile +++ b/arm7/Makefile @@ -27,7 +27,6 @@ ARCH := -mthumb-interwork CFLAGS := -g -Wall -O2\ -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ -ffast-math \ - -Wall -Wextra -Werror \ $(ARCH) CFLAGS += $(INCLUDE) -DARM7 @@ -35,9 +34,9 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-rtti ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,-Map,$(notdir $*).map +LDFLAGS = -specs=../ds_arm7_ram.specs -g $(ARCH) -Wl,-Map,$(notdir $*).map -LIBS := -lnds7 +LIBS := -lmm7 -lnds7 #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing @@ -53,7 +52,8 @@ LIBDIRS := $(LIBNDS) ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- -export ARM7ELF := $(CURDIR)/$(TARGET).elf +export ARM7BIN := $(TOPDIR)/$(TARGET).arm7 +export ARM7ELF := $(CURDIR)/$(TARGET).arm7.elf export DEPSDIR := $(CURDIR)/$(BUILD) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) @@ -107,6 +107,11 @@ DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- +$(ARM7BIN) : $(ARM7ELF) + @$(OBJCOPY) -O binary $< $@ + @echo built ... $(notdir $@) + + $(ARM7ELF) : $(OFILES) @echo linking $(notdir $@) @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ diff --git a/arm7/ds_arm7_ram.ld b/arm7/ds_arm7_ram.ld new file mode 100644 index 0000000..52d6a5e --- /dev/null +++ b/arm7/ds_arm7_ram.ld @@ -0,0 +1,176 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) + +MEMORY { + rom : ORIGIN = 0x08000000, LENGTH = 32M + ram : ORIGIN = 0x2380000, LENGTH = 128K + iwram : ORIGIN = 0x037f8000, LENGTH = 96K +} + +__iwram_start = ORIGIN(iwram); +__iwram_top = ORIGIN(iwram)+ LENGTH(iwram); + +__sp_irq = __iwram_top - 0x100; +__sp_svc = __sp_irq - 0x100; +__sp_usr = __sp_svc - 0x100; + +__irq_flags = 0x04000000 - 8; +__irq_flagsaux = 0x04000000 - 0x40; +__irq_vector = 0x04000000 - 4; + +SECTIONS +{ + .init : + { + __text_start = . ; + KEEP (*(.init)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + .plt : { *(.plt) } >ram = 0xff + + .text : /* ALIGN (4): */ + { + *(.text .stub .text.* .gnu.linkonce.t.*) + KEEP (*(.text.*personality*)) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .fini : + { + KEEP (*(.fini)) + } >ram =0xff + + __text_end = . ; + + .rodata : + { + *(.rodata) + *all.rodata*(*) + *(.roda) + *(.rodata.*) + *(.gnu.linkonce.r*) + SORT(CONSTRUCTORS) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ram + __exidx_start = .; + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ram + __exidx_end = .; + +/* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(32 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { KEEP (*(.preinit_array)) } >ram = 0xff + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { KEEP (*(.init_array)) } >ram = 0xff + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { KEEP (*(.fini_array)) } >ram = 0xff + PROVIDE (__fini_array_end = .); + + .ctors : + { + /* gcc uses crtbegin.o to find the start of the constructors, so + we make sure it is first. Because this is a wildcard, it + doesn't matter if the user does not actually link against + crtbegin.o; the linker won't look for a file to match a + wildcard. The wildcard also means that it doesn't matter which + directory crtbegin.o is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .eh_frame : + { + KEEP (*(.eh_frame)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .gcc_except_table : + { + *(.gcc_except_table) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + .jcr : { KEEP (*(.jcr)) } >ram = 0 + .got : { *(.got.plt) *(.got) } >ram = 0 + + .data ALIGN(4) : { + __data_start = ABSOLUTE(.); + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + CONSTRUCTORS + . = ALIGN(4); + __data_end = ABSOLUTE(.) ; + } >ram = 0xff + + .bss ALIGN(4) : + { + __bss_start = ABSOLUTE(.); + __bss_start__ = ABSOLUTE(.); + *(.dynbss) + *(.gnu.linkonce.b*) + *(.bss*) + *(COMMON) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + __bss_end__ = ABSOLUTE(.); + __end__ = ABSOLUTE(.); + } >ram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .stack 0x80000 : { _stack = .; *(.stack) } + /* These must appear regardless of . */ +} diff --git a/arm7/ds_arm7_ram.specs b/arm7/ds_arm7_ram.specs new file mode 100644 index 0000000..c82aa96 --- /dev/null +++ b/arm7/ds_arm7_ram.specs @@ -0,0 +1,8 @@ +%rename link old_link + +*link: +%(old_link) -T ../ds_arm7_ram.ld%s --gc-sections + +*startfile: +ds_arm7_crt0%O%s crti%O%s crtbegin%O%s + diff --git a/arm7/source/bios.s b/arm7/source/bios.s new file mode 100644 index 0000000..7b14333 --- /dev/null +++ b/arm7/source/bios.s @@ -0,0 +1,61 @@ +#define ARM7 + +/*--------------------------------------------------------------------------------- + + Copyright (C) 2009 + Dave Murphy (WinterMute) + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + +---------------------------------------------------------------------------------*/ + + .text + .align 4 + + .arm +@--------------------------------------------------------------------------------- + .global swiSoftReset2 + .type swiSoftReset2 STT_FUNC +@--------------------------------------------------------------------------------- +swiSoftReset2: +@--------------------------------------------------------------------------------- + REG_IME = 0; +#ifdef ARM7 + ldr r0,=0x2FFFE34 +#endif + +#ifdef ARM9 + .arch armv5te + .cpu arm946e-s + ldr r1, =0x00002078 @ disable TCM and protection unit + mcr p15, 0, r1, c1, c0 + @ Disable cache + mov r0, #0 + mcr p15, 0, r0, c7, c5, 0 @ Instruction cache + mcr p15, 0, r0, c7, c6, 0 @ Data cache + + @ Wait for write buffer to empty + mcr p15, 0, r0, c7, c10, 4 + + ldr r0,=0x2FFFE24 +#endif + + ldr r0,[r0] + bx r0 + + .pool \ No newline at end of file diff --git a/arm7/source/launch_engine_arm7.c b/arm7/source/launch_engine_arm7.c new file mode 100644 index 0000000..cc1b530 --- /dev/null +++ b/arm7/source/launch_engine_arm7.c @@ -0,0 +1,44 @@ +/* + NitroHax -- Cheat tool for the Nintendo DS + Copyright (C) 2008 Michael "Chishm" Chisholm + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include + +// #define REG_ROMCTRL (*(vu32*)0x40001A4) +#define REG_SCFG_ROM (*(vu32*)0x4004000) +#define REG_SCFG_CLK (*(vu32*)0x4004004) +#define REG_SCFG_EXT (*(vu32*)0x4004008) +// #define REG_SCFG_MC (*(vu32*)0x4004010) + +void runLaunchEngineCheck (void) +{ + + if(*((vu32*)0x027FFE24) == (u32)0x027FFE04) + { + if(fifoCheckValue32(FIFO_USER_04)) { + if(fifoCheckValue32(FIFO_USER_05)) { REG_SCFG_CLK = 0x0181; } else { REG_SCFG_CLK = 0x0180; } + } + if(fifoCheckValue32(FIFO_USER_06)) { /*Do Nothing*/ } else { REG_SCFG_ROM = 0x703; } + if(fifoCheckValue32(FIFO_USER_05)) { REG_SCFG_EXT = 0x93A50000; } else { REG_SCFG_EXT = 0x12A00000; } + + irqDisable (IRQ_ALL); + *((vu32*)0x027FFE34) = (u32)0x06000000; + + swiSoftReset(); + } +} + diff --git a/arm7/source/cheat_engine_arm7.h b/arm7/source/launch_engine_arm7.h old mode 100755 new mode 100644 similarity index 87% rename from arm7/source/cheat_engine_arm7.h rename to arm7/source/launch_engine_arm7.h index 213bbe6..cd3576b --- a/arm7/source/cheat_engine_arm7.h +++ b/arm7/source/launch_engine_arm7.h @@ -16,20 +16,19 @@ along with this program. If not, see . */ -#ifndef CHEAT_ENGINE_ARM7_H -#define CHEAT_ENGINE_ARM7_H +#ifndef LAUNCH_ENGINE_ARM7_H +#define LAUNCH_ENGINE_ARM7_H #ifdef __cplusplus extern "C" { #endif - -void runCheatEngineCheck (void); - +void runLaunchEngineCheck (void); #ifdef __cplusplus } #endif -#endif // CHEAT_ENGINE_ARM7_H +#endif // LAUNCH_ENGINE_ARM7_H + diff --git a/arm7/source/main.c b/arm7/source/main.c index df01f49..1fabe0a 100755 --- a/arm7/source/main.c +++ b/arm7/source/main.c @@ -20,8 +20,15 @@ #include #include -#include "cheat_engine_arm7.h" +#include +#include "launch_engine_arm7.h" + +#define REG_ROMCTRL (*(vu32*)0x40001A4) +#define REG_SCFG_ROM (*(vu32*)0x4004000) +#define REG_SCFG_CLK (*(vu32*)0x4004004) +#define REG_SCFG_EXT (*(vu32*)0x4004008) +#define REG_SCFG_MC (*(vu32*)0x4004010) void VcountHandler() { inputGetAndSend(); @@ -30,10 +37,41 @@ void VcountHandler() { void VblankHandler(void) { } -//--------------------------------------------------------------------------------- -int main(void) { -//--------------------------------------------------------------------------------- +void PowerOnSlot() { + // Power On Slot + while(REG_SCFG_MC&0x0C != 0x0C); // wait until state<>3 + if(REG_SCFG_MC&0x0C != 0x00) return; // exit if state<>0 + + REG_SCFG_MC = 0x04; // wait 1ms, then set state=1 + while(REG_SCFG_MC&0x0C != 0x04); + + REG_SCFG_MC = 0x08; // wait 10ms, then set state=2 + while(REG_SCFG_MC&0x0C != 0x08); + + REG_ROMCTRL = 0x20000000; // wait 27ms, then set ROMCTRL=20000000h + + while(REG_ROMCTRL&0x8000000 != 0x8000000); + +} +void PowerOffSlot() { + while(REG_SCFG_MC&0x0C != 0x0C); // wait until state<>3 + if(REG_SCFG_MC&0x0C != 0x08) return 1; // exit if state<>2 + + REG_SCFG_MC = 0x0C; // set state=3 + while(REG_SCFG_MC&0x0C != 0x00); // wait until state=0 +} + +void TWL_ResetSlot1() { + PowerOffSlot(); + for (int i = 0; i < 30; i++) { swiWaitForVBlank(); } + PowerOnSlot(); +} + +int main(void) { + + REG_SCFG_CLK = 0x0187; + irqInit(); fifoInit(); @@ -42,21 +80,30 @@ int main(void) { // Start the RTC tracking IRQ initClockIRQ(); + + mmInstall(FIFO_MAXMOD); SetYtrigger(80); + installSoundFIFO(); installSystemFIFO(); - + irqSet(IRQ_VCOUNT, VcountHandler); irqSet(IRQ_VBLANK, VblankHandler); irqEnable( IRQ_VBLANK | IRQ_VCOUNT); - - // Keep the ARM7 mostly idle + + // Make sure Arm9 had a chance to check slot status + fifoWaitValue32(FIFO_USER_01); + // If Arm9 reported slot is powered off, have Arm7 wait for Arm9 to be ready before card reset. This makes sure arm7 doesn't try card reset too early. + if(fifoCheckValue32(FIFO_USER_02)) { + if(fifoCheckValue32(FIFO_USER_07)) { TWL_ResetSlot1(); } else { PowerOnSlot(); } + } + fifoSendValue32(FIFO_USER_03, 1); + while (1) { - runCheatEngineCheck(); + runLaunchEngineCheck(); swiWaitForVBlank(); } } - diff --git a/arm9/Makefile b/arm9/Makefile index 236a50e..b47cd58 100755 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -19,6 +19,7 @@ IMAGES := graphics SOURCES := source $(IMG_DATA) INCLUDES := include DATA := data +MUSIC := music #--------------------------------------------------------------------------------- # options for code generation @@ -28,10 +29,9 @@ ARCH := -mthumb -mthumb-interwork CFLAGS := -g -Wall -O2\ -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ -ffast-math \ - -Wall -Wextra -Werror \ $(ARCH) -CFLAGS += $(INCLUDE) -DARM9 +CFLAGS += $(INCLUDE) -DARM9 -fno-strict-aliasing CXXFLAGS := $(CFLAGS) ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s @@ -41,7 +41,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lfat -lnds9 +LIBS := -lfat -lmm9 -lnds9 #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing @@ -56,16 +56,19 @@ LIBDIRS := $(LIBNDS) ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- -export ARM9ELF := $(CURDIR)/$(TARGET).elf +export ARM9BIN := $(TOPDIR)/$(TARGET).arm9 +export ARM9ELF := $(CURDIR)/$(TARGET).arm9.elf export DEPSDIR := $(CURDIR)/$(BUILD) +export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir)) + export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) soundbank.bin BMPFILES := $(foreach dir,$(IMAGES),$(notdir $(wildcard $(dir)/*.bmp))) @@ -106,7 +109,9 @@ clean: #--------------------------------------------------------------------------------- else - + +DEPENDS := $(OFILES:.o=.d) + #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- @@ -122,39 +127,390 @@ $(ARM9ELF) : $(OFILES) #--------------------------------------------------------------------------------- # graphics #--------------------------------------------------------------------------------- -bgtop.s : ../$(IMAGES)/bgtop.bmp - grit $< -gB4 -gzl -fts -o $@ -q +#Cartridge Wait Prompt (bottom screen) +CartPrompt01.s : ../$(IMAGES)/CartPrompt01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +CartPrompt02.s : ../$(IMAGES)/CartPrompt02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +CartPrompt03.s : ../$(IMAGES)/CartPrompt03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +CartPrompt04.s : ../$(IMAGES)/CartPrompt04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +#DSi Cartridge Wait Prompt (bottom screen) +DSiCartPrompt01.s : ../$(IMAGES)/DSiCartPrompt01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSiCartPrompt02.s : ../$(IMAGES)/DSiCartPrompt02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSiCartPrompt03.s : ../$(IMAGES)/DSiCartPrompt03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSiCartPrompt04.s : ../$(IMAGES)/DSiCartPrompt04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +# generic fade from white to black + +fade00.s : ../$(IMAGES)/fade00.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +fade01.s : ../$(IMAGES)/fade01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +fade02.s : ../$(IMAGES)/fade02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +fade03.s : ../$(IMAGES)/fade03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +fade04.s : ../$(IMAGES)/fade04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +# generic bottom screen error message +suberror00.s : ../$(IMAGES)/suberror00.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -bgsub.s : ../$(IMAGES)/bgsub.bmp - grit $< -gB4 -gzl -fts -o $@ -q +suberror01.s : ../$(IMAGES)/suberror01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -cursor.s : ../$(IMAGES)/cursor.bmp - grit $< -gB4 -fts -Mw8 -Mh4 -o $@ -q +suberror02.s : ../$(IMAGES)/suberror02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -font.s : ../$(IMAGES)/font.bmp - grit $< -gB4 -gzl -fts -o font.s -q +suberror03.s : ../$(IMAGES)/suberror03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -button_go.s : ../$(IMAGES)/button_go.bmp - grit $< -gB4 -fts -Mw16 -Mh4 -o $@ -q +suberror04.s : ../$(IMAGES)/suberror04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -button_on.s : ../$(IMAGES)/button_on.bmp - grit $< -gB4 -fts -Mw30 -Mh2 -o $@ -q +suberror05.s : ../$(IMAGES)/suberror05.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -button_off.s : ../$(IMAGES)/button_off.bmp - grit $< -gB4 -fts -Mw30 -Mh2 -o $@ -q +suberror06.s : ../$(IMAGES)/suberror06.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -button_folder.s : ../$(IMAGES)/button_folder.bmp - grit $< -gB4 -fts -Mw30 -Mh2 -o $@ -q +# No Cartridge Error +toperror2_00.s : ../$(IMAGES)/toperror2_00.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -button_file.s : ../$(IMAGES)/button_file.bmp - grit $< -gB4 -fts -Mw30 -Mh2 -o $@ -q +toperror2_01.s : ../$(IMAGES)/toperror2_01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -scrollbar.s : ../$(IMAGES)/scrollbar.bmp - grit $< -gB4 -Mw2 -Mh2 -fts -o scrollbar.s -q +toperror2_02.s : ../$(IMAGES)/toperror2_02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q -textbox.s : ../$(IMAGES)/textbox.bmp - grit $< -gB4 -fts -o textbox.s -q +toperror2_03.s : ../$(IMAGES)/toperror2_03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q +toperror2_04.s : ../$(IMAGES)/toperror2_04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +toperror2_05.s : ../$(IMAGES)/toperror2_05.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +toperror2_06.s : ../$(IMAGES)/toperror2_06.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +# Main Boot Splash sequence +Bot00.s : ../$(IMAGES)/Bot00.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot01.s : ../$(IMAGES)/Bot01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot02.s : ../$(IMAGES)/Bot02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot03.s : ../$(IMAGES)/Bot03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot04.s : ../$(IMAGES)/Bot04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot05.s : ../$(IMAGES)/Bot05.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot06.s : ../$(IMAGES)/Bot06.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot07.s : ../$(IMAGES)/Bot07.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot08.s : ../$(IMAGES)/Bot08.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot09.s : ../$(IMAGES)/Bot09.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Bot10.s : ../$(IMAGES)/Bot10.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top00.s : ../$(IMAGES)/Top00.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top01.s : ../$(IMAGES)/Top01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top02.s : ../$(IMAGES)/Top02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top03.s : ../$(IMAGES)/Top03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top04.s : ../$(IMAGES)/Top04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top05.s : ../$(IMAGES)/Top05.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top06.s : ../$(IMAGES)/Top06.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top07.s : ../$(IMAGES)/Top07.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top08.s : ../$(IMAGES)/Top08.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top09.s : ../$(IMAGES)/Top09.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top10.s : ../$(IMAGES)/Top10.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top11.s : ../$(IMAGES)/Top11.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top12.s : ../$(IMAGES)/Top12.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top13.s : ../$(IMAGES)/Top13.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top14.s : ../$(IMAGES)/Top14.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top15.s : ../$(IMAGES)/Top15.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top16.s : ../$(IMAGES)/Top16.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top17.s : ../$(IMAGES)/Top17.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top18.s : ../$(IMAGES)/Top18.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top19.s : ../$(IMAGES)/Top19.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top20.s : ../$(IMAGES)/Top20.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top21.s : ../$(IMAGES)/Top21.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top22.s : ../$(IMAGES)/Top22.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top23.s : ../$(IMAGES)/Top23.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top24.s : ../$(IMAGES)/Top24.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top25.s : ../$(IMAGES)/Top25.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top26.s : ../$(IMAGES)/Top26.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top27.s : ../$(IMAGES)/Top27.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top28.s : ../$(IMAGES)/Top28.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top29.s : ../$(IMAGES)/Top29.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top30.s : ../$(IMAGES)/Top30.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top31.s : ../$(IMAGES)/Top31.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top32.s : ../$(IMAGES)/Top32.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top33.s : ../$(IMAGES)/Top33.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top34.s : ../$(IMAGES)/Top34.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top35.s : ../$(IMAGES)/Top35.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top36.s : ../$(IMAGES)/Top36.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +Top37.s : ../$(IMAGES)/Top37.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +# DSi BootSplash. Used if TWL mode detected +DSi01.s : ../$(IMAGES)/DSi01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi02.s : ../$(IMAGES)/DSi02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi03.s : ../$(IMAGES)/DSi03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi04.s : ../$(IMAGES)/DSi04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi05.s : ../$(IMAGES)/DSi05.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi06.s : ../$(IMAGES)/DSi06.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi07.s : ../$(IMAGES)/DSi07.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi08.s : ../$(IMAGES)/DSi08.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi09.s : ../$(IMAGES)/DSi09.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi10.s : ../$(IMAGES)/DSi10.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi11.s : ../$(IMAGES)/DSi11.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi12.s : ../$(IMAGES)/DSi12.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi13.s : ../$(IMAGES)/DSi13.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi14.s : ../$(IMAGES)/DSi14.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi15.s : ../$(IMAGES)/DSi15.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi16.s : ../$(IMAGES)/DSi16.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi17.s : ../$(IMAGES)/DSi17.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi18.s : ../$(IMAGES)/DSi18.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi19.s : ../$(IMAGES)/DSi19.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi20.s : ../$(IMAGES)/DSi20.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi21.s : ../$(IMAGES)/DSi21.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi22.s : ../$(IMAGES)/DSi22.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi23.s : ../$(IMAGES)/DSi23.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi24.s : ../$(IMAGES)/DSi24.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi25.s : ../$(IMAGES)/DSi25.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi26.s : ../$(IMAGES)/DSi26.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi27.s : ../$(IMAGES)/DSi27.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi28.s : ../$(IMAGES)/DSi28.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi29.s : ../$(IMAGES)/DSi29.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi30.s : ../$(IMAGES)/DSi30.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi31.s : ../$(IMAGES)/DSi31.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi32.s : ../$(IMAGES)/DSi32.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi33.s : ../$(IMAGES)/DSi33.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi34.s : ../$(IMAGES)/DSi34.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +DSi35.s : ../$(IMAGES)/DSi35.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +#DSi version of bottom screen +BotDSi00.s : ../$(IMAGES)/BotDSi00.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi01.s : ../$(IMAGES)/BotDSi01.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi02.s : ../$(IMAGES)/BotDSi02.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi03.s : ../$(IMAGES)/BotDSi03.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi04.s : ../$(IMAGES)/BotDSi04.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi05.s : ../$(IMAGES)/BotDSi05.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi06.s : ../$(IMAGES)/BotDSi06.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi07.s : ../$(IMAGES)/BotDSi07.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi08.s : ../$(IMAGES)/BotDSi08.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi09.s : ../$(IMAGES)/BotDSi09.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi10.s : ../$(IMAGES)/BotDSi10.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +BotDSi11.s : ../$(IMAGES)/BotDSi11.bmp + grit $< -gB8 -gzl -fts -gTff00ff -o $@ -q + +#--------------------------------------------------------------------------------- +# rule to build soundbank from music files +#--------------------------------------------------------------------------------- +soundbank.bin : $(AUDIOFILES) +#--------------------------------------------------------------------------------- + @mmutil $^ -d -osoundbank.bin -hsoundbank.h #--------------------------------------------------------------------------------- # you need a rule like this for each extension you use as binary data @@ -164,7 +520,7 @@ textbox.s : ../$(IMAGES)/textbox.bmp @echo $(notdir $<) @$(bin2o) --include $(DEPSDIR)/*.d +-include $(DEPENDS) #--------------------------------------------------------------------------------------- endif diff --git a/arm9/graphics/Bot00.bmp b/arm9/graphics/Bot00.bmp new file mode 100644 index 0000000..4201844 Binary files /dev/null and b/arm9/graphics/Bot00.bmp differ diff --git a/arm9/graphics/Bot01.bmp b/arm9/graphics/Bot01.bmp new file mode 100644 index 0000000..4201844 Binary files /dev/null and b/arm9/graphics/Bot01.bmp differ diff --git a/arm9/graphics/Bot02.bmp b/arm9/graphics/Bot02.bmp new file mode 100644 index 0000000..0505f81 Binary files /dev/null and b/arm9/graphics/Bot02.bmp differ diff --git a/arm9/graphics/Bot03.bmp b/arm9/graphics/Bot03.bmp new file mode 100644 index 0000000..1b8d1ee Binary files /dev/null and b/arm9/graphics/Bot03.bmp differ diff --git a/arm9/graphics/Bot04.bmp b/arm9/graphics/Bot04.bmp new file mode 100644 index 0000000..bed7b4a Binary files /dev/null and b/arm9/graphics/Bot04.bmp differ diff --git a/arm9/graphics/Bot05.bmp b/arm9/graphics/Bot05.bmp new file mode 100644 index 0000000..8ff7ba8 Binary files /dev/null and b/arm9/graphics/Bot05.bmp differ diff --git a/arm9/graphics/Bot06.bmp b/arm9/graphics/Bot06.bmp new file mode 100644 index 0000000..bed7b4a Binary files /dev/null and b/arm9/graphics/Bot06.bmp differ diff --git a/arm9/graphics/Bot07.bmp b/arm9/graphics/Bot07.bmp new file mode 100644 index 0000000..1b8d1ee Binary files /dev/null and b/arm9/graphics/Bot07.bmp differ diff --git a/arm9/graphics/Bot08.bmp b/arm9/graphics/Bot08.bmp new file mode 100644 index 0000000..0505f81 Binary files /dev/null and b/arm9/graphics/Bot08.bmp differ diff --git a/arm9/graphics/Bot09.bmp b/arm9/graphics/Bot09.bmp new file mode 100644 index 0000000..4201844 Binary files /dev/null and b/arm9/graphics/Bot09.bmp differ diff --git a/arm9/graphics/Bot10.bmp b/arm9/graphics/Bot10.bmp new file mode 100644 index 0000000..4201844 Binary files /dev/null and b/arm9/graphics/Bot10.bmp differ diff --git a/arm9/graphics/BotDSi00.bmp b/arm9/graphics/BotDSi00.bmp new file mode 100644 index 0000000..4201844 Binary files /dev/null and b/arm9/graphics/BotDSi00.bmp differ diff --git a/arm9/graphics/BotDSi01.bmp b/arm9/graphics/BotDSi01.bmp new file mode 100644 index 0000000..3c76727 Binary files /dev/null and b/arm9/graphics/BotDSi01.bmp differ diff --git a/arm9/graphics/BotDSi02.bmp b/arm9/graphics/BotDSi02.bmp new file mode 100644 index 0000000..ec0a432 Binary files /dev/null and b/arm9/graphics/BotDSi02.bmp differ diff --git a/arm9/graphics/BotDSi03.bmp b/arm9/graphics/BotDSi03.bmp new file mode 100644 index 0000000..a772c3e Binary files /dev/null and b/arm9/graphics/BotDSi03.bmp differ diff --git a/arm9/graphics/BotDSi04.bmp b/arm9/graphics/BotDSi04.bmp new file mode 100644 index 0000000..364df69 Binary files /dev/null and b/arm9/graphics/BotDSi04.bmp differ diff --git a/arm9/graphics/BotDSi05.bmp b/arm9/graphics/BotDSi05.bmp new file mode 100644 index 0000000..f52cbdb Binary files /dev/null and b/arm9/graphics/BotDSi05.bmp differ diff --git a/arm9/graphics/BotDSi06.bmp b/arm9/graphics/BotDSi06.bmp new file mode 100644 index 0000000..5a1c902 Binary files /dev/null and b/arm9/graphics/BotDSi06.bmp differ diff --git a/arm9/graphics/BotDSi07.bmp b/arm9/graphics/BotDSi07.bmp new file mode 100644 index 0000000..f5b598f Binary files /dev/null and b/arm9/graphics/BotDSi07.bmp differ diff --git a/arm9/graphics/BotDSi08.bmp b/arm9/graphics/BotDSi08.bmp new file mode 100644 index 0000000..4897f71 Binary files /dev/null and b/arm9/graphics/BotDSi08.bmp differ diff --git a/arm9/graphics/BotDSi09.bmp b/arm9/graphics/BotDSi09.bmp new file mode 100644 index 0000000..ec0a432 Binary files /dev/null and b/arm9/graphics/BotDSi09.bmp differ diff --git a/arm9/graphics/BotDSi10.bmp b/arm9/graphics/BotDSi10.bmp new file mode 100644 index 0000000..aaa2902 Binary files /dev/null and b/arm9/graphics/BotDSi10.bmp differ diff --git a/arm9/graphics/BotDSi11.bmp b/arm9/graphics/BotDSi11.bmp new file mode 100644 index 0000000..59449b8 Binary files /dev/null and b/arm9/graphics/BotDSi11.bmp differ diff --git a/arm9/graphics/CartPrompt01.bmp b/arm9/graphics/CartPrompt01.bmp new file mode 100644 index 0000000..94ac22e Binary files /dev/null and b/arm9/graphics/CartPrompt01.bmp differ diff --git a/arm9/graphics/CartPrompt02.bmp b/arm9/graphics/CartPrompt02.bmp new file mode 100644 index 0000000..647ce46 Binary files /dev/null and b/arm9/graphics/CartPrompt02.bmp differ diff --git a/arm9/graphics/CartPrompt03.bmp b/arm9/graphics/CartPrompt03.bmp new file mode 100644 index 0000000..a681f7c Binary files /dev/null and b/arm9/graphics/CartPrompt03.bmp differ diff --git a/arm9/graphics/CartPrompt04.bmp b/arm9/graphics/CartPrompt04.bmp new file mode 100644 index 0000000..2fe0394 Binary files /dev/null and b/arm9/graphics/CartPrompt04.bmp differ diff --git a/arm9/graphics/DSi01.bmp b/arm9/graphics/DSi01.bmp new file mode 100644 index 0000000..377c08e Binary files /dev/null and b/arm9/graphics/DSi01.bmp differ diff --git a/arm9/graphics/DSi02.bmp b/arm9/graphics/DSi02.bmp new file mode 100644 index 0000000..df0ff50 Binary files /dev/null and b/arm9/graphics/DSi02.bmp differ diff --git a/arm9/graphics/DSi03.bmp b/arm9/graphics/DSi03.bmp new file mode 100644 index 0000000..a66974a Binary files /dev/null and b/arm9/graphics/DSi03.bmp differ diff --git a/arm9/graphics/DSi04.bmp b/arm9/graphics/DSi04.bmp new file mode 100644 index 0000000..80bc2ed Binary files /dev/null and b/arm9/graphics/DSi04.bmp differ diff --git a/arm9/graphics/DSi05.bmp b/arm9/graphics/DSi05.bmp new file mode 100644 index 0000000..18050be Binary files /dev/null and b/arm9/graphics/DSi05.bmp differ diff --git a/arm9/graphics/DSi06.bmp b/arm9/graphics/DSi06.bmp new file mode 100644 index 0000000..11d6e0e Binary files /dev/null and b/arm9/graphics/DSi06.bmp differ diff --git a/arm9/graphics/DSi07.bmp b/arm9/graphics/DSi07.bmp new file mode 100644 index 0000000..5ef4f35 Binary files /dev/null and b/arm9/graphics/DSi07.bmp differ diff --git a/arm9/graphics/DSi08.bmp b/arm9/graphics/DSi08.bmp new file mode 100644 index 0000000..17fe698 Binary files /dev/null and b/arm9/graphics/DSi08.bmp differ diff --git a/arm9/graphics/DSi09.bmp b/arm9/graphics/DSi09.bmp new file mode 100644 index 0000000..9eadc4f Binary files /dev/null and b/arm9/graphics/DSi09.bmp differ diff --git a/arm9/graphics/DSi10.bmp b/arm9/graphics/DSi10.bmp new file mode 100644 index 0000000..e604d52 Binary files /dev/null and b/arm9/graphics/DSi10.bmp differ diff --git a/arm9/graphics/DSi11.bmp b/arm9/graphics/DSi11.bmp new file mode 100644 index 0000000..6aaead5 Binary files /dev/null and b/arm9/graphics/DSi11.bmp differ diff --git a/arm9/graphics/DSi12.bmp b/arm9/graphics/DSi12.bmp new file mode 100644 index 0000000..62233f5 Binary files /dev/null and b/arm9/graphics/DSi12.bmp differ diff --git a/arm9/graphics/DSi13.bmp b/arm9/graphics/DSi13.bmp new file mode 100644 index 0000000..b992bc3 Binary files /dev/null and b/arm9/graphics/DSi13.bmp differ diff --git a/arm9/graphics/DSi14.bmp b/arm9/graphics/DSi14.bmp new file mode 100644 index 0000000..c6dde56 Binary files /dev/null and b/arm9/graphics/DSi14.bmp differ diff --git a/arm9/graphics/DSi15.bmp b/arm9/graphics/DSi15.bmp new file mode 100644 index 0000000..05ec3aa Binary files /dev/null and b/arm9/graphics/DSi15.bmp differ diff --git a/arm9/graphics/DSi16.bmp b/arm9/graphics/DSi16.bmp new file mode 100644 index 0000000..3c94ba8 Binary files /dev/null and b/arm9/graphics/DSi16.bmp differ diff --git a/arm9/graphics/DSi17.bmp b/arm9/graphics/DSi17.bmp new file mode 100644 index 0000000..24a122d Binary files /dev/null and b/arm9/graphics/DSi17.bmp differ diff --git a/arm9/graphics/DSi18.bmp b/arm9/graphics/DSi18.bmp new file mode 100644 index 0000000..e301326 Binary files /dev/null and b/arm9/graphics/DSi18.bmp differ diff --git a/arm9/graphics/DSi19.bmp b/arm9/graphics/DSi19.bmp new file mode 100644 index 0000000..183d2c7 Binary files /dev/null and b/arm9/graphics/DSi19.bmp differ diff --git a/arm9/graphics/DSi20.bmp b/arm9/graphics/DSi20.bmp new file mode 100644 index 0000000..ca2b412 Binary files /dev/null and b/arm9/graphics/DSi20.bmp differ diff --git a/arm9/graphics/DSi21.bmp b/arm9/graphics/DSi21.bmp new file mode 100644 index 0000000..5bd0b87 Binary files /dev/null and b/arm9/graphics/DSi21.bmp differ diff --git a/arm9/graphics/DSi22.bmp b/arm9/graphics/DSi22.bmp new file mode 100644 index 0000000..2c683b5 Binary files /dev/null and b/arm9/graphics/DSi22.bmp differ diff --git a/arm9/graphics/DSi23.bmp b/arm9/graphics/DSi23.bmp new file mode 100644 index 0000000..440ebae Binary files /dev/null and b/arm9/graphics/DSi23.bmp differ diff --git a/arm9/graphics/DSi24.bmp b/arm9/graphics/DSi24.bmp new file mode 100644 index 0000000..b70ff84 Binary files /dev/null and b/arm9/graphics/DSi24.bmp differ diff --git a/arm9/graphics/DSi25.bmp b/arm9/graphics/DSi25.bmp new file mode 100644 index 0000000..26ebd84 Binary files /dev/null and b/arm9/graphics/DSi25.bmp differ diff --git a/arm9/graphics/DSi26.bmp b/arm9/graphics/DSi26.bmp new file mode 100644 index 0000000..3b06d7f Binary files /dev/null and b/arm9/graphics/DSi26.bmp differ diff --git a/arm9/graphics/DSi27.bmp b/arm9/graphics/DSi27.bmp new file mode 100644 index 0000000..efe9081 Binary files /dev/null and b/arm9/graphics/DSi27.bmp differ diff --git a/arm9/graphics/DSi28.bmp b/arm9/graphics/DSi28.bmp new file mode 100644 index 0000000..79da95b Binary files /dev/null and b/arm9/graphics/DSi28.bmp differ diff --git a/arm9/graphics/DSi29.bmp b/arm9/graphics/DSi29.bmp new file mode 100644 index 0000000..fff7b42 Binary files /dev/null and b/arm9/graphics/DSi29.bmp differ diff --git a/arm9/graphics/DSi30.bmp b/arm9/graphics/DSi30.bmp new file mode 100644 index 0000000..0b1e0b6 Binary files /dev/null and b/arm9/graphics/DSi30.bmp differ diff --git a/arm9/graphics/DSi31.bmp b/arm9/graphics/DSi31.bmp new file mode 100644 index 0000000..da586e3 Binary files /dev/null and b/arm9/graphics/DSi31.bmp differ diff --git a/arm9/graphics/DSi32.bmp b/arm9/graphics/DSi32.bmp new file mode 100644 index 0000000..c798c58 Binary files /dev/null and b/arm9/graphics/DSi32.bmp differ diff --git a/arm9/graphics/DSi33.bmp b/arm9/graphics/DSi33.bmp new file mode 100644 index 0000000..575df4a Binary files /dev/null and b/arm9/graphics/DSi33.bmp differ diff --git a/arm9/graphics/DSi34.bmp b/arm9/graphics/DSi34.bmp new file mode 100644 index 0000000..bcd0825 Binary files /dev/null and b/arm9/graphics/DSi34.bmp differ diff --git a/arm9/graphics/DSi35.bmp b/arm9/graphics/DSi35.bmp new file mode 100644 index 0000000..f099ede Binary files /dev/null and b/arm9/graphics/DSi35.bmp differ diff --git a/arm9/graphics/DSiCartPrompt01.bmp b/arm9/graphics/DSiCartPrompt01.bmp new file mode 100644 index 0000000..5d15f1c Binary files /dev/null and b/arm9/graphics/DSiCartPrompt01.bmp differ diff --git a/arm9/graphics/DSiCartPrompt02.bmp b/arm9/graphics/DSiCartPrompt02.bmp new file mode 100644 index 0000000..db7a44c Binary files /dev/null and b/arm9/graphics/DSiCartPrompt02.bmp differ diff --git a/arm9/graphics/DSiCartPrompt03.bmp b/arm9/graphics/DSiCartPrompt03.bmp new file mode 100644 index 0000000..c8c6dc7 Binary files /dev/null and b/arm9/graphics/DSiCartPrompt03.bmp differ diff --git a/arm9/graphics/DSiCartPrompt04.bmp b/arm9/graphics/DSiCartPrompt04.bmp new file mode 100644 index 0000000..be9d67b Binary files /dev/null and b/arm9/graphics/DSiCartPrompt04.bmp differ diff --git a/arm9/graphics/Top00.bmp b/arm9/graphics/Top00.bmp new file mode 100644 index 0000000..377c08e Binary files /dev/null and b/arm9/graphics/Top00.bmp differ diff --git a/arm9/graphics/Top01.bmp b/arm9/graphics/Top01.bmp new file mode 100644 index 0000000..377c08e Binary files /dev/null and b/arm9/graphics/Top01.bmp differ diff --git a/arm9/graphics/Top02.bmp b/arm9/graphics/Top02.bmp new file mode 100644 index 0000000..a7fadbf Binary files /dev/null and b/arm9/graphics/Top02.bmp differ diff --git a/arm9/graphics/Top03.bmp b/arm9/graphics/Top03.bmp new file mode 100644 index 0000000..1b85c81 Binary files /dev/null and b/arm9/graphics/Top03.bmp differ diff --git a/arm9/graphics/Top04.bmp b/arm9/graphics/Top04.bmp new file mode 100644 index 0000000..09e5d4b Binary files /dev/null and b/arm9/graphics/Top04.bmp differ diff --git a/arm9/graphics/Top05.bmp b/arm9/graphics/Top05.bmp new file mode 100644 index 0000000..b47f250 Binary files /dev/null and b/arm9/graphics/Top05.bmp differ diff --git a/arm9/graphics/Top06.bmp b/arm9/graphics/Top06.bmp new file mode 100644 index 0000000..a3523f3 Binary files /dev/null and b/arm9/graphics/Top06.bmp differ diff --git a/arm9/graphics/Top07.bmp b/arm9/graphics/Top07.bmp new file mode 100644 index 0000000..ad7c3cf Binary files /dev/null and b/arm9/graphics/Top07.bmp differ diff --git a/arm9/graphics/Top08.bmp b/arm9/graphics/Top08.bmp new file mode 100644 index 0000000..0ddb145 Binary files /dev/null and b/arm9/graphics/Top08.bmp differ diff --git a/arm9/graphics/Top09.bmp b/arm9/graphics/Top09.bmp new file mode 100644 index 0000000..0e07bd1 Binary files /dev/null and b/arm9/graphics/Top09.bmp differ diff --git a/arm9/graphics/Top10.bmp b/arm9/graphics/Top10.bmp new file mode 100644 index 0000000..ebf38f1 Binary files /dev/null and b/arm9/graphics/Top10.bmp differ diff --git a/arm9/graphics/Top11.bmp b/arm9/graphics/Top11.bmp new file mode 100644 index 0000000..0e7224b Binary files /dev/null and b/arm9/graphics/Top11.bmp differ diff --git a/arm9/graphics/Top12.bmp b/arm9/graphics/Top12.bmp new file mode 100644 index 0000000..31ec17b Binary files /dev/null and b/arm9/graphics/Top12.bmp differ diff --git a/arm9/graphics/Top13.bmp b/arm9/graphics/Top13.bmp new file mode 100644 index 0000000..49156ad Binary files /dev/null and b/arm9/graphics/Top13.bmp differ diff --git a/arm9/graphics/Top14.bmp b/arm9/graphics/Top14.bmp new file mode 100644 index 0000000..2c7716b Binary files /dev/null and b/arm9/graphics/Top14.bmp differ diff --git a/arm9/graphics/Top15.bmp b/arm9/graphics/Top15.bmp new file mode 100644 index 0000000..dbd7f70 Binary files /dev/null and b/arm9/graphics/Top15.bmp differ diff --git a/arm9/graphics/Top16.bmp b/arm9/graphics/Top16.bmp new file mode 100644 index 0000000..f9ac39a Binary files /dev/null and b/arm9/graphics/Top16.bmp differ diff --git a/arm9/graphics/Top17.bmp b/arm9/graphics/Top17.bmp new file mode 100644 index 0000000..4906d7c Binary files /dev/null and b/arm9/graphics/Top17.bmp differ diff --git a/arm9/graphics/Top18.bmp b/arm9/graphics/Top18.bmp new file mode 100644 index 0000000..8ff1a4d Binary files /dev/null and b/arm9/graphics/Top18.bmp differ diff --git a/arm9/graphics/Top19.bmp b/arm9/graphics/Top19.bmp new file mode 100644 index 0000000..b7136fe Binary files /dev/null and b/arm9/graphics/Top19.bmp differ diff --git a/arm9/graphics/Top20.bmp b/arm9/graphics/Top20.bmp new file mode 100644 index 0000000..b784f50 Binary files /dev/null and b/arm9/graphics/Top20.bmp differ diff --git a/arm9/graphics/Top21.bmp b/arm9/graphics/Top21.bmp new file mode 100644 index 0000000..b439e8b Binary files /dev/null and b/arm9/graphics/Top21.bmp differ diff --git a/arm9/graphics/Top22.bmp b/arm9/graphics/Top22.bmp new file mode 100644 index 0000000..9729990 Binary files /dev/null and b/arm9/graphics/Top22.bmp differ diff --git a/arm9/graphics/Top23.bmp b/arm9/graphics/Top23.bmp new file mode 100644 index 0000000..07f28de Binary files /dev/null and b/arm9/graphics/Top23.bmp differ diff --git a/arm9/graphics/Top24.bmp b/arm9/graphics/Top24.bmp new file mode 100644 index 0000000..5687bda Binary files /dev/null and b/arm9/graphics/Top24.bmp differ diff --git a/arm9/graphics/Top25.bmp b/arm9/graphics/Top25.bmp new file mode 100644 index 0000000..abcb139 Binary files /dev/null and b/arm9/graphics/Top25.bmp differ diff --git a/arm9/graphics/Top26.bmp b/arm9/graphics/Top26.bmp new file mode 100644 index 0000000..c9451c6 Binary files /dev/null and b/arm9/graphics/Top26.bmp differ diff --git a/arm9/graphics/Top27.bmp b/arm9/graphics/Top27.bmp new file mode 100644 index 0000000..57e9875 Binary files /dev/null and b/arm9/graphics/Top27.bmp differ diff --git a/arm9/graphics/Top28.bmp b/arm9/graphics/Top28.bmp new file mode 100644 index 0000000..67c08d8 Binary files /dev/null and b/arm9/graphics/Top28.bmp differ diff --git a/arm9/graphics/Top29.bmp b/arm9/graphics/Top29.bmp new file mode 100644 index 0000000..37a8617 Binary files /dev/null and b/arm9/graphics/Top29.bmp differ diff --git a/arm9/graphics/Top30.bmp b/arm9/graphics/Top30.bmp new file mode 100644 index 0000000..a9d7b8d Binary files /dev/null and b/arm9/graphics/Top30.bmp differ diff --git a/arm9/graphics/Top31.bmp b/arm9/graphics/Top31.bmp new file mode 100644 index 0000000..d075ea8 Binary files /dev/null and b/arm9/graphics/Top31.bmp differ diff --git a/arm9/graphics/Top32.bmp b/arm9/graphics/Top32.bmp new file mode 100644 index 0000000..bc7622a Binary files /dev/null and b/arm9/graphics/Top32.bmp differ diff --git a/arm9/graphics/Top33.bmp b/arm9/graphics/Top33.bmp new file mode 100644 index 0000000..cf1aa85 Binary files /dev/null and b/arm9/graphics/Top33.bmp differ diff --git a/arm9/graphics/Top34.bmp b/arm9/graphics/Top34.bmp new file mode 100644 index 0000000..174a157 Binary files /dev/null and b/arm9/graphics/Top34.bmp differ diff --git a/arm9/graphics/Top35.bmp b/arm9/graphics/Top35.bmp new file mode 100644 index 0000000..289f9ed Binary files /dev/null and b/arm9/graphics/Top35.bmp differ diff --git a/arm9/graphics/Top36.bmp b/arm9/graphics/Top36.bmp new file mode 100644 index 0000000..87825bf Binary files /dev/null and b/arm9/graphics/Top36.bmp differ diff --git a/arm9/graphics/Top37.bmp b/arm9/graphics/Top37.bmp new file mode 100644 index 0000000..377c08e Binary files /dev/null and b/arm9/graphics/Top37.bmp differ diff --git a/arm9/graphics/bgsub.bmp b/arm9/graphics/bgsub.bmp deleted file mode 100755 index 941f9f0..0000000 Binary files a/arm9/graphics/bgsub.bmp and /dev/null differ diff --git a/arm9/graphics/bgtop.bmp b/arm9/graphics/bgtop.bmp deleted file mode 100755 index fb85dba..0000000 Binary files a/arm9/graphics/bgtop.bmp and /dev/null differ diff --git a/arm9/graphics/button_file.bmp b/arm9/graphics/button_file.bmp deleted file mode 100755 index 13830e9..0000000 Binary files a/arm9/graphics/button_file.bmp and /dev/null differ diff --git a/arm9/graphics/button_folder.bmp b/arm9/graphics/button_folder.bmp deleted file mode 100755 index 02fa395..0000000 Binary files a/arm9/graphics/button_folder.bmp and /dev/null differ diff --git a/arm9/graphics/button_go.bmp b/arm9/graphics/button_go.bmp deleted file mode 100755 index 9d33afc..0000000 Binary files a/arm9/graphics/button_go.bmp and /dev/null differ diff --git a/arm9/graphics/button_off.bmp b/arm9/graphics/button_off.bmp deleted file mode 100755 index 791efe4..0000000 Binary files a/arm9/graphics/button_off.bmp and /dev/null differ diff --git a/arm9/graphics/button_on.bmp b/arm9/graphics/button_on.bmp deleted file mode 100755 index 50fc29e..0000000 Binary files a/arm9/graphics/button_on.bmp and /dev/null differ diff --git a/arm9/graphics/cursor.bmp b/arm9/graphics/cursor.bmp deleted file mode 100755 index 71d40c4..0000000 Binary files a/arm9/graphics/cursor.bmp and /dev/null differ diff --git a/arm9/graphics/fade00.bmp b/arm9/graphics/fade00.bmp new file mode 100644 index 0000000..377c08e Binary files /dev/null and b/arm9/graphics/fade00.bmp differ diff --git a/arm9/graphics/fade01.bmp b/arm9/graphics/fade01.bmp new file mode 100644 index 0000000..e768691 Binary files /dev/null and b/arm9/graphics/fade01.bmp differ diff --git a/arm9/graphics/fade02.bmp b/arm9/graphics/fade02.bmp new file mode 100644 index 0000000..57c01e6 Binary files /dev/null and b/arm9/graphics/fade02.bmp differ diff --git a/arm9/graphics/fade03.bmp b/arm9/graphics/fade03.bmp new file mode 100644 index 0000000..9eddf04 Binary files /dev/null and b/arm9/graphics/fade03.bmp differ diff --git a/arm9/graphics/fade04.bmp b/arm9/graphics/fade04.bmp new file mode 100644 index 0000000..f249720 Binary files /dev/null and b/arm9/graphics/fade04.bmp differ diff --git a/arm9/graphics/font.bmp b/arm9/graphics/font.bmp deleted file mode 100755 index bc6274a..0000000 Binary files a/arm9/graphics/font.bmp and /dev/null differ diff --git a/arm9/graphics/scrollbar.bmp b/arm9/graphics/scrollbar.bmp deleted file mode 100755 index 23d6b73..0000000 Binary files a/arm9/graphics/scrollbar.bmp and /dev/null differ diff --git a/arm9/graphics/suberror00.bmp b/arm9/graphics/suberror00.bmp new file mode 100644 index 0000000..15129c5 Binary files /dev/null and b/arm9/graphics/suberror00.bmp differ diff --git a/arm9/graphics/suberror01.bmp b/arm9/graphics/suberror01.bmp new file mode 100644 index 0000000..b44955b Binary files /dev/null and b/arm9/graphics/suberror01.bmp differ diff --git a/arm9/graphics/suberror02.bmp b/arm9/graphics/suberror02.bmp new file mode 100644 index 0000000..16a8621 Binary files /dev/null and b/arm9/graphics/suberror02.bmp differ diff --git a/arm9/graphics/suberror03.bmp b/arm9/graphics/suberror03.bmp new file mode 100644 index 0000000..00b431d Binary files /dev/null and b/arm9/graphics/suberror03.bmp differ diff --git a/arm9/graphics/suberror04.bmp b/arm9/graphics/suberror04.bmp new file mode 100644 index 0000000..69217eb Binary files /dev/null and b/arm9/graphics/suberror04.bmp differ diff --git a/arm9/graphics/suberror05.bmp b/arm9/graphics/suberror05.bmp new file mode 100644 index 0000000..807e9e9 Binary files /dev/null and b/arm9/graphics/suberror05.bmp differ diff --git a/arm9/graphics/suberror06.bmp b/arm9/graphics/suberror06.bmp new file mode 100644 index 0000000..1a772ec Binary files /dev/null and b/arm9/graphics/suberror06.bmp differ diff --git a/arm9/graphics/textbox.bmp b/arm9/graphics/textbox.bmp deleted file mode 100755 index 3fea880..0000000 Binary files a/arm9/graphics/textbox.bmp and /dev/null differ diff --git a/arm9/graphics/toperror2_00.bmp b/arm9/graphics/toperror2_00.bmp new file mode 100644 index 0000000..b651f58 Binary files /dev/null and b/arm9/graphics/toperror2_00.bmp differ diff --git a/arm9/graphics/toperror2_01.bmp b/arm9/graphics/toperror2_01.bmp new file mode 100644 index 0000000..ef40549 Binary files /dev/null and b/arm9/graphics/toperror2_01.bmp differ diff --git a/arm9/graphics/toperror2_02.bmp b/arm9/graphics/toperror2_02.bmp new file mode 100644 index 0000000..242c703 Binary files /dev/null and b/arm9/graphics/toperror2_02.bmp differ diff --git a/arm9/graphics/toperror2_03.bmp b/arm9/graphics/toperror2_03.bmp new file mode 100644 index 0000000..c2aa9a0 Binary files /dev/null and b/arm9/graphics/toperror2_03.bmp differ diff --git a/arm9/graphics/toperror2_04.bmp b/arm9/graphics/toperror2_04.bmp new file mode 100644 index 0000000..242c703 Binary files /dev/null and b/arm9/graphics/toperror2_04.bmp differ diff --git a/arm9/graphics/toperror2_05.bmp b/arm9/graphics/toperror2_05.bmp new file mode 100644 index 0000000..ef40549 Binary files /dev/null and b/arm9/graphics/toperror2_05.bmp differ diff --git a/arm9/graphics/toperror2_06.bmp b/arm9/graphics/toperror2_06.bmp new file mode 100644 index 0000000..b651f58 Binary files /dev/null and b/arm9/graphics/toperror2_06.bmp differ diff --git a/arm9/music/dsboot.wav b/arm9/music/dsboot.wav new file mode 100644 index 0000000..0fc9475 Binary files /dev/null and b/arm9/music/dsboot.wav differ diff --git a/arm9/music/dsiboot.wav b/arm9/music/dsiboot.wav new file mode 100644 index 0000000..c23579b Binary files /dev/null and b/arm9/music/dsiboot.wav differ diff --git a/arm9/source/bios.s b/arm9/source/bios.s new file mode 100644 index 0000000..901a831 --- /dev/null +++ b/arm9/source/bios.s @@ -0,0 +1,61 @@ +#define ARM9 + +/*--------------------------------------------------------------------------------- + + Copyright (C) 2009 + Dave Murphy (WinterMute) + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + +---------------------------------------------------------------------------------*/ + + .text + .align 4 + + .arm +@--------------------------------------------------------------------------------- + .global swiSoftReset2 + .type swiSoftReset2 STT_FUNC +@--------------------------------------------------------------------------------- +swiSoftReset2: +@--------------------------------------------------------------------------------- + REG_IME = 0; +#ifdef ARM7 + ldr r0,=0x2FFFE34 +#endif + +#ifdef ARM9 + .arch armv5te + .cpu arm946e-s + ldr r1, =0x00002078 @ disable TCM and protection unit + mcr p15, 0, r1, c1, c0 + @ Disable cache + mov r0, #0 + mcr p15, 0, r0, c7, c5, 0 @ Instruction cache + mcr p15, 0, r0, c7, c6, 0 @ Data cache + + @ Wait for write buffer to empty + mcr p15, 0, r0, c7, c10, 4 + + ldr r0,=0x2FFFE24 +#endif + + ldr r0,[r0] + bx r0 + + .pool \ No newline at end of file diff --git a/arm9/source/bios_decompress_callback.c b/arm9/source/bios_decompress_callback.c index 92a79c8..658edd2 100755 --- a/arm9/source/bios_decompress_callback.c +++ b/arm9/source/bios_decompress_callback.c @@ -18,14 +18,12 @@ #include "bios_decompress_callback.h" -static int getSizeBiosCallback (uint8 * source, uint16 * dest, uint32 r2) +int getSizeBiosCallback (uint8 * source, uint16 * dest, uint32 r2) { - (void)dest; - (void)r2; return *((int*)source); } -static uint8 readByteBiosCallback (uint8 * source) +uint8 readByteBiosCallback (uint8 * source) { return *source; } diff --git a/arm9/source/bootsplash.cpp b/arm9/source/bootsplash.cpp new file mode 100644 index 0000000..d4dd4c9 --- /dev/null +++ b/arm9/source/bootsplash.cpp @@ -0,0 +1,800 @@ +/* + NitroHax -- Cheat tool for the Nintendo DS + Copyright (C) 2008 Michael "Chishm" Chisholm + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include + +#include "soundbank.h" +#include "soundbank_bin.h" + +#include "bios_decompress_callback.h" + +#include "CartPrompt01.h" +#include "CartPrompt02.h" +#include "CartPrompt03.h" +#include "CartPrompt04.h" + +#include "DSiCartPrompt01.h" +#include "DSiCartPrompt02.h" +#include "DSiCartPrompt03.h" +#include "DSiCartPrompt04.h" + +#include "Bot00.h" +#include "Bot01.h" +#include "Bot02.h" +#include "Bot03.h" +#include "Bot04.h" +#include "Bot05.h" +#include "Bot06.h" +#include "Bot07.h" +#include "Bot08.h" +#include "Bot09.h" +#include "Bot10.h" + +#include "BotDSi00.h" +#include "BotDSi01.h" +#include "BotDSi02.h" +#include "BotDSi03.h" +#include "BotDSi04.h" +#include "BotDSi05.h" +#include "BotDSi06.h" +#include "BotDSi07.h" +#include "BotDSi08.h" +#include "BotDSi09.h" +#include "BotDSi10.h" +#include "BotDSi11.h" + +#include "Top00.h" +#include "Top01.h" +#include "Top02.h" +#include "Top03.h" +#include "Top04.h" +#include "Top05.h" +#include "Top06.h" +#include "Top07.h" +#include "Top08.h" +#include "Top09.h" +#include "Top10.h" +#include "Top11.h" +#include "Top12.h" +#include "Top13.h" +#include "Top14.h" +#include "Top15.h" +#include "Top16.h" +#include "Top17.h" +#include "Top18.h" +#include "Top19.h" +#include "Top20.h" +#include "Top21.h" +#include "Top22.h" +#include "Top23.h" +#include "Top24.h" +#include "Top25.h" +#include "Top26.h" +#include "Top27.h" +#include "Top28.h" +#include "Top29.h" +#include "Top30.h" +#include "Top31.h" +#include "Top32.h" +#include "Top33.h" +#include "Top34.h" +#include "Top35.h" +#include "Top36.h" +#include "Top37.h" + +#include "DSi01.h" +#include "DSi02.h" +#include "DSi03.h" +#include "DSi04.h" +#include "DSi05.h" +#include "DSi06.h" +#include "DSi07.h" +#include "DSi08.h" +#include "DSi09.h" +#include "DSi10.h" +#include "DSi11.h" +#include "DSi12.h" +#include "DSi13.h" +#include "DSi14.h" +#include "DSi15.h" +#include "DSi16.h" +#include "DSi17.h" +#include "DSi18.h" +#include "DSi19.h" +#include "DSi20.h" +#include "DSi21.h" +#include "DSi22.h" +#include "DSi23.h" +#include "DSi24.h" +#include "DSi25.h" +#include "DSi26.h" +#include "DSi27.h" +#include "DSi28.h" +#include "DSi29.h" +#include "DSi30.h" +#include "DSi31.h" +#include "DSi32.h" +#include "DSi33.h" +#include "DSi34.h" +#include "DSi35.h" + +#include "errorsplash.h" + +#include "bootsplash.h" + +#define CONSOLE_SCREEN_WIDTH 32 +#define CONSOLE_SCREEN_HEIGHT 24 + +#define REG_SCFG_MC (*(vu32*)0x4004010) + +void vramcpy_ui (void* dest, const void* src, int size) +{ + u16* destination = (u16*)dest; + u16* source = (u16*)src; + while (size > 0) { + *destination++ = *source++; + size-=2; + } +} + +void BootJingle() { + mmInitDefaultMem((mm_addr)soundbank_bin); + + mmLoadEffect( SFX_DSBOOT ); + + mm_sound_effect dsboot = { + { SFX_DSBOOT } , // id + (int)(1.0f * (1<<10)), // rate + 0, // handle + 255, // volume + 128, // panning + }; + + mmEffectEx(&dsboot); +} + +void BootJingleDSi() { + + mmInitDefaultMem((mm_addr)soundbank_bin); + + mmLoadEffect( SFX_DSIBOOT ); + + mm_sound_effect dsiboot = { + { SFX_DSIBOOT } , // id + (int)(1.0f * (1<<10)), // rate + 0, // handle + 255, // volume + 128, // panning + }; + + mmEffectEx(&dsiboot); +} + +void CartridgePrompt() { + + swiDecompressLZSSVram ((void*)Bot05Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot05Pal, Bot05PalLen); + + for (int i = 0; i < 20; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)CartPrompt04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], CartPrompt04Pal, CartPrompt04PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)CartPrompt03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], CartPrompt03Pal, CartPrompt03PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)CartPrompt02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], CartPrompt02Pal, CartPrompt02PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)CartPrompt01Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], CartPrompt01Pal, CartPrompt01PalLen); + + for (int i = 0; i < 40; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)CartPrompt02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], CartPrompt02Pal, CartPrompt02PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)CartPrompt03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], CartPrompt03Pal, CartPrompt03PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)CartPrompt04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], CartPrompt04Pal, CartPrompt04PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Bot05Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot05Pal, Bot05PalLen); + + for (int i = 0; i < 20; i++) { swiWaitForVBlank(); } + +} + +void CartridgePromptDSi() { + + swiDecompressLZSSVram ((void*)BotDSi05Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi05Pal, Bot05PalLen); + + for (int i = 0; i < 20; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSiCartPrompt04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], DSiCartPrompt04Pal, DSiCartPrompt04PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSiCartPrompt03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], DSiCartPrompt03Pal, DSiCartPrompt03PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSiCartPrompt02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], DSiCartPrompt02Pal, DSiCartPrompt02PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSiCartPrompt01Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], DSiCartPrompt01Pal, DSiCartPrompt01PalLen); + + for (int i = 0; i < 40; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSiCartPrompt02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], DSiCartPrompt02Pal, DSiCartPrompt02PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSiCartPrompt03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], DSiCartPrompt03Pal, DSiCartPrompt03PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSiCartPrompt04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], DSiCartPrompt04Pal, DSiCartPrompt04PalLen); + + for (int i = 0; i < 4; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)BotDSi05Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi05Pal, BotDSi05PalLen); + + for (int i = 0; i < 20; i++) { swiWaitForVBlank(); } + +} + +void BootSplashDSi() { + + swiDecompressLZSSVram ((void*)DSi01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi01Pal, DSi01PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi00Pal, BotDSi00PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi02Pal, DSi02PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi01Pal, BotDSi01PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi02Pal, DSi02PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi01Pal, BotDSi01PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi01Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi02Pal, DSi02PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi02Pal, BotDSi02PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi02Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi03Pal, DSi03PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi03Pal, BotDSi03PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi03Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi03Pal, DSi03PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi03Pal, BotDSi03PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi04Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi04Pal, DSi04PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi04Pal, BotDSi04PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi05Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi05Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi05Pal, DSi05PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi05Pal, BotDSi05PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi06Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi06Pal, DSi06PalLen); + + BootJingleDSi(); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi07Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi07Pal, DSi07PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi08Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi08Pal, DSi08PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi09Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi09Pal, DSi09PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi10Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi10Pal, DSi10PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi11Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi11Pal, DSi11PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi12Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi12Pal, DSi12PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi13Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi13Pal, DSi13PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi14Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi14Pal, DSi14PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi15Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi15Pal, DSi15PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi16Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi16Pal, DSi16PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi17Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi17Pal, DSi17PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi18Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi18Pal, DSi18PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi19Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi19Pal, DSi19PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi20Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi20Pal, DSi20PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi21Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi21Pal, DSi21PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi22Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi22Pal, DSi22PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi23Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi23Pal, DSi23PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi24Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi24Pal, DSi24PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi25Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi25Pal, DSi25PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi26Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi26Pal, DSi26PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi27Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi27Pal, DSi27PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi28Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi28Pal, DSi28PalLen); + + // Display Cartridge Prompt animation until cartridge inserted. (skipped if one already inserted) + if(REG_SCFG_MC == 0x11) { + do { CartridgePromptDSi(); } + while (REG_SCFG_MC == 0x11); + } + + // Pause on frame 31 for a second + for (int i = 0; i < 80; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi29Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi06Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi29Pal, DSi29PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi06Pal, BotDSi06PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi30Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi07Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi30Pal, DSi30PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi07Pal, BotDSi07PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi31Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi08Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi31Pal, DSi31PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi08Pal, BotDSi08PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi32Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi09Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi32Pal, DSi32PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi09Pal, BotDSi09PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi33Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi10Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi33Pal, DSi33PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi10Pal, BotDSi10PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi34Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi11Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi34Pal, DSi34PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi11Pal, BotDSi11PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi35Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)BotDSi00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi35Pal, DSi35PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], BotDSi00Pal, BotDSi00PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)DSi01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], DSi01Pal, DSi01PalLen); + + if(REG_SCFG_MC == 0x11) { ErrorNoCard(); } +} + +void BootSplashDS() { + + // offsetting palletes by one frame during the fade in seems to fix black flicker at start. + // only did this for about 5 frames. (time it takes for bottom screen to fade in) + swiDecompressLZSSVram ((void*)Top00Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top01Pal, Top01PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot01Pal, Bot01PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top00Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top00Pal, Top00PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot00Pal, Bot00PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top00Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top00Pal, Top00PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot00Pal, Bot00PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot01Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top02Pal, Top02PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot02Pal, Bot02PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top02Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top03Pal, Top03PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot03Pal, Bot03PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top03Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top04Pal, Top04PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot04Pal, Bot04PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top04Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top05Pal, Top05PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot04Pal, Bot04PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top05Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot05Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top05Pal, Top05PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot05Pal, Bot05PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + BootJingle(); + + swiDecompressLZSSVram ((void*)Top06Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top06Pal, Top06PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top07Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top07Pal, Top07PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top08Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top08Pal, Top08PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top09Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top09Pal, Top09PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top10Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top10Pal, Top10PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top11Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top11Pal, Top11PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top12Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top12Pal, Top12PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top13Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top13Pal, Top13PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top14Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top14Pal, Top14PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top15Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top15Pal, Top15PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top16Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top16Pal, Top16PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top17Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top17Pal, Top17PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top18Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top18Pal, Top18PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top19Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top19Pal, Top19PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top20Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top20Pal, Top20PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top21Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top21Pal, Top21PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top22Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top22Pal, Top22PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top23Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top23Pal, Top23PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top24Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top24Pal, Top24PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top25Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top25Pal, Top25PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top26Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top26Pal, Top26PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top27Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top27Pal, Top27PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top28Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top28Pal, Top28PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top29Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top29Pal, Top29PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top30Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top30Pal, Top30PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top31Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top31Pal, Top31PalLen); + + // Display Cartridge Prompt animation until cartridge inserted. (skipped if one already inserted) + if(REG_SCFG_MC == 0x11) { + do { CartridgePrompt(); } + while (REG_SCFG_MC == 0x11); + } + + // Pause on frame 31 for a second + for (int i = 0; i < 80; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top32Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot06Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top32Pal, Top32PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot06Pal, Bot06PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top33Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot07Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top33Pal, Top33PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot07Pal, Bot07PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top34Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot08Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top34Pal, Top34PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot08Pal, Bot08PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top35Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot09Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top35Pal, Top35PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot09Pal, Bot09PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top36Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)Bot10Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top36Pal, Top36PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], Bot10Pal, Bot10PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)Top37Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], Top37Pal, Top37PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiWaitForVBlank(); + + if(REG_SCFG_MC == 0x11) { ErrorNoCard(); } + + swiWaitForVBlank(); + +} + +void BootSplashInit(bool UseNTRSplash) { + + videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE); + videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); + vramSetBankA (VRAM_A_MAIN_BG_0x06000000); + vramSetBankC (VRAM_C_SUB_BG_0x06200000); + REG_BG0CNT = BG_MAP_BASE(0) | BG_COLOR_256 | BG_TILE_BASE(2); + REG_BG0CNT_SUB = BG_MAP_BASE(0) | BG_COLOR_256 | BG_TILE_BASE(2); + BG_PALETTE[0]=0; + BG_PALETTE[255]=0xffff; + u16* bgMapTop = (u16*)SCREEN_BASE_BLOCK(0); + u16* bgMapSub = (u16*)SCREEN_BASE_BLOCK_SUB(0); + for (int i = 0; i < CONSOLE_SCREEN_WIDTH*CONSOLE_SCREEN_HEIGHT; i++) { + bgMapTop[i] = (u16)i; + bgMapSub[i] = (u16)i; + } + + int pressed = keysDown(); + + if ( pressed & KEY_A ) { + BootSplashDSi(); + } else { + if( UseNTRSplash ) { + BootSplashDS(); + } else { + BootSplashDSi(); + } + } +} + diff --git a/BootLoader/source/cheat.h b/arm9/source/bootsplash.h old mode 100755 new mode 100644 similarity index 65% rename from BootLoader/source/cheat.h rename to arm9/source/bootsplash.h index 129935d..770fc28 --- a/BootLoader/source/cheat.h +++ b/arm9/source/bootsplash.h @@ -16,12 +16,25 @@ along with this program. If not, see . */ -#include -#include +#ifndef BOOTSPLASH_H +#define BOOTSPLASH_H -/*------------------------------------------------------------------------- -arm7_hookGame -Adds a hook in the game's ARM7 binary to our own code --------------------------------------------------------------------------*/ -int arm7_hookGame (const tNDSHeader* ndsHeader, const u32* cheatData, u32* cheatEngineLocation); +#ifdef __cplusplus +extern "C" { +#endif + +void vramcpy_ui (void* dest, const void* src, int size); +void BootJingle (void); +void BootJingleDSi (void); +void BootSplashDSi (void); +void CartridgePrompt (void); +void CartridgePromptDSi (void); +void BootSplashDS (void); +void BootSplashInit (bool UseNTRSplash); + +#ifdef __cplusplus +} +#endif + +#endif // BOOTSPLASH_H diff --git a/arm9/source/cheat.cpp b/arm9/source/cheat.cpp deleted file mode 100755 index b5e96a6..0000000 --- a/arm9/source/cheat.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/* - NitroHax -- Cheat tool for the Nintendo DS - Copyright (C) 2008 Michael "Chishm" Chisholm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "cheat.h" -#include -#include -#include - -#include "ui.h" - -static const char HEX_CHARACTERS[] = "0123456789ABCDEFabcdef"; - -CheatFolder::~CheatFolder() -{ - for (std::vector::iterator curItem = contents.begin(); curItem != contents.end(); curItem++) { - delete (*curItem); - } -} - -void CheatFolder::enableAll (bool enabled) -{ - if (allowOneOnly && enabled) { - return; - } - for (std::vector::iterator curItem = contents.begin(); curItem != contents.end(); curItem++) { - CheatCode* cheatCode = dynamic_cast(*curItem); - if (cheatCode) { - cheatCode->setEnabled (enabled); - } - } -} - -void CheatFolder::enablingSubCode (void) -{ - if (allowOneOnly) { - enableAll (false); - } -} - -std::list CheatFolder::getEnabledCodeData (void) -{ - std::list codeData; - CheatCode* cheatCode; - - for (std::vector::iterator curItem = contents.begin(); curItem != contents.end(); curItem++) { - std::list curCodeData = (*curItem)->getEnabledCodeData(); - cheatCode = dynamic_cast(*curItem); - if (cheatCode && cheatCode->isMaster()) { - codeData.insert( codeData.begin(), curCodeData.begin(), curCodeData.end()); - } else { - codeData.insert( codeData.end(), curCodeData.begin(), curCodeData.end()); - } - } - - return codeData; -} - -std::list CheatCode::getEnabledCodeData (void) -{ - std::list codeData; - if (enabled) { - codeData = cheatData; - } - - return codeData; -} - -void CheatCode::setCodeData (const std::string& data) -{ - const char* codeData = data.c_str(); - char codeinfo[30]; - int value; - int codeLen = strlen (codeData); - int codePos = 0; - int readNum = 1; - - const char ALWAYS_ON[] = "always_on"; - const char ON[] = "on"; - const char MASTER[] = "master"; - - if (sscanf (codeData, "%29s", codeinfo) > 0) { - if (strcmp(codeinfo, ALWAYS_ON) == 0) { - always_on = true; - enabled = true; - codePos += strlen (ALWAYS_ON); - } else if (strcmp(codeinfo, ON) == 0) { - enabled = true; - codePos += strlen (ON); - } else if (strcmp(codeinfo, MASTER) == 0) { - master = true; - codePos += strlen (MASTER); - } - } - - while ((codePos < codeLen) && (readNum > 0)) { - // Move onto the next hexadecimal value - codePos += strcspn (codeData + codePos, HEX_CHARACTERS); - readNum = sscanf (codeData + codePos, "%x", &value); - if (readNum > 0) { - cheatData.push_back (value); - codePos += CODE_WORD_LEN; - } else { - readNum = sscanf (codeData + codePos, "%29s", codeinfo); - if (readNum > 0) { - codePos += strlen (codeinfo); - } - } - } - - if (master && (cheatData.size() >= 2)) { - if ((*(cheatData.begin()) & 0xFF000000) == 0xCF000000) { - // Master code meant for Nitro Hax - always_on = true; - enabled = true; - } else if ((cheatData.size() >= 18) && (*(cheatData.begin()) == 0x00000000)) { - // Master code meant for the Action Replay - // Convert it for Nitro Hax - CheatWord relocDest; - std::list::iterator i = cheatData.begin(); - std::advance (i, 13); - relocDest = *i; - cheatData.clear(); - cheatData.push_back (CHEAT_ENGINE_RELOCATE); - cheatData.push_back (relocDest); - enabled = true; - } - } -} - -void CheatCode::toggleEnabled (void) -{ - if (!enabled && getParent()) { - getParent()->enablingSubCode(); - } - if (!always_on) { - enabled = !enabled; - } -} - - -void CheatGame::setGameid (const std::string& id) -{ - const char* idData = id.c_str(); - const char* crcData; - - headerCRC = 0; - if (id.size() < 9) { - return; - } - gameid[0] = id.at(0); - gameid[1] = id.at(1); - gameid[2] = id.at(2); - gameid[3] = id.at(3); - - headerCRC = 0; - crcData = strpbrk (idData+4, HEX_CHARACTERS); - if (crcData) { - sscanf (crcData, "%" SCNx32, &headerCRC); - // CRC is inverted in the cheat list - headerCRC = ~headerCRC; - } -} - - -CheatCodelist::~CheatCodelist(void) -{ - for (std::vector::iterator curItem = getContents().begin(); curItem != getContents().end(); curItem++) { - delete (*curItem); - } -} - -#define BUFFER_SIZE 1024 -bool CheatCodelist::nextToken (FILE* fp, std::string& token, TOKEN_TYPE& tokenType) -{ - char tokenData[BUFFER_SIZE]; - token.clear(); - - if (fscanf(fp, " <%1023[^>]", tokenData) > 0) { - if (tokenData[0] == '/') { - tokenType = TOKEN_TAG_END; - token += &tokenData[1]; - } else { - tokenType = TOKEN_TAG_START; - token += tokenData; - } - while (fscanf(fp, "%1023[^>]", tokenData) > 0) { - token += tokenData; - } ; - fscanf(fp, ">"); - if (tokenType == TOKEN_TAG_START && token.at(token.size() -1 ) == '/') { - token.resize (token.size() -1); - tokenType = TOKEN_TAG_SINGLE; - } - } else if (fscanf(fp, "%1023[^<]", tokenData) > 0) { - tokenType = TOKEN_DATA; - do { - token += tokenData; - } while (fscanf(fp, "%1023[^<]", tokenData) > 0); - if (token.empty()) { - return false; - } - } else { - return false; - } - - return true; -} - -bool CheatCodelist::load (FILE* fp) -{ - enum {state_normal, state_name, state_note, state_codes, state_gameid, state_allowedon} state = state_normal; - CheatBase* curItem = this; - CheatBase* newItem; - CheatCode* cheatCode; - CheatFolder* cheatFolder; - CheatGame* cheatGame; - std::string token; - TOKEN_TYPE tokenType; - int depth = 0; - bool done = false; - - while (nextToken (fp, token, tokenType) && (tokenType != TOKEN_TAG_START || token != "codelist")) ; - - if (token != "codelist") { - return false; - } - depth ++; - - while (nextToken (fp, token, tokenType) && !done) { - switch (tokenType) { - case TOKEN_DATA: - switch (state) { - case state_name: - curItem->name = token; - break; - case state_note: - curItem->note = token; - break; - case state_codes: - cheatCode = dynamic_cast(curItem); - if (cheatCode) { - cheatCode->setCodeData (token); - } - break; - case state_gameid: - cheatGame = dynamic_cast(curItem); - if (cheatGame) { - cheatGame->setGameid (token); - } - break; - case state_allowedon: - cheatFolder = dynamic_cast(curItem); - if (cheatFolder) { - cheatFolder->setAllowOneOnly (!(token == "0")); - } - break; - case state_normal: - break; - } - break; - case TOKEN_TAG_START: - depth++; - if (token == "game") { - cheatGame = new CheatGame (this); - this->addItem (cheatGame); - curItem = cheatGame; - } else if (token == "folder") { - cheatFolder = dynamic_cast(curItem); - if (cheatFolder) { - newItem = new CheatFolder (cheatFolder); - cheatFolder->addItem (newItem); - curItem = newItem; - } - } else if (token == "cheat") { - cheatFolder = dynamic_cast(curItem); - if (cheatFolder) { - newItem = new CheatCode (cheatFolder); - cheatFolder->addItem (newItem); - curItem = newItem; - } - } else if (token == "codelist") { - // Should only occur at top level - curItem = this; - depth = 1; - } else if (token == "name") { - state = state_name; - } else if (token == "note") { - state = state_note; - } else if (token == "codes") { - state = state_codes; - } else if (token == "gameid") { - state = state_gameid; - } else if (token == "allowedon") { - state = state_allowedon; - } - break; - case TOKEN_TAG_END: - if ((token == "game") || - (token == "folder") || - (token == "cheat") - ) { - newItem = curItem->getParent(); - if (newItem) { - curItem = newItem; - } - } else if (token == "subscription") { - done = true; - } - state = state_normal; - depth--; - break; - case TOKEN_TAG_SINGLE: - break; - } - } - - this->name = "Cheat list"; - return true; -} - -CheatGame* CheatCodelist::getGame (const char gameid[4], uint32_t headerCRC) -{ - for (std::vector::iterator curItem = contents.begin(); curItem != contents.end(); curItem++) { - CheatGame* game = dynamic_cast(*curItem); - if (game && game->checkGameid(gameid, headerCRC)) { - return game; - } - } - - return NULL; -} - - diff --git a/arm9/source/cheat.h b/arm9/source/cheat.h deleted file mode 100755 index 2dbb438..0000000 --- a/arm9/source/cheat.h +++ /dev/null @@ -1,213 +0,0 @@ - -#ifndef CHEAT_H -#define CHEAT_H - -#include -#include -#include -#include -#include -#include - -#define CHEAT_CODE_END 0xCF000000 -#define CHEAT_ENGINE_RELOCATE 0xCF000001 -#define CHEAT_ENGINE_HOOK 0xCF000002 - - -typedef unsigned int CheatWord; - -class CheatFolder; - -class CheatBase -{ -private: - CheatFolder* parent; - -public: - std::string name; - std::string note; - - CheatBase (CheatFolder* parent) - { - this->parent = parent; - } - - CheatBase (const char* name, CheatFolder* parent) - { - this->name = name; - this->parent = parent; - } - - CheatBase (const std::string name, CheatFolder* parent) - { - this->name = name; - this->parent = parent; - } - - virtual ~CheatBase () - { - } - - const char* getName (void) - { - return name.c_str(); - } - - const char* getNote (void) - { - return note.c_str(); - } - - CheatFolder* getParent (void) - { - return parent; - } - - virtual std::list getEnabledCodeData(void) - { - std::list codeData; - return codeData; - } -} ; - -class CheatCode : public CheatBase -{ -public: - CheatCode (CheatFolder* parent) : CheatBase (parent) - { - enabled = false; - always_on = false; - master = false; - } - - void setEnabled (bool enable) - { - if (!always_on) { - enabled = enable; - } - } - - void toggleEnabled (void); - - bool getEnabledStatus (void) - { - return enabled; - } - - bool isMaster (void) - { - return master; - } - - std::list getCodeData(void) - { - return cheatData; - } - - void setCodeData (const std::string& data); - - std::list getEnabledCodeData(void); - - static const int CODE_WORD_LEN = 8; - -private: - std::list cheatData; - bool enabled; - bool always_on; - bool master; -} ; - -class CheatFolder : public CheatBase -{ -public: - CheatFolder (const char* name, CheatFolder* parent) : CheatBase (name, parent) - { - allowOneOnly = false; - } - - CheatFolder (CheatFolder* parent) : CheatBase (parent) - { - allowOneOnly = false; - } - - ~CheatFolder(); - - void addItem (CheatBase* item) - { - if (item) { - contents.push_back(item); - } - } - - void enablingSubCode (void); - - void enableAll (bool enabled); - - void setAllowOneOnly (bool value) - { - allowOneOnly = value; - } - - std::vector getContents(void) - { - return contents; - } - - std::list getEnabledCodeData(void); - -protected: - std::vector contents; - -private: - bool allowOneOnly; - -} ; - -class CheatGame : public CheatFolder -{ -public: - CheatGame (const char* name, CheatFolder* parent) : CheatFolder (name, parent) - { - memset(gameid, ' ', 4); - } - - CheatGame (CheatFolder* parent) : CheatFolder (parent) - { - memset(gameid, ' ', 4); - } - - bool checkGameid (const char gameid[4], uint32_t headerCRC) - { - return (memcmp (gameid, this->gameid, sizeof(this->gameid)) == 0) && - (headerCRC == this->headerCRC); - } - - void setGameid (const std::string& id); - -private: - char gameid[4]; - uint32_t headerCRC; -} ; - -class CheatCodelist : public CheatFolder -{ -public: - CheatCodelist (void) : CheatFolder ("No codes loaded", NULL) - { - } - - ~CheatCodelist (); - - bool load (FILE* fp); - - CheatGame* getGame (const char gameid[4], uint32_t headerCRC); - -private: - enum TOKEN_TYPE {TOKEN_DATA, TOKEN_TAG_START, TOKEN_TAG_END, TOKEN_TAG_SINGLE}; - - bool nextToken (FILE* fp, std::string& token, TOKEN_TYPE& tokenType); - -} ; - -#endif // CHEAT_H - diff --git a/arm9/source/consoletext.cpp b/arm9/source/consoletext.cpp deleted file mode 100755 index 88fbcea..0000000 --- a/arm9/source/consoletext.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - NitroHax -- Cheat tool for the Nintendo DS - Copyright (C) 2008 Michael "Chishm" Chisholm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "consoletext.h" -#include - -#define TAB_STOP 4 -#define SCREEN_WIDTH 32 - -ConsoleText::ConsoleText (int width, int height, CHAR_SIZE tileSize, u16* fontMap, u16 palette) -{ - this->width = width; - this->height = height; - this->tileSize = tileSize; - this->fontStart = 0; - this->fontMap = fontMap; - this->fontPal = (u16)(palette << 12); - this->row = 0; - this->col = 0; -} - -void ConsoleText::clearText (void) -{ - setPosition (0, 0); - for (int i = 0; i < width * height; i++) { - putChar (' '); - } - setPosition (0, 0); -} - -void ConsoleText::clearText (int startRow, int startCol, int endRow, int endCol) -{ - for (int i = startRow; i <= endRow; i++) { - for (int j = startCol; j <= endCol; j++) { - putChar (' ', i, j); - } - } -} - - -void ConsoleText::setPosition (int row, int col) -{ - this->row = row; - this->col = col; -} - -void ConsoleText::putText (const char* str) -{ - putText (str, 0, height-1, width-1); -} - -int ConsoleText::putText (const char* str, int startCol, int endRow, int endCol, int curRow, int curCol) -{ - int pos = 0; - int len = strlen (str); - row = curRow; - col = curCol; - char curChar; - - while (pos < len) { - curChar = str[pos]; - switch (curChar) { - case '\r': - col = startCol; - break; - case '\n': - row++; - col = startCol; - break; - case '\t': - col += TAB_STOP; - col = col - (col % TAB_STOP); - break; - default: - if (col > endCol) { - row++; - col = startCol; - } - - if (row > endRow) { - // Overflowed the screen so bail out - return row; - } - - putChar (curChar, row, col); - col++; - break; - } - pos++; - } - - return row; -} - -void ConsoleText::putChar (char chr) -{ - putChar (chr, row, col); - col++; - if (col >= width) { - row++; - col = 0; - } - if (row >= height) { - row = 0; - } -} - -void ConsoleText::putChar (char chr, int row, int col) -{ - if (tileSize == CHAR_SIZE_8PX) { - fontMap[col + row * SCREEN_WIDTH] = fontPal | (u16)(chr + fontStart); - } else { - fontMap[col * 2 + row * 2 * SCREEN_WIDTH] = fontPal | (u16)(chr * 4 + fontStart); - fontMap[(col * 2 + 1) + row * 2 * SCREEN_WIDTH] = fontPal | (u16)(chr * 4 + 1 + fontStart); - fontMap[col * 2 + (row * 2 + 1) * SCREEN_WIDTH] = fontPal | (u16)(chr * 4 + 2 + fontStart); - fontMap[(col * 2 + 1) + (row * 2 + 1) * SCREEN_WIDTH] = fontPal | (u16)(chr * 4 + 3 + fontStart); - } -} - -void ConsoleText::putTile (int val, int row, int col, int palette) -{ - u16 pal = (u16)(palette << 12); - if (tileSize == CHAR_SIZE_8PX) { - fontMap[col + row * SCREEN_WIDTH] = pal | (u16)val; - } else { - fontMap[col * 2 + row * 2 * SCREEN_WIDTH] = pal | (u16)(val * 4); - fontMap[(col * 2 + 1) + row * 2 * SCREEN_WIDTH] = pal | (u16)(val * 4 + 1); - fontMap[col * 2 + (row * 2 + 1) * SCREEN_WIDTH] = pal | (u16)(val * 4 + 2); - fontMap[(col * 2 + 1) + (row * 2 + 1) * SCREEN_WIDTH] = pal | (u16)(val * 4 + 3); - } -} diff --git a/arm9/source/consoletext.h b/arm9/source/consoletext.h deleted file mode 100755 index e44a310..0000000 --- a/arm9/source/consoletext.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - NitroHax -- Cheat tool for the Nintendo DS - Copyright (C) 2008 Michael "Chishm" Chisholm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include - -class ConsoleText -{ -public: - enum CHAR_SIZE {CHAR_SIZE_8PX, CHAR_SIZE_16PX}; - - ConsoleText (int width, int height, CHAR_SIZE tileSize, u16* fontMap, u16 palette); - - void setPosition (int x, int y); - void clearText (void); - void clearText (int startRow, int startCol, int endRow, int endCol); - void putText (const char* str); - int putText (const char* str, int startCol, int endRow, int endCol, int curRow, int curCol); - int putText (const char* str, int startCol, int endRow, int endCol) - { - return putText (str, startCol, endRow, endCol, row, col); - } - - void putChar (char chr); - void putChar (char chr, int row, int col); - void putTile (int val, int row, int col, int palette); - -private: - u16 fontPal; - int row, col; - int width, height; - int fontStart; - u16* fontMap; - CHAR_SIZE tileSize; -} ; diff --git a/arm9/source/errorsplash.c b/arm9/source/errorsplash.c new file mode 100644 index 0000000..63ed144 --- /dev/null +++ b/arm9/source/errorsplash.c @@ -0,0 +1,148 @@ +/* + NitroHax -- Cheat tool for the Nintendo DS + Copyright (C) 2008 Michael "Chishm" Chisholm + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include + +#include "errorsplash.h" + +#include "bios_decompress_callback.h" + +#include "fade00.h" +#include "fade01.h" +#include "fade02.h" +#include "fade03.h" +#include "fade04.h" + +#include "suberror00.h" +#include "suberror01.h" +#include "suberror02.h" +#include "suberror03.h" +#include "suberror04.h" +#include "suberror05.h" +#include "suberror06.h" + +#include "toperror2_00.h" +#include "toperror2_01.h" +#include "toperror2_02.h" +#include "toperror2_03.h" +#include "toperror2_04.h" +#include "toperror2_05.h" +#include "toperror2_06.h" + +void FadeFX() { + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)fade00Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)fade00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], fade00Pal, fade00PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], fade00Pal, fade00PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)fade01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)fade01Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], fade01Pal, fade01PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], fade01Pal, fade01PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)fade02Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)fade02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], fade02Pal, fade02PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], fade02Pal, fade02PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)fade03Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)fade03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], fade03Pal, fade03PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], fade03Pal, fade03PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)fade04Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)fade04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], fade04Pal, fade04PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], fade04Pal, fade04PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } +} + +void ErrorNoCard() { + + FadeFX(); + + swiDecompressLZSSVram ((void*)toperror2_00Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)suberror00Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], toperror2_00Pal, toperror2_00PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], suberror00Pal, suberror00PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)toperror2_01Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)suberror01Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], toperror2_01Pal, toperror2_01PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], suberror01Pal, suberror01PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)toperror2_02Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)suberror02Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], toperror2_02Pal, toperror2_02PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], suberror02Pal, suberror02PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)toperror2_03Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)suberror03Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], toperror2_03Pal, toperror2_03PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], suberror03Pal, suberror03PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + // Wait for input, then fade out + do { swiWaitForVBlank(); scanKeys(); } while (!keysDown()); + + swiDecompressLZSSVram ((void*)toperror2_04Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)suberror04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], toperror2_04Pal, toperror2_04PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], suberror04Pal, suberror04PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)toperror2_05Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)suberror05Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], toperror2_05Pal, toperror2_05PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], suberror05Pal, suberror05PalLen); + + swiDecompressLZSSVram ((void*)toperror2_06Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)suberror06Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], toperror2_06Pal, toperror2_06PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], suberror06Pal, suberror06PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } + + swiDecompressLZSSVram ((void*)fade04Tiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); + swiDecompressLZSSVram ((void*)fade04Tiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); + vramcpy_ui (&BG_PALETTE[0], fade04Pal, fade04PalLen); + vramcpy_ui (&BG_PALETTE_SUB[0], fade04Pal, fade04PalLen); + + for (int i = 0; i < 2; i++) { swiWaitForVBlank(); } +} + diff --git a/arm7/source/cheat_engine_arm7.c b/arm9/source/errorsplash.h old mode 100755 new mode 100644 similarity index 78% rename from arm7/source/cheat_engine_arm7.c rename to arm9/source/errorsplash.h index 1afd29b..a3e20ba --- a/arm7/source/cheat_engine_arm7.c +++ b/arm9/source/errorsplash.h @@ -16,14 +16,20 @@ along with this program. If not, see . */ -#include +#ifndef ERRORSPLASH_H +#define ERRORSPLASH_H -void runCheatEngineCheck (void) -{ - if(*((vu32*)0x027FFE24) == (u32)0x027FFE04) - { - irqDisable (IRQ_ALL); - *((vu32*)0x027FFE34) = (u32)0x06000000; - swiSoftReset(); - } +#ifdef __cplusplus +extern "C" { +#endif + +void FadeFX (void); +void ErrorNoBit31 (void); +void ErrorNoCard (void); + +#ifdef __cplusplus } +#endif + +#endif // ERRORSPLASH_H + diff --git a/arm9/source/inifile.cpp b/arm9/source/inifile.cpp new file mode 100644 index 0000000..10f691d --- /dev/null +++ b/arm9/source/inifile.cpp @@ -0,0 +1,391 @@ +/* + inifile.cpp + Copyright (C) 2007 Acekard, www.acekard.com + Copyright (C) 2007-2009 somebody + Copyright (C) 2009 yellow wood goblin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include "inifile.h" +#include "stringtool.h" + +static bool freadLine(FILE* f,std::string& str) +{ + str.clear(); +__read: + char p=0; + + size_t readed=fread(&p,1,1,f); + if(0==readed) + { + str=""; + return false; + } + if('\n'==p||'\r'==p) + { + str=""; + return true; + } + + while(p!='\n'&&p!='\r'&&readed) + { + str+=p; + readed=fread(&p,1,1,f); + } + + if(str.empty()||""==str) + { + goto __read; + } + + return true; +} + +static void trimString(std::string& str) +{ + size_t first=str.find_first_not_of(" \t"),last; + if(first==str.npos) + { + str=""; + } + else + { + last=str.find_last_not_of(" \t"); + if(first>0||(last+1)0) + { + m_FileContainer.clear(); + } +} + +void CIniFile::SetString(const std::string& Section,const std::string& Item,const std::string& Value) +{ + if(GetFileString(Section,Item)!=Value) + { + SetFileString(Section,Item,Value); + m_bModified=true; + } +} + +void CIniFile::SetInt(const std::string& Section,const std::string& Item,int Value) +{ + std::string strtemp=formatString("%d",Value); + + if(GetFileString(Section,Item)!=strtemp) + { + SetFileString(Section,Item,strtemp); + m_bModified=true; + } +} + +std::string CIniFile::GetString(const std::string& Section,const std::string& Item) +{ + return GetFileString(Section,Item); +} + +std::string CIniFile::GetString(const std::string& Section,const std::string& Item,const std::string& DefaultValue) +{ + std::string temp=GetString(Section,Item); + if(!m_bLastResult) + { + SetString(Section,Item,DefaultValue); + temp=DefaultValue; + } + return temp; +} + +void CIniFile::GetStringVector(const std::string& Section,const std::string& Item,std::vector< std::string >& strings,char delimiter) +{ + std::string strValue=GetFileString(Section,Item); + strings.clear(); + size_t pos; + while((pos=strValue.find(delimiter),strValue.npos!=pos)) + { + const std::string string=strValue.substr(0,pos); + if(string.length()) + { + strings.push_back(string); + } + strValue=strValue.substr(pos+1,strValue.npos); + } + if(strValue.length()) + { + strings.push_back(strValue); + } +} + +void CIniFile::SetStringVector(const std::string& Section,const std::string& Item,std::vector& strings,char delimiter) +{ + std::string strValue; + for(size_t ii=0;ii2&&'0'==value[0]&&('x'==value[1]||'X'==value[1])) + return strtol(value.c_str(),NULL,16); + else + return strtol(value.c_str(),NULL,10); +} + +int CIniFile::GetInt(const std::string& Section,const std::string& Item,int DefaultValue) +{ + int temp; + temp=GetInt(Section,Item); + if(!m_bLastResult) + { + SetInt(Section,Item,DefaultValue); + temp=DefaultValue; + } + return temp; +} + +bool CIniFile::LoadIniFile(const std::string& FileName) +{ + //dbg_printf("load %s\n",FileName.c_str()); + if(FileName!="") m_sFileName=FileName; + + FILE* f=fopen(FileName.c_str(),"rb"); + + if(NULL==f) return false; + + //check for utf8 bom. + char bom[3]; + if(fread(bom,3,1,f)==1&&bom[0]==0xef&&bom[1]==0xbb&&bom[2]==0xbf) ; + else fseek(f,0,SEEK_SET); + + std::string strline(""); + m_FileContainer.clear(); + + while(freadLine(f,strline)) + { + trimString(strline); + if(strline!=""&&';'!=strline[0]&&'/'!=strline[0]&&'!'!=strline[0]) m_FileContainer.push_back(strline); + } + + fclose(f); + + m_bLastResult=false; + m_bModified=false; + + return true; +} + +bool CIniFile::SaveIniFileModified(const std::string& FileName) +{ + if(m_bModified==true) + { + return SaveIniFile(FileName); + } + + return true; +} + +bool CIniFile::SaveIniFile(const std::string& FileName) +{ + if(FileName!="") + m_sFileName=FileName; + + FILE* f=fopen(m_sFileName.c_str(),"wb"); + if(NULL==f) + { + return false; + } + + for(size_t ii=0;ii0) + { + if(!m_FileContainer[ii-1].empty()&&m_FileContainer[ii-1]!="") + fwrite("\r\n",1,2,f); + } + if(!strline.empty()&&strline!="") + { + fwrite(strline.c_str(),1,strline.length(),f); + fwrite("\r\n",1,2,f); + } + } + + fclose(f); + + m_bModified=false; + + return true; +} + +std::string CIniFile::GetFileString(const std::string& Section,const std::string& Item) +{ + std::string strline; + std::string strSection; + std::string strItem; + std::string strValue; + + size_t ii=0; + size_t iFileLines=m_FileContainer.size(); + + if(m_bReadOnly) + { + cSectionCache::iterator it=m_Cache.find(Section); + if((it!=m_Cache.end())) ii=it->second; + } + + m_bLastResult=false; + + if(iFileLines>=0) + { + while(ii0&&rBracketPos!=std::string::npos) + { + strSection=strline.substr(1,rBracketPos-1); + if(m_bReadOnly) m_Cache.insert(std::make_pair(strSection,ii-1)); + if(strSection==Section) + { + while(ii0&&rBracketPos!=std::string::npos) + { + strSection=strline.substr(1,rBracketPos-1); + if(strSection==Section) + { + while(ii. */ -#ifndef CHEAT_ENGINE_H -#define CHEAT_ENGINE_H +#ifndef LAUNCH_ENGINE_H +#define LAUNCH_ENGINE_H #include -#define CHEAT_MAX_DATA_SIZE (64 * 1024) // 64KiB #ifdef __cplusplus extern "C" { #endif - -void runCheatEngine (void* cheats, int cheatLength); - +void runLaunchEngine (bool UseNTRSplash, bool EnableSD); #ifdef __cplusplus } #endif -#endif // CHEAT_ENGINE_H +#endif // LAUNCH_ENGINE_H + diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index 8730ad3..ec780b6 100755 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -17,132 +17,120 @@ */ #include -#include #include +#include + +#include #include #include #include -#include "cheat.h" -#include "ui.h" +#include "inifile.h" +#include "bootsplash.h" #include "nds_card.h" -#include "cheat_engine.h" +#include "launch_engine.h" #include "crc.h" -#include "version.h" +#include "version.h" -const char TITLE_STRING[] = "Nitro Hax " VERSION_STRING "\nWritten by Chishm"; -const char* defaultFiles[] = {"cheats.xml", "/DS/NitroHax/cheats.xml", "/NitroHax/cheats.xml", "/data/NitroHax/cheats.xml", "/cheats.xml"}; +// #define REG_ROMCTRL (*(vu32*)0x40001A4) +// #define REG_SCFG_ROM (*(vu32*)0x4004000) +#define REG_SCFG_CLK (*(vu32*)0x4004004) +#define REG_SCFG_EXT (*(vu32*)0x4004008) +#define REG_SCFG_MC (*(vu32*)0x4004010) -static inline void ensure (bool condition, const char* errorMsg) { - if (false == condition) { - ui.showMessage (errorMsg); - while(1) swiWaitForVBlank(); - } +int main(int argc, const char* argv[]) { - return; -} + // volatile u32* REG_SCFG_EXT = (volatile u32*)0x4004008; + // volatile u32* REG_SCFG_CLK = (volatile u32*)0x4004004; + // volatile u32* REG_SCFG_MC = (volatile u32*)0x4004010; + // volatile u32* REG_SCFG_ROM = (volatile u32*)0x4004000; -//--------------------------------------------------------------------------------- -int main(int argc, const char* argv[]) -{ - (void)argc; - (void)argv; + // REG_SCFG_EXT = 0x8307F100; + + // NTR Mode/Splash used by default + bool UseNTRSplash = true; + bool EnableSD = false; + + REG_SCFG_CLK = 0x85; + + swiWaitForVBlank(); + + // If slot is powered off, tell Arm7 slot power on is required. + if(REG_SCFG_MC == 0x11) { fifoSendValue32(FIFO_USER_02, 1); } + if(REG_SCFG_MC == 0x10) { fifoSendValue32(FIFO_USER_02, 1); } + + // Will wait till implemented in official libnds + // dsi_forceTouchDsmode(); u32 ndsHeader[0x80]; - u32* cheatDest; - int curCheat = 0; char gameid[4]; uint32_t headerCRC; - std::string filename; - int c; - FILE* cheatFile; + + scanKeys(); + int pressed = keysDown(); - ui.showMessage (UserInterface::TEXT_TITLE, TITLE_STRING); + if (fatInitDefault()) { + CIniFile ntrlauncher_config( "sd:/nds/ntr_launcher.ini" ); + + if(ntrlauncher_config.GetInt("NTRLAUNCHER_ALT","NTRCLOCK",0) == 0) { UseNTRSplash = false; } -#ifdef DEMO - ui.demo(); - while(1); -#endif + if(ntrlauncher_config.GetInt("NTRLAUNCHER_ALT","DISABLEANIMATION",0) == 0) { + if( pressed & KEY_B ) { if(REG_SCFG_MC == 0x11) { BootSplashInit(UseNTRSplash); } } else { BootSplashInit(UseNTRSplash); } + } else { + if(REG_SCFG_MC == 0x11) { BootSplashInit(UseNTRSplash); } + } - ensure (fatInitDefault(), "FAT init failed"); + if( UseNTRSplash == true ) { + fifoSendValue32(FIFO_USER_04, 1); + REG_SCFG_CLK = 0x80; + swiWaitForVBlank(); + } - // Read cheat file - for (u32 i = 0; i < sizeof(defaultFiles)/sizeof(const char*); i++) { - cheatFile = fopen (defaultFiles[i], "rb"); - if (NULL != cheatFile) break; - } - if (NULL == cheatFile) { - filename = ui.fileBrowser (".xml"); - ensure (filename.size() > 0, "No file specified"); - cheatFile = fopen (filename.c_str(), "rb"); - ensure (cheatFile != NULL, "Couldn't load cheats"); + if(ntrlauncher_config.GetInt("NTRLAUNCHER_ALT","ENABLESD",0) == 1) { + EnableSD = true; + // Tell Arm7 to use alternate SCFG_EXT values. + fifoSendValue32(FIFO_USER_05, 1); + } + + if(ntrlauncher_config.GetInt("NTRLAUNCHER_ALT","TWLMODE",0) == 1) { + // Tell Arm7 not to switch into NTR mode (this will only work on alt build of NTR Launcher) + fifoSendValue32(FIFO_USER_06, 1); + } + + if(ntrlauncher_config.GetInt("NTRLAUNCHER_ALT","RESETSLOT1",0) == 1) { + fifoSendValue32(FIFO_USER_02, 1); + fifoSendValue32(FIFO_USER_07, 1); + } + + } else { + if ( pressed & KEY_B ) { if(REG_SCFG_MC == 0x11) { BootSplashInit(UseNTRSplash); } } else { BootSplashInit(UseNTRSplash); } } - ui.showMessage (UserInterface::TEXT_TITLE, TITLE_STRING); - ui.showMessage ("Loading codes"); + // Tell Arm7 it's ready for card reset (if card reset is nessecery) + fifoSendValue32(FIFO_USER_01, 1); + // Waits for Arm7 to finish card reset (if nessecery) + fifoWaitValue32(FIFO_USER_03); - c = fgetc(cheatFile); - ensure (c != 0xFF && c != 0xFE, "File is in an unsupported unicode encoding"); - fseek (cheatFile, 0, SEEK_SET); - CheatCodelist* codelist = new CheatCodelist(); - ensure (codelist->load(cheatFile), "Can't read cheat list\n"); - fclose (cheatFile); - - ui.showMessage (UserInterface::TEXT_TITLE, TITLE_STRING); + // Wait for card to stablize before continuing + for (int i = 0; i < 20; i++) { swiWaitForVBlank(); } sysSetCardOwner (BUS_OWNER_ARM9); - ui.showMessage ("Loaded codes\nYou can remove your flash card\nRemove DS Card"); - do { - swiWaitForVBlank(); - getHeader (ndsHeader); - } while (ndsHeader[0] != 0xffffffff); - - ui.showMessage ("Insert Game"); - do { - swiWaitForVBlank(); - getHeader (ndsHeader); - } while (ndsHeader[0] == 0xffffffff); - - // Delay half a second for the DS card to stabilise - for (int i = 0; i < 30; i++) { - swiWaitForVBlank(); - } - getHeader (ndsHeader); - ui.showMessage ("Finding game"); - + for (int i = 0; i < 20; i++) { swiWaitForVBlank(); } + memcpy (gameid, ((const char*)ndsHeader) + 12, 4); headerCRC = crc32((const char*)ndsHeader, sizeof(ndsHeader)); - CheatFolder *gameCodes = codelist->getGame (gameid, headerCRC); - - if (!gameCodes) { - gameCodes = codelist; - } - - ui.cheatMenu (gameCodes, gameCodes); - - - cheatDest = (u32*) malloc(CHEAT_MAX_DATA_SIZE); - ensure (cheatDest != NULL, "Bad malloc\n"); - - std::list cheatList = gameCodes->getEnabledCodeData(); - - for (std::list::iterator cheat = cheatList.begin(); cheat != cheatList.end(); cheat++) { - cheatDest[curCheat++] = (*cheat); - } - - ui.showMessage (UserInterface::TEXT_TITLE, TITLE_STRING); - ui.showMessage ("Running game"); - - runCheatEngine (cheatDest, curCheat * sizeof(u32)); while(1) { - + if(REG_SCFG_MC == 0x11) { + break; } else { + runLaunchEngine (UseNTRSplash, EnableSD); + } } - return 0; } + diff --git a/arm9/source/nds_card.c b/arm9/source/nds_card.c index 1171b36..bf21207 100755 --- a/arm9/source/nds_card.c +++ b/arm9/source/nds_card.c @@ -30,3 +30,4 @@ void getHeader (u32* ndsHeader) { ndsHeader, 512); } + diff --git a/arm9/source/nds_card.h b/arm9/source/nds_card.h index ee1eb93..0d49105 100755 --- a/arm9/source/nds_card.h +++ b/arm9/source/nds_card.h @@ -28,6 +28,10 @@ extern "C" { void getHeader (u32* ndsHeader); +void SwitchToNTRCARD(); + +void SwitchToTWLCARD(); + #ifdef __cplusplus } diff --git a/arm9/source/stringtool.cpp b/arm9/source/stringtool.cpp new file mode 100644 index 0000000..f7ad76e --- /dev/null +++ b/arm9/source/stringtool.cpp @@ -0,0 +1,45 @@ +/*--------------------------------------------------------------------------------- + + +Copyright (C) 2007 Acekard, www.acekard.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +---------------------------------------------------------------------------------*/ + +#include "stringtool.h" +#include +#include +#include + +std::string formatString( const char* fmt, ... ) +{ + const char * f = fmt; + va_list argList; + va_start(argList, fmt); + char * ptempStr = NULL; + size_t max_len = vasiprintf( &ptempStr, f, argList); + std::string str( ptempStr ); + str.resize( max_len ); + free( ptempStr ); + va_end(argList); + return str; +} + diff --git a/arm9/source/stringtool.h b/arm9/source/stringtool.h new file mode 100644 index 0000000..ab67cb9 --- /dev/null +++ b/arm9/source/stringtool.h @@ -0,0 +1,44 @@ +/*--------------------------------------------------------------------------------- + + +Copyright (C) 2007 Acekard, www.acekard.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +---------------------------------------------------------------------------------*/ + + + + + + + + + +#ifndef _STRINGTOOL_H_ +#define _STRINGTOOL_H_ + +#include + +std::string formatString( const char* fmt, ... ); + + + +#endif//_STRINGTOOL_H_ diff --git a/arm9/source/ui.cpp b/arm9/source/ui.cpp deleted file mode 100755 index f7742d2..0000000 --- a/arm9/source/ui.cpp +++ /dev/null @@ -1,1064 +0,0 @@ -/* - NitroHax -- Cheat tool for the Nintendo DS - Copyright (C) 2008 Michael "Chishm" Chisholm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ui.h" -#include "bios_decompress_callback.h" - -#include "font.h" -#include "bgtop.h" -#include "bgsub.h" -#include "scrollbar.h" -#include "cursor.h" -#include "textbox.h" -#include "button_off.h" -#include "button_on.h" -#include "button_folder.h" -#include "button_file.h" -#include "button_go.h" - -#define MAX_CHARS_PER_SCREEN 768 - -#define CONSOLE_SCREEN_WIDTH 32 -#define CONSOLE_SCREEN_HEIGHT 24 -#define CONSOLE_SUB_START_ROW 24 -#define MAP_SIZE 1024 - -#define FIRST_ROW 0 -#define FIRST_COL 0 -#define LAST_ROW (CONSOLE_SCREEN_HEIGHT - 1) -#define LAST_COL (CONSOLE_SCREEN_WIDTH - 1) - -#define MENU_LAST_COL 28 -#define MENU_NUM_ITEMS 10 -#define MENU_FIRST_ROW 0 -#define MENU_FIRST_COL 0 -#define MENU_LAST_ROW (MENU_FIRST_ROW + (MENU_NUM_ITEMS - 1)) - -#define MENU_CONTROLS_ROW 11 - -#define TITLE_BOX_START_ROW 8 -#define TITLE_BOX_END_ROW 12 - -#define TEXT_BOX_START_ROW 13 -#define TEXT_BOX_END_ROW 23 - -#define TOUCH_GRID_SIZE 16 - -#define SCROLLBAR_START MENU_FIRST_ROW -#define SCROLLBAR_END (MENU_FIRST_ROW + MENU_NUM_ITEMS - 1) -#define SCROLLBAR_COL 15 - -#define GO_BUTTON_COL 8 -#define GO_BUTTON_ROW 21 -#define GO_BUTTON_WIDTH 16 -#define GO_BUTTON_HEIGHT 3 - -#define CURSOR_VERTICAL_OFFSET (-8) // Compensate for position of cursor image within bitmap file - -#define TILE_SIZE 32 -#define PALETTE_SIZE 16 - -// button combinations for the menus -#define BUTTON_LINE_UP KEY_UP -#define BUTTON_LINE_DOWN KEY_DOWN -#define BUTTON_PAGE_UP KEY_L -#define BUTTON_PAGE_DOWN KEY_R -#define BUTTON_SELECT KEY_A -#define BUTTON_BACK KEY_B -#define BUTTON_EXIT KEY_START -#define BUTTON_ENABLE_ALL KEY_X -#define BUTTON_DISABLE_ALL KEY_Y - -#define MENU_PAGE_SCROLL 6 - -#define CHEAT_MENU_FOLDER_UP -1 -const char CHEAT_MENU_FOLDER_UP_NAME[] = " [..]"; - - -UserInterface ui; - -void vramcpy (void* dest, const void* src, int size) -{ - u16* destination = (u16*)dest; - u16* source = (u16*)src; - while (size > 0) { - *destination++ = *source++; - size-=2; - } -} - -UserInterface::UserInterface (void) -{ - videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE | DISPLAY_BG2_ACTIVE); - // BG0 = backdrop - // BG1 = text box background & border - // BG2 = text - vramSetBankA (VRAM_A_MAIN_BG_0x06000000); - REG_BG0CNT = BG_MAP_BASE(0) | BG_COLOR_16 | BG_TILE_BASE(2) | BG_PRIORITY(2); - REG_BG1CNT = BG_MAP_BASE(2) | BG_COLOR_16 | BG_TILE_BASE(4) | BG_PRIORITY(1); - REG_BG2CNT = BG_MAP_BASE(4) | BG_COLOR_16 | BG_TILE_BASE(6) | BG_PRIORITY(0); - BG_PALETTE[0]=0; - BG_PALETTE[255]=0xffff; - - videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE | - DISPLAY_BG1_ACTIVE | DISPLAY_BG2_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D); - // BG0 = backdrop - // BG1 = scrollbar & highlights - // BG2 = text - vramSetBankC (VRAM_C_SUB_BG_0x06200000); - REG_BG0CNT_SUB = BG_MAP_BASE(0) | BG_COLOR_16 | BG_TILE_BASE(2) | BG_PRIORITY(2); - REG_BG1CNT_SUB = BG_MAP_BASE(2) | BG_COLOR_16 | BG_TILE_BASE(4) | BG_PRIORITY(1); - REG_BG2CNT_SUB = BG_MAP_BASE(4) | BG_COLOR_16 | BG_TILE_BASE(6) | BG_PRIORITY(0); - - // Set up background image - swiDecompressLZSSVram ((void*)bgtopTiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); - swiDecompressLZSSVram ((void*)bgsubTiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); - vramcpy (&BG_PALETTE[0], bgtopPal, bgtopPalLen); - vramcpy (&BG_PALETTE_SUB[0], bgsubPal, bgsubPalLen); - u16* bgMapTop = (u16*)SCREEN_BASE_BLOCK(0); - u16* bgMapSub = (u16*)SCREEN_BASE_BLOCK_SUB(0); - for (int i = 0; i < CONSOLE_SCREEN_WIDTH*CONSOLE_SCREEN_HEIGHT; i++) { - bgMapTop[i] = (u16)i; - bgMapSub[i] = (u16)i; - } - - // Copy text box for BG1 - use palette 3 - vramcpy (&BG_PALETTE[TEXTBOX_PALETTE * PALETTE_SIZE], textboxPal, textboxPalLen); - vramcpy ((void*)(CHAR_BASE_BLOCK(4) + TEXTBOX_OFFSET * TILE_SIZE), textboxTiles, textboxTilesLen); - textboxMap = (u16*)SCREEN_BASE_BLOCK(2); - // Clear tile 0 - for (int i = 0; i < TILE_SIZE/2; i++) { - ((u16*)CHAR_BASE_BLOCK(4))[i] = 0; - } - clearBox(); - - // Copy the font into top screen's tile base for BG2 - u16* fontDestMain = (u16*)CHAR_BASE_BLOCK(6); - swiDecompressLZSSVram ((void*)fontTiles, fontDestMain, 0, &decompressBiosCallback); - vramcpy (&BG_PALETTE[FONT_PALETTE * PALETTE_SIZE], fontPal, fontPalLen); - - // Copy the font into sub screen's tile base for BG2 - u16* fontDestSub = (u16*)CHAR_BASE_BLOCK_SUB(6); - swiDecompressLZSSVram ((void*)fontTiles, fontDestSub, 0, &decompressBiosCallback); - vramcpy (&BG_PALETTE_SUB[FONT_PALETTE * PALETTE_SIZE], fontPal, fontPalLen); - BG_OFFSET_SUB[2].x = -4; - BG_OFFSET_SUB[2].y = -4; - - u16* fontMapTop = (u16*)SCREEN_BASE_BLOCK(4); - u16* fontMapSub = (u16*)SCREEN_BASE_BLOCK_SUB(4); - - // Initialise consoles - topText = new ConsoleText (CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT, - ConsoleText::CHAR_SIZE_8PX, fontMapTop, FONT_PALETTE); - subText = new ConsoleText (MENU_LAST_COL - MENU_FIRST_COL + 1, CONSOLE_SCREEN_HEIGHT, - ConsoleText::CHAR_SIZE_8PX, fontMapSub, FONT_PALETTE); - for (int i = 0; i < MAP_SIZE; i++) { - fontMapSub[i] = 0; - } - - // Set up the GUI BG - u16* tileDestSub = (u16*)CHAR_BASE_BLOCK_SUB(4); - guiSubMap = (u16*)SCREEN_BASE_BLOCK_SUB(2); - BG_OFFSET[1].x = 0; - BG_OFFSET[1].y = 0; - // Create a double size blank tile - for (int i = 0; i < 4 * TILE_SIZE; i++) { - tileDestSub[i] = 0; - } - // Clear GUI tile map - for (int i = 0; i < CONSOLE_SCREEN_WIDTH * CONSOLE_SCREEN_HEIGHT; i++) { - guiSubMap[i] = 0; - } - - // Load scroll bar data, use palette 1 - vramcpy (&tileDestSub[SCROLLBAR_OFFSET * TILE_SIZE / 2], scrollbarTiles, scrollbarTilesLen); - vramcpy (&BG_PALETTE_SUB[SCROLLBAR_PALETTE * PALETTE_SIZE], scrollbarPal, scrollbarPalLen); - - // Load button backgrounds - vramcpy (&tileDestSub[BUTTON_BG_FOLDER * TILE_SIZE / 2], button_folderTiles, button_folderTilesLen); - vramcpy (&BG_PALETTE_SUB[BUTTON_PALETTE_FOLDER * PALETTE_SIZE], button_folderPal, button_folderPalLen); - vramcpy (&tileDestSub[BUTTON_BG_ON * TILE_SIZE / 2], button_onTiles, button_onTilesLen); - vramcpy (&BG_PALETTE_SUB[BUTTON_PALETTE_ON * PALETTE_SIZE], button_onPal, button_onPalLen); - vramcpy (&tileDestSub[BUTTON_BG_OFF * TILE_SIZE / 2], button_offTiles, button_offTilesLen); - vramcpy (&BG_PALETTE_SUB[BUTTON_PALETTE_OFF * PALETTE_SIZE], button_offPal, button_offPalLen); - vramcpy (&tileDestSub[BUTTON_BG_FILE * TILE_SIZE / 2], button_fileTiles, button_fileTilesLen); - vramcpy (&BG_PALETTE_SUB[BUTTON_PALETTE_FILE * PALETTE_SIZE], button_filePal, button_filePalLen); - - // Load go button - vramcpy (&tileDestSub[GO_BUTTON_OFFSET * TILE_SIZE / 2], button_goTiles, button_goTilesLen); - vramcpy (&BG_PALETTE_SUB[GO_BUTTON_PALETTE * PALETTE_SIZE], button_goPal, button_goPalLen); - - // Erase any text already on screen - topText->clearText(); - subText->clearText(); - - // Set up sub screen sprites - vramSetBankD (VRAM_D_SUB_SPRITE); - Sprite::init(); - - for (int i = 0; i < NUM_CURSORS; i++) { - cursor[i] = new Sprite (64, 32, (const u16*)&(cursorTiles[256 * i]), cursorPal); - } - - scrollbox = new Sprite (16, 16, (const u16*)&(scrollbarTiles[96]), scrollbarPal); - showScrollbar (false); -} - -UserInterface::~UserInterface () -{ - delete scrollbox; - delete topText; - delete subText; - for (int i = 0; i < NUM_CURSORS; i++) { - delete cursor[i]; - } -} - -void UserInterface::putGuiTile (int val, int row, int col, int palette, bool doubleSize) -{ - u16 pal = (u16)(palette << 12); - if (!doubleSize) { - guiSubMap[col + row * CONSOLE_SCREEN_WIDTH] = pal | (u16)val; - } else { - guiSubMap[col + row * CONSOLE_SCREEN_WIDTH] = pal | (u16)(val); - guiSubMap[(col + 1) + row * CONSOLE_SCREEN_WIDTH] = pal | (u16)(val + 1); - guiSubMap[col + (row + 1) * CONSOLE_SCREEN_WIDTH] = pal | (u16)(val + 2); - guiSubMap[(col + 1) + (row + 1) * CONSOLE_SCREEN_WIDTH] = pal | (u16)(val + 3); - } -} - -void UserInterface::showScrollbar (bool visible) -{ - if (visible) { - for (int i = SCROLLBAR_START + 1; i <= SCROLLBAR_END - 1; i++) { - // vertical bar - putGuiTile (SCROLLBAR_BAR, i*2, SCROLLBAR_COL * 2, SCROLLBAR_PALETTE, true); - } - // up arrow - putGuiTile (SCROLLBAR_UP, SCROLLBAR_START*2, SCROLLBAR_COL * 2, SCROLLBAR_PALETTE, true); - // down arrow - putGuiTile (SCROLLBAR_DOWN, SCROLLBAR_END*2, SCROLLBAR_COL * 2, SCROLLBAR_PALETTE, true); - } else { - for (int i = SCROLLBAR_START; i <= SCROLLBAR_END ; i++) { - // vertical bar - putGuiTile (BLANK_TILE, i*2, SCROLLBAR_COL * 2, 0, true); - } - } - - scrollboxPosition = (SCROLLBAR_START + 1) * TOUCH_GRID_SIZE; - scrollbox->setPosition (scrollboxPosition, (CONSOLE_SCREEN_WIDTH - 2) * 8); - scrollbox->showSprite (visible); -} - -void UserInterface::setScrollbarPosition (int offset, int listLength) -{ - scrollboxPosition = ((SCROLLBAR_END - SCROLLBAR_START - 2) * TOUCH_GRID_SIZE * offset / listLength) + (SCROLLBAR_START + 1) * TOUCH_GRID_SIZE; - scrollbox->setPosition (scrollboxPosition, (CONSOLE_SCREEN_WIDTH - 2) * 8); -} - -void UserInterface::showCursor (bool visible) -{ - for (int i = 0; i < NUM_CURSORS; i++) { - cursor[i]->setPosition (16, 64 * i); - cursor[i]->showSprite (visible); - } -} - -void UserInterface::setCursorPosition (int offset) -{ - for (int i = 0; i < NUM_CURSORS; i++) { - cursor[i]->setPosition (offset + CURSOR_VERTICAL_OFFSET, 64 * i); - } -} - -void UserInterface::drawBox (int startRow, int startCol, int endRow, int endCol) -{ - for (int i = startCol + 1; i < endCol; i++) { - textboxMap[startRow * CONSOLE_SCREEN_WIDTH + i] = TEXTBOX_N | (TEXTBOX_PALETTE << 12); - textboxMap[endRow * CONSOLE_SCREEN_WIDTH + i] = TEXTBOX_S | (TEXTBOX_PALETTE << 12); - } - for (int i = startRow + 1; i < endRow; i++) { - textboxMap[i * CONSOLE_SCREEN_WIDTH + startCol] = TEXTBOX_W | (TEXTBOX_PALETTE << 12); - textboxMap[i * CONSOLE_SCREEN_WIDTH + endCol] = TEXTBOX_E | (TEXTBOX_PALETTE << 12); - } - textboxMap[startRow * CONSOLE_SCREEN_WIDTH + startCol] = TEXTBOX_NW | (TEXTBOX_PALETTE << 12); - textboxMap[startRow * CONSOLE_SCREEN_WIDTH + endCol] = TEXTBOX_NE | (TEXTBOX_PALETTE << 12); - textboxMap[endRow * CONSOLE_SCREEN_WIDTH + startCol] = TEXTBOX_SW | (TEXTBOX_PALETTE << 12); - textboxMap[endRow * CONSOLE_SCREEN_WIDTH + endCol] = TEXTBOX_SE | (TEXTBOX_PALETTE << 12); - for (int i = startRow + 1; i < endRow; i++) { - for (int j = startCol + 1; j < endCol; j++) { - textboxMap[i * CONSOLE_SCREEN_WIDTH + j] = TEXTBOX_C | (TEXTBOX_PALETTE << 12); - } - } -} - -void UserInterface::clearBox (int startRow, int startCol, int endRow, int endCol) -{ - for (int i = startRow; i <= endRow; i++) { - for (int j = startCol; j <= endCol; j++) { - textboxMap[i * CONSOLE_SCREEN_WIDTH + j] = 0 | (TEXTBOX_PALETTE << 12); - } - } -} - -void UserInterface::clearBox (void) -{ - for (int i = 0; i < CONSOLE_SCREEN_WIDTH*CONSOLE_SCREEN_HEIGHT; i++) { - textboxMap[i] = 0 | (TEXTBOX_PALETTE << 12); - } -} - - -void UserInterface::wordWrap (char* str, int height, int width) -{ - int maxLen = 768; - char wrappedText[768]; - char *srcPos = str; - char *destPos = wrappedText; - char *wordStart; - char *wordEnd; - int numLines = 1; - int spaceLeft = width; - int wordLength; - - memset (wrappedText, 0, maxLen); - - while (*srcPos != '\0' && destPos < (wrappedText + maxLen)) { - while (*srcPos && isspace(*srcPos)) { - if (*srcPos == '\n') { - *destPos++ = '\n'; - spaceLeft = width; - ++numLines; - } - ++srcPos; // find start of word - } - if (*srcPos == '\0') { - break; - } - wordStart = srcPos; - while (*srcPos && !isspace(*srcPos)) { - ++srcPos; // find end of word - } - wordEnd = srcPos; - wordLength = wordEnd - wordStart; - if ((wordLength > spaceLeft) && (wordLength <= width)) { - // Word needs to be put on a new line - *destPos++ = '\n'; - spaceLeft = width; - ++numLines; - } else if (spaceLeft < width) { - // Not at the start of a line - *destPos++ = ' '; - spaceLeft = spaceLeft - 1; - } - memcpy (destPos, wordStart, wordLength); - destPos += wordLength; - spaceLeft -= wordLength; - while (spaceLeft < 0) { - spaceLeft += width; - } - } - if (numLines <= height) { - strcpy (str, wrappedText); - } -} - -void UserInterface::writeTextBox (TEXT_TYPE textType, const char* str, va_list args) -{ - char dispStr[MAX_CHARS_PER_SCREEN]; - vsniprintf(dispStr, MAX_CHARS_PER_SCREEN, str, args); - int lastRow; - - clearMessage (textType); - if (textType == TEXT_TITLE) { - wordWrap (dispStr, TITLE_BOX_END_ROW - TITLE_BOX_START_ROW - 2, LAST_COL - FIRST_COL - 2); - lastRow = topText->putText (dispStr, FIRST_COL + 1, - TITLE_BOX_END_ROW - 1, LAST_COL - 1, TITLE_BOX_START_ROW + 1, FIRST_COL + 1); - drawBox (TITLE_BOX_START_ROW, FIRST_COL, lastRow + 1, LAST_COL); - } else { - wordWrap (dispStr, TEXT_BOX_END_ROW - TEXT_BOX_START_ROW - 2, LAST_COL - FIRST_COL - 2); - lastRow = topText->putText (dispStr, FIRST_COL + 1, - TEXT_BOX_END_ROW - 1, LAST_COL - 1, TEXT_BOX_START_ROW + 1, FIRST_COL + 1); - drawBox (TEXT_BOX_START_ROW, FIRST_COL, lastRow + 1, LAST_COL); - } -} - -void UserInterface::showMessage (const char* str, ...) -{ - va_list args; - - va_start(args, str); - writeTextBox (TEXT_INFO, str, args); - va_end(args); -} - -void UserInterface::showMessage (TEXT_TYPE textType, const char* str, ...) -{ - va_list args; - - va_start(args, str); - writeTextBox (textType, str, args); - va_end(args); -} - -void UserInterface::clearMessage (TEXT_TYPE textType) -{ - if (textType == TEXT_TITLE) { - topText->clearText (TITLE_BOX_START_ROW, FIRST_COL, TITLE_BOX_END_ROW, LAST_COL); - clearBox (TITLE_BOX_START_ROW, FIRST_COL, TITLE_BOX_END_ROW, LAST_COL); - } else { - topText->clearText (TEXT_BOX_START_ROW, FIRST_COL, TEXT_BOX_END_ROW, LAST_COL); - clearBox (TEXT_BOX_START_ROW, FIRST_COL, TEXT_BOX_END_ROW, LAST_COL); - } -} - -void UserInterface::clearMessage (void) -{ - clearMessage (TEXT_TITLE); - clearMessage (TEXT_INFO); -} - -void UserInterface::putButtonBg (BUTTON_BG_OFFSETS buttonBg, int position) -{ - int palette; - - if (buttonBg != BUTTON_BG_NONE) { - if (buttonBg == BUTTON_BG_FOLDER) { - palette = BUTTON_PALETTE_FOLDER; - } else if (buttonBg == BUTTON_BG_FILE) { - palette = BUTTON_PALETTE_FILE; - } else if (buttonBg == BUTTON_BG_ON) { - palette = BUTTON_PALETTE_ON; - } else { - palette = BUTTON_PALETTE_OFF; - } - for (int col = 0; col < 30; col++) { - for (int row = 0; row < 2; row++) { - putGuiTile (buttonBg + col + row * 30, row + position , col, palette, false); - } - } - } else { - for (int col = 0; col < 30; col++) { - for (int row = 0; row < 2; row++) { - putGuiTile (BLANK_TILE, row + position , col, 0, false); - } - } - } -} - -void UserInterface::clearFolderBackground (void) -{ - for (int i = MENU_FIRST_ROW; i <= MENU_LAST_ROW; i++) { - putButtonBg (BUTTON_BG_NONE, i * 2); - } -} - -void UserInterface::showGoButton (bool visible, int left, int top) -{ - if (visible) { - for (int col = 0; col < GO_BUTTON_WIDTH; col++) { - for (int row = 0; row < GO_BUTTON_HEIGHT; row++) { - putGuiTile (GO_BUTTON_OFFSET + col + row * GO_BUTTON_WIDTH, row + top, col + left, GO_BUTTON_PALETTE, false); - } - } - } else { - for (int col = 0; col < GO_BUTTON_WIDTH; col++) { - for (int row = 0; row < GO_BUTTON_HEIGHT; row++) { - putGuiTile (BLANK_TILE, row + top, col + left, 0, false); - } - } - } -} - - -void UserInterface::showCheatFolder (std::vector &contents) -{ - int menuLength; - - menuLevel.bottom = menuLevel.top + MENU_NUM_ITEMS - 1; - - if (menuLevel.bottom >= (int)contents.size()) { - menuLevel.bottom = contents.size() - 1; - } - - menuLength = menuLevel.bottom - menuLevel.top; - - subText->clearText(MENU_FIRST_ROW, 0, MENU_LAST_ROW*2, MENU_LAST_COL); - - clearFolderBackground(); - - for (int curItem = 0; curItem <= menuLength; curItem++) { - if (CHEAT_MENU_FOLDER_UP == menuLevel.top + curItem) { - putButtonBg (BUTTON_BG_FOLDER, (MENU_FIRST_ROW + curItem) * 2); - subText->putText (CHEAT_MENU_FOLDER_UP_NAME, MENU_FIRST_COL, - (MENU_FIRST_ROW + curItem) * 2, MENU_LAST_COL, (MENU_FIRST_ROW + curItem) * 2, MENU_FIRST_COL); - } else { - CheatCode* cheatCode = dynamic_cast(contents[menuLevel.top + curItem]); - - subText->putText (contents[menuLevel.top + curItem]->getName(), MENU_FIRST_COL, - (MENU_FIRST_ROW + curItem) * 2, MENU_LAST_COL, (MENU_FIRST_ROW + curItem) * 2, MENU_FIRST_COL); - - if (cheatCode) { - if (cheatCode->getEnabledStatus()) { - putButtonBg (BUTTON_BG_ON, (MENU_FIRST_ROW + curItem) * 2); - } else { - putButtonBg (BUTTON_BG_OFF, (MENU_FIRST_ROW + curItem) * 2); - } - } else { - putButtonBg (BUTTON_BG_FOLDER, (MENU_FIRST_ROW + curItem) * 2); - } - } - } -} - -#define CHEAT_MENU_TOP (gameCodes==top?0:CHEAT_MENU_FOLDER_UP) - -void UserInterface::cheatMenu (CheatFolder* gameCodes, CheatFolder* top) -{ - menuLevel.top = 0; - menuLevel.selected = 0; - - std::stack menuLevelStack; - - std::vector contents = gameCodes->getContents(); - - showScrollbar(true); - showCheatFolder (contents); - showCursor (true); - showGoButton(true, GO_BUTTON_COL, GO_BUTTON_ROW); - - int pressed; - - while ((pressed = menuInput(true)) != BUTTON_EXIT) { - if (pressed == BUTTON_LINE_DOWN) { - if (menuLevel.selected < (int)contents.size()-1) { - menuLevel.selected ++; - if (menuLevel.selected > menuLevel.bottom) { - menuLevel.top ++; - showCheatFolder (contents); - } - } - } else if (pressed == BUTTON_LINE_UP) { - if (menuLevel.selected > CHEAT_MENU_TOP) { - menuLevel.selected --; - if (menuLevel.selected < menuLevel.top) { - menuLevel.top --; - showCheatFolder (contents); - } - } - } else if (pressed == BUTTON_SELECT) { - if (menuLevel.selected == CHEAT_MENU_FOLDER_UP) { - CheatFolder* cheatFolder = gameCodes->getParent(); - if (!cheatFolder || gameCodes == top) { - // Back out of top level folder - break; - } else { - gameCodes = cheatFolder; - if (!menuLevelStack.empty()) { - menuLevel = menuLevelStack.top(); - menuLevelStack.pop(); - } else { - menuLevel.top = CHEAT_MENU_TOP; - menuLevel.selected = CHEAT_MENU_TOP; - } - contents = gameCodes->getContents(); - showCheatFolder (contents); - } - } else { - CheatCode* cheatCode = dynamic_cast(contents[menuLevel.selected]); - CheatFolder* cheatFolder = dynamic_cast(contents[menuLevel.selected]); - if (cheatCode) { - cheatCode->toggleEnabled(); - showCheatFolder (contents); - } else if (cheatFolder) { - menuLevelStack.push(menuLevel); - gameCodes = cheatFolder; - menuLevel.top = CHEAT_MENU_TOP; - menuLevel.selected = CHEAT_MENU_TOP; - contents = gameCodes->getContents(); - showCheatFolder (contents); - } - } - } else if (pressed == BUTTON_BACK) { - CheatFolder* cheatFolder = gameCodes->getParent(); - if (!cheatFolder || gameCodes == top) { - // Back out of top level folder - break; - } else { - if (!menuLevelStack.empty()) { - menuLevel = menuLevelStack.top(); - menuLevelStack.pop(); - } else { - menuLevel.top = CHEAT_MENU_TOP; - menuLevel.selected = CHEAT_MENU_TOP; - } - gameCodes = cheatFolder; - contents = gameCodes->getContents(); - showCheatFolder (contents); - } - } else if (pressed == BUTTON_PAGE_UP) { - menuLevel.selected -= MENU_PAGE_SCROLL; - if (menuLevel.selected < CHEAT_MENU_TOP) { - menuLevel.selected = CHEAT_MENU_TOP; - } - menuLevel.top -= MENU_PAGE_SCROLL; - if (menuLevel.top < CHEAT_MENU_TOP) { - menuLevel.top = CHEAT_MENU_TOP; - } - showCheatFolder (contents); - } else if (pressed == BUTTON_PAGE_DOWN) { - menuLevel.selected += MENU_PAGE_SCROLL; - if (menuLevel.selected > (int)contents.size()-1) { - menuLevel.selected = (int)contents.size()-1; - } - menuLevel.top += MENU_PAGE_SCROLL; - if (menuLevel.top > (int)contents.size()-MENU_NUM_ITEMS) { - menuLevel.top = (int)contents.size()-MENU_NUM_ITEMS; - } - if (menuLevel.top < CHEAT_MENU_TOP) { - menuLevel.top = CHEAT_MENU_TOP; - } - showCheatFolder (contents); - } else if (pressed == BUTTON_ENABLE_ALL) { - gameCodes->enableAll(true); - showCheatFolder (contents); - } else if (pressed == BUTTON_DISABLE_ALL) { - gameCodes->enableAll(false); - showCheatFolder (contents); - } - setCursorPosition ((MENU_FIRST_ROW + menuLevel.selected - menuLevel.top) * TOUCH_GRID_SIZE); - setScrollbarPosition (CHEAT_MENU_TOP + menuLevel.selected, (int)contents.size()-1); - showMessage (TEXT_TITLE, "%s", gameCodes->getName()); - if (contents[menuLevel.selected]->note.empty()) { - showMessage (TEXT_INFO, "%s", contents[menuLevel.selected]->getName()); - } else { - showMessage (TEXT_INFO, "%s\n\n%s", contents[menuLevel.selected]->getName(), contents[menuLevel.selected]->getNote()); - } - } - - clearMessage (); - clearFolderBackground(); - showCursor (false); - showScrollbar (false); - showGoButton(false, GO_BUTTON_COL, GO_BUTTON_ROW); - subText->clearText (); -} - - -bool UserInterface::fileInfoPredicate (const FileInfo& lhs, const FileInfo& rhs) -{ - if (!lhs.isDirectory && rhs.isDirectory) { - return false; - } - if (lhs.isDirectory && !rhs.isDirectory) { - return true; - } - return strcasecmp(lhs.filename.c_str(), rhs.filename.c_str()) < 0; -} - -std::vector UserInterface::getDirContents (const char* extension) -{ - std::vector files; - struct dirent* dentry; - size_t extLen = 0; - - if (extension) { - extLen = strlen (extension); - } - - DIR* dir = opendir ("."); - - while ( NULL != (dentry = readdir(dir)) ) { - bool isDirectory = (dentry->d_type == DT_DIR); - size_t nameLen = strlen(dentry->d_name); - if ( (isDirectory && strcmp(dentry->d_name, ".") != 0) || - extension == NULL || - strcasecmp(extension, &dentry->d_name[nameLen-extLen]) != 0 ) - { - UserInterface::FileInfo fileInfo; - fileInfo.filename = dentry->d_name; - fileInfo.isDirectory = isDirectory; - files.push_back (fileInfo); - } - } - - closedir (dir); - - std::sort(files.begin(), files.end(), UserInterface::fileInfoPredicate); - - return files; -} - -void UserInterface::showFileFolder (std::vector &contents) -{ - int menuLength; - - menuLevel.bottom = menuLevel.top + MENU_LAST_ROW; - - if (menuLevel.bottom >= (int)contents.size()) { - menuLevel.bottom = contents.size() - 1; - } - - menuLength = menuLevel.bottom - menuLevel.top; - - subText->clearText(MENU_FIRST_ROW, 0, MENU_LAST_ROW*2, MENU_LAST_COL); - - for (int i = MENU_FIRST_ROW; i <= MENU_LAST_ROW; i++) { - putButtonBg (BUTTON_BG_NONE, i * 2); - } - - for (int curItem = 0; curItem <= menuLength; curItem++) { - subText->putText (contents[menuLevel.top + curItem].filename.c_str(), - MENU_FIRST_COL, (MENU_FIRST_ROW + curItem) * 2, MENU_LAST_COL, - (MENU_FIRST_ROW + curItem) * 2, MENU_FIRST_COL); - - if (contents[menuLevel.top + curItem].isDirectory) { - putButtonBg (BUTTON_BG_FOLDER, (MENU_FIRST_ROW + curItem) * 2); - } else { - putButtonBg (BUTTON_BG_FILE, (MENU_FIRST_ROW + curItem) * 2); - } - } -} - -int UserInterface::menuInput(bool enableGoButton) -{ - int pressed; - touchPosition touchXY; - - swiWaitForVBlank(); - scanKeys(); - pressed = keysDown(); - touchRead(&touchXY); - - // Touch screen stuff - if (pressed & KEY_TOUCH) { - if ((touchXY.px < (SCROLLBAR_COL * TOUCH_GRID_SIZE)) && -#if MENU_FIRST_ROW > 0 - (touchXY.py >= (MENU_FIRST_ROW * TOUCH_GRID_SIZE)) && -#endif - (touchXY.py < ((MENU_FIRST_ROW + menuLevel.bottom - menuLevel.top + 1) * TOUCH_GRID_SIZE))) - { - // Touched an item - menuLevel.selected = (touchXY.py / TOUCH_GRID_SIZE) + menuLevel.top - MENU_FIRST_ROW; - pressed = BUTTON_SELECT; - } - if (touchXY.px >= (SCROLLBAR_COL * TOUCH_GRID_SIZE) && touchXY.px < ((SCROLLBAR_COL+1) * TOUCH_GRID_SIZE)) { - if ( -#if SCROLLBAR_START > 0 - (touchXY.py >= (SCROLLBAR_START) * TOUCH_GRID_SIZE) && -#endif - (touchXY.py < (SCROLLBAR_START + 1) * TOUCH_GRID_SIZE)) - { - // Touched up arrow - pressed = BUTTON_LINE_UP; - } else if ((touchXY.py >= SCROLLBAR_END * TOUCH_GRID_SIZE) && (touchXY.py < (SCROLLBAR_END + 1) * TOUCH_GRID_SIZE)) { - // Touched down arrow - pressed = BUTTON_LINE_DOWN; - } else if ((touchXY.py >= (SCROLLBAR_START + 1) * TOUCH_GRID_SIZE) && (touchXY.py < scrollboxPosition)) { - // Touched scrollbar above scrollbox - pressed = BUTTON_PAGE_UP; - } else if ((touchXY.py >= scrollboxPosition + TOUCH_GRID_SIZE) && (touchXY.py < (SCROLLBAR_END) * TOUCH_GRID_SIZE)) { - // Touched scrollbar below scrollbox - pressed = BUTTON_PAGE_DOWN; - } - } - if (enableGoButton) - { - if ((touchXY.px >= (GO_BUTTON_COL * TOUCH_GRID_SIZE / 2)) && - (touchXY.px < ((GO_BUTTON_COL + GO_BUTTON_WIDTH) * TOUCH_GRID_SIZE / 2)) && - (touchXY.py >= (GO_BUTTON_ROW * TOUCH_GRID_SIZE / 2)) && - (touchXY.py < ((GO_BUTTON_ROW + GO_BUTTON_HEIGHT) * TOUCH_GRID_SIZE / 2))) - { - // Touched the go button - pressed = BUTTON_EXIT; - } - } - } - - return pressed; -} - -std::string UserInterface::fileBrowser (const char* extension) -{ - menuLevel.top = 0; - menuLevel.selected = 0; - - std::vector contents; - std::string filename; - char* cwd = new char[MAXPATHLEN]; - std::stack menuLevelStack; - - contents = getDirContents (extension); - - showScrollbar (true); - showFileFolder (contents); - showCursor (true); - - if (extension) { - showMessage (TEXT_TITLE, "Open *%s file", extension); - } else { - showMessage (TEXT_TITLE, "Open file"); - } - - int pressed; - - while ((pressed = menuInput(false)) != BUTTON_EXIT) { - if (pressed == BUTTON_LINE_DOWN) { - if (menuLevel.selected < (int)contents.size()-1) { - menuLevel.selected ++; - if (menuLevel.selected > menuLevel.bottom) { - menuLevel.top ++; - showFileFolder (contents); - } - } - } else if (pressed == BUTTON_LINE_UP) { - if (menuLevel.selected > 0) { - menuLevel.selected --; - if (menuLevel.selected < menuLevel.top) { - menuLevel.top --; - showFileFolder (contents); - } - } - } else if (pressed == BUTTON_SELECT) { - if (contents[menuLevel.selected].isDirectory) { - if (contents[menuLevel.selected].filename == "..") { - chdir(".."); - if (!menuLevelStack.empty()) { - menuLevel = menuLevelStack.top(); - menuLevelStack.pop(); - } else { - menuLevel.top = 0; - menuLevel.selected = 0; - } - } else { - chdir (contents[menuLevel.selected].filename.c_str()); - menuLevelStack.push(menuLevel); - menuLevel.top = 0; - menuLevel.selected = 0; - } - contents = getDirContents(extension); - showFileFolder (contents); - } else { - filename = contents[menuLevel.selected].filename.c_str(); - break; - } - } else if (pressed == BUTTON_BACK) { - chdir (".."); - if (!menuLevelStack.empty()) { - menuLevel = menuLevelStack.top(); - menuLevelStack.pop(); - } else { - menuLevel.top = 0; - menuLevel.selected = 0; - } - contents = getDirContents(extension); - showFileFolder (contents); - } else if (pressed == BUTTON_PAGE_UP) { - menuLevel.selected -= MENU_PAGE_SCROLL; - if (menuLevel.selected < 0) { - menuLevel.selected = 0; - } - menuLevel.top -= MENU_PAGE_SCROLL; - if (menuLevel.top < 0) { - menuLevel.top = 0; - } - showFileFolder (contents); - } else if (pressed == BUTTON_PAGE_DOWN) { - menuLevel.selected += MENU_PAGE_SCROLL; - if (menuLevel.selected > (int)contents.size()-1) { - menuLevel.selected = (int)contents.size()-1; - } - menuLevel.top += MENU_PAGE_SCROLL; - if (menuLevel.top > (int)contents.size()-MENU_NUM_ITEMS) { - menuLevel.top = (int)contents.size()-MENU_NUM_ITEMS; - } - if (menuLevel.top < 0) { - menuLevel.top = 0; - } - showFileFolder (contents); - } - setCursorPosition ((MENU_FIRST_ROW + menuLevel.selected - menuLevel.top) * TOUCH_GRID_SIZE); - setScrollbarPosition (menuLevel.selected, (int)contents.size()-1); - getcwd (cwd, MAXPATHLEN); - showMessage (TEXT_INFO, "%s\n%s", cwd, contents[menuLevel.selected].filename.c_str()); - } - - delete [] cwd; - - clearMessage (); - clearFolderBackground(); - showCursor (false); - showScrollbar (false); - subText->clearText (); - - return filename; -} - - -#ifdef DEMO -struct DEMO_STUFF -{ - const char name[40]; - int icon; -}; - -void UserInterface::demo (void) -{ - const DEMO_STUFF demoMenu[] = { - {"Track Hacks (WiFi)", BUTTON_BG_FOLDER}, - {"Shy Guy Codes", BUTTON_BG_FOLDER}, - {"Press Y for safe DC", BUTTON_BG_ON}, - {"Speed Codes", BUTTON_BG_FOLDER}, - {"WiFi Win Loss Modifier", BUTTON_BG_FOLDER}, - {"Item Codes: Always have...", BUTTON_BG_FOLDER}, - {"ALWAYS USE CART", BUTTON_BG_FOLDER}, - {"Always Play as CHARACTER", BUTTON_BG_FOLDER}, - {"CRAZY SOUNDS", BUTTON_BG_OFF}, - {"Always Play on an UNTEXTURED track", BUTTON_BG_OFF} - }; - - int menuLength; - - menuLength = sizeof(demoMenu) / sizeof (DEMO_STUFF); - - subText->clearText(0, 0, MENU_LAST_ROW, MENU_LAST_COL); - - showScrollbar(true); - showCursor (true); - for (int col = 0; col < GO_BUTTON_WIDTH; col++) { - for (int row = 0; row < GO_BUTTON_HEIGHT; row++) { - putGuiTile (GO_BUTTON_OFFSET + col + row * GO_BUTTON_WIDTH, row + GO_BUTTON_ROW, col + GO_BUTTON_COL, GO_BUTTON_PALETTE, false); - } - } - - setCursorPosition ((MENU_FIRST_ROW + menuLength - menuLevel.top - 1) * TOUCH_GRID_SIZE); - setScrollbarPosition (menuLength - 1, menuLength - 1); - showMessage (TEXT_TITLE, "Mario Kart DS (USA)"); - - for (int curItem = 0; curItem < menuLength; curItem++) { subText->putText (demoMenu[curItem].name, (MENU_FIRST_ROW + curItem) * 2, - MENU_FIRST_COL, (MENU_FIRST_ROW + curItem) * 2, MENU_LAST_COL, (MENU_FIRST_ROW + curItem) * 2, MENU_FIRST_COL); - - putButtonBg ((BUTTON_BG_OFFSETS)demoMenu[curItem].icon, (MENU_FIRST_ROW + curItem) * 2); - - showMessage (demoMenu[curItem].name); - } -} -#endif - -// Sprite -int Sprite::getSpriteNum (void) -{ - static int nextNum = 0; - return nextNum++; -} - -void Sprite::init (void) -{ - for (int i = 0; i < 128; i++) { - OAM_SUB[i*4] = (2<<8); - } -} - -Sprite::Sprite (int width, int height, const u16* spriteData, const u16* paletteData) -{ - u16 size_attrib; - u16 shape_attrib; - - int spriteDataOffset; - - num = getSpriteNum(); - - spriteDataOffset = num * 64; // Assume 64 tiles per sprite - - for (int i = 0; i < PALETTE_SIZE; i++) { - SPRITE_PALETTE_SUB[PALETTE_SIZE * num + i] = paletteData[i] | 0x8000; - } - vramcpy (SPRITE_GFX_SUB + TILE_SIZE / sizeof(u16) * spriteDataOffset, spriteData, 64 * TILE_SIZE); // 64 tiles per sprite - - if (width == height) { - shape_attrib = ATTR0_SQUARE; - if (width >= 64) { - size_attrib = ATTR1_SIZE_64; - } else if (width >= 32) { - size_attrib = ATTR1_SIZE_32; - } else if (width >= 16) { - size_attrib = ATTR1_SIZE_16; - } else { - size_attrib = ATTR1_SIZE_8; - } - } else if (width > height) { - shape_attrib = ATTR0_WIDE; - if (width >= 64) { - size_attrib = ATTR1_SIZE_64; - } else if ((width >= 32) && (height >= 16)) { - size_attrib = ATTR1_SIZE_32; - } else if (width >= 32) { - size_attrib = ATTR1_SIZE_16; - } else { - size_attrib = ATTR1_SIZE_8; - } - } else { - shape_attrib = ATTR0_TALL; - if (height >= 64) { - size_attrib = ATTR1_SIZE_64; - } else if ((height >= 32) && (width >= 16)) { - size_attrib = ATTR1_SIZE_32; - } else if (height >= 32) { - size_attrib = ATTR1_SIZE_16; - } else { - size_attrib = ATTR1_SIZE_8; - } - } - - attrib0 = ATTR0_NORMAL | ATTR0_TYPE_NORMAL | ATTR0_COLOR_16 | shape_attrib; - attrib1 = size_attrib; - attrib2 = spriteDataOffset | ATTR2_PALETTE(num); - - showSprite (false); - setPosition(0,0); -} - -void Sprite::showSprite (bool visible) -{ - this->visible = visible; - attrib0 = (attrib0 & ~(3<<8)) | (visible ? 0 : (2<<8)); - updateAttribs(); -} - -void Sprite::setPosition (int top, int left) -{ - this->top = top; - this->left = left; - updateAttribs(); -} - -void Sprite::updateAttribs (void) -{ - OAM_SUB[num*4 + 0] = attrib0 | (top & 0xFF); - OAM_SUB[num*4 + 1] = attrib1 | (left & 0x1FF); - OAM_SUB[num*4 + 2] = attrib2; -} diff --git a/arm9/source/ui.h b/arm9/source/ui.h deleted file mode 100755 index 5e688ff..0000000 --- a/arm9/source/ui.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - NitroHax -- Cheat tool for the Nintendo DS - Copyright (C) 2008 Michael "Chishm" Chisholm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include -#include -#include "cheat.h" -#include "consoletext.h" - -//#define DEMO - -class Sprite; - - -class UserInterface -{ -public: - UserInterface (void); - ~UserInterface (); - - struct FileInfo { - std::string filename; - bool isDirectory; - }; - - - enum TEXT_TYPE {TEXT_TITLE, TEXT_INFO}; - - void showMessage (TEXT_TYPE textType, const char* str, ...); - void showMessage (const char* str, ...); - void clearMessage (TEXT_TYPE textType); - void clearMessage (void); - - void cheatMenu (CheatFolder* gameCodes) { - cheatMenu (gameCodes, NULL); - } - void cheatMenu (CheatFolder* gameCodes, CheatFolder* top); - - std::string fileBrowser (const char* extension); - -#ifdef DEMO - void demo (void) ; -#endif - -private: - static const int FONT_PALETTE = 1; - - static const int BUTTON_PALETTE_ON = 4; - static const int BUTTON_PALETTE_OFF = 5; - static const int BUTTON_PALETTE_FILE = 6; - static const int BUTTON_PALETTE_FOLDER = 7; - enum BUTTON_BG_OFFSETS {BUTTON_BG_OFFSET = 16, BUTTON_BG_FOLDER = BUTTON_BG_OFFSET + 0, - BUTTON_BG_ON = BUTTON_BG_OFFSET + 60, BUTTON_BG_OFF = BUTTON_BG_OFFSET + 120, - BUTTON_BG_FILE = BUTTON_BG_OFFSET + 180, BUTTON_BG_NONE = 0}; - - enum MENU_CONTROLS {MENU_END1 = 0, MENU_END2 = 1, MENU_BACK = 5, MENU_TICK1 = 9, MENU_TICK2 = 10, - MENU_CROSS1 = 14, MENU_CROSS2 = 15}; - - static const int SCROLLBAR_PALETTE = 2; - enum SCROLLBAR_OFFSETS {SCROLLBAR_OFFSET = 4, SCROLLBAR_UP = SCROLLBAR_OFFSET + 0, SCROLLBAR_BAR = SCROLLBAR_OFFSET + 4, - SCROLLBAR_DOWN = SCROLLBAR_OFFSET + 8, SCROLLBAR_BOX = SCROLLBAR_OFFSET + 12}; - - static const int TEXTBOX_PALETTE = 3; - enum TEXTBOX_OFFSETS {TEXTBOX_OFFSET = 1, TEXTBOX_NW = TEXTBOX_OFFSET + 0, TEXTBOX_N = TEXTBOX_OFFSET + 1, - TEXTBOX_NE = TEXTBOX_OFFSET + 2, TEXTBOX_W = TEXTBOX_OFFSET + 3, TEXTBOX_C = TEXTBOX_OFFSET + 4, - TEXTBOX_E = TEXTBOX_OFFSET + 5, TEXTBOX_SW = TEXTBOX_OFFSET + 6, TEXTBOX_S = TEXTBOX_OFFSET + 7, - TEXTBOX_SE = TEXTBOX_OFFSET + 8}; - - static const int GO_BUTTON_PALETTE = 8; - static const int GO_BUTTON_OFFSET = 256; - static const int BLANK_TILE = 0; - - static const int NUM_CURSORS = 4; - - // Console elements - ConsoleText* topText; - u16* textboxMap; - ConsoleText* subText; - - // GUI elements - Sprite* scrollbox; - Sprite* cursor[NUM_CURSORS]; - u16* guiSubMap; - int scrollboxPosition; - - // Menu elements - struct MENU_LEVEL { - int top; - int selected; - int bottom; - }; - - MENU_LEVEL menuLevel; - - void writeTextBox (TEXT_TYPE textType, const char* str, va_list args); - void drawBox (int startRow, int startCol, int endRow, int endCol); - void clearBox (void); - void clearBox (int startRow, int startCol, int endRow, int endCol); - static void wordWrap (char* str, int height, int width); - - void showCheatFolder (std::vector &contents); - - std::vector getDirContents (const char* extension); - static bool fileInfoPredicate (const FileInfo& lhs, const FileInfo& rhs); - void showFileFolder (std::vector &contents); - - int menuInput(bool enableGoButton); - - void putGuiTile (int val, int row, int col, int palette, bool doubleSize); - void clearFolderBackground(void); - void showCursor (bool visible); - void setCursorPosition (int offset); - void putButtonBg (BUTTON_BG_OFFSETS buttonBg, int position); void showScrollbar (bool visisble); - void setScrollbarPosition (int offset, int listLength); - void showGoButton (bool visible, int left, int top); -} ; - -class Sprite -{ -public: - Sprite (int width, int height, const u16* spriteData, const u16* paletteData); - - void showSprite (bool visible); - void setPosition (int left, int top); - -public: - static void init (void); - -private: - int top; - int left; - int num; - u16 attrib0, attrib1, attrib2; - bool visible; - - void updateAttribs (void); - -private: - static int getSpriteNum (void); -} ; - -extern UserInterface ui; - diff --git a/ds_arm7_ram.ld b/ds_arm7_ram.ld new file mode 100644 index 0000000..216ff0e --- /dev/null +++ b/ds_arm7_ram.ld @@ -0,0 +1,176 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) + +MEMORY { + rom : ORIGIN = 0x08000000, LENGTH = 32M + ram : ORIGIN = 0x2380000, LENGTH = 96K + iwram : ORIGIN = 0x037f8000, LENGTH = 96K +} + +__iwram_start = ORIGIN(iwram); +__iwram_top = ORIGIN(iwram)+ LENGTH(iwram); + +__sp_irq = __iwram_top - 0x100; +__sp_svc = __sp_irq - 0x100; +__sp_usr = __sp_svc - 0x100; + +__irq_flags = 0x04000000 - 8; +__irq_flagsaux = 0x04000000 - 0x40; +__irq_vector = 0x04000000 - 4; + +SECTIONS +{ + .init : + { + __text_start = . ; + KEEP (*(.init)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + .plt : { *(.plt) } >ram = 0xff + + .text : /* ALIGN (4): */ + { + *(.text .stub .text.* .gnu.linkonce.t.*) + KEEP (*(.text.*personality*)) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .fini : + { + KEEP (*(.fini)) + } >ram =0xff + + __text_end = . ; + + .rodata : + { + *(.rodata) + *all.rodata*(*) + *(.roda) + *(.rodata.*) + *(.gnu.linkonce.r*) + SORT(CONSTRUCTORS) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ram + __exidx_start = .; + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ram + __exidx_end = .; + +/* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(32 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { KEEP (*(.preinit_array)) } >ram = 0xff + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { KEEP (*(.init_array)) } >ram = 0xff + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { KEEP (*(.fini_array)) } >ram = 0xff + PROVIDE (__fini_array_end = .); + + .ctors : + { + /* gcc uses crtbegin.o to find the start of the constructors, so + we make sure it is first. Because this is a wildcard, it + doesn't matter if the user does not actually link against + crtbegin.o; the linker won't look for a file to match a + wildcard. The wildcard also means that it doesn't matter which + directory crtbegin.o is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .eh_frame : + { + KEEP (*(.eh_frame)) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + + .gcc_except_table : + { + *(.gcc_except_table) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + } >ram = 0xff + .jcr : { KEEP (*(.jcr)) } >ram = 0 + .got : { *(.got.plt) *(.got) } >ram = 0 + + .data ALIGN(4) : { + __data_start = ABSOLUTE(.); + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + CONSTRUCTORS + . = ALIGN(4); + __data_end = ABSOLUTE(.) ; + } >ram = 0xff + + .bss ALIGN(4) : + { + __bss_start = ABSOLUTE(.); + __bss_start__ = ABSOLUTE(.); + *(.dynbss) + *(.gnu.linkonce.b*) + *(.bss*) + *(COMMON) + . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ + __bss_end__ = ABSOLUTE(.); + __end__ = ABSOLUTE(.); + } >ram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .stack 0x80000 : { _stack = .; *(.stack) } + /* These must appear regardless of . */ +} diff --git a/ds_arm7_ram.specs b/ds_arm7_ram.specs new file mode 100644 index 0000000..205a47a --- /dev/null +++ b/ds_arm7_ram.specs @@ -0,0 +1,8 @@ +%rename link old_link + +*link: +%(old_link) -T ../../ds_arm7_ram.ld%s --gc-sections + +*startfile: +ds_arm7_crt0%O%s crti%O%s crtbegin%O%s + diff --git a/icon.bmp b/icon.bmp index 092f8cb..92e2a86 100755 Binary files a/icon.bmp and b/icon.bmp differ diff --git a/make_cia.exe b/make_cia.exe new file mode 100644 index 0000000..2e445ff Binary files /dev/null and b/make_cia.exe differ diff --git a/nds/ntr_launcher.ini b/nds/ntr_launcher.ini new file mode 100644 index 0000000..969caa8 --- /dev/null +++ b/nds/ntr_launcher.ini @@ -0,0 +1,6 @@ +[NTRLAUNCHER_ALT] +DISABLEANIMATION = 0 +NTRCLOCK = 1 +ENABLESD = 0 +TWLMODE = 0 +RESETSLOT1 = 0 \ No newline at end of file diff --git a/patch_ndsheader_dsiware.py b/patch_ndsheader_dsiware.py new file mode 100644 index 0000000..d53fae9 --- /dev/null +++ b/patch_ndsheader_dsiware.py @@ -0,0 +1,554 @@ +# -*- coding: utf8 -*- +# Patch an .nds (works with homebrew and ds demo only) to make it ready for make_cia +# +# 2016-02-28, Ahezard +# +# inspired by +# Apache Thunder .nds edited files and comments +# https://github.com/Relys/Project_CTR/blob/master/makerom/srl.h +# https://dsibrew.org/wiki/DSi_Cartridge_Header +# if the header size of the input nds file is 0x200 (homebrew) +# the header size of the output nds file will be patched to 0x4000 (normal ds/dsi header), 0x3E00 offset + +from struct import * +from collections import namedtuple +from collections import OrderedDict +from pprint import pprint +import os, sys +import binascii +import argparse + + +parser = argparse.ArgumentParser(description='Patch an nds in order to be ready cia conversion via make_cia --srl=.') +parser.add_argument('file', metavar='file.nds', type=file, help='nds file to patch') +parser.add_argument('--verbose', help='verbose mode', action="store_true") +parser.add_argument('--out', help='output file [optionnal]') +parser.add_argument('--read', help='print only the header content, do not patch', action="store_true") +parser.add_argument('--extract', help='extract the content of the rom : header.bin,arm9.bin,arm7.bin,icon.bin,arm9i.bin,arm7i.bin, do not patch', action="store_true") #Not yet implemented +parser.add_argument('--title', help='Game title') +parser.add_argument('--code', help='Game code') +parser.add_argument('--maker', help='Maker code') +parser.add_argument('--mode', help='target mode, default mode is ds [ds|dsi|dsinogba]') +parser.add_argument('--arm7', type=file, help='swap the ds arm7 binary by the one provided') +parser.add_argument('--arm7EntryAddress', help='arm7 ram address of the binary provided') +parser.add_argument('--arm9i', type=file, help='add a dsi arm9i binary to the file, not needed for homebrew so far') +parser.add_argument('--arm7i', type=file, help='add a dsi arm7i binary to the file, not needed for homebrew so far') +parser.add_argument('--digest-block', type=file, help='dsi digest block table') #Not yet implemented +parser.add_argument('--digest-sector', type=file, help='dsi digest sector table') #Not yet implemented +args = parser.parse_args() + +if args.mode is None: + args.mode = "ds" + +# +# CRC16 MODULE +# +# includes CRC16 and CRC16 MODBUS +# + +from ctypes import c_ushort + +# from https://github.com/cristianav/PyCRC/blob/master/demo.py +class CRC16(object): + crc16_tab = [] + + # The CRC's are computed using polynomials. Here is the most used + # coefficient for CRC16 + crc16_constant = 0xA001 # 40961 + + def __init__(self, modbus_flag=False): + # initialize the precalculated tables + if not len(self.crc16_tab): + self.init_crc16() + self.mdflag = bool(modbus_flag) + + def calculate(self, input_data=None): + try: + is_string = isinstance(input_data, str) + is_bytes = isinstance(input_data, (bytes, bytearray)) + + if not is_string and not is_bytes: + raise Exception("Please provide a string or a byte sequence " + "as argument for calculation.") + + crc_value = 0x0000 if not self.mdflag else 0xffff + + for c in input_data: + d = ord(c) if is_string else c + tmp = crc_value ^ d + rotated = crc_value >> 8 + crc_value = rotated ^ self.crc16_tab[(tmp & 0x00ff)] + + return crc_value + except Exception as e: + print("EXCEPTION(calculate): {}".format(e)) + + def init_crc16(self): + """The algorithm uses tables with precalculated values""" + for i in range(0, 256): + crc = c_ushort(i).value + for j in range(0, 8): + if crc & 0x0001: + crc = c_ushort(crc >> 1).value ^ self.crc16_constant + else: + crc = c_ushort(crc >> 1).value + self.crc16_tab.append(crc) + +def getSize(fileobject): + current = fileobject.tell() + fileobject.seek(0,2) # move the cursor to the end of the file + size = fileobject.tell() + fileobject.seek(current,0) + return size + +def skipUntilAddress(f_in,f_out, caddr, taddr): + chunk = f_in.read(taddr-caddr) + f_out.write(chunk) + +def writeBlankuntilAddress(f_out, caddr, taddr): + f_out.write("\x00"*(taddr-caddr)) + +fname=args.file.name +args.file.close() + +if not args.read: + print "Patching file : "+fname +else: + print "Reading header of file : "+fname + +#offset of 0x4600 created + +# File size compute +file = open(fname, 'rb') +fsize=getSize(file) +file.close() + +#CRC header compute "CRC-16 (Modbus)" +file = open(fname, 'rb') +#0x15E from https://github.com/devkitPro/ndstool/ ... source/header.cpp +hdr = file.read(0x15E) +hdrCrc=CRC16(modbus_flag=True).calculate(hdr) +if args.verbose: + print("{:10s} {:20X}".format('HDR CRC-16 ModBus', hdrCrc)) +#print "origin header cr c"+hdr[0x15E:0x15F] +#filew = open(fname+".hdr", "wb") +#filew.write(hdr); +#filew.close() +file.close() + +if args.arm7 is not None: + arm7Fname=args.arm7.name + args.arm7.close() + arm7File = open(arm7Fname, 'rb') + arm7FileSize=getSize(arm7File) + dataArm7=arm7File.read(arm7FileSize) + arm7File.close() + +filer = open(fname, 'rb') +data = filer.read(0x180) +caddr=0x180 + +#DS Data 180 bytes +SrlHeader = namedtuple('SrlHeader', + "gameTitle " + "gameCode " + "makerCode " + "unitCode " + "encryptionSeedSelect " + "deviceCapacity " + "reserved0 " + "dsiflags " + "romVersion " + "internalFlag " + "arm9RomOffset " + "arm9EntryAddress " + "arm9RamAddress " + "arm9Size " + "arm7RomOffset " + "arm7EntryAddress " + "arm7RamAddress " + "arm7Size " + "fntOffset " + "fntSize " + "fatOffset " + "fatSize " + "arm9OverlayOffset " + "arm9OverlaySize " + "arm7OverlayOffset " + "arm7OverlaySize " + "normalCardControlRegSettings " + "secureCardControlRegSettings " + "icon_bannerOffset " + "secureAreaCrc " + "secure_transfer_timeout " + "arm9Autoload " + "arm7Autoload " + "secureDisable " + "ntrRomSize " + "headerSize " + "reserved1 " + "nintendoLogo " + "nintendoLogoCrc " + "headerCrc " + "debugReserved ") +srlHeaderFormat='<12s4s2scbb7s2sbcIIIIIIIIIIIIIIIIIIIHHII8sII56s156s2sH32s' +srlHeader=SrlHeader._make(unpack_from(srlHeaderFormat, data)) +if args.verbose: + print "origin header crc "+hex(srlHeader.headerCrc) + print "origin secure crc "+hex(srlHeader.secureAreaCrc) + +#SecureArea CRC compute "CRC-16 (Modbus)" +file = open(fname, 'rb') +#0x15E from https://github.com/devkitPro/ndstool/ ... source/header.cpp +file.read(0x200) +sec = file.read(0x4000) +secCrc=CRC16(modbus_flag=True).calculate(sec) +if args.verbose: + print("{:10s} {:20X}".format('SEC CRC-16 ModBus', secCrc)) +file.close() + +if srlHeader.arm7EntryAddress>0x2400000 and not args.read and args.arm7 is None: + print "WARNING: .nds arm7EntryAddress greater than 0x2400000 will not boot as cia" + print "you need to recompile or swap the arm7 binary with a precompiled one with --arm7 and --arm7EntryAddress" + +# Fix srlHeader +srlHeaderPatched=srlHeader._replace( + secureCardControlRegSettings= 1575160, + normalCardControlRegSettings= 5791744, + internalFlag= '\x00', + arm9RomOffset= srlHeader.arm9RomOffset+0x3E00, + arm7RomOffset= srlHeader.arm7RomOffset+0x3E00, + fntOffset= srlHeader.fntOffset+0x4640, + fatOffset= srlHeader.fatOffset+0x444C, + icon_bannerOffset= srlHeader.icon_bannerOffset+0x3E00-0x200, + ntrRomSize= srlHeader.ntrRomSize+0x3E00-0x200, + headerSize= 0x4000, + nintendoLogo= "$\xff\xaeQi\x9a\xa2!=\x84\x82\n\x84\xe4\t\xad\x11$\x8b\x98\xc0\x81\x7f!\xa3R\xbe\x19\x93\t\xce \x10FJJ\xf8'1\xecX\xc7\xe83\x82\xe3\xce\xbf\x85\xf4\xdf\x94\xceK\t\xc1\x94V\x8a\xc0\x13r\xa7\xfc\x9f\x84Ms\xa3\xca\x9aaX\x97\xa3'\xfc\x03\x98v#\x1d\xc7a\x03\x04\xaeV\xbf8\x84\x00@\xa7\x0e\xfd\xffR\xfe\x03o\x950\xf1\x97\xfb\xc0\x85`\xd6\x80%\xa9c\xbe\x03\x01N8\xe2\xf9\xa24\xff\xbb>\x03Dx\x00\x90\xcb\x88\x11:\x94e\xc0|c\x87\xf0<\xaf\xd6%\xe4\x8b8\n\xacr!\xd4\xf8\x07", + nintendoLogoCrc= 'V\xcf', + secureAreaCrc= secCrc, + reserved1= '\x00'*156, + # better to recompile or swap the arm7 binary if this is needed + #arm7EntryAddress= 0x2380000, + #arm7RamAddress= 0x2380000, + #arm7Autoload= 0x2380118, + #arm9EntryAddress= 0x2000000, + #arm9RamAddress= 0x2000000, + #arm9Autoload= 0x2000A60, + ) + +if args.arm7 is not None: + if args.arm7EntryAddress is None: + print "WARNING : you may need to provide the ARM7 binary entry address via --arm7EntryAddress, default value 0x2380000 used" + args.arm7EntryAddress="0x2380000" + + srlHeaderPatched=srlHeaderPatched._replace( + arm7RamAddress= int(args.arm7EntryAddress, 0), + arm7EntryAddress= int(args.arm7EntryAddress, 0), + arm7Size= arm7FileSize, + ntrRomSize= srlHeaderPatched.ntrRomSize-srlHeader.arm7Size+arm7FileSize, + fntOffset= srlHeaderPatched.fntOffset-srlHeader.arm7Size+arm7FileSize, + fatOffset= srlHeaderPatched.fatOffset-srlHeader.arm7Size+arm7FileSize, + icon_bannerOffset= srlHeaderPatched.icon_bannerOffset-srlHeader.arm7Size+arm7FileSize, + deviceCapacity= srlHeader.deviceCapacity+1 + ) + +if "dsi" in args.mode : + srlHeaderPatched=srlHeaderPatched._replace( + deviceCapacity= srlHeaderPatched.deviceCapacity+2, + dsiflags= '\x01\x00', #disable modcrypt but enable twl + unitCode= '\x03', + #arm7Autoload= 0, + #arm9Autoload= 0, + ) + +if args.title is not None: + srlHeaderPatched=srlHeaderPatched._replace(gameTitle=args.title) +if args.code is not None: + srlHeaderPatched=srlHeaderPatched._replace(gameCode=args.code) +if args.maker is not None: + srlHeaderPatched=srlHeaderPatched._replace(makerCode=args.maker) + +data1=pack(*[srlHeaderFormat]+srlHeaderPatched._asdict().values()) +newHdrCrc=CRC16(modbus_flag=True).calculate(data1[0:0x15E]) +srlHeaderPatched=srlHeaderPatched._replace(headerCrc=newHdrCrc) + +if args.verbose: + print "new header crc "+hex(newHdrCrc) +if not args.read : + if args.verbose: + pprint(dict(srlHeaderPatched._asdict())) +else: + pprint(dict(srlHeader._asdict())) + +data1=pack(*[srlHeaderFormat]+srlHeaderPatched._asdict().values()) + +arm9isize=0 +arm7isize=0 + +#TWL Only Data 384 bytes +SrlTwlExtHeader = namedtuple('SrlTwlExtHeader', + "MBK_1_5_Settings " + "MBK_6_8_Settings_ARM9 " + "MBK_6_8_Settings_ARM7 " + "global_MBK_9_Setting " + "regionFlags " + "accessControl " + "arm7ScfgExtMask " + "reserved_flags " + "arm9iRomOffset " + "reserved2 " + "arm9iLoadAddress " + "arm9iSize " + "arm7iRomOffset " + "struct_param_baseAddress " + "arm7iLoadAddress " + "arm7iSize " + "digest_ntrRegionOffset " + "digest_ntrRegionSize " + "digest_twlRegionOffset " + "digest_twlRegionSize " + "digestSectorHashtableOffset " + "digestSectorHashtableSize " + "digest_blockHashtableOffset " + "digest_blockHashtableSize " + "digestSectorSize " + "digest_blockSectorcount " + "iconSize " #usually 0x23C0 or 2112 in homebrew + "unknown1 " + "twlRomSize " + "unknown2 " + "modcryptArea1Offset " + "modcryptArea1Size " + "modcryptArea2Offset " + "modcryptArea2Size " + "title_id " + "pubSaveDataSize " + "privSaveDataSize " + "reserved4 " + "parentalControl ") +srlTwlExtHeaderFormat="<20s12s12s4s4sIIII4sIIIIIIIIIIIIIIIII4sI12sIIII8sII176s16s" +if srlHeader.headerSize<0x300: + #homebrew + srlTwlExtHeader=SrlTwlExtHeader._make(unpack_from(srlTwlExtHeaderFormat, "\x00" * (0x300-0x180))) +else: + data = filer.read(0x300-0x180) + srlTwlExtHeader=SrlTwlExtHeader._make(unpack_from(srlTwlExtHeaderFormat, data)) + caddr=0x300 + +#pprint(dict(srlTwlExtHeader._asdict())) + +if not args.read: + # Fix srlTwlExtHeader + srlTwlExtHeader=srlTwlExtHeader._replace( + title_id= srlHeaderPatched.gameCode[::-1]+"\x04\x00\x03\x00", + regionFlags= '\xff\xff\xff\xff', + iconSize= 2112, + unknown1= '\x00\x00\x01\x00', + reserved_flags= 0x01000000 + ) + if "dsi" in args.mode: + arm7iRomOffset=srlHeaderPatched.arm7RomOffset + arm9iRomOffset=srlHeaderPatched.arm9RomOffset + arm7isize=srlHeaderPatched.arm7Size + arm9isize=srlHeaderPatched.arm9Size + totaldsisize=0 + arm7iname = None + arm9iname = None + + if args.arm9i is not None: + arm9iname = args.arm9i.name + arm9isize = getSize(args.arm9i) + arm9iRomOffset=srlHeaderPatched.ntrRomSize + if args.verbose: + print "arm9isize : "+hex(arm9isize) + print "arm9ioffset : "+hex(srlHeaderPatched.ntrRomSize) + args.arm9i.close() + totaldsisize=arm9isize + + if args.arm7i is not None: + arm7iname = args.arm7i.name + arm7isize = getSize(args.arm7i) + arm7iRomOffset=srlHeaderPatched.ntrRomSize+arm9isize + if args.verbose: + print "arm7isize : "+hex(arm7isize) + print "arm9ioffset : "+hex(srlHeaderPatched.ntrRomSize+arm9isize) + args.arm7i.close() + totaldsisize=arm9isize+arm7isize + + srlTwlExtHeader=srlTwlExtHeader._replace( + MBK_1_5_Settings= '\x81\x85\x89\x8d\x80\x84\x88\x8c\x90\x94\x98\x9c\x80\x84\x88\x8c\x90\x94\x98\x9c', + MBK_6_8_Settings_ARM7= '\xc07\x00\x08@7\xc0\x07\x007@\x07', + MBK_6_8_Settings_ARM9= '\x00\x00\x00\x00@7\xc0\x07\x007@\x07', + accessControl= 0x00000038, + arm7ScfgExtMask= 0x80040000, + reserved_flags= 0x00000000, + arm7iLoadAddress= 0x2E80000, + arm7iRomOffset= arm7iRomOffset, + arm7iSize= arm7isize, + arm9iLoadAddress= 0x2400000, + arm9iRomOffset= arm9iRomOffset, + arm9iSize= arm9isize, + global_MBK_9_Setting= '\x0f\x00\x00\x03', + iconSize= 2112, + pubSaveDataSize= 00000, + regionFlags= '\xff\xff\xff\xff', + title_id= srlHeaderPatched.gameCode[::-1]+"\x04\x00\x03\x00", + twlRomSize= srlHeaderPatched.ntrRomSize+totaldsisize, + unknown1= '\x00\x00\x01\x00', + unknown2= '\x00\x00\x00\x00|\x0f\x00\x00 \x05\x00\x00', + parentalControl= '\x80'*16 + ) + + if "dsinogba" in args.mode : + # Fix for no$gba 2.8d + srlTwlExtHeader=srlTwlExtHeader._replace( + arm7iLoadAddress= srlHeaderPatched.arm7EntryAddress, + arm9iLoadAddress= srlHeaderPatched.arm9EntryAddress + ) + +if args.verbose or args.read: + pprint(dict(srlTwlExtHeader._asdict())) + +data2=pack(*[srlTwlExtHeaderFormat]+srlTwlExtHeader._asdict().values()) + +#TWL and Signed NTR 3328 bytes +SrlSignedHeader = namedtuple('SrlSignedHeader', + "arm9WithSecAreaSha1Hmac " + "arm7Sha1Hmac " + "digestMasterSha1Hmac " + "bannerSha1Hmac " + "arm9iSha1Hmac " + "arm7iSha1Hmac " + "reserved5 " + "arm9Sha1Hmac " + "reserved6 " + "reserved7 " + "signature " + ) +srlSignedHeaderFormat="<20s20s20s20s20s20s40s20s2636s384s128s" +if srlHeader.headerSize<0x1100: + #homebrew + srlSignedHeader=SrlSignedHeader._make(unpack_from(srlSignedHeaderFormat, "\x00" * (3328))) +else: + data = filer.read(3328) + srlSignedHeader=SrlSignedHeader._make(unpack_from(srlSignedHeaderFormat, data)) + caddr=0x300+3328 + +#pprint(dict(srlSignedHeader._asdict())) + +# Fix srlSignedHeader +if not args.read: + srlSignedHeader=srlSignedHeader._replace( + arm7Sha1Hmac= '\xff'*20, + arm9WithSecAreaSha1Hmac= '\xff'*20, + bannerSha1Hmac= '\xff'*20, + signature= '\xff'*128 + ) + if "dsi" in args.mode : + srlSignedHeader=srlSignedHeader._replace( + arm7Sha1Hmac= '\xff'*20, + arm7iSha1Hmac= '\xff'*20, + arm9Sha1Hmac= '\xff'*20, + arm9WithSecAreaSha1Hmac= '\xff'*20, + arm9iSha1Hmac= '\xff'*20, + bannerSha1Hmac= '\xff'*20, + digestMasterSha1Hmac= '\xff'*20, + signature= '\xff'*128 + ) +if args.verbose or args.read: + pprint(dict(srlSignedHeader._asdict())) + +data3=pack(*[srlSignedHeaderFormat]+srlSignedHeader._asdict().values()) + +# ARM9 footer +# from https://github.com/devkitPro/ndstool/ ... source/header.cpp +# ARM9 footer size = 3*4 +ARM9Footer = namedtuple('ARM9Footer', + "nitrocode " #0xDEC00621 + "versionInfo " + "reserved " + ) +ARM9FooterFormat="