Skip to content

Instantly share code, notes, and snippets.

View phire's full-sized avatar

Scott Mansell phire

View GitHub Profile
from construct import *
def sizeof_struct(subcon, value, parent=None):
ctx = Container(value)
ctx._ = parent or Container()
ctx._params = Container()
ctx._parsing = False
ctx._sizing = True
ctx._building = False
@phire
phire / gist:e9752c3ff0ffc0db07f7960e70e7f22a
Created March 23, 2024 19:00
Interesting Gamecube patents
EP1189173A2 - Highly detailed XF pipeline
US6489963 - graphics api
US6580430 - fog
US6618048 near-far clipping
US6636214 - early depth (shows graphics pipeline)
US6664962 - shadow mapping (technique)
US6700586 - XF pipeline
US6717577 - Early vertex cache? might not be gamecube
US7034828 - tev
US7071945 - CP commands and vertex formats
@phire
phire / make.py
Created June 19, 2023 18:16
Custom metabuild system
#!/usr/bin/env python3
# Story time:
# I tend to use cmake for projects these days, but I'm not excatly happy with it's support
# for cross-compiling. Sure, it's flexible enough that you do almost anything, but anything
# advanced (like compiling host tools or building multiple platforms simultaneously)
# requires janky usage of external projects.
# So I set aside some time to explore other build systems to find one that better supported
# my needs.
# I spent some time exploring meson, it had first-party understanding of compiling host tools
@phire
phire / alternate2.cpp
Last active September 16, 2021 19:49
#include <FEXThunkDefs.h> // provides fexgen_config in this model
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
// For each exported function:
fexgen_config exports[] = {
// Variadic functions: The variadic parameters are automatically packed into an unsigned long array
@phire
phire / literalfn.hpp
Created June 17, 2021 09:24
Literal std::function experment. Can be passed as template argument.
#include <type_traits>
#include <utility>
template<class ReturnType, class...Xs>
struct CallableBase {
virtual ReturnType operator()(Xs...) const = 0;
virtual ReturnType operator()(Xs...) = 0;
virtual void copy(void*) const = 0;
};
%ifdef CONFIG
{
"Match": "All",
"RegData": {
"MM7": ["0xfb53d1c000000000", "0x4002"]
}
}
%endif
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdatomic.h>
#include <stdlib.h>
atomic_int count = 0;
void sig_handler(int signum) {
printf("Alarm %i\n", count++);
0001/0:0001: #version 120
0002/0:0002: #define GL2
0003/0:0003: #define texture texture2D
0004/0:0004: #define VSIN(index) attribute
0005/0:0005: #define VSOUT varying
0006/0:0006: #define FSIN varying
0007/0:0007: #define FRAGCOLOR(c) (gl_FragColor = c)
0008/1:0001: #define DIRECTIONALS
0009/1:0002: //#define POINTLIGHTS
MESA_SHADER_FRAGMENT prog 25/1 QPU:
0x3e90f186bb800000 nop ; nop ; ldvary.r3; wrtmuc (tex[0].p0 | 0x3)
0x56403106bbcc0000 nop ; fmul r4, r3, rf0 ; wrtmuc (tex[0].p1 | 0x0)
0x3dd0054805fec000 fadd rf8, r4, r5 ; mov rf21, 0 ; ldvary.r0
0x54003046bbc00000 nop ; fmul r1, r0, rf0
0x3d10a18705829000 fadd rf7, r1, r5 ; nop ; ldvary.r2
0x540030c6bbc80000 nop ; fmul r3, r2, rf0
0x3d1121850582b000 fadd rf5, r3, r5 ; nop ; ldvary.r4
0x54003006bbd00000 nop ; fmul r0, r4, rf0
0x3d10618605828000 fadd rf6, r0, r5 ; nop ; ldvary.r1
@phire
phire / pthread-test.c
Created February 12, 2021 22:12
Trying to reproduce a bug in an emulator.
// clang pthread-test.c -O3 -o pthread-test -lpthread
#include <stdio.h>
#include <stdint.h>
#include <stdatomic.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#define NUM_THREADS 64