/*
 ******************************************************************************
 *              
 *      処理情報の出力
 * 	$Id: system_info.c,v 1.1 2003/05/30 21:25:28 tong Exp $
 ******************************************************************************
 */
#include "system.h"
#include "system_info.h"
#include "actorManager.h"
#include "oamManager.h"
#include "worldManager.h"
#include "viewManager.h"
#include "frameManager.h"
#include "loadgraph.h"

#if TIME
static int timerLive = FALSE;
/*
 ******************************************************************************
 *   処理タイム計測
 ******************************************************************************
 */
#define Z_LOAD_GRAPH     (SIZE_ZSORTBUFF- 1)
void AddLoadGraph(void)
{
    loadgraph_init(&load_graph);
    bgfuncx_init(&load_graph.bgfuncx,
		 loadgraph_callback,
		 NULL,
		 BG_FUNC_GFXLIST);
}
void timerProc1(void)
{
    if(!timerLive)
	return;
    load_graph.all_time = osGetTime() - load_graph.all_start_time;
    loadgraph_move();
}
void timerProc2(void)
{
    if(!timerLive)
	return;
    load_graph.all_start_time = osGetTime();
}
/*
 ******************************************************************************
 *      "タイマー"の処理
 ******************************************************************************
 */
static void Timer(ACTOR *Actor)
{
    timerLive = TRUE;
    Actor->hidden = DISPLAY;
    Actor->wposf[XX] = getP_frameP()->wposf_CT[XX];
    Actor->wposf[YY] = getP_frameP()->wposf[LTOP][YY] + 32.0F;
}
/*
 ******************************************************************************
 *      "タイマー"の誕生
 ******************************************************************************
 */
NORMALBOOT_ACTOR(Timer)
void birth_Timer(ACTOR *Actor)
{
    DWIFFN_P(Actor)->process = bgfuncx_getFunc(&load_graph.bgfuncx);
						      
    Actor->process = Timer;
    refreshPrio(ON);                  /* 表示優先順位処理をON */
}
#endif
#if SYSTEM_INFO
/*
 ******************************************************************************
 *      システム情報の出力
 ******************************************************************************
 */
#define kbyte(b)    ((float)((b)/1024) + (float)((b)%1024)/1000.0F)
void print_info(void)
{
    extern char _codeSegmentStart[], _codeSegmentEnd[];
    extern char _bufferSegmentStart[], _bufferSegmentEnd[];
    float  fSize = kbyte(_bufferSegmentEnd - _bufferSegmentStart);
    float  pSize = kbyte(_codeSegmentEnd - _codeSegmentStart);
	
    PRINTF("\n");
    PRINTF("ﾌﾟﾛｸﾞﾗﾑ    ｱﾄﾞﾚｽ : ｻｲｽﾞ = %x - %x (%f Kbyte) \n",
	   _codeSegmentStart,
	   _codeSegmentEnd - 1,
	   pSize); 
    PRINTF("ﾌﾚｰﾑﾊﾞｯﾌｧ & zﾊﾞｯﾌｧ ｱﾄﾞﾚｽ : ｻｲｽﾞ = %x - %x (%f Kbyte)\n",
	   _bufferSegmentStart,
	   _bufferSegmentEnd - 1,
	   fSize);
    PRINTF("ﾄｰﾀﾙ ｻｲｽﾞ = %f Kbyte \n", fSize + pSize);
    PRINTF("ﾌﾚｰﾑﾊﾞｯﾌｧ数 = %d\n", CFB_MAX);
#if 0
    PRINTF("ﾜｰﾙﾄﾞﾃﾞｰﾀﾍﾞｰｽのROMｱﾄﾞﾚｽ = %xh \n",
	   _worldDatabaseSegmentRomStart);
#endif
    PRINTF("\n");
    PRINTF("sizeof(ACTOR)=%d\n",sizeof(ACTOR));
    PRINTF("sizeof(ACTORDT)=%d\n",sizeof(ACTORDT));
}
#endif
