/
banim-ekrbattlestarting.c
269 lines (215 loc) · 6.08 KB
/
banim-ekrbattlestarting.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#include "global.h"
#include "proc.h"
#include "hardware.h"
#include "ctc.h"
#include "bm.h"
#include "bmlib.h"
#include "bmio.h"
#include "mu.h"
#include "anime.h"
#include "ekrbattle.h"
#include "efxbattle.h"
#include "ekrdragon.h"
bool sub_8055BB4(void)
{
return PrepareBattleGraphicsMaybe();
}
bool sub_8055BC4(void)
{
return PrepareBattleGraphicsMaybe();
}
void BeginAnimsOnBattleAnimations(void)
{
int ret;
if (GetBattleAnimArenaFlag() == true) {
BeginAnimsOnBattle_Arena();
return;
}
if (CheckBanimHensei() == true) {
BeginAnimsOnBattle_Hensei();
return;
}
NewEkrBattleDeamon();
AnimClearAll();
ret = GetBanimInitPosReal();
gEkrInitPosReal = ret;
NewEkrBattleStarting();
gAnims[0] = NULL;
gAnims[1] = NULL;
gAnims[2] = NULL;
gAnims[3] = NULL;
gUnknown_02000010[0] = NULL;
gUnknown_02000010[1] = NULL;
SetMainUpdateRoutine(MainUpdate_8055C68);
SetPrimaryHBlankHandler(NULL);
}
void EkrMainEndExec(void)
{
if (GetBattleAnimArenaFlag() == true) {
ExecBattleAnimArenaExit();
return;
}
if (CheckBanimHensei() == true) {
ExecEkrHenseiEnd();
return;
}
NewEkrbattleending();
SetMainUpdateRoutine(MainUpdate_8055C68);
}
void MainUpdate_8055C68(void)
{
UpdateKeyStatus(gKeyStatusPtr);
ClearSprites();
Proc_Run(gProcTreeRootArray[1]);
if (GetGameLock() == 0)
Proc_Run(gProcTreeRootArray[2]);
Proc_Run(gProcTreeRootArray[3]);
Proc_Run(gProcTreeRootArray[5]);
PushSpriteLayerObjects(0);
Proc_Run(gProcTreeRootArray[4]);
AnimUpdateAll();
BattleAIS_ExecCommands();
PushSpriteLayerObjects(0xD);
gBmSt.sync_hardware = true;
gBmSt.prevVCount = REG_VCOUNT;
VBlankIntrWait();
}
void NewEkrBattleStarting(void)
{
Proc_Start(ProcScr_ekrBattleStarting, PROC_TREE_3);
}
void ekrBaStart_InitScreen(struct ProcEkrBattleStarting *proc)
{
int val;
proc->timer = 0;
proc->terminator = 0xF;
val = (gEkrBmLocation[0] + gEkrBmLocation[2]) * 8 + 8;
proc->x2 = val;
proc->x1 = val;
val = (gEkrBmLocation[1] + gEkrBmLocation[3]) * 8 + 8;
proc->y2 = val;
proc->y1 = val;
CpuFastFill(0, gBG2TilemapBuffer, 0x800);
BG_EnableSyncByMask(BG2_SYNC_BIT);
SetBlendConfig(3, 0, 0, 4);
SetBlendTargetA(0, 0, 0, 1, 0);
SetWinEnable(1, 0, 0);
SetWin0Box(0, 0, 0xF0, 0xA0);
SetWin0Layers(1, 1, 1, 1, 1);
SetWOutLayers(1, 1, 1, 1, 0);
gLCDControlBuffer.wincnt.win0_enableBlend = 0;
gLCDControlBuffer.wincnt.wout_enableBlend = 1;
Proc_Break(proc);
}
void ekrBaStart_SreenFailIn(struct ProcEkrBattleStarting *proc)
{
int left, top, right, bottom;
if (proc->timer != proc->terminator)
proc->timer++;
left = Interpolate(INTERPOLATE_LINEAR, 0, proc->x1, proc->timer, proc->terminator);
top = Interpolate(INTERPOLATE_LINEAR, 0, proc->y1, proc->timer, proc->terminator);
right = Interpolate(INTERPOLATE_LINEAR, 0xF0, proc->x2, proc->timer, proc->terminator);
bottom = Interpolate(INTERPOLATE_LINEAR, 0xA0, proc->y2, proc->timer, proc->terminator);
SetWin0Box(left, top, right, bottom);
if (proc->timer == proc->terminator) {
SetWOutLayers(1, 1, 1, 1, 1);
InitOam(0);
BMapDispSuspend();
SetWin0Box(0, 0, 0xF0, 0xA0);
EfxPalBlackInOut(gPaletteBuffer, 0x6, 0xA, 0x4);
EnablePaletteSync();
MU_EndAll();
Proc_Break(proc);
}
}
void ekrBaStart_InitBattleScreen(struct ProcEkrBattleStarting *proc)
{
if (0 == gEkrDebugModeMaybe) {
NewEkrGauge();
NewEkrDispUP();
switch (gEkrDistanceType) {
case EKR_DISTANCE_CLOSE:
case EKR_DISTANCE_FAR:
case EKR_DISTANCE_FARFAR:
break;
case EKR_DISTANCE_MONOCOMBAT:
if (gBanimValid[EKR_POS_L] == false) {
EkrGauge_Set4C();
EkrDispUpSet4C();
}
if (gBanimValid[EKR_POS_R] == false) {
EkrGauge_Set50();
EkrDispUpSet50();
}
break;
case EKR_DISTANCE_PROMOTION:
EkrGauge_Set4C();
EkrDispUpSet4C();
break;
default:
break;
}
}
EfxClearScreenFx();
NewEkrUnitKakudai(0);
NewEkrBaseKaiten(0);
NewEkrWindowAppear(0, 0xB);
NewEkrNamewinAppear(0, 0xB, 0);
NewEkrBaseAppear(0, 0xB);
proc->timer = 0;
Proc_Break(proc);
}
void ekrBaStart_ExecEkrBattle6C(struct ProcEkrBattleStarting *proc)
{
if (++proc->timer > 0xB) {
if (gBanimBG == 0 || GetBanimDragonStatusType() != EKRDRGON_TYPE_NORMAL) {
/* In normal battle, here will directly end the proc */
NewEkrBattle();
Proc_End(proc);
} else {
proc->timer = 0;
NewEkrBattle();
Proc_Break(proc);
}
}
}
void ekrBaStart_8055FE8(struct ProcEkrBattleStarting *proc)
{
EfxChapterMapFadeOUT(Interpolate(0, 4, 0x10, proc->timer, 8));
if (++proc->timer == 0x9) {
proc->timer = 0;
Proc_Break(proc);
}
}
void ekrBaStart_8056024(struct ProcEkrBattleStarting *proc)
{
if (gEkrSnowWeather == 0)
gUnknown_0201FAD8 = 0x6;
else
gUnknown_0201FAD8 = 0xA;
PutBanimBG(gBanimBG - 1);
EfxPalBlackInOut(gPaletteBuffer, 0x6, 0xA, 0x10);
Proc_Break(proc);
}
void ekrBaStart_8056078(struct ProcEkrBattleStarting *proc)
{
int val = Interpolate(0, 0x10, 0, proc->timer, 8);
PutBanimBgPAL(gBanimBG - 1);
EfxPalBlackInOut(gPaletteBuffer, 0x6, 0xA, val);
EnablePaletteSync();
if (++proc->timer == 0x9) {
proc->timer = 0;
Proc_Break(proc);
}
}
CONST_DATA struct ProcCmd ProcScr_ekrBattleStarting[] = {
PROC_NAME("ekrBattleStarting"),
PROC_REPEAT(ekrBaStart_InitScreen),
PROC_REPEAT(ekrBaStart_SreenFailIn),
PROC_REPEAT(ekrBaStart_InitBattleScreen),
PROC_REPEAT(ekrBaStart_ExecEkrBattle6C),
PROC_REPEAT(ekrBaStart_8055FE8),
PROC_REPEAT(ekrBaStart_8056024),
PROC_REPEAT(ekrBaStart_8056078),
PROC_END
};