Move one #ifdef BSNES_HAS_DEBUGGER to the proper place
[lsnes.git] / manual.txt
blob45370be39e002ba73a2415fda3d886995f69d665
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 --pluginmanager
88 Instead of starting the emulator, display the plugin manager 
89 (useful to disable some plugin that causes emulator to crash on 
90 startup)
92 4.1.6 --lua=<file>
94 Run this Lua file on startup
96 4.2 dump options (lsnes-dumpavi only)
98 4.2.1 --rom=<file>
100 Load <file> as ROM. Required.
102 4.2.2 <filename>
104 Load <filename> as movie or savestate file on startup. Required.
106 4.2.3 --dumper=<dumper>
108 Set the dumper to use (required). Use 'list' for listing of known 
109 dumpers.
111 4.2.4 --firmware-path=<path>
113 Set path to look for firmware.
115 4.2.5 --mode=<mode>
117 Set the mode to use (required for dumpers with multiple modes, 
118 forbidden otherwise). Use 'list' for known modes.
120 4.2.6 --prefix=<prefix>
122 Set dump prefix. Default is “avidump”.
124 4.2.7 --option=<name>=<value>
126 Set option <name> to value <value>.
128 4.2.8 --length=<length>
130 Set number of frames to dump. Mandatory, unless --overdump-length 
131 is specified.
133 4.2.9 --overdump-length=<length>
135 Set number of frames to dump after movie end. Mutually exclusive 
136 with --length.
138 4.2.10 --lua=<script>
140 Run specified lua script (lsnes-dumpavi does not have 
141 initialization files).
143 4.2.11 --load-library=<library>
145 Load the specified shared object / dynamic library / dynamic link 
146 library.
148 4.3 lsnes settings directory
150 The lsnes settings directory is (in order of decreasing 
151 perference):
153 • Windows: %APPDATA%\lsnes (if %APPDATA% exists)
155 • Unix: $XDG_CONFIG_HOME/lsnes (if $XDG_CONFIG_HOME exists)
157 • Unix: $HOME/.config/lsnes (if $HOME exists)
159 • All: . (fallback default).
161 If leading directories do not exist, attempt to create them is 
162 made.
164 5 Internal commands
166 • Commands beginning with '*' invoke the corresponding command 
167   without alias expansion.
169 • If command starts with '+' (after possible '*'), the command is 
170   executed as-is when button is pressed, and when button is 
171   released, it is executed with '+' replaced by '-'.
173 • Commands without '+' execute only on negative edge (release).
175 5.1 run-script <script>
177 Run <script> as if commands were entered on the command line.
179 5.2 Memory manipulation
181 <address> may be decimal or hexadecimal (prefixed with '0x'). 
182 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
183 signed (prefixed with '-') decimal.
185 The available element <sizes> are:
187 • byte: 1 byte
189 • word: 2 bytes
191 • hword: 3 bytes
193 • dword: 4 bytes
195 • qword: 8 bytes
197 • float: 4 bytes (floating-point)
199 • double: 8 bytes (floating-point)
201 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
202 When dealing with DSP memory, multi-byte reads/writes are 
203 native-endian (do not use operand sizes exceeding DSP bitness, 
204 except dword is OK for 24-bit memory).
206 5.2.1 read-<size> <address>
208 Read the value of byte in <address>.
210 5.2.2 read-s<size> <address>
212 Read the value of signed byte in <address>.
214 5.2.3 write-<size> <address> <value>
216 Write <value> to byte in address <address>.
218 5.3 Main commands
220 These commands are not available in lsnesrc, but are available 
221 after ROM has been loaded.
223 5.3.1 quit-emulator
225 Quits the emulator.
227 5.3.2 pause-emulator
229 Toggle paused/unpaused
231 5.3.3 +advance-frame 
233 Advance frame. If the button is still held after configurable 
234 timeout expires, game unpauses for the duration frame advance is 
235 held.
237 5.3.4 +advance-poll 
239 Advance subframe. If the button is still held after configurable 
240 timeout expires, game unpauses for the duration frame advance is 
241 held.
243 5.3.5 advance-skiplag 
245 Skip to first poll in frame after current.
247 5.3.6 reset 
249 Reset the SNES after this frame.
251 5.3.7 load <filename> 
253 Load savestate <filename> in current mode.
255 5.3.8 load-state <filename> 
257 Load savestate <filename> in readwrite mode.
259 5.3.9 load-readonly <filename> 
261 Load savestate <filename> in readonly mode.
263 5.3.10 load-preserve <filename> 
265 Load savestate <filename> in readonly mode, preserving current 
266 events.
268 5.3.11 load-movie <filename> 
270 Load savestate <filename>, ignoring save part in readonly mode.
272 5.3.12 save-state <filename> 
274 Save system state to <filename> as soon as possible.
276 5.3.13 save-movie <filename> 
278 Save movie to <filename>.
280 5.3.14 set-rwmode 
282 Set read-write mode.
284 5.3.15 set-romode 
286 Set read-only mode
288 5.3.16 toggle-rwmode 
290 Toggle between read-only and read-write modes.
292 5.3.17 test-1, test-2, test-3
294 Internal test commands. Don't use.
296 5.3.18 take-screenshot <filename> 
298 Save screenshot to <filename>.
300 5.3.19 +controller <class>-<#>-<button>
302 Press button <button> on controller <num> of class <class>.
304 • Class 'gamepad': A, B, X, Y, L, R, select, start, up, down, 
305   left, right, ext0, ext1, ext2, ext3
307 • Class 'mouse': L, R
309 • Class 'superscope': trigger, cursor, turbo, pause
311 • Class 'justifier': trigger, start
313 • Class 'gb': A, B, select, start, up, down, left, right
315 5.3.20 hold-controller <class>-<#>-<button>
317 Hold/unhold button <button> on controller <num> of class <class>.
319 5.3.21 type-controller <class>-<#>-<button>
321 Hold/unhold button <button> on controller <num> of class <class> 
322 for the next frame. See +controller for button names.
324 Cauntion: Does not work properly if outside frame advance.
326 5.3.22 +autofire-controller <class>-<#>-<button> [[<duty>] 
327   <cyclelen>]
329 Start autofire. If duty is not specified, defaults to 1. If 
330 <cyclelen> is not specified, defaults to 2.
332 5.3.23 -autofire-controller <class>-<#>-<button> [[<duty>] 
333   <cyclelen>]
335 End autofire.
337 5.3.24 autofire-controller <class>-<#>-<button> [[<duty>] 
338   <cyclelen>]
340 Toggle autofire. If autofire is turned on, specified cycle is 
341 used.
343 5.3.25 designate-position <class>-<#>-analog<n>
345 Designate position for analog pair. <n> is only there if there 
346 are multiple axis pairs.
348 5.3.26 repaint
350 Force a repaint.
352 5.3.27 toggle-pause-on-end
354 Toggle pause on end flag.
356 5.3.28 set-pause-on-end
358 Set pause on end flag.
360 5.3.29 clear-pause-on-end
362 Clear pause on end flag.
364 5.3.30 action <action> [<parameters>]
366 Run specified core action.
368 5.4 Save jukebox 
370 5.4.1 cycle-jukebox-backward
372 Cycle save jukebox backwards.
374 5.4.2 cycle-jukebox-forward
376 Cycle save jukebox forwards
378 5.4.3 set-jukebox-slot <slot>
380 Set current jukebox slot
382 5.4.4 load-jukebox
384 Do load from jukebox (current mode).
386 5.4.5 save-jukebox
388 Do state save to jukebox.
390 5.5 Slot branches
392 5.5.1 list-branches
394 List all branches
396 5.5.2 create-branch <pid> <name>
398 Create a new branch, with <pid> as parent and <name> as name.
400 5.5.3 rename-branch <id> <name>
402 Rename branch <id> to <name>.
404 5.5.4 reparent-branch <id> <pid>
406 Set parent of branch <id> to <pid>.
408 5.5.5 set-branch <id>
410 Set current branch to <id>.
412 5.5.6 delete-branch <id>
414 Delete branch <id>.
418 5.6 Lua 
420 5.6.1 evaluate-lua <luacode>
422 Run Lua code <luacode> using built-in Lua interpretter.
424 5.6.2 L <luacode>
426 Synonym for evaluate-lua.
428 5.6.3 run-lua <script>
430 Run specified lua file using built-in Lua interpretter.
432 5.6.4 reset-lua
434 Clear the Lua VM state and restore to factory defaults.
436 5.7 Sound 
438 5.7.1 enable-sound <on/off> 
440 Enable/Disable sound.
442 5.8 Misc.
444 5.8.1 reload-rom [<file>]
446 Reloads the main ROM image from <file>.
448 5.8.2 +tangent
450 Tangent for recording voice for commentary track. While pressed, 
451 record a stream.
453 5.8.3 advance-subframe-timeout
455 Subframe advance timeout in milliseconds. Default is 100.
457 6 Settings
459 6.1 Core settings
461 6.2 AVI dumper settings
463 6.2.1 avi-large
465 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
466 the console outputs.
468 6.2.2 avi-left-border
470 AVI dumper: Set the default left border thickness (unless lua 
471 overrides) for dumps. Range 0-8191. Default is 0.
473 6.2.3 avi-right-border
475 AVI dumper: Set the default right border thickness (unless lua 
476 overrides) for dumps. Range 0-8191. Default is 0.
478 6.2.4 avi-top-border
480 AVI dumper: Set the default top border thickness (unless lua 
481 overrides) for dumps. Range 0-8191. Default is 0.
483 6.2.5 avi-bottom-border
485 AVI dumper: Set the default bottom border thickness (unless lua 
486 overrides) for dumps. Range 0-8191. Default is 0.
488 6.2.6 avi-maxframes
490 AVI dumper: Maximum number of frames per dump segment (0 => 
491 unlimited). Range 0-999999999. Default is 0.
493 6.2.7 avi-compresison
495 AVI dumper: Compression level (0-18).
497 • Compression levels 10 and above are not compatible with stock 
498   CSCD codec.
500 • Recomended level is 7.
502 6.2.8 avi-soundrate
504 AVI dumper: Set method of determining the sound rate.
506 • 0: Pick nearest of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48, 
507   64, 88.2, 96, 128, 176.4 and 192 kHz.
509 • 1: Round down to nearest integer.
511 • 2: Round up to nearest ingeter.
513 • 3: Multiply by denominator.
515 • 4: High quality 44.1kHz (SRC needed).
517 • 5: High quality 48kHz (SRC needed).
519 6.3 JMD options
521 6.3.1 jmd-compression
523 JMD dumper: Compression level (0-9).
525 7 Movie editor
527 • The editor edits in-memory movie.
529 • Because past can't be edited and readwrite mode doesn't allow 
530   future, editing only works in read only mode.
532 • Keyboard triggers the normal hotkeys and bindings.
534 7.1 Left button actions
536 • Clicking on cell in future (indicated by lack of redish 
537   background) toggles it (if it is a button) or prompts for a 
538   value (if it is an axis)
540 • Dragging vertically toggles sequence of buttons or changes a 
541   sequence of axis values.
543 7.2 Right button actions
545 The right mouse button pops up a context-sensitive menu:
547 • Toggle <something>: Toggle this button
549 • Change <something>: Change this axis value
551 • Insert frame after: Insert a frame after this frame
553 • Append frame: Append a frame to movie
555 • Append frames: Append specified number of frames to movie
557 • Delete frame: Delete this frame
559 • Delete subframe: Delete this subframe
561 • Truncate movie: Delete this subframe and everything after it.
563 • Scroll to frame: Prompt for a frame and scroll the display to 
564   that frame.
566 • Scroll to current frame: Scroll the display to current position
568 • Run to frame: Prompts for frame and runs the emulation to that 
569   frame.
571 • Change number of lines visible: Change the height of the movie 
572   display (1 to 255).
574 • Lock scroll to playback: While playing back or rewinding 
575   movies, the display will follow if enabled.
577 8 Memory watch expression syntax
579 Memory watch expressions has the following syntax elements:
581 ${foo}     The value of memory watch foo.
583 0x1234     Hexadecimal number 1234
585 12345      Decimal number 12345
587 3.141      Decimal number 3.141
589 -a         Unary negation
591 ~a         Bitwise NOT (integers only)
593 a*b        Multiplication
595 a/b        Division/quotent
597 a%b        Remainder (integers only)
599 a+b        Sum or string concatenation
601 a-b        Difference
603 a<<b       Shift left (integers only)
605 a>>b       Shift right (integers only). Arithmetic for signed.
607 a<b        Less than
609 a<=b       Less or equal to
611 a==b       Equal to
613 a!=b       Not equal to
615 a>=b       Greater or equal to
617 a>b        Greater than
619 a&b        Bitwise AND (integers only)
621 a^b        Bitwise XOR (integers only)
623 a|b        Bitwise OR (integers only)
625 a&&b       Logical AND
627 a||b       Logical OR
629 π          Numeric constant pi.
631 i          Imaginary unit
633 if(x,y)    If x is true, y, else false.
635 if(x,y,z)  If x is true, y, else z.
637 select(x...)
639            First value in x... that is not false, or false if 
640 none.
642 unsigned(x)
644            Cast x to unsigned.
646 signed(x)
648            Cast x to signed.
650 float(x)
652            Cast x to float.
654 min(x...)  The smallest value among x... or false if empty.
656 max(x...)  The largest value among x... or false if empty.
658 sum(x...)  Sum/concatenation of x... or false if empty.
660 prod(x...) Product of x... or false if empty.
662 sqrt(x)    Square root of x.
664 log(x)     Natural log of x.
666 log(x,y)   Log of y to base x.
668 exp(x)     e^x.
670 exp(x,y)   x^y
672 sin(x)     Sine of x
674 cos(x)     Cosine of x
676 tan(x)     Tangent of x
678 asin(x)    Arcsine of x
680 acos(x)    Arccosine of x
682 atan(x)    Arctangent of x
684 atan(x,y)  Angle between vector (x,y) and x-axis.
686 sinh(x)    Hyperbolic sine of x
688 cosh(x)    Hyperbolic cosine of x
690 tanh(x)    Hyperbolic tangent of x
692 arsinh(x)  Hyperbolic arsine of x
694 arcosh(x)  Hyperbolic arcosine of x
696 artanh(x)  Hyperbolic artangent of x
698 torad(x)   Convert x degrees to radians.
700 todeg(x)   Convert x radians to degrees.
702 re(x)      Real part of complex number x.
704 im(x)      Imaginary part of complex number x.
706 conj(x)    Complex conjugate of x.
708 abs(x)     Absolute value of x.
710 arg(x)     Argument of x.
712 pyth(x...) sqrt(sum(x^2)). I.e. pythagorean distance.
714 e          Base of natural logarithm
716 pi         Pi
718 true       Constant true
720 false      Constant false
724 9 Modifier and key names:
726 9.1 wxWidgets platform
728 9.1.1 Modifier names:
730 Following modifier names are known:
732 • alt
734 • ctrl
736 • shift 
738 • meta
740 • cmd (Mac OS X only)
742 9.1.2 Key names:
744 Following key names are known:
746 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
747   dollar, percent, ampersand, quote, leftparen, rightparen, 
748   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
749   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
750   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
751   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
752   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
753   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
754   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
755   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
756   home, lefT, up, right, down, select, print, execute, snapshot, 
757   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
758   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
759   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
760   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
761   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
762   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
763   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
764   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
765   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
766   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
767   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
768   windows_right, windows_menu, command, special1, special2, 
769   special3, special4, special5, special6, special7, special8, 
770   special9, special10, special11, special12, special13, 
771   special14, special15, special16, special17, special18, 
772   special19, special20
774 10 Movie file format
776 Movie file is .zip archive in itself, normal ZIP archive tools 
777 work on it (note: If you recompress it, do not use compression 
778 methods other than store and deflate and especially do not use 
779 encryption of any kind).
781 10.1 Detecting clean start/SRAM/Savestate
783 • If file has member “savestate” it is savestate, otherwise:
785 • If file has members with names starting “moviesram.” it is 
786   movie starting from SRAM, otherwise:
788 • It is movie starting from clear state.
790 10.2 Member: gametype
792 Type of game ROM and region (as one line). Valid values are:
795 +--------------+---------------------+--------+
796 |    Value     |       System        | Region |
797 +--------------+---------------------+--------+
798 +--------------+---------------------+--------+
799 |  snes_pal    |     Super NES       |  PAL   |
800 +--------------+---------------------+--------+
801 |   sgb_pal    |   Super Game Boy    |  PAL   |
802 +--------------+---------------------+--------+
803 |  snes_ntsc   |     Super NES       |  NTSC  |
804 +--------------+---------------------+--------+
805 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
806 +--------------+---------------------+--------+
807 |     bsx      | BS-X (non-slotted)  |  NTSC  |
808 +--------------+---------------------+--------+
809 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
810 +--------------+---------------------+--------+
811 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
812 +--------------+---------------------+--------+
815 Frame rates are:
818 +---------+-----------------+
819 | Region  | Framerate (fps) |
820 +---------+-----------------+
821 +---------+-----------------+
822 |  PAL    |   322445/6448   |
823 +---------+-----------------+
824 |  NTSC   | 10738636/178683 |
825 +---------+-----------------+
828 10.3 Member: port1
830 Contains type of port #1 (as one line). Valid values are 'none', 
831 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
832 'gamepad'.
834 10.4 Member: port2
836 Contains type of port #2 (as one line). Valid values are 'none', 
837 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
838 'justifiers'. If not present, defaults to 'none'.
840 10.5 Member: gamename
842 Contains name of the game (as one line).
844 10.6 Member: authors
846 Contains authors, one per line. Part before '|' is the full name, 
847 part after is the nickname.
849 10.7 Member: systemid
851 Always “lsnes-rr1” (one line). Used to reject other saves.
853 10.8 Member: controlsversion
855 Always “0” (one line). Used to identify what controls are there.
857 10.9 Member: “coreversion”
859 Contains bsnes core version number (as one line).
861 10.10 Member: projectid
863 Contains project ID (as one line). Used to identify if two movies 
864 are part of the same project.
866 10.11 Member: {rom,slota,slotb}{,xml}.sha256
868 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
869 Absent if corresponding file is absent.
871 10.12 Member: moviesram.<name>
873 Raw binary startup SRAM of kind <name>. Only present in 
874 savestates and movies starting from SRAM.
876 10.13 Member: saveframe
878 Contains frame number (as one line) of frame movie was saved on. 
879 Only present in savestates.
881 10.14 Member: lagcounter
883 Current value of lag counter (as one line). Only present in 
884 savestates.
886 10.15 Member: pollcounters
888 Contains poll counters (currently 100 of them), one per line. 
889 Each line is raw poll count if DRDY is set for it. Otherwise it 
890 is negative poll count minus one. Only present in savestates.
892 10.16 Member: hostmemory
894 Raw binary dump of host memory. Only present in savestates.
896 10.17 Member: savestate
898 The raw binary savestate itself. Savestate detection uses this 
899 file, only present in savestates.
901 10.18 Member: screenshot
903 Screenshot of current frame. Only present in savestates. First 2 
904 bytes are big-endian width of image, rest are 24-bit RGB image 
905 data. Height of image is inferred from the width and size of 
906 data.
908 10.19 Member: sram.<name>
910 Raw binary SRAM of kind <name> at time of savestate. Only present 
911 in savestates.
913 10.20 Member: input
915 The actual input track, one line per subframe (blank lines are 
916 skipped).
918 • If the first byte of each line is '.', ' ', <tab> or '|', then 
919   the line is part of same frame as previous, otherwise it starts 
920   a new frame.
922 • First subframe must start a new frame.
924 Length of movie in frames is number of lines in input file that 
925 start a new frame.
927 10.21 Member: subtitles
929 Subtitle track. Optional.
931 • Each line is in form <firstframe> <numframes> <text>.
933 • Linefeed is encoded as \n, backslash is encoded as \\.
935 10.22 Member: rerecords
937 Contains textual base-10 rerecord count (as one line; emulator 
938 just writes this, it doesn't read it) + 1.
940 10.23 Member: rrdata
942 This member stores set of load IDs. There is one load ID per 
943 rerecord (plus one corresponding to start of project).
945 • This member constists of concatenation of records
947 • Each record is 2-36 bytes long and can represent 1-16,843,009 
948   consequtive IDs.
950 • IDs are interpretted as 256-bit big-endian integers with 
951   warparound.
953 • Initial predicted ID is all zeroes.
955 Format of each record is:
957 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
958   bits 5-6 are count length (countlen). Bit 7 is unused.
960 • 32-prefixlen bytes of ID.
962 • countlen bytes of big-endian count (count).
964 Records are processed as follows:
966 • To form the first ID encoded by record, take the first 
967   prefixlen bytes predicted ID and append the read ID value to 
968   it. The result is the first ID encoded.
970 • If countlen is 0, record encodes 1 ID.
972 • If countlen is 1, record encodes 2+count IDs.
974 • If countlen is 2, record encodes 258+count IDs.
976 • If countlen is 3, record encodes 65794+count IDs.
978 • The new predicted ID is the next ID after last one encoded by 
979   the record.
981 The number of rerecords + 1 is equal to the sum of number of IDs 
982 encoded by all records.
984 10.24 Member: starttime.second
986 Movie starting time, second part. Epoch is Unix epoch. Default is 
987 1,000,000,000.
989 10.25 Member: starttime.subsecond
991 Movie starting time, subsecond part. Unit is CPU clocks. Default 
992 is 0.
994 10.26 Member: savetime.second
996 Movie saving time, second part. Default is starttime.second. Only 
997 present in savestates.
999 10.27 Member: savetime.subsecond
1001 Movie saving time, subsecond part. Default is 
1002 starttime.subsecond. Only present in savestates.
1004 11 lsvs file format (commentary tracks)
1006 11.1 Clusters
1008 • Each cluster is 8kB (8192 bytes) in size.
1010 • Cluster n starts at offset 8192*n in file.
1012 • The following clusters are system special:
1014   – Cluster 0 and all clusters with number multiple of 2048 
1015     (cluster tables)
1017   – Cluster 1 (superblock)
1019 11.2 Cluster tables
1021 • The cluster table describing cluster n is stored in cluster n & 
1022   ~0x7FF (zero last 11 bits of n).
1024 • This cluster table consists of 2048 4-byte big-endian integers.
1026 • Each entry describes a cluster in 16MB supercluster, in order.
1028 • The valid values for entries are:
1030   – 0x00000000: Free cluster
1032   – 0x00000001: Last cluster in chain.
1034   – 0xFFFFFFFF: System cluster (cluster tables and superblock)
1036   – (anything else): Number of next cluster in chain. Must not be 
1037     multiple of 2048.
1039 • Due to limitations of the format, there can be at most 2097052 
1040   superclusters, giving maximum file size of 16TB.
1042 11.3 Stream table
1044 • The stream table chain always starts in cluster 2.
1046 • Otherwise, it follows normal chaining.
1048 • The stream table consists of 16-byte entries:
1050   – The first 8 bytes of entry give big-endian beginning position 
1051     of stream in units of 1/48000 s.
1053   – The next 4 bytes of entry give big-endian beginning cluster 
1054     for control data. 0 here marks the entry as not present.
1056   – The last 4 bytes of entry give big-endian beginning cluster 
1057     for codec data.
1059 • Stream table clusters are normal clusters, following normal 
1060   chaining.
1062 • The stream begnning position is not guarenteed unique. There 
1063   can be multiple streams with the same starting position in the 
1064   file.
1066 11.4 Stream control data
1068 • The stream control data consists of entries 4 bytes each:
1070   – The first 2 bytes of entry gives big-endian length of packet
1072   – The next byte of entry gives audio length of packet in units 
1073     of 1/400 s.
1075   – The last byte is control byte.
1077     ∗ 0 means this entry is not present and the control data 
1078       ends.
1080     ∗ 1 is valid control entry.
1082 • The stream control data can also end by running into end of the 
1083   readable chain.
1085   – This happens if there happens to be exact multiple of 2048 
1086     packets in stream and number of packets is nonzero.
1088 • These clusters follow normal chaining.
1090 11.5 Stream codec data
1092 • Stream codec data consists of raw Opus data packets packed back 
1093   to back with nothing in between.
1095 • Warning: Due to internal limitations, this data must reside in 
1096   the first 65536 superclusters (that is, the first 1TB of the 
1097   file).
1099 11.6 Superblock
1101 • The superblock is stored in cluster 1. 
1103 • The first 11 bytes are “sefs-magic”<NUL>.
1105 • The rest are unused.
1107 • This cluster 1 is marked as system special.
1109 12 Known ROM extensions
1111 • SNES cartridge ROMs: sfc, smc, swc, fig, ufo, sf2, gd3, gd7, 
1112   dx2, mgd, mgh.
1114 • DMG cartridge ROMs: dmg, gb.
1116 • GBC cartridge ROMs: cgb, gbc.
1118 13 Gamepack files
1120 • The first line must be: “[GAMEPACK FILE]”.
1122 • There is one needed line: “type <systype>”. This sets system 
1123   type to <systype>. The following system types are valid:
1125   – snes (SNES)
1127   – bsx (BS-X non-slotted)
1129   – bsxslotted (BS-X slotted)
1131   – sufamiturbo (Sufami Turbo)
1133   – sgb (Super Game Boy)
1135   – dmg (Game Boy)
1137   – gbc (Game Boy Color)
1139   – gbc_gba (Game Boy Color with GBA initial register values)
1141 • Optionally a region can be specified: “region <region>”. The 
1142   following values are valid:
1144   – autodetect (Autodetect region: snes and sgb only)
1146   – ntsc (NTSC: snes, bsx, bsxslotted, sufamiturbo, sgb)
1148   – pal (PAL: snes, sgb)
1150   – world (World: dmg, gbc, gbc_gba)
1152 • ROM images are loaded as: “rom <type> <file>”. The following 
1153   types are valid:
1155   – rom (Cartridge ROM in snes, dmg, gbc, gbc_gba. BIOS in bsx, 
1156     bsxslotted, sufamiturbo)
1158   – bsx (Cartridge ROM in bsx, bsxslotted)
1160   – slot-a (Cartridge ROM in sufamiturbo)
1162   – slot-b (Cartridge ROM in sufamiturbo)
1164 • ROM markup can be loaded as: “xml <type> <file>”. The types 
1165   valid are the same as for ROMs.
1167 • Patches can be loaded as “patch[<offset>] <type> <file>”. The 
1168   types are the same as for ROMs.
1170   – Offset is given in form [+-]<number>. Usually offset is 
1171     either +0 or -512.
1173   – Default offset is +0.
1175 13.1 Example:
1177 [GAMEPACK FILE]
1179 type snes
1181 rom rom speedygonzales.sfc
1183 patch-512 rom sonicthehedgehog.ips
1185 13.2 Example 2:
1187 [GAMEPACK FILE]
1189 type sgb
1191 rom rom supergameboy.sfc
1193 rom dmg megamanV.dmg
1195 14 Quick'n'dirty encode guide
1197 1. Start the emulator and load the ROM and movie file.
1199 2. Set large AVI option 'set-setting avi-large on'
1201 3. Enable dumping 'dump-avi tmpdump' 
1203 4. Unpause and let it run until you want to end dumping.
1205 5. Close the emulator (closing the window is the easiest way). Or 
1206   use 'end-avi'.
1208 6. For each tmpdump*.avi file created, on command prompt, do 
1209   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
1211 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
1213 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
1214   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
1215   tmpdump_<numbers>.mkv, with + in between).
1217 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
1218   final.mkv contains quick'n'dirty encode.
1220 15 Axis configurations for some gamepad types:
1222 15.1 XBox360 controller:
1224 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
1225 set to pressure-+.
1227 set-axis joystick0axis2 pressure-+
1229 set-axis joystick0axis5 pressure-+
1231 • This is needed for SDL only. EVDEV sets those types correctly.
1233 15.2 PS3 “sixaxis” controller:
1235 Axes 8-19 should be disabled.
1237 set-axis joystick0axis8 disabled
1239 set-axis joystick0axis9 disabled
1241 set-axis joystick0axis10 disabled
1243 set-axis joystick0axis11 disabled
1245 set-axis joystick0axis12 disabled
1247 set-axis joystick0axis13 disabled
1249 set-axis joystick0axis14 disabled
1251 set-axis joystick0axis15 disabled
1253 set-axis joystick0axis16 disabled
1255 set-axis joystick0axis17 disabled
1257 set-axis joystick0axis18 disabled
1259 set-axis joystick0axis19 disabled
1261 16 Errata:
1263 16.1 Problems from BSNES core:
1265 • The whole pending save stuff.
1267 • It is slow (especially accuracy).
1269 • Firmwares can't be loaded from ZIP archives.
1271 16.2 Other problems:
1273 • Modifiers don't work with pseudo-keys.
1275 • Audio for last dumped frame is not itself dumped.
1277 • Audio in UI is pretty bad in quality if game doesn't run at 
1278   full speed.