Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DanTheMan827 committed Aug 9, 2016
0 parents commit 9902084
Show file tree
Hide file tree
Showing 12 changed files with 6,857 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*~
*.3dsx
*.elf
*.smdh
Thumbs.db
build/
lib/
docs/
examples/
internal_docs
build.sh
output/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "buildtools"]
path = buildtools
url = https://github.com/Steveice10/buildtools.git
674 changes: 674 additions & 0 deletions LICENSE.TXT

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# TARGET #

TARGET := 3DS
LIBRARY := 0

ifeq ($(TARGET),3DS)
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
endif

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
endif

# COMMON CONFIGURATION #

NAME := tikSweep

BUILD_DIR := build
OUTPUT_DIR := output
INCLUDE_DIRS := include
SOURCE_DIRS := source

BUILD_FILTER := source/svchax/test/test.c

EXTRA_OUTPUT_FILES :=

LIBRARY_DIRS := $(DEVKITPRO)/libctru
LIBRARIES := ctru m

BUILD_FLAGS := -DVERSION_STRING="\"`git describe --tags --abbrev=0`\"" -DREVISION_STRING="\"`git rev-parse --short HEAD`\""
RUN_FLAGS :=

# 3DS CONFIGURATION #

TITLE := $(NAME)
DESCRIPTION := Remove unused tickets
AUTHOR := DanTheMan827
PRODUCT_CODE := CTR-K-TIKSWEEP
UNIQUE_ID := 0xA8BF

SYSTEM_MODE := 64MB
SYSTEM_MODE_EXT := Legacy

ICON_FLAGS :=

ROMFS_DIR := romfs
BANNER_AUDIO := audio.wav
BANNER_IMAGE := banner.png
ICON := icon.png

# INTERNAL #

include buildtools/make_base
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ![tikShop](https://raw.githubusercontent.com/DanTheMan827/tikSweep/master/banner.png)
tikSweep is utility app meant to do one thing, remove unused tickets from the system.

# Installation
Scan the QR code below in FBI to install the current version of tikSweep

![tikSweep QR Code](https://raw.githubusercontent.com/DanTheMan827/tikSweep/master/qr_code.png)

# Building
LibCTRU v.1.1.0 or higher is required, this version is not installed with devkitPro by default.

# License
tikSweep
Copyright (C) 2016 Daniel Radtke (DanTheMan827)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Binary file added audio.wav
Binary file not shown.
2,885 changes: 2,885 additions & 0 deletions banner.ai

Large diffs are not rendered by default.

Binary file added banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,083 changes: 3,083 additions & 0 deletions icon.ai

Large diffs are not rendered by default.

Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qr_code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
tikSweep
Copyright (C) 2016 Daniel Radtke (DanTheMan827)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <fstream>
#include <cstdlib>
#include <3ds.h>

u32 wait_key()
{
while (true)
{
hidScanInput();

u32 keys = hidKeysDown();
if (keys > 0)
{
return keys;
}
gfxFlushBuffers();
gspWaitForVBlank();
}
}

int util_compare_u64(const void* e1, const void* e2) {
u64 id1 = *(u64*) e1;
u64 id2 = *(u64*) e2;

return id1 > id2 ? 1 : id1 < id2 ? -1 : 0;
}

void clean_tickets(){
Result res = 0;
u32 ticketCount = 0;
u32 deletedCount = 0;
if(R_SUCCEEDED(res = AM_GetTicketCount(&ticketCount))) {
u64* ticketIDs = (u64*) calloc(ticketCount, sizeof(u64));
if(ticketIDs != NULL) {
if(R_SUCCEEDED(res = AM_GetTicketList(&ticketCount, ticketCount, 0, ticketIDs))) {
qsort(ticketIDs, ticketCount, sizeof(u64), util_compare_u64);
char cur[34];
for(u32 i = 0; i < ticketCount && R_SUCCEEDED(res); i++) {
sprintf(cur,"%016llX", ticketIDs[i]);
std::string curStr = cur;
std::string typeCheck = curStr.substr(4,4);
u64 titleID = ticketIDs[i];
AM_TitleEntry entry;
if(
(typeCheck == "0000" || typeCheck == "008c" || typeCheck == "000e" || typeCheck == "8004") &&
(
!R_SUCCEEDED(AM_GetTitleInfo(MEDIATYPE_SD, 1, &titleID, &entry)) &&
!R_SUCCEEDED(AM_GetTitleInfo(MEDIATYPE_NAND, 1, &titleID, &entry))
)
) {
AM_DeleteTicket(titleID);
deletedCount++;
printf("Deleted ");
printf(cur);
printf("\n");
}
}
}
}
}
printf("\nTotal tickets: %lu\n", ticketCount);
printf("Deleted tickets: %lu", deletedCount);
printf("\n\nPress any button to exit.");
wait_key();
}

void action_about(gfxScreen_t screen){
PrintConsole infoConsole;
PrintConsole* currentConsole = consoleSelect(&infoConsole);
consoleInit(screen, &infoConsole);

consoleClear();

printf(CONSOLE_RED "\n tikSweep " VERSION_STRING " by DanTheMan827\n\n" CONSOLE_RESET);
printf(" Remove unused tickets.\n\n");

printf(" Commit: " REVISION_STRING);

consoleSelect(currentConsole);
}

int main(int argc, const char* argv[]){

gfxInitDefault();
consoleInit(GFX_TOP, NULL);
amInit();

AM_InitializeExternalTitleDatabase(false);


action_about(GFX_BOTTOM);
printf("This will remove all unused tickets.");
printf("\n\nPress the A button to continue.\n\n");

if(wait_key() == KEY_A)
clean_tickets();

amExit();
gfxExit();
}

0 comments on commit 9902084

Please sign in to comment.