|
@@ -0,0 +1,84 @@
|
|
1
|
+/****************************************************************************
|
|
2
|
+ * Copyright (C) 2015-2017 by the SotS Team *
|
|
3
|
+ * *
|
|
4
|
+ * This file is part of Sovereign of the Skies. *
|
|
5
|
+ * *
|
|
6
|
+ * Sovereign of the Skies is free software: you can redistribute it *
|
|
7
|
+ * and/or modify it *
|
|
8
|
+ * under the terms of the GNU Lesser General Public License as published *
|
|
9
|
+ * by the Free Software Foundation, either version 3 of the License, or *
|
|
10
|
+ * (at your option) any later version provided you include a copy of the *
|
|
11
|
+ * licence and this header. *
|
|
12
|
+ * *
|
|
13
|
+ * Sovereign of the Skies is distributed in the hope that it will be *
|
|
14
|
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
15
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
16
|
+ * GNU Lesser General Public License for more details. *
|
|
17
|
+ * *
|
|
18
|
+ * You should have received a copy of the GNU Lesser General Public *
|
|
19
|
+ * License along with Sovereign of the Skies. *
|
|
20
|
+ * If not, see <http://www.gnu.org/licenses/>. *
|
|
21
|
+ ****************************************************************************/
|
|
22
|
+
|
|
23
|
+ /**
|
|
24
|
+ * @file flag_manipulation.c
|
|
25
|
+ * @author Sturmvogel
|
|
26
|
+ * @date 25 may 2017
|
|
27
|
+ * @brief functions for preserving flags and reusing difficulty
|
|
28
|
+ */
|
|
29
|
+
|
|
30
|
+#define TRAINER_FLAG_SPACE_START 0x1000
|
|
31
|
+
|
|
32
|
+#include <types.h>
|
|
33
|
+#include <agb_debug.h>
|
|
34
|
+#include <stdbool.h>
|
|
35
|
+#include <game_engine.h>
|
|
36
|
+#include <battle_structs.h>
|
|
37
|
+
|
|
38
|
+u16 trainerflag_fix_difficulty(u16 flag_id);
|
|
39
|
+
|
|
40
|
+u16 load_hword(void* ptr)
|
|
41
|
+{
|
|
42
|
+ u8* to_load = (u8*)ptr;
|
|
43
|
+ u16 result = *to_load;
|
|
44
|
+ u16 result2 = *(to_load+1) << 8;
|
|
45
|
+ return result | result2;
|
|
46
|
+}
|
|
47
|
+
|
|
48
|
+u16 trainerflag_fix_difficulty(u16 flag_id)
|
|
49
|
+{
|
|
50
|
+ u16 new_flag = ((flag_id - TRAINER_FLAG_SPACE_START + 1) / 3) + TRAINER_FLAG_SPACE_START;
|
|
51
|
+ dprintf("trainerflag_fix_difficulty;; flag_id: 0x%x, reduced: 0x%x\n", flag_id, new_flag);
|
|
52
|
+ return new_flag;
|
|
53
|
+}
|
|
54
|
+
|
|
55
|
+u8 trainerflag_read_fix(void* script_location)
|
|
56
|
+{
|
|
57
|
+ script_location+=2;
|
|
58
|
+ u16 flag = load_hword(script_location);
|
|
59
|
+ //dprintf("trainerflag_read_fix: 0x%x", flag);
|
|
60
|
+ flag = trainerflag_fix_difficulty(flag + TRAINER_FLAG_SPACE_START);
|
|
61
|
+ return flag_check(flag);
|
|
62
|
+}
|
|
63
|
+
|
|
64
|
+volatile u8 test;
|
|
65
|
+
|
|
66
|
+u16 trainerflag_opponent_fix(void)
|
|
67
|
+{
|
|
68
|
+ return trainerflag_fix_difficulty(trainerbattle_flag_id + TRAINER_FLAG_SPACE_START);
|
|
69
|
+}
|
|
70
|
+
|
|
71
|
+bool trainerflag_check_fix(u16 flag)
|
|
72
|
+{
|
|
73
|
+ return flag_check(trainerflag_fix_difficulty(flag + TRAINER_FLAG_SPACE_START));
|
|
74
|
+}
|
|
75
|
+
|
|
76
|
+void trainerflag_set_fix(u16 flag)
|
|
77
|
+{
|
|
78
|
+ flag_set(trainerflag_fix_difficulty(flag + TRAINER_FLAG_SPACE_START));
|
|
79
|
+}
|
|
80
|
+
|
|
81
|
+void trainerflag_clear_fix(u16 flag)
|
|
82
|
+{
|
|
83
|
+ flag_clear(trainerflag_fix_difficulty(flag + TRAINER_FLAG_SPACE_START));
|
|
84
|
+}
|