Skip to content

Instantly share code, notes, and snippets.

@magcius
Last active November 7, 2016 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magcius/c83afb2f7ba9977374e884fca3ff3236 to your computer and use it in GitHub Desktop.
Save magcius/c83afb2f7ba9977374e884fca3ff3236 to your computer and use it in GitHub Desktop.
/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*+ Status
*
* Copyright(C) 2010 SUZAK Inc. All Rights Reserved.
*
* project name:アボート制御
* source name:src/Abort.c
* data model:ILP32
* make:uno
* tab range:space [4]
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Logs
*
* update:----/--/---[--:--:--]:byUNO
* ▼
*
* create:2010/06/18-[15:47:09]:byUNO
* ▼新規作成。
*
*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*/
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Source explain
*
* ◆アボート制御◆
*
* ▼
*
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/*=============<>==============<>==============<>==============<>==============<
*+ ソースネーム定義
*=============<>==============<>==============<>==============<>==============<
*/
static const char s__SRC__[] = __FILE__;
#define __SRC__ s__SRC__
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Include
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/*=============<>==============<>==============<>==============<>==============<
*+ 基本ヘッダ
*=============<>==============<>==============<>==============<>==============<
*/
#include <libsuzak/Abort.h>
#include <types.h>
#include <libsuzak/MemUtils.h>
#include <libsuzak/Print.h>
#include <libsuzak/UtilSec.h>
#include <libsuzak/Sym.h>
#include <libsuzak/BreakPoint.h>
#include <stdio.h>
#include <stdarg.h>
#include <malloc.h>
#include <libgu.h>
#include <displaysvc.h>
#include <rtcsvc.h>
#include <ctrlsvc.h>
#include <loadexec.h>
#include <string.h>
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Build control
*=============<>==============<>==============<>==============<>==============<>==============<
*/
#if (__ENABLE_ABORT__)
//[
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Macro / Enumeration / Type definition
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/*=============<>==============<>==============<>==============<>==============<
*+ RGBA 8888 フォーマットの色値を作成する
*=============<>==============<>==============<>==============<>==============<
*/
#define RGBA8888_(r,g,b,a) ¥
( (SCOPECLIP(r, 0x00, 0xFF) << 0) ¥
| (SCOPECLIP(g, 0x00, 0xFF) << 8) ¥
| (SCOPECLIP(b, 0x00, 0xFF) << 16) ¥
| (SCOPECLIP(a, 0x00, 0xFF) << 24) ¥
)
/*=============<>==============<>==============<>==============<>==============<
*+ 文字幅
*=============<>==============<>==============<>==============<>==============<
*/
#define GLYPH_W_ ( 8 )
#define GLYPH_H_ ( 8 )
/*=============<>==============<>==============<>==============<>==============<
*+ ディスプレイリスト
*=============<>==============<>==============<>==============<>==============<
*/
#define DISP_LIST_BUF_SIZE_ (KBYTE(16))
#define DISP_LIST_BUF_ALIGN_ (64)
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Structure / Union
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/*=============<>==============<>==============<>==============<>==============<
*+ アボートスワーク構造体
*=============<>==============<>==============<>==============<>==============<
*/
typedef struct tagSAbortWork_
{
char symbol[SYM_LETTER_LENGTH_MAX]; //+ シンボル
//+ 2010/07/02-[23:11:53] 変更 byUNO
// Abort 系命令が使われてしまうので、自前処理に切り替え。
//[
// SSym sym;
//]
BOOL isValid; //+ 制御の正当性
RAbortCB rAbortCB; //+ アボートコールバック(NULL 可)
}
SAbortWork_;
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Prototype / External / Inline routine
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/*=============<>==============<>==============<>==============<>==============<
*+ インターフェイス
*=============<>==============<>==============<>==============<>==============<
*/
void Abort_Init/*#*/
( RAbortCB rAbortCB //+ アボートコールバック(NULL 可)
);
void Abort_Term/*#*/
(void);
BOOL Abort_IsValid/*#*/
(void);
void Abort_Exec/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, ... //+ 可変引数
);
void Abort_ExecCore/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, va_list vaList //+ 可変引数リスト
);
static void Abort_ExecCore_Ind_/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, va_list vaList //+ 可変引数リスト
);
static void Abort_ExecCore_Dep_/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, va_list vaList //+ 可変引数リスト
, void * dispListBuf //+ ディスプレイリストバッファ
);
int Abort_ExecCore_Dep_Comment_/*#*/
( int posX //+ x座標
, int posY //+ y座標
, uint color //+ 文字色
, const char * pFmt //+ 文字フォーマット
, va_list vaList //+ 可変引数リスト
);
/*=============<>==============<>==============<>==============<>==============<
*+
*=============<>==============<>==============<>==============<>==============<
*/
static void UtilGetNotice_/*#*/
( EAbortID abortID //+ アボート ID
, const char ** ppNotice //+ エラー内容の格納先
);
static void UtilPrintf_/*#*/
( int posX //+ x座標
, int posY //+ y座標
, uint color //+ 文字色
, const char * pFmt //+ フォーマット文字列
, ... //+ 可変引数
);
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Constant memory
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/*=============<>==============<>==============<>==============<>==============<
*+ セパレータ
*=============<>==============<>==============<>==============<>==============<
*/
static const char s_Separator0000[] = "============================================================";
static const char s_Separator0001[] = "---- Abort status ------------------------------------------";
static const char s_Separator0002[] = "---- Comment -----------------------------------------------";
/*=============<>==============<>==============<>==============<>==============<
*+ シンボル
*=============<>==============<>==============<>==============<>==============<
*/
static const char s_Symbol[] = "libsuzak::Abort";
/*=============<>==============<>==============<>==============<>==============<
*+ アボート ID 情報構造体
*=============<>==============<>==============<>==============<>==============<
*/
typedef struct tagSAbortIDInfo_
{
#if (__BUILD_DEBUG__)
//[
EAbortID d_AbortID; //+ アボート ID
const char * d_Name; //+ ネーム
//]
#endif
const char * pNotice; //+ エラー内容
}
SAbortIDInfo_;
/*=============<>==============<>==============<>==============<>==============<
*+ アボート ID 情報構造生成マクロ
*=============<>==============<>==============<>==============<>==============<
*/
#if (__BUILD_DEBUG__)
//[
#define SAbortIDInfo_MAKE_(NAME, pNotice) {AbortID_ ## NAME, #NAME, pNotice}
//]
#else
//[
#define SAbortIDInfo_MAKE_(NAME, pNotice) {pNotice}
//]
#endif
/*=============<>==============<>==============<>==============<>==============<
*+ アボート ID 情報構造テーブル
*=============<>==============<>==============<>==============<>==============<
*/
static const SAbortIDInfo_ s_AbortIDInfoTbl[] =
{ SAbortIDInfo_MAKE_(NONE , "None." ) //+ AbortID_NONE //+ なし
, SAbortIDInfo_MAKE_(UNKNOWN , "Unknown." ) //+ AbortID_UNKNOWN //+ 不明
, SAbortIDInfo_MAKE_(ACCESS_TO_NULL , "Access to NULL." ) //+ AbortID_ACCESS_TO_NULL //+ NULL アクセス
, SAbortIDInfo_MAKE_(ZERO_DIVIDE , "Zero divide." ) //+ AbortID_ZERO_DIVIDE //+ ゼロ除算
, SAbortIDInfo_MAKE_(BUFFER_OVERRUN , "Buffer overrun." ) //+ AbortID_BUFFER_OVERRUN //+ バッファオーバーラン
, SAbortIDInfo_MAKE_(AREA_EXCESS , "Area excess." ) //+ AbortID_AREA_EXCESS //+ 領域超過
, SAbortIDInfo_MAKE_(TABLE_NOT_MAINTAINED , "Table Not Maintained." ) //+ AbortID_TABLE_NOT_MAINTAINED //+ 未整備のテーブル
, SAbortIDInfo_MAKE_(LACK_OF_MEMORY , "Lack of memory." ) //+ AbortID_LACK_OF_MEMORY //+ メモリ不足
};
/**************<>**************<>**************<>**************<>**************<
*+ アボート ID 情報構造:ゲッタ
**************<>**************<>**************<>**************<>**************<
*/
static const SAbortIDInfo_ *GetAbortIDInfo_(EAbortID abortID);
static const SAbortIDInfo_ *GetAbortIDInfo_(EAbortID abortID)
{
if ((u32)abortID >= elemof(s_AbortIDInfoTbl)) { ABORT(AbortID_BUFFER_OVERRUN); return NULL; }
if (_AbortID_MAX != elemof(s_AbortIDInfoTbl)) { ABORT(AbortID_TABLE_NOT_MAINTAINED); return NULL; }
#if (__BUILD_DEBUG__)
{
const SAbortIDInfo_ *pAbortIDInfo = &s_AbortIDInfoTbl[abortID];
if (pAbortIDInfo->d_AbortID != abortID) { ABORT(AbortID_TABLE_NOT_MAINTAINED); return NULL; }
return pAbortIDInfo;
}
#else
{
return &s_AbortIDInfoTbl[abortID];
}
#endif
}
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Static memory
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/*=============<>==============<>==============<>==============<>==============<
*+ アボートワーク構造
*=============<>==============<>==============<>==============<>==============<
*/
static SAbortWork_ s_AbortWork;
/*=============<>==============<>==============<>==============<>==============<>==============<
*+ Routine
*=============<>==============<>==============<>==============<>==============<>==============<
*/
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:初期化する。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
void Abort_Init/*#*/
( RAbortCB rAbortCB //+ アボートコールバック(NULL 可)
)
{
SAbortWork_ *pWork = &s_AbortWork;
//+ デバッグチェック
ifd (true)
{
GetAbortIDInfo_(AbortID_NONE);
}
//+ ワークセットアップ
MemClear(pWork, sizeof(*pWork));
#if (__ENABLE_SYM__)
{
MemClear(pWork->symbol, sizeof(pWork->symbol));
strncpy(pWork->symbol, s_Symbol, elemof(pWork->symbol));
pWork->symbol[elemof(pWork->symbol) - 1] = 0';
}
#endif
//+ 2010/07/02-[23:11:53] 変更 byUNO
// Abort 系命令が使われてしまうので、自前処理に切り替え。
//[
// Sym_Init(&pWork->sym);
// Sym_Store(&pWork->sym, s_Symbol);
//]
pWork->rAbortCB = rAbortCB;
pWork->isValid = true;
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:終了化する。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
void Abort_Term/*#*/
(void)
{
SAbortWork_ *pWork = &s_AbortWork;
if (pWork->isValid)
{
#if (__ENABLE_SYM__)
{
if (strncmp(pWork->symbol, s_Symbol, elemof(pWork->symbol)) != 0)
{
ABORT_NONE();
}
MemClear(pWork->symbol, sizeof(pWork->symbol));
}
#endif
//+ 2010/07/02-[23:11:53] 変更 byUNO
// Abort 系命令が使われてしまうので、自前処理に切り替え。
//[
// Sym_CheckName(&pWork->sym, s_Symbol);
// Sym_Term(&pWork->sym);
//]
pWork->isValid = false;
}
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:制御の正当性を調べる。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* 真:正当である。
* 偽:不当である。
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
BOOL Abort_IsValid/*#*/
(void)
{
const SAbortWork_ *pWork = &s_AbortWork;
#if (__ENABLE_SYM__)
{
if (pWork->isValid)
{
if (strncmp(pWork->symbol, s_Symbol, elemof(pWork->symbol)) != 0)
{
ABORT_NONE();
}
//+ 2010/07/02-[23:11:53] 変更 byUNO
// Abort 系命令が使われてしまうので、自前処理に切り替え。
//[
// Sym_CheckName(&pWork->sym, s_Symbol);
//]
}
}
#endif
return pWork->isValid;
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:実行する。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
void Abort_Exec/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, ... //+ 可変引数
)
{
va_list vaList;
//+ 2010/06/25-[11:29:23] 凍結 byUNO
// Abort_ExecCore() に依存。
//[
// //+ 未初期化なら初期化
// // よろしくない処理だが、アサートするわけにもいかんし…
// if (!Abort_IsValid()) { Abort_Init(NULL); }
//]
va_start(vaList, pComment);
{
Abort_ExecCore(pSrcName, curLine, abortID, resumeMsec, pComment, vaList);
}
va_end(vaList);
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:実行する。
* ※ILP32 固有処理を含みます。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
void Abort_ExecCore/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, va_list vaList //+ 可変引数リスト
)
{
void *dispListBuf = malloc(DISP_LIST_BUF_SIZE_ + DISP_LIST_BUF_ALIGN_);
if (dispListBuf == NULL)
{
Abort_ExecCore_Ind_(pSrcName, curLine, abortID, resumeMsec, pComment, vaList);
}
else
{
u32 ofs = (u32)dispListBuf;
//+ align
if (ofs & (DISP_LIST_BUF_ALIGN_ - 1))
{
ofs += (DISP_LIST_BUF_ALIGN_ - (ofs & (DISP_LIST_BUF_ALIGN_ - 1)));
}
Abort_ExecCore_Dep_(pSrcName, curLine, abortID, resumeMsec, pComment, vaList, (void *)ofs);
{ free(dispListBuf); dispListBuf = NULL; }
}
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:実行する。
* ▼独立タイプ。
* ※ILP32 固有処理を含みます。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
static void Abort_ExecCore_Ind_/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, va_list vaList //+ 可変引数リスト
)
{
BYTE dispListBuf[DISP_LIST_BUF_SIZE_ + DISP_LIST_BUF_ALIGN_];
u32 ofs = (u32)dispListBuf;
//+ align
if (ofs & (DISP_LIST_BUF_ALIGN_ - 1))
{
ofs += (DISP_LIST_BUF_ALIGN_ - (ofs & (DISP_LIST_BUF_ALIGN_ - 1)));
}
Abort_ExecCore_Dep_(pSrcName, curLine, abortID, resumeMsec, pComment, vaList, dispListBuf);
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:実行する。
* ▼依存タイプ。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
static void Abort_ExecCore_Dep_/*#*/
( const char * pSrcName //+ ソースネーム
, int curLine //+ ライン数
, EAbortID abortID //+ アボート ID(AbortID_XXXX)
, int resumeMsec //+ 復帰時間(ミリ秒)
, const char * pComment //+ コメント(NULL 可)
, va_list vaList //+ 可変引数リスト
, void * dispListBuf //+ ディスプレイリストバッファ
)
{
/*=============<>==============<>==============<>==============<>==============<
*+ ステップ ID
*=============<>==============<>==============<>==============<>==============<
*/
typedef enum tagEStepID_
{ StepID_INIT_ = 100 * 0 //+ 始端
, StepID_TERM_ = 100 * 1 //+ 終端
, StepID_MENU_ = 100 * 2 //+ メニュー
, StepID_EXIT_ = 100 * 3 //+ アプリケーション終了
, StepID_RESUME_ = 100 * 4 //+ アプリケーション復帰
, _StepID_EOF_ //+ End OF
}
EStepID_;
/*=============<>==============<>==============<>==============<>==============<
*+ メニュー ID
*=============<>==============<>==============<>==============<>==============<
*/
typedef enum tagEMenuID_
{ MenuID_EXIT_ //+ 終了
, MenuID_KEEP_ //+ 維持
, MenuID_RESUME_ //+ 復元
, _MenuID_MAX_ //+ 総数
, _MenuID_EOF_ //+ End OF
}
EMenuID_;
const char gearAry[] = "-¥¥|/";
const char *pGear = gearAry;
//const SAbortWork_ *pWork = &s_AbortWork;
const char *pNotice;
EStepID_ stepID = StepID_INIT_;
EMenuID_ menuID = MenuID_KEEP_;
BOOL rqLoop = true;
BOOL isDrawing = false;
int yy;
int colorValue = 0xFF;
int colorDir = -1;
int color;
int resumeFrame = 0;
SceRtcTick beginTick, elapseTick;
ScePspDateTime beginTime, elapseTime;
uint svSamplingMode = 0;
SceCtrlData pad = {0};
u32 pressButtons = 0;
u32 trigButtons = 0;
//+ 未初期化なら初期化
// よろしくない処理だが、アサートするわけにもいかんし…
// とりあえず、イニシャライズしておく。
if (!Abort_IsValid()) { Abort_Init(NULL); }
//+ アボートループ
while (rqLoop)
{
//+ 描画終了
if (isDrawing)
{
sceGuFinish();
isDrawing = false;
}
//+ 描画の更新とフレーム経過を待つ
sceGuSync(SCEGU_SYNC_FINISH, SCEGU_SYNC_WAIT);
sceDisplayWaitVblankStart();
sceGuSwapBuffers();
//+ 描画開始
if (!isDrawing)
{
sceGuStart(SCEGU_IMMEDIATE, dispListBuf, DISP_LIST_BUF_SIZE_);
sceGuClear(SCEGU_CLEAR_ALL);
isDrawing = true;
}
//+ パッド更新
sceCtrlPeekBufferPositive(&pad, 1);
trigButtons = pad.Buttons &pressButtons;
pressButtons = pad.Buttons;
//+ 歯車
++pGear;
if ((*pGear) == 0')
{
pGear = gearAry;
}
//+ 文字色
color = RGBA8888_(colorValue, colorValue, colorValue, colorValue);
colorValue += colorDir;
if (ScopeOut(colorValue, 0x00, 0xFF))
{
colorDir = (colorDir >= 0)? -1: +1;
}
//+ ステップ ID 分岐
switch (stepID)
{
/*-------------<>--------------<>--------------<>--------------<*/
default:
{
stepID = StepID_EXIT_;
}
break;
/*-------------<>--------------<>--------------<>--------------<*/
case StepID_INIT_:
{
//+ サンプリングモードをデジタルボタン専用に変更する
sceCtrlGetSamplingMode(&svSamplingMode);
sceCtrlSetSamplingMode(SCE_CTRL_MODE_DIGITALONLY);
//+ 開始時間を得る
sceRtcGetCurrentTick(&beginTick);
sceRtcSetTick(&beginTime, &beginTick);
//+ エラー内容を得る
UtilGetNotice_(abortID, &pNotice);
Print_Separator();
Printf("Abort ... [%d] ... %s¥n" , abortID , pNotice );
Printf(" %s(%d)¥n" , pSrcName , curLine );
Print_Separator();
stepID = StepID_MENU_;
}
break;
/*-------------<>--------------<>--------------<>--------------<*/
case StepID_TERM_:
{
//+ サンプリングモードを復元する
sceCtrlSetSamplingMode(svSamplingMode);
rqLoop = false;
++stepID;
}
break;
//+
case StepID_TERM_+1:
{
//+ nop
}
break;
/*-------------<>--------------<>--------------<>--------------<*/
case StepID_MENU_:
{
//+ 決定
if (trigButtons & (SCE_CTRL_CIRCLE | SCE_CTRL_START))
{
//+ メニュー ID 分岐
switch (menuID)
{
/*-------------<>--------------<>--------------<>--------------<*/
default:
case MenuID_EXIT_:
{
stepID = StepID_EXIT_;
continue;
}
break;
/*-------------<>--------------<>--------------<>--------------<*/
case MenuID_KEEP_:
{
//+ nop
}
break;
/*-------------<>--------------<>--------------<>--------------<*/
case MenuID_RESUME_:
{
stepID = StepID_RESUME_;
continue;
}
break;
}
}
//+ メニュー:選択上昇
if (trigButtons & (SCE_CTRL_UP | SCE_CTRL_LEFT | SCE_CTRL_L))
{
menuID = (EMenuID_)((menuID > 0)? menuID - 1: _MenuID_MAX_ - 1);
}
//+ メニュー:選択下降
if (trigButtons & (SCE_CTRL_DOWN | SCE_CTRL_RIGHT | SCE_CTRL_R))
{
menuID = (EMenuID_)((menuID < (_MenuID_MAX_ - 1))? menuID + 1: 0);
}
//+ 経過時間を得る
sceRtcGetCurrentTick(&elapseTick);
elapseTick.tick -= beginTick.tick;
sceRtcSetTick(&elapseTime, &elapseTick);
//+ 経過時間を補正
sceRtcSetYear( &elapseTime, sceRtcGetYear(&elapseTime) - 1);
sceRtcSetMonth( &elapseTime, sceRtcGetMonth(&elapseTime) - 1);
sceRtcSetDay( &elapseTime, sceRtcGetDay(&elapseTime) - 1);
//+ アボート情報をプリント
yy = 0;
UtilPrintf_(0, GLYPH_H_ * yy++, color , s_Separator0000 );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " << Abort application >>" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " [Begin time]" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " %04d/%02d/%02d-[%02d:%02d:%02d.%06d]" , sceRtcGetYear(&beginTime) , sceRtcGetMonth(&beginTime) , sceRtcGetDay(&beginTime) , sceRtcGetHour(&beginTime) , sceRtcGetMinute(&beginTime) , sceRtcGetSecond(&beginTime) , sceRtcGetMicrosecond(&beginTime) );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
if ( (sceRtcGetYear(&elapseTime) >= 1)
|| (sceRtcGetMonth(&elapseTime) >= 1)
)
{
UtilPrintf_(0, GLYPH_H_ * yy++, color , " [Elapse tick]" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " %d" , elapseTick.tick );
}
else
{
UtilPrintf_(0, GLYPH_H_ * yy++, color , " [Elapse time]" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " %d:%02d:%02d.%06d" , sceRtcGetDay(&elapseTime) * 24 + sceRtcGetHour(&elapseTime) , sceRtcGetMinute(&elapseTime) , sceRtcGetSecond(&elapseTime) , sceRtcGetMicrosecond(&elapseTime) );
}
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , s_Separator0001 );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " [Source]" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " %s" , pSrcName );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " [Line]" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " %d" , curLine );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " [Abort notice]" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " %d:%s" , abortID , pNotice );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
if (pComment != NULL)
{
yy += Abort_ExecCore_Dep_Comment_(0, GLYPH_H_ * yy, color, pComment, vaList);
}
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * 33, color , s_Separator0000 );
//+ メニュー表示
yy = 2;
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "+------------+" );
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "| MENU |" );
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "+------------+" );
if (menuID == MenuID_EXIT_)
{
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "| %c EXIT %c |" , (*pGear) , (*pGear));
}
else
{
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "| EXIT |" );
}
if (menuID == MenuID_KEEP_)
{
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "| %c KEEP %c |" , (*pGear) , (*pGear));
}
else
{
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "| KEEP |" );
}
if (menuID == MenuID_RESUME_)
{
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "| %c RESUME %c |" , (*pGear) , (*pGear));
}
else
{
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "| RESUME |" );
}
UtilPrintf_(GLYPH_W_*44, GLYPH_H_ * yy++, color , "+------------+" );
}
break;
/*-------------<>--------------<>--------------<>--------------<*/
case StepID_EXIT_:
{
Print_Separator();
Printf("Exit application.¥n");
Print_Separator();
++stepID;
}
break;
//+
case StepID_EXIT_+1:
{
sceKernelExitGame();
++stepID;
}
break;
//+
case StepID_EXIT_+2:
{
//+ nop
}
break;
/*-------------<>--------------<>--------------<>--------------<*/
case StepID_RESUME_:
{
Print_Separator();
Printf("Resume abort.¥n");
Print_Separator();
resumeFrame = UtilMsecToFrame60(resumeMsec);
++stepID;
}
break;
//+
case StepID_RESUME_+1:
{
if (--resumeFrame < 0)
{
stepID = StepID_TERM_;
continue;
}
//+ 復帰カウントダウン表示
yy = 0;
UtilPrintf_(0, GLYPH_H_ * yy++, color , s_Separator0000 );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " << Resume application >>" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " [Countdown]" );
UtilPrintf_(0, GLYPH_H_ * yy++, color , " %d sec" , UtilFrameToSec(60, resumeFrame) + 1);
UtilPrintf_(0, GLYPH_H_ * yy++, color , "" );
UtilPrintf_(0, GLYPH_H_ * 33, color , s_Separator0000 );
}
break;
}
//+ 描画終了
if (isDrawing)
{
sceGuFinish();
isDrawing = false;
}
}
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:実行する。
* ▼依存タイプ。
* ▽コメントをプリントする。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* ライン数。
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
int Abort_ExecCore_Dep_Comment_/*#*/
( int posX //+ x座標
, int posY //+ y座標
, uint color //+ 文字色
, const char * pFmt //+ 文字フォーマット
, va_list vaList //+ 可変引数リスト
)
{
int ret = 0;
char *pText;
const char *pCur;
char dispAry[2];
UtilPrintf_(posX, posY, color , s_Separator0002 );
{ posX = 0; posY += GLYPH_H_; ++ret; } //+ 改行反映
UtilPrintf_(posX, posY, color , "" );
{ posX = 0; posY += GLYPH_H_; ++ret; } //+ 改行反映
//+ コメントを展開
if (Print_VExpand(malloc, free, &pText, pFmt, vaList) < 0)
{
pText = NULL;
pCur = pFmt;
}
else
{
pCur = pText;
}
//+ プリント
for (; (*pCur) != 0'; ++pCur)
{
//+ 改行を処理
if ((*pCur) == n')
{
{ posX = 0; posY += GLYPH_H_; ++ret; } //+ 改行反映
continue;
}
//+ 1 文字プリント
dispAry[0] = *pCur;
dispAry[1] = 0';
sceGuDebugPrint(posX, posY, color, dispAry);
{ posX += GLYPH_W_; }
}
//+ コメントの展開バッファを開放
if (pText != NULL)
{
{ free((void *)pText); pText = NULL; }
}
return ret;
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:アボートする。
* ▼エラー内容を得る。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
static void UtilGetNotice_/*#*/
( EAbortID abortID //+ アボート ID
, const char ** ppNotice //+ エラー内容の格納先
)
{
const SAbortWork_ *pWork = &s_AbortWork;
(*ppNotice) = NULL;
//+ システム定義のアボート ID
if ((u32)abortID < _AbortID_MAX)
{
const SAbortIDInfo_ *pInfo = GetAbortIDInfo_(abortID);
if (pInfo == NULL)
{
(*ppNotice) = NULL;
}
else
{
(*ppNotice) = pInfo->pNotice;
}
}
//+ ユーザ定義のアボート ID
else if (pWork->rAbortCB != NULL)
{
if (!pWork->rAbortCB(abortID, ppNotice))
{
(*ppNotice) = NULL;
}
}
//+ 未だエラー内容が決まっていない。
if ((*ppNotice) == NULL)
{
UtilGetNotice_(AbortID_UNKNOWN, ppNotice);
}
}
/**************<>**************<>**************<>**************<>**************<>**************<
*+ Routine explain
* アボート制御:実行する。
* ▼フォーマットつきでプリントする。
*
*-------------<>--------------<>--------------<>--------------<>--------------<>--------------<
*+ Result
* なし
*
**************<>**************<>**************<>**************<>**************<>**************<
*/
static void UtilPrintf_/*#*/
( int posX //+ x座標
, int posY //+ y座標
, uint color //+ 文字色
, const char * pFmt //+ フォーマット文字列
, ... //+ 可変引数
)
{
char *pText;
va_list vaList;
va_start(vaList, pFmt);
{
if (Print_VExpand(malloc, free, &pText, pFmt, vaList) < 0)
{
sceGuDebugPrint(posX, posY, color, pFmt);
}
else
{
sceGuDebugPrint(posX, posY, color, pText);
{ free((void *)pText); pText = NULL; }
}
}
va_end(vaList);
}
//]
#endif//__ABORT_ENABLE_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment