First steps towards consistent use of HMalloc.
DRAWABLE, FONT, and a few others which mix memory handles with flags still remain; this patch catches the low-hanging fruit. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2890 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -51,7 +51,7 @@ FreeKernel (void)
|
|||||||
UninitPlayerInput ();
|
UninitPlayerInput ();
|
||||||
|
|
||||||
DestroyDrawable (ReleaseDrawable (Screen));
|
DestroyDrawable (ReleaseDrawable (Screen));
|
||||||
DestroyContext (ReleaseContext (ScreenContext));
|
DestroyContext (ScreenContext);
|
||||||
|
|
||||||
UninitVideoPlayer ();
|
UninitVideoPlayer ();
|
||||||
UninitSound ();
|
UninitSound ();
|
||||||
@@ -63,9 +63,9 @@ UninitContexts (void)
|
|||||||
{
|
{
|
||||||
UninitQueue (&disp_q);
|
UninitQueue (&disp_q);
|
||||||
|
|
||||||
DestroyContext (ReleaseContext (OffScreenContext));
|
DestroyContext (OffScreenContext);
|
||||||
DestroyContext (ReleaseContext (SpaceContext));
|
DestroyContext (SpaceContext);
|
||||||
DestroyContext (ReleaseContext (StatusContext));
|
DestroyContext (StatusContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -1238,7 +1238,7 @@ DoCommunication (ENCOUNTER_STATE *pES)
|
|||||||
CommData.AlienTransitionDesc.AnimFlags &= ~(TALK_INTRO | TALK_DONE);
|
CommData.AlienTransitionDesc.AnimFlags &= ~(TALK_INTRO | TALK_DONE);
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
SetContext (SpaceContext);
|
||||||
DestroyContext (ReleaseContext (TaskContext));
|
DestroyContext (TaskContext);
|
||||||
TaskContext = 0;
|
TaskContext = 0;
|
||||||
|
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
@@ -1333,7 +1333,7 @@ HailAlien (void)
|
|||||||
SubtitleText.align = CommData.AlienTextAlign;
|
SubtitleText.align = CommData.AlienTextAlign;
|
||||||
|
|
||||||
// init subtitle cache context
|
// init subtitle cache context
|
||||||
TextCacheContext = CaptureContext (CreateContext ());
|
TextCacheContext = CreateContext ();
|
||||||
TextCacheFrame = CaptureDrawable (
|
TextCacheFrame = CaptureDrawable (
|
||||||
CreateDrawable (WANT_PIXMAP, SIS_SCREEN_WIDTH,
|
CreateDrawable (WANT_PIXMAP, SIS_SCREEN_WIDTH,
|
||||||
SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT + 2, 1));
|
SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT + 2, 1));
|
||||||
@@ -1354,7 +1354,7 @@ HailAlien (void)
|
|||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
TaskContext = CaptureContext (CreateContext ());
|
TaskContext = CreateContext ();
|
||||||
SetContext (TaskContext);
|
SetContext (TaskContext);
|
||||||
SetContextFGFrame (Screen);
|
SetContextFGFrame (Screen);
|
||||||
GetFrameRect (CommData.AlienFrame, &r);
|
GetFrameRect (CommData.AlienFrame, &r);
|
||||||
@@ -1420,7 +1420,7 @@ HailAlien (void)
|
|||||||
DestroyFont (ReleaseFont (CommData.AlienFont));
|
DestroyFont (ReleaseFont (CommData.AlienFont));
|
||||||
DestroyDrawable (ReleaseDrawable (CommData.AlienFrame));
|
DestroyDrawable (ReleaseDrawable (CommData.AlienFrame));
|
||||||
|
|
||||||
DestroyContext (ReleaseContext (TextCacheContext));
|
DestroyContext (TextCacheContext);
|
||||||
DestroyDrawable (ReleaseDrawable (TextCacheFrame));
|
DestroyDrawable (ReleaseDrawable (TextCacheFrame));
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
SetContext (SpaceContext);
|
||||||
|
|||||||
@@ -314,8 +314,8 @@ credit_roll_task (void *data)
|
|||||||
TextBack = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00);
|
TextBack = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00);
|
||||||
TextFore = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F);
|
TextFore = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F);
|
||||||
|
|
||||||
LocalContext = CaptureContext (CreateContext ());
|
LocalContext = CreateContext ();
|
||||||
DrawContext = CaptureContext (CreateContext ());
|
DrawContext = CreateContext ();
|
||||||
|
|
||||||
total_h = disp_h = SCREEN_HEIGHT;
|
total_h = disp_h = SCREEN_HEIGHT;
|
||||||
|
|
||||||
@@ -530,8 +530,8 @@ credit_roll_task (void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyContext (ReleaseContext (DrawContext));
|
DestroyContext (DrawContext);
|
||||||
DestroyContext (ReleaseContext (LocalContext));
|
DestroyContext (LocalContext);
|
||||||
|
|
||||||
// free remaining frames
|
// free remaining frames
|
||||||
DestroyDrawable (ReleaseDrawable (Frame));
|
DestroyDrawable (ReleaseDrawable (Frame));
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
#include "displist.h"
|
#include "displist.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
#ifdef QUEUE_TABLE
|
||||||
|
#define NULL_HANDLE NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains code for generic doubly linked lists.
|
* This file contains code for generic doubly linked lists.
|
||||||
* If QUEUE_TABLE is defined, each lists has its own preallocated
|
* If QUEUE_TABLE is defined, each lists has its own preallocated
|
||||||
@@ -40,7 +44,7 @@ InitQueue (QUEUE *pq, COUNT num_elements, OBJ_SIZE size)
|
|||||||
log_add (log_Debug, "InitQueue(): num_elements = %d (%d)",
|
log_add (log_Debug, "InitQueue(): num_elements = %d (%d)",
|
||||||
num_elements, (BYTE)num_elements);
|
num_elements, (BYTE)num_elements);
|
||||||
#endif
|
#endif
|
||||||
if (AllocQueueTab (pq, num_elements) && LockQueueTab (pq))
|
if (AllocQueueTab (pq, num_elements) != NULL)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
FreeLink (pq, GetLinkAddr (pq, num_elements));
|
FreeLink (pq, GetLinkAddr (pq, num_elements));
|
||||||
@@ -60,7 +64,6 @@ UninitQueue (QUEUE *pq)
|
|||||||
SetHeadLink (pq, NULL_HANDLE);
|
SetHeadLink (pq, NULL_HANDLE);
|
||||||
SetTailLink (pq, NULL_HANDLE);
|
SetTailLink (pq, NULL_HANDLE);
|
||||||
SetFreeList (pq, NULL_HANDLE);
|
SetFreeList (pq, NULL_HANDLE);
|
||||||
UnlockQueueTab (pq);
|
|
||||||
FreeQueueTab (pq);
|
FreeQueueTab (pq);
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
#define _DISPLIST_H
|
#define _DISPLIST_H
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "libs/memlib.h"
|
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
#include "compiler.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
// Note that we MUST use the QUEUE_TABLE variant at this time, because
|
// Note that we MUST use the QUEUE_TABLE variant at this time, because
|
||||||
// certain gameplay elements depend on it. Namely, the maximum number
|
// certain gameplay elements depend on it. Namely, the maximum number
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
#ifdef QUEUE_TABLE
|
#ifdef QUEUE_TABLE
|
||||||
typedef void* QUEUE_HANDLE;
|
typedef void* QUEUE_HANDLE;
|
||||||
#else /* !QUEUE_TABLE */
|
#else /* !QUEUE_TABLE */
|
||||||
|
#include "libs/memlib.h"
|
||||||
typedef MEM_HANDLE QUEUE_HANDLE;
|
typedef MEM_HANDLE QUEUE_HANDLE;
|
||||||
#endif /* QUEUE_TABLE */
|
#endif /* QUEUE_TABLE */
|
||||||
|
|
||||||
@@ -55,7 +57,6 @@ typedef struct /* queue */
|
|||||||
#ifdef QUEUE_TABLE
|
#ifdef QUEUE_TABLE
|
||||||
BYTE *pq_tab;
|
BYTE *pq_tab;
|
||||||
HLINK free_list;
|
HLINK free_list;
|
||||||
MEM_HANDLE hq_tab;
|
|
||||||
#endif
|
#endif
|
||||||
COUNT object_size;
|
COUNT object_size;
|
||||||
#ifdef QUEUE_TABLE
|
#ifdef QUEUE_TABLE
|
||||||
@@ -89,16 +90,13 @@ UnlockLink (const QUEUE *pq, HLINK h)
|
|||||||
#define GetFreeList(pq) (pq)->free_list
|
#define GetFreeList(pq) (pq)->free_list
|
||||||
#define SetFreeList(pq, h) (pq)->free_list = (h)
|
#define SetFreeList(pq, h) (pq)->free_list = (h)
|
||||||
#define AllocQueueTab(pq,n) \
|
#define AllocQueueTab(pq,n) \
|
||||||
((pq)->hq_tab = mem_allocate ((MEM_SIZE)((COUNT)(pq)->object_size * \
|
((pq)->pq_tab = HMalloc (((COUNT)(pq)->object_size * \
|
||||||
(COUNT)((pq)->num_objects = (BYTE)(n))), \
|
(COUNT)((pq)->num_objects = (BYTE)(n)))))
|
||||||
MEM_PRIMARY))
|
#define FreeQueueTab(pq) HFree ((pq)->pq_tab); (pq)->pq_tab = NULL
|
||||||
#define LockQueueTab(pq) ((pq)->pq_tab = (BYTE*)mem_lock ((pq)->hq_tab))
|
|
||||||
#define UnlockQueueTab(pq) mem_unlock ((pq)->hq_tab)
|
|
||||||
#define FreeQueueTab(pq) mem_release ((pq)->hq_tab); (pq)->hq_tab = 0
|
|
||||||
#define SizeQueueTab(pq) (COUNT)((pq)->num_objects)
|
#define SizeQueueTab(pq) (COUNT)((pq)->num_objects)
|
||||||
#define GetLinkAddr(pq,i) (HLINK)((pq)->pq_tab + ((pq)->object_size * ((i) - 1)))
|
#define GetLinkAddr(pq,i) (HLINK)((pq)->pq_tab + ((pq)->object_size * ((i) - 1)))
|
||||||
#else /* !QUEUE_TABLE */
|
#else /* !QUEUE_TABLE */
|
||||||
#define AllocLink(pq) (HLINK)mem_request ((pq)->object_size)
|
#define AllocLink(pq) (HLINK)mem_allocate ((pq)->object_size, DEFAULT_MEM_FLAGS)
|
||||||
#define LockLink(pq, h) (LINK*)mem_lock (h)
|
#define LockLink(pq, h) (LINK*)mem_lock (h)
|
||||||
#define UnlockLink(pq, h) mem_unlock (h)
|
#define UnlockLink(pq, h) mem_unlock (h)
|
||||||
#define FreeLink(pq,h) mem_release (h)
|
#define FreeLink(pq,h) mem_release (h)
|
||||||
|
|||||||
+1
-12
@@ -84,7 +84,7 @@ enum
|
|||||||
MEM_HANDLE hData;
|
MEM_HANDLE hData;
|
||||||
|
|
||||||
which_res = GetResFileChar (fp);
|
which_res = GetResFileChar (fp);
|
||||||
hData = mem_request (sizeof (CODERES_STRUCT));
|
hData = mem_allocate (sizeof (CODERES_STRUCT), DEFAULT_MEM_FLAGS);
|
||||||
if (hData)
|
if (hData)
|
||||||
{
|
{
|
||||||
RACE_DESC *RDPtr;
|
RACE_DESC *RDPtr;
|
||||||
@@ -374,14 +374,3 @@ ReleaseCodeRes (void *CodeRef)
|
|||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DRAWABLE
|
|
||||||
CreatePixmapRegion (FRAME Frame, POINT *lpOrg, SIZE width, SIZE height)
|
|
||||||
{
|
|
||||||
(void) lpOrg; /* Satisfying compiler (unused parameter) */
|
|
||||||
(void) width; /* Satisfying compiler (unused parameter) */
|
|
||||||
(void) height; /* Satisfying compiler (unused parameter) */
|
|
||||||
return (GetFrameHandle (Frame));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ CreateRadar (void)
|
|||||||
RECT r;
|
RECT r;
|
||||||
CONTEXT OldContext;
|
CONTEXT OldContext;
|
||||||
|
|
||||||
RadarContext = CaptureContext (CreateContext ());
|
RadarContext = CreateContext ();
|
||||||
OldContext = SetContext (RadarContext);
|
OldContext = SetContext (RadarContext);
|
||||||
SetContextFGFrame (Screen);
|
SetContextFGFrame (Screen);
|
||||||
r.corner.x = RADAR_X;
|
r.corner.x = RADAR_X;
|
||||||
@@ -372,7 +372,7 @@ InitSIS (void)
|
|||||||
void
|
void
|
||||||
FreeSC2Data (void)
|
FreeSC2Data (void)
|
||||||
{
|
{
|
||||||
DestroyContext (ReleaseContext (RadarContext));
|
DestroyContext (RadarContext);
|
||||||
RadarContext = 0;
|
RadarContext = 0;
|
||||||
DestroyDrawable (ReleaseDrawable (FontGradFrame));
|
DestroyDrawable (ReleaseDrawable (FontGradFrame));
|
||||||
FontGradFrame = 0;
|
FontGradFrame = 0;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "libs/decomp/lzh.h"
|
#include "libs/decomp/lzh.h"
|
||||||
|
#include "reslib.h"
|
||||||
|
|
||||||
PLZHCODE_DESC _lpCurCodeDesc;
|
PLZHCODE_DESC _lpCurCodeDesc;
|
||||||
STREAM_TYPE _StreamType;
|
STREAM_TYPE _StreamType;
|
||||||
@@ -103,7 +104,6 @@ StartHuff (void)
|
|||||||
DECODE_REF
|
DECODE_REF
|
||||||
copen (void *InStream, STREAM_TYPE SType, STREAM_MODE SMode)
|
copen (void *InStream, STREAM_TYPE SType, STREAM_MODE SMode)
|
||||||
{
|
{
|
||||||
MEM_HANDLE h;
|
|
||||||
DWORD StreamLength;
|
DWORD StreamLength;
|
||||||
|
|
||||||
_StreamType = SType;
|
_StreamType = SType;
|
||||||
@@ -132,17 +132,14 @@ copen (void *InStream, STREAM_TYPE SType, STREAM_MODE SMode)
|
|||||||
StreamLength = MAKE_DWORD (loword, hiword);
|
StreamLength = MAKE_DWORD (loword, hiword);
|
||||||
}
|
}
|
||||||
|
|
||||||
h = 0;
|
|
||||||
if (StreamLength == 0xFFFFFFFF
|
if (StreamLength == 0xFFFFFFFF
|
||||||
|| (h = AllocCodeDesc ()) == 0
|
|| (_lpCurCodeDesc = AllocCodeDesc ()) == NULL)
|
||||||
|| (_lpCurCodeDesc = LockCodeDesc (h)) == 0)
|
|
||||||
{
|
{
|
||||||
_lpCurCodeDesc = 0;
|
FreeCodeDesc (_lpCurCodeDesc);
|
||||||
FreeCodeDesc (h);
|
_lpCurCodeDesc = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_lpCurCodeDesc->fh = h;
|
|
||||||
_lpCurCodeDesc->Stream = _Stream;
|
_lpCurCodeDesc->Stream = _Stream;
|
||||||
_lpCurCodeDesc->StreamType = _StreamType;
|
_lpCurCodeDesc->StreamType = _StreamType;
|
||||||
_lpCurCodeDesc->StreamMode = SMode;
|
_lpCurCodeDesc->StreamMode = SMode;
|
||||||
@@ -168,8 +165,8 @@ cclose (PLZHCODE_DESC lpCodeDesc)
|
|||||||
(*_lpCurCodeDesc->CleanupFunc) ();
|
(*_lpCurCodeDesc->CleanupFunc) ();
|
||||||
|
|
||||||
StreamIndex = lpCodeDesc->StreamIndex;
|
StreamIndex = lpCodeDesc->StreamIndex;
|
||||||
UnlockCodeDesc (lpCodeDesc->fh);
|
FreeCodeDesc (lpCodeDesc);
|
||||||
FreeCodeDesc (lpCodeDesc->fh);
|
_lpCurCodeDesc = NULL;
|
||||||
|
|
||||||
return (StreamIndex);
|
return (StreamIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,38 +26,34 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "lzh.h"
|
#include "lzh.h"
|
||||||
|
#include "reslib.h"
|
||||||
|
|
||||||
static UWORD match_position, match_length;
|
static UWORD match_position, match_length;
|
||||||
static SWORD *lson;
|
static SWORD *lson;
|
||||||
static SWORD *rson;
|
static SWORD *rson;
|
||||||
static SWORD *dad;
|
static SWORD *dad;
|
||||||
|
static SWORD *encode_arrays;
|
||||||
|
|
||||||
#define AllocEncodeArrays() \
|
#define AllocEncodeArrays() \
|
||||||
mem_allocate ( \
|
HCalloc ( \
|
||||||
(MEM_SIZE)(((N + 1) + (N + 257) + (N + 1)) \
|
(MEM_SIZE)(((N + 1) + (N + 257) + (N + 1)) \
|
||||||
* sizeof (lson[0]) + sizeof (MEM_HANDLE)), \
|
* sizeof (lson[0])))
|
||||||
MEM_ZEROINIT)
|
#define FreeCodeArrays HFree
|
||||||
#define LockCodeArrays (SWORD*)mem_lock
|
|
||||||
#define UnlockCodeArrays mem_unlock
|
|
||||||
#define FreeCodeArrays mem_release
|
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
InitTree (void)
|
InitTree (void)
|
||||||
{
|
{
|
||||||
MEM_HANDLE h;
|
if ((encode_arrays = AllocEncodeArrays ()) == NULL)
|
||||||
|
|
||||||
if ((h = AllocEncodeArrays ()) == 0
|
|
||||||
|| (lson = LockCodeArrays (h)) == 0)
|
|
||||||
{
|
{
|
||||||
FreeCodeArrays (h);
|
FreeCodeArrays (encode_arrays);
|
||||||
|
encode_arrays = NULL;
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SWORD i;
|
SWORD i;
|
||||||
|
|
||||||
*(MEM_HANDLE *)lson = h;
|
lson = encode_arrays;
|
||||||
lson = (SWORD*)((BYTE*)lson + sizeof (h));
|
|
||||||
rson = lson + (N + 1);
|
rson = lson + (N + 1);
|
||||||
dad = rson + (N + 257);
|
dad = rson + (N + 257);
|
||||||
|
|
||||||
@@ -277,18 +273,17 @@ EncodePosition (UWORD c)
|
|||||||
static void
|
static void
|
||||||
UninitTree (void)
|
UninitTree (void)
|
||||||
{
|
{
|
||||||
MEM_HANDLE h;
|
|
||||||
|
|
||||||
if (_workbuflen)
|
if (_workbuflen)
|
||||||
{
|
{
|
||||||
OutChar ((BYTE)(_workbuf >> 8));
|
OutChar ((BYTE)(_workbuf >> 8));
|
||||||
++_lpCurCodeDesc->StreamIndex;
|
++_lpCurCodeDesc->StreamIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
lson = (SWORD*)((BYTE*)lson - sizeof (h));
|
FreeCodeArrays (encode_arrays);
|
||||||
h = *(MEM_HANDLE *)lson;
|
encode_arrays = NULL;
|
||||||
UnlockCodeArrays (h);
|
lson = NULL;
|
||||||
FreeCodeArrays (h);
|
rson = NULL;
|
||||||
|
dad = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
#ifndef _LZH_H
|
#ifndef _LZH_H
|
||||||
#define _LZH_H
|
#define _LZH_H
|
||||||
|
|
||||||
#include "reslib.h"
|
|
||||||
#include "declib.h"
|
#include "declib.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
/* LZSS Parameters */
|
/* LZSS Parameters */
|
||||||
|
|
||||||
@@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
struct _LZHCODE_DESC
|
struct _LZHCODE_DESC
|
||||||
{
|
{
|
||||||
MEM_HANDLE fh;
|
|
||||||
|
|
||||||
COUNT buf_index, restart_index, bytes_left;
|
COUNT buf_index, restart_index, bytes_left;
|
||||||
BYTE text_buf[N + F - 1];
|
BYTE text_buf[N + F - 1];
|
||||||
/* reconstruct freq tree */
|
/* reconstruct freq tree */
|
||||||
@@ -77,11 +75,8 @@ typedef LZHCODE_DESC *PLZHCODE_DESC;
|
|||||||
(*_Stream++ = (BYTE)(c)))
|
(*_Stream++ = (BYTE)(c)))
|
||||||
|
|
||||||
|
|
||||||
#define AllocCodeDesc() \
|
#define AllocCodeDesc() HCalloc ((MEM_SIZE)sizeof (LZHCODE_DESC))
|
||||||
mem_allocate ((MEM_SIZE)sizeof (LZHCODE_DESC), MEM_ZEROINIT)
|
#define FreeCodeDesc HFree
|
||||||
#define LockCodeDesc (PLZHCODE_DESC)mem_lock
|
|
||||||
#define UnlockCodeDesc mem_unlock
|
|
||||||
#define FreeCodeDesc mem_release
|
|
||||||
|
|
||||||
extern void _update (COUNT c);
|
extern void _update (COUNT c);
|
||||||
extern void StartHuff (void);
|
extern void StartHuff (void);
|
||||||
|
|||||||
@@ -131,8 +131,6 @@ typedef struct
|
|||||||
STAMP IntersectStamp;
|
STAMP IntersectStamp;
|
||||||
} INTERSECT_CONTROL;
|
} INTERSECT_CONTROL;
|
||||||
|
|
||||||
typedef MEM_HANDLE CONTEXT_REF;
|
|
||||||
|
|
||||||
typedef DWORD DRAWABLE;
|
typedef DWORD DRAWABLE;
|
||||||
#define BUILD_DRAWABLE(h,i) ((DRAWABLE)MAKE_DWORD(h,i))
|
#define BUILD_DRAWABLE(h,i) ((DRAWABLE)MAKE_DWORD(h,i))
|
||||||
|
|
||||||
@@ -172,8 +170,6 @@ extern BOOLEAN InitGraphics (int argc, char *argv[], COUNT
|
|||||||
extern void UninitGraphics (void);
|
extern void UninitGraphics (void);
|
||||||
|
|
||||||
extern CONTEXT SetContext (CONTEXT Context);
|
extern CONTEXT SetContext (CONTEXT Context);
|
||||||
extern CONTEXT CaptureContext (CONTEXT_REF ContextRef);
|
|
||||||
extern CONTEXT_REF ReleaseContext (CONTEXT Context);
|
|
||||||
extern COLOR SetContextForeGroundColor (COLOR Color);
|
extern COLOR SetContextForeGroundColor (COLOR Color);
|
||||||
extern COLOR SetContextBackGroundColor (COLOR Color);
|
extern COLOR SetContextBackGroundColor (COLOR Color);
|
||||||
extern FRAME SetContextFGFrame (FRAME Frame);
|
extern FRAME SetContextFGFrame (FRAME Frame);
|
||||||
@@ -196,8 +192,8 @@ extern void UnbatchGraphics (void);
|
|||||||
extern void FlushGraphics (void);
|
extern void FlushGraphics (void);
|
||||||
extern void ClearBackGround (RECT *pClipRect);
|
extern void ClearBackGround (RECT *pClipRect);
|
||||||
extern void ClearDrawable (void);
|
extern void ClearDrawable (void);
|
||||||
extern CONTEXT_REF CreateContext (void);
|
extern CONTEXT CreateContext (void);
|
||||||
extern BOOLEAN DestroyContext (CONTEXT_REF ContextRef);
|
extern BOOLEAN DestroyContext (CONTEXT ContextRef);
|
||||||
extern DRAWABLE CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth,
|
extern DRAWABLE CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth,
|
||||||
SIZE *pheight);
|
SIZE *pheight);
|
||||||
extern DRAWABLE CreateDrawable (CREATE_FLAGS CreateFlags, SIZE width,
|
extern DRAWABLE CreateDrawable (CREATE_FLAGS CreateFlags, SIZE width,
|
||||||
|
|||||||
@@ -65,67 +65,40 @@ SetContext (CONTEXT Context)
|
|||||||
return (LastContext);
|
return (LastContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTEXT_REF
|
CONTEXT
|
||||||
CreateContext (void)
|
CreateContext (void)
|
||||||
{
|
{
|
||||||
CONTEXT_REF ContextRef;
|
CONTEXT NewContext;
|
||||||
|
|
||||||
ContextRef = AllocContext ();
|
NewContext = AllocContext ();
|
||||||
if (ContextRef)
|
if (NewContext)
|
||||||
{
|
{
|
||||||
CONTEXT OldContext;
|
CONTEXT OldContext;
|
||||||
|
|
||||||
/* initialize context */
|
/* initialize context */
|
||||||
OldContext = SetContext (CaptureContext (ContextRef));
|
OldContext = SetContext (NewContext);
|
||||||
SetContextForeGroundColor (
|
SetContextForeGroundColor (
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
|
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
|
||||||
SetContextBackGroundColor (
|
SetContextBackGroundColor (
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00));
|
BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00));
|
||||||
SetContextClipping (TRUE);
|
SetContextClipping (TRUE);
|
||||||
ReleaseContext (SetContext (OldContext));
|
SetContext (OldContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ContextRef);
|
return (NewContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
DestroyContext (CONTEXT_REF ContextRef)
|
DestroyContext (CONTEXT ContextRef)
|
||||||
{
|
{
|
||||||
if (ContextRef == 0)
|
if (ContextRef == 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
if (_pCurContext && _pCurContext->ContextRef == ContextRef)
|
if (_pCurContext && _pCurContext == ContextRef)
|
||||||
SetContext ((CONTEXT)0);
|
SetContext ((CONTEXT)0);
|
||||||
|
|
||||||
return (FreeContext (ContextRef));
|
FreeContext (ContextRef);
|
||||||
}
|
return TRUE;
|
||||||
|
|
||||||
CONTEXT
|
|
||||||
CaptureContext (CONTEXT_REF ContextRef)
|
|
||||||
{
|
|
||||||
CONTEXT ContextPtr;
|
|
||||||
|
|
||||||
ContextPtr = LockContext (ContextRef);
|
|
||||||
if (ContextPtr)
|
|
||||||
ContextPtr->ContextRef = ContextRef;
|
|
||||||
|
|
||||||
return (ContextPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
CONTEXT_REF
|
|
||||||
ReleaseContext (CONTEXT ContextPtr)
|
|
||||||
{
|
|
||||||
if (ContextPtr)
|
|
||||||
{
|
|
||||||
CONTEXT_REF ContextRef;
|
|
||||||
|
|
||||||
ContextRef = ContextPtr->ContextRef;
|
|
||||||
UnlockContext (ContextRef);
|
|
||||||
|
|
||||||
return (ContextRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
COLOR
|
COLOR
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ typedef UWORD FBK_FLAGS;
|
|||||||
|
|
||||||
struct context_desc
|
struct context_desc
|
||||||
{
|
{
|
||||||
CONTEXT_REF ContextRef;
|
|
||||||
UWORD Flags;
|
UWORD Flags;
|
||||||
|
|
||||||
COLOR ForeGroundColor, BackGroundColor;
|
COLOR ForeGroundColor, BackGroundColor;
|
||||||
@@ -42,14 +41,8 @@ struct context_desc
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CONTEXT_PRIORITY DEFAULT_MEM_PRIORITY
|
#define AllocContext() HCalloc ((MEM_SIZE)sizeof (CONTEXT_DESC))
|
||||||
|
#define FreeContext HFree
|
||||||
#define AllocContext() \
|
|
||||||
(CONTEXT_REF)mem_allocate ((MEM_SIZE)sizeof (CONTEXT_DESC), \
|
|
||||||
MEM_ZEROINIT | MEM_PRIMARY)
|
|
||||||
#define LockContext (CONTEXT)mem_lock
|
|
||||||
#define UnlockContext mem_unlock
|
|
||||||
#define FreeContext mem_release
|
|
||||||
|
|
||||||
extern CONTEXT _pCurContext;
|
extern CONTEXT _pCurContext;
|
||||||
extern PRIMITIVE _locPrim;
|
extern PRIMITIVE _locPrim;
|
||||||
|
|||||||
@@ -44,21 +44,12 @@ typedef struct mem_header {
|
|||||||
#define GET_MEM_HEADER(addr) ((MEM_HEADER *) \
|
#define GET_MEM_HEADER(addr) ((MEM_HEADER *) \
|
||||||
(((char *) addr) - sizeof (MEM_HEADER)))
|
(((char *) addr) - sizeof (MEM_HEADER)))
|
||||||
|
|
||||||
//Newer verion from w_memlib.c to follow...
|
|
||||||
/*
|
|
||||||
extern MEM_BOOL mem_init (MEM_SIZE core_size, PMEM_SIZE pmin_addressable,
|
|
||||||
PSTR disk_name);*/
|
|
||||||
|
|
||||||
extern BOOLEAN mem_init (void);
|
extern BOOLEAN mem_init (void);
|
||||||
|
|
||||||
extern BOOLEAN mem_uninit (void);
|
extern BOOLEAN mem_uninit (void);
|
||||||
|
|
||||||
extern MEM_HANDLE mem_allocate (MEM_SIZE size, MEM_FLAGS flags);
|
extern MEM_HANDLE mem_allocate (MEM_SIZE size, MEM_FLAGS flags);
|
||||||
extern BOOLEAN mem_release (MEM_HANDLE handle);
|
extern BOOLEAN mem_release (MEM_HANDLE handle);
|
||||||
|
|
||||||
#define mem_request(size) \
|
|
||||||
mem_allocate((MEM_SIZE)(size), DEFAULT_MEM_FLAGS)
|
|
||||||
|
|
||||||
extern void* mem_lock (MEM_HANDLE handle);
|
extern void* mem_lock (MEM_HANDLE handle);
|
||||||
extern BOOLEAN mem_unlock (MEM_HANDLE handle);
|
extern BOOLEAN mem_unlock (MEM_HANDLE handle);
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ GenerateChmmr (BYTE control)
|
|||||||
CaptureStringTable (
|
CaptureStringTable (
|
||||||
LoadStringTable (CHMMR_BASE_STRTAB));
|
LoadStringTable (CHMMR_BASE_STRTAB));
|
||||||
|
|
||||||
ScanContext = CaptureContext (CreateContext ());
|
ScanContext = CreateContext ();
|
||||||
SetContext (ScanContext);
|
SetContext (ScanContext);
|
||||||
SetContextFGFrame (Screen);
|
SetContextFGFrame (Screen);
|
||||||
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
|
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
|
||||||
@@ -125,7 +125,7 @@ GenerateChmmr (BYTE control)
|
|||||||
DoDiscoveryReport (MenuSounds);
|
DoDiscoveryReport (MenuSounds);
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
SetContext (SpaceContext);
|
||||||
DestroyContext (ReleaseContext (ScanContext));
|
DestroyContext (ScanContext);
|
||||||
ScanContext = 0;
|
ScanContext = 0;
|
||||||
|
|
||||||
DestroyStringTable (ReleaseStringTable (
|
DestroyStringTable (ReleaseStringTable (
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ LoadPlanet (FRAME SurfDefFrame)
|
|||||||
|
|
||||||
StopMusic ();
|
StopMusic ();
|
||||||
|
|
||||||
TaskContext = CaptureContext (CreateContext ());
|
TaskContext = CreateContext ();
|
||||||
|
|
||||||
pPlanetDesc = pSolarSysState->pOrbitalDesc;
|
pPlanetDesc = pSolarSysState->pOrbitalDesc;
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ FreePlanet (void)
|
|||||||
Orbit->ScratchArray = 0;
|
Orbit->ScratchArray = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyContext (ReleaseContext (TaskContext));
|
DestroyContext (TaskContext);
|
||||||
TaskContext = 0;
|
TaskContext = 0;
|
||||||
|
|
||||||
DestroyStringTable (ReleaseStringTable (
|
DestroyStringTable (ReleaseStringTable (
|
||||||
|
|||||||
@@ -1229,7 +1229,7 @@ ScanSystem (void)
|
|||||||
(MAP_HEIGHT >> 1) << MAG_SHIFT;
|
(MAP_HEIGHT >> 1) << MAG_SHIFT;
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
ScanContext = CaptureContext (CreateContext ());
|
ScanContext = CreateContext ();
|
||||||
SetContext (ScanContext);
|
SetContext (ScanContext);
|
||||||
MenuState.flash_rect0.extent.width = FLASH_WIDTH;
|
MenuState.flash_rect0.extent.width = FLASH_WIDTH;
|
||||||
MenuState.flash_rect0.extent.height = FLASH_HEIGHT;
|
MenuState.flash_rect0.extent.height = FLASH_HEIGHT;
|
||||||
@@ -1263,7 +1263,7 @@ ScanSystem (void)
|
|||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
SetContext (SpaceContext);
|
SetContext (SpaceContext);
|
||||||
DestroyDrawable (ReleaseDrawable (MenuState.flash_frame0));
|
DestroyDrawable (ReleaseDrawable (MenuState.flash_frame0));
|
||||||
DestroyContext (ReleaseContext (ScanContext));
|
DestroyContext (ScanContext);
|
||||||
ScanContext = 0;
|
ScanContext = 0;
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-12
@@ -618,24 +618,21 @@ BOOLEAN
|
|||||||
SaveGame (COUNT which_game, SUMMARY_DESC *SummPtr)
|
SaveGame (COUNT which_game, SUMMARY_DESC *SummPtr)
|
||||||
{
|
{
|
||||||
BOOLEAN success, made_room;
|
BOOLEAN success, made_room;
|
||||||
void *out_fp;
|
void *out_fp, *h;
|
||||||
MEM_HANDLE h;
|
|
||||||
DECODE_REF fh;
|
DECODE_REF fh;
|
||||||
|
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
made_room = FALSE;
|
made_room = FALSE;
|
||||||
RetrySave:
|
RetrySave:
|
||||||
h = mem_request (10 * 1024);
|
h = HMalloc (10 * 1024);
|
||||||
out_fp = mem_lock (h);
|
if (h == 0
|
||||||
if (out_fp == 0
|
|| (fh = copen (h, MEMORY_STREAM, STREAM_WRITE)) == 0)
|
||||||
|| (fh = copen (out_fp, MEMORY_STREAM, STREAM_WRITE)) == 0)
|
|
||||||
{
|
{
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
made_room = TRUE;
|
made_room = TRUE;
|
||||||
mem_unlock (h);
|
HFree (h);
|
||||||
mem_release (h);
|
|
||||||
|
|
||||||
FreeSC2Data ();
|
FreeSC2Data ();
|
||||||
log_add (log_Debug, "Insufficient room for save buffers"
|
log_add (log_Debug, "Insufficient room for save buffers"
|
||||||
@@ -821,11 +818,10 @@ RetrySave:
|
|||||||
|
|
||||||
success = SaveSummary (SummPtr, out_fp);
|
success = SaveSummary (SummPtr, out_fp);
|
||||||
// Then write the rest of the data.
|
// Then write the rest of the data.
|
||||||
if (success && WriteResFile (mem_lock (h), (COUNT)flen, 1,
|
if (success && WriteResFile (h, (COUNT)flen, 1,
|
||||||
out_fp) == 0)
|
out_fp) == 0)
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
|
|
||||||
mem_unlock (h);
|
|
||||||
if (res_CloseResFile ((uio_Stream *)out_fp) == 0)
|
if (res_CloseResFile ((uio_Stream *)out_fp) == 0)
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
|
|
||||||
@@ -837,8 +833,7 @@ RetrySave:
|
|||||||
DeleteResFile (saveDir, file);
|
DeleteResFile (saveDir, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_unlock (h);
|
HFree (h);
|
||||||
mem_release (h);
|
|
||||||
|
|
||||||
if (made_room)
|
if (made_room)
|
||||||
LoadSC2Data ();
|
LoadSC2Data ();
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ LoadKernel (int argc, char *argv[])
|
|||||||
InitSound (argc, argv);
|
InitSound (argc, argv);
|
||||||
InitVideoPlayer (TRUE);
|
InitVideoPlayer (TRUE);
|
||||||
|
|
||||||
ScreenContext = CaptureContext (CreateContext ());
|
ScreenContext = CreateContext ();
|
||||||
if (ScreenContext == NULL)
|
if (ScreenContext == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ InitContexts (void)
|
|||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
StatusContext = CaptureContext (CreateContext ());
|
StatusContext = CreateContext ();
|
||||||
if (StatusContext == NULL)
|
if (StatusContext == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -162,11 +162,11 @@ InitContexts (void)
|
|||||||
r.extent.height = STATUS_HEIGHT;
|
r.extent.height = STATUS_HEIGHT;
|
||||||
SetContextClipRect (&r);
|
SetContextClipRect (&r);
|
||||||
|
|
||||||
SpaceContext = CaptureContext (CreateContext ());
|
SpaceContext = CreateContext ();
|
||||||
if (SpaceContext == NULL)
|
if (SpaceContext == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
OffScreenContext = CaptureContext (CreateContext ());
|
OffScreenContext = CreateContext ();
|
||||||
if (OffScreenContext == NULL)
|
if (OffScreenContext == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user