diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/Card/Makefile b/tests/MasterEditorTWL_mrc_roms/original_rom/Card/Makefile new file mode 100644 index 0000000..d877b54 --- /dev/null +++ b/tests/MasterEditorTWL_mrc_roms/original_rom/Card/Makefile @@ -0,0 +1,51 @@ +#! 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 + +SUBDIRS = ../common/banner \ + $(ROOT)/build/demos/gx/UnitTours/DEMOLib + +TARGET_BIN = CardRomHeaderChecker.srl +#INCDIR = ../common/include +SRCDIR = ../common/src +SRCS = main.c + +ROM_SPEC = ./ROM-TS.rsf + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib + +# インストール指定 +#ifneq ($(TWL_IPL_RED_ROOT),) +#INSTALL_DIR = $(TWL_IPL_RED_ROOT)/debugsoft/CardRomHeaderChecker +#INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) +#endif + + +do-build: $(TARGETS) + +#---------------------------------------------------------------------------- + +LIBSYSCALL = ../common/0CZA/libsyscall.a + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/Card/ROM-TS.rsf b/tests/MasterEditorTWL_mrc_roms/original_rom/Card/ROM-TS.rsf new file mode 100644 index 0000000..b02f0fd --- /dev/null +++ b/tests/MasterEditorTWL_mrc_roms/original_rom/Card/ROM-TS.rsf @@ -0,0 +1,238 @@ +#---------------------------------------------------------------------------- +# 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 1TROM + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G/4G] + # + RomSize 256M + + # + # 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 + + ### + ### 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 Japan + + # + # 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 + + ### + #### END +} + +AppendProperty +{ + # + # Boot allowed Media: [GameCard] + # + Media GameCard + + # + # 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 +} + +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 + # - OGN9 : reserved + # - OGN10 : reserved + # - OGN11 : reserved + # - OGN12 : reserved + # - OGN13 : reserved + # - OGN14 : reserved + # - OGN15 : reserved + # + # Available age [ 0 - 31 / PENDING / FREE ] + # + + CERO 0 +# ESRB FREE +# USK FREE +# PEGI_GEN FREE +# PEGI_PRT FREE +# PEGI_BBFC FREE +# OFLC FREE + + # + # Unnecessary rating: [TRUE/FALSE] + # +# Unnecessary TRUE +} + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(MAKEROM_ROMROOT) + Root / + File $(MAKEROM_ROMFILES) +} diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/Makefile b/tests/MasterEditorTWL_mrc_roms/original_rom/Makefile new file mode 100644 index 0000000..d5d8dc2 --- /dev/null +++ b/tests/MasterEditorTWL_mrc_roms/original_rom/Makefile @@ -0,0 +1,35 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - debugsoft - ApplicationJump +# 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 + +include $(TWLSDK_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = Card \ + Nand + +#---------------------------------------------------------------------------- + +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +#===== End of Makefile ===== + + diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/Nand/Makefile b/tests/MasterEditorTWL_mrc_roms/original_rom/Nand/Makefile new file mode 100644 index 0000000..dd80640 --- /dev/null +++ b/tests/MasterEditorTWL_mrc_roms/original_rom/Nand/Makefile @@ -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 = CardRomHeaderChecker.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 + +# インストール指定 +#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 ===== diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/Nand/ROM-TS_nand.rsf b/tests/MasterEditorTWL_mrc_roms/original_rom/Nand/ROM-TS_nand.rsf new file mode 100644 index 0000000..b15c03c --- /dev/null +++ b/tests/MasterEditorTWL_mrc_roms/original_rom/Nand/ROM-TS_nand.rsf @@ -0,0 +1,252 @@ +#---------------------------------------------------------------------------- +# 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 Japan + + # + # 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 +} diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/common/0CZA/libsyscall.a b/tests/MasterEditorTWL_mrc_roms/original_rom/common/0CZA/libsyscall.a new file mode 100644 index 0000000..7377eea Binary files /dev/null and b/tests/MasterEditorTWL_mrc_roms/original_rom/common/0CZA/libsyscall.a differ diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/common/0CZA/rom_header_0cza.template.sbin b/tests/MasterEditorTWL_mrc_roms/original_rom/common/0CZA/rom_header_0cza.template.sbin new file mode 100644 index 0000000..f99ad76 Binary files /dev/null and b/tests/MasterEditorTWL_mrc_roms/original_rom/common/0CZA/rom_header_0cza.template.sbin differ diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/Makefile b/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/Makefile new file mode 100644 index 0000000..1f8aa1d --- /dev/null +++ b/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# 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:: $ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +ICON_DIR = ./icon + +BANNER_ICON = $(ICON_DIR)/gameIcon.bmp +BANNER_SPEC = banner_v3.bsf + +TARGETS = banner.bnr +INSTALL_DIR = ./ +INSTALL_TARGETS = $(TARGETS) + +BANNER_ICON_NAME = $(basename $(BANNER_ICON)) + +LDIRT_CLEAN = $(TARGETS) \ + $(BANNER_ICON_NAME).nbfs \ + $(BANNER_ICON_NAME).nbfc \ + $(BANNER_ICON_NAME).nbfp \ + $(TARGETS:.bnr=.srl) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- +# build +#---------------------------------------------------------------------------- +do-build: $(TARGETS) + +$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) + $(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \ + $(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS) + +# diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/banner_v3.bsf b/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/banner_v3.bsf new file mode 100644 index 0000000..427fb48 Binary files /dev/null and b/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/banner_v3.bsf differ diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/icon/gameIcon.bmp b/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/icon/gameIcon.bmp new file mode 100644 index 0000000..3ea06fe Binary files /dev/null and b/tests/MasterEditorTWL_mrc_roms/original_rom/common/banner/icon/gameIcon.bmp differ diff --git a/tests/MasterEditorTWL_mrc_roms/original_rom/common/src/main.c b/tests/MasterEditorTWL_mrc_roms/original_rom/common/src/main.c new file mode 100644 index 0000000..398f523 --- /dev/null +++ b/tests/MasterEditorTWL_mrc_roms/original_rom/common/src/main.c @@ -0,0 +1,238 @@ +/*---------------------------------------------------------------------------* + 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 +//#include +//#include +//#include +#include +#include +#include "DEMO.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(); + + 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 ======*/