SBird1337 7 лет назад
Родитель
Сommit
91c1fb1a1a

+ 1
- 0
bpre.sym Просмотреть файл

@@ -1,3 +1,4 @@
1
+<<<<<<< HEAD
1 2
 agbprintf = 0x081E39D8|1;
2 3
 agbprint_flush = 0x081E3B04|1;
3 4
 agb_assert = 0x081E3B14|1;

+ 249
- 222
patches/hooks.asm Просмотреть файл

@@ -1,222 +1,249 @@
1
-//Ipatix sound stuff
2
-.org 0x080007B4
3
-    .word  0x0203E000   // new PCM work area
4
-.org 0x081DD0B4
5
-    .word  main_mixer   // new mixer ROM location
6
-    .word  0x03005F50   // new mixer RAM location (used for loading)
7
-    .halfword mixer_size
8
-    .halfword 0x400        // CpuSet, copy code by 32 bit units
9
-    .word  0x0203E000   // new PCM work area
10
-.org 0x081DD0C8
11
-     // set correct sound driver operation mode
12
-     // 12 channels at 26758 Hz samplerate
13
-    .byte  0x00, 0xCC, 0x98, 0x00
14
-.org 0x081DC094
15
-    .word  0x03005F50+1 // new mixer RAM location (used for branch)
16
-
17
-   // repoint correctly to the new cry tables
18
-.org 0x080720C8
19
-    .include "patches/disable_cry_table_blocks.s"
20
-
21
-   // cry-ID = poke-ID
22
-.org 0x08043304
23
-    LSL R0, R0, #0x10
24
-    LSR R0, R0, #0x10
25
-    BX  LR
26
-
27
-   // music overrides
28
-.org 0x081DD0F4
29
-    LDR R1, =music_override|1
30
-    BX  R1
31
-    .pool
32
-
33
-.org 0x0808064C
34
-    LDR R1, =trainer_intro_music_id_to_song|1
35
-    LDR R2, =0x080806BA|1 // return location
36
-    MOV LR, R2
37
-    BX  R1
38
-    .pool
39
-
40
-//End of sound stuff
41
-
42
-//Don't know what thats all about... leaving it commented for now
43
-//.org 0x0800f268
44
-//    .halfword 0xE000
45
-
46
-//Battle bg use new table
47
-.org 0x0800F2A0
48
-    .word battle_bg_table
49
-
50
-.org 0x0800F2E0
51
-    .word battle_bg_table
52
-
53
-.org 0x0800F320
54
-    .word battle_bg_table
55
-
56
-.org 0x0800F40E
57
-    ldr r0, =battle_bg_hook|1
58
-    bx r0
59
-    lsl r0, #0
60
-	.pool
61
-
62
-.org 0x0800FD5C
63
-    .word battle_bg_table
64
-
65
-.org 0x0800FD88
66
-    .word battle_bg_table
67
-//end of battle bg table
68
-
69
-//flag routine
70
-.org 0x0806E5D6
71
-	ldr r0, =flag_hook|1
72
-	bx r0
73
-	lsl r0, #0
74
-	.pool
75
-//end of flag routine
76
-
77
-//var routine
78
-.org 0x0806E45C
79
-    ldr r0,=var_hook+1
80
-    bx r0
81
-	.pool
82
-
83
-//end of var routine
84
-
85
-//trainer Flag stuff
86
-.org 0x08080382
87
-	mov r1, #0x80
88
-	lsl r1, #0x15
89
-
90
-.org 0x080800BA
91
-	mov r2, #0x80
92
-	lsl r2, #0x5
93
-
94
-.org 0x08080428
95
-    mov r1, #0x80
96
-    lsl r1, #0x15
97
-
98
-.org 0x08080440
99
-    mov r1, #0x80
100
-    lsl r1, #0x15
101
-
102
-.org 0x08080454
103
-    mov r1, #0x80
104
-    lsl r1, #0x15
105
-//end of trainer flag stuff
106
-
107
-//New behavior bytes for jumping
108
-
109
-.org 0x0806811A
110
-	ldr r0,=jump_behavior|1
111
-	bx r0
112
-	.pool
113
-
114
-//behavior walk stuff
115
-.org 0x0806D720
116
-	ldr r0,=on_step|1
117
-	bx r0
118
-	.pool
119
-
120
-//end of new behavior bytes for jumping
121
-
122
-//transparent textboxes and mugshots
123
-.org 0x08069410
124
-    bx r0
125
-
126
-.org 0x0806941C
127
-    .word trans_activate|1
128
-
129
-.org 0x08069504
130
-    bx r1
131
-
132
-.org 0x0806950C
133
-    .word trans_deactivate|1
134
-
135
-.org 0x08150000
136
-    ldr r0, =pal_load_hook_2|1
137
-    bx r0
138
-	.pool
139
-
140
-.org 0x0815044A
141
-    bx r1
142
-
143
-.org 0x08150450
144
-    .word pal_load_hook|1
145
-
146
-.org 0x0809CEB2
147
-    ldr r0, =trans_mug_close_fix+1
148
-    bx r0
149
-    lsl r0, #0
150
-	.pool
151
-
152
-//end of transparent textboxes and mugshots
153
-
154
-//saveblock routine start
155
-
156
-.org 0x080D9EDC
157
-    ldr r0, =load_hijack|1
158
-    bx r0
159
-    .pool
160
-
161
-.org 0x080d991E
162
-    bx r7
163
-.org 0x080d995C
164
-    .word store_hijack|1
165
-
166
-.org 0x083FEC94
167
-.include "patches/save_table/save_table.S"
168
-
169
-//end of saveblock routine
170
-//new battle script commands
171
-	//replace tables
172
-.org 0x08014C1C
173
-	.word bs_command_table
174
-.org 0x08015A28
175
-	.word bs_command_table
176
-.org 0x08015C6C
177
-	.word bs_command_table
178
-.org 0x08015C98
179
-	.word bs_command_table
180
-.org 0x0801D054
181
-	.word bs_command_table
182
-
183
-//end of new battle script commands
184
-
185
-//move effect table
186
-
187
-.org 0x08016364
188
-	.word m_effect_table
189
-.org 0x08023328
190
-	.word m_effect_table
191
-.org 0x08025CF8
192
-	.word m_effect_table
193
-.org 0x08027464
194
-	.word m_effect_table
195
-.org 0x080297F0
196
-	.word m_effect_table
197
-.org 0x0802BE80
198
-	.word m_effect_table
199
-
200
-//end of move effect table
201
-
202
-//move limits
203
-
204
-.org 0x080D75FC
205
-	.byte 0,0,0,0,0,0
206
-
207
-//end of move limits
208
-
209
-//print string mod
210
-
211
-.org 0x080D77C0
212
-	bx r1
213
-
214
-.org 0x080D77CC
215
-	.word custom_print_string|1
216
-
217
-//end of print string mod
218
-
219
-//new move animation table
220
-.org 0x080725d0
221
-    .word m_animation_table
222
-//end of new move animation table
1
+_call_via_r0 equ 0x081E3BA8
2
+_call_via_r1 equ 0x081E3BAC
3
+
4
+//Ipatix sound stuff
5
+.org 0x080007B4
6
+    .word  0x0203E000   // new PCM work area
7
+.org 0x081DD0B4
8
+    .word  main_mixer   // new mixer ROM location
9
+    .word  0x03005F50   // new mixer RAM location (used for loading)
10
+    .halfword mixer_size
11
+    .halfword 0x400        // CpuSet, copy code by 32 bit units
12
+    .word  0x0203E000   // new PCM work area
13
+.org 0x081DD0C8
14
+     // set correct sound driver operation mode
15
+     // 12 channels at 26758 Hz samplerate
16
+    .byte  0x00, 0xCC, 0x98, 0x00
17
+.org 0x081DC094
18
+    .word  0x03005F50+1 // new mixer RAM location (used for branch)
19
+
20
+   // repoint correctly to the new cry tables
21
+.org 0x080720C8
22
+    .include "patches/disable_cry_table_blocks.s"
23
+
24
+   // cry-ID = poke-ID
25
+.org 0x08043304
26
+    LSL R0, R0, #0x10
27
+    LSR R0, R0, #0x10
28
+    BX  LR
29
+
30
+   // music overrides
31
+.org 0x081DD0F4
32
+    LDR R1, =music_override|1  // TODO wait for replacement by functions below, but can stay for now
33
+    BX  R1
34
+    .pool
35
+
36
+.org 0x0808064C // intro music (!) song hook
37
+    LDR R1, =mhk_intro_music_id_to_song|1
38
+    BL  _call_via_r1
39
+    B   0x080806BA
40
+    .pool
41
+
42
+.org 0x08043FD4 // batle music song hook
43
+    LDR R0, =mhk_song_id_for_battle|1
44
+    BX  R0
45
+    .pool
46
+
47
+.org 0x080156FE // trainer victory music hook
48
+    LDR R0, =mhk_trainer_battle_play_defeat|1
49
+    BL  _call_via_r0
50
+    B   0x0801576E
51
+    .pool
52
+
53
+.org 0x08021D46  // wild poke defeated
54
+    BL  _call_via_r0 // call via r0
55
+.org 0x08021D94
56
+    .word   mhk_wild_poke_def_music|1
57
+
58
+.org 0x0807F9F8
59
+    LDR R1, =0x0807FA3E
60
+    BL  _call_via_r1 // call via r1
61
+    MOV R1, R0
62
+    B   0x0807FA3E
63
+    .pool
64
+
65
+
66
+
67
+//End of sound stuff
68
+
69
+//Don't know what thats all about... leaving it commented for now
70
+//.org 0x0800f268
71
+//    .halfword 0xE000
72
+
73
+//Battle bg use new table
74
+.org 0x0800F2A0
75
+    .word battle_bg_table
76
+
77
+.org 0x0800F2E0
78
+    .word battle_bg_table
79
+
80
+.org 0x0800F320
81
+    .word battle_bg_table
82
+
83
+.org 0x0800F40E
84
+    ldr r0, =battle_bg_hook|1
85
+    bx r0
86
+    lsl r0, #0
87
+	.pool
88
+
89
+.org 0x0800FD5C
90
+    .word battle_bg_table
91
+
92
+.org 0x0800FD88
93
+    .word battle_bg_table
94
+//end of battle bg table
95
+
96
+//flag routine
97
+.org 0x0806E5D6
98
+	ldr r0, =flag_hook|1
99
+	bx r0
100
+	lsl r0, #0
101
+	.pool
102
+//end of flag routine
103
+
104
+//var routine
105
+.org 0x0806E45C
106
+    ldr r0,=var_hook+1
107
+    bx r0
108
+	.pool
109
+
110
+//end of var routine
111
+
112
+//trainer Flag stuff
113
+.org 0x08080382
114
+	mov r1, #0x80
115
+	lsl r1, #0x15
116
+
117
+.org 0x080800BA
118
+	mov r2, #0x80
119
+	lsl r2, #0x5
120
+
121
+.org 0x08080428
122
+    mov r1, #0x80
123
+    lsl r1, #0x15
124
+
125
+.org 0x08080440
126
+    mov r1, #0x80
127
+    lsl r1, #0x15
128
+
129
+.org 0x08080454
130
+    mov r1, #0x80
131
+    lsl r1, #0x15
132
+//end of trainer flag stuff
133
+
134
+//New behavior bytes for jumping
135
+
136
+.org 0x0806811A
137
+	ldr r0,=jump_behavior|1
138
+	bx r0
139
+	.pool
140
+
141
+//behavior walk stuff
142
+.org 0x0806D720
143
+	ldr r0,=on_step|1
144
+	bx r0
145
+	.pool
146
+
147
+//end of new behavior bytes for jumping
148
+
149
+//transparent textboxes and mugshots
150
+.org 0x08069410
151
+    bx r0
152
+
153
+.org 0x0806941C
154
+    .word trans_activate|1
155
+
156
+.org 0x08069504
157
+    bx r1
158
+
159
+.org 0x0806950C
160
+    .word trans_deactivate|1
161
+
162
+.org 0x08150000
163
+    ldr r0, =pal_load_hook_2|1
164
+    bx r0
165
+	.pool
166
+
167
+.org 0x0815044A
168
+    bx r1
169
+
170
+.org 0x08150450
171
+    .word pal_load_hook|1
172
+
173
+.org 0x0809CEB2
174
+    ldr r0, =trans_mug_close_fix+1
175
+    bx r0
176
+    lsl r0, #0
177
+	.pool
178
+
179
+//end of transparent textboxes and mugshots
180
+
181
+//saveblock routine start
182
+
183
+.org 0x080D9EDC
184
+    ldr r0, =load_hijack|1
185
+    bx r0
186
+    .pool
187
+
188
+.org 0x080d991E
189
+    bx r7
190
+.org 0x080d995C
191
+    .word store_hijack|1
192
+
193
+.org 0x083FEC94
194
+.include "patches/save_table/save_table.S"
195
+
196
+//end of saveblock routine
197
+//new battle script commands
198
+	//replace tables
199
+.org 0x08014C1C
200
+	.word bs_command_table
201
+.org 0x08015A28
202
+	.word bs_command_table
203
+.org 0x08015C6C
204
+	.word bs_command_table
205
+.org 0x08015C98
206
+	.word bs_command_table
207
+.org 0x0801D054
208
+	.word bs_command_table
209
+
210
+//end of new battle script commands
211
+
212
+//move effect table
213
+
214
+.org 0x08016364
215
+	.word m_effect_table
216
+.org 0x08023328
217
+	.word m_effect_table
218
+.org 0x08025CF8
219
+	.word m_effect_table
220
+.org 0x08027464
221
+	.word m_effect_table
222
+.org 0x080297F0
223
+	.word m_effect_table
224
+.org 0x0802BE80
225
+	.word m_effect_table
226
+
227
+//end of move effect table
228
+
229
+//move limits
230
+
231
+.org 0x080D75FC
232
+	.byte 0,0,0,0,0,0
233
+
234
+//end of move limits
235
+
236
+//print string mod
237
+
238
+.org 0x080D77C0
239
+	bx r1
240
+
241
+.org 0x080D77CC
242
+	.word custom_print_string|1
243
+
244
+//end of print string mod
245
+
246
+//new move animation table
247
+.org 0x080725d0
248
+    .word m_animation_table
249
+//end of new move animation table

