マスタエディタ動作チェック用ROM:中韓版やTCL使用する版のMakefile/rsfを追加。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@344 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2009-07-06 08:53:05 +00:00
parent 49e7acaa27
commit 21d649c738
8 changed files with 1232 additions and 0 deletions

View File

@ -0,0 +1,54 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - tests - appjumpTest - Card
# File: Makefile
#
# 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$
#----------------------------------------------------------------------------
TARGET_PLATFORM := TWL
TWL_NANDAPP := TRUE
TWL_ARCHGEN := LIMITED
SUBDIRS = ../common/banner \
$(ROOT)/build/demos/gx/UnitTours/DEMOLib
TARGET_BIN = china_nand.tad
#INCDIR = ../common/include
SRCDIR = ../common/src
SRCS = main_china.c
ROM_SPEC = ./ROM-TS_nand.china.rsf
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib
# ƒCƒ“ƒXƒg<C692>Žwè
#ifneq ($(TWL_IPL_RED_ROOT),)
#INSTALL_DIR = $(TWL_IPL_RED_ROOT)/debugsoft/CardRomHeaderChecker
#INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN)
#endif
#TWL_LIBS_EX += libtcl$(TWL_LIBSUFFIX).a
do-build: $(TARGETS)
#----------------------------------------------------------------------------
LIBSYSCALL = ../common/0CZA/libsyscall.a
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,54 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - tests - appjumpTest - Card
# File: Makefile
#
# 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$
#----------------------------------------------------------------------------
TARGET_PLATFORM := TWL
TWL_NANDAPP := TRUE
TWL_ARCHGEN := LIMITED
SUBDIRS = ../common/banner \
$(ROOT)/build/demos/gx/UnitTours/DEMOLib
TARGET_BIN = korea_nand.tad
#INCDIR = ../common/include
SRCDIR = ../common/src
SRCS = main.c
ROM_SPEC = ./ROM-TS_nand.korea.rsf
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib
# ƒCƒ“ƒXƒg<C692>Žwè
#ifneq ($(TWL_IPL_RED_ROOT),)
#INSTALL_DIR = $(TWL_IPL_RED_ROOT)/debugsoft/CardRomHeaderChecker
#INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN)
#endif
#TWL_LIBS_EX += libtcl$(TWL_LIBSUFFIX).a
do-build: $(TARGETS)
#----------------------------------------------------------------------------
LIBSYSCALL = ../common/0CZA/libsyscall.a
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,54 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - tests - appjumpTest - Card
# File: Makefile
#
# 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$
#----------------------------------------------------------------------------
TARGET_PLATFORM := TWL
TWL_NANDAPP := TRUE
TWL_ARCHGEN := LIMITED
SUBDIRS = ../common/banner \
$(ROOT)/build/demos/gx/UnitTours/DEMOLib
TARGET_BIN = syscall_nand1.tad
#INCDIR = ../common/include
SRCDIR = ../common/src
SRCS = main.c
ROM_SPEC = ./ROM-TS_nand.rsf
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib
# ƒCƒ“ƒXƒg<C692>Žwè
#ifneq ($(TWL_IPL_RED_ROOT),)
#INSTALL_DIR = $(TWL_IPL_RED_ROOT)/debugsoft/CardRomHeaderChecker
#INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN)
#endif
#TWL_LIBS_EX += libtcl$(TWL_LIBSUFFIX).a
do-build: $(TARGETS)
#----------------------------------------------------------------------------
#LIBSYSCALL = ../common/0CZA/libsyscall.a
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,54 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - tests - appjumpTest - Card
# File: Makefile
#
# 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$
#----------------------------------------------------------------------------
TARGET_PLATFORM := TWL
TWL_NANDAPP := TRUE
TWL_ARCHGEN := LIMITED
SUBDIRS = ../common/banner \
$(ROOT)/build/demos/gx/UnitTours/DEMOLib
TARGET_BIN = tcl_nand.tad
#INCDIR = ../common/include
SRCDIR = ../common/src
SRCS = main_tcl.c
ROM_SPEC = ./ROM-TS_nand.rsf
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib
# ƒCƒ“ƒXƒg<C692>Žwè
#ifneq ($(TWL_IPL_RED_ROOT),)
#INSTALL_DIR = $(TWL_IPL_RED_ROOT)/debugsoft/CardRomHeaderChecker
#INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN)
#endif
TWL_LIBS_EX += libtcl$(TWL_LIBSUFFIX).a
do-build: $(TARGETS)
#----------------------------------------------------------------------------
LIBSYSCALL = ../common/0CZA/libsyscall.a
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,253 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - include
# File: ROM-TS.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:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
#
# 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 "SAMPLE GAME"
#
# 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/4G]
#
#RomSize 64M
#
# ROM PADDING: TRUE if finalrom
#
#RomFootPadding TRUE
#
# ROM HEADER TEMPLATE: Provided to every product by NINTENDO
#
RomHeaderTemplate ../common/0CZA/rom_header_0cza.template.sbin
#
# BANNER FILE: generated from Banner Spec File
#
BannerFile ../common/banner/banner.bnr
#
# Permit LandingNormalJump: for TWL "ApplicationJump" function [TRUE/FALSE]
#
#PermitLandingNormalJump FALSE
#
# Permit LandingTmpJump: for TWL "ApplicationJump" function [TRUE/FALSE]
#
#PermitLandingTmpJump FALSE
###
### Setting for TWL
###
#
# ROM HEADER Ltd: Provided to every product by NINTENDO
#
RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin
#
# Digest parameters:
#
DigestParam 1024 32
#
# WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD
# MAP2_BB_HYB/MAP2_BB_LTD/MAP2_TS_HYB/MAP2_TS_LTD]
# don't have to edit
#
WramMapping $(MAKEROM_WRAM_MAPPING)
#
# CardRegion: card region [Japan/America/Europe/Australia/China/Korea]
#
CardRegion China
ForChina TRUE
#
# Codec mode:
# don't have to edit
#
CodecMode $(MAKEROM_CODEC_MODE)
#
# Disp WiFiConnection Icon for Launcher [TRUE/FALSE]
#
#WiFiConnectionIcon FALSE
#
# Disp DSWireless Icon for Launcher [TRUE/FALSE]
#
#DSWirelessIcon FALSE
#
# Agree EULA [TRUE/FALSE]
#
#AgreeEULA FALSE
#
# Agree EULA version [1 - 255]
#
#AgreeEULAVersion 1
#SDCardAccess TRUE
#JpegSign TRUE
#PhotoAccess Read
###
#### END
}
AppendProperty
{
#
# Boot allowed Media: [GameCard]
#
Media NAND
#
# GameCode for TitleID : Your GameCode in 4 ascii words
#
#GameCode ABCJ
#
# Public save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M]
#
PublicSaveDataSize 1M
#
# Private save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M]
#
PrivateSaveDataSize 2M
#
# Enable SubBannerFile
SubBannerFile TRUE
#
# Game card power on: [TRUE/FALSE]
#
#GameCardOn FALSE
#
# Game card transferd to nitro mode: [TRUE/FALSE]
#
#GameCardNitroMode FALSE
}
RomSpec
{
Offset 0x00000000
Segment ALL
HostRoot $(MAKEROM_ROMROOT)
Root /
File $(MAKEROM_ROMFILES)
}
Rating
{
#
# Permited age to play for each rating organization
#
# Supported organization
# - CERO (OGN0) : for Japan
# - ESRB (OGN1) : for North America
# - BBFC (OGN2) : obsolete organization
# - USK (OGN3) : for German
# - PEGI_GEN (OGN4) : for Europe
# - PEGI_FINLAND (OGN5) : obsolete organization
# - PEGI_PRT (OGN6) : for Portugal
# - PEGI_BBFC (OGN7) : for UK
# - OFLC (OGN8) : for Australia and NewZealand
# - GRB (OGN9) : for Korea
# - OGN10 : reserved
# - OGN11 : reserved
# - OGN12 : reserved
# - OGN13 : reserved
# - OGN14 : reserved
# - OGN15 : reserved
#
# Available age [ 0 - 31 / PENDING / FREE ]
# CERO FREE
# ESRB FREE
# USK FREE
# PEGI_GEN FREE
# PEGI_PRT FREE
# PEGI_BBFC FREE
# OFLC FREE
# GRB FREE
#
# Unnecessary rating: [TRUE/FALSE]
#
#Unnecessary TRUE
}

