From 18d1f1fa9504854fd39bdf0b13ea98ba001c91b8 Mon Sep 17 00:00:00 2001 From: Mischa Poslawsky Date: Mon, 19 Jul 1999 00:00:00 +0200 Subject: [PATCH] version 0.3: shooting enemies (hitpoints) * bullets appear correctly (not INSIDE your ship) + some enemies can take multiple hits (differs per class) + all enemies fire bullets at random + if you're hit by bullet/enemy, you'll lose one hitpoint --- nemesis.z80 | 311 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 237 insertions(+), 74 deletions(-) diff --git a/nemesis.z80 b/nemesis.z80 index fc84fb3..b735b9c 100644 --- a/nemesis.z80 +++ b/nemesis.z80 @@ -1,12 +1,14 @@ .include "asm86.h" .include "ti86asm.inc" .include "ti86abs.inc" + .org _asm_exec_ram + nop jp Start .dw $0000 .dw Title -Title: .db "Nemesis v0.1.718 by Shiar",0 +Title: .db "Nemesis v0.3.719 by Shiar",0 Start: jr init @@ -69,6 +71,7 @@ Clear_screen: xor a ld hl,GRAPH_MEM+(16*12) ld b,a + ld a,(background) clearloop: ld (hl),a inc hl @@ -91,12 +94,14 @@ game_stuff: call Level_event ;insert enemies call Handle_Ship ;move you call Fire_bullet ;check for fire - call Handle_bullets + call Handle_bullets ;move bullets call Handle_enemies ;move enemies + call Enemy_fires ;check for enemy fire + call Enemy_bullets ;move bullets call Enemies_hit ;check for collision with enemies call Display_Screen ;display all -; halt \ halt \ halt ;delay + halt \ halt \ halt ;delay jr game_main_loop ;loop quit: ret @@ -126,11 +131,10 @@ displayloop: ;------------------------- handle ship ---------------------------------------- Handle_Ship: - ld a,(your_status) -; bit 4,a -; jr nz,you_not_normal + ld a,(your_occ) or a - jr z,ok + jr z,ok ;0 = normal stat + ; dec a ; ld (your_status),a ; ld hl,(lives) @@ -187,14 +191,6 @@ display_common: jp drw_spr ;you_not_normal: -; ld hl,(score) -; ld de,-6 -; add hl,de -; ld a,255 -; cp h -; jr nz,_ok_ -; ld hl,0 -;_ok_: ld (score),hl ; ld a,(your_status) ; dec a ; ld (your_status),a @@ -217,19 +213,23 @@ explosion_stuff: inc hl jr display_common +damage_you: + or %10101010 + ld (background),a + ret + ;------------------------- fire bullet ---------------------------------------- Fire_bullet: ld a,%00111111 out (1),a -; ld a,(your_status) -; or a -; ret nz + ld a,(your_occ) + or a + ret nz ;return if not normal stat ld hl,just_fired - nop in a,(1) bit 4,a - jr z,fire + jr z,fire ;fire pressed? ld (hl),0 ;not fired ret @@ -241,7 +241,6 @@ fire: ld a,(hl) ld hl,ybullets ld de,3 ld b,10 - find_ybullet: ld a,(hl) or a @@ -254,7 +253,7 @@ found_ybullet: ld (hl),1 ;use bullet inc hl ld a,(x) - add a,3 + add a,5 ld (hl),a ;set x ld a,(y) add a,2 @@ -272,7 +271,7 @@ remove_bullet: Handle_bullets: ld hl,ybullets ld b,10 -scan_your_bullets: +scan_bullets: push bc push hl ld (temp1),hl @@ -284,7 +283,7 @@ scan_your_bullets: pop bc ld de,3 add hl,de - djnz scan_your_bullets + djnz scan_bullets ret bullet_type1: @@ -310,8 +309,8 @@ hit_enemies: ;Hits with normal enemies push hl ld a,(hl) - dec a - jr nz,nohit ;no hit when enemy_occ <> 1 + and %00000001 + jr z,nohit ;no hit when enemy_occ <> 1 inc hl inc hl @@ -338,10 +337,23 @@ hit_enemies: ;Hits with normal enemies dec hl dec hl - ld (hl),a ;explosionFrame 0 dec hl + ld a,(hl) ;occ + srl a + srl a ;occ/4 = HP left + jr nz,hpleft ld (hl),2 ;set to explode + inc hl + ld (hl),a ;explosionFrame 0 + pop hl + ret +hpleft: + dec a + add a,a + add a,a + inc a ;HP*4+1 = occ 1 + ld (hl),a ;save pop hl ret @@ -374,18 +386,27 @@ chk_noenemy: or a jr nz,chk_noenemy - ld a,$01 - ld (de),a ;occ inc de - ld a,(hl) ld (de),a ;type - inc de + ld hl,enemy01 + ld c,a + ld b,0 + add hl,bc + add hl,bc + add hl,bc ;hl = enemy specs + dec de + ld a,(hl) ;load hitpoints + or 1 ;set type 1 (normal) enemy + ld (de),a ;occ + inc de + inc de ld a,$5a ld (de),a ;x inc de + ld hl,(curevent) inc hl ld a,(hl) ld (de),a ;y @@ -400,6 +421,121 @@ chk_noenemy: ld (curevent),hl ret +;--------------------------- enemy fires -------------------------------------- + +Enemy_fires: + ld a,r + and %01111111 + cp 19 + ret p + + add a,a + add a,a + ld c,a + ld b,0 ;bc = a*4 + ld hl,enemies + add hl,bc ;hl = enemy + ld a,(hl) + or a + ret z ;return if no enemy + dec a + dec a + ret z ;or exploding enemy + inc hl + inc hl + ld c,(hl) ;enemy x-pos + dec c + dec c ;c = x-2 + inc hl + ld a,(hl) ;y-pos + add a,5 + ld e,a ;e = y+5 + + ld b,10 + ld hl,ebullets +find_ebullet: + ld a,(hl) + or a + jr z,found_ebullet ;0 = not used + inc hl + inc hl + inc hl + djnz find_ebullet ;look next bullet + ret + +found_ebullet: + ld (hl),1 ;use bullet + inc hl + ld (hl),c ;set x-pos + inc hl + ld (hl),e ;set y-pos + ret + +;----------------------------- enemy bullets ---------------------------------- + +Enemy_bullets: + ld hl,ebullets + ld b,10 +handle_bullet: + push bc + push hl + ld a,(hl) + or a + jr nz,enemy_bullet +next_bullet: + pop hl + pop bc + inc hl + inc hl + inc hl + djnz handle_bullet + ret + + +enemy_bullet: + inc hl + ld a,(hl) ;bullet x + dec a + jp m,remove_ebullet ;off screen? + jr z,remove_ebullet ;" + dec a ;move left + ld (hl),a + ld d,a ;d=x + inc hl + ld e,(hl) ;e=y + ld ix,spr_bullet11 ;display enemy bullet + call drw_spr + + ld a,(your_occ) + or a + jr nz,next_bullet ;0 = you're normal + + pop hl + push hl + inc hl ;check x + ld a,(x) + sub (hl) + add a,6 + jp m,next_bullet + cp 9 + jr nc,next_bullet + + inc hl ;check y + ld a,(y) + sub (hl) + add a,6 + jp m,next_bullet + cp 9 + jr nc,next_bullet + + call damage_you ;HIT!! + +remove_ebullet: + dec hl + dec hl + ld (hl),0 ;bullet > unused + jr next_bullet + ;--------------------------- handle enemies ----------------------------------- Handle_enemies: @@ -407,19 +543,22 @@ Handle_enemies: ld b,20 handle_enemy: - push hl push bc + push hl ld a,(hl) - dec a - jr z,normal_enemy ;occ "normal" 1 - dec a + and %00000011 + jr z,next_enemy ;occ "no enemy" 0 + and %00000001 jr z,exploding_enemy ;occ "exploding" 2 - jr next_enemy ;occ "no enemy" 0 -normal_enemy: +normal_enemy: ;occ "normal" 1 inc hl - ld c,(hl) ;type + ld a,(hl) ;type + add a,a + add a,a + add a,a + ld c,a ;type*8 = offset inc hl ld d,(hl) ;x inc hl @@ -449,12 +588,10 @@ enemy_gone: ld (hl),$0000 ;bye bye enemy next_enemy: - pop bc pop hl - inc hl - inc hl - inc hl - inc hl + ld bc,$0004 + add hl,bc + pop bc djnz handle_enemy ret @@ -475,13 +612,15 @@ exploding_enemy: ;--------------------------- check collision ---------------------------------- Enemies_hit: + ld a,(your_occ) + or a + ret nz + ld de,(x) ;e = X, d = Y ld hl,enemies-4 check_next: - inc hl - inc hl - inc hl - inc hl + ld bc,$0004 + add hl,bc ld a,(hl) cp $ff @@ -512,6 +651,7 @@ check_next: ld (hl),0 ;explosionFrame 0 dec hl ld (hl),2 ;set to explode + call damage_you nocrash: pop hl @@ -623,15 +763,20 @@ spr_ship: spr_bullet01: .db 5,3 ;your bullets - .db %11110000 ; ████ - .db %11111000 ; █████ - .db %11110000 ; ████ - + .db %00110000 ; ░▒▓██ + .db %11111000 ; ░▒▓█████ + .db %00110000 ; ░▒▓██ spr_bullet02: + .db 5,3 ;your bullets + .db %11110000 ; ░▒▓████ + .db %11111000 ; ░▒▓█████ + .db %11110000 ; ░▒▓████ + +spr_bullet11: .db 3,3 ;enemy bullets - .db %01000000 ; █ - .db %11100000 ; ███ - .db %01000000 ; █ + .db %01000000 ; █▓▒░ + .db %11100000 ; ███▓▒░ + .db %01000000 ; █▓▒░ spr_enemy01: .db 6,6 ;enemy type one @@ -657,6 +802,14 @@ spr_enemy03: .db %11111000 ; █████ .db %01111100 ; █████ .db %00111000 ; ███ +spr_enemy03: + .db 6,6 ;enemy type three + .db %00111000 ; ███ + .db %01111100 ; ██ + .db %11111000 ; █████ + .db %11111000 ; █████ + .db %01111100 ; █████ + .db %00111000 ; ███ spr_explosion: .db 8,6 ;1 @@ -725,20 +878,20 @@ spr_explosion: ;---------------------------- enemy types ------------------------------------- -;enemy01: .db $01,$00,$00 ;$hits $fire frequency -;enemy02: .db $02,$00,$00 -;enemy03: .db $04,$00,$00 +enemy01: .db %00000000,$ff,$ff ;$hits $fire frequency +enemy02: .db %00000100,$ff,$ff +enemy03: .db %00001000,$ff,$ff ;---------------------------- level data -------------------------------------- Leveldata: - .db $10,$00,$40 ;$time (ff=end) $type $y-pos + .db $01,$01,$40 ;$time (ff=end) $type $y-pos .db $10,$00,$30 - .db $10,$00,$20 - .db $40,$00,$10 + .db $10,$02,$20 + .db $40,$01,$10 .db $01,$00,$44 - .db $15,$00,$31 - .db $04,$00,$38 + .db $15,$01,$31 + .db $04,$02,$38 .db $05,$00,$40 .db $03,$00,$2f .db $04,$00,$3a @@ -762,29 +915,32 @@ title_message: stored_data_start: +level .dw $0000 ;level number +background .db %00000001 ;level background +timer .dw $0000 curevent .dw Leveldata+1 ;next event nextevent .db (Leveldata) ;time to next event + score .dw $0000 -lives .dw $0003 -level .dw $0000 -x .db $16 -y .db $46 -shield .db $00 + +your_occ .db $00 ;0=normal 1=exploding 2=gone +lives .dw $0003 ;unused +x .db $16 ;x-pos +y .db $46 ;think about it.. +hp .db $00 ;hitpoints left +your_status .db $00,$00 ;unused + ybullets .dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;10 x (state,x,y) -;ebuls .dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +ebullets .dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;10 x (state,x,y) + enemies .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000 .dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000 -; 0011 2233 >> 0=occupation (0=no enemy 1=normal 2=exploding) +; 0011 2233 >> 0=occupation (and %00000011: 0=no enemy 1=normal 2=exploding) ; 1=frame/ship 2=x 3=y -timer .dw $0000 -your_status .db $00 - .db $00 -warped_status .db $00 - variables_end: stored_data_end: @@ -815,5 +971,12 @@ stored_data_end: ; ; + ability to fire bullets (F1). Enemies disappear on impact ; * enemies explode instead of disappearing +; +; 0.3.719 -- 19.VII.99 -- size 1401 +; +; * bullets appear correctly (not INSIDE your ship) +; + some enemies can take multiple hits (differs per class) +; + all enemies fire bullets at random +; + if you're hit by bullet/enemy, you'll lose one hitpoint -- 2.30.0