//
// Generated by dtk
// Translation Unit: d_metronome.cpp
//

#include "d/dolzel.h" // IWYU pragma: keep
#include "d/d_metronome.h"
#include "d/actor/d_a_player_main.h"
#include "d/d_com_inf_game.h"
#include "m_Do/m_Do_audio.h"
#include "m_Do/m_Do_lib.h"
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
#include "JSystem/J2DGraph/J2DScreen.h"

enum {
    ACT_INIT = 0,
    ACT_GROW = 1,
    ACT_WAIT = 2,
    ACT_SHIFT = 3,
    ACT_DEMO = 4,
    ACT_SHRINK = 5,
};

dMn_HIO_c g_mnHIO;

/* 80221C38-80221CD4       .text __ct__9dMn_HIO_cFv */
dMn_HIO_c::dMn_HIO_c() {
    mEchoScale = 5.0f;
    mShiftTiming = 11;
    mFlashTiming = 5;
    mAlphaOrig = 0xFF;
    mTimingTrail = false;
    mWhiteColor0.set(0xFF, 0xFF, 0xFF, 0xFF);
    mBlackColor0.set(0xFF, 0xFF, 0xFF, 0x00);
    mWhiteColor1.set(0xFF, 0xB9, 0x00, 0xFF);
    mBlackColor1.set(0xFF, 0xB9, 0x00, 0x00);
}

/* 80221CD4-80221DF4       .text screenSet__12dMetronome_cFv */
void dMetronome_c::screenSet() {
    static const u32 cn_t2[] = { 'cn08', 'cn09', 'cn10', 'cn11', 'cn12', 'cn13' };
    static const u32 wn_t2[] = { 'wn08', 'wn09', 'wn10', 'wn11', 'wn12', 'wn13' };
    static const u32 i12_t2[] = { 'i081', 'i091', 'i101', 'i111', 'i121', 'i131' };
    static const u32 i11_t2[] = { 'i082', 'i092', 'i102', 'i112', 'i122', 'i132' };
    static const u32 bs_t2[] = { 'bs08', 'bs09', 'bs10', 'bs11', 'bs12', 'bs13' };

    static const u32 cn_t1[] = { 'cn01', 'cn02', 'cn03', 'cn04', 'cn05', 'cn06', 'cn07' };
    static const u32 wn_t1[] = { 'wn01', 'wn02', 'wn03', 'wn04', 'wn05', 'wn06', 'wn07' };
    static const u32 pk_t1[] = { 'pk01', 'pk02', 'pk03', 'pk04', 'pk05', 'pk06', 'pk07' };
    static const u32 i11_t1[] = { 'i011', 'i021', 'i031', 'i041', 'i051', 'i061', 'i071' };
    static const u32 i12_t1[] = { 'i012', 'i022', 'i032', 'i042', 'i052', 'i062', 'i072' };
    static const u32 bs_t1[] = { 'bs01', 'bs02', 'bs03', 'bs04', 'bs05', 'bs06', 'bs07' };

    static const u32 timing_t[21] = {
        '\000\00001',
        '\000\00002',
        '\000\00003',
        '\000\00004',
        '\000\00005',
        '\000\00006',
        '\000\00007',
        '\000\00008',
        '\000\00009',
        '\000\00010',
        '\000\00011',
        '\000\00012',
        '\000\00013',
        '\000\00014',
        '\000\00015',
        '\000\00016',
        '\000\00017',
        '\000\00018',
        '\000\00019',
        '\000\00020',
        '\000\00021',
    };

    for (s32 i = 0; i < 7; i++) {
        fopMsgM_setPaneData(&pane_cn[i], scrn, cn_t1[i]);
        fopMsgM_setPaneData(&pane_wn[i], scrn, wn_t1[i]);
        fopMsgM_setPaneData(&pane_pk[i], scrn, pk_t1[i]);
        fopMsgM_setPaneData(&pane_i11[i], scrn, i11_t1[i]);
        fopMsgM_setPaneData(&pane_i12[i], scrn, i12_t1[i]);
        fopMsgM_setPaneData(&pane_bs[i], scrn, bs_t1[i]);
    }

    for (s32 i = 0; i < 21; i++) {
        fopMsgM_setPaneData(&pane_timing[i], scrn, timing_t[i]);
    }

    fopMsgM_setPaneData(&pane_echo, scrn, '\000112');
}

