Skip to content

Instantly share code, notes, and snippets.

View TheMaverickProgrammer's full-sized avatar

Mav TheMaverickProgrammer

View GitHub Profile
// color1 and color2 are R4G4B4 12bit RGB color values, alpha is 0-255
uint16_t blend_12bit( uint16_t color1, uint16_t color2, uint8_t alpha ) {
uint64_t c1 = (uint64_t) color1;
uint64_t c2 = (uint64_t) color2;
uint64_t a = (uint64_t)( alpha >> 4 );
// bit magic to alpha blend R G B with single mul
c1 = ( c1 | ( c1 << 12 ) ) & 0x0f0f0f;
c2 = ( c2 | ( c2 << 12 ) ) & 0x0f0f0f;
uint32_t o = ( ( ( ( c2 - c1 ) * a ) >> 4 ) + c1 ) & 0x0f0f0f;
@TheMaverickProgrammer
TheMaverickProgrammer / normcore-llm.md
Created August 30, 2023 17:26 — forked from veekaybee/normcore-llm.md
Normcore LLM Reads
void login(httplib::Client& client) {
std::string user, pass;
std::cout << "user: ";
std::getline(std::cin, user);
std::cout << "pass: ";
char input[256];
#pragma once
#include "cx_murmur3.h"
//----------------------------------------------------------------------------
// constexpr typeid
namespace cx
{
namespace err
/******************************************************************************
Swizzling demonstration
by James King (TheMaverickProgrammer on Github)
Uses strings and overloaded [] operator.
Malformed strings throw exception.
Supports any number of vectors by always returning the
biggest vector.
# File "Player.anims" generated 5/13/2018 @ 3:30pm
# Origin is relative to the rectangle defined by {x, y, x+w, y+h}
animation name="PLAYER_IDLE"
frame duration="0.01" x="0" y="0" w="36" h="60" originx="12" originy="0"
animation name="PLAYER_MOVING"
frame duration="0.01" x="0" y="0" w="36" h="60" originx="12" originy="0"
frame duration="0.01" x="0" y="0" w="36" h="80" originx="54" originy="12"
frame duration="0.01" x="0" y="0" w="36" h="20" originx="4" originy="0"
@TheMaverickProgrammer
TheMaverickProgrammer / flatten.js
Created August 29, 2016 22:58
Flatten is a function that turns a nested array 'glob' and transform it into a linear array
/**************************************************
Author: Maverick Peppers
Date: 8/29/2016
Transform a nested array glob into one linear array
Input:
- Glob. A nested array.
Returns:
- Queue. A linear array.
***************************************************/