This repository has been archived by the owner on Dec 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
/
HATENM.A65
2529 lines (2524 loc) · 30.4 KB
/
HATENM.A65
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
;
;
; <NINJA HATTORI KUN>
; enemy sub
;
tekini:
ldx #TEKMAX-1
lda #$ff
tekilp: sta tekflg,x
dex
bpl tekilp
lda scrole
sta oldsce
ldx #0
stx teknof
stx catcnt
stx blkcnt
stx tekdth
dex
stx nowtek
rts
;
tkgttb:
db 0,1,2,3,4,4,4,4,4,5,5,5,5,5,6,7
;
tkgtim:
JTBL kmgtim ;kaminari
JTBL krgtim ;karasu tengu
JTBL obgtim ;obake
JTBL rbgtim ;robo dori
JTBL clgtim ;kumonori
JTBL blgtim ;kuro ninja
JTBL kegtim ;kemumaki
JTBL hkgtim ;hakubyusai
;
rbgtim: ;robo dori
obgtim: ;obake
ldy nanido
lda timer
and rbgtdt,y ;#$3f
beq oktgen
rts
;
rbgtdt:
db $ff,$7f,$3f,$1f
;
kmgtim: ;kaminari
lda timer
and #$3f
bne owari
lda thnfir
cmp #4
bcc oktgen
rts
krgtim: ;karasutengu
lda krsfir
beq oktgen
rts
;
hkgtim: ;hakbyousai
lda hakfir
beq oktgen
rts
;
clgtim: ;kumonori
blgtim: ;kuro ninja
lda kouwai
beq blgt10
dec kouwai
rts
blgt10: lda nxtblk
beq blgt20
dec nxtblk
rts
blgt20: ldy nanido
lda blcndt,y ;lda #$10
sta nxtblk
inc tektim
rts
;
blcndt:
db $40,$30,$20,$10
;
kegtim: ;kemumaki
lda tekfir
bne owari
lda teknof
bne owari
oktgen: inc tektim
owari:
tekgr1: rts
;
tekgen:
lda oldsce
cmp scrole
beq tekg10
lda scrole
sta oldsce
lda area
asl a
asl a
asl a
asl a
clc
adc scrole ;manxh ;scrole
tay
lda emytbl,y
sta nowtek
tay
lda tkgttb,y
sta tekgrp
lda #0
sta tekfir
sta kouwai
sta nxtblk
sta blkcnt
sta thnfir
sta krsfir
sta hakfir
lda nowtek
cmp #15
bne tekg09
lda #4
sta muscmd
bne tekg10 ;<bra>
tekg09:
lda muscmd
and #$0f
cmp #4
bne tekg10
lda #2
sta muscmd
;
tekg10: lda teknof ;hakbyu karaten
bne tekgr1
ldy nowtek ; lda nowtek
iny ; cmp #$ff
beq tekgr1
;
lda #0
sta tektim
lda tekgrp
asl a
tay
INDCAL tkgtim,y
lda tektim
beq tekgrt
;
lda kanflg
bne tekgrt
lda shnflg
cmp #$80
beq tekgrt
ldx #TEKMAX-1
tekglp:
ldy tekflg,x ; lda tekflg,x
iny ; cmp #$ff
beq tekgok
dex
bpl tekglp
tekgrt: rts
;
tekgok:
lda #0
sta tekxcn,x
sta tekycn,x
sta teksta,x
sta tekstp,x
sta tekjpt,x
lda nowtek
cmp #$ff
beq tekgrt
sta tekflg,x
asl a
tay
INDJMP tekgtb,y
;
tekgtb:
JTBL thngen ;kaminari tsukai ;0
JTBL kargen ;karasu tengu
JTBL obkgen ;obake
JTBL robgen ;robo dori
JTBL km0gen ;kumonori type 0 ;4
JTBL km1gen ;///////////// 1
JTBL km2gen ;///////////// 2
JTBL km3gen ;///////////// 3
JTBL km4gen ;///////////// 4
JTBL bl0gen ;kuro ninja type 0 ;9
JTBL bl1gen ;/////////////// 1
JTBL bl1gen ;bl2gen ;/////////////// 2
JTBL bl3gen ;/////////////// 3
JTBL bl4gen ;/////////////// 4
JTBL kemgen ;kemumaki ;14
JTBL hakgen ;hakubyusai
;
thngen:
lda #$01
sta tekdir,x
jsr tekxst
lda #$50
sta teky,x
inc thnfir
rts
;
kargen: lda #%0000_1101
sta tekdir,x
jsr tekxst
lda #$50
sta teky,x
lda #1
sta teknof
inc krsfir
rts
;
obkgen:
lda #1
sta tekdir,x
lda #$50
sta teky,x
jsr tekxst
lodhat: ;load hattori position and direction set
lda tekdir,x
and #$f5
sta tekdir,x
;
lda manxl
sta oldhxl,x
lda manxh
sta oldhxh,x
lda manxl
cmp tekxl,x
bcc lodh10
lda tekdir,x
ora #$02
sta tekdir,x
lodh10:
lda many
sta oldhy,x
cmp teky,x
bcc lodhrt
lda tekdir,x
ora #$08
sta tekdir,x
lodhrt: rts
;
robgen: ;robo dori
lda #%0000_1101 ;$09
sta tekdir,x
lda #$40
sta teky,x
jmp tekxst
;
km0gen: ;kumonori type 0
jsr blcup
lda #$01
sta tekdir,x
lda #$80
sta teky,x
jmp tekxst
;
km1gen:
jsr blcup
lda #$01
sta tekdir,x
lda #$50
sta teky,x
jmp tekxst
;
km2gen:
jsr blcup
lda #$01
sta tekdir,x
lda score+6
asl a
asl a
clc
adc #$50
sta teky,x
jmp tekxst
;
km3gen:
jsr blcup
lda #%0000_1101
sta tekdir,x
lda #$50
sta teky,x
jmp tekxst
;
km4gen: ;kumonori type 4
; jsr blcup
lda #$03
sta tekdir,x
lda #$80
sta teky,x
lda scrolh
sta tekxl,x
lda scrole
sta tekxh,x
jmp blcup
; rts
;
bl0gen:
bl1gen:
bl3gen:
jsr blcup
inc catcnt
lda catcnt
cmp #12
bcc blsok
;
lda #0
sta catcnt
ldy catokf
bne blsok
sta catatc
lda #17
sta tekflg,x
;
blsok: lda #$01
sta tekdir,x
lda #$b0
sta teky,x
jmp tekxst
;
;
kemgen:
lda #%0000_1101
sta tekdir,x
lda #$40
sta teky,x
lda #1
sta teknof
inc tekfir
jmp tekxst
;
;
hakgen:
lda #%0000_0000
sta tekdir,x
sta hakatc ; hakatc <= 0
lda scrole
sta tekxh,x
lda scrolh
clc
adc #$e0
sta tekxl,x
lda #$b0
sta teky,x
lda #1
sta teknof
inc hakfir
rts
;
tekxst:
lda scrolh
clc
adc #$ff
sta tekxl,x
lda scrole
adc #0
sta tekxh,x
bl4gen: rts
;
blcup:
inc blkcnt
lda blkcnt
cmp #10
bcc blcurt
lda #240
sta kouwai
lda #0
sta blkcnt
blcurt: rts
;
tekmov:
jsr tekgen
ldx #TEKMAX-1
tekmlp: stx cc
lda tekflg,x
cmp #$ff
beq tekmsk
cmp #16
beq tekm10
ldy kanflg ;kanashibari
bne tekmcl
tekm10: asl a
tay
INDCAL tekmtb,y
;
tekmcl: jsr tektam
jsr tekdog
jsr mantek
;
ldx cc
lda tekxl,x
sta clipl
lda tekxh,x
sta cliph
jsr clip
bcc tekmsk
ldy tekflg,x
lda #$ff
sta tekflg,x
;
cpy #1
beq tekmtn
cpy #14
beq tekmtn
cpy #15
bne tekmsk
tekmtn: lda #$0
sta teknof
tekmsk: ldx cc
dex
bpl tekmlp
rts
;
tekmtb:
JTBL thnmov ;kaminari kozou
JTBL karmov ;karasu tengu
JTBL obkmov ;obake
JTBL robmov ;robo dori
JTBL km0mov ;kumonori type 0
JTBL km1mov ;///////////// 1
JTBL km2mov ;///////////// 2
JTBL km3mov ;///////////// 3
JTBL km4mov ;///////////// 4
JTBL bl0mov ;kuro ninja type 0
JTBL bl1mov ;/////////////// 1
JTBL bl1mov ;bl2mov ;/////////////// 2
JTBL bl3mov ;/////////////// 3
JTBL bl4mov ;/////////////// 4
JTBL kemmov ;kemumaki
JTBL hakmov ;hakubyusai
JTBL tekyra ;yarare 16
JTBL catmov ;kagechiyo 17
;
tekyra: ;yarare
dec teksta,x
bne tekyrt
lda #$ff
sta tekflg,x
tekyrt: rts
;
catmov:
lda #1
sta dltdat
jsr tekhmv
;
ldy tekflg,x
iny
bne catm02
tya
sta catokf
;
catm02: inc tekstp,x
lda tekdir,x
and #%0001_0000
bne catm10
lda tekxl,x
sec
sbc manxl
tay
lda tekxh,x
sbc manxh
cpy #$40
sbc #0
bcs catm10
lda tekdir,x
ora #%0011_0000
sta tekdir,x
lda #0
sta tekjpt,x
catm10:
jsr tekjmp
karmrt:
rts
;
thnmov: ;kaminari
lda #0
jsr arexmv
inc teksta,x
lda teksta,x
and #$0f
bne thnmrt
lda #1
jsr misgen
thnmrt: rts
;
karmov: ;karasu
lda #1
jsr arexmv
ldy tekflg,x ; lda tekflg,x
iny ; cmp #$ff
bne karm10
lda #0
sta teknof
rts
karm10: inc tekstp,x
lda tekstp,x
and #$0f
bne karm12
lda #0
jsr misgen
karm12: lda tekycn,x
beq karm11
dec tekycn,x
rts
karm11: jsr rnd
and #1
sta tekycn,x
;
lda #0
jmp areymv
; jsr areymv
; rts
;
;
obkmov: ;obake
;xmov
lda tekxcn,x
beq obkm01
dec tekxcn,x
jmp obkm10
obkm01: lda #1
sta tekxcn,x
lda tekxh,x
cmp manxh
bne obkm02
lda oldhxl,x
cmp tekxl,x
beq obkm10
obkm02: lda #0
jsr arexmv
obkm10: ;ymov
lda tekycn,x
beq obkm11
dec tekycn,x
jmp obkm20
obkm11: lda #1
sta tekycn,x
lda tekxh,x
cmp manxh
bne obkm12
lda oldhy,x
cmp teky,x
beq obkm20
obkm12: lda #0
jsr areymv
obkm20:
lda oldhxl,x
cmp tekxl,x
bne obkmrt
lda oldhy,x
cmp teky,x
bne obkmrt
jmp lodhat
obkmrt:
rts
;
robmov: ;robo dori
lda #0
jsr arexmv
lda dirchg
beq robm03
lda tekdir,x
and #%1111_0011
sta tekdir,x
lda #0
sta teksta,x
jmp robm10
robm03: inc teksta,x
lda tekdir,x
and #%1111_1011
sta tekdir,x
lda teksta,x
sec
sbc #$40
cmp #$80
bcs robm10
lda tekdir,x
ora #%0000_0100
sta tekdir,x
robm10: ;ymov
lda teksta,x
and #$0f
bne robm11
lda tekdir,x
eor #%0000_1000
sta tekdir,x
and #%0000_1000
beq robm11
lda teksta,x
sbc #$40
cmp #$80
bcs robm11
lda #3 ;3
jsr misgen
robm11: lda tekdir,x
and #%0000_0100
beq robmrt
lda #1
jmp areymv
; rts
;
km4mov:
km0mov: ;kumonori type 0
lda #1
sta dltdat
jsr tekhmv
inc tekstp,x
lda tekstp,x
cmp #(96 / 2)
bcc km0m10
and #$0f
bne km0m10
lda teksta,x
bne km0m01
lda #0
jsr misgen
km0m01: inc teksta,x
lda teksta,x
cmp #4
bcc km0m10
lda #4
sta teksta,x
km0m10:
lda teksta,x
tay
lda km0ymd,y
cmp #$ff
beq km0mrt
sta dltdat
jsr tekvmv
lda teky,x
cmp #$8
bcs km0mrt
km0med: lda #$ff
sta tekflg,x
km1mrt:
robmrt:
km0mrt: rts
;
km0ymd: db $ff,0,1,2,3
;
km1mov:
lda #0
sta dltdat
jsr tekhmv
lda tekdir,x
and #$1111_0011
sta tekdir,x
inc teksta,x
lda teksta,x
sec
sbc #$58
cmp #$50
bcs km1m10 ;rt
lda tekdir,x
ora #%0000_1100
sta tekdir,x
lda #0
sta dltdat
jsr tekvmv
km1m10: lda teksta,x
cmp #128
bne km1mrt
lda #0
jmp misgen
;
km2mov:
ldy #0
lda teksta,x
bpl km2m01
ldy #2
km2m01: tya
sta dltdat
jsr tekhmv
lda teksta,x
bmi km2mrt
inc teksta,x
lda teksta,x
and #$7f
bne km2mrt
lda tekdir,x
ora #%0000_0010
sta tekdir,x
lda #0
jmp misgen
km2mrt: rts
;
km3mov:
lda #0
sta dltdat
jsr tekhmv
inc teksta,x
lda teksta,x
and #$1f
bne km3m10
lda tekdir,x
eor #%0000_1000
sta tekdir,x
km3m10:
lda #0
sta dltdat
jsr tekvmv
lda teksta,x
cmp #128
bne km3mrt
lda #0
jmp misgen
;
bl0mov:
lda #0 ;1
sta dltdat
jmp tekhmv
;
bl1mov:
lda #0 ;1
sta dltdat
jsr tekhmv
inc tekstp,x
lda tekdir,x
and #%0001_0000
bne bl1m10
lda tekxl,x
sec
sbc manxl
tay
lda tekxh,x
sbc manxh
cpy #$40
sbc #0
bcs bl1m10
lda tekdir,x
ora #%0011_0000
sta tekdir,x
lda #0
sta tekjpt,x
bl1m10:
jmp tekjmp
; rts
;
bl3mov:
ldy #0 ;1
lda teksta,x
beq bl3m01
ldy #2
bl3m01: sty dltdat
jsr tekhmv
lda teksta,x
bne bl3mrt
lda tekxl,x
sec
sbc scrolh
tay
lda tekxh,x
sbc scrole
cpy #160
sbc #0
bcs bl3mrt
lda #$03
sta tekdir,x
inc teksta,x
km3mrt:
bl4mov:
bl3mrt: rts
;
kemmov:
ldy #0
lda teksta,x
beq kemm00
ldy #2
kemm00: sty dltdat
jsr tekhmv
ldy tekflg,x ; lda tekflg,x
iny ; cmp #$ff
bne kemm02
lda #0
sta teknof
rts
kemm02: inc tekstp,x
lda tekstp,x
and #$3f
bne kemm01
lda tekdir,x
ora #%0000_1000 ;y vec change
sta tekdir,x
kemm01: lda teksta,x
bne kemm10
lda tekxl,x
sec
sbc scrolh
tay
lda tekxh,x
sbc scrole
cpy #$20
sbc #0
bcs kemm10
lda tekdir,x
eor #%0000_0010 ;x vec chenge
sta tekdir,x
inc teksta,x
kemm10:
lda tekdir,x
and #%0100_0000
bne kemm12
lda teksta,x
beq kemm12
lda timer
and #$f
bne kemm12
lda #4
jsr misgen
;
kemm12: lda tekycn,x
beq kemm11
dec tekycn,x
rts
kemm11: lda #8
sta tekycn,x
lda #0
sta dltdat
jmp tekvmv
;
hakmov:
lda teksta,x
bne hakm10
inc tekstp,x
lda tekstp,x
cmp #20
bcc hakmrt
lda #255-120
sta tekstp,x
inc teksta,x
hakmrt: rts
hakm10:
lda #0
sta dltdat
jsr tekhmv
;
ldy tekflg,x ; lda tekflg,x
iny ; cmp #$ff
beq hakm20
lda tekdir,x
ora #%0011_0000
sta tekdir,x
lda teksta,x
cmp #2
beq hakm13
jsr tekjp2
jmp hakm14
hakm13: jsr tekjp1
lda tekjpt,x
cmp #32
bne hakm14
lda #2
jsr misgen
hakm14: lda tekjpt,x
bne hakm11
lda tekdir,x
eor #%0000_0010
sta tekdir,x
hakm11: inc tekstp,x
bne hakmrt
lda teksta,x
cmp #1
bne hakmrt
inc teksta,x
lda teky,x
sec
sbc #16
sta teky,x
rts
hakm20:
lda #0
sta teknof
rts
;
tekjmp:
lda tekdir,x
and #%0010_0000
beq tekjrt
lda tekjpt,x
tay
lda teky,x
clc
adc kujtbl,y
sta teky,x
iny
tya
and #$1f
sta tekjpt,x
bne tekjrt
lda tekdir,x
and #%1101_1111
sta tekdir,x
tekjrt: rts
;
;
kujtbl:
db -8,-8,-4,-4,-4,-3,-3
db -2,-2,-2,-1,-1,-1,-1,0,0
db 0,0,1,1,1,1,2,2,2,3,3,4,4,4,8,8
;
tekjp1:
lda tekdir,x
and #%0010_0000
beq tekjrt
lda tekjpt,x
tay
lda teky,x
clc
adc kujtb1,y
sta teky,x
iny
tya
and #$3f
sta tekjpt,x
bne tekj1r
lda tekdir,x
and #%1101_1111
sta tekdir,x
tekj1r: rts
;
kujtb1:
db -8,-8,-8,-8,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3
db -2,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0
db 0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2
db 3,3,3,3,4,4,4,4,4,4,8,8,8,8
;
tekjp2:
lda tekdir,x
and #%0010_0000
beq tekj2r
lda tekjpt,x
tay
lda teky,x
clc
adc kujtb2,y
sta teky,x
iny
tya
and #$f
sta tekjpt,x
bne tekj2r
lda tekdir,x
and #%1101_1111
sta tekdir,x
tekj2r: rts
;
kujtb2:
db -8,-4,-3
db -2,-2,-1,-1,0
db 0,1,1,2,2,3,4,8
arexmv:
sta dltdat
lda #0
sta dirchg
lda tekxl,x
sta xlsave
lda tekxh,x
sta xhsave
jsr tekhmv
lda xhsave
cmp tekxh,x
beq arexrt
sta tekxh,x
lda xlsave
sta tekxl,x
lda tekdir,x
eor #$02
sta tekdir,x
inc dirchg
arexrt: rts
;
areymv:
sta dltdat
lda #0
sta dirchg
lda teky,x
sta ysave
jsr tekvmv
lda teky,x
sec
sbc #$30
cmp #$b0-$30
bcc areyrt
lda ysave
sta teky,x
lda tekdir,x
eor #$08
sta tekdir,x
inc dirchg
areyrt: rts
;
tekhmv:
lda dltdat
asl a
asl a