/* 80221DF4-802222D8       .text metronomeMove__12dMetronome_cFv */
void dMetronome_c::metronomeMove() {
    s32 timer = daPy_getPlayerLinkActorClass()->getTactMetronomeRate() * 20.0f;
    if (timer > 20)
        timer = 20;
    else if (timer < 0)
        timer = 0;

    if (timer != mCurTimer)
        pane_timing[mCurTimer].mUserArea = 5;

    if (field_0xE38 != 0) {
        if (mCurRate > daPy_getPlayerLinkActorClass()->getTactMetronomeRate())
            field_0xE38 = 0;

        if (timer <= 10)
            timer = 10 - timer;
        else
            timer = timer - 10;
    } else {
        if (mCurRate > daPy_getPlayerLinkActorClass()->getTactMetronomeRate())
            field_0xE38 = 1;

        if (timer <= 10)
            timer = timer + 10;
        else
            timer = 30 - timer;
    }

    // Kick off the echo if we reach the middle.
    if (pane_wn[3].mUserArea == 0 && timer == 10 && pane_echo.mUserArea == 0) {
        pane_echo.mUserArea = 1;
    }

    if (pane_echo.mUserArea != 0) {
        f32 scale, alpha;
        if (pane_echo.mUserArea >= 10) {
            alpha = 0.0f;
            scale = 0.0f;
            pane_echo.mUserArea = 0;
        } else {
            alpha = fopMsgM_valueIncrease(10, 10 - pane_echo.mUserArea, 0);
            scale = fopMsgM_valueIncrease(10, pane_echo.mUserArea, 0);
            scale = (g_mnHIO.mEchoScale - 1.0f) * scale;
            scale = scale + 1.0f;
            pane_echo.mUserArea++;
        }

        fopMsgM_paneScaleXY(&pane_echo, scale);
        fopMsgM_setNowAlpha(&pane_echo, alpha);
    }

    mCurRate = daPy_getPlayerLinkActorClass()->getTactMetronomeRate();
    mCurTimer = timer;

    for (s32 i = 0; i < 21; i++) {
        if (i == timer) {
            if (i == 10) {
                ((J2DPicture *)pane_timing[i].pane)->setBlack(JUtility::TColor(0xFF505000));
                ((J2DPicture *)pane_timing[i].pane)->setWhite(JUtility::TColor(0xFF5050FF));
            } else {
                ((J2DPicture *)pane_timing[i].pane)->setBlack(JUtility::TColor(0xFFB90000));
                ((J2DPicture *)pane_timing[i].pane)->setWhite(JUtility::TColor(0xFFB900FF));
            }
        } else {
            if (pane_timing[i].mUserArea != 0 && g_mnHIO.mTimingTrail) {
                // Unused timing trail effect.
                pane_timing[i].mUserArea--;
                f32 fade = fopMsgM_valueIncrease(5, pane_timing[i].mUserArea, 0);
                JUtility::TColor black, white;

                if (i == 10) {
                    black.r = -(fade * -255.0f);
                    black.g = -(fade * -80.0f);
                    black.b = -(fade * -80.0f);
                    black.a = 0x00;
                    white.r = 0xFF;
                    white.g = 255.0f - (fade * 175.f);
                    white.b = 255.0f - (fade * 175.f);
                    white.a = 0xFF;
                } else {
                    black.r = -(fade * -255.0f);
                    black.g = -(fade * -185.0f);
                    black.b = 0x00;
                    black.a = 0x00;
                    white.r = 0xFF;
                    white.g = 255.0f - (fade * 70.f);
                    white.b = 255.0f - (fade * 255.f);
                    white.a = 0xFF;
                }

                ((J2DPicture *)pane_timing[i].pane)->setBlack(black);
                ((J2DPicture *)pane_timing[i].pane)->setWhite(white);
            } else {
                ((J2DPicture *)pane_timing[i].pane)->setBlack(JUtility::TColor(0x00000000));
                ((J2DPicture *)pane_timing[i].pane)->setWhite(JUtility::TColor(0xFFFFFFFF));
            }
        }
    }
}

