forked from Pigu-A/nobankskank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_botb_logo.asm
executable file
·899 lines (867 loc) · 12.4 KB
/
1_botb_logo.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
; Part 1: BotB logo
.include "gvars.asm"
Ma = GVarsZPBegin-24
Mb = Ma+2
SDMCTL = $22f
SDLSTL = $230
dlist = $bc20
chardat = $bc40
charset = $c000
texArea = $d800 ; must be page-aligned
os_char = $e000
* = partEntry
start
; move char rom into ram
mvchr
ldx #0
ldy #4
_loop
mva #$fb, rPORTB
lda os_char, x
_src = *-2
sta scratch, x
inx
bne _loop
lda #124 ; wait until out of screen
- cmp rVCOUNT
bne -
mva #$fa, rPORTB
- lda scratch, x
sta charset, x
_dst = *-2
inx
bne -
inc _src+1
inc _dst+1
dey
bne _loop
mva #>(charset+$400), curpage
sta rCHBASE
; make a copy to charset+$400 too for double buffering
; ldx #0
ldy #4
- lda charset, x
_src2 = *-2
sta charset+$400, x
_dst2 = *-2
inx
bne -
inc _src2+1
inc _dst2+1
dey
bne -
lda #>SineTable
jsr loadSineTable
mva >#QSTable, zARG0
mva #192, zARG1
jsr initQSTable
; install vector to Ma and Mb instead since zARG2-3 is already occupied
mva >#QSTable, Ma+1
sta Mb+1
initcharmap
; force 40x24 hires char mode with data at $bc40
; (where dos display data without cart would be)
ldy #size(botbDlist0)
- lda botbDlist0-1, y
sta dlist-1, y
dey
bne -
mva #0, rHPOSP0
sta rHPOSP1
sta rHPOSP2
sta rHPOSP3
sta rPRIOR ; combine all plyer colors
mva #3, rSIZEP0 ; quad width
sta rSIZEP1
sta rSIZEP2
sta rSIZEP3
mva #$2a, SDMCTL ; enable player and dlist dma, normal pf, double line player
mva #$02, rGRACTL ; turn on player
mva #>(player0-$200), rPMBASE
mwa #dlist, SDLSTL
mva #$ca, COLOR+5 ; default a8 palette
sta rCOLPF1
mva #$94, COLOR+6
; special case: if there's internal basic before,
; just copy the data from $9c40
lda $6
beq putlogotiles
ldx #0
- mva $9c40,x, chardat,x
mva $9d30,x, chardat+240,x
mva $9e20,x, chardat+480,x
mva $9f10,x, chardat+720,x
inx
cpx #240
bne -
initplayers
; make color masks as player graphics
tax
ldy #16
jsr blankpyrs
ldy #28
jsr fillpyrs
ldy #4
jsr blankpyrs
ldy #32
jsr fillpyrs
ldy #4
jsr blankpyrs
ldy #28
jsr fillpyrs
ldy #16
jsr blankpyrs
putlogotiles
; time to put botb logo in the middle of the screen
ldy #0
ldx #0
- lda botbFrame, x
sta coord40(15,7,chardat), y
_dst = *-2
iny
cpy #10
bne +
addw #40, _dst
ldy #0
+ inx
cpx #100
bne -
unpackTex
mva #$80, zTMP0
ldx #4
- ldy #0
- lda botbTex,y
_src = *-2
and zTMP0
bne +
lda #0
geq ++
+ lda #3
+ sta texArea,y
_dst = *-2
iny
cpy #64
bne -
inc _dst+1
ldy #0
lsr zTMP0
bcc --
ror zTMP0
lda _src
add #64
sta _src
dex
bne --
putlogobitmap
; o-------------u
; | Ax,y
; | ^
; | / \<-----view
; |Cx,y< >Bx,y
; | \ /
; | v
; v texture
Ay = Mb+2 ; starting texture pos
Ax = Ay+2
By = Ay+4 ; texture pos to advance each view x change
Bx = Ay+6
Cy = Ay+8 ; texture pos to advance each view y change
Cx = Ay+10
tt = Ay+12 ; temp texture pointers
txy = zARG2
txx = zARG3
tyy = zTMP0 ; temp texture positions
tyx = zTMP2
tyt = zTMP4
by = zTMP6 ; current charmap pos
bx = zTMP7 ;
mwa #0, Ax
mwa #0, Ay
mwa #$100, Bx
mwa #0, By
mwa #0, Cx
mwa #$200, Cy
mwa #vbi, rNMI
mva #0, rIRQEN
mva #$40, rNMIEN ; vblank
cli
placeroto
; now time to draw rotozoomer
lda Ax
sta txx
sta tyx
tay
lda Ax+1
sta txx+1
sta tyx+1
tax
lda Ay
sta txy
sta tyy
lda Ay+1
sta txy+1
sta tyy+1
; multiply Bx,y by 4 since we are skipping 4 pixels when moving to the next column
lda Bx+1
sta _bx4hi
lda Bx
asl a
rol _bx4hi
asl a
rol _bx4hi
sta _bx4lo
lda By+1
sta _by4hi
lda By
asl a
rol _by4hi
asl a
rol _by4hi
sta _by4lo
lda #<charset
rotoBaseLo = *-1
sta rotoBaseX
sta rotoBaseX2
lda #>(charset+$200)
rotoDestHi = *-1
eor #4 ; flip the page
sta rotoBaseX+1
sta rotoBaseX2+1
sta rotoDestHi
lda #0
curpage = *-1
eor #4
sta curpage
; wait for vblank to properly display the finished page
sta rNMIRES
- bit rNMIST
bvc -
jsr scene0 ; update scene-specific variables
scefunc = *-2
lda #8
rotoWidth = *-1
sta bx
mva #0, by
_loop
txa ; 2
add #>texArea ; 4
sta tt+1 ; 3
lda tyy+1 ; 3
sta tt ; 3
_x := 2
.rept 3
tya ; 2
adc Bx ; 3
tay ; 2
txa ; 2
adc Bx+1 ; 3
tax ; 2
and #31 ; 2
add #>texArea ; 4
sta tt+_x+1 ; 3
.if _x == 2
lda tyy ; 3
.else
lda tyt
.fi
add By ; 5
sta tyt ; 3
lda tt+_x-2 ;3
adc By+1 ; 3
and #63 ; 2
sta tt+_x ; 3
_x := _x + 2
.next ; 45*3 = 135
ldy #0 ; 2
lda (tt),y ; 5
asl a ; 2
asl a ; 2
eor (tt+2),y ; 5
asl a ; 2
asl a ; 2
eor (tt+4),y ; 5
asl a ; 2
asl a ; 2
eor (tt+6),y ; 5
ldy by ; 3
sta $ffff,y ; 5
rotoBaseX = *-2
iny ; 2
sta $ffff,y ; 5
rotoBaseX2 = *-2
iny ; 2
cpy #64 ; 2
rotoHeight = *-1
beq + ; 2
sty by ; 3
lda tyx ; 3
adc Cx ; 3
sta tyx ; 3
tay ; 2
lda tyx+1 ; 3
adc Cx+1 ; 3
and #31 ; 2
sta tyx+1 ; 3
tax ; 2
lda tyy ; 3
add Cy ; 5
sta tyy ; 3
lda tyy+1 ; 3
adc Cy+1 ; 3
and #63 ; 2
sta tyy+1 ; 3
jmp _loop ; 3
; = 257
; advance to next column
+ dec bx
beq ++ ; finished
mva #0, by
lda txx
add #0
_bx4lo = *-1
sta txx
sta tyx
tay
lda txx+1
adc #0
_bx4hi = *-1
and #31
sta txx+1
sta tyx+1
tax
lda txy
add #0
_by4lo = *-1
sta txy
sta tyy
lda txy+1
adc #0
_by4hi = *-1
and #63
sta txy+1
sta tyy+1
lda rotoBaseX
add rotoHeight
sta rotoBaseX
sta rotoBaseX2
bcc +
inc rotoBaseX+1
inc rotoBaseX2+1
+ jmp _loop
updateA
; TODO: properly animate this
+ lda haltroto
beq placeroto
lda Ay
add #$33
sta Ay
lda Ay+1
adc #3
and #63
sta Ay+1
lda Ax
add #$44
sta Ax
lda Ax+1
adc #4
and #31
sta Ax+1
updateBC
mva #0, Bx+1
sta By+1
sta Cx+1
ldx #$90
zooi = *-1
inx
inx
inx
stx zooi
lda SineTable,x
asr a
asr a ; -32~31
add #40 ; 8~71
tay
lda #0
ang = *-1
add #7
sta ang
tax
lda SineTable,x
asr a
sta Ma
neg
sta Mb
lda (Ma),y
sub (Mb),y
bpl +
dec By+1
+ asl a
rol By+1
asl a
rol By+1
asl a
rol By+1
asl a
rol By+1
sta By
txa
add #64 ; change to cos(x)
tax
lda SineTable,x
asr a
sta Ma
neg
sta Mb
lda (Ma),y
sub (Mb),y
bpl +
dec Bx+1
+ asl a
rol Bx+1
asl a
rol Bx+1
asl a
rol Bx+1
sta Bx
sta Cy
mva Bx+1, Cy+1
asl Cy
rol Cy+1
txa
add #64 ; change to -sin(x)
tax
lda SineTable,x
asr a
sta Ma
neg
sta Mb
lda (Ma),y
sub (Mb),y
bpl +
dec Cx+1
+ asl a
rol Cx+1
asl a
rol Cx+1
asl a
rol Cx+1
sta Cx
txa
jmp placeroto
blankpyrs
lda #0
- sta player0,x
sta player1,x
sta player2,x
sta player3,x
inx
dey
bne -
rts
fillpyrs
lda #$3f
sta player0,x
lda #$ff
sta player1,x
sta player2,x
lda #$fc
sta player3,x
inx
dey
bne fillpyrs
rts
vbi
sta nmiA
bit rNMIST
bpl +
jmp dli1
VDSLST = *-2
+ stx nmiX
sty nmiY
mwa SDLSTL, rDLISTL
mva SDMCTL, rDMACTL
mva curpage, rCHBASE
ldx #8
- mva COLOR,x, rCOLPM0,x
dex
bpl -
jsr updateMusic
ldx nmiX
ldy nmiY
retdli
lda nmiA
rti
dli1 ; center
lda #2
sta rWSYNC
sta rCHACTL
lda dlicolupd
beq +
mva COLOR+9, rCOLPM0
mva COLOR+10, rCOLPM1
mva COLOR+11, rCOLPM2
mva COLOR+12, rCOLPM3
mva COLOR+13, rCOLPF2
+ mwa #dli2, VDSLST
gne retdli
dli2 ; bottom
lda #6
sta rWSYNC
sta rCHACTL ; xflip tiles on non-center rows
lda dlicolupd
beq +
mva COLOR+14, rCOLPM0
mva COLOR+15, rCOLPM1
mva COLOR+16, rCOLPM2
mva COLOR+17, rCOLPM3
mva COLOR+18, rCOLPF2
+ mwa #dli1, VDSLST
gne retdli
scene0
lda zCurMsxOrd
beq _skip
inc haltroto
mwa #scene1, scefunc
_skip
rts
haltroto .byte 0
dlicolupd .byte 0
scene1
lda _siz
cmp #9
bcc _skip
mva #$00, zTMP0
jsr _box
_skip
inc _siz
lda _siz
cmp #41
beq _skip2
mva #$80, zTMP0
jsr _box
rts
_skip2
mva #$c0, rNMIEN
mwa #scene2, scefunc
rts
_siz .byte 8
_box
lda _siz
lsr a
sta zTMP1
lda #19
sub zTMP1
tay
lda #11+17
sub zTMP1
tax
mva chardataddrL,x, zTMP1
mva chardataddrH,x, zTMP2
mva _siz, zTMP3
lda zTMP0
- sta (zTMP1),y
iny
dec zTMP3
bne -
mva _siz, zTMP3
- lda zTMP0
sta (zTMP1),y
inx
mva chardataddrL,x, zTMP1
mva chardataddrH,x, zTMP2
dec zTMP3
bne -
mva _siz, zTMP3
lda zTMP0
- sta (zTMP1),y
dey
dec zTMP3
bne -
tya
bmi +
mva _siz, zTMP3
- lda zTMP0
sta (zTMP1),y
dex
mva chardataddrL,x, zTMP1
mva chardataddrH,x, zTMP2
dec zTMP3
bne -
+ rts
scene2
lda zCurMsxOrd
cmp #$02
bne _skipall
lda zCurMsxRow
cmp #32
bcc _skipfade
dec _frame
bne _skipfade
mva #6, _frame
lda COLOR+5
and #$f
cmp #$f
beq +
tax
inx
stx COLOR+5
+ lda COLOR+6
and #$f
beq +
dec COLOR+6
+ lda COLOR+8
and #$f
beq _skipfade
dec COLOR+8
_skipfade
lda zCurMsxRow
cmp #-1
_last = *-1
sta _last
beq _skipall
and #7
bne _skipall
jmp _0
_ptr = *-2
_skipall
rts
_0 ; left
mva #$50, zTMP0
mva #6, zTMP2
mva #25, zTMP3
ldx #0
jsr _draw
mwa #_1, _ptr
mva #$c0, zTMP0
mva #8, zTMP2
mva #25, zTMP3
ldx #7
jmp _draw
_1 ; downright
mva #$40, zTMP0
mva #8, zTMP2
mva #41, zTMP3
mva #$88, _cmd ; dey
ldx #25
jsr _draw
mwa #_2, _ptr
mva #$c0, zTMP0
mva #6, zTMP2
mva #41, zTMP3
ldx #34
jmp _draw
_2 ; up
mwa #_3, _ptr
mva #$c0, zTMP0
mva #8, zTMP2
mva #23, zTMP3
ldx #16
jmp _draw
_3 ; right
mva #$c0, zTMP0
mva #8, zTMP2
mva #25, zTMP3
mva #$c8, _cmd ; iny
ldx #25
jsr _draw
mwa #_4, _ptr
mva #$40, zTMP0
mva #6, zTMP2
mva #25, zTMP3
ldx #34
jmp _draw
_4 ; downleft
mva #$d0, zTMP0
mva #6, zTMP2
mva #41, zTMP3
mva #$88, _cmd ; dey
ldx #0
jsr _draw
mwa #_5, _ptr
mva #$40, zTMP0
mva #8, zTMP2
mva #41, zTMP3
ldx #7
jmp _draw
_5 ; upright
mva #$40, zTMP0
mva #8, zTMP2
mva #23, zTMP3
ldx #25
jsr _draw
mwa #_6, _ptr
mva #$c0, zTMP0
mva #6, zTMP2
mva #23, zTMP3
ldx #34
jmp _draw
_6 ; down
mwa #_7, _ptr
mva #$c0, zTMP0
mva #8, zTMP2
mva #41, zTMP3
ldx #16
jmp _draw
_7 ; upleft
mva #$d0, zTMP0
mva #6, zTMP2
mva #23, zTMP3
ldx #0
jsr _draw
mwa #scene2_0, scefunc
mva #$40, zTMP0
mva #8, zTMP2
mva #23, zTMP3
ldx #7
jmp _draw
_frame .byte 2
_draw
- ldy zTMP3
mva #8, zTMP1
- mva chardataddrL,y, _dst
mva chardataddrH,y, _dst+1
mva zTMP0, $ffff,x
_dst = *-2
iny
_cmd = *-1
inc zTMP0
dec zTMP1
bne -
inx
dec zTMP2
bne --
rts
scene2_0 ; end
lda zCurMsxOrd
cmp #$03
bcc +
lda zCurMsxRow
bne +
mva #$28, rHPOSP0
mva #$4c, rHPOSP1
mva #$94, rHPOSP2
mva #$b8, rHPOSP3
inc dlicolupd
mwa #scene3, scefunc
+ rts
scene3
lda zCurMsxRow
and #7
cmp #-1
_last = *-1
sta _last
beq ++
ldx #0
ldy #5
cmp #0
beq +
ldx #5
ldy #6
cmp #4
beq +
ldx #11
ldy #4
cmp #6
bne ++
+ sty zTMP0
- ldy _colp,x
lda rRANDOM
and #$f2
sta COLOR,y
inx
dec zTMP0
bne -
+ lda zCurMsxOrd
cmp #$04
bcc _skip
lda zCurMsxRow
cmp #32
bne _skip
dec dlicolupd
mva #0, rHPOSP0
sta rHPOSP1
sta rHPOSP2
sta rHPOSP3
mwa #scene4, scefunc
_skip
rts
_colp .byte 1,2,13,15,16,0,3,10,11,14,17,6,9,12,18
COLOR .fill 19
scene4
lda curVol
and #$0f
sta COLOR+5
lda curVol
and #$f0
bne +
cmp #0
_last = *-1
beq +
lda rRANDOM
and #$f0
sta COLOR+6
sta COLOR+8
+ sta _last
_skipcol
lda zCurMsxOrd
cmp #$05
bcc _skip
mva #0, rCOLPF2
sta rCOLBK
sta rSIZEP0
sta rSIZEP1
sta rSIZEP2
sta rSIZEP3
mva #2, rCHACTL
pla ; pop return address so the stack points
pla ; to the loader's return address instead
_skip
rts
botbFrame
.enc "a8screen"
.text "/========\"
_x := $40
.rept 8
.text "H"
.rept 8
.byte _x
_x := _x + 8
.next
.text "H"
_x := _x - 63
.next
.text "\========/"
botbDlist0 .block
.byte $70, $70, $70 ; 24 blank lines
.byte $42 ; 24 mode 2
.word chardat
.fill 5, $02
.byte $82
.fill 8, $02
.byte $82
.fill 8, $02
.byte $41 ; jvb
.word dlist
.bend
chardataddr = chardat + range(0,40*24,40)
dumm = $f800
chardataddrL
.fill 17, <dumm
.byte <(chardataddr)
.fill 17, <dumm
chardataddrH
.fill 17, >dumm
.byte >(chardataddr)
.fill 17, >dumm
.align $100
botbTex .binary "gfx/botb.t.1bpp"
.align $400
.union
scratch .fill $100
QSTable .fill $200
.endu
player0 .fill $80
player1 .fill $80
player2 .fill $80
player3 .fill $80
.warn format("Part 1's memory usage: %#04x - %#04x", start, *)