code:
#include "global.h"
#include "librfu.h"
#include "link_rfu.h"

#define RN_ACCEPT           0x01
#define RN_NAME_TIMER_CLEAR 0x02
#define RN_DISCONNECT       0x04

#define LINK_RECOVERY_OFF        0x00
#define LINK_RECOVERY_START      0x01
#define LINK_RECOVERY_EXE        0x02
#define LINK_RECOVERY_IMPOSSIBLE 0x04

#define FSP_ON    0x01
#define FSP_START 0x02

LINK_MANAGER lman;

static void rfu_LMAN_clearVariables(void);
static void rfu_LMAN_settingPCSWITCH(u32 rand);
static void rfu_LMAN_REQ_callback(u16 reqCommandId, u16 reqResult);
static void rfu_LMAN_MSC_callback(u16 reqCommandId);
static void rfu_LMAN_PARENT_checkRecvChildName(void);
static void rfu_LMAN_CHILD_checkSendChildName(void);
static void rfu_LMAN_CHILD_checkSendChildName2(void);
static void rfu_LMAN_CHILD_linkRecoveryProcess(void);
static u8 rfu_LMAN_CHILD_checkEnableParentCandidate(void);
static void rfu_LMAN_occureCallback(u8 msg, u8 param_count);
static void rfu_LMAN_disconnect(u8 bmDisconnectSlot);
static void rfu_LMAN_reflectCommunicationStatus(u8 bm_disconnectedSlot);
static void rfu_LMAN_checkNICommunicateStatus(void);
static void rfu_LMAN_managerChangeAgbClockMaster(void);

u32 rfu_LMAN_REQBN_softReset_and_checkID(void)
{
    u32 id = rfu_REQBN_softReset_and_checkID();
    if (id == RFU_ID)
        lman.RFU_powerOn_flag = 1;
    if (lman.state != LMAN_FORCED_STOP_AND_RFU_RESET && lman.state != LMAN_STATE_SOFT_RESET_AND_CHECK_ID)
    {
        lman.state = lman.next_state = LMAN_STATE_READY;
    }
    lman.pcswitch_flag = 0;
    lman.reserveDisconnectSlot_flag = 0;
    lman.acceptCount = 0;
    lman.acceptSlot_flag = 0;
    lman.parent_child = MODE_NEUTRAL;
    rfu_LMAN_managerChangeAgbClockMaster();
    return id;
}

void rfu_LMAN_REQ_sendData(u8 clockChangeFlag)
{
    if (gRfuLinkStatus->parentChild == MODE_CHILD)
    {
        if (lman.childClockSlave_flag == RFU_CHILD_CLOCK_SLAVE_ON)
            clockChangeFlag = TRUE;
        else
            clockChangeFlag = FALSE;
    }
    else
        lman.parentAck_flag = 0;
    rfu_REQ_sendData(clockChangeFlag);
}

u8 rfu_LMAN_initializeManager(void (*LMAN_callback_p)(u8, u8), void (*MSC_callback_p)(u16))
{
    if (LMAN_callback_p == NULL)
    {
        return LMAN_ERROR_ILLEGAL_PARAMETER;
    }
    CpuFill16(0, &lman, sizeof(struct linkManagerTag));
    lman.parent_child = MODE_NEUTRAL;
    lman.LMAN_callback = LMAN_callback_p;
    lman.MSC_callback = MSC_callback_p;
    rfu_setMSCCallback(rfu_LMAN_MSC_callback);
    rfu_setREQCallback(rfu_LMAN_REQ_callback);
    return 0;
}

static void rfu_LMAN_endManager(void)
{
    CpuFill16(0, &lman, sizeof(struct linkManagerTag) - 8);
    lman.parent_child = MODE_NEUTRAL;
}

void rfu_LMAN_initializeRFU(INIT_PARAM *init_parameters)
{
    rfu_LMAN_clearVariables();
    lman.state = LMAN_STATE_SOFT_RESET_AND_CHECK_ID;
    lman.next_state = LMAN_STATE_RESET;
    lman.init_param = init_parameters;
    lman.linkRecovery_enable = init_parameters->linkRecovery_enable;
    lman.linkRecoveryTimer.count_max = init_parameters->linkRecovery_period;
    lman.NI_failCounter_limit = init_parameters->NI_failCounter_limit;
    if (init_parameters->fastSearchParent_flag)
    {
        lman.fastSearchParent_flag = FSP_ON;
    }
}

static void rfu_LMAN_clearVariables(void)
{
    u8 i;

    lman.state = lman.next_state = LMAN_STATE_READY;
    lman.parent_child = MODE_NEUTRAL;
    lman.pcswitch_flag = 0;
    lman.child_slot = 0;
    lman.connectSlot_flag_old = 0;
    lman.nameAcceptTimer.active = 0;
    lman.linkRecoveryTimer.active = 0;
    for (i = 0; i < RFU_CHILD_MAX; i++)
    {
        lman.nameAcceptTimer.count[i] = 0;
        lman.linkRecoveryTimer.count[i] = 0;
    }
}

void rfu_LMAN_powerDownRFU(void)
{
    lman.state = LMAN_STATE_STOP_MODE;
}

u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list)
{
    u8 i;
    u16 *serial_list;

    if (lman.state != LMAN_STATE_READY && (lman.state != LMAN_STATE_WAIT_RECV_CHILD_NAME || parent_child != MODE_PARENT))
    {
        lman.param[0] = 1;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_MANAGER_BUSY;
    }
    if (rfu_getMasterSlave() == AGB_CLK_SLAVE)
    {
        lman.param[0] = 2;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_AGB_CLK_SLAVE;
    }
    for (i = 0, serial_list = acceptable_serialNo_list; i < 16; i++)
    {
        if (*serial_list++ == 0xFFFF)
        {
            break;
        }
    }
    if (i == 16)
    {
        lman.param[0] = 4;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_ILLEGAL_PARAMETER;
    }
    if (parent_child > MODE_PARENT)
    {
        lman.pcswitch_flag = PCSWITCH_1ST_SC_START;
        parent_child = MODE_PARENT;
        connect_period = 0;
    }
    else
    {
        lman.pcswitch_flag = 0;
    }
    if (parent_child != MODE_CHILD)
    {
        lman.state = LMAN_STATE_START_SEARCH_CHILD;
    }
    else
    {
        lman.state = LMAN_STATE_START_SEARCH_PARENT;
        if (lman.fastSearchParent_flag)
        {
            lman.fastSearchParent_flag = FSP_START;
        }
    }
    lman.parent_child = parent_child;
    lman.connect_period = connect_period;
    lman.nameAcceptTimer.count_max = name_accept_period;
    lman.acceptable_serialNo_list = acceptable_serialNo_list;
    return 0;
}

u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 connect_period)
{
    u8 i;

    if (lman.state != LMAN_STATE_READY && (lman.state < 9 || lman.state > 11))
    {
        lman.param[0] = 1;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_MANAGER_BUSY;
    }
    if (rfu_getMasterSlave() == AGB_CLK_SLAVE)
    {
        lman.param[0] = 2;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_AGB_CLK_SLAVE;
    }
    for (i = 0; i < gRfuLinkStatus->findParentCount; i++)
    {
        if (gRfuLinkStatus->partner[i].id == parentId)
        {
            break;
        }
    }
    if (gRfuLinkStatus->findParentCount == 0 || i == gRfuLinkStatus->findParentCount)
    {
        lman.param[0] = 3;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_PID_NOT_FOUND;
    }
    if (lman.state == LMAN_STATE_READY || lman.state == LMAN_STATE_START_SEARCH_PARENT)
    {
        lman.state = LMAN_STATE_START_CONNECT_PARENT;
        lman.next_state = LMAN_STATE_POLL_CONNECT_PARENT;
    }
    else
    {
        lman.state = LMAN_STATE_END_SEARCH_PARENT;
        lman.next_state = LMAN_STATE_START_CONNECT_PARENT;
    }
    lman.work = parentId;
    lman.connect_period = connect_period;
    if (lman.pcswitch_flag != 0)
    {
        lman.pcswitch_flag = PCSWITCH_CP;
    }
    return 0;
}

static void rfu_LMAN_PARENT_stopWaitLinkRecoveryAndDisconnect(u8 bm_targetSlot)
{
    u8 i;

    if ((bm_targetSlot & lman.linkRecoveryTimer.active) == 0)
        return;
    lman.linkRecoveryTimer.active &= ~bm_targetSlot;
    for (i = 0; i < RFU_CHILD_MAX; i++)
    {
        if ((bm_targetSlot >> i) & 1)
        {
            lman.linkRecoveryTimer.count[i] = 0;
        }
    }
    i = gRfuLinkStatus->linkLossSlotFlag & bm_targetSlot;
    if (i)
    {
        rfu_LMAN_disconnect(i);
    }
    lman.param[0] = i;
    rfu_LMAN_occureCallback(LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED, i);
}

void rfu_LMAN_stopManager(u8 forced_stop_and_RFU_reset_flag)
{
    u8 msg = 0;
    lman.pcswitch_flag = 0;
    if (forced_stop_and_RFU_reset_flag)
    {
        rfu_LMAN_clearVariables();
        lman.state = LMAN_FORCED_STOP_AND_RFU_RESET;
        return;
    }
    switch (lman.state)
    {
    case LMAN_STATE_START_SEARCH_CHILD:
        lman.state = LMAN_STATE_WAIT_RECV_CHILD_NAME;
        lman.next_state = LMAN_STATE_READY;
        msg = LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED;
        break;
    case LMAN_STATE_POLL_SEARCH_CHILD:
        lman.state = LMAN_STATE_END_SEARCH_CHILD;
        lman.next_state = LMAN_STATE_WAIT_RECV_CHILD_NAME;
        break;
    case LMAN_STATE_END_SEARCH_CHILD:
        lman.state = LMAN_STATE_END_SEARCH_CHILD;
        lman.next_state = LMAN_STATE_WAIT_RECV_CHILD_NAME;
        break;
    case LMAN_STATE_WAIT_RECV_CHILD_NAME:
        break;
    case LMAN_STATE_START_SEARCH_PARENT:
        lman.state = lman.next_state = LMAN_STATE_READY;
        msg = LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED;
        break;
    case LMAN_STATE_POLL_SEARCH_PARENT:
        lman.state = LMAN_STATE_END_SEARCH_PARENT;
        lman.next_state = LMAN_STATE_READY;
        break;
    case LMAN_STATE_END_SEARCH_PARENT:
        lman.state = LMAN_STATE_END_SEARCH_PARENT;
        lman.next_state = LMAN_STATE_READY;
        break;
    case LMAN_STATE_START_CONNECT_PARENT:
        lman.state = lman.next_state = LMAN_STATE_READY;
        msg = LMAN_MSG_CONNECT_PARENT_FAILED;
        break;
    case LMAN_STATE_POLL_CONNECT_PARENT:
        lman.state = LMAN_STATE_END_CONNECT_PARENT;
        break;
    case LMAN_STATE_END_CONNECT_PARENT:
        lman.state = LMAN_STATE_END_CONNECT_PARENT;
        break;
    case LMAN_STATE_SEND_CHILD_NAME:
        break;
    case LMAN_STATE_START_LINK_RECOVERY:
        lman.state = lman.state_bak[0];
        lman.next_state = lman.state_bak[1];
        rfu_LMAN_disconnect(gRfuLinkStatus->linkLossSlotFlag);
        lman.param[0] = gRfuLinkStatus->linkLossSlotFlag;
        rfu_LMAN_occureCallback(LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED, 1);
        return;
    case LMAN_STATE_POLL_LINK_RECOVERY:
        lman.state = LMAN_STATE_END_LINK_RECOVERY;
        break;
    case LMAN_STATE_END_LINK_RECOVERY:
        lman.state = LMAN_STATE_END_LINK_RECOVERY;
        break;
    default:
        lman.state = lman.next_state = LMAN_STATE_READY;
        msg = LMAN_MSG_MANAGER_STOPPED;
        break;
    }
    if (lman.state == LMAN_STATE_READY)
    {
        rfu_LMAN_occureCallback(msg, 0);
    }
}

static bool8 rfu_LMAN_linkWatcher(u16 REQ_commandID)
{
    u8 i;
    u8 bm_linkLossSlot;
    u8 reason;
    u8 bm_linkRecoverySlot;
    u8 bm_disconnectSlot;

    bool8 disconnect_occure_flag = FALSE;
    rfu_REQBN_watchLink(REQ_commandID, &bm_linkLossSlot, &reason, &bm_linkRecoverySlot);
    if (bm_linkLossSlot)
    {
        lman.param[0] = bm_linkLossSlot;
        lman.param[1] = reason;
        if (lman.linkRecovery_enable)
        {
            lman.linkRecovery_start_flag = LINK_RECOVERY_START;
            if (lman.parent_child == MODE_CHILD && reason == REASON_DISCONNECTED)
            {
                lman.linkRecovery_start_flag = LINK_RECOVERY_IMPOSSIBLE;
            }
            if (lman.linkRecovery_start_flag == LINK_RECOVERY_START)
            {
                for (i = 0; i < RFU_CHILD_MAX; i++)
                {
                    if ((bm_linkLossSlot >> i) & 1)
                    {
                        lman.linkRecoveryTimer.active |= (1 << i);
                        lman.linkRecoveryTimer.count[i] = lman.linkRecoveryTimer.count_max;
                    }
                }
                rfu_LMAN_occureCallback(LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY, 1);
            }
            else
            {
                lman.linkRecovery_start_flag = 0;
                rfu_LMAN_disconnect(bm_linkLossSlot);
                disconnect_occure_flag = TRUE;
                rfu_LMAN_occureCallback(LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED, 1);
            }
        }
        else
        {
            rfu_LMAN_disconnect(bm_linkLossSlot);
            disconnect_occure_flag = TRUE;
            rfu_LMAN_occureCallback(LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED, 2);
        }
        rfu_LMAN_managerChangeAgbClockMaster();
    }
    if (gRfuLinkStatus->parentChild == MODE_PARENT)
    {
        if (bm_linkRecoverySlot)
        {
            for (i = 0; i < RFU_CHILD_MAX; i++)
            {
                if ((lman.linkRecoveryTimer.active >> i) & 1 && (bm_linkRecoverySlot >> i) & 1)
                {
                    lman.linkRecoveryTimer.count[i] = 0;
                }
            }
            lman.linkRecoveryTimer.active &= ~bm_linkRecoverySlot;
            lman.param[0] = bm_linkRecoverySlot;
            rfu_LMAN_occureCallback(LMAN_MSG_LINK_RECOVERY_SUCCESSED, 1);
        }
        if (lman.linkRecoveryTimer.active)
        {
            bm_disconnectSlot = 0;
            for (i = 0; i < RFU_CHILD_MAX; i++)
            {
                if ((lman.linkRecoveryTimer.active >> i) & 1 && lman.linkRecoveryTimer.count[i] && --lman.linkRecoveryTimer.count[i] == 0)
                {
                    lman.linkRecoveryTimer.active &= ~(1 << i);
                    bm_disconnectSlot |= (1 << i);
                }
            }
            if (bm_disconnectSlot)
            {
                rfu_LMAN_disconnect(bm_disconnectSlot);
                disconnect_occure_flag = TRUE;
                lman.param[0] = bm_disconnectSlot;
                rfu_LMAN_occureCallback(LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED, 1);
            }
        }
        if (!lman.linkRecoveryTimer.active)
        {
            lman.linkRecovery_start_flag = 0;
        }
    }
    return disconnect_occure_flag;
}

