Skip to content

Instantly share code, notes, and snippets.

@bryc
bryc / YamahaFM.md
Last active April 13, 2024 09:03
Collecting info on Yamaha FM soundchips
@bryc
bryc / alea.js
Last active March 15, 2022 12:01
PRNGs
/*
Optimized Alea
----------------------
Based on Alea by Johannes Baagøe (2010) which is based on MWC by George Marsaglia and Arif Zaman (1991).
Should be fast and pass BigCrush statistical test suite. It's quite fast but the quality is unverified.
Used like so:
var rand = Alea("test123");
rand(); // 0.7390809920616448
rand(); // 0.3916741746943444
@bryc
bryc / rc4.js
Last active March 6, 2021 11:26
RC4
function rc4(key, data) {
var output = [], S = [], tmp, i, j = 0;
for (i = 0; i < 256; i++) {
S[i] = i;
}
for (i = 0; i < 256; i++) {
j = (j + S[i] + key[i % key.length]) % 256;
tmp = S[i];
S[i] = S[j];
S[j] = tmp;
@bryc
bryc / crc.js
Last active July 18, 2022 13:13
CRC
/*
Cyclic redundancy check (CRC-4, CRC-8, CRC-16, CRC-32)
Common CRC implementation supporting wide range of configurations:
http://reveng.sourceforge.net/crc-catalogue/all.htm
NOTE: These common polynomials are likely suboptimal.
In the future I should make a page of Koopman's best general purpose polynomials.
http://github.com/bryc
@bryc
bryc / cyrb32.c
Last active February 9, 2018 00:27
A simple but usable checksum/hash algorithm, in C.
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
unsigned char *data;
int len = 0;
int cyrb32() {
uint32_t i, tmp, sum = 0xbf3931a8;
for(i = 32; i < len; i++) {
var p = ["RHYDON","KANGASKHAN","NIDORAN_M","CLEFAIRY","SPEAROW","VOLTORB","NIDOKING","SLOWBRO","IVYSAUR","EXEGGUTOR","LICKITUNG","EXEGGCUTE","GRIMER","GENGAR","NIDORAN_F","NIDOQUEEN","CUBONE","RHYHORN","LAPRAS","ARCANINE","MEW","GYARADOS","SHELLDER","TENTACOOL","GASTLY","SCYTHER","STARYU","BLASTOISE","PINSIR","TANGELA","MISSINGNO_1F","MISSINGNO_20","GROWLITHE","ONIX","FEAROW","PIDGEY","SLOWPOKE","KADABRA","GRAVELER","CHANSEY","MACHOKE","MR_MIME","HITMONLEE","HITMONCHAN","ARBOK","PARASECT","PSYDUCK","DROWZEE","GOLEM","MISSINGNO_32","MAGMAR","MISSINGNO_34","ELECTABUZZ","MAGNETON","KOFFING","MISSINGNO_38","MANKEY","SEEL","DIGLETT","TAUROS","MISSINGNO_3D","MISSINGNO_3E","MISSINGNO_3F","FARFETCHD","VENONAT","DRAGONITE","MISSINGNO_43","MISSINGNO_44","MISSINGNO_45","DODUO","POLIWAG","JYNX","MOLTRES","ARTICUNO","ZAPDOS","DITTO","MEOWTH","KRABBY","MISSINGNO_4F","MISSINGNO_50","MISSINGNO_51","VULPIX","NINETALES","PIKACHU","RAICHU","MISSINGNO_56","MISSINGNO_57","DRATINI","DRAGONAIR","KABUTO","KABUTOPS","HORSEA","SEADRA"
function noteFromKey(keyCode) {
var char = String.fromCharCode(keyCode).toUpperCase();
if(pianoMap[char]) {
return pianoMap[char];
}
else {
return false;
}
}
/*
@bryc
bryc / !info.txt
Last active December 11, 2016 18:55
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 October 15, 2023 14:44
Text stuff - Online code editors, chiptunes etc
@bryc
bryc / filereader.html
Last active December 6, 2016 01:34
Random HTML crap
<!-- In case you forget how to use the FileReader API -->
<script>
window.ondragover = function () {return false;};
window.ondrop = function (e)
{
var reader = new FileReader();
reader.readAsText(e.dataTransfer.files[0]);
reader.onprogress = function (Z)