Lua: Some fixes related to sysrc.lua
[lsnes.git] / lua.lyx
blob786f8f8d24f87a357cb0f0fc9954b8c2892a2b16
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 Classes
129 \end_layout
131 \begin_layout Subsection
132 MMAP_STRUCT: Quasi-table mapping emulated memory
133 \end_layout
135 \begin_layout Standard
136 Objects of this class act like tables, except that the values are reflected
137  in emulated memory.
138 \end_layout
140 \begin_layout Subsubsection
141 static function new: Create new instance
142 \end_layout
144 \begin_layout Itemize
145 Compat.
146  alias: memory.map_structure
147 \end_layout
149 \begin_layout Itemize
150 syntax: classes.MMAP_STRUCT.new()
151 \end_layout
153 \begin_layout Standard
154 Create and returns a new mapping structure.
155 \end_layout
157 \begin_layout Subsubsection
158 operator(): Bind key in mmap structure
159 \end_layout
161 \begin_layout Itemize
162 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
163  type)
164 \end_layout
166 \begin_layout Standard
167 Bind key <key> in mmap structure to specified address <address> with specified
168  type <type>.
169 \end_layout
171 \begin_layout Itemize
172 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
173  qword, sqword, float or double.
174 \end_layout
176 \begin_layout Standard
177 \begin_inset Newpage pagebreak
178 \end_inset
181 \end_layout
183 \begin_layout Subsection
184 ZIPWRITER: Writes .zip files
185 \end_layout
187 \begin_layout Standard
188 This class does writing of .zip files.
189 \end_layout
191 \begin_layout Subsubsection
192 Static function new: Create a new zipfile
193 \end_layout
195 \begin_layout Itemize
196 Compat.
197  alias: zip.create
198 \end_layout
200 \begin_layout Itemize
201 Syntax: classes.ZIPWRITER.new(string filename[, number compression])
202 \end_layout
204 \begin_layout Standard
205 Creates a new zipfile <filename>, with specified compression level <compression>
206  (default 9).
207 \end_layout
209 \begin_layout Subsubsection
210 Method commit: Finish creating ZIP file.
211 \end_layout
213 \begin_layout Itemize
214 Syntax: none ZIPWRITER:commit()
215 \end_layout
217 \begin_layout Standard
218 Closes the ZIP archive.
219  Nothing more can be written.
220 \end_layout
222 \begin_layout Subsubsection
223 Method rollback: Delete the ZIP file being creted
224 \end_layout
226 \begin_layout Itemize
227 Syntax: none ZIPWRITER:rollback()
228 \end_layout
230 \begin_layout Standard
231 Deletes the newly written ZIP archive.
232  Nothing more can be written.
233 \end_layout
235 \begin_layout Subsubsection
236 Method create_file: Start writing a new member
237 \end_layout
239 \begin_layout Itemize
240 Syntax: none ZIPWRITER:create_file(string filename)
241 \end_layout
243 \begin_layout Standard
244 Starts writing a new member <filename> in ZIP file.
245  If member is open, it is closed.
246 \end_layout
248 \begin_layout Subsubsection
249 Method close_file: Close member
250 \end_layout
252 \begin_layout Itemize
253 Syntax: none ZIPWRITER:close_file()
254 \end_layout
256 \begin_layout Standard
257 Closes member in ZIP file.
258 \end_layout
260 \begin_layout Subsubsection
261 Method write: Write data
262 \end_layout
264 \begin_layout Itemize
265 Syntax none ZIPWRITER:write(string data)
266 \end_layout
268 \begin_layout Standard
269 Writes data <data> into ZIP file (binary mode).
270 \end_layout
272 \begin_layout Standard
273 \begin_inset Newpage pagebreak
274 \end_inset
277 \end_layout
279 \begin_layout Subsection
280 TILEMAP: Tiled collection of bitmaps.
281 \end_layout
283 \begin_layout Standard
284 A tilemap is tiled table, each cell holding a bitmap.
285 \end_layout
287 \begin_layout Subsubsection
288 Static function new: Create a tilemap
289 \end_layout
291 \begin_layout Itemize
292 Compat.
293  alias: gui.tilemap
294 \end_layout
296 \begin_layout Itemize
297 Syntax: TILEMAP classes.TILEMAP.new(number w, number h, number bw, number
298  bh)
299 \end_layout
301 \begin_layout Standard
302 Create a new tilemap of size <w>*<h>, with each cell being <bw>*<bh>.
303 \end_layout
305 \begin_layout Subsubsection
306 TILEMAP:getsize: Query tilemap size
307 \end_layout
309 \begin_layout Itemize
310 Syntax: number, number TILEMAP:getsize()
311 \end_layout
313 \begin_layout Standard
314 Return size of tilemap (width first).
315 \end_layout
317 \begin_layout Subsubsection
318 TILEMAP:getcsize: Query tilemap cell size
319 \end_layout
321 \begin_layout Itemize
322 Syntax: number, number TILEMAP:getcsize()
323 \end_layout
325 \begin_layout Standard
326 Return size of tilemap cell (width first).
327 \end_layout
329 \begin_layout Subsubsection
330 TILEMAP:get: Query tilemap cell
331 \end_layout
333 \begin_layout Itemize
334 Syntax: none TILEMAP:get(number x, number y)
335 \end_layout
337 \begin_layout Itemize
338 Syntax: dbitmap TILEMAP:get(number x, number y)
339 \end_layout
341 \begin_layout Itemize
342 Syntax: bitmap,palette TILEMAP:get(number x, number y)
343 \end_layout
345 \begin_layout Standard
346 Return contents of cell at <x>,<y>.
347 \end_layout
349 \begin_layout Subsubsection
350 TILEMAP:set: Set tilemap cell
351 \end_layout
353 \begin_layout Itemize
354 Syntax: none TILEMAP:set(number x, number y)
355 \end_layout
357 \begin_layout Itemize
358 Syntax: none TILEMAP:set(number x, number y, dbitmap b)
359 \end_layout
361 \begin_layout Itemize
362 Syntax: none TILEMAP:set(number x, number y, bitmap b, palette p)
363 \end_layout
365 \begin_layout Standard
366 Set contents of cell at <x>,<y>.
367  If no bitmap/dbitmap is given, cell is cleared.
368  Otherwise specified (d)bitmap is used (with specified palette if bitmap).
369 \end_layout
371 \begin_layout Subsubsection
372 TILEMAP:scroll: Scroll tilemap
373 \end_layout
375 \begin_layout Itemize
376 Syntax: none TILEMAP:scroll(number ox, number oy)
377 \end_layout
379 \begin_layout Itemize
380 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
381  w, number h)
382 \end_layout
384 \begin_layout Itemize
385 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
386  w, number h, boolean circx, boolean circy)
387 \end_layout
389 \begin_layout Standard
390 Scrolls the tilemap tiles by <ox>,<oy>.
391  If <x>,<y>,<w>,<h> is specified, the scrolling is limited to <w>*<h> window
392  starting at <x>,<y> (in tiles).
393 \end_layout
395 \begin_layout Standard
396 If <circx> is true, the window is circular in horizontal direction.
397  Similarly with <circy> and vertical direciton.
398 \end_layout
400 \begin_layout Subsubsection
401 TILEMAP:draw: Draw tilemap
402 \end_layout
404 \begin_layout Itemize
405 Syntax: none TILEMAP:draw(number x, number y)
406 \end_layout
408 \begin_layout Itemize
409 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0)
410 \end_layout
412 \begin_layout Itemize
413 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0, number
414  w, number h)
415 \end_layout
417 \begin_layout Standard
418 Draw tilemap at <x>,<y>.
419  If <x0>,<y0> is given, that is tilemap coordinate (in pixels) of upper
420  left edge.
421  If <w>,<h> is given, that is the size of window to draw (in pixels)
422 \end_layout
424 \begin_layout Standard
425 \begin_inset Newpage pagebreak
426 \end_inset
429 \end_layout
431 \begin_layout Subsection
432 RENDERCTX: Render queue
433 \end_layout
435 \begin_layout Subsubsection
436 Static function new: Create a render queue
437 \end_layout
439 \begin_layout Itemize
440 Compat.
441  alias: gui.renderq_new
442 \end_layout
444 \begin_layout Itemize
445 Syntax: RENDERQUEUE classes.RENDERCTX.new(number width, number height)
446 \end_layout
448 \begin_layout Standard
449 Create render queue with specified reported size and return it.
450 \end_layout
452 \begin_layout Subsubsection
453 Static function setnull: Reset to default queue
454 \end_layout
456 \begin_layout Itemize
457 Compat.
458  alias: gui.renderq_set
459 \end_layout
461 \begin_layout Itemize
462 Syntax: none classes.RENDERCTX:setnull()
463 \end_layout
465 \begin_layout Standard
466 Reset back to default queue (screen, video or none).
467 \end_layout
469 \begin_layout Subsubsection
470 Method clear: Clear a render queue
471 \end_layout
473 \begin_layout Itemize
474 Compat.
475  alias: gui.renderq_clear
476 \end_layout
478 \begin_layout Itemize
479 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
480 \end_layout
482 \begin_layout Itemize
483 Syntax: none RENDERQUEUE:clear()
484 \end_layout
486 \begin_layout Standard
487 Clear specified render queue.
488 \end_layout
490 \begin_layout Subsubsection
491 Method set: Change active render queue
492 \end_layout
494 \begin_layout Itemize
495 Compat.
496  alias: gui.renderq_set
497 \end_layout
499 \begin_layout Itemize
500 Syntax: none RENDERQUEUE:set()
501 \end_layout
503 \begin_layout Standard
504 Switch to specified render queue.
505  Use nil as queue to switch to default queue.
506 \end_layout
508 \begin_layout Itemize
509 Note: When switched to another queue, all drawing functions work and draw
510  there, even outside on_video/on_paint.
511 \end_layout
513 \begin_layout Subsubsection
514 Method run: Run render queue
515 \end_layout
517 \begin_layout Itemize
518 Compat.
519  alias: gui.renderq_run
520 \end_layout
522 \begin_layout Itemize
523 Syntax: none RENDERQUEUE:run()
524 \end_layout
526 \begin_layout Standard
527 Run specified render queue, copying the objects to current render queue.
529 \end_layout
531 \begin_layout Itemize
532 Warning: Don't try to run the current render queue.
533 \end_layout
535 \begin_layout Subsubsection
536 Method render: Render a queue to DBITMAP
537 \end_layout
539 \begin_layout Itemize
540 Syntax: DBITMAP RENDERQUEUE:render()
541 \end_layout
543 \begin_layout Standard
544 Renders the specified render queue to a bitmap, the base bitmap size (modified
545  by gaps) being the nominal screen size for render queue.
546 \end_layout
548 \begin_layout Subsection
549 Method synchronous_repaint: Paint screen now
550 \end_layout
552 \begin_layout Itemize
553 Compat.
554  alias: gui.synchronous_repaint
555 \end_layout
557 \begin_layout Itemize
558 Syntax: none RENDERQUEUE::synchronous_repaint()
559 \end_layout
561 \begin_layout Standard
562 Paints specified render queue on screen right there and then.
563 \end_layout
565 \begin_layout Standard
566 \begin_inset Newpage pagebreak
567 \end_inset
570 \end_layout
572 \begin_layout Section
573 Global
574 \end_layout
576 \begin_layout Subsection
577 print: Print values to console
578 \end_layout
580 \begin_layout Itemize
581 Syntax: none print(value...
582  values)
583 \end_layout
585 \begin_layout Standard
586 Prints specified values to console.
587  Can print any Lua type at least enough to identify the type and instance.
588 \end_layout
590 \begin_layout Subsection
591 tostringx: Format a value to string
592 \end_layout
594 \begin_layout Itemize
595 Syntax: string tostringx(value val)
596 \end_layout
598 \begin_layout Standard
599 Formats value <val> like print would, and returns the result as a string.
600 \end_layout
602 \begin_layout Subsection
603 exec: Execute lsnes commands
604 \end_layout
606 \begin_layout Itemize
607 Syntax: none exec(string cmd)
608 \end_layout
610 \begin_layout Standard
611 Execute lsnes command <cmd>.
612 \end_layout
614 \begin_layout Subsection
615 utime: Get current time
616 \end_layout
618 \begin_layout Itemize
619 Syntax: (number,number) utime()
620 \end_layout
622 \begin_layout Standard
623 Returns two numbers.
624  First is time since some epoch in seconds, the second is microseconds mod
625  10^6 since that epoch.
626 \end_layout
628 \begin_layout Subsection
629 emulator_ready: Check if emulator has been fully initialized
630 \end_layout
632 \begin_layout Itemize
633 Syntax: boolean emulator_ready()
634 \end_layout
636 \begin_layout Standard
637 Returns true if emulator has finished booting, false if not (on_startup()
638  will be issued later).
639 \end_layout
641 \begin_layout Subsection
642 set_idle_timeout: Run function after timeout when emulator is idle
643 \end_layout
645 \begin_layout Itemize
646 Syntax: none set_idle_timeout(number timeout)
647 \end_layout
649 \begin_layout Standard
650 Set number of microseconds to block idle for.
651  After this timeout has expired, on_idle() will be called once.
652 \end_layout
654 \begin_layout Subsection
655 set_timer_timeout: Run function after timeout.
656 \end_layout
658 \begin_layout Itemize
659 Syntax: none set_timer_timeout(number timeout)
660 \end_layout
662 \begin_layout Standard
663 Set number of microseconds to block timer for.
664  After this timeout has expired, on_timer() will be called once.
665 \end_layout
667 \begin_layout Subsection
668 bus_address: Look up address in system bus.
669 \end_layout
671 \begin_layout Itemize
672 Syntax: none bus_address(number bus_addr)
673 \end_layout
675 \begin_layout Standard
676 Returns virtual address corresponding to specified address on system bus.
677 \end_layout
679 \begin_layout Subsection
680 loopwrapper: Convert loop into callable function
681 \end_layout
683 \begin_layout Itemize
684 Syntax: function loopwrapper(function fun, ...)
685 \end_layout
687 \begin_layout Standard
688 Calls function <fun> with function and specified arguments.
689  The function passed suspends execution until the function returned is called.
690  Handy for linear flow control among multiple invocations of a hook.
691  Example code:
692 \end_layout
694 \begin_layout LyX-Code
695 on_paint = loopwrapper(function(wait)
696 \end_layout
698 \begin_deeper
699 \begin_layout LyX-Code
700 while true do
701 \end_layout
703 \begin_deeper
704 \begin_layout LyX-Code
705 gui.text(0, 0, 
706 \begin_inset Quotes eld
707 \end_inset
709 Test!
710 \begin_inset Quotes erd
711 \end_inset
714 \end_layout
716 \begin_layout LyX-Code
717 wait();
718 \end_layout
720 \end_deeper
721 \begin_layout LyX-Code
723 \end_layout
725 \end_deeper
726 \begin_layout LyX-Code
727 end);
728 \end_layout
730 \begin_layout Subsection
731 list_bindings: List keybindings
732 \end_layout
734 \begin_layout Itemize
735 Syntax: table list_bindings([string cmd])
736 \end_layout
738 \begin_layout Standard
739 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
740  If <cmd> is specified, the table is limited to that command.
741  Also searches for controller keys.
742 \end_layout
744 \begin_layout Subsection
745 get_alias: Get expansion of alias
746 \end_layout
748 \begin_layout Itemize
749 Syntax: string get_alias(string aname)
750 \end_layout
752 \begin_layout Standard
753 Get expansion of given alias <aname>.
754 \end_layout
756 \begin_layout Subsection
757 set_alias: Set expansion of alias
758 \end_layout
760 \begin_layout Itemize
761 Syntax: none set_alias(string aname, string value)
762 \end_layout
764 \begin_layout Standard
765 Set expansion of given alias.
766 \end_layout
768 \begin_layout Subsection
769 create_ibind: Create invese binding
770 \end_layout
772 \begin_layout Itemize
773 Syntax: INVERSEBIND create_ibind(string name, string cmd)
774 \end_layout
776 \begin_layout Standard
777 Return object representing inverse binding with specified name <name> and
778  specified command <cmd>.
779 \end_layout
781 \begin_layout Itemize
782 Note: To create press/release commands, use aliases +foo and -foo .
783 \end_layout
785 \begin_layout Itemize
786 Note: Keep the returned object around.
787 \end_layout
789 \begin_layout Subsection
790 create_command: Create a command
791 \end_layout
793 \begin_layout Itemize
794 Syntax: COMMANDBIND create_commmand(string name, function a)
795 \end_layout
797 \begin_layout Itemize
798 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
799 \end_layout
801 \begin_layout Standard
802 Return object representing a command (pair).
803 \end_layout
805 \begin_layout Itemize
806 If only one function is specied, the command is level-sensitive, <a> is
807  callback.
808 \end_layout
810 \begin_layout Itemize
811 If <b> is function, the function is edge-sensitive, <a> is positive edge
812  callback and <b> is negative edge callback.
813 \end_layout
815 \begin_layout Itemize
816 All callbacks get single argument: The parameters passed.
817 \end_layout
819 \begin_layout Itemize
820 Keep the returned object around.
821 \end_layout
823 \begin_layout Subsection
824 loadfile: Load Lua script
825 \end_layout
827 \begin_layout Itemize
828 Syntax: function loadfile(string filename[, string base])
829 \end_layout
831 \begin_layout Standard
832 Load lua script from <filename>, resolved relative to <base> (if empty,
833  current directory).
834 \end_layout
836 \begin_layout Subsection
837 dofile: Execute Lua script
838 \end_layout
840 \begin_layout Itemize
841 Syntax: function dofile(string filename[, string base])
842 \end_layout
844 \begin_layout Standard
845 Execute lua script from <filename>, resolved relative to <base> (if empty,
846  current directory) and return all return values.
847 \end_layout
849 \begin_layout Subsection
850 open_file: Open a stream
851 \end_layout
853 \begin_layout Itemize
854 Syntax: FILEREADER open_file(string filename[, string base])
855 \end_layout
857 \begin_layout Standard
858 Open file <filename>, resolved relative to <base> (if empty, current directory)
859  and return a handle.
860 \end_layout
862 \begin_layout Subsection
863 FILEREADER(): Read line/bytes from stream
864 \end_layout
866 \begin_layout Itemize
867 Syntax: string/nil FILEREADER()
868 \end_layout
870 \begin_layout Itemize
871 Syntax: string/nil FILEREADER(number bytes)
872 \end_layout
874 \begin_layout Standard
875 Reads next line or <bytes> bytes from specified file handle.
876  On EOF, nil is returned.
877 \end_layout
879 \begin_layout Itemize
880 Note: The line-oriented variant reads in text mode, so CR at end of line
881  is stripped.
882 \end_layout
884 \begin_layout Subsection
885 FILEREADER:lines: Iterator to read all lines
886 \end_layout
888 \begin_layout Itemize
889 Syntax: for line in <foo>:lines() do ...
890  end
891 \end_layout
893 \begin_layout Standard
894 Iterator for reading all lines of <foo> in a loop.
895 \end_layout
897 \begin_layout Subsection
898 resolve_filename: Resolve name of file relative to another
899 \end_layout
901 \begin_layout Itemize
902 Syntax: string resolve_file(string filename, string base)
903 \end_layout
905 \begin_layout Standard
906 Resolve name of file <filename> relative to <base> and return the result.
907 \end_layout
909 \begin_layout Subsection
910 render_queue_function: Return paint function for render queue
911 \end_layout
913 \begin_layout Itemize
914 Syntax: function render_queue_function(RENDERQUEUE rq)
915 \end_layout
917 \begin_layout Standard
918 Return function that renders render queue <rq>.
919 \end_layout
921 \begin_layout Itemize
922 Handy for paint callback if one is using render queues updated in other
923  callbacks.
924  As in:
925 \end_layout
927 \begin_layout LyX-Code
928 handle = callback.paint:register(render_queue_function(my_rq));
929 \end_layout
931 \begin_layout Subsection
932 iconv_new: Create new character set converter
933 \end_layout
935 \begin_layout Itemize
936 Syntax: ICONV iconv_new(string from, string to)
937 \end_layout
939 \begin_layout Standard
940 Create a character set converter, converting from <from> to <to>.
941 \end_layout
943 \begin_layout Subsection
944 ICONV(): Convert string fragment from character set to another
945 \end_layout
947 \begin_layout Itemize
948 Syntax: boolean, string, (number, string) ICONV(string input)
949 \end_layout
951 \begin_layout Standard
952 Convert string fragment <input> from character set to another.
953 \end_layout
955 \begin_layout Itemize
956 If conversion is successful, returns (true, {converted-string}).
958 \end_layout
960 \begin_layout Itemize
961 If conversion was unsuccessful, returns (false, {converted-part}, {unconverted-b
962 ytes}, {error}).
963  The following errors are defined:
964 \end_layout
966 \begin_deeper
967 \begin_layout Itemize
968 INVALID: Invalid byte sequence in input
969 \end_layout
971 \begin_layout Itemize
972 INCOMPLETE: The input is cut of in middle of multi-byte sequence
973 \end_layout
975 \begin_layout Itemize
976 INTERNALERR: Internal errror
977 \end_layout
979 \end_deeper
980 \begin_layout Subsection
981 identify_class: Identify class of object
982 \end_layout
984 \begin_layout Itemize
985 Syntax: string identify_class(userdata object)
986 \end_layout
988 \begin_layout Standard
989 Identifies the class of userdata <object>, if possible.
990  If no identification is possible, returns 
991 \begin_inset Quotes eld
992 \end_inset
994 unknown
995 \begin_inset Quotes erd
996 \end_inset
999 \end_layout
1001 \begin_layout Subsection
1002 lookup_class: Lookup class by name
1003 \end_layout
1005 \begin_layout Itemize
1006 Syntax: classobj lookup_class(string name)
1007 \end_layout
1009 \begin_layout Standard
1010 Looks up class corresponding to <name>, if possible.
1011  If not found, returns nil.
1012  The classobj has following fields:
1013 \end_layout
1015 \begin_layout Itemize
1016 _static_methods: Return static method names
1017 \end_layout
1019 \begin_layout Itemize
1020 _class_methods: Return class method names
1021 \end_layout
1023 \begin_layout Itemize
1024 <static-function-name>: The specified static function.
1025 \end_layout
1027 \begin_layout Standard
1028 \begin_inset Newpage pagebreak
1029 \end_inset
1032 \end_layout
1034 \begin_layout Section
1035 Table bit:
1036 \end_layout
1038 \begin_layout Standard
1039 Bitwise logical functions and related.
1040 \end_layout
1042 \begin_layout Subsection
1043 bit.none/bit.bnot: Bitwise none or NOT function
1044 \end_layout
1046 \begin_layout Itemize
1047 Syntax: number bit.none(number...)
1048 \end_layout
1050 \begin_layout Itemize
1051 Syntax: number bit.bnot(number...)
1052 \end_layout
1054 \begin_layout Standard
1055 48-bit bitwise NOT / NONE function (set bits that are set in none of the
1056  arguments).
1057 \end_layout
1059 \begin_layout Subsection
1060 bit.any/bit.bor: Bitwise any or OR function
1061 \end_layout
1063 \begin_layout Itemize
1064 Syntax: number bit.any(number...)
1065 \end_layout
1067 \begin_layout Itemize
1068 Syntax: number bit.bor(number...)
1069 \end_layout
1071 \begin_layout Standard
1072 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
1073 \end_layout
1075 \begin_layout Subsection
1076 bit.all/bit.band: Bitwise all or AND function
1077 \end_layout
1079 \begin_layout Itemize
1080 Syntax: number bit.all(number...)
1081 \end_layout
1083 \begin_layout Itemize
1084 Syntax: number bit.band(number...)
1085 \end_layout
1087 \begin_layout Standard
1088 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
1090 \end_layout
1092 \begin_layout Subsection
1093 bit.parity/bit.bxor: Bitwise parity or XOR function
1094 \end_layout
1096 \begin_layout Itemize
1097 Syntax: number bit.parity(number...)
1098 \end_layout
1100 \begin_layout Itemize
1101 Syntax: number bit.bxor(number...)
1102 \end_layout
1104 \begin_layout Standard
1105 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
1106  of the arguments).
1107 \end_layout
1109 \begin_layout Subsection
1110 bit.lrotate: Rotate a number left
1111 \end_layout
1113 \begin_layout Itemize
1114 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
1115 \end_layout
1117 \begin_layout Standard
1118 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
1119  1) places.
1120 \end_layout
1122 \begin_layout Subsection
1123 bit.rrotate: Rotate a number right
1124 \end_layout
1126 \begin_layout Itemize
1127 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
1128 \end_layout
1130 \begin_layout Standard
1131 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
1132  1) places.
1133 \end_layout
1135 \begin_layout Subsection
1136 bit.lshift: Shift a number left
1137 \end_layout
1139 \begin_layout Itemize
1140 Syntax: number bit.lshift(number base[, number amount[, number bits]])
1141 \end_layout
1143 \begin_layout Standard
1144 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
1145  1) places.
1146  The new bits are filled with zeroes.
1147 \end_layout
1149 \begin_layout Subsection
1150 bit.lrshift: Shift a number right (logical)
1151 \end_layout
1153 \begin_layout Itemize
1154 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
1155 \end_layout
1157 \begin_layout Standard
1158 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
1159  (default 1) places.
1160  The new bits are filled with zeroes.
1161 \end_layout
1163 \begin_layout Subsection
1164 bit.arshift: Shift a number right (arithmetic)
1165 \end_layout
1167 \begin_layout Itemize
1168 Syntax: number bit.arshift(number base[, number amount[, number bits]])
1169 \end_layout
1171 \begin_layout Standard
1172 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
1173  (default 1) places.
1174  The new bits are shifted in with copy of the high bit.
1175 \end_layout
1177 \begin_layout Subsection
1178 bit.extract: Extract/shuffle bits from number
1179 \end_layout
1181 \begin_layout Itemize
1182 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
1183 \end_layout
1185 \begin_layout Standard
1186 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
1187 \end_layout
1189 \begin_layout Itemize
1190 Note: Bit numbers up to 51 should work reliably (then things start falling
1191  apart due to double precision issues).
1192 \end_layout
1194 \begin_layout Itemize
1195 Note: There are two special bit positions, true and false, standing for
1196  always set bit and always clear bit.
1197 \end_layout
1199 \begin_layout Subsection
1200 bit.value: Construct number with specified bits set
1201 \end_layout
1203 \begin_layout Itemize
1204 Syntax: number bit.value([number bit1[, number bit2,...]])
1205 \end_layout
1207 \begin_layout Standard
1208 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
1209  <bit2> places and so on.
1210  As special value, nil argument is no-op.
1211 \end_layout
1213 \begin_layout Subsection
1214 bit.test_any: Test if any bit is set
1215 \end_layout
1217 \begin_layout Itemize
1218 Syntax: boolean bit.test_any(number a, number b)
1219 \end_layout
1221 \begin_layout Standard
1222 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
1223 \end_layout
1225 \begin_layout Subsection
1226 bit.test_all: Test if all bits are set
1227 \end_layout
1229 \begin_layout Itemize
1230 Syntax: boolean bit.test_all(number a, number b)
1231 \end_layout
1233 \begin_layout Standard
1234 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
1235 \end_layout
1237 \begin_layout Subsection
1238 bit.popcount: Population count
1239 \end_layout
1241 \begin_layout Itemize
1242 Syntax: number bit.popcount(number a)
1243 \end_layout
1245 \begin_layout Standard
1246 Returns number of set bits in <a>.
1247 \end_layout
1249 \begin_layout Subsection
1250 bit.clshift: Chained left shift
1251 \end_layout
1253 \begin_layout Itemize
1254 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
1255  bits]])
1256 \end_layout
1258 \begin_layout Standard
1259 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
1260  numbers to be of specified number of bits <bits> (default 48).
1261 \end_layout
1263 \begin_layout Subsection
1264 bit.crshift: Chained right shift
1265 \end_layout
1267 \begin_layout Itemize
1268 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
1269  bits]])
1270 \end_layout
1272 \begin_layout Standard
1273 Does chained right shift on <a>, <b> by <amount> positions (default 1),
1274  assuming numbers to be of specified number of bits <bits> (default 48).
1275 \end_layout
1277 \begin_layout Subsection
1278 bit.flagdecode: Decode bitfield into flags
1279 \end_layout
1281 \begin_layout Itemize
1282 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
1283  off]])
1284 \end_layout
1286 \begin_layout Standard
1287 Return string of length bits where ith character is ith character of on
1288  if bit i is on, otherwise ith character of off.
1289  Out of range reads give last character.
1290 \end_layout
1292 \begin_layout Itemize
1293 Note: <on> defaults to '*' if empty.
1294 \end_layout
1296 \begin_layout Itemize
1297 Note: <off> defaults to '-' if empty.
1298 \end_layout
1300 \begin_layout Subsection
1301 bit.rflagdecode: Decode bitfield into flags
1302 \end_layout
1304 \begin_layout Itemize
1305 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
1306  off]])
1307 \end_layout
1309 \begin_layout Standard
1310 Like bit.flagdecode, but outputs the string in the opposite order (most significa
1311 nt bit first).
1312 \end_layout
1314 \begin_layout Subsection
1315 bit.swap{,s}{,h,d,q}word: Swap word endian
1316 \end_layout
1318 \begin_layout Itemize
1319 Syntax: number bit.swapword(number n)
1320 \end_layout
1322 \begin_layout Itemize
1323 Syntax: number bit.swaphword(number n)
1324 \end_layout
1326 \begin_layout Itemize
1327 Syntax: number bit.swapdword(number n)
1328 \end_layout
1330 \begin_layout Itemize
1331 Syntax: number bit.swapqword(number n)
1332 \end_layout
1334 \begin_layout Itemize
1335 Syntax: number bit.swapsword(number n)
1336 \end_layout
1338 \begin_layout Itemize
1339 Syntax: number bit.swapshword(number n)
1340 \end_layout
1342 \begin_layout Itemize
1343 Syntax: number bit.swapsdword(number n)
1344 \end_layout
1346 \begin_layout Itemize
1347 Syntax: number bit.swapsqword(number n)
1348 \end_layout
1350 \begin_layout Standard
1351 Swap endianess of (un)signed integer <n>.
1352 \end_layout
1354 \begin_layout Standard
1355 \begin_inset Newpage pagebreak
1356 \end_inset
1359 \end_layout
1361 \begin_layout Section
1362 Table classes:
1363 \end_layout
1365 \begin_layout Subsection
1366 classes.<foo>: The classobj for class <foo>
1367 \end_layout
1369 \begin_layout Itemize
1370 Syntax: classes.<foo>
1371 \end_layout
1373 \begin_layout Standard
1374 The classobj for class <foo>.
1375 \end_layout
1377 \begin_layout Subsection
1378 classes.<foo>._static_methods: Enumerate static methods
1379 \end_layout
1381 \begin_layout Itemize
1382 Syntax: string...
1383  classes.<foo>._static_methods()
1384 \end_layout
1386 \begin_layout Standard
1387 Returns all static methods of <foo> as strings.
1388 \end_layout
1390 \begin_layout Subsection
1391 classes.<foo>._class_methods: Enumerate static methods
1392 \end_layout
1394 \begin_layout Itemize
1395 Syntax: string...
1396  classes.<foo>._class_methods()
1397 \end_layout
1399 \begin_layout Standard
1400 Returns all class methods of <foo> as strings.
1401 \end_layout
1403 \begin_layout Subsection
1404 classes.<foo>.<bar>: Static method
1405 \end_layout
1407 \begin_layout Itemize
1408 Syntax: variable classes.<foo>.<bar>(variable...)
1409 \end_layout
1411 \begin_layout Standard
1412 Invokes static method <bar> of class <foo>.
1413 \end_layout
1415 \begin_layout Section
1416 Table gui:
1417 \end_layout
1419 \begin_layout Itemize
1420 Functions that draw to screen can only only be called in on_paint and on_video
1421  callbacks or if non-default render queue has been set.
1422 \end_layout
1424 \begin_layout Itemize
1425 Colors are 32-bit.
1426  Bits 0-7 are the blue component, bits 8-15 are the green component, bits
1427  16-23 are the red component, bits 24-31 are alpha component (0 is fully
1428  opaque, 255 is almost transparent).
1429  -1 is the fully transparent color.
1430  Alternatively, colors can be given as strings naming the color.
1431 \end_layout
1433 \begin_layout Itemize
1434 Alpha values greater than 127 do work properly.
1435 \end_layout
1437 \begin_layout Itemize
1438 Origin of coordinates is at top left corner of game display area.
1439  Left and top gaps correspond to negative coordinates.
1440 \end_layout
1442 \begin_layout Itemize
1443 The following color names are known: aliceblue antiquewhite antiquewhite1
1444  antiquewhite2 antiquewhite3 antiquewhite4 aqua aquamarine aquamarine1 aquamarin
1445 e2 aquamarine3 aquamarine4 azure azure1 azure2 azure3 azure4 beige bisque
1446  bisque1 bisque2 bisque3 bisque4 black blanchedalmond blue blue1 blue2 blue3
1447  blue4 blueviolet brown brown1 brown2 brown3 brown4 burlywood burlywood1
1448  burlywood2 burlywood3 burlywood4 cadet cadetblue cadetblue1 cadetblue2
1449  cadetblue3 cadetblue4 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse
1450 4 chocolate chocolate1 chocolate2 chocolate3 chocolate4 coral coral1 coral2
1451  coral3 coral4 cornflowerblue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4
1452  crimson cyan cyan1 cyan2 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgolden
1453 rod1 darkgoldenrod2 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey
1454  darkkhaki darkmagenta darkolivegreen darkolivegreen1 darkolivegreen2 darkoliveg
1455 reen3 darkolivegreen4 darkorange darkorange1 darkorange2 darkorange3 darkorange4
1456  darkorchid darkorchid1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon
1457  darkseagreen darkseagreen1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateb
1458 lue darkslategray darkslategray1 darkslategray2 darkslategray3 darkslategray4
1459  darkslategrey darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3
1460  deeppink4 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4
1461  dimgray dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4
1462  firebrick firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen
1463  fractal fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod
1464  goldenrod1 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100
1465  gray11 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20
1466  gray21 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30
1467  gray31 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40
1468  gray41 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50
1469  gray51 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60
1470  gray61 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70
1471  gray71 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80
1472  gray81 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90
1473  gray91 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1
1474  green2 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11
1475  grey12 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21
1476  grey22 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31
1477  grey32 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41
1478  grey42 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51
1479  grey52 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61
1480  grey62 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71
1481  grey72 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81
1482  grey82 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91
1483  grey92 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1
1484  honeydew2 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4
1485  indianred indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1
1486  ivory2 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
1487  lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
1488 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
1489  lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
1490  lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
1491 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
1492  lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
1493  lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
1494  lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
1495  lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
1496  lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
1497  lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
1498  maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
1499  mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
1500  mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
1501 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
1502 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
1503 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
1504  navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
1505  olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
1506  orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
1507  palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
1508 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
1509  palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
1510  peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
1511  pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
1512  purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
1513  rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
1514  saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
1515  seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
1516  seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
1517  skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
1518 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
1519  snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
1520 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
1521  tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
1522  tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
1523  turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
1524  wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
1525  yellow3 yellow4 yellowgreen hsl-{r,ry,o,y,yg,g,gc,c,cb,b,bm,m,mr}{0,1,2,3,4,5,6
1526 ,7,8}{0,1,2,3,4,5,6,7,8}.
1527 \end_layout
1529 \begin_layout Itemize
1530 The following modifiers can be applied: opaque10, opaque20, opaque25, opaque30,
1531  opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
1532  hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
1533 \end_layout
1535 \begin_layout Itemize
1536 HSL base color names: r => Red, ry => Red-Yellow (also o).
1537  y => Yellow, yg => Yellow-Green, g => Green, gc => Green-Cyan, c => Cyan,
1538  cb => Cyan-Blue, b => Blue, bm => Blue-Magenta, m => Magenta, mr => Magenta
1539  red.
1540 \end_layout
1542 \begin_layout Itemize
1543 HSL colors use 8-step scales for saturation and lightness.
1544 \end_layout
1546 \begin_layout Itemize
1547 Modifiers have opaqueness on percent scale (0 is transparent, 100 is fully
1548  opaque).
1549 \end_layout
1551 \begin_layout Itemize
1552 Modifiers have Hue on 24-step scale (4 steps between R->Y->G->C->B->M->R).
1553 \end_layout
1555 \begin_layout Itemize
1556 Modifiers have Saturation/Lightness on 16 step scale.
1557 \end_layout
1559 \begin_layout Subsection
1560 gui.resolution: Get current resolution
1561 \end_layout
1563 \begin_layout Itemize
1564 Syntax: (number, number) gui.resolution()
1565 \end_layout
1567 \begin_layout Standard
1568 Returns 2-tuple (hresolution, vresolution).
1569 \end_layout
1571 \begin_layout Subsection
1572 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
1573 \end_layout
1575 \begin_layout Itemize
1576 Syntax: number gui.left_gap(number gap)
1577 \end_layout
1579 \begin_layout Itemize
1580 Syntax: number gui.right_gap(number gap)
1581 \end_layout
1583 \begin_layout Itemize
1584 Syntax: number gui.top_gap(number gap)
1585 \end_layout
1587 \begin_layout Itemize
1588 Syntax: number gui.bottom_gap(number gap)
1589 \end_layout
1591 \begin_layout Standard
1592 Set the specified edge gap to specified value <gap> (max gap is 8191).
1593  If successful, old gap is returned.
1594 \end_layout
1596 \begin_layout Subsection
1597 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
1598  Adjust edge gaps
1599 \end_layout
1601 \begin_layout Itemize
1602 Syntax: number gui.delta_left_gap(number dgap)
1603 \end_layout
1605 \begin_layout Itemize
1606 Syntax: number gui.delta_right_gap(number dgap)
1607 \end_layout
1609 \begin_layout Itemize
1610 Syntax: number gui.delta_top_gap(number dgap)
1611 \end_layout
1613 \begin_layout Itemize
1614 Syntax: number gui.delta_bottom_gap(number dgap)
1615 \end_layout
1617 \begin_layout Standard
1618 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
1619  and return the old gap (returns nothing on error).
1620 \end_layout
1622 \begin_layout Subsection
1623 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
1624 \end_layout
1626 \begin_layout Itemize
1627 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
1628  bgc]])
1629 \end_layout
1631 \begin_layout Itemize
1632 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
1633  bgc]])
1634 \end_layout
1636 \begin_layout Itemize
1637 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
1638  bgc]])
1639 \end_layout
1641 \begin_layout Itemize
1642 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
1643  bgc]])
1644 \end_layout
1646 \begin_layout Standard
1647 Draw specified text on the GUI (each character cell is 8 or 16 wide and
1648  16 high).
1649  Parameters:
1650 \end_layout
1652 \begin_layout Itemize
1653 x: X-coordinate to start the drawing from (and x-coordinate at begining
1654  of the lines).
1655 \end_layout
1657 \begin_layout Itemize
1658 y: Y-coordinate to start the drawing from.
1659 \end_layout
1661 \begin_layout Itemize
1662 text: The text to draw.
1663 \end_layout
1665 \begin_layout Itemize
1666 fgc: Text color (default is 0xFFFFFF (white))
1667 \end_layout
1669 \begin_layout Itemize
1670 bgc: Background color (default is -1 (transparent))
1671 \end_layout
1673 \begin_layout Standard
1674 Note: The H variants draw at double width and V variants draw at double
1675  height.
1676 \end_layout
1678 \begin_layout Subsection
1679 gui.rectangle: Draw a rectangle
1680 \end_layout
1682 \begin_layout Itemize
1683 Syntax: none gui.rectangle(number x, number y, number width, number height[,
1684  number thickness[, number outline[, number fill]]])
1685 \end_layout
1687 \begin_layout Standard
1688 Draw rectangle on the GUI.
1689  Parameters:
1690 \end_layout
1692 \begin_layout Itemize
1693 x: X-coordinate of left edge.
1694 \end_layout
1696 \begin_layout Itemize
1697 y: Y-coordinate of upper edge.
1698 \end_layout
1700 \begin_layout Itemize
1701 width: Width of rectangle.
1702 \end_layout
1704 \begin_layout Itemize
1705 height: Height of rectangle.
1706 \end_layout
1708 \begin_layout Itemize
1709 thickness: Thickness of outline (default is 1).
1710 \end_layout
1712 \begin_layout Itemize
1713 outline: Color of outline (default is 0xFFFFFF (white))
1714 \end_layout
1716 \begin_layout Itemize
1717 fill: Color of fill (default is -1 (transparent))
1718 \end_layout
1720 \begin_layout Subsection
1721 gui.box: Draw a 3D-effect box
1722 \end_layout
1724 \begin_layout Itemize
1725 Syntax: none gui.box(number x, number y, number width, number height[, number
1726  thickness[, number outline1[,number outline2[, number fill]]]])
1727 \end_layout
1729 \begin_layout Standard
1730 Draw rectangle with 3D effect on the GUI.
1731  Parameters:
1732 \end_layout
1734 \begin_layout Itemize
1735 x: X-coordinate of left edge.
1736 \end_layout
1738 \begin_layout Itemize
1739 y: Y-coordinate of upper edge.
1740 \end_layout
1742 \begin_layout Itemize
1743 width: Width of rectangle.
1744 \end_layout
1746 \begin_layout Itemize
1747 height: Height of rectangle.
1748 \end_layout
1750 \begin_layout Itemize
1751 thickness: Thickness of outline (default is 1).
1752 \end_layout
1754 \begin_layout Itemize
1755 outline1: First color of outline (default is 0xFFFFFF (white))
1756 \end_layout
1758 \begin_layout Itemize
1759 outline2: First color of outline (default is 0x808080 (dark gray))
1760 \end_layout
1762 \begin_layout Itemize
1763 fill: Color of fill (default is 0xC0C0C0 (light grayy))
1764 \end_layout
1766 \begin_layout Subsection
1767 gui.pixel: Draw a single pixel
1768 \end_layout
1770 \begin_layout Itemize
1771 Syntax: none gui.pixel(number x, number y[, number color])
1772 \end_layout
1774 \begin_layout Standard
1775 Draw one pixel on the GUI.
1776  Parameters:
1777 \end_layout
1779 \begin_layout Itemize
1780 x: X-coordinate of the pixel
1781 \end_layout
1783 \begin_layout Itemize
1784 y: Y-coordinate of the pixel
1785 \end_layout
1787 \begin_layout Itemize
1788 color: Color of the pixel (default is 0xFFFFFF (white))
1789 \end_layout
1791 \begin_layout Subsection
1792 gui.crosshair: Draw a crosshair
1793 \end_layout
1795 \begin_layout Itemize
1796 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
1797 \end_layout
1799 \begin_layout Standard
1800 Draw a crosshair.
1801  Parameters:
1802 \end_layout
1804 \begin_layout Itemize
1805 x: X-coordinate of the crosshair
1806 \end_layout
1808 \begin_layout Itemize
1809 y: Y-coordinate of the crosshair
1810 \end_layout
1812 \begin_layout Itemize
1813 length: Length of the crosshair lines (default 10).
1814 \end_layout
1816 \begin_layout Itemize
1817 color: Color of the crosshair (default is 0xFFFFFF (white))
1818 \end_layout
1820 \begin_layout Subsection
1821 gui.line: Draw a line
1822 \end_layout
1824 \begin_layout Itemize
1825 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
1826  color])
1827 \end_layout
1829 \begin_layout Standard
1830 Draw a thin line.
1831  Parameters:
1832 \end_layout
1834 \begin_layout Itemize
1835 x1: X-coordinate of one end.
1836 \end_layout
1838 \begin_layout Itemize
1839 y1: Y-coordinate of one end.
1840 \end_layout
1842 \begin_layout Itemize
1843 x2: X-coordinate of the other end.
1844 \end_layout
1846 \begin_layout Itemize
1847 y2: Y-coordinate of the other end.
1848 \end_layout
1850 \begin_layout Itemize
1851 color: Color of the line (default is 0xFFFFFF (white)).
1852 \end_layout
1854 \begin_layout Subsection
1855 gui.circle: Draw a (filled) circle
1856 \end_layout
1858 \begin_layout Itemize
1859 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
1860  border[, number fil]]])
1861 \end_layout
1863 \begin_layout Standard
1864 Draw a circle.
1865  Parameters.
1866 \end_layout
1868 \begin_layout Itemize
1869 x: X-coordinate of the center
1870 \end_layout
1872 \begin_layout Itemize
1873 y: Y-coordinate of the center
1874 \end_layout
1876 \begin_layout Itemize
1877 r: The radius of the circle
1878 \end_layout
1880 \begin_layout Itemize
1881 thick: Border thickness
1882 \end_layout
1884 \begin_layout Itemize
1885 border: Border color (default is 0xFFFFFF (white))
1886 \end_layout
1888 \begin_layout Itemize
1889 fill: Fill color (default is -1 (transparent)).
1890 \end_layout
1892 \begin_layout Subsection
1893 gui.bitmap_draw/(D)BITMAP:draw: Draw a bitmap
1894 \end_layout
1896 \begin_layout Itemize
1897 Syntax: none gui.bitmap_draw(number x, number y, BITMAP bitmap, PALETTE palette)
1898 \end_layout
1900 \begin_layout Itemize
1901 Syntax: none gui.bitmap_draw(number x, number y, DBITMAP bitmap)
1902 \end_layout
1904 \begin_layout Itemize
1905 Syntax: none BITMAP:draw(number x, number y, PALETTE palette)
1906 \end_layout
1908 \begin_layout Itemize
1909 Syntax: none DBITMAP:draw(number x, number y)
1910 \end_layout
1912 \begin_layout Standard
1913 Draw a bitmap <bitmap> (or object) on screen with specified palette <palette>
1914  (if bitmap is paletted) .
1915  Parameters:
1916 \end_layout
1918 \begin_layout Itemize
1919 x: X-coordinate of left edge.
1920 \end_layout
1922 \begin_layout Itemize
1923 y: Y-coordinate of top edge.
1924 \end_layout
1926 \begin_layout Itemize
1927 bitmap: The bitmap to draw
1928 \end_layout
1930 \begin_layout Itemize
1931 palette: The palette to draw the bitmap using.
1932 \end_layout
1934 \begin_layout Subsection
1935 gui.palette_new: Create a new palette
1936 \end_layout
1938 \begin_layout Itemize
1939 Syntax: PALETTE gui.palette_new()
1940 \end_layout
1942 \begin_layout Standard
1943 Returns a new palette (initially all transparent).
1945 \end_layout
1947 \begin_layout Subsection
1948 gui.bitmap_new: Create a new bitmap
1949 \end_layout
1951 \begin_layout Itemize
1952 Syntax: BITMAP/DBITMAP gui.bitmap_new(number w, number h, boolean direct[,
1953  bool icolor])
1954 \end_layout
1956 \begin_layout Standard
1957 Returns a new bitmap/dbitmap.
1958 \end_layout
1960 \begin_layout Standard
1961 Parameters:
1962 \end_layout
1964 \begin_layout Itemize
1965 w: The width of new bitmap
1966 \end_layout
1968 \begin_layout Itemize
1969 h: The height of new bitmap
1970 \end_layout
1972 \begin_layout Itemize
1973 direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
1974 \end_layout
1976 \begin_layout Itemize
1977 icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
1978 \end_layout
1980 \begin_layout Subsection
1981 gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
1982 \end_layout
1984 \begin_layout Itemize
1985 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
1986 \end_layout
1988 \begin_layout Itemize
1989 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
1990 \end_layout
1992 \begin_layout Standard
1993 Reads file <file> (resolved relative to <base>) or string <content> and
1994  returns loaded bitmap/dbitmap (if bitmap, the second return value is palette
1995  for bitmap).
1996 \end_layout
1998 \begin_layout Subsection
1999 gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
2000 \end_layout
2002 \begin_layout Itemize
2003 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
2004  base])
2005 \end_layout
2007 \begin_layout Itemize
2008 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
2009 \end_layout
2011 \begin_layout Standard
2012 Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
2013  encoded content <content>.
2014 \end_layout
2016 \begin_layout Itemize
2017 If the PNG is of color type 3 (PALETTE), returns two values.
2018  First is BITMAP containing the image data from the PNG and second is PALETTE
2019  containg the palette data from the PNG.
2020 \end_layout
2022 \begin_layout Itemize
2023 For color types 0 (GRAY), 2 (RGB), 4 (GRAY_ALPHA) and 6 (RGBA), returns
2024  one DBITMAP containg the image data loaded from the PNG.
2025 \end_layout
2027 \begin_layout Subsection
2028 gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
2029 \end_layout
2031 \begin_layout Itemize
2032 Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
2033 \end_layout
2035 \begin_layout Itemize
2036 Syntax: PALETTE gui.bitmap_load_pal_str(string content)
2037 \end_layout
2039 \begin_layout Standard
2040 Load a palette from file <file>(resolved relative to <base>) or string <content>.
2041 \end_layout
2043 \begin_layout Itemize
2044 The kinds of lines supported:
2045 \end_layout
2047 \begin_deeper
2048 \begin_layout Itemize
2049 Blank or just whitespace: Ignored
2050 \end_layout
2052 \begin_layout Itemize
2053 First non-whitespace is '#': Ignored
2054 \end_layout
2056 \begin_layout Itemize
2057 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
2058 \end_layout
2060 \begin_layout Itemize
2061 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
2062  (0-256, 0 being fully transparent and 256 fully opaque).
2063 \end_layout
2065 \begin_layout Itemize
2066 transparent: Fully transparent color
2067 \end_layout
2069 \end_deeper
2070 \begin_layout Subsection
2071 gui.palette_set/PALETTE:set: Set palette entry
2072 \end_layout
2074 \begin_layout Itemize
2075 Syntax: none gui.palette_set(PALETTE palette, number index, number color)
2076 \end_layout
2078 \begin_layout Itemize
2079 Syntax: none PALETTE:set(number index, number color)
2080 \end_layout
2082 \begin_layout Standard
2083 Sets color in palette.
2084  Parameters:
2085 \end_layout
2087 \begin_layout Itemize
2088 palette: The palette to manipulate
2089 \end_layout
2091 \begin_layout Itemize
2092 index: Index of color (0-65535).
2093 \end_layout
2095 \begin_layout Itemize
2096 color: The color value.
2097 \end_layout
2099 \begin_layout Subsection
2100 gui.bitmap_pset/(D)BITMAP:pset: Set pixel in bitmap
2101 \end_layout
2103 \begin_layout Itemize
2104 Syntax: none gui.bitmap_pset(BITMAP/DBITMAP bitmap, number x, number y, number
2105  color)
2106 \end_layout
2108 \begin_layout Itemize
2109 Syntax: none BITMAP:pset(number x, number y, number color)
2110 \end_layout
2112 \begin_layout Itemize
2113 Syntax: none DBITMAP:pset(number x, number y, number color)
2114 \end_layout
2116 \begin_layout Standard
2117 Sets specified pixel in bitmap.
2118  Parameters:
2119 \end_layout
2121 \begin_layout Itemize
2122 bitmap: The bitmap to manipulate
2123 \end_layout
2125 \begin_layout Itemize
2126 x: The x-coordinate of the pixel.
2127 \end_layout
2129 \begin_layout Itemize
2130 y: The y-coordinate of the pixel.
2131 \end_layout
2133 \begin_layout Itemize
2134 color: If bitmap is a bitmap, color index (0-65535).
2135  Otherwise color value.
2136 \end_layout
2138 \begin_layout Subsection
2139 gui.bitmap_pget/(D)BITMAP:pget: Get pixel in bitmap
2140 \end_layout
2142 \begin_layout Itemize
2143 Syntax: number gui.bitmap_pget(BITMAP/DBITMAP bitmap, number x, number y)
2144 \end_layout
2146 \begin_layout Itemize
2147 Syntax: number BITMAP:pget(number x, number y)
2148 \end_layout
2150 \begin_layout Itemize
2151 Syntax: number DBITMAP:pget(number x, number y)
2152 \end_layout
2154 \begin_layout Standard
2155 Gets specified pixel in bitmap.
2156  Parameters:
2157 \end_layout
2159 \begin_layout Itemize
2160 bitmap: The bitmap to query
2161 \end_layout
2163 \begin_layout Itemize
2164 x: The x-coordinate of the pixel.
2165 \end_layout
2167 \begin_layout Itemize
2168 y: The y-coordinate of the pixel.
2169 \end_layout
2171 \begin_layout Standard
2172 The bitmap color (color index if paletted, otherwise color value).
2173 \end_layout
2175 \begin_layout Subsection
2176 gui.bitmap_size/(D)BITMAP:size: Get size of bitmap
2177 \end_layout
2179 \begin_layout Itemize
2180 Syntax: (number, number) gui.bitmap_size(BITMAP/DBITMAP bitmap)
2181 \end_layout
2183 \begin_layout Itemize
2184 Syntax: (number, number) BITMAP:size()
2185 \end_layout
2187 \begin_layout Itemize
2188 Syntax: (number, number) DBITMAP:size()
2189 \end_layout
2191 \begin_layout Standard
2192 Get size of bitmap <bitmap>.
2193  The first return is the width, the second is the height.
2194 \end_layout
2196 \begin_layout Itemize
2197 Note: Can be used anywhere.
2198 \end_layout
2200 \begin_layout Subsection
2201 gui.bitmap_blit/(D)BITMAP:blit: Blit a bitmap into another
2202 \end_layout
2204 \begin_layout Itemize
2205 Syntax: none gui.bitmap_blit(BITMAP dest, number dx, number dy, BITMAP src,
2206  number sx, number sy, number w, number h[, number ck])
2207 \end_layout
2209 \begin_layout Itemize
2210 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, DBITMAP
2211  src, number sx, number sy, number w, number h[, number ck])
2212 \end_layout
2214 \begin_layout Itemize
2215 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, BITMAP src,
2216  PALETTE pal, number sx, number sy, number w, number h[, number ck])
2217 \end_layout
2219 \begin_layout Itemize
2220 Syntax: none BITMAP::blit(number dx, number dy, BITMAP src, number sx, number
2221  sy, number w, number h[, number ck])
2222 \end_layout
2224 \begin_layout Itemize
2225 Syntax: none DBITMAP::blit(number dx, number dy, DBITMAP src, number sx,
2226  number sy, number w, number h[, number ck])
2227 \end_layout
2229 \begin_layout Itemize
2230 Syntax: none DBITMAP:blit(number dx, number dy, BITMAP src, PALETTE pal,
2231  number sx, number sy, number w, number h[, number ck])
2232 \end_layout
2234 \begin_layout Standard
2235 Blit a part of bitmap to another (current object if any is destination).
2236  Parameters:
2237 \end_layout
2239 \begin_layout Itemize
2240 dest: Destination to blit to.
2241 \end_layout
2243 \begin_layout Itemize
2244 dx: left edge of target
2245 \end_layout
2247 \begin_layout Itemize
2248 dy: Top edge of target
2249 \end_layout
2251 \begin_layout Itemize
2252 src: The source to blit from.
2253 \end_layout
2255 \begin_layout Itemize
2256 pal: The palette to use in blit.
2257 \end_layout
2259 \begin_layout Itemize
2260 sx: left edge of source
2261 \end_layout
2263 \begin_layout Itemize
2264 sy: Top edge of source
2265 \end_layout
2267 \begin_layout Itemize
2268 w: Width of region
2269 \end_layout
2271 \begin_layout Itemize
2272 h: Height of region.
2273 \end_layout
2275 \begin_layout Itemize
2276 ck: Color key.
2277  Pixels of this color are not blitted.
2278 \end_layout
2280 \begin_deeper
2281 \begin_layout Itemize
2282 If soruce bitmap is bitmap, this is color index of colorkey.
2283  Values outside range 0-65535 cause no key to be used as colorkey.
2284 \end_layout
2286 \begin_layout Itemize
2287 If source bitmap is dbitmap, this is the color value of colorkey.
2288 \end_layout
2290 \begin_layout Itemize
2291 May be absent or nil for no colorkey blit.
2292 \end_layout
2294 \end_deeper
2295 \begin_layout Subsection
2296 gui.bitmap_blit_scaled/(D)BITMAP:blit_scaled: Blit a bitmap into another
2297  with scaling
2298 \end_layout
2300 \begin_layout Itemize
2301 Syntax: none gui.bitmap_blit_scaled(BITMAP dest, number dx, number dy, BITMAP
2302  src, number sx, number sy, number w, number h, number hscl[, number vscl[,
2303  number ck]])
2304 \end_layout
2306 \begin_layout Itemize
2307 Syntax: none gui.bitmap_blit_scaled(DBITMAP dest, number dx, number dy, DBITMAP
2308  src, number sx, number sy, number w, number h, number hscl[, number vscl[,
2309  number ck]])
2310 \end_layout
2312 \begin_layout Itemize
2313 Syntax: none gui.bitmap_blit_scaled(DBITMAP dest, number dx, number dy, BITMAP
2314  src, PALETTE pal, number sx, number sy, number w, number h, number hscl[,
2315  number vscl[, number ck]])
2316 \end_layout
2318 \begin_layout Itemize
2319 Syntax: none BITMAP::blit_scaled(number dx, number dy, BITMAP src, number
2320  sx, number sy, number w, number h, number hscl[, number vscl[, number ck]])
2321 \end_layout
2323 \begin_layout Itemize
2324 Syntax: none DBITMAP::blit_scaled(number dx, number dy, DBITMAP src, number
2325  sx, number sy, number w, number h, number hscl[, number vscl[, number ck]])
2326 \end_layout
2328 \begin_layout Itemize
2329 Syntax: none DBITMAP:blit_scaled(number dx, number dy, BITMAP src, PALETTE
2330  pal, number sx, number sy, number w, number h, number hscl[, number vscl[,
2331  number ck]])
2332 \end_layout
2334 \begin_layout Standard
2335 Like (D)BITMAP:blit, but also scale the image horizontally by <hscl> and
2336  vertically by <vscl> (if not specified, <vscl> defaults to <hscl>).
2337 \end_layout
2339 \begin_layout Subsection
2340 gui.bitmap_blit_porterduff/(D)BITMAP:blit_porterduff: Blit a bitmap into
2341  another with Porter-Duff composition
2342 \end_layout
2344 \begin_layout Itemize
2345 Syntax: none gui.bitmap_blit_porterduff(BITMAP dest, number dx, number dy,
2346  BITMAP src, number sx, number sy, number w, number h, string operator)
2347 \end_layout
2349 \begin_layout Itemize
2350 Syntax: none gui.bitmap_blit_porterduff(DBITMAP dest, number dx, number dy,
2351  DBITMAP src, number sx, number sy, number w, number h, string operator)
2352 \end_layout
2354 \begin_layout Itemize
2355 Syntax: none gui.bitmap_blit_porterduff(DBITMAP dest, number dx, number dy,
2356  BITMAP src, PALETTE pal, number sx, number sy, number w, number h, string
2357  operator)
2358 \end_layout
2360 \begin_layout Itemize
2361 Syntax: none BITMAP::blit_porterduff(number dx, number dy, BITMAP src, number
2362  sx, number sy, number w, number h, string operator)
2363 \end_layout
2365 \begin_layout Itemize
2366 Syntax: none DBITMAP::blit_porterduff(number dx, number dy, DBITMAP src,
2367  number sx, number sy, number w, number h, string operator)
2368 \end_layout
2370 \begin_layout Itemize
2371 Syntax: none DBITMAP:blit_porterduff(number dx, number dy, BITMAP src, PALETTE
2372  pal, number sx, number sy, number w, number h, string operator)
2373 \end_layout
2375 \begin_layout Standard
2376 Like (D)BITMAP:blit, but applying specified Porter-Duff operator.
2377  BITMAPs always have color 0 treated as background, DBITMAPs treat full
2378  opaque as background.
2379  <operator> may be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver,
2380  DestIn, DestOut, Clear or Xor.
2381 \end_layout
2383 \begin_layout Subsection
2384 gui.bitmap_blit_scaled_porterduff/(D)BITMAP:blit_scaled_porterduff: Blit
2385  a bitmap into another with scaling and Porter-Duff composition
2386 \end_layout
2388 \begin_layout Itemize
2389 Syntax: none gui.bitmap_blit_scaled_porterduff(BITMAP dest, number dx, number
2390  dy, BITMAP src, number sx, number sy, number w, number h, number hscl,
2391  number vscl, string operator)
2392 \end_layout
2394 \begin_layout Itemize
2395 Syntax: none gui.bitmap_blit_scaled_porterduff(DBITMAP dest, number dx, number
2396  dy, DBITMAP src, number sx, number sy, number w, number h, number hscl,
2397  number vscl, string operator)
2398 \end_layout
2400 \begin_layout Itemize
2401 Syntax: none gui.bitmap_blit_scaled_porterduff(DBITMAP dest, number dx, number
2402  dy, BITMAP src, PALETTE pal, number sx, number sy, number w, number h,
2403  number hscl, number vscl, string operator)
2404 \end_layout
2406 \begin_layout Itemize
2407 Syntax: none BITMAP::blit_scaled_porterduff(number dx, number dy, BITMAP
2408  src, number sx, number sy, number w, number h, number hscl, number vscl,
2409  string operator)
2410 \end_layout
2412 \begin_layout Itemize
2413 Syntax: none DBITMAP::blit_scaled_porterduff(number dx, number dy, DBITMAP
2414  src, number sx, number sy, number w, number h, number hscl, number vscl,
2415  string operator)
2416 \end_layout
2418 \begin_layout Itemize
2419 Syntax: none DBITMAP:blit_scaled_porterduff(number dx, number dy, BITMAP
2420  src, PALETTE pal, number sx, number sy, number w, number h, number hscl,
2421  number vscl, string operator)
2422 \end_layout
2424 \begin_layout Standard
2425 Like (D)BITMAP:blit_porterduff, but also scale the image horizontally by
2426  <hscl> and vertically by <vscl> (if nil, <vscl> defaults to <hscl>).
2427 \end_layout
2429 \begin_layout Subsection
2430 gui.bitmap_blit_priority/BITMAP:blit_priority: Blit a bitmap into another
2431  with color priority
2432 \end_layout
2434 \begin_layout Itemize
2435 Syntax: none gui.bitmap_blit_priority(BITMAP dest, number dx, number dy,
2436  BITMAP src, number sx, number sy, number w, number h)
2437 \end_layout
2439 \begin_layout Itemize
2440 Syntax: none BITMAP::blit_priority(number dx, number dy, BITMAP src, number
2441  sx, number sy, number w, number h)
2442 \end_layout
2444 \begin_layout Standard
2445 Like BITMAP:blit, but copy a pixel only if source palette index is greater
2446  than destination palette index.
2447 \end_layout
2449 \begin_layout Subsection
2450 gui.bitmap_blit_scaled_priority/BITMAP:blit_scaled_priority: Blit a bitmap
2451  into another with color priority and scaling
2452 \end_layout
2454 \begin_layout Itemize
2455 Syntax: none gui.bitmap_blit_scaled_priority(BITMAP dest, number dx, number
2456  dy, BITMAP src, number sx, number sy, number w, number h, number hscl[,
2457  number vscl])
2458 \end_layout
2460 \begin_layout Itemize
2461 Syntax: none BITMAP::blit_scaled_priority(number dx, number dy, BITMAP src,
2462  number sx, number sy, number w, number h, number hscl[, number vscl])
2463 \end_layout
2465 \begin_layout Standard
2466 Like BITMAP:blit_scaled, but copy a pixel only if source palette index is
2467  greater than destination palette index.
2468 \end_layout
2470 \begin_layout Subsection
2471 gui.repaint: Arrange a repaint
2472 \end_layout
2474 \begin_layout Itemize
2475 Syntax: none gui.repaint()
2476 \end_layout
2478 \begin_layout Standard
2479 Request on_repaint() to happen as soon as possible.
2480 \end_layout
2482 \begin_layout Subsection
2483 gui.subframe_update: Enable/Disable subframe updates
2484 \end_layout
2486 \begin_layout Itemize
2487 Syntax: none gui.subframe_update(boolean on)
2488 \end_layout
2490 \begin_layout Standard
2491 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
2492  or not happen (<on>=false).
2493 \end_layout
2495 \begin_layout Subsection
2496 gui.screenshot: Write a screenshot
2497 \end_layout
2499 \begin_layout Itemize
2500 Syntax: none gui.screenshot(string filename)
2501 \end_layout
2503 \begin_layout Standard
2504 Write PNG screenshot of the current frame (no drawings) to specified file
2505  <filename>.
2506 \end_layout
2508 \begin_layout Subsection
2509 gui.screenshot_bitmap: Write a screenshot to bitmap
2510 \end_layout
2512 \begin_layout Itemize
2513 Syntax: DBITMAP gui.screenshot_bitmap()
2514 \end_layout
2516 \begin_layout Standard
2517 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
2518  the result.
2519 \end_layout
2521 \begin_layout Subsection
2522 gui.color: Compose a color.
2523 \end_layout
2525 \begin_layout Itemize
2526 Syntax: number gui.color(number r, number g, number b[, number a])
2527 \end_layout
2529 \begin_layout Itemize
2530 Syntax: number gui.color(string c)
2531 \end_layout
2533 \begin_layout Standard
2534 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
2535 , each component in scale 0-255.
2536  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
2537  fully opaque).
2538  The default alpha is 256.
2539 \end_layout
2541 \begin_layout Standard
2542 The form taking a string returns color corresponding color name.
2543 \end_layout
2545 \begin_layout Subsection
2546 gui.status: Set status variable
2547 \end_layout
2549 \begin_layout Itemize
2550 Syntax: none gui.status(string name, string value)
2551 \end_layout
2553 \begin_layout Standard
2554 Set status field 
2555 \begin_inset Quotes eld
2556 \end_inset
2558 L[<name>]
2559 \begin_inset Quotes erd
2560 \end_inset
2562  to <value> in status area.
2563 \end_layout
2565 \begin_layout Subsection
2566 gui.rainbow: Rainbow color calculation
2567 \end_layout
2569 \begin_layout Itemize
2570 Syntax: number gui.rainbow(number step, number steps[, number color])
2571 \end_layout
2573 \begin_layout Standard
2574 Perform hue rotation of color <color> (default bright red), by <step> steps.
2575  The number of steps per full rotation is given by absolute value of <steps>.
2576 \end_layout
2578 \begin_layout Standard
2579 If <step> is negative, the rotation will be counterclockwise.
2580 \end_layout
2582 \begin_layout Subsection
2583 gui.loadfont: Load a font file
2584 \end_layout
2586 \begin_layout Itemize
2587 Syntax: CUSTOMFONT gui.loadfont([string filename[, string relative_to]])
2588 \end_layout
2590 \begin_layout Standard
2591 Loads font from specified file (CUSTOMFONT object).
2592  If filename is not given, loads the system default font.
2593 \end_layout
2595 \begin_layout Subsection
2596 gui.font_new: Return a new empty font
2597 \end_layout
2599 \begin_layout Itemize
2600 Syntax: CUSTOMFONT gui.font_new()
2601 \end_layout
2603 \begin_layout Standard
2604 Returns a new font with no characters.
2605 \end_layout
2607 \begin_layout Subsection
2608 CUSTOMFONT(): Render text to screen
2609 \end_layout
2611 \begin_layout Itemize
2612 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
2613  bgc[, number hlc]]])
2614 \end_layout
2616 \begin_layout Standard
2617 Draw string with custom font to screen.
2618  The parameters are the same as in gui.text, except <hlc> is the halo color
2619  (default is no halo).
2621 \end_layout
2623 \begin_layout Subsection
2624 CUSTOMFONT:edit: Alter glyph in font
2625 \end_layout
2627 \begin_layout Itemize
2628 Syntax: none CUSTOMFONT:edit(string character, BITMAP glyph)
2629 \end_layout
2631 \begin_layout Standard
2632 Alter the character <character> (UTF-8 encoded) in font to use glyph specified
2633  by bitmap <glyph>.
2634  The conversion to monochrome is done by treating color 0 as background,
2635  and everything else as foreground.
2636 \end_layout
2638 \begin_layout Standard
2639 If <character> is empty string, the bad glyph is edited.
2640  If <character> has multiple characters, corresponding ligature glyph is
2641  edited.
2642 \end_layout
2644 \begin_layout Subsection
2645 gui.adjust_transparency/DBITMAP:adjust_transparency/PALETTE:adjust_transparency:
2646  Adjust transparency of DBITMAP or PALETTE
2647 \end_layout
2649 \begin_layout Itemize
2650 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
2651 \end_layout
2653 \begin_layout Itemize
2654 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
2655 \end_layout
2657 \begin_layout Itemize
2658 Syntax: none DBITMAP:adjust_transparency(number adj)
2659 \end_layout
2661 \begin_layout Itemize
2662 Syntax: none PALETTE:adjust_transparency(number adj)
2663 \end_layout
2665 \begin_layout Standard
2666 Multiply alpha channel of <obj> by <adj>/256.
2667  Useful for making 
2668 \begin_inset Quotes eld
2669 \end_inset
2671 ghosts
2672 \begin_inset Quotes erd
2673 \end_inset
2675  out of solid bitmaps.
2676 \end_layout
2678 \begin_layout Subsection
2679 gui.kill_frame: Kill video frame and associated sound
2680 \end_layout
2682 \begin_layout Itemize
2683 Syntax: none gui.kill_frame()
2684 \end_layout
2686 \begin_layout Standard
2687 Kills the currently dumped video frame + the associated sound.
2688  Only valid in on_video callback.
2689 \end_layout
2691 \begin_layout Subsection
2692 gui.set_video_scale: Set video frame scale
2693 \end_layout
2695 \begin_layout Itemize
2696 Syntax: none gui.set_video_scale(number h, number v)
2697 \end_layout
2699 \begin_layout Standard
2700 Sets the scale factors of current frame to <h>x<v>.
2701  Only valid in on_video callback.
2702 \end_layout
2704 \begin_layout Subsection
2705 gui.arrow: Draw an arrow
2706 \end_layout
2708 \begin_layout Itemize
2709 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
2710  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
2712 \end_layout
2714 \begin_layout Standard
2715 Draws an arrow using color <color>.
2716  The tip of arrow is at (<x>, <y>).
2717  Other parameters:
2718 \end_layout
2720 \begin_layout Enumerate
2721 <length>: The length of arrow tail.
2722 \end_layout
2724 \begin_layout Enumerate
2725 <hwidth>: The width of arrow head.
2726  Should be odd.
2727 \end_layout
2729 \begin_layout Enumerate
2730 <direction>: Direction of arrow.
2731  0 is to right, +1 rotates 45 degrees counterclockwise.
2732 \end_layout
2734 \begin_layout Enumerate
2735 <fill>: If true, fill the arrow head.
2736  Default false.
2737 \end_layout
2739 \begin_layout Enumerate
2740 <twidth>: Tail width.
2741  Should be odd.
2742  Default 1.
2743 \end_layout
2745 \begin_layout Enumerate
2746 <hthick>: Head thickness (only used if <fill> is false).
2747  Default is <twidth>.
2748 \end_layout
2750 \begin_layout Subsection
2751 gui.bitmap_save_png/(D)BITMAP:save_png: Save a bitmap to PNG
2752 \end_layout
2754 \begin_layout Itemize
2755 Syntax: none gui.bitmap_save_png(string filename[, string base], BITMAP bmp,
2756  PALETTE pal)
2757 \end_layout
2759 \begin_layout Itemize
2760 Syntax: none gui.bitmap_save_png(string filename[, string base], DBITMAP
2761  bmp)
2762 \end_layout
2764 \begin_layout Itemize
2765 Syntax: string gui.bitmap_save_png(BITMAP bmp, PALETTE pal)
2766 \end_layout
2768 \begin_layout Itemize
2769 Syntax: string gui.bitmap_save_png(DBITMAP bmp)
2770 \end_layout
2772 \begin_layout Itemize
2773 Syntax: none BITMAP:save_png(string filename[, string base], PALETTE pal)
2774 \end_layout
2776 \begin_layout Itemize
2777 Syntax: none DBITMAP:save_png(string filename[, string base])
2778 \end_layout
2780 \begin_layout Itemize
2781 Syntax: string BITMAP:save_png(PALETTE pal)
2782 \end_layout
2784 \begin_layout Itemize
2785 Syntax: string DBITMAP:save_png()
2786 \end_layout
2788 \begin_layout Standard
2789 Save specified bitmap <bmp> (or current object), with palette <pal> (only
2790  if paletted) into PNG file <filename> (relative to <base>) or return BASE64
2791  encoding as return value.
2792 \end_layout
2794 \begin_layout Subsection
2795 gui.bitmap_hash/(D)BITMAP:hash: Hash a bitmap
2796 \end_layout
2798 \begin_layout Itemize
2799 Syntax: string gui.bitmap_hash(BITMAP bmp)
2800 \end_layout
2802 \begin_layout Itemize
2803 Syntax: string gui.bitmap_hash(DBITMAP bmp)
2804 \end_layout
2806 \begin_layout Itemize
2807 Syntax: string BITMAP:hash()
2808 \end_layout
2810 \begin_layout Itemize
2811 Syntax: string DBITMAP:hash()
2812 \end_layout
2814 \begin_layout Standard
2815 Hashes bitmap <bmp> (or current object) and returns 64-hex digit crypto-strong
2816  hash.
2817  Identical bitmaps result in indentical hashes (but color order in indexed
2818  bitmaps is significant).
2819 \end_layout
2821 \begin_layout Subsection
2822 gui.palette_hash/PALETTE:hash: Hash a palette
2823 \end_layout
2825 \begin_layout Itemize
2826 Syntax: string gui.palette_hash(PALETTE pal)
2827 \end_layout
2829 \begin_layout Itemize
2830 Syntax: string PALETTE:hash(PALETTE pal)
2831 \end_layout
2833 \begin_layout Standard
2834 Hashes palette <pal> (or current object) and retruns 64-hex digit crypto-strong
2835  hash.
2836  Identical palettes result in identical hashes (fully transparent colors
2837  at end of palette don't affect the hash).
2838 \end_layout
2840 \begin_layout Standard
2841 \begin_inset Newpage pagebreak
2842 \end_inset
2845 \end_layout
2847 \begin_layout Section
2848 table input
2849 \end_layout
2851 \begin_layout Standard
2852 Input handling.
2853  Functions manipulating input are only available in on_input callback.
2854 \end_layout
2856 \begin_layout Subsection
2857 input.get: Read controller button/axis (deprecated)
2858 \end_layout
2860 \begin_layout Itemize
2861 Syntax: number input.get(number controller, number index)
2862 \end_layout
2864 \begin_layout Standard
2865 Read the specified index <index> (zero-based) from specified controller
2866  <controller> (zero-based).
2868 \end_layout
2870 \begin_layout Subsection
2871 input.set: Write controller button/axis (deprecated)
2872 \end_layout
2874 \begin_layout Itemize
2875 Syntax: none input.set(number controller, number index, number value)
2876 \end_layout
2878 \begin_layout Standard
2879 Write the specified index <index> (zero-based) from specified controller
2880  <controller> (zero-based), storing value <value>.
2881 \end_layout
2883 \begin_layout Subsection
2884 input.get2: Read controller button/axis
2885 \end_layout
2887 \begin_layout Itemize
2888 Syntax: number input.get2(number port, number controller, number index)
2889 \end_layout
2891 \begin_layout Standard
2892 Read the specified input tuple.
2893  Port 0 is system port.
2894 \end_layout
2896 \begin_layout Subsection
2897 input.set2: Write controller button/axis
2898 \end_layout
2900 \begin_layout Itemize
2901 Syntax: input.set2(number port, number controller, number index, number value)
2902 \end_layout
2904 \begin_layout Standard
2905 Write the specified input tuple.
2906  Port 0 is system port.
2907 \end_layout
2909 \begin_layout Subsection
2910 input.lcid_to_pcid2: Look up logical controller
2911 \end_layout
2913 \begin_layout Itemize
2914 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
2915 \end_layout
2917 \begin_layout Standard
2918 Look up physical pcid pair (port, controller) corresponding to specified
2919  logical controller (1-based).
2920  Returns nothing if controller does not exist.
2921 \end_layout
2923 \begin_layout Subsection
2924 input.port_type: Look up port type
2925 \end_layout
2927 \begin_layout Itemize
2928 Syntax: string input.port_type(number port)
2929 \end_layout
2931 \begin_layout Standard
2932 Return type of specified port.
2933 \end_layout
2935 \begin_layout Subsection
2936 input.controller_info: Get information about controller
2937 \end_layout
2939 \begin_layout Itemize
2940 Syntax: table input.controller_info(number port, number controller)
2941 \end_layout
2943 \begin_layout Standard
2944 Get controller info for specified controller.
2945  If controller does not exist, returns nil.
2946  Otherwise returns a table with following fields:
2947 \end_layout
2949 \begin_layout Itemize
2950 type (string): Type of the controller.
2951 \end_layout
2953 \begin_layout Itemize
2954 class (string): Class of the controller.
2955 \end_layout
2957 \begin_layout Itemize
2958 classnum (number): Number of the controller within its class (1-based)
2959 \end_layout
2961 \begin_layout Itemize
2962 lcid (number): Logical controller number of the controller.
2963 \end_layout
2965 \begin_layout Itemize
2966 button_count (number): Number of buttons on controller
2967 \end_layout
2969 \begin_layout Itemize
2970 buttons (array): Array of following info about each button:
2971 \end_layout
2973 \begin_deeper
2974 \begin_layout Itemize
2975 type (string): Type of button.
2976  Currently one of 
2977 \begin_inset Quotes eld
2978 \end_inset
2980 null
2981 \begin_inset Quotes erd
2982 \end_inset
2985 \begin_inset Quotes eld
2986 \end_inset
2988 button
2989 \begin_inset Quotes erd
2990 \end_inset
2993 \begin_inset Quotes eld
2994 \end_inset
2996 axis
2997 \begin_inset Quotes erd
2998 \end_inset
3001 \begin_inset Quotes eld
3002 \end_inset
3004 raxis
3005 \begin_inset Quotes erd
3006 \end_inset
3009 \end_layout
3011 \begin_layout Itemize
3012 name (string): Name of button.
3013 \end_layout
3015 \begin_layout Itemize
3016 symbol (string): Symbol of button.
3017  Only present for type 
3018 \begin_inset Quotes eld
3019 \end_inset
3021 button
3022 \begin_inset Quotes erd
3023 \end_inset
3026 \end_layout
3028 \begin_layout Itemize
3029 hidden (boolean): True if hidden button.
3031 \end_layout
3033 \end_deeper
3034 \begin_layout Subsection
3035 input.veto_button: Veto a button press
3036 \end_layout
3038 \begin_layout Itemize
3039 Syntax: none input.veto_button()
3040 \end_layout
3042 \begin_layout Standard
3043 Signals that the button event should be vetoed.
3044  Only valid in on_button callback.
3045 \end_layout
3047 \begin_layout Subsection
3048 input.geta: Get all buttons for controller (deprecated)
3049 \end_layout
3051 \begin_layout Itemize
3052 Syntax: (number, number...) input.geta(number controller)
3053 \end_layout
3055 \begin_layout Standard
3056 Get input state for entiere controller.
3057  Returns n return values.
3058 \end_layout
3060 \begin_layout Itemize
3061 1st return value: Bitmask: bit i is set if i:th index is nonzero
3062 \end_layout
3064 \begin_layout Itemize
3065 2nd- return value: value of i:th index.
3066 \end_layout
3068 \begin_layout Subsection
3069 input.seta: Set all buttons for controller (deprecated)
3070 \end_layout
3072 \begin_layout Itemize
3073 Syntax: none input.seta(number controller, number bitmask, number args...)
3074 \end_layout
3076 \begin_layout Standard
3077 Set state for entiere controller.
3078  args is up to N values for indices (overriding values in bitmask if specified).
3079 \end_layout
3081 \begin_layout Subsection
3082 input.controllertype: Get controller type (deprecated)
3083 \end_layout
3085 \begin_layout Itemize
3086 syntax: string input.controllertype(number controller)
3087 \end_layout
3089 \begin_layout Standard
3090 Get the type of controller as string.
3091 \end_layout
3093 \begin_layout Subsection
3094 input.reset: Execute (delayed) reset
3095 \end_layout
3097 \begin_layout Itemize
3098 Syntax: none input.reset([number cycles])
3099 \end_layout
3101 \begin_layout Standard
3102 Execute reset.
3103  If <cycles> is greater than zero, do delayed reset.
3104  0 (or no value) causes immediate reset.
3105 \end_layout
3107 \begin_layout Itemize
3108 Note: Only available with subframe flag false.
3109 \end_layout
3111 \begin_layout Subsection
3112 input.raw: Return raw input data
3113 \end_layout
3115 \begin_layout Itemize
3116 Syntax: table input.raw()
3117 \end_layout
3119 \begin_layout Standard
3120 Returns table of tables of all available keys and axes.
3121  The first table is indexed by key name (platform-dependent!), and the inner
3122  table has the following fields:
3123 \end_layout
3125 \begin_layout Itemize
3126 value: Last reported value for control
3127 \end_layout
3129 \begin_deeper
3130 \begin_layout Itemize
3131 For keys: 1 for pressed, 0 for released.
3132 \end_layout
3134 \begin_layout Itemize
3135 For axes: -32767...32767.
3136 \end_layout
3138 \begin_layout Itemize
3139 For presure-sensitive buttons: 0...32767.
3140 \end_layout
3142 \begin_layout Itemize
3143 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
3144 \end_layout
3146 \begin_layout Itemize
3147 For mouse: Coordinates relative to game area.
3148 \end_layout
3150 \end_deeper
3151 \begin_layout Itemize
3152 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
3153 \end_layout
3155 \begin_layout Subsection
3156 input.keyhook: Hook a key
3157 \end_layout
3159 \begin_layout Itemize
3160 Syntax: none input.keyhook(string key, boolean state)
3161 \end_layout
3163 \begin_layout Standard
3164 Requests that keyhook events to be sent for key <key> (<state>=true) or
3165  not sent (<state>=false).
3166 \end_layout
3168 \begin_layout Subsection
3169 input.joyget: Get controls for controller
3170 \end_layout
3172 \begin_layout Itemize
3173 Syntax: table input.joyget(number logical)
3174 \end_layout
3176 \begin_layout Standard
3177 Returns table for current controls for specified logical controller <logical>.
3178  The names of fields vary by controller type.
3179 \end_layout
3181 \begin_layout Itemize
3182 The buttons have the same name as those are referred to in other contexts
3183  in the emulator
3184 \end_layout
3186 \begin_layout Itemize
3187 The analog axes are usually 
3188 \begin_inset Quotes eld
3189 \end_inset
3191 xaxis
3192 \begin_inset Quotes erd
3193 \end_inset
3195  and 
3196 \begin_inset Quotes eld
3197 \end_inset
3199 yaxis
3200 \begin_inset Quotes erd
3201 \end_inset
3204 \end_layout
3206 \begin_layout Itemize
3207 Each field is numeric or boolean depending on axis/button.
3208 \end_layout
3210 \begin_layout Subsection
3211 input.joyset: Set controls for controller
3212 \end_layout
3214 \begin_layout Itemize
3215 Syntax: none input.joyset(number controller, table controls)
3216 \end_layout
3218 \begin_layout Standard
3219 Set the the state of specified controller to values specified in specified
3220  table.
3221 \end_layout
3223 \begin_layout Itemize
3224 Each field can be boolean or number.
3225 \end_layout
3227 \begin_layout Itemize
3228 Also, buttons allow strings, which cause value to be inverted.
3229 \end_layout
3231 \begin_layout Subsection
3232 input.lcid_to_pcid: Look up logical controller (deprecated)
3233 \end_layout
3235 \begin_layout Itemize
3236 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
3237 \end_layout
3239 \begin_layout Standard
3240 Returns the legacy pcid for controller (or false if there isn't one), followed
3241  by pcid pair.
3242  Returns nothing if controller does not exist.
3243 \end_layout
3245 \begin_layout Standard
3246 \begin_inset Newpage pagebreak
3247 \end_inset
3250 \end_layout
3252 \begin_layout Section
3253 Table keyboard
3254 \end_layout
3256 \begin_layout Standard
3257 Various keybinding-related functions
3258 \end_layout
3260 \begin_layout Subsection
3261 keyboard.bind: Bind a key
3262 \end_layout
3264 \begin_layout Itemize
3265 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
3266 \end_layout
3268 \begin_layout Standard
3269 Bind specified key with specified modifers to specified command.
3270 \end_layout
3272 \begin_layout Subsection
3273 keyboard.unbind: Unbind a key
3274 \end_layout
3276 \begin_layout Itemize
3277 Syntax: none keyboard.unbind(string mod, string mask, string key)
3278 \end_layout
3280 \begin_layout Standard
3281 Unbind specified key with specified modifers.
3282 \end_layout
3284 \begin_layout Subsection
3285 keyboard.alias: Set alias expansion
3286 \end_layout
3288 \begin_layout Itemize
3289 Syntax: none keyboard.alias(string alias, string expansion)
3290 \end_layout
3292 \begin_layout Standard
3293 Set expansion of given command.
3294 \end_layout
3296 \begin_layout Standard
3297 \begin_inset Newpage pagebreak
3298 \end_inset
3301 \end_layout
3303 \begin_layout Section
3304 Table subtitle
3305 \end_layout
3307 \begin_layout Standard
3308 Subtitle handling
3309 \end_layout
3311 \begin_layout Subsection
3312 subtitle.byindex: Look up start and length of subtitle by index
3313 \end_layout
3315 \begin_layout Itemize
3316 Syntax: (number, number) subtitle.byindex(number i)
3317 \end_layout
3319 \begin_layout Standard
3320 Read the frame and length of ith subtitle.
3321  Returns nothing if not present.
3322 \end_layout
3324 \begin_layout Subsection
3325 subtitle.set: Write a subtitle
3326 \end_layout
3328 \begin_layout Itemize
3329 Syntax: none subtitle.set(number f, number l, string txt)
3330 \end_layout
3332 \begin_layout Standard
3333 Set the text of subtitle.
3334 \end_layout
3336 \begin_layout Subsection
3337 subtitle.get: Read a subtitle
3338 \end_layout
3340 \begin_layout Itemize
3341 Syntax: string subtitle.get(number f, number l)
3342 \end_layout
3344 \begin_layout Standard
3345 Get the text of subtitle.
3346 \end_layout
3348 \begin_layout Subsection
3349 subtitle.delete: Delete a subtitle
3350 \end_layout
3352 \begin_layout Itemize
3353 Syntax: nonesubtitle.delete(number f, number l)
3354 \end_layout
3356 \begin_layout Standard
3357 Delete specified subtitle.
3358 \end_layout
3360 \begin_layout Standard
3361 \begin_inset Newpage pagebreak
3362 \end_inset
3365 \end_layout
3367 \begin_layout Section
3368 Table hostmemory
3369 \end_layout
3371 \begin_layout Standard
3372 Host memory handling (extra memory saved to savestates).
3373  Host memory starts empty.
3374 \end_layout
3376 \begin_layout Itemize
3377 Reads out of range return false.
3378 \end_layout
3380 \begin_layout Itemize
3381 Writes out of range extend the memory.
3382 \end_layout
3384 \begin_layout Subsection
3385 hostmemory.read: Read byte from host memory
3386 \end_layout
3388 \begin_layout Itemize
3389 Syntax: number hostmemory.read(number address)
3390 \end_layout
3392 \begin_layout Standard
3393 Reads byte from hostmemory slot address <address>.
3394 \end_layout
3396 \begin_layout Subsection
3397 hostmemory.write: Write byte to host memory
3398 \end_layout
3400 \begin_layout Itemize
3401 Syntax: none hostmemory.write(number address, number value)
3402 \end_layout
3404 \begin_layout Standard
3405 Writes hostmemory slot with value <value> 0-255.
3406 \end_layout
3408 \begin_layout Subsection
3409 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
3410 \end_layout
3412 \begin_layout Itemize
3413 Syntax: number hostmemory.readbyte(number address)
3414 \end_layout
3416 \begin_layout Itemize
3417 Syntax: number hostmemory.readsbyte(number address)
3418 \end_layout
3420 \begin_layout Itemize
3421 Syntax: number hostmemory.readword(number address)
3422 \end_layout
3424 \begin_layout Itemize
3425 Syntax: number hostmemory.readsword(number address)
3426 \end_layout
3428 \begin_layout Itemize
3429 Syntax: number hostmemory.readhword(number address)
3430 \end_layout
3432 \begin_layout Itemize
3433 Syntax: number hostmemory.readshword(number address)
3434 \end_layout
3436 \begin_layout Itemize
3437 Syntax: number hostmemory.readdword(number address)
3438 \end_layout
3440 \begin_layout Itemize
3441 Syntax: number hostmemory.readsdword(number address)
3442 \end_layout
3444 \begin_layout Itemize
3445 Syntax: number hostmemory.readqword(number address)
3446 \end_layout
3448 \begin_layout Itemize
3449 Syntax: number hostmemory.readsqword(number address)
3450 \end_layout
3452 \begin_layout Standard
3453 Read elements (big-endian) from given address <address>.
3454 \end_layout
3456 \begin_layout Itemize
3457 byte is 1 element
3458 \end_layout
3460 \begin_layout Itemize
3461 word is 2 elements
3462 \end_layout
3464 \begin_layout Itemize
3465 hword is 3 elements
3466 \end_layout
3468 \begin_layout Itemize
3469 dword is 4 elements
3470 \end_layout
3472 \begin_layout Itemize
3473 qword is 8 elements.
3474 \end_layout
3476 \begin_layout Itemize
3477 The 's' variants do signed read.
3478 \end_layout
3480 \begin_layout Subsection
3481 hostmemory.read{float,double}: Read from host memory
3482 \end_layout
3484 \begin_layout Itemize
3485 syntax: number hostmemory.readfloat(number address)
3486 \end_layout
3488 \begin_layout Itemize
3489 Syntax: number hostmemory.readdouble(number address)
3490 \end_layout
3492 \begin_layout Standard
3493 Read elements (big-endian) floating-pont from given address <address>.
3494 \end_layout
3496 \begin_layout Subsection
3497 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
3498 \end_layout
3500 \begin_layout Itemize
3501 Syntax: number hostmemory.writebyte(number address, number value)
3502 \end_layout
3504 \begin_layout Itemize
3505 Syntax: number hostmemory.writesbyte(number address, number value)
3506 \end_layout
3508 \begin_layout Itemize
3509 Syntax: number hostmemory.writeword(number address, number value)
3510 \end_layout
3512 \begin_layout Itemize
3513 Syntax: number hostmemory.writesword(number address, number value)
3514 \end_layout
3516 \begin_layout Itemize
3517 Syntax: number hostmemory.writehword(number address, number value)
3518 \end_layout
3520 \begin_layout Itemize
3521 Syntax: number hostmemory.writeshword(number address, number value)
3522 \end_layout
3524 \begin_layout Itemize
3525 Syntax: number hostmemory.writedword(number address, number value)
3526 \end_layout
3528 \begin_layout Itemize
3529 Syntax: number hostmemory.writesdword(number address, number value)
3530 \end_layout
3532 \begin_layout Itemize
3533 Syntax: number hostmemory.writeqword(number address, number value)
3534 \end_layout
3536 \begin_layout Itemize
3537 Syntax: number hostmemory.writesqword(number address, number value)
3538 \end_layout
3540 \begin_layout Standard
3541 Write value <value> to elements (little-endian) starting from given address
3542  <address>.
3543 \end_layout
3545 \begin_layout Itemize
3546 byte is 1 element
3547 \end_layout
3549 \begin_layout Itemize
3550 word is 2 elements
3551 \end_layout
3553 \begin_layout Itemize
3554 hword is 3 elements
3555 \end_layout
3557 \begin_layout Itemize
3558 dword is 4 elements
3559 \end_layout
3561 \begin_layout Itemize
3562 qword is 8 elements.
3563 \end_layout
3565 \begin_layout Itemize
3566 The 's' variants do signed write.
3567 \end_layout
3569 \begin_layout Subsection
3570 hostmemory.write{float,double}: Write to host memory
3571 \end_layout
3573 \begin_layout Itemize
3574 syntax: none hostmemory.readfloat(number address, number value)
3575 \end_layout
3577 \begin_layout Itemize
3578 Syntax: none hostmemory.readdouble(number address, number value)
3579 \end_layout
3581 \begin_layout Standard
3582 Write elements (big-endian) floating-pont to given address <address>, storing
3583  <value>.
3584 \end_layout
3586 \begin_layout Standard
3587 \begin_inset Newpage pagebreak
3588 \end_inset
3591 \end_layout
3593 \begin_layout Section
3594 Table movie
3595 \end_layout
3597 \begin_layout Standard
3598 Movie handling
3599 \end_layout
3601 \begin_layout Subsection
3602 movie.currentframe: Get current frame number
3603 \end_layout
3605 \begin_layout Itemize
3606 Syntax: number movie.currentframe()
3607 \end_layout
3609 \begin_layout Standard
3610 Return number of current frame.
3611 \end_layout
3613 \begin_layout Subsection
3614 movie.framecount: Get move frame count
3615 \end_layout
3617 \begin_layout Itemize
3618 Syntax: number movie.framecount()
3619 \end_layout
3621 \begin_layout Standard
3622 Return number of frames in movie.
3623 \end_layout
3625 \begin_layout Subsection
3626 movie.readonly: Is in readonly mode?
3627 \end_layout
3629 \begin_layout Itemize
3630 Syntax: boolean movie.readonly()
3631 \end_layout
3633 \begin_layout Standard
3634 Return true if in readonly mode, false if in readwrite.
3635 \end_layout
3637 \begin_layout Subsection
3638 movie.rerecords: Movie rerecord count
3639 \end_layout
3641 \begin_layout Itemize
3642 Syntax: number movie.rerecords()
3643 \end_layout
3645 \begin_layout Standard
3646 Returns the current value of rerecord count.
3647 \end_layout
3649 \begin_layout Subsection
3650 movie.set_readwrite: Set read-write mode.
3651 \end_layout
3653 \begin_layout Itemize
3654 Syntax: none movie.set_readwrite()
3655 \end_layout
3657 \begin_layout Standard
3658 Set readwrite mode (does not cause on_readwrite callback).
3659 \end_layout
3661 \begin_layout Subsection
3662 movie.frame_subframes: Count subframes in frame
3663 \end_layout
3665 \begin_layout Itemize
3666 Syntax: number movie.frame_subframes(number frame)
3667 \end_layout
3669 \begin_layout Standard
3670 Count number of subframes in specified frame <frame> (frame numbers are
3671  1-based) and return that.
3672 \end_layout
3674 \begin_layout Subsection
3675 movie.read_subframes: Read subframe data (deprecated)
3676 \end_layout
3678 \begin_layout Itemize
3679 Syntax: table movie.read_subframes(number frame, number subframe)
3680 \end_layout
3682 \begin_layout Standard
3683 Read specifed subframe in specified frame and return data as array.
3684 \end_layout
3686 \begin_layout Subsection
3687 movie.read_rtc: Read current RTC time
3688 \end_layout
3690 \begin_layout Itemize
3691 Syntax: (number, number) movie.read_rtc()
3692 \end_layout
3694 \begin_layout Standard
3695 Returns the current value of the RTC as a pair (second, subsecond).
3696 \end_layout
3698 \begin_layout Subsection
3699 movie.unsafe_rewind: Fast movie rewind to saved state
3700 \end_layout
3702 \begin_layout Itemize
3703 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
3704 \end_layout
3706 \begin_layout Standard
3707 Start setting point for unsafe rewind or jump to point of unsafe rewind.
3708 \end_layout
3710 \begin_layout Itemize
3711 If called without argument, causes emulator to start process of setting
3712  unsafe rewind point.
3713  When this has finished, callback on_set_rewind occurs, passing the rewind
3714  state to lua script.
3715 \end_layout
3717 \begin_layout Itemize
3718 If called with argument, causes emulator rewind to passed rewind point as
3719  soon as possible.
3720  Readwrite mode is implicitly activated.
3721 \end_layout
3723 \begin_layout Standard
3724 The following warnings apply to unsafe rewinding:
3725 \end_layout
3727 \begin_layout Itemize
3728 There are no safety checks against misuse (that's what 
3729 \begin_inset Quotes eld
3730 \end_inset
3732 unsafe
3733 \begin_inset Quotes erd
3734 \end_inset
3736  comes from)!
3737 \end_layout
3739 \begin_layout Itemize
3740 Only call rewind from timeline rewind point was set from.
3741 \end_layout
3743 \begin_layout Itemize
3744 Only call rewind from after the rewind point was set.
3745 \end_layout
3747 \begin_layout Subsection
3748 movie.to_rewind: Load savestate as rewind point
3749 \end_layout
3751 \begin_layout Itemize
3752 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
3753 \end_layout
3755 \begin_layout Standard
3756 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
3757  corresponding to it.
3758 \end_layout
3760 \begin_layout Itemize
3761 Note: This operation does not take emulated time.
3762 \end_layout
3764 \begin_layout Subsection
3765 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
3766 \end_layout
3768 \begin_layout Itemize
3769 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
3770 \end_layout
3772 \begin_layout Itemize
3773 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
3774 \end_layout
3776 \begin_layout Standard
3777 Copies specified movie <movie>/current object (if none or nil, the active
3778  movie) as new movie object.
3779 \end_layout
3781 \begin_layout Subsection
3782 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
3783 \end_layout
3785 \begin_layout Itemize
3786 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
3787 \end_layout
3789 \begin_layout Itemize
3790 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
3791 \end_layout
3793 \begin_layout Standard
3794 Get INPUTFRAME object corresponding to specified frame in specified movie.
3795 \end_layout
3797 \begin_layout Subsection
3798 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
3799 \end_layout
3801 \begin_layout Itemize
3802 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
3803  data)
3804 \end_layout
3806 \begin_layout Itemize
3807 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
3808 \end_layout
3810 \begin_layout Standard
3811 Set data in specified frame.
3812 \end_layout
3814 \begin_layout Itemize
3815 Note: Past can't be edited in active movie.
3816 \end_layout
3818 \begin_layout Subsection
3819 movie.get_size/INPUTMOVIE::get_size: Get size of movie
3820 \end_layout
3822 \begin_layout Itemize
3823 Syntax: integer movie.get_size([INPUTMOVIE movie])
3824 \end_layout
3826 \begin_layout Itemize
3827 Syntax: integer INPUTMOVIE::get_size()
3828 \end_layout
3830 \begin_layout Standard
3831 Return number of subframes in specified movie.
3832 \end_layout
3834 \begin_layout Subsection
3835 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
3836 \end_layout
3838 \begin_layout Itemize
3839 Syntax: number movie.count_frames([INPUTMOVIE movie])
3840 \end_layout
3842 \begin_layout Itemize
3843 Syntax: number INPUTMOVIE::count_frames()
3844 \end_layout
3846 \begin_layout Standard
3847 Return number of frames in movie.
3848 \end_layout
3850 \begin_layout Subsection
3851 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
3852 \end_layout
3854 \begin_layout Itemize
3855 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
3856 \end_layout
3858 \begin_layout Itemize
3859 Syntax: number INPUTMOVIE::find_frame(number frame)
3860 \end_layout
3862 \begin_layout Standard
3863 Returns starting subframe of given frame (frame numbers are 1-based).
3864  Returns -1 if frame number is bad.
3865 \end_layout
3867 \begin_layout Subsection
3868 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
3869 \end_layout
3871 \begin_layout Itemize
3872 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
3873 \end_layout
3875 \begin_layout Itemize
3876 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
3877 \end_layout
3879 \begin_layout Standard
3880 Return blank INPUTFRAME with frame type from specified movie.
3881 \end_layout
3883 \begin_layout Subsection
3884 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
3885 \end_layout
3887 \begin_layout Itemize
3888 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
3889 \end_layout
3891 \begin_layout Itemize
3892 Syntax: none INPUTMOVIE::append_frames(number frames)
3893 \end_layout
3895 \begin_layout Standard
3896 Append specified number <frames> of frames.
3897 \end_layout
3899 \begin_layout Subsection
3900 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
3901 \end_layout
3903 \begin_layout Itemize
3904 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
3905 \end_layout
3907 \begin_layout Itemize
3908 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
3909 \end_layout
3911 \begin_layout Standard
3912 Append specified frame <frame>.
3913  Past of current movie can't be edited.
3914 \end_layout
3916 \begin_layout Subsection
3917 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
3918 \end_layout
3920 \begin_layout Itemize
3921 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
3922 \end_layout
3924 \begin_layout Itemize
3925 Syntax: none INPUTMOVIE::truncate(number frames)
3926 \end_layout
3928 \begin_layout Standard
3929 Truncate the specified movie to specified number of frames.
3930 \end_layout
3932 \begin_layout Subsection
3933 movie.edit/INPUTMOVIE::edit: Edit a movie
3934 \end_layout
3936 \begin_layout Itemize
3937 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
3938  controller, number control, number/bool value)
3939 \end_layout
3941 \begin_layout Itemize
3942 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
3943  number control, number/bool value)
3944 \end_layout
3946 \begin_layout Standard
3947 Change specified control in specified frame in specified movie.
3948  Past can't be edited in active movie.
3949 \end_layout
3951 \begin_layout Subsection
3952 movie.copy_frames2: Copy frames between movies
3953 \end_layout
3955 \begin_layout Itemize
3956 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
3957  srcmov,] number src, number count)
3958 \end_layout
3960 \begin_layout Standard
3961 Copy specified number of frames between two movies.
3962  The copy proceeeds in forward direction.
3963 \end_layout
3965 \begin_layout Subsection
3966 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
3967 \end_layout
3969 \begin_layout Itemize
3970 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
3971  number count, bool backwards)
3972 \end_layout
3974 \begin_layout Itemize
3975 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
3976  bool backwards)
3977 \end_layout
3979 \begin_layout Standard
3980 Copy specified number of frames from one point in movie to another.
3981  If backwards is true, the copy will be done backwards.
3982 \end_layout
3984 \begin_layout Subsection
3985 movie.serialize/INPUTMOVIE::serialize: Serialize movie
3986 \end_layout
3988 \begin_layout Itemize
3989 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
3990 \end_layout
3992 \begin_layout Itemize
3993 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
3994 \end_layout
3996 \begin_layout Standard
3997 Serialize given movie into file.
3998  If binary is true, binary format (more compact and much faster) is used.
3999 \end_layout
4001 \begin_layout Subsection
4002 movie.unserialize: Unserialize movie
4003 \end_layout
4005 \begin_layout Itemize
4006 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
4007  bool binary)
4008 \end_layout
4010 \begin_layout Standard
4011 Unserialize movie from file.
4012  The given frame is used as template to decide the frame type.
4013  If binary is true, binary format is decoded (much faster).
4014 \end_layout
4016 \begin_layout Subsection
4017 movie.current_first_subframe: Return first subframe in current frame
4018 \end_layout
4020 \begin_layout Itemize
4021 Syntax: number movie.current_first_subframe()
4022 \end_layout
4024 \begin_layout Standard
4025 Returns first subframe in current frame.
4026 \end_layout
4028 \begin_layout Subsection
4029 movie.pollcounter: Return poll counter for speified control
4030 \end_layout
4032 \begin_layout Itemize
4033 Syntax: number movie.pollcounter(number port, number controller, number control)
4034 \end_layout
4036 \begin_layout Standard
4037 Returns number of times the specified control has been polled this frame.
4038 \end_layout
4040 \begin_layout Subsection
4041 INPUTFRAME::get_button: Get button
4042 \end_layout
4044 \begin_layout Itemize
4045 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
4046  control)
4047 \end_layout
4049 \begin_layout Standard
4050 Returns state of given button as boolean.
4051 \end_layout
4053 \begin_layout Subsection
4054 INPUTFRAME::get_axis: Get axis
4055 \end_layout
4057 \begin_layout Itemize
4058 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
4059  control)
4060 \end_layout
4062 \begin_layout Standard
4063 Returns state of given axis as number.
4064 \end_layout
4066 \begin_layout Subsection
4067 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
4068 \end_layout
4070 \begin_layout Itemize
4071 Syntax: none INPUTFRAME::set_button(number port, number controller, number
4072  control, number/bool value)
4073 \end_layout
4075 \begin_layout Itemize
4076 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
4077  control)
4078 \end_layout
4080 \begin_layout Standard
4081 Set the given button/axis to given value.
4082 \end_layout
4084 \begin_layout Subsection
4085 INPUTFRAME::serialize: Serialize a frame
4086 \end_layout
4088 \begin_layout Itemize
4089 Syntax: string INPUTFRAME::serialize()
4090 \end_layout
4092 \begin_layout Standard
4093 Return string representation of frame.
4094 \end_layout
4096 \begin_layout Subsection
4097 INPUTFRAME::unserialize: Unserialize a frame
4098 \end_layout
4100 \begin_layout Itemize
4101 Syntax: none INPUTFRAME::unserialize(string data)
4102 \end_layout
4104 \begin_layout Standard
4105 Set current frame from given data.
4106 \end_layout
4108 \begin_layout Subsection
4109 INPUTFRAME::get_stride: Get movie stride
4110 \end_layout
4112 \begin_layout Itemize
4113 Syntax: number INPUTFRAME::get_stride()
4114 \end_layout
4116 \begin_layout Standard
4117 Return number of bytes needed to store the input frame.
4118  Mainly useful for some debugging.
4119 \end_layout
4121 \begin_layout Standard
4122 \begin_inset Newpage pagebreak
4123 \end_inset
4126 \end_layout
4128 \begin_layout Section
4129 Table settings
4130 \end_layout
4132 \begin_layout Standard
4133 Routines for settings manipulation
4134 \end_layout
4136 \begin_layout Subsection
4137 settings.get: Get value of setting
4138 \end_layout
4140 \begin_layout Itemize
4141 Syntax: string settings.get(string name)
4142 \end_layout
4144 \begin_layout Standard
4145 Get value of setting <name>.
4146  If setting value can't be obtained, returns (nil, error message).
4147 \end_layout
4149 \begin_layout Subsection
4150 settings.set: Set value of setting
4151 \end_layout
4153 \begin_layout Itemize
4154 Syntax: none settings.set(string name, string value)
4155 \end_layout
4157 \begin_layout Standard
4158 Set value <value> of setting <name>.
4159  If setting can't be set, returns (nil, error message).
4160 \end_layout
4162 \begin_layout Standard
4163 \begin_inset Newpage pagebreak
4164 \end_inset
4167 \end_layout
4169 \begin_layout Section
4170 Table memory
4171 \end_layout
4173 \begin_layout Standard
4174 Contains various functions for managing memory
4175 \end_layout
4177 \begin_layout Subsection
4178 memory.vma_count: Count number of VMAs.
4179 \end_layout
4181 \begin_layout Itemize
4182 Syntax: number memory.vma_count()
4183 \end_layout
4185 \begin_layout Standard
4186 Returns the number of VMAs
4187 \end_layout
4189 \begin_layout Subsection
4190 memory.read_vma: Lookup VMA info by index
4191 \end_layout
4193 \begin_layout Itemize
4194 Syntax: string memory.read_vma(number index)
4195 \end_layout
4197 \begin_layout Standard
4198 Reads the specified VMA (indices start from zero).
4199  Trying to read invalid VMA gives nil.
4200  The read VMA is table with the following fields:
4201 \end_layout
4203 \begin_layout Itemize
4204 region_name (string): The readable name of the VMA
4205 \end_layout
4207 \begin_layout Itemize
4208 baseaddr (number): Base address of the VMA
4209 \end_layout
4211 \begin_layout Itemize
4212 lastaddr (number): Last address in the VMA.
4213 \end_layout
4215 \begin_layout Itemize
4216 size (number): The size of VMA in bytes.
4217 \end_layout
4219 \begin_layout Itemize
4220 readonly (boolean): True of the VMA corresponds to ROM.
4221 \end_layout
4223 \begin_layout Itemize
4224 iospace (boolean): True if the VMA is I/O space.
4225 \end_layout
4227 \begin_layout Itemize
4228 native_endian (boolean): True if the VMA has native endian as opposed to
4229  little endian.
4230 \end_layout
4232 \begin_layout Subsection
4233 memory.find_vma: Find VMA info by address
4234 \end_layout
4236 \begin_layout Itemize
4237 Syntax: table memory.find_vma(number address)
4238 \end_layout
4240 \begin_layout Standard
4241 Finds the VMA containing specified address.
4242  Returns table in the same format as read_vma or nil if not found.
4243 \end_layout
4245 \begin_layout Subsection
4246 memory.read{,s}{byte,{,h,d,q}word}: Read memory
4247 \end_layout
4249 \begin_layout Itemize
4250 Syntax: none memory.readbyte([string vma, ]number address)
4251 \end_layout
4253 \begin_layout Itemize
4254 Syntax: none memory.readword([string vma, ]number address)
4255 \end_layout
4257 \begin_layout Itemize
4258 Syntax: none memory.readhword([string vma, ]number address)
4259 \end_layout
4261 \begin_layout Itemize
4262 Syntax: none memory.readdword([string vma, ]number address)
4263 \end_layout
4265 \begin_layout Itemize
4266 Syntax: none memory.readqword([string vma, ]number address)
4267 \end_layout
4269 \begin_layout Itemize
4270 Syntax: none memory.readsbyte([string vma, ]number address)
4271 \end_layout
4273 \begin_layout Itemize
4274 Syntax: none memory.readsword([string vma, ]number address)
4275 \end_layout
4277 \begin_layout Itemize
4278 Syntax: none memory.readshword([string vma, ]number address)
4279 \end_layout
4281 \begin_layout Itemize
4282 Syntax: none memory.readsdword([string vma, ]number address)
4283 \end_layout
4285 \begin_layout Itemize
4286 Syntax: none memory.readsqword([string vma, ]number address)
4287 \end_layout
4289 \begin_layout Standard
4290 Reads the specified address <address> (if 's' variant is used, do undergo
4291  2's complement).
4292 \end_layout
4294 \begin_layout Subsection
4295 memory.{,s}read_sg: Scatter/Gather read memory
4296 \end_layout
4298 \begin_layout Itemize
4299 Syntax: none memory.read_sg(string/boolean/number...)
4300 \end_layout
4302 \begin_layout Itemize
4303 Syntax: none memory.sread_sg(string/boolean/number...)
4304 \end_layout
4306 \begin_layout Standard
4307 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
4308  of memory.
4309  Each argument can be string, boolean or number:
4310 \end_layout
4312 \begin_layout Itemize
4313 String: Set VMA addresses are relative to (e.g.
4314  'WRAM').
4315 \end_layout
4317 \begin_layout Itemize
4318 boolean: If true, increment relative address by 1, if false, decrement by
4319  1.
4320  The new address is read as next higher byte.
4321 \end_layout
4323 \begin_layout Itemize
4324 integer: Set the relative address to specified value and read the address
4325  as next higher byte.
4326 \end_layout
4328 \begin_layout Subsection
4329 memory.write_sg: Scatter/Gather write memory
4330 \end_layout
4332 \begin_layout Itemize
4333 Syntax: none memory.write_sg(number value, string/boolean/number...)
4334 \end_layout
4336 \begin_layout Standard
4337 Perform scatter/gather write of value <value> on memory.
4338  Each argument can be string, boolean or number:
4339 \end_layout
4341 \begin_layout Itemize
4342 String: Set VMA addresses are relative to (e.g.
4343  'WRAM').
4344 \end_layout
4346 \begin_layout Itemize
4347 boolean: If true, increment relative address by 1, if false, decrement by
4348  1.
4349  The new address is read as next higher byte.
4350 \end_layout
4352 \begin_layout Itemize
4353 integer: Set the relative address to specified value and read the address
4354  as next higher byte.
4355 \end_layout
4357 \begin_layout Subsection
4358 memory.read{float,double}: Read memory
4359 \end_layout
4361 \begin_layout Itemize
4362 Syntax: none memory.readfloat([string vma, ]number address)
4363 \end_layout
4365 \begin_layout Itemize
4366 Syntax: none memory.readdouble([string vma, ]number address)
4367 \end_layout
4369 \begin_layout Standard
4370 Reads the specified address <address>
4371 \end_layout
4373 \begin_layout Subsection
4374 memory.write{byte,{,h,d,q}word,float,double}: Write memory
4375 \end_layout
4377 \begin_layout Itemize
4378 Syntax: none memory.writebyte([string vma, ]number address, number value)
4379 \end_layout
4381 \begin_layout Itemize
4382 Syntax: none memory.writeword([string vma, ]number address, number value)
4383 \end_layout
4385 \begin_layout Itemize
4386 Syntax: none memory.writehword([string vma, ]number address, number value)
4387 \end_layout
4389 \begin_layout Itemize
4390 Syntax: none memory.writedword([string vma, ]number address, number value)
4391 \end_layout
4393 \begin_layout Itemize
4394 Syntax: none memory.writeqword([string vma, ]number address, number value)
4395 \end_layout
4397 \begin_layout Itemize
4398 Syntax: none memory.writefloat([string vma, ]number address, number value)
4399 \end_layout
4401 \begin_layout Itemize
4402 Syntax: none memory.writedouble([string vma, ]number address, number value)
4403 \end_layout
4405 \begin_layout Standard
4406 Writes the specified value <value> (negative integer values undergo 2's
4407  complement) to specified address <address>.
4408 \end_layout
4410 \begin_layout Subsection
4411 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
4412 \end_layout
4414 \begin_layout Itemize
4415 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
4416 \end_layout
4418 \begin_layout Standard
4419 Returns a table mapping specified memory aperture for read/write.
4420  If parameters are omitted, entiere map space is the aperture.
4421 \end_layout
4423 \begin_layout Itemize
4424 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
4425  qword, sqword, float or double.
4426 \end_layout
4428 \begin_layout Subsection
4429 memory.hash_region: Hash region of memory
4430 \end_layout
4432 \begin_layout Itemize
4433 Syntax: string memory.hash_region([string vma, ]number base, number size)
4434 \end_layout
4436 \begin_layout Standard
4437 Hash specified number of bytes starting from specified address and return
4438  the SHA-256.
4439 \end_layout
4441 \begin_layout Subsection
4442 memory.hash_state: Hash system state
4443 \end_layout
4445 \begin_layout Itemize
4446 Syntax: string memory.hash_state()
4447 \end_layout
4449 \begin_layout Standard
4450 Hash the current system state.
4451  Mainly useful for debugging savestates.
4452 \end_layout
4454 \begin_layout Subsection
4455 memory.readregion: Read region of memory
4456 \end_layout
4458 \begin_layout Itemize
4459 Syntax: table memory.readregion([string vma, ]number base, number size)
4460 \end_layout
4462 \begin_layout Standard
4463 Read a region of memory.
4464 \end_layout
4466 \begin_layout Itemize
4467 Warning: If the region crosses VMA boundary, the results are undefined.
4468 \end_layout
4470 \begin_layout Subsection
4471 memory.writeregion: Write region of memory
4472 \end_layout
4474 \begin_layout Itemize
4475 Syntax: none memory.writeregion([string vma, ]number base, number size, table
4476  data)
4477 \end_layout
4479 \begin_layout Standard
4480 Write a region of memory.
4481 \end_layout
4483 \begin_layout Itemize
4484 Warning: If the region crosses VMA boundary, the results are undefined.
4485 \end_layout
4487 \begin_layout Subsection
4488 memory.read_expr: Evaluate memory watch expression
4489 \end_layout
4491 \begin_layout Itemize
4492 Syntax: string memory.read_expr(string expr)
4493 \end_layout
4495 \begin_layout Standard
4496 Evaluate specified watch expression and return result
4497 \end_layout
4499 \begin_layout Subsection
4500 memory.action: Run core action
4501 \end_layout
4503 \begin_layout Itemize
4504 memory.action(string action, [<params>])
4505 \end_layout
4507 \begin_layout Standard
4508 Run core action.
4509  The different models expect parameters as:
4510 \end_layout
4512 \begin_layout Itemize
4513 string: String
4514 \end_layout
4516 \begin_layout Itemize
4517 numeric: numeric
4518 \end_layout
4520 \begin_layout Itemize
4521 enumeration: String
4522 \end_layout
4524 \begin_layout Itemize
4525 boolean: String
4526 \end_layout
4528 \begin_layout Itemize
4529 toggle: None.
4530 \end_layout
4532 \begin_layout Subsection
4533 memory.get_lag_flag: Get lag flag
4534 \end_layout
4536 \begin_layout Itemize
4537 Syntax: boolean memory.get_lag_flag()
4538 \end_layout
4540 \begin_layout Standard
4541 Get the value of core lag flag.
4542  True if this frame has been lag so far, false if poll has been detected.
4543 \end_layout
4545 \begin_layout Subsection
4546 memory.set_lag_flag: Set lag flag
4547 \end_layout
4549 \begin_layout Itemize
4550 Syntax: none memory.set_lag_flag(boolean flag)
4551 \end_layout
4553 \begin_layout Standard
4554 Set the value of core lag flag.
4555  This flag automatically gets cleared if poll is detected, but can be forcibly
4556  set or cleared if game so requires.
4557 \end_layout
4559 \begin_layout Itemize
4560 Should only be used in on_frame_emulated callback.
4561 \end_layout
4563 \begin_layout Itemize
4564 Setting or clearing this affects the emulator lag counter.
4565 \end_layout
4567 \begin_layout Subsection
4568 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
4569  callback
4570 \end_layout
4572 \begin_layout Itemize
4573 Syntax: function memory.registerread([string vma, ] number addr, function
4574  fn);
4575 \end_layout
4577 \begin_layout Itemize
4578 Syntax: function memory.registerwrite([string vma, ] number addr, function
4579  fn);
4580 \end_layout
4582 \begin_layout Itemize
4583 Syntax: function memory.registerexec([string vma, ] number addr, function
4584  fn);
4585 \end_layout
4587 \begin_layout Itemize
4588 Syntax: none memory.unregisterread([string vma, ] number addr, function fn);
4589 \end_layout
4591 \begin_layout Itemize
4592 Syntax: none memory.unregisterwrite([string vma, ] number addr, function
4593  fn);
4594 \end_layout
4596 \begin_layout Itemize
4597 Syntax: none memory.unregisterexec([string vma, ] number addr, function fn);
4598 \end_layout
4600 \begin_layout Standard
4601 Add or remove callback on memory read, write or execute (depending on the
4602  function).
4603  If <vma> is specified, <addr> is relative to it, otherwise <addr> is global.
4604  <fn> is the callback.
4605  The register* functions return <fn> (which can then be passed to unregister*
4606  functions.
4607 \end_layout
4609 \begin_layout Itemize
4610 Not all cores support this, and it may be unsupported for some VMAs.
4611 \end_layout
4613 \begin_layout Itemize
4614 The functions are passed two parameters: Address and value.
4615 \end_layout
4617 \begin_layout Subsection
4618 memory.{,un}registertrace: Set/Clear trace hook
4619 \end_layout
4621 \begin_layout Itemize
4622 Syntax: function memory.registertrace(number processor, function fn);
4623 \end_layout
4625 \begin_layout Itemize
4626 Syntax: none memory.unregistertrace(number processor, function fn);
4627 \end_layout
4629 \begin_layout Standard
4630 Add or remove trace callback.
4631  <processor> is system-dependent processor number (0 is usually main CPU).
4632  The function arguments work like in other (un)register* functions.
4633 \end_layout
4635 \begin_layout Itemize
4636 The functions are passed two parameters: Trace CPU and Trace event string.
4637 \end_layout
4639 \begin_layout Subsection
4640 memory.cheat: Set cheat
4641 \end_layout
4643 \begin_layout Itemize
4644 Syntax: none memory.cheat([string vma, ] number addr, number value);
4645 \end_layout
4647 \begin_layout Itemize
4648 Syntax: none memory.cheat([string vma, ] number addr);
4649 \end_layout
4651 \begin_layout Standard
4652 Set or clear cheat (value <value>) on address <addr>.
4653  If <vma> is specified, <addr> is relative to that.
4654  If <value> is not speicified, clear a cheat.
4655 \end_layout
4657 \begin_layout Itemize
4658 Not all cores support this, and it may be unsupported for some VMAs.
4659 \end_layout
4661 \begin_layout Subsection
4662 memory.setxmask: Set global execute hook mask
4663 \end_layout
4665 \begin_layout Itemize
4666 Syntax: none memory.setxmask(number mask)
4667 \end_layout
4669 \begin_layout Standard
4670 Set the global execute hook mask to <mask>.
4671  The meaning of each bit is system-dependent, but bit 0 should be the main
4672  CPU.
4673 \end_layout
4675 \begin_layout Standard
4676 \begin_inset Newpage pagebreak
4677 \end_inset
4680 \end_layout
4682 \begin_layout Section
4683 Table memory2
4684 \end_layout
4686 \begin_layout Standard
4687 Contains newer memory functions.
4688 \end_layout
4690 \begin_layout Subsection
4691 memory2(): Get all VMA names.
4692 \end_layout
4694 \begin_layout Itemize
4695 Syntax: table memory2()
4696 \end_layout
4698 \begin_layout Standard
4699 Returns array of all valid VMA names.
4700 \end_layout
4702 \begin_layout Subsection
4703 memory2.<vma>:info: Get VMA info
4704 \end_layout
4706 \begin_layout Itemize
4707 Syntax: table memory2.<vma>:info()
4708 \end_layout
4710 \begin_layout Standard
4711 Return table describing given VMA.
4712  Includes fields address, size, last, readonly, special and endian.
4713 \end_layout
4715 \begin_layout Subsection
4716 memory2.<vma>:<op>: Read/Write memory
4717 \end_layout
4719 \begin_layout Itemize
4720 Syntax: none memory2.<vma>:<op>(number offset, number value)
4721 \end_layout
4723 \begin_layout Itemize
4724 Syntax: number memory2.<vma>:<op>(number offset)
4725 \end_layout
4727 \begin_layout Standard
4728 Read/Write value from/to given VMA <vma> at given offset <offset> (must
4729  be in-range).
4730  The value written is <value>.
4731  <Op> is of form: [i][s]<type>, where:
4732 \end_layout
4734 \begin_layout Itemize
4735 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4736 \end_layout
4738 \begin_layout Itemize
4739 'i' signifies that the value is treated as opposite-to-normal endianess,
4740 \end_layout
4742 \begin_layout Itemize
4743 's' signifies that value is treated as signed (not available for floating-point).
4744 \end_layout
4746 \begin_layout Subsection
4747 memory2.<vma>:read: Scatter-gather value read
4748 \end_layout
4750 \begin_layout Itemize
4751 Syntax: number memory2.<vma>:read(number addr...)
4752 \end_layout
4754 \begin_layout Standard
4755 Read value from given VMA <vma> at byte offsets <addr>..., given in order of
4756  increasing significance.
4757  Value of true and false are special.
4758  True increments address by 1, and false decrements address by 1.
4759 \end_layout
4761 \begin_layout Subsection
4762 memory2.<vma>:sread: Signed scatter-gather value read
4763 \end_layout
4765 \begin_layout Itemize
4766 Syntax: number memory2.<vma>:sread(number addr...)
4767 \end_layout
4769 \begin_layout Standard
4770 Like memory2.<vma>:read, but reads signed values.
4771 \end_layout
4773 \begin_layout Subsection
4774 memory2.<vma>:write: Scatter-gather value write
4775 \end_layout
4777 \begin_layout Itemize
4778 Syntax: number memory2.<vma>:write(number val, number addr...)
4779 \end_layout
4781 \begin_layout Standard
4782 Write value <val> to given VMA <vma> at byte offsets <addr>..., given in order
4783  of increasing significance.
4784  Value of true and false are special.
4785  True increments address by 1, and false decrements address by 1.
4786 \end_layout
4788 \begin_layout Standard
4789 \begin_inset Newpage pagebreak
4790 \end_inset
4793 \end_layout
4795 \begin_layout Section
4796 Table random
4797 \end_layout
4799 \begin_layout Standard
4800 Contains random number generation methods.
4801  These functions do not return reproducable results.
4802 \end_layout
4804 \begin_layout Subsection
4805 random.boolean: Random boolean
4806 \end_layout
4808 \begin_layout Itemize
4809 Syntax: boolean random.boolean()
4810 \end_layout
4812 \begin_layout Standard
4813 Returns true or false at random (50-50 chance).
4814 \end_layout
4816 \begin_layout Subsection
4817 random.integer: Random integer
4818 \end_layout
4820 \begin_layout Itemize
4821 Syntax: number random.integer(number highplusone)
4822 \end_layout
4824 \begin_layout Itemize
4825 Syntax: number random.integer(number low, number high)
4826 \end_layout
4828 \begin_layout Standard
4829 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
4830  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
4831 \end_layout
4833 \begin_layout Standard
4834 The returned numbers are from uniform distribution.
4835 \end_layout
4837 \begin_layout Subsection
4838 random.float: Random float
4839 \end_layout
4841 \begin_layout Itemize
4842 Syntax: number random.float()
4843 \end_layout
4845 \begin_layout Standard
4846 Returns random decimal number [0,1).
4847 \end_layout
4849 \begin_layout Subsection
4850 random.among: Random parameter
4851 \end_layout
4853 \begin_layout Itemize
4854 Syntax: value random.among(value values...)
4855 \end_layout
4857 \begin_layout Standard
4858 Returns random parameter value, picked at uniform.
4859  Multiple equivalent values are returned with higher chance.
4860 \end_layout
4862 \begin_layout Subsection
4863 random.amongtable: Random from table
4864 \end_layout
4866 \begin_layout Itemize
4867 Syntax: value random.amongtable(table tab)
4868 \end_layout
4870 \begin_layout Standard
4871 Returns random value from table <tab>.
4872  As in random.among, no equality testing is done.
4873 \end_layout
4875 \begin_layout Standard
4876 \begin_inset Newpage pagebreak
4877 \end_inset
4880 \end_layout
4882 \begin_layout Section
4883 Table zip
4884 \end_layout
4886 \begin_layout Subsection
4887 zip.enumerate: Enumerate members in zipfile
4888 \end_layout
4890 \begin_layout Itemize
4891 Syntax: Table zip.enumerate(string filename[, boolean invert])
4892 \end_layout
4894 \begin_layout Standard
4895 Returns table of files in zip archive <filename>.
4896  If <invert> is true, instead of returning array of names, returns table
4897  with keys being member names and values being true.
4898 \end_layout
4900 \begin_layout Standard
4901 \begin_inset Newpage pagebreak
4902 \end_inset
4905 \end_layout
4907 \begin_layout Section
4908 Table callback
4909 \end_layout
4911 \begin_layout Standard
4912 Various callback-related functions.
4913 \end_layout
4915 \begin_layout Subsection
4916 \begin_inset CommandInset label
4917 LatexCommand label
4918 name "sub:callback.register:-Register-a"
4920 \end_inset
4922 callback.register: Register a callback
4923 \end_layout
4925 \begin_layout Itemize
4926 Syntax: function callback.register(string cbname, function cbfun);
4927 \end_layout
4929 \begin_layout Standard
4930 Instruct function <cbfun> to be added to list of callbacks to call on event
4931  <cbname> (See section 
4932 \begin_inset CommandInset ref
4933 LatexCommand ref
4934 reference "sec:Callbacks"
4936 \end_inset
4939  The callback name does not have the 'on_' prefix (e.g.
4941 \begin_inset Quotes eld
4942 \end_inset
4944 paint
4945 \begin_inset Quotes erd
4946 \end_inset
4949  Returns <cbfun>.
4950 \end_layout
4952 \begin_layout Subsection
4953 \begin_inset CommandInset label
4954 LatexCommand label
4955 name "sub:callback.unregister:-Unregister-"
4957 \end_inset
4959 callback.unregister: Unregister a callback
4960 \end_layout
4962 \begin_layout Itemize
4963 Syntax: function callback.unregister(string cbname, function cbfun);
4964 \end_layout
4966 \begin_layout Standard
4967 Instruct function <cbfun> to be removed from list of callbacks to call on
4968  event <cbname>.
4969 \end_layout
4971 \begin_layout Subsection
4972 callback.<cbname>:register: Register callback
4973 \end_layout
4975 \begin_layout Itemize
4976 Syntax: function callback.<cbname>:register(function cbfun)
4977 \end_layout
4979 \begin_layout Standard
4980 Synonym for callback.register (section 
4981 \begin_inset CommandInset ref
4982 LatexCommand ref
4983 reference "sub:callback.register:-Register-a"
4985 \end_inset
4987 ), albeit with callback name specified differently.
4988 \end_layout
4990 \begin_layout Subsection
4991 callback.<cbname>:unregister: Register callback
4992 \end_layout
4994 \begin_layout Itemize
4995 Syntax: function callback.<cbname>:unregister(function cbfun)
4996 \end_layout
4998 \begin_layout Standard
4999 Synonym for callback.unregister (section 
5000 \begin_inset CommandInset ref
5001 LatexCommand ref
5002 reference "sub:callback.unregister:-Unregister-"
5004 \end_inset
5006 ), albeit with callback name specified differently.
5007 \end_layout
5009 \begin_layout Section
5010 table bsnes
5011 \end_layout
5013 \begin_layout Standard
5014 Various bsnes-specific functions.
5015 \end_layout
5017 \begin_layout Subsection
5018 bsnes.dump_sprite: Dump a sprite
5019 \end_layout
5021 \begin_layout Itemize
5022 Syntax: BITMAP bsnes.dump_sprite([string vma, ] number addr, number width,
5023  number height[, number stride])
5024 \end_layout
5026 \begin_layout Standard
5027 Dumps given sprite (in native format) from memory.
5028  VMA is usually 
5029 \begin_inset Quotes eld
5030 \end_inset
5032 VRAM
5033 \begin_inset Quotes erd
5034 \end_inset
5037  <Width> and <height> are given in 8x8 blocks.
5038  <Stride> overrides row stride (default 512).
5039 \end_layout
5041 \begin_layout Subsection
5042 bsnes.dump_palette: Dump a palette
5043 \end_layout
5045 \begin_layout Itemize
5046 Syntax: PALETTE bsnes.dump_palette([string vma, ] number addr, bool full256,
5047  bool first_trans)
5048 \end_layout
5050 \begin_layout Standard
5051 Dumps a palette from memory.
5052  VMA is usually 
5053 \begin_inset Quotes eld
5054 \end_inset
5056 CGRAM
5057 \begin_inset Quotes erd
5058 \end_inset
5061  If <full256> is true, 256 colors are dumped (otherwise 16).
5062  If <first_trans> is true, first color is forced transparent.
5063 \end_layout
5065 \begin_layout Section
5066 extensions to table string
5067 \end_layout
5069 \begin_layout Subsection
5070 string.charU: string.char, UTF-8 version.
5071 \end_layout
5073 \begin_layout Itemize
5074 Syntax: string string.charU(number n...)
5075 \end_layout
5077 \begin_layout Standard
5078 Like Lua string.char(), but works in terms of Unicode codepoints.
5079  The returned string is UTF-8.
5080 \end_layout
5082 \begin_layout Subsection
5083 string.byteU: string.byte, UTF-8 version.
5084 \end_layout
5086 \begin_layout Itemize
5087 Syntax: number...
5088  string.byteU(string str[, number i[, number j]])
5089 \end_layout
5091 \begin_layout Standard
5092 Like string.byte(), but works in terms of Unicode codepoints.
5093  The input string <str> is assumed UTF-8.
5094 \end_layout
5096 \begin_layout Section
5097 Table _SYSTEM
5098 \end_layout
5100 \begin_layout Standard
5101 Contains copy of global variables from time of Lua initialization.
5102  Non-writeable.
5103 \end_layout
5105 \begin_layout Standard
5106 \begin_inset Newpage pagebreak
5107 \end_inset
5110 \end_layout
5112 \begin_layout Section
5113 \begin_inset CommandInset label
5114 LatexCommand label
5115 name "sec:Callbacks"
5117 \end_inset
5119 Callbacks
5120 \end_layout
5122 \begin_layout Standard
5123 Various callbacks to Lua that can occur.
5124 \end_layout
5126 \begin_layout Subsection
5127 on_paint: Screen is being painted
5128 \end_layout
5130 \begin_layout Itemize
5131 Callback: on_paint(bool not_synth)
5132 \end_layout
5134 \begin_layout Standard
5135 Called when screen is being painted.
5136  Any gui.* calls requiring graphic context draw on the screen.
5137 \end_layout
5139 \begin_layout Itemize
5140 not_synth is true if this hook is being called in response to received frame,
5141  false otherwise.
5142 \end_layout
5144 \begin_layout Subsection
5145 on_video: Dumped video frame is being painted
5146 \end_layout
5148 \begin_layout Itemize
5149 Callback: on_video()
5150 \end_layout
5152 \begin_layout Standard
5153 Called when video dump frame is being painted.
5154  Any gui.* calls requiring graphic context draw on the video.
5155 \end_layout
5157 \begin_layout Subsection
5158 on_frame_emulated: Frame emulation complete
5159 \end_layout
5161 \begin_layout Itemize
5162 Callback: on_frame_emulated()
5163 \end_layout
5165 \begin_layout Standard
5166 Called when emulating frame has completed and on_paint()/on_video() calls
5167  are about to be issued.
5168 \end_layout
5170 \begin_layout Subsection
5171 on_frame: Frame emulation starting.
5172 \end_layout
5174 \begin_layout Itemize
5175 Callback: on_frame()
5176 \end_layout
5178 \begin_layout Standard
5179 Called on each starting whole frame.
5180 \end_layout
5182 \begin_layout Subsection
5183 on_startup: Emulator startup complete
5184 \end_layout
5186 \begin_layout Itemize
5187 Callback: on_startup()
5188 \end_layout
5190 \begin_layout Standard
5191 Called when the emulator is starting (lsnes.rc and --run files has been run).
5192 \end_layout
5194 \begin_layout Subsection
5195 on_rewind: Movie rewound to beginning
5196 \end_layout
5198 \begin_layout Itemize
5199 Callback: on_rewind()
5200 \end_layout
5202 \begin_layout Standard
5203 Called when rewind movie to beginning has completed.
5204 \end_layout
5206 \begin_layout Subsection
5207 on_pre_load: Load operation is about to start
5208 \end_layout
5210 \begin_layout Itemize
5211 Callback: on_pre_load(string name)
5212 \end_layout
5214 \begin_layout Standard
5215 Called just before savestate/movie load occurs (note: loads are always delayed,
5216  so this occurs even when load was initiated by lua).
5217 \end_layout
5219 \begin_layout Subsection
5220 on_err_Load: Load failed
5221 \end_layout
5223 \begin_layout Itemize
5224 Callback: on_err_load(string name)
5225 \end_layout
5227 \begin_layout Standard
5228 Called if loadstate goes wrong.
5229 \end_layout
5231 \begin_layout Subsection
5232 on_post_load: Load completed
5233 \end_layout
5235 \begin_layout Itemize
5236 Callback: on_post_load(string name, boolean was_savestate)
5237 \end_layout
5239 \begin_layout Standard
5240 Called on successful loadstate.
5241  was_savestate gives if this was a savestate or a movie.
5242 \end_layout
5244 \begin_layout Subsection
5245 on_pre_save: Save operation is about to start
5246 \end_layout
5248 \begin_layout Itemize
5249 Callback: on_pre_save(string name, boolean is_savestate)
5250 \end_layout
5252 \begin_layout Standard
5253 Called just before savestate save occurs (note: movie saves are synchronous
5254  and won't trigger these callbacks if called from Lua).
5255 \end_layout
5257 \begin_layout Subsection
5258 on_err_save: Save failed
5259 \end_layout
5261 \begin_layout Itemize
5262 Callback: on_err_save(string name)
5263 \end_layout
5265 \begin_layout Standard
5266 Called if savestate goes wrong.
5267 \end_layout
5269 \begin_layout Subsection
5270 on_post_save: Save completed
5271 \end_layout
5273 \begin_layout Itemize
5274 Callback: on_post_save(string name, boolean is_savestate)
5275 \end_layout
5277 \begin_layout Standard
5278 Called on successful savaestate.
5279  is_savestate gives if this was a savestate or a movie.
5280 \end_layout
5282 \begin_layout Subsection
5283 on_quit: Emulator is shutting down
5284 \end_layout
5286 \begin_layout Itemize
5287 Callback: on_quit()
5288 \end_layout
5290 \begin_layout Standard
5291 Called when emulator is shutting down.
5292 \end_layout
5294 \begin_layout Subsection
5295 on_input: Polling for input
5296 \end_layout
5298 \begin_layout Standard
5299 Called when emulator is just sending input to bsnes core.
5300  Warning: This is called even in readonly mode, but the results are ignored.
5301 \end_layout
5303 \begin_layout Subsection
5304 on_reset: System has been reset
5305 \end_layout
5307 \begin_layout Itemize
5308 Callback: on_reset()
5309 \end_layout
5311 \begin_layout Standard
5312 Called when system is reset.
5313 \end_layout
5315 \begin_layout Subsection
5316 on_readwrite: Entered readwrite mode
5317 \end_layout
5319 \begin_layout Itemize
5320 Callback: on_readwrite()
5321 \end_layout
5323 \begin_layout Standard
5324 Called when moving into readwrite mode as result of 
5325 \begin_inset Quotes eld
5326 \end_inset
5328 set-rwmode
5329 \begin_inset Quotes erd
5330 \end_inset
5332  command (note: moving to rwmode by Lua won't trigger this, as per recursive
5333  entry protection).
5334 \end_layout
5336 \begin_layout Subsection
5337 on_snoop/on_snoop2: Snoop core controller reads
5338 \end_layout
5340 \begin_layout Itemize
5341 Callback: on_snoop(number port, number controller, number index, number
5342  value)
5343 \end_layout
5345 \begin_layout Itemize
5346 Callback: on_snoop2(number port, number controller, number index, number
5347  value)
5348 \end_layout
5350 \begin_layout Standard
5351 Called each time bsnes asks for input.
5352  The value is the final value to be sent to bsnes core (readonly mode, autohold
5353  and autofire have been taken into account).
5354  Might be useful when translating movies to format suitable for console
5355  verification.
5356  Note: There is no way to modify the value to be sent.
5357 \end_layout
5359 \begin_layout Itemize
5360 On_snoop2 is called instead of on_snoop if defined.
5361  Reserves port 0 for system, having first user port be port 1.
5362 \end_layout
5364 \begin_layout Subsection
5365 on_keyhook: Hooked key/axis has been moved
5366 \end_layout
5368 \begin_layout Itemize
5369 Callback: on_keyhook(string keyname, table state)
5370 \end_layout
5372 \begin_layout Standard
5373 Sent when key that has keyhook events requested changes state.
5374  Keyname is name of the key (group) and state is the state (same kind as
5375  table values in input.raw).
5376 \end_layout
5378 \begin_layout Subsection
5379 on_idle: Idle event
5380 \end_layout
5382 \begin_layout Itemize
5383 Callback: on_idle()
5384 \end_layout
5386 \begin_layout Standard
5387 Called when requested by set_idle_timeout(), the timeout has expired and
5388  emulator is waiting.
5389 \end_layout
5391 \begin_layout Subsection
5392 on_timer: Timer event
5393 \end_layout
5395 \begin_layout Itemize
5396 Callback: on_timer()
5397 \end_layout
5399 \begin_layout Standard
5400 Called when requested by set_idle_timeout() and the timeout has expired
5401  (regardless if emulator is waiting).
5402 \end_layout
5404 \begin_layout Subsection
5405 on_set_rewind: Rewind point has been set
5406 \end_layout
5408 \begin_layout Itemize
5409 Callback: on_set_rewind(UNSAFEREWIND r)
5410 \end_layout
5412 \begin_layout Standard
5413 Called when unsafe rewind object has been constructed.
5414 \end_layout
5416 \begin_layout Subsection
5417 on_pre_rewind: Rewind is about to occur
5418 \end_layout
5420 \begin_layout Itemize
5421 Callback: on_pre_rewind() 
5422 \end_layout
5424 \begin_layout Standard
5425 Called just before unsafe rewind is about to occur.
5426 \end_layout
5428 \begin_layout Subsection
5429 on_post_rewind: Rewind has occured
5430 \end_layout
5432 \begin_layout Itemize
5433 Callback: on_post_rewind() 
5434 \end_layout
5436 \begin_layout Standard
5437 Called just after unsafe rewind has occured.
5438 \end_layout
5440 \begin_layout Subsection
5441 on_button: Button has been pressed
5442 \end_layout
5444 \begin_layout Itemize
5445 Callback: on_button(number port, number controller, number index, string
5446  type)
5447 \end_layout
5449 \begin_layout Standard
5450 Called on controller button press, with following parameters:
5451 \end_layout
5453 \begin_layout Itemize
5454 port: Port number (0 is system)
5455 \end_layout
5457 \begin_layout Itemize
5458 controller: Controller within port
5459 \end_layout
5461 \begin_layout Itemize
5462 index: Index of button.
5463 \end_layout
5465 \begin_layout Itemize
5466 type: Type of event, one of:
5467 \end_layout
5469 \begin_deeper
5470 \begin_layout Itemize
5471 \begin_inset Quotes eld
5472 \end_inset
5474 pressed
5475 \begin_inset Quotes erd
5476 \end_inset
5478 : Button was pressed.
5479 \end_layout
5481 \begin_layout Itemize
5482 \begin_inset Quotes eld
5483 \end_inset
5485 released
5486 \begin_inset Quotes erd
5487 \end_inset
5489 : Button was released.
5490 \end_layout
5492 \begin_layout Itemize
5493 \begin_inset Quotes eld
5494 \end_inset
5496 hold
5497 \begin_inset Quotes erd
5498 \end_inset
5500 : Held.
5501 \end_layout
5503 \begin_layout Itemize
5504 \begin_inset Quotes eld
5505 \end_inset
5507 unhold
5508 \begin_inset Quotes erd
5509 \end_inset
5511 : Released from hold.
5512 \end_layout
5514 \begin_layout Itemize
5515 \begin_inset Quotes eld
5516 \end_inset
5518 type
5519 \begin_inset Quotes erd
5520 \end_inset
5522 : Typing input on button.
5523 \end_layout
5525 \begin_layout Itemize
5526 \begin_inset Quotes eld
5527 \end_inset
5529 untype
5530 \begin_inset Quotes erd
5531 \end_inset
5533 : Typing input undone.
5534 \end_layout
5536 \begin_layout Itemize
5537 \begin_inset Quotes eld
5538 \end_inset
5540 autofire <duty> <cycle>
5541 \begin_inset Quotes erd
5542 \end_inset
5544 : Autofire with specifie duty and cycle.
5545 \end_layout
5547 \begin_layout Itemize
5548 \begin_inset Quotes eld
5549 \end_inset
5551 autofire
5552 \begin_inset Quotes erd
5553 \end_inset
5555 : Stop autofire.
5556 \end_layout
5558 \begin_layout Itemize
5559 \begin_inset Quotes eld
5560 \end_inset
5562 analog
5563 \begin_inset Quotes erd
5564 \end_inset
5566 : Analog action on axis.
5567 \end_layout
5569 \end_deeper
5570 \begin_layout Subsection
5571 on_movie_lost: Movie data is about to be lost
5572 \end_layout
5574 \begin_layout Itemize
5575 Callback: on_movie_lost(STRING kind)
5576 \end_layout
5578 \begin_layout Standard
5579 Called just before something would happen that could lose movie data.
5580  Kind can be:
5581 \end_layout
5583 \begin_layout Itemize
5584 readwrite: Switching to readwrite mode.
5585 \end_layout
5587 \begin_layout Itemize
5588 reload: ROM is being reloaded in readwrite mode.
5589 \end_layout
5591 \begin_layout Itemize
5592 load: New movie is being loaded.
5593 \end_layout
5595 \begin_layout Itemize
5596 unsaferewind: Unsafe rewind is happening.
5597 \end_layout
5599 \begin_layout Subsection
5600 on_latch: Latch line is rising
5601 \end_layout
5603 \begin_layout Itemize
5604 Callback: on_latch(<core-dependent-parameters>)
5605 \end_layout
5607 \begin_layout Standard
5608 Called when latch line for controller is rising.
5609  Some cores may not support this.
5610 \end_layout
5612 \begin_layout Section
5613 System-dependent behaviour
5614 \end_layout
5616 \begin_layout Subsection
5617 bsnes core
5618 \end_layout
5620 \begin_layout Itemize
5621 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
5622  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
5623  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
5624 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
5625 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
5626  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
5627  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
5628  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
5629  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
5630 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
5631 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
5632  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
5633 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
5634 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
5635  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
5636 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
5637  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
5638 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
5639 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
5640 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
5641  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
5642 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
5643  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
5644  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
5645 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
5646 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
5647 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
5648  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
5649 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
5650  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
5651  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
5652  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
5653  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
5654 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
5655  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
5656 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
5657  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
5658  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
5659 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
5660  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
5661 \end_layout
5663 \begin_layout Itemize
5664 on_latch has no parameters
5665 \end_layout
5667 \begin_layout Itemize
5668 CPU 0 is S-CPU, 1 is S-SMP.
5669 \end_layout
5671 \begin_layout Itemize
5672 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
5673 \end_layout
5675 \begin_layout Itemize
5676 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
5677 {RAM,ROM}.
5678 \end_layout
5680 \begin_layout Subsection
5681 gambatte core
5682 \end_layout
5684 \begin_layout Itemize
5685 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
5686  d, e, f, h, l
5687 \end_layout
5689 \begin_layout Itemize
5690 on_latch is not supported
5691 \end_layout
5693 \begin_layout Itemize
5694 CPU 0 is main CPU.
5695 \end_layout
5697 \begin_layout Itemize
5698 Cheats are supported for ROM, SRAM and WRAM.
5699 \end_layout
5701 \begin_layout Itemize
5702 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
5703  and WRAM.
5704 \end_layout
5706 \end_body
5707 \end_document