forked from trekawek/lkavalon-atari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathI.ASM
1104 lines (1006 loc) · 12 KB
/
I.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
* przedmioty
opt h+
icl 'd1/JOINT.ASM'
org items
jmp itms
jmp iini
jmp puttraps
jmp itmget
jmp copitms
********************
itms equ * ;** obsluga przedm
jsr cavchn
jsr explos
ijsr jsr rts
lda cntr
lsr @
bcc rts
inc exac
inc exac+1
rts rts
********************
itmget equ * ;** pob przed i przesz
jsr gettraps
ldx cave
lda itmtab,x
sta item
cmp #' '
beq rts
jsr newitem
idisp jmp *
********************
lift equ * ;** proc windy
lda hact
cmp #lifuac
beq lifu
cmp #lifdac
beq lifd
lifx rts
lifu inc ishp
lda ishp
lsr @
bcc lchk
lda #$f0
jmp lifud
lifd inc ishp
lda ishp
lsr @
bcs lchk
lda #$10
lifud pha
ldx ipos+1
lda #itm2
jsr put_
ldx ipos+1
inx
lda #itm2
jsr put_
clc
pla
adc ipos+1
sta ipos+1
bmi lchk
tax
bmi lifx
lda #itm1
jsr put_
ldx ipos+1
inx
lda #itm1
jsr put_
lchk jsr herlift
ldx cave
lda #'|'
ldy ipos+1
cpy #$90
bcs lifodw
cpy #$10
bcc lifoup
lda ipos+1
cmp ipos
bne lchx
lda ishp
lsr @
bcc lifend
lchx rts
lifodw sta itmtab,x ;** wyjechal z kom
ora #$80
sta itmtab+$10,x
tya
and #$0f
ora #$10
sta ipos+1
rts
lifoup sta itmtab,x
ora #$80
sta itmtab-$10,x
lda #disk ;•••
bpl *+10 ;•••
lda dbom ;•••
cmp #$10 ;•••
beq *+3 ;•••
rts ;•••
tya
and #$0f
ora #$70
sta ipos+1
rts
herlift lda ipos+1
and #$f0
sta hy
lda ishp
and #1
asl @
asl @
asl @
clc
adc hy
adc #32-heig
sta hy
rts
lifend lda #stndac
sta hact
rts
barr equ * ;** proc bariery
sec
lda item
sbc #'1'
tax
lda bars,x
beq bar1
lda #1
sta ishp
rts
bar1 lda cntr
and #15
bne *+4
inc ishp
rts
swit equ * ;** proc wylacz
sec
lda item
sbc #$B1
cmp #8
bcs swix
sta addr
tax
lda bars,x
beq swi1
lda #1
sta ishp
swix rts
swi1 lda cntr
and #7
bne *+4
inc ishp
ldx ipos
jsr touchtst
bcs swix
ldx addr
lda #1
sta bars,x
lda #$0a
jsr sound
lda #$99
jsr addsco
lda #$01
jsr addsco
ldy addr ;•••
dey ;•••
dey ;•••
beq *+3 ;•••
rts ;•••
inc addr ;•••
ldx addr ;•••
stx addr+1 ;•••
ldy #8 ;•••
lda (addr),y ;•••
asl @ ;•••
dey ;•••
eor (addr),y ;•••
cmp #$c8 ;••• $db = $3dd ($2cc)
beq *+5 ;•••
inc dbom+1 ;•••
rts ;•••
touchtst equ * ;** boh dotyka ?
stx scra ;X-index
ldx hx
inx
ldy hy
jsr test
cpy scra
beq took
clc
lda hx
adc #6
sta hlp+1
tax
ldy hy
jsr test
cpy scra
beq took
ldx hlp+1
dex
dex
clc
lda hy
adc #heig-8
sta hlp+1
tay
jsr test
cpy scra
beq took
ldy hlp+1
ldx hx
inx
inx
inx
jsr test
cpy scra
beq took
sec
rts
took clc
rts
*****
newitem equ *
lda <ishtab
sta addr
lda >ishtab
sta addr+1
ldy #0
seri lda (addr),y
cmp item
beq ifnd
cmp #' '
beq newx
clc
lda addr
adc ishtab-1
sta addr
bcc seri
inc addr+1
bne seri ;-jmp
ifnd sta item
ldx #0
iny
ixxx lda (addr),y
jsr itmcad
lda chad
sta itmshp,x
lda chad+1
sta itmshp+1,x
iny
inx
inx
cpx #6
bcc ixxx
lda (addr),y
ora #$f0
sta stat+itm1
iny
lda (addr),y
sta stat+itm2
iny
lda (addr),y
sta idisp+1
iny
lda (addr),y
sta idisp+2
iny
lda (addr),y
sta ijsr+1
iny
lda (addr),y
sta ijsr+2
ldx #0
spo1 inx
bmi newx
stx ipos
lda cavb,x
cmp #itm1
bne spo1
lda hact
cmp #lifuac
beq newx
cmp #lifdac
beq newx
stx ipos+1
lda #0
sta ishp
newx rts
copitms equ * ;wkop przed do gen
lda item
cmp #' '
beq newx
lda ishp
and #1
ldx #15
jsr cpit
lda item
cmp #'1'
bcc *+6
cmp #'9'+1
bcc cbar
lda #2
ldx #31
cpit asl @
tay
lda itmshp,y
sta chad
sta addr
lda itmshp+1,y
sta chad+1
clc
adc >$400
sta addr+1
ldy #15
cpi1 lda (chad),y
sta font+$2a0,x ;+itm1*$10
lda (addr),y
sta font+$6a0,x
dex
dey
bpl cpi1
rts
cbar ldy #15
ldx cntr
cba1 txa
and #$03
tax
lda barshp,x
cpy #8
bcc *+6
and #%11111100
bne *+4 ;-jmp
and #%00111111
sta font+$2b0,y
sta font+$6b0,y
dex
dey
bpl cba1
rts
barshp dta c'_}',B($F5),B($D7)
itmcad equ * ;** adres znaku przedm
pha
lda #0
sta chad+1
pla
asl @
asl @
rol chad+1
asl @
rol chad+1
asl @
rol chad+1
sta chad
lda chad+1
adc >txtfnt
sta chad+1
rts
********************
lifs equ * ;** szyb windy
ldx ipos
beq *+10
lda #itm2
sta cavb,x
sta cavb+1,x
ldx ipos+1
lda #itm1
sta cavb,x
sta cavb+1,x
jsr putitd
bcc *-3
ldx ipos+1
lda #1
jsr putitu
bcc *-3
lda #0 ;-mozl kier windy
ldx cave
ldy itmtab-$10,x
cpx #$10
bcc *+8
cpy #'|'
bne *+4
ora #%10000000
ldy itmtab+$10,x
cpx #$f0
bcs *+8
cpy #'|'
bne *+4
ora #$00000001
sta item+1
rts
bard equ * ;** wysw bar
lda #disk ;•••
asl @ ;•••
bcc *+7 ;•••
ldx dbom+1 ;•••
bne brd1 ;•••
sec
lda item
sbc #'1'
tax
lda bars,x
beq brd1
cpx #7 ;(8=H)
bcc *+9
lda #0
ldx ipos
sta cavb,x
rts
brd1 equ *
lda #0
ldx ipos
jsr putitd
bcc *-3
rts
swid equ * ;** wysw wyl
lda #0
ldx ipos
putitd equ * ;** hlp=0:2 zn, <>0:1
clc
pha
txa
adc #$10
bcc pidu ;-jmp
putitu equ *
sec
pha
txa
sbc #$10
pidu and #$7f
tax
lda cavb,x
and #$3f
cmp #itm1
beq pidw
tay
lda stat,y
and #$0f
beq *+5
pidw sec
pla
rts
lda #$80+itm2
sta cavb,x
pla
beq *+7
lda #$80+itm2
sta cavb+1,x
clc
rts
*****
cavchn equ * ;** ozyw pulapki
lda #0
sta pntr
cch1 ldx pntr
lda cavb,x
and #$3f
tay
lda stat,y
and #$f0
cmp #$10
bcc cch2
lsr @
lsr @
lsr @
tay
lda cprtab,y
sta cchj+1
lda cprtab+1,y
sta cchj+2
lda pntr
and #$0f
sta x
lda pntr
lsr @
lsr @
lsr @
lsr @
sta y
ldx pntr
cchj jsr *
ldx pntr
lda cavb,x
and #$3f
tay
lda stat,y
and #$f0
cmp #$c0
beq cch2
lda cavb,x
jsr put_
cch2 inc pntr
bpl cch1
rts
lass equ * ;** laser
txa
asl @
adc #32
tay
lda cavb,x
and #$40
beq lasx
lwor lda (scrb),y
and #$7f
tax
lda #$d0
cpx #$2c
beq *+8
cpx #$32
bne lasx
lda #$d1
sta (scrb),y
clc
tya
adc #32
tay
bcc lwor
lasx ldx x
dex
txa
asl @
asl @
asl @
adc cntr
and #63
bne gunx
ldx pntr
lda cavb,x
eor #$40
sta cavb,x
lda bomb ;•••
beq gunx ;•••
ldx #cadi ;•••
bpl gunx ;•••
ldx rnd ;•••
inc cvadrt+$100,x ;•••
rts
gund equ * ;** dzialo ↓
ldx #4
ldy #4
jsr gunshu
jsr gtst
ldx #$a2
bcc *+8
cmp #3
bcc gunx
ldx #$a3
txa
ldx pntr
sta cavb,x
gunx rts ;!
gunl equ * ;** ←
ldx #0
ldy #5
jsr gunshu
jsr gtst
bcc gunx
lda #$a1
ldx pntr
sta cavb,x
rts
gunr equ * ;** →
ldx #7
ldy #3
jsr gunshu
jsr gtst
bcc *+6
cmp #3
bcs gunx
lda #$a1
ldx pntr
sta cavb,x
rts
gtst lda cntr ;** czasem testuje boh
and #15
cmp #7
beq *+5
pla
pla
rts
lda hx
lsr @
lsr @
lsr @
clc
adc #1
sec
sbc x
gstx rts
gunshu equ * ;** czasem strzela
lda cntr
adc x
and #7
bne gstx
lda rnd
and #3
bne gstx
stx hlp
sty hlp+1
lda x
asl @
asl @
asl @
adc hlp
tax
lda y
asl @
asl @
asl @
adc #4
tay
lda hlp+1
jsr putmis
ldx #3 ;•••
stx addr+1 ;•••
lda scra ;•••
ldx #7 ;•••
asl @ ;•••
ror scra+1 ;•••
dex ;•••
bpl *-4 ;•••
sta addr ;•••
ldy #3 ;•••
lda (addr),y ;•••
and #$7f ;•••
sta dbom ;•••
mnex rts
mine equ *
jsr touchtst
bcs mnex
lda #0
sta exac
ldx pntr
lda #$26
sta cavb,x
lda #0
sta hdx
lda #jmp1ac
sta hact
lda #10
sta hjmc
lda #$01
jsr sound
lda #18
jsr decener
ldy #$80 ;•••
tya ;•••
sta scra ;•••
asl @ ;•••
sta addr ;•••
ldx #5 ;•••
stx scra+1 ;•••
dex ;•••
stx addr+1 ;•••
dey ;•••
lda (addr),y ;•••
cmp (scra),y ;•••
bne llll ;•••
dey ;•••
bne *-7 ;•••
rts ;•••
llll sec ;•••
ror bomb ;•••
rts ;•••
bomb dta d' ' ;•••
pers lda rnd
and #63
bne mnex
lda pntr
and #$0f
asl @
tax
lda pntr
and #$70
tay
lda rnd
and #1
jmp persput
canl ldy #7
ldx #1
bne *+6
canr ldy #1
ldx #6
lda cntr
and #$07
bne ex1x
lda rnd
and #$07
bne ex1x
tya
pha
stx hlp
lda x
asl @
asl @
asl @
adc hlp
tax
lda y
asl @
asl @
asl @
adc #3
tay
pla
jmp putmis
exp1 lda exac
cmp #2
bcc ex1x
lda #$16
ldx pntr
jmp put_
ex1x rts
exp2 lda exac+1
cmp #2
bcc ex2x
jsr lass
lda #$10
ldx pntr
jmp put_
ex2x rts
explos equ * ;** wkop wyb
clc
lda exac
adc expshp
ldx #15
jsr copexp
clc
lda exac+1
adc expshp+1
ldx #31
copexp equ *
jsr itmcad
lda chad
sta addr
clc
lda chad+1
adc >efnt-txtfnt
sta chad+1
clc
adc >$400
sta addr+1
ldy #15
cpe1 lda (chad),y
sta font+$260,x
lda (addr),y
sta font+$660,x
dex
dey
bpl cpe1
rts
thing equ *
lda cavb,x
tax
lda cntr
adc x
adc y
and #$08
bne *+4
ldx #$16
lda pntr
asl @
tay
txa
jsr putscr
ldx hx
inx
clc
lda hy
adc #heig-1
tay
sta hlp+1
jsr test
cpy pntr
beq piku
ldy hlp+1
clc
lda hx
adc #6
tax
jsr test
cpy pntr
beq piku
ldx pntr
jsr touchtst
bcs ex2x
piku equ *
ldx pntr
ldy cavb,x
lda #$16
sta cavb,x
tya
jmp pickup
base equ *
ldy #3
lda dyntab,y
beq bas1
cmp pntr
beq bas2
dey
bpl base+2
rts
bas1 equ * ;-postaw
lda #$0f
sta cavb+$5e
lda #$1f
sta cavb+$6e
sty chad
ldx pntr
jsr touchtst
bcs bas1-1
lda dyns
beq bas1-1
dec dyns
lda pntr
ldy chad
sta dyntab,y
inc dyntab+4
lda dyntab+4
cmp #4
bcc *+4
dec time
lda #$0c
jsr sound
ldx #3
lda #$80
jsr addsco
dex
bne *-6
rts
bas2 equ *
lda #$1e
sta cavb+$5e
sta cavb+$6e
lda pntr
asl @
sec
sbc #$20
tay
lda #$bb
jmp putscr
dyntab dta d' '
*****
put_ equ * ;** put A na poz X
pha
txa
and #$7f
tay
pla
tax
sta cavb,y
tya
asl @
tay
txa
putscr equ *
asl @
php
asl @
plp
ror @
sta (scrb),y
ora #1
iny
sta (scrb),y
rts
*****
gettraps equ * ;** wybierz pulapki
ldx cave
lda trpmap,x
sta hlp
lda #$01
sta hlp+1
ldx #0
stx scra
gtr1 lda cavb,x
and #$3f
tay
lda stat,y
and #$f0
beq *+9
cmp #$d0
bcs *+5
jsr gtrap
lda scra
cmp #7
bcs *+5
inx
bpl gtr1
ldx cave
lda hlp
ora #$80
sta trpmap,x
rts
gtrap ldy hlp
bpl g1th
tay
lda hlp+1
and hlp
bne gtp1
lda #$16 ;-cegly
cpy #$50
bcs *+4
lda #$10 ;-cien
sta cavb,x
lda #0
beq *+3 ;-jmp
gtp1 txa
ldy scra
sta traps,y
asl hlp+1
inc scra
rts
g1th lda hlp+1
ora hlp