Merge branch 'rr1-maint'
[lsnes.git] / manual.txt
blob3f8cfd796660e7c4099a2764a39f68848b78220d
1 1 Introduction
3 lsnes is SNES rerecording emulator based on bsnes core.
5 2 Dependencies
7 1. bsnes libsnes
9   (a) v084 or 085
11   (b) accuracy or compatiblity core.
13   (c) Patched version (using included 6 patches)
15 2. Zlib
17 3. boost_iostreams
19 4. boost_filesystem
21 5. boost_thread
23 6. libsdl (SDL only)
25 7. sdlmain (SDL only, part of SDL)
27 8. boost_conversion (this is header-only library)
29 9. libswscale (wxwidgets graphics only)
31 10. Portaudio (portaudio sound only)
33 11. std::thread and co (for threaded dumper only, not needed if 
34   std::thread is available)
36 12. Lua (if Lua support is needed).
38 • Version 5.1.X or 5.2X.
40 3 Building
42 Building is via makefile, the following options are available:
44 • CROSS_PREFIX=<prefix>
46   – Prefix to apply to commands when building executables / 
47     object files for the target architecture. 
49   – Default is blank.
51 • CC=<name>
53   – Name of C++ compiler.
55   – CROSS_PREFIX is prepended if compiling for target 
56     architecture.
58   – This needs to be at least GCC 4.6.
60   – Set to 'g++-mp-4.6' if compiling on Mac OS X using GCC 4.6 
61     from Macports.
63   – Default is 'g++'.
65 • HOSTCC=<name>
67   – Name of host C++ compiler.
69   – Default is value of 'CC' option.
71 • USER_HOSTCCFLAGS=<flags>:
73   – Compiler flags to pass when compiling/linking for host 
74     architecture.
76   – Default is blank.
78 • USER_CFLAGS=<flags>
80   – Extra flags to pass when compiling for target architecture
82   – Default is blank.
84 • USER_LDFLAGS=<flags>: 
86   – Extra flags to pass when linking for target architecture.
88   – Default is blank.
90 • USER_PLATFORM_CFLAGS=<flags>
92   – Extra flags to pass when compiling files using 
93     platform-dependent code for target architecture.
95   – Default is blank.
97 • USER_PLATFORM_LDFLAGS=<flags>
99   – Extra flags to pass when linking files using 
100     platform-dependent code for target architecture.
102   – Default is blank.
104 • FONT_SRC=<file>
106   – Set the font file to use.
108   – Currently the valid values are:
110     ∗ cp437.hex: Standard VGA font (256 characters).
112     ∗ unifontfull-5.1.20080820.hex: GNU unifont (covers most of 
113       Unicode BMP)
115   – Default is 'unifontfull-5.1.20080820.hex'
117 • LUA=<package>
119   – Package to use for Lua support.
121   – Usually valid value is 'lua' or 'lua5.1'.
123   – Default is not to build Lua support.
125 • THREADS=<value>
127   – Override platform default for dumper threading support.
129   – Threading is default on Linux.
131   – 'YES' tries to use threading (std::thread).
133   – 'BOOST' tries to use threading (boost::thread).
135   – 'NO' disables threading.
137   – Note: This has absolutely nothing to do with platform 
138     threading.
140 • BSNES_IS_COMPAT=<anything>
142   – Signals that BSNES core used is compatiblity core, not 
143     accuracy core.
145   – Default is to assume accuracy core.
147 • JOYSTICK=<implementation>
149   – Set joystick implementation. Valid values are:
151     ∗ SDL: Use SDL for joystick (requires SDL graphics)
153     ∗ EVDEV: Use EVDEV for joystick (Linux only).
155     ∗ DUMMY: Disable joystick support.
157   – Default is SDL.
159 • SOUND=<implementation>
161   – Set sound implementation. Valid values are:
163     ∗ SDL: Use SDL for sound (requires SDL graphics)
165     ∗ PORTAUDIO: Use Portaudio for sound.
167     ∗ DUMMY: Disable sound support
169   – Default is SDL.
171 • GRAPHICS=<implementation>
173   – Set windowing library to use. Valid values are:
175     ∗ SDL: Use SDL for graphics
177     ∗ WXWIDGETS: Use wxWidgets for graphics.
179   – Default is SDL.
181 4 Command line options
183 4.1 ROM options
185 <kind> in the following can be one of:
187 • rom: Cartridge ROM (BIOS for special carts). This is required.
189 • bsx: BS-X (non-slotted) Game flash ROM.
191 • bsxslotted: BS-X (slotted) Game flash ROM.
193 • dmg: DMG game ROM
195 • slot-a: Sufami Turbo Slot A ROM
197 • slot-b: Sufami Turbo Slot B ROM
199 4.1.1 --<kind>=<file> (lsnes/SDL, lsnes-avidump)
201 Load <file> as specified ROM (SFC/BS/DMG/ST file format).
203 4.1.2 --<kind>-xml=<file> (lsnes/SDL, lsnes-avidump)
205 Override hardware detection for ROM, reading the values from 
206 <file> (BSNES XML format).
208 4.1.3 --ips-<kind>=<file> (lsnes/SDL, lsnes-avidump)
210 Apply BPS/IPS patch <file> to ROM <kind>. If specified multiple 
211 times, the patches are applied in order.
213 4.1.4 --ips-<kind>-xml=<file> (lsnes/SDL, lsnes-avidump)
215 Apply BPS/IPS patch <file> to XML of ROM <kind>. If specified 
216 multiple times, the patches are applied in order.
218 4.1.5 --ips-offset=<offset> (lsnes/SDL, lsnes-avidump)
220 Set offset to apply to IPS patches. May be negative. Handy for 
221 applying headered IPS patches (use offset of -512 for this). The 
222 offset must be 0 for BPS patches.
224 4.1.6 --pal
226 Force ROM to be considered PAL-only.
228 • Only works on SNES and SGB ROMs (not BS-X or Sufami Turbo).
230 • Attempting to load NTSC movie file will error out.
232 4.1.7 --ntsc
234 Force ROM to be considered NTSC-only.
236 • Attempting to load PAL movie file will error out.
238 4.2 Session options
240 4.2.1 <filename> (lsnes/SDL, lsnes-avidump, movieinfo)
242 Load <filename> as movie or savestate file. All other session 
243 options are ignored.
245 4.2.2 --port1=<device> (lsnes/SDL)
247 Set type of port1. Valid values are:
249 • none: No device connected
251 • gamepad: One gamepad (the default)
253 • multitap: Four gamepads (warning: makes most games refuse to 
254   start)
256 • mouse: Mouse.
258 4.2.3 --port2=<type> (lsnes/SDL)
260 Set type of port2. Valid values are:
262 • none: No device connected (the default)
264 • gamepad: One gamepad
266 • multitap: Four gamepads.
268 • mouse: Mouse
270 • superscope: Super Scope
272 • justifier: One justifier
274 • justifiers: Two justifiers
276 4.2.4 --gamename=<name> (lsnes/SDL)
278 Set the name of game to <name>. Default is blank.
280 4.2.5 --author=<name> (lsnes/SDL)
282 Add author with full name of <name> (no nickname).
284 4.2.6 --author=|<name> (lsnes/SDL)
286 Add author with nickname of <name> (no full name).
288 4.2.7 --author=<fullname>|<nickname> (lsnes/SDL)
290 Add author with full name of <fullname> and nickname of 
291 <nickname>.
293 4.2.8 --rtc-second=<value> (lsnes/SDL)
295 Set RTC second (0 is 1st January 1970 00:00:00Z). Default is 
296 1,000,000,000.
298 4.2.9 --rtc-subsecond=<value> (lsnes/SDL)
300 Set RTC subsecond. Range is 0-. Unit is CPU cycle. Default is 0.
302 4.3 Misc. options:
304 4.3.1 --run=<file> (lsnes/SDL)
306 After running main RC file, run this file. If multiple are 
307 specified, these execute in order specified.
309 4.4 dump options (lsnes-dumpavi only)
311 4.4.1 --dumper=<dumper>
313 Set the dumper to use (required). Use 'list' for listing of known 
314 dumpers.
316 4.4.2 --mode=<mode>
318 Set the mode to use (required for dumpers with multiple modes, 
319 forbidden otherwise). Use 'list' for known modes.
321 4.4.3 --prefix=<prefix>
323 Set dump prefix. Default is “avidump”.
325 4.4.4 --option=<name>=<value>
327 Set option <name> to value <value>.
329 4.4.5 --length=<length>
331 Set number of frames to dump. Mandatory.
333 4.4.6 --lua=<script>
335 Run specified lua script (lsnes-dumpavi does not have 
336 initialization files).
338 4.4.7 --load-library=<library>
340 Load the specified shared object / dynamic library / dynamic link 
341 library.
343 5 Startup file lsnes.rc
345 Upon startup, lsnes (lsnes/SDL only) executes file lsnes.rc as 
346 commands. This file is located in:
348 • Windows: %APPDATA%\lsnes\lsnes.rc (if %APPDATA% exists)
350 • Unix: $XDG_CONFIG_HOME/lsnes/lsnes.rc (if $XDG_CONFIG_HOME 
351   exists)
353 • Unix: $HOME/.config/lsnes/lsnes.rc (if $HOME exists)
355 • All: ./lsnes.rc (fallback default).
357 If leading directories do not exist, attempt to create them is 
358 made.
360 6 Internal commands
362 • Commands beginning with '*' invoke the corresponding command 
363   without alias expansion.
365 • If command starts with '+' (after possible '*'), the command is 
366   executed as-is when button is pressed, and when button is 
367   released, it is executed with '+' replaced by '-'.
369 • Commands without '+' execute only on negative edge (release).
371 6.1 Settings:
373 Settings control various aspects of emulator behaviour.
375 6.1.1 set-setting <setting> <value>
377 Sets setting <setting> to value <value> (may be empty).
379 6.1.2 unset-setting <setting>
381 Try to unset setting <setting> (not all settings can be unset).
383 6.1.3 get-setting <setting>
385 Read value of setting <setting>
387 6.1.4 show-settings
389 Print names and values of all settings.
391 6.2 Keybindings
393 Keybindings bind commands or aliases to keys (or pseudo-keys). 
395 Notes:
397 • Do not bind edge active (+/-) commands to keys with modifiers, 
398   that won't work right!
400 • Names of keys and modifiers are platform-dependent.
402 • Be careful before binding pseudo-keys (such as joystick axes, 
403   buttons or hats) with modifiers. That may or may not work 
404   right.
406 6.2.1 bind-key [<mod>/<modmask>] <key> <command>
408 Bind <command> to key <key> (activating if modifiers in <modmask> 
409 (comma-seperated list) are set as <mod> (comma-seperated list).
411 The names of keys and modifiers are platform-dependent.
413 6.2.2 unbind-key [<mod>/<modmask>] <key>
415 Unbind command from <key> (with specified <mod> and <modmask>).
417 6.2.3 set-axis <axis> [disabled | axis | axis-inverse | 
418   pressure0- | pressure0+ | pressure-0 | pressure-+ | pressure+0 
419   | pressure+-] [minus=<val>] [zero=<val>] [plus=<val>] 
420   [tolerance=<val>]
422 Set axis parameters for axis <axis>.
424 • disabled: Disable axis
426 • axis: Normal axis
428 • axis-inverse: Inverse axis
430 • pressure0-: Pressure sensitive. Released at 0, pressed at -.
432 • pressure0+: Pressure sensitive. Released at 0, pressed at +.
434 • pressure-0: Pressure sensitive. Released at -, pressed at 0.
436 • pressure-+: Pressure sensitive. Released at -, pressed at +.
438 • pressure+0: Pressure sensitive. Released at +, pressed at 0.
440 • pressure+-: Pressure sensitive. Released at +, pressed at -.
442 • minus=<val>: Calibration at extreme minus position 
443   (-32768-32767)
445 • zero=<val>: Calibration at neutral position (-32768-32767)
447 • plus=<val>: Calibration at extreme plus position (-32768-32767)
449 • tolerance=<value>: Center band tolerance (0<x<1). The smaller 
450   the value, the more sensitive the control is.
452 6.2.4 show-bindings
454 Print all key bindings in effect.
456 6.3 Aliases
458 Aliases bind command to sequence of commands. After alias has 
459 been defined, it replaces the command it shadows.
461 Notes:
463 • You can't alias command to itself.
465 • Aliases starting with +/- are edge active just like ordinary 
466   commands starting with +/-.
468 • One command can be aliased to multiple commands.
470 6.3.1 alias-command <command> <expansion>
472 Append <expansion> to alias <command>. If alias does not already 
473 exist, it is created.
475 6.3.2 unalias-command <command>
477 Clear alias expansion for <command>.
479 6.3.3 show-aliases
481 Print all aliases and their expansions in effect.
483 6.4 run-script <script>
485 Run <script> as if commands were entered on the command line.
487 6.5 Video dumping
489 Following commands control video dumping:
491 6.5.1 start-dump <dumper> [<mode>] <prefix/filename>
493 Start dumping using dumper <dumper>. If mode is present or not 
494 and if prefix or filename is present depends on the dumper and 
495 dumper mode.
497 The following dumpers are available:
499 • INTERNAL-AVI-CSCD: Internal CSCD in .avi dumper.
501   – Mode: uncompressed/pcm: Uncompressed video, PCM audio. Takes 
502     prefix.
504   – Mode: cscd/pcm: CSCD video, PCM audio. Takes prefix.
506 • INTERNAL-JMD: Internal .jmd dumper.
508   – Does not take mode.
510   – Takes a filename.
512 • INTERNAL-RAW: Internal RAW dumper.
514   – Does not take mode.
516   – Takes a prefix.
518   – Sound is big-endian signed 16-bit, usually at 32040.5Hz.
520   – Video is always upscaled to double resolution (512x448 / 512 
521     x 478).
523   – Video framerate is usually 322445/6448 fps for PAL and 
524     10738636/178683 fps for NTSC.
526 • INTERNAL-SDMP: Internal SDMP dumper.
528   – Mode 'ms': Multi-segment. Takes prefix.
530   – Mode 'ss': Single-segment. Takes filename.
532 6.5.2 end-dump <dumper>
534 End dumping using <dumper>
536 6.5.3 show-dumpers [<dumper>]
538 Show the list of dumpers or list of modes for <dumper>
540 6.6 Memory manipulation
542 <address> may be decimal or hexadecimal (prefixed with '0x'). 
543 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
544 signed (prefixed with '-') decimal.
546 The available element <sizes> are:
548 • byte: 1 byte
550 • word: 2 bytes
552 • dword: 4 bytes
554 • qword: 8 bytes
556 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
557 When dealing with DSP memory, multi-byte reads/writes are 
558 native-endian (do not use operand sizes exceeding DSP bitness, 
559 except dword is OK for 24-bit memory).
561 6.6.1 read-<size> <address>
563 Read the value of byte in <address>.
565 6.6.2 read-s<size> <address>
567 Read the value of signed byte in <address>.
569 6.6.3 write-<size> <address> <value>
571 Write <value> to byte in address <address>.
573 6.6.4 search-memory reset
575 Reset the memory search
577 6.6.5 search-memory count
579 Print number of candidates remaining
581 6.6.6 search-memory print
583 Print all candidates remaining
585 6.6.7 search-memory <usflag><sizeflag><op>
587 Searches memory for addresses satisfying criteria.
589 <usflag> can be:
591 • u: unsigned
593 • s: signed
595 <sizeflag> can be:
597 • b: byte
599 • w: word
601 • d: dword
603 • q: qword
605 <op> can be:
607 • lt: < previous value.
609 • le: <= previous value.
611 • eq: = previous value.
613 • ne: != previous value.
615 • ge: >= previous value.
617 • gt: > previous value.
619 6.6.8 search-memory <sizeflag> <value>
621 Searches for addresses that currently have value <value>. 
622 <sizeflag> is as in previous command.
624 6.7 Main commands
626 These commands are not available in lsnesrc, but are available 
627 after ROM has been loaded.
629 6.7.1 quit-emulator [/y]
631 Quits the emulator (asking for confirmation). If /y is given, no 
632 confirmation is asked.
634 6.7.2 pause-emulator
636 Toggle paused/unpaused
638 6.7.3 +advance-frame 
640 Advance frame. If the button is still held after configurable 
641 timeout expires, game unpauses for the duration frame advance is 
642 held.
644 6.7.4 +advance-poll 
646 Advance subframe. If the button is still held after configurable 
647 timeout expires, game unpauses for the duration frame advance is 
648 held.
650 6.7.5 advance-skiplag 
652 Skip to first poll in frame after current.
654 6.7.6 reset 
656 Reset the SNES after this frame.
658 6.7.7 load <filename> 
660 Load savestate <filename> in current mode.
662 6.7.8 load-state <filename> 
664 Load savestate <filename> in readwrite mode.
666 6.7.9 load-readonly <filename> 
668 Load savestate <filename> in readonly mode.
670 6.7.10 load-preserve <filename> 
672 Load savestate <filename> in readonly mode, preserving current 
673 events.
675 6.7.11 load-movie <filename> 
677 Load savestate <filename>, ignoring save part in readonly mode.
679 6.7.12 save-state <filename> 
681 Save system state to <filename> as soon as possible.
683 6.7.13 save-movie <filename> 
685 Save movie to <filename>.
687 6.7.14 set-rwmode 
689 Set read-write mode.
691 6.7.15 set-romode 
693 Set read-only mode
695 6.7.16 toggle-rwmode 
697 Toggle between read-only and read-write modes.
699 6.7.17 set-gamename <name> 
701 Set name of the game to <name>
703 6.7.18 get-gamename 
705 Print the name of the game.
707 6.7.19 add-author <author> 
709 Adds new author <author>. If <author> does not contain '|' it is 
710 full name. If it contains '|', '|' splits the full name and 
711 nickname.
713 6.7.20 edit-author <num> <author> 
715 Edit the author in slot <num> (0-based) to be <author> (see 
716 add-author for format)
718 6.7.21 remove-author <num> 
720 Remove author in slot <num>
722 6.7.22 print-authors 
724 Print authors.
726 6.7.23 test-1, test-2, test-3
728 Internal test commands. Don't use.
730 6.7.24 take-screenshot <filename> 
732 Save screenshot to <filename>.
734 6.7.25 +controller<num><button>
736 Press button <button> on controller <num> (1-8). The following 
737 button names are known:
739 • left
741 • right
743 • up
745 • down
747 • A
749 • B
751 • X
753 • Y
755 • L
757 • R
759 • select
761 • start
763 • trigger
765 • cursor
767 • pause
769 • turbo
771 6.7.26 controllerh<num><button>
773 Hold/unhold button <button> on controller <num> (1-8). See 
774 +controller for button names.
776 6.7.27 autofire (<pattern>|-)...
778 Set autofire pattern. Each parameter is comma-separated list of 
779 button names (in form of 1start, 1A, 2B, etc..) to hold on that 
780 frame. After reaching the end of pattern, the pattern restarts 
781 from the beginning.
783 6.7.28 repaint
785 Force a repaint.
787 6.8 Save jukebox 
789 6.8.1 cycle-jukebox-backward
791 Cycle save jukebox backwards.
793 6.8.2 cycle-jukebox-forward
795 Cycle save jukebox forwards
797 6.8.3 add-jukebox-save <filename>
799 Add <filename> to jukebox saves.
801 6.8.4 load-jukebox
803 Do load from jukebox (current mode).
805 6.8.5 save-jukebox
807 Do state save to jukebox.
809 6.9 Lua 
811 Only available if lua support is compiled in.
813 6.9.1 evaluate-lua <luacode>
815 Run Lua code <luacode> using built-in Lua interpretter.
817 6.9.2 run-lua <script>
819 Run specified lua file using built-in Lua interpretter.
821 6.10 Memory watch
823 6.10.1 add-watch <name> <expression>
825 Adds new watch (or modifies old one).
827 6.10.2 remove-watch <name>
829 Remove a watch.
831 6.11 Sound 
833 6.11.1 enable-sound <on/off> 
835 Enable/Disable sound.
837 6.11.2 set-sound-device <device> 
839 Set sound device to <device>
841 6.11.3 show-sound-status 
843 Show status of sound system.
845 6.11.4 show-sound-devices
847 Show all available devices.
849 6.12 SDL Platform commands 
851 The following are valid on SDL platform.
853 6.12.1 identify-key
855 Asks to press a key and then identifies that (pseudo-)key.
857 6.12.2 toggle-console 
859 Toggle between windowed/fullscreen console.
861 6.12.3 scroll-fullup 
863 Scroll messages window as far back as it goes.
865 6.12.4 scroll-fulldown 
867 Scroll messages window as far forward as it goes.
869 6.12.5 scroll-up 
871 Scroll messages window back one screenful.
873 6.12.6 scroll-down 
875 Scroll messages window forward one screenful.
877 7 Settings
879 7.1 Core settings
881 7.1.1 firmwarepath
883 Set where bsnes looks for firmware files. Default is “.”.
885 7.1.2 targetfps
887 Set the target fps. Numeric, range is 0.001 to “infinite”. 
888 Default is native framerate.
890 7.1.3 savecompression
892 Set save compression level (integer 0-9). Default is 7 (0 is no 
893 compression).
895 7.1.4 advance-timeout
897 Set the frame advance timeout in milliseconds. Numeric integer, 
898 range is 0-999999999. Default is 500.
900 7.2 AVI dumper settings
902 7.2.1 avi-large
904 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
905 the console outputs.
907 7.2.2 avi-left-border
909 AVI dumper: Set the default left border thickness (unless lua 
910 overrides) for dumps. Range 0-8191. Default is 0.
912 7.2.3 avi-right-border
914 AVI dumper: Set the default right border thickness (unless lua 
915 overrides) for dumps. Range 0-8191. Default is 0.
917 7.2.4 avi-top-border
919 AVI dumper: Set the default top border thickness (unless lua 
920 overrides) for dumps. Range 0-8191. Default is 0.
922 7.2.5 avi-bottom-border
924 AVI dumper: Set the default bottom border thickness (unless lua 
925 overrides) for dumps. Range 0-8191. Default is 0.
927 7.2.6 avi-maxframes
929 AVI dumper: Maximum number of frames per dump segment (0 => 
930 unlimited). Range 0-999999999. Default is 0.
932 7.2.7 avi-compresison
934 AVI dumper: Compression level (0-18).
936 • Compression levels 10 and above are not compatible with stock 
937   CSCD codec.
939 • Recomended level is 7.
941 7.2.8 avi-soundrate
943 AVI dumper: Set method of determining the sound rate.
945 • 0: Pick nearest of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48, 
946   64, 88.2, 96, 128, 176.4 and 192 kHz.
948 • 1: Round down to nearest integer.
950 • 2: Round up to nearest ingeter.
952 7.3 JMD options
954 7.3.1 jmd-copression
956 JMD dumper: Compression level (0-9).
958 7.4 SDL platform settings
960 7.4.1 autorepeat-first-delay
962 Sets the delay for first character in typematic autorepeat.
964 7.4.2 autorepeat-subsequent-delay
966 Sets the delay for subsequent characters in typematic autorepeat.
968 8 Lua functions
970 8.1 Core (in main table)
972 8.1.1 print
974 Print line to message console.
976 8.1.2 exec(string command)
978 Run command as it was entered on the command line
980 8.2 Table bit:
982 Bitwise logical functions and related.
984 8.2.1 bit.none(number...) / bit.bnot(number...)
986 48-bit bitwise NOT / NONE function (set bits that are set in none 
987 of the arguments).
989 8.2.2 bit.any(number...) / bit.bor(number...)
991 48-bit bitwise OR / ANY function (set bits that are set in any of 
992 the arguments).
994 8.2.3 bit.all(number...) / bit.band(number...)
996 48-bit bitwise AND / ALL function (set bits that are set in all 
997 of the arguments).
999 8.2.4 bit.parity(number...) / bit.bxor(number...)
1001 48-bit bitwise XOR / PARITY function (set bits that are set in 
1002 odd number of the arguments).
1004 8.2.5 bit.lrotate(number base[, number amount[, number bits]])
1006 Rotate bits-bit (max 48, default 48) number left by amount 
1007 (default 1) places.
1009 8.2.6 bit.rrotate(number base[, number amount[, number bits]])
1011 Rotate bits-bit (max 48, default 48) number right by amount 
1012 (default 1) places.
1014 8.2.7 bit.lshift(number base[, number amount[, number bits]])
1016 Shift bits-bit (max 48, default 48) number left by amount 
1017 (default 1) places. The new bits are filled with zeroes.
1019 8.2.8 bit.lrshift(number base[, number amount[, number bits]])
1021 Shift bits-bit (max 48, default 48) number logically right by 
1022 amount (default 1) places. The new bits are filled with zeroes.
1024 8.2.9 bit.arshift(number base[, number amount[, number bits]])
1026 Shift bits-bit (max 48, default 48) number arithmetically right 
1027 by amount (default 1) places. The new bits are shifted in with 
1028 copy of the high bit.
1030 8.3 Table gui:
1032 Most of these functions can only be called in on_paint and 
1033 on_video callbacks. Exceptions are noted.
1035 Colors are 32-bit. Bits 0-7 are the blue component, bits 8-15 are 
1036 the green component, bits 16-23 are the red component, bits 24-31 
1037 are alpha component (0 is fully opaque, 255 is almost 
1038 transparent). -1 is the fully transparent color. Alpha values 
1039 greater than 127 do work.
1041 Origin of coordinates is at top left corner of game display area. 
1042 Left and top gaps correspond to negative coordinates.
1044 8.3.1 gui.resolution()
1046 Returns 2-tuple (hresolution, vresolution).
1048 8.3.2 gui.<class>_gap(number gap)
1050 Set the <class> (left, right, top, bottom) gap to specified value 
1051 (max gap is 8191).
1053 8.3.3 gui.text(number x, number y, string text[, number fgc[, 
1054   number bgc]])
1056 Draw specified text on the GUI (each character cell is 8 or 16 
1057 wide and 16 high). Parameters:
1059 • x: X-coordinate to start the drawing from (and x-coordinate at 
1060   begining of the lines).
1062 • y: Y-coordinate to start the drawing from.
1064 • text: The text to draw.
1066 • fgc: Text color (default is 0xFFFFFF (white))
1068 • bgc: Background color (default is -1 (transparent))
1070 8.3.4 gui.textH(number x, number y, string text[, number fgc[, 
1071   number bgc]])
1073 Like gui.text, but draw using double-width.
1075 8.3.5 gui.textV(number x, number y, string text[, number fgc[, 
1076   number bgc]])
1078 Like gui.text, but draw using double-height.
1080 8.3.6 gui.textHV(number x, number y, string text[, number fgc[, 
1081   number bgc]])
1083 Like gui.text, but draw using double-width/double-height.
1085 8.3.7 gui.rectangle(number x, number y, number width, number 
1086   height[, number thickness[, number outline[, number fill]]])
1088 Draw rectangle on the GUI. Parameters:
1090 • x: X-coordinate of left edge.
1092 • y: Y-coordinate of upper edge.
1094 • width: Width of rectangle.
1096 • height: Height of rectangle.
1098 • thickness: Thickness of outline (default is 1).
1100 • outline: Color of outline (default is 0xFFFFFF (white))
1102 • fill: Color of fil (default is -1 (transparent))
1104 8.3.8 gui.pixel(number x, number y[, number color])
1106 Draw one pixel on the GUI. Parameters:
1108 • x: X-coordinate of the pixel
1110 • y: Y-coordinate of the pixel
1112 • color: Color of the pixel (default is 0xFFFFFF (white))
1114 8.3.9 gui.crosshair(number x, number y[, number length[, number 
1115   color]])
1117 Draw a crosshair. Parameters:
1119 • x: X-coordinate of the crosshair
1121 • y: Y-coordinate of the crosshair
1123 • length: Length of the crosshair lines (default 10).
1125 • color: Color of the crosshair (default is 0xFFFFFF (white))
1127 8.3.10 gui.line(number x1, number y1, number x2, number y2[, 
1128   number color])
1130 Draw a thin line. Parameters:
1132 • x1: X-coordinate of one end.
1134 • y1: Y-coordinate of one end.
1136 • x2: X-coordinate of the other end.
1138 • y2: Y-coordinate of the other end.
1140 • color: Color of the line (default is 0xFFFFFF (white)).
1142 8.3.11 gui.circle(number x, number y, number r[, number thick[, 
1143   number border[, number fil]]])
1145 Draw a circle. Parameters.
1147 • x: X-coordinate of the center
1149 • y: Y-coordinate of the center
1151 • r: The radius of the circle
1153 • thick: Border thickness
1155 • border: Border color (default is 0xFFFFFF (white))
1157 • fill: Fill color (default is -1 (transparent)).
1159 8.3.12 gui.repaint()
1161 Request on_repaint() to happen as soon as possible. Can be used 
1162 anywhere.
1164 8.3.13 gui.subframe_update(boolean on)
1166 Request subframe updates (calling on_paint() on subframes) to 
1167 happen (on=true) or not happen (on=false). Can be used anywhere.
1169 8.3.14 gui.screenshot(string filename)
1171 Write PNG screenshot of the current frame (no drawings) to 
1172 specified file. Can be used anywhere.
1174 8.3.15 gui.color(number r, number g, number b[, number a])
1176 Returns color (in notation Lua scripts use) corresponding to 
1177 color (r,g,b), each component in scale 0-255. If a is specified, 
1178 that is alpha (0 is fully transparent, 256(sic) is fully opaque). 
1179 The default alpha is 256.
1181 8.3.16 gui.status(string name, string value)
1183 Set status field “L[<name>]” to <value> in status area. Can be 
1184 used anywhere.
1186 8.4 table input
1188 Input handling. Only available in on_input callback.
1190 8.4.1 input.get(number controller, number index)
1192 Read the specified index (0-11) from specified controller (0-7). 
1193 Notes:
1195 • Uses physical controller numbering. Gamepad in port 2 is 
1196   controller 4, not 1!
1198 8.4.2 input.set(number controller, number index, number value)
1200 Write the specified index (0-11) from specified controller (0-7), 
1201 storing value. Notes:
1203 • Uses physical controller numbering. Gamepad in port 2 is 
1204   controller 4, not 1!
1206 8.4.3 input.reset([number cycles])
1208 Execute reset. If cycles is greater than zero, do delayed reset. 
1209 0 (or no value) causes immediate reset.
1211 • Only available with subframe flag false.
1213 8.4.4 input.raw()
1215 Returns table of tables of all available keys and axes. The first 
1216 table is indexed by key name (platform-dependent!), and the inner 
1217 table has the following fields:
1219 • last_rawval: Last reported raw value for control.
1221 • ktype: Type of key (disabled, key, mouse, axis, axis-inverse, 
1222   hat, pressure-m0, pressure-mp, pressure-0m, pressure-0p, 
1223   pressure-pm, pressure-p0).
1225 • cal_left: Minimum calibration value. Only meaningful with axis 
1226   and pressure types.
1228 • cal_center: Center calibration value. Only meaningful with axis 
1229   and pressure types.
1231 • cal_right: Maximum calibration value. Only meaningful with axis 
1232   and pressure types.
1234 • cal_tolerance: Dead zone tolerance. Only meaningful with axis 
1235   and pressure types.
1237 8.4.5 input.keyhook(key, state)
1239 Requests that keyhook events to be sent for key (state=true) or 
1240 not sent (state=false).
1242 8.5 Table hostmemory
1244 Host memory handling (extra memory saved to savestates). Host 
1245 memory starts empty.
1247 8.5.1 hostmemory.read(number address)
1249 Reads hostmemory slot address. Slot numbers out of range return 
1250 false instead of numeric.
1252 8.5.2 hostmemory.write(number address, number value)
1254 Writes hostmemory slot with 0-255. Slot numbers out of range 
1255 cause extension of host memory slot space.
1257 8.5.3 hostmemory.readbyte(number address)
1259 Read unsigned byte (1 element) from given address. Slots out of 
1260 range return false.
1262 8.5.4 hostmemory.writebyte(number address, number value)
1264 Write unsigned byte (1 element) to given slot. Slot numbers out 
1265 of range cause extension.
1267 8.5.5 hostmemory.readsbyte(number address)
1269 Read signed byte (1 element) from given address. Slots out of 
1270 range return false.
1272 8.5.6 hostmemory.writesbyte(number address, number value)
1274 Write signed byte (1 element) to given slot. Slot numbers out of 
1275 range cause extension.
1277 8.5.7 hostmemory.readword(number address)
1279 Read unsigned word (2 elements) from given address. Slots out of 
1280 range return false.
1282 8.5.8 hostmemory.writeword(number address, number value)
1284 Write unsigned word (2 elements) to given slot. Slot numbers out 
1285 of range cause extension.
1287 8.5.9 hostmemory.readsword(number address)
1289 Read signed word (2 elements) from given address. Slots out of 
1290 range return false.
1292 8.5.10 hostmemory.writesword(number address, number value)
1294 Write signed word (2 elements) to given slot. Slot numbers out of 
1295 range cause extension.
1297 8.5.11 hostmemory.readdword(number address)
1299 Read unsigned doubleword (4 elements) from given address. Slots 
1300 out of range return false.
1302 8.5.12 hostmemory.writedword(number address, number value)
1304 Write unsigned doubleword (4 elements) to given slot. Slot 
1305 numbers out of range cause extension.
1307 8.5.13 hostmemory.readsdword(number address)
1309 Read signed doubleword (4 elements) from given address. Slots out 
1310 of range return false.
1312 8.5.14 hostmemory.writesdword(number address, number value)
1314 Write signed doubleword (4 elements) to given slot. Slot numbers 
1315 out of range cause extension.
1317 8.5.15 hostmemory.readqword(number address)
1319 Read unsigned quadword (8 elements) from given address. Slots out 
1320 of range return false.
1322 8.5.16 hostmemory.writeqword(number address, number value)
1324 Write unsigned quadword (4 elements) to given slot. Slot numbers 
1325 out of range cause extension.
1327 8.5.17 hostmemory.readsqword(number address)
1329 Read signed quadword (8 elements) from given address. Slots out 
1330 of range return false.
1332 8.5.18 hostmemory.writesqword(number address, number value)
1334 Write signed quadword (8 elements) to given slot. Slot numbers 
1335 out of range cause extension.
1337 8.6 Table movie
1339 Movie handling
1341 8.6.1 movie.currentframe()
1343 Return number of current frame.
1345 8.6.2 movie.framecount()
1347 Return number of frames in movie.
1349 8.6.3 movie.readonly()
1351 Return true if in readonly mode, false if in readwrite.
1353 8.6.4 movie.set_readwrite()
1355 Set readwrite mode (does not cause on_readwrite callback).
1357 8.6.5 movie.frame_subframes(number frame)
1359 Count number of subframes in specified frame (frame numbers are 
1360 1-based) and return that.
1362 8.6.6 movie.read_subframe(number frame, number subframe)
1364 Read specifed subframe in specified frame and return data as 
1365 array (100 elements, numbered 0-99 currently).
1367 8.7 Table settings
1369 Routines for settings manipulation
1371 8.7.1 settings.get(string name)
1373 Get value of setting. If setting is blank, returns false. If 
1374 setting value can't be obtained, returns (nil, error message).
1376 8.7.2 settings.set(string name, string value)
1378 Set value of setting. If setting can't be set, returns (nil, 
1379 error message).
1381 8.7.3 settings.is_set(string name)
1383 Returns if setting is set. If setting does not exist, returns 
1384 (nil, error message).
1386 8.7.4 settings.blank(string name)
1388 Blanks a setting and returns true. If setting can't be blanked, 
1389 returns (nil, error message).
1391 8.8 Table memory
1393 Contains various functions for managing memory
1395 8.8.1 memory.vma_count()
1397 Returns the number of VMAs
1399 8.8.2 memory.read_vma(number index)
1401 Reads the specified VMA (indices start from zero). Trying to read 
1402 invalid VMA gives nil. The read VMA is table with the following 
1403 fields:
1405 • region_name (string): The readable name of the VMA
1407 • baseaddr (number): Base address of the VMA
1409 • lastaddr (number): Last address in the VMA.
1411 • size (number): The size of VMA in bytes.
1413 • readonly (boolean): True of the VMA corresponds to ROM.
1415 • native_endian (boolean): True if the VMA has native endian as 
1416   opposed to little endian.
1418 8.8.3 memory.find_vma(number address)
1420 Finds the VMA containing specified address. Returns table in the 
1421 same format as read_vma or nil if not found.
1423 8.8.4 memory.readbyte(number address)
1425 Reads the specified address as unsigned byte and returns the 
1426 result.
1428 8.8.5 memory.readsbyte(number address)
1430 Reads the specified address as signed byte and returns the 
1431 result.
1433 8.8.6 memory.writebyte(number address, number value)
1435 Writes the specified value (negative values undergo 2's 
1436 complement) to specified address (as a byte).
1438 8.8.7 memory.readword(number address)
1440 Reads the specified address as unsigned word and returns the 
1441 result.
1443 8.8.8 memory.readsword(number address)
1445 Reads the specified address as signed word and returns the 
1446 result.
1448 8.8.9 memory.writeword(number address, number value)
1450 Writes the specified value (negative values undergo 2's 
1451 complement) to specified address (as a word).
1453 8.8.10 memory.readdword(number address)
1455 Reads the specified address as unsigned doubleword and returns 
1456 the result.
1458 8.8.11 memory.readsdword(number address)
1460 Reads the specified address as signed doubleword and returns the 
1461 result.
1463 8.8.12 memory.writedword(number address, number value)
1465 Writes the specified value (negative values undergo 2's 
1466 complement) to specified address (as a doubleword).
1468 8.8.13 memory.readqword(number address)
1470 Reads the specified address as unsigned quadword and returns the 
1471 result.
1473 8.8.14 memory.readsqword(number address)
1475 Reads the specified address as signed quadword and returns the 
1476 result.
1478 8.8.15 memory.writeqword(number address, number value)
1480 Writes the specified value (negative values undergo 2's 
1481 complement) to specified address (as a quadword).
1483 8.9 Table _SYSTEM
1485 Contains copy of global variables from time of Lua 
1486 initialization. Non-writeable.
1488 8.10 Callbacks
1490 Various callbacks to Lua that can occur.
1492 8.10.1 Callback: on_paint()
1494 Called when screen is being painted. Any gui.* calls requiring 
1495 graphic context draw on the screen.
1497 8.10.2 Callback: on_video()
1499 Called when video dump frame is being painted. Any gui.* calls 
1500 requiring graphic context draw on the video.
1502 8.10.3 Callback: on_frame()
1504 Called on each starting whole frame.
1506 8.10.4 Callback: on_startup()
1508 Called when the emulator is starting (lsnes.rc and --run files 
1509 has been run).
1511 8.10.5 Callback: on_pre_load(string name)
1513 Called just before savestate/movie load occurs (note: loads are 
1514 always delayed, so this occurs even when load was initiated by 
1515 lua).
1517 8.10.6 Callback: on_err_load(string name)
1519 Called if loadstate goes wrong.
1521 8.10.7 Callback: on_post_load(string name, boolean was_savestate)
1523 Called on successful loadstate. was_savestate gives if this was a 
1524 savestate or a movie.
1526 8.10.8 Callback: on_pre_save(string name, boolean is_savestate)
1528 Called just before savestate save occurs (note: movie saves are 
1529 synchronous and won't trigger these callbacks if called from 
1530 Lua).
1532 8.10.9 Callback: on_err_save(string name)
1534 Called if savestate goes wrong.
1536 8.10.10 Callback: on_post_save(string name, boolean is_savestate)
1538 Called on successful savaestate. is_savestate gives if this was a 
1539 savestate or a movie.
1541 8.10.11 Callback: on_quit()
1543 Called when emulator is shutting down.
1545 8.10.12 Callback: on_input(boolean subframe)
1547 Called when emulator is just sending input to bsnes core. 
1548 Warning: This is called even in readonly mode, but the results 
1549 are ignored.
1551 8.10.13 Callback: on_reset()
1553 Called when SNES is reset.
1555 8.10.14 Callback: on_readwrite()
1557 Called when moving into readwrite mode as result of “set-rwmode” 
1558 command (note: moving to rwmode by Lua won't trigger this, as per 
1559 recursive entry protection).
1561 8.10.15 Callback: on_snoop(number port, number controller, number 
1562   index, number value)
1564 Called each time bsnes asks for input. The value is the final 
1565 value to be sent to bsnes core (readonly mode, autohold and 
1566 autofire have been taken into account). Might be useful when 
1567 translating movies to format suitable for console verification. 
1568 Note: There is no way to modify the value to be sent.
1570 8.10.16 Callback: on_keyhook(string keyname, table state)
1572 Sent when key that has keyhook events requested changes state. 
1573 Keyname is name of the key (group) and state is the state (same 
1574 kind as table values in input.raw).
1576 9 Memory watch expression syntax
1578 Memory watch expressions are in RPN (Reverse Polish Notation). At 
1579 the end of expression, the top entry on stack is taken as the 
1580 final result.
1582 Notations:
1584 • Evaluation order is strictly left to right.
1586 • a is the entry on top of stack
1588 • b is the entry immediately below top of stack
1590 • ; separates values to be pushed (no intermediate pop).
1592 • After end of element, all used stack slots are popped and all 
1593   results are pushed.
1595 • When pushing multiple values, the pushes occur in order shown.
1597 The following operators are available:
1599 • + : a + b
1601 • - : a - b
1603 • * : a * b
1605 • / : a / b
1607 • % : a % b
1609 • a : atan(a)
1611 • b : read_signed_byte(a)
1613 • c : cos(a)
1615 • d : read_signed_dword(a)
1617 • i : quotent(a / b)
1619 • p :\pi
1622 • q : read_signed_qword(a)
1624 • r : sqrt(a)
1626 • s : sin(a)
1628 • t : tan(a)
1630 • u : a; a
1632 • w : read_signed_word(a)
1634 • A : atan2(a, b)
1636 • B : read_unsigned_byte(a)
1638 • C<number>z : Push number <number> to stack.
1640 • D : read_unsigned_dword(a)
1642 • C0x<number>z : Push number <number> (hexadecimal) to stack.
1644 • Q : read_unsigned_qword(a)
1646 • R<digit> : round a to <digit> digits.
1648 • W : read_unsigned_word(a)
1650 9.1 Example:
1652 C0x007e0878zWC0x007e002czW-
1654 1. Push value 0x7e0878 on top of stack (C0x007e0878z).
1656 2. Pop the value on top of stack (0x7e0878), read word value at 
1657   that address and push the result,call it x1 (W).
1659 3. Push value 0x7e002c on top of stack (C0x007e002cz).
1661 4. Pop the value on top of stack (0x7e002c), read word value at 
1662   that address and push the result,call it x2 (W).
1664 5. Pop the two top numbers on stack, x1 and x2, substract x1 from 
1665   x2 and push x2 - x1 (-).
1667 6. Since the expression ends, the final memory watch result is 
1668   the top one on stack, which is x2 - x1.
1670 10 Modifier and key names:
1672 10.1 SDL Platform
1674 10.1.1 Modifier names
1676 Following modifier names are known:
1678 • ctrl, lctrl, rctrl: Control keys
1680 • alt, lalt, ralt: ALT keys.
1682 • shift, lshift, rshift: Shift keys.
1684 • meta, lmeta, rmeta: Meta keys.
1686 • num, caps: Numlock/Capslock (these are sticky!)
1688 • mode: Mode select.
1690 10.1.2 Key names
1692 Following key names are known:
1694 • backspace, tab, clear, return, pause, escape, space, exclaim, 
1695   quotedbl, hash, dollar, ampersand, quote, leftparen, 
1696   rightparen, asterisk, plus, comma, minus, period, slash, 0, 1, 
1697   2, 3, 4, 5, 6, 7, 8, 9, colon, semicolon, less, equals, 
1698   greater, question, at, leftbracket, backslash, rightbracket, 
1699   caret, underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, 
1700   l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, delete, world_0, 
1701   world_1, world_2, world_3, world_4, world_5, world_6, world_7, 
1702   world_8, world_9, world_10, world_11, world_12, world_13, 
1703   world_14, world_15, world_16, world_17, world_18, world_19, 
1704   world_20, world_21, world_22, world_23, world_24, world_25, 
1705   world_26, world_27, world_28, world_29, world_30, world_31, 
1706   world_32, world_33, world_34, world_35, world_36, world_37, 
1707   world_38, world_39, world_40, world_41, world_42, world_43, 
1708   world_44, world_45, world_46, world_47, world_48, world_49, 
1709   world_50, world_51, world_52, world_53, world_54, world_55, 
1710   world_56, world_57, world_58, world_59, world_60, world_61, 
1711   world_62, world_63, world_64, world_65, world_66, world_67, 
1712   world_68, world_69, world_70, world_71, world_72, world_73, 
1713   world_74, world_75, world_76, world_77, world_78, world_79, 
1714   world_80, world_81, world_82, world_83, world_84, world_85, 
1715   world_86, world_87, world_88, world_89, world_90, world_91, 
1716   world_92, world_93, world_94, world_95, kp0, kp1, kp2, kp3, 
1717   kp4, kp5, kp6, kp7, kp8, kp9, kp_period, kp_divide, 
1718   kp_multiply, kp_minus, kp_plus, kp_enter, kp_equals, up, down, 
1719   right, left, insert, home, end, pageup, pagedown, f1, f2, f3, 
1720   f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, numlock, 
1721   capslock, scrollock, rshift, lshift, rctrl, lctrl, ralt, lalt, 
1722   rmeta, lmeta, lsuper, rsuper, mode, compose, help, print, 
1723   sysreq, break, menu, power, euro, undo
1725 • Names of form 'key<n>' where <n> is 0-255 are interpretted as 
1726   key having hardware-dependent scan code of <n> (useful to bind 
1727   those keys that don't have symbolic names).
1729 10.1.3 Joystick pseudo-keys:
1731 • joystick<num>button<button>: Joystick <num> (0-based) button 
1732   <button> (0-based).
1734 • joystick<num>hat<hat>n: Joystick <num> (0-based) hat <hat> 
1735   (0-based) up.
1737 • joystick<num>hat<hat>w: Joystick <num> (0-based) hat <hat> 
1738   (0-based) left.
1740 • joystick<num>hat<hat>s: Joystick <num> (0-based) hat <hat> 
1741   (0-based) down.
1743 • joystick<num>hat<hat>e: Joystick <num> (0-based) hat <hat> 
1744   (0-based) right.
1746 • joystick<num>axis<axis>-: Joystick <num> (0-based) axis <axis> 
1747   negative position (axis modes axis and axis_inverse).
1749 • joystick<num>axis<axis>+: Joystick <num> (0-based) axis <axis> 
1750   positive position (axis modes axis and axis_inverse).
1752 • joystick<num>axis<axis>: Joystick <num> (0-based) axis <axis> 
1753   pressure (axis modes pressure_*).
1755 10.1.4 Special buttons:
1757 • Escape: Enter/Exit Command mode, cancel modal dialogs.
1759 • Return (also KPEnter): Execute command, ok modal dialog.
1761 • Pgup/Up (also KP8/9 if no num lock; command mode): Previous 
1762   command in command history
1764 • Pgdn/Down(also KP2/3 if no num lock; command mode): Next 
1765   command in command history
1767 • Home (also KP7 if no num lock; command mode): Beginning of 
1768   command.
1770 • End (also KP1 if no num lock; command mode): End of command.
1772 • Left (also KP4 if no num lock; command mode): Move cursor left.
1774 • Right (also KP6 if no num lock; command mode): Move cursor 
1775   right.
1777 • Delete (also KP. if no num lock; command mode): Delete 
1778   character to right of cursor.
1780 • Insert (also KP0 if no num lock; command mode): Toggle between 
1781   insert / overwrite modes.
1783 • Backspace (command mode): Delete character to left of cursor.
1785 • LCTRL+LALT+ESCAPE: Ungraceful shutdown (leaves dump 
1786   corrupted!).
1788 10.2 wxWidgets platform
1790 10.2.1 Modifier names:
1792 Following modifier names are known:
1794 • alt
1796 • ctrl
1798 • shift 
1800 • meta
1802 • cmd (Mac OS X only)
1804 10.2.2 Key names:
1806 Following key names are known:
1808 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
1809   dollar, percent, ampersand, quote, leftparen, rightparen, 
1810   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
1811   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
1812   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
1813   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
1814   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
1815   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
1816   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
1817   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
1818   home, lefT, up, right, down, select, print, execute, snapshot, 
1819   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
1820   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
1821   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
1822   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
1823   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
1824   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
1825   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
1826   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
1827   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
1828   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
1829   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
1830   windows_right, windows_menu, command, special1, special2, 
1831   special3, special4, special5, special6, special7, special8, 
1832   special9, special10, special11, special12, special13, 
1833   special14, special15, special16, special17, special18, 
1834   special19, special20
1836 11 Movie file format
1838 Movie file is .zip archive in itself, normal ZIP archive tools 
1839 work on it (note: If you recompress it, do not use compression 
1840 methods other than store and deflate and especially do not use 
1841 encryption of any kind).
1843 11.1 Detecting clean start/SRAM/Savestate
1845 • If file has member “savestate” it is savestate, otherwise:
1847 • If file has members with names starting “moviesram.” it is 
1848   movie starting from SRAM, otherwise:
1850 • It is movie starting from clear state.
1852 11.2 Member: gametype
1854 Type of game ROM and region (as one line). Valid values are:
1857 +--------------+---------------------+--------+
1858 |    Value     |       System        | Region |
1859 +--------------+---------------------+--------+
1860 +--------------+---------------------+--------+
1861 |  snes_pal    |     Super NES       |  PAL   |
1862 +--------------+---------------------+--------+
1863 |   sgb_pal    |   Super Game Boy    |  PAL   |
1864 +--------------+---------------------+--------+
1865 |  snes_ntsc   |     Super NES       |  NTSC  |
1866 +--------------+---------------------+--------+
1867 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
1868 +--------------+---------------------+--------+
1869 |     bsx      | BS-X (non-slotted)  |  NTSC  |
1870 +--------------+---------------------+--------+
1871 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
1872 +--------------+---------------------+--------+
1873 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
1874 +--------------+---------------------+--------+
1877 Frame rates are:
1880 +---------+-----------------+
1881 | Region  | Framerate (fps) |
1882 +---------+-----------------+
1883 +---------+-----------------+
1884 |  PAL    |   322445/6448   |
1885 +---------+-----------------+
1886 |  NTSC   | 10738636/178683 |
1887 +---------+-----------------+
1890 11.3 Member: port1
1892 Contains type of port #1 (as one line). Valid values are 'none', 
1893 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
1894 'gamepad'.
1896 11.4 Member: port2
1898 Contains type of port #2 (as one line). Valid values are 'none', 
1899 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
1900 'justifiers'. If not present, defaults to 'none'.
1902 11.5 Member: gamename
1904 Contains name of the game (as one line).
1906 11.6 Member: authors
1908 Contains authors, one per line. Part before '|' is the full name, 
1909 part after is the nickname.
1911 11.7 Member: systemid
1913 Always “lsnes-rr1” (one line). Used to reject other saves.
1915 11.8 Member: controlsversion
1917 Always “0” (one line). Used to identify what controls are there.
1919 11.9 Member: “coreversion”
1921 Contains bsnes core version number (as one line).
1923 11.10 Member: projectid
1925 Contains project ID (as one line). Used to identify if two movies 
1926 are part of the same project.
1928 11.11 Member: {rom,slota,slotb}{,xml}.sha256
1930 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
1931 Absent if corresponding file is absent.
1933 11.12 Member: moviesram.<name>
1935 Raw binary startup SRAM of kind <name>. Only present in 
1936 savestates and movies starting from SRAM.
1938 11.13 Member: saveframe
1940 Contains frame number (as one line) of frame movie was saved on. 
1941 Only present in savestates.
1943 11.14 Member: lagcounter
1945 Current value of lag counter (as one line). Only present in 
1946 savestates.
1948 11.15 Member: pollcounters
1950 Contains poll counters (currently 100 of them), one per line. 
1951 Each line is raw poll count if DRDY is set for it. Otherwise it 
1952 is negative poll count minus one. Only present in savestates.
1954 11.16 Member: hostmemory
1956 Raw binary dump of host memory. Only present in savestates.
1958 11.17 Member: savestate
1960 The raw binary savestate itself. Savestate detection uses this 
1961 file, only present in savestates.
1963 11.18 Member: screenshot
1965 Screenshot of current frame. Only present in savestates. First 2 
1966 bytes are big-endian width of image, rest are 24-bit RGB image 
1967 data. Height of image is inferred from the width and size of 
1968 data.
1970 11.19 Member: sram.<name>
1972 Raw binary SRAM of kind <name> at time of savestate. Only present 
1973 in savestates.
1975 11.20 Member: input
1977 The actual input track, one line per subframe (blank lines are 
1978 skipped).
1980 • If the first byte of each line is '.', ' ', <tab> or '|', then 
1981   the line is part of same frame as previous, otherwise it starts 
1982   a new frame.
1984 • First subframe must start a new frame.
1986 Length of movie in frames is number of lines in input file that 
1987 start a new frame.
1989 11.21 Member: rerecords
1991 Contains textual base-10 rerecord count (as one line; emulator 
1992 just writes this, it doesn't read it) + 1.
1994 11.22 Member: rrdata
1996 This member stores set of load IDs. There is one load ID per 
1997 rerecord (plus one corresponding to start of project).
1999 • This member constists of concatenation of records
2001 • Each record is 2-36 bytes long and can represent 1-16,843,009 
2002   consequtive IDs.
2004 • IDs are interpretted as 256-bit big-endian integers with 
2005   warparound.
2007 • Initial predicted ID is all zeroes.
2009 Format of each record is:
2011 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
2012   bits 5-6 are count length (countlen). Bit 7 is unused.
2014 • 32-prefixlen bytes of ID.
2016 • countlen bytes of big-endian count (count).
2018 Records are processed as follows:
2020 • To form the first ID encoded by record, take the first 
2021   prefixlen bytes predicted ID and append the read ID value to 
2022   it. The result is the first ID encoded.
2024 • If countlen is 0, record encodes 1 ID.
2026 • If countlen is 1, record encodes 2+count IDs.
2028 • If countlen is 2, record encodes 258+count IDs.
2030 • If countlen is 3, record encodes 65794+count IDs.
2032 • The new predicted ID is the next ID after last one encoded by 
2033   the record.
2035 The number of rerecords + 1 is equal to the sum of number of IDs 
2036 encoded by all records.
2038 11.23 Member: starttime.second
2040 Movie starting time, second part. Epoch is Unix epoch. Default is 
2041 1,000,000,000.
2043 11.24 Member: starttime.subsecond
2045 Movie starting time, subsecond part. Unit is CPU clocks. Default 
2046 is 0.
2048 11.25 Member: savetime.second
2050 Movie saving time, second part. Default is starttime.second. Only 
2051 present in savestates.
2053 11.26 Member: savetime.subsecond
2055 Movie saving time, subsecond part. Default is 
2056 starttime.subsecond. Only present in savestates.
2058 12 Quick'n'dirty encode guide
2060 1. Start the emulator and load the movie file.
2062 2. Set large AVI option 'set-setting avi-large on'
2064 3. Enable dumping 'dump-avi tmpdump' 
2066 4. Unpause and let it run until you want to end dumping.
2068 5. Close the emulator (closing the window is the easiest way). Or 
2069   use 'end-avi'.
2071 6. For each tmpdump*.avi file created, on command prompt, do 
2072   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
2074 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
2076 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
2077   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
2078   tmpdump_<numbers>.mkv, with + in between).
2080 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
2081   final.mkv contains quick'n'dirty encode.
2083 13 Axis configurations for some gamepad types:
2085 13.1 XBox360 controller:
2087 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
2088 set to pressure-+.
2090 set-axis joystick0axis2 pressure-+
2092 set-axis joystick0axis5 pressure-+
2094 • This is needed for SDL only. EVDEV sets those types correctly.
2096 13.2 PS3 “sixaxis” controller:
2098 Axes 8-19 should be disabled.
2100 set-axis joystick0axis8 disabled
2102 set-axis joystick0axis9 disabled
2104 set-axis joystick0axis10 disabled
2106 set-axis joystick0axis11 disabled
2108 set-axis joystick0axis12 disabled
2110 set-axis joystick0axis13 disabled
2112 set-axis joystick0axis14 disabled
2114 set-axis joystick0axis15 disabled
2116 set-axis joystick0axis16 disabled
2118 set-axis joystick0axis17 disabled
2120 set-axis joystick0axis18 disabled
2122 set-axis joystick0axis19 disabled
2124 14 Errata:
2126 14.1 Problems from BSNES core:
2128 • The whole pending save stuff.
2130 • Lack of layer hiding.
2132 • It is slow (especially accuracy).
2134 • Firmwares can't be loaded from ZIP archives.
2136 14.2 Other problems:
2138 • Modifiers don't work with pseudo-keys (SDL, EVDEV).
2140 • Audio for last dumped frame is not itself dumped.
2142 • Audio in UI is pretty bad in quality if game doesn't run at 
2143   full speed.
2145 • AVI compression levels 10-18 are not compatible with AVISynth 
2146   AVISource.
2148 • No menus, command based interface (SDL).
2150 • Long commands don't scroll.
2152 • Wxwidgets UI is still buggy.
2154 15 Changelog:
2156 15.1 rr0-beta1
2158 • Fix -Wall warnings
2160 • Fix dumper video corruption with levels 10-18.
2162 15.2 rr0-beta2
2164 • Autofire
2166 • Lots of code cleanups
2168 • Lua interface to settings
2170 • Allow specifying AVI borders without Lua
2172 • Fix scaling if vscale > 1 and originx > 0 (left border exists)
2174 • on_snoop lua callback
2176 • Faster movie loading and saving.
2178 15.3 rr0-beta3
2180 • Joystick support
2182 15.4 rr0-beta4
2184 • Fix multi-buttons
2186 • Save jukebox functionality.
2188 15.5 rr0-beta5
2190 • Try to fix some nasty failing movie load edge cases
2192 • Allow specifying scripts to run on command line.
2194 15.6 rr0-beta6
2196 • Major source code reorganization.
2198 • Backup savestates before overwriting.
2200 • Don't crash if loading initial state fails.
2202 15.7 rr0-beta7
2204 • Fix firmware lookup
2206 • Fix author name parsing
2208 • Fix rerecord counting
2210 • (SDL) Print messages to console if SDL is uninitialized
2212 • Add movieinfo program
2214 • Fix loading movies starting from SRAM.
2216 15.8 rr0-beta8
2218 • Add support for unattended dumping
2220 • Fix compiling for Win32
2222 • Don't lock up if sound can't be initialized
2224 • Strip trailing CR from commands
2226 • Don't try to do dubious things in global ctors (fix crash on 
2227   startup)
2229 15.9 rr0-beta9
2231 • Small documentation tweaking
2233 • Fix make clean
2235 • Fix major bug in modifier matching
2237 15.10 rr0-beta10
2239 • Lots of documentation fixes
2241 • Use dedicated callbacks for event backcomm., not commands.
2243 • Ensure that the watchdog is not hit when executing delayed 
2244   reset.
2246 • Remove errant tab from joystick message.
2248 15.11 rr0-beta11
2250 • Make autofire operate in absolute time, not linear time
2252 • Reinitialize controls when resuming from loadstate
2254 • Some more code cleanups
2256 • If Lua allocator fails, call OOM_panic()
2258 • Byte/word/dword/qword sized host memory write/read functions.
2260 • Dump at correct framerate if dumping interlaced NTSC 
2261   (height=448).
2263 15.12 rr0-beta12
2265 • Actually include the complete source code
2267 • Keep track of RTC
2269 15.13 rr0-beta13
2271 • Document {save,start}time.{,sub}second.
2273 • Intercept time() from bsnes core.
2275 15.14 rr0-beta14
2277 • Allow disabling time() interception (allow build on Mac OS X)
2279 • Use SDLMain on Mac OS X (make SDL not crash)
2281 • Disable delayed resets (just plain too buggy for now).
2283 • Code cleanups
2285 • Use 16-bit for graphics/video instead of 32-bit.
2287 • gui.rectangle/gui.pixel
2289 • gui.crosshair
2291 • New CSCD writer implementation.
2293 15.15 rr0-beta15
2295 • Fix interaction of * and +.
2297 • Manual improvements
2299 • Use gettimeofday()/usleep(), these seem portable enough.
2301 • Move joystick axis manipulation to keymapper code.
2303 • Changes to how read-only works.
2305 • Refactor controller input code.
2307 15.16 rr0-beta16
2309 • Fix mouseclick scale compensation.
2311 • Draw area boundaries correctly in SDL code.
2313 • gui.screenshot.
2315 • Fix CSCD output (buffer overrun and race condition).
2317 15.17 rr0-beta17
2319 • JMD dumping support.
2321 • Allow unattended dumping to JMD.
2323 • Move to BSNES v083.
2325 • Switch back to 32-bit colors.
2327 • Add Lua function gui.color.
2329 • Use some new C++11 features in GCC 4.6.
2331 • Be prepared for core frequency changes.
2333 • Pass colors in one chunk from Lua.
2335 15.18 rr0-beta18
2337 • New lua functions gui.line(), gui.status() and gui.circle(), 
2338   memory.vma_count(), memory.read_vma() and memory.find_vma().
2340 • Numerious documentation fixups
2342 • RTC time format changed
2344 • Reformat flags display
2346 • Allow lua package name to be overridden
2348 • SDUMP (high-quality dumping).
2350 • Split platform support to plugins.
2352 • Make all sound plugins support basic sound commands
2354 • Support portaudio for sound.
2356 • Allow disable Lua/SDL searching.
2358 • Upconvert colors when copying lcscreen to screen.
2360 • Reorganize source tree.
2362 • Evdev joystick support.
2364 • Refactor more code into generic window code.
2366 15.19 rr0-beta19
2368 • Refactor message handling.
2370 • Rework makefile
2372 • Documentation fixes
2374 • Finish pending saves before load/quit.
2376 • Wxwidgets graphics plugin.
2378 15.20 rr0-beta20
2380 • Get rid of win32-crap.[ch]pp.
2382 • Move files around a lot.
2384 • Get rid of need for host C++ compiler.
2386 • Bsnes v084 core.
2388 • Refactor inter-component communication.
2390 • Fix zero luma.
2392 • Fix crash on multiline aliases.
2394 • Load/Save settings in wxwidgets gui.
2396 15.21 rr0-beta21
2398 • Patch problems in bsnes core
2400 • SNES is little-endian, not big-endian!
2402 • Fix memory corruption in lcscreen::load()
2404 15.22 rr0-beta22
2406 • Fix interpretting repeat counts in rrdata loading.
2408 • New lua callback: on_frame()
2410 • Remove calls to runtosave() that aren't supposed to be there
2412 • Lua function: movie.read_rtc()
2414 • Ignore src/fonts/font.cpp
2416 • Fix more bsnes core problems
2418 • Control bsnes random seeding
2420 • Pause-on-end
2422 • Some bsnes core debugging features (state dump and state hash)
2424 • Fix titlebar version number (no, the last version wasn't 
2425   'lsnes-0-beta21', it was 'lsnes rr0-beta21').
2427 15.23 rr0-beta23
2429 • Fix memory corruption due to macro/field mixup
2431 • search-memory update
2433 • Allow direct-mapped framebuffer
2435 • SDL: Use SDL_ANYFORMAT if possible
2437 • SDMP2SOX: 2s delay modes.
2439 • Wxwidgets: Cleanups
2441 • Use sed -E, not sed -r. Fixes building on Mac OS X.
2443 • Wxwidgets: Save jukebox on exit
2445 • Fix RTC if using load-movie on savestate.
2447 • Fix crash related to full console mode.
2449 15.24 rr0-beta24
2451 • Wxwidgets: Allow bringing application to foreground on Mac OS 
2452   X.
2454 • Wxwidgets: Allow compiling on Mac OS X.
2456 • Use movie compare instead of movie hashing (faster save/load).
2458 • Lua: _SYSTEM table.
2460 15.25 rr0-beta25
2462 • sdmp2sox: Pad soundtrack if using -l or -L.
2464 • sdmp2sox: Fix NTSC overscan.
2466 • sdmp2sox: Add AR correction mode.
2468 • call lua_close() when exiting.
2470 • Fix zip_writer bug causing warnings from info-zip and error 
2471   from advzip.
2473 15.26 rr0-beta26
2475 • Fix IPS patching code (use bsnes core IPS patcher).
2477 • Implement BPS patching (using bsnes core IPS patcher).
2479 • Add feature to load headered ROMs.
2481 15.27 rr0-beta27
2483 • Show command names when showing keybindings
2485 15.28 rr0
2487 • Fix pause-on-end to be actually controllable
2489 • SDL: Poll all events in queue, not just first one (fixes 
2490   slowness in command typing)
2492 • Wxwidgets: Fix ROM loading.
2494 15.29 rr1-beta0
2496 • Lua: Add gui.textH, gui.textV, gui.textHV
2498 • Fix text colors on SDL on Mac OS X
2500 • Mode 'F' for finished in readonly mode.
2502 • Fix some WS errors.
2504 • Reliably pause after skip poll
2506 • Split UI and core into their own threads
2508 15.30 rr1-beta1
2510 • Remove leftover dummy SRAM slot
2512 • Fix controller numbers.
2514 15.31 rr1-beta2
2516 • Fix lsnes-dumpavi after interface change.
2518 • Also give BSNES patches for v085.
2520 • Pack movie data in memory.
2522 15.32 rr1-beta3
2524 • Fix framecount/length given when loading movies.
2526 • Controller command memory leak fixes.
2528 • Don't leak palette if freeing screen object.
2530 15.33 rr1-beta4
2532 • Detect revisions.
2534 • Wxwidgets: Allow controlling dumper from the menu.
2536 15.34 rr1-beta5
2538 • Rewrite parts of manual
2540 • Lua: Make it work with Lua 5.2.
2542 15.35 rr1-beta6
2544 • Win32: Fix compile errors.
2546 15.36 rr1-beta7
2548 • Refactor controller input code.
2550 • Fix crash when using command line on SDL / Mac OS X.
2552 15.37 rr1-beta8
2554 • Delete core/coroutine (obsolete)
2556 • Lag input display by one frame.
2558 • Rewind movie to beginning function.
2560 • Fix wrong frame number reported to Lua when repainting after 
2561   loadstate
2563 • Support UI editing of jukebox
2565 • Wxwidgets: Save settings on exit.
2567 • Support ${project} for filenames
2569 • SDL: Fix command history
2571 15.38 rr1-beta9
2573 • Fix some order-of-global-ctor bugs.
2575 15.39 rr1-beta10
2577 • Fix crashes when quitting on Win32.
2579 15.40 rr1-beta11
2581 • EVDEV: Queue keypresses from joystick, don't send directly
2583 • Wxwidgets: Load-Preserve that actually works.
2585 15.41 rr1-beta12
2587 • Wxwidgets: GUI for memory search.
2589 • Warn about using synchronous queue in UI callback.
2591 15.42 rr1-beta13
2593 • Remember last saved file for each ROM
2595 • Support MT dumping via boost.
2597 • Lua: input.raw
2599 • Lua: input.keyhook
2601 • Make mouse be ordinary input instead of special-casing
2603 • SDL: Don't screw up commands with NUL codepoints.
2605 15.43 rr1-beta14
2607 • Merge status panel and main window
2609 • True movie slot support (the rest of it)
2611 • SDL: Fix compilation error
2613 • Elminate cross calls in dump menu code.
2615 15.44 rr1-beta15
2617 • Cancel pending saves command
2619 • Wxwidgets: Code refactoring
2621 • Wxwidgets: Fix system -> reset
2623 • Wxwidgets: Read watch expressions in the right thread
2625 15.45 rr1-beta16
2627 • Wxwidgets: Don't prompt for member when running Lua script (Lua 
2628   doesn't support that).
2630 • Wxwidgets: 128 -> 1024 Autohold slots (in case more are 
2631   needed).
2633 • Don't append trailing '-' to prefix when saving movie.
2635 • Fix ROM/savestate handling (don't let user mismatch ROM and 
2636   savestates).
2638 15.46 rr1
2640 • Document memory watch syntax.
2642 15.47 rr1-delta1
2644 • Fix unattended dumping (lsnes-dumpavi)
2646 • Support RAW dumping
2648 • Use adv_dumper instead of the old interface in lsnes-dumpavi 
2649   (changes syntax)
2651 • Add option to control sample rate preturbation in AVI dumper
2653 15.48 rr1-delta2
2655 • Wxwidgets: Fix dumper submodes
2657 • Set core controller types before loadstate
2659 15.49 rr1-delta2epsilon1
2661 • Fix compiling with bsnes v086.