void rfu_LMAN_syncVBlank(void)
{
    if (rfu_syncVBlank())
    {
        rfu_LMAN_occureCallback(LMAN_MSG_WATCH_DOG_TIMER_ERROR, 0);
        rfu_LMAN_managerChangeAgbClockMaster();
    }
}

void rfu_LMAN_manager_entity(u32 rand)
{
    u8 msg;

    if (lman.LMAN_callback == NULL && lman.state != LMAN_STATE_READY)
    {
        lman.state = LMAN_STATE_READY;
        return;
    }
    if (lman.pcswitch_flag)
    {
        rfu_LMAN_settingPCSWITCH(rand);
    }
    while (1)
    {
        if (lman.state != LMAN_STATE_READY)
        {
            rfu_waitREQComplete();
            lman.active = 1;
            switch (lman.state)
            {
            case LMAN_FORCED_STOP_AND_RFU_RESET:
                if (rfu_LMAN_REQBN_softReset_and_checkID() == RFU_ID)
                {
                    msg=LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET;
                }
                else
                {
                    msg=LMAN_MSG_RFU_FATAL_ERROR;
                }
                lman.state = lman.next_state = LMAN_STATE_READY;
                rfu_LMAN_occureCallback(msg, 0);
                break;
            case LMAN_STATE_SOFT_RESET_AND_CHECK_ID:
                if (rfu_LMAN_REQBN_softReset_and_checkID() == RFU_ID)
                {
                    lman.state = lman.next_state;
                    lman.next_state = LMAN_STATE_CONFIG_SYSTEM;
                }
                else
                {
                    lman.state = lman.next_state = LMAN_STATE_READY;
                    rfu_LMAN_occureCallback(LMAN_MSG_RFU_FATAL_ERROR, 0);
                }
                break;
            case LMAN_STATE_RESET:
                rfu_REQ_reset();
                break;
            case LMAN_STATE_CONFIG_SYSTEM:
                rfu_REQ_configSystem(lman.init_param->availSlot_flag, lman.init_param->maxMFrame, lman.init_param->MC_TimerCount);
                break;
            case LMAN_STATE_CONFIG_GAME_DATA:
                rfu_REQ_configGameData(lman.init_param->mboot_flag, lman.init_param->serialNo, (const u8 *)lman.init_param->gameName, lman.init_param->userName);
                break;
            case LMAN_STATE_START_SEARCH_CHILD:
                rfu_REQ_startSearchChild();
                break;
            case LMAN_STATE_POLL_SEARCH_CHILD:
                rfu_REQ_pollSearchChild();
                break;
            case LMAN_STATE_END_SEARCH_CHILD:
                rfu_REQ_endSearchChild();
                break;
            case LMAN_STATE_WAIT_RECV_CHILD_NAME:
                break;
            case LMAN_STATE_START_SEARCH_PARENT:
                rfu_REQ_startSearchParent();
                break;
            case LMAN_STATE_POLL_SEARCH_PARENT:
                rfu_REQ_pollSearchParent();
                break;
            case LMAN_STATE_END_SEARCH_PARENT:
                rfu_REQ_endSearchParent();
                break;
            case LMAN_STATE_START_CONNECT_PARENT:
                rfu_REQ_startConnectParent(lman.work);
                break;
            case LMAN_STATE_POLL_CONNECT_PARENT:
                rfu_REQ_pollConnectParent();
                break;
            case LMAN_STATE_END_CONNECT_PARENT:
                rfu_REQ_endConnectParent();
                break;
            case LMAN_STATE_SEND_CHILD_NAME:
                break;
            case LMAN_STATE_START_LINK_RECOVERY:
                rfu_REQ_CHILD_startConnectRecovery(gRfuLinkStatus->linkLossSlotFlag);
                break;
            case LMAN_STATE_POLL_LINK_RECOVERY:
                rfu_REQ_CHILD_pollConnectRecovery();
                break;
            case LMAN_STATE_END_LINK_RECOVERY:
                rfu_REQ_CHILD_endConnectRecovery();
                break;
            case LMAN_STATE_MS_CHANGE:
                rfu_REQ_changeMasterSlave();
                break;
            case LMAN_STATE_WAIT_CLOCK_MASTER:
                break;
            case LMAN_STATE_STOP_MODE:
                rfu_REQ_stopMode();
                break;
            case LMAN_STATE_BACK_STATE:
                break;
            default:
                break;
            }
            rfu_waitREQComplete();
            lman.active = 0;
        }
        if (lman.state == LMAN_STATE_END_LINK_RECOVERY || lman.state == LMAN_STATE_MS_CHANGE)
            ;
        else
            break;
    }
    if (gRfuLinkStatus->parentChild == MODE_PARENT)
    {
        if (rfu_LMAN_linkWatcher(0))
            return;
    }
    rfu_LMAN_PARENT_checkRecvChildName();
    rfu_LMAN_CHILD_checkSendChildName();
    rfu_LMAN_CHILD_linkRecoveryProcess();
    rfu_LMAN_checkNICommunicateStatus();
}

static void rfu_LMAN_settingPCSWITCH(u32 rand)
{
    if (lman.pcswitch_flag == PCSWITCH_3RD_SC_START)
    {
        lman.parent_child = MODE_PARENT;
        lman.state = LMAN_STATE_START_SEARCH_CHILD;
        lman.connect_period = lman.pcswitch_period_bak;
        if (lman.connect_period)
        {
            lman.pcswitch_flag = PCSWITCH_3RD_SC;
        }
        else
        {
            lman.pcswitch_flag = PCSWITCH_1ST_SC_START;
        }
    }
    if (lman.pcswitch_flag == PCSWITCH_1ST_SC_START)
    {
        lman.parent_child = MODE_PARENT;
        lman.state = LMAN_STATE_START_SEARCH_CHILD;
        lman.connect_period = rand % 140;
        lman.pcswitch_period_bak = 140 - lman.connect_period;
        if (lman.connect_period)
        {
            lman.pcswitch_flag = PCSWITCH_1ST_SC;
        }
        else
        {
            lman.pcswitch_flag = PCSWITCH_2ND_SP_START;
        }
    }
    if (lman.pcswitch_flag == PCSWITCH_2ND_SP_START)
    {
        lman.parent_child = MODE_CHILD;
        lman.connect_period = PCSWITCH_SP_PERIOD;
        lman.pcswitch_flag = PCSWITCH_2ND_SP;
        lman.state = LMAN_STATE_START_SEARCH_PARENT;
    }
}

static void rfu_LMAN_REQ_callback(u16 reqCommandId, u16 reqResult)
{
    u8 status;
    u8 *stwiRecvBuffer;
    u8 i;

    if (lman.active != 0)
    {
        lman.active = 0;
        switch (reqCommandId)
        {
        case ID_RESET_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state;
                lman.next_state = LMAN_STATE_CONFIG_GAME_DATA;
            }
            break;
        case ID_SYSTEM_CONFIG_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state;
                lman.next_state = LMAN_STATE_READY;
            }
            break;
        case ID_GAME_CONFIG_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state = LMAN_STATE_READY;
                rfu_LMAN_occureCallback(LMAN_MSG_INITIALIZE_COMPLETED, 0);
            }
            break;
        case ID_SC_START_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state = LMAN_STATE_POLL_SEARCH_CHILD;
            }
            break;
        case ID_SC_POLL_REQ:
            if (lman.connect_period && --lman.connect_period == 0)
            {
                lman.state = LMAN_STATE_END_SEARCH_CHILD;
                lman.next_state = LMAN_STATE_WAIT_RECV_CHILD_NAME;
            }
            break;
        case ID_SC_END_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state;
                lman.next_state = LMAN_STATE_READY;
                if (lman.pcswitch_flag == 0)
                {
                    rfu_LMAN_occureCallback(LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED, 0);
                }
            }
            break;
        case ID_SP_START_REQ:
            if (reqResult == 0)
            {
                if (lman.fastSearchParent_flag == FSP_ON)
                {
                    if (lman.connect_period > 1)
                    {
                        lman.connect_period--;
                    }
                }
                lman.state = lman.next_state = LMAN_STATE_POLL_SEARCH_PARENT;
            }
            break;
        case ID_SP_POLL_REQ:
            if (reqResult == 0)
            {
                status = rfu_LMAN_CHILD_checkEnableParentCandidate();
                lman.param[0] = status;
                if (status)
                {
                    rfu_LMAN_occureCallback(LMAN_MSG_PARENT_FOUND, 1);
                }
                if (lman.fastSearchParent_flag && lman.connect_period != 1 && gRfuLinkStatus->findParentCount == RFU_CHILD_MAX)
                {
                    rfu_REQ_endSearchParent();
                    rfu_waitREQComplete();
                    lman.state = LMAN_STATE_START_SEARCH_PARENT;
                    lman.fastSearchParent_flag = FSP_ON;
                }
            }
            if (lman.connect_period && --lman.connect_period == 0)
            {
                lman.state = LMAN_STATE_END_SEARCH_PARENT;
                lman.next_state = LMAN_STATE_READY;
            }
            break;
        case ID_SP_END_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state;
                if (lman.pcswitch_flag == 0)
                {
                    if (lman.state == LMAN_STATE_READY)
                    {
                        rfu_LMAN_occureCallback(LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED, 0);
                    }
                }
                else if (lman.pcswitch_flag != PCSWITCH_CP)
                {
                    lman.state = LMAN_STATE_START_SEARCH_CHILD;
                    lman.pcswitch_flag = PCSWITCH_3RD_SC_START;
                }
            }
            break;
        case ID_CP_START_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state = LMAN_STATE_POLL_CONNECT_PARENT;
            }
            break;
        case ID_CP_POLL_REQ:
            if (reqResult == 0 && !rfu_getConnectParentStatus(&status, &lman.child_slot) && !status)
            {
                lman.state = LMAN_STATE_END_CONNECT_PARENT;
            }
            if (lman.connect_period && --lman.connect_period == 0)
            {
                lman.state = LMAN_STATE_END_CONNECT_PARENT;
            }
            break;
        case ID_CP_END_REQ:
            if (reqResult == 0 && !rfu_getConnectParentStatus(&status, &lman.child_slot))
            {
                if (!status)
                {
                    lman.state = LMAN_STATE_MS_CHANGE;
                    lman.next_state = LMAN_STATE_SEND_CHILD_NAME;
                    lman.work = 0x22;
                    lman.param[0] = lman.child_slot;
                }
                else
                {
                    lman.state = lman.next_state = LMAN_STATE_READY;
                    lman.work = 0x23;
                    lman.param[0] = status;
                    if (lman.pcswitch_flag)
                    {
                        lman.pcswitch_flag = PCSWITCH_2ND_SP_START;
                        lman.state = LMAN_STATE_START_SEARCH_PARENT;
                    }
                }
                rfu_LMAN_occureCallback(lman.work, 0x01);
                lman.work = 0;
            }
            break;
        case ID_CPR_START_REQ:
            if (reqResult == 0)
            {
                lman.param[0] = gRfuLinkStatus->linkLossSlotFlag;
                lman.state = lman.next_state = LMAN_STATE_POLL_LINK_RECOVERY;
                for (lman.child_slot = 0; lman.child_slot < RFU_CHILD_MAX; lman.child_slot++)
                {
                    if ((gRfuLinkStatus->linkLossSlotFlag >> lman.child_slot) & 1)
                    {
                        break;
                    }
                }
            }
            break;
        case ID_CPR_POLL_REQ:
            if (reqResult == 0 && !rfu_CHILD_getConnectRecoveryStatus(&status) && status < 2)
            {
                lman.state = LMAN_STATE_END_LINK_RECOVERY;
            }
            if (lman.linkRecoveryTimer.count[lman.child_slot] && --lman.linkRecoveryTimer.count[lman.child_slot] == 0)
            {
                lman.state = LMAN_STATE_END_LINK_RECOVERY;
            }
            break;
        case ID_CPR_END_REQ:
            if (reqResult == 0 && !rfu_CHILD_getConnectRecoveryStatus(&status))
            {
                if (!status)
                {
                    lman.state = LMAN_STATE_MS_CHANGE;
                    lman.next_state = LMAN_STATE_BACK_STATE;
                    lman.work = 0x32;
                }
                else
                {
                    lman.state = lman.next_state = LMAN_STATE_READY;
                    rfu_LMAN_disconnect(gRfuLinkStatus->linkLossSlotFlag);
                    lman.work = 0x33;
                }
                lman.linkRecoveryTimer.count[lman.child_slot] = 0;
                lman.linkRecoveryTimer.active = 0;
                lman.linkRecovery_start_flag = 0;
                rfu_LMAN_occureCallback(lman.work, 0x01);
                lman.work = 0;
            }
            break;
        case ID_MS_CHANGE_REQ:
            if (reqResult == 0)
            {
                if (lman.next_state == LMAN_STATE_BACK_STATE)
                {
                    lman.state = lman.state_bak[0];
                    lman.next_state = lman.state_bak[1];
                    lman.childClockSlave_flag = RFU_CHILD_CLOCK_SLAVE_ON;
                    rfu_LMAN_occureCallback(LMAN_MSG_CHANGE_AGB_CLOCK_SLAVE, 0);
                }
                else if (lman.next_state == LMAN_STATE_SEND_CHILD_NAME)
                {
                    lman.state = lman.next_state;
                    lman.childClockSlave_flag = RFU_CHILD_CLOCK_SLAVE_ON;
                    rfu_LMAN_occureCallback(LMAN_MSG_CHANGE_AGB_CLOCK_SLAVE, 0);
                    lman.nameAcceptTimer.active |= 1 << lman.child_slot;
                    lman.nameAcceptTimer.count[lman.child_slot] = lman.nameAcceptTimer.count_max;
                    rfu_clearSlot(TYPE_NI_SEND, lman.child_slot);
                    status = rfu_NI_CHILD_setSendGameName(lman.child_slot, 0x0e);
                    if (status)
                    {
                        lman.state = lman.next_state = LMAN_STATE_READY;
                        rfu_LMAN_managerChangeAgbClockMaster();
                        rfu_LMAN_disconnect(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
                        lman.param[0] = status;
                        rfu_LMAN_occureCallback(LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED, 1);
                    }
                }
            }
            break;
        case ID_STOP_MODE_REQ:
            if (reqResult == 0)
            {
                lman.state = lman.next_state = LMAN_STATE_READY;
                rfu_LMAN_occureCallback(LMAN_MSG_RFU_POWER_DOWN, 0);
            }
            break;
        }
        lman.active = 1;
    }
    else if (reqResult == 3 && lman.msc_exe_flag && (reqCommandId == ID_DATA_TX_REQ || reqCommandId == ID_DATA_RX_REQ || reqCommandId == ID_MS_CHANGE_REQ))
    {
        rfu_REQ_RFUStatus();
        rfu_waitREQComplete();
        rfu_getRFUStatus(&status);
        if (status == 0 && gRfuLinkStatus->parentChild == MODE_CHILD)
        {
            stwiRecvBuffer = rfu_getSTWIRecvBuffer() + 4;
            *stwiRecvBuffer++ = gRfuLinkStatus->connSlotFlag;
            *stwiRecvBuffer = REASON_LINK_LOSS;
            rfu_LMAN_linkWatcher(ID_DISCONNECTED_AND_CHANGE_REQ);
            reqResult = 0;
        }
    }
    switch (reqCommandId)
    {
    case ID_DISCONNECT_REQ:
        if (reqResult == 0)
        {
            lman.param[0] = *(rfu_getSTWIRecvBuffer() + 8);
            rfu_LMAN_reflectCommunicationStatus(lman.param[0]);
            if (lman.linkRecoveryTimer.active)
            {
                lman.linkRecoveryTimer.active &= ~lman.param[0];
                for (i = 0; i < RFU_CHILD_MAX; i++)
                {
                    if ((lman.param[0] >> i) & 1)
                    {
                        lman.linkRecoveryTimer.count[i] = 0;
                    }
                }
                if (lman.parent_child == MODE_CHILD)
                {
                    lman.state = lman.next_state = LMAN_STATE_READY;
                }
            }
            status = lman.acceptSlot_flag & lman.param[0];
            for (i = 0; i < RFU_CHILD_MAX; i++)
            {
                if ((status >> i) & 1 && lman.acceptCount)
                {
                    lman.acceptCount--;
                }
            }
            lman.acceptSlot_flag &= ~lman.param[0];
            if (lman.pcswitch_flag)
            {
                if (gRfuLinkStatus->parentChild == MODE_NEUTRAL)
                {
                    if (lman.pcswitch_flag == PCSWITCH_SC_LOCK)
                    {
                        lman.connect_period = lman.pcswitch_period_bak;
                        lman.pcswitch_flag = PCSWITCH_3RD_SC;
                        lman.state = LMAN_STATE_POLL_SEARCH_CHILD;
                    }
                    else if (lman.state != LMAN_STATE_POLL_SEARCH_CHILD && lman.state != LMAN_STATE_END_SEARCH_CHILD)
                    {
                        lman.pcswitch_flag = PCSWITCH_1ST_SC_START;
                        lman.state = LMAN_STATE_START_SEARCH_CHILD;
                    }
                }
            }
            if (gRfuLinkStatus->parentChild == MODE_NEUTRAL)
            {
                if (lman.state == LMAN_STATE_READY)
                {
                    lman.parent_child = MODE_NEUTRAL;
                }
            }
            if (lman.active == 0)
            {
                rfu_LMAN_occureCallback(LMAN_MSG_LINK_DISCONNECTED_BY_USER, 1);
            }
        }
        break;
    case ID_DATA_RX_REQ:
        rfu_LMAN_CHILD_checkSendChildName2();
        if (gRfuLinkStatus->parentChild != MODE_NEUTRAL)
        {
            rfu_LMAN_occureCallback(LMAN_MSG_RECV_DATA_REQ_COMPLETED, 0);
        }
        break;
    case ID_RESET_REQ:
    case ID_STOP_MODE_REQ:
        if (reqResult == 0)
        {
            lman.reserveDisconnectSlot_flag = 0;
            lman.acceptCount = 0;
            lman.acceptSlot_flag = 0;
            lman.parent_child = MODE_NEUTRAL;
            rfu_LMAN_managerChangeAgbClockMaster();
            if (reqCommandId == ID_STOP_MODE_REQ)
            {
                rfu_LMAN_endManager();
            }
        }
        break;
    }
    if (reqResult != 0)
    {
        if (reqCommandId == ID_SP_START_REQ && reqResult != 0 && lman.pcswitch_flag == PCSWITCH_2ND_SP)
        {
            gRfuLinkStatus->parentChild = MODE_PARENT;
            gRfuLinkStatus->connSlotFlag = 0xF;
            rfu_LMAN_disconnect(15);
            rfu_waitREQComplete();
            return;
        }
        else
        {
            lman.param[0] = reqCommandId;
            lman.param[1] = reqResult;
            if (lman.active)
            {
                lman.state = lman.next_state = LMAN_STATE_READY;
            }
            rfu_LMAN_occureCallback(LMAN_MSG_REQ_API_ERROR, 2);
            rfu_LMAN_managerChangeAgbClockMaster();
        }
    }
    if (reqCommandId == ID_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA_REQ)
    {
        rfu_LMAN_occureCallback(LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA, 0);
        rfu_LMAN_managerChangeAgbClockMaster();
    }
}

