#include typedef struct { UInt8 count; UInt8 isActive; UInt32 prevAppCreatorID; } GlobalValType; static void asm GlobalVal (void) { DC.B 0 //count用の領域 DC.B false //動作中かいなかのフラグ DC.L 'strt' //prevAppCreatorID用の領域 } static Err callbackFunc (SysNotifyParamType *notifyParamsP) { GlobalValType* GlobalValP = (GlobalValType*)&GlobalVal; //グローバル領域のアドレス取得 WinDrawChars ((Char*)&GlobalValP->prevAppCreatorID, 4, 10, 10); //クリエータIDの描画 UInt16 cardNo; LocalID dbID; SysCurAppDatabase (&cardNo, &dbID); //今動作しているアプリケーションの取得 UInt32 curAppCreatorID; DmDatabaseInfo (cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &curAppCreatorID); //クリエータIDの取得 Boolean isSame = (GlobalValP->prevAppCreatorID == curAppCreatorID); //前回呼ばれたときとの比較 UInt8 tmpCount = GlobalValP->count; Char tmpCountA[5]; if (isSame) { StrIToA (tmpCountA, ++tmpCount); } else { StrIToA (tmpCountA, tmpCount); tmpCount = 1; } WinDrawChars (tmpCountA, StrLen (tmpCountA), 10, 25); //カウント数の描画 //グローバル領域への書き込み MemSemaphoreReserve (true); GlobalValP->prevAppCreatorID = curAppCreatorID; GlobalValP->count = tmpCount; MemSemaphoreRelease (true); return errNone; } static void activate (void) { GlobalValType* GlobalValP = (GlobalValType*)&GlobalVal; //グローバル領域のアドレス取得 if(!GlobalValP->isActive) { UInt16 cardNo; LocalID dbID; SysCurAppDatabase (&cardNo, &dbID); //今動作しているアプリケーションの取得 SysNotifyRegister (cardNo, dbID, sysNotifyMenuCmdBarOpenEvent, &callbackFunc, sysNotifyNormalPriority, NULL); DmDatabaseProtect (cardNo, dbID, true); //グローバル領域への書き込み MemSemaphoreReserve (true); GlobalValP->isActive = true; //動作中のフラグをセット MemSemaphoreRelease (true); } } UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { switch (cmd) { case sysAppLaunchCmdNormalLaunch: activate (); break; case sysAppLaunchCmdSystemReset: GlobalValType* GlobalValP = (GlobalValType*)&GlobalVal; //グローバル領域のアドレス取得 //グローバル領域への書き込み MemSemaphoreReserve (true); GlobalValP->isActive = true; //動作中のフラグをリセット MemSemaphoreRelease (true); } return true; }