-#define COMPILE_DATE_STRING "2009-10-23 00:17"
+#define COMPILE_DATE_STRING "2009-10-24 01:44"
void CopyNativeLevel_RND_to_SP(struct LevelInfo *level)
{
- LevelInfoType *header = &native_sp_level.header;
+ struct LevelInfo_SP *level_sp = level->native_sp_level;
+ LevelInfoType *header = &level_sp->header;
int i, x, y;
- native_sp_level.width = level->fieldx;
- native_sp_level.height = level->fieldy;
+ level_sp->width = level->fieldx;
+ level_sp->height = level->fieldy;
for (x = 0; x < level->fieldx; x++)
{
else if (element_old == EL_INVISIBLE_WALL)
element_new = 0x28;
else
- element_new = EL_SP_HARDWARE_YELLOW; /* unknown to Supaplex engine */
+ element_new = 0x20; /* map unknown elements to yellow "hardware" */
- native_sp_level.playfield[x][y] = element_new;
+ level_sp->playfield[x][y] = element_new;
}
}
void CopyNativeLevel_SP_to_RND(struct LevelInfo *level)
{
- LevelInfoType *header = &native_sp_level.header;
+ struct LevelInfo_SP *level_sp = level->native_sp_level;
+ LevelInfoType *header = &level_sp->header;
int i, x, y;
- level->fieldx = native_sp_level.width;
- level->fieldy = native_sp_level.height;
+ level->fieldx = level_sp->width;
+ level->fieldy = level_sp->height;
for (x = 0; x < level->fieldx; x++)
{
for (y = 0; y < level->fieldy; y++)
{
- int element_old = native_sp_level.playfield[x][y];
+ int element_old = level_sp->playfield[x][y];
int element_new;
if (element_old <= 0x27)
level->yamyam_content[i].e[x][y] = EL_EMPTY;
}
+static void setTapeInfoToDefaults();
+
+static void CopyNativeTape_SP_to_RND(struct LevelInfo *level)
+{
+ struct LevelInfo_SP *level_sp = level->native_sp_level;
+ struct DemoInfo_SP *demo = &level_sp->demo;
+ int i;
+
+ /* always start with reliable default values */
+ setTapeInfoToDefaults();
+
+ tape.level_nr = demo->level_nr; /* (currently not used) */
+ tape.length = demo->length - 1; /* without "end of demo" byte */
+ tape.random_seed = level_sp->header.DemoRandomSeed;
+
+ // tape.date = <SET FROM FILE DATE OF *.SP FILE>
+
+ for (i = 0; i < demo->length - 1; i++)
+ {
+ int demo_action = demo->data[i] & 0x0f;
+ int demo_repeat = (demo->data[i] & 0xf0) >> 4;
+
+ tape.pos[i].action[0] = map_key_SP_to_RND(demo_action);
+ tape.pos[i].delay = demo_repeat + 1;
+ }
+
+ tape.length_seconds = GetTapeLength();
+}
+
/* ------------------------------------------------------------------------- */
/* functions for loading DC level */
char *filename = getSolutionTapeFilename(nr);
LoadTapeFromFilename(filename);
+
+#if 1
+ if (TAPE_IS_EMPTY(tape) &&
+ level.game_engine_type == GAME_ENGINE_TYPE_SP &&
+ level.native_sp_level->demo.is_available)
+ CopyNativeTape_SP_to_RND(&level);
+#endif
}
static void SaveTape_VERS(FILE *file, struct TapeInfo *tape)
}
#endif
-#if 1
+#if 0
printf("::: BugsTerminals.c: ========== subRandomize()\n");
#endif
int KeyScanCode7;
+int map_key_RND_to_SP(int key)
+{
+ if (key & KEY_BUTTON)
+ {
+ return (key & MV_UP ? keySpaceUp :
+ key & MV_LEFT ? keySpaceLeft :
+ key & MV_DOWN ? keySpaceDown :
+ key & MV_RIGHT ? keySpaceRight : keySpace);
+ }
+ else
+ {
+ return (key & MV_UP ? keyUp :
+ key & MV_LEFT ? keyLeft :
+ key & MV_DOWN ? keyDown :
+ key & MV_RIGHT ? keyRight : keyNone);
+ }
+}
+
+int map_key_SP_to_RND(int key)
+{
+ return (key == keyUp ? MV_UP :
+ key == keyLeft ? MV_LEFT :
+ key == keyDown ? MV_DOWN :
+ key == keyRight ? MV_RIGHT :
+ key == keySpaceUp ? KEY_BUTTON | MV_UP :
+ key == keySpaceLeft ? KEY_BUTTON | MV_LEFT :
+ key == keySpaceDown ? KEY_BUTTON | MV_DOWN :
+ key == keySpaceRight ? KEY_BUTTON | MV_RIGHT :
+ key == keySpace ? KEY_BUTTON : MV_NONE);
+}
+
void subCheckJoystick()
{
}
#if 1
- if (action & KEY_BUTTON)
- {
- DemoKeyCode = (action & MV_UP ? keySpaceUp :
- action & MV_LEFT ? keySpaceLeft :
- action & MV_DOWN ? keySpaceDown :
- action & MV_RIGHT ? keySpaceRight : keySpace);
- }
- else
- {
- DemoKeyCode = (action & MV_UP ? keyUp :
- action & MV_LEFT ? keyLeft :
- action & MV_DOWN ? keyDown :
- action & MV_RIGHT ? keyRight : keyNone);
- }
+ DemoKeyCode = map_key_RND_to_SP(action);
+
+#if 0
+ printf("::: DemoKeyCode == %d\n", DemoKeyCode);
+#endif
return subProcessKeyboardInput;
{
subGetNextDemoKey();
+#if 0
+ printf("::: DemoKeyCode == %d\n", DemoKeyCode);
+#endif
+
if (ExitToMenuFlag != 0)
return subProcessKeyboardInput;
}
boolean GameOver;
};
+struct DemoInfo_SP
+{
+ boolean is_available; /* structure contains valid demo */
+
+ int level_nr; /* number of corresponding level */
+
+ int length; /* number of demo entries */
+ byte data[SP_MAX_TAPE_LEN]; /* array of demo entries */
+};
+
struct LevelInfo_SP
{
LevelInfoType header;
- byte playfield[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
-
int width, height;
- boolean demo_available;
+ byte playfield[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
- byte demo[SP_MAX_TAPE_LEN];
- int demo_length;
+ struct DemoInfo_SP demo;
};
struct GraphicInfo_SP
extern void LoadEngineSnapshotValues_SP();
extern void SaveEngineSnapshotValues_SP();
+extern int map_key_RND_to_SP(int);
+extern int map_key_SP_to_RND(int);
+
#endif /* GAME_SP_EXPORT_H */
port->FreezeEnemies = 0;
}
- native_sp_level.demo_available = FALSE;
- native_sp_level.demo_length = 0;
+ native_sp_level.demo.is_available = FALSE;
+ native_sp_level.demo.length = 0;
}
void copyInternalEngineVars_SP()
FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
LevelMax = (FieldWidth * FieldHeight) - 1;
- FileMax = FieldMax + native_sp_level.demo_length;
+ FileMax = FieldMax + native_sp_level.demo.length;
PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1);
DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
}
}
- if (native_sp_level.demo_available)
+ if (native_sp_level.demo.is_available)
{
DemoAvailable = True;
- for (i = 0; i < native_sp_level.demo_length; i++)
- PlayField8[FieldMax + i + 1] = native_sp_level.demo[i];
+ 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];
}
AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 * FieldWidth);
if (demo_available)
{
+ int level_nr = getFile8Bit(file);
+
+ level_nr &= 0x7f; /* clear highest bit */
+ level_nr = (level_nr < 1 ? 1 :
+ level_nr > 111 ? 111 : level_nr);
+
+ native_sp_level.demo.level_nr = level_nr;
+
for (i = 0; i < SP_MAX_TAPE_LEN && !feof(file); i++)
{
- native_sp_level.demo[i] = getFile8Bit(file);
+ native_sp_level.demo.data[i] = getFile8Bit(file);
- if (native_sp_level.demo[i] == 0xff) /* "end of demo" byte */
+ if (native_sp_level.demo.data[i] == 0xff) /* "end of demo" byte */
{
i++;
}
}
- native_sp_level.demo_length = i;
- native_sp_level.demo_available = (native_sp_level.demo_length > 0);
+ native_sp_level.demo.length = i;
+ native_sp_level.demo.is_available = (native_sp_level.demo.length > 0);
}
}