12 Title: .db "Nemesis v0.5.725 by Shiar",0
16 just_fired = $c0f9 ;byte
19 ;---------------------- init --------------------------------------------------
24 ;---------------------- main menu ---------------------------------------------
26 ;---------------------- game setup --------------------------------------------
31 ;------------------------------------------------------------------------------
32 ;---------------------- game loop ---------------------------------------------
33 ;------------------------------------------------------------------------------
36 ld hl,timer ;update time
41 ld hl,GRAPH_MEM+(16*12)
53 ld a,%00111111 ;<exit> pressed?
59 jr z,quit ;yes: quit game
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
70 call Display_Screen ;display all
71 halt \ halt \ halt ;delay
72 jr game_main_loop ;loop
76 ;---------------------- display -----------------------------------------------
79 ld a,64 ;Display Image
80 ld hl,GRAPH_MEM+(16*12)
92 ld hl,$1006 ;Display Score
99 ;------------------------- handle ship ----------------------------------------
104 jr z,ok ;0 = normal stat
106 inc a ;next (explosion)frame
107 ld (your_occ),a ;save
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
155 no_up: ld ix,spr_ship01
162 srl a ;half the framerate
163 dec a ;first frame is 1>inc>srl>dec = 0
181 ld a,1 ;set to explode (1st frame)
185 ;------------------------- fire bullet ----------------------------------------
192 ret nz ;return if not normal stat
196 jr z,fire ;fire pressed?
201 or a ;can't fire when 1
203 ld (hl),1 ;just fired
211 jr z,found_ybullet ;0 = no bullet here
213 djnz find_ybullet ;look next bullet
217 ld (hl),1 ;use bullet
228 ;------------------------ handle bullets --------------------------------------
232 ld (hl),0 ;dump this bullet!
261 ld (hl),a ;save new pos.
267 call drw_spr ;display bullet
272 hit_enemies: ;Hits with normal enemies
277 jr z,nohit ;no hit when enemy_occ <> 2/3
299 ld (hl),a ;remove bullet
308 srl a ;occ/4 = HP left
310 ld (hl),$01 ;set to explode
312 ld (hl),a ;explosionFrame 0
318 sub %00000100 ;decrease HP by one
328 djnz hit_enemies ;check next enemy
331 ;--------------------------- level events -------------------------------------
349 or a ;0 = no enemy present
358 add hl,bc ;hl = enemy specs
359 ld a,(hl) ;load hitpoints+occ of this enemy class
364 ld a,(hl) ;load movement+type of this enemy class
368 ld a,$5a ;appear at right edge of screen
379 cp $ff ;255 = end marker
381 ld (nextevent),a ;else time to next event
384 ld (curevent),hl ;update pointer
388 ret ;no more events for now
390 ;--------------------------- enemy fires --------------------------------------
392 Enemy_fires: ;de = x,y
402 jr z,found_ebullet ;0 = not used
406 djnz find_ebullet ;look next bullet
410 ld (hl),1 ;use bullet
417 ;----------------------------- enemy bullets ----------------------------------
441 jp m,remove_ebullet ;off screen?
442 jr z,remove_ebullet ;"
448 ld ix,spr_bullet11 ;display enemy bullet
453 jr nz,next_bullet ;0 = you're normal
473 call damage_you ;HIT!!
476 ld (hl),0 ;bullet > unused
479 ;--------------------------- handle enemies -----------------------------------
483 ld b,nrenemies ;loop 20x
491 jr z,next_enemy ;occ "no enemy" 0
493 jr z,exploding_enemy ;occ "exploding" 1
496 jr z,normal_enemy ;occ "normal" 2
498 moving_enemy: ;occ "moving" 3
504 and %11100000 ;move-type
505 add a,b ;add move bit from occ
511 ld c,a ;type*8 = offset
516 jp m,remove_enemy ;off screen
522 ld a,b ;%xxx00001=moving -0=normal
524 jr z,ymove_done ;skip y-move
527 ; ld b,a ;b = %0xxx0000 (move stat)
529 and %00010000 ;switches 0<>1 every 16 turns
530 ; add a,b ;a = new move stat
532 ; ld b,a ;b = %xxx00000 (new move stat*2)
536 ; and %00011111 ;reset move-type
537 ; add a,b ;set new move-type
539 ; inc hl \ inc hl ;@y
543 moveup: dec (hl) ;decrease y-pos
546 inc (hl) ;increase y-pos
550 ld (hl),d ;store new x
555 ; push hl ;save registers
557 call drw_spr ;display
558 pop de ;restore (destroyed by drw_spr)
563 ; and %00011111 ;enemy class
564 ; ld hl,enemy01 ;all enemies' specs
565 ; inc b ;next enemy's specs
569 ; add hl,bc ;go there
570 ; dec hl ;last byte of this enemy's specs
572 ld a,$ff ;fire frequency
573 call Random ;random value < a
575 call z,Enemy_fires ;fires bullet
580 ld (hl),$0000 ;bye bye enemy
594 call explosion_stuff ;display explosion
599 jr z,remove_enemy ;remove when at last frame
601 ld (hl),a ;next frame
604 ;--------------------------- check collision ----------------------------------
608 or a ;0 = you're normal
611 ld de,(x) ;e = X, d = Y
613 ld b,nrenemies ;check all 20 enemies
618 jr z,check_next ;2/3 = ok
622 ld a,(hl) ;check x match
630 ld a,(hl) ;check y match
640 ld (hl),a ;explosionFrame 0
643 ld (hl),a ;set to explode
644 call damage_you ;auch!
655 ;--------------------------- next level ---------------------------------------
658 ld hl,Leveldata+1 ;reset level data
661 call _clrLCD ;clear screen
663 ld (_curRow),hl ;center
665 call _puts ;display "LEVEL "
668 inc a ;increase level nr.
678 call _putc ;display second digit
680 call _putc ;display first digit
685 call _getkey ;wait for keypress
686 jr game_setup ;prepare display and vars
689 ;--------------------------- game over ----------------------------------------
692 ld hl,Leveldata+1 ;reset level data
695 call _clrLCD ;clear screen
697 ld (_curRow),hl ;center
699 call _puts ;display "GAME OVER"
704 call _getkey ;wait for keypress
705 jr game_setup ;prepare display and vars
708 ;---------------------- setup game --------------------------------------------
714 ld hl,txt_score ;display "SCORE"
715 call _puts ;display texts
718 ld (timer),a ;reset time
719 ld (level),a ;level 1
721 ld (curevent),hl ;reset level
725 ;---------------------- exit --------------------------------------------------
730 ;--------------------------- putsprite ----------------------------------------
733 .db 128,64,32,16,8,4,2,1
764 _oloop: push bc ;Save # of rows
765 push hl ;Save screen address
767 ld c,(ix+2) ;Load one line of image
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
777 jr nc,_notedge ;Test if edge of byte reached
778 inc hl ;Go to next byte
780 pop hl ;Restore address
781 ld bc,12 ;Go to next line
787 ;---------------------- random ------------------------------------------------
789 Random: ; Creates a random number 0 <= x < A
808 ;------------------------
814 ldhld: call UNPACK_HL
832 up_data: .db "PAD98",0
836 ;------------------------------- sprites --------------------------------------
841 .db %11111000 ; █████
842 .db %00111110 ; █████
843 .db %11111001 ; █████ █
844 .db %11111101 ; ██████ █
845 .db %11111001 ; █████ █
846 .db %00111110 ; █████
847 .db %11111000 ; █████
851 .db 7,7 ;ship alpha class
854 .db %11111100 ; ██████
855 .db %11110010 ; ████ █
856 .db %11111100 ; ██████
860 .db 7,7 ;ship beta class
863 .db %01111100 ; █████
864 .db %01110010 ; ███ █
865 .db %01111100 ; █████
870 .db 5,3 ;your bullets
871 .db %00110000 ; ░▒▓██
872 .db %11111000 ; ░▒▓█████
873 .db %00110000 ; ░▒▓██
875 .db 5,3 ;your bullets
876 .db %11110000 ; ░▒▓████
877 .db %11111000 ; ░▒▓█████
878 .db %11110000 ; ░▒▓████
881 .db 3,3 ;enemy bullets
883 .db %11100000 ; ███▓▒░
890 .db %00111110 ; █████
891 .db %01010110 ; █ █ ██
897 .db %01001110 ; █ ▒███
898 .db %10111110 ; █ █████
899 .db %01001111 ; █ ▒████
904 .db %10110011 ; █ ██ ██
905 .db %01001110 ; █ ███
906 .db %10110101 ; █ ██▒█▒█
907 .db %01000101 ; █ ▒█▒█
908 .db %00111110 ; █████
909 .db %11011010 ; ██ ██ █
912 .db %00101010 ; ▒ █▒█ █▒
913 .db %01000110 ; █ ▒██
914 .db %10110101 ; █ ██ █ █
915 .db %01100110 ; ██ ██▒
916 .db %00111100 ; ████▒
917 .db %01011001 ; ▒█ ██ ▒█
920 .db %01000001 ; █▒ ▒ ▒█
921 .db %00100101 ; ▒█ █▒█
922 .db %00010100 ; ▒ ▒█ █ ▒
924 .db %00010010 ; ▒█▒▒█
925 .db %10011010 ; █▒ ██ █▒
928 .db %01000100 ; █ █ ▒
929 .db %00100000 ; ▒█ ▒ ▒
930 .db %00000001 ; ▒ ▒ █
933 .db %01001000 ; ▒█ ▒█ ▒
937 .db %11000010 ; ██ ▒ █
954 .db %10101000 ; █ █ █
955 .db %11111000 ; █████
960 .db %00000000 ; ██ ██
964 ;---------------------------- texts -------------------------------------------
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
971 ;---------------------------- save data ---------------------------------------
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
982 your_occ .db $00 ;0=normal 1..16=exploding
983 ;lives .dw $0003 ;unused
985 y .db $46 ;think about it..
986 hp .db $00 ;hitpoints left
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)
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
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
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)
1006 ;---------------------------- enemy data --------------------------------------
1009 .db 6,6 ;enemy type one
1010 .db %00111100 ; ████
1012 .db %11110000 ; ████
1013 .db %11110000 ; ████
1015 .db %00111100 ; ████
1017 .db 6,6 ;enemy type two
1020 .db %11111100 ; ██████
1021 .db %11111100 ; ██████
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 ; █████
1033 .db 6,6 ;enemy type four
1035 .db %01111100 ; █████
1036 .db %11111000 ; █████
1037 .db %11111000 ; █████
1038 .db %01111100 ; █████
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
1052 ;---------------------------- level data --------------------------------------
1054 Leveldata: ;time,enemyclass,ypos
1055 .db $0d,$00,$38 ;first wave (bottom)
1058 .db $1e,$00,$10 ;second wave (top)
1061 .db $1e,$00,$24 ;third wave (middle)
1065 .db $0d,$00,$10 ;top & bottom
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
1072 .db $09,$02,$21 ;two 3HP behind them
1074 .db $09,$02,$1b ;and two 3HP behind them
1077 .db $15,$03,$11 ;one vertical line of 8HPs
1086 .db $0c,$02,$11 ;one vertical line of 3HPs
1095 .db $0c,$00,$11 ;one vertical line of 1HPs
1131 ;----------------------------- end --------------------------------------------
1139 ;----------------------------- NEMESIS'86 by Shiar ----------------------------
1141 ;----------------------------- version history --------------------------------
1143 ;0.01.717 -- 17.VII.99 -- size 984
1145 ; + movement of ship over whole screen
1146 ; + enemies moving from right to left, appearing right at specified times
1148 ; 0.1.718 -- 18.VII.99 -- size 907
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
1156 ; 0.2.718 -- 18.VII.99 -- size 1153
1158 ; + ability to fire bullets (F1). Enemies disappear on impact
1159 ; * enemies explode instead of disappearing
1161 ; 0.3.719 -- 19.VII.99 -- size 1401
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
1168 ; 0.4.720 -- 20.VII.99 -- size 1481
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
1177 ; 0.5.725 -- 25.VII.99 -- size 1778
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
1189 ; + added - removed * changed # bug fixed