Optimize, pass entity pointer around instead of index, this avoids expensive multiplies to index into the entity array
This commit is contained in:
parent
4966075052
commit
ff4bd68c0b
|
@ -25,9 +25,9 @@ extern U8 e_bomb_ticker;
|
||||||
extern U8 e_bomb_xc;
|
extern U8 e_bomb_xc;
|
||||||
extern U16 e_bomb_yc;
|
extern U16 e_bomb_yc;
|
||||||
|
|
||||||
extern U8 e_bomb_hit(U8);
|
extern U8 e_bomb_hit(ent_t* pEnt);
|
||||||
extern void e_bomb_init(U16, U16);
|
extern void e_bomb_init(U16, U16);
|
||||||
extern void e_bomb_action(U8);
|
extern void e_bomb_action(ent_t* pEnt);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
extern void e_bonus_action(U8);
|
extern void e_bonus_action(ent_t*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
extern void e_box_action(U8);
|
extern void e_box_action(ent_t*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ extern S16 e_bullet_offsx;
|
||||||
extern S16 e_bullet_xc, e_bullet_yc;
|
extern S16 e_bullet_xc, e_bullet_yc;
|
||||||
|
|
||||||
extern void e_bullet_init(U16, U16);
|
extern void e_bullet_init(U16, U16);
|
||||||
extern void e_bullet_action(U8);
|
extern void e_bullet_action(ent_t*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,9 @@ extern S16 e_rick_stop_x, e_rick_stop_y;
|
||||||
|
|
||||||
extern void e_rick_save(void);
|
extern void e_rick_save(void);
|
||||||
extern void e_rick_restore(void);
|
extern void e_rick_restore(void);
|
||||||
extern void e_rick_action(U8);
|
extern void e_rick_action(ent_t*);
|
||||||
extern void e_rick_gozombie(void);
|
extern void e_rick_gozombie(void);
|
||||||
extern U8 e_rick_boxtest(U8);
|
extern U8 e_rick_boxtest(ent_t*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ extern U8 e_sbonus_counting;
|
||||||
extern U8 e_sbonus_counter;
|
extern U8 e_sbonus_counter;
|
||||||
extern U16 e_sbonus_bonus;
|
extern U16 e_sbonus_bonus;
|
||||||
|
|
||||||
extern void e_sbonus_start(U8);
|
extern void e_sbonus_start(ent_t*);
|
||||||
extern void e_sbonus_stop(U8);
|
extern void e_sbonus_stop(ent_t*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
|
|
||||||
extern U32 e_them_rndseed;
|
extern U32 e_them_rndseed;
|
||||||
|
|
||||||
extern void e_them_t1a_action(U8);
|
extern void e_them_t1a_action(ent_t*);
|
||||||
extern void e_them_t1b_action(U8);
|
extern void e_them_t1b_action(ent_t*);
|
||||||
extern void e_them_t2_action(U8);
|
extern void e_them_t2_action(ent_t*);
|
||||||
extern void e_them_t3_action(U8);
|
extern void e_them_t3_action(ent_t*);
|
||||||
extern void e_them_z_action(U8);
|
extern void e_them_z_action(ent_t*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,12 @@
|
||||||
#ifndef _UTIL_H
|
#ifndef _UTIL_H
|
||||||
#define _UTIL_H
|
#define _UTIL_H
|
||||||
|
|
||||||
|
#include "ents.h"
|
||||||
|
|
||||||
extern void u_envtest(S16, S16, U8, U8 *, U8 *);
|
extern void u_envtest(S16, S16, U8, U8 *, U8 *);
|
||||||
extern U8 u_boxtest(U8, U8);
|
extern U8 u_boxtest(ent_t*, ent_t*);
|
||||||
extern U8 u_fboxtest(U8, S16, S16);
|
extern U8 u_fboxtest(ent_t*, S16, S16);
|
||||||
extern U8 u_trigbox(U8, S16, S16);
|
extern U8 u_trigbox(ent_t* pEnt, S16, S16);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
16
src/e_bomb.c
16
src/e_bomb.c
|
@ -41,15 +41,15 @@ U8 e_bomb_ticker;
|
||||||
* ASM 11CD
|
* ASM 11CD
|
||||||
* returns: TRUE/hit, FALSE/not
|
* returns: TRUE/hit, FALSE/not
|
||||||
*/
|
*/
|
||||||
U8 e_bomb_hit(U8 e)
|
U8 e_bomb_hit(ent_t *pEnt)
|
||||||
{
|
{
|
||||||
if (ent_ents[e].x > (E_BOMB_ENT.x >= 0xE0 ? 0xFF : E_BOMB_ENT.x + 0x20))
|
if (pEnt->x > (E_BOMB_ENT.x >= 0xE0 ? 0xFF : E_BOMB_ENT.x + 0x20))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (ent_ents[e].x + ent_ents[e].w < (E_BOMB_ENT.x > 0x04 ? E_BOMB_ENT.x - 0x04 : 0))
|
if (pEnt->x + pEnt->w < (E_BOMB_ENT.x > 0x04 ? E_BOMB_ENT.x - 0x04 : 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (ent_ents[e].y > (E_BOMB_ENT.y + 0x1D))
|
if (pEnt->y > (E_BOMB_ENT.y + 0x1D))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (ent_ents[e].y + ent_ents[e].h < (E_BOMB_ENT.y > 0x0004 ? E_BOMB_ENT.y - 0x0004 : 0))
|
if (pEnt->y + pEnt->h < (E_BOMB_ENT.y > 0x0004 ? E_BOMB_ENT.y - 0x0004 : 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ void e_bomb_init(U16 x, U16 y)
|
||||||
* ASM 18CA
|
* ASM 18CA
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_bomb_action(UNUSED(U8 e))
|
e_bomb_action(UNUSED(ent_t* pEnt))
|
||||||
{
|
{
|
||||||
/* tick */
|
/* tick */
|
||||||
e_bomb_ticker--;
|
e_bomb_ticker--;
|
||||||
|
@ -133,7 +133,7 @@ e_bomb_action(UNUSED(U8 e))
|
||||||
e_bomb_xc = E_BOMB_ENT.x + 0x0C;
|
e_bomb_xc = E_BOMB_ENT.x + 0x0C;
|
||||||
e_bomb_yc = E_BOMB_ENT.y + 0x000A;
|
e_bomb_yc = E_BOMB_ENT.y + 0x000A;
|
||||||
e_bomb_lethal = TRUE;
|
e_bomb_lethal = TRUE;
|
||||||
if (e_bomb_hit(E_RICK_NO))
|
if (e_bomb_hit(&ent_ents[E_RICK_NO]))
|
||||||
e_rick_gozombie();
|
e_rick_gozombie();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -148,7 +148,7 @@ e_bomb_action(UNUSED(U8 e))
|
||||||
E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
|
E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
|
||||||
#endif
|
#endif
|
||||||
/* exploding, hence lethal */
|
/* exploding, hence lethal */
|
||||||
if (e_bomb_hit(E_RICK_NO))
|
if (e_bomb_hit(&ent_ents[E_RICK_NO]))
|
||||||
e_rick_gozombie();
|
e_rick_gozombie();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,31 +30,31 @@ segment "e";
|
||||||
* ASM 242C
|
* ASM 242C
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_bonus_action(U8 e)
|
e_bonus_action(ent_t *pEnt)
|
||||||
{
|
{
|
||||||
#define seq c1
|
#define seq c1
|
||||||
|
|
||||||
if (ent_ents[e].seq == 0) {
|
if (pEnt->seq == 0) {
|
||||||
if (e_rick_boxtest(e)) {
|
if (e_rick_boxtest(pEnt)) {
|
||||||
game_score += 500;
|
game_score += 500;
|
||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
syssnd_play(WAV_BONUS, 1);
|
syssnd_play(WAV_BONUS, 1);
|
||||||
#endif
|
#endif
|
||||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
|
||||||
ent_ents[e].seq = 1;
|
pEnt->seq = 1;
|
||||||
ent_ents[e].sprite = 0xad;
|
pEnt->sprite = 0xad;
|
||||||
ent_ents[e].front = TRUE;
|
pEnt->front = TRUE;
|
||||||
ent_ents[e].y -= 0x08;
|
pEnt->y -= 0x08;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (ent_ents[e].seq > 0 && ent_ents[e].seq < 10) {
|
else if (pEnt->seq > 0 && pEnt->seq < 10) {
|
||||||
ent_ents[e].seq++;
|
pEnt->seq++;
|
||||||
ent_ents[e].y -= 2;
|
pEnt->y -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
src/e_box.c
40
src/e_box.c
|
@ -42,7 +42,7 @@ segment "e";
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
static void explode(U8);
|
static void explode(ent_t*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Entity action
|
* Entity action
|
||||||
|
@ -50,49 +50,49 @@ static void explode(U8);
|
||||||
* ASM 245A
|
* ASM 245A
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_box_action(U8 e)
|
e_box_action(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
static U8 sp[] = {0x24, 0x25, 0x26, 0x27, 0x28}; /* explosion sprites sequence */
|
static U8 sp[] = {0x24, 0x25, 0x26, 0x27, 0x28}; /* explosion sprites sequence */
|
||||||
|
|
||||||
if (ent_ents[e].n & ENT_LETHAL) {
|
if (pEnt->n & ENT_LETHAL) {
|
||||||
/*
|
/*
|
||||||
* box is lethal i.e. exploding
|
* box is lethal i.e. exploding
|
||||||
* play sprites sequence then stop
|
* play sprites sequence then stop
|
||||||
*/
|
*/
|
||||||
ent_ents[e].sprite = sp[ent_ents[e].cnt >> 1];
|
pEnt->sprite = sp[pEnt->cnt >> 1];
|
||||||
if (--ent_ents[e].cnt == 0) {
|
if (--pEnt->cnt == 0) {
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* not lethal: check to see if triggered
|
* not lethal: check to see if triggered
|
||||||
*/
|
*/
|
||||||
if (e_rick_boxtest(e)) {
|
if (e_rick_boxtest(pEnt)) {
|
||||||
/* rick: collect bombs or bullets and stop */
|
/* rick: collect bombs or bullets and stop */
|
||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
syssnd_play(WAV_BOX, 1);
|
syssnd_play(WAV_BOX, 1);
|
||||||
#endif
|
#endif
|
||||||
if (ent_ents[e].n == 0x10)
|
if (pEnt->n == 0x10)
|
||||||
game_bombs = GAME_BOMBS_INIT;
|
game_bombs = GAME_BOMBS_INIT;
|
||||||
else /* 0x11 */
|
else /* 0x11 */
|
||||||
game_bullets = GAME_BULLETS_INIT;
|
game_bullets = GAME_BULLETS_INIT;
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
|
||||||
}
|
}
|
||||||
else if (E_RICK_STTST(E_RICK_STSTOP) &&
|
else if (E_RICK_STTST(E_RICK_STSTOP) &&
|
||||||
u_fboxtest(e, e_rick_stop_x, e_rick_stop_y)) {
|
u_fboxtest(pEnt, e_rick_stop_x, e_rick_stop_y)) {
|
||||||
/* rick's stick: explode */
|
/* rick's stick: explode */
|
||||||
explode(e);
|
explode(pEnt);
|
||||||
}
|
}
|
||||||
else if (E_BULLET_ENT.n && u_fboxtest(e, e_bullet_xc, e_bullet_yc)) {
|
else if (E_BULLET_ENT.n && u_fboxtest(pEnt, e_bullet_xc, e_bullet_yc)) {
|
||||||
/* bullet: explode (and stop bullet) */
|
/* bullet: explode (and stop bullet) */
|
||||||
E_BULLET_ENT.n = 0;
|
E_BULLET_ENT.n = 0;
|
||||||
explode(e);
|
explode(pEnt);
|
||||||
}
|
}
|
||||||
else if (e_bomb_lethal && e_bomb_hit(e)) {
|
else if (e_bomb_lethal && e_bomb_hit(pEnt)) {
|
||||||
/* bomb: explode */
|
/* bomb: explode */
|
||||||
explode(e);
|
explode(pEnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,10 +101,10 @@ e_box_action(U8 e)
|
||||||
/*
|
/*
|
||||||
* Explode when
|
* Explode when
|
||||||
*/
|
*/
|
||||||
static void explode(U8 e)
|
static void explode(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
ent_ents[e].cnt = SEQ_INIT;
|
pEnt->cnt = SEQ_INIT;
|
||||||
ent_ents[e].n |= ENT_LETHAL;
|
pEnt->n |= ENT_LETHAL;
|
||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
syssnd_play(WAV_EXPLODE, 1);
|
syssnd_play(WAV_EXPLODE, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -58,7 +58,7 @@ e_bullet_init(U16 x, U16 y)
|
||||||
* ASM 1883, 0F97
|
* ASM 1883, 0F97
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_bullet_action(UNUSED(U8 e))
|
e_bullet_action(UNUSED(ent_t* pEnt))
|
||||||
{
|
{
|
||||||
/* move bullet */
|
/* move bullet */
|
||||||
E_BULLET_ENT.x += e_bullet_offsx;
|
E_BULLET_ENT.x += e_bullet_offsx;
|
||||||
|
|
12
src/e_rick.c
12
src/e_rick.c
|
@ -62,17 +62,17 @@ static U16 save_x, save_y;
|
||||||
* ret: TRUE/intersect, FALSE/not.
|
* ret: TRUE/intersect, FALSE/not.
|
||||||
*/
|
*/
|
||||||
U8
|
U8
|
||||||
e_rick_boxtest(U8 e)
|
e_rick_boxtest(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* rick: x+0x05 to x+0x11, y+[0x08 if rick's crawling] to y+0x14
|
* rick: x+0x05 to x+0x11, y+[0x08 if rick's crawling] to y+0x14
|
||||||
* entity: x to x+w, y to y+h
|
* entity: x to x+w, y to y+h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (E_RICK_ENT.x + 0x11 < ent_ents[e].x ||
|
if (E_RICK_ENT.x + 0x11 < pEnt->x ||
|
||||||
E_RICK_ENT.x + 0x05 > ent_ents[e].x + ent_ents[e].w ||
|
E_RICK_ENT.x + 0x05 > pEnt->x + pEnt->w ||
|
||||||
E_RICK_ENT.y + 0x14 < ent_ents[e].y ||
|
E_RICK_ENT.y + 0x14 < pEnt->y ||
|
||||||
E_RICK_ENT.y + (E_RICK_STTST(E_RICK_STCRAWL) ? 0x08 : 0x00) > ent_ents[e].y + ent_ents[e].h - 1)
|
E_RICK_ENT.y + (E_RICK_STTST(E_RICK_STCRAWL) ? 0x08 : 0x00) > pEnt->y + pEnt->h - 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -449,7 +449,7 @@ e_rick_action2(void)
|
||||||
*
|
*
|
||||||
* ASM 12CA
|
* ASM 12CA
|
||||||
*/
|
*/
|
||||||
void e_rick_action(UNUSED(U8 e))
|
void e_rick_action(UNUSED(ent_t* pEnt))
|
||||||
{
|
{
|
||||||
static U8 stopped = FALSE; /* is this the most elegant way? */
|
static U8 stopped = FALSE; /* is this the most elegant way? */
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,12 @@ U16 e_sbonus_bonus = 0;
|
||||||
* ASM 2182
|
* ASM 2182
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_sbonus_start(U8 e)
|
e_sbonus_start(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
ent_ents[e].sprite = 0; /* invisible */
|
pEnt->sprite = 0; /* invisible */
|
||||||
if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
|
if (u_trigbox(pEnt, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
|
||||||
/* rick is within trigger box */
|
/* rick is within trigger box */
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
e_sbonus_counting = TRUE; /* 6DD5 */
|
e_sbonus_counting = TRUE; /* 6DD5 */
|
||||||
e_sbonus_counter = 0x1e; /* 6DDB */
|
e_sbonus_counter = 0x1e; /* 6DDB */
|
||||||
e_sbonus_bonus = 2000; /* 291A-291D */
|
e_sbonus_bonus = 2000; /* 291A-291D */
|
||||||
|
@ -61,23 +61,23 @@ e_sbonus_start(U8 e)
|
||||||
* ASM 2143
|
* ASM 2143
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_sbonus_stop(U8 e)
|
e_sbonus_stop(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
ent_ents[e].sprite = 0; /* invisible */
|
pEnt->sprite = 0; /* invisible */
|
||||||
|
|
||||||
if (!e_sbonus_counting)
|
if (!e_sbonus_counting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (u_trigbox(e, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
|
if (u_trigbox(pEnt, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
|
||||||
/* rick is within trigger box */
|
/* rick is within trigger box */
|
||||||
e_sbonus_counting = FALSE; /* stop counting */
|
e_sbonus_counting = FALSE; /* stop counting */
|
||||||
ent_ents[e].n = 0; /* deactivate entity */
|
pEnt->n = 0; /* deactivate entity */
|
||||||
game_score += e_sbonus_bonus; /* add bonus to score */
|
game_score += e_sbonus_bonus; /* add bonus to score */
|
||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
syssnd_play(WAV_SBONUS2, 1);
|
syssnd_play(WAV_SBONUS2, 1);
|
||||||
#endif
|
#endif
|
||||||
/* make sure the entity won't be activated again */
|
/* make sure the entity won't be activated again */
|
||||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* keep counting */
|
/* keep counting */
|
||||||
|
|
368
src/e_them.c
368
src/e_them.c
|
@ -50,15 +50,15 @@ segment "e";
|
||||||
* ret: TRUE/boxtests, FALSE/not
|
* ret: TRUE/boxtests, FALSE/not
|
||||||
*/
|
*/
|
||||||
U8
|
U8
|
||||||
u_themtest(U8 e)
|
u_themtest(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
U8 i;
|
ent_t* pI;
|
||||||
|
|
||||||
if ((ent_ents[0].n & ENT_LETHAL) && u_boxtest(e, 0))
|
if ((ent_ents[0].n & ENT_LETHAL) && u_boxtest(pEnt, ent_ents))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
for (i = 4; i < 9; i++)
|
for (pI = &ent_ents[4]; pI < &ent_ents[9]; pI++)
|
||||||
if ((ent_ents[i].n & ENT_LETHAL) && u_boxtest(e, i))
|
if ((pI->n & ENT_LETHAL) && u_boxtest(pEnt, pI))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -71,21 +71,21 @@ u_themtest(U8 e)
|
||||||
* ASM 237B
|
* ASM 237B
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_gozombie(U8 e)
|
e_them_gozombie(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
#define offsx c1
|
#define offsx c1
|
||||||
ent_ents[e].n = 0x47; /* zombie entity */
|
pEnt->n = 0x47; /* zombie entity */
|
||||||
ent_ents[e].front = TRUE;
|
pEnt->front = TRUE;
|
||||||
ent_ents[e].offsy = -0x0400;
|
pEnt->offsy = -0x0400;
|
||||||
#ifdef ENABLE_SOUND
|
#ifdef ENABLE_SOUND
|
||||||
syssnd_play(WAV_DIE, 1);
|
syssnd_play(WAV_DIE, 1);
|
||||||
#endif
|
#endif
|
||||||
game_score += 50;
|
game_score += 50;
|
||||||
if (ent_ents[e].flags & ENT_FLG_ONCE) {
|
if (pEnt->flags & ENT_FLG_ONCE) {
|
||||||
/* make sure entity won't be activated again */
|
/* make sure entity won't be activated again */
|
||||||
map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT;
|
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
|
||||||
}
|
}
|
||||||
ent_ents[e].offsx = (ent_ents[e].x >= 0x80 ? -0x02 : 0x02);
|
pEnt->offsx = (pEnt->x >= 0x80 ? -0x02 : 0x02);
|
||||||
#undef offsx
|
#undef offsx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ e_them_gozombie(U8 e)
|
||||||
* ASM 2242
|
* ASM 2242
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t1_action2(U8 e, U8 type)
|
e_them_t1_action2(ent_t* pEnt, U8 type)
|
||||||
{
|
{
|
||||||
#define offsx c1
|
#define offsx c1
|
||||||
#define step_count c2
|
#define step_count c2
|
||||||
|
@ -110,105 +110,105 @@ e_them_t1_action2(U8 e, U8 type)
|
||||||
U8 env0, env1;
|
U8 env0, env1;
|
||||||
|
|
||||||
/* by default, try vertical move. calculate new y */
|
/* by default, try vertical move. calculate new y */
|
||||||
i = (((S32)ent_ents[e].y) << 8) + ((S32)ent_ents[e].offsy) + ((U32)ent_ents[e].ylow);
|
i = (((S32)pEnt->y) << 8) + ((S32)pEnt->offsy) + ((U32)pEnt->ylow);
|
||||||
y = i >> 8;
|
y = i >> 8;
|
||||||
|
|
||||||
/* deactivate if outside vertical boundaries */
|
/* deactivate if outside vertical boundaries */
|
||||||
/* no need to test zero since e_them _t1a/b don't go up */
|
/* no need to test zero since e_them _t1a/b don't go up */
|
||||||
/* FIXME what if they got scrolled out ? */
|
/* FIXME what if they got scrolled out ? */
|
||||||
if (y > 0x140) {
|
if (y > 0x140) {
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test environment */
|
/* test environment */
|
||||||
u_envtest(ent_ents[e].x, y, FALSE, &env0, &env1);
|
u_envtest(pEnt->x, y, FALSE, &env0, &env1);
|
||||||
|
|
||||||
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
||||||
/* vertical move possible: falling */
|
/* vertical move possible: falling */
|
||||||
if (env1 & MAP_EFLG_LETHAL) {
|
if (env1 & MAP_EFLG_LETHAL) {
|
||||||
/* lethal entities kill e_them */
|
/* lethal entities kill e_them */
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* save, cleanup and return */
|
/* save, cleanup and return */
|
||||||
ent_ents[e].y = y;
|
pEnt->y = y;
|
||||||
ent_ents[e].ylow = i;
|
pEnt->ylow = i;
|
||||||
ent_ents[e].offsy += 0x0080;
|
pEnt->offsy += 0x0080;
|
||||||
if (ent_ents[e].offsy > 0x0800)
|
if (pEnt->offsy > 0x0800)
|
||||||
ent_ents[e].offsy = 0x0800;
|
pEnt->offsy = 0x0800;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vertical move not possible. calculate new sprite */
|
/* vertical move not possible. calculate new sprite */
|
||||||
ent_ents[e].sprite = ent_ents[e].sprbase
|
pEnt->sprite = pEnt->sprbase
|
||||||
+ ent_sprseq[(ent_ents[e].x & 0x1c) >> 3]
|
+ ent_sprseq[(pEnt->x & 0x1c) >> 3]
|
||||||
+ (ent_ents[e].offsx < 0 ? 0x03 : 0x00);
|
+ (pEnt->offsx < 0 ? 0x03 : 0x00);
|
||||||
|
|
||||||
/* reset offsy */
|
/* reset offsy */
|
||||||
ent_ents[e].offsy = 0x0080;
|
pEnt->offsy = 0x0080;
|
||||||
|
|
||||||
/* align to ground */
|
/* align to ground */
|
||||||
ent_ents[e].y &= 0xfff8;
|
pEnt->y &= 0xfff8;
|
||||||
ent_ents[e].y |= 0x0003;
|
pEnt->y |= 0x0003;
|
||||||
|
|
||||||
/* latency: if not zero then decrease and return */
|
/* latency: if not zero then decrease and return */
|
||||||
if (ent_ents[e].latency > 0) {
|
if (pEnt->latency > 0) {
|
||||||
ent_ents[e].latency--;
|
pEnt->latency--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* horizontal move. calculate new x */
|
/* horizontal move. calculate new x */
|
||||||
if (ent_ents[e].offsx == 0) /* not supposed to move -> don't */
|
if (pEnt->offsx == 0) /* not supposed to move -> don't */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x = ent_ents[e].x + ent_ents[e].offsx;
|
x = pEnt->x + pEnt->offsx;
|
||||||
if (ent_ents[e].x < 0 || ent_ents[e].x > 0xe8) {
|
if (pEnt->x < 0 || pEnt->x > 0xe8) {
|
||||||
/* U-turn and return if reaching horizontal boundaries */
|
/* U-turn and return if reaching horizontal boundaries */
|
||||||
ent_ents[e].step_count = 0;
|
pEnt->step_count = 0;
|
||||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
pEnt->offsx = -pEnt->offsx;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test environment */
|
/* test environment */
|
||||||
u_envtest(x, ent_ents[e].y, FALSE, &env0, &env1);
|
u_envtest(x, pEnt->y, FALSE, &env0, &env1);
|
||||||
|
|
||||||
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
|
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
|
||||||
/* horizontal move not possible: u-turn and return */
|
/* horizontal move not possible: u-turn and return */
|
||||||
ent_ents[e].step_count = 0;
|
pEnt->step_count = 0;
|
||||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
pEnt->offsx = -pEnt->offsx;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* horizontal move possible */
|
/* horizontal move possible */
|
||||||
if (env1 & MAP_EFLG_LETHAL) {
|
if (env1 & MAP_EFLG_LETHAL) {
|
||||||
/* lethal entities kill e_them */
|
/* lethal entities kill e_them */
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save */
|
/* save */
|
||||||
ent_ents[e].x = x;
|
pEnt->x = x;
|
||||||
|
|
||||||
/* depending on type, */
|
/* depending on type, */
|
||||||
if (type == TYPE_1B) {
|
if (type == TYPE_1B) {
|
||||||
/* set direction to move horizontally towards rick */
|
/* set direction to move horizontally towards rick */
|
||||||
if ((ent_ents[e].x & 0x1e) != 0x10) /* prevents too frequent u-turns */
|
if ((pEnt->x & 0x1e) != 0x10) /* prevents too frequent u-turns */
|
||||||
return;
|
return;
|
||||||
ent_ents[e].offsx = (ent_ents[e].x < E_RICK_ENT.x) ? 0x02 : -0x02;
|
pEnt->offsx = (pEnt->x < E_RICK_ENT.x) ? 0x02 : -0x02;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* set direction according to step counter */
|
/* set direction according to step counter */
|
||||||
ent_ents[e].step_count++;
|
pEnt->step_count++;
|
||||||
/* FIXME why trig_x (b16) ?? */
|
/* FIXME why trig_x (b16) ?? */
|
||||||
if ((ent_ents[e].trig_x >> 1) > ent_ents[e].step_count)
|
if ((pEnt->trig_x >> 1) > pEnt->step_count)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* type is 1A and step counter reached its limit: u-turn */
|
/* type is 1A and step counter reached its limit: u-turn */
|
||||||
ent_ents[e].step_count = 0;
|
pEnt->step_count = 0;
|
||||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
pEnt->offsx = -pEnt->offsx;
|
||||||
#undef offsx
|
#undef offsx
|
||||||
#undef step_count
|
#undef step_count
|
||||||
}
|
}
|
||||||
|
@ -218,38 +218,38 @@ e_them_t1_action2(U8 e, U8 type)
|
||||||
* ASM 21CF
|
* ASM 21CF
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t1_action(U8 e, U8 type)
|
e_them_t1_action(ent_t* pEnt, U8 type)
|
||||||
{
|
{
|
||||||
e_them_t1_action2(e, type);
|
e_them_t1_action2(pEnt, type);
|
||||||
|
|
||||||
/* lethal entities kill them */
|
/* lethal entities kill them */
|
||||||
if (u_themtest(e)) {
|
if (u_themtest(pEnt)) {
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bullet kills them */
|
/* bullet kills them */
|
||||||
if (E_BULLET_ENT.n &&
|
if (E_BULLET_ENT.n &&
|
||||||
u_fboxtest(e, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 0 : 0x18),
|
u_fboxtest(pEnt, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 0 : 0x18),
|
||||||
E_BULLET_ENT.y)) {
|
E_BULLET_ENT.y)) {
|
||||||
E_BULLET_ENT.n = 0;
|
E_BULLET_ENT.n = 0;
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bomb kills them */
|
/* bomb kills them */
|
||||||
if (e_bomb_lethal && e_bomb_hit(e)) {
|
if (e_bomb_lethal && e_bomb_hit(pEnt)) {
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rick stops them */
|
/* rick stops them */
|
||||||
if (E_RICK_STTST(E_RICK_STSTOP) &&
|
if (E_RICK_STTST(E_RICK_STSTOP) &&
|
||||||
u_fboxtest(e, e_rick_stop_x, e_rick_stop_y))
|
u_fboxtest(pEnt, e_rick_stop_x, e_rick_stop_y))
|
||||||
ent_ents[e].latency = 0x14;
|
pEnt->latency = 0x14;
|
||||||
|
|
||||||
/* they kill rick */
|
/* they kill rick */
|
||||||
if (e_rick_boxtest(e))
|
if (e_rick_boxtest(pEnt))
|
||||||
e_rick_gozombie();
|
e_rick_gozombie();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,9 +260,9 @@ e_them_t1_action(U8 e, U8 type)
|
||||||
* ASM 2452
|
* ASM 2452
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t1a_action(U8 e)
|
e_them_t1a_action(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
e_them_t1_action(e, TYPE_1A);
|
e_them_t1_action(pEnt, TYPE_1A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,9 +272,9 @@ e_them_t1a_action(U8 e)
|
||||||
* ASM 21CA
|
* ASM 21CA
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t1b_action(U8 e)
|
e_them_t1b_action(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
e_them_t1_action(e, TYPE_1B);
|
e_them_t1_action(pEnt, TYPE_1B);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,37 +284,37 @@ e_them_t1b_action(U8 e)
|
||||||
* ASM 23B8
|
* ASM 23B8
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_z_action(U8 e)
|
e_them_z_action(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
#define offsx c1
|
#define offsx c1
|
||||||
U32 i;
|
U32 i;
|
||||||
|
|
||||||
/* calc new sprite */
|
/* calc new sprite */
|
||||||
ent_ents[e].sprite = ent_ents[e].sprbase
|
pEnt->sprite = pEnt->sprbase
|
||||||
+ ((ent_ents[e].x & 0x04) ? 0x07 : 0x06);
|
+ ((pEnt->x & 0x04) ? 0x07 : 0x06);
|
||||||
|
|
||||||
/* calc new y */
|
/* calc new y */
|
||||||
i = (((S32)ent_ents[e].y) << 8) + ((S32)ent_ents[e].offsy) + ((U32)ent_ents[e].ylow);
|
i = (((S32)pEnt->y) << 8) + ((S32)pEnt->offsy) + ((U32)pEnt->ylow);
|
||||||
|
|
||||||
/* deactivate if out of vertical boundaries */
|
/* deactivate if out of vertical boundaries */
|
||||||
if (ent_ents[e].y < 0 || ent_ents[e].y > 0x0140) {
|
if (pEnt->y < 0 || pEnt->y > 0x0140) {
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save */
|
/* save */
|
||||||
ent_ents[e].offsy += 0x0080;
|
pEnt->offsy += 0x0080;
|
||||||
ent_ents[e].ylow = i;
|
pEnt->ylow = i;
|
||||||
ent_ents[e].y = i >> 8;
|
pEnt->y = i >> 8;
|
||||||
|
|
||||||
/* calc new x */
|
/* calc new x */
|
||||||
ent_ents[e].x += ent_ents[e].offsx;
|
pEnt->x += pEnt->offsx;
|
||||||
|
|
||||||
/* must stay within horizontal boundaries */
|
/* must stay within horizontal boundaries */
|
||||||
if (ent_ents[e].x < 0)
|
if (pEnt->x < 0)
|
||||||
ent_ents[e].x = 0;
|
pEnt->x = 0;
|
||||||
if (ent_ents[e].x > 0xe8)
|
if (pEnt->x > 0xe8)
|
||||||
ent_ents[e].x = 0xe8;
|
pEnt->x = 0xe8;
|
||||||
#undef offsx
|
#undef offsx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ e_them_z_action(U8 e)
|
||||||
* ASM 2792
|
* ASM 2792
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t2_action2(U8 e)
|
e_them_t2_action2(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
#define flgclmb c1
|
#define flgclmb c1
|
||||||
#define offsx c2
|
#define offsx c2
|
||||||
|
@ -351,50 +351,50 @@ e_them_t2_action2(U8 e)
|
||||||
/*sys_printf("e_them_t2 ------------------------------\n");*/
|
/*sys_printf("e_them_t2 ------------------------------\n");*/
|
||||||
|
|
||||||
/* latency: if not zero then decrease */
|
/* latency: if not zero then decrease */
|
||||||
if (ent_ents[e].latency > 0) ent_ents[e].latency--;
|
if (pEnt->latency > 0) pEnt->latency--;
|
||||||
|
|
||||||
/* climbing? */
|
/* climbing? */
|
||||||
if (ent_ents[e].flgclmb != TRUE) goto climbing_not;
|
if (pEnt->flgclmb != TRUE) goto climbing_not;
|
||||||
|
|
||||||
/* CLIMBING */
|
/* CLIMBING */
|
||||||
|
|
||||||
/*sys_printf("e_them_t2 climbing\n");*/
|
/*sys_printf("e_them_t2 climbing\n");*/
|
||||||
|
|
||||||
/* latency: if not zero then return */
|
/* latency: if not zero then return */
|
||||||
if (ent_ents[e].latency > 0) return;
|
if (pEnt->latency > 0) return;
|
||||||
|
|
||||||
/* calc new sprite */
|
/* calc new sprite */
|
||||||
ent_ents[e].sprite = ent_ents[e].sprbase + 0x08 +
|
pEnt->sprite = pEnt->sprbase + 0x08 +
|
||||||
(((ent_ents[e].x ^ ent_ents[e].y) & 0x04) ? 1 : 0);
|
(((pEnt->x ^ pEnt->y) & 0x04) ? 1 : 0);
|
||||||
|
|
||||||
/* reached rick's level? */
|
/* reached rick's level? */
|
||||||
if ((ent_ents[e].y & 0xfe) != (E_RICK_ENT.y & 0xfe)) goto ymove;
|
if ((pEnt->y & 0xfe) != (E_RICK_ENT.y & 0xfe)) goto ymove;
|
||||||
|
|
||||||
xmove:
|
xmove:
|
||||||
/* calc new x and test environment */
|
/* calc new x and test environment */
|
||||||
ent_ents[e].offsx = (ent_ents[e].x < E_RICK_ENT.x) ? 0x02 : -0x02;
|
pEnt->offsx = (pEnt->x < E_RICK_ENT.x) ? 0x02 : -0x02;
|
||||||
x = ent_ents[e].x + ent_ents[e].offsx;
|
x = pEnt->x + pEnt->offsx;
|
||||||
u_envtest(x, ent_ents[e].y, FALSE, &env0, &env1);
|
u_envtest(x, pEnt->y, FALSE, &env0, &env1);
|
||||||
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))
|
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))
|
||||||
return;
|
return;
|
||||||
if (env1 & MAP_EFLG_LETHAL) {
|
if (env1 & MAP_EFLG_LETHAL) {
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ent_ents[e].x = x;
|
pEnt->x = x;
|
||||||
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
|
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
|
||||||
return;
|
return;
|
||||||
goto climbing_not; /* not climbing anymore */
|
goto climbing_not; /* not climbing anymore */
|
||||||
|
|
||||||
ymove:
|
ymove:
|
||||||
/* calc new y and test environment */
|
/* calc new y and test environment */
|
||||||
yd = ent_ents[e].y < E_RICK_ENT.y ? 0x02 : -0x02;
|
yd = pEnt->y < E_RICK_ENT.y ? 0x02 : -0x02;
|
||||||
y = ent_ents[e].y + yd;
|
y = pEnt->y + yd;
|
||||||
if (y < 0 || y > 0x0140) {
|
if (y < 0 || y > 0x0140) {
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
u_envtest(ent_ents[e].x, y, FALSE, &env0, &env1);
|
u_envtest(pEnt->x, y, FALSE, &env0, &env1);
|
||||||
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
|
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
|
||||||
if (yd < 0)
|
if (yd < 0)
|
||||||
goto xmove; /* can't go up */
|
goto xmove; /* can't go up */
|
||||||
|
@ -402,7 +402,7 @@ e_them_t2_action2(U8 e)
|
||||||
goto climbing_not; /* can't go down */
|
goto climbing_not; /* can't go down */
|
||||||
}
|
}
|
||||||
/* can move */
|
/* can move */
|
||||||
ent_ents[e].y = y;
|
pEnt->y = y;
|
||||||
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
|
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -411,70 +411,70 @@ e_them_t2_action2(U8 e)
|
||||||
climbing_not:
|
climbing_not:
|
||||||
/*sys_printf("e_them_t2 climbing NOT\n");*/
|
/*sys_printf("e_them_t2 climbing NOT\n");*/
|
||||||
|
|
||||||
ent_ents[e].flgclmb = FALSE; /* not climbing */
|
pEnt->flgclmb = FALSE; /* not climbing */
|
||||||
|
|
||||||
/* calc new y (falling) and test environment */
|
/* calc new y (falling) and test environment */
|
||||||
i = (ent_ents[e].y << 8) + ent_ents[e].offsy + ent_ents[e].ylow;
|
i = (pEnt->y << 8) + pEnt->offsy + pEnt->ylow;
|
||||||
y = i >> 8;
|
y = i >> 8;
|
||||||
u_envtest(ent_ents[e].x, y, FALSE, &env0, &env1);
|
u_envtest(pEnt->x, y, FALSE, &env0, &env1);
|
||||||
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
||||||
/*sys_printf("e_them_t2 y move OK\n");*/
|
/*sys_printf("e_them_t2 y move OK\n");*/
|
||||||
/* can go there */
|
/* can go there */
|
||||||
if (env1 & MAP_EFLG_LETHAL) {
|
if (env1 & MAP_EFLG_LETHAL) {
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (y > 0x0140) { /* deactivate if outside */
|
if (y > 0x0140) { /* deactivate if outside */
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(env1 & MAP_EFLG_VERT)) {
|
if (!(env1 & MAP_EFLG_VERT)) {
|
||||||
/* save */
|
/* save */
|
||||||
ent_ents[e].y = y;
|
pEnt->y = y;
|
||||||
ent_ents[e].ylow = i;
|
pEnt->ylow = i;
|
||||||
ent_ents[e].offsy += 0x0080;
|
pEnt->offsy += 0x0080;
|
||||||
if (ent_ents[e].offsy > 0x0800)
|
if (pEnt->offsy > 0x0800)
|
||||||
ent_ents[e].offsy = 0x0800;
|
pEnt->offsy = 0x0800;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (((ent_ents[e].x & 0x07) == 0x04) && (y < E_RICK_ENT.y)) {
|
if (((pEnt->x & 0x07) == 0x04) && (y < E_RICK_ENT.y)) {
|
||||||
/*sys_printf("e_them_t2 climbing00\n");*/
|
/*sys_printf("e_them_t2 climbing00\n");*/
|
||||||
ent_ents[e].flgclmb = TRUE; /* climbing */
|
pEnt->flgclmb = TRUE; /* climbing */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*sys_printf("e_them_t2 ymove nok or ...\n");*/
|
/*sys_printf("e_them_t2 ymove nok or ...\n");*/
|
||||||
/* can't go there, or ... */
|
/* can't go there, or ... */
|
||||||
ent_ents[e].y = (ent_ents[e].y & 0xf8) | 0x03; /* align to ground */
|
pEnt->y = (pEnt->y & 0xf8) | 0x03; /* align to ground */
|
||||||
ent_ents[e].offsy = 0x0100;
|
pEnt->offsy = 0x0100;
|
||||||
if (ent_ents[e].latency != 00)
|
if (pEnt->latency != 00)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((env1 & MAP_EFLG_CLIMB) &&
|
if ((env1 & MAP_EFLG_CLIMB) &&
|
||||||
((ent_ents[e].x & 0x0e) == 0x04) &&
|
((pEnt->x & 0x0e) == 0x04) &&
|
||||||
(ent_ents[e].y > E_RICK_ENT.y)) {
|
(pEnt->y > E_RICK_ENT.y)) {
|
||||||
/*sys_printf("e_them_t2 climbing01\n");*/
|
/*sys_printf("e_them_t2 climbing01\n");*/
|
||||||
ent_ents[e].flgclmb = TRUE; /* climbing */
|
pEnt->flgclmb = TRUE; /* climbing */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calc new sprite */
|
/* calc new sprite */
|
||||||
ent_ents[e].sprite = ent_ents[e].sprbase +
|
pEnt->sprite = pEnt->sprbase +
|
||||||
ent_sprseq[(ent_ents[e].offsx < 0 ? 4 : 0) +
|
ent_sprseq[(pEnt->offsx < 0 ? 4 : 0) +
|
||||||
((ent_ents[e].x & 0x0e) >> 3)];
|
((pEnt->x & 0x0e) >> 3)];
|
||||||
/*sys_printf("e_them_t2 sprite %02x\n", ent_ents[e].sprite);*/
|
/*sys_printf("e_them_t2 sprite %02x\n", pEnt->sprite);*/
|
||||||
|
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
if (ent_ents[e].offsx == 0)
|
if (pEnt->offsx == 0)
|
||||||
ent_ents[e].offsx = 2;
|
pEnt->offsx = 2;
|
||||||
x = ent_ents[e].x + ent_ents[e].offsx;
|
x = pEnt->x + pEnt->offsx;
|
||||||
/*sys_printf("e_them_t2 xmove x=%02x\n", x);*/
|
/*sys_printf("e_them_t2 xmove x=%02x\n", x);*/
|
||||||
if (x < 0xe8) {
|
if (x < 0xe8) {
|
||||||
u_envtest(x, ent_ents[e].y, FALSE, &env0, &env1);
|
u_envtest(x, pEnt->y, FALSE, &env0, &env1);
|
||||||
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
|
||||||
ent_ents[e].x = x;
|
pEnt->x = x;
|
||||||
if ((x & 0x1e) != 0x08)
|
if ((x & 0x1e) != 0x08)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ e_them_t2_action2(U8 e)
|
||||||
*bl ^= *bh;
|
*bl ^= *bh;
|
||||||
e_them_rndnbr = bx;
|
e_them_rndnbr = bx;
|
||||||
|
|
||||||
ent_ents[e].offsx = (*bl & 0x01) ? -0x02 : 0x02;
|
pEnt->offsx = (*bl & 0x01) ? -0x02 : 0x02;
|
||||||
|
|
||||||
/* back to normal */
|
/* back to normal */
|
||||||
|
|
||||||
|
@ -503,10 +503,10 @@ e_them_t2_action2(U8 e)
|
||||||
|
|
||||||
/* U-turn */
|
/* U-turn */
|
||||||
/*sys_printf("e_them_t2 u-turn\n");*/
|
/*sys_printf("e_them_t2 u-turn\n");*/
|
||||||
if (ent_ents[e].offsx == 0)
|
if (pEnt->offsx == 0)
|
||||||
ent_ents[e].offsx = 2;
|
pEnt->offsx = 2;
|
||||||
else
|
else
|
||||||
ent_ents[e].offsx = -ent_ents[e].offsx;
|
pEnt->offsx = -pEnt->offsx;
|
||||||
#undef offsx
|
#undef offsx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,39 +516,39 @@ e_them_t2_action2(U8 e)
|
||||||
* ASM 2718
|
* ASM 2718
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t2_action(U8 e)
|
e_them_t2_action(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
e_them_t2_action2(e);
|
e_them_t2_action2(pEnt);
|
||||||
|
|
||||||
/* they kill rick */
|
/* they kill rick */
|
||||||
if (e_rick_boxtest(e))
|
if (e_rick_boxtest(pEnt))
|
||||||
e_rick_gozombie();
|
e_rick_gozombie();
|
||||||
|
|
||||||
/* lethal entities kill them */
|
/* lethal entities kill them */
|
||||||
if (u_themtest(e)) {
|
if (u_themtest(pEnt)) {
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bullet kills them */
|
/* bullet kills them */
|
||||||
if (E_BULLET_ENT.n &&
|
if (E_BULLET_ENT.n &&
|
||||||
u_fboxtest(e, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 00 : 0x18),
|
u_fboxtest(pEnt, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 00 : 0x18),
|
||||||
E_BULLET_ENT.y)) {
|
E_BULLET_ENT.y)) {
|
||||||
E_BULLET_ENT.n = 0;
|
E_BULLET_ENT.n = 0;
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bomb kills them */
|
/* bomb kills them */
|
||||||
if (e_bomb_lethal && e_bomb_hit(e)) {
|
if (e_bomb_lethal && e_bomb_hit(pEnt)) {
|
||||||
e_them_gozombie(e);
|
e_them_gozombie(pEnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rick stops them */
|
/* rick stops them */
|
||||||
if (E_RICK_STTST(E_RICK_STSTOP) &&
|
if (E_RICK_STTST(E_RICK_STSTOP) &&
|
||||||
u_fboxtest(e, e_rick_stop_x, e_rick_stop_y))
|
u_fboxtest(pEnt, e_rick_stop_x, e_rick_stop_y))
|
||||||
ent_ents[e].latency = 0x14;
|
pEnt->latency = 0x14;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -566,7 +566,7 @@ e_them_t2_action(U8 e)
|
||||||
* ASM: 255A
|
* ASM: 255A
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t3_action2(U8 e)
|
e_them_t3_action2(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
#define sproffs c1
|
#define sproffs c1
|
||||||
#define step_count c2
|
#define step_count c2
|
||||||
|
@ -576,41 +576,41 @@ e_them_t3_action2(U8 e)
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
/* calc new sprite */
|
/* calc new sprite */
|
||||||
i = ent_sprseq[ent_ents[e].sprbase + ent_ents[e].sproffs];
|
i = ent_sprseq[pEnt->sprbase + pEnt->sproffs];
|
||||||
if (i == 0xff)
|
if (i == 0xff)
|
||||||
i = ent_sprseq[ent_ents[e].sprbase];
|
i = ent_sprseq[pEnt->sprbase];
|
||||||
ent_ents[e].sprite = i;
|
pEnt->sprite = i;
|
||||||
|
|
||||||
if (ent_ents[e].sproffs != 0) { /* awake */
|
if (pEnt->sproffs != 0) { /* awake */
|
||||||
|
|
||||||
/* rotate sprseq */
|
/* rotate sprseq */
|
||||||
if (ent_sprseq[ent_ents[e].sprbase + ent_ents[e].sproffs] != 0xff)
|
if (ent_sprseq[pEnt->sprbase + pEnt->sproffs] != 0xff)
|
||||||
ent_ents[e].sproffs++;
|
pEnt->sproffs++;
|
||||||
if (ent_sprseq[ent_ents[e].sprbase + ent_ents[e].sproffs] == 0xff)
|
if (ent_sprseq[pEnt->sprbase + pEnt->sproffs] == 0xff)
|
||||||
ent_ents[e].sproffs = 1;
|
pEnt->sproffs = 1;
|
||||||
|
|
||||||
if (ent_ents[e].step_count < ent_mvstep[ent_ents[e].step_no].count) {
|
if (pEnt->step_count < ent_mvstep[pEnt->step_no].count) {
|
||||||
/*
|
/*
|
||||||
* still running this step: try to increment x and y while
|
* still running this step: try to increment x and y while
|
||||||
* checking that they remain within boudaries. if so, return.
|
* checking that they remain within boudaries. if so, return.
|
||||||
* else switch to next step.
|
* else switch to next step.
|
||||||
*/
|
*/
|
||||||
ent_ents[e].step_count++;
|
pEnt->step_count++;
|
||||||
x = ent_ents[e].x + ((S16)(ent_mvstep[ent_ents[e].step_no].dx));
|
x = pEnt->x + ((S16)(ent_mvstep[pEnt->step_no].dx));
|
||||||
|
|
||||||
/* check'n save */
|
/* check'n save */
|
||||||
if (x > 0 && x < 0xe8) {
|
if (x > 0 && x < 0xe8) {
|
||||||
ent_ents[e].x = x;
|
pEnt->x = x;
|
||||||
/*FIXME*/
|
/*FIXME*/
|
||||||
/*
|
/*
|
||||||
y = ent_mvstep[ent_ents[e].step_no].dy;
|
y = ent_mvstep[pEnt->step_no].dy;
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y += 0xff00;
|
y += 0xff00;
|
||||||
y += ent_ents[e].y;
|
y += pEnt->y;
|
||||||
*/
|
*/
|
||||||
y = ent_ents[e].y + ((S16)(ent_mvstep[ent_ents[e].step_no].dy));
|
y = pEnt->y + ((S16)(ent_mvstep[pEnt->step_no].dy));
|
||||||
if (y > 0 && y < 0x0140) {
|
if (y > 0 && y < 0x0140) {
|
||||||
ent_ents[e].y = y;
|
pEnt->y = y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -620,62 +620,62 @@ e_them_t3_action2(U8 e)
|
||||||
* step is done, or x or y is outside boundaries. try to
|
* step is done, or x or y is outside boundaries. try to
|
||||||
* switch to next step
|
* switch to next step
|
||||||
*/
|
*/
|
||||||
ent_ents[e].step_no++;
|
pEnt->step_no++;
|
||||||
if (ent_mvstep[ent_ents[e].step_no].count != 0xff) {
|
if (ent_mvstep[pEnt->step_no].count != 0xff) {
|
||||||
/* there is a next step: init and loop */
|
/* there is a next step: init and loop */
|
||||||
ent_ents[e].step_count = 0;
|
pEnt->step_count = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* there is no next step: restart or deactivate */
|
/* there is no next step: restart or deactivate */
|
||||||
if (!E_RICK_STTST(E_RICK_STZOMBIE) &&
|
if (!E_RICK_STTST(E_RICK_STZOMBIE) &&
|
||||||
!(ent_ents[e].flags & ENT_FLG_ONCE)) {
|
!(pEnt->flags & ENT_FLG_ONCE)) {
|
||||||
/* loop this entity */
|
/* loop this entity */
|
||||||
ent_ents[e].sproffs = 0;
|
pEnt->sproffs = 0;
|
||||||
ent_ents[e].n &= ~ENT_LETHAL;
|
pEnt->n &= ~ENT_LETHAL;
|
||||||
if (ent_ents[e].flags & ENT_FLG_LETHALR)
|
if (pEnt->flags & ENT_FLG_LETHALR)
|
||||||
ent_ents[e].n |= ENT_LETHAL;
|
pEnt->n |= ENT_LETHAL;
|
||||||
ent_ents[e].x = ent_ents[e].xsave;
|
pEnt->x = pEnt->xsave;
|
||||||
ent_ents[e].y = ent_ents[e].ysave;
|
pEnt->y = pEnt->ysave;
|
||||||
if (ent_ents[e].y < 0 || ent_ents[e].y > 0x140) {
|
if (pEnt->y < 0 || pEnt->y > 0x140) {
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* deactivate this entity */
|
/* deactivate this entity */
|
||||||
ent_ents[e].n = 0;
|
pEnt->n = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* ent_ents[e].sprseq1 == 0 -- waiting */
|
else { /* pEnt->sprseq1 == 0 -- waiting */
|
||||||
|
|
||||||
/* ugly GOTOs */
|
/* ugly GOTOs */
|
||||||
|
|
||||||
if (ent_ents[e].flags & ENT_FLG_TRIGRICK) { /* reacts to rick */
|
if (pEnt->flags & ENT_FLG_TRIGRICK) { /* reacts to rick */
|
||||||
/* wake up if triggered by rick */
|
/* wake up if triggered by rick */
|
||||||
if (u_trigbox(e, E_RICK_ENT.x + 0x0C, E_RICK_ENT.y + 0x0A))
|
if (u_trigbox(pEnt, E_RICK_ENT.x + 0x0C, E_RICK_ENT.y + 0x0A))
|
||||||
goto wakeup;
|
goto wakeup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent_ents[e].flags & ENT_FLG_TRIGSTOP) { /* reacts to rick "stop" */
|
if (pEnt->flags & ENT_FLG_TRIGSTOP) { /* reacts to rick "stop" */
|
||||||
/* wake up if triggered by rick "stop" */
|
/* wake up if triggered by rick "stop" */
|
||||||
if (E_RICK_STTST(E_RICK_STSTOP) &&
|
if (E_RICK_STTST(E_RICK_STSTOP) &&
|
||||||
u_trigbox(e, e_rick_stop_x, e_rick_stop_y))
|
u_trigbox(pEnt, e_rick_stop_x, e_rick_stop_y))
|
||||||
goto wakeup;
|
goto wakeup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent_ents[e].flags & ENT_FLG_TRIGBULLET) { /* reacts to bullets */
|
if (pEnt->flags & ENT_FLG_TRIGBULLET) { /* reacts to bullets */
|
||||||
/* wake up if triggered by bullet */
|
/* wake up if triggered by bullet */
|
||||||
if (E_BULLET_ENT.n && u_trigbox(e, e_bullet_xc, e_bullet_yc)) {
|
if (E_BULLET_ENT.n && u_trigbox(pEnt, e_bullet_xc, e_bullet_yc)) {
|
||||||
E_BULLET_ENT.n = 0;
|
E_BULLET_ENT.n = 0;
|
||||||
goto wakeup;
|
goto wakeup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ent_ents[e].flags & ENT_FLG_TRIGBOMB) { /* reacts to bombs */
|
if (pEnt->flags & ENT_FLG_TRIGBOMB) { /* reacts to bombs */
|
||||||
/* wake up if triggered by bomb */
|
/* wake up if triggered by bomb */
|
||||||
if (e_bomb_lethal && u_trigbox(e, e_bomb_xc, e_bomb_yc))
|
if (e_bomb_lethal && u_trigbox(pEnt, e_bomb_xc, e_bomb_yc))
|
||||||
goto wakeup;
|
goto wakeup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,15 +694,15 @@ e_them_t3_action2(U8 e)
|
||||||
* FIXME is it 8 of them, not 10?
|
* FIXME is it 8 of them, not 10?
|
||||||
* FIXME testing below...
|
* FIXME testing below...
|
||||||
*/
|
*/
|
||||||
syssnd_play(WAV_ENTITY[(ent_ents[e].trigsnd & 0x1F) - 0x14], 1);
|
syssnd_play(WAV_ENTITY[(pEnt->trigsnd & 0x1F) - 0x14], 1);
|
||||||
/*syssnd_play(WAV_ENTITY[0], 1);*/
|
/*syssnd_play(WAV_ENTITY[0], 1);*/
|
||||||
#endif
|
#endif
|
||||||
ent_ents[e].n &= ~ENT_LETHAL;
|
pEnt->n &= ~ENT_LETHAL;
|
||||||
if (ent_ents[e].flags & ENT_FLG_LETHALI)
|
if (pEnt->flags & ENT_FLG_LETHALI)
|
||||||
ent_ents[e].n |= ENT_LETHAL;
|
pEnt->n |= ENT_LETHAL;
|
||||||
ent_ents[e].sproffs = 1;
|
pEnt->sproffs = 1;
|
||||||
ent_ents[e].step_count = 0;
|
pEnt->step_count = 0;
|
||||||
ent_ents[e].step_no = ent_ents[e].step_no_i;
|
pEnt->step_no = pEnt->step_no_i;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -716,13 +716,13 @@ e_them_t3_action2(U8 e)
|
||||||
* ASM 2546
|
* ASM 2546
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
e_them_t3_action(U8 e)
|
e_them_t3_action(ent_t* pEnt)
|
||||||
{
|
{
|
||||||
e_them_t3_action2(e);
|
e_them_t3_action2(pEnt);
|
||||||
|
|
||||||
/* if lethal, can kill rick */
|
/* if lethal, can kill rick */
|
||||||
if ((ent_ents[e].n & ENT_LETHAL) &&
|
if ((pEnt->n & ENT_LETHAL) &&
|
||||||
!E_RICK_STTST(E_RICK_STZOMBIE) && e_rick_boxtest(e)) { /* CALL 1130 */
|
!E_RICK_STTST(E_RICK_STZOMBIE) && e_rick_boxtest(pEnt)) { /* CALL 1130 */
|
||||||
e_rick_gozombie();
|
e_rick_gozombie();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -293,7 +293,7 @@ frame(void)
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
{
|
{
|
||||||
printf("%ld game_state = %s\n", *tick, game_state_strings[game_state]);
|
// printf("%ld game_state = %s\n", *tick, game_state_strings[game_state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -610,8 +610,6 @@ init(void)
|
||||||
{
|
{
|
||||||
U8 i;
|
U8 i;
|
||||||
|
|
||||||
printf("game.c: init(void);\n");
|
|
||||||
|
|
||||||
E_RICK_STRST(0xff);
|
E_RICK_STRST(0xff);
|
||||||
|
|
||||||
game_lives = 6;
|
game_lives = 6;
|
||||||
|
|
38
src/util.c
38
src/util.c
|
@ -36,12 +36,12 @@
|
||||||
* ret: TRUE/(x,y) is within e's space, FALSE/not.
|
* ret: TRUE/(x,y) is within e's space, FALSE/not.
|
||||||
*/
|
*/
|
||||||
U8
|
U8
|
||||||
u_fboxtest(U8 e, S16 x, S16 y)
|
u_fboxtest(ent_t* pEnt, S16 x, S16 y)
|
||||||
{
|
{
|
||||||
if (ent_ents[e].x >= x ||
|
if (pEnt->x >= x ||
|
||||||
ent_ents[e].x + ent_ents[e].w < x ||
|
pEnt->x + pEnt->w < x ||
|
||||||
ent_ents[e].y >= y ||
|
pEnt->y >= y ||
|
||||||
ent_ents[e].y + ent_ents[e].h < y)
|
pEnt->y + pEnt->h < y)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -60,20 +60,20 @@ u_fboxtest(U8 e, S16 x, S16 y)
|
||||||
* ret: TRUE/intersect, FALSE/not.
|
* ret: TRUE/intersect, FALSE/not.
|
||||||
*/
|
*/
|
||||||
U8
|
U8
|
||||||
u_boxtest(U8 e1, U8 e2)
|
u_boxtest(ent_t* pEnt1, ent_t* pEnt2)
|
||||||
{
|
{
|
||||||
/* rick is special (may be crawling) */
|
/* rick is special (may be crawling) */
|
||||||
if (e1 == E_RICK_NO)
|
if (pEnt1 == &ent_ents[E_RICK_NO])
|
||||||
return e_rick_boxtest(e2);
|
return e_rick_boxtest(pEnt2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* entity 1: x+0x05 to x+0x011, y to y+0x14
|
* entity 1: x+0x05 to x+0x011, y to y+0x14
|
||||||
* entity 2: x to x+ .w, y to y+ .h
|
* entity 2: x to x+ .w, y to y+ .h
|
||||||
*/
|
*/
|
||||||
if (ent_ents[e1].x + 0x11 < ent_ents[e2].x ||
|
if (pEnt1->x + 0x11 < pEnt2->x ||
|
||||||
ent_ents[e1].x + 0x05 > ent_ents[e2].x + ent_ents[e2].w ||
|
pEnt1->x + 0x05 > pEnt2->x + pEnt2->w ||
|
||||||
ent_ents[e1].y + 0x14 < ent_ents[e2].y ||
|
pEnt1->y + 0x14 < pEnt2->y ||
|
||||||
ent_ents[e1].y > ent_ents[e2].y + ent_ents[e2].h - 1)
|
pEnt1->y > pEnt2->y + pEnt2->h - 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -175,7 +175,7 @@ u_envtest(S16 x, S16 y, U8 crawl, U8 *rc0, U8 *rc1)
|
||||||
*/
|
*/
|
||||||
if (!(*rc1 & MAP_EFLG_LETHAL)
|
if (!(*rc1 & MAP_EFLG_LETHAL)
|
||||||
&& ent_ents[0].n
|
&& ent_ents[0].n
|
||||||
&& u_boxtest(ENT_ENTSNUM, 0)) {
|
&& u_boxtest(&ent_ents[ENT_ENTSNUM], &ent_ents[0])) {
|
||||||
*rc1 |= MAP_EFLG_SOLID;
|
*rc1 |= MAP_EFLG_SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,17 +193,19 @@ u_envtest(S16 x, S16 y, U8 crawl, U8 *rc0, U8 *rc1)
|
||||||
* return: FALSE if not in box, TRUE if in box.
|
* return: FALSE if not in box, TRUE if in box.
|
||||||
*/
|
*/
|
||||||
U8
|
U8
|
||||||
u_trigbox(U8 e, S16 x, S16 y)
|
u_trigbox(ent_t* pEnt, S16 x, S16 y)
|
||||||
{
|
{
|
||||||
U16 xmax, ymax;
|
U16 xmax, ymax;
|
||||||
|
|
||||||
xmax = ent_ents[e].trig_x + (ent_entdata[ent_ents[e].n & 0x7F].trig_w << 3);
|
//printf("u_trigbox e=%d x=%d y=%d ", e, x, y);
|
||||||
ymax = ent_ents[e].trig_y + (ent_entdata[ent_ents[e].n & 0x7F].trig_h << 3);
|
|
||||||
|
xmax = pEnt->trig_x + (ent_entdata[pEnt->n & 0x7F].trig_w << 3);
|
||||||
|
ymax = pEnt->trig_y + (ent_entdata[pEnt->n & 0x7F].trig_h << 3);
|
||||||
|
|
||||||
if (xmax > 0xFF) xmax = 0xFF;
|
if (xmax > 0xFF) xmax = 0xFF;
|
||||||
|
|
||||||
if (x <= ent_ents[e].trig_x || x > xmax ||
|
if (x <= pEnt->trig_x || x > xmax ||
|
||||||
y <= ent_ents[e].trig_y || y > ymax)
|
y <= pEnt->trig_y || y > ymax)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in New Issue