summaryrefslogtreecommitdiff
path: root/docs/tasd-spec-0001/draft-tasd-spec-0001.txt
blob: f1388971d6d2744d69b72e2605ae37b713e172b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252




Independent TAS Console Replay Research Group                    V. Grey
                                                                        
                                                                 Bigbass
                                                                        
                                                                 rasteri
                                                       14 September 2023


                TASD File Format Specification Version 1
                          draft-tasd-v0001-00

Abstract

   The *TASD* file format is used for storing "Tool Assisted Speedrun"
   or "Tool Assisted Superplay" (TAS) data for TAS replay devices to
   replay on physical video game console hardware.  The format is
   defined to be expandable for future needs.  The format is also
   defined to be parsable by programs that do not understand portions of
   the format, whether that is due to incomplete support of the format
   specification or due to new features being added to later versions of
   the specification at a later date.

   This document defines the file format specification for *TASD* files.

Table of Contents

   1.  Introduction
     1.1.  Overview and Preliminaries
       1.1.1.  Notation and Vocabulary
     1.2.  Motivations
       1.2.1.  Problems With Existing Formats
   2.  Header
   3.  Packets
     3.1.  Assigned Packet Keys Without Descriptions
       3.1.1.  General Keys
       3.1.2.  NES Specific Keys
       3.1.3.  SNES Specific Keys
       3.1.4.  Genesis Specific Keys
       3.1.5.  Input Frame/Timing Keys
       3.1.6.  Extraneous Keys
     3.2.  Assigned Packet Keys With Descriptions
       3.2.1.  General Key Descriptions
       3.2.2.  NES Specific Key Descriptions
       3.2.3.  SNES Specific Key Descriptions
       3.2.4.  Genesis Specific Key Descriptions
       3.2.5.  Input Frame/Timing Key Descriptions
       3.2.6.  Extraneous Key Descriptions
     3.3.  Packet Payload Formats
       3.3.1.  General Key Payload Formats
         3.3.1.1.  CONSOLE_TYPE Packet
         3.3.1.2.  CONSOLE_REGION Packet
         3.3.1.3.  GAME_TITLE Packet
         3.3.1.4.  ROM_NAME Packet
         3.3.1.5.  ATTRIBUTION Packet
         3.3.1.6.  CATEGORY Packet
         3.3.1.7.  EMULATOR_NAME Packet
         3.3.1.8.  EMULATOR_VERSION Packet
         3.3.1.9.  EMULATOR_CORE Packet
         3.3.1.10. TAS_LAST_MODIFIED Packet
         3.3.1.11. DUMP_CREATED Packet
         3.3.1.12. DUMP_LAST_MODIFIED Packet
         3.3.1.13. TOTAL_FRAMES Packet
         3.3.1.14. RERECORDS Packet
         3.3.1.15. SOURCE_LINK Packet
         3.3.1.16. BLANK_FRAMES Packet
         3.3.1.17. VERIFIED Packet
         3.3.1.18. MEMORY_INIT Packet
         3.3.1.19. GAME_IDENTIFIER Packet
         3.3.1.20. MOVIE_LICENSE Packet
         3.3.1.21. MOVIE_FILE Packet
         3.3.1.22. PORT_CONTROLLER Packet
       3.3.2.  NES Specific Key Payload Formats
         3.3.2.1.  NES_LATCH_FILTER Packet
         3.3.2.2.  NES_CLOCK_FILTER Packet
         3.3.2.3.  NES_OVERREAD Packet
         3.3.2.4.  NES_GAME_GENIE_CODE Packet
       3.3.3.  SNES Specific Key Payload Formats
         3.3.3.1.  SNES_CLOCK_FILTER Packet
         3.3.3.2.  SNES_OVERREAD Packet
         3.3.3.3.  SNES_GAME_GENIE_CODE Packet
         3.3.3.4.  SNES_LATCH_TRAIN Packet
       3.3.4.  Genesis Specific Key Payload Formats
         3.3.4.1.  GENESIS_GAME_GENIE_CODE Packet
       3.3.5.  Input Frame/Timing Key Payload Formats
         3.3.5.1.  INPUT_CHUNK Packet
         3.3.5.2.  INPUT_MOMENT Packet
         3.3.5.3.  TRANSITION Packet
         3.3.5.4.  LAG_FRAME_CHUNK Packet
         3.3.5.5.  MOVIE_TRANSITION
       3.3.6.  Extraneous Key Payload Formats
         3.3.6.1.  COMMENT Packet
         3.3.6.2.  EXPERIMENTAL Packet
         3.3.6.3.  UNSPECIFIED Packet
   4.  Controller Input Formats
     4.1.  NES/Famicom Controller Types
       4.1.1.  NES Standard Controller
       4.1.2.  NES Four Score
     4.2.  SNES Controller Types
       4.2.1.  SNES Standard Controller
       4.2.2.  SNES Mouse
       4.2.3.  SNES Super Multitap
     4.3.  N64 Controller Types
       4.3.1.  N64 Standard Controller
       4.3.2.  N64 Standard Controller with Rumble
       4.3.3.  N64 Standard Controller with Controller Pak
       4.3.4.  N64 Standard Controller with Transfer Pak
       4.3.5.  N64 Mouse
       4.3.6.  N64 Densha de Go
     4.4.  GameCube Controller Types
       4.4.1.  GameCube Standard Controller
     4.5.  Game Boy Controller Types
       4.5.1.  GB Standard Controller
     4.6.  Game Boy Color Controller Types
       4.6.1.  GBC Standard Controller
     4.7.  Game Boy Advance Controller Types
       4.7.1.  GBA Standard Controller
     4.8.  Genesis Controller Types
       4.8.1.  Genesis (Mega Drive) 3-Button
       4.8.2.  Genesis (Mega Drive) 6-Button
     4.9.  Atari 2600 Controller Types
       4.9.1.  A2600 Joystick
       4.9.2.  A2600 Keyboard Controller
   5.  References
     5.1.  Normative References
   Copyright Notice
   Authors' Addresses

1.  Introduction

   The Tool Assisted Speedrun Dump (*TASD*) interchange format is a file
   format for storing data to allow "Tool Assisted Speedruns" or "Tool
   Assisted Superplays" to be played on physical video game console
   hardware using TAS replay devices.  Created to be hardware and
   software agnostic, the *TASD* interchange format uses a key-based,
   binary, packet format to break up pieces of information into easily-
   parsable and forward-compatible chunks.  The format is extensible by
   simply defining additional keys or value types as necessary.  When
   parsing the file, software can skip any packets whose key is unknown
   or unsupported.

   Keys can be used multiple times or completely omitted as needed.
   This reusability eliminates the need of a predefined delimiter to
   separate pieces of data such as a list of TAS authors.

   While files generated by emulator dump scripts should provide as much
   information as possible, because keys are optional, the file can be
   expanded later with any additional data as desired.  No intermediary
   file format is necessary.

1.1.  Overview and Preliminaries

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in this document are to be interpreted as described in BCP
   14 [RFC2119] [RFC8174] when, and only when, they appear in all
   capitals, as shown here.

1.1.1.  Notation and Vocabulary

   Data Types:

      (S) = String
      (A) = Binary Data
      (I) = Signed Integer
      (N) = Unsigned Integer
      (B) = Boolean
      ([]N) = List of Unsigned Integers

   We use the terms *byte* and *octet* interchangeably in this document.

   Unless specified otherwise, all multi-octet integers are big-endian.

   We use the terms *Tool Assisted Speedrun*, *Tool Assisted Superplay*
   and *TAS* interchangeably in this document.

   In subsections of (Section 3.2), the term "in direct form" is used.
   That term is defined to mean a packet in a *TASD* file directly
   (first order packet) rather than a packet inside a TRANSITION or
   MOVIE_TRANSITION packet (second order packet).

   String values MUST use UTF-8 encoding.  If an example of a string
   value is given, the example will be between quotation marks.  The
   quotation marks are not included in the string.  Not all content
   between quotations will be string value examples, so be aware of that
   when continuing through this document.

   Unsigned and signed integers can have different bit widths.  For
   instance, an 8-bit integer can be used in one part of the
   specification and a 64-bit integer can be used in another part of the
   specification.

   Boolean values MUST be a single octet with the value of 0 for *FALSE*
   or 1 for *TRUE*.

   [N octets]  A sequence of octets with a length of N

   [00 7F FF]  A sequence of octets 00, 7F, and FF in that order.

   *0-indexed*  When counting sequentially, start counting at 0.

   *1-indexed*  When counting sequentially, start counting at 1.

   In packet diagrams, a single octet is represented with a box like
   this:

         +-----+
         | Var | <-- Vertical bars MAY be missing
         +-----+

      *Var* is a variable name.

   In packet diagrams, an arbitrary number of octets are represented
   with a box like this:

         +=====+
         | Var |
         +=====+

      *Var* is a variable name.

   In packet diagrams, boxes can be connected like these examples:

         +-----------+-----------+
         | Var 1 (B) | Var 2 (I) |
         +-----------+-----------+

      In this example, *Var 1* is a 1 octet long boolean value and *Var
      2* is a 1 octet long signed integer.

         +-----+-----+===========+
         | Var 1 (N) | Var 2 (S) |
         +-----+-----+===========+

      In this example, *Var 1* is a 2 octet long unsigned integer and
      *Var 2* is an arbitrary octet length string.

   In packet diagrams, boxes MAY have relative offset values above them
   like in the following example:

            0     1       2...
         +-----+-----+===========+
         | Var 1 (N) | Var 2 (S) |
         +-----+-----+===========+

      In this example, *Var 1* is a 2 octet long unsigned integer and
      *Var 2* is an arbitrary octet length string.

   Packet diagrams MAY be split into multiple lined sections like in the
   following example:

               0           1           2           3
         +-----------+-----------+-----------+-----------+
         | Var 1 (N) | Var 2 (I) | Var 3 (B) | Var 4 (I) | ...
         +-----------+-----------+-----------+-----------+
               4           5
         +-----------+===========+
         | Var 5 (N) | Var 6 (S) |
         +-----------+===========+

      In this example, enough variable boxes are in the packet diagram
      to require being split into 2 sections to take up less horizontal
      space in this documentation.  The packet diagram is separated by
      an ellipsis (...) on the same text row as the variable names to
      signify that the packet diagram is continuing.

