up to date repo

This commit is contained in:
ProjectRevoTPP 2020-04-12 16:15:06 -04:00
parent 7e14113e47
commit 41fa994a86
13 changed files with 273 additions and 26 deletions

9
.gitignore vendored
View File

@ -1,3 +1,12 @@
# Object files
*.nds
# Compilers
tools/mwccarm/**
# Build folder
build/**
# CLion folders
.idea/
cmake-build-debug/

View File

@ -12,7 +12,7 @@ TARGET := pokediamond.us
ROM := $(BUILD_DIR)/$(TARGET).nds
ELF := $(BUILD_DIR)/$(TARGET).elf
LD_SCRIPT := pokediamond.lcf
LD_SCRIPT := ld_script.txt
# Directories containing source files
SRC_DIRS := src
@ -31,20 +31,17 @@ MWCCVERSION := 2.0/base
CROSS := arm-linux-gnueabi-
# TODO: Replace mwldarm with gnu ld
MWLDARM := ./tools/mwccarm/$(MWCCVERSION)/mwldarm.exe
MWCCARM := ./tools/mwccarm/$(MWCCVERSION)/mwccarm.exe
MWCCARM := tools/mwccarm/2.0/base/mwccarm.exe
AS := $(CROSS)as
CC := $(MWCCARM)
CPP := cpp -P
LD := $(MWLDARM)
LD := $(CROSS)ld
AR := $(CROSS)ar
OBJDUMP := $(CROSS)objdump
OBJCOPY := $(CROSS)objcopy
CFLAGS = -c -O4,p -proc arm946e -thumb -fp soft -lang c -Cpp_exceptions off
CFLAGS = -O4,p -proc arm946e -thumb -fp soft -lang c -Cpp_exceptions off
####################### Other Tools #########################
@ -62,11 +59,14 @@ clean:
ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))
$(BUILD_DIR)/%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
$(ELF): $(O_FILES) $(LD_SCRIPT)
$(MWLDARM) -LC:/pokediamond/$(BUILD_DIR)/asm/ $(O_FILES) $(LD_SCRIPT) -o $@ -nodead
$(ELF): $(O_FILES) $(LD_SCRIPT) undefined_syms.txt
$(LD) -T undefined_syms.txt -T $(LD_SCRIPT) -o $(ELF)
$(ROM): $(ELF)
$(OBJCOPY) -O binary $< $@

1
asm/macros.inc Normal file
View File

@ -0,0 +1 @@
.include "asm/macros/function.inc"

29
asm/macros/function.inc Normal file
View File

@ -0,0 +1,29 @@
.macro arm_func_start name
.align 2, 0
.global \name
.arm
.type \name, function
.endm
.macro arm_func_end name
.size \name, .-\name
.endm
.macro thumb_func_start name
.align 2, 0
.global \name
.thumb
.thumb_func
.type \name, function
.endm
.macro non_word_aligned_thumb_func_start name
.global \name
.thumb
.thumb_func
.type \name, function
.endm
.macro thumb_func_end name
.size \name, .-\name
.endm

172
asm/main.s Normal file
View File

@ -0,0 +1,172 @@
.include "asm/macros.inc"
.text
arm_func_start Main
Main: @ 0x02000800
mov ip, #0x4000000
str ip, [ip, #0x208]
_02000808:
ldrh r0, [ip, #6]
cmp r0, #0
bne _02000808
bl sub_02000A78
mov r0, #0x13
msr cpsr_c, r0
ldr r0, _02000918 @ =0x027E0000
add r0, r0, #0x3fc0
mov sp, r0
mov r0, #0x12
msr cpsr_c, r0
ldr r0, _02000918 @ =0x027E0000
add r0, r0, #0x3fc0
sub r0, r0, #0x40
sub sp, r0, #4
tst sp, #4
subeq sp, sp, #4
ldr r1, _0200091C @ =0x00000400
sub r1, r0, r1
mov r0, #0x1f
msr cpsr_fsxc, r0
sub sp, r1, #4
mov r0, #0
ldr r1, _02000918 @ =0x027E0000
mov r2, #0x4000
bl _0200093C
_02000870:
.byte 0x00, 0x00, 0xA0, 0xE3, 0xA4, 0x10, 0x9F, 0xE5, 0x01, 0x2B, 0xA0, 0xE3, 0x2E, 0x00, 0x00, 0xEB
.byte 0x02, 0x0C, 0xA0, 0xE3, 0x98, 0x10, 0x9F, 0xE5, 0x01, 0x2B, 0xA0, 0xE3, 0x2A, 0x00, 0x00, 0xEB
.byte 0x90, 0x10, 0x9F, 0xE5, 0x14, 0x00, 0x91, 0xE5, 0x2C, 0x00, 0x00, 0xEB, 0x56, 0x00, 0x00, 0xEB
.byte 0x80, 0x00, 0x9F, 0xE5, 0x0C, 0x10, 0x90, 0xE5, 0x10, 0x20, 0x90, 0xE5, 0x01, 0x30, 0xA0, 0xE1
.byte 0x00, 0x00, 0xA0, 0xE3, 0x02, 0x00, 0x51, 0xE1, 0x04, 0x00, 0x81, 0x34, 0xFC, 0xFF, 0xFF, 0x3A
.byte 0x1F, 0x10, 0xC3, 0xE3, 0x9A, 0x0F, 0x07, 0xEE, 0x35, 0x1F, 0x07, 0xEE, 0x3E, 0x1F, 0x07, 0xEE
.byte 0x20, 0x10, 0x81, 0xE2, 0x02, 0x00, 0x51, 0xE1, 0xF9, 0xFF, 0xFF, 0xBA, 0x48, 0x10, 0x9F, 0xE5
.byte 0x00, 0x00, 0x81, 0xE5, 0x2C, 0x10, 0x9F, 0xE5, 0xFF, 0x1D, 0x81, 0xE2, 0x3C, 0x10, 0x81, 0xE2
.byte 0x38, 0x00, 0x9F, 0xE5, 0x00, 0x00, 0x81, 0xE5, 0x33, 0xAF, 0x03, 0xEB, 0x98, 0x00, 0x00, 0xEB
.byte 0x63, 0xAF, 0x03, 0xEB, 0x28, 0x10, 0x9F, 0xE5, 0x28, 0xE0, 0x9F, 0xE5, 0x04, 0x00, 0x1D, 0xE3
.byte 0x04, 0xD0, 0x4D, 0x12, 0x11, 0xFF, 0x2F, 0xE1
_02000918: .4byte 0x027E0000
_0200091C: .4byte 0x00000400
_02000920:
.byte 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x07, 0x68, 0x0B, 0x00, 0x02, 0x9C, 0xFF, 0x7F, 0x02
.byte 0x00, 0x80, 0xFF, 0x01, 0x55, 0x0C, 0x00, 0x02, 0x00, 0x00, 0xFF, 0xFF
_0200093C:
add ip, r1, r2
_02000940:
cmp r1, ip
stmlt r1!, {r0}
blt _02000940
bx lr
_02000950:
.byte 0x00, 0x00, 0x50, 0xE3, 0x27, 0x00, 0x00, 0x0A, 0xF0, 0x00, 0x2D, 0xE9, 0x06, 0x00, 0x10, 0xE9
.byte 0x02, 0x20, 0x80, 0xE0, 0x21, 0x3C, 0x40, 0xE0, 0xFF, 0x14, 0xC1, 0xE3, 0x01, 0x10, 0x40, 0xE0
.byte 0x02, 0x40, 0xA0, 0xE1, 0x01, 0x00, 0x53, 0xE1, 0x15, 0x00, 0x00, 0xDA, 0x01, 0x50, 0x73, 0xE5
.byte 0x08, 0x60, 0xA0, 0xE3, 0x01, 0x60, 0x56, 0xE2, 0xF9, 0xFF, 0xFF, 0xBA, 0x80, 0x00, 0x15, 0xE3
.byte 0x02, 0x00, 0x00, 0x1A, 0x01, 0x00, 0x73, 0xE5, 0x01, 0x00, 0x62, 0xE5, 0x09, 0x00, 0x00, 0xEA
.byte 0x01, 0xC0, 0x73, 0xE5, 0x01, 0x70, 0x73, 0xE5, 0x0C, 0x74, 0x87, 0xE1, 0x0F, 0x7A, 0xC7, 0xE3
.byte 0x02, 0x70, 0x87, 0xE2, 0x20, 0xC0, 0x8C, 0xE2, 0x07, 0x00, 0xD2, 0xE7, 0x01, 0x00, 0x62, 0xE5
.byte 0x10, 0xC0, 0x5C, 0xE2, 0xFB, 0xFF, 0xFF, 0xAA, 0x01, 0x00, 0x53, 0xE1, 0x85, 0x50, 0xA0, 0xE1
.byte 0xEB, 0xFF, 0xFF, 0xCA, 0x00, 0x00, 0xA0, 0xE3, 0x1F, 0x30, 0xC1, 0xE3, 0x9A, 0x0F, 0x07, 0xEE
.byte 0x35, 0x3F, 0x07, 0xEE, 0x3E, 0x3F, 0x07, 0xEE, 0x20, 0x30, 0x83, 0xE2, 0x04, 0x00, 0x53, 0xE1
.byte 0xF9, 0xFF, 0xFF, 0xBA, 0xF0, 0x00, 0xBD, 0xE8, 0x1E, 0xFF, 0x2F, 0xE1, 0x6C, 0x00, 0x9F, 0xE5
.byte 0x00, 0x10, 0x90, 0xE5, 0x04, 0x20, 0x90, 0xE5, 0x08, 0x30, 0x90, 0xE5, 0x02, 0x00, 0x51, 0xE1
.byte 0x15, 0x00, 0x00, 0x0A, 0x04, 0x50, 0x91, 0xE4, 0x04, 0x70, 0x91, 0xE4, 0x07, 0x60, 0x85, 0xE0
.byte 0x05, 0x40, 0xA0, 0xE1, 0x06, 0x00, 0x54, 0xE1, 0x04, 0x70, 0x93, 0x44, 0x04, 0x70, 0x84, 0x44
.byte 0xFB, 0xFF, 0xFF, 0x4A, 0x04, 0x70, 0x91, 0xE4, 0x07, 0x60, 0x84, 0xE0, 0x00, 0x70, 0xA0, 0xE3
.byte 0x06, 0x00, 0x54, 0xE1, 0x04, 0x70, 0x84, 0x34, 0xFC, 0xFF, 0xFF, 0x3A, 0x1F, 0x40, 0xC5, 0xE3
.byte 0x9A, 0x7F, 0x07, 0xEE, 0x35, 0x4F, 0x07, 0xEE, 0x3E, 0x4F, 0x07, 0xEE, 0x20, 0x40, 0x84, 0xE2
.byte 0x06, 0x00, 0x54, 0xE1, 0xF9, 0xFF, 0xFF, 0xBA, 0xE7, 0xFF, 0xFF, 0xEA, 0x00, 0x00, 0x00, 0xEA
.byte 0x68, 0x0B, 0x00, 0x02, 0x1E, 0xFF, 0x2F, 0xE1
arm_func_start sub_02000A78
sub_02000A78: @ 0x02000A78
mrc p15, #0, r0, c1, c0, #0
ldr r1, _02000B30 @ =0x000F9005
bic r0, r0, r1
mcr p15, #0, r0, c1, c0, #0
mov r0, #0
mcr p15, #0, r0, c7, c5, #0
mcr p15, #0, r0, c7, c6, #0
mcr p15, #0, r0, c7, c10, #4
ldr r0, _02000B34 @ =0x04000033
mcr p15, #0, r0, c6, c0, #0
ldr r0, _02000B38 @ =0x0200002D
mcr p15, #0, r0, c6, c1, #0
ldr r0, _02000B3C @ =0x027E0021
mcr p15, #0, r0, c6, c2, #0
ldr r0, _02000B40 @ =0x08000035
mcr p15, #0, r0, c6, c3, #0
ldr r0, _02000B44 @ =0x027E0000
orr r0, r0, #0x1a
orr r0, r0, #1
mcr p15, #0, r0, c6, c4, #0
ldr r0, _02000B48 @ =0x0100002F
mcr p15, #0, r0, c6, c5, #0
ldr r0, _02000B4C @ =0xFFFF001D
mcr p15, #0, r0, c6, c6, #0
ldr r0, _02000B50 @ =0x027FF017
mcr p15, #0, r0, c6, c7, #0
mov r0, #0x20
mcr p15, #0, r0, c9, c1, #1
ldr r0, _02000B44 @ =0x027E0000
orr r0, r0, #0xa
mcr p15, #0, r0, c9, c1, #0
mov r0, #0x42
mcr p15, #0, r0, c2, c0, #1
mov r0, #0x42
mcr p15, #0, r0, c2, c0, #0
mov r0, #2
mcr p15, #0, r0, c3, c0, #0
ldr r0, _02000B54 @ =0x05100011
mcr p15, #0, r0, c5, c0, #3
ldr r0, _02000B58 @ =0x15111011
mcr p15, #0, r0, c5, c0, #2
mrc p15, #0, r0, c1, c0, #0
ldr r1, _02000B5C @ =0x0005707D
orr r0, r0, r1
mcr p15, #0, r0, c1, c0, #0
bx lr
.align 2, 0
_02000B30: .4byte 0x000F9005
_02000B34: .4byte 0x04000033
_02000B38: .4byte 0x0200002D
_02000B3C: .4byte 0x027E0021
_02000B40: .4byte 0x08000035
_02000B44: .4byte 0x027E0000
_02000B48: .4byte 0x0100002F
_02000B4C: .4byte 0xFFFF001D
_02000B50: .4byte 0x027FF017
_02000B54: .4byte 0x05100011
_02000B58: .4byte 0x15111011
_02000B5C: .4byte 0x0005707D
arm_func_start sub_2000B60_dummy
sub_2000B60_dummy: @ 0x02000B60
bx lr
arm_func_start sub_2000B64_dummy
sub_2000B64_dummy: @ 0x02000B64
bx lr
_02000B68:
.word 0x02107700
.word 0x02107724
.word 0x02106FA0
.word 0x02106FA0
.word 0x021D74E0
.word 0x00000000
.byte 0x31, 0x75, 0x02, 0x03, 0x21, 0x06, 0xC0, 0xDE, 0xDE, 0xC0, 0x06, 0x21
# strings
.balign 4
.asciz "[SDK+NINTENDO:DWC1.2.30006.061019.2254_DWC_1_2_PLUS6]"
.balign 4
.asciz "[SDK+NINTENDO:WiFi1.2.30000.0609050341]"
.balign 4
.asciz "[SDK+UBIQUITOUS:CPS]"
.balign 4
.asciz "[SDK+UBIQUITOUS:SSL]"
.balign 4
.asciz "[SDK+Abiosso:libVCT 1.0.1_ec]"
.balign 4
.asciz "[SDK+NINTENDO:BACKUP]"

View File

@ -2,4 +2,4 @@
.section .text
.incbin "baserom.nds", 0x200, 0x3FFFE00
.incbin "baserom.nds", 0x4C54, 0x1A0

5
asm/rom2.s Normal file
View File

@ -0,0 +1,5 @@
/* rom.s TODO: Disassemble */
.section .text
.incbin "baserom.nds", 0x4E0C, 0x3FFB1F4

