Browse Source

dont return score struct by value, pass as pointer arg instead. fixes banking score issue strangely.

Thomas B 1 month ago
parent
commit
1d1ddca278
3 changed files with 16 additions and 11 deletions
  1. 10
    3
      src/main.c
  2. 4
    6
      src/score.ba0.c
  3. 2
    2
      src/score.h

+ 10
- 3
src/main.c View File

61
     SHOW_WIN;
61
     SHOW_WIN;
62
 
62
 
63
     for (uint8_t i = 0; i < SCORE_NUM; i++) {
63
     for (uint8_t i = 0; i < SCORE_NUM; i++) {
64
-        struct scores score = is_black ? score_lowest(i) : score_highest(i);
64
+        struct scores score;
65
+        is_black ? score_lowest(i, &score) : score_highest(i, &score);
65
         win_score_draw(score, i, is_black);
66
         win_score_draw(score, i, is_black);
66
     }
67
     }
67
 
68
 
104
         move_win(MINWNDPOSX, MINWNDPOSY);
105
         move_win(MINWNDPOSX, MINWNDPOSY);
105
     } else {
106
     } else {
106
         // initially show the top 1 scores
107
         // initially show the top 1 scores
107
-        int32_t low = score_lowest(0).score;
108
-        int32_t high = score_highest(0).score;
108
+        struct scores score;
109
+
110
+        score_lowest(0, &score);
111
+        int32_t low = score.score;
112
+
113
+        score_highest(0, &score);
114
+        int32_t high = score.score;
115
+
109
         win_splash_draw(-low, high);
116
         win_splash_draw(-low, high);
110
 
117
 
111
         move_win(MINWNDPOSX, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - (8 * 4));
118
         move_win(MINWNDPOSX, MINWNDPOSY + DEVICE_SCREEN_PX_HEIGHT - (8 * 4));

+ 4
- 6
src/score.ba0.c View File

158
     DISABLE_RAM;
158
     DISABLE_RAM;
159
 }
159
 }
160
 
160
 
161
-struct scores score_highest(uint8_t off) BANKED {
161
+void score_highest(uint8_t off, struct scores *t) BANKED {
162
     ENABLE_RAM;
162
     ENABLE_RAM;
163
     SWITCH_RAM(0);
163
     SWITCH_RAM(0);
164
 
164
 
171
     if (off >= SCORE_NUM) {
171
     if (off >= SCORE_NUM) {
172
         off = SCORE_NUM - 1;
172
         off = SCORE_NUM - 1;
173
     }
173
     }
174
-    struct scores r = scores[off];
174
+    *t = scores[off];
175
 
175
 
176
     DISABLE_RAM;
176
     DISABLE_RAM;
177
-    return r;
178
 }
177
 }
179
 
178
 
180
-struct scores score_lowest(uint8_t off) BANKED {
179
+void score_lowest(uint8_t off, struct scores *t) BANKED {
181
     ENABLE_RAM;
180
     ENABLE_RAM;
182
     SWITCH_RAM(0);
181
     SWITCH_RAM(0);
183
 
182
 
190
     if (off >= SCORE_NUM) {
189
     if (off >= SCORE_NUM) {
191
         off = SCORE_NUM - 1;
190
         off = SCORE_NUM - 1;
192
     }
191
     }
193
-    struct scores r = scores[(SCORE_NUM * 2) - 1 - off];
192
+    *t = scores[(SCORE_NUM * 2) - 1 - off];
194
 
193
 
195
     DISABLE_RAM;
194
     DISABLE_RAM;
196
-    return r;
197
 }
195
 }
198
 
196
 
199
 void score_reset(void) BANKED {
197
 void score_reset(void) BANKED {

+ 2
- 2
src/score.h View File

33
 uint16_t convert_name(char a, char b, char c) BANKED;
33
 uint16_t convert_name(char a, char b, char c) BANKED;
34
 uint8_t score_ranking(int32_t score) BANKED;
34
 uint8_t score_ranking(int32_t score) BANKED;
35
 void score_add(struct scores score) BANKED;
35
 void score_add(struct scores score) BANKED;
36
-struct scores score_highest(uint8_t off) BANKED;
37
-struct scores score_lowest(uint8_t off) BANKED;
36
+void score_highest(uint8_t off, struct scores *t) BANKED;
37
+void score_lowest(uint8_t off, struct scores *t) BANKED;
38
 void score_reset(void) BANKED;
38
 void score_reset(void) BANKED;
39
 
39
 
40
 BANKREF_EXTERN(score)
40
 BANKREF_EXTERN(score)

Loading…
Cancel
Save