+2009-10-28
+ * fixed array allocation in native Supaplex engine to correctly handle
+ preceding scratch buffers (needed because of missing border checking)
+ * fixed playfield initialization to correctly add raw header bytes as
+ subsequent scratch buffer (needed because of missing border checking)
+
2009-10-24
* most important parts of native Supaplex engine integration working:
- native Supaplex levels can be played in native Supaplex engine
-#define COMPILE_DATE_STRING "2009-10-24 22:25"
+#define COMPILE_DATE_STRING "2009-10-28 15:07"
if (element_old >= EL_SP_START &&
element_old <= EL_SP_END)
element_new = element_old - EL_SP_START;
+ else if (element_old == EL_EMPTY_SPACE)
+ element_new = 0x00;
else if (element_old == EL_INVISIBLE_WALL)
element_new = 0x28;
else
SR.left, SR.top, mScrollX, mScrollY, mDestXOff, mDestYOff);
#endif
+#if 0
+ /* !!! quick and dirty -- FIX THIS !!! */
+ if (tape.playing && tape.fast_forward &&
+ target_bitmap == window &&
+ (FrameCounter % 2) != 0)
+ printf("::: FrameCounter == %d\n", FrameCounter);
+#endif
+
+#if 1
+ SyncDisplay();
+#endif
+
#if 1
BlitBitmap(screenBitmap, target_bitmap,
SR.left, SR.top,
SCR_FIELDX * TILEX, SCR_FIELDY * TILEY, SX, SY);
#endif
+#if 1
+ FlushDisplay();
+#endif
+
return;
+
#endif
// DDraw.WaitForVerticalBlank DDWAITVB_BLOCKBEGIN, 0
case fiMurphy:
#if 1
- printf("::: Explosions.c: LetExplodeFieldSP(): killing murphy\n");
+ printf("::: Explosions.c: LetExplodeFieldSP(): killing murphy [%d]\n",
+ tsi);
#endif
KillMurphyFlag = 1;
byte *PlayField8;
byte *DisPlayField;
+long ScreenBuffer[SP_SCREEN_BUFFER_XSIZE][SP_SCREEN_BUFFER_YSIZE];
+
// Public DisplayMin%, DisplayMax%, DisplayWidth%, DisplayHeight%
int TimerVar;
// Trace "MainForm", "subFetchAndInitLevel returned"
+#if 0
Stage.Blt();
+#endif
#if 0
// Trace "MainForm", "<-- menPlay_Click()"
#endif
-
}
#if 1
Oldflag = NoDisplayFlag;
NoDisplayFlag = False;
+
+#if 0
Stage.Blt();
+#endif
+
NoDisplayFlag = Oldflag;
}
ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
+#if 0
Stage.Blt();
+#endif
picPane_Paint();
}
if (DemoFlag != 0)
{
-#if 1
+#if 0
printf("::: playing demo ...\n");
#endif
}
else // loc_g_1836:
{
-#if 1
+#if 0
printf("::: playing game ...\n");
#endif
locExitMainGameLoop:
-#if 1
+#if 0
printf("::: locExitMainGameLoop reached [%d]\n", LeadOutCounter);
#endif
SP_PLAYFIELD_HEIGHT)
#define SP_LEVEL_SIZE (SP_HEADER_SIZE + SP_PLAYFIELD_SIZE)
+#define SP_SCREEN_BUFFER_XSIZE (SCR_FIELDX + 2)
+#define SP_SCREEN_BUFFER_YSIZE (SCR_FIELDY + 2)
+
#define SP_FRAMES_PER_SECOND 35
#define SP_MAX_TAPE_LEN 64010 /* (see "spfix63.doc") */
struct LevelInfo_SP
{
LevelInfoType header;
+ byte header_raw_bytes[SP_HEADER_SIZE];
int width, height;
port->FreezeEnemies = 0;
}
+ /* set raw header bytes (used for subsequent buffer zone) to "hardware" */
+ for (i = 0; i < SP_HEADER_SIZE; i++)
+ native_sp_level.header_raw_bytes[i] = 0x20;
+
native_sp_level.demo.is_available = FALSE;
native_sp_level.demo.length = 0;
}
void copyInternalEngineVars_SP()
{
int i, x, y;
+ int count;
LInfo = native_sp_level.header;
DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax);
- for (i = 0, y = 0; y < native_sp_level.height; y++)
+#if 1
+
+ count = 0;
+ for (y = 0; y < native_sp_level.height; y++)
+ for (x = 0; x < native_sp_level.width; x++)
+ PlayField8[count++] = native_sp_level.playfield[x][y];
+
+ /* add raw header bytes to subsequent playfield buffer zone */
+ for (i = 0; i < SP_HEADER_SIZE; i++)
+ PlayField8[count++] = native_sp_level.header_raw_bytes[i];
+
+ for (i = 0; i < count; i++)
+ {
+ PlayField16[i] = PlayField8[i];
+ DisPlayField[i] = PlayField8[i];
+ PlayField8[i] = 0;
+ }
+
+#else
+
+ for (i = 0; y = 0; y < native_sp_level.height; y++)
{
for (x = 0; x < native_sp_level.width; x++)
{
}
}
+#endif
+
if (native_sp_level.demo.is_available)
{
DemoAvailable = True;
header->InfotronsNeeded &= 0xff; /* only use low byte -- see above */
}
+ /* read raw level header bytes (96 bytes) */
+
+ fseek(file, -(SP_HEADER_SIZE), SEEK_CUR); /* rewind file */
+ for (i = 0; i < SP_HEADER_SIZE; i++)
+ native_sp_level.header_raw_bytes[i] = fgetc(file);
+
/* also load demo tape, if available */
if (demo_available)
{
if (seed == NEW_RANDOMIZE)
{
-#if 1
+#if 0
printf("::: init.c: InitEngineRandom_SP(): subRandomize()\n");
#endif
RandomSeed = (short)seed;
-#if 1
+#if 0
printf("::: init.c: InitEngineRandom_SP(): RandomSeed == %d\n", RandomSeed);
#endif
/* helper functions for constructs not supported by C */
+
+#if 1
+
+void *REDIM_1D(int data_size, int first_data_pos, int last_data_pos)
+{
+ /* for a buffer of n elements, first_data_pos is 0 and last_data_pos is n-1 */
+ /* a negative value for "first_data_pos" indicates a preceding buffer zone */
+
+ int data_count = last_data_pos - first_data_pos + 1;
+ int buffer_size = data_size * data_count;
+ int buffer_start = data_size * first_data_pos;
+
+ return (checked_calloc(buffer_size) - buffer_start);
+}
+
+#else
+
void *REDIM_1D(int a, int b, int c)
{
return checked_calloc(a * (c - b + 1));
}
+#endif
+
void *REDIM_2D(int a, int b, int c, int d, int e)
{
return 0;