Refactor rectangle clipping calculation
[lsnes.git] / manual.lyx
blobf6d8668c90bca5f1ee2078a81b4516c696200aab
1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
2 \lyxformat 413
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options true
7 \maintain_unincluded_children false
8 \language finnish
9 \language_package default
10 \inputencoding auto
11 \fontencoding global
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
17 \font_sc false
18 \font_osf false
19 \font_sf_scale 100
20 \font_tt_scale 100
22 \graphics default
23 \default_output_format default
24 \output_sync 0
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
28 \use_hyperref false
29 \papersize default
30 \use_geometry false
31 \use_amsmath 1
32 \use_esint 1
33 \use_mhchem 1
34 \use_mathdots 1
35 \cite_engine basic
36 \use_bibtopic false
37 \use_indices false
38 \paperorientation portrait
39 \suppress_date false
40 \use_refstyle 1
41 \index Hakusana
42 \shortcut idx
43 \color #008000
44 \end_index
45 \secnumdepth 3
46 \tocdepth 3
47 \paragraph_separation indent
48 \paragraph_indentation default
49 \quotes_language english
50 \papercolumns 1
51 \papersides 1
52 \paperpagestyle default
53 \tracking_changes false
54 \output_changes false
55 \html_math_output 0
56 \html_css_as_file 0
57 \html_be_strict false
58 \end_header
60 \begin_body
62 \begin_layout Section
63 Introduction
64 \end_layout
66 \begin_layout Standard
67 lsnes is SNES rerecording emulator based on bsnes core.
68 \end_layout
70 \begin_layout Section
71 Command line options
72 \end_layout
74 \begin_layout Itemize
75 Syntax: lsnes.exe <rom-options> <misc-options> (<new-session-options>|<filename>)
76 \end_layout
78 \begin_layout Itemize
79 Syntax: lsnes-avidump <dump-options> <misc-options> <rom-options> <filename>
80 \end_layout
82 \begin_layout Itemize
83 Syntax: movieinfo.exe <filename>
84 \end_layout
86 \begin_layout Subsection
87 ROM options
88 \end_layout
90 \begin_layout Standard
91 These options control loading the ROM.
92 \end_layout
94 \begin_layout Subsubsection
95 --rom=<file>
96 \end_layout
98 \begin_layout Standard
99 Load <file> (SFC file format) as main SNES cartridge ROM.
100  This is the game ROM for SNES and cartridge BIOS for other types.
101  Required option.
102 \end_layout
104 \begin_layout Subsubsection
105 --rom-xml=<file>
106 \end_layout
108 \begin_layout Standard
109 Set the mapping XML file for main cartridge ROM.
110  If not specified, defaults are used.
111 \end_layout
113 \begin_layout Subsubsection
114 --bsx=<file>
115 \end_layout
117 \begin_layout Standard
118 Load <file> (BS file format) as BS-X non-slotted flash memory.
119  Also sets system type to BS-X non-slotted (not compatible with --bsxslotted=<fi
120 le>, --dmg=<file>, --slot-a=<file> nor --slot-b=<file>).
121 \end_layout
123 \begin_layout Subsubsection
124 --bsx-xml=<file>
125 \end_layout
127 \begin_layout Standard
128 Set mapping XML file for BS-X non-slotted flash memory.
129  If not specified, defaults are used.
130  Only can be used together with --bsx=<file>.
131 \end_layout
133 \begin_layout Subsubsection
134 --bsxslotted=<file>
135 \end_layout
137 \begin_layout Standard
138 Load <file> (BS file format) as BS-X slotted flash memory.
139  Also sets system type to BS-X slotted (not compatible with --bsx=<file>,
140  --dmg=<file>, --slot-a=<file> nor --slot-b=<file>).
141 \end_layout
143 \begin_layout Subsubsection
144 --bsxslotted-xml=<file>
145 \end_layout
147 \begin_layout Standard
148 Set mapping XML file for BS-X slotted flash memory.
149  If not specified, defaults are used.
150  Only can be used together with --bsxslotted=<file>.
151 \end_layout
153 \begin_layout Subsubsection
154 --dmg=<file>
155 \end_layout
157 \begin_layout Standard
158 Load <file> (GB file format) as Game Boy ROM.
159  Also sets system type to SGB (not compatible with --bsx=<file>, --bsxslotted=<f
160 ile>, --slot-a=<file> nor --slot-b=<file>).
161 \end_layout
163 \begin_layout Subsubsection
164 --dmg-xml=<file>
165 \end_layout
167 \begin_layout Standard
168 Set mapping XML file for Game Boy ROM.
169  If not specified, defaults are used.
170  Only can be used together with --dmg=<file>.
171 \end_layout
173 \begin_layout Subsubsection
174 --slot-a=<file>
175 \end_layout
177 \begin_layout Standard
178 Load <file> (ST file format) as Sufami turbo cartridge A ROM.
179  Also sets system type to Sufami Turbo (not compatible with --bsx=<file>,
180  --bsxslotted=<file> nor --dmg=<file>).
181 \end_layout
183 \begin_layout Subsubsection
184 --slot-a-xml=<file>
185 \end_layout
187 \begin_layout Standard
188 Set mapping XML file for Sufami turbo cartridge A ROM.
189  If not specified, defaults are used.
190  Only can be used together with --slot-a=<file>.
191 \end_layout
193 \begin_layout Subsubsection
194 --slot-b=<file>
195 \end_layout
197 \begin_layout Standard
198 Load <file> (ST file format) as Sufami turbo cartridge B ROM.
199  Also sets system type to Sufami Turbo (not compatible with --bsx=<file>,
200  --bsxslotted=<file> nor --dmg=<file>).
201 \end_layout
203 \begin_layout Subsubsection
204 --slot-b-xml=<file>
205 \end_layout
207 \begin_layout Standard
208 Set mapping XML file for Sufami turbo cartridge B ROM.
209  If not specified, defaults are used.
210  Only can be used together with --slot-b=<file>.
211 \end_layout
213 \begin_layout Subsubsection
214 --ips-rom=<file>
215 \end_layout
217 \begin_layout Standard
218 Apply IPS patch <file> to main cartridge ROM.
219  Requires --rom=<file>.
220 \end_layout
222 \begin_layout Subsubsection
223 --ips-rom-xml=<file>
224 \end_layout
226 \begin_layout Standard
227 Apply IPS patch <file> to main cartridge ROM mapping XML.
228  Requires --rom-xml=<file>.
229 \end_layout
231 \begin_layout Subsubsection
232 --ips-bsx=<file>
233 \end_layout
235 \begin_layout Standard
236 Apply IPS patch <file> to BS-X non-slotted flash.
237  Requires --bsx=<file>.
238 \end_layout
240 \begin_layout Subsubsection
241 --ips-bsx-xml=<file>
242 \end_layout
244 \begin_layout Standard
245 Apply IPS patch <file> to BS-X non-slotted flash mapping XML.
246  Requires --bsx-xml=<file>.
247 \end_layout
249 \begin_layout Subsubsection
250 --ips-bsxslotted=<file>
251 \end_layout
253 \begin_layout Standard
254 Apply IPS patch <file> to BS-X slotted flash.
255  Requires --bsxslotted=<file>.
256 \end_layout
258 \begin_layout Subsubsection
259 --ips-bsxslotted-xml=<file>
260 \end_layout
262 \begin_layout Standard
263 Apply IPS patch <file> to BS-X slotted flash mapping XML.
264  Requires --bsxslotted-xml=<file>.
265 \end_layout
267 \begin_layout Subsubsection
268 --ips-dmg=<file>
269 \end_layout
271 \begin_layout Standard
272 Apply IPS patch <file> to Game Boy ROM.
273  Requires --dmg=<file>.
274 \end_layout
276 \begin_layout Subsubsection
277 --ips-dmg-xml=<file>
278 \end_layout
280 \begin_layout Standard
281 Apply IPS patch <file> to Game Boy ROM mapping XML.
282  Requires --dmg-xml=<file>.
283 \end_layout
285 \begin_layout Subsubsection
286 --ips-slot-a=<file>
287 \end_layout
289 \begin_layout Standard
290 Apply IPS patch <file> to Sufami turbo cartridge A ROM.
291  Requires --slot-a=<file>.
292 \end_layout
294 \begin_layout Subsubsection
295 --ips-slot-a-xml=<file>
296 \end_layout
298 \begin_layout Standard
299 Apply IPS patch <file> to Sufami turbo cartridge A ROM mapping XML.
300  Requires --slot-a-xml=<file>.
301 \end_layout
303 \begin_layout Subsubsection
304 --ips-slot-b=<file>
305 \end_layout
307 \begin_layout Standard
308 Apply IPS patch <file> to Sufami turbo cartridge B ROM.
309  Requires --slot-b=<file>.
310 \end_layout
312 \begin_layout Subsubsection
313 --ips-slot-b-xml=<file>
314 \end_layout
316 \begin_layout Standard
317 Apply IPS patch <file> to Sufami turbo cartridge B ROM mapping XML.
318  Requires --slot-b-xml=<file>.
319 \end_layout
321 \begin_layout Subsubsection
322 --ips-offset=<offset>
323 \end_layout
325 \begin_layout Standard
326 Set IPS apply offset to <offset> (can be negative).
327  IPS apply offset is added to all addresses inside IPS file before applying.
328  If the resulting address is negative, write is ignored (with a warning).
329  If resulting address exceeds ROM size, the ROM is extended.
330 \end_layout
332 \begin_layout Subsubsection
333 --pal
334 \end_layout
336 \begin_layout Standard
337 Force ROM to be considered PAL-only (warning: Will cause error if used on
338  anything except SNES and SGB).
339 \end_layout
341 \begin_layout Subsubsection
342 --ntsc
343 \end_layout
345 \begin_layout Standard
346 Force ROM to be considered NTSC-only (default for everything except SNES
347  and SGB).
348 \end_layout
350 \begin_layout Subsection
351 New session options (lsnes.exe only)
352 \end_layout
354 \begin_layout Standard
355 If filename is not specified, new session is started.
356  These options control the properties of new session:
357 \end_layout
359 \begin_layout Subsubsection
360 --port1=<type>
361 \end_layout
363 \begin_layout Standard
364 Set type of port1.
365  Valid values are:
366 \end_layout
368 \begin_layout Itemize
369 none: No device connected
370 \end_layout
372 \begin_layout Itemize
373 gamepad: One gamepad (the default)
374 \end_layout
376 \begin_layout Itemize
377 multitap: Four gamepads (warning: makes most games refuse to start)
378 \end_layout
380 \begin_layout Itemize
381 mouse: Mouse.
382 \end_layout
384 \begin_layout Subsubsection
385 --port2=<type>
386 \end_layout
388 \begin_layout Standard
389 Set type of port2.
390  Valid values are:
391 \end_layout
393 \begin_layout Itemize
394 none: No device connected (the default)
395 \end_layout
397 \begin_layout Itemize
398 gamepad: One gamepad
399 \end_layout
401 \begin_layout Itemize
402 multitap: Four gamepads.
403 \end_layout
405 \begin_layout Itemize
406 mouse: Mouse
407 \end_layout
409 \begin_layout Itemize
410 superscope: Super Scope
411 \end_layout
413 \begin_layout Itemize
414 justifier: One justifier
415 \end_layout
417 \begin_layout Itemize
418 justifiers: Two justifiers
419 \end_layout
421 \begin_layout Subsubsection
422 --gamename=<name>
423 \end_layout
425 \begin_layout Standard
426 Set the name of game to <name>
427 \end_layout
429 \begin_layout Subsubsection
430 --author=<name>
431 \end_layout
433 \begin_layout Standard
434 Add author with full name of <name> (no nickname).
435 \end_layout
437 \begin_layout Subsubsection
438 --author=|<name>
439 \end_layout
441 \begin_layout Standard
442 Add author with nickname of <name> (no full name).
443 \end_layout
445 \begin_layout Subsubsection
446 --author=<fullname>|<nickname>
447 \end_layout
449 \begin_layout Standard
450 Add author with full name of <fullname> and nickname of <nickname>.
451 \end_layout
453 \begin_layout Subsubsection
454 --rtc-second=<value>
455 \end_layout
457 \begin_layout Standard
458 Set RTC second (0 is 1st January 1970 00:00:00Z).
459 \end_layout
461 \begin_layout Subsubsection
462 --rtc-subsecond=<value>
463 \end_layout
465 \begin_layout Standard
466 Set RTC subsecond.
467  Range is 0-3,462,619,485,019.
468 \end_layout
470 \begin_layout Subsection
471 <filename>
472 \end_layout
474 \begin_layout Standard
475 If filename is specified on command line, it is loaded as initial state
476  (instead of constructing one).
477  Mandatory for lsnes-avidump.exe and movieinfo.exe.
478 \end_layout
480 \begin_layout Subsection
481 Misc.
482  options
483 \end_layout
485 \begin_layout Subsubsection
486 --run=<file> (lsnes.exe only)
487 \end_layout
489 \begin_layout Standard
490 After running main RC file, run this file.
491  If multiple are specified, these execute in order specified.
492 \end_layout
494 \begin_layout Subsection
495 dump options (lsnes-avidump.exe only)
496 \end_layout
498 \begin_layout Subsubsection
499 --prefix=<prefix>
500 \end_layout
502 \begin_layout Standard
503 Set dump prefix.
504  Default is 
505 \begin_inset Quotes eld
506 \end_inset
508 avidump
509 \begin_inset Quotes erd
510 \end_inset
513 \end_layout
515 \begin_layout Subsubsection
516 --level=<level>
517 \end_layout
519 \begin_layout Standard
520 Set compression level (0-18).
521  Default is 7.
522 \end_layout
524 \begin_layout Subsubsection
525 --length=<length>
526 \end_layout
528 \begin_layout Standard
529 Set number of frames to dump.
530  Mandatory.
531 \end_layout
533 \begin_layout Subsubsection
534 --lua=<script>
535 \end_layout
537 \begin_layout Standard
538 Run specified lua script (lsnes-avidump.exe does not have initialization
539  files).
540 \end_layout
542 \begin_layout Section
543 Startup file lsnes.rc
544 \end_layout
546 \begin_layout Standard
547 Upon startup, lsnes (lsnes.exe only) executes file lsnes.rc as commands.
548  This file is located in:
549 \end_layout
551 \begin_layout Itemize
552 Windows: %APPDATA%
553 \backslash
554 lsnes
555 \backslash
556 lsnes.rc (if %APPDATA% exists)
557 \end_layout
559 \begin_layout Itemize
560 Unix: $XDG_CONFIG_HOME/lsnes/lsnes.rc (if $XDG_CONFIG_HOME exists)
561 \end_layout
563 \begin_layout Itemize
564 Unix: $HOME/.config/lsnes/lsnes.rc (if $HOME exists)
565 \end_layout
567 \begin_layout Itemize
568 All: ./lsnes.rc (fallback default).
569 \end_layout
571 \begin_layout Standard
572 If leading directories do not exist, attempt to create them is made.
573 \end_layout
575 \begin_layout Section
576 Game internal commands
577 \end_layout
579 \begin_layout Itemize
580 Commands beginning with '*' invoke the corresponding command without alias
581  expansion.
582 \end_layout
584 \begin_layout Itemize
585 If command starts with '+', the command is executed as-is when button is
586  pressed, and when button is released, it is executed with '+' replaced
587  by '-'.
588 \end_layout
590 \begin_layout Subsection
591 Settings:
592 \end_layout
594 \begin_layout Standard
595 Settings control various aspects of emulator behaviour.
596 \end_layout
598 \begin_layout Subsubsection
599 set-setting <setting> <value>
600 \end_layout
602 \begin_layout Standard
603 Sets setting <setting> to value <value> (may be empty).
604 \end_layout
606 \begin_layout Subsubsection
607 unset-setting <setting>
608 \end_layout
610 \begin_layout Standard
611 Try to unset setting <setting> (not all settings can be unset).
612 \end_layout
614 \begin_layout Subsubsection
615 get-setting <setting>
616 \end_layout
618 \begin_layout Standard
619 Read value of setting <setting>
620 \end_layout
622 \begin_layout Subsubsection
623 print-settings
624 \end_layout
626 \begin_layout Standard
627 Print names and values of all settings.
628 \end_layout
630 \begin_layout Subsection
631 Keybindings
632 \end_layout
634 \begin_layout Standard
635 Keybindings bind commands or aliases to keys (or pseudo-keys).
637 \end_layout
639 \begin_layout Standard
640 Notes:
641 \end_layout
643 \begin_layout Itemize
644 Do not bind edge active (+/-) commands to keys with modifiers, that won't
645  work right!
646 \end_layout
648 \begin_layout Itemize
649 Names of keys and modifiers are platform-dependent.
650 \end_layout
652 \begin_layout Itemize
653 Be careful before binding pseudo-keys (such as joystick axes, buttons or
654  hats) with modifiers.
655  That may or may not work right.
656 \end_layout
658 \begin_layout Subsubsection
659 bind-key [<mod>/<modmask>] <key> <command>
660 \end_layout
662 \begin_layout Standard
663 Bind <command> to key <key> (activating if modifiers in <modmask> (comma-seperat
664 ed list) are set as <mod> (comma-seperated list).
665 \end_layout
667 \begin_layout Standard
668 The names of keys and modifiers are platform-dependent.
669 \end_layout
671 \begin_layout Subsubsection
672 unbind-key [<mod>/<modmask>] <key>
673 \end_layout
675 \begin_layout Standard
676 Unbind command from <key> (with specified <mod> and <modmask>).
677 \end_layout
679 \begin_layout Subsubsection
680 print-keybindings
681 \end_layout
683 \begin_layout Standard
684 Print all key bindings in effect.
685 \end_layout
687 \begin_layout Subsection
688 Aliases
689 \end_layout
691 \begin_layout Standard
692 Aliases bind command to sequence of commands.
693  After alias has been defined, it replaces the command it shadows.
694 \end_layout
696 \begin_layout Standard
697 Notes:
698 \end_layout
700 \begin_layout Itemize
701 You can't alias command to itself.
702 \end_layout
704 \begin_layout Itemize
705 Aliases starting with +/- are edge active just like ordinary commands starting
706  with +/-.
707 \end_layout
709 \begin_layout Itemize
710 One command can be aliased to multiple commands.
711 \end_layout
713 \begin_layout Subsubsection
714 alias-command <command> <expansion>
715 \end_layout
717 \begin_layout Standard
718 Append <expansion> to alias <command>.
719  If alias does not already exist, it is created.
720 \end_layout
722 \begin_layout Subsubsection
723 unalias-command <command>
724 \end_layout
726 \begin_layout Standard
727 Clear alias expansion for <command>.
728 \end_layout
730 \begin_layout Subsubsection
731 print-aliases
732 \end_layout
734 \begin_layout Standard
735 Print all aliases and their expansions in effect.
736 \end_layout
738 \begin_layout Subsection
739 run-script <script>
740 \end_layout
742 \begin_layout Standard
743 Run <script> as if commands were entered on the command line.
744 \end_layout
746 \begin_layout Subsection
747 AVI Video dumping
748 \end_layout
750 \begin_layout Standard
751 Following commands control AVI video dumping:
752 \end_layout
754 \begin_layout Subsubsection
755 dump-avi <level> <prefix>
756 \end_layout
758 \begin_layout Standard
759 Dump AVI video to prefix <prefix> at level <level> (0-18).
760  Notes:
761 \end_layout
763 \begin_layout Itemize
764 The codec is Camstudio Codec in gzip mode.
765 \end_layout
767 \begin_layout Itemize
768 Encoder and muxer are internal, available on all platforms.
769 \end_layout
771 \begin_layout Itemize
772 Audio enable/disable and framerate has no effect.
773 \end_layout
775 \begin_layout Itemize
776 Levels 10-18 are not compatible with AVISource.
777 \end_layout
779 \begin_layout Itemize
780 Recomended level is 7 if decoded by AVISource.
781 \end_layout
783 \begin_layout Itemize
784 Recomended level is 16 if decoded by ffmpeg, mencoder or FFMpegSource.
785 \end_layout
787 \begin_layout Itemize
788 Dumps of low-res PAL games are 256x239 (with all the consequences odd height
789  carries).
790 \end_layout
792 \begin_layout Itemize
793 The audio dumped to .avi is low-quality version.
794  The high-quality version is dumped to .sox file.
795 \end_layout
797 \begin_layout Subsubsection
798 end-avi
799 \end_layout
801 \begin_layout Standard
802 End current AVI video dump (closing the emulator also closes the dump).
803 \end_layout
805 \begin_layout Subsection
806 Memory manipulation
807 \end_layout
809 \begin_layout Standard
810 <address> may be decimal or hexadecimal (prefixed with '0x').
811  <value> can be hexadecimal (prefixed with '0x'), unsigned or signed (prefixed
812  with '-') decimal.
813 \end_layout
815 \begin_layout Standard
816 The available element <sizes> are:
817 \end_layout
819 \begin_layout Itemize
820 byte: 1 byte
821 \end_layout
823 \begin_layout Itemize
824 word: 2 bytes
825 \end_layout
827 \begin_layout Itemize
828 dword: 4 bytes
829 \end_layout
831 \begin_layout Itemize
832 qword: 8 bytes
833 \end_layout
835 \begin_layout Standard
836 When reading RAM and ROM, multi-byte reads/writes are big-endian.
837  When dealing with DSP memory, multi-byte reads/writes are native-endian
838  (do not use operand sizes exceeding DSP bitness, except dword is OK for
839  24-bit memory).
840 \end_layout
842 \begin_layout Subsubsection
843 read-<size> <address>
844 \end_layout
846 \begin_layout Standard
847 Read the value of byte in <address>.
848 \end_layout
850 \begin_layout Subsubsection
851 read-s<size> <address>
852 \end_layout
854 \begin_layout Standard
855 Read the value of signed byte in <address>.
856 \end_layout
858 \begin_layout Subsubsection
859 write-<size> <address> <value>
860 \end_layout
862 \begin_layout Standard
863 Write <value> to byte in address <address>.
864 \end_layout
866 \begin_layout Subsubsection
867 search-memory reset
868 \end_layout
870 \begin_layout Standard
871 Reset the memory search
872 \end_layout
874 \begin_layout Subsubsection
875 search-memory count
876 \end_layout
878 \begin_layout Standard
879 Print number of candidates remaining
880 \end_layout
882 \begin_layout Subsubsection
883 search-memory print
884 \end_layout
886 \begin_layout Standard
887 Print all candidates remaining
888 \end_layout
890 \begin_layout Subsubsection
891 search-memory <usflag><sizeflag><op>
892 \end_layout
894 \begin_layout Standard
895 Searches memory for addresses satisfying criteria.
896 \end_layout
898 \begin_layout Standard
899 <usflag> can be:
900 \end_layout
902 \begin_layout Itemize
903 u: unsigned
904 \end_layout
906 \begin_layout Itemize
907 s: signed
908 \end_layout
910 \begin_layout Standard
911 <sizeflag> can be:
912 \end_layout
914 \begin_layout Itemize
915 b: byte
916 \end_layout
918 \begin_layout Itemize
919 w: word
920 \end_layout
922 \begin_layout Itemize
923 d: dword
924 \end_layout
926 \begin_layout Itemize
927 q: qword
928 \end_layout
930 \begin_layout Standard
931 <op> can be:
932 \end_layout
934 \begin_layout Itemize
935 lt: < previous value.
936 \end_layout
938 \begin_layout Itemize
939 le: <= previous value.
940 \end_layout
942 \begin_layout Itemize
943 eq: = previous value.
944 \end_layout
946 \begin_layout Itemize
947 ne: != previous value.
948 \end_layout
950 \begin_layout Itemize
951 ge: >= previous value.
952 \end_layout
954 \begin_layout Itemize
955 gt: > previous value.
956 \end_layout
958 \begin_layout Subsubsection
959 search-memory <sizeflag> <value>
960 \end_layout
962 \begin_layout Standard
963 Searches for addresses that currently have value <value>.
964  <sizeflag> is as in previous command.
965 \end_layout
967 \begin_layout Subsection
968 Main commands
969 \end_layout
971 \begin_layout Standard
972 These commands are not available in lsnesrc, but are available after ROM
973  has been loaded.
974 \end_layout
976 \begin_layout Subsubsection
977 quit-emulator [/y]
978 \end_layout
980 \begin_layout Standard
981 Quits the emulator (asking for confirmation).
982  If /y is given, no confirmation is asked.
983 \end_layout
985 \begin_layout Subsubsection
986 pause-emulator
987 \end_layout
989 \begin_layout Standard
990 Toggle paused/unpaused
991 \end_layout
993 \begin_layout Subsubsection
994 +advance-frame
995 \end_layout
997 \begin_layout Standard
998 Advance frame.
999  If the button is still held after configurable timeout expires, game unpauses
1000  for the duration frame advance is held.
1001 \end_layout
1003 \begin_layout Subsubsection
1004 +advance-poll
1005 \end_layout
1007 \begin_layout Standard
1008 Advance subframe.
1009  If the button is still held after configurable timeout expires, game unpauses
1010  for the duration frame advance is held.
1011 \end_layout
1013 \begin_layout Subsubsection
1014 advance-skiplag
1015 \end_layout
1017 \begin_layout Standard
1018 Skip to first poll in frame after current.
1019 \end_layout
1021 \begin_layout Subsubsection
1022 reset
1023 \end_layout
1025 \begin_layout Standard
1026 Reset the SNES after this frame.
1027 \end_layout
1029 \begin_layout Subsubsection
1030 load-state <filename>
1031 \end_layout
1033 \begin_layout Standard
1034 Load savestate <filename> in readwrite mode.
1035 \end_layout
1037 \begin_layout Subsubsection
1038 load-readonly <filename>
1039 \end_layout
1041 \begin_layout Standard
1042 Load savestate <filename> in readonly mode.
1043 \end_layout
1045 \begin_layout Subsubsection
1046 load-preserve <filename>
1047 \end_layout
1049 \begin_layout Standard
1050 Load savestate <filename> in readonly mode, preserving current events.
1051 \end_layout
1053 \begin_layout Subsubsection
1054 load-movie <filename>
1055 \end_layout
1057 \begin_layout Standard
1058 Load savestate <filename>, ignoring save part in readonly mode.
1059 \end_layout
1061 \begin_layout Subsubsection
1062 save-state <filename>
1063 \end_layout
1065 \begin_layout Standard
1066 Save system state to <filename> as soon as possible.
1067 \end_layout
1069 \begin_layout Subsubsection
1070 save-movie <filename>
1071 \end_layout
1073 \begin_layout Standard
1074 Save movie to <filename>.
1075 \end_layout
1077 \begin_layout Subsubsection
1078 set-rwmode
1079 \end_layout
1081 \begin_layout Standard
1082 Set read-write mode.
1083 \end_layout
1085 \begin_layout Subsubsection
1086 set-gamename <name>
1087 \end_layout
1089 \begin_layout Standard
1090 Set name of the game to <name>
1091 \end_layout
1093 \begin_layout Subsubsection
1094 get-gamename
1095 \end_layout
1097 \begin_layout Standard
1098 Print the name of the game.
1099 \end_layout
1101 \begin_layout Subsubsection
1102 add-author <author>
1103 \end_layout
1105 \begin_layout Standard
1106 Adds new author <author>.
1107  If <author> does not contain '|' it is full name.
1108  If it contains '|', '|' splits the full name and nickname.
1109 \end_layout
1111 \begin_layout Subsubsection
1112 edit-author <num> <author>
1113 \end_layout
1115 \begin_layout Standard
1116 Edit the author in slot <num> (0-based) to be <author> (see add-author for
1117  format)
1118 \end_layout
1120 \begin_layout Subsubsection
1121 remove-author <num>
1122 \end_layout
1124 \begin_layout Standard
1125 Remove author in slot <num>
1126 \end_layout
1128 \begin_layout Subsubsection
1129 print-authors
1130 \end_layout
1132 \begin_layout Standard
1133 Print authors.
1134 \end_layout
1136 \begin_layout Subsubsection
1137 test-1, test-2, test-3
1138 \end_layout
1140 \begin_layout Standard
1141 Internal test commands.
1142  Don't use.
1143 \end_layout
1145 \begin_layout Subsubsection
1146 take-screenshot <filename>
1147 \end_layout
1149 \begin_layout Standard
1150 Save screenshot to <filename>.
1151 \end_layout
1153 \begin_layout Subsubsection
1154 +controller<num><button>
1155 \end_layout
1157 \begin_layout Standard
1158 Press button <button> on controller <num> (1-8).
1159  The following button names are known:
1160 \end_layout
1162 \begin_layout Itemize
1163 left
1164 \end_layout
1166 \begin_layout Itemize
1167 right
1168 \end_layout
1170 \begin_layout Itemize
1172 \end_layout
1174 \begin_layout Itemize
1175 down
1176 \end_layout
1178 \begin_layout Itemize
1180 \end_layout
1182 \begin_layout Itemize
1184 \end_layout
1186 \begin_layout Itemize
1188 \end_layout
1190 \begin_layout Itemize
1192 \end_layout
1194 \begin_layout Itemize
1196 \end_layout
1198 \begin_layout Itemize
1200 \end_layout
1202 \begin_layout Itemize
1203 select
1204 \end_layout
1206 \begin_layout Itemize
1207 start
1208 \end_layout
1210 \begin_layout Itemize
1211 trigger
1212 \end_layout
1214 \begin_layout Itemize
1215 cursor
1216 \end_layout
1218 \begin_layout Itemize
1219 pause
1220 \end_layout
1222 \begin_layout Itemize
1223 turbo
1224 \end_layout
1226 \begin_layout Subsubsection
1227 controllerh<num><button>
1228 \end_layout
1230 \begin_layout Standard
1231 Hold/unhold button <button> on controller <num> (1-8).
1232  See +controller for button names.
1233 \end_layout
1235 \begin_layout Subsubsection
1236 autofire (<pattern>|-)...
1237 \end_layout
1239 \begin_layout Standard
1240 Set autofire pattern.
1241  Each parameter is comma-separated list of button names (in form of 1start,
1242  1A, 2B, etc..) to hold on that frame.
1243  After reaching the end of pattern, the pattern restarts from the beginning.
1244 \end_layout
1246 \begin_layout Subsubsection
1247 repaint
1248 \end_layout
1250 \begin_layout Standard
1251 Force a repaint.
1252 \end_layout
1254 \begin_layout Subsection
1255 Save jukebox
1256 \end_layout
1258 \begin_layout Subsubsection
1259 cycle-jukebox-backward
1260 \end_layout
1262 \begin_layout Standard
1263 Cycle save jukebox backwards.
1264 \end_layout
1266 \begin_layout Subsubsection
1267 cycle-jukebox-forward
1268 \end_layout
1270 \begin_layout Standard
1271 Cycle save jukebox forwards
1272 \end_layout
1274 \begin_layout Subsubsection
1275 add-jukebox-save <filename>
1276 \end_layout
1278 \begin_layout Standard
1279 Add <filename> to jukebox saves.
1280 \end_layout
1282 \begin_layout Subsubsection
1283 load-jukebox
1284 \end_layout
1286 \begin_layout Standard
1287 Do R/W load from jukebox.
1288 \end_layout
1290 \begin_layout Subsubsection
1291 save-jukebox
1292 \end_layout
1294 \begin_layout Standard
1295 Do state save to jukebox.
1296 \end_layout
1298 \begin_layout Subsection
1300 \end_layout
1302 \begin_layout Standard
1303 Only available if lua support is compiled in.
1304 \end_layout
1306 \begin_layout Subsubsection
1307 eval-lua <luacode>
1308 \end_layout
1310 \begin_layout Standard
1311 Run Lua code <luacode> using built-in Lua interpretter.
1312 \end_layout
1314 \begin_layout Subsubsection
1315 run-lua <script>
1316 \end_layout
1318 \begin_layout Standard
1319 Run specified lua file using built-in Lua interpretter.
1320 \end_layout
1322 \begin_layout Subsection
1323 Memory watch
1324 \end_layout
1326 \begin_layout Subsubsection
1327 add-watch <name> <expression>
1328 \end_layout
1330 \begin_layout Standard
1331 Adds new watch (or modifies old one).
1332 \end_layout
1334 \begin_layout Subsubsection
1335 remove-watch <name>
1336 \end_layout
1338 \begin_layout Standard
1339 Remove a watch.
1340 \end_layout
1342 \begin_layout Subsection
1343 SDL Platform commands
1344 \end_layout
1346 \begin_layout Standard
1347 The following are valid on SDL platform.
1348 \end_layout
1350 \begin_layout Subsubsection
1351 enable-sound on
1352 \end_layout
1354 \begin_layout Standard
1355 Enable sounds in GUI (has no effect on video dumping).
1356 \end_layout
1358 \begin_layout Subsubsection
1359 enable-sound off
1360 \end_layout
1362 \begin_layout Standard
1363 Disable sounds in GUI (has no effect on video dumping).
1364 \end_layout
1366 \begin_layout Subsubsection
1367 identify-key
1368 \end_layout
1370 \begin_layout Standard
1371 Asks to press a key and then identifies that (pseudo-)key.
1372 \end_layout
1374 \begin_layout Subsubsection
1375 toggle-console
1376 \end_layout
1378 \begin_layout Standard
1379 Toggle between windowed/fullscreen console.
1380 \end_layout
1382 \begin_layout Subsubsection
1383 scroll-fullup
1384 \end_layout
1386 \begin_layout Standard
1387 Scroll messages window as far back as it goes.
1388 \end_layout
1390 \begin_layout Subsubsection
1391 scroll-fulldown
1392 \end_layout
1394 \begin_layout Standard
1395 Scroll messages window as far forward as it goes.
1396 \end_layout
1398 \begin_layout Subsubsection
1399 scroll-up
1400 \end_layout
1402 \begin_layout Standard
1403 Scroll messages window back one screenful.
1404 \end_layout
1406 \begin_layout Subsubsection
1407 scroll-down
1408 \end_layout
1410 \begin_layout Standard
1411 Scroll messages window forward one screenful.
1412 \end_layout
1414 \begin_layout Subsubsection
1415 axismode <axis> <mode>
1416 \end_layout
1418 \begin_layout Standard
1419 Set joystick axis mode.
1420  <axis> is of form 
1421 \begin_inset Quotes eld
1422 \end_inset
1424 joystick<num>axis<axis>
1425 \begin_inset Quotes erd
1426 \end_inset
1428 , e.g.
1430 \begin_inset Quotes eld
1431 \end_inset
1433 joystick0axis5
1434 \begin_inset Quotes erd
1435 \end_inset
1438  Mode is one of:
1439 \end_layout
1441 \begin_layout Itemize
1442 axis: Normal axis mode
1443 \end_layout
1445 \begin_layout Itemize
1446 axis_inverse: Inverse axis mode.
1447 \end_layout
1449 \begin_layout Itemize
1450 pressure_0m: Pressure sensitive.
1451  Released at 0, pressed at full negative.
1452 \end_layout
1454 \begin_layout Itemize
1455 pressure_0p: Pressure sensitive.
1456  Released at 0, pressed at full positive.
1457 \end_layout
1459 \begin_layout Itemize
1460 pressure_m0: Pressure sensitive.
1461  Released at full negative, pressed at 0.
1462 \end_layout
1464 \begin_layout Itemize
1465 pressure_mp: Pressure sensitive.
1466  Released at full negative, pressed at full positive.
1467  E.g.
1468  XBox360 Pad axes 2 and 5.
1469 \end_layout
1471 \begin_layout Itemize
1472 pressure_p0: Pressure sensitive.
1473  Released at full positive, pressed at 0.
1474 \end_layout
1476 \begin_layout Itemize
1477 pressure_pm: Pressure sensitive.
1478  Released at full positive, pressed at full negative.
1479 \end_layout
1481 \begin_layout Itemize
1482 disabled: Disable the axis.
1483  On PS3 controller, axes 8-19 should be disabled since those controls are
1484  digital buttons as well.
1485 \end_layout
1487 \begin_layout Section
1488 Settings
1489 \end_layout
1491 \begin_layout Subsection
1492 Core settings
1493 \end_layout
1495 \begin_layout Subsubsection
1496 firmwarepath
1497 \end_layout
1499 \begin_layout Standard
1500 Set where bsnes looks for firmware files.
1501  Default is 
1502 \begin_inset Quotes eld
1503 \end_inset
1506 \begin_inset Quotes erd
1507 \end_inset
1510 \end_layout
1512 \begin_layout Subsubsection
1513 targetfps
1514 \end_layout
1516 \begin_layout Standard
1517 Set the target fps.
1518  Numeric, range is 0.001 to 
1519 \begin_inset Quotes eld
1520 \end_inset
1522 infinite
1523 \begin_inset Quotes erd
1524 \end_inset
1527  Default is native framerate.
1528 \end_layout
1530 \begin_layout Subsubsection
1531 savecompression
1532 \end_layout
1534 \begin_layout Standard
1535 Set save compression level (integer 0-9).
1536  Default is 7 (0 is no compression).
1537 \end_layout
1539 \begin_layout Subsubsection
1540 advance-timeout
1541 \end_layout
1543 \begin_layout Standard
1544 Set the frame advance timeout in milliseconds.
1545  Numeric integer, range is 0-999999999.
1546  Default is 500.
1547 \end_layout
1549 \begin_layout Subsection
1550 AVI dumper settings
1551 \end_layout
1553 \begin_layout Subsubsection
1554 avi-large
1555 \end_layout
1557 \begin_layout Standard
1558 AVI dumper: Always dump at 512x448 or 512x478 regardless of what the console
1559  outputs.
1560 \end_layout
1562 \begin_layout Subsubsection
1563 avi-left-border
1564 \end_layout
1566 \begin_layout Standard
1567 AVI dumper: Set the default left border thickness (unless lua overrides)
1568  for dumps.
1569  Range 0-8191.
1570  Default is 0.
1571 \end_layout
1573 \begin_layout Subsubsection
1574 avi-right-border
1575 \end_layout
1577 \begin_layout Standard
1578 AVI dumper: Set the default right border thickness (unless lua overrides)
1579  for dumps.
1580  Range 0-8191.
1581  Default is 0.
1582 \end_layout
1584 \begin_layout Subsubsection
1585 avi-top-border
1586 \end_layout
1588 \begin_layout Standard
1589 AVI dumper: Set the default top border thickness (unless lua overrides)
1590  for dumps.
1591  Range 0-8191.
1592  Default is 0.
1593 \end_layout
1595 \begin_layout Subsubsection
1596 avi-bottom-border
1597 \end_layout
1599 \begin_layout Standard
1600 AVI dumper: Set the default bottom border thickness (unless lua overrides)
1601  for dumps.
1602  Range 0-8191.
1603  Default is 0.
1604 \end_layout
1606 \begin_layout Subsubsection
1607 avi-maxframes
1608 \end_layout
1610 \begin_layout Standard
1611 AVI dumper: Maximum number of frames per dump segment (0 => unlimited).
1612  Range 0-999999999.
1613  Default is 0.
1614 \end_layout
1616 \begin_layout Subsection
1617 SDL platform settings
1618 \end_layout
1620 \begin_layout Subsubsection
1621 autorepeat-first-delay
1622 \end_layout
1624 \begin_layout Standard
1625 Sets the delay for first character in typematic autorepeat.
1626 \end_layout
1628 \begin_layout Subsubsection
1629 autorepeat-subsequent-delay
1630 \end_layout
1632 \begin_layout Standard
1633 Sets the delay for subsequent characters in typematic autorepeat.
1634 \end_layout
1636 \begin_layout Section
1637 Lua functions
1638 \end_layout
1640 \begin_layout Subsection
1641 Core (in main table)
1642 \end_layout
1644 \begin_layout Subsubsection
1645 print
1646 \end_layout
1648 \begin_layout Standard
1649 Print line to message console.
1650 \end_layout
1652 \begin_layout Subsubsection
1653 exec(string command)
1654 \end_layout
1656 \begin_layout Standard
1657 Run command as it was entered on the command line
1658 \end_layout
1660 \begin_layout Subsection
1661 Table bit:
1662 \end_layout
1664 \begin_layout Standard
1665 Bitwise logical functions and related.
1666 \end_layout
1668 \begin_layout Subsubsection
1669 none(number...) / bnot(number...)
1670 \end_layout
1672 \begin_layout Standard
1673 48-bit bitwise NOT / NONE function (set bits that are set in none of the
1674  arguments).
1675 \end_layout
1677 \begin_layout Subsubsection
1678 any(number...) / bor(number...)
1679 \end_layout
1681 \begin_layout Standard
1682 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
1683 \end_layout
1685 \begin_layout Subsubsection
1686 all(number...) / band(number...)
1687 \end_layout
1689 \begin_layout Standard
1690 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
1692 \end_layout
1694 \begin_layout Subsubsection
1695 parity(number...) / bxor(number...)
1696 \end_layout
1698 \begin_layout Standard
1699 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
1700  of the arguments).
1701 \end_layout
1703 \begin_layout Subsubsection
1704 lrotate(number base[, number amount[, number bits]])
1705 \end_layout
1707 \begin_layout Standard
1708 Rotate bits-bit (max 48, default 48) number left by amount (default 1) places.
1709 \end_layout
1711 \begin_layout Subsubsection
1712 rrotate(number base[, number amount[, number bits]])
1713 \end_layout
1715 \begin_layout Standard
1716 Rotate bits-bit (max 48, default 48) number right by amount (default 1)
1717  places.
1718 \end_layout
1720 \begin_layout Subsubsection
1721 lshift(number base[, number amount[, number bits]])
1722 \end_layout
1724 \begin_layout Standard
1725 Shift bits-bit (max 48, default 48) number left by amount (default 1) places.
1726  The new bits are filled with zeroes.
1727 \end_layout
1729 \begin_layout Subsubsection
1730 lrshift(number base[, number amount[, number bits]])
1731 \end_layout
1733 \begin_layout Standard
1734 Shift bits-bit (max 48, default 48) number logically right by amount (default
1735  1) places.
1736  The new bits are filled with zeroes.
1737 \end_layout
1739 \begin_layout Subsubsection
1740 arshift(number base[, number amount[, number bits]])
1741 \end_layout
1743 \begin_layout Standard
1744 Shift bits-bit (max 48, default 48) number arithmetically right by amount
1745  (default 1) places.
1746  The new bits are shifted in with copy of the high bit.
1747 \end_layout
1749 \begin_layout Subsection
1750 Table gui:
1751 \end_layout
1753 \begin_layout Standard
1754 Most of these functions can only be called in on_paint and on_video callbacks.
1755  Exceptions are noted.
1756 \end_layout
1758 \begin_layout Subsubsection
1759 gui.resolution()
1760 \end_layout
1762 \begin_layout Standard
1763 Returns 2-tuple (hresolution, vresolution).
1764 \end_layout
1766 \begin_layout Subsubsection
1767 gui.<class>_gap(number gap)
1768 \end_layout
1770 \begin_layout Standard
1771 Set the <class> (left, right, top, bottom) gap to specified value (max gap
1772  is 8191).
1773 \end_layout
1775 \begin_layout Subsubsection
1776 gui.text(number x, number y, string text[, number fgc[, number fga[, number
1777  bgc[, number bga]]]])
1778 \end_layout
1780 \begin_layout Standard
1781 Draw text on the GUI.
1782  Font size is 8 (or 16) by 16.
1783  Notes:
1784 \end_layout
1786 \begin_layout Itemize
1787 Coordinate origin is at top-left of the game area.
1788  Left and top gaps have negative coordinates.
1789 \end_layout
1791 \begin_layout Itemize
1792 Use gui.resolution() to discover how to layout colors.
1793 \end_layout
1795 \begin_layout Itemize
1796 Alpha range is 0(transparent)-32(opaque).
1797 \end_layout
1799 \begin_layout Itemize
1800 Only available in on_paint() and on_video() callbacks.
1801 \end_layout
1803 \begin_layout Itemize
1804 Colors are 15 bits (1024 * r + 32 * g + b).
1805 \end_layout
1807 \begin_layout Subsubsection
1808 gui.rectangle(number x, number y, number width, number height[, number thickness[
1809 , number outline[, number outlinealpha[, number fill[, number fillalpha]]]]])
1810 \end_layout
1812 \begin_layout Standard
1813 Draw rectangle on the GUI.
1814  All notes of gui.text apply.
1815 \end_layout
1817 \begin_layout Subsubsection
1818 gui.pixel(number x, number y[, number color[, number alpha]])
1819 \end_layout
1821 \begin_layout Standard
1822 Draw one pixel on the GUI.
1823  All notes of gui.text apply.
1824 \end_layout
1826 \begin_layout Subsubsection
1827 gui.repaint()
1828 \end_layout
1830 \begin_layout Standard
1831 Request on_repaint() to happen as soon as possible.
1832  Can be used anywhere.
1833 \end_layout
1835 \begin_layout Subsubsection
1836 gui.subframe_update(boolean on)
1837 \end_layout
1839 \begin_layout Standard
1840 Request subframe updates (calling on_paint() on subframes) to happen (on=true)
1841  or not happen (on=false).
1842  Can be used anywhere.
1843 \end_layout
1845 \begin_layout Subsection
1846 table input
1847 \end_layout
1849 \begin_layout Standard
1850 Input handling.
1851  Only available in on_input callback.
1852 \end_layout
1854 \begin_layout Subsection
1855 get(number controller, number index)
1856 \end_layout
1858 \begin_layout Standard
1859 Read the specified index (0-11) from specified controller (0-7).
1860  Notes:
1861 \end_layout
1863 \begin_layout Itemize
1864 Uses physical controller numbering.
1865  Gamepad in port 2 is controller 4, not 1!
1866 \end_layout
1868 \begin_layout Subsection
1869 set(number controller, number index, number value)
1870 \end_layout
1872 \begin_layout Standard
1873 Write the specified index (0-11) from specified controller (0-7), storing
1874  value.
1875  Notes:
1876 \end_layout
1878 \begin_layout Itemize
1879 Uses physical controller numbering.
1880  Gamepad in port 2 is controller 4, not 1!
1881 \end_layout
1883 \begin_layout Subsection
1884 reset([number cycles])
1885 \end_layout
1887 \begin_layout Standard
1888 Execute reset.
1889  If cycles is greater than zero, do delayed reset.
1890  0 (or no value) causes immediate reset.
1891 \end_layout
1893 \begin_layout Itemize
1894 Only available with subframe flag false.
1895 \end_layout
1897 \begin_layout Subsection
1898 Table hostmemory
1899 \end_layout
1901 \begin_layout Standard
1902 Host memory handling (extra memory saved to savestates).
1903  Host memory starts empty.
1904 \end_layout
1906 \begin_layout Subsubsection
1907 read(number address)
1908 \end_layout
1910 \begin_layout Standard
1911 Reads hostmemory slot address.
1912  Slot numbers out of range return false instead of numeric.
1913 \end_layout
1915 \begin_layout Subsubsection
1916 write(number address, number value)
1917 \end_layout
1919 \begin_layout Standard
1920 Writes hostmemory slot with 0-255.
1921  Slot numbers out of range cause extension of host memory slot space.
1922 \end_layout
1924 \begin_layout Subsubsection
1925 readbyte(number address)
1926 \end_layout
1928 \begin_layout Standard
1929 Read unsigned byte (1 element) from given address.
1930  Slots out of range return false.
1931 \end_layout
1933 \begin_layout Subsubsection
1934 writebyte(number address, number value)
1935 \end_layout
1937 \begin_layout Standard
1938 Write unsigned byte (1 element) to given slot.
1939  Slot numbers out of range cause extension.
1940 \end_layout
1942 \begin_layout Subsubsection
1943 readsbyte(number address)
1944 \end_layout
1946 \begin_layout Standard
1947 Read signed byte (1 element) from given address.
1948  Slots out of range return false.
1949 \end_layout
1951 \begin_layout Subsubsection
1952 writesbyte(number address, number value)
1953 \end_layout
1955 \begin_layout Standard
1956 Write signed byte (1 element) to given slot.
1957  Slot numbers out of range cause extension.
1958 \end_layout
1960 \begin_layout Subsubsection
1961 readword(number address)
1962 \end_layout
1964 \begin_layout Standard
1965 Read unsigned word (2 elements) from given address.
1966  Slots out of range return false.
1967 \end_layout
1969 \begin_layout Subsubsection
1970 writeword(number address, number value)
1971 \end_layout
1973 \begin_layout Standard
1974 Write unsigned word (2 elements) to given slot.
1975  Slot numbers out of range cause extension.
1976 \end_layout
1978 \begin_layout Subsubsection
1979 readsword(number address)
1980 \end_layout
1982 \begin_layout Standard
1983 Read signed word (2 elements) from given address.
1984  Slots out of range return false.
1985 \end_layout
1987 \begin_layout Subsubsection
1988 writesword(number address, number value)
1989 \end_layout
1991 \begin_layout Standard
1992 Write signed word (2 elements) to given slot.
1993  Slot numbers out of range cause extension.
1994 \end_layout
1996 \begin_layout Subsubsection
1997 readdword(number address)
1998 \end_layout
2000 \begin_layout Standard
2001 Read unsigned doubleword (4 elements) from given address.
2002  Slots out of range return false.
2003 \end_layout
2005 \begin_layout Subsubsection
2006 writedword(number address, number value)
2007 \end_layout
2009 \begin_layout Standard
2010 Write unsigned doubleword (4 elements) to given slot.
2011  Slot numbers out of range cause extension.
2012 \end_layout
2014 \begin_layout Subsubsection
2015 readsdword(number address)
2016 \end_layout
2018 \begin_layout Standard
2019 Read signed doubleword (4 elements) from given address.
2020  Slots out of range return false.
2021 \end_layout
2023 \begin_layout Subsubsection
2024 writesdword(number address, number value)
2025 \end_layout
2027 \begin_layout Standard
2028 Write signed doubleword (4 elements) to given slot.
2029  Slot numbers out of range cause extension.
2030 \end_layout
2032 \begin_layout Subsubsection
2033 readqword(number address)
2034 \end_layout
2036 \begin_layout Standard
2037 Read unsigned quadword (8 elements) from given address.
2038  Slots out of range return false.
2039 \end_layout
2041 \begin_layout Subsubsection
2042 writeqword(number address, number value)
2043 \end_layout
2045 \begin_layout Standard
2046 Write unsigned quadword (4 elements) to given slot.
2047  Slot numbers out of range cause extension.
2048 \end_layout
2050 \begin_layout Subsubsection
2051 readsqword(number address)
2052 \end_layout
2054 \begin_layout Standard
2055 Read signed quadword (8 elements) from given address.
2056  Slots out of range return false.
2057 \end_layout
2059 \begin_layout Subsubsection
2060 writesqword(number address, number value)
2061 \end_layout
2063 \begin_layout Standard
2064 Write signed quadword (8 elements) to given slot.
2065  Slot numbers out of range cause extension.
2066 \end_layout
2068 \begin_layout Subsection
2069 Table movie
2070 \end_layout
2072 \begin_layout Standard
2073 Movie handling
2074 \end_layout
2076 \begin_layout Subsubsection
2077 movie.currentframe()
2078 \end_layout
2080 \begin_layout Standard
2081 Return number of current frame.
2082 \end_layout
2084 \begin_layout Subsubsection
2085 movie.framecount()
2086 \end_layout
2088 \begin_layout Standard
2089 Return number of frames in movie.
2090 \end_layout
2092 \begin_layout Subsubsection
2093 movie.readonly()
2094 \end_layout
2096 \begin_layout Standard
2097 Return true if in readonly mode, false if in readwrite.
2098 \end_layout
2100 \begin_layout Subsubsection
2101 movie.set_readwrite()
2102 \end_layout
2104 \begin_layout Standard
2105 Set readwrite mode (does not cause on_readwrite callback).
2106 \end_layout
2108 \begin_layout Subsubsection
2109 movie.frame_subframes(number frame)
2110 \end_layout
2112 \begin_layout Standard
2113 Count number of subframes in specified frame (frame numbers are 1-based)
2114  and return that.
2115 \end_layout
2117 \begin_layout Subsubsection
2118 movie.read_subframe(number frame, number subframe)
2119 \end_layout
2121 \begin_layout Standard
2122 Read specifed subframe in specified frame and return data as array (100
2123  elements, numbered 0-99 currently).
2124 \end_layout
2126 \begin_layout Subsection
2127 Table settings
2128 \end_layout
2130 \begin_layout Standard
2131 Routines for settings manipulation
2132 \end_layout
2134 \begin_layout Subsubsection
2135 get(string name)
2136 \end_layout
2138 \begin_layout Standard
2139 Get value of setting.
2140  If setting is blank, returns false.
2141  If setting value can't be obtained, returns (nil, error message).
2142 \end_layout
2144 \begin_layout Subsubsection
2145 set(string name, string value)
2146 \end_layout
2148 \begin_layout Standard
2149 Set value of setting.
2150  If setting can't be set, returns (nil, error message).
2151 \end_layout
2153 \begin_layout Subsubsection
2154 is_set(string name)
2155 \end_layout
2157 \begin_layout Standard
2158 Returns if setting is set.
2159  If setting does not exist, returns (nil, error message).
2160 \end_layout
2162 \begin_layout Subsubsection
2163 blank(string name)
2164 \end_layout
2166 \begin_layout Standard
2167 Blanks a setting and returns true.
2168  If setting can't be blanked, returns (nil, error message).
2169 \end_layout
2171 \begin_layout Subsection
2172 Callbacks
2173 \end_layout
2175 \begin_layout Standard
2176 Various callbacks to Lua that can occur.
2177 \end_layout
2179 \begin_layout Subsubsection
2180 Callback: on_paint()
2181 \end_layout
2183 \begin_layout Standard
2184 Called when screen is being painted.
2185  Any gui.* calls requiring graphic context draw on the screen.
2186 \end_layout
2188 \begin_layout Subsubsection
2189 Callback: on_video()
2190 \end_layout
2192 \begin_layout Standard
2193 Called when video dump frame is being painted.
2194  Any gui.* calls requiring graphic context draw on the video.
2195 \end_layout
2197 \begin_layout Subsubsection
2198 Callback: on_startup()
2199 \end_layout
2201 \begin_layout Standard
2202 Called when the emulator is starting (lsnes.rc and --run files has been run).
2203 \end_layout
2205 \begin_layout Subsubsection
2206 Callback: on_pre_load(string name)
2207 \end_layout
2209 \begin_layout Standard
2210 Called just before savestate/movie load occurs (note: loads are always delayed,
2211  so this occurs even when load was initiated by lua).
2212 \end_layout
2214 \begin_layout Subsubsection
2215 Callback: on_err_load(string name)
2216 \end_layout
2218 \begin_layout Standard
2219 Called if loadstate goes wrong.
2220 \end_layout
2222 \begin_layout Subsubsection
2223 Callback: on_post_load(string name, boolean was_savestate)
2224 \end_layout
2226 \begin_layout Standard
2227 Called on successful loadstate.
2228  was_savestate gives if this was a savestate or a movie.
2229 \end_layout
2231 \begin_layout Subsubsection
2232 Callback: on_pre_save(string name, boolean is_savestate)
2233 \end_layout
2235 \begin_layout Standard
2236 Called just before savestate save occurs (note: movie saves are synchronous
2237  and won't trigger these callbacks if called from Lua).
2238 \end_layout
2240 \begin_layout Subsubsection
2241 Callback: on_err_save(string name)
2242 \end_layout
2244 \begin_layout Standard
2245 Called if savestate goes wrong.
2246 \end_layout
2248 \begin_layout Subsubsection
2249 Callback: on_post_save(string name, boolean is_savestate)
2250 \end_layout
2252 \begin_layout Standard
2253 Called on successful savaestate.
2254  is_savestate gives if this was a savestate or a movie.
2255 \end_layout
2257 \begin_layout Subsubsection
2258 Callback: on_quit()
2259 \end_layout
2261 \begin_layout Standard
2262 Called when emulator is shutting down.
2263 \end_layout
2265 \begin_layout Subsubsection
2266 Callback: on_input(boolean subframe)
2267 \end_layout
2269 \begin_layout Standard
2270 Called when emulator is just sending input to bsnes core.
2271  Warning: This is called even in readonly mode, but the results are ignored.
2272 \end_layout
2274 \begin_layout Subsubsection
2275 Callback: on_reset()
2276 \end_layout
2278 \begin_layout Standard
2279 Called when SNES is reset.
2280 \end_layout
2282 \begin_layout Subsubsection
2283 Callback: on_readwrite()
2284 \end_layout
2286 \begin_layout Standard
2287 Called when moving into readwrite mode as result of 
2288 \begin_inset Quotes eld
2289 \end_inset
2291 set-rwmode
2292 \begin_inset Quotes erd
2293 \end_inset
2295  command (note: moving to rwmode by Lua won't trigger this, as per recursive
2296  entry protection).
2297 \end_layout
2299 \begin_layout Subsubsection
2300 Callback: on_snoop(number port, number controller, number index, number
2301  value)
2302 \end_layout
2304 \begin_layout Standard
2305 Called each time bsnes asks for input.
2306  The value is the final value to be sent to bsnes core (readonly mode, autohold
2307  and autofire have been taken into account).
2308  Might be useful when translating movies to format suitable for console
2309  verification.
2310  Note: There is no way to modify the value to be sent.
2311 \end_layout
2313 \begin_layout Section
2314 Modifier and key names:
2315 \end_layout
2317 \begin_layout Subsection
2318 SDL Platform
2319 \end_layout
2321 \begin_layout Subsubsection
2322 Modifier names
2323 \end_layout
2325 \begin_layout Standard
2326 Following modifier names are known:
2327 \end_layout
2329 \begin_layout Itemize
2330 ctrl, lctrl, rctrl: Control keys
2331 \end_layout
2333 \begin_layout Itemize
2334 alt, lalt, ralt: ALT keys.
2335 \end_layout
2337 \begin_layout Itemize
2338 shift, lshift, rshift: Shift keys.
2339 \end_layout
2341 \begin_layout Itemize
2342 meta, lmeta, rmeta: Meta keys.
2343 \end_layout
2345 \begin_layout Itemize
2346 num, caps: Numlock/Capslock (these are sticky!)
2347 \end_layout
2349 \begin_layout Itemize
2350 mode: Mode select.
2351 \end_layout
2353 \begin_layout Subsubsection
2354 Key names
2355 \end_layout
2357 \begin_layout Standard
2358 Following key names are known:
2359 \end_layout
2361 \begin_layout Itemize
2362 backspace, tab, clear, return, pause, escape, space, exclaim, quotedbl,
2363  hash, dollar, ampersand, quote, leftparen, rightparen, asterisk, plus,
2364  comma, minus, period, slash, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, colon, semicolon,
2365  less, equals, greater, question, at, leftbracket, backslash, rightbracket,
2366  caret, underscore, backquote, a, b, c, d, e, f, g, h, i, j, k, l, m, n,
2367  o, p, q, r, s, t, u, v, w, x, y, z, delete, world_0, world_1, world_2,
2368  world_3, world_4, world_5, world_6, world_7, world_8, world_9, world_10,
2369  world_11, world_12, world_13, world_14, world_15, world_16, world_17, world_18,
2370  world_19, world_20, world_21, world_22, world_23, world_24, world_25, world_26,
2371  world_27, world_28, world_29, world_30, world_31, world_32, world_33, world_34,
2372  world_35, world_36, world_37, world_38, world_39, world_40, world_41, world_42,
2373  world_43, world_44, world_45, world_46, world_47, world_48, world_49, world_50,
2374  world_51, world_52, world_53, world_54, world_55, world_56, world_57, world_58,
2375  world_59, world_60, world_61, world_62, world_63, world_64, world_65, world_66,
2376  world_67, world_68, world_69, world_70, world_71, world_72, world_73, world_74,
2377  world_75, world_76, world_77, world_78, world_79, world_80, world_81, world_82,
2378  world_83, world_84, world_85, world_86, world_87, world_88, world_89, world_90,
2379  world_91, world_92, world_93, world_94, world_95, kp0, kp1, kp2, kp3, kp4,
2380  kp5, kp6, kp7, kp8, kp9, kp_period, kp_divide, kp_multiply, kp_minus, kp_plus,
2381  kp_enter, kp_equals, up, down, right, left, insert, home, end, pageup,
2382  pagedown, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14,
2383  f15, numlock, capslock, scrollock, rshift, lshift, rctrl, lctrl, ralt,
2384  lalt, rmeta, lmeta, lsuper, rsuper, mode, compose, help, print, sysreq,
2385  break, menu, power, euro, undo
2386 \end_layout
2388 \begin_layout Itemize
2389 Names of form 'key<n>' where <n> is 0-255 are interpretted as key having
2390  hardware-dependent scan code of <n> (useful to bind those keys that don't
2391  have symbolic names).
2392 \end_layout
2394 \begin_layout Standard
2395 In addition, following pseudo-keys are known (note: these do not work in
2396  conjunction with modifers):
2397 \end_layout
2399 \begin_layout Itemize
2400 joystick<num>button<button>: Joystick <num> (0-based) button <button> (0-based).
2401 \end_layout
2403 \begin_layout Itemize
2404 joystick<num>hat<hat>n: Joystick <num> (0-based) hat <hat> (0-based) up.
2405 \end_layout
2407 \begin_layout Itemize
2408 joystick<num>hat<hat>w: Joystick <num> (0-based) hat <hat> (0-based) left.
2409 \end_layout
2411 \begin_layout Itemize
2412 joystick<num>hat<hat>s: Joystick <num> (0-based) hat <hat> (0-based) down.
2413 \end_layout
2415 \begin_layout Itemize
2416 joystick<num>hat<hat>e: Joystick <num> (0-based) hat <hat> (0-based) right.
2417 \end_layout
2419 \begin_layout Itemize
2420 joystick<num>axis<axis>-: Joystick <num> (0-based) axis <axis> negative
2421  position (axis modes axis and axis_inverse).
2422 \end_layout
2424 \begin_layout Itemize
2425 joystick<num>axis<axis>+: Joystick <num> (0-based) axis <axis> positive
2426  position (axis modes axis and axis_inverse).
2427 \end_layout
2429 \begin_layout Itemize
2430 joystick<num>axis<axis>: Joystick <num> (0-based) axis <axis> pressure (axis
2431  modes pressure_*).
2432 \end_layout
2434 \begin_layout Subsubsection
2435 Special buttons:
2436 \end_layout
2438 \begin_layout Itemize
2439 Escape: Enter/Exit Command mode, cancel modal dialogs.
2440 \end_layout
2442 \begin_layout Itemize
2443 Return (also KPEnter): Execute command, ok modal dialog.
2444 \end_layout
2446 \begin_layout Itemize
2447 Pgup/Up (also KP8/9 if no num lock; command mode): Previous command in command
2448  history
2449 \end_layout
2451 \begin_layout Itemize
2452 Pgdn/Down(also KP2/3 if no num lock; command mode): Next command in command
2453  history
2454 \end_layout
2456 \begin_layout Itemize
2457 Home (also KP7 if no num lock; command mode): Beginning of command.
2458 \end_layout
2460 \begin_layout Itemize
2461 End (also KP1 if no num lock; command mode): End of command.
2462 \end_layout
2464 \begin_layout Itemize
2465 Left (also KP4 if no num lock; command mode): Move cursor left.
2466 \end_layout
2468 \begin_layout Itemize
2469 Right (also KP6 if no num lock; command mode): Move cursor right.
2470 \end_layout
2472 \begin_layout Itemize
2473 Delete (also KP.
2474  if no num lock; command mode): Delete character to right of cursor.
2475 \end_layout
2477 \begin_layout Itemize
2478 Insert (also KP0 if no num lock; command mode): Toggle between insert /
2479  overwrite modes.
2480 \end_layout
2482 \begin_layout Itemize
2483 Backspace (command mode): Delete character to left of cursor.
2484 \end_layout
2486 \begin_layout Itemize
2487 LCTRL+LALT+ESCAPE: Ungraceful shutdown (leaves dump corrupted!).
2488 \end_layout
2490 \begin_layout Subsubsection
2491 Watchdog timer:
2492 \end_layout
2494 \begin_layout Standard
2495 If emulator does not reach internal polling loop in 15 seconds after leaving
2496  it or 15 seconds after starting, the emulator instantly bombs out.
2497 \end_layout
2499 \begin_layout Section
2500 Movie file format
2501 \end_layout
2503 \begin_layout Standard
2504 Movie file is .zip archive in itself, normal ZIP archive tools work on it
2505  (note: If you recompress it, do not use compression methods other than
2506  store and deflate and especially do not use encryption of any kind).
2507 \end_layout
2509 \begin_layout Subsection
2510 Detecting clean start/SRAM/Savestate
2511 \end_layout
2513 \begin_layout Itemize
2514 If file has member 
2515 \begin_inset Quotes eld
2516 \end_inset
2518 savestate
2519 \begin_inset Quotes erd
2520 \end_inset
2522  it is savestate, otherwise:
2523 \end_layout
2525 \begin_layout Itemize
2526 If file has members with names starting 
2527 \begin_inset Quotes eld
2528 \end_inset
2530 moviesram.
2531 \begin_inset Quotes erd
2532 \end_inset
2534  it is movie starting from SRAM, otherwise:
2535 \end_layout
2537 \begin_layout Itemize
2538 It is movie starting from clear state.
2539 \end_layout
2541 \begin_layout Subsection
2542 Member: gametype
2543 \end_layout
2545 \begin_layout Standard
2546 Type of game ROM and region (as one line).
2547  Valid values are:
2548 \end_layout
2550 \begin_layout Standard
2551 \begin_inset Tabular
2552 <lyxtabular version="3" rows="8" columns="3">
2553 <features tabularvalignment="middle">
2554 <column alignment="center" valignment="top" width="0">
2555 <column alignment="center" valignment="top" width="0">
2556 <column alignment="center" valignment="top" width="0">
2557 <row>
2558 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
2559 \begin_inset Text
2561 \begin_layout Plain Layout
2562 Value
2563 \end_layout
2565 \end_inset
2566 </cell>
2567 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
2568 \begin_inset Text
2570 \begin_layout Plain Layout
2571 System
2572 \end_layout
2574 \end_inset
2575 </cell>
2576 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
2577 \begin_inset Text
2579 \begin_layout Plain Layout
2580 Region
2581 \end_layout
2583 \end_inset
2584 </cell>
2585 </row>
2586 <row>
2587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2588 \begin_inset Text
2590 \begin_layout Plain Layout
2591 snes_pal
2592 \end_layout
2594 \end_inset
2595 </cell>
2596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2597 \begin_inset Text
2599 \begin_layout Plain Layout
2600 Super NES
2601 \end_layout
2603 \end_inset
2604 </cell>
2605 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2606 \begin_inset Text
2608 \begin_layout Plain Layout
2610 \end_layout
2612 \end_inset
2613 </cell>
2614 </row>
2615 <row>
2616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2617 \begin_inset Text
2619 \begin_layout Plain Layout
2620 sgb_pal
2621 \end_layout
2623 \end_inset
2624 </cell>
2625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2626 \begin_inset Text
2628 \begin_layout Plain Layout
2629 Super Game Boy
2630 \end_layout
2632 \end_inset
2633 </cell>
2634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2635 \begin_inset Text
2637 \begin_layout Plain Layout
2639 \end_layout
2641 \end_inset
2642 </cell>
2643 </row>
2644 <row>
2645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2646 \begin_inset Text
2648 \begin_layout Plain Layout
2649 snes_ntsc
2650 \end_layout
2652 \end_inset
2653 </cell>
2654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2655 \begin_inset Text
2657 \begin_layout Plain Layout
2658 Super NES
2659 \end_layout
2661 \end_inset
2662 </cell>
2663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2664 \begin_inset Text
2666 \begin_layout Plain Layout
2667 NTSC
2668 \end_layout
2670 \end_inset
2671 </cell>
2672 </row>
2673 <row>
2674 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2675 \begin_inset Text
2677 \begin_layout Plain Layout
2678 sgb_ntsc
2679 \end_layout
2681 \end_inset
2682 </cell>
2683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2684 \begin_inset Text
2686 \begin_layout Plain Layout
2687 Super Game Boy
2688 \end_layout
2690 \end_inset
2691 </cell>
2692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2693 \begin_inset Text
2695 \begin_layout Plain Layout
2696 NTSC
2697 \end_layout
2699 \end_inset
2700 </cell>
2701 </row>
2702 <row>
2703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2704 \begin_inset Text
2706 \begin_layout Plain Layout
2708 \end_layout
2710 \end_inset
2711 </cell>
2712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2713 \begin_inset Text
2715 \begin_layout Plain Layout
2716 BS-X (non-slotted)
2717 \end_layout
2719 \end_inset
2720 </cell>
2721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2722 \begin_inset Text
2724 \begin_layout Plain Layout
2725 NTSC
2726 \end_layout
2728 \end_inset
2729 </cell>
2730 </row>
2731 <row>
2732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2733 \begin_inset Text
2735 \begin_layout Plain Layout
2736 bsxslotted
2737 \end_layout
2739 \end_inset
2740 </cell>
2741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2742 \begin_inset Text
2744 \begin_layout Plain Layout
2745 BS-X (slotted)
2746 \end_layout
2748 \end_inset
2749 </cell>
2750 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2751 \begin_inset Text
2753 \begin_layout Plain Layout
2754 NTSC
2755 \end_layout
2757 \end_inset
2758 </cell>
2759 </row>
2760 <row>
2761 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
2762 \begin_inset Text
2764 \begin_layout Plain Layout
2765 sufamiturbo
2766 \end_layout
2768 \end_inset
2769 </cell>
2770 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
2771 \begin_inset Text
2773 \begin_layout Plain Layout
2774 Sufami Turbo
2775 \end_layout
2777 \end_inset
2778 </cell>
2779 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
2780 \begin_inset Text
2782 \begin_layout Plain Layout
2783 NTSC
2784 \end_layout
2786 \end_inset
2787 </cell>
2788 </row>
2789 </lyxtabular>
2791 \end_inset
2794 \end_layout
2796 \begin_layout Standard
2797 Frame rates are:
2798 \end_layout
2800 \begin_layout Standard
2801 \begin_inset Tabular
2802 <lyxtabular version="3" rows="3" columns="2">
2803 <features tabularvalignment="middle">
2804 <column alignment="center" valignment="top" width="0">
2805 <column alignment="center" valignment="top" width="0">
2806 <row>
2807 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
2808 \begin_inset Text
2810 \begin_layout Plain Layout
2811 Region
2812 \end_layout
2814 \end_inset
2815 </cell>
2816 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
2817 \begin_inset Text
2819 \begin_layout Plain Layout
2820 Framerate (fps)
2821 \end_layout
2823 \end_inset
2824 </cell>
2825 </row>
2826 <row>
2827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2828 \begin_inset Text
2830 \begin_layout Plain Layout
2832 \end_layout
2834 \end_inset
2835 </cell>
2836 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2837 \begin_inset Text
2839 \begin_layout Plain Layout
2840 322445/6448
2841 \end_layout
2843 \end_inset
2844 </cell>
2845 </row>
2846 <row>
2847 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
2848 \begin_inset Text
2850 \begin_layout Plain Layout
2851 NTSC
2852 \end_layout
2854 \end_inset
2855 </cell>
2856 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
2857 \begin_inset Text
2859 \begin_layout Plain Layout
2860 10738636/178683
2861 \end_layout
2863 \end_inset
2864 </cell>
2865 </row>
2866 </lyxtabular>
2868 \end_inset
2871 \end_layout
2873 \begin_layout Subsection
2874 Member: port1
2875 \end_layout
2877 \begin_layout Standard
2878 Contains type of port #1 (as one line).
2879  Valid values are 'none', 'gamepad', 'multitap' and 'mouse'.
2880  If not present, defaults to 'gamepad'.
2881 \end_layout
2883 \begin_layout Subsection
2884 Member: port2
2885 \end_layout
2887 \begin_layout Standard
2888 Contains type of port #2 (as one line).
2889  Valid values are 'none', 'gamepad', 'multitap', 'mouse', 'superscope',
2890  'justifier' and 'justifiers'.
2891  If not present, defaults to 'none'.
2892 \end_layout
2894 \begin_layout Subsection
2895 Member: gamename
2896 \end_layout
2898 \begin_layout Standard
2899 Contains name of the game (as one line).
2900 \end_layout
2902 \begin_layout Subsection
2903 Member: authors
2904 \end_layout
2906 \begin_layout Standard
2907 Contains authors, one per line.
2908  Part before '|' is the full name, part after is the nickname.
2909 \end_layout
2911 \begin_layout Subsection
2912 Member: systemid
2913 \end_layout
2915 \begin_layout Standard
2916 Always 
2917 \begin_inset Quotes eld
2918 \end_inset
2920 lsnes-rr1
2921 \begin_inset Quotes erd
2922 \end_inset
2924  (one line).
2925  Used to reject other saves.
2926 \end_layout
2928 \begin_layout Subsection
2929 Member: controlsversion
2930 \end_layout
2932 \begin_layout Standard
2933 Always 
2934 \begin_inset Quotes eld
2935 \end_inset
2938 \begin_inset Quotes erd
2939 \end_inset
2941  (one line).
2942  Used to identify what controls are there.
2943 \end_layout
2945 \begin_layout Subsection
2946 Member: 
2947 \begin_inset Quotes eld
2948 \end_inset
2950 coreversion
2951 \begin_inset Quotes erd
2952 \end_inset
2955 \end_layout
2957 \begin_layout Standard
2958 Contains bsnes core version number (as one line).
2959 \end_layout
2961 \begin_layout Subsection
2962 Member: projectid
2963 \end_layout
2965 \begin_layout Standard
2966 Contains project ID (as one line).
2967  Used to identify if two movies are part of the same project.
2968 \end_layout
2970 \begin_layout Subsection
2971 Member: {rom,slota,slotb}{,xml}.sha256
2972 \end_layout
2974 \begin_layout Standard
2975 Contains SHA-256 of said ROM or ROM mapping file (as one line).
2976  Absent if corresponding file is absent.
2977 \end_layout
2979 \begin_layout Subsection
2980 Member: moviesram.<name>
2981 \end_layout
2983 \begin_layout Standard
2984 Raw binary startup SRAM of kind <name>.
2985  Only present in savestates and movies starting from SRAM.
2986 \end_layout
2988 \begin_layout Subsection
2989 Member: moviestate
2990 \end_layout
2992 \begin_layout Standard
2993 Raw binary movie state data.
2994  Only present in savestates.
2995 \end_layout
2997 \begin_layout Standard
2998 for version 0:
2999 \end_layout
3001 \begin_layout Itemize
3002 32 bytes: SHA-256 of project ID.
3003 \end_layout
3005 \begin_layout Itemize
3006 8 bytes: Big-endian current frame.
3007 \end_layout
3009 \begin_layout Itemize
3010 100x4 bytes: Poll counters for each control (bit31 of each is 
3011 \begin_inset Quotes eld
3012 \end_inset
3014 data ready
3015 \begin_inset Quotes erd
3016 \end_inset
3018  bit), big-endian.
3019 \end_layout
3021 \begin_layout Itemize
3022 8 bytes: Big-endian lag frame count.
3023 \end_layout
3025 \begin_layout Itemize
3026 32 bytes: SHA-256 of past input
3027 \end_layout
3029 \begin_layout Itemize
3030 32 bytes: SHA-256 of previous.
3031 \end_layout
3033 \begin_layout Itemize
3034 (total of 512 bytes)
3035 \end_layout
3037 \begin_layout Subsection
3038 Member: hostmemory
3039 \end_layout
3041 \begin_layout Standard
3042 Raw binary dump of host memory.
3043  Only present in savestates.
3044 \end_layout
3046 \begin_layout Subsection
3047 Member: savestate
3048 \end_layout
3050 \begin_layout Standard
3051 The raw binary savestate itself.
3052  Savestate detection uses this file, only present in savestates.
3053 \end_layout
3055 \begin_layout Subsection
3056 Member: screenshot
3057 \end_layout
3059 \begin_layout Standard
3060 Screenshot of current frame.
3061  Only present in savestates.
3062  First 2 bytes are big-endian width of image, rest are big-endian 15-bit
3063  image data (5 bits per channel*pixel, the MSB is unused).
3064  Height of image is inferred from the width and size of data.
3065 \end_layout
3067 \begin_layout Subsection
3068 Member: sram.<name>
3069 \end_layout
3071 \begin_layout Standard
3072 Raw binary SRAM of kind <name> at time of savestate.
3073  Only present in savestates.
3074 \end_layout
3076 \begin_layout Subsection
3077 Member: input
3078 \end_layout
3080 \begin_layout Standard
3081 The actual input track, one line per subframe (blank lines are skipped).
3082 \end_layout
3084 \begin_layout Itemize
3085 If the first byte of each line is '.', ' ', <tab> or '|', then the line is
3086  part of same frame as previous, otherwise it starts a new frame.
3087 \end_layout
3089 \begin_layout Itemize
3090 First subframe must start a new frame.
3091 \end_layout
3093 \begin_layout Standard
3094 Length of movie in frames is number of lines in input file that start a
3095  new frame.
3096 \end_layout
3098 \begin_layout Subsection
3099 Member: rerecords
3100 \end_layout
3102 \begin_layout Standard
3103 Contains textual base-10 rerecord count (as one line; emulator just writes
3104  this, it doesn't read it) + 1.
3105 \end_layout
3107 \begin_layout Subsection
3108 Member: rrdata
3109 \end_layout
3111 \begin_layout Standard
3112 This member stores set of load IDs.
3113  There is one load ID per rerecord (plus one corresponding to start of project).
3114 \end_layout
3116 \begin_layout Itemize
3117 This member constists of concatenation of records
3118 \end_layout
3120 \begin_layout Itemize
3121 Each record is 2-36 bytes long and can represent 1-16,843,009 consequtive
3122  IDs.
3123 \end_layout
3125 \begin_layout Itemize
3126 IDs are interpretted as 256-bit big-endian integers with warparound.
3127 \end_layout
3129 \begin_layout Itemize
3130 Initial predicted ID is all zeroes.
3131 \end_layout
3133 \begin_layout Standard
3134 Format of each record is:
3135 \end_layout
3137 \begin_layout Itemize
3138 1 byte: Opcode byte.
3139  Bits 0-4 are prefix length (prefixlen), bits 5-6 are count length (countlen).
3140  Bit 7 is unused.
3141 \end_layout
3143 \begin_layout Itemize
3144 32-prefixlen bytes of ID.
3145 \end_layout
3147 \begin_layout Itemize
3148 countlen bytes of big-endian count (count).
3149 \end_layout
3151 \begin_layout Standard
3152 Records are processed as follows:
3153 \end_layout
3155 \begin_layout Itemize
3156 To form the first ID encoded by record, take the first prefixlen bytes predicted
3157  ID and append the read ID value to it.
3158  The result is the first ID encoded.
3159 \end_layout
3161 \begin_layout Itemize
3162 If countlen is 0, record encodes 1 ID.
3163 \end_layout
3165 \begin_layout Itemize
3166 If countlen is 1, record encodes 2+count IDs.
3167 \end_layout
3169 \begin_layout Itemize
3170 If countlen is 2, record encodes 258+count IDs.
3171 \end_layout
3173 \begin_layout Itemize
3174 If countlen is 3, record encodes 65794+count IDs.
3175 \end_layout
3177 \begin_layout Itemize
3178 The new predicted ID is the next ID after last one encoded by the record.
3179 \end_layout
3181 \begin_layout Standard
3182 The number of rerecords + 1 is equal to the sum of number of IDs encoded
3183  by all records.
3184 \end_layout
3186 \begin_layout Subsection
3187 Member: starttime.second
3188 \end_layout
3190 \begin_layout Standard
3191 Movie starting time, second part.
3192  Epoch is Unix epoch.
3193  Default is 1,000,000,000.
3194 \end_layout
3196 \begin_layout Subsection
3197 Member: starttime.subsecond
3198 \end_layout
3200 \begin_layout Standard
3201 Movie starting time, subsecond part.
3202  Unit is 1/3,462,619,485,020 s.
3203  Default is 0.
3204 \end_layout
3206 \begin_layout Subsection
3207 Member: savetime.second
3208 \end_layout
3210 \begin_layout Standard
3211 Movie saving time, second part.
3212  Default is starttime.second.
3213  Only present in savestates.
3214 \end_layout
3216 \begin_layout Subsection
3217 Member: savetime.subsecond
3218 \end_layout
3220 \begin_layout Standard
3221 Movie saving time, subsecond part.
3222  Default is starttime.subsecond.
3223  Only present in savestates.
3224 \end_layout
3226 \begin_layout Section
3227 Compiling:
3228 \end_layout
3230 \begin_layout Subsection
3231 Building BSNES
3232 \end_layout
3234 \begin_layout Standard
3235 make ui=ui-libsnes options=debugger profile=accuracy
3236 \end_layout
3238 \begin_layout Itemize
3239 Yes, debugger is needed.
3240 \end_layout
3242 \begin_layout Subsection
3243 Prerequisite libraries:
3244 \end_layout
3246 \begin_layout Itemize
3247 zlib
3248 \end_layout
3250 \begin_layout Itemize
3251 SDL (SDL platform)
3252 \end_layout
3254 \begin_layout Itemize
3255 SDLmain (Windows only; Note you may have to extract the object out of archive)
3256 \end_layout
3258 \begin_layout Itemize
3259 boost_iostreams
3260 \end_layout
3262 \begin_layout Itemize
3263 boost_filesystem
3264 \end_layout
3266 \begin_layout Itemize
3267 boost conversion (header only)
3268 \end_layout
3270 \begin_layout Subsection
3271 Compile options to make:
3272 \end_layout
3274 \begin_layout Subsubsection
3275 BSNES_PATH=<path>
3276 \end_layout
3278 \begin_layout Standard
3279 Set path to BSNES bsnes directory to <path>.
3280 \end_layout
3282 \begin_layout Subsubsection
3283 NO_THREADS=1
3284 \end_layout
3286 \begin_layout Standard
3287 Don't use threads on Linux.
3288 \end_layout
3290 \begin_layout Subsubsection
3291 USE_THREADS=1
3292 \end_layout
3294 \begin_layout Standard
3295 Try to use threads even on non-Linux systems.
3296 \end_layout
3298 \begin_layout Subsubsection
3299 CC=<compiler>
3300 \end_layout
3302 \begin_layout Standard
3303 Target C++ compiler to use.
3304  Defaults to g++-4.5.
3305 \end_layout
3307 \begin_layout Standard
3308 Note: If crosscompiling, this has to be crosscompiler.
3309 \end_layout
3311 \begin_layout Subsubsection
3312 HOSTCC=<compiler>
3313 \end_layout
3315 \begin_layout Standard
3316 Host C++ compiler to use.
3317  Defaults to the same as CC.
3318 \end_layout
3320 \begin_layout Standard
3321 Note: If crosscompiling, that has to be host compiler (the files produced
3322  will be run in the build process!)
3323 \end_layout
3325 \begin_layout Subsubsection
3326 BSNES_IS_COMPAT=1
3327 \end_layout
3329 \begin_layout Standard
3330 Assume BSNES uses compatiblity core instead of accuracy core.
3331 \end_layout
3333 \begin_layout Subsubsection
3334 NO_LUA=1
3335 \end_layout
3337 \begin_layout Standard
3338 Don't compile in Lua support.
3339 \end_layout
3341 \begin_layout Subsubsection
3342 NO_TIME_INTERCEPT=1
3343 \end_layout
3345 \begin_layout Standard
3346 Disable time() interception.
3347  Prevents recording games using RTC but allows building on some platforms,
3348  notably Mac OS X.
3349 \end_layout
3351 \begin_layout Section
3352 Quick'n'dirty encode guide
3353 \end_layout
3355 \begin_layout Enumerate
3356 Start the emulator and load the movie file.
3357 \end_layout
3359 \begin_layout Enumerate
3360 Set large AVI option 'set-setting avi-large on'
3361 \end_layout
3363 \begin_layout Enumerate
3364 If dumping PAL, set bottom border to 2 'set-setting avi-bottom-border 2'
3365 \end_layout
3367 \begin_layout Enumerate
3368 Enable dumping 'dump-avi 12 tmpdump' (note: Normally 10 and above are 
3369 \begin_inset Quotes eld
3370 \end_inset
3372 use only if you know what you are doing.
3373 \begin_inset Quotes erd
3374 \end_inset
3377  In this case, these can be safely used because of how x264 internally works.
3378 \end_layout
3380 \begin_layout Enumerate
3381 Unpause and let it run until you want to end dumping.
3382 \end_layout
3384 \begin_layout Enumerate
3385 Close the emulator (closing the window is the easiest way)
3386 \end_layout
3388 \begin_layout Enumerate
3389 For each tmpdump*.avi file created, on command prompt, do 'x264 --crf 10
3390  -o tmpdump_<numbers>.mkv tmpdump_<numbers>.avi'.
3391 \end_layout
3393 \begin_layout Enumerate
3394 Do 'sox tmpdump.sox tmpdump.ogg rate -v 32000'
3395 \end_layout
3397 \begin_layout Enumerate
3398 Do 'mkvmerge -o tmpdump_video.mkv tmpdump_0000000.mkv + tmpdump_0000001.mkv
3399  + tmpdump_0000002.mkv' (list every tmpdump_<numbers>.mkv, with + in between).
3400 \end_layout
3402 \begin_layout Enumerate
3403 Do 'mkvmerge -o final.mkv tmpdump_video.mkv tmpdump.ogg'.
3404  Now final.mkv contains quick'n'dirty encode.
3405 \end_layout
3407 \begin_layout Section
3408 Errata:
3409 \end_layout
3411 \begin_layout Subsection
3412 Problems from BSNES core:
3413 \end_layout
3415 \begin_layout Itemize
3416 The whole pending save stuff.
3417 \end_layout
3419 \begin_layout Itemize
3420 Delay resets are slow.
3421 \end_layout
3423 \begin_layout Itemize
3424 RTC is not emulated in sync-stable manner.
3425 \end_layout
3427 \begin_layout Itemize
3428 Lack of layer hiding.
3429 \end_layout
3431 \begin_layout Itemize
3432 It is slow.
3433 \end_layout
3435 \begin_layout Itemize
3436 Firmwares can't be loaded from ZIP archives.
3437 \end_layout
3439 \begin_layout Itemize
3440 Manual polls can be corrupted if savestate occurs during those.
3441 \end_layout
3443 \begin_layout Subsection
3444 Other problems:
3445 \end_layout
3447 \begin_layout Itemize
3448 Modifiers don't work with pseudo-keys (SDL).
3449 \end_layout
3451 \begin_layout Itemize
3452 Audio for last dumped frame is not itself dumped.
3453 \end_layout
3455 \begin_layout Itemize
3456 Audio in UI is pretty bad in quality.
3457 \end_layout
3459 \begin_layout Itemize
3460 UI itself is 30fps max.
3461 \end_layout
3463 \begin_layout Itemize
3464 AVI compression levels 10-18 are not compatible with AVISynth AVISource.
3465 \end_layout
3467 \begin_layout Itemize
3468 No menus, command based interface (SDL).
3469 \end_layout
3471 \begin_layout Itemize
3472 Long commands don't scroll.
3473 \end_layout
3475 \begin_layout Section
3476 Changelog:
3477 \end_layout
3479 \begin_layout Subsection
3480 rr0-beta1
3481 \end_layout
3483 \begin_layout Itemize
3484 Fix -Wall warnings
3485 \end_layout
3487 \begin_layout Itemize
3488 Fix dumper video corruption with levels 10-18.
3489 \end_layout
3491 \begin_layout Subsection
3492 rr0-beta2
3493 \end_layout
3495 \begin_layout Itemize
3496 Autofire
3497 \end_layout
3499 \begin_layout Itemize
3500 Lots of code cleanups
3501 \end_layout
3503 \begin_layout Itemize
3504 Lua interface to settings
3505 \end_layout
3507 \begin_layout Itemize
3508 Allow specifying AVI borders without Lua
3509 \end_layout
3511 \begin_layout Itemize
3512 Fix scaling if vscale > 1 and originx > 0 (left border exists)
3513 \end_layout
3515 \begin_layout Itemize
3516 on_snoop lua callback
3517 \end_layout
3519 \begin_layout Itemize
3520 Faster movie loading and saving.
3521 \end_layout
3523 \begin_layout Subsection
3524 rr0-beta3
3525 \end_layout
3527 \begin_layout Itemize
3528 Joystick support
3529 \end_layout
3531 \begin_layout Subsection
3532 rr0-beta4
3533 \end_layout
3535 \begin_layout Itemize
3536 Fix multi-buttons
3537 \end_layout
3539 \begin_layout Itemize
3540 Save jukebox functionality.
3541 \end_layout
3543 \begin_layout Subsection
3544 rr0-beta5
3545 \end_layout
3547 \begin_layout Itemize
3548 Try to fix some nasty failing movie load edge cases
3549 \end_layout
3551 \begin_layout Itemize
3552 Allow specifying scripts to run on command line.
3553 \end_layout
3555 \begin_layout Subsection
3556 rr0-beta6
3557 \end_layout
3559 \begin_layout Itemize
3560 Major source code reorganization.
3561 \end_layout
3563 \begin_layout Itemize
3564 Backup savestates before overwriting.
3565 \end_layout
3567 \begin_layout Itemize
3568 Don't crash if loading initial state fails.
3569 \end_layout
3571 \begin_layout Subsection
3572 rr0-beta7
3573 \end_layout
3575 \begin_layout Itemize
3576 Fix firmware lookup
3577 \end_layout
3579 \begin_layout Itemize
3580 Fix author name parsing
3581 \end_layout
3583 \begin_layout Itemize
3584 Fix rerecord counting
3585 \end_layout
3587 \begin_layout Itemize
3588 (SDL) Print messages to console if SDL is uninitialized
3589 \end_layout
3591 \begin_layout Itemize
3592 Add movieinfo program
3593 \end_layout
3595 \begin_layout Itemize
3596 Fix loading movies starting from SRAM.
3597 \end_layout
3599 \begin_layout Subsection
3600 rr0-beta8
3601 \end_layout
3603 \begin_layout Itemize
3604 Add support for unattended dumping
3605 \end_layout
3607 \begin_layout Itemize
3608 Fix compiling for Win32
3609 \end_layout
3611 \begin_layout Itemize
3612 Don't lock up if sound can't be initialized
3613 \end_layout
3615 \begin_layout Itemize
3616 Strip trailing CR from commands
3617 \end_layout
3619 \begin_layout Itemize
3620 Don't try to do dubious things in global ctors (fix crash on startup)
3621 \end_layout
3623 \begin_layout Subsection
3624 rr0-beta9
3625 \end_layout
3627 \begin_layout Itemize
3628 Small documentation tweaking
3629 \end_layout
3631 \begin_layout Itemize
3632 Fix make clean
3633 \end_layout
3635 \begin_layout Itemize
3636 Fix major bug in modifier matching
3637 \end_layout
3639 \begin_layout Subsection
3640 rr0-beta10
3641 \end_layout
3643 \begin_layout Itemize
3644 Lots of documentation fixes
3645 \end_layout
3647 \begin_layout Itemize
3648 Use dedicated callbacks for event backcomm., not commands.
3649 \end_layout
3651 \begin_layout Itemize
3652 Ensure that the watchdog is not hit when executing delayed reset.
3653 \end_layout
3655 \begin_layout Itemize
3656 Remove errant tab from joystick message.
3657 \end_layout
3659 \begin_layout Subsection
3660 rr0-beta11
3661 \end_layout
3663 \begin_layout Itemize
3664 Make autofire operate in absolute time, not linear time
3665 \end_layout
3667 \begin_layout Itemize
3668 Reinitialize controls when resuming from loadstate
3669 \end_layout
3671 \begin_layout Itemize
3672 Some more code cleanups
3673 \end_layout
3675 \begin_layout Itemize
3676 If Lua allocator fails, call OOM_panic()
3677 \end_layout
3679 \begin_layout Itemize
3680 Byte/word/dword/qword sized host memory write/read functions.
3681 \end_layout
3683 \begin_layout Itemize
3684 Dump at correct framerate if dumping interlaced NTSC (height=448).
3685 \end_layout
3687 \begin_layout Subsection
3688 rr0-beta12
3689 \end_layout
3691 \begin_layout Itemize
3692 Actually include the complete source code
3693 \end_layout
3695 \begin_layout Itemize
3696 Keep track of RTC
3697 \end_layout
3699 \begin_layout Subsection
3700 rr0-beta13
3701 \end_layout
3703 \begin_layout Itemize
3704 Document {save,start}time.{,sub}second.
3705 \end_layout
3707 \begin_layout Itemize
3708 Intercept time() from bsnes core.
3709 \end_layout
3711 \end_body
3712 \end_document