Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | /* |
| 2 | * src/e_bomb.c |
||
| 3 | * |
||
| 4 | * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved. |
||
| 5 | * |
||
| 6 | * The use and distribution terms for this software are contained in the file |
||
| 7 | * named README, which can be found in the root of this distribution. By |
||
| 8 | * using this software in any fashion, you are agreeing to be bound by the |
||
| 9 | * terms of this license. |
||
| 10 | * |
||
| 11 | * You must not remove this notice, or any other, from this software. |
||
| 12 | */ |
||
| 13 | |||
| 14 | #include "system.h" |
||
| 15 | #include "game.h" |
||
| 16 | #include "ents.h" |
||
| 17 | #include "e_bomb.h" |
||
| 18 | |||
| 19 | #include "e_rick.h" |
||
| 20 | |||
| 21 | /* |
||
| 22 | * public vars (for performance reasons) |
||
| 23 | */ |
||
| 24 | U8 e_bomb_lethal; |
||
| 25 | U8 e_bomb_xc; |
||
| 26 | U16 e_bomb_yc; |
||
| 27 | |||
| 28 | /* |
||
| 29 | * private vars |
||
| 30 | */ |
||
| 31 | U8 e_bomb_ticker; |
||
| 32 | |||
| 33 | |||
| 34 | /* |
||
| 35 | * Bomb hit test |
||
| 36 | * |
||
| 37 | * ASM 11CD |
||
| 38 | * returns: TRUE/hit, FALSE/not |
||
| 39 | */ |
||
| 40 | U8 e_bomb_hit (U8 e) |
||
| 41 | { |
||
| 42 | if (ent_ents[e].x > (E_BOMB_ENT.x >= 0xE0 ? 0xFF : E_BOMB_ENT.x + 0x20)) |
||
| 43 | return FALSE; |
||
| 44 | if (ent_ents[e].x + ent_ents[e].w < (E_BOMB_ENT.x > 0x04 ? E_BOMB_ENT.x - 0x04 : 0)) |
||
| 45 | return FALSE; |
||
| 46 | if (ent_ents[e].y > (E_BOMB_ENT.y + 0x1D)) |
||
| 47 | return FALSE; |
||
| 48 | if (ent_ents[e].y + ent_ents[e].h < (E_BOMB_ENT.y > 0x0004 ? E_BOMB_ENT.y - 0x0004 : 0)) |
||
| 49 | return FALSE; |
||
| 50 | |||
| 51 | return TRUE; |
||
| 52 | } |
||
| 53 | |||
| 54 | |||
| 55 | /* |
||
| 56 | * Initialize bomb |
||
| 57 | */ |
||
| 58 | void e_bomb_init (U16 x, U16 y) |
||
| 59 | { |
||
| 60 | E_BOMB_ENT.n = 0x03; |
||
| 61 | E_BOMB_ENT.x = x; |
||
| 62 | E_BOMB_ENT.y = y; |
||
| 63 | e_bomb_ticker = E_BOMB_TICKER; |
||
| 64 | e_bomb_lethal = FALSE; |
||
| 65 | |||
| 66 | /* |
||
| 67 | * Atari ST dynamite sprites are not centered the |
||
| 68 | * way IBM PC sprites were ... need to adjust things a little bit |
||
| 69 | */ |
||
| 70 | E_BOMB_ENT.x += 4; |
||
| 71 | E_BOMB_ENT.y += 5; |
||
| 72 | |||
| 73 | } |
||
| 74 | |||
| 75 | |||
| 76 | /* |
||
| 77 | * Entity action |
||
| 78 | * |
||
| 79 | * ASM 18CA |
||
| 80 | */ |
||
| 81 | void e_bomb_action (U8 e) |
||
| 82 | { |
||
| 83 | /* tick */ |
||
| 84 | e_bomb_ticker--; |
||
| 85 | |||
| 86 | if (e_bomb_ticker == 0) |
||
| 87 | { |
||
| 88 | /* |
||
| 89 | * end: deactivate |
||
| 90 | */ |
||
| 91 | E_BOMB_ENT.n = 0; |
||
| 92 | e_bomb_lethal = FALSE; |
||
| 93 | } |
||
| 94 | else if (e_bomb_ticker >= 0x0A) |
||
| 95 | { |
||
| 96 | /* |
||
| 97 | * ticking |
||
| 98 | */ |
||
| 99 | if ((e_bomb_ticker & 0x03) == 0x02) |
||
| 100 | syssnd_play (WAV_BOMBSHHT, 1); |
||
| 101 | |||
| 102 | /* ST bomb sprites sequence is longer */ |
||
| 103 | if (e_bomb_ticker < 40) |
||
| 104 | E_BOMB_ENT.sprite = 0x99 + 19 - (e_bomb_ticker >> 1); |
||
| 105 | else |
||
| 106 | E_BOMB_ENT.sprite = (e_bomb_ticker & 0x01) ? 0x23 : 0x22; |
||
| 107 | } |
||
| 108 | else if (e_bomb_ticker == 0x09) |
||
| 109 | { |
||
| 110 | if (E_RICK_STTST (E_RICK_STZOMBIE)) |
||
| 111 | return; |
||
| 112 | |||
| 113 | /* |
||
| 114 | * explode |
||
| 115 | */ |
||
| 116 | syssnd_play (WAV_EXPLODE, 1); |
||
| 117 | |||
| 118 | /* See above: fixing alignment */ |
||
| 119 | E_BOMB_ENT.x -= 4; |
||
| 120 | E_BOMB_ENT.y -= 5; |
||
| 121 | E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1); |
||
| 122 | e_bomb_xc = E_BOMB_ENT.x + 0x0C; |
||
| 123 | e_bomb_yc = E_BOMB_ENT.y + 0x000A; |
||
| 124 | e_bomb_lethal = TRUE; |
||
| 125 | |||
| 126 | if (e_bomb_hit (E_RICK_NO)) |
||
| 127 | e_rick_gozombie (); |
||
| 128 | } |
||
| 129 | else |
||
| 130 | { |
||
| 131 | if (E_RICK_STTST (E_RICK_STZOMBIE)) |
||
| 132 | return; |
||
| 133 | |||
| 134 | /* |
||
| 135 | * exploding |
||
| 136 | */ |
||
| 137 | E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1); |
||
| 138 | |||
| 139 | /* exploding, hence lethal */ |
||
| 140 | if (e_bomb_hit (E_RICK_NO)) |
||
| 141 | e_rick_gozombie (); |
||
| 142 | } |
||
| 143 | } |