lsnes rr2-β11
[lsnes.git] / manual.txt
blobc5943a6becd3596c9f42ccc538a23e238c2f01a5
1 1 Introduction
3 lsnes is SNES rerecording emulator based on bsnes core.
5 2 Dependencies
7 1. bsnes libsnes (for bsnes SNES core)
9   (a) v084-v087 (v084 or v085 for delayreset support)
11   (b) accuracy or compatiblity core with debugger enabled.
13   (c) Patched version (using included 7 patches)
15 2. gambatte (for gambatte core)
17   (a) SVN r320, r358 or r364
19   (b) Patched with included patches
21 3. Zlib
23 4. boost_iostreams
25 5. boost_filesystem
27 6. boost_thread (if native std::thread is not available)
29 7. libsdl (SDL only)
31 8. sdlmain (SDL only, part of SDL)
33 9. boost_conversion (this is header-only library)
35 10. libswscale (wxwidgets graphics only)
37 11. Portaudio (portaudio sound only)
39 12. libao (libao sound only)
41 13. Lua version 5.1.X or 5.2.X
43 14. G++ 4.6 or 4.7
45 15. libopus (optional, for commentary track tool)
47 3 Building
49 • Copy bsnes sources (the bsnes subdirectory) to subdirectory 
50   'bsnes' (for bsnes core).
52 • Copy gambatte sources to subdirectory 'gambatte' (for gambatte 
53   core).
55 • Patch the bsnes sources with included patches (directory 
56   'bsnes-patches/<version>', bsnes core)
58 • Patch the gambatte sources with included patches (directory 
59   'gambatte-patches/<version>', gambatte core)
61 • Edit options.build (or copy of that file)
63 • Run make (passing 'OPTIONS=<filename>' if using something else 
64   than options.build).
66 4 Command line options
68 4.1 Wxwidgets options
70 4.1.1 --rom=<file>
72 Load <file> as ROM.
74 4.1.2 <file>
76 Load <file> as ROM.
78 4.1.3 --load=<file>
80 Load <file> as movie or savestate file on startup.
82 4.1.4 --settings
84 Instead of starting the emulator, only display the settings.
86 4.1.5 --lua=<file>
88 Run this Lua file on startup
90 4.2 dump options (lsnes-dumpavi only)
92 4.2.1 --rom=<file>
94 Load <file> as ROM. Required.
96 4.2.2 <filename>
98 Load <filename> as movie or savestate file on startup. Required.
100 4.2.3 --dumper=<dumper>
102 Set the dumper to use (required). Use 'list' for listing of known 
103 dumpers.
105 4.2.4 --firmware-path=<path>
107 Set path to look for firmware.
109 4.2.5 --mode=<mode>
111 Set the mode to use (required for dumpers with multiple modes, 
112 forbidden otherwise). Use 'list' for known modes.
114 4.2.6 --prefix=<prefix>
116 Set dump prefix. Default is “avidump”.
118 4.2.7 --option=<name>=<value>
120 Set option <name> to value <value>.
122 4.2.8 --length=<length>
124 Set number of frames to dump. Mandatory, unless --overdump-length 
125 is specified.
127 4.2.9 --overdump-length=<length>
129 Set number of frames to dump after movie end. Mutually exclusive 
130 with --length.
132 4.2.10 --lua=<script>
134 Run specified lua script (lsnes-dumpavi does not have 
135 initialization files).
137 4.2.11 --load-library=<library>
139 Load the specified shared object / dynamic library / dynamic link 
140 library.
142 4.3 lsnes settings directory
144 The lsnes settings directory is (in order of decreasing 
145 perference):
147 • Windows: %APPDATA%\lsnes (if %APPDATA% exists)
149 • Unix: $XDG_CONFIG_HOME/lsnes (if $XDG_CONFIG_HOME exists)
151 • Unix: $HOME/.config/lsnes (if $HOME exists)
153 • All: . (fallback default).
155 If leading directories do not exist, attempt to create them is 
156 made.
158 5 Internal commands
160 • Commands beginning with '*' invoke the corresponding command 
161   without alias expansion.
163 • If command starts with '+' (after possible '*'), the command is 
164   executed as-is when button is pressed, and when button is 
165   released, it is executed with '+' replaced by '-'.
167 • Commands without '+' execute only on negative edge (release).
169 5.1 run-script <script>
171 Run <script> as if commands were entered on the command line.
173 5.2 Memory manipulation
175 <address> may be decimal or hexadecimal (prefixed with '0x'). 
176 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
177 signed (prefixed with '-') decimal.
179 The available element <sizes> are:
181 • byte: 1 byte
183 • word: 2 bytes
185 • hword: 3 bytes
187 • dword: 4 bytes
189 • qword: 8 bytes
191 • float: 4 bytes (floating-point)
193 • double: 8 bytes (floating-point)
195 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
196 When dealing with DSP memory, multi-byte reads/writes are 
197 native-endian (do not use operand sizes exceeding DSP bitness, 
198 except dword is OK for 24-bit memory).
200 5.2.1 read-<size> <address>
202 Read the value of byte in <address>.
204 5.2.2 read-s<size> <address>
206 Read the value of signed byte in <address>.
208 5.2.3 write-<size> <address> <value>
210 Write <value> to byte in address <address>.
212 5.3 Main commands
214 These commands are not available in lsnesrc, but are available 
215 after ROM has been loaded.
217 5.3.1 quit-emulator
219 Quits the emulator.
221 5.3.2 pause-emulator
223 Toggle paused/unpaused
225 5.3.3 +advance-frame 
227 Advance frame. If the button is still held after configurable 
228 timeout expires, game unpauses for the duration frame advance is 
229 held.
231 5.3.4 +advance-poll 
233 Advance subframe. If the button is still held after configurable 
234 timeout expires, game unpauses for the duration frame advance is 
235 held.
237 5.3.5 advance-skiplag 
239 Skip to first poll in frame after current.
241 5.3.6 reset 
243 Reset the SNES after this frame.
245 5.3.7 load <filename> 
247 Load savestate <filename> in current mode.
249 5.3.8 load-state <filename> 
251 Load savestate <filename> in readwrite mode.
253 5.3.9 load-readonly <filename> 
255 Load savestate <filename> in readonly mode.
257 5.3.10 load-preserve <filename> 
259 Load savestate <filename> in readonly mode, preserving current 
260 events.
262 5.3.11 load-movie <filename> 
264 Load savestate <filename>, ignoring save part in readonly mode.
266 5.3.12 save-state <filename> 
268 Save system state to <filename> as soon as possible.
270 5.3.13 save-movie <filename> 
272 Save movie to <filename>.
274 5.3.14 set-rwmode 
276 Set read-write mode.
278 5.3.15 set-romode 
280 Set read-only mode
282 5.3.16 toggle-rwmode 
284 Toggle between read-only and read-write modes.
286 5.3.17 test-1, test-2, test-3
288 Internal test commands. Don't use.
290 5.3.18 take-screenshot <filename> 
292 Save screenshot to <filename>.
294 5.3.19 +controller <class>-<#>-<button>
296 Press button <button> on controller <num> of class <class>.
298 • Class 'gamepad': A, B, X, Y, L, R, select, start, up, down, 
299   left, right, ext0, ext1, ext2, ext3
301 • Class 'mouse': L, R
303 • Class 'superscope': trigger, cursor, turbo, pause
305 • Class 'justifier': trigger, start
307 • Class 'gb': A, B, select, start, up, down, left, right
309 5.3.20 hold-controller <class>-<#>-<button>
311 Hold/unhold button <button> on controller <num> of class <class>.
313 5.3.21 type-controller <class>-<#>-<button>
315 Hold/unhold button <button> on controller <num> of class <class> 
316 for the next frame. See +controller for button names.
318 Cauntion: Does not work properly if outside frame advance.
320 5.3.22 +autofire-controller <class>-<#>-<button> [[<duty>] 
321   <cyclelen>]
323 Start autofire. If duty is not specified, defaults to 1. If 
324 <cyclelen> is not specified, defaults to 2.
326 5.3.23 -autofire-controller <class>-<#>-<button> [[<duty>] 
327   <cyclelen>]
329 End autofire.
331 5.3.24 autofire-controller <class>-<#>-<button> [[<duty>] 
332   <cyclelen>]
334 Toggle autofire. If autofire is turned on, specified cycle is 
335 used.
337 5.3.25 designate-position <class>-<#>-analog<n>
339 Designate position for analog pair. <n> is only there if there 
340 are multiple axis pairs.
342 5.3.26 repaint
344 Force a repaint.
346 5.3.27 toggle-pause-on-end
348 Toggle pause on end flag.
350 5.3.28 set-pause-on-end
352 Set pause on end flag.
354 5.3.29 clear-pause-on-end
356 Clear pause on end flag.
358 5.3.30 action <action> [<parameters>]
360 Run specified core action.
362 5.4 Save jukebox 
364 5.4.1 cycle-jukebox-backward
366 Cycle save jukebox backwards.
368 5.4.2 cycle-jukebox-forward
370 Cycle save jukebox forwards
372 5.4.3 load-jukebox
374 Do load from jukebox (current mode).
376 5.4.4 save-jukebox
378 Do state save to jukebox.
380 5.5 Lua 
382 5.5.1 evaluate-lua <luacode>
384 Run Lua code <luacode> using built-in Lua interpretter.
386 5.5.2 L <luacode>
388 Synonym for evaluate-lua.
390 5.5.3 run-lua <script>
392 Run specified lua file using built-in Lua interpretter.
394 5.5.4 reset-lua
396 Clear the Lua VM state and restore to factory defaults.
398 5.6 Memory watch
400 5.6.1 add-watch <name> <expression>
402 Adds new watch (or modifies old one).
404 5.6.2 remove-watch <name>
406 Remove a watch.
408 5.7 Sound 
410 5.7.1 enable-sound <on/off> 
412 Enable/Disable sound.
414 5.8 Misc.
416 5.8.1 reload-rom [<file>]
418 Reloads the main ROM image from <file>.
420 5.8.2 +tangent
422 Tangent for recording voice for commentary track. While pressed, 
423 record a stream.
425 5.8.3 advance-subframe-timeout
427 Subframe advance timeout in milliseconds. Default is 100.
429 6 Settings
431 6.1 Core settings
433 6.2 AVI dumper settings
435 6.2.1 avi-large
437 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
438 the console outputs.
440 6.2.2 avi-left-border
442 AVI dumper: Set the default left border thickness (unless lua 
443 overrides) for dumps. Range 0-8191. Default is 0.
445 6.2.3 avi-right-border
447 AVI dumper: Set the default right border thickness (unless lua 
448 overrides) for dumps. Range 0-8191. Default is 0.
450 6.2.4 avi-top-border
452 AVI dumper: Set the default top border thickness (unless lua 
453 overrides) for dumps. Range 0-8191. Default is 0.
455 6.2.5 avi-bottom-border
457 AVI dumper: Set the default bottom border thickness (unless lua 
458 overrides) for dumps. Range 0-8191. Default is 0.
460 6.2.6 avi-maxframes
462 AVI dumper: Maximum number of frames per dump segment (0 => 
463 unlimited). Range 0-999999999. Default is 0.
465 6.2.7 avi-compresison
467 AVI dumper: Compression level (0-18).
469 • Compression levels 10 and above are not compatible with stock 
470   CSCD codec.
472 • Recomended level is 7.
474 6.2.8 avi-soundrate
476 AVI dumper: Set method of determining the sound rate.
478 • 0: Pick nearest of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48, 
479   64, 88.2, 96, 128, 176.4 and 192 kHz.
481 • 1: Round down to nearest integer.
483 • 2: Round up to nearest ingeter.
485 • 3: Multiply by denominator.
487 • 4: High quality 44.1kHz (SRC needed).
489 • 5: High quality 48kHz (SRC needed).
491 6.3 JMD options
493 6.3.1 jmd-compression
495 JMD dumper: Compression level (0-9).
497 7 Movie editor
499 • The editor edits in-memory movie.
501 • Because past can't be edited and readwrite mode doesn't allow 
502   future, editing only works in read only mode.
504 • Keyboard triggers the normal hotkeys and bindings.
506 7.1 Left button actions
508 • Clicking on cell in future (indicated by lack of redish 
509   background) toggles it (if it is a button) or prompts for a 
510   value (if it is an axis)
512 • Dragging vertically toggles sequence of buttons or changes a 
513   sequence of axis values.
515 7.2 Right button actions
517 The right mouse button pops up a context-sensitive menu:
519 • Toggle <something>: Toggle this button
521 • Change <something>: Change this axis value
523 • Insert frame after: Insert a frame after this frame
525 • Append frame: Append a frame to movie
527 • Append frames: Append specified number of frames to movie
529 • Delete frame: Delete this frame
531 • Delete subframe: Delete this subframe
533 • Truncate movie: Delete this subframe and everything after it.
535 • Scroll to frame: Prompt for a frame and scroll the display to 
536   that frame.
538 • Scroll to current frame: Scroll the display to current position
540 • Run to frame: Prompts for frame and runs the emulation to that 
541   frame.
543 • Change number of lines visible: Change the height of the movie 
544   display (1 to 255).
546 • Lock scroll to playback: While playing back or rewinding 
547   movies, the display will follow if enabled.
549 8 Memory watch expression syntax
551 Memory watch expressions are in RPN (Reverse Polish Notation). At 
552 the end of expression, the top entry on stack is taken as the 
553 final result.
555 Notations:
557 • Evaluation order is strictly left to right.
559 • a is the entry on top of stack
561 • b is the entry immediately below top of stack
563 • ; separates values to be pushed (no intermediate pop).
565 • After end of element, all used stack slots are popped and all 
566   results are pushed.
568 • When pushing multiple values, the pushes occur in order shown.
570 The following operators are available:
572 • + : a + b
574 • - : a - b
576 • * : a * b
578 • / : a / b
580 • % : a % b
582 • a : atan(a)
584 • b : read_signed_byte(a)
586 • c : cos(a)
588 • d : read_signed_dword(a)
590 • f: read_float(a)
592 • i : quotent(a / b)
594 • o: read_signed_hword(a)
596 • p :\pi
599 • q : read_signed_qword(a)
601 • r : sqrt(a)
603 • s : sin(a)
605 • t : tan(a)
607 • u : a; a
609 • w : read_signed_word(a)
611 • A : atan2(a, b)
613 • B : read_unsigned_byte(a)
615 • C<number>z : Push number <number> to stack.
617 • D : read_unsigned_dword(a)
619 • C0x<number>z : Push number <number> (hexadecimal) to stack.
621 • F: read_double(a)
623 • H<digit> : Set hexadecimal mode with specified number of digits 
624   (use A-G for 10-16 digits).
626 • O: read_unsigned_hword(a)
628 • Q : read_unsigned_qword(a)
630 • R<digit> : round a to <digit> digits.
632 • W : read_unsigned_word(a)
634 8.1 Example:
636 C0x007e0878zWC0x007e002czW-
638 1. Push value 0x7e0878 on top of stack (C0x007e0878z).
640 2. Pop the value on top of stack (0x7e0878), read word value at 
641   that address and push the result,call it x1 (W).
643 3. Push value 0x7e002c on top of stack (C0x007e002cz).
645 4. Pop the value on top of stack (0x7e002c), read word value at 
646   that address and push the result,call it x2 (W).
648 5. Pop the two top numbers on stack, x1 and x2, substract x1 from 
649   x2 and push x2 - x1 (-).
651 6. Since the expression ends, the final memory watch result is 
652   the top one on stack, which is x2 - x1.
654 9 Modifier and key names:
656 9.1 wxWidgets platform
658 9.1.1 Modifier names:
660 Following modifier names are known:
662 • alt
664 • ctrl
666 • shift 
668 • meta
670 • cmd (Mac OS X only)
672 9.1.2 Key names:
674 Following key names are known:
676 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
677   dollar, percent, ampersand, quote, leftparen, rightparen, 
678   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
679   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
680   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
681   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
682   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
683   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
684   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
685   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
686   home, lefT, up, right, down, select, print, execute, snapshot, 
687   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
688   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
689   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
690   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
691   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
692   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
693   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
694   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
695   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
696   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
697   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
698   windows_right, windows_menu, command, special1, special2, 
699   special3, special4, special5, special6, special7, special8, 
700   special9, special10, special11, special12, special13, 
701   special14, special15, special16, special17, special18, 
702   special19, special20
704 10 Movie file format
706 Movie file is .zip archive in itself, normal ZIP archive tools 
707 work on it (note: If you recompress it, do not use compression 
708 methods other than store and deflate and especially do not use 
709 encryption of any kind).
711 10.1 Detecting clean start/SRAM/Savestate
713 • If file has member “savestate” it is savestate, otherwise:
715 • If file has members with names starting “moviesram.” it is 
716   movie starting from SRAM, otherwise:
718 • It is movie starting from clear state.
720 10.2 Member: gametype
722 Type of game ROM and region (as one line). Valid values are:
725 +--------------+---------------------+--------+
726 |    Value     |       System        | Region |
727 +--------------+---------------------+--------+
728 +--------------+---------------------+--------+
729 |  snes_pal    |     Super NES       |  PAL   |
730 +--------------+---------------------+--------+
731 |   sgb_pal    |   Super Game Boy    |  PAL   |
732 +--------------+---------------------+--------+
733 |  snes_ntsc   |     Super NES       |  NTSC  |
734 +--------------+---------------------+--------+
735 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
736 +--------------+---------------------+--------+
737 |     bsx      | BS-X (non-slotted)  |  NTSC  |
738 +--------------+---------------------+--------+
739 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
740 +--------------+---------------------+--------+
741 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
742 +--------------+---------------------+--------+
745 Frame rates are:
748 +---------+-----------------+
749 | Region  | Framerate (fps) |
750 +---------+-----------------+
751 +---------+-----------------+
752 |  PAL    |   322445/6448   |
753 +---------+-----------------+
754 |  NTSC   | 10738636/178683 |
755 +---------+-----------------+
758 10.3 Member: port1
760 Contains type of port #1 (as one line). Valid values are 'none', 
761 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
762 'gamepad'.
764 10.4 Member: port2
766 Contains type of port #2 (as one line). Valid values are 'none', 
767 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
768 'justifiers'. If not present, defaults to 'none'.
770 10.5 Member: gamename
772 Contains name of the game (as one line).
774 10.6 Member: authors
776 Contains authors, one per line. Part before '|' is the full name, 
777 part after is the nickname.
779 10.7 Member: systemid
781 Always “lsnes-rr1” (one line). Used to reject other saves.
783 10.8 Member: controlsversion
785 Always “0” (one line). Used to identify what controls are there.
787 10.9 Member: “coreversion”
789 Contains bsnes core version number (as one line).
791 10.10 Member: projectid
793 Contains project ID (as one line). Used to identify if two movies 
794 are part of the same project.
796 10.11 Member: {rom,slota,slotb}{,xml}.sha256
798 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
799 Absent if corresponding file is absent.
801 10.12 Member: moviesram.<name>
803 Raw binary startup SRAM of kind <name>. Only present in 
804 savestates and movies starting from SRAM.
806 10.13 Member: saveframe
808 Contains frame number (as one line) of frame movie was saved on. 
809 Only present in savestates.
811 10.14 Member: lagcounter
813 Current value of lag counter (as one line). Only present in 
814 savestates.
816 10.15 Member: pollcounters
818 Contains poll counters (currently 100 of them), one per line. 
819 Each line is raw poll count if DRDY is set for it. Otherwise it 
820 is negative poll count minus one. Only present in savestates.
822 10.16 Member: hostmemory
824 Raw binary dump of host memory. Only present in savestates.
826 10.17 Member: savestate
828 The raw binary savestate itself. Savestate detection uses this 
829 file, only present in savestates.
831 10.18 Member: screenshot
833 Screenshot of current frame. Only present in savestates. First 2 
834 bytes are big-endian width of image, rest are 24-bit RGB image 
835 data. Height of image is inferred from the width and size of 
836 data.
838 10.19 Member: sram.<name>
840 Raw binary SRAM of kind <name> at time of savestate. Only present 
841 in savestates.
843 10.20 Member: input
845 The actual input track, one line per subframe (blank lines are 
846 skipped).
848 • If the first byte of each line is '.', ' ', <tab> or '|', then 
849   the line is part of same frame as previous, otherwise it starts 
850   a new frame.
852 • First subframe must start a new frame.
854 Length of movie in frames is number of lines in input file that 
855 start a new frame.
857 10.21 Member: subtitles
859 Subtitle track. Optional.
861 • Each line is in form <firstframe> <numframes> <text>.
863 • Linefeed is encoded as \n, backslash is encoded as \\.
865 10.22 Member: rerecords
867 Contains textual base-10 rerecord count (as one line; emulator 
868 just writes this, it doesn't read it) + 1.
870 10.23 Member: rrdata
872 This member stores set of load IDs. There is one load ID per 
873 rerecord (plus one corresponding to start of project).
875 • This member constists of concatenation of records
877 • Each record is 2-36 bytes long and can represent 1-16,843,009 
878   consequtive IDs.
880 • IDs are interpretted as 256-bit big-endian integers with 
881   warparound.
883 • Initial predicted ID is all zeroes.
885 Format of each record is:
887 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
888   bits 5-6 are count length (countlen). Bit 7 is unused.
890 • 32-prefixlen bytes of ID.
892 • countlen bytes of big-endian count (count).
894 Records are processed as follows:
896 • To form the first ID encoded by record, take the first 
897   prefixlen bytes predicted ID and append the read ID value to 
898   it. The result is the first ID encoded.
900 • If countlen is 0, record encodes 1 ID.
902 • If countlen is 1, record encodes 2+count IDs.
904 • If countlen is 2, record encodes 258+count IDs.
906 • If countlen is 3, record encodes 65794+count IDs.
908 • The new predicted ID is the next ID after last one encoded by 
909   the record.
911 The number of rerecords + 1 is equal to the sum of number of IDs 
912 encoded by all records.
914 10.24 Member: starttime.second
916 Movie starting time, second part. Epoch is Unix epoch. Default is 
917 1,000,000,000.
919 10.25 Member: starttime.subsecond
921 Movie starting time, subsecond part. Unit is CPU clocks. Default 
922 is 0.
924 10.26 Member: savetime.second
926 Movie saving time, second part. Default is starttime.second. Only 
927 present in savestates.
929 10.27 Member: savetime.subsecond
931 Movie saving time, subsecond part. Default is 
932 starttime.subsecond. Only present in savestates.
934 11 lsvs file format (commentary tracks)
936 11.1 Clusters
938 • Each cluster is 8kB (8192 bytes) in size.
940 • Cluster n starts at offset 8192*n in file.
942 • The following clusters are system special:
944   – Cluster 0 and all clusters with number multiple of 2048 
945     (cluster tables)
947   – Cluster 1 (superblock)
949 11.2 Cluster tables
951 • The cluster table describing cluster n is stored in cluster n & 
952   ~0x7FF (zero last 11 bits of n).
954 • This cluster table consists of 2048 4-byte big-endian integers.
956 • Each entry describes a cluster in 16MB supercluster, in order.
958 • The valid values for entries are:
960   – 0x00000000: Free cluster
962   – 0x00000001: Last cluster in chain.
964   – 0xFFFFFFFF: System cluster (cluster tables and superblock)
966   – (anything else): Number of next cluster in chain. Must not be 
967     multiple of 2048.
969 • Due to limitations of the format, there can be at most 2097052 
970   superclusters, giving maximum file size of 16TB.
972 11.3 Stream table
974 • The stream table chain always starts in cluster 2.
976 • Otherwise, it follows normal chaining.
978 • The stream table consists of 16-byte entries:
980   – The first 8 bytes of entry give big-endian beginning position 
981     of stream in units of 1/48000 s.
983   – The next 4 bytes of entry give big-endian beginning cluster 
984     for control data. 0 here marks the entry as not present.
986   – The last 4 bytes of entry give big-endian beginning cluster 
987     for codec data.
989 • Stream table clusters are normal clusters, following normal 
990   chaining.
992 • The stream begnning position is not guarenteed unique. There 
993   can be multiple streams with the same starting position in the 
994   file.
996 11.4 Stream control data
998 • The stream control data consists of entries 4 bytes each:
1000   – The first 2 bytes of entry gives big-endian length of packet
1002   – The next byte of entry gives audio length of packet in units 
1003     of 1/400 s.
1005   – The last byte is control byte.
1007     ∗ 0 means this entry is not present and the control data 
1008       ends.
1010     ∗ 1 is valid control entry.
1012 • The stream control data can also end by running into end of the 
1013   readable chain.
1015   – This happens if there happens to be exact multiple of 2048 
1016     packets in stream and number of packets is nonzero.
1018 • These clusters follow normal chaining.
1020 11.5 Stream codec data
1022 • Stream codec data consists of raw Opus data packets packed back 
1023   to back with nothing in between.
1025 • Warning: Due to internal limitations, this data must reside in 
1026   the first 65536 superclusters (that is, the first 1TB of the 
1027   file).
1029 11.6 Superblock
1031 • The superblock is stored in cluster 1. 
1033 • The first 11 bytes are “sefs-magic”<NUL>.
1035 • The rest are unused.
1037 • This cluster 1 is marked as system special.
1039 12 Known ROM extensions
1041 • SNES cartridge ROMs: sfc, smc, swc, fig, ufo, sf2, gd3, gd7, 
1042   dx2, mgd, mgh.
1044 • DMG cartridge ROMs: dmg, gb.
1046 • GBC cartridge ROMs: cgb, gbc.
1048 13 Gamepack files
1050 • The first line must be: “[GAMEPACK FILE]”.
1052 • There is one needed line: “type <systype>”. This sets system 
1053   type to <systype>. The following system types are valid:
1055   – snes (SNES)
1057   – bsx (BS-X non-slotted)
1059   – bsxslotted (BS-X slotted)
1061   – sufamiturbo (Sufami Turbo)
1063   – sgb (Super Game Boy)
1065   – dmg (Game Boy)
1067   – gbc (Game Boy Color)
1069   – gbc_gba (Game Boy Color with GBA initial register values)
1071 • Optionally a region can be specified: “region <region>”. The 
1072   following values are valid:
1074   – autodetect (Autodetect region: snes and sgb only)
1076   – ntsc (NTSC: snes, bsx, bsxslotted, sufamiturbo, sgb)
1078   – pal (PAL: snes, sgb)
1080   – world (World: dmg, gbc, gbc_gba)
1082 • ROM images are loaded as: “rom <type> <file>”. The following 
1083   types are valid:
1085   – rom (Cartridge ROM in snes, dmg, gbc, gbc_gba. BIOS in bsx, 
1086     bsxslotted, sufamiturbo)
1088   – bsx (Cartridge ROM in bsx, bsxslotted)
1090   – slot-a (Cartridge ROM in sufamiturbo)
1092   – slot-b (Cartridge ROM in sufamiturbo)
1094 • ROM markup can be loaded as: “xml <type> <file>”. The types 
1095   valid are the same as for ROMs.
1097 • Patches can be loaded as “patch[<offset>] <type> <file>”. The 
1098   types are the same as for ROMs.
1100   – Offset is given in form [+-]<number>. Usually offset is 
1101     either +0 or -512.
1103   – Default offset is +0.
1105 13.1 Example:
1107 [GAMEPACK FILE]
1109 type snes
1111 rom rom speedygonzales.sfc
1113 patch-512 rom sonicthehedgehog.ips
1115 13.2 Example 2:
1117 [GAMEPACK FILE]
1119 type sgb
1121 rom rom supergameboy.sfc
1123 rom dmg megamanV.dmg
1125 14 Quick'n'dirty encode guide
1127 1. Start the emulator and load the ROM and movie file.
1129 2. Set large AVI option 'set-setting avi-large on'
1131 3. Enable dumping 'dump-avi tmpdump' 
1133 4. Unpause and let it run until you want to end dumping.
1135 5. Close the emulator (closing the window is the easiest way). Or 
1136   use 'end-avi'.
1138 6. For each tmpdump*.avi file created, on command prompt, do 
1139   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
1141 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
1143 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
1144   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
1145   tmpdump_<numbers>.mkv, with + in between).
1147 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
1148   final.mkv contains quick'n'dirty encode.
1150 15 Axis configurations for some gamepad types:
1152 15.1 XBox360 controller:
1154 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
1155 set to pressure-+.
1157 set-axis joystick0axis2 pressure-+
1159 set-axis joystick0axis5 pressure-+
1161 • This is needed for SDL only. EVDEV sets those types correctly.
1163 15.2 PS3 “sixaxis” controller:
1165 Axes 8-19 should be disabled.
1167 set-axis joystick0axis8 disabled
1169 set-axis joystick0axis9 disabled
1171 set-axis joystick0axis10 disabled
1173 set-axis joystick0axis11 disabled
1175 set-axis joystick0axis12 disabled
1177 set-axis joystick0axis13 disabled
1179 set-axis joystick0axis14 disabled
1181 set-axis joystick0axis15 disabled
1183 set-axis joystick0axis16 disabled
1185 set-axis joystick0axis17 disabled
1187 set-axis joystick0axis18 disabled
1189 set-axis joystick0axis19 disabled
1191 16 Errata:
1193 16.1 Problems from BSNES core:
1195 • The whole pending save stuff.
1197 • It is slow (especially accuracy).
1199 • Firmwares can't be loaded from ZIP archives.
1201 16.2 Other problems:
1203 • Modifiers don't work with pseudo-keys.
1205 • Audio for last dumped frame is not itself dumped.
1207 • Audio in UI is pretty bad in quality if game doesn't run at 
1208   full speed.