Lua: New function input.raw, which gives data for all buttons
[lsnes.git] / manual.txt
blob55f4adedd5ffc0e3f6fdebc95627d9f50830e5fa
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 --prefix=<prefix>
318 Set dump prefix. Default is “avidump”.
320 4.4.2 --level=<level>
322 Set compression level (0-18). Default is 7.
324 4.4.3 --length=<length>
326 Set number of frames to dump. Mandatory.
328 4.4.4 --lua=<script>
330 Run specified lua script (lsnes-dumpavi does not have 
331 initialization files).
333 4.4.5 --jmd
335 Use JMD dumping instead of AVI dumping.
337 4.4.6 --sdmp
339 Use SDMP dumping instead of AVI dumping.
341 4.4.7 --ss
343 Dump in single segment (SDMP only).
345 5 Startup file lsnes.rc
347 Upon startup, lsnes (lsnes/SDL only) executes file lsnes.rc as 
348 commands. This file is located in:
350 • Windows: %APPDATA%\lsnes\lsnes.rc (if %APPDATA% exists)
352 • Unix: $XDG_CONFIG_HOME/lsnes/lsnes.rc (if $XDG_CONFIG_HOME 
353   exists)
355 • Unix: $HOME/.config/lsnes/lsnes.rc (if $HOME exists)
357 • All: ./lsnes.rc (fallback default).
359 If leading directories do not exist, attempt to create them is 
360 made.
362 6 Internal commands
364 • Commands beginning with '*' invoke the corresponding command 
365   without alias expansion.
367 • If command starts with '+' (after possible '*'), the command is 
368   executed as-is when button is pressed, and when button is 
369   released, it is executed with '+' replaced by '-'.
371 • Commands without '+' execute only on negative edge (release).
373 6.1 Settings:
375 Settings control various aspects of emulator behaviour.
377 6.1.1 set-setting <setting> <value>
379 Sets setting <setting> to value <value> (may be empty).
381 6.1.2 unset-setting <setting>
383 Try to unset setting <setting> (not all settings can be unset).
385 6.1.3 get-setting <setting>
387 Read value of setting <setting>
389 6.1.4 show-settings
391 Print names and values of all settings.
393 6.2 Keybindings
395 Keybindings bind commands or aliases to keys (or pseudo-keys). 
397 Notes:
399 • Do not bind edge active (+/-) commands to keys with modifiers, 
400   that won't work right!
402 • Names of keys and modifiers are platform-dependent.
404 • Be careful before binding pseudo-keys (such as joystick axes, 
405   buttons or hats) with modifiers. That may or may not work 
406   right.
408 6.2.1 bind-key [<mod>/<modmask>] <key> <command>
410 Bind <command> to key <key> (activating if modifiers in <modmask> 
411 (comma-seperated list) are set as <mod> (comma-seperated list).
413 The names of keys and modifiers are platform-dependent.
415 6.2.2 unbind-key [<mod>/<modmask>] <key>
417 Unbind command from <key> (with specified <mod> and <modmask>).
419 6.2.3 set-axis <axis> [disabled | axis | axis-inverse | 
420   pressure0- | pressure0+ | pressure-0 | pressure-+ | pressure+0 
421   | pressure+-] [minus=<val>] [zero=<val>] [plus=<val>] 
422   [tolerance=<val>]
424 Set axis parameters for axis <axis>.
426 • disabled: Disable axis
428 • axis: Normal axis
430 • axis-inverse: Inverse axis
432 • pressure0-: Pressure sensitive. Released at 0, pressed at -.
434 • pressure0+: Pressure sensitive. Released at 0, pressed at +.
436 • pressure-0: Pressure sensitive. Released at -, pressed at 0.
438 • pressure-+: Pressure sensitive. Released at -, pressed at +.
440 • pressure+0: Pressure sensitive. Released at +, pressed at 0.
442 • pressure+-: Pressure sensitive. Released at +, pressed at -.
444 • minus=<val>: Calibration at extreme minus position 
445   (-32768-32767)
447 • zero=<val>: Calibration at neutral position (-32768-32767)
449 • plus=<val>: Calibration at extreme plus position (-32768-32767)
451 • tolerance=<value>: Center band tolerance (0<x<1). The smaller 
452   the value, the more sensitive the control is.
454 6.2.4 show-bindings
456 Print all key bindings in effect.
458 6.3 Aliases
460 Aliases bind command to sequence of commands. After alias has 
461 been defined, it replaces the command it shadows.
463 Notes:
465 • You can't alias command to itself.
467 • Aliases starting with +/- are edge active just like ordinary 
468   commands starting with +/-.
470 • One command can be aliased to multiple commands.
472 6.3.1 alias-command <command> <expansion>
474 Append <expansion> to alias <command>. If alias does not already 
475 exist, it is created.
477 6.3.2 unalias-command <command>
479 Clear alias expansion for <command>.
481 6.3.3 show-aliases
483 Print all aliases and their expansions in effect.
485 6.4 run-script <script>
487 Run <script> as if commands were entered on the command line.
489 6.5 Video dumping
491 Following commands control video dumping:
493 6.5.1 dump-avi <prefix>
495 Dump AVI video to prefix <prefix> Notes:
497 • The codec is Camstudio Codec in gzip mode.
499 • Encoder and muxer are internal, available on all platforms.
501 • Audio enable/disable and framerate has no effect.
503 • The audio dumped to .avi is low-quality version. The 
504   high-quality version is dumped to .sox file.
506 6.5.2 end-avi
508 End current AVI video dump (closing the emulator also closes the 
509 dump).
511 6.5.3 dump-jmd <file>
513 Dump JMD video to file <file>.
515 6.5.4 end-jmd
517 End the current JMD dump in progress.
519 6.5.5 dump-sdmp <prefix>
521 Dump SDMP to <prefix>, splitting at 2GB.
523 6.5.6 dump-sdmp-ss <file>
525 Dump SDMP to <file>, no splitting
527 6.5.7 end-sdmp
529 End the current SDMP dump in progress.
531 6.6 Memory manipulation
533 <address> may be decimal or hexadecimal (prefixed with '0x'). 
534 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
535 signed (prefixed with '-') decimal.
537 The available element <sizes> are:
539 • byte: 1 byte
541 • word: 2 bytes
543 • dword: 4 bytes
545 • qword: 8 bytes
547 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
548 When dealing with DSP memory, multi-byte reads/writes are 
549 native-endian (do not use operand sizes exceeding DSP bitness, 
550 except dword is OK for 24-bit memory).
552 6.6.1 read-<size> <address>
554 Read the value of byte in <address>.
556 6.6.2 read-s<size> <address>
558 Read the value of signed byte in <address>.
560 6.6.3 write-<size> <address> <value>
562 Write <value> to byte in address <address>.
564 6.6.4 search-memory reset
566 Reset the memory search
568 6.6.5 search-memory count
570 Print number of candidates remaining
572 6.6.6 search-memory print
574 Print all candidates remaining
576 6.6.7 search-memory <usflag><sizeflag><op>
578 Searches memory for addresses satisfying criteria.
580 <usflag> can be:
582 • u: unsigned
584 • s: signed
586 <sizeflag> can be:
588 • b: byte
590 • w: word
592 • d: dword
594 • q: qword
596 <op> can be:
598 • lt: < previous value.
600 • le: <= previous value.
602 • eq: = previous value.
604 • ne: != previous value.
606 • ge: >= previous value.
608 • gt: > previous value.
610 6.6.8 search-memory <sizeflag> <value>
612 Searches for addresses that currently have value <value>. 
613 <sizeflag> is as in previous command.
615 6.7 Main commands
617 These commands are not available in lsnesrc, but are available 
618 after ROM has been loaded.
620 6.7.1 quit-emulator [/y]
622 Quits the emulator (asking for confirmation). If /y is given, no 
623 confirmation is asked.
625 6.7.2 pause-emulator
627 Toggle paused/unpaused
629 6.7.3 +advance-frame 
631 Advance frame. If the button is still held after configurable 
632 timeout expires, game unpauses for the duration frame advance is 
633 held.
635 6.7.4 +advance-poll 
637 Advance subframe. If the button is still held after configurable 
638 timeout expires, game unpauses for the duration frame advance is 
639 held.
641 6.7.5 advance-skiplag 
643 Skip to first poll in frame after current.
645 6.7.6 reset 
647 Reset the SNES after this frame.
649 6.7.7 load <filename> 
651 Load savestate <filename> in current mode.
653 6.7.8 load-state <filename> 
655 Load savestate <filename> in readwrite mode.
657 6.7.9 load-readonly <filename> 
659 Load savestate <filename> in readonly mode.
661 6.7.10 load-preserve <filename> 
663 Load savestate <filename> in readonly mode, preserving current 
664 events.
666 6.7.11 load-movie <filename> 
668 Load savestate <filename>, ignoring save part in readonly mode.
670 6.7.12 save-state <filename> 
672 Save system state to <filename> as soon as possible.
674 6.7.13 save-movie <filename> 
676 Save movie to <filename>.
678 6.7.14 set-rwmode 
680 Set read-write mode.
682 6.7.15 set-romode 
684 Set read-only mode
686 6.7.16 toggle-rwmode 
688 Toggle between read-only and read-write modes.
690 6.7.17 set-gamename <name> 
692 Set name of the game to <name>
694 6.7.18 get-gamename 
696 Print the name of the game.
698 6.7.19 add-author <author> 
700 Adds new author <author>. If <author> does not contain '|' it is 
701 full name. If it contains '|', '|' splits the full name and 
702 nickname.
704 6.7.20 edit-author <num> <author> 
706 Edit the author in slot <num> (0-based) to be <author> (see 
707 add-author for format)
709 6.7.21 remove-author <num> 
711 Remove author in slot <num>
713 6.7.22 print-authors 
715 Print authors.
717 6.7.23 test-1, test-2, test-3
719 Internal test commands. Don't use.
721 6.7.24 take-screenshot <filename> 
723 Save screenshot to <filename>.
725 6.7.25 +controller<num><button>
727 Press button <button> on controller <num> (1-8). The following 
728 button names are known:
730 • left
732 • right
734 • up
736 • down
738 • A
740 • B
742 • X
744 • Y
746 • L
748 • R
750 • select
752 • start
754 • trigger
756 • cursor
758 • pause
760 • turbo
762 6.7.26 controllerh<num><button>
764 Hold/unhold button <button> on controller <num> (1-8). See 
765 +controller for button names.
767 6.7.27 autofire (<pattern>|-)...
769 Set autofire pattern. Each parameter is comma-separated list of 
770 button names (in form of 1start, 1A, 2B, etc..) to hold on that 
771 frame. After reaching the end of pattern, the pattern restarts 
772 from the beginning.
774 6.7.28 repaint
776 Force a repaint.
778 6.8 Save jukebox 
780 6.8.1 cycle-jukebox-backward
782 Cycle save jukebox backwards.
784 6.8.2 cycle-jukebox-forward
786 Cycle save jukebox forwards
788 6.8.3 add-jukebox-save <filename>
790 Add <filename> to jukebox saves.
792 6.8.4 load-jukebox
794 Do load from jukebox (current mode).
796 6.8.5 save-jukebox
798 Do state save to jukebox.
800 6.9 Lua 
802 Only available if lua support is compiled in.
804 6.9.1 evaluate-lua <luacode>
806 Run Lua code <luacode> using built-in Lua interpretter.
808 6.9.2 run-lua <script>
810 Run specified lua file using built-in Lua interpretter.
812 6.10 Memory watch
814 6.10.1 add-watch <name> <expression>
816 Adds new watch (or modifies old one).
818 6.10.2 remove-watch <name>
820 Remove a watch.
822 6.11 Sound 
824 6.11.1 enable-sound <on/off> 
826 Enable/Disable sound.
828 6.11.2 set-sound-device <device> 
830 Set sound device to <device>
832 6.11.3 show-sound-status 
834 Show status of sound system.
836 6.11.4 show-sound-devices
838 Show all available devices.
840 6.12 SDL Platform commands 
842 The following are valid on SDL platform.
844 6.12.1 identify-key
846 Asks to press a key and then identifies that (pseudo-)key.
848 6.12.2 toggle-console 
850 Toggle between windowed/fullscreen console.
852 6.12.3 scroll-fullup 
854 Scroll messages window as far back as it goes.
856 6.12.4 scroll-fulldown 
858 Scroll messages window as far forward as it goes.
860 6.12.5 scroll-up 
862 Scroll messages window back one screenful.
864 6.12.6 scroll-down 
866 Scroll messages window forward one screenful.
868 7 Settings
870 7.1 Core settings
872 7.1.1 firmwarepath
874 Set where bsnes looks for firmware files. Default is “.”.
876 7.1.2 targetfps
878 Set the target fps. Numeric, range is 0.001 to “infinite”. 
879 Default is native framerate.
881 7.1.3 savecompression
883 Set save compression level (integer 0-9). Default is 7 (0 is no 
884 compression).
886 7.1.4 advance-timeout
888 Set the frame advance timeout in milliseconds. Numeric integer, 
889 range is 0-999999999. Default is 500.
891 7.2 AVI dumper settings
893 7.2.1 avi-large
895 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
896 the console outputs.
898 7.2.2 avi-left-border
900 AVI dumper: Set the default left border thickness (unless lua 
901 overrides) for dumps. Range 0-8191. Default is 0.
903 7.2.3 avi-right-border
905 AVI dumper: Set the default right border thickness (unless lua 
906 overrides) for dumps. Range 0-8191. Default is 0.
908 7.2.4 avi-top-border
910 AVI dumper: Set the default top border thickness (unless lua 
911 overrides) for dumps. Range 0-8191. Default is 0.
913 7.2.5 avi-bottom-border
915 AVI dumper: Set the default bottom border thickness (unless lua 
916 overrides) for dumps. Range 0-8191. Default is 0.
918 7.2.6 avi-maxframes
920 AVI dumper: Maximum number of frames per dump segment (0 => 
921 unlimited). Range 0-999999999. Default is 0.
923 7.2.7 avi-compresison
925 AVI dumper: Compression level (0-18).
927 • Compression levels 10 and above are not compatible with stock 
928   CSCD codec.
930 • Recomended level is 7.
932 7.3 JMD options
934 7.3.1 jmd-copression
936 JMD dumper: Compression level (0-9).
938 7.4 SDL platform settings
940 7.4.1 autorepeat-first-delay
942 Sets the delay for first character in typematic autorepeat.
944 7.4.2 autorepeat-subsequent-delay
946 Sets the delay for subsequent characters in typematic autorepeat.
948 8 Lua functions
950 8.1 Core (in main table)
952 8.1.1 print
954 Print line to message console.
956 8.1.2 exec(string command)
958 Run command as it was entered on the command line
960 8.2 Table bit:
962 Bitwise logical functions and related.
964 8.2.1 bit.none(number...) / bit.bnot(number...)
966 48-bit bitwise NOT / NONE function (set bits that are set in none 
967 of the arguments).
969 8.2.2 bit.any(number...) / bit.bor(number...)
971 48-bit bitwise OR / ANY function (set bits that are set in any of 
972 the arguments).
974 8.2.3 bit.all(number...) / bit.band(number...)
976 48-bit bitwise AND / ALL function (set bits that are set in all 
977 of the arguments).
979 8.2.4 bit.parity(number...) / bit.bxor(number...)
981 48-bit bitwise XOR / PARITY function (set bits that are set in 
982 odd number of the arguments).
984 8.2.5 bit.lrotate(number base[, number amount[, number bits]])
986 Rotate bits-bit (max 48, default 48) number left by amount 
987 (default 1) places.
989 8.2.6 bit.rrotate(number base[, number amount[, number bits]])
991 Rotate bits-bit (max 48, default 48) number right by amount 
992 (default 1) places.
994 8.2.7 bit.lshift(number base[, number amount[, number bits]])
996 Shift bits-bit (max 48, default 48) number left by amount 
997 (default 1) places. The new bits are filled with zeroes.
999 8.2.8 bit.lrshift(number base[, number amount[, number bits]])
1001 Shift bits-bit (max 48, default 48) number logically right by 
1002 amount (default 1) places. The new bits are filled with zeroes.
1004 8.2.9 bit.arshift(number base[, number amount[, number bits]])
1006 Shift bits-bit (max 48, default 48) number arithmetically right 
1007 by amount (default 1) places. The new bits are shifted in with 
1008 copy of the high bit.
1010 8.3 Table gui:
1012 Most of these functions can only be called in on_paint and 
1013 on_video callbacks. Exceptions are noted.
1015 Colors are 32-bit. Bits 0-7 are the blue component, bits 8-15 are 
1016 the green component, bits 16-23 are the red component, bits 24-31 
1017 are alpha component (0 is fully opaque, 255 is almost 
1018 transparent). -1 is the fully transparent color. Alpha values 
1019 greater than 127 do work.
1021 Origin of coordinates is at top left corner of game display area. 
1022 Left and top gaps correspond to negative coordinates.
1024 8.3.1 gui.resolution()
1026 Returns 2-tuple (hresolution, vresolution).
1028 8.3.2 gui.<class>_gap(number gap)
1030 Set the <class> (left, right, top, bottom) gap to specified value 
1031 (max gap is 8191).
1033 8.3.3 gui.text(number x, number y, string text[, number fgc[, 
1034   number bgc]])
1036 Draw specified text on the GUI (each character cell is 8 or 16 
1037 wide and 16 high). Parameters:
1039 • x: X-coordinate to start the drawing from (and x-coordinate at 
1040   begining of the lines).
1042 • y: Y-coordinate to start the drawing from.
1044 • text: The text to draw.
1046 • fgc: Text color (default is 0xFFFFFF (white))
1048 • bgc: Background color (default is -1 (transparent))
1050 8.3.4 gui.textH(number x, number y, string text[, number fgc[, 
1051   number bgc]])
1053 Like gui.text, but draw using double-width.
1055 8.3.5 gui.textV(number x, number y, string text[, number fgc[, 
1056   number bgc]])
1058 Like gui.text, but draw using double-height.
1060 8.3.6 gui.textHV(number x, number y, string text[, number fgc[, 
1061   number bgc]])
1063 Like gui.text, but draw using double-width/double-height.
1065 8.3.7 gui.rectangle(number x, number y, number width, number 
1066   height[, number thickness[, number outline[, number fill]]])
1068 Draw rectangle on the GUI. Parameters:
1070 • x: X-coordinate of left edge.
1072 • y: Y-coordinate of upper edge.
1074 • width: Width of rectangle.
1076 • height: Height of rectangle.
1078 • thickness: Thickness of outline (default is 1).
1080 • outline: Color of outline (default is 0xFFFFFF (white))
1082 • fill: Color of fil (default is -1 (transparent))
1084 8.3.8 gui.pixel(number x, number y[, number color])
1086 Draw one pixel on the GUI. Parameters:
1088 • x: X-coordinate of the pixel
1090 • y: Y-coordinate of the pixel
1092 • color: Color of the pixel (default is 0xFFFFFF (white))
1094 8.3.9 gui.crosshair(number x, number y[, number length[, number 
1095   color]])
1097 Draw a crosshair. Parameters:
1099 • x: X-coordinate of the crosshair
1101 • y: Y-coordinate of the crosshair
1103 • length: Length of the crosshair lines (default 10).
1105 • color: Color of the crosshair (default is 0xFFFFFF (white))
1107 8.3.10 gui.line(number x1, number y1, number x2, number y2[, 
1108   number color])
1110 Draw a thin line. Parameters:
1112 • x1: X-coordinate of one end.
1114 • y1: Y-coordinate of one end.
1116 • x2: X-coordinate of the other end.
1118 • y2: Y-coordinate of the other end.
1120 • color: Color of the line (default is 0xFFFFFF (white)).
1122 8.3.11 gui.circle(number x, number y, number r[, number thick[, 
1123   number border[, number fil]]])
1125 Draw a circle. Parameters.
1127 • x: X-coordinate of the center
1129 • y: Y-coordinate of the center
1131 • r: The radius of the circle
1133 • thick: Border thickness
1135 • border: Border color (default is 0xFFFFFF (white))
1137 • fill: Fill color (default is -1 (transparent)).
1139 8.3.12 gui.repaint()
1141 Request on_repaint() to happen as soon as possible. Can be used 
1142 anywhere.
1144 8.3.13 gui.subframe_update(boolean on)
1146 Request subframe updates (calling on_paint() on subframes) to 
1147 happen (on=true) or not happen (on=false). Can be used anywhere.
1149 8.3.14 gui.screenshot(string filename)
1151 Write PNG screenshot of the current frame (no drawings) to 
1152 specified file. Can be used anywhere.
1154 8.3.15 gui.color(number r, number g, number b[, number a])
1156 Returns color (in notation Lua scripts use) corresponding to 
1157 color (r,g,b), each component in scale 0-255. If a is specified, 
1158 that is alpha (0 is fully transparent, 256(sic) is fully opaque). 
1159 The default alpha is 256.
1161 8.3.16 gui.status(string name, string value)
1163 Set status field “L[<name>]” to <value> in status area. Can be 
1164 used anywhere.
1166 8.4 table input
1168 Input handling. Only available in on_input callback.
1170 8.4.1 input.get(number controller, number index)
1172 Read the specified index (0-11) from specified controller (0-7). 
1173 Notes:
1175 • Uses physical controller numbering. Gamepad in port 2 is 
1176   controller 4, not 1!
1178 8.4.2 input.set(number controller, number index, number value)
1180 Write the specified index (0-11) from specified controller (0-7), 
1181 storing value. Notes:
1183 • Uses physical controller numbering. Gamepad in port 2 is 
1184   controller 4, not 1!
1186 8.4.3 input.reset([number cycles])
1188 Execute reset. If cycles is greater than zero, do delayed reset. 
1189 0 (or no value) causes immediate reset.
1191 • Only available with subframe flag false.
1193 8.4.4 input.raw()
1195 Returns table of tables of all available keys and axes. The first 
1196 table is indexed by key name (platform-dependent!), and the inner 
1197 table has the following fields:
1199 • last_rawval: Last reported raw value for control.
1201 • ktype: Type of key (disabled, key, mouse, axis, axis-inverse, 
1202   hat, pressure-m0, pressure-mp, pressure-0m, pressure-0p, 
1203   pressure-pm, pressure-p0).
1205 • cal_left: Minimum calibration value. Only meaningful with axis 
1206   and pressure types.
1208 • cal_center: Center calibration value. Only meaningful with axis 
1209   and pressure types.
1211 • cal_right: Maximum calibration value. Only meaningful with axis 
1212   and pressure types.
1214 • cal_tolerance: Dead zone tolerance. Only meaningful with axis 
1215   and pressure types.
1217 8.5 Table hostmemory
1219 Host memory handling (extra memory saved to savestates). Host 
1220 memory starts empty.
1222 8.5.1 hostmemory.read(number address)
1224 Reads hostmemory slot address. Slot numbers out of range return 
1225 false instead of numeric.
1227 8.5.2 hostmemory.write(number address, number value)
1229 Writes hostmemory slot with 0-255. Slot numbers out of range 
1230 cause extension of host memory slot space.
1232 8.5.3 hostmemory.readbyte(number address)
1234 Read unsigned byte (1 element) from given address. Slots out of 
1235 range return false.
1237 8.5.4 hostmemory.writebyte(number address, number value)
1239 Write unsigned byte (1 element) to given slot. Slot numbers out 
1240 of range cause extension.
1242 8.5.5 hostmemory.readsbyte(number address)
1244 Read signed byte (1 element) from given address. Slots out of 
1245 range return false.
1247 8.5.6 hostmemory.writesbyte(number address, number value)
1249 Write signed byte (1 element) to given slot. Slot numbers out of 
1250 range cause extension.
1252 8.5.7 hostmemory.readword(number address)
1254 Read unsigned word (2 elements) from given address. Slots out of 
1255 range return false.
1257 8.5.8 hostmemory.writeword(number address, number value)
1259 Write unsigned word (2 elements) to given slot. Slot numbers out 
1260 of range cause extension.
1262 8.5.9 hostmemory.readsword(number address)
1264 Read signed word (2 elements) from given address. Slots out of 
1265 range return false.
1267 8.5.10 hostmemory.writesword(number address, number value)
1269 Write signed word (2 elements) to given slot. Slot numbers out of 
1270 range cause extension.
1272 8.5.11 hostmemory.readdword(number address)
1274 Read unsigned doubleword (4 elements) from given address. Slots 
1275 out of range return false.
1277 8.5.12 hostmemory.writedword(number address, number value)
1279 Write unsigned doubleword (4 elements) to given slot. Slot 
1280 numbers out of range cause extension.
1282 8.5.13 hostmemory.readsdword(number address)
1284 Read signed doubleword (4 elements) from given address. Slots out 
1285 of range return false.
1287 8.5.14 hostmemory.writesdword(number address, number value)
1289 Write signed doubleword (4 elements) to given slot. Slot numbers 
1290 out of range cause extension.
1292 8.5.15 hostmemory.readqword(number address)
1294 Read unsigned quadword (8 elements) from given address. Slots out 
1295 of range return false.
1297 8.5.16 hostmemory.writeqword(number address, number value)
1299 Write unsigned quadword (4 elements) to given slot. Slot numbers 
1300 out of range cause extension.
1302 8.5.17 hostmemory.readsqword(number address)
1304 Read signed quadword (8 elements) from given address. Slots out 
1305 of range return false.
1307 8.5.18 hostmemory.writesqword(number address, number value)
1309 Write signed quadword (8 elements) to given slot. Slot numbers 
1310 out of range cause extension.
1312 8.6 Table movie
1314 Movie handling
1316 8.6.1 movie.currentframe()
1318 Return number of current frame.
1320 8.6.2 movie.framecount()
1322 Return number of frames in movie.
1324 8.6.3 movie.readonly()
1326 Return true if in readonly mode, false if in readwrite.
1328 8.6.4 movie.set_readwrite()
1330 Set readwrite mode (does not cause on_readwrite callback).
1332 8.6.5 movie.frame_subframes(number frame)
1334 Count number of subframes in specified frame (frame numbers are 
1335 1-based) and return that.
1337 8.6.6 movie.read_subframe(number frame, number subframe)
1339 Read specifed subframe in specified frame and return data as 
1340 array (100 elements, numbered 0-99 currently).
1342 8.7 Table settings
1344 Routines for settings manipulation
1346 8.7.1 settings.get(string name)
1348 Get value of setting. If setting is blank, returns false. If 
1349 setting value can't be obtained, returns (nil, error message).
1351 8.7.2 settings.set(string name, string value)
1353 Set value of setting. If setting can't be set, returns (nil, 
1354 error message).
1356 8.7.3 settings.is_set(string name)
1358 Returns if setting is set. If setting does not exist, returns 
1359 (nil, error message).
1361 8.7.4 settings.blank(string name)
1363 Blanks a setting and returns true. If setting can't be blanked, 
1364 returns (nil, error message).
1366 8.8 Table memory
1368 Contains various functions for managing memory
1370 8.8.1 memory.vma_count()
1372 Returns the number of VMAs
1374 8.8.2 memory.read_vma(number index)
1376 Reads the specified VMA (indices start from zero). Trying to read 
1377 invalid VMA gives nil. The read VMA is table with the following 
1378 fields:
1380 • region_name (string): The readable name of the VMA
1382 • baseaddr (number): Base address of the VMA
1384 • lastaddr (number): Last address in the VMA.
1386 • size (number): The size of VMA in bytes.
1388 • readonly (boolean): True of the VMA corresponds to ROM.
1390 • native_endian (boolean): True if the VMA has native endian as 
1391   opposed to little endian.
1393 8.8.3 memory.find_vma(number address)
1395 Finds the VMA containing specified address. Returns table in the 
1396 same format as read_vma or nil if not found.
1398 8.8.4 memory.readbyte(number address)
1400 Reads the specified address as unsigned byte and returns the 
1401 result.
1403 8.8.5 memory.readsbyte(number address)
1405 Reads the specified address as signed byte and returns the 
1406 result.
1408 8.8.6 memory.writebyte(number address, number value)
1410 Writes the specified value (negative values undergo 2's 
1411 complement) to specified address (as a byte).
1413 8.8.7 memory.readword(number address)
1415 Reads the specified address as unsigned word and returns the 
1416 result.
1418 8.8.8 memory.readsword(number address)
1420 Reads the specified address as signed word and returns the 
1421 result.
1423 8.8.9 memory.writeword(number address, number value)
1425 Writes the specified value (negative values undergo 2's 
1426 complement) to specified address (as a word).
1428 8.8.10 memory.readdword(number address)
1430 Reads the specified address as unsigned doubleword and returns 
1431 the result.
1433 8.8.11 memory.readsdword(number address)
1435 Reads the specified address as signed doubleword and returns the 
1436 result.
1438 8.8.12 memory.writedword(number address, number value)
1440 Writes the specified value (negative values undergo 2's 
1441 complement) to specified address (as a doubleword).
1443 8.8.13 memory.readqword(number address)
1445 Reads the specified address as unsigned quadword and returns the 
1446 result.
1448 8.8.14 memory.readsqword(number address)
1450 Reads the specified address as signed quadword and returns the 
1451 result.
1453 8.8.15 memory.writeqword(number address, number value)
1455 Writes the specified value (negative values undergo 2's 
1456 complement) to specified address (as a quadword).
1458 8.9 Table _SYSTEM
1460 Contains copy of global variables from time of Lua 
1461 initialization. Non-writeable.
1463 8.10 Callbacks
1465 Various callbacks to Lua that can occur.
1467 8.10.1 Callback: on_paint()
1469 Called when screen is being painted. Any gui.* calls requiring 
1470 graphic context draw on the screen.
1472 8.10.2 Callback: on_video()
1474 Called when video dump frame is being painted. Any gui.* calls 
1475 requiring graphic context draw on the video.
1477 8.10.3 Callback: on_frame()
1479 Called on each starting whole frame.
1481 8.10.4 Callback: on_startup()
1483 Called when the emulator is starting (lsnes.rc and --run files 
1484 has been run).
1486 8.10.5 Callback: on_pre_load(string name)
1488 Called just before savestate/movie load occurs (note: loads are 
1489 always delayed, so this occurs even when load was initiated by 
1490 lua).
1492 8.10.6 Callback: on_err_load(string name)
1494 Called if loadstate goes wrong.
1496 8.10.7 Callback: on_post_load(string name, boolean was_savestate)
1498 Called on successful loadstate. was_savestate gives if this was a 
1499 savestate or a movie.
1501 8.10.8 Callback: on_pre_save(string name, boolean is_savestate)
1503 Called just before savestate save occurs (note: movie saves are 
1504 synchronous and won't trigger these callbacks if called from 
1505 Lua).
1507 8.10.9 Callback: on_err_save(string name)
1509 Called if savestate goes wrong.
1511 8.10.10 Callback: on_post_save(string name, boolean is_savestate)
1513 Called on successful savaestate. is_savestate gives if this was a 
1514 savestate or a movie.
1516 8.10.11 Callback: on_quit()
1518 Called when emulator is shutting down.
1520 8.10.12 Callback: on_input(boolean subframe)
1522 Called when emulator is just sending input to bsnes core. 
1523 Warning: This is called even in readonly mode, but the results 
1524 are ignored.
1526 8.10.13 Callback: on_reset()
1528 Called when SNES is reset.
1530 8.10.14 Callback: on_readwrite()
1532 Called when moving into readwrite mode as result of “set-rwmode” 
1533 command (note: moving to rwmode by Lua won't trigger this, as per 
1534 recursive entry protection).
1536 8.10.15 Callback: on_snoop(number port, number controller, number 
1537   index, number value)
1539 Called each time bsnes asks for input. The value is the final 
1540 value to be sent to bsnes core (readonly mode, autohold and 
1541 autofire have been taken into account). Might be useful when 
1542 translating movies to format suitable for console verification. 
1543 Note: There is no way to modify the value to be sent.
1545 9 Modifier and key names:
1547 9.1 SDL Platform
1549 9.1.1 Modifier names
1551 Following modifier names are known:
1553 • ctrl, lctrl, rctrl: Control keys
1555 • alt, lalt, ralt: ALT keys.
1557 • shift, lshift, rshift: Shift keys.
1559 • meta, lmeta, rmeta: Meta keys.
1561 • num, caps: Numlock/Capslock (these are sticky!)
1563 • mode: Mode select.
1565 9.1.2 Key names
1567 Following key names are known:
1569 • backspace, tab, clear, return, pause, escape, space, exclaim, 
1570   quotedbl, hash, dollar, ampersand, quote, leftparen, 
1571   rightparen, asterisk, plus, comma, minus, period, slash, 0, 1, 
1572   2, 3, 4, 5, 6, 7, 8, 9, colon, semicolon, less, equals, 
1573   greater, question, at, leftbracket, backslash, rightbracket, 
1574   caret, underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, 
1575   l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, delete, world_0, 
1576   world_1, world_2, world_3, world_4, world_5, world_6, world_7, 
1577   world_8, world_9, world_10, world_11, world_12, world_13, 
1578   world_14, world_15, world_16, world_17, world_18, world_19, 
1579   world_20, world_21, world_22, world_23, world_24, world_25, 
1580   world_26, world_27, world_28, world_29, world_30, world_31, 
1581   world_32, world_33, world_34, world_35, world_36, world_37, 
1582   world_38, world_39, world_40, world_41, world_42, world_43, 
1583   world_44, world_45, world_46, world_47, world_48, world_49, 
1584   world_50, world_51, world_52, world_53, world_54, world_55, 
1585   world_56, world_57, world_58, world_59, world_60, world_61, 
1586   world_62, world_63, world_64, world_65, world_66, world_67, 
1587   world_68, world_69, world_70, world_71, world_72, world_73, 
1588   world_74, world_75, world_76, world_77, world_78, world_79, 
1589   world_80, world_81, world_82, world_83, world_84, world_85, 
1590   world_86, world_87, world_88, world_89, world_90, world_91, 
1591   world_92, world_93, world_94, world_95, kp0, kp1, kp2, kp3, 
1592   kp4, kp5, kp6, kp7, kp8, kp9, kp_period, kp_divide, 
1593   kp_multiply, kp_minus, kp_plus, kp_enter, kp_equals, up, down, 
1594   right, left, insert, home, end, pageup, pagedown, f1, f2, f3, 
1595   f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, numlock, 
1596   capslock, scrollock, rshift, lshift, rctrl, lctrl, ralt, lalt, 
1597   rmeta, lmeta, lsuper, rsuper, mode, compose, help, print, 
1598   sysreq, break, menu, power, euro, undo
1600 • Names of form 'key<n>' where <n> is 0-255 are interpretted as 
1601   key having hardware-dependent scan code of <n> (useful to bind 
1602   those keys that don't have symbolic names).
1604 9.1.3 Joystick pseudo-keys:
1606 • joystick<num>button<button>: Joystick <num> (0-based) button 
1607   <button> (0-based).
1609 • joystick<num>hat<hat>n: Joystick <num> (0-based) hat <hat> 
1610   (0-based) up.
1612 • joystick<num>hat<hat>w: Joystick <num> (0-based) hat <hat> 
1613   (0-based) left.
1615 • joystick<num>hat<hat>s: Joystick <num> (0-based) hat <hat> 
1616   (0-based) down.
1618 • joystick<num>hat<hat>e: Joystick <num> (0-based) hat <hat> 
1619   (0-based) right.
1621 • joystick<num>axis<axis>-: Joystick <num> (0-based) axis <axis> 
1622   negative position (axis modes axis and axis_inverse).
1624 • joystick<num>axis<axis>+: Joystick <num> (0-based) axis <axis> 
1625   positive position (axis modes axis and axis_inverse).
1627 • joystick<num>axis<axis>: Joystick <num> (0-based) axis <axis> 
1628   pressure (axis modes pressure_*).
1630 9.1.4 Special buttons:
1632 • Escape: Enter/Exit Command mode, cancel modal dialogs.
1634 • Return (also KPEnter): Execute command, ok modal dialog.
1636 • Pgup/Up (also KP8/9 if no num lock; command mode): Previous 
1637   command in command history
1639 • Pgdn/Down(also KP2/3 if no num lock; command mode): Next 
1640   command in command history
1642 • Home (also KP7 if no num lock; command mode): Beginning of 
1643   command.
1645 • End (also KP1 if no num lock; command mode): End of command.
1647 • Left (also KP4 if no num lock; command mode): Move cursor left.
1649 • Right (also KP6 if no num lock; command mode): Move cursor 
1650   right.
1652 • Delete (also KP. if no num lock; command mode): Delete 
1653   character to right of cursor.
1655 • Insert (also KP0 if no num lock; command mode): Toggle between 
1656   insert / overwrite modes.
1658 • Backspace (command mode): Delete character to left of cursor.
1660 • LCTRL+LALT+ESCAPE: Ungraceful shutdown (leaves dump 
1661   corrupted!).
1663 9.2 wxWidgets platform
1665 9.2.1 Modifier names:
1667 Following modifier names are known:
1669 • alt
1671 • ctrl
1673 • shift 
1675 • meta
1677 • cmd (Mac OS X only)
1679 9.2.2 Key names:
1681 Following key names are known:
1683 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
1684   dollar, percent, ampersand, quote, leftparen, rightparen, 
1685   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
1686   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
1687   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
1688   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
1689   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
1690   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
1691   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
1692   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
1693   home, lefT, up, right, down, select, print, execute, snapshot, 
1694   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
1695   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
1696   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
1697   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
1698   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
1699   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
1700   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
1701   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
1702   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
1703   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
1704   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
1705   windows_right, windows_menu, command, special1, special2, 
1706   special3, special4, special5, special6, special7, special8, 
1707   special9, special10, special11, special12, special13, 
1708   special14, special15, special16, special17, special18, 
1709   special19, special20
1711 10 Movie file format
1713 Movie file is .zip archive in itself, normal ZIP archive tools 
1714 work on it (note: If you recompress it, do not use compression 
1715 methods other than store and deflate and especially do not use 
1716 encryption of any kind).
1718 10.1 Detecting clean start/SRAM/Savestate
1720 • If file has member “savestate” it is savestate, otherwise:
1722 • If file has members with names starting “moviesram.” it is 
1723   movie starting from SRAM, otherwise:
1725 • It is movie starting from clear state.
1727 10.2 Member: gametype
1729 Type of game ROM and region (as one line). Valid values are:
1732 +--------------+---------------------+--------+
1733 |    Value     |       System        | Region |
1734 +--------------+---------------------+--------+
1735 +--------------+---------------------+--------+
1736 |  snes_pal    |     Super NES       |  PAL   |
1737 +--------------+---------------------+--------+
1738 |   sgb_pal    |   Super Game Boy    |  PAL   |
1739 +--------------+---------------------+--------+
1740 |  snes_ntsc   |     Super NES       |  NTSC  |
1741 +--------------+---------------------+--------+
1742 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
1743 +--------------+---------------------+--------+
1744 |     bsx      | BS-X (non-slotted)  |  NTSC  |
1745 +--------------+---------------------+--------+
1746 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
1747 +--------------+---------------------+--------+
1748 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
1749 +--------------+---------------------+--------+
1752 Frame rates are:
1755 +---------+-----------------+
1756 | Region  | Framerate (fps) |
1757 +---------+-----------------+
1758 +---------+-----------------+
1759 |  PAL    |   322445/6448   |
1760 +---------+-----------------+
1761 |  NTSC   | 10738636/178683 |
1762 +---------+-----------------+
1765 10.3 Member: port1
1767 Contains type of port #1 (as one line). Valid values are 'none', 
1768 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
1769 'gamepad'.
1771 10.4 Member: port2
1773 Contains type of port #2 (as one line). Valid values are 'none', 
1774 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
1775 'justifiers'. If not present, defaults to 'none'.
1777 10.5 Member: gamename
1779 Contains name of the game (as one line).
1781 10.6 Member: authors
1783 Contains authors, one per line. Part before '|' is the full name, 
1784 part after is the nickname.
1786 10.7 Member: systemid
1788 Always “lsnes-rr1” (one line). Used to reject other saves.
1790 10.8 Member: controlsversion
1792 Always “0” (one line). Used to identify what controls are there.
1794 10.9 Member: “coreversion”
1796 Contains bsnes core version number (as one line).
1798 10.10 Member: projectid
1800 Contains project ID (as one line). Used to identify if two movies 
1801 are part of the same project.
1803 10.11 Member: {rom,slota,slotb}{,xml}.sha256
1805 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
1806 Absent if corresponding file is absent.
1808 10.12 Member: moviesram.<name>
1810 Raw binary startup SRAM of kind <name>. Only present in 
1811 savestates and movies starting from SRAM.
1813 10.13 Member: saveframe
1815 Contains frame number (as one line) of frame movie was saved on. 
1816 Only present in savestates.
1818 10.14 Member: lagcounter
1820 Current value of lag counter (as one line). Only present in 
1821 savestates.
1823 10.15 Member: pollcounters
1825 Contains poll counters (currently 100 of them), one per line. 
1826 Each line is raw poll count if DRDY is set for it. Otherwise it 
1827 is negative poll count minus one. Only present in savestates.
1829 10.16 Member: hostmemory
1831 Raw binary dump of host memory. Only present in savestates.
1833 10.17 Member: savestate
1835 The raw binary savestate itself. Savestate detection uses this 
1836 file, only present in savestates.
1838 10.18 Member: screenshot
1840 Screenshot of current frame. Only present in savestates. First 2 
1841 bytes are big-endian width of image, rest are 24-bit RGB image 
1842 data. Height of image is inferred from the width and size of 
1843 data.
1845 10.19 Member: sram.<name>
1847 Raw binary SRAM of kind <name> at time of savestate. Only present 
1848 in savestates.
1850 10.20 Member: input
1852 The actual input track, one line per subframe (blank lines are 
1853 skipped).
1855 • If the first byte of each line is '.', ' ', <tab> or '|', then 
1856   the line is part of same frame as previous, otherwise it starts 
1857   a new frame.
1859 • First subframe must start a new frame.
1861 Length of movie in frames is number of lines in input file that 
1862 start a new frame.
1864 10.21 Member: rerecords
1866 Contains textual base-10 rerecord count (as one line; emulator 
1867 just writes this, it doesn't read it) + 1.
1869 10.22 Member: rrdata
1871 This member stores set of load IDs. There is one load ID per 
1872 rerecord (plus one corresponding to start of project).
1874 • This member constists of concatenation of records
1876 • Each record is 2-36 bytes long and can represent 1-16,843,009 
1877   consequtive IDs.
1879 • IDs are interpretted as 256-bit big-endian integers with 
1880   warparound.
1882 • Initial predicted ID is all zeroes.
1884 Format of each record is:
1886 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
1887   bits 5-6 are count length (countlen). Bit 7 is unused.
1889 • 32-prefixlen bytes of ID.
1891 • countlen bytes of big-endian count (count).
1893 Records are processed as follows:
1895 • To form the first ID encoded by record, take the first 
1896   prefixlen bytes predicted ID and append the read ID value to 
1897   it. The result is the first ID encoded.
1899 • If countlen is 0, record encodes 1 ID.
1901 • If countlen is 1, record encodes 2+count IDs.
1903 • If countlen is 2, record encodes 258+count IDs.
1905 • If countlen is 3, record encodes 65794+count IDs.
1907 • The new predicted ID is the next ID after last one encoded by 
1908   the record.
1910 The number of rerecords + 1 is equal to the sum of number of IDs 
1911 encoded by all records.
1913 10.23 Member: starttime.second
1915 Movie starting time, second part. Epoch is Unix epoch. Default is 
1916 1,000,000,000.
1918 10.24 Member: starttime.subsecond
1920 Movie starting time, subsecond part. Unit is CPU clocks. Default 
1921 is 0.
1923 10.25 Member: savetime.second
1925 Movie saving time, second part. Default is starttime.second. Only 
1926 present in savestates.
1928 10.26 Member: savetime.subsecond
1930 Movie saving time, subsecond part. Default is 
1931 starttime.subsecond. Only present in savestates.
1933 11 Quick'n'dirty encode guide
1935 1. Start the emulator and load the movie file.
1937 2. Set large AVI option 'set-setting avi-large on'
1939 3. Enable dumping 'dump-avi tmpdump' 
1941 4. Unpause and let it run until you want to end dumping.
1943 5. Close the emulator (closing the window is the easiest way). Or 
1944   use 'end-avi'.
1946 6. For each tmpdump*.avi file created, on command prompt, do 
1947   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
1949 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
1951 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
1952   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
1953   tmpdump_<numbers>.mkv, with + in between).
1955 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
1956   final.mkv contains quick'n'dirty encode.
1958 12 Axis configurations for some gamepad types:
1960 12.1 XBox360 controller:
1962 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
1963 set to pressure-+.
1965 set-axis joystick0axis2 pressure-+
1967 set-axis joystick0axis5 pressure-+
1969 • This is needed for SDL only. EVDEV sets those types correctly.
1971 12.2 PS3 “sixaxis” controller:
1973 Axes 8-19 should be disabled.
1975 set-axis joystick0axis8 disabled
1977 set-axis joystick0axis9 disabled
1979 set-axis joystick0axis10 disabled
1981 set-axis joystick0axis11 disabled
1983 set-axis joystick0axis12 disabled
1985 set-axis joystick0axis13 disabled
1987 set-axis joystick0axis14 disabled
1989 set-axis joystick0axis15 disabled
1991 set-axis joystick0axis16 disabled
1993 set-axis joystick0axis17 disabled
1995 set-axis joystick0axis18 disabled
1997 set-axis joystick0axis19 disabled
1999 13 Errata:
2001 13.1 Problems from BSNES core:
2003 • The whole pending save stuff.
2005 • Lack of layer hiding.
2007 • It is slow (especially accuracy).
2009 • Firmwares can't be loaded from ZIP archives.
2011 13.2 Other problems:
2013 • Modifiers don't work with pseudo-keys (SDL, EVDEV).
2015 • Audio for last dumped frame is not itself dumped.
2017 • Audio in UI is pretty bad in quality if game doesn't run at 
2018   full speed.
2020 • AVI compression levels 10-18 are not compatible with AVISynth 
2021   AVISource.
2023 • No menus, command based interface (SDL).
2025 • Long commands don't scroll.
2027 • The SDL screen drawing is slow.
2029 • Wxwidgets UI is still pretty buggy.
2031 14 Changelog:
2033 14.1 rr0-beta1
2035 • Fix -Wall warnings
2037 • Fix dumper video corruption with levels 10-18.
2039 14.2 rr0-beta2
2041 • Autofire
2043 • Lots of code cleanups
2045 • Lua interface to settings
2047 • Allow specifying AVI borders without Lua
2049 • Fix scaling if vscale > 1 and originx > 0 (left border exists)
2051 • on_snoop lua callback
2053 • Faster movie loading and saving.
2055 14.3 rr0-beta3
2057 • Joystick support
2059 14.4 rr0-beta4
2061 • Fix multi-buttons
2063 • Save jukebox functionality.
2065 14.5 rr0-beta5
2067 • Try to fix some nasty failing movie load edge cases
2069 • Allow specifying scripts to run on command line.
2071 14.6 rr0-beta6
2073 • Major source code reorganization.
2075 • Backup savestates before overwriting.
2077 • Don't crash if loading initial state fails.
2079 14.7 rr0-beta7
2081 • Fix firmware lookup
2083 • Fix author name parsing
2085 • Fix rerecord counting
2087 • (SDL) Print messages to console if SDL is uninitialized
2089 • Add movieinfo program
2091 • Fix loading movies starting from SRAM.
2093 14.8 rr0-beta8
2095 • Add support for unattended dumping
2097 • Fix compiling for Win32
2099 • Don't lock up if sound can't be initialized
2101 • Strip trailing CR from commands
2103 • Don't try to do dubious things in global ctors (fix crash on 
2104   startup)
2106 14.9 rr0-beta9
2108 • Small documentation tweaking
2110 • Fix make clean
2112 • Fix major bug in modifier matching
2114 14.10 rr0-beta10
2116 • Lots of documentation fixes
2118 • Use dedicated callbacks for event backcomm., not commands.
2120 • Ensure that the watchdog is not hit when executing delayed 
2121   reset.
2123 • Remove errant tab from joystick message.
2125 14.11 rr0-beta11
2127 • Make autofire operate in absolute time, not linear time
2129 • Reinitialize controls when resuming from loadstate
2131 • Some more code cleanups
2133 • If Lua allocator fails, call OOM_panic()
2135 • Byte/word/dword/qword sized host memory write/read functions.
2137 • Dump at correct framerate if dumping interlaced NTSC 
2138   (height=448).
2140 14.12 rr0-beta12
2142 • Actually include the complete source code
2144 • Keep track of RTC
2146 14.13 rr0-beta13
2148 • Document {save,start}time.{,sub}second.
2150 • Intercept time() from bsnes core.
2152 14.14 rr0-beta14
2154 • Allow disabling time() interception (allow build on Mac OS X)
2156 • Use SDLMain on Mac OS X (make SDL not crash)
2158 • Disable delayed resets (just plain too buggy for now).
2160 • Code cleanups
2162 • Use 16-bit for graphics/video instead of 32-bit.
2164 • gui.rectangle/gui.pixel
2166 • gui.crosshair
2168 • New CSCD writer implementation.
2170 14.15 rr0-beta15
2172 • Fix interaction of * and +.
2174 • Manual improvements
2176 • Use gettimeofday()/usleep(), these seem portable enough.
2178 • Move joystick axis manipulation to keymapper code.
2180 • Changes to how read-only works.
2182 • Refactor controller input code.
2184 14.16 rr0-beta16
2186 • Fix mouseclick scale compensation.
2188 • Draw area boundaries correctly in SDL code.
2190 • gui.screenshot.
2192 • Fix CSCD output (buffer overrun and race condition).
2194 14.17 rr0-beta17
2196 • JMD dumping support.
2198 • Allow unattended dumping to JMD.
2200 • Move to BSNES v083.
2202 • Switch back to 32-bit colors.
2204 • Add Lua function gui.color.
2206 • Use some new C++11 features in GCC 4.6.
2208 • Be prepared for core frequency changes.
2210 • Pass colors in one chunk from Lua.
2212 14.18 rr0-beta18
2214 • New lua functions gui.line(), gui.status() and gui.circle(), 
2215   memory.vma_count(), memory.read_vma() and memory.find_vma().
2217 • Numerious documentation fixups
2219 • RTC time format changed
2221 • Reformat flags display
2223 • Allow lua package name to be overridden
2225 • SDUMP (high-quality dumping).
2227 • Split platform support to plugins.
2229 • Make all sound plugins support basic sound commands
2231 • Support portaudio for sound.
2233 • Allow disable Lua/SDL searching.
2235 • Upconvert colors when copying lcscreen to screen.
2237 • Reorganize source tree.
2239 • Evdev joystick support.
2241 • Refactor more code into generic window code.
2243 14.19 rr0-beta19
2245 • Refactor message handling.
2247 • Rework makefile
2249 • Documentation fixes
2251 • Finish pending saves before load/quit.
2253 • Wxwidgets graphics plugin.
2255 14.20 rr0-beta20
2257 • Get rid of win32-crap.[ch]pp.
2259 • Move files around a lot.
2261 • Get rid of need for host C++ compiler.
2263 • Bsnes v084 core.
2265 • Refactor inter-component communication.
2267 • Fix zero luma.
2269 • Fix crash on multiline aliases.
2271 • Load/Save settings in wxwidgets gui.
2273 14.21 rr0-beta21
2275 • Patch problems in bsnes core
2277 • SNES is little-endian, not big-endian!
2279 • Fix memory corruption in lcscreen::load()
2281 14.22 rr0-beta22
2283 • Fix interpretting repeat counts in rrdata loading.
2285 • New lua callback: on_frame()
2287 • Remove calls to runtosave() that aren't supposed to be there
2289 • Lua function: movie.read_rtc()
2291 • Ignore src/fonts/font.cpp
2293 • Fix more bsnes core problems
2295 • Control bsnes random seeding
2297 • Pause-on-end
2299 • Some bsnes core debugging features (state dump and state hash)
2301 • Fix titlebar version number (no, the last version wasn't 
2302   'lsnes-0-beta21', it was 'lsnes rr0-beta21').
2304 14.23 rr0-beta23
2306 • Fix memory corruption due to macro/field mixup
2308 • search-memory update
2310 • Allow direct-mapped framebuffer
2312 • SDL: Use SDL_ANYFORMAT if possible
2314 • SDMP2SOX: 2s delay modes.
2316 • Wxwidgets: Cleanups
2318 • Use sed -E, not sed -r. Fixes building on Mac OS X.
2320 • Wxwidgets: Save jukebox on exit
2322 • Fix RTC if using load-movie on savestate.
2324 • Fix crash related to full console mode.
2326 14.24 rr0-beta24
2328 • Wxwidgets: Allow bringing application to foreground on Mac OS 
2329   X.
2331 • Wxwidgets: Allow compiling on Mac OS X.
2333 • Use movie compare instead of movie hashing (faster save/load).
2335 • Lua: _SYSTEM table.
2337 14.25 rr0-beta25
2339 • sdmp2sox: Pad soundtrack if using -l or -L.
2341 • sdmp2sox: Fix NTSC overscan.
2343 • sdmp2sox: Add AR correction mode.
2345 • call lua_close() when exiting.
2347 • Fix zip_writer bug causing warnings from info-zip and error 
2348   from advzip.
2350 14.26 rr0-beta26
2352 • Fix IPS patching code (use bsnes core IPS patcher).
2354 • Implement BPS patching (using bsnes core IPS patcher).
2356 • Add feature to load headered ROMs.
2358 14.27 rr0-beta27
2360 • Show command names when showing keybindings
2362 14.28 rr0
2364 • Fix pause-on-end to be actually controllable
2366 • SDL: Poll all events in queue, not just first one (fixes 
2367   slowness in command typing)
2369 • Wxwidgets: Fix ROM loading.
2371 14.29 rr1-beta0
2373 • Lua: Add gui.textH, gui.textV, gui.textHV
2375 • Fix text colors on SDL on Mac OS X
2377 • Mode 'F' for finished in readonly mode.
2379 • Fix some WS errors.
2381 • Reliably pause after skip poll
2383 • Split UI and core into their own threads
2385 14.30 rr1-beta1
2387 • Remove leftover dummy SRAM slot
2389 • Fix controller numbers.
2391 14.31 rr1-beta2
2393 • Fix lsnes-dumpavi after interface change.
2395 • Also give BSNES patches for v085.
2397 • Pack movie data in memory.
2399 14.32 rr1-beta3
2401 • Fix framecount/length given when loading movies.
2403 • Controller command memory leak fixes.
2405 • Don't leak palette if freeing screen object.
2407 14.33 rr1-beta4
2409 • Detect revisions.
2411 • Wxwidgets: Allow controlling dumper from the menu.
2413 14.34 rr1-beta5
2415 • Rewrite parts of manual
2417 • Lua: Make it work with Lua 5.2.
2419 14.35 rr1-beta6
2421 • Win32: Fix compile errors.
2423 14.36 rr1-beta7
2425 • Refactor controller input code.
2427 • Fix crash when using command line on SDL / Mac OS X.
2429 14.37 rr1-beta8
2431 • Delete core/coroutine (obsolete)
2433 • Lag input display by one frame.
2435 • Rewind movie to beginning function.
2437 • Fix wrong frame number reported to Lua when repainting after 
2438   loadstate
2440 • Support UI editing of jukebox
2442 • Wxwidgets: Save settings on exit.
2444 • Support ${project} for filenames
2446 • SDL: Fix command history
2448 14.38 rr1-beta9
2450 • Fix some order-of-global-ctor bugs.
2452 14.39 rr1-beta10
2454 • Fix crashes when quitting on Win32.
2456 14.40 rr1-beta11
2458 • EVDEV: Queue keypresses from joystick, don't send directly
2460 • Wxwidgets: Load-Preserve that actually works.
2462 14.41 rr1-beta12
2464 • Wxwidgets: GUI for memory search.
2466 • Warn about using synchronous queue in UI callback.