GB: Disassemble/Tracelog fixes for CB xx
[lsnes.git] / manual.txt
blobf7ced34d369e380fc6730b43ed96c551e19a2fde
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 set-jukebox-slot <slot>
374 Set current jukebox slot
376 5.4.4 load-jukebox
378 Do load from jukebox (current mode).
380 5.4.5 save-jukebox
382 Do state save to jukebox.
384 5.5 Lua 
386 5.5.1 evaluate-lua <luacode>
388 Run Lua code <luacode> using built-in Lua interpretter.
390 5.5.2 L <luacode>
392 Synonym for evaluate-lua.
394 5.5.3 run-lua <script>
396 Run specified lua file using built-in Lua interpretter.
398 5.5.4 reset-lua
400 Clear the Lua VM state and restore to factory defaults.
402 5.6 Memory watch
404 5.6.1 add-watch <name> <expression>
406 Adds new watch (or modifies old one).
408 5.6.2 remove-watch <name>
410 Remove a watch.
412 5.7 Sound 
414 5.7.1 enable-sound <on/off> 
416 Enable/Disable sound.
418 5.8 Misc.
420 5.8.1 reload-rom [<file>]
422 Reloads the main ROM image from <file>.
424 5.8.2 +tangent
426 Tangent for recording voice for commentary track. While pressed, 
427 record a stream.
429 5.8.3 advance-subframe-timeout
431 Subframe advance timeout in milliseconds. Default is 100.
433 6 Settings
435 6.1 Core settings
437 6.2 AVI dumper settings
439 6.2.1 avi-large
441 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
442 the console outputs.
444 6.2.2 avi-left-border
446 AVI dumper: Set the default left border thickness (unless lua 
447 overrides) for dumps. Range 0-8191. Default is 0.
449 6.2.3 avi-right-border
451 AVI dumper: Set the default right border thickness (unless lua 
452 overrides) for dumps. Range 0-8191. Default is 0.
454 6.2.4 avi-top-border
456 AVI dumper: Set the default top border thickness (unless lua 
457 overrides) for dumps. Range 0-8191. Default is 0.
459 6.2.5 avi-bottom-border
461 AVI dumper: Set the default bottom border thickness (unless lua 
462 overrides) for dumps. Range 0-8191. Default is 0.
464 6.2.6 avi-maxframes
466 AVI dumper: Maximum number of frames per dump segment (0 => 
467 unlimited). Range 0-999999999. Default is 0.
469 6.2.7 avi-compresison
471 AVI dumper: Compression level (0-18).
473 • Compression levels 10 and above are not compatible with stock 
474   CSCD codec.
476 • Recomended level is 7.
478 6.2.8 avi-soundrate
480 AVI dumper: Set method of determining the sound rate.
482 • 0: Pick nearest of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48, 
483   64, 88.2, 96, 128, 176.4 and 192 kHz.
485 • 1: Round down to nearest integer.
487 • 2: Round up to nearest ingeter.
489 • 3: Multiply by denominator.
491 • 4: High quality 44.1kHz (SRC needed).
493 • 5: High quality 48kHz (SRC needed).
495 6.3 JMD options
497 6.3.1 jmd-compression
499 JMD dumper: Compression level (0-9).
501 7 Movie editor
503 • The editor edits in-memory movie.
505 • Because past can't be edited and readwrite mode doesn't allow 
506   future, editing only works in read only mode.
508 • Keyboard triggers the normal hotkeys and bindings.
510 7.1 Left button actions
512 • Clicking on cell in future (indicated by lack of redish 
513   background) toggles it (if it is a button) or prompts for a 
514   value (if it is an axis)
516 • Dragging vertically toggles sequence of buttons or changes a 
517   sequence of axis values.
519 7.2 Right button actions
521 The right mouse button pops up a context-sensitive menu:
523 • Toggle <something>: Toggle this button
525 • Change <something>: Change this axis value
527 • Insert frame after: Insert a frame after this frame
529 • Append frame: Append a frame to movie
531 • Append frames: Append specified number of frames to movie
533 • Delete frame: Delete this frame
535 • Delete subframe: Delete this subframe
537 • Truncate movie: Delete this subframe and everything after it.
539 • Scroll to frame: Prompt for a frame and scroll the display to 
540   that frame.
542 • Scroll to current frame: Scroll the display to current position
544 • Run to frame: Prompts for frame and runs the emulation to that 
545   frame.
547 • Change number of lines visible: Change the height of the movie 
548   display (1 to 255).
550 • Lock scroll to playback: While playing back or rewinding 
551   movies, the display will follow if enabled.
553 8 Memory watch expression syntax
555 Memory watch expressions are in RPN (Reverse Polish Notation). At 
556 the end of expression, the top entry on stack is taken as the 
557 final result.
559 Notations:
561 • Evaluation order is strictly left to right.
563 • a is the entry on top of stack
565 • b is the entry immediately below top of stack
567 • ; separates values to be pushed (no intermediate pop).
569 • After end of element, all used stack slots are popped and all 
570   results are pushed.
572 • When pushing multiple values, the pushes occur in order shown.
574 The following operators are available:
576 • + : a + b
578 • - : a - b
580 • * : a * b
582 • / : a / b
584 • % : a % b
586 • a : atan(a)
588 • b : read_signed_byte(a)
590 • c : cos(a)
592 • d : read_signed_dword(a)
594 • f: read_float(a)
596 • i : quotent(a / b)
598 • o: read_signed_hword(a)
600 • p :\pi
603 • q : read_signed_qword(a)
605 • r : sqrt(a)
607 • s : sin(a)
609 • t : tan(a)
611 • u : a; a
613 • w : read_signed_word(a)
615 • A : atan2(a, b)
617 • B : read_unsigned_byte(a)
619 • C<number>z : Push number <number> to stack.
621 • D : read_unsigned_dword(a)
623 • C0x<number>z : Push number <number> (hexadecimal) to stack.
625 • F: read_double(a)
627 • H<digit> : Set hexadecimal mode with specified number of digits 
628   (use A-G for 10-16 digits).
630 • O: read_unsigned_hword(a)
632 • Q : read_unsigned_qword(a)
634 • R<digit> : round a to <digit> digits.
636 • W : read_unsigned_word(a)
638 8.1 Example:
640 C0x007e0878zWC0x007e002czW-
642 1. Push value 0x7e0878 on top of stack (C0x007e0878z).
644 2. Pop the value on top of stack (0x7e0878), read word value at 
645   that address and push the result,call it x1 (W).
647 3. Push value 0x7e002c on top of stack (C0x007e002cz).
649 4. Pop the value on top of stack (0x7e002c), read word value at 
650   that address and push the result,call it x2 (W).
652 5. Pop the two top numbers on stack, x1 and x2, substract x1 from 
653   x2 and push x2 - x1 (-).
655 6. Since the expression ends, the final memory watch result is 
656   the top one on stack, which is x2 - x1.
658 9 Modifier and key names:
660 9.1 wxWidgets platform
662 9.1.1 Modifier names:
664 Following modifier names are known:
666 • alt
668 • ctrl
670 • shift 
672 • meta
674 • cmd (Mac OS X only)
676 9.1.2 Key names:
678 Following key names are known:
680 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
681   dollar, percent, ampersand, quote, leftparen, rightparen, 
682   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
683   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
684   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
685   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
686   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
687   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
688   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
689   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
690   home, lefT, up, right, down, select, print, execute, snapshot, 
691   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
692   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
693   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
694   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
695   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
696   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
697   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
698   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
699   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
700   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
701   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
702   windows_right, windows_menu, command, special1, special2, 
703   special3, special4, special5, special6, special7, special8, 
704   special9, special10, special11, special12, special13, 
705   special14, special15, special16, special17, special18, 
706   special19, special20
708 10 Movie file format
710 Movie file is .zip archive in itself, normal ZIP archive tools 
711 work on it (note: If you recompress it, do not use compression 
712 methods other than store and deflate and especially do not use 
713 encryption of any kind).
715 10.1 Detecting clean start/SRAM/Savestate
717 • If file has member “savestate” it is savestate, otherwise:
719 • If file has members with names starting “moviesram.” it is 
720   movie starting from SRAM, otherwise:
722 • It is movie starting from clear state.
724 10.2 Member: gametype
726 Type of game ROM and region (as one line). Valid values are:
729 +--------------+---------------------+--------+
730 |    Value     |       System        | Region |
731 +--------------+---------------------+--------+
732 +--------------+---------------------+--------+
733 |  snes_pal    |     Super NES       |  PAL   |
734 +--------------+---------------------+--------+
735 |   sgb_pal    |   Super Game Boy    |  PAL   |
736 +--------------+---------------------+--------+
737 |  snes_ntsc   |     Super NES       |  NTSC  |
738 +--------------+---------------------+--------+
739 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
740 +--------------+---------------------+--------+
741 |     bsx      | BS-X (non-slotted)  |  NTSC  |
742 +--------------+---------------------+--------+
743 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
744 +--------------+---------------------+--------+
745 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
746 +--------------+---------------------+--------+
749 Frame rates are:
752 +---------+-----------------+
753 | Region  | Framerate (fps) |
754 +---------+-----------------+
755 +---------+-----------------+
756 |  PAL    |   322445/6448   |
757 +---------+-----------------+
758 |  NTSC   | 10738636/178683 |
759 +---------+-----------------+
762 10.3 Member: port1
764 Contains type of port #1 (as one line). Valid values are 'none', 
765 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
766 'gamepad'.
768 10.4 Member: port2
770 Contains type of port #2 (as one line). Valid values are 'none', 
771 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
772 'justifiers'. If not present, defaults to 'none'.
774 10.5 Member: gamename
776 Contains name of the game (as one line).
778 10.6 Member: authors
780 Contains authors, one per line. Part before '|' is the full name, 
781 part after is the nickname.
783 10.7 Member: systemid
785 Always “lsnes-rr1” (one line). Used to reject other saves.
787 10.8 Member: controlsversion
789 Always “0” (one line). Used to identify what controls are there.
791 10.9 Member: “coreversion”
793 Contains bsnes core version number (as one line).
795 10.10 Member: projectid
797 Contains project ID (as one line). Used to identify if two movies 
798 are part of the same project.
800 10.11 Member: {rom,slota,slotb}{,xml}.sha256
802 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
803 Absent if corresponding file is absent.
805 10.12 Member: moviesram.<name>
807 Raw binary startup SRAM of kind <name>. Only present in 
808 savestates and movies starting from SRAM.
810 10.13 Member: saveframe
812 Contains frame number (as one line) of frame movie was saved on. 
813 Only present in savestates.
815 10.14 Member: lagcounter
817 Current value of lag counter (as one line). Only present in 
818 savestates.
820 10.15 Member: pollcounters
822 Contains poll counters (currently 100 of them), one per line. 
823 Each line is raw poll count if DRDY is set for it. Otherwise it 
824 is negative poll count minus one. Only present in savestates.
826 10.16 Member: hostmemory
828 Raw binary dump of host memory. Only present in savestates.
830 10.17 Member: savestate
832 The raw binary savestate itself. Savestate detection uses this 
833 file, only present in savestates.
835 10.18 Member: screenshot
837 Screenshot of current frame. Only present in savestates. First 2 
838 bytes are big-endian width of image, rest are 24-bit RGB image 
839 data. Height of image is inferred from the width and size of 
840 data.
842 10.19 Member: sram.<name>
844 Raw binary SRAM of kind <name> at time of savestate. Only present 
845 in savestates.
847 10.20 Member: input
849 The actual input track, one line per subframe (blank lines are 
850 skipped).
852 • If the first byte of each line is '.', ' ', <tab> or '|', then 
853   the line is part of same frame as previous, otherwise it starts 
854   a new frame.
856 • First subframe must start a new frame.
858 Length of movie in frames is number of lines in input file that 
859 start a new frame.
861 10.21 Member: subtitles
863 Subtitle track. Optional.
865 • Each line is in form <firstframe> <numframes> <text>.
867 • Linefeed is encoded as \n, backslash is encoded as \\.
869 10.22 Member: rerecords
871 Contains textual base-10 rerecord count (as one line; emulator 
872 just writes this, it doesn't read it) + 1.
874 10.23 Member: rrdata
876 This member stores set of load IDs. There is one load ID per 
877 rerecord (plus one corresponding to start of project).
879 • This member constists of concatenation of records
881 • Each record is 2-36 bytes long and can represent 1-16,843,009 
882   consequtive IDs.
884 • IDs are interpretted as 256-bit big-endian integers with 
885   warparound.
887 • Initial predicted ID is all zeroes.
889 Format of each record is:
891 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
892   bits 5-6 are count length (countlen). Bit 7 is unused.
894 • 32-prefixlen bytes of ID.
896 • countlen bytes of big-endian count (count).
898 Records are processed as follows:
900 • To form the first ID encoded by record, take the first 
901   prefixlen bytes predicted ID and append the read ID value to 
902   it. The result is the first ID encoded.
904 • If countlen is 0, record encodes 1 ID.
906 • If countlen is 1, record encodes 2+count IDs.
908 • If countlen is 2, record encodes 258+count IDs.
910 • If countlen is 3, record encodes 65794+count IDs.
912 • The new predicted ID is the next ID after last one encoded by 
913   the record.
915 The number of rerecords + 1 is equal to the sum of number of IDs 
916 encoded by all records.
918 10.24 Member: starttime.second
920 Movie starting time, second part. Epoch is Unix epoch. Default is 
921 1,000,000,000.
923 10.25 Member: starttime.subsecond
925 Movie starting time, subsecond part. Unit is CPU clocks. Default 
926 is 0.
928 10.26 Member: savetime.second
930 Movie saving time, second part. Default is starttime.second. Only 
931 present in savestates.
933 10.27 Member: savetime.subsecond
935 Movie saving time, subsecond part. Default is 
936 starttime.subsecond. Only present in savestates.
938 11 lsvs file format (commentary tracks)
940 11.1 Clusters
942 • Each cluster is 8kB (8192 bytes) in size.
944 • Cluster n starts at offset 8192*n in file.
946 • The following clusters are system special:
948   – Cluster 0 and all clusters with number multiple of 2048 
949     (cluster tables)
951   – Cluster 1 (superblock)
953 11.2 Cluster tables
955 • The cluster table describing cluster n is stored in cluster n & 
956   ~0x7FF (zero last 11 bits of n).
958 • This cluster table consists of 2048 4-byte big-endian integers.
960 • Each entry describes a cluster in 16MB supercluster, in order.
962 • The valid values for entries are:
964   – 0x00000000: Free cluster
966   – 0x00000001: Last cluster in chain.
968   – 0xFFFFFFFF: System cluster (cluster tables and superblock)
970   – (anything else): Number of next cluster in chain. Must not be 
971     multiple of 2048.
973 • Due to limitations of the format, there can be at most 2097052 
974   superclusters, giving maximum file size of 16TB.
976 11.3 Stream table
978 • The stream table chain always starts in cluster 2.
980 • Otherwise, it follows normal chaining.
982 • The stream table consists of 16-byte entries:
984   – The first 8 bytes of entry give big-endian beginning position 
985     of stream in units of 1/48000 s.
987   – The next 4 bytes of entry give big-endian beginning cluster 
988     for control data. 0 here marks the entry as not present.
990   – The last 4 bytes of entry give big-endian beginning cluster 
991     for codec data.
993 • Stream table clusters are normal clusters, following normal 
994   chaining.
996 • The stream begnning position is not guarenteed unique. There 
997   can be multiple streams with the same starting position in the 
998   file.
1000 11.4 Stream control data
1002 • The stream control data consists of entries 4 bytes each:
1004   – The first 2 bytes of entry gives big-endian length of packet
1006   – The next byte of entry gives audio length of packet in units 
1007     of 1/400 s.
1009   – The last byte is control byte.
1011     ∗ 0 means this entry is not present and the control data 
1012       ends.
1014     ∗ 1 is valid control entry.
1016 • The stream control data can also end by running into end of the 
1017   readable chain.
1019   – This happens if there happens to be exact multiple of 2048 
1020     packets in stream and number of packets is nonzero.
1022 • These clusters follow normal chaining.
1024 11.5 Stream codec data
1026 • Stream codec data consists of raw Opus data packets packed back 
1027   to back with nothing in between.
1029 • Warning: Due to internal limitations, this data must reside in 
1030   the first 65536 superclusters (that is, the first 1TB of the 
1031   file).
1033 11.6 Superblock
1035 • The superblock is stored in cluster 1. 
1037 • The first 11 bytes are “sefs-magic”<NUL>.
1039 • The rest are unused.
1041 • This cluster 1 is marked as system special.
1043 12 Known ROM extensions
1045 • SNES cartridge ROMs: sfc, smc, swc, fig, ufo, sf2, gd3, gd7, 
1046   dx2, mgd, mgh.
1048 • DMG cartridge ROMs: dmg, gb.
1050 • GBC cartridge ROMs: cgb, gbc.
1052 13 Gamepack files
1054 • The first line must be: “[GAMEPACK FILE]”.
1056 • There is one needed line: “type <systype>”. This sets system 
1057   type to <systype>. The following system types are valid:
1059   – snes (SNES)
1061   – bsx (BS-X non-slotted)
1063   – bsxslotted (BS-X slotted)
1065   – sufamiturbo (Sufami Turbo)
1067   – sgb (Super Game Boy)
1069   – dmg (Game Boy)
1071   – gbc (Game Boy Color)
1073   – gbc_gba (Game Boy Color with GBA initial register values)
1075 • Optionally a region can be specified: “region <region>”. The 
1076   following values are valid:
1078   – autodetect (Autodetect region: snes and sgb only)
1080   – ntsc (NTSC: snes, bsx, bsxslotted, sufamiturbo, sgb)
1082   – pal (PAL: snes, sgb)
1084   – world (World: dmg, gbc, gbc_gba)
1086 • ROM images are loaded as: “rom <type> <file>”. The following 
1087   types are valid:
1089   – rom (Cartridge ROM in snes, dmg, gbc, gbc_gba. BIOS in bsx, 
1090     bsxslotted, sufamiturbo)
1092   – bsx (Cartridge ROM in bsx, bsxslotted)
1094   – slot-a (Cartridge ROM in sufamiturbo)
1096   – slot-b (Cartridge ROM in sufamiturbo)
1098 • ROM markup can be loaded as: “xml <type> <file>”. The types 
1099   valid are the same as for ROMs.
1101 • Patches can be loaded as “patch[<offset>] <type> <file>”. The 
1102   types are the same as for ROMs.
1104   – Offset is given in form [+-]<number>. Usually offset is 
1105     either +0 or -512.
1107   – Default offset is +0.
1109 13.1 Example:
1111 [GAMEPACK FILE]
1113 type snes
1115 rom rom speedygonzales.sfc
1117 patch-512 rom sonicthehedgehog.ips
1119 13.2 Example 2:
1121 [GAMEPACK FILE]
1123 type sgb
1125 rom rom supergameboy.sfc
1127 rom dmg megamanV.dmg
1129 14 Quick'n'dirty encode guide
1131 1. Start the emulator and load the ROM and movie file.
1133 2. Set large AVI option 'set-setting avi-large on'
1135 3. Enable dumping 'dump-avi tmpdump' 
1137 4. Unpause and let it run until you want to end dumping.
1139 5. Close the emulator (closing the window is the easiest way). Or 
1140   use 'end-avi'.
1142 6. For each tmpdump*.avi file created, on command prompt, do 
1143   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
1145 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
1147 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
1148   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
1149   tmpdump_<numbers>.mkv, with + in between).
1151 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
1152   final.mkv contains quick'n'dirty encode.
1154 15 Axis configurations for some gamepad types:
1156 15.1 XBox360 controller:
1158 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
1159 set to pressure-+.
1161 set-axis joystick0axis2 pressure-+
1163 set-axis joystick0axis5 pressure-+
1165 • This is needed for SDL only. EVDEV sets those types correctly.
1167 15.2 PS3 “sixaxis” controller:
1169 Axes 8-19 should be disabled.
1171 set-axis joystick0axis8 disabled
1173 set-axis joystick0axis9 disabled
1175 set-axis joystick0axis10 disabled
1177 set-axis joystick0axis11 disabled
1179 set-axis joystick0axis12 disabled
1181 set-axis joystick0axis13 disabled
1183 set-axis joystick0axis14 disabled
1185 set-axis joystick0axis15 disabled
1187 set-axis joystick0axis16 disabled
1189 set-axis joystick0axis17 disabled
1191 set-axis joystick0axis18 disabled
1193 set-axis joystick0axis19 disabled
1195 16 Errata:
1197 16.1 Problems from BSNES core:
1199 • The whole pending save stuff.
1201 • It is slow (especially accuracy).
1203 • Firmwares can't be loaded from ZIP archives.
1205 16.2 Other problems:
1207 • Modifiers don't work with pseudo-keys.
1209 • Audio for last dumped frame is not itself dumped.
1211 • Audio in UI is pretty bad in quality if game doesn't run at 
1212   full speed.