Added safety checks for rendering, fixed crash in first level.

This commit is contained in:
Justin Marshall
2020-06-02 16:25:20 -07:00
parent e4b2ccf409
commit 22f3ea37de
4 changed files with 33 additions and 28 deletions
+20 -16
View File
@@ -571,14 +571,14 @@ void DisplayClass::Set_View_Dimensions(int x, int y, int width, int height)
// ST - 3/1/2019 12:05PM // ST - 3/1/2019 12:05PM
// Made the below code more consistent with the width calculation. This is needed if we aren't going to draw the tabs at the top of the screen // Made the below code more consistent with the width calculation. This is needed if we aren't going to draw the tabs at the top of the screen
// //
if (height == -1) { //if (height == -1) {
TacLeptonHeight = Pixel_To_Lepton(SeenBuff.Get_Height() - y); // TacLeptonHeight = Pixel_To_Lepton(SeenBuff.Get_Height() - y);
//height = (SeenBuff.Get_Height()-y) / CELL_PIXEL_H; // //height = (SeenBuff.Get_Height()-y) / CELL_PIXEL_H;
} //}
else { //else {
TacLeptonHeight = height * CELL_LEPTON_H; // TacLeptonHeight = height * CELL_LEPTON_H;
} //}
//TacLeptonHeight = height * CELL_LEPTON_H; TacLeptonHeight = height * CELL_LEPTON_H;
/* /*
** Adjust the tactical cell if it is now in an invalid position ** Adjust the tactical cell if it is now in an invalid position
@@ -3096,13 +3096,17 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key)
** or release event, special mouse queuing storage variables are used. Other ** or release event, special mouse queuing storage variables are used. Other
** events must use the current mouse position globals. ** events must use the current mouse position globals.
*/ */
if (flags & (LEFTPRESS|LEFTRELEASE|RIGHTPRESS|RIGHTRELEASE)) { // jmarshall
x = Keyboard->MouseQX; //if (flags & (LEFTPRESS|LEFTRELEASE|RIGHTPRESS|RIGHTRELEASE)) {
y = Keyboard->MouseQY; // x = Keyboard->MouseQX;
} else { // y = Keyboard->MouseQY;
x = Get_Mouse_X(); //} else {
y = Get_Mouse_Y(); // x = Get_Mouse_X();
} // y = Get_Mouse_Y();
//}
x = Get_Mouse_X();
y = Get_Mouse_Y();
// jmarshall end
bool edge = (y == 0 || x == 0 || x == SeenBuff.Get_Width()-1 || y == SeenBuff.Get_Height()-1); bool edge = (y == 0 || x == 0 || x == SeenBuff.Get_Width()-1 || y == SeenBuff.Get_Height()-1);
COORDINATE coord = Map.Pixel_To_Coord(x, y); COORDINATE coord = Map.Pixel_To_Coord(x, y);
CELL cell = Coord_Cell(coord); CELL cell = Coord_Cell(coord);
@@ -3296,7 +3300,7 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key)
} }
} }
return(GadgetClass::Action(0, key)); return true; //(GadgetClass::Action(0, key));
} }
+7 -9
View File
@@ -355,7 +355,6 @@ static unsigned char const _redpal[]={0xD0,0xD1,0xD7,0xD3,0xD9,0xD5,0xDA,0xD7,
static unsigned char const _yellowpal[]={0x0,0x0,0xEC,0x0,0xEB,0x0,0xEA,0x0,0xE9,0x0,0x0,0x0,0x0,0x0,0xED,0x0}; static unsigned char const _yellowpal[]={0x0,0x0,0xEC,0x0,0xEB,0x0,0xEA,0x0,0xE9,0x0,0x0,0x0,0x0,0x0,0xED,0x0};
void ScoreClass::Presentation(void) void ScoreClass::Presentation(void)
{ {
#if (0)//PG
#ifdef WIN32 #ifdef WIN32
// if (Keyboard != NULL) return; // if (Keyboard != NULL) return;
#endif #endif
@@ -446,8 +445,8 @@ void ScoreClass::Presentation(void)
/* --- Now display the background animation --- */ /* --- Now display the background animation --- */
Hide_Mouse(); Hide_Mouse();
#ifdef WIN32 #ifdef WIN32
Load_Title_Screen(ScreenNames[house], &HidPage, ScorePalette); Load_Title_Screen(ScreenNames[house], &HidPage, (unsigned char *)ScorePalette.Get_Data());
Increase_Palette_Luminance (ScorePalette , 30, 30, 30, 63); Increase_Palette_Luminance ((unsigned char*)ScorePalette.Get_Data(), 30, 30, 30, 63);
HidPage.Blit(SeenPage); HidPage.Blit(SeenPage);
HidPage.Blit(*PseudoSeenBuff); HidPage.Blit(*PseudoSeenBuff);
#else #else
@@ -622,7 +621,7 @@ Keyboard->Clear();
Call_Back_Delay(60); Call_Back_Delay(60);
//BG } //BG }
if (house) Show_Credits(house, _greenpal); if (house) Show_Credits(house, (const char *)&_greenpal[0]);
/*BG if (!Keyboard->Check()) */ Call_Back_Delay(60); /*BG if (!Keyboard->Check()) */ Call_Back_Delay(60);
@@ -713,7 +712,7 @@ Keyboard->Clear();
Keyboard->Clear(); Keyboard->Clear();
if (!house) Show_Credits(house, _greenpal); if (!house) Show_Credits(house, (const char*)&_greenpal[0]);
/* /*
** Hall of fame display and processing ** Hall of fame display and processing
*/ */
@@ -778,9 +777,9 @@ Keyboard->Clear();
#ifdef WIN32 #ifdef WIN32
char maststr[NUMFAMENAMES*32]; char maststr[NUMFAMENAMES*32];
#endif #endif
char const *pal; const char *pal;
for (i = 0; i < NUMFAMENAMES; i++) { for (i = 0; i < NUMFAMENAMES; i++) {
pal = hallfame[i].side ? _redpal : _bluepal; pal = (const char* )(hallfame[i].side ? _redpal : _bluepal);
Alloc_Object(new ScorePrintClass(hallfame[i].name, HALLFAME_X, HALLFAME_Y + (i*8), pal)); Alloc_Object(new ScorePrintClass(hallfame[i].name, HALLFAME_X, HALLFAME_Y + (i*8), pal));
if (hallfame[i].score) { if (hallfame[i].score) {
#ifdef WIN32 #ifdef WIN32
@@ -811,7 +810,7 @@ Keyboard->Clear();
Keyboard->Clear(); Keyboard->Clear();
if (index < NUMFAMENAMES) { if (index < NUMFAMENAMES) {
pal = hallfame[index].side ? _redpal : _bluepal; pal = (const char *)(hallfame[index].side ? _redpal : _bluepal);
Input_Name(hallfame[index].name, HALLFAME_X, HALLFAME_Y + (index*8), pal); Input_Name(hallfame[index].name, HALLFAME_X, HALLFAME_Y + (index*8), pal);
file.Open(WRITE); file.Open(WRITE);
@@ -866,7 +865,6 @@ Keyboard->Clear();
Enable_Uncompressed_Shapes(); Enable_Uncompressed_Shapes();
#endif //FIXIT #endif //FIXIT
#endif
#endif #endif
} }
+3 -2
View File
@@ -622,8 +622,9 @@ int PASCAL WinMain ( HINSTANCE instance , HINSTANCE , char * command_line , int
} }
} }
ScreenHeight = 3072; // jmarshall
//ScreenHeight = 3072;
// jmarshall end
if (VisiblePage.Get_Height() == 480) { if (VisiblePage.Get_Height() == 480) {
SeenBuff.Attach(&VisiblePage, 0, 40, 3072, 3072); SeenBuff.Attach(&VisiblePage, 0, 40, 3072, 3072);
HidPage.Attach(&HiddenPage, 0, 40, 3072, 3072); HidPage.Attach(&HiddenPage, 0, 40, 3072, 3072);
+3 -1
View File
@@ -1117,7 +1117,9 @@ inline void GraphicViewPortClass::Draw_Stamp(void const * icondata, int icon, in
if (drewit == 0) { if (drewit == 0) {
if (Lock()){ if (Lock()){
UnCachedIconsDrawn++; UnCachedIconsDrawn++;
Buffer_Draw_Stamp_Clip(this, icondata, icon, x_pixel, y_pixel, remap, WindowList[clip_window][WINDOWX], WindowList[clip_window][WINDOWY], WindowList[clip_window][WINDOWWIDTH], WindowList[clip_window][WINDOWHEIGHT]); extern int ScreenHeight, ScreenWidth;
if(y_pixel < ScreenHeight && x_pixel < ScreenWidth)
Buffer_Draw_Stamp_Clip(this, icondata, icon, x_pixel, y_pixel, remap, WindowList[clip_window][WINDOWX], WindowList[clip_window][WINDOWY], WindowList[clip_window][WINDOWWIDTH], WindowList[clip_window][WINDOWHEIGHT]);
} }
} }
Unlock(); Unlock();