lsnes rr0
[lsnes.git] / manual.txt
blob7ddb6f4c7323ec6a5f860eefc858958e6c8b55eb
1 1 Introduction
3 lsnes is SNES rerecording emulator based on bsnes core.
5 2 Command line options
7 • Syntax: lsnes.exe <rom-options> <misc-options> 
8   (<new-session-options>|<filename>)
10 • Syntax: lsnes-avidump <dump-options> <misc-options> 
11   <rom-options> <filename>
13 • Syntax: movieinfo.exe <filename>
15 2.1 ROM options
17 These options control loading the ROM.
19 2.1.1 --rom=<file>
21 Load <file> (SFC file format) as main SNES cartridge ROM. This is 
22 the game ROM for SNES and cartridge BIOS for other types. 
23 Required option.
25 2.1.2 --headered-rom=<file>
27 Same as --rom, but strips first 512 bytes off the file as copier 
28 header. Handy for loading .smc and .fig (also some others) files.
30 2.1.3 --rom-xml=<file>
32 Set the mapping XML file for main cartridge ROM. If not 
33 specified, defaults are used.
35 2.1.4 --bsx=<file>
37 Load <file> (BS file format) as BS-X non-slotted flash memory. 
38 Also sets system type to BS-X non-slotted (not compatible with 
39 --bsxslotted=<file>, --dmg=<file>, --slot-a=<file> nor 
40 --slot-b=<file>).
42 2.1.5 --headered-bsx=<file>
44 Same as --bsx but strips first 512 bytes off the file as copier 
45 header. Handy for loading .smc and .fig (also some others) files.
47 2.1.6 --bsx-xml=<file>
49 Set mapping XML file for BS-X non-slotted flash memory. If not 
50 specified, defaults are used. Only can be used together with 
51 --bsx=<file>.
53 2.1.7 --bsxslotted=<file>
55 Load <file> (BS file format) as BS-X slotted flash memory. Also 
56 sets system type to BS-X slotted (not compatible with 
57 --bsx=<file>, --dmg=<file>, --slot-a=<file> nor --slot-b=<file>).
59 2.1.8 --headered-bsxslotted=<file>
61 Same as --bsxslotted but strips first 512 bytes off the file as 
62 copier header. Handy for loading .smc and .fig (also some others) 
63 files.
65 2.1.9 --bsxslotted-xml=<file>
67 Set mapping XML file for BS-X slotted flash memory. If not 
68 specified, defaults are used. Only can be used together with 
69 --bsxslotted=<file>.
71 2.1.10 --dmg=<file>
73 Load <file> (GB file format) as Game Boy ROM. Also sets system 
74 type to SGB (not compatible with --bsx=<file>, 
75 --bsxslotted=<file>, --slot-a=<file> nor --slot-b=<file>).
77 2.1.11 --headered-dmg=<file>
79 Same as --dmg but strips first 512 bytes off the file as copier 
80 header. Handy for loading .smc and .fig (also some others) files.
82 2.1.12 --dmg-xml=<file>
84 Set mapping XML file for Game Boy ROM. If not specified, defaults 
85 are used. Only can be used together with --dmg=<file>.
87 2.1.13 --slot-a=<file>
89 Load <file> (ST file format) as Sufami turbo cartridge A ROM. 
90 Also sets system type to Sufami Turbo (not compatible with 
91 --bsx=<file>, --bsxslotted=<file> nor --dmg=<file>).
93 2.1.14 --headered-slot-a=<file>
95 Same as --slot-a but strips first 512 bytes off the file as 
96 copier header. Handy for loading .smc and .fig (also some others) 
97 files.
99 2.1.15 --slot-a-xml=<file>
101 Set mapping XML file for Sufami turbo cartridge A ROM. If not 
102 specified, defaults are used. Only can be used together with 
103 --slot-a=<file>.
105 2.1.16 --slot-b=<file>
107 Load <file> (ST file format) as Sufami turbo cartridge B ROM. 
108 Also sets system type to Sufami Turbo (not compatible with 
109 --bsx=<file>, --bsxslotted=<file> nor --dmg=<file>).
111 2.1.17 --headered-slot-b=<file>
113 Same as --slot-b but strips first 512 bytes off the file as 
114 copier header. Handy for loading .smc and .fig (also some others) 
115 files.
117 2.1.18 --slot-b-xml=<file>
119 Set mapping XML file for Sufami turbo cartridge B ROM. If not 
120 specified, defaults are used. Only can be used together with 
121 --slot-b=<file>.
123 2.1.19 --ips-rom=<file>
125 Apply IPS patch <file> to main cartridge ROM. Requires 
126 --rom=<file>.
128 2.1.20 --ips-rom-xml=<file>
130 Apply IPS patch <file> to main cartridge ROM mapping XML. 
131 Requires --rom-xml=<file>.
133 2.1.21 --ips-bsx=<file>
135 Apply IPS patch <file> to BS-X non-slotted flash. Requires 
136 --bsx=<file>.
138 2.1.22 --ips-bsx-xml=<file>
140 Apply IPS patch <file> to BS-X non-slotted flash mapping XML. 
141 Requires --bsx-xml=<file>.
143 2.1.23 --ips-bsxslotted=<file>
145 Apply IPS patch <file> to BS-X slotted flash. Requires 
146 --bsxslotted=<file>.
148 2.1.24 --ips-bsxslotted-xml=<file>
150 Apply IPS patch <file> to BS-X slotted flash mapping XML. 
151 Requires --bsxslotted-xml=<file>.
153 2.1.25 --ips-dmg=<file>
155 Apply IPS patch <file> to Game Boy ROM. Requires --dmg=<file>.
157 2.1.26 --ips-dmg-xml=<file>
159 Apply IPS patch <file> to Game Boy ROM mapping XML. Requires 
160 --dmg-xml=<file>.
162 2.1.27 --ips-slot-a=<file>
164 Apply IPS patch <file> to Sufami turbo cartridge A ROM. Requires 
165 --slot-a=<file>.
167 2.1.28 --ips-slot-a-xml=<file>
169 Apply IPS patch <file> to Sufami turbo cartridge A ROM mapping 
170 XML. Requires --slot-a-xml=<file>.
172 2.1.29 --ips-slot-b=<file>
174 Apply IPS patch <file> to Sufami turbo cartridge B ROM. Requires 
175 --slot-b=<file>.
177 2.1.30 --ips-slot-b-xml=<file>
179 Apply IPS patch <file> to Sufami turbo cartridge B ROM mapping 
180 XML. Requires --slot-b-xml=<file>.
182 2.1.31 --ips-offset=<offset>
184 Set IPS apply offset to <offset> (can be negative). IPS apply 
185 offset is added to all addresses inside IPS file before applying. 
186 If the resulting address is negative, write is ignored (with a 
187 warning). If resulting address exceeds ROM size, the ROM is 
188 extended.
190 Using offset of -512 is handy for applying IPS patches meant for 
191 SMC/FIG or such files.
193 2.1.32 --pal
195 Force ROM to be considered PAL-only (warning: Will cause error if 
196 used on anything except SNES and SGB).
198 2.1.33 --ntsc
200 Force ROM to be considered NTSC-only (default for everything 
201 except SNES and SGB).
203 2.2 New session options (lsnes.exe only)
205 If filename is not specified, new session is started. These 
206 options control the properties of new session:
208 2.2.1 --port1=<type>
210 Set type of port1. Valid values are:
212 • none: No device connected
214 • gamepad: One gamepad (the default)
216 • multitap: Four gamepads (warning: makes most games refuse to 
217   start)
219 • mouse: Mouse.
221 2.2.2 --port2=<type>
223 Set type of port2. Valid values are:
225 • none: No device connected (the default)
227 • gamepad: One gamepad
229 • multitap: Four gamepads.
231 • mouse: Mouse
233 • superscope: Super Scope
235 • justifier: One justifier
237 • justifiers: Two justifiers
239 2.2.3 --gamename=<name>
241 Set the name of game to <name>
243 2.2.4 --author=<name>
245 Add author with full name of <name> (no nickname).
247 2.2.5 --author=|<name>
249 Add author with nickname of <name> (no full name).
251 2.2.6 --author=<fullname>|<nickname>
253 Add author with full name of <fullname> and nickname of 
254 <nickname>.
256 2.2.7 --rtc-second=<value>
258 Set RTC second (0 is 1st January 1970 00:00:00Z).
260 2.2.8 --rtc-subsecond=<value>
262 Set RTC subsecond. Range is 0-. Unit is CPU cycle.
264 2.3 <filename>
266 If filename is specified on command line, it is loaded as initial 
267 state (instead of constructing one). Mandatory for 
268 lsnes-avidump.exe and movieinfo.exe.
270 2.4 Misc. options
272 2.4.1 --run=<file> (lsnes.exe only)
274 After running main RC file, run this file. If multiple are 
275 specified, these execute in order specified.
277 2.5 dump options (lsnes-avidump.exe only)
279 2.5.1 --prefix=<prefix>
281 Set dump prefix. Default is “avidump”.
283 2.5.2 --level=<level>
285 Set compression level (0-18). Default is 7.
287 2.5.3 --length=<length>
289 Set number of frames to dump. Mandatory.
291 2.5.4 --lua=<script>
293 Run specified lua script (lsnes-avidump.exe does not have 
294 initialization files).
296 2.5.5 --jmd
298 Use JMD dumping instead of AVI dumping.
300 3 Startup file lsnes.rc
302 Upon startup, lsnes (lsnes.exe only) executes file lsnes.rc as 
303 commands. This file is located in:
305 • Windows: %APPDATA%\lsnes\lsnes.rc (if %APPDATA% exists)
307 • Unix: $XDG_CONFIG_HOME/lsnes/lsnes.rc (if $XDG_CONFIG_HOME 
308   exists)
310 • Unix: $HOME/.config/lsnes/lsnes.rc (if $HOME exists)
312 • All: ./lsnes.rc (fallback default).
314 If leading directories do not exist, attempt to create them is 
315 made.
317 4 Game internal commands
319 • Commands beginning with '*' invoke the corresponding command 
320   without alias expansion.
322 • If command starts with '+' (after possible '*'), the command is 
323   executed as-is when button is pressed, and when button is 
324   released, it is executed with '+' replaced by '-'.
326 4.1 Settings:
328 Settings control various aspects of emulator behaviour.
330 4.1.1 set-setting <setting> <value>
332 Sets setting <setting> to value <value> (may be empty).
334 4.1.2 unset-setting <setting>
336 Try to unset setting <setting> (not all settings can be unset).
338 4.1.3 get-setting <setting>
340 Read value of setting <setting>
342 4.1.4 show-settings
344 Print names and values of all settings.
346 4.2 Keybindings
348 Keybindings bind commands or aliases to keys (or pseudo-keys). 
350 Notes:
352 • Do not bind edge active (+/-) commands to keys with modifiers, 
353   that won't work right!
355 • Names of keys and modifiers are platform-dependent.
357 • Be careful before binding pseudo-keys (such as joystick axes, 
358   buttons or hats) with modifiers. That may or may not work 
359   right.
361 4.2.1 bind-key [<mod>/<modmask>] <key> <command>
363 Bind <command> to key <key> (activating if modifiers in <modmask> 
364 (comma-seperated list) are set as <mod> (comma-seperated list).
366 The names of keys and modifiers are platform-dependent.
368 4.2.2 unbind-key [<mod>/<modmask>] <key>
370 Unbind command from <key> (with specified <mod> and <modmask>).
372 4.2.3 set-axis <axis> [disabled | axis | axis-inverse | 
373   pressure0- | pressure0+ | pressure-0 | pressure-+ | pressure+0 
374   | pressure+-] [minus=<val>] [zero=<val>] [plus=<val>] 
375   [tolerance=<val>]
377 Set axis parameters for axis <axis>.
379 • disabled: Disable axis
381 • axis: Normal axis
383 • axis-inverse: Inverse axis
385 • pressure0-: Pressure sensitive. Released at 0, pressed at -.
387 • pressure0+: Pressure sensitive. Released at 0, pressed at +.
389 • pressure-0: Pressure sensitive. Released at -, pressed at 0.
391 • pressure-+: Pressure sensitive. Released at -, pressed at +.
393 • pressure+0: Pressure sensitive. Released at +, pressed at 0.
395 • pressure+-: Pressure sensitive. Released at +, pressed at -.
397 • minus=<val>: Calibration at extreme minus position 
398   (-32768-32767)
400 • zero=<val>: Calibration at neutral position (-32768-32767)
402 • plus=<val>: Calibration at extreme plus position (-32768-32767)
404 • tolerance=<value>: Center band tolerance (0<x<1). The smaller 
405   the value, the more sensitive the control is.
407 4.2.4 show-bindings
409 Print all key bindings in effect.
411 4.3 Aliases
413 Aliases bind command to sequence of commands. After alias has 
414 been defined, it replaces the command it shadows.
416 Notes:
418 • You can't alias command to itself.
420 • Aliases starting with +/- are edge active just like ordinary 
421   commands starting with +/-.
423 • One command can be aliased to multiple commands.
425 4.3.1 alias-command <command> <expansion>
427 Append <expansion> to alias <command>. If alias does not already 
428 exist, it is created.
430 4.3.2 unalias-command <command>
432 Clear alias expansion for <command>.
434 4.3.3 show-aliases
436 Print all aliases and their expansions in effect.
438 4.4 run-script <script> (implemented for wxwidgets)
440 Run <script> as if commands were entered on the command line.
442 4.5 AVI Video dumping
444 Following commands control AVI video dumping:
446 4.5.1 dump-avi <level> <prefix>
448 Dump AVI video to prefix <prefix> at level <level> (0-18). Notes:
450 • The codec is Camstudio Codec in gzip mode.
452 • Encoder and muxer are internal, available on all platforms.
454 • Audio enable/disable and framerate has no effect.
456 • Levels 10-18 are not compatible with AVISource.
458 • Recomended level is 7 if decoded by AVISource.
460 • Recomended level is 16 if decoded by ffmpeg, mencoder or 
461   FFMpegSource.
463 • Dumps of low-res PAL games are 256x239 (with all the 
464   consequences odd height carries).
466 • The audio dumped to .avi is low-quality version. The 
467   high-quality version is dumped to .sox file.
469 4.5.2 end-avi
471 End current AVI video dump (closing the emulator also closes the 
472 dump).
474 4.6 JMD video dumping
476 Following commands control JMD video dumping:
478 4.6.1 dump-jmd <level> <file>
480 Dump JMD video to file <file> at level <level> (0-9).
482 4.6.2 end-jmd
484 End the current JMD dump in progress.
486 4.7 Memory manipulation
488 <address> may be decimal or hexadecimal (prefixed with '0x'). 
489 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
490 signed (prefixed with '-') decimal.
492 The available element <sizes> are:
494 • byte: 1 byte
496 • word: 2 bytes
498 • dword: 4 bytes
500 • qword: 8 bytes
502 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
503 When dealing with DSP memory, multi-byte reads/writes are 
504 native-endian (do not use operand sizes exceeding DSP bitness, 
505 except dword is OK for 24-bit memory).
507 4.7.1 read-<size> <address>
509 Read the value of byte in <address>.
511 4.7.2 read-s<size> <address>
513 Read the value of signed byte in <address>.
515 4.7.3 write-<size> <address> <value>
517 Write <value> to byte in address <address>.
519 4.7.4 search-memory reset
521 Reset the memory search
523 4.7.5 search-memory count
525 Print number of candidates remaining
527 4.7.6 search-memory print
529 Print all candidates remaining
531 4.7.7 search-memory <usflag><sizeflag><op>
533 Searches memory for addresses satisfying criteria.
535 <usflag> can be:
537 • u: unsigned
539 • s: signed
541 <sizeflag> can be:
543 • b: byte
545 • w: word
547 • d: dword
549 • q: qword
551 <op> can be:
553 • lt: < previous value.
555 • le: <= previous value.
557 • eq: = previous value.
559 • ne: != previous value.
561 • ge: >= previous value.
563 • gt: > previous value.
565 4.7.8 search-memory <sizeflag> <value>
567 Searches for addresses that currently have value <value>. 
568 <sizeflag> is as in previous command.
570 4.8 Main commands
572 These commands are not available in lsnesrc, but are available 
573 after ROM has been loaded.
575 4.8.1 quit-emulator [/y] (implemented for wxwidgets)
577 Quits the emulator (asking for confirmation). If /y is given, no 
578 confirmation is asked.
580 4.8.2 pause-emulator (implemented for wxwidgets)
582 Toggle paused/unpaused
584 4.8.3 +advance-frame (implemented for wxwidgets)
586 Advance frame. If the button is still held after configurable 
587 timeout expires, game unpauses for the duration frame advance is 
588 held.
590 4.8.4 +advance-poll (implemented for wxwidgets)
592 Advance subframe. If the button is still held after configurable 
593 timeout expires, game unpauses for the duration frame advance is 
594 held.
596 4.8.5 advance-skiplag (implemented for wxwidgets)
598 Skip to first poll in frame after current.
600 4.8.6 reset (implemented for wxwidgets)
602 Reset the SNES after this frame.
604 4.8.7 load <filename> (implemented for wxwidgets)
606 Load savestate <filename> in current mode.
608 4.8.8 load-state <filename> (implemented for wxwidgets)
610 Load savestate <filename> in readwrite mode.
612 4.8.9 load-readonly <filename> (implemented for wxwidgets)
614 Load savestate <filename> in readonly mode.
616 4.8.10 load-preserve <filename> (implemented for wxwidgets)
618 Load savestate <filename> in readonly mode, preserving current 
619 events.
621 4.8.11 load-movie <filename> (implemented for wxwidgets)
623 Load savestate <filename>, ignoring save part in readonly mode.
625 4.8.12 save-state <filename> (implemented for wxwidgets)
627 Save system state to <filename> as soon as possible.
629 4.8.13 save-movie <filename> (implemented for wxwidgets)
631 Save movie to <filename>.
633 4.8.14 set-rwmode (implemented for wxwidgets)
635 Set read-write mode.
637 4.8.15 set-romode (implemented for wxwidgets)
639 Set read-only mode
641 4.8.16 toggle-rwmode (implemented for wxwidgets)
643 Toggle between read-only and read-write modes.
645 4.8.17 set-gamename <name> (implemented for wxwidgets)
647 Set name of the game to <name>
649 4.8.18 get-gamename (implemented for wxwidgets)
651 Print the name of the game.
653 4.8.19 add-author <author> (implemented for wxwidgets)
655 Adds new author <author>. If <author> does not contain '|' it is 
656 full name. If it contains '|', '|' splits the full name and 
657 nickname.
659 4.8.20 edit-author <num> <author> (implemented for wxwidgets)
661 Edit the author in slot <num> (0-based) to be <author> (see 
662 add-author for format)
664 4.8.21 remove-author <num> (implemented for wxwidgets)
666 Remove author in slot <num>
668 4.8.22 print-authors (implemented for wxwidgets)
670 Print authors.
672 4.8.23 test-1, test-2, test-3 (N/A for wxwidgets)
674 Internal test commands. Don't use.
676 4.8.24 take-screenshot <filename> (implemented for wxwidgets)
678 Save screenshot to <filename>.
680 4.8.25 +controller<num><button> (N/A for wxwidgets)
682 Press button <button> on controller <num> (1-8). The following 
683 button names are known:
685 • left
687 • right
689 • up
691 • down
693 • A
695 • B
697 • X
699 • Y
701 • L
703 • R
705 • select
707 • start
709 • trigger
711 • cursor
713 • pause
715 • turbo
717 4.8.26 controllerh<num><button>
719 Hold/unhold button <button> on controller <num> (1-8). See 
720 +controller for button names.
722 4.8.27 autofire (<pattern>|-)... (N/A for wxwidgets)
724 Set autofire pattern. Each parameter is comma-separated list of 
725 button names (in form of 1start, 1A, 2B, etc..) to hold on that 
726 frame. After reaching the end of pattern, the pattern restarts 
727 from the beginning.
729 4.8.28 repaint (N/A for wxwidgets)
731 Force a repaint.
733 4.9 Save jukebox (implemented for wxwidgets)
735 4.9.1 cycle-jukebox-backward (N/A for wxwidgets)
737 Cycle save jukebox backwards.
739 4.9.2 cycle-jukebox-forward (N/A for wxwidgets)
741 Cycle save jukebox forwards
743 4.9.3 add-jukebox-save <filename> (N/A for wxwidgets)
745 Add <filename> to jukebox saves.
747 4.9.4 load-jukebox (N/A for wxwidgets)
749 Do load from jukebox (current mode).
751 4.9.5 save-jukebox (N/A for wxwidgets)
753 Do state save to jukebox.
755 4.10 Lua (implemented for wxwidgets)
757 Only available if lua support is compiled in.
759 4.10.1 <<<<<<< HEADevaluate-lua <luacode>=======eval-lua 
760   <luacode> (implemented for wxwidgets)>>>>>>> Wxwidgets Graphics 
761   plugin WIP
763 Run Lua code <luacode> using built-in Lua interpretter.
765 4.10.2 run-lua <script> (implemented for wxwidgets)
767 Run specified lua file using built-in Lua interpretter.
769 4.11 Memory watch
771 4.11.1 add-watch <name> <expression>
773 Adds new watch (or modifies old one).
775 4.11.2 remove-watch <name>
777 Remove a watch.
779 4.12 Sound (implemented for wxwidgets)
781 4.12.1 enable-sound <on/off> (implemented for wxwidgets)
783 Enable/Disable sound.
785 4.12.2 set-sound-device <device> (implemented for wxwidgets)
787 Set sound device to <device>
789 4.12.3 show-sound-status (implemented for wxwidgets)
791 Show status of sound system.
793 4.12.4 show-sound-devices (N/A for wxwidgets)
795 Show all available devices.
797 4.13 SDL Platform commands (implemented for wxwidgets)
799 The following are valid on SDL platform.
801 4.13.1 identify-key (N/A for wxwidgets)
803 Asks to press a key and then identifies that (pseudo-)key.
805 4.13.2 toggle-console (N/A for wxwidgets)
807 Toggle between windowed/fullscreen console.
809 4.13.3 scroll-fullup (N/A for wxwidgets)
811 Scroll messages window as far back as it goes.
813 4.13.4 scroll-fulldown (N/A for wxwidgets)
815 Scroll messages window as far forward as it goes.
817 4.13.5 scroll-up (N/A for wxwidgets)
819 Scroll messages window back one screenful.
821 4.13.6 scroll-down (N/A for wxwidgets)
823 Scroll messages window forward one screenful.
825 5 Settings
827 5.1 Core settings
829 5.1.1 firmwarepath
831 Set where bsnes looks for firmware files. Default is “.”.
833 5.1.2 targetfps
835 Set the target fps. Numeric, range is 0.001 to “infinite”. 
836 Default is native framerate.
838 5.1.3 savecompression
840 Set save compression level (integer 0-9). Default is 7 (0 is no 
841 compression).
843 5.1.4 advance-timeout
845 Set the frame advance timeout in milliseconds. Numeric integer, 
846 range is 0-999999999. Default is 500.
848 5.2 AVI dumper settings
850 5.2.1 avi-large
852 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
853 the console outputs.
855 5.2.2 avi-left-border
857 AVI dumper: Set the default left border thickness (unless lua 
858 overrides) for dumps. Range 0-8191. Default is 0.
860 5.2.3 avi-right-border
862 AVI dumper: Set the default right border thickness (unless lua 
863 overrides) for dumps. Range 0-8191. Default is 0.
865 5.2.4 avi-top-border
867 AVI dumper: Set the default top border thickness (unless lua 
868 overrides) for dumps. Range 0-8191. Default is 0.
870 5.2.5 avi-bottom-border
872 AVI dumper: Set the default bottom border thickness (unless lua 
873 overrides) for dumps. Range 0-8191. Default is 0.
875 5.2.6 avi-maxframes
877 AVI dumper: Maximum number of frames per dump segment (0 => 
878 unlimited). Range 0-999999999. Default is 0.
880 5.3 SDL platform settings
882 5.3.1 autorepeat-first-delay
884 Sets the delay for first character in typematic autorepeat.
886 5.3.2 autorepeat-subsequent-delay
888 Sets the delay for subsequent characters in typematic autorepeat.
890 6 Lua functions
892 6.1 Core (in main table)
894 6.1.1 print
896 Print line to message console.
898 6.1.2 exec(string command)
900 Run command as it was entered on the command line
902 6.2 Table bit:
904 Bitwise logical functions and related.
906 6.2.1 bit.none(number...) / bit.bnot(number...)
908 48-bit bitwise NOT / NONE function (set bits that are set in none 
909 of the arguments).
911 6.2.2 bit.any(number...) / bit.bor(number...)
913 48-bit bitwise OR / ANY function (set bits that are set in any of 
914 the arguments).
916 6.2.3 bit.all(number...) / bit.band(number...)
918 48-bit bitwise AND / ALL function (set bits that are set in all 
919 of the arguments).
921 6.2.4 bit.parity(number...) / bit.bxor(number...)
923 48-bit bitwise XOR / PARITY function (set bits that are set in 
924 odd number of the arguments).
926 6.2.5 bit.lrotate(number base[, number amount[, number bits]])
928 Rotate bits-bit (max 48, default 48) number left by amount 
929 (default 1) places.
931 6.2.6 bit.rrotate(number base[, number amount[, number bits]])
933 Rotate bits-bit (max 48, default 48) number right by amount 
934 (default 1) places.
936 6.2.7 bit.lshift(number base[, number amount[, number bits]])
938 Shift bits-bit (max 48, default 48) number left by amount 
939 (default 1) places. The new bits are filled with zeroes.
941 6.2.8 bit.lrshift(number base[, number amount[, number bits]])
943 Shift bits-bit (max 48, default 48) number logically right by 
944 amount (default 1) places. The new bits are filled with zeroes.
946 6.2.9 bit.arshift(number base[, number amount[, number bits]])
948 Shift bits-bit (max 48, default 48) number arithmetically right 
949 by amount (default 1) places. The new bits are shifted in with 
950 copy of the high bit.
952 6.3 Table gui:
954 Most of these functions can only be called in on_paint and 
955 on_video callbacks. Exceptions are noted.
957 Colors are 32-bit. Bits 0-7 are the blue component, bits 8-15 are 
958 the green component, bits 16-23 are the red component, bits 24-31 
959 are alpha component (0 is fully opaque, 255 is almost 
960 transparent). -1 is the fully transparent color. Alpha values 
961 greater than 127 do work.
963 Origin of coordinates is at top left corner of game display area. 
964 Left and top gaps correspond to negative coordinates.
966 6.3.1 gui.resolution()
968 Returns 2-tuple (hresolution, vresolution).
970 6.3.2 gui.<class>_gap(number gap)
972 Set the <class> (left, right, top, bottom) gap to specified value 
973 (max gap is 8191).
975 6.3.3 gui.text(number x, number y, string text[, number fgc[, 
976   number bgc]])
978 Draw specified text on the GUI (each character cell is 8 or 16 
979 wide and 16 high). Parameters:
981 • x: X-coordinate to start the drawing from (and x-coordinate at 
982   begining of the lines).
984 • y: Y-coordinate to start the drawing from.
986 • text: The text to draw.
988 • fgc: Text color (default is 0xFFFFFF (white))
990 • bgc: Background color (default is -1 (transparent))
992 6.3.4 gui.rectangle(number x, number y, number width, number 
993   height[, number thickness[, number outline[, number fill]]])
995 Draw rectangle on the GUI. Parameters:
997 • x: X-coordinate of left edge.
999 • y: Y-coordinate of upper edge.
1001 • width: Width of rectangle.
1003 • height: Height of rectangle.
1005 • thickness: Thickness of outline (default is 1).
1007 • outline: Color of outline (default is 0xFFFFFF (white))
1009 • fill: Color of fil (default is -1 (transparent))
1011 6.3.5 gui.pixel(number x, number y[, number color])
1013 Draw one pixel on the GUI. Parameters:
1015 • x: X-coordinate of the pixel
1017 • y: Y-coordinate of the pixel
1019 • color: Color of the pixel (default is 0xFFFFFF (white))
1021 6.3.6 gui.crosshair(number x, number y[, number length[, number 
1022   color]])
1024 Draw a crosshair. Parameters:
1026 • x: X-coordinate of the crosshair
1028 • y: Y-coordinate of the crosshair
1030 • length: Length of the crosshair lines (default 10).
1032 • color: Color of the crosshair (default is 0xFFFFFF (white))
1034 6.3.7 gui.line(number x1, number y1, number x2, number y2[, 
1035   number color])
1037 Draw a thin line. Parameters:
1039 • x1: X-coordinate of one end.
1041 • y1: Y-coordinate of one end.
1043 • x2: X-coordinate of the other end.
1045 • y2: Y-coordinate of the other end.
1047 • color: Color of the line (default is 0xFFFFFF (white)).
1049 6.3.8 gui.circle(number x, number y, number r[, number thick[, 
1050   number border[, number fil]]])
1052 Draw a circle. Parameters.
1054 • x: X-coordinate of the center
1056 • y: Y-coordinate of the center
1058 • r: The radius of the circle
1060 • thick: Border thickness
1062 • border: Border color (default is 0xFFFFFF (white))
1064 • fill: Fill color (default is -1 (transparent)).
1066 6.3.9 gui.repaint()
1068 Request on_repaint() to happen as soon as possible. Can be used 
1069 anywhere.
1071 6.3.10 gui.subframe_update(boolean on)
1073 Request subframe updates (calling on_paint() on subframes) to 
1074 happen (on=true) or not happen (on=false). Can be used anywhere.
1076 6.3.11 gui.screenshot(string filename)
1078 Write PNG screenshot of the current frame (no drawings) to 
1079 specified file. Can be used anywhere.
1081 6.3.12 gui.color(number r, number g, number b[, number a])
1083 Returns color (in notation Lua scripts use) corresponding to 
1084 color (r,g,b), each component in scale 0-255. If a is specified, 
1085 that is alpha (0 is fully transparent, 256(sic) is fully opaque). 
1086 The default alpha is 256.
1088 6.3.13 gui.status(string name, string value)
1090 Set status field “L[<name>]” to <value> in status area. Can be 
1091 used anywhere.
1093 6.4 table input
1095 Input handling. Only available in on_input callback.
1097 6.4.1 input.get(number controller, number index)
1099 Read the specified index (0-11) from specified controller (0-7). 
1100 Notes:
1102 • Uses physical controller numbering. Gamepad in port 2 is 
1103   controller 4, not 1!
1105 6.4.2 input.set(number controller, number index, number value)
1107 Write the specified index (0-11) from specified controller (0-7), 
1108 storing value. Notes:
1110 • Uses physical controller numbering. Gamepad in port 2 is 
1111   controller 4, not 1!
1113 6.4.3 input.reset([number cycles])
1115 Execute reset. If cycles is greater than zero, do delayed reset. 
1116 0 (or no value) causes immediate reset.
1118 • Only available with subframe flag false.
1120 6.5 Table hostmemory
1122 Host memory handling (extra memory saved to savestates). Host 
1123 memory starts empty.
1125 6.5.1 hostmemory.read(number address)
1127 Reads hostmemory slot address. Slot numbers out of range return 
1128 false instead of numeric.
1130 6.5.2 hostmemory.write(number address, number value)
1132 Writes hostmemory slot with 0-255. Slot numbers out of range 
1133 cause extension of host memory slot space.
1135 6.5.3 hostmemory.readbyte(number address)
1137 Read unsigned byte (1 element) from given address. Slots out of 
1138 range return false.
1140 6.5.4 hostmemory.writebyte(number address, number value)
1142 Write unsigned byte (1 element) to given slot. Slot numbers out 
1143 of range cause extension.
1145 6.5.5 hostmemory.readsbyte(number address)
1147 Read signed byte (1 element) from given address. Slots out of 
1148 range return false.
1150 6.5.6 hostmemory.writesbyte(number address, number value)
1152 Write signed byte (1 element) to given slot. Slot numbers out of 
1153 range cause extension.
1155 6.5.7 hostmemory.readword(number address)
1157 Read unsigned word (2 elements) from given address. Slots out of 
1158 range return false.
1160 6.5.8 hostmemory.writeword(number address, number value)
1162 Write unsigned word (2 elements) to given slot. Slot numbers out 
1163 of range cause extension.
1165 6.5.9 hostmemory.readsword(number address)
1167 Read signed word (2 elements) from given address. Slots out of 
1168 range return false.
1170 6.5.10 hostmemory.writesword(number address, number value)
1172 Write signed word (2 elements) to given slot. Slot numbers out of 
1173 range cause extension.
1175 6.5.11 hostmemory.readdword(number address)
1177 Read unsigned doubleword (4 elements) from given address. Slots 
1178 out of range return false.
1180 6.5.12 hostmemory.writedword(number address, number value)
1182 Write unsigned doubleword (4 elements) to given slot. Slot 
1183 numbers out of range cause extension.
1185 6.5.13 hostmemory.readsdword(number address)
1187 Read signed doubleword (4 elements) from given address. Slots out 
1188 of range return false.
1190 6.5.14 hostmemory.writesdword(number address, number value)
1192 Write signed doubleword (4 elements) to given slot. Slot numbers 
1193 out of range cause extension.
1195 6.5.15 hostmemory.readqword(number address)
1197 Read unsigned quadword (8 elements) from given address. Slots out 
1198 of range return false.
1200 6.5.16 hostmemory.writeqword(number address, number value)
1202 Write unsigned quadword (4 elements) to given slot. Slot numbers 
1203 out of range cause extension.
1205 6.5.17 hostmemory.readsqword(number address)
1207 Read signed quadword (8 elements) from given address. Slots out 
1208 of range return false.
1210 6.5.18 hostmemory.writesqword(number address, number value)
1212 Write signed quadword (8 elements) to given slot. Slot numbers 
1213 out of range cause extension.
1215 6.6 Table movie
1217 Movie handling
1219 6.6.1 movie.currentframe()
1221 Return number of current frame.
1223 6.6.2 movie.framecount()
1225 Return number of frames in movie.
1227 6.6.3 movie.readonly()
1229 Return true if in readonly mode, false if in readwrite.
1231 6.6.4 movie.set_readwrite()
1233 Set readwrite mode (does not cause on_readwrite callback).
1235 6.6.5 movie.frame_subframes(number frame)
1237 Count number of subframes in specified frame (frame numbers are 
1238 1-based) and return that.
1240 6.6.6 movie.read_subframe(number frame, number subframe)
1242 Read specifed subframe in specified frame and return data as 
1243 array (100 elements, numbered 0-99 currently).
1245 6.7 Table settings
1247 Routines for settings manipulation
1249 6.7.1 settings.get(string name)
1251 Get value of setting. If setting is blank, returns false. If 
1252 setting value can't be obtained, returns (nil, error message).
1254 6.7.2 settings.set(string name, string value)
1256 Set value of setting. If setting can't be set, returns (nil, 
1257 error message).
1259 6.7.3 settings.is_set(string name)
1261 Returns if setting is set. If setting does not exist, returns 
1262 (nil, error message).
1264 6.7.4 settings.blank(string name)
1266 Blanks a setting and returns true. If setting can't be blanked, 
1267 returns (nil, error message).
1269 6.8 Table memory
1271 Contains various functions for managing memory
1273 6.8.1 memory.vma_count()
1275 Returns the number of VMAs
1277 6.8.2 memory.read_vma(number index)
1279 Reads the specified VMA (indices start from zero). Trying to read 
1280 invalid VMA gives nil. The read VMA is table with the following 
1281 fields:
1283 • region_name (string): The readable name of the VMA
1285 • baseaddr (number): Base address of the VMA
1287 • lastaddr (number): Last address in the VMA.
1289 • size (number): The size of VMA in bytes.
1291 • readonly (boolean): True of the VMA corresponds to ROM.
1293 • native_endian (boolean): True if the VMA has native endian as 
1294   opposed to little endian.
1296 6.8.3 memory.find_vma(number address)
1298 Finds the VMA containing specified address. Returns table in the 
1299 same format as read_vma or nil if not found.
1301 6.8.4 memory.readbyte(number address)
1303 Reads the specified address as unsigned byte and returns the 
1304 result.
1306 6.8.5 memory.readsbyte(number address)
1308 Reads the specified address as signed byte and returns the 
1309 result.
1311 6.8.6 memory.writebyte(number address, number value)
1313 Writes the specified value (negative values undergo 2's 
1314 complement) to specified address (as a byte).
1316 6.8.7 memory.readword(number address)
1318 Reads the specified address as unsigned word and returns the 
1319 result.
1321 6.8.8 memory.readsword(number address)
1323 Reads the specified address as signed word and returns the 
1324 result.
1326 6.8.9 memory.writeword(number address, number value)
1328 Writes the specified value (negative values undergo 2's 
1329 complement) to specified address (as a word).
1331 6.8.10 memory.readdword(number address)
1333 Reads the specified address as unsigned doubleword and returns 
1334 the result.
1336 6.8.11 memory.readsdword(number address)
1338 Reads the specified address as signed doubleword and returns the 
1339 result.
1341 6.8.12 memory.writedword(number address, number value)
1343 Writes the specified value (negative values undergo 2's 
1344 complement) to specified address (as a doubleword).
1346 6.8.13 memory.readqword(number address)
1348 Reads the specified address as unsigned quadword and returns the 
1349 result.
1351 6.8.14 memory.readsqword(number address)
1353 Reads the specified address as signed quadword and returns the 
1354 result.
1356 6.8.15 memory.writeqword(number address, number value)
1358 Writes the specified value (negative values undergo 2's 
1359 complement) to specified address (as a quadword).
1361 6.9 Table _SYSTEM
1363 Contains copy of global variables from time of Lua 
1364 initialization. Non-writeable.
1366 6.10 Callbacks
1368 Various callbacks to Lua that can occur.
1370 6.10.1 Callback: on_paint()
1372 Called when screen is being painted. Any gui.* calls requiring 
1373 graphic context draw on the screen.
1375 6.10.2 Callback: on_video()
1377 Called when video dump frame is being painted. Any gui.* calls 
1378 requiring graphic context draw on the video.
1380 6.10.3 Callback: on_frame()
1382 Called on each starting whole frame.
1384 6.10.4 Callback: on_startup()
1386 Called when the emulator is starting (lsnes.rc and --run files 
1387 has been run).
1389 6.10.5 Callback: on_pre_load(string name)
1391 Called just before savestate/movie load occurs (note: loads are 
1392 always delayed, so this occurs even when load was initiated by 
1393 lua).
1395 6.10.6 Callback: on_err_load(string name)
1397 Called if loadstate goes wrong.
1399 6.10.7 Callback: on_post_load(string name, boolean was_savestate)
1401 Called on successful loadstate. was_savestate gives if this was a 
1402 savestate or a movie.
1404 6.10.8 Callback: on_pre_save(string name, boolean is_savestate)
1406 Called just before savestate save occurs (note: movie saves are 
1407 synchronous and won't trigger these callbacks if called from 
1408 Lua).
1410 6.10.9 Callback: on_err_save(string name)
1412 Called if savestate goes wrong.
1414 6.10.10 Callback: on_post_save(string name, boolean is_savestate)
1416 Called on successful savaestate. is_savestate gives if this was a 
1417 savestate or a movie.
1419 6.10.11 Callback: on_quit()
1421 Called when emulator is shutting down.
1423 6.10.12 Callback: on_input(boolean subframe)
1425 Called when emulator is just sending input to bsnes core. 
1426 Warning: This is called even in readonly mode, but the results 
1427 are ignored.
1429 6.10.13 Callback: on_reset()
1431 Called when SNES is reset.
1433 6.10.14 Callback: on_readwrite()
1435 Called when moving into readwrite mode as result of “set-rwmode” 
1436 command (note: moving to rwmode by Lua won't trigger this, as per 
1437 recursive entry protection).
1439 6.10.15 Callback: on_snoop(number port, number controller, number 
1440   index, number value)
1442 Called each time bsnes asks for input. The value is the final 
1443 value to be sent to bsnes core (readonly mode, autohold and 
1444 autofire have been taken into account). Might be useful when 
1445 translating movies to format suitable for console verification. 
1446 Note: There is no way to modify the value to be sent.
1448 7 Modifier and key names:
1450 7.1 SDL Platform
1452 7.1.1 Modifier names
1454 Following modifier names are known:
1456 • ctrl, lctrl, rctrl: Control keys
1458 • alt, lalt, ralt: ALT keys.
1460 • shift, lshift, rshift: Shift keys.
1462 • meta, lmeta, rmeta: Meta keys.
1464 • num, caps: Numlock/Capslock (these are sticky!)
1466 • mode: Mode select.
1468 7.1.2 Key names
1470 Following key names are known:
1472 • backspace, tab, clear, return, pause, escape, space, exclaim, 
1473   quotedbl, hash, dollar, ampersand, quote, leftparen, 
1474   rightparen, asterisk, plus, comma, minus, period, slash, 0, 1, 
1475   2, 3, 4, 5, 6, 7, 8, 9, colon, semicolon, less, equals, 
1476   greater, question, at, leftbracket, backslash, rightbracket, 
1477   caret, underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, 
1478   l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, delete, world_0, 
1479   world_1, world_2, world_3, world_4, world_5, world_6, world_7, 
1480   world_8, world_9, world_10, world_11, world_12, world_13, 
1481   world_14, world_15, world_16, world_17, world_18, world_19, 
1482   world_20, world_21, world_22, world_23, world_24, world_25, 
1483   world_26, world_27, world_28, world_29, world_30, world_31, 
1484   world_32, world_33, world_34, world_35, world_36, world_37, 
1485   world_38, world_39, world_40, world_41, world_42, world_43, 
1486   world_44, world_45, world_46, world_47, world_48, world_49, 
1487   world_50, world_51, world_52, world_53, world_54, world_55, 
1488   world_56, world_57, world_58, world_59, world_60, world_61, 
1489   world_62, world_63, world_64, world_65, world_66, world_67, 
1490   world_68, world_69, world_70, world_71, world_72, world_73, 
1491   world_74, world_75, world_76, world_77, world_78, world_79, 
1492   world_80, world_81, world_82, world_83, world_84, world_85, 
1493   world_86, world_87, world_88, world_89, world_90, world_91, 
1494   world_92, world_93, world_94, world_95, kp0, kp1, kp2, kp3, 
1495   kp4, kp5, kp6, kp7, kp8, kp9, kp_period, kp_divide, 
1496   kp_multiply, kp_minus, kp_plus, kp_enter, kp_equals, up, down, 
1497   right, left, insert, home, end, pageup, pagedown, f1, f2, f3, 
1498   f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, numlock, 
1499   capslock, scrollock, rshift, lshift, rctrl, lctrl, ralt, lalt, 
1500   rmeta, lmeta, lsuper, rsuper, mode, compose, help, print, 
1501   sysreq, break, menu, power, euro, undo
1503 • Names of form 'key<n>' where <n> is 0-255 are interpretted as 
1504   key having hardware-dependent scan code of <n> (useful to bind 
1505   those keys that don't have symbolic names).
1507 In addition, following pseudo-keys are known (note: these do not 
1508 work in conjunction with modifers):
1510 • joystick<num>button<button>: Joystick <num> (0-based) button 
1511   <button> (0-based).
1513 • joystick<num>hat<hat>n: Joystick <num> (0-based) hat <hat> 
1514   (0-based) up.
1516 • joystick<num>hat<hat>w: Joystick <num> (0-based) hat <hat> 
1517   (0-based) left.
1519 • joystick<num>hat<hat>s: Joystick <num> (0-based) hat <hat> 
1520   (0-based) down.
1522 • joystick<num>hat<hat>e: Joystick <num> (0-based) hat <hat> 
1523   (0-based) right.
1525 • joystick<num>axis<axis>-: Joystick <num> (0-based) axis <axis> 
1526   negative position (axis modes axis and axis_inverse).
1528 • joystick<num>axis<axis>+: Joystick <num> (0-based) axis <axis> 
1529   positive position (axis modes axis and axis_inverse).
1531 • joystick<num>axis<axis>: Joystick <num> (0-based) axis <axis> 
1532   pressure (axis modes pressure_*).
1534 7.1.3 Special buttons:
1536 • Escape: Enter/Exit Command mode, cancel modal dialogs.
1538 • Return (also KPEnter): Execute command, ok modal dialog.
1540 • Pgup/Up (also KP8/9 if no num lock; command mode): Previous 
1541   command in command history
1543 • Pgdn/Down(also KP2/3 if no num lock; command mode): Next 
1544   command in command history
1546 • Home (also KP7 if no num lock; command mode): Beginning of 
1547   command.
1549 • End (also KP1 if no num lock; command mode): End of command.
1551 • Left (also KP4 if no num lock; command mode): Move cursor left.
1553 • Right (also KP6 if no num lock; command mode): Move cursor 
1554   right.
1556 • Delete (also KP. if no num lock; command mode): Delete 
1557   character to right of cursor.
1559 • Insert (also KP0 if no num lock; command mode): Toggle between 
1560   insert / overwrite modes.
1562 • Backspace (command mode): Delete character to left of cursor.
1564 • LCTRL+LALT+ESCAPE: Ungraceful shutdown (leaves dump 
1565   corrupted!).
1567 7.1.4 Watchdog timer:
1569 If emulator does not reach internal polling loop in 15 seconds 
1570 after leaving it or 15 seconds after starting, the emulator 
1571 instantly bombs out.
1573 8 Movie file format
1575 Movie file is .zip archive in itself, normal ZIP archive tools 
1576 work on it (note: If you recompress it, do not use compression 
1577 methods other than store and deflate and especially do not use 
1578 encryption of any kind).
1580 8.1 Detecting clean start/SRAM/Savestate
1582 • If file has member “savestate” it is savestate, otherwise:
1584 • If file has members with names starting “moviesram.” it is 
1585   movie starting from SRAM, otherwise:
1587 • It is movie starting from clear state.
1589 8.2 Member: gametype
1591 Type of game ROM and region (as one line). Valid values are:
1594 +--------------+---------------------+--------+
1595 |    Value     |       System        | Region |
1596 +--------------+---------------------+--------+
1597 +--------------+---------------------+--------+
1598 |  snes_pal    |     Super NES       |  PAL   |
1599 +--------------+---------------------+--------+
1600 |   sgb_pal    |   Super Game Boy    |  PAL   |
1601 +--------------+---------------------+--------+
1602 |  snes_ntsc   |     Super NES       |  NTSC  |
1603 +--------------+---------------------+--------+
1604 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
1605 +--------------+---------------------+--------+
1606 |     bsx      | BS-X (non-slotted)  |  NTSC  |
1607 +--------------+---------------------+--------+
1608 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
1609 +--------------+---------------------+--------+
1610 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
1611 +--------------+---------------------+--------+
1614 Frame rates are:
1617 +---------+-----------------+
1618 | Region  | Framerate (fps) |
1619 +---------+-----------------+
1620 +---------+-----------------+
1621 |  PAL    |   322445/6448   |
1622 +---------+-----------------+
1623 |  NTSC   | 10738636/178683 |
1624 +---------+-----------------+
1627 8.3 Member: port1
1629 Contains type of port #1 (as one line). Valid values are 'none', 
1630 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
1631 'gamepad'.
1633 8.4 Member: port2
1635 Contains type of port #2 (as one line). Valid values are 'none', 
1636 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
1637 'justifiers'. If not present, defaults to 'none'.
1639 8.5 Member: gamename
1641 Contains name of the game (as one line).
1643 8.6 Member: authors
1645 Contains authors, one per line. Part before '|' is the full name, 
1646 part after is the nickname.
1648 8.7 Member: systemid
1650 Always “lsnes-rr1” (one line). Used to reject other saves.
1652 8.8 Member: controlsversion
1654 Always “0” (one line). Used to identify what controls are there.
1656 8.9 Member: “coreversion”
1658 Contains bsnes core version number (as one line).
1660 8.10 Member: projectid
1662 Contains project ID (as one line). Used to identify if two movies 
1663 are part of the same project.
1665 8.11 Member: {rom,slota,slotb}{,xml}.sha256
1667 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
1668 Absent if corresponding file is absent.
1670 8.12 Member: moviesram.<name>
1672 Raw binary startup SRAM of kind <name>. Only present in 
1673 savestates and movies starting from SRAM.
1675 8.13 Member: saveframe
1677 Contains frame number (as one line) of frame movie was saved on. 
1678 Only present in savestates.
1680 8.14 Member: lagcounter
1682 Current value of lag counter (as one line). Only present in 
1683 savestates.
1685 8.15 Member: pollcounters
1687 Contains poll counters (currently 100 of them), one per line. 
1688 Each line is raw poll count if DRDY is set for it. Otherwise it 
1689 is negative poll count minus one. Only present in savestates.
1691 8.16 Member: hostmemory
1693 Raw binary dump of host memory. Only present in savestates.
1695 8.17 Member: savestate
1697 The raw binary savestate itself. Savestate detection uses this 
1698 file, only present in savestates.
1700 8.18 Member: screenshot
1702 Screenshot of current frame. Only present in savestates. First 2 
1703 bytes are big-endian width of image, rest are 24-bit RGB image 
1704 data. Height of image is inferred from the width and size of 
1705 data.
1707 8.19 Member: sram.<name>
1709 Raw binary SRAM of kind <name> at time of savestate. Only present 
1710 in savestates.
1712 8.20 Member: input
1714 The actual input track, one line per subframe (blank lines are 
1715 skipped).
1717 • If the first byte of each line is '.', ' ', <tab> or '|', then 
1718   the line is part of same frame as previous, otherwise it starts 
1719   a new frame.
1721 • First subframe must start a new frame.
1723 Length of movie in frames is number of lines in input file that 
1724 start a new frame.
1726 8.21 Member: rerecords
1728 Contains textual base-10 rerecord count (as one line; emulator 
1729 just writes this, it doesn't read it) + 1.
1731 8.22 Member: rrdata
1733 This member stores set of load IDs. There is one load ID per 
1734 rerecord (plus one corresponding to start of project).
1736 • This member constists of concatenation of records
1738 • Each record is 2-36 bytes long and can represent 1-16,843,009 
1739   consequtive IDs.
1741 • IDs are interpretted as 256-bit big-endian integers with 
1742   warparound.
1744 • Initial predicted ID is all zeroes.
1746 Format of each record is:
1748 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
1749   bits 5-6 are count length (countlen). Bit 7 is unused.
1751 • 32-prefixlen bytes of ID.
1753 • countlen bytes of big-endian count (count).
1755 Records are processed as follows:
1757 • To form the first ID encoded by record, take the first 
1758   prefixlen bytes predicted ID and append the read ID value to 
1759   it. The result is the first ID encoded.
1761 • If countlen is 0, record encodes 1 ID.
1763 • If countlen is 1, record encodes 2+count IDs.
1765 • If countlen is 2, record encodes 258+count IDs.
1767 • If countlen is 3, record encodes 65794+count IDs.
1769 • The new predicted ID is the next ID after last one encoded by 
1770   the record.
1772 The number of rerecords + 1 is equal to the sum of number of IDs 
1773 encoded by all records.
1775 8.23 Member: starttime.second
1777 Movie starting time, second part. Epoch is Unix epoch. Default is 
1778 1,000,000,000.
1780 8.24 Member: starttime.subsecond
1782 Movie starting time, subsecond part. Unit is CPU clocks. Default 
1783 is 0.
1785 8.25 Member: savetime.second
1787 Movie saving time, second part. Default is starttime.second. Only 
1788 present in savestates.
1790 8.26 Member: savetime.subsecond
1792 Movie saving time, subsecond part. Default is 
1793 starttime.subsecond. Only present in savestates.
1795 9 Compiling:
1797 9.1 Building BSNES
1799 make ui=ui-libsnes profile=accuracy
1801 For Bsnes v084 You need to apply the six patches in 
1802 bsnes-patches/. These fix the following:
1804 1. Make libsnes actually compile (it won't compile without!)
1806 2. Bump the version number to be correct (nice to have)
1808 3. Make RTC emulation time cleanly overridable (needed by games 
1809   using RTC)
1811 4. Save/Load controller state on savestate/loadstate (many games 
1812   screw up without)
1814 5. Fix unserialization of 64-bit integers (needed)
1816 6. Allow frontend to control random number seed (just nice to 
1817   have)
1819 9.2 Prerequisite libraries:
1821 • zlib
1823 • SDL (SDL platform)
1825 • SDLmain (Windows/Mac OS X only; Note you may have to extract 
1826   the object out of archive)
1828 • boost_iostreams
1830 • boost_filesystem
1832 • boost conversion (header only)
1834 9.3 Compile options to make:
1836 9.3.1 BSNES_PATH=<path>
1838 Set path to BSNES bsnes directory to <path>.
1840 9.3.2 THREADS=NO
1842 Don't use threads on Linux.
1844 9.3.3 THREADS=YES
1846 Try to use threads even on non-Linux systems.
1848 9.3.4 CROSS_PREFIX=<prefix>
1850 Prepend this to all commands refering to cross-compiling 
1851 environment with this.
1853 9.3.5 CC=<compiler>
1855 Target C++ compiler to use. Defaults to g++
1857 Note: If crosscompiling, this has to be crosscompiler, and 
1858 CROSS_PREFIX is prepended.
1860 9.3.6 BSNES_IS_COMPAT=1
1862 Assume BSNES uses compatiblity core instead of accuracy core.
1864 9.3.7 LUA=<package>
1866 Compile lua support, using package <package>
1868 9.3.8 GRAPHICS=<plat>
1870 Set graphics platform. Currently available choices are “SDL” and “
1871 WXWIDGETS”.
1873 9.3.9 SOUND=<plat>
1875 Set sound platform. Currently available choices are “SDL” 
1876 (requires SDL graphics), “PORTAUDIO” and “DUMMY”.
1878 9.3.10 JOYSTICK=<plat>
1880 Set joystick platform. Currently available choices are “SDL” 
1881 (requires SDL graphics), “EVDEV” and “DUMMY”.
1883 10 Quick'n'dirty encode guide
1885 1. Start the emulator and load the movie file.
1887 2. Set large AVI option 'set-setting avi-large on'
1889 3. Enable dumping 'dump-avi 12 tmpdump' (note: Normally 10 and 
1890   above are “use only if you know what you are doing.”. In this 
1891   case, these can be safely used because of how x264 internally 
1892   works).
1894 4. Unpause and let it run until you want to end dumping.
1896 5. Close the emulator (closing the window is the easiest way). Or 
1897   use 'end-avi'.
1899 6. For each tmpdump*.avi file created, on command prompt, do 
1900   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
1902 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
1904 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
1905   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
1906   tmpdump_<numbers>.mkv, with + in between).
1908 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
1909   final.mkv contains quick'n'dirty encode.
1911 11 Axis configurations for some gamepad types:
1913 11.1 XBox360 controller:
1915 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
1916 set to pressure-+.
1918 set-axis joystick0axis2 pressure-+
1920 set-axis joystick0axis5 pressure-+
1922 11.2 PS3 “sixaxis” controller:
1924 Axes 8-19 should be disabled.
1926 set-axis joystick0axis8 disabled
1928 set-axis joystick0axis9 disabled
1930 set-axis joystick0axis10 disabled
1932 set-axis joystick0axis11 disabled
1934 set-axis joystick0axis12 disabled
1936 set-axis joystick0axis13 disabled
1938 set-axis joystick0axis14 disabled
1940 set-axis joystick0axis15 disabled
1942 set-axis joystick0axis16 disabled
1944 set-axis joystick0axis17 disabled
1946 set-axis joystick0axis18 disabled
1948 set-axis joystick0axis19 disabled
1950 12 Errata:
1952 12.1 Problems from BSNES core:
1954 • The whole pending save stuff.
1956 • Lack of layer hiding.
1958 • It is slow.
1960 • Firmwares can't be loaded from ZIP archives.
1962 12.2 Other problems:
1964 • Modifiers don't work with pseudo-keys (SDL, EVDEV).
1966 • Audio for last dumped frame is not itself dumped.
1968 • Audio in UI is pretty bad in quality.
1970 • UI itself is 30fps max (SDL).
1972 • AVI compression levels 10-18 are not compatible with AVISynth 
1973   AVISource.
1975 • No menus, command based interface (SDL).
1977 • Long commands don't scroll.
1979 • The SDL screen drawing is slow.
1981 • Wxwidgets UI slows down with time.
1983 • Movies use way too much (like at least 10x what would be 
1984   needed) memory.
1986 13 Changelog:
1988 13.1 rr0-beta1
1990 • Fix -Wall warnings
1992 • Fix dumper video corruption with levels 10-18.
1994 13.2 rr0-beta2
1996 • Autofire
1998 • Lots of code cleanups
2000 • Lua interface to settings
2002 • Allow specifying AVI borders without Lua
2004 • Fix scaling if vscale > 1 and originx > 0 (left border exists)
2006 • on_snoop lua callback
2008 • Faster movie loading and saving.
2010 13.3 rr0-beta3
2012 • Joystick support
2014 13.4 rr0-beta4
2016 • Fix multi-buttons
2018 • Save jukebox functionality.
2020 13.5 rr0-beta5
2022 • Try to fix some nasty failing movie load edge cases
2024 • Allow specifying scripts to run on command line.
2026 13.6 rr0-beta6
2028 • Major source code reorganization.
2030 • Backup savestates before overwriting.
2032 • Don't crash if loading initial state fails.
2034 13.7 rr0-beta7
2036 • Fix firmware lookup
2038 • Fix author name parsing
2040 • Fix rerecord counting
2042 • (SDL) Print messages to console if SDL is uninitialized
2044 • Add movieinfo program
2046 • Fix loading movies starting from SRAM.
2048 13.8 rr0-beta8
2050 • Add support for unattended dumping
2052 • Fix compiling for Win32
2054 • Don't lock up if sound can't be initialized
2056 • Strip trailing CR from commands
2058 • Don't try to do dubious things in global ctors (fix crash on 
2059   startup)
2061 13.9 rr0-beta9
2063 • Small documentation tweaking
2065 • Fix make clean
2067 • Fix major bug in modifier matching
2069 13.10 rr0-beta10
2071 • Lots of documentation fixes
2073 • Use dedicated callbacks for event backcomm., not commands.
2075 • Ensure that the watchdog is not hit when executing delayed 
2076   reset.
2078 • Remove errant tab from joystick message.
2080 13.11 rr0-beta11
2082 • Make autofire operate in absolute time, not linear time
2084 • Reinitialize controls when resuming from loadstate
2086 • Some more code cleanups
2088 • If Lua allocator fails, call OOM_panic()
2090 • Byte/word/dword/qword sized host memory write/read functions.
2092 • Dump at correct framerate if dumping interlaced NTSC 
2093   (height=448).
2095 13.12 rr0-beta12
2097 • Actually include the complete source code
2099 • Keep track of RTC
2101 13.13 rr0-beta13
2103 • Document {save,start}time.{,sub}second.
2105 • Intercept time() from bsnes core.
2107 13.14 rr0-beta14
2109 • Allow disabling time() interception (allow build on Mac OS X)
2111 • Use SDLMain on Mac OS X (make SDL not crash)
2113 • Disable delayed resets (just plain too buggy for now).
2115 • Code cleanups
2117 • Use 16-bit for graphics/video instead of 32-bit.
2119 • gui.rectangle/gui.pixel
2121 • gui.crosshair
2123 • New CSCD writer implementation.
2125 13.15 rr0-beta15
2127 • Fix interaction of * and +.
2129 • Manual improvements
2131 • Use gettimeofday()/usleep(), these seem portable enough.
2133 • Move joystick axis manipulation to keymapper code.
2135 • Changes to how read-only works.
2137 • Refactor controller input code.
2139 13.16 rr0-beta16
2141 • Fix mouseclick scale compensation.
2143 • Draw area boundaries correctly in SDL code.
2145 • gui.screenshot.
2147 • Fix CSCD output (buffer overrun and race condition).
2149 13.17 rr0-beta17
2151 • JMD dumping support.
2153 • Allow unattended dumping to JMD.
2155 • Move to BSNES v083.
2157 • Switch back to 32-bit colors.
2159 • Add Lua function gui.color.
2161 • Use some new C++11 features in GCC 4.6.
2163 • Be prepared for core frequency changes.
2165 • Pass colors in one chunk from Lua.
2167 13.18 rr0-beta18
2169 • New lua functions gui.line(), gui.status() and gui.circle(), 
2170   memory.vma_count(), memory.read_vma() and memory.find_vma().
2172 • Numerious documentation fixups
2174 • RTC time format changed
2176 • Reformat flags display
2178 • Allow lua package name to be overridden
2180 • SDUMP (high-quality dumping).
2182 • Split platform support to plugins.
2184 • Make all sound plugins support basic sound commands
2186 • Support portaudio for sound.
2188 • Allow disable Lua/SDL searching.
2190 • Upconvert colors when copying lcscreen to screen.
2192 • Reorganize source tree.
2194 • Evdev joystick support.
2196 • Refactor more code into generic window code.
2198 13.19 rr0-beta19
2200 • Refactor message handling.
2202 • Rework makefile
2204 • Documentation fixes
2206 • Finish pending saves before load/quit.
2208 • Wxwidgets graphics plugin.
2210 13.20 rr0-beta20
2212 • Get rid of win32-crap.[ch]pp.
2214 • Move files around a lot.
2216 • Get rid of need for host C++ compiler.
2218 • Bsnes v084 core.
2220 • Refactor inter-component communication.
2222 • Fix zero luma.
2224 • Fix crash on multiline aliases.
2226 • Load/Save settings in wxwidgets gui.
2228 13.21 rr0-beta21
2230 • Patch problems in bsnes core
2232 • SNES is little-endian, not big-endian!
2234 • Fix memory corruption in lcscreen::load()
2236 13.22 rr0-beta22
2238 • Fix interpretting repeat counts in rrdata loading.
2240 • New lua callback: on_frame()
2242 • Remove calls to runtosave() that aren't supposed to be there
2244 • Lua function: movie.read_rtc()
2246 • Ignore src/fonts/font.cpp
2248 • Fix more bsnes core problems
2250 • Control bsnes random seeding
2252 • Pause-on-end
2254 • Some bsnes core debugging features (state dump and state hash)
2256 • Fix titlebar version number (no, the last version wasn't 
2257   'lsnes-0-beta21', it was 'lsnes rr0-beta21').
2259 13.23 rr0-beta23
2261 • Fix memory corruption due to macro/field mixup
2263 • search-memory update
2265 • Allow direct-mapped framebuffer
2267 • SDL: Use SDL_ANYFORMAT if possible
2269 • SDMP2SOX: 2s delay modes.
2271 • Wxwidgets: Cleanups
2273 • Use sed -E, not sed -r. Fixes building on Mac OS X.
2275 • Wxwidgets: Save jukebox on exit
2277 • Fix RTC if using load-movie on savestate.
2279 • Fix crash related to full console mode.
2281 13.24 rr0-beta24
2283 • Wxwidgets: Allow bringing application to foreground on Mac OS 
2284   X.
2286 • Wxwidgets: Allow compiling on Mac OS X.
2288 • Use movie compare instead of movie hashing (faster save/load).
2290 • Lua: _SYSTEM table.
2292 13.25 rr0-beta25
2294 • sdmp2sox: Pad soundtrack if using -l or -L.
2296 • sdmp2sox: Fix NTSC overscan.
2298 • sdmp2sox: Add AR correction mode.
2300 • call lua_close() when exiting.
2302 • Fix zip_writer bug causing warnings from info-zip and error 
2303   from advzip.
2305 13.26 rr0-beta26
2307 • Fix IPS patching code (use bsnes core IPS patcher).
2309 • Implement BPS patching (using bsnes core IPS patcher).
2311 • Add feature to load headered ROMs.
2313 13.27 rr0-beta27
2315 • Show command names when showing keybindings
2317 13.28 rr0
2319 • Fix pause-on-end to be actually controllable
2321 • SDL: Poll all events in queue, not just first one (fixes 
2322   slowness in command typing)
2324 • Wxwidgets: Fix ROM loading.