+ 19
- 17
src/include/battle_common.h Просмотреть файл

@@ -1,17 +1,19 @@
1
-#ifndef BATTLE_H_
2
-#define BATTLE_H_
3
-
4
-#include <types.h>
5
-
6
-#define REQUEST_HELDITEM_BATTLE 0x2
7
-#define REQUEST_STATUS_BATTLE 0x28
8
-
9
-u8 get_side_from_bank(u8 bank);
10
-u16 battle_turn_random;
11
-void mark_buffer_bank_for_execution(u8 bank);
12
-void prepare_setattributes_in_battle(u8 buffer, u8 data_request, u8 unkown, u8 data_to_add, void* ptr_to_attribute);
13
-u8 item_get_quality(u8 item_id);
14
-u8 get_item_x12_battle_function(u16 item_id);
15
-void battle_script_push();
16
-
17
-#endif
1
+#ifndef BATTLE_H_
2
+#define BATTLE_H_
3
+
4
+#include <types.h>
5
+
6
+#define REQUEST_HELDITEM_BATTLE 0x2
7
+#define REQUEST_STATUS_BATTLE 0x28
8
+
9
+u8 get_side_from_bank(u8 bank);
10
+u16 battle_turn_random;
11
+void mark_buffer_bank_for_execution(u8 bank);
12
+void prepare_setattributes_in_battle(u8 buffer, u8 data_request, u8 unkown, u8 data_to_add, void* ptr_to_attribute);
13
+u8 item_get_quality(u8 item_id);
14
+u8 get_item_x12_battle_function(u16 item_id);
15
+void battle_script_push(void);
16
+
17
+void song_play_for_text(u16 songid);
18
+
19
+#endif