/* 802222D8-802224E4       .text melodyInit__12dMetronome_cFUc */
void dMetronome_c::melodyInit(u8 beat) {
    pane_wn[2].mUserArea = 0;
    pane_wn[3].mUserArea = 0;
    pane_wn[4].mUserArea = 0;
    pane_wn[5].mUserArea = 0;
    pane_echo.mUserArea = 10;

    mCurTimer = daPy_getPlayerLinkActorClass()->getTactMetronomeRate() * 20.0f;
    if (mCurTimer > 20)
        mCurTimer = 20;
    else if (mCurTimer < 0)
        mCurTimer = 0;

    for (u32 i = 0; i < 21; i++)
        pane_timing[i].mUserArea = 0;

    switch (beat) {
    case 3:
        mPosX = (pane_bs[1].mPosCenterOrig.x + pane_bs[2].mPosCenterOrig.x) / 2.0f;
        break;
    case 4:
        mPosX = pane_bs[1].mPosCenterOrig.x;
        break;
    case 6:
        mPosX = pane_bs[0].mPosCenterOrig.x;
        break;
    }

    for (s32 i = 0; i < 7; i++) {
        pane_bs[i].mUserArea = 0;
        pane_cn[i].mPosCenter.x = mPosX;
        pane_cn[i].mPosCenter.y = pane_cn[i].mPosCenterOrig.y;
        pane_wn[i].mPosCenter.x = mPosX;
        pane_pk[i].mPosCenter.x = mPosX;
        pane_i11[i].mPosCenter.x = mPosX;
        pane_i12[i].mPosCenter.x = mPosX;
        pane_bs[i].mPosCenter.x = mPosX;

        fopMsgM_cposMove(&pane_cn[i]);
        fopMsgM_cposMove(&pane_wn[i]);
        fopMsgM_cposMove(&pane_pk[i]);
        fopMsgM_cposMove(&pane_i11[i]);
        fopMsgM_cposMove(&pane_i12[i]);
        fopMsgM_cposMove(&pane_bs[i]);

        if (i < beat) {
            fopMsgM_setInitAlpha(&pane_wn[i]);
            fopMsgM_setInitAlpha(&pane_bs[i]);
        } else {
            fopMsgM_setNowAlphaZero(&pane_wn[i]);
            fopMsgM_setNowAlphaZero(&pane_bs[i]);
        }
        fopMsgM_setNowAlphaZero(&pane_cn[i]);
        fopMsgM_setNowAlphaZero(&pane_pk[i]);
        fopMsgM_setNowAlphaZero(&pane_i11[i]);
        fopMsgM_setNowAlphaZero(&pane_i12[i]);
    }
}

/* 802224E4-80222608       .text melodyMove__12dMetronome_cFv */
void dMetronome_c::melodyMove() {
    f32 sepX = fopMsgM_valueIncrease(3, pane_wn[1].mUserArea, 0);
    sepX = sepX * (pane_bs[2].mPosCenterOrig.x - pane_bs[1].mPosCenterOrig.x);

    if (pane_wn[1].mUserArea >= 3) {
        mAction = ACT_WAIT;
    } else if (pane_wn[1].mUserArea <= 0) {
        mAction = ACT_INIT;
    }

    for (s32 i = 0; i < 7; i++) {
        f32 x = mPosX + sepX * i;
        pane_cn[i].mPosCenter.x = x;
        pane_wn[i].mPosCenter.x = x;
        pane_pk[i].mPosCenter.x = x;
        pane_i11[i].mPosCenter.x = x;
        pane_i12[i].mPosCenter.x = x;
        pane_bs[i].mPosCenter.x = x;

        fopMsgM_cposMove(&pane_cn[i]);
        fopMsgM_cposMove(&pane_wn[i]);
        fopMsgM_cposMove(&pane_pk[i]);
        fopMsgM_cposMove(&pane_i11[i]);
        fopMsgM_cposMove(&pane_i12[i]);
        fopMsgM_cposMove(&pane_bs[i]);
    }
}

/* 80222608-80222854       .text melodyGuideShow__12dMetronome_cFls */
void dMetronome_c::melodyGuideShow(s32 note, s16 no) {
    s16 rot[] = { 0x00E1, 0x00E1, 0x0087, 0x002D, 0x013B };

    switch (note) {
    case 1:
        pane_cn[no].mPosCenter.y -= (s16)(pane_i11[no].mSize.y / 4.0f);
        break;
    case 3:
        pane_cn[no].mPosCenter.y += (s16)(pane_i11[no].mSize.y / 4.0f);
        break;
    case 4:
        pane_cn[no].mUserArea = pane_i11[no].mSize.x / 4.0f;
        pane_cn[no].mPosCenter.x -= pane_cn[no].mUserArea;
        break;
    case 2:
        pane_cn[no].mUserArea = pane_i11[no].mSize.x / 4.0f;
        pane_cn[no].mPosCenter.x += pane_cn[no].mUserArea;
        break;
    }

    fopMsgM_cposMove(&pane_cn[no]);

    // This is almost J2DPane::setBasePosition
    f32 centerX = pane_i11[no].mSize.x / 2.0f;
    f32 centerY = pane_i11[no].mSize.y / 2.0f;
    J2DScreen* scrn = (J2DScreen*)pane_i11[no].pane;
    scrn->mBasePosition.x = centerX;
    scrn->mBasePosition.y = centerY;
    scrn->mRotationAxis = ROTATE_Z;
    scrn->mRotation = rot[note];
    scrn->calcMtx();
}

