changeset 46:abadcc080667

*** empty log message ***
author gongo
date Wed, 08 Nov 2006 06:10:44 +0000
parents d7520785d8a6
children d7e0a5c33540
files Makefile game.c game.h linda.c linda.h schedule.c schedule.h
diffstat 7 files changed, 85 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed Nov 08 05:23:40 2006 +0000
+++ b/Makefile	Wed Nov 08 06:10:44 2006 +0000
@@ -14,7 +14,7 @@
 -I/usr/local/include/ps2util \
 -I./Linda
 
-DEFINES = -DDEBUG #-DLINDA #-DDEMO_CREATE
+DEFINES = -DDEBUG #-DLINDA
 DEBUGFLAGS = -Wall -g
 LIBPS2ARC = /usr/local/lib/libps2a.a
 
--- a/game.c	Wed Nov 08 05:23:40 2006 +0000
+++ b/game.c	Wed Nov 08 06:10:44 2006 +0000
@@ -18,21 +18,30 @@
 /* linda.c */
 #ifdef LINDA
 extern int linda_init();
-#else
-#define linda_init() 1
 #endif
-extern void linda_update();
 
 Game game;
 
 extern void sche_game_init();
 extern void set_schedule(void*);
 
+static Bool
+ret()
+{
+    return TRUE;
+}
+
+static int
+linda_init()
+{
+    game.linda_exec = &ret;
+    return 1;
+}
+
 void
 game_main()
 {
     Bool flg = TRUE;
-    Bool linda_flg = TRUE;
     set_schedule(sche_game_init);
 
     game.play_id = linda_init();
--- a/game.h	Wed Nov 08 05:23:40 2006 +0000
+++ b/game.h	Wed Nov 08 06:10:44 2006 +0000
@@ -4,7 +4,7 @@
 
 typedef struct game {
     void* (*exec)();
-    void* (*linda_exec)();
+    Bool (*linda_exec)();
     CarPtr jiki;
     int course_id;   // $B%3!<%9(BID
     int car_id;      // $B<+5!(BID
--- a/linda.c	Wed Nov 08 05:23:40 2006 +0000
+++ b/linda.c	Wed Nov 08 06:10:44 2006 +0000
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
+#include <arpa/inet.h>
 #include <libps2.h>
 #include <ps2util.h>
 
@@ -12,14 +13,11 @@
 #include "lindaapi.h"
 #include "linda.h"
 
-#define PLAYER_1P 1
-
 extern void carNode_append(CarPtr);
 extern FILE *main_fp;
 static int my_id;
 static CarPtr linda_carlist[CLIENT_MAX+1];
 static int linda_seq[CLIENT_MAX+1];
-static void* sche;
 
 static void
 set_header(unsigned int data, char *pkt, int offset)
@@ -90,11 +88,11 @@
     if (reply) {
 	pkt    = reply+LINDA_HEADER_SIZE;
 
-	if (flg)    flg = 1;
-	if (mode)   mode   = get_header(pkt, PKT_MODE_OFFSET);
-	if (car)    car    = get_header(pkt, PKT_CARID_OFFSET);
-	if (course) course = get_header(pkt, PKT_COURSEID_OFFSET);
-	if (data)   data   = get_header(pkt, PKT_DATA_OFFSET);
+	if (flg)    *flg    = 1;
+	if (mode)   *mode   = get_header(pkt, PKT_MODE_OFFSET);
+	if (car)    *car    = get_header(pkt, PKT_CARID_OFFSET);
+	if (course) *course = get_header(pkt, PKT_COURSEID_OFFSET);
+	//if (data)   data   = get_header(pkt, PKT_DATA_OFFSET);
 
 	psx_free(reply);
 	linda_seq[id] = psx_rd(id);
@@ -113,9 +111,8 @@
 linda_sche_wait0()
 {
     int i, flg=0;
-    int id = game.player_id;
+    int id = game.play_id;
     int connect = 1; // 接続済みユーザ数
-    char *reply = NULL;
 
     for (i=1; i<=CLIENT_MAX+1; i++) {
 	if (i == id) continue;
@@ -153,7 +150,7 @@
 linda_sche_wait_ready0()
 {
     int i, flg, mode;
-    int id = game.player_id;
+    int id = game.play_id;
     int connect = 1;
 
     for (i=1; i<=CLIENT_MAX+1; i++) {
@@ -173,7 +170,7 @@
 
 }
 
-static void
+static Bool
 linda_sche_wait_ready1()
 {
     int mode;
@@ -188,11 +185,11 @@
     }
 }
 
-static void
+static Bool
 linda_sche_opening0()
 {
     int i, flg, mode;
-    int id = game.player_id;
+    int id = game.play_id;
     int connect = 1;
 
     for (i=1; i<=CLIENT_MAX+1; i++) {
@@ -211,7 +208,7 @@
     }
 }
 
-static void
+static Bool
 linda_sche_opening1()
 {
     int mode;
@@ -230,7 +227,7 @@
 linda_sche_select_car0()
 {
     int i, flg, mode;
-    int id = game.player_id;
+    int id = game.play_id;
     int connect = 1;
 
     for (i=1; i<=CLIENT_MAX+1; i++) {
@@ -267,11 +264,15 @@
 static Bool
 linda_sche_select_course0()
 {
+    int i;
+    int flg, mode;
+    int connect;
+    int id = game.play_id;
     static int course_id = 1;
 
     if (course_id != game.course_id) {
 	course_id = game.course_id;
-	send_packet(game.player_id, MODE_SELECT_COURSE, 0, course_id, NULL);
+	send_packet(game.play_id, MODE_SELECT_COURSE, 0, course_id, NULL);
 	return TRUE;
     }
 
@@ -563,9 +564,9 @@
     psx_sync_n();
 
     if (my_id == PLAYER_1P)
-	sche = linda_set_schedule(linda_sche_wait0, MODE_WAIT);
+	linda_set_schedule(linda_sche_wait0, MODE_WAIT);
     else
-	sche = linda_set_schedule(linda_sche_wait1, MODE_WAIT);
+	linda_set_schedule(linda_sche_wait1, MODE_WAIT);
 
     return my_id;
 }
--- a/linda.h	Wed Nov 08 05:23:40 2006 +0000
+++ b/linda.h	Wed Nov 08 06:10:44 2006 +0000
@@ -29,11 +29,27 @@
 #define MODE_WAIT_READY       2
 #define MODE_OPENING          3
 #define MODE_SELECT_CAR       4
-#degine MODE_SELECT_COURSE    5
-#degine MODE_READY            6
-#degine MODE_MAIN_INIT        7
-#degine MODE_MAIN             8
-#degine MODE_MAIN_PAUSE       9
-#degine MODE_MAIN_GOAL       10
-#degine MODE_MAIN_FINISH     11
-#degine MODE_FINISH          12
+#define MODE_SELECT_COURSE    5
+#define MODE_READY            6
+#define MODE_MAIN_INIT        7
+#define MODE_MAIN             8
+#define MODE_MAIN_PAUSE       9
+#define MODE_MAIN_GOAL       10
+#define MODE_MAIN_FINISH     11
+#define MODE_FINISH          12
+
+
+#define PLAYER_1P 1
+
+static Bool linda_sche_wait0();
+static Bool linda_sche_wait1();
+static Bool linda_sche_wait_ready0();
+static Bool linda_sche_wait_ready1();
+static Bool linda_sche_opening0();
+static Bool linda_sche_opening1();
+static Bool linda_sche_select_car0();
+static Bool linda_sche_select_car1();
+static Bool linda_sche_select_course0();
+static Bool linda_sche_select_course1();
+static Bool linda_sche_ready0();
+static Bool linda_sche_ready1();
--- a/schedule.c	Wed Nov 08 05:23:40 2006 +0000
+++ b/schedule.c	Wed Nov 08 06:10:44 2006 +0000
@@ -41,6 +41,8 @@
 /* --- linda.c --- */
 extern void linda_env_init();
 
+
+
 /* timer */
 static int start_time,time_count;
 static int RUNNIG=0;
@@ -96,7 +98,11 @@
     graphic_init();
     camera_init();
 
+#ifdef LINDA
+    set_schedule(sche_game_wait);
+#else
     set_schedule(sche_game_opening);
+#endif
 }
 
 /**
@@ -125,7 +131,7 @@
     }
 
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_wait_opening);
+	set_schedule(sche_game_opening);
     
 WAIT_READY:
     return;
@@ -141,7 +147,7 @@
 	}
 	blink_count = (blink_count > 70) ? 0 : blink_count + 1;
 
-	if (pad.st != 1) { goto LINDA_OPENING; }
+	if (pad.st != 1) { goto OPENING; }
     }
 
     if (game.linda_exec() == TRUE)
@@ -203,9 +209,7 @@
 
     gFont_SetString("SELECT COURSE", 150, 50);
 
-    if (game.player_id == 1) {
-	if (pad.circle != 1) { goto SELECT_COURSE; }
-
+    if (game.play_id == 1) {
 	if (pad.right == 1) {
 	    game.course_id =
 		(game.course_id > MAXFIELD-1) ? 1 : game.course_id + 1;
@@ -218,10 +222,12 @@
 	    game.linda_exec();
 	    goto SELECT_COURSE;
 	}
+
+	if (pad.circle != 1) { goto SELECT_COURSE; }
     }
 
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_select_course);
+	set_schedule(sche_game_ready);
 
 SELECT_COURSE:
     return;
--- a/schedule.h	Wed Nov 08 05:23:40 2006 +0000
+++ b/schedule.h	Wed Nov 08 06:10:44 2006 +0000
@@ -1,14 +1,14 @@
-extern void set_schedule();
-extern void sche_game_init();
-extern static void sche_game_wait();
-extern static void sche_game_wait_ready();
-extern static void sche_game_opening();
-extern static void sche_game_select_car();
-extern static void sche_game_select_course();
-extern static void sche_game_ready();
-extern static void sche_game_main_init();
-extern static void sche_game_main();
-extern static void sche_game_main_pause();
-extern static void sche_game_main_goal();
-extern static void sche_game_main_finish();
-extern static void sche_game_main_finish2();
+void set_schedule();
+void sche_game_init();
+static void sche_game_wait();
+static void sche_game_wait_ready();
+static void sche_game_opening();
+static void sche_game_select_car();
+static void sche_game_select_course();
+static void sche_game_ready();
+static void sche_game_main_init();
+static void sche_game_main();
+static void sche_game_main_pause();
+static void sche_game_main_goal();
+static void sche_game_main_finish();
+static void sche_game_main_finish2();