Browse Source

clear save at the beginning of the game

SBird1337 7 years ago
parent
commit
0aee7b3356
4 changed files with 39 additions and 40 deletions
  1. 1
    1
      g3headers
  2. 5
    0
      patches/hooks.asm
  3. 9
    0
      src/savefile/clear_save.c
  4. 24
    39
      src/specials/custom_specials.c

+ 1
- 1
g3headers

1
-Subproject commit cb245518f41d5d508f7c1e70e7b751a2ae4546e8
1
+Subproject commit 04e8a122f208ca1ee8052fef39f2dca51dcffe10

+ 5
- 0
patches/hooks.asm View File

130
 
130
 
131
 //end of var routine
131
 //end of var routine
132
 
132
 
133
+.org 0x0804C034
134
+    ldr r0, =clear_sav1|1
135
+    bx r0
136
+    .pool
137
+
133
 //trainer Flag stuff
138
 //trainer Flag stuff
134
 .org 0x08080378
139
 .org 0x08080378
135
 	ldr r1, =trainerflag_read_fix+1
140
 	ldr r1, =trainerflag_read_fix+1

+ 9
- 0
src/savefile/clear_save.c View File

1
+#include <pokeagb/pokeagb.h>
2
+
3
+extern void sp_init_script(void);
4
+
5
+void clear_sav1(void)
6
+{
7
+    memset(&stdsav1, 0, sizeof(struct SaveBlock1));
8
+    sp_init_script();
9
+}

+ 24
- 39
src/specials/custom_specials.c View File

25
  * @author Sturmvogel
25
  * @author Sturmvogel
26
  * @date 15 dec 2016
26
  * @date 15 dec 2016
27
  * @brief Special 0x68 implementation to read from LASTRESULT and execute
27
  * @brief Special 0x68 implementation to read from LASTRESULT and execute
28
- * 
28
+ *
29
  */
29
  */
30
 
30
 
31
 /* === INCLUDES === */
31
 /* === INCLUDES === */
32
 
32
 
33
-#include "cutscene_meteor.h"
34
 #include "camera_move.h"
33
 #include "camera_move.h"
34
+#include "cutscene_meteor.h"
35
 #include <callback.h>
35
 #include <callback.h>
36
+#include <config.h>
36
 #include <debug.h>
37
 #include <debug.h>
37
 #include <game_engine.h>
38
 #include <game_engine.h>
38
-#include <config.h>
39
 #include <math.h>
39
 #include <math.h>
40
 
40
 
41
 /* === PROTOTYPES === */
41
 /* === PROTOTYPES === */
50
  */
50
  */
51
 void sp_init_script();
51
 void sp_init_script();
52
 
52
 
53
-
54
 /**
53
 /**
55
  * @brief callasm to call a var-based routine as defined
54
  * @brief callasm to call a var-based routine as defined
56
  */
55
  */
68
 
67
 
69
 extern void sp_batchmaptile(void);
68
 extern void sp_batchmaptile(void);
70
 
69
 
71
-
72
 void get_text_pointer_from_lookup();
70
 void get_text_pointer_from_lookup();
73
 
71
 
74
 void sp_check_tileset();
72
 void sp_check_tileset();
78
 /* === STATICS === */
76
 /* === STATICS === */
79
 
77
 
80
 static callback special_routines[9] = {
78
 static callback special_routines[9] = {
81
-    met_play,
82
-    cam_sp_move_camera,
83
-    sp_init_script,
84
-    debug_some_test,
85
-    sp_dns_switch,
86
-    sp_random_number,
87
-    sp_check_tileset,
88
-    sp_batchmaptile,
89
-    sp_crystal_fade,
79
+    met_play,         cam_sp_move_camera, sp_init_script,  debug_some_test, sp_dns_switch,
80
+    sp_random_number, sp_check_tileset,   sp_batchmaptile, sp_crystal_fade,
90
 };
81
 };
91
 
82
 
92
 /* === IMPLEMENTATIONS === */
83
 /* === IMPLEMENTATIONS === */
93
 
84
 
94
-void sp_dns_switch()
95
-{
96
-    volatile u8* test_pointer = (u8*) (0x0203FAB0);
97
-    *(test_pointer+1) = (*(test_pointer+1) == 3 ? 0 : (*(test_pointer+1)) + 1);
85
+void sp_dns_switch() {
86
+    volatile u8 *test_pointer = (u8 *)(0x0203FAB0);
87
+    *(test_pointer + 1) = (*(test_pointer + 1) == 3 ? 0 : (*(test_pointer + 1)) + 1);
98
     *test_pointer = 1;
88
     *test_pointer = 1;
99
 }
89
 }
100
 
90
 
101
-void sp_init_script()
102
-{
103
-  for(u16 i = 0x1000; i < 0x1800; ++i)
104
-  {
105
-    flag_clear(i);
106
-  }
91
+void sp_init_script() {
92
+    for (u16 i = 0x1000; i < 0x1800; ++i)
93
+        flag_clear(i);
94
+    for (u16 i = 0x5000; i <= 0x5100; ++i)
95
+        var_set(i, 0);
107
 }
96
 }
108
 
97
 
109
-void sp_special_casm() //special 0x68
98
+void sp_special_casm() // special 0x68
110
 {
99
 {
111
-    u16* var_special = var_access(CALLASM_VAR);
100
+    u16 *var_special = var_access(CALLASM_VAR);
112
     special_routines[*var_special]();
101
     special_routines[*var_special]();
113
 }
102
 }
114
 
103
 
115
-void sp_clear_variables()
116
-{
117
-    (void) var_set(MUGHSOT_1_TABLE, 0);
118
-    (void) var_set(MUGHSOT_2_TABLE, 0);
119
-    (void) var_set(MUGSHOT_1_X, 0);
120
-    (void) var_set(MUGSHOT_2_X, 0);
121
-    (void) var_set(MUGSHOT_1_Y, 0);
122
-    (void) var_set(MUGSHOT_2_Y, 0);
123
-    (void) var_set(TEXT_VAR, 0);
104
+void sp_clear_variables() {
105
+    (void)var_set(MUGHSOT_1_TABLE, 0);
106
+    (void)var_set(MUGHSOT_2_TABLE, 0);
107
+    (void)var_set(MUGSHOT_1_X, 0);
108
+    (void)var_set(MUGSHOT_2_X, 0);
109
+    (void)var_set(MUGSHOT_1_Y, 0);
110
+    (void)var_set(MUGSHOT_2_Y, 0);
111
+    (void)var_set(TEXT_VAR, 0);
124
     return;
112
     return;
125
 }
113
 }
126
 
114
 
127
-void sp_random_number()
128
-{
129
-    var_set(0x800D, (random() % var_get(0x8000)));
130
-}
115
+void sp_random_number() { var_set(0x800D, (random() % var_get(0x8000))); }