Skip to content

Instantly share code, notes, and snippets.

View qookei's full-sized avatar
🤔
hmm

Kacper Słomiński qookei

🤔
hmm
  • Poland
  • 16:12 (UTC +02:00)
View GitHub Profile
@qookei
qookei / libarch_clone.cpp
Last active April 21, 2020 11:48
Bad clone of managarm's libarch
#include <stdint.h>
constexpr uintptr_t spi1_addr = 0x40013000;
enum class spi_reg : uintptr_t {
cr2 = 0x04
};
template <uintptr_t Base, auto Reg>
struct periph_reg_addr {
constexpr size_t bytes_per_line = 16;
void buffer_pretty_print(const void *buf, size_t size) {
uintptr_t addr = reinterpret_cast<uintptr_t>(buf);
for (size_t i = 0; i < (size + bytes_per_line - 1) / bytes_per_line; i++) {
uint8_t buf[bytes_per_line];
auto off = i * bytes_per_line;
size_t n = std::min(bytes_per_line, size - off);
std::memcpy(
#include <iostream>
#include <tuple>
#include <array>
namespace details {
template<typename... Ts>
struct concat_size;
template<typename... Ts>
inline constexpr size_t concat_size_v = concat_size<Ts...>::value;
#include <iostream>
#include <tuple>
#include <array>
namespace details {
template<typename... Ts>
struct concat_size;
template<typename... Ts>
inline constexpr size_t concat_size_v = concat_size<Ts...>::value;
#include <iostream>
#include <tuple>
#include <array>
struct RecvBuffer{};
struct SendBuffer{};
struct ImbueCredentials{};
struct ExtractCredentials{};
struct RecvInline{};
struct Offer{};
#!/usr/bin/env python3
def gen_primes():
D = {}
q = 2
while True:
if q not in D:
yield q
D[q * q] = [q]
x86_64-managarm-g++ -std=gnu++11 -fsigned-char -DHAVE_CONFIG_H -I../include -I/home/qookie/code/managarm/build/../src/ports/mednafen/include -I../intl -fno-fast-math -fno-unsafe-math-optimizations -fno-aggressive-loop-optimizations -fno-ipa-icf -fno-printf-return-value -fomit-frame-pointer -fstrict-aliasing -Wall -Wshadow -Wempty-body -Wignored-qualifiers -Wvla -Wvariadic-macros -Wdisabled-optimization -Werror=write-strings -fno-pic -fno-pie -fno-PIC -fno-PIE -no-pie -fwrapv -fjump-tables -mfunction-return=keep -mindirect-branch=keep -mno-indirect-branch-register -mcmodel=small -fexceptions -g -O2 -MT cdrom/crc32.o -MD -MP -MF $depbase.Tpo -c -o cdrom/crc32.o /home/qookie/code/managarm/build/../src/ports/mednafen/src/cdrom/crc32.cpp &&\
mv -f $depbase.Tpo $depbase.Po
/home/qookie/code/managarm/build/../src/ports/mednafen/src/mthreading/MThreading_POSIX.cpp: In function ‘bool Mednafen::MThreading::Sem_Wait(Mednafen::MThreading::Sem*)’:
/home/qookie/code/managarm/build/../src/ports/mednafen/src/mthreadi
@qookei
qookei / bootqwrd.asm
Created February 4, 2020 23:18
DOS qword loader
; compile with: nasm -fbin bootqwrd.asm -o bootqwrd.com
; note: the DOS extender nasm uses causes this to triple fault
; when ran right after assembling
; usage: put a flat binary to be loaded at 1MB called QWORD.BIN in
; the current directory and run bootqwrd.com
; tested in qemu with DOS 6.22
org 0x100
bits 16
start:
#include <stdio.h>
#include <epoxy/gl.h> // replace with proper include
void gl_debug_callback(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length,
const char *message, const void *) {
const char *sev = "";
switch (severity) {
case GL_DEBUG_SEVERITY_HIGH: sev = "\e[91m"; break;
case GL_DEBUG_SEVERITY_MEDIUM: sev = "\e[93m"; break;
@qookei
qookei / translate_key_name.cc
Last active December 10, 2019 15:37
Key name to SFML constant
sf::Keyboard::Key translate_key_name(const std::string &name) {
if (name == "a") return sf::Keyboard::A;
if (name == "b") return sf::Keyboard::B;
if (name == "c") return sf::Keyboard::C;
if (name == "d") return sf::Keyboard::D;
if (name == "e") return sf::Keyboard::E;
if (name == "f") return sf::Keyboard::F;
if (name == "g") return sf::Keyboard::G;
if (name == "h") return sf::Keyboard::H;
if (name == "i") return sf::Keyboard::I;