diff --git a/trunk/FlickerCfgChanger/ConsoleBackup.bsf b/trunk/FlickerCfgChanger/ConsoleBackup.bsf new file mode 100644 index 0000000..104a94d Binary files /dev/null and b/trunk/FlickerCfgChanger/ConsoleBackup.bsf differ diff --git a/trunk/FlickerCfgChanger/OMakefile b/trunk/FlickerCfgChanger/OMakefile new file mode 100644 index 0000000..dc007b5 --- /dev/null +++ b/trunk/FlickerCfgChanger/OMakefile @@ -0,0 +1,47 @@ +#!/usr/bin/env omake +#---------------------------------------------------------------------------- +# Project: CalViewer +# File: OMakefile +# +# Copyright (C)2009 Nintendo Co., Ltd. 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. +# +# $Revision$ +#---------------------------------------------------------------------------- +SUPPORTED_TARGETS = CTR-T*.Process.MPCore.fast +CTR_APPTYPE = CARD + +SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include) +INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \ + ../common + +include $(HORIZON_ROOT)/include/nn/CTR/CTR_Version.inc +FIRM_VERSION = $(getvar global.NN_CTR_VERSIOIN_NATIVE_FIRM) +MAKEROMFLAGS += -DFIRM_VERSION=$(FIRM_VERSION) + +SOURCES[] = + main.cpp + +TARGET_PROGRAM = FlickerCfgChanger + +CTR_BANNER_SPEC = ConsoleBackup.bsf + +INCLUDES += include + +LIBS += lib_demo libnn_driversCal libnn_driversEeprom libnn_i2c + +# RSF +ROM_SPEC_FILE = $(HORIZON_ROOT)/sources/tools/Config/Config.rsf + +# DESC +DESCRIPTOR = $(HORIZON_ROOT)/sources/tools/Config/Config.autogen.desc + + +include $(ROOT_OMAKE)/modulerules + +build: $(DEFAULT_TARGETS) diff --git a/trunk/FlickerCfgChanger/OMakeroot b/trunk/FlickerCfgChanger/OMakeroot new file mode 100644 index 0000000..7ee1cb5 --- /dev/null +++ b/trunk/FlickerCfgChanger/OMakeroot @@ -0,0 +1,73 @@ +#!/usr/bin/env omake +#---------------------------------------------------------------------------- +# Project: Horizon +# File: OMakeroot +# +# Copyright (C)2009 Nintendo Co., Ltd. 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. +# +# $Rev:$ +#---------------------------------------------------------------------------- + +# ディレクトリレイアウトについての説明 +# +# a) ソースコードがルートディレクトリ直下に配置される場合 +# 例: +# /OMakeroot +# /foo/bar/OMakefile +# +# 結果: +# OMakefile と同じディレクトリ以下に objects や images が生成されます。 +# +# /foo/bar/objects/... +# /foo/bar/images/.. +# +# +# b) ソースコードが sources 以下に配置される場合 +# 例: +# /OMakeroot +# /sources/foo/bar/OMakefile +# +# 結果: +# ルートディレクトリ以下に objects や images が生成されます。 +# +# /objects/foo/bar/... +# /images/foo/bar/... +# +# + +# ルート環境変数の取得 +public.HORIZON_ROOT = +if $(defined-env HORIZON_ROOT) + HORIZON_ROOT = $(absname $(getenv HORIZON_ROOT)) + export + +if $(defined-env CTRSDK_ROOT) + CTRSDK_ROOT = $(absname $(getenv CTRSDK_ROOT)) + if $(and $(defined-env HORIZON_ROOT), $(not $(equal $(HORIZON_ROOT), $(CTRSDK_ROOT)))) + eprintln(HORIZON_ROOT と CTRSDK_ROOT が一致しません。同じパスを設定するか、どちらか一方だけを定義して下さい。) + exit(1) + HORIZON_ROOT = $(CTRSDK_ROOT) + export + +if $(not $(HORIZON_ROOT)) + eprintln($"$$CTRSDK_ROOT が定義されていません") + exit(1) + +include $(HORIZON_ROOT)/build/omake/commondefs + +DefineCommandVars() + +.PHONY: all build clean clobber +.PHONY: run run-scripts run-emumem + +# +# OMakefile の読み込み +# +.SUBDIRS: . + diff --git a/trunk/FlickerCfgChanger/Readme.txt b/trunk/FlickerCfgChanger/Readme.txt new file mode 100644 index 0000000..64259f6 --- /dev/null +++ b/trunk/FlickerCfgChanger/Readme.txt @@ -0,0 +1,4 @@ +【ビルド環境】 + +・SDK +Horizon 0_14 branch r33437 diff --git a/trunk/FlickerCfgChanger/banner/model.cbmd b/trunk/FlickerCfgChanger/banner/model.cbmd new file mode 100644 index 0000000..f1c7b62 Binary files /dev/null and b/trunk/FlickerCfgChanger/banner/model.cbmd differ diff --git a/trunk/FlickerCfgChanger/banner/sound.cbsd b/trunk/FlickerCfgChanger/banner/sound.cbsd new file mode 100644 index 0000000..f1c7b62 Binary files /dev/null and b/trunk/FlickerCfgChanger/banner/sound.cbsd differ diff --git a/trunk/FlickerCfgChanger/banner/unknown24x24.ctpk b/trunk/FlickerCfgChanger/banner/unknown24x24.ctpk new file mode 100644 index 0000000..794b136 --- /dev/null +++ b/trunk/FlickerCfgChanger/banner/unknown24x24.ctpk @@ -0,0 +1 @@ +スススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススニススススススススススススススススススススススススススススススススススススススニ8ニ8ニ゙銷スス8ニススススス釡゙ニ鍄踟ススススススススススススススススススススススススススススススススススススススススススニススススススススススススススススススススススススススススススススススススススススススyホスyホスススススYホスススススススススススススススススススススススススススススススススス鍄゙yホYホスロ゙ロ゙ススニススロ゙yボスyホ轌ホ釡゙ススススYホ轌ホ銷スススススyホニロ゙鍄躡ホyホスススyホスコヨスススススyホスyホスススススYホスススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススyホ躡ホ銷スススススニスス轌ホ8ニススススニススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススス \ No newline at end of file diff --git a/trunk/FlickerCfgChanger/banner/unknown48x48.ctpk b/trunk/FlickerCfgChanger/banner/unknown48x48.ctpk new file mode 100644 index 0000000..8c7da16 --- /dev/null +++ b/trunk/FlickerCfgChanger/banner/unknown48x48.ctpk @@ -0,0 +1 @@ +スススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススYホススススススススススススススススススススススススススス8ニスス8ニ8ニスススコヨ8ニコヨ釡゙銷スススススススススス8ニ8ニススニススススススススススススススススス鍄逧ヨニ銷スス墮ス逧ヨ銷スススススススススススススススススススススススススススススススススススススススススス8ニススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススロ゙スロ゙ススススス銷ズスススススススススススススススススススススコヨスススススススススス鍄8ニ゙ロ゙スス墮スYホススススス躡ホyホ轌ホニススススススススニススススススススススススロ゙ロ゙釡゙踟スス躡ホ銷スススススロ゙スロ゙銷ススYボ墮釡゙コヨス墮スロ゙ススススス踟ス踟スススススススススススススススススススススロ゙スyホススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススYホス墮銷スロ゙スロ゙銷ススススススススススススススススス8ニススコヨロ゙スススススYホニyホ逧ヨ郤ヨスYホス觝ホススススススススススススススロ゙墮ススススススyホス鍄踟ススニスススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススス踟ス銷ズスYホ鍄銷ススススススススススススススススススススス8ニスススススススススス逧ヨスロ゙ス釡゙墮ススススススススススススススススススス8ニススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススススス \ No newline at end of file diff --git a/trunk/FlickerCfgChanger/main.cpp b/trunk/FlickerCfgChanger/main.cpp new file mode 100644 index 0000000..3c797ca --- /dev/null +++ b/trunk/FlickerCfgChanger/main.cpp @@ -0,0 +1,301 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: main.cpp + + Copyright 2009-2011 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. + + $Rev$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "demo.h" + +#define HANDLE_ERROR(result) \ + if(result.IsFailure()) \ + { \ + DrawError(result, __LINE__); \ + } \ + +namespace +{ + +nn::drivers::cal::CTR::LcdFlickerInfo s_LcdFlickerInfo; +bool s_LcdFlickerInfoIsValid = false; +u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN]; +bit64 s_TranferableId; +bool s_CanReadSerialNumber = false; +u32 s_CalVersion = 0; + +void* heapForGx; +nn::fnd::ExpHeap s_AppHeap; +demo::RenderSystemDrawing s_RenderSystem; + +} + +void DrawError(nn::Result result, s32 line) +{ + s_RenderSystem.SetColor(1, 0, 0); + for(;;) + { + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 0, 0, 0, 1); + s_RenderSystem.Clear(); + s_RenderSystem.DrawText(0, 0, "line %d: Error = %X", line, result.GetPrintableBits()); + s_RenderSystem.SwapBuffers(); + + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 1, 0, 0, 1); + s_RenderSystem.Clear(); + s_RenderSystem.SwapBuffers(); + + nngxWaitVSync(NN_GX_DISPLAY_BOTH); + } +} + +void Finalize() +{ + s_RenderSystem.Finalize(); + s_AppHeap.Free(heapForGx); + s_AppHeap.Finalize(); + + nn::applet::DisableSleep(); + nn::hid::Finalize(); + nn::cfg::init::Finalize(); + nn::fs::Finalize(); + + nn::applet::PrepareToCloseApplication(); + nn::applet::CloseApplication(); +} + +extern "C" void nnMain() +{ + nn::Result result; + + // os 縺ョ蛻晄悄蛹 + nn::os::Initialize(); + + // ServiceManager繝励Ο繧サ繧ケ縺ョ蛻晄悄蛹 + result = nn::srv::Initialize(); + HANDLE_ERROR(result); + + nn::applet::Enable(); + + NN_LOG("FlickerCalCollector start\n"); + + const u32 s_GxHeapSize = 0x800000; + + // 繝偵シ繝励ョ遒コ菫 + s_AppHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR); + + // RenderSystem 縺ョ貅門y + heapForGx = s_AppHeap.Allocate(s_GxHeapSize); + s_RenderSystem.Initialize(reinterpret_cast(heapForGx), s_GxHeapSize); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 0, 0, 0, 1); + s_RenderSystem.SetColor(1, 1, 1); + + // fs 縺ョ蛻晄悄蛹 + nn::fs::Initialize(); + + // NAND 繝槭え繝ウ繝 + // nand:/ro/ 縺ョ繝槭え繝ウ繝 + result = nn::fs::MountSpecialArchive("nandro:", nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND_RO); + if ( result.IsFailure() ) + { + NN_LOG_WARN("[CFG] Mount nand:/ro failed.\n"); + nn::dbg::PrintResult(result); + } + + NN_LOG("Before %d, %d\n", s_LcdFlickerInfo.vcomTop, s_LcdFlickerInfo.vcomBottom); + // cal 縺ョ諠蝣ア蜿門セ + { + nn::drivers::cal::CTR::Calibration calibration; + nn::drivers::cal::CTR::Type currentCalType; + + // Cal 縺ョ蛻晄悄蛹 + calibration.Initialize(); + + //----- 繝舌シ繧ク繝ァ繝ウ繧貞叙蠕 + s_CalVersion = calibration.GetVersion(); + + //----- LCD FLICKER + currentCalType = nn::drivers::cal::CTR::CAL_DATA_LCD_FLICKER; + s_LcdFlickerInfoIsValid = calibration.Get(&s_LcdFlickerInfo, currentCalType); + if(!s_LcdFlickerInfoIsValid) + { + DrawError(nn::ResultSuccess(), __LINE__); + } + } + result = nn::fs::Unmount("nandro"); + HANDLE_ERROR(result); + + // cfg 縺ョ蛻晄悄蛹 + nn::cfg::CTR::init::Initialize(); + + // 繧キ繝ェ繧「繝ォ繝翫Φ繝舌シ縺ョ蜿門セ + std::memset(s_SerialNo, '\0', + nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN); + result = nn::cfg::CTR::init::GetSerialNo(s_SerialNo); + HANDLE_ERROR(result); + if(result.IsSuccess()) + { + s_CanReadSerialNumber = true; + } + + // 遘サ陦悟庄閭スID縺ョ蜿門セ + s_TranferableId = nn::cfg::CTR::GetTransferableId(0); + + nn::hid::InitializeWithPrivilege(); + + u32 count = 0; + s32 flushCount = -1; + + nn::hid::PadReader padReader; + nn::hid::PadStatus padStatus; + + using namespace nn::cfg::CTR::detail; + + LcdFlickerCfgData flicker; + // 迴セ蝨ィ縺ョcfg蛟、縺ョ蜿門セ + result = nn::cfg::CTR::init::GetConfig(&flicker, sizeof(LcdFlickerCfgData), + GET_CFG_KEY(NN_CFG_LCD, NN_CFG_LCD_CAL_FLICKER)); + HANDLE_ERROR(result); + + for (;;) + { + padReader.ReadLatest(&padStatus); + + // 繧ュ繝シ縺ョ蜿肴丐 + if(padStatus.trigger & nn::hid::BUTTON_A || + padStatus.hold & nn::hid::BUTTON_X) + { + flicker.vcomTop++; + } + + if(padStatus.trigger & nn::hid::BUTTON_B || + padStatus.hold & nn::hid::BUTTON_Y) + { + flicker.vcomTop--; + } + + if(padStatus.trigger & nn::hid::BUTTON_RIGHT || + padStatus.hold & nn::hid::BUTTON_R) + { + flicker.vcomBottom++; + } + + if(padStatus.trigger & nn::hid::BUTTON_LEFT || + padStatus.hold & nn::hid::BUTTON_L) + { + flicker.vcomBottom--; + } + + if(padStatus.trigger & nn::hid::BUTTON_START) + { + NN_LOG("update\n"); + // 譖ク縺崎セシ縺ソ + result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_LCD, NN_CFG_LCD_CAL_FLICKER), &flicker, + sizeof(LcdFlickerCfgData)); + HANDLE_ERROR(result); + result = nn::cfg::CTR::init::FlushConfig(); + HANDLE_ERROR(result); + flushCount = count; + + // 迴セ蝨ィ縺ョcfg蛟、縺ョ蜿門セ + result = nn::cfg::CTR::init::GetConfig(&flicker, sizeof(LcdFlickerCfgData), + GET_CFG_KEY(NN_CFG_LCD, NN_CFG_LCD_CAL_FLICKER)); + HANDLE_ERROR(result); + } + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 0, 0, 0, 1); + s_RenderSystem.Clear(); + + s_RenderSystem.DrawText(0, 0, "count = %d", count++); + if(s_CanReadSerialNumber) + { + s_RenderSystem.DrawText(0, 10, "serial = %s", s_SerialNo); + } + s_RenderSystem.DrawText(0, 20, "TransferableId = %llx\n", s_TranferableId); + s_RenderSystem.DrawText(0, 30, "calVersion = %d\n", s_CalVersion); + s_RenderSystem.DrawText(0, 40, "Flicker = %0x, %0x", s_LcdFlickerInfo.vcomTop, s_LcdFlickerInfo.vcomBottom); + s_RenderSystem.DrawText(0, 50, "cfg = %0x, %0x", flicker.vcomTop, flicker.vcomBottom); + s_RenderSystem.DrawText(0, 60, "flush = %d", flushCount); + s_RenderSystem.DrawText(0, 80, "A : VcomTop++"); + s_RenderSystem.DrawText(0, 90, "B : VcomTop--"); + s_RenderSystem.DrawText(0, 100, "Right: VcomBottom++"); + s_RenderSystem.DrawText(0, 110, "Left : VcomBottom--"); + s_RenderSystem.DrawText(0, 120, "Start: Flush data to Nand"); + + s_RenderSystem.SwapBuffers(); + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 0, 0, 0, 1); + s_RenderSystem.Clear(); + + + s_RenderSystem.SwapBuffers(); + nngxWaitVSync(NN_GX_DISPLAY_BOTH); + + // Home繝懊ち繝ウ + if (nn::applet::IsExpectedToProcessHomeButton()) + { + nn::applet::ProcessHomeButton(); + nn::applet::WaitForStarting(); + + // 蠕縺。縺縺代°繧峨ョ謌サ繧顔オゆコ繝√ぉ繝繧ッ + if (nn::applet::IsExpectedToCloseApplication()) + { + break; + } + + // GPU 繝ャ繧ク繧ケ繧ソ險ュ螳壹ョ蠕ゥ蟶ー + nngxUpdateState(NN_GX_STATE_ALL); + nngxValidateState(NN_GX_STATE_ALL, GL_TRUE); + } + + // 髮サ貅舌懊ち繝ウ + if (nn::applet::IsExpectedToProcessPowerButton()) + { + nn::applet::ProcessPowerButton(); + nn::applet::WaitForStarting(); + + // 蠕縺。縺縺代°繧峨ョ謌サ繧顔オゆコ繝√ぉ繝繧ッ + if (nn::applet::IsExpectedToCloseApplication()) + { + break; + } + + // GPU 繝ャ繧ク繧ケ繧ソ險ュ螳壹ョ蠕ゥ蟶ー + nngxUpdateState(NN_GX_STATE_ALL); + nngxValidateState(NN_GX_STATE_ALL, GL_TRUE); + } + + if (nn::applet::IsExpectedToCloseApplication()) + { + break; + } + } + + Finalize(); +}