Mercurial > hg > old > magoroku_racing.bad
diff demo.c @ 0:0fae5658fb0b
Initial revision
author | gongo |
---|---|
date | Thu, 02 Nov 2006 08:55:19 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo.c Thu Nov 02 08:55:19 2006 +0000 @@ -0,0 +1,77 @@ +/* + * $Id$ + */ +#include <stdio.h> +#include <stdlib.h> + +#include <libps2.h> +#include <ps2util.h> +#include "col.h" +#include "field.h" +#include "car.h" +#include "game.h" + +#define BUFSIZE 256 + + +static FILE *fp; +extern FILE *main_fp; +extern Game game; + +char *filename[3] = { + "demo_log1.dat", "demo_log2.dat", "demo_log3.dat"}; + +static char* bufp; + +void +demo_closeFp() +{ + if (fp) { + fclose(fp); +#ifdef DEBUG + fprintf(main_fp, "FILE pointer %x is close\n", (int)fp); +#endif + fp = NULL; + } + bufp = NULL; +} + +void +demo_openFp(int i) +{ +#ifdef DEMO_CREATE + fp = fopen(filename[i], "w"); +#else + char buff[BUFSIZE]; + fp = fopen(filename[i], "r"); + + if ((bufp = fgets(buff, BUFSIZE, fp)) != NULL) { + sscanf(bufp, "%d %d\n", &game.car_id, &game.course_id); + } +#endif + +#ifdef DEBUG + fprintf(main_fp, "FILE pointer %x is open\n", (int)fp); +#endif +} + +#ifdef DEMO_CREATE +void +setPadValue(int pad) +{ + fprintf(fp, "%d\n", pad); +} +#endif + +int +getPadValue() +{ + char buff[BUFSIZE]; + int pad; + + if ((bufp = fgets(buff, BUFSIZE, fp)) != NULL) { + sscanf(bufp, "%d\n", &pad); + } + + return pad; +}