Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,12 +1514,6 @@ UINT32 InitializeJA2(void)
// INit intensity tables
BuildIntensityTable( );

// Init Event Manager
if ( !InitializeEventManager( ) )
{
return( ERROR_SCREEN );
}

// Initailize World
if ( !InitializeWorld( ) )
{
Expand Down Expand Up @@ -1698,8 +1692,6 @@ void ShutdownJA2(void)

ShutdownJA2Sound( );

ShutdownEventManager( );

ShutdownBaseDirtyRectQueue( );

// Unload any text box images!
Expand Down
1 change: 0 additions & 1 deletion Standard Gaming Platform/vobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@



HLIST ghVideoObjects = NULL;
BOOLEAN gfVideoObjectsInit=FALSE;

#ifndef SGP_VIDEO_DEBUGGING
Expand Down
1 change: 0 additions & 1 deletion Standard Gaming Platform/vobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ BOOLEAN GetETRLEPixelValue( UINT8 * pDest, HVOBJECT hVObject, UINT16 usETLREInde
// Globals
//
// ****************************************************************************
extern HLIST ghVideoObjects;

// ****************************************************************************
//
Expand Down
74 changes: 19 additions & 55 deletions Standard Gaming Platform/vsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,13 @@ void CheckValidVSurfaceIndex( UINT32 uiIndex );

INT32 giMemUsedInSurfaces;


//OBSOLETE!!!!!!!!!
HLIST ghVideoSurfaces = NULL;
//OBSOLETE!!!!!!!!!


HVSURFACE ghPrimary = NULL;
HVSURFACE ghBackBuffer = NULL;
HVSURFACE ghFrameBuffer = NULL;
HVSURFACE ghMouseBuffer = NULL;

#include <map>
#include <vector>

extern std::map<UINT32,ClipRectangle> g_SurfaceRectangle;

Expand Down Expand Up @@ -1161,11 +1156,7 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc )
//
// Allocate memory for Video Surface data and initialize
//

hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) );
memset( hVSurface, 0, sizeof( SGPVSurface ) );
CHECKF( hVSurface != NULL );

hVSurface = new SGPVSurface{};
hVSurface->usHeight = usHeight;
hVSurface->usWidth = usWidth;
// BF : since we use a 16bpp framebuffer and images are converted to that format,
Expand All @@ -1178,7 +1169,6 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc )
hVSurface->pPalette = NULL;
hVSurface->p16BPPPalette = NULL;
hVSurface->TransparentColor = FROMRGB( 0, 0, 0 );
hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) );
hVSurface->fFlags = 0;
hVSurface->pClipper = NULL;

Expand Down Expand Up @@ -1647,12 +1637,6 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
hVSurface->pPalette = NULL;
}

//if ( hVSurface->pClipper != NULL )
//{
// Release Clipper
// DDReleaseClipper( (LPDIRECTDRAWCLIPPER)hVSurface->pClipper );
//}

// Get surface pointer
lpDDSurface = (LPDIRECTDRAWSURFACE2)hVSurface->pSurfaceData;

Expand All @@ -1670,7 +1654,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
}

// Release region data
DeleteList( hVSurface->RegionList );
hVSurface->RegionList.clear();

//If there is a 16bpp palette, free it
if( hVSurface->p16BPPPalette != NULL )
Expand All @@ -1682,8 +1666,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
giMemUsedInSurfaces -= ( hVSurface->usHeight * hVSurface->usWidth * ( hVSurface->ubBitDepth / 8 ) );

// Release object
MemFree( hVSurface );

delete hVSurface;
return( TRUE );
}

Expand Down Expand Up @@ -1768,7 +1751,7 @@ BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions )
{
Assert( hVSurface );

*puiNumRegions = ListSize( hVSurface->RegionList );
*puiNumRegions = hVSurface->RegionList.size();

return( TRUE );

Expand All @@ -1780,7 +1763,7 @@ BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion )
Assert( pNewRegion != NULL );

