This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
OlderNewer