Skip to content

Instantly share code, notes, and snippets.

@camprevail
Last active September 20, 2024 04:00
Show Gist options
  • Save camprevail/e2b70948ae85c38b5dae742f57a77099 to your computer and use it in GitHub Desktop.
Save camprevail/e2b70948ae85c38b5dae742f57a77099 to your computer and use it in GitHub Desktop.
museca - judge_hit_notes decomp
void __fastcall judge_hit_note(CGameSceneComponent *cGSC_, NoteStruct *noteStruct_)
{
NoteStruct *noteStruct; // rdi
CGameSceneComponent *cGSC; // rbx
int v4; // eax
int noteTimeDelta; // er13
float flt_noteTimeDelta; // xmm6_4
float _volatile_xmm0; // xmm0_4
int judgeType; // esi
NOTE_TYPE_INTERNAL lane; // er11
char btnPressed; // r9
signed int abs_noteTimeDelta; // er10
BUTTON_TYPE btn; // ecx
__int64 ptr_PlayScore_; // rcx
int judgeFrame; // eax
int v15; // er12
int judgeFrame_; // eax
__int64 ptr_PlayScore; // rcx
signed __int64 v18; // rdx
__int64 v19; // rcx
signed int v20; // eax
if ( !noteStruct_ )
return;
noteStruct = noteStruct_;
cGSC = cGSC_;
if ( noteStruct_->judged )
return;
if ( noteStruct_->kind_internal ) // if it's anything but a hit note
return;
v4 = cGSC_->judgedLaneMask;
if ( _bittest(&v4, noteStruct_->lane) )
return;
noteTimeDelta = cGSC_->currentTime - cGSC_->offset - noteStruct_->stime;
if ( noteTimeDelta <= -300 )
return;
flt_noteTimeDelta = noteTimeDelta;
_volatile_xmm0 = get_timing_window(&cGSC_->PlayScore, NEAR) * 2.0;// Getting some value from PlayScore->GiftParam.
// For NEAR, 144 seems to be returned
if ( noteTimeDelta <= _volatile_xmm0 )
{
lane = noteStruct_->lane;
btnPressed = 0;
abs_noteTimeDelta = abs(noteTimeDelta);
switch ( lane )
{
case 0:
btn = 4;
goto LABEL_15;
case 1:
btn = 5;
goto LABEL_15;
case 2:
btn = 6;
goto LABEL_15;
case 3:
btn = 7;
goto LABEL_15;
case 4:
btn = 8;
LABEL_15:
if ( CRVOLDevice::GetButtonTrigger(btn) )
btnPressed = 1;
break;
case 5:
if ( CRVOLDevice::GetButtonTrigger(btn_pedal) )
btnPressed = 1;
break;
default:
break;
}
if ( cGSC->autoplay || dead_debug_check() )
{
if ( cGSC->currentTime < (noteStruct->stime - 8.335) )
return;
judgeType = CRITICAL;
if ( flt_noteTimeDelta >= 0.0 )
{
_volatile_xmm0 = floorf((flt_noteTimeDelta + 8.335) / 16.67);// 16.67 is the length of one frame in ms
judgeFrame = _volatile_xmm0;
goto LABEL_35;
}
}
else
{
if ( !btnPressed )
return;
judgeType = CRITICAL;
ptr_PlayScore_ = &cGSC->PlayScore;
if ( lane == PEDAL_AND_MARKERS )
{ // this code doesn't belong here lol. It'll never get called
_volatile_xmm0 = get_timing_window(ptr_PlayScore_, CRITICAL) * 1.5;
if ( _volatile_xmm0 < abs_noteTimeDelta )
{
_volatile_xmm0 = get_timing_window(&cGSC->PlayScore, NEAR) * 3.0;
if ( _volatile_xmm0 < abs_noteTimeDelta )
return;
judgeType = NEAR;
}
goto LABEL_49;
}
if ( abs_noteTimeDelta > get_timing_window(ptr_PlayScore_, CRITICAL) )// returns 48 for crit
{
_volatile_xmm0 = get_timing_window(&cGSC->PlayScore, NEAR) * 2.0;// returns 144 for near
if ( _volatile_xmm0 < abs_noteTimeDelta )
return;
judgeType = NEAR;
goto LABEL_49;
}
if ( flt_noteTimeDelta >= 0.0 )
{
_volatile_xmm0 = floorf((flt_noteTimeDelta + 8.335) / 16.67);
judgeFrame = _volatile_xmm0;
goto LABEL_35;
}
}
_volatile_xmm0 = floorf((abs_noteTimeDelta + 8.335) / 16.67);
judgeFrame = -_volatile_xmm0;
LABEL_35:
if ( judgeFrame ) // Increments the just_checker values seen in the save_m request.
// Appears to be for critical notes only.
{
switch ( judgeFrame )
{
case 1:
++cGSC->after_1;
break;
case 0xFFFFFFFF:
++cGSC->before_1;
break;
case 2:
++cGSC->after_2;
break;
case 0xFFFFFFFE:
++cGSC->before_2;
break;
default:
if ( judgeFrame <= 2 )
{
if ( judgeFrame < -2 )
++cGSC->before_3;
}
else
{
++cGSC->after_3;
}
break;
}
}
else
{
++cGSC->just;
}
goto LABEL_49;
}
judgeType = 1;
if ( !cGSC->field_4FC0 )
cGSC->field_4FC0 = 10;
LABEL_49:
v15 = 0;
HIBYTE(cGSC->field_4FE0) = 1;
cGSC->field_4FBC = 10;
LODWORD(cGSC->field_47B8) = 0;
if ( judgeType != ERROR )
cGSC->note_hit_array[noteStruct->lane] = 1; // 20440 is an byte array that sets a value at the index of the lane if the note was hit?
if ( judgeType == NEAR )
{
if ( flt_noteTimeDelta < 0.0 ) // if early
{
_volatile_xmm0 = floorf((abs(noteTimeDelta) + 8.335) / 16.67);
judgeFrame_ = -_volatile_xmm0; // negate if early
}
else
{
_volatile_xmm0 = floorf((flt_noteTimeDelta + 8.335) / 16.67);
judgeFrame_ = _volatile_xmm0;
}
LOBYTE(v15) = judgeFrame_ >= 0;
LODWORD(cGSC->field_47B8) = v15 + 2;
}
NoteStruct::SetJudgeInfo(noteStruct, judgeType, cGSC->currentTime);
ptr_PlayScore = &cGSC->PlayScore;
if ( noteStruct->is_GA_note )
{
v18 = (&cGSC->GiftParam + 397 * noteStruct->GA_grafica_index);
cGSC->field_1AF8 = cGSC->field_1AF0;
cGSC->field_1AF0 = v18;
playscore_restscore_idk(
cGSC->currentTime,
ptr_PlayScore,
noteStruct->lane,
noteStruct->kind_internal,
_volatile_xmm0,
judgeType,
2,
noteStruct->GA_grafica_index);
}
else
{
playscore_restscore_idk(
cGSC->currentTime,
ptr_PlayScore,
noteStruct->lane,
noteStruct->kind_internal,
_volatile_xmm0,
judgeType,
1,
noteStruct->GA_grafica_index);
}
sub_1801EA450(&cGSC->CGameSequence, noteStruct);// move note struct
set_Crit_Near_Error_frame_labels(cGSC->CLayerJudgeComponent, noteStruct->lane, noteStruct->judgeType);
v19 = cGSC->GameMatchingComponent;
if ( v19 )
{
sub_1801F6C50(v19, cGSC->field_BD8);
if ( cGSC->game_mode_maybe == 1 )
sub_1801F6C20(cGSC->GameMatchingComponent, cGSC->field_D74);
sub_1801F7C30(cGSC->GameMatchingComponent);
}
if ( judgeType == ERROR )
{
v20 = cGSC->field_4FC0;
if ( !v20 )
v20 = 10;
cGSC->field_4FC0 = v20;
}
else
{
sub_1801FF080(&cGSC->field_1C60, noteStruct->lane, judgeType);
*&cGSC->gap98[12 * noteStruct->lane + 2348] = 0x3F800000;
*&cGSC->gap98[4 * noteStruct->lane + 2440] = 14;
if ( noteStruct->lane == PEDAL_AND_MARKERS )
{
if ( noteStruct->judgeType == CRITICAL )
cGSC->field_4B2C |= 1 << noteStruct->lane;
if ( noteStruct->judgeType == NEAR )
cGSC->field_4B6C |= 1 << noteStruct->lane;
}
else
{
if ( noteStruct->judgeType == CRITICAL )
cGSC->criticalLaneMask |= 1 << noteStruct->lane;
if ( noteStruct->judgeType == NEAR )
cGSC->nearLaneMask |= 1 << noteStruct->lane;
cGSC->judgedLaneMask |= 1 << noteStruct->lane;
}
if ( cGSC->field_20427 )
++cGSC->field_19196;
if ( cGSC->field_20428 )
++cGSC->field_19200;
sub_1801F81A0(&cGSC->DrawLane, noteStruct->lane, judgeType);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment