Skip to content

Commit

Permalink
Merge pull request Aeplexi#13 from Aeplexi/main
Browse files Browse the repository at this point in the history
bump
  • Loading branch information
korbosoft authored Jan 26, 2025
2 parents d4523a0 + 7c28b00 commit 49b6323
Show file tree
Hide file tree
Showing 11 changed files with 470 additions and 80 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build HBC

on:
push:
branches: [ "main" ]
branches: [ "**" ]
pull_request:
branches: [ "main" ]
branches: [ "**" ]

jobs:
build:
Expand All @@ -31,4 +31,16 @@ jobs:
uses: actions/upload-artifact@v4
with:
path: "channel/title/channel_retail.wad"
name: The Homebrew Channel
name: The Homebrew Channel (WAD, LULZ)
- name: Publish ELF
uses: actions/upload-artifact@v4
with:
path: "channel/channelapp/channelapp-channel.elf"
name: The Homebrew Channel (ELF, LULZ)
- name: Publish DOL
uses: actions/upload-artifact@v4
with:
path: "channel/channelapp/channelapp-channel.dol"
name: The Homebrew Channel (DOL, LULZ)


3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# The Homebrew Channel
[![Build HBC](https://github.com/Aeplexi/hbc/actions/workflows/build.yml/badge.svg)](https://github.com/Aeplexi/hbc/actions/workflows/build.yml)

Included portions:

Expand Down Expand Up @@ -53,4 +54,4 @@ correct title identity/permissions.
Unless otherwise noted in an individual file header, all source code in this
repository is released under the terms of the GNU General Public License,
version 2 or later. The full text of the license can be found in the COPYING
file.
file.
24 changes: 6 additions & 18 deletions channel/channelapp/source/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ static const char *caption_sort_date;

static const char *l_version;
static const char *l_coder;
static const char *l_release_date;

static const char *string_about_pre;
static const char *string_about_post;
Expand Down Expand Up @@ -129,7 +128,6 @@ void dialogs_theme_reinit (void) {

l_version = _("Version: %s");
l_coder = _("Author: %s");
l_release_date = _("Release Date: %s");
}

void dialogs_init (void) {
Expand Down Expand Up @@ -181,7 +179,6 @@ view * dialog_app (const app_entry *entry, const view *sub_view) {
char *name;
char coder[64];
char version[64];
char release_date[64];
const char *desc;
u16 ym, hm, yb;

Expand All @@ -200,17 +197,12 @@ view * dialog_app (const app_entry *entry, const view *sub_view) {
else
*version = 0;

if (entry->meta && entry->meta->release_date)
snprintf (release_date, sizeof (release_date), l_release_date, entry->meta->release_date);
else
*release_date = 0;

if (entry->meta && entry->meta->long_description)
desc = entry->meta->long_description;
else
desc = app_entry_desc_default;

v = view_new (12, sub_view, (view_width - theme_gfx[THEME_DIALOG]->w) / 2,
v = view_new (11, sub_view, (view_width - theme_gfx[THEME_DIALOG]->w) / 2,
44, TEX_LAYER_DIALOGS, PADS_B);

widget_image(&v->widgets[0], 0, 0, 0, theme_gfx[THEME_DIALOG],
Expand All @@ -231,30 +223,26 @@ view * dialog_app (const app_entry *entry, const view *sub_view) {
theme_gfx[THEME_DIALOG]->w - 72 - APP_ENTRY_ICON_WIDTH,
FA_LEFT, FA_ASCENDER, FONT_LABEL);

widget_label (&v->widgets[5], 48 + APP_ENTRY_ICON_WIDTH, 90, 1, release_date,
theme_gfx[THEME_DIALOG]->w - 72 - APP_ENTRY_ICON_WIDTH,
FA_LEFT, FA_ASCENDER, FONT_LABEL);

yb = theme_gfx[THEME_DIALOG]->h - theme_gfx[THEME_BUTTON_TINY]->h - 16;
ym = 48 + APP_ENTRY_ICON_HEIGHT + 8;
hm = yb - ym - 8;

widget_memo_deco (&v->widgets[6], 32, ym, 1,
widget_memo_deco (&v->widgets[5], 32, ym, 1,
theme_gfx[THEME_DIALOG]->w - 64, hm, desc, FA_LEFT);

gap = (theme_gfx[THEME_DIALOG]->w -
theme_gfx[THEME_BUTTON_TINY]->w * 3) / 4;

x = gap;
widget_button (&v->widgets[9], x, yb, 1, BTN_TINY, caption_delete);
widget_button (&v->widgets[8], x, yb, 1, BTN_TINY, caption_delete);

x += gap + theme_gfx[THEME_BUTTON_TINY]->w;
widget_button (&v->widgets[10], x, yb, 1, BTN_TINY, caption_load);
widget_button (&v->widgets[9], x, yb, 1, BTN_TINY, caption_load);

x += gap + theme_gfx[THEME_BUTTON_TINY]->w;
widget_button (&v->widgets[11], x, yb, 1, BTN_TINY, caption_back);
widget_button (&v->widgets[10], x, yb, 1, BTN_TINY, caption_back);

view_set_focus (v, 11);
view_set_focus (v, 10);

return v;
}
Expand Down
76 changes: 76 additions & 0 deletions channel/channelapp/source/fileops.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <stdio.h>
#include <string.h>
#include <malloc.h>

#include "fileops.h"

static struct stat st;

bool FSOPFileExists(const char* file)
{
return !stat(file, &st) && !S_ISDIR(st.st_mode);
}

bool FSOPFolderExists(const char* path)
{
return !stat(path, &st) && S_ISDIR(st.st_mode);
}

size_t FSOPGetFileSizeBytes(const char* path)
{
if (stat(path, &st) < 0) return 0;

return st.st_size;
}

void FSOPDeleteFile(const char* file)
{
if (FSOPFileExists(file))
remove(file);
}

void FSOPMakeFolder(const char* path)
{
if (FSOPFolderExists(path))
return;

char* pos = strchr(path, '/');
s32 current = pos - path;
current++;
pos = strchr(path + current, '/');

while (pos)
{
*pos = 0;
mkdir(path, S_IREAD | S_IWRITE);
*pos = '/';

current = pos - path;
current++;
pos = strchr(path + current, '/');
}

mkdir(path, S_IREAD | S_IWRITE);
}

s32 FSOPReadOpenFile(FILE* fp, void* buffer, u32 offset, u32 length)
{
fseek(fp, offset, SEEK_SET);
return fread(buffer, length, 1, fp);
}

s32 FSOPReadOpenFileA(FILE* fp, void** buffer, u32 offset, u32 length)
{
*buffer = memalign(32, length);
if (!*buffer)
return -1;

s32 ret = FSOPReadOpenFile(fp, *buffer, offset, length);
if (ret <= 0)
{
free(*buffer);
*buffer = NULL;
}

return ret;
}
18 changes: 18 additions & 0 deletions channel/channelapp/source/fileops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef __FILEOPS_H__
#define __FILEOPS_H__

#include <sys/stat.h>
#include <dirent.h>
#include <ogcsys.h>

bool FSOPFileExists(const char* file);
bool FSOPFolderExists(const char* path);
size_t FSOPGetFileSizeBytes(const char* path);

void FSOPDeleteFile(const char* file);
void FSOPMakeFolder(const char* path);

s32 FSOPReadOpenFile(FILE* fp, void* buffer, u32 offset, u32 length);
s32 FSOPReadOpenFileA(FILE* fp, void** buffer, u32 offset, u32 length);

#endif
114 changes: 70 additions & 44 deletions channel/channelapp/source/m_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "m_main.h"
#include "title.h"
#include "wiiinfo.h"
#include "nand.h"
#include "fileops.h"

#define TITLE_UPPER(x) (u32)(x >> 32)
#define TITLE_LOWER(x) (u32)(x & 0xFFFFFFFF)
Expand Down Expand Up @@ -59,51 +61,75 @@ static bool bootmii_is_installed(u64 title_id) {
return ret;
}

static bool priiloader_is_installed(u64 title_id) {

u32 tmd_size;
static u8 tmd_buf[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
static signed_blob *mTMD;
static tmd *rTMD;
char TMD_Path[ISFS_MAXPATH];
char TMD_Path2[ISFS_MAXPATH];

//IOS Shit Done
//read TMD so we can get the main booting dol
s32 fd = 0;
u32 id = 0;
bool ret = false;
memset(TMD_Path,0,64);
memset(TMD_Path2,0,64);
sprintf(TMD_Path, "/title/%08x/%08x/content/title.tmd",TITLE_UPPER(title_id),TITLE_LOWER(title_id));
sprintf(TMD_Path2, "/title/%08x/%08x/content/title_or.tmd",TITLE_UPPER(title_id),TITLE_LOWER(title_id));
fd = ES_GetStoredTMDSize(title_id,&tmd_size);
if (fd < 0)
{
gprintf("Unable to get stored tmd size");
}
mTMD = (signed_blob *)tmd_buf;
fd = ES_GetStoredTMD(title_id,mTMD,tmd_size);
if (fd < 0)
{
gprintf("Unable to get stored tmd");
}
rTMD = (tmd*)SIGNATURE_PAYLOAD(mTMD);
for(u8 i=0; i < rTMD->num_contents; ++i)
{
if (rTMD->contents[i].index == rTMD->boot_index)
{
id = rTMD->contents[i].cid;
break;
}
}
if (id == 0)
{
gprintf("Unable to retrieve title booting app");
}
static u32 GetSysMenuBootContent(void)
{
s32 ret;
u32 cid = 0;
u32 size = 0;
signed_blob *s_tmd = NULL;

ret = ES_GetStoredTMDSize(0x100000002LL, &size);
if (!size)
{
printf("Error! ES_GetStoredTMDSize failed (ret=%i)\n", ret);
return 0;
}

s_tmd = memalign(32, size);
if (!s_tmd)
{
printf("Error! Memory allocation failed!\n");
return 0;
}

ret = ES_GetStoredTMD(0x100000002LL, s_tmd, size);
if (ret < 0)
{
printf("Error! ES_GetStoredTMD failed (ret=%i)\n", ret);
free(s_tmd);
return 0;
}

tmd *p_tmd = SIGNATURE_PAYLOAD(s_tmd);

for (int i = 0; i < p_tmd->num_contents; i++)
{
tmd_content* content = &p_tmd->contents[i];
if (content->index == p_tmd->boot_index)
{
cid = content->cid;
break;
}
}

free(s_tmd);
if (!cid) printf("Error! Cannot find system menu boot content!\n");

return cid;
}

ret = id;
return ret;
bool GetSysMenuExecPath(char path[ISFS_MAXPATH], bool mainDOL)
{
u32 cid = GetSysMenuBootContent();
if (!cid) return false;

if (mainDOL) cid |= 0x10000000;
sprintf(path, "/title/00000001/00000002/content/%08x.app", cid);

return true;
}

bool priiloader_is_installed()
{
char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(0x20);

if (!GetSysMenuExecPath(path, true))
return false;

u32 size = 0;
NANDGetFileSize(path, &size);

return (size > 0);
}

// todo: move to diff file!
Expand Down
12 changes: 6 additions & 6 deletions channel/channelapp/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,9 @@ void main_real(void) {
continue;
}

widget_scroll_memo_deco (&v_detail->widgets[6], mm);
widget_scroll_memo_deco (&v_detail->widgets[5], mm);

if ((bd & PADS_A) && v_detail->focus == 11) {
if ((bd & PADS_A) && v_detail->focus == 10) {
dialog_fade (v_current, false);

v_current = v_browser;
Expand All @@ -681,7 +681,7 @@ void main_real(void) {
continue;
}

if ((bd & PADS_A) && v_detail->focus == 9) {
if ((bd & PADS_A) && v_detail->focus == 8) {
dialog_fade (v_current, false);

v_current = v_browser;
Expand All @@ -705,7 +705,7 @@ void main_real(void) {
continue;
}

if ((bd & PADS_A) && v_detail->focus == 10) {
if ((bd & PADS_A) && v_detail->focus == 9) {
dialog_fade (v_current, false);

v_current = v_browser;
Expand Down Expand Up @@ -764,7 +764,7 @@ void main_real(void) {
}

if ((frame > 60 * 2) && (frame % 3) == 0)
widget_scroll_memo (&v_current->widgets[3], -1);
widget_scroll_memo (&v_current->widgets[2], -1);
}
}

Expand Down Expand Up @@ -864,4 +864,4 @@ int main(int argc, char *argv[]) {
main_real();
gprintf("uh oh\n");
return 0;
}
}
Loading

0 comments on commit 49b6323

Please sign in to comment.