-
Notifications
You must be signed in to change notification settings - Fork 2
/
Naomi_O_to_NL_Convert.bms
233 lines (145 loc) · 4.78 KB
/
Naomi_O_to_NL_Convert.bms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#-----------------------------------------------
#
# Naomi Model SDK to .bin
# By VincentNL 13/05/2022
#
#-----------------------------------------------
get name basename
String name P "%name%.bin"
savepos startpos = 0x0
math remove_start = 0x0
get size asize
set memory_file ""
set memory_file2 ""
#-----------------------------------------------
# clean header garbage before model data
#-----------------------------------------------
findloc model_start binary "\x5E\x1C\xFD\x80\x00\x00\x00\x00\xF4" 0 ""
math model_start += 0x9
#print "start of model at: %model_start|x%"
math startpos = model_start
goto startpos
#-----------------------------------------------
# 1st Clean Loop
#-----------------------------------------------
for i
findloc test_offset binary "\x80\x00" 0 ""
print "Found at %test_offset|x%"
if test_offset != "" # if found
goto test_offset
get junk short
get test_2 byte
if test_2 <= 2
xmath test_f4 "test_offset+0x5"
goto test_f4
get byteval byte
# print "F4 test: %byteval|x%"
if byteval = 0xf4 || byteval = 0x04 || byteval = 0xb0 || byteval = 0xc4 || byteval = 0x88 || byteval = 0x34 || byteval = 0x28 || byteval = 0xd8
Math clean_flag = 1
elif byteval = 0x0c || byteval = 0xec || byteval = 0x3c || byteval = 0x1c || byteval = 0x08 || byteval = 0x58
Math clean_flag = 1
endif
if clean_flag = 1
#print "F4 test: %byteval|x%"
#-----------------------------------------------
# logs from past address until start of garbage
#-----------------------------------------------
xmath garbage_start "test_offset-0x3"
xmath logsize "garbage_start-startpos"
append
log memory_file startpos logsize
append
savepos startpos
endif
Math clean_flag = 0
endif
else
xmath rest_of_file "size-startpos"
append
log MEMORY_FILE startpos rest_of_file
append
break
endif
next i
goto 0x0 -1
savepos startpos -1
get size asize -1
#-----------------------------------------------
# 2nd Clean Loop
#-----------------------------------------------
for j
findloc test_offset binary "\x9A\x07\x00\x00\x00\x00" -1 ""
#print "loop2 string found at %test_offset|x%"
if test_offset != "" # if found
#-----------------------------------------------
# logs from past address until start of garbage
#-----------------------------------------------
xmath garbage_start "test_offset-0x1"
xmath garbage_end "test_offset+0x6"
xmath logsize "garbage_start-startpos"
append
log memory_file2 startpos logsize -1
append
goto garbage_end -1
savepos startpos -1
else
xmath rest_of_file "(size-0x4)-startpos"
append
log MEMORY_FILE2 startpos rest_of_file -1
append
get memsize asize -2
log MEMORY_FILE 0 memsize -2
break
endif
next j
set memory_file2 ""
goto 0x0 -1
savepos startpos -1
get size asize -1
#-----------------------------------------------
# 3rd Clean Loop
#-----------------------------------------------
for k
findloc test_offset binary "\x18\x08\x10\x08\x08\x08\x00\x08" -1 ""
#print "loop2 string found at %test_offset|x%"
if test_offset != "" # if found
# xmath test_3 "test_offset-0x6"
# goto test_3 -1
# get test3 long -1
# if test3 = 0x34FF
#
# print "test3: %test3|x%"
#
# xmath garbage_start "test_offset-0x5"
#
# else
#
# xmath garbage_start "test_offset-0x8"
#
# endif
#-----------------------------------------------
# logs from past address until start of garbage
#-----------------------------------------------
xmath garbage_start "test_offset-0x8"
xmath garbage_end "test_offset+0xD"
xmath logsize "garbage_start-startpos"
print "garbage_start:%garbage_start|x%,garbage_end:%garbage_end|x%"
append
log memory_file2 startpos logsize -1
append
goto garbage_end -1
savepos startpos -1
else
xmath rest_of_file "(size-0x4)-startpos"
if rest_of_file < 0
print "negative!!!!"
xmath rest_of_file "size-startpos"
endif
append
log MEMORY_FILE2 startpos rest_of_file -1
append
get memsize asize -2
log name 0 memsize -2
break
endif
next k