1.Nand Format 2.Write HW Info 3.Write eticket 4.Import TAD 5.Import Nandfirm 6.Inport Norfirm

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@517 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
kamikawa 2008-01-25 06:37:04 +00:00
parent 317b088aca
commit b55f76eef8
46 changed files with 9372 additions and 0 deletions

View File

@ -0,0 +1,68 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - tests - camera-test
# File: Makefile
#
# Copyright 2007 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:: 2007-12-18#$
# $Rev: 3150 $
# $Author: yutaka $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
TARGET_PLATFORM := TWL
#TWL_CODEGEN = THUMB
TWL_PROC = ARM7
TWL_ARCHGEN = LIMITED
TARGET_TEF = main.tef
SRCS = main.c kami_pxi.c formatter.c nvram_misc.c
LINCLUDES = ../common/include $(TWLSDK_ROOT)/build/libraries/spi/ARM7/include
#SRCDIR = # using default
#LCFILE = # using default
LCFILE_SPEC = main.lsf
LCFILE_TEMPLATE = racoon.lcf.template
LDRES_TEMPLATE = racoon.response.template
include $(TWLSDK_ROOT)/build/buildtools/commondefs
ifdef TWLSDK_NOCRYPTO
CCFLAGS += -DSDK_NOCRYPTO
endif
ifndef TWLSDK_NOCRYPTO
MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a'
endif
TWL_LIBS_EX = libcamera_sp$(TWL_LIBSUFFIX).a \
libfatfs_sp$(TWL_LIBSUFFIX).a \
libi2c_sp$(TWL_LIBSUFFIX).a \
libcamera_sp$(TWL_LIBSUFFIX).a \
libcdc_sp$(TWL_LIBSUFFIX).a \
libtpex_sp$(TWL_LIBSUFFIX).a
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: formatter.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef NAND_INITIALIZER_FORMATTER_H_
#define NAND_INITIALIZER_FORMATTER_H_
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
typedef enum {
FORMAT_MODE_QUICK, // Quickフォーマット
FORMAT_MODE_FULL // Fullフォーマット(各パーティション内を0xFFで埋める
} FormatMode;
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
BOOL ExeFormat(FormatMode format_mode);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* NAND_INITIALIZER_FORMATTER_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: kami_pxi.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef TWL_CAMERA_TEST_CAMERATEST_H_
#define TWL_CAMERA_TEST_CAMERATEST_H_
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
void KamiPxiInit( void );
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* TWL_CAMERA_TEST_CAMERATEST_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: nvram.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef FIRM_NVRAM_H_
#define FIRM_NVRAM_H_
#include <twl/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SDK_ARM9
#else // SDK_ARM7
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void NVRAMi_Read(u32 address, void *buf, u32 size);
void NVRAMi_Write(u32 address, void *buf, u32 size);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* FIRM_NVRAM_H_ */
#endif

View File

