mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2834 b08762b0-b915-fc4b-9d8c-17b2551a87ff
157 lines
4.6 KiB
C
157 lines
4.6 KiB
C
/*---------------------------------------------------------------------------*
|
|
Project: TwlSDK - tests - appjumpTest
|
|
File: common.c
|
|
|
|
Copyright 2008 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.
|
|
|
|
$Date:: 2008-08-25#$
|
|
$Rev: 8074 $
|
|
$Author: nishimoto_takashi $
|
|
*---------------------------------------------------------------------------*/
|
|
#include "common.h"
|
|
|
|
static void InitInterrupts(void);
|
|
static void InitHeap(void);
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
関数定義
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: InitCommon
|
|
|
|
Description: 基本的な初期化関数をここで呼ぶ。
|
|
|
|
Arguments: None.
|
|
|
|
Returns: None.
|
|
*---------------------------------------------------------------------------*/
|
|
void InitCommon(void)
|
|
{
|
|
OS_Init();
|
|
OS_InitTick();
|
|
OS_InitAlarm();
|
|
GX_Init();
|
|
GX_DispOff();
|
|
GXS_DispOff();
|
|
|
|
CARD_Init(); // 新規追加
|
|
CARD_Enable(TRUE); // 新規追加
|
|
|
|
InitHeap();
|
|
InitInterrupts();
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: ReadKey
|
|
|
|
Description: キー入力情報を取得し、入力情報構造体を編集する。
|
|
押しトリガ、離しトリガ、押し継続リピートトリガ を検出する。
|
|
|
|
Arguments: pKey - 編集するキー入力情報構造体を指定する。
|
|
|
|
Returns: None.
|
|
*---------------------------------------------------------------------------*/
|
|
void ReadKey(KeyInfo* pKey)
|
|
{
|
|
static u16 repeat_count[12];
|
|
int i;
|
|
u16 r;
|
|
|
|
r = PAD_Read();
|
|
pKey->trg = 0x0000;
|
|
pKey->up = 0x0000;
|
|
pKey->rep = 0x0000;
|
|
|
|
for (i = 0; i < 12; i++)
|
|
{
|
|
if (r & (0x0001 << i))
|
|
{
|
|
if (!(pKey->cnt & (0x0001 << i)))
|
|
{
|
|
pKey->trg |= (0x0001 << i); // 押しトリガ
|
|
repeat_count[i] = 1;
|
|
}
|
|
else
|
|
{
|
|
if (repeat_count[i] > KEY_REPEAT_START)
|
|
{
|
|
pKey->rep |= (0x0001 << i); // 押し継続リピート
|
|
repeat_count[i] = (u16) (KEY_REPEAT_START - KEY_REPEAT_SPAN);
|
|
}
|
|
else
|
|
{
|
|
repeat_count[i]++;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pKey->cnt & (0x0001 << i))
|
|
{
|
|
pKey->up |= (0x0001 << i); // 離しトリガ
|
|
}
|
|
}
|
|
}
|
|
|
|
pKey->cnt = r; // 未加工キー入力
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: InitInterrupts
|
|
|
|
Description: 割り込み設定を初期化する。
|
|
V ブランク割り込みを許可し、割り込みハンドラを設定する。
|
|
|
|
Arguments: None.
|
|
|
|
Returns: None.
|
|
*---------------------------------------------------------------------------*/
|
|
static void InitInterrupts(void)
|
|
{
|
|
// V ブランク割り込み設定
|
|
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
|
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
|
(void)GX_VBlankIntr(TRUE);
|
|
|
|
// 割り込み許可
|
|
(void)OS_EnableIrq();
|
|
(void)OS_EnableInterrupts();
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: InitHeap
|
|
|
|
Description: メインメモリ上のアリーナにてメモリ割当てシステムを初期化する。
|
|
|
|
Arguments: None.
|
|
|
|
Returns: None.
|
|
*---------------------------------------------------------------------------*/
|
|
static void InitHeap(void)
|
|
{
|
|
void* tempLo;
|
|
OSHeapHandle hh;
|
|
|
|
// メインメモリ上のアリーナにヒープをひとつ作成
|
|
tempLo = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1);
|
|
OS_SetArenaLo(OS_ARENA_MAIN, tempLo);
|
|
hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi());
|
|
if (hh < 0)
|
|
{
|
|
// ヒープ作成に失敗した場合は異常終了
|
|
OS_Panic("ARM9: Fail to create heap...\n");
|
|
}
|
|
(void)OS_SetCurrentHeap(OS_ARENA_MAIN, hh);
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
End of file
|
|
*---------------------------------------------------------------------------*/
|