Skip to content

Instantly share code, notes, and snippets.

View bbbradsmith's full-sized avatar
🦎

Brad Smith bbbradsmith

🦎
View GitHub Profile
@bbbradsmith
bbbradsmith / autothumbs.py
Last active April 4, 2024 20:26
Generates movie thumbnail images automatically
#!/usr/bin/env python3
#
# Automatic Movie Thumbnail Generator
#
# Scans a folder, and generates a thumbnail image for every movie found.
# Uses a grid layout that attempts to maximize utilized space while
# fitting under a given maximum image size, and having at least as many
# frames as requested.
#
@bbbradsmith
bbbradsmith / bat.yml
Last active March 25, 2024 14:38
Github Actions example workflow for building a batch file
# Action name and trigger conditions.
# workflow_dispatch means: this can be manually re-triggered, and not just by push/pr.
name: Batch File Continuous Integration
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
@bbbradsmith
bbbradsmith / approximate_spacing.py
Last active October 16, 2023 20:59
Approximating smooth motion in discrete steps
# Problem:
# Making an NES game, want smooth motion but don't want to store sub-pixel precision.
# Solution:
# Approximate smooth motion in discrete steps.
#
# Investigate a few methods, and compare them by smoothness.
# Use standard deviation as a measure of smoothness.
# (Lower deviation total is better.)
#
# Result:
@bbbradsmith
bbbradsmith / abyss_boat_pak_dump.py
Created September 29, 2023 03:57
Unpacks PAK files from the game Abyss Boat by Leaf
# dumps PAK files from the game Abyss Boat by Leaf
import os
import struct
def printable(d):
s = ""
for c in d: s += chr(c) if (c >= 0x20 and c <= 126) else '.'
return s
@bbbradsmith
bbbradsmith / TerranigmaCompressor.py
Created February 7, 2022 11:53
Compressor and decompressor for Terranigma (SNES)
# Terranigma data compressor and decompressor
# Brad Smith, 2022-02-07
# https://rainwarrior.ca
#
# Format reference:
# https://www.terranigma.be/index.php/Compression
import sys
def usage():
@bbbradsmith
bbbradsmith / a8_to_tga.py
Created July 16, 2018 06:01
Microsoft screensaver sample A8 to TGA decoder
# decodes the A8 files in
# Microsoft Windows NT 4.0 SDK (1996)
# MSTOOLS\SAMPLES\OPENGL\SCRSAVE\MAZE
#
# based on MSTOOLS\SAMPLES\OPENGL\SCRSAVE\COMMON\SSA8.C
import struct
def a8decompress(d):
# defines
@bbbradsmith
bbbradsmith / milva_dump.py
Last active July 19, 2023 04:20
Milva DOS image dumper (Desafio, Kick Boxing Street) and re-compressor
# Dumps image data from Milva DOS game,
# as well as Desafio and Kick Boxing Street
# from Ediciones Manali.
#
# https://archive.org/details/msdos_Milva_1993
# https://www.old-games.ru/game/4884.html (Desafio)
# https://www.old-games.ru/game/4532.html (Kick Boxing)
#
# If you successfully use this for their other games,
# send me the dump list and I can add it.
@bbbradsmith
bbbradsmith / nes_blocky.py
Last active June 24, 2023 02:04
NES blocky graphics converter - Details: https://www.patreon.com/posts/22735126
#!/usr/bin/env python3
# nes_blocky.py
# Brad Smith, 2018
# http://rainwarrior.ca
#
# Finds .NES ROM files in the current folder,
# and generates "blocky" pixellated versions of each,
# if the game does not use CHR-RAM.
@bbbradsmith
bbbradsmith / subfix.py
Last active June 10, 2023 18:46
Plex subtitle file fixer and cleanup
#!/usr/bin/env python3
#
# This scrips attempts to find suitable subtitles in video collections,
# and will copy the best candidate into the same folder as the video,
# with the same filename as the video with the subtitle's extension.
#
# If a video already has a subtitle file in this place, it will not overwrite it.
#
# I can also delete directories and files as automatic cleanup.
@bbbradsmith
bbbradsmith / capchess_dumpega.py
Last active February 3, 2023 22:56
Capstone Chess DOS image dumper
import PIL.Image
import os
def decode_file(filename):
print(filename)
f = open(filename,"rb").read()
print("Header: %02X %02X" % (f[0],f[1]))
pal = f[2:2+(16*3)]
offset = 2 + (16*3)
count = 0