From 5625846bf2a0015e212ea2f1d97543cbba81e0c7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 22:32:40 +1000 Subject: TONY: Further conversion work on window conversion --- engines/tony/window.cpp | 480 ++++-------------------------------------------- 1 file changed, 31 insertions(+), 449 deletions(-) (limited to 'engines/tony/window.cpp') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c05af6b5e0..8e23ec8aa5 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -55,9 +55,6 @@ namespace Tony { #define DDRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } -// Tabella per il b&w. Globale per accederci dalla roba ASM -static uint16 m_wPrecalcTable[0x10000]; - /****************************************************************************\ * RMWindow Methods \****************************************************************************/ @@ -71,7 +68,9 @@ RMWindow::~RMWindow() { RMText::Unload(); } - +/** + * Initialises the graphics window + */ void RMWindow::Init() { initGraphics(RM_SX, RM_SY, false); @@ -83,6 +82,9 @@ void RMWindow::Init() { m_bGrabMovie = false; } +/** + * Close the window + */ void RMWindow::Close(void) { } @@ -97,467 +99,47 @@ void RMWindow::Repaint(void) { g_system->updateScreen(); } - -void RMWindow::Unlock(DDSURFACEDESC &ddsd) { -#ifdef REFACTOR_ME - m_Back->Unlock(ddsd.lpSurface); -#endif +bool RMWindow::Lock() { + return true; } -void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { -#ifdef REFACTOR_ME - Common::Rect rcScreen; - HRGN hrgnCombined; - HRGN hrgnScreen; - HRGN hrgnEllipse; - uint32 dwDataSize; - RGNDATA *rgnData; - - SetRect(&rcScreen, 0, 0, 640, 480); - - hrgnScreen = CreateRectRgnIndirect(&rcScreen); - hrgnEllipse = CreateEllipticRgnIndirect(&rcBoundEllipse); - hrgnCombined = CreateRectRgnIndirect(&rcScreen); - - CombineRgn(hrgnCombined, hrgnScreen, hrgnEllipse, RGN_DIFF); - - dwDataSize = GetRegionData(hrgnCombined, 0, NULL); - rgnData = (RGNDATA *)new char[dwDataSize]; - GetRegionData(hrgnCombined, dwDataSize, rgnData); - - m_BackClipper->SetClipList(rgnData, 0); - m_Back->SetClipper(m_BackClipper); - - DDBLTFX ddbltfx; - ddbltfx.dwSize=sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - - m_Back->SetClipper(NULL); - delete [] rgnData; - DeleteObject(hrgnCombined); - DeleteObject(hrgnEllipse); - DeleteObject(hrgnScreen); -#endif +void RMWindow::Unlock() { } -bool RMWindow::Lock(DDSURFACEDESC &ddsd) { -#ifdef REFACTOR_ME - HRESULT err; +/** + * Wipes an area of the screen + */ +void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { + if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && + (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { + // Full screen clear wanted, so use shortcut method + g_system->fillScreen(0); + } else { + // Clear the designated area a line at a time + byte line[RM_SX]; + Common::fill(line, line + RM_SX, 0); - // Lock della surface - ddsd.dwSize = sizeof(ddsd); - while (1) { - err = m_Back->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_WRITEONLY|DDLOCK_NOSYSLOCK, NULL); - if (err==DD_OK) - break; - else if (err==DDERR_SURFACELOST) { -// MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); - m_Back->Restore(); - return false; + // Loop through each line + for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { + g_system->copyRectToScreen(line, RM_SX, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); } } -#endif - return true; } void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { -#ifdef REFACTOR_ME - HRESULT err; - DDSURFACEDESC ddsd; - int x,y; - byte *dest; - uint16 *destw; - RMString s; - uint16 *src,src2; - - if (GetAsyncKeyState(VK_F7)&0x8001) - goto DOFRAMERATE; - - if (!Lock(ddsd)) - return; - - // Copia del buffer - src = (uint16 *)lpBuf; - dest = (byte *)ddsd.lpSurface; -// src+=RM_SKIPY*RM_BBX; Lo skipY e' integrato nell'offseting del bigbuffer - - if (ISMODE2()) { - // 565 RGB, Marco - Matrox G200 - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw = (uint16 *)dest; - - if (bCfgAnni30) { - __asm { - pushad - - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - line30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - line302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - mov ecx,eax ; U 2 - mov edx,ebx ; V - and eax,0x7FE07FE0 ; U 3 - and ebx,0x7FE07FE0 ; V - and ecx,0x001F001F ; U 4 - and edx,0x001F001F ; V - shl eax,1 ; U 5 - shl ebx,1 ; V - or eax,ecx ; U 6 - or ebx,edx ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 7 - mov [edi+4],ebx ; V - add esi,8 ; U 8 - add edi,8 ; V - sub x,4 ; U 9 - jnz line302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz line30 - - popad - } - - } else { - __asm { - pushad - - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - line: - mov x,RM_SX - add esi,RM_SKIPX*2 - - line2: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - mov ecx,eax ; U 2 - mov edx,ebx ; V - and eax,0x7FE07FE0 ; U 3 - and ebx,0x7FE07FE0 ; V - and ecx,0x001F001F ; U 4 - and edx,0x001F001F ; V - shl eax,1 ; U 5 - shl ebx,1 ; V - or eax,ecx ; U 6 - or ebx,edx ; V - mov [edi],eax ; U 7 - mov [edi+4],ebx ; V - add esi,8 ; U 8 - add edi,8 ; V - sub x,4 ; U 9 - jnz line2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz line - - popad - } - } - } else if (ISMODE3()) { - // 5551 RGB - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - aline30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - aline302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - shl eax,1 ; U 2 - shl ebx,1 ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz aline302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz aline30 - } - } else { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - aline: - mov x,RM_SX - add esi,RM_SKIPX*2 - - aline2: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - shl eax,1 ; U 2 - shl ebx,1 ; V - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz aline2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz aline - } - } - } else if (ISMODE4()) { - // 565 BGR - Intergraph - int lineinc=(ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2=(RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) // Manca supporto per Intergraph ... non so pairarlo!!! :) - { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - intersux30: - mov ecx,RM_SX - add esi,RM_SKIPX*2 - - intersux302: - mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - add esi,4 ; V - mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 - and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 - and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 - and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 - shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB - add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 - or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB - add edi,4 ; V - or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB - sub ecx,2 ; V - mov [edi-4],eax ; U 8 - jnz intersux302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz intersux30 - } - } else { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - intersux: - mov ecx,RM_SX - add esi,RM_SKIPX*2 - - intersux2: - mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - add esi,4 ; V - mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 - and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 - and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 - and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 - shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB - add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 - or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB - add edi,4 ; V - or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB - sub ecx,2 ; V - mov [edi-4],eax ; U 8 - jnz intersux2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz intersux - } - } + if (rcBoundEllipse == NULL) { + // Full screen update + g_system->copyRectToScreen(lpBuf, RM_SX, 0, 0, RM_SX, RM_SY); } else { - // 555 RGB - Computer di Bagio, nVidia Riva 128 - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - bagioline30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - bagioline302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz bagioline302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz bagioline30 - } - } else { - for (y = 0; y < RM_SY; y++) { - CopyMemory(dest, src + RM_SKIPX, RM_SX * 2); - dest += ddsd.lPitch; - src += RM_BBX; - } - } - } - - - // Unlock - Unlock(ddsd); - - // Effetto di wipe - if (rcBoundEllipse) { - WipeEffect(*rcBoundEllipse); - } - - // Repaint - Repaint(); - -DOFRAMERATE: - - // Conteggio per gli FPS - fcount++; - - if (lastsecond + 1000 < _vm->GetTime()) { - lastsecond = _vm->GetTime(); - fps=fcount - lastfcount; - lastfcount = fcount; - - if (!m_bFullscreen) { - s.Format("Tony Tough and the night of Roasted Moths - %u FPS",fps); - SetWindowText(m_hWnd,s); - } - } if (!_vm->getIsDemo()) { - if (m_bGrabScreenshot || m_bGrabMovie) { - RMSnapshot snapshot; - - snapshot.GrabScreenshot(lpBuf); - m_bGrabScreenshot = false; - } - - if (m_bGrabThumbnail) { - RMSnapshot snapshot; - - snapshot.GrabScreenshot(lpBuf, 4, m_wThumbBuf); - m_bGrabThumbnail = false; - } + // Update a screen section + g_system->copyRectToScreen(lpBuf, RM_SX, rcBoundEllipse->left, rcBoundEllipse->top, + rcBoundEllipse->width(), rcBoundEllipse->height()); } -#endif } /****************************************************************************\ -* Metodi di RMSnapshot +* RMSnapshot Methods \****************************************************************************/ char RMSnapshot::bufDrive[MAX_DRIVE]; -- cgit v1.2.3