Lua: gui.synchronous_repaint()
[lsnes.git] / lua.lyx
blob1c62cf050688f675d4a582a252b48bfea129fb82
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 english
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 \spacing single
29 \use_hyperref true
30 \pdf_bookmarks true
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
34 \pdf_breaklinks false
35 \pdf_pdfborder false
36 \pdf_colorlinks false
37 \pdf_backref false
38 \pdf_pdfusetitle true
39 \papersize a4paper
40 \use_geometry true
41 \use_amsmath 1
42 \use_esint 1
43 \use_mhchem 1
44 \use_mathdots 1
45 \cite_engine basic
46 \use_bibtopic false
47 \use_indices false
48 \paperorientation portrait
49 \suppress_date false
50 \use_refstyle 1
51 \index Hakusana
52 \shortcut idx
53 \color #008000
54 \end_index
55 \leftmargin 2cm
56 \topmargin 2cm
57 \rightmargin 1cm
58 \bottommargin 2cm
59 \headheight 1cm
60 \headsep 1cm
61 \footskip 1cm
62 \secnumdepth 3
63 \tocdepth 3
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
67 \papercolumns 1
68 \papersides 1
69 \paperpagestyle default
70 \tracking_changes false
71 \output_changes false
72 \html_math_output 0
73 \html_css_as_file 0
74 \html_be_strict false
75 \end_header
77 \begin_body
79 \begin_layout Title
80 lsnes Lua functions reference
81 \end_layout
83 \begin_layout Section
84 Table of contents
85 \end_layout
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
91 \end_inset
94 \end_layout
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
98 \end_inset
101 \end_layout
103 \begin_layout Section
104 Special tokens
105 \end_layout
107 \begin_layout Standard
108 These tokens are special, and are expanded while the script is being loaded
109 \end_layout
111 \begin_layout Subsection
112 @@LUA_SCRIPT_FILENAME@@
113 \end_layout
115 \begin_layout Standard
116 Expanded to string token containing path and filename of this Lua script.
117  Handy for referencing other lua scripts or resources that are relative
118  to this Lua script.
119 \end_layout
121 \begin_layout Standard
122 In practicular, this is suitable to be passed as base argument of various
123  functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
124 ad_png and gui.bitmap_load_pal.
125 \end_layout
127 \begin_layout Section
128 Global
129 \end_layout
131 \begin_layout Subsection
132 print: Print values to console
133 \end_layout
135 \begin_layout Itemize
136 Syntax: none print(value...
137  values)
138 \end_layout
140 \begin_layout Standard
141 Prints specified values to console.
142 \end_layout
144 \begin_layout Subsection
145 exec: Execute lsnes commands
146 \end_layout
148 \begin_layout Itemize
149 Syntax: none exec(string cmd)
150 \end_layout
152 \begin_layout Standard
153 Execute lsnes command <cmd>.
154 \end_layout
156 \begin_layout Subsection
157 utime: Get current time
158 \end_layout
160 \begin_layout Itemize
161 Syntax: (number,number) utime()
162 \end_layout
164 \begin_layout Standard
165 Returns two numbers.
166  First is time since some epoch in seconds, the second is microseconds mod
167  10^6 since that epoch.
168 \end_layout
170 \begin_layout Subsection
171 emulator_ready: Check if emulator has been fully initialized
172 \end_layout
174 \begin_layout Itemize
175 Syntax: boolean emulator_ready()
176 \end_layout
178 \begin_layout Standard
179 Returns true if emulator has finished booting, false if not (on_startup()
180  will be issued later).
181 \end_layout
183 \begin_layout Subsection
184 set_idle_timeout: Run function after timeout when emulator is idle
185 \end_layout
187 \begin_layout Itemize
188 Syntax: none set_idle_timeout(number timeout)
189 \end_layout
191 \begin_layout Standard
192 Set number of microseconds to block idle for.
193  After this timeout has expired, on_idle() will be called once.
194 \end_layout
196 \begin_layout Subsection
197 set_timer_timeout: Run function after timeout.
198 \end_layout
200 \begin_layout Itemize
201 Syntax: none set_timer_timeout(number timeout)
202 \end_layout
204 \begin_layout Standard
205 Set number of microseconds to block timer for.
206  After this timeout has expired, on_timer() will be called once.
207 \end_layout
209 \begin_layout Subsection
210 bus_address: Look up address in system bus.
211 \end_layout
213 \begin_layout Itemize
214 Syntax: none bus_address(number bus_addr)
215 \end_layout
217 \begin_layout Standard
218 Returns virtual address corresponding to specified address on system bus.
219 \end_layout
221 \begin_layout Subsection
222 loopwrapper: Convert loop into callable function
223 \end_layout
225 \begin_layout Itemize
226 Syntax: function loopwrapper(function fun, ...)
227 \end_layout
229 \begin_layout Standard
230 Calls function <fun> with function and specified arguments.
231  The function passed suspends execution until the function returned is called.
232  Handy for linear flow control among multiple invocations of a hook.
233  Example code:
234 \end_layout
236 \begin_layout LyX-Code
237 on_paint = loopwrapper(function(wait)
238 \end_layout
240 \begin_deeper
241 \begin_layout LyX-Code
242 while true do
243 \end_layout
245 \begin_deeper
246 \begin_layout LyX-Code
247 gui.text(0, 0, 
248 \begin_inset Quotes eld
249 \end_inset
251 Test!
252 \begin_inset Quotes erd
253 \end_inset
256 \end_layout
258 \begin_layout LyX-Code
259 wait();
260 \end_layout
262 \end_deeper
263 \begin_layout LyX-Code
265 \end_layout
267 \end_deeper
268 \begin_layout LyX-Code
269 end);
270 \end_layout
272 \begin_layout Subsection
273 list_bindings: List keybindings
274 \end_layout
276 \begin_layout Itemize
277 Syntax: table list_bindings([string cmd])
278 \end_layout
280 \begin_layout Standard
281 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
282  If <cmd> is specified, the table is limited to that command.
283  Also searches for controller keys.
284 \end_layout
286 \begin_layout Subsection
287 get_alias: Get expansion of alias
288 \end_layout
290 \begin_layout Itemize
291 Syntax: string get_alias(string aname)
292 \end_layout
294 \begin_layout Standard
295 Get expansion of given alias <aname>.
296 \end_layout
298 \begin_layout Subsection
299 set_alias: Set expansion of alias
300 \end_layout
302 \begin_layout Itemize
303 Syntax: none set_alias(string aname, string value)
304 \end_layout
306 \begin_layout Standard
307 Set expansion of given alias.
308 \end_layout
310 \begin_layout Subsection
311 create_ibind: Create invese binding
312 \end_layout
314 \begin_layout Itemize
315 Syntax: INVERSEBIND create_ibind(string name, string cmd)
316 \end_layout
318 \begin_layout Standard
319 Return object representing inverse binding with specified name <name> and
320  specified command <cmd>.
321 \end_layout
323 \begin_layout Itemize
324 Note: To create press/release commands, use aliases +foo and -foo .
325 \end_layout
327 \begin_layout Itemize
328 Note: Keep the returned object around.
329 \end_layout
331 \begin_layout Subsection
332 create_command: Create a command
333 \end_layout
335 \begin_layout Itemize
336 Syntax: COMMANDBIND create_commmand(string name, function a)
337 \end_layout
339 \begin_layout Itemize
340 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
341 \end_layout
343 \begin_layout Standard
344 Return object representing a command (pair).
345 \end_layout
347 \begin_layout Itemize
348 If only one function is specied, the command is level-sensitive, <a> is
349  callback.
350 \end_layout
352 \begin_layout Itemize
353 If <b> is function, the function is edge-sensitive, <a> is positive edge
354  callback and <b> is negative edge callback.
355 \end_layout
357 \begin_layout Itemize
358 All callbacks get single argument: The parameters passed.
359 \end_layout
361 \begin_layout Itemize
362 Keep the returned object around.
363 \end_layout
365 \begin_layout Subsection
366 loadfile: Load Lua script
367 \end_layout
369 \begin_layout Itemize
370 Syntax: function loadfile(string filename[, string base])
371 \end_layout
373 \begin_layout Standard
374 Load lua script from <filename>, resolved relative to <base> (if empty,
375  current directory).
376 \end_layout
378 \begin_layout Subsection
379 dofile: Execute Lua script
380 \end_layout
382 \begin_layout Itemize
383 Syntax: function dofile(string filename[, string base])
384 \end_layout
386 \begin_layout Standard
387 Execute lua script from <filename>, resolved relative to <base> (if empty,
388  current directory) and return all return values.
389 \end_layout
391 \begin_layout Subsection
392 open_file: Open a stream
393 \end_layout
395 \begin_layout Itemize
396 Syntax: FILEREADER open_file(string filename[, string base])
397 \end_layout
399 \begin_layout Standard
400 Open file <filename>, resolved relative to <base> (if empty, current directory)
401  and return a handle.
402 \end_layout
404 \begin_layout Subsection
405 FILEREADER(): Read line/bytes from stream
406 \end_layout
408 \begin_layout Itemize
409 Syntax: string/nil FILEREADER()
410 \end_layout
412 \begin_layout Itemize
413 Syntax: string/nil FILEREADER(number bytes)
414 \end_layout
416 \begin_layout Standard
417 Reads next line or <bytes> bytes from specified file handle.
418  On EOF, nil is returned.
419 \end_layout
421 \begin_layout Itemize
422 Note: The line-oriented variant reads in text mode, so CR at end of line
423  is stripped.
424 \end_layout
426 \begin_layout Subsection
427 FILEREADER:lines: Iterator to read all lines
428 \end_layout
430 \begin_layout Itemize
431 Syntax: for line in <foo>:lines() do ...
432  end
433 \end_layout
435 \begin_layout Standard
436 Iterator for reading all lines of <foo> in a loop.
437 \end_layout
439 \begin_layout Subsection
440 resolve_filename: Resolve name of file relative to another
441 \end_layout
443 \begin_layout Itemize
444 Syntax: string resolve_file(string filename, string base)
445 \end_layout
447 \begin_layout Standard
448 Resolve name of file <filename> relative to <base> and return the result.
449 \end_layout
451 \begin_layout Standard
452 \begin_inset Newpage pagebreak
453 \end_inset
456 \end_layout
458 \begin_layout Section
459 Table bit:
460 \end_layout
462 \begin_layout Standard
463 Bitwise logical functions and related.
464 \end_layout
466 \begin_layout Subsection
467 bit.none/bit.bnot: Bitwise none or NOT function
468 \end_layout
470 \begin_layout Itemize
471 Syntax: number bit.none(number...)
472 \end_layout
474 \begin_layout Itemize
475 Syntax: number bit.bnot(number...)
476 \end_layout
478 \begin_layout Standard
479 48-bit bitwise NOT / NONE function (set bits that are set in none of the
480  arguments).
481 \end_layout
483 \begin_layout Subsection
484 bit.any/bit.bor: Bitwise any or OR function
485 \end_layout
487 \begin_layout Itemize
488 Syntax: number bit.any(number...)
489 \end_layout
491 \begin_layout Itemize
492 Syntax: number bit.bor(number...)
493 \end_layout
495 \begin_layout Standard
496 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
497 \end_layout
499 \begin_layout Subsection
500 bit.all/bit.band: Bitwise all or AND function
501 \end_layout
503 \begin_layout Itemize
504 Syntax: number bit.all(number...)
505 \end_layout
507 \begin_layout Itemize
508 Syntax: number bit.band(number...)
509 \end_layout
511 \begin_layout Standard
512 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
514 \end_layout
516 \begin_layout Subsection
517 bit.parity/bit.bxor: Bitwise parity or XOR function
518 \end_layout
520 \begin_layout Itemize
521 Syntax: number bit.parity(number...)
522 \end_layout
524 \begin_layout Itemize
525 Syntax: number bit.bxor(number...)
526 \end_layout
528 \begin_layout Standard
529 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
530  of the arguments).
531 \end_layout
533 \begin_layout Subsection
534 bit.lrotate: Rotate a number left
535 \end_layout
537 \begin_layout Itemize
538 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
539 \end_layout
541 \begin_layout Standard
542 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
543  1) places.
544 \end_layout
546 \begin_layout Subsection
547 bit.rrotate: Rotate a number right
548 \end_layout
550 \begin_layout Itemize
551 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
552 \end_layout
554 \begin_layout Standard
555 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
556  1) places.
557 \end_layout
559 \begin_layout Subsection
560 bit.lshift: Shift a number left
561 \end_layout
563 \begin_layout Itemize
564 Syntax: number bit.lshift(number base[, number amount[, number bits]])
565 \end_layout
567 \begin_layout Standard
568 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
569  1) places.
570  The new bits are filled with zeroes.
571 \end_layout
573 \begin_layout Subsection
574 bit.lrshift: Shift a number right (logical)
575 \end_layout
577 \begin_layout Itemize
578 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
579 \end_layout
581 \begin_layout Standard
582 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
583  (default 1) places.
584  The new bits are filled with zeroes.
585 \end_layout
587 \begin_layout Subsection
588 bit.arshift: Shift a number right (arithmetic)
589 \end_layout
591 \begin_layout Itemize
592 Syntax: number bit.arshift(number base[, number amount[, number bits]])
593 \end_layout
595 \begin_layout Standard
596 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
597  (default 1) places.
598  The new bits are shifted in with copy of the high bit.
599 \end_layout
601 \begin_layout Subsection
602 bit.extract: Extract/shuffle bits from number
603 \end_layout
605 \begin_layout Itemize
606 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
607 \end_layout
609 \begin_layout Standard
610 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
611 \end_layout
613 \begin_layout Itemize
614 Note: Bit numbers up to 51 should work reliably (then things start falling
615  apart due to double precision issues).
616 \end_layout
618 \begin_layout Itemize
619 Note: There are two special bit positions, true and false, standing for
620  always set bit and always clear bit.
621 \end_layout
623 \begin_layout Subsection
624 bit.value: Construct number with specified bits set
625 \end_layout
627 \begin_layout Itemize
628 Syntax: number bit.value([number bit1[, number bit2,...]])
629 \end_layout
631 \begin_layout Standard
632 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
633  <bit2> places and so on.
634  As special value, nil argument is no-op.
635 \end_layout
637 \begin_layout Subsection
638 bit.test_any: Test if any bit is set
639 \end_layout
641 \begin_layout Itemize
642 Syntax: boolean bit.test_any(number a, number b)
643 \end_layout
645 \begin_layout Standard
646 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
647 \end_layout
649 \begin_layout Subsection
650 bit.test_all: Test if all bits are set
651 \end_layout
653 \begin_layout Itemize
654 Syntax: boolean bit.test_all(number a, number b)
655 \end_layout
657 \begin_layout Standard
658 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
659 \end_layout
661 \begin_layout Subsection
662 bit.popcount: Population count
663 \end_layout
665 \begin_layout Itemize
666 Syntax: number bit.popcount(number a)
667 \end_layout
669 \begin_layout Standard
670 Returns number of set bits in <a>.
671 \end_layout
673 \begin_layout Subsection
674 bit.clshift: Chained left shift
675 \end_layout
677 \begin_layout Itemize
678 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
679  bits]])
680 \end_layout
682 \begin_layout Standard
683 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
684  numbers to be of specified number of bits <bits> (default 48).
685 \end_layout
687 \begin_layout Subsection
688 bit.crshift: Chained right shift
689 \end_layout
691 \begin_layout Itemize
692 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
693  bits]])
694 \end_layout
696 \begin_layout Standard
697 Does chained right shift on <a>, <b> by <amount> positions (default 1),
698  assuming numbers to be of specified number of bits <bits> (default 48).
699 \end_layout
701 \begin_layout Subsection
702 bit.flagdecode: Decode bitfield into flags
703 \end_layout
705 \begin_layout Itemize
706 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
707  off]])
708 \end_layout
710 \begin_layout Standard
711 Return string of length bits where ith character is ith character of on
712  if bit i is on, otherwise ith character of off.
713  Out of range reads give last character.
714 \end_layout
716 \begin_layout Itemize
717 Note: <on> defaults to '*' if empty.
718 \end_layout
720 \begin_layout Itemize
721 Note: <off> defaults to '-' if empty.
722 \end_layout
724 \begin_layout Subsection
725 bit.rflagdecode: Decode bitfield into flags
726 \end_layout
728 \begin_layout Itemize
729 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
730  off]])
731 \end_layout
733 \begin_layout Standard
734 Like bit.flagdecode, but outputs the string in the opposite order (most significa
735 nt bit first).
736 \end_layout
738 \begin_layout Standard
739 \begin_inset Newpage pagebreak
740 \end_inset
743 \end_layout
745 \begin_layout Section
746 Table gui:
747 \end_layout
749 \begin_layout Itemize
750 Functions that draw to screen can only only be called in on_paint and on_video
751  callbacks or if non-default render queue has been set.
752 \end_layout
754 \begin_layout Itemize
755 Colors are 32-bit.
756  Bits 0-7 are the blue component, bits 8-15 are the green component, bits
757  16-23 are the red component, bits 24-31 are alpha component (0 is fully
758  opaque, 255 is almost transparent).
759  -1 is the fully transparent color.
760 \end_layout
762 \begin_layout Itemize
763 Alpha values greater than 127 do work properly.
764 \end_layout
766 \begin_layout Itemize
767 Origin of coordinates is at top left corner of game display area.
768  Left and top gaps correspond to negative coordinates.
769 \end_layout
771 \begin_layout Subsection
772 gui.resolution: Get current resolution
773 \end_layout
775 \begin_layout Itemize
776 Syntax: (number, number) gui.resolution()
777 \end_layout
779 \begin_layout Standard
780 Returns 2-tuple (hresolution, vresolution).
781 \end_layout
783 \begin_layout Subsection
784 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
785 \end_layout
787 \begin_layout Itemize
788 Syntax: number gui.left_gap(number gap)
789 \end_layout
791 \begin_layout Itemize
792 Syntax: number gui.right_gap(number gap)
793 \end_layout
795 \begin_layout Itemize
796 Syntax: number gui.top_gap(number gap)
797 \end_layout
799 \begin_layout Itemize
800 Syntax: number gui.bottom_gap(number gap)
801 \end_layout
803 \begin_layout Standard
804 Set the specified edge gap to specified value <gap> (max gap is 8191).
805  If successful, old gap is returned.
806 \end_layout
808 \begin_layout Subsection
809 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
810  Adjust edge gaps
811 \end_layout
813 \begin_layout Itemize
814 Syntax: number gui.delta_left_gap(number dgap)
815 \end_layout
817 \begin_layout Itemize
818 Syntax: number gui.delta_right_gap(number dgap)
819 \end_layout
821 \begin_layout Itemize
822 Syntax: number gui.delta_top_gap(number dgap)
823 \end_layout
825 \begin_layout Itemize
826 Syntax: number gui.delta_bottom_gap(number dgap)
827 \end_layout
829 \begin_layout Standard
830 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
831  and return the old gap (returns nothing on error).
832 \end_layout
834 \begin_layout Subsection
835 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
836 \end_layout
838 \begin_layout Itemize
839 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
840  bgc]])
841 \end_layout
843 \begin_layout Itemize
844 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
845  bgc]])
846 \end_layout
848 \begin_layout Itemize
849 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
850  bgc]])
851 \end_layout
853 \begin_layout Itemize
854 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
855  bgc]])
856 \end_layout
858 \begin_layout Standard
859 Draw specified text on the GUI (each character cell is 8 or 16 wide and
860  16 high).
861  Parameters:
862 \end_layout
864 \begin_layout Itemize
865 x: X-coordinate to start the drawing from (and x-coordinate at begining
866  of the lines).
867 \end_layout
869 \begin_layout Itemize
870 y: Y-coordinate to start the drawing from.
871 \end_layout
873 \begin_layout Itemize
874 text: The text to draw.
875 \end_layout
877 \begin_layout Itemize
878 fgc: Text color (default is 0xFFFFFF (white))
879 \end_layout
881 \begin_layout Itemize
882 bgc: Background color (default is -1 (transparent))
883 \end_layout
885 \begin_layout Standard
886 Note: The H variants draw at double width and V variants draw at double
887  height.
888 \end_layout
890 \begin_layout Subsection
891 gui.rectangle: Draw a rectangle
892 \end_layout
894 \begin_layout Itemize
895 Syntax: none gui.rectangle(number x, number y, number width, number height[,
896  number thickness[, number outline[, number fill]]])
897 \end_layout
899 \begin_layout Standard
900 Draw rectangle on the GUI.
901  Parameters:
902 \end_layout
904 \begin_layout Itemize
905 x: X-coordinate of left edge.
906 \end_layout
908 \begin_layout Itemize
909 y: Y-coordinate of upper edge.
910 \end_layout
912 \begin_layout Itemize
913 width: Width of rectangle.
914 \end_layout
916 \begin_layout Itemize
917 height: Height of rectangle.
918 \end_layout
920 \begin_layout Itemize
921 thickness: Thickness of outline (default is 1).
922 \end_layout
924 \begin_layout Itemize
925 outline: Color of outline (default is 0xFFFFFF (white))
926 \end_layout
928 \begin_layout Itemize
929 fill: Color of fill (default is -1 (transparent))
930 \end_layout
932 \begin_layout Subsection
933 gui.box: Draw a 3D-effect box
934 \end_layout
936 \begin_layout Itemize
937 Syntax: none gui.box(number x, number y, number width, number height[, number
938  thickness[, number outline1[,number outline2[, number fill]]]])
939 \end_layout
941 \begin_layout Standard
942 Draw rectangle with 3D effect on the GUI.
943  Parameters:
944 \end_layout
946 \begin_layout Itemize
947 x: X-coordinate of left edge.
948 \end_layout
950 \begin_layout Itemize
951 y: Y-coordinate of upper edge.
952 \end_layout
954 \begin_layout Itemize
955 width: Width of rectangle.
956 \end_layout
958 \begin_layout Itemize
959 height: Height of rectangle.
960 \end_layout
962 \begin_layout Itemize
963 thickness: Thickness of outline (default is 1).
964 \end_layout
966 \begin_layout Itemize
967 outline1: First color of outline (default is 0xFFFFFF (white))
968 \end_layout
970 \begin_layout Itemize
971 outline2: First color of outline (default is 0x808080 (dark gray))
972 \end_layout
974 \begin_layout Itemize
975 fill: Color of fill (default is 0xC0C0C0 (light grayy))
976 \end_layout
978 \begin_layout Subsection
979 gui.pixel: Draw a single pixel
980 \end_layout
982 \begin_layout Itemize
983 Syntax: none gui.pixel(number x, number y[, number color])
984 \end_layout
986 \begin_layout Standard
987 Draw one pixel on the GUI.
988  Parameters:
989 \end_layout
991 \begin_layout Itemize
992 x: X-coordinate of the pixel
993 \end_layout
995 \begin_layout Itemize
996 y: Y-coordinate of the pixel
997 \end_layout
999 \begin_layout Itemize
1000 color: Color of the pixel (default is 0xFFFFFF (white))
1001 \end_layout
1003 \begin_layout Subsection
1004 gui.crosshair: Draw a crosshair
1005 \end_layout
1007 \begin_layout Itemize
1008 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
1009 \end_layout
1011 \begin_layout Standard
1012 Draw a crosshair.
1013  Parameters:
1014 \end_layout
1016 \begin_layout Itemize
1017 x: X-coordinate of the crosshair
1018 \end_layout
1020 \begin_layout Itemize
1021 y: Y-coordinate of the crosshair
1022 \end_layout
1024 \begin_layout Itemize
1025 length: Length of the crosshair lines (default 10).
1026 \end_layout
1028 \begin_layout Itemize
1029 color: Color of the crosshair (default is 0xFFFFFF (white))
1030 \end_layout
1032 \begin_layout Subsection
1033 gui.line: Draw a line
1034 \end_layout
1036 \begin_layout Itemize
1037 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
1038  color])
1039 \end_layout
1041 \begin_layout Standard
1042 Draw a thin line.
1043  Parameters:
1044 \end_layout
1046 \begin_layout Itemize
1047 x1: X-coordinate of one end.
1048 \end_layout
1050 \begin_layout Itemize
1051 y1: Y-coordinate of one end.
1052 \end_layout
1054 \begin_layout Itemize
1055 x2: X-coordinate of the other end.
1056 \end_layout
1058 \begin_layout Itemize
1059 y2: Y-coordinate of the other end.
1060 \end_layout
1062 \begin_layout Itemize
1063 color: Color of the line (default is 0xFFFFFF (white)).
1064 \end_layout
1066 \begin_layout Subsection
1067 gui.circle: Draw a (filled) circle
1068 \end_layout
1070 \begin_layout Itemize
1071 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
1072  border[, number fil]]])
1073 \end_layout
1075 \begin_layout Standard
1076 Draw a circle.
1077  Parameters.
1078 \end_layout
1080 \begin_layout Itemize
1081 x: X-coordinate of the center
1082 \end_layout
1084 \begin_layout Itemize
1085 y: Y-coordinate of the center
1086 \end_layout
1088 \begin_layout Itemize
1089 r: The radius of the circle
1090 \end_layout
1092 \begin_layout Itemize
1093 thick: Border thickness
1094 \end_layout
1096 \begin_layout Itemize
1097 border: Border color (default is 0xFFFFFF (white))
1098 \end_layout
1100 \begin_layout Itemize
1101 fill: Fill color (default is -1 (transparent)).
1102 \end_layout
1104 \begin_layout Subsection
1105 gui.bitmap_draw: Draw a bitmap
1106 \end_layout
1108 \begin_layout Itemize
1109 Syntax: none gui.bitmap_draw(number x, number y, BITMAP bitmap, PALETTE palette)
1110 \end_layout
1112 \begin_layout Itemize
1113 Syntax: none gui.bitmap_draw(number x, number y, DBITMAP bitmap)
1114 \end_layout
1116 \begin_layout Standard
1117 Draw a bitmap <bitmap> on screen with specified palette <palette> (if bitmap
1118  is paletted) .
1119  Parameters:
1120 \end_layout
1122 \begin_layout Itemize
1123 x: X-coordinate of left edge.
1124 \end_layout
1126 \begin_layout Itemize
1127 y: Y-coordinate of top edge.
1128 \end_layout
1130 \begin_layout Itemize
1131 bitmap: The bitmap to draw
1132 \end_layout
1134 \begin_layout Itemize
1135 palette: The palette to draw the bitmap using.
1136 \end_layout
1138 \begin_layout Subsection
1139 gui.palette_new: Create a new palette
1140 \end_layout
1142 \begin_layout Itemize
1143 Syntax: PALETTE gui.palette_new()
1144 \end_layout
1146 \begin_layout Standard
1147 Returns a new palette (initially all transparent).
1149 \end_layout
1151 \begin_layout Subsection
1152 gui.bitmap_new: Create a new bitmap
1153 \end_layout
1155 \begin_layout Itemize
1156 Syntax: BITMAP/DBITMAP gui.bitmap_new(number w, number h, boolean direct[,
1157  bool icolor])
1158 \end_layout
1160 \begin_layout Standard
1161 Returns a new bitmap/dbitmap.
1162 \end_layout
1164 \begin_layout Standard
1165 Parameters:
1166 \end_layout
1168 \begin_layout Itemize
1169 w: The width of new bitmap
1170 \end_layout
1172 \begin_layout Itemize
1173 h: The height of new bitmap
1174 \end_layout
1176 \begin_layout Itemize
1177 direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
1178 \end_layout
1180 \begin_layout Itemize
1181 icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
1182 \end_layout
1184 \begin_layout Subsection
1185 gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
1186 \end_layout
1188 \begin_layout Itemize
1189 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
1190 \end_layout
1192 \begin_layout Itemize
1193 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
1194 \end_layout
1196 \begin_layout Standard
1197 Reads file <file> (resolved relative to <base>) or string <content> and
1198  returns loaded bitmap/dbitmap (if bitmap, the second return value is palette
1199  for bitmap).
1200 \end_layout
1202 \begin_layout Subsection
1203 gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
1204 \end_layout
1206 \begin_layout Itemize
1207 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
1208  base])
1209 \end_layout
1211 \begin_layout Itemize
1212 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
1213 \end_layout
1215 \begin_layout Standard
1216 Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
1217  encoded content <content>.
1218 \end_layout
1220 \begin_layout Itemize
1221 If the PNG is of color type 3 (PALETTE), returns two value.
1222  First is BITMAP containing the image data from the PNG and second is PALETTE
1223  containg the palette data from the PNG.
1224 \end_layout
1226 \begin_layout Itemize
1227 For color types 0 (GRAY), 2 (RGB), 4 (GRAY_ALPHA) and 6 (RGBA), returns
1228  one DBITMAP containg the image data loaded from the PNG.
1229 \end_layout
1231 \begin_layout Subsection
1232 gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
1233 \end_layout
1235 \begin_layout Itemize
1236 Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
1237 \end_layout
1239 \begin_layout Itemize
1240 Syntax: PALETTE gui.bitmap_load_pal_str(string content)
1241 \end_layout
1243 \begin_layout Standard
1244 Load a palette from file <file>(resolved relative to <base>) or string <content>.
1245 \end_layout
1247 \begin_layout Itemize
1248 The kinds of lines supported:
1249 \end_layout
1251 \begin_deeper
1252 \begin_layout Itemize
1253 Blank or just whitespace: Ignored
1254 \end_layout
1256 \begin_layout Itemize
1257 First non-whitespace is '#': Ignored
1258 \end_layout
1260 \begin_layout Itemize
1261 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1262 \end_layout
1264 \begin_layout Itemize
1265 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1266  (0-256, 0 being fully transparent and 256 fully opaque).
1267 \end_layout
1269 \begin_layout Itemize
1270 transparent: Fully transparent color
1271 \end_layout
1273 \end_deeper
1274 \begin_layout Subsection
1275 gui.palette_set: Set palette entry
1276 \end_layout
1278 \begin_layout Itemize
1279 Syntax: none gui.palette_set(PALETTE palette, number index, number color)
1280 \end_layout
1282 \begin_layout Standard
1283 Sets color in palette.
1284  Parameters:
1285 \end_layout
1287 \begin_layout Itemize
1288 palette: The palette to manipulate
1289 \end_layout
1291 \begin_layout Itemize
1292 index: Index of color (0-65535).
1293 \end_layout
1295 \begin_layout Itemize
1296 color: The color value.
1297 \end_layout
1299 \begin_layout Subsection
1300 gui.bitmap_pset: Set pixel in bitmap
1301 \end_layout
1303 \begin_layout Itemize
1304 Syntax: none gui.bitmap_pset(BITMAP/DBITMAP bitmap, number x, number y, number
1305  color)
1306 \end_layout
1308 \begin_layout Standard
1309 Sets specified pixel in bitmap.
1310  Parameters:
1311 \end_layout
1313 \begin_layout Itemize
1314 bitmap: The bitmap to manipulate
1315 \end_layout
1317 \begin_layout Itemize
1318 x: The x-coordinate of the pixel.
1319 \end_layout
1321 \begin_layout Itemize
1322 y: The y-coordinate of the pixel.
1323 \end_layout
1325 \begin_layout Itemize
1326 color: If bitmap is a bitmap, color index (0-65535).
1327  Otherwise color value.
1328 \end_layout
1330 \begin_layout Subsection
1331 gui.bitmap_pget: Get pixel in bitmap
1332 \end_layout
1334 \begin_layout Itemize
1335 Syntax: number gui.bitmap_pget(BITMAP/DBITMAP bitmap, number x, number y)
1336 \end_layout
1338 \begin_layout Standard
1339 Gets specified pixel in bitmap.
1340  Parameters:
1341 \end_layout
1343 \begin_layout Itemize
1344 bitmap: The bitmap to query
1345 \end_layout
1347 \begin_layout Itemize
1348 x: The x-coordinate of the pixel.
1349 \end_layout
1351 \begin_layout Itemize
1352 y: The y-coordinate of the pixel.
1353 \end_layout
1355 \begin_layout Standard
1356 The bitmap color (color index if paletted, otherwise color value).
1357 \end_layout
1359 \begin_layout Subsection
1360 gui.bitmap_size: Get size of bitmap
1361 \end_layout
1363 \begin_layout Itemize
1364 Syntax: (number, number) gui.bitmap_size(BITMAP/DBITMAP bitmap)
1365 \end_layout
1367 \begin_layout Standard
1368 Get size of bitmap <bitmap>.
1369  The first return is the width, the second is the height.
1370 \end_layout
1372 \begin_layout Itemize
1373 Note: Can be used anywhere.
1374 \end_layout
1376 \begin_layout Subsection
1377 gui.bitmap_blit: Blit a bitmap into another
1378 \end_layout
1380 \begin_layout Itemize
1381 Syntax: none gui.bitmap_blit(BITMAP/DBITMAP dest, number dx, number dy, BITMAP/DB
1382 ITMAP src, number sx, number sy, number w, number h[, number ck])
1383 \end_layout
1385 \begin_layout Standard
1386 Blit a part of bitmap to another.
1387  Parameters:
1388 \end_layout
1390 \begin_layout Itemize
1391 dest: Destination to blit to.
1392 \end_layout
1394 \begin_layout Itemize
1395 dx: left edge of target
1396 \end_layout
1398 \begin_layout Itemize
1399 dy: Top edge of target
1400 \end_layout
1402 \begin_layout Itemize
1403 src: The source to blit from.
1404  Must be of the same type as destination.
1405 \end_layout
1407 \begin_layout Itemize
1408 sx: left edge of source
1409 \end_layout
1411 \begin_layout Itemize
1412 sy: Top edge of source
1413 \end_layout
1415 \begin_layout Itemize
1416 w: Width of region
1417 \end_layout
1419 \begin_layout Itemize
1420 h: Height of region.
1421 \end_layout
1423 \begin_layout Itemize
1424 ck: Color key.
1425  Pixels of this color are not blitted.
1426 \end_layout
1428 \begin_deeper
1429 \begin_layout Itemize
1430 If bitmaps are bitmaps, this is color index of colorkey.
1431  Values outside range 0-65535 cause no key to be used as colorkey.
1432 \end_layout
1434 \begin_layout Itemize
1435 If bitmaps are dbitmaps, this color value of colorkey.
1436 \end_layout
1438 \begin_layout Itemize
1439 May be absent or nil for no colorkey blit.
1440 \end_layout
1442 \end_deeper
1443 \begin_layout Subsection
1444 gui.repaint: Arrange a repaint
1445 \end_layout
1447 \begin_layout Itemize
1448 Syntax: none gui.repaint()
1449 \end_layout
1451 \begin_layout Standard
1452 Request on_repaint() to happen as soon as possible.
1453 \end_layout
1455 \begin_layout Subsection
1456 gui.synchronous_repaint: Paint screen now
1457 \end_layout
1459 \begin_layout Itemize
1460 Syntax: none gui.synchronous_repaint(RENDERQUEUE queue)
1461 \end_layout
1463 \begin_layout Standard
1464 Paints specified render queue on screen right there and then.
1465 \end_layout
1467 \begin_layout Subsection
1468 gui.subframe_update: Enable/Disable subframe updates
1469 \end_layout
1471 \begin_layout Itemize
1472 Syntax: none gui.subframe_update(boolean on)
1473 \end_layout
1475 \begin_layout Standard
1476 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
1477  or not happen (<on>=false).
1478 \end_layout
1480 \begin_layout Subsection
1481 gui.screenshot: Write a screenshot
1482 \end_layout
1484 \begin_layout Itemize
1485 Syntax: none gui.screenshot(string filename)
1486 \end_layout
1488 \begin_layout Standard
1489 Write PNG screenshot of the current frame (no drawings) to specified file
1490  <filename>.
1491 \end_layout
1493 \begin_layout Subsection
1494 gui.color: Compose a color.
1495 \end_layout
1497 \begin_layout Itemize
1498 Syntax: number gui.color(number r, number g, number b[, number a])
1499 \end_layout
1501 \begin_layout Standard
1502 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
1503 , each component in scale 0-255.
1504  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
1505  fully opaque).
1506  The default alpha is 256.
1507 \end_layout
1509 \begin_layout Subsection
1510 gui.status: Set status variable
1511 \end_layout
1513 \begin_layout Itemize
1514 Syntax: none gui.status(string name, string value)
1515 \end_layout
1517 \begin_layout Standard
1518 Set status field 
1519 \begin_inset Quotes eld
1520 \end_inset
1522 L[<name>]
1523 \begin_inset Quotes erd
1524 \end_inset
1526  to <value> in status area.
1527 \end_layout
1529 \begin_layout Subsection
1530 gui.rainbow: Rainbow color calculation
1531 \end_layout
1533 \begin_layout Itemize
1534 Syntax: number gui.rainbow(number step, number steps[, number color])
1535 \end_layout
1537 \begin_layout Standard
1538 Perform hue rotation of color <color> (default bright red), by <step> steps.
1539  The number of steps per full rotation is given by absolute value of <steps>.
1540 \end_layout
1542 \begin_layout Standard
1543 If <steps> is negative, the rotation will be counterclockwise.
1544 \end_layout
1546 \begin_layout Subsection
1547 gui.renderq_new: Create a render queue
1548 \end_layout
1550 \begin_layout Itemize
1551 Syntax: RENDERQUEUE gui.renderq_new(number width, number height)
1552 \end_layout
1554 \begin_layout Standard
1555 Create render queue with specified reported size and return it.
1556 \end_layout
1558 \begin_layout Subsection
1559 gui.renderq_clear: Clear a render queue
1560 \end_layout
1562 \begin_layout Itemize
1563 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
1564 \end_layout
1566 \begin_layout Standard
1567 Clear specified render queue.
1568 \end_layout
1570 \begin_layout Subsection
1571 gui.renderq_set: Change active render queue
1572 \end_layout
1574 \begin_layout Itemize
1575 Syntax: none gui.renderq_set(RENDERQUEUE queue)
1576 \end_layout
1578 \begin_layout Standard
1579 Switch to specified render queue.
1580  Use nil as queue to switch to default queue.
1581 \end_layout
1583 \begin_layout Itemize
1584 Note: When switched to another queue, all drawing functions work and draw
1585  there, even outside on_video/on_paint.
1586 \end_layout
1588 \begin_layout Subsection
1589 gui.renderq_run: Run render queue
1590 \end_layout
1592 \begin_layout Itemize
1593 Syntax: none gui.renderq_run(RENDERQUEUE queue)
1594 \end_layout
1596 \begin_layout Standard
1597 Run specified render queue, copying the objects to current render queue.
1599 \end_layout
1601 \begin_layout Itemize
1602 Warning: Don't try to run the current render queue.
1603 \end_layout
1605 \begin_layout Subsection
1606 gui.loadfont: Load a font file
1607 \end_layout
1609 \begin_layout Itemize
1610 Syntax: CUSTOMFONT gui.loadfont(string filename)
1611 \end_layout
1613 \begin_layout Standard
1614 Loads font from specified file (CUSTOMFONT object).
1615 \end_layout
1617 \begin_layout Subsection
1618 CUSTOMFONT(): Render text to screen
1619 \end_layout
1621 \begin_layout Itemize
1622 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
1623  bgc[, number hlc]]])
1624 \end_layout
1626 \begin_layout Standard
1627 Draw string with custom font to screen.
1628  The parameters are the same as in gui.text, except <hlc> is the halo color
1629  (default is no halo).
1631 \end_layout
1633 \begin_layout Subsection
1634 gui.adjust_transparency: Adjust transparency of DBITMAP or PALETTE
1635 \end_layout
1637 \begin_layout Itemize
1638 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
1639 \end_layout
1641 \begin_layout Itemize
1642 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
1643 \end_layout
1645 \begin_layout Standard
1646 Multiply alpha channel of <obj> by <adj>/256.
1647  Useful for making 
1648 \begin_inset Quotes eld
1649 \end_inset
1651 ghosts
1652 \begin_inset Quotes erd
1653 \end_inset
1655  out of solid bitmaps.
1656 \end_layout
1658 \begin_layout Subsection
1659 gui.kill_frame: Kill video frame and associated sound
1660 \end_layout
1662 \begin_layout Itemize
1663 Syntax: none gui.kill_frame()
1664 \end_layout
1666 \begin_layout Standard
1667 Kills the currently dumped video frame + the associated sound.
1668  Only valid in on_video callback.
1669 \end_layout
1671 \begin_layout Standard
1672 \begin_inset Newpage pagebreak
1673 \end_inset
1676 \end_layout
1678 \begin_layout Section
1679 table input
1680 \end_layout
1682 \begin_layout Standard
1683 Input handling.
1684  Functions manipulating input are only available in on_input callback.
1685 \end_layout
1687 \begin_layout Subsection
1688 input.get: Read controller button/axis (deprecated)
1689 \end_layout
1691 \begin_layout Itemize
1692 Syntax: number input.get(number controller, number index)
1693 \end_layout
1695 \begin_layout Standard
1696 Read the specified index <index> (zero-based) from specified controller
1697  <controller> (zero-based).
1699 \end_layout
1701 \begin_layout Subsection
1702 input.set: Write controller button/axis (deprecated)
1703 \end_layout
1705 \begin_layout Itemize
1706 Syntax: none input.set(number controller, number index, number value)
1707 \end_layout
1709 \begin_layout Standard
1710 Write the specified index <index> (zero-based) from specified controller
1711  <controller> (zero-based), storing value <value>.
1712 \end_layout
1714 \begin_layout Subsection
1715 input.get2: Read controller button/axis
1716 \end_layout
1718 \begin_layout Itemize
1719 Syntax: number input.get2(number port, number controller, number index)
1720 \end_layout
1722 \begin_layout Standard
1723 Read the specified input tuple.
1724  Port 0 is system port.
1725 \end_layout
1727 \begin_layout Subsection
1728 input.set2: Write controller button/axis
1729 \end_layout
1731 \begin_layout Itemize
1732 Syntax: input.set2(number port, number controller, number index, number value)
1733 \end_layout
1735 \begin_layout Standard
1736 Write the specified input tuple.
1737  Port 0 is system port.
1738 \end_layout
1740 \begin_layout Subsection
1741 input.lcid_to_pcid2: Look up logical controller
1742 \end_layout
1744 \begin_layout Itemize
1745 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
1746 \end_layout
1748 \begin_layout Standard
1749 Look up physical pcid pair (port, controller) corresponding to specified
1750  logical controller (1-based).
1751  Returns nothing if controller does not exist.
1752 \end_layout
1754 \begin_layout Subsection
1755 input.port_type: Look up port type
1756 \end_layout
1758 \begin_layout Itemize
1759 Syntax: string input.port_type(number port)
1760 \end_layout
1762 \begin_layout Standard
1763 Return type of specified port.
1764 \end_layout
1766 \begin_layout Subsection
1767 input.controller_info: Get information about controller
1768 \end_layout
1770 \begin_layout Itemize
1771 Syntax: table input.controller_info(number port, number controller)
1772 \end_layout
1774 \begin_layout Standard
1775 Get controller info for specified controller.
1776  If controller does not exist, returns nil.
1777  Otherwise returns a table with following fields:
1778 \end_layout
1780 \begin_layout Itemize
1781 type (string): Type of the controller.
1782 \end_layout
1784 \begin_layout Itemize
1785 class (string): Class of the controller.
1786 \end_layout
1788 \begin_layout Itemize
1789 classnum (number): Number of the controller within its class (1-based)
1790 \end_layout
1792 \begin_layout Itemize
1793 lcid (number): Logical controller number of the controller.
1794 \end_layout
1796 \begin_layout Itemize
1797 button_count (number): Number of buttons on controller
1798 \end_layout
1800 \begin_layout Itemize
1801 buttons (array): Array of following info about each button:
1802 \end_layout
1804 \begin_deeper
1805 \begin_layout Itemize
1806 type (string): Type of button.
1807  Currently one of 
1808 \begin_inset Quotes eld
1809 \end_inset
1811 null
1812 \begin_inset Quotes erd
1813 \end_inset
1816 \begin_inset Quotes eld
1817 \end_inset
1819 button
1820 \begin_inset Quotes erd
1821 \end_inset
1824 \begin_inset Quotes eld
1825 \end_inset
1827 axis
1828 \begin_inset Quotes erd
1829 \end_inset
1832 \begin_inset Quotes eld
1833 \end_inset
1835 raxis
1836 \begin_inset Quotes erd
1837 \end_inset
1840 \end_layout
1842 \begin_layout Itemize
1843 name (string): Name of button.
1844 \end_layout
1846 \begin_layout Itemize
1847 symbol (string): Symbol of button.
1848  Only present for type 
1849 \begin_inset Quotes eld
1850 \end_inset
1852 button
1853 \begin_inset Quotes erd
1854 \end_inset
1857 \end_layout
1859 \begin_layout Itemize
1860 hidden (boolean): True if hidden button.
1862 \end_layout
1864 \end_deeper
1865 \begin_layout Subsection
1866 input.veto_button: Veto a button press
1867 \end_layout
1869 \begin_layout Itemize
1870 Syntax: none input.veto_button()
1871 \end_layout
1873 \begin_layout Standard
1874 Signals that the button event should be vetoed.
1875  Only valid in on_button callback.
1876 \end_layout
1878 \begin_layout Subsection
1879 input.geta: Get all buttons for controller (deprecated)
1880 \end_layout
1882 \begin_layout Itemize
1883 Syntax: (number, number...) input.geta(number controller)
1884 \end_layout
1886 \begin_layout Standard
1887 Get input state for entiere controller.
1888  Returns n return values.
1889 \end_layout
1891 \begin_layout Itemize
1892 1st return value: Bitmask: bit i is set if i:th index is nonzero
1893 \end_layout
1895 \begin_layout Itemize
1896 2nd- return value: value of i:th index.
1897 \end_layout
1899 \begin_layout Subsection
1900 input.seta: Set all buttons for controller (deprecated)
1901 \end_layout
1903 \begin_layout Itemize
1904 Syntax: none input.seta(number controller, number bitmask, number args...)
1905 \end_layout
1907 \begin_layout Standard
1908 Set state for entiere controller.
1909  args is up to N values for indices (overriding values in bitmask if specified).
1910 \end_layout
1912 \begin_layout Subsection
1913 input.controllertype: Get controller type (deprecated)
1914 \end_layout
1916 \begin_layout Itemize
1917 syntax: string input.controllertype(number controller)
1918 \end_layout
1920 \begin_layout Standard
1921 Get the type of controller as string.
1922 \end_layout
1924 \begin_layout Subsection
1925 input.reset: Execute (delayed) reset
1926 \end_layout
1928 \begin_layout Itemize
1929 Syntax: none input.reset([number cycles])
1930 \end_layout
1932 \begin_layout Standard
1933 Execute reset.
1934  If <cycles> is greater than zero, do delayed reset.
1935  0 (or no value) causes immediate reset.
1936 \end_layout
1938 \begin_layout Itemize
1939 Note: Only available with subframe flag false.
1940 \end_layout
1942 \begin_layout Subsection
1943 input.raw: Return raw input data
1944 \end_layout
1946 \begin_layout Itemize
1947 Syntax: table input.raw()
1948 \end_layout
1950 \begin_layout Standard
1951 Returns table of tables of all available keys and axes.
1952  The first table is indexed by key name (platform-dependent!), and the inner
1953  table has the following fields:
1954 \end_layout
1956 \begin_layout Itemize
1957 value: Last reported value for control
1958 \end_layout
1960 \begin_deeper
1961 \begin_layout Itemize
1962 For keys: 1 for pressed, 0 for released.
1963 \end_layout
1965 \begin_layout Itemize
1966 For axes: -32767...32767.
1967 \end_layout
1969 \begin_layout Itemize
1970 For presure-sensitive buttons: 0...32767.
1971 \end_layout
1973 \begin_layout Itemize
1974 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
1975 \end_layout
1977 \begin_layout Itemize
1978 For mouse: Coordinates relative to game area.
1979 \end_layout
1981 \end_deeper
1982 \begin_layout Itemize
1983 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
1984 \end_layout
1986 \begin_layout Subsection
1987 input.keyhook: Hook a key
1988 \end_layout
1990 \begin_layout Itemize
1991 Syntax: none input.keyhook(string key, boolean state)
1992 \end_layout
1994 \begin_layout Standard
1995 Requests that keyhook events to be sent for key <key> (<state>=true) or
1996  not sent (<state>=false).
1997 \end_layout
1999 \begin_layout Subsection
2000 input.joyget: Get controls for controller
2001 \end_layout
2003 \begin_layout Itemize
2004 Syntax: table input.joyget(number logical)
2005 \end_layout
2007 \begin_layout Standard
2008 Returns table for current controls for specified logical controller <logical>.
2009  The names of fields vary by controller type.
2010 \end_layout
2012 \begin_layout Itemize
2013 The buttons have the same name as those are referred to in other contexts
2014  in the emulator
2015 \end_layout
2017 \begin_layout Itemize
2018 The analog axes are usually 
2019 \begin_inset Quotes eld
2020 \end_inset
2022 xaxis
2023 \begin_inset Quotes erd
2024 \end_inset
2026  and 
2027 \begin_inset Quotes eld
2028 \end_inset
2030 yaxis
2031 \begin_inset Quotes erd
2032 \end_inset
2035 \end_layout
2037 \begin_layout Itemize
2038 Each field is numeric or boolean depending on axis/button.
2039 \end_layout
2041 \begin_layout Subsection
2042 input.joyset: Set controls for controller
2043 \end_layout
2045 \begin_layout Itemize
2046 Syntax: none input.joyset(number controller, table controls)
2047 \end_layout
2049 \begin_layout Standard
2050 Set the the state of specified controller to values specified in specified
2051  table.
2052 \end_layout
2054 \begin_layout Itemize
2055 Each field can be boolean or number.
2056 \end_layout
2058 \begin_layout Itemize
2059 Also, buttons allow strings, which cause value to be inverted.
2060 \end_layout
2062 \begin_layout Subsection
2063 input.lcid_to_pcid: Look up logical controller (deprecated)
2064 \end_layout
2066 \begin_layout Itemize
2067 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
2068 \end_layout
2070 \begin_layout Standard
2071 Returns the legacy pcid for controller (or false if there isn't one), followed
2072  by pcid pair.
2073  Returns nothing if controller does not exist.
2074 \end_layout
2076 \begin_layout Standard
2077 \begin_inset Newpage pagebreak
2078 \end_inset
2081 \end_layout
2083 \begin_layout Section
2084 Table keyboard
2085 \end_layout
2087 \begin_layout Standard
2088 Various keybinding-related functions
2089 \end_layout
2091 \begin_layout Subsection
2092 keyboard.bind: Bind a key
2093 \end_layout
2095 \begin_layout Itemize
2096 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
2097 \end_layout
2099 \begin_layout Standard
2100 Bind specified key with specified modifers to specified command.
2101 \end_layout
2103 \begin_layout Subsection
2104 keyboard.unbind: Unbind a key
2105 \end_layout
2107 \begin_layout Itemize
2108 Syntax: none keyboard.unbind(string mod, string mask, string key)
2109 \end_layout
2111 \begin_layout Standard
2112 Unbind specified key with specified modifers.
2113 \end_layout
2115 \begin_layout Subsection
2116 keyboard.alias: Set alias expansion
2117 \end_layout
2119 \begin_layout Itemize
2120 Syntax: none keyboard.alias(string alias, string expansion)
2121 \end_layout
2123 \begin_layout Standard
2124 Set expansion of given command.
2125 \end_layout
2127 \begin_layout Standard
2128 \begin_inset Newpage pagebreak
2129 \end_inset
2132 \end_layout
2134 \begin_layout Section
2135 Table subtitle
2136 \end_layout
2138 \begin_layout Standard
2139 Subtitle handling
2140 \end_layout
2142 \begin_layout Subsection
2143 subtitle.byindex: Look up start and length of subtitle by index
2144 \end_layout
2146 \begin_layout Itemize
2147 Syntax: (number, number) subtitle.byindex(number i)
2148 \end_layout
2150 \begin_layout Standard
2151 Read the frame and length of ith subtitle.
2152  Returns nothing if not present.
2153 \end_layout
2155 \begin_layout Subsection
2156 subtitle.set: Write a subtitle
2157 \end_layout
2159 \begin_layout Itemize
2160 Syntax: none subtitle.set(number f, number l, string txt)
2161 \end_layout
2163 \begin_layout Standard
2164 Set the text of subtitle.
2165 \end_layout
2167 \begin_layout Subsection
2168 subtitle.get: Read a subtitle
2169 \end_layout
2171 \begin_layout Itemize
2172 Syntax: string subtitle.get(number f, number l)
2173 \end_layout
2175 \begin_layout Standard
2176 Get the text of subtitle.
2177 \end_layout
2179 \begin_layout Subsection
2180 subtitle.delete: Delete a subtitle
2181 \end_layout
2183 \begin_layout Itemize
2184 Syntax: nonesubtitle.delete(number f, number l)
2185 \end_layout
2187 \begin_layout Standard
2188 Delete specified subtitle.
2189 \end_layout
2191 \begin_layout Standard
2192 \begin_inset Newpage pagebreak
2193 \end_inset
2196 \end_layout
2198 \begin_layout Section
2199 Table hostmemory
2200 \end_layout
2202 \begin_layout Standard
2203 Host memory handling (extra memory saved to savestates).
2204  Host memory starts empty.
2205 \end_layout
2207 \begin_layout Itemize
2208 Reads out of range return false.
2209 \end_layout
2211 \begin_layout Itemize
2212 Writes out of range extend the memory.
2213 \end_layout
2215 \begin_layout Subsection
2216 hostmemory.read: Read byte from host memory
2217 \end_layout
2219 \begin_layout Itemize
2220 Syntax: number hostmemory.read(number address)
2221 \end_layout
2223 \begin_layout Standard
2224 Reads byte from hostmemory slot address <address>.
2225 \end_layout
2227 \begin_layout Subsection
2228 hostmemory.write: Write byte to host memory
2229 \end_layout
2231 \begin_layout Itemize
2232 Syntax: none hostmemory.write(number address, number value)
2233 \end_layout
2235 \begin_layout Standard
2236 Writes hostmemory slot with value <value> 0-255.
2237 \end_layout
2239 \begin_layout Subsection
2240 hostmemory.read{,s}{byte,{,d,q}word}: Read from host memory
2241 \end_layout
2243 \begin_layout Itemize
2244 Syntax: number hostmemory.readbyte(number address)
2245 \end_layout
2247 \begin_layout Itemize
2248 Syntax: number hostmemory.readsbyte(number address)
2249 \end_layout
2251 \begin_layout Itemize
2252 Syntax: number hostmemory.readword(number address)
2253 \end_layout
2255 \begin_layout Itemize
2256 Syntax: number hostmemory.readsword(number address)
2257 \end_layout
2259 \begin_layout Itemize
2260 Syntax: number hostmemory.readdword(number address)
2261 \end_layout
2263 \begin_layout Itemize
2264 Syntax: number hostmemory.readsdword(number address)
2265 \end_layout
2267 \begin_layout Itemize
2268 Syntax: number hostmemory.readqword(number address)
2269 \end_layout
2271 \begin_layout Itemize
2272 Syntax: number hostmemory.readsqword(number address)
2273 \end_layout
2275 \begin_layout Standard
2276 Read elements (little-endian) from given address <address>.
2277 \end_layout
2279 \begin_layout Itemize
2280 byte is 1 element
2281 \end_layout
2283 \begin_layout Itemize
2284 word is 2 elements
2285 \end_layout
2287 \begin_layout Itemize
2288 dword is 4 elements
2289 \end_layout
2291 \begin_layout Itemize
2292 qword is 8 elements.
2293 \end_layout
2295 \begin_layout Itemize
2296 The 's' variants do signed read.
2297 \end_layout
2299 \begin_layout Subsection
2300 hostmemory.write{,s}{byte,{,d,q}word}: Write to host memory
2301 \end_layout
2303 \begin_layout Itemize
2304 Syntax: number hostmemory.writebyte(number address, number value)
2305 \end_layout
2307 \begin_layout Itemize
2308 Syntax: number hostmemory.writesbyte(number address, number value)
2309 \end_layout
2311 \begin_layout Itemize
2312 Syntax: number hostmemory.writeword(number address, number value)
2313 \end_layout
2315 \begin_layout Itemize
2316 Syntax: number hostmemory.writesword(number address, number value)
2317 \end_layout
2319 \begin_layout Itemize
2320 Syntax: number hostmemory.writedword(number address, number value)
2321 \end_layout
2323 \begin_layout Itemize
2324 Syntax: number hostmemory.writesdword(number address, number value)
2325 \end_layout
2327 \begin_layout Itemize
2328 Syntax: number hostmemory.writeqword(number address, number value)
2329 \end_layout
2331 \begin_layout Itemize
2332 Syntax: number hostmemory.writesqword(number address, number value)
2333 \end_layout
2335 \begin_layout Standard
2336 Write value <value> to elements (little-endian) starting from given address
2337  <address>.
2338 \end_layout
2340 \begin_layout Itemize
2341 byte is 1 element
2342 \end_layout
2344 \begin_layout Itemize
2345 word is 2 elements
2346 \end_layout
2348 \begin_layout Itemize
2349 dword is 4 elements
2350 \end_layout
2352 \begin_layout Itemize
2353 qword is 8 elements.
2354 \end_layout
2356 \begin_layout Itemize
2357 The 's' variants do signed write.
2358 \end_layout
2360 \begin_layout Standard
2361 \begin_inset Newpage pagebreak
2362 \end_inset
2365 \end_layout
2367 \begin_layout Section
2368 Table movie
2369 \end_layout
2371 \begin_layout Standard
2372 Movie handling
2373 \end_layout
2375 \begin_layout Subsection
2376 movie.currentframe: Get current frame number
2377 \end_layout
2379 \begin_layout Itemize
2380 Syntax: number movie.currentframe()
2381 \end_layout
2383 \begin_layout Standard
2384 Return number of current frame.
2385 \end_layout
2387 \begin_layout Subsection
2388 movie.framecount: Get move frame count
2389 \end_layout
2391 \begin_layout Itemize
2392 Syntax: number movie.framecount()
2393 \end_layout
2395 \begin_layout Standard
2396 Return number of frames in movie.
2397 \end_layout
2399 \begin_layout Subsection
2400 movie.readonly: Is in readonly mode?
2401 \end_layout
2403 \begin_layout Itemize
2404 Syntax: boolean movie.readonly()
2405 \end_layout
2407 \begin_layout Standard
2408 Return true if in readonly mode, false if in readwrite.
2409 \end_layout
2411 \begin_layout Subsection
2412 movie.rerecords: Movie rerecord count
2413 \end_layout
2415 \begin_layout Itemize
2416 Syntax: number movie.rerecords()
2417 \end_layout
2419 \begin_layout Standard
2420 Returns the current value of rerecord count.
2421 \end_layout
2423 \begin_layout Subsection
2424 movie.set_readwrite: Set read-write mode.
2425 \end_layout
2427 \begin_layout Itemize
2428 Syntax: none movie.set_readwrite()
2429 \end_layout
2431 \begin_layout Standard
2432 Set readwrite mode (does not cause on_readwrite callback).
2433 \end_layout
2435 \begin_layout Subsection
2436 movie.frame_subframes: Count subframes in frame
2437 \end_layout
2439 \begin_layout Itemize
2440 Syntax: number movie.frame_subframes(number frame)
2441 \end_layout
2443 \begin_layout Standard
2444 Count number of subframes in specified frame <frame> (frame numbers are
2445  1-based) and return that.
2446 \end_layout
2448 \begin_layout Subsection
2449 movie.read_subframes: Read subframe data (deprecated)
2450 \end_layout
2452 \begin_layout Itemize
2453 Syntax: table movie.read_subframes(number frame, number subframe)
2454 \end_layout
2456 \begin_layout Standard
2457 Read specifed subframe in specified frame and return data as array.
2458 \end_layout
2460 \begin_layout Subsection
2461 movie.read_rtc: Read current RTC time
2462 \end_layout
2464 \begin_layout Itemize
2465 Syntax: (number, number) movie.read_rtc()
2466 \end_layout
2468 \begin_layout Standard
2469 Returns the current value of the RTC as a pair (second, subsecond).
2470 \end_layout
2472 \begin_layout Subsection
2473 movie.unsafe_rewind: Fast movie rewind to saved state
2474 \end_layout
2476 \begin_layout Itemize
2477 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
2478 \end_layout
2480 \begin_layout Standard
2481 Start setting point for unsafe rewind or jump to point of unsafe rewind.
2482 \end_layout
2484 \begin_layout Itemize
2485 If called without argument, causes emulator to start process of setting
2486  unsafe rewind point.
2487  When this has finished, callback on_set_rewind occurs, passing the rewind
2488  state to lua script.
2489 \end_layout
2491 \begin_layout Itemize
2492 If called with argument, causes emulator rewind to passed rewind point as
2493  soon as possible.
2494  Readwrite mode is implicitly activated.
2495 \end_layout
2497 \begin_layout Standard
2498 The following warnings apply to unsafe rewinding:
2499 \end_layout
2501 \begin_layout Itemize
2502 There are no safety checks against misuse (that's what 
2503 \begin_inset Quotes eld
2504 \end_inset
2506 unsafe
2507 \begin_inset Quotes erd
2508 \end_inset
2510  comes from)!
2511 \end_layout
2513 \begin_layout Itemize
2514 Only call rewind from timeline rewind point was set from.
2515 \end_layout
2517 \begin_layout Itemize
2518 Only call rewind from after the rewind point was set.
2519 \end_layout
2521 \begin_layout Subsection
2522 movie.to_rewind: Load savestate as rewind point
2523 \end_layout
2525 \begin_layout Itemize
2526 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
2527 \end_layout
2529 \begin_layout Standard
2530 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
2531  corresponding to it.
2532 \end_layout
2534 \begin_layout Itemize
2535 Note: This operation does not take emulated time.
2536 \end_layout
2538 \begin_layout Subsection
2539 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
2540 \end_layout
2542 \begin_layout Itemize
2543 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
2544 \end_layout
2546 \begin_layout Itemize
2547 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
2548 \end_layout
2550 \begin_layout Standard
2551 Copies specified movie <movie>/current object (if none or nil, the active
2552  movie) as new movie object.
2553 \end_layout
2555 \begin_layout Subsection
2556 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
2557 \end_layout
2559 \begin_layout Itemize
2560 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
2561 \end_layout
2563 \begin_layout Itemize
2564 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
2565 \end_layout
2567 \begin_layout Standard
2568 Get INPUTFRAME object corresponding to specified frame in specified movie.
2569 \end_layout
2571 \begin_layout Subsection
2572 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
2573 \end_layout
2575 \begin_layout Itemize
2576 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
2577  data)
2578 \end_layout
2580 \begin_layout Itemize
2581 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
2582 \end_layout
2584 \begin_layout Standard
2585 Set data in specified frame.
2586 \end_layout
2588 \begin_layout Itemize
2589 Note: Past can't be edited in active movie.
2590 \end_layout
2592 \begin_layout Subsection
2593 movie.get_size/INPUTMOVIE::get_size: Get size of movie
2594 \end_layout
2596 \begin_layout Itemize
2597 Syntax: integer movie.get_size([INPUTMOVIE movie])
2598 \end_layout
2600 \begin_layout Itemize
2601 Syntax: integer INPUTMOVIE::get_size()
2602 \end_layout
2604 \begin_layout Standard
2605 Return number of subframes in specified movie.
2606 \end_layout
2608 \begin_layout Subsection
2609 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
2610 \end_layout
2612 \begin_layout Itemize
2613 Syntax: number movie.count_frames([INPUTMOVIE movie])
2614 \end_layout
2616 \begin_layout Itemize
2617 Syntax: number INPUTMOVIE::count_frames()
2618 \end_layout
2620 \begin_layout Standard
2621 Return number of frames in movie.
2622 \end_layout
2624 \begin_layout Subsection
2625 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
2626 \end_layout
2628 \begin_layout Itemize
2629 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
2630 \end_layout
2632 \begin_layout Itemize
2633 Syntax: number INPUTMOVIE::find_frame(number frame)
2634 \end_layout
2636 \begin_layout Standard
2637 Returns starting subframe of given frame (frame numbers are 1-based).
2638  Returns -1 if frame number is bad.
2639 \end_layout
2641 \begin_layout Subsection
2642 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
2643 \end_layout
2645 \begin_layout Itemize
2646 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
2647 \end_layout
2649 \begin_layout Itemize
2650 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
2651 \end_layout
2653 \begin_layout Standard
2654 Return blank INPUTFRAME with frame type from specified movie.
2655 \end_layout
2657 \begin_layout Subsection
2658 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
2659 \end_layout
2661 \begin_layout Itemize
2662 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
2663 \end_layout
2665 \begin_layout Itemize
2666 Syntax: none INPUTMOVIE::append_frames(number frames)
2667 \end_layout
2669 \begin_layout Standard
2670 Append specified number <frames> of frames.
2671 \end_layout
2673 \begin_layout Subsection
2674 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
2675 \end_layout
2677 \begin_layout Itemize
2678 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
2679 \end_layout
2681 \begin_layout Itemize
2682 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
2683 \end_layout
2685 \begin_layout Standard
2686 Append specified frame <frame>.
2687  Past of current movie can't be edited.
2688 \end_layout
2690 \begin_layout Subsection
2691 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
2692 \end_layout
2694 \begin_layout Itemize
2695 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
2696 \end_layout
2698 \begin_layout Itemize
2699 Syntax: none INPUTMOVIE::truncate(number frames)
2700 \end_layout
2702 \begin_layout Standard
2703 Truncate the specified movie to specified number of frames.
2704 \end_layout
2706 \begin_layout Subsection
2707 movie.edit/INPUTMOVIE::edit: Edit a movie
2708 \end_layout
2710 \begin_layout Itemize
2711 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
2712  controller, number control, number/bool value)
2713 \end_layout
2715 \begin_layout Itemize
2716 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
2717  number control, number/bool value)
2718 \end_layout
2720 \begin_layout Standard
2721 Change specified control in specified frame in specified movie.
2722  Past can't be edited in active movie.
2723 \end_layout
2725 \begin_layout Subsection
2726 movie.copy_frames2: Copy frames between movies
2727 \end_layout
2729 \begin_layout Itemize
2730 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
2731  srcmov,] number src, number count)
2732 \end_layout
2734 \begin_layout Standard
2735 Copy specified number of frames between two movies.
2736  The copy proceeeds in forward direction.
2737 \end_layout
2739 \begin_layout Subsection
2740 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
2741 \end_layout
2743 \begin_layout Itemize
2744 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
2745  number count, bool backwards)
2746 \end_layout
2748 \begin_layout Itemize
2749 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
2750  bool backwards)
2751 \end_layout
2753 \begin_layout Standard
2754 Copy specified number of frames from one point in movie to another.
2755  If backwards is true, the copy will be done backwards.
2756 \end_layout
2758 \begin_layout Subsection
2759 movie.serialize/INPUTMOVIE::serialize: Serialize movie
2760 \end_layout
2762 \begin_layout Itemize
2763 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
2764 \end_layout
2766 \begin_layout Itemize
2767 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
2768 \end_layout
2770 \begin_layout Standard
2771 Serialize given movie into file.
2772  If binary is true, binary format (more compact and much faster) is used.
2773 \end_layout
2775 \begin_layout Subsection
2776 movie.unserialize: Unserialize movie
2777 \end_layout
2779 \begin_layout Itemize
2780 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
2781  bool binary)
2782 \end_layout
2784 \begin_layout Standard
2785 Unserialize movie from file.
2786  The given frame is used as template to decide the frame type.
2787  If binary is true, binary format is decoded (much faster).
2788 \end_layout
2790 \begin_layout Subsection
2791 movie.current_first_subframe: Return first subframe in current frame
2792 \end_layout
2794 \begin_layout Itemize
2795 Syntax: number movie.current_first_subframe()
2796 \end_layout
2798 \begin_layout Standard
2799 Returns first subframe in current frame.
2800 \end_layout
2802 \begin_layout Subsection
2803 movie.pollcounter: Return poll counter for speified control
2804 \end_layout
2806 \begin_layout Itemize
2807 Syntax: number movie.pollcounter(number port, number controller, number control)
2808 \end_layout
2810 \begin_layout Standard
2811 Returns number of times the specified control has been polled this frame.
2812 \end_layout
2814 \begin_layout Subsection
2815 INPUTFRAME::get_button: Get button
2816 \end_layout
2818 \begin_layout Itemize
2819 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
2820  control)
2821 \end_layout
2823 \begin_layout Standard
2824 Returns state of given button as boolean.
2825 \end_layout
2827 \begin_layout Subsection
2828 INPUTFRAME::get_axis: Get axis
2829 \end_layout
2831 \begin_layout Itemize
2832 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
2833  control)
2834 \end_layout
2836 \begin_layout Standard
2837 Returns state of given axis as number.
2838 \end_layout
2840 \begin_layout Subsection
2841 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
2842 \end_layout
2844 \begin_layout Itemize
2845 Syntax: none INPUTFRAME::set_button(number port, number controller, number
2846  control, number/bool value)
2847 \end_layout
2849 \begin_layout Itemize
2850 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
2851  control)
2852 \end_layout
2854 \begin_layout Standard
2855 Set the given button/axis to given value.
2856 \end_layout
2858 \begin_layout Subsection
2859 INPUTFRAME::serialize: Serialize a frame
2860 \end_layout
2862 \begin_layout Itemize
2863 Syntax: string INPUTFRAME::serialize()
2864 \end_layout
2866 \begin_layout Standard
2867 Return string representation of frame.
2868 \end_layout
2870 \begin_layout Subsection
2871 INPUTFRAME::unserialize: Unserialize a frame
2872 \end_layout
2874 \begin_layout Itemize
2875 Syntax: none INPUTFRAME::unserialize(string data)
2876 \end_layout
2878 \begin_layout Standard
2879 Set current frame from given data.
2880 \end_layout
2882 \begin_layout Subsection
2883 INPUTFRAME::get_stride: Get movie stride
2884 \end_layout
2886 \begin_layout Itemize
2887 Syntax: number INPUTFRAME::get_stride()
2888 \end_layout
2890 \begin_layout Standard
2891 Return number of bytes needed to store the input frame.
2892  Mainly useful for some debugging.
2893 \end_layout
2895 \begin_layout Standard
2896 \begin_inset Newpage pagebreak
2897 \end_inset
2900 \end_layout
2902 \begin_layout Section
2903 Table settings
2904 \end_layout
2906 \begin_layout Standard
2907 Routines for settings manipulation
2908 \end_layout
2910 \begin_layout Subsection
2911 settings.get: Get value of setting
2912 \end_layout
2914 \begin_layout Itemize
2915 Syntax: string settings.get(string name)
2916 \end_layout
2918 \begin_layout Standard
2919 Get value of setting <name>.
2920  If setting value can't be obtained, returns (nil, error message).
2921 \end_layout
2923 \begin_layout Subsection
2924 settings.set: Set value of setting
2925 \end_layout
2927 \begin_layout Itemize
2928 Syntax: none settings.set(string name, string value)
2929 \end_layout
2931 \begin_layout Standard
2932 Set value <value> of setting <name>.
2933  If setting can't be set, returns (nil, error message).
2934 \end_layout
2936 \begin_layout Standard
2937 \begin_inset Newpage pagebreak
2938 \end_inset
2941 \end_layout
2943 \begin_layout Section
2944 Table memory
2945 \end_layout
2947 \begin_layout Standard
2948 Contains various functions for managing memory
2949 \end_layout
2951 \begin_layout Subsection
2952 memory.vma_count: Count number of VMAs.
2953 \end_layout
2955 \begin_layout Itemize
2956 Syntax: number memory.vma_count()
2957 \end_layout
2959 \begin_layout Standard
2960 Returns the number of VMAs
2961 \end_layout
2963 \begin_layout Subsection
2964 memory.read_vma: Lookup VMA info by index
2965 \end_layout
2967 \begin_layout Itemize
2968 Syntax: string memory.read_vma(number index)
2969 \end_layout
2971 \begin_layout Standard
2972 Reads the specified VMA (indices start from zero).
2973  Trying to read invalid VMA gives nil.
2974  The read VMA is table with the following fields:
2975 \end_layout
2977 \begin_layout Itemize
2978 region_name (string): The readable name of the VMA
2979 \end_layout
2981 \begin_layout Itemize
2982 baseaddr (number): Base address of the VMA
2983 \end_layout
2985 \begin_layout Itemize
2986 lastaddr (number): Last address in the VMA.
2987 \end_layout
2989 \begin_layout Itemize
2990 size (number): The size of VMA in bytes.
2991 \end_layout
2993 \begin_layout Itemize
2994 readonly (boolean): True of the VMA corresponds to ROM.
2995 \end_layout
2997 \begin_layout Itemize
2998 iospace (boolean): True if the VMA is I/O space.
2999 \end_layout
3001 \begin_layout Itemize
3002 native_endian (boolean): True if the VMA has native endian as opposed to
3003  little endian.
3004 \end_layout
3006 \begin_layout Subsection
3007 memory.find_vma: Find VMA info by address
3008 \end_layout
3010 \begin_layout Itemize
3011 Syntax: table memory.find_vma(number address)
3012 \end_layout
3014 \begin_layout Standard
3015 Finds the VMA containing specified address.
3016  Returns table in the same format as read_vma or nil if not found.
3017 \end_layout
3019 \begin_layout Subsection
3020 memory.read{,s}{byte,{,d,q}word}: Write memory
3021 \end_layout
3023 \begin_layout Itemize
3024 Syntax: none memory.readbyte([string vma, ]number address)
3025 \end_layout
3027 \begin_layout Itemize
3028 Syntax: none memory.readword([string vma, ]number address)
3029 \end_layout
3031 \begin_layout Itemize
3032 Syntax: none memory.readdword([string vma, ]number address)
3033 \end_layout
3035 \begin_layout Itemize
3036 Syntax: none memory.readqword([string vma, ]number address)
3037 \end_layout
3039 \begin_layout Itemize
3040 Syntax: none memory.readsbyte([string vma, ]number address)
3041 \end_layout
3043 \begin_layout Itemize
3044 Syntax: none memory.readsword([string vma, ]number address)
3045 \end_layout
3047 \begin_layout Itemize
3048 Syntax: none memory.readsdword([string vma, ]number address)
3049 \end_layout
3051 \begin_layout Itemize
3052 Syntax: none memory.readsqword([string vma, ]number address)
3053 \end_layout
3055 \begin_layout Standard
3056 Reads the specified address <ddress> (if 's' variant is used, do undergo
3057  2's complement).
3058 \end_layout
3060 \begin_layout Subsection
3061 memory.write{byte,{,d,q}word}: Write memory
3062 \end_layout
3064 \begin_layout Itemize
3065 Syntax: none memory.writebyte([string vma, ]number address, number value)
3066 \end_layout
3068 \begin_layout Itemize
3069 Syntax: none memory.writeword([string vma, ]number address, number value)
3070 \end_layout
3072 \begin_layout Itemize
3073 Syntax: none memory.writedword([string vma, ]number address, number value)
3074 \end_layout
3076 \begin_layout Itemize
3077 Syntax: none memory.writeqword([string vma, ]number address, number value)
3078 \end_layout
3080 \begin_layout Standard
3081 Writes the specified value <value> (negative values undergo 2's complement)
3082  to specified address <address>.
3083 \end_layout
3085 \begin_layout Subsection
3086 memory.map{,s}{byte,{,d,q}word}: Map an array
3087 \end_layout
3089 \begin_layout Itemize
3090 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
3091 \end_layout
3093 \begin_layout Standard
3094 Returns a table mapping specified memory aperture for read/write.
3095  If parameters are omitted, entiere map space is the aperture.
3096 \end_layout
3098 \begin_layout Itemize
3099 Type may be one of: byte, sbyte, word, sword, dword, sdword, qword or sqword.
3100 \end_layout
3102 \begin_layout Subsection
3103 memory.hash_region: Hash region of memory
3104 \end_layout
3106 \begin_layout Itemize
3107 Syntax: string memory.hash_region([string vma, ]number base, number size)
3108 \end_layout
3110 \begin_layout Standard
3111 Hash specified number of bytes starting from specified address and return
3112  the SHA-256.
3113 \end_layout
3115 \begin_layout Subsection
3116 memory.hash_state: Hash system state
3117 \end_layout
3119 \begin_layout Itemize
3120 Syntax: string memory.hash_state()
3121 \end_layout
3123 \begin_layout Standard
3124 Hash the current system state.
3125  Mainly useful for debugging savestates.
3126 \end_layout
3128 \begin_layout Subsection
3129 memory.readregion: Read region of memory
3130 \end_layout
3132 \begin_layout Itemize
3133 Syntax: table memory.readregion([string vma, ]number base, number size)
3134 \end_layout
3136 \begin_layout Standard
3137 Read a region of memory.
3138 \end_layout
3140 \begin_layout Itemize
3141 Warning: If the region crosses VMA boundary, the results are undefined.
3142 \end_layout
3144 \begin_layout Subsection
3145 memory.writeregion: Write region of memory
3146 \end_layout
3148 \begin_layout Itemize
3149 Syntax: none memory.writeregion([string vma, ]number base, number size, table
3150  data)
3151 \end_layout
3153 \begin_layout Standard
3154 Write a region of memory.
3155 \end_layout
3157 \begin_layout Itemize
3158 Warning: If the region crosses VMA boundary, the results are undefined.
3159 \end_layout
3161 \begin_layout Subsection
3162 memory.map_structure: Create mmap structure
3163 \end_layout
3165 \begin_layout Itemize
3166 syntax: MMAP_STRUCT memory.map_structure()
3167 \end_layout
3169 \begin_layout Standard
3170 Returns a new mapping structure (MMAP_STRUCT)
3171 \end_layout
3173 \begin_layout Subsection
3174 MMAP_STRUCT(): Bind key in mmap structure
3175 \end_layout
3177 \begin_layout Itemize
3178 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
3179  type)
3180 \end_layout
3182 \begin_layout Standard
3183 Bind key <key> in mmap structure to specified address <address> with specified
3184  type <type>.
3185 \end_layout
3187 \begin_layout Itemize
3188 Type may be one of: byte, sbyte, word, sword, dword, sdword, qword or sqword.
3189 \end_layout
3191 \begin_layout Subsection
3192 memory.read_expr: Evaluate memory watch expression
3193 \end_layout
3195 \begin_layout Itemize
3196 Syntax: string memory.read_expr(string expr)
3197 \end_layout
3199 \begin_layout Standard
3200 Evaluate specified watch expression and return result
3201 \end_layout
3203 \begin_layout Subsection
3204 memory.action: Run core action
3205 \end_layout
3207 \begin_layout Itemize
3208 memory.action(string action, [<params>])
3209 \end_layout
3211 \begin_layout Standard
3212 Run core action.
3213  The different models expect parameters as:
3214 \end_layout
3216 \begin_layout Itemize
3217 string: String
3218 \end_layout
3220 \begin_layout Itemize
3221 numeric: numeric
3222 \end_layout
3224 \begin_layout Itemize
3225 enumeration: String
3226 \end_layout
3228 \begin_layout Itemize
3229 boolean: String
3230 \end_layout
3232 \begin_layout Itemize
3233 toggle: None.
3234 \end_layout
3236 \begin_layout Subsection
3237 memory.get_lag_flag: Get lag flag
3238 \end_layout
3240 \begin_layout Itemize
3241 Syntax: boolean memory.get_lag_flag()
3242 \end_layout
3244 \begin_layout Standard
3245 Get the value of core lag flag.
3246  True if this frame has been lag so far, false if poll has been detected.
3247 \end_layout
3249 \begin_layout Subsection
3250 memory.set_lag_flag: Set lag flag
3251 \end_layout
3253 \begin_layout Itemize
3254 Syntax: none memory.set_lag_flag(boolean flag)
3255 \end_layout
3257 \begin_layout Standard
3258 Set the value of core lag flag.
3259  This flag automatically gets cleared if poll is detected, but can be forcibly
3260  set or cleared if game so requires.
3261 \end_layout
3263 \begin_layout Itemize
3264 Should only be used in on_frame_emulated callback.
3265 \end_layout
3267 \begin_layout Itemize
3268 Setting or clearing this affects the emulator lag counter.
3269 \end_layout
3271 \begin_layout Standard
3272 \begin_inset Newpage pagebreak
3273 \end_inset
3276 \end_layout
3278 \begin_layout Section
3279 Table memory2
3280 \end_layout
3282 \begin_layout Standard
3283 Contains newer memory functions.
3284 \end_layout
3286 \begin_layout Subsection
3287 memory2(): Get all VMA names.
3288 \end_layout
3290 \begin_layout Itemize
3291 Syntax: table memory2()
3292 \end_layout
3294 \begin_layout Standard
3295 Returns array of all valid VMA names.
3296 \end_layout
3298 \begin_layout Subsection
3299 memory2.<vma>:info: Get VMA info
3300 \end_layout
3302 \begin_layout Itemize
3303 Syntax: table memory2.<vma>:info()
3304 \end_layout
3306 \begin_layout Standard
3307 Return table describing given VMA.
3308  Includes fields address, size, last, readonly, special and endian.
3309 \end_layout
3311 \begin_layout Subsection
3312 memory2.<vma>:<op>: Read/Write memory
3313 \end_layout
3315 \begin_layout Itemize
3316 Syntax: none memory2.<vma>:<op>(number offset, number value)
3317 \end_layout
3319 \begin_layout Itemize
3320 Syntax: number memory2.<vma>:<op>(number offset)
3321 \end_layout
3323 \begin_layout Standard
3324 Read/Write value from/to given VMA <vma> at given offset <offset> (must
3325  be in-range).
3326  The value written is <value>.
3327  <Op> is of form: [i][s]<type>, where:
3328 \end_layout
3330 \begin_layout Itemize
3331 <type> is one of 'byte', 'word', 'dword', 'qword'.
3332 \end_layout
3334 \begin_layout Itemize
3335 'i' signifies that the value is treated as opposite-to-normal endianess,
3336 \end_layout
3338 \begin_layout Itemize
3339 's' signifies that value is treated as signed.
3340 \end_layout
3342 \begin_layout Standard
3343 \begin_inset Newpage pagebreak
3344 \end_inset
3347 \end_layout
3349 \begin_layout Section
3350 Table callback
3351 \end_layout
3353 \begin_layout Standard
3354 Various callback-related functions.
3355 \end_layout
3357 \begin_layout Subsection
3358 \begin_inset CommandInset label
3359 LatexCommand label
3360 name "sub:callback.register:-Register-a"
3362 \end_inset
3364 callback.register: Register a callback
3365 \end_layout
3367 \begin_layout Itemize
3368 Syntax: function callback.register(string cbname, function cbfun);
3369 \end_layout
3371 \begin_layout Standard
3372 Instruct function <cbfun> to be added to list of callbacks to call on event
3373  <cbname> (See section 
3374 \begin_inset CommandInset ref
3375 LatexCommand ref
3376 reference "sec:Callbacks"
3378 \end_inset
3381  The callback name does not have the 'on_' prefix (e.g.
3383 \begin_inset Quotes eld
3384 \end_inset
3386 paint
3387 \begin_inset Quotes erd
3388 \end_inset
3391  Returns <cbfun>.
3392 \end_layout
3394 \begin_layout Subsection
3395 \begin_inset CommandInset label
3396 LatexCommand label
3397 name "sub:callback.unregister:-Unregister-"
3399 \end_inset
3401 callback.unregister: Unregister a callback
3402 \end_layout
3404 \begin_layout Itemize
3405 Syntax: function callback.unregister(string cbname, function cbfun);
3406 \end_layout
3408 \begin_layout Standard
3409 Instruct function <cbfun> to be removed from list of callbacks to call on
3410  event <cbname>.
3411 \end_layout
3413 \begin_layout Subsection
3414 callback.<cbname>:register: Register callback
3415 \end_layout
3417 \begin_layout Itemize
3418 Syntax: function callback.<cbname>:register(function cbfun)
3419 \end_layout
3421 \begin_layout Standard
3422 Synonym for callback.register (section 
3423 \begin_inset CommandInset ref
3424 LatexCommand ref
3425 reference "sub:callback.register:-Register-a"
3427 \end_inset
3429 ), albeit with callback name specified differently.
3430 \end_layout
3432 \begin_layout Subsection
3433 callback.<cbname>:unregister: Register callback
3434 \end_layout
3436 \begin_layout Itemize
3437 Syntax: function callback.<cbname>:unregister(function cbfun)
3438 \end_layout
3440 \begin_layout Standard
3441 Synonym for callback.unregister (section 
3442 \begin_inset CommandInset ref
3443 LatexCommand ref
3444 reference "sub:callback.unregister:-Unregister-"
3446 \end_inset
3448 ), albeit with callback name specified differently.
3449 \end_layout
3451 \begin_layout Section
3452 Table _SYSTEM
3453 \end_layout
3455 \begin_layout Standard
3456 Contains copy of global variables from time of Lua initialization.
3457  Non-writeable.
3458 \end_layout
3460 \begin_layout Standard
3461 \begin_inset Newpage pagebreak
3462 \end_inset
3465 \end_layout
3467 \begin_layout Section
3468 \begin_inset CommandInset label
3469 LatexCommand label
3470 name "sec:Callbacks"
3472 \end_inset
3474 Callbacks
3475 \end_layout
3477 \begin_layout Standard
3478 Various callbacks to Lua that can occur.
3479 \end_layout
3481 \begin_layout Subsection
3482 on_paint: Screen is being painted
3483 \end_layout
3485 \begin_layout Itemize
3486 Callback: on_paint(bool not_synth)
3487 \end_layout
3489 \begin_layout Standard
3490 Called when screen is being painted.
3491  Any gui.* calls requiring graphic context draw on the screen.
3492 \end_layout
3494 \begin_layout Itemize
3495 not_synth is true if this hook is being called in response to received frame,
3496  false otherwise.
3497 \end_layout
3499 \begin_layout Subsection
3500 on_video: Dumped video frame is being painted
3501 \end_layout
3503 \begin_layout Itemize
3504 Callback: on_video()
3505 \end_layout
3507 \begin_layout Standard
3508 Called when video dump frame is being painted.
3509  Any gui.* calls requiring graphic context draw on the video.
3510 \end_layout
3512 \begin_layout Subsection
3513 on_frame_emulated: Frame emulation complete
3514 \end_layout
3516 \begin_layout Itemize
3517 Callback: on_frame_emulated()
3518 \end_layout
3520 \begin_layout Standard
3521 Called when emulating frame has completed and on_paint()/on_video() calls
3522  are about to be issued.
3523 \end_layout
3525 \begin_layout Subsection
3526 on_frame: Frame emulation starting.
3527 \end_layout
3529 \begin_layout Itemize
3530 Callback: on_frame()
3531 \end_layout
3533 \begin_layout Standard
3534 Called on each starting whole frame.
3535 \end_layout
3537 \begin_layout Subsection
3538 on_startup: Emulator startup complete
3539 \end_layout
3541 \begin_layout Itemize
3542 Callback: on_startup()
3543 \end_layout
3545 \begin_layout Standard
3546 Called when the emulator is starting (lsnes.rc and --run files has been run).
3547 \end_layout
3549 \begin_layout Subsection
3550 on_rewind: Movie rewound to beginning
3551 \end_layout
3553 \begin_layout Itemize
3554 Callback: on_rewind()
3555 \end_layout
3557 \begin_layout Standard
3558 Called when rewind movie to beginning has completed.
3559 \end_layout
3561 \begin_layout Subsection
3562 on_pre_load: Load operation is about to start
3563 \end_layout
3565 \begin_layout Itemize
3566 Callback: on_pre_load(string name)
3567 \end_layout
3569 \begin_layout Standard
3570 Called just before savestate/movie load occurs (note: loads are always delayed,
3571  so this occurs even when load was initiated by lua).
3572 \end_layout
3574 \begin_layout Subsection
3575 on_err_Load: Load failed
3576 \end_layout
3578 \begin_layout Itemize
3579 Callback: on_err_load(string name)
3580 \end_layout
3582 \begin_layout Standard
3583 Called if loadstate goes wrong.
3584 \end_layout
3586 \begin_layout Subsection
3587 on_post_load: Load completed
3588 \end_layout
3590 \begin_layout Itemize
3591 Callback: on_post_load(string name, boolean was_savestate)
3592 \end_layout
3594 \begin_layout Standard
3595 Called on successful loadstate.
3596  was_savestate gives if this was a savestate or a movie.
3597 \end_layout
3599 \begin_layout Subsection
3600 on_pre_save: Save operation is about to start
3601 \end_layout
3603 \begin_layout Itemize
3604 Callback: on_pre_save(string name, boolean is_savestate)
3605 \end_layout
3607 \begin_layout Standard
3608 Called just before savestate save occurs (note: movie saves are synchronous
3609  and won't trigger these callbacks if called from Lua).
3610 \end_layout
3612 \begin_layout Subsection
3613 on_err_save: Save failed
3614 \end_layout
3616 \begin_layout Itemize
3617 Callback: on_err_save(string name)
3618 \end_layout
3620 \begin_layout Standard
3621 Called if savestate goes wrong.
3622 \end_layout
3624 \begin_layout Subsection
3625 on_post_save: Save completed
3626 \end_layout
3628 \begin_layout Itemize
3629 Callback: on_post_save(string name, boolean is_savestate)
3630 \end_layout
3632 \begin_layout Standard
3633 Called on successful savaestate.
3634  is_savestate gives if this was a savestate or a movie.
3635 \end_layout
3637 \begin_layout Subsection
3638 on_quit: Emulator is shutting down
3639 \end_layout
3641 \begin_layout Itemize
3642 Callback: on_quit()
3643 \end_layout
3645 \begin_layout Standard
3646 Called when emulator is shutting down.
3647 \end_layout
3649 \begin_layout Subsection
3650 on_input: Polling for input
3651 \end_layout
3653 \begin_layout Standard
3654 Called when emulator is just sending input to bsnes core.
3655  Warning: This is called even in readonly mode, but the results are ignored.
3656 \end_layout
3658 \begin_layout Subsection
3659 on_reset: System has been reset
3660 \end_layout
3662 \begin_layout Itemize
3663 Callback: on_reset()
3664 \end_layout
3666 \begin_layout Standard
3667 Called when system is reset.
3668 \end_layout
3670 \begin_layout Subsection
3671 on_readwrite: Entered readwrite mode
3672 \end_layout
3674 \begin_layout Itemize
3675 Callback: on_readwrite()
3676 \end_layout
3678 \begin_layout Standard
3679 Called when moving into readwrite mode as result of 
3680 \begin_inset Quotes eld
3681 \end_inset
3683 set-rwmode
3684 \begin_inset Quotes erd
3685 \end_inset
3687  command (note: moving to rwmode by Lua won't trigger this, as per recursive
3688  entry protection).
3689 \end_layout
3691 \begin_layout Subsection
3692 on_snoop/on_snoop2: Snoop core controller reads
3693 \end_layout
3695 \begin_layout Itemize
3696 Callback: on_snoop(number port, number controller, number index, number
3697  value)
3698 \end_layout
3700 \begin_layout Itemize
3701 Callback: on_snoop2(number port, number controller, number index, number
3702  value)
3703 \end_layout
3705 \begin_layout Standard
3706 Called each time bsnes asks for input.
3707  The value is the final value to be sent to bsnes core (readonly mode, autohold
3708  and autofire have been taken into account).
3709  Might be useful when translating movies to format suitable for console
3710  verification.
3711  Note: There is no way to modify the value to be sent.
3712 \end_layout
3714 \begin_layout Itemize
3715 On_snoop2 is called instead of on_snoop if defined.
3716  Reserves port 0 for system, having first user port be port 1.
3717 \end_layout
3719 \begin_layout Subsection
3720 on_keyhook: Hooked key/axis has been moved
3721 \end_layout
3723 \begin_layout Itemize
3724 Callback: on_keyhook(string keyname, table state)
3725 \end_layout
3727 \begin_layout Standard
3728 Sent when key that has keyhook events requested changes state.
3729  Keyname is name of the key (group) and state is the state (same kind as
3730  table values in input.raw).
3731 \end_layout
3733 \begin_layout Subsection
3734 on_idle: Idle event
3735 \end_layout
3737 \begin_layout Itemize
3738 Callback: on_idle()
3739 \end_layout
3741 \begin_layout Standard
3742 Called when requested by set_idle_timeout(), the timeout has expired and
3743  emulator is waiting.
3744 \end_layout
3746 \begin_layout Subsection
3747 on_timer: Timer event
3748 \end_layout
3750 \begin_layout Itemize
3751 Callback: on_timer()
3752 \end_layout
3754 \begin_layout Standard
3755 Called when requested by set_idle_timeout() and the timeout has expired
3756  (regardless if emulator is waiting).
3757 \end_layout
3759 \begin_layout Subsection
3760 on_set_rewind: Rewind point has been set
3761 \end_layout
3763 \begin_layout Itemize
3764 Callback: on_set_rewind(UNSAFEREWIND r)
3765 \end_layout
3767 \begin_layout Standard
3768 Called when unsafe rewind object has been constructed.
3769 \end_layout
3771 \begin_layout Subsection
3772 on_pre_rewind: Rewind is about to occur
3773 \end_layout
3775 \begin_layout Itemize
3776 Callback: on_pre_rewind() 
3777 \end_layout
3779 \begin_layout Standard
3780 Called just before unsafe rewind is about to occur.
3781 \end_layout
3783 \begin_layout Subsection
3784 on_post_rewind: Rewind has occured
3785 \end_layout
3787 \begin_layout Itemize
3788 Callback: on_post_rewind() 
3789 \end_layout
3791 \begin_layout Standard
3792 Called just after unsafe rewind has occured.
3793 \end_layout
3795 \begin_layout Subsection
3796 on_button: Button has been pressed
3797 \end_layout
3799 \begin_layout Itemize
3800 Callback: on_button(number port, number controller, number index, string
3801  type)
3802 \end_layout
3804 \begin_layout Standard
3805 Called on controller button press, with following parameters:
3806 \end_layout
3808 \begin_layout Itemize
3809 port: Port number (0 is system)
3810 \end_layout
3812 \begin_layout Itemize
3813 controller: Controller within port
3814 \end_layout
3816 \begin_layout Itemize
3817 index: Index of button.
3818 \end_layout
3820 \begin_layout Itemize
3821 type: Type of event, one of:
3822 \end_layout
3824 \begin_deeper
3825 \begin_layout Itemize
3826 \begin_inset Quotes eld
3827 \end_inset
3829 pressed
3830 \begin_inset Quotes erd
3831 \end_inset
3833 : Button was pressed.
3834 \end_layout
3836 \begin_layout Itemize
3837 \begin_inset Quotes eld
3838 \end_inset
3840 released
3841 \begin_inset Quotes erd
3842 \end_inset
3844 : Button was released.
3845 \end_layout
3847 \begin_layout Itemize
3848 \begin_inset Quotes eld
3849 \end_inset
3851 hold
3852 \begin_inset Quotes erd
3853 \end_inset
3855 : Held.
3856 \end_layout
3858 \begin_layout Itemize
3859 \begin_inset Quotes eld
3860 \end_inset
3862 unhold
3863 \begin_inset Quotes erd
3864 \end_inset
3866 : Released from hold.
3867 \end_layout
3869 \begin_layout Itemize
3870 \begin_inset Quotes eld
3871 \end_inset
3873 type
3874 \begin_inset Quotes erd
3875 \end_inset
3877 : Typing input on button.
3878 \end_layout
3880 \begin_layout Itemize
3881 \begin_inset Quotes eld
3882 \end_inset
3884 untype
3885 \begin_inset Quotes erd
3886 \end_inset
3888 : Typing input undone.
3889 \end_layout
3891 \begin_layout Itemize
3892 \begin_inset Quotes eld
3893 \end_inset
3895 autofire <duty> <cycle>
3896 \begin_inset Quotes erd
3897 \end_inset
3899 : Autofire with specifie duty and cycle.
3900 \end_layout
3902 \begin_layout Itemize
3903 \begin_inset Quotes eld
3904 \end_inset
3906 autofire
3907 \begin_inset Quotes erd
3908 \end_inset
3910 : Stop autofire.
3911 \end_layout
3913 \begin_layout Itemize
3914 \begin_inset Quotes eld
3915 \end_inset
3917 analog
3918 \begin_inset Quotes erd
3919 \end_inset
3921 : Analog action on axis.
3922 \end_layout
3924 \end_deeper
3925 \begin_layout Subsection
3926 on_movie_lost: Movie data is about to be lost
3927 \end_layout
3929 \begin_layout Itemize
3930 Callback: on_movie_lost(STRING kind)
3931 \end_layout
3933 \begin_layout Standard
3934 Called just before something would happen that could lose movie data.
3935  Kind can be:
3936 \end_layout
3938 \begin_layout Itemize
3939 readwrite: Switching to readwrite mode.
3940 \end_layout
3942 \begin_layout Itemize
3943 reload: ROM is being reloaded in readwrite mode.
3944 \end_layout
3946 \begin_layout Itemize
3947 load: New movie is being loaded.
3948 \end_layout
3950 \begin_layout Itemize
3951 unsaferewind: Unsafe rewind is happening.
3952 \end_layout
3954 \end_body
3955 \end_document