SCC Decoder
Python:
Input Text
get sample
Output Text
Copy Output
Notes
- Each button replaces what was in the Output box
- The mid-line commands (eg {Type in WHITE}) "are spacing attributes which appear in the display just as if a standard space (20h) had been received."
#!/usr/bin/env python
import re
sample = """Scenarist_SCC V1.0
00:00:00;06 9420 94ae 9454 5468 e973 20e9 7320 6120 7361 6d70 ece5 94f4 efe6 2061 ecec 20e3 6861 f261 e3f4 e5f2 7380 942f
00:00:01;01 9420 94ae 9452 97a2 f468 61f4 2061 f2e5 2070 ef73 73e9 62ec e520 e96e 94f2 97a2 6120 ceef f2f4 6820 c16d e5f2 e9e3 616e 20d3 4343 942f
00:00:02;27 942c
00:00:03;20 9420 94ae 9476 a120 a223 a425 26a7 942f
00:00:04;20 9420 94ae 9476 a829 2aab 2cad ae2f 942f
00:00:05;20 9420 94ae 9476 b031 32b3 34b5 b637 942f
00:00:06;20 9420 94ae 9476 38b9 ba3b bc3d 3ebf 942f
00:00:07;27 942c
00:00:08;20 9420 94ae 9476 40c1 c243 c445 46c7 942f
00:00:09;20 9420 94ae 9476 c849 4acb 4ccd ce4f 942f
00:00:10;20 9420 94ae 9476 d051 52d3 54d5 d657 942f
00:00:11;20 9420 94ae 9476 58d9 da5b dc5d 5edf 942f
00:00:12;27 942c
00:00:13;20 9420 94ae 9476 e061 62e3 64e5 e667 942f
00:00:14;20 9420 94ae 9476 68e9 ea6b ec6d 6eef 942f
00:00:15;20 9420 94ae 9476 70f1 f273 f475 76f7 942f
00:00:16;20 9420 94ae 9476 f879 7afb 7cfd fe7f 942f
00:00:17;27 942c
00:00:18;19 9420 94ae 9476 97a2 91b0 9131 9132 91b3 942f
00:00:19;19 9420 94ae 9476 97a2 9134 91b5 91b6 9137 942f
00:00:20;18 9420 94ae 9476 97a2 9138 91b9 91ba 913b 942f
00:00:21;19 9420 94ae 9476 97a2 91bc 913d 913e 91bf 942f
00:00:22;27 942c
"""
def separate_into_bytes(str):
str = re.sub(r'Scenarist SCC V1\.0' , 'Decoded' ,str)
str = re.sub(r'Scenarist_SCC V1\.0' , 'Decoded' ,str)
str = re.sub(r'\t(..)(..)' , r'\t{{\1}}{{\2}}' ,str)
str = re.sub(r' (..)(..)' , r'_{{\1}}{{\2}}' ,str)
return str
def zero_first_parity_bit(str): #minus 8 to the first digit of a hex pair
str = re.sub(r'\{\{8(.)\}\}' , r'{{0\1}}' ,str)
str = re.sub(r'\{\{9(.)\}\}' , r'{{1\1}}' ,str)
str = re.sub(r'\{\{a(.)\}\}' , r'{{2\1}}' ,str)
str = re.sub(r'\{\{b(.)\}\}' , r'{{3\1}}' ,str)
str = re.sub(r'\{\{c(.)\}\}' , r'{{4\1}}' ,str)
str = re.sub(r'\{\{d(.)\}\}' , r'{{5\1}}' ,str)
str = re.sub(r'\{\{e(.)\}\}' , r'{{6\1}}' ,str)
str = re.sub(r'\{\{f(.)\}\}' , r'{{7\1}}' ,str)
return str
def turn_bytes_into_608_commands(str):
str = re.sub(r'\{\{11\}\}\{\{(..)\}\}' , r'{{11\1}}' ,str)
str = re.sub(r'\{\{14\}\}\{\{(..)\}\}' , r'{{14\1}}' ,str)
str = re.sub(r'\{\{17\}\}\{\{(..)\}\}' , r'{{17\1}}' ,str)
str = re.sub(r'\{\{1420\}\}' , r'{Start Caption}' ,str)
str = re.sub(r'\{\{142c\}\}' , r'{Clear Screen}' ,str)
str = re.sub(r'\{\{142e\}\}' , r'{Clear Buffer}' ,str)
str = re.sub(r'\{\{142f\}\}' , r'{End Caption}' ,str)
str = re.sub(r'\{\{1425\}\}' , r'{Roll-Up 2}' ,str)
str = re.sub(r'\{\{1426\}\}' , r'{Roll-Up 3}' ,str)
str = re.sub(r'\{\{1427\}\}' , r'{Roll-Up 4}' ,str)
str = re.sub(r'\{\{142d\}\}' , r'{New Line}' ,str)
str = re.sub(r'\{\{1120\}\}' , r'{Type in WHITE}' ,str)
str = re.sub(r'\{\{1121\}\}' , r'{Type in WHITE UNDERLINE}' ,str)
str = re.sub(r'\{\{1122\}\}' , r'{Type in GREEN}' ,str)
str = re.sub(r'\{\{1123\}\}' , r'{Type in GREEN UNDERLINE}' ,str)
str = re.sub(r'\{\{1124\}\}' , r'{Type in BLUE}' ,str)
str = re.sub(r'\{\{1125\}\}' , r'{Type in BLUE UNDERLINE}' ,str)
str = re.sub(r'\{\{1126\}\}' , r'{Type in CYAN}' ,str)
str = re.sub(r'\{\{1127\}\}' , r'{Type in CYAN UNDERLINE}' ,str)
str = re.sub(r'\{\{1128\}\}' , r'{Type in RED}' ,str)
str = re.sub(r'\{\{1129\}\}' , r'{Type in RED UNDERLINE}' ,str)
str = re.sub(r'\{\{112a\}\}' , r'{Type in YELLOW}' ,str)
str = re.sub(r'\{\{112b\}\}' , r'{Type in YELLOW UNDERLINE}' ,str)
str = re.sub(r'\{\{112c\}\}' , r'{Type in MAGENTA}' ,str)
str = re.sub(r'\{\{112d\}\}' , r'{Type in MAGENTA UNDERLINE}' ,str)
str = re.sub(r'\{\{112e\}\}' , r'{Type in ITALICS}' ,str)
str = re.sub(r'\{\{112f\}\}' , r'{Type in ITALICS UNDERLINE}' ,str)
str = re.sub(r'\{\{1150\}\}' , r'{Go To Row 00 Col 00}' ,str)
str = re.sub(r'\{\{1152\}\}' , r'{Go To Row 00 Col 04}' ,str)
str = re.sub(r'\{\{1154\}\}' , r'{Go To Row 00 Col 08}' ,str)
str = re.sub(r'\{\{1156\}\}' , r'{Go To Row 00 Col 12}' ,str)
str = re.sub(r'\{\{1158\}\}' , r'{Go To Row 00 Col 16}' ,str)
str = re.sub(r'\{\{115a\}\}' , r'{Go To Row 00 Col 20}' ,str)
str = re.sub(r'\{\{115c\}\}' , r'{Go To Row 00 Col 24}' ,str)
str = re.sub(r'\{\{115e\}\}' , r'{Go To Row 00 Col 28}' ,str)
str = re.sub(r'\{\{1170\}\}' , r'{Go To Row 02 Col 00}' ,str)
str = re.sub(r'\{\{1172\}\}' , r'{Go To Row 02 Col 04}' ,str)
str = re.sub(r'\{\{1174\}\}' , r'{Go To Row 02 Col 08}' ,str)
str = re.sub(r'\{\{1176\}\}' , r'{Go To Row 02 Col 12}' ,str)
str = re.sub(r'\{\{1178\}\}' , r'{Go To Row 02 Col 16}' ,str)
str = re.sub(r'\{\{117a\}\}' , r'{Go To Row 02 Col 20}' ,str)
str = re.sub(r'\{\{117c\}\}' , r'{Go To Row 02 Col 24}' ,str)
str = re.sub(r'\{\{117e\}\}' , r'{Go To Row 02 Col 28}' ,str)
str = re.sub(r'\{\{1450\}\}' , r'{Go To Row 14 Col 00}' ,str)
str = re.sub(r'\{\{1452\}\}' , r'{Go To Row 14 Col 04}' ,str)
str = re.sub(r'\{\{1454\}\}' , r'{Go To Row 14 Col 08}' ,str)
str = re.sub(r'\{\{1456\}\}' , r'{Go To Row 14 Col 12}' ,str)
str = re.sub(r'\{\{1458\}\}' , r'{Go To Row 14 Col 16}' ,str)
str = re.sub(r'\{\{145a\}\}' , r'{Go To Row 14 Col 20}' ,str)
str = re.sub(r'\{\{145c\}\}' , r'{Go To Row 14 Col 24}' ,str)
str = re.sub(r'\{\{145e\}\}' , r'{Go To Row 14 Col 28}' ,str)
str = re.sub(r'\{\{1470\}\}' , r'{Go To Row 15 Col 00}' ,str)
str = re.sub(r'\{\{1472\}\}' , r'{Go To Row 15 Col 04}' ,str)
str = re.sub(r'\{\{1474\}\}' , r'{Go To Row 15 Col 08}' ,str)
str = re.sub(r'\{\{1476\}\}' , r'{Go To Row 15 Col 12}' ,str)
str = re.sub(r'\{\{1478\}\}' , r'{Go To Row 15 Col 16}' ,str)
str = re.sub(r'\{\{147a\}\}' , r'{Go To Row 15 Col 20}' ,str)
str = re.sub(r'\{\{147c\}\}' , r'{Go To Row 15 Col 24}' ,str)
str = re.sub(r'\{\{147e\}\}' , r'{Go To Row 15 Col 28}' ,str)
str = re.sub(r'\{\{1721\}\}' , r'{Col +1}' ,str)
str = re.sub(r'\{\{1722\}\}' , r'{Col +2}' ,str)
str = re.sub(r'\{\{1723\}\}' , r'{Col +3}' ,str)
str = re.sub(r'\{\{1130\}\}' , r'®' ,str)
str = re.sub(r'\{\{1131\}\}' , r'°' ,str)
str = re.sub(r'\{\{1132\}\}' , r'½' ,str)
str = re.sub(r'\{\{1133\}\}' , r'¿' ,str)
str = re.sub(r'\{\{1134\}\}' , r'™' ,str)
str = re.sub(r'\{\{1135\}\}' , r'¢' ,str)
str = re.sub(r'\{\{1136\}\}' , r'£' ,str)
str = re.sub(r'\{\{1137\}\}' , r'♪' ,str)
str = re.sub(r'\{\{1138\}\}' , r'à' ,str)
str = re.sub(r'\{\{1139\}\}' , r'[non breaking space]' ,str)
str = re.sub(r'\{\{113a\}\}' , r'è' ,str)
str = re.sub(r'\{\{113b\}\}' , r'â' ,str)
str = re.sub(r'\{\{113c\}\}' , r'ê' ,str)
str = re.sub(r'\{\{113d\}\}' , r'î' ,str)
str = re.sub(r'\{\{113e\}\}' , r'ô' ,str)
str = re.sub(r'\{\{113f\}\}' , r'û' ,str)
str = re.sub(r'\{\{00\}\}' , r'{null}' ,str)
str = re.sub(r'\{\{20\}\}' , r' ' ,str)
str = re.sub(r'\{\{21\}\}' , r'!' ,str)
str = re.sub(r'\{\{22\}\}' , r'\\' ,str)
str = re.sub(r'\{\{23\}\}' , r'#' ,str)
str = re.sub(r'\{\{24\}\}' , r'$' ,str)
str = re.sub(r'\{\{25\}\}' , r'%' ,str)
str = re.sub(r'\{\{26\}\}' , r'&' ,str)
str = re.sub(r'\{\{27\}\}' , r'’' ,str)
str = re.sub(r'\{\{28\}\}' , r'(' ,str)
str = re.sub(r'\{\{29\}\}' , r')' ,str)
str = re.sub(r'\{\{2a\}\}' , r'á' ,str)
str = re.sub(r'\{\{2b\}\}' , r'+' ,str)
str = re.sub(r'\{\{2c\}\}' , r',' ,str)
str = re.sub(r'\{\{2d\}\}' , r'-' ,str)
str = re.sub(r'\{\{2e\}\}' , r'.' ,str)
str = re.sub(r'\{\{2f\}\}' , r'/' ,str)
str = re.sub(r'\{\{30\}\}' , r'0' ,str)
str = re.sub(r'\{\{31\}\}' , r'1' ,str)
str = re.sub(r'\{\{32\}\}' , r'2' ,str)
str = re.sub(r'\{\{33\}\}' , r'3' ,str)
str = re.sub(r'\{\{34\}\}' , r'4' ,str)
str = re.sub(r'\{\{35\}\}' , r'5' ,str)
str = re.sub(r'\{\{36\}\}' , r'6' ,str)
str = re.sub(r'\{\{37\}\}' , r'7' ,str)
str = re.sub(r'\{\{38\}\}' , r'8' ,str)
str = re.sub(r'\{\{39\}\}' , r'9' ,str)
str = re.sub(r'\{\{3a\}\}' , r':' ,str)
str = re.sub(r'\{\{3b\}\}' , r';' ,str)
str = re.sub(r'\{\{3c\}\}' , r'<' ,str)
str = re.sub(r'\{\{3d\}\}' , r'=' ,str)
str = re.sub(r'\{\{3e\}\}' , r'>' ,str)
str = re.sub(r'\{\{3f\}\}' , r'?' ,str)
str = re.sub(r'\{\{40\}\}' , r'@' ,str)
str = re.sub(r'\{\{41\}\}' , r'A' ,str)
str = re.sub(r'\{\{42\}\}' , r'B' ,str)
str = re.sub(r'\{\{43\}\}' , r'C' ,str)
str = re.sub(r'\{\{44\}\}' , r'D' ,str)
str = re.sub(r'\{\{45\}\}' , r'E' ,str)
str = re.sub(r'\{\{46\}\}' , r'F' ,str)
str = re.sub(r'\{\{47\}\}' , r'G' ,str)
str = re.sub(r'\{\{48\}\}' , r'H' ,str)
str = re.sub(r'\{\{49\}\}' , r'I' ,str)
str = re.sub(r'\{\{4a\}\}' , r'J' ,str)
str = re.sub(r'\{\{4b\}\}' , r'K' ,str)
str = re.sub(r'\{\{4c\}\}' , r'L' ,str)
str = re.sub(r'\{\{4d\}\}' , r'M' ,str)
str = re.sub(r'\{\{4e\}\}' , r'N' ,str)
str = re.sub(r'\{\{4f\}\}' , r'O' ,str)
str = re.sub(r'\{\{50\}\}' , r'P' ,str)
str = re.sub(r'\{\{51\}\}' , r'Q' ,str)
str = re.sub(r'\{\{52\}\}' , r'R' ,str)
str = re.sub(r'\{\{53\}\}' , r'S' ,str)
str = re.sub(r'\{\{54\}\}' , r'T' ,str)
str = re.sub(r'\{\{55\}\}' , r'U' ,str)
str = re.sub(r'\{\{56\}\}' , r'V' ,str)
str = re.sub(r'\{\{57\}\}' , r'W' ,str)
str = re.sub(r'\{\{58\}\}' , r'X' ,str)
str = re.sub(r'\{\{59\}\}' , r'Y' ,str)
str = re.sub(r'\{\{5a\}\}' , r'Z' ,str)
str = re.sub(r'\{\{5b\}\}' , r'[' ,str)
str = re.sub(r'\{\{5c\}\}' , r'é' ,str)
str = re.sub(r'\{\{5d\}\}' , r']' ,str)
str = re.sub(r'\{\{5e\}\}' , r'í' ,str)
str = re.sub(r'\{\{5f\}\}' , r'ó' ,str)
str = re.sub(r'\{\{60\}\}' , r'ú' ,str)
str = re.sub(r'\{\{61\}\}' , r'a' ,str)
str = re.sub(r'\{\{62\}\}' , r'b' ,str)
str = re.sub(r'\{\{63\}\}' , r'c' ,str)
str = re.sub(r'\{\{64\}\}' , r'd' ,str)
str = re.sub(r'\{\{65\}\}' , r'e' ,str)
str = re.sub(r'\{\{66\}\}' , r'f' ,str)
str = re.sub(r'\{\{67\}\}' , r'g' ,str)
str = re.sub(r'\{\{68\}\}' , r'h' ,str)
str = re.sub(r'\{\{69\}\}' , r'i' ,str)
str = re.sub(r'\{\{6a\}\}' , r'j' ,str)
str = re.sub(r'\{\{6b\}\}' , r'k' ,str)
str = re.sub(r'\{\{6c\}\}' , r'l' ,str)
str = re.sub(r'\{\{6d\}\}' , r'm' ,str)
str = re.sub(r'\{\{6e\}\}' , r'n' ,str)
str = re.sub(r'\{\{6f\}\}' , r'o' ,str)
str = re.sub(r'\{\{70\}\}' , r'p' ,str)
str = re.sub(r'\{\{71\}\}' , r'q' ,str)
str = re.sub(r'\{\{72\}\}' , r'r' ,str)
str = re.sub(r'\{\{73\}\}' , r's' ,str)
str = re.sub(r'\{\{74\}\}' , r't' ,str)
str = re.sub(r'\{\{75\}\}' , r'u' ,str)
str = re.sub(r'\{\{76\}\}' , r'v' ,str)
str = re.sub(r'\{\{77\}\}' , r'w' ,str)
str = re.sub(r'\{\{78\}\}' , r'x' ,str)
str = re.sub(r'\{\{79\}\}' , r'y' ,str)
str = re.sub(r'\{\{7a\}\}' , r'z' ,str)
str = re.sub(r'\{\{7b\}\}' , r'ç' ,str)
str = re.sub(r'\{\{7c\}\}' , r'÷' ,str)
str = re.sub(r'\{\{7d\}\}' , r'Ñ' ,str)
str = re.sub(r'\{\{7e\}\}' , r'ñ' ,str)
str = re.sub(r'\{\{7f\}\}' , r'█' ,str)
return str
def remove_underscores_and_nulls(str):
str = re.sub(r'_' , r'' ,str)
str = re.sub(r'\{null\}' , r'' ,str)
return str
def remove_commands(str):
str = re.sub(r'^(\d\d.\d\d.\d\d.\d\d)' , r'Preload Starts at \1 -- ' ,str, flags=re.MULTILINE) #flag makes ^ work
str = re.sub(r'\t' , r'TAB' ,str)
str = re.sub(r'\{Go To.*?\}' , r'\t' ,str)
str = re.sub(r'\{Clear Screen}\}' , r'' ,str)
str = re.sub(r'\{.*?\}' , r'' ,str)
str = re.sub(r'TAB\t' , r'' ,str)
str = re.sub(r'TAB\n' , r'\n' ,str)
return str
def remove_curlys_and_underscores(str):
str = re.sub(r'{' , r'' ,str)
str = re.sub(r'}' , r'' ,str)
str = re.sub(r'_' , r' ' ,str)
return str