Fix desyncs with rewind movie to begnning function
[lsnes.git] / manual.txt
blobcb7f65a9d8e59b6042c159ef31c28c5cd3a57d27
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. libsdl (SDL only)
23 6. sdlmain (SDL only, part of SDL)
25 7. boost_conversion (this is header-only library)
27 8. libswscale (wxwidgets graphics only)
29 9. Portaudio (portaudio sound only)
31 10. std::thread and co (for threaded dumper only)
33 11. Lua (if Lua support is needed).
35 • Version 5.1.X or 5.2X.
37 3 Building
39 Building is via makefile, the following options are available:
41 • CROSS_PREFIX=<prefix>
43   – Prefix to apply to commands when building executables / 
44     object files for the target architecture. 
46   – Default is blank.
48 • CC=<name>
50   – Name of C++ compiler.
52   – CROSS_PREFIX is prepended if compiling for target 
53     architecture.
55   – This needs to be at least GCC 4.6.
57   – Set to 'g++-mp-4.6' if compiling on Mac OS X using GCC 4.6 
58     from Macports.
60   – Default is 'g++'.
62 • HOSTCC=<name>
64   – Name of host C++ compiler.
66   – Default is value of 'CC' option.
68 • USER_HOSTCCFLAGS=<flags>:
70   – Compiler flags to pass when compiling/linking for host 
71     architecture.
73   – Default is blank.
75 • USER_CFLAGS=<flags>
77   – Extra flags to pass when compiling for target architecture
79   – Default is blank.
81 • USER_LDFLAGS=<flags>: 
83   – Extra flags to pass when linking for target architecture.
85   – Default is blank.
87 • USER_PLATFORM_CFLAGS=<flags>
89   – Extra flags to pass when compiling files using 
90     platform-dependent code for target architecture.
92   – Default is blank.
94 • USER_PLATFORM_LDFLAGS=<flags>
96   – Extra flags to pass when linking files using 
97     platform-dependent code for target architecture.
99   – Default is blank.
101 • FONT_SRC=<file>
103   – Set the font file to use.
105   – Currently the valid values are:
107     ∗ cp437.hex: Standard VGA font (256 characters).
109     ∗ unifontfull-5.1.20080820.hex: GNU unifont (covers most of 
110       Unicode BMP)
112   – Default is 'unifontfull-5.1.20080820.hex'
114 • LUA=<package>
116   – Package to use for Lua support.
118   – Usually valid value is 'lua' or 'lua5.1'.
120   – Default is not to build Lua support.
122 • THREADS=<bool>
124   – Override platform default for dumper threading support.
126   – Threading is default on Linux.
128   – 'YES' tries to use threading.
130   – 'NO' disables threading.
132   – Note: This has absolutely nothing to do with platform 
133     threading.
135 • BSNES_IS_COMPAT=<anything>
137   – Signals that BSNES core used is compatiblity core, not 
138     accuracy core.
140   – Default is to assume accuracy core.
142 • JOYSTICK=<implementation>
144   – Set joystick implementation. Valid values are:
146     ∗ SDL: Use SDL for joystick (requires SDL graphics)
148     ∗ EVDEV: Use EVDEV for joystick (Linux only).
150     ∗ DUMMY: Disable joystick support.
152   – Default is SDL.
154 • SOUND=<implementation>
156   – Set sound implementation. Valid values are:
158     ∗ SDL: Use SDL for sound (requires SDL graphics)
160     ∗ PORTAUDIO: Use Portaudio for sound.
162     ∗ DUMMY: Disable sound support
164   – Default is SDL.
166 • GRAPHICS=<implementation>
168   – Set windowing library to use. Valid values are:
170     ∗ SDL: Use SDL for graphics
172     ∗ WXWIDGETS: Use wxWidgets for graphics.
174   – Default is SDL.
176 4 Command line options
178 4.1 ROM options
180 <kind> in the following can be one of:
182 • rom: Cartridge ROM (BIOS for special carts). This is required.
184 • bsx: BS-X (non-slotted) Game flash ROM.
186 • bsxslotted: BS-X (slotted) Game flash ROM.
188 • dmg: DMG game ROM
190 • slot-a: Sufami Turbo Slot A ROM
192 • slot-b: Sufami Turbo Slot B ROM
194 4.1.1 --<kind>=<file> (lsnes/SDL, lsnes-avidump)
196 Load <file> as specified ROM (SFC/BS/DMG/ST file format).
198 4.1.2 --headered-<kind>=<file> (lsnes/SDL, lsnes-avidump)
200 Load <file> as specified ROM, stripping first 512 bytes. Handy 
201 for loading SMC / FIG and such files.
203 4.1.3 --<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.4 --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.5 --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.6 --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.7 --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.8 --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 --prefix=<prefix>
313 Set dump prefix. Default is “avidump”.
315 4.4.2 --level=<level>
317 Set compression level (0-18). Default is 7.
319 4.4.3 --length=<length>
321 Set number of frames to dump. Mandatory.
323 4.4.4 --lua=<script>
325 Run specified lua script (lsnes-dumpavi does not have 
326 initialization files).
328 4.4.5 --jmd
330 Use JMD dumping instead of AVI dumping.
332 4.4.6 --sdmp
334 Use SDMP dumping instead of AVI dumping.
336 4.4.7 --ss
338 Dump in single segment (SDMP only).
340 5 Startup file lsnes.rc
342 Upon startup, lsnes (lsnes/SDL only) executes file lsnes.rc as 
343 commands. This file is located in:
345 • Windows: %APPDATA%\lsnes\lsnes.rc (if %APPDATA% exists)
347 • Unix: $XDG_CONFIG_HOME/lsnes/lsnes.rc (if $XDG_CONFIG_HOME 
348   exists)
350 • Unix: $HOME/.config/lsnes/lsnes.rc (if $HOME exists)
352 • All: ./lsnes.rc (fallback default).
354 If leading directories do not exist, attempt to create them is 
355 made.
357 6 Internal commands
359 • Commands beginning with '*' invoke the corresponding command 
360   without alias expansion.
362 • If command starts with '+' (after possible '*'), the command is 
363   executed as-is when button is pressed, and when button is 
364   released, it is executed with '+' replaced by '-'.
366 • Commands without '+' execute only on negative edge (release).
368 6.1 Settings:
370 Settings control various aspects of emulator behaviour.
372 6.1.1 set-setting <setting> <value>
374 Sets setting <setting> to value <value> (may be empty).
376 6.1.2 unset-setting <setting>
378 Try to unset setting <setting> (not all settings can be unset).
380 6.1.3 get-setting <setting>
382 Read value of setting <setting>
384 6.1.4 show-settings
386 Print names and values of all settings.
388 6.2 Keybindings
390 Keybindings bind commands or aliases to keys (or pseudo-keys). 
392 Notes:
394 • Do not bind edge active (+/-) commands to keys with modifiers, 
395   that won't work right!
397 • Names of keys and modifiers are platform-dependent.
399 • Be careful before binding pseudo-keys (such as joystick axes, 
400   buttons or hats) with modifiers. That may or may not work 
401   right.
403 6.2.1 bind-key [<mod>/<modmask>] <key> <command>
405 Bind <command> to key <key> (activating if modifiers in <modmask> 
406 (comma-seperated list) are set as <mod> (comma-seperated list).
408 The names of keys and modifiers are platform-dependent.
410 6.2.2 unbind-key [<mod>/<modmask>] <key>
412 Unbind command from <key> (with specified <mod> and <modmask>).
414 6.2.3 set-axis <axis> [disabled | axis | axis-inverse | 
415   pressure0- | pressure0+ | pressure-0 | pressure-+ | pressure+0 
416   | pressure+-] [minus=<val>] [zero=<val>] [plus=<val>] 
417   [tolerance=<val>]
419 Set axis parameters for axis <axis>.
421 • disabled: Disable axis
423 • axis: Normal axis
425 • axis-inverse: Inverse axis
427 • pressure0-: Pressure sensitive. Released at 0, pressed at -.
429 • pressure0+: Pressure sensitive. Released at 0, pressed at +.
431 • pressure-0: Pressure sensitive. Released at -, pressed at 0.
433 • pressure-+: Pressure sensitive. Released at -, pressed at +.
435 • pressure+0: Pressure sensitive. Released at +, pressed at 0.
437 • pressure+-: Pressure sensitive. Released at +, pressed at -.
439 • minus=<val>: Calibration at extreme minus position 
440   (-32768-32767)
442 • zero=<val>: Calibration at neutral position (-32768-32767)
444 • plus=<val>: Calibration at extreme plus position (-32768-32767)
446 • tolerance=<value>: Center band tolerance (0<x<1). The smaller 
447   the value, the more sensitive the control is.
449 6.2.4 show-bindings
451 Print all key bindings in effect.
453 6.3 Aliases
455 Aliases bind command to sequence of commands. After alias has 
456 been defined, it replaces the command it shadows.
458 Notes:
460 • You can't alias command to itself.
462 • Aliases starting with +/- are edge active just like ordinary 
463   commands starting with +/-.
465 • One command can be aliased to multiple commands.
467 6.3.1 alias-command <command> <expansion>
469 Append <expansion> to alias <command>. If alias does not already 
470 exist, it is created.
472 6.3.2 unalias-command <command>
474 Clear alias expansion for <command>.
476 6.3.3 show-aliases
478 Print all aliases and their expansions in effect.
480 6.4 run-script <script>
482 Run <script> as if commands were entered on the command line.
484 6.5 Video dumping
486 Following commands control video dumping:
488 6.5.1 dump-avi <prefix>
490 Dump AVI video to prefix <prefix> Notes:
492 • The codec is Camstudio Codec in gzip mode.
494 • Encoder and muxer are internal, available on all platforms.
496 • Audio enable/disable and framerate has no effect.
498 • The audio dumped to .avi is low-quality version. The 
499   high-quality version is dumped to .sox file.
501 6.5.2 end-avi
503 End current AVI video dump (closing the emulator also closes the 
504 dump).
506 6.5.3 dump-jmd <file>
508 Dump JMD video to file <file>.
510 6.5.4 end-jmd
512 End the current JMD dump in progress.
514 6.5.5 dump-sdmp <prefix>
516 Dump SDMP to <prefix>, splitting at 2GB.
518 6.5.6 dump-sdmp-ss <file>
520 Dump SDMP to <file>, no splitting
522 6.5.7 end-sdmp
524 End the current SDMP dump in progress.
526 6.6 Memory manipulation
528 <address> may be decimal or hexadecimal (prefixed with '0x'). 
529 <value> can be hexadecimal (prefixed with '0x'), unsigned or 
530 signed (prefixed with '-') decimal.
532 The available element <sizes> are:
534 • byte: 1 byte
536 • word: 2 bytes
538 • dword: 4 bytes
540 • qword: 8 bytes
542 When reading RAM and ROM, multi-byte reads/writes are big-endian. 
543 When dealing with DSP memory, multi-byte reads/writes are 
544 native-endian (do not use operand sizes exceeding DSP bitness, 
545 except dword is OK for 24-bit memory).
547 6.6.1 read-<size> <address>
549 Read the value of byte in <address>.
551 6.6.2 read-s<size> <address>
553 Read the value of signed byte in <address>.
555 6.6.3 write-<size> <address> <value>
557 Write <value> to byte in address <address>.
559 6.6.4 search-memory reset
561 Reset the memory search
563 6.6.5 search-memory count
565 Print number of candidates remaining
567 6.6.6 search-memory print
569 Print all candidates remaining
571 6.6.7 search-memory <usflag><sizeflag><op>
573 Searches memory for addresses satisfying criteria.
575 <usflag> can be:
577 • u: unsigned
579 • s: signed
581 <sizeflag> can be:
583 • b: byte
585 • w: word
587 • d: dword
589 • q: qword
591 <op> can be:
593 • lt: < previous value.
595 • le: <= previous value.
597 • eq: = previous value.
599 • ne: != previous value.
601 • ge: >= previous value.
603 • gt: > previous value.
605 6.6.8 search-memory <sizeflag> <value>
607 Searches for addresses that currently have value <value>. 
608 <sizeflag> is as in previous command.
610 6.7 Main commands
612 These commands are not available in lsnesrc, but are available 
613 after ROM has been loaded.
615 6.7.1 quit-emulator [/y]
617 Quits the emulator (asking for confirmation). If /y is given, no 
618 confirmation is asked.
620 6.7.2 pause-emulator
622 Toggle paused/unpaused
624 6.7.3 +advance-frame 
626 Advance frame. If the button is still held after configurable 
627 timeout expires, game unpauses for the duration frame advance is 
628 held.
630 6.7.4 +advance-poll 
632 Advance subframe. If the button is still held after configurable 
633 timeout expires, game unpauses for the duration frame advance is 
634 held.
636 6.7.5 advance-skiplag 
638 Skip to first poll in frame after current.
640 6.7.6 reset 
642 Reset the SNES after this frame.
644 6.7.7 load <filename> 
646 Load savestate <filename> in current mode.
648 6.7.8 load-state <filename> 
650 Load savestate <filename> in readwrite mode.
652 6.7.9 load-readonly <filename> 
654 Load savestate <filename> in readonly mode.
656 6.7.10 load-preserve <filename> 
658 Load savestate <filename> in readonly mode, preserving current 
659 events.
661 6.7.11 load-movie <filename> 
663 Load savestate <filename>, ignoring save part in readonly mode.
665 6.7.12 save-state <filename> 
667 Save system state to <filename> as soon as possible.
669 6.7.13 save-movie <filename> 
671 Save movie to <filename>.
673 6.7.14 set-rwmode 
675 Set read-write mode.
677 6.7.15 set-romode 
679 Set read-only mode
681 6.7.16 toggle-rwmode 
683 Toggle between read-only and read-write modes.
685 6.7.17 set-gamename <name> 
687 Set name of the game to <name>
689 6.7.18 get-gamename 
691 Print the name of the game.
693 6.7.19 add-author <author> 
695 Adds new author <author>. If <author> does not contain '|' it is 
696 full name. If it contains '|', '|' splits the full name and 
697 nickname.
699 6.7.20 edit-author <num> <author> 
701 Edit the author in slot <num> (0-based) to be <author> (see 
702 add-author for format)
704 6.7.21 remove-author <num> 
706 Remove author in slot <num>
708 6.7.22 print-authors 
710 Print authors.
712 6.7.23 test-1, test-2, test-3
714 Internal test commands. Don't use.
716 6.7.24 take-screenshot <filename> 
718 Save screenshot to <filename>.
720 6.7.25 +controller<num><button>
722 Press button <button> on controller <num> (1-8). The following 
723 button names are known:
725 • left
727 • right
729 • up
731 • down
733 • A
735 • B
737 • X
739 • Y
741 • L
743 • R
745 • select
747 • start
749 • trigger
751 • cursor
753 • pause
755 • turbo
757 6.7.26 controllerh<num><button>
759 Hold/unhold button <button> on controller <num> (1-8). See 
760 +controller for button names.
762 6.7.27 autofire (<pattern>|-)...
764 Set autofire pattern. Each parameter is comma-separated list of 
765 button names (in form of 1start, 1A, 2B, etc..) to hold on that 
766 frame. After reaching the end of pattern, the pattern restarts 
767 from the beginning.
769 6.7.28 repaint
771 Force a repaint.
773 6.8 Save jukebox 
775 6.8.1 cycle-jukebox-backward
777 Cycle save jukebox backwards.
779 6.8.2 cycle-jukebox-forward
781 Cycle save jukebox forwards
783 6.8.3 add-jukebox-save <filename>
785 Add <filename> to jukebox saves.
787 6.8.4 load-jukebox
789 Do load from jukebox (current mode).
791 6.8.5 save-jukebox
793 Do state save to jukebox.
795 6.9 Lua 
797 Only available if lua support is compiled in.
799 6.9.1 evaluate-lua <luacode>
801 Run Lua code <luacode> using built-in Lua interpretter.
803 6.9.2 run-lua <script>
805 Run specified lua file using built-in Lua interpretter.
807 6.10 Memory watch
809 6.10.1 add-watch <name> <expression>
811 Adds new watch (or modifies old one).
813 6.10.2 remove-watch <name>
815 Remove a watch.
817 6.11 Sound 
819 6.11.1 enable-sound <on/off> 
821 Enable/Disable sound.
823 6.11.2 set-sound-device <device> 
825 Set sound device to <device>
827 6.11.3 show-sound-status 
829 Show status of sound system.
831 6.11.4 show-sound-devices
833 Show all available devices.
835 6.12 SDL Platform commands 
837 The following are valid on SDL platform.
839 6.12.1 identify-key
841 Asks to press a key and then identifies that (pseudo-)key.
843 6.12.2 toggle-console 
845 Toggle between windowed/fullscreen console.
847 6.12.3 scroll-fullup 
849 Scroll messages window as far back as it goes.
851 6.12.4 scroll-fulldown 
853 Scroll messages window as far forward as it goes.
855 6.12.5 scroll-up 
857 Scroll messages window back one screenful.
859 6.12.6 scroll-down 
861 Scroll messages window forward one screenful.
863 7 Settings
865 7.1 Core settings
867 7.1.1 firmwarepath
869 Set where bsnes looks for firmware files. Default is “.”.
871 7.1.2 targetfps
873 Set the target fps. Numeric, range is 0.001 to “infinite”. 
874 Default is native framerate.
876 7.1.3 savecompression
878 Set save compression level (integer 0-9). Default is 7 (0 is no 
879 compression).
881 7.1.4 advance-timeout
883 Set the frame advance timeout in milliseconds. Numeric integer, 
884 range is 0-999999999. Default is 500.
886 7.2 AVI dumper settings
888 7.2.1 avi-large
890 AVI dumper: Always dump at 512x448 or 512x478 regardless of what 
891 the console outputs.
893 7.2.2 avi-left-border
895 AVI dumper: Set the default left border thickness (unless lua 
896 overrides) for dumps. Range 0-8191. Default is 0.
898 7.2.3 avi-right-border
900 AVI dumper: Set the default right border thickness (unless lua 
901 overrides) for dumps. Range 0-8191. Default is 0.
903 7.2.4 avi-top-border
905 AVI dumper: Set the default top border thickness (unless lua 
906 overrides) for dumps. Range 0-8191. Default is 0.
908 7.2.5 avi-bottom-border
910 AVI dumper: Set the default bottom border thickness (unless lua 
911 overrides) for dumps. Range 0-8191. Default is 0.
913 7.2.6 avi-maxframes
915 AVI dumper: Maximum number of frames per dump segment (0 => 
916 unlimited). Range 0-999999999. Default is 0.
918 7.2.7 avi-compresison
920 AVI dumper: Compression level (0-18).
922 • Compression levels 10 and above are not compatible with stock 
923   CSCD codec.
925 • Recomended level is 7.
927 7.3 JMD options
929 7.3.1 jmd-copression
931 JMD dumper: Compression level (0-9).
933 7.4 SDL platform settings
935 7.4.1 autorepeat-first-delay
937 Sets the delay for first character in typematic autorepeat.
939 7.4.2 autorepeat-subsequent-delay
941 Sets the delay for subsequent characters in typematic autorepeat.
943 8 Lua functions
945 8.1 Core (in main table)
947 8.1.1 print
949 Print line to message console.
951 8.1.2 exec(string command)
953 Run command as it was entered on the command line
955 8.2 Table bit:
957 Bitwise logical functions and related.
959 8.2.1 bit.none(number...) / bit.bnot(number...)
961 48-bit bitwise NOT / NONE function (set bits that are set in none 
962 of the arguments).
964 8.2.2 bit.any(number...) / bit.bor(number...)
966 48-bit bitwise OR / ANY function (set bits that are set in any of 
967 the arguments).
969 8.2.3 bit.all(number...) / bit.band(number...)
971 48-bit bitwise AND / ALL function (set bits that are set in all 
972 of the arguments).
974 8.2.4 bit.parity(number...) / bit.bxor(number...)
976 48-bit bitwise XOR / PARITY function (set bits that are set in 
977 odd number of the arguments).
979 8.2.5 bit.lrotate(number base[, number amount[, number bits]])
981 Rotate bits-bit (max 48, default 48) number left by amount 
982 (default 1) places.
984 8.2.6 bit.rrotate(number base[, number amount[, number bits]])
986 Rotate bits-bit (max 48, default 48) number right by amount 
987 (default 1) places.
989 8.2.7 bit.lshift(number base[, number amount[, number bits]])
991 Shift bits-bit (max 48, default 48) number left by amount 
992 (default 1) places. The new bits are filled with zeroes.
994 8.2.8 bit.lrshift(number base[, number amount[, number bits]])
996 Shift bits-bit (max 48, default 48) number logically right by 
997 amount (default 1) places. The new bits are filled with zeroes.
999 8.2.9 bit.arshift(number base[, number amount[, number bits]])
1001 Shift bits-bit (max 48, default 48) number arithmetically right 
1002 by amount (default 1) places. The new bits are shifted in with 
1003 copy of the high bit.
1005 8.3 Table gui:
1007 Most of these functions can only be called in on_paint and 
1008 on_video callbacks. Exceptions are noted.
1010 Colors are 32-bit. Bits 0-7 are the blue component, bits 8-15 are 
1011 the green component, bits 16-23 are the red component, bits 24-31 
1012 are alpha component (0 is fully opaque, 255 is almost 
1013 transparent). -1 is the fully transparent color. Alpha values 
1014 greater than 127 do work.
1016 Origin of coordinates is at top left corner of game display area. 
1017 Left and top gaps correspond to negative coordinates.
1019 8.3.1 gui.resolution()
1021 Returns 2-tuple (hresolution, vresolution).
1023 8.3.2 gui.<class>_gap(number gap)
1025 Set the <class> (left, right, top, bottom) gap to specified value 
1026 (max gap is 8191).
1028 8.3.3 gui.text(number x, number y, string text[, number fgc[, 
1029   number bgc]])
1031 Draw specified text on the GUI (each character cell is 8 or 16 
1032 wide and 16 high). Parameters:
1034 • x: X-coordinate to start the drawing from (and x-coordinate at 
1035   begining of the lines).
1037 • y: Y-coordinate to start the drawing from.
1039 • text: The text to draw.
1041 • fgc: Text color (default is 0xFFFFFF (white))
1043 • bgc: Background color (default is -1 (transparent))
1045 8.3.4 gui.textH(number x, number y, string text[, number fgc[, 
1046   number bgc]])
1048 Like gui.text, but draw using double-width.
1050 8.3.5 gui.textV(number x, number y, string text[, number fgc[, 
1051   number bgc]])
1053 Like gui.text, but draw using double-height.
1055 8.3.6 gui.textHV(number x, number y, string text[, number fgc[, 
1056   number bgc]])
1058 Like gui.text, but draw using double-width/double-height.
1060 8.3.7 gui.rectangle(number x, number y, number width, number 
1061   height[, number thickness[, number outline[, number fill]]])
1063 Draw rectangle on the GUI. Parameters:
1065 • x: X-coordinate of left edge.
1067 • y: Y-coordinate of upper edge.
1069 • width: Width of rectangle.
1071 • height: Height of rectangle.
1073 • thickness: Thickness of outline (default is 1).
1075 • outline: Color of outline (default is 0xFFFFFF (white))
1077 • fill: Color of fil (default is -1 (transparent))
1079 8.3.8 gui.pixel(number x, number y[, number color])
1081 Draw one pixel on the GUI. Parameters:
1083 • x: X-coordinate of the pixel
1085 • y: Y-coordinate of the pixel
1087 • color: Color of the pixel (default is 0xFFFFFF (white))
1089 8.3.9 gui.crosshair(number x, number y[, number length[, number 
1090   color]])
1092 Draw a crosshair. Parameters:
1094 • x: X-coordinate of the crosshair
1096 • y: Y-coordinate of the crosshair
1098 • length: Length of the crosshair lines (default 10).
1100 • color: Color of the crosshair (default is 0xFFFFFF (white))
1102 8.3.10 gui.line(number x1, number y1, number x2, number y2[, 
1103   number color])
1105 Draw a thin line. Parameters:
1107 • x1: X-coordinate of one end.
1109 • y1: Y-coordinate of one end.
1111 • x2: X-coordinate of the other end.
1113 • y2: Y-coordinate of the other end.
1115 • color: Color of the line (default is 0xFFFFFF (white)).
1117 8.3.11 gui.circle(number x, number y, number r[, number thick[, 
1118   number border[, number fil]]])
1120 Draw a circle. Parameters.
1122 • x: X-coordinate of the center
1124 • y: Y-coordinate of the center
1126 • r: The radius of the circle
1128 • thick: Border thickness
1130 • border: Border color (default is 0xFFFFFF (white))
1132 • fill: Fill color (default is -1 (transparent)).
1134 8.3.12 gui.repaint()
1136 Request on_repaint() to happen as soon as possible. Can be used 
1137 anywhere.
1139 8.3.13 gui.subframe_update(boolean on)
1141 Request subframe updates (calling on_paint() on subframes) to 
1142 happen (on=true) or not happen (on=false). Can be used anywhere.
1144 8.3.14 gui.screenshot(string filename)
1146 Write PNG screenshot of the current frame (no drawings) to 
1147 specified file. Can be used anywhere.
1149 8.3.15 gui.color(number r, number g, number b[, number a])
1151 Returns color (in notation Lua scripts use) corresponding to 
1152 color (r,g,b), each component in scale 0-255. If a is specified, 
1153 that is alpha (0 is fully transparent, 256(sic) is fully opaque). 
1154 The default alpha is 256.
1156 8.3.16 gui.status(string name, string value)
1158 Set status field “L[<name>]” to <value> in status area. Can be 
1159 used anywhere.
1161 8.4 table input
1163 Input handling. Only available in on_input callback.
1165 8.4.1 input.get(number controller, number index)
1167 Read the specified index (0-11) from specified controller (0-7). 
1168 Notes:
1170 • Uses physical controller numbering. Gamepad in port 2 is 
1171   controller 4, not 1!
1173 8.4.2 input.set(number controller, number index, number value)
1175 Write the specified index (0-11) from specified controller (0-7), 
1176 storing value. Notes:
1178 • Uses physical controller numbering. Gamepad in port 2 is 
1179   controller 4, not 1!
1181 8.4.3 input.reset([number cycles])
1183 Execute reset. If cycles is greater than zero, do delayed reset. 
1184 0 (or no value) causes immediate reset.
1186 • Only available with subframe flag false.
1188 8.5 Table hostmemory
1190 Host memory handling (extra memory saved to savestates). Host 
1191 memory starts empty.
1193 8.5.1 hostmemory.read(number address)
1195 Reads hostmemory slot address. Slot numbers out of range return 
1196 false instead of numeric.
1198 8.5.2 hostmemory.write(number address, number value)
1200 Writes hostmemory slot with 0-255. Slot numbers out of range 
1201 cause extension of host memory slot space.
1203 8.5.3 hostmemory.readbyte(number address)
1205 Read unsigned byte (1 element) from given address. Slots out of 
1206 range return false.
1208 8.5.4 hostmemory.writebyte(number address, number value)
1210 Write unsigned byte (1 element) to given slot. Slot numbers out 
1211 of range cause extension.
1213 8.5.5 hostmemory.readsbyte(number address)
1215 Read signed byte (1 element) from given address. Slots out of 
1216 range return false.
1218 8.5.6 hostmemory.writesbyte(number address, number value)
1220 Write signed byte (1 element) to given slot. Slot numbers out of 
1221 range cause extension.
1223 8.5.7 hostmemory.readword(number address)
1225 Read unsigned word (2 elements) from given address. Slots out of 
1226 range return false.
1228 8.5.8 hostmemory.writeword(number address, number value)
1230 Write unsigned word (2 elements) to given slot. Slot numbers out 
1231 of range cause extension.
1233 8.5.9 hostmemory.readsword(number address)
1235 Read signed word (2 elements) from given address. Slots out of 
1236 range return false.
1238 8.5.10 hostmemory.writesword(number address, number value)
1240 Write signed word (2 elements) to given slot. Slot numbers out of 
1241 range cause extension.
1243 8.5.11 hostmemory.readdword(number address)
1245 Read unsigned doubleword (4 elements) from given address. Slots 
1246 out of range return false.
1248 8.5.12 hostmemory.writedword(number address, number value)
1250 Write unsigned doubleword (4 elements) to given slot. Slot 
1251 numbers out of range cause extension.
1253 8.5.13 hostmemory.readsdword(number address)
1255 Read signed doubleword (4 elements) from given address. Slots out 
1256 of range return false.
1258 8.5.14 hostmemory.writesdword(number address, number value)
1260 Write signed doubleword (4 elements) to given slot. Slot numbers 
1261 out of range cause extension.
1263 8.5.15 hostmemory.readqword(number address)
1265 Read unsigned quadword (8 elements) from given address. Slots out 
1266 of range return false.
1268 8.5.16 hostmemory.writeqword(number address, number value)
1270 Write unsigned quadword (4 elements) to given slot. Slot numbers 
1271 out of range cause extension.
1273 8.5.17 hostmemory.readsqword(number address)
1275 Read signed quadword (8 elements) from given address. Slots out 
1276 of range return false.
1278 8.5.18 hostmemory.writesqword(number address, number value)
1280 Write signed quadword (8 elements) to given slot. Slot numbers 
1281 out of range cause extension.
1283 8.6 Table movie
1285 Movie handling
1287 8.6.1 movie.currentframe()
1289 Return number of current frame.
1291 8.6.2 movie.framecount()
1293 Return number of frames in movie.
1295 8.6.3 movie.readonly()
1297 Return true if in readonly mode, false if in readwrite.
1299 8.6.4 movie.set_readwrite()
1301 Set readwrite mode (does not cause on_readwrite callback).
1303 8.6.5 movie.frame_subframes(number frame)
1305 Count number of subframes in specified frame (frame numbers are 
1306 1-based) and return that.
1308 8.6.6 movie.read_subframe(number frame, number subframe)
1310 Read specifed subframe in specified frame and return data as 
1311 array (100 elements, numbered 0-99 currently).
1313 8.7 Table settings
1315 Routines for settings manipulation
1317 8.7.1 settings.get(string name)
1319 Get value of setting. If setting is blank, returns false. If 
1320 setting value can't be obtained, returns (nil, error message).
1322 8.7.2 settings.set(string name, string value)
1324 Set value of setting. If setting can't be set, returns (nil, 
1325 error message).
1327 8.7.3 settings.is_set(string name)
1329 Returns if setting is set. If setting does not exist, returns 
1330 (nil, error message).
1332 8.7.4 settings.blank(string name)
1334 Blanks a setting and returns true. If setting can't be blanked, 
1335 returns (nil, error message).
1337 8.8 Table memory
1339 Contains various functions for managing memory
1341 8.8.1 memory.vma_count()
1343 Returns the number of VMAs
1345 8.8.2 memory.read_vma(number index)
1347 Reads the specified VMA (indices start from zero). Trying to read 
1348 invalid VMA gives nil. The read VMA is table with the following 
1349 fields:
1351 • region_name (string): The readable name of the VMA
1353 • baseaddr (number): Base address of the VMA
1355 • lastaddr (number): Last address in the VMA.
1357 • size (number): The size of VMA in bytes.
1359 • readonly (boolean): True of the VMA corresponds to ROM.
1361 • native_endian (boolean): True if the VMA has native endian as 
1362   opposed to little endian.
1364 8.8.3 memory.find_vma(number address)
1366 Finds the VMA containing specified address. Returns table in the 
1367 same format as read_vma or nil if not found.
1369 8.8.4 memory.readbyte(number address)
1371 Reads the specified address as unsigned byte and returns the 
1372 result.
1374 8.8.5 memory.readsbyte(number address)
1376 Reads the specified address as signed byte and returns the 
1377 result.
1379 8.8.6 memory.writebyte(number address, number value)
1381 Writes the specified value (negative values undergo 2's 
1382 complement) to specified address (as a byte).
1384 8.8.7 memory.readword(number address)
1386 Reads the specified address as unsigned word and returns the 
1387 result.
1389 8.8.8 memory.readsword(number address)
1391 Reads the specified address as signed word and returns the 
1392 result.
1394 8.8.9 memory.writeword(number address, number value)
1396 Writes the specified value (negative values undergo 2's 
1397 complement) to specified address (as a word).
1399 8.8.10 memory.readdword(number address)
1401 Reads the specified address as unsigned doubleword and returns 
1402 the result.
1404 8.8.11 memory.readsdword(number address)
1406 Reads the specified address as signed doubleword and returns the 
1407 result.
1409 8.8.12 memory.writedword(number address, number value)
1411 Writes the specified value (negative values undergo 2's 
1412 complement) to specified address (as a doubleword).
1414 8.8.13 memory.readqword(number address)
1416 Reads the specified address as unsigned quadword and returns the 
1417 result.
1419 8.8.14 memory.readsqword(number address)
1421 Reads the specified address as signed quadword and returns the 
1422 result.
1424 8.8.15 memory.writeqword(number address, number value)
1426 Writes the specified value (negative values undergo 2's 
1427 complement) to specified address (as a quadword).
1429 8.9 Table _SYSTEM
1431 Contains copy of global variables from time of Lua 
1432 initialization. Non-writeable.
1434 8.10 Callbacks
1436 Various callbacks to Lua that can occur.
1438 8.10.1 Callback: on_paint()
1440 Called when screen is being painted. Any gui.* calls requiring 
1441 graphic context draw on the screen.
1443 8.10.2 Callback: on_video()
1445 Called when video dump frame is being painted. Any gui.* calls 
1446 requiring graphic context draw on the video.
1448 8.10.3 Callback: on_frame()
1450 Called on each starting whole frame.
1452 8.10.4 Callback: on_startup()
1454 Called when the emulator is starting (lsnes.rc and --run files 
1455 has been run).
1457 8.10.5 Callback: on_pre_load(string name)
1459 Called just before savestate/movie load occurs (note: loads are 
1460 always delayed, so this occurs even when load was initiated by 
1461 lua).
1463 8.10.6 Callback: on_err_load(string name)
1465 Called if loadstate goes wrong.
1467 8.10.7 Callback: on_post_load(string name, boolean was_savestate)
1469 Called on successful loadstate. was_savestate gives if this was a 
1470 savestate or a movie.
1472 8.10.8 Callback: on_pre_save(string name, boolean is_savestate)
1474 Called just before savestate save occurs (note: movie saves are 
1475 synchronous and won't trigger these callbacks if called from 
1476 Lua).
1478 8.10.9 Callback: on_err_save(string name)
1480 Called if savestate goes wrong.
1482 8.10.10 Callback: on_post_save(string name, boolean is_savestate)
1484 Called on successful savaestate. is_savestate gives if this was a 
1485 savestate or a movie.
1487 8.10.11 Callback: on_quit()
1489 Called when emulator is shutting down.
1491 8.10.12 Callback: on_input(boolean subframe)
1493 Called when emulator is just sending input to bsnes core. 
1494 Warning: This is called even in readonly mode, but the results 
1495 are ignored.
1497 8.10.13 Callback: on_reset()
1499 Called when SNES is reset.
1501 8.10.14 Callback: on_readwrite()
1503 Called when moving into readwrite mode as result of “set-rwmode” 
1504 command (note: moving to rwmode by Lua won't trigger this, as per 
1505 recursive entry protection).
1507 8.10.15 Callback: on_snoop(number port, number controller, number 
1508   index, number value)
1510 Called each time bsnes asks for input. The value is the final 
1511 value to be sent to bsnes core (readonly mode, autohold and 
1512 autofire have been taken into account). Might be useful when 
1513 translating movies to format suitable for console verification. 
1514 Note: There is no way to modify the value to be sent.
1516 9 Modifier and key names:
1518 9.1 SDL Platform
1520 9.1.1 Modifier names
1522 Following modifier names are known:
1524 • ctrl, lctrl, rctrl: Control keys
1526 • alt, lalt, ralt: ALT keys.
1528 • shift, lshift, rshift: Shift keys.
1530 • meta, lmeta, rmeta: Meta keys.
1532 • num, caps: Numlock/Capslock (these are sticky!)
1534 • mode: Mode select.
1536 9.1.2 Key names
1538 Following key names are known:
1540 • backspace, tab, clear, return, pause, escape, space, exclaim, 
1541   quotedbl, hash, dollar, ampersand, quote, leftparen, 
1542   rightparen, asterisk, plus, comma, minus, period, slash, 0, 1, 
1543   2, 3, 4, 5, 6, 7, 8, 9, colon, semicolon, less, equals, 
1544   greater, question, at, leftbracket, backslash, rightbracket, 
1545   caret, underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, 
1546   l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, delete, world_0, 
1547   world_1, world_2, world_3, world_4, world_5, world_6, world_7, 
1548   world_8, world_9, world_10, world_11, world_12, world_13, 
1549   world_14, world_15, world_16, world_17, world_18, world_19, 
1550   world_20, world_21, world_22, world_23, world_24, world_25, 
1551   world_26, world_27, world_28, world_29, world_30, world_31, 
1552   world_32, world_33, world_34, world_35, world_36, world_37, 
1553   world_38, world_39, world_40, world_41, world_42, world_43, 
1554   world_44, world_45, world_46, world_47, world_48, world_49, 
1555   world_50, world_51, world_52, world_53, world_54, world_55, 
1556   world_56, world_57, world_58, world_59, world_60, world_61, 
1557   world_62, world_63, world_64, world_65, world_66, world_67, 
1558   world_68, world_69, world_70, world_71, world_72, world_73, 
1559   world_74, world_75, world_76, world_77, world_78, world_79, 
1560   world_80, world_81, world_82, world_83, world_84, world_85, 
1561   world_86, world_87, world_88, world_89, world_90, world_91, 
1562   world_92, world_93, world_94, world_95, kp0, kp1, kp2, kp3, 
1563   kp4, kp5, kp6, kp7, kp8, kp9, kp_period, kp_divide, 
1564   kp_multiply, kp_minus, kp_plus, kp_enter, kp_equals, up, down, 
1565   right, left, insert, home, end, pageup, pagedown, f1, f2, f3, 
1566   f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, numlock, 
1567   capslock, scrollock, rshift, lshift, rctrl, lctrl, ralt, lalt, 
1568   rmeta, lmeta, lsuper, rsuper, mode, compose, help, print, 
1569   sysreq, break, menu, power, euro, undo
1571 • Names of form 'key<n>' where <n> is 0-255 are interpretted as 
1572   key having hardware-dependent scan code of <n> (useful to bind 
1573   those keys that don't have symbolic names).
1575 9.1.3 Joystick pseudo-keys:
1577 • joystick<num>button<button>: Joystick <num> (0-based) button 
1578   <button> (0-based).
1580 • joystick<num>hat<hat>n: Joystick <num> (0-based) hat <hat> 
1581   (0-based) up.
1583 • joystick<num>hat<hat>w: Joystick <num> (0-based) hat <hat> 
1584   (0-based) left.
1586 • joystick<num>hat<hat>s: Joystick <num> (0-based) hat <hat> 
1587   (0-based) down.
1589 • joystick<num>hat<hat>e: Joystick <num> (0-based) hat <hat> 
1590   (0-based) right.
1592 • joystick<num>axis<axis>-: Joystick <num> (0-based) axis <axis> 
1593   negative position (axis modes axis and axis_inverse).
1595 • joystick<num>axis<axis>+: Joystick <num> (0-based) axis <axis> 
1596   positive position (axis modes axis and axis_inverse).
1598 • joystick<num>axis<axis>: Joystick <num> (0-based) axis <axis> 
1599   pressure (axis modes pressure_*).
1601 9.1.4 Special buttons:
1603 • Escape: Enter/Exit Command mode, cancel modal dialogs.
1605 • Return (also KPEnter): Execute command, ok modal dialog.
1607 • Pgup/Up (also KP8/9 if no num lock; command mode): Previous 
1608   command in command history
1610 • Pgdn/Down(also KP2/3 if no num lock; command mode): Next 
1611   command in command history
1613 • Home (also KP7 if no num lock; command mode): Beginning of 
1614   command.
1616 • End (also KP1 if no num lock; command mode): End of command.
1618 • Left (also KP4 if no num lock; command mode): Move cursor left.
1620 • Right (also KP6 if no num lock; command mode): Move cursor 
1621   right.
1623 • Delete (also KP. if no num lock; command mode): Delete 
1624   character to right of cursor.
1626 • Insert (also KP0 if no num lock; command mode): Toggle between 
1627   insert / overwrite modes.
1629 • Backspace (command mode): Delete character to left of cursor.
1631 • LCTRL+LALT+ESCAPE: Ungraceful shutdown (leaves dump 
1632   corrupted!).
1634 9.2 wxWidgets platform
1636 9.2.1 Modifier names:
1638 Following modifier names are known:
1640 • alt
1642 • ctrl
1644 • shift 
1646 • meta
1648 • cmd (Mac OS X only)
1650 9.2.2 Key names:
1652 Following key names are known:
1654 • back, tab, return, escape, space, exclaim, quotedbl, hash, 
1655   dollar, percent, ampersand, quote, leftparen, rightparen, 
1656   asterisk, plus, comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 
1657   6, 7, 8, 9, colon, semicolon, less, equals, greater, question, 
1658   at, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, 
1659   u, v, w, x, y, z, leftbracket, backslash, rightbracket, caret, 
1660   underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, 
1661   n, o, p, q, r, s, t, u, v, w, x, y, z, leftcurly, pipe, 
1662   rightcurly, tilde, delete, start, lbutton, rbutton, cancel, 
1663   mbutton, clear, shift, alt, control, menu, pause, capital, end, 
1664   home, lefT, up, right, down, select, print, execute, snapshot, 
1665   insert, help, numpad0, numpad1, numpad2, numpad3, numpad4, 
1666   numpad5, numpad6, numpad7, numpad8, numpad9, multiply, add, 
1667   separator, subtract, decimal, divide, f1, f2, f3, f4, f5, f6, 
1668   f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, 
1669   f20, f21, f22, f23, f24, numlock, scroll, pageup, pagedown, 
1670   numpad_space, numpad_tab, numpad_enter, numpad_f1, numpad_f2, 
1671   numpad_f3, numpad_f4, numpad_home, numpad_left, numpad_up, 
1672   numpad_right, numpad_down, numpad_pageup, numpad_pagedown, 
1673   numpad_end, numpad_begin, numpad_insert, numpad_delete, 
1674   numpad_equal, numpad_multiply, numpad_add, numpad_separator, 
1675   numpad_subtract, numpad_decimal, numpad_divide, windows_left, 
1676   windows_right, windows_menu, command, special1, special2, 
1677   special3, special4, special5, special6, special7, special8, 
1678   special9, special10, special11, special12, special13, 
1679   special14, special15, special16, special17, special18, 
1680   special19, special20
1682 10 Movie file format
1684 Movie file is .zip archive in itself, normal ZIP archive tools 
1685 work on it (note: If you recompress it, do not use compression 
1686 methods other than store and deflate and especially do not use 
1687 encryption of any kind).
1689 10.1 Detecting clean start/SRAM/Savestate
1691 • If file has member “savestate” it is savestate, otherwise:
1693 • If file has members with names starting “moviesram.” it is 
1694   movie starting from SRAM, otherwise:
1696 • It is movie starting from clear state.
1698 10.2 Member: gametype
1700 Type of game ROM and region (as one line). Valid values are:
1703 +--------------+---------------------+--------+
1704 |    Value     |       System        | Region |
1705 +--------------+---------------------+--------+
1706 +--------------+---------------------+--------+
1707 |  snes_pal    |     Super NES       |  PAL   |
1708 +--------------+---------------------+--------+
1709 |   sgb_pal    |   Super Game Boy    |  PAL   |
1710 +--------------+---------------------+--------+
1711 |  snes_ntsc   |     Super NES       |  NTSC  |
1712 +--------------+---------------------+--------+
1713 |  sgb_ntsc    |   Super Game Boy    |  NTSC  |
1714 +--------------+---------------------+--------+
1715 |     bsx      | BS-X (non-slotted)  |  NTSC  |
1716 +--------------+---------------------+--------+
1717 | bsxslotted   |   BS-X (slotted)    |  NTSC  |
1718 +--------------+---------------------+--------+
1719 | sufamiturbo  |    Sufami Turbo     |  NTSC  |
1720 +--------------+---------------------+--------+
1723 Frame rates are:
1726 +---------+-----------------+
1727 | Region  | Framerate (fps) |
1728 +---------+-----------------+
1729 +---------+-----------------+
1730 |  PAL    |   322445/6448   |
1731 +---------+-----------------+
1732 |  NTSC   | 10738636/178683 |
1733 +---------+-----------------+
1736 10.3 Member: port1
1738 Contains type of port #1 (as one line). Valid values are 'none', 
1739 'gamepad', 'multitap' and 'mouse'. If not present, defaults to 
1740 'gamepad'.
1742 10.4 Member: port2
1744 Contains type of port #2 (as one line). Valid values are 'none', 
1745 'gamepad', 'multitap', 'mouse', 'superscope', 'justifier' and 
1746 'justifiers'. If not present, defaults to 'none'.
1748 10.5 Member: gamename
1750 Contains name of the game (as one line).
1752 10.6 Member: authors
1754 Contains authors, one per line. Part before '|' is the full name, 
1755 part after is the nickname.
1757 10.7 Member: systemid
1759 Always “lsnes-rr1” (one line). Used to reject other saves.
1761 10.8 Member: controlsversion
1763 Always “0” (one line). Used to identify what controls are there.
1765 10.9 Member: “coreversion”
1767 Contains bsnes core version number (as one line).
1769 10.10 Member: projectid
1771 Contains project ID (as one line). Used to identify if two movies 
1772 are part of the same project.
1774 10.11 Member: {rom,slota,slotb}{,xml}.sha256
1776 Contains SHA-256 of said ROM or ROM mapping file (as one line). 
1777 Absent if corresponding file is absent.
1779 10.12 Member: moviesram.<name>
1781 Raw binary startup SRAM of kind <name>. Only present in 
1782 savestates and movies starting from SRAM.
1784 10.13 Member: saveframe
1786 Contains frame number (as one line) of frame movie was saved on. 
1787 Only present in savestates.
1789 10.14 Member: lagcounter
1791 Current value of lag counter (as one line). Only present in 
1792 savestates.
1794 10.15 Member: pollcounters
1796 Contains poll counters (currently 100 of them), one per line. 
1797 Each line is raw poll count if DRDY is set for it. Otherwise it 
1798 is negative poll count minus one. Only present in savestates.
1800 10.16 Member: hostmemory
1802 Raw binary dump of host memory. Only present in savestates.
1804 10.17 Member: savestate
1806 The raw binary savestate itself. Savestate detection uses this 
1807 file, only present in savestates.
1809 10.18 Member: screenshot
1811 Screenshot of current frame. Only present in savestates. First 2 
1812 bytes are big-endian width of image, rest are 24-bit RGB image 
1813 data. Height of image is inferred from the width and size of 
1814 data.
1816 10.19 Member: sram.<name>
1818 Raw binary SRAM of kind <name> at time of savestate. Only present 
1819 in savestates.
1821 10.20 Member: input
1823 The actual input track, one line per subframe (blank lines are 
1824 skipped).
1826 • If the first byte of each line is '.', ' ', <tab> or '|', then 
1827   the line is part of same frame as previous, otherwise it starts 
1828   a new frame.
1830 • First subframe must start a new frame.
1832 Length of movie in frames is number of lines in input file that 
1833 start a new frame.
1835 10.21 Member: rerecords
1837 Contains textual base-10 rerecord count (as one line; emulator 
1838 just writes this, it doesn't read it) + 1.
1840 10.22 Member: rrdata
1842 This member stores set of load IDs. There is one load ID per 
1843 rerecord (plus one corresponding to start of project).
1845 • This member constists of concatenation of records
1847 • Each record is 2-36 bytes long and can represent 1-16,843,009 
1848   consequtive IDs.
1850 • IDs are interpretted as 256-bit big-endian integers with 
1851   warparound.
1853 • Initial predicted ID is all zeroes.
1855 Format of each record is:
1857 • 1 byte: Opcode byte. Bits 0-4 are prefix length (prefixlen), 
1858   bits 5-6 are count length (countlen). Bit 7 is unused.
1860 • 32-prefixlen bytes of ID.
1862 • countlen bytes of big-endian count (count).
1864 Records are processed as follows:
1866 • To form the first ID encoded by record, take the first 
1867   prefixlen bytes predicted ID and append the read ID value to 
1868   it. The result is the first ID encoded.
1870 • If countlen is 0, record encodes 1 ID.
1872 • If countlen is 1, record encodes 2+count IDs.
1874 • If countlen is 2, record encodes 258+count IDs.
1876 • If countlen is 3, record encodes 65794+count IDs.
1878 • The new predicted ID is the next ID after last one encoded by 
1879   the record.
1881 The number of rerecords + 1 is equal to the sum of number of IDs 
1882 encoded by all records.
1884 10.23 Member: starttime.second
1886 Movie starting time, second part. Epoch is Unix epoch. Default is 
1887 1,000,000,000.
1889 10.24 Member: starttime.subsecond
1891 Movie starting time, subsecond part. Unit is CPU clocks. Default 
1892 is 0.
1894 10.25 Member: savetime.second
1896 Movie saving time, second part. Default is starttime.second. Only 
1897 present in savestates.
1899 10.26 Member: savetime.subsecond
1901 Movie saving time, subsecond part. Default is 
1902 starttime.subsecond. Only present in savestates.
1904 11 Quick'n'dirty encode guide
1906 1. Start the emulator and load the movie file.
1908 2. Set large AVI option 'set-setting avi-large on'
1910 3. Enable dumping 'dump-avi tmpdump' 
1912 4. Unpause and let it run until you want to end dumping.
1914 5. Close the emulator (closing the window is the easiest way). Or 
1915   use 'end-avi'.
1917 6. For each tmpdump*.avi file created, on command prompt, do 
1918   'x264 --crf 10 -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
1920 7. Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
1922 8. Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + 
1923   tmpdump_0000001.mkv + tmpdump_0000002.mkv' (list every 
1924   tmpdump_<numbers>.mkv, with + in between).
1926 9. Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'. Now 
1927   final.mkv contains quick'n'dirty encode.
1929 12 Axis configurations for some gamepad types:
1931 12.1 XBox360 controller:
1933 Axes 2 and 5 (joystick<n>axis2 and joystick<n>axis5) should be 
1934 set to pressure-+.
1936 set-axis joystick0axis2 pressure-+
1938 set-axis joystick0axis5 pressure-+
1940 • This is needed for SDL only. EVDEV sets those types correctly.
1942 12.2 PS3 “sixaxis” controller:
1944 Axes 8-19 should be disabled.
1946 set-axis joystick0axis8 disabled
1948 set-axis joystick0axis9 disabled
1950 set-axis joystick0axis10 disabled
1952 set-axis joystick0axis11 disabled
1954 set-axis joystick0axis12 disabled
1956 set-axis joystick0axis13 disabled
1958 set-axis joystick0axis14 disabled
1960 set-axis joystick0axis15 disabled
1962 set-axis joystick0axis16 disabled
1964 set-axis joystick0axis17 disabled
1966 set-axis joystick0axis18 disabled
1968 set-axis joystick0axis19 disabled
1970 13 Errata:
1972 13.1 Problems from BSNES core:
1974 • The whole pending save stuff.
1976 • Lack of layer hiding.
1978 • It is slow (especially accuracy).
1980 • Firmwares can't be loaded from ZIP archives.
1982 13.2 Other problems:
1984 • Modifiers don't work with pseudo-keys (SDL, EVDEV).
1986 • Audio for last dumped frame is not itself dumped.
1988 • Audio in UI is pretty bad in quality if game doesn't run at 
1989   full speed.
1991 • AVI compression levels 10-18 are not compatible with AVISynth 
1992   AVISource.
1994 • No menus, command based interface (SDL).
1996 • Long commands don't scroll.
1998 • The SDL screen drawing is slow.
2000 • Wxwidgets UI is still pretty buggy.
2002 14 Changelog:
2004 14.1 rr0-beta1
2006 • Fix -Wall warnings
2008 • Fix dumper video corruption with levels 10-18.
2010 14.2 rr0-beta2
2012 • Autofire
2014 • Lots of code cleanups
2016 • Lua interface to settings
2018 • Allow specifying AVI borders without Lua
2020 • Fix scaling if vscale > 1 and originx > 0 (left border exists)
2022 • on_snoop lua callback
2024 • Faster movie loading and saving.
2026 14.3 rr0-beta3
2028 • Joystick support
2030 14.4 rr0-beta4
2032 • Fix multi-buttons
2034 • Save jukebox functionality.
2036 14.5 rr0-beta5
2038 • Try to fix some nasty failing movie load edge cases
2040 • Allow specifying scripts to run on command line.
2042 14.6 rr0-beta6
2044 • Major source code reorganization.
2046 • Backup savestates before overwriting.
2048 • Don't crash if loading initial state fails.
2050 14.7 rr0-beta7
2052 • Fix firmware lookup
2054 • Fix author name parsing
2056 • Fix rerecord counting
2058 • (SDL) Print messages to console if SDL is uninitialized
2060 • Add movieinfo program
2062 • Fix loading movies starting from SRAM.
2064 14.8 rr0-beta8
2066 • Add support for unattended dumping
2068 • Fix compiling for Win32
2070 • Don't lock up if sound can't be initialized
2072 • Strip trailing CR from commands
2074 • Don't try to do dubious things in global ctors (fix crash on 
2075   startup)
2077 14.9 rr0-beta9
2079 • Small documentation tweaking
2081 • Fix make clean
2083 • Fix major bug in modifier matching
2085 14.10 rr0-beta10
2087 • Lots of documentation fixes
2089 • Use dedicated callbacks for event backcomm., not commands.
2091 • Ensure that the watchdog is not hit when executing delayed 
2092   reset.
2094 • Remove errant tab from joystick message.
2096 14.11 rr0-beta11
2098 • Make autofire operate in absolute time, not linear time
2100 • Reinitialize controls when resuming from loadstate
2102 • Some more code cleanups
2104 • If Lua allocator fails, call OOM_panic()
2106 • Byte/word/dword/qword sized host memory write/read functions.
2108 • Dump at correct framerate if dumping interlaced NTSC 
2109   (height=448).
2111 14.12 rr0-beta12
2113 • Actually include the complete source code
2115 • Keep track of RTC
2117 14.13 rr0-beta13
2119 • Document {save,start}time.{,sub}second.
2121 • Intercept time() from bsnes core.
2123 14.14 rr0-beta14
2125 • Allow disabling time() interception (allow build on Mac OS X)
2127 • Use SDLMain on Mac OS X (make SDL not crash)
2129 • Disable delayed resets (just plain too buggy for now).
2131 • Code cleanups
2133 • Use 16-bit for graphics/video instead of 32-bit.
2135 • gui.rectangle/gui.pixel
2137 • gui.crosshair
2139 • New CSCD writer implementation.
2141 14.15 rr0-beta15
2143 • Fix interaction of * and +.
2145 • Manual improvements
2147 • Use gettimeofday()/usleep(), these seem portable enough.
2149 • Move joystick axis manipulation to keymapper code.
2151 • Changes to how read-only works.
2153 • Refactor controller input code.
2155 14.16 rr0-beta16
2157 • Fix mouseclick scale compensation.
2159 • Draw area boundaries correctly in SDL code.
2161 • gui.screenshot.
2163 • Fix CSCD output (buffer overrun and race condition).
2165 14.17 rr0-beta17
2167 • JMD dumping support.
2169 • Allow unattended dumping to JMD.
2171 • Move to BSNES v083.
2173 • Switch back to 32-bit colors.
2175 • Add Lua function gui.color.
2177 • Use some new C++11 features in GCC 4.6.
2179 • Be prepared for core frequency changes.
2181 • Pass colors in one chunk from Lua.
2183 14.18 rr0-beta18
2185 • New lua functions gui.line(), gui.status() and gui.circle(), 
2186   memory.vma_count(), memory.read_vma() and memory.find_vma().
2188 • Numerious documentation fixups
2190 • RTC time format changed
2192 • Reformat flags display
2194 • Allow lua package name to be overridden
2196 • SDUMP (high-quality dumping).
2198 • Split platform support to plugins.
2200 • Make all sound plugins support basic sound commands
2202 • Support portaudio for sound.
2204 • Allow disable Lua/SDL searching.
2206 • Upconvert colors when copying lcscreen to screen.
2208 • Reorganize source tree.
2210 • Evdev joystick support.
2212 • Refactor more code into generic window code.
2214 14.19 rr0-beta19
2216 • Refactor message handling.
2218 • Rework makefile
2220 • Documentation fixes
2222 • Finish pending saves before load/quit.
2224 • Wxwidgets graphics plugin.
2226 14.20 rr0-beta20
2228 • Get rid of win32-crap.[ch]pp.
2230 • Move files around a lot.
2232 • Get rid of need for host C++ compiler.
2234 • Bsnes v084 core.
2236 • Refactor inter-component communication.
2238 • Fix zero luma.
2240 • Fix crash on multiline aliases.
2242 • Load/Save settings in wxwidgets gui.
2244 14.21 rr0-beta21
2246 • Patch problems in bsnes core
2248 • SNES is little-endian, not big-endian!
2250 • Fix memory corruption in lcscreen::load()
2252 14.22 rr0-beta22
2254 • Fix interpretting repeat counts in rrdata loading.
2256 • New lua callback: on_frame()
2258 • Remove calls to runtosave() that aren't supposed to be there
2260 • Lua function: movie.read_rtc()
2262 • Ignore src/fonts/font.cpp
2264 • Fix more bsnes core problems
2266 • Control bsnes random seeding
2268 • Pause-on-end
2270 • Some bsnes core debugging features (state dump and state hash)
2272 • Fix titlebar version number (no, the last version wasn't 
2273   'lsnes-0-beta21', it was 'lsnes rr0-beta21').
2275 14.23 rr0-beta23
2277 • Fix memory corruption due to macro/field mixup
2279 • search-memory update
2281 • Allow direct-mapped framebuffer
2283 • SDL: Use SDL_ANYFORMAT if possible
2285 • SDMP2SOX: 2s delay modes.
2287 • Wxwidgets: Cleanups
2289 • Use sed -E, not sed -r. Fixes building on Mac OS X.
2291 • Wxwidgets: Save jukebox on exit
2293 • Fix RTC if using load-movie on savestate.
2295 • Fix crash related to full console mode.
2297 14.24 rr0-beta24
2299 • Wxwidgets: Allow bringing application to foreground on Mac OS 
2300   X.
2302 • Wxwidgets: Allow compiling on Mac OS X.
2304 • Use movie compare instead of movie hashing (faster save/load).
2306 • Lua: _SYSTEM table.
2308 14.25 rr0-beta25
2310 • sdmp2sox: Pad soundtrack if using -l or -L.
2312 • sdmp2sox: Fix NTSC overscan.
2314 • sdmp2sox: Add AR correction mode.
2316 • call lua_close() when exiting.
2318 • Fix zip_writer bug causing warnings from info-zip and error 
2319   from advzip.
2321 14.26 rr0-beta26
2323 • Fix IPS patching code (use bsnes core IPS patcher).
2325 • Implement BPS patching (using bsnes core IPS patcher).
2327 • Add feature to load headered ROMs.
2329 14.27 rr0-beta27
2331 • Show command names when showing keybindings
2333 14.28 rr0
2335 • Fix pause-on-end to be actually controllable
2337 • SDL: Poll all events in queue, not just first one (fixes 
2338   slowness in command typing)
2340 • Wxwidgets: Fix ROM loading.
2342 14.29 rr1-beta0
2344 • Lua: Add gui.textH, gui.textV, gui.textHV
2346 • Fix text colors on SDL on Mac OS X
2348 • Mode 'F' for finished in readonly mode.
2350 • Fix some WS errors.
2352 • Reliably pause after skip poll
2354 • Split UI and core into their own threads
2356 14.30 rr1-beta1
2358 • Remove leftover dummy SRAM slot
2360 • Fix controller numbers.
2362 14.31 rr1-beta2
2364 • Fix lsnes-dumpavi after interface change.
2366 • Also give BSNES patches for v085.
2368 • Pack movie data in memory.
2370 14.32 rr1-beta3
2372 • Fix framecount/length given when loading movies.
2374 • Controller command memory leak fixes.
2376 • Don't leak palette if freeing screen object.
2378 14.33 rr1-beta4
2380 • Detect revisions.
2382 • Wxwidgets: Allow controlling dumper from the menu.
2384 14.34 rr1-beta5
2386 • Rewrite parts of manual
2388 • Lua: Make it work with Lua 5.2.
2390 14.35 rr1-beta6
2392 • Win32: Fix compile errors.
2394 14.36 rr1-beta7
2396 • Refactor controller input code.
2398 • Fix crash when using command line on SDL / Mac OS X.