From 8bcc7bcd47d7043cf5fd9f3ec10e594369576338 Mon Sep 17 00:00:00 2001 From: ghaushe Date: Tue, 24 Dec 2002 00:23:54 +0000 Subject: [PATCH] Replaced add_sub_frame with arith_frame_blit -PhracturedBlue git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@478 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + .../sc2code/libs/graphics/sdl/3do_getbody.c | 44 +++++++++++-------- sc2/src/sc2code/libs/graphics/sdl/rndzoom.c | 2 +- sc2/src/sc2code/planets/pl_stuff.c | 8 ++-- sc2/src/sc2code/planets/plangen.c | 14 +++--- sc2/src/sc2code/planets/scan.c | 6 ++- 6 files changed, 44 insertions(+), 31 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 552f626a4..ff56c09f1 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ 0.2: +- Replaced add_sub_frame with arith_frame_blit -PhracturedBlue - Crosshair in orbit leaving light trace to image in OpenGL mode fixed -Mika - Planet scan should now take ~2secs on all computers -PhracturedBlue - Updated earth image to look nicer (no vertical lines) -PhracturedBlue diff --git a/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c b/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c index 10ae9b4d2..894d85ed1 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c +++ b/sc2/src/sc2code/libs/graphics/sdl/3do_getbody.c @@ -209,7 +209,8 @@ void fill_frame_rgb (FRAMEPTR FramePtr, Uint32 color, int x0, int y0, int x, int SDL_UnlockSurface (img); UnlockMutex (tfbImg->mutex); } -void add_sub_frame (FRAMEPTR srcFrame, RECT *rsrc, FRAMEPTR dstFrame, RECT *rdst, int add_sub) + +void arith_frame_blit (FRAMEPTR srcFrame, RECT *rsrc, FRAMEPTR dstFrame, RECT *rdst, int num,int denom) { int add = 0, sub = 0; TFB_Image *srcImg, *dstImg; @@ -221,14 +222,6 @@ void add_sub_frame (FRAMEPTR srcFrame, RECT *rsrc, FRAMEPTR dstFrame, RECT *rdst LockMutex (dstImg->mutex); src = srcImg->NormalImg; dst = dstImg->NormalImg; - if (rsrc) - { - srcRect.x = rsrc->corner.x; - srcRect.y = rsrc->corner.y; - srcRect.w = rsrc->extent.width; - srcRect.h = rsrc->extent.height; - srp = &srcRect; - } if (rdst) { dstRect.x = rdst->corner.x; @@ -237,17 +230,32 @@ void add_sub_frame (FRAMEPTR srcFrame, RECT *rsrc, FRAMEPTR dstFrame, RECT *rdst dstRect.h = rdst->extent.height; drp = &dstRect; } - if (add_sub > 0) + if (rsrc) { - add = -1; - sub = 1; - } - else if (add_sub < 0) - { - add = 1; - sub = -1; + srcRect.x = rsrc->corner.x; + srcRect.y = rsrc->corner.y; + srcRect.w = rsrc->extent.width; + srcRect.h = rsrc->extent.height; + srp = &srcRect; } - TFB_BlitSurface (src, srp, dst, drp, sub, add); + else if (GetFrameHotX (srcFrame) || GetFrameHotY (srcFrame)) + { + if (rdst) + { + dstRect.x -= GetFrameHotX (srcFrame); + dstRect.y -= GetFrameHotY (srcFrame); + } + else + { + dstRect.x = -GetFrameHotX (srcFrame); + dstRect.y = -GetFrameHotY (srcFrame); + dstRect.w = GetFrameWidth (srcFrame); + dstRect.h = GetFrameHeight (srcFrame); + drp =&dstRect; + } + + } + TFB_BlitSurface (src, srp, dst, drp, num, denom); UnlockMutex (srcImg->mutex); UnlockMutex (dstImg->mutex); } diff --git a/sc2/src/sc2code/libs/graphics/sdl/rndzoom.c b/sc2/src/sc2code/libs/graphics/sdl/rndzoom.c index 33a076e7e..892abd34e 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/rndzoom.c +++ b/sc2/src/sc2code/libs/graphics/sdl/rndzoom.c @@ -558,7 +558,7 @@ SDL_Surface *random16xZoomSurfaceRGBA (SDL_Surface *src) return (dst); } -void buildLanderView (FRAMEPTR FramePtr) +void scale16xRandomizeFrame (FRAMEPTR FramePtr) { TFB_Image *tfbImg; diff --git a/sc2/src/sc2code/planets/pl_stuff.c b/sc2/src/sc2code/planets/pl_stuff.c index 696dc60ff..b36ed50aa 100644 --- a/sc2/src/sc2code/planets/pl_stuff.c +++ b/sc2/src/sc2code/planets/pl_stuff.c @@ -33,7 +33,7 @@ void process_rgb_bmp (FRAME FramePtr, DWORD *rgba, int maxx, int maxy); void fill_frame_rgb (FRAMEPTR FramePtr, DWORD color, int x0, int y0, int x, int y); -void add_sub_frame (FRAMEPTR srcFrame, RECT *rsrc, FRAMEPTR dstFrame, RECT *rdst, int add_sub); +void arith_frame_blit (FRAMEPTR srcFrame, RECT *rsrc, FRAMEPTR dstFrame, RECT *rdst, int num, int denom); extern FRAME stretch_frame (FRAME FramePtr, int neww, int newh,int destroy); @@ -174,7 +174,7 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb) { pSolarSysState->Tint_rgb=rgb; // Buffer the topoMap to the tintFrame; - add_sub_frame (s.frame, NULL, tintFrame[0], NULL, 0); + arith_frame_blit (s.frame, NULL, tintFrame[0], NULL, 0, 0); r = (rgb & (0x1f << 10)) >> 8; g = (rgb & (0x1f << 5)) >> 3; b = (rgb & 0x1f) << 2; @@ -207,9 +207,9 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb) if (dy <= frameh) { #ifdef USE_ADDITIVE_SCAN_BLIT - add_sub_frame (tintFrame[1], psrect, tintFrame[0], pdrect, 1); + arith_frame_blit (tintFrame[1], psrect, tintFrame[0], pdrect, 0, -1); #else - add_sub_frame (tintFrame[1], psrect, tintFrame[0], pdrect, 0); + arith_frame_blit (tintFrame[1], psrect, tintFrame[0], pdrect, 0, 0); #endif } s.frame = tintFrame[0]; diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index 393d54f04..704f80d89 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -47,9 +47,9 @@ FRAME stretch_frame (FRAME FramePtr, int neww, int newh,int destroy); void fill_frame_rgb (FRAME FramePtr, DWORD color, int x0, int y0, int x, int y); -void add_sub_frame (FRAME srcFrame, RECT *rsrc, FRAME dstFrame, RECT *rdst, int add_sub); +void arith_frame_blit (FRAME srcFrame, RECT *rsrc, FRAME dstFrame, RECT *rdst, int num, int denom); -void buildLanderView(FRAME FramePtr); +void scale16xRandomizeFrame(FRAME FramePtr); DWORD **getpixelarray(FRAME FramePtr,int width, int height); @@ -540,18 +540,20 @@ static void CreateShieldMask () pSolarSysState->ShieldFrame = ShieldFrame; { // Applythe shield to the topo data - UBYTE a, blit_type; + UBYTE a; + int blit_type; FRAME tintFrame = pSolarSysState->TintFrame; #ifdef USE_ALPHA_SHIELD a = 200; blit_type = 0; #else + //additive_blit a = 255; - blit_type = 1; + blit_type = -1; #endif p = frame_mapRGBA (tintFrame, 255, 0, 0, a); fill_frame_rgb (tintFrame, p, 0, 0, 0, 0); - add_sub_frame (tintFrame, NULL, pSolarSysState->TopoFrame, NULL, blit_type); + arith_frame_blit (tintFrame, NULL, pSolarSysState->TopoFrame, NULL, 0, blit_type); } } @@ -1300,7 +1302,7 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth) // from lpTopoData instead of the FRAMPTR though x = MAP_WIDTH + MAP_HEIGHT; y = MAP_HEIGHT; - buildLanderView(pSolarSysState->TopoFrame); + scale16xRandomizeFrame(pSolarSysState->TopoFrame); pSolarSysState->lpTopoMap = getpixelarray ( pSolarSysState->TopoFrame, x, y ); diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 6a47f2a20..e9a3d2b31 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -847,6 +847,7 @@ DoScan (INPUT_STATE InputState, PMENU_STATE PressState = AnyButtonPress (TRUE); WaitTime = (ONE_SECOND << 1) / MAP_HEIGHT; + SetSemaphore (GraphicsSem); TimeIn = GetTimeCounter (); for (i = 0; i < MAP_HEIGHT + NUM_FLASH_COLORS + 1; i++) { @@ -858,7 +859,7 @@ DoScan (INPUT_STATE InputState, PMENU_STATE } if (ButtonState) i = -i; - SetSemaphore (GraphicsSem); +// SetSemaphore (GraphicsSem); BatchGraphics (); DrawPlanet (0, 0, i, rgb); if (i < 0) @@ -866,11 +867,12 @@ DoScan (INPUT_STATE InputState, PMENU_STATE if (pMS->delta_item) DrawScannedStuff (i, min_scan); UnbatchGraphics (); - ClearSemaphore (GraphicsSem); +// ClearSemaphore (GraphicsSem); // FlushGraphics (); SleepThreadUntil (TimeIn + WaitTime); TimeIn = GetTimeCounter (); } + ClearSemaphore (GraphicsSem); pSolarSysState->Tint_rgb = 0; }