diff options
author | Torbjörn Andersson | 2003-10-07 07:07:47 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2003-10-07 07:07:47 +0000 |
commit | 29b646b30a967f1ec1028b4112fd106ed7b24143 (patch) | |
tree | a2f2dbe3de212e437844fe546ef51321a6f13ffd /sword2/driver | |
parent | e8b6016e336567ef9abf9c0b5e1fe3097c02a90e (diff) | |
download | scummvm-rg350-29b646b30a967f1ec1028b4112fd106ed7b24143.tar.gz scummvm-rg350-29b646b30a967f1ec1028b4112fd106ed7b24143.tar.bz2 scummvm-rg350-29b646b30a967f1ec1028b4112fd106ed7b24143.zip |
Some cleanup, some code removal and some unstubbing. Nothing important.
svn-id: r10659
Diffstat (limited to 'sword2/driver')
-rw-r--r-- | sword2/driver/driver96.h | 1 | ||||
-rw-r--r-- | sword2/driver/language.cpp | 30 | ||||
-rw-r--r-- | sword2/driver/palette.cpp | 17 | ||||
-rw-r--r-- | sword2/driver/rdwin.cpp | 16 | ||||
-rw-r--r-- | sword2/driver/render.cpp | 247 |
5 files changed, 85 insertions, 226 deletions
diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h index f27adae736..3f49a84961 100644 --- a/sword2/driver/driver96.h +++ b/sword2/driver/driver96.h @@ -303,7 +303,6 @@ extern void SetWindowName(const char *windowName); //----------------------------------------------------------------------------- extern int32 GetLanguageVersion(uint8 *version); extern int32 SetLanguageVersion(uint8 version); -extern int32 GetGameName(uint8 *name); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/sword2/driver/language.cpp b/sword2/driver/language.cpp index a7b67d7f99..eaef47999b 100644 --- a/sword2/driver/language.cpp +++ b/sword2/driver/language.cpp @@ -66,34 +66,4 @@ int32 SetLanguageVersion(uint8 version) { return RD_OK; } -/** - * Fills the string pointed to by 'name' with the title of the game, depending - * upon what the current language version is. - * @param name buffer to store the title of the game in - */ - -int32 GetGameName(uint8 *name) { - uint8 version; - int32 rv; - - rv = GetLanguageVersion(&version); - - switch (version) { - case ENGLISH: - strcpy((char *) name, "Broken Sword II"); - break; - case AMERICAN: - strcpy((char *) name, "Circle of Blood II"); - break; - case GERMAN: - strcpy((char *) name, "Baphomet's Fluch II"); - break; - default: - strcpy((char *) name, "Some game or other, part 86"); - return RDERR_INVALIDVERSION; - } - - return rv; -} - } // End of namespace Sword2 diff --git a/sword2/driver/palette.cpp b/sword2/driver/palette.cpp index fe10ce31c0..c08f0ac14e 100644 --- a/sword2/driver/palette.cpp +++ b/sword2/driver/palette.cpp @@ -29,11 +29,10 @@ namespace Sword2 { #define PALTABLESIZE 64 * 64 * 64 uint8 palCopy[256][4]; -uint8 fadePalette[256][4]; -uint8 paletteMatch[PALTABLESIZE]; - -uint8 fadeStatus = RDFADE_NONE; +static uint8 fadePalette[256][4]; +static uint8 paletteMatch[PALTABLESIZE]; +static uint8 fadeStatus = RDFADE_NONE; static int32 fadeStartTime; static int32 fadeTotalTime; @@ -65,8 +64,7 @@ uint8 GetMatch(uint8 r, uint8 g, uint8 b) { min = diff; minIndex = 0; if (diff > 0) { - i = 1; - while (i < 256) { + for (i = 1; i < 256; i++) { diffred = palCopy[i][0] - r; diffgreen = palCopy[i][1] - g; diffblue = palCopy[i][2] - b; @@ -78,7 +76,6 @@ uint8 GetMatch(uint8 r, uint8 g, uint8 b) { if (min == 0) break; } - i++; } } @@ -111,7 +108,7 @@ int32 UpdatePaletteMatchTable(uint8 *data) { } } } else { - // The provided data is th new palette match table + // The provided data is the new palette match table memcpy(paletteMatch, data, PALTABLESIZE); } @@ -155,10 +152,10 @@ int32 BS2_SetPalette(int16 startEntry, int16 noEntries, uint8 *colourTable, uint int32 DimPalette(void) { byte *p = (byte *) palCopy; - uint32 i; - for (i = 0; i < 256 * 4; i++) + for (int i = 0; i < 256 * 4; i++) p[i] /= 2; + g_system->set_palette(p, 0, 256); return RD_OK; } diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp index 95a5e12efc..6d63521ce7 100644 --- a/sword2/driver/rdwin.cpp +++ b/sword2/driver/rdwin.cpp @@ -18,8 +18,7 @@ */ #include "common/stdafx.h" -#include "base/engine.h" -#include "common/timer.h" +#include "bs2/sword2.h" #include "bs2/driver/driver96.h" #include "bs2/driver/_mouse.h" #include "bs2/driver/keyboard.h" @@ -29,12 +28,9 @@ #include "bs2/driver/render.h" #include "bs2/driver/menu.h" #include "bs2/driver/d_sound.h" -#include "bs2/sword2.h" namespace Sword2 { -#define MENUDEEP 40 // Temporary, until menu.h is written! - // --------------------------------------------------------------------------- // OSystem Event Handler. Full of cross platform goodness and 99% fat free! // --------------------------------------------------------------------------- @@ -117,14 +113,14 @@ int32 ServiceWindows(void) { } /** - * Set the window name to windowName and stores this name in gameName for - * future use. + * Set the window title */ void SetWindowName(const char *windowName) { - warning("stub SetWindowName( %s )", windowName); - // SetWindowText(hwnd, windowName); - // strcpy(gameName, windowName); + OSystem::Property prop; + + prop.caption = windowName; + g_system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop); } } // End of namespace Sword2 diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp index ffae9d5518..9718106963 100644 --- a/sword2/driver/render.cpp +++ b/sword2/driver/render.cpp @@ -49,14 +49,14 @@ static uint16 layer = 0; #define RENDERAVERAGETOTAL 4 -int32 renderCountIndex = 0; -int32 renderTimeLog[RENDERAVERAGETOTAL] = { 60, 60, 60, 60 }; -int32 initialTime; -int32 startTime; -int32 totalTime; -int32 renderAverageTime = 60; -int32 framesPerGameCycle; -int32 renderTooSlow; +static int32 renderCountIndex = 0; +static int32 renderTimeLog[RENDERAVERAGETOTAL] = { 60, 60, 60, 60 }; +static int32 initialTime; +static int32 startTime; +static int32 totalTime; +static int32 renderAverageTime = 60; +static int32 framesPerGameCycle; +static int32 renderTooSlow; #define BLOCKWIDTH 64 #define BLOCKHEIGHT 64 @@ -64,8 +64,8 @@ int32 renderTooSlow; #define BLOCKHBITS 6 #define MAXLAYERS 5 -uint8 xblocks[MAXLAYERS]; -uint8 yblocks[MAXLAYERS]; +static uint8 xblocks[MAXLAYERS]; +static uint8 yblocks[MAXLAYERS]; // blockSurfaces stores an array of sub-blocks for each of the parallax layers. @@ -74,7 +74,7 @@ typedef struct { bool transparent; } BlockSurface; -BlockSurface **blockSurfaces[MAXLAYERS] = { 0, 0, 0, 0, 0 }; +static BlockSurface **blockSurfaces[MAXLAYERS] = { 0, 0, 0, 0, 0 }; void UploadRect(Common::Rect *r) { g_system->copy_rect(lpBackBuffer + r->top * screenWide + r->left, @@ -403,41 +403,16 @@ int32 RestoreBackgroundLayer(_parallax *p, int16 l) */ int32 PlotPoint(uint16 x, uint16 y, uint8 colour) { - warning("stub PlotPoint( %d, %d, %d )", x, y, colour); -/* + uint8 *buf = lpBackBuffer + 40 * RENDERWIDE; int16 newx, newy; newx = x - scrollx; newy = y - scrolly; - if ((newx < 0) || (newx > RENDERWIDE) || (newy < 0) || (newy > RENDERDEEP)) - { - return(RD_OK); - } - if (renderCaps & RDBLTFX_ALLHARDWARE) - { - DDSURFACEDESC ddsd; - HRESULT hr; - - ddsd.dwSize = sizeof(DDSURFACEDESC); - hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - if (hr != DD_OK) - { - hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - } - - if (hr == DD_OK) - { - - *((uint8 *) ddsd.lpSurface + (newy + 40) * ddsd.lPitch + newx) = colour; - IDirectDrawSurface2_Unlock(lpBackBuffer, ddsd.lpSurface); - } - } - else - myScreenBuffer[newy * RENDERWIDE + newx] = colour; -*/ - return(RD_OK); + if (newx >= 0 && newx < RENDERWIDE && newy >= 0 && newy < RENDERDEEP) + buf[newy * RENDERWIDE + newx] = colour; + return RD_OK; } /** @@ -451,46 +426,24 @@ int32 PlotPoint(uint16 x, uint16 y, uint8 colour) { // Uses Bressnham's incremental algorithm! int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) { - warning("stub DrawLine( %d, %d, %d, %d, %d )", x0, y0, x1, y1, colour); -/* + uint8 *buf = lpBackBuffer + 40 * RENDERWIDE; int dx, dy; int dxmod, dymod; int ince, incne; - int d; + int d; int x, y; int addTo; - DDSURFACEDESC ddsd; - HRESULT hr; x1 -= scrollx; y1 -= scrolly; x0 -= scrollx; y0 -= scrolly; - // Lock the surface if we're rendering to the back buffer. - if (renderCaps & RDBLTFX_ALLHARDWARE) - { - ddsd.dwSize = sizeof(DDSURFACEDESC); - hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - if (hr != DD_OK) - { - hr = IDirectDrawSurface2_Lock(lpBackBuffer, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - } - if (hr != DD_OK) - return(RD_OK); - - (uint8 *) ddsd.lpSurface += (40 * ddsd.lPitch); - - } - - - - //Make sure we're going from left to right - if (x1 < x0) - { + + if (x1 < x0) { x = x1; x1 = x0; x0 = x; @@ -498,6 +451,7 @@ int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) { y1 = y0; y0 = y; } + dx = x1 - x0; dy = y1 - y0; @@ -511,42 +465,29 @@ int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) { else dymod = dy; - if (dxmod >= dymod) - { - if (dy > 0) - { + if (dxmod >= dymod) { + if (dy > 0) { d = 2 * dy - dx; ince = 2 * dy; incne = 2 * (dy - dx); x = x0; y = y0; - if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour; - else - myScreenBuffer[y * RENDERWIDE + x] = colour; - while (x < x1) - { - if (d <= 0) - { + if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP) + buf[y * RENDERWIDE + x] = colour; + + while (x < x1) { + if (d <= 0) { d += ince; - x += 1; - } - else - { + x++; + } else { d += incne; - x += 1; - y += 1; + x++; + y++; } - if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour; - else - myScreenBuffer[y * RENDERWIDE + x] = colour; + if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP) + buf[y * RENDERWIDE + x] = colour; } - } - else - { + } else { addTo = y0; y0 = 0; y1 -= addTo; @@ -558,39 +499,26 @@ int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) { incne = 2 * (dy - dx); x = x0; y = y0; - if ((x >= 0) && (x < RENDERWIDE) && (addTo - y >= 0) && (addTo - y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + (addTo - y) * ddsd.lPitch + x) = colour; - else - myScreenBuffer[(addTo - y) * RENDERWIDE + x] = colour; - while (x < x1) - { - if (d <= 0) - { + if (x >= 0 && x < RENDERWIDE && addTo - y >= 0 && addTo - y < RENDERDEEP) + buf[(addTo - y) * RENDERWIDE + x] = colour; + + while (x < x1) { + if (d <= 0) { d += ince; - x += 1; - } - else - { + x++; + } else { d += incne; - x += 1; - y += 1; + x++; + y++; } - if ((x >= 0) && (x < RENDERWIDE) && (addTo - y >= 0) && (addTo - y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + (addTo - y) * ddsd.lPitch + x) = colour; - else - myScreenBuffer[(addTo - y) * RENDERWIDE + x] = colour; + if (x >= 0 && x < RENDERWIDE && addTo - y >= 0 && addTo - y < RENDERDEEP) + buf[(addTo - y) * RENDERWIDE + x] = colour; } - } - } - else - { + } else { //OK, y is now going to be the single increment. // Ensure the line is going top to bottom - if (y1 < y0) - { + if (y1 < y0) { x = x1; x1 = x0; x0 = x; @@ -601,40 +529,28 @@ int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) { dx = x1 - x0; dy = y1 - y0; - if (dx > 0) - { + if (dx > 0) { d = 2 * dx - dy; ince = 2 * dx; incne = 2 * (dx - dy); x = x0; y = y0; - if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour; - else - myScreenBuffer[y * RENDERWIDE + x] = colour; - while (y < y1) - { - if (d <= 0) - { + if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP) + buf[y * RENDERWIDE + x] = colour; + + while (y < y1) { + if (d <= 0) { d += ince; - y += 1; - } - else - { + y++; + } else { d += incne; - x += 1; - y += 1; + x++; + y++; } - if ((x >= 0) && (x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + x) = colour; - else - myScreenBuffer[y * RENDERWIDE + x] = colour; + if (x >= 0 && x < RENDERWIDE && y >= 0 && y < RENDERDEEP) + buf[y * RENDERWIDE + x] = colour; } - } - else - { + } else { addTo = x0; x0 = 0; x1 -= addTo; @@ -646,41 +562,24 @@ int32 DrawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) { incne = 2 * (dx - dy); x = x0; y = y0; - if ((addTo - x >= 0) && (addTo - x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + addTo - x) = colour; - else - myScreenBuffer[y * RENDERWIDE + addTo - x] = colour; - while (y < y1) - { - if (d <= 0) - { + if (addTo - x >= 0 && addTo - x < RENDERWIDE && y >= 0 && y < RENDERDEEP) + buf[y * RENDERWIDE + addTo - x] = colour; + + while (y < y1) { + if (d <= 0) { d += ince; - y += 1; - } - else - { + y++; + } else { d += incne; - x += 1; - y += 1; + x++; + y++; } - if ((addTo - x >= 0) && (addTo - x < RENDERWIDE) && (y >= 0) && (y < RENDERDEEP)) - if (renderCaps & RDBLTFX_ALLHARDWARE) - *((uint8 *) ddsd.lpSurface + y * ddsd.lPitch + addTo - x) = colour; - else - myScreenBuffer[y * RENDERWIDE + addTo - x] = colour; + if (addTo - x >= 0 && addTo - x < RENDERWIDE && y >= 0 && y < RENDERDEEP) + buf[y * RENDERWIDE + addTo - x] = colour; } - } - } - if (renderCaps & RDBLTFX_ALLHARDWARE) - { - (uint8 *) ddsd.lpSurface -= (40 * ddsd.lPitch); - IDirectDrawSurface2_Unlock(lpBackBuffer, ddsd.lpSurface); - } -*/ return RD_OK; } @@ -796,7 +695,7 @@ int32 EndRenderCycle(bool *end) { startTime = time; renderAverageTime = (renderTimeLog[0] + renderTimeLog[1] + renderTimeLog[2] + renderTimeLog[3]) >> 2; - framesPerGameCycle += 1; + framesPerGameCycle++; if (++renderCountIndex == RENDERAVERAGETOTAL) renderCountIndex = 0; @@ -870,8 +769,6 @@ int32 InitialiseBackgroundLayer(_parallax *p) { // This function is called to re-initialise the layers if they have // been lost. We know this if the layers have already been assigned. - // TODO: Can layers still be lost, or is that a DirectDraw-ism? - if (layer == MAXLAYERS) CloseBackgroundLayer(); |