Skip to content

Instantly share code, notes, and snippets.

View ske2004's full-sized avatar
💠
hello

ske ske2004

💠
hello
View GitHub Profile
@ske2004
ske2004 / Win32.c
Last active March 31, 2025 22:01
811 byte windows executable with graphics update.
// Compile like this:
// cl Win32.c /O1 /c /GS- && crinkler Win32.obj user32.lib kernel32.lib gdi32.lib /SUBSYSTEM:WINDOWS /NODEFAULTLIB /UNSAFEIMPORT /TINYHEADER
#include <windows.h>
#define WN_TITLE "Unnamed"
#define WN_CLASS "WindowClassName"
#define WN_WIDTH 800
#define WN_HEIGHT 600
@ske2004
ske2004 / cyl.c
Last active November 20, 2024 17:57
typedef struct {
float x, y, z;
} vector3;
// Implementation defined, in OpenGL it would probably push the vertices into
// vertex buffer and add indices to the index buffer.
void make_tri(vector3 p1, vector3 p2, vector3 p3);
int main() {
#define SEGMENTS 9
// clang-format off
// Compile the program linking user32.lib
#pragma comment(lib, "user32.lib")
#include <Windows.h>
// Event handler.
LRESULT CALLBACK WndProc(
HWND hWnd, // Window the event was assigned to.
UINT Msg, // Message type.
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#define ADDR_MODE_COUNT 13
enum instr {
ADC, AND, ASL,
BCC, BCS, BEQ, BIT, BMI, BNE, BPL, BRK, BVC, BVS,
@ske2004
ske2004 / mario.c
Last active February 20, 2023 12:45
Generates Mario Theme Song
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_SAMPLES 44100
#define PI 3.14159265
// ------ NOTE IDS ------
#define C_ 0
#define CS 1
#define D_ 2
#include <stdint.h>
#include <stdlib.h>
#include "../../lib/umka/src/umka_api.h"
#include <string.h>
#ifdef __unix__
#include <dirent.h>
// 0 : DirectoryPath : str
// R : DirPtr : ^void
@ske2004
ske2004 / floatadd.c
Created July 28, 2022 22:35
Add floats (non negative)
// DOES NOT WORK ON NEGATIVE VALUES !! :P
#include <stdio.h>
union MyFloat {
float fv;
struct {
unsigned mantissa: 23;
unsigned exponent: 8;
unsigned sign: 1;
@ske2004
ske2004 / Main.c
Last active July 25, 2022 16:47
My first attempt at SIMD :P
#include <emmintrin.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <immintrin.h>
#include <time.h>
#define Benchmark(name, times) for (int t = 1; t;) for (double final; t;) for(clock_t start = clock(); t; final = (double)(clock()-start) / CLOCKS_PER_SEC, printf(" <%s> %gs / %dtimes = %gs\n", name, final, times, final/times), t = 0) for (int i = 0; i < times; ++i)
#define Utf8_BYTES_PER_ASCII 32
static inline size_t Utf8_Fetch(uint32_t *out, const char *s_)
{
const unsigned char *s = (const unsigned char*)s_;
if ((*s & 0xC0) != 0xC0) {
*out = *s;
return *s > 0;
}
const static size_t clas[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5};
size_t cl = clas[*s>>3];
@ske2004
ske2004 / ske.vim
Created June 8, 2022 12:50
Vim colorscheme uses handmade-hero.vim as a base
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "handmade-hero"