View File

@ -0,0 +1,253 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - include
# File: ROM-TS.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:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
#
# 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 "SAMPLE GAME"
#
# 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/4G]
#
#RomSize 64M
#
# ROM PADDING: TRUE if finalrom
#
#RomFootPadding TRUE
#
# ROM HEADER TEMPLATE: Provided to every product by NINTENDO
#
RomHeaderTemplate ../common/0CZA/rom_header_0cza.template.sbin
#
# BANNER FILE: generated from Banner Spec File
#
BannerFile ../common/banner/banner.bnr
#
# Permit LandingNormalJump: for TWL "ApplicationJump" function [TRUE/FALSE]
#
#PermitLandingNormalJump FALSE
#
# Permit LandingTmpJump: for TWL "ApplicationJump" function [TRUE/FALSE]
#
#PermitLandingTmpJump FALSE
###
### Setting for TWL
###
#
# ROM HEADER Ltd: Provided to every product by NINTENDO
#
RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin
#
# Digest parameters:
#
DigestParam 1024 32
#
# WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD
# MAP2_BB_HYB/MAP2_BB_LTD/MAP2_TS_HYB/MAP2_TS_LTD]
# don't have to edit
#
WramMapping $(MAKEROM_WRAM_MAPPING)
#
# CardRegion: card region [Japan/America/Europe/Australia/China/Korea]
#
CardRegion Korea
ForKorea TRUE
#
# Codec mode:
# don't have to edit
#
CodecMode $(MAKEROM_CODEC_MODE)
#
# Disp WiFiConnection Icon for Launcher [TRUE/FALSE]
#
#WiFiConnectionIcon FALSE
#
# Disp DSWireless Icon for Launcher [TRUE/FALSE]
#
#DSWirelessIcon FALSE
#
# Agree EULA [TRUE/FALSE]
#
#AgreeEULA FALSE
#
# Agree EULA version [1 - 255]
#
#AgreeEULAVersion 1
#SDCardAccess TRUE
#JpegSign TRUE
#PhotoAccess Read
###
#### END
}
AppendProperty
{
#
# Boot allowed Media: [GameCard]
#
Media NAND
#
# GameCode for TitleID : Your GameCode in 4 ascii words
#
#GameCode ABCJ
#
# Public save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M]
#
PublicSaveDataSize 1M
#
# Private save data size: [0K/16K/32K/64K/128K/256K/512K/1M/2M/4M]
#
PrivateSaveDataSize 2M
#
# Enable SubBannerFile
SubBannerFile TRUE
#
# Game card power on: [TRUE/FALSE]
#
#GameCardOn FALSE
#
# Game card transferd to nitro mode: [TRUE/FALSE]
#
#GameCardNitroMode FALSE
}
RomSpec
{
Offset 0x00000000
Segment ALL
HostRoot $(MAKEROM_ROMROOT)
Root /
File $(MAKEROM_ROMFILES)
}
Rating
{
#
# Permited age to play for each rating organization
#
# Supported organization
# - CERO (OGN0) : for Japan
# - ESRB (OGN1) : for North America
# - BBFC (OGN2) : obsolete organization
# - USK (OGN3) : for German
# - PEGI_GEN (OGN4) : for Europe
# - PEGI_FINLAND (OGN5) : obsolete organization
# - PEGI_PRT (OGN6) : for Portugal
# - PEGI_BBFC (OGN7) : for UK
# - OFLC (OGN8) : for Australia and NewZealand
# - GRB (OGN9) : for Korea
# - OGN10 : reserved
# - OGN11 : reserved
# - OGN12 : reserved
# - OGN13 : reserved
# - OGN14 : reserved
# - OGN15 : reserved
#
# Available age [ 0 - 31 / PENDING / FREE ]
# CERO FREE
# ESRB FREE
# USK FREE
# PEGI_GEN FREE
# PEGI_PRT FREE
# PEGI_BBFC FREE
# OFLC FREE
# GRB FREE
#
# Unnecessary rating: [TRUE/FALSE]
#
#Unnecessary TRUE
}

