Skip to content

Instantly share code, notes, and snippets.

@sean3z
sean3z / apgar.mrc
Created December 29, 2022 23:30
WOL Apgar routine in mIRC Script (Frank Razenberg)
alias apgar {
var %lookup = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
var %out, %i = 1
while (%i <= 8) {
var %left, %right = 0
if (%i <= $len($1-)) { %left = $asc($mid($1-, %i ,1)) }
if ($calc($len($1-) - %i + 1) < $len($1-)) { %right = $asc($mid($1-, $calc($len($1-) - %i + 2), 1)) }
var %x = $iif(%left & 1, $and($calc(%left * (2 ^ $and(%left, 1))), %right), $xor(%left, %right))
;# echo -a left: %left - righT: %right - x: %x
%out = %out $+ $mid(%lookup, $calc($and(%x, 63) + 1), 1)
@sean3z
sean3z / cpu.rs
Last active December 30, 2022 01:29
Example nibble parsing for Chip-8 emulator
pub fn emulate_cycle(&mut self) {
self.fetch_opcode();
self.execute_opcode();
// okay, PCs are much faster these days
// threw this cheeky delay in to slow things down
thread::sleep(time::Duration::from_micros(500));
}
fn fetch_opcode(&mut self) {