lsnes rr2-β13
[lsnes.git] / lua.lyx
blobce19dd621bc011791b9b807220eda4141622e491
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  Can print any Lua type at least enough to identify the type and instance.
143 \end_layout
145 \begin_layout Subsection
146 tostringx: Format a value to string
147 \end_layout
149 \begin_layout Itemize
150 Syntax: string tostringx(value val)
151 \end_layout
153 \begin_layout Standard
154 Formats value <val> like print would, and returns the result as a string.
155 \end_layout
157 \begin_layout Subsection
158 exec: Execute lsnes commands
159 \end_layout
161 \begin_layout Itemize
162 Syntax: none exec(string cmd)
163 \end_layout
165 \begin_layout Standard
166 Execute lsnes command <cmd>.
167 \end_layout
169 \begin_layout Subsection
170 utime: Get current time
171 \end_layout
173 \begin_layout Itemize
174 Syntax: (number,number) utime()
175 \end_layout
177 \begin_layout Standard
178 Returns two numbers.
179  First is time since some epoch in seconds, the second is microseconds mod
180  10^6 since that epoch.
181 \end_layout
183 \begin_layout Subsection
184 emulator_ready: Check if emulator has been fully initialized
185 \end_layout
187 \begin_layout Itemize
188 Syntax: boolean emulator_ready()
189 \end_layout
191 \begin_layout Standard
192 Returns true if emulator has finished booting, false if not (on_startup()
193  will be issued later).
194 \end_layout
196 \begin_layout Subsection
197 set_idle_timeout: Run function after timeout when emulator is idle
198 \end_layout
200 \begin_layout Itemize
201 Syntax: none set_idle_timeout(number timeout)
202 \end_layout
204 \begin_layout Standard
205 Set number of microseconds to block idle for.
206  After this timeout has expired, on_idle() will be called once.
207 \end_layout
209 \begin_layout Subsection
210 set_timer_timeout: Run function after timeout.
211 \end_layout
213 \begin_layout Itemize
214 Syntax: none set_timer_timeout(number timeout)
215 \end_layout
217 \begin_layout Standard
218 Set number of microseconds to block timer for.
219  After this timeout has expired, on_timer() will be called once.
220 \end_layout
222 \begin_layout Subsection
223 bus_address: Look up address in system bus.
224 \end_layout
226 \begin_layout Itemize
227 Syntax: none bus_address(number bus_addr)
228 \end_layout
230 \begin_layout Standard
231 Returns virtual address corresponding to specified address on system bus.
232 \end_layout
234 \begin_layout Subsection
235 loopwrapper: Convert loop into callable function
236 \end_layout
238 \begin_layout Itemize
239 Syntax: function loopwrapper(function fun, ...)
240 \end_layout
242 \begin_layout Standard
243 Calls function <fun> with function and specified arguments.
244  The function passed suspends execution until the function returned is called.
245  Handy for linear flow control among multiple invocations of a hook.
246  Example code:
247 \end_layout
249 \begin_layout LyX-Code
250 on_paint = loopwrapper(function(wait)
251 \end_layout
253 \begin_deeper
254 \begin_layout LyX-Code
255 while true do
256 \end_layout
258 \begin_deeper
259 \begin_layout LyX-Code
260 gui.text(0, 0, 
261 \begin_inset Quotes eld
262 \end_inset
264 Test!
265 \begin_inset Quotes erd
266 \end_inset
269 \end_layout
271 \begin_layout LyX-Code
272 wait();
273 \end_layout
275 \end_deeper
276 \begin_layout LyX-Code
278 \end_layout
280 \end_deeper
281 \begin_layout LyX-Code
282 end);
283 \end_layout
285 \begin_layout Subsection
286 list_bindings: List keybindings
287 \end_layout
289 \begin_layout Itemize
290 Syntax: table list_bindings([string cmd])
291 \end_layout
293 \begin_layout Standard
294 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
295  If <cmd> is specified, the table is limited to that command.
296  Also searches for controller keys.
297 \end_layout
299 \begin_layout Subsection
300 get_alias: Get expansion of alias
301 \end_layout
303 \begin_layout Itemize
304 Syntax: string get_alias(string aname)
305 \end_layout
307 \begin_layout Standard
308 Get expansion of given alias <aname>.
309 \end_layout
311 \begin_layout Subsection
312 set_alias: Set expansion of alias
313 \end_layout
315 \begin_layout Itemize
316 Syntax: none set_alias(string aname, string value)
317 \end_layout
319 \begin_layout Standard
320 Set expansion of given alias.
321 \end_layout
323 \begin_layout Subsection
324 create_ibind: Create invese binding
325 \end_layout
327 \begin_layout Itemize
328 Syntax: INVERSEBIND create_ibind(string name, string cmd)
329 \end_layout
331 \begin_layout Standard
332 Return object representing inverse binding with specified name <name> and
333  specified command <cmd>.
334 \end_layout
336 \begin_layout Itemize
337 Note: To create press/release commands, use aliases +foo and -foo .
338 \end_layout
340 \begin_layout Itemize
341 Note: Keep the returned object around.
342 \end_layout
344 \begin_layout Subsection
345 create_command: Create a command
346 \end_layout
348 \begin_layout Itemize
349 Syntax: COMMANDBIND create_commmand(string name, function a)
350 \end_layout
352 \begin_layout Itemize
353 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
354 \end_layout
356 \begin_layout Standard
357 Return object representing a command (pair).
358 \end_layout
360 \begin_layout Itemize
361 If only one function is specied, the command is level-sensitive, <a> is
362  callback.
363 \end_layout
365 \begin_layout Itemize
366 If <b> is function, the function is edge-sensitive, <a> is positive edge
367  callback and <b> is negative edge callback.
368 \end_layout
370 \begin_layout Itemize
371 All callbacks get single argument: The parameters passed.
372 \end_layout
374 \begin_layout Itemize
375 Keep the returned object around.
376 \end_layout
378 \begin_layout Subsection
379 loadfile: Load Lua script
380 \end_layout
382 \begin_layout Itemize
383 Syntax: function loadfile(string filename[, string base])
384 \end_layout
386 \begin_layout Standard
387 Load lua script from <filename>, resolved relative to <base> (if empty,
388  current directory).
389 \end_layout
391 \begin_layout Subsection
392 dofile: Execute Lua script
393 \end_layout
395 \begin_layout Itemize
396 Syntax: function dofile(string filename[, string base])
397 \end_layout
399 \begin_layout Standard
400 Execute lua script from <filename>, resolved relative to <base> (if empty,
401  current directory) and return all return values.
402 \end_layout
404 \begin_layout Subsection
405 open_file: Open a stream
406 \end_layout
408 \begin_layout Itemize
409 Syntax: FILEREADER open_file(string filename[, string base])
410 \end_layout
412 \begin_layout Standard
413 Open file <filename>, resolved relative to <base> (if empty, current directory)
414  and return a handle.
415 \end_layout
417 \begin_layout Subsection
418 FILEREADER(): Read line/bytes from stream
419 \end_layout
421 \begin_layout Itemize
422 Syntax: string/nil FILEREADER()
423 \end_layout
425 \begin_layout Itemize
426 Syntax: string/nil FILEREADER(number bytes)
427 \end_layout
429 \begin_layout Standard
430 Reads next line or <bytes> bytes from specified file handle.
431  On EOF, nil is returned.
432 \end_layout
434 \begin_layout Itemize
435 Note: The line-oriented variant reads in text mode, so CR at end of line
436  is stripped.
437 \end_layout
439 \begin_layout Subsection
440 FILEREADER:lines: Iterator to read all lines
441 \end_layout
443 \begin_layout Itemize
444 Syntax: for line in <foo>:lines() do ...
445  end
446 \end_layout
448 \begin_layout Standard
449 Iterator for reading all lines of <foo> in a loop.
450 \end_layout
452 \begin_layout Subsection
453 resolve_filename: Resolve name of file relative to another
454 \end_layout
456 \begin_layout Itemize
457 Syntax: string resolve_file(string filename, string base)
458 \end_layout
460 \begin_layout Standard
461 Resolve name of file <filename> relative to <base> and return the result.
462 \end_layout
464 \begin_layout Standard
465 \begin_inset Newpage pagebreak
466 \end_inset
469 \end_layout
471 \begin_layout Section
472 Table bit:
473 \end_layout
475 \begin_layout Standard
476 Bitwise logical functions and related.
477 \end_layout
479 \begin_layout Subsection
480 bit.none/bit.bnot: Bitwise none or NOT function
481 \end_layout
483 \begin_layout Itemize
484 Syntax: number bit.none(number...)
485 \end_layout
487 \begin_layout Itemize
488 Syntax: number bit.bnot(number...)
489 \end_layout
491 \begin_layout Standard
492 48-bit bitwise NOT / NONE function (set bits that are set in none of the
493  arguments).
494 \end_layout
496 \begin_layout Subsection
497 bit.any/bit.bor: Bitwise any or OR function
498 \end_layout
500 \begin_layout Itemize
501 Syntax: number bit.any(number...)
502 \end_layout
504 \begin_layout Itemize
505 Syntax: number bit.bor(number...)
506 \end_layout
508 \begin_layout Standard
509 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
510 \end_layout
512 \begin_layout Subsection
513 bit.all/bit.band: Bitwise all or AND function
514 \end_layout
516 \begin_layout Itemize
517 Syntax: number bit.all(number...)
518 \end_layout
520 \begin_layout Itemize
521 Syntax: number bit.band(number...)
522 \end_layout
524 \begin_layout Standard
525 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
527 \end_layout
529 \begin_layout Subsection
530 bit.parity/bit.bxor: Bitwise parity or XOR function
531 \end_layout
533 \begin_layout Itemize
534 Syntax: number bit.parity(number...)
535 \end_layout
537 \begin_layout Itemize
538 Syntax: number bit.bxor(number...)
539 \end_layout
541 \begin_layout Standard
542 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
543  of the arguments).
544 \end_layout
546 \begin_layout Subsection
547 bit.lrotate: Rotate a number left
548 \end_layout
550 \begin_layout Itemize
551 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
552 \end_layout
554 \begin_layout Standard
555 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
556  1) places.
557 \end_layout
559 \begin_layout Subsection
560 bit.rrotate: Rotate a number right
561 \end_layout
563 \begin_layout Itemize
564 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
565 \end_layout
567 \begin_layout Standard
568 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
569  1) places.
570 \end_layout
572 \begin_layout Subsection
573 bit.lshift: Shift a number left
574 \end_layout
576 \begin_layout Itemize
577 Syntax: number bit.lshift(number base[, number amount[, number bits]])
578 \end_layout
580 \begin_layout Standard
581 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
582  1) places.
583  The new bits are filled with zeroes.
584 \end_layout
586 \begin_layout Subsection
587 bit.lrshift: Shift a number right (logical)
588 \end_layout
590 \begin_layout Itemize
591 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
592 \end_layout
594 \begin_layout Standard
595 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
596  (default 1) places.
597  The new bits are filled with zeroes.
598 \end_layout
600 \begin_layout Subsection
601 bit.arshift: Shift a number right (arithmetic)
602 \end_layout
604 \begin_layout Itemize
605 Syntax: number bit.arshift(number base[, number amount[, number bits]])
606 \end_layout
608 \begin_layout Standard
609 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
610  (default 1) places.
611  The new bits are shifted in with copy of the high bit.
612 \end_layout
614 \begin_layout Subsection
615 bit.extract: Extract/shuffle bits from number
616 \end_layout
618 \begin_layout Itemize
619 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
620 \end_layout
622 \begin_layout Standard
623 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
624 \end_layout
626 \begin_layout Itemize
627 Note: Bit numbers up to 51 should work reliably (then things start falling
628  apart due to double precision issues).
629 \end_layout
631 \begin_layout Itemize
632 Note: There are two special bit positions, true and false, standing for
633  always set bit and always clear bit.
634 \end_layout
636 \begin_layout Subsection
637 bit.value: Construct number with specified bits set
638 \end_layout
640 \begin_layout Itemize
641 Syntax: number bit.value([number bit1[, number bit2,...]])
642 \end_layout
644 \begin_layout Standard
645 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
646  <bit2> places and so on.
647  As special value, nil argument is no-op.
648 \end_layout
650 \begin_layout Subsection
651 bit.test_any: Test if any bit is set
652 \end_layout
654 \begin_layout Itemize
655 Syntax: boolean bit.test_any(number a, number b)
656 \end_layout
658 \begin_layout Standard
659 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
660 \end_layout
662 \begin_layout Subsection
663 bit.test_all: Test if all bits are set
664 \end_layout
666 \begin_layout Itemize
667 Syntax: boolean bit.test_all(number a, number b)
668 \end_layout
670 \begin_layout Standard
671 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
672 \end_layout
674 \begin_layout Subsection
675 bit.popcount: Population count
676 \end_layout
678 \begin_layout Itemize
679 Syntax: number bit.popcount(number a)
680 \end_layout
682 \begin_layout Standard
683 Returns number of set bits in <a>.
684 \end_layout
686 \begin_layout Subsection
687 bit.clshift: Chained left shift
688 \end_layout
690 \begin_layout Itemize
691 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
692  bits]])
693 \end_layout
695 \begin_layout Standard
696 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
697  numbers to be of specified number of bits <bits> (default 48).
698 \end_layout
700 \begin_layout Subsection
701 bit.crshift: Chained right shift
702 \end_layout
704 \begin_layout Itemize
705 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
706  bits]])
707 \end_layout
709 \begin_layout Standard
710 Does chained right shift on <a>, <b> by <amount> positions (default 1),
711  assuming numbers to be of specified number of bits <bits> (default 48).
712 \end_layout
714 \begin_layout Subsection
715 bit.flagdecode: Decode bitfield into flags
716 \end_layout
718 \begin_layout Itemize
719 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
720  off]])
721 \end_layout
723 \begin_layout Standard
724 Return string of length bits where ith character is ith character of on
725  if bit i is on, otherwise ith character of off.
726  Out of range reads give last character.
727 \end_layout
729 \begin_layout Itemize
730 Note: <on> defaults to '*' if empty.
731 \end_layout
733 \begin_layout Itemize
734 Note: <off> defaults to '-' if empty.
735 \end_layout
737 \begin_layout Subsection
738 bit.rflagdecode: Decode bitfield into flags
739 \end_layout
741 \begin_layout Itemize
742 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
743  off]])
744 \end_layout
746 \begin_layout Standard
747 Like bit.flagdecode, but outputs the string in the opposite order (most significa
748 nt bit first).
749 \end_layout
751 \begin_layout Standard
752 \begin_inset Newpage pagebreak
753 \end_inset
756 \end_layout
758 \begin_layout Section
759 Table gui:
760 \end_layout
762 \begin_layout Itemize
763 Functions that draw to screen can only only be called in on_paint and on_video
764  callbacks or if non-default render queue has been set.
765 \end_layout
767 \begin_layout Itemize
768 Colors are 32-bit.
769  Bits 0-7 are the blue component, bits 8-15 are the green component, bits
770  16-23 are the red component, bits 24-31 are alpha component (0 is fully
771  opaque, 255 is almost transparent).
772  -1 is the fully transparent color.
773 \end_layout
775 \begin_layout Itemize
776 Alpha values greater than 127 do work properly.
777 \end_layout
779 \begin_layout Itemize
780 Origin of coordinates is at top left corner of game display area.
781  Left and top gaps correspond to negative coordinates.
782 \end_layout
784 \begin_layout Subsection
785 gui.resolution: Get current resolution
786 \end_layout
788 \begin_layout Itemize
789 Syntax: (number, number) gui.resolution()
790 \end_layout
792 \begin_layout Standard
793 Returns 2-tuple (hresolution, vresolution).
794 \end_layout
796 \begin_layout Subsection
797 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
798 \end_layout
800 \begin_layout Itemize
801 Syntax: number gui.left_gap(number gap)
802 \end_layout
804 \begin_layout Itemize
805 Syntax: number gui.right_gap(number gap)
806 \end_layout
808 \begin_layout Itemize
809 Syntax: number gui.top_gap(number gap)
810 \end_layout
812 \begin_layout Itemize
813 Syntax: number gui.bottom_gap(number gap)
814 \end_layout
816 \begin_layout Standard
817 Set the specified edge gap to specified value <gap> (max gap is 8191).
818  If successful, old gap is returned.
819 \end_layout
821 \begin_layout Subsection
822 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
823  Adjust edge gaps
824 \end_layout
826 \begin_layout Itemize
827 Syntax: number gui.delta_left_gap(number dgap)
828 \end_layout
830 \begin_layout Itemize
831 Syntax: number gui.delta_right_gap(number dgap)
832 \end_layout
834 \begin_layout Itemize
835 Syntax: number gui.delta_top_gap(number dgap)
836 \end_layout
838 \begin_layout Itemize
839 Syntax: number gui.delta_bottom_gap(number dgap)
840 \end_layout
842 \begin_layout Standard
843 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
844  and return the old gap (returns nothing on error).
845 \end_layout
847 \begin_layout Subsection
848 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
849 \end_layout
851 \begin_layout Itemize
852 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
853  bgc]])
854 \end_layout
856 \begin_layout Itemize
857 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
858  bgc]])
859 \end_layout
861 \begin_layout Itemize
862 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
863  bgc]])
864 \end_layout
866 \begin_layout Itemize
867 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
868  bgc]])
869 \end_layout
871 \begin_layout Standard
872 Draw specified text on the GUI (each character cell is 8 or 16 wide and
873  16 high).
874  Parameters:
875 \end_layout
877 \begin_layout Itemize
878 x: X-coordinate to start the drawing from (and x-coordinate at begining
879  of the lines).
880 \end_layout
882 \begin_layout Itemize
883 y: Y-coordinate to start the drawing from.
884 \end_layout
886 \begin_layout Itemize
887 text: The text to draw.
888 \end_layout
890 \begin_layout Itemize
891 fgc: Text color (default is 0xFFFFFF (white))
892 \end_layout
894 \begin_layout Itemize
895 bgc: Background color (default is -1 (transparent))
896 \end_layout
898 \begin_layout Standard
899 Note: The H variants draw at double width and V variants draw at double
900  height.
901 \end_layout
903 \begin_layout Subsection
904 gui.rectangle: Draw a rectangle
905 \end_layout
907 \begin_layout Itemize
908 Syntax: none gui.rectangle(number x, number y, number width, number height[,
909  number thickness[, number outline[, number fill]]])
910 \end_layout
912 \begin_layout Standard
913 Draw rectangle on the GUI.
914  Parameters:
915 \end_layout
917 \begin_layout Itemize
918 x: X-coordinate of left edge.
919 \end_layout
921 \begin_layout Itemize
922 y: Y-coordinate of upper edge.
923 \end_layout
925 \begin_layout Itemize
926 width: Width of rectangle.
927 \end_layout
929 \begin_layout Itemize
930 height: Height of rectangle.
931 \end_layout
933 \begin_layout Itemize
934 thickness: Thickness of outline (default is 1).
935 \end_layout
937 \begin_layout Itemize
938 outline: Color of outline (default is 0xFFFFFF (white))
939 \end_layout
941 \begin_layout Itemize
942 fill: Color of fill (default is -1 (transparent))
943 \end_layout
945 \begin_layout Subsection
946 gui.box: Draw a 3D-effect box
947 \end_layout
949 \begin_layout Itemize
950 Syntax: none gui.box(number x, number y, number width, number height[, number
951  thickness[, number outline1[,number outline2[, number fill]]]])
952 \end_layout
954 \begin_layout Standard
955 Draw rectangle with 3D effect on the GUI.
956  Parameters:
957 \end_layout
959 \begin_layout Itemize
960 x: X-coordinate of left edge.
961 \end_layout
963 \begin_layout Itemize
964 y: Y-coordinate of upper edge.
965 \end_layout
967 \begin_layout Itemize
968 width: Width of rectangle.
969 \end_layout
971 \begin_layout Itemize
972 height: Height of rectangle.
973 \end_layout
975 \begin_layout Itemize
976 thickness: Thickness of outline (default is 1).
977 \end_layout
979 \begin_layout Itemize
980 outline1: First color of outline (default is 0xFFFFFF (white))
981 \end_layout
983 \begin_layout Itemize
984 outline2: First color of outline (default is 0x808080 (dark gray))
985 \end_layout
987 \begin_layout Itemize
988 fill: Color of fill (default is 0xC0C0C0 (light grayy))
989 \end_layout
991 \begin_layout Subsection
992 gui.pixel: Draw a single pixel
993 \end_layout
995 \begin_layout Itemize
996 Syntax: none gui.pixel(number x, number y[, number color])
997 \end_layout
999 \begin_layout Standard
1000 Draw one pixel on the GUI.
1001  Parameters:
1002 \end_layout
1004 \begin_layout Itemize
1005 x: X-coordinate of the pixel
1006 \end_layout
1008 \begin_layout Itemize
1009 y: Y-coordinate of the pixel
1010 \end_layout
1012 \begin_layout Itemize
1013 color: Color of the pixel (default is 0xFFFFFF (white))
1014 \end_layout
1016 \begin_layout Subsection
1017 gui.crosshair: Draw a crosshair
1018 \end_layout
1020 \begin_layout Itemize
1021 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
1022 \end_layout
1024 \begin_layout Standard
1025 Draw a crosshair.
1026  Parameters:
1027 \end_layout
1029 \begin_layout Itemize
1030 x: X-coordinate of the crosshair
1031 \end_layout
1033 \begin_layout Itemize
1034 y: Y-coordinate of the crosshair
1035 \end_layout
1037 \begin_layout Itemize
1038 length: Length of the crosshair lines (default 10).
1039 \end_layout
1041 \begin_layout Itemize
1042 color: Color of the crosshair (default is 0xFFFFFF (white))
1043 \end_layout
1045 \begin_layout Subsection
1046 gui.line: Draw a line
1047 \end_layout
1049 \begin_layout Itemize
1050 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
1051  color])
1052 \end_layout
1054 \begin_layout Standard
1055 Draw a thin line.
1056  Parameters:
1057 \end_layout
1059 \begin_layout Itemize
1060 x1: X-coordinate of one end.
1061 \end_layout
1063 \begin_layout Itemize
1064 y1: Y-coordinate of one end.
1065 \end_layout
1067 \begin_layout Itemize
1068 x2: X-coordinate of the other end.
1069 \end_layout
1071 \begin_layout Itemize
1072 y2: Y-coordinate of the other end.
1073 \end_layout
1075 \begin_layout Itemize
1076 color: Color of the line (default is 0xFFFFFF (white)).
1077 \end_layout
1079 \begin_layout Subsection
1080 gui.circle: Draw a (filled) circle
1081 \end_layout
1083 \begin_layout Itemize
1084 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
1085  border[, number fil]]])
1086 \end_layout
1088 \begin_layout Standard
1089 Draw a circle.
1090  Parameters.
1091 \end_layout
1093 \begin_layout Itemize
1094 x: X-coordinate of the center
1095 \end_layout
1097 \begin_layout Itemize
1098 y: Y-coordinate of the center
1099 \end_layout
1101 \begin_layout Itemize
1102 r: The radius of the circle
1103 \end_layout
1105 \begin_layout Itemize
1106 thick: Border thickness
1107 \end_layout
1109 \begin_layout Itemize
1110 border: Border color (default is 0xFFFFFF (white))
1111 \end_layout
1113 \begin_layout Itemize
1114 fill: Fill color (default is -1 (transparent)).
1115 \end_layout
1117 \begin_layout Subsection
1118 gui.bitmap_draw: Draw a bitmap
1119 \end_layout
1121 \begin_layout Itemize
1122 Syntax: none gui.bitmap_draw(number x, number y, BITMAP bitmap, PALETTE palette)
1123 \end_layout
1125 \begin_layout Itemize
1126 Syntax: none gui.bitmap_draw(number x, number y, DBITMAP bitmap)
1127 \end_layout
1129 \begin_layout Standard
1130 Draw a bitmap <bitmap> on screen with specified palette <palette> (if bitmap
1131  is paletted) .
1132  Parameters:
1133 \end_layout
1135 \begin_layout Itemize
1136 x: X-coordinate of left edge.
1137 \end_layout
1139 \begin_layout Itemize
1140 y: Y-coordinate of top edge.
1141 \end_layout
1143 \begin_layout Itemize
1144 bitmap: The bitmap to draw
1145 \end_layout
1147 \begin_layout Itemize
1148 palette: The palette to draw the bitmap using.
1149 \end_layout
1151 \begin_layout Subsection
1152 gui.palette_new: Create a new palette
1153 \end_layout
1155 \begin_layout Itemize
1156 Syntax: PALETTE gui.palette_new()
1157 \end_layout
1159 \begin_layout Standard
1160 Returns a new palette (initially all transparent).
1162 \end_layout
1164 \begin_layout Subsection
1165 gui.bitmap_new: Create a new bitmap
1166 \end_layout
1168 \begin_layout Itemize
1169 Syntax: BITMAP/DBITMAP gui.bitmap_new(number w, number h, boolean direct[,
1170  bool icolor])
1171 \end_layout
1173 \begin_layout Standard
1174 Returns a new bitmap/dbitmap.
1175 \end_layout
1177 \begin_layout Standard
1178 Parameters:
1179 \end_layout
1181 \begin_layout Itemize
1182 w: The width of new bitmap
1183 \end_layout
1185 \begin_layout Itemize
1186 h: The height of new bitmap
1187 \end_layout
1189 \begin_layout Itemize
1190 direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
1191 \end_layout
1193 \begin_layout Itemize
1194 icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
1195 \end_layout
1197 \begin_layout Subsection
1198 gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
1199 \end_layout
1201 \begin_layout Itemize
1202 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
1203 \end_layout
1205 \begin_layout Itemize
1206 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
1207 \end_layout
1209 \begin_layout Standard
1210 Reads file <file> (resolved relative to <base>) or string <content> and
1211  returns loaded bitmap/dbitmap (if bitmap, the second return value is palette
1212  for bitmap).
1213 \end_layout
1215 \begin_layout Subsection
1216 gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
1217 \end_layout
1219 \begin_layout Itemize
1220 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
1221  base])
1222 \end_layout
1224 \begin_layout Itemize
1225 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
1226 \end_layout
1228 \begin_layout Standard
1229 Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
1230  encoded content <content>.
1231 \end_layout
1233 \begin_layout Itemize
1234 If the PNG is of color type 3 (PALETTE), returns two value.
1235  First is BITMAP containing the image data from the PNG and second is PALETTE
1236  containg the palette data from the PNG.
1237 \end_layout
1239 \begin_layout Itemize
1240 For color types 0 (GRAY), 2 (RGB), 4 (GRAY_ALPHA) and 6 (RGBA), returns
1241  one DBITMAP containg the image data loaded from the PNG.
1242 \end_layout
1244 \begin_layout Subsection
1245 gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
1246 \end_layout
1248 \begin_layout Itemize
1249 Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
1250 \end_layout
1252 \begin_layout Itemize
1253 Syntax: PALETTE gui.bitmap_load_pal_str(string content)
1254 \end_layout
1256 \begin_layout Standard
1257 Load a palette from file <file>(resolved relative to <base>) or string <content>.
1258 \end_layout
1260 \begin_layout Itemize
1261 The kinds of lines supported:
1262 \end_layout
1264 \begin_deeper
1265 \begin_layout Itemize
1266 Blank or just whitespace: Ignored
1267 \end_layout
1269 \begin_layout Itemize
1270 First non-whitespace is '#': Ignored
1271 \end_layout
1273 \begin_layout Itemize
1274 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1275 \end_layout
1277 \begin_layout Itemize
1278 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1279  (0-256, 0 being fully transparent and 256 fully opaque).
1280 \end_layout
1282 \begin_layout Itemize
1283 transparent: Fully transparent color
1284 \end_layout
1286 \end_deeper
1287 \begin_layout Subsection
1288 gui.palette_set: Set palette entry
1289 \end_layout
1291 \begin_layout Itemize
1292 Syntax: none gui.palette_set(PALETTE palette, number index, number color)
1293 \end_layout
1295 \begin_layout Standard
1296 Sets color in palette.
1297  Parameters:
1298 \end_layout
1300 \begin_layout Itemize
1301 palette: The palette to manipulate
1302 \end_layout
1304 \begin_layout Itemize
1305 index: Index of color (0-65535).
1306 \end_layout
1308 \begin_layout Itemize
1309 color: The color value.
1310 \end_layout
1312 \begin_layout Subsection
1313 gui.bitmap_pset: Set pixel in bitmap
1314 \end_layout
1316 \begin_layout Itemize
1317 Syntax: none gui.bitmap_pset(BITMAP/DBITMAP bitmap, number x, number y, number
1318  color)
1319 \end_layout
1321 \begin_layout Standard
1322 Sets specified pixel in bitmap.
1323  Parameters:
1324 \end_layout
1326 \begin_layout Itemize
1327 bitmap: The bitmap to manipulate
1328 \end_layout
1330 \begin_layout Itemize
1331 x: The x-coordinate of the pixel.
1332 \end_layout
1334 \begin_layout Itemize
1335 y: The y-coordinate of the pixel.
1336 \end_layout
1338 \begin_layout Itemize
1339 color: If bitmap is a bitmap, color index (0-65535).
1340  Otherwise color value.
1341 \end_layout
1343 \begin_layout Subsection
1344 gui.bitmap_pget: Get pixel in bitmap
1345 \end_layout
1347 \begin_layout Itemize
1348 Syntax: number gui.bitmap_pget(BITMAP/DBITMAP bitmap, number x, number y)
1349 \end_layout
1351 \begin_layout Standard
1352 Gets specified pixel in bitmap.
1353  Parameters:
1354 \end_layout
1356 \begin_layout Itemize
1357 bitmap: The bitmap to query
1358 \end_layout
1360 \begin_layout Itemize
1361 x: The x-coordinate of the pixel.
1362 \end_layout
1364 \begin_layout Itemize
1365 y: The y-coordinate of the pixel.
1366 \end_layout
1368 \begin_layout Standard
1369 The bitmap color (color index if paletted, otherwise color value).
1370 \end_layout
1372 \begin_layout Subsection
1373 gui.bitmap_size: Get size of bitmap
1374 \end_layout
1376 \begin_layout Itemize
1377 Syntax: (number, number) gui.bitmap_size(BITMAP/DBITMAP bitmap)
1378 \end_layout
1380 \begin_layout Standard
1381 Get size of bitmap <bitmap>.
1382  The first return is the width, the second is the height.
1383 \end_layout
1385 \begin_layout Itemize
1386 Note: Can be used anywhere.
1387 \end_layout
1389 \begin_layout Subsection
1390 gui.bitmap_blit: Blit a bitmap into another
1391 \end_layout
1393 \begin_layout Itemize
1394 Syntax: none gui.bitmap_blit(BITMAP dest, number dx, number dy, BITMAP src,
1395  number sx, number sy, number w, number h[, number ck])
1396 \end_layout
1398 \begin_layout Itemize
1399 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, DBITMAP
1400  src, number sx, number sy, number w, number h[, number ck])
1401 \end_layout
1403 \begin_layout Itemize
1404 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, BITMAP src,
1405  PALETTE pal, number sx, number sy, number w, number h[, number ck])
1406 \end_layout
1408 \begin_layout Standard
1409 Blit a part of bitmap to another.
1410  Parameters:
1411 \end_layout
1413 \begin_layout Itemize
1414 dest: Destination to blit to.
1415 \end_layout
1417 \begin_layout Itemize
1418 dx: left edge of target
1419 \end_layout
1421 \begin_layout Itemize
1422 dy: Top edge of target
1423 \end_layout
1425 \begin_layout Itemize
1426 src: The source to blit from.
1427 \end_layout
1429 \begin_layout Itemize
1430 pal: The palette to use in blit.
1431 \end_layout
1433 \begin_layout Itemize
1434 sx: left edge of source
1435 \end_layout
1437 \begin_layout Itemize
1438 sy: Top edge of source
1439 \end_layout
1441 \begin_layout Itemize
1442 w: Width of region
1443 \end_layout
1445 \begin_layout Itemize
1446 h: Height of region.
1447 \end_layout
1449 \begin_layout Itemize
1450 ck: Color key.
1451  Pixels of this color are not blitted.
1452 \end_layout
1454 \begin_deeper
1455 \begin_layout Itemize
1456 If soruce bitmap is bitmap, this is color index of colorkey.
1457  Values outside range 0-65535 cause no key to be used as colorkey.
1458 \end_layout
1460 \begin_layout Itemize
1461 If source bitmap is dbitmap, this is the color value of colorkey.
1462 \end_layout
1464 \begin_layout Itemize
1465 May be absent or nil for no colorkey blit.
1466 \end_layout
1468 \end_deeper
1469 \begin_layout Subsection
1470 gui.repaint: Arrange a repaint
1471 \end_layout
1473 \begin_layout Itemize
1474 Syntax: none gui.repaint()
1475 \end_layout
1477 \begin_layout Standard
1478 Request on_repaint() to happen as soon as possible.
1479 \end_layout
1481 \begin_layout Subsection
1482 gui.synchronous_repaint: Paint screen now
1483 \end_layout
1485 \begin_layout Itemize
1486 Syntax: none gui.synchronous_repaint(RENDERQUEUE queue)
1487 \end_layout
1489 \begin_layout Standard
1490 Paints specified render queue on screen right there and then.
1491 \end_layout
1493 \begin_layout Subsection
1494 gui.subframe_update: Enable/Disable subframe updates
1495 \end_layout
1497 \begin_layout Itemize
1498 Syntax: none gui.subframe_update(boolean on)
1499 \end_layout
1501 \begin_layout Standard
1502 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
1503  or not happen (<on>=false).
1504 \end_layout
1506 \begin_layout Subsection
1507 gui.screenshot: Write a screenshot
1508 \end_layout
1510 \begin_layout Itemize
1511 Syntax: none gui.screenshot(string filename)
1512 \end_layout
1514 \begin_layout Standard
1515 Write PNG screenshot of the current frame (no drawings) to specified file
1516  <filename>.
1517 \end_layout
1519 \begin_layout Subsection
1520 gui.color: Compose a color.
1521 \end_layout
1523 \begin_layout Itemize
1524 Syntax: number gui.color(number r, number g, number b[, number a])
1525 \end_layout
1527 \begin_layout Standard
1528 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
1529 , each component in scale 0-255.
1530  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
1531  fully opaque).
1532  The default alpha is 256.
1533 \end_layout
1535 \begin_layout Subsection
1536 gui.status: Set status variable
1537 \end_layout
1539 \begin_layout Itemize
1540 Syntax: none gui.status(string name, string value)
1541 \end_layout
1543 \begin_layout Standard
1544 Set status field 
1545 \begin_inset Quotes eld
1546 \end_inset
1548 L[<name>]
1549 \begin_inset Quotes erd
1550 \end_inset
1552  to <value> in status area.
1553 \end_layout
1555 \begin_layout Subsection
1556 gui.rainbow: Rainbow color calculation
1557 \end_layout
1559 \begin_layout Itemize
1560 Syntax: number gui.rainbow(number step, number steps[, number color])
1561 \end_layout
1563 \begin_layout Standard
1564 Perform hue rotation of color <color> (default bright red), by <step> steps.
1565  The number of steps per full rotation is given by absolute value of <steps>.
1566 \end_layout
1568 \begin_layout Standard
1569 If <steps> is negative, the rotation will be counterclockwise.
1570 \end_layout
1572 \begin_layout Subsection
1573 gui.renderq_new: Create a render queue
1574 \end_layout
1576 \begin_layout Itemize
1577 Syntax: RENDERQUEUE gui.renderq_new(number width, number height)
1578 \end_layout
1580 \begin_layout Standard
1581 Create render queue with specified reported size and return it.
1582 \end_layout
1584 \begin_layout Subsection
1585 gui.renderq_clear: Clear a render queue
1586 \end_layout
1588 \begin_layout Itemize
1589 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
1590 \end_layout
1592 \begin_layout Standard
1593 Clear specified render queue.
1594 \end_layout
1596 \begin_layout Subsection
1597 gui.renderq_set: Change active render queue
1598 \end_layout
1600 \begin_layout Itemize
1601 Syntax: none gui.renderq_set(RENDERQUEUE queue)
1602 \end_layout
1604 \begin_layout Standard
1605 Switch to specified render queue.
1606  Use nil as queue to switch to default queue.
1607 \end_layout
1609 \begin_layout Itemize
1610 Note: When switched to another queue, all drawing functions work and draw
1611  there, even outside on_video/on_paint.
1612 \end_layout
1614 \begin_layout Subsection
1615 gui.renderq_run: Run render queue
1616 \end_layout
1618 \begin_layout Itemize
1619 Syntax: none gui.renderq_run(RENDERQUEUE queue)
1620 \end_layout
1622 \begin_layout Standard
1623 Run specified render queue, copying the objects to current render queue.
1625 \end_layout
1627 \begin_layout Itemize
1628 Warning: Don't try to run the current render queue.
1629 \end_layout
1631 \begin_layout Subsection
1632 gui.loadfont: Load a font file
1633 \end_layout
1635 \begin_layout Itemize
1636 Syntax: CUSTOMFONT gui.loadfont(string filename)
1637 \end_layout
1639 \begin_layout Standard
1640 Loads font from specified file (CUSTOMFONT object).
1641 \end_layout
1643 \begin_layout Subsection
1644 CUSTOMFONT(): Render text to screen
1645 \end_layout
1647 \begin_layout Itemize
1648 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
1649  bgc[, number hlc]]])
1650 \end_layout
1652 \begin_layout Standard
1653 Draw string with custom font to screen.
1654  The parameters are the same as in gui.text, except <hlc> is the halo color
1655  (default is no halo).
1657 \end_layout
1659 \begin_layout Subsection
1660 gui.adjust_transparency: Adjust transparency of DBITMAP or PALETTE
1661 \end_layout
1663 \begin_layout Itemize
1664 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
1665 \end_layout
1667 \begin_layout Itemize
1668 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
1669 \end_layout
1671 \begin_layout Standard
1672 Multiply alpha channel of <obj> by <adj>/256.
1673  Useful for making 
1674 \begin_inset Quotes eld
1675 \end_inset
1677 ghosts
1678 \begin_inset Quotes erd
1679 \end_inset
1681  out of solid bitmaps.
1682 \end_layout
1684 \begin_layout Subsection
1685 gui.kill_frame: Kill video frame and associated sound
1686 \end_layout
1688 \begin_layout Itemize
1689 Syntax: none gui.kill_frame()
1690 \end_layout
1692 \begin_layout Standard
1693 Kills the currently dumped video frame + the associated sound.
1694  Only valid in on_video callback.
1695 \end_layout
1697 \begin_layout Subsection
1698 gui.arrow: Draw an arrow
1699 \end_layout
1701 \begin_layout Itemize
1702 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
1703  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
1705 \end_layout
1707 \begin_layout Standard
1708 Draws an arrow using color <color>.
1709  The tip of arrow is at (<x>, <y>).
1710  Other parameters:
1711 \end_layout
1713 \begin_layout Enumerate
1714 <length>: The length of arrow tail.
1715 \end_layout
1717 \begin_layout Enumerate
1718 <hwidth>: The width of arrow head.
1719  Should be odd.
1720 \end_layout
1722 \begin_layout Enumerate
1723 <direction>: Direction of arrow.
1724  0 is to right, +1 rotates 45 degrees counterclockwise.
1725 \end_layout
1727 \begin_layout Enumerate
1728 <fill>: If true, fill the arrow head.
1729  Default false.
1730 \end_layout
1732 \begin_layout Enumerate
1733 <twidth>: Tail width.
1734  Should be odd.
1735  Default 1.
1736 \end_layout
1738 \begin_layout Enumerate
1739 <hthick>: Head thickness (only used if <fill> is false).
1740  Default is <twidth>.
1741 \end_layout
1743 \begin_layout Subsection
1744 gui.tilemap: Create a tilemap
1745 \end_layout
1747 \begin_layout Itemize
1748 Syntax: TILEMAP gui.tilemap(number w, number h, number bw, number bh)
1749 \end_layout
1751 \begin_layout Standard
1752 Create a new tilemap of size <w>*<h>, with each cell being <bw>*<bh>.
1753 \end_layout
1755 \begin_layout Subsection
1756 TILEMAP:getsize: Query tilemap size
1757 \end_layout
1759 \begin_layout Itemize
1760 Syntax: number, number TILEMAP:getsize()
1761 \end_layout
1763 \begin_layout Standard
1764 Return size of tilemap (width first).
1765 \end_layout
1767 \begin_layout Subsection
1768 TILEMAP:getcsize: Query tilemap cell size
1769 \end_layout
1771 \begin_layout Itemize
1772 Syntax: number, number TILEMAP:getcsize()
1773 \end_layout
1775 \begin_layout Standard
1776 Return size of tilemap cell (width first).
1777 \end_layout
1779 \begin_layout Subsection
1780 TILEMAP:get: Query tilemap cell
1781 \end_layout
1783 \begin_layout Itemize
1784 Syntax: none TILEMAP:get(number x, number y)
1785 \end_layout
1787 \begin_layout Itemize
1788 Syntax: dbitmap TILEMAP:get(number x, number y)
1789 \end_layout
1791 \begin_layout Itemize
1792 Syntax: bitmap,palette TILEMAP:get(number x, number y)
1793 \end_layout
1795 \begin_layout Standard
1796 Return contents of cell at <x>,<y>.
1797 \end_layout
1799 \begin_layout Subsection
1800 TILEMAP:set: Set tilemap cell
1801 \end_layout
1803 \begin_layout Itemize
1804 Syntax: none TILEMAP:set(number x, number y)
1805 \end_layout
1807 \begin_layout Itemize
1808 Syntax: none TILEMAP:set(number x, number y, dbitmap b)
1809 \end_layout
1811 \begin_layout Itemize
1812 Syntax: none TILEMAP:set(number x, number y, bitmap b, palette p)
1813 \end_layout
1815 \begin_layout Standard
1816 Set contents of cell at <x>,<y>.
1817  If no bitmap/dbitmap is given, cell is cleared.
1818  Otherwise specified (d)bitmap is used (with specified palette if bitmap).
1819 \end_layout
1821 \begin_layout Subsection
1822 TILEMAP:scroll: Scroll tilemap
1823 \end_layout
1825 \begin_layout Itemize
1826 Syntax: none TILEMAP:scroll(number ox, number oy)
1827 \end_layout
1829 \begin_layout Itemize
1830 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
1831  w, number h)
1832 \end_layout
1834 \begin_layout Itemize
1835 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
1836  w, number h, boolean circx, boolean circy)
1837 \end_layout
1839 \begin_layout Standard
1840 Scrolls the tilemap tiles by <ox>,<oy>.
1841  If <x>,<y>,<w>,<h> is specified, the scrolling is limited to <w>*<h> window
1842  starting at <x>,<y> (in tiles).
1843 \end_layout
1845 \begin_layout Standard
1846 If <circx> is true, the window is circular in horizontal direction.
1847  Similarly with <circy> and vertical direciton.
1848 \end_layout
1850 \begin_layout Subsection
1851 TILEMAP:draw: Draw tilemap
1852 \end_layout
1854 \begin_layout Itemize
1855 Syntax: none TILEMAP:draw(number x, number y)
1856 \end_layout
1858 \begin_layout Itemize
1859 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0)
1860 \end_layout
1862 \begin_layout Itemize
1863 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0, number
1864  w, number h)
1865 \end_layout
1867 \begin_layout Standard
1868 Draw tilemap at <x>,<y>.
1869  If <x0>,<y0> is given, that is tilemap coordinate (in pixels) of upper
1870  left edge.
1871  If <w>,<h> is given, that is the size of window to draw (in pixels)
1872 \end_layout
1874 \begin_layout Subsection
1875 gui.bitmap_save_png: Save a bitmap to PNG
1876 \end_layout
1878 \begin_layout Itemize
1879 Syntax: none gui.bitmap_save_png(string filename[, string base], BITMAP bmp,
1880  PALETTE pal)
1881 \end_layout
1883 \begin_layout Itemize
1884 Syntax: none gui.bitmap_save_png(string filename[, string base], DBITMAP
1885  bmp)
1886 \end_layout
1888 \begin_layout Itemize
1889 Syntax: string gui.bitmap_save_png(BITMAP bmp, PALETTE pal)
1890 \end_layout
1892 \begin_layout Itemize
1893 Syntax: string gui.bitmap_save_png(DBITMAP bmp)
1894 \end_layout
1896 \begin_layout Standard
1897 Save specified bitmap <bmp>, with palette <pal> (only if paletted) into
1898  PNG file <filename> (relative to <base>) or return BASE64 encoding as return
1899  value.
1900 \end_layout
1902 \begin_layout Subsection
1903 gui.bitmap_hash: Hash a bitmap
1904 \end_layout
1906 \begin_layout Itemize
1907 Syntax: string gui.bitmap_hash(BITMAP bmp)
1908 \end_layout
1910 \begin_layout Itemize
1911 Syntax: string gui.bitmap_hash(DBITMAP bmp)
1912 \end_layout
1914 \begin_layout Standard
1915 Hashes bitmap <bmp> and returns 64-hex digit crypto-strong hash.
1916  Identical bitmaps result in indentical hashes (but color order in indexed
1917  bitmaps is significant).
1918 \end_layout
1920 \begin_layout Subsection
1921 gui.palette_hash: Hash a palette
1922 \end_layout
1924 \begin_layout Itemize
1925 Syntax: string gui.palette_hash(PALETTE pal)
1926 \end_layout
1928 \begin_layout Standard
1929 Hashes palette <pal> and retruns 64-hex digit crypto-strong hash.
1930  Identical palettes result in identical hashes (fully transparent colors
1931  at end of palette don't affect the hash).
1932 \end_layout
1934 \begin_layout Standard
1935 \begin_inset Newpage pagebreak
1936 \end_inset
1939 \end_layout
1941 \begin_layout Section
1942 table input
1943 \end_layout
1945 \begin_layout Standard
1946 Input handling.
1947  Functions manipulating input are only available in on_input callback.
1948 \end_layout
1950 \begin_layout Subsection
1951 input.get: Read controller button/axis (deprecated)
1952 \end_layout
1954 \begin_layout Itemize
1955 Syntax: number input.get(number controller, number index)
1956 \end_layout
1958 \begin_layout Standard
1959 Read the specified index <index> (zero-based) from specified controller
1960  <controller> (zero-based).
1962 \end_layout
1964 \begin_layout Subsection
1965 input.set: Write controller button/axis (deprecated)
1966 \end_layout
1968 \begin_layout Itemize
1969 Syntax: none input.set(number controller, number index, number value)
1970 \end_layout
1972 \begin_layout Standard
1973 Write the specified index <index> (zero-based) from specified controller
1974  <controller> (zero-based), storing value <value>.
1975 \end_layout
1977 \begin_layout Subsection
1978 input.get2: Read controller button/axis
1979 \end_layout
1981 \begin_layout Itemize
1982 Syntax: number input.get2(number port, number controller, number index)
1983 \end_layout
1985 \begin_layout Standard
1986 Read the specified input tuple.
1987  Port 0 is system port.
1988 \end_layout
1990 \begin_layout Subsection
1991 input.set2: Write controller button/axis
1992 \end_layout
1994 \begin_layout Itemize
1995 Syntax: input.set2(number port, number controller, number index, number value)
1996 \end_layout
1998 \begin_layout Standard
1999 Write the specified input tuple.
2000  Port 0 is system port.
2001 \end_layout
2003 \begin_layout Subsection
2004 input.lcid_to_pcid2: Look up logical controller
2005 \end_layout
2007 \begin_layout Itemize
2008 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
2009 \end_layout
2011 \begin_layout Standard
2012 Look up physical pcid pair (port, controller) corresponding to specified
2013  logical controller (1-based).
2014  Returns nothing if controller does not exist.
2015 \end_layout
2017 \begin_layout Subsection
2018 input.port_type: Look up port type
2019 \end_layout
2021 \begin_layout Itemize
2022 Syntax: string input.port_type(number port)
2023 \end_layout
2025 \begin_layout Standard
2026 Return type of specified port.
2027 \end_layout
2029 \begin_layout Subsection
2030 input.controller_info: Get information about controller
2031 \end_layout
2033 \begin_layout Itemize
2034 Syntax: table input.controller_info(number port, number controller)
2035 \end_layout
2037 \begin_layout Standard
2038 Get controller info for specified controller.
2039  If controller does not exist, returns nil.
2040  Otherwise returns a table with following fields:
2041 \end_layout
2043 \begin_layout Itemize
2044 type (string): Type of the controller.
2045 \end_layout
2047 \begin_layout Itemize
2048 class (string): Class of the controller.
2049 \end_layout
2051 \begin_layout Itemize
2052 classnum (number): Number of the controller within its class (1-based)
2053 \end_layout
2055 \begin_layout Itemize
2056 lcid (number): Logical controller number of the controller.
2057 \end_layout
2059 \begin_layout Itemize
2060 button_count (number): Number of buttons on controller
2061 \end_layout
2063 \begin_layout Itemize
2064 buttons (array): Array of following info about each button:
2065 \end_layout
2067 \begin_deeper
2068 \begin_layout Itemize
2069 type (string): Type of button.
2070  Currently one of 
2071 \begin_inset Quotes eld
2072 \end_inset
2074 null
2075 \begin_inset Quotes erd
2076 \end_inset
2079 \begin_inset Quotes eld
2080 \end_inset
2082 button
2083 \begin_inset Quotes erd
2084 \end_inset
2087 \begin_inset Quotes eld
2088 \end_inset
2090 axis
2091 \begin_inset Quotes erd
2092 \end_inset
2095 \begin_inset Quotes eld
2096 \end_inset
2098 raxis
2099 \begin_inset Quotes erd
2100 \end_inset
2103 \end_layout
2105 \begin_layout Itemize
2106 name (string): Name of button.
2107 \end_layout
2109 \begin_layout Itemize
2110 symbol (string): Symbol of button.
2111  Only present for type 
2112 \begin_inset Quotes eld
2113 \end_inset
2115 button
2116 \begin_inset Quotes erd
2117 \end_inset
2120 \end_layout
2122 \begin_layout Itemize
2123 hidden (boolean): True if hidden button.
2125 \end_layout
2127 \end_deeper
2128 \begin_layout Subsection
2129 input.veto_button: Veto a button press
2130 \end_layout
2132 \begin_layout Itemize
2133 Syntax: none input.veto_button()
2134 \end_layout
2136 \begin_layout Standard
2137 Signals that the button event should be vetoed.
2138  Only valid in on_button callback.
2139 \end_layout
2141 \begin_layout Subsection
2142 input.geta: Get all buttons for controller (deprecated)
2143 \end_layout
2145 \begin_layout Itemize
2146 Syntax: (number, number...) input.geta(number controller)
2147 \end_layout
2149 \begin_layout Standard
2150 Get input state for entiere controller.
2151  Returns n return values.
2152 \end_layout
2154 \begin_layout Itemize
2155 1st return value: Bitmask: bit i is set if i:th index is nonzero
2156 \end_layout
2158 \begin_layout Itemize
2159 2nd- return value: value of i:th index.
2160 \end_layout
2162 \begin_layout Subsection
2163 input.seta: Set all buttons for controller (deprecated)
2164 \end_layout
2166 \begin_layout Itemize
2167 Syntax: none input.seta(number controller, number bitmask, number args...)
2168 \end_layout
2170 \begin_layout Standard
2171 Set state for entiere controller.
2172  args is up to N values for indices (overriding values in bitmask if specified).
2173 \end_layout
2175 \begin_layout Subsection
2176 input.controllertype: Get controller type (deprecated)
2177 \end_layout
2179 \begin_layout Itemize
2180 syntax: string input.controllertype(number controller)
2181 \end_layout
2183 \begin_layout Standard
2184 Get the type of controller as string.
2185 \end_layout
2187 \begin_layout Subsection
2188 input.reset: Execute (delayed) reset
2189 \end_layout
2191 \begin_layout Itemize
2192 Syntax: none input.reset([number cycles])
2193 \end_layout
2195 \begin_layout Standard
2196 Execute reset.
2197  If <cycles> is greater than zero, do delayed reset.
2198  0 (or no value) causes immediate reset.
2199 \end_layout
2201 \begin_layout Itemize
2202 Note: Only available with subframe flag false.
2203 \end_layout
2205 \begin_layout Subsection
2206 input.raw: Return raw input data
2207 \end_layout
2209 \begin_layout Itemize
2210 Syntax: table input.raw()
2211 \end_layout
2213 \begin_layout Standard
2214 Returns table of tables of all available keys and axes.
2215  The first table is indexed by key name (platform-dependent!), and the inner
2216  table has the following fields:
2217 \end_layout
2219 \begin_layout Itemize
2220 value: Last reported value for control
2221 \end_layout
2223 \begin_deeper
2224 \begin_layout Itemize
2225 For keys: 1 for pressed, 0 for released.
2226 \end_layout
2228 \begin_layout Itemize
2229 For axes: -32767...32767.
2230 \end_layout
2232 \begin_layout Itemize
2233 For presure-sensitive buttons: 0...32767.
2234 \end_layout
2236 \begin_layout Itemize
2237 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
2238 \end_layout
2240 \begin_layout Itemize
2241 For mouse: Coordinates relative to game area.
2242 \end_layout
2244 \end_deeper
2245 \begin_layout Itemize
2246 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
2247 \end_layout
2249 \begin_layout Subsection
2250 input.keyhook: Hook a key
2251 \end_layout
2253 \begin_layout Itemize
2254 Syntax: none input.keyhook(string key, boolean state)
2255 \end_layout
2257 \begin_layout Standard
2258 Requests that keyhook events to be sent for key <key> (<state>=true) or
2259  not sent (<state>=false).
2260 \end_layout
2262 \begin_layout Subsection
2263 input.joyget: Get controls for controller
2264 \end_layout
2266 \begin_layout Itemize
2267 Syntax: table input.joyget(number logical)
2268 \end_layout
2270 \begin_layout Standard
2271 Returns table for current controls for specified logical controller <logical>.
2272  The names of fields vary by controller type.
2273 \end_layout
2275 \begin_layout Itemize
2276 The buttons have the same name as those are referred to in other contexts
2277  in the emulator
2278 \end_layout
2280 \begin_layout Itemize
2281 The analog axes are usually 
2282 \begin_inset Quotes eld
2283 \end_inset
2285 xaxis
2286 \begin_inset Quotes erd
2287 \end_inset
2289  and 
2290 \begin_inset Quotes eld
2291 \end_inset
2293 yaxis
2294 \begin_inset Quotes erd
2295 \end_inset
2298 \end_layout
2300 \begin_layout Itemize
2301 Each field is numeric or boolean depending on axis/button.
2302 \end_layout
2304 \begin_layout Subsection
2305 input.joyset: Set controls for controller
2306 \end_layout
2308 \begin_layout Itemize
2309 Syntax: none input.joyset(number controller, table controls)
2310 \end_layout
2312 \begin_layout Standard
2313 Set the the state of specified controller to values specified in specified
2314  table.
2315 \end_layout
2317 \begin_layout Itemize
2318 Each field can be boolean or number.
2319 \end_layout
2321 \begin_layout Itemize
2322 Also, buttons allow strings, which cause value to be inverted.
2323 \end_layout
2325 \begin_layout Subsection
2326 input.lcid_to_pcid: Look up logical controller (deprecated)
2327 \end_layout
2329 \begin_layout Itemize
2330 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
2331 \end_layout
2333 \begin_layout Standard
2334 Returns the legacy pcid for controller (or false if there isn't one), followed
2335  by pcid pair.
2336  Returns nothing if controller does not exist.
2337 \end_layout
2339 \begin_layout Standard
2340 \begin_inset Newpage pagebreak
2341 \end_inset
2344 \end_layout
2346 \begin_layout Section
2347 Table keyboard
2348 \end_layout
2350 \begin_layout Standard
2351 Various keybinding-related functions
2352 \end_layout
2354 \begin_layout Subsection
2355 keyboard.bind: Bind a key
2356 \end_layout
2358 \begin_layout Itemize
2359 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
2360 \end_layout
2362 \begin_layout Standard
2363 Bind specified key with specified modifers to specified command.
2364 \end_layout
2366 \begin_layout Subsection
2367 keyboard.unbind: Unbind a key
2368 \end_layout
2370 \begin_layout Itemize
2371 Syntax: none keyboard.unbind(string mod, string mask, string key)
2372 \end_layout
2374 \begin_layout Standard
2375 Unbind specified key with specified modifers.
2376 \end_layout
2378 \begin_layout Subsection
2379 keyboard.alias: Set alias expansion
2380 \end_layout
2382 \begin_layout Itemize
2383 Syntax: none keyboard.alias(string alias, string expansion)
2384 \end_layout
2386 \begin_layout Standard
2387 Set expansion of given command.
2388 \end_layout
2390 \begin_layout Standard
2391 \begin_inset Newpage pagebreak
2392 \end_inset
2395 \end_layout
2397 \begin_layout Section
2398 Table subtitle
2399 \end_layout
2401 \begin_layout Standard
2402 Subtitle handling
2403 \end_layout
2405 \begin_layout Subsection
2406 subtitle.byindex: Look up start and length of subtitle by index
2407 \end_layout
2409 \begin_layout Itemize
2410 Syntax: (number, number) subtitle.byindex(number i)
2411 \end_layout
2413 \begin_layout Standard
2414 Read the frame and length of ith subtitle.
2415  Returns nothing if not present.
2416 \end_layout
2418 \begin_layout Subsection
2419 subtitle.set: Write a subtitle
2420 \end_layout
2422 \begin_layout Itemize
2423 Syntax: none subtitle.set(number f, number l, string txt)
2424 \end_layout
2426 \begin_layout Standard
2427 Set the text of subtitle.
2428 \end_layout
2430 \begin_layout Subsection
2431 subtitle.get: Read a subtitle
2432 \end_layout
2434 \begin_layout Itemize
2435 Syntax: string subtitle.get(number f, number l)
2436 \end_layout
2438 \begin_layout Standard
2439 Get the text of subtitle.
2440 \end_layout
2442 \begin_layout Subsection
2443 subtitle.delete: Delete a subtitle
2444 \end_layout
2446 \begin_layout Itemize
2447 Syntax: nonesubtitle.delete(number f, number l)
2448 \end_layout
2450 \begin_layout Standard
2451 Delete specified subtitle.
2452 \end_layout
2454 \begin_layout Standard
2455 \begin_inset Newpage pagebreak
2456 \end_inset
2459 \end_layout
2461 \begin_layout Section
2462 Table hostmemory
2463 \end_layout
2465 \begin_layout Standard
2466 Host memory handling (extra memory saved to savestates).
2467  Host memory starts empty.
2468 \end_layout
2470 \begin_layout Itemize
2471 Reads out of range return false.
2472 \end_layout
2474 \begin_layout Itemize
2475 Writes out of range extend the memory.
2476 \end_layout
2478 \begin_layout Subsection
2479 hostmemory.read: Read byte from host memory
2480 \end_layout
2482 \begin_layout Itemize
2483 Syntax: number hostmemory.read(number address)
2484 \end_layout
2486 \begin_layout Standard
2487 Reads byte from hostmemory slot address <address>.
2488 \end_layout
2490 \begin_layout Subsection
2491 hostmemory.write: Write byte to host memory
2492 \end_layout
2494 \begin_layout Itemize
2495 Syntax: none hostmemory.write(number address, number value)
2496 \end_layout
2498 \begin_layout Standard
2499 Writes hostmemory slot with value <value> 0-255.
2500 \end_layout
2502 \begin_layout Subsection
2503 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
2504 \end_layout
2506 \begin_layout Itemize
2507 Syntax: number hostmemory.readbyte(number address)
2508 \end_layout
2510 \begin_layout Itemize
2511 Syntax: number hostmemory.readsbyte(number address)
2512 \end_layout
2514 \begin_layout Itemize
2515 Syntax: number hostmemory.readword(number address)
2516 \end_layout
2518 \begin_layout Itemize
2519 Syntax: number hostmemory.readsword(number address)
2520 \end_layout
2522 \begin_layout Itemize
2523 Syntax: number hostmemory.readhword(number address)
2524 \end_layout
2526 \begin_layout Itemize
2527 Syntax: number hostmemory.readshword(number address)
2528 \end_layout
2530 \begin_layout Itemize
2531 Syntax: number hostmemory.readdword(number address)
2532 \end_layout
2534 \begin_layout Itemize
2535 Syntax: number hostmemory.readsdword(number address)
2536 \end_layout
2538 \begin_layout Itemize
2539 Syntax: number hostmemory.readqword(number address)
2540 \end_layout
2542 \begin_layout Itemize
2543 Syntax: number hostmemory.readsqword(number address)
2544 \end_layout
2546 \begin_layout Standard
2547 Read elements (big-endian) from given address <address>.
2548 \end_layout
2550 \begin_layout Itemize
2551 byte is 1 element
2552 \end_layout
2554 \begin_layout Itemize
2555 word is 2 elements
2556 \end_layout
2558 \begin_layout Itemize
2559 hword is 3 elements
2560 \end_layout
2562 \begin_layout Itemize
2563 dword is 4 elements
2564 \end_layout
2566 \begin_layout Itemize
2567 qword is 8 elements.
2568 \end_layout
2570 \begin_layout Itemize
2571 The 's' variants do signed read.
2572 \end_layout
2574 \begin_layout Subsection
2575 hostmemory.read{float,double}: Read from host memory
2576 \end_layout
2578 \begin_layout Itemize
2579 syntax: number hostmemory.readfloat(number address)
2580 \end_layout
2582 \begin_layout Itemize
2583 Syntax: number hostmemory.readdouble(number address)
2584 \end_layout
2586 \begin_layout Standard
2587 Read elements (big-endian) floating-pont from given address <address>.
2588 \end_layout
2590 \begin_layout Subsection
2591 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
2592 \end_layout
2594 \begin_layout Itemize
2595 Syntax: number hostmemory.writebyte(number address, number value)
2596 \end_layout
2598 \begin_layout Itemize
2599 Syntax: number hostmemory.writesbyte(number address, number value)
2600 \end_layout
2602 \begin_layout Itemize
2603 Syntax: number hostmemory.writeword(number address, number value)
2604 \end_layout
2606 \begin_layout Itemize
2607 Syntax: number hostmemory.writesword(number address, number value)
2608 \end_layout
2610 \begin_layout Itemize
2611 Syntax: number hostmemory.writehword(number address, number value)
2612 \end_layout
2614 \begin_layout Itemize
2615 Syntax: number hostmemory.writeshword(number address, number value)
2616 \end_layout
2618 \begin_layout Itemize
2619 Syntax: number hostmemory.writedword(number address, number value)
2620 \end_layout
2622 \begin_layout Itemize
2623 Syntax: number hostmemory.writesdword(number address, number value)
2624 \end_layout
2626 \begin_layout Itemize
2627 Syntax: number hostmemory.writeqword(number address, number value)
2628 \end_layout
2630 \begin_layout Itemize
2631 Syntax: number hostmemory.writesqword(number address, number value)
2632 \end_layout
2634 \begin_layout Standard
2635 Write value <value> to elements (little-endian) starting from given address
2636  <address>.
2637 \end_layout
2639 \begin_layout Itemize
2640 byte is 1 element
2641 \end_layout
2643 \begin_layout Itemize
2644 word is 2 elements
2645 \end_layout
2647 \begin_layout Itemize
2648 hword is 3 elements
2649 \end_layout
2651 \begin_layout Itemize
2652 dword is 4 elements
2653 \end_layout
2655 \begin_layout Itemize
2656 qword is 8 elements.
2657 \end_layout
2659 \begin_layout Itemize
2660 The 's' variants do signed write.
2661 \end_layout
2663 \begin_layout Subsection
2664 hostmemory.write{float,double}: Write to host memory
2665 \end_layout
2667 \begin_layout Itemize
2668 syntax: none hostmemory.readfloat(number address, number value)
2669 \end_layout
2671 \begin_layout Itemize
2672 Syntax: none hostmemory.readdouble(number address, number value)
2673 \end_layout
2675 \begin_layout Standard
2676 Write elements (big-endian) floating-pont to given address <address>, storing
2677  <value>.
2678 \end_layout
2680 \begin_layout Standard
2681 \begin_inset Newpage pagebreak
2682 \end_inset
2685 \end_layout
2687 \begin_layout Section
2688 Table movie
2689 \end_layout
2691 \begin_layout Standard
2692 Movie handling
2693 \end_layout
2695 \begin_layout Subsection
2696 movie.currentframe: Get current frame number
2697 \end_layout
2699 \begin_layout Itemize
2700 Syntax: number movie.currentframe()
2701 \end_layout
2703 \begin_layout Standard
2704 Return number of current frame.
2705 \end_layout
2707 \begin_layout Subsection
2708 movie.framecount: Get move frame count
2709 \end_layout
2711 \begin_layout Itemize
2712 Syntax: number movie.framecount()
2713 \end_layout
2715 \begin_layout Standard
2716 Return number of frames in movie.
2717 \end_layout
2719 \begin_layout Subsection
2720 movie.readonly: Is in readonly mode?
2721 \end_layout
2723 \begin_layout Itemize
2724 Syntax: boolean movie.readonly()
2725 \end_layout
2727 \begin_layout Standard
2728 Return true if in readonly mode, false if in readwrite.
2729 \end_layout
2731 \begin_layout Subsection
2732 movie.rerecords: Movie rerecord count
2733 \end_layout
2735 \begin_layout Itemize
2736 Syntax: number movie.rerecords()
2737 \end_layout
2739 \begin_layout Standard
2740 Returns the current value of rerecord count.
2741 \end_layout
2743 \begin_layout Subsection
2744 movie.set_readwrite: Set read-write mode.
2745 \end_layout
2747 \begin_layout Itemize
2748 Syntax: none movie.set_readwrite()
2749 \end_layout
2751 \begin_layout Standard
2752 Set readwrite mode (does not cause on_readwrite callback).
2753 \end_layout
2755 \begin_layout Subsection
2756 movie.frame_subframes: Count subframes in frame
2757 \end_layout
2759 \begin_layout Itemize
2760 Syntax: number movie.frame_subframes(number frame)
2761 \end_layout
2763 \begin_layout Standard
2764 Count number of subframes in specified frame <frame> (frame numbers are
2765  1-based) and return that.
2766 \end_layout
2768 \begin_layout Subsection
2769 movie.read_subframes: Read subframe data (deprecated)
2770 \end_layout
2772 \begin_layout Itemize
2773 Syntax: table movie.read_subframes(number frame, number subframe)
2774 \end_layout
2776 \begin_layout Standard
2777 Read specifed subframe in specified frame and return data as array.
2778 \end_layout
2780 \begin_layout Subsection
2781 movie.read_rtc: Read current RTC time
2782 \end_layout
2784 \begin_layout Itemize
2785 Syntax: (number, number) movie.read_rtc()
2786 \end_layout
2788 \begin_layout Standard
2789 Returns the current value of the RTC as a pair (second, subsecond).
2790 \end_layout
2792 \begin_layout Subsection
2793 movie.unsafe_rewind: Fast movie rewind to saved state
2794 \end_layout
2796 \begin_layout Itemize
2797 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
2798 \end_layout
2800 \begin_layout Standard
2801 Start setting point for unsafe rewind or jump to point of unsafe rewind.
2802 \end_layout
2804 \begin_layout Itemize
2805 If called without argument, causes emulator to start process of setting
2806  unsafe rewind point.
2807  When this has finished, callback on_set_rewind occurs, passing the rewind
2808  state to lua script.
2809 \end_layout
2811 \begin_layout Itemize
2812 If called with argument, causes emulator rewind to passed rewind point as
2813  soon as possible.
2814  Readwrite mode is implicitly activated.
2815 \end_layout
2817 \begin_layout Standard
2818 The following warnings apply to unsafe rewinding:
2819 \end_layout
2821 \begin_layout Itemize
2822 There are no safety checks against misuse (that's what 
2823 \begin_inset Quotes eld
2824 \end_inset
2826 unsafe
2827 \begin_inset Quotes erd
2828 \end_inset
2830  comes from)!
2831 \end_layout
2833 \begin_layout Itemize
2834 Only call rewind from timeline rewind point was set from.
2835 \end_layout
2837 \begin_layout Itemize
2838 Only call rewind from after the rewind point was set.
2839 \end_layout
2841 \begin_layout Subsection
2842 movie.to_rewind: Load savestate as rewind point
2843 \end_layout
2845 \begin_layout Itemize
2846 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
2847 \end_layout
2849 \begin_layout Standard
2850 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
2851  corresponding to it.
2852 \end_layout
2854 \begin_layout Itemize
2855 Note: This operation does not take emulated time.
2856 \end_layout
2858 \begin_layout Subsection
2859 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
2860 \end_layout
2862 \begin_layout Itemize
2863 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
2864 \end_layout
2866 \begin_layout Itemize
2867 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
2868 \end_layout
2870 \begin_layout Standard
2871 Copies specified movie <movie>/current object (if none or nil, the active
2872  movie) as new movie object.
2873 \end_layout
2875 \begin_layout Subsection
2876 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
2877 \end_layout
2879 \begin_layout Itemize
2880 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
2881 \end_layout
2883 \begin_layout Itemize
2884 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
2885 \end_layout
2887 \begin_layout Standard
2888 Get INPUTFRAME object corresponding to specified frame in specified movie.
2889 \end_layout
2891 \begin_layout Subsection
2892 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
2893 \end_layout
2895 \begin_layout Itemize
2896 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
2897  data)
2898 \end_layout
2900 \begin_layout Itemize
2901 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
2902 \end_layout
2904 \begin_layout Standard
2905 Set data in specified frame.
2906 \end_layout
2908 \begin_layout Itemize
2909 Note: Past can't be edited in active movie.
2910 \end_layout
2912 \begin_layout Subsection
2913 movie.get_size/INPUTMOVIE::get_size: Get size of movie
2914 \end_layout
2916 \begin_layout Itemize
2917 Syntax: integer movie.get_size([INPUTMOVIE movie])
2918 \end_layout
2920 \begin_layout Itemize
2921 Syntax: integer INPUTMOVIE::get_size()
2922 \end_layout
2924 \begin_layout Standard
2925 Return number of subframes in specified movie.
2926 \end_layout
2928 \begin_layout Subsection
2929 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
2930 \end_layout
2932 \begin_layout Itemize
2933 Syntax: number movie.count_frames([INPUTMOVIE movie])
2934 \end_layout
2936 \begin_layout Itemize
2937 Syntax: number INPUTMOVIE::count_frames()
2938 \end_layout
2940 \begin_layout Standard
2941 Return number of frames in movie.
2942 \end_layout
2944 \begin_layout Subsection
2945 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
2946 \end_layout
2948 \begin_layout Itemize
2949 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
2950 \end_layout
2952 \begin_layout Itemize
2953 Syntax: number INPUTMOVIE::find_frame(number frame)
2954 \end_layout
2956 \begin_layout Standard
2957 Returns starting subframe of given frame (frame numbers are 1-based).
2958  Returns -1 if frame number is bad.
2959 \end_layout
2961 \begin_layout Subsection
2962 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
2963 \end_layout
2965 \begin_layout Itemize
2966 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
2967 \end_layout
2969 \begin_layout Itemize
2970 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
2971 \end_layout
2973 \begin_layout Standard
2974 Return blank INPUTFRAME with frame type from specified movie.
2975 \end_layout
2977 \begin_layout Subsection
2978 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
2979 \end_layout
2981 \begin_layout Itemize
2982 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
2983 \end_layout
2985 \begin_layout Itemize
2986 Syntax: none INPUTMOVIE::append_frames(number frames)
2987 \end_layout
2989 \begin_layout Standard
2990 Append specified number <frames> of frames.
2991 \end_layout
2993 \begin_layout Subsection
2994 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
2995 \end_layout
2997 \begin_layout Itemize
2998 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
2999 \end_layout
3001 \begin_layout Itemize
3002 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
3003 \end_layout
3005 \begin_layout Standard
3006 Append specified frame <frame>.
3007  Past of current movie can't be edited.
3008 \end_layout
3010 \begin_layout Subsection
3011 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
3012 \end_layout
3014 \begin_layout Itemize
3015 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
3016 \end_layout
3018 \begin_layout Itemize
3019 Syntax: none INPUTMOVIE::truncate(number frames)
3020 \end_layout
3022 \begin_layout Standard
3023 Truncate the specified movie to specified number of frames.
3024 \end_layout
3026 \begin_layout Subsection
3027 movie.edit/INPUTMOVIE::edit: Edit a movie
3028 \end_layout
3030 \begin_layout Itemize
3031 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
3032  controller, number control, number/bool value)
3033 \end_layout
3035 \begin_layout Itemize
3036 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
3037  number control, number/bool value)
3038 \end_layout
3040 \begin_layout Standard
3041 Change specified control in specified frame in specified movie.
3042  Past can't be edited in active movie.
3043 \end_layout
3045 \begin_layout Subsection
3046 movie.copy_frames2: Copy frames between movies
3047 \end_layout
3049 \begin_layout Itemize
3050 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
3051  srcmov,] number src, number count)
3052 \end_layout
3054 \begin_layout Standard
3055 Copy specified number of frames between two movies.
3056  The copy proceeeds in forward direction.
3057 \end_layout
3059 \begin_layout Subsection
3060 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
3061 \end_layout
3063 \begin_layout Itemize
3064 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
3065  number count, bool backwards)
3066 \end_layout
3068 \begin_layout Itemize
3069 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
3070  bool backwards)
3071 \end_layout
3073 \begin_layout Standard
3074 Copy specified number of frames from one point in movie to another.
3075  If backwards is true, the copy will be done backwards.
3076 \end_layout
3078 \begin_layout Subsection
3079 movie.serialize/INPUTMOVIE::serialize: Serialize movie
3080 \end_layout
3082 \begin_layout Itemize
3083 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
3084 \end_layout
3086 \begin_layout Itemize
3087 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
3088 \end_layout
3090 \begin_layout Standard
3091 Serialize given movie into file.
3092  If binary is true, binary format (more compact and much faster) is used.
3093 \end_layout
3095 \begin_layout Subsection
3096 movie.unserialize: Unserialize movie
3097 \end_layout
3099 \begin_layout Itemize
3100 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
3101  bool binary)
3102 \end_layout
3104 \begin_layout Standard
3105 Unserialize movie from file.
3106  The given frame is used as template to decide the frame type.
3107  If binary is true, binary format is decoded (much faster).
3108 \end_layout
3110 \begin_layout Subsection
3111 movie.current_first_subframe: Return first subframe in current frame
3112 \end_layout
3114 \begin_layout Itemize
3115 Syntax: number movie.current_first_subframe()
3116 \end_layout
3118 \begin_layout Standard
3119 Returns first subframe in current frame.
3120 \end_layout
3122 \begin_layout Subsection
3123 movie.pollcounter: Return poll counter for speified control
3124 \end_layout
3126 \begin_layout Itemize
3127 Syntax: number movie.pollcounter(number port, number controller, number control)
3128 \end_layout
3130 \begin_layout Standard
3131 Returns number of times the specified control has been polled this frame.
3132 \end_layout
3134 \begin_layout Subsection
3135 INPUTFRAME::get_button: Get button
3136 \end_layout
3138 \begin_layout Itemize
3139 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
3140  control)
3141 \end_layout
3143 \begin_layout Standard
3144 Returns state of given button as boolean.
3145 \end_layout
3147 \begin_layout Subsection
3148 INPUTFRAME::get_axis: Get axis
3149 \end_layout
3151 \begin_layout Itemize
3152 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
3153  control)
3154 \end_layout
3156 \begin_layout Standard
3157 Returns state of given axis as number.
3158 \end_layout
3160 \begin_layout Subsection
3161 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
3162 \end_layout
3164 \begin_layout Itemize
3165 Syntax: none INPUTFRAME::set_button(number port, number controller, number
3166  control, number/bool value)
3167 \end_layout
3169 \begin_layout Itemize
3170 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
3171  control)
3172 \end_layout
3174 \begin_layout Standard
3175 Set the given button/axis to given value.
3176 \end_layout
3178 \begin_layout Subsection
3179 INPUTFRAME::serialize: Serialize a frame
3180 \end_layout
3182 \begin_layout Itemize
3183 Syntax: string INPUTFRAME::serialize()
3184 \end_layout
3186 \begin_layout Standard
3187 Return string representation of frame.
3188 \end_layout
3190 \begin_layout Subsection
3191 INPUTFRAME::unserialize: Unserialize a frame
3192 \end_layout
3194 \begin_layout Itemize
3195 Syntax: none INPUTFRAME::unserialize(string data)
3196 \end_layout
3198 \begin_layout Standard
3199 Set current frame from given data.
3200 \end_layout
3202 \begin_layout Subsection
3203 INPUTFRAME::get_stride: Get movie stride
3204 \end_layout
3206 \begin_layout Itemize
3207 Syntax: number INPUTFRAME::get_stride()
3208 \end_layout
3210 \begin_layout Standard
3211 Return number of bytes needed to store the input frame.
3212  Mainly useful for some debugging.
3213 \end_layout
3215 \begin_layout Standard
3216 \begin_inset Newpage pagebreak
3217 \end_inset
3220 \end_layout
3222 \begin_layout Section
3223 Table settings
3224 \end_layout
3226 \begin_layout Standard
3227 Routines for settings manipulation
3228 \end_layout
3230 \begin_layout Subsection
3231 settings.get: Get value of setting
3232 \end_layout
3234 \begin_layout Itemize
3235 Syntax: string settings.get(string name)
3236 \end_layout
3238 \begin_layout Standard
3239 Get value of setting <name>.
3240  If setting value can't be obtained, returns (nil, error message).
3241 \end_layout
3243 \begin_layout Subsection
3244 settings.set: Set value of setting
3245 \end_layout
3247 \begin_layout Itemize
3248 Syntax: none settings.set(string name, string value)
3249 \end_layout
3251 \begin_layout Standard
3252 Set value <value> of setting <name>.
3253  If setting can't be set, returns (nil, error message).
3254 \end_layout
3256 \begin_layout Standard
3257 \begin_inset Newpage pagebreak
3258 \end_inset
3261 \end_layout
3263 \begin_layout Section
3264 Table memory
3265 \end_layout
3267 \begin_layout Standard
3268 Contains various functions for managing memory
3269 \end_layout
3271 \begin_layout Subsection
3272 memory.vma_count: Count number of VMAs.
3273 \end_layout
3275 \begin_layout Itemize
3276 Syntax: number memory.vma_count()
3277 \end_layout
3279 \begin_layout Standard
3280 Returns the number of VMAs
3281 \end_layout
3283 \begin_layout Subsection
3284 memory.read_vma: Lookup VMA info by index
3285 \end_layout
3287 \begin_layout Itemize
3288 Syntax: string memory.read_vma(number index)
3289 \end_layout
3291 \begin_layout Standard
3292 Reads the specified VMA (indices start from zero).
3293  Trying to read invalid VMA gives nil.
3294  The read VMA is table with the following fields:
3295 \end_layout
3297 \begin_layout Itemize
3298 region_name (string): The readable name of the VMA
3299 \end_layout
3301 \begin_layout Itemize
3302 baseaddr (number): Base address of the VMA
3303 \end_layout
3305 \begin_layout Itemize
3306 lastaddr (number): Last address in the VMA.
3307 \end_layout
3309 \begin_layout Itemize
3310 size (number): The size of VMA in bytes.
3311 \end_layout
3313 \begin_layout Itemize
3314 readonly (boolean): True of the VMA corresponds to ROM.
3315 \end_layout
3317 \begin_layout Itemize
3318 iospace (boolean): True if the VMA is I/O space.
3319 \end_layout
3321 \begin_layout Itemize
3322 native_endian (boolean): True if the VMA has native endian as opposed to
3323  little endian.
3324 \end_layout
3326 \begin_layout Subsection
3327 memory.find_vma: Find VMA info by address
3328 \end_layout
3330 \begin_layout Itemize
3331 Syntax: table memory.find_vma(number address)
3332 \end_layout
3334 \begin_layout Standard
3335 Finds the VMA containing specified address.
3336  Returns table in the same format as read_vma or nil if not found.
3337 \end_layout
3339 \begin_layout Subsection
3340 memory.read{,s}{byte,{,h,d,q}word}: Read memory
3341 \end_layout
3343 \begin_layout Itemize
3344 Syntax: none memory.readbyte([string vma, ]number address)
3345 \end_layout
3347 \begin_layout Itemize
3348 Syntax: none memory.readword([string vma, ]number address)
3349 \end_layout
3351 \begin_layout Itemize
3352 Syntax: none memory.readhword([string vma, ]number address)
3353 \end_layout
3355 \begin_layout Itemize
3356 Syntax: none memory.readdword([string vma, ]number address)
3357 \end_layout
3359 \begin_layout Itemize
3360 Syntax: none memory.readqword([string vma, ]number address)
3361 \end_layout
3363 \begin_layout Itemize
3364 Syntax: none memory.readsbyte([string vma, ]number address)
3365 \end_layout
3367 \begin_layout Itemize
3368 Syntax: none memory.readsword([string vma, ]number address)
3369 \end_layout
3371 \begin_layout Itemize
3372 Syntax: none memory.readshword([string vma, ]number address)
3373 \end_layout
3375 \begin_layout Itemize
3376 Syntax: none memory.readsdword([string vma, ]number address)
3377 \end_layout
3379 \begin_layout Itemize
3380 Syntax: none memory.readsqword([string vma, ]number address)
3381 \end_layout
3383 \begin_layout Standard
3384 Reads the specified address <address> (if 's' variant is used, do undergo
3385  2's complement).
3386 \end_layout
3388 \begin_layout Subsection
3389 memory.{,s}read_sg: Scatter/Gather read memory
3390 \end_layout
3392 \begin_layout Itemize
3393 Syntax: none memory.read_sg(string/boolean/number...)
3394 \end_layout
3396 \begin_layout Itemize
3397 Syntax: none memory.sread_sg(string/boolean/number...)
3398 \end_layout
3400 \begin_layout Standard
3401 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
3402  of memory.
3403  Each argument can be string, boolean or number:
3404 \end_layout
3406 \begin_layout Itemize
3407 String: Set VMA addresses are relative to (e.g.
3408  'WRAM').
3409 \end_layout
3411 \begin_layout Itemize
3412 boolean: If true, increment relative address by 1, if false, decrement by
3413  1.
3414  The new address is read as next higher byte.
3415 \end_layout
3417 \begin_layout Itemize
3418 integer: Set the relative address to specified value and read the address
3419  as next higher byte.
3420 \end_layout
3422 \begin_layout Subsection
3423 memory.write_sg: Scatter/Gather write memory
3424 \end_layout
3426 \begin_layout Itemize
3427 Syntax: none memory.write_sg(number value, string/boolean/number...)
3428 \end_layout
3430 \begin_layout Standard
3431 Perform scatter/gather write of value <value> on memory.
3432  Each argument can be string, boolean or number:
3433 \end_layout
3435 \begin_layout Itemize
3436 String: Set VMA addresses are relative to (e.g.
3437  'WRAM').
3438 \end_layout
3440 \begin_layout Itemize
3441 boolean: If true, increment relative address by 1, if false, decrement by
3442  1.
3443  The new address is read as next higher byte.
3444 \end_layout
3446 \begin_layout Itemize
3447 integer: Set the relative address to specified value and read the address
3448  as next higher byte.
3449 \end_layout
3451 \begin_layout Subsection
3452 memory.read{float,double}: Read memory
3453 \end_layout
3455 \begin_layout Itemize
3456 Syntax: none memory.readfloat([string vma, ]number address)
3457 \end_layout
3459 \begin_layout Itemize
3460 Syntax: none memory.readdouble([string vma, ]number address)
3461 \end_layout
3463 \begin_layout Standard
3464 Reads the specified address <address>
3465 \end_layout
3467 \begin_layout Subsection
3468 memory.write{byte,{,h,d,q}word,float,double}: Write memory
3469 \end_layout
3471 \begin_layout Itemize
3472 Syntax: none memory.writebyte([string vma, ]number address, number value)
3473 \end_layout
3475 \begin_layout Itemize
3476 Syntax: none memory.writeword([string vma, ]number address, number value)
3477 \end_layout
3479 \begin_layout Itemize
3480 Syntax: none memory.writehword([string vma, ]number address, number value)
3481 \end_layout
3483 \begin_layout Itemize
3484 Syntax: none memory.writedword([string vma, ]number address, number value)
3485 \end_layout
3487 \begin_layout Itemize
3488 Syntax: none memory.writeqword([string vma, ]number address, number value)
3489 \end_layout
3491 \begin_layout Itemize
3492 Syntax: none memory.writefloat([string vma, ]number address, number value)
3493 \end_layout
3495 \begin_layout Itemize
3496 Syntax: none memory.writedouble([string vma, ]number address, number value)
3497 \end_layout
3499 \begin_layout Standard
3500 Writes the specified value <value> (negative integer values undergo 2's
3501  complement) to specified address <address>.
3502 \end_layout
3504 \begin_layout Subsection
3505 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
3506 \end_layout
3508 \begin_layout Itemize
3509 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
3510 \end_layout
3512 \begin_layout Standard
3513 Returns a table mapping specified memory aperture for read/write.
3514  If parameters are omitted, entiere map space is the aperture.
3515 \end_layout
3517 \begin_layout Itemize
3518 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
3519  qword, sqword, float or double.
3520 \end_layout
3522 \begin_layout Subsection
3523 memory.hash_region: Hash region of memory
3524 \end_layout
3526 \begin_layout Itemize
3527 Syntax: string memory.hash_region([string vma, ]number base, number size)
3528 \end_layout
3530 \begin_layout Standard
3531 Hash specified number of bytes starting from specified address and return
3532  the SHA-256.
3533 \end_layout
3535 \begin_layout Subsection
3536 memory.hash_state: Hash system state
3537 \end_layout
3539 \begin_layout Itemize
3540 Syntax: string memory.hash_state()
3541 \end_layout
3543 \begin_layout Standard
3544 Hash the current system state.
3545  Mainly useful for debugging savestates.
3546 \end_layout
3548 \begin_layout Subsection
3549 memory.readregion: Read region of memory
3550 \end_layout
3552 \begin_layout Itemize
3553 Syntax: table memory.readregion([string vma, ]number base, number size)
3554 \end_layout
3556 \begin_layout Standard
3557 Read a region of memory.
3558 \end_layout
3560 \begin_layout Itemize
3561 Warning: If the region crosses VMA boundary, the results are undefined.
3562 \end_layout
3564 \begin_layout Subsection
3565 memory.writeregion: Write region of memory
3566 \end_layout
3568 \begin_layout Itemize
3569 Syntax: none memory.writeregion([string vma, ]number base, number size, table
3570  data)
3571 \end_layout
3573 \begin_layout Standard
3574 Write a region of memory.
3575 \end_layout
3577 \begin_layout Itemize
3578 Warning: If the region crosses VMA boundary, the results are undefined.
3579 \end_layout
3581 \begin_layout Subsection
3582 memory.map_structure: Create mmap structure
3583 \end_layout
3585 \begin_layout Itemize
3586 syntax: MMAP_STRUCT memory.map_structure()
3587 \end_layout
3589 \begin_layout Standard
3590 Returns a new mapping structure (MMAP_STRUCT)
3591 \end_layout
3593 \begin_layout Subsection
3594 MMAP_STRUCT(): Bind key in mmap structure
3595 \end_layout
3597 \begin_layout Itemize
3598 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
3599  type)
3600 \end_layout
3602 \begin_layout Standard
3603 Bind key <key> in mmap structure to specified address <address> with specified
3604  type <type>.
3605 \end_layout
3607 \begin_layout Itemize
3608 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
3609  qword, sqword, float or double.
3610 \end_layout
3612 \begin_layout Subsection
3613 memory.read_expr: Evaluate memory watch expression
3614 \end_layout
3616 \begin_layout Itemize
3617 Syntax: string memory.read_expr(string expr)
3618 \end_layout
3620 \begin_layout Standard
3621 Evaluate specified watch expression and return result
3622 \end_layout
3624 \begin_layout Subsection
3625 memory.action: Run core action
3626 \end_layout
3628 \begin_layout Itemize
3629 memory.action(string action, [<params>])
3630 \end_layout
3632 \begin_layout Standard
3633 Run core action.
3634  The different models expect parameters as:
3635 \end_layout
3637 \begin_layout Itemize
3638 string: String
3639 \end_layout
3641 \begin_layout Itemize
3642 numeric: numeric
3643 \end_layout
3645 \begin_layout Itemize
3646 enumeration: String
3647 \end_layout
3649 \begin_layout Itemize
3650 boolean: String
3651 \end_layout
3653 \begin_layout Itemize
3654 toggle: None.
3655 \end_layout
3657 \begin_layout Subsection
3658 memory.get_lag_flag: Get lag flag
3659 \end_layout
3661 \begin_layout Itemize
3662 Syntax: boolean memory.get_lag_flag()
3663 \end_layout
3665 \begin_layout Standard
3666 Get the value of core lag flag.
3667  True if this frame has been lag so far, false if poll has been detected.
3668 \end_layout
3670 \begin_layout Subsection
3671 memory.set_lag_flag: Set lag flag
3672 \end_layout
3674 \begin_layout Itemize
3675 Syntax: none memory.set_lag_flag(boolean flag)
3676 \end_layout
3678 \begin_layout Standard
3679 Set the value of core lag flag.
3680  This flag automatically gets cleared if poll is detected, but can be forcibly
3681  set or cleared if game so requires.
3682 \end_layout
3684 \begin_layout Itemize
3685 Should only be used in on_frame_emulated callback.
3686 \end_layout
3688 \begin_layout Itemize
3689 Setting or clearing this affects the emulator lag counter.
3690 \end_layout
3692 \begin_layout Subsection
3693 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
3694  callback
3695 \end_layout
3697 \begin_layout Itemize
3698 Syntax: function memory.registerread([string vma, ] number addr, function
3699  fn);
3700 \end_layout
3702 \begin_layout Itemize
3703 Syntax: function memory.registerwrite([string vma, ] number addr, function
3704  fn);
3705 \end_layout
3707 \begin_layout Itemize
3708 Syntax: function memory.registerexec([string vma, ] number addr, function
3709  fn);
3710 \end_layout
3712 \begin_layout Itemize
3713 Syntax: none memory.unregisterread([string vma, ] number addr, function fn);
3714 \end_layout
3716 \begin_layout Itemize
3717 Syntax: none memory.unregisterwrite([string vma, ] number addr, function
3718  fn);
3719 \end_layout
3721 \begin_layout Itemize
3722 Syntax: none memory.unregisterexec([string vma, ] number addr, function fn);
3723 \end_layout
3725 \begin_layout Standard
3726 Add or remove callback on memory read, write or execute (depending on the
3727  function).
3728  If <vma> is specified, <addr> is relative to it, otherwise <addr> is global.
3729  <fn> is the callback.
3730  The register* functions return <fn> (which can then be passed to unregister*
3731  functions.
3732 \end_layout
3734 \begin_layout Itemize
3735 Not all cores support this, and it may be unsupported for some VMAs.
3736 \end_layout
3738 \begin_layout Itemize
3739 The functions are passed two parameters: Address and value.
3740 \end_layout
3742 \begin_layout Subsection
3743 memory.{,un}registertrace: Set/Clear trace hook
3744 \end_layout
3746 \begin_layout Itemize
3747 Syntax: function memory.registertrace(number processor, function fn);
3748 \end_layout
3750 \begin_layout Itemize
3751 Syntax: none memory.unregistertrace(number processor, function fn);
3752 \end_layout
3754 \begin_layout Standard
3755 Add or remove trace callback.
3756  <processor> is system-dependent processor number (0 is usually main CPU).
3757  The function arguments work like in other (un)register* functions.
3758 \end_layout
3760 \begin_layout Itemize
3761 The functions are passed two parameters: Trace CPU and Trace event string.
3762 \end_layout
3764 \begin_layout Subsection
3765 memory.cheat: Set cheat
3766 \end_layout
3768 \begin_layout Itemize
3769 Syntax: none memory.cheat([string vma, ] number addr, number value);
3770 \end_layout
3772 \begin_layout Itemize
3773 Syntax: none memory.cheat([string vma, ] number addr);
3774 \end_layout
3776 \begin_layout Standard
3777 Set or clear cheat (value <value>) on address <addr>.
3778  If <vma> is specified, <addr> is relative to that.
3779  If <value> is not speicified, clear a cheat.
3780 \end_layout
3782 \begin_layout Itemize
3783 Not all cores support this, and it may be unsupported for some VMAs.
3784 \end_layout
3786 \begin_layout Subsection
3787 memory.setxmask: Set global execute hook mask
3788 \end_layout
3790 \begin_layout Itemize
3791 Syntax: none memory.setxmask(number mask)
3792 \end_layout
3794 \begin_layout Standard
3795 Set the global execute hook mask to <mask>.
3796  The meaning of each bit is system-dependent, but bit 0 should be the main
3797  CPU.
3798 \end_layout
3800 \begin_layout Standard
3801 \begin_inset Newpage pagebreak
3802 \end_inset
3805 \end_layout
3807 \begin_layout Section
3808 Table memory2
3809 \end_layout
3811 \begin_layout Standard
3812 Contains newer memory functions.
3813 \end_layout
3815 \begin_layout Subsection
3816 memory2(): Get all VMA names.
3817 \end_layout
3819 \begin_layout Itemize
3820 Syntax: table memory2()
3821 \end_layout
3823 \begin_layout Standard
3824 Returns array of all valid VMA names.
3825 \end_layout
3827 \begin_layout Subsection
3828 memory2.<vma>:info: Get VMA info
3829 \end_layout
3831 \begin_layout Itemize
3832 Syntax: table memory2.<vma>:info()
3833 \end_layout
3835 \begin_layout Standard
3836 Return table describing given VMA.
3837  Includes fields address, size, last, readonly, special and endian.
3838 \end_layout
3840 \begin_layout Subsection
3841 memory2.<vma>:<op>: Read/Write memory
3842 \end_layout
3844 \begin_layout Itemize
3845 Syntax: none memory2.<vma>:<op>(number offset, number value)
3846 \end_layout
3848 \begin_layout Itemize
3849 Syntax: number memory2.<vma>:<op>(number offset)
3850 \end_layout
3852 \begin_layout Standard
3853 Read/Write value from/to given VMA <vma> at given offset <offset> (must
3854  be in-range).
3855  The value written is <value>.
3856  <Op> is of form: [i][s]<type>, where:
3857 \end_layout
3859 \begin_layout Itemize
3860 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
3861 \end_layout
3863 \begin_layout Itemize
3864 'i' signifies that the value is treated as opposite-to-normal endianess,
3865 \end_layout
3867 \begin_layout Itemize
3868 's' signifies that value is treated as signed (not available for floating-point).
3869 \end_layout
3871 \begin_layout Subsection
3872 memory2.<vma>:read: Scatter-gather value read
3873 \end_layout
3875 \begin_layout Itemize
3876 Syntax: number memory2.<vma>:read(number addr...)
3877 \end_layout
3879 \begin_layout Standard
3880 Read value from given VMA <vma> at byte offsets <addr>..., given in order of
3881  increasing significance.
3882  Value of true and false are special.
3883  True increments address by 1, and false decrements address by 1.
3884 \end_layout
3886 \begin_layout Subsection
3887 memory2.<vma>:sread: Signed scatter-gather value read
3888 \end_layout
3890 \begin_layout Itemize
3891 Syntax: number memory2.<vma>:sread(number addr...)
3892 \end_layout
3894 \begin_layout Standard
3895 Like memory2.<vma>:read, but reads signed values.
3896 \end_layout
3898 \begin_layout Subsection
3899 memory2.<vma>:write: Scatter-gather value write
3900 \end_layout
3902 \begin_layout Itemize
3903 Syntax: number memory2.<vma>:write(number val, number addr...)
3904 \end_layout
3906 \begin_layout Standard
3907 Write value <val> to given VMA <vma> at byte offsets <addr>..., given in order
3908  of increasing significance.
3909  Value of true and false are special.
3910  True increments address by 1, and false decrements address by 1.
3911 \end_layout
3913 \begin_layout Standard
3914 \begin_inset Newpage pagebreak
3915 \end_inset
3918 \end_layout
3920 \begin_layout Section
3921 Table callback
3922 \end_layout
3924 \begin_layout Standard
3925 Various callback-related functions.
3926 \end_layout
3928 \begin_layout Subsection
3929 \begin_inset CommandInset label
3930 LatexCommand label
3931 name "sub:callback.register:-Register-a"
3933 \end_inset
3935 callback.register: Register a callback
3936 \end_layout
3938 \begin_layout Itemize
3939 Syntax: function callback.register(string cbname, function cbfun);
3940 \end_layout
3942 \begin_layout Standard
3943 Instruct function <cbfun> to be added to list of callbacks to call on event
3944  <cbname> (See section 
3945 \begin_inset CommandInset ref
3946 LatexCommand ref
3947 reference "sec:Callbacks"
3949 \end_inset
3952  The callback name does not have the 'on_' prefix (e.g.
3954 \begin_inset Quotes eld
3955 \end_inset
3957 paint
3958 \begin_inset Quotes erd
3959 \end_inset
3962  Returns <cbfun>.
3963 \end_layout
3965 \begin_layout Subsection
3966 \begin_inset CommandInset label
3967 LatexCommand label
3968 name "sub:callback.unregister:-Unregister-"
3970 \end_inset
3972 callback.unregister: Unregister a callback
3973 \end_layout
3975 \begin_layout Itemize
3976 Syntax: function callback.unregister(string cbname, function cbfun);
3977 \end_layout
3979 \begin_layout Standard
3980 Instruct function <cbfun> to be removed from list of callbacks to call on
3981  event <cbname>.
3982 \end_layout
3984 \begin_layout Subsection
3985 callback.<cbname>:register: Register callback
3986 \end_layout
3988 \begin_layout Itemize
3989 Syntax: function callback.<cbname>:register(function cbfun)
3990 \end_layout
3992 \begin_layout Standard
3993 Synonym for callback.register (section 
3994 \begin_inset CommandInset ref
3995 LatexCommand ref
3996 reference "sub:callback.register:-Register-a"
3998 \end_inset
4000 ), albeit with callback name specified differently.
4001 \end_layout
4003 \begin_layout Subsection
4004 callback.<cbname>:unregister: Register callback
4005 \end_layout
4007 \begin_layout Itemize
4008 Syntax: function callback.<cbname>:unregister(function cbfun)
4009 \end_layout
4011 \begin_layout Standard
4012 Synonym for callback.unregister (section 
4013 \begin_inset CommandInset ref
4014 LatexCommand ref
4015 reference "sub:callback.unregister:-Unregister-"
4017 \end_inset
4019 ), albeit with callback name specified differently.
4020 \end_layout
4022 \begin_layout Section
4023 table bsnes
4024 \end_layout
4026 \begin_layout Standard
4027 Various bsnes-specific functions.
4028 \end_layout
4030 \begin_layout Subsection
4031 bsnes.dump_sprite: Dump a sprite
4032 \end_layout
4034 \begin_layout Itemize
4035 Syntax: BITMAP bsnes.dump_sprite([string vma, ] number addr, number width,
4036  number height[, number stride])
4037 \end_layout
4039 \begin_layout Standard
4040 Dumps given sprite (in native format) from memory.
4041  VMA is usually 
4042 \begin_inset Quotes eld
4043 \end_inset
4045 VRAM
4046 \begin_inset Quotes erd
4047 \end_inset
4050  <Width> and <height> are given in 8x8 blocks.
4051  <Stride> overrides row stride (default 512).
4052 \end_layout
4054 \begin_layout Subsection
4055 bsnes.dump_palette: Dump a palette
4056 \end_layout
4058 \begin_layout Itemize
4059 Syntax: PALETTE bsnes.dump_palette([string vma, ] number addr, bool full256,
4060  bool first_trans)
4061 \end_layout
4063 \begin_layout Standard
4064 Dumps a palette from memory.
4065  VMA is usually 
4066 \begin_inset Quotes eld
4067 \end_inset
4069 CGRAM
4070 \begin_inset Quotes erd
4071 \end_inset
4074  If <full256> is true, 256 colors are dumped (otherwise 16).
4075  If <first_trans> is true, first color is forced transparent.
4076 \end_layout
4078 \begin_layout Section
4079 Table _SYSTEM
4080 \end_layout
4082 \begin_layout Standard
4083 Contains copy of global variables from time of Lua initialization.
4084  Non-writeable.
4085 \end_layout
4087 \begin_layout Standard
4088 \begin_inset Newpage pagebreak
4089 \end_inset
4092 \end_layout
4094 \begin_layout Section
4095 \begin_inset CommandInset label
4096 LatexCommand label
4097 name "sec:Callbacks"
4099 \end_inset
4101 Callbacks
4102 \end_layout
4104 \begin_layout Standard
4105 Various callbacks to Lua that can occur.
4106 \end_layout
4108 \begin_layout Subsection
4109 on_paint: Screen is being painted
4110 \end_layout
4112 \begin_layout Itemize
4113 Callback: on_paint(bool not_synth)
4114 \end_layout
4116 \begin_layout Standard
4117 Called when screen is being painted.
4118  Any gui.* calls requiring graphic context draw on the screen.
4119 \end_layout
4121 \begin_layout Itemize
4122 not_synth is true if this hook is being called in response to received frame,
4123  false otherwise.
4124 \end_layout
4126 \begin_layout Subsection
4127 on_video: Dumped video frame is being painted
4128 \end_layout
4130 \begin_layout Itemize
4131 Callback: on_video()
4132 \end_layout
4134 \begin_layout Standard
4135 Called when video dump frame is being painted.
4136  Any gui.* calls requiring graphic context draw on the video.
4137 \end_layout
4139 \begin_layout Subsection
4140 on_frame_emulated: Frame emulation complete
4141 \end_layout
4143 \begin_layout Itemize
4144 Callback: on_frame_emulated()
4145 \end_layout
4147 \begin_layout Standard
4148 Called when emulating frame has completed and on_paint()/on_video() calls
4149  are about to be issued.
4150 \end_layout
4152 \begin_layout Subsection
4153 on_frame: Frame emulation starting.
4154 \end_layout
4156 \begin_layout Itemize
4157 Callback: on_frame()
4158 \end_layout
4160 \begin_layout Standard
4161 Called on each starting whole frame.
4162 \end_layout
4164 \begin_layout Subsection
4165 on_startup: Emulator startup complete
4166 \end_layout
4168 \begin_layout Itemize
4169 Callback: on_startup()
4170 \end_layout
4172 \begin_layout Standard
4173 Called when the emulator is starting (lsnes.rc and --run files has been run).
4174 \end_layout
4176 \begin_layout Subsection
4177 on_rewind: Movie rewound to beginning
4178 \end_layout
4180 \begin_layout Itemize
4181 Callback: on_rewind()
4182 \end_layout
4184 \begin_layout Standard
4185 Called when rewind movie to beginning has completed.
4186 \end_layout
4188 \begin_layout Subsection
4189 on_pre_load: Load operation is about to start
4190 \end_layout
4192 \begin_layout Itemize
4193 Callback: on_pre_load(string name)
4194 \end_layout
4196 \begin_layout Standard
4197 Called just before savestate/movie load occurs (note: loads are always delayed,
4198  so this occurs even when load was initiated by lua).
4199 \end_layout
4201 \begin_layout Subsection
4202 on_err_Load: Load failed
4203 \end_layout
4205 \begin_layout Itemize
4206 Callback: on_err_load(string name)
4207 \end_layout
4209 \begin_layout Standard
4210 Called if loadstate goes wrong.
4211 \end_layout
4213 \begin_layout Subsection
4214 on_post_load: Load completed
4215 \end_layout
4217 \begin_layout Itemize
4218 Callback: on_post_load(string name, boolean was_savestate)
4219 \end_layout
4221 \begin_layout Standard
4222 Called on successful loadstate.
4223  was_savestate gives if this was a savestate or a movie.
4224 \end_layout
4226 \begin_layout Subsection
4227 on_pre_save: Save operation is about to start
4228 \end_layout
4230 \begin_layout Itemize
4231 Callback: on_pre_save(string name, boolean is_savestate)
4232 \end_layout
4234 \begin_layout Standard
4235 Called just before savestate save occurs (note: movie saves are synchronous
4236  and won't trigger these callbacks if called from Lua).
4237 \end_layout
4239 \begin_layout Subsection
4240 on_err_save: Save failed
4241 \end_layout
4243 \begin_layout Itemize
4244 Callback: on_err_save(string name)
4245 \end_layout
4247 \begin_layout Standard
4248 Called if savestate goes wrong.
4249 \end_layout
4251 \begin_layout Subsection
4252 on_post_save: Save completed
4253 \end_layout
4255 \begin_layout Itemize
4256 Callback: on_post_save(string name, boolean is_savestate)
4257 \end_layout
4259 \begin_layout Standard
4260 Called on successful savaestate.
4261  is_savestate gives if this was a savestate or a movie.
4262 \end_layout
4264 \begin_layout Subsection
4265 on_quit: Emulator is shutting down
4266 \end_layout
4268 \begin_layout Itemize
4269 Callback: on_quit()
4270 \end_layout
4272 \begin_layout Standard
4273 Called when emulator is shutting down.
4274 \end_layout
4276 \begin_layout Subsection
4277 on_input: Polling for input
4278 \end_layout
4280 \begin_layout Standard
4281 Called when emulator is just sending input to bsnes core.
4282  Warning: This is called even in readonly mode, but the results are ignored.
4283 \end_layout
4285 \begin_layout Subsection
4286 on_reset: System has been reset
4287 \end_layout
4289 \begin_layout Itemize
4290 Callback: on_reset()
4291 \end_layout
4293 \begin_layout Standard
4294 Called when system is reset.
4295 \end_layout
4297 \begin_layout Subsection
4298 on_readwrite: Entered readwrite mode
4299 \end_layout
4301 \begin_layout Itemize
4302 Callback: on_readwrite()
4303 \end_layout
4305 \begin_layout Standard
4306 Called when moving into readwrite mode as result of 
4307 \begin_inset Quotes eld
4308 \end_inset
4310 set-rwmode
4311 \begin_inset Quotes erd
4312 \end_inset
4314  command (note: moving to rwmode by Lua won't trigger this, as per recursive
4315  entry protection).
4316 \end_layout
4318 \begin_layout Subsection
4319 on_snoop/on_snoop2: Snoop core controller reads
4320 \end_layout
4322 \begin_layout Itemize
4323 Callback: on_snoop(number port, number controller, number index, number
4324  value)
4325 \end_layout
4327 \begin_layout Itemize
4328 Callback: on_snoop2(number port, number controller, number index, number
4329  value)
4330 \end_layout
4332 \begin_layout Standard
4333 Called each time bsnes asks for input.
4334  The value is the final value to be sent to bsnes core (readonly mode, autohold
4335  and autofire have been taken into account).
4336  Might be useful when translating movies to format suitable for console
4337  verification.
4338  Note: There is no way to modify the value to be sent.
4339 \end_layout
4341 \begin_layout Itemize
4342 On_snoop2 is called instead of on_snoop if defined.
4343  Reserves port 0 for system, having first user port be port 1.
4344 \end_layout
4346 \begin_layout Subsection
4347 on_keyhook: Hooked key/axis has been moved
4348 \end_layout
4350 \begin_layout Itemize
4351 Callback: on_keyhook(string keyname, table state)
4352 \end_layout
4354 \begin_layout Standard
4355 Sent when key that has keyhook events requested changes state.
4356  Keyname is name of the key (group) and state is the state (same kind as
4357  table values in input.raw).
4358 \end_layout
4360 \begin_layout Subsection
4361 on_idle: Idle event
4362 \end_layout
4364 \begin_layout Itemize
4365 Callback: on_idle()
4366 \end_layout
4368 \begin_layout Standard
4369 Called when requested by set_idle_timeout(), the timeout has expired and
4370  emulator is waiting.
4371 \end_layout
4373 \begin_layout Subsection
4374 on_timer: Timer event
4375 \end_layout
4377 \begin_layout Itemize
4378 Callback: on_timer()
4379 \end_layout
4381 \begin_layout Standard
4382 Called when requested by set_idle_timeout() and the timeout has expired
4383  (regardless if emulator is waiting).
4384 \end_layout
4386 \begin_layout Subsection
4387 on_set_rewind: Rewind point has been set
4388 \end_layout
4390 \begin_layout Itemize
4391 Callback: on_set_rewind(UNSAFEREWIND r)
4392 \end_layout
4394 \begin_layout Standard
4395 Called when unsafe rewind object has been constructed.
4396 \end_layout
4398 \begin_layout Subsection
4399 on_pre_rewind: Rewind is about to occur
4400 \end_layout
4402 \begin_layout Itemize
4403 Callback: on_pre_rewind() 
4404 \end_layout
4406 \begin_layout Standard
4407 Called just before unsafe rewind is about to occur.
4408 \end_layout
4410 \begin_layout Subsection
4411 on_post_rewind: Rewind has occured
4412 \end_layout
4414 \begin_layout Itemize
4415 Callback: on_post_rewind() 
4416 \end_layout
4418 \begin_layout Standard
4419 Called just after unsafe rewind has occured.
4420 \end_layout
4422 \begin_layout Subsection
4423 on_button: Button has been pressed
4424 \end_layout
4426 \begin_layout Itemize
4427 Callback: on_button(number port, number controller, number index, string
4428  type)
4429 \end_layout
4431 \begin_layout Standard
4432 Called on controller button press, with following parameters:
4433 \end_layout
4435 \begin_layout Itemize
4436 port: Port number (0 is system)
4437 \end_layout
4439 \begin_layout Itemize
4440 controller: Controller within port
4441 \end_layout
4443 \begin_layout Itemize
4444 index: Index of button.
4445 \end_layout
4447 \begin_layout Itemize
4448 type: Type of event, one of:
4449 \end_layout
4451 \begin_deeper
4452 \begin_layout Itemize
4453 \begin_inset Quotes eld
4454 \end_inset
4456 pressed
4457 \begin_inset Quotes erd
4458 \end_inset
4460 : Button was pressed.
4461 \end_layout
4463 \begin_layout Itemize
4464 \begin_inset Quotes eld
4465 \end_inset
4467 released
4468 \begin_inset Quotes erd
4469 \end_inset
4471 : Button was released.
4472 \end_layout
4474 \begin_layout Itemize
4475 \begin_inset Quotes eld
4476 \end_inset
4478 hold
4479 \begin_inset Quotes erd
4480 \end_inset
4482 : Held.
4483 \end_layout
4485 \begin_layout Itemize
4486 \begin_inset Quotes eld
4487 \end_inset
4489 unhold
4490 \begin_inset Quotes erd
4491 \end_inset
4493 : Released from hold.
4494 \end_layout
4496 \begin_layout Itemize
4497 \begin_inset Quotes eld
4498 \end_inset
4500 type
4501 \begin_inset Quotes erd
4502 \end_inset
4504 : Typing input on button.
4505 \end_layout
4507 \begin_layout Itemize
4508 \begin_inset Quotes eld
4509 \end_inset
4511 untype
4512 \begin_inset Quotes erd
4513 \end_inset
4515 : Typing input undone.
4516 \end_layout
4518 \begin_layout Itemize
4519 \begin_inset Quotes eld
4520 \end_inset
4522 autofire <duty> <cycle>
4523 \begin_inset Quotes erd
4524 \end_inset
4526 : Autofire with specifie duty and cycle.
4527 \end_layout
4529 \begin_layout Itemize
4530 \begin_inset Quotes eld
4531 \end_inset
4533 autofire
4534 \begin_inset Quotes erd
4535 \end_inset
4537 : Stop autofire.
4538 \end_layout
4540 \begin_layout Itemize
4541 \begin_inset Quotes eld
4542 \end_inset
4544 analog
4545 \begin_inset Quotes erd
4546 \end_inset
4548 : Analog action on axis.
4549 \end_layout
4551 \end_deeper
4552 \begin_layout Subsection
4553 on_movie_lost: Movie data is about to be lost
4554 \end_layout
4556 \begin_layout Itemize
4557 Callback: on_movie_lost(STRING kind)
4558 \end_layout
4560 \begin_layout Standard
4561 Called just before something would happen that could lose movie data.
4562  Kind can be:
4563 \end_layout
4565 \begin_layout Itemize
4566 readwrite: Switching to readwrite mode.
4567 \end_layout
4569 \begin_layout Itemize
4570 reload: ROM is being reloaded in readwrite mode.
4571 \end_layout
4573 \begin_layout Itemize
4574 load: New movie is being loaded.
4575 \end_layout
4577 \begin_layout Itemize
4578 unsaferewind: Unsafe rewind is happening.
4579 \end_layout
4581 \begin_layout Subsection
4582 on_latch: Latch line is rising
4583 \end_layout
4585 \begin_layout Itemize
4586 Callback: on_latch(<core-dependent-parameters>)
4587 \end_layout
4589 \begin_layout Standard
4590 Called when latch line for controller is rising.
4591  Some cores may not support this.
4592 \end_layout
4594 \begin_layout Section
4595 System-dependent behaviour
4596 \end_layout
4598 \begin_layout Subsection
4599 bsnes core
4600 \end_layout
4602 \begin_layout Itemize
4603 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
4604  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
4605  p_z, p_c
4606 \end_layout
4608 \begin_layout Itemize
4609 on_latch has no parameters
4610 \end_layout
4612 \begin_layout Itemize
4613 CPU 0 is S-CPU, 1 is S-SMP.
4614 \end_layout
4616 \begin_layout Itemize
4617 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
4618 \end_layout
4620 \begin_layout Itemize
4621 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
4622 {RAM,ROM}.
4623 \end_layout
4625 \begin_layout Subsection
4626 gambatte core
4627 \end_layout
4629 \begin_layout Itemize
4630 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
4631  d, e, f, h, l
4632 \end_layout
4634 \begin_layout Itemize
4635 on_latch is not supported
4636 \end_layout
4638 \begin_layout Itemize
4639 CPU 0 is main CPU.
4640 \end_layout
4642 \begin_layout Itemize
4643 Cheats are supported for ROM, SRAM and WRAM.
4644 \end_layout
4646 \begin_layout Itemize
4647 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
4648  and WRAM.
4649 \end_layout
4651 \begin_layout Itemize
4653 \end_layout
4655 \end_body
4656 \end_document