2010-06-24
* started adding alternative (smaller) tile size option for playing game
+ * fixed another memory violation bug in the native Supaplex game engine
+ (this potential memory bug was also in the original Megaplex code, but
+ apparently only occured under rare conditions triggered by using the
+ additional added preceding playfield memory area to make a few strange
+ levels using dirty off-playfield tricks (bugs) like "12s033.sp" also
+ solvable (this all worked fine in the classic DOS version, of course))
2010-06-23
* added graphics performance optimization to native Supaplex game engine
-#define COMPILE_DATE_STRING "2010-06-24 01:23"
+#define COMPILE_DATE_STRING "2010-06-24 11:02"
{
int al;
- if (tsi < (-FieldWidth))
+ if (tsi < -FieldWidth)
return;
al = LowByte(PlayField16[tsi]);
int FieldHeight; // standard size = 24
int HeaderSize; // standard size = 96
int FieldMax, LevelMax;
+#if 0
long FileMax;
+#endif
#if 1
int *PlayField16;
+byte *PlayField8;
// int PlayField16[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
-byte PlayField8[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
+// byte PlayField8[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
byte DisPlayField[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
#else
int *PlayField16;
bPlaying = False;
menBorder = False;
+ /* add preceding playfield buffer (as large as preceding memory area) */
PlayField16 = checked_calloc((game_sp.preceding_buffer_size +
SP_MAX_PLAYFIELD_SIZE +
SP_HEADER_SIZE) * sizeof(int));
PlayField16 = &PlayField16[game_sp.preceding_buffer_size];
+ /* add preceding playfield buffer (as large as one playfield row) */
+ PlayField8 = checked_calloc((SP_MAX_PLAYFIELD_WIDTH +
+ SP_MAX_PLAYFIELD_SIZE +
+ SP_HEADER_SIZE) * sizeof(byte));
+ PlayField8 = &PlayField8[SP_MAX_PLAYFIELD_WIDTH];
+
#if 0
/* these defaults will be changed after reading a Supaplex level file */
PlayField8 = REDIM_1D(sizeof(byte), 0, FieldMax);
#if 1
extern int *PlayField16;
+extern byte *PlayField8;
// extern int PlayField16[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
-extern byte PlayField8[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
+// extern byte PlayField8[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
extern byte DisPlayField[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
#else
extern int *PlayField16;
extern int TimerVar;
extern short RandomSeed;
+#if 0
extern long FileMax;
+#endif
extern LevelInfoType LInfo;
extern int ScrollMinX, ScrollMaxX, ScrollMinY, ScrollMaxY;
FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
LevelMax = (FieldWidth * FieldHeight) - 1;
+#if 0
/* (add one byte for the level number stored as first byte of demo data) */
FileMax = FieldMax + native_sp_level.demo.length + 1;
+#endif
#if 0
PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax);
PlayField16 = REDIM_1D(sizeof(int), -game_sp.preceding_buffer_size, FieldMax);
#endif
+ /* initialize preceding playfield buffer */
+ for (i = -game_sp.preceding_buffer_size; i < 0; i++)
+ PlayField16[i] = 0;
+
+ /* initialize preceding playfield buffer */
+ for (i = -SP_MAX_PLAYFIELD_WIDTH; i < 0; i++)
+ PlayField8[i] = 0;
+
count = 0;
for (i = 0; game_sp.preceding_buffer[i] != NULL; i++)
{
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(FieldHeight));
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(FieldMax));
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(LevelMax));
+#if 0
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(FileMax));
+#endif
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(TimerVar));
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(RandomSeed));