X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2Ffile.c;h=2b8a1755fbd66d1ad559fe76ad9c86dbf4132b19;hb=f7cee51ad23b10be242545a6445fddf45accf65d;hp=a998cfdf2fef43442dfdb9b7a672ccaba4879fa1;hpb=4591885cdbcfec145d1ac0510fed1519af1eea1d;p=rocksndiamonds.git diff --git a/src/game_sp/file.c b/src/game_sp/file.c index a998cfdf..2b8a1755 100644 --- a/src/game_sp/file.c +++ b/src/game_sp/file.c @@ -112,10 +112,8 @@ void copyInternalEngineVars_SP() int count; int i, x, y; -#if 1 for (i = 0; preceding_playfield_memory[i] != NULL; i++) preceding_buffer_size += 8; /* eight 16-bit integer values */ -#endif /* needed for engine snapshots */ game_sp.preceding_buffer_size = preceding_buffer_size; @@ -129,25 +127,13 @@ void copyInternalEngineVars_SP() FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; LevelMax = (FieldWidth * FieldHeight) - 1; - FileMax = FieldMax + native_sp_level.demo.length; + /* (add one byte for the level number stored as first byte of demo data) */ + FileMax = FieldMax + native_sp_level.demo.length + 1; - PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1); - DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); -#if 1 + PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax); + DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax); PlayField16 = REDIM_1D(sizeof(int), -preceding_buffer_size, FieldMax); -#else - PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax); -#endif - -#if 1 -#if 0 - /* fill preceding playfield buffer zone with (indestructible) "hardware" */ - for (i = -FieldWidth; i < 0; i++) - PlayField16[i] = 0x20; -#endif - -#if 1 count = 0; for (i = 0; preceding_playfield_memory[i] != NULL; i++) { @@ -176,7 +162,6 @@ void copyInternalEngineVars_SP() s++; } } -#endif count = 0; for (y = 0; y < native_sp_level.height; y++) @@ -194,46 +179,6 @@ void copyInternalEngineVars_SP() PlayField8[i] = 0; } -#if 0 - { - static int x = 0; - - if (x == 1) - { - printf("++++++++"); - printf("----------\n"); - for (i = 0; i < preceding_buffer_size + FieldMax; i++) - { - int x = PlayField16[-preceding_buffer_size + i]; - - printf("%c%c", x & 0xff, x >> 8); - } - printf("----------\n"); - exit(0); - } - - x++; - } -#endif - -#else - - for (i = 0; y = 0; y < native_sp_level.height; y++) - { - for (x = 0; x < native_sp_level.width; x++) - { - PlayField8[i] = native_sp_level.playfield[x][y]; - - PlayField16[i] = PlayField8[i]; - DisPlayField[i] = PlayField8[i]; - PlayField8[i] = 0; - - i++; - } - } - -#endif - if (native_sp_level.demo.is_available) { DemoAvailable = True; @@ -241,7 +186,7 @@ void copyInternalEngineVars_SP() PlayField8[FieldMax + 1] = native_sp_level.demo.level_nr; for (i = 0; i < native_sp_level.demo.length; i++) - PlayField8[FieldMax + i + 2] = native_sp_level.demo.data[i]; + PlayField8[FieldMax + 2 + i] = native_sp_level.demo.data[i]; } AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 * FieldWidth); @@ -254,13 +199,7 @@ void copyInternalEngineVars_SP() #if 1 /* this is set by main game tape code to native random generator directly */ #else - -#if 1 - printf("::: file.c: copyInternalEngineVars_SP(): RandomSeed = LInfo.DemoRandomSeed\n"); -#endif - RandomSeed = LInfo.DemoRandomSeed; - #endif LevelLoaded = True; @@ -308,10 +247,6 @@ static void LoadNativeLevelFromFileStream_SP(FILE *file, int width, int height, /* number of special ("gravity") port entries below (maximum 10 allowed) */ header->SpecialPortCount = getFile8Bit(file); -#if 0 - printf("::: num_special_ports == %d\n", header->SpecialPortCount); -#endif - /* database of properties of up to 10 special ports (6 bytes per port) */ for (i = 0; i < SP_MAX_SPECIAL_PORTS; i++) { @@ -324,16 +259,6 @@ static void LoadNativeLevelFromFileStream_SP(FILE *file, int width, int height, which is 2 bytes per tile) */ port->PortLocation = getFile16BitBE(file); /* yes, big endian */ -#if 0 - { - int port_x = (port->PortLocation / 2) % SP_PLAYFIELD_WIDTH; - int port_y = (port->PortLocation / 2) / SP_PLAYFIELD_WIDTH; - - printf("::: %d: port_location == %d => (%d, %d)\n", - i, port->PortLocation, port_x, port_y); - } -#endif - /* change gravity: 1 == "turn on", anything else (0) == "turn off" */ port->Gravity = getFile8Bit(file); @@ -354,11 +279,6 @@ static void LoadNativeLevelFromFileStream_SP(FILE *file, int width, int height, /* random seed used for recorded demos */ header->DemoRandomSeed = getFile16BitLE(file); /* yes, little endian */ - // header->DemoRandomSeed = getFile16BitBE(file); /* !!! TEST ONLY !!! */ - -#if 0 - printf("::: file.c: DemoRandomSeed == %d\n", header->DemoRandomSeed); -#endif /* auto-determine number of infotrons if it was stored as "0" -- see above */ if (header->InfotronsNeeded == 0)