forked from p4plus2/DKC2-disassembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank_80.asm
13599 lines (12931 loc) · 323 KB
/
bank_80.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
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
DATA_808000:
db $00, $00, $72, $4E, $00, $00, $71, $4E
db $00, $00, $71, $4E, $00, $00, $71, $4E
db $00, $00, $51, $4E, $00, $00, $51, $4E
db $00, $00, $51, $4E, $00, $00, $51, $4A
db $00, $00, $50, $4A, $00, $00, $50, $4A
db $00, $00, $50, $4A, $00, $00, $30, $4A
db $00, $00, $30, $4A, $00, $00, $30, $4A
db $00, $00, $30, $4A, $00, $00, $2F, $4A
db $00, $00, $2F, $4A, $00, $00, $2F, $4A
db $00, $00, $2F, $4A, $00, $00, $0F, $46
db $00, $00, $0F, $46, $00, $00, $0F, $46
db $00, $00, $0E, $46, $00, $00, $0E, $46
db $00, $00, $0E, $46, $00, $00, $0E, $46
db $00, $00, $EE, $45, $00, $00, $EE, $45
db $00, $00, $EE, $45, $00, $00, $EE, $45
db $00, $00, $ED, $45, $00, $00, $ED, $41
db $00, $00, $ED, $41, $00, $00, $CD, $41
db $00, $00, $CD, $41, $00, $00, $CD, $41
db $00, $00, $CD, $41, $00, $00, $CC, $41
db $00, $00, $CC, $41, $00, $00, $CC, $41
db $00, $00, $CC, $41, $00, $00, $AC, $41
db $00, $00, $AC, $41, $00, $00, $AC, $3D
db $00, $00, $AB, $3D, $00, $00, $AB, $3D
db $00, $00, $AB, $3D, $00, $00, $AB, $3D
db $00, $00, $8B, $3D, $00, $00, $8B, $3D
db $00, $00, $8B, $3D, $00, $00, $8B, $3D
db $00, $00, $8A, $3D, $00, $00, $8A, $3D
db $00, $00, $8A, $3D, $00, $00, $8A, $3D
db $00, $00, $8A, $39, $00, $00, $8A, $39
db $00, $00, $6A, $39, $00, $00, $69, $39
db $00, $00, $69, $39, $00, $00, $69, $39
db $00, $00, $69, $39, $00, $00, $69, $39
db $00, $00, $69, $39, $00, $00, $48, $39
db $00, $00, $48, $35, $00, $00, $48, $35
db $00, $00, $48, $35, $00, $00, $48, $35
db $00, $00, $48, $35, $00, $00, $48, $35
db $00, $00, $27, $35, $00, $00, $27, $35
db $00, $00, $27, $31, $00, $00, $27, $31
db $00, $00, $27, $31, $00, $00, $27, $31
db $00, $00, $06, $31, $00, $00, $06, $31
db $00, $00, $06, $2D, $00, $00, $06, $2D
db $00, $00, $06, $2D, $00, $00, $06, $2D
db $00, $00, $05, $2D, $00, $00, $E5, $2C
db $00, $00, $E5, $28, $00, $00, $E5, $28
db $00, $00, $E5, $28, $00, $00, $E5, $28
db $00, $00, $E5, $28, $00, $00, $E4, $24
db $00, $00, $C4, $24, $00, $00, $C4, $24
db $00, $00, $C4, $24, $00, $00, $C4, $24
db $00, $00, $C4, $24, $00, $00, $C3, $20
db $00, $00, $C3, $20, $00, $00, $A3, $20
db $00, $00, $A3, $20, $00, $00, $A3, $20
db $00, $00, $A3, $20, $00, $00, $A3, $1C
db $00, $00, $A2, $1C, $00, $00, $A2, $1C
db $00, $00, $82, $1C, $00, $00, $82, $1C
db $00, $00, $82, $18, $00, $00, $82, $18
db $00, $00, $81, $18, $00, $00, $81, $18
db $00, $00, $81, $18, $00, $00, $61, $18
db $00, $00, $61, $14, $00, $00, $61, $14
db $00, $00, $60, $14, $00, $00, $60, $14
db $00, $00, $60, $14, $00, $00, $60, $14
db $00, $00, $77, $4A, $00, $00, $77, $46
db $00, $00, $77, $46, $00, $00, $77, $46
db $00, $00, $57, $46, $00, $00, $57, $46
db $00, $00, $57, $46, $00, $00, $56, $46
db $00, $00, $56, $42, $00, $00, $56, $42
db $00, $00, $56, $42, $00, $00, $36, $42
db $00, $00, $36, $42, $00, $00, $36, $42
db $00, $00, $36, $42, $00, $00, $36, $3E
db $00, $00, $36, $3E, $00, $00, $36, $3E
db $00, $00, $36, $3E, $00, $00, $15, $3E
db $00, $00, $15, $3E, $00, $00, $15, $3E
db $00, $00, $15, $3A, $00, $00, $15, $3A
db $00, $00, $15, $3A, $00, $00, $15, $3A
db $00, $00, $F5, $39, $00, $00, $F5, $39
db $00, $00, $F5, $39, $00, $00, $F5, $39
db $00, $00, $F5, $35, $00, $00, $F4, $35
db $00, $00, $F4, $35, $00, $00, $D4, $35
db $00, $00, $D4, $35, $00, $00, $D4, $35
db $00, $00, $D4, $35, $00, $00, $D4, $31
db $00, $00, $D4, $31, $00, $00, $D4, $31
db $00, $00, $D4, $31, $00, $00, $B4, $31
db $00, $00, $B4, $31, $00, $00, $B3, $31
db $00, $00, $B3, $2D, $00, $00, $B3, $2D
db $00, $00, $B3, $2D, $00, $00, $B3, $2D
db $00, $00, $93, $2D, $00, $00, $93, $2D
db $00, $00, $93, $2D, $00, $00, $93, $2D
db $00, $00, $93, $29, $00, $00, $93, $29
db $00, $00, $93, $29, $00, $00, $93, $29
db $00, $00, $92, $29, $00, $00, $92, $29
db $00, $00, $72, $29, $00, $00, $72, $25
db $00, $00, $72, $25, $00, $00, $72, $25
db $00, $00, $72, $25, $00, $00, $72, $25
db $00, $00, $72, $25, $00, $00, $52, $21
db $00, $00, $51, $21, $00, $00, $51, $21
db $00, $00, $51, $21, $00, $00, $51, $21
db $00, $00, $51, $21, $00, $00, $51, $21
db $00, $00, $31, $1D, $00, $00, $31, $1D
db $00, $00, $30, $1D, $00, $00, $30, $1D
db $00, $00, $30, $1D, $00, $00, $30, $1D
db $00, $00, $10, $19, $00, $00, $10, $19
db $00, $00, $0F, $19, $00, $00, $0F, $19
db $00, $00, $0F, $19, $00, $00, $0F, $19
db $00, $00, $0F, $15, $00, $00, $EF, $14
db $00, $00, $EE, $14, $00, $00, $EE, $14
db $00, $00, $EE, $14, $00, $00, $EE, $14
db $00, $00, $EE, $14, $00, $00, $ED, $10
db $00, $00, $CD, $10, $00, $00, $CD, $10
db $00, $00, $CD, $10, $00, $00, $CD, $10
db $00, $00, $CD, $10, $00, $00, $CC, $0C
db $00, $00, $CC, $0C, $00, $00, $AC, $0C
db $00, $00, $AC, $0C, $00, $00, $AC, $0C
db $00, $00, $AC, $0C, $00, $00, $AB, $0C
db $00, $00, $AB, $08, $00, $00, $AB, $08
db $00, $00, $8B, $08, $00, $00, $8B, $08
db $00, $00, $8A, $08, $00, $00, $8A, $08
db $00, $00, $8A, $04, $00, $00, $8A, $04
db $00, $00, $8A, $04, $00, $00, $6A, $04
db $00, $00, $69, $04, $00, $00, $69, $04
db $00, $00, $69, $00, $00, $00, $69, $00
db $00, $00, $69, $00, $00, $00, $69, $00
rare_string:
db "Rareware"
piracy_string:
db "A thief!"
display_error_message:
TYA ;$8083D0 \
JSL CODE_BB80B0 ;$8083D1 |
LDA #DATA_FD258E ;$8083D5 |
LDY #$0000 ;$8083D8 |
LDX #$0020 ;$8083DB |
JSL CODE_BB8089 ;$8083DE |
LDA #DATA_FD0408 ;$8083E2 |
LDY #$0000 ;$8083E5 |
LDX #$0001 ;$8083E8 |
JSL CODE_BB8089 ;$8083EB |
LDA #$0039 ;$8083EF |
JSL CODE_BB80AC ;$8083F2 |
STP ;$8083F6 /
RESET_start:
SEI ;$8083F7 \ Disable interrupts
LDA #$80 ;$8083F8 |\ Enable F-Blank
STA $2100 ;$8083FA |/
LDA #$01 ;$8083FD |\ Enable autojoy and fastROM
STA $4200 ;$8083FF | |
STA $420D ;$808402 |/
DEC A ;$808405 |\ Disable HDMA
STA $420C ;$808406 |/
CLC ;$808409 |\ Disable emulation mode
XCE ;$80840A |/
REP #$30 ;$80840B |\ Anti piracy: Ensure dp is zero
TDC ;$80840D | | and the emulation flag was set
ADC #$FFFF ;$80840E | |
BEQ .anti_piracy_test ;$808411 |/
BRL .prepare_anti_piracy ;$808413 / Anti piracy triggered
.anti_piracy_test ; \
TSX ;$808416 |\ Check if the reset vector was
LDA #RESET_start-1 ;$808417 | | the most recent popped value
CMP $FFFF,x ;$80841A | |
BEQ .check_for_false_positive ;$80841D |/
LDY #$1FFD ;$80841F | Load number of RAM bytes to scan
SEP #$20 ;$808422 | Use 8 bit to check each byte
.next_byte ; |
LDA $0000,y ;$808424 | Load byte to scan
CMP #$4C ;$808427 |\ Test for JMP $83F7 (reset vector)
BEQ .jmp_test ;$808429 |/
CMP #$6C ;$80842B |\ Test for JMP ($xxxx) (indirect reset vector)
BEQ .indirect_jmp_test ;$80842D |/
CMP #$60 ;$80842F |\ Test for #$60-#$7F being sequential
BEQ .sequential_test ;$808431 |/
.resume_scanning ; |
DEY ;$808433 |\ If not at the end of RAM continue scanning
BPL .next_byte ;$808434 |/
REP #$20 ;$808436 |\ Test that SRAM is present
LDA.l $B06000 ;$808438 | |
INC A ;$80843C | |
STA $B06000 ;$80843D | |
CMP $B06000 ;$808441 | |
BNE .prepare_anti_piracy ;$808445 |/ Otherwise trigger anti piracy
DEC A ;$808447 |\ Restore byte modified from SRAM test
STA $B06000 ;$808448 |/
LDY #$003D ;$80844C | Load wrong console message
LDA $213F ;$80844F |\ Verify the console is NTSC
AND #$0010 ;$808452 | |
BNE .prepare_message ;$808455 |/ Display wrong console message
BRA .final_piracy_test ;$808457 / Do the final piracy test
.jmp_test
REP #$20 ;$808459 \
LDA $0001,y ;$80845B |\ Check if the operand was the reset vector
CMP #RESET_start ;$80845E | |
BEQ .check_for_false_positive ;$808461 |/
SEP #$20 ;$808463 |
BRA .resume_scanning ;$808465 / Continue scanning
.indirect_jmp_test
REP #$20 ;$808467 \
LDX $0001,y ;$808469 |\ Test if operand was ROM
BMI .address_rom ;$80846C |/
CPX #$2000 ;$80846E |\ Test if the operand was low RAM
BPL .invalid_address ;$808471 |/ Otherwise skip the indirect test
.address_rom ; |
LDA $0000,x ;$808473 |\ Check if the operand pointed to the reset vector
CMP #RESET_start ;$808476 | |
BEQ .check_for_false_positive ;$808479 |/
.invalid_address ; |
SEP #$20 ;$80847B |
BRA .resume_scanning ;$80847D / Continue scanning
.sequential_test
TYX ;$80847F \ X is used so to preserve Y if the test fails
.next_count ; |
CMP $0000,x ;$808480 |\ Scan for the sequential string of $60-$7F
BNE .resume_scanning ;$808483 | |
INX ;$808485 | |
INC A ;$808486 | |
BPL .next_count ;$808487 |/
REP #$20 ;$808489 | Fall through to final check
.check_for_false_positive ; |
PHK ;$80848B |\ Set current databank
PLB ;$80848C |/
LDX #$0006 ;$80848D | Load anti piracy test string length
- ; |
LDA $0907,x ;$808490 |\ Avoid false positive by checking if
CMP rare_string,x ;$808493 | | the anti piracy check was prior passed
BNE .write_piracy_string ;$808496 | | Otherwise jump and fail anti piracy check
DEX ;$808498 | |
DEX ;$808499 | |
BPL - ;$80849A |/
BRA .prepare_logo ;$80849C / Boot the game
.write_piracy_string
LDX #$0006 ;$80849E \ Load anti piracy string length
LDY #$0004 ;$8084A1 | Load target iteration count
.write_next_byte ; |
LDA piracy_string,x ;$8084A4 |\ Load the current anti piracy byte
STA $0907,x ;$8084A7 | | Write the anti piracy byte in RAM
CMP.l $B06000,x ;$8084AA | |\ If the byte is already in SRAM decrease the
BNE + ;$8084AE | | | iteration count. If zero, the full string
DEY ;$8084B0 | |/ was already present.
+ ; | |
STA $B06000,x ;$8084B1 | | Write the anti piracy byte to SRAM
DEX ;$8084B5 | |\ Move anti piracy index
DEX ;$8084B6 | |/
BPL .write_next_byte ;$8084B7 |/ Continue writing until there are no more bytes
TYA ;$8084B9 |\ If the anti piracy failure string was already in SRAM
BEQ .prepare_anti_piracy ;$8084BA |/ Display the anti piracy message
LDY #$003B ;$8084BC | Otherwise load irregularity detected message
BRA .prepare_message ;$8084BF / Display the message
.prepare_anti_piracy
LDY #$003C ;$8084C1 \ Load anti piracy message
.prepare_message ; |
LDA #$0000 ;$8084C4 |\ Zero the direct page register
TCD ;$8084C7 |/
LDX #$01FF ;$8084C8 |\ Reset the stack register
TXS ;$8084CB |/
%return(display_error_message) ;$8084CC | Push address to decompress and display the message
%return(clear_vram) ;$8084CF | Push address for clearing vram
BRA init_registers ;$8084D2 / Initialize MMIO registers
.final_piracy_test ; \
PHK ;$8084D4 |\ Set current databank
PLB ;$8084D5 |/
LDX #$0006 ;$8084D6 | Load anti piracy string length
- ; |
LDA $0907,x ;$8084D9 |\ Verify the anti piracy failure string is not in RAM
CMP piracy_string,x ;$8084DC | |
BNE .prepare_logo ;$8084DF | |
DEX ;$8084E1 | |
DEX ;$8084E2 | |
BPL - ;$8084E3 |/
BRA .prepare_anti_piracy ;$8084E5 / If the string was matched, display anti piracy message
.prepare_logo ; \
LDA #$0000 ;$8084E7 |\ Clear first word of SRAM
STA $B06000 ;$8084EA |/
LDX #$01FF ;$8084EE |\ Reset the stack register
TXS ;$8084F1 |/
%return(start_engine) ;$8084F2 | Push address to start the game engine
%return(clear_vram) ;$8084F5 | Push address for clearing VRAM
init_registers: ; |
SEP #$30 ;$8084F8 | Use 8 bit to manipulate MMIO
LDX #$00 ;$8084FA | Reset index to clear PPU MMIO
.clear_PPU ; |
STZ $2101,x ;$8084FC |\ Clear $2101 - $2134
STZ $2101,x ;$8084FF | | Clear twice to handle write twice registers
INX ;$808502 | |
CPX #$34 ;$808503 | |
BNE .clear_PPU ;$808505 |/
LDX #$00 ;$808507 | Reset index to clear CPU MMIO
.clear_CPU ; |
STZ $4202,x ;$808509 |\ Clear 4202-420C
INX ;$80850C | |
CPX #$0B ;$80850D | |
BNE .clear_CPU ;$80850F |/
LDA #$8F ;$808511 |\ Enable F-Blank with full brightness
STA $2100 ;$808513 |/
LDA #$80 ;$808516 |\
STA $2115 ;$808518 | | Increment VRAM after high byte write
STA $211A ;$80851B |/ Use large mode 7 tilemap bounds
LDA #$01 ;$80851E |\ Enable fastROM
STA $420D ;$808520 |/
STZ $2131 ;$808523 | Disable color math
STZ $2133 ;$808526 | Reset screen mode
STZ $4200 ;$808529 | Disable interrupts and autojoy
LDA #$FF ;$80852C |\ Initalize outport (unused)
STA $4201 ;$80852E |/
LDA #$E0 ;$808531 |\ Set fixed color
STA $2132 ;$808533 |/
LDA #$30 ;$808536 |\ Clear color math settings
STA $2130 ;$808538 |/
LDA #$00 ;$80853B |\ Disable mosaic
STA $2106 ;$80853D |/
STZ $210D ;$808540 |\ Clear layer 1-3 horizontal scroll (Layer 1)
STZ $210D ;$808543 | |
STZ $210F ;$808546 | | Layer 2
STZ $210F ;$808549 | |
STZ $2111 ;$80854C | | Layer 3
STZ $2111 ;$80854F |/
LDA #$FF ;$808552 |\ Set layer 1-3 vertical scroll to $FFFF
STA $210E ;$808554 | | Layer 1
STA $210E ;$808557 | |
STA $2110 ;$80855A | | Layer 2
STA $2110 ;$80855D | |
STA $2112 ;$808560 | | Layer 3
STA $2112 ;$808563 |/
REP #$30 ;$808566 | Restore to 16 bit access...
SEP #$20 ;$808568 | ...Just to make A 8 bit again
LDX #$000A ;$80856A | Load up the number of H/DMA bytes to clear
.clear_DMA ; |
STZ $4300,x ;$80856D |\ Zero out channels 0-7
STZ $4310,x ;$808570 | |
STZ $4320,x ;$808573 | |
STZ $4330,x ;$808576 | |
STZ $4340,x ;$808579 | |
STZ $4350,x ;$80857C | |
STZ $4360,x ;$80857F | |
STZ $4370,x ;$808582 | |
DEX ;$808585 | | Next byte
BPL .clear_DMA ;$808586 |/ Continue until addresses from all channel are clear
REP #$20 ;$808588 | Back to a full 16 bit
RTS ;$80858A /
init_registers_wrapper:
JSR init_registers ;$80858B \ Wrapper for long calls
RTL ;$80858E /
vram_zero_fill:
dw $0000 ;$80858F > Used for vram fill byte
clear_vram:
STZ $2116 ;$808591 \ Initialize VRAM to zeros
LDA #vram_zero_fill ;$808594 |\ Set DMA source word
STA $4302 ;$808597 |/
STA $4308 ;$80859A | Set HDMA word (not used.)
STZ $4305 ;$80859D | Set size to zero, (full 64K)
LDA #$1809 ;$8085A0 |\ Set DMA destination 2118, fixed transfer,
STA $4300 ;$8085A3 |/ with two register write once
SEP #$20 ;$8085A6 |
LDA #vram_zero_fill>>16 ;$8085A8 |\ Set DMA source bank
STA $4304 ;$8085AA |/
LDA #$01 ;$8085AD |\
STA $420B ;$8085AF |/ Enable channel 1 DMA
REP #$20 ;$8085B2 |
RTS ;$8085B4 /
clear_vram_wrapper:
JSR clear_vram ;$8085B5 \ Wrapper for long calls
RTL ;$8085B8 /
start_engine: ; \
STZ $00 ;$8085B9 |\ Zero the first byte of WRAM
LDX #$0000 ;$8085BB | | Set up MVN
LDY #$0001 ;$8085BE | |
LDA #$FFFF ;$8085C1 | | 64K
MVN $7E, $7E ;$8085C4 |/ Copy first byte of WRAM across bank 7E (zero bank 7E)
LDY #$0000 ;$8085C7 |\ Set up another MVN
TYX ;$8085CA | |
LDA #$FFFF ;$8085CB | |
MVN $7F, $7E ;$8085CE |/ Copy 64K from bank 7E to 7F (zero bank 7F)
PHK ;$8085D1 |\ Set the program bank to the data bank
PLB ;$8085D2 |/
LDX #$0006 ;$8085D3 |\ Number of bytes minus one to copy (due to 16 bit)
.rare_string_copy ; | |
LDA rare_string,x ;$8085D6 | | Use the Rareware anti piracy success string,
STA $0907,x ;$8085D9 | | and copy that into RAM
DEX ;$8085DC | |
DEX ;$8085DD | |
BPL .rare_string_copy ;$8085DE |/ Copy the string until there are no more bytes
JSL upload_spc_engine_entry ;$8085E0 | Upload the SPC engine
init_rare_logo: ; |
JSL disable_screen ;$8085E4 | Disable the screen
JSR clear_wram_reset ;$8085E8 | Clear WRAM
JML CODE_8090DA ;$8085EB / Run the Rareware logo
CODE_8085EF:
LDA #$FFFF ;$8085EF \
STA $00090F ;$8085F2 |
JSL disable_screen ;$8085F6 |
LDA #CODE_80B3D7 ;$8085FA |
STA $24 ;$8085FD |
STZ $2102 ;$8085FF |
LDA #CODE_808608 ;$808602 |
JMP CODE_808C82 ;$808605 /
CODE_808608:
LDA #$01FF ;$808608 \
TCS ;$80860B |
CODE_80860C: ; |
LDA #CODE_80F3E6 ;$80860C |
STA $20 ;$80860F |
INC $2A ;$808611 |
JMP ($0024) ;$808613 /
CODE_808616:
LDA #$0100 ;$808616 |
CLC ;$808619 |
ADC $0985 ;$80861A |
STA $0985 ;$80861D |
SEP #$20 ;$808620 |
LDA $0512 ;$808622 |
STA $2100 ;$808625 |
REP #$20 ;$808628 |
CODE_80862A: ; |
PHB ;$80862A |
PHB ;$80862B |
PLA ;$80862C |
SEC ;$80862D |
SBC #$C000 ;$80862E |
BCC CODE_808636 ;$808631 /
DATA_808633:
db $00, $80, $FD
CODE_808636:
INC $D5 ;$808636 \
BNE CODE_808640 ;$808638 |
INC $D7 ;$80863A |
BNE CODE_808640 ;$80863C |
DEC $D7 ;$80863E |
CODE_808640: ; |
LDA #CODE_808608 ;$808640 |
STA $20 ;$808643 |
SEP #$20 ;$808645 |
LDA $4210 ;$808647 |
LDA #$81 ;$80864A |
STA $4200 ;$80864C |
STZ $4016 ;$80864F |
CODE_808652: ; |
WAI ;$808652 |
BRA CODE_808652 ;$808653 /
LDA $0504 ;$808655 |
AND #$0020 ;$808658 |
BNE CODE_808672 ;$80865B |
LDA $0987 ;$80865D |
CLC ;$808660 |
ADC #$0010 ;$808661 |
CMP #$0800 ;$808664 |
BMI CODE_80866C ;$808667 |
LDA #$0800 ;$808669 |
CODE_80866C: ; |
STA $0987 ;$80866C |
JMP CODE_80860C ;$80866F /
CODE_808672:
LDA $0987 ;$808672 \
SEC ;$808675 |
SBC #$0010 ;$808676 |
BPL CODE_80867E ;$808679 |
LDA #$0000 ;$80867B |
CODE_80867E: ; |
STA $0987 ;$80867E |
JMP CODE_80860C ;$808681 /
CODE_808684:
JSL disable_screen ;$808684 |
SEP #$20 ;$808688 |
LDA #$FF ;$80868A |
STA $210E ;$80868C |
STA $210E ;$80868F |
REP #$20 ;$808692 |
LDA #DATA_FD0FF0 ;$808694 |
LDY #$0000 ;$808697 |
LDX #$0040 ;$80869A |
JSL CODE_BB8089 ;$80869D |
LDA #$0008 ;$8086A1 |
JSL CODE_BB80B0 ;$8086A4 |
LDA #$0007 ;$8086A8 |
JSL CODE_BB80AC ;$8086AB |
LDA #$7000 ;$8086AF |
STA $2116 ;$8086B2 |
LDY #$0064 ;$8086B5 |
LDX #$0000 ;$8086B8 |
CODE_8086BB: ; |
LDA.l DATA_ED57EF,x ;$8086BB |
STA $2118 ;$8086BF |
INX ;$8086C2 |
INX ;$8086C3 |
TXA ;$8086C4 |
AND #$000F ;$8086C5 |
BNE CODE_8086BB ;$8086C8 |
STZ $2118 ;$8086CA |
STZ $2118 ;$8086CD |
STZ $2118 ;$8086D0 |
STZ $2118 ;$8086D3 |
STZ $2118 ;$8086D6 |
STZ $2118 ;$8086D9 |
STZ $2118 ;$8086DC |
STZ $2118 ;$8086DF |
DEY ;$8086E2 |
BNE CODE_8086BB ;$8086E3 |
LDA #$0001 ;$8086E5 |
STA $059B ;$8086E8 |
SEP #$20 ;$8086EB |
LDA #$0F ;$8086ED |
STA $2100 ;$8086EF |
REP #$20 ;$8086F2 |
CODE_8086F4: ; |
BRA CODE_8086F4 ;$8086F4 /
CODE_8086F6:
JSL disable_screen ;$8086F6 \
PHK ;$8086FA |
PLB ;$8086FB |
LDA #$8000 ;$8086FC |
TSB $08C4 ;$8086FF |
LDA #$0001 ;$808702 |
STA $05FB ;$808705 |
JSR CODE_808712 ;$808708 |
LDA #CODE_8087E1 ;$80870B |
JML CODE_808C9E ;$80870E /
CODE_808712:
LDA #$AA55 ;$808712 \
STA $2E ;$808715 |
LDA #$3765 ;$808717 |
STA $30 ;$80871A |
STZ $05FD ;$80871C |
STZ $05FF ;$80871F |
LDA #$0040 ;$808722 |
TRB $08C2 ;$808725 |
STZ $0502 ;$808728 |
STZ $0506 ;$80872B |
STZ $050A ;$80872E |
LDA $05FB ;$808731 |
CMP #$0002 ;$808734 |
BNE CODE_80875E ;$808737 |
LDA #$000C ;$808739 |
STA $D3 ;$80873C |
STA $08C8 ;$80873E |
LDA #$0001 ;$808741 |
STA $08A6 ;$808744 |
LDX $05FD ;$808747 |
LDA $D3 ;$80874A |
STA DATA_FE9388,x ;$80874C |
INX ;$808750 |
INX ;$808751 |
LDA $08A6 ;$808752 |
STA DATA_FE9388,x ;$808755 |
INX ;$808759 |
INX ;$80875A |
STX $05FD ;$80875B |
CODE_80875E: ; |
LDA.l $000605 ;$80875E |
AND #$0003 ;$808762 |
CMP #$0003 ;$808765 |
BNE CODE_80876E ;$808768 |
JML init_rare_logo ;$80876A /
CODE_80876E:
ASL A ;$80876E \
TAX ;$80876F |
LDA.l DATA_FE958E,x ;$808770 |
STA $000601 ;$808774 |
INC $0605 ;$808778 |
LDA.l $000601 ;$80877B |
STA $36 ;$80877F |
LDA #$00FE ;$808781 |
STA $38 ;$808784 |
LDA $05FB ;$808786 |
CMP #$0001 ;$808789 |
BNE CODE_8087B8 ;$80878C |
PHB ;$80878E |
PHK ;$80878F |
PLB ;$808790 |
LDY $05FD ;$808791 |
LDA [$36],y ;$808794 |
STA $000603 ;$808796 |
INY ;$80879A |
INY ;$80879B |
LDA [$36],y ;$80879C |
STA $D3 ;$80879E |
STA $08C8 ;$8087A0 |
INY ;$8087A3 |
INY ;$8087A4 |
LDA [$36],y ;$8087A5 |
STA $08A6 ;$8087A7 |
INY ;$8087AA |
INY ;$8087AB |
STY $05FD ;$8087AC |
INY ;$8087AF |
INY ;$8087B0 |
LDA [$36],y ;$8087B1 |
STA $0005FF ;$8087B3 |
PLB ;$8087B7 |
CODE_8087B8: ; |
RTS ;$8087B8 /
CODE_8087B9:
JSL CODE_80F3FB ;$8087B9 \
PHK ;$8087BD |
PLB ;$8087BE |
LDA #CODE_8087C5 ;$8087BF |
JMP CODE_808C9E ;$8087C2 /
CODE_8087C5:
JML CODE_80F482 ;$8087C5 /
CODE_8087C9:
JSL disable_screen ;$8087C9 |
PHK ;$8087CD |
PLB ;$8087CE |
JSR CODE_808712 ;$8087CF |
LDA #CODE_8087E1 ;$8087D2 |
JML CODE_808C9E ;$8087D5 /
CODE_8087D9:
LDA.l $0006B1 ;$8087D9 \
JML CODE_B5CDFD ;$8087DD /
CODE_8087E1:
PHK ;$8087E1 \
PLB ;$8087E2 |
JSL disable_screen ;$8087E3 |
JSL CODE_BB9210 ;$8087E7 |
PHK ;$8087EB |
PLB ;$8087EC |
LDA #$0200 ;$8087ED |
JSR CODE_808C32 ;$8087F0 |
JSR CODE_808CAC ;$8087F3 |
SEP #$20 ;$8087F6 |
LDA $0529 ;$8087F8 |
STA $96 ;$8087FB |
LDA $0527 ;$8087FD |
STA $94 ;$808800 |
REP #$20 ;$808802 |
LDA #CODE_808819 ;$808804 |
JMP CODE_808C9E ;$808807 /
CODE_80880A:
SEP #$20 ;$80880A |
STA $96 ;$80880C |
XBA ;$80880E |
STA $94 ;$80880F |
REP #$20 ;$808811 |
LDA #CODE_808819 ;$808813 |
JMP CODE_808C9E ;$808816 /
CODE_808819:
LDA $94 ;$808819 \
ASL A ;$80881B |
TAX ;$80881C |
JSR (DATA_80B6C1,x) ;$80881D |
SEP #$20 ;$808820 |
LDA $4212 ;$808822 |
REP #$20 ;$808825 |
BMI CODE_808830 ;$808827 |
LDA #$0005 ;$808829 |
JSL CODE_808C13 ;$80882C |
CODE_808830: ; |
LDA $96 ;$808830 |
ASL A ;$808832 |
TAX ;$808833 |
JMP (DATA_80D411,x) ;$808834 /
CODE_808837:
JSR CODE_80883B ;$808837 \
RTL ;$80883A /
CODE_80883B:
BNE CODE_808863 ;$80883B \
LDA #$0DE2 ;$80883D |
STA $0593 ;$808840 |
LDA #$16B2 ;$808843 |
STA $0595 ;$808846 |
STZ $08A4 ;$808849 |
LDA $08A4 ;$80884C |
INC A ;$80884F |
STA $08A2 ;$808850 |
LDA #$0E40 ;$808853 |
STA $0597 ;$808856 |
LDA #$16D8 ;$808859 |
STA $0599 ;$80885C |
JSR CODE_808889 ;$80885F |
RTS ;$808862 /
CODE_808863:
LDA #$0E40 ;$808863 \
STA $0593 ;$808866 |
LDA #$16D8 ;$808869 |
STA $0595 ;$80886C |
LDA #$0001 ;$80886F |
STA $08A4 ;$808872 |
INC A ;$808875 |
STA $08A2 ;$808876 |
LDA #$0DE2 ;$808879 |
STA $0597 ;$80887C |
LDA #$16B2 ;$80887F |
STA $0599 ;$808882 |
JSR CODE_808889 ;$808885 |
RTS ;$808888 /
CODE_808889:
PHX ;$808889 \
LDX $0593 ;$80888A |
LDA #$001E ;$80888D |
STA $30,x ;$808890 |
LDX $0597 ;$808892 |
LDA #$0000 ;$808895 |
STA $30,x ;$808898 |
PLX ;$80889A |
RTS ;$80889B /
CODE_80889C:
JSR CODE_8088A0 ;$80889C \
RTL ;$80889F /
CODE_8088A0:
LDA $08A4 ;$8088A0 \
EOR #$0001 ;$8088A3 |
BRA CODE_80883B ;$8088A6 /
CODE_8088A8:
LDA $D3 ;$8088A8 \
RTL ;$8088AA /
CODE_8088AB:
LDA #$0200 ;$8088AB \
STA $70 ;$8088AE |
JSR CODE_8088BA ;$8088B0 |
RTL ;$8088B3 /
CODE_8088B4:
PHB ;$8088B4 \
JSR CODE_8088BA ;$8088B5 |
PLB ;$8088B8 |
RTL ;$8088B9 /
CODE_8088BA:
PHK ;$8088BA \
PLB ;$8088BB |
LDX $70 ;$8088BC |
CPX #$0400 ;$8088BE |
BEQ CODE_8088D1 ;$8088C1 |
LDA #$F0FF ;$8088C3 |
CODE_8088C6: ; |
STA $00,x ;$8088C6 |
INX ;$8088C8 |
INX ;$8088C9 |
INX ;$8088CA |
INX ;$8088CB |
CPX #$0400 ;$8088CC |
BNE CODE_8088C6 ;$8088CF |
CODE_8088D1: ; |
RTS ;$8088D1 /
CODE_8088D2:
LDY #DATA_8088F1 ;$8088D2 \
PHB ;$8088D5 |
PHK ;$8088D6 |
PLB ;$8088D7 |
BRA CODE_8088EA ;$8088D8 /
CODE_8088DA:
TAX ;$8088DA \
LDA $0002,y ;$8088DB |
LSR A ;$8088DE |
CODE_8088DF: ; |
STZ $00,x ;$8088DF |
INX ;$8088E1 |
INX ;$8088E2 |
DEC A ;$8088E3 |
BNE CODE_8088DF ;$8088E4 |
INY ;$8088E6 |
INY ;$8088E7 |
INY ;$8088E8 |
INY ;$8088E9 |
CODE_8088EA: ; |
LDA $0000,y ;$8088EA |
BPL CODE_8088DA ;$8088ED |
PLB ;$8088EF |
RTL ;$8088F0 /
DATA_8088F1:
db $84, $0D, $2E, $09, $B2, $16, $26, $00
db $D8, $16, $26, $00, $7A, $0D, $02, $00
db $A0, $0B, $02, $00, $A2, $0B, $02, $00
db $36, $0A, $02, $00, $38, $0A, $02, $00
db $04, $0B, $20, $00, $24, $0B, $40, $00
db $EF, $00, $02, $00, $F1, $00, $02, $00
db $64, $0B, $10, $00, $74, $0B, $10, $00
db $42, $0A, $40, $00, $29, $09, $02, $00
db $2B, $09, $02, $00, $2D, $09, $02, $00
db $23, $09, $02, $00, $15, $05, $3E, $00
db $5B, $09, $08, $00, $63, $09, $08, $00
db $4A, $0D, $02, $00, $89, $09, $02, $00
db $1B, $09, $02, $00, $19, $09, $02, $00
db $02, $0B, $02, $00, $FF, $FF
CODE_80895F:
JSR CODE_808963 ;$80895F \
RTL ;$808962 /
CODE_808963:
STA $4302 ;$808963 \
STY $4305 ;$808966 |
LDA #$1801 ;$808969 |
STA $4300 ;$80896C |
SEP #$30 ;$80896F |
STX $4304 ;$808971 |
LDA #$01 ;$808974 |
STA $420B ;$808976 |
REP #$30 ;$808979 |
RTS ;$80897B /
CODE_80897C:
PHB ;$80897C \
JSR CODE_808988 ;$80897D |
PLB ;$808980 |
RTL ;$808981 /
CODE_808982:
JSL CODE_809025 ;$808982 \
BRA CODE_808A00 ;$808986 /
CODE_808988:
PHK ;$808988 \
PLB ;$808989 |
SEP #$20 ;$80898A |
LDA #$01 ;$80898C |
CODE_80898E: ; |
BIT $4212 ;$80898E |
BNE CODE_80898E ;$808991 |
REP #$20 ;$808993 |
LDA $05FB ;$808995 |
BNE CODE_808982 ;$808998 |
LDA $0B02 ;$80899A |
AND #$0020 ;$80899D |
BEQ CODE_8089C9 ;$8089A0 |
LDA $0927 ;$8089A2 |
BPL CODE_8089C2 ;$8089A5 |
LDA #$0100 ;$8089A7 |
CLC ;$8089AA |
ADC $0927 ;$8089AB |
STA $0927 ;$8089AE |
LDA #$0002 ;$8089B1 |
TSB $0B02 ;$8089B4 |
LDA $0510 ;$8089B7 |
AND #$EFFF ;$8089BA |
STA $0510 ;$8089BD |
BRA CODE_808A3C ;$8089C0 /
CODE_8089C2:
SEC ;$8089C2 \
SBC $0925 ;$8089C3 |
STA $0927 ;$8089C6 |
CODE_8089C9: ; |
LDA $4218 ;$8089C9 |
TAX ;$8089CC |
EOR $0502 ;$8089CD |
AND $4218 ;$8089D0 |
STA $0506 ;$8089D3 |
TXA ;$8089D6 |
EOR $0502 ;$8089D7 |
AND $0502 ;$8089DA |
STA $050A ;$8089DD |
STX $0502 ;$8089E0 |
LDA $421A ;$8089E3 |
TAX ;$8089E6 |
EOR $0504 ;$8089E7 |
AND $421A ;$8089EA |
STA $0508 ;$8089ED |
TXA ;$8089F0 |
EOR $0504 ;$8089F1 |
AND $0504 ;$8089F4 |
STA $050C ;$8089F7 |
STX $0504 ;$8089FA |
JSR CODE_808BB0 ;$8089FD |
CODE_808A00: ; |
LDA $060D ;$808A00 |
BNE CODE_808A26 ;$808A03 |
LDA $0502 ;$808A05 |
STA $050E ;$808A08 |
LDA $0506 ;$808A0B |
STA $0510 ;$808A0E |
BRA CODE_808A3C ;$808A11 /
CODE_808A13:
LDA $060F ;$808A13 \
ASL A ;$808A16 |
TAX ;$808A17 |
LDA $0502,x ;$808A18 |
STA $050E ;$808A1B |
LDA $0506,x ;$808A1E |
STA $0510 ;$808A21 |
BRA CODE_808A3C ;$808A24 /
CODE_808A26:
DEC A ;$808A26 \
BNE CODE_808A13 ;$808A27 |
LDA $08A2 ;$808A29 |
AND #$0002 ;$808A2C |
TAX ;$808A2F |
LDA $0502,x ;$808A30 |
STA $050E ;$808A33 |
LDA $0506,x ;$808A36 |
STA $0510 ;$808A39 |
CODE_808A3C: ; |
LDA $0B02 ;$808A3C |
AND #$0010 ;$808A3F |
BEQ CODE_808A76 ;$808A42 |
LDA $050E ;$808A44 |
XBA ;$808A47 |
AND #$000F ;$808A48 |
ASL A ;$808A4B |
TAX ;$808A4C |
LDA.l DATA_808B90,x ;$808A4D |
EOR $050E ;$808A51 |
AND #$0F00 ;$808A54 |
EOR $050E ;$808A57 |
STA $050E ;$808A5A |
LDA $0510 ;$808A5D |
XBA ;$808A60 |
AND #$000F ;$808A61 |
ASL A ;$808A64 |
TAX ;$808A65 |
LDA.l DATA_808B90,x ;$808A66 |
EOR $0510 ;$808A6A |
AND #$0F00 ;$808A6D |
EOR $0510 ;$808A70 |
STA $0510 ;$808A73 |
CODE_808A76: ; |
LDA $08C2 ;$808A76 |
AND #$0040 ;$808A79 |
BNE CODE_808AB4 ;$808A7C |
LDA #$0010 ;$808A7E |
TRB $08C4 ;$808A81 |
BNE CODE_808A8D ;$808A84 |
LDA $08C2 ;$808A86 |
AND #$0040 ;$808A89 |
RTS ;$808A8C /
CODE_808A8D:
LDA #$0040 ;$808A8D \
TSB $08C2 ;$808A90 |
LDA #$075E ;$808A93 |
JSL CODE_B58021 ;$808A96 |
LDA #$065E ;$808A9A |
JSL CODE_B58021 ;$808A9D |
LDA #$055E ;$808AA1 |
JSL CODE_B58021 ;$808AA4 |
LDA #$045E ;$808AA8 |
JSL CODE_B58021 ;$808AAB |
LDA $2A ;$808AAF |
STA $0636 ;$808AB1 |
CODE_808AB4: ; |
LDA $0510 ;$808AB4 |
AND #$1000 ;$808AB7 |
BNE CODE_808AED ;$808ABA |
LDA $D5 ;$808ABC |
SEC ;$808ABE |
SBC #$0001 ;$808ABF |
STA $D5 ;$808AC2 |
LDA $D7 ;$808AC4 |
SBC #$0000 ;$808AC6 |
STA $D7 ;$808AC9 |
LDA $0510 ;$808ACB |
AND #$2000 ;$808ACE |
BEQ CODE_808AE6 ;$808AD1 |
LDA $08A8 ;$808AD3 |
JSL CODE_BB825C ;$808AD6 |
BCC CODE_808AE6 ;$808ADA |
LDA #$0040 ;$808ADC |
TRB $08C2 ;$808ADF |
JML CODE_BBBDC4 ;$808AE2 /
CODE_808AE6:
JSR CODE_808B19 ;$808AE6 \
LDA #$0001 ;$808AE9 |
RTS ;$808AEC /