Skip to content

Instantly share code, notes, and snippets.

@Pigu-A
Pigu-A / dmf2ds24.py
Last active January 8, 2022 17:30
Deflemask module (.dmf) to DevSound 2.4 converter. Not all features are converted correctly.
import io, string, sys, zlib
CH3_DMF_VOL_IS_DS_VOL = False
def sane(a):
cap = True
t = ""
for i in a.decode():
if i in string.ascii_letters + string.digits + "_":
t += i.upper() if cap else i
cap = False
@Pigu-A
Pigu-A / adpcm_yamaha.ino
Last active March 8, 2019 18:43
when your avr compiler is very bad at 24-bit math
#include "Arduino.h"
#include "SPI.h"
const uint8_t F[] = {57,57,57,57,77,102,128,153};
const int8_t L[] = {1,3,5,7,9,11,13,15,-1,-3,-5,-7,-9,-11,-13,-15};
const uint16_t MIN_Q = 127;
const uint16_t MAX_Q = 24576;
uint16_t qn;
int16_t xn;
>>> cnt = 0
>>> for i in roms:
... fi = open(i,"rb")
... t = fi.seek(0x147)
... cart = ord(fi.read(1))
... siz = romsiz(ord(fi.read(1)))
... if 0x18 < cart < 0x20 and siz < 1024:
... print("{} | {} KiB".format(i.split("\\")[-1],siz))
... cnt += 1
... fi.close()
@Pigu-A
Pigu-A / decompress.asm
Created November 11, 2018 17:38
(Actual) Z80 port of Pokemon Crystal's decompressor. Assuming the entire routine is loaded in the RAM.
Decompress:
; Pokemon Crystal uses an lz variant for compression.
; This is mainly (but not necessarily) used for graphics.
; This function decompresses lz-compressed data from hl to de.
LZ_END EQU $ff ; Compressed data is terminated with $ff.
import argparse, string, sys
BCODES = {
"line": (10,),
"id": (11,),
"const": (12,),
"if": (13,0),
"goto": (14,),
"print": (15,0),
"stop": (16,0),
@Pigu-A
Pigu-A / dmf2pmd.py
Created January 17, 2018 13:33
Deflemask module (.dmf) to PMD MML converter
# By Pigu
# Usage: dmf2pmd.py <input.dmf> <output.txt>
import io, math, string, sys, zlib
poke = lambda c,o,a,d: "y{},{}".format(a+(c%3)+o*4,d)
timerB = lambda x: math.floor(256.5-(10400/3/x))
u8 = lambda x: int.from_bytes(x.read(1),byteorder="little")
s16 = lambda x: int.from_bytes(x.read(2),byteorder="little",signed=True)
s32 = lambda x: int.from_bytes(x.read(4),byteorder="little",signed=True)
#Title Transcendence in the Dead of Night
#Composer Pigu
#Option /v
#FM3Extend X
#Filename .M
#Memo 2017/09/29
#Memo Entry for Battle of the Bits FM Synth 2
#Memo PC-x801 category
@01 4 7 ; bd
@Pigu-A
Pigu-A / gbz80disasm.asm
Last active January 8, 2022 17:30
Yo dawg, I heard you like GB-Z80 disassembly so I made a GB-Z80 disassembler in GB-Z80 disassembly so you can disassemble GB-Z80 code while using GB-Z80 assembly
; code by PikalaxALT, not me
FarDisassemble:
; Disassemble the opcode at a:hl to wStringBuffer1
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
call Disassemble