+ 387
- 344
src/include/battle_structs.h Просмотреть файл

@@ -1,344 +1,387 @@
1
-#ifndef BATTLE_STRUCT_H_
2
-#define BATTLE_STRUCT_H_
3
-
4
-#include <types.h>
5
-
6
-struct side_affecting_hword{
7
-    u16 reflect_on : 1;
8
-    u16 light_screen_on : 1;
9
-    u16 unkown1 : 2;
10
-    u16 spikes_on : 1;
11
-    u16 safeguard_on : 1;
12
-    u16 unkown2 : 2;
13
-    u16 mist_on : 1;
14
-    u16 spikes_damage_done : 1;
15
-};
16
-
17
-extern struct side_affecting_hword side_affecting_halfword[2];
18
-
19
-struct status_main{
20
-    u32 sleep : 3;
21
-    u32 poison : 1;
22
-    u32 burn : 1;
23
-    u32 freeze : 1;
24
-    u32 paralysis: 1;
25
-    u32 toxic_poison : 1;
26
-    u32 poison_counter : 4;
27
-};
28
-
29
-union main_status{
30
-    u32 int_status;
31
-    struct status_main flags;
32
-};
33
-
34
-struct protect_struct{
35
-    u8 flag0_protect : 1;
36
-    u8 flag0_endure : 1;
37
-    u8 flag0_onlystruggle : 1;
38
-    u8 flag0_helpinghand : 1;
39
-    u8 flag0_bouncemove : 1;
40
-    u8 flag0_stealmove : 1;
41
-    u8 flag0_unknown: 1;
42
-    u8 flag0_prlz_immobility: 1;
43
-    u8 flag1_confusion_self_damage: 1;
44
-    u8 flag1_noteffective: 1;
45
-    u8 flag1_chargingturn: 1; //dive, dig etc.
46
-    u8 flag1_smokeballflee: 1;
47
-    u8 flag1_runaway_flee: 1;
48
-    u8 flag1_used_imprisoned_move: 1;
49
-    u8 flag1_love_immobility: 1;
50
-    u8 flag1_used_disabled_move: 1;
51
-    u8 flag2_used_taunted_move: 1;
52
-    u8 flag2_unknown: 1;
53
-    u8 flag2_flinch_immobility : 1;
54
-    u8 flag2_notfirststrike : 1;
55
-    u8 flag2_free: 4;
56
-    u8 field3;
57
-    u32 physical_damage;
58
-    u32 special_damage;
59
-    u8 counter_target;
60
-    u8 mirrorcoat_target;
61
-    u16 fieldE;
62
-};
63
-
64
-extern struct protect_struct battle_protect[4];
65
-
66
-#define STATUS_SLEEP 0x7
67
-#define STATUS_POISON 0x8
68
-#define STATUS_BURN 0x10
69
-#define STATUS_FREEZE 0x20
70
-#define STATUS_PARALYSIS 0x40
71
-#define STATUS_TOXIC_POISON 0x80
72
-
73
-struct flags2{
74
-    u32 confusion : 3;
75
-    u32 flinched : 1;
76
-    u32 uproar : 3;
77
-    u32 flag_x80 : 1;
78
-    u32 bide : 2;
79
-    u32 locked_and_confuse : 2;
80
-    u32 multiple_turn_move : 1;
81
-    u32 trapped_in_wrap : 3;
82
-    u32 in_love : 4;
83
-    u32 focus_energy : 1;
84
-    u32 transformed : 1;
85
-    u32 recharge : 1;
86
-    u32 raged : 1;
87
-    u32 substitute : 1;
88
-    u32 destinny_bond : 1;
89
-    u32 cant_escape : 1;
90
-    u32 nightmare : 1;
91
-    u32 cursed : 1;
92
-    u32 foresight : 1;
93
-    u32 defense_curled : 1;
94
-    u32 tormented : 1;
95
-};
96
-
97
-struct iv_set
98
-{
99
-    u32 iv_hp: 5;
100
-    u32 iv_atk: 5;
101
-    u32 iv_def: 5;
102
-    u32 iv_spd: 5;
103
-    u32 iv_sp_atk: 5;
104
-    u32 iv_sp_def: 5;
105
-};
106
-
107
-struct pokemon{
108
-	u32 PID;
109
-	u32 OTID;
110
-	char name[10];
111
-	u16 language;
112
-	u8 OT_name[7];
113
-	u8 markings;
114
-	u16 checksum;
115
-	u16 padding_maybe;
116
-	u8 data[48];
117
-	u32 ailment;
118
-	u8 level;
119
-	u8 pokerus;
120
-	u16 current_hp;
121
-	u16 total_hp;
122
-	u16 attack;
123
-	u16 defense;
124
-	u16 speed;
125
-	u16 sp_attack;
126
-	u16 sp_defense;
127
-};
128
-
129
-extern struct pokemon party_opponent[6];
130
-extern struct pokemon party_player[6];
131
-
132
-struct battle_participant {
133
-    u16 poke_species;
134
-    u16 atk;
135
-    u16 def;
136
-    u16 spd;
137
-    u16 sp_atk;
138
-    u16 sp_def;
139
-    u16 moves[4];
140
-    struct iv_set ivs;
141
-    u8 hp_buff;
142
-    u8 atk_buff;
143
-    u8 def_buff;
144
-    u8 spd_buff;
145
-    u8 sp_atk_buff;
146
-    u8 sp_def_buff;
147
-    u8 acc_buff;
148
-    u8 evasion_buff;
149
-    u8 ability_id;
150
-    u8 type1;
151
-    u8 type2;
152
-    u8 padd;
153
-    u8 current_pp[4];
154
-    u16 current_hp;
155
-    u8 level;
156
-    u8 happiness;
157
-    u16 max_hp;
158
-    u16 held_item;
159
-    u8 poke_name[12];
160
-    u8 trainer_name[8];
161
-    u32 padd2;
162
-    u32 pid;
163
-    union main_status status;
164
-    struct flags2 status2;
165
-    u32 otid;
166
-};
167
-
168
-extern struct battle_participant battle_participants[4];
169
-
170
-struct side_timer{
171
-    u8 reflect_timer;
172
-    u8 reflect_bank;
173
-    u8 lightscreen_timer;
174
-    u8 lightscreen_bank;
175
-    u8 mist_timer;
176
-    u8 mist_bank;
177
-    u8 safeguard_timer;
178
-    u8 safeguard_bank;
179
-    u8 followme_timer;
180
-    u8 followme_target;
181
-    u8 spikes_amount;
182
-    u8 fieldB;
183
-};
184
-
185
-extern struct side_timer battle_side_timers[2];
186
-
187
-struct in_battle_weather{
188
-    u32 rain : 1;
189
-    u32 downpour : 1;
190
-    u32 permament_rain : 1;
191
-    u32 sandstorm : 1;
192
-    u32 permament_sandstorm : 1;
193
-    u32 sun : 1;
194
-    u32 permament_sun : 1;
195
-    u32 hail : 1;
196
-    //custom flags
197
-    u32 permament_hail : 1;
198
-    u32 fog : 1;
199
-    u32 permament_fog : 1;
200
-    u32 harsh_sun : 1;
201
-    u32 heavy_rain : 1;
202
-    u32 air_current : 1;
203
-};
204
-
205
-struct status_3{
206
-    u32 leech_seed_hp_receiver : 2; // 2 bits
207
-    u32 leech_seed : 1; //4
208
-    u32 always_hits : 2; //x8 | x10
209
-    u32 perish_song : 1; //x20
210
-    u32 on_air : 1; //x40
211
-    u32 underground : 1;//80
212
-    u32 minimized : 1; //x100
213
-    u32 charged_up : 1; //x200
214
-    u32 rooted : 1; //x400
215
-    u32 yawn : 2; //x800 || x1000
216
-    u32 imprision : 1; //x2000
217
-    u32 grudge : 1; //x4000
218
-    u32 unkown_no_crit : 1; //x8000
219
-    u32 mud_sport : 1; //x10 000
220
-    u32 watersport : 1; //x20 000
221
-    u32 underwater : 1; //x40 000
222
-    u32 switchinlock : 1; //x80 000
223
-    u32 unburden : 1; //x100 000 (previously trace)
224
-    u32 phantomforce : 1; //x200 000
225
-};
226
-
227
-extern struct status_3 battle_status_3[4];
228
-
229
-union battle_weather{
230
-    u32 int_bw;
231
-    struct in_battle_weather flags;
232
-};
233
-
234
-extern union battle_weather battle_weather;
235
-
236
-struct mirror_move_set_per_bank
237
-{
238
-    u16 moves_per_target[4];
239
-};
240
-
241
-struct battle_stuff{
242
-    u8 end_turn_statetracker1; //0x0
243
-    u8 end_turn_checked_bank; //0x1
244
-    u8 field_2; //0x2
245
-    u8 end_turn_statetracker2; //0x3
246
-    u16 trapped_move[4]; //0x4 - 0xB
247
-    u8 move_target[4]; //0xC - 0xF
248
-    u8 field_10; //0x10
249
-    u8 field_11; //0x11
250
-    u8 field_12; //0x12
251
-    u8 dynamic_move_type; //0x13
252
-    u8 trapper[4];//0x14-0x17
253
-    u8 field_18[48]; //0x18-0x47
254
-    u8 pre_attacks_bank_counter; //0x48
255
-    u8 field_49; //0x49
256
-    u8 money_multiplier; //0x4A
257
-    u8 field_4B; //0x4B
258
-    u8 switch_in_ability_bank_counter; //0x4C
259
-    u8 field_4D[7]; //0x4D-0x53
260
-    u8 field_54; //0x54
261
-    u8 field_55; //0x55
262
-    u8 field_56; //0x56
263
-    u8 field_57; //0x57
264
-    u8 field_58[4];
265
-    u8 field_5C[35];
266
-    u8 castform_switch_form; //0x7F
267
-    u8 chosen_move_position[4]; //0x80
268
-    u8 field_84[13]; //0x84-0x90
269
-    u8 absent_bank_flags_prev_turn; //0x91
270
-    u8 field_92[6]; //0x92-0x97
271
-    u16 mirror_moves_pbs[4]; //0x98-0x9F
272
-    u8 field_A0[18]; //0xA0-0xB1
273
-    u8 synchronize_effect_chooser; //0xB2
274
-    u8 field_B3[5];
275
-    u16 used_held_items[4]; //0xB8-0xBF
276
-    u8 field_C0[8]; //0xC0-0xC7
277
-    u16 choiced_move[4]; //0xC8-0xCF (checked in cmd49)
278
-    u16 changed_held_items[4]; //0xD0-0xD8 (later written to battlestruct in cmd49)
279
-    u8 intimidate_user; //0xD8
280
-    u8 switch_in_item_bank_counter; //0xD9
281
-    u8 field_DA; //0xDA
282
-    u8 field_DB; //0xDB
283
-    u8 field_DC; //0xDC
284
-    u8 field_DD; //0xDD
285
-    u8 field_DE; //0xDE
286
-    u8 field_DF; //0xDF
287
-    struct mirror_move_set_per_bank mirror_move_set_pbs[4]; //0xE0-0xFF
288
-    u8 field_100[162]; //0x100-0x1A1
289
-    u8 battle_load_weather_from_map_flag; //0x1A2
290
-    u8 atk_canceller_state_tracker; //0x1A3
291
-    u8 field_1A4[240]; //0x1A4-0x293
292
-    u8 switchout_index[4]; //0x294-0x297
293
-    u8 field_298[11];
294
-    u8 field_2A3;
295
-};
296
-
297
-struct battle_stuff_struct{
298
-    struct battle_stuff *ptr;
299
-};
300
-
301
-extern struct battle_stuff_struct battle_stuff_ptr;
302
-
303
-struct prop_flags{
304
-    u8 makes_contact : 1;//1
305
-    u8 affected_by_protect : 1;//2
306
-    u8 affected_by_magic_coat : 1;//4
307
-    u8 affected_by_snatch : 1;//8
308
-    u8 affected_by_mirrormove :1;//x10
309
-    u8 affected_by_kingsrock :1;//x20
310
-    u8 raised_crit_ratio :1;//x40
311
-    u8 unused_bit : 1;//x80
312
-};
313
-
314
-union move_flags{
315
-    u8 int_flag;
316
-    struct prop_flags flags;
317
-};
318
-
319
-struct move_info{
320
-    u8 script_id;
321
-    u8 base_power;
322
-    u8 type;
323
-    u8 accuracy;
324
-    u8 pp;
325
-    u8 effect_chance;
326
-    u8 target;
327
-    s8 priority;
328
-    union move_flags move_flags;
329
-    u8 arg1;
330
-    u8 split;
331
-    u8 arg2;
332
-};
333
-
334
-struct b_enigma_berry{
335
-    u8 field0[7];
336
-    u8 battle_effect_x12;
337
-    u8 field8[18];
338
-    u8 quality;
339
-    u8 field1B;
340
-};
341
-
342
-extern struct b_enigma_berry battle_enigma_berry[4];
343
-
344
-#endif
1
+#ifndef BATTLE_STRUCT_H_
2
+#define BATTLE_STRUCT_H_
3
+
4
+#include <types.h>
5
+
6
+struct side_affecting_hword{
7
+    u16 reflect_on : 1;
8
+    u16 light_screen_on : 1;
9
+    u16 unkown1 : 2;
10
+    u16 spikes_on : 1;
11
+    u16 safeguard_on : 1;
12
+    u16 unkown2 : 2;
13
+    u16 mist_on : 1;
14
+    u16 spikes_damage_done : 1;
15
+};
16
+
17
+extern struct side_affecting_hword side_affecting_halfword[2];
18
+
19
+struct status_main{
20
+    u32 sleep : 3;
21
+    u32 poison : 1;
22
+    u32 burn : 1;
23
+    u32 freeze : 1;
24
+    u32 paralysis: 1;
25
+    u32 toxic_poison : 1;
26
+    u32 poison_counter : 4;
27
+};
28
+
29
+union main_status{
30
+    u32 int_status;
31
+    struct status_main flags;
32
+};
33
+
34
+struct protect_struct{
35
+    u8 flag0_protect : 1;
36
+    u8 flag0_endure : 1;
37
+    u8 flag0_onlystruggle : 1;
38
+    u8 flag0_helpinghand : 1;
39
+    u8 flag0_bouncemove : 1;
40
+    u8 flag0_stealmove : 1;
41
+    u8 flag0_unknown: 1;
42
+    u8 flag0_prlz_immobility: 1;
43
+    u8 flag1_confusion_self_damage: 1;
44
+    u8 flag1_noteffective: 1;
45
+    u8 flag1_chargingturn: 1; //dive, dig etc.
46
+    u8 flag1_smokeballflee: 1;
47
+    u8 flag1_runaway_flee: 1;
48
+    u8 flag1_used_imprisoned_move: 1;
49
+    u8 flag1_love_immobility: 1;
50
+    u8 flag1_used_disabled_move: 1;
51
+    u8 flag2_used_taunted_move: 1;
52
+    u8 flag2_unknown: 1;
53
+    u8 flag2_flinch_immobility : 1;
54
+    u8 flag2_notfirststrike : 1;
55
+    u8 flag2_free: 4;
56
+    u8 field3;
57
+    u32 physical_damage;
58
+    u32 special_damage;
59
+    u8 counter_target;
60
+    u8 mirrorcoat_target;
61
+    u16 fieldE;
62
+};
63
+
64
+extern struct protect_struct battle_protect[4];
65
+
66
+#define STATUS_SLEEP 0x7
67
+#define STATUS_POISON 0x8
68
+#define STATUS_BURN 0x10
69
+#define STATUS_FREEZE 0x20
70
+#define STATUS_PARALYSIS 0x40
71
+#define STATUS_TOXIC_POISON 0x80
72
+
73
+struct flags2{
74
+    u32 confusion : 3;
75
+    u32 flinched : 1;
76
+    u32 uproar : 3;
77
+    u32 flag_x80 : 1;
78
+    u32 bide : 2;
79
+    u32 locked_and_confuse : 2;
80
+    u32 multiple_turn_move : 1;
81
+    u32 trapped_in_wrap : 3;
82
+    u32 in_love : 4;
83
+    u32 focus_energy : 1;
84
+    u32 transformed : 1;
85
+    u32 recharge : 1;
86
+    u32 raged : 1;
87
+    u32 substitute : 1;
88
+    u32 destinny_bond : 1;
89
+    u32 cant_escape : 1;
90
+    u32 nightmare : 1;
91
+    u32 cursed : 1;
92
+    u32 foresight : 1;
93
+    u32 defense_curled : 1;
94
+    u32 tormented : 1;
95
+};
96
+
97
+struct iv_set
98
+{
99
+    u32 iv_hp: 5;
100
+    u32 iv_atk: 5;
101
+    u32 iv_def: 5;
102
+    u32 iv_spd: 5;
103
+    u32 iv_sp_atk: 5;
104
+    u32 iv_sp_def: 5;
105
+};
106
+
107
+struct pokemon{
108
+	u32 PID;
109
+	u32 OTID;
110
+	char name[10];
111
+	u16 language;
112
+	u8 OT_name[7];
113
+	u8 markings;
114
+	u16 checksum;
115
+	u16 padding_maybe;
116
+	u8 data[48];
117
+	u32 ailment;
118
+	u8 level;
119
+	u8 pokerus;
120
+	u16 current_hp;
121
+	u16 total_hp;
122
+	u16 attack;
123
+	u16 defense;
124
+	u16 speed;
125
+	u16 sp_attack;
126
+	u16 sp_defense;
127
+};
128
+
129
+extern struct pokemon party_opponent[6];
130
+extern struct pokemon party_player[6];
131
+
132
+struct battle_participant {
133
+    u16 poke_species;
134
+    u16 atk;
135
+    u16 def;
136
+    u16 spd;
137
+    u16 sp_atk;
138
+    u16 sp_def;
139
+    u16 moves[4];
140
+    struct iv_set ivs;
141
+    u8 hp_buff;
142
+    u8 atk_buff;
143
+    u8 def_buff;
144
+    u8 spd_buff;
145
+    u8 sp_atk_buff;
146
+    u8 sp_def_buff;
147
+    u8 acc_buff;
148
+    u8 evasion_buff;
149
+    u8 ability_id;
150
+    u8 type1;
151
+    u8 type2;
152
+    u8 padd;
153
+    u8 current_pp[4];
154
+    u16 current_hp;
155
+    u8 level;
156
+    u8 happiness;
157
+    u16 max_hp;
158
+    u16 held_item;
159
+    u8 poke_name[12];
160
+    u8 trainer_name[8];
161
+    u32 padd2;
162
+    u32 pid;
163
+    union main_status status;
164
+    struct flags2 status2;
165
+    u32 otid;
166
+};
167
+
168
+extern struct battle_participant battle_participants[4];
169
+
170
+struct side_timer{
171
+    u8 reflect_timer;
172
+    u8 reflect_bank;
173
+    u8 lightscreen_timer;
174
+    u8 lightscreen_bank;
175
+    u8 mist_timer;
176
+    u8 mist_bank;
177
+    u8 safeguard_timer;
178
+    u8 safeguard_bank;
179
+    u8 followme_timer;
180
+    u8 followme_target;
181
+    u8 spikes_amount;
182
+    u8 fieldB;
183
+};
184
+
185
+extern struct side_timer battle_side_timers[2];
186
+
187
+struct in_battle_weather{
188
+    u32 rain : 1;
189
+    u32 downpour : 1;
190
+    u32 permament_rain : 1;
191
+    u32 sandstorm : 1;
192
+    u32 permament_sandstorm : 1;
193
+    u32 sun : 1;
194
+    u32 permament_sun : 1;
195
+    u32 hail : 1;
196
+    //custom flags
197
+    u32 permament_hail : 1;
198
+    u32 fog : 1;
199
+    u32 permament_fog : 1;
200
+    u32 harsh_sun : 1;
201
+    u32 heavy_rain : 1;
202
+    u32 air_current : 1;
203
+};
204
+
205
+struct status_3{
206
+    u32 leech_seed_hp_receiver : 2; // 2 bits
207
+    u32 leech_seed : 1; //4
208
+    u32 always_hits : 2; //x8 | x10
209
+    u32 perish_song : 1; //x20
210
+    u32 on_air : 1; //x40
211
+    u32 underground : 1;//80
212
+    u32 minimized : 1; //x100
213
+    u32 charged_up : 1; //x200
214
+    u32 rooted : 1; //x400
215
+    u32 yawn : 2; //x800 || x1000
216
+    u32 imprision : 1; //x2000
217
+    u32 grudge : 1; //x4000
218
+    u32 unkown_no_crit : 1; //x8000
219
+    u32 mud_sport : 1; //x10 000
220
+    u32 watersport : 1; //x20 000
221
+    u32 underwater : 1; //x40 000
222
+    u32 switchinlock : 1; //x80 000
223
+    u32 unburden : 1; //x100 000 (previously trace)
224
+    u32 phantomforce : 1; //x200 000
225
+};
226
+
227
+extern struct status_3 battle_status_3[4];
228
+
229
+union battle_weather{
230
+    u32 int_bw;
231
+    struct in_battle_weather flags;
232
+};
233
+
234
+extern union battle_weather battle_weather;
235
+
236
+struct mirror_move_set_per_bank
237
+{
238
+    u16 moves_per_target[4];
239
+};
240
+
241
+struct battle_stuff{
242
+    u8 end_turn_statetracker1; //0x0
243
+    u8 end_turn_checked_bank; //0x1
244
+    u8 field_2; //0x2
245
+    u8 end_turn_statetracker2; //0x3
246
+    u16 trapped_move[4]; //0x4 - 0xB
247
+    u8 move_target[4]; //0xC - 0xF
248
+    u8 field_10; //0x10
249
+    u8 field_11; //0x11
250
+    u8 field_12; //0x12
251
+    u8 dynamic_move_type; //0x13
252
+    u8 trapper[4];//0x14-0x17
253
+    u8 field_18[48]; //0x18-0x47
254
+    u8 pre_attacks_bank_counter; //0x48
255
+    u8 field_49; //0x49
256
+    u8 money_multiplier; //0x4A
257
+    u8 field_4B; //0x4B
258
+    u8 switch_in_ability_bank_counter; //0x4C
259
+    u8 field_4D[7]; //0x4D-0x53
260
+    u8 field_54; //0x54
261
+    u8 field_55; //0x55
262
+    u8 field_56; //0x56
263
+    u8 field_57; //0x57
264
+    u8 field_58[4];
265
+    u8 field_5C[35];
266
+    u8 castform_switch_form; //0x7F
267
+    u8 chosen_move_position[4]; //0x80
268
+    u8 field_84[13]; //0x84-0x90
269
+    u8 absent_bank_flags_prev_turn; //0x91
270
+    u8 field_92[6]; //0x92-0x97
271
+    u16 mirror_moves_pbs[4]; //0x98-0x9F
272
+    u8 field_A0[18]; //0xA0-0xB1
273
+    u8 synchronize_effect_chooser; //0xB2
274
+    u8 field_B3[5];
275
+    u16 used_held_items[4]; //0xB8-0xBF
276
+    u8 field_C0[8]; //0xC0-0xC7
277
+    u16 choiced_move[4]; //0xC8-0xCF (checked in cmd49)
278
+    u16 changed_held_items[4]; //0xD0-0xD8 (later written to battlestruct in cmd49)
279
+    u8 intimidate_user; //0xD8
280
+    u8 switch_in_item_bank_counter; //0xD9
281
+    u8 field_DA; //0xDA
282
+    u8 field_DB; //0xDB
283
+    u8 field_DC; //0xDC
284
+    u8 field_DD; //0xDD
285
+    u8 field_DE; //0xDE
286
+    u8 field_DF; //0xDF
287
+    struct mirror_move_set_per_bank mirror_move_set_pbs[4]; //0xE0-0xFF
288
+    u8 field_100[162]; //0x100-0x1A1
289
+    u8 battle_load_weather_from_map_flag; //0x1A2
290
+    u8 atk_canceller_state_tracker; //0x1A3
291
+    u8 field_1A4[240]; //0x1A4-0x293
292
+    u8 switchout_index[4]; //0x294-0x297
293
+    u8 field_298[11];
294
+    u8 field_2A3;
295
+};
296
+
297
+struct battle_stuff_struct{
298
+    struct battle_stuff *ptr;
299
+};
300
+
301
+extern struct battle_stuff_struct battle_stuff_ptr;
302
+
303
+struct prop_flags{
304
+    u8 makes_contact : 1;//1
305
+    u8 affected_by_protect : 1;//2
306
+    u8 affected_by_magic_coat : 1;//4
307
+    u8 affected_by_snatch : 1;//8
308
+    u8 affected_by_mirrormove :1;//x10
309
+    u8 affected_by_kingsrock :1;//x20
310
+    u8 raised_crit_ratio :1;//x40
311
+    u8 unused_bit : 1;//x80
312
+};
313
+
314
+union move_flags{
315
+    u8 int_flag;
316
+    struct prop_flags flags;
317
+};
318
+
319
+struct move_info{
320
+    u8 script_id;
321
+    u8 base_power;
322
+    u8 type;
323
+    u8 accuracy;
324
+    u8 pp;
325
+    u8 effect_chance;
326
+    u8 target;
327
+    s8 priority;
328
+    union move_flags move_flags;
329
+    u8 arg1;
330
+    u8 split;
331
+    u8 arg2;
332
+};
333
+
334
+struct b_enigma_berry{
335
+    u8 field0[7];
336
+    u8 battle_effect_x12;
337
+    u8 field8[18];
338
+    u8 quality;
339
+    u8 field1B;
340
+};
341
+
342
+extern struct b_enigma_berry battle_enigma_berry[4];
343
+
344
+// trainerbattle stuff
345
+
346
+extern u16 trainerbattle_flag_id;
347
+
348
+extern struct {
349
+    u8 battle_double : 1;       //   1
350
+    u8 battle_link : 1;         //   2
351
+    u8 battle_wild : 1;         //   4
352
+    u8 battle_trainer : 1;      //   8
353
+    u8 battle_oak_comments : 1; //0x10
354
+    u8 _battle_unk_1 : 1;       //0x20
355
+    u8 battle_double_2 : 1;     //0x40
356
+    u8 battle_safari : 1;       //0x80
357
+    u8 battle_trainer_tower : 1;//0x100
358
+    u8 _battle_unk_2 : 1;       //0x200
359
+    u8 battle_old_man : 1;      //0x400
360
+    u8 battle_trainer_tower_2 : 1;//0x800
361
+    u8 _battle_unk_3 : 1;       //0x1000
362
+    u8 _battle_unk_4 : 1;       //0x2000
363
+    u8 _battle_unk_5 : 1;       //0x4000
364
+    u8 battle_ghost : 1;        //0x8000
365
+    u8 battle_poke_dude : 1;    //0x10000
366
+    u8 _battle_unk_6 : 1;       //0x20000
367
+    u8 battle_secret_base : 1;  //0x40000
368
+} battle_type_flags;
369
+
370
+_Static_assert(sizeof(battle_type_flags) <= 4, "Invalid struct size for battle_type_flags");
371
+
372
+struct trainer_table_entry {
373
+    u8 _unk_1;
374
+    u8 trainer_class;
375
+    u8 encounter_music;
376
+    u8 _unk_2;
377
+    u8 _unk_3[16];
378
+    u8 _unk_4[16];
379
+    u32 _unk; // probably pokemon data
380
+};
381
+
382
+_Static_assert(sizeof(struct trainer_table_entry) == 0x28, "Invalid struct size for trainer_table_entry");
383
+
384
+extern struct trainer_table_entry trainer_data[];
385
+
386
+
387
+#endif