// Add new region to list
hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, ListSize( hVSurface->RegionList ) );
hVSurface->RegionList.push_back(*pNewRegion);

return( TRUE );
}
Expand All @@ -1801,41 +1784,23 @@ BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions,
return( TRUE );
}

BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex )
{
VSURFACE_REGION aRegion;

Assert( hVSurface != NULL );

return( RemfromList( hVSurface->RegionList, &aRegion, usIndex ) );

}

BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface )
{
UINT32 uiListSize;

Assert( hVSurface != NULL );

uiListSize = ListSize( hVSurface->RegionList );

for ( INT32 cnt = uiListSize - 1; cnt >= 0; cnt-- )
{
RemoveVSurfaceRegion( hVSurface, (UINT16)cnt );
}

hVSurface->RegionList.clear();
return( TRUE );
}

BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *aRegion )
{
Assert( hVSurface != NULL );

if ( !PeekList( hVSurface->RegionList, aRegion, usIndex ) )
if (usIndex >= hVSurface->RegionList.size())
{
return( FALSE );
}

*aRegion = hVSurface->RegionList[usIndex];
return( TRUE );
}

Expand All @@ -1858,15 +1823,12 @@ BOOLEAN ReplaceVSurfaceRegion( HVSURFACE hVSurface , UINT16 usIndex, VSURFACE_RE

Assert( hVSurface != NULL );

// Validate index given
if ( !PeekList( hVSurface->RegionList, &OldRegion, usIndex ) )
if (usIndex >= hVSurface->RegionList.size())
{
return( FALSE );
}

// Replace information
hVSurface->RegionList = AddtoList( hVSurface->RegionList, aRegion, usIndex );

hVSurface->RegionList[usIndex] = *aRegion;
return( TRUE );
}

Expand All @@ -1875,11 +1837,14 @@ BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_
Assert( hVSurface != NULL );
Assert( pNewRegion != NULL );

// Add new region to list
hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, usIndex );

return( TRUE );
if (usIndex >= hVSurface->RegionList.size())
{
return(FALSE);
}

auto pos = hVSurface->RegionList.begin() + usIndex;
hVSurface->RegionList.insert(pos, *pNewRegion);
return(TRUE);
}

// *******************************************************************
Expand Down Expand Up @@ -2161,7 +2126,7 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface )


// Allocate Video Surface struct
hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) );
hVSurface = new SGPVSurface{};

// Set values based on DD Surface given
DDGetSurfaceDescription ( lpDDSurface, &DDSurfaceDesc );
Expand All @@ -2173,7 +2138,6 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface )
hVSurface->pSurfaceData = (PTR)lpDDSurface;
hVSurface->pSurfaceData1 = NULL;
hVSurface->pSavedSurfaceData = NULL;
hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) );
hVSurface->fFlags = 0;

// Get and Set palette, if attached, allow to fail
Expand Down
6 changes: 3 additions & 3 deletions Standard Gaming Platform/vsurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "container.h"
#include "himage.h"
#include "vobject.h"
#include <vector>

///////////////////////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -105,7 +106,7 @@ typedef struct
UINT16 *p16BPPPalette; // A 16BPP palette used for 8->16 blits
COLORVAL TransparentColor; // Defaults to 0,0,0
PTR pClipper; // A void pointer encapsolated as a clipper Surface
HLIST RegionList; // A List of regions within the video Surface
std::vector<VSURFACE_REGION> RegionList; // A List of regions within the video Surface

} SGPVSurface, *HVSURFACE;

Expand Down Expand Up @@ -240,7 +241,6 @@ BOOLEAN DeleteVideoSurfaceFromIndex( UINT32 uiIndex );
BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion );
BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion );
BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions, UINT16 uiNumRegions );
BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex );
BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface );
BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *aRegion );
BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions );
Expand Down Expand Up @@ -286,4 +286,4 @@ BOOLEAN ShadowVideoSurfaceRectUsingLowPercentTable( UINT32 uiDestVSurface, INT32
#endif
*/

#endif
#endif
Loading