Skip to content

Instantly share code, notes, and snippets.

View mojobojo's full-sized avatar

Joey Giordano mojobojo

View GitHub Profile
@mojobojo
mojobojo / vimrc
Last active February 7, 2018 17:52
" Joeys vim config
"
" Some options from
" - https://github.com/rygorous/vimfiles/blob/master/vimrc
set nocompatible
if has("win32")
" Maximize on startup
; Compile with nasm
; nasm Small.asm -o Small.exe
bits 64
%define ImageAddress 0x0000000140000000
%define BaseAddress 0x00010000
%define addr(x) (x+ImageAddress+BaseAddress)
%define Kernel32Handle rsp+0x50
%define Kernel32PeHeader rsp+0x58
%define GetProcAddress rsp+0x60
tilemap "Images\hyptosis_tile-art-batch-1.png"
width 16
height 16
lights 1
light 0 {
color 1.000000,1.000000,1.000000,1.000000
position 10,10
}
ambientlight 0.16,0.16,0.16
layers 2
// Clearly the best hello world out there.
#define _ATL_ATTRIBUTES 1
#define _WINDLL 1
#include <atlbase.h>
#include <atlcom.h>
#include <string.h>
#include <comdef.h>
#include <string>
#include <fstream>
#include <iostream>
@mojobojo
mojobojo / pi.md
Last active March 14, 2018 17:31
Getting every 4 digit ATM pin number from pi

The Code

#include <Windows.h>
#include <stdio.h>
#include <stdint.h>

struct PIStruct {
	size_t position;
	int32_t found;
};
@mojobojo
mojobojo / atm_pi.txt
Last active March 14, 2018 17:17
Every ATM 4 digit pin is in this number
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327

The Code

#include <Windows.h>
#include <stdio.h>
#include <stdint.h>

struct PIStruct {
	size_t position;
	int32_t found;
};
void Render_DrawTile(f64 X, f64 Y, f64 Width, f64 Height, i32 map_width, i32 map_height, i32 TileX, i32 TileY, OpenglImage image) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GLuint TextureID = image.id;
GLint ProgramID = tile_draw_shader.id;
// NOTE: ceil prevents pixel gaps when tile edges are exactly aligned agaisnt one another
// doesnt always happen but will see an ocassional "shimmer" of one if there is no ceil
f64 TileScaleX = 1.0 / (f64)image.width * (f64)map_width;
f64 TileScaleY = 1.0 / (f64)image.height * (f64)map_height;
f64 SizeX = ceil(Width * meters_to_pixels);
void Render_DrawTileMap(dv2 position, i32 *tile_data, i32 world_width, i32 world_height, TileMap tile_map) {
GLuint texture_id = tile_map.image.id;
GLint program_id = tile_draw_shader.id;
f64 tile_scale_x = 1.0 / (f64)tile_map.image.width * (f64)tile_map.width;
f64 tile_scale_y = 1.0 / (f64)tile_map.image.height * (f64)tile_map.height;
f64 size_x = 1.0 * meters_to_pixels;
f64 size_y = 1.0 * meters_to_pixels;
glUseProgram(program_id);
@mojobojo
mojobojo / main.cc
Created April 26, 2018 21:59
intellisense problem
#include <stdio.h>
enum SomeEnum {
SOME_ENUM_THING,
SOME_ENUM_THING_AS_WELL
};
struct Some {
int nothing_to_see_here;
};