+ 55
- 48
src/include/pokemon.h Просмотреть файл

@@ -1,48 +1,55 @@
1
-#ifndef POKE_INDICES_H
2
-#define POKE_INDICES_H
3
-
4
-#define POKE_PIKACHU 0x19
5
-#define POKE_CUBONE 0x68
6
-#define POKE_MAROWAK 0x69
7
-#define POKE_FARFETCHD 0x53
8
-#define POKE_CHANSEY 0x71
9
-#define POKE_DITTO 132
10
-#define POKE_CLAMPERL 0x175
11
-#define POKE_LATIAS 0x197
12
-#define POKE_LATIOS 0x198
13
-#define POKE_CHERRIM 0x200
14
-#define POKE_DIALGA 0x218
15
-#define POKE_PALKIA 0x219
16
-#define POKE_GIRATINA 0x21C || 0x21C //for that another form
17
-
18
-struct pokemon_data
19
-{
20
-    u8 hp;
21
-    u8 attack;
22
-    u8 defence;
23
-    u8 speed;
24
-    u8 sp_attack;
25
-    u8 sp_defence;
26
-    u8 type_one;
27
-    u8 type_two;
28
-    u8 catch_rate;
29
-    u8 base_exp_yield;
30
-    u16 effort_yield;
31
-    u16 item_one;
32
-    u16 item_two;
33
-    u8 gender;
34
-    u8 egg_cycles;
35
-    u8 base_friendship;
36
-    u8 level_type;
37
-    u8 egg_group_one;
38
-    u8 egg_group_two;
39
-    u8 ability_one;
40
-    u8 ability_two;
41
-    u8 safari_rate;
42
-    u8 color_flip;
43
-    u16 padding;
44
-};
45
-
46
-extern struct pokemon_data pokemon_stats[1300];
47
-
48
-#endif /* POKE_INDICES_H */
1
+#ifndef POKE_INDICES_H
2
+#define POKE_INDICES_H
3
+
4
+#define POKE_PIKACHU    25
5
+#define POKE_FARFETCHD  83
6
+#define POKE_CUBONE     104
7
+#define POKE_MAROWAK    105
8
+#define POKE_CHANSEY    113
9
+#define POKE_DITTO      132
10
+#define POKE_ARTICUNO   144
11
+#define POKE_ZAPDOS     145
12
+#define POKE_MOLTRES    146
13
+#define POKE_MEWTWO     150
14
+#define POKE_LUGIA      249
15
+#define POKE_HOOH       250
16
+#define POKE_CLAMPERL   373
17
+#define POKE_LATIAS     407
18
+#define POKE_LATIOS     408
19
+#define POKE_DEOXYS     410
20
+#define POKE_CHERRIM    512
21
+#define POKE_DIALGA     536
22
+#define POKE_PALKIA     537
23
+#define POKE_GIRATINA   540 || 540 //for that another form
24
+
25
+struct pokemon_data
26
+{
27
+    u8 hp;
28
+    u8 attack;
29
+    u8 defence;
30
+    u8 speed;
31
+    u8 sp_attack;
32
+    u8 sp_defence;
33
+    u8 type_one;
34
+    u8 type_two;
35
+    u8 catch_rate;
36
+    u8 base_exp_yield;
37
+    u16 effort_yield;
38
+    u16 item_one;
39
+    u16 item_two;
40
+    u8 gender;
41
+    u8 egg_cycles;
42
+    u8 base_friendship;
43
+    u8 level_type;
44
+    u8 egg_group_one;
45
+    u8 egg_group_two;
46
+    u8 ability_one;
47
+    u8 ability_two;
48
+    u8 safari_rate;
49
+    u8 color_flip;
50
+    u16 padding;
51
+};
52
+
53
+extern struct pokemon_data pokemon_stats[1300];
54
+
55
+#endif /* POKE_INDICES_H */