1.2.  Motivations

   This file format's primary goal is to provide a comprehensive and
   replay device agnostic TAS movie controller input dump format that is
   usable for any console.  Additional goals include:

   *  No intermediary formats

   *  Forward compatibility

   *  High extensibility

   *  Ability to easily generate using lua scripting in emulators

   Consideration was also given to how usable the format would be for
   the software that interacts with replay devices (examples: methods of
   ingestion/parsing, ease of ingestion/parsing in various languages).

1.2.1.  Problems With Existing Formats

   Most existing formats are either incomplete for some verification
   needs or don't exist at all for some consoles.  A format commonly
   used for NES console verifications (r08) only encodes 2 standard
   controllers worth of sequential data and a format commonly used for
   SNES console verifications (r16m) only encodes up to 8 standard
   controllers worth of sequential data.  There is no built in way to
   store *RESET* press timing information or indicate additional
   settings/information.  Non-standard controllers are also not
   supported in commonly used formats.

   For consoles not as popular as the NES and SNES, controller input
   formats would frequently be written in a way that is meant only to
   work and not in a "standard" way.  While that process works, it's
   less than ideal for redistribution of console replays so that others
   (especially with differing TAS replay devices) can also verify the
   same TAS.

2.  Header

   *TASD* files MUST include a header, which MUST be in the following
   format:

           0    1    2    3     4      5          6
         +----+----+----+----+------+------+--------------+
         | Magic Number (A)  | Version (N) | G_KEYLEN (N) |
         +----+----+----+----+------+------+--------------+

         Magic Number (Binary Data)              [4 octets]
         Version (Unsigned Integer)              [2 octets]
         G_KEYLEN (Unsigned Integer)             [1 octet]

   *Magic Number*
      4 octet value that MUST be [54 41 53 44](ASCII value TASD).

   *Version*
      Version of the *TASD* file format.  Version currently MUST be a
      value of 1.

   *G_KEYLEN*
      Global length of *Key* values of packets.  G_KEYLEN currently MUST
      be a value of 2.

3.  Packets

   Packets MUST be in the following format:

         +=========+----------+==========+=============+
         | Key (A) | PEXP (N) | PLEN (N) | Payload (A) |
         +=========+----------+==========+=============+

         Key (Binary Data)                     [G_KEYLEN octets]
         PEXP (Unsigned Integer)               [1 octet]
         PLEN (Unsigned Integer)               [PEXP octets]
         Payload (Binary Data)                 [PLEN octets]

   *Key*
      Packet type (Packet key).

   *PEXP*
      Length of *PLEN*.

   *PLEN*
      Length of *Payload*.

   *Payload*
      Payload/Content of the packet.

   *G_KEYLEN*
      Length of *Key* in packets and is specified in the *TASD* file
      header.

   All packets are OPTIONAL.

3.1.  Assigned Packet Keys Without Descriptions

3.1.1.  General Keys

   [00 01]  CONSOLE_TYPE
   [00 02]  CONSOLE_REGION
   [00 03]  GAME_TITLE
   [00 04]  ROM_NAME
   [00 05]  ATTRIBUTION
   [00 06]  CATEGORY
   [00 07]  EMULATOR_NAME
   [00 08]  EMULATOR_VERSION
   [00 09]  EMULATOR_CORE
   [00 0A]  TAS_LAST_MODIFIED
   [00 0B]  DUMP_CREATED
   [00 0C]  DUMP_LAST_MODIFIED
   [00 0D]  TOTAL_FRAMES
   [00 0E]  RERECORDS
   [00 0F]  SOURCE_LINK
   [00 10]  BLANK_FRAMES
   [00 11]  VERIFIED
   [00 12]  MEMORY_INIT
   [00 13]  GAME_IDENTIFIER
   [00 14]  MOVIE_LICENSE
   [00 15]  MOVIE_FILE
   [00 F0]  PORT_CONTROLLER

3.1.2.  NES Specific Keys

   [01 01]  NES_LATCH_FILTER
   [01 02]  NES_CLOCK_FILTER
   [01 03]  NES_OVERREAD
   [01 04]  NES_GAME_GENIE_CODE

3.1.3.  SNES Specific Keys

   [02 02]  SNES_CLOCK_FILTER
   [02 03]  SNES_OVERREAD
   [02 04]  SNES_GAME_GENIE_CODE
   [02 05]  SNES_LATCH_TRAIN

3.1.4.  Genesis Specific Keys

   [08 04]  GENESIS_GAME_GENIE_CODE

3.1.5.  Input Frame/Timing Keys

   [FE 01]  INPUT_CHUNK
   [FE 02]  INPUT_MOMENT
   [FE 03]  TRANSITION
   [FE 04]  LAG_FRAME_CHUNK
   [FE 05]  MOVIE_TRANSITION

3.1.6.  Extraneous Keys

   [FF 01]  COMMENT
   [FF FE]  EXPERIMENTAL
   [FF FF]  UNSPECIFIED

3.2.  Assigned Packet Keys With Descriptions