5
asm/secure.s Normal file
View File

@ -0,0 +1,5 @@
/* secure.s TODO: Disassemble */
.section .text
.incbin "baserom.nds", 0x4000, 0x800

16
ld_script.txt Normal file
View File

@ -0,0 +1,16 @@
SECTIONS {
header :
{
build/asm/rom_header.o(.text);
}
. = 0x4000;
rom_code :
{
build/asm/secure.o(.text);
build/asm/main.o(.text);
build/asm/rom.o(.text);
build/src/sub_02000DF4.o(.text);
build/asm/rom2.o(.text);
}
}

View File

@ -1,16 +0,0 @@
/* Linker Script for Pokemon Diamond */
MEMORY {
header (RWX) : ORIGIN=0, LENGTH=0
rom_main (RWX) : ORIGIN=512, LENGTH=0
}
SECTIONS {
.header:{
rom_header.o (.text)
} > header
.rom_main:{
rom.o (.text)
} > rom_main
}

1
pokediamond.us.sha1 Normal file
View File

@ -0,0 +1 @@
a46233d8b79a69ea87aa295a0efad5237d02841e build/pokediamond.us.nds

24
src/sub_02000DF4.c Normal file
View File

@ -0,0 +1,24 @@
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef signed char s8;
typedef signed short s16;
typedef signed long s32;
struct Unk2106FA0 {
u8 filler0[0x8];
s32 unk8;
s32 unkC;
s32 unk10;
s32 unk14;
};
extern struct Unk2106FA0 gUnknown2106FA0;
void sub_02000DF4(void)
{
gUnknown2106FA0.unk8 = -1;
gUnknown2106FA0.unkC = 0;
gUnknown2106FA0.unk10 = -1;
gUnknown2106FA0.unk14 = 0;
}

1
undefined_syms.txt Normal file
View File

@ -0,0 +1 @@
gUnknown2106FA0 = 0x2106FA0;