mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@276 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
e69bf8e098
commit
93ab9dbba0
@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
|
||||
SUBDIRS = make_tad_table my_armadillo.TWL copy_org copy_dst
|
||||
SUBDIRS = make_tad_table my_armadillo.TWL copy_org copy_dst auto_preinst_rom
|
||||
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
119
build/tools/sctools/auto_preinst_rom/Makefile
Normal file
119
build/tools/sctools/auto_preinst_rom/Makefile
Normal file
@ -0,0 +1,119 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - demos - MI - ndma-1
|
||||
# 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:: 2008-01-17#$
|
||||
# $Rev: 3650 $
|
||||
# $Author: okubata_ryoma $
|
||||
#----------------------------------------------------------------------------
|
||||
SUBDIRS = ./banner ../files/tads ../files/taddevs
|
||||
|
||||
TARGET_PLATFORM := TWL
|
||||
TWL_ARCHGEN := LIMITED
|
||||
|
||||
SRCDIR = ../common/src ./src
|
||||
|
||||
SRCS = main.c key.c font.c text.c mprintf.c logprintf.c \
|
||||
gfx.c hwi.c my_fs_util.c \
|
||||
error_report.c \
|
||||
myfilename.c menu_version.c \
|
||||
myimport.c pre_install.c
|
||||
|
||||
TARGET_BIN = auto_preinst_rom.srl
|
||||
ROM_SPEC = auto_preinst_rom.rsf
|
||||
# TARGET_AUTOBOOT = ./bin/$(TWL_BUILDTYPE)/auto_preinst_rom.srl
|
||||
|
||||
|
||||
ES_DIR = $(ROOT)/add-ins/es
|
||||
ES_LATEST = $(shell ls -d $(ES_DIR)/es-sdk-*|sort|tail -n 1)
|
||||
ES_ROOT = $(ES_LATEST)
|
||||
|
||||
LINCLUDES = $(TWLSDK_ROOT)/build/libraries/lcfg/ARM9.TWL/include ../common/src \
|
||||
$(TWLSDK_ROOT)/build/libraries/nam/ARM9.TWL/include \
|
||||
$(TWLSDK_ROOT)/build/libraries/ese/common/include \
|
||||
$(ES_ROOT)/twl/include $(ES_ROOT)/common/lib/ec/include
|
||||
|
||||
LLIBRARY_DIRS += $(ES_ROOT)/twl/lib/$(TWL_BUILDTYPE) ../wifilib/$(TWL_BUILDTYPE)
|
||||
# LLIBRARY_DIRS += $(ES_ROOT)/twl/lib/$(TWL_BUILDTYPE)
|
||||
|
||||
|
||||
LLIBRARIES += libecx$(TWL_LIBSUFFIX).a \
|
||||
liblcfg$(TWL_LIBSUFFIX).a \
|
||||
libnhttp.nssl$(TWL_LIBSUFFIX).a \
|
||||
libshr$(TWL_LIBSUFFIX).a \
|
||||
libnuc$(TWL_LIBSUFFIX).a \
|
||||
libnup$(TWL_LIBSUFFIX).a \
|
||||
libnam$(TWL_LIBSUFFIX).a \
|
||||
libes$(TWL_LIBSUFFIX).a \
|
||||
libsea$(TWL_LIBSUFFIX).a \
|
||||
libboc$(TWL_LIBSUFFIX).a \
|
||||
libsfs$(TWL_LIBSUFFIX).a \
|
||||
libna$(TWL_LIBSUFFIX).a \
|
||||
|
||||
|
||||
MAKEROM_ROMROOT = ../files
|
||||
|
||||
TAD_TABLE_TXT = ../files/tads/tad_table.txt
|
||||
|
||||
TADDEV_TABLE_TXT = ../files/taddevs/taddev_table.txt
|
||||
|
||||
MAKE_TAD_INCLUDE_FILE = ../copy_dst/MakefileTad.inc
|
||||
|
||||
MAKE_TADDEV_INCLUDE_FILE = ../copy_dst/MakefileTadDev.inc
|
||||
|
||||
-include $(MAKE_TAD_INCLUDE_FILE)
|
||||
|
||||
-include $(MAKE_TADDEV_INCLUDE_FILE)
|
||||
|
||||
MAKEROM_ROMFILES = tads/tad_table.txt taddevs/taddev_table.txt $(MAKEROM_TAD_ROMFILES) $(MAKEROM_TADDEV_ROMFILES)
|
||||
|
||||
MY_TWL_COMPONENTSDIR = ../my_armadillo.TWL/bin
|
||||
|
||||
COMPONENT_NAME = armadillo
|
||||
|
||||
MAKEROM_ARM7_BASE = $(MY_TWL_COMPONENTSDIR)/$(TWL_BUILDTYPE_ARM7)/$(COMPONENT_NAME)
|
||||
|
||||
MAKEROM_ARM7 = $(MAKEROM_ARM7_BASE).$(TWL_ELF_EXT)
|
||||
|
||||
|
||||
LDIRT_CLEAN =
|
||||
|
||||
|
||||
include $(TWLWIFI_ROOT)/build/buildtools/commondefs
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
|
||||
|
||||
#----------------------------------
|
||||
# ƒZƒLƒ…ƒAƒAƒvƒŠŽw’è
|
||||
|
||||
MAKEROM := $(TWL_TOOLSDIR)/bin/makerom.TWL.secure.exe
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# $(TARGET_AUTOBOOT): ./bin/$(TWL_BUILDTYPE)/$(TARGET_BIN)
|
||||
# ../bin/FakeRomHeader.secure.exe -c -f $< $@
|
||||
|
||||
|
||||
# do-build: $(TARGETS) $(TARGET_AUTOBOOT)
|
||||
|
||||
do-build: $(TARGETS)
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET_BIN_BASENAME).$(TWL_ELF_EXT): $(MAKE_TAD_INCLUDE_FILE) $(MAKE_TADDEV_INCLUDE_FILE) $(TAD_TABLE_TXT) $(TADDEV_TABLE_TXT)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
include $(TWLWIFI_ROOT)/build/buildtools/modulerules
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
325
build/tools/sctools/auto_preinst_rom/auto_preinst_rom.rsf
Normal file
325
build/tools/sctools/auto_preinst_rom/auto_preinst_rom.rsf
Normal file
@ -0,0 +1,325 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - include
|
||||
# File: ROM-TS.rsf
|
||||
#
|
||||
# Copyright 2007-2008 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-09-26#$
|
||||
# $Rev: 8709 $
|
||||
# $Author: hatamoto_minoru $
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# 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 "MY APP NAME"
|
||||
|
||||
#
|
||||
# MAKER CODE: Your company ID# in 2 ascii words
|
||||
# issued by NINTENDO
|
||||
#
|
||||
MakerCode 01
|
||||
|
||||
#
|
||||
# REMASTER VERSION: Mastering version
|
||||
#
|
||||
#RemasterVersion 0
|
||||
|
||||
#
|
||||
# ROM SPEED TYPE: [MROM/1TROM/UNDEFINED]
|
||||
#
|
||||
RomSpeedType $(MAKEROM_ROMSPEED)
|
||||
|
||||
#
|
||||
# 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 ./etc/rom_header.template.sbin
|
||||
|
||||
#
|
||||
# BANNER FILE: generated from Banner Spec File
|
||||
#
|
||||
BannerFile "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 MAP_TS_SCR
|
||||
|
||||
#
|
||||
# CardRegion: card region [Japan/America/Europe/Australia/China/Korea]
|
||||
#
|
||||
CardRegion ALL
|
||||
|
||||
#
|
||||
# CommonClientKey: launcher deliver common client Key [TRUE/FALSE]
|
||||
#
|
||||
CommonClientKey TRUE
|
||||
|
||||
#
|
||||
# HwAESSlotA_SSLClientCert: launcher deliver HW AES slot A setting [TRUE/FALSE]
|
||||
#
|
||||
HwAESSlotA_SSLClientCert TRUE
|
||||
|
||||
#
|
||||
# HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE]
|
||||
#
|
||||
HwAESSlotB TRUE
|
||||
|
||||
#
|
||||
# HwAESSlotB for Sign JPEG for Launcher: launcher deliver HW AES slot B setting for Sign JPEG for Launcher [TRUE/FALSE]
|
||||
#
|
||||
#HwAESSlotB_SignJPEGForLauncher FALSE
|
||||
|
||||
#
|
||||
# HwAESSlotB for Sign JPEG for User: launcher deliver HW AES slot B setting for Sign JPEG for User [TRUE/FALSE]
|
||||
#
|
||||
#HwAESSlotB_SignJPEGForUser FALSE
|
||||
|
||||
#
|
||||
# HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE]
|
||||
#
|
||||
#HwAESSlotC FALSE
|
||||
|
||||
#
|
||||
# SDCardAccess: sd card access control [TRUE/FALSE]
|
||||
#
|
||||
SDCardAccess ReadWrite
|
||||
|
||||
#
|
||||
# NANDAccess: NAND access control [TRUE/FALSE]
|
||||
#
|
||||
NANDAccess 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
|
||||
|
||||
#
|
||||
# Disable debug [TRUE/FALSE]
|
||||
#
|
||||
DisableDebug FALSE
|
||||
|
||||
#
|
||||
# Agree EULA [TRUE/FALSE]
|
||||
#
|
||||
#AgreeEULA FALSE
|
||||
|
||||
#
|
||||
# Agree EULA version [1 - 255]
|
||||
#
|
||||
#AgreeEULAVersion 1
|
||||
|
||||
###
|
||||
#### 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]
|
||||
#
|
||||
Media GameCard
|
||||
|
||||
#
|
||||
# Data only title : [TRUE/FALSE]
|
||||
# don't have to edit
|
||||
#DataOnly FALSE
|
||||
|
||||
#
|
||||
# Secure title : [TRUE/FALSE]
|
||||
# don't have to edit
|
||||
Secure TRUE
|
||||
|
||||
#
|
||||
# InitialCode : Your InitialCode in 4 ascii words
|
||||
#
|
||||
#InitialCode ABCJ
|
||||
|
||||
#
|
||||
# Public save data size: [0-/0K-/0M-]
|
||||
#
|
||||
#PublicSaveDataSize 0K
|
||||
|
||||
#
|
||||
# Private save data size: [0-/0K-/0M-]
|
||||
#
|
||||
#PrivateSaveDataSize 0K
|
||||
|
||||
#
|
||||
# Enable SubBannerFile: [TRUE/FALSE]
|
||||
#
|
||||
#SubBannerFile FALSE
|
||||
|
||||
#
|
||||
# Game card power on: [TRUE/FALSE]
|
||||
#
|
||||
GameCardOn FALSE
|
||||
|
||||
#
|
||||
# Game card transferd to nitro mode: [TRUE/FALSE]
|
||||
#
|
||||
#GameCardNitroMode FALSE
|
||||
|
||||
#
|
||||
# Shared2 file size: [DISABLE/0-4194304/0K-4096K/0M-4M]
|
||||
#
|
||||
#Shared2File0Size Disable
|
||||
#Shared2File1Size Disable
|
||||
#Shared2File2Size Disable
|
||||
#Shared2File3Size Disable
|
||||
#Shared2File4Size Disable
|
||||
#Shared2File5Size Disable
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
59
build/tools/sctools/auto_preinst_rom/banner/Makefile
Normal file
59
build/tools/sctools/auto_preinst_rom/banner/Makefile
Normal file
@ -0,0 +1,59 @@
|
||||
#! make -f
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: TwlSDK - nandApp - demos - SubBanner
|
||||
# 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:: 2008-06-27#$
|
||||
# $Rev: 6887 $
|
||||
# $Author: nakasima $
|
||||
#----------------------------------------------------------------------------
|
||||
TARGET_PLATFORM = TWL
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/commondefs
|
||||
MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe
|
||||
|
||||
ICON_DIR = ./icon
|
||||
|
||||
BANNER_ICON = $(ICON_DIR)/gameIcon.bmp
|
||||
BANNER_SPEC = banner_v3.bsf
|
||||
|
||||
SUB_BANNER_ICON = $(ICON_DIR)/subIcon.bmp
|
||||
SUB_BANNER_SPEC = sub_banner_v3.bsf
|
||||
|
||||
|
||||
TARGETS = banner.bnr
|
||||
SUB_TARGETS = sub_banner.bnr
|
||||
INSTALL_DIR = ./
|
||||
INSTALL_TARGETS = $(TARGETS) $(SUB_TARGETS)
|
||||
|
||||
BANNER_ICON_NAME = $(basename $(BANNER_ICON))
|
||||
BANNER_ICON_MIDDLE = $(addprefix $(BANNER_ICON_NAME), .nbfs .nbfc .nbfp)
|
||||
SUB_BANNER_ICON_NAME = $(basename $(SUB_BANNER_ICON))
|
||||
SUB_BANNER_ICON_MIDDLE = $(addprefix $(SUB_BANNER_ICON_NAME), .nbfs .nbfc .nbfp)
|
||||
|
||||
LDIRT_CLEAN = $(TARGETS) $(SUB_TARGETS) \
|
||||
$(BANNER_ICON_MIDDLE) \
|
||||
$(SUB_BANNER_ICON_MIDDLE) \
|
||||
$(TARGETS:.bnr=.srl)
|
||||
|
||||
include $(TWLSDK_ROOT)/build/buildtools/modulerules
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# build
|
||||
#----------------------------------------------------------------------------
|
||||
do-build: $(TARGETS) $(SUB_TARGETS)
|
||||
|
||||
$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) $(BANNER_ICON_MIDDLE)
|
||||
$(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS)
|
||||
|
||||
$(SUB_TARGETS): $(SUB_BANNER_SPEC) $(SUB_BANNER_ICON) $(SUB_BANNER_ICON_MIDDLE)
|
||||
$(MAKEBANNER) -s -N $(SUB_BANNER_ICON_NAME) $(SUB_BANNER_SPEC) $(SUB_TARGETS)
|
||||
#
|
||||
BIN
build/tools/sctools/auto_preinst_rom/banner/banner_v3.bsf
Normal file
BIN
build/tools/sctools/auto_preinst_rom/banner/banner_v3.bsf
Normal file
Binary file not shown.
BIN
build/tools/sctools/auto_preinst_rom/banner/icon/gameIcon.bmp
Normal file
BIN
build/tools/sctools/auto_preinst_rom/banner/icon/gameIcon.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 630 B |
BIN
build/tools/sctools/auto_preinst_rom/banner/icon/subIcon.bmp
Normal file
BIN
build/tools/sctools/auto_preinst_rom/banner/icon/subIcon.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 630 B |
BIN
build/tools/sctools/auto_preinst_rom/banner/sub_banner_v3.bsf
Normal file
BIN
build/tools/sctools/auto_preinst_rom/banner/sub_banner_v3.bsf
Normal file
Binary file not shown.
504
build/tools/sctools/auto_preinst_rom/src/main.c
Normal file
504
build/tools/sctools/auto_preinst_rom/src/main.c
Normal file
@ -0,0 +1,504 @@
|
||||
#include <twl.h>
|
||||
#include <nitro/nvram/nvram.h>
|
||||
#include <twl/sea.h>
|
||||
#include <twl/lcfg.h>
|
||||
#include <twl/na.h>
|
||||
#include <twl/nam.h>
|
||||
|
||||
#include "ecdl.h"
|
||||
|
||||
#include "font.h"
|
||||
#include "text.h"
|
||||
#include "mprintf.h"
|
||||
#include "gfx.h"
|
||||
#include "key.h"
|
||||
#include "my_fs_util.h"
|
||||
#include "hwi.h"
|
||||
#include "mydata.h"
|
||||
|
||||
#include "error_report.h"
|
||||
|
||||
#include "myfilename.h"
|
||||
|
||||
#include "pre_install.h"
|
||||
|
||||
#define THREAD_COMMAND_INSTALL_APP 1
|
||||
#define THREAD_COMMAND_INSTALL_TICKET 2
|
||||
#define THREAD_COMMAND_DELETE_APP_CONTENT 3
|
||||
#define THREAD_COMMAND_DELETE_APP_COMPLETELY 4
|
||||
|
||||
|
||||
static void init_my_thread(void);
|
||||
static BOOL start_my_thread(u32 command);
|
||||
|
||||
|
||||
static BOOL development_console_flag = FALSE;
|
||||
|
||||
static OSHeapHandle hHeap;
|
||||
static u32 allocator_total_size = 0;
|
||||
|
||||
static u8 org_region = 0;
|
||||
static u64 org_fuseId = 0;
|
||||
|
||||
static BOOL pushed_power_button = FALSE;
|
||||
static BOOL throw_pushed_power_button = FALSE;
|
||||
|
||||
static LCFGTWLHWNormalInfo hwn_info;
|
||||
static LCFGTWLHWSecureInfo hws_info;
|
||||
|
||||
static MyData mydata;
|
||||
|
||||
static int vram_num_main = 1;
|
||||
static int vram_num_sub = 0;
|
||||
|
||||
static u64 eticket_only_id_buf[100];
|
||||
static int eticket_only_id_count = 0;
|
||||
|
||||
static void fill_command(void)
|
||||
{
|
||||
if( development_console_flag == FALSE ) {
|
||||
/*
|
||||
0x00030004484e474a, 0 , 0 , rom:/tads/TWL-HNGJ-v256.tad,
|
||||
0x000300044b32444a, 0 , 0 , rom:/tads/TWL-K2DJ-v0.tad,
|
||||
0x000300044b47554a, 0 , 0 , rom:/tads/TWL-KGUJ-v257.tad,
|
||||
*/
|
||||
eticket_only_id_buf[0] = 0x00030004484e474a;
|
||||
eticket_only_id_buf[1] = 0x000300044b32444a;
|
||||
eticket_only_id_buf[2] = 0x000300044b47554a;
|
||||
eticket_only_id_count = 3;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
0x0003000434424e41, 0 , 0 , rom:/tads_dev/backupSample.tad,
|
||||
0x00030004344a4541, 0 , 0 , rom:/tads_dev/encodeSD.tad,
|
||||
0x0003000434534e41, 0 , 0 , rom:/tads_dev/nandAppSample.tad,
|
||||
*/
|
||||
eticket_only_id_buf[2] = 0x0003000434424e41;
|
||||
eticket_only_id_buf[1] = 0x00030004344a4541;
|
||||
eticket_only_id_buf[0] = 0x0003000434534e41;
|
||||
eticket_only_id_count = 3;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL myTWLCardCallback( void )
|
||||
{
|
||||
return FALSE; // means that not terminate.
|
||||
}
|
||||
|
||||
static PMExitCallbackInfo pmexitcallbackinfo;
|
||||
|
||||
static void pmexitcallback(void *arg)
|
||||
{
|
||||
#pragma unused(arg)
|
||||
/* 処理中(データ書き込み中)ならリセットをブロックしなければならない */
|
||||
pushed_power_button = TRUE;
|
||||
}
|
||||
|
||||
static void *AllocForNAM(size_t size)
|
||||
{
|
||||
OSIntrMode old = OS_DisableInterrupts();
|
||||
void* p = OS_Alloc(size);
|
||||
OS_RestoreInterrupts(old);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void FreeForNAM(void* ptr)
|
||||
{
|
||||
if( ptr != NULL ) {
|
||||
OSIntrMode old = OS_DisableInterrupts();
|
||||
OS_Free(ptr);
|
||||
OS_RestoreInterrupts(old);
|
||||
}
|
||||
}
|
||||
|
||||
void TwlMain(void)
|
||||
{
|
||||
int i;
|
||||
void* newArenaLo;
|
||||
u8 macAddress[6];
|
||||
ESError es_error_code;
|
||||
u16 keyData;
|
||||
int loop_counter = 0;
|
||||
RTCDate rtc_date;
|
||||
RTCTime rtc_time;
|
||||
u16 BatterylevelBuf = 0;
|
||||
BOOL isAcConnectedBuf = FALSE;
|
||||
|
||||
OS_Init();
|
||||
OS_InitThread();
|
||||
|
||||
OS_InitTick();
|
||||
OS_InitAlarm();
|
||||
// マスター割り込みフラグを許可に
|
||||
(void)OS_EnableIrq();
|
||||
|
||||
// IRQ 割り込みを許可します
|
||||
(void)OS_EnableInterrupts();
|
||||
|
||||
// ARM7との通信FIFO割り込み許可
|
||||
(void)OS_EnableIrqMask(OS_IE_SPFIFO_RECV);
|
||||
|
||||
// ファイルシステム初期化
|
||||
FS_Init( FS_DMA_NOT_USE );
|
||||
|
||||
PM_Init();
|
||||
// メインアリーナのアロケートシステムを初期化
|
||||
newArenaLo = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1);
|
||||
OS_SetMainArenaLo(newArenaLo);
|
||||
|
||||
// メインアリーナ上にヒープを作成
|
||||
hHeap = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi());
|
||||
OS_SetCurrentHeap(OS_ARENA_MAIN, hHeap);
|
||||
|
||||
allocator_total_size = OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap);
|
||||
|
||||
|
||||
Gfx_Init();
|
||||
|
||||
RTC_Init();
|
||||
|
||||
SCFG_Init();
|
||||
|
||||
NVRAMi_Init();
|
||||
|
||||
CARD_Init();
|
||||
CARD_SetPulledOutCallback( myTWLCardCallback );
|
||||
|
||||
// 必須;SEA の初期化
|
||||
SEA_Init();
|
||||
|
||||
|
||||
development_console_flag = IsThisDevelopmentConsole();
|
||||
if(TRUE == development_console_flag ) {
|
||||
mprintf("--development console--\n");
|
||||
}
|
||||
|
||||
PM_SetAutoExit( FALSE );
|
||||
PM_SetExitCallbackInfo( &pmexitcallbackinfo,pmexitcallback, NULL);
|
||||
PM_PrependPreExitCallback( &pmexitcallbackinfo );
|
||||
|
||||
|
||||
ES_InitLib();
|
||||
|
||||
|
||||
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("HW Normal Info. read error.\n");
|
||||
m_set_palette(tc[0], 0xF);
|
||||
}
|
||||
|
||||
// mprintf("HW Secure Info. read ");
|
||||
if( FALSE == MiyaReadHWSecureInfo( &hws_info ) ) {
|
||||
m_set_palette(tc[0], 0x1); /* red */
|
||||
mprintf("HW Secure Info. read error.\n");
|
||||
m_set_palette(tc[0], 0xF); /* white */
|
||||
}
|
||||
|
||||
|
||||
// ニックネームが空なら適当に設定
|
||||
if( *LCFG_TSD_GetNicknamePtr() == L'\0' ) {
|
||||
LCFG_TSD_SetNickname((const u16*)(L"repair-tool"));
|
||||
// mprintf("Set dummy Nickname\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// region
|
||||
org_region = LCFG_THW_GetRegion();
|
||||
// ES Device ID
|
||||
|
||||
// 国が選択されていないなら適当に設定
|
||||
if( LCFG_TSD_GetCountry() == LCFG_TWL_COUNTRY_UNDEFINED ) {
|
||||
|
||||
mprintf("Set dummy Country code ");
|
||||
|
||||
switch( org_region ) {
|
||||
case OS_TWL_REGION_JAPAN:
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_JAPAN);
|
||||
mprintf("JPN");
|
||||
break;
|
||||
case OS_TWL_REGION_AMERICA:
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_UNITED_STATES);
|
||||
mprintf("USA");
|
||||
break;
|
||||
case OS_TWL_REGION_EUROPE:
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_UNITED_KINGDOM);
|
||||
mprintf("UK");
|
||||
break;
|
||||
case OS_TWL_REGION_AUSTRALIA:
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_AUSTRALIA);
|
||||
mprintf("AUS");
|
||||
break;
|
||||
case OS_TWL_REGION_CHINA:
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_CHINA);
|
||||
mprintf("CHN");
|
||||
break;
|
||||
case OS_TWL_REGION_KOREA:
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_SOUTH_KOREA);
|
||||
mprintf("KOR");
|
||||
break;
|
||||
case OS_TWL_REGION_MAX:
|
||||
default:
|
||||
mprintf("JPN");
|
||||
LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_JAPAN);
|
||||
break;
|
||||
}
|
||||
mprintf("\n");
|
||||
}
|
||||
|
||||
|
||||
org_fuseId = SCFG_ReadFuseData();
|
||||
OS_TPrintf("eFuseID: %08X%08X\n", (u32)(org_fuseId >> 32), (u32)(org_fuseId));
|
||||
|
||||
OS_GetMacAddress( macAddress );
|
||||
|
||||
mydata.shop_record_flag = FALSE;
|
||||
es_error_code = ES_GetDeviceId(&mydata.deviceId);
|
||||
if( es_error_code == ES_ERR_OK ) {
|
||||
if( TRUE == CheckShopRecord( NULL ) ) {
|
||||
mydata.shop_record_flag = TRUE;
|
||||
}
|
||||
else {
|
||||
mprintf("no shop record\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
OS_TPrintf("es_error_code = %d\n", es_error_code );
|
||||
}
|
||||
|
||||
// NAM の初期化
|
||||
NAM_Init(&AllocForNAM, &FreeForNAM);
|
||||
|
||||
|
||||
init_my_thread();
|
||||
|
||||
|
||||
{
|
||||
double d;
|
||||
d = 0.1234567789;
|
||||
mprintf("test %f\n", d);
|
||||
}
|
||||
|
||||
|
||||
while( 1 ) {
|
||||
Gfx_Render( vram_num_main , vram_num_sub );
|
||||
OS_WaitVBlankIntr();
|
||||
(void)RTC_GetDate( &rtc_date );
|
||||
(void)RTC_GetTime( &rtc_time );
|
||||
|
||||
keyData = m_get_key_trigger();
|
||||
|
||||
if ( keyData & PAD_BUTTON_R ) {
|
||||
vram_num_main++;
|
||||
if( vram_num_main > (MAX_VRAM_NUM-1) ) {
|
||||
vram_num_main = 0;
|
||||
}
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_L ) {
|
||||
vram_num_main--;
|
||||
if( vram_num_main < 0 ) {
|
||||
vram_num_main = (MAX_VRAM_NUM-1);
|
||||
}
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_A ) {
|
||||
fill_command();
|
||||
(void)start_my_thread(THREAD_COMMAND_INSTALL_APP);
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_B ) {
|
||||
fill_command();
|
||||
(void)start_my_thread(THREAD_COMMAND_INSTALL_TICKET);
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_X ) {
|
||||
fill_command();
|
||||
(void)start_my_thread(THREAD_COMMAND_DELETE_APP_CONTENT);
|
||||
}
|
||||
else if ( keyData & PAD_BUTTON_Y ) {
|
||||
fill_command();
|
||||
(void)start_my_thread(THREAD_COMMAND_DELETE_APP_COMPLETELY);
|
||||
}
|
||||
|
||||
|
||||
mfprintf(tc[1], "\fAuto Pre-install Tool");
|
||||
|
||||
|
||||
/* ユニークIDは表示しなくていい? */
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mfprintf(tc[1], "Unique ID:\n");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
mfprintf(tc[1], " ");
|
||||
for( i = 0; i < LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN/2 ; i++ ) {
|
||||
mfprintf(tc[1], "%02X:", hwn_info.movableUniqueID[i]);
|
||||
}
|
||||
mfprintf(tc[1], "\n ");
|
||||
for( ; i < LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN ; i++ ) {
|
||||
mfprintf(tc[1], "%02X:", hwn_info.movableUniqueID[i]);
|
||||
}
|
||||
mfprintf(tc[1], "\n\n");
|
||||
|
||||
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mfprintf(tc[1], "Serial No. ");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
mfprintf(tc[1], "%s\n", hws_info.serialNo);
|
||||
mfprintf(tc[1], "\n");
|
||||
|
||||
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mfprintf(tc[1], "eFuse ID: ");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
mfprintf(tc[1],"%08X%08X\n\n", (u32)(org_fuseId >> 32), (u32)(org_fuseId));
|
||||
|
||||
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mfprintf(tc[1],"MAC add.: ");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
mfprintf(tc[1],"%02X:%02X:%02X:%02X:%02X:%02X", macAddress[0],macAddress[1],
|
||||
macAddress[2], macAddress[3], macAddress[4], macAddress[5]);
|
||||
mfprintf(tc[1],"\n\n");
|
||||
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_LIGHTBLUE );
|
||||
mfprintf(tc[1],"Device ID: ");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
|
||||
/* ここで mydata.shop_record_flag といっしょに */
|
||||
if( TRUE == mydata.shop_record_flag ) {
|
||||
mfprintf(tc[1],"%s\n", mydata.bmsDeviceId);
|
||||
}
|
||||
else {
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_YELLOW );
|
||||
mfprintf(tc[1],"-----------\n");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
mfprintf(tc[1],"\n");
|
||||
if( (loop_counter % 60*5) == 0 ) {
|
||||
// PM_RESULT_SUCCESS
|
||||
(void)PM_GetACAdapter( &isAcConnectedBuf );
|
||||
(void)PM_GetBatteryLevel( &BatterylevelBuf );
|
||||
}
|
||||
mfprintf(tc[1], "%4d/%02d/%02d %02d:%02d:%02d ",
|
||||
rtc_date.year + 2000, rtc_date.month , rtc_date.day,
|
||||
rtc_time.hour , rtc_time.minute , rtc_time.second );
|
||||
|
||||
if( isAcConnectedBuf == TRUE ) {
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_BLUE );
|
||||
mfprintf(tc[1], "AC. \n\n");
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
else {
|
||||
mfprintf(tc[1], "Batt.Lv ");
|
||||
switch( BatterylevelBuf ) {
|
||||
case 0:
|
||||
case 1:
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_RED );
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_YELLOW );
|
||||
break;
|
||||
default:
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_GREEN );
|
||||
break;
|
||||
}
|
||||
mfprintf(tc[1], "%d/5\n\n" , BatterylevelBuf);
|
||||
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
mfprintf(tc[1], "A -> Install App.\n");
|
||||
mfprintf(tc[1], "B -> Install Ticket\n");
|
||||
mfprintf(tc[1], "X -> Delete App. content\n");
|
||||
mfprintf(tc[1], "Y -> Delete App. completely\n");
|
||||
|
||||
if( pushed_power_button == TRUE ) {
|
||||
OS_TPrintf("%s Power button pressed!\n",__FUNCTION__);
|
||||
PM_ReadyToExit();
|
||||
pushed_power_button = FALSE;
|
||||
}
|
||||
|
||||
loop_counter++;
|
||||
}
|
||||
OS_Terminate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define MY_STACK_SIZE (1024*128) /* でかいほうがいい */
|
||||
//#define MY_THREAD_PRIO 20
|
||||
|
||||
#define MY_THREAD_PRIO 5
|
||||
|
||||
static OSThread MyThread;
|
||||
static u64 MyStack[MY_STACK_SIZE/sizeof(u64)];
|
||||
|
||||
static OSMessage MyMesgBuffer_request[1];
|
||||
static OSMessage MyMesgBuffer_response[1];
|
||||
static OSMessageQueue MyMesgQueue_request;
|
||||
static OSMessageQueue MyMesgQueue_response;
|
||||
|
||||
static void MyThreadProc(void *arg)
|
||||
{
|
||||
#pragma unused(arg)
|
||||
OSMessage message;
|
||||
BOOL flag;
|
||||
u32 command;
|
||||
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
while( 1 ) {
|
||||
// (void)pre_install_process( NULL, NULL, 0, NULL, 0 , development_console_flag);
|
||||
|
||||
(void)OS_SendMessage(&MyMesgQueue_response, (OSMessage)0, OS_MESSAGE_NOBLOCK);
|
||||
(void)OS_ReceiveMessage(&MyMesgQueue_request, &message, OS_MESSAGE_BLOCK);
|
||||
flag = TRUE;
|
||||
command = (u32)message;
|
||||
switch( command ) {
|
||||
case THREAD_COMMAND_INSTALL_APP:
|
||||
flag = pre_install_command(NULL, eticket_only_id_buf, eticket_only_id_count,
|
||||
1, development_console_flag );
|
||||
break;
|
||||
case THREAD_COMMAND_INSTALL_TICKET:
|
||||
flag = pre_install_command(NULL, eticket_only_id_buf, eticket_only_id_count,
|
||||
2, development_console_flag );
|
||||
break;
|
||||
case THREAD_COMMAND_DELETE_APP_CONTENT:
|
||||
flag = pre_install_command(NULL, eticket_only_id_buf, eticket_only_id_count,
|
||||
3, development_console_flag );
|
||||
break;
|
||||
case THREAD_COMMAND_DELETE_APP_COMPLETELY:
|
||||
flag = pre_install_command(NULL, eticket_only_id_buf, eticket_only_id_count,
|
||||
4, development_console_flag );
|
||||
break;
|
||||
default:
|
||||
flag = FALSE;
|
||||
mprintf("%s unknown command!\n",__FUNCTION__);
|
||||
break;
|
||||
}
|
||||
mprintf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void init_my_thread(void)
|
||||
{
|
||||
OS_InitMessageQueue(&MyMesgQueue_request, &MyMesgBuffer_request[0], 1);
|
||||
OS_InitMessageQueue(&MyMesgQueue_response, &MyMesgBuffer_response[0], 1);
|
||||
|
||||
OS_CreateThread(&MyThread, MyThreadProc,
|
||||
NULL, MyStack + MY_STACK_SIZE /sizeof(u64),
|
||||
MY_STACK_SIZE, MY_THREAD_PRIO);
|
||||
OS_WakeupThreadDirect(&MyThread);
|
||||
}
|
||||
|
||||
|
||||
static BOOL start_my_thread(u32 command)
|
||||
{
|
||||
OSMessage message;
|
||||
if( TRUE == OS_ReceiveMessage(&MyMesgQueue_response, &message, OS_MESSAGE_NOBLOCK) ) {
|
||||
(void)OS_SendMessage(&MyMesgQueue_request, (OSMessage)command, OS_MESSAGE_BLOCK);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -11,10 +11,9 @@
|
||||
#define __std(ref) ref
|
||||
// #define __std(ref) ::std::ref
|
||||
|
||||
#include <twl.h>
|
||||
#include "text.h"
|
||||
#include "mprintf.h"
|
||||
#include "logprintf.h"
|
||||
#define size_t my_size_t
|
||||
|
||||
typedef signed long my_size_t;
|
||||
|
||||
#define __fourbytealign(n) ((((unsigned long) (n)) + 3U) & ~3U)
|
||||
#define __va_start(parm) ((__std(va_list)) ((char*) ((unsigned long)(&parm) & ~3U) + __fourbytealign(sizeof(parm))))
|
||||
@ -153,15 +152,7 @@ static void miya_Litob(_Pft *, char);
|
||||
#endif
|
||||
|
||||
#define ISDIGIT(c) ((c >= '0') && (c <= '9'))
|
||||
#define MAX_PAD (sizeof(spaces) - 1)
|
||||
#define PAD(s, n) \
|
||||
if (0 < (n)) { \
|
||||
int i, j = (n); \
|
||||
for (; 0 < j; j -= i) { \
|
||||
i = MAX_PAD < j ? MAX_PAD : j; \
|
||||
PUT(s, i); \
|
||||
} \
|
||||
}
|
||||
|
||||
#if 0 // miyamoto
|
||||
#define PUT(s, n) \
|
||||
if( len > n ) {\
|
||||
@ -186,10 +177,22 @@ static void miya_Litob(_Pft *, char);
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
return (x.nchar); \
|
||||
return (x.nchar); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define MAX_PAD (sizeof(spaces) - 1)
|
||||
#define PAD(s, n) \
|
||||
if (0 < (n)) { \
|
||||
int i, j = (n); \
|
||||
for (; 0 < j; j -= i) { \
|
||||
i = MAX_PAD < j ? (int)MAX_PAD : j; \
|
||||
PUT(s, i); \
|
||||
} \
|
||||
}
|
||||
|
||||
static char spaces[] = " ";
|
||||
static char zeroes[] = "00000000000000000000000000000000";
|
||||
|
||||
@ -243,7 +246,7 @@ static int _Printf(void *(*pfn)(void *, const char *, size_t),
|
||||
}
|
||||
--s;
|
||||
#if 1
|
||||
PUT(fmt, s - fmt);
|
||||
PUT(fmt, (s - fmt));
|
||||
#else
|
||||
if (0 < (s-fmt)) {
|
||||
if ((arg = (*pfn)(arg, fmt, s-fmt)) != NULL)
|
||||
@ -258,7 +261,7 @@ static int _Printf(void *(*pfn)(void *, const char *, size_t),
|
||||
|
||||
#endif
|
||||
if (c == '\0')
|
||||
return (x.nchar);
|
||||
return (int)(x.nchar);
|
||||
fmt = ++s;
|
||||
|
||||
/* parse a conversion specifier */
|
||||
@ -391,7 +394,7 @@ static void _Putfld(_Pft *px, va_list *pap, char code, char *ac)
|
||||
break;
|
||||
case 's': /* convert a string */
|
||||
px->s = va_arg(*pap, char *);
|
||||
px->n1 = strlen(px->s);
|
||||
px->n1 = (int)strlen(px->s);
|
||||
if (0 <= px->prec && px->prec < px->n1)
|
||||
px->n1 = px->prec;
|
||||
break;
|
||||
@ -445,20 +448,20 @@ static void miya_Litob(_Pft *px, char code)
|
||||
char *digs = code == 'X' ? udigs : ldigs;
|
||||
int base = code == 'o' ? 8 : code != 'x' && code != 'X' ? 10 : 16;
|
||||
int i = sizeof(ac);
|
||||
unsigned long long ullval = px->v.ll;
|
||||
unsigned long long ullval = (unsigned long long)(px->v.ll);
|
||||
|
||||
if ((code == 'd' || code == 'i') && px->v.ll < 0)
|
||||
ullval = -ullval; /* safe against overflow */
|
||||
if (ullval || px->prec)
|
||||
ac[--i] = digs[ullval % base];
|
||||
px->v.ll = ullval / base;
|
||||
px->v.ll = (long long)(ullval / base);
|
||||
while (0 < px->v.ll && 0 < i) { /* convert digits */
|
||||
miya_lldiv_t qr = miya_lldiv(px->v.ll, (long long) base);
|
||||
|
||||
px->v.ll = qr.quot;
|
||||
ac[--i] = digs[qr.rem];
|
||||
}
|
||||
px->n1 = sizeof(ac) - i;
|
||||
px->n1 = (int)sizeof(ac) - i;
|
||||
(void)my_memcpy(px->s, &ac[i], px->n1);
|
||||
if (px->n1 < px->prec)
|
||||
px->nz0 = px->prec - px->n1;
|
||||
@ -686,7 +689,7 @@ static short _Ldunscale(short *pex, ldouble *px)
|
||||
_NAN : INF);
|
||||
} else if (0 < xchar /* || (xchar = _Dnorm(ps)) != 0 */) {
|
||||
/* finite, reduce to [1/2, 1) */
|
||||
ps[_D0] = (short)(ps[_D0] & ~_DMASK | _DBIAS << _DOFF);
|
||||
ps[_D0] = (unsigned short)(ps[_D0] & ~_DMASK | _DBIAS << _DOFF);
|
||||
#if _LONG_DOUBLE
|
||||
*pex = (short)(xchar - _DBIAS);
|
||||
#else
|
||||
|
||||
@ -27,6 +27,10 @@
|
||||
#include "text.h"
|
||||
#include "mprintf.h"
|
||||
|
||||
#define size_t my_size_t
|
||||
typedef signed long my_size_t;
|
||||
|
||||
|
||||
#define CODE32
|
||||
|
||||
|
||||
@ -68,7 +72,7 @@ static void *memcpy(void *dest, const void *src, size_t n)
|
||||
unsigned char *ss = (unsigned char *)src;
|
||||
|
||||
while(n--) {
|
||||
My_WriteByte( s++,My_ReadByte(ss++));
|
||||
*s++ = *ss++ ;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
@ -78,7 +82,7 @@ static void *memcpy(void *dest, const void *src, size_t n)
|
||||
static const char *strchr(const char *s,int c)
|
||||
{
|
||||
int a;
|
||||
while( (a = (int)My_ReadByte(s)) != NULL ) {
|
||||
while( (a = (int)*s) != NULL ) {
|
||||
if(a == c)
|
||||
return s;
|
||||
s++;
|
||||
@ -89,7 +93,7 @@ static const char *strchr(const char *s,int c)
|
||||
static size_t strlen(const char *s)
|
||||
{
|
||||
size_t n=0;
|
||||
while( My_ReadByte(s) != NULL) {
|
||||
while( *s != NULL) {
|
||||
n++;
|
||||
s++;
|
||||
}
|
||||
@ -110,7 +114,7 @@ static void *proutPrintf(void *txb, const char *buf, size_t n)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
MIYA_PUTCHAR( txb, My_ReadByte(&(buf[i])));
|
||||
MIYA_PUTCHAR( txb, buf[i]);
|
||||
/* return a fake pointer so that it's not NULL */
|
||||
return ((void *)txb);
|
||||
}
|
||||
@ -206,7 +210,7 @@ static void miya_Litob(_Pft *, char);
|
||||
if (0 < (n)) { \
|
||||
int i, j = (n); \
|
||||
for (; 0 < j; j -= i) { \
|
||||
i = MAX_PAD < j ? MAX_PAD : j; \
|
||||
i = MAX_PAD < j ? (int)MAX_PAD : j; \
|
||||
PUT(s, i); \
|
||||
} \
|
||||
}
|
||||
@ -270,7 +274,7 @@ static int _Printf(void *(*pfn)(void *, const char *, size_t),
|
||||
|
||||
/* copy any literal text */
|
||||
|
||||
while ( (0 < (c = (int)My_ReadByte(s++)) ) && (c != '%')) {
|
||||
while ( (0 < (c = (int)*s++) ) && (c != '%')) {
|
||||
}
|
||||
--s;
|
||||
#if 1
|
||||
@ -291,7 +295,7 @@ static int _Printf(void *(*pfn)(void *, const char *, size_t),
|
||||
/* parse a conversion specifier */
|
||||
for (x.flags = 0; (t = strchr(fchar, *s)) != NULL; ++s)
|
||||
x.flags |= fbit[t - fchar];
|
||||
if (My_ReadByte(s) == '*') { /* get width argument */
|
||||
if ( *s == '*') { /* get width argument */
|
||||
x.width = va_arg(ap, int);
|
||||
if (x.width < 0) { /* same as '-' flag */
|
||||
x.width = -x.width;
|
||||
@ -302,24 +306,23 @@ static int _Printf(void *(*pfn)(void *, const char *, size_t),
|
||||
for (x.width = 0; ISDIGIT((int)*s); ++s)
|
||||
if (x.width < _WMAX)
|
||||
x.width = x.width * 10 + *s - '0';
|
||||
if (My_ReadByte(s) != '.')
|
||||
if ( *s != '.')
|
||||
x.prec = -1;
|
||||
else if ( My_ReadByte(++s) == '*') { /* get precision argument */
|
||||
else if ( *++s == '*') { /* get precision argument */
|
||||
x.prec = va_arg(ap, int);
|
||||
++s;
|
||||
} else /* accumulate precision digits */
|
||||
for (x.prec = 0; ISDIGIT(*s); ++s)
|
||||
if (x.prec < _WMAX)
|
||||
x.prec = x.prec * 10 + *s - '0';
|
||||
My_WriteByte(&(x.qual),
|
||||
(char)(strchr("hlL", My_ReadByte(s)) ? My_ReadByte(s++) : '\0'));
|
||||
if ((My_ReadByte(&(x.qual)) == 'l') && (My_ReadByte(s) == 'l')) {
|
||||
My_WriteByte(&(x.qual), 'L'); /* the %ll qualifier */
|
||||
x.qual = (char)(strchr("hlL", *s) ? *s++ : '\0');
|
||||
if( (x.qual == 'l') && ( *s == 'l')) {
|
||||
x.qual= 'L'; /* the %ll qualifier */
|
||||
s++;
|
||||
}
|
||||
|
||||
/* do the conversion */
|
||||
_Putfld(&x, &ap, My_ReadByte(s), ac);
|
||||
_Putfld(&x, &ap, *s, ac);
|
||||
x.width -= x.n0 + x.nz0 + x.n1 + x.nz1 + x.n2 + x.nz2;
|
||||
if (!(x.flags & _FMI))
|
||||
PAD(spaces, x.width);
|
||||
@ -337,6 +340,104 @@ static int _Printf(void *(*pfn)(void *, const char *, size_t),
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
static void _Putfld(_Pft *px, va_list *pap, char code, char *ac)
|
||||
{ /* convert a field for _Printf */
|
||||
|
||||
px->n0 = px->nz0 = px->n1 = px->nz1 = px->n2 = px->nz2 = 0;
|
||||
switch (code) { /* switch on conversion specifier */
|
||||
case 'c':
|
||||
ac[px->n0++] = (char)va_arg(*pap, int);
|
||||
break;
|
||||
case 'd':
|
||||
case 'i': /* convert a signed decimal integer */
|
||||
if (px->qual == 'l')
|
||||
px->v.ll = va_arg(*pap, long);
|
||||
else if (px->qual == 'L')
|
||||
px->v.ll = va_arg(*pap, long long);
|
||||
else
|
||||
px->v.ll = va_arg(*pap, int);
|
||||
if ( px->qual == 'h')
|
||||
px->v.ll = (short) px->v.ll;
|
||||
if (px->v.ll < 0) /* negate safely in miya_Litob */
|
||||
ac[px->n0++] = '-';
|
||||
else if (px->flags & _FPL)
|
||||
ac[px->n0++] = '+';
|
||||
else if (px->flags & _FSP)
|
||||
ac[px->n0++] = ' ';
|
||||
px->s = &ac[px->n0];
|
||||
miya_Litob(px, code);
|
||||
break;
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X': /* convert unsigned */
|
||||
if (px->qual == 'l')
|
||||
px->v.ll = va_arg(*pap, long);
|
||||
else if (px->qual == 'L')
|
||||
px->v.ll = va_arg(*pap, long long);
|
||||
else
|
||||
px->v.ll = va_arg(*pap, int);
|
||||
if (px->qual == 'h')
|
||||
px->v.ll = (unsigned short) px->v.ll;
|
||||
else if (px->qual == '\0')
|
||||
px->v.ll = (unsigned int) px->v.ll;
|
||||
if (px->flags & _FNO) { /* indicate base with prefix */
|
||||
ac[px->n0++] = '0';
|
||||
if (code == 'x' || code == 'X')
|
||||
ac[px->n0++] = code;
|
||||
}
|
||||
px->s = &ac[px->n0];
|
||||
miya_Litob(px, code);
|
||||
break;
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G': /* convert floating */
|
||||
px->v.ld = px->qual == 'L' ?
|
||||
va_arg(*pap, ldouble) : va_arg(*pap, double);
|
||||
if (LDSIGN(px->v.ld))
|
||||
ac[px->n0++] = '-';
|
||||
else if (px->flags & _FPL)
|
||||
ac[px->n0++] = '+';
|
||||
else if (px->flags & _FSP)
|
||||
ac[px->n0++] = ' ';
|
||||
px->s = &ac[px->n0];
|
||||
miya_Ldtob(px, code);
|
||||
break;
|
||||
case 'n': /* return output count */
|
||||
if (px->qual == 'h')
|
||||
*va_arg(*pap, short *) = (short)(px->nchar);
|
||||
else if (px->qual == 'l')
|
||||
*va_arg(*pap, long *) = px->nchar;
|
||||
else if (px->qual == 'L')
|
||||
*va_arg(*pap, long long *) = px->nchar;
|
||||
else
|
||||
*va_arg(*pap, int *) = px->nchar;
|
||||
break;
|
||||
case 'p': /* convert a pointer, hex long version */
|
||||
px->v.ll = (long) va_arg(*pap, void *);
|
||||
px->s = &ac[px->n0];
|
||||
miya_Litob(px, 'x');
|
||||
break;
|
||||
case 's': /* convert a string */
|
||||
px->s = va_arg(*pap, char *);
|
||||
px->n1 = (int)strlen(px->s);
|
||||
if (0 <= px->prec && px->prec < px->n1)
|
||||
px->n1 = px->prec;
|
||||
break;
|
||||
case '%': /* put a '%' */
|
||||
ac[px->n0++] = '%';
|
||||
break;
|
||||
default: /* undefined specifier, print it out */
|
||||
ac[px->n0++] = code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
static void _Putfld(_Pft *px, va_list *pap, char code, char *ac)
|
||||
{ /* convert a field for _Printf */
|
||||
|
||||
@ -353,14 +454,14 @@ static void _Putfld(_Pft *px, va_list *pap, char code, char *ac)
|
||||
px->v.ll = va_arg(*pap, long long);
|
||||
else
|
||||
px->v.ll = va_arg(*pap, int);
|
||||
if (My_ReadByte(&(px->qual)) == 'h')
|
||||
if (px->qual == 'h')
|
||||
px->v.ll = (short) px->v.ll;
|
||||
if (px->v.ll < 0) /* negate safely in miya_Litob */
|
||||
My_WriteByte(&(ac[px->n0++]), '-');
|
||||
ac[px->n0++] = '-';
|
||||
else if (px->flags & _FPL)
|
||||
My_WriteByte(&(ac[px->n0++]),'+');
|
||||
ac[px->n0++] = '+';
|
||||
else if (px->flags & _FSP)
|
||||
My_WriteByte(&(ac[px->n0++]),' ');
|
||||
ac[px->n0++] = ' ';
|
||||
px->s = &ac[px->n0];
|
||||
miya_Litob(px, code);
|
||||
break;
|
||||
@ -431,7 +532,7 @@ static void _Putfld(_Pft *px, va_list *pap, char code, char *ac)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/*****************************************************************/
|
||||
|
||||
/* miya_Litob function */
|
||||
@ -473,20 +574,21 @@ static void miya_Litob(_Pft *px, char code)
|
||||
char *digs = code == 'X' ? udigs : ldigs;
|
||||
int base = code == 'o' ? 8 : code != 'x' && code != 'X' ? 10 : 16;
|
||||
int i = sizeof(ac);
|
||||
unsigned long long ullval = px->v.ll;
|
||||
unsigned long long ullval = (unsigned long long)(px->v.ll);
|
||||
|
||||
if ((code == 'd' || code == 'i') && px->v.ll < 0)
|
||||
ullval = -ullval; /* safe against overflow */
|
||||
if (ullval || px->prec)
|
||||
My_WriteByte(&(ac[--i]), My_ReadByte(&(digs[ullval % base])));
|
||||
px->v.ll = ullval / base;
|
||||
ac[--i] = digs[ullval % base];
|
||||
px->v.ll = (long long)(ullval / base);
|
||||
while (0 < px->v.ll && 0 < i) { /* convert digits */
|
||||
miya_lldiv_t qr = miya_lldiv(px->v.ll, (long long) base);
|
||||
|
||||
px->v.ll = qr.quot;
|
||||
My_WriteByte(&(ac[--i]), My_ReadByte(&(digs[qr.rem])));
|
||||
ac[--i] = digs[qr.rem];
|
||||
}
|
||||
px->n1 = sizeof(ac) - i;
|
||||
px->n1 = (int)sizeof(ac) - i;
|
||||
|
||||
(void)memcpy(px->s, &ac[i], px->n1);
|
||||
if (px->n1 < px->prec)
|
||||
px->nz0 = px->prec - px->n1;
|
||||
@ -519,6 +621,107 @@ static const ldouble pows[] = {
|
||||
static short _Ldunscale(short *, ldouble *);
|
||||
static void _Genld(_Pft *, char, char *, short, short);
|
||||
|
||||
#if 1
|
||||
static void miya_Ldtob(_Pft *px, char code)
|
||||
{ /* convert long double to text */
|
||||
char ac[32];
|
||||
char *p = ac;
|
||||
ldouble ldval = px->v.ld;
|
||||
short errx, nsig, xexp;
|
||||
|
||||
if (px->prec < 0)
|
||||
px->prec = 6;
|
||||
else if (px->prec == 0 && (code == 'g' || code == 'G'))
|
||||
px->prec = 1;
|
||||
if (0 < (errx = _Ldunscale(&xexp, &px->v.ld))) {
|
||||
/* x == Nan, x == INF */
|
||||
// (void)memcpy(px->s, errx == _NAN ? "NaN" : "Inf", px->n1 = 3);
|
||||
(void)memcpy(px->s, errx == NAN ? "NaN" : "Inf", px->n1 = 3);
|
||||
return;
|
||||
} else if (0 == errx) /*x == 0 */
|
||||
nsig = 0, xexp = 0;
|
||||
else { /* 0 < |x|, convert it */
|
||||
{ /* scale ldval to ~~10^(NDIG/2) */
|
||||
int i, n;
|
||||
|
||||
if (ldval < 0.0)
|
||||
ldval = -ldval;
|
||||
if ((xexp = (short)(xexp * 30103L / 100000L - NDIG/2)) < 0) {
|
||||
/* scale up */
|
||||
n = (-xexp + (NDIG/2-1)) & ~(NDIG/2-1), xexp = (short)(-n);
|
||||
for (i = 0; 0 < n; n >>= 1, ++i)
|
||||
if (n & 1)
|
||||
ldval *= pows[i];
|
||||
} else if (0 < xexp) { /* scale down */
|
||||
ldouble factor = 1.0;
|
||||
|
||||
xexp &= ~(NDIG/2-1);
|
||||
for (n = xexp, i = 0; 0 < n; n >>= 1, ++i)
|
||||
if (n & 1)
|
||||
factor *= pows[i];
|
||||
ldval /= factor;
|
||||
}
|
||||
}
|
||||
{ /* convert significant digits */
|
||||
int gen = px->prec +
|
||||
(code == 'f' ? xexp + 2 + NDIG : 2 + NDIG / 2);
|
||||
|
||||
if (LDBL_DIG + NDIG / 2 < gen)
|
||||
gen = LDBL_DIG + NDIG / 2;
|
||||
for ( *p++ = '0' ; 0 < gen && 0.0 < ldval; p += NDIG) {
|
||||
/* convert NDIG at a time */
|
||||
int j;
|
||||
long lo = (long) ldval;
|
||||
|
||||
if (0 < (gen -= NDIG))
|
||||
ldval = (ldval - (ldouble) lo) * 1e8L;
|
||||
for (p += NDIG, j = NDIG; 0 < lo && 0 <= --j; ) {
|
||||
/* convert NDIG digits */
|
||||
miya_ldiv_t qr;
|
||||
|
||||
qr = miya_ldiv(lo, 10);
|
||||
*--p = (char)(qr.rem + '0'), lo = qr.quot;
|
||||
}
|
||||
while (0 <= --j)
|
||||
*--p = '0';
|
||||
}
|
||||
gen = p - &ac[1];
|
||||
for (p = &ac[1], xexp += NDIG - 1; *p == '0'; ++p)
|
||||
--gen, --xexp; /* correct xexp */
|
||||
|
||||
/* miya
|
||||
char code
|
||||
int prec
|
||||
short nsig, xexp;
|
||||
*/
|
||||
nsig = (short)(px->prec + (code == 'f' ? xexp + 1 :
|
||||
code == 'e' || code == 'E' ? 1 : 0));
|
||||
if (gen < nsig)
|
||||
nsig = (short)gen;
|
||||
if (0 < nsig) { /* round and strip trailing zeros */
|
||||
/* const char drop; */
|
||||
char drop;
|
||||
int n;
|
||||
drop = (char)(nsig < gen && '5' <= p[nsig] ? '9' : '0');
|
||||
|
||||
for (n = nsig; p[--n] == drop; )
|
||||
--nsig;
|
||||
|
||||
if ( drop == '9') {
|
||||
p[n] = *(&(p[n])+1);
|
||||
|
||||
// ++p[n];
|
||||
}
|
||||
if (n < 0)
|
||||
--p, ++nsig, ++xexp;
|
||||
}
|
||||
}
|
||||
}
|
||||
_Genld(px, code, p, nsig, xexp);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void miya_Ldtob(_Pft *px, char code)
|
||||
{ /* convert long double to text */
|
||||
char ac[32];
|
||||
@ -582,7 +785,7 @@ static void miya_Ldtob(_Pft *px, char code)
|
||||
My_WriteByte(--p , '0');
|
||||
}
|
||||
gen = p - &ac[1];
|
||||
for (p = &ac[1], xexp += NDIG - 1; My_ReadByte(p) == '0'; ++p)
|
||||
for (p = &ac[1], xexp += NDIG - 1; *p == '0'; ++p)
|
||||
--gen, --xexp; /* correct xexp */
|
||||
|
||||
/* miya
|
||||
@ -595,17 +798,15 @@ static void miya_Ldtob(_Pft *px, char code)
|
||||
if (gen < nsig)
|
||||
nsig = (short)gen;
|
||||
if (0 < nsig) { /* round and strip trailing zeros */
|
||||
const char drop;
|
||||
char drop;
|
||||
int n;
|
||||
My_WriteByte((void *)&drop, (char)(nsig < gen && '5' <= My_ReadByte(&(p[nsig])) ? '9' : '0') );
|
||||
drop = (char)(nsig < gen && '5' <= p[nsig] ? '9' : '0');
|
||||
|
||||
for (n = nsig; My_ReadByte(&(p[--n])) == My_ReadByte(&drop); )
|
||||
for (n = nsig; p[--n] == drop; )
|
||||
--nsig;
|
||||
|
||||
if (My_ReadByte(&drop) == '9') {
|
||||
My_WriteByte(&(p[n]), My_ReadByte(&(p[n])+1));
|
||||
|
||||
// ++p[n];
|
||||
if ( drop == '9') {
|
||||
++p[n];
|
||||
}
|
||||
if (n < 0)
|
||||
--p, ++nsig, ++xexp;
|
||||
@ -614,6 +815,7 @@ static void miya_Ldtob(_Pft *px, char code)
|
||||
}
|
||||
_Genld(px, code, p, nsig, xexp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _DLONG /* 10-byte IEEE format */
|
||||
#define _LMASK 0x7fff
|
||||
@ -713,7 +915,7 @@ static short _Ldunscale(short *pex, ldouble *px)
|
||||
NAN : INF);
|
||||
} else if (0 < xchar /* || (xchar = _Dnorm(ps)) != 0 */) {
|
||||
/* finite, reduce to [1/2, 1) */
|
||||
ps[_D0] = (short)(ps[_D0] & ~_DMASK | _DBIAS << _DOFF);
|
||||
ps[_D0] = (unsigned short)(ps[_D0] & ~_DMASK | _DBIAS << _DOFF);
|
||||
#if _LONG_DOUBLE
|
||||
*pex = (short)(xchar - _DBIAS);
|
||||
#else
|
||||
@ -730,6 +932,99 @@ static short _Ldunscale(short *pex, ldouble *px)
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
static void _Genld(_Pft *px, char code, char *p, short nsig, short xexp)
|
||||
{ /* generate long double text */
|
||||
const char point = '.';
|
||||
|
||||
if (nsig <= 0)
|
||||
nsig = 1, p = "0";
|
||||
if (code == 'f' || (code == 'g' || code == 'G') &&
|
||||
-4 <= xexp && xexp < px->prec) { /* 'f' format */
|
||||
++xexp; /* change to leading digit count */
|
||||
if (code != 'f') { /* fixup for 'g' */
|
||||
if (!(px->flags & _FNO) && nsig < px->prec)
|
||||
px->prec = nsig;
|
||||
if ((px->prec -= xexp) < 0)
|
||||
px->prec = 0;
|
||||
}
|
||||
if (xexp <= 0) { /* digits only to right of point */
|
||||
px->s[px->n1++] = '0';
|
||||
|
||||
if (0 < px->prec || px->flags & _FNO)
|
||||
px->s[px->n1++] = point;
|
||||
if (px->prec < -xexp)
|
||||
xexp = (short)(-px->prec);
|
||||
px->nz1 = -xexp;
|
||||
px->prec += xexp;
|
||||
if (px->prec < nsig)
|
||||
nsig = (short)(px->prec);
|
||||
(void)memcpy(&px->s[px->n1], p, px->n2 = nsig);
|
||||
px->nz2 = px->prec - nsig;
|
||||
} else if (nsig < xexp) { /* zeros before point */
|
||||
(void)memcpy(&px->s[px->n1], p, nsig);
|
||||
px->n1 += nsig;
|
||||
px->nz1 = xexp - nsig;
|
||||
if (0 < px->prec || px->flags & _FNO)
|
||||
px->s[px->n1] = point, ++px->n2;
|
||||
px->nz2 = px->prec;
|
||||
} else { /* enough digits before point */
|
||||
(void)memcpy(&px->s[px->n1], p, xexp);
|
||||
px->n1 += xexp;
|
||||
nsig -= xexp;
|
||||
if (0 < px->prec || px->flags & _FNO)
|
||||
px->s[px->n1++] = point;
|
||||
if (px->prec < nsig)
|
||||
nsig = (short)(px->prec);
|
||||
(void)memcpy(&px->s[px->n1], p + xexp, nsig);
|
||||
px->n1 += nsig;
|
||||
px->nz1 = px->prec - nsig;
|
||||
}
|
||||
} else { /* 'e' format */
|
||||
if (code == 'g' || code == 'G') { /* fixup for 'g' */
|
||||
if (nsig < px->prec)
|
||||
px->prec = nsig;
|
||||
if (--px->prec < 0)
|
||||
px->prec = 0;
|
||||
code = (char)(code == 'g' ? 'e' : 'E');
|
||||
}
|
||||
px->s[px->n1++] = *p++;
|
||||
if (0 < px->prec || px->flags & _FNO)
|
||||
px->s[px->n1++] = point;
|
||||
if (0 < px->prec) { /* put fraction digits */
|
||||
if (px->prec < --nsig)
|
||||
nsig = (short)(px->prec);
|
||||
(void)memcpy(&px->s[px->n1], p, nsig);
|
||||
px->n1 += nsig;
|
||||
px->nz1 = px->prec - nsig;
|
||||
}
|
||||
p = &px->s[px->n1]; /* put exponent */
|
||||
*p++ = code;
|
||||
if (0 <= xexp)
|
||||
*p++ = '+';
|
||||
else { /* negative exponent */
|
||||
*p++ = '-';
|
||||
xexp = (short)(-xexp);
|
||||
}
|
||||
if (100 <= xexp) { /* put oversize exponent */
|
||||
if (1000 <= xexp)
|
||||
*p = (char)(xexp / 1000 + '0'), p++, xexp %= 1000;
|
||||
*p = (char)(xexp / 100 + '0'), p++, xexp %= 100;
|
||||
}
|
||||
*p = (char)(xexp / 10 + '0'),p++, xexp %= 10;
|
||||
*p = (char)(xexp + '0'); p++;
|
||||
px->n2 = p - &px->s[px->n1];
|
||||
}
|
||||
if ((px->flags & (_FMI | _FZE)) == _FZE) { /* pad with leading zeros */
|
||||
int n = px->n0 + px->n1 + px->nz1 + px->n2 + px->nz2;
|
||||
|
||||
if (n < px->width)
|
||||
px->nz0 = px->width - n;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void _Genld(_Pft *px, char code, char *p, short nsig, short xexp)
|
||||
{ /* generate long double text */
|
||||
const char point = '.';
|
||||
@ -820,3 +1115,4 @@ static void _Genld(_Pft *px, char code, char *p, short nsig, short xexp)
|
||||
px->nz0 = px->width - n;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2182,11 +2182,8 @@ BOOL TitleIDLoad(const char *path, MY_USER_APP_TID **pBuffer, int *count, char *
|
||||
return ret_flag;
|
||||
}
|
||||
|
||||
// BOOL TitleIDSave(const char *path, u64 *pData, int count, char *log_file_name )
|
||||
BOOL TitleIDSave(const char *path, MY_USER_APP_TID *pData, int count, char *log_file_name )
|
||||
|
||||
{
|
||||
|
||||
FSFile f;
|
||||
BOOL bSuccess;
|
||||
FSResult res;
|
||||
@ -2210,6 +2207,19 @@ BOOL TitleIDSave(const char *path, MY_USER_APP_TID *pData, int count, char *log_
|
||||
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
|
||||
|
||||
|
||||
if( count < 1 ) {
|
||||
miya_log_fprintf(log_fd, "%s path=%s count=%d pData=0x%08x\n", __FUNCTION__,path,count, pData );
|
||||
goto function_end;
|
||||
}
|
||||
if( path == NULL ) {
|
||||
miya_log_fprintf(log_fd, "%s path=%s count=%d pData=0x%08x\n", __FUNCTION__,path,count, pData );
|
||||
goto function_end;
|
||||
}
|
||||
if( pData == NULL ) {
|
||||
miya_log_fprintf(log_fd, "%s path=%s count=%d pData=0x%08x\n", __FUNCTION__,path,count, pData );
|
||||
goto function_end;
|
||||
}
|
||||
|
||||
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_W);
|
||||
if( ! bSuccess ) {
|
||||
FS_CreateFileAuto( path, FS_PERMIT_W|FS_PERMIT_R);
|
||||
@ -2297,6 +2307,181 @@ BOOL TitleIDSave(const char *path, MY_USER_APP_TID *pData, int count, char *log_
|
||||
|
||||
}
|
||||
|
||||
BOOL TitleIDLoadETicketOnly(const char *path, u64 **pBuffer, int *count, char *log_file_name)
|
||||
{
|
||||
FSFile f;
|
||||
BOOL bSuccess;
|
||||
// u32 fileSize;
|
||||
s32 readSize = 0;
|
||||
int id_count= 0;
|
||||
int size;
|
||||
BOOL log_active = FALSE;
|
||||
FSFile *log_fd;
|
||||
FSFile log_fd_real;
|
||||
BOOL ret_flag = TRUE;
|
||||
|
||||
log_fd = &log_fd_real;
|
||||
|
||||
FS_InitFile(&f);
|
||||
|
||||
log_active = Log_File_Open( log_fd, log_file_name );
|
||||
if( !log_active ) {
|
||||
log_fd = NULL;
|
||||
}
|
||||
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
|
||||
|
||||
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_R);
|
||||
if( ! bSuccess ) {
|
||||
miya_log_fprintf(log_fd, "Failed Open File %s\n",__FUNCTION__);
|
||||
miya_log_fprintf(log_fd, " path=%s\n", path );
|
||||
miya_log_fprintf(log_fd, " res=%s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path) ));
|
||||
ret_flag = FALSE;
|
||||
goto function_end;
|
||||
}
|
||||
|
||||
if( sizeof(int) != FS_ReadFile(&f, &id_count, (s32)sizeof(int)) ) {
|
||||
miya_log_fprintf(log_fd, "Failed Read File %s\n",__FUNCTION__);
|
||||
miya_log_fprintf(log_fd, " path=%s\n", path );
|
||||
miya_log_fprintf(log_fd, " res=%s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path) ));
|
||||
ret_flag = FALSE;
|
||||
goto function_end;
|
||||
}
|
||||
|
||||
*count = id_count;
|
||||
size = (int)sizeof(u64) * id_count;
|
||||
|
||||
*pBuffer = (u64 *)OS_Alloc( (u32)size );
|
||||
if( *pBuffer == NULL ) {
|
||||
ret_flag = FALSE;
|
||||
miya_log_fprintf(log_fd, "%s Failed memory alloc size %d\n",__FUNCTION__, size);
|
||||
goto function_end;
|
||||
}
|
||||
readSize = FS_ReadFile(&f, (void *)*pBuffer, (s32)size );
|
||||
if( readSize != size ) {
|
||||
miya_log_fprintf(log_fd, "Failed Read File: %s request size %d read size %d\n",path, size, readSize);
|
||||
if( readSize != size ) {
|
||||
ret_flag = FALSE;
|
||||
goto function_end;
|
||||
}
|
||||
}
|
||||
function_end:
|
||||
|
||||
bSuccess = FS_CloseFile(&f);
|
||||
if( ! bSuccess ) {
|
||||
miya_log_fprintf(log_fd, "Failed Close File\n");
|
||||
miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path)));
|
||||
}
|
||||
|
||||
if( log_active ) {
|
||||
miya_log_fprintf(log_fd, "%s END\n\n", __FUNCTION__);
|
||||
Log_File_Close(log_fd);
|
||||
}
|
||||
return ret_flag;
|
||||
}
|
||||
|
||||
BOOL TitleIDSaveETicketOnly(const char *path, u64 *pData, int count, char *log_file_name )
|
||||
{
|
||||
FSFile f;
|
||||
BOOL bSuccess;
|
||||
FSResult res;
|
||||
FSResult fsResult;
|
||||
// s32 writtenSize;
|
||||
BOOL log_active = FALSE;
|
||||
FSFile *log_fd;
|
||||
FSFile log_fd_real;
|
||||
BOOL ret_flag = TRUE;
|
||||
|
||||
log_fd = &log_fd_real;
|
||||
|
||||
FS_InitFile(&f);
|
||||
|
||||
log_active = Log_File_Open( log_fd, log_file_name );
|
||||
if( !log_active ) {
|
||||
log_fd = NULL;
|
||||
}
|
||||
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
|
||||
|
||||
if( count < 1 ) {
|
||||
miya_log_fprintf(log_fd, "%s path=%s count=%d pData=0x%08x\n", __FUNCTION__,path,count, pData );
|
||||
goto function_end;
|
||||
}
|
||||
if( path == NULL ) {
|
||||
miya_log_fprintf(log_fd, "%s path=%s count=%d pData=0x%08x\n", __FUNCTION__,path,count, pData );
|
||||
goto function_end;
|
||||
}
|
||||
if( pData == NULL ) {
|
||||
miya_log_fprintf(log_fd, "%s path=%s count=%d pData=0x%08x\n", __FUNCTION__,path,count, pData );
|
||||
goto function_end;
|
||||
}
|
||||
|
||||
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_W);
|
||||
if( ! bSuccess ) {
|
||||
FS_CreateFileAuto( path, FS_PERMIT_W|FS_PERMIT_R);
|
||||
bSuccess = FS_OpenFileEx(&f, path , FS_FILEMODE_W );
|
||||
if( ! bSuccess ) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(log_fd, "%s file open error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(log_fd, " Failed open file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
ret_flag = FALSE;
|
||||
goto function_end;
|
||||
}
|
||||
}
|
||||
|
||||
fsResult = FS_SetFileLength(&f, 0);
|
||||
if( fsResult != FS_RESULT_SUCCESS ) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(log_fd, "%s file length error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(log_fd, " Failed file lenght :%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
ret_flag = FALSE;
|
||||
goto function_end;
|
||||
}
|
||||
|
||||
if( sizeof(int) != FS_WriteFile(&f, &count, (s32)sizeof(int)) ) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(log_fd, "%s file write error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(log_fd, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
ret_flag = FALSE;
|
||||
goto function_end;
|
||||
}
|
||||
else {
|
||||
miya_log_fprintf(log_fd, "num of title id = %d\n", count);
|
||||
}
|
||||
|
||||
if( ( pData != NULL ) && ( count != 0 ) ) {
|
||||
/* 16•¶Žš‚¾‚©‚ç */
|
||||
if( (count*sizeof(u64)) != FS_WriteFile(&f, pData, (s32)(count*sizeof(u64)) )) {
|
||||
res = FS_GetArchiveResultCode( path );
|
||||
miya_log_fprintf(log_fd, "%s file write error %s\n", __FUNCTION__,path );
|
||||
miya_log_fprintf(log_fd, " Failed write file:%s\n", my_fs_util_get_fs_result_word( res ));
|
||||
ret_flag = FALSE;
|
||||
goto function_end;
|
||||
}
|
||||
else {
|
||||
int j;
|
||||
u64 *ptr = pData;
|
||||
|
||||
if( ptr != NULL && count > 0 ) {
|
||||
for( j = 0 ; j < count ; j++ ) {
|
||||
miya_log_fprintf(log_fd,"No. %d 0x%016llx\n",j, *ptr);
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FS_FlushFile(&f);
|
||||
function_end:
|
||||
bSuccess = FS_CloseFile(&f);
|
||||
if( bSuccess ) {
|
||||
|
||||
}
|
||||
if( log_active ) {
|
||||
miya_log_fprintf(log_fd, "%s END\n\n", __FUNCTION__);
|
||||
Log_File_Close(log_fd);
|
||||
}
|
||||
return ret_flag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* TWLカードがあるかどうか */
|
||||
|
||||
@ -74,6 +74,10 @@ BOOL MydataSaveEncrypt(const char *path, void *pData, int size, FSFile *log_fd);
|
||||
BOOL TitleIDSave(const char *path, MY_USER_APP_TID *pData, int count, char *log_file_name);
|
||||
BOOL TitleIDLoad(const char *path, MY_USER_APP_TID **pBuffer, int *count, char *log_file_name);
|
||||
|
||||
BOOL TitleIDSaveETicketOnly(const char *path, u64 *pData, int count, char *log_file_name );
|
||||
BOOL TitleIDLoadETicketOnly(const char *path, u64 **pBuffer, int *count, char *log_file_name);
|
||||
|
||||
|
||||
BOOL CopyFile(const char *dst_path, const char *src_path, FSFile *log_fd );
|
||||
|
||||
void Log_File_Close(FSFile *log_fd);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
#define MY_DATA_VERSION_MAJOR 1
|
||||
#define MY_DATA_VERSION_MINOR 4
|
||||
#define MY_DATA_VERSION_MINOR 5
|
||||
|
||||
typedef struct {
|
||||
u8 version_major;
|
||||
@ -20,6 +20,7 @@ typedef struct {
|
||||
BOOL shop_record_flag;
|
||||
int num_of_user_download_app;
|
||||
int num_of_user_pre_installed_app;
|
||||
int num_of_user_pre_installed_eticket_only;
|
||||
int num_of_app_save_data;
|
||||
int num_of_photo_files;
|
||||
int num_of_shared2_files;
|
||||
|
||||
@ -213,7 +213,7 @@ char *MyFile_GetDownloadTitleIDRestoreLogFileName(void)
|
||||
char *MyFile_GetDownloadTitleIDSaveLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_DOWNLOAD_TITLE_ID_RESTORE_LOG );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_DOWNLOAD_TITLE_ID_SAVE_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
@ -224,6 +224,28 @@ char *MyFile_GetDownloadTitleIDFileName(void)
|
||||
return path;
|
||||
}
|
||||
|
||||
char *MyFile_GetDownloadTitleIDTicketOnlyFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
STD_StrCat( path , MY_FILE_NAME_DOWNLOAD_TITLE_ID_TICKET_DATA );
|
||||
return path;
|
||||
}
|
||||
|
||||
char *MyFile_GetDownloadTitleIDTicketOnlyRestoreLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_DOWNLOAD_TITLE_ID_TICKET_RESTORE_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
char *MyFile_GetDownloadTitleIDTicketOnlySaveLogFileName(void)
|
||||
{
|
||||
STD_StrCpy( path_log , path_base );
|
||||
STD_StrCat( path_log , MY_FILE_NAME_DOWNLOAD_TITLE_ID_TICKET_SAVE_LOG );
|
||||
return path_log;
|
||||
}
|
||||
|
||||
|
||||
char *MyFile_GetGlobalInformationFileName(void)
|
||||
{
|
||||
STD_StrCpy( path , path_base );
|
||||
|
||||
@ -39,6 +39,11 @@
|
||||
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_RESTORE_LOG ("title_id_rst.txt" )
|
||||
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_SAVE_LOG ("title_id_sv.txt" )
|
||||
|
||||
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_TICKET_DATA ("title_tk.dat")
|
||||
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_TICKET_LOG ("title_tk.txt" )
|
||||
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_TICKET_RESTORE_LOG ("title_tk_rst.txt" )
|
||||
#define MY_FILE_NAME_DOWNLOAD_TITLE_ID_TICKET_SAVE_LOG ("title_id_sv.txt" )
|
||||
|
||||
#define MY_FILE_NAME_ORG_DATA ("personal.dat")
|
||||
#define MY_FILE_NAME_ORG_LOG ("personal.txt")
|
||||
#define MY_FILE_NAME_ORG_RESTORE_LOG ("personal_rst.txt")
|
||||
@ -94,6 +99,10 @@ char *MyFile_GetDownloadTitleIDFileName(void);
|
||||
char *MyFile_GetDownloadTitleIDRestoreLogFileName(void);
|
||||
char *MyFile_GetDownloadTitleIDSaveLogFileName(void);
|
||||
|
||||
char *MyFile_GetDownloadTitleIDTicketOnlyFileName(void);
|
||||
char *MyFile_GetDownloadTitleIDTicketOnlySaveLogFileName(void);
|
||||
char *MyFile_GetDownloadTitleIDTicketOnlyRestoreLogFileName(void);
|
||||
|
||||
char *MyFile_GetGlobalInformationFileName(void);
|
||||
char *MyFile_GetGlobalInformationRestoreFileName(void);
|
||||
char *MyFile_GetGlobalInformationLogFileName(void);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL myImportTad(char* file_name, FSFile *log_fd);
|
||||
|
||||
BOOL myDeleteTitle(u64 tid, BOOL with_ticket, FSFile *log_fd);
|
||||
BOOL my_NAM_ImportTadTicketOnly(const char* path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "pre_install.h"
|
||||
|
||||
#define PRE_INSTALL_TABLE_FILE_NAND "rom:/tads/tad_table.txt"
|
||||
#define PRE_INSTALL_TABLE_DEV_FILE_NAND "rom:/taddevs/taddev_table.txt"
|
||||
#define PRE_INSTALL_TABLE_FILE_SD "sdmc:/tads/tad_table.txt"
|
||||
|
||||
static PRE_INSTALL_FILE *pre_install_file_list = NULL;
|
||||
@ -74,6 +75,16 @@ BOOL pre_install_check_download_or_pre_install(u64 tid, int *flag, FSFile *log_f
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if 0
|
||||
miya_log_fprintf(log_fd,"ES_GetTicketViews failed numTickets = 0: %d tid=0x%08x%08x\n",
|
||||
rv, (u32)(tid >> 32) , (u32)(tid & 0xffffffff) );
|
||||
return FALSE;
|
||||
#endif
|
||||
/* error ??? */
|
||||
*flag = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
@ -133,20 +144,19 @@ static BOOL pre_install_add_list(u64 tid, u8 region, u8 country_code, char *temp
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
char *pre_install_search_tid(u64 tid, FSFile *log_fd)
|
||||
{
|
||||
PRE_INSTALL_FILE *temp_list;
|
||||
|
||||
for( temp_list = pre_install_file_list ; temp_list != NULL ; temp_list = temp_list->next ) {
|
||||
if( temp_list->tid == tid ) {
|
||||
miya_log_fprintf(log_fd,"tad file entry tid=0x%08x%08x %s\n",
|
||||
miya_log_fprintf(log_fd,"\ntad file entry tid=0x%08x%08x\n%s\n",
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), temp_list->file_name );
|
||||
|
||||
return temp_list->file_name;
|
||||
}
|
||||
}
|
||||
miya_log_fprintf(log_fd,"%s %s:No entry tid 0x%08x%08x\n",__FILE__,__FUNCTION__,
|
||||
miya_log_fprintf(log_fd,"\n%s:No entry\ntid 0x%08x%08x\n",__FUNCTION__,
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff));
|
||||
return NULL;
|
||||
|
||||
@ -163,10 +173,23 @@ BOOL pre_install_discard_list(void)
|
||||
OS_Free( temp_list );
|
||||
temp_list = temp_list2;
|
||||
}
|
||||
pre_install_file_list = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void pre_install_print_list(FSFile *log_fd)
|
||||
{
|
||||
PRE_INSTALL_FILE *temp_list;
|
||||
u64 tid;
|
||||
|
||||
for( temp_list = pre_install_file_list ; temp_list != NULL ; temp_list = temp_list->next ) {
|
||||
tid = temp_list->tid;
|
||||
miya_log_fprintf(log_fd,"tad file entry tid=0x%08x%08x %s\n",
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), temp_list->file_name );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ReadLine(FSFile *f, char *buf, int buf_size)
|
||||
@ -197,15 +220,10 @@ static int ReadLine(FSFile *f, char *buf, int buf_size)
|
||||
*buf = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int my_char_to_hex(char c)
|
||||
{
|
||||
if( '0' <= c && c <= '9' ) {
|
||||
@ -220,7 +238,6 @@ static int my_char_to_hex(char c)
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
|
||||
BOOL pre_install_load_file(char *path, FSFile *log_fd)
|
||||
{
|
||||
FSFile file;
|
||||
@ -237,7 +254,6 @@ BOOL pre_install_load_file(char *path, FSFile *log_fd)
|
||||
// PRE_INSTALL_FILE temp_pre_install_file;
|
||||
char temp_file_name[FS_FILE_NAME_MAX];
|
||||
|
||||
|
||||
u64 temp_tid;
|
||||
u8 temp_region;
|
||||
u8 temp_country_code;
|
||||
@ -358,8 +374,10 @@ BOOL pre_install_load_file(char *path, FSFile *log_fd)
|
||||
buf_state = 5; /* next state */
|
||||
}
|
||||
else {
|
||||
temp_file_name[temp_filename_count] = c;
|
||||
temp_filename_count++;
|
||||
if( c != ' ' ) {
|
||||
temp_file_name[temp_filename_count] = c;
|
||||
temp_filename_count++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5: /* until line end */
|
||||
@ -370,8 +388,6 @@ BOOL pre_install_load_file(char *path, FSFile *log_fd)
|
||||
}
|
||||
buf_counter++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
/* 妙なフォーマットは全部コメント扱い. */
|
||||
@ -397,11 +413,23 @@ BOOL pre_install_Cleanup_User_Titles( FSFile *log_fd )
|
||||
u64 tid;
|
||||
char game_code_buf[5];
|
||||
|
||||
#if 1
|
||||
num = NAM_GetNumInstalledTitles();
|
||||
#else
|
||||
num = NAM_GetNumTitles();
|
||||
#endif
|
||||
|
||||
if( num > 0 ) {
|
||||
#if 1
|
||||
if( NAM_OK != NAM_GetInstalledTitleList( pArray , NAM_TITLE_ID_S ) ) {
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
if( NAM_OK != NAM_GetTitleList( pArray , NAM_TITLE_ID_S ) ) {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
miya_log_fprintf(log_fd, "NAND Installed titles\n");
|
||||
|
||||
mprintf("Clean-up NAND installed titles\n");
|
||||
@ -431,13 +459,13 @@ BOOL pre_install_Cleanup_User_Titles( FSFile *log_fd )
|
||||
miya_log_fprintf(log_fd, " usr.id %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
|
||||
|
||||
if( NAM_OK != NAM_DeleteTitle( tid ) ) {
|
||||
if( NAM_OK != NAM_DeleteTitleCompletely( tid ) ) {
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
miya_log_fprintf(log_fd, "NG.\n");
|
||||
miya_log_fprintf(log_fd, " Error: NAM_DeleteTitle id = %08X%08X\n", (u32)(tid >> 32), (u32)tid);
|
||||
miya_log_fprintf(log_fd, " Error: NAM_DeleteTitleCompletely id = %08X%08X\n", (u32)(tid >> 32), (u32)tid);
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
else {
|
||||
@ -453,7 +481,110 @@ BOOL pre_install_Cleanup_User_Titles( FSFile *log_fd )
|
||||
}
|
||||
|
||||
|
||||
BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int title_id_count )
|
||||
BOOL pre_install_command(FSFile *log_fd, u64 *tid_array, int tid_count, int command, BOOL development_version_flag )
|
||||
{
|
||||
char *tad_file_name;
|
||||
int i;
|
||||
u64 tid;
|
||||
char game_code_buf[5];
|
||||
BOOL ret_flag;
|
||||
|
||||
if( development_version_flag ) {
|
||||
(void)pre_install_load_file(PRE_INSTALL_TABLE_DEV_FILE_NAND, log_fd);
|
||||
}
|
||||
else {
|
||||
(void)pre_install_load_file(PRE_INSTALL_TABLE_FILE_NAND, log_fd);
|
||||
}
|
||||
|
||||
switch( command ) {
|
||||
case 1:
|
||||
mprintf("Install App.\n");
|
||||
break;
|
||||
case 2:
|
||||
mprintf("Install TicketOnly.\n");
|
||||
break;
|
||||
case 3:
|
||||
mprintf("Uninstall App.(except ticket)\n");
|
||||
break;
|
||||
case 4:
|
||||
mprintf("Uninstall App. with ticket\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for( i = 0 ; i < tid_count ; i++ ) {
|
||||
ret_flag = TRUE;
|
||||
tid = tid_array[i];
|
||||
(void)my_fs_Tid_To_GameCode(tid, game_code_buf);
|
||||
mprintf(" %08X%08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, " %08X%08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
if( tid == 0 ) {
|
||||
/* errorか */
|
||||
continue;
|
||||
}
|
||||
|
||||
switch( command ) {
|
||||
case 1:
|
||||
mprintf("IA ");
|
||||
miya_log_fprintf(log_fd, "IA ");
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd);
|
||||
if( tad_file_name ) {
|
||||
ret_flag = myImportTad( tad_file_name , log_fd );
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
mprintf("TO ");
|
||||
miya_log_fprintf(log_fd, "TO ");
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd);
|
||||
if( tad_file_name ) {
|
||||
ret_flag = my_NAM_ImportTadTicketOnly( tad_file_name );
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
mprintf("DA ");
|
||||
miya_log_fprintf(log_fd, "DA ");
|
||||
ret_flag = myDeleteTitle( tid, 0 , NULL );
|
||||
break;
|
||||
case 4:
|
||||
mprintf("DC ");
|
||||
miya_log_fprintf(log_fd, "DC ");
|
||||
ret_flag = myDeleteTitle( tid, 1 , NULL );
|
||||
break;
|
||||
default:
|
||||
mprintf("?? ");
|
||||
miya_log_fprintf(log_fd, "?? ");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if( ret_flag == FALSE ) {
|
||||
/* error チケットインストール失敗? */
|
||||
miya_log_fprintf(log_fd, "NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
|
||||
}
|
||||
else {
|
||||
miya_log_fprintf(log_fd, "OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mprintf("Done.\n");
|
||||
|
||||
(void)pre_install_discard_list();
|
||||
return ret_flag;
|
||||
|
||||
}
|
||||
|
||||
BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int title_id_count,
|
||||
u64 *ticket_id_array, int ticket_id_count, BOOL development_version_flag )
|
||||
{
|
||||
char *tad_file_name;
|
||||
int i;
|
||||
@ -467,14 +598,68 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int
|
||||
(void)pre_install_load_file(PRE_INSTALL_TABLE_FILE_SD, log_fd);
|
||||
#endif
|
||||
|
||||
(void)pre_install_load_file(PRE_INSTALL_TABLE_FILE_NAND, log_fd);
|
||||
if( development_version_flag ) {
|
||||
(void)pre_install_load_file(PRE_INSTALL_TABLE_DEV_FILE_NAND, log_fd);
|
||||
}
|
||||
else {
|
||||
(void)pre_install_load_file(PRE_INSTALL_TABLE_FILE_NAND, log_fd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
pre_install_print_list(NULL);
|
||||
|
||||
|
||||
/* チケットだけのインストール */
|
||||
for( i = 0 ; i < ticket_id_count ; i++ ) {
|
||||
tid = ticket_id_array[i];
|
||||
(void)my_fs_Tid_To_GameCode(tid, game_code_buf);
|
||||
mprintf(" TO %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, " TO %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
if( tid == 0 ) {
|
||||
/* errorか */
|
||||
continue;
|
||||
}
|
||||
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd);
|
||||
if( tad_file_name ) {
|
||||
if( FALSE == my_NAM_ImportTadTicketOnly( tad_file_name ) ) {
|
||||
/* error チケットインストール失敗? */
|
||||
miya_log_fprintf(log_fd, "NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
miya_log_fprintf(log_fd, "error: import tid=0x%08x%08x %s\n",
|
||||
(u32)(tid >> 32) , (u32)(tid & 0xffffffff), tad_file_name);
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
else {
|
||||
miya_log_fprintf(log_fd, "OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
|
||||
mprintf("OK.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* error ROMにファイルがない */
|
||||
miya_log_fprintf(log_fd, "NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */
|
||||
mprintf("NG.\n");
|
||||
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
|
||||
mprintf("No file\n");
|
||||
miya_log_fprintf(log_fd, "error: no file\n");
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* アプリ(common eticket)のインストール */
|
||||
for( i = 0 ; i < title_id_count ; i++ ) {
|
||||
/*
|
||||
pTitleIds[i].is_personalized = 1 -> common (pre installed)
|
||||
pTitleIds[i].is_personalized = 2 -> personalized
|
||||
*/
|
||||
if( title_id_buf_ptr[i].is_personalized == 1 ) {
|
||||
if( title_id_buf_ptr[i].is_personalized == 1 /* commonの場合 */ ) {
|
||||
/*
|
||||
0x00030004484E474A "rom:/tads/TWL-KGUJ-v257.tad.out"
|
||||
0x000300044B32444A "rom:/tads/TWL-K2DJ-v0.tad.out"
|
||||
@ -482,8 +667,8 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int
|
||||
*/
|
||||
tid = title_id_buf_ptr[i].tid;
|
||||
(void)my_fs_Tid_To_GameCode(tid, game_code_buf);
|
||||
mprintf(" id %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, " id %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
mprintf(" AP %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
miya_log_fprintf(log_fd, " AP %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf);
|
||||
|
||||
tad_file_name = pre_install_search_tid( tid , log_fd);
|
||||
if( tad_file_name ) {
|
||||
|
||||
@ -19,8 +19,11 @@ BOOL pre_install_Cleanup_User_Titles( FSFile *log_fd );
|
||||
BOOL pre_install_load_file(char *path, FSFile *log_fd);
|
||||
char *pre_install_search_tid(u64 tid, FSFile *log_fd);
|
||||
BOOL pre_install_discard_list(void);
|
||||
BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int tile_id_count );
|
||||
BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int tile_id_count,
|
||||
u64 *ticket_id_array, int ticket_id_count ,BOOL development_version_flag );
|
||||
BOOL pre_install_check_download_or_pre_install(u64 tid, int *flag, FSFile *log_fd);
|
||||
void pre_install_print_list(FSFile *log_fd);
|
||||
BOOL pre_install_command(FSFile *log_fd, u64 *tid_array, int tid_count, int command, BOOL development_version_flag );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
# $Rev: 3650 $
|
||||
# $Author: okubata_ryoma $
|
||||
#----------------------------------------------------------------------------
|
||||
SUBDIRS = ./banner ../files/tads
|
||||
SUBDIRS = ./banner ../files/tads ../files/taddevs
|
||||
|
||||
TARGET_PLATFORM := TWL
|
||||
TWL_ARCHGEN := LIMITED
|
||||
@ -39,6 +39,8 @@ ES_LATEST = $(shell ls -d $(ES_DIR)/es-sdk-*|sort|tail -n 1)
|
||||
ES_ROOT = $(ES_LATEST)
|
||||
|
||||
LINCLUDES = $(TWLSDK_ROOT)/build/libraries/lcfg/ARM9.TWL/include ../common/src \
|
||||
$(TWLSDK_ROOT)/build/libraries/nam/ARM9.TWL/include \
|
||||
$(TWLSDK_ROOT)/build/libraries/ese/common/include \
|
||||
$(ES_ROOT)/twl/include $(ES_ROOT)/common/lib/ec/include
|
||||
|
||||
LLIBRARY_DIRS += $(ES_ROOT)/twl/lib/$(TWL_BUILDTYPE) ../wifilib/$(TWL_BUILDTYPE)
|
||||
@ -62,12 +64,15 @@ LLIBRARIES += libecx$(TWL_LIBSUFFIX).a \
|
||||
|
||||
MAKEROM_ROMROOT = ../files
|
||||
|
||||
TAD_TABLE_TXT = ../files/tads/tad_table.txt
|
||||
TAD_TABLE_TXT = ../files/tads/tad_table.txt
|
||||
TADDEV_TABLE_TXT = ../files/taddevs/taddev_table.txt
|
||||
|
||||
-include MakefileTad.inc
|
||||
|
||||
include Makefile.TadIncludes
|
||||
-include MakefileTadDev.inc
|
||||
|
||||
MAKEROM_ROMFILES = fanfare.32.wav ok.wav ng.wav cursor.wav tads/tad_table.txt $(MAKEROM_TAD_ROMFILES)
|
||||
MAKEROM_ROMFILES = fanfare.32.wav ok.wav ng.wav cursor.wav \
|
||||
tads/tad_table.txt taddevs/taddev_table.txt $(MAKEROM_TAD_ROMFILES) $(MAKEROM_TADDEV_ROMFILES)
|
||||
|
||||
|
||||
|
||||
@ -105,7 +110,9 @@ $(TARGET_AUTOBOOT): ./bin/$(TWL_BUILDTYPE)/$(TARGET_BIN)
|
||||
do-build: $(TARGETS) $(TARGET_AUTOBOOT)
|
||||
|
||||
|
||||
$(BINDIR)/$(TARGET_BIN_BASENAME).$(TWL_ELF_EXT): Makefile.TadIncludes $(TAD_TABLE_TXT)
|
||||
$(BINDIR)/$(TARGET_BIN_BASENAME).$(TWL_ELF_EXT): MakefileTad.inc MakefileTadDev.inc $(TAD_TABLE_TXT) $(TADDEV_TABLE_TXT)
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
@ -165,7 +165,7 @@ Property
|
||||
#
|
||||
# SDCardAccess: sd card access control [TRUE/FALSE]
|
||||
#
|
||||
SDCardAccess TRUE
|
||||
SDCardAccess ReadWrite
|
||||
|
||||
#
|
||||
# NANDAccess: NAND access control [TRUE/FALSE]
|
||||
|
||||
@ -642,6 +642,8 @@ static BOOL RestoreFromSDCard7(void)
|
||||
char game_code_buf[5];
|
||||
int is_personalized;
|
||||
u64 tid;
|
||||
u64 *eticket_only_id_buf = NULL;
|
||||
int num_of_eticket_only_titles = 0;
|
||||
|
||||
title_id_count = 0;
|
||||
if( title_id_buf_ptr != NULL ) {
|
||||
@ -721,7 +723,6 @@ static BOOL RestoreFromSDCard7(void)
|
||||
goto pre_install_label;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
EC downloadの後にNAM_ImportをやらないとLoadCertのSEA_Decryptでこける。
|
||||
理由はAESエンジンのスロットをNAM_Importでつぶしちゃうから。
|
||||
@ -752,7 +753,6 @@ static BOOL RestoreFromSDCard7(void)
|
||||
SetupShopTitleId(); /* エラーはない */
|
||||
miya_log_fprintf(log_fd,"SetupShopTitleId\n");
|
||||
|
||||
|
||||
// ?:ユーザ設定がされていないと接続できないので適当に設定
|
||||
// SetupUserInfo();
|
||||
// 必須:バージョンデータのマウント
|
||||
@ -866,16 +866,28 @@ static BOOL RestoreFromSDCard7(void)
|
||||
|
||||
pre_install_label:
|
||||
|
||||
if( mydata.num_of_user_pre_installed_app > 0 ) {
|
||||
if( (mydata.num_of_user_pre_installed_app > 0) ||
|
||||
(mydata.num_of_user_pre_installed_eticket_only > 0) ) {
|
||||
/* プリンストール対応 */
|
||||
miya_log_fprintf(log_fd,"Import Pre-installed apps.\n");
|
||||
mprintf("Import Pre-installed apps..\n");
|
||||
if( FALSE == pre_install_process( log_fd, title_id_buf_ptr, title_id_count ) ) {
|
||||
if( mydata.num_of_user_pre_installed_eticket_only > 0 ) {
|
||||
if( FALSE == TitleIDLoadETicketOnly( MyFile_GetDownloadTitleIDTicketOnlyFileName(),
|
||||
&eticket_only_id_buf, &num_of_eticket_only_titles,
|
||||
MyFile_GetDownloadTitleIDTicketOnlyRestoreLogFileName()) ) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/* pre_install_process関数の中でEチケットだけのやつもやりたい。 */
|
||||
if( FALSE == pre_install_process( log_fd, title_id_buf_ptr, title_id_count,
|
||||
eticket_only_id_buf,
|
||||
mydata.num_of_user_pre_installed_eticket_only ,
|
||||
development_console_flag ) ) {
|
||||
ret_flag = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hatamotolib_log_end();
|
||||
|
||||
return ret_flag;
|
||||
|
||||
@ -37,6 +37,8 @@ ES_LATEST = $(shell ls -d $(ES_DIR)/es-sdk-*|sort|tail -n 1)
|
||||
ES_ROOT = $(ES_LATEST)
|
||||
|
||||
LINCLUDES = $(TWLSDK_ROOT)/build/libraries/lcfg/ARM9.TWL/include ../common/src \
|
||||
$(TWLSDK_ROOT)/build/libraries/nam/ARM9.TWL/include \
|
||||
$(TWLSDK_ROOT)/build/libraries/ese/common/include \
|
||||
$(ES_ROOT)/twl/include $(ES_ROOT)/common/lib/ec/include
|
||||
|
||||
LLIBRARY_DIRS += $(ES_ROOT)/twl/lib/$(TWL_BUILDTYPE) ../wifilib/$(TWL_BUILDTYPE)
|
||||
|
||||
@ -165,7 +165,7 @@ Property
|
||||
#
|
||||
# SDCardAccess: sd card access control [TRUE/FALSE]
|
||||
#
|
||||
SDCardAccess TRUE
|
||||
SDCardAccess ReadWrite
|
||||
|
||||
#
|
||||
# NANDAccess: NAND access control [TRUE/FALSE]
|
||||
|
||||
@ -97,6 +97,14 @@ static int vram_num_sub = 0;
|
||||
static LCFGTWLHWNormalInfo hwn_info;
|
||||
static LCFGTWLHWSecureInfo hws_info;
|
||||
|
||||
#define NAM_TITLE_ID_S 128
|
||||
|
||||
static NAMTitleId array_eticket_only_titles[NAM_TITLE_ID_S];
|
||||
static NAMTitleId array_app_titles[NAM_TITLE_ID_S];
|
||||
static int num_of_eticket_only_titles = 0;
|
||||
static int num_of_app_titles = 0;
|
||||
static int num_of_all_titles = 0;
|
||||
|
||||
#define MY_STACK_SIZE (1024*16) /* ‚Å‚©‚¢‚Ù‚¤‚ª‚¢‚¢ */
|
||||
#define MY_THREAD_PRIO 20
|
||||
static OSThread MyThread;
|
||||
@ -147,13 +155,93 @@ static void FreeForNAM(void* ptr)
|
||||
}
|
||||
}
|
||||
|
||||
static NAMTitleId pArray[NAM_TITLE_ID_S];
|
||||
|
||||
|
||||
static int Check_User_Titles_ETicket_Only(void)
|
||||
{
|
||||
s32 i,j;
|
||||
s32 num = 0;
|
||||
int user_title_count = 0;
|
||||
BOOL now_installed_flag;
|
||||
u64 id;
|
||||
char game_code[5];
|
||||
int common_or_personalized_flag;
|
||||
|
||||
// num = NAM_GetNumTitles();
|
||||
num = NAM_GetNumInstalledTitles();
|
||||
if( num >= 0 ) {
|
||||
if( NAM_OK != NAM_GetInstalledTitleList( pArray , NAM_TITLE_ID_S ) ) {
|
||||
OS_TPrintf("error:NAM_GetInstalledTitleList\n");
|
||||
return -1; /* error */
|
||||
}
|
||||
OS_TPrintf("NAND Ticket only titles\n");
|
||||
for( i = 0 ; i < num ; i++ ) {
|
||||
now_installed_flag = FALSE;
|
||||
id = pArray[i];
|
||||
for( j = 0 ; j < num_of_all_titles ; j++ ) {
|
||||
if( id == array_app_titles[ j ] ) {
|
||||
now_installed_flag = TRUE;
|
||||
}
|
||||
}
|
||||
if( now_installed_flag == TRUE ) {
|
||||
}
|
||||
else {
|
||||
/*
|
||||
No. 0 0003000f484e4c41
|
||||
No. 1 0003000f484e4841
|
||||
No. 2 0003000f484e4341
|
||||
No. 3 00030015484e4241
|
||||
No. 4 00030017484e4141 launcher
|
||||
^
|
||||
| ここの最下位ビットが1のやつがシステムアプリ
|
||||
|
|
||||
システムアプリはダウンロード対象外
|
||||
*/
|
||||
(void)my_fs_Tid_To_GameCode(id, game_code);
|
||||
|
||||
if( id & 0x0000000100000000 ) {
|
||||
/* system app. */
|
||||
OS_TPrintf(" sys.:%3d:0x%llx %s\n", i, id, game_code);
|
||||
|
||||
}
|
||||
else {
|
||||
/* user app. */
|
||||
// OS_TPrintf(" usr.:%3d:0x%llx %s\n", i, id, game_code);
|
||||
common_or_personalized_flag = 1;
|
||||
if( FALSE == pre_install_check_download_or_pre_install(id, &common_or_personalized_flag, NULL) ) {
|
||||
OS_TPrintf(" pre_install_check_download_or_pre_install failed\n");
|
||||
}
|
||||
else {
|
||||
if( common_or_personalized_flag == 1 ) {
|
||||
OS_TPrintf(" usr.:%3d:0x%llx %s common\n", i, id, game_code);
|
||||
array_eticket_only_titles[user_title_count] = id;
|
||||
user_title_count++;
|
||||
}
|
||||
else {
|
||||
OS_TPrintf(" usr.:%3d:0x%llx %s personalized\n", i, id, game_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
OS_TPrintf("error:NAM_GetInstalledTitles\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
num_of_eticket_only_titles = user_title_count;
|
||||
return user_title_count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int Check_User_Titles(void)
|
||||
{
|
||||
|
||||
#define NAM_TITLE_ID_S 128
|
||||
|
||||
NAMTitleId pArray[NAM_TITLE_ID_S];
|
||||
s32 i;
|
||||
s32 num = 0;
|
||||
int user_tilte_count = 0;
|
||||
@ -161,13 +249,16 @@ static int Check_User_Titles(void)
|
||||
char game_code[5];
|
||||
|
||||
num = NAM_GetNumTitles();
|
||||
if( num > 0 ) {
|
||||
if( NAM_OK != NAM_GetTitleList( pArray , NAM_TITLE_ID_S ) ) {
|
||||
if( num >= 0 ) {
|
||||
|
||||
|
||||
if( NAM_OK != NAM_GetTitleList( array_app_titles , NAM_TITLE_ID_S ) ) {
|
||||
OS_TPrintf("error:NAM_GetTitleList\n");
|
||||
return -1; /* error */
|
||||
}
|
||||
OS_TPrintf("NAND Installed titles\n");
|
||||
OS_TPrintf("NAND Installed titles %d\n",num);
|
||||
for( i = 0 ; i < num ; i++ ) {
|
||||
id = pArray[i];
|
||||
id = array_app_titles[i];
|
||||
|
||||
/*
|
||||
No. 0 0003000f484e4c41
|
||||
@ -194,6 +285,12 @@ static int Check_User_Titles(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
OS_TPrintf("error:NAM_GetNumTitles\n");
|
||||
return -1;
|
||||
}
|
||||
num_of_app_titles = user_tilte_count;
|
||||
num_of_all_titles = num;
|
||||
return user_tilte_count;
|
||||
}
|
||||
|
||||
@ -433,6 +530,7 @@ static BOOL SDBackupToSDCard6(void)
|
||||
return ret_flag;
|
||||
}
|
||||
|
||||
|
||||
static BOOL SDBackupToSDCard7(void)
|
||||
{
|
||||
MY_DIR_ENTRY_LIST *dir_entry_list_head = NULL;
|
||||
@ -482,16 +580,31 @@ static BOOL SDBackupToSDCard7(void)
|
||||
flag = GetUserAppTitleList( dir_entry_list_head, &pBuffer, &count,
|
||||
MyFile_GetUserAppTitleListLogFileName()) ;
|
||||
|
||||
|
||||
if( TRUE == flag ) {
|
||||
ptr = pBuffer;
|
||||
mydata.num_of_user_download_app = count;
|
||||
mydata.num_of_error_user_download_app = 0;
|
||||
mydata.num_of_user_pre_installed_app = 0;
|
||||
mydata.num_of_user_pre_installed_eticket_only = 0;
|
||||
|
||||
if( no_sd_clean_flag == TRUE ) {
|
||||
mprintf("\n");
|
||||
}
|
||||
|
||||
|
||||
//char *MyFile_GetDownloadTitleIDTicketOnlyFileName(void);
|
||||
//char *MyFile_GetDownloadTitleIDTicketOnlySaveLogFileName(void);
|
||||
//char *MyFile_GetDownloadTitleIDTicketOnlyRestoreLogFileName(void);
|
||||
|
||||
|
||||
mydata.num_of_user_pre_installed_eticket_only = num_of_eticket_only_titles;
|
||||
if( FALSE == TitleIDSaveETicketOnly( MyFile_GetDownloadTitleIDTicketOnlyFileName(),
|
||||
array_eticket_only_titles, num_of_eticket_only_titles,
|
||||
MyFile_GetDownloadTitleIDTicketOnlySaveLogFileName()) ) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
if( ptr != NULL && count != 0 ) {
|
||||
for( j = 0 ; j < count ; j++ ) {
|
||||
@ -546,7 +659,7 @@ static BOOL SDBackupToSDCard7(void)
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PrintSrcDirEntryListBackward( dir_entry_list_head, NULL );
|
||||
flag = TitleIDSave( MyFile_GetDownloadTitleIDFileName(),
|
||||
pBuffer, count, MyFile_GetDownloadTitleIDSaveLogFileName());
|
||||
@ -962,7 +1075,9 @@ void TwlMain(void)
|
||||
|
||||
// mydata.num_of_user_download_app_by_nam = Check_User_Titles();
|
||||
// mprintf("num of user tiltes = %d\n",mydata.num_of_user_download_app_by_nam);
|
||||
mprintf("num of user tiltes = %d\n",Check_User_Titles());
|
||||
/* 順番厳守 */
|
||||
mprintf("user tiltes(installed) = %d\n", Check_User_Titles());
|
||||
mprintf("user tiltes(ticket only) = %d\n", Check_User_Titles_ETicket_Only());
|
||||
|
||||
mprintf("\n");
|
||||
|
||||
|
||||
13
build/tools/sctools/files/taddevs/Makefile
Normal file
13
build/tools/sctools/files/taddevs/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
RM = rm.exe -f
|
||||
|
||||
TAD_TABLE_FILE = taddev_table.txt
|
||||
TAD_MAKE_INC_FILE = ../../copy_dst/MakefileTadDev.inc
|
||||
|
||||
$(TAD_TABLE_FILE): *.tad
|
||||
../../bin/make_tad_table.exe -dir . -o $@ -var MAKEROM_TADDEV_ROMFILES -fdir taddevs -mk $(TAD_MAKE_INC_FILE)
|
||||
|
||||
|
||||
|
||||
.PHONY: clean clobber
|
||||
clean clobber:
|
||||
$(RM) $(TAD_TABLE_FILE) $(TAD_MAKE_INC_FILE)
|
||||
BIN
build/tools/sctools/files/taddevs/backupSample.tad
Normal file
BIN
build/tools/sctools/files/taddevs/backupSample.tad
Normal file
Binary file not shown.
BIN
build/tools/sctools/files/taddevs/encodeSD.tad
Normal file
BIN
build/tools/sctools/files/taddevs/encodeSD.tad
Normal file
Binary file not shown.
BIN
build/tools/sctools/files/taddevs/nandAppSample.tad
Normal file
BIN
build/tools/sctools/files/taddevs/nandAppSample.tad
Normal file
Binary file not shown.
@ -1,4 +1,12 @@
|
||||
TAD_TABLE_FILE = tad_table.txt
|
||||
RM = rm.exe -f
|
||||
|
||||
$(TAD_TABLE_FILE):
|
||||
../../bin/make_tad_table.exe -dir . -o $@ -mk ../../copy_dst/Makefile.TadIncludes
|
||||
TAD_TABLE_FILE = tad_table.txt
|
||||
TAD_MAKE_INC_FILE = ../../copy_dst/MakefileTad.inc
|
||||
|
||||
$(TAD_TABLE_FILE): *.tad
|
||||
../../bin/make_tad_table.exe -dir . -o $@ -var MAKEROM_TAD_ROMFILES -fdir tads -mk $(TAD_MAKE_INC_FILE)
|
||||
|
||||
|
||||
.PHONY: clean clobber
|
||||
clean clobber:
|
||||
$(RM) $(TAD_TABLE_FILE) $(TAD_MAKE_INC_FILE)
|
||||
|
||||
@ -18,6 +18,7 @@ LD = gcc
|
||||
LDFLAGS = -Wl,--subsystem,console -mwindows -mno-cygwin
|
||||
LDLIBS =
|
||||
|
||||
RM = rm.exe -f
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .o .c
|
||||
|
||||
@ -200,10 +200,12 @@ static void print_gamecode(u32 tid_lo)
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static write_tad_table_form(FILE *fp, u32 tid_hi, u32 tid_lo, char *filename)
|
||||
{
|
||||
fprintf(fp, "0x%08x%08x, %d , %d , rom:/tads/%s\n",tid_hi, tid_lo, 0 , 0 , filename);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void read_file_and_print_titleid( char *path , char *d_name, FILE *fp_out, FILE *fp_mk)
|
||||
{
|
||||
@ -243,13 +245,13 @@ static void read_file_and_print_titleid( char *path , char *d_name, FILE *fp_out
|
||||
}
|
||||
|
||||
if( fp_out ) {
|
||||
fprintf(fp_out, "0x%08x%08x, %d , %d , rom:/tads/%s,\n", titleid_hi, titleid_lo, 0 , 0 , d_name);
|
||||
fprintf(fp_out, "0x%08x%08x, %d , %d , rom:/%s,\n", titleid_hi, titleid_lo, 0 , 0 , d_name);
|
||||
if( fp_mk ) {
|
||||
fprintf(fp_mk, "\t\ttads/%s \\\n", d_name);
|
||||
fprintf(fp_mk, "\t\t%s \\\n", d_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("0x%08x%08x, %d , %d , rom:/tads/%s,\n", titleid_hi, titleid_lo, 0 , 0 , d_name);
|
||||
printf("0x%08x%08x, %d , %d , rom:/%s,\n", titleid_hi, titleid_lo, 0 , 0 , d_name);
|
||||
}
|
||||
|
||||
|
||||
@ -273,10 +275,15 @@ int main(int argc, char **argv)
|
||||
char *outfile = NULL;
|
||||
char *dir_name = NULL;
|
||||
char *mkfile = NULL;
|
||||
char *var_name = NULL;
|
||||
char *file_dir = NULL;
|
||||
|
||||
BOOL read_file_flag = FALSE;
|
||||
BOOL write_file_flag = FALSE;
|
||||
BOOL dir_read_flag = FALSE;
|
||||
BOOL mk_file_flag = FALSE;
|
||||
BOOL var_name_flag = FALSE;
|
||||
BOOL file_dir_flag = FALSE;
|
||||
|
||||
char *prog;
|
||||
int badops = 0;
|
||||
@ -293,6 +300,7 @@ int main(int argc, char **argv)
|
||||
struct dirent *dr;
|
||||
struct stat st;
|
||||
char *full_path;
|
||||
char rom_file_full_path[256];
|
||||
|
||||
|
||||
prog=argv[0];
|
||||
@ -307,6 +315,20 @@ int main(int argc, char **argv)
|
||||
dir_name = *++argv;
|
||||
dir_read_flag = TRUE;
|
||||
}
|
||||
else if (strcmp(*argv,"-var") == 0 && !var_name_flag ) {
|
||||
if (--argc < 1) {
|
||||
goto bad;
|
||||
}
|
||||
var_name = *++argv;
|
||||
var_name_flag = TRUE;
|
||||
}
|
||||
else if (strcmp(*argv,"-fdir") == 0 && !file_dir_flag ) {
|
||||
if (--argc < 1) {
|
||||
goto bad;
|
||||
}
|
||||
file_dir = *++argv;
|
||||
file_dir_flag = TRUE;
|
||||
}
|
||||
else if (strcmp(*argv,"-o") == 0 && !write_file_flag ) {
|
||||
if (--argc < 1) {
|
||||
goto bad;
|
||||
@ -369,9 +391,12 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "error: file open %s\n",mkfile);
|
||||
goto end;
|
||||
}
|
||||
|
||||
fprintf(fp_mk, "MAKEROM_TAD_ROMFILES = \\\n");
|
||||
|
||||
if( var_name_flag ) {
|
||||
fprintf(fp_mk, "%s = \\\n",var_name);
|
||||
}
|
||||
else {
|
||||
fprintf(fp_mk, "MAKEROM_TAD_ROMFILES = \\\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -403,7 +428,15 @@ int main(int argc, char **argv)
|
||||
printf("FILE %s\n", dr->d_name);
|
||||
}
|
||||
if( st.st_size >= 32 ) {
|
||||
read_file_and_print_titleid( full_path ,dr->d_name, fp_out , fp_mk );
|
||||
if( file_dir_flag ) {
|
||||
strcpy( rom_file_full_path, file_dir);
|
||||
strcat( rom_file_full_path, "/");
|
||||
strcat( rom_file_full_path, dr->d_name);
|
||||
read_file_and_print_titleid( full_path ,rom_file_full_path, fp_out , fp_mk );
|
||||
}
|
||||
else {
|
||||
read_file_and_print_titleid( full_path ,dr->d_name, fp_out , fp_mk );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user