This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SDL/SDL.h> | |
#include <array> | |
#include <memory> | |
#include <assert.h> | |
namespace { | |
// min value | |
template <typename type_t> | |
constexpr type_t minv(type_t a, type_t b) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- | |
float constexpr lerp(float a0, float a1, float i) { | |
return a0 + (a1 - a0) * i; | |
} | |
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- | |
void intersect(float a0, float a1, float b0, float b1, vec2f_t &out) { | |
#if 1 | |
const float i = (a0 - b0) / (a0 - a1 - b0 + b1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdint> | |
namespace { | |
template <int hi, int lo> | |
constexpr uint32_t mask() { | |
// hi_mask xor lo_mask | |
return ((1u << hi) | ((1u << hi) - 1u)) ^ ((1u << lo) - 1u); | |
} | |
template <int hi, int lo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
struct base_t { | |
const int type; | |
base_t() : type(0) {} | |
base_t(int type) : type(type) {} | |
virtual int call() { return 1; } | |
}; | |
struct derived_t : public base_t { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- | |
# DATA TRANSFER | |
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- | |
# | |
@ MOV, Move | |
/ Register to Register/Memory | |
% 2/12 + 4*w | |
$ 1000100w | mod reg r/m | |
/ Register/memory to register |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
// operand format | |
enum { | |
OPR_IMM = 0, | |
OPR_ZP, | |
OPR_ZPX, | |
OPR_ZPY, | |
OPR_ABS, | |
OPR_ABSX, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
// fourcc function | |
static constexpr | |
uint32_t fourcc(const char (&in)[4]) { | |
return ((in[0]<<24) | (in[1]<<16) | (in[3]<<8) | ' '); | |
} | |
// addressing mode types | |
enum { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 6502 netlist and pin descriptions | |
* | |
* Original author: Greg James | |
* Original source material: www.visual6502.org | |
**/ | |
#pragma once | |
#include <cstdint> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OPCODE MNEMONIC OPERANDS FLAGS CYCLES LENGTH | |
0x00 BRK B 7 1 | |
0x01 ORA (ind,X) SZ 6 2 | |
0x05 ORA zpg SZ 3 2 | |
0x06 ASL zpg SZC 5 2 | |
0x08 PHP 3 1 | |
0x09 ORA # SZ 2 2 | |
0x0a ASL A SZC 2 1 | |
0x0d ORA abs SZ 4 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <cstdint> | |
struct xtea_t | |
{ | |
static const uint32_t _delta = 0x9E3779B9; | |
typedef uint32_t key_t[4]; | |
template <uint32_t num_rounds> |