@ -0,0 +1,157 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - components - racoon.TWL
# File: racoon.lsf
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded insructions, 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:: 2007-12-11#$
# $Rev: 2989 $
# $Author: terui $
#----------------------------------------------------------------------------
#
# Nitro LCF SPEC FILE
#
#--------
Static $(TARGET_NAME)
{
Address 0x02380000
Library crt0.LTD.TWL.o
StackSize 1024 1024
}
#--------
Autoload WRAM
{
Address 0x037c0000
Library libsubpsyscall.a \
libsyscall_sp.twl.a \
$(CW_LIBS) \
libos_sp$(LIBSUFFIX).a \
libmi_sp$(LIBSUFFIX).a \
libpad_sp$(LIBSUFFIX).a \
libpxi_sp$(LIBSUFFIX).a \
libstd_sp$(LIBSUFFIX).a \
libexi_sp$(LIBSUFFIX).a \
libsnd_sp$(LIBSUFFIX).a \
libspi_sp$(LIBSUFFIX).a \
libpm_sp$(LIBSUFFIX).a \
libmath_sp$(LIBSUFFIX).a \
libscfg_sp$(LIBSUFFIX).a \
libtp_sp$(LIBSUFFIX).a \
libmic_sp$(LIBSUFFIX).a \
libfs_sp$(LIBSUFFIX).a \
libcard_sp$(LIBSUFFIX).a \
libi2c_sp$(LIBSUFFIX).a \
libcamera_sp$(LIBSUFFIX).a \
libcdc_sp$(LIBSUFFIX).a \
libtpex_sp$(LIBSUFFIX).a \
libmicex_sp$(LIBSUFFIX).a \
Library libsdio_hcd_twl$(LIBSUFFIX).a \
libsdio_busdriver$(LIBSUFFIX).a \
libsdio_lib$(LIBSUFFIX).a \
Object * (.etable)
Object * (.wram)
Object * (.ltdwram)
Object $(OBJDIR)/main.o
Object $(OBJDIR)/kami_pxi.o
Object $(OBJDIR)/formatter.o
Object $(OBJDIR)/nvram_misc.o
# caches in fatfs library, that should be on WRAM.
# 2007/12/11 OBJECT() による .bss シンボルのリンクがうまくいかないので、
# 変数定義箇所に pragma で .ltdwram セクションに含まれるように暫定対策しました。
#Object OBJECT( FATFSi___mem_drives_structures , libfatfs_sp$(LIBSUFFIX).a) (.bss)
#####
# Sub-routines in WL library , that should be on WRAM.
# in TaskMan.o
Object OBJECT( MainTaskRoutine , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AddTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( DeleteTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( LowestIdleTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ExecuteMessage , libwl_sp$(LIBSUFFIX).a ) (.text)
# in BufMan.o
Object OBJECT( NewHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( DeleteHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AllocateHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ReleaseHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( MoveHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AddHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( GetHeapBufNextAdrs , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlCmdIf.o
Object OBJECT( RequestCmdTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( SendMessageToWmDirect , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlNic.o
Object OBJECT( WStart , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WStop , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WSetStaState , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlIntr.o
Object OBJECT( WlIntr , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrPreTbtt , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTbtt , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrActEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
# Object OBJECT( WlIntrAckCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTxErr , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrRxCntup , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrRxEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrMpEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrStartTx , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrStartRx , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( SetParentTbttTxq , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( MacBugTxMp , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AdjustRingPointer , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( CheckKeyTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlIntrTask.o
Object OBJECT( WlIntrTxBeaconTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrRxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrMpEndTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( SetParentTbttTxqTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( TakeoutRxFrame , libwl_sp$(LIBSUFFIX).a ) (.text)
# in TxCtrl.o
Object OBJECT( InitTxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text)
# in RxCtrl.o
Object OBJECT( InitRxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WaitLoop.o
Object OBJECT( WaitLoop_Rxpe , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_Waitus , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_ClrAid , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_BbpAccess , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_RfAccess , libwl_sp$(LIBSUFFIX).a ) (.text)
}
#--------
Ltdautoload LTDMAIN
{
Address 0x02f88000
Object * (.ltdmain)
Library libnvram_sp$(LIBSUFFIX).a
Library librtc_sp$(LIBSUFFIX).a
Library librompatch_sp$(LIBSUFFIX).a \
libwm_sp$(LIBSUFFIX).a \
libnwm_sp$(LIBSUFFIX).a \
libARM7athdrv$(LIBSUFFIX).a \
libwvr_sp$(LIBSUFFIX).a \
libwl_sp$(LIBSUFFIX).a
Library libfatfs_sp$(LIBSUFFIX).a \
$(USE_CRYPTO_LIBS)
Library $(ISDBG_LIBS_TWL)
Library $(ISDBG_LIBS_NITRO)
Library libstubsistd_sp.TWL.LTD.a \
libstubsisd_sp.TWL.LTD.a
}

View File

@ -0,0 +1,930 @@
#---------------------------------------------------------------------------
# Project: TwlSDK - components - racoon.TWL
# File: racoon.lcf.template
#
# Copyright 2007 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:: 2007-11-12#$
# $Rev: 2249 $
# $Author: terui $
#---------------------------------------------------------------------------
MEMORY
{
<STATIC.NAME> (RWX) : ORIGIN = <STATIC.ADDRESS>, LENGTH = 0x0 > <STATIC.NAME><PROPERTY.FLXSUFFIX>
<FOREACH.AUTOLOADS>
<AUTOLOAD.NAME> (RWX) : ORIGIN = <AUTOLOAD.ADDRESS>, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.FLXSUFFIX>
<END.AUTOLOADS>
binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.FLXSUFFIX>
binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.FLXSUFFIX>
<PROPERTY.OVERLAYDEFS>F (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.OVERLAYDEFS><PROPERTY.FLXSUFFIX>
<PROPERTY.OVERLAYTABLE>F (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.OVERLAYTABLE><PROPERTY.FLXSUFFIX>
<FOREACH.OVERLAYS>
<OVERLAY.NAME> (RWXO): ORIGIN = <OVERLAY.ADDRESS>, LENGTH = 0x0 > <OVERLAY.NAME><PROPERTY.FLXSUFFIX>
<END.OVERLAYS>
check.WORKRAM (RWX) : ORIGIN = 0x037c0000, LENGTH = 0x50000 > workram.check
binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > <STATIC.NAME><PROPERTY.LTDSUFFIX>
<FOREACH.LTDAUTOLOADS>
<LTDAUTOLOAD.NAME> (RWX) : ORIGIN = <LTDAUTOLOAD.ADDRESS>, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.LTDSUFFIX>
<END.LTDAUTOLOADS>
binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.LTDSUFFIX>
<PROPERTY.LTDOVERLAYDEFS>L (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.LTDOVERLAYDEFS><PROPERTY.LTDSUFFIX>
<PROPERTY.LTDOVERLAYTABLE>L (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.LTDOVERLAYTABLE><PROPERTY.LTDSUFFIX>
<FOREACH.LTDOVERLAYS>
<LTDOVERLAY.NAME> (RWXO): ORIGIN = <LTDOVERLAY.ADDRESS>, LENGTH = 0x0 > <LTDOVERLAY.NAME><PROPERTY.LTDSUFFIX>
<END.LTDOVERLAYS>
check.LTDMAIN (RWX) : ORIGIN = 0x02f88000, LENGTH = 0x74000 > ltdmain.check
}
KEEP_SECTION
{
.sinit
}
SECTIONS
{
############################ STATIC #################################
.<STATIC.NAME>:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.STATIC.SEARCHSYMBOLS>
SEARCH_SYMBOL <STATIC.SEARCHSYMBOL>;
<END.STATIC.SEARCHSYMBOLS>
#
# TEXT BLOCK: READ ONLY
#
SDK_STATIC_START =.;
SDK_STATIC_TEXT_START =.;
#:::::::::: text/rodata
OBJECT(_start,*)
<FOREACH.STATIC.OBJECTS=.text>
<STATIC.OBJECT=.text:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.text>
<STATIC.LIBRARY=.text:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.rodata>
<STATIC.OBJECT=.rodata:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.rodata>
<STATIC.LIBRARY=.rodata:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.init>
<STATIC.OBJECT=.init:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.init>
<STATIC.LIBRARY=.init:t>
<END.STATIC.LIBRARIES>
. = ALIGN(4);
SDK_STATIC_SINIT_START =.;
#:::::::::: ctor
<FOREACH.STATIC.OBJECTS=.ctor>
<STATIC.OBJECT=.ctor:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.ctor>
<STATIC.LIBRARY=.ctor:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.sinit>
<STATIC.OBJECT=.sinit:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.sinit>
<STATIC.LIBRARY=.sinit:t>
<END.STATIC.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_STATIC_SINIT_END =.;
#:::::::::: text/rodata
SDK_STATIC_TEXT_END =.;
#
# DATA BLOCK: READ WRITE
#
. = ALIGN(4);
SDK_STATIC_DATA_START =.;
#:::::::::: data
<FOREACH.STATIC.OBJECTS=.sdata>
<STATIC.OBJECT=.sdata:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.sdata>
<STATIC.LIBRARY=.sdata:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.data>
<STATIC.OBJECT=.data:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.data>
<STATIC.LIBRARY=.data:t>
<END.STATIC.LIBRARIES>
#:::::::::: data
SDK_STATIC_DATA_END =.;
. = ALIGN(4);
SDK_STATIC_END =.;
SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START;
SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START;
SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START;
__sinit__ = SDK_STATIC_SINIT_START; # for static initializer
} > <STATIC.NAME>
.<STATIC.NAME>.bss:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.STATIC.SEARCHSYMBOLS>
SEARCH_SYMBOL <STATIC.SEARCHSYMBOL>;
<END.STATIC.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_STATIC_BSS_START =.;
#:::::::::: bss
<FOREACH.STATIC.OBJECTS=.sbss>
<STATIC.OBJECT=.sbss:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.sbss>
<STATIC.LIBRARY=.sbss:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.bss>
<STATIC.OBJECT=.bss:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.bss>
<STATIC.LIBRARY=.bss:t>
<END.STATIC.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_STATIC_BSS_END = .;
SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START;
} >> <STATIC.NAME>
############################ AUTOLOADS ##############################
SDK_AUTOLOAD.WRAM.START = 0x037c0000;
SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START;
SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START;
SDK_AUTOLOAD.WRAM.SIZE = 0;
SDK_AUTOLOAD.WRAM.BSS_SIZE = 0;
SDK_AUTOLOAD_START = SDK_STATIC_END;
SDK_AUTOLOAD_SIZE = 0;
SDK_AUTOLOAD_NUMBER = <NUMBER.AUTOLOADS>;
<FOREACH.AUTOLOADS>
.<AUTOLOAD.NAME>:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.AUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <AUTOLOAD.SEARCHSYMBOL>;
<END.AUTOLOAD.SEARCHSYMBOLS>
#
# TEXT BLOCK: READ ONLY
#
SDK_AUTOLOAD_<AUTOLOAD.NAME>_ID =<AUTOLOAD.ID>;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.ID =<AUTOLOAD.ID>;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.START =.;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<FOREACH.AUTOLOAD.OBJECTS=.text>
<AUTOLOAD.OBJECT=.text:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.text>
<AUTOLOAD.LIBRARY=.text:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.etable>
<AUTOLOAD.OBJECT=.exception:t>
. = ALIGN(4);
SDK_STATIC_ETABLE_START =.;
__exception_table_start__ =.;
EXCEPTION
__exception_table_end__ =.;
SDK_STATIC_ETABLE_END =.;
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.OBJECTS=.rodata>
<AUTOLOAD.OBJECT=.rodata:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.rodata>
<AUTOLOAD.LIBRARY=.rodata:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.init>
<AUTOLOAD.OBJECT=.init:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.init>
<AUTOLOAD.LIBRARY=.init:t>
<END.AUTOLOAD.LIBRARIES>
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.SINIT_START =.;
#:::::::::: ctor
<FOREACH.AUTOLOAD.OBJECTS=.ctor>
<AUTOLOAD.OBJECT=.ctor:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.ctor>
<AUTOLOAD.LIBRARY=.ctor:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.sinit>
<AUTOLOAD.OBJECT=.sinit:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.sinit>
<AUTOLOAD.LIBRARY=.sinit:t>
<END.AUTOLOAD.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_AUTOLOAD.<AUTOLOAD.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE BLOCK
#
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_START =.;
#:::::::::: data
<FOREACH.AUTOLOAD.OBJECTS=.wram>
<AUTOLOAD.OBJECT=.wram:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.wram>
<AUTOLOAD.LIBRARY=.wram:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.ltdwram>
<AUTOLOAD.OBJECT=.ltdwram:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.ltdwram>
<AUTOLOAD.LIBRARY=.ltdwram:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.sdata>
<AUTOLOAD.OBJECT=.sdata:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.sdata>
<AUTOLOAD.LIBRARY=.sdata:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.data>
<AUTOLOAD.OBJECT=.data:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.data>
<AUTOLOAD.LIBRARY=.data:t>
<END.AUTOLOAD.LIBRARIES>
#:::::::::: data
SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.END =.;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_START;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_START;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.START;
SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD.<AUTOLOAD.NAME>.SIZE;
} > <AUTOLOAD.NAME>
.<AUTOLOAD.NAME>.bss:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.AUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <AUTOLOAD.SEARCHSYMBOL>;
<END.AUTOLOAD.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_START = .;
#:::::::::: bss
<FOREACH.AUTOLOAD.OBJECTS=.wram>
<AUTOLOAD.OBJECT=.wram.bss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.wram>
<AUTOLOAD.LIBRARY=.wram.bss:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.ltdwram>
<AUTOLOAD.OBJECT=.ltdwram.bss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.ltdwram>
<AUTOLOAD.LIBRARY=.ltdwram.bss:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.sbss>
<AUTOLOAD.OBJECT=.sbss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.sbss>
<AUTOLOAD.LIBRARY=.sbss:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.bss>
<AUTOLOAD.OBJECT=.bss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.bss>
<AUTOLOAD.LIBRARY=.bss:t>
<END.AUTOLOAD.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_END = .;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_START;
} >> <AUTOLOAD.NAME>
<END.AUTOLOADS>
SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START;
SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END;
SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END;
SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE;
SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE;
############################ AUTOLOAD_INFO ##########################
.binary.AUTOLOAD_INFO:
{
<FOREACH.AUTOLOADS>
WRITEW ADDR(.<AUTOLOAD.NAME>);
WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.SIZE;
WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.SINIT_START;
WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_SIZE;
<END.AUTOLOADS>
} > binary.AUTOLOAD_INFO
SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE;
SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO);
SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO);
############################ STATIC_FOOTER ##########################
.binary.STATIC_FOOTER:
{
WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE
WRITEW _start_ModuleParams - ADDR(.<STATIC.NAME>);
WRITEW 0; # NO DIGEST
WRITEW _start_LtdModuleParams - ADDR(.<STATIC.NAME>);
} > binary.STATIC_FOOTER
############################ OVERLAYS ###############################
SDK_OVERLAY_NUMBER = <NUMBER.OVERLAYS>;
<FOREACH.OVERLAYS>
.<OVERLAY.NAME>:<OVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.OVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <OVERLAY.SEARCHSYMBOL>;
<END.OVERLAY.SEARCHSYMBOLS>
#
# TEXT BLOCK: READ ONLY
#
SDK_OVERLAY_<OVERLAY.NAME>_ID =<OVERLAY.ID>; ### SEGMENT <OVERLAY.NAME> OVERLAY ID
SDK_OVERLAY.<OVERLAY.NAME>.ID =<OVERLAY.ID>;
SDK_OVERLAY.<OVERLAY.NAME>.START =.;
SDK_OVERLAY.<OVERLAY.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<FOREACH.OVERLAY.OBJECTS=.text>
<OVERLAY.OBJECT=.text:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.text>
<OVERLAY.LIBRARY=.text:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.rodata>
<OVERLAY.OBJECT=.rodata:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.rodata>
<OVERLAY.LIBRARY=.rodata:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.init>
<OVERLAY.OBJECT=.init:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.init>
<OVERLAY.LIBRARY=.init:t>
<END.OVERLAY.LIBRARIES>
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.SINIT_START =.;
#:::::::::: ctor
<FOREACH.OVERLAY.OBJECTS=.ctor>
<OVERLAY.OBJECT=.ctor:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.ctor>
<OVERLAY.LIBRARY=.ctor:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.sinit>
<OVERLAY.OBJECT=.sinit:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.sinit>
<OVERLAY.LIBRARY=.sinit:t>
<END.OVERLAY.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_OVERLAY.<OVERLAY.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_OVERLAY.<OVERLAY.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE
#
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.DATA_START =.;
#:::::::::: data
<FOREACH.OVERLAY.OBJECTS=.sdata>
<OVERLAY.OBJECT=.sdata:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.sdata>
<OVERLAY.LIBRARY=.sdata:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.data>
<OVERLAY.OBJECT=.data:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.data>
<OVERLAY.LIBRARY=.data:t>
<END.OVERLAY.LIBRARIES>
#:::::::::: data
SDK_OVERLAY.<OVERLAY.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.END =.;
SDK_OVERLAY.<OVERLAY.NAME>.TEXT_SIZE = SDK_OVERLAY.<OVERLAY.NAME>.TEXT_END - SDK_OVERLAY.<OVERLAY.NAME>.TEXT_START;
SDK_OVERLAY.<OVERLAY.NAME>.DATA_SIZE = SDK_OVERLAY.<OVERLAY.NAME>.DATA_END - SDK_OVERLAY.<OVERLAY.NAME>.DATA_START;
SDK_OVERLAY.<OVERLAY.NAME>.SIZE = SDK_OVERLAY.<OVERLAY.NAME>.END - SDK_OVERLAY.<OVERLAY.NAME>.START;
} > <OVERLAY.NAME>
.<OVERLAY.NAME>.bss:<OVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.OVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <OVERLAY.SEARCHSYMBOL>;
<END.OVERLAY.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_OVERLAY.<OVERLAY.NAME>.BSS_START = .;
#:::::::::: bss
<FOREACH.OVERLAY.OBJECTS=.bss>
<OVERLAY.OBJECT=.bss:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.bss>
<OVERLAY.LIBRARY=.bss:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.sbss>
<OVERLAY.OBJECT=.sbss:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.sbss>
<OVERLAY.LIBRARY=.sbss:t>
<END.OVERLAY.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.BSS_END = .;
SDK_OVERLAY.<OVERLAY.NAME>.BSS_SIZE = SDK_OVERLAY.<OVERLAY.NAME>.BSS_END - SDK_OVERLAY.<OVERLAY.NAME>.BSS_START;
} >> <OVERLAY.NAME>
<END.OVERLAYS>
############################ OVERLAYDEFS ############################
.<PROPERTY.OVERLAYDEFS>F:
{
### <STATIC.NAME> module information
WRITEW ADDR(.<STATIC.NAME>); # load address
WRITEW _start; # entry address
WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module
WRITEW _start_AutoloadDoneCallback; # callback autoload done
### overlay filename
<FOREACH.OVERLAYS>
WRITES ("<OVERLAY.NAME><PROPERTY.FLXSUFFIX>"); # Overlay <OVERLAY.ID>
<END.OVERLAYS>
} > <PROPERTY.OVERLAYDEFS>F
############################ OVERLAYTABLE ###########################
.<PROPERTY.OVERLAYTABLE>F:
{
<FOREACH.OVERLAYS>
WRITEW <OVERLAY.ID>; # overlay ID
WRITEW ADDR(.<OVERLAY.NAME>); # load address
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.SIZE; # size of module
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.BSS_SIZE; # size of bss
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.SINIT_START; # start address of static init
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.SINIT_END; # end address of static init
WRITEW <OVERLAY.ID>; # ROM file ID
WRITEW 0; # Reserved
<END.OVERLAYS>
} > <PROPERTY.OVERLAYTABLE>F
############################ OTHERS #################################
SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END;
SDK_IRQ_STACKSIZE = <STATIC.IRQSTACKSIZE>; # allocated in WRAM
SDK_SYS_STACKSIZE = <STATIC.STACKSIZE>; # allocated in WRAM
SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1;
.check.WORKRAM:
{
. = . + SDK_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN;
} > check.WORKRAM
########################### LTDAUTOLOADS ############################
SDK_LTDAUTOLOAD.LTDMAIN.START = 0x02f88000;
SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START;
SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START;
SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0;
SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0;
#### SDK_LTDAUTOLOAD.LTDWRAM.START の位置は間違っているかも
SDK_LTDAUTOLOAD.LTDWRAM.START = 0x03800000;
SDK_LTDAUTOLOAD.LTDWRAM.END = SDK_LTDAUTOLOAD.LTDWRAM.START;
SDK_LTDAUTOLOAD.LTDWRAM.BSS_END = SDK_LTDAUTOLOAD.LTDWRAM.START;
SDK_LTDAUTOLOAD.LTDWRAM.SIZE = 0;
SDK_LTDAUTOLOAD.LTDWRAM.BSS_SIZE = 0;
####
SDK_LTDAUTOLOAD_TOP_START = 0x02e80000;
SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC 領域が無い代わりに 4 bytes のダミーがバイナリファイルの先頭に入る #
SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE;
SDK_LTDAUTOLOAD_SIZE = 0;
SDK_LTDAUTOLOAD_NUMBER = <NUMBER.LTDAUTOLOADS>;
.binary.LTDAUTOLOAD_TOP:
{
WRITEW 0;
} > binary.LTDAUTOLOAD_TOP
<FOREACH.LTDAUTOLOADS>
.<LTDAUTOLOAD.NAME>:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDAUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDAUTOLOAD.SEARCHSYMBOL>;
<END.LTDAUTOLOAD.SEARCHSYMBOLS>
SDK_LTDAUTOLOAD_<LTDAUTOLOAD.NAME>_ID =<LTDAUTOLOAD.ID>;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.ID =<LTDAUTOLOAD.ID>;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.START =.;
#
# TEXT BLOCK: READ ONLY
#
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<FOREACH.LTDAUTOLOAD.OBJECTS=.text>
<LTDAUTOLOAD.OBJECT=.text:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.text>
<LTDAUTOLOAD.LIBRARY=.text:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.rodata>
<LTDAUTOLOAD.OBJECT=.rodata:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.rodata>
<LTDAUTOLOAD.LIBRARY=.rodata:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.init>
<LTDAUTOLOAD.OBJECT=.init:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.init>
<LTDAUTOLOAD.LIBRARY=.init:t>
<END.LTDAUTOLOAD.LIBRARIES>
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SINIT_START =.;
#:::::::::: ctor
<FOREACH.LTDAUTOLOAD.OBJECTS=.ctor>
<LTDAUTOLOAD.OBJECT=.ctor:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ctor>
<LTDAUTOLOAD.LIBRARY=.ctor:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.sinit>
<LTDAUTOLOAD.OBJECT=.sinit:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.sinit>
<LTDAUTOLOAD.LIBRARY=.sinit:t>
<END.LTDAUTOLOAD.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE BLOCK
#
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_START =.;
#:::::::::: data
<FOREACH.LTDAUTOLOAD.OBJECTS=.sdata>
<LTDAUTOLOAD.OBJECT=.sdata:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.sdata>
<LTDAUTOLOAD.LIBRARY=.sdata:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.data>
<LTDAUTOLOAD.OBJECT=.data:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.data>
<LTDAUTOLOAD.LIBRARY=.data:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.ltdmain>
<LTDAUTOLOAD.OBJECT=.ltdmain:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdmain>
<LTDAUTOLOAD.LIBRARY=.ltdmain:t>
<END.LTDAUTOLOAD.LIBRARIES>
#:::::::::: data
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.END =.;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_START;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_START;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.START;
SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SIZE;
} > <LTDAUTOLOAD.NAME>
.<LTDAUTOLOAD.NAME>.bss:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDAUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDAUTOLOAD.SEARCHSYMBOL>;
<END.LTDAUTOLOAD.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_START =.;
#:::::::::: bss
<FOREACH.LTDAUTOLOAD.OBJECTS=.sbss>
<LTDAUTOLOAD.OBJECT=.sbss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.sbss>
<LTDAUTOLOAD.LIBRARY=.sbss:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.bss>
<LTDAUTOLOAD.OBJECT=.bss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.bss>
<LTDAUTOLOAD.LIBRARY=.bss:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.ltdmain>
<LTDAUTOLOAD.OBJECT=.ltdmain.bss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdmain>
<LTDAUTOLOAD.LIBRARY=.ltdmain.bss:t>
<END.LTDAUTOLOAD.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_END =.;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_START;
} >> <LTDAUTOLOAD.NAME>
<END.LTDAUTOLOADS>
SDK_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START;
SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END;
SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END;
SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE;
SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE;
SDK_LTDAUTOLOAD_LTDWRAM_START = SDK_LTDAUTOLOAD.LTDWRAM.START;
SDK_LTDAUTOLOAD_LTDWRAM_END = SDK_LTDAUTOLOAD.LTDWRAM.END;
SDK_LTDAUTOLOAD_LTDWRAM_BSS_END = SDK_LTDAUTOLOAD.LTDWRAM.BSS_END;
SDK_LTDAUTOLOAD_LTDWRAM_SIZE = SDK_LTDAUTOLOAD.LTDWRAM.SIZE;
SDK_LTDAUTOLOAD_LTDWRAM_BSS_SIZE = SDK_LTDAUTOLOAD.LTDWRAM.BSS_SIZE;
######################### LTDAUTOLOAD_INFO ##########################
.binary.LTDAUTOLOAD_INFO:
{
<FOREACH.LTDAUTOLOADS>
WRITEW ADDR(.<LTDAUTOLOAD.NAME>);
WRITEW SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SIZE;
WRITEW SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SINIT_START;
WRITEW SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_SIZE;
<END.LTDAUTOLOADS>
} > binary.LTDAUTOLOAD_INFO
SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE;
SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO);
SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO);
########################### LTDOVERLAYS #############################
SDK_LTDOVERLAY_NUMBER = <NUMBER.LTDOVERLAYS>;
<FOREACH.LTDOVERLAYS>
.<LTDOVERLAY.NAME>:<LTDOVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDOVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDOVERLAY.SEARCHSYMBOL>;
<END.LTDOVERLAY.SEARCHSYMBOLS>
SDK_LTDOVERLAY_<LTDOVERLAY.NAME>_ID =<LTDOVERLAY.ID>;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.ID =<LTDOVERLAY.ID>;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.START =.;
#
# TEXT BLOCK: READ ONLY
#
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<FOREACH.LTDOVERLAY.OBJECTS=.text>
<LTDOVERLAY.OBJECT=.text:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.text>
<LTDOVERLAY.LIBRARY=.text:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.rodata>
<LTDOVERLAY.OBJECT=.rodata:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.rodata>
<LTDOVERLAY.LIBRARY=.rodata:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.init>
<LTDOVERLAY.OBJECT=.init:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.init>
<LTDOVERLAY.LIBRARY=.init:t>
<END.LTDOVERLAY.LIBRARIES>
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_START =.;
#:::::::::: ctor
<FOREACH.LTDOVERLAY.OBJECTS=.ctor>
<LTDOVERLAY.OBJECT=.ctor:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.ctor>
<LTDOVERLAY.LIBRARY=.ctor:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.sinit>
<LTDOVERLAY.OBJECT=.sinit:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.sinit>
<LTDOVERLAY.LIBRARY=.sinit:t>
<END.LTDOVERLAY.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE
#
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_START =.;
#:::::::::: data
<FOREACH.LTDOVERLAY.OBJECTS=.sdata>
<LTDOVERLAY.OBJECT=.sdata:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.sdata>
<LTDOVERLAY.LIBRARY=.sdata:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.data>
<LTDOVERLAY.OBJECT=.data:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.data>
<LTDOVERLAY.LIBRARY=.data:t>
<END.LTDOVERLAY.LIBRARIES>
#:::::::::: data
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.END =.;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_START;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_START;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.START;
} > <LTDOVERLAY.NAME>
.<LTDOVERLAY.NAME>.bss:<LTDOVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDOVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDOVERLAY.SEARCHSYMBOL>;
<END.LTDOVERLAY.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_START =.;
#:::::::::: bss
<FOREACH.LTDOVERLAY.OBJECTS=.bss>
<LTDOVERLAY.OBJECT=.bss:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.bss>
<LTDOVERLAY.LIBRARY=.bss:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.sbss>
<LTDOVERLAY.OBJECT=.sbss:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.sbss>
<LTDOVERLAY.LIBRARY=.sbss:t>
<END.LTDOVERLAY.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_END =.;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_START;
} >> <LTDOVERLAY.NAME>
<END.LTDOVERLAYS>
########################## LTDOVERLAYDEFS ###########################
.<PROPERTY.LTDOVERLAYDEFS>L:
{
### TWL limited extended static module information
WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address
WRITEW 0; # padding
WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module
WRITEW 0; # padding
### TWL limited overlay filename
<FOREACH.LTDOVERLAYS>
WRITES ("<LTDOVERLAY.NAME><PROPERTY.LTDSUFFIX>");
<END.LTDOVERLAYS>
} > <PROPERTY.LTDOVERLAYDEFS>L
######################### LTDOVERLAYTABLE ###########################
.<PROPERTY.LTDOVERLAYTABLE>L:
{
<FOREACH.LTDOVERLAYS>
WRITES <LTDOVERLAY.ID> # overlay ID
WRITEW ADDR(.<LTDOVERLAY.NAME>); # load address
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SIZE; # size of module
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_SIZE; # size of bss
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_START; # start address of static init
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_END; # end address of static init
WRITEW <LTDOVERLAY.ID> # ROM file ID
WRITEW 0; # Reserved
<END.LTDOVERLAYS>
} > <PROPERTY.LTDOVERLAYTABLE>L
############################ OTHERS #################################
SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END;
.check.LTDMAIN:
{
. = SDK_SUBPRIV_ARENA_LO;
} > check.LTDMAIN
}

View File

@ -0,0 +1,40 @@
<FOREACH.STATIC.OBJECTS:f>
<STATIC.OBJECT>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES:f>
-l<STATIC.LIBRARY>
<END.STATIC.LIBRARIES>
<FOREACH.AUTOLOADS>
<FOREACH.AUTOLOAD.OBJECTS:f>
<AUTOLOAD.OBJECT>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES:f>
-l<AUTOLOAD.LIBRARY>
<END.AUTOLOAD.LIBRARIES>
<END.AUTOLOADS>
<FOREACH.OVERLAYS>
-og <OVERLAY.GROUP>,0 -ol <OVERLAY.NAME>
<FOREACH.OVERLAY.OBJECTS:f>
<OVERLAY.OBJECT>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES:f>
-l<OVERLAY.LIBRARY>
<END.OVERLAY.LIBRARIES>
<END.OVERLAYS>
<FOREACH.LTDAUTOLOADS>
<FOREACH.LTDAUTOLOAD.OBJECTS:f>
<LTDAUTOLOAD.OBJECT>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES:f>
-l<LTDAUTOLOAD.LIBRARY>
<END.LTDAUTOLOAD.LIBRARIES>
<END.LTDAUTOLOADS>
<FOREACH.LTDOVERLAYS>
-og <LTDOVERLAY.GROUP>,0 -ol <LTDOVERLAY.NAME>
<FOREACH.LTDOVERLAY.OBJECTS:f>
<LTDOVERLAY.OBJECT>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES:f>
-l<LTDOVERLAY.LIBRARY>
<END.LTDOVERLAY.LIBRARIES>
<END.LTDOVERLAYS>

View File

@ -0,0 +1,420 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: formatter.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <nitro/types.h>
#include <twl/init/crt0.h>
#include <twl/memorymap_sp.h>
#include <twl/os.h>
#include <twl/spi.h>
#include <twl/fatfs.h>
#include <nitro/pad.h>
#include <nitro/std.h>
#include <nitro/card.h>
#include "formatter.h"
extern BOOL FATFSi_nandFillPartition( int partition_no, u32* buf, u32 blocks);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
typedef struct FileProperty {
u32 length;
const char *path;
}FileProperty;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define ERROR_RETURN() { OS_TPrintf("FATAL ERROR OCCURED %s %s\n", __FILE__, __LINE__); return 0; }
// ここを編集したら、SDKのFATFS_Init内の同パラメータも修正する必要がある。
#define NAND_SIZE 245 // 256MB mobiNANDでの使用可能サイズiNANDでは違う値になる。未定。
#define PARTITION_RAW_SIZE 4
#define PARTITION_0_SIZE 213
#define PARTITION_1_SIZE ( NAND_SIZE - PARTITION_RAW_SIZE - PARTITION_0_SIZE )
#define NAND_FAT_PARTITION_NUM 2 // FATパーティション数RAWパーティションを除く
// const data--------------------------------------------------------
//#define NAND_SEPARATE_READ
#define FS_READ_BLOCK_SIZE ( 2 * 1024 )
#define FATFS_CLUSTER_SIZE ( 16 * 1024 )
// FATFSのクラスタサイズは16KBなので、データサイズが決まっていないものは、余裕を持たせて16KBにしておく
static const FileProperty s_fileList[] = {
{ 128, "F:/sys/ID.sgn" }, // 現状、全部サイズは適当。中身も空。
{ FATFS_CLUSTER_SIZE, "F:/sys/HWINFO.dat" },
{ FATFS_CLUSTER_SIZE, "F:/shared1/TWLCFG0.dat" },
{ FATFS_CLUSTER_SIZE, "F:/shared1/TWLCFG1.dat" }, // ミラー
// { FATFS_CLUSTER_SIZE, "F:/shared1/WIFICFG0.dat" },
// { FATFS_CLUSTER_SIZE, "F:/shared1/WIFICFG1.dat" }, // ミラー
{ 0, NULL },
};
static const char *s_pDirList0[] = {
(const char *)"sys",
(const char *)"title",
(const char *)"ticket",
(const char *)"shared1",
(const char *)"import",
(const char *)"tmp",
NULL,
};
static const char *s_pDirList1[] = {
(const char *)"photo",
(const char *)"shared2",
NULL,
};
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL CreateDirectory( const char *pDrive, const char **ppDirList );
static BOOL CheckDirectory ( const char *pDrive, const char **ppDirList );
static BOOL CreateFile( const FileProperty *pFileList );
static BOOL CheckFile ( const FileProperty *pFileList );
static int MY_ReadFile( FATFSFileHandle file, void *pBuffer, int length );
/*---------------------------------------------------------------------------*
Name: ExeFormat
Description: Nandのフォーマットを行います
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
BOOL
ExeFormat(FormatMode format_mode)
{
u32 *init_datbuf;
int nand_fat_partition_num;
init_datbuf = OS_Alloc( 512*16 );
if( init_datbuf == NULL ) {
OS_TPrintf( "memory allocate error.\n" );
ERROR_RETURN();
}
MI_CpuFill8( init_datbuf, 0xFF, 512*16);
// NANDをフォーマット
{
int i;
/* パーティションサイズをプロンプトから設定 */
u32 partition_MB_size[5];
partition_MB_size[0] = PARTITION_RAW_SIZE; // RAW領域
partition_MB_size[1] = PARTITION_0_SIZE; // FAT0領域
partition_MB_size[2] = PARTITION_1_SIZE; // FAT1領域
nand_fat_partition_num = NAND_FAT_PARTITION_NUM;
// F G ドライブアンマウント
for( i=0; i<nand_fat_partition_num; i++) {
char drive[4];
STD_TSPrintf( drive, "%c:", 'F'+i);
FATFS_UnmountDrive( drive);
}
// NANDのパーティションを指定
// sizeInMB : パーティションサイズをメガバイト単位で格納した配列
// partitions : パーティション総数
if (FATFSi_SetNANDPartitions(partition_MB_size, nand_fat_partition_num))
{
// マウント
if (FATFS_MountDrive("F", FATFS_MEDIA_TYPE_NAND, 0))
{
const char *path = "F:"; // "F:"がFAT0パーティションになる。
// デフォルトドライブ設定
if (!FATFS_SetDefaultDrive(path))
{
return FALSE;
}
// 指定のパスが指すドライブを含むメディア全体を初期化
else if(!FATFS_FormatMedia(path))
{
return FALSE;
}
// パーティション内を指定バッファの内容でフィルする
else if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( 0, init_datbuf, 16))
{
return FALSE;
}
// 指定のパスが指すドライブ全体を初期化
else if(!FATFS_FormatDrive(path))
{
return FALSE;
}
else
{
// F以降のドライブの初期化
for (i = 1; i < nand_fat_partition_num; ++i)
{
char drive[4];
STD_TSPrintf(drive, "%c:", 'F' + i);
if(!FATFS_MountDrive(drive, FATFS_MEDIA_TYPE_NAND, (u32)i))
{
return FALSE;
}
}
for (i = 1; i < nand_fat_partition_num; ++i)
{
char drive[4];
STD_TSPrintf(drive, "%c:", 'F' + i);
if (format_mode == FORMAT_MODE_FULL && !FATFSi_nandFillPartition( i, init_datbuf, 16))
{
return FALSE;
}
else if (!FATFS_FormatDrive(drive))
{
return FALSE;
}
}
}
}
}
}
// メモリ解放
OS_Free( init_datbuf );
// ディレクトリ生成&チェック
if (!CreateDirectory( "F:", s_pDirList0 )) { return FALSE; }
if (!CheckDirectory ( "F:", s_pDirList0 )) { return FALSE; }
if (!CreateDirectory( "G:", s_pDirList1 )) { return FALSE; }
if (!CheckDirectory ( "G:", s_pDirList1 )) { return FALSE; }
// ファイル生成&チェック
if (!CreateFile( &s_fileList[0] )) { return FALSE; }
if (!CheckFile ( &s_fileList[0] )) { return FALSE; }
// F,Gドライブアンマウント
{
int i;
for( i=0; i<nand_fat_partition_num; i++) {
char drive[4];
STD_TSPrintf( drive, "%c:", 'F'+i);
FATFS_UnmountDrive( drive);
}
}
// デフォルトマウント状態に戻しておく
FATFS_MountDrive("F", FATFS_MEDIA_TYPE_NAND, 0);
FATFS_MountDrive("G", FATFS_MEDIA_TYPE_SD, 0);
// 成功
return TRUE;
}
// ディレクトリ作成
static BOOL CreateDirectory( const char *pDrive, const char **ppDirList )
{
// デフォルトドライブの指定
OS_TPrintf( "\nCreate directory : %s\n", pDrive );
if( !FATFS_SetDefaultDrive( pDrive ) ) {
ERROR_RETURN();
}
// 指定されたディレクトリをルートに作成
while( *ppDirList ) {
OS_TPrintf( " %s...", *ppDirList );
if( !FATFS_CreateDirectory( *ppDirList, "rwxrwxrwx") ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
OS_TPrintf( "ok.\n" );
ppDirList++;
}
return TRUE;
}
// ディレクトリ存在チェック
static BOOL CheckDirectory( const char *pDrive, const char **ppDirList )
{
// デフォルトドライブの指定
OS_TPrintf( "\nCheck directory : %s\n", pDrive );
if( !FATFS_SetDefaultDrive( pDrive ) ) {
ERROR_RETURN();
}
// 指定されたディレクトリをチェック
while( *ppDirList ) {
FATFSDirectoryHandle dir = FATFS_OpenDirectory( *ppDirList, "rw");
OS_TPrintf( " %s...", *ppDirList );
if( dir ) {
OS_TPrintf( "ok.\n" );
(void)FATFS_CloseDirectory( dir );
}else {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
ppDirList++;
}
return TRUE;
}
// ファイル作成
static BOOL CreateFile( const FileProperty *pFileList )
{
const FileProperty *pTemp = pFileList;
u32 length = 0;
u8 *pBuffer;
// ファイルリスト中の最大サイズのバッファを確保し、"0"埋め
while( pTemp->path ) {
if( length < pTemp->length ) {
length = pTemp->length;
}
pTemp++;
}
pBuffer = OS_Alloc( length );
if( pBuffer == NULL ) {
OS_TPrintf( "memory allocate error.\n" );
ERROR_RETURN();
}
MI_CpuClearFast( pBuffer, length );
OS_TPrintf( "\nCreate File :\n" );
// 指定されたファイルを作成して、"0"埋め
while( pFileList->path ) {
FATFSFileHandle file;
OS_TPrintf( " %s, %dbytes...", pFileList->path, pFileList->length );
// ファイル生成
if( !FATFS_CreateFile( pFileList->path, TRUE, "rwxrwxrwx" ) ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
// ファイルオープン
file = FATFS_OpenFile( pFileList->path, "w" );
if( !file ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
// ファイル長変更
if( !FATFS_SetFileLength( file, (int)pFileList->length ) ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
// ファイル書き込み
if( !FATFS_WriteFile( file, pBuffer, (int)pFileList->length ) ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
// ファイルクローズ
(void)FATFS_CloseFile( file );
OS_TPrintf( "ok.\n" );
pFileList++;
}
// メモリ解放
OS_Free( pBuffer );
return TRUE;
}
// ファイルチェック
static BOOL CheckFile( const FileProperty *pFileList )
{
// デフォルトドライブの指定
OS_TPrintf( "\nCheck File :\n" );
// 指定されたディレクトリをルートに作成
while( pFileList->path ) {
FATFSFileHandle file;
u32 *pBuffer;
int i;
OSTick start;
OS_TPrintf( " %s, %dbytes...", pFileList->path, pFileList->length );
// ファイルオープン
file = FATFS_OpenFile( pFileList->path, "r+" );
if( !file ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
// ファイル長チェック
if( FATFS_GetFileLength( file ) != pFileList->length ) {
OS_TPrintf( "ng. length = %d\n", FATFS_GetFileLength( file ) );
ERROR_RETURN();
}
// バッファ メモリ確保
pBuffer = OS_Alloc( pFileList->length );
if( pBuffer == NULL ) {
OS_TPrintf( "memory allocate error.\n" );
ERROR_RETURN();
}
start = OS_GetTick();
// ファイル読み込み
if(
#ifdef NAND_SEPARATE_READ
MY_ReadFile( file, pBuffer, (int)pFileList->length )
#else
FATFS_ReadFile( file, pBuffer, (int)pFileList->length )
#endif
!= pFileList->length ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
OS_TPrintf( " [ReadTime : %dms] ", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
start = OS_GetTick();
// ファイルベリファイ
for( i = 0; i < pFileList->length / sizeof(u32); i++ ) {
if( pBuffer[ i ] != 0 ) {
OS_TPrintf( "ng.\n" );
ERROR_RETURN();
}
}
OS_TPrintf( " [VerifyTime : %dms] ", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
// メモリ解放
OS_Free( pBuffer );
// ファイルクローズ
(void)FATFS_CloseFile( file );
OS_TPrintf( "ok.\n" );
pFileList++;
}
return TRUE;
}
#ifdef NAND_SEPARATE_READ
// NAND不具合をARM7側のFSは吸収しきれいていないので、自前で2KB単位に分割してリード
static int MY_ReadFile( FATFSFileHandle file, void *pBuffer, int length )
{
int length_bak = length;
while( length ) {
int rdLength = ( length > FS_READ_BLOCK_SIZE ) ? FS_READ_BLOCK_SIZE : length;
if( FATFS_ReadFile( file, pBuffer, rdLength ) != rdLength ) {
return -1;
}
pBuffer = (u8 *)pBuffer + rdLength;
length -= rdLength;
}
return length_bak;
}
#endif

View File

@ -0,0 +1,290 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: kami_pxi.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <twl/exi/ARM7/genPort2.h>
#include "kami_pxi.h"
#include "fifo.h"
#include "twl/cdc.h"
#include "formatter.h"
#include "nvram.h"
#include <twl/ltdmain_begin.h>
//#include <c:/TWL_SDK/build/libraries/fatfs/ARM7.TWL/include/twl/rtfs.h>
//#include <c:/TWL_SDK/build/libraries/fatfs/ARM7.TWL/include/twl/devices/sdmc/ARM7/sdmc.h>
typedef unsigned char byte; /* Don't change */
typedef unsigned short word; /* Don't change */
typedef unsigned long dword; /* Don't change */
#define BOOLEAN int
extern BOOL FATFSi_nandRtfsIo( int driveno, dword block, void* buffer, word count, BOOLEAN reading);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define KAMITEST_MESSAGE_ARRAY_MAX 4 // スレッド同期用メッセージキューのサイズ
#define KAMITEST_THREAD_STACK_SIZE 2048 // スレッドのスタックサイズ
#define KAMITEST_THREAD_PRIORITY 6
// アライメント調整してコピーする
#define KAMI_UNPACK_U16(d, s) \
(*(d) = (u16)((((u8*)s)[0] << 0) | (((u8*)s)[1] << 8)))
#define KAMI_UNPACK_U32(d, s) \
(*(d) = (u32)((((u8*)s)[0] << 0) | (((u8*)s)[1] << 8) | (((u8*)s)[2] << 16) | (((u8*)s)[3] << 24)))
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
typedef struct KamiWork
{
BOOL result;
u32 total;
u32 current;
KamiCommand command;
u8 data[KAMITEST_PXI_DATA_SIZE_MAX]; // 後続データ格納用
OSMessageQueue msgQ; // スレッド同期用メッセージキュー
OSMessage msgArray[KAMITEST_MESSAGE_ARRAY_MAX];
// メッセージを格納するバッファ
OSThread thread; // KAMI用スレッド
u64 stack[KAMITEST_THREAD_STACK_SIZE / sizeof(u64)];
// KAMI用スレッドのスタック
}
KamiWork;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL kamiInitialized;
static KamiWork kamiWork;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err);
static void KamiReturnResult(KamiCommand command, KAMIPxiResult result);
static void KamiReturnResultEx(KamiCommand command, KAMIPxiResult result, u8 size, u8* data);
static void KamiThread(void *arg);
void KamiPxiInit(void)
{
if (kamiInitialized)
{
return;
}
kamiInitialized = TRUE;
PXI_Init();
PXI_SetFifoRecvCallback(PXI_FIFO_TAG_KAMITEST, KamiPxiCallback);
OS_InitMessageQueue(&kamiWork.msgQ, kamiWork.msgArray, KAMITEST_MESSAGE_ARRAY_MAX);
OS_CreateThread(&kamiWork.thread, KamiThread, 0,
(void *)(kamiWork.stack + (KAMITEST_THREAD_STACK_SIZE / sizeof(u64))),
KAMITEST_THREAD_STACK_SIZE, KAMITEST_THREAD_PRIORITY);
OS_WakeupThreadDirect(&kamiWork.thread);
}
static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err)
{
#pragma unused( tag )
if (err)
{
return;
}
if (data & KAMITEST_PXI_START_BIT) // 先頭データ
{
kamiWork.total = (u8)((data & KAMITEST_PXI_DATA_NUMS_MASK) >> KAMITEST_PXI_DATA_NUMS_SHIFT);
kamiWork.current = 0;
kamiWork.command = (KamiCommand)((data & KAMITEST_PXI_COMMAND_MASK) >> KAMITEST_PXI_COMMAND_SHIFT);
kamiWork.data[kamiWork.current++] = (u8)((data & KAMITEST_PXI_1ST_DATA_MASK) >> KAMITEST_PXI_1ST_DATA_SHIFT);
}
else // 後続データ
{
kamiWork.data[kamiWork.current++] = (u8)((data & 0xFF0000) >> 16);
kamiWork.data[kamiWork.current++] = (u8)((data & 0x00FF00) >> 8);
kamiWork.data[kamiWork.current++] = (u8)((data & 0x0000FF) >> 0);
}
if (kamiWork.current >= kamiWork.total)
{
switch (kamiWork.command)
{
case CODEC_READ_REGISTER:
case CODEC_WRITE_REGISTER:
case GPIO333_WRITE:
case EXE_FORMAT:
case KAMI_NAND_IO:
case KAMI_NVRAM_IO:
if (!OS_SendMessage(&kamiWork.msgQ, NULL, OS_MESSAGE_NOBLOCK))
{
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_FATAL_ERROR);
}
break;
default:
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_INVALID_COMMAND);
}
}
}
static void KamiReturnResult(KamiCommand command, KAMIPxiResult result)
{
u32 pxiData = (u32)(KAMITEST_PXI_START_BIT | KAMITEST_PXI_RESULT_BIT |
((command << KAMITEST_PXI_COMMAND_SHIFT) & KAMITEST_PXI_COMMAND_MASK) |
((1 << KAMITEST_PXI_DATA_NUMS_SHIFT) & KAMITEST_PXI_DATA_NUMS_MASK) |
((result << KAMITEST_PXI_1ST_DATA_SHIFT) & KAMITEST_PXI_1ST_DATA_MASK));
while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0))
{
}
}
static void KamiReturnResultEx(KamiCommand command, KAMIPxiResult result, u8 size, u8* data)
{
u32 pxiData = (u32)(KAMITEST_PXI_START_BIT | KAMITEST_PXI_RESULT_BIT |
((command << KAMITEST_PXI_COMMAND_SHIFT) & KAMITEST_PXI_COMMAND_MASK) |
(((size+1) << KAMITEST_PXI_DATA_NUMS_SHIFT) & KAMITEST_PXI_DATA_NUMS_MASK) |
((result << KAMITEST_PXI_1ST_DATA_SHIFT) & KAMITEST_PXI_1ST_DATA_MASK));
int i;
while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0))
{
}
for (i = 0; i < size; i+= 3)
{
pxiData = (u32)((data[i] << 16) | (data[i+1] << 8) | data[i+2]);
while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0))
{
}
}
}
static void KamiThread(void *arg)
{
#pragma unused( arg )
OSMessage msg;
BOOL result;
while (TRUE)
{
(void)OS_ReceiveMessage(&kamiWork.msgQ, &msg, OS_MESSAGE_BLOCK);
switch (kamiWork.command)
{
////////////////////////////////////////////////////////
case CODEC_READ_REGISTER:
{
u8 value;
value = CDC_ReadSpiRegisterEx( kamiWork.data[0], kamiWork.data[1] );
KamiReturnResultEx(kamiWork.command, KAMI_PXI_RESULT_SUCCESS, sizeof(u8), (u8*)&value);
}
break;
case CODEC_WRITE_REGISTER:
{
CDC_WriteSpiRegisterEx( kamiWork.data[0], kamiWork.data[1], kamiWork.data[2] );
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS);
}
break;
case GPIO333_WRITE:
{
if (kamiWork.data[0])
{
// GPIO333 1出力
EXI2i_SetBitGpio2CntL(0x8080, 0x8080);
}
else
{
// GPIO333 0出力
EXI2i_SetBitGpio2CntL(0x8080, 0x8000);
}
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS);
}
break;
case EXE_FORMAT:
{
result = ExeFormat((FormatMode)kamiWork.data[0]); // Quick or Full
if (result)
{
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_TRUE);
}
else
{
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE);
}
}
break;
case KAMI_NAND_IO:
{
BOOL is_read;
u32 block;
void* buffer;
u32 count;
is_read = (BOOL)kamiWork.data[0];
KAMI_UNPACK_U32(&block, &kamiWork.data[1]);
KAMI_UNPACK_U32((u32 *)(&buffer), &kamiWork.data[5]);
KAMI_UNPACK_U32(&count, &kamiWork.data[9]);
result = FATFSi_nandRtfsIo( 0, block, buffer, (u16)count, is_read );
if (result)
{
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_TRUE);
}
else
{
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS_FALSE);
}
}
break;
case KAMI_NVRAM_IO:
{
BOOL is_read;
u32 adress;
void* buffer;
u32 size;
is_read = (BOOL)kamiWork.data[0];
KAMI_UNPACK_U32(&adress, &kamiWork.data[1]);
KAMI_UNPACK_U32((u32 *)(&buffer), &kamiWork.data[5]);
KAMI_UNPACK_U32(&size, &kamiWork.data[9]);
if (is_read)
{
NVRAMi_Read( adress, buffer, size );
}
else
{
NVRAMi_Write( adress, buffer, size );
}
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_SUCCESS);
}
break;
////////////////////////////////////////////////////////
default:
KamiReturnResult(kamiWork.command, KAMI_PXI_RESULT_INVALID_COMMAND);
}
}
}
#include <twl/ltdmain_end.h>

