void DrawBackgnd() { int i; // playfield counter PLAYFIELD *pPlay; // playfield pointer int prevX, prevY; // save interger part of position Common::Point ptWin; // window top left if (pCurBgnd == NULL) return; // no current background // scroll each background playfield for (i = 0; i < pCurBgnd->numPlayfields; i++) { // get pointer to correct playfield pPlay = pCurBgnd->fieldArray + i; // save integer part of position prevX = fracToInt(pPlay->fieldX); prevY = fracToInt(pPlay->fieldY); // update scrolling pPlay->fieldX += pPlay->fieldXvel; pPlay->fieldY += pPlay->fieldYvel; // convert fixed point window pos to a int ptWin.x = fracToInt(pPlay->fieldX); ptWin.y = fracToInt(pPlay->fieldY); // set the moved flag if the playfield has moved if (prevX != ptWin.x || prevY != ptWin.y) pPlay->bMoved = true; // sort the display list for this background - just in case somebody has changed object Z positions SortObjectList((OBJECT *)&pPlay->pDispList); // generate clipping rects for all objects that have moved etc. FindMovingObjects((OBJECT *)&pPlay->pDispList, &ptWin, &pPlay->rcClip, false, pPlay->bMoved); // clear playfield moved flag pPlay->bMoved = false; } // merge the clipping rectangles MergeClipRect(); // redraw all playfields within the clipping rectangles const RectList &clipRects = GetClipRects(); for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) { // clear the clip rectangle on the virtual screen // for each background playfield for (i = 0; i < pCurBgnd->numPlayfields; i++) { Common::Rect rcPlayClip; // clip rect for this playfield // get pointer to correct playfield pPlay = pCurBgnd->fieldArray + i; // convert fixed point window pos to a int ptWin.x = fracToInt(pPlay->fieldX); ptWin.y = fracToInt(pPlay->fieldY); if (IntersectRectangle(rcPlayClip, pPlay->rcClip, *r)) // redraw all objects within this clipping rect UpdateClipRect((OBJECT *)&pPlay->pDispList, &ptWin, &rcPlayClip); } } // transfer any new palettes to the video DAC PalettesToVideoDAC(); // update the screen within the clipping rectangles for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) { UpdateScreenRect(*r); } g_system->updateScreen(); // delete all the clipping rectangles ResetClipRect(); }
char *DialogBox(int type,const char *fmt,...) { SDL_Rect rect; char *val; int vallen; va_list args; char *buf; int i,h,cnt=0; char *ptr[20]; char *p; buf=(char *)malloc(4096); val=(char *)malloc(4096); va_start(args,fmt); vsnprintf(buf,4095,fmt,args); va_end(args); p=buf; ptr[0]=p;cnt=1; while (*p) { if (*p=='\n') { ptr[cnt++]=p+1; *p=0; } p++; } rect.w=352; rect.h=128; rect.x=(resX-rect.w) >> 1; rect.y=(resY-rect.h) >> 1; SDL_BlitSurface(GfxData[type],NULL,GfxData[SCREEN],&rect); rect.w-=4; rect.h-=4; rect.x+=2; rect.y+=2; if (type==DLGWINNER || type==DLGLOOSER) BFont_SetCurrentFont(bigfont); h=BFont_FontHeight(BFont_GetCurrentFont()); for (i=0;i<cnt;i++) BFont_CenteredPutString(GfxData[SCREEN],240-h*cnt/2+h*i,ptr[i]); UpdateScreenRect(rect.x-2,rect.y-2,rect.w+4,rect.h+4); if (type==DLGWINNER || type==DLGLOOSER) BFont_SetCurrentFont(font); free(buf); if (type!=DLGNETWORK) return NULL; val[0]='_';val[1]=0;vallen=1;h=0; while (!h) { rect.x=160; rect.y=272; rect.w=320; rect.h=16; SDL_FillRect(GfxData[SCREEN],&rect,0); i=BFont_TextWidth(val); if (i<312) BFont_PutString(GfxData[SCREEN],164,276,val); else BFont_PutString(GfxData[SCREEN],164+(312-i),276,val); SDL_UpdateRect(GfxData[SCREEN],160,272,320,16); while (event.type!=SDL_KEYDOWN) { SDL_PollEvent(&event); // wait for keypress SDL_Delay(CPUWAIT); } if (event.type==SDL_KEYDOWN) { i=ValidInputChar(event.key.keysym.sym); if (i&&(vallen<4095)) { val[vallen-1]=i; val[vallen++]='_'; val[vallen]=0; } if (((vallen>1)&&(event.key.keysym.sym==SDLK_BACKSPACE))||(event.key.keysym.sym==SDLK_DELETE)) { val[--vallen]=0; val[vallen-1]='_'; } if ((event.key.keysym.sym==SDLK_KP_ENTER)||(event.key.keysym.sym==SDLK_RETURN)) h=1; if (event.key.keysym.sym==SDLK_ESCAPE) h=2; while (event.type!=SDL_KEYUP) { SDL_PollEvent(&event); // wait for keyrelease SDL_Delay(CPUWAIT); } } } if (h==2) return NULL; else { val[vallen-1]=0; return val; } }