Skip to content

Commit d9d3075

Browse files
main/mbar: Partial match for ExamDispOn/hex2decPlMi/hex2decPlMi
Also fix build by moving static variable as extern
1 parent 396f338 commit d9d3075

File tree

2 files changed

+148
-16
lines changed

2 files changed

+148
-16
lines changed

config/p3.jul12.symbol_addrs.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ guime_camera_hdl = 0x00399a94;
871871

872872
exam_global_ply = 0x01c70030; // size:0x10
873873
exam_global_ply_current_ply = 0x01c70040; // size:0x10
874+
tp_tmp1 = 0x01c6ffc0; // size:0x10
874875
metFrameCnt = 0x01c70050; // size:0xc
875876
metFrameCntLight = 0x01c70060; // size:0xc
876877
scr_tenmetu_col_dat = 0x01c70070; // size:0xc
@@ -2396,6 +2397,7 @@ __divdi3 = 0x001680d0; // type:func
23962397
exit = 0x00169730; // type:func
23972398
__fixsfdi = 0x00169760; // type:func
23982399
__floatdisf = 0x00169a20; // type:func
2400+
__muldi3 = 0x0016a168; // type:func
23992401
__udivdi3 = 0x0016a1c8; // type:func
24002402
__umoddi3 = 0x0016a798; // type:func
24012403

src/main/mbar.c

Lines changed: 146 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
// /* data 186f08 */ static int guimap_hk[];
3434
/* bss 1c70030 */ extern GLOBAL_PLY *exam_global_ply[4]; /* static */
3535
/* sbss 399a80 */ extern GLOBAL_PLY *exam_global_ply_current;
36+
/* bss 1c6ffc0 */ extern sceGsLoadImage tp_tmp1; /* static */
3637
/* bss 1c70040 */ extern int exam_global_ply_current_ply[4]; /* static */
3738
/* bss 1c70050 */ extern int metFrameCnt[3]; /* static */
3839
/* bss 1c70060 */ extern int metFrameCntLight[3]; /* static */
@@ -117,7 +118,6 @@ void examCharSet(EX_CHAR_DISP *ecd_pp, sceGifPacket *gifpk_pp) {
117118
}
118119

119120
static void clrColorBuffer(int id) {
120-
static sceGsLoadImage tp;
121121
TIM2_DAT *tim2_dat_pp;
122122
u_char *tr_adr;
123123
u_int cpsm, cbp;
@@ -126,9 +126,9 @@ static void clrColorBuffer(int id) {
126126
tr_adr = (u_char*)&tmpColor;
127127
cpsm = (int)(PR_TEX0(tim2_dat_pp).CPSM << 32) >> 32;
128128
cbp = (int)(PR_TEX0(tim2_dat_pp).CBP << 32) >> 32;
129-
sceGsSetDefLoadImage(&tp, cbp, 1, cpsm, 0, 0, 8, 2);
129+
sceGsSetDefLoadImage(&tp_tmp1, cbp, 1, cpsm, 0, 0, 8, 2);
130130
FlushCache(0);
131-
sceGsExecLoadImage(&tp, (u_long128*)tr_adr);
131+
sceGsExecLoadImage(&tp_tmp1, (u_long128*)tr_adr);
132132
sceGsSyncPath(0, 0);
133133
}
134134

@@ -437,37 +437,37 @@ static void metColorInit(void) {
437437
}
438438
}
439439

