-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCENGINE.ASM
More file actions
1484 lines (1381 loc) · 37.9 KB
/
CENGINE.ASM
File metadata and controls
1484 lines (1381 loc) · 37.9 KB
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
;;Chris Busch
;;(c)1995
;;;;
;;;headers
#include "ti-85.h"
#define jp DONT_USE
#include "cmacros.asm"
;-------------------------
; Title
;-------------------------
.org 0
.db "CENGINE v5.0 ",0
;; ^^^^^^^^^^^^^<-dont change that length!!
;-------------------------
; Program start
;-------------------------
main:
halt ;;;;;;;<- must be first opcode of program!
ld hl,(PROGRAM_ADDR) ;checksum begin
ld b,9
xor a
chksum:
add a,(hl)
inc hl
djnz chksum
cp 143 ;"CENGINE v"
jr z,skipshow
;dimagain:
; CALL_( dimout)
; jr dimagain
; .db $3A ;;dummy
skipshow:
ld b,6
ld hl,(PROGRAM_ADDR)
ld de,myname
add hl,de
xor a
;chksum2:
; add a,(hl)
; inc hl
; djnz chksum2
; cp 120 ;"cbusch"
; jr nz,dimagain ;;checksum end!
ld a,0
ld (level),a
CALL_( checkhiscore);
CALL_( intro);
ld hl,(picptr) ;;make sure picptr!=0 && levelptr!=0
ld de,0
call CP_HL_DE
jr nz,datanot0
ld hl,(levelptr)
call CP_HL_DE
jr nz,datanot0
ld hl,$0000
ld de,cantfind ;;print cant data find message
CALL_( putstr)
CALL_( wait4enter);
ret ;;quit program!
datanot0:
CALL_( showpurpose) ;;aug 1996
;; CALL_( findlevel);
donewlevel:
startlevel:
;;CALL_( dissolve) ;;;;;ROM_CALL(CLEARLCD)
ld hl,VIDEO_MEM
ld (hl),0
ld de,VIDEO_MEM+1
ld bc,scrwidth
ldir
ld b,128 ;{ scroll up really fast
scrollclrloop: ; clearing screen
push bc ;
halt ;
ld de,VIDEO_MEM + 1024 ;
ld hl,VIDEO_MEM + 1024 - scrwidth ;
ld bc,1024 - scrwidth ;
lddr ;
pop bc ;
djnz scrollclrloop ;}
CALL_( initlevel)
CALL_( stripe) ;;show stripe
ld a,(health)
inc a
ld (health),a
CALL_( dechealth)
CALL_( incscore)
ld a,0 ;;{clear play mode flags!
ld (playmode),a ;;}
ld a,(level) ;;{
inc a ;; level++
ld (level),a ;;}
ld ix,bullet ;;initbullet{
ld d,bulletid ;;
ld bc,0 ;;
ld hl,0
CALL_(initspr) ;;}
;;initspr(IX=sprite*,d=idtype,e=empty,bc=extra bytes,hl=videostart)
ld ix,player
ld d,playerid
ld e,0
ld bc,0
ld hl,0
CALL_( initspr) ;;;;;;;initplayer
ld ix,monster1 ;{ --|-- ;kill all the monsters
ld de,sprsize ; |
ld b,monsternum ; |
clrmonsters: ; |
ld (ix+sprmonsth),0 ; |
add ix,de ; |
djnz clrmonsters ;} --|--
gameloop:
CALL_( display) ;
halt
CALL_( moveplayer) ;
CALL_( blockfall)
ld a,(frame) ;increment frame counter{
inc a
ld (frame),a
bit 0,a
jr z,Nomovebullet
CALL_( movebullet)
Nomovebullet:
ld a,(delay) ;increment delay counter{
inc a ;
ld (delay),a ;
and 3
cp 3 ;
jr nz,gameloop ;}
ld a,(delay)
and 7
cp 7
jr nz,gameloop
CALL_( movemonster) ;
ld a,(playmode) ;{new level yet?? ie found scroll
bit hasscrollbit,a ;
jr z,skipnewlevel
;;printnum(hl=number,b=col,c=row)
ld a,(level)
inc a
ld h,0
ld l,a ;number to print
ld b,5 ;col
ld c,3 ;row
CALL_( printnum)
ld hl,$0502 ;location on screen (col,row)
ld de,newlevel ;str to print
CALL_( putstr)
CALL_(wait4enter);
JUMP_(donewlevel) ;}
skipnewlevel:
ld a,(health) ;if(health!='0') {
cp '0' ; continue game
jr nz,gameloop ;}
ld hl,$0603 ;;col,row
ld de,gameover
CALL_( putstr)
CALL_( wait4enter);
JUMP_( main) ;}health=='0' so startover
quit:
ROM_CALL(CLEARLCD)
ld hl,$0001 ;;col,row
ld de,byebye
CALL_( putstr)
CALL_( checkhiscore)
CALL_( puthiscore)
CALL_( getyourname)
CALL_( wait4enter);
;;fill graph screen with exit message
ld bc,1024 ;
ld DE,GRAPH_MEM ;
ld HL,VIDEO_MEM ;
ldir ;;;end fill graph screen
ret
;;;;;;;;;;;;end of main
;-------------------------
; functions
;-------------------------
;.db 31h ;;dummy
#include "rand.asm"
#include "actor.asm"
#include "smisc.asm"
;;void blockfall()
blockfall:
ld b,32
loopbf:
ld de,GRAPH_MEM
ld hl,(blockspot)
dec hl
ld a,h
and 3
ld h,a
ld (blockspot),hl
add hl,de
ld c,(hl) ;;C= fallerID
bit fallingbit,(hl)
jr z,skipfallid ;;if not skipped then hl->falling block
ld de,levelwidth
ld hl,(blockspot)
add hl,de
ld a,h \ and 3 \ ld h,a
ld de,GRAPH_MEM
add hl,de
ld a,blankid
cp (hl)
jr nz,skipfallid ;;spot below falling block not empty
ld (hl),c ;;draw block
ld hl,(blockspot)
ld de,GRAPH_MEM
add hl,de
ld (hl),blankid ;;erase block
skipfallid:
djnz loopbf
ret
;;end blockfall
;;;void stripe()
;;;destroys most!
stripe:
ld hl,VIDEO_MEM+13
ld de,16
ld a,00100000b
ld b,63
stripe_loop:
ld (hl),a
add hl,de
djnz stripe_loop
ld de,$006C ; y,x x,y= 107,10
ld hl,namestr
CALL_(putmstr);
scorespot =$126C
ld de,scorespot ; y,x x,y= 107,10
ld hl,scorestr
CALL_(putmstr);
livesspot =$236D
ld de,livesspot ; y,x x,y= 107,10
ld hl,livesstr
CALL_(putmstr);
ret
;;;end stripe
;.db 3Ah ;dummy
;;intro to the game
intro:
ld a,r
ld (randvar),a
CALL_( dissolve) ;;ROM_CALL(CLEARLCD)
ld hl,0
ld hl,$0001
ld de,title
CALL_( putstr)
CALL_( puthiscore)
;;;;CALL_( wait4enter)
ld hl,$FFFF
ld (score),hl
ld a,'9' ;;init health
ld (health),a
ret
;;;;;;;;;;;;;;;;;;;;;end intro
purposestr .db "You must find this",0
;;;;;showpurpose()
;;;;;alters randvar and loop
showpurpose:
s0howpurloop:
halt
ld hl,randvar ;;seeding random variable
inc (hl)
ld e, 64 - 28 ;x
ld d, 57 ;y was 55
ld hl,purposestr
CALL_( putmstr) ;;putmstr(e=x,d=y,hl->string);
ld bc, picnum*picsize + ( picsize * (playerid & idand ) )
ld a,(randvar)
bit 6,a
jr z,skip216
ld bc, (playerid & idand) * picsize
skip216:
ld ix,(picptr)
add ix,bc
ld hl,VIDEO_MEM + (scrwidth*sprlength*7) + 3
CALL_( drawspr) ;;one for player
ld a,(randvar) ;;its not random here
ld bc, picnum*picsize + ( picsize * (scrollid & idand ) )
bit 6,a
jr z,skip225
ld bc, (scrollid & idand) * picsize
skip225:
ld ix,(picptr)
add ix,bc
ld hl,VIDEO_MEM + (scrwidth*sprlength*7) + scrwidth - 4
CALL_( drawspr) ;;one for scroll
call GET_KEY
or a ;;is A==0? ;;cp K_NOKEY
jr z,s0howpurloop
ret
;;end showpurpose
;;;;;;;;;;;;;;;put hi score
puthiscore:
ld hl,(hiscore) ;drawhiscore(){
ld de,0
call CP_HL_DE
ret z
ld hl,$0D06 ;
ld (CURSOR_ROW),hl ;
ld hl,(hiscore) ;
ROM_CALL(D_HL_DECI) ;
ld hl,$0306 ;
ld de,hiscorestr ;
CALL_( putstr) ;//end drawing hiscore
ret
;;end puthiscore
;;firebullet
;;void firebullet()
;;destroys a,hl (a=0 afterward)
firebullet:
ld a,(bullet+sprmondir) ;if(bullet still going) {
cp K_NOKEY ; return
jr nz,endfireb ;}
ld a,(pdir) ;set bullet dir
dec a
and 3
inc a
ld (bullet+sprmondir),a
ld a,brange ;bullet range
ld (bullet+sprmonsth),a ;set bullet range
ld hl,(player+sprxyoffhl) ;set bullet start location
ld (bullet+sprxyoffhl),hl
endfireb:
ld a,K_GRAPH
ret
;;end firebullet
;;.db 35h ;;dummy
;;;;;;;;;;;;;;;;
;;void stopbullet()
;;destroys a,ix
stopbullet:
ld a,0
ld (bullet+sprmondir),a ;bulletdir=0
ld hl,GRAPH_MEM
ld de,(bullet+sprxyoffhl)
add hl,de
ld a,blankid
ld (hl),blankid
ret
;;;;;;;;end stopbullet
;;;;;;putblood
putblood: ;placing bloodpic here
ld hl,GRAPH_MEM
ld de,(hitxy)
add hl,de
ld a,bloodid
ld (hl),a
ret
;;end putblood
;;;;;;;;movebullet
movebullet:
ld a,(bullet+sprmondir) ;;if(bulletdir==0) {
cp 0 ;; goto gameloop
JUMP_Z( exitmbullet2) ;;}//a=bulletdirection
ld ix,bullet ;;//get bullet
CALL_( movespr) ;;//move bullet
ld a,(hitxyval) ;;if(hitxyval != 0) {
CP bombid
CALL_Z(incscore) ;get points for bombs
ld a,(hitxyval) ;;if(hitxyval != 0) {
bit killablebit,a
JUMP_Z(lookloopend)
;;;;;;;;;;;;;;;;;;;;;;;;find monster to kill!
;; and idand ;;use this monster check if monster hp>1
;; cp monsters ;;if(hitxyval > monsters) {
;; CALL_NC( putblood); ;; putblood }
and idand
cp monsters ;;if(hitxyval < monsters) {
CALL_C(incscore);
ld ix,monster1 ;;;;;;;loop
ld a,monsternum
ld (loop),a
lookloop:
ld a,(ix+sprmonsth)
cp 0
jr z,nomonstkill
ld h,(ix+sprxyoffh)
ld l,(ix+sprxyoffl)
ld de,(hitxy)
ld a,h
cp d
jr nz,nomonstkill
ld a,l
cp e
jr nz,nomonstkill
dec (ix+sprmonsth) ;monsterhealth--
push ix
ld a,(ix+sprmonsth)
cp 0 ;;is the monster dead?
CALL_Z( putblood)
;;CALL_( incscore);
pop ix
nomonstkill:
ld de,sprsize
add ix,de
ld a,(loop)
dec a
ld (loop),a
cp 0
JUMP_NZ(lookloop) ;;end search for monster loop
CALL_( putblood) ;;if you couldnt find live monster put blood there anywaz
lookloopend:
ld a,(hitxyval) ;;if(hitxyval != 0) {
cp 0 ;; stopbullet();
CALL_NZ(stopbullet) ;;}
exitmbullet:
ld a,(bullet+sprmonsth)
dec a
ld (bullet+sprmonsth),a
cp 0
CALL_Z( stopbullet)
exitmbullet2:
ld hl,GRAPH_MEM ;{draw player
ld de,(player+sprxyoffhl) ;
add hl,de ;
ld a,playerid ;
ld (hl),a ;}
ret
;;end movebullet
;;.db "c",12,"g",26,"b",73
;;void putbomb( A = direction, hl= xyspot)
putbomb:
;;ld a,(pdir)
dec a
and 3
;;ld hl,(player+sprxyoffhl)
cp K_UP-1
jr nz,notup
ld de,-1 ;;-levelwidth ;up
jr dobomb
notup:
cp K_DOWN-1
jr nz,notdown
ld de,1 ;;levelwidth ;down
jr dobomb
notdown:
cp K_LEFT-1
jr nz,notleft
ld de,-1 ;left
jr dobomb
notleft: ;must right since that is left over
ld de,1 ;right
dobomb:
add hl,de ;;hl=map offset
ld a,h
and 3
ld h,a ;;hl=true 1024 map offset
ld de,GRAPH_MEM
add hl,de ;
ld a,(hl) ;if( map spot is blank) {
cp blankid ;
ret nz ; place bomb!
ld a,bombid ;
ld (hl),a ;}
ret ;
;;end putbomb
;;handlef1 function
handlef1:
ld hl,0
nokeyyet:
inc hl
halt
ld a,47 ;wait for 47*256 clock ticks for 60.16 seconds
cp h
jr nz,skipoffon
SwitchOff:
ld hl,0
di
ld a,1
out (3),a
ei
halt ;; <after this instruction your calc switches off.
SwitchOn: ;; <The code starts again here..
ld a,%1011
out (3),a
skipoffon:
push hl
call GET_KEY
pop hl
cp K_NOKEY ;;0
jr z,nokeyyet
cp K_MORE ;;if press more then shut off immediately
jr z,SwitchOff
cp K_GRAPH
jr nz,nograph
CALL_(showmap)
jr skipoffon
nograph:
cp K_STAT
jr nz,nostatscan
CALL_(tourMap)
jr skipoffon
nostatscan:
cp K_PLUS
jr nz,noplus
ld a,(playmode) ;plus key pressed so found scroll
set hasscrollbit,a
ld (playmode),a
ret
noplus:
cp K_RAISE
jr nz,noraise
ld a,120 ;highjump flying
ld (jumpptr),a
ld hl,(score)
sra h ;proper div
rr l ;
dec hl
ld (score),hl
CALL_( incscore)
ret
noraise:
cp K_COS
jr nz,nocos ;;;;CHEAT!
ld a,'9' ;give health
ld (health),a
CALL_(dechealth)
ld hl,(score)
sra h ;proper div
rr l ;
;srl l
;srl h
dec hl
ld (score),hl
CALL_( incscore)
nocos:
ret
;;end of handlef1
jumplen =3 ;was 3
P_ALPHA =7
P_EXIT =6
P_2ND =5
P_F1 =4
P_UP =3
P_RIGHT =2
P_LEFT =1
P_DOWN =0
;;.db 0DCh ;;dummy
;;;moveplayer proc
moveplayer:
;;halt
ld a,(frame)
bit 0,a
ret nz ;;;only move player every other frame
;;call GET_KEY
; ld b,50
;loopabit:
ld a,0
out (1),a
in a,(1)
; cp 255
; jr nz,stoploopabit ;a key has been pressed!
; djnz loopabit ;;this loop will hopefully make respond better
;stoploopabit:
bit P_F1,a
;;cp K_MORE
;;jr nz,skippause
JUMP_Z(handlef1)
;skippause:
;;cp K_SECOND
bit P_2ND,a
;jr nz,skipfire
CALL_Z( firebullet)
;;ret ;;;;;;;;jr skipplayer
;skipfire:
;;cp K_EXIT
in a,(1)
bit P_EXIT,a
jr nz,noexit
call GET_KEY
CALL_(wait4enter)
cp K_EXIT
ret nz ;;;;;;;;; jr nz,noexit
pop hl ;;DITCH return address, so the quit quits
JUMP_( quit)
noexit:
ld hl,0
ld a,(frame)
bit 1,a
jr z,skipjmpchk ;;hopefully wont fall as fast...
ld a,(jumpptr) ;
cp 0 ;
jr nz,injump ;if in jump goto injump
ld ix,player
CALL_( beneath) ;
ld hl,levelwidth
cp blankid ;
jr z,isfalling ;
cp fireid
jr z,isfalling
cp bulletid ;;if land on a bullet then jumps really high
jr nz,notbullid
in a,(1)
bit P_2ND,a
jr z,notbullid ;;could jump high if not pressing 2nd
bit P_DOWN,a
jr nz,notbullid ;;jumps really high only if pushes down.
ld a,20 ;highjump
ld (jumpptr),a
notbullid:
;;cp K_UP ;
ld hl,0 ;put 0 into hl, why??
in a,(1) ;Read keyboard
bit P_ALPHA,a ;is alpha pressed?
jr z,beginnewjump ;if alpha then begin new jump
bit P_2ND,a
jr z,nogoup ;if 2nd is pressed don't jump w/up
bit P_UP,a ;if up then begin new jump
jr z,beginnewjump
jr nogoup
beginnewjump:
ld a,jumplen ;a=jumplen
jr injump2 ;goto injump2, start new jump
injump: ;
ld a,(jumpptr) ;preexisting jump in action
injump2:
dec a ;gravity
ld (jumpptr),a ;jumptr value=a
ld hl,-levelwidth ;go downward
skipjmpchk:
isfalling:
nogoup:
in a,(1) ;check for down key
bit P_DOWN,a
jr nz,nogodown ;if down key then:
bit P_2ND,a ;if not 2nd button then:
jr z,nofallfaster
ld hl,levelwidth ;fall faster??
nofallfaster: ;endif
ld a,K_DOWN ;set direction
ld (pdir),a
;ld hl,levelwidth ;fall faster??
nogodown: ;endif down key
in a,(1)
bit P_UP,a
jr nz,noaimup
ld a,K_UP
ld (pdir),a
noaimup:
;;cp K_RIGHT
in a,(1)
bit P_RIGHT,a
jr nz,nogright
push af ; make sure that P_2ND is not also pushed
ld a,K_RIGHT
ld (pdir),a
pop af ; make sure that P_2ND is not also pushed
bit P_2ND, a ; make sure that P_2ND is not also pushed
jr z,nogright ; make sure that P_2ND is not also pushed
ld de,1
push hl ;oldhl
add hl,de ;;move right
push hl ;newhl
ld ix,player
ex de,hl
CALL_( checkspot) ;;hl-> xyspot
pop hl ;newhl
pop de ;oldhl
and idand
cp brickid & idand
jr nz,nogright
ex de,hl ;;hl is old hl
nogright:
;;cp K_LEFT
in a,(1)
bit P_LEFT,a
jr nz,nogoleft
push af ;make sure that p2nd is not pressed as well
ld a,K_LEFT
ld (pdir),a
pop af ; make sure that P_2ND is not also pushed
bit P_2ND, a ; make sure that P_2ND is not also pushed
jr z,nogoleft ; make sure that P_2ND is not also pushed
ld de,-1
push hl ;oldhl
add hl,de ;;move right
push hl ;newhl
ld ix,player
ex de,hl
CALL_( checkspot) ;;hl->xyspot
pop hl ;newhl
pop de ;oldhl
and idand
cp brickid & idand
jr nz,nogoleft
ex de,hl ;;hl is old hl
nogoleft:
ex de,hl ;;de is now dxdy
ld ix,player ;;//get player ;;de must be dx/dy
ld hl,playmode
set isplayerbit,(hl)
CALL_(domove) ;;//move player
ld hl,playmode
res isplayerbit,(hl)
ld a,(hitxyval)
cp coinid ;;coin here?
jr nz,skipcoin
;;ld a,20 ;;TEST!
;;ld (jumpptr),a ;;TEST!
CALL_( incscore);
CALL_( incscore);
CALL_( incscore);
ret
skipcoin:
cp fireid ;;fire or bomb here?
jr nz,skipfire1
CALL_( dimout);
CALL_( dechealth);
ld hl,(player+sprxyoffhl)
ld de,GRAPH_MEM
add hl,de
ld a,bloodid
ld (hl),a
ld hl,0
ld (player+sprxyoffhl),hl ;;if fire then send to restart level
ret
skipfire1:
cp bombid
jr nz,skipbomb1
CALL_( dimout);
CALL_( dechealth);
ret
skipbomb1:
cp keyid
jr nz,skipkey
ld a,(playmode)
bit haskeybit,a
ret nz
set haskeybit,a
ld (playmode),a
CALL_( erasehitxy)
ld ix,(picptr) ;;keypic
ld de,picsize*(keyid & idand)
add ix,de
;;; ld de,(PROGRAM_ADDR)
;;; add ix,de
ld hl,VIDEO_MEM+894 ;(sprlength*(scrwidth*scrhite-2))
CALL_(drawspr) ;picked up key so draw key
ret
skipkey:
cp doorid
jr nz,skipdoor
ld a,(playmode)
bit haskeybit,a
ret z
res haskeybit,a
ld (playmode),a
CALL_( erasehitxy)
ld ix,(picptr) ;;blankpic first pic is the blank pic
;; ld de,(PROGRAM_ADDR)
;; add ix,de
ld hl,VIDEO_MEM+894 ;(sprlength*(scrwidth*scrhite-2))
CALL_(drawspr)
ret
skipdoor:
cp scrollid
jr nz,skipscrollid
ld a,(playmode)
set hasscrollbit,a
ld (playmode),a
CALL_( erasehitxy)
CALL_(incscore)
ret
skipscrollid:
and idand
cp brickid & idand
ret nz ;;if didnt hit anything then quit!
ld hl,jumpptr ;;hit something so stop the jump!
xor a
cp (hl) ;;jumpptr==0?? ;;after experimentation, this code is kinda dumb...
ret z
dec (hl) ;;jumpptr--
skipplayer:
ret
;;;;;;;;;end moveplayer
;;;void erasehitxy()
;;;destroys: hl,de,a
erasehitxy:
ld hl,(hitxy)
ld de,GRAPH_MEM
add hl,de
ld a,blankid
ld (hl),blankid
ret
;;;end erasehitxy
;;;incscore()
;;increments and prints score
;;destroys: a,hl
incscore:
ld hl,(score)
inc hl
ld (score),hl
ld a,l
and 31 ;;;;;score needed for extra life
cp 31
jr nz,incscore_skxtra
ld a,(health)
add a,2
ld (health),a
CALL_( dechealth)
incscore_skxtra:
ld hl,(score)
ld de,scorespot+$080E ;;$1078 ;;78
CALL_( putnumber)
ret
;;;;end incscore
;;;;;;;put number on screen
;;putnumber(e=x,d=y,hl=number)
putnumber:
ld b,4 ;number of digits
ConvLoop:
ld (CURSOR_X),de
call UNPACK_HL
add a,'0'
push de
ROM_CALL(M_CHARPUT)
pop de
dec e \ dec e \ dec e \ dec e
djnz ConvLoop
ret
;;;end putnumber
warning .db "no disassembly!"
;;putmstr(e=x,d=y,hl->string);
;;destroys bc
putmstr:
ld bc,(PROGRAM_ADDR)
add hl,bc
ld (CURSOR_X),de
ROM_CALL(D_ZM_STR)
ret
;;end putmstr
;;;;void initmonster(ix->sprite)
initmonster:
CALL_( rand )
ld l,a ; rand(256)
ld a,r
and 1
ld h,a ; hl=rand(512)
ld bc, 256
add hl,bc ;
ld de,(player+sprxyoffhl)
add hl,de ;(hl+=playeroffset)
ld a,h
and 3
ld h,a ;hl%=1024
;DEBUG16(hl)
ld de,GRAPH_MEM ;
ex de,hl ;so now hl=GRAPHMEM de=START
add hl,de
ld a,(hl) ;if( map location != blankid) {
cp blankid ; return
ret nz ;}
ex de,hl ;swap(hl,de) so hl=random(1024)
ld d,monster1id ;
CALL_( rand) ;
srl a
ld e,a ;;first bit is used to determine patrol or not
bit 0,a ;;first bit to determine monster picture
jr z,skipm2id ;
ld d,monster2id ;
skipm2id: ;
ld b,1 ;
ld c,$01 ;monster initial direction
CALL_(initspr) ;
ret ;
;;end initmonster
;;A=doseek() ;returns dir 1-4, down=1,left=2,right=3,up=4
doseek:
CALL_( rand)
srl a
srl a
and 3 ;25% of time do random move
jr nz,notberand
ld a,r
and 3
inc a
ret
notberand:
ld de,(player+sprxyoffhl)
ld h,(ix+sprxyoffh)
ld l,(ix+sprxyoffl)
or a ;compare hl,de; clear f
sbc hl,de ;set f bits
ld a,h
and 3 ;mod 1024
ld h,a
or a ;compare hl,de; clear f
ld de,16
sbc hl,de ;set f bits
add hl,de
jr nc,notgoleft
ld a,K_LEFT
ret
notgoleft:
or a ;compare hl,de; clear f
ld de,1024-16
sbc hl,de ;set f bits
add hl,de
jr c,notgoright
ld a,K_RIGHT
ret
notgoright:
or a ;compare hl,de; clear f
ld de,512
sbc hl,de ;set f bits
add hl,de
jr nc,notgoup
ld a,K_UP
ret
notgoup:
ld a,K_DOWN
ret
;;end doseek
;;;A=beneath(ix->monster) or A=checkspot(ix->monster,de=offset)
;;destroys: hl,de,a
beneath:
ld de,levelwidth ;
checkspot: ;;; de->offset to check
ld h,(ix+sprxyoffh) ;
ld l,(ix+sprxyoffl) ;
add hl,de ;
checkthis: ;;; A=checkthis(hl= xyspot)
ld a,h ;
and 3 ;
ld h,a ;
ld de,GRAPH_MEM ;
add hl,de ;
ld a,(hl) ;
ret
;;;;;end beneath