changeset 58:1cccf6d964b7

*** empty log message ***
author gongo
date Thu, 09 Nov 2006 01:43:07 +0000
parents dfe6a2fb031a
children 035e56b8614c
files game.c game.h linda.c linda.h schedule.c
diffstat 5 files changed, 92 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/game.c	Wed Nov 08 12:35:55 2006 +0000
+++ b/game.c	Thu Nov 09 01:43:07 2006 +0000
@@ -24,9 +24,6 @@
 
 Game game;
 
-extern void sche_game_init();
-extern void set_schedule(void*);
-
 static Bool
 ret()
 {
@@ -44,7 +41,6 @@
 game_main()
 {
     Bool flg = TRUE;
-    set_schedule(sche_game_init);
 
     game.play_id = linda_init();
 
--- a/game.h	Wed Nov 08 12:35:55 2006 +0000
+++ b/game.h	Thu Nov 09 01:43:07 2006 +0000
@@ -3,7 +3,6 @@
  */
 
 typedef struct game {
-    void* (*exec)();
     Bool (*linda_exec)();
     CarPtr jiki;
     int course_id;   // $B%3!<%9(BID
--- a/linda.c	Wed Nov 08 12:35:55 2006 +0000
+++ b/linda.c	Thu Nov 09 01:43:07 2006 +0000
@@ -110,25 +110,22 @@
 }
 
 static Bool
-linda_sche_wait0()
+linda_sche_wait0(int p)
 {
     int i, flg=0;
     int id = game.play_id;
     int connect = 1; // 接続済みユーザ数
 
     for (i=1; i<=CLIENT_MAX; i++) {
+	if (i == id) continue;
 	get_packet(i, &flg, NULL, NULL, NULL, NULL);
-	if (i == id) {
-	    flg = 0;
-	    continue;
-	}
 	if (flg == 1) {
 	    connect++;
 	    flg = 0;
 	}
     }
 
-    if (connect == CLIENT_MAX) {
+    if (p == 1 && connect == CLIENT_MAX) {
 	linda_set_schedule(linda_sche_wait_ready0, MODE_WAIT_READY);
 	return TRUE;
     } else {
@@ -138,7 +135,7 @@
 }
 
 static Bool
-linda_sche_wait1()
+linda_sche_wait1(int p)
 {
     int mode;
 
@@ -153,13 +150,14 @@
 }
 
 static Bool
-linda_sche_wait_ready0()
+linda_sche_wait_ready0(int p)
 {
     int i, flg, mode;
     int id = game.play_id;
     int connect = 1;
 
     for (i=1; i<=CLIENT_MAX; i++) {
+	if (i == id) continue;
 	get_packet(i, &flg, &mode, NULL, NULL, NULL);
 	if (i == id) {
 	    flg = 0;
@@ -171,7 +169,7 @@
 	}
     }
 
-    if (connect == CLIENT_MAX) {
+    if (p == 1 && connect == CLIENT_MAX) {
 	linda_set_schedule(linda_sche_opening0, MODE_OPENING);
 	return TRUE;
     } else {
@@ -181,7 +179,7 @@
 }
 
 static Bool
-linda_sche_wait_ready1()
+linda_sche_wait_ready1(int p)
 {
     int mode;
 
@@ -196,25 +194,22 @@
 }
 
 static Bool
-linda_sche_opening0()
+linda_sche_opening0(int p)
 {
     int i, flg, mode;
     int id = game.play_id;
     int connect = 1;
 
     for (i=1; i<=CLIENT_MAX; i++) {
+	if (i == id) continue;
 	get_packet(i, &flg, &mode, NULL, NULL, NULL);
-	if (i == id) {
-	    flg = 0;
-	    continue;
-	}
 	if (flg == 1 && mode == MODE_OPENING) {
 	    connect++;
 	    flg = 0;
 	}
     }
 
-    if (connect == CLIENT_MAX) {
+    if (p == 1 && connect == CLIENT_MAX) {
 	linda_set_schedule(linda_sche_select_car0, MODE_SELECT_CAR);
 	return TRUE;
     } else {
@@ -223,7 +218,7 @@
 }
 
 static Bool
-linda_sche_opening1()
+linda_sche_opening1(int p)
 {
     int mode;
 
@@ -238,25 +233,22 @@
 }
 
 static Bool 
-linda_sche_select_car0()
+linda_sche_select_car0(int p)
 {
     int i, flg, mode;
     int id = game.play_id;
     int connect = 1;
 
     for (i=1; i<=CLIENT_MAX; i++) {
+	if (i == id) continue;
 	get_packet(i, &flg, &mode, NULL, NULL, NULL);
-	if (i == id) {
-	    flg = 0;
-	    continue;
-	}
 	if (flg == 1 && mode == MODE_SELECT_CAR) {
 	    connect++;
 	    flg = 0;
 	}
     }
 
-    if (connect == CLIENT_MAX) {
+    if (p == 1 && connect == CLIENT_MAX) {
 	linda_set_schedule(linda_sche_select_course0, MODE_SELECT_COURSE);
 	return TRUE;
     } else {
@@ -265,7 +257,7 @@
 }
 
 static Bool
-linda_sche_select_car1()
+linda_sche_select_car1(int p)
 {
     int mode;
 
@@ -280,7 +272,7 @@
 }
 
 static Bool
-linda_sche_select_course0()
+linda_sche_select_course0(int p)
 {
     int i;
     int flg, mode;
@@ -290,17 +282,14 @@
 
     if (course_id != game.course_id) {
 	course_id = game.course_id;
-	linda_seq[game.play_id] = psx_in(game.play_id);
-	send_packet(game.play_id, MODE_SELECT_COURSE, 0, course_id, NULL);
+	linda_seq[id] = psx_in(id);
+	send_packet(id, MODE_SELECT_COURSE, 0, course_id, NULL);
 	return FALSE;
     }
 
     for (i=1; i<=CLIENT_MAX; i++) {
+	if (i == id) continue;
 	get_packet(i, &flg, &mode, NULL, NULL, NULL);
-	if (i == id) {
-	    flg = 0;
-	    continue;
-	}
 	if (flg == 1 && mode == MODE_SELECT_COURSE) {
 	    connect++;
 	    flg = 0;
@@ -308,7 +297,7 @@
 
     }
 
-    if (connect == CLIENT_MAX) {
+    if (p == 1 && connect == CLIENT_MAX) {
 	linda_set_schedule(linda_sche_ready0, MODE_READY);
 	return TRUE;
     } else {
@@ -317,7 +306,7 @@
 }
 
 static Bool
-linda_sche_select_course1()
+linda_sche_select_course1(int p)
 {
     int mode, course_id;
 
@@ -336,35 +325,39 @@
 
 
 static Bool
-linda_sche_ready0()
+linda_sche_ready0(int p)
 {
     linda_set_schedule(linda_sche_main0, MODE_MAIN);
     return TRUE;
 }
 
 static Bool
-linda_sche_ready1()
+linda_sche_ready1(int p)
 {
     linda_set_schedule(linda_sche_main1, MODE_MAIN);
     return TRUE;
 }
 
 static Bool
-linda_sche_main0()
+linda_sche_main0(int p)
 {
     FMATRIX data;
+    static int i=0;
 
-    ps2_vu0_unit_matrix(data);
-    ps2_vu0_copy_matrix(data, game.jiki->body->transfer);
-    ps2_vu0_copy_vector(data[3], game.jiki->location);
-
-    linda_seq[game.play_id] = psx_in(game.play_id);
-    send_packet(game.play_id, MODE_MAIN, 1, 1, (char*)data);
+    if (i++ > 100) {
+	ps2_vu0_unit_matrix(data);
+	ps2_vu0_copy_matrix(data, game.jiki->body->transfer);
+	ps2_vu0_copy_vector(data[3], game.jiki->location);
+	
+	linda_seq[game.play_id] = psx_in(game.play_id);
+	send_packet(game.play_id, MODE_MAIN, 1, 1, (char*)data);
+	i = 0;
+    }
     return FALSE;
 }
 
 static Bool
-linda_sche_main1()
+linda_sche_main1(int p)
 {
     int mode;
     FMATRIX po;
@@ -573,6 +566,11 @@
 }
 #endif
 
+void
+linda_update()
+{
+}
+
 static int
 get_id()
 {
--- a/linda.h	Wed Nov 08 12:35:55 2006 +0000
+++ b/linda.h	Thu Nov 09 01:43:07 2006 +0000
@@ -41,17 +41,17 @@
 
 #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();
-static Bool linda_sche_main0();
-static Bool linda_sche_main1();
+static Bool linda_sche_wait0(int);
+static Bool linda_sche_wait1(int);
+static Bool linda_sche_wait_ready0(int);
+static Bool linda_sche_wait_ready1(int);
+static Bool linda_sche_opening0(int);
+static Bool linda_sche_opening1(int);
+static Bool linda_sche_select_car0(int);
+static Bool linda_sche_select_car1(int);
+static Bool linda_sche_select_course0(int);
+static Bool linda_sche_select_course1(int);
+static Bool linda_sche_ready0(int);
+static Bool linda_sche_ready1(int);
+static Bool linda_sche_main0(int);
+static Bool linda_sche_main1(int);
--- a/schedule.c	Wed Nov 08 12:35:55 2006 +0000
+++ b/schedule.c	Thu Nov 09 01:43:07 2006 +0000
@@ -53,10 +53,21 @@
 
 static int i=0;
 
-void
-set_schedule(void *func)
+static void *sche_func_assumption;
+static void *sche_func = &sche_game_init;
+static int change_state = 0;
+static void
+set_schedule_assumption(void *_func)
 {
-    game.exec = func;
+    sche_func_assumption = _func;
+    change_state = 1;
+}
+
+static void
+set_schedule()
+{
+    sche_func = sche_func_assumption;
+    change_state = 0;
 }
 
 static void
@@ -99,9 +110,9 @@
     camera_init();
 
 #ifdef LINDA
-    set_schedule(sche_game_wait);
+    set_schedule_assumption(sche_game_wait);
 #else
-    set_schedule(sche_game_opening);
+    set_schedule_assumption(sche_game_opening);
 #endif
 }
 
@@ -114,7 +125,7 @@
 {
     gFont_SetString("WAITING...", 200, 100);
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_wait_ready);
+	set_schedule_assumption(sche_game_wait_ready);
 }
 
 /**
@@ -131,7 +142,7 @@
     }
 
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_opening);
+	set_schedule_assumption(sche_game_opening);
     
 WAIT_READY:
     return;
@@ -151,7 +162,7 @@
     }
 
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_select_car);
+	set_schedule_assumption(sche_game_select_car);
 
 OPENING:
     return;
@@ -194,7 +205,7 @@
 	if (pad.circle != 1) { goto SELECT_CAR; }
 
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_select_course);
+	set_schedule_assumption(sche_game_select_course);
     
 SELECT_CAR:
     return;
@@ -227,7 +238,7 @@
     }
 
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_ready);
+	set_schedule_assumption(sche_game_ready);
 
 SELECT_COURSE:
     return;
@@ -250,14 +261,14 @@
     blink_count = (blink_count > 70) ? 0 : blink_count + 1;
 
     if (game.linda_exec() == TRUE)
-	set_schedule(sche_game_main_init);
+	set_schedule_assumption(sche_game_main_init);
 
 /*
     if (pad.st == 1) {
-	set_schedule(sche_game_main_init);
+	set_schedule_assumption(sche_game_main_init);
     }
     if (pad.cross > 0) {
-	set_schedule(sche_game_select_car);
+	set_schedule_assumption(sche_game_select_car);
     }
 */
 }
@@ -270,7 +281,7 @@
 	play_init();
     RUNNIG=0;
 
-    set_schedule(sche_game_main);
+    set_schedule_assumption(sche_game_main);
 }
 
 void
@@ -309,7 +320,7 @@
 
     if (game.rap > MAXRAP) {
 	ranking = 1;
-	set_schedule(sche_game_main_goal);
+	set_schedule_assumption(sche_game_main_goal);
     }
 
     gFont_SetStringInt((int)(100.0*game.jiki->speed), 380, 350);
@@ -333,7 +344,7 @@
 	game.camera_type = !game.camera_type;
     }
     if (pad.st == 1) {
-	set_schedule(sche_game_main_pause);
+	set_schedule_assumption(sche_game_main_pause);
     }
 }
 
@@ -357,12 +368,12 @@
 
     if (pad.circle == 1) {
 	if (select == 0) {
-	    set_schedule(sche_game_main);
+	    set_schedule_assumption(sche_game_main);
 	} else {
-	    set_schedule(sche_game_main_finish);
+	    set_schedule_assumption(sche_game_main_finish);
 	}
     } else if (pad.st == 1) {
-	set_schedule(sche_game_main);
+	set_schedule_assumption(sche_game_main);
     } else if (pad.up == 1 || pad.down == 1) {
 	select = !select;
     }
@@ -390,7 +401,7 @@
     carNode_draw();
     camera_update(game.jiki->body->transfer);
     if (pad.st == 1) {
-	set_schedule(sche_game_main_finish);
+	set_schedule_assumption(sche_game_main_finish);
     }
 }
 
@@ -401,7 +412,7 @@
     carNode_destroy();
     game_env_init();
 
-    set_schedule(sche_game_main_finish2);
+    set_schedule_assumption(sche_game_main_finish2);
 }
 
 void
@@ -410,7 +421,7 @@
     gFont_SetString("GAME OVER ...", 200, 200);
 
     if (pad.st == 1) {
-	set_schedule(sche_game_opening);
+	set_schedule_assumption(sche_game_opening);
     }
 }
 
@@ -418,8 +429,11 @@
 void
 schedule()
 {
-    game.exec();
+    sche_func();
     
+    if (linda_update(change_state) == TRUE)
+	set_schedule();
+
     wait_sync();
     swap_dbuff();
     sjoy_poll();