440-
// TODO
441440
static void metColorSet(EXAM_TYPE exam_type, float per) {
442441
u_char *moto_pp;
443442
u_char *saki_pp;
444443
int sakiper;
445444

446-
if (per == 0.0f) {
445+
if (per == 0.f) {
447446
return Tim2Trans(cmnfGetFileAdrs(metcol_str[exam_type].df_num));
448447
}
449-
if (per == -1.0f) {
448+
if (per == -1.f) {
450449
return Tim2Trans(cmnfGetFileAdrs(metcol_str[exam_type].ng_num));
451450
}
452-
if (per == 1.0f) {
451+
if (per == 1.f) {
453452
return Tim2Trans(cmnfGetFileAdrs(metcol_str[exam_type].ok_num));
454453
}
455454
sakiper = metcol_str[exam_type].df_num;
456455
moto_pp = cmnfGetFileAdrs(sakiper);
457-
if (per < 0.0f) {
456+
if (per < 0.f) {
458457
per = -per;
459-
if (1.0f < per) {
460-
per = 1.0f;
458+
if (1.f < per) {
459+
per = 1.f;
461460
}
462-
sakiper = metcol_str[exam_type].ng_num;
461+
saki_pp = cmnfGetFileAdrs(metcol_str[exam_type].ng_num);
462+
sakiper = per * 128;
463463
} else {
464-
if (1.0f < per) {
465-
per = 1.0f;
464+
if (1.f < per) {
465+
per = 1.f;
466466
}
467-
sakiper = metcol_str[exam_type].ok_num;
467+
saki_pp = cmnfGetFileAdrs(metcol_str[exam_type].ok_num);
468+
sakiper = per * 128;
468469
}
469-
saki_pp = cmnfGetFileAdrs(sakiper);
470-
Cl2MixTrans(per * 128.0f, 128, saki_pp, moto_pp);
470+
Cl2MixTrans(sakiper, 128, saki_pp, moto_pp);
471471
}
472472

473473
void metFrameInit(void) {
@@ -559,13 +559,143 @@ float examScore2Level(long score) {
559559
return ret_lvl;
560560
}
561561

562+
#ifndef NON_MATCHING
562563
INCLUDE_ASM("asm/nonmatchings/main/mbar", ExamDispOn);
564+
#else
565+
static void ExamDispOn() {
566+
int met_time;
567+
int i;
568+
float maxfr;
569+
float lev_tmp;
570+
u_int perd;
571+
u_char *moto_p;
572+
573+
if (exam_disp_cursor_timer < 0) {
574+
return metFrameInit();
575+
}
576+
exam_disp_cursor_timer += 1;
577+
if (exam_disp_cursor_timer >= 91) {
578+
exam_disp_cursor_timer = -1;
579+
metColorInit();
580+
for (i = 0; i < 3; i++) {
581+
exam_global_ply_current_ply[i] = 0;
582+
}
583+
met_time = 0;
584+
} else if (exam_disp_cursor_timer >= 61) {
585+
met_time = 90 - exam_disp_cursor_timer;
586+
} else {
587+
met_time = 30;
588+
if (met_time >= exam_disp_cursor_timer) {
589+
met_time = exam_disp_cursor_timer;
590+
}
591+
}
592+
maxfr = met_time / 30.0f;
593+
for (i = 0; i < 3; i++) {
594+
lev_tmp = examScore2Level(exam_global_ply_current->exam_score[i]);
595+
if (lev_tmp < 0.0f && lev_tmp < -maxfr) {
596+
lev_tmp = -maxfr;
597+
}
598+
if (0.0f < lev_tmp && maxfr < lev_tmp) {
599+
lev_tmp = maxfr;
600+
}
601+
if (exam_global_ply_current->exam_score[i] > 0) {
602+
metColorSet(i, maxfr);
603+
} else {
604+
metColorSet(i, -maxfr);
605+
}
606+
lev_tmp -= -1.0;
607+
lev_tmp = (lev_tmp / 2.0) * 280.0;
608+
metFrameCnt[i] = lev_tmp;
609+
if (exam_disp_cursor_timer < 30) {
610+
if (exam_global_ply_current->exam_score[i] > 0) {
611+
metFrameCntLight[i] = exam_disp_cursor_timer;
612+
} else {
613+
metFrameCntLight[i] = exam_disp_cursor_timer + 60;
614+
}
615+
} else {
616+
metFrameCntLight[i] = 0;
617+
}
618+
}
619+
for (i = 0; i < 3; i++) {
620+
if (exam_global_ply_current_ply[i] != 0) {
621+
if (exam_global_ply[i]->now_score > 0) {
622+
moto_p = scr_tenmetu_col[1];
623+
} else {
624+
moto_p = scr_tenmetu_col[2];
625+
}
626+
perd = exam_disp_cursor_timer * 16;
627+
if (perd & 0x100) {
628+
perd ^= 0xff;
629+
}
630+
perd &= 0xff;
631+
scr_tenmetu_col_dat[i][0] = ((moto_p[0] * perd) >> 9) + (moto_p[0] >> 1);
632+
scr_tenmetu_col_dat[i][1] = ((moto_p[1] * perd) >> 9) + (moto_p[1] >> 1);
633+
scr_tenmetu_col_dat[i][2] = ((moto_p[2] * perd) >> 9) + (moto_p[2] >> 1);
634+
}
635+
}
636+
}
637+
#endif
563638

564639
INCLUDE_ASM("asm/nonmatchings/main/mbar", hex2dec_mbar_tmp);
565640

641+
#ifndef NON_MATCHING
566642
INCLUDE_ASM("asm/nonmatchings/main/mbar", hex2decPlMi);
643+
#else
644+
static u_long hex2decPlMi(long int data) {
645+
u_long ret;
646+
int i;
647+
long int plmichar;
567648

649+
ret = 0;
650+
if (data == 0) {
651+
return ret;
652+
}
653+
plmichar = data < 1 ? 0 : 10;
654+
if (data < 0) {
655+
plmichar = 11;
656+
data *= -1;
657+
}
658+
for (i = 0; i < 16u && data; i++) {
659+
ret |= (data % 10) << (i * 4);
660+
data /= 10;
661+
}
662+
ret |= plmichar << (i * 4);
663+
return ret;
664+
}
665+
#endif
666+
667+
#ifndef NON_MATCHING
568668
INCLUDE_ASM("asm/nonmatchings/main/mbar", examNumDisp);
669+
#else
670+
void examNumDisp(sceGifPacket *ex_gif_pp, long int score, short int x, short int y, int keta, u_char *coldat_pp, int plmi) {
671+
int i;
672+
u_char num;
673+
int first_f;
674+
EX_CHAR_DISP ex_ecd;
675+
676+
first_f = 0;
677+
examCharBasic(&ex_ecd, &tim2spr_tbl_tmp1[27]);
678+
examCharKidoSet(&ex_ecd, coldat_pp[0], coldat_pp[1], coldat_pp[2]);
679+
if (plmi != 0) {
680+
score = hex2decPlMi(score);
681+
} else {
682+
score = hex2dec(score);
683+
}
684+
for (i = 0; i < keta; i++) {
685+
num = keta - (i + 1);
686+
num <<= 2;
687+
num = score >> num;
688+
num &= 0xf;
689+
num &= 0xff;
690+
if (num != 0 || first_f != 0 || i == keta - 1) {
691+
first_f = 1;
692+
examCharUVWHSet(&ex_ecd, num * 13, 0, 13, 24);
693+
examCharPosSet(&ex_ecd, x + (i * 16) - i, y);
694+
examCharSet(&ex_ecd, ex_gif_pp);
695+
}
696+
}
697+
}
698+
#endif
569699

570700
INCLUDE_ASM("asm/nonmatchings/main/mbar", examScoreSet);
571701

0 commit comments

Comments
 (0)