- /* 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);
- DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax);
- PlayField16 = REDIM_1D(sizeof(int), 0, FieldMax);
-
- AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax);
- AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax);
- TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax);
-#endif
+ // add preceding playfield buffer (as large as preceding memory area)
+ PlayField16Mem = checked_calloc((game_sp.preceding_buffer_size +
+ SP_MAX_PLAYFIELD_SIZE +
+ SP_HEADER_SIZE) * sizeof(int));
+ PlayField16 = &PlayField16Mem[game_sp.preceding_buffer_size];
+
+ // add preceding playfield buffer (as large as one playfield row)
+ PlayField8Mem = checked_calloc((SP_MAX_PLAYFIELD_WIDTH +
+ SP_MAX_PLAYFIELD_SIZE +
+ SP_HEADER_SIZE) * sizeof(byte));
+ PlayField8 = &PlayField8Mem[SP_MAX_PLAYFIELD_WIDTH];
+}
+
+void FreeGlobals(void)
+{
+ checked_free(PlayField16Mem);
+ checked_free(PlayField8Mem);