/* 80222854-80222C4C       .text melodyShow__12dMetronome_cFv */
void dMetronome_c::melodyShow() {
    cXyz tactTop, sparklePos;
    if (daPy_getPlayerActorClass()->checkTactInput()) {
        cXyz pos;
        pos.x = 0.0f;
        pos.y = 0.0f;
        pos.z = 0.0f;

        s32 note = daPy_getPlayerLinkActorClass()->getTactLeftHandPos();
        if (pane_wn[0].mUserArea < mBeat) {
            mNote[pane_wn[0].mUserArea] = note;
            melodyGuideShow(note, pane_wn[0].mUserArea);
            pane_bs[pane_wn[0].mUserArea].mUserArea = 1;
            pos.x = pane_wn[pane_wn[0].mUserArea].mPosCenter.x - 320.0f;
            pos.y = pane_wn[pane_wn[0].mUserArea].mPosCenter.y - 240.0f;
            pane_wn[0].mUserArea++;
        } else {
            mNote[mBeat - 1] = note;
            melodyGuideShow(note, mBeat - 1);
            pane_bs[mBeat - 1].mUserArea = 1;
            pos.x = pane_wn[mBeat - 1].mPosCenter.x - 320.0f;
            pos.y = pane_wn[mBeat - 1].mPosCenter.y - 240.0f;
        }

        dComIfGp_particle_set2Dfore(dPa_name::ID_HM_J2_BATONINPUT00, &pos);

        if (daPy_getPlayerLinkActorClass()->getTactTopPos(&tactTop)) {
            mDoLib_project(&tactTop, &sparklePos);

            sparklePos.x -= 320.0f;
            sparklePos.y -= 240.0f;
            mpEmitter = dComIfGp_particle_set2Dfore(dPa_name::ID_HM_J2_BATONINPUT01, &sparklePos);
            mpEmitter->becomeImmortalEmitter();
        }

        if (daPy_getPlayerLinkActorClass()->checkTactLastInput()) {
            pane_pk[0].mUserArea = 1;
            pane_pk[1].mUserArea = 0;
            pane_wn[3].mUserArea = 1;
        }
    }

    if (mpEmitter != NULL) {
        if (mpEmitter->isEnableDeleteEmitter()) {
            mpEmitter->quitImmortalEmitter();
            mpEmitter = NULL;
        } else {
            if (daPy_getPlayerLinkActorClass()->getTactTopPos(&tactTop)) {
                mDoLib_project(&tactTop, &sparklePos);
                sparklePos.x -= 320.0f;
                sparklePos.y -= 240.0f;
                mpEmitter->setGlobalTranslation(sparklePos.x, sparklePos.y, sparklePos.z);
            }
        }
    }

    for (s32 i = 0; i < 7; i++) {
        if (pane_bs[i].mUserArea != 0) {
            f32 alpha = fopMsgM_valueIncrease(5, pane_bs[i].mUserArea, 0);
            if (i == mBeat) {
                fopMsgM_setNowAlpha(&pane_wn[i], alpha);
                fopMsgM_setNowAlpha(&pane_bs[i], alpha);
                fopMsgM_setNowAlphaZero(&pane_cn[i]);
                fopMsgM_setNowAlphaZero(&pane_i11[i]);
                fopMsgM_setNowAlphaZero(&pane_i12[i]);
            } else {
                fopMsgM_setNowAlpha(&pane_cn[i], alpha);
                fopMsgM_setNowAlpha(&pane_i11[i], alpha);
                if (mNote[i] == 0)
                    fopMsgM_setNowAlpha(&pane_i12[i], alpha);
            }

            if (pane_bs[i].mUserArea < 5) {
                pane_bs[i].mUserArea++;
            } else {
                pane_bs[i].mUserArea = 0;
            }

            if (pane_wn[0].mUserArea >= mBeat && pane_wn[3].mUserArea == 0 && pane_bs[mBeat - 1].mUserArea == 5) {
                pane_wn[2].mUserArea = 5;
                pane_wn[0].mUserArea = 0;
                pane_wn[6].mUserArea = 0;
                mAction = ACT_SHIFT;
            }
        }
    }
}

