Skip to content

Instantly share code, notes, and snippets.

@JohnnyonFlame
JohnnyonFlame / ds34usb.c
Last active January 14, 2022 22:05
PADEMU IOP Driver for the XBOX 360 wireless receiver.
#include "types.h"
#include "loadcore.h"
#include "stdio.h"
#include "sifrpc.h"
#include "sysclib.h"
#include "usbd.h"
#include "usbd_macro.h"
#include "thbase.h"
#include "thsemap.h"
#include "ds34usb.h"
@JohnnyonFlame
JohnnyonFlame / aob.cpp
Last active August 3, 2023 04:55
Compile-time parsed AOB patterns example
/*
# Do what the fuck you want to public license
Version 2, December 2004
Copyright (C) `2021` `Johnny on Flame`
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@JohnnyonFlame
JohnnyonFlame / build.sh
Created November 8, 2021 06:40
Empty libcurl-gnutls.so.4 stub
#!/bin/bash
gcc -c empty.c -o empty.o -m32
gcc -fPIC -shared -Wl,-soname,libcurl-gnutls.so.4 empty.o -o libcurl-gnutls.so.4 -m32
@JohnnyonFlame
JohnnyonFlame / POTNewTextureRepacker.csx
Created October 15, 2021 00:44
Power of Two NewTextureRepacker.csx
// Texture Repacker by JohnnyonFlame
// Licensed under GPLv3 for UndertaleModTool
// This script is meant to be edited by the user - search for "User Configurable".
// By allowing you to layout assets into different page sizes, this script can fix
// or significantly lower stuttering on low end hardware due to high VRAM and
// Texture Streaming pressure.
// Special thanks to:
// Jukka Jylänki (2010), for "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing"
@JohnnyonFlame
JohnnyonFlame / NewTextureRepacker.csx
Last active October 8, 2021 19:31
wip texture repacker for UTMT
// Texture Repacker by JohnnyonFlame
// Licensed under GPLv3 for UndertaleModTool
// This script is meant to be edited by the user - search for "User Configurable".
// By allowing you to layout assets into different page sizes, this script can fix
// or significantly lower stuttering on low end hardware due to high VRAM and
// Texture Streaming pressure.
// Special thanks to:
// Jukka Jylänki (2010), for "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing"
@JohnnyonFlame
JohnnyonFlame / binpack.cs
Last active October 8, 2021 05:55
A C# binpacker.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program
{
public class Rect
{
@JohnnyonFlame
JohnnyonFlame / plt0.c
Last active May 15, 2021 18:32
Human-parseable symbol resolution errors
//Iterates each symbol that is either in .rel.dyn or .rel.plt sections
#define FOREACH_REL(func) \
for (int i = 0; i < elf_hdr->e_shnum; i++) { \
char *sh_name = shstrtab + sec_hdr[i].sh_name; \
if (strcmp(sh_name, ".rel.dyn") == 0 || strcmp(sh_name, ".rel.plt") == 0) { \
Elf32_Rel *rels = (Elf32_Rel *)((uintptr_t)text_base + sec_hdr[i].sh_addr); \
for (size_t j = 0; j < sec_hdr[i].sh_size / sizeof(Elf32_Rel); j++) { \
uintptr_t *ptr = (uintptr_t *)(text_base + rels[j].r_offset); \
Elf32_Sym *sym = &syms[ELF32_R_SYM(rels[j].r_info)]; \
int type = ELF32_R_TYPE(rels[j].r_info); \
@JohnnyonFlame
JohnnyonFlame / calc.py
Created April 26, 2021 21:15
SSA ZExt/SExt flags calculator
from itertools import product
def F(x):
# <zear> 0000.0xxx - Z && E
# <zear> 0000.1xxx - Z
# <pcercuei> 1111.0xxx -
# <pcercuei> 1111.1xxx - E
return ['ZE', 'Z ', ' ', ' E'][x]
bits = [0b00, 0b01, 0b10, 0b11]
for (Rs, Rt) in product(bits, repeat=2):
@JohnnyonFlame
JohnnyonFlame / gles2_bridge.h
Last active April 8, 2021 14:28
GLES2 Loader/Bridge Helpers (e.g. for softfp->hardfp bridging)
#ifndef __GLES2_BRIDGE_H__
#define __GLES2_BRIDGE_H__
// GL_APICALL ([\w\s]+) (\*?)GL_APIENTRY (\w+) \(([^)]+)\);
// GL_FWD($3, $1$2, (), ($4))
#define GLES2_BRIDGE \
GB_DECL_FWD(glActiveTexture, void, (texture), (GLenum texture)) \
GB_DECL_FWD(glAttachShader, void, (program, shader), (GLuint program, GLuint shader)) \
GB_DECL_FWD(glBindAttribLocation, void, (program, index, name), (GLuint program, GLuint index, const GLchar *name)) \
GB_DECL_FWD(glBindBuffer, void, (target, buffer), (GLenum target, GLuint buffer)) \
@JohnnyonFlame
JohnnyonFlame / sdlglesgears.c
Created March 17, 2021 16:44
sdlglesgears test sample
/*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*