static void rfu_LMAN_MSC_callback(u16 reqCommandId)
{
    u8 active_bak;
    u8 thisAck_flag;

    active_bak = lman.active;
    lman.active = 0;
    lman.msc_exe_flag = 1;
    if (gRfuLinkStatus->parentChild == MODE_CHILD)
    {
        rfu_LMAN_linkWatcher(reqCommandId);
        if (lman.childClockSlave_flag != RFU_CHILD_CLOCK_SLAVE_ON)
        {
            rfu_LMAN_managerChangeAgbClockMaster();
            lman.msc_exe_flag = 0;
            lman.active = active_bak;
            return;
        }
    }
    else
    {
        if (!rfu_UNI_PARENT_getDRAC_ACK(&thisAck_flag))
        {
            lman.parentAck_flag |= thisAck_flag;
        }
    }
    if (lman.MSC_callback != NULL)
    {
        lman.MSC_callback(reqCommandId);
        rfu_waitREQComplete();
        if (lman.childClockSlave_flag == RFU_CHILD_CLOCK_SLAVE_OFF_REQ)
        {
            rfu_LMAN_managerChangeAgbClockMaster();
        }
    }
    lman.msc_exe_flag = 0;
    lman.active = active_bak;
}

static void rfu_LMAN_PARENT_checkRecvChildName(void)
{
    u8 newSlot;
    u8 newAcceptSlot;
    u8 i;
    u8 flags;
    u8 tgtSlot;
    const u16 *ptr;

    if (lman.state == LMAN_STATE_START_SEARCH_CHILD || lman.state == LMAN_STATE_POLL_SEARCH_CHILD || lman.state == LMAN_STATE_END_SEARCH_CHILD || lman.state == LMAN_STATE_WAIT_RECV_CHILD_NAME)
    {
        newSlot = ((gRfuLinkStatus->connSlotFlag ^ lman.connectSlot_flag_old) & gRfuLinkStatus->connSlotFlag) & ~gRfuLinkStatus->getNameFlag;
        lman.connectSlot_flag_old = gRfuLinkStatus->connSlotFlag;
        if (newSlot)
        {
            lman.param[0] = newSlot;
            rfu_LMAN_occureCallback(LMAN_MSG_NEW_CHILD_CONNECT_DETECTED, 1);
        }
        newAcceptSlot = 0x00;
        for (i = 0; i < RFU_CHILD_MAX; i++)
        {
            tgtSlot = 1 << i;
            flags = 0x00;
            if (newSlot & tgtSlot)
            {
                lman.nameAcceptTimer.count[i] = lman.nameAcceptTimer.count_max;
                lman.nameAcceptTimer.active |= tgtSlot;
            }
            else if (lman.nameAcceptTimer.active & tgtSlot)
            {
                if (gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS)
                {
                    if (gRfuSlotStatusNI[i]->recv.dataType == 1)
                    {
                        flags = RN_NAME_TIMER_CLEAR;
                        for (ptr = lman.acceptable_serialNo_list; *ptr != 0xFFFF; ptr++)
                        {
                            if (gRfuLinkStatus->partner[i].serialNo == *ptr)
                            {
                                lman.acceptSlot_flag |= tgtSlot;
                                lman.acceptCount++;
                                newAcceptSlot |= tgtSlot;
                                flags |= RN_ACCEPT;
                                break;
                            }
                        }
                        if (!(flags & RN_ACCEPT))
                        {
                            flags |= RN_DISCONNECT;
                        }
                    }
                }
                else if (--lman.nameAcceptTimer.count[i] == 0)
                {
                    flags = RN_NAME_TIMER_CLEAR | RN_DISCONNECT;
                }
                if (flags & RN_NAME_TIMER_CLEAR)
                {
                    lman.nameAcceptTimer.active &= ~tgtSlot;
                    lman.nameAcceptTimer.count[i] = 0;
                    rfu_clearSlot(TYPE_NI_RECV, i);
                }
                if (flags & RN_DISCONNECT)
                {
                    lman.reserveDisconnectSlot_flag |= tgtSlot;
                }
            }
        }
        if (newAcceptSlot)
        {
            lman.param[0] = newAcceptSlot;
            rfu_LMAN_occureCallback(LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED, 1);
        }
        if (lman.reserveDisconnectSlot_flag)
        {
            flags = 1;
            if (gRfuLinkStatus->sendSlotUNIFlag)
            {
                if (((lman.parentAck_flag & lman.acceptSlot_flag) != lman.acceptSlot_flag))
                {
                    flags = 0;
                }
            }
            if (flags)
            {
                rfu_LMAN_disconnect(lman.reserveDisconnectSlot_flag);
                lman.param[0] = lman.reserveDisconnectSlot_flag;
                lman.reserveDisconnectSlot_flag = 0;
                rfu_LMAN_occureCallback(LMAN_MSG_NEW_CHILD_CONNECT_REJECTED, 1);
            }
        }
        if (lman.nameAcceptTimer.active == 0 && lman.state == LMAN_STATE_WAIT_RECV_CHILD_NAME)
        {
            if (lman.pcswitch_flag == 0)
            {
                lman.state = lman.next_state = LMAN_STATE_READY;
                rfu_LMAN_occureCallback(LMAN_MSG_END_WAIT_CHILD_NAME, 0);
            }
            else
            {
                if (lman.pcswitch_flag == PCSWITCH_1ST_SC)
                {
                    lman.pcswitch_flag = PCSWITCH_2ND_SP_START;
                    lman.state = LMAN_STATE_START_SEARCH_PARENT;
                }
                else
                {
                    lman.pcswitch_flag = PCSWITCH_1ST_SC_START;
                    lman.state = LMAN_STATE_START_SEARCH_CHILD;
                }
                if (lman.acceptSlot_flag)
                {
                    lman.connect_period = 0;
                    lman.pcswitch_flag = PCSWITCH_SC_LOCK;
                    lman.state = LMAN_STATE_START_SEARCH_CHILD;
                }
            }
        }
    }
}

