for(std::list<IUpdateListener *>::iterator it = updateList.begin(); it != updateList.end(); ) { IUpdateListener *up = *it; it++; up->update();
if(updateCount) { for(std::list<IUpdateListener *>::iterator it = updateList.begin(); it != updateList.end(); ) { IUpdateListener *up = *it; it++; up->update(); }
void systemDrawScreen(){  HRESULT hret;  if(pDirectDraw == NULL ||     ddsOffscreen == NULL ||     ddsPrimary == NULL)    return;  renderedFrames++;  for(std::list<IUpdateListener *>::iterator it = updateList.begin();      it != updateList.end(); ) {    IUpdateListener *up = *it;    it++;    up->update();  }  if(aviRecording) {    int width = 240;    int height = 160;    switch(cartridgeType) {    case 0:      width = 240;      height = 160;      break;    case 1:      if(gbBorderOn) {        width = 256;        height = 224;      } else {        width = 160;        height = 144;      }      break;    }        if(aviRecorder == NULL) {      aviRecorder = new CAVIFile();            if(cartridgeType == 0) {        aviRecorder->SetRate(60/(frameSkip+1));      } else {         aviRecorder->SetRate(60/(gbFrameSkip+1));      }            BITMAPINFOHEADER bi;      memset(&bi, 0, sizeof(bi));            bi.biSize = 0x28;          bi.biPlanes = 1;      bi.biBitCount = 24;      bi.biWidth = width;      bi.biHeight = height;      bi.biSizeImage = 3*width*height;      aviRecorder->SetFormat(&bi);      aviRecorder->Open(aviRecordName);    }        char *bmp = new char[width*height*3];        utilWriteBMP(bmp, width, height, pix);    aviRecorder->AddFrame(bmp);        delete bmp;  }    if(ifbFunction) {    if(systemColorDepth == 16)      ifbFunction(pix+filterWidth*2+2, filterWidth*2+2,                  filterWidth, filterHeight);    else      ifbFunction(pix+filterWidth*4+4, filterWidth*4+4,                  filterWidth, filterHeight);  }    if(vsync && !speedup) {    hret = pDirectDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);  }    DDSURFACEDESC2 ddsDesc;    ZeroMemory(&ddsDesc, sizeof(ddsDesc));    ddsDesc.dwSize = sizeof(ddsDesc);    hret = ddsOffscreen->Lock(NULL,                            &ddsDesc,                            DDLOCK_WRITEONLY|#ifndef FINAL_VERSION                            DDLOCK_NOSYSLOCK|#endif                            DDLOCK_SURFACEMEMORYPTR,                            NULL);  if(hret == DDERR_SURFACELOST) {    hret = ddsPrimary->Restore();    if(hret == DD_OK) {      hret = ddsOffscreen->Restore();            if(hret == DD_OK) {        hret = ddsOffscreen->Lock(NULL,                                  &ddsDesc,                                  DDLOCK_WRITEONLY|#ifndef FINAL_VERSION                                  DDLOCK_NOSYSLOCK|#endif                                  DDLOCK_SURFACEMEMORYPTR,                                  NULL);              }    }  }      if(hret == DD_OK) {    if(filterFunction) {      if(systemColorDepth == 16)        (*filterFunction)(pix+filterWidth*2+2,                          filterWidth*2+2,                          (u8*)delta,                          (u8*)ddsDesc.lpSurface,                          ddsDesc.lPitch,                          filterWidth,                          filterHeight);      else        (*filterFunction)(pix+filterWidth*4+4,                          filterWidth*4+4,                          (u8*)delta,                          (u8*)ddsDesc.lpSurface,                          ddsDesc.lPitch,                          filterWidth,                          filterHeight);            } else {      int copyX = 240;      int copyY = 160;            if(cartridgeType == 1) {        if(gbBorderOn) {          copyX = 256;          copyY = 224;        } else {          copyX = 160;          copyY = 144;        }      }      // MMX doesn't seem to be faster to copy the data      __asm {        mov eax, copyX;        mov ebx, copyY;                mov esi, pix;        mov edi, ddsDesc.lpSurface;        mov edx, ddsDesc.lPitch;        cmp systemColorDepth, 16;        jnz gbaOtherColor;        sub edx, eax;        sub edx, eax;        lea esi,[esi+2*eax+2];        shr eax, 1;      gbaLoop16bit:        mov ecx, eax;        repz movsd;        inc esi;        inc esi;        add edi, edx;        dec ebx;        jnz gbaLoop16bit;        jmp gbaLoopEnd;      gbaOtherColor:        cmp systemColorDepth, 32;        jnz gbaOtherColor2;                sub edx, eax;        sub edx, eax;        sub edx, eax;        sub edx, eax;        lea esi, [esi+4*eax+4];      gbaLoop32bit:        mov ecx, eax;        repz movsd;        add esi, 4;        add edi, edx;        dec ebx;        jnz gbaLoop32bit;        jmp gbaLoopEnd;      gbaOtherColor2:        lea eax, [eax+2*eax];        sub edx, eax;      gbaLoop24bit:        mov ecx, eax;        shr ecx, 2;        repz movsd;        add edi, edx;        dec ebx;        jnz gbaLoop24bit;      gbaLoopEnd:      }    }    if(videoOption > VIDEO_4X && showSpeed) {      char buffer[30];      if(showSpeed == 1)        sprintf(buffer, "%3d%%", systemSpeed);      else        sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,                systemFrameSkip,                showRenderedFrames);      if(showSpeedTransparent)        fontDisplayStringTransp((u8*)ddsDesc.lpSurface,                                ddsDesc.lPitch,                                rect.left+10,                                rect.bottom-10,                                buffer);      else        fontDisplayString((u8*)ddsDesc.lpSurface,                          ddsDesc.lPitch,                          rect.left+10,                          rect.bottom-10,                          buffer);            }  } else if(ddrawDebug)    winlog("Error during lock: %08x\n", hret);        hret = ddsOffscreen->Unlock(NULL);    if(hret == DD_OK) {    ddsOffscreen->PageLock(0);    if(tripleBuffering && videoOption > VIDEO_4X) {      hret = ddsFlip->Blt(&dest, ddsOffscreen, &rect, DDBLT_WAIT, NULL);      if(hret == DD_OK) {        if(menuToggle) {          pDirectDraw->FlipToGDISurface();          ddsPrimary->SetClipper(ddsClipper);          hret = ddsPrimary->Blt(&dest, ddsFlip, &dest, DDBLT_ASYNC, NULL);          // if using emulation only, then we have to redraw the menu          // everytime. It seems like a bug in DirectDraw to me as we not          // overwritting the menu area at all.          if(ddrawUsingEmulationOnly)            DrawMenuBar(hWindow);        } else          hret = ddsPrimary->Flip(NULL, 0);      }    } else {      hret = ddsPrimary->Blt(&dest, ddsOffscreen, &rect,DDBLT_ASYNC,NULL);            if(hret == DDERR_SURFACELOST) {        hret = ddsPrimary->Restore();                if(hret == DD_OK) {          hret = ddsPrimary->Blt(&dest, ddsOffscreen, &rect, DDBLT_ASYNC, NULL);        }      }    }    ddsOffscreen->PageUnlock(0);  } else if(ddrawDebug)    winlog("Error during unlock: %08x\n", hret);  if(screenMessage) {    if(((GetTickCount() - screenMessageTime) < 3000) &&       !disableStatusMessage) {      ddsPrimary->SetClipper(ddsClipper);      HDC hdc;      ddsPrimary->GetDC(&hdc);      SetTextColor(hdc, RGB(255,0,0));      SetBkMode(hdc,TRANSPARENT);            TextOut(hdc, dest.left+10, dest.bottom - 20, screenMessageBuffer,              strlen(screenMessageBuffer));      ddsPrimary->ReleaseDC(hdc);    } else {      screenMessage = false;    }  }    if(hret != DD_OK) {    if(ddrawDebug)      winlog("Error on update screen: %08xl\n", hret);  }}