-
Notifications
You must be signed in to change notification settings - Fork 2
/
bios9.s
1294 lines (1248 loc) · 22.9 KB
/
bios9.s
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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.include "macros.inc"
.macro LD_DTCM_SYSRV reg
mrc p15, #0, \reg, c9, c1, #0
lsr \reg, \reg, #12
lsl \reg, \reg, #12
.endm
.macro LD_DTCM_SYSRV_TOP reg
LD_DTCM_SYSRV \reg
add \reg, \reg, #64, #24
.endm
.set HW_BIOS_EXCP_STACK_MAIN_END, 0x027FFD9C
.section .text
.syntax unified
.global _start
_start:
b __reset_handler @ Reset
b __reserved_vector @ Undefined instruction
b __svc_handler @ SWI
b __reserved_vector @ Prefetch Abort
b __reserved_vector @ Data Abort
b __reserved_vector @ Reserved
b __irq_handler @ IRQ
__reserved_vector:
b __fiq_handler @ FIQ
_0020:
.byte 0x24, 0xFF, 0xAE, 0x51, 0x69, 0x9A, 0xA2, 0x21, 0x3D, 0x84, 0x82, 0x0A, 0x84, 0xE4, 0x09, 0xAD
.byte 0x11, 0x24, 0x8B, 0x98, 0xC0, 0x81, 0x7F, 0x21, 0xA3, 0x52, 0xBE, 0x19, 0x93, 0x09, 0xCE, 0x20
.byte 0x10, 0x46, 0x4A, 0x4A, 0xF8, 0x27, 0x31, 0xEC, 0x58, 0xC7, 0xE8, 0x33, 0x82, 0xE3, 0xCE, 0xBF
.byte 0x85, 0xF4, 0xDF, 0x94, 0xCE, 0x4B, 0x09, 0xC1, 0x94, 0x56, 0x8A, 0xC0, 0x13, 0x72, 0xA7, 0xFC
.byte 0x9F, 0x84, 0x4D, 0x73, 0xA3, 0xCA, 0x9A, 0x61, 0x58, 0x97, 0xA3, 0x27, 0xFC, 0x03, 0x98, 0x76
.byte 0x23, 0x1D, 0xC7, 0x61, 0x03, 0x04, 0xAE, 0x56, 0xBF, 0x38, 0x84, 0x00, 0x40, 0xA7, 0x0E, 0xFD
.byte 0xFF, 0x52, 0xFE, 0x03, 0x6F, 0x95, 0x30, 0xF1, 0x97, 0xFB, 0xC0, 0x85, 0x60, 0xD6, 0x80, 0x25
.byte 0xA9, 0x63, 0xBE, 0x03, 0x01, 0x4E, 0x38, 0xE2, 0xF9, 0xA2, 0x34, 0xFF, 0xBB, 0x3E, 0x03, 0x44
.byte 0x78, 0x00, 0x90, 0xCB, 0x88, 0x11, 0x3A, 0x94, 0x65, 0xC0, 0x7C, 0x63, 0x87, 0xF0, 0x3C, 0xAF
.byte 0xD6, 0x25, 0xE4, 0x8B, 0x38, 0x0A, 0xAC, 0x72, 0x21, 0xD4, 0xF8, 0x07, 0x56, 0xCF, 0x00, 0x00
arm_func_start __fiq_handler
__fiq_handler:
mrs sp, apsr
orr sp, sp, #0xc0
msr cpsr_fsxc, sp
ldr sp, _02F8 @ =HW_BIOS_EXCP_STACK_MAIN_END
add sp, sp, #1
__fiq_internal:
push {r12, lr}
mrs lr, spsr
mrc p15, #0, r12, c1, c0, #0
push {r12, lr}
bic r12, r12, #1
mcr p15, #0, r12, c1, c0, #0
bic r12, sp, #1
ldr r12, [r12, #0x10]
cmp r12, #0
blxne r12
pop {r12, lr}
mcr p15, #0, r12, c1, c0, #0
msr spsr_fsxc, lr
pop {r12, lr}
subs pc, lr, #4
arm_func_end __fiq_handler
arm_func_start __reset_handler
__reset_handler:
cmp lr, #0
moveq lr, #4
mov r12, #64, #12
ldrb r12, [r12, #0x300]
teq r12, #1
mrseq r12, apsr
orreq r12, r12, #0xc0
msreq cpsr_fsxc, r12
ldreq sp, _02F8 @ =HW_BIOS_EXCP_STACK_MAIN_END
beq __fiq_internal
mov r4, #64, #12
mov r0, #0
mov r1, #0x80
str r0, [r4, #0x1a4]
str r1, [r4, #0x1a1]
mov r0, #0xdf
msr cpsr_fsxc, r0
mov r0, #128, #26
blx SVC_WaitByLoop
ldr r4, _037C @ =0x04000204
mov r1, #128, #26
strh r1, [r4]
mov r0, #128, #26
blx SVC_WaitByLoop
ldr r3, _0380 @ =0x027FFFFE
ldr r1, _0384 @ =0x0000FFDF
ldr r2, _0388 @ =0x0000E732
ldr r12, _038C @ =0x027E57FE
ldrh r0, [r3]
strh r0, [r3]
strh r0, [r3]
strh r1, [r3]
strh r2, [r3]
ldrh r0, [r12]
ldr r4, _037C @ =0x04000204
mov r1, #96, #24
strh r1, [r4]
bl sub_0790
mov r4, #64, #12
strb r4, [r4, #0x208]
bl sub_021C
ldr r0, _0390 @ =sub_03B6+1
blx r0
bl sub_01FC
mov r12, #160, #14
ldr lr, [r12, #-0x1dc]
sub r12, r12, #128, #28
ldrh r0, [r12, #0x2c]
cmp r0, #0
_01D4:
bne _01D4
ldr r12, [r12, #0x20]
cmp r12, #0
_01E0:
beq _01E0
bx r12
arm_func_end __reset_handler
arm_func_start SVC_SoftReset
SVC_SoftReset: @ 0xFFFF01E8
bl sub_01FC
mov r12, #160, #14
ldr lr, [r12, #-0x1dc]
mov r12, #0
bx lr
arm_func_end SVC_SoftReset
arm_func_start sub_01FC
sub_01FC: @ 0xFFFF01FC
mov r12, lr
mov r0, #0x1f
msr cpsr_fsxc, r0
ldr r0, _0394 @ =0x00012078
bl sub_0778
bl sub_021C
ldmdb r4, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11}
bx r12
arm_func_end sub_01FC
arm_func_start sub_021C
sub_021C: @ 0xFFFF021C
mov r0, #0xd3
msr cpsr_fsxc, r0
ldr sp, _02F4 @ =0x00803FC0
mov lr, #0
msr spsr_fsxc, lr
mov r0, #0xd2
msr cpsr_fsxc, r0
ldr sp, _02F0 @ =0x00803FA0
mov lr, #0
msr spsr_fsxc, lr
mov r0, #0x5f
msr cpsr_fsxc, r0
ldr sp, _02EC @ =0x00803EC0
@ Clear DTCM
LD_DTCM_SYSRV_TOP r4
adr r0, _0268+1
bx r0
.thumb
_0268:
movs r0, #0
ldr r1, _0398 @ =-0x200
_026C:
str r0, [r4, r1]
adds r1, #4
blt _026C
bx lr
arm_func_end sub_021C
arm_func_start __irq_handler
__irq_handler: @ 0xFFFF0274
push {r0, r1, r2, r3, r12, lr}
@ Call the interrupt vector from DTCM
LD_DTCM_SYSRV_TOP r0
adr lr, _0290
ldr pc, [r0, #-4]
_0290:
pop {r0, r1, r2, r3, r12, lr}
subs pc, lr, #4
arm_func_end __irq_handler
arm_func_start __svc_handler
__svc_handler: @ 0xFFFF0298
push {r11, r12, lr}
@ The interrupt number is always located
@ 2 bytes before the return address
ldrh r12, [lr, #-2]
and r12, r12, #0xff
adr r11, SVCTable
ldr r12, [r11, r12, lsl #2]
@ Store the system sp and switch to the svc stack
mrs r11, spsr
stmdb sp!, {r11}
and r11, r11, #0x80
orr r11, r11, #0x1f
msr cpsr_fsxc, r11
@ Call the requested svc
push {r2, lr}
blx r12
pop {r2, lr}
@ Restore the system stack
mov r12, #0xd3
msr cpsr_fsxc, r12
ldm sp!, {r11}
msr spsr_fsxc, r11
pop {r11, r12, lr}
movs pc, lr
arm_func_end __svc_handler
thumb_func_start SVC_CustomPost
SVC_CustomPost: @ 0xFFFF02E4
ldr r2, _039C @ =0x04000300
str r0, [r2]
bx lr
.align 2, 0
_02EC: .4byte 0x00803EC0
_02F0: .4byte 0x00803FA0
_02F4: .4byte 0x00803FC0
_02F8: .4byte HW_BIOS_EXCP_STACK_MAIN_END
SVCTable:
.4byte SVC_SoftReset @ 00
.4byte 0 @ 01
.4byte 0 @ 02
.4byte SVC_WaitByLoop+1 @ 03
.4byte SVC_IntrWait @ 04
.4byte SVC_VBlankIntrWait @ 05
.4byte SVC_Halt @ 06
.4byte 0 @ 07
.4byte 0 @ 08
.4byte SVC_Div @ 09
.4byte 0 @ 0A
.4byte SVC_CpuSet+1 @ 0B
.4byte SVC_CpuFastSet @ 0C
.4byte SVC_Sqrt @ 0D
.4byte SVC_GetCRC16+1 @ 0E
.4byte SVC_IsDebugger+1 @ 0F
.4byte SVC_BitUnPack @ 10
.4byte SVC_LZ77UnCompWRAM @ 11
.4byte SVC_LZ77UnCompVRAM+1 @ 12
.4byte SVC_HuffUnComp+1 @ 13
.4byte SVC_RLUnCompWRAM+1 @ 14
.4byte SVC_RLUnCompVRAM+1 @ 15
.4byte SVC_Diff8UnFilter+1 @ 16
.4byte 0 @ 17
.4byte SVC_Diff16UnFilter+1 @ 18
.4byte 0 @ 19
.4byte 0 @ 1A
.4byte 0 @ 1B
.4byte 0 @ 1C
.4byte 0 @ 1D
.4byte 0 @ 1E
.4byte SVC_CustomPost+1 @ 1F
_037C: .4byte 0x04000204
_0380: .4byte 0x027FFFFE
_0384: .4byte 0x0000FFDF
_0388: .4byte 0x0000E732
_038C: .4byte 0x027E57FE
_0390: .4byte sub_03B6+1
_0394: .4byte 0x00012078
_0398: .4byte -0x200
_039C: .4byte 0x04000300
thumb_func_end SVC_CustomPost
thumb_func_start sub_03A0
sub_03A0: @ 0xFFFF03A0
ldr r1, _0408 @ =0x04000180
lsls r0, r0, #8
strh r0, [r1]
bx lr
thumb_func_end sub_03A0
thumb_func_start sub_03A8
sub_03A8: @ 0xFFFF03A8
ldr r2, _0408 @ =0x04000180
_03AA:
ldrh r1, [r2]
lsls r1, r1, #0x1c
lsrs r1, r1, #0x1c
cmp r1, r0
bne _03AA
bx lr
thumb_func_end sub_03A8
non_word_aligned_thumb_func_start sub_03B6
sub_03B6: @ 0xFFFF03B6
push {r4, lr}
ldr r4, _0408 @ =0x04000180
movs r0, #0
strh r0, [r4]
bl sub_03A8
lsrs r0, r4, #0x12
strh r0, [r4]
movs r0, #1
bl sub_03A8
bl sub_0410
bl sub_042A
ldr r0, _0408 @ =0x04000180
ldr r1, _040C @ =0x0000E880
adds r0, #0x80
strh r1, [r0, #4]
lsls r1, r0, #0x14
str r1, [r4, #0x24]
lsrs r1, r0, #0x11
strh r1, [r4]
_03E4:
ldrh r1, [r4]
lsls r1, r1, #0x1c
lsrs r1, r1, #0x1c
cmp r1, #3
bne _03E4
movs r1, #0
str r1, [r0, #8]
str r1, [r0, #0x10]
mvns r1, r1
str r1, [r0, #0x14]
movs r0, #3
bl sub_03A8
movs r0, #3
lsls r0, r0, #8
strh r0, [r4]
pop {r4, pc}
.align 2, 0
_0408: .4byte 0x04000180
_040C: .4byte 0x0000E880
thumb_func_end sub_03B6
thumb_func_start sub_0410
sub_0410: @ 0xFFFF0410
ldr r1, _0758 @ =0x04000200
movs r0, #0
str r0, [r1, #8]
str r0, [r1, #0x10]
mvns r2, r0
str r2, [r1, #0x14]
ldr r2, _0758 @ =0x04000200
movs r1, #3
adds r2, #0x40
strb r1, [r2, #7]
ldr r1, _075C @ =0x04000300
strh r0, [r1, #4]
bx lr
thumb_func_end sub_0410
non_word_aligned_thumb_func_start sub_042A
sub_042A: @ 0xFFFF042A
movs r0, #0
push {r3, lr}
str r0, [sp]
movs r1, #1
lsls r1, r1, #0x17
mov r0, sp
ldr r2, _0760 @ =0x01000F80
blx SVC_CpuFastSet
movs r0, #0
str r0, [sp]
mov r0, sp
ldr r2, _0764 @ =0x01002000
ldr r1, _0768 @ =0x027F8000
blx SVC_CpuFastSet
pop {r3, pc}
thumb_func_end sub_042A
thumb_func_start SVC_GetCRC16
SVC_GetCRC16: @ 0xFFFF044C
push {r4, r5, r6, lr}
lsrs r2, r2, #1
lsls r2, r2, #1
adds r6, r2, r1
movs r2, #0
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
ldr r5, _076C @ =CRC16Table
b _0484
_045E:
cmp r2, #0
bne _0464
ldrh r3, [r1]
_0464:
lsls r4, r0, #0x1c
lsrs r4, r4, #0x1b
ldrh r4, [r5, r4]
lsrs r0, r0, #4
eors r0, r4
adds r4, r3, #0
lsrs r4, r2
lsls r4, r4, #0x1c
lsrs r4, r4, #0x1b
ldrh r4, [r5, r4]
adds r2, #4
eors r0, r4
cmp r2, #0x10
blo _0484
movs r2, #0
adds r1, #2
_0484:
cmp r1, r6
blo _045E
pop {r4, r5, r6, pc}
thumb_func_end SVC_GetCRC16
non_word_aligned_thumb_func_start SVC_IsDebugger
SVC_IsDebugger: @ 0xFFFF048A
push {r4, r5, r6, lr}
ldr r5, _076C @ =DebuggerIdent+8
ldr r4, _0770 @ =0x023FFFE0
movs r1, #0
movs r0, #0
ldr r3, _0774 @ =0x027FFFE0
subs r5, #8
_0498:
lsls r2, r0, #1
ldrh r2, [r5, r2]
strh r2, [r3, #0x18]
ldrh r6, [r4, #0x18]
cmp r6, r2
beq _04A6
adds r1, #1
_04A6:
adds r0, #1
cmp r0, #4
blt _0498
movs r0, #0
strh r0, [r3, #0x18]
movs r0, #1
cmp r1, #3
bhs _04B8
movs r0, #0
_04B8:
pop {r4, r5, r6, pc}
thumb_func_end SVC_IsDebugger
non_word_aligned_thumb_func_start SVC_HuffUnComp
SVC_HuffUnComp: @ 0xFFFF04BA
push {r0, r1, r2, r3, r4, r5, r6, r7, lr}
sub sp, #0x1c
ldr r1, [sp, #0x28]
add r2, sp, #0x1c
ldr r3, [r1]
movs r7, #0
movs r6, #0
ldm r2, {r0, r1, r2}
blx r3
lsls r2, r0, #0x1c
lsrs r2, r2, #0x1c
lsls r1, r2, #0x1d
lsrs r1, r1, #0x1d
adds r1, #4
str r1, [sp, #4]
movs r1, #0x20
subs r3, r1, r2
asrs r5, r0, #8
str r5, [sp, #0xc]
cmp r0, #0
str r3, [sp]
str r2, [sp, #8]
bge _04EC
str r0, [sp, #0xc]
b _0590
_04EC:
ldr r0, [sp, #0x1c]
ldr r1, [sp, #0x28]
adds r0, #4
str r0, [sp, #0x1c]
ldr r1, [r1, #8]
blx r1
ldr r1, [sp, #0x24]
strb r0, [r1]
lsls r0, r0, #1
adds r0, #2
str r0, [sp, #0x14]
movs r4, #1
b _0518
_0506:
ldr r0, [sp, #0x1c]
ldr r1, [sp, #0x28]
adds r0, #1
str r0, [sp, #0x1c]
ldr r1, [r1, #8]
blx r1
ldr r1, [sp, #0x24]
strb r0, [r1, r4]
adds r4, #1
_0518:
ldr r0, [sp, #0x14]
cmp r4, r0
blt _0506
ldr r0, [sp, #0x1c]
ldr r4, [sp, #0x24]
adds r0, #1
adds r4, #1
str r4, [sp, #0x18]
str r0, [sp, #0x1c]
b _058C
_052C:
movs r1, #0x20
str r1, [sp, #0x10]
ldr r1, [sp, #0x28]
ldr r1, [r1, #0x10]
ldr r0, [sp, #0x1c]
blx r1
ldr r1, [sp, #0x1c]
adds r1, #4
str r1, [sp, #0x1c]
b _0584
_0540:
ldrb r2, [r4]
lsrs r4, r4, #1
lsrs r1, r0, #0x1f
adds r3, r2, #0
lsls r2, r2, #0x1a
lsrs r2, r2, #0x1a
adds r2, r4, r2
adds r2, #1
lsls r2, r2, #1
adds r4, r2, r1
lsls r3, r1
lsls r1, r3, #0x18
bpl _057E
ldr r2, [sp, #8]
adds r6, #1
lsrs r7, r2
ldrb r2, [r4]
ldr r3, [sp]
adds r1, r7, #0
lsls r2, r3
orrs r2, r1
ldr r1, [sp, #4]
adds r7, r2, #0
cmp r6, r1
ldr r4, [sp, #0x18]
bne _057E
ldr r1, [sp, #0x20]
subs r5, #4
stm r1!, {r7}
str r1, [sp, #0x20]
movs r6, #0
_057E:
cmp r5, #0
ble _0590
lsls r0, r0, #1
_0584:
ldr r1, [sp, #0x10]
subs r1, #1
str r1, [sp, #0x10]
bpl _0540
_058C:
cmp r5, #0
bgt _052C
_0590:
ldr r1, [sp, #0x28]
ldr r1, [r1, #4]
cmp r1, #0
beq _05A0
ldr r0, [sp, #0x1c]
blx r1
cmp r0, #0
blt _05A2
_05A0:
ldr r0, [sp, #0xc]
_05A2:
add sp, #0x2c
pop {r4, r5, r6, r7, pc}
thumb_func_end SVC_HuffUnComp
non_word_aligned_thumb_func_start SVC_LZ77UnCompVRAM
SVC_LZ77UnCompVRAM: @ 0xFFFF05A6
push {r0, r1, r2, r3, r4, r5, r6, r7, lr}
sub sp, #0x1c
adds r6, r1, #0
ldr r1, [sp, #0x28]
adds r7, r0, #0
movs r5, #0
movs r4, #0
ldr r3, [r1]
adds r1, r6, #0
blx r3
asrs r1, r0, #8
str r1, [sp, #8]
str r1, [sp, #4]
cmp r0, #0
bge _05C8
str r0, [sp, #8]
b _068C
_05C8:
adds r7, #3
b _0686
_05CC:
ldr r1, [sp, #0x28]
adds r0, r7, #1
ldr r1, [r1, #8]
adds r7, r0, #0
blx r1
str r0, [sp, #0x18]
movs r0, #8
str r0, [sp, #0xc]
b _067E
_05DE:
ldr r0, [sp, #0x18]
lsls r0, r0, #0x18
bmi _0606
ldr r1, [sp, #0x28]
adds r0, r7, #1
ldr r1, [r1, #8]
adds r7, r0, #0
blx r1
lsls r0, r5
ldr r1, [sp, #4]
orrs r4, r0
subs r1, #1
movs r2, #8
eors r5, r2
str r1, [sp, #4]
bne _0672
strh r4, [r6]
adds r6, #2
movs r4, #0
b _0672
_0606:
ldr r1, [sp, #0x28]
adds r0, r7, #1
ldr r1, [r1, #8]
adds r7, r0, #0
blx r1
lsrs r3, r0, #4
lsls r0, r0, #0x1c
lsrs r1, r0, #0x14
str r1, [sp, #0x14]
ldr r1, [sp, #0x28]
adds r3, #3
str r3, [sp, #0x10]
ldr r1, [r1, #8]
adds r0, r7, #1
adds r7, r0, #0
blx r1
ldr r1, [sp, #0x14]
movs r2, #8
orrs r0, r1
adds r3, r0, #0
adds r3, #1
lsls r1, r3, #0x1f
lsrs r1, r1, #0x1c
subs r0, r2, r5
eors r0, r1
mov r12, r3
ldr r3, [sp, #0x10]
ldr r1, [sp, #4]
subs r1, r1, r3
str r1, [sp, #4]
b _066A
_0644:
subs r1, r2, r5
lsrs r1, r1, #3
add r1, r12
lsrs r1, r1, #1
lsls r1, r1, #1
subs r1, r6, r1
ldrh r1, [r1]
eors r0, r2
movs r3, #0xff
lsls r3, r0
ands r1, r3
lsrs r1, r0
lsls r1, r5
orrs r4, r1
eors r5, r2
bne _066A
strh r4, [r6]
adds r6, #2
movs r4, #0
_066A:
ldr r1, [sp, #0x10]
subs r1, #1
str r1, [sp, #0x10]
bpl _0644
_0672:
ldr r1, [sp, #4]
cmp r1, #0
ble _068C
ldr r0, [sp, #0x18]
lsls r0, r0, #1
str r0, [sp, #0x18]
_067E:
ldr r0, [sp, #0xc]
subs r0, #1
str r0, [sp, #0xc]
bpl _05DE
_0686:
ldr r1, [sp, #4]
cmp r1, #0
bgt _05CC
_068C:
ldr r1, [sp, #0x28]
ldr r1, [r1, #4]
cmp r1, #0
beq _069C
adds r0, r7, #1
blx r1
cmp r0, #0
blt _069E
_069C:
ldr r0, [sp, #8]
_069E:
add sp, #0x2c
pop {r4, r5, r6, r7, pc}
thumb_func_end SVC_LZ77UnCompVRAM
non_word_aligned_thumb_func_start SVC_RLUnCompVRAM
SVC_RLUnCompVRAM: @ 0xFFFF06A2
push {r0, r1, r2, r3, r4, r5, r6, r7, lr}
sub sp, #0xc
adds r7, r1, #0
ldr r1, [sp, #0x18]
adds r6, r0, #0
movs r5, #0
movs r4, #0
ldr r3, [r1]
adds r1, r7, #0
blx r3
asrs r1, r0, #8
str r1, [sp, #4]
str r1, [sp]
cmp r0, #0
bge _06C4
str r0, [sp, #4]
b _0742
_06C4:
adds r6, #3
b _073C
_06C8:
ldr r1, [sp, #0x18]
adds r0, r6, #1
ldr r1, [r1, #8]
adds r6, r0, #0
blx r1
lsls r1, r0, #0x19
lsrs r1, r1, #0x19
lsls r0, r0, #0x18
bmi _070C
adds r0, r1, #1
str r0, [sp, #8]
ldr r1, [sp, #8]
ldr r0, [sp]
subs r0, r0, r1
str r0, [sp]
b _0702
_06E8:
ldr r1, [sp, #0x18]
adds r0, r6, #1
ldr r1, [r1, #8]
adds r6, r0, #0
blx r1
lsls r0, r5
orrs r4, r0
movs r0, #8
eors r5, r0
bne _0702
strh r4, [r7]
adds r7, #2
movs r4, #0
_0702:
ldr r0, [sp, #8]
subs r0, #1
str r0, [sp, #8]
bpl _06E8
b _073C
_070C:
adds r1, #3
ldr r0, [sp]
str r1, [sp, #8]
subs r0, r0, r1
str r0, [sp]
ldr r1, [sp, #0x18]
adds r0, r6, #1
ldr r1, [r1, #8]
adds r6, r0, #0
blx r1
movs r2, #8
b _0734
_0724:
adds r1, r0, #0
lsls r1, r5
orrs r4, r1
eors r5, r2
bne _0734
strh r4, [r7]
adds r7, #2
movs r4, #0
_0734:
ldr r1, [sp, #8]
subs r1, #1
str r1, [sp, #8]
bpl _0724
_073C:
ldr r0, [sp]
cmp r0, #0
bgt _06C8
_0742:
ldr r1, [sp, #0x18]
ldr r1, [r1, #4]
cmp r1, #0
beq _0752
adds r0, r6, #1
blx r1
cmp r0, #0
blt _0754
_0752:
ldr r0, [sp, #4]
_0754:
add sp, #0x1c
pop {r4, r5, r6, r7, pc}
.align 2, 0
_0758: .4byte 0x04000200
_075C: .4byte 0x04000300
_0760: .4byte 0x01000F80
_0764: .4byte 0x01002000
_0768: .4byte 0x027F8000
_076C: .4byte CRC16Table
_0770: .4byte 0x023FFFE0
_0774: .4byte 0x027FFFE0
thumb_func_end SVC_RLUnCompVRAM
arm_func_start sub_0778
sub_0778: @ 0xFFFF0778
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
bx lr
arm_func_end sub_0778
arm_func_start sub_0790
sub_0790: @ 0xFFFF0790
mov r12, lr
ldr r0, _07B4 @ =0x00002078
bl sub_0778
ldr r0, _07B8 @ =0x0080000A
mcr p15, #0, r0, c9, c1, #0
mrc p15, #0, r0, c1, c0, #0
ldr r0, _07BC @ =0x00012078
mcr p15, #0, r0, c1, c0, #0
bx r12
.align 2, 0
_07B4: .4byte 0x00002078
_07B8: .4byte 0x0080000A
_07BC: .4byte 0x00012078
arm_func_end sub_0790
arm_func_start SVC_Halt
SVC_Halt: @ 0xFFFF07C0
mov r0, #0
mcr p15, #0, r0, c7, c0, #4
bx lr
arm_func_end SVC_Halt
thumb_func_start SVC_WaitByLoop
SVC_WaitByLoop: @ 0xFFFF07CC
subs r0, #1
bgt SVC_WaitByLoop
bx lr
.align 2, 0
thumb_func_end SVC_WaitByLoop
arm_func_start SVC_VBlankIntrWait
SVC_VBlankIntrWait: @ 0xFFFF07D4
mov r0, #1
mov r1, #1
arm_func_start SVC_IntrWait
SVC_IntrWait: @ 0xFFFF07DC
push {r4, lr}
cmp r0, #0
blne sub_0800
_07E8:
mov lr, #0
mcr p15, #0, lr, c7, c0, #4
bl sub_0800
beq _07E8
pop {r4, lr}
bx lr
arm_func_end SVC_IntrWait
arm_func_end SVC_VBlankIntrWait
arm_func_start sub_0800
sub_0800: @ 0xFFFF0800
@ Disable IME
mov r12, #64, #12
str r12, [r12, #0x208]
@ Cancel requested interrupt mask
LD_DTCM_SYSRV_TOP r3
ldr r2, [r3, #-8]
ands r0, r1, r2
eorne r2, r2, r0
strne r2, [r3, #-8]
@ Enable IME
mov r0, #1
str r0, [r12, #0x208]
bx lr
arm_func_end sub_0800
arm_func_start SVC_Div
SVC_Div: @ 0xFFFF0834
ands r3, r1, #128, #8
rsbmi r1, r1, #0
eors r12, r3, r0, asr #32
rsbhs r0, r0, #0
movs r2, r1
_0848:
cmp r2, r0, lsr #1
lslls r2, r2, #1
blo _0848
_0854:
cmp r0, r2
adc r3, r3, r3
subhs r0, r0, r2
teq r2, r1
lsrne r2, r2, #1
bne _0854
mov r1, r0
mov r0, r3
lsls r12, r12, #1
rsbhs r0, r0, #0
rsbmi r1, r1, #0
bx lr
arm_func_end SVC_Div
arm_func_start SVC_Sqrt
SVC_Sqrt: @ 0xFFFF0884
push {r4, r5}
mov r12, r0
mov r1, #1
_0890:
cmp r0, r1
lsrhi r0, r0, #1
lslhi r1, r1, #1
bhi _0890
_08A0:
mov r0, r12
mov r4, r1
mov r3, #0
mov r2, r1
_08B0:
cmp r2, r0, lsr #1
lslls r2, r2, #1
blo _08B0
_08BC:
cmp r0, r2
adc r3, r3, r3
subhs r0, r0, r2
teq r2, r1
lsrne r2, r2, #1
bne _08BC
add r1, r1, r3
lsrs r1, r1, #1
cmp r1, r4
blo _08A0
mov r0, r4
pop {r4, r5}
bx lr
arm_func_end SVC_Sqrt
thumb_func_start SVC_CpuSet
SVC_CpuSet: @ 0xFFFF08F0
push {r4, r5, r6, lr}
lsls r4, r2, #0xb
lsrs r4, r4, #9
movs r5, #0
lsrs r3, r2, #0x1b
blo _0916
adds r5, r1, r4
lsrs r3, r2, #0x19
blo _090C
ldm r0!, {r3}
_0904:
cmp r1, r5
bge _0934
stm r1!, {r3}
b _0904
_090C:
cmp r1, r5
bge _0934
ldm r0!, {r3}
stm r1!, {r3}
b _090C
_0916:
lsrs r4, r4, #1
lsrs r3, r2, #0x19
blo _0928
ldrh r3, [r0]
_091E:
cmp r5, r4