int sx = (mx - SX) / TILEX;
int sy = (my - SY) / TILEY;
- if (IN_SCR_FIELD(sx,sy))
+ if (IN_VIS_FIELD(sx,sy))
{
int x = LEVELX(sx);
int y = LEVELY(sy);
{
int joystick = Joystick();
int keyboard = key_joystick_mapping;
+
+ /*
int joy = (tape.playing ? TapePlayAction() : (joystick | keyboard));
+ */
+
+ int joy = (joystick | keyboard);
int left = joy & JOY_LEFT;
int right = joy & JOY_RIGHT;
int up = joy & JOY_UP;
char filename[MAX_FILENAME];
char cookie[MAX_FILENAME];
FILE *file;
+ BOOL levelrec_10 = FALSE;
#ifndef MSDOS
sprintf(filename,"%s/%s/%d.tape",
{
fgets(cookie,LEVELREC_COOKIE_LEN,file);
fgetc(file);
- if (strcmp(cookie,LEVELREC_COOKIE)) /* ungültiges Format? */
+ if (!strcmp(cookie,LEVELREC_COOKIE_10)) /* old 1.0 tape format */
+ levelrec_10 = TRUE;
+ else if (strcmp(cookie,LEVELREC_COOKIE)) /* unknown tape format */
{
fprintf(stderr,"%s: wrong format of level recording file '%s'!\n",
progname,filename);
for(i=0;i<tape.length;i++)
{
- if (i>=MAX_TAPELEN)
+ int j;
+
+ if (i >= MAX_TAPELEN)
break;
- tape.pos[i].joystickdata = fgetc(file);
- tape.pos[i].delay = fgetc(file);
+
+ for(j=0; j<MAX_PLAYERS; j++)
+ {
+ if (levelrec_10 && j>0)
+ {
+ tape.pos[i].joystickdata[j] = MV_NO_MOVING;
+ continue;
+ }
+ tape.pos[i].joystickdata[j] = fgetc(file);
+ }
+
+ tape.pos[i].delay = fgetc(file);
+
if (feof(file))
break;
}
for(i=0;i<tape.length;i++)
{
- fputc(tape.pos[i].joystickdata,file);
+ int j;
+
+ for(j=0; j<MAX_PLAYERS; j++)
+ fputc(tape.pos[i].joystickdata[j],file);
+
fputc(tape.pos[i].delay,file);
}
void PlayerActions(struct PlayerInfo *player, int player_action)
{
+ static int stored_player_action[MAX_PLAYERS];
+ static int num_stored_actions = 0;
BOOL moved = FALSE, snapped = FALSE, bombed = FALSE;
int jx = player->jx, jy = player->jy;
int left = player_action & JOY_LEFT;
int dx = (left ? -1 : right ? 1 : 0);
int dy = (up ? -1 : down ? 1 : 0);
+ stored_player_action[player->nr] = 0;
+ num_stored_actions++;
+
if (!player->active || player->gone)
return;
{
if (bombed && !moved)
player_action &= JOY_BUTTON;
- TapeRecordAction(player_action);
+
+ stored_player_action[player->nr] = player_action;
+
+ /* this allows cycled sequences of PlayerActions() */
+ if (num_stored_actions >= MAX_PLAYERS)
+ {
+ TapeRecordAction(stored_player_action);
+ num_stored_actions = 0;
+ }
}
else if (tape.playing && snapped)
SnapField(player, 0,0); /* stop snapping */
if (tape.playing && !tape.pausing && !player_action &&
tape.counter < tape.length)
{
- int next_joy = tape.pos[tape.counter].joystickdata & (JOY_LEFT|JOY_RIGHT);
+ int next_joy =
+ tape.pos[tape.counter].joystickdata[player->nr] & (JOY_LEFT|JOY_RIGHT);
if (next_joy == JOY_LEFT || next_joy == JOY_RIGHT)
{
long action_delay_value;
int sieb_x = 0, sieb_y = 0;
int i, x,y, element;
+ int *recorded_player_action;
if (game_status != PLAYING)
return;
/* main game synchronization point */
WaitUntilDelayReached(&action_delay, action_delay_value);
+ if (tape.playing)
+ recorded_player_action = TapePlayAction();
+ else
+ recorded_player_action = NULL;
+
for(i=0; i<MAX_PLAYERS; i++)
{
+ int actual_player_action = player_action;
/* TEST TEST TEST */
if (i != TestPlayer && !stored_player[i].MovPos)
- continue;
+ actual_player_action = 0;
/* TEST TEST TEST */
- PlayerActions(&stored_player[i], player_action);
+ if (recorded_player_action)
+ actual_player_action = recorded_player_action[i];
+
+ PlayerActions(&stored_player[i], actual_player_action);
ScrollFigure(&stored_player[i], SCROLL_GO_ON);
}
#define JOY_RIGHT MV_RIGHT
#define JOY_UP MV_UP
#define JOY_DOWN MV_DOWN
-#define JOY_BUTTON_1 16
-#define JOY_BUTTON_2 32
+#define JOY_BUTTON_1 (1<<4)
+#define JOY_BUTTON_2 (1<<5)
#define JOY_BUTTON (JOY_BUTTON_1 | JOY_BUTTON_2)
#define JOY_BUTTON_NOT_PRESSED 0
#define JOY_BUTTON_PRESSED 1
BOOL changed;
struct
{
- unsigned char joystickdata;
+ unsigned char joystickdata[MAX_PLAYERS];
unsigned char delay;
} pos[MAX_TAPELEN];
};
/* directions for moving */
#define MV_NO_MOVING 0
-#define MV_LEFT 1
-#define MV_RIGHT 2
-#define MV_UP 4
-#define MV_DOWN 8
+#define MV_LEFT (1<<0)
+#define MV_RIGHT (1<<1)
+#define MV_UP (1<<2)
+#define MV_DOWN (1<<3)
/* font types */
#define FS_SMALL 0
/* old cookies */
#define NAMES_COOKIE_10 "ROCKSNDIAMONDS_NAMES_FILE_VERSION_1.0"
+#define LEVELREC_COOKIE_10 "ROCKSNDIAMONDS_LEVELREC_FILE_VERSION_1.0"
#define LEVEL_COOKIE "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.0"
#define SCORE_COOKIE "ROCKSNDIAMONDS_SCORE_FILE_VERSION_1.0"
#define NAMES_COOKIE "ROCKSNDIAMONDS_NAMES_FILE_VERSION_1.1"
#define LEVELDIR_COOKIE "ROCKSNDIAMONDS_LEVELDIR_FILE_VERSION_1.0"
-#define LEVELREC_COOKIE "ROCKSNDIAMONDS_LEVELREC_FILE_VERSION_1.0"
+#define LEVELREC_COOKIE "ROCKSNDIAMONDS_LEVELREC_FILE_VERSION_1.2"
#define JOYSTICK_COOKIE "ROCKSNDIAMONDS_JOYSTICK_FILE_VERSION_1.0"
#define LEVEL_COOKIE_LEN (strlen(LEVEL_COOKIE)+1)
#define SCORE_COOKIE_LEN (strlen(SCORE_COOKIE)+1)
void TapeStopRecording()
{
+ int i;
+
if (!tape.recording)
return;
- tape.pos[tape.counter].joystickdata = 0;
+ for(i=0; i<MAX_PLAYERS; i++)
+ tape.pos[tape.counter].joystickdata[i] = 0;
+
tape.counter++;
tape.length = tape.counter;
tape.length_seconds = GetTapeLength();
DrawVideoDisplay(VIDEO_STATE_REC_OFF,0);
}
-void TapeRecordAction(int joy)
+void TapeRecordAction(int joy[MAX_PLAYERS])
{
+ int i;
+
if (!tape.recording || tape.pausing)
return;
return;
}
- if (joy)
- {
- tape.pos[tape.counter].joystickdata = joy;
- tape.counter++;
- tape.pos[tape.counter].delay = 0;
- }
+ for(i=0; i<MAX_PLAYERS; i++)
+ tape.pos[tape.counter].joystickdata[i] = joy[i];
+
+ tape.counter++;
+ tape.pos[tape.counter].delay = 0;
}
void TapeRecordDelay()
{
+ int i;
+
if (!tape.recording || tape.pausing)
return;
tape.pos[tape.counter].delay++;
- if (tape.pos[tape.counter].delay>=255)
+ if (tape.pos[tape.counter].delay >= 255)
{
- tape.pos[tape.counter].joystickdata = 0;
+ for(i=0; i<MAX_PLAYERS; i++)
+ tape.pos[tape.counter].joystickdata[i] = 0;
+
tape.counter++;
tape.pos[tape.counter].delay = 0;
}
DrawVideoDisplay(VIDEO_STATE_PLAY_OFF,0);
}
-int TapePlayAction()
+int *TapePlayAction()
{
+ static int joy[MAX_PLAYERS];
+ int i;
+
if (!tape.playing || tape.pausing)
- return(0);
+ return(NULL);
if (tape.counter>=tape.length)
{
TapeStop();
- return(0);
+ return(NULL);
}
if (tape.delay_played == tape.pos[tape.counter].delay)
{
tape.delay_played = 0;
tape.counter++;
- return(tape.pos[tape.counter-1].joystickdata);
+
+ for(i=0; i<MAX_PLAYERS; i++)
+ joy[i] = tape.pos[tape.counter-1].joystickdata[i];
+
+ return(joy);
}
- else
- return(0);
+
+ return(NULL);
}
BOOL TapePlayDelay()
void TapeStartRecording(void);
void TapeStopRecording(void);
-void TapeRecordAction(int);
+void TapeRecordAction(int *);
void TapeRecordDelay(void);
void TapeTogglePause(void);
void TapeStartPlaying(void);
void TapeStopPlaying(void);
-int TapePlayAction(void);
+int *TapePlayAction(void);
BOOL TapePlayDelay(void);
void TapeStop(void);
void TapeErase(void);