From: Holger Schemel Date: Wed, 28 Oct 2009 14:15:47 +0000 (+0100) Subject: rnd-20091028-1-src X-Git-Tag: 3.3.0.0^2~69 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=3c080c7b33b6dfcc6e0039b592c5f268535873e7;p=rocksndiamonds.git rnd-20091028-1-src * 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) --- diff --git a/ChangeLog b/ChangeLog index 22e68ea2..514c6ed8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/src/conftime.h b/src/conftime.h index 7a9a4638..64d01167 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2009-10-24 22:25" +#define COMPILE_DATE_STRING "2009-10-28 15:07" diff --git a/src/files.c b/src/files.c index d0caceb5..05dfd5bd 100644 --- a/src/files.c +++ b/src/files.c @@ -4174,6 +4174,8 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level) 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 diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 12344b80..48a35ef1 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -181,13 +181,30 @@ void DDScrollBuffer_Blt_Ext(Bitmap *target_bitmap) 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 diff --git a/src/game_sp/Explosions.c b/src/game_sp/Explosions.c index b6f009bf..cf1d7297 100644 --- a/src/game_sp/Explosions.c +++ b/src/game_sp/Explosions.c @@ -153,7 +153,8 @@ static void LetExplodeFieldSP(int tsi, int cx, int dh) case fiMurphy: #if 1 - printf("::: Explosions.c: LetExplodeFieldSP(): killing murphy\n"); + printf("::: Explosions.c: LetExplodeFieldSP(): killing murphy [%d]\n", + tsi); #endif KillMurphyFlag = 1; diff --git a/src/game_sp/Globals.c b/src/game_sp/Globals.c index 4c4f7afe..a54380ef 100644 --- a/src/game_sp/Globals.c +++ b/src/game_sp/Globals.c @@ -64,6 +64,8 @@ int *PlayField16; byte *PlayField8; byte *DisPlayField; +long ScreenBuffer[SP_SCREEN_BUFFER_XSIZE][SP_SCREEN_BUFFER_YSIZE]; + // Public DisplayMin%, DisplayMax%, DisplayWidth%, DisplayHeight% int TimerVar; diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index 4f7bee91..0a66bd96 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -2509,7 +2509,9 @@ void menPlay_Click() // Trace "MainForm", "subFetchAndInitLevel returned" +#if 0 Stage.Blt(); +#endif #if 0 @@ -2520,7 +2522,6 @@ void menPlay_Click() // Trace "MainForm", "<-- menPlay_Click()" #endif - } #if 1 @@ -2990,7 +2991,11 @@ static void picPane_Paint() Oldflag = NoDisplayFlag; NoDisplayFlag = False; + +#if 0 Stage.Blt(); +#endif + NoDisplayFlag = Oldflag; } @@ -3082,7 +3087,9 @@ static void ReStretch(float NewStretch) ScrollTo(ScreenScrollXPos, ScreenScrollYPos); +#if 0 Stage.Blt(); +#endif picPane_Paint(); } diff --git a/src/game_sp/MainGameLoop.c b/src/game_sp/MainGameLoop.c index eddb4cdd..e1f81f4d 100644 --- a/src/game_sp/MainGameLoop.c +++ b/src/game_sp/MainGameLoop.c @@ -35,7 +35,7 @@ int subMainGameLoop_Init() if (DemoFlag != 0) { -#if 1 +#if 0 printf("::: playing demo ...\n"); #endif @@ -45,7 +45,7 @@ int subMainGameLoop_Init() } else // loc_g_1836: { -#if 1 +#if 0 printf("::: playing game ...\n"); #endif @@ -279,7 +279,7 @@ locRepeatMainGameLoop: // start repeating game loop locExitMainGameLoop: -#if 1 +#if 0 printf("::: locExitMainGameLoop reached [%d]\n", LeadOutCounter); #endif diff --git a/src/game_sp/export.h b/src/game_sp/export.h index 4438990f..aecfcc85 100644 --- a/src/game_sp/export.h +++ b/src/game_sp/export.h @@ -24,6 +24,9 @@ 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") */ @@ -97,6 +100,7 @@ struct DemoInfo_SP struct LevelInfo_SP { LevelInfoType header; + byte header_raw_bytes[SP_HEADER_SIZE]; int width, height; diff --git a/src/game_sp/file.c b/src/game_sp/file.c index 7a0c2c87..934f52f7 100644 --- a/src/game_sp/file.c +++ b/src/game_sp/file.c @@ -43,6 +43,10 @@ void setLevelInfoToDefaults_SP() 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; } @@ -50,6 +54,7 @@ void setLevelInfoToDefaults_SP() void copyInternalEngineVars_SP() { int i, x, y; + int count; LInfo = native_sp_level.header; @@ -66,7 +71,27 @@ void copyInternalEngineVars_SP() 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++) { @@ -80,6 +105,8 @@ void copyInternalEngineVars_SP() } } +#endif + if (native_sp_level.demo.is_available) { DemoAvailable = True; @@ -219,6 +246,12 @@ static void LoadNativeLevelFromFileStream_SP(FILE *file, boolean demo_available) 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) diff --git a/src/game_sp/init.c b/src/game_sp/init.c index d8e73a1d..0e217a9d 100644 --- a/src/game_sp/init.c +++ b/src/game_sp/init.c @@ -58,7 +58,7 @@ unsigned int InitEngineRandom_SP(long seed) { if (seed == NEW_RANDOMIZE) { -#if 1 +#if 0 printf("::: init.c: InitEngineRandom_SP(): subRandomize()\n"); #endif @@ -69,7 +69,7 @@ unsigned int InitEngineRandom_SP(long seed) RandomSeed = (short)seed; -#if 1 +#if 0 printf("::: init.c: InitEngineRandom_SP(): RandomSeed == %d\n", RandomSeed); #endif diff --git a/src/game_sp/vb_lib.c b/src/game_sp/vb_lib.c index d88c8e36..5c1dae75 100644 --- a/src/game_sp/vb_lib.c +++ b/src/game_sp/vb_lib.c @@ -13,11 +13,30 @@ /* 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;