Skip to content

Instantly share code, notes, and snippets.

@bryc
bryc / bbk - preliminary checksum calc 9.c
Last active April 19, 2026 18:01
C Code Snippets Archive #1 (old note: 2016 NOTE: USE fscanf() in future C projects)
#include <stdio.h>
#include <stdint.h>
int main(void)
{
uint64_t A1, A2, A3=0x13108B3C1, T0, T1, T2, T3, T4=0, T5, T6, T7, T8, T9, S1, V0, AT, S3;
int i;
unsigned char bytes[28] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,

DX7

image

These are the original 32 algorithms as used in Yamaha DX7.

The later Yamaha FS1R and Yamaha SY77 may have compatibility with these algorithms, but that's beyond the current scope. The FS1R contains 88 algorithms, while the SY77 contains 45 algorithms.

DX9

image

@bryc
bryc / YamahaFM.md
Last active April 17, 2026 03:27
Collecting info on Yamaha FM soundchips
@bryc
bryc / sum1.a80
Created March 31, 2026 06:25
Checksums written in 8-bit Assembly
.cpu 8080
; 8-bit Modulo-255 checksum (aka end-around-carry) - Null terminator version
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
mvi C, $00 ; Initialize checksum value to zero
lxi H, data ; Store the RAM address of our input data, in register HL
csum:
mov A, M ; Get next input byte (Accumulator = RAM at address HL)
cpi 0 ; If Accumulator is zero, enable zero flag
jz done ; If zero flag is set, break out of loop
// Optimal version of the XS1 checksum function.
function xs1cksm(data) {
let sum = [0, 0];
for(let i = 0, tmp; i < data.length; i++) {
tmp = (Math.imul(data[i], i) + sum[0] + 1994) >>> 0;
sum[1] = (sum[1] + (tmp < sum[0] ? 1 : 0)) >>> 0;
sum[0] = tmp;
}
return sum;
@bryc
bryc / arrstr.js
Last active March 21, 2026 23:16
Various useful js JavaScript snippets I use often - Credit = bryc.github.io
// #### ARRAY <-> STRING CONVERSION ####
// b62 - reversible base62 encoder/decoder in two lines.
function b62(n,c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"){var r="",l=c.length,i=0;
if(n.trim)while(i<n.length)r=l*r+c.indexOf(n[i++]);else while(n>0)r=c[n%l]+r,n=Math.floor(n/l);return r}
// arst is a reversible string<>array utility in one line. It converts a string to an array of integers and back.
// ES6 (shorter)
arst=a=>{return a.trim?[...a].map(a=>a.charCodeAt()):String.fromCharCode.apply(0,a)}
@bryc
bryc / !info.txt
Last active November 19, 2025 03:52
ultraSMS/MSX2 rom inserters
Original process:
ultraSMS and ultraMSX2 both have a rominserter.exe file which insert a ROM into
the respective v64 (byteswapped) emulator at a specific offset. It actually inserts the ROM byteswapped,
allowing the V64jr or other to re-swap it when loading on the N64. This is quite stupid.
The filesize of the output ROM appears to be incompatible with 64drive, and must be 1052672 bytes.
Also, to run on 64drive's USB mode, they must not be in v64 format, and must be in the original z64 format.
TODO: Load large ROMs into the rominserter and see exactly where it stops writing at. Should shed light
@bryc
bryc / links.xml
Last active August 3, 2025 17:45
Text stuff - Online code editors, chiptunes etc
@bryc
bryc / checksums.js
Last active June 23, 2025 09:51
CHECKSUMS!
// BSD-16
// From: en.wikipedia.org/wiki/BSD_checksum
function bsd16(data) {
for(var i = 0, c = 0; i < data.length; i++) {
c = (c>>1) + ((c&1) << 15);
c += data[i];
c &= 0xffff;
}
return c;
}
function noteFromKey(keyCode) {
var char = String.fromCharCode(keyCode).toUpperCase();
if(pianoMap[char]) {
return pianoMap[char];
}
else {
return false;
}
}
/*