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