static void rfu_LMAN_CHILD_checkSendChildName(void)
{
    u16 imeBak = REG_IME;
    REG_IME = 0;
    if (lman.state == LMAN_STATE_SEND_CHILD_NAME)
    {
        if (--lman.nameAcceptTimer.count[lman.child_slot] == 0 || gRfuSlotStatusNI[lman.child_slot]->send.state == SLOT_STATE_SEND_FAILED)
        {
            rfu_LMAN_requestChangeAgbClockMaster();
            lman.state = LMAN_STATE_WAIT_CHANGE_CLOCK_MASTER;
            rfu_clearSlot(TYPE_NI_SEND, lman.child_slot);
            lman.nameAcceptTimer.active &= ~(1 << lman.child_slot);
            lman.nameAcceptTimer.count[lman.child_slot] = 0;
        }
    }
    REG_IME = imeBak;
    if (lman.state == LMAN_STATE_WAIT_CHANGE_CLOCK_MASTER)
    {
        if (lman.childClockSlave_flag == RFU_CHILD_CLOCK_SLAVE_ON)
        {
            rfu_LMAN_requestChangeAgbClockMaster();
        }
        if (lman.childClockSlave_flag == RFU_CHILD_CLOCK_SLAVE_OFF)
        {
            lman.state = lman.next_state = LMAN_STATE_READY;
            rfu_LMAN_disconnect(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
            lman.param[0] = 0;
            rfu_LMAN_occureCallback(LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED, 1);
        }
    }
}

static void rfu_LMAN_CHILD_checkSendChildName2(void)
{
    if (lman.state == LMAN_STATE_SEND_CHILD_NAME && gRfuSlotStatusNI[lman.child_slot]->send.state == SLOT_STATE_SEND_SUCCESS)
    {
        lman.state = lman.next_state = LMAN_STATE_READY;
        rfu_clearSlot(TYPE_NI_SEND, lman.child_slot);
        lman.nameAcceptTimer.active &= ~(1 << lman.child_slot);
        lman.nameAcceptTimer.count[lman.child_slot] = 0;
        rfu_LMAN_occureCallback(LMAN_MSG_CHILD_NAME_SEND_COMPLETED, 0);
    }
}

static void rfu_LMAN_CHILD_linkRecoveryProcess(void)
{
    if (lman.parent_child == MODE_CHILD && lman.linkRecovery_start_flag == LINK_RECOVERY_START)
    {
        lman.state_bak[0] = lman.state;
        lman.state_bak[1] = lman.next_state;
        lman.state = LMAN_STATE_START_LINK_RECOVERY;
        lman.next_state = LMAN_STATE_POLL_LINK_RECOVERY;
        lman.linkRecovery_start_flag = LINK_RECOVERY_EXE;
    }
}

static u8 rfu_LMAN_CHILD_checkEnableParentCandidate(void)
{
    u8 i;
    u16 *serialNo;
    u8 flags = 0x00;

    for (i = 0; i < gRfuLinkStatus->findParentCount; i++)
    {
        for (serialNo = lman.acceptable_serialNo_list; *serialNo != 0xFFFF; serialNo++)
        {
            if (gRfuLinkStatus->partner[i].serialNo == *serialNo)
            {
                flags |= (1 << i);
            }
        }
    }
    return flags;
}

static void rfu_LMAN_occureCallback(u8 msg, u8 param_count)
{
    if (lman.LMAN_callback != NULL)
    {
        lman.LMAN_callback(msg, param_count);
    }
    lman.param[0] = lman.param[1] = 0;
}

static void rfu_LMAN_disconnect(u8 bm_disconnectedSlot)
{
    u8 active_bak = lman.active;
    lman.active = 1;
    rfu_REQ_disconnect(bm_disconnectedSlot);
    rfu_waitREQComplete();
    lman.active = active_bak;
}

static void rfu_LMAN_reflectCommunicationStatus(u8 bm_disconnectedSlot)
{
    u8 i;

    if (gRfuLinkStatus->sendSlotNIFlag)
    {
        for (i = 0; i < RFU_CHILD_MAX; i++)
        {
            if (gRfuSlotStatusNI[i]->send.state & SLOT_BUSY_FLAG && gRfuSlotStatusNI[i]->send.bmSlot & bm_disconnectedSlot)
            {
                rfu_changeSendTarget(TYPE_NI, i, gRfuSlotStatusNI[i]->send.bmSlot & ~bm_disconnectedSlot);
            }
        }
    }
    if (gRfuLinkStatus->recvSlotNIFlag)
    {
        for (i = 0; i < RFU_CHILD_MAX; i++)
        {
            if (gRfuSlotStatusNI[i]->recv.state & SLOT_BUSY_FLAG && gRfuSlotStatusNI[i]->recv.bmSlot & bm_disconnectedSlot)
            {
                rfu_NI_stopReceivingData(i);
            }
        }
    }
    if (gRfuLinkStatus->sendSlotUNIFlag)
    {
        gRfuLinkStatus->sendSlotUNIFlag &= ~bm_disconnectedSlot;
        for (i = 0; i < RFU_CHILD_MAX; i++)
        {
            if (gRfuSlotStatusUNI[i]->send.state == SLOT_STATE_SEND_UNI && bm_disconnectedSlot & gRfuSlotStatusUNI[i]->send.bmSlot)
            {
                gRfuSlotStatusUNI[i]->send.bmSlot &= ~bm_disconnectedSlot;
            }
        }
    }
}

static void rfu_LMAN_checkNICommunicateStatus(void)
{
    u8 i;
    u8 j;
    u8 flags;

    if (lman.NI_failCounter_limit)
    {
        if (gRfuLinkStatus->sendSlotNIFlag)
        {
            for (i = 0; i < RFU_CHILD_MAX; i++)
            {
                if (gRfuSlotStatusNI[i]->send.state & SLOT_BUSY_FLAG)
                {
                    flags = 0;
                    for (j = 0; j < RFU_CHILD_MAX; j++)
                    {
                        if ((gRfuSlotStatusNI[i]->send.bmSlot >> j) & 1 && gRfuSlotStatusNI[j]->send.failCounter > lman.NI_failCounter_limit)
                        {
                            flags |= (1 << j);
                        }
                        if (flags)
                        {
                            rfu_changeSendTarget(TYPE_NI, i, flags ^ gRfuSlotStatusNI[i]->send.bmSlot);
                        }
                    }
                }
            }
        }
        if (gRfuLinkStatus->recvSlotNIFlag)
        {
            for (i = 0; i < RFU_CHILD_MAX; i++)
            {
                if (gRfuSlotStatusNI[i]->recv.state & SLOT_BUSY_FLAG && gRfuSlotStatusNI[i]->recv.failCounter > lman.NI_failCounter_limit)
                {
                    rfu_NI_stopReceivingData(i);
                }
            }
        }
    }
}

void rfu_LMAN_setMSCCallback(void (*MSC_callback_p)(u16))
{
    lman.MSC_callback = MSC_callback_p;
    rfu_setMSCCallback(rfu_LMAN_MSC_callback);
}

static void rfu_LMAN_setLMANCallback(void (*func)(u8, u8))
{
    lman.LMAN_callback = func;
}

u8 rfu_LMAN_setLinkRecovery(u8 enable_flag, u16 recovery_period)
{
    u16 imeBak;
    if (lman.linkRecovery_enable && enable_flag == 0 && lman.linkRecoveryTimer.active)
    {
        return LMAN_ERROR_NOW_LINK_RECOVERY;
    }
    imeBak = REG_IME;
    REG_IME = 0;
    lman.linkRecovery_enable = enable_flag;
    lman.linkRecoveryTimer.count_max = recovery_period;
    REG_IME = imeBak;
    return 0;
}

static u8 rfu_LMAN_setNIFailCounterLimit(u16 NI_failCounter_limit)
{
    if (gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag)
    {
        lman.param[0] = 6;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_NOW_COMMUNICATION;
    }
    lman.NI_failCounter_limit = NI_failCounter_limit;
    return 0;
}

static u8 rfu_LMAN_setFastSearchParent(u8 enable_flag)
{
    if (lman.state == LMAN_STATE_START_SEARCH_PARENT || lman.state == LMAN_STATE_POLL_SEARCH_PARENT || lman.state == LMAN_STATE_END_SEARCH_PARENT)
    {
        lman.param[0] = 7;
        rfu_LMAN_occureCallback(LMAN_MSG_LMAN_API_ERROR_RETURN, 1);
        return LMAN_ERROR_NOW_SEARCH_PARENT;
    }
    if (enable_flag)
    {
        lman.fastSearchParent_flag = FSP_ON;
    }
    else
    {
        lman.fastSearchParent_flag = 0;
    }
    return 0;
}

static void rfu_LMAN_managerChangeAgbClockMaster(void)
{
    if (lman.childClockSlave_flag != RFU_CHILD_CLOCK_SLAVE_OFF)
    {
        lman.childClockSlave_flag = RFU_CHILD_CLOCK_SLAVE_OFF;
        rfu_LMAN_occureCallback(LMAN_MSG_CHANGE_AGB_CLOCK_MASTER, 0);
    }
}

void rfu_LMAN_requestChangeAgbClockMaster(void)
{
    if (lman.childClockSlave_flag == RFU_CHILD_CLOCK_SLAVE_OFF)
    {
        rfu_LMAN_occureCallback(LMAN_MSG_CHANGE_AGB_CLOCK_MASTER, 0);
    }
    else if (lman.childClockSlave_flag == RFU_CHILD_CLOCK_SLAVE_ON)
    {
        lman.childClockSlave_flag = RFU_CHILD_CLOCK_SLAVE_OFF_REQ;
    }
}

void rfu_LMAN_forceChangeSP(void)
{
    if (lman.pcswitch_flag)
    {
        switch (lman.state)
        {
        case LMAN_STATE_START_SEARCH_CHILD:
            lman.pcswitch_flag = PCSWITCH_2ND_SP_START;
            lman.state = LMAN_STATE_START_SEARCH_PARENT;
            break;
        case LMAN_STATE_POLL_SEARCH_CHILD:
            lman.pcswitch_flag = PCSWITCH_1ST_SC;
            lman.connect_period = 1;
            break;
        case LMAN_STATE_END_SEARCH_CHILD:
        case LMAN_STATE_WAIT_RECV_CHILD_NAME:
            lman.pcswitch_flag = PCSWITCH_1ST_SC;
            break;
        case LMAN_STATE_START_SEARCH_PARENT:
        case LMAN_STATE_POLL_SEARCH_PARENT:
            lman.connect_period = PCSWITCH_SP_PERIOD;
            break;
        case LMAN_STATE_END_SEARCH_PARENT:
            lman.connect_period = PCSWITCH_SP_PERIOD;
            lman.state = LMAN_STATE_POLL_SEARCH_PARENT;
            break;
        }
    }
}


code:
#include "gba/gba.h"
#include "gba/flash_internal.h"

static u8 sTimerNum;
static u16 sTimerCount;
static vu16 *sTimerReg;
static u16 sSavedIme;

u8 gFlashTimeoutFlag;
u8 (*PollFlashStatus)(u8 *);
u16 (*WaitForFlashWrite)(u8 phase, u8 *addr, u8 lastData);
u16 (*ProgramFlashSector)(u16 sectorNum, u8 *src);
const struct FlashType *gFlash;
u16 (*ProgramFlashByte)(u16 sectorNum, u32 offset, u8 data);
u16 gFlashNumRemainingBytes;
u16 (*EraseFlashChip)();
u16 (*EraseFlashSector)(u16 sectorNum);
const u16 *gFlashMaxTime;

void SetReadFlash1(u16 *dest);

void SwitchFlashBank(u8 bankNum)
{
    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0xB0);
    FLASH_WRITE(0x0000, bankNum);
}

#define DELAY()                  \
do {                             \
    vu16 i;                      \
    for (i = 20000; i != 0; i--) \
        ;                        \
} while (0)

u16 ReadFlashId(void)
{
    u16 flashId;
    u16 readFlash1Buffer[0x20];
    u8 (*readFlash1)(u8 *);

    SetReadFlash1(readFlash1Buffer);
    readFlash1 = (u8 (*)(u8 *))((s32)readFlash1Buffer + 1);

    // Enter ID mode.
    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0x90);
    DELAY();

    flashId = readFlash1(FLASH_BASE + 1) << 8;
    flashId |= readFlash1(FLASH_BASE);

    // Leave ID mode.
    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0xF0);
    FLASH_WRITE(0x5555, 0xF0);
    DELAY();

    return flashId;
}

void FlashTimerIntr(void)
{
    if (sTimerCount != 0 && --sTimerCount == 0)
        gFlashTimeoutFlag = 1;
}

u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void))
{
    if (timerNum >= 4)
        return 1;

    sTimerNum = timerNum;
    sTimerReg = &REG_TMCNT_L(sTimerNum);
    *intrFunc = FlashTimerIntr;
    return 0;
}

void StartFlashTimer(u8 phase)
{
    const u16 *maxTime = &gFlashMaxTime[phase * 3];
    sSavedIme = REG_IME;
    REG_IME = 0;
    sTimerReg[1] = 0;
    REG_IE |= (INTR_FLAG_TIMER0 << sTimerNum);
    gFlashTimeoutFlag = 0;
    sTimerCount = *maxTime++;
    *sTimerReg++ = *maxTime++;
    *sTimerReg-- = *maxTime++;
    REG_IF = (INTR_FLAG_TIMER0 << sTimerNum);
    REG_IME = 1;
}

void StopFlashTimer(void)
{
    REG_IME = 0;
    *sTimerReg++ = 0;
    *sTimerReg-- = 0;
    REG_IE &= ~(INTR_FLAG_TIMER0 << sTimerNum);
    REG_IME = sSavedIme;
}

u8 ReadFlash1(u8 *addr)
{
    return *addr;
}

void SetReadFlash1(u16 *dest)
{
    u16 *src;
    u16 i;

    PollFlashStatus = (u8 (*)(u8 *))((s32)dest + 1);

    src = (u16 *)ReadFlash1;
    src = (u16 *)((s32)src ^ 1);

    i = ((s32)SetReadFlash1 - (s32)ReadFlash1) >> 1;

    while (i != 0)
    {
        *dest++ = *src++;
        i--;
    }
}

// Using volatile here to make sure the flash memory will ONLY be read as bytes, to prevent any compiler optimizations.
void ReadFlash_Core(vu8 *src, u8 *dest, u32 size)
{
    while (size-- != 0)
    {
        *dest++ = *src++;
    }
}

void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size)
{
    u8 *src;
    u16 i;
    vu16 readFlash_Core_Buffer[0x40];
    vu16 *funcSrc;
    vu16 *funcDest;
    void (*readFlash_Core)(vu8 *, u8 *, u32);

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8;

    if (gFlash->romSize == FLASH_ROM_SIZE_1M)
    {
        SwitchFlashBank(sectorNum / SECTORS_PER_BANK);
        sectorNum %= SECTORS_PER_BANK;
    }

    funcSrc = (vu16 *)ReadFlash_Core;
    funcSrc = (vu16 *)((s32)funcSrc ^ 1);
    funcDest = readFlash_Core_Buffer;

    i = ((s32)ReadFlash - (s32)ReadFlash_Core) >> 1;

    while (i != 0)
    {
        *funcDest++ = *funcSrc++;
        i--;
    }

    readFlash_Core = (void (*)(vu8 *, u8 *, u32))((s32)readFlash_Core_Buffer + 1);

    src = FLASH_BASE + (sectorNum << gFlash->sector.shift) + offset;

    readFlash_Core(src, dest, size);
}

u32 VerifyFlashSector_Core(u8 *src, u8 *tgt, u32 size)
{
    while (size-- != 0)
    {
        if (*tgt++ != *src++)
            return (u32)(tgt - 1);
    }

    return 0;
}

u32 VerifyFlashSector(u16 sectorNum, u8 *src)
{
    u16 i;
    vu16 verifyFlashSector_Core_Buffer[0x80];
    vu16 *funcSrc;
    vu16 *funcDest;
    u8 *tgt;
    u16 size;
    u32 (*verifyFlashSector_Core)(u8 *, u8 *, u32);

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8;

    if (gFlash->romSize == FLASH_ROM_SIZE_1M)
    {
        SwitchFlashBank(sectorNum / SECTORS_PER_BANK);
        sectorNum %= SECTORS_PER_BANK;
    }

    funcSrc = (vu16 *)VerifyFlashSector_Core;
    funcSrc = (vu16 *)((s32)funcSrc ^ 1);
    funcDest = verifyFlashSector_Core_Buffer;

    i = ((s32)VerifyFlashSector - (s32)VerifyFlashSector_Core) >> 1;

    while (i != 0)
    {
        *funcDest++ = *funcSrc++;
        i--;
    }

    verifyFlashSector_Core = (u32 (*)(u8 *, u8 *, u32))((s32)verifyFlashSector_Core_Buffer + 1);

    tgt = FLASH_BASE + (sectorNum << gFlash->sector.shift);
    size = gFlash->sector.size;

    return verifyFlashSector_Core(src, tgt, size);
}