View File

@ -0,0 +1,244 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - template - demos
File: main.c
Copyright 2003-2005,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/tcl.h>
//#include <twl/ssp/ARM9/jpegdec.h>
//#include <twl/ssp/ARM9/exifdec.h>
#include <twl/os/common/format_rom.h>
#include <twl/hw/common/mmap_shared.h>
#include "DEMO.h"
#include <nitro/os/ARM9/china.h>
#define COLOR_WHITE (GX_RGBA(31, 31, 31, 1))
#define COLOR_CYAN (GX_RGBA(0, 31, 31, 1))
#define COLOR_RED (GX_RGBA(31, 0, 0, 1))
#define COLOR_YELLOW (GX_RGBA(31, 31, 0, 1))
#define TITLE_COLOR COLOR_YELLOW
#define LABEL_COLOR COLOR_WHITE
#define VALUE_COLOR COLOR_WHITE
#define OK_COLOR COLOR_CYAN
#define NG_COLOR COLOR_RED
// CRC計算
#define CRC16_INIT_VALUE 0xffff
#define CALC_CRC16_SIZE 0x15e
static u16 CalcCRC16(u16 start, u8 *data, int size);
// 中国語対応用 ISBN 文字列
// (例) { "978-7-900381-62-7", "025-2004-017", "2005", "065" }
static const char *isbn[4] = { "000-0-000000-00-0", "000-0000-000", "0000", "000" };
void TwlMain(void)
{
ROM_Header *prhTWL, *prhNTR;
char str[100];
u16 row = 0;
u16 shift = 8;
u16 crc;
OS_Init();
OS_InitChina(isbn,OS_CHINA_ISBN_DISP);
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
DEMOInitCommon();
DEMOInitVRAM();
DEMOInitDisplayBitmap();
DEMOHookConsole();
DEMOSetBitmapTextColor(GX_RGBA(31, 31, 0, 1));
DEMOSetBitmapGroundColor(DEMO_RGB_CLEAR);
DEMOStartDisplay();
/*
// TCLライブラリの組込み
{
void* pTableBuf;
void* pWorkBuf;
FSResult fs_result;
TCLResult result;
// TCLアクセサ
TCLAccessor accessor;
// TCL初期化
// 32byteアライメントが必要
pTableBuf = OS_Alloc( TCL_GetTableBufferSize() );
pWorkBuf = OS_Alloc( TCL_GetWorkBufferSize() );
if( pTableBuf == NULL || pWorkBuf == NULL )
{
OS_Panic("Cannot allocate memory!");
}
result = TCL_LoadTable( &accessor,
pTableBuf,
TCL_GetTableBufferSize(),
pWorkBuf,
TCL_GetWorkBufferSize(),
&fs_result );
}
*/
// カードROMヘッダ: NTR互換用
prhNTR = (ROM_Header*)HW_CARD_ROM_HEADER;
DEMOSetBitmapTextColor(COLOR_YELLOW);
DEMODrawText( 8, row, "Card ROM Header" );
row += 2 * shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Title Name:" );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhNTR->s.title_name, str, TITLE_NAME_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Game Code:" );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhNTR->s.game_code, str, GAME_CODE_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Header CRC:" );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, "0x%04x", prhNTR->s.header_crc16 );
row += shift;
crc = CalcCRC16( CRC16_INIT_VALUE, (u8*)prhNTR, CALC_CRC16_SIZE );
if( crc == prhNTR->s.header_crc16 )
{
DEMOSetBitmapTextColor(OK_COLOR);
DEMODrawText( 96, row, "0x%04x OK", crc );
}
else
{
DEMOSetBitmapTextColor(NG_COLOR);
DEMODrawText( 96, row, "0x%04x NG", crc );
}
row += 3 * shift;
// この固定メモリアドレスにTWLカードROMヘッダがある
// これはカードROMヘッダとは異なる
// カードROMヘッダ: NTR互換のための領域でROMヘッダのNTR互換部分だけがある
// TWLカードROMヘッダ: NTR互換部分に加えてROMヘッダのTWLで追加された部分もある
prhTWL = (ROM_Header*)HW_TWL_CARD_ROM_HEADER_BUF;
DEMOSetBitmapTextColor(COLOR_YELLOW);
DEMODrawText( 8, row, "TWL Card ROM Header" );
row += 2 * shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Title Name: " );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhTWL->s.title_name, str, TITLE_NAME_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Game Code: " );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhTWL->s.game_code, str, GAME_CODE_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "TitleID_Hi: " );
prhTWL = (ROM_Header*)HW_TWL_CARD_ROM_HEADER_BUF;
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, "0x%08x", prhTWL->s.titleID_Hi );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "TitleID_Lo: " );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhTWL->s.titleID_Lo, str, 4 );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Header CRC:" );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, "0x%04x", prhTWL->s.header_crc16 );
row += shift;
crc = CalcCRC16( CRC16_INIT_VALUE, (u8*)prhTWL, CALC_CRC16_SIZE );
if( crc == prhTWL->s.header_crc16 )
{
DEMOSetBitmapTextColor(OK_COLOR);
DEMODrawText( 96, row, "0x%04x OK", crc );
}
else
{
DEMOSetBitmapTextColor(NG_COLOR);
DEMODrawText( 96, row, "0x%04x NG", crc );
}
row += 2 * shift;
DEMOSetBitmapTextColor(GX_RGBA(31, 31, 31, 1));
DEMODrawText( 8, row, "End." );
while (1)
{
DEMO_DrawFlip();
OS_WaitVBlankIntr();
}
}
/*---------------------------------------------------------------------------*
* Math
*
* u16 CalcCRC16( u16 start, u8 *data, int size )
*---------------------------------------------------------------------------*/
static u16 crc16_table[16] = {
0x0000, 0xCC01, 0xD801, 0x1400,
0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401,
0x5000, 0x9C01, 0x8801, 0x4400
};
static u16 CalcCRC16(u16 start, u8 *data, int size)
{
u16 r1;
u16 total = start;
while (size-- > 0)
{
// 下位4bit
r1 = crc16_table[total & 0xf];
total = (u16)((total >> 4) & 0x0fff);
total = (u16)(total ^ r1 ^ crc16_table[*data & 0xf]);
// 上位4bit
r1 = crc16_table[total & 0xf];
total = (u16)((total >> 4) & 0x0fff);
total = (u16)(total ^ r1 ^ crc16_table[(*data >> 4) & 0xf]);
data++;
}
return total;
}
/*====== End of main.c ======*/

