From c7aa14badbfdda80ea45e68d13cd1f1c2bac2667 Mon Sep 17 00:00:00 2001 From: gewlitys Date: Wed, 11 Dec 2002 02:13:19 +0000 Subject: [PATCH] PhracturedBlue's scan fixes git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@404 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/planets/pl_stuff.c | 58 ++++++++++++++++++++---------- sc2/src/sc2code/planets/planets.c | 8 ++--- sc2/src/sc2code/planets/planets.h | 2 +- sc2/src/sc2code/planets/plangen.c | 9 ++--- sc2/src/sc2code/planets/scan.c | 8 +++-- 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/sc2/src/sc2code/planets/pl_stuff.c b/sc2/src/sc2code/planets/pl_stuff.c index 5ef87f207..aedf9d383 100644 --- a/sc2/src/sc2code/planets/pl_stuff.c +++ b/sc2/src/sc2code/planets/pl_stuff.c @@ -148,38 +148,58 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb) { UBYTE r, g, b; DWORD p; - COUNT framew; - RECT drect; - FRAME tintFrame = pSolarSysState->TintFrame[0]; - FRAME tintLine = pSolarSysState->TintFrame[1]; + COUNT framew, frameh; + RECT srect, drect, *psrect = NULL, *pdrect = NULL; + FRAME tintFrame[2]; + tintFrame[0] = SetAbsFrameIndex (pSolarSysState->TintFrame, (COUNT)(1)); + tintFrame[1] = SetAbsFrameIndex (pSolarSysState->TintFrame, (COUNT)(2)); + + framew = GetFrameWidth (tintFrame[0]); + frameh = GetFrameHeight (tintFrame[0]); + if (rgb != pSolarSysState->Tint_rgb) - { + { pSolarSysState->Tint_rgb=rgb; // Buffer the topoMap to the tintFrame; - add_sub_frame (s.frame, NULL, tintFrame, NULL, 0); + add_sub_frame (s.frame, NULL, tintFrame[0], NULL, 0); r = (rgb & (0x1f << 10)) >> 8; g = (rgb & (0x1f << 5)) >> 3; b = (rgb & 0x1f) << 2; #ifdef USE_ADDITIVE_SCAN_BLIT a = 255; #endif - p = frame_mapRGBA (tintFrame, r, g, b, a); - fill_frame_rgb (tintLine, p, 0, 0, 0, 0); + p = frame_mapRGBA (tintFrame[1], r, g, b, a); + fill_frame_rgb (tintFrame[1], p, 0, 0, 0, 0); } - framew = GetFrameWidth (tintFrame); drect.corner.x = 0; - drect.corner.y = dy; drect.extent.width = framew; - drect.extent.height = 1; -#ifdef USE_ADDITIVE_SCAN_BLIT - add_sub_frame (tintLine, NULL, tintFrame, &drect, 1); -#else - add_sub_frame (tintLine, NULL, tintFrame, &drect, 0); -#endif - if (GetFrameHeight (tintFrame) == dy) - pSolarSysState->Tint_rgb = 0; + srect.corner.x = 0; + srect.corner.y = 0; + srect.extent.width = framew; + if (dy >= 0 && dy <= frameh) { + drect.corner.y = dy; + drect.extent.height = 1; + pdrect = &drect; + srect.extent.height = 1; + psrect = &srect; + } + if (dy < 0) { + drect.corner.y = -dy; + drect.extent.height = frameh + dy; + pdrect = &drect; + srect.extent.height = frameh + dy; + psrect = &srect; + } - s.frame = tintFrame; + if (dy <= frameh) { + +#ifdef USE_ADDITIVE_SCAN_BLIT + add_sub_frame (tintFrame[1], psrect, tintFrame[0], pdrect, 1); +#else + add_sub_frame (tintFrame[1], psrect, tintFrame[0], pdrect, 0); +#endif + } + s.frame = tintFrame[0]; DrawStamp (&s); } UnbatchGraphics (); diff --git a/sc2/src/sc2code/planets/planets.c b/sc2/src/sc2code/planets/planets.c index 928e4e672..26c7bc3a1 100644 --- a/sc2/src/sc2code/planets/planets.c +++ b/sc2/src/sc2code/planets/planets.c @@ -231,12 +231,10 @@ FreePlanet (void) DestroyDrawable (ReleaseDrawable (pSolarSysState->ScaleFrame[i])); pSolarSysState->ScaleFrame[i]=0; } - if (pSolarSysState->TintFrame[i]) - { - DestroyDrawable (ReleaseDrawable (pSolarSysState->TintFrame[i])); - pSolarSysState->TintFrame[i] = 0; - } } + if (pSolarSysState->TintFrame) + DestroyDrawable (ReleaseDrawable (pSolarSysState->TintFrame)); + pSolarSysState->TintFrame = 0; pSolarSysState->Tint_rgb = 0; if(pSolarSysState->ShieldFrame != 0) { diff --git a/sc2/src/sc2code/planets/planets.h b/sc2/src/sc2code/planets/planets.h index 5082d38de..5093cd8e7 100644 --- a/sc2/src/sc2code/planets/planets.h +++ b/sc2/src/sc2code/planets/planets.h @@ -169,7 +169,7 @@ typedef struct solarsys_state BYTE *isPFADefined; FRAME ScaleFrame[2]; FRAME ShieldFrame; - FRAME TintFrame[2]; + FRAME TintFrame; UWORD Tint_rgb; DWORD **lpTopoMap; UBYTE PauseRotate; diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index 29e690ee8..37404c459 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -479,7 +479,7 @@ static void CreateShieldMask () { // Applythe shield to the topo data UBYTE a, blit_type; - FRAME tintFrame = pSolarSysState->TintFrame[0]; + FRAME tintFrame = pSolarSysState->TintFrame; #ifdef USE_ALPHA_SHIELD a = 200; blit_type = 0; @@ -1111,11 +1111,8 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, BOOLEAN IsEarth) OldContext = SetContext (TaskContext); pSolarSysState->isPFADefined = (BYTE *)HCalloc (sizeof(BYTE) * 255); - pSolarSysState->TintFrame[0] = CaptureDrawable ( - CreateDrawable (WANT_PIXMAP, (SWORD)MAP_WIDTH, (SWORD)MAP_HEIGHT, 1) - ); - pSolarSysState->TintFrame[1] = CaptureDrawable ( - CreateDrawable (WANT_PIXMAP, (SWORD)MAP_WIDTH, (SWORD)1, 1) + pSolarSysState->TintFrame = CaptureDrawable ( + CreateDrawable (WANT_PIXMAP, (SWORD)MAP_WIDTH, (SWORD)MAP_HEIGHT, 2) ); pSolarSysState->PlanetFrameArray = CaptureDrawable ( diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 491c8f491..0bece42f8 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -777,7 +777,7 @@ DoScan (INPUT_STATE InputState, PMENU_STATE do { TEXT t; - COUNT i; + SWORD i; t.baseline.x = SIS_SCREEN_WIDTH >> 1; t.baseline.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7; @@ -855,10 +855,12 @@ DoScan (INPUT_STATE InputState, PMENU_STATE ButtonState = 0; } if (ButtonState) - i = MAP_HEIGHT + NUM_FLASH_COLORS; + i = -i; SetSemaphore (GraphicsSem); BatchGraphics (); DrawPlanet (0, 0, i, rgb); + if (i < 0) + i = MAP_HEIGHT + NUM_FLASH_COLORS; if (pMS->delta_item) DrawScannedStuff (i, min_scan); UnbatchGraphics (); @@ -866,6 +868,8 @@ DoScan (INPUT_STATE InputState, PMENU_STATE // FlushGraphics (); SleepThread (2); } + pSolarSysState->Tint_rgb = 0; + } } while (++min_scan <= max_scan);