View File

@ -0,0 +1,401 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: main.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl_sp.h>
#include <twl/spi.h>
#include <twl/camera.h>
#include <twl/rtc.h>
#include <twl/fatfs.h>
#include <twl/os/common/codecmode.h>
#include <twl/cdc.h>
#include <twl/exi/ARM7/genPort2.h>
#include <twl/aes.h>
#include "kami_pxi.h"
#include "formatter.h"
/* Priorities of each threads */
#define THREAD_PRIO_SPI 2
#define THREAD_PRIO_SND 6
#define THREAD_PRIO_FATFS 8
#define THREAD_PRIO_RTC 12
#define THREAD_PRIO_FS 15
/* OS_THREAD_LAUNCHER_PRIORITY 16 */
extern void PMi_InitShutdownControl(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static OSHeapHandle InitializeAllocateSystem(void);
static void VBlankIntr(void);
static void InitializeFatfs(void);
static void InitializeCdc(void);
static void DummyThread(void* arg);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#ifdef SDK_TWLHYB
extern void SDK_LTDAUTOLOAD_LTDWRAM_BSS_END(void);
extern void SDK_LTDAUTOLOAD_LTDMAIN_BSS_END(void);
#endif
/*---------------------------------------------------------------------------*
Name: TwlSpMain
Description: Initialize and do main
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void TwlSpMain(void)
{
OSThread thread;
u32 stack[18];
// OS初期化
OS_Init();
SPI_Init(2);
OS_InitTick();
OS_InitAlarm();
OS_InitThread();
// (void)PAD_InitXYButton();
// ヒープ領域設定
InitializeAllocateSystem();
// ボタン入力サーチ初期化
(void)PAD_InitXYButton();
// 割り込み許可
(void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
// ダミースレッド作成(CDC_InitとFS_InitでOS_Sleepが使用されているため
OS_CreateThread(&thread, DummyThread, NULL,
(void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX);
OS_WakeupThreadDirect(&thread);
// ファイルシステム初期化
FS_Init(FS_DMA_NOT_USE);
FS_CreateReadServerThread(THREAD_PRIO_FS);
if (OS_IsRunOnTwl() == TRUE)
{
InitializeFatfs(); // FATFS 初期化
//InitializeNwm(); // NWM 初期化
#ifndef SDK_NOCRYPTO
AES_Init(); // AES 初期化
#endif
}
if (OSi_IsCodecTwlMode() == TRUE)
{
// CODEC 初期化
InitializeCdc();
// カメラ初期化
//CAMERA_Init();
/* CODEC が TWL モードでないとシャッター音を強制的に鳴らす
使CODEC TWL
使 */
}
// サウンド初期化
SND_Init(THREAD_PRIO_SND);
// RTC 初期化
RTC_Init(THREAD_PRIO_RTC);
// 旧無線初期化
//WVR_Begin(heapHandle);
// SPI 初期化
SPI_Init(THREAD_PRIO_SPI);
KamiPxiInit();
// ダミースレッド破棄
OS_KillThread(&thread, NULL);
while (TRUE)
{
OS_Halt();
//---- check reset
if (OS_IsResetOccurred())
{
OS_ResetSystem();
}
}
}
#include <twl/ltdwram_begin.h>
/*---------------------------------------------------------------------------*
Name: InitializeFatfs
Description: FATFSライブラリを初期化する
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
InitializeFatfs(void)
{
#ifndef SDK_NOCRYPTO
#ifdef FATFS_AES_MOUNT_FOR_NAND
if(!FATFS_Init( FATFS_DMA_4, 8))
#else
if(!FATFS_Init(FATFS_DMA_NOT_USE, 8))
#endif
#else
if(!FATFS_Init(FATFS_DMA_NOT_USE, 8))
#endif
{
OS_TPanic("FATFS_Init() failed.\n");
}
}
#include <twl/ltdwram_end.h>
#include <twl/ltdwram_begin.h>
/*---------------------------------------------------------------------------*
Name: InitializeCdc
Description: CDCライブラリを初期化するCDC初期化関数内でスレッド休止する
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
InitializeCdc(void)
{
#if 1
// CODEC 初期化
CDC_Init();
CDC_InitMic();
// CDCi_DumpRegisters();
#else
/* [Debug] CODEC を DS モードで初期化 */
*((u8*)(HW_TWL_ROM_HEADER_BUF + 0x01bf)) &= ~(0x01);
CDC_Init();
CDC_GoDsMode();
OS_TPrintf("Codec mode changed to DS mode for debug.\n");
#endif
}
/*---------------------------------------------------------------------------*
Name: DummyThread
Description: CDCライブラリを初期化する際に立てるダミーのスレッド
Arguments: arg - 使
Returns: None.
*---------------------------------------------------------------------------*/
static void
DummyThread(void* arg)
{
#pragma unused(arg)
while (TRUE)
{
}
}
#include <twl/ltdwram_end.h>
/*---------------------------------------------------------------------------*
Name: InitializeAllocateSystem
Description:
Arguments: None.
Returns: OSHeapHandle - WRAM
*---------------------------------------------------------------------------*/
static OSHeapHandle
InitializeAllocateSystem(void){
OSHeapHandle hh;
#ifdef SDK_TWLHYB
if (OS_IsRunOnTwl() == TRUE)
{
void* basicLo = (void*)OS_GetSubPrivArenaLo();
void* basicHi = (void*)OS_GetSubPrivArenaHi();
void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDMAIN_BSS_END, 32);
void* extraHi = (void*)MATH_ROUNDDOWN(HW_MAIN_MEM_SUB, 32);
#if SDK_DEBUG
// debug information
OS_TPrintf("ARM7: MAIN arena basicLo = %p\n", basicLo);
OS_TPrintf("ARM7: MAIN arena basicHi = %p\n", basicHi);
OS_TPrintf("ARM7: MAIN arena extraLo = %p\n", extraLo);
OS_TPrintf("ARM7: MAIN arena extraHi = %p\n", extraHi);
#endif
// アリーナを 0 クリア
MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo);
MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo);
// メモリ割り当て初期化
if ((u32)basicLo < (u32)extraLo)
{
basicLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, basicLo, extraHi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, basicLo);
}
else
{
extraLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, extraLo, basicHi, 1);
}
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, basicLo, basicHi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to create MAIN heap.\n");
}
// ヒープに拡張ブロックを追加
OS_AddToHeap(OS_ARENA_MAIN_SUBPRIV, hh, extraLo, extraHi);
}
else
#endif
{
void* lo = (void*)OS_GetSubPrivArenaLo();
void* hi = (void*)OS_GetSubPrivArenaHi();
// アリーナを 0 クリア
MI_CpuClear8(lo, (u32)hi - (u32)lo);
// メモリ割り当て初期化
lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo);
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, lo, hi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to MAIN create heap.\n");
}
}
// カレントヒープに設定
(void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh);
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh);
OS_TPrintf("ARM7: MAIN heap size is %d\n", heapSize);
}
#ifdef SDK_TWLHYB
if (OS_IsRunOnTwl() == TRUE)
{
void* basicLo = (void*)OS_GetWramSubPrivArenaLo();
void* basicHi = (void*)OS_GetWramSubPrivArenaHi();
void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDWRAM_BSS_END, 32);
void* extraHi = (void*)MATH_ROUNDDOWN(HW_WRAM_A_HYB_END, 32);
#if SDK_DEBUG
// debug information
OS_TPrintf("ARM7: WRAM arena basicLo = %p\n", basicLo);
OS_TPrintf("ARM7: WRAM arena basicHi = %p\n", basicHi);
OS_TPrintf("ARM7: WRAM arena extraLo = %p\n", extraLo);
OS_TPrintf("ARM7: WRAM arena extraHi = %p\n", extraHi);
#endif
// アリーナを 0 クリア
MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo);
MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo);
// メモリ割り当て初期化
if ((u32)basicLo < (u32)extraLo)
{
basicLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, basicLo, extraHi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, basicLo);
}
else
{
extraLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, extraLo, basicHi, 1);
}
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, basicLo, basicHi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to WRAM create heap.\n");
}
// ヒープに拡張ブロックを追加
OS_AddToHeap(OS_ARENA_WRAM_SUBPRIV, hh, extraLo, extraHi);
}
else
#endif
{
void* lo = (void*)OS_GetWramSubPrivArenaLo();
void* hi = (void*)OS_GetWramSubPrivArenaHi();
// アリーナを 0 クリア
MI_CpuClear8(lo, (u32)hi - (u32)lo);
// メモリ割り当て初期化
lo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, lo, hi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, lo);
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, lo, hi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to WRAM create heap.\n");
}
}
// カレントヒープに設定
(void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh);
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh);
if (WM_WL_HEAP_SIZE > heapSize)
{
OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE);
}
OS_TPrintf("ARM7: WRAM heap size is %d\n", heapSize);
}
return hh;
}
/*---------------------------------------------------------------------------*
Name: VBlankIntr
Description: V
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
extern BOOL PMi_Initialized;
void PM_SelfBlinkProc(void);
static void
VBlankIntr(void)
{
if (PMi_Initialized)
{
PM_SelfBlinkProc();
}
}

View File

@ -0,0 +1,181 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: nvram_misc.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include "nvram.h"
#include "spi_sp.h"
#include "nvram_sp.h"
/*---------------------------------------------------------------------------*
Name: NvramCheckReadyToRead
Description: NVRAMを読み出し可能な状態かどうか確認する
Arguments: None.
Returns: BOOL - TRUEを返す
FALSEの場合は読み出し禁止の状態
*---------------------------------------------------------------------------*/
static BOOL NvramCheckReadyToRead(void)
{
u16 tempStatus;
// ステータスレジスタ読み出し
NVRAM_ReadStatusRegister((u8 *)(&tempStatus));
// 書き込みもしくは消去操作中かを確認
if (tempStatus & NVRAM_STATUS_REGISTER_WIP)
{
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: NvramCheckReadyToWrite
Description: NVRAMを書き込み可能な状態かどうか確認する
Arguments: None.
Returns: BOOL - TRUEを返す
FALSEの場合は書き込み禁止の状態
*---------------------------------------------------------------------------*/
static BOOL NvramCheckReadyToWrite(void)
{
u16 tempStatus;
// ステータスレジスタ読み出し
NVRAM_ReadStatusRegister((u8 *)(&tempStatus));
// 書き込みもしくは消去操作中かを確認
if (tempStatus & NVRAM_STATUS_REGISTER_WIP)
{
return FALSE;
}
// 書き込み許可されているかを確認
if (!(tempStatus & NVRAM_STATUS_REGISTER_WEL))
{
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: NVRAM_WaitOperation
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void NVRAM_WaitOperation(void)
{
while( NvramCheckReadyToRead() == FALSE ) {
}
}
/*---------------------------------------------------------------------------*
Name: NVRAM_WaitWriteEnable
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void NVRAM_WaitWriteEnable(void)
{
while( NvramCheckReadyToWrite() == FALSE ) {
}
}
/*---------------------------------------------------------------------------*
Name: NVRAMi_Read
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void NVRAMi_Read(u32 address, void *buf, u32 size)
{
NVRAM_WaitOperation();
NVRAM_ReadDataBytes(address, size, buf);
return;
}
/*---------------------------------------------------------------------------*
Name: NVRAMi_Write
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void NVRAMi_Write(u32 address, void *buf, u32 size)
{
u32 i;
u32 page_start;
u32 page_end;
u32 offset_start;
u32 offset_end;
u8 *src_ptr;
u8 temp_buffer[SPI_NVRAM_PAGE_SIZE];
src_ptr = (u8 *)buf;
page_start = (address / SPI_NVRAM_PAGE_SIZE) * SPI_NVRAM_PAGE_SIZE;
page_end = ((address+size-1) / SPI_NVRAM_PAGE_SIZE ) * SPI_NVRAM_PAGE_SIZE;
offset_start = address % SPI_NVRAM_PAGE_SIZE;
offset_end = (address+size-1) % SPI_NVRAM_PAGE_SIZE;
while( page_start <= page_end ) {
if( offset_start != 0 ) {
NVRAMi_Read(page_start, temp_buffer, offset_start);
}
if( page_start != page_end ) {
for( i = offset_start ; i < SPI_NVRAM_PAGE_SIZE ; i++ ) {
temp_buffer[i] = *src_ptr++;
}
}
else {
for( i = offset_start ; i <= offset_end ; i++ ) {
temp_buffer[i] = *src_ptr++;
}
if( offset_end != (SPI_NVRAM_PAGE_SIZE-1) ) {
NVRAMi_Read(page_start+offset_end+1, &(temp_buffer[offset_end+1]), SPI_NVRAM_PAGE_SIZE - (offset_end+1) );
}
}
NVRAM_WriteEnable();
NVRAM_WaitWriteEnable();
NVRAM_PageErase((u32)page_start);
NVRAM_WaitOperation();
NVRAM_WriteEnable();
NVRAM_PageWrite((u32)page_start, (u16)SPI_NVRAM_PAGE_SIZE, temp_buffer);
NVRAM_WaitOperation();
page_start += SPI_NVRAM_PAGE_SIZE;
offset_start = 0;
}
}

View File

@ -0,0 +1,57 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - include
# File: ARM9-TS.lsf
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded insructions, 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:: 2007-12-05#$
# $Rev: 2840 $
# $Author: yosizaki $
#----------------------------------------------------------------------------
#
# TWL LCF SPEC FILE
#
Static $(TARGET_NAME)
{
Address $(ADDRESS_STATIC)
Object $(OBJS_STATIC)
Library $(LLIBS) $(GLIBS) $(CW_LIBS)
StackSize 2048 2048
}
Autoload ITCM
{
Address $(ADDRESS_ITCM)
Object * (.itcm)
Object $(OBJS_AUTOLOAD) (.text)
Object $(OBJS_AUTOLOAD) (.rodata)
Object $(OBJS_AUTOLOAD) (.init)
Object $(OBJS_AUTOLOAD) (.ctor)
Object $(OBJS_AUTOLOAD) (.sinit)
}
Autoload DTCM
{
Address $(ADDRESS_DTCM)
Object * (.dtcm)
Object $(OBJS_AUTOLOAD) (.data)
Object $(OBJS_AUTOLOAD) (.sdata)
Object $(OBJS_AUTOLOAD) (.bss)
Object $(OBJS_AUTOLOAD) (.sbss)
}
Ltdautoload LTDMAIN
{
# NITRO/TWL 共有のオーバーレイが在る場合は、さらにその後ろに配置する必要があります。
After $(TARGET_NAME)
Object * (.ltdmain)
Object $(OBJS_LTDAUTOLOAD)
Library $(LLIBS_EX) $(GLIBS_EX)
}

View File

@ -0,0 +1,93 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - tests - camera-test
# File: Makefile
#
# Copyright 2007 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:: 2007-11-28#$
# $Rev: 2683 $
# $Author: yutaka $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
USE_PRODUCT_KEY = TRUE
TARGET_FIRM = SYSTEMMENU
TARGET_PLATFORM = TWL
TWL_ARCHGEN = LIMITED
#TWL_CODEGEN = THUMB
TITLEID_LO = NNNN
TARGET_BIN = main.srl
LCFILE_SPEC = ARM9-TS.lsf
ROM_SPEC = main.rsf
MAKEROM_ARM7_BASE = ../ARM7.TWL/bin/$(TWL_BUILDTYPE_ARM7)/main
MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT)
SRCS = main.c \
kami_pxi.c \
font_data.c \
graphics.c \
keypad.c \
kami_font.c \
cursor.c \
process_format.c \
process_topmenu.c \
process_hw_info.c \
process_eticket.c \
process_import.c \
process_nandfirm.c \
process_norfirm.c \
process_auto.c
LINCLUDES = ../common/include \
$(ROOT)/build/libraries/lcfg/ARM9.TWL/include
SRCDIR = src ../../../../demos.TWL/camera/saveShoot-1/src
#LCFILE = # using default
MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \
-DHWINFO_PRIVKEY='private_HWInfo.der'
MAKETAD_FLAGS += -s
ifdef USE_PRODUCT_KEY
MAKEROM_FLAGS += -DPRIVKEY_PATH='$(TWL_KEYSDIR)/rsa'
MACRO_FLAGS += -DUSE_PRODUCT_KEY
else
MAKEROM_FLAGS += -DPRIVKEY_PATH='../../../../keys/dummy/rsa'
endif
LLIBRARIES += libes$(TWL_LIBSUFFIX).a \
libboc$(TWL_LIBSUFFIX).a \
libnam$(TWL_LIBSUFFIX).a \
libacsign_enc$(TWL_LIBSUFFIX).a
#include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/buildtools/twl/commondefs.gx.demolib
#----------------------------------------------------------------------------
do-build: $(TARGETS)
#include $(TWLSDK_ROOT)/build/buildtools/modulerules
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: cursor.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef KAMI_CURSOR_H_
#define KAMI_CURSOR_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void SetCursorPos(u16 x, u16 y);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* KAMI_CURSOR_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: graphics.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef GRAPHICS_H_
#define GRAPHICS_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void InitGraphics(void);
void DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* GRAPHICS_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,92 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: kami_font.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef KAMI_FONT_H_
#define KAMI_FONT_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <twl.h>
extern u8 prog_state;
enum
{ STATE_NONE, STATE_SELECT, STATE_KS_PARENTINIT, STATE_KS_PARENT, STATE_KS_CHILDINIT,
STATE_KS_CHILDSCAN, STATE_KS_CHILD
};
extern OSHeapHandle heapHandle; // Heapハンドル;
extern const u16 BgScDataMain[32 * 24];
extern const u16 BgScDataSub[32 * 24];
extern const u32 sampleCharData[8 * 0x100];
extern const u16 PlttDataObj[16][16];
extern const u16 PlttDataMain[16][16];
extern const u16 PlttDataSub[16][16];
void kamiFontInit(void);
void kamiFontClear(void);
void kamiFontPut(u16 x, u16 y, u16 color, u16 no);
void kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...);
void kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...);
void kamiFontFill(s16 x, s16 y, u8 color, s16 value, s32 length);
void kamiFontFillChar(int lineNo, u8 color1, u8 color2);
void kamiFontLoadScreenData(void);
void kamiFontPrintfConsole(u8 color, char *text, ...);
void kamiFontPrintfConsoleEx(u8 color, char *text, ...);
// 上画面コンソール文字列用パレット
#define CONSOLE_ORANGE 0
#define CONSOLE_RED 1
#define CONSOLE_GREEN 2
// 下画面フォント用パレット
#define FONT_COLOR_BLACK 0
#define FONT_COLOR_RED 1
#define FONT_COLOR_GREEN 2
#define FONT_COLOR_BLUE 3
#define FONT_COLOR_YELLOW 4
#define FONT_COLOR_CYAN 5
#define FONT_COLOR_PURPLE 6
// 下画面背景用パレット
#define BG_COLOR_TRANS 0
#define BG_COLOR_WHITE 1
#define BG_COLOR_BLACK 2
#define BG_COLOR_GRAY 3
#define BG_COLOR_PURPLE 4
#define BG_COLOR_PINK 5
#define BG_COLOR_BLUE 6
#define BG_COLOR_GREEN 7
#define BG_COLOR_VIOLET 8
#define BG_COLOR_RED 9
#define BG_COLOR_NONE 0xff
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* KAMI_FONT_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: kami_pxi.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef TWL_KAMI_TEST_KAMITEST_H_
#define TWL_KAMI_TEST_KAMITEST_H_
#include "fifo.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
// 処理結果定義
typedef enum KAMIResult
{
KAMI_RESULT_SUCCESS = 0,
KAMI_RESULT_SUCCESS_TRUE = 0,
KAMI_RESULT_SUCCESS_FALSE,
KAMI_RESULT_INVALID_COMMAND,
KAMI_RESULT_INVALID_PARAMETER,
KAMI_RESULT_ILLEGAL_STATUS,
KAMI_RESULT_BUSY,
KAMI_RESULT_FATAL_ERROR,
KAMI_RESULT_SEND_ERROR,
KAMI_RESULT_MAX
}
KAMIResult;
typedef enum {
FORMAT_MODE_QUICK, // Quickフォーマット
FORMAT_MODE_FULL // Fullフォーマット(各パーティション内を0xFFで埋める
} FormatMode;
// コールバック
typedef void (*KAMICallback)(KAMIResult result, void *arg);
void KamiPxiInit( void );
KAMIResult CDC_ReadRegister(u8 page, u8 reg_no, u8* pData);
KAMIResult CDC_WriteRegister(u8 page, u8 reg_no, u8 value);
KAMIResult GPIO333_Write(BOOL value);
KAMIResult ExeFormatAsync(FormatMode format_mode, KAMICallback callback);
KAMIResult kamiNandIo(u32 block, void* buffer, u32 count, BOOL is_read);
KAMIResult kamiNvramIo(u32 address, void* buffer, u32 size, BOOL is_read);
static KAMIResult kamiNandRead(u32 block, void* buffer, u32 count)
{
return kamiNandIo(block, buffer, count, TRUE);
}
static KAMIResult kamiNandWrite(u32 block, void* buffer, u32 count)
{
return kamiNandIo(block, buffer, count, FALSE);
}
static KAMIResult kamiNvramRead(u32 adress, void* buffer, u32 size)
{
return kamiNvramIo(adress, buffer, size, TRUE);
}
static KAMIResult kamiNvramWrite(u32 adress, void* buffer, u32 size)
{
return kamiNvramIo(adress, buffer, size, FALSE);
}
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* TWL_KAMI_TEST_KAMITEST_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: keypad.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef KAMI_KEY_PAD_H_
#define KAMI_KEY_PAD_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void kamiPadRead(void);
BOOL kamiPadIsTrigger(u16 key);
BOOL kamiPadIsRepeatTrigger(u16 key);
BOOL kamiPadIsPress(u16 key);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* KAMI_KEY_PAD_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_auto.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef AUTO_TOPMENU_H_
#define AUTO_TOPMENU_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
extern BOOL gAutoFlag;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
void* AutoProcess0(void);
void* AutoProcess1(void);
void* AutoProcess2(void);
void* AutoProcess3(void);
void* AutoProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* AUTO_TOPMENU_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_eticket.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_ETICKET_H_
#define PROCESS_ETICKET_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
#define E_TICKET_FILE_PATH_IN_ROM "data/cert.sys"
#define E_TICKET_FILE_PATH_IN_NAND "F:sys/cert.sys"
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* eTicketProcess0(void);
void* eTicketProcess1(void);
void* eTicketProcess2(void);
void* eTicketProcess3(void);
void* eTicketProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_ETICKET_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_format.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_FORMAT_H_
#define PROCESS_FORMAT_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* FormatProcess0(void);
void* FormatProcess1(void);
void* FormatProcess2(void);
void* FormatProcess3(void);
void* FormatProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_FORMAT_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_hw_info.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_HW_INFO_H_
#define PROCESS_HW_INFO_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* HWInfoProcess0(void);
void* HWInfoProcess1(void);
void* HWInfoProcess2(void);
void* HWInfoProcess3(void);
void* HWInfoProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_HW_INFO_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_import.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_IMPORT_H_
#define PROCESS_IMPORT_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* ImportProcess0(void);
void* ImportProcess1(void);
void* ImportProcess2(void);
void* ImportProcess3(void);
void* ImportProcess4(void);
void ProgressInit(void);
void ProgressDraw(f32 ratio);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_IMPORT_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_nandfirm.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_NANDFIRM_H_
#define PROCESS_NANDFIRM_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* NandfirmProcess0(void);
void* NandfirmProcess1(void);
void* NandfirmProcess2(void);
void* NandfirmProcess3(void);
void* NandfirmProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_NANDFIRM_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_norfirm.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_NORFIRM_H_
#define PROCESS_NORFIRM_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* NorfirmProcess0(void);
void* NorfirmProcess1(void);
void* NorfirmProcess2(void);
void* NorfirmProcess3(void);
void* NorfirmProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_NORFIRM_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_topmenu.h
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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#ifndef PROCESS_TOPMENU_H_
#define PROCESS_TOPMENU_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro.h>
/*---------------------------------------------------------------------------*
Œ^è`
*---------------------------------------------------------------------------*/
//typedef void* (*TpProcess)(void);
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void* TopmenuProcess0(void);
void* TopmenuProcess1(void);
void* TopmenuProcess2(void);
void* TopmenuProcess3(void);
void* TopmenuProcess4(void);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PROCESS_TOPMENU_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,182 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - include
# File: ROM-BB.rsf
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded insructions, 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-01-07#$
# $Rev: 436 $
# $Author: yosiokat $
#----------------------------------------------------------------------------
#
# TWL ROM SPEC FILE
#
Arm9
{
Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)"
Elf "$(MAKEROM_ARM9:r).tef"
}
Arm7
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)"
Elf "$(MAKEROM_ARM7_BASE:r).tef"
}
Arm9.Ltd
{
Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)"
}
Arm7.Ltd
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)"
}
Property
{
###
### Settings for FinalROM
###
#### BEGIN
#
# TITLE NAME: Your product name within 12bytes
#
#TitleName "YourAppName"
#
# MAKER CODE: Your company ID# in 2 ascii words
# issued by NINTENDO
#
#MakerCode "00"
#
# REMASTER VERSION: Mastering version
#
#RomVersion 0
#
# ROM SPEED TYPE: [MROM/1TROM/UNDEFINED]
#
RomSpeedType $(MAKEROM_ROMSPEED)
#
# ROM SIZE: in bit [64M/128M/256M/512M/1G/2G]
#
#RomSize 128M
#RomSize 256M
#
# ROM PADDING: TRUE if finalrom
#
#RomFootPadding TRUE
#
# ROM HEADER TEMPLATE: Provided to every product by NINTENDO
#
#RomHeaderTemplate ./etc/rom_header.template.sbin
#
# BANNER FILE: generated from Banner Spec File
#
BannerFile ../banner/banner.bnr
###
### Setting for TWL
###
#
# BANNER FILE:
#
BannerTWLFile $(TWLSDK_ROOT)/include/twl/specfiles/default.bnr
#
# Digest parameters:
#
DigestParam 1024 32
#
# WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD]
# don't have to edit
#
WramMapping $(MAKEROM_WRAM_MAPPING)
#
# Codec mode:
# don't have to edit
#
CodecMode $(MAKEROM_CODEC_MODE)
###
#### END
}
AppendProperty
{
#
# Publisher : "Nintendo"
# don't have to edit
Publisher Nintendo
#
# Application type : [USER/SYSTEM]
# don't have to edit
AppType System
#
# launch title on the launcher : [TRUE/FALSE]
# don't have to edit
Launch TRUE
#
# Boot allowed Media: [GameCard/NAND]
#
Media GameCard
#
# GameCode for TitleID : Your GameCode in 4 ascii words
#
GameCode $(TITLEID_LO)
#
# Public save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M]
#
#PublicSaveDataSize 32K
#
# Private save data size: [16K/32K/64K/128K/256K/512K/1M/2M/4M/8M]
#
#PrivateSaveDataSize 16K
#
# Enable SaveBannerFile
#SaveBannerFile TRUE
}
RomSpec
{
Offset 0x00000000
Segment ALL
HostRoot ../data
Root /data
File *.*
HostRoot $(PRIVKEY_PATH)
Root /key
File $(HWINFO_PRIVKEY)
}

