Skip to content

Instantly share code, notes, and snippets.

View mikezila's full-sized avatar

Not Important mikezila

View GitHub Profile
@mikezila
mikezila / romtool.rb
Created December 19, 2017 05:29
Easily generate playlists from folders of disc images. For lakka/retroarch.
Game = Struct.new(:name, :path)
PATH_SLUG = '/storage/roms/USB/PSX/'.freeze
CORE_PATH = 'DETECT'.freeze
CORE_FRIENDLY_NAME = 'DETECT'.freeze
CRC_SLUG = '00000000|crc'.freeze
PLAYLIST_NAME = 'Sony - PlayStation.lpl'.freeze
games = []
Dir.foreach('.') do |folder|
@mikezila
mikezila / textool.rb
Last active March 7, 2021 23:53
Rip textures from a quake1 bsp. Requires the palette.lmp file with the quake palette.
require 'chunky_png'
Texture = Struct.new(:name, :width, :height, :pixels)
TextureLump = Struct.new(:count, :offsets)
textures = []
bsp = IO.read(ARGV.first, mode: "rb")
palette = IO.read("palette.lmp", mode: "rb")
tex_lump_offset = bsp[20, 4].unpack("L").first
@mikezila
mikezila / generate.js
Last active November 6, 2017 00:36
Generate a playlist of playstation games for Lakka when images are stored in their own folders.
const fs = require('fs');
const pathSlug = "/storage/roms/USB/PSX/";
const corePath = "DETECT";
const coreFriendlyName = "DETECT";
const crcSlug = "00000000|crc";
const playlistName = "Sony - PlayStation.lpl";
let games = [];
@mikezila
mikezila / imagetool.js
Created May 4, 2017 05:35
Simple pgm viewer. Doesn't support comments in the image data.
let canvas = document.getElementById('raster');
let pgmText = document.getElementById('image-data');
function renderImage() {
// Get text image data
let pattern = /[\s\n]/g;
// Also split on whitespace and throw away any
// blank entires leftover.
let pgmData = pgmText.value.split(pattern).filter(i => {
@mikezila
mikezila / LIFE
Created March 9, 2017 22:33
Life in Apple BASIC
100 size = 10
101 gfx = 5
102 gr
103 color = gfx
200 dim board(size, size)
210 dim temp(size, size)
300 gosub 800 : rem random
310 rem main loop
320 gosub 900 : rem render
@mikezila
mikezila / rekt.rb
Created March 3, 2017 07:31
Get rekt m8
#turns 'rekt' into
#R E K T
#E
#K
#T
subject = ARGV[0].upcase
subject.each_char do |x|
print x + ' '
@mikezila
mikezila / textool.rb
Last active March 3, 2017 07:24
Replace "magic pink" with real transparency
require 'chunky_png'
#replaces magic-pink with actual transparency
img = ChunkyPNG::Image.from_file(ARGV.first)
img.height.times do |y|
img.width.times do |x|
img[x,y] = 0x00000000 if img[x,y] == 0xff00ffff
end
@mikezila
mikezila / tilesheet.rb
Created March 2, 2017 19:28
TileSheet class for Gosu in Ruby
# tilesheet.rb
#
# This is for loading tile sheets that either have padding between the tiles,
# do not take up the whole of the image, or both. The normal Gosu method for
# loading from tiles doesn't work if there is padding or the tiles themselves
# are not wall-to-wall on the sheet. This can load such a sheet, though you
# will need to know how many tiles there are both wide and tall, as there's no
# way to guess on such a sheet. You'll also need to make sure the sheet is a
# power-of-two in size. You can do this by adjusting the sheet to 512x512 or
# 1024x1024, just add empty space if needed.
@mikezila
mikezila / AnimatedSpriteSheet.cs
Created February 26, 2017 21:49
SpriteSheet and AnimatedSpriteSheet classes for Monogame.
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
namespace AdvancedWars
{
class AnimatedSpriteSheet
{
private string baseName;
@mikezila
mikezila / life.c
Created January 23, 2017 01:38
Game of Life in C using OpenMP.
#include <stdlib.h>
#include <stdio.h>
#include "stopwatch.h"
#include <time.h>
#include <omp.h>
int wrappedLookup(int);
void seedGame(char *);