Last active
April 11, 2024 22:42
-
-
Save Spongman/44852b1f14188e450838717c7d2b52b5 to your computer and use it in GitHub Desktop.
Mysterious Program in EPROM of Synertek SYM-1 Owned by Composer Richard Teitelbaum
This file contains hidden or 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
{ | |
via3.DDRA = 1; | |
via3.DDRB = 0xff; // output | |
via3.PCR = 1; // CA1: Independent interrupt input-negative edge | |
via2.DDRA = 0; // input | |
via2.DDRB = 0xff; // output | |
via2.PCR = 0x88; // CA & CB: Handshake output, negative active edge | |
bool moreBits = true; | |
int count16 = 0; | |
int inputByte0 = 0; | |
int inputByte1 = 0; | |
int shift0 = 0; | |
int shift1 = 0; | |
int bitCount = 8; | |
while(true) { | |
// wait until via3.B is ready | |
while ((via3.IFR >> 1 & 1) == 0) {} | |
via3.B = ~via3.B; | |
int inputBit = via3.A & 0x80; | |
int bits = 0; | |
if (inputByte0 < 0) | |
bits |= (1<<0); | |
if (inputByte1 < 0) | |
bits |= (1<<1); | |
while ((via3.IFR & 0x10) == 0) {} | |
via3.B ^= bits; | |
shift0 <<= 2; | |
shift1 <<= 2; | |
if ((via3.A & 0x80) != inputBit) { | |
shift0 |= 1; | |
shift1 |= 1; | |
} | |
if ((moreBits) && (shift0 == 0xfd)) { | |
count16 = 0; | |
moreBits = false; | |
} | |
else { | |
bitCount --; | |
inputByte0 <<= 1; | |
inputByte1 <<= 1; | |
if (bitCount != 0) | |
continue; | |
} | |
count16 += 1; | |
if (count16 == 16) { | |
if (shift1 != 0xfd) { | |
moreBits = true; | |
} | |
count16 = 0; | |
} | |
via2.B = shift1; | |
shift1 = 0; | |
bitCount = 8; | |
while ((via2.IFR & 2) == 0) {} | |
inputByte0 = via2.A; | |
while ((via2.IFR & 2) == 0) {} | |
inputByte1 = via2.A; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment