Skip to content

Instantly share code, notes, and snippets.

@FaultyPine
FaultyPine / gist:567b0a089e4737951b8640843697aeac
Last active August 17, 2025 05:44
Overlapping virtual memory views win32
struct VirtualAllocation
{
void* data;
HANDLE mapping;
size_t size;
};
VirtualAllocation CreatePlaceholderVirtualAllocation(uint64_t size)
{
BOOL result;
@FaultyPine
FaultyPine / download_clang.bat
Created February 22, 2025 19:27
Download + unzip clang binaries batch script
@echo off
setlocal
@REM https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz
@REM note the "tools" directory, which was specific to my project
start /wait /b powershell -command "Start-BitsTransfer -Source https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz -Destination tools/clang.tar.xz"
IF %ERRORLEVEL% NEQ 0 (echo Error:%ERRORLEVEL% && exit /b)
@REM start /wait /b powershell -command "Expand-Archive tools/clang.zip tools/clang_inner"
@FaultyPine
FaultyPine / gist:b4230b54435ec27dd9895e6ced69d160
Last active January 4, 2025 18:28
Batch snippets I've used in the past that I've found useful
@echo off
setlocal ENABLEDELAYEDEXPANSION
:: unpack cmd line args
for %%a in (%*) do set "%%a=1"
set root=%~dp0
:: remove trailing backslash
set root=%root:~0,-1%
@FaultyPine
FaultyPine / names.h
Created October 26, 2022 23:19
C++ Enums with String Representation
REGISTER_ENUM(MSG_PlayerSighted)
REGISTER_ENUM(MSG_HeardSound)
REGISTER_ENUM(MSG_SetTarget)
REGISTER_ENUM(MSG_Arrived)
REGISTER_ENUM(MSG_Reset)
@FaultyPine
FaultyPine / ToonShading.shader
Created August 3, 2021 16:45
Toon Shader for URP 11.0
Shader "Pine/ToonShading"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[MainColor] _Color ("Main Color", Color) = (1,1,1,1)
[HDR] _AmbientColor ("Ambient Color", Color) = (0.4, 0.4, 0.4, 1)
[HDR] _SpecularColor ("Specular Color", Color) = (0.9, 0.9, 0.9, 1)
_Glossiness ("Glossiness", Range(0, 100)) = 32
[HDR] _RimColor ("Rim Color", Color) = (1,1,1,1)
@FaultyPine
FaultyPine / lib.rs
Created January 20, 2021 19:34
Laggy Smash
#![feature(proc_macro_hygiene)]
use smash::lib::lua_const::*;
const PERCENT_CHANCE_FOR_LAG: i32 = 5; // 5% chance for lag on every frame
const LAG_SPIKE_DURATION_RANGE: i32 = 75; // Max "lag spike" is 75 miliseconds.
pub fn sys_line(fighter: &mut smash::lua2cpp::L2CFighterCommon) {
unsafe {
let lua_state = fighter.lua_state_agent;
@FaultyPine
FaultyPine / lib.rs
Created June 20, 2020 22:23
ACMD POC
#![feature(proc_macro_hygiene)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![allow(dead_code)]
#![allow(unused_parens)]
@FaultyPine
FaultyPine / sys_line_system_control_fighter.rs
Created June 15, 2020 03:17
Moonwalks... mostly. Might have some issues here and there idk :)
/*
Calling this function in smash::lua2cpp::L2CFighterCommon_sys_line_system_control_fighter
this isn't a copy-paste type deal... theres stuff like get_player_number that is left out.
If your looking to implement this yourself and don't know/understand how to do so, feel free to ask me!
*/
static mut moonwalk_mul: [f32;8] = [1.0;8];
unsafe fn moonwalks(boma: &mut app::BattleObjectModuleAccessor, status_kind: i32, stick_value_x: f32, facing: f32) {
/* Moonwalk melee calculation: (stick_pos.x * run_accel_mul) + (sign(stick_pos.x) * run_accel_add) */
@FaultyPine
FaultyPine / lib.rs
Created June 4, 2020 19:51
CustomDI Source code
#![feature(proc_macro_hygiene)]
#![allow(non_snake_case)]
use skyline::nro::{self, NroInfo};
use smash::app::{self, lua_bind::*, sv_system};
use smash::lib::{lua_const::*, L2CValue};
use smash::lua2cpp::L2CFighterCommon;
fn get_category(boma: &mut app::BattleObjectModuleAccessor) -> i32{
return (boma.info >> 28) as u8 as i32;
@FaultyPine
FaultyPine / script_replacement.h
Created March 19, 2020 01:42
Random Attack Values Mod
/*
All credits to jugeeya for implementing this ATTACK replacement. I simply did the random number-related stuff.
Also, don't forget to call script_replacement(); in main somewhere if you are trying to recreate/compile the mod yourself.
*/
#include <switch_min.h>
#include <stdint.h>
#include <stdlib.h>