Browse Source

option for constant prng seed

Thomas B 1 week ago
parent
commit
c4c9a5ca01
2 changed files with 18 additions and 9 deletions
  1. 13
    0
      src/main.c
  2. 5
    9
      src/sound_over.c

+ 13
- 0
src/main.c View File

@@ -45,6 +45,15 @@
45 45
 #include "table_speed_shot.h"
46 46
 #include "main.h"
47 47
 
48
+/*
49
+ * TODO: The gb-interceptor has problems emulating the
50
+ * DIV register properly. When using it to initialize
51
+ * our random number generator seed, the emulation
52
+ * runs out-of-sync with the real hardware.
53
+ * Using a constant seed 'fixes' this.
54
+ */
55
+//#define CONSTANT_SEED 42
56
+
48 57
 uint8_t debug_menu_index = 0;
49 58
 uint8_t debug_special_value = 0;
50 59
 
@@ -659,9 +668,13 @@ void main(void) NONBANKED {
659 668
 
660 669
     splash();
661 670
 
671
+#ifdef CONSTANT_SEED
672
+    uint16_t seed = CONSTANT_SEED;
673
+#else
662 674
     uint16_t seed = DIV_REG;
663 675
     waitpadup();
664 676
     seed |= ((uint16_t)DIV_REG) << 8;
677
+#endif
665 678
     initarand(seed);
666 679
 
667 680
     while (1) {

+ 5
- 9
src/sound_over.c View File

@@ -32,13 +32,7 @@
32 32
 BANKREF(sound_over)
33 33
 
34 34
 static const enum notes over_notes[] = {
35
-    // fanfare
36
-    /*
37
-     C3,  C3,  C3,  C3, Ab2, Ab2, Bb2, Bb2,
38
-     C3,  C3, SIL, Bb2,  C3,  C3, SIL, SIL,
39
-    */
40
-
41
-    // repeat
35
+    // repeat 1
42 36
 
43 37
     Ab4,  C5, Ab4,  F4, Ab4, Ab4, Ab4,  C5,
44 38
     Ab4,  F4, Ab4, Bb4,  C5, Bb4, Ab4,  F4,
@@ -70,7 +64,7 @@ static const enum notes over_notes[] = {
70 64
     Bb4,  D5, Bb4,  G4, Bb4, Bb4, Bb4, D5,
71 65
     Bb4,  G4, Bb4,  C5,  D5,  C5, Bb4, G4,
72 66
 
73
-    // repeat
67
+    // repeat 2
74 68
 
75 69
     Ab4,  C5, Ab4,  F4, Ab4, Ab4, Ab4,  C5,
76 70
     Ab4,  F4, Ab4, Bb4,  C5, Bb4, Ab4,  F4,
@@ -124,6 +118,8 @@ static const enum notes over_notes[] = {
124 118
      E2, SIL,  E2, SIL,  E2, SIL,  E2, SIL
125 119
 
126 120
 static const enum notes over_notes2[] = {
121
+    // repeat 1
122
+
127 123
     ADD_LOOP, ADD_LOOP_2,
128 124
     ADD_LOOP, ADD_LOOP_3,
129 125
     ADD_LOOP, ADD_LOOP_2,
@@ -138,7 +134,7 @@ static const enum notes over_notes2[] = {
138 134
     SIL, SIL, SIL, SIL, SIL, SIL, SIL, SIL,
139 135
     SIL, SIL, SIL, SIL, SIL, SIL, SIL, SIL,
140 136
 
141
-    // repeat
137
+    // repeat 2
142 138
 
143 139
     ADD_LOOP, ADD_LOOP_2,
144 140
     ADD_LOOP, ADD_LOOP_3,

Loading…
Cancel
Save