View File

@ -0,0 +1,93 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: cursor.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "graphics.h"
#include "cursor.h"
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
àÏ<EFBFBD>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
ŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void SetCursorPos(u16 x, u16 y)
{
GXOamAttr oam;
/* []
G2_SetOBJAttr(
&oam,
x, y,
0,
GX_OAM_MODE_NORMAL,
FALSE,
GX_OAM_EFFECT_FLIP_H,
GX_OAM_SHAPE_8x8,
GX_OAM_COLORMODE_16,
0xf6, // charNo
0,
0
);
DC_FlushRange( &oam, sizeof(GXOamAttr) );
GXS_LoadOAM( &oam, 8, sizeof(GXOamAttr) );
G2_SetOBJAttr(
&oam,
x+31, y,
0,
GX_OAM_MODE_NORMAL,
FALSE,
GX_OAM_EFFECT_NONE,
GX_OAM_SHAPE_8x8,
GX_OAM_COLORMODE_16,
0xf6, // charNo
0,
0
);
DC_FlushRange( &oam, sizeof(GXOamAttr) );
GXS_LoadOAM( &oam, 16, sizeof(GXOamAttr) );
*/
G2_SetOBJAttr(
&oam,
x, y,
0,
GX_OAM_MODE_NORMAL,
FALSE,
GX_OAM_EFFECT_NONE,
GX_OAM_SHAPE_8x8,
GX_OAM_COLORMODE_16,
0xff, // charNo
0,
0
);
DC_FlushRange( &oam, sizeof(GXOamAttr) );
GXS_LoadOAM( &oam, 24, sizeof(GXOamAttr) );
}

View File