/* 80222C4C-80222DB4       .text melodyDemo__12dMetronome_cFv */
void dMetronome_c::melodyDemo() {
    if (pane_wn[4].mUserArea != 0) {
        s32 note[6];
        s16 frames[7];

        u32 melody_no = daPy_getPlayerLinkActorClass()->getTactMusic();

        frames[0] = 1;
        for (s32 i = 0; i < mBeat; i++) {
            frames[i + 1] = frames[i] + mDoAud_tact_getMelodyPattern(melody_no, i, &note[i]);
        }

        if (mBeat > pane_wn[5].mUserArea) {
            if (pane_wn[4].mUserArea == frames[pane_wn[5].mUserArea]) {
                pane_bs[pane_wn[5].mUserArea].mUserArea = 1;
                pane_wn[5].mUserArea++;
            }
            pane_wn[4].mUserArea++;
        }
    } else {
        if (daPy_getPlayerLinkActorClass()->checkTactPlayMelody())
            pane_wn[4].mUserArea = 1;
    }
}

/* 80222DB4-80222EF0       .text melodyFlash__12dMetronome_cFv */
void dMetronome_c::melodyFlash() {
    f32 alpha = 0.0f;
    pane_pk[1].mUserArea++;
    if (pane_pk[1].mUserArea < g_mnHIO.mFlashTiming) {
        alpha = fopMsgM_valueIncrease(g_mnHIO.mFlashTiming, pane_pk[1].mUserArea, 0);
    } else if (pane_pk[1].mUserArea >= g_mnHIO.mFlashTiming * 2) {
        pane_pk[1].mUserArea = 0;
        pane_pk[0].mUserArea++;
        if (pane_pk[0].mUserArea >= 3) {
            pane_pk[0].mUserArea = 0;
            for (s32 i = 0; i < mBeat; i++) {
                fopMsgM_setNowAlphaZero(&pane_cn[i]);
                fopMsgM_setNowAlphaZero(&pane_i11[i]);
                fopMsgM_setNowAlphaZero(&pane_i12[i]);
            }
            mAction = ACT_DEMO;
        }
    } else {
        alpha = fopMsgM_valueIncrease(g_mnHIO.mFlashTiming, g_mnHIO.mFlashTiming * 2 - pane_pk[1].mUserArea, 0);
    }

    for (s32 i = 0; i < mBeat; i++) {
        pane_pk[i].mInitAlpha = g_mnHIO.mAlphaOrig;
        fopMsgM_setNowAlpha(&pane_pk[i], alpha);
    }
}

/* 80222EF0-8022300C       .text melodyShift__12dMetronome_cFv */
void dMetronome_c::melodyShift() {
    if (pane_wn[6].mUserArea < g_mnHIO.mShiftTiming) {
        pane_wn[6].mUserArea++;
    } else {
        melodyInit(mBeat);

        f32 sepX = pane_bs[2].mPosCenterOrig.x - pane_bs[1].mPosCenterOrig.x;

        for (s32 i = 0; i < 7; i++) {
            f32 x = mPosX + sepX * i;
            pane_cn[i].mPosCenter.x = x;
            pane_wn[i].mPosCenter.x = x;
            pane_pk[i].mPosCenter.x = x;
            pane_i11[i].mPosCenter.x = x;
            pane_i12[i].mPosCenter.x = x;
            pane_bs[i].mPosCenter.x = x;

            fopMsgM_cposMove(&pane_cn[i]);
            fopMsgM_cposMove(&pane_wn[i]);
            fopMsgM_cposMove(&pane_pk[i]);
            fopMsgM_cposMove(&pane_i11[i]);
            fopMsgM_cposMove(&pane_i12[i]);
            fopMsgM_cposMove(&pane_bs[i]);
        }

        mAction = ACT_WAIT;
    }
}