3.2.1.  General Key Descriptions

   [00 01] - CONSOLE_TYPE
      Specifies console used on emulator when dumping the TAS controller
      inputs.  This packet type is OPTIONAL but SHOULD be included in a
      *TASD* file and a *TASD* file SHOULD NOT contain more than 1 of
      this packet type in direct form.  Discussed in (Section 3.3.1.1).

   [00 02] - CONSOLE_REGION
      Specifies video region of console used for the TAS.  This packet
      type is OPTIONAL and a *TASD* file MAY contain more than 1 of this
      packet type.  Discussed in (Section 3.3.1.2).

   [00 03] - GAME_TITLE
      Specifies the name of the game the TAS is written for.  This
      packet type is OPTIONAL and a *TASD* file MAY contain more than 1
      of this packet type.  Discussed in (Section 3.3.1.3).

   [00 04] - ROM_NAME
      Specifies the name of the specific ROM file used for the TAS.
      This packet type is OPTIONAL and a *TASD* file MAY contain more
      than 1 of this packet type.  Discussed in (Section 3.3.1.4).

   [00 05] - ATTRIBUTION
      Specifies the name of someone involved in the TAS or the creation
      or management of the *TASD* file in order to provide proper
      attribution for work done.  This packet type is OPTIONAL and a
      *TASD* file MAY contain more than 1 of this packet type.
      Discussed in (Section 3.3.1.5).

   [00 06] - CATEGORY
      Specifies the run category of the TAS.  This packet type is
      OPTIONAL and a *TASD* file SHOULD NOT contain more than 1 of this
      packet type in direct form.  Discussed in (Section 3.3.1.6).

   [00 07] - EMULATOR_NAME
      Specifies the emulator used while dumping TAS controller inputs.
      This packet type is OPTIONAL and a *TASD* file SHOULD NOT contain
      more than 1 of this packet type in direct form.  Discussed in
      (Section 3.3.1.7).

   [00 08] - EMULATOR_VERSION
      Specifies the version of the emulator used while dump the TAS
      controller inputs.  This packet type is OPTIONAL and a *TASD* file
      SHOULD NOT contain more than 1 of this packet type in direct form.
      Discussed in (Section 3.3.1.8).

   [00 09] - EMULATOR_CORE
      Specifies the core of the emulator used while dumping the TAS
      controller inputs.  This packet type is OPTIONAL and a *TASD* file
      SHOULD NOT contain more than 1 of this packet type in direct form.
      Discussed in (Section 3.3.1.9).

   [00 0A] - TAS_LAST_MODIFIED
      Specifies when the TAS was last modified.  Frequently used to
      specify the date and time when the TAS was published.  This packet
      type is OPTIONAL and a *TASD* file SHOULD NOT contain more than 1
      of this packet type in direct form.  Discussed in
      (Section 3.3.1.10).

   [00 0B] - DUMP_CREATED
      Specifies when the *TASD* file was first created.  This packet is
      OPTIONAL but SHOULD be included in a *TASD* file and a *TASD* file
      SHOULD NOT contain more than 1 of this packet type.  Discussed in
      (Section 3.3.1.11).

   [00 0C] - DUMP_LAST_MODIFIED
      Specifies when the *TASD* file was last modified.  This packet is
      OPTIONAL but SHOULD be included in a *TASD* file and a *TASD* file
      SHOULD NOT contain more than 1 of this packet type.  Discussed in
      (Section 3.3.1.12).

   [00 0D] - TOTAL_FRAMES
      Specifies the total number of frames in the TAS.  This packet type
      is OPTIONAL and a *TASD* file SHOULD NOT contain more than 1 of
      this packet type in direct form.  Discussed in (Section 3.3.1.13).

   [00 0E] - RERECORDS
      Specifies the total number of rerecords of the TAS.  This packet
      type is OPTIONAL and a *TASD* file SHOULD NOT contain more than 1
      of this packet type in direct form.  Discussed in
      (Section 3.3.1.14).

   [00 0F] - SOURCE_LINK
      Specifies the source link for the TAS.  This packet type is
      OPTIONAL and a *TASD* file SHOULD NOT contain more than 1 of this
      packet type.  Discussed in (Section 3.3.1.15).

   [00 10] - BLANK_FRAMES
      Specifies the number of blank controller inputs or frames to
      prepend to the inputs of the TAS when played on hardware.  This
      packet type is OPTIONAL and a *TASD* file SHOULD NOT contain more
      than 1 of this packet type in direct form.  Discussed in
      (Section 3.3.1.16).

   [00 11] - VERIFIED
      Specifies whether the TAS is verified to run on hardware, also
      known as "console verified", using the *TASD* file.  This packet
      type is OPTIONAL and a *TASD* file SHOULD NOT contain more than 1
      of this packet type in direct form.  Discussed in
      (Section 3.3.1.17).

   [00 12] - MEMORY_INIT
      Specifies initial memory values used for the TAS.  This packet
      type is OPTIONAL and a *TASD* file MAY contain more than 1 of this
      packet type.  Discussed in (Section 3.3.1.18).

   [00 13] - GAME_IDENTIFIER
      Specifies an identifier for the game the TAS is written for.  This
      can be checksums, hashes, or other identifying data.  This packet
      type is OPTIONAL and a *TASD* file MAY contain more than 1 of this
      packet type.  Discussed in (Section 3.3.1.19).

   [00 14] - MOVIE_LICENSE
      Specifies a copyright license for the TAS.  This packet type is
      OPTIONAL and a *TASD* file MAY contain more than 1 of this packet
      type.  Discussed in (Section 3.3.1.20).

   [00 15] - MOVIE_FILE
      Specifies the TAS movie data.  This packet type is OPTIONAL and a
      *TASD* file SHOULD NOT contain more than 1 of this packet type.
      Discussed in (Section 3.3.1.21).

   [00 F0] - PORT_CONTROLLER
      Specifies the controller type in specific console controller ports
      for the TAS when played on hardware.  This packet type is OPTIONAL
      and a *TASD* file SHOULD NOT contain more than 1 of this packet
      type in direct form.  Discussed in (Section 3.3.1.22).

3.2.2.  NES Specific Key Descriptions

   [01 01] - NES_LATCH_FILTER
      Specifies a latch filter time in microseconds for how long how
      long to wait after a latch signal until new latch signals SHOULD
      be accepted by the replay device.  This packet type is OPTIONAL
      and a *TASD* file SHOULD NOT contain more than 1 of this packet
      type in direct form.  Discussed in (Section 3.3.2.1).

   [01 02] - NES_CLOCK_FILTER
      Specifies a clock filter time in tenths of a microsecond (0.1
      microseconds or 100 nanoseconds) for how long to wait after a
      clock pulse until new clock pulses SHOULD be accepted by the
      replay device.  This packet type is OPTIONAL and a *TASD* file
      SHOULD NOT contain more than 1 of this packet type in direct form.
      Discussed in (Section 3.3.2.2).

   [01 03] - NES_OVERREAD
      Specifies whether a high or low signal SHOULD be sent to the NES
      console if the console clocks the replay device for more input
      buttons than are expected for the latch.  This packet type is
      OPTIONAL and a *TASD* file SHOULD NOT contain more than 1 of this
      packet type in direct form.  Discussed in (Section 3.3.2.3).

   [01 04] - NES_GAME_GENIE_CODE
      Specifies a Game Genie code for the TAS.  This packet type is
      OPTIONAL and a *TASD* file MAY contain more than 1 of this packet
      type.  Discussed in (Section 3.3.2.4).

3.2.3.  SNES Specific Key Descriptions

   [02 02] - SNES_CLOCK_FILTER
      Specifies a clock filter time in tenths of a microsecond (0.1
      microseconds or 100 nanoseconds) for how long to wait after a
      clock pulse until new clock pulses SHOULD be accepted by the
      replay device.  This packet type is OPTIONAL and a *TASD* file
      SHOULD NOT contain more than 1 of this packet type in direct form.
      Discussed in (Section 3.3.3.1).

   [01 03] - SNES_OVERREAD
      Specifies whether a high or low signal SHOULD be sent to the SNES
      console if the console clocks the replay device for more input
      buttons than are expected for the latch.  This packet type is
      OPTIONAL and a *TASD* file SHOULD NOT contain more than 1 of this
      packet type in direct form.  Discussed in (Section 3.3.3.2).

   [01 04] - SNES_GAME_GENIE_CODE
      Specifies a Game Genie code for the TAS.  This packet type is
      OPTIONAL and a *TASD* file MAY contain more than 1 of this packet
      type.  Discussed in (Section 3.3.3.3).

   [01 04] - SNES_LATCH_TRAIN
      Specifies Latch Trains for TAS.  This packet type is OPTIONAL and
      a *TASD* file MAY contain more than 1 of this packet type.
      Discussed in (Section 3.3.3.4).

3.2.4.  Genesis Specific Key Descriptions

   [08 04] - GENESIS_GAME_GENIE_CODE
      Specifies a Game Genie code for the TAS.  This packet type is
      OPTIONAL and a *TASD* file MAY contain more than 1 of this packet
      type.  Discussed in (Section 3.3.4.1).

3.2.5.  Input Frame/Timing Key Descriptions

   [FE 01] - INPUT_CHUNK
      Specifies a chunk of input data for the TAS when played on
      hardware.  All data from INPUT_CHUNK packets are concatenated
      together in order of appearance in the *TASD* file.  If the
      INPUT_CHUNK packet type is used, the PORT_CONTROLLER packet type
      MUST be used.  If the INPUT_CHUNK packet type is used, the
      INPUT_MOMENT packet type SHOULD NOT be used.  This packet type is
      OPTIONAL and a *TASD* file MAY contain more than 1 of this packet
      type.  Discussed in (Section 3.3.5.1).

   [FE 02] - INPUT_MOMENT
      Specifies input data that is sent from the replay device to the
      console with specific timing.  If the INPUT_MOMENT packet type is
      used, the PORT_CONTROLLER packet type MUST be used.  If the
      INPUT_MOMENT packet type is used, the INPUT_CHUNK packet type
      SHOULD NOT be used.  This packet type is OPTIONAL and a *TASD*
      file MAY contain more than 1 of this packet type.  Discussed in
      (Section 3.3.5.2).

   [FE 03] - TRANSITION
      Specifies when a transition or change occurs during a TAS replay
      (example: console reset or changing of controller types).  This
      packet type is OPTIONAL and a *TASD* file MAY contain more than 1
      of this packet type.  Discussed in (Section 3.3.5.3).

   [FE 04] - LAG_FRAME_CHUNK
      Specifies a chunk of lag frames in a TAS based on the original TAS
      movie.  This packet type is OPTIONAL and a *TASD* file MAY contain
      more than 1 of this packet type.  Discussed in (Section 3.3.5.4).

   [FE 05] - MOVIE_TRANSITION
      Specifies when a transition or change occurs in the original TAS
      movie (example: console reset or changing of controller types).
      This packet type is OPTIONAL and a *TASD* file MAY contain more
      than 1 of this packet type.  Discussed in (Section 3.3.5.5).

