Portaudio: Heed defaults, don't use full-duplex mode
[lsnes.git] / lua.lyx
blob3e7e39ea5a377c85af19be52049a6c407d880e15
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.subframe_update: Enable/Disable subframe updates
1457 \end_layout
1459 \begin_layout Itemize
1460 Syntax: none gui.subframe_update(boolean on)
1461 \end_layout
1463 \begin_layout Standard
1464 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
1465  or not happen (<on>=false).
1466 \end_layout
1468 \begin_layout Subsection
1469 gui.screenshot: Write a screenshot
1470 \end_layout
1472 \begin_layout Itemize
1473 Syntax: none gui.screenshot(string filename)
1474 \end_layout
1476 \begin_layout Standard
1477 Write PNG screenshot of the current frame (no drawings) to specified file
1478  <filename>.
1479 \end_layout
1481 \begin_layout Subsection
1482 gui.color: Compose a color.
1483 \end_layout
1485 \begin_layout Itemize
1486 Syntax: number gui.color(number r, number g, number b[, number a])
1487 \end_layout
1489 \begin_layout Standard
1490 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
1491 , each component in scale 0-255.
1492  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
1493  fully opaque).
1494  The default alpha is 256.
1495 \end_layout
1497 \begin_layout Subsection
1498 gui.status: Set status variable
1499 \end_layout
1501 \begin_layout Itemize
1502 Syntax: none gui.status(string name, string value)
1503 \end_layout
1505 \begin_layout Standard
1506 Set status field 
1507 \begin_inset Quotes eld
1508 \end_inset
1510 L[<name>]
1511 \begin_inset Quotes erd
1512 \end_inset
1514  to <value> in status area.
1515 \end_layout
1517 \begin_layout Subsection
1518 gui.rainbow: Rainbow color calculation
1519 \end_layout
1521 \begin_layout Itemize
1522 Syntax: number gui.rainbow(number step, number steps[, number color])
1523 \end_layout
1525 \begin_layout Standard
1526 Perform hue rotation of color <color> (default bright red), by <step> steps.
1527  The number of steps per full rotation is given by absolute value of <steps>.
1528 \end_layout
1530 \begin_layout Standard
1531 If <steps> is negative, the rotation will be counterclockwise.
1532 \end_layout
1534 \begin_layout Subsection
1535 gui.renderq_new: Create a render queue
1536 \end_layout
1538 \begin_layout Itemize
1539 Syntax: RENDERQUEUE gui.renderq_new(number width, number height)
1540 \end_layout
1542 \begin_layout Standard
1543 Create render queue with specified reported size and return it.
1544 \end_layout
1546 \begin_layout Subsection
1547 gui.renderq_clear: Clear a render queue
1548 \end_layout
1550 \begin_layout Itemize
1551 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
1552 \end_layout
1554 \begin_layout Standard
1555 Clear specified render queue.
1556 \end_layout
1558 \begin_layout Subsection
1559 gui.renderq_set: Change active render queue
1560 \end_layout
1562 \begin_layout Itemize
1563 Syntax: none gui.renderq_set(RENDERQUEUE queue)
1564 \end_layout
1566 \begin_layout Standard
1567 Switch to specified render queue.
1568  Use nil as queue to switch to default queue.
1569 \end_layout
1571 \begin_layout Itemize
1572 Note: When switched to another queue, all drawing functions work and draw
1573  there, even outside on_video/on_paint.
1574 \end_layout
1576 \begin_layout Subsection
1577 gui.renderq_run: Run render queue
1578 \end_layout
1580 \begin_layout Itemize
1581 Syntax: none gui.renderq_run(RENDERQUEUE queue)
1582 \end_layout
1584 \begin_layout Standard
1585 Run specified render queue, copying the objects to current render queue.
1587 \end_layout
1589 \begin_layout Itemize
1590 Warning: Don't try to run the current render queue.
1591 \end_layout
1593 \begin_layout Subsection
1594 gui.loadfont: Load a font file
1595 \end_layout
1597 \begin_layout Itemize
1598 Syntax: CUSTOMFONT gui.loadfont(string filename)
1599 \end_layout
1601 \begin_layout Standard
1602 Loads font from specified file (CUSTOMFONT object).
1603 \end_layout
1605 \begin_layout Subsection
1606 CUSTOMFONT(): Render text to screen
1607 \end_layout
1609 \begin_layout Itemize
1610 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
1611  bgc[, number hlc]]])
1612 \end_layout
1614 \begin_layout Standard
1615 Draw string with custom font to screen.
1616  The parameters are the same as in gui.text, except <hlc> is the halo color
1617  (default is no halo).
1619 \end_layout
1621 \begin_layout Subsection
1622 gui.adjust_transparency: Adjust transparency of DBITMAP or PALETTE
1623 \end_layout
1625 \begin_layout Itemize
1626 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
1627 \end_layout
1629 \begin_layout Itemize
1630 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
1631 \end_layout
1633 \begin_layout Standard
1634 Multiply alpha channel of <obj> by <adj>/256.
1635  Useful for making 
1636 \begin_inset Quotes eld
1637 \end_inset
1639 ghosts
1640 \begin_inset Quotes erd
1641 \end_inset
1643  out of solid bitmaps.
1644 \end_layout
1646 \begin_layout Subsection
1647 gui.kill_frame: Kill video frame and associated sound
1648 \end_layout
1650 \begin_layout Itemize
1651 Syntax: none gui.kill_frame()
1652 \end_layout
1654 \begin_layout Standard
1655 Kills the currently dumped video frame + the associated sound.
1656  Only valid in on_video callback.
1657 \end_layout
1659 \begin_layout Standard
1660 \begin_inset Newpage pagebreak
1661 \end_inset
1664 \end_layout
1666 \begin_layout Section
1667 table input
1668 \end_layout
1670 \begin_layout Standard
1671 Input handling.
1672  Functions manipulating input are only available in on_input callback.
1673 \end_layout
1675 \begin_layout Subsection
1676 input.get: Read controller button/axis (deprecated)
1677 \end_layout
1679 \begin_layout Itemize
1680 Syntax: number input.get(number controller, number index)
1681 \end_layout
1683 \begin_layout Standard
1684 Read the specified index <index> (zero-based) from specified controller
1685  <controller> (zero-based).
1687 \end_layout
1689 \begin_layout Subsection
1690 input.set: Write controller button/axis (deprecated)
1691 \end_layout
1693 \begin_layout Itemize
1694 Syntax: none input.set(number controller, number index, number value)
1695 \end_layout
1697 \begin_layout Standard
1698 Write the specified index <index> (zero-based) from specified controller
1699  <controller> (zero-based), storing value <value>.
1700 \end_layout
1702 \begin_layout Subsection
1703 input.get2: Read controller button/axis
1704 \end_layout
1706 \begin_layout Itemize
1707 Syntax: number input.get2(number port, number controller, number index)
1708 \end_layout
1710 \begin_layout Standard
1711 Read the specified input tuple.
1712  Port 0 is system port.
1713 \end_layout
1715 \begin_layout Subsection
1716 input.set2: Write controller button/axis
1717 \end_layout
1719 \begin_layout Itemize
1720 Syntax: input.set2(number port, number controller, number index, number value)
1721 \end_layout
1723 \begin_layout Standard
1724 Write the specified input tuple.
1725  Port 0 is system port.
1726 \end_layout
1728 \begin_layout Subsection
1729 input.lcid_to_pcid2: Look up logical controller
1730 \end_layout
1732 \begin_layout Itemize
1733 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
1734 \end_layout
1736 \begin_layout Standard
1737 Look up physical pcid pair (port, controller) corresponding to specified
1738  logical controller (1-based).
1739  Returns nothing if controller does not exist.
1740 \end_layout
1742 \begin_layout Subsection
1743 input.port_type: Look up port type
1744 \end_layout
1746 \begin_layout Itemize
1747 Syntax: string input.port_type(number port)
1748 \end_layout
1750 \begin_layout Standard
1751 Return type of specified port.
1752 \end_layout
1754 \begin_layout Subsection
1755 input.controller_info: Get information about controller
1756 \end_layout
1758 \begin_layout Itemize
1759 Syntax: table input.controller_info(number port, number controller)
1760 \end_layout
1762 \begin_layout Standard
1763 Get controller info for specified controller.
1764  If controller does not exist, returns nil.
1765  Otherwise returns a table with following fields:
1766 \end_layout
1768 \begin_layout Itemize
1769 type (string): Type of the controller.
1770 \end_layout
1772 \begin_layout Itemize
1773 class (string): Class of the controller.
1774 \end_layout
1776 \begin_layout Itemize
1777 classnum (number): Number of the controller within its class (1-based)
1778 \end_layout
1780 \begin_layout Itemize
1781 lcid (number): Logical controller number of the controller.
1782 \end_layout
1784 \begin_layout Itemize
1785 button_count (number): Number of buttons on controller
1786 \end_layout
1788 \begin_layout Itemize
1789 buttons (array): Array of following info about each button:
1790 \end_layout
1792 \begin_deeper
1793 \begin_layout Itemize
1794 type (string): Type of button.
1795  Currently one of 
1796 \begin_inset Quotes eld
1797 \end_inset
1799 null
1800 \begin_inset Quotes erd
1801 \end_inset
1804 \begin_inset Quotes eld
1805 \end_inset
1807 button
1808 \begin_inset Quotes erd
1809 \end_inset
1812 \begin_inset Quotes eld
1813 \end_inset
1815 axis
1816 \begin_inset Quotes erd
1817 \end_inset
1820 \begin_inset Quotes eld
1821 \end_inset
1823 raxis
1824 \begin_inset Quotes erd
1825 \end_inset
1828 \end_layout
1830 \begin_layout Itemize
1831 name (string): Name of button.
1832 \end_layout
1834 \begin_layout Itemize
1835 symbol (string): Symbol of button.
1836  Only present for type 
1837 \begin_inset Quotes eld
1838 \end_inset
1840 button
1841 \begin_inset Quotes erd
1842 \end_inset
1845 \end_layout
1847 \begin_layout Itemize
1848 hidden (boolean): True if hidden button.
1850 \end_layout
1852 \end_deeper
1853 \begin_layout Subsection
1854 input.veto_button: Veto a button press
1855 \end_layout
1857 \begin_layout Itemize
1858 Syntax: none input.veto_button()
1859 \end_layout
1861 \begin_layout Standard
1862 Signals that the button event should be vetoed.
1863  Only valid in on_button callback.
1864 \end_layout
1866 \begin_layout Subsection
1867 input.geta: Get all buttons for controller (deprecated)
1868 \end_layout
1870 \begin_layout Itemize
1871 Syntax: (number, number...) input.geta(number controller)
1872 \end_layout
1874 \begin_layout Standard
1875 Get input state for entiere controller.
1876  Returns n return values.
1877 \end_layout
1879 \begin_layout Itemize
1880 1st return value: Bitmask: bit i is set if i:th index is nonzero
1881 \end_layout
1883 \begin_layout Itemize
1884 2nd- return value: value of i:th index.
1885 \end_layout
1887 \begin_layout Subsection
1888 input.seta: Set all buttons for controller (deprecated)
1889 \end_layout
1891 \begin_layout Itemize
1892 Syntax: none input.seta(number controller, number bitmask, number args...)
1893 \end_layout
1895 \begin_layout Standard
1896 Set state for entiere controller.
1897  args is up to N values for indices (overriding values in bitmask if specified).
1898 \end_layout
1900 \begin_layout Subsection
1901 input.controllertype: Get controller type (deprecated)
1902 \end_layout
1904 \begin_layout Itemize
1905 syntax: string input.controllertype(number controller)
1906 \end_layout
1908 \begin_layout Standard
1909 Get the type of controller as string.
1910 \end_layout
1912 \begin_layout Subsection
1913 input.reset: Execute (delayed) reset
1914 \end_layout
1916 \begin_layout Itemize
1917 Syntax: none input.reset([number cycles])
1918 \end_layout
1920 \begin_layout Standard
1921 Execute reset.
1922  If <cycles> is greater than zero, do delayed reset.
1923  0 (or no value) causes immediate reset.
1924 \end_layout
1926 \begin_layout Itemize
1927 Note: Only available with subframe flag false.
1928 \end_layout
1930 \begin_layout Subsection
1931 input.raw: Return raw input data
1932 \end_layout
1934 \begin_layout Itemize
1935 Syntax: table input.raw()
1936 \end_layout
1938 \begin_layout Standard
1939 Returns table of tables of all available keys and axes.
1940  The first table is indexed by key name (platform-dependent!), and the inner
1941  table has the following fields:
1942 \end_layout
1944 \begin_layout Itemize
1945 value: Last reported value for control
1946 \end_layout
1948 \begin_deeper
1949 \begin_layout Itemize
1950 For keys: 1 for pressed, 0 for released.
1951 \end_layout
1953 \begin_layout Itemize
1954 For axes: -32767...32767.
1955 \end_layout
1957 \begin_layout Itemize
1958 For presure-sensitive buttons: 0...32767.
1959 \end_layout
1961 \begin_layout Itemize
1962 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
1963 \end_layout
1965 \begin_layout Itemize
1966 For mouse: Coordinates relative to game area.
1967 \end_layout
1969 \end_deeper
1970 \begin_layout Itemize
1971 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
1972 \end_layout
1974 \begin_layout Subsection
1975 input.keyhook: Hook a key
1976 \end_layout
1978 \begin_layout Itemize
1979 Syntax: none input.keyhook(string key, boolean state)
1980 \end_layout
1982 \begin_layout Standard
1983 Requests that keyhook events to be sent for key <key> (<state>=true) or
1984  not sent (<state>=false).
1985 \end_layout
1987 \begin_layout Subsection
1988 input.joyget: Get controls for controller
1989 \end_layout
1991 \begin_layout Itemize
1992 Syntax: table input.joyget(number logical)
1993 \end_layout
1995 \begin_layout Standard
1996 Returns table for current controls for specified logical controller <logical>.
1997  The names of fields vary by controller type.
1998 \end_layout
2000 \begin_layout Itemize
2001 The buttons have the same name as those are referred to in other contexts
2002  in the emulator
2003 \end_layout
2005 \begin_layout Itemize
2006 The analog axes are usually 
2007 \begin_inset Quotes eld
2008 \end_inset
2010 xaxis
2011 \begin_inset Quotes erd
2012 \end_inset
2014  and 
2015 \begin_inset Quotes eld
2016 \end_inset
2018 yaxis
2019 \begin_inset Quotes erd
2020 \end_inset
2023 \end_layout
2025 \begin_layout Itemize
2026 Each field is numeric or boolean depending on axis/button.
2027 \end_layout
2029 \begin_layout Subsection
2030 input.joyset: Set controls for controller
2031 \end_layout
2033 \begin_layout Itemize
2034 Syntax: none input.joyset(number controller, table controls)
2035 \end_layout
2037 \begin_layout Standard
2038 Set the the state of specified controller to values specified in specified
2039  table.
2040 \end_layout
2042 \begin_layout Itemize
2043 Each field can be boolean or number.
2044 \end_layout
2046 \begin_layout Itemize
2047 Also, buttons allow strings, which cause value to be inverted.
2048 \end_layout
2050 \begin_layout Subsection
2051 input.lcid_to_pcid: Look up logical controller (deprecated)
2052 \end_layout
2054 \begin_layout Itemize
2055 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
2056 \end_layout
2058 \begin_layout Standard
2059 Returns the legacy pcid for controller (or false if there isn't one), followed
2060  by pcid pair.
2061  Returns nothing if controller does not exist.
2062 \end_layout
2064 \begin_layout Standard
2065 \begin_inset Newpage pagebreak
2066 \end_inset
2069 \end_layout
2071 \begin_layout Section
2072 Table keyboard
2073 \end_layout
2075 \begin_layout Standard
2076 Various keybinding-related functions
2077 \end_layout
2079 \begin_layout Subsection
2080 keyboard.bind: Bind a key
2081 \end_layout
2083 \begin_layout Itemize
2084 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
2085 \end_layout
2087 \begin_layout Standard
2088 Bind specified key with specified modifers to specified command.
2089 \end_layout
2091 \begin_layout Subsection
2092 keyboard.unbind: Unbind a key
2093 \end_layout
2095 \begin_layout Itemize
2096 Syntax: none keyboard.unbind(string mod, string mask, string key)
2097 \end_layout
2099 \begin_layout Standard
2100 Unbind specified key with specified modifers.
2101 \end_layout
2103 \begin_layout Subsection
2104 keyboard.alias: Set alias expansion
2105 \end_layout
2107 \begin_layout Itemize
2108 Syntax: none keyboard.alias(string alias, string expansion)
2109 \end_layout
2111 \begin_layout Standard
2112 Set expansion of given command.
2113 \end_layout
2115 \begin_layout Standard
2116 \begin_inset Newpage pagebreak
2117 \end_inset
2120 \end_layout
2122 \begin_layout Section
2123 Table subtitle
2124 \end_layout
2126 \begin_layout Standard
2127 Subtitle handling
2128 \end_layout
2130 \begin_layout Subsection
2131 subtitle.byindex: Look up start and length of subtitle by index
2132 \end_layout
2134 \begin_layout Itemize
2135 Syntax: (number, number) subtitle.byindex(number i)
2136 \end_layout
2138 \begin_layout Standard
2139 Read the frame and length of ith subtitle.
2140  Returns nothing if not present.
2141 \end_layout
2143 \begin_layout Subsection
2144 subtitle.set: Write a subtitle
2145 \end_layout
2147 \begin_layout Itemize
2148 Syntax: none subtitle.set(number f, number l, string txt)
2149 \end_layout
2151 \begin_layout Standard
2152 Set the text of subtitle.
2153 \end_layout
2155 \begin_layout Subsection
2156 subtitle.get: Read a subtitle
2157 \end_layout
2159 \begin_layout Itemize
2160 Syntax: string subtitle.get(number f, number l)
2161 \end_layout
2163 \begin_layout Standard
2164 Get the text of subtitle.
2165 \end_layout
2167 \begin_layout Subsection
2168 subtitle.delete: Delete a subtitle
2169 \end_layout
2171 \begin_layout Itemize
2172 Syntax: nonesubtitle.delete(number f, number l)
2173 \end_layout
2175 \begin_layout Standard
2176 Delete specified subtitle.
2177 \end_layout
2179 \begin_layout Standard
2180 \begin_inset Newpage pagebreak
2181 \end_inset
2184 \end_layout
2186 \begin_layout Section
2187 Table hostmemory
2188 \end_layout
2190 \begin_layout Standard
2191 Host memory handling (extra memory saved to savestates).
2192  Host memory starts empty.
2193 \end_layout
2195 \begin_layout Itemize
2196 Reads out of range return false.
2197 \end_layout
2199 \begin_layout Itemize
2200 Writes out of range extend the memory.
2201 \end_layout
2203 \begin_layout Subsection
2204 hostmemory.read: Read byte from host memory
2205 \end_layout
2207 \begin_layout Itemize
2208 Syntax: number hostmemory.read(number address)
2209 \end_layout
2211 \begin_layout Standard
2212 Reads byte from hostmemory slot address <address>.
2213 \end_layout
2215 \begin_layout Subsection
2216 hostmemory.write: Write byte to host memory
2217 \end_layout
2219 \begin_layout Itemize
2220 Syntax: none hostmemory.write(number address, number value)
2221 \end_layout
2223 \begin_layout Standard
2224 Writes hostmemory slot with value <value> 0-255.
2225 \end_layout
2227 \begin_layout Subsection
2228 hostmemory.read{,s}{byte,{,d,q}word}: Read from host memory
2229 \end_layout
2231 \begin_layout Itemize
2232 Syntax: number hostmemory.readbyte(number address)
2233 \end_layout
2235 \begin_layout Itemize
2236 Syntax: number hostmemory.readsbyte(number address)
2237 \end_layout
2239 \begin_layout Itemize
2240 Syntax: number hostmemory.readword(number address)
2241 \end_layout
2243 \begin_layout Itemize
2244 Syntax: number hostmemory.readsword(number address)
2245 \end_layout
2247 \begin_layout Itemize
2248 Syntax: number hostmemory.readdword(number address)
2249 \end_layout
2251 \begin_layout Itemize
2252 Syntax: number hostmemory.readsdword(number address)
2253 \end_layout
2255 \begin_layout Itemize
2256 Syntax: number hostmemory.readqword(number address)
2257 \end_layout
2259 \begin_layout Itemize
2260 Syntax: number hostmemory.readsqword(number address)
2261 \end_layout
2263 \begin_layout Standard
2264 Read elements (little-endian) from given address <address>.
2265 \end_layout
2267 \begin_layout Itemize
2268 byte is 1 element
2269 \end_layout
2271 \begin_layout Itemize
2272 word is 2 elements
2273 \end_layout
2275 \begin_layout Itemize
2276 dword is 4 elements
2277 \end_layout
2279 \begin_layout Itemize
2280 qword is 8 elements.
2281 \end_layout
2283 \begin_layout Itemize
2284 The 's' variants do signed read.
2285 \end_layout
2287 \begin_layout Subsection
2288 hostmemory.write{,s}{byte,{,d,q}word}: Write to host memory
2289 \end_layout
2291 \begin_layout Itemize
2292 Syntax: number hostmemory.writebyte(number address, number value)
2293 \end_layout
2295 \begin_layout Itemize
2296 Syntax: number hostmemory.writesbyte(number address, number value)
2297 \end_layout
2299 \begin_layout Itemize
2300 Syntax: number hostmemory.writeword(number address, number value)
2301 \end_layout
2303 \begin_layout Itemize
2304 Syntax: number hostmemory.writesword(number address, number value)
2305 \end_layout
2307 \begin_layout Itemize
2308 Syntax: number hostmemory.writedword(number address, number value)
2309 \end_layout
2311 \begin_layout Itemize
2312 Syntax: number hostmemory.writesdword(number address, number value)
2313 \end_layout
2315 \begin_layout Itemize
2316 Syntax: number hostmemory.writeqword(number address, number value)
2317 \end_layout
2319 \begin_layout Itemize
2320 Syntax: number hostmemory.writesqword(number address, number value)
2321 \end_layout
2323 \begin_layout Standard
2324 Write value <value> to elements (little-endian) starting from given address
2325  <address>.
2326 \end_layout
2328 \begin_layout Itemize
2329 byte is 1 element
2330 \end_layout
2332 \begin_layout Itemize
2333 word is 2 elements
2334 \end_layout
2336 \begin_layout Itemize
2337 dword is 4 elements
2338 \end_layout
2340 \begin_layout Itemize
2341 qword is 8 elements.
2342 \end_layout
2344 \begin_layout Itemize
2345 The 's' variants do signed write.
2346 \end_layout
2348 \begin_layout Standard
2349 \begin_inset Newpage pagebreak
2350 \end_inset
2353 \end_layout
2355 \begin_layout Section
2356 Table movie
2357 \end_layout
2359 \begin_layout Standard
2360 Movie handling
2361 \end_layout
2363 \begin_layout Subsection
2364 movie.currentframe: Get current frame number
2365 \end_layout
2367 \begin_layout Itemize
2368 Syntax: number movie.currentframe()
2369 \end_layout
2371 \begin_layout Standard
2372 Return number of current frame.
2373 \end_layout
2375 \begin_layout Subsection
2376 movie.framecount: Get move frame count
2377 \end_layout
2379 \begin_layout Itemize
2380 Syntax: number movie.framecount()
2381 \end_layout
2383 \begin_layout Standard
2384 Return number of frames in movie.
2385 \end_layout
2387 \begin_layout Subsection
2388 movie.readonly: Is in readonly mode?
2389 \end_layout
2391 \begin_layout Itemize
2392 Syntax: boolean movie.readonly()
2393 \end_layout
2395 \begin_layout Standard
2396 Return true if in readonly mode, false if in readwrite.
2397 \end_layout
2399 \begin_layout Subsection
2400 movie.rerecords: Movie rerecord count
2401 \end_layout
2403 \begin_layout Itemize
2404 Syntax: number movie.rerecords()
2405 \end_layout
2407 \begin_layout Standard
2408 Returns the current value of rerecord count.
2409 \end_layout
2411 \begin_layout Subsection
2412 movie.set_readwrite: Set read-write mode.
2413 \end_layout
2415 \begin_layout Itemize
2416 Syntax: none movie.set_readwrite()
2417 \end_layout
2419 \begin_layout Standard
2420 Set readwrite mode (does not cause on_readwrite callback).
2421 \end_layout
2423 \begin_layout Subsection
2424 movie.frame_subframes: Count subframes in frame
2425 \end_layout
2427 \begin_layout Itemize
2428 Syntax: number movie.frame_subframes(number frame)
2429 \end_layout
2431 \begin_layout Standard
2432 Count number of subframes in specified frame <frame> (frame numbers are
2433  1-based) and return that.
2434 \end_layout
2436 \begin_layout Subsection
2437 movie.read_subframes: Read subframe data (deprecated)
2438 \end_layout
2440 \begin_layout Itemize
2441 Syntax: table movie.read_subframes(number frame, number subframe)
2442 \end_layout
2444 \begin_layout Standard
2445 Read specifed subframe in specified frame and return data as array.
2446 \end_layout
2448 \begin_layout Subsection
2449 movie.read_rtc: Read current RTC time
2450 \end_layout
2452 \begin_layout Itemize
2453 Syntax: (number, number) movie.read_rtc()
2454 \end_layout
2456 \begin_layout Standard
2457 Returns the current value of the RTC as a pair (second, subsecond).
2458 \end_layout
2460 \begin_layout Subsection
2461 movie.unsafe_rewind: Fast movie rewind to saved state
2462 \end_layout
2464 \begin_layout Itemize
2465 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
2466 \end_layout
2468 \begin_layout Standard
2469 Start setting point for unsafe rewind or jump to point of unsafe rewind.
2470 \end_layout
2472 \begin_layout Itemize
2473 If called without argument, causes emulator to start process of setting
2474  unsafe rewind point.
2475  When this has finished, callback on_set_rewind occurs, passing the rewind
2476  state to lua script.
2477 \end_layout
2479 \begin_layout Itemize
2480 If called with argument, causes emulator rewind to passed rewind point as
2481  soon as possible.
2482  Readwrite mode is implicitly activated.
2483 \end_layout
2485 \begin_layout Standard
2486 The following warnings apply to unsafe rewinding:
2487 \end_layout
2489 \begin_layout Itemize
2490 There are no safety checks against misuse (that's what 
2491 \begin_inset Quotes eld
2492 \end_inset
2494 unsafe
2495 \begin_inset Quotes erd
2496 \end_inset
2498  comes from)!
2499 \end_layout
2501 \begin_layout Itemize
2502 Only call rewind from timeline rewind point was set from.
2503 \end_layout
2505 \begin_layout Itemize
2506 Only call rewind from after the rewind point was set.
2507 \end_layout
2509 \begin_layout Subsection
2510 movie.to_rewind: Load savestate as rewind point
2511 \end_layout
2513 \begin_layout Itemize
2514 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
2515 \end_layout
2517 \begin_layout Standard
2518 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
2519  corresponding to it.
2520 \end_layout
2522 \begin_layout Itemize
2523 Note: This operation does not take emulated time.
2524 \end_layout
2526 \begin_layout Subsection
2527 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
2528 \end_layout
2530 \begin_layout Itemize
2531 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
2532 \end_layout
2534 \begin_layout Itemize
2535 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
2536 \end_layout
2538 \begin_layout Standard
2539 Copies specified movie <movie>/current object (if none or nil, the active
2540  movie) as new movie object.
2541 \end_layout
2543 \begin_layout Subsection
2544 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
2545 \end_layout
2547 \begin_layout Itemize
2548 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
2549 \end_layout
2551 \begin_layout Itemize
2552 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
2553 \end_layout
2555 \begin_layout Standard
2556 Get INPUTFRAME object corresponding to specified frame in specified movie.
2557 \end_layout
2559 \begin_layout Subsection
2560 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
2561 \end_layout
2563 \begin_layout Itemize
2564 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
2565  data)
2566 \end_layout
2568 \begin_layout Itemize
2569 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
2570 \end_layout
2572 \begin_layout Standard
2573 Set data in specified frame.
2574 \end_layout
2576 \begin_layout Itemize
2577 Note: Past can't be edited in active movie.
2578 \end_layout
2580 \begin_layout Subsection
2581 movie.get_size/INPUTMOVIE::get_size: Get size of movie
2582 \end_layout
2584 \begin_layout Itemize
2585 Syntax: integer movie.get_size([INPUTMOVIE movie])
2586 \end_layout
2588 \begin_layout Itemize
2589 Syntax: integer INPUTMOVIE::get_size()
2590 \end_layout
2592 \begin_layout Standard
2593 Return number of subframes in specified movie.
2594 \end_layout
2596 \begin_layout Subsection
2597 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
2598 \end_layout
2600 \begin_layout Itemize
2601 Syntax: number movie.count_frames([INPUTMOVIE movie])
2602 \end_layout
2604 \begin_layout Itemize
2605 Syntax: number INPUTMOVIE::count_frames()
2606 \end_layout
2608 \begin_layout Standard
2609 Return number of frames in movie.
2610 \end_layout
2612 \begin_layout Subsection
2613 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
2614 \end_layout
2616 \begin_layout Itemize
2617 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
2618 \end_layout
2620 \begin_layout Itemize
2621 Syntax: number INPUTMOVIE::find_frame(number frame)
2622 \end_layout
2624 \begin_layout Standard
2625 Returns starting subframe of given frame (frame numbers are 1-based).
2626  Returns -1 if frame number is bad.
2627 \end_layout
2629 \begin_layout Subsection
2630 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
2631 \end_layout
2633 \begin_layout Itemize
2634 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
2635 \end_layout
2637 \begin_layout Itemize
2638 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
2639 \end_layout
2641 \begin_layout Standard
2642 Return blank INPUTFRAME with frame type from specified movie.
2643 \end_layout
2645 \begin_layout Subsection
2646 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
2647 \end_layout
2649 \begin_layout Itemize
2650 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
2651 \end_layout
2653 \begin_layout Itemize
2654 Syntax: none INPUTMOVIE::append_frames(number frames)
2655 \end_layout
2657 \begin_layout Standard
2658 Append specified number <frames> of frames.
2659 \end_layout
2661 \begin_layout Subsection
2662 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
2663 \end_layout
2665 \begin_layout Itemize
2666 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
2667 \end_layout
2669 \begin_layout Itemize
2670 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
2671 \end_layout
2673 \begin_layout Standard
2674 Append specified frame <frame>.
2675  Past of current movie can't be edited.
2676 \end_layout
2678 \begin_layout Subsection
2679 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
2680 \end_layout
2682 \begin_layout Itemize
2683 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
2684 \end_layout
2686 \begin_layout Itemize
2687 Syntax: none INPUTMOVIE::truncate(number frames)
2688 \end_layout
2690 \begin_layout Standard
2691 Truncate the specified movie to specified number of frames.
2692 \end_layout
2694 \begin_layout Subsection
2695 movie.edit/INPUTMOVIE::edit: Edit a movie
2696 \end_layout
2698 \begin_layout Itemize
2699 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
2700  controller, number control, number/bool value)
2701 \end_layout
2703 \begin_layout Itemize
2704 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
2705  number control, number/bool value)
2706 \end_layout
2708 \begin_layout Standard
2709 Change specified control in specified frame in specified movie.
2710  Past can't be edited in active movie.
2711 \end_layout
2713 \begin_layout Subsection
2714 movie.copy_frames2: Copy frames between movies
2715 \end_layout
2717 \begin_layout Itemize
2718 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
2719  srcmov,] number src, number count)
2720 \end_layout
2722 \begin_layout Standard
2723 Copy specified number of frames between two movies.
2724  The copy proceeeds in forward direction.
2725 \end_layout
2727 \begin_layout Subsection
2728 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
2729 \end_layout
2731 \begin_layout Itemize
2732 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
2733  number count, bool backwards)
2734 \end_layout
2736 \begin_layout Itemize
2737 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
2738  bool backwards)
2739 \end_layout
2741 \begin_layout Standard
2742 Copy specified number of frames from one point in movie to another.
2743  If backwards is true, the copy will be done backwards.
2744 \end_layout
2746 \begin_layout Subsection
2747 movie.serialize/INPUTMOVIE::serialize: Serialize movie
2748 \end_layout
2750 \begin_layout Itemize
2751 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
2752 \end_layout
2754 \begin_layout Itemize
2755 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
2756 \end_layout
2758 \begin_layout Standard
2759 Serialize given movie into file.
2760  If binary is true, binary format (more compact and much faster) is used.
2761 \end_layout
2763 \begin_layout Subsection
2764 movie.unserialize: Unserialize movie
2765 \end_layout
2767 \begin_layout Itemize
2768 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
2769  bool binary)
2770 \end_layout
2772 \begin_layout Standard
2773 Unserialize movie from file.
2774  The given frame is used as template to decide the frame type.
2775  If binary is true, binary format is decoded (much faster).
2776 \end_layout
2778 \begin_layout Subsection
2779 movie.current_first_subframe: Return first subframe in current frame
2780 \end_layout
2782 \begin_layout Itemize
2783 Syntax: number movie.current_first_subframe()
2784 \end_layout
2786 \begin_layout Standard
2787 Returns first subframe in current frame.
2788 \end_layout
2790 \begin_layout Subsection
2791 movie.pollcounter: Return poll counter for speified control
2792 \end_layout
2794 \begin_layout Itemize
2795 Syntax: number movie.pollcounter(number port, number controller, number control)
2796 \end_layout
2798 \begin_layout Standard
2799 Returns number of times the specified control has been polled this frame.
2800 \end_layout
2802 \begin_layout Subsection
2803 INPUTFRAME::get_button: Get button
2804 \end_layout
2806 \begin_layout Itemize
2807 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
2808  control)
2809 \end_layout
2811 \begin_layout Standard
2812 Returns state of given button as boolean.
2813 \end_layout
2815 \begin_layout Subsection
2816 INPUTFRAME::get_axis: Get axis
2817 \end_layout
2819 \begin_layout Itemize
2820 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
2821  control)
2822 \end_layout
2824 \begin_layout Standard
2825 Returns state of given axis as number.
2826 \end_layout
2828 \begin_layout Subsection
2829 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
2830 \end_layout
2832 \begin_layout Itemize
2833 Syntax: none INPUTFRAME::set_button(number port, number controller, number
2834  control, number/bool value)
2835 \end_layout
2837 \begin_layout Itemize
2838 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
2839  control)
2840 \end_layout
2842 \begin_layout Standard
2843 Set the given button/axis to given value.
2844 \end_layout
2846 \begin_layout Subsection
2847 INPUTFRAME::serialize: Serialize a frame
2848 \end_layout
2850 \begin_layout Itemize
2851 Syntax: string INPUTFRAME::serialize()
2852 \end_layout
2854 \begin_layout Standard
2855 Return string representation of frame.
2856 \end_layout
2858 \begin_layout Subsection
2859 INPUTFRAME::unserialize: Unserialize a frame
2860 \end_layout
2862 \begin_layout Itemize
2863 Syntax: none INPUTFRAME::unserialize(string data)
2864 \end_layout
2866 \begin_layout Standard
2867 Set current frame from given data.
2868 \end_layout
2870 \begin_layout Subsection
2871 INPUTFRAME::get_stride: Get movie stride
2872 \end_layout
2874 \begin_layout Itemize
2875 Syntax: number INPUTFRAME::get_stride()
2876 \end_layout
2878 \begin_layout Standard
2879 Return number of bytes needed to store the input frame.
2880  Mainly useful for some debugging.
2881 \end_layout
2883 \begin_layout Standard
2884 \begin_inset Newpage pagebreak
2885 \end_inset
2888 \end_layout
2890 \begin_layout Section
2891 Table settings
2892 \end_layout
2894 \begin_layout Standard
2895 Routines for settings manipulation
2896 \end_layout
2898 \begin_layout Subsection
2899 settings.get: Get value of setting
2900 \end_layout
2902 \begin_layout Itemize
2903 Syntax: string settings.get(string name)
2904 \end_layout
2906 \begin_layout Standard
2907 Get value of setting <name>.
2908  If setting value can't be obtained, returns (nil, error message).
2909 \end_layout
2911 \begin_layout Subsection
2912 settings.set: Set value of setting
2913 \end_layout
2915 \begin_layout Itemize
2916 Syntax: none settings.set(string name, string value)
2917 \end_layout
2919 \begin_layout Standard
2920 Set value <value> of setting <name>.
2921  If setting can't be set, returns (nil, error message).
2922 \end_layout
2924 \begin_layout Standard
2925 \begin_inset Newpage pagebreak
2926 \end_inset
2929 \end_layout
2931 \begin_layout Section
2932 Table memory
2933 \end_layout
2935 \begin_layout Standard
2936 Contains various functions for managing memory
2937 \end_layout
2939 \begin_layout Subsection
2940 memory.vma_count: Count number of VMAs.
2941 \end_layout
2943 \begin_layout Itemize
2944 Syntax: number memory.vma_count()
2945 \end_layout
2947 \begin_layout Standard
2948 Returns the number of VMAs
2949 \end_layout
2951 \begin_layout Subsection
2952 memory.read_vma: Lookup VMA info by index
2953 \end_layout
2955 \begin_layout Itemize
2956 Syntax: string memory.read_vma(number index)
2957 \end_layout
2959 \begin_layout Standard
2960 Reads the specified VMA (indices start from zero).
2961  Trying to read invalid VMA gives nil.
2962  The read VMA is table with the following fields:
2963 \end_layout
2965 \begin_layout Itemize
2966 region_name (string): The readable name of the VMA
2967 \end_layout
2969 \begin_layout Itemize
2970 baseaddr (number): Base address of the VMA
2971 \end_layout
2973 \begin_layout Itemize
2974 lastaddr (number): Last address in the VMA.
2975 \end_layout
2977 \begin_layout Itemize
2978 size (number): The size of VMA in bytes.
2979 \end_layout
2981 \begin_layout Itemize
2982 readonly (boolean): True of the VMA corresponds to ROM.
2983 \end_layout
2985 \begin_layout Itemize
2986 iospace (boolean): True if the VMA is I/O space.
2987 \end_layout
2989 \begin_layout Itemize
2990 native_endian (boolean): True if the VMA has native endian as opposed to
2991  little endian.
2992 \end_layout
2994 \begin_layout Subsection
2995 memory.find_vma: Find VMA info by address
2996 \end_layout
2998 \begin_layout Itemize
2999 Syntax: table memory.find_vma(number address)
3000 \end_layout
3002 \begin_layout Standard
3003 Finds the VMA containing specified address.
3004  Returns table in the same format as read_vma or nil if not found.
3005 \end_layout
3007 \begin_layout Subsection
3008 memory.read{,s}{byte,{,d,q}word}: Write memory
3009 \end_layout
3011 \begin_layout Itemize
3012 Syntax: none memory.readbyte([string vma, ]number address)
3013 \end_layout
3015 \begin_layout Itemize
3016 Syntax: none memory.readword([string vma, ]number address)
3017 \end_layout
3019 \begin_layout Itemize
3020 Syntax: none memory.readdword([string vma, ]number address)
3021 \end_layout
3023 \begin_layout Itemize
3024 Syntax: none memory.readqword([string vma, ]number address)
3025 \end_layout
3027 \begin_layout Itemize
3028 Syntax: none memory.readsbyte([string vma, ]number address)
3029 \end_layout
3031 \begin_layout Itemize
3032 Syntax: none memory.readsword([string vma, ]number address)
3033 \end_layout
3035 \begin_layout Itemize
3036 Syntax: none memory.readsdword([string vma, ]number address)
3037 \end_layout
3039 \begin_layout Itemize
3040 Syntax: none memory.readsqword([string vma, ]number address)
3041 \end_layout
3043 \begin_layout Standard
3044 Reads the specified address <ddress> (if 's' variant is used, do undergo
3045  2's complement).
3046 \end_layout
3048 \begin_layout Subsection
3049 memory.write{byte,{,d,q}word}: Write memory
3050 \end_layout
3052 \begin_layout Itemize
3053 Syntax: none memory.writebyte([string vma, ]number address, number value)
3054 \end_layout
3056 \begin_layout Itemize
3057 Syntax: none memory.writeword([string vma, ]number address, number value)
3058 \end_layout
3060 \begin_layout Itemize
3061 Syntax: none memory.writedword([string vma, ]number address, number value)
3062 \end_layout
3064 \begin_layout Itemize
3065 Syntax: none memory.writeqword([string vma, ]number address, number value)
3066 \end_layout
3068 \begin_layout Standard
3069 Writes the specified value <value> (negative values undergo 2's complement)
3070  to specified address <address>.
3071 \end_layout
3073 \begin_layout Subsection
3074 memory.map{,s}{byte,{,d,q}word}: Map an array
3075 \end_layout
3077 \begin_layout Itemize
3078 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
3079 \end_layout
3081 \begin_layout Standard
3082 Returns a table mapping specified memory aperture for read/write.
3083  If parameters are omitted, entiere map space is the aperture.
3084 \end_layout
3086 \begin_layout Itemize
3087 Type may be one of: byte, sbyte, word, sword, dword, sdword, qword or sqword.
3088 \end_layout
3090 \begin_layout Subsection
3091 memory.hash_region: Hash region of memory
3092 \end_layout
3094 \begin_layout Itemize
3095 Syntax: string memory.hash_region([string vma, ]number base, number size)
3096 \end_layout
3098 \begin_layout Standard
3099 Hash specified number of bytes starting from specified address and return
3100  the SHA-256.
3101 \end_layout
3103 \begin_layout Subsection
3104 memory.hash_state: Hash system state
3105 \end_layout
3107 \begin_layout Itemize
3108 Syntax: string memory.hash_state()
3109 \end_layout
3111 \begin_layout Standard
3112 Hash the current system state.
3113  Mainly useful for debugging savestates.
3114 \end_layout
3116 \begin_layout Subsection
3117 memory.readregion: Read region of memory
3118 \end_layout
3120 \begin_layout Itemize
3121 Syntax: table memory.readregion([string vma, ]number base, number size)
3122 \end_layout
3124 \begin_layout Standard
3125 Read a region of memory.
3126 \end_layout
3128 \begin_layout Itemize
3129 Warning: If the region crosses VMA boundary, the results are undefined.
3130 \end_layout
3132 \begin_layout Subsection
3133 memory.writeregion: Write region of memory
3134 \end_layout
3136 \begin_layout Itemize
3137 Syntax: none memory.writeregion([string vma, ]number base, number size, table
3138  data)
3139 \end_layout
3141 \begin_layout Standard
3142 Write a region of memory.
3143 \end_layout
3145 \begin_layout Itemize
3146 Warning: If the region crosses VMA boundary, the results are undefined.
3147 \end_layout
3149 \begin_layout Subsection
3150 memory.map_structure: Create mmap structure
3151 \end_layout
3153 \begin_layout Itemize
3154 syntax: MMAP_STRUCT memory.map_structure()
3155 \end_layout
3157 \begin_layout Standard
3158 Returns a new mapping structure (MMAP_STRUCT)
3159 \end_layout
3161 \begin_layout Subsection
3162 MMAP_STRUCT(): Bind key in mmap structure
3163 \end_layout
3165 \begin_layout Itemize
3166 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
3167  type)
3168 \end_layout
3170 \begin_layout Standard
3171 Bind key <key> in mmap structure to specified address <address> with specified
3172  type <type>.
3173 \end_layout
3175 \begin_layout Itemize
3176 Type may be one of: byte, sbyte, word, sword, dword, sdword, qword or sqword.
3177 \end_layout
3179 \begin_layout Subsection
3180 memory.read_expr: Evaluate memory watch expression
3181 \end_layout
3183 \begin_layout Itemize
3184 Syntax: string memory.read_expr(string expr)
3185 \end_layout
3187 \begin_layout Standard
3188 Evaluate specified watch expression and return result
3189 \end_layout
3191 \begin_layout Subsection
3192 memory.action: Run core action
3193 \end_layout
3195 \begin_layout Itemize
3196 memory.action(string action, [<params>])
3197 \end_layout
3199 \begin_layout Standard
3200 Run core action.
3201  The different models expect parameters as:
3202 \end_layout
3204 \begin_layout Itemize
3205 string: String
3206 \end_layout
3208 \begin_layout Itemize
3209 numeric: numeric
3210 \end_layout
3212 \begin_layout Itemize
3213 enumeration: String
3214 \end_layout
3216 \begin_layout Itemize
3217 boolean: String
3218 \end_layout
3220 \begin_layout Itemize
3221 toggle: None.
3222 \end_layout
3224 \begin_layout Subsection
3225 memory.get_lag_flag: Get lag flag
3226 \end_layout
3228 \begin_layout Itemize
3229 Syntax: boolean memory.get_lag_flag()
3230 \end_layout
3232 \begin_layout Standard
3233 Get the value of core lag flag.
3234  True if this frame has been lag so far, false if poll has been detected.
3235 \end_layout
3237 \begin_layout Subsection
3238 memory.set_lag_flag: Set lag flag
3239 \end_layout
3241 \begin_layout Itemize
3242 Syntax: none memory.set_lag_flag(boolean flag)
3243 \end_layout
3245 \begin_layout Standard
3246 Set the value of core lag flag.
3247  This flag automatically gets cleared if poll is detected, but can be forcibly
3248  set or cleared if game so requires.
3249 \end_layout
3251 \begin_layout Itemize
3252 Should only be used in on_frame_emulated callback.
3253 \end_layout
3255 \begin_layout Itemize
3256 Setting or clearing this affects the emulator lag counter.
3257 \end_layout
3259 \begin_layout Standard
3260 \begin_inset Newpage pagebreak
3261 \end_inset
3264 \end_layout
3266 \begin_layout Section
3267 Table memory2
3268 \end_layout
3270 \begin_layout Standard
3271 Contains newer memory functions.
3272 \end_layout
3274 \begin_layout Subsection
3275 memory2(): Get all VMA names.
3276 \end_layout
3278 \begin_layout Itemize
3279 Syntax: table memory2()
3280 \end_layout
3282 \begin_layout Standard
3283 Returns array of all valid VMA names.
3284 \end_layout
3286 \begin_layout Subsection
3287 memory2.<vma>:info: Get VMA info
3288 \end_layout
3290 \begin_layout Itemize
3291 Syntax: table memory2.<vma>:info()
3292 \end_layout
3294 \begin_layout Standard
3295 Return table describing given VMA.
3296  Includes fields address, size, last, readonly, special and endian.
3297 \end_layout
3299 \begin_layout Subsection
3300 memory2.<vma>:<op>: Read/Write memory
3301 \end_layout
3303 \begin_layout Itemize
3304 Syntax: none memory2.<vma>:<op>(number offset, number value)
3305 \end_layout
3307 \begin_layout Itemize
3308 Syntax: number memory2.<vma>:<op>(number offset)
3309 \end_layout
3311 \begin_layout Standard
3312 Read/Write value from/to given VMA <vma> at given offset <offset> (must
3313  be in-range).
3314  The value written is <value>.
3315  <Op> is of form: [i][s]<type>, where:
3316 \end_layout
3318 \begin_layout Itemize
3319 <type> is one of 'byte', 'word', 'dword', 'qword'.
3320 \end_layout
3322 \begin_layout Itemize
3323 'i' signifies that the value is treated as opposite-to-normal endianess,
3324 \end_layout
3326 \begin_layout Itemize
3327 's' signifies that value is treated as signed.
3328 \end_layout
3330 \begin_layout Standard
3331 \begin_inset Newpage pagebreak
3332 \end_inset
3335 \end_layout
3337 \begin_layout Section
3338 Table callback
3339 \end_layout
3341 \begin_layout Standard
3342 Various callback-related functions.
3343 \end_layout
3345 \begin_layout Subsection
3346 \begin_inset CommandInset label
3347 LatexCommand label
3348 name "sub:callback.register:-Register-a"
3350 \end_inset
3352 callback.register: Register a callback
3353 \end_layout
3355 \begin_layout Itemize
3356 Syntax: function callback.register(string cbname, function cbfun);
3357 \end_layout
3359 \begin_layout Standard
3360 Instruct function <cbfun> to be added to list of callbacks to call on event
3361  <cbname> (See section 
3362 \begin_inset CommandInset ref
3363 LatexCommand ref
3364 reference "sec:Callbacks"
3366 \end_inset
3369  The callback name does not have the 'on_' prefix (e.g.
3371 \begin_inset Quotes eld
3372 \end_inset
3374 paint
3375 \begin_inset Quotes erd
3376 \end_inset
3379  Returns <cbfun>.
3380 \end_layout
3382 \begin_layout Subsection
3383 \begin_inset CommandInset label
3384 LatexCommand label
3385 name "sub:callback.unregister:-Unregister-"
3387 \end_inset
3389 callback.unregister: Unregister a callback
3390 \end_layout
3392 \begin_layout Itemize
3393 Syntax: function callback.unregister(string cbname, function cbfun);
3394 \end_layout
3396 \begin_layout Standard
3397 Instruct function <cbfun> to be removed from list of callbacks to call on
3398  event <cbname>.
3399 \end_layout
3401 \begin_layout Subsection
3402 callback.<cbname>:register: Register callback
3403 \end_layout
3405 \begin_layout Itemize
3406 Syntax: function callback.<cbname>:register(function cbfun)
3407 \end_layout
3409 \begin_layout Standard
3410 Synonym for callback.register (section 
3411 \begin_inset CommandInset ref
3412 LatexCommand ref
3413 reference "sub:callback.register:-Register-a"
3415 \end_inset
3417 ), albeit with callback name specified differently.
3418 \end_layout
3420 \begin_layout Subsection
3421 callback.<cbname>:unregister: Register callback
3422 \end_layout
3424 \begin_layout Itemize
3425 Syntax: function callback.<cbname>:unregister(function cbfun)
3426 \end_layout
3428 \begin_layout Standard
3429 Synonym for callback.unregister (section 
3430 \begin_inset CommandInset ref
3431 LatexCommand ref
3432 reference "sub:callback.unregister:-Unregister-"
3434 \end_inset
3436 ), albeit with callback name specified differently.
3437 \end_layout
3439 \begin_layout Section
3440 Table _SYSTEM
3441 \end_layout
3443 \begin_layout Standard
3444 Contains copy of global variables from time of Lua initialization.
3445  Non-writeable.
3446 \end_layout
3448 \begin_layout Standard
3449 \begin_inset Newpage pagebreak
3450 \end_inset
3453 \end_layout
3455 \begin_layout Section
3456 \begin_inset CommandInset label
3457 LatexCommand label
3458 name "sec:Callbacks"
3460 \end_inset
3462 Callbacks
3463 \end_layout
3465 \begin_layout Standard
3466 Various callbacks to Lua that can occur.
3467 \end_layout
3469 \begin_layout Subsection
3470 on_paint: Screen is being painted
3471 \end_layout
3473 \begin_layout Itemize
3474 Callback: on_paint(bool not_synth)
3475 \end_layout
3477 \begin_layout Standard
3478 Called when screen is being painted.
3479  Any gui.* calls requiring graphic context draw on the screen.
3480 \end_layout
3482 \begin_layout Itemize
3483 not_synth is true if this hook is being called in response to received frame,
3484  false otherwise.
3485 \end_layout
3487 \begin_layout Subsection
3488 on_video: Dumped video frame is being painted
3489 \end_layout
3491 \begin_layout Itemize
3492 Callback: on_video()
3493 \end_layout
3495 \begin_layout Standard
3496 Called when video dump frame is being painted.
3497  Any gui.* calls requiring graphic context draw on the video.
3498 \end_layout
3500 \begin_layout Subsection
3501 on_frame_emulated: Frame emulation complete
3502 \end_layout
3504 \begin_layout Itemize
3505 Callback: on_frame_emulated()
3506 \end_layout
3508 \begin_layout Standard
3509 Called when emulating frame has completed and on_paint()/on_video() calls
3510  are about to be issued.
3511 \end_layout
3513 \begin_layout Subsection
3514 on_frame: Frame emulation starting.
3515 \end_layout
3517 \begin_layout Itemize
3518 Callback: on_frame()
3519 \end_layout
3521 \begin_layout Standard
3522 Called on each starting whole frame.
3523 \end_layout
3525 \begin_layout Subsection
3526 on_startup: Emulator startup complete
3527 \end_layout
3529 \begin_layout Itemize
3530 Callback: on_startup()
3531 \end_layout
3533 \begin_layout Standard
3534 Called when the emulator is starting (lsnes.rc and --run files has been run).
3535 \end_layout
3537 \begin_layout Subsection
3538 on_rewind: Movie rewound to beginning
3539 \end_layout
3541 \begin_layout Itemize
3542 Callback: on_rewind()
3543 \end_layout
3545 \begin_layout Standard
3546 Called when rewind movie to beginning has completed.
3547 \end_layout
3549 \begin_layout Subsection
3550 on_pre_load: Load operation is about to start
3551 \end_layout
3553 \begin_layout Itemize
3554 Callback: on_pre_load(string name)
3555 \end_layout
3557 \begin_layout Standard
3558 Called just before savestate/movie load occurs (note: loads are always delayed,
3559  so this occurs even when load was initiated by lua).
3560 \end_layout
3562 \begin_layout Subsection
3563 on_err_Load: Load failed
3564 \end_layout
3566 \begin_layout Itemize
3567 Callback: on_err_load(string name)
3568 \end_layout
3570 \begin_layout Standard
3571 Called if loadstate goes wrong.
3572 \end_layout
3574 \begin_layout Subsection
3575 on_post_load: Load completed
3576 \end_layout
3578 \begin_layout Itemize
3579 Callback: on_post_load(string name, boolean was_savestate)
3580 \end_layout
3582 \begin_layout Standard
3583 Called on successful loadstate.
3584  was_savestate gives if this was a savestate or a movie.
3585 \end_layout
3587 \begin_layout Subsection
3588 on_pre_save: Save operation is about to start
3589 \end_layout
3591 \begin_layout Itemize
3592 Callback: on_pre_save(string name, boolean is_savestate)
3593 \end_layout
3595 \begin_layout Standard
3596 Called just before savestate save occurs (note: movie saves are synchronous
3597  and won't trigger these callbacks if called from Lua).
3598 \end_layout
3600 \begin_layout Subsection
3601 on_err_save: Save failed
3602 \end_layout
3604 \begin_layout Itemize
3605 Callback: on_err_save(string name)
3606 \end_layout
3608 \begin_layout Standard
3609 Called if savestate goes wrong.
3610 \end_layout
3612 \begin_layout Subsection
3613 on_post_save: Save completed
3614 \end_layout
3616 \begin_layout Itemize
3617 Callback: on_post_save(string name, boolean is_savestate)
3618 \end_layout
3620 \begin_layout Standard
3621 Called on successful savaestate.
3622  is_savestate gives if this was a savestate or a movie.
3623 \end_layout
3625 \begin_layout Subsection
3626 on_quit: Emulator is shutting down
3627 \end_layout
3629 \begin_layout Itemize
3630 Callback: on_quit()
3631 \end_layout
3633 \begin_layout Standard
3634 Called when emulator is shutting down.
3635 \end_layout
3637 \begin_layout Subsection
3638 on_input: Polling for input
3639 \end_layout
3641 \begin_layout Standard
3642 Called when emulator is just sending input to bsnes core.
3643  Warning: This is called even in readonly mode, but the results are ignored.
3644 \end_layout
3646 \begin_layout Subsection
3647 on_reset: System has been reset
3648 \end_layout
3650 \begin_layout Itemize
3651 Callback: on_reset()
3652 \end_layout
3654 \begin_layout Standard
3655 Called when system is reset.
3656 \end_layout
3658 \begin_layout Subsection
3659 on_readwrite: Entered readwrite mode
3660 \end_layout
3662 \begin_layout Itemize
3663 Callback: on_readwrite()
3664 \end_layout
3666 \begin_layout Standard
3667 Called when moving into readwrite mode as result of 
3668 \begin_inset Quotes eld
3669 \end_inset
3671 set-rwmode
3672 \begin_inset Quotes erd
3673 \end_inset
3675  command (note: moving to rwmode by Lua won't trigger this, as per recursive
3676  entry protection).
3677 \end_layout
3679 \begin_layout Subsection
3680 on_snoop/on_snoop2: Snoop core controller reads
3681 \end_layout
3683 \begin_layout Itemize
3684 Callback: on_snoop(number port, number controller, number index, number
3685  value)
3686 \end_layout
3688 \begin_layout Itemize
3689 Callback: on_snoop2(number port, number controller, number index, number
3690  value)
3691 \end_layout
3693 \begin_layout Standard
3694 Called each time bsnes asks for input.
3695  The value is the final value to be sent to bsnes core (readonly mode, autohold
3696  and autofire have been taken into account).
3697  Might be useful when translating movies to format suitable for console
3698  verification.
3699  Note: There is no way to modify the value to be sent.
3700 \end_layout
3702 \begin_layout Itemize
3703 On_snoop2 is called instead of on_snoop if defined.
3704  Reserves port 0 for system, having first user port be port 1.
3705 \end_layout
3707 \begin_layout Subsection
3708 on_keyhook: Hooked key/axis has been moved
3709 \end_layout
3711 \begin_layout Itemize
3712 Callback: on_keyhook(string keyname, table state)
3713 \end_layout
3715 \begin_layout Standard
3716 Sent when key that has keyhook events requested changes state.
3717  Keyname is name of the key (group) and state is the state (same kind as
3718  table values in input.raw).
3719 \end_layout
3721 \begin_layout Subsection
3722 on_idle: Idle event
3723 \end_layout
3725 \begin_layout Itemize
3726 Callback: on_idle()
3727 \end_layout
3729 \begin_layout Standard
3730 Called when requested by set_idle_timeout(), the timeout has expired and
3731  emulator is waiting.
3732 \end_layout
3734 \begin_layout Subsection
3735 on_timer: Timer event
3736 \end_layout
3738 \begin_layout Itemize
3739 Callback: on_timer()
3740 \end_layout
3742 \begin_layout Standard
3743 Called when requested by set_idle_timeout() and the timeout has expired
3744  (regardless if emulator is waiting).
3745 \end_layout
3747 \begin_layout Subsection
3748 on_set_rewind: Rewind point has been set
3749 \end_layout
3751 \begin_layout Itemize
3752 Callback: on_set_rewind(UNSAFEREWIND r)
3753 \end_layout
3755 \begin_layout Standard
3756 Called when unsafe rewind object has been constructed.
3757 \end_layout
3759 \begin_layout Subsection
3760 on_pre_rewind: Rewind is about to occur
3761 \end_layout
3763 \begin_layout Itemize
3764 Callback: on_pre_rewind() 
3765 \end_layout
3767 \begin_layout Standard
3768 Called just before unsafe rewind is about to occur.
3769 \end_layout
3771 \begin_layout Subsection
3772 on_post_rewind: Rewind has occured
3773 \end_layout
3775 \begin_layout Itemize
3776 Callback: on_post_rewind() 
3777 \end_layout
3779 \begin_layout Standard
3780 Called just after unsafe rewind has occured.
3781 \end_layout
3783 \begin_layout Subsection
3784 on_button: Button has been pressed
3785 \end_layout
3787 \begin_layout Itemize
3788 Callback: on_button(number port, number controller, number index, string
3789  type)
3790 \end_layout
3792 \begin_layout Standard
3793 Called on controller button press, with following parameters:
3794 \end_layout
3796 \begin_layout Itemize
3797 port: Port number (0 is system)
3798 \end_layout
3800 \begin_layout Itemize
3801 controller: Controller within port
3802 \end_layout
3804 \begin_layout Itemize
3805 index: Index of button.
3806 \end_layout
3808 \begin_layout Itemize
3809 type: Type of event, one of:
3810 \end_layout
3812 \begin_deeper
3813 \begin_layout Itemize
3814 \begin_inset Quotes eld
3815 \end_inset
3817 pressed
3818 \begin_inset Quotes erd
3819 \end_inset
3821 : Button was pressed.
3822 \end_layout
3824 \begin_layout Itemize
3825 \begin_inset Quotes eld
3826 \end_inset
3828 released
3829 \begin_inset Quotes erd
3830 \end_inset
3832 : Button was released.
3833 \end_layout
3835 \begin_layout Itemize
3836 \begin_inset Quotes eld
3837 \end_inset
3839 hold
3840 \begin_inset Quotes erd
3841 \end_inset
3843 : Held.
3844 \end_layout
3846 \begin_layout Itemize
3847 \begin_inset Quotes eld
3848 \end_inset
3850 unhold
3851 \begin_inset Quotes erd
3852 \end_inset
3854 : Released from hold.
3855 \end_layout
3857 \begin_layout Itemize
3858 \begin_inset Quotes eld
3859 \end_inset
3861 type
3862 \begin_inset Quotes erd
3863 \end_inset
3865 : Typing input on button.
3866 \end_layout
3868 \begin_layout Itemize
3869 \begin_inset Quotes eld
3870 \end_inset
3872 untype
3873 \begin_inset Quotes erd
3874 \end_inset
3876 : Typing input undone.
3877 \end_layout
3879 \begin_layout Itemize
3880 \begin_inset Quotes eld
3881 \end_inset
3883 autofire <duty> <cycle>
3884 \begin_inset Quotes erd
3885 \end_inset
3887 : Autofire with specifie duty and cycle.
3888 \end_layout
3890 \begin_layout Itemize
3891 \begin_inset Quotes eld
3892 \end_inset
3894 autofire
3895 \begin_inset Quotes erd
3896 \end_inset
3898 : Stop autofire.
3899 \end_layout
3901 \begin_layout Itemize
3902 \begin_inset Quotes eld
3903 \end_inset
3905 analog
3906 \begin_inset Quotes erd
3907 \end_inset
3909 : Analog action on axis.
3910 \end_layout
3912 \end_deeper
3913 \begin_layout Subsection
3914 on_movie_lost: Movie data is about to be lost
3915 \end_layout
3917 \begin_layout Itemize
3918 Callback: on_movie_lost(STRING kind)
3919 \end_layout
3921 \begin_layout Standard
3922 Called just before something would happen that could lose movie data.
3923  Kind can be:
3924 \end_layout
3926 \begin_layout Itemize
3927 readwrite: Switching to readwrite mode.
3928 \end_layout
3930 \begin_layout Itemize
3931 reload: ROM is being reloaded in readwrite mode.
3932 \end_layout
3934 \begin_layout Itemize
3935 load: New movie is being loaded.
3936 \end_layout
3938 \begin_layout Itemize
3939 unsaferewind: Unsafe rewind is happening.
3940 \end_layout
3942 \end_body
3943 \end_document