Skip to content

Instantly share code, notes, and snippets.

@mod-san
mod-san / search.rb
Created February 8, 2019 00:13
Search for a specific text reference inside files of a whole tree of directories. [It has been used specifically to find strings in the files of the Shenmue games.]
def search(query, path = "**/*", output = "log.txt")
entry = query; entrySource = entry.source; #sndCase = entrySource.include?(".snd")
logfile = File.open(output, "w")
logfile << "== REREFERNCES OF \"#{entrySource}\" ==\n\n"
findsSize = 0; matchesOffsets = {}; filenames = []
Dir.glob(path) { |f|
( File.directory?(f) or f == File.basename(__FILE__) ) and next
string = IO.binread(f); stringSize = string.size
refsSize = 0; lastOffset = 0; matchesOffsets.clear
while lastOffset < stringSize
@mod-san
mod-san / pvr2png.rb
Last active February 8, 2019 00:07
Convert SEGA Dreamcast PVR images to PNG ones (of an entire directory, recursively), using Pvr2Png.exe and and the Ruby gem chunky_png. [It has specifically been used to convert Shenmue's PVR files to PNGs.]
require "chunky_png"
class Dir
def self.each_valid_file(path = "**/*")
glob(path) { |f|
File.directory?(f) or f == File.basename(__FILE__) or yield f
}
end
def self.exist_or_make(name)
File.exist?(name) or mkdir(name)
@mod-san
mod-san / PlotColiData.cs
Last active January 4, 2019 14:06
Using Unity 3D, plot all the points based on COLI data (floats) onto a scene. COLI is a subsection of COLS, which is found on MAPINFO.BIN files of areas of Shenmue I.
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlotColiData : MonoBehaviour
{
[SerializeField]
TextAsset asset;