Skip to content

Instantly share code, notes, and snippets.

@tattlemuss
tattlemuss / m68ktags.py
Last active December 16, 2023 11:28
Simple tags generator for Motorola 68k source code and vim.
#!/usr/bin/env python3
""" Simple ctags creator for Motorola m68k assembly.
Format specified by https://docs.ctags.io/en/latest/man/tags.5.html
{tagname} {TAB} {tagfile} {TAB} {tagaddress} {term} {field} ..
NOTE We only add tagaddress as line numbers, adding a search string takes more work,
like escaping regexp characters.
Regexps are very loose to support Devpac syntax, so will "over-find" labels.
@tattlemuss
tattlemuss / wavtosnd.py
Created August 2, 2023 14:52
A very simple and hacky Python3 script to convert 16-bit uncompressed WAV files to MPC-3000 .SND files.
#!/usr/bin/env python3
"""
A very simple and hacky Python3 script to convert 16-bit uncompressed WAV
files to MPC-3000 .SND files.
The output is modelled to copy the output of Wav2Snd
(http://www.mpc3000.com/wavsnd.htm) but this might be a bit more portable
to run on modern machines.
"""
A very simple and hacky script to convert 16-bit or 24-bit WAV sample files to 4-bit.
Files must be mono and uncompressed PCM data.
Output is a 4-bits-per-sample output, with an end marker byte, suitable for TTRAK playback.
"""
import struct, math
import os, array
if __name__ == '__main__':
import struct, sys
pi1 = open(sys.argv[1], "rb")
header = pi1.read(34) # skip the header data
pi1_bytes = pi1.read(32000) # We just want the pixeles
pi1.close()
out_bytes = bytearray(256 * 8)
for b in range(0, 256*8):
@tattlemuss
tattlemuss / lines_of_code.sh
Last active August 29, 2015 14:08
count number of post-processed lines in standard C/C++ include files
# sample output on my windows mingw setup
cpp:algorithm, 8196
cpp:array, 13
cpp:atomic, 2464
cpp:backward, 4
cpp:bits, 4
cpp:bitset, 9187
cpp:cassert, 27
cpp:ccomplex, 18329
cpp:cctype, 154
@tattlemuss
tattlemuss / vasm_builder.sh
Last active August 29, 2015 14:02
download and build vasm and vlink
#!/usr/bin/env sh
curl http://sun.hasenbraten.de/vasm/release/vasm.tar.gz > vasm.tar.gz
curl http://sun.hasenbraten.de/vlink/release/vlink.tar.gz > vlink.tar.gz
mkdir vasm
mkdir vlink
tar -zxvf ./vasm.tar.gz # unpacks to "vasm"
tar -zxvf ./vlink.tar.gz # unpacks to "vlink"