paulo@0: /* Replay functionality for LOCKJAW, an implementation of the Soviet Mind Game paulo@0: paulo@0: Copyright (C) 2006 Damian Yerrick paulo@0: paulo@0: This work is free software; you can redistribute it and/or modify paulo@0: it under the terms of the GNU General Public License as published by paulo@0: the Free Software Foundation; either version 2 of the License, or paulo@0: (at your option) any later version. paulo@0: paulo@0: This program is distributed in the hope that it will be useful, paulo@0: but WITHOUT ANY WARRANTY; without even the implied warranty of paulo@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the paulo@0: GNU General Public License for more details. paulo@0: paulo@0: You should have received a copy of the GNU General Public License paulo@0: along with this program; if not, write to the Free Software paulo@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA paulo@0: paulo@0: Original game concept and design by Alexey Pajitnov. paulo@0: The Software is not sponsored or endorsed by Alexey Pajitnov, Elorg, paulo@0: or The Tetris Company LLC. paulo@0: paulo@0: */ paulo@0: #ifndef LJREPLAY_H paulo@0: #define LJREPLAY_H paulo@0: paulo@0: #include "lj.h" paulo@0: #include "ljcontrol.h" paulo@0: paulo@0: #define LJREPLAY_EOF (-1) paulo@0: paulo@0: typedef struct LJReplay LJReplay; paulo@0: paulo@0: /** paulo@0: * Creates a new replay. paulo@0: * @param filename The name of the file to which the replay is recorded. paulo@0: * @param p The field that is observed. paulo@0: * @return A pointer to the replay object, paulo@0: * or NULL if allocation failed. paulo@0: */ paulo@0: LJReplay *newReplay(const char *filename, LJField *p); paulo@0: paulo@0: /** paulo@0: * Records a single frame of input in the replay. paulo@0: * If spawn or hold sound is played, records the new piece. paulo@0: * @param r The replay object. paulo@0: */ paulo@0: void replayRecord(LJReplay *r, LJBits keys, const LJInput *in); paulo@0: paulo@0: /** paulo@0: * Stops recording the replay and dumps it to the file. paulo@0: */ paulo@0: void replayClose(LJReplay *r); paulo@0: paulo@0: /** paulo@0: * Opens an existing replay. paulo@0: * @param filename The name of the file to which the replay is recorded. paulo@0: * @param p The field that is observed. paulo@0: * @return A pointer to the replay object, paulo@0: * or NULL if allocation failed. paulo@0: */ paulo@0: LJReplay *openReplay(const char *filename, LJField *p); paulo@0: paulo@0: /** paulo@0: * @param d The structure to be filled with input paulo@0: * @return The keys pressed, or REPLAY_EOF. paulo@0: */ paulo@0: int getReplayFrame(LJReplay *r, LJInput *d); paulo@0: paulo@0: #endif