Skip to content

Instantly share code, notes, and snippets.

View jdryg's full-sized avatar

Jim Drygiannakis jdryg

View GitHub Profile
@jdryg
jdryg / ColorUtil.cs
Last active August 29, 2015 14:18
Rainbow Gradient
using System;
using System.Drawing;
public class ColorUtil
{
public static Color GetRainbowColor(float percentage)
{
// The code below tries to mimick Matlab's color gradient. A naive implementation which
// linearly interpolates hue, ends up with a very large range mapped to greenish colors
// and we cannot distinguish different regions easily.
var ENABLE_LOGGING = true;
// Addressing modes
var ADDR_IMPLIED = 0;
var ADDR_ACCUMULATOR = 1;
var ADDR_IMMEDIATE = 2;
var ADDR_ZERO_PAGE = 3;
var ADDR_ZERO_PAGE_X = 4;
var ADDR_ZERO_PAGE_Y = 5;
var ADDR_RELATIVE = 6;
@jdryg
jdryg / bios.asm
Created January 31, 2017 18:12
Tiny BIOS for an i8080 system
.ORG 0x0000
LF EQU 0x0A
CR EQU 0x0D
EOS EQU 0x24; '$'
STACK EQU 0x80FF
TERMINAL EQU 0xF000
CARET_ADDR EQU 0xEFFE
JMP boot ;
NOP ;
@jdryg
jdryg / link.lds
Created August 17, 2017 12:17
Linker script problem
@jdryg
jdryg / imgui_keyboard_input.inl
Last active August 19, 2017 14:00
ImGui KeyboardInput() widget
namespace ImGui
{
bool KeyboardInput(const char* label, char* buf, unsigned int buf_size, const ImVec2& size_arg, bool is_editable)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems) {
return false;
}
ImGuiContext& g = *GImGui;
@jdryg
jdryg / color_circle.cpp
Created February 24, 2018 16:55
Color circle
static float colorCirclePos[512];
static vg::Color colorCircleColor[256];
static uint16_t colorCircleIndices[765];
static bool colorCircleReady = false;
if (!colorCircleReady) {
// Center of the circle
colorCirclePos[0] = 0.0f;
colorCirclePos[1] = 0.0f;
colorCircleColor[0] = vg::ColorRGBA::White;
@jdryg
jdryg / benchmark.cpp
Last active April 2, 2018 07:25
strokerConvexFillAA (benchmark)
#include <stdint.h>
#include <inttypes.h>
#include <math.h>
#include <malloc.h>
#include <memory.h>
#include <Windows.h>
#include <stdio.h>
#include <xmmintrin.h>
#include <immintrin.h>
@jdryg
jdryg / cullrects_benchmark.cpp
Created April 20, 2018 16:55
cullRects SIMD benchmark
#define TEST_SIMD 3
struct Rect
{
float minx, miny;
float maxx, maxy;
};
struct RectSoA
{
@jdryg
jdryg / _instructions.md
Last active August 14, 2018 17:15
bgfx shader custom MSBuild rule for VS2013

Installation

  1. Download all 3 files and place them at the same folder as your VS solution
  2. Build shaderc and move the executable to the same folder. If you get the original executable from the build directory, remember to rename it to shaderc.exe instead of shadercRelease.exe
  3. Open your solution into VS, right click on the project and select Build Dependencies > Build Customizations...
  4. Click Find existing... and select the bgfxshader.targets file you just created
  5. Add .sc files to your project and they should be treated as bgfx shaders

To verify that the new target works correctly you can right click on an .sc file and select Properties. Item Type property should read "bgfx Shader"

@jdryg
jdryg / testbench.lua
Created January 12, 2019 17:54
Graphics on a character LCD
local COLS = 20;
local ROWS = 4;
local CHAR_WIDTH = 5;
local CHAR_HEIGHT = 8;
local WAIT_ANIM = 0;
function wait(n)
for i=1,n do
simulate();