Allow compiling against bsnes v086
[lsnes.git] / manual.txt
blobd837614803dec302c8359d163defd5d2437e001e
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 --headered-<kind>=<file> (lsnes/SDL, lsnes-avidump)
205 Load <file> as specified ROM, stripping first 512 bytes. Handy 
206 for loading SMC / FIG and such files.
208 4.1.3 --<kind>-xml=<file> (lsnes/SDL, lsnes-avidump)
210 Override hardware detection for ROM, reading the values from 
211 <file> (BSNES XML format).
213 4.1.4 --ips-<kind>=<file> (lsnes/SDL, lsnes-avidump)
215 Apply BPS/IPS patch <file> to ROM <kind>. If specified multiple 
216 times, the patches are applied in order.
218 4.1.5 --ips-<kind>-xml=<file> (lsnes/SDL, lsnes-avidump)
220 Apply BPS/IPS patch <file> to XML of ROM <kind>. If specified 
221 multiple times, the patches are applied in order.
223 4.1.6 --ips-offset=<offset> (lsnes/SDL, lsnes-avidump)
225 Set offset to apply to IPS patches. May be negative. Handy for 
226 applying headered IPS patches (use offset of -512 for this). The 
227 offset must be 0 for BPS patches.
229 4.1.7 --pal
231 Force ROM to be considered PAL-only.
233 • Only works on SNES and SGB ROMs (not BS-X or Sufami Turbo).
235 • Attempting to load NTSC movie file will error out.
237 4.1.8 --ntsc
239 Force ROM to be considered NTSC-only.
241 • Attempting to load PAL movie file will error out.
243 4.2 Session options
245 4.2.1 <filename> (lsnes/SDL, lsnes-avidump, movieinfo)
247 Load <filename> as movie or savestate file. All other session 
248 options are ignored.
250 4.2.2 --port1=<device> (lsnes/SDL)
252 Set type of port1. Valid values are:
254 • none: No device connected
256 • gamepad: One gamepad (the default)
258 • multitap: Four gamepads (warning: makes most games refuse to 
259   start)
261 • mouse: Mouse.
263 4.2.3 --port2=<type> (lsnes/SDL)
265 Set type of port2. Valid values are:
267 • none: No device connected (the default)
269 • gamepad: One gamepad
271 • multitap: Four gamepads.
273 • mouse: Mouse
275 • superscope: Super Scope
277 • justifier: One justifier
279 • justifiers: Two justifiers
281 4.2.4 --gamename=<name> (lsnes/SDL)
283 Set the name of game to <name>. Default is blank.
285 4.2.5 --author=<name> (lsnes/SDL)
287 Add author with full name of <name> (no nickname).
289 4.2.6 --author=|<name> (lsnes/SDL)
291 Add author with nickname of <name> (no full name).
293 4.2.7 --author=<fullname>|<nickname> (lsnes/SDL)
295 Add author with full name of <fullname> and nickname of 
296 <nickname>.
298 4.2.8 --rtc-second=<value> (lsnes/SDL)
300 Set RTC second (0 is 1st January 1970 00:00:00Z). Default is 
301 1,000,000,000.
303 4.2.9 --rtc-subsecond=<value> (lsnes/SDL)
305 Set RTC subsecond. Range is 0-. Unit is CPU cycle. Default is 0.
307 4.3 Misc. options:
309 4.3.1 --run=<file> (lsnes/SDL)
311 After running main RC file, run this file. If multiple are 
312 specified, these execute in order specified.
314 4.4 dump options (lsnes-dumpavi only)
316 4.4.1 --dumper=<dumper>
318 Set the dumper to use (required). Use 'list' for listing of known 
319 dumpers.
321 4.4.2 --mode=<mode>
323 Set the mode to use (required for dumpers with multiple modes, 
324 forbidden otherwise). Use 'list' for known modes.
326 4.4.3 --prefix=<prefix>
328 Set dump prefix. Default is “avidump”.
330 4.4.4 --option=<name>=<value>
332 Set option <name> to value <value>.
334 4.4.5 --length=<length>
336 Set number of frames to dump. Mandatory.
338 4.4.6 --lua=<script>
340 Run specified lua script (lsnes-dumpavi does not have 
341 initialization files).
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 dump-avi <prefix>
493 Dump AVI video to prefix <prefix> Notes:
495 • The codec is Camstudio Codec in gzip mode.
497 • Encoder and muxer are internal, available on all platforms.
499 • Audio enable/disable and framerate has no effect.
501 • The audio dumped to .avi is low-quality version. The 
502   high-quality version is dumped to .sox file.
504 6.5.2 end-avi
506 End current AVI video dump (closing the emulator also closes the 
507 dump).
509 6.5.3 dump-jmd <file>
511 Dump JMD video to file <file>.
513 6.5.4 end-jmd
515 End the current JMD dump in progress.
517 6.5.5 dump-sdmp <prefix>
519 Dump SDMP to <prefix>, splitting at 2GB.
521 6.5.6 dump-sdmp-ss <file>
523 Dump SDMP to <file>, no splitting
525 6.5.7 end-sdmp
527 End the current SDMP dump in progress.
529 6.5.8 dump-raw <prefix>
531 Dump raw audio (to <prefix>.audio, at 32040.5Hz) and video (to 
532 <prefix>.video>, at nominal framerate and 512x448 / 512x478 
533 size).
535 6.5.9 end-raw
537 End the current RAW dump in progress.
539 6.6 Memory manipulation
541 <address> may be decimal or hexadecimal (prefixed with '0x'). 
542 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
543 signed (prefixed with '-') decimal.
545 The available element <sizes> are:
547 • byte: 1 byte
549 • word: 2 bytes
551 • dword: 4 bytes
553 • qword: 8 bytes
555 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
556 When dealing with DSP memory, multi-byte reads/writes are 
557 native-endian (do not use operand sizes exceeding DSP bitness, 
558 except dword is OK for 24-bit memory).
560 6.6.1 read-<size> <address>
562 Read the value of byte in <address>.
564 6.6.2 read-s<size> <address>
566 Read the value of signed byte in <address>.
568 6.6.3 write-<size> <address> <value>
570 Write <value> to byte in address <address>.
572 6.6.4 search-memory reset
574 Reset the memory search
576 6.6.5 search-memory count
578 Print number of candidates remaining
580 6.6.6 search-memory print
582 Print all candidates remaining
584 6.6.7 search-memory <usflag><sizeflag><op>
586 Searches memory for addresses satisfying criteria.
588 <usflag> can be:
590 • u: unsigned
592 • s: signed
594 <sizeflag> can be:
596 • b: byte
598 • w: word
600 • d: dword
602 • q: qword
604 <op> can be:
606 • lt: < previous value.
608 • le: <= previous value.
610 • eq: = previous value.
612 • ne: != previous value.
614 • ge: >= previous value.
616 • gt: > previous value.
618 6.6.8 search-memory <sizeflag> <value>
620 Searches for addresses that currently have value <value>. 
621 <sizeflag> is as in previous command.
623 6.7 Main commands
625 These commands are not available in lsnesrc, but are available 
626 after ROM has been loaded.
628 6.7.1 quit-emulator [/y]
630 Quits the emulator (asking for confirmation). If /y is given, no 
631 confirmation is asked.
633 6.7.2 pause-emulator
635 Toggle paused/unpaused
637 6.7.3 +advance-frame 
639 Advance frame. If the button is still held after configurable 
640 timeout expires, game unpauses for the duration frame advance is 
641 held.
643 6.7.4 +advance-poll 
645 Advance subframe. If the button is still held after configurable 
646 timeout expires, game unpauses for the duration frame advance is 
647 held.
649 6.7.5 advance-skiplag 
651 Skip to first poll in frame after current.
653 6.7.6 reset 
655 Reset the SNES after this frame.
657 6.7.7 load <filename> 
659 Load savestate <filename> in current mode.
661 6.7.8 load-state <filename> 
663 Load savestate <filename> in readwrite mode.
665 6.7.9 load-readonly <filename> 
667 Load savestate <filename> in readonly mode.
669 6.7.10 load-preserve <filename> 
671 Load savestate <filename> in readonly mode, preserving current 
672 events.
674 6.7.11 load-movie <filename> 
676 Load savestate <filename>, ignoring save part in readonly mode.
678 6.7.12 save-state <filename> 
680 Save system state to <filename> as soon as possible.
682 6.7.13 save-movie <filename> 
684 Save movie to <filename>.
686 6.7.14 set-rwmode 
688 Set read-write mode.
690 6.7.15 set-romode 
692 Set read-only mode
694 6.7.16 toggle-rwmode 
696 Toggle between read-only and read-write modes.
698 6.7.17 set-gamename <name> 
700 Set name of the game to <name>
702 6.7.18 get-gamename 
704 Print the name of the game.
706 6.7.19 add-author <author> 
708 Adds new author <author>. If <author> does not contain '|' it is 
709 full name. If it contains '|', '|' splits the full name and 
710 nickname.
712 6.7.20 edit-author <num> <author> 
714 Edit the author in slot <num> (0-based) to be <author> (see 
715 add-author for format)
717 6.7.21 remove-author <num> 
719 Remove author in slot <num>
721 6.7.22 print-authors 
723 Print authors.
725 6.7.23 test-1, test-2, test-3
727 Internal test commands. Don't use.
729 6.7.24 take-screenshot <filename> 
731 Save screenshot to <filename>.
733 6.7.25 +controller<num><button>
735 Press button <button> on controller <num> (1-8). The following 
736 button names are known:
738 • left
740 • right
742 • up
744 • down
746 • A
748 • B
750 • X
752 • Y
754 • L
756 • R
758 • select
760 • start
762 • trigger
764 • cursor
766 • pause
768 • turbo
770 6.7.26 controllerh<num><button>
772 Hold/unhold button <button> on controller <num> (1-8). See 
773 +controller for button names.
775 6.7.27 autofire (<pattern>|-)...
777 Set autofire pattern. Each parameter is comma-separated list of 
778 button names (in form of 1start, 1A, 2B, etc..) to hold on that 
779 frame. After reaching the end of pattern, the pattern restarts 
780 from the beginning.
782 6.7.28 repaint
784 Force a repaint.
786 6.8 Save jukebox 
788 6.8.1 cycle-jukebox-backward
790 Cycle save jukebox backwards.
792 6.8.2 cycle-jukebox-forward
794 Cycle save jukebox forwards
796 6.8.3 add-jukebox-save <filename>
798 Add <filename> to jukebox saves.
800 6.8.4 load-jukebox
802 Do load from jukebox (current mode).
804 6.8.5 save-jukebox
806 Do state save to jukebox.
808 6.9 Lua 
810 Only available if lua support is compiled in.
812 6.9.1 evaluate-lua <luacode>
814 Run Lua code <luacode> using built-in Lua interpretter.
816 6.9.2 run-lua <script>
818 Run specified lua file using built-in Lua interpretter.
820 6.10 Memory watch
822 6.10.1 add-watch <name> <expression>
824 Adds new watch (or modifies old one).
826 6.10.2 remove-watch <name>
828 Remove a watch.
830 6.11 Sound 
832 6.11.1 enable-sound <on/off> 
834 Enable/Disable sound.
836 6.11.2 set-sound-device <device> 
838 Set sound device to <device>
840 6.11.3 show-sound-status 
842 Show status of sound system.
844 6.11.4 show-sound-devices
846 Show all available devices.
848 6.12 SDL Platform commands 
850 The following are valid on SDL platform.
852 6.12.1 identify-key
854 Asks to press a key and then identifies that (pseudo-)key.
856 6.12.2 toggle-console 
858 Toggle between windowed/fullscreen console.
860 6.12.3 scroll-fullup 
862 Scroll messages window as far back as it goes.
864 6.12.4 scroll-fulldown 
866 Scroll messages window as far forward as it goes.
868 6.12.5 scroll-up 
870 Scroll messages window back one screenful.
872 6.12.6 scroll-down 
874 Scroll messages window forward one screenful.
876 7 Settings
878 7.1 Core settings
880 7.1.1 firmwarepath
882 Set where bsnes looks for firmware files. Default is “.”.
884 7.1.2 targetfps
886 Set the target fps. Numeric, range is 0.001 to “infinite”. 
887 Default is native framerate.
889 7.1.3 savecompression
891 Set save compression level (integer 0-9). Default is 7 (0 is no 
892 compression).
894 7.1.4 advance-timeout
896 Set the frame advance timeout in milliseconds. Numeric integer, 
897 range is 0-999999999. Default is 500.
899 7.2 AVI dumper settings
901 7.2.1 avi-large
903 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
904 the console outputs.
906 7.2.2 avi-left-border
908 AVI dumper: Set the default left border thickness (unless lua 
909 overrides) for dumps. Range 0-8191. Default is 0.
911 7.2.3 avi-right-border
913 AVI dumper: Set the default right border thickness (unless lua 
914 overrides) for dumps. Range 0-8191. Default is 0.
916 7.2.4 avi-top-border
918 AVI dumper: Set the default top border thickness (unless lua 
919 overrides) for dumps. Range 0-8191. Default is 0.
921 7.2.5 avi-bottom-border
923 AVI dumper: Set the default bottom border thickness (unless lua 
924 overrides) for dumps. Range 0-8191. Default is 0.
926 7.2.6 avi-maxframes
928 AVI dumper: Maximum number of frames per dump segment (0 => 
929 unlimited). Range 0-999999999. Default is 0.
931 7.2.7 avi-compresison
933 AVI dumper: Compression level (0-18).
935 • Compression levels 10 and above are not compatible with stock 
936   CSCD codec.
938 • Recomended level is 7.
940 7.2.8 avi-soundrate
942 AVI dumper: Set method of determining the sound rate.
944 • 0: Pick nearest of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, 48, 
945   64, 88.2, 96, 128, 176.4 and 192 kHz.
947 • 1: Round down to nearest integer.
949 • 2: Round up to nearest ingeter.
951 7.3 JMD options
953 7.3.1 jmd-copression
955 JMD dumper: Compression level (0-9).
957 7.4 SDL platform settings
959 7.4.1 autorepeat-first-delay
961 Sets the delay for first character in typematic autorepeat.
963 7.4.2 autorepeat-subsequent-delay
965 Sets the delay for subsequent characters in typematic autorepeat.
967 8 Lua functions
969 8.1 Core (in main table)
971 8.1.1 print
973 Print line to message console.
975 8.1.2 exec(string command)
977 Run command as it was entered on the command line
979 8.2 Table bit:
981 Bitwise logical functions and related.
983 8.2.1 bit.none(number...) / bit.bnot(number...)
985 48-bit bitwise NOT / NONE function (set bits that are set in none 
986 of the arguments).
988 8.2.2 bit.any(number...) / bit.bor(number...)
990 48-bit bitwise OR / ANY function (set bits that are set in any of 
991 the arguments).
993 8.2.3 bit.all(number...) / bit.band(number...)
995 48-bit bitwise AND / ALL function (set bits that are set in all 
996 of the arguments).
998 8.2.4 bit.parity(number...) / bit.bxor(number...)
1000 48-bit bitwise XOR / PARITY function (set bits that are set in 
1001 odd number of the arguments).
1003 8.2.5 bit.lrotate(number base[, number amount[, number bits]])
1005 Rotate bits-bit (max 48, default 48) number left by amount 
1006 (default 1) places.
1008 8.2.6 bit.rrotate(number base[, number amount[, number bits]])
1010 Rotate bits-bit (max 48, default 48) number right by amount 
1011 (default 1) places.
1013 8.2.7 bit.lshift(number base[, number amount[, number bits]])
1015 Shift bits-bit (max 48, default 48) number left by amount 
1016 (default 1) places. The new bits are filled with zeroes.
1018 8.2.8 bit.lrshift(number base[, number amount[, number bits]])
1020 Shift bits-bit (max 48, default 48) number logically right by 
1021 amount (default 1) places. The new bits are filled with zeroes.
1023 8.2.9 bit.arshift(number base[, number amount[, number bits]])
1025 Shift bits-bit (max 48, default 48) number arithmetically right 
1026 by amount (default 1) places. The new bits are shifted in with 
1027 copy of the high bit.
1029 8.3 Table gui:
1031 Most of these functions can only be called in on_paint and 
1032 on_video callbacks. Exceptions are noted.
1034 Colors are 32-bit. Bits 0-7 are the blue component, bits 8-15 are 
1035 the green component, bits 16-23 are the red component, bits 24-31 
1036 are alpha component (0 is fully opaque, 255 is almost 
1037 transparent). -1 is the fully transparent color. Alpha values 
1038 greater than 127 do work.
1040 Origin of coordinates is at top left corner of game display area. 
1041 Left and top gaps correspond to negative coordinates.
1043 8.3.1 gui.resolution()
1045 Returns 2-tuple (hresolution, vresolution).
1047 8.3.2 gui.<class>_gap(number gap)
1049 Set the <class> (left, right, top, bottom) gap to specified value 
1050 (max gap is 8191).
1052 8.3.3 gui.text(number x, number y, string text[, number fgc[, 
1053   number bgc]])
1055 Draw specified text on the GUI (each character cell is 8 or 16 
1056 wide and 16 high). Parameters:
1058 • x: X-coordinate to start the drawing from (and x-coordinate at 
1059   begining of the lines).
1061 • y: Y-coordinate to start the drawing from.
1063 • text: The text to draw.
1065 • fgc: Text color (default is 0xFFFFFF (white))
1067 • bgc: Background color (default is -1 (transparent))
1069 8.3.4 gui.textH(number x, number y, string text[, number fgc[, 
1070   number bgc]])
1072 Like gui.text, but draw using double-width.
1074 8.3.5 gui.textV(number x, number y, string text[, number fgc[, 
1075   number bgc]])
1077 Like gui.text, but draw using double-height.
1079 8.3.6 gui.textHV(number x, number y, string text[, number fgc[, 
1080   number bgc]])
1082 Like gui.text, but draw using double-width/double-height.
1084 8.3.7 gui.rectangle(number x, number y, number width, number 
1085   height[, number thickness[, number outline[, number fill]]])
1087 Draw rectangle on the GUI. Parameters:
1089 • x: X-coordinate of left edge.
1091 • y: Y-coordinate of upper edge.
1093 • width: Width of rectangle.
1095 • height: Height of rectangle.
1097 • thickness: Thickness of outline (default is 1).
1099 • outline: Color of outline (default is 0xFFFFFF (white))
1101 • fill: Color of fil (default is -1 (transparent))
1103 8.3.8 gui.pixel(number x, number y[, number color])
1105 Draw one pixel on the GUI. Parameters:
1107 • x: X-coordinate of the pixel
1109 • y: Y-coordinate of the pixel
1111 • color: Color of the pixel (default is 0xFFFFFF (white))
1113 8.3.9 gui.crosshair(number x, number y[, number length[, number 
1114   color]])
1116 Draw a crosshair. Parameters:
1118 • x: X-coordinate of the crosshair
1120 • y: Y-coordinate of the crosshair
1122 • length: Length of the crosshair lines (default 10).
1124 • color: Color of the crosshair (default is 0xFFFFFF (white))
1126 8.3.10 gui.line(number x1, number y1, number x2, number y2[, 
1127   number color])
1129 Draw a thin line. Parameters:
1131 • x1: X-coordinate of one end.
1133 • y1: Y-coordinate of one end.
1135 • x2: X-coordinate of the other end.
1137 • y2: Y-coordinate of the other end.
1139 • color: Color of the line (default is 0xFFFFFF (white)).
1141 8.3.11 gui.circle(number x, number y, number r[, number thick[, 
1142   number border[, number fil]]])
1144 Draw a circle. Parameters.
1146 • x: X-coordinate of the center
1148 • y: Y-coordinate of the center
1150 • r: The radius of the circle
1152 • thick: Border thickness
1154 • border: Border color (default is 0xFFFFFF (white))
1156 • fill: Fill color (default is -1 (transparent)).
1158 8.3.12 gui.repaint()
1160 Request on_repaint() to happen as soon as possible. Can be used 
1161 anywhere.
1163 8.3.13 gui.subframe_update(boolean on)
1165 Request subframe updates (calling on_paint() on subframes) to 
1166 happen (on=true) or not happen (on=false). Can be used anywhere.
1168 8.3.14 gui.screenshot(string filename)
1170 Write PNG screenshot of the current frame (no drawings) to 
1171 specified file. Can be used anywhere.
1173 8.3.15 gui.color(number r, number g, number b[, number a])
1175 Returns color (in notation Lua scripts use) corresponding to 
1176 color (r,g,b), each component in scale 0-255. If a is specified, 
1177 that is alpha (0 is fully transparent, 256(sic) is fully opaque). 
1178 The default alpha is 256.
1180 8.3.16 gui.status(string name, string value)
1182 Set status field “L[<name>]” to <value> in status area. Can be 
1183 used anywhere.
1185 8.4 table input
1187 Input handling. Only available in on_input callback.
1189 8.4.1 input.get(number controller, number index)
1191 Read the specified index (0-11) from specified controller (0-7). 
1192 Notes:
1194 • Uses physical controller numbering. Gamepad in port 2 is 
1195   controller 4, not 1!
1197 8.4.2 input.set(number controller, number index, number value)
1199 Write the specified index (0-11) from specified controller (0-7), 
1200 storing value. Notes:
1202 • Uses physical controller numbering. Gamepad in port 2 is 
1203   controller 4, not 1!
1205 8.4.3 input.reset([number cycles])
1207 Execute reset. If cycles is greater than zero, do delayed reset. 
1208 0 (or no value) causes immediate reset.
1210 • Only available with subframe flag false.
1212 8.4.4 input.raw()
1214 Returns table of tables of all available keys and axes. The first 
1215 table is indexed by key name (platform-dependent!), and the inner 
1216 table has the following fields:
1218 • last_rawval: Last reported raw value for control.
1220 • ktype: Type of key (disabled, key, mouse, axis, axis-inverse, 
1221   hat, pressure-m0, pressure-mp, pressure-0m, pressure-0p, 
1222   pressure-pm, pressure-p0).
1224 • cal_left: Minimum calibration value. Only meaningful with axis 
1225   and pressure types.
1227 • cal_center: Center calibration value. Only meaningful with axis 
1228   and pressure types.
1230 • cal_right: Maximum calibration value. Only meaningful with axis 
1231   and pressure types.
1233 • cal_tolerance: Dead zone tolerance. Only meaningful with axis 
1234   and pressure types.
1236 8.4.5 input.keyhook(key, state)
1238 Requests that keyhook events to be sent for key (state=true) or 
1239 not sent (state=false).
1241 8.5 Table hostmemory
1243 Host memory handling (extra memory saved to savestates). Host 
1244 memory starts empty.
1246 8.5.1 hostmemory.read(number address)
1248 Reads hostmemory slot address. Slot numbers out of range return 
1249 false instead of numeric.
1251 8.5.2 hostmemory.write(number address, number value)
1253 Writes hostmemory slot with 0-255. Slot numbers out of range 
1254 cause extension of host memory slot space.
1256 8.5.3 hostmemory.readbyte(number address)
1258 Read unsigned byte (1 element) from given address. Slots out of 
1259 range return false.
1261 8.5.4 hostmemory.writebyte(number address, number value)
1263 Write unsigned byte (1 element) to given slot. Slot numbers out 
1264 of range cause extension.
1266 8.5.5 hostmemory.readsbyte(number address)
1268 Read signed byte (1 element) from given address. Slots out of 
1269 range return false.
1271 8.5.6 hostmemory.writesbyte(number address, number value)
1273 Write signed byte (1 element) to given slot. Slot numbers out of 
1274 range cause extension.
1276 8.5.7 hostmemory.readword(number address)
1278 Read unsigned word (2 elements) from given address. Slots out of 
1279 range return false.
1281 8.5.8 hostmemory.writeword(number address, number value)
1283 Write unsigned word (2 elements) to given slot. Slot numbers out 
1284 of range cause extension.
1286 8.5.9 hostmemory.readsword(number address)
1288 Read signed word (2 elements) from given address. Slots out of 
1289 range return false.
1291 8.5.10 hostmemory.writesword(number address, number value)
1293 Write signed word (2 elements) to given slot. Slot numbers out of 
1294 range cause extension.
1296 8.5.11 hostmemory.readdword(number address)
1298 Read unsigned doubleword (4 elements) from given address. Slots 
1299 out of range return false.
1301 8.5.12 hostmemory.writedword(number address, number value)
1303 Write unsigned doubleword (4 elements) to given slot. Slot 
1304 numbers out of range cause extension.
1306 8.5.13 hostmemory.readsdword(number address)
1308 Read signed doubleword (4 elements) from given address. Slots out 
1309 of range return false.
1311 8.5.14 hostmemory.writesdword(number address, number value)
1313 Write signed doubleword (4 elements) to given slot. Slot numbers 
1314 out of range cause extension.
1316 8.5.15 hostmemory.readqword(number address)
1318 Read unsigned quadword (8 elements) from given address. Slots out 
1319 of range return false.
1321 8.5.16 hostmemory.writeqword(number address, number value)
1323 Write unsigned quadword (4 elements) to given slot. Slot numbers 
1324 out of range cause extension.
1326 8.5.17 hostmemory.readsqword(number address)
1328 Read signed quadword (8 elements) from given address. Slots out 
1329 of range return false.
1331 8.5.18 hostmemory.writesqword(number address, number value)
1333 Write signed quadword (8 elements) to given slot. Slot numbers 
1334 out of range cause extension.
1336 8.6 Table movie
1338 Movie handling
1340 8.6.1 movie.currentframe()
1342 Return number of current frame.
1344 8.6.2 movie.framecount()
1346 Return number of frames in movie.
1348 8.6.3 movie.readonly()
1350 Return true if in readonly mode, false if in readwrite.
1352 8.6.4 movie.set_readwrite()
1354 Set readwrite mode (does not cause on_readwrite callback).
1356 8.6.5 movie.frame_subframes(number frame)
1358 Count number of subframes in specified frame (frame numbers are 
1359 1-based) and return that.
1361 8.6.6 movie.read_subframe(number frame, number subframe)
1363 Read specifed subframe in specified frame and return data as 
1364 array (100 elements, numbered 0-99 currently).
1366 8.7 Table settings
1368 Routines for settings manipulation
1370 8.7.1 settings.get(string name)
1372 Get value of setting. If setting is blank, returns false. If 
1373 setting value can't be obtained, returns (nil, error message).
1375 8.7.2 settings.set(string name, string value)
1377 Set value of setting. If setting can't be set, returns (nil, 
1378 error message).
1380 8.7.3 settings.is_set(string name)
1382 Returns if setting is set. If setting does not exist, returns 
1383 (nil, error message).
1385 8.7.4 settings.blank(string name)
1387 Blanks a setting and returns true. If setting can't be blanked, 
1388 returns (nil, error message).
1390 8.8 Table memory
1392 Contains various functions for managing memory
1394 8.8.1 memory.vma_count()
1396 Returns the number of VMAs
1398 8.8.2 memory.read_vma(number index)
1400 Reads the specified VMA (indices start from zero). Trying to read 
1401 invalid VMA gives nil. The read VMA is table with the following 
1402 fields:
1404 • region_name (string): The readable name of the VMA
1406 • baseaddr (number): Base address of the VMA
1408 • lastaddr (number): Last address in the VMA.
1410 • size (number): The size of VMA in bytes.
1412 • readonly (boolean): True of the VMA corresponds to ROM.
1414 • native_endian (boolean): True if the VMA has native endian as 
1415   opposed to little endian.
1417 8.8.3 memory.find_vma(number address)
1419 Finds the VMA containing specified address. Returns table in the 
1420 same format as read_vma or nil if not found.
1422 8.8.4 memory.readbyte(number address)
1424 Reads the specified address as unsigned byte and returns the 
1425 result.
1427 8.8.5 memory.readsbyte(number address)
1429 Reads the specified address as signed byte and returns the 
1430 result.
1432 8.8.6 memory.writebyte(number address, number value)
1434 Writes the specified value (negative values undergo 2's 
1435 complement) to specified address (as a byte).
1437 8.8.7 memory.readword(number address)
1439 Reads the specified address as unsigned word and returns the 
1440 result.
1442 8.8.8 memory.readsword(number address)
1444 Reads the specified address as signed word and returns the 
1445 result.
1447 8.8.9 memory.writeword(number address, number value)
1449 Writes the specified value (negative values undergo 2's 
1450 complement) to specified address (as a word).
1452 8.8.10 memory.readdword(number address)
1454 Reads the specified address as unsigned doubleword and returns 
1455 the result.
1457 8.8.11 memory.readsdword(number address)
1459 Reads the specified address as signed doubleword and returns the 
1460 result.
1462 8.8.12 memory.writedword(number address, number value)
1464 Writes the specified value (negative values undergo 2's 
1465 complement) to specified address (as a doubleword).
1467 8.8.13 memory.readqword(number address)
1469 Reads the specified address as unsigned quadword and returns the 
1470 result.
1472 8.8.14 memory.readsqword(number address)
1474 Reads the specified address as signed quadword and returns the 
1475 result.
1477 8.8.15 memory.writeqword(number address, number value)
1479 Writes the specified value (negative values undergo 2's 
1480 complement) to specified address (as a quadword).
1482 8.9 Table _SYSTEM
1484 Contains copy of global variables from time of Lua 
1485 initialization. Non-writeable.
1487 8.10 Callbacks
1489 Various callbacks to Lua that can occur.
1491 8.10.1 Callback: on_paint()
1493 Called when screen is being painted. Any gui.* calls requiring 
1494 graphic context draw on the screen.
1496 8.10.2 Callback: on_video()
1498 Called when video dump frame is being painted. Any gui.* calls 
1499 requiring graphic context draw on the video.
1501 8.10.3 Callback: on_frame()
1503 Called on each starting whole frame.
1505 8.10.4 Callback: on_startup()
1507 Called when the emulator is starting (lsnes.rc and --run files 
1508 has been run).
1510 8.10.5 Callback: on_pre_load(string name)
1512 Called just before savestate/movie load occurs (note: loads are 
1513 always delayed, so this occurs even when load was initiated by 
1514 lua).
1516 8.10.6 Callback: on_err_load(string name)
1518 Called if loadstate goes wrong.
1520 8.10.7 Callback: on_post_load(string name, boolean was_savestate)
1522 Called on successful loadstate. was_savestate gives if this was a 
1523 savestate or a movie.
1525 8.10.8 Callback: on_pre_save(string name, boolean is_savestate)
1527 Called just before savestate save occurs (note: movie saves are 
1528 synchronous and won't trigger these callbacks if called from 
1529 Lua).
1531 8.10.9 Callback: on_err_save(string name)
1533 Called if savestate goes wrong.
1535 8.10.10 Callback: on_post_save(string name, boolean is_savestate)
1537 Called on successful savaestate. is_savestate gives if this was a 
1538 savestate or a movie.
1540 8.10.11 Callback: on_quit()
1542 Called when emulator is shutting down.
1544 8.10.12 Callback: on_input(boolean subframe)
1546 Called when emulator is just sending input to bsnes core. 
1547 Warning: This is called even in readonly mode, but the results 
1548 are ignored.
1550 8.10.13 Callback: on_reset()
1552 Called when SNES is reset.
1554 8.10.14 Callback: on_readwrite()
1556 Called when moving into readwrite mode as result of “set-rwmode” 
1557 command (note: moving to rwmode by Lua won't trigger this, as per 
1558 recursive entry protection).
1560 8.10.15 Callback: on_snoop(number port, number controller, number 
1561   index, number value)
1563 Called each time bsnes asks for input. The value is the final 
1564 value to be sent to bsnes core (readonly mode, autohold and 
1565 autofire have been taken into account). Might be useful when 
1566 translating movies to format suitable for console verification. 
1567 Note: There is no way to modify the value to be sent.
1569 8.10.16 Callback: on_keyhook(string keyname, table state)
1571 Sent when key that has keyhook events requested changes state. 
1572 Keyname is name of the key (group) and state is the state (same 
1573 kind as table values in input.raw).
1575 9 Memory watch expression syntax
1577 Memory watch expressions are in RPN (Reverse Polish Notation). At 
1578 the end of expression, the top entry on stack is taken as the 
1579 final result.
1581 Notations:
1583 • Evaluation order is strictly left to right.
1585 • a is the entry on top of stack
1587 • b is the entry immediately below top of stack
1589 • ; separates values to be pushed (no intermediate pop).
1591 • After end of element, all used stack slots are popped and all 
1592   results are pushed.
1594 • When pushing multiple values, the pushes occur in order shown.
1596 The following operators are available:
1598 • + : a + b
1600 • - : a - b
1602 • * : a * b
1604 • / : a / b
1606 • % : a % b
1608 • a : atan(a)
1610 • b : read_signed_byte(a)
1612 • c : cos(a)
1614 • d : read_signed_dword(a)
1616 • i : quotent(a / b)
1618 • p :\pi
1621 • q : read_signed_qword(a)
1623 • r : sqrt(a)
1625 • s : sin(a)
1627 • t : tan(a)
1629 • u : a; a
1631 • w : read_signed_word(a)
1633 • A : atan2(a, b)
1635 • B : read_unsigned_byte(a)
1637 • C<number>z : Push number <number> to stack.
1639 • D : read_unsigned_dword(a)
1641 • C0x<number>z : Push number <number> (hexadecimal) to stack.
1643 • Q : read_unsigned_qword(a)
1645 • R<digit> : round a to <digit> digits.
1647 • W : read_unsigned_word(a)
1649 9.1 Example:
1651 C0x007e0878zWC0x007e002czW-
1653 1. Push value 0x7e0878 on top of stack (C0x007e0878z).
1655 2. Pop the value on top of stack (0x7e0878), read word value at 
1656   that address and push the result,call it x1 (W).
1658 3. Push value 0x7e002c on top of stack (C0x007e002cz).
1660 4. Pop the value on top of stack (0x7e002c), read word value at 
1661   that address and push the result,call it x2 (W).
1663 5. Pop the two top numbers on stack, x1 and x2, substract x1 from 
1664   x2 and push x2 - x1 (-).
1666 6. Since the expression ends, the final memory watch result is 
1667   the top one on stack, which is x2 - x1.
1669 10 Modifier and key names:
1671 10.1 SDL Platform
1673 10.1.1 Modifier names
1675 Following modifier names are known:
1677 • ctrl, lctrl, rctrl: Control keys
1679 • alt, lalt, ralt: ALT keys.
1681 • shift, lshift, rshift: Shift keys.
1683 • meta, lmeta, rmeta: Meta keys.
1685 • num, caps: Numlock/Capslock (these are sticky!)
1687 • mode: Mode select.
1689 10.1.2 Key names
1691 Following key names are known:
1693 • backspace, tab, clear, return, pause, escape, space, exclaim, 
1694   quotedbl, hash, dollar, ampersand, quote, leftparen, 
1695   rightparen, asterisk, plus, comma, minus, period, slash, 0, 1, 
1696   2, 3, 4, 5, 6, 7, 8, 9, colon, semicolon, less, equals, 
1697   greater, question, at, leftbracket, backslash, rightbracket, 
1698   caret, underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, 
1699   l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, delete, world_0, 
1700   world_1, world_2, world_3, world_4, world_5, world_6, world_7, 
1701   world_8, world_9, world_10, world_11, world_12, world_13, 
1702   world_14, world_15, world_16, world_17, world_18, world_19, 
1703   world_20, world_21, world_22, world_23, world_24, world_25, 
1704   world_26, world_27, world_28, world_29, world_30, world_31, 
1705   world_32, world_33, world_34, world_35, world_36, world_37, 
1706   world_38, world_39, world_40, world_41, world_42, world_43, 
1707   world_44, world_45, world_46, world_47, world_48, world_49, 
1708   world_50, world_51, world_52, world_53, world_54, world_55, 
1709   world_56, world_57, world_58, world_59, world_60, world_61, 
1710   world_62, world_63, world_64, world_65, world_66, world_67, 
1711   world_68, world_69, world_70, world_71, world_72, world_73, 
1712   world_74, world_75, world_76, world_77, world_78, world_79, 
1713   world_80, world_81, world_82, world_83, world_84, world_85, 
1714   world_86, world_87, world_88, world_89, world_90, world_91, 
1715   world_92, world_93, world_94, world_95, kp0, kp1, kp2, kp3, 
1716   kp4, kp5, kp6, kp7, kp8, kp9, kp_period, kp_divide, 
1717   kp_multiply, kp_minus, kp_plus, kp_enter, kp_equals, up, down, 
1718   right, left, insert, home, end, pageup, pagedown, f1, f2, f3, 
1719   f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, numlock, 
1720   capslock, scrollock, rshift, lshift, rctrl, lctrl, ralt, lalt, 
1721   rmeta, lmeta, lsuper, rsuper, mode, compose, help, print, 
1722   sysreq, break, menu, power, euro, undo
1724 • Names of form 'key<n>' where <n> is 0-255 are interpretted as 
1725   key having hardware-dependent scan code of <n> (useful to bind 
1726   those keys that don't have symbolic names).
1728 10.1.3 Joystick pseudo-keys:
1730 • joystick<num>button<button>: Joystick <num> (0-based) button 
1731   <button> (0-based).
1733 • joystick<num>hat<hat>n: Joystick <num> (0-based) hat <hat> 
1734   (0-based) up.
1736 • joystick<num>hat<hat>w: Joystick <num> (0-based) hat <hat> 
1737   (0-based) left.
1739 • joystick<num>hat<hat>s: Joystick <num> (0-based) hat <hat> 
1740   (0-based) down.
1742 • joystick<num>hat<hat>e: Joystick <num> (0-based) hat <hat> 
1743   (0-based) right.
1745 • joystick<num>axis<axis>-: Joystick <num> (0-based) axis <axis> 
1746   negative position (axis modes axis and axis_inverse).
1748 • joystick<num>axis<axis>+: Joystick <num> (0-based) axis <axis> 
1749   positive position (axis modes axis and axis_inverse).
1751 • joystick<num>axis<axis>: Joystick <num> (0-based) axis <axis> 
1752   pressure (axis modes pressure_*).
1754 10.1.4 Special buttons:
1756 • Escape: Enter/Exit Command mode, cancel modal dialogs.
1758 • Return (also KPEnter): Execute command, ok modal dialog.
1760 • Pgup/Up (also KP8/9 if no num lock; command mode): Previous 
1761   command in command history
1763 • Pgdn/Down(also KP2/3 if no num lock; command mode): Next 
1764   command in command history
1766 • Home (also KP7 if no num lock; command mode): Beginning of 
1767   command.
1769 • End (also KP1 if no num lock; command mode): End of command.
1771 • Left (also KP4 if no num lock; command mode): Move cursor left.
1773 • Right (also KP6 if no num lock; command mode): Move cursor 
1774   right.
1776 • Delete (also KP. if no num lock; command mode): Delete 
1777   character to right of cursor.
1779 • Insert (also KP0 if no num lock; command mode): Toggle between 
1780   insert / overwrite modes.
1782 • Backspace (command mode): Delete character to left of cursor.
1784 • LCTRL+LALT+ESCAPE: Ungraceful shutdown (leaves dump 
1785   corrupted!).
1787 10.2 wxWidgets platform
1789 10.2.1 Modifier names:
1791 Following modifier names are known:
1793 • alt
1795 • ctrl
1797 • shift 
1799 • meta
1801 • cmd (Mac OS X only)
1803 10.2.2 Key names:
1805 Following key names are known:
1807 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
1808   dollar, percent, ampersand, quote, leftparen, rightparen, 
1809   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
1810   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
1811   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
1812   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
1813   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
1814   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
1815   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
1816   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
1817   home, lefT, up, right, down, select, print, execute, snapshot, 
1818   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
1819   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
1820   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
1821   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
1822   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
1823   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
1824   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
1825   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
1826   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
1827   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
1828   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
1829   windows_right, windows_menu, command, special1, special2, 
1830   special3, special4, special5, special6, special7, special8, 
1831   special9, special10, special11, special12, special13, 
1832   special14, special15, special16, special17, special18, 
1833   special19, special20
1835 11 Movie file format
1837 Movie file is .zip archive in itself, normal ZIP archive tools 
1838 work on it (note: If you recompress it, do not use compression 
1839 methods other than store and deflate and especially do not use 
1840 encryption of any kind).
1842 11.1 Detecting clean start/SRAM/Savestate
1844 • If file has member “savestate” it is savestate, otherwise:
1846 • If file has members with names starting “moviesram.” it is 
1847   movie starting from SRAM, otherwise:
1849 • It is movie starting from clear state.
1851 11.2 Member: gametype
1853 Type of game ROM and region (as one line). Valid values are:
1856 +--------------+---------------------+--------+
1857 |    Value     |       System        | Region |
1858 +--------------+---------------------+--------+
1859 +--------------+---------------------+--------+
1860 |  snes_pal    |     Super NES       |  PAL   |
1861 +--------------+---------------------+--------+
1862 |   sgb_pal    |   Super Game Boy    |  PAL   |
1863 +--------------+---------------------+--------+
1864 |  snes_ntsc   |     Super NES       |  NTSC  |
1865 +--------------+---------------------+--------+
1866 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
1867 +--------------+---------------------+--------+
1868 |     bsx      | BS-X (non-slotted)  |  NTSC  |
1869 +--------------+---------------------+--------+
1870 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
1871 +--------------+---------------------+--------+
1872 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
1873 +--------------+---------------------+--------+
1876 Frame rates are:
1879 +---------+-----------------+
1880 | Region  | Framerate (fps) |
1881 +---------+-----------------+
1882 +---------+-----------------+
1883 |  PAL    |   322445/6448   |
1884 +---------+-----------------+
1885 |  NTSC   | 10738636/178683 |
1886 +---------+-----------------+
1889 11.3 Member: port1
1891 Contains type of port #1 (as one line). Valid values are 'none', 
1892 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
1893 'gamepad'.
1895 11.4 Member: port2
1897 Contains type of port #2 (as one line). Valid values are 'none', 
1898 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
1899 'justifiers'. If not present, defaults to 'none'.
1901 11.5 Member: gamename
1903 Contains name of the game (as one line).
1905 11.6 Member: authors
1907 Contains authors, one per line. Part before '|' is the full name, 
1908 part after is the nickname.
1910 11.7 Member: systemid
1912 Always “lsnes-rr1” (one line). Used to reject other saves.
1914 11.8 Member: controlsversion
1916 Always “0” (one line). Used to identify what controls are there.
1918 11.9 Member: “coreversion”
1920 Contains bsnes core version number (as one line).
1922 11.10 Member: projectid
1924 Contains project ID (as one line). Used to identify if two movies 
1925 are part of the same project.
1927 11.11 Member: {rom,slota,slotb}{,xml}.sha256
1929 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
1930 Absent if corresponding file is absent.
1932 11.12 Member: moviesram.<name>
1934 Raw binary startup SRAM of kind <name>. Only present in 
1935 savestates and movies starting from SRAM.
1937 11.13 Member: saveframe
1939 Contains frame number (as one line) of frame movie was saved on. 
1940 Only present in savestates.
1942 11.14 Member: lagcounter
1944 Current value of lag counter (as one line). Only present in 
1945 savestates.
1947 11.15 Member: pollcounters
1949 Contains poll counters (currently 100 of them), one per line. 
1950 Each line is raw poll count if DRDY is set for it. Otherwise it 
1951 is negative poll count minus one. Only present in savestates.
1953 11.16 Member: hostmemory
1955 Raw binary dump of host memory. Only present in savestates.
1957 11.17 Member: savestate
1959 The raw binary savestate itself. Savestate detection uses this 
1960 file, only present in savestates.
1962 11.18 Member: screenshot
1964 Screenshot of current frame. Only present in savestates. First 2 
1965 bytes are big-endian width of image, rest are 24-bit RGB image 
1966 data. Height of image is inferred from the width and size of 
1967 data.
1969 11.19 Member: sram.<name>
1971 Raw binary SRAM of kind <name> at time of savestate. Only present 
1972 in savestates.
1974 11.20 Member: input
1976 The actual input track, one line per subframe (blank lines are 
1977 skipped).
1979 • If the first byte of each line is '.', ' ', <tab> or '|', then 
1980   the line is part of same frame as previous, otherwise it starts 
1981   a new frame.
1983 • First subframe must start a new frame.
1985 Length of movie in frames is number of lines in input file that 
1986 start a new frame.
1988 11.21 Member: rerecords
1990 Contains textual base-10 rerecord count (as one line; emulator 
1991 just writes this, it doesn't read it) + 1.
1993 11.22 Member: rrdata
1995 This member stores set of load IDs. There is one load ID per 
1996 rerecord (plus one corresponding to start of project).
1998 • This member constists of concatenation of records
2000 • Each record is 2-36 bytes long and can represent 1-16,843,009 
2001   consequtive IDs.
2003 • IDs are interpretted as 256-bit big-endian integers with 
2004   warparound.
2006 • Initial predicted ID is all zeroes.
2008 Format of each record is:
2010 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
2011   bits 5-6 are count length (countlen). Bit 7 is unused.
2013 • 32-prefixlen bytes of ID.
2015 • countlen bytes of big-endian count (count).
2017 Records are processed as follows:
2019 • To form the first ID encoded by record, take the first 
2020   prefixlen bytes predicted ID and append the read ID value to 
2021   it. The result is the first ID encoded.
2023 • If countlen is 0, record encodes 1 ID.
2025 • If countlen is 1, record encodes 2+count IDs.
2027 • If countlen is 2, record encodes 258+count IDs.
2029 • If countlen is 3, record encodes 65794+count IDs.
2031 • The new predicted ID is the next ID after last one encoded by 
2032   the record.
2034 The number of rerecords + 1 is equal to the sum of number of IDs 
2035 encoded by all records.
2037 11.23 Member: starttime.second
2039 Movie starting time, second part. Epoch is Unix epoch. Default is 
2040 1,000,000,000.
2042 11.24 Member: starttime.subsecond
2044 Movie starting time, subsecond part. Unit is CPU clocks. Default 
2045 is 0.
2047 11.25 Member: savetime.second
2049 Movie saving time, second part. Default is starttime.second. Only 
2050 present in savestates.
2052 11.26 Member: savetime.subsecond
2054 Movie saving time, subsecond part. Default is 
2055 starttime.subsecond. Only present in savestates.
2057 12 Quick'n'dirty encode guide
2059 1. Start the emulator and load the movie file.
2061 2. Set large AVI option 'set-setting avi-large on'
2063 3. Enable dumping 'dump-avi tmpdump' 
2065 4. Unpause and let it run until you want to end dumping.
2067 5. Close the emulator (closing the window is the easiest way). Or 
2068   use 'end-avi'.
2070 6. For each tmpdump*.avi file created, on command prompt, do 
2071   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
2073 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
2075 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
2076   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
2077   tmpdump_<numbers>.mkv, with + in between).
2079 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
2080   final.mkv contains quick'n'dirty encode.
2082 13 Axis configurations for some gamepad types:
2084 13.1 XBox360 controller:
2086 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
2087 set to pressure-+.
2089 set-axis joystick0axis2 pressure-+
2091 set-axis joystick0axis5 pressure-+
2093 • This is needed for SDL only. EVDEV sets those types correctly.
2095 13.2 PS3 “sixaxis” controller:
2097 Axes 8-19 should be disabled.
2099 set-axis joystick0axis8 disabled
2101 set-axis joystick0axis9 disabled
2103 set-axis joystick0axis10 disabled
2105 set-axis joystick0axis11 disabled
2107 set-axis joystick0axis12 disabled
2109 set-axis joystick0axis13 disabled
2111 set-axis joystick0axis14 disabled
2113 set-axis joystick0axis15 disabled
2115 set-axis joystick0axis16 disabled
2117 set-axis joystick0axis17 disabled
2119 set-axis joystick0axis18 disabled
2121 set-axis joystick0axis19 disabled
2123 14 Errata:
2125 14.1 Problems from BSNES core:
2127 • The whole pending save stuff.
2129 • Lack of layer hiding.
2131 • It is slow (especially accuracy).
2133 • Firmwares can't be loaded from ZIP archives.
2135 14.2 Other problems:
2137 • Modifiers don't work with pseudo-keys (SDL, EVDEV).
2139 • Audio for last dumped frame is not itself dumped.
2141 • Audio in UI is pretty bad in quality if game doesn't run at 
2142   full speed.
2144 • AVI compression levels 10-18 are not compatible with AVISynth 
2145   AVISource.
2147 • No menus, command based interface (SDL).
2149 • Long commands don't scroll.
2151 • Wxwidgets UI is still buggy.
2153 15 Changelog:
2155 15.1 rr0-beta1
2157 • Fix -Wall warnings
2159 • Fix dumper video corruption with levels 10-18.
2161 15.2 rr0-beta2
2163 • Autofire
2165 • Lots of code cleanups
2167 • Lua interface to settings
2169 • Allow specifying AVI borders without Lua
2171 • Fix scaling if vscale > 1 and originx > 0 (left border exists)
2173 • on_snoop lua callback
2175 • Faster movie loading and saving.
2177 15.3 rr0-beta3
2179 • Joystick support
2181 15.4 rr0-beta4
2183 • Fix multi-buttons
2185 • Save jukebox functionality.
2187 15.5 rr0-beta5
2189 • Try to fix some nasty failing movie load edge cases
2191 • Allow specifying scripts to run on command line.
2193 15.6 rr0-beta6
2195 • Major source code reorganization.
2197 • Backup savestates before overwriting.
2199 • Don't crash if loading initial state fails.
2201 15.7 rr0-beta7
2203 • Fix firmware lookup
2205 • Fix author name parsing
2207 • Fix rerecord counting
2209 • (SDL) Print messages to console if SDL is uninitialized
2211 • Add movieinfo program
2213 • Fix loading movies starting from SRAM.
2215 15.8 rr0-beta8
2217 • Add support for unattended dumping
2219 • Fix compiling for Win32
2221 • Don't lock up if sound can't be initialized
2223 • Strip trailing CR from commands
2225 • Don't try to do dubious things in global ctors (fix crash on 
2226   startup)
2228 15.9 rr0-beta9
2230 • Small documentation tweaking
2232 • Fix make clean
2234 • Fix major bug in modifier matching
2236 15.10 rr0-beta10
2238 • Lots of documentation fixes
2240 • Use dedicated callbacks for event backcomm., not commands.
2242 • Ensure that the watchdog is not hit when executing delayed 
2243   reset.
2245 • Remove errant tab from joystick message.
2247 15.11 rr0-beta11
2249 • Make autofire operate in absolute time, not linear time
2251 • Reinitialize controls when resuming from loadstate
2253 • Some more code cleanups
2255 • If Lua allocator fails, call OOM_panic()
2257 • Byte/word/dword/qword sized host memory write/read functions.
2259 • Dump at correct framerate if dumping interlaced NTSC 
2260   (height=448).
2262 15.12 rr0-beta12
2264 • Actually include the complete source code
2266 • Keep track of RTC
2268 15.13 rr0-beta13
2270 • Document {save,start}time.{,sub}second.
2272 • Intercept time() from bsnes core.
2274 15.14 rr0-beta14
2276 • Allow disabling time() interception (allow build on Mac OS X)
2278 • Use SDLMain on Mac OS X (make SDL not crash)
2280 • Disable delayed resets (just plain too buggy for now).
2282 • Code cleanups
2284 • Use 16-bit for graphics/video instead of 32-bit.
2286 • gui.rectangle/gui.pixel
2288 • gui.crosshair
2290 • New CSCD writer implementation.
2292 15.15 rr0-beta15
2294 • Fix interaction of * and +.
2296 • Manual improvements
2298 • Use gettimeofday()/usleep(), these seem portable enough.
2300 • Move joystick axis manipulation to keymapper code.
2302 • Changes to how read-only works.
2304 • Refactor controller input code.
2306 15.16 rr0-beta16
2308 • Fix mouseclick scale compensation.
2310 • Draw area boundaries correctly in SDL code.
2312 • gui.screenshot.
2314 • Fix CSCD output (buffer overrun and race condition).
2316 15.17 rr0-beta17
2318 • JMD dumping support.
2320 • Allow unattended dumping to JMD.
2322 • Move to BSNES v083.
2324 • Switch back to 32-bit colors.
2326 • Add Lua function gui.color.
2328 • Use some new C++11 features in GCC 4.6.
2330 • Be prepared for core frequency changes.
2332 • Pass colors in one chunk from Lua.
2334 15.18 rr0-beta18
2336 • New lua functions gui.line(), gui.status() and gui.circle(), 
2337   memory.vma_count(), memory.read_vma() and memory.find_vma().
2339 • Numerious documentation fixups
2341 • RTC time format changed
2343 • Reformat flags display
2345 • Allow lua package name to be overridden
2347 • SDUMP (high-quality dumping).
2349 • Split platform support to plugins.
2351 • Make all sound plugins support basic sound commands
2353 • Support portaudio for sound.
2355 • Allow disable Lua/SDL searching.
2357 • Upconvert colors when copying lcscreen to screen.
2359 • Reorganize source tree.
2361 • Evdev joystick support.
2363 • Refactor more code into generic window code.
2365 15.19 rr0-beta19
2367 • Refactor message handling.
2369 • Rework makefile
2371 • Documentation fixes
2373 • Finish pending saves before load/quit.
2375 • Wxwidgets graphics plugin.
2377 15.20 rr0-beta20
2379 • Get rid of win32-crap.[ch]pp.
2381 • Move files around a lot.
2383 • Get rid of need for host C++ compiler.
2385 • Bsnes v084 core.
2387 • Refactor inter-component communication.
2389 • Fix zero luma.
2391 • Fix crash on multiline aliases.
2393 • Load/Save settings in wxwidgets gui.
2395 15.21 rr0-beta21
2397 • Patch problems in bsnes core
2399 • SNES is little-endian, not big-endian!
2401 • Fix memory corruption in lcscreen::load()
2403 15.22 rr0-beta22
2405 • Fix interpretting repeat counts in rrdata loading.
2407 • New lua callback: on_frame()
2409 • Remove calls to runtosave() that aren't supposed to be there
2411 • Lua function: movie.read_rtc()
2413 • Ignore src/fonts/font.cpp
2415 • Fix more bsnes core problems
2417 • Control bsnes random seeding
2419 • Pause-on-end
2421 • Some bsnes core debugging features (state dump and state hash)
2423 • Fix titlebar version number (no, the last version wasn't 
2424   'lsnes-0-beta21', it was 'lsnes rr0-beta21').
2426 15.23 rr0-beta23
2428 • Fix memory corruption due to macro/field mixup
2430 • search-memory update
2432 • Allow direct-mapped framebuffer
2434 • SDL: Use SDL_ANYFORMAT if possible
2436 • SDMP2SOX: 2s delay modes.
2438 • Wxwidgets: Cleanups
2440 • Use sed -E, not sed -r. Fixes building on Mac OS X.
2442 • Wxwidgets: Save jukebox on exit
2444 • Fix RTC if using load-movie on savestate.
2446 • Fix crash related to full console mode.
2448 15.24 rr0-beta24
2450 • Wxwidgets: Allow bringing application to foreground on Mac OS 
2451   X.
2453 • Wxwidgets: Allow compiling on Mac OS X.
2455 • Use movie compare instead of movie hashing (faster save/load).
2457 • Lua: _SYSTEM table.
2459 15.25 rr0-beta25
2461 • sdmp2sox: Pad soundtrack if using -l or -L.
2463 • sdmp2sox: Fix NTSC overscan.
2465 • sdmp2sox: Add AR correction mode.
2467 • call lua_close() when exiting.
2469 • Fix zip_writer bug causing warnings from info-zip and error 
2470   from advzip.
2472 15.26 rr0-beta26
2474 • Fix IPS patching code (use bsnes core IPS patcher).
2476 • Implement BPS patching (using bsnes core IPS patcher).
2478 • Add feature to load headered ROMs.
2480 15.27 rr0-beta27
2482 • Show command names when showing keybindings
2484 15.28 rr0
2486 • Fix pause-on-end to be actually controllable
2488 • SDL: Poll all events in queue, not just first one (fixes 
2489   slowness in command typing)
2491 • Wxwidgets: Fix ROM loading.
2493 15.29 rr1-beta0
2495 • Lua: Add gui.textH, gui.textV, gui.textHV
2497 • Fix text colors on SDL on Mac OS X
2499 • Mode 'F' for finished in readonly mode.
2501 • Fix some WS errors.
2503 • Reliably pause after skip poll
2505 • Split UI and core into their own threads
2507 15.30 rr1-beta1
2509 • Remove leftover dummy SRAM slot
2511 • Fix controller numbers.
2513 15.31 rr1-beta2
2515 • Fix lsnes-dumpavi after interface change.
2517 • Also give BSNES patches for v085.
2519 • Pack movie data in memory.
2521 15.32 rr1-beta3
2523 • Fix framecount/length given when loading movies.
2525 • Controller command memory leak fixes.
2527 • Don't leak palette if freeing screen object.
2529 15.33 rr1-beta4
2531 • Detect revisions.
2533 • Wxwidgets: Allow controlling dumper from the menu.
2535 15.34 rr1-beta5
2537 • Rewrite parts of manual
2539 • Lua: Make it work with Lua 5.2.
2541 15.35 rr1-beta6
2543 • Win32: Fix compile errors.
2545 15.36 rr1-beta7
2547 • Refactor controller input code.
2549 • Fix crash when using command line on SDL / Mac OS X.
2551 15.37 rr1-beta8
2553 • Delete core/coroutine (obsolete)
2555 • Lag input display by one frame.
2557 • Rewind movie to beginning function.
2559 • Fix wrong frame number reported to Lua when repainting after 
2560   loadstate
2562 • Support UI editing of jukebox
2564 • Wxwidgets: Save settings on exit.
2566 • Support ${project} for filenames
2568 • SDL: Fix command history
2570 15.38 rr1-beta9
2572 • Fix some order-of-global-ctor bugs.
2574 15.39 rr1-beta10
2576 • Fix crashes when quitting on Win32.
2578 15.40 rr1-beta11
2580 • EVDEV: Queue keypresses from joystick, don't send directly
2582 • Wxwidgets: Load-Preserve that actually works.
2584 15.41 rr1-beta12
2586 • Wxwidgets: GUI for memory search.
2588 • Warn about using synchronous queue in UI callback.
2590 15.42 rr1-beta13
2592 • Remember last saved file for each ROM
2594 • Support MT dumping via boost.
2596 • Lua: input.raw
2598 • Lua: input.keyhook
2600 • Make mouse be ordinary input instead of special-casing
2602 • SDL: Don't screw up commands with NUL codepoints.
2604 15.43 rr1-beta14
2606 • Merge status panel and main window
2608 • True movie slot support (the rest of it)
2610 • SDL: Fix compilation error
2612 • Elminate cross calls in dump menu code.
2614 15.44 rr1-beta15
2616 • Cancel pending saves command
2618 • Wxwidgets: Code refactoring
2620 • Wxwidgets: Fix system -> reset
2622 • Wxwidgets: Read watch expressions in the right thread
2624 15.45 rr1-beta16
2626 • Wxwidgets: Don't prompt for member when running Lua script (Lua 
2627   doesn't support that).
2629 • Wxwidgets: 128 -> 1024 Autohold slots (in case more are 
2630   needed).
2632 • Don't append trailing '-' to prefix when saving movie.
2634 • Fix ROM/savestate handling (don't let user mismatch ROM and 
2635   savestates).
2637 15.46 rr1
2639 • Document memory watch syntax.
2641 15.47 rr1-delta1
2643 • Fix unattended dumping (lsnes-dumpavi)
2645 • Support RAW dumping
2647 • Use adv_dumper instead of the old interface in lsnes-dumpavi 
2648   (changes syntax)
2650 • Add option to control sample rate preturbation in AVI dumper
2652 15.48 rr1-delta2
2654 • Wxwidgets: Fix dumper submodes
2656 • Set core controller types before loadstate
2658 15.49 rr1-delta2epsilon1
2660 • Fix compiling with bsnes v086.