Skip to content

Instantly share code, notes, and snippets.

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

ITotalJustice

💜
Coding away...
View GitHub Profile
#!/usr/bin/python
from ftplib import FTP
from io import BytesIO
# pip install python-slugify
from slugify import slugify
import argparse
import time
parser = argparse.ArgumentParser()
#include "png.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
static void crc32_to_buf(uint8_t* buf, const uint8_t* in, size_t len) {
const uint32_t c = crc32(0, in, len);
@ITotalJustice
ITotalJustice / SDL_memory_map.c
Last active October 5, 2024 04:18
mmap for sdl3
#include "SDL_memory_map.h"
#include <SDL3/SDL.h>
// #include "SDL_internal.h"
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
@ITotalJustice
ITotalJustice / hideable_menubar.cpp
Created October 4, 2024 19:57
hides menu bar when the area isn't hovered / selected.
void menubar() {
static float menubar_height = 30.0;
const auto& io = ImGui::GetIO();
const auto flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize;
const auto window_pos = ImVec2(0, 0);
const auto window_size = ImVec2(io.DisplaySize.x, menubar_height);
ImGui::SetNextWindowPos(window_pos);
ImGui::SetNextWindowSize(window_size);
ImGui::SetNextWindowBgAlpha(0);
@ITotalJustice
ITotalJustice / ring_buf.c
Last active September 30, 2024 14:44
ring buffer from gba fifo
struct RingBuf
{
uint32_t buf[8];
uint32_t r_index;
uint32_t w_index;
};
static void ringbuf_reset(struct RingBuf* ring)
{
ring->r_index = ring->w_index;
@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 November 29, 2024 08:10
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;