Skip to content

Instantly share code, notes, and snippets.

#ifndef OOB_H_GUARD
#define OOB_H_GUARD
#include <linealg.h>
struct OOB_LineSeg
{
Vector4f v1, v2;
};
@Madsy
Madsy / gist:6980061
Last active January 15, 2024 10:04
Working multi-threading two-context OpenGL example with GLFW 3.0.3 and GLEW 1.8
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <vector>
#include <cmath>
#include <cstdio>
#include <limits>
#include <chrono>
#include <thread>
#include <mutex>
@Madsy
Madsy / gist:3898990
Created October 16, 2012 12:33
Problem: Fill convention is correct (each pixel belongs to one triangle), but the texture is sometimes "swimming".
static void drawScanLine(dstBuffer,
width,
height,
y,
x1, x2,
z1, z2,
w1, w2,
s1, s2,
t1, t2)
{
@Madsy
Madsy / gist:1088393
Created July 18, 2011 02:07
Fixedpoint versions of ln, pow, exp, sqrt and division
/*
Copyright (c) 2011, Mads A. Elvheim
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the

How to build wine2.9 staging which supports Blizzard's Overwatch

Overview

gamax92's wine repo has the DirectX11 overwatch patches already applied. We need to build this version of Wine with WOW64 support. That is, the 64-bit version of wine which also supports 32-bit Windows programs. In so many words: if your CPU is 32-bit only, don't bother and you couldn't run Overwatch anyway.

Building wine with WOW64 support requires boostrapping the final build. The three stages look like:

  1. Build the 64-bit version of wine (pass --enable-win64 to ./configure)
/*
Conditional pattern:
teq (root)
-teq
Equivalent C code:
*/
if(root){
} else {
if(-teq_0){
const SerialPort = require('serialport');
const fs = require('fs');
//request reset on address /?9999999
let request_init = [ 0x2f, 0x3f, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x21, 0x0d, 0x0a ];
//select register "51"
let request_select_register_51 = [0x06, 0x30, 0x35, 0x31, 0x0d, 0x0a];
//.R1.0030().
let request_register_R1_30 = [
local data_raw = require("data_raw");
local json = require ("dkjson");
local str = json.encode (data_raw, { indent = true });
local current_outFile = io.output();
io.output("data_raw.js");
io.output():write(str);
io.output():flush();
io.output():close();
io.output(current_outFile);
os.exit(0);
@Madsy
Madsy / build-65816-gas-toolchain.sh
Last active April 2, 2019 19:39
SNES 'lorom' toolchain.
#!/bin/bash
PREFIX=$(HOME)/snes-toolchain
#clone binutils development branch
git clone git://sourceware.org/git/binutils-gdb.git binutils-gdb
cd binutils-gdb
# Checkout a *very* old binutils commit from 2005, as gas support for the coff-w65 target was discontinued a long time ago.
# This version is the best one I found so far.
git checkout 0fdc72dad81fc7f32b898cb408da0300667f728b
void S_to_bit_vector(u32* S, int count, u32* out){
for(int i = 0; i < count; i++){
//assuming 32-bit integers
u32 integer_index = S[i] / 32u;
//mask all bits that fit
u32 bit_index = S[i] & 31;
out[integer_index] |= 1<<bit_index;
}
}