Rudimentary library unloading support
[lsnes.git] / manual.txt
bloba2c847fbfb7ea60b31361f3ba1266c42f3eb29ff
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> can be one of:
183   – Decimal number
185   – Hexadecimal number (prefixed with 0x)
187   – <memarea>+<hexoffset> (no 0x prefix for offset).
189 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
190 signed (prefixed with '-') decimal.
192 The available element <sizes> are:
194 • byte: 1 byte
196 • word: 2 bytes
198 • hword: 3 bytes
200 • dword: 4 bytes
202 • qword: 8 bytes
204 • float: 4 bytes (floating-point)
206 • double: 8 bytes (floating-point)
208 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
209 When dealing with DSP memory, multi-byte reads/writes are 
210 native-endian (do not use operand sizes exceeding DSP bitness, 
211 except dword is OK for 24-bit memory).
213 5.2.1 read-<size> <address>
215 Read the value of byte in <address>.
217 5.2.2 read-s<size> <address>
219 Read the value of signed byte in <address>.
221 5.2.3 write-<size> <address> <value>
223 Write <value> to byte in address <address>.
225 5.3 Main commands
227 These commands are not available in lsnesrc, but are available 
228 after ROM has been loaded.
230 5.3.1 quit-emulator
232 Quits the emulator.
234 5.3.2 pause-emulator
236 Toggle paused/unpaused
238 5.3.3 +advance-frame 
240 Advance frame. If the button is still held after configurable 
241 timeout expires, game unpauses for the duration frame advance is 
242 held.
244 5.3.4 +advance-poll 
246 Advance subframe. If the button is still held after configurable 
247 timeout expires, game unpauses for the duration frame advance is 
248 held.
250 5.3.5 advance-skiplag 
252 Skip to first poll in frame after current.
254 5.3.6 reset 
256 Reset the SNES after this frame.
258 5.3.7 load <filename> 
260 Load savestate <filename> in current mode.
262 5.3.8 load-state <filename> 
264 Load savestate <filename> in readwrite mode.
266 5.3.9 load-readonly <filename> 
268 Load savestate <filename> in readonly mode.
270 5.3.10 load-preserve <filename> 
272 Load savestate <filename> in readonly mode, preserving current 
273 events.
275 5.3.11 load-movie <filename> 
277 Load savestate <filename>, ignoring save part in readonly mode.
279 5.3.12 save-state <filename> 
281 Save system state to <filename> as soon as possible.
283 5.3.13 save-movie <filename> 
285 Save movie to <filename>.
287 5.3.14 set-rwmode 
289 Set recording mode.
291 5.3.15 set-romode 
293 Set playback mode
295 5.3.16 toggle-rwmode 
297 Toggle between playback and recording modes.
299 5.3.17 test-1, test-2, test-3
301 Internal test commands. Don't use.
303 5.3.18 take-screenshot <filename> 
305 Save screenshot to <filename>.
307 5.3.19 +controller <class>-<#>-<button>
309 Press button <button> on controller <num> of class <class>.
311 • Class 'gamepad': A, B, X, Y, L, R, select, start, up, down, 
312   left, right, ext0, ext1, ext2, ext3
314 • Class 'mouse': L, R
316 • Class 'superscope': trigger, cursor, turbo, pause
318 • Class 'justifier': trigger, start
320 • Class 'gb': A, B, select, start, up, down, left, right
322 5.3.20 hold-controller <class>-<#>-<button>
324 Hold/unhold button <button> on controller <num> of class <class>.
326 5.3.21 type-controller <class>-<#>-<button>
328 Hold/unhold button <button> on controller <num> of class <class> 
329 for the next frame. See +controller for button names.
331 Cauntion: Does not work properly if outside frame advance.
333 5.3.22 +autofire-controller <class>-<#>-<button> [[<duty>] 
334   <cyclelen>]
336 Start autofire. If duty is not specified, defaults to 1. If 
337 <cyclelen> is not specified, defaults to 2.
339 5.3.23 -autofire-controller <class>-<#>-<button> [[<duty>] 
340   <cyclelen>]
342 End autofire.
344 5.3.24 autofire-controller <class>-<#>-<button> [[<duty>] 
345   <cyclelen>]
347 Toggle autofire. If autofire is turned on, specified cycle is 
348 used.
350 5.3.25 designate-position <class>-<#>-analog<n>
352 Designate position for analog pair. <n> is only there if there 
353 are multiple axis pairs.
355 5.3.26 repaint
357 Force a repaint.
359 5.3.27 toggle-pause-on-end
361 Toggle pause on end flag.
363 5.3.28 set-pause-on-end
365 Set pause on end flag.
367 5.3.29 clear-pause-on-end
369 Clear pause on end flag.
371 5.3.30 action <action> [<parameters>]
373 Run specified core action.
375 5.4 Save jukebox 
377 5.4.1 cycle-jukebox-backward
379 Cycle save jukebox backwards.
381 5.4.2 cycle-jukebox-forward
383 Cycle save jukebox forwards
385 5.4.3 set-jukebox-slot <slot>
387 Set current jukebox slot
389 5.4.4 load-jukebox
391 Do load from jukebox (current mode).
393 5.4.5 save-jukebox
395 Do state save to jukebox.
397 5.5 Slot branches
399 5.5.1 list-branches
401 List all branches
403 5.5.2 create-branch <pid> <name>
405 Create a new branch, with <pid> as parent and <name> as name.
407 5.5.3 rename-branch <id> <name>
409 Rename branch <id> to <name>.
411 5.5.4 reparent-branch <id> <pid>
413 Set parent of branch <id> to <pid>.
415 5.5.5 set-branch <id>
417 Set current branch to <id>.
419 5.5.6 delete-branch <id>
421 Delete branch <id>.
425 5.6 Lua 
427 5.6.1 evaluate-lua <luacode>
429 Run Lua code <luacode> using built-in Lua interpretter.
431 5.6.2 L <luacode>
433 Synonym for evaluate-lua.
435 5.6.3 run-lua <script>
437 Run specified lua file using built-in Lua interpretter.
439 5.6.4 reset-lua
441 Clear the Lua VM state and restore to factory defaults.
443 5.7 Sound 
445 5.7.1 enable-sound <on/off> 
447 Enable/Disable sound.
449 5.8 Misc.
451 5.8.1 reload-rom [<file>]
453 Reloads the main ROM image from <file>.
455 5.8.2 +tangent
457 Tangent for recording voice for commentary track. While pressed, 
458 record a stream.
460 5.8.3 advance-subframe-timeout
462 Subframe advance timeout in milliseconds. Default is 100.
464 6 Settings
466 6.1 Core settings
468 6.2 AVI dumper settings
470 6.2.1 avi-large
472 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
473 the console outputs.
475 6.2.2 avi-left-border
477 AVI dumper: Set the default left border thickness (unless lua 
478 overrides) for dumps. Range 0-8191. Default is 0.
480 6.2.3 avi-right-border
482 AVI dumper: Set the default right border thickness (unless lua 
483 overrides) for dumps. Range 0-8191. Default is 0.
485 6.2.4 avi-top-border
487 AVI dumper: Set the default top border thickness (unless lua 
488 overrides) for dumps. Range 0-8191. Default is 0.
490 6.2.5 avi-bottom-border
492 AVI dumper: Set the default bottom border thickness (unless lua 
493 overrides) for dumps. Range 0-8191. Default is 0.
495 6.2.6 avi-maxframes
497 AVI dumper: Maximum number of frames per dump segment (0 => 
498 unlimited). Range 0-999999999. Default is 0.
500 6.2.7 avi-compresison
502 AVI dumper: Compression level (0-18).
504 • Compression levels 10 and above are not compatible with stock 
505   CSCD codec.
507 • Recomended level is 7.
509 6.2.8 avi-soundrate
511 AVI dumper: Set method of determining the sound rate.
513 • 0: Pick nearest of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48, 
514   64, 88.2, 96, 128, 176.4 and 192 kHz.
516 • 1: Round down to nearest integer.
518 • 2: Round up to nearest ingeter.
520 • 3: Multiply by denominator.
522 • 4: High quality 44.1kHz (SRC needed).
524 • 5: High quality 48kHz (SRC needed).
526 6.3 JMD options
528 6.3.1 jmd-compression
530 JMD dumper: Compression level (0-9).
532 7 Movie editor
534 • The editor edits in-memory movie.
536 • Because past can't be edited and readwrite mode doesn't allow 
537   future, editing only works in read only mode.
539 • Keyboard triggers the normal hotkeys and bindings.
541 7.1 Left button actions
543 • Clicking on cell in future (indicated by lack of redish 
544   background) toggles it (if it is a button) or prompts for a 
545   value (if it is an axis)
547 • Dragging vertically toggles sequence of buttons or changes a 
548   sequence of axis values.
550 7.2 Right button actions
552 The right mouse button pops up a context-sensitive menu:
554 • Toggle <something>: Toggle this button
556 • Change <something>: Change this axis value
558 • Insert frame after: Insert a frame after this frame
560 • Append frame: Append a frame to movie
562 • Append frames: Append specified number of frames to movie
564 • Delete frame: Delete this frame
566 • Delete subframe: Delete this subframe
568 • Truncate movie: Delete this subframe and everything after it.
570 • Scroll to frame: Prompt for a frame and scroll the display to 
571   that frame.
573 • Scroll to current frame: Scroll the display to current position
575 • Run to frame: Prompts for frame and runs the emulation to that 
576   frame.
578 • Change number of lines visible: Change the height of the movie 
579   display (1 to 255).
581 • Lock scroll to playback: While playing back or rewinding 
582   movies, the display will follow if enabled.
584 8 Memory watch expression syntax
586 Memory watch expressions has the following syntax elements:
588 ${foo}     The value of memory watch foo.
590 0x1234     Hexadecimal number 1234
592 12345      Decimal number 12345
594 3.141      Decimal number 3.141
596 -a         Unary negation
598 ~a         Bitwise NOT (integers only)
600 a*b        Multiplication
602 a/b        Division/quotent
604 a%b        Remainder (integers only)
606 a+b        Sum or string concatenation
608 a-b        Difference
610 a<<b       Shift left (integers only)
612 a>>b       Shift right (integers only). Arithmetic for signed.
614 a<b        Less than
616 a<=b       Less or equal to
618 a==b       Equal to
620 a!=b       Not equal to
622 a>=b       Greater or equal to
624 a>b        Greater than
626 a&b        Bitwise AND (integers only)
628 a^b        Bitwise XOR (integers only)
630 a|b        Bitwise OR (integers only)
632 a&&b       Logical AND
634 a||b       Logical OR
636 π          Numeric constant pi.
638 i          Imaginary unit
640 if(x,y)    If x is true, y, else false.
642 if(x,y,z)  If x is true, y, else z.
644 select(x...)
646            First value in x... that is not false, or false if 
647 none.
649 unsigned(x)
651            Cast x to unsigned.
653 signed(x)
655            Cast x to signed.
657 float(x)
659            Cast x to float.
661 min(x...)  The smallest value among x... or false if empty.
663 max(x...)  The largest value among x... or false if empty.
665 sum(x...)  Sum/concatenation of x... or false if empty.
667 prod(x...) Product of x... or false if empty.
669 sqrt(x)    Square root of x.
671 log(x)     Natural log of x.
673 log(x,y)   Log of y to base x.
675 exp(x)     e^x.
677 exp(x,y)   x^y
679 sin(x)     Sine of x
681 cos(x)     Cosine of x
683 tan(x)     Tangent of x
685 asin(x)    Arcsine of x
687 acos(x)    Arccosine of x
689 atan(x)    Arctangent of x
691 atan(x,y)  Angle between vector (x,y) and x-axis.
693 sinh(x)    Hyperbolic sine of x
695 cosh(x)    Hyperbolic cosine of x
697 tanh(x)    Hyperbolic tangent of x
699 arsinh(x)  Hyperbolic arsine of x
701 arcosh(x)  Hyperbolic arcosine of x
703 artanh(x)  Hyperbolic artangent of x
705 torad(x)   Convert x degrees to radians.
707 todeg(x)   Convert x radians to degrees.
709 re(x)      Real part of complex number x.
711 im(x)      Imaginary part of complex number x.
713 conj(x)    Complex conjugate of x.
715 abs(x)     Absolute value of x.
717 arg(x)     Argument of x.
719 pyth(x...) sqrt(sum(x^2)). I.e. pythagorean distance.
721 e          Base of natural logarithm
723 pi         Pi
725 true       Constant true
727 false      Constant false
731 9 Modifier and key names:
733 9.1 wxWidgets platform
735 9.1.1 Modifier names:
737 Following modifier names are known:
739 • alt
741 • ctrl
743 • shift 
745 • meta
747 • cmd (Mac OS X only)
749 9.1.2 Key names:
751 Following key names are known:
753 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
754   dollar, percent, ampersand, quote, leftparen, rightparen, 
755   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
756   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
757   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
758   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
759   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
760   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
761   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
762   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
763   home, lefT, up, right, down, select, print, execute, snapshot, 
764   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
765   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
766   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
767   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
768   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
769   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
770   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
771   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
772   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
773   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
774   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
775   windows_right, windows_menu, command, special1, special2, 
776   special3, special4, special5, special6, special7, special8, 
777   special9, special10, special11, special12, special13, 
778   special14, special15, special16, special17, special18, 
779   special19, special20
781 10 Movie file format
783 Movie file is .zip archive in itself, normal ZIP archive tools 
784 work on it (note: If you recompress it, do not use compression 
785 methods other than store and deflate and especially do not use 
786 encryption of any kind).
788 10.1 Detecting clean start/SRAM/Savestate
790 • If file has member “savestate” it is savestate, otherwise:
792 • If file has members with names starting “moviesram.” it is 
793   movie starting from SRAM, otherwise:
795 • It is movie starting from clear state.
797 10.2 Member: gametype
799 Type of game ROM and region (as one line). Valid values are:
802 +--------------+---------------------+--------+
803 |    Value     |       System        | Region |
804 +--------------+---------------------+--------+
805 +--------------+---------------------+--------+
806 |  snes_pal    |     Super NES       |  PAL   |
807 +--------------+---------------------+--------+
808 |   sgb_pal    |   Super Game Boy    |  PAL   |
809 +--------------+---------------------+--------+
810 |  snes_ntsc   |     Super NES       |  NTSC  |
811 +--------------+---------------------+--------+
812 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
813 +--------------+---------------------+--------+
814 |     bsx      | BS-X (non-slotted)  |  NTSC  |
815 +--------------+---------------------+--------+
816 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
817 +--------------+---------------------+--------+
818 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
819 +--------------+---------------------+--------+
822 Frame rates are:
825 +---------+-----------------+
826 | Region  | Framerate (fps) |
827 +---------+-----------------+
828 +---------+-----------------+
829 |  PAL    |   322445/6448   |
830 +---------+-----------------+
831 |  NTSC   | 10738636/178683 |
832 +---------+-----------------+
835 10.3 Member: port1
837 Contains type of port #1 (as one line). Valid values are 'none', 
838 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
839 'gamepad'.
841 10.4 Member: port2
843 Contains type of port #2 (as one line). Valid values are 'none', 
844 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
845 'justifiers'. If not present, defaults to 'none'.
847 10.5 Member: gamename
849 Contains name of the game (as one line).
851 10.6 Member: authors
853 Contains authors, one per line. Part before '|' is the full name, 
854 part after is the nickname.
856 10.7 Member: systemid
858 Always “lsnes-rr1” (one line). Used to reject other saves.
860 10.8 Member: controlsversion
862 Always “0” (one line). Used to identify what controls are there.
864 10.9 Member: “coreversion”
866 Contains bsnes core version number (as one line).
868 10.10 Member: projectid
870 Contains project ID (as one line). Used to identify if two movies 
871 are part of the same project.
873 10.11 Member: {rom,slota,slotb}{,xml}.sha256
875 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
876 Absent if corresponding file is absent.
878 10.12 Member: moviesram.<name>
880 Raw binary startup SRAM of kind <name>. Only present in 
881 savestates and movies starting from SRAM.
883 10.13 Member: saveframe
885 Contains frame number (as one line) of frame movie was saved on. 
886 Only present in savestates.
888 10.14 Member: lagcounter
890 Current value of lag counter (as one line). Only present in 
891 savestates.
893 10.15 Member: pollcounters
895 Contains poll counters (currently 100 of them), one per line. 
896 Each line is raw poll count if DRDY is set for it. Otherwise it 
897 is negative poll count minus one. Only present in savestates.
899 10.16 Member: hostmemory
901 Raw binary dump of host memory. Only present in savestates.
903 10.17 Member: savestate
905 The raw binary savestate itself. Savestate detection uses this 
906 file, only present in savestates.
908 10.18 Member: screenshot
910 Screenshot of current frame. Only present in savestates. First 2 
911 bytes are big-endian width of image, rest are 24-bit RGB image 
912 data. Height of image is inferred from the width and size of 
913 data.
915 10.19 Member: sram.<name>
917 Raw binary SRAM of kind <name> at time of savestate. Only present 
918 in savestates.
920 10.20 Member: input
922 The actual input track, one line per subframe (blank lines are 
923 skipped).
925 • If the first byte of each line is '.', ' ', <tab> or '|', then 
926   the line is part of same frame as previous, otherwise it starts 
927   a new frame.
929 • First subframe must start a new frame.
931 Length of movie in frames is number of lines in input file that 
932 start a new frame.
934 10.21 Member: subtitles
936 Subtitle track. Optional.
938 • Each line is in form <firstframe> <numframes> <text>.
940 • Linefeed is encoded as \n, backslash is encoded as \\.
942 10.22 Member: rerecords
944 Contains textual base-10 rerecord count (as one line; emulator 
945 just writes this, it doesn't read it) + 1.
947 10.23 Member: rrdata
949 This member stores set of load IDs. There is one load ID per 
950 rerecord (plus one corresponding to start of project).
952 • This member constists of concatenation of records
954 • Each record is 2-36 bytes long and can represent 1-16,843,009 
955   consequtive IDs.
957 • IDs are interpretted as 256-bit big-endian integers with 
958   warparound.
960 • Initial predicted ID is all zeroes.
962 Format of each record is:
964 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
965   bits 5-6 are count length (countlen). Bit 7 is unused.
967 • 32-prefixlen bytes of ID.
969 • countlen bytes of big-endian count (count).
971 Records are processed as follows:
973 • To form the first ID encoded by record, take the first 
974   prefixlen bytes predicted ID and append the read ID value to 
975   it. The result is the first ID encoded.
977 • If countlen is 0, record encodes 1 ID.
979 • If countlen is 1, record encodes 2+count IDs.
981 • If countlen is 2, record encodes 258+count IDs.
983 • If countlen is 3, record encodes 65794+count IDs.
985 • The new predicted ID is the next ID after last one encoded by 
986   the record.
988 The number of rerecords + 1 is equal to the sum of number of IDs 
989 encoded by all records.
991 10.24 Member: starttime.second
993 Movie starting time, second part. Epoch is Unix epoch. Default is 
994 1,000,000,000.
996 10.25 Member: starttime.subsecond
998 Movie starting time, subsecond part. Unit is CPU clocks. Default 
999 is 0.
1001 10.26 Member: savetime.second
1003 Movie saving time, second part. Default is starttime.second. Only 
1004 present in savestates.
1006 10.27 Member: savetime.subsecond
1008 Movie saving time, subsecond part. Default is 
1009 starttime.subsecond. Only present in savestates.
1011 11 lsvs file format (commentary tracks)
1013 11.1 Clusters
1015 • Each cluster is 8kB (8192 bytes) in size.
1017 • Cluster n starts at offset 8192*n in file.
1019 • The following clusters are system special:
1021   – Cluster 0 and all clusters with number multiple of 2048 
1022     (cluster tables)
1024   – Cluster 1 (superblock)
1026 11.2 Cluster tables
1028 • The cluster table describing cluster n is stored in cluster n & 
1029   ~0x7FF (zero last 11 bits of n).
1031 • This cluster table consists of 2048 4-byte big-endian integers.
1033 • Each entry describes a cluster in 16MB supercluster, in order.
1035 • The valid values for entries are:
1037   – 0x00000000: Free cluster
1039   – 0x00000001: Last cluster in chain.
1041   – 0xFFFFFFFF: System cluster (cluster tables and superblock)
1043   – (anything else): Number of next cluster in chain. Must not be 
1044     multiple of 2048.
1046 • Due to limitations of the format, there can be at most 2097052 
1047   superclusters, giving maximum file size of 16TB.
1049 11.3 Stream table
1051 • The stream table chain always starts in cluster 2.
1053 • Otherwise, it follows normal chaining.
1055 • The stream table consists of 16-byte entries:
1057   – The first 8 bytes of entry give big-endian beginning position 
1058     of stream in units of 1/48000 s.
1060   – The next 4 bytes of entry give big-endian beginning cluster 
1061     for control data. 0 here marks the entry as not present.
1063   – The last 4 bytes of entry give big-endian beginning cluster 
1064     for codec data.
1066 • Stream table clusters are normal clusters, following normal 
1067   chaining.
1069 • The stream begnning position is not guarenteed unique. There 
1070   can be multiple streams with the same starting position in the 
1071   file.
1073 11.4 Stream control data
1075 • The stream control data consists of entries 4 bytes each:
1077   – The first 2 bytes of entry gives big-endian length of packet
1079   – The next byte of entry gives audio length of packet in units 
1080     of 1/400 s.
1082   – The last byte is control byte.
1084     ∗ 0 means this entry is not present and the control data 
1085       ends.
1087     ∗ 1 is valid control entry.
1089 • The stream control data can also end by running into end of the 
1090   readable chain.
1092   – This happens if there happens to be exact multiple of 2048 
1093     packets in stream and number of packets is nonzero.
1095 • These clusters follow normal chaining.
1097 11.5 Stream codec data
1099 • Stream codec data consists of raw Opus data packets packed back 
1100   to back with nothing in between.
1102 • Warning: Due to internal limitations, this data must reside in 
1103   the first 65536 superclusters (that is, the first 1TB of the 
1104   file).
1106 11.6 Superblock
1108 • The superblock is stored in cluster 1. 
1110 • The first 11 bytes are “sefs-magic”<NUL>.
1112 • The rest are unused.
1114 • This cluster 1 is marked as system special.
1116 12 Known ROM extensions
1118 • SNES cartridge ROMs: sfc, smc, swc, fig, ufo, sf2, gd3, gd7, 
1119   dx2, mgd, mgh.
1121 • DMG cartridge ROMs: dmg, gb.
1123 • GBC cartridge ROMs: cgb, gbc.
1125 13 Gamepack files
1127 • The first line must be: “[GAMEPACK FILE]”.
1129 • There is one needed line: “type <systype>”. This sets system 
1130   type to <systype>. The following system types are valid:
1132   – snes (SNES)
1134   – bsx (BS-X non-slotted)
1136   – bsxslotted (BS-X slotted)
1138   – sufamiturbo (Sufami Turbo)
1140   – sgb (Super Game Boy)
1142   – dmg (Game Boy)
1144   – gbc (Game Boy Color)
1146   – gbc_gba (Game Boy Color with GBA initial register values)
1148 • Optionally a region can be specified: “region <region>”. The 
1149   following values are valid:
1151   – autodetect (Autodetect region: snes and sgb only)
1153   – ntsc (NTSC: snes, bsx, bsxslotted, sufamiturbo, sgb)
1155   – pal (PAL: snes, sgb)
1157   – world (World: dmg, gbc, gbc_gba)
1159 • ROM images are loaded as: “rom <type> <file>”. The following 
1160   types are valid:
1162   – rom (Cartridge ROM in snes, dmg, gbc, gbc_gba. BIOS in bsx, 
1163     bsxslotted, sufamiturbo)
1165   – bsx (Cartridge ROM in bsx, bsxslotted)
1167   – slot-a (Cartridge ROM in sufamiturbo)
1169   – slot-b (Cartridge ROM in sufamiturbo)
1171 • ROM markup can be loaded as: “xml <type> <file>”. The types 
1172   valid are the same as for ROMs.
1174 • Patches can be loaded as “patch[<offset>] <type> <file>”. The 
1175   types are the same as for ROMs.
1177   – Offset is given in form [+-]<number>. Usually offset is 
1178     either +0 or -512.
1180   – Default offset is +0.
1182 13.1 Example:
1184 [GAMEPACK FILE]
1186 type snes
1188 rom rom speedygonzales.sfc
1190 patch-512 rom sonicthehedgehog.ips
1192 13.2 Example 2:
1194 [GAMEPACK FILE]
1196 type sgb
1198 rom rom supergameboy.sfc
1200 rom dmg megamanV.dmg
1202 14 Quick'n'dirty encode guide
1204 1. Start the emulator and load the ROM and movie file.
1206 2. Set large AVI option 'set-setting avi-large on'
1208 3. Enable dumping 'dump-avi tmpdump' 
1210 4. Unpause and let it run until you want to end dumping.
1212 5. Close the emulator (closing the window is the easiest way). Or 
1213   use 'end-avi'.
1215 6. For each tmpdump*.avi file created, on command prompt, do 
1216   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
1218 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
1220 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
1221   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
1222   tmpdump_<numbers>.mkv, with + in between).
1224 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
1225   final.mkv contains quick'n'dirty encode.
1227 15 Axis configurations for some gamepad types:
1229 15.1 XBox360 controller:
1231 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
1232 set to pressure-+.
1234 set-axis joystick0axis2 pressure-+
1236 set-axis joystick0axis5 pressure-+
1238 • This is needed for SDL only. EVDEV sets those types correctly.
1240 15.2 PS3 “sixaxis” controller:
1242 Axes 8-19 should be disabled.
1244 set-axis joystick0axis8 disabled
1246 set-axis joystick0axis9 disabled
1248 set-axis joystick0axis10 disabled
1250 set-axis joystick0axis11 disabled
1252 set-axis joystick0axis12 disabled
1254 set-axis joystick0axis13 disabled
1256 set-axis joystick0axis14 disabled
1258 set-axis joystick0axis15 disabled
1260 set-axis joystick0axis16 disabled
1262 set-axis joystick0axis17 disabled
1264 set-axis joystick0axis18 disabled
1266 set-axis joystick0axis19 disabled
1268 16 Errata:
1270 16.1 Problems from BSNES core:
1272 • The whole pending save stuff.
1274 • It is slow (especially accuracy).
1276 • Firmwares can't be loaded from ZIP archives.
1278 16.2 Other problems:
1280 • Modifiers don't work with pseudo-keys.
1282 • Audio for last dumped frame is not itself dumped.
1284 • Audio in UI is pretty bad in quality if game doesn't run at 
1285   full speed.