Browse Source

more multiplayer preparations

Thomas B 1 month ago
parent
commit
96e8361ace
5 changed files with 29 additions and 8 deletions
  1. 10
    3
      src/game.c
  2. 6
    2
      src/game.h
  3. 1
    1
      src/main.c
  4. 9
    2
      src/multiplayer.c
  5. 3
    0
      src/multiplayer.h

+ 10
- 3
src/game.c View File

@@ -31,6 +31,7 @@
31 31
 #include "main.h"
32 32
 #include "sample.h"
33 33
 #include "window.h"
34
+#include "multiplayer.h"
34 35
 #include "game.h"
35 36
 
36 37
 #define BAR_OFFSET_X (4 - 80)
@@ -137,7 +138,7 @@ static void show_explosion(uint16_t power) NONBANKED {
137 138
     }
138 139
 }
139 140
 
140
-int32_t game(void) NONBANKED {
141
+int32_t game(enum GAME_MODE mode) NONBANKED {
141 142
     snd_music_off();
142 143
     snd_note_off();
143 144
 
@@ -159,8 +160,10 @@ int32_t game(void) NONBANKED {
159 160
 
160 161
     obj_init();
161 162
 
162
-    if (!(conf_get()->debug_flags & DBG_NO_OBJ)) {
163
-        obj_spawn();
163
+    if (mode == GM_SINGLE) {
164
+        if (!(conf_get()->debug_flags & DBG_NO_OBJ)) {
165
+            obj_spawn();
166
+        }
164 167
     }
165 168
 
166 169
     win_init(0);
@@ -176,6 +179,10 @@ int32_t game(void) NONBANKED {
176 179
     while(1) {
177 180
         key_read();
178 181
 
182
+        if (mode != GM_SINGLE) {
183
+            mp_handle();
184
+        }
185
+
179 186
         enum ACCELERATION acc = 0;
180 187
         int32_t prev_score = score;
181 188
 

+ 6
- 2
src/game.h View File

@@ -25,10 +25,14 @@
25 25
 #define HEALTH_MAX 0x1FF
26 26
 #define HEALTH_SHIFT 1
27 27
 
28
-// TODO ?
29 28
 #define SHOT_SPEED 42 //23
30 29
 #define MAX_TRAVEL 64 //128
31 30
 
32
-int32_t game(void);
31
+enum GAME_MODE {
32
+    GM_SINGLE = 0,
33
+    GM_MULTI,
34
+};
35
+
36
+int32_t game(enum GAME_MODE mode);
33 37
 
34 38
 #endif // __GAME_H__

+ 1
- 1
src/main.c View File

@@ -593,7 +593,7 @@ void main(void) NONBANKED {
593 593
     initarand(seed);
594 594
 
595 595
     while (1) {
596
-        int32_t score = game();
596
+        int32_t score = game(GM_SINGLE);
597 597
 
598 598
         if ((!(conf_get()->debug_flags & DBG_GOD_MODE)) && (score != 0) && score_ranking(score)) {
599 599
             uint16_t name = ask_name(score);

+ 9
- 2
src/multiplayer.c View File

@@ -38,6 +38,7 @@ enum mp_state {
38 38
 
39 39
 static enum mp_state state = 0;
40 40
 static uint16_t next_t = 0;
41
+static uint8_t our_turn = 0;
41 42
 
42 43
 uint8_t mp_connection_status = 0;
43 44
 
@@ -88,7 +89,8 @@ uint8_t mp_master_ready(void) BANKED {
88 89
 }
89 90
 
90 91
 void mp_master_start(void) BANKED {
91
-    game(); // TODO
92
+    our_turn = 1;
93
+    game(GM_MULTI);
92 94
     state = 0;
93 95
 }
94 96
 
@@ -139,6 +141,11 @@ uint8_t mp_slave_ready(void) BANKED {
139 141
 }
140 142
 
141 143
 void mp_slave_start(void) BANKED {
142
-    game(); // TODO
144
+    our_turn = 0;
145
+    game(GM_MULTI);
143 146
     state = 0;
144 147
 }
148
+
149
+void mp_handle(void) BANKED {
150
+
151
+}

+ 3
- 0
src/multiplayer.h View File

@@ -25,9 +25,12 @@
25 25
 
26 26
 uint8_t mp_master_ready(void) BANKED;
27 27
 void mp_master_start(void) BANKED;
28
+
28 29
 uint8_t mp_slave_ready(void) BANKED;
29 30
 void mp_slave_start(void) BANKED;
30 31
 
32
+void mp_handle(void) BANKED;
33
+
31 34
 extern uint8_t mp_connection_status;
32 35
 
33 36
 #endif // __MULTIPLAYER_H__

Loading…
Cancel
Save