CGE: Remove static parts of HEART

This commit is contained in:
Strangerke 2011-06-20 00:55:47 +02:00
parent 40f95669ae
commit 77d4dcade2
6 changed files with 39 additions and 36 deletions

View File

@ -42,6 +42,8 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription)
_console = new CGEConsole(this);
Text = new TEXT(ProgName());
Vga = new VGA(M13H);
Heart = new HEART;
OffUseCount = atoi(Text->getText(OFF_USE_COUNT));

View File

@ -61,6 +61,9 @@ namespace CGE {
extern uint16 _stklen = (STACK_SIZ * 2);
VGA *Vga;
HEART *Heart;
// 0.75 - 17II95 - full sound support
// 0.76 - 18II95 - small MiniEMS in DEMO,
// unhide CavLight in SNLEVEL
@ -117,7 +120,6 @@ static SPRITE *Sprite = NULL;
static SPRITE *MiniCave = NULL;
static SPRITE *Shadow = NULL;
VGA *Vga;
static EMS *Mini = MiniEmm.Alloc((uint16)MINI_EMM_SIZE);
static BMP_PTR *MiniShpList = NULL;
static BMP_PTR MiniShp[] = { NULL, NULL };
@ -582,7 +584,6 @@ static void SaveMapping(void);
WALK *Hero = NULL;
static INFO_LINE InfoLine = INFO_W;
static HEART Heart;
static SPRITE CavLight = PR;
@ -738,7 +739,7 @@ static void CaveUp(void) {
if (! Startup)
Mouse.On();
HEART::Enable = true;
Heart->Enable = true;
}
@ -779,7 +780,7 @@ static void QGame(void) {
void SwitchCave(int cav) {
if (cav != Now) {
HEART::Enable = false;
Heart->Enable = false;
if (cav < 0) {
SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint
//TODO Change the SNPOST message send to a special way to send function pointer
@ -1673,7 +1674,7 @@ static void RunGame(void) {
}
KEYBOARD::SetClient(NULL);
HEART::Enable = false;
Heart->Enable = false;
SNPOST(SNCLEAR, -1, 0, NULL);
SNPOST_(SNCLEAR, -1, 0, NULL);
Mouse.Off();
@ -1691,13 +1692,13 @@ void Movie(const char *ext) {
ExpandSprite(Vga->SpareQ->Locate(999));
FeedSnail(Vga->ShowQ->Locate(999), TAKE);
Vga->ShowQ->Append(&Mouse);
HEART::Enable = true;
Heart->Enable = true;
KEYBOARD::SetClient(Sys);
while (! Snail.Idle()) {
MainLoop();
}
KEYBOARD::SetClient(NULL);
HEART::Enable = false;
Heart->Enable = false;
SNPOST(SNCLEAR, -1, 0, NULL);
SNPOST_(SNCLEAR, -1, 0, NULL);
Vga->ShowQ->Clear();
@ -1733,12 +1734,12 @@ bool ShowTitle(const char *name) {
Vga->CopyPage(1, 2);
Vga->CopyPage(0, 1);
Vga->ShowQ->Append(&Mouse);
HEART::Enable = true;
Heart->Enable = true;
Mouse.On();
for (SelectSound(); ! Snail.Idle() || VMENU::Addr;)
MainLoop();
Mouse.Off();
HEART::Enable = false;
Heart->Enable = false;
Vga->ShowQ->Clear();
Vga->CopyPage(0, 2);
STARTUP::SoundOk = 2;
@ -1771,10 +1772,10 @@ bool ShowTitle(const char *name) {
Vga->CopyPage(0, 1);
Vga->ShowQ->Append(&Mouse);
//Mouse.On();
HEART::Enable = true;
Heart->Enable = true;
for (TakeName(); GET_TEXT::Ptr;)
MainLoop();
HEART::Enable = false;
Heart->Enable = false;
if (KEYBOARD::Last() == Enter && *UsrFnam)
usr_ok = true;
if (usr_ok)

View File

@ -170,6 +170,7 @@ void ContractSprite(SPRITE *spr);
void cge_main(void);
extern VGA *Vga;
extern HEART *Heart;
extern int OffUseCount;
} // End of namespace CGE

View File

@ -511,16 +511,16 @@ static void SNRTNext(SPRITE *sprel, int p) {
static void SNZTrim(SPRITE *spr) {
if (spr)
if (spr->Active()) {
bool en = HEART::Enable;
bool en = Heart->Enable;
SPRITE *s;
HEART::Enable = false;
Heart->Enable = false;
s = (spr->Flags.Shad) ? spr->Prev : NULL;
Vga->ShowQ->Insert(Vga->ShowQ->Remove(spr));
if (s) {
s->Z = spr->Z;
Vga->ShowQ->Insert(Vga->ShowQ->Remove(s), spr);
}
HEART::Enable = en;
Heart->Enable = en;
}
}
@ -936,7 +936,7 @@ void SNAIL::RunCom(void) {
case SNLABEL :
break;
case SNPAUSE :
HEART::SetXTimer(&Pause, snc->Val);
Heart->SetXTimer(&Pause, snc->Val);
if (Talk)
TextDelay = true;
break;
@ -944,7 +944,7 @@ void SNAIL::RunCom(void) {
if (sprel) {
if (sprel->SeqTest(snc->Val) &&
(snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) {
HEART::SetXTimer(&Pause, sprel->Time);
Heart->SetXTimer(&Pause, sprel->Time);
} else
goto xit;
}

View File

@ -219,12 +219,10 @@ SPRITE *Locate(int ref) {
}
bool HEART::Enable = false;
uint16 *HEART::XTimer = NULL;
HEART::HEART(void)
: ENGINE(TMR_DIV) {
Enable = false;
XTimer = NULL;
}
@ -235,11 +233,11 @@ extern "C" void TimerProc (void)
static uint8 run = 0;
// decrement external timer uint16
if (HEART::XTimer)
if (*HEART::XTimer) -- *HEART::XTimer;
else HEART::XTimer = NULL;
if (Heart->XTimer)
if (*Heart->XTimer) -- *Heart->XTimer;
else Heart->XTimer = NULL;
if (! run && HEART::Enable) // check overrun flag
if (! run && Heart->Enable) // check overrun flag
{
static uint16 oldSP, oldSS;
@ -299,11 +297,11 @@ void ENGINE::NewTimer(...) {
my_int: //------72Hz-------//
// decrement external timer uint16
if (HEART::XTimer)
if (*HEART::XTimer) -- *HEART::XTimer;
else HEART::XTimer = NULL;
if (Heart->XTimer)
if (*Heart->XTimer) -- *Heart->XTimer;
else Heart->XTimer = NULL;
if (! run && HEART::Enable) // check overrun flag
if (! run && Heart->Enable) // check overrun flag
{
static uint16 oldSP, oldSS;
@ -473,8 +471,8 @@ void SPRITE::SetName(char *n) {
SPRITE *SPRITE::Expand(void) {
if (! Ext) {
bool enbl = HEART::Enable;
HEART::Enable = false;
bool enbl = Heart->Enable;
Heart->Enable = false;
if ((Ext = new SPREXT) == NULL)
error("No core");
if (*File) {
@ -596,7 +594,7 @@ SPRITE *SPRITE::Expand(void) {
else
TakePtr = NO_PTR;
}
HEART::Enable = enbl;
Heart->Enable = enbl;
}
return this;
}

View File

@ -131,11 +131,12 @@ extern SEQ Seq2[];
class HEART : public ENGINE {
friend class ENGINE;
public:
static bool Enable;
static uint16 *XTimer;
static void SetXTimer(uint16 *ptr);
static void SetXTimer(uint16 *ptr, uint16 time);
HEART(void);
HEART();
bool Enable;
uint16 *XTimer;
void SetXTimer(uint16 *ptr);
void SetXTimer(uint16 *ptr, uint16 time);
};