void initmbspr(void) { int i; for (i=0;i<BAGS;i++) initspr(FIRSTBAG+i,62,4,15,0,0); for (i=0;i<MONSTERS;i++) initspr(FIRSTMONSTER+i,71,4,15,0,0); initdbfspr(); }
void drawfire(int n,int16_t x,int16_t y,int16_t t) { int nn=(n==0) ? 0 : 32; if (t==0) { firespr[n]++; if (firespr[n]>2) firespr[n]=0; initspr(FIRSTFIREBALL+n,82+firespr[n]+nn,2,8,0,0); } else initspr(FIRSTFIREBALL+n,84+t+nn,2,8,0,0); drawspr(FIRSTFIREBALL+n,x,y); }
void drawmondie(int16_t n,bool nobf,int16_t dir,int16_t x,int16_t y) { if (nobf) initspr(FIRSTMONSTER+n,72,4,15,0,0); else switch(dir) { case DIR_RIGHT: initspr(FIRSTMONSTER+n,76,4,15,0,0); break; case DIR_LEFT: initspr(FIRSTMONSTER+n,80,4,14,0,0); } drawspr(FIRSTMONSTER+n,x,y); }
void initdbfspr(void) { int i; for (i=0;i<DIGGERS;i++) { digspd[i]=1; digspr[i]=0; } for (i=0;i<FIREBALLS;i++) firespr[i]=0; for (i=FIRSTDIGGER;i<LASTDIGGER;i++) initspr(i,0,4,15,0,0); for (i=FIRSTBONUS;i<LASTBONUS;i++) initspr(i,81,4,15,0,0); for (i=FIRSTFIREBALL;i<LASTFIREBALL;i++) initspr(i,82,2,8,0,0); }
void drawmon(int16_t n,bool nobf,int16_t dir,int16_t x,int16_t y) { monspr[n]+=monspd[n]; if (monspr[n]==2 || monspr[n]==0) monspd[n]=-monspd[n]; if (monspr[n]>2) monspr[n]=2; if (monspr[n]<0) monspr[n]=0; if (nobf) initspr(FIRSTMONSTER+n,monspr[n]+69,4,15,0,0); else switch (dir) { case DIR_RIGHT: initspr(FIRSTMONSTER+n,monspr[n]+73,4,15,0,0); break; case DIR_LEFT: initspr(FIRSTMONSTER+n,monspr[n]+77,4,15,0,0); } drawspr(FIRSTMONSTER+n,x,y); }
static void monster_obj_updspr(struct monster_obj_private *mop) { int16_t sprid; sprid = FIRSTMONSTER + mop->m_id; if (mop->alive) { if (mop->nobf) { initspr(sprid, mop->monspr + 69, 4, 15, 0, 0); } else { switch (mop->pos.dir) { case DIR_RIGHT: initspr(sprid, mop->monspr + 73, 4, 15, 0, 0); break; case DIR_LEFT: initspr(sprid, mop->monspr + 77, 4, 15, 0, 0); } } } else if (mop->zombie) { if (mop->nobf) { initspr(sprid, 72, 4, 15, 0, 0); } else { switch(mop->pos.dir) { case DIR_RIGHT: initspr(sprid, 76, 4, 15, 0, 0); break; case DIR_LEFT: initspr(sprid, 80, 4, 14, 0, 0); } } } }
void drawdigger(int n,int16_t t,int16_t x,int16_t y,bool f) { int nn=(n==0) ? 0 : 31; digspr[n]+=digspd[n]; if (digspr[n]==2 || digspr[n]==0) digspd[n]=-digspd[n]; if (digspr[n]>2) digspr[n]=2; if (digspr[n]<0) digspr[n]=0; if (t>=0 && t<=6 && !(t&1)) { initspr(FIRSTDIGGER+n,(t+(f ? 0 : 1))*3+digspr[n]+1+nn,4,15,0,0); drawspr(FIRSTDIGGER+n,x,y); return; } if (t>=10 && t<=15) { initspr(FIRSTDIGGER+n,40+nn-t,4,15,0,0); drawspr(FIRSTDIGGER+n,x,y); return; } first[0]=first[1]=first[2]=first[3]=first[4]=-1; }
/* return malloc()ed library state, or NULL on error */ struct spr_tree * spr_init( struct spr_node *root, void (*callback)(struct spr_node *), int dup ) { int nnodes; struct spr_tree *tree; if (!root) return NULL; tree = xmalloc( sizeof(*tree) ); tree->root = root; initspr( tree, root ); // TODO: sort nodelist? nnodes = tree->nodes; if (nnodes < 4) goto out_err; // TODO: either be re-entrant or forget about it... if (nnodes > (volatile int)sprmapnodes) grow_map( nnodes ); // set up and initialize an LCG that will cover all source/dest pairs findlcg( &tree->lcg, nnodes*(nnodes-1) ); tree->callback = callback; spr_apply(tree); // basically an init function if(dup) tree->dups = NULL; else{ tree->dups = xmalloc(sizeof(*tree->dups)); tree->dups->next = NULL; tree->dups->tree = xmalloc(nnodes * sizeof(*tree->dups->tree)); spr_copytoarray(tree->dups->tree, tree->root); } return tree; out_err: spr_statefree( tree ); return NULL; }
void drawbonus(int16_t x,int16_t y) { int n=0; initspr(FIRSTBONUS+n,81,4,15,0,0); movedrawspr(FIRSTBONUS+n,x,y); }
void drawgold(int16_t n,int16_t t,int16_t x,int16_t y) { initspr(FIRSTBAG+n,t+62,4,15,0,0); drawspr(FIRSTBAG+n,x,y); }