version 0.5: moving enemies, some fixes
[nemesis.git] / nemesis.z80
1         .include "asm86.h"
2         .include "ti86asm.inc"
3         .include "ti86abs.inc"
4
5         .org _asm_exec_ram
6
7         nop
8         jp  Start
9         .dw $0001
10         .dw Title
11         .dw spr_ship
12 Title:  .db "Nemesis v0.5.725 by Shiar",0
13 Start:
14         jr init
15
16 just_fired      = $c0f9         ;byte
17 temp1           = $c100         ;word
18
19 ;---------------------- init --------------------------------------------------
20
21 init:
22         call _runindicoff
23
24 ;---------------------- main menu ---------------------------------------------
25
26 ;---------------------- game setup --------------------------------------------
27
28 play_game:
29         call Next_level
30
31 ;------------------------------------------------------------------------------
32 ;---------------------- game loop ---------------------------------------------
33 ;------------------------------------------------------------------------------
34
35 game_main_loop:
36         ld  hl,timer            ;update time
37         inc (hl)
38
39 Clear_screen:
40         xor a
41         ld  hl,GRAPH_MEM+(16*12)
42         ld  b,a
43 clearloop:
44         ld  (hl),a
45         inc hl
46         ld  (hl),a
47         inc hl
48         ld  (hl),a
49         inc hl
50         djnz clearloop
51
52 check_exitkey:
53         ld  a,%00111111         ;<exit> pressed?
54         out (1),a
55         nop
56         nop
57         in  a,(1)
58         bit 6,a
59         jr  z,quit              ;yes: quit game
60
61 game_stuff:
62         call Level_event        ;insert enemies
63         call Handle_Ship        ;move you
64         call Fire_bullet        ;check for fire
65         call Handle_enemies     ;move enemies
66         call Handle_bullets     ;move your bullets
67         call Enemy_bullets      ;move enemy bullets
68         call Enemies_hit        ;check for collision with enemies
69
70         call Display_Screen     ;display all
71         halt \ halt \ halt      ;delay
72         jr   game_main_loop     ;loop
73
74 quit:   ret
75
76 ;---------------------- display -----------------------------------------------
77
78 Display_Screen:
79         ld  a,64                ;Display Image
80         ld  hl,GRAPH_MEM+(16*12)
81         ld  de,$fc00
82 displayloop:
83         ld  bc,12
84         ldir
85         inc de
86         inc de
87         inc de
88         inc de
89         dec a
90         jr  nz,displayloop
91
92         ld  hl,$1006            ;Display Score
93         ld  (_curRow),hl
94         ld  hl,(timer)
95         ld  h,0
96         jp  _D_HL_DECI
97         ret
98
99 ;------------------------- handle ship ----------------------------------------
100
101 Handle_Ship:
102         ld  a,(your_occ)
103         or  a
104         jr  z,ok                ;0 = normal stat
105
106         inc a                   ;next (explosion)frame
107         ld  (your_occ),a        ;save
108
109         cp  34                  ;last explosion frame?
110         jr  c,exploding_you     ;not yet: display explosion
111         cp  54                  ;delay finished?
112         jp  z,game_over         ;yes = game over
113         ret                     ;don't display anything
114
115 ok:
116         ld  a,%01111110
117         out (1),a
118         ld  hl,y
119         in  a,(1)
120         rra
121         ld  b,a
122
123         jr  c,no_down
124         ld  a,(hl)
125         inc a
126         cp  73                  ;y < 73
127         jr  z,no_down
128         ld  (hl),a
129 no_down:
130         dec hl
131         rr  b
132         jr  c,no_left
133         ld  a,(hl)
134         dec a
135         jr  z,no_left           ;x > 0
136         ld  (hl),a
137 no_left:
138         rr b   
139         jr  c,no_right
140         ld  a,(hl)
141         inc a
142         cp  89                  ;x < 89
143         jr  z,no_right
144         ld  (hl),a
145 no_right:
146         ld d,(hl)
147         inc hl
148         rr  b
149         jr  c,no_up
150         ld  a,(hl)
151         dec a
152         cp  15                  ;y > 15
153         jr  z,no_up
154         ld  (hl),a
155 no_up:  ld  ix,spr_ship01
156
157 display_common:
158         ld  e,(hl)
159         jp  drw_spr             ;ret
160
161 exploding_you:
162         srl a                   ;half the framerate
163         dec a                   ;first frame is 1>inc>srl>dec = 0
164         ld  hl,x-1
165
166 explosion_stuff:
167         rra
168         add a,a
169         add a,a
170         add a,a
171         ld  c,a
172         ld  b,0
173         ld  ix,spr_explosion
174         add ix,bc
175         inc hl
176         ld  d,(hl)
177         inc hl
178         jr  display_common
179
180 damage_you:
181         ld  a,1                 ;set to explode (1st frame)
182         ld  (your_occ),a
183         ret
184
185 ;------------------------- fire bullet ----------------------------------------
186
187 Fire_bullet:
188         ld  a,%00111111
189         out (1),a
190         ld  a,(your_occ)
191         or  a
192         ret nz                  ;return if not normal stat
193         ld  hl,just_fired
194         in  a,(1)
195         bit 4,a
196         jr  z,fire              ;fire pressed?
197         ld  (hl),0              ;not fired
198         ret
199
200 fire:   ld  a,(hl)
201         or  a                   ;can't fire when 1
202         ret nz
203         ld  (hl),1              ;just fired
204
205         ld  hl,ybullets
206         ld  de,3
207         ld  b,10
208 find_ybullet:
209         ld  a,(hl)
210         or  a
211         jr  z,found_ybullet     ;0 = no bullet here
212         add hl,de
213         djnz find_ybullet       ;look next bullet
214         ret
215
216 found_ybullet:
217         ld  (hl),1              ;use bullet
218         inc hl
219         ld  a,(x)
220         add a,5
221         ld  (hl),a              ;set x
222         ld  a,(y)
223         add a,2
224         inc hl
225         ld  (hl),a              ;set y
226         ret
227
228 ;------------------------ handle bullets --------------------------------------
229
230 remove_bullet:
231         dec hl
232         ld  (hl),0              ;dump this bullet!
233         ret
234
235 Handle_bullets:
236         ld  hl,ybullets
237         ld  b,10
238 scan_bullets:
239         push bc
240         push hl
241         ld  (temp1),hl
242         ld  a,(hl)
243         inc hl
244         dec a
245         call z,bullet_type1
246         pop hl
247         pop bc
248         ld  de,3
249         add hl,de
250         djnz scan_bullets
251         ret
252
253 bullet_type1:
254         ld  a,(hl)              ;d = X
255         inc a                   ;move right
256         cp  $5a                 ;off screen?
257         jr  z,remove_bullet
258         inc a                   ;move right
259         cp  $5a                 ;off screen?
260         jr  z,remove_bullet
261         ld  (hl),a              ;save new pos.
262         ld  d,a
263         inc hl
264         ld  e,(hl)              ;e = Y
265         ld  ix,spr_bullet01
266         push de
267         call drw_spr            ;display bullet
268         pop de
269         ld  b,nrenemies
270         ld  hl,enemies
271
272 hit_enemies:                    ;Hits with normal enemies
273         push hl
274
275         ld  a,(hl)
276         and %00000010
277         jr  z,nohit             ;no hit when enemy_occ <> 2/3
278
279         inc hl
280         inc hl
281         ld  a,(hl)              ;check x
282         sub d
283         add a,5
284         jp  m,nohit
285         cp  8
286         jr  nc,nohit
287
288         inc hl
289         ld  a,(hl)              ;check y
290         sub e
291         add a,5
292         jp  m,nohit
293         cp  10
294         jr  nc,nohit
295
296         xor a
297         push hl
298         ld  hl,(temp1)
299         ld  (hl),a              ;remove bullet
300         pop hl
301
302         dec hl
303         dec hl
304         dec hl
305         ld  a,(hl)              ;occ
306         ld  b,a                 ;push occ
307         srl a
308         srl a                   ;occ/4 = HP left
309         jr  nz,hpleft
310         ld  (hl),$01            ;set to explode
311         inc hl
312         ld  (hl),a              ;explosionFrame 0
313         pop hl
314         ret
315
316 hpleft:
317         ld  a,b                 ;pop occ
318         sub %00000100           ;decrease HP by one
319         ld  (hl),a              ;save
320         pop hl
321         ret
322
323 nohit:  pop hl
324         inc hl
325         inc hl
326         inc hl
327         inc hl
328         djnz hit_enemies        ;check next enemy
329         ret
330
331 ;--------------------------- level events -------------------------------------
332
333 Level_event:
334         ld  a,(nextevent)
335         dec a
336         ld  (nextevent),a
337         or  a
338         ret nz
339
340 do_event:
341         ld  hl,(curevent)
342         ld  de,enemies-4
343 chk_noenemy:
344         inc de
345         inc de
346         inc de
347         inc de
348         ld  a,(de)
349         or  a                   ;0 = no enemy present
350         jr  nz,chk_noenemy
351
352         ld  a,(hl)              ;type
353         ld  hl,enemy01
354         ld  c,a
355         ld  b,0
356         add hl,bc
357         add hl,bc
358         add hl,bc               ;hl = enemy specs
359         ld  a,(hl)              ;load hitpoints+occ of this enemy class
360         ld  (de),a              ;occ
361
362         inc hl
363         inc de
364         ld  a,(hl)              ;load movement+type of this enemy class
365         ld  (de),a              ;type
366
367         inc de
368         ld  a,$5a               ;appear at right edge of screen
369         ld  (de),a              ;x
370         inc de
371
372         ld  hl,(curevent)
373         inc hl
374         ld  a,(hl)
375         ld  (de),a              ;y
376
377         inc hl                  ;@ next event
378         ld  a,(hl)
379         cp  $ff                 ;255 = end marker
380         jp  z,Next_level
381         ld  (nextevent),a       ;else time to next event
382
383         inc hl
384         ld  (curevent),hl       ;update pointer
385
386         or  a                   ;no delay
387         jr  z,do_event
388         ret                     ;no more events for now
389
390 ;--------------------------- enemy fires --------------------------------------
391
392 Enemy_fires:                    ;de = x,y
393         dec d
394         dec d                   ;d = x-2
395         inc e                   ;e = y+1
396
397         ld  b,10
398         ld  hl,ebullets
399 find_ebullet:
400         ld  a,(hl)
401         or  a
402         jr  z,found_ebullet     ;0 = not used
403         inc hl
404         inc hl
405         inc hl
406         djnz find_ebullet       ;look next bullet
407         ret
408
409 found_ebullet:
410         ld  (hl),1              ;use bullet
411         inc hl
412         ld  (hl),d              ;set x-pos
413         inc hl
414         ld  (hl),e              ;set y-pos
415         ret         
416
417 ;----------------------------- enemy bullets ----------------------------------
418
419 Enemy_bullets:
420         ld  hl,ebullets
421         ld  b,10
422 handle_bullet:
423         push bc
424         push hl
425         ld  a,(hl)
426         or  a
427         jr  nz,enemy_bullet
428 next_bullet:
429         pop hl
430         pop bc
431         inc hl
432         inc hl
433         inc hl
434         djnz handle_bullet
435         ret
436
437 enemy_bullet:
438         inc hl
439         ld  a,(hl)              ;bullet x
440         dec a
441         jp  m,remove_ebullet    ;off screen?
442         jr  z,remove_ebullet    ;"
443         dec a                   ;move left
444         ld  (hl),a
445         ld  d,a                 ;d=x
446         inc hl
447         ld  e,(hl)              ;e=y
448         ld  ix,spr_bullet11     ;display enemy bullet
449         call drw_spr
450
451         ld  a,(your_occ)
452         or  a
453         jr  nz,next_bullet      ;0 = you're normal
454
455         pop hl
456         push hl
457         inc hl                  ;check x
458         ld  a,(x)
459         sub (hl)
460         add a,6
461         jp  m,next_bullet
462         cp  9
463         jr  nc,next_bullet
464
465         inc hl                  ;check y
466         ld  a,(y)
467         sub (hl)
468         add a,6
469         jp  m,next_bullet
470         cp  9
471         jr  nc,next_bullet
472
473         call damage_you         ;HIT!!
474 remove_ebullet:
475         dec hl
476         ld   (hl),0             ;bullet > unused
477         jr   next_bullet
478
479 ;--------------------------- handle enemies -----------------------------------
480
481 Handle_enemies:
482         ld  hl,enemies
483         ld  b,nrenemies         ;loop 20x
484
485 handle_enemy:
486         push bc
487         push hl
488
489         ld  a,(hl)
490         and %00000011
491         jr  z,next_enemy        ;occ "no enemy" 0
492         dec a
493         jr  z,exploding_enemy   ;occ "exploding" 1
494         ld  b,1
495         dec a
496         jr  z,normal_enemy      ;occ "normal" 2
497
498 moving_enemy:                   ;occ "moving" 3
499         ld  b,0
500
501 normal_enemy:
502         inc hl
503         ld  a,(hl)              ;type
504         and %11100000           ;move-type
505         add a,b                 ;add move bit from occ
506         ld  b,a                 ;save in b
507         ld  a,(hl)              ;type
508         add a,a
509         add a,a
510         add a,a
511         ld  c,a                 ;type*8 = offset
512
513         inc hl
514         ld  a,(hl)              ;x
515         dec a                   ;move left
516         jp  m,remove_enemy      ;off screen
517         jr  z,remove_enemy      ;"
518         ld  d,a
519
520         inc hl
521         ld  e,(hl)              ;y
522         ld  a,b                 ;%xxx00001=moving -0=normal
523         dec a
524         jr  z,ymove_done        ;skip y-move
525
526 ;       srl a
527 ;       ld  b,a                 ;b = %0xxx0000 (move stat)
528         ld  a,(timer)
529         and %00010000           ;switches 0<>1 every 16 turns
530 ;       add a,b                 ;a = new move stat
531 ;       add a,a
532 ;       ld  b,a                 ;b = %xxx00000 (new move stat*2)
533
534 ;       dec hl \ dec hl
535 ;       ld  a,(hl)              ;type
536 ;       and %00011111           ;reset move-type
537 ;       add a,b                 ;set new move-type
538 ;       ld  (hl),a
539 ;       inc hl \ inc hl         ;@y
540
541 ;       and %00100000
542         jr  z,movedown
543 moveup: dec (hl)                ;decrease y-pos
544         jr ymove_done
545 movedown:
546         inc (hl)                ;increase y-pos
547
548 ymove_done:
549         dec hl                  ;@x
550         ld  (hl),d              ;store new x
551         ld  ix,spr_enemy01
552         ld  b,$00
553         add ix,bc
554
555 ;       push hl                 ;save registers
556         push de
557         call drw_spr            ;display
558         pop  de                 ;restore (destroyed by drw_spr)
559 ;       pop  hl
560
561 ;       dec hl
562 ;       ld  b,(hl)              ;type
563 ;       and %00011111           ;enemy class
564 ;       ld  hl,enemy01          ;all enemies' specs
565 ;       inc b                   ;next enemy's specs
566 ;       ld  c,$00
567 ;       add hl,bc
568 ;       add hl,bc
569 ;       add hl,bc               ;go there
570 ;       dec hl                  ;last byte of this enemy's specs
571
572         ld  a,$ff               ;fire frequency
573         call Random             ;random value < a
574         dec a                   ;fire if 1
575         call z,Enemy_fires      ;fires bullet
576         jr   next_enemy
577
578 remove_enemy:
579         pop hl
580         ld  (hl),$0000          ;bye bye enemy
581         push hl
582 next_enemy:
583         pop hl
584         ld  bc,$0004
585         add hl,bc
586         pop bc
587         djnz handle_enemy
588         ret
589
590 exploding_enemy:
591         inc  hl
592         push hl
593         ld   a,(hl)
594         call explosion_stuff    ;display explosion
595         pop  hl
596
597         ld  a,(hl)
598         cp  15
599         jr  z,remove_enemy      ;remove when at last frame
600         inc a
601         ld  (hl),a              ;next frame
602         jr  next_enemy
603
604 ;--------------------------- check collision ----------------------------------
605
606 Enemies_hit:
607         ld  a,(your_occ)
608         or  a                   ;0 = you're normal
609         ret nz
610
611         ld  de,(x)              ;e = X, d = Y
612         ld  hl,enemies
613         ld  b,nrenemies         ;check all 20 enemies
614 check_collision:
615         push hl
616         ld  a,(hl)
617         and %00000010
618         jr  z,check_next        ;2/3 = ok
619
620         inc hl
621         inc hl
622         ld  a,(hl)              ;check x match
623         sub e
624         add a,6
625         jp  m,check_next
626         cp  12
627         jr  nc,check_next
628
629         inc hl
630         ld  a,(hl)              ;check y match
631         sub d
632         add a,6
633         jp  m,check_next
634         cp  12
635         jr  nc,check_next
636
637         dec hl
638         dec hl
639         xor a
640         ld  (hl),a              ;explosionFrame 0
641         dec hl
642         inc a
643         ld  (hl),a              ;set to explode
644         call damage_you         ;auch!
645
646 check_next:
647         pop hl
648         inc hl
649         inc hl
650         inc hl
651         inc hl
652         djnz check_collision
653         ret
654
655 ;--------------------------- next level ---------------------------------------
656
657 Next_level:
658         ld  hl,Leveldata+1      ;reset level data
659         ld  (curevent),hl
660
661         call _clrLCD            ;clear screen
662         ld  hl,$0703
663         ld  (_curRow),hl        ;center
664         ld  hl,txt_level
665         call _puts              ;display "LEVEL "
666
667         ld  a,(level)
668         inc a                   ;increase level nr.
669         ld  (level),a
670         ld  l,a
671         ld  h,$00
672
673         call UNPACK_HL
674         add a,'0'
675         ld  b,a
676         call UNPACK_HL
677         add a,'0'
678         call _putc              ;display second digit
679         ld  a,b
680         call _putc              ;display first digit
681
682         ld  b,$20
683 wait:   halt \ halt
684         djnz wait               ;delay
685         call _getkey            ;wait for keypress
686         jr  game_setup          ;prepare display and vars
687         ret
688
689 ;--------------------------- game over ----------------------------------------
690
691 game_over:
692         ld  hl,Leveldata+1      ;reset level data
693         ld  (curevent),hl
694
695         call _clrLCD            ;clear screen
696         ld  hl,$0603
697         ld  (_curRow),hl        ;center
698         ld  hl,txt_gameover
699         call _puts              ;display "GAME OVER"
700
701         ld  b,$20
702 wait2:  halt \ halt
703         djnz wait2              ;delay
704         call _getkey            ;wait for keypress
705         jr  game_setup          ;prepare display and vars
706         ret
707
708 ;---------------------- setup game --------------------------------------------
709
710 game_setup:
711         call _clrLCD
712         ld  hl,$1005
713         ld  (_curRow),hl
714         ld  hl,txt_score        ;display "SCORE"
715         call _puts                      ;display texts
716
717         xor a
718         ld  (timer),a                   ;reset time
719         ld  (level),a                   ;level 1
720         ld  hl,Leveldata+1
721         ld  (curevent),hl               ;reset level
722         ld  hl,(Leveldata)
723         ld  (nextevent),hl
724                                         ;ret
725 ;---------------------- exit --------------------------------------------------
726
727 exit_game:
728         ret
729
730 ;--------------------------- putsprite ----------------------------------------
731
732 offsets_table:
733         .db 128,64,32,16,8,4,2,1
734 drw_spr:
735         ld  a,d
736         and 7
737         ld  hl,offsets_table
738         ld  c,a
739         ld  b,0
740         add hl,bc
741         ld  a,(hl)
742         ld  (_smc1+1),a
743
744         ld  (_smc1+1),a
745         ld  hl,GRAPH_MEM
746         ld  a,e
747         add a,a
748         add a,e
749         add a,a
750         rl  b
751         add a,a
752         rl  b
753         srl d
754         srl d
755         srl d
756         add a,d
757         jr  nc,_n1
758         inc b
759 _n1:    ld  c,a
760         add hl,bc
761           
762         ld  d,(ix)
763         ld  b,(ix+1)
764 _oloop: push bc                 ;Save # of rows
765         push hl                 ;Save screen address
766         ld  b,d                 ;Load width
767         ld  c,(ix+2)            ;Load one line of image
768         inc ix
769 _smc1:  ld  a,1                 ;Load pixel mask
770 _iloop: sla c                   ;Test leftmost pixel
771         jr  nc,_noplot          ;See if a plot is needed
772         ld  e,a                 ;OR pixel with screen
773         or  (hl)
774         ld  (hl),a
775         ld  a,e
776 _noplot: rrca
777         jr  nc,_notedge         ;Test if edge of byte reached
778         inc hl                  ;Go to next byte
779 _notedge:djnz _iloop
780         pop hl                  ;Restore address
781         ld  bc,12               ;Go to next line
782         add hl,bc
783         pop bc                  ;Restore data
784         djnz _oloop
785         ret
786
787 ;---------------------- random ------------------------------------------------
788
789 Random:                ; Creates a random number 0 <= x < A
790  push bc
791  push de
792  push hl
793  ld b,a
794  ld a,r
795  add a,a
796  ld hl,0
797  ld d,0
798  ld e,a
799 RMul:
800  add hl,de
801  djnz RMul
802  ld a,h
803  pop hl
804  pop de
805  pop bc
806  ret
807
808 ;------------------------
809
810 _D_HL_DECI:
811          push     bc
812          ld       de,up_data+4
813          ld       b,5
814 ldhld:   call     UNPACK_HL
815          add      a,'0'
816          ld       (de),a
817          dec      de
818          djnz     ldhld
819          ld       hl,up_data
820          ld       b,4
821 lis:     ld       a,(hl)
822          cp       '0'
823          jr       nz,dis
824          ld       (hl),' '
825          inc      hl
826          djnz     lis
827 dis:     ld       hl,up_data
828          call     _puts
829          pop      bc
830          ret
831
832 up_data: .db      "PAD98",0
833
834
835
836 ;------------------------------- sprites --------------------------------------
837
838 spr_ship:
839         .db 9,1         ;ship icon
840         .db %11100000   ; ███
841         .db %11111000   ; █████
842         .db %00111110   ;   █████
843         .db %11111001   ; █████  █
844         .db %11111101   ; ██████ █
845         .db %11111001   ; █████  █
846         .db %00111110   ;   █████
847         .db %11111000   ; █████
848         .db %11100000   ; ███
849
850 spr_ship01:
851         .db 7,7         ;ship alpha class
852         .db %01110000   ;  ███
853         .db %11100000   ; ███
854         .db %11111100   ; ██████
855         .db %11110010   ; ████  █
856         .db %11111100   ; ██████
857         .db %11100000   ; ███
858         .db %01110000   ;  ███
859 spr_ship02:
860         .db 7,7         ;ship beta class
861         .db %11000000   ; ██
862         .db %11110000   ; ████
863         .db %01111100   ;  █████
864         .db %01110010   ;  ███  █
865         .db %01111100   ;  █████
866         .db %11110000   ; ████
867         .db %11000000   ; ██
868
869 spr_bullet01:
870         .db 5,3         ;your bullets
871         .db %00110000   ;   ░▒▓██
872         .db %11111000   ; ░▒▓█████
873         .db %00110000   ;   ░▒▓██
874 spr_bullet02:
875         .db 5,3         ;your bullets
876         .db %11110000   ; ░▒▓████
877         .db %11111000   ; ░▒▓█████
878         .db %11110000   ; ░▒▓████
879
880 spr_bullet11:
881         .db 3,3         ;enemy bullets
882         .db %01000000   ;  █▓▒░
883         .db %11100000   ; ███▓▒░
884         .db %01000000   ;  █▓▒░
885
886 spr_explosion:                               
887         .db 8,6         ;1
888         .db %00000000
889         .db %00011100   ;    ███
890         .db %00111110   ;   █████
891         .db %01010110   ;  █ █ ██
892         .db %00111000   ;   ███
893         .db %00000000
894
895         .db 8,6         ;2
896         .db %00110000   ;   ██
897         .db %01001110   ;  █ ▒███
898         .db %10111110   ; █ █████
899         .db %01001111   ;  █ ▒████
900         .db %00111000   ;   ███
901         .db %00011010   ;    ██ █
902
903         .db 8,6         ;3
904         .db %10110011   ; █ ██  ██
905         .db %01001110   ;  █  ███
906         .db %10110101   ; █ ██▒█▒█
907         .db %01000101   ;  █  ▒█▒█
908         .db %00111110   ;   █████
909         .db %11011010   ; ██ ██ █
910
911         .db 8,6         ;4
912         .db %00101010   ; ▒ █▒█ █▒
913         .db %01000110   ;  █  ▒██
914         .db %10110101   ; █ ██ █ █
915         .db %01100110   ;  ██  ██▒
916         .db %00111100   ;   ████▒
917         .db %01011001   ; ▒█ ██ ▒█
918
919         .db 8,6         ;5
920         .db %01000001   ;  █▒ ▒ ▒█
921         .db %00100101   ;  ▒█  █▒█
922         .db %00010100   ; ▒ ▒█ █ ▒
923         .db %01000100   ;  █▒  █
924         .db %00010010   ;   ▒█▒▒█
925         .db %10011010   ; █▒ ██ █▒
926
927         .db 8,6         ;6
928         .db %01000100   ;  █   █ ▒
929         .db %00100000   ;   ▒█ ▒ ▒
930         .db %00000001   ;    ▒ ▒ █
931         .db %01000100   ;  █   █
932         .db %00100010   ;   █▒  █
933         .db %01001000   ; ▒█ ▒█ ▒
934
935         .db 8,6         ;7
936         .db %00001000   ;  ▒  █▒
937         .db %11000010   ; ██ ▒  █
938         .db %00000000   ;        ▒
939         .db %00100000   ;  ▒█  ▒
940         .db %00000001   ;   ▒   ▒█
941         .db %00110000   ;  ▒██▒
942
943         .db 8,6         ;8
944         .db %00000100   ;     ▒█
945         .db %00000000   ; ▒▒    ▒
946         .db %01000000   ;  █
947         .db %00000000   ;   ▒
948         .db %00000010   ;       █▒
949         .db %00100100   ;   █▒ █
950
951 spr_icon01:
952         .db 5,4
953         .db %00100000   ;   █
954         .db %10101000   ; █ █ █
955         .db %11111000   ; █████
956         .db %01110000   ;  ███
957 spr_icon02:
958         .db 5,4
959         .db %00000000   ;  ███
960         .db %00000000   ; ██ ██
961         .db %00000000   ; █   █
962         .db %00000000   ;
963
964 ;---------------------------- texts -------------------------------------------
965
966 txt_title:      .db "* * NEMESIS * *",0
967 txt_level:      .db "LEVEL ",0
968 txt_gameover:   .db "GAME OVER!",0
969 txt_score:      .db "SCORE",0
970
971 ;---------------------------- save data ---------------------------------------
972
973 stored_data_start:
974
975 level           .db $00                 ;level number
976 timer           .db $00                 ;frame counter
977 curevent        .dw Leveldata+1         ;next event
978 nextevent       .db (Leveldata)         ;time to next event
979
980 score           .dw $0000
981
982 your_occ        .db $00                 ;0=normal 1..16=exploding
983 ;lives          .dw $0003       ;unused
984 x               .db $16                 ;x-pos
985 y               .db $46                 ;think about it..
986 hp              .db $00                 ;hitpoints left
987
988 ybullets        .dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0       ;10 x (state,x,y)
989 ebullets        .dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0       ;10 x (state,x,y)
990
991 nrenemies       = 32
992 enemies         .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
993                 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
994                 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
995                 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
996
997                 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
998                 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
999                 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
1000                 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
1001
1002 ; %111111 (HP left) 11 (00=no enemy 01=exploding 10=normal 11=moving)
1003 ; %111 (move ptrn) 11111 (ship or explosion frame)  %11111111 (x) %11111111 (y)
1004
1005
1006 ;---------------------------- enemy data --------------------------------------
1007
1008 spr_enemy01:
1009         .db 6,6         ;enemy type one
1010         .db %00111100   ;   ████
1011         .db %01110000   ;  ███
1012         .db %11110000   ; ████
1013         .db %11110000   ; ████
1014         .db %01110000   ;  ███
1015         .db %00111100   ;   ████
1016 spr_enemy02:
1017         .db 6,6         ;enemy type two
1018         .db %00111000   ;   ███
1019         .db %01100000   ;  ██
1020         .db %11111100   ; ██████
1021         .db %11111100   ; ██████
1022         .db %01100000   ;  ██
1023         .db %00111000   ;   ███
1024 spr_enemy03:
1025         .db 6,6         ;enemy type three
1026         .db %01111100   ;  █████
1027         .db %11110000   ; ████
1028         .db %11111000   ; █████
1029         .db %11111000   ; █████
1030         .db %11110000   ; ████
1031         .db %01111100   ;  █████
1032 spr_enemy04:
1033         .db 6,6         ;enemy type four
1034         .db %00111000   ;   ███
1035         .db %01111100   ;  █████
1036         .db %11111000   ; █████
1037         .db %11111000   ; █████
1038         .db %01111100   ;  █████
1039         .db %00111000   ;   ███
1040
1041 enemy01:                                ;HP:1  move:- fire:-
1042         .db %00000010,%00000000,%00000000               ;first two enemy bytes
1043 enemy02:                                ;HP:1  move:1 fire:1.5%
1044         .db %00000011,%00100001,%01111111
1045 enemy03:                                ;HP:2  move:- fire:3%
1046         .db %00000110,%00000010,%00001111
1047 enemy04:                                ;HP:5  move:- fire:6%
1048         .db %00010010,%00000011,%00000011
1049 enemy05:                                ;HP:10 move:- fire:25%
1050         .db %00100111,%00000100,%00000011
1051
1052 ;---------------------------- level data --------------------------------------
1053
1054 Leveldata:                      ;time,enemyclass,ypos
1055         .db $0d,$00,$38                 ;first wave (bottom)
1056         .db $00,$00,$40
1057         .db $00,$00,$48
1058         .db $1e,$00,$10                 ;second wave (top)
1059         .db $00,$00,$18
1060         .db $00,$00,$20
1061         .db $1e,$00,$24                 ;third wave (middle)
1062         .db $00,$02,$2c
1063         .db $00,$00,$34
1064
1065         .db $0d,$00,$10                 ;top & bottom
1066         .db $00,$00,$4a
1067         .db $2a,$01,$2d                 ;middle: moving
1068         .db $0c,$02,$2d                 ;        3HP
1069         .db $0b,$02,$2d                 ;        3HP
1070         .db $09,$00,$27                 ;two 1HP behind him
1071         .db $00,$00,$33
1072         .db $09,$02,$21                 ;two 3HP behind them
1073         .db $00,$02,$39
1074         .db $09,$02,$1b                 ;and two 3HP behind them
1075         .db $00,$02,$3f
1076
1077         .db $15,$03,$11                 ;one vertical line of 8HPs
1078         .db $00,$03,$19
1079         .db $00,$03,$21
1080         .db $00,$03,$29
1081         .db $00,$03,$31
1082         .db $00,$03,$39
1083         .db $00,$03,$41
1084         .db $00,$03,$49
1085
1086         .db $0c,$02,$11                 ;one vertical line of 3HPs
1087         .db $00,$02,$19
1088         .db $00,$02,$21
1089         .db $00,$02,$29
1090         .db $00,$02,$31
1091         .db $00,$02,$39
1092         .db $00,$02,$41
1093         .db $00,$02,$49
1094
1095         .db $0c,$00,$11                 ;one vertical line of 1HPs
1096         .db $00,$00,$19
1097         .db $00,$00,$21
1098         .db $00,$00,$29
1099         .db $00,$00,$31
1100         .db $00,$00,$39
1101         .db $00,$00,$41
1102         .db $00,$00,$49
1103
1104
1105
1106
1107
1108
1109
1110         .db $f1,$01,$40
1111         .db $10,$00,$30
1112         .db $10,$02,$20
1113         .db $40,$01,$10
1114         .db $01,$00,$44
1115         .db $15,$01,$31
1116         .db $04,$02,$38
1117         .db $05,$00,$40
1118         .db $03,$00,$2f
1119         .db $04,$00,$3a
1120         .db $12,$02,$10
1121         .db $10,$03,$18
1122         .db $0e,$03,$20
1123         .db $0c,$03,$28
1124         .db $0a,$02,$30
1125         .db $08,$02,$38
1126         .db $06,$01,$40
1127         .db $04,$00,$48
1128         .db $2a,$00,$20
1129         .db $ff,$ff,$ff
1130
1131 ;----------------------------- end --------------------------------------------
1132
1133         .end
1134 .end
1135
1136
1137
1138
1139 ;----------------------------- NEMESIS'86 by Shiar ----------------------------
1140
1141 ;----------------------------- version history --------------------------------
1142
1143 ;0.01.717 -- 17.VII.99 -- size 984
1144 ;
1145 ;       + movement of ship over whole screen
1146 ;       + enemies moving from right to left, appearing right at specified times
1147 ;
1148 ; 0.1.718 -- 18.VII.99 -- size 907
1149 ;
1150 ;       # no crash when level restarts for the third time
1151 ;       * exit-procedure updated, unnecessary stuff/keychecks removed
1152 ;       * alot of unused code removed
1153 ;       + different types of enemies (just look different)
1154 ;       + collision detection!! enemy ships disappear when you hit them
1155 ;
1156 ; 0.2.718 -- 18.VII.99 -- size 1153
1157 ;
1158 ;       + ability to fire bullets (F1). Enemies disappear on impact
1159 ;       * enemies explode instead of disappearing
1160 ;
1161 ; 0.3.719 -- 19.VII.99 -- size 1401
1162 ;
1163 ;       * bullets appear correctly (not INSIDE your ship)
1164 ;       + some enemies can take multiple hits (differs per class)
1165 ;       + all enemies fire bullets at random
1166 ;       + if you're hit by bullet/enemy, you'll lose one hitpoint
1167 ;
1168 ; 0.4.720 -- 20.VII.99 -- size 1481
1169 ;
1170 ;       # collision detection fixed and optimized (much faster now!)
1171 ;       + shell-icon added (YAS type)
1172 ;       * code optimizations, some data "compression"
1173 ;       * explosion looks better, and some vars removed/smaller
1174 ;       # enemies are removed if at left side (instead of becoming invisible)
1175 ;       + displays level number before each level begins
1176 ;
1177 ; 0.5.725 -- 25.VII.99 -- size 1778
1178 ;
1179 ;       * waits a sec at level display (in case of accidental keypress)
1180 ;       * moving enemies (move up&down)
1181 ;       # bullets removed correctly so they can be used again later
1182 ;       * first level made
1183 ;       # enemy weaponfire is fired from correct positions
1184 ;       + your ship explodes on impact with ships/bullets
1185 ;       * game over screen will be displayed just *after* your ship's gone
1186 ;       + frame counter onscreen
1187 ;
1188
1189 ;        + added        - removed       * changed       # bug fixed