View File

@ -0,0 +1,266 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - template - demos
File: main.c
Copyright 2003-2005,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/tcl.h>
//#include <twl/ssp/ARM9/jpegdec.h>
//#include <twl/ssp/ARM9/exifdec.h>
#include <twl/os/common/format_rom.h>
#include <twl/hw/common/mmap_shared.h>
#include "DEMO.h"
#include <twl/tcl.h>
#define COLOR_WHITE (GX_RGBA(31, 31, 31, 1))
#define COLOR_CYAN (GX_RGBA(0, 31, 31, 1))
#define COLOR_RED (GX_RGBA(31, 0, 0, 1))
#define COLOR_YELLOW (GX_RGBA(31, 31, 0, 1))
#define TITLE_COLOR COLOR_YELLOW
#define LABEL_COLOR COLOR_WHITE
#define VALUE_COLOR COLOR_WHITE
#define OK_COLOR COLOR_CYAN
#define NG_COLOR COLOR_RED
// CRC計算
#define CRC16_INIT_VALUE 0xffff
#define CALC_CRC16_SIZE 0x15e
static u16 CalcCRC16(u16 start, u8 *data, int size);
void TwlMain(void)
{
ROM_Header *prhTWL, *prhNTR;
char str[100];
u16 row = 0;
u16 shift = 8;
u16 crc;
OS_Init();
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
{
FSResult fs_result;
TCLResult result;
// TCLアクセサ
TCLAccessor accessor;
void* pTableBuf;
void* pWorkBuf;
// TCL初期化
// 32byteアライメントが必要
pTableBuf = OS_Alloc( TCL_GetTableBufferSize() );
pWorkBuf = OS_Alloc( TCL_GetWorkBufferSize() );
if( pTableBuf == NULL || pWorkBuf == NULL )
{
OS_Panic("Cannot allocate memory!");
}
result = TCL_LoadTable( &accessor,
pTableBuf,
TCL_GetTableBufferSize(),
pWorkBuf,
TCL_GetWorkBufferSize(),
&fs_result );
}
DEMOInitCommon();
DEMOInitVRAM();
DEMOInitDisplayBitmap();
DEMOHookConsole();
DEMOSetBitmapTextColor(GX_RGBA(31, 31, 0, 1));
DEMOSetBitmapGroundColor(DEMO_RGB_CLEAR);
DEMOStartDisplay();
/*
// TCLライブラリの組込み
{
void* pTableBuf;
void* pWorkBuf;
FSResult fs_result;
TCLResult result;
// TCLアクセサ
TCLAccessor accessor;
// TCL初期化
// 32byteアライメントが必要
pTableBuf = OS_Alloc( TCL_GetTableBufferSize() );
pWorkBuf = OS_Alloc( TCL_GetWorkBufferSize() );
if( pTableBuf == NULL || pWorkBuf == NULL )
{
OS_Panic("Cannot allocate memory!");
}
result = TCL_LoadTable( &accessor,
pTableBuf,
TCL_GetTableBufferSize(),
pWorkBuf,
TCL_GetWorkBufferSize(),
&fs_result );
}
*/
// カードROMヘッダ: NTR互換用
prhNTR = (ROM_Header*)HW_CARD_ROM_HEADER;
DEMOSetBitmapTextColor(COLOR_YELLOW);
DEMODrawText( 8, row, "Card ROM Header" );
row += 2 * shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Title Name:" );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhNTR->s.title_name, str, TITLE_NAME_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Game Code:" );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhNTR->s.game_code, str, GAME_CODE_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Header CRC:" );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, "0x%04x", prhNTR->s.header_crc16 );
row += shift;
crc = CalcCRC16( CRC16_INIT_VALUE, (u8*)prhNTR, CALC_CRC16_SIZE );
if( crc == prhNTR->s.header_crc16 )
{
DEMOSetBitmapTextColor(OK_COLOR);
DEMODrawText( 96, row, "0x%04x OK", crc );
}
else
{
DEMOSetBitmapTextColor(NG_COLOR);
DEMODrawText( 96, row, "0x%04x NG", crc );
}
row += 3 * shift;
// この固定メモリアドレスにTWLカードROMヘッダがある
// これはカードROMヘッダとは異なる
// カードROMヘッダ: NTR互換のための領域でROMヘッダのNTR互換部分だけがある
// TWLカードROMヘッダ: NTR互換部分に加えてROMヘッダのTWLで追加された部分もある
prhTWL = (ROM_Header*)HW_TWL_CARD_ROM_HEADER_BUF;
DEMOSetBitmapTextColor(COLOR_YELLOW);
DEMODrawText( 8, row, "TWL Card ROM Header" );
row += 2 * shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Title Name: " );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhTWL->s.title_name, str, TITLE_NAME_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Game Code: " );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhTWL->s.game_code, str, GAME_CODE_MAX );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "TitleID_Hi: " );
prhTWL = (ROM_Header*)HW_TWL_CARD_ROM_HEADER_BUF;
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, "0x%08x", prhTWL->s.titleID_Hi );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "TitleID_Lo: " );
MI_CpuClear8( str, 100 );
MI_CpuCopy8( prhTWL->s.titleID_Lo, str, 4 );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, str );
row += shift;
DEMOSetBitmapTextColor(LABEL_COLOR);
DEMODrawText( 8, row, "Header CRC:" );
DEMOSetBitmapTextColor(VALUE_COLOR);
DEMODrawText( 96, row, "0x%04x", prhTWL->s.header_crc16 );
row += shift;
crc = CalcCRC16( CRC16_INIT_VALUE, (u8*)prhTWL, CALC_CRC16_SIZE );
if( crc == prhTWL->s.header_crc16 )
{
DEMOSetBitmapTextColor(OK_COLOR);
DEMODrawText( 96, row, "0x%04x OK", crc );
}
else
{
DEMOSetBitmapTextColor(NG_COLOR);
DEMODrawText( 96, row, "0x%04x NG", crc );
}
row += 2 * shift;
DEMOSetBitmapTextColor(GX_RGBA(31, 31, 31, 1));
DEMODrawText( 8, row, "End." );
while (1)
{
DEMO_DrawFlip();
OS_WaitVBlankIntr();
}
}
/*---------------------------------------------------------------------------*
* Math
*
* u16 CalcCRC16( u16 start, u8 *data, int size )
*---------------------------------------------------------------------------*/
static u16 crc16_table[16] = {
0x0000, 0xCC01, 0xD801, 0x1400,
0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401,
0x5000, 0x9C01, 0x8801, 0x4400
};
static u16 CalcCRC16(u16 start, u8 *data, int size)
{
u16 r1;
u16 total = start;
while (size-- > 0)
{
// 下位4bit
r1 = crc16_table[total & 0xf];
total = (u16)((total >> 4) & 0x0fff);
total = (u16)(total ^ r1 ^ crc16_table[*data & 0xf]);
// 上位4bit
r1 = crc16_table[total & 0xf];
total = (u16)((total >> 4) & 0x0fff);
total = (u16)(total ^ r1 ^ crc16_table[(*data >> 4) & 0xf]);
data++;
}
return total;
}
/*====== End of main.c ======*/