Mercurial > vba-linux
comparison src/common/movie.cpp @ 39:3e36553d0cbf
got some speedruns to work!
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 05 Mar 2012 16:37:38 -0600 |
parents | 47a513ea3529 |
children |
comparison
equal
deleted
inserted
replaced
38:b374503a5b31 | 39:3e36553d0cbf |
---|---|
926 | 926 |
927 if (!alreadyOpen) | 927 if (!alreadyOpen) |
928 change_state(MOVIE_STATE_NONE); // stop current movie when we're able to open the other one | 928 change_state(MOVIE_STATE_NONE); // stop current movie when we're able to open the other one |
929 | 929 |
930 // clear out the current movie | 930 // clear out the current movie |
931 printf("RLM: movie init\n"); | 931 //printf("RLM: movie init\n"); |
932 | 932 |
933 VBAMovieInit(); | 933 VBAMovieInit(); |
934 | 934 |
935 // fill in the movie's header | 935 // fill in the movie's header |
936 Movie.header.uid = (uint32)time(NULL); | 936 Movie.header.uid = (uint32)time(NULL); |
947 SetRecordEmuSettings(); | 947 SetRecordEmuSettings(); |
948 | 948 |
949 // set ROM and BIOS checksums and stuff | 949 // set ROM and BIOS checksums and stuff |
950 VBAMovieGetRomInfo(Movie, Movie.header.romTitle, Movie.header.romGameCode, Movie.header.romOrBiosChecksum, Movie.header.romCRC); | 950 VBAMovieGetRomInfo(Movie, Movie.header.romTitle, Movie.header.romGameCode, Movie.header.romOrBiosChecksum, Movie.header.romCRC); |
951 | 951 |
952 printf("RLM: Writing movie header\n"); | 952 //printf("RLM: Writing movie header\n"); |
953 // write the header to file | 953 // write the header to file |
954 write_movie_header(file, Movie); | 954 write_movie_header(file, Movie); |
955 | 955 |
956 printf("RLM: setting metadata\n"); | 956 //printf("RLM: setting metadata\n"); |
957 | 957 |
958 // copy over the metadata / author info | 958 // copy over the metadata / author info |
959 VBAMovieSetMetadata("________________Robert McIntyre______________________________________________________________________________________________________________________________________________________________________________________________________________________"); | 959 VBAMovieSetMetadata("________________Robert McIntyre______________________________________________________________________________________________________________________________________________________________________________________________________________________"); |
960 | 960 |
961 printf("RLM: writing metadata\n"); | 961 //printf("RLM: writing metadata\n"); |
962 | 962 |
963 // write the metadata / author info to file | 963 // write the metadata / author info to file |
964 | 964 |
965 | 965 |
966 fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, file); | 966 fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, file); |
1167 | 1167 |
1168 // this function should only be called once every frame | 1168 // this function should only be called once every frame |
1169 void VBAMovieUpdateState() | 1169 void VBAMovieUpdateState() |
1170 { | 1170 { |
1171 ++Movie.currentFrame; | 1171 ++Movie.currentFrame; |
1172 printf("RLM: inside updateState\n"); | 1172 //printf("RLM: inside updateState\n"); |
1173 if (Movie.state == MOVIE_STATE_PLAY) | 1173 if (Movie.state == MOVIE_STATE_PLAY) |
1174 { | 1174 { |
1175 Movie.inputBufferPtr += Movie.bytesPerFrame; | 1175 Movie.inputBufferPtr += Movie.bytesPerFrame; |
1176 if (Movie.currentFrame >= Movie.header.length_frames) | 1176 if (Movie.currentFrame >= Movie.header.length_frames) |
1177 { | 1177 { |
1179 change_state(MOVIE_STATE_END); | 1179 change_state(MOVIE_STATE_END); |
1180 } | 1180 } |
1181 } | 1181 } |
1182 else if (Movie.state == MOVIE_STATE_RECORD) | 1182 else if (Movie.state == MOVIE_STATE_RECORD) |
1183 { | 1183 { |
1184 printf("RLM: Movie_STATE_RECORD\n"); | 1184 //printf("RLM: Movie_STATE_RECORD\n"); |
1185 VBAMovieWrite(0,true); | 1185 VBAMovieWrite(0,true); |
1186 // use first fseek? | 1186 // use first fseek? |
1187 //TODO: THis is the problem. | 1187 //TODO: THis is the problem. |
1188 if (Movie.inputBuffer){ | 1188 if (Movie.inputBuffer){ |
1189 fwrite(Movie.inputBufferPtr, 1, Movie.bytesPerFrame, Movie.file); | 1189 fwrite(Movie.inputBufferPtr, 1, Movie.bytesPerFrame, Movie.file); |
1190 } | 1190 } |
1191 printf("RLM: write successful.\n"); | 1191 //printf("RLM: write successful.\n"); |
1192 Movie.header.length_frames = Movie.currentFrame; | 1192 Movie.header.length_frames = Movie.currentFrame; |
1193 Movie.inputBufferPtr += Movie.bytesPerFrame; | 1193 Movie.inputBufferPtr += Movie.bytesPerFrame; |
1194 Movie.RecordedThisSession = true; | 1194 Movie.RecordedThisSession = true; |
1195 flush_movie_header(); | 1195 flush_movie_header(); |
1196 } | 1196 } |
1214 } | 1214 } |
1215 else | 1215 else |
1216 { | 1216 { |
1217 currentButtons[i] = 0; // pretend the controller is disconnected | 1217 currentButtons[i] = 0; // pretend the controller is disconnected |
1218 } | 1218 } |
1219 | 1219 |
1220 if ((currentButtons[i] & BUTTON_MASK_NEW_RESET) != 0) | 1220 printf("RLM: button %d\n",currentButtons[i]); |
1221 if ((currentButtons[i] & BUTTON_MASK_NEW_RESET) != 0){ | |
1222 printf("RLM: reset signaled\n"); | |
1221 resetSignaled = true; | 1223 resetSignaled = true; |
1224 } | |
1222 } | 1225 } |
1223 | 1226 |
1224 void VBAMovieWrite(int i, bool /*sensor*/) | 1227 void VBAMovieWrite(int i, bool /*sensor*/) |
1225 { | 1228 { |
1226 if (Movie.state != MOVIE_STATE_RECORD) | 1229 if (Movie.state != MOVIE_STATE_RECORD) |
1233 | 1236 |
1234 if (Movie.header.controllerFlags) | 1237 if (Movie.header.controllerFlags) |
1235 { | 1238 { |
1236 // get the current controller data | 1239 // get the current controller data |
1237 uint16 buttonData = currentButtons[i]; | 1240 uint16 buttonData = currentButtons[i]; |
1238 printf("RLM: currentButtons %i\n", currentButtons[0]); | 1241 //printf("RLM: currentButtons %i\n", currentButtons[0]); |
1239 | 1242 |
1240 // mask away the irrelevent bits | 1243 // mask away the irrelevent bits |
1241 buttonData &= BUTTON_REGULAR_MASK | BUTTON_MOTION_MASK; | 1244 buttonData &= BUTTON_REGULAR_MASK | BUTTON_MOTION_MASK; |
1242 | 1245 |
1243 // soft-reset "button" for 1 frame if the game is reset while recording | 1246 // soft-reset "button" for 1 frame if the game is reset while recording |
1667 // write the metadata / author info to file | 1670 // write the metadata / author info to file |
1668 fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, Movie.file); | 1671 fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, Movie.file); |
1669 | 1672 |
1670 fflush(Movie.file); | 1673 fflush(Movie.file); |
1671 } | 1674 } |
1672 printf("RLM: setMetadata called\n"); | 1675 //printf("RLM: setMetadata called\n"); |
1673 | 1676 |
1674 } | 1677 } |
1675 | 1678 |
1676 void VBAMovieRestart() | 1679 void VBAMovieRestart() |
1677 { | 1680 { |