+ 13
- 0
src/include/songlist.h Просмотреть файл

@@ -46,11 +46,24 @@
46 46
 #define SEQ_BGM_VS_TT_BOSS_JANA     384
47 47
 #define SEQ_BGM_VS_TT_BOSS_NORMAN   388
48 48
 
49
+#define SEQ_BGM_VS_POKE             298
50
+#define SEQ_BGM_VS_RSE              266
51
+#define SEQ_BGM_VS_CHAMP            299
52
+#define SEQ_BGM_VS_LEADER           296
53
+#define SEQ_BGM_VS_TRAINER          297
54
+
55
+#define SEQ_BGM_VS_DEOXYS           399
56
+#define SEQ_BGM_VS_MEWTWO           340
57
+#define SEQ_BGM_VS_LEG1             341
58
+
49 59
 // Victories
50 60
 
51 61
 #define SEQ_BGM_VIC_TT              387
52 62
 #define SEQ_BGM_VIC_TRAINER         310
53 63
 
64
+#define SEQ_BGM_VIC_LEADER          312
65
+#define SEQ_BGM_VIC_POKE            311
66
+
54 67
 // Various Events
55 68
 
56 69
 #define SEQ_BGM_EVENT_TT_RAID       375

+ 2
- 8
src/include/types.h Просмотреть файл

