소스 검색

clear save at the beginning of the game

SBird1337 7 년 전
부모
커밋
0aee7b3356
4개의 변경된 파일39개의 추가작업 그리고 40개의 파일을 삭제
  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 +1 @@
1
-Subproject commit cb245518f41d5d508f7c1e70e7b751a2ae4546e8
1
+Subproject commit 04e8a122f208ca1ee8052fef39f2dca51dcffe10

+ 5
- 0
patches/hooks.asm 파일 보기

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

+ 9
- 0
src/savefile/clear_save.c 파일 보기

@@ -0,0 +1,9 @@
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 파일 보기

@@ -25,17 +25,17 @@
25 25
  * @author Sturmvogel
26 26
  * @date 15 dec 2016
27 27
  * @brief Special 0x68 implementation to read from LASTRESULT and execute
28
- * 
28
+ *
29 29
  */
30 30
 
31 31
 /* === INCLUDES === */
32 32
 
33
-#include "cutscene_meteor.h"
34 33
 #include "camera_move.h"
34
+#include "cutscene_meteor.h"
35 35
 #include <callback.h>
36
+#include <config.h>
36 37
 #include <debug.h>
37 38
 #include <game_engine.h>
38
-#include <config.h>
39 39
 #include <math.h>
40 40
 
41 41
 /* === PROTOTYPES === */
@@ -50,7 +50,6 @@ void sp_dns_switch();
50 50
  */
51 51
 void sp_init_script();
52 52
 
53
-
54 53
 /**
55 54
  * @brief callasm to call a var-based routine as defined
56 55
  */
@@ -68,7 +67,6 @@ void sp_random_number();
68 67
 
69 68
 extern void sp_batchmaptile(void);
70 69
 
71
-
72 70
 void get_text_pointer_from_lookup();
73 71
 
74 72
 void sp_check_tileset();
@@ -78,53 +76,40 @@ extern void sp_crystal_fade(void);
78 76
 /* === STATICS === */
79 77
 
80 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 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 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 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 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))); }