Skip to content

Instantly share code, notes, and snippets.

@hikiko
hikiko / helloworld.asm
Last active July 26, 2019 19:24
ASM helloworld (nasm)
;32bit x86 code
[bits 32]
[section .text]
global _start
_start:
;linux specific
;interrupt 80hex for system calls
@hikiko
hikiko / main.rs
Created September 15, 2019 12:44
my helloworld in Rust (not proud)
extern crate sdl2;
extern crate gl;
extern crate image;
use sdl2::video::GLProfile;
use gl::types::*;
use image::GenericImageView;
static WIN_W : u32 = 800;
static WIN_H : u32 = 800;
@hikiko
hikiko / Makefile
Created September 29, 2019 19:01
Makefile for dosbox asm (nasm)
test.com: test.asm
%.com: %.asm
nasm -o $@ -f bin $<
.PHONY: clean
clean:
rm -f test.com
@hikiko
hikiko / palset.asm
Created September 29, 2019 19:02
Asm/DOS: setting custom palette
; vi:filetype=nasm:
bits 16
; DOS loads COM programs at offset 100h (256) of the program segment
; therefore we need to let the assembler know, that everything should
; start from address 100h
org 100h
; video bios (10h) call 00h: set video mode
; ah: 00h, al: video mode number
mov ax, 13h ; mode 13h (320x200 8bpp)
@hikiko
hikiko / palshow.asm
Created September 29, 2019 19:03
DOS/asm: Showing the default palette
bits 16
; DOS loads COM programs at offset 100h (256) of the program segment
; therefore we need to let the assembler know, that everything should
; start from address 100h
org 100h
; video bios (10h) call 00h: set video mode
; ah: 00h, al: video mode number
mov ax, 13h ; mode 13h (320x200 8bpp)
int 10h
@hikiko
hikiko / mushroom.shader_test.glsl
Last active February 27, 2020 13:30
A vkrunner compatible shader_test that draws a field of mushrooms by performing ray marching in distance fields. (WIP)
[require]
fbsize 800 600
[vertex shader passthrough]
[fragment shader]
#version 450
layout(location = 0) out vec4 out_color;
@hikiko
hikiko / . build_mesa.sh
Last active March 25, 2020 20:03
a quick script to build mesa (need to modify the meson params for special builds)
#!/bin/bash
PS1="[isolated] $PS1"
export VK_ICD_FILENAMES=$HOME/igalia/install/share/vulkan/icd.d/intel_icd.x86_64.json
#export VK_ICD_FILENAMES=$HOME/igalia/install/share/vulkan/icd.d/radeon_icd.x86_64.json
export PATH=$PATH:$HOME/igalia/install/bin
export LD_LIBRARY_PATH=$HOME/igalia/install/lib
export LD_RUN_PATH=$HOME/igalia/install/lib
export XDG_DATA_DIRS=$XDG_DATA_DIRS:$HOME/igalia/install/share
@hikiko
hikiko / dump_ppm.c
Created April 7, 2020 13:22
the code I use to dump ppm because I always forget those P6, P3 etc :p
{
unsigned char pix[160 * 160 * 4];
FILE *fp;
int i;
glBindTexture(GL_TEXTURE_2D, gl_tex);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix);
if ((fp = fopen("/tmp/foo.ppm", "wb"))) {
//fprintf(fp, "P6\n160 160\n255\n");
@hikiko
hikiko / xor.vert.frag
Last active April 13, 2020 18:18
xor pattern shader (the comment) :p
#version 430
#extension GL_ARB_separate_shader_objects : enable
const vec2 vdata[] = vec2[] (
vec2(1.0, 1.0),
vec2(1.0, 0.0),
vec2(0.0, 1.0),
vec2(0.0, 0.0));
void main()
@hikiko
hikiko / . iso_env.sh
Last active June 3, 2020 10:34
script to create an "isolated" environment in my igalia/install dir where I've installed mesa, the vulkan loader, layers, tools etc (run as . iso_env.sh)
#!/bin/bash
PS1="[isolated] $PS1"
export PATH=$PATH:/home/eleni/igalia/install/bin
export LD_LIBRARY_PATH=/home/eleni/igalia/install/lib:/home/eleni/igalia/install/lib/x86_64-linux-gnu
export LD_RUN_PATH=/home/eleni/igalia/install/lib:/home/eleni/igalia/install/lib/x86_64-linux-gnu
export XDG_DATA_DIRS=$XDG_DATA_DIRS:/home/eleni/igalia/install/share
export LIBGL_DRIVERS_PATH=/home/eleni/igalia/install/lib/x86_64-linux-gnu/dri/
export MESA_DEBUG=1
#intel specific