-
Notifications
You must be signed in to change notification settings - Fork 2
/
BUILD.asm
622 lines (483 loc) · 11 KB
/
BUILD.asm
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
.n64
//.open "ROM\amp2.z64", "ROM\BASE.z64", 0
.open "ROM\stock.z64", "ROM\BASE.z64", 0
.definelabel PAYLOAD_ROM, 0x00C00000
.definelabel PAYLOAD_RAM, 0x80400000
.definelabel DMA_FUNC, 0x80001158
.definelabel RAM_END, org(EndRAMData)
.definelabel DMA_MAX_LENGTH, org(EndRAMData) - org(StartRAMData)
.definelabel Printf, 0x800D6420
.definelabel ok_ModelDataRawSize, filesize("data\ModelData\ModelData.raw")
.definelabel itemChanceHi, hi(org(ok_ItemTable))
.definelabel itemChanceLo, lo(org(ok_ItemTable))
.definelabel OKBuild, 0
.include "..\library\GameVariables\NTSC\GameOffsets.asm"
.include "..\library\GameVariables\NTSC\StatsOffsets.asm"
.include "..\library\OKHeader.asm"
.include "..\library\GameVariables\NTSC\OKAssembly.asm"
.include "data\ModelData\ModelData.asm"
.org 0xBFFFFC
.word 0xF00000
.org 0x113FBA
.halfword 0x8080
.org 0x113FCE
.byte 0x00
.if OKBuild
//fix the flip and stop that shit
.org 0x095C64
NOP
//Remove the default Title Screen Image
.org 0x09F8C4
NOP
.endif
.org 0x079290
J SnowHook
NOP
.org 0x0FBA68
J DisplayMap2Hook
NOP
//add XLU to RGBA32
.org 0x047350
.word 0x273979E8
.org 0x0473C4
.word 0x273979E8
//fix kwtexture2D_rgba32_bl
.org 0x0473F0
.word 0x0C011869
//Change kwtexture2d to use loadtile
.org 0x463E0
.word 0x0C010F0A
.org 0x123B0C
JAL MapStartup
.org 0x0036F4
JAL MapStartup
.org 0x12506C
JAL MapStartup
.org 0x0036FC
JAL InitialMapCode
.org 0x0051E8
JAL DisplayCrashScreen
.org 0x5200
NOP
.org 0x5240
NOP
.org 0x111D4C
LB t2, -1(v0)
// fixes Alpha loading for level data vert color
.org 0x10C7E2
.halfword hi(DisplayHopTable)
.org 0x10C7EA
.halfword lo(DisplayHopTable)
.org 0x10C7D6
.halfword(100)
//Kart Collision Wrappers
.org 0x02BF48
JAL BombThrowRolloverWrap
.org 0x02BF6C
JAL RolloverWrap
.org 0x02BF90
JAL WheelspinWrap
.org 0x02C044
JAL BrokenWrap
.org 0x02C068
JAL ThunderWrap
.org 0x02C08C
JAL SpinWrap
.org 0x02C0B0
JAL BombRolloverWrap
.org 0x02C0D4
JAL BombThrowRolloverWrap
.org 0x02C184
JAL ProWheelSpinWrap
.org 0x02C1A4
JAL BombRolloverWrap
.org 0x10CB44
J FreeDraw
//PlayStarMusicHook
.org 0x90420
JAL PlayStarMusicHook
//StopStarMusicHook
.org 0x904B4
JAL StopStarMusicHook
.org 0x902D8
JAL StopStarMusicHook
//PlayFinalLapMusicHook
.org 0xF8954
JAL PlayFinalLapMusicHook
.org 0x109AAA
.halfword hi(CollisionHopTable)
.org 0x109AB2
.halfword lo(CollisionHopTable)
.org 0x109A92
.halfword(100)
//original hook placement
.org 0x34BC //RAM address 0x800028BC
J GlobalCustomCode
NOP
//EventDisplay Hooks
.org 0x058EB4
JAL EventDisplay
.org 0x058F7C
JAL EventDisplay
.org 0x059044
JAL EventDisplay
.org 0x059120
JAL EventDisplay
//EventDisplay_After Hooks
.org 0x0592E4
JAL EventDisplay_After
.org 0x05938C
JAL EventDisplay_After
.org 0x059434
JAL EventDisplay_After
.org 0x0594DC
JAL EventDisplay_After
//CommonGameEvent Hooks
.org 0x05AA18
JAL CommonGameEventChart
.org 0x05AAA8
JAL CommonGameEventChart
.org 0x05AB38
JAL CommonGameEventChart
.org 0x05AC50
JAL CommonGameEventChart
.org 0x05AD08
JAL CommonGameEventChart
//title screen hook
.org 0x957D0 //RAM address 0x80094BD0
J CustomCodeTitleScreen
NOP
.org 0x2B30
J PrintMenuHook
NOP
//1p
.org 0x2214
J race1P
NOP
//2p
.org 0x269C
J race2P
NOP
.org 0x24F4
J race2PLR
NOP
//mp
.org 0x28F8
J raceMP
NOP
.org 0x17EC //RAM address 0x80000BEC
LUI a0, 0x8040 //RAM address
LUI a1, hi(PAYLOAD_ROM)
ADDIU a1, a1, lo(PAYLOAD_ROM) //DMA from ROM address 0x00C00000
LUI a2, hi(DMA_MAX_LENGTH)
JAL DMA_FUNC
ADDIU a2, lo(DMA_MAX_LENGTH)
J OriginalBootFunction
NOP
.headersize PAYLOAD_RAM - PAYLOAD_ROM
.org PAYLOAD_RAM
StartRAMData:
.align 0x10
bannerN:
.import "data\\banner_n.mio0.bin" ;; 324
.align 0x10
bannerU:
.import "data\\banner_U.mio0.bin" ;; 311
.align 0x10
set0:
.import "data\\Stock.png.MIO0" ;; 87c
.align 0x10
set0end:
.align 0x10
set1:
.import "data\\Set1.png.MIO0" ;; 7f5
.align 0x10
set1end:
.align 0x10
set2:
.import "data\\Set2.png.MIO0" ;; 7fc
.align 0x10
set2end:
.align 0x10
set3:
.import "data\\Set3.png.MIO0" ;; 808
.align 0x10
set3end:
.align 0x10
set4:
.import "data\\Set4.png.MIO0" ;; 800
.align 0x10
set4end:
.align 0x10
OriginalBootFunction: //we overwrite this when DMAing our code
//therefore, make sure it gets ran or the game wont boot
LUI T6, 0x8030
LUI AT, 0x1FFF
ORI AT, AT, 0xFFFF
ADDIU t6, t6, 0x9F80
AND t7, t6, at
LUI at, 0x8015
J 0x800012AC //jump back to where execution should be on boot
SW t7, 0x02B4 (at)
.align 0x10
CustomCodeTitleScreen:
ADDIU sp, sp, -0x20
SW ra, 0x001C (sp)
JAL 0x80095574 //run what we overwrote with our hook
NOP
JAL titleMenu
NOP
LW ra, 0x001C (sp)
ADDIU sp, sp, 0x20
J 0x80094BD8 //jump back to where we were
NOP
NOP
.align 0x10
GlobalCustomCode:
ADDIU sp, sp, -0x20
SW ra, 0x001C (sp) //push ra to the stack
NOP
JAL allRun
NOP
LW ra, 0x001C (sp) //pop ra from the stack
ADDIU sp, sp, 0x20
J 0x8000286C //tells the game where to jump back to, dont remove
NOP
.align 0x10
race1P:
ADDIU sp, sp, -0x20
SW ra, 0x001C (sp) //push ra to the stack
NOP
JAL gameCode
NOP
LW ra, 0x001C (sp) //pop ra from the stack
ADDIU sp, sp, 0x20
LUI a0, 0x800E
LHU a0, 0xC520 (a0)
LUI a1, 0x800E
J 0x8000161C
NOP
.align 0x10
race2P:
ADDIU sp, sp, -0x20
SW ra, 0x001C (sp) //push ra to the stack
NOP
JAL gameCode
NOP
LW ra, 0x001C (sp) //pop ra from the stack
ADDIU sp, sp, 0x20
LUI t3, 0x800E
LW t3, 0xC5E8 (t3)
J 0x80001AA4
NOP
.align 0x10
race2PLR:
ADDIU sp, sp, -0x20
SW ra, 0x001C (sp) //push ra to the stack
NOP
JAL gameCode
NOP
LW ra, 0x001C (sp) //pop ra from the stack
ADDIU sp, sp, 0x20
LUI t3, 0x800E
LW t3, 0xC5E8 (t3)
J 0x800018FC
NOP
.align 0x10
raceMP:
ADDIU sp, sp, -0x20
SW ra, 0x001C (sp) //push ra to the stack
NOP
JAL gameCode
NOP
LW ra, 0x001C (sp) //pop ra from the stack
ADDIU sp, sp, 0x20
LUI v0, 0x800E
LW v0, 0xC5E8 (v0)
J 0x80001D00
NOP
.align 0x10
PrintMenuHook:
LW ra, 0x14 (sp)
SW ra, 0x1C (sp)
JAL PrintMenuFunction
NOP
J 0x80001F64
LW ra, 0x001C(sp)
.align 0x10
SnowHook:
LW a0, 0x40(sp)
ADDIU sp, sp, -0x20
SW ra, 0x001C (sp) //push ra to the stack
JAL SnowCustomCheck
NOP
LW ra, 0x001C (sp) //pop ra from the stack
ADDIU sp, sp, 0x20
J 0x800786B8
NOP
.align 0x10
DisplayMap2Hook:
SW ra, 0x001C(sp)
LW a0, 0x270(sp)
JAL XLUDisplay
NOP
LW ra, 0x001C(sp)
addiu sp, sp, 0x270
JR ra
NOP
.include "..\Library\LIBRARYBUILD.asm"
.align 0x10
.importobj "OverKartVariables.o"
.align 0x10
.importobj "MarioKartAI.o"
.align 0x10
.importobj "OKMenu.o"
.align 0x10
.importobj "Protec.o"
.align 0x10
.importobj "MarioKartPractice.o"
.align 0x10
.importobj "OKGameTypes.o"
.align 0x10
.importobj "LitroFunc.o"
.align 0x10
.importobj "OverKart.o"
.align 0x10
.importobj "OverKartObjectHandler.o"
.align 0x10
DisplayHop:
MOVE $a0, $s1
JAL DisplayObject
MOVE $a1, $s0
J 0x802A34D4
NOP
.align 0x10
FreeDraw:
JAL DrawPerScreen
NOP
LW ra, 0x24 (sp)
LW s0, 0x18 (sp)
LW s1, 0x1C (sp)
LW s2, 0x20 (sp)
JR ra
ADDIU sp, sp, 0x98
.align 0x10
CollisionHop:
LW $t4, 0xbc($a3)
MOVE $a0, $a3
LW $ra, 0x1c($sp)
JAL CollideObject
MOVE $a1, $s0
J 0x802A0D44
LW $ra, 0x1c($sp)
.align 0x10
DisplayHopTable:
.word 0x802A31E4, 0x802A31FC, 0x802A3214, 0x802A32EC
.word 0x802A3318, 0x802A3330, 0x802A3348, 0x802A34C0
.word 0x802A3378, 0x802A34D4, 0x802A34D4, 0x802A34D4
.word 0x802A34D4, 0x802A3390, 0x802A33A4, 0x802A33B8
.word 0x802A33CC, 0x802A322C, 0x802A33E4, 0x802A34D4 //19
.word 0x802A34D4, 0x802A33FC, 0x802A34D4, 0x802A3428 //23
.word 0x802A3244, 0x802A34D4, 0x802A325C, 0x802A328C //27
.word 0x802A32A4, 0x802A32BC, 0x802A32D4, 0x802A3274 //31
.word 0x802A34D4, 0x802A3414, 0x802A34D4, 0x802A345C //35
.word 0x802A3440, 0x802A34AC, 0x802A3470, 0x802A3484 //39
.word 0x802A3360, 0x802A34D4, 0x802A3498, 0x802A3300 //43
.word 0x802A33E4, DisplayHop, DisplayHop, DisplayHop //47
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //51
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //55
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //59
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //63
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //67
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //71
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //75
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //79
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4
.word 0x802A33E4, 0x802A33E4, 0x802A33E4, 0x802A33E4 //99
.align 0x10
CollisionHopTable:
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09D4
.word 0x802A04E0, 0x802A063C, 0x802A0858, 0x802A04AC //7
.word 0x802A0968, 0x802A0D40, 0x802A0CBC, 0x802A0AA4
.word 0x802A0D40, 0x802A0D40, 0x802A0D40, 0x802A0D40
.word 0x802A0D40, 0x802A09B0, 0x802A0D40, 0x802A0D40 //19
.word 0x802A0D40, 0x802A098C, 0x802A0D40, 0x802A09B0
.word 0x802A09B0, 0x802A0D40, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A0D40, 0x802A0D40, 0x802A0D40, 0x802A0D40
.word 0x802A0D40, 0x802A0D40, 0x802A0D40, 0x802A0D40 //39
.word 0x802A0744, 0x802A0C34, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, CollisionHop, CollisionHop, CollisionHop
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0 //59
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0 //79
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0
.word 0x802A09B0, 0x802A09B0, 0x802A09B0, 0x802A09B0 //99
EndRAMData:
.headersize 0
Splash3D:
.import "data\\SplashLogo\\model\\SplashLogo.bin"
.align 0x10
Splash3DEnd:
BackDrop:
.import "data\\SplashLogo\\backdrop.bin"
.align 0x10
BackDropEnd:
previewN:
.import "textures\\preview_n.mio0.bin" ;; c10
.align 0x10
previewU:
.import "textures\\preview_U.mio0.bin" ;; c64
.align 0x10
LogoROM:
.import "data\\ModelData\\Logo\\Logo.bin" ;; 0xD388
.align 0x10
BackgroundLogo:
.import "data\\SplashLogo\\BackgroundSource.bin"
.align 0x10
BackgroundEnd:
StartLogo:
.import "data\\SplashLogo\\PressStart.bin"
.align 0x10
StartEnd:
Pirate:
.import "Data\test\Pirate512.MIO0"
.align 0x10
PirateEnd:
Crash:
.import "Data\test\Crash512.bin"
.align 0x10
CrashEnd:
ModelDataStart:
.import "data\\ModelData\\ModelData.bin"
.align 0x10
ModelDataEnd:
RCSpriteROM:
.import "data\\RedCoinSprite16.png.MIO0" ;; 0x4F0
.align 0x10
ArrowsSpriteROM:
.import "data\\arrows.png.MIO0" ;; 0x1000
.align 0x10
NumbersSpriteROM:
.import "data\\number_sprites.png.MIO0" ;; 0x1600
.align 0x10
JP_Bank:
.import "data\\JP_Bank.bin"
.align 0x10
JP_Audio:
.import "data\\JP_Audio.bin"
.align 0x10
.org 0xEFFFFC
.word 0xFFFFFFFF
.close