void domouse(int str) { /* TO USE THIS ROUTINE YOU MUST LOAD A MOUSE CURSOR USING mloadcursor. . . YOU MUST ALSO REMEMBER TO CALL mfreemem AT THE END OF THE PROGRAM. */ /* short *sstr=(short*)&mousecurs[currentcursor][0]; int poow=(short)sstr[0],pooh=(short)sstr[1];*/ int poow=wgetblockwidth(mousecurs[currentcursor]); int pooh=wgetblockheight(mousecurs[currentcursor]); int smx=mousex-hotxwas,smy=mousey-hotywas; // mousex-=hotx; mousey-=hoty; mgetgraphpos(); mousex-=hotx; mousey-=hoty; if (mousex+poow>=vesa_xres) poow=vesa_xres-mousex; if (mousey+pooh>=vesa_yres) pooh=vesa_yres-mousey; wclip(0,0,vesa_xres-1,vesa_yres-1); if ((str==0) & (mouseturnedon==TRUE)) { if ((mousex!=smx) | (mousey!=smy)) { // the mouse has moved wputblock(smx,smy,savebk,0); wfreeblock(savebk); savebk=wnewblock(mousex,mousey,mousex+poow,mousey+pooh); wputblock(mousex,mousey,mousecurs[currentcursor],1); } } else if ((str==1) & (mouseturnedon==FALSE)) { // the mouse is just being turned on savebk=wnewblock(mousex,mousey,mousex+poow,mousey+pooh); wputblock(mousex,mousey,mousecurs[currentcursor],1); mouseturnedon=TRUE; } else if ((str==2) & (mouseturnedon==TRUE)) { // the mouse is being turned off // if (abuf != ignore_mouseoff_bitmap) wputblock(smx,smy,savebk,0); wfreeblock(savebk); mouseturnedon=FALSE; } mousex+=hotx; mousey+=hoty; hotxwas=hotx; hotywas=hoty; }
void IAGSEngine::BlitBitmap (int x, int y, BITMAP *bmp, int masked) { wputblock (x, y, bmp, masked); invalidate_rect(x, y, x + bmp->w, y + bmp->h); }
int try_this_square(int srcx, int srcy, int tox, int toy) { if (beenhere[srcy][srcx] & 0x80) return 0; // nesting of 8040 leads to stack overflow if (nesting > 7000) return 0; nesting++; if (can_see_from(srcx, srcy, tox, toy)) { finalpartx = srcx; finalparty = srcy; nesting--; pathbackstage = 0; return 2; } #ifdef DEBUG_PATHFINDER wputblock(lastcx, lastcy, mousecurs[C_CROSS], 1); #endif int trydir = DIR_UP; int xdiff = abs(srcx - tox), ydiff = abs(srcy - toy); if (ydiff > xdiff) { if (srcy > toy) trydir = DIR_UP; else trydir = DIR_DOWN; } else if (srcx > tox) trydir = DIR_LEFT; else if (srcx < tox) trydir = DIR_RIGHT; int iterations = 0; try_again: int nextx = srcx, nexty = srcy; if (trydir == DIR_LEFT) nextx--; else if (trydir == DIR_RIGHT) nextx++; else if (trydir == DIR_DOWN) nexty++; else if (trydir == DIR_UP) nexty--; iterations++; if (iterations > 5) { // fprintf(stderr,"not found: %d,%d beenhere 0x%X\n",srcx,srcy,beenhere[srcy][srcx]); nesting--; return 0; } if (((nextx < 0) | (nextx >= wallscreen->w) | (nexty < 0) | (nexty >= wallscreen->h)) || (getpixel(wallscreen, nextx, nexty) == 0) || ((beenhere[srcy][srcx] & (1 << trydir)) != 0)) { if (leftorright == 0) { trydir++; if (trydir > 3) trydir = 0; } else { trydir--; if (trydir < 0) trydir = 3; } goto try_again; } beenhere[srcy][srcx] |= (1 << trydir); // srcx=nextx; srcy=nexty; beenhere[srcy][srcx] |= 0x80; // being processed int retcod = try_this_square(nextx, nexty, tox, toy); if (retcod == 0) goto try_again; nesting--; beenhere[srcy][srcx] &= 0x7f; if (retcod == 2) { pathbackx[pathbackstage] = srcx; pathbacky[pathbackstage] = srcy; pathbackstage++; if (pathbackstage >= MAXPATHBACK - 1) return 0; return 2; } return 1; }