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
 #include "main.h"
31
 #include "main.h"
32
 #include "sample.h"
32
 #include "sample.h"
33
 #include "window.h"
33
 #include "window.h"
34
+#include "multiplayer.h"
34
 #include "game.h"
35
 #include "game.h"
35
 
36
 
36
 #define BAR_OFFSET_X (4 - 80)
37
 #define BAR_OFFSET_X (4 - 80)
137
     }
138
     }
138
 }
139
 }
139
 
140
 
140
-int32_t game(void) NONBANKED {
141
+int32_t game(enum GAME_MODE mode) NONBANKED {
141
     snd_music_off();
142
     snd_music_off();
142
     snd_note_off();
143
     snd_note_off();
143
 
144
 
159
 
160
 
160
     obj_init();
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
     win_init(0);
169
     win_init(0);
176
     while(1) {
179
     while(1) {
177
         key_read();
180
         key_read();
178
 
181
 
182
+        if (mode != GM_SINGLE) {
183
+            mp_handle();
184
+        }
185
+
179
         enum ACCELERATION acc = 0;
186
         enum ACCELERATION acc = 0;
180
         int32_t prev_score = score;
187
         int32_t prev_score = score;
181
 
188
 

+ 6
- 2
src/game.h View File

25
 #define HEALTH_MAX 0x1FF
25
 #define HEALTH_MAX 0x1FF
26
 #define HEALTH_SHIFT 1
26
 #define HEALTH_SHIFT 1
27
 
27
 
28
-// TODO ?
29
 #define SHOT_SPEED 42 //23
28
 #define SHOT_SPEED 42 //23
30
 #define MAX_TRAVEL 64 //128
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
 #endif // __GAME_H__
38
 #endif // __GAME_H__

+ 1
- 1
src/main.c View File

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

+ 9
- 2
src/multiplayer.c View File

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

+ 3
- 0
src/multiplayer.h View File

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

Loading…
Cancel
Save