Skip to content

Instantly share code, notes, and snippets.

@hwei
hwei / cavesh3.c
Created January 29, 2012 13:24
cave sh3 driver for mame 0144u6 mame plus r4973
/*
Cave CV1000 hardware
Games by Cave ID number:
CA011 Mushihime-Sama
CA012 Ibara
CA012B Ibara Kuro Black Label
CA013 Espgaluda II
@hwei
hwei / makelist.c
Created January 29, 2012 13:35
build file for mame plus r4973 and Mac OSX
/***************************************************************************
makelist.c
Create and sort the driver list.
****************************************************************************
Copyright Aaron Giles
All rights reserved.
@hwei
hwei / const_fvn_hash.cpp
Last active December 4, 2022 20:39
C++ 32bit FNV-1a string hashing. Support both compile-time and runtime calulations.
// C++ 32bit FNV-1a string hashing.
// Support both compile-time and runtime calulations.
// This implementation also hashes '\0' terminator.
// Requires a compiler with C++11 support.
// See main for examples.
#include <iostream>
namespace hardrock
@hwei
hwei / gist:c1eae657b44f3436702a
Created April 27, 2015 09:26
Convert matcap to cubemap (Unity 5.0)
using UnityEngine;
using UnityEditor;
public class MatcapToCubemap : ScriptableWizard {
public Texture matcap;
public float emissionScale = 1f;
public int size = 256;
void OnWizardUpdate () {
this.isValid = this.matcap != null;
@hwei
hwei / vertex_color.shader
Created May 20, 2015 06:46
Vertex color shader for Unity3D
Shader "G42/vertex_color" {
SubShader {
Tags { "RenderType"="Opaque" }
Lighting Off
BindChannels {
Bind "Color", color
}
Pass {
SetTexture[_] {
@hwei
hwei / CombineTextureFrames.cs
Created June 2, 2015 01:58
Combine Texture Frames Tool for Unity 5
using UnityEngine;
using UnityEditor;
using System.Linq;
public class CombineTextureFrames : ScriptableWizard {
public Texture2D[] textures;
public Vector2 frameSize;
public Vector2 layout;
@hwei
hwei / depth_field.c
Last active September 29, 2015 02:18
Signed Distance Field Font Tools
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define STBI_ONLY_PNG
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
@hwei
hwei / BakeSpriteAtlas.cs
Created April 21, 2016 03:02
Replace Unity sprite packing with custom atlas.
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
public class BakeSpriteAtlas : EditorWindow
{
const string TITLE = "Bake Sprite Atlas";
[MenuItem ("Window/" + TITLE)]
@hwei
hwei / spRunOpList.js
Created April 14, 2020 02:41
Cosmos DB stored procedures for general transactions
function spRunOpList(opList) {
const ERROR_CODE = {
BAD_REQUEST: 400,
NOT_FOUND: 404,
CONFLICT: 409,
NOT_ACCEPTED: 499
}
const collection = getContext().getCollection()
const collectionLink = collection.getSelfLink()
@hwei
hwei / CustomTextureImporter.cs
Created January 26, 2022 04:28
How to create a custom texture importer to fix GUI alpha gamma for Unity
using System;
using System.Reflection;
using UnityEditor;
using UnityEditor.AssetImporters;
using UnityEngine;
namespace Hwei.AssetTools
{
[CustomEditor(typeof(TextureImporter))]
public class CustomTextureImporter : Editor