/
banim-efxlvup.c
759 lines (641 loc) · 16.9 KB
/
banim-efxlvup.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
#include "global.h"
#include "proc.h"
#include "anime.h"
#include "ekrbattle.h"
#include "efxbattle.h"
#include "ekrlevelup.h"
#include "hardware.h"
#include "mapanim.h"
#include "ctc.h"
#include "bmlib.h"
EWRAM_OVERLAY(banim) int gEkrBg2ScrollFlip = 0;
EWRAM_OVERLAY(banim) u16 * gpBg2ScrollOffsetStart = NULL;
EWRAM_OVERLAY(banim) u16 * gpBg2ScrollOffset = NULL;
EWRAM_OVERLAY(banim) u16 gpBg2ScrollOffsetTable1[160] = {0};
EWRAM_OVERLAY(banim) u16 gpBg2ScrollOffsetTable2[160] = {0};
EWRAM_OVERLAY(banim) int gEkrBg1ScrollFlip = 0;
EWRAM_OVERLAY(banim) u16 * gpBg1ScrollOffsetStart = NULL;
EWRAM_OVERLAY(banim) u16 * gpBg1ScrollOffset = NULL;
EWRAM_OVERLAY(banim) u16 gpBg1ScrollOffsetList1[160] = {0};
EWRAM_OVERLAY(banim) u16 gpBg1ScrollOffsetList2[160] = {0};
EWRAM_OVERLAY(banim) int gUnknown_02020044 = 0;
CONST_DATA struct ProcCmd ProcScr_EfxPartsofScroll[] = {
PROC_NAME("efxPartsofScroll"),
PROC_SET_END_CB(EfxPartsofScrollCallBack),
PROC_REPEAT(EfxPartsofScrollMain),
PROC_END
};
ProcPtr NewEfxPartsofScroll(void)
{
struct ProcEfx * proc =
Proc_Start(ProcScr_EfxPartsofScroll, PROC_TREE_3);
proc->timer = 0;
proc->step = 0;
return proc;
}
void EfxUpdatePartsofScroll(void)
{
u32 i;
u16 * buf1 = (gEkrBg1ScrollFlip == 0)
? gpBg2ScrollOffsetTable2
: gpBg2ScrollOffsetTable1;
u16 * buf2 = (gEkrBg1ScrollFlip == 0)
? gpBg1ScrollOffsetList2
: gpBg1ScrollOffsetList1;
for (i = 0; i < 0xA0; i++)
{
if (i < 0x28)
{
*buf1++ = 0;
*buf2++ = 0;
continue;
}
if (i <= 0x47)
{
*buf1++ = gEkrLvupScrollPos1;
*buf2++ = gEkrLvupScrollPos1;
continue;
}
if (i <= 0x9F)
{
*buf1++ = gEkrLvupScrollPos2;
*buf2++ = gEkrLvupScrollPos2;
continue;
}
}
}
void EfxPartsofScrollCallBack(ProcPtr proc)
{
return;
}
void EfxPartsofScrollMain(ProcPtr proc)
{
EfxUpdatePartsofScroll();
}
CONST_DATA struct ProcCmd ProcScr_EfxPartsofScroll2[] = {
PROC_NAME("efxPartsofScroll2"),
PROC_SET_END_CB(EfxPartsofScroll2CallBack),
PROC_REPEAT(EfxPartsofScroll2Main),
PROC_END
};
ProcPtr NewEfxPartsofScroll2(void)
{
struct ProcEfx * proc =
Proc_Start(ProcScr_EfxPartsofScroll2, PROC_TREE_3);
proc->timer = 0;
proc->step = 0;
return proc;
}
void EfxPartsofScroll2CallBack(ProcPtr proc)
{
return;
}
CONST_DATA s16 gUnknown_0875941C[] = {
-0x100, -0xEE, -0xDD, -0xCC, -0xBB, -0xAA, -0x99, -0x88,
-0x77, -0x66, -0x55, -0x44, -0x33, -0x22, -0x22, -0x11,
0x11, 0x22, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x100
};
void EfxPartsofScroll2Main(ProcPtr proc)
{
u16 * buf1 = (gEkrBg1ScrollFlip == 0)
? gpBg2ScrollOffsetTable2
: gpBg2ScrollOffsetTable1;
u16 * buf2 = (gEkrBg1ScrollFlip == 0)
? gpBg1ScrollOffsetList2
: gpBg1ScrollOffsetList1;
u32 i = 0;
for (; i < 0xA0; i++)
{
s16 * src = gUnknown_0875941C;
src = src - 0x28;
if (i < 0x28)
{
*buf1++ = 0;
*buf2++ = 0;
continue;
}
if (i <= 0x47)
{
s16 val2 = (src[i] * gEkrLvupScrollPos1) >> 0xC;
if (i + val2 < 0x2F)
val2 = -0x20;
else if (i + val2 >= 0x52)
val2 = -0x20;
*buf1++ = val2;
*buf2++ = val2;
continue;
}
if (i <= 0x9F)
{
*buf1++ = 0;
*buf2++ = 0;
continue;
}
}
}
CONST_DATA struct ProcCmd ProcScr_Efxleveluphb[] = {
PROC_NAME("efxLevelupHB"),
PROC_SET_END_CB(EfxleveluphbCallBack),
PROC_REPEAT(EfxleveluphbNop),
PROC_REPEAT(EfxleveluphbMain),
PROC_END
};
ProcPtr NewEfxleveluphb(void)
{
u32 i;
struct ProcEfx * proc;
u16 * buf;
struct ProcCmd * v;
gEfxBgSemaphore++;
buf = gpBg2ScrollOffsetTable1;
for (i = 0; i < 0xA0; i++)
*buf++ = 0;
buf = gpBg2ScrollOffsetTable2;
for (i = 0; i < 0xA0; i++)
*buf++ = 0;
buf = gpBg1ScrollOffsetList1;
for (i = 0; i < 0xA0; i++)
*buf++ = 0;
buf = gpBg1ScrollOffsetList2;
for (i = 0; i < 0xA0; i++)
*buf++ = 0;
gEkrBg2ScrollFlip = 0;
v = ProcScr_Efxleveluphb; // by permuter
gEkrBg1ScrollFlip = 0;
#ifndef NONMATCHING
asm("":::"v7"); // by me
#endif
buf = gpBg2ScrollOffsetTable1;
gpBg2ScrollOffsetStart = buf;
buf = gpBg1ScrollOffsetList1;
gpBg1ScrollOffsetStart = buf;
buf = gpBg2ScrollOffsetStart;
gpBg2ScrollOffset = buf;
buf = gpBg1ScrollOffsetStart;
gpBg1ScrollOffset = buf;
proc = Proc_Start(v, PROC_TREE_VSYNC);
proc->timer = 0;
return proc;
}
void EfxleveluphbCallBack(ProcPtr proc)
{
SetPrimaryHBlankHandler(NULL);
}
void EfxleveluphbNop(ProcPtr proc)
{
Proc_Break(proc);
}
void EfxleveluphbMain(ProcPtr proc)
{
if (gBmSt.sync_hardware != false)
{
if (gEkrBg2ScrollFlip == 1)
{
gEkrBg2ScrollFlip = 0;
gpBg2ScrollOffsetStart = gpBg2ScrollOffsetTable1;
}
else
{
gEkrBg2ScrollFlip = 1;
gpBg2ScrollOffsetStart = gpBg2ScrollOffsetTable2;
}
if (gEkrBg1ScrollFlip == 1)
{
gEkrBg1ScrollFlip = 0;
gpBg1ScrollOffsetStart = gpBg1ScrollOffsetList1;
}
else
{
gEkrBg1ScrollFlip = 1;
gpBg1ScrollOffsetStart = gpBg1ScrollOffsetList2;
}
}
gpBg2ScrollOffset = gpBg2ScrollOffsetStart;
gpBg1ScrollOffset = gpBg1ScrollOffsetStart;
}
void EkrLvupHBlank(void)
{
/* line 160..226 */
if (REG_DISPSTAT & DISPSTAT_VBLANK)
return;
REG_BG2HOFS = *gpBg2ScrollOffset++;
REG_BG1HOFS = *gpBg1ScrollOffset++;
}
void EfxPartsofScroll2HBlank(void)
{
/* line 160..226 */
if (REG_DISPSTAT & DISPSTAT_VBLANK)
return;
REG_BG2VOFS = gLCDControlBuffer.bgoffset[2].y + *gpBg2ScrollOffset++;
REG_BG1VOFS = gLCDControlBuffer.bgoffset[1].y + *gpBg1ScrollOffset++;
}
CONST_DATA struct ProcCmd ProcScr_Efxlvupbg[] = {
PROC_NAME("efxLvupBG"),
PROC_REPEAT(EfxlvupbgMain),
PROC_END
};
const u16 FrameConfig_EfxLvupBG[] = {
0, 1,
1, 1,
2, 1,
3, 1,
4, 1,
5, 1,
6, 1,
7, 1,
8, 1,
9, 1,
10, 1,
-1
};
CONST_DATA u16 * TsaLut_EfxLvupBG[] = {
Tsa1_EfxLvupBG,
Tsa2_EfxLvupBG,
Tsa3_EfxLvupBG,
Tsa4_EfxLvupBG,
Tsa5_EfxLvupBG,
Tsa6_EfxLvupBG,
Tsa7_EfxLvupBG,
Tsa8_EfxLvupBG,
Tsa9_EfxLvupBG,
Tsa10_EfxLvupBG,
Tsa11_EfxLvupBG
};
CONST_DATA u16 * ImgLut_EfxLvupBG[] = {
Img1_EfxLvupBG,
Img1_EfxLvupBG,
Img2_EfxLvupBG,
Img2_EfxLvupBG,
Img3_EfxLvupBG,
Img4_EfxLvupBG,
Img5_EfxLvupBG,
Img6_EfxLvupBG,
Img7_EfxLvupBG,
Img7_EfxLvupBG,
Img7_EfxLvupBG
};
void NewEfxlvupbg(struct Anim * anim)
{
struct ProcEfxBG * proc =
Proc_Start(ProcScr_Efxlvupbg, PROC_TREE_3);
proc->anim = anim;
proc->timer = 0;
proc->frame = 0;
proc->frame_config = FrameConfig_EfxLvupBG;
proc->tsal = TsaLut_EfxLvupBG;
proc->tsar = TsaLut_EfxLvupBG;
proc->img = ImgLut_EfxLvupBG;
SpellFx_RegisterBgPal(Pal_EfxLvupBG, 0x20);
SpellFx_SetSomeColorEffect();
}
void EfxlvupbgMain(struct ProcEfxBG * proc)
{
int ret;
ret = EfxAdvanceFrameLut((s16 *)&proc->timer, (s16 *)&proc->frame, proc->frame_config);
if (ret >= 0) {
u16 ** tsa1 = proc->tsal;
u16 ** tsa2 = proc->tsar;
u16 ** img = proc->img;
SpellFx_WriteBgMap(proc->anim, tsa1[ret], tsa2[ret]);
SpellFx_RegisterBgGfx(img[ret], 0x2000);
return;
}
if (ret == -1)
{
SpellFx_ClearBG1();
SetDefaultColorEffects_();
Proc_Break(proc);
}
}
CONST_DATA struct ProcCmd ProcScr_efxLvupBG2[] = {
PROC_NAME("efxLvupBG2"),
PROC_REPEAT(EfxLvupBg2Main),
PROC_END
};
CONST_DATA u16 * TsaLut_EfxLvupBG2[] = {
Tsa1_EfxLvupBG2,
Tsa2_EfxLvupBG2,
Tsa3_EfxLvupBG2,
Tsa4_EfxLvupBG2,
Tsa5_EfxLvupBG2,
Tsa6_EfxLvupBG2
};
const u16 FrameConfig_EfxLvupBG2[] = {
0, 1,
1, 1,
2, 1,
3, 1,
4, 1,
5, 0x1C,
-1
};
void NewEfxLvupBG2(struct Anim * anim)
{
struct ProcEfxBG * proc =
Proc_Start(ProcScr_efxLvupBG2, PROC_TREE_3);
proc->anim = anim;
proc->timer = 0;
proc->frame = 0;
proc->frame_config = FrameConfig_EfxLvupBG2;
proc->tsal = TsaLut_EfxLvupBG2;
proc->tsar = TsaLut_EfxLvupBG2;
SpellFx_RegisterBgGfx(Img_EfxLvupBG2, 0x2000);
SpellFx_RegisterBgPal(Pal_EfxLvupBG2, 0x20);
}
void EfxLvupBg2Main(struct ProcEfxBG * proc)
{
int ret;
ret = EfxAdvanceFrameLut((s16 *)&proc->timer, (s16 *)&proc->frame, proc->frame_config);
if (ret >= 0) {
u16 ** tsa1 = proc->tsal;
u16 ** tsa2 = proc->tsar;
SpellFx_WriteBgMap(proc->anim, tsa1[ret], tsa2[ret]);
return;
}
if (ret == -1)
Proc_Break(proc);
}
CONST_DATA struct ProcCmd ProcScr_efxLvupOBJ2[] = {
PROC_NAME("efxLvupOBJ2"),
PROC_SET_END_CB(EfxLvupOBJ2CallBack),
PROC_SLEEP(0x18),
PROC_END
};
void NewEfxLvupOBJ2(struct Anim * anim, int x, int y)
{
struct Anim * anim3;
struct ProcEfxOBJ * proc =
Proc_Start(ProcScr_efxLvupOBJ2, PROC_TREE_3);
proc->anim = anim;
anim3 = EfxCreateFrontAnim(anim, AnimScr_EfxLvupOBJ2, AnimScr_EfxLvupOBJ2, AnimScr_EfxLvupOBJ2, AnimScr_EfxLvupOBJ2);
proc->anim3 = anim3;
anim3->xPosition = x;
anim3->yPosition = y;
SpellFx_RegisterObjGfx(Img_EfxLvupOBJ2, 0x1000);
SpellFx_RegisterObjPal(Pal_EfxLvupBG2, 0x20);
}
void EfxLvupOBJ2CallBack(struct ProcEfxOBJ * proc)
{
AnimDelete(proc->anim3);
}
CONST_DATA struct ProcCmd ProcScr_efxLvupBGCOL[] = {
PROC_NAME("efxLvupBGCOL"),
PROC_REPEAT(Loop6C1_EfxLvupBGCOL),
PROC_REPEAT(Loop6C2_EfxLvupBGCOL),
PROC_END
};
const u16 FrameLut_EfxLvupBGCOL[] = {
0, 2,
1, 2,
2, 2,
3, 2,
4, 2,
5, 2,
6, 2,
7, 2,
8, 2,
9, 2,
10, 2,
11, 2,
12, 2,
13, 2,
14, 2,
15, 2,
-2
};
void NewEfxLvupBGCOL(struct Anim * anim)
{
struct ProcEfxBGCOL * proc =
Proc_Start(ProcScr_efxLvupBGCOL, PROC_TREE_3);
proc->anim = anim;
proc->timer = 0;
proc->timer2 = 0;
proc->terminator = 0x19;
proc->frame = 0;
proc->frame_config = FrameLut_EfxLvupBGCOL;
proc->pal = Pal_EfxLvupBGCOL;
}
const u16 FrameLut2_EfxLvupBGCOL[] = {
0, 2,
1, 2,
2, 2,
3, 2,
-1
};
void Loop6C1_EfxLvupBGCOL(struct ProcEfxBGCOL * proc)
{
int ret;
ret = EfxAdvanceFrameLut((s16 *)&proc->timer, (s16 *)&proc->frame, proc->frame_config);
if (ret >= 0)
sub_805588C(proc->pal, gPaletteBuffer + 1, ret, 0xF, 8);
if (++proc->timer2 > proc->terminator)
{
proc->timer = 0;
proc->timer2 = 0;
proc->frame = 0;
proc->frame_config = FrameLut2_EfxLvupBGCOL;
proc->pal = Pal_EfxLvupBG2;
Proc_Break(proc);
}
}
void Loop6C2_EfxLvupBGCOL(struct ProcEfxBGCOL * proc)
{
int ret;
ret = EfxAdvanceFrameLut((s16 *)&proc->timer, (s16 *)&proc->frame, proc->frame_config);
if (ret >= 0)
{
u16 * pal = proc->pal;
SpellFx_RegisterBgPal(&PAL_BUF_COLOR(pal, ret, 0), 0x20);
return;
}
if (ret == -1)
Proc_Break(proc);
}
void EkrLvupApfxInit(struct ProcEkrLvupApfx * proc)
{
proc->clock = 0;
}
void EkrLvupApfxMain(struct ProcEkrLvupApfx * proc)
{
int new_color_offset;
u16 * colors = Pal_ManimLevelUpStatGainCycling;
++proc->clock;
if (proc->clock & 3)
return;
new_color_offset = (proc->clock >> 2) & 0xF;
// TODO: constants
CopyToPaletteBuffer(colors + new_color_offset + 0x00, (0x10 + proc->pal + 0) * 0x20 + 0x12, 0x20 - 0x12);
CopyToPaletteBuffer(colors + new_color_offset + 0x20, (0x10 + proc->pal + 1) * 0x20 + 0x12, 0x20 - 0x12);
}
CONST_DATA struct ProcCmd ProcScr_EkrLvupApfx[] = {
PROC_CALL(EkrLvupApfxInit),
PROC_REPEAT(EkrLvupApfxMain),
PROC_END
};
void NewEkrLvupApfx(int chr, int pal)
{
int pal_bank;
const u16 * pal_src;
struct ProcEkrLvupApfx * proc;
Decompress(Img_ManimLevelUpStatGain, OBJ_VRAM0 + OAM2_CHR(chr) * CHR_SIZE);
pal_src = Pal_ManimLevelUp;
pal_bank = pal + 0x10;
ApplyPalette(pal_src, pal + 0x10);
pal_bank = pal + 0x11;
ApplyPalette(pal_src, pal_bank);
proc = Proc_Start(ProcScr_EkrLvupApfx, PROC_TREE_3);
proc->pal = pal;
gEkrLvupApfxUnexist = false;
}
void EkrLvupApfxEndEach(void)
{
Proc_EndEach(ProcScr_EkrLvupApfx);
gEkrLvupApfxUnexist = true;
}
void PutEkrLvupStatGainLabelGfx1(int stat_num, int stat_gain)
{
u8 * img = Img_EkrLvupNumBig;
register int chr asm("r4");
int chr_this_stat;
chr = (stat_num - 1) * 2;
chr_this_stat = chr;
if (chr < 0)
chr_this_stat = -chr;
VramCopy(img + OAM2_CHR(chr_this_stat) * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x2C) << 5), 2 * CHR_SIZE);
chr_this_stat = chr >= 0 ? chr : -chr;
VramCopy(img + OAM2_CHR((chr_this_stat) + 0x20) * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x4C) << 5), 2 * CHR_SIZE);
}
void PutEkrLvupStatGainLabelGfx2(int chr, int stat_gain)
{
int chr_this_stat;
int chr_this_stat_2;
u8 * img1;
u8 * img2;
img1 = Img_ManimLevelUpStatGainDigits;
img2 = Img_EkrLvupNumBig;
if (chr >= 0)
{
VramCopy(img2 + 0x18 * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x2C) << 5), 2 * CHR_SIZE);
VramCopy(img2 + 0x38 * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x4C) << 5), 2 * CHR_SIZE);
}
else
{
VramCopy(img2 + 0x1A * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x2C) << 5), 2 * CHR_SIZE);
VramCopy(img2 + 0x3A * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x4C) << 5), 2 * CHR_SIZE);
}
chr_this_stat = chr >= 0 ? chr : -chr;
VramCopy(img1 + OAM2_CHR(chr_this_stat) * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x2D) << 5), CHR_SIZE);
chr_this_stat_2 = chr >= 0 ? chr : -chr;
VramCopy(img1 + OAM2_CHR((chr_this_stat_2) + 0x20) * CHR_SIZE,
OBJ_VRAM0 + (OAM2_CHR(stat_gain + 0x4D) << 5), CHR_SIZE);
}
CONST_DATA struct ProcCmd ProcScr_eobjLvup[] = {
PROC_NAME("eobjLvup"),
PROC_REPEAT(sub_8074E6C),
PROC_REPEAT(sub_8074EDC),
PROC_REPEAT(sub_8074F14),
PROC_END
};
void BanimDrawStatupAp(int chr, int pal, int x, int y, int index, int gain)
{
s32 sp14 = chr;
int chr2 = chr + 2 * (index - 1);
#ifndef NONMATCHING
register int _pal asm("r6") = pal << 12;
register struct ProcEobjLvup * proc asm("r4");
#else
int _pal = pal << 12;
struct ProcEobjLvup * proc;
#endif
int _chr = chr | 0x400;
int __oam = _pal;
if (__oam) { __oam++; __oam--; } // serialize code
__oam |= _chr;
NewEkrsubAnimeEmulator(x - 0x12, y - 0x04, gUnknown_085C9270, 0, __oam, 0, PROC_TREE_5);
if (index == 0)
return;
proc = Proc_Start(ProcScr_eobjLvup, PROC_TREE_3);
if (gain >= 0)
{
proc->child2 = NewEkrsubAnimeEmulator(x, y, gUnknown_085C92A0, 2, __oam, 0, PROC_TREE_5);
}
else
{
int _oam = 0x400 | _pal | chr2;
proc->child1 = NewEkrsubAnimeEmulator(x - 3, y, gUnknown_085C92EC, 2, _oam, 0, PROC_TREE_5);
_pal |= _chr;
proc->child2 = NewEkrsubAnimeEmulator(x, y, gUnknown_085C92D0, 2, _pal, 0, PROC_TREE_5);
PutEkrLvupStatGainLabelGfx2(gain, chr2);
}
proc->x = x;
proc->y = y;
proc->timer = 0;
proc->chr1 = sp14;
proc->chr2 = chr2;
proc->chr = chr;
proc->pal = pal;
proc->index = index;
proc->diff = gain;
}
void sub_8074E6C(struct ProcEobjLvup * proc)
{
int oam2;
if (proc->diff < 0)
{
Proc_Break(proc);
return;
}
if (++proc->timer == 0xF)
{
proc->timer = 0;
{
int _pal = proc->pal << 12;
int _chr = proc->chr2;
int _lay = 0x400;
oam2 = _pal | (_chr | _lay);
}
proc->child1 = NewEkrsubAnimeEmulator(
proc->x - 3,
proc->y,
gUnknown_085C9328,
2,
oam2,
0,
PROC_TREE_3
);
PutEkrLvupStatGainLabelGfx1(proc->diff, proc->chr2);
Proc_Break(proc);
}
}
void sub_8074EDC(struct ProcEobjLvup * proc)
{
int oam2;
if (proc->diff < 0)
{
Proc_Break(proc);
return;
}
if (++proc->timer == 0xF)
{
proc->timer = 0;
PutEkrLvupStatGainLabelGfx2(proc->diff, proc->chr2);
Proc_Break(proc);
}
}
void sub_8074F14(struct ProcEobjLvup * proc)
{
if (gEkrLvupApfxUnexist == true)
{
Proc_End(proc->child1);
Proc_End(proc->child2);
Proc_Break(proc);
}
}