Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a797ff

Browse files
committed
Initial commit
0 parents  commit 8a797ff

16 files changed

Lines changed: 1199 additions & 0 deletions

.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Object Files
2+
*.o
3+
*.ko
4+
*.obj
5+
*.elf
6+
7+
# Precompiled Headers
8+
*.gch
9+
*.pch
10+
11+
# Libraries
12+
*.lib
13+
*.a
14+
*.la
15+
*.lo
16+
17+
# Shared objects (inc. Windows DLLs)
18+
*.dll
19+
*.so
20+
*.so.*
21+
*.dylib
22+
23+
# Executables
24+
*.exe
25+
*.out
26+
*.app
27+
*.i*86
28+
*.x86_64
29+
*.hex
30+
31+
# Raw files
32+
*.bin
33+
*.raw
34+
35+
# ROMS
36+
*.gba
37+
*.nds
38+
39+
# Generated files
40+
*.lsc
41+
makefile
42+
toolchain
43+
devkitARM
44+
45+
# Emulator crap
46+
*.exe
47+
*.sav
48+
*.ini

18506.png

46.1 KB
Loading

BPRE.sym

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
getPkmStat = 0x201CD25;
2+
setPkmStat = 0x201CD49;
3+
4+
loadMessageBox = 0x080F6EE5;
5+
fdecoder = 0x08008FCD;
6+
box_related_one = 0x080F6CD1;
7+
check_a_pressed = 0x08002E65;
8+
rboxid_to_vram = 0x08003F21;
9+
fadescreen = 0x08070589;
10+
11+
malloc_and_LZ77UnComp = 0x080F6AA1;
12+
gpu_copy_to_tileset = 0x080017D1;
13+
gpu_copy_tilemap = 0x08002041;
14+
bgid_send_tilemap = 0x080020BD;
15+
gpu_sync_bg_show = 0x080019BD;
16+
song_play_for_text = 0x080722A1;
17+
18+
19+
LZ77UnCompVram = 0x081E3B6D;
20+
21+
gpu_pal_apply = 0x080703ED;
22+
23+
malloc_and_clear = 0x08002BB1;
24+
free = 0x08002BC4;
25+
26+
bgid_fill_rectangle = 0x08002555;
27+
28+
29+
textbox_close = 0x080694F5;

bg.png

281 Bytes
Loading

bootstrap.s

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.align 2
2+
.thumb
3+
4+
@ Force the correct method to be loaded.
5+
@ This s file should appear first in the list of targets
6+
@ Long call method, compiled C gets huge pretty quickly
7+
8+
ldr r1, .callbacks
9+
bx r1
10+
11+
.align 2
12+
.callbacks: .word callback

