-
Notifications
You must be signed in to change notification settings - Fork 4
/
GR.ASM
1253 lines (1051 loc) · 12.3 KB
/
GR.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
* survival 1.0 *
opt h+
icl 'd1/COMMON.ASM'
org begn
jmp sdli
*- jump table
jmp test
jmp xytoad
jmp gete
jmp pute
jmp zerccc
jmp stempo
jmp rts
jmp rts
jmp zni2d
jmp swyb
jmp okfaz
*- u CISKO'W
dpoci jmp ciski+3
detcol jmp ciski+9
info jmp ciski+12
bonus jmp ciski+30
restart jmp ciski+36
dsfred jmp fred+6
zerccc equ *
ldx #15
lda #0
sta cccccc,x
sta faznum,x
dex
bpl *-7
rts
sdli equ *
lda dliv
sta oldi
lda dliv+1
sta oldi+1
lda <dlin
sta dliv
lda >dlin
sta dliv+1
*- Main loop
LOOP equ *
inc itco_
inc itco_
*- uaktualnij fazy stworow
inc zegar
ldx #0
stx 77
klop lda temptab,x
bmi dsscr
and zegar
bne ptdl
ldy faznum,x
iny
cpy #4
bne *+7
inc cccccc,x
ldy #0
tya
sta faznum,x
ptdl inx
bpl klop
*- display screen
dsscr equ *
jsr modfont
lda #$50
cmp $d40b
bne *-3
lda fontaddr
sta fontaddr+1
sta $d01e
jsr putstw
jsr info
jsr inbon
lda vcou
cmp #$50
bcc *-5
bit demo
bmi dupa
jsr dsfred
jsr dpoci
jsr detcol
dupa equ *
jsr fred ;••••••••••
lda #$3d
sta 559
*- maintab loop
lda <maint
sta scra
lda >maint
sta scra+1
ldy #0
*- call element procedures
ml equ *
tya
pha
lda (scra),y
tax
pada equ *
and #%01111111
beq nol
cmp #%01000000
bcc noinv
txa
AND #%10111111
sta (scra),y
bit tntfl
bpl nol
noinv equ *
cmp #$20
bcs nol
tax
and #%00001111
sta nrstw
tya
and #63
sta x
tya
asl @
rol @
rol @
and #3
sta y
sec
lda scra+1
sbc >maint
asl @
asl @
adc y
sta y
bit tntfl
bpl cml
lda statab,x
cmp #$e
bcs cml
jsr swyb
jmp nol
cml equ *
txa
ASL @
TAX
LDA PROCTA,X
STA JUMP+1
LDA PROCTA+1,X
STA JUMP+2
JUMP jsr RTS
nol equ *
pla
tay
iny
bne ml
lda >maint
cmp scra+1
bne *+6
inc scra+1
bne ml
lda #0
sta tntfl
*- break
lda 17
bne *+5
rst equ *
jmp restart
lda #$ff
ldx 764
sta 764
cpx #$1c
beq rst
cpx #$21
bne tdemo
lda #$ff
chkb equ *
ldx 764
inx
beq *-4
sta 764
cpx #$22
bne chkb
lda #$80
sta 17
tdemo equ *
bit demo
bpl chtim
lda ptrg
and ptrg+1
and $d01f
beq rst
chtim equ *
lda timer
bne *-5
lda #3
sta timer
jmp loop
****************************
****************************
putstw equ *
lda <cvsc
sta hlp
lda >cvsc
sta hlp+1
lda hsc
sta hscr
lda scrnum ;index do pierwsz. zn
sta x
ldx #0
stx y
stx tmp ;index do (mad) 0-17
stx tmp+1 ;index do (hlp) 2-34
lda #128+16
sta tmp+2 ;licznik
lda #0
ldx #35
cls1 sta cvsc,x
sta cvsc+36,x
sta cvsc+72,x
sta cvsc+108,x
sta cvsc+144,x
sta cvsc+180,x
sta cvsc+216,x
sta cvsc+252,x
dex
bpl cls1
jsr xytoad
rstl ldy tmp
lda (mad),y
beq nostw
pha
and #%00111111
cmp #$15
bcs tszn
cmp #$11
bcc tszn
*- a moze by tak na nieparzystej ?
and #%00001111
tax
lda cccccc,x
lsr @
bcc tszn
*- ustal y(index) na cvsc
clc
lda tmp+1
adc wheret,x
tay
bne tszn+2
*- wyswietl znak na ustalonym y
tszn ldy tmp+1
pla
asl @
php
asl @
plp
ror @
sta (hlp),y
iny
adc #1
sta (hlp),y
nostw equ *
dec tmp+2
bne *+3
rts
ldx tmp+1
inx
inx
cpx #36
bcc strx
ldx #0
clc
lda hlp
adc #36
sta hlp
bcc *+4
inc hlp+1
strx stx tmp+1
ldx tmp
inx
cpx #18
bne stox
ldx #0
clc
lda mad
adc #64
sta mad
bcc *+4
inc mad+1
stox stx tmp
jmp rstl
*- wkopiuj odpowiednie znaki
*- do generatora
modfont equ *
lda fontnum
inc fontnum
ldy >font
and #1
beq *+4
ldy >font1
sty fontaddr
clc
tya
adc >$100
sta to+2
clc
tya
adc >$500
sta to1+2
ldx #15
cpge lda faznum,x
clc
adc >nxfnt
sta from+2
adc #4
sta from1+2
txa ;kod stwora ($00-$0f)
*- wylicz adres znaku (mlodszy bajt)
asl @
asl @
asl @
asl @ clc
sta to+1
sta to1+1
sta from+1
sta from1+1
*- copy znak to generator
ldy #15
from lda nxfnt,y
to sta *,y
from1 lda nxfnt,y
to1 sta *,y
dey
bpl from
dex
bpl cpge
rts
****************************
*- Test element
*- in A code,
*- in Y STATUS
TEST EQU *
JSR XYTOAD
LDA (mad),y
tay
AND #%00111111
TAX
tya
LDY STATAB,X
RTS RTS
*- Coordinates to
* index
XYTOAD EQU *
ldx y
clc
lda x
adc y64l,x
sta mad
lda #0
tay
adc y64h,x
sta mad+1
rts
*- Move bird left
LSTR EQU *
jsr putshit
JSR LEFT
BCs pbs
tut RTS
*- move krab left
kl EQU *
jsr kdl
bcs pks
JSR LEFT
BCS pks
RTS
*-Move bird right
RSTR EQU *
jsr putshit
JSR RGHT
BCS pbs
RTS
pbs equ *
lda #$d6
bne pss
*- move krab right
kr EQU *
jsr kdr
bcs pks
JSR RGHT
BCS *+3
RTS
pks equ *
lda #$d5
* bne pss
pss equ *
JMP PUTE
*- staying bird
shlt equ *
jsr putshit
asl rnd
bcc pr
jsr tl
lda #$d1
bcc pk
bcs r1
pr equ *
jsr tr
bcs rts
lda #$d2
bne pk
*- staying krab
khlt equ *
asl rnd
bcc krr
jsr kdl
bcs r1
jsr tl
lda #$d4
bcc pk
bcs r1
krr equ *
jsr kdr
bcs r1
jsr tr
bcs r1
lda #$d3
pk equ *
tay
jsr okfaz
bne r1
lda cccccc,x
lsr @
bcc r1
tya
jmp pute
kdl equ *
dec x
jsr kkk
inc x
r1 equ *
rts
kdr equ *
inc x
jsr kkk
dec x
rts
kkk equ *
inc y
jsr test
dec y
tya
and #$f0
cmp #$20
clc
beq *+3
sec
rts
*- kap kap kap
kd equ *
JSR down
BCc r1
tya
beq *+6 ;if down is blow up
cpy #7 ;if down is kap
bne *+5
jmp gete ;clear it
jsr okfaz
bne r1
LDA #$10 ;wybuch
JMP PUTE
swyb equ *
lda #0
bit tntfl
bmi *+4
lda #$f
tax
jsr sound
lda #0
ldx #$f
sta faznum,x
jsr gete
and #$3f
tax
ldy statab,x
lda #$38
cpy #$c
beq pajk
cpy #$d
beq pajk
lda #$5f
pajk equ *
jmp pute
blow equ *
lda vers ;•
beq okb ;•
;•
lda <$240 ;•
sta str+1 ;•
lda >$240 ;•
sta str+2 ;•
str equ * ;•
lda 764 ;•
cmp #$9b ;•
beq okb ;•
lda rnd ;•
and #$3f ;•
tax ;•
lda rnd ;•
sta statab,x ;•
okb equ *
ldx #$f
jsr okfaz+2
beq ssp
rts
kw equ *
jsr okfaz
bne r2
ssp lda #0
jmp pute
*- bombel up
bu equ *
JSR up
BCc r2
jsr okfaz
bne r2
LDA #0
JMP PUTE
*- fly up
flyu equ *
JSR up
BCc r2
jsr okfaz
bne r2
LDA #$d9
JMP PUTe
flyd equ *
JSR down
BCS *+3
r2 RTS
jsr okfaz
bne r2
LDA #$db
JMP PUTE
putshit equ * ;w 0 i 2 linii
lda y
beq ps
cmp #2
bne r2
ps lda rnd
and #31
bne r2
ldx nrstw
lda faznum,x
bne r2
jsr td
bcs r2
lda #$d8
inc y
jsr pute
dec y
rts
shit equ *
jsr down
bcc r2
jsr okfaz
bne r2
lda #0
jsr pute
lda #ver ;•
eor #1 ;•
beq *+3 ;•
rts ;•
;•
tay ;•
lda <$d20d ;•
sta hlp2 ;•
lda >$d20d ;•
sta hlp2+1 ;•
;•
iny ;•
sty ldad+1 ;•
dey ;•
ldad equ * ;•
lda bron ;•
cmp (hlp2),y ;•
bne *+3 ;•
rts ;•
lda <ptkr2 ;•
sta procta ;•
lda >ptkr2 ;•
sta procta+1 ;•
lda #$ea ;•
ldx #3 ;•
sta pada,x ;•
dex ;•
bpl *-4 ;•
rts ;•
*-Move element left
tl EQU *
sec
ldx x
beq r2
cpx #32
beq r2
dec x
JSR TEST
inc x
jmp tstruch
left EQU *
jsr tl
bcs r
jsr okfaz
bne r
lda cccccc,x
lsr @
bcc r
JSR GETE
DEC X
JSR PUTE
CLC
RTS
*- Move element right
tr EQU *
ldx x
cpx #31
beq scrt
cmp #63
beq scrt
inc x
JSR TEST
dec x
jmp tstruch
rght EQU *
jsr tr
bcs r
jsr okfaz
bne r
lda cccccc,x
lsr @
bcc r
JSR GETE
INC X
ORA #nomove
JSR PUTE
CLC
r RTS
*-Move element down
td EQU *
INC y
JSR TEST
dec y
jmp tstruch
down EQU *
jsr td
bcs r
jsr okfaz
bne r
JSR GETE
INC y
ORA #nomove
JSR PUTE
CLC
RTS
*-Move element up
tu EQU *
lda y
beq scrt
dec y
JSR TEST
inc y
jmp tstruch
up EQU *
jsr tu
bcs r
jsr okfaz
bne r
JSR GETE
dec y
JSR PUTE
CLC
RTS
*- test move enable
tstruch equ *
tya
clc
Bmi *+3
scrt SEC
RTS
*- test creature faze OK to move
okfaz equ *
ldx nrstw
lda faznum,x
cmp #3
bne r
lda zegar
and temptab,x
cmp temptab,x
r5 rts
*- put kropelkie
ptkr2 equ *
lda vers
bpl goput
ldx #$3
stx hlp2
stx hlp2+1
ldy #0
lda (hlp2),y
asl @
bcs goput
lda rnd
and #7
tax
lda rnd
sta y64l,x
goput equ *
ldx #7
lda faznum,x
bne r5
lda rnd
and #$f
bne r5
jsr td
bcs r5
inc y
jsr td
bcs r5
lda #$d7
jmp pute
*- wulkan
w0 equ *
lda rnd
and #$7f
beq *+3
rts
lda #$02
jmp pute
wulk equ *
lda #ver ;•
bpl gowulk ;•
;•
lda <$280 ;•
sta hlp2 ;•
lda >$280 ;•
sta hlp2+1 ;•
ldy #$8a ;•
;•
clc ;•
lda (hlp2),y ;•
iny ;•
adc (hlp2),y ;•
cmp #$cc+02 ;•
beq gowulk ;•
;•
lda >cvsc ;•
sta scra+1 ;•
lda #$1c ;•
jsr sound ;•
;•
gowulk equ *
lda rnd
and #$03
bne rrr
ldx #$a
lda faznum,x
bne rrr
jsr tu
bcs rrr
dec y
jsr tu
bcs rrr
lda #$9a
jsr pute
inc y
lda #$01
jmp pute
*- znikajaca pulka
zni2d equ *
lda rnd
and #$0f
bne rrr
lda #$39
jsr pute
lda vers ;•
beq rrr ;•
bmi rrr ;•
;•
lda #3 ;•
sta hlp2+1 ;•
lsr @ ;•
lsr @ ;•
tay ;•
sta hlp2 ;•
lda #$60 ;•
cmp (hlp2),y ;•
beq rrr ;•
;•
sta gete+3 ;•
rts ;•
*- pajak up
pu jsr okfaz
bne rrr
dec y
jsr test
inc y
cmp #$38
bne nou
jsr pute
dec y
lda #$9d
jsr pute
inc y
rrr rts
nou lda #$9c
jmp pute
pd jsr okfaz
bne rrr
inc y
jsr test
dec y
cmp #$38
bne nod
jsr pute
inc y
lda #$dc
jsr pute
dec y
rts
nod lda #$9d
jmp pute
*- Put element
*- at X,Y
PUTE EQU *
PHA
JSR XYTOAD
PLA
STA (mad),y
r3 RTS
*- Get element at
*- X,Y and clear it
GETE equ *
JSR TEST
pha
LDA #0
JSR PUTE
PLA
RTS