Skip to content

Instantly share code, notes, and snippets.

View ITotalJustice's full-sized avatar
💜
Coding away...

ITotalJustice

💜
Coding away...
View GitHub Profile
@ITotalJustice
ITotalJustice / scheduler.c
Last active February 27, 2024 17:20
c99 scheduler, very fast, converted from my c++23 impl
#include "scheduler.h"
#include <stdbool.h>
#include <assert.h>
#ifndef SCHEDULER_UNUSED
#define SCHEDULER_UNUSED(x) (void)(x)
#endif // SCHEDULER_UNUSED
// this is the value that events are set to when disabled
enum { SCHEDULER_DISABLE_VALUE = INT_MAX };
/*
io_ezfo.c
Hardware Routines for reading the EZ Flash Omega filesystem
*/
#include "io_ezfo.h"
#include <gba_dma.h>
// Copyright 2022 TotalJustice.
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#ifndef SCHEDULER_USE_BOOST
#define SCHEDULER_USE_BOOST 1
#endif
// set this to 0 if the scheduler can be empty, 1 by default
// due to the reset event always being set!
@ITotalJustice
ITotalJustice / gci.cpp
Last active December 22, 2023 20:08
test code to ensure proper xci installs work :)
#include <switch.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cstdarg>
#include <vector>
#include <memory>
#include <bit>
#include <experimental/scope>
// SOURCE: https://github.com/nba-emu/NanoBoyAdvance/blob/master/src/platform/core/src/device/shader/color_agb.glsl.hpp
// GODBOLT: https://godbolt.org/z/1cfaedavK
#include <cstdint>
#include <cmath>
#include <algorithm>
uint32_t gba_shader(uint16_t bgr555) {
constexpr auto darken_screen = 1.0;
constexpr auto target_gamma = 2.2;
@ITotalJustice
ITotalJustice / main.c
Created September 16, 2023 16:49
n64 main.c, will commit eventually when im done with changes
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <libdragon.h>
#include <sms.h>
// todo: use timer_ticks() for benchmarking
// add timer_ticks() after functions and log the diff
// then sort the logs that way.
@ITotalJustice
ITotalJustice / hbloader_system.c
Created June 6, 2023 23:48
hbloader, modified to launch nro using path in romfs, and exits correctly. size optimised :)
#include <switch.h>
#include <string.h>
#include <stdlib.h>
static char g_argv[2048];
static char g_nextArgv[2048];
static char g_nextNroPath[FS_MAX_PATH];
static enum {
CodeMemoryUnavailable = 0,
@ITotalJustice
ITotalJustice / nro_scan_new.cpp
Created June 5, 2023 17:44
nro scanning code. new code is faster by 0.07 seconds (64 entries, 48 nros) total time 0.30 seconds
auto nro_parse(FsFileSystem* fs, const char* path, const char* star_path, NroEntry& entry) -> bool {
Result rc{};
FsFile f{};
u64 bytes_read{};
if (R_FAILED(rc = fsFsOpenFile(fs, path, FsOpenMode_Read, &f))) {
// std::printf("failed to open: %s\n", path);
return false;
}
#include "minGlue.h"
#include <string.h>
static bool ini_open(const char* filename, struct NxFile* nxfile, u32 mode) {
Result rc = {0};
char filename_buf[FS_MAX_PATH] = {0};
if (R_FAILED(rc = fsOpenSdCardFileSystem(&nxfile->system))) {
return false;
}
@ITotalJustice
ITotalJustice / emummc_detection.cpp
Last active May 20, 2023 22:49
example of how to detect emunand
struct EmummcPaths {
char unk[0x80];
char nintendo[0x80];
};
void smcAmsGetEmunandConfig(EmummcPaths* out_paths) {
SecmonArgs args{};
args.X[0] = 0xF0000404; /* smcAmsGetEmunandConfig */
args.X[1] = 0; /* EXO_EMUMMC_MMC_NAND*/
args.X[2] = (u64)out_paths; /* out path */