configure.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/python3
2+
3+
import os
4+
5+
def linker_script(offset):
6+
out = """OUTPUT_ARCH(arm)
7+
MEMORY {{
8+
9+
rom : ORIGIN = 0x{:08X}, LENGTH = 32M
10+
ewram : ORIGIN = 0x02000000, LENGTH = 4M - 4k
11+
}}
12+
13+
SECTIONS {{
14+
.text : {{
15+
16+
FILL (0xABCD)
17+
18+
__text_start = . ;
19+
*(.init)
20+
*(.text)
21+
*(.ctors)
22+
*(.dtors)
23+
*(.rodata)
24+
*(.fini)
25+
*(COMMON)
26+
__text_end = . ;
27+
28+
__bss_start__ = . ;
29+
*(.bss)
30+
__bss_end__ = . ;
31+
_end = __bss_end__ ;
32+
__end__ = __bss_end__ ;
33+
}} >rom = 0xff
34+
}}
35+
""".format(offset)
36+
37+
return out
38+
39+
def target(path):
40+
base, ext = os.path.splitext(path.strip())
41+
42+
# TODO: Ensure target name is unique
43+
target_name = base
44+
45+
46+
47+
if ext in ['.s', '.asm']:
48+
target_name += '.o'
49+
output = '{}: {}\n\t'.format(target_name, path.strip())
50+
output += '$(AS) $(AFLAGS) -c {} -o {}'.format(path.strip(), target_name)
51+
elif ext in ['.c']:
52+
target_name += '.o'
53+
output = '{}: {}\n\t'.format(target_name, path.strip())
54+
output += '$(CC) $(CFLAGS) -c {}'.format(path)
55+
elif ext in ['.cc', '.cpp', '.cxx']:
56+
target_name += '.o'
57+
output = '{}: {}\n\t'.format(target_name, path.strip())
58+
output += '$(CXX) $(CXXFLAGS) -c {}'.format(path)
59+
elif ext in ['.csv']:
60+
# String
61+
target_name += '.h'
62+
output = '{}: {}\n\t'.format(target_name, path.strip())
63+
output += 'python3 poke2c.py {}'.format(path)
64+
else:
65+
raise ValueError(path, ext)
66+
67+
output += '\n'
68+
69+
return target_name, output
70+
71+
def makefile(toolchain, rom_path, offset=0x800000):
72+
with open('targets') as file:
73+
lines = [line.strip() for line in file]
74+
targets = dict(target(line) for line in lines)
75+
order = [target(line)[0] for line in lines]
76+
77+
with open('linker.lsc', 'w') as file:
78+
file.write(linker_script(0x8000000 + offset))
79+
80+
with open(rom_path, 'rb') as file:
81+
file.seek(0xAC)
82+
gamecode = file.read(4).decode()
83+
file.seek(0xBC)
84+
version = int(file.read(1)[0])
85+
86+
target_strings = ' '.join(item for item in order if os.path.splitext(item)[1] == '.o')
87+
target_strings_all = ' '.join(order)
88+
89+
output = """
90+
all: {targets_all}
91+
\t$(LD) $(LDFLAGS) -o a.o -T {linker_script} -T {symbols} {targets}
92+
\t$(OBJCOPY) -O binary a.o a.bin
93+
94+
""".format(targets=target_strings, targets_all=target_strings_all, linker_script='linker.lsc', symbols=gamecode + '.sym')
95+
96+
defines = """CC={toolchain[cc]}
97+
CXX={toolchain[cxx]}
98+
AS={toolchain[as]}
99+
LD={toolchain[ld]}
100+
OBJCOPY={toolchain[objcopy]}
101+
OBJDUMP={toolchain[objdump]}
102+
XXD=xxd
103+
IMG=todo
104+
COMPRESS=toolchain/gbalzss
105+
PADBIN=toolchain/padbin
106+
107+
OPTS=-fauto-inc-dec -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdse -fguess-branch-probability -fif-conversion2 -fif-conversion -fipa-pure-const -fipa-profile -fipa-reference -fmerge-constants -fsplit-wide-types -ftree-bit-ccp -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop -ftree-sra -ftree-pta -ftree-ter -funit-at-a-time -fomit-frame-pointer -fthread-jumps -falign-functions -falign-jumps -falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fdelete-null-pointer-checks -fdevirtualize -fexpensive-optimizations -fgcse -fgcse-lm -finline-small-functions -findirect-inlining -fipa-sra -foptimize-sibling-calls -fpartial-inlining -fpeephole2 -fregmove -freorder-blocks -freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec -fschedule-insns -fschedule-insns2 -fstrict-aliasing -fstrict-overflow -ftree-switch-conversion -ftree-tail-merge -ftree-pre -ftree-vrp -finline-functions -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-slp-vectorize -fvect-cost-model -fipa-cp-clone -ffast-math -fforward-propagate -finline-functions-called-once -fmerge-all-constants -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-sm -fgcse-las -funsafe-loop-optimizations -fconserve-stack
108+
DEFINES=-D{gamecode} -DSOFTWARE_VERSION={version}
109+
CFLAGS=-mthumb -mthumb-interwork -mcpu=arm7tdmi $(OPTS) -mlong-calls -march=armv4t -Wall -O3 $(DEFINES)
110+
CXXFLAGS=-mthumb -mthumb-interwork -mcpu=arm7tdmi $(OPTS) -mlong-calls -march=armv4t -Wall -O3 $(DEFINES)
111+
ASFLAGS=-mthumb
112+
LDFLAGS=
113+
""".format(toolchain=toolchain, gamecode=gamecode, version=version)
114+
body = '\n'.join(targets.values())
115+
116+
clean = """
117+
clean:
118+
\trm -rf {targets} a.o a.bin
119+
""".format(targets=target_strings_all)
120+
121+
insert = """
122+
insert:
123+
\tdd conv=notrunc of={rom} if={bin} bs=1 seek={offset}
124+
""".format(offset=offset, rom=rom_path, bin='a.bin')
125+
126+
with open('makefile', 'w') as file:
127+
print(defines + output + body + clean + insert, file=file)
128+
129+
toolchain = {
130+
'cc': 'arm-linux-gnueabi-gcc-4.7',
131+
'cxx': 'arm-linux-gnueabi-gcc-4.7',
132+
'as': 'arm-linux-gnueabi-as',
133+
'ld': 'arm-linux-gnueabi-ld',
134+
'objcopy': 'arm-linux-gnueabi-objcopy',
135+
'objdump': 'arm-linux-gnueabi-objcopy'
136+
}
137+
makefile(toolchain, 'test.gba')
138+

graphics/intro_bg_palette.act

768 Bytes
Binary file not shown.

graphics/intro_bg_tileset.bmp

278 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)