12-26-2019 (wasnt in git)

This commit is contained in:
Michael Nolan 2022-04-17 06:39:48 -05:00
commit 357c896b6f
7 changed files with 1823 additions and 0 deletions

160
Makefile Normal file
View File

@ -0,0 +1,160 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES :=
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
# the order can-be/is critical
#---------------------------------------------------------------------------------
LIBS := -lgrrlib -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lwiisocket
LIBS += -lfreetype -lbz2
LIBS += -lpngu -lpng -ljpeg -lz -lntfs -lfat
LIBS += -lwiiuse
#LIBS += -lmodplay -laesnd
LIBS += -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := -L$(LIBOGC_LIB) $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
wiiload $(TARGET).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
$(OFILES_SOURCES) : $(HFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .png extension
#---------------------------------------------------------------------------------
%.png.o : %.png
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .ttf extension
#---------------------------------------------------------------------------------
%.ttf.o : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

BIN
data/FreeMonoBold.ttf Normal file

Binary file not shown.

113
source/colors.c Normal file
View File

@ -0,0 +1,113 @@
#include "colors.h"
u32 colors[TOTALCOLORS];
int s=5;
void Green(){
SetColor(RGBA(0,128,0,255),DOWNLOAD_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_TEXTBOX_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_FOREGROUND_NO_SELECTOR);
SetColor(RGBA(0,0,255,255),DOWNLOAD_FOREGROUND_SELECTOR);
SetColor(RGBA(0,0,255,255),DOWNLOAD_KEYBOARD_UNSELECT);
SetColor(RGBA(0,0,0,255),DOWNLOAD_TEXTBOX_FOREGROUND);
SetColor(RGBA(255,12,255,255),DOWNLOAD_CURSOR);
SetColor(RGBA(127,0,127,255),DOWNLOAD_PROGRESSBAR_FOREGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_PROGRESSBAR_BACKGROUND);
SetColor(RGBA(0,0,255,255),DOWNLOAD_PROGRESSVAL);
SetColor(RGBA(255,0,0,255),DOWNLOAD_SELECTOR);
SetColor(RGBA(128,0,128,255),DOWNLOAD_KEYBOARD_OUTLINE);
}
void DefaultColors(){
SetColor(RGBA(255,0,0,255),DOWNLOAD_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_TEXTBOX_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_FOREGROUND_NO_SELECTOR);
SetColor(RGBA(0,0,255,255),DOWNLOAD_FOREGROUND_SELECTOR);
SetColor(RGBA(0,0,255,255),DOWNLOAD_KEYBOARD_UNSELECT);
SetColor(RGBA(0,0,0,255),DOWNLOAD_TEXTBOX_FOREGROUND);
SetColor(RGBA(255,12,255,255),DOWNLOAD_CURSOR);
SetColor(RGBA(127,0,127,255),DOWNLOAD_PROGRESSBAR_FOREGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_PROGRESSBAR_BACKGROUND);
SetColor(RGBA(0,0,255,255),DOWNLOAD_PROGRESSVAL);
SetColor(RGBA(0,255,0,255),DOWNLOAD_SELECTOR);
SetColor(RGBA(128,0,128,255),DOWNLOAD_KEYBOARD_OUTLINE);
}
void Yellow(){
SetColor(RGBA(128,128,0,255),DOWNLOAD_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_TEXTBOX_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_FOREGROUND_NO_SELECTOR);
SetColor(RGBA(0,0,255,255),DOWNLOAD_FOREGROUND_SELECTOR);
SetColor(RGBA(0,0,255,255),DOWNLOAD_KEYBOARD_UNSELECT);
SetColor(RGBA(0,0,0,255),DOWNLOAD_TEXTBOX_FOREGROUND);
SetColor(RGBA(255,12,255,255),DOWNLOAD_CURSOR);
SetColor(RGBA(127,0,127,255),DOWNLOAD_PROGRESSBAR_FOREGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_PROGRESSBAR_BACKGROUND);
SetColor(RGBA(0,0,255,255),DOWNLOAD_PROGRESSVAL);
SetColor(RGBA(255,0,0,255),DOWNLOAD_SELECTOR);
SetColor(RGBA(128,0,128,255),DOWNLOAD_KEYBOARD_OUTLINE);
}
void ShiftL1(){
SetColor(RGBA(0,0,255,255),DOWNLOAD_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_TEXTBOX_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_FOREGROUND_NO_SELECTOR);
SetColor(RGBA(0,255,0,255),DOWNLOAD_FOREGROUND_SELECTOR);
SetColor(RGBA(0,255,0,255),DOWNLOAD_KEYBOARD_UNSELECT);
SetColor(RGBA(0,0,0,255),DOWNLOAD_TEXTBOX_FOREGROUND);
SetColor(RGBA(12,255,255,255),DOWNLOAD_CURSOR);
SetColor(RGBA(0,127,127,255),DOWNLOAD_PROGRESSBAR_FOREGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_PROGRESSBAR_BACKGROUND);
SetColor(RGBA(0,255,0,255),DOWNLOAD_PROGRESSVAL);
SetColor(RGBA(255,0,0,255),DOWNLOAD_SELECTOR);
SetColor(RGBA(0,128,128,255),DOWNLOAD_KEYBOARD_OUTLINE);
}
void InvertedColors(){
SetColor(RGBA(0,255,255,255),DOWNLOAD_BACKGROUND);
SetColor(RGBA(0,0,0,255),DOWNLOAD_TEXTBOX_BACKGROUND);
SetColor(RGBA(0,0,0,255),DOWNLOAD_FOREGROUND_NO_SELECTOR);
SetColor(RGBA(255,255,0,255),DOWNLOAD_FOREGROUND_SELECTOR);
SetColor(RGBA(255,255,255,255),DOWNLOAD_KEYBOARD_UNSELECT);
SetColor(RGBA(255,255,255,255),DOWNLOAD_TEXTBOX_FOREGROUND);
SetColor(RGBA(0,243,0,255),DOWNLOAD_CURSOR);
SetColor(RGBA(128,255,128,255),DOWNLOAD_PROGRESSBAR_FOREGROUND);
SetColor(RGBA(0,0,0,255),DOWNLOAD_PROGRESSBAR_BACKGROUND);
SetColor(RGBA(255,255,0,255),DOWNLOAD_PROGRESSVAL);
SetColor(RGBA(255,0,255,255),DOWNLOAD_SELECTOR);
SetColor(RGBA(127,255,127,255),DOWNLOAD_KEYBOARD_OUTLINE);
}
u32 GetColor(int component){
return colors[component];
}
void SetColor(u32 color,int component){
colors[component] = color;
}
void InitColor(int scheme){
//Type Colors
switch(scheme){
case 0:
DefaultColors();
break;
case 1:
InvertedColors();
break;
case 2:
Green();
break;
case 3:
Yellow();
break;
default:
ShiftL1();
break;
}
}
int AddScheme(int val){
if (val<(s-1)){
return val+1;
}
return 0;
}

22
source/colors.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef COLORS_H
#define COLORS_H
#include "settings.h"
u32 GetColor(int component);
static const int DOWNLOAD_BACKGROUND=0; // Originaly Red
static const int DOWNLOAD_TEXTBOX_BACKGROUND=1; //Originaly White
static const int DOWNLOAD_FOREGROUND_NO_SELECTOR=2; // Originaly White
static const int DOWNLOAD_FOREGROUND_SELECTOR=3; // Originaly Blue
static const int DOWNLOAD_KEYBOARD_UNSELECT=4; // Originaly Blue
static const int DOWNLOAD_KEYBOARD_SELECT=5; // Originaly Yellow
static const int DOWNLOAD_TEXTBOX_FOREGROUND=6; // Originaly Black
static const int DOWNLOAD_CURSOR = 7; // Originaly Violet
static const int DOWNLOAD_PROGRESSBAR_FOREGROUND=8; //Originaly Violet
static const int DOWNLOAD_PROGRESSBAR_BACKGROUND=9; //Originaly White
static const int DOWNLOAD_PROGRESSVAL=10; //Originaly Blue
static const int DOWNLOAD_SELECTOR=11; //Originaly Green
static const int DOWNLOAD_KEYBOARD_OUTLINE=12; //Originaly Violet
#define TOTALCOLORS 13
void SetColor(u32 color,int component);
void InitColor(int scheme);
int AddScheme(int val);
#endif

1392
source/main.c Normal file

File diff suppressed because it is too large Load Diff

101
source/settings.c Normal file
View File

@ -0,0 +1,101 @@
#include "settings.h"
int irmode=0;
int UsingIRFeatures(){
return irmode;
}
void SwitchIR(){
if(irmode==0){irmode=1;}else{irmode=0;}
}
FILE* HistoryRead(){
return fopen("/TYTD/history.txt","r");
}
FILE* HistoryAppend(){
return fopen("/TYTD/history.txt","aw");
}
FILE* PlaylistTXT(char* fil){
char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s.txt",fil);
return fopen(file2,"r");
}
int FileSystemDrivers(){
fatInitDefault();
USBStorage_Initialize();
return 0;
}
char* OpenVideoFile(char* filename){
char *yt = malloc(sizeof(char)*530);
snprintf(yt,530,"/TYTD/Videos/%s.mp4",filename);
return yt;
}
void OpenPlaylistFile(char* playlist){
char yt[820];
snprintf(yt,820,"/TYTD/Videos/%s",playlist);
mkdir(yt,0777);
}
char* OpenFile(char* fname2){
char filename[720];
char *yt = malloc(sizeof(char)*820);
char timein[20];
time_t now = time(0);
strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now));
snprintf(filename,720, fname2,timein);
snprintf(yt,820,"/TYTD/Downloads/%s",filename);
return yt;
}
char* OpenPlaylistVideoFile(char* playlist,char* video){
char *yt = malloc(sizeof(char)*820);
snprintf(yt,820,"/TYTD/Videos/%s/%s.mp4",playlist,video);
return yt;
}
char* ThumbnailFileName(char* filename){
char *yt = malloc(sizeof(char) *530);
snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename);
return yt;
}
int ThumbnailExists(char* filename){
char yt[530];
snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename);
struct stat buffer;
return (stat(yt,&buffer)==0);
}
char* ThumbnailURL(char* id){
char *yt = malloc(sizeof(char) *530);
sprintf(yt,"https://img.youtube.com/vi/%s/hqdefault.jpg",id);
return yt;
}
int CreateFolders(){
mkdir("/TYTD",0777); //Downloader
mkdir("/TYTD/Thumbnails",0777); //Thumbnails
mkdir("/TYTD/Downloads",0777); //Downloads
mkdir("/TYTD/Videos",0777); //Videos
mkdir("/TYTD/PLTXT",0777); //create dir for playlist text files
return 0;
}
char* Temp(){
char *yt = malloc(sizeof(char)*530);
snprintf(yt,530,"/TYTD/~TMP");
return yt;
}
void DeleteTemp(){
unlink("/TYTD/~TMP");
}

35
source/settings.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include <fat.h>
#include <unistd.h>
#include <sys/stat.h>
#include <ogc/usbstorage.h>
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <string.h>
#include <time.h>
#include <curl/curl.h>
#include <grrlib.h>
#include "FreeMonoBold_ttf.h"
void OpenPlaylistFile(char* playlist);
char* OpenFile(char* fname);
char* OpenPlaylistVideoFile(char* playlist,char* video);
FILE* HistoryRead();
FILE* HistoryAppend();
int UsingIRFeatures();
int FileSystemDrivers();
char* OpenVideoFile(char* filename);
char* ThumbnailFileName(char* filename);
int ThumbnailExists(char* id);
int CreateFolders();
char* ThumbnailURL(char* id);
FILE* PlaylistTXT(char* fil);
char* Temp();
void DeleteTemp();
void SwitchIR();
#endif