u32 VerifyFlashSectorNBytes(u16 sectorNum, u8 *src, u32 n)
{
    u16 i;
    vu16 verifyFlashSector_Core_Buffer[0x80];
    vu16 *funcSrc;
    vu16 *funcDest;
    u8 *tgt;
    u32 (*verifyFlashSector_Core)(u8 *, u8 *, u32);

    if (gFlash->romSize == FLASH_ROM_SIZE_1M)
    {
        SwitchFlashBank(sectorNum / SECTORS_PER_BANK);
        sectorNum %= SECTORS_PER_BANK;
    }

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8;

    funcSrc = (vu16 *)VerifyFlashSector_Core;
    funcSrc = (vu16 *)((s32)funcSrc ^ 1);
    funcDest = verifyFlashSector_Core_Buffer;

    i = ((s32)VerifyFlashSector - (s32)VerifyFlashSector_Core) >> 1;

    while (i != 0)
    {
        *funcDest++ = *funcSrc++;
        i--;
    }

    verifyFlashSector_Core = (u32 (*)(u8 *, u8 *, u32))((s32)verifyFlashSector_Core_Buffer + 1);

    tgt = FLASH_BASE + (sectorNum << gFlash->sector.shift);

    return verifyFlashSector_Core(src, tgt, n);
}

u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src)
{
    u8 i;
    u32 result;

    for (i = 0; i < 3; i++)
    {
        result = ProgramFlashSector(sectorNum, src);
        if (result != 0)
            continue;

        result = VerifyFlashSector(sectorNum, src);
        if (result == 0)
            break;
    }

    return result;
}

u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, u8 *src, u32 n)
{
    u8 i;
    u32 result;

    for (i = 0; i < 3; i++)
    {
        result = ProgramFlashSector(sectorNum, src);
        if (result != 0)
            continue;

        result = VerifyFlashSectorNBytes(sectorNum, src, n);
        if (result == 0)
            break;
    }

    return result;
}

repo_name: Lunos/pokeemerald

license: mit


code:
#include "gba/gba.h"
#include "gba/flash_internal.h"

static const char AgbLibFlashVersion[] = "FLASH1M_V103";

const struct FlashSetupInfo * const sSetupInfos[] =
{
    &MX29L010,
    &LE26FV10N1TS,
    &DefaultFlash
};

u16 IdentifyFlash(void)
{
    u16 result;
    u16 flashId;
    const struct FlashSetupInfo * const *setupInfo;

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8;

    flashId = ReadFlashId();

    setupInfo = sSetupInfos;
    result = 1;

    for (;;)
    {
        if ((*setupInfo)->type.ids.separate.makerId == 0)
            break;

        if (flashId == (*setupInfo)->type.ids.joined)
        {
            result = 0;
            break;
        }

        setupInfo++;
    }

    ProgramFlashByte = (*setupInfo)->programFlashByte;
    ProgramFlashSector = (*setupInfo)->programFlashSector;
    EraseFlashChip = (*setupInfo)->eraseFlashChip;
    EraseFlashSector = (*setupInfo)->eraseFlashSector;
    WaitForFlashWrite = (*setupInfo)->WaitForFlashWrite;
    gFlashMaxTime = (*setupInfo)->maxTime;
    gFlash = &(*setupInfo)->type;

    return result;
}

u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData)
{
    u16 result = 0;
    u8 status;

    StartFlashTimer(phase);

    while ((status = PollFlashStatus(addr)) != lastData)
    {
        if (status & 0x20)
        {
            // The write operation exceeded the flash chip's time limit.

            if (PollFlashStatus(addr) == lastData)
                break;

            FLASH_WRITE(0x5555, 0xF0);
            result = phase | 0xA000u;
            break;
        }

        if (gFlashTimeoutFlag)
        {
            if (PollFlashStatus(addr) == lastData)
                break;

            FLASH_WRITE(0x5555, 0xF0);
            result = phase | 0xC000u;
            break;
        }
    }

    StopFlashTimer();

    return result;
}


code:
#include "gba/gba.h"
#include "gba/flash_internal.h"

const u16 leMaxTime[] =
{
      10, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
      10, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
    2000, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
    2000, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
};

const struct FlashSetupInfo LE26FV10N1TS =
{
    ProgramFlashByte_MX,
    ProgramFlashSector_MX,
    EraseFlashChip_MX,
    EraseFlashSector_MX,
    WaitForFlashWrite_Common,
    leMaxTime,
    {
        131072, // ROM size
        {
            4096, // sector size
              12, // bit shift to multiply by sector size (4096 == 1 << 12)
              32, // number of sectors
               0  // appears to be unused
        },
        { 3, 1 }, // wait state setup data
        { { 0x62, 0x13 } } // ID
    }
};


code:
#include "gba/gba.h"
#include "gba/flash_internal.h"

const u16 mxMaxTime[] =
{
      10, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
      10, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
    2000, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
    2000, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK,
};

const struct FlashSetupInfo MX29L010 =
{
    ProgramFlashByte_MX,
    ProgramFlashSector_MX,
    EraseFlashChip_MX,
    EraseFlashSector_MX,
    WaitForFlashWrite_Common,
    mxMaxTime,
    {
        131072, // ROM size
        {
            4096, // sector size
              12, // bit shift to multiply by sector size (4096 == 1 << 12)
              32, // number of sectors
               0  // appears to be unused
        },
        { 3, 1 }, // wait state setup data
        { { 0xC2, 0x09 } } // ID
    }
};

const struct FlashSetupInfo DefaultFlash =
{
    ProgramFlashByte_MX,
    ProgramFlashSector_MX,
    EraseFlashChip_MX,
    EraseFlashSector_MX,
    WaitForFlashWrite_Common,
    mxMaxTime,
    {
        131072, // ROM size
        {
            4096, // sector size
              12, // bit shift to multiply by sector size (4096 == 1 << 12)
              32, // number of sectors
               0  // appears to be unused
        },
        { 3, 1 }, // wait state setup data
        { { 0x00, 0x00 } } // ID of 0
    }
};

u16 EraseFlashChip_MX(void)
{
    u16 result;
    u16 readFlash1Buffer[0x20];

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | gFlash->wait[0];

    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0x80);
    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0x10);

    SetReadFlash1(readFlash1Buffer);

    result = WaitForFlashWrite(3, FLASH_BASE, 0xFF);

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8;

    return result;
}

u16 EraseFlashSector_MX(u16 sectorNum)
{
    u16 numTries;
    u16 result;
    u8 *addr;
    u16 readFlash1Buffer[0x20];

    if (sectorNum >= gFlash->sector.count)
        return 0x80FF;

    SwitchFlashBank(sectorNum / SECTORS_PER_BANK);
    sectorNum %= SECTORS_PER_BANK;

    numTries = 0;

try_erase:
    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | gFlash->wait[0];

    addr = FLASH_BASE + (sectorNum << gFlash->sector.shift);

    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0x80);
    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    *addr = 0x30;

    SetReadFlash1(readFlash1Buffer);

    result = WaitForFlashWrite(2, addr, 0xFF);

    if (!(result & 0xA000) || numTries > 3)
        goto done;

    numTries++;

    goto try_erase;

done:
    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8;

    return result;
}

u16 ProgramFlashByte_MX(u16 sectorNum, u32 offset, u8 data)
{
    u8 *addr;
    u16 readFlash1Buffer[0x20];

    if (offset >= gFlash->sector.size)
        return 0x8000;

    SwitchFlashBank(sectorNum / SECTORS_PER_BANK);
    sectorNum %= SECTORS_PER_BANK;

    addr = FLASH_BASE + (sectorNum << gFlash->sector.shift) + offset;

    SetReadFlash1(readFlash1Buffer);

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | gFlash->wait[0];

    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0xA0);
    *addr = data;

    return WaitForFlashWrite(1, addr, data);
}

static u16 ProgramByte(u8 *src, u8 *dest)
{
    FLASH_WRITE(0x5555, 0xAA);
    FLASH_WRITE(0x2AAA, 0x55);
    FLASH_WRITE(0x5555, 0xA0);
    *dest = *src;

    return WaitForFlashWrite(1, dest, *src);
}

u16 ProgramFlashSector_MX(u16 sectorNum, u8 *src)
{
    u16 result;
    u8 *dest;
    u16 readFlash1Buffer[0x20];

    if (sectorNum >= gFlash->sector.count)
        return 0x80FF;

    result = EraseFlashSector_MX(sectorNum);

    if (result != 0)
        return result;

    SwitchFlashBank(sectorNum / SECTORS_PER_BANK);
    sectorNum %= SECTORS_PER_BANK;

    SetReadFlash1(readFlash1Buffer);

    REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | gFlash->wait[0];

    gFlashNumRemainingBytes = gFlash->sector.size;
    dest = FLASH_BASE + (sectorNum << gFlash->sector.shift);

    while (gFlashNumRemainingBytes > 0)
    {
        result = ProgramByte(src, dest);

        if (result != 0)
            break;

        gFlashNumRemainingBytes--;
        src++;
        dest++;
    }

    return result;
}


code:
#include "global.h"

const u32 gMonFrontPic_CircledQuestionMark[] = INCBIN_U32("graphics/pokemon/question_mark/circled/anim_front.4bpp.lz");

