TwlIPL/build/tests/NotLaunchRom/src/main.c
aoki_ryoma 3d4c5ef4d3 初版
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2241 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-08-22 10:39:31 +00:00

110 lines
3.8 KiB
C
Raw Blame History

/*---------------------------------------------------------------------------*
Project: TwlSDK - GX - demos - UnitTours/2D_CharBg_1
File: main.c
Copyright 2003 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:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
//---------------------------------------------------------------------------
// A sample that use BG #0 as text mode:
//
// This sample simply displays a sphere on the display.
//
// HOWTO:
// 1. Transfer the character data by GX_LoadBGxChar().
// 2. Transfer the palette data by GX_LoadBGPltt().
// 3. Transfer the screen data by GX_LoadBGxScr().
//
// Do not forget to flush the corresponding cache if you modified the data
// before transfer.
//---------------------------------------------------------------------------
#ifdef SDK_TWL
#include <twl.h>
#else
#include <nitro.h>
#endif
#include "DEMO.h"
#include "data.h"
static u16 sScrnBuf[SCREEN_SIZE]; // Buffer for screen data(BG #0)
#ifdef SDK_TWL
void TwlMain(void)
#else
void NitroMain(void)
#endif
{
//---------------------------------------------------------------------------
// Initialize:
// They enable IRQ interrupts, initialize VRAM, and set BG #0 for text mode.
//---------------------------------------------------------------------------
DEMOInitCommon();
DEMOInitVRAM();
DEMOInitDisplayBG0Only();
//---------------------------------------------------------------------------
// Transmitting the character data and the palette data
//---------------------------------------------------------------------------
GX_LoadBG0Char(d_64_256_bg_schDT, 0, sizeof(d_64_256_bg_schDT));
GX_LoadBGPltt(d_64_256_bg_sclDT, 0, sizeof(d_64_256_bg_sclDT));
{
int i, j;
for (i = 0; i < 8; i++)
{
for (j = 0; j < 8; j++)
{
sScrnBuf[(i * 32) + j] = (u16)((i * 0x10) + j);
}
}
}
// Store the data onto the main memory, and invalidate the cache.
DC_FlushRange(sScrnBuf, sizeof(sScrnBuf));
/* DMA<4D><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F><EFBFBD>W<EFBFBD>X<EFBFBD>^<5E>փA<D683>N<EFBFBD>Z<EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>̂ŃL<C583><4C><EFBFBD>b<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD> Wait <20>͕s<CD95>v */
// DC_WaitWriteBufferEmpty();
// DMA transfer to BG #0 screen
GX_LoadBG0Scr(sScrnBuf, 0, sizeof(sScrnBuf));
DEMOStartDisplay();
//---------------------------------------------------------------------------
// Main Loop
//---------------------------------------------------------------------------
while (1)
{
#ifdef SDK_AUTOTEST
GX_SetBankForLCDC(GX_VRAM_LCDC_C);
EXT_TestSetVRAMForScreenShot(GX_VRAM_LCDC_C);
EXT_TestScreenShot(100, 0xC7953680);
EXT_TestTickCounter();
#endif //SDK_AUTOTEST
OS_WaitVBlankIntr(); // Waiting the end of VBlank interrupt
GX_LoadBG0Scr(sScrnBuf, 0, sizeof(sScrnBuf));
}
}
//---------------------------------------------------------------------------
// VBlank interrupt function:
//
// Interrupt handlers are registered on the interrupt table by OS_SetIRQFunction.
// OS_EnableIrqMask selects IRQ interrupts to enable, and
// OS_EnableIrq enables IRQ interrupts.
// Notice that you have to call 'OS_SetIrqCheckFlag' to check a VBlank interrupt.
//---------------------------------------------------------------------------
void VBlankIntr(void)
{
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
}