3.2.6.  Extraneous Key Descriptions

   [FF 01] - COMMENT
      Comment data.  This packet type is OPTIONAL and a *TASD* file MAY
      contain more than 1 of this packet type.  Discussed in
      (Section 3.3.6.1).

   [FF FE] - EXPERIMENTAL
      TASD file is using draft/experimental packets.  This packet type
      is OPTIONAL and a *TASD* file SHOULD NOT contain more than 1 of
      this packet type.  Discussed in (Section 3.3.6.2).

   [FF FF] - UNSPECIFIED
      Unspecified packet data.  Can contain any arbitrary data.  This
      packet type is OPTIONAL and a *TASD* file MAY contain more than 1
      of this packet type.  Discussed in (Section 3.3.6.3).

3.3.  Packet Payload Formats

3.3.1.  General Key Payload Formats

3.3.1.1.  CONSOLE_TYPE Packet

   CONSOLE_TYPE packets MUST be in the following format:

                0          1...
         +-------------+==========+
         | Console (A) | Name (S) |
         +-------------+==========+

         Console (Binary Data):                  [1 octet]
            [01] - NES <Nintendo Entertainment System>
            [02] - SNES <Super Nintendo>
            [03] - N64 <Nintendo 64>
            [04] - GC <GameCube>
            [05] - GB <Game Boy>
            [06] - GBC <Game Boy Color>
            [07] - GBA <Game Boy Advance>
            [08] - Genesis <Sega Genesis/Sega Mega Drive>
            [09] - A2600 <Atari 2600>
            [FF] - Custom
         Name (String)                           [PLEN - 1 octets]

   *Console*
      Game console the TAS movie is for.  There are pre-specified
      console types, but a *TASD* file MAY use [FF] to specify a console
      that is not in the pre-specified console types.

   *Name*
      Name of the console the TAS movie is for.  SHOULD be empty if
      *Console* is not set to [FF].

   *PLEN*
      Length of the packet payload.

3.3.1.2.  CONSOLE_REGION Packet

   CONSOLE_REGION packets MUST be in the following format:

                  0
         +------------------+
         | Video Signal (A) |
         +------------------+

         Video Signal (Binary Data):             [1 octet]
            [01] - NTSC
            [02] - PAL
            [FF] - Other/Unknown

   *Video Signal*
      Specifies the video signal of the game console being emulated
      while dumping the TAS movie controller inputs.

3.3.1.3.  GAME_TITLE Packet

   GAME_TITLE packets MUST be in the following format:

             0...
         +===========+
         | Title (S) |
         +===========+

         Title (String)                          [PLEN octets]

   *Title*
      Game title the TAS movie is for (example: "Super Mario Bros. 3").

   *PLEN*
      Length of the packet payload.