@@ -14,14 +14,8 @@ typedef     signed long long int    s64;
14 14
 typedef     float                   f32;
15 15
 typedef     double                  f64;
16 16
 
17
-typedef     unsigned int            size_t;
18
-
19
-typedef     unsigned char           bool;
20
-
21
-#define true 1
22
-#define false 0
23
-
24
-#define NULL 0
17
+#include <stddef.h>
18
+#include <stdbool.h>
25 19
 
26 20
 #define rgb5(r,g,b)                 (u16)( r | ( g << 5) | ( b << 10) )
27 21
 

+ 106
- 0
src/music/battle_music_lookup.c Просмотреть файл

@@ -0,0 +1,106 @@
1
+#include <songlist.h>
2
+#include <game_engine.h>
3
+#include <bpre.h>
4
+#include <battle_structs.h>
5
+#include <battle_common.h>
6
+#include <pokemon.h>
7
+
8
+u16 mhk_intro_music_id_to_song(u8 introid) {
9
+    u16 res = 0;
10
+
11
+    switch (introid) {
12
+        case 0:
13
+        case 4:
14
+        case 5:
15
+        case 8:
16
+        case 10:
17
+        case 11:
18
+        case 12:
19
+        case 13:
20
+            res = SEQ_FRLG_E_3;
21
+            break;
22
+        case 1:
23
+        case 2:
24
+        case 9:
25
+            res = SEQ_FRLG_E_2;
26
+            break;
27
+        default:
28
+            res = SEQ_FRLG_E_3;
29
+            break;
30
+    }
31
+
32
+    return res;
33
+}
34
+
35
+// replaces sub_08043FD4
36
+u16 mhk_song_id_for_battle(void) {
37
+    u16 res = 0;
38
+
39
+    if (battle_type_flags._battle_unk_3) {
40
+        res = SEQ_BGM_VS_POKE;
41
+    } else if (battle_type_flags._battle_unk_5 || battle_type_flags.battle_link) {
42
+        res = SEQ_BGM_VS_RSE;
43
+    } else if (battle_type_flags.battle_trainer) {
44
+        switch (trainer_data[trainerbattle_flag_id].trainer_class) {
45
+            case 90:
46
+                res = SEQ_BGM_VS_CHAMP;
47
+                break;
48
+            case 84:
49
+            case 87:
50
+                res = SEQ_BGM_VS_LEADER;
51
+                break;
52
+            default:
53
+                res = SEQ_BGM_VS_TRAINER;
54
+                break;
55
+        }
56
+    } else {
57
+        res = SEQ_BGM_VS_POKE;
58
+    }
59
+
60
+    return res;
61
+}
62
+
63
+void mhk_trainer_battle_play_defeat(void) {
64
+    u16 song = 0;
65
+
66
+    switch (trainer_data[trainerbattle_flag_id].trainer_class) {
67
+        case 84:
68
+        case 90:
69
+            song = SEQ_BGM_VIC_LEADER;
70
+            break;
71
+        default:
72
+            song = SEQ_BGM_VIC_TRAINER;
73
+            break;
74
+    }
75
+
76
+    song_play_for_text(song);
77
+}
78
+
79
+void mhk_wild_poke_def_music(void) {
80
+    song_play_for_text(SEQ_BGM_VIC_POKE);
81
+}
82
+
83
+u16 mhk_species_to_song(u16 species) {
84
+    u16 res = 0;
85
+
86
+    switch (species) {
87
+        case POKE_MEWTWO:
88
+            res = SEQ_BGM_VS_MEWTWO;
89
+            break;
90
+        case POKE_ARTICUNO:
91
+        case POKE_ZAPDOS:
92
+        case POKE_MOLTRES:
93
+        case POKE_LUGIA:
94
+        case POKE_HOOH:
95
+            res = SEQ_BGM_VS_LEG1;
96
+            break;
97
+        case POKE_DEOXYS:
98
+            res = SEQ_BGM_VS_DEOXYS;
99
+            break;
100
+        default:
101
+            res = SEQ_BGM_VS_RSE;
102
+            break;
103
+    }
104
+
105
+    return res;
106
+}

+ 0
- 27
src/music/encounter_lookup.c Просмотреть файл

@@ -1,27 +0,0 @@
1
-#include <songlist.h>
2
-#include <game_engine.h>
3
-
4
-u16 trainer_intro_music_id_to_song(u8 introid) {
5
-    u16 res = 0;
6
-    switch (introid) {
7
-        case 0:
8
-        case 4:
9
-        case 5:
10
-        case 8:
11
-        case 10:
12
-        case 11:
13
-        case 12:
14
-        case 13:
15
-            res = SEQ_FRLG_E_3;
16
-            break;
17
-        case 1:
18
-        case 2:
19
-        case 9:
20
-            res = SEQ_FRLG_E_2;
21
-            break;
22
-        default:
23
-            res = SEQ_FRLG_E_3;
24
-            break;
25
-    }
26
-    return res;
27
-}