const u32 gMonFrontPic_Bulbasaur[] = INCBIN_U32("graphics/pokemon/bulbasaur/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ivysaur[] = INCBIN_U32("graphics/pokemon/ivysaur/anim_front.4bpp.lz");
const u32 gMonFrontPic_Venusaur[] = INCBIN_U32("graphics/pokemon/venusaur/anim_front.4bpp.lz");
const u32 gMonFrontPic_Charmander[] = INCBIN_U32("graphics/pokemon/charmander/anim_front.4bpp.lz");
const u32 gMonFrontPic_Charmeleon[] = INCBIN_U32("graphics/pokemon/charmeleon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Charizard[] = INCBIN_U32("graphics/pokemon/charizard/anim_front.4bpp.lz");
const u32 gMonFrontPic_Squirtle[] = INCBIN_U32("graphics/pokemon/squirtle/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wartortle[] = INCBIN_U32("graphics/pokemon/wartortle/anim_front.4bpp.lz");
const u32 gMonFrontPic_Blastoise[] = INCBIN_U32("graphics/pokemon/blastoise/anim_front.4bpp.lz");
const u32 gMonFrontPic_Caterpie[] = INCBIN_U32("graphics/pokemon/caterpie/anim_front.4bpp.lz");
const u32 gMonFrontPic_Metapod[] = INCBIN_U32("graphics/pokemon/metapod/anim_front.4bpp.lz");
const u32 gMonFrontPic_Butterfree[] = INCBIN_U32("graphics/pokemon/butterfree/anim_front.4bpp.lz");
const u32 gMonFrontPic_Weedle[] = INCBIN_U32("graphics/pokemon/weedle/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kakuna[] = INCBIN_U32("graphics/pokemon/kakuna/anim_front.4bpp.lz");
const u32 gMonFrontPic_Beedrill[] = INCBIN_U32("graphics/pokemon/beedrill/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pidgey[] = INCBIN_U32("graphics/pokemon/pidgey/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pidgeotto[] = INCBIN_U32("graphics/pokemon/pidgeotto/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pidgeot[] = INCBIN_U32("graphics/pokemon/pidgeot/anim_front.4bpp.lz");
const u32 gMonFrontPic_Rattata[] = INCBIN_U32("graphics/pokemon/rattata/anim_front.4bpp.lz");
const u32 gMonFrontPic_Raticate[] = INCBIN_U32("graphics/pokemon/raticate/anim_front.4bpp.lz");
const u32 gMonFrontPic_Spearow[] = INCBIN_U32("graphics/pokemon/spearow/anim_front.4bpp.lz");
const u32 gMonFrontPic_Fearow[] = INCBIN_U32("graphics/pokemon/fearow/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ekans[] = INCBIN_U32("graphics/pokemon/ekans/anim_front.4bpp.lz");
const u32 gMonFrontPic_Arbok[] = INCBIN_U32("graphics/pokemon/arbok/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pikachu[] = INCBIN_U32("graphics/pokemon/pikachu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Raichu[] = INCBIN_U32("graphics/pokemon/raichu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sandshrew[] = INCBIN_U32("graphics/pokemon/sandshrew/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sandslash[] = INCBIN_U32("graphics/pokemon/sandslash/anim_front.4bpp.lz");
const u32 gMonFrontPic_NidoranF[] = INCBIN_U32("graphics/pokemon/nidoran_f/anim_front.4bpp.lz");
const u32 gMonFrontPic_Nidorina[] = INCBIN_U32("graphics/pokemon/nidorina/anim_front.4bpp.lz");
const u32 gMonFrontPic_Nidoqueen[] = INCBIN_U32("graphics/pokemon/nidoqueen/anim_front.4bpp.lz");
const u32 gMonFrontPic_NidoranM[] = INCBIN_U32("graphics/pokemon/nidoran_m/anim_front.4bpp.lz");
const u32 gMonFrontPic_Nidorino[] = INCBIN_U32("graphics/pokemon/nidorino/anim_front.4bpp.lz");
const u32 gMonFrontPic_Nidoking[] = INCBIN_U32("graphics/pokemon/nidoking/anim_front.4bpp.lz");
const u32 gMonFrontPic_Clefairy[] = INCBIN_U32("graphics/pokemon/clefairy/anim_front.4bpp.lz");
const u32 gMonFrontPic_Clefable[] = INCBIN_U32("graphics/pokemon/clefable/anim_front.4bpp.lz");
const u32 gMonFrontPic_Vulpix[] = INCBIN_U32("graphics/pokemon/vulpix/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ninetales[] = INCBIN_U32("graphics/pokemon/ninetales/anim_front.4bpp.lz");
const u32 gMonFrontPic_Jigglypuff[] = INCBIN_U32("graphics/pokemon/jigglypuff/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wigglytuff[] = INCBIN_U32("graphics/pokemon/wigglytuff/anim_front.4bpp.lz");
const u32 gMonFrontPic_Zubat[] = INCBIN_U32("graphics/pokemon/zubat/anim_front.4bpp.lz");
const u32 gMonFrontPic_Golbat[] = INCBIN_U32("graphics/pokemon/golbat/anim_front.4bpp.lz");
const u32 gMonFrontPic_Oddish[] = INCBIN_U32("graphics/pokemon/oddish/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gloom[] = INCBIN_U32("graphics/pokemon/gloom/anim_front.4bpp.lz");
const u32 gMonFrontPic_Vileplume[] = INCBIN_U32("graphics/pokemon/vileplume/anim_front.4bpp.lz");
const u32 gMonFrontPic_Paras[] = INCBIN_U32("graphics/pokemon/paras/anim_front.4bpp.lz");
const u32 gMonFrontPic_Parasect[] = INCBIN_U32("graphics/pokemon/parasect/anim_front.4bpp.lz");
const u32 gMonFrontPic_Venonat[] = INCBIN_U32("graphics/pokemon/venonat/anim_front.4bpp.lz");
const u32 gMonFrontPic_Venomoth[] = INCBIN_U32("graphics/pokemon/venomoth/anim_front.4bpp.lz");
const u32 gMonFrontPic_Diglett[] = INCBIN_U32("graphics/pokemon/diglett/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dugtrio[] = INCBIN_U32("graphics/pokemon/dugtrio/anim_front.4bpp.lz");
const u32 gMonFrontPic_Meowth[] = INCBIN_U32("graphics/pokemon/meowth/anim_front.4bpp.lz");
const u32 gMonFrontPic_Persian[] = INCBIN_U32("graphics/pokemon/persian/anim_front.4bpp.lz");
const u32 gMonFrontPic_Psyduck[] = INCBIN_U32("graphics/pokemon/psyduck/anim_front.4bpp.lz");
const u32 gMonFrontPic_Golduck[] = INCBIN_U32("graphics/pokemon/golduck/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mankey[] = INCBIN_U32("graphics/pokemon/mankey/anim_front.4bpp.lz");
const u32 gMonFrontPic_Primeape[] = INCBIN_U32("graphics/pokemon/primeape/anim_front.4bpp.lz");
const u32 gMonFrontPic_Growlithe[] = INCBIN_U32("graphics/pokemon/growlithe/anim_front.4bpp.lz");
const u32 gMonFrontPic_Arcanine[] = INCBIN_U32("graphics/pokemon/arcanine/anim_front.4bpp.lz");
const u32 gMonFrontPic_Poliwag[] = INCBIN_U32("graphics/pokemon/poliwag/anim_front.4bpp.lz");
const u32 gMonFrontPic_Poliwhirl[] = INCBIN_U32("graphics/pokemon/poliwhirl/anim_front.4bpp.lz");
const u32 gMonFrontPic_Poliwrath[] = INCBIN_U32("graphics/pokemon/poliwrath/anim_front.4bpp.lz");
const u32 gMonFrontPic_Abra[] = INCBIN_U32("graphics/pokemon/abra/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kadabra[] = INCBIN_U32("graphics/pokemon/kadabra/anim_front.4bpp.lz");
const u32 gMonFrontPic_Alakazam[] = INCBIN_U32("graphics/pokemon/alakazam/anim_front.4bpp.lz");
const u32 gMonFrontPic_Machop[] = INCBIN_U32("graphics/pokemon/machop/anim_front.4bpp.lz");
const u32 gMonFrontPic_Machoke[] = INCBIN_U32("graphics/pokemon/machoke/anim_front.4bpp.lz");
const u32 gMonFrontPic_Machamp[] = INCBIN_U32("graphics/pokemon/machamp/anim_front.4bpp.lz");
const u32 gMonFrontPic_Bellsprout[] = INCBIN_U32("graphics/pokemon/bellsprout/anim_front.4bpp.lz");
const u32 gMonFrontPic_Weepinbell[] = INCBIN_U32("graphics/pokemon/weepinbell/anim_front.4bpp.lz");
const u32 gMonFrontPic_Victreebel[] = INCBIN_U32("graphics/pokemon/victreebel/anim_front.4bpp.lz");
const u32 gMonFrontPic_Tentacool[] = INCBIN_U32("graphics/pokemon/tentacool/anim_front.4bpp.lz");
const u32 gMonFrontPic_Tentacruel[] = INCBIN_U32("graphics/pokemon/tentacruel/anim_front.4bpp.lz");
const u32 gMonFrontPic_Geodude[] = INCBIN_U32("graphics/pokemon/geodude/anim_front.4bpp.lz");
const u32 gMonFrontPic_Graveler[] = INCBIN_U32("graphics/pokemon/graveler/anim_front.4bpp.lz");
const u32 gMonFrontPic_Golem[] = INCBIN_U32("graphics/pokemon/golem/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ponyta[] = INCBIN_U32("graphics/pokemon/ponyta/anim_front.4bpp.lz");
const u32 gMonFrontPic_Rapidash[] = INCBIN_U32("graphics/pokemon/rapidash/anim_front.4bpp.lz");
const u32 gMonFrontPic_Slowpoke[] = INCBIN_U32("graphics/pokemon/slowpoke/anim_front.4bpp.lz");
const u32 gMonFrontPic_Slowbro[] = INCBIN_U32("graphics/pokemon/slowbro/anim_front.4bpp.lz");
const u32 gMonFrontPic_Magnemite[] = INCBIN_U32("graphics/pokemon/magnemite/anim_front.4bpp.lz");
const u32 gMonFrontPic_Magneton[] = INCBIN_U32("graphics/pokemon/magneton/anim_front.4bpp.lz");
const u32 gMonFrontPic_Farfetchd[] = INCBIN_U32("graphics/pokemon/farfetchd/anim_front.4bpp.lz");
const u32 gMonFrontPic_Doduo[] = INCBIN_U32("graphics/pokemon/doduo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dodrio[] = INCBIN_U32("graphics/pokemon/dodrio/anim_front.4bpp.lz");
const u32 gMonFrontPic_Seel[] = INCBIN_U32("graphics/pokemon/seel/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dewgong[] = INCBIN_U32("graphics/pokemon/dewgong/anim_front.4bpp.lz");
const u32 gMonFrontPic_Grimer[] = INCBIN_U32("graphics/pokemon/grimer/anim_front.4bpp.lz");
const u32 gMonFrontPic_Muk[] = INCBIN_U32("graphics/pokemon/muk/anim_front.4bpp.lz");
const u32 gMonFrontPic_Shellder[] = INCBIN_U32("graphics/pokemon/shellder/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cloyster[] = INCBIN_U32("graphics/pokemon/cloyster/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gastly[] = INCBIN_U32("graphics/pokemon/gastly/anim_front.4bpp.lz");
const u32 gMonFrontPic_Haunter[] = INCBIN_U32("graphics/pokemon/haunter/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gengar[] = INCBIN_U32("graphics/pokemon/gengar/anim_front.4bpp.lz");
const u32 gMonFrontPic_Onix[] = INCBIN_U32("graphics/pokemon/onix/anim_front.4bpp.lz");
const u32 gMonFrontPic_Drowzee[] = INCBIN_U32("graphics/pokemon/drowzee/anim_front.4bpp.lz");
const u32 gMonFrontPic_Hypno[] = INCBIN_U32("graphics/pokemon/hypno/anim_front.4bpp.lz");
const u32 gMonFrontPic_Krabby[] = INCBIN_U32("graphics/pokemon/krabby/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kingler[] = INCBIN_U32("graphics/pokemon/kingler/anim_front.4bpp.lz");
const u32 gMonFrontPic_Voltorb[] = INCBIN_U32("graphics/pokemon/voltorb/anim_front.4bpp.lz");
const u32 gMonFrontPic_Electrode[] = INCBIN_U32("graphics/pokemon/electrode/anim_front.4bpp.lz");
const u32 gMonFrontPic_Exeggcute[] = INCBIN_U32("graphics/pokemon/exeggcute/anim_front.4bpp.lz");
const u32 gMonFrontPic_Exeggutor[] = INCBIN_U32("graphics/pokemon/exeggutor/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cubone[] = INCBIN_U32("graphics/pokemon/cubone/anim_front.4bpp.lz");
const u32 gMonFrontPic_Marowak[] = INCBIN_U32("graphics/pokemon/marowak/anim_front.4bpp.lz");
const u32 gMonFrontPic_Hitmonlee[] = INCBIN_U32("graphics/pokemon/hitmonlee/anim_front.4bpp.lz");
const u32 gMonFrontPic_Hitmonchan[] = INCBIN_U32("graphics/pokemon/hitmonchan/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lickitung[] = INCBIN_U32("graphics/pokemon/lickitung/anim_front.4bpp.lz");
const u32 gMonFrontPic_Koffing[] = INCBIN_U32("graphics/pokemon/koffing/anim_front.4bpp.lz");
const u32 gMonFrontPic_Weezing[] = INCBIN_U32("graphics/pokemon/weezing/anim_front.4bpp.lz");
const u32 gMonFrontPic_Rhyhorn[] = INCBIN_U32("graphics/pokemon/rhyhorn/anim_front.4bpp.lz");
const u32 gMonFrontPic_Rhydon[] = INCBIN_U32("graphics/pokemon/rhydon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Chansey[] = INCBIN_U32("graphics/pokemon/chansey/anim_front.4bpp.lz");
const u32 gMonFrontPic_Tangela[] = INCBIN_U32("graphics/pokemon/tangela/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kangaskhan[] = INCBIN_U32("graphics/pokemon/kangaskhan/anim_front.4bpp.lz");
const u32 gMonFrontPic_Horsea[] = INCBIN_U32("graphics/pokemon/horsea/anim_front.4bpp.lz");
const u32 gMonFrontPic_Seadra[] = INCBIN_U32("graphics/pokemon/seadra/anim_front.4bpp.lz");
const u32 gMonFrontPic_Goldeen[] = INCBIN_U32("graphics/pokemon/goldeen/anim_front.4bpp.lz");
const u32 gMonFrontPic_Seaking[] = INCBIN_U32("graphics/pokemon/seaking/anim_front.4bpp.lz");
const u32 gMonFrontPic_Staryu[] = INCBIN_U32("graphics/pokemon/staryu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Starmie[] = INCBIN_U32("graphics/pokemon/starmie/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mrmime[] = INCBIN_U32("graphics/pokemon/mr_mime/anim_front.4bpp.lz");
const u32 gMonFrontPic_Scyther[] = INCBIN_U32("graphics/pokemon/scyther/anim_front.4bpp.lz");
const u32 gMonFrontPic_Jynx[] = INCBIN_U32("graphics/pokemon/jynx/anim_front.4bpp.lz");
const u32 gMonFrontPic_Electabuzz[] = INCBIN_U32("graphics/pokemon/electabuzz/anim_front.4bpp.lz");
const u32 gMonFrontPic_Magmar[] = INCBIN_U32("graphics/pokemon/magmar/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pinsir[] = INCBIN_U32("graphics/pokemon/pinsir/anim_front.4bpp.lz");
const u32 gMonFrontPic_Tauros[] = INCBIN_U32("graphics/pokemon/tauros/anim_front.4bpp.lz");
const u32 gMonFrontPic_Magikarp[] = INCBIN_U32("graphics/pokemon/magikarp/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gyarados[] = INCBIN_U32("graphics/pokemon/gyarados/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lapras[] = INCBIN_U32("graphics/pokemon/lapras/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ditto[] = INCBIN_U32("graphics/pokemon/ditto/anim_front.4bpp.lz");
const u32 gMonFrontPic_Eevee[] = INCBIN_U32("graphics/pokemon/eevee/anim_front.4bpp.lz");
const u32 gMonFrontPic_Vaporeon[] = INCBIN_U32("graphics/pokemon/vaporeon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Jolteon[] = INCBIN_U32("graphics/pokemon/jolteon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Flareon[] = INCBIN_U32("graphics/pokemon/flareon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Porygon[] = INCBIN_U32("graphics/pokemon/porygon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Omanyte[] = INCBIN_U32("graphics/pokemon/omanyte/anim_front.4bpp.lz");
const u32 gMonFrontPic_Omastar[] = INCBIN_U32("graphics/pokemon/omastar/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kabuto[] = INCBIN_U32("graphics/pokemon/kabuto/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kabutops[] = INCBIN_U32("graphics/pokemon/kabutops/anim_front.4bpp.lz");
const u32 gMonFrontPic_Aerodactyl[] = INCBIN_U32("graphics/pokemon/aerodactyl/anim_front.4bpp.lz");
const u32 gMonFrontPic_Snorlax[] = INCBIN_U32("graphics/pokemon/snorlax/anim_front.4bpp.lz");
const u32 gMonFrontPic_Articuno[] = INCBIN_U32("graphics/pokemon/articuno/anim_front.4bpp.lz");
const u32 gMonFrontPic_Zapdos[] = INCBIN_U32("graphics/pokemon/zapdos/anim_front.4bpp.lz");
const u32 gMonFrontPic_Moltres[] = INCBIN_U32("graphics/pokemon/moltres/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dratini[] = INCBIN_U32("graphics/pokemon/dratini/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dragonair[] = INCBIN_U32("graphics/pokemon/dragonair/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dragonite[] = INCBIN_U32("graphics/pokemon/dragonite/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mewtwo[] = INCBIN_U32("graphics/pokemon/mewtwo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mew[] = INCBIN_U32("graphics/pokemon/mew/anim_front.4bpp.lz");

const u32 gMonFrontPic_Chikorita[] = INCBIN_U32("graphics/pokemon/chikorita/anim_front.4bpp.lz");
const u32 gMonFrontPic_Bayleef[] = INCBIN_U32("graphics/pokemon/bayleef/anim_front.4bpp.lz");
const u32 gMonFrontPic_Meganium[] = INCBIN_U32("graphics/pokemon/meganium/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cyndaquil[] = INCBIN_U32("graphics/pokemon/cyndaquil/anim_front.4bpp.lz");
const u32 gMonFrontPic_Quilava[] = INCBIN_U32("graphics/pokemon/quilava/anim_front.4bpp.lz");
const u32 gMonFrontPic_Typhlosion[] = INCBIN_U32("graphics/pokemon/typhlosion/anim_front.4bpp.lz");
const u32 gMonFrontPic_Totodile[] = INCBIN_U32("graphics/pokemon/totodile/anim_front.4bpp.lz");
const u32 gMonFrontPic_Croconaw[] = INCBIN_U32("graphics/pokemon/croconaw/anim_front.4bpp.lz");
const u32 gMonFrontPic_Feraligatr[] = INCBIN_U32("graphics/pokemon/feraligatr/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sentret[] = INCBIN_U32("graphics/pokemon/sentret/anim_front.4bpp.lz");
const u32 gMonFrontPic_Furret[] = INCBIN_U32("graphics/pokemon/furret/anim_front.4bpp.lz");
const u32 gMonFrontPic_Hoothoot[] = INCBIN_U32("graphics/pokemon/hoothoot/anim_front.4bpp.lz");
const u32 gMonFrontPic_Noctowl[] = INCBIN_U32("graphics/pokemon/noctowl/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ledyba[] = INCBIN_U32("graphics/pokemon/ledyba/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ledian[] = INCBIN_U32("graphics/pokemon/ledian/anim_front.4bpp.lz");
const u32 gMonFrontPic_Spinarak[] = INCBIN_U32("graphics/pokemon/spinarak/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ariados[] = INCBIN_U32("graphics/pokemon/ariados/anim_front.4bpp.lz");
const u32 gMonFrontPic_Crobat[] = INCBIN_U32("graphics/pokemon/crobat/anim_front.4bpp.lz");
const u32 gMonFrontPic_Chinchou[] = INCBIN_U32("graphics/pokemon/chinchou/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lanturn[] = INCBIN_U32("graphics/pokemon/lanturn/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pichu[] = INCBIN_U32("graphics/pokemon/pichu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cleffa[] = INCBIN_U32("graphics/pokemon/cleffa/anim_front.4bpp.lz");
const u32 gMonFrontPic_Igglybuff[] = INCBIN_U32("graphics/pokemon/igglybuff/anim_front.4bpp.lz");
const u32 gMonFrontPic_Togepi[] = INCBIN_U32("graphics/pokemon/togepi/anim_front.4bpp.lz");
const u32 gMonFrontPic_Togetic[] = INCBIN_U32("graphics/pokemon/togetic/anim_front.4bpp.lz");
const u32 gMonFrontPic_Natu[] = INCBIN_U32("graphics/pokemon/natu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Xatu[] = INCBIN_U32("graphics/pokemon/xatu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mareep[] = INCBIN_U32("graphics/pokemon/mareep/anim_front.4bpp.lz");
const u32 gMonFrontPic_Flaaffy[] = INCBIN_U32("graphics/pokemon/flaaffy/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ampharos[] = INCBIN_U32("graphics/pokemon/ampharos/anim_front.4bpp.lz");
const u32 gMonFrontPic_Bellossom[] = INCBIN_U32("graphics/pokemon/bellossom/anim_front.4bpp.lz");
const u32 gMonFrontPic_Marill[] = INCBIN_U32("graphics/pokemon/marill/anim_front.4bpp.lz");
const u32 gMonFrontPic_Azumarill[] = INCBIN_U32("graphics/pokemon/azumarill/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sudowoodo[] = INCBIN_U32("graphics/pokemon/sudowoodo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Politoed[] = INCBIN_U32("graphics/pokemon/politoed/anim_front.4bpp.lz");
const u32 gMonFrontPic_Hoppip[] = INCBIN_U32("graphics/pokemon/hoppip/anim_front.4bpp.lz");
const u32 gMonFrontPic_Skiploom[] = INCBIN_U32("graphics/pokemon/skiploom/anim_front.4bpp.lz");
const u32 gMonFrontPic_Jumpluff[] = INCBIN_U32("graphics/pokemon/jumpluff/anim_front.4bpp.lz");
const u32 gMonFrontPic_Aipom[] = INCBIN_U32("graphics/pokemon/aipom/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sunkern[] = INCBIN_U32("graphics/pokemon/sunkern/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sunflora[] = INCBIN_U32("graphics/pokemon/sunflora/anim_front.4bpp.lz");
const u32 gMonFrontPic_Yanma[] = INCBIN_U32("graphics/pokemon/yanma/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wooper[] = INCBIN_U32("graphics/pokemon/wooper/anim_front.4bpp.lz");
const u32 gMonFrontPic_Quagsire[] = INCBIN_U32("graphics/pokemon/quagsire/anim_front.4bpp.lz");
const u32 gMonFrontPic_Espeon[] = INCBIN_U32("graphics/pokemon/espeon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Umbreon[] = INCBIN_U32("graphics/pokemon/umbreon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Murkrow[] = INCBIN_U32("graphics/pokemon/murkrow/anim_front.4bpp.lz");
const u32 gMonFrontPic_Slowking[] = INCBIN_U32("graphics/pokemon/slowking/anim_front.4bpp.lz");
const u32 gMonFrontPic_Misdreavus[] = INCBIN_U32("graphics/pokemon/misdreavus/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownA[] = INCBIN_U32("graphics/pokemon/unown/a/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wobbuffet[] = INCBIN_U32("graphics/pokemon/wobbuffet/anim_front.4bpp.lz");
const u32 gMonFrontPic_Girafarig[] = INCBIN_U32("graphics/pokemon/girafarig/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pineco[] = INCBIN_U32("graphics/pokemon/pineco/anim_front.4bpp.lz");
const u32 gMonFrontPic_Forretress[] = INCBIN_U32("graphics/pokemon/forretress/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dunsparce[] = INCBIN_U32("graphics/pokemon/dunsparce/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gligar[] = INCBIN_U32("graphics/pokemon/gligar/anim_front.4bpp.lz");
const u32 gMonFrontPic_Steelix[] = INCBIN_U32("graphics/pokemon/steelix/anim_front.4bpp.lz");
const u32 gMonFrontPic_Snubbull[] = INCBIN_U32("graphics/pokemon/snubbull/anim_front.4bpp.lz");
const u32 gMonFrontPic_Granbull[] = INCBIN_U32("graphics/pokemon/granbull/anim_front.4bpp.lz");
const u32 gMonFrontPic_Qwilfish[] = INCBIN_U32("graphics/pokemon/qwilfish/anim_front.4bpp.lz");
const u32 gMonFrontPic_Scizor[] = INCBIN_U32("graphics/pokemon/scizor/anim_front.4bpp.lz");
const u32 gMonFrontPic_Shuckle[] = INCBIN_U32("graphics/pokemon/shuckle/anim_front.4bpp.lz");
const u32 gMonFrontPic_Heracross[] = INCBIN_U32("graphics/pokemon/heracross/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sneasel[] = INCBIN_U32("graphics/pokemon/sneasel/anim_front.4bpp.lz");
const u32 gMonFrontPic_Teddiursa[] = INCBIN_U32("graphics/pokemon/teddiursa/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ursaring[] = INCBIN_U32("graphics/pokemon/ursaring/anim_front.4bpp.lz");
const u32 gMonFrontPic_Slugma[] = INCBIN_U32("graphics/pokemon/slugma/anim_front.4bpp.lz");
const u32 gMonFrontPic_Magcargo[] = INCBIN_U32("graphics/pokemon/magcargo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Swinub[] = INCBIN_U32("graphics/pokemon/swinub/anim_front.4bpp.lz");
const u32 gMonFrontPic_Piloswine[] = INCBIN_U32("graphics/pokemon/piloswine/anim_front.4bpp.lz");
const u32 gMonFrontPic_Corsola[] = INCBIN_U32("graphics/pokemon/corsola/anim_front.4bpp.lz");
const u32 gMonFrontPic_Remoraid[] = INCBIN_U32("graphics/pokemon/remoraid/anim_front.4bpp.lz");
const u32 gMonFrontPic_Octillery[] = INCBIN_U32("graphics/pokemon/octillery/anim_front.4bpp.lz");
const u32 gMonFrontPic_Delibird[] = INCBIN_U32("graphics/pokemon/delibird/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mantine[] = INCBIN_U32("graphics/pokemon/mantine/anim_front.4bpp.lz");
const u32 gMonFrontPic_Skarmory[] = INCBIN_U32("graphics/pokemon/skarmory/anim_front.4bpp.lz");
const u32 gMonFrontPic_Houndour[] = INCBIN_U32("graphics/pokemon/houndour/anim_front.4bpp.lz");
const u32 gMonFrontPic_Houndoom[] = INCBIN_U32("graphics/pokemon/houndoom/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kingdra[] = INCBIN_U32("graphics/pokemon/kingdra/anim_front.4bpp.lz");
const u32 gMonFrontPic_Phanpy[] = INCBIN_U32("graphics/pokemon/phanpy/anim_front.4bpp.lz");
const u32 gMonFrontPic_Donphan[] = INCBIN_U32("graphics/pokemon/donphan/anim_front.4bpp.lz");
const u32 gMonFrontPic_Porygon2[] = INCBIN_U32("graphics/pokemon/porygon2/anim_front.4bpp.lz");
const u32 gMonFrontPic_Stantler[] = INCBIN_U32("graphics/pokemon/stantler/anim_front.4bpp.lz");
const u32 gMonFrontPic_Smeargle[] = INCBIN_U32("graphics/pokemon/smeargle/anim_front.4bpp.lz");
const u32 gMonFrontPic_Tyrogue[] = INCBIN_U32("graphics/pokemon/tyrogue/anim_front.4bpp.lz");
const u32 gMonFrontPic_Hitmontop[] = INCBIN_U32("graphics/pokemon/hitmontop/anim_front.4bpp.lz");
const u32 gMonFrontPic_Smoochum[] = INCBIN_U32("graphics/pokemon/smoochum/anim_front.4bpp.lz");
const u32 gMonFrontPic_Elekid[] = INCBIN_U32("graphics/pokemon/elekid/anim_front.4bpp.lz");
const u32 gMonFrontPic_Magby[] = INCBIN_U32("graphics/pokemon/magby/anim_front.4bpp.lz");
const u32 gMonFrontPic_Miltank[] = INCBIN_U32("graphics/pokemon/miltank/anim_front.4bpp.lz");
const u32 gMonFrontPic_Blissey[] = INCBIN_U32("graphics/pokemon/blissey/anim_front.4bpp.lz");
const u32 gMonFrontPic_Raikou[] = INCBIN_U32("graphics/pokemon/raikou/anim_front.4bpp.lz");
const u32 gMonFrontPic_Entei[] = INCBIN_U32("graphics/pokemon/entei/anim_front.4bpp.lz");
const u32 gMonFrontPic_Suicune[] = INCBIN_U32("graphics/pokemon/suicune/anim_front.4bpp.lz");
const u32 gMonFrontPic_Larvitar[] = INCBIN_U32("graphics/pokemon/larvitar/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pupitar[] = INCBIN_U32("graphics/pokemon/pupitar/anim_front.4bpp.lz");
const u32 gMonFrontPic_Tyranitar[] = INCBIN_U32("graphics/pokemon/tyranitar/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lugia[] = INCBIN_U32("graphics/pokemon/lugia/anim_front.4bpp.lz");
const u32 gMonFrontPic_HoOh[] = INCBIN_U32("graphics/pokemon/ho_oh/anim_front.4bpp.lz");
const u32 gMonFrontPic_Celebi[] = INCBIN_U32("graphics/pokemon/celebi/anim_front.4bpp.lz");

const u32 gMonFrontPic_DoubleQuestionMark[] = INCBIN_U32("graphics/pokemon/question_mark/double/anim_front.4bpp.lz");

const u32 gMonFrontPic_Treecko[] = INCBIN_U32("graphics/pokemon/treecko/anim_front.4bpp.lz");
const u32 gMonFrontPic_Grovyle[] = INCBIN_U32("graphics/pokemon/grovyle/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sceptile[] = INCBIN_U32("graphics/pokemon/sceptile/anim_front.4bpp.lz");
const u32 gMonFrontPic_Torchic[] = INCBIN_U32("graphics/pokemon/torchic/anim_front.4bpp.lz");
const u32 gMonFrontPic_Combusken[] = INCBIN_U32("graphics/pokemon/combusken/anim_front.4bpp.lz");
const u32 gMonFrontPic_Blaziken[] = INCBIN_U32("graphics/pokemon/blaziken/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mudkip[] = INCBIN_U32("graphics/pokemon/mudkip/anim_front.4bpp.lz");
const u32 gMonFrontPic_Marshtomp[] = INCBIN_U32("graphics/pokemon/marshtomp/anim_front.4bpp.lz");
const u32 gMonFrontPic_Swampert[] = INCBIN_U32("graphics/pokemon/swampert/anim_front.4bpp.lz");
const u32 gMonFrontPic_Poochyena[] = INCBIN_U32("graphics/pokemon/poochyena/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mightyena[] = INCBIN_U32("graphics/pokemon/mightyena/anim_front.4bpp.lz");
const u32 gMonFrontPic_Zigzagoon[] = INCBIN_U32("graphics/pokemon/zigzagoon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Linoone[] = INCBIN_U32("graphics/pokemon/linoone/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wurmple[] = INCBIN_U32("graphics/pokemon/wurmple/anim_front.4bpp.lz");
const u32 gMonFrontPic_Silcoon[] = INCBIN_U32("graphics/pokemon/silcoon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Beautifly[] = INCBIN_U32("graphics/pokemon/beautifly/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cascoon[] = INCBIN_U32("graphics/pokemon/cascoon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dustox[] = INCBIN_U32("graphics/pokemon/dustox/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lotad[] = INCBIN_U32("graphics/pokemon/lotad/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lombre[] = INCBIN_U32("graphics/pokemon/lombre/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ludicolo[] = INCBIN_U32("graphics/pokemon/ludicolo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Seedot[] = INCBIN_U32("graphics/pokemon/seedot/anim_front.4bpp.lz");
const u32 gMonFrontPic_Nuzleaf[] = INCBIN_U32("graphics/pokemon/nuzleaf/anim_front.4bpp.lz");
const u32 gMonFrontPic_Shiftry[] = INCBIN_U32("graphics/pokemon/shiftry/anim_front.4bpp.lz");
const u32 gMonFrontPic_Nincada[] = INCBIN_U32("graphics/pokemon/nincada/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ninjask[] = INCBIN_U32("graphics/pokemon/ninjask/anim_front.4bpp.lz");
const u32 gMonFrontPic_Shedinja[] = INCBIN_U32("graphics/pokemon/shedinja/anim_front.4bpp.lz");
const u32 gMonFrontPic_Taillow[] = INCBIN_U32("graphics/pokemon/taillow/anim_front.4bpp.lz");
const u32 gMonFrontPic_Swellow[] = INCBIN_U32("graphics/pokemon/swellow/anim_front.4bpp.lz");
const u32 gMonFrontPic_Shroomish[] = INCBIN_U32("graphics/pokemon/shroomish/anim_front.4bpp.lz");
const u32 gMonFrontPic_Breloom[] = INCBIN_U32("graphics/pokemon/breloom/anim_front.4bpp.lz");
const u32 gMonFrontPic_Spinda[] = INCBIN_U32("graphics/pokemon/spinda/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wingull[] = INCBIN_U32("graphics/pokemon/wingull/anim_front.4bpp.lz");
const u32 gMonFrontPic_Pelipper[] = INCBIN_U32("graphics/pokemon/pelipper/anim_front.4bpp.lz");
const u32 gMonFrontPic_Surskit[] = INCBIN_U32("graphics/pokemon/surskit/anim_front.4bpp.lz");
const u32 gMonFrontPic_Masquerain[] = INCBIN_U32("graphics/pokemon/masquerain/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wailmer[] = INCBIN_U32("graphics/pokemon/wailmer/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wailord[] = INCBIN_U32("graphics/pokemon/wailord/anim_front.4bpp.lz");
const u32 gMonFrontPic_Skitty[] = INCBIN_U32("graphics/pokemon/skitty/anim_front.4bpp.lz");
const u32 gMonFrontPic_Delcatty[] = INCBIN_U32("graphics/pokemon/delcatty/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kecleon[] = INCBIN_U32("graphics/pokemon/kecleon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Baltoy[] = INCBIN_U32("graphics/pokemon/baltoy/anim_front.4bpp.lz");
const u32 gMonFrontPic_Claydol[] = INCBIN_U32("graphics/pokemon/claydol/anim_front.4bpp.lz");
const u32 gMonFrontPic_Nosepass[] = INCBIN_U32("graphics/pokemon/nosepass/anim_front.4bpp.lz");
const u32 gMonFrontPic_Torkoal[] = INCBIN_U32("graphics/pokemon/torkoal/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sableye[] = INCBIN_U32("graphics/pokemon/sableye/anim_front.4bpp.lz");
const u32 gMonFrontPic_Barboach[] = INCBIN_U32("graphics/pokemon/barboach/anim_front.4bpp.lz");
const u32 gMonFrontPic_Whiscash[] = INCBIN_U32("graphics/pokemon/whiscash/anim_front.4bpp.lz");
const u32 gMonFrontPic_Luvdisc[] = INCBIN_U32("graphics/pokemon/luvdisc/anim_front.4bpp.lz");
const u32 gMonFrontPic_Corphish[] = INCBIN_U32("graphics/pokemon/corphish/anim_front.4bpp.lz");
const u32 gMonFrontPic_Crawdaunt[] = INCBIN_U32("graphics/pokemon/crawdaunt/anim_front.4bpp.lz");
const u32 gMonFrontPic_Feebas[] = INCBIN_U32("graphics/pokemon/feebas/anim_front.4bpp.lz");
const u32 gMonFrontPic_Milotic[] = INCBIN_U32("graphics/pokemon/milotic/anim_front.4bpp.lz");
const u32 gMonFrontPic_Carvanha[] = INCBIN_U32("graphics/pokemon/carvanha/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sharpedo[] = INCBIN_U32("graphics/pokemon/sharpedo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Trapinch[] = INCBIN_U32("graphics/pokemon/trapinch/anim_front.4bpp.lz");
const u32 gMonFrontPic_Vibrava[] = INCBIN_U32("graphics/pokemon/vibrava/anim_front.4bpp.lz");
const u32 gMonFrontPic_Flygon[] = INCBIN_U32("graphics/pokemon/flygon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Makuhita[] = INCBIN_U32("graphics/pokemon/makuhita/anim_front.4bpp.lz");
const u32 gMonFrontPic_Hariyama[] = INCBIN_U32("graphics/pokemon/hariyama/anim_front.4bpp.lz");
const u32 gMonFrontPic_Electrike[] = INCBIN_U32("graphics/pokemon/electrike/anim_front.4bpp.lz");
const u32 gMonFrontPic_Manectric[] = INCBIN_U32("graphics/pokemon/manectric/anim_front.4bpp.lz");
const u32 gMonFrontPic_Numel[] = INCBIN_U32("graphics/pokemon/numel/anim_front.4bpp.lz");
const u32 gMonFrontPic_Camerupt[] = INCBIN_U32("graphics/pokemon/camerupt/anim_front.4bpp.lz");
const u32 gMonFrontPic_Spheal[] = INCBIN_U32("graphics/pokemon/spheal/anim_front.4bpp.lz");
const u32 gMonFrontPic_Sealeo[] = INCBIN_U32("graphics/pokemon/sealeo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Walrein[] = INCBIN_U32("graphics/pokemon/walrein/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cacnea[] = INCBIN_U32("graphics/pokemon/cacnea/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cacturne[] = INCBIN_U32("graphics/pokemon/cacturne/anim_front.4bpp.lz");
const u32 gMonFrontPic_Snorunt[] = INCBIN_U32("graphics/pokemon/snorunt/anim_front.4bpp.lz");
const u32 gMonFrontPic_Glalie[] = INCBIN_U32("graphics/pokemon/glalie/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lunatone[] = INCBIN_U32("graphics/pokemon/lunatone/anim_front.4bpp.lz");
const u32 gMonFrontPic_Solrock[] = INCBIN_U32("graphics/pokemon/solrock/anim_front.4bpp.lz");
const u32 gMonFrontPic_Azurill[] = INCBIN_U32("graphics/pokemon/azurill/anim_front.4bpp.lz");
const u32 gMonFrontPic_Spoink[] = INCBIN_U32("graphics/pokemon/spoink/anim_front.4bpp.lz");
const u32 gMonFrontPic_Grumpig[] = INCBIN_U32("graphics/pokemon/grumpig/anim_front.4bpp.lz");
const u32 gMonFrontPic_Plusle[] = INCBIN_U32("graphics/pokemon/plusle/anim_front.4bpp.lz");
const u32 gMonFrontPic_Minun[] = INCBIN_U32("graphics/pokemon/minun/anim_front.4bpp.lz");
const u32 gMonFrontPic_Mawile[] = INCBIN_U32("graphics/pokemon/mawile/anim_front.4bpp.lz");
const u32 gMonFrontPic_Meditite[] = INCBIN_U32("graphics/pokemon/meditite/anim_front.4bpp.lz");
const u32 gMonFrontPic_Medicham[] = INCBIN_U32("graphics/pokemon/medicham/anim_front.4bpp.lz");
const u32 gMonFrontPic_Swablu[] = INCBIN_U32("graphics/pokemon/swablu/anim_front.4bpp.lz");
const u32 gMonFrontPic_Altaria[] = INCBIN_U32("graphics/pokemon/altaria/anim_front.4bpp.lz");
const u32 gMonFrontPic_Wynaut[] = INCBIN_U32("graphics/pokemon/wynaut/anim_front.4bpp.lz");
const u32 gMonFrontPic_Duskull[] = INCBIN_U32("graphics/pokemon/duskull/anim_front.4bpp.lz");
const u32 gMonFrontPic_Dusclops[] = INCBIN_U32("graphics/pokemon/dusclops/anim_front.4bpp.lz");
const u32 gMonFrontPic_Roselia[] = INCBIN_U32("graphics/pokemon/roselia/anim_front.4bpp.lz");
const u32 gMonFrontPic_Slakoth[] = INCBIN_U32("graphics/pokemon/slakoth/anim_front.4bpp.lz");
const u32 gMonFrontPic_Vigoroth[] = INCBIN_U32("graphics/pokemon/vigoroth/anim_front.4bpp.lz");
const u32 gMonFrontPic_Slaking[] = INCBIN_U32("graphics/pokemon/slaking/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gulpin[] = INCBIN_U32("graphics/pokemon/gulpin/anim_front.4bpp.lz");
const u32 gMonFrontPic_Swalot[] = INCBIN_U32("graphics/pokemon/swalot/anim_front.4bpp.lz");
const u32 gMonFrontPic_Tropius[] = INCBIN_U32("graphics/pokemon/tropius/anim_front.4bpp.lz");
const u32 gMonFrontPic_Whismur[] = INCBIN_U32("graphics/pokemon/whismur/anim_front.4bpp.lz");
const u32 gMonFrontPic_Loudred[] = INCBIN_U32("graphics/pokemon/loudred/anim_front.4bpp.lz");
const u32 gMonFrontPic_Exploud[] = INCBIN_U32("graphics/pokemon/exploud/anim_front.4bpp.lz");
const u32 gMonFrontPic_Clamperl[] = INCBIN_U32("graphics/pokemon/clamperl/anim_front.4bpp.lz");
const u32 gMonFrontPic_Huntail[] = INCBIN_U32("graphics/pokemon/huntail/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gorebyss[] = INCBIN_U32("graphics/pokemon/gorebyss/anim_front.4bpp.lz");
const u32 gMonFrontPic_Absol[] = INCBIN_U32("graphics/pokemon/absol/anim_front.4bpp.lz");
const u32 gMonFrontPic_Shuppet[] = INCBIN_U32("graphics/pokemon/shuppet/anim_front.4bpp.lz");
const u32 gMonFrontPic_Banette[] = INCBIN_U32("graphics/pokemon/banette/anim_front.4bpp.lz");
const u32 gMonFrontPic_Seviper[] = INCBIN_U32("graphics/pokemon/seviper/anim_front.4bpp.lz");
const u32 gMonFrontPic_Zangoose[] = INCBIN_U32("graphics/pokemon/zangoose/anim_front.4bpp.lz");
const u32 gMonFrontPic_Relicanth[] = INCBIN_U32("graphics/pokemon/relicanth/anim_front.4bpp.lz");
const u32 gMonFrontPic_Aron[] = INCBIN_U32("graphics/pokemon/aron/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lairon[] = INCBIN_U32("graphics/pokemon/lairon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Aggron[] = INCBIN_U32("graphics/pokemon/aggron/anim_front.4bpp.lz");
const u32 gMonFrontPic_Castform[] = INCBIN_U32("graphics/pokemon/castform/anim_front.4bpp.lz");
const u32 gMonFrontPic_Volbeat[] = INCBIN_U32("graphics/pokemon/volbeat/anim_front.4bpp.lz");
const u32 gMonFrontPic_Illumise[] = INCBIN_U32("graphics/pokemon/illumise/anim_front.4bpp.lz");
const u32 gMonFrontPic_Lileep[] = INCBIN_U32("graphics/pokemon/lileep/anim_front.4bpp.lz");
const u32 gMonFrontPic_Cradily[] = INCBIN_U32("graphics/pokemon/cradily/anim_front.4bpp.lz");
const u32 gMonFrontPic_Anorith[] = INCBIN_U32("graphics/pokemon/anorith/anim_front.4bpp.lz");
const u32 gMonFrontPic_Armaldo[] = INCBIN_U32("graphics/pokemon/armaldo/anim_front.4bpp.lz");
const u32 gMonFrontPic_Ralts[] = INCBIN_U32("graphics/pokemon/ralts/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kirlia[] = INCBIN_U32("graphics/pokemon/kirlia/anim_front.4bpp.lz");
const u32 gMonFrontPic_Gardevoir[] = INCBIN_U32("graphics/pokemon/gardevoir/anim_front.4bpp.lz");
const u32 gMonFrontPic_Bagon[] = INCBIN_U32("graphics/pokemon/bagon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Shelgon[] = INCBIN_U32("graphics/pokemon/shelgon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Salamence[] = INCBIN_U32("graphics/pokemon/salamence/anim_front.4bpp.lz");
const u32 gMonFrontPic_Beldum[] = INCBIN_U32("graphics/pokemon/beldum/anim_front.4bpp.lz");
const u32 gMonFrontPic_Metang[] = INCBIN_U32("graphics/pokemon/metang/anim_front.4bpp.lz");
const u32 gMonFrontPic_Metagross[] = INCBIN_U32("graphics/pokemon/metagross/anim_front.4bpp.lz");
const u32 gMonFrontPic_Regirock[] = INCBIN_U32("graphics/pokemon/regirock/anim_front.4bpp.lz");
const u32 gMonFrontPic_Regice[] = INCBIN_U32("graphics/pokemon/regice/anim_front.4bpp.lz");
const u32 gMonFrontPic_Registeel[] = INCBIN_U32("graphics/pokemon/registeel/anim_front.4bpp.lz");
const u32 gMonFrontPic_Kyogre[] = INCBIN_U32("graphics/pokemon/kyogre/anim_front.4bpp.lz");
const u32 gMonFrontPic_Groudon[] = INCBIN_U32("graphics/pokemon/groudon/anim_front.4bpp.lz");
const u32 gMonFrontPic_Rayquaza[] = INCBIN_U32("graphics/pokemon/rayquaza/anim_front.4bpp.lz");
const u32 gMonFrontPic_Latias[] = INCBIN_U32("graphics/pokemon/latias/anim_front.4bpp.lz");
const u32 gMonFrontPic_Latios[] = INCBIN_U32("graphics/pokemon/latios/anim_front.4bpp.lz");
const u32 gMonFrontPic_Jirachi[] = INCBIN_U32("graphics/pokemon/jirachi/anim_front.4bpp.lz");
const u32 gMonFrontPic_Deoxys[] = INCBIN_U32("graphics/pokemon/deoxys/anim_front.4bpp.lz");
const u32 gMonFrontPic_Chimecho[] = INCBIN_U32("graphics/pokemon/chimecho/anim_front.4bpp.lz");

const u32 gMonFrontPic_Egg[] = INCBIN_U32("graphics/pokemon/egg/anim_front.4bpp.lz");

const u32 gMonFrontPic_UnownB[] = INCBIN_U32("graphics/pokemon/unown/b/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownC[] = INCBIN_U32("graphics/pokemon/unown/c/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownD[] = INCBIN_U32("graphics/pokemon/unown/d/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownE[] = INCBIN_U32("graphics/pokemon/unown/e/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownF[] = INCBIN_U32("graphics/pokemon/unown/f/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownG[] = INCBIN_U32("graphics/pokemon/unown/g/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownH[] = INCBIN_U32("graphics/pokemon/unown/h/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownI[] = INCBIN_U32("graphics/pokemon/unown/i/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownJ[] = INCBIN_U32("graphics/pokemon/unown/j/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownK[] = INCBIN_U32("graphics/pokemon/unown/k/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownL[] = INCBIN_U32("graphics/pokemon/unown/l/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownM[] = INCBIN_U32("graphics/pokemon/unown/m/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownN[] = INCBIN_U32("graphics/pokemon/unown/n/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownO[] = INCBIN_U32("graphics/pokemon/unown/o/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownP[] = INCBIN_U32("graphics/pokemon/unown/p/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownQ[] = INCBIN_U32("graphics/pokemon/unown/q/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownR[] = INCBIN_U32("graphics/pokemon/unown/r/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownS[] = INCBIN_U32("graphics/pokemon/unown/s/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownT[] = INCBIN_U32("graphics/pokemon/unown/t/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownU[] = INCBIN_U32("graphics/pokemon/unown/u/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownV[] = INCBIN_U32("graphics/pokemon/unown/v/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownW[] = INCBIN_U32("graphics/pokemon/unown/w/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownX[] = INCBIN_U32("graphics/pokemon/unown/x/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownY[] = INCBIN_U32("graphics/pokemon/unown/y/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownZ[] = INCBIN_U32("graphics/pokemon/unown/z/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownExclamationMark[] = INCBIN_U32("graphics/pokemon/unown/exclamation_mark/anim_front.4bpp.lz");
const u32 gMonFrontPic_UnownQuestionMark[] = INCBIN_U32("graphics/pokemon/unown/question_mark/anim_front.4bpp.lz");