@ -0,0 +1,732 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: font_data.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <nitro.h>
/*---------------------- BGスクリーン ---------------------------*/
const u16 BgScDataMain[32 * 24] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
const u16 BgScDataSub[32 * 24] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
/*---------------------- パレットデータ ---------------------------*/
#define RGB555(r,g,b) (b<<10|g<<5|r)
const u16 PlttDataObj[16][16] = {
{RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(31, 0, 0), RGB555(5, 5, 20),}, // Black
{RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red
{RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green
{RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue
{RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow
{RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan
{RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
};
// 上画面コンソール文字列パレット
const u16 PlttDataMain[16][16] = {
{RGB555( 0, 0, 0), RGB555(31, 10, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Orange
{RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red
{RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green
{RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue
{RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow
{RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan
{RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
};
const u16 PlttDataSub[16][16] = {
{RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(25, 25, 25), RGB555(31, 31, 31),}, // Black
{RGB555(31, 31, 31), RGB555(21, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red
{RGB555(31, 31, 31), RGB555( 0, 21, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green
{RGB555(31, 31, 31), RGB555( 0, 0, 21), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue
{RGB555(31, 31, 31), RGB555(21, 21, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow
{RGB555(31, 31, 31), RGB555(0, 21, 21), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan
{RGB555(31, 31, 31), RGB555(21, 0, 21), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
// 背景カラーはこの16番パレット
// 白 黒 灰 むらさき ピンク みずいろ 緑 青紫 赤
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555( 0, 0, 0), RGB555(20, 20, 20), RGB555(31, 15, 31), RGB555(31, 20, 20), RGB555(20, 29, 31), RGB555(20, 31, 20), RGB555(21, 21, 31), RGB555(31, 0, 0), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), } // White
};
/*---------------------- キャラクタデータ -------------------------*/
const u32 sampleCharData[8 * 0x100] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x11111111, 0x11111111, // 0001h use for import progress bar
0x11111111, 0x11111111, 0x00000000, 0x00000000,
0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h
0x00100010, 0x00100010, 0x00100001, 0x00100001,
0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h
0x00000001, 0x00000001, 0x00000001, 0x01111110,
0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h
0x00100000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h
0x00010001, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h
0x00001000, 0x00101010, 0x01001010, 0x01001001,
0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h
0x00010010, 0x00010010, 0x00010010, 0x00001001,
0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h
0x00011111, 0x00001000, 0x00000001, 0x00011110,
0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h
0x00000001, 0x00000110, 0x00011000, 0x00100000,
0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah
0x00010001, 0x00010001, 0x00010001, 0x00001010,
0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh
0x00000000, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch
0x00010000, 0x00000001, 0x00000001, 0x00011110,
0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh
0x00010100, 0x00010100, 0x00011000, 0x00001100,
0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh
0x00010010, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h
0x00111111, 0x00000100, 0x00000100, 0x00011000,
0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h
0x01110100, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h
0x00011110, 0x00100001, 0x00100000, 0x00011110,
0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h
0x00001000, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h
0x00000010, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h
0x00010001, 0x00111001, 0x01010101, 0x00011001,
0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h
0x00010001, 0x00010001, 0x00001010, 0x00000100,
0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah
0x00010001, 0x00011001, 0x00110101, 0x00001001,
0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh
0x00010001, 0x00111001, 0x01010101, 0x00011001,
0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch
0x00010001, 0x00010001, 0x00001010, 0x00000100,
0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh
0x00010001, 0x00011001, 0x00110101, 0x00001001,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h
0x00001000, 0x00001000, 0x00000000, 0x00001000,
0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h
0x00100100, 0x01111111, 0x00010010, 0x00010010,
0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h
0x00111110, 0x01001000, 0x00111111, 0x00001000,
0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h
0x00001000, 0x00100100, 0x01010010, 0x00100001,
0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h
0x01000110, 0x00101001, 0x00110001, 0x01001110,
0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h
0x00000100, 0x00000100, 0x00001000, 0x01110000,
0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h
0x00010000, 0x00010000, 0x00001000, 0x00000111,
0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah
0x00011100, 0x00101010, 0x01001001, 0x00001000,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh
0x01111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch
0x00000000, 0x00001100, 0x00001000, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh
0x01111111, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh
0x00000000, 0x00000000, 0x00000000, 0x00001100,
0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh
0x00001000, 0x00000100, 0x00000010, 0x00000001,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h
0x01000001, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h
0x00010000, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h
0x00111110, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h
0x00111110, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h
0x00100100, 0x00100010, 0x01111111, 0x00100000,
0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h
0x01000000, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h
0x01000001, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h
0x00010000, 0x00010000, 0x00001000, 0x00001000,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h
0x00111110, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h
0x01000001, 0x01111110, 0x01000000, 0x00111110,
0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah
0x00000000, 0x00000000, 0x00001100, 0x00000000,
0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh
0x00000000, 0x00001100, 0x00001000, 0x00000100,
0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch
0x00000001, 0x00000110, 0x00011000, 0x01100000,
0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh
0x00000000, 0x00000000, 0x01111111, 0x00000000,
0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh
0x01000000, 0x00110000, 0x00001100, 0x00000011,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh
0x00110000, 0x00001000, 0x00000000, 0x00001000,
0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h
0x01010101, 0x01010101, 0x01010101, 0x00111010,
0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h
0x00100010, 0x00111110, 0x01000001, 0x01000001,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h
0x00111111, 0x01000001, 0x01000001, 0x00111111,
0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h
0x00000001, 0x00000001, 0x01000010, 0x00111100,
0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h
0x01000001, 0x01000001, 0x00100001, 0x00011111,
0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h
0x01111111, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h
0x00111111, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h
0x01111001, 0x01000001, 0x01000010, 0x00111100,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h
0x01111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h
0x00001000, 0x00001000, 0x00001000, 0x00111110,
0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh
0x00000011, 0x00000101, 0x00011001, 0x01100001,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch
0x00000001, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh
0x01001001, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh
0x01001001, 0x01010001, 0x01100001, 0x01000001,
0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h
0x00111111, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h
0x01000001, 0x01011001, 0x00100010, 0x01011100,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h
0x00111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h
0x00111110, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h
0x00100010, 0x00010100, 0x00010100, 0x00001000,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h
0x01001001, 0x01010101, 0x01100011, 0x01000001,
0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h
0x00001000, 0x00010100, 0x00100010, 0x01000001,
0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah
0x00001000, 0x00000100, 0x00000010, 0x01111111,
0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh
0x00000100, 0x00000100, 0x00000100, 0x01111100,
0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch
0x00001000, 0x00111110, 0x00001000, 0x00001000,
0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh
0x00010000, 0x00010000, 0x00010000, 0x00011111,
0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh
0x00000000, 0x00000000, 0x00000000, 0x01111111,
0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h
0x00111110, 0x00100001, 0x00100001, 0x01011110,
0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h
0x01000001, 0x01000001, 0x01000001, 0x00111111,
0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h
0x00000001, 0x00000001, 0x01000010, 0x00111100,
0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h
0x01000001, 0x01000001, 0x01000001, 0x01111110,
0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h
0x01111111, 0x00000001, 0x01000001, 0x00111110,
0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h
0x01111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h
0x01000001, 0x01111110, 0x01000000, 0x00111110,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h
0x00111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah
0x00100000, 0x00100001, 0x00100001, 0x00011110,
0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh
0x00011001, 0x00000111, 0x00011001, 0x01100001,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh
0x01001001, 0x01001001, 0x01001001, 0x01001001,
0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh
0x01000001, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h
0x01000001, 0x01000011, 0x00111101, 0x00000001,
0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h
0x01000001, 0x01100001, 0x01011110, 0x01000000,
0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h
0x00000011, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h
0x00001110, 0x00110000, 0x01000001, 0x00111110,
0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h
0x00000100, 0x00000100, 0x00000100, 0x01111000,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h
0x01000001, 0x01000001, 0x01000001, 0x01111110,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h
0x00100010, 0x00100010, 0x00010100, 0x00001000,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h
0x01001001, 0x00101010, 0x00101010, 0x00010100,
0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h
0x00001100, 0x00001100, 0x00010010, 0x00100001,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h
0x00100010, 0x00011100, 0x00001000, 0x00000110,
0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah
0x00001000, 0x00000100, 0x00000010, 0x00111111,
0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh
0x00011000, 0x00100100, 0x00000100, 0x01111000,
0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch
0x00011110, 0x00110101, 0x00101101, 0x00010010,
0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh
0x00100001, 0x00100001, 0x00000001, 0x00000010,
0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh
0x00011110, 0x00100000, 0x00100000, 0x00011100,
0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh
0x00111110, 0x00010000, 0x00001100, 0x00110010,
0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h
0x01000100, 0x00011110, 0x00100101, 0x00010110,
0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h
0x00101011, 0x00100010, 0x00010100, 0x00000100,
0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h
0x00101011, 0x00101001, 0x00011001, 0x00000100,
0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h
0x00001000, 0x00011110, 0x00101001, 0x00000110,
0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h
0x00100011, 0x00100000, 0x00100000, 0x00011100,
0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h
0x00111110, 0x01010101, 0x01001101, 0x00100110,
0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h
0x01000001, 0x01000001, 0x00000001, 0x00000010,
0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h
0x00010000, 0x00001000, 0x00010100, 0x01100010,
0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah
0x00111110, 0x01000101, 0x01000101, 0x00100010,
0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh
0x01010010, 0x00010010, 0x00010010, 0x00001001,
0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch
0x00111110, 0x00010000, 0x00000010, 0x00111100,
0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh
0x00000001, 0x00000110, 0x00011000, 0x00100000,
0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh
0x00100001, 0x00100001, 0x00100001, 0x00010010,
0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh
0x00000000, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h
0x00100000, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h
0x00010100, 0x00010100, 0x00011000, 0x00001100,
0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h
0x00100010, 0x00000010, 0x00000010, 0x01111100,
0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h
0x01111111, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h
0x01110100, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h
0x00111100, 0x01000010, 0x01000000, 0x00111100,
0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h
0x00001000, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h
0x00000010, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah
0x00010001, 0x00111100, 0x00010010, 0x00001100,
0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh
0x00000010, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch
0x01001011, 0x01101101, 0x01010101, 0x00110010,
0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh
0x01000110, 0x01110010, 0x01001011, 0x00110010,
0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh
0x01001001, 0x01000101, 0x01000101, 0x00110010,
0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh
0x00100001, 0x00111001, 0x01100101, 0x00011001,
0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h
0x00100001, 0x00100001, 0x00010010, 0x00001100,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h
0x00000000, 0x00000100, 0x00001010, 0x00000100,
0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h
0x00010000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h
0x00001000, 0x00001000, 0x00001000, 0x00001110,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h
0x00000000, 0x00000010, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h
0x00011000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h
0x00010100, 0x00001100, 0x00000100, 0x00000010,
0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h
0x00010000, 0x00001111, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah
0x00001000, 0x00001000, 0x00001000, 0x01111111,
0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh
0x00011000, 0x00010100, 0x00010010, 0x00011001,
0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach
0x00100010, 0x00010010, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh
0x00100000, 0x00100000, 0x00100000, 0x01111111,
0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh
0x00111110, 0x00100000, 0x00100000, 0x00111110,
0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh
0x00101010, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h
0x01111111, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h
0x00011000, 0x00001000, 0x00001000, 0x00000100,
0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h
0x00010111, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h
0x01000001, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h
0x00001000, 0x00001000, 0x00001000, 0x01111111,
0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h
0x00101000, 0x00100100, 0x00100010, 0x00110001,
0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h
0x01000100, 0x01000100, 0x01000010, 0x00100001,
0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h
0x01111111, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h
0x01000010, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah
0x01000000, 0x01000000, 0x01000000, 0x01111110,
0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh
0x00100010, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch
0x01000100, 0x00100000, 0x00011000, 0x00000111,
0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh
0x00010000, 0x00011000, 0x00100100, 0x01000011,
0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh
0x00100010, 0x00000010, 0x00000010, 0x01111100,
0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh
0x00100000, 0x00100000, 0x00011000, 0x00000110,
0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h
0x01110001, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h
0x01111111, 0x00010000, 0x00010000, 0x00001100,
0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h
0x01000000, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h
0x00010000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h
0x00011010, 0x01100010, 0x00000010, 0x00000010,
0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h
0x00010000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h
0x00000000, 0x00000000, 0x00000000, 0x01111111,
0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h
0x00101000, 0x00010000, 0x00101000, 0x01000110,
0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h
0x00010000, 0x00011100, 0x01101011, 0x00001000,
0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h
0x00100000, 0x00100000, 0x00011000, 0x00000111,
0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah
0x01000010, 0x01000010, 0x01000001, 0x01000001,
0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh
0x00000001, 0x00000001, 0x00000001, 0x01111110,
0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch
0x01000000, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh
0x00010001, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh
0x00001000, 0x00101010, 0x01001010, 0x01001001,
0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh
0x00100010, 0x00010100, 0x00001000, 0x00010000,
0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h
0x01110000, 0x00000110, 0x00011000, 0x01100000,
0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h
0x00000100, 0x00100010, 0x01000010, 0x01111111,
0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h
0x00101000, 0x00010000, 0x00101100, 0x01000011,
0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h
0x00000100, 0x00000100, 0x00000100, 0x01111000,
0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h
0x00100010, 0x00010100, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h
0x00100000, 0x00100000, 0x00100000, 0x01111111,
0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h
0x01111110, 0x01000000, 0x01000000, 0x01111110,
0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h
0x01000010, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h
0x01001010, 0x01001010, 0x00101010, 0x00011001,
0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah
0x01000010, 0x00100010, 0x00010010, 0x00001110,
0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh
0x01000001, 0x01000001, 0x01000001, 0x01111111,
0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh
0x01000000, 0x00100000, 0x00010000, 0x00001111,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh 0
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh 1
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h 2
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h 3
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h 4
0x00100001, 0x00111001, 0x01100101, 0x00011001,
0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h 5
0x00010000, 0x00011100, 0x00110010, 0x00001100,
0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h 6
0x00111110, 0x01100101, 0x00100101, 0x00010010,
0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h 7
0x00000110, 0x01000101, 0x01000101, 0x00111110,
0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h 8
0x01010010, 0x01010101, 0x01001101, 0x00100110,
0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h 9
0x00011111, 0x01000010, 0x01000010, 0x00111100,
0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h 10
0x01000010, 0x00100100, 0x00000100, 0x00000100,
0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h 11
0x01001001, 0x01001001, 0x00111000, 0x00000100,
0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah 12
0x00001000, 0x00011110, 0x00101001, 0x00000110,
0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh 13
0x00111010, 0x01000110, 0x01000000, 0x00111000,
0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech 14
0x01000110, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh 15
0x01000011, 0x01001100, 0x01010010, 0x00111100,
0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh 16
0x00100110, 0x00100010, 0x00100011, 0x01000010,
0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh 17
0x01000011, 0x01000000, 0x01000010, 0x00111100,
0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h 18
0x01000010, 0x01000011, 0x01000010, 0x00110010,
0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h 19
0x01000110, 0x01000101, 0x01000101, 0x00111001,
0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h 20
0x00100100, 0x00100100, 0x00100010, 0x00010001,
0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h 21
0x00111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h 22
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h 23
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x33330000,
0x33330000,
0x33000000,
0x33000000, // 00f6h
0x33000000,
0x33000000,
0x33330000,
0x33330000,
0x00020000, // 00f7h
0x00020000,
0x00020000,
0x22222222,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000, // 00f8h
0x00000000,
0x00000000,
0x00000000,
0x11111111,
0x11111111,
0x11111111,
0x11111111,
0x11111111, // 00f9h
0x11111111,
0x11111111,
0x11111111,
0x11111111,
0x11111111,
0x11111111,
0x11111111,
0x11111111, // 00fah
0x11111111,
0x11111111,
0x11111111,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000, // 00fbh
0x00000000,
0x00000000,
0x22222222,
0x00020000,
0x00020000,
0x00020000,
0x00020000,
0x00020000, // 00fch
0x00020000,
0x00020000,
0x22222222,
0x00020000,
0x00020000,
0x00020000,
0x00020000,
0x00020000, // 00fdh
0x00020000,
0x00020000,
0x00020000,
0x00020000,
0x00020000,
0x00020000,
0x00020000,
0x00000000, // 00feh
0x00000000,
0x00000000,
0x22222222,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00020000,
0x00220000,
0x02122222,
0x21111112,
0x21111112,
0x02122222,
0x00220000,
0x00020000,
/*
0x00022222,
0x00002112,
0x00021112,
0x00211122,
0x02111202,
0x21112000,
0x02120000,
0x00200000,
*/
/*
0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh
0x00001000, 0x00001000, 0x00001000, 0x00000110
*/
};
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,160 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: praphics.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
//#include <twl/mic.h>
#include <nitro/snd.h>
#include "kami_font.h"
#include "graphics.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: InitGraphics
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void
InitGraphics(void)
{
GX_DispOff();
GXS_DispOff();
//---- VRAM クリア
GX_SetBankForLCDC(GX_VRAM_LCDC_ALL);
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
//---- OAMとパレットクリア
MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE);
MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE);
MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE);
MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
//---- OBJバンクの設定
GX_SetBankForOBJ(GX_VRAM_OBJ_128_A);
GX_SetBankForSubOBJ(GX_VRAM_SUB_OBJ_128_D);
//---- BGバンクの設定
GX_SetBankForBG(GX_VRAM_BG_128_B);
GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C);
//---- 表示モード設定
GX_SetGraphicsMode (GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_3D);
GX_SetVisiblePlane (GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ);
GXS_SetVisiblePlane(GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_OBJ);
//---- 3D初期化
G3X_Init();
G3X_InitMtxStack();
G2_SetBG0Priority(0);
G3X_AlphaTest(FALSE, 0);
G3X_AntiAlias(TRUE);
G3X_EdgeMarking(FALSE);
G3X_SetFog(FALSE, (GXFogBlend)0, (GXFogSlope)0, 0);
G3X_SetClearColor(0, 0, 0x7fff, 63, FALSE);
G3_ViewPort(0, 0, 255, 191);
G3_MtxMode(GX_MTXMODE_POSITION_VECTOR);
//---- 32KバイトのOBJで2Dマップモードで使用
GX_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_2D);
// スクリーンオフセット及びキャラクターオフセットの設定
GX_SetBGScrOffset(GX_BGSCROFFSET_0x00000);
GX_SetBGCharOffset(GX_BGCHAROFFSET_0x10000);
G2_SetBG1Control(
GX_BG_SCRSIZE_TEXT_256x256,
GX_BG_COLORMODE_16,
GX_BG_SCRBASE_0x0000 ,
GX_BG_CHARBASE_0x00000,
GX_BG_EXTPLTT_01
);
G2S_SetBG0Control(
GX_BG_SCRSIZE_TEXT_256x256,
GX_BG_COLORMODE_16,
GX_BG_SCRBASE_0x0000 ,
GX_BG_CHARBASE_0x04000,
GX_BG_EXTPLTT_01
);
G2S_SetBG1Control(
GX_BG_SCRSIZE_TEXT_256x256,
GX_BG_COLORMODE_16,
GX_BG_SCRBASE_0x2000 ,
GX_BG_CHARBASE_0x04000,
GX_BG_EXTPLTT_01
);
G2_BG1Mosaic(FALSE);
G2S_BG1Mosaic(FALSE);
//---- データロード
GX_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData));
GX_LoadBG1Char( sampleCharData, 0, sizeof(sampleCharData));
GX_LoadBGPltt ( PlttDataMain, 0, sizeof(PlttDataMain));
GX_LoadBG1Scr ( BgScDataMain, 0, sizeof(BgScDataMain));
GX_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj));
GXS_LoadOBJ ( sampleCharData, 0, sizeof(sampleCharData));
GXS_LoadBG0Char( sampleCharData, 0, sizeof(sampleCharData));
GXS_LoadBGPltt ( PlttDataSub, 0, sizeof(PlttDataSub));
GXS_LoadBG0Scr ( BgScDataSub, 0, sizeof(BgScDataSub));
GXS_LoadOBJPltt( PlttDataObj, 0, sizeof(PlttDataObj));
GX_DispOn();
GXS_DispOn();
}
/*---------------------------------------------------------------------------*
Name: DrawLine
Description:
Arguments: sx -
sy -
ex -
ey -
color -
Returns: None.
*---------------------------------------------------------------------------*/
void
DrawLine(s16 sx, s16 sy, s16 ex, s16 ey, GXRgb color)
{
fx16 fsx = (fx16)(((sx - 128) * 0x1000) / 128);
fx16 fsy = (fx16)(((96 - sy) * 0x1000) / 96);
fx16 fex = (fx16)(((ex - 128) * 0x1000) / 128);
fx16 fey = (fx16)(((96 - ey) * 0x1000) / 96);
G3_Begin(GX_BEGIN_TRIANGLES);
{
G3_Color( color );
G3_Vtx(fsx, fsy, 0);
G3_Color( color );
G3_Vtx(fex, fey, 0);
G3_Color( color );
G3_Vtx(fsx, fsy, 1);
}
G3_End();
}

View File

@ -0,0 +1,392 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: kami_font.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "kami_font.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define SCREEN_DATA_COLOR_PLTT_SHIFT 12
#define NUM_OF_PRINT_TARGET 2
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static u8 sXPos;
static u8 sYPos;
static u32 sBackColorCharData[24*8];
static u16 sFontScreenDataMain[32 * 24] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
static u16 sFontScreenDataSub[24*32] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
static u16 sBackColorScreenData[32 * 24] = {
0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,0xf0de,
0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,0xf0df,
0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,0xf0e0,
0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,0xf0e1,
0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,0xf0e2,
0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,0xf0e3,
0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,0xf0e4,
0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,0xf0e5,
0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,0xf0e6,
0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,0xf0e7,
0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,0xf0e8,
0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,0xf0e9,
0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,0xf0ea,
0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,0xf0eb,
0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,0xf0ec,
0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,0xf0ed,
0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,0xf0ee,
0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,0xf0ef,
0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,0xf0f0,
0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,0xf0f1,
0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,0xf0f2,
0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,0xf0f3,
0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,0xf0f4,
0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,0xf0f5,
};
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static void kamiFontReturnConsole( void );
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontInit(void)
{
// 背景用キャラクタデータ
MI_CpuCopy32( &sampleCharData[8 * 0xde], sBackColorCharData, sizeof(sBackColorCharData) );
// 背景用スクリーンデータセット
DC_FlushRange ( sBackColorScreenData, sizeof(sBackColorScreenData) );
GXS_LoadBG1Scr ( sBackColorScreenData, 0, sizeof(sBackColorScreenData) );
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontLoadScreenData(void)
{
DC_FlushRange ( sFontScreenDataMain, sizeof(sFontScreenDataMain) );
GX_LoadBG0Scr ( sFontScreenDataMain, 0, sizeof(sFontScreenDataMain) );
DC_FlushRange ( sFontScreenDataSub, sizeof(sFontScreenDataSub) );
GXS_LoadBG0Scr ( sFontScreenDataSub, 0, sizeof(sFontScreenDataSub) );
// 背景キャラクタデータ書き換え
DC_FlushRange( sBackColorCharData, sizeof(sBackColorCharData) );
GXS_LoadBG0Char( sBackColorCharData, 0xde*32, sizeof(sBackColorCharData) );
}
/*---------------------------------------------------------------------------*
Name: kamiFontClear
Description:
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontClear(void)
{
MI_CpuClear8( sFontScreenDataSub, sizeof(sFontScreenDataSub) );
}
/*---------------------------------------------------------------------------*
Name: kamiFontPrintf
Description: 32
Arguments: x - x ( × 8 )
y - y ( × 8 )
color -
text - NULL
... -
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontPrintf(s16 x, s16 y, u8 color, char *text, ...)
{
va_list vlist;
char temp[32 + 2];
s32 i;
va_start(vlist, text);
(void)vsnprintf(temp, 33, text, vlist);
va_end(vlist);
*(u16 *)(&temp[32]) = 0x0000;
for (i = 0;temp[i] != 0x00; i++)
{
sFontScreenDataSub[((y * 32) + x + i) % (24 * 32)] =
(u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]);
}
}
/*---------------------------------------------------------------------------*
Name: kamiFontPrintf
Description: 32
Arguments: x - x ( × 8 )
y - y ( × 8 )
color -
text - NULL
... -
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...)
{
va_list vlist;
char temp[32 + 2];
s32 i;
va_start(vlist, text);
(void)vsnprintf(temp, 33, text, vlist);
va_end(vlist);
*(u16 *)(&temp[32]) = 0x0000;
for (i = 0;temp[i] != 0x00; i++)
{
sFontScreenDataMain[((y * 32) + x + i) % (24 * 32)] =
(u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]);
}
}
/*---------------------------------------------------------------------------*
Name: kamiFontFillChar
Description:
Arguments: x - x ( × 8 )
y - y ( × 8 )
color -
value
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontFillChar(int lineNo, u8 color1, u8 color2)
{
s32 i;
u32 line;
int charNo = 0xde + lineNo;
if (color1 < 0x10)
{
line = (u32)(0x11111111 * color1);
for (i = 0;i<4; i++)
{
sBackColorCharData[8 * lineNo + i] = line;
}
}
if (color2 < 0x10)
{
line = (u32)(0x11111111 * color2);
for (i = 4;i<8; i++)
{
sBackColorCharData[8 * lineNo + i] = line;
}
}
}
/*---------------------------------------------------------------------------*
Name: kamiFontPrintfConsole
Description: 256
Arguments: color -
text - NULL
... -
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontPrintfConsole(u8 color, char *text, ...)
{
va_list vlist;
char temp[256 + 2];
s32 i;
va_start(vlist, text);
(void)vsnprintf(temp, 256, text, vlist);
va_end(vlist);
// 終端追加
*(u16 *)(&temp[256]) = 0x0000;
for(i=0; temp[i] != 0x00; i++)
{
if (temp[i] == 0x0A)
{
// 改行コード
kamiFontReturnConsole();
}
else
{
// 一文字ずつ書き込み
sFontScreenDataMain[((sYPos * 32) + sXPos) % (24 * 32)] =
(u16)((color << SCREEN_DATA_COLOR_PLTT_SHIFT) | temp[i]);
// X座標が右端に到達した場合は改行処理
if (++sXPos >= 32)
{
kamiFontReturnConsole();
}
}
}
}
/*---------------------------------------------------------------------------*
Name: kamiFontPrintfConsoleEx
Description: 256
OS_Printfもついでに実行する
Arguments: color -
text - NULL
... -
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontPrintfConsoleEx(u8 color, char *text, ...)
{
va_list vlist;
char temp[256 + 2];
va_start(vlist, text);
(void)vsnprintf(temp, 256, text, vlist);
va_end(vlist);
kamiFontPrintfConsole(color, temp);
OS_TPrintf(temp);
}
/*---------------------------------------------------------------------------*
Name: kamiFontReturnConsole
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
kamiFontReturnConsole( void )
{
sXPos = 0;
if (sYPos < 23)
{
// 次の行へ
sYPos++;
}
else
{
// 既に最終行に到達している場合シフトを行う
MI_CpuCopy32( &sFontScreenDataMain[32], sFontScreenDataMain, sizeof(u16)*32*23 );
MI_CpuClear32( &sFontScreenDataMain[32*23], sizeof(u16)*32);
}
}

View File

@ -0,0 +1,472 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: kami_pxi.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "kami_pxi.h"
#include "fifo.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
// 詰めてコピーする
#define KAMI_PACK_U16(d, s) \
((d)[0] = (u8)((*((u16*)s) >> 0) & 0xFF), \
(d)[1] = (u8)((*((u16*)s) >> 8) & 0xFF))
#define KAMI_PACK_U32(d, s) \
((d)[0] = (u8)((*((u32*)s) >> 0) & 0xFF), \
(d)[1] = (u8)((*((u32*)s) >> 8) & 0xFF), \
(d)[2] = (u8)((*((u32*)s) >> 16) & 0xFF), \
(d)[3] = (u8)((*((u32*)s) >> 24) & 0xFF))
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
typedef struct KamiWork
{
BOOL lock;
KamiCommand command;
KAMIPxiResult result;
KAMICallback callback;
void* arg;
u32 total;
u32 current;
u8* data;
}
KamiWork;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL kamiInitialized;
static KamiWork kamiWork;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL KamiSendPxiCommand(KamiCommand command, u8 size, u8 data);
static void KamiSendPxiData(u8 *pData);
static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err);
static void KamiDone(KAMIResult result);
static void KamiWaitBusy(void);
void KamiPxiInit( void )
{
kamiWork.lock = FALSE;
PXI_Init();
while ( !PXI_IsCallbackReady(PXI_FIFO_TAG_KAMITEST, PXI_PROC_ARM7 ))
{
}
PXI_SetFifoRecvCallback(PXI_FIFO_TAG_KAMITEST, KamiPxiCallback);
if ( 0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, 0, 0))
{
return;
}
}
///////////////////////////////////////////////////////////////////
//typedef void (*KAMICallback)(KAMIResult result, void *arg);
/*
void CDC_ReadCallback(KAMIResult result, void* arg);
void CDC_ReadCallback(KAMIResult result, void* arg)
{
}
*/
/*---------------------------------------------------------------------------*
Name: CODEC
Description:
Arguments: None.
Returns:
*---------------------------------------------------------------------------*/
KAMIResult CDC_ReadRegister(u8 page, u8 reg_no, u8* pData)
{
OSIntrMode enabled;
// ロック
enabled = OS_DisableInterrupts();
if (kamiWork.lock)
{
(void)OS_RestoreInterrupts(enabled);
return KAMI_RESULT_BUSY;
}
kamiWork.lock = TRUE;
(void)OS_RestoreInterrupts(enabled);
kamiWork.callback = NULL;
kamiWork.arg = 0;
kamiWork.data = (u8*)pData;
if (KamiSendPxiCommand(CODEC_READ_REGISTER, 2, page))
{
KamiSendPxiData(&reg_no);
KamiWaitBusy();
return (KAMIResult)kamiWork.result;
}
return KAMI_RESULT_SEND_ERROR;
}
/*---------------------------------------------------------------------------*
Name: CODEC
Description:
Arguments: None.
Returns:
*---------------------------------------------------------------------------*/
KAMIResult CDC_WriteRegister(u8 page, u8 reg_no, u8 value)
{
OSIntrMode enabled;
u8 data[2];
int i;
// ロック
enabled = OS_DisableInterrupts();
if (kamiWork.lock)
{
(void)OS_RestoreInterrupts(enabled);
return KAMI_RESULT_BUSY;
}
kamiWork.lock = TRUE;
(void)OS_RestoreInterrupts(enabled);
kamiWork.callback = NULL;
kamiWork.arg = 0;
kamiWork.data = 0;
// データ作成
data[0] = reg_no;
data[1] = value;
if (KamiSendPxiCommand(CODEC_WRITE_REGISTER, 3, page))
{
for (i = 0; i < 2; i++)
{
KamiSendPxiData(&data[i]);
}
KamiWaitBusy();
return (KAMIResult)kamiWork.result;
}
return KAMI_RESULT_SEND_ERROR;
}
/*---------------------------------------------------------------------------*
Name: GPIO333
Description:
Arguments: None.
Returns:
*---------------------------------------------------------------------------*/
KAMIResult GPIO333_Write(BOOL value)
{
OSIntrMode enabled;
// ロック
enabled = OS_DisableInterrupts();
if (kamiWork.lock)
{
(void)OS_RestoreInterrupts(enabled);
return KAMI_RESULT_BUSY;
}
kamiWork.lock = TRUE;
(void)OS_RestoreInterrupts(enabled);
kamiWork.callback = NULL;
kamiWork.arg = 0;
kamiWork.data = 0;
if (KamiSendPxiCommand(GPIO333_WRITE, 1, (u8)value))
{
KamiWaitBusy();
return (KAMIResult)kamiWork.result;
}
return KAMI_RESULT_SEND_ERROR;
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: FormatMode
Returns:
*---------------------------------------------------------------------------*/
KAMIResult ExeFormatAsync(FormatMode format_mode, KAMICallback callback)
{
OSIntrMode enabled;
// ロック
enabled = OS_DisableInterrupts();
if (kamiWork.lock)
{
(void)OS_RestoreInterrupts(enabled);
return KAMI_RESULT_BUSY;
}
kamiWork.lock = TRUE;
(void)OS_RestoreInterrupts(enabled);
kamiWork.callback = callback;
kamiWork.arg = 0;
kamiWork.data = 0;
if (KamiSendPxiCommand(EXE_FORMAT, 1, format_mode) == FALSE)
{
return KAMI_RESULT_SEND_ERROR;
}
return KAMI_RESULT_SUCCESS;
}
/*---------------------------------------------------------------------------*
Name: NANDアクセス関数
Description:
Arguments: None.
Returns:
*---------------------------------------------------------------------------*/
KAMIResult kamiNandIo(u32 block, void* buffer, u32 count, BOOL is_read)
{
OSIntrMode enabled;
u8 data[12];
int i;
// ロック
enabled = OS_DisableInterrupts();
if (kamiWork.lock)
{
(void)OS_RestoreInterrupts(enabled);
return KAMI_RESULT_BUSY;
}
kamiWork.lock = TRUE;
(void)OS_RestoreInterrupts(enabled);
kamiWork.callback = NULL;
kamiWork.arg = 0;
kamiWork.data = 0;
// データ作成
KAMI_PACK_U32(&data[0], &block);
KAMI_PACK_U32(&data[4], &buffer);
KAMI_PACK_U32(&data[8], &count);
if (KamiSendPxiCommand(KAMI_NAND_IO, 12, (u8)is_read))
{
for (i = 0; i < 12; i+=3)
{
KamiSendPxiData(&data[i]);
}
KamiWaitBusy();
return (KAMIResult)kamiWork.result;
}
return KAMI_RESULT_SEND_ERROR;
}
/*---------------------------------------------------------------------------*
Name: Nvramアクセス関数
Description:
Arguments: None.
Returns:
*---------------------------------------------------------------------------*/
KAMIResult kamiNvramIo(u32 address, void* buffer, u32 size, BOOL is_read)
{
OSIntrMode enabled;
u8 data[12];
int i;
// ロック
enabled = OS_DisableInterrupts();
if (kamiWork.lock)
{
(void)OS_RestoreInterrupts(enabled);
return KAMI_RESULT_BUSY;
}
kamiWork.lock = TRUE;
(void)OS_RestoreInterrupts(enabled);
kamiWork.callback = NULL;
kamiWork.arg = 0;
kamiWork.data = 0;
// データ作成
KAMI_PACK_U32(&data[0], &address);
KAMI_PACK_U32(&data[4], &buffer);
KAMI_PACK_U32(&data[8], &size);
if (KamiSendPxiCommand(KAMI_NVRAM_IO, 12, (u8)is_read))
{
for (i = 0; i < 12; i+=3)
{
KamiSendPxiData(&data[i]);
}
KamiWaitBusy();
return (KAMIResult)kamiWork.result;
}
return KAMI_RESULT_SEND_ERROR;
}
///////////////////////////////////////////////////////////////////
/////////
static BOOL KamiSendPxiCommand(KamiCommand command, u8 size, u8 data)
{
u32 pxiData = (u32)(KAMITEST_PXI_START_BIT |
((command << KAMITEST_PXI_COMMAND_SHIFT) & KAMITEST_PXI_COMMAND_MASK) |
((size << KAMITEST_PXI_DATA_NUMS_SHIFT) & KAMITEST_PXI_DATA_NUMS_MASK) |
((data << KAMITEST_PXI_1ST_DATA_SHIFT) & KAMITEST_PXI_1ST_DATA_MASK));
if (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0))
{
return FALSE;
}
return TRUE;
}
static void KamiSendPxiData(u8 *pData)
{
u32 pxiData = (u32)((pData[0] << 16) | (pData[1] << 8) | pData[2]);
while (0 > PXI_SendWordByFifo(PXI_FIFO_TAG_KAMITEST, pxiData, 0))
{
}
}
static void KamiPxiCallback(PXIFifoTag tag, u32 data, BOOL err)
{
#pragma unused( tag )
if (err)
{
KamiDone(KAMI_RESULT_FATAL_ERROR);
return;
}
if (data & KAMITEST_PXI_START_BIT) // 先頭データ
{
if (data & KAMITEST_PXI_RESULT_BIT)
{
kamiWork.total = (u8)((data & KAMITEST_PXI_DATA_NUMS_MASK) >> KAMITEST_PXI_DATA_NUMS_SHIFT);
kamiWork.current = 0;
kamiWork.command = (KamiCommand)((data & KAMITEST_PXI_COMMAND_MASK) >> KAMITEST_PXI_COMMAND_SHIFT);
kamiWork.result = (KAMIPxiResult)((data & KAMITEST_PXI_1ST_DATA_MASK) >> KAMITEST_PXI_1ST_DATA_SHIFT);
}
else // 未知のデータ
{
KamiDone(KAMI_RESULT_FATAL_ERROR);
return;
}
}
else // 後続データ
{
if (kamiWork.data == NULL)
{
KamiDone(KAMI_RESULT_FATAL_ERROR);
return;
}
if (kamiWork.current < kamiWork.total-1)
{
kamiWork.data[kamiWork.current++] = (u8)((data & 0xFF0000) >> 16);
}
if (kamiWork.current < kamiWork.total-1)
{
kamiWork.data[kamiWork.current++] = (u8)((data & 0x00FF00) >> 8);
}
if (kamiWork.current < kamiWork.total-1)
{
kamiWork.data[kamiWork.current++] = (u8)((data & 0x0000FF) >> 0);
}
}
if (kamiWork.current == kamiWork.total-1)
{
KAMIResult result;
switch (kamiWork.result)
{
case KAMI_PXI_RESULT_SUCCESS: // alias KAMI_PXI_RESULT_SUCCESS_TRUE
result = KAMI_RESULT_SUCCESS; // alias KAMI_RESULT_SUCCESS_TRUE
break;
case KAMI_PXI_RESULT_SUCCESS_FALSE:
result = KAMI_RESULT_SUCCESS_FALSE;
break;
case KAMI_PXI_RESULT_INVALID_COMMAND:
result = KAMI_RESULT_INVALID_COMMAND;
break;
case KAMI_PXI_RESULT_INVALID_PARAMETER:
result = KAMI_RESULT_INVALID_PARAMETER;
break;
case KAMI_PXI_RESULT_ILLEGAL_STATUS:
result = KAMI_RESULT_ILLEGAL_STATUS;
break;
case KAMI_PXI_RESULT_BUSY:
result = KAMI_RESULT_BUSY;
break;
default:
result = KAMI_RESULT_FATAL_ERROR;
}
KamiDone(result);
return;
}
}
extern void PXIi_HandlerRecvFifoNotEmpty(void);
static void KamiWaitBusy(void)
{
volatile BOOL *p = &kamiWork.lock;
while (*p)
{
if (OS_GetCpsrIrq() == OS_INTRMODE_IRQ_DISABLE)
{
PXIi_HandlerRecvFifoNotEmpty();
}
}
}
static void KamiDone(KAMIResult result)
{
KAMICallback callback = kamiWork.callback;
void* arg = kamiWork.arg;
kamiWork.callback = NULL;
kamiWork.arg = NULL;
if (kamiWork.lock)
{
kamiWork.lock = FALSE;
}
if (callback)
{
callback(result, arg);
}
}

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: keypad.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "keypad.h"
/*---------------------------------------------------------------------------*
è<EFBFBD>è`
*---------------------------------------------------------------------------*/
#define KEY_REPEAT_TRIGGER_START 20
#define KEY_REPEAT_TRIGGER_TERM 5
/*---------------------------------------------------------------------------*
àÏ<EFBFBD>è`
*---------------------------------------------------------------------------*/
static u16 Cont;
static u16 Trg;
static u16 Release;
static u16 RepeatTrg;
static u8 key = 60;
static int repeat_counter;
/*---------------------------------------------------------------------------*
àŠÖ<EFBFBD>è`
*---------------------------------------------------------------------------*/
void
kamiPadRead(void)
{
u16 ReadData;
ReadData = PAD_Read();
Trg = (u16)(ReadData & (ReadData ^ Cont));
Release = (u16)(Cont & (ReadData ^ Cont));
Cont = ReadData;
RepeatTrg = Trg;
if (++repeat_counter > (KEY_REPEAT_TRIGGER_START + KEY_REPEAT_TRIGGER_TERM))
{
repeat_counter = KEY_REPEAT_TRIGGER_START;
}
if (repeat_counter == KEY_REPEAT_TRIGGER_START)
{
RepeatTrg = ReadData;
}
if (!ReadData)
{
repeat_counter = 0;
}
}
BOOL
kamiPadIsTrigger(u16 key)
{
return (Trg & key)? TRUE : FALSE;
}
BOOL
kamiPadIsRepeatTrigger(u16 key)
{
return (RepeatTrg & key)? TRUE : FALSE;
}
BOOL
kamiPadIsPress(u16 key)
{
return (Cont & key)? TRUE : FALSE;
}

View File

@ -0,0 +1,180 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: main.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include "kami_font.h"
#include "process_format.h"
#include "process_topmenu.h"
#include "graphics.h"
#include "keypad.h"
#include "kami_pxi.h"
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
extern void HWInfoWriterInit( void );
typedef void* (*Process)(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static Process sProcess;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static void VBlankIntr(void);
static void InitAllocation(void);
/*---------------------------------------------------------------------------*
Name: TwlMain
Description: main
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void
TwlMain()
{
OS_Init();
OS_InitArena();
PXI_Init();
OS_InitLock();
OS_InitArenaEx();
OS_InitIrqTable();
OS_SetIrqStackChecker();
MI_Init();
OS_InitVAlarm();
OSi_InitVramExclusive();
OS_InitThread();
OS_InitReset();
GX_Init();
FX_Init();
SND_Init();
TP_Init();
RTC_Init();
InitAllocation();
KamiPxiInit(); /* 独自PXI初期化 */
// Vブランク割り込み設定
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)OS_EnableIrqMask(OS_IE_FIFO_RECV);
(void)OS_EnableIrq();
(void)GX_VBlankIntr(TRUE);
/* initialize file-system */
FS_Init(FS_DMA_NOT_USE);
// NAMライブラリ初期化
NAM_Init( OS_AllocFromMain, OS_FreeToMain);
// 表示関連初期化
InitGraphics();
kamiFontInit();
/* always preload FS table for faster directory access. */
{
u32 need_size = FS_GetTableSize();
void *p_table = OS_Alloc(need_size);
SDK_ASSERT(p_table != NULL);
(void)FS_LoadTable(p_table, need_size);
}
// 初期シーケンス設定
sProcess = TopmenuProcess0;
kamiFontPrintfConsole( CONSOLE_ORANGE, "Thank you for using program.\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "l A Button : Select Menu l\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "l Up/Down Key : Change Menu l\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "l L&R Button : Auto Init * l\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "* Note that nand memory is deleted.\n");
while (1)
{
kamiPadRead();
// 蓋閉じ検出
if (PAD_DetectFold() == TRUE)
{
PM_GoSleepMode_Twl(PM_TRIGGER_COVER_OPEN, 0, 0);
}
// コマンドフラッシュ
(void)SND_FlushCommand(SND_COMMAND_NOBLOCK);
// Vブランク待ち
OS_WaitVBlankIntr();
// ARM7コマンド応答受信
while (SND_RecvCommandReply(SND_COMMAND_NOBLOCK) != NULL)
{
}
// フォントスクリーンデータロード
kamiFontLoadScreenData();
sProcess = sProcess();
}
}
/*---------------------------------------------------------------------------*
Name: VBlankIntr
Description: VBlank割り込み処理
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
VBlankIntr(void)
{
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
}
/*---------------------------------------------------------------------------*
Name: InitAllocation
Description: .
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void InitAllocation(void)
{
void *tmp;
OSHeapHandle hh;
/* アリーナの初期化 */
tmp = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1);
OS_SetArenaLo(OS_ARENA_MAIN, tmp);
hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi());
if (hh < 0)
OS_Panic("ARM9: Fail to create heap...\n");
hh = OS_SetCurrentHeap(OS_ARENA_MAIN, hh);
}

View File

@ -0,0 +1,216 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_auto.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "kami_font.h"
#include "process_topmenu.h"
#include "process_format.h"
#include "process_hw_info.h"
#include "process_import.h"
#include "process_eticket.h"
#include "process_nandfirm.h"
#include "process_norfirm.h"
#include "process_auto.h"
#include "cursor.h"
#include "keypad.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 6
#define DOT_OF_MENU_SPACE 16
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
BOOL gAutoFlag = FALSE;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess0(void)
{
// オートフラグセット
gAutoFlag = TRUE;
// メニュー初期化
sMenuSelectNo = 0;
// カーソル消去
SetCursorPos((u16)200, (u16)200);
return AutoProcess1;
}
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess1(void)
{
switch ( sMenuSelectNo++ )
{
case 0:
return FormatProcess0;
case 1:
return HWInfoProcess0;
break;
case 2:
return eTicketProcess0;
case 3:
return ImportProcess0;
case 4:
return NandfirmProcess0;
case 5:
return AutoProcess2;
}
// never reach
return TopmenuProcess0;
}
/*---------------------------------------------------------------------------*
Name: Top Menu 2
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess2(void)
{
int i;
u8 bg_color;
// 文字列全クリア
kamiFontClear();
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Auto Nand Initialization");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// メニュー一覧
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, " FORMAT NAND ");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, " WRITE HARDWARE INFO ");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, " WRITE ETICKET SIGN ");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, " INPORT TAD FROM SD ");
kamiFontPrintf(3, 15, FONT_COLOR_BLACK, " INPORT NANDFIRM FROM SD");
kamiFontPrintf(3, 22, FONT_COLOR_BLACK, " Button B : return to menu");
for (i=0;i<sMenuSelectNo-1;i++)
{
kamiFontPrintf(3, (s16)(7+2*i), FONT_COLOR_GREEN, "OK");
}
// 失敗あり
if (i<5)
{
kamiFontPrintf(3, (s16)(7+2*i), FONT_COLOR_RED, "NG");
kamiFontPrintf(3, 18, FONT_COLOR_BLACK, " Error Occured!");
bg_color = BG_COLOR_RED;
}
// 失敗なし
else
{
kamiFontPrintf(3, 18, FONT_COLOR_BLACK, " Finished Sucessfully!");
bg_color = BG_COLOR_GREEN;
}
// 背景上部
kamiFontFillChar( 0, bg_color, bg_color );
kamiFontFillChar( 1, bg_color, bg_color );
kamiFontFillChar( 2, bg_color, BG_COLOR_TRANS );
// 背景下部
kamiFontFillChar(17, BG_COLOR_TRANS, bg_color );
kamiFontFillChar(18, bg_color, bg_color );
kamiFontFillChar(19, bg_color, BG_COLOR_TRANS );
// オートフラグクリア
gAutoFlag = FALSE;
return AutoProcess3;
}
/*---------------------------------------------------------------------------*
Name: Top Menu 3
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* AutoProcess3(void)
{
if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return TopmenuProcess0;
}
return AutoProcess3;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,287 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_eticket.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include "process_topmenu.h"
#include "process_eticket.h"
#include "process_auto.h"
#include "cursor.h"
#include "keypad.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 2
#define DOT_OF_MENU_SPACE 16
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
#define ROUND_UP(value, alignment) \
(((u32)(value) + (alignment-1)) & ~(alignment-1))
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL MakeETicketFile(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: eTicket
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* eTicketProcess0(void)
{
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write eTicket Sign");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// メニュー一覧
kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE E-TICKET l l");
kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l RETURN l l");
kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+");
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景上部
kamiFontFillChar( 0, BG_COLOR_GRAY, BG_COLOR_GRAY );
kamiFontFillChar( 1, BG_COLOR_GRAY, BG_COLOR_GRAY );
kamiFontFillChar( 2, BG_COLOR_GRAY, BG_COLOR_TRANS );
return eTicketProcess1;
}
/*---------------------------------------------------------------------------*
Name: eTicket
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* eTicketProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return eTicketProcess2;
}
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0;
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return eTicketProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return TopmenuProcess0;
}
return eTicketProcess1;
}
/*---------------------------------------------------------------------------*
Name: eTicket
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* eTicketProcess2(void)
{
BOOL result;
switch( sMenuSelectNo )
{
case 0:
result = MakeETicketFile();
if (result)
{
kamiFontPrintf(25, 7, FONT_COLOR_GREEN, "OK");
}
else
{
kamiFontPrintf(25, 7, FONT_COLOR_RED, "NG");
}
break;
case 1:
return TopmenuProcess0;
}
// Auto用
if (gAutoFlag)
{
if (result) return AutoProcess1;
else return AutoProcess2;
}
return eTicketProcess1;
}
/*---------------------------------------------------------------------------*
Name: eTicket
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* eTicketProcess3(void)
{
return eTicketProcess3;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL MakeETicketFile(void)
{
FSFile file;
FATFSFileHandle fat_handle;
BOOL open_is_ok;
BOOL read_is_ok;
void* pTempBuf;
u32 file_size;
u32 alloc_size;
BOOL result = TRUE;
// F:sys/cert.sysが既に存在するなら何もしない
fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "r");
if (fat_handle)
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "%s already exist\n", E_TICKET_FILE_PATH_IN_NAND);
kamiFontPrintf(2, 20, FONT_COLOR_RED, "%s already exist", E_TICKET_FILE_PATH_IN_NAND);
FATFS_CloseFile(fat_handle);
return FALSE;
}
// ROMファイルオープン
FS_InitFile(&file);
open_is_ok = FS_OpenFile(&file, E_TICKET_FILE_PATH_IN_ROM);
if (!open_is_ok)
{
OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", E_TICKET_FILE_PATH_IN_ROM);
return FALSE;
}
// ROMファイルリード
file_size = FS_GetFileLength(&file) ;
alloc_size = ROUND_UP(file_size, 32) ;
pTempBuf = OS_Alloc( alloc_size );
SDK_NULL_ASSERT(pTempBuf);
DC_InvalidateRange(pTempBuf, alloc_size);
read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size );
if (!read_is_ok)
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", E_TICKET_FILE_PATH_IN_ROM);
FS_CloseFile(&file);
OS_Free(pTempBuf);
return FALSE;
}
// ROMファイルクローズ
FS_CloseFile(&file);
// F:sys/cert.sys作成
if (!FATFS_CreateFile(E_TICKET_FILE_PATH_IN_NAND, TRUE, "rwxrwxrwx"))
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_CreateFile(%s) failed.\n", E_TICKET_FILE_PATH_IN_NAND);
result = FALSE;
}
else
{
// F:sys/cert.sysオープン
fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "w");
if (!fat_handle)
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_OpenFile(%s) failed.\n", E_TICKET_FILE_PATH_IN_NAND);
result = FALSE;
}
// F:sys/cert.sys書き込み
else if (FATFS_WriteFile(fat_handle, pTempBuf, (s32)file_size) == -1)
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FATFS_WritFile() failed.\n");
result = FALSE;
}
(void)FATFS_CloseFile(fat_handle);
}
OS_Free(pTempBuf);
return result;
}

View File

@ -0,0 +1,294 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_format.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include "process_topmenu.h"
#include "process_format.h"
#include "process_auto.h"
#include "cursor.h"
#include "keypad.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 4
#define DOT_OF_MENU_SPACE 16
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
static u8 sLock;
static u8 sFormatResult;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static void FormatCallback(KAMIResult result, void* arg);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Format
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess0(void)
{
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Format Nand Flash");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// メニュー一覧
kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l QUICK FORMAT l l");
kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l FULL FORMAT l l");
kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l CHECK DISK l l");
kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l RETURN l l");
kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+-------------------+-----+");
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景上部
kamiFontFillChar( 0, BG_COLOR_BLUE, BG_COLOR_BLUE );
kamiFontFillChar( 1, BG_COLOR_BLUE, BG_COLOR_BLUE );
kamiFontFillChar( 2, BG_COLOR_BLUE, BG_COLOR_TRANS );
return FormatProcess1;
}
/*---------------------------------------------------------------------------*
Name: Format
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return FormatProcess2;
}
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0;
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return FormatProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return TopmenuProcess0;
}
return FormatProcess1;
}
/*---------------------------------------------------------------------------*
Name: Format
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess2(void)
{
if (sLock == FALSE)
{
switch( sMenuSelectNo )
{
case 0:
sLock = TRUE;
ExeFormatAsync(FORMAT_MODE_QUICK, FormatCallback);
kamiFontPrintf(24, 7, FONT_COLOR_BLACK, " ");
return FormatProcess3;
case 1:
sLock = TRUE;
ExeFormatAsync(FORMAT_MODE_FULL, FormatCallback);
kamiFontPrintf(24, 9, FONT_COLOR_BLACK, " ");
return FormatProcess3;
case 2:
{
FATFSDiskInfo info;
BOOL result = FALSE;
kamiFontPrintf(24, 11, FONT_COLOR_BLACK, " ");
kamiFontLoadScreenData();
FATFS_UnmountDrive("F:");
FATFS_UnmountDrive("G:");
// 指定のNANDパーティション0をFドライブにマウント
if (FATFS_MountDrive("F", FATFS_MEDIA_TYPE_NAND, 0))
{
// チェックディスク実行
if (FATFS_CheckDisk("F:", &info, TRUE, TRUE, TRUE))
{
// 指定のNANDパーティション1をGドライブにマウント
if (FATFS_MountDrive("G", FATFS_MEDIA_TYPE_NAND, 1))
{
// チェックディスク実行
if (FATFS_CheckDisk("G:", &info, TRUE, TRUE, TRUE))
{
result = TRUE;
}
}
}
}
// デフォルトマウント状態に戻しておく
FATFS_UnmountDrive("G:");
FATFS_MountDrive("G", FATFS_MEDIA_TYPE_SD, 0);
if (result == TRUE) { kamiFontPrintf(24, 11, FONT_COLOR_GREEN, " OK "); }
else { kamiFontPrintf(24, 11, FONT_COLOR_RED, " NG "); }
return FormatProcess1;
}
case 3:
return TopmenuProcess0;
}
}
return FormatProcess1;
}
static void FormatCallback(KAMIResult result, void* /*arg*/)
{
s16 y_pos;
if ( sMenuSelectNo == 0 ) y_pos = 7;
else y_pos = 9;
if ( result == KAMI_RESULT_SUCCESS_TRUE )
{
kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK ");
sFormatResult = TRUE;
}
else
{
kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG ");
sFormatResult = FALSE;
}
// ロック解除
sLock = FALSE;
}
/*---------------------------------------------------------------------------*
Name: Format
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess3(void)
{
static s32 progress;
s16 y_pos;
// 処理終了判定
if (sLock == FALSE)
{
progress = 0;
// Auto用
if (gAutoFlag)
{
if (sFormatResult == TRUE) return AutoProcess1;
else return AutoProcess2;
}
return FormatProcess1;
}
if ( sMenuSelectNo == 0 ) { y_pos = 7; }
else { y_pos = 9; }
// 進捗表示更新
if ( ++progress >= 30*5 )
{
progress = 0;
kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " ");
}
kamiFontPrintf((s16)(24 + (progress / 30)), y_pos, FONT_COLOR_BLACK, "*");
return FormatProcess3;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,664 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_hw_info.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include "process_topmenu.h"
#include "process_hw_info.h"
#include "process_auto.h"
#include "cursor.h"
#include "keypad.h"
#include <sysmenu/acsign.h>
//#include <sysmenu/settings/common/TWLHWInfo.h>
//#include <sysmenu/settings/common/TWLSettings.h>
//
#include "TWLHWInfo_api.h"
#include "TWLSettings_api.h"
//
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 8
#define DOT_OF_MENU_SPACE 16
#define CHAR_OF_MENU_SPACE 2
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
static const u32 s_langBitmapList[ LCFG_TWL_REGION_MAX ] = {
LCFG_TWL_LANG_BITMAP_JAPAN,
LCFG_TWL_LANG_BITMAP_AMERICA,
LCFG_TWL_LANG_BITMAP_EUROPE,
LCFG_TWL_LANG_BITMAP_AUSTRALIA,
LCFG_TWL_LANG_BITMAP_CHINA,
LCFG_TWL_LANG_BITMAP_KOREA,
};
static char *strLanguage[] = {
(char *)"LANG_JAPANESE",
(char *)"LANG_ENGLISH",
(char *)"LANG_FRENCH",
(char *)"LANG_GERMAN",
(char *)"LANG_ITALIAN",
(char *)"LANG_SPANISH",
(char *)"LANG_CHINESE",
(char *)"LANG_KOREAN",
};
static const char *strRegion[] = {
"JAPAN",
"AMERICA",
"EUROPE",
"AUSTRALIA",
"CHINA",
"KOREA",
};
static const char *strLauncherGameCode[] = {
"LNCJ",
"LNCE",
"LNCP",
"LNCO",
"LNCC",
"LNCK",
};
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
static u8 *s_pPrivKeyBuffer = NULL;
static LCFGReadResult (*s_pReadSecureInfoFunc)( void );
static BOOL s_isReadTSD;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
void HWInfoWriterInit( void );
static void ReadTWLSettings( void );
static void ModifyLanguage( u8 region );
static void ReadPrivateKey( void );
static void ReadHWInfoFile( void );
static void VerifyHWInfo( void );
static BOOL WriteHWInfoFile( u8 region );
static BOOL WriteHWNormalInfoFile( void );
static BOOL WriteHWSecureInfoFile( u8 region );
static BOOL DeleteHWInfoFile( void );
const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void );
const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void );
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: HWInfo
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess0(void)
{
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write Hardware Information ");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// メニュー一覧
kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l REGION JAPAN l l");
kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l REGION AMERICA l l");
kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l REGION EUROPE l l");
kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l REGION AUSTRALIA l l");
kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l REGION CHINA l l");
kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 17, FONT_COLOR_BLACK, "l REGION KOREA l l");
kamiFontPrintf(3, 18, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 19, FONT_COLOR_BLACK, "l DELETE l l");
kamiFontPrintf(3, 20, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 21, FONT_COLOR_BLACK, "l RETURN l l");
kamiFontPrintf(3, 22, FONT_COLOR_BLACK, "+--------------------+----+");
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景上部
kamiFontFillChar( 0, BG_COLOR_PURPLE, BG_COLOR_PURPLE );
kamiFontFillChar( 1, BG_COLOR_PURPLE, BG_COLOR_PURPLE );
kamiFontFillChar( 2, BG_COLOR_PURPLE, BG_COLOR_TRANS );
// 前準備
HWInfoWriterInit();
return HWInfoProcess1;
}
/*---------------------------------------------------------------------------*
Name: HWInfo
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return HWInfoProcess2;
}
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0;
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return HWInfoProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return TopmenuProcess0;
}
return HWInfoProcess1;
}
/*---------------------------------------------------------------------------*
Name: HWInfo
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess2(void)
{
int i;
BOOL result;
switch( sMenuSelectNo )
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
OS_TPrintf( "Write Start.\n" );
result = WriteHWInfoFile( (u8)sMenuSelectNo );
break;
case 6:
OS_TPrintf( "Delete start.\n" );
result = DeleteHWInfoFile();
break;
case 7:
return TopmenuProcess0;
}
// 全結果をクリア
for (i=0;i<NUM_OF_MENU_SELECT;i++)
{
kamiFontPrintf(26, (s16)(7+i*CHAR_OF_MENU_SPACE), FONT_COLOR_BLACK, " ");
}
// 今回の結果を表示
if ( result == TRUE )
{
kamiFontPrintf(26, (s16)(7+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK");
}
else
{
kamiFontPrintf(26, (s16)(7+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG");
}
// Auto用
if (gAutoFlag)
{
if (result) return AutoProcess1;
else return AutoProcess2;
}
return HWInfoProcess1;
}
/*---------------------------------------------------------------------------*
Name: HWInfo
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* HWInfoProcess3(void)
{
return HWInfoProcess3;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: HW情報ライターの初期化
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void HWInfoWriterInit( void )
{
// PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"HW Info Writer");
// GetAndDrawRTCData( &g_rtcDraw, TRUE );
ACSign_SetAllocFunc( OS_AllocFromMain, OS_FreeToMain );
ReadTWLSettings();
ReadPrivateKey();
ReadHWInfoFile();
// VerifyHWInfo();
OS_TPrintf( "region = %d\n", LCFG_THW_GetRegion() );
// s_csr = 0;
// DrawMenu( s_csr, &s_writerParam );
// GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
// GX_DispOn();
// GXS_DispOn();
}
/*---------------------------------------------------------------------------*
Name: TWL設定データのリード
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ReadTWLSettings( void )
{
s_isReadTSD = LCFGi_TSD_ReadSettings();
if( s_isReadTSD ) {
OS_TPrintf( "TSD read succeeded.\n" );
}else {
OS_TPrintf( "TSD read failed.\n" );
}
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ModifyLanguage( u8 region )
{
u32 langBitmap = s_langBitmapList[ region ];
u8 nowLanguage = LCFG_TSD_GetLanguage();
// TSDが読み込めていないなら、何もせずリターン
if( !s_isReadTSD ) {
return;
}
if( langBitmap & ( 0x0001 << nowLanguage ) ) {
OS_TPrintf( "Language no change.\n" );
}else {
int i;
for( i = 0; i < LCFG_TWL_LANG_CODE_MAX; i++ ) {
if( langBitmap & ( 0x0001 << i ) ) {
break;
}
}
LCFG_TSD_SetLanguage( (LCFGTWLLangCode)i );
LCFG_TSD_SetFlagCountry( FALSE ); // ※ついでに国コードもクリアしておく。
LCFG_TSD_SetCountry( LCFG_TWL_COUNTRY_UNDEFINED );
LCFGi_TSD_WriteSettings();
OS_TPrintf( "Language Change \"%s\" -> \"%s\"\n",
strLanguage[ nowLanguage ], strLanguage[ LCFG_TSD_GetLanguage() ] );
}
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ReadPrivateKey( void )
{
BOOL result = FALSE;
u32 keyLength;
FSFile file;
OSTick start = OS_GetTick();
FS_InitFile( &file );
if( !FS_OpenFileEx( &file, "rom:key/private_HWInfo.der", FS_FILEMODE_R ) ) {
OS_TPrintf( "PrivateKey read failed.\n" );
}else {
keyLength = FS_GetFileLength( &file );
if( keyLength > 0 ) {
s_pPrivKeyBuffer = OS_Alloc( keyLength );
if( FS_ReadFile( &file, s_pPrivKeyBuffer, (s32)keyLength ) == keyLength ) {
OS_TPrintf( "PrivateKey read succeeded.\n" );
result = TRUE;
}else {
OS_TPrintf( "PrivateKey read failed.\n" );
}
}
FS_CloseFile( &file );
}
if( !result && s_pPrivKeyBuffer ) {
OS_Free( s_pPrivKeyBuffer );
s_pPrivKeyBuffer = NULL;
}
OS_TPrintf( "PrivKey read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
#ifdef USE_PRODUCT_KEY
// 製品用秘密鍵が有効なら、署名ありのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo;
#else
// そうでないなら、署名なしのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo_NoCheck;
// PutStringUTF16( 14 * 8, 0 * 8, TXT_COLOR_RED, (const u16 *)L"[No Signature MODE]" );
#endif
}
/*---------------------------------------------------------------------------*
Name: HW情報全体のリード
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ReadHWInfoFile( void )
{
LCFGReadResult retval;
OSTick start = OS_GetTick();
retval = LCFGi_THW_ReadNormalInfo();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Normal Info read succeeded.\n" );
}else {
OS_TPrintf( "HW Normal Info read failed.\n" );
}
OS_TPrintf( "HW Normal Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
start = OS_GetTick();
retval = s_pReadSecureInfoFunc();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Secure Info read succeeded.\n" );
}else {
OS_TPrintf( "HW Secure Info read failed.\n" );
}
OS_TPrintf( "HW Secure Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
}
/*---------------------------------------------------------------------------*
Name: HW情報全体のライト
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL WriteHWInfoFile( u8 region )
{
static const u16 *pMsgNormalWriting = (const u16 *)L"Writing Normal File...";
static const u16 *pMsgSecureWriting = (const u16 *)L"Writing Secure File...";
static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!";
static const u16 *pMsgFailed = (const u16 *)L"Failed!";
BOOL result = TRUE;
// ノーマルファイルのライト
// (void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalWriting );
if( WriteHWNormalInfoFile() ) {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
result = FALSE;
}
// セキュアファイルのライト
// (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureWriting );
if( WriteHWSecureInfoFile( region ) ) {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
result = FALSE;
}
ModifyLanguage( region );
// メッセージを一定時間表示して消去
// DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
// NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE,
// MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 );
return result;
}
/*---------------------------------------------------------------------------*
Name: HWーマルInfoファイルのライト
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL WriteHWNormalInfoFile( void )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
result = LCFGi_THW_ReadNormalInfo();
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoveryNormalInfo( result ) ) {
OS_TPrintf( "HW Normal Info Recovery failed.\n" );
isWrite = FALSE;
}
}
if( isWrite &&
!LCFGi_THW_WriteNormalInfo() ) {
OS_TPrintf( "HW Normal Info Write failed.\n" );
}
return isWrite;
}
/*---------------------------------------------------------------------------*
Name: HWセキュアInfoファイルのライト
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL WriteHWSecureInfoFile( u8 region )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
// ファイルのリード
result = s_pReadSecureInfoFunc();
// リードに失敗したらリカバリ
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoverySecureInfo( result ) ) {
OS_TPrintf( "HW Secure Info Recovery failed.\n" );
isWrite = FALSE;
}
}
// リージョンのセット
LCFG_THW_SetRegion( region );
// 対応言語ビットマップのセット
LCFG_THW_SetValidLanguageBitmap( s_langBitmapList[ region ] );
// [TODO:]量産工程でないとシリアルNo.は用意できないので、ここではMACアドレスをもとに適当な値をセットする。
// シリアルNo.のセット
{
u8 buffer[ 12 ] = "SERIAL"; // 適当な文字列をMACアドレスと結合してSHA1を取り、仮SerialNoとする。
u8 serialNo[ SVC_SHA1_DIGEST_SIZE ];
int i;
int len = ( LCFG_THW_GetRegion() == LCFG_TWL_REGION_AMERICA ) ?
LCFG_TWL_HWINFO_SERIALNO_LEN_AMERICA : LCFG_TWL_HWINFO_SERIALNO_LEN_OTHERS;
OS_GetMacAddress( buffer + 6 );
SVC_CalcSHA1( serialNo, buffer, sizeof(buffer) );
for( i = 3; i < SVC_SHA1_DIGEST_SIZE; i++ ) {
serialNo[ i ] = (u8)( ( serialNo[ i ] % 10 ) + 0x30 );
}
MI_CpuCopy8( "SRN", serialNo, 3 );
MI_CpuClear8( &serialNo[ len ], sizeof(serialNo) - len );
OS_TPrintf( "serialNo : %s\n", serialNo );
LCFG_THW_SetSerialNo( serialNo );
}
// ランチャーゲームコード
LCFG_THW_SetLauncherGameCode( (const u8 *)strLauncherGameCode[ region ] );
// ライト
if( isWrite &&
!LCFGi_THW_WriteSecureInfo( s_pPrivKeyBuffer ) ) {
isWrite = FALSE;
OS_TPrintf( "HW Secure Info Write failed.\n" );
}
return isWrite;
}
/*---------------------------------------------------------------------------*
Name: HWInfoファイルの削除
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL DeleteHWInfoFile( void )
{
static const u16 *pMsgNormalDeleting = (const u16 *)L"Deleting Normal File...";
static const u16 *pMsgSecureDeleting = (const u16 *)L"Deteting Secure File...";
static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!";
static const u16 *pMsgFailed = (const u16 *)L"Failed!";
BOOL result = TRUE;
// ノーマルファイル
// (void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalDeleting );
if( FS_DeleteFile( (char *)LCFG_TWL_HWINFO_NORMAL_PATH ) ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
result = FALSE;
}
// セキュアファイル
// (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureDeleting );
if( FS_DeleteFile( (char *)LCFG_TWL_HWINFO_SECURE_PATH ) ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
result = FALSE;
}
// DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
// NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE,
// MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 );
return result;
}

View File

@ -0,0 +1,870 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_import.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include "process_topmenu.h"
#include "process_import.h"
#include "process_eticket.h"
#include "process_auto.h"
#include "cursor.h"
#include "keypad.h"
#include "TWLHWInfo_api.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
typedef enum {
TAD_WRITE_OPTION_OVERWRITE, // 強制上書き
TAD_WRITE_OPTION_NONEXISTENT, // NANDに同プログラムが存在しない場合に限り書き込み
TAD_WRITE_OPTION_USER // ユーザーに選択させる
} TadWriteOption;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 4
#define NUM_OF_MENU_SELECT_INDIVIDUALLY 17
#define DOT_OF_MENU_SPACE 16
#define DOT_OF_MENU_SPACE_INDIVIDUALLY 8
#define CHAR_OF_MENU_SPACE 2
#define CHAR_OF_MENU_SPACE_INDIVIDUALLY 1
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 40
// 表示&インポートできる.TADファイルは最大16個まで
// しかもSDカードのルートに存在するファイルのみというお手軽実装
#define FILE_NUM_MAX 16
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s32 sMenuSelectNo;
static s32 sMenuSelectNoIndividually;
static LCFGReadResult (*s_pReadSecureInfoFunc)( void );
static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX];
static u8 sFileNum;
static void* spStack;
static u32 sCurrentProgress;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static BOOL ImportTad(char* file_name, TadWriteOption option);
static void ProgressThread(void* arg);
static void Destructor(void* arg);
static void DumpTadInfo(void);
static void MakeFullPathForSD(char* file_name, char* full_path);
static void ShowTitleinfoDifference( NAMTitleInfo* titleInfoNand, NAMTitleInfo* titleInfoSd);
void ProgessInit(void);
void ProgressDraw(f32 ratio);
static void* ImportProcessReturn(void);
static void* ImportIndividuallyProcess0(void);
static void* ImportIndividuallyProcess1(void);
static void* ImportIndividuallyProcess2(void);
static void* ImportIndividuallyProcess3(void);
static void* ImportAllOverwriteProcess0(void);
static void* ImportAllOverwriteProcess1(void);
static void* ImportAllOverwriteProcess2(void);
static void* ImportAllOverwriteProcess3(void);
static void* ImportAllNonexistentProcess0(void);
static void* ImportAllNonexistentProcess1(void);
static void* ImportAllNonexistentProcess2(void);
static void* ImportAllNonexistentProcess3(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ImportProcess0(void)
{
FATFSFileHandle fat_handle;
FSFile dir;
int i;
// F:sys/cert.sysが存在しないなら出直してもらう
fat_handle = FATFS_OpenFile(E_TICKET_FILE_PATH_IN_NAND, "r");
if (!fat_handle)
{
FATFS_CloseFile(fat_handle);
return ImportProcessReturn;
}
FATFS_CloseFile(fat_handle);
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import TAD from SD");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// メニュー一覧
kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 5, FONT_COLOR_BLACK, "l OVERWRITE ALL l l");
kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE NONEXISTENT l l");
kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l SELECT FILE >> l l");
kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l RETURN l l");
kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+--------------------+----+");
// 配列クリア
MI_CpuClear8( sFilePath, sizeof(sFilePath) );
// ファイル数初期化
sFileNum = 0;
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景上部
kamiFontFillChar( 0, BG_COLOR_PINK, BG_COLOR_PINK );
kamiFontFillChar( 1, BG_COLOR_PINK, BG_COLOR_PINK );
kamiFontFillChar( 2, BG_COLOR_PINK, BG_COLOR_TRANS );
// SDカードのルートディレクトリを検索
if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) )
{
kamiFontPrintfConsole(CONSOLE_RED, "Error FS_OpenDirectory(sdmc:/)\n");
}
else
{
FSDirectoryEntryInfo info[1];
OS_Printf("[%s]:\n", "sdmc:/");
kamiFontPrintfConsole(CONSOLE_ORANGE, "------ tad file List -----\n");
// .dat .nand .nor を探してファイル名を保存しておく
while (FS_ReadDirectory(&dir, info))
{
OS_Printf(" %s", info->longname);
if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0)
{
OS_Printf("/\n");
}
else
{
char* pExtension;
OS_Printf(" (%d BYTEs)\n", info->filesize);
// 拡張子のチェック
pExtension = STD_SearchCharReverse( info->longname, '.');
if (pExtension)
{
if (!STD_CompareString( pExtension, ".tad") )
{
char full_path[FS_ENTRY_LONGNAME_MAX+6];
// フルパスを作成
MakeFullPathForSD(info->longname, full_path);
STD_CopyString( sFilePath[sFileNum], info->longname );
kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", sFileNum, info->longname);
// 最大16個で終了
if (++sFileNum >= FILE_NUM_MAX)
{
break;
}
}
}
}
}
(void)FS_CloseDirectory(&dir);
kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n");
// DumpTadInfo();
}
return ImportProcess1;
}
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ImportProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return ImportProcess2;
}
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0;
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return ImportProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return TopmenuProcess0;
}
return ImportProcess1;
}
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ImportProcess2(void)
{
switch( sMenuSelectNo )
{
case 0:
return ImportAllOverwriteProcess0;
break;
case 1:
return ImportAllNonexistentProcess0;
break;
case 2:
return ImportIndividuallyProcess0;
case 3:
return TopmenuProcess0;
}
return ImportProcess1;
}
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ImportProcessReturn(void)
{
int i;
// 文字列全クリア
kamiFontClear();
kamiFontPrintf(4, 10, FONT_COLOR_RED, "%s is not exist", E_TICKET_FILE_PATH_IN_NAND);
kamiFontPrintf(4, 11, FONT_COLOR_RED, "You should write e-ticket", E_TICKET_FILE_PATH_IN_NAND);
kamiFontPrintf(4, 12, FONT_COLOR_RED, "beforehand.", E_TICKET_FILE_PATH_IN_NAND);
kamiFontPrintf(4, 22, FONT_COLOR_BLACK, "B Button : return to menu");
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import TAD from SD");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景上部
kamiFontFillChar( 0, BG_COLOR_PINK, BG_COLOR_PINK );
kamiFontFillChar( 1, BG_COLOR_PINK, BG_COLOR_PINK );
kamiFontFillChar( 2, BG_COLOR_PINK, BG_COLOR_TRANS );
// カーソル消去
SetCursorPos((u16)200, (u16)200);
// フォントスクリーンデータロード
kamiFontLoadScreenData();
while(1)
{
kamiPadRead();
if (kamiPadIsTrigger(PAD_BUTTON_B)) { break; }
}
return TopmenuProcess0;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
static void* ImportAllOverwriteProcess0(void)
{
int i;
BOOL result = TRUE;
kamiFontPrintf(25, 5, FONT_COLOR_BLACK, "WAIT");
for (i=0;i<sFileNum;i++)
{
// 強制上書き
if (ImportTad(sFilePath[i], TAD_WRITE_OPTION_OVERWRITE) == FALSE)
{
result = FALSE;
}
}
if (result) { kamiFontPrintf(25, 5, FONT_COLOR_GREEN, " OK "); }
else { kamiFontPrintf(25, 5, FONT_COLOR_RED, " NG "); }
// Auto用
if (gAutoFlag)
{
if (result && sFileNum > 0) return AutoProcess1;
else return AutoProcess2;
}
return ImportProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
static void* ImportAllNonexistentProcess0(void)
{
int i;
BOOL result = TRUE;
kamiFontPrintf(25, 7, FONT_COLOR_BLACK, "WAIT");
for (i=0;i<sFileNum;i++)
{
// 書き込みチャレンジ
if (ImportTad(sFilePath[i], TAD_WRITE_OPTION_NONEXISTENT) == FALSE)
{
result = FALSE;
}
}
if (result) { kamiFontPrintf(25, 7, FONT_COLOR_GREEN, " OK "); }
else { kamiFontPrintf(25, 7, FONT_COLOR_RED, " NG "); }
return ImportProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
static void* ImportIndividuallyProcess0(void)
{
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import from SD Card ");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// メニュー一覧
kamiFontPrintf(3, 4, FONT_COLOR_BLACK, "+--------------------+----+");
for (i=0;i<sFileNum+1;i++)
{
kamiFontPrintf(3, (s16)(5+i), FONT_COLOR_BLACK, "l l l");
}
kamiFontPrintf(3, (s16)(5+i), FONT_COLOR_BLACK, "+--------------------+----+");
// tad ファイルリストを表示
for (i=0;i<sFileNum; i++)
{
// ファイル名追加
kamiFontPrintf(3, (s16)(5+CHAR_OF_MENU_SPACE_INDIVIDUALLY*i), FONT_COLOR_BLACK, "l %-16.16s l l", sFilePath[i]);
}
// 最後にリターンを追加
kamiFontPrintf(3, (s16)(5+CHAR_OF_MENU_SPACE_INDIVIDUALLY*sFileNum), FONT_COLOR_BLACK, "l RETURN l l");
DumpTadInfo();
return ImportIndividuallyProcess1;
}
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* ImportIndividuallyProcess1(void)
{
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNoIndividually < 0) sMenuSelectNoIndividually = sFileNum;
DumpTadInfo();
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNoIndividually > sFileNum) sMenuSelectNoIndividually = 0;
DumpTadInfo();
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNoIndividually * DOT_OF_MENU_SPACE_INDIVIDUALLY));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return ImportIndividuallyProcess2;
}
// ひとつ前のメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return ImportProcess0;
}
return ImportIndividuallyProcess1;
}
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
#define THREAD_STACK_SIZE (16*1024)
void* ImportIndividuallyProcess2(void)
{
BOOL ret;
if (STD_GetStringLength(sFilePath[sMenuSelectNoIndividually]))
{
// 個別インポート
ret = ImportTad(sFilePath[sMenuSelectNoIndividually], TAD_WRITE_OPTION_USER);
}
else
{
// リターン
return ImportProcess0;
}
// 今回の結果を表示
if ( ret == TRUE )
{
kamiFontPrintf(26, (s16)(5+sMenuSelectNoIndividually*CHAR_OF_MENU_SPACE_INDIVIDUALLY), FONT_COLOR_GREEN, "OK");
}
else
{
kamiFontPrintf(26, (s16)(5+sMenuSelectNoIndividually*CHAR_OF_MENU_SPACE_INDIVIDUALLY), FONT_COLOR_RED, "NG");
}
return ImportIndividuallyProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: ImportTad
Description: .tad
Arguments: no
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL ImportTad(char* file_name, TadWriteOption option)
{
NAMTadInfo tadInfo;
NAMTitleInfo titleInfo;
char full_path[FS_ENTRY_LONGNAME_MAX+6];
OSThread thread;
BOOL ret = FALSE;
// フルパスを作成
MakeFullPathForSD(file_name, full_path);
// tadファイルの情報取得
if (NAM_ReadTadInfo(&tadInfo, full_path) != NAM_OK)
{
return FALSE;
}
// NANDの情報を取得
if ( option != TAD_WRITE_OPTION_OVERWRITE && NAM_ReadTitleInfo(&titleInfo, tadInfo.titleInfo.titleId) == NAM_OK)
{
// NANDに既にインストールされているかどうか確認する
if (tadInfo.titleInfo.titleId == titleInfo.titleId)
{
switch (option)
{
case TAD_WRITE_OPTION_NONEXISTENT:
return TRUE;
case TAD_WRITE_OPTION_USER:
ShowTitleinfoDifference(&titleInfo, &tadInfo.titleInfo);
kamiFontPrintfConsole(1, "The program has already existed.");
kamiFontPrintfConsole(1, "Do you overwrite ?\n");
kamiFontPrintfConsole(1, " <Yes: Push A> <No: Push B>\n");
// フォントスクリーンデータロード
kamiFontLoadScreenData();
while(1)
{
kamiPadRead();
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
break;
}
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
kamiFontPrintfConsole(CONSOLE_ORANGE, "Import was canceled.\n");
return TRUE;
}
}
}
}
}
// 進捗スレッド作成
spStack = OS_Alloc(THREAD_STACK_SIZE);
MI_CpuClear8(spStack, THREAD_STACK_SIZE);
OS_CreateThread(&thread, ProgressThread, NULL,
(void*)((u32)spStack + THREAD_STACK_SIZE), THREAD_STACK_SIZE, OS_THREAD_PRIORITY_MAX);
// デストラクタセット
OS_SetThreadDestructor( &thread, Destructor );
OS_WakeupThreadDirect(&thread);
// Import開始
OS_Printf( "Import %s Start.\n", full_path );
kamiFontPrintfConsole(CONSOLE_ORANGE, "Import %s Start.\n", file_name );
if ( NAM_ImportTad( full_path ) == NAM_OK )
{
ret = TRUE;
kamiFontPrintfConsole(CONSOLE_ORANGE, "Import %s Sucess.\n", file_name );
}
else
{
kamiFontPrintfConsole(1, "Import %s Fail.\n", file_name );
}
return ret;
}
static void Destructor(void* /*arg*/)
{
OS_Free(spStack);
}
/*---------------------------------------------------------------------------*
Name: ProgressThread
Description: .tad
100%
Arguments: arg - 使
Returns: None.
*---------------------------------------------------------------------------*/
static void ProgressThread(void* /*arg*/)
{
u32 currentSize;
u32 totalSize;
ProgressInit();
while (TRUE)
{
NAM_GetProgress(&currentSize, &totalSize);
if (totalSize != 0)
{
ProgressDraw((f32)currentSize/totalSize);
// 100%なら終了
if (currentSize == totalSize)
{
break;
}
}
}
}
/*---------------------------------------------------------------------------*
Name: DumpTadInfo
Description: .tad
Arguments: arg - 使
Returns: None.
*---------------------------------------------------------------------------*/
static void DumpTadInfo(void)
{
NAMTadInfo info;
// ファイル名の有無を確認
if (STD_GetStringLength(sFilePath[sMenuSelectNoIndividually]))
{
char full_path[FS_ENTRY_LONGNAME_MAX+6];
// フルパスを作成
MakeFullPathForSD( sFilePath[sMenuSelectNoIndividually], full_path );
// TADファイルの情報取得
if (NAM_ReadTadInfo(&info, full_path) == NAM_OK)
{
char temp[100];
u16 companyCode = MI_SwapEndian16(info.titleInfo.companyCode);
u32 gameCode = (u32)(info.titleInfo.titleId & 0xffffffff);
gameCode = MI_SwapEndian32(gameCode);
kamiFontPrintfConsole(CONSOLE_ORANGE, "------ tad profile -----\n");
// File Name
kamiFontPrintfConsole(CONSOLE_ORANGE, "%s\n", sFilePath[sMenuSelectNoIndividually]);
// File Size
kamiFontPrintfConsole(CONSOLE_ORANGE, "fileSize = %d Byte\n", info.fileSize);
// Company Code
MI_CpuCopy8( &companyCode, temp, sizeof(companyCode) );
temp[sizeof(companyCode)] = NULL;
kamiFontPrintfConsole(CONSOLE_ORANGE, "Company Code = %s\n", temp);
// Game Code
MI_CpuCopy8( &gameCode, temp, sizeof(gameCode) );
temp[sizeof(gameCode)] = NULL;
kamiFontPrintfConsole(CONSOLE_ORANGE, "GameCode Code = %s\n", temp);
// Game Version
kamiFontPrintfConsole(CONSOLE_ORANGE, "GameVersion = %d\n", info.titleInfo.version);
// name
kamiFontPrintfConsole(CONSOLE_ORANGE, "name = %s\n", info.name);
// user
kamiFontPrintfConsole(CONSOLE_ORANGE, "user = %s\n",info.user);
kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n");
}
}
}
/*---------------------------------------------------------------------------*
Name: MakeFullPathForSD
Description:
Arguments: no
Returns: None.
*---------------------------------------------------------------------------*/
static void MakeFullPathForSD(char* file_name, char* full_path)
{
// フルパスを作成
STD_CopyString( full_path, "sdmc:/" );
STD_ConcatenateString( full_path, file_name );
}
/*---------------------------------------------------------------------------*
Name: ShowTitleinfoDifference
Description: NANDプログラムとSDプログラムの比較情報を表示する
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
static void ShowTitleinfoDifference( NAMTitleInfo* titleInfoNand, NAMTitleInfo* titleInfoSd)
{
char tempOld[100];
char tempNew[100];
u16 companyCode;
u32 gameCode;
kamiFontPrintfConsole(CONSOLE_ORANGE, "+--------------+-------+-------+");
kamiFontPrintfConsole(CONSOLE_ORANGE, "l l NAND l SD l");
kamiFontPrintfConsole(CONSOLE_ORANGE, "+--------------+-------+-------+");
// Company Code (nand)
companyCode = MI_SwapEndian16(titleInfoNand->companyCode);
MI_CpuCopy8( &companyCode, tempOld, sizeof(companyCode) );
tempOld[sizeof(companyCode)] = NULL;
// Company Code (sd)
companyCode = MI_SwapEndian16(titleInfoSd->companyCode);
MI_CpuCopy8( &companyCode, tempNew, sizeof(companyCode) );
tempNew[sizeof(companyCode)] = NULL;
kamiFontPrintfConsole(CONSOLE_ORANGE, "l Company Code l %-2.2s l %-2.2s l", tempOld, tempNew);
// Game Code (nand)
gameCode = (u32)(titleInfoNand->titleId & 0xffffffff);
gameCode = MI_SwapEndian32(gameCode);
MI_CpuCopy8( &gameCode, tempOld, sizeof(gameCode) );
tempOld[sizeof(gameCode)] = NULL;
// Game Code (sd)
gameCode = (u32)(titleInfoSd->titleId & 0xffffffff);
gameCode = MI_SwapEndian32(gameCode);
MI_CpuCopy8( &gameCode, tempNew, sizeof(gameCode) );
tempNew[sizeof(gameCode)] = NULL;
kamiFontPrintfConsole(CONSOLE_ORANGE, "l Game Code l %-4.4s l %-4.4s l", tempOld, tempNew);
// Game Version
kamiFontPrintfConsole(CONSOLE_ORANGE, "l Game Version l %-4.4d l %-4.4d l", titleInfoNand->version, titleInfoSd->version );
kamiFontPrintfConsole(CONSOLE_ORANGE, "+--------------+-------+-------+");
}
/*---------------------------------------------------------------------------*
Name: ProgressInit
Description:
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
void ProgressInit(void)
{
sCurrentProgress = 0;
}
/*---------------------------------------------------------------------------*
Name: ProgressDraw
Description:
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
void ProgressDraw(f32 ratio)
{
char square[2] = { 0x01, 0x00 };
u32 temp;
s32 i;
temp = (u32)(32 * ratio);
if (temp > sCurrentProgress)
{
s32 diff = (s32)(temp - sCurrentProgress);
for (i=0;i<diff;i++)
{
kamiFontPrintfConsole(2, square);
}
}
sCurrentProgress = temp;
// フォントスクリーンデータロード
kamiFontLoadScreenData();
}

View File

@ -0,0 +1,438 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_nandfirm.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include "process_topmenu.h"
#include "process_nandfirm.h"
#include "process_import.h"
#include "process_auto.h"
#include "cursor.h"
#include "keypad.h"
#include "TWLHWInfo_api.h"
#include <firm/format/firm_common.h>
#include <../build/libraries/spi/ARM9/include/spi.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define ROUND_UP(value, alignment) \
(((u32)(value) + (alignment-1)) & ~(alignment-1))
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define DOT_OF_MENU_SPACE 8
#define CHAR_OF_MENU_SPACE 1
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 40
#define FILE_NUM_MAX 16
#define NAND_BLOCK_BYTE 0x200
#define NAND_BOOT_FLAG_ADDRESS 0x2ff
#define NAND_FIRM_START_OFFSET 0x200
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s32 sMenuSelectNo;
static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX];
static u8 sFileNum;
static u8 sNandBootFlag = 0xff;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static void MakeFullPathForSD(char* file_name, char* full_path);
static BOOL WriteNandfirm(char* file_name);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NandfirmProcess0(void)
{
FSFile dir;
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import NandFirm from SD");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// 配列クリア
MI_CpuClear8( sFilePath, sizeof(sFilePath) );
// ファイル数初期化
sFileNum = 0;
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景上部
kamiFontFillChar( 0, BG_COLOR_GREEN, BG_COLOR_GREEN );
kamiFontFillChar( 1, BG_COLOR_GREEN, BG_COLOR_GREEN );
kamiFontFillChar( 2, BG_COLOR_GREEN, BG_COLOR_TRANS );
// SDカードのルートディレクトリを検索
if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) )
{
OS_Printf("Error FS_OpenDirectory(sdmc:/)\n");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "Error FS_OpenDirectory(sdmc:/)");
}
else
{
FSDirectoryEntryInfo info[1];
OS_Printf("[%s]:\n", "sdmc:/");
kamiFontPrintfConsole(CONSOLE_ORANGE, "------ nand file list -----\n");
// .nand を探してファイル名を保存しておく
while (FS_ReadDirectory(&dir, info))
{
OS_Printf(" %s", info->longname);
if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0)
{
OS_Printf("/\n");
}
else
{
char* pExtension;
OS_Printf(" (%d BYTEs)\n", info->filesize);
// 拡張子のチェック
pExtension = STD_SearchCharReverse( info->longname, '.');
if (pExtension)
{
if (!STD_CompareString( pExtension, ".nand") || !STD_CompareString( pExtension, ".NAND"))
{
STD_CopyString( sFilePath[sFileNum], info->longname );
kamiFontPrintfConsole(CONSOLE_ORANGE, "%d:%s\n", sFileNum, info->longname);
// 最大16個で終了
if (++sFileNum >= FILE_NUM_MAX)
{
break;
}
}
}
}
}
(void)FS_CloseDirectory(&dir);
kamiFontPrintfConsole(CONSOLE_ORANGE, "--------------------------\n");
}
// メニュー一覧
kamiFontPrintf((s16)3, (s16)4, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf((s16)3, (s16)(5+sFileNum+1), FONT_COLOR_BLACK, "+--------------------+----+");
// tad ファイルリストを表示
for (i=0;i<sFileNum; i++)
{
// ファイル名追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*i), FONT_COLOR_BLACK, "l %-16.16s l l", sFilePath[i]);
}
// 最後にリターンを追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*sFileNum), FONT_COLOR_BLACK, "l RETURN l l");
return NandfirmProcess1;
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NandfirmProcess1(void)
{
// オート実行用
if (gAutoFlag)
{
sMenuSelectNo = 0;
return NandfirmProcess2;
}
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = sFileNum;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo > sFileNum) sMenuSelectNo = 0;
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return NandfirmProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return TopmenuProcess0;
}
return NandfirmProcess1;
}
/*---------------------------------------------------------------------------*
Name: 2
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NandfirmProcess2(void)
{
BOOL ret;
if (STD_GetStringLength(sFilePath[sMenuSelectNo]))
{
ret = WriteNandfirm(sFilePath[sMenuSelectNo]);
}
else
{
if (gAutoFlag) { return AutoProcess2; }
else { return TopmenuProcess0; }
}
// 今回の結果を表示
if ( ret == TRUE )
{
kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK");
}
else
{
kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG");
}
// Auto用
if (gAutoFlag)
{
if (ret) return AutoProcess1;
else return AutoProcess2;
}
return NandfirmProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: MakeFullPathForSD
Description:
Arguments: no
Returns: None.
*---------------------------------------------------------------------------*/
static void MakeFullPathForSD(char* file_name, char* full_path)
{
// フルパスを作成
STD_CopyString( full_path, "sdmc:/" );
STD_ConcatenateString( full_path, file_name );
}
/*---------------------------------------------------------------------------*
Name: MakeFullPathForSD
Description:
Arguments: no
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL WriteNandfirm(char* file_name)
{
FSFile file;
char full_path[FS_ENTRY_LONGNAME_MAX+6];
BOOL open_is_ok;
BOOL read_is_ok;
u8* pTempBuf;
u32 file_size;
u32 alloc_size;
u32 write_size;
BOOL result = TRUE;
u16 crc_w1, crc_w2;
u16 crc_r1, crc_r2;
// .nandのフルパスを作成
MakeFullPathForSD(file_name, full_path);
// .nandファイルオープン
FS_InitFile(&file);
open_is_ok = FS_OpenFile(&file, full_path);
OS_Printf("FS_OpenFile(\"%s\") ... %s!\n", full_path, open_is_ok ? "OK" : "ERROR");
// サイズチェック
file_size = FS_GetFileLength(&file) ;
if (file_size > (800*1024))
{
kamiFontPrintfConsoleEx(1, "too big file size!\n");
FS_CloseFile(&file);
return FALSE;
}
// バッファ確保
alloc_size = ROUND_UP(file_size, 32) ;
pTempBuf = OS_Alloc( alloc_size );
if (pTempBuf == NULL)
{
kamiFontPrintfConsoleEx(1, "Fail Alloc()!\n");
FS_CloseFile(&file);
return FALSE;
}
// .nandファイルリード
read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size );
DC_FlushRange(pTempBuf, file_size);
if (!read_is_ok)
{
kamiFontPrintfConsoleEx(1, "Fail FS_ReadFile!\n");
FS_CloseFile(&file);
OS_Free(pTempBuf);
return FALSE;
}
// ファイルクローズ
FS_CloseFile(&file);
// 書き込み前のCRCを計算
crc_w1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) );
crc_w2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 );
// まずNORHeaderDS領域を書き込む40byte?
if (kamiNvramWrite(0, (void*)pTempBuf, sizeof(NORHeaderDS)) == KAMI_RESULT_SEND_ERROR)
{
kamiFontPrintfConsoleEx(1, "Fail kamiNvramWrite()\n");
result = FALSE;
}
// CRCを計算するので念のためにクリアしてからリードする
MI_CpuFill8( pTempBuf, 0xee, sizeof(NORHeaderDS) );
DC_FlushRange(pTempBuf, sizeof(NORHeaderDS));
// CRCチェックのためNvramからリード
if (kamiNvramRead(0, pTempBuf, sizeof(NORHeaderDS) ) == KAMI_RESULT_SEND_ERROR)
{
kamiFontPrintfConsoleEx(1, "Fail kamiNvramRead()!\n");
}
// 読み込みはARM7が直接メモリに書き出すため
DC_InvalidateRange(pTempBuf, sizeof(NORHeaderDS));
// 書き込み後のCRCを計算
crc_r1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) );
// NVRAM先頭部分のCRC比較
if ( crc_w1 != crc_r1 )
{
OS_Free(pTempBuf);
kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w1, crc_r1);
return FALSE;
}
// nandfirm 起動フラグを立てる
if (kamiNvramWrite(NAND_BOOT_FLAG_ADDRESS, &sNandBootFlag, 1) == KAMI_RESULT_SEND_ERROR)
{
kamiFontPrintfConsoleEx(1, "Fail kamiNvramWrite()\n");
result = FALSE;
}
kamiFontPrintfConsoleEx(0, "NAND Firm Import Start!\n");
// NAND書き込み
write_size = file_size/NAND_BLOCK_BYTE + (file_size % NAND_BLOCK_BYTE != 0);
kamiNandWrite( NAND_FIRM_START_OFFSET/NAND_BLOCK_BYTE, pTempBuf+NAND_FIRM_START_OFFSET, write_size ); // ブロック単位、バイト単位、ブロック単位
kamiFontPrintfConsoleEx(0, "Start CRC check\n");
kamiFontLoadScreenData();
// CRCを計算するので念のためにクリアしてからリードする
MI_CpuClear8( pTempBuf, file_size );
DC_FlushRange(pTempBuf, file_size);
// CRCチェックのためNandからリード
if (kamiNandRead(0, pTempBuf, file_size/512 ) == KAMI_RESULT_SEND_ERROR)
{
kamiFontPrintfConsoleEx(1, "kamiNandRead ... %s!\n", "ERROR");
}
DC_FlushRange(pTempBuf, file_size);
// 書き込み後のCRCを計算
crc_r2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 );
// NAND部分についてのCRCチェック
if (crc_w2 == crc_r2)
{
kamiFontPrintfConsoleEx(0, "Success! CRC check %x==%x\n", crc_w2, crc_r2);
}
else
{
result = FALSE;
kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w2, crc_r2);
}
// メモリ解放
OS_Free(pTempBuf);
return result;
}

View File

@ -0,0 +1,423 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_norfirm.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include <twl/nam.h>
#include <stddef.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include "process_topmenu.h"
#include "process_import.h"
#include "process_norfirm.h"
#include "cursor.h"
#include "keypad.h"
#include "TWLHWInfo_api.h"
#include <firm/format/firm_common.h>
#include <firm/format/norfirm.h>
#include <../build/libraries/spi/ARM9/include/spi.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define DOT_OF_MENU_SPACE 8
#define CHAR_OF_MENU_SPACE 1
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 40
#define FILE_NUM_MAX 16
#define ROUND_UP(value, alignment) \
(((u32)(value) + (alignment-1)) & ~(alignment-1))
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s32 sMenuSelectNo;
static char sFilePath[FILE_NUM_MAX][FS_ENTRY_LONGNAME_MAX];
static u8 sFileNum;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static void MakeFullPathForSD(char* file_name, char* full_path);
static BOOL WriteNorfirm(char* file_name);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Import
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NorfirmProcess0(void)
{
FSFile dir;
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Import Norfirm from SD");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// 配列クリア
MI_CpuClear8( sFilePath, sizeof(sFilePath) );
// ファイル数初期化
sFileNum = 0;
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景上部
kamiFontFillChar( 0, BG_COLOR_VIOLET, BG_COLOR_VIOLET );
kamiFontFillChar( 1, BG_COLOR_VIOLET, BG_COLOR_VIOLET );
kamiFontFillChar( 2, BG_COLOR_VIOLET, BG_COLOR_TRANS );
// SDカードのルートディレクトリを検索
if ( !FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_R | FS_FILEMODE_W) )
{
OS_Printf("Error FS_OpenDirectory(sdmc:/)\n");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "Error FS_OpenDirectory(sdmc:/)");
}
else
{
FSDirectoryEntryInfo info[1];
OS_Printf("[%s]:\n", "sdmc:/");
kamiFontPrintfConsole(0, "------ nor file list -----\n");
// .nor を探してファイル名を保存しておく
while (FS_ReadDirectory(&dir, info))
{
OS_Printf(" %s", info->longname);
if ((info->attributes & (FS_ATTRIBUTE_DOS_DIRECTORY | FS_ATTRIBUTE_IS_DIRECTORY)) != 0)
{
OS_Printf("/\n");
}
else
{
char* pExtension;
OS_Printf(" (%d BYTEs)\n", info->filesize);
// 拡張子のチェック
pExtension = STD_SearchCharReverse( info->longname, '.');
if (pExtension)
{
if (!STD_CompareString( pExtension, ".nor") || !STD_CompareString( pExtension, ".NOR"))
{
STD_CopyString( sFilePath[sFileNum], info->longname );
kamiFontPrintfConsole(0, "%d:%s\n", sFileNum, info->longname);
// 最大16個で終了
if (++sFileNum >= FILE_NUM_MAX)
{
break;
}
}
}
}
}
(void)FS_CloseDirectory(&dir);
kamiFontPrintfConsole(0, "--------------------------\n");
}
// メニュー一覧
kamiFontPrintf((s16)3, (s16)4, FONT_COLOR_BLACK, "+--------------------+----+");
kamiFontPrintf((s16)3, (s16)(5+sFileNum+1), FONT_COLOR_BLACK, "+--------------------+----+");
// tad ファイルリストを表示
for (i=0;i<sFileNum; i++)
{
// ファイル名追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*i), FONT_COLOR_BLACK, "l %-16.16s l l", sFilePath[i]);
}
// 最後にリターンを追加
kamiFontPrintf((s16)3, (s16)(5+CHAR_OF_MENU_SPACE*sFileNum), FONT_COLOR_BLACK, "l RETURN l l");
return NorfirmProcess1;
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NorfirmProcess1(void)
{
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = sFileNum;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo > sFileNum) sMenuSelectNo = 0;
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return NorfirmProcess2;
}
// トップメニューへ戻る
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
return TopmenuProcess0;
}
return NorfirmProcess1;
}
/*---------------------------------------------------------------------------*
Name: 2
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* NorfirmProcess2(void)
{
BOOL ret;
if (STD_GetStringLength(sFilePath[sMenuSelectNo]))
{
ret = WriteNorfirm(sFilePath[sMenuSelectNo]);
}
else
{
// リターン
return TopmenuProcess0;
}
// 今回の結果を表示
if ( ret == TRUE )
{
kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_GREEN, "OK");
}
else
{
kamiFontPrintf((s16)26, (s16)(5+sMenuSelectNo*CHAR_OF_MENU_SPACE), FONT_COLOR_RED, "NG");
}
return NorfirmProcess1;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: MakeFullPathForSD
Description:
Arguments: no
Returns: None.
*---------------------------------------------------------------------------*/
static void MakeFullPathForSD(char* file_name, char* full_path)
{
// フルパスを作成
STD_CopyString( full_path, "sdmc:/" );
STD_ConcatenateString( full_path, file_name );
}
/*---------------------------------------------------------------------------*
Name: MakeFullPathForSD
Description:
Arguments: no
Returns: None.
*---------------------------------------------------------------------------*/
#define NVRAM_PAGE_SIZE 256
static BOOL WriteNorfirm(char* file_name)
{
FSFile file;
char full_path[FS_ENTRY_LONGNAME_MAX+6];
BOOL open_is_ok;
BOOL read_is_ok;
u8* pTempBuf;
u32 file_size;
u32 alloc_size;
BOOL result = TRUE;
int nor_addr;
u16 crc_w1, crc_w2;
u16 crc_r1, crc_r2;
// .norのフルパスを作成
MakeFullPathForSD(file_name, full_path);
// .norファイルオープン
FS_InitFile(&file);
open_is_ok = FS_OpenFile(&file, full_path);
OS_Printf("FS_OpenFile(\"%s\") ... %s!\n", full_path, open_is_ok ? "OK" : "ERROR");
// サイズチェック
file_size = FS_GetFileLength(&file) ;
if (file_size > 256*1024)
{
kamiFontPrintfConsoleEx(1, "too big file size!\n");
FS_CloseFile(&file);
return FALSE;
}
// バッファ確保
alloc_size = ROUND_UP(file_size, 32) ;
pTempBuf = OS_Alloc( alloc_size );
if (pTempBuf == NULL)
{
kamiFontPrintfConsoleEx(1, "Fail Alloc()\n");
FS_CloseFile(&file);
return FALSE;
}
// .norファイルリード
read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size );
DC_FlushRange(pTempBuf, file_size);
if (!read_is_ok)
{
kamiFontPrintfConsoleEx(1, "FS_ReadFile(\"%s\") ... ERROR!\n", full_path);
FS_CloseFile(&file);
OS_Free(pTempBuf);
return FALSE;
}
// ファイルクローズ
FS_CloseFile(&file);
// 書き込み前のCRCを計算
crc_w1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) );
crc_w2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 );
// まずNORHeaderDS領域を書き込む40byte?
if (kamiNvramWrite(0, (void*)pTempBuf, sizeof(NORHeaderDS)) == KAMI_RESULT_SEND_ERROR)
{
kamiFontPrintfConsoleEx(1, "Fail SPI_NvramPageWrite()\n");
result = FALSE;
}
// CRCチェックのためNvramからリード
if (kamiNvramRead(0, pTempBuf, sizeof(NORHeaderDS) ) == KAMI_RESULT_SEND_ERROR)
{
OS_Printf("kamiNvramRead ... ERROR!\n");
}
// 読み込みはARM7が直接メモリに書き出す
DC_InvalidateRange(pTempBuf, sizeof(NORHeaderDS));
// 書き込み後のCRCを計算
crc_r1 = SVC_GetCRC16( 0xffff, pTempBuf, sizeof(NORHeaderDS) );
// NVRAM前半部のCRCをチェック
if ( crc_w1 != crc_r1 )
{
OS_Free(pTempBuf);
kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w1, crc_r1);
return FALSE;
}
nor_addr = offsetof(NORHeader, l); // 512byte
// 進捗メーター初期化
ProgressInit();
kamiFontPrintfConsole(0, "NOR Firm Import Start!\n");
while ( nor_addr < file_size)
{
// 書きこみ
if (kamiNvramWrite((u32)nor_addr, (void*)(pTempBuf + nor_addr), NVRAM_PAGE_SIZE) == KAMI_RESULT_SEND_ERROR)
{
OS_TPrintf("======= Fail SPI_NvramPageWrite() ======== \n");
result = FALSE;
break;
}
nor_addr += NVRAM_PAGE_SIZE;
// 進捗メーター表示
ProgressDraw((f32)nor_addr/file_size);
}
kamiFontPrintfConsoleEx(0, "Start CRC check\n");
kamiFontLoadScreenData();
// CRCチェックのためNvramからリード
if (kamiNvramRead(0, pTempBuf, file_size ) == KAMI_RESULT_SEND_ERROR)
{
OS_Printf("kamiNvramRead ... ERROR!\n");
}
// 読み込みはARM7が直接メモリに書き出す
DC_InvalidateRange(pTempBuf, file_size);
// 書き込み後のCRCを計算
crc_r2 = SVC_GetCRC16( 0xffff, pTempBuf+512, file_size-512 );
// CRC比較
if (crc_w2 != crc_r2)
{
result = FALSE;
kamiFontPrintfConsoleEx(1, "Fail! CRC check %x!=%x\n", crc_w2, crc_r2);
}
// メモリ解放
OS_Free(pTempBuf);
return result;
}

View File

@ -0,0 +1,217 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_topmenu.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:: $
$Rev:$
$Author:$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "kami_font.h"
#include "process_topmenu.h"
#include "process_format.h"
#include "process_hw_info.h"
#include "process_import.h"
#include "process_eticket.h"
#include "process_nandfirm.h"
#include "process_norfirm.h"
#include "process_auto.h"
#include "cursor.h"
#include "keypad.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 6
#define DOT_OF_MENU_SPACE 16
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* TopmenuProcess0(void)
{
int i;
// 文字列全クリア
kamiFontClear();
// バージョン表示
kamiFontPrintf(4, 2, 0, "Nand Initializer ver 0.1");
// メニュー一覧
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, " FORMAT NAND ");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, " WRITE HARDWARE INFO ");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, " WRITE ETICKET SIGN ");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, " INPORT TAD FROM SD ");
kamiFontPrintf(3, 15, FONT_COLOR_BLACK, " INPORT NANDFIRM FROM SD");
kamiFontPrintf(3, 17, FONT_COLOR_BLACK, " INPORT NORFIRM FROM SD");
// 背景全クリア
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// 背景設定
kamiFontFillChar( 6, BG_COLOR_TRANS, BG_COLOR_BLUE );
kamiFontFillChar( 7, BG_COLOR_BLUE, BG_COLOR_BLUE );
kamiFontFillChar( 8, BG_COLOR_BLUE, BG_COLOR_TRANS );
kamiFontFillChar( 8, BG_COLOR_NONE, BG_COLOR_PURPLE );
kamiFontFillChar( 9, BG_COLOR_PURPLE, BG_COLOR_PURPLE );
kamiFontFillChar(10, BG_COLOR_PURPLE, BG_COLOR_TRANS );
kamiFontFillChar(10, BG_COLOR_NONE, BG_COLOR_GRAY );
kamiFontFillChar(11, BG_COLOR_GRAY, BG_COLOR_GRAY );
kamiFontFillChar(12, BG_COLOR_GRAY, BG_COLOR_TRANS );
kamiFontFillChar(12, BG_COLOR_NONE, BG_COLOR_PINK );
kamiFontFillChar(13, BG_COLOR_PINK, BG_COLOR_PINK );
kamiFontFillChar(14, BG_COLOR_PINK, BG_COLOR_TRANS );
kamiFontFillChar(14, BG_COLOR_NONE, BG_COLOR_GREEN );
kamiFontFillChar(15, BG_COLOR_GREEN, BG_COLOR_GREEN );
kamiFontFillChar(16, BG_COLOR_GREEN, BG_COLOR_TRANS );
kamiFontFillChar(16, BG_COLOR_NONE, BG_COLOR_VIOLET );
kamiFontFillChar(17, BG_COLOR_VIOLET, BG_COLOR_VIOLET );
kamiFontFillChar(18, BG_COLOR_VIOLET, BG_COLOR_TRANS );
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
return TopmenuProcess1;
}
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* TopmenuProcess1(void)
{
// 選択メニューの変更
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0;
}
// カーソル配置
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// 決定
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return TopmenuProcess2;
}
// L&R同時押しでオート実行
if (kamiPadIsPress(PAD_BUTTON_L) && kamiPadIsPress(PAD_BUTTON_R))
{
return AutoProcess0;
}
return TopmenuProcess1;
}
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* TopmenuProcess2(void)
{
switch ( sMenuSelectNo )
{
case 0:
return FormatProcess0;
case 1:
return HWInfoProcess0;
break;
case 2:
return eTicketProcess0;
break;
case 3:
return ImportProcess0;
break;
case 4:
return NandfirmProcess0;
break;
case 5:
return NorfirmProcess0;
break;
}
return TopmenuProcess1;
}
/*---------------------------------------------------------------------------*
Name: Top Menu
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* TopmenuProcess3(void)
{
return TopmenuProcess3;
}
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,33 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - tests - camera
# File: Makefile
#
# Copyright 2007 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:: 2007-10-30#$
# $Rev: 1951 $
# $Author: yutaka $
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = \
ARM7.TWL \
ARM9.TWL \
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

Binary file not shown.

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - camera-test - include
File: fifo.h
Copyright 2007 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:: 2007-11-29#$
$Rev: 2734 $
$Author: yutaka $
*---------------------------------------------------------------------------*/
#ifndef TWL_KAMI_TEST_FIFO_H_
#define TWL_KAMI_TEST_FIFO_H_
#include <twl/types.h>
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#define PXI_FIFO_TAG_KAMITEST PXI_FIFO_TAG_USER_1
#define KAMI_PXI_CONTINUOUS_PACKET_MAX 10
#define KAMITEST_PXI_DATA_SIZE_MAX ((KAMI_PXI_CONTINUOUS_PACKET_MAX-1)*3+1) // 最大データ数
#define KAMITEST_PXI_START_BIT 0x02000000 // 先頭パケットを意味する
#define KAMITEST_PXI_RESULT_BIT 0x00008000 // PXIの応答を示す
#define KAMITEST_PXI_COMMAND_SHIFT 8 // コマンド格納部分の位置
#define KAMITEST_PXI_COMMAND_MASK 0x00007f00 // コマンド格納部分のマスク
#define KAMITEST_PXI_DATA_NUMS_MASK 0x00ff0000 // データ数領域
#define KAMITEST_PXI_DATA_NUMS_SHIFT 16 // データ数位置
#define KAMITEST_PXI_1ST_DATA_MASK 0x000000ff // 先頭パケットのデータ領域
#define KAMITEST_PXI_1ST_DATA_SHIFT 0 // 先頭パケットのデータ位置
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
typedef enum KAMIPxiResult
{
KAMI_PXI_RESULT_SUCCESS = 0, // 処理成功 (void/void*型) // 場合により後続パケットあり
KAMI_PXI_RESULT_SUCCESS_TRUE = 0, // 処理成功 (BOOL型)
KAMI_PXI_RESULT_SUCCESS_FALSE, // 処理成功 (BOOL型)
KAMI_PXI_RESULT_INVALID_COMMAND, // 不正なPXIコマンド
KAMI_PXI_RESULT_INVALID_PARAMETER, // 不正なパラメータ
KAMI_PXI_RESULT_ILLEGAL_STATUS, // KAMIの状態により処理を実行不可
KAMI_PXI_RESULT_BUSY, // 他のリクエストを実行中
KAMI_PXI_RESULT_FATAL_ERROR, // その他何らかの原因で処理に失敗
KAMI_PXI_RESULT_MAX
}
KAMIPxiResult;
typedef enum KamiCommand
{
CODEC_READ_REGISTER,
CODEC_WRITE_REGISTER,
GPIO333_WRITE,
EXE_FORMAT,
KAMI_NAND_IO,
KAMI_NVRAM_IO
}
KamiCommand;
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* TWL_KAMI_TEST_FIFO_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

Binary file not shown.