/* 8022300C-8022309C       .text initialize__12dMetronome_cFv */
void dMetronome_c::initialize() {
    mCurRate = daPy_getPlayerLinkActorClass()->getTactMetronomeRate();
    mPosX = 0.0f;
    field_0xE38 = 0;
    mBeat = mDoAud_tact_getBeat();
    mAction = ACT_INIT;
    field_0xE14 = 0;

    for (s32 i = 0; i < 7; i++)
        mNote[i] = 0;

    mbOpen = false;
    mCurTimer = NULL;
    mpEmitter = NULL;
}

/* 8022309C-8022319C       .text _create__12dMetronome_cFv */
void dMetronome_c::_create() {
    scrn = new J2DScreen();
    JUT_ASSERT(0x2db, scrn != NULL);
    scrn->set("baton_input.blo", dComIfGp_getTactMsgArchive());
    screenSet();
    initialize();
}

/* 8022319C-802231F4       .text _delete__12dMetronome_cFv */
void dMetronome_c::_delete() {
    delete scrn;
    dComIfGp_getTactMsgArchive()->removeResourceAll();
}

/* 802231F4-80223314       .text _move__12dMetronome_cFv */
void dMetronome_c::_move() {
    metronomeMove();
    if (pane_wn[3].mUserArea == 0 && mBeat != mDoAud_tact_getBeat()) {
        mBeat = mDoAud_tact_getBeat();
        pane_wn[0].mUserArea = 0;
        mAction = ACT_SHRINK;
    }

    if (mAction == ACT_INIT) {
        mAction = ACT_GROW;
        pane_wn[1].mUserArea = 0;
        pane_wn[0].mUserArea = 0;
        melodyInit(mBeat);
    } else if (mAction == ACT_GROW) {
        pane_wn[1].mUserArea++;
        melodyMove();
    } else if (mAction == ACT_SHRINK) {
        pane_wn[1].mUserArea--;
        melodyMove();
    } else if (mAction == ACT_SHIFT) {
        melodyShift();
    } else if (mAction == ACT_DEMO) {
        melodyDemo();
    }

    if (pane_wn[1].mUserArea != 0)
        melodyShow();
    if (pane_pk[0].mUserArea != 0)
        melodyFlash();
}

/* 80223314-802233E4       .text _draw__12dMetronome_cFv */
void dMetronome_c::_draw() {
    for (s32 i = 0; i < 7; i++) {
        fopMsgM_setAlpha(&pane_cn[i]);
        fopMsgM_setAlpha(&pane_wn[i]);
        fopMsgM_setAlpha(&pane_pk[i]);
        fopMsgM_setAlpha(&pane_i11[i]);
        fopMsgM_setAlpha(&pane_i12[i]);
        fopMsgM_setAlpha(&pane_bs[i]);
    }

    for (s32 i = 0; i < 21; i++)
        fopMsgM_setAlpha(&pane_timing[0]);  // nice bug

    fopMsgM_setAlpha(&pane_echo);

    J2DOrthoGraph* port = dComIfGp_getCurrentGrafPort();
    port->setPort();
    scrn->draw(0.0f, 0.0f, port);
}

/* 802233E4-80223478       .text _open__12dMetronome_cFv */
bool dMetronome_c::_open() {
    if (!mbOpen) {
        for (s32 i = 0; i < 21; i++) {
            fopMsgM_setInitAlpha(&pane_timing[i]);
        }

        mBeat = mDoAud_tact_getBeat();

        pane_wn[1].mUserArea = 0;
        pane_wn[0].mUserArea = 0;

        melodyInit(mBeat);
    }
    mbOpen = true;
    return true;
}

/* 80223478-80223534       .text _close__12dMetronome_cFv */
bool dMetronome_c::_close() {
    mbOpen = false;
    if (!mbOpen) {  // nice bug
        for (s32 i = 0; i < 7; i++) {
            fopMsgM_setNowAlphaZero(&pane_cn[i]);
            fopMsgM_setNowAlphaZero(&pane_wn[i]);
            fopMsgM_setNowAlphaZero(&pane_pk[i]);
            fopMsgM_setNowAlphaZero(&pane_i11[i]);
            fopMsgM_setNowAlphaZero(&pane_i12[i]);
            fopMsgM_setNowAlphaZero(&pane_bs[i]);
        }

        for (s32 i = 0; i < 21; i++) {
            fopMsgM_setNowAlphaZero(&pane_timing[i]);
        }

        fopMsgM_setNowAlphaZero(&pane_echo);
    }

    return true;
}