3.3.1.4.  ROM_NAME Packet

   ROM_NAME packets MUST be in the following format:

             0...
         +==========+
         | Name (S) |
         +==========+

         Name (String)                           [PLEN octets]

   *Name*
      File name of the ROM used for the TAS movie (example: "Super Mario
      Bros. 3 (J) [!].nes").

   *PLEN*
      Length of the packet payload.

3.3.1.5.  ATTRIBUTION Packet

   ATTRIBUTION packets MUST be in the following format:

              0         1...
         +----------+==========+
         | Type (A) | Name (S) |
         +----------+==========+

         Type (Binary Data)                      [1 octet]
            [01] - Author
            [02] - Verifier
            [03] - TASD File Creator
            [04] - TASD File Editor
            [FF] - Other
         Name (String)                           [PLEN - 1 octets]

   *Type*
      Function of the person who is being attributed.  *Author* is meant
      for a TAS movie author.  *Verifier* is meant for a person who
      initially console verified the the TAS movie using the *TASD
      file*.  *TASD File Creator* is meant for the person who initially
      dumped the TAS movie controller inputs into the *TASD* file.
      *TASD File Editor* is meant for a person who edited the *TASD*
      file.

   *Name*
      Name of the individual getting the attribution (example:
      "OnehundredthCoin").

   *PLEN*
      Length of the packet payload.

3.3.1.6.  CATEGORY Packet

   CATEGORY packets MUST be in the following format:

               0...
         +==============+
         | Category (S) |
         +==============+

         Category (String)                       [PLEN octets]

   *Category*
      Name of the TAS movie run category (example: "Any %", "100%", "No
      Warps").

   *PLEN*
      Length of the packet payload.

3.3.1.7.  EMULATOR_NAME Packet

   EMULATOR_NAME packets MUST be in the following format:

             0...
         +==========+
         | Name (S) |
         +==========+

         Name (String)                           [PLEN octets]

   *Name*
      Name of the emulator used to play the TAS movie while dumping
      controller inputs (example: "FCEUX", "Bizhawk").

   *PLEN*
      Length of the packet payload.

3.3.1.8.  EMULATOR_VERSION Packet

   EMULATOR_VERSION packets MUST be in the following format:

              0...
         +=============+
         | Version (S) |
         +=============+

         Version (String)                        [PLEN octets]

   *Version*
      Version of the emulator used to play the TAS movie while dumping
      controller inputs (example: "2.7.0").

   *PLEN*
      Length of the packet payload.

3.3.1.9.  EMULATOR_CORE Packet

   EMULATOR_CORE packets MUST be in the following format:

             0...
         +==========+
         | Core (S) |
         +==========+

         Core (String)                           [PLEN octets]

   *Core*
      Core of the emulator used to play the TAS movie while dumping
      controller inputs (example: "NESHawk", "Gambatte").

   *PLEN*
      Length of the packet payload

3.3.1.10.  TAS_LAST_MODIFIED Packet

   TAS_LAST_MODIFIED packets MUST be in the following format:

          0  1  2  3  4  5  6  7
         +--+--+--+--+--+--+--+--+
         |  Unix Timestamp (I)   |
         +--+--+--+--+--+--+--+--+

         Unix Timestamp (Signed Integer)         [8 octets]

   *Unix Timestamp*
      64-bit Unix timestamp of when the TAS movie was last modified.

3.3.1.11.  DUMP_CREATED Packet

   DUMP_CREATED packets MUST be in the following format:

          0  1  2  3  4  5  6  7
         +--+--+--+--+--+--+--+--+
         |  Unix Timestamp (I)   |
         +--+--+--+--+--+--+--+--+

         Unix Timestamp (Signed Integer)         [8 octets]

   *Unix Timestamp*
      64-bit Unix timestamp of when the *TASD* file was created.

3.3.1.12.  DUMP_LAST_MODIFIED Packet

   DUMP_LAST_MODIFIED packets MUST be in the following format:

          0  1  2  3  4  5  6  7
         +--+--+--+--+--+--+--+--+
         |  Unix Timestamp (I)   |
         +--+--+--+--+--+--+--+--+

         Unix Timestamp (Signed Integer)         [8 octets]

   *Unix Timestamp*
      64-bit Unix timestamp of when the *TASD* file was last modified.

3.3.1.13.  TOTAL_FRAMES Packet

   TOTAL_FRAMES packets MUST be in the following format:

           0   1   2   3
         +---+---+---+---+
         |  Frames (N)   |
         +---+---+---+---+

         Frames (Unsigned Integer)               [4 octets]

   *Frames*
      Total number of frames of the TAS movie.

3.3.1.14.  RERECORDS Packet

   RERECORDS packets MUST be in the following format:

           0   1   2   3
         +---+---+---+---+
         | Rerecords (N) |
         +---+---+---+---+

         Rerecords (Unsigned Integer)            [4 octets]

   *Rerecords*
      Total number of rerecords of the TAS movie.

3.3.1.15.  SOURCE_LINK Packet

   SOURCE_LINK packets MUST be in the following format:

             0...
         +==========+
         | Link (S) |
         +==========+

         Link (String)                           [PLEN octets]

   *Link*
      URL that points to the TAS movie or submission (example:
      "https://tasvideos.org/4567M").

   *PLEN*
      Length of the packet payload.

3.3.1.16.  BLANK_FRAMES Packet

   BLANK_FRAMES packets MUST be in the following format:

            0      1
         +------+------+
         | Frames (I)  |
         +------+------+

         Frames (Signed Integer)                 [2 octets]

   *Frames*
      Number of blank frames (inputs where no buttons are being pressed)
      needed at the beginning of a TAS console replay of the TAS movie.
      If *Frames* is a negative value, the value of *Frames* amount of
      inputs of the TAS console replay of the TAS movie should be
      removed.

3.3.1.17.  VERIFIED Packet

   VERIFIED packets MUST be in the following format:

                0
         +--------------+
         | Verified (B) |
         +--------------+

         Verified (Boolean)                      [1 octet]

   *Verified*
      Boolean value that is *TRUE* if the *TASD* file has been
      successfully console verified and *FALSE* if it has not been
      verified.

3.3.1.18.  MEMORY_INIT Packet

   MEMORY_INIT packets MUST be in the following format:

                 0          1      2          3
         +---------------+------+------+--------------+
         | Data Type (A) | Device (A)  | Required (B) | ...
         +---------------+------+------+--------------+
              4         5...    5+NLEN...
         +----------+==========+==========+
         | NLEN (N) | Name (S) | Data (A) |
         +----------+==========+==========+

         Data Type (Binary Data):                [1 octet]
            [01] - No Initialization Required
            [02] - All [00]
            [03] - All [FF]
            [04] - [00 00 00 00 FF FF FF FF] Repeating
            [05] - Random
            [FF] - Custom
         Device (Binary Data):                   [2 octets]
            [01 01] - NES CPU RAM
            [01 02] - NES Cartridge Save Data
            [02 01] - SNES CPU RAM
            [02 02] - SNES Cartridge Save Data
            [05 01] - GB CPU RAM
            [05 02] - GB Cartridge Save Data
            [06 01] - GBC CPU RAM
            [06 02] - GBC Cartridge Save Data
            [07 01] - GBA CPU RAM
            [07 02] - GBA Cartridge Save Data
            [08 01] - Genesis CPU RAM
            [08 02] - Genesis Cartridge Save Data
            [09 01] - A2600 CPU RAM
            [09 02] - A2600 Cartridge Save Data
            [FF FF] - Custom/Other Device
         Required (Boolean)                      [1 octet]
         NLEN (Unsigned Integer)                 [1 octet]
         Name (String)                           [NLEN octets]
         Data (Binary Data)                      [PLEN - NLEN -
                                                  5 octets]

   *Data Type*
      Content type of initial memory.  If *Type* is not [FF], *Data*
      SHOULD be empty (0 octet length binary data).

   *Device*
      Device/Location that is to have memory initialized.

   *Required*
      Boolean value that is *TRUE* if this memory initialization data is
      known to be required and *FALSE* if the memory initialization data
      is not known to be required.

   *NLEN*
      Length of *Name*

   *Name*
      Label for the memory initialization data (example: "CPU RAM",
      "SAVE RAM").  If *Device* is [FF FF], *Name* SHOULD NOT be empty
      (0 octet length string).

   *Data*
      Raw memory initialization data.  If *Data Type* is not [FF],
      *Data* SHOULD be empty (0 octet length binary data).

   *PLEN*
      Length of the packet payload.

3.3.1.19.  GAME_IDENTIFIER Packet

   GAME_IDENTIFIER packets MUST be in the following format:

              0          1            2...
         +----------+----------+================+
         | Type (A) | Base (A) | Identifier (A) |
         +----------+----------+================+

         Type (Binary Data):               [1 octet]
            [01] - CRC-8 Checksum
            [02] - CRC-16 Checksum
            [03] - CRC-32 Checksum
            [04] - MD5 Hash
            [05] - SHA1 Hash
            [06] - SHA224 Hash
            [07] - SHA256 Hash
            [08] - SHA384 Hash
            [09] - SHA512 Hash
            [0A] - SHA512/224 Hash
            [0B] - SHA512/256 Hash
            [0C] - SHA3-224 Hash
            [0D] - SHA3-256 Hash
            [0E] - SHA3-384 Hash
            [0F] - SHA3-512 Hash
            [10] - SHAKE-128 Hash
            [11] - SHAKE-256 Hash
            [FF] - Other
         Base (Binary Data):                     [1 octet]
            [01] - Raw Binary
            [02] - Case Insensitive Base 16 (Hex) - RFC 4648
            [03] - Case Insensitive Base 32 - RFC 4648
            [04] - Base 64 - RFC 4648
            [FF] - Other
         Identifier (Binary Data)                [PLEN - 2 octets]

   *Type*
      Hash, checksum, or identifier algorithm *Identifier* is using.

   *Base*
      Describes the data encoding of *Identifier*.

   *Identifier*
      Game hash, checksum, or identifier data.

   *PLEN*
      Length of the packet payload

3.3.1.20.  MOVIE_LICENSE Packet

   MOVIE_LICENSE packets MUST be in the following format:

                0
         +=============+
         | License (S) |
         +=============+

         License (String)                        [PLEN octet]

   *License*
      License information for the TAS movie (example: "Creative Commons
      Attribution 2.0").

   *PLEN*
      Length of the packet payload.

3.3.1.21.  MOVIE_FILE Packet

   MOVIE_FILE packets MUST be in the following format:

              0         1...      1+NLEN...
         +----------+==========+=============+
         | NLEN (N) | Name (S) |  Data (A)   |
         +----------+==========+=============+

         NLEN (Unsigned Integer)                 [1 octet]
         Name (String)                           [NLEN octets]
         Data (Binary Data)                      [PLEN - NLEN -
                                                  1 octets]

   *NLEN*
      Length of *Name*.

   *Name*
      Name of the TAS movie (RECOMMENDED to use TAS movie file name, for
      example: "100thcoinv2-smb3j-geg.bk2").

   *Data*
      TAS movie file data/content.

   *PLEN*
      Length of the packet payload.

3.3.1.22.  PORT_CONTROLLER Packet

   PORT_CONTROLLER packets MUST be in the following format:

              0        1     2
         +----------+-----+-----+
         | Port (N) | Type (A)  |
         +----------+-----+-----+

         Port (Unsigned Integer)                 [1 octet]
         Type (Binary Data):                     [2 octets]
            [01 01] - NES Standard Controller
            [01 02] - NES Four Score
            [01 03] - (RESERVED) NES Zapper
            [01 04] - (RESERVED) NES Power Pad
            [01 05] - (RESERVED) Famicom Family BASIC Keyboard
            [02 01] - SNES Standard Controller
            [02 02] - SNES Super Multitap
            [02 03] - SNES Mouse
            [02 04] - (RESERVED) SNES Superscope
            [03 01] - N64 Standard Controller
            [03 02] - N64 Standard Controller with Rumble Pak
            [03 03] - N64 Standard Controller with Controller Pak
            [03 04] - N64 Standard Controller with Transfer Pak
            [03 05] - N64 Mouse
            [03 06] - (RESERVED) N64 Voice Recognition Unit (VRU)
            [03 07] - (RESERVED) N64 RandNet Keyboard
            [03 08] - N64 Densha de Go
            [04 01] - GC Standard Controller
            [04 02] - (RESERVED) GC Keyboard
            [05 01] - GB Gamepad
            [06 01] - GBC Gamepad
            [07 01] - GBA Gamepad
            [08 01] - Genesis (Mega Drive) 3-Button
            [08 02] - Genesis (Mega Drive) 6-Button
            [09 01] - A2600 Joystick
            [09 02] - (RESERVED) A2600 Paddle
            [09 03] - A2600 Keyboard Controller
            [FF FF] - Other/Unspecified

   *Port*
      Controller port number (*Port* number MUST be *1-indexed*).

   *Type*
      Specifies the controller type connected to the *Port*.
      *(RESERVED)* specifies that the controller type is not described
      in this document, but the byte values are reserved for a later
      version of the *TASD* file format protocol.  Input formats for
      specific controller types are described in (Section 4).

3.3.2.  NES Specific Key Payload Formats

3.3.2.1.  NES_LATCH_FILTER Packet

   NES_LATCH_FILTER packets MUST be in the following format:

            0     1
         +-----+-----+
         | Time (N)  |
         +-----+-----+

         Time (Unsigned Integer)                 [2 octets]

   *Time*
      Latch filter length of time in microseconds.

3.3.2.2.  NES_CLOCK_FILTER Packet

   NES_CLOCK_FILTER packets MUST be in the following format:

              0
         +----------+
         | Time (N) |
         +----------+

         Time (Unsigned Integer)                 [1 octet]

   *Time*
      Clock filter length of time in tenths of a microsecond (units of
      0.1 microseconds or 100 nanoseconds).

3.3.2.3.  NES_OVERREAD Packet

   NES_OVERREAD packets MUST be in the following format:

              0
         +----------+
         | High (B) |
         +----------+

         High (Boolean)                          [1 octet]

   *High*
      Boolean value that is *TRUE* if overread bits are set to high and
      *FALSE* if overread bits are set to low.

3.3.2.4.  NES_GAME_GENIE_CODE Packet

   NES_GAME_GENIE_CODE packets MUST be in the following format:

             0...
         +==========+
         | Code (S) |
         +==========+

         Code (String)                           [PLEN octets]

   *Code*
      Game Genie code (example: "AATOZA").

   *PLEN*
      Length of the packet payload.

3.3.3.  SNES Specific Key Payload Formats

3.3.3.1.  SNES_CLOCK_FILTER Packet

   SNES_CLOCK_FILTER packets MUST be in the following format:

              0
         +----------+
         | Time (N) |
         +----------+

         Time (Unsigned Integer)                 [1 octet]

   *Time*
      Clock filter length of time in tenths of a microsecond (units of
      0.1 microseconds or 100 nanoseconds).

3.3.3.2.  SNES_OVERREAD Packet

   SNES_OVERREAD packets MUST be in the following format:

              0
         +----------+
         | High (B) |
         +----------+

         High (Boolean)                          [1 octet]

   *High*
      Boolean value that is *TRUE* if overread bits are set to high and
      *FALSE* if overread bits are set to low.

3.3.3.3.  SNES_GAME_GENIE_CODE Packet

   SNES_GAME_GENIE_CODE packets MUST be in the following format:

             0...
         +==========+
         | Code (S) |
         +==========+

         Code (String)                           [PLEN octets]

   *Code*
      Game Genie code (example: "DDB4-6F07").

   *PLEN*
      Length of the packet payload.

3.3.3.4.  SNES_LATCH_TRAIN Packet

   SNES_LATCH_TRAIN packets MUST be in the following format:

                     0...
         +====================+
         | Latch Trains ([]N) |
         +====================+

         Latch Trains (List of Unsigned Integers)  [PLEN octets]

   *Latch Trains*
      List of 64-bit unsigned integers in which each integer is the
      length of one Latch Train.  MUST be a multiple of 8 octets in size

   *PLEN*
      Length of the packet payload.

   A single SNES_LATCH_TRAIN packet MAY contain up to every Latch Train
   of a SNES TAS movie console replay and MAY contain fewer than every
   Latch Train of a SNES TAS movie console replay.  There MAY be more
   than 1 SNES_LATCH_TRAIN packet.

3.3.4.  Genesis Specific Key Payload Formats

3.3.4.1.  GENESIS_GAME_GENIE_CODE Packet

   GENESIS_GAME_GENIE_CODE packets MUST be in the following format:

             0...
         +==========+
         | Code (S) |
         +==========+

         Code (String)                           [PLEN octets]

   *Code*
      Game Genie code (example: "ATBT-AA32").

   *PLEN*
      Length of the packet payload.

3.3.5.  Input Frame/Timing Key Payload Formats

3.3.5.1.  INPUT_CHUNK Packet

   INPUT_CHUNK packets MUST be in the following format:

              0          1...
         +----------+============+
         | Port (N) | Inputs (A) |
         +----------+============+

         Port (Unsigned Integer)                 [1 octet]
         Inputs (Binary Data)                    [PLEN - 1 octets]

   *Port*
      Controller port number (*Port* number MUST be *1-indexed*).

   *Inputs*
      Controller input data for controller on *Port*. Input values are
      usually in native format (usually active-low).  Input formats for
      specific controller types are described in (Section 4).

   *PLEN*
      Length of the packet payload.

   A single INPUT_CHUNK packet MAY contain up to every input of a TAS
   movie console replay and MAY contain fewer than every input of a TAS
   movie console replay.  If there are more than 1 INPUT_CHUNK packets,
   the INPUT_CHUNK packets MUST be in order of the TAS movie console
   replay inputs, where earlier inputs in the TAS movie console replay
   are earlier in the *TASD* file and later inputs in the TAS movie
   console replay are later in the *TASD* file.

3.3.5.2.  INPUT_MOMENT Packet

   INPUT_MOMENT packets MUST be in the following format:

              0             1         2  3  4  5  7  8  9  10
         +----------+----------------+--+--+--+--+--+--+--+--+
         | Port (N) | Index Type (A) |       Index (N)       | ...
         +----------+----------------+--+--+--+--+--+--+--+--+
             11...
         +============+
         | Inputs (B) |
         +============+

         Port (Unsigned Integer)                 [1 octet]
         Index Type (Binary Data):               [1 octet]
            [01] - Frame
            [02] - Cycle Count
            [03] - Milliseconds
            [04] - Microseconds * 10
         Index (Unsigned Integer)                [8 octets]
         Inputs (Binary Data)                    [PLEN - 10 octets]


   *Port*
      Controller port number (*Port* number MUST be *1-indexed*).

   *Type*
      Determines specific timing type for start of *Inputs*.

   *Index*
      Time value to start sending *Inputs* data.

   *Inputs*
      Controller input data for controller on *Port*. Input values are
      usually in native format (usually active-low).  Input formats for
      specific controller types are described in (Section 4).

   *PLEN*
      Length of the packet payload.

3.3.5.3.  TRANSITION Packet

   TRANSITION packets MUST be in the following format:

                  0        1  2  3  4  5  6  7  8       9
         +----------------+--+--+--+--+--+--+--+--+----------+
         | Index Type (A) |       Index (N)       | Type (A) | ...
         +----------------+--+--+--+--+--+--+--+--+----------+
             10...
         +============+
         | Packet (A) |
         +============+

         Index Type (Binary Data):               [1 octet]
            [01] - Frame
            [02] - Cycle Count
            [03] - Milliseconds
            [04] - Microseconds * 10
            [05] - INPUT_CHUNK Index
         Index (Unsigned Integer)                [8 octets]
         Type (Binary Data):                     [1 octet]
            [01] - Soft Reset
            [02] - Power Reset
            [03] - Restart TASD File
            [FF] - Packet Derived
         Inner Packet (Binary Data)              [PLEN - 10 octets]

   *Input Type*
      Determines specific timing type for start of transition.

   *Index*
      Time or offset value to start transition.

   *Type*
      Type of transition.  If *Type* is [FF], the transition action will
      be interpreting a *TASD* packet.

   *Inner Packet*
      If *Type* is [FF], *Inner Packet* SHOULD be a *TASD* packet.
      *Inner Packet* MUST NOT be a *INPUT_CHUNK*, *INPUT_MOMENT*,
      *TRANSITION*, *LAG_FRAME_CHUNK*, or *MOVIE_TRANSITION* packet.

   *PLEN*
      Length of the packet payload (Not *Inner Packet* length).

3.3.5.4.  LAG_FRAME_CHUNK Packet

   LAG_FRAME_CHUNK packets MUST be in the following format:

           0    1    2    3   4  5  6  7
         +----+----+----+----+--+--+--+--+
         |  Movie Frame (N)  | Count (N) |
         +----+----+----+----+--+--+--+--+

         Movie Frame (Unsigned Integer)          [4 octets]
         Count (Unsigned Integer)                [4 octets]

   *Movie Frame*
      Frame number of the TAS movie where Lag Frames start (*Movie
      Frame* MUST be *0-indexed*).

   *Count*
      Number of Lag Frames in a row starting from *Movie Frame*.

3.3.5.5.  MOVIE_TRANSITION

   MOVIE_TRANSITION packets MUST be in the following format:

           0    1    2    3       4             5...
         +----+----+----+----+----------+==================+
         |  Movie Frame (N)  | Type (A) | Inner Packet (A) |
         +----+----+----+----+----------+==================+

         Movie Frame (Unsigned Integer)          [4 octets]
         Type (Binary Data):                     [1 octet]
            [01] - Soft Reset
            [02] - Power Reset
            [03] - Restart TASD File
            [FF] - Packet Derived
         Inner Packet (Binary Data)              [PLEN - 5 octets]

   *Movie Frame*
      Frame number of the TAS movie (*Movie Frame* MUST be *0-indexed*).

   *Type*
      Type of transition.  If *Type* is [FF], the transition action will
      be interpreting a *TASD* packet.

   *Inner Packet*
      If *Type* is [FF], *Inner Packet* SHOULD be a *TASD* packet.
      *Inner Packet* MUST NOT be a *INPUT_CHUNK*, *INPUT_MOMENT*,
      *TRANSITION*, *LAG_FRAME_CHUNK*, or *MOVIE_TRANSITION* packet.

   *PLEN*
      Length of the packet payload (Not *Inner Packet* length).

3.3.6.  Extraneous Key Payload Formats

3.3.6.1.  COMMENT Packet

   COMMENT packets MUST be in the following format:

                0
         +=============+
         | Comment (S) |
         +=============+

         Comment (String)                        [PLEN octet]

   *Comment*
      Comment text.

   *PLEN*
      Length of the packet payload.

3.3.6.2.  EXPERIMENTAL Packet

   EXPERIMENTAL packets MUST be in the following format:

                 0...
         +==================+
         | Experimental (B) |
         +==================+

         Experimental (Boolean)                  [PLEN octet]

   *Experimental*
      Boolean data that is *TRUE* if the TASD file is using draft/
      experimental features (Currently SHOULD be *TRUE*) and *FALSE* if
      the TASD file is using only stable features.

   *PLEN*
      Length of the packet payload.

3.3.6.3.  UNSPECIFIED Packet

   UNSPECIFIED packets MUST be in the following format:

                   0...
         +======================+
         | Unspecified Data (A) |
         +======================+

         Unspecified Data (Binary Data)          [PLEN octets]

   *Unspecified Data*
      Arbitrary data.  Can be used for any data.  Because this is
      unspecified data, there there is no guarantee any software to
      control a TAS replay device will support data in this packet type.

   *PLEN*
      Length of the packet payload.

4.  Controller Input Formats

   A forward slash (*/*) is used to signify *active low*.  As an
   example, if a bit is labeled as */A*, the bit MUST be 0 if the A
   button is pressed and MUST be 1 if the A button is not pressed.

   Multi-octet controller inputs are in little-endian order

   Bit order for octets in controller inputs are high-order (MSB) (Most
   significant bit to least significant bit), so bit 7 MUST be the left-
   most bit of the octet and bit 0 MUST be the right-most bit of the
   octet.

4.1.  NES/Famicom Controller Types

4.1.1.  NES Standard Controller

   Single Input Length: 1 Octet

   *Octet 0*

   Bit 7:  /A
   Bit 6:  /B
   Bit 5:  /Select
   Bit 4:  /Start
   Bit 3:  /Up
   Bit 2:  /Down
   Bit 1:  /Left
   Bit 0:  /Right

4.1.2.  NES Four Score

   Single Input Length: 3 Octets

   *Octet 0*

   Bit 7:  Controller N-1 /A
   Bit 6:  Controller N-1 /B
   Bit 5:  Controller N-1 /Select
   Bit 4:  Controller N-1 /Start
   Bit 3:  Controller N-1 /Up
   Bit 2:  Controller N-1 /Down
   Bit 1:  Controller N-1 /Left
   Bit 0:  Controller N-1 /Right

   *Octet 1*

   Bit 7:  Controller N-2 /A
   Bit 6:  Controller N-2 /B
   Bit 5:  Controller N-2 /Select
   Bit 4:  Controller N-2 /Start
   Bit 3:  Controller N-2 /Up
   Bit 2:  Controller N-2 /Down
   Bit 1:  Controller N-2 /Left
   Bit 0:  Controller N-2 /Right

   *Octet 2*

   Bit 7:  1
   Bit 6:  1
   Bit 5:  0 if Controller Port is 2, otherwise 1
   Bit 4:  0 if Controller Port is 1, otherwise 1
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  1

   *Controller N* is the controller port number.  The NES Four Score
   allows players 1 and 3 to input buttons on controller port 1 and
   players 2 and 4 to input buttons on controller port 2.  *Controller
   N-1* on controller port 1 is *Player 1*, *Controller N-2* on
   controller port 1 is *Player 3*, *Controller N-1* on controller port
   2 is *Player 2*, and *Controller N-2* on controller port 2 is *Player
   4*.

4.2.  SNES Controller Types

4.2.1.  SNES Standard Controller

   Single Input Length: 2 Octets

   *Octet 0*

   Bit 7:  /B
   Bit 6:  /Y
   Bit 5:  /Select
   Bit 4:  /Start
   Bit 3:  /Up
   Bit 2:  /Down
   Bit 1:  /Left
   Bit 0:  /Right

   *Octet 1*

   Bit 7:  /A
   Bit 6:  /X
   Bit 5:  /L
   Bit 4:  /R
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  1

4.2.2.  SNES Mouse

   Single Input Length: 4 Octets

   *Octet 0*

   Bit 7:  1
   Bit 6:  1
   Bit 5:  1
   Bit 4:  1
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  1

   *Octet 1*

   Bit 7:  /Right button
   Bit 6:  /Left button
   Bit 5:  Current sensitivity (0: high sensitivity; 1: low or medium
      sensitivity)
   Bit 4:  Current sensitivity (0: medium sensitivity; 1: low or high
      sensitivity)
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  0

   *Octet 2*

   Bits 7-1:  /Vertical displacement since last read
   Bit 0:  Direction (0: up; 1: down)

   *Octet 3*

   Bits 7-1:  /Horizontal displacement since last read
   Bit 0:  Direction (0: up; 1: down)

4.2.3.  SNES Super Multitap

   Single Input Length: 5 Octets

   *Octet 0* :

   Bit 7:  1
   Bit 6:  1
   Bit 5:  1
   Bit 4:  1
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  I/O Pin State - *1* if Multitap ports *1 and 2* are being
      polled, *0* if ports *3 and 4* are.

   *Octet 1*

   Bit 7:  Controller N-1 or N-3 /B
   Bit 6:  Controller N-1 or N-3 /Y
   Bit 5:  Controller N-1 or N-3 /Select
   Bit 4:  Controller N-1 or N-3 /Start
   Bit 3:  Controller N-1 or N-3 /Up
   Bit 2:  Controller N-1 or N-3 /Down
   Bit 1:  Controller N-1 or N-3 /Left
   Bit 0:  Controller N-1 or N-3 /Right

   *Octet 2*

   Bit 7:  Controller N-1 or N-3 /A
   Bit 6:  Controller N-1 or N-3 /X
   Bit 5:  Controller N-1 or N-3 /L
   Bit 4:  Controller N-1 or N-3 /R
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  1

   *Octet 3*

   Bit 7:  Controller N-2 or N-4 /B
   Bit 6:  Controller N-2 or N-4 /Y
   Bit 5:  Controller N-2 or N-4 /Select
   Bit 4:  Controller N-2 or N-4 /Start
   Bit 3:  Controller N-2 or N-4 /Up
   Bit 2:  Controller N-2 or N-4 /Down
   Bit 1:  Controller N-2 or N-4 /Left
   Bit 0:  Controller N-2 or N-4 /Right

   *Octet 4*

   Bit 7:  Controller N-2 or N-4 /A
   Bit 6:  Controller N-2 or N-4 /X
   Bit 5:  Controller N-2 or N-4 /L
   Bit 4:  Controller N-2 or N-4 /R
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  1

   *Controller N* is the controller port number on the console that the
   Multitap is connected to. *Controller N-1...N-4* are the controller
   ports *1...4* on the Multitap.  Two Multitap ports are polled
   simultaneously by the game - either *1 and 2*, or *3 and 4*. The I/O
   Pin state in octet 0 MUST be *1* for multitap ports *1 and 2*, or *0*
   for ports *3 and 4*.

4.3.  N64 Controller Types

4.3.1.  N64 Standard Controller

   Single Input Length: 4 Octets

   *Octet 0*

   Bit 7:  A
   Bit 6:  B
   Bit 5:  Z
   Bit 4:  Start
   Bit 3:  D-Pad Up
   Bit 2:  D-Pad Down
   Bit 1:  D-Pad Left
   Bit 0:  D-Pad Right

   *Octet 1*

   Bit 7:  RST (special controller reset bit)
   Bit 6:  0
   Bit 5:  Left Trigger
   Bit 4:  Right Trigger
   Bit 3:  C-Up
   Bit 2:  C-Down
   Bit 1:  C-Left
   Bit 0:  C-Right

   *Octet 2*

   Bits 7-0:  Analog Stick X-Axis (signed 8-bit number)

   *Octet 3*

   Bits 7-0:  Analog Stick Y-Axis (signed 8-bit number)

4.3.2.  N64 Standard Controller with Rumble

   Single Input Length: 4 Octets

   *Octet 0*

   Bit 7:  A
   Bit 6:  B
   Bit 5:  Z
   Bit 4:  Start
   Bit 3:  D-Pad Up
   Bit 2:  D-Pad Down
   Bit 1:  D-Pad Left
   Bit 0:  D-Pad Right

   *Octet 1*

   Bit 7:  RST (special controller reset bit)
   Bit 6:  0
   Bit 5:  Left Trigger
   Bit 4:  Right Trigger
   Bit 3:  C-Up
   Bit 2:  C-Down
   Bit 1:  C-Left
   Bit 0:  C-Right

   *Octet 2*

   Bits 7-0:  Analog Stick X-Axis (signed 8-bit number)

   *Octet 3*

   Bits 7-0:  Analog Stick Y-Axis (signed 8-bit number)

4.3.3.  N64 Standard Controller with Controller Pak

   Single Input Length: 4 Octets

   *Octet 0*

   Bit 7:  A
   Bit 6:  B
   Bit 5:  Z
   Bit 4:  Start
   Bit 3:  D-Pad Up
   Bit 2:  D-Pad Down
   Bit 1:  D-Pad Left
   Bit 0:  D-Pad Right

   *Octet 1*

   Bit 7:  RST (special controller reset bit)
   Bit 6:  0
   Bit 5:  Left Trigger
   Bit 4:  Right Trigger
   Bit 3:  C-Up
   Bit 2:  C-Down
   Bit 1:  C-Left
   Bit 0:  C-Right

   *Octet 2*

   Bits 7-0:  Analog Stick X-Axis (signed 8-bit number)

   *Octet 3*

   Bits 7-0:  Analog Stick Y-Axis (signed 8-bit number)

4.3.4.  N64 Standard Controller with Transfer Pak

   Single Input Length: 4 Octets

   *Octet 0*

   Bit 7:  A
   Bit 6:  B
   Bit 5:  Z
   Bit 4:  Start
   Bit 3:  D-Pad Up
   Bit 2:  D-Pad Down
   Bit 1:  D-Pad Left
   Bit 0:  D-Pad Right

   *Octet 1*

   Bit 7:  RST (special controller reset bit)
   Bit 6:  0
   Bit 5:  Left Trigger
   Bit 4:  Right Trigger
   Bit 3:  C-Up
   Bit 2:  C-Down
   Bit 1:  C-Left
   Bit 0:  C-Right

   *Octet 2*

   Bits 7-0:  Analog Stick X-Axis (signed 8-bit number)

   *Octet 3*

   Bits 7-0:  Analog Stick Y-Axis (signed 8-bit number)

4.3.5.  N64 Mouse

   Single Input Length: 4 Octets

   *Octet 0*

   Bit 7:  A
   Bit 6:  B
   Bit 5:  0
   Bit 4:  0
   Bit 3:  0
   Bit 2:  0
   Bit 1:  0
   Bit 0:  0

   *Octet 1*

   Bit 7:  0
   Bit 6:  0
   Bit 5:  0
   Bit 4:  0
   Bit 3:  0
   Bit 2:  0
   Bit 1:  0
   Bit 0:  0

   *Octet 2*

   Bits 7-0:  Relative X-Axis position (signed 8-bit number)

   *Octet 3*

   Bits 7-0:  Relative Y-Axis position (signed 8-bit number)

4.3.6.  N64 Densha de Go

   Single Input Length: 4 Octets

   *Octet 0*

   Bit 7:  A
   Bit 6:  B
   Bit 5:  Accelerator
   Bit 4:  Start
   Bit 3:  Accelerator
   Bit 2:  0
   Bit 1:  0
   Bit 0:  Accelerator

   *Octet 1*

   Bit 7:  0
   Bit 6:  0
   Bit 5:  C
   Bit 4:  Select
   Bits 3-0:  Brake

   *Octet 2*

   Bit 7:  0
   Bit 6:  0
   Bit 5:  0
   Bit 4:  0
   Bit 3:  0
   Bit 2:  0
   Bit 1:  0
   Bit 0:  0

   *Octet 3*

   Bit 7:  0
   Bit 6:  0
   Bit 5:  0
   Bit 4:  0
   Bit 3:  0
   Bit 2:  0
   Bit 1:  0
   Bit 0:  0

4.4.  GameCube Controller Types

4.4.1.  GameCube Standard Controller

   Single Input Length: 8 Octets

   *Octet 0*

   Bit 7:  0
   Bit 6:  0
   Bit 5:  0
   Bit 4:  Start
   Bit 3:  Y
   Bit 2:  X
   Bit 1:  B
   Bit 0:  A

   *Octet 1*

   Bit 7:  1
   Bit 6:  L
   Bit 5:  R
   Bit 4:  Z
   Bit 3:  D-Pad Up
   Bit 2:  D-Pad Down
   Bit 1:  D-Pad Right
   Bit 0:  D-Pad Left

   *Octet 2*

   Bits 7-0:  Analog Stick X-Axis (signed 8-bit number)

   *Octet 3*

   Bits 7-0:  Analog Stick Y-Axis (signed 8-bit number)

   *Octet 4*

   Bits 7-0:  C-Stick X-Axis (signed 8-bit number)

   *Octet 5*

   Bits 7-0:  C-Stick Y-Axis (signed 8-bit number)

   *Octet 6*

   Bits 7-0:  L Analog Value (unsigned 8-bit number)

   *Octet 7*

   Bits 7-0:  R Analog Value (unsigned 8-bit number)

4.5.  Game Boy Controller Types

4.5.1.  GB Standard Controller

   Single Input Length: 1 Octet

   *Octet 0*

   Bit 7:  /Down
   Bit 6:  /Up
   Bit 5:  /Left
   Bit 4:  /Right
   Bit 3:  /Start
   Bit 2:  /Select
   Bit 1:  /B
   Bit 0:  /A

4.6.  Game Boy Color Controller Types

4.6.1.  GBC Standard Controller

   Single Input Length: 1 Octet

   *Octet 0*

   Bit 7:  /Down
   Bit 6:  /Up
   Bit 5:  /Left
   Bit 4:  /Right
   Bit 3:  /Start
   Bit 2:  /Select
   Bit 1:  /B
   Bit 0:  /A

4.7.  Game Boy Advance Controller Types

4.7.1.  GBA Standard Controller

   Single Input Length: 2 Octets

   *Octet 0*

   Bit 7:  1
   Bit 6:  1
   Bit 5:  1
   Bit 4:  1
   Bit 3:  1
   Bit 2:  1
   Bit 1:  /L
   Bit 0:  /R

   *Octet 1*

   Bit 7:  /Down
   Bit 6:  /Up
   Bit 5:  /Left
   Bit 4:  /Right
   Bit 3:  /Start
   Bit 2:  /Select
   Bit 1:  /B
   Bit 0:  /A

4.8.  Genesis Controller Types

4.8.1.  Genesis (Mega Drive) 3-Button

   Single Input Length: 1 Octet

   *Octet 0*

   Bit 7:  /Up
   Bit 6:  /Down
   Bit 5:  /Left
   Bit 4:  /Right
   Bit 3:  /B
   Bit 2:  /C
   Bit 1:  /A
   Bit 0:  /Start

4.8.2.  Genesis (Mega Drive) 6-Button

   Single Input Length: 2 Octets

   *Octet 0*

   Bit 7:  /Up
   Bit 6:  /Down
   Bit 5:  /Left
   Bit 4:  /Right
   Bit 3:  /B
   Bit 2:  /C
   Bit 1:  /A
   Bit 0:  /Start

   *Octet 1*

   Bit 7:  /Z
   Bit 6:  /Y
   Bit 5:  /X
   Bit 4:  /Mode
   Bit 3:  1
   Bit 2:  1
   Bit 1:  1
   Bit 0:  1

4.9.  Atari 2600 Controller Types

4.9.1.  A2600 Joystick

   Single Input Length: 1 Octet

   *Octet 0*

   Bit 7:  /Up
   Bit 6:  /Down
   Bit 5:  /Left
   Bit 4:  /Right
   Bit 3:  1
   Bit 2:  /Button
   Bit 1:  1
   Bit 0:  1

4.9.2.  A2600 Keyboard Controller

   Single Input Length: 1 Octet

   *Octet 0*

   Bit 7:  /Row1 (key 1, 2, or 3 pressed)
   Bit 6:  /Row2 (key 4, 5, or 6 pressed)
   Bit 5:  /Row3 (key 7, 8, or 9 pressed)
   Bit 4:  /Row4 (key *, 0, or # pressed)
   Bit 3:  /Column1 (key 1, 4, 7, or * pressed)
   Bit 2:  /Column3 (key 3, 6, 9, or # pressed)
   Bit 1:  /Column2 (key 2, 5, 8, or 0 pressed)
   Bit 0:  1

5.  References

5.1.  Normative References

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

Copyright Notice

   Copyright (c) 2021-2023, Vi Grey, Bigbass, and rasteri

   All rights reserved.

   Redistribution and use of this documentation in source (XML format)
   and/or "compiled" forms (TXT, PDF, HTML, etc), with or without
   modification, are permitted provided that the following conditions
   are met:

   1.  Redistributions of source code (XML format) of this documentation
       must retain the above copyright notice, this list of conditions,
       and the following disclaimer in the documentation.

   2.  Redistributions in compiled form (Converted to TXT, PDF, HTML,
       and other formats) of this documentation must reproduce the above
       copyright notice, this list of conditions, and the following
       disclaimer in the documentation.

   THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY
   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
   BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
   OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Authors' Addresses

   Vi Grey
   Email: vi@vigrey.com
   URI:   https://vigrey.com


   Bigbass
   URI:   https://github.com/bigbass1997


   rasteri
   URI:   https://github.com/rasteri