/*---------------------------------------------------------------------------* Project: WiiConnect24 API demos File: MsgViewerUpdate.c Copyright 2006 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: MsgViewerUpdate.c,v $ Revision 1.2 2007/02/02 02:20:46 torigoe_nobutaka Added handling of message without subject or body text. Revision 1.1 2006/09/27 08:58:21 torigoe_nobutaka Renamed from update.c Moved from nwc24demo/src. Revision 1.2 2006/09/27 07:31:45 torigoe_nobutaka Improved performance. Revision 1.1 2006/08/28 08:51:50 torigoe_nobutaka Initial check in. $NoKeywords: $ *---------------------------------------------------------------------------*/ #include #include #include #include #include #include #include "MsgViewerUpdate.h" #include "MsgViewer.h" /*---------------------------------------------------------------------------* Local functions *---------------------------------------------------------------------------*/ static BOOL GetMsgData ( MsgData* msgData, NWC24MsgBoxId mBoxId, u32 msgId ); static void ReceiveMessage ( void ); static void PostMessage ( void ); static void CreateMessage ( NWC24MsgBoxId mBoxId ); static void UpdateMenu ( const KPADStatus* input ); static void UpdateRecvBox ( const KPADStatus* input ); static void UpdateSendBox ( const KPADStatus* input ); static void UpdateMsgContent ( const KPADStatus* input ); static void UpdateDeleteMsg ( const KPADStatus* input ); static void UpdateBeforeRecvMsg( const KPADStatus* input ); static void UpdateBeforePostMsg( const KPADStatus* input ); static void UpdateDoneRecvMsg ( const KPADStatus* input ); static void UpdateDonePostMsg ( const KPADStatus* input ); /*---------------------------------------------------------------------------* Name: Render Description: Performs scene update processing other than rendering. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ void Update( const KPADStatus* input ) { switch ( g_state ) { case MB_STATE_MENU: UpdateMenu( input ); break; case MB_STATE_RECV_BOX: UpdateRecvBox( input ); break; case MB_STATE_SEND_BOX: UpdateSendBox( input ); break; case MB_STATE_MSG_CONTENT: UpdateMsgContent( input ); break; case MB_STATE_DELETE_MSG: UpdateDeleteMsg( input ); break; case MB_STATE_BEFORE_RECV_MSG: UpdateBeforeRecvMsg( input ); break; case MB_STATE_BEFORE_POST_MSG: UpdateBeforePostMsg( input ); break; case MB_STATE_DONE_RECV_MSG: UpdateDoneRecvMsg( input ); break; case MB_STATE_DONE_POST_MSG: UpdateDonePostMsg( input ); break; } return; } /*---------------------------------------------------------------------------* Name: GetMsgData Description: Obtains the data from the specified message. Arguments: msgData - Pointer to the MsgData type structure that stores the message data. mBoxId - Message box type. msgId - Message ID. Returns: BOOL - TRUE if successful. *---------------------------------------------------------------------------*/ static BOOL GetMsgData( MsgData* msgData, NWC24MsgBoxId mBoxId, u32 msgId ) { NWC24Err err; NWC24MsgObj msgObj; u32 subjectSize; char* subject; u32 textSize; char* text; NWC24Charset charset; NWC24Encoding encoding; MsgBoxType mbType = (mBoxId == NWC24_RECV_BOX) ? MB_TYPE_RECV : MB_TYPE_SEND; err = NWC24GetMsgObj( &msgObj, mBoxId, msgId ); if ( err == NWC24_ERR_HIDDEN ) { return FALSE; } CheckError( "NWC24InitMsgObj()", err ); /* Message type */ err = NWC24GetMsgType( &msgObj, &msgData->type ); CheckError( "NWC24GetMsgType()", err ); /* Number of recipients */ err = NWC24GetMsgNumTo( &msgObj, &msgData->numTo ); CheckError( "NWC24GetMsgNumTo()", err ); if ( MAX_NUM_TO < msgData->numTo ) { msgData->numTo = MAX_NUM_TO; } /* Subject Line */ err = NWC24GetMsgSubjectSize( &msgObj, &subjectSize ); CheckError( "NWC24GetMsgSubjectSize()", err ); if ( subjectSize < 1 ) { subjectSize = 1; } subject = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); err = NWC24ReadMsgSubject( &msgObj, subject, subjectSize ); if ( err != NWC24_OK ) { subject[0] = '\0'; } if ( MAX_SUBJECT_SIZE < subjectSize ) { subjectSize = MAX_SUBJECT_SIZE; } (void)memcpy( msgData->subject, subject, subjectSize ); msgData->subject[subjectSize] = '\0'; MEMFreeToAllocator( &DemoAllocator1, subject ); /* Text */ err = NWC24GetMsgTextSize( &msgObj, &textSize ); CheckError( "NWC24GetMsgTextSize()", err ); if ( textSize < 1 ) { textSize = 1; } text = MEMAllocFromAllocator( &DemoAllocator1, textSize ); err = NWC24ReadMsgText( &msgObj, text, textSize, &charset, &encoding ); if ( err != NWC24_OK ) { text[0] = '\0'; } if ( MAX_TEXT_SIZE < textSize ) { textSize = MAX_TEXT_SIZE; } (void)memcpy( msgData->text, text, textSize ); msgData->text[textSize] = '\0'; MEMFreeToAllocator( &DemoAllocator1, text ); /* Sender/recipient */ if ( msgData->type != NWC24_MSGTYPE_PUBLIC ) { NWC24UserId temp; u32 i; err = NWC24GetMsgFromId( &msgObj, &temp ); CheckError( "NWC24GetMsgFromId()", err ); (void)sprintf( msgData->from, "%016llu", temp ); for ( i = 0; i < msgData->numTo; ++i ) { err = NWC24ReadMsgToId( &msgObj, i, &temp ); CheckError( "NWC24ReadMsgToId()", err ); (void)sprintf( msgData->to[i], "%016llu", temp ); } } else { u32 i; err = NWC24ReadMsgFromAddr( &msgObj, msgData->from, MAX_ADDR_SIZE ); CheckError( "NWC24ReadMsgFromAddr()", err ); for ( i = 0; i < msgData->numTo; ++i ) { err = NWC24ReadMsgToAddr( &msgObj, i, msgData->to[i], MAX_ADDR_SIZE ); CheckError( "NWC24ReadMsgToAddr()", err ); } } return TRUE; } /*---------------------------------------------------------------------------* Name: ReceiveMessage Description: Creates a Wii message and stores it in the Inbox. Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ static void ReceiveMessage( void ) { CreateMessage( NWC24_RECV_BOX ); ReleaseMsgIdList( NWC24_RECV_BOX ); GetMsgIdList( NWC24_RECV_BOX ); ReleaseListedSubjects( NWC24_RECV_BOX ); GetListedSubjects( NWC24_RECV_BOX ); return; } /*---------------------------------------------------------------------------* Name: PostMessage Description: Creates a Wii message and stores it in the Outbox. Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ static void PostMessage( void ) { CreateMessage( NWC24_SEND_BOX ); ReleaseMsgIdList( NWC24_SEND_BOX ); GetMsgIdList( NWC24_SEND_BOX ); ReleaseListedSubjects( NWC24_SEND_BOX ); GetListedSubjects( NWC24_SEND_BOX ); return; } /*---------------------------------------------------------------------------* Name: CreateMessage Description: Creates a Wii message and stores it in the specified message box. Arguments: None. Returns: None. *---------------------------------------------------------------------------*/ static void CreateMessage( NWC24MsgBoxId mBoxId ) { NWC24Err err; NWC24MsgObj msgObj; const NWC24UserId UID_TO = 1234567890ULL; const char* STR_SUBJECT = "TEST MESSAGE"; const char* STR_BODY_TEXT = "Hello Wii Connect 24 World!!\x0d\x0a" "This is a test mail.\x0d\x0a" "Thank you.\x0d\x0a"; err = NWC24InitMsgObj( &msgObj, NWC24_MSGTYPE_WII ); CheckError( "NWC24InitMsgObj()", err ); if ( mBoxId == NWC24_SEND_BOX ) { err = NWC24SetMsgToId( &msgObj, UID_TO ); } else { // Set self as the recipient if the storage destination is the Inbox. NWC24UserId uidMy; err = NWC24GetMyUserId( &uidMy ); CheckError( "NWC24GetMyUserId()", err ); err = NWC24SetMsgToId( &msgObj, uidMy ); } CheckError( "NWC24SetMsgToId()", err ); err = NWC24SetMsgSubject( &msgObj, STR_SUBJECT, (u32)strlen( STR_SUBJECT ) ); CheckError( "NWC24SetMsgSubject()", err ); err = NWC24SetMsgText( &msgObj, (char*)STR_BODY_TEXT, (u32)strlen( STR_BODY_TEXT ), NWC24_US_ASCII, NWC24_ENC_7BIT ); CheckError( "NWC24SetMsgText()", err ); err = NWC24CommitMsg( &msgObj ); CheckError( "NWC24CommitMsg()", err ); return; } /*---------------------------------------------------------------------------* Name: UpdateMenu Description: This function is called each frame to perform updating other than rendering during menu selection. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateMenu ( const KPADStatus* input ) { /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { switch ( g_selectedMenu ) { case MB_MENU_RECV_BOX: { if ( g_numMsgs[MB_TYPE_RECV] != 0 ) { g_state = MB_STATE_RECV_BOX; } break; } case MB_MENU_SEND_BOX: { if ( g_numMsgs[MB_TYPE_SEND] != 0 ) { g_state = MB_STATE_SEND_BOX; } break; } case MB_MENU_RECV_MSG: { g_state = MB_STATE_BEFORE_RECV_MSG; break; } case MB_MENU_POST_MSG: { g_state = MB_STATE_BEFORE_POST_MSG; break; } } } /* (up) button */ if ( (input->trig & KPAD_BUTTON_UP) || (g_longHold & KPAD_BUTTON_UP) ) { if ( 0 < g_selectedMenu ) { --g_selectedMenu; g_lineTopOfBodyText = 0; } } /* (down) button */ if ( (input->trig & KPAD_BUTTON_DOWN) || (g_longHold & KPAD_BUTTON_DOWN) ) { if (g_selectedMenu < NUM_MSG_BOX_MENUS - 1) { ++g_selectedMenu; g_lineTopOfBodyText = 0; } } return; } /*---------------------------------------------------------------------------* Name: UpdateRecvBox Description: This function is called each frame to perform updating other than rendering during inbox selection. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateRecvBox( const KPADStatus* input ) { NWC24Err err; /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { if ( GetMsgData( &g_msgData, NWC24_RECV_BOX, g_idListBuf[MB_TYPE_RECV][g_idxSelectedId[MB_TYPE_RECV]] ) ) { g_state = MB_STATE_MSG_CONTENT; } else { g_state = MB_STATE_RECV_BOX; } } /* (B) button */ if ( input->trig & KPAD_BUTTON_B ) { g_state = MB_STATE_MENU; } /* (up) button */ if ( (input->trig & KPAD_BUTTON_UP) || (g_longHold & KPAD_BUTTON_UP) ) { if ( 0 < g_idxSelectedId[MB_TYPE_RECV] ) { if ( g_idxSelectedId[MB_TYPE_RECV] == g_idxIdTopOfList[MB_TYPE_RECV] ) { u32 subjectSize; NWC24MsgObj msgObj; u32 msgId; char* subjectBuf = NULL; --g_idxIdTopOfList[MB_TYPE_RECV]; g_idxSubjectBufStart[MB_TYPE_RECV] = (u32)((g_idxSubjectBufStart[MB_TYPE_RECV] + LIST_BOX_ROWS - 1) % LIST_BOX_ROWS); msgId = g_idListBuf[MB_TYPE_RECV][g_idxIdTopOfList[MB_TYPE_RECV]]; subjectBuf = g_subjectBuf[MB_TYPE_RECV][g_idxSubjectBufStart[MB_TYPE_RECV]]; if ( subjectBuf ) { MEMFreeToAllocator( &DemoAllocator1, subjectBuf ); subjectBuf = NULL; } err = NWC24GetMsgObj( &msgObj, NWC24_RECV_BOX, msgId ); if ( err == NWC24_ERR_HIDDEN ) { subjectSize = strlen( HIDDEN_MESSAGE ) + 1; subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); (void)memcpy( subjectBuf, HIDDEN_MESSAGE, subjectSize ); } else { CheckError( "NWC24GetMsgObj()", err ); err = NWC24GetMsgSubjectSize( &msgObj, &subjectSize ); CheckError( "NWC24GetMsgSubjectSize()", err ); if ( subjectSize < 1 ) { subjectSize = 1; } subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); err = NWC24ReadMsgSubject( &msgObj, subjectBuf, subjectSize ); if ( err != NWC24_OK ) { subjectBuf[0] = '\0'; } } g_subjectBuf[MB_TYPE_RECV][g_idxSubjectBufStart[MB_TYPE_RECV]] = subjectBuf; } --g_idxSelectedId[MB_TYPE_RECV]; g_lineTopOfBodyText = 0; } } /* (down) button */ if ( (input->trig & KPAD_BUTTON_DOWN) || (g_longHold & KPAD_BUTTON_DOWN) ) { if ( g_idxSelectedId[MB_TYPE_RECV] < g_numMsgs[MB_TYPE_RECV] - 1 ) { u32 idxIdBottomOfList = g_idxIdTopOfList[MB_TYPE_RECV] + LIST_BOX_ROWS - 1; if ( g_idxSelectedId[MB_TYPE_RECV] == idxIdBottomOfList ) { u32 subjectSize; NWC24MsgObj msgObj; u32 msgId; char* subjectBuf = NULL; u32 idxSubjectBufEnd; ++g_idxIdTopOfList[MB_TYPE_RECV]; ++idxIdBottomOfList; idxSubjectBufEnd = g_idxSubjectBufStart[MB_TYPE_RECV]; g_idxSubjectBufStart[MB_TYPE_RECV] = (u32)((g_idxSubjectBufStart[MB_TYPE_RECV] + 1) % LIST_BOX_ROWS); msgId = g_idListBuf[MB_TYPE_RECV][idxIdBottomOfList]; subjectBuf = g_subjectBuf[MB_TYPE_RECV][idxSubjectBufEnd]; if ( subjectBuf ) { MEMFreeToAllocator( &DemoAllocator1, subjectBuf ); subjectBuf = NULL; } err = NWC24GetMsgObj( &msgObj, NWC24_RECV_BOX, msgId ); if ( err == NWC24_ERR_HIDDEN ) { subjectSize = strlen( HIDDEN_MESSAGE ) + 1; subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); (void)memcpy( subjectBuf, HIDDEN_MESSAGE, subjectSize ); } else { CheckError( "NWC24GetMsgObj()", err ); err = NWC24GetMsgSubjectSize( &msgObj, &subjectSize ); CheckError( "NWC24GetMsgSubjectSize()", err ); if ( subjectSize < 1 ) { subjectSize = 1; } subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); err = NWC24ReadMsgSubject( &msgObj, subjectBuf, subjectSize ); if ( err != NWC24_OK ) { subjectBuf[0] = '\0'; } } g_subjectBuf[MB_TYPE_RECV][idxSubjectBufEnd] = subjectBuf; } ++g_idxSelectedId[MB_TYPE_RECV]; g_lineTopOfBodyText = 0; } } return; } /*---------------------------------------------------------------------------* Name: UpdateSendBox Description: This function is called each frame to perform updating other than rendering during outbox selection. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateSendBox( const KPADStatus* input ) { NWC24Err err; /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { if ( GetMsgData( &g_msgData, NWC24_SEND_BOX, g_idListBuf[MB_TYPE_SEND][g_idxSelectedId[MB_TYPE_SEND]] ) ) { g_state = MB_STATE_MSG_CONTENT; } else { g_state = MB_STATE_SEND_BOX; } } /* (B) button */ if ( input->trig & KPAD_BUTTON_B ) { g_state = MB_STATE_MENU; } /* (up) button */ if ( (input->trig & KPAD_BUTTON_UP) || (g_longHold & KPAD_BUTTON_UP) ) { if ( 0 < g_idxSelectedId[MB_TYPE_SEND] ) { if ( g_idxSelectedId[MB_TYPE_SEND] == g_idxIdTopOfList[MB_TYPE_SEND] ) { u32 subjectSize; NWC24MsgObj msgObj; u32 msgId; char* subjectBuf = NULL; --g_idxIdTopOfList[MB_TYPE_SEND]; g_idxSubjectBufStart[MB_TYPE_SEND] = (u32)((g_idxSubjectBufStart[MB_TYPE_SEND] + LIST_BOX_ROWS - 1) % LIST_BOX_ROWS); msgId = g_idListBuf[MB_TYPE_SEND][g_idxIdTopOfList[MB_TYPE_SEND]]; subjectBuf = g_subjectBuf[MB_TYPE_SEND][g_idxSubjectBufStart[MB_TYPE_SEND]]; if ( subjectBuf ) { MEMFreeToAllocator( &DemoAllocator1, subjectBuf ); subjectBuf = NULL; } err = NWC24GetMsgObj( &msgObj, NWC24_SEND_BOX, msgId ); if ( err == NWC24_ERR_HIDDEN ) { subjectSize = strlen( HIDDEN_MESSAGE ) + 1; subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); (void)memcpy( subjectBuf, HIDDEN_MESSAGE, subjectSize ); } else { CheckError( "NWC24GetMsgObj()", err ); err = NWC24GetMsgSubjectSize( &msgObj, &subjectSize ); CheckError( "NWC24GetMsgSubjectSize()", err ); if ( subjectSize < 1 ) { subjectSize = 1; } subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); err = NWC24ReadMsgSubject( &msgObj, subjectBuf, subjectSize ); if ( err != NWC24_OK ) { subjectBuf[0] = '\0'; } } g_subjectBuf[MB_TYPE_SEND][g_idxSubjectBufStart[MB_TYPE_SEND]] = subjectBuf; } --g_idxSelectedId[MB_TYPE_SEND]; g_lineTopOfBodyText = 0; } } /* (down) button */ if ( (input->trig & KPAD_BUTTON_DOWN) || (g_longHold & KPAD_BUTTON_DOWN) ) { if ( g_idxSelectedId[MB_TYPE_SEND] < g_numMsgs[MB_TYPE_SEND] - 1 ) { u32 idxIdBottomOfList = g_idxIdTopOfList[MB_TYPE_SEND] + LIST_BOX_ROWS - 1; if ( g_idxSelectedId[MB_TYPE_SEND] == idxIdBottomOfList ) { u32 subjectSize; NWC24MsgObj msgObj; u32 msgId; char* subjectBuf = NULL; u32 idxSubjectBufEnd; ++g_idxIdTopOfList[MB_TYPE_SEND]; ++idxIdBottomOfList; idxSubjectBufEnd = g_idxSubjectBufStart[MB_TYPE_SEND]; g_idxSubjectBufStart[MB_TYPE_SEND] = (u32)((g_idxSubjectBufStart[MB_TYPE_SEND] + 1) % LIST_BOX_ROWS); msgId = g_idListBuf[MB_TYPE_SEND][idxIdBottomOfList]; subjectBuf = g_subjectBuf[MB_TYPE_SEND][idxSubjectBufEnd]; if ( subjectBuf ) { MEMFreeToAllocator( &DemoAllocator1, subjectBuf ); subjectBuf = NULL; } err = NWC24GetMsgObj( &msgObj, NWC24_SEND_BOX, msgId ); if ( err == NWC24_ERR_HIDDEN ) { subjectSize = strlen( HIDDEN_MESSAGE ) + 1; subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); (void)memcpy( subjectBuf, HIDDEN_MESSAGE, subjectSize ); } else { CheckError( "NWC24GetMsgObj()", err ); err = NWC24GetMsgSubjectSize( &msgObj, &subjectSize ); CheckError( "NWC24GetMsgSubjectSize()", err ); if ( subjectSize < 1 ) { subjectSize = 1; } subjectBuf = MEMAllocFromAllocator( &DemoAllocator1, subjectSize ); err = NWC24ReadMsgSubject( &msgObj, subjectBuf, subjectSize ); if ( err != NWC24_OK ) { subjectBuf[0] = '\0'; } } g_subjectBuf[MB_TYPE_SEND][idxSubjectBufEnd] = subjectBuf; } ++g_idxSelectedId[MB_TYPE_SEND]; g_lineTopOfBodyText = 0; } } return; } /*---------------------------------------------------------------------------* Name: UpdateMsgContent Description: This function is called each frame to perform updating other than rendering during message selection. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateMsgContent( const KPADStatus* input ) { /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { g_state = MB_STATE_DELETE_MSG; } /* (B) button */ if ( input->trig & KPAD_BUTTON_B ) { g_state = (g_selectedMenu == MB_MENU_RECV_BOX) ? MB_STATE_RECV_BOX : MB_STATE_SEND_BOX; } /* (up) button */ if ( (input->trig & KPAD_BUTTON_UP) || (g_longHold & KPAD_BUTTON_UP) ) { if ( 0 < g_lineTopOfBodyText ) { --g_lineTopOfBodyText; } } /* (down) button */ if ( (input->trig & KPAD_BUTTON_DOWN) || (g_longHold & KPAD_BUTTON_DOWN) ) { if ( (s32)g_lineTopOfBodyText < (s32)(g_numLinesBodyText - TEXT_BOX_ROWS) ) { ++g_lineTopOfBodyText; } } return; } /*---------------------------------------------------------------------------* Name: UpdateDeleteMsg Description: This function is called each frame to perform updating other than rendering when delete message is selected. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateDeleteMsg( const KPADStatus* input ) { /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { NWC24Err err; NWC24MsgBoxId mBoxId = (g_selectedMenu == MB_MENU_RECV_BOX) ? NWC24_RECV_BOX : NWC24_SEND_BOX; MsgBoxType mbType = (g_selectedMenu == MB_MENU_RECV_BOX) ? MB_TYPE_RECV : MB_TYPE_SEND; err = NWC24DeleteMsg( mBoxId, g_idListBuf[mbType][ g_idxSelectedId[mbType] ] ); if ( err == NWC24_ERR_PROTECTED ) { g_state = MB_STATE_MSG_CONTENT; } else { CheckError( "NWC24DeleteMsg()", err ); } ReleaseMsgIdList( mBoxId ); GetMsgIdList( mBoxId ); if ( g_numMsgs[mbType] == 0 ) { g_idxSelectedId[mbType] = 0; g_state = MB_STATE_MENU; } else { if ( g_numMsgs[mbType] <= g_idxSelectedId[mbType] ) { g_idxSelectedId[mbType] = g_numMsgs[mbType] - 1; } if ( g_idxIdTopOfList[mbType] != 0 && g_numMsgs[mbType] - g_idxIdTopOfList[mbType] < LIST_BOX_ROWS ) { g_idxIdTopOfList[mbType] = g_numMsgs[mbType] - LIST_BOX_ROWS; } g_state = (g_selectedMenu == MB_MENU_RECV_BOX) ? MB_STATE_RECV_BOX : MB_STATE_SEND_BOX; } ReleaseListedSubjects( mBoxId ); GetListedSubjects( mBoxId ); } /* (B) button */ if ( input->trig & KPAD_BUTTON_B ) { g_state = MB_STATE_MSG_CONTENT; } return; } /*---------------------------------------------------------------------------* Name: UpdateBeforeRecvMsg Description: This function is called each frame to perform updating other than rendering when receive message is selected. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateBeforeRecvMsg( const KPADStatus* input ) { /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { ReceiveMessage(); g_state = MB_STATE_DONE_RECV_MSG; } /* (B) button */ if ( input->trig & KPAD_BUTTON_B ) { g_state = MB_STATE_MENU; } return; } /*---------------------------------------------------------------------------* Name: UpdateBeforePostMsg Description: This function is called each frame to perform updating other than rendering when send message is selected. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateBeforePostMsg( const KPADStatus* input ) { /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { PostMessage(); g_state = MB_STATE_DONE_POST_MSG; } /* (B) button */ if ( input->trig & KPAD_BUTTON_B ) { g_state = MB_STATE_MENU; } return; } /*---------------------------------------------------------------------------* Name: UpdateDoneRecvMsg Description: This function is called each frame to perform updating other than rendering after the message is received. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateDoneRecvMsg( const KPADStatus* input ) { /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { g_state = MB_STATE_MENU; } return; } /*---------------------------------------------------------------------------* Name: UpdateDonePostMsg Description: This function is called each frame to perform updating other than rendering after the message is sent. Arguments: input - Pointer to KPADStatus type controller information. Returns: None. *---------------------------------------------------------------------------*/ static void UpdateDonePostMsg( const KPADStatus* input ) { /* (A) button */ if ( input->trig & KPAD_BUTTON_A ) { g_state = MB_STATE_MENU; } return; } /*======== End of MsgViewerUpdate.c ========*/