Lua: Cleanup hostmemory and use static method for TILEMAP ctor
[lsnes.git] / lua.lyx
blob7f7b4ae2efbac6a894af2aafda498683a734712c
1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
2 \lyxformat 413
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options true
7 \maintain_unincluded_children false
8 \language english
9 \language_package default
10 \inputencoding auto
11 \fontencoding global
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
17 \font_sc false
18 \font_osf false
19 \font_sf_scale 100
20 \font_tt_scale 100
22 \graphics default
23 \default_output_format default
24 \output_sync 0
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
28 \spacing single
29 \use_hyperref true
30 \pdf_bookmarks true
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
34 \pdf_breaklinks false
35 \pdf_pdfborder false
36 \pdf_colorlinks false
37 \pdf_backref false
38 \pdf_pdfusetitle true
39 \papersize a4paper
40 \use_geometry true
41 \use_amsmath 1
42 \use_esint 1
43 \use_mhchem 1
44 \use_mathdots 1
45 \cite_engine basic
46 \use_bibtopic false
47 \use_indices false
48 \paperorientation portrait
49 \suppress_date false
50 \use_refstyle 1
51 \index Hakusana
52 \shortcut idx
53 \color #008000
54 \end_index
55 \leftmargin 2cm
56 \topmargin 2cm
57 \rightmargin 1cm
58 \bottommargin 2cm
59 \headheight 1cm
60 \headsep 1cm
61 \footskip 1cm
62 \secnumdepth 3
63 \tocdepth 3
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
67 \papercolumns 1
68 \papersides 1
69 \paperpagestyle default
70 \tracking_changes false
71 \output_changes false
72 \html_math_output 0
73 \html_css_as_file 0
74 \html_be_strict false
75 \end_header
77 \begin_body
79 \begin_layout Title
80 lsnes Lua functions reference
81 \end_layout
83 \begin_layout Section
84 Table of contents
85 \end_layout
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
91 \end_inset
94 \end_layout
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
98 \end_inset
101 \end_layout
103 \begin_layout Section
104 Special tokens
105 \end_layout
107 \begin_layout Standard
108 These tokens are special, and are expanded while the script is being loaded
109 \end_layout
111 \begin_layout Subsection
112 @@LUA_SCRIPT_FILENAME@@
113 \end_layout
115 \begin_layout Standard
116 Expanded to string token containing path and filename of this Lua script.
117  Handy for referencing other lua scripts or resources that are relative
118  to this Lua script.
119 \end_layout
121 \begin_layout Standard
122 In practicular, this is suitable to be passed as base argument of various
123  functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
124 ad_png and gui.bitmap_load_pal.
125 \end_layout
127 \begin_layout Section
128 Global
129 \end_layout
131 \begin_layout Subsection
132 print: Print values to console
133 \end_layout
135 \begin_layout Itemize
136 Syntax: none print(value...
137  values)
138 \end_layout
140 \begin_layout Standard
141 Prints specified values to console.
142  Can print any Lua type at least enough to identify the type and instance.
143 \end_layout
145 \begin_layout Subsection
146 tostringx: Format a value to string
147 \end_layout
149 \begin_layout Itemize
150 Syntax: string tostringx(value val)
151 \end_layout
153 \begin_layout Standard
154 Formats value <val> like print would, and returns the result as a string.
155 \end_layout
157 \begin_layout Subsection
158 exec: Execute lsnes commands
159 \end_layout
161 \begin_layout Itemize
162 Syntax: none exec(string cmd)
163 \end_layout
165 \begin_layout Standard
166 Execute lsnes command <cmd>.
167 \end_layout
169 \begin_layout Subsection
170 utime: Get current time
171 \end_layout
173 \begin_layout Itemize
174 Syntax: (number,number) utime()
175 \end_layout
177 \begin_layout Standard
178 Returns two numbers.
179  First is time since some epoch in seconds, the second is microseconds mod
180  10^6 since that epoch.
181 \end_layout
183 \begin_layout Subsection
184 emulator_ready: Check if emulator has been fully initialized
185 \end_layout
187 \begin_layout Itemize
188 Syntax: boolean emulator_ready()
189 \end_layout
191 \begin_layout Standard
192 Returns true if emulator has finished booting, false if not (on_startup()
193  will be issued later).
194 \end_layout
196 \begin_layout Subsection
197 set_idle_timeout: Run function after timeout when emulator is idle
198 \end_layout
200 \begin_layout Itemize
201 Syntax: none set_idle_timeout(number timeout)
202 \end_layout
204 \begin_layout Standard
205 Set number of microseconds to block idle for.
206  After this timeout has expired, on_idle() will be called once.
207 \end_layout
209 \begin_layout Subsection
210 set_timer_timeout: Run function after timeout.
211 \end_layout
213 \begin_layout Itemize
214 Syntax: none set_timer_timeout(number timeout)
215 \end_layout
217 \begin_layout Standard
218 Set number of microseconds to block timer for.
219  After this timeout has expired, on_timer() will be called once.
220 \end_layout
222 \begin_layout Subsection
223 bus_address: Look up address in system bus.
224 \end_layout
226 \begin_layout Itemize
227 Syntax: none bus_address(number bus_addr)
228 \end_layout
230 \begin_layout Standard
231 Returns virtual address corresponding to specified address on system bus.
232 \end_layout
234 \begin_layout Subsection
235 loopwrapper: Convert loop into callable function
236 \end_layout
238 \begin_layout Itemize
239 Syntax: function loopwrapper(function fun, ...)
240 \end_layout
242 \begin_layout Standard
243 Calls function <fun> with function and specified arguments.
244  The function passed suspends execution until the function returned is called.
245  Handy for linear flow control among multiple invocations of a hook.
246  Example code:
247 \end_layout
249 \begin_layout LyX-Code
250 on_paint = loopwrapper(function(wait)
251 \end_layout
253 \begin_deeper
254 \begin_layout LyX-Code
255 while true do
256 \end_layout
258 \begin_deeper
259 \begin_layout LyX-Code
260 gui.text(0, 0, 
261 \begin_inset Quotes eld
262 \end_inset
264 Test!
265 \begin_inset Quotes erd
266 \end_inset
269 \end_layout
271 \begin_layout LyX-Code
272 wait();
273 \end_layout
275 \end_deeper
276 \begin_layout LyX-Code
278 \end_layout
280 \end_deeper
281 \begin_layout LyX-Code
282 end);
283 \end_layout
285 \begin_layout Subsection
286 list_bindings: List keybindings
287 \end_layout
289 \begin_layout Itemize
290 Syntax: table list_bindings([string cmd])
291 \end_layout
293 \begin_layout Standard
294 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
295  If <cmd> is specified, the table is limited to that command.
296  Also searches for controller keys.
297 \end_layout
299 \begin_layout Subsection
300 get_alias: Get expansion of alias
301 \end_layout
303 \begin_layout Itemize
304 Syntax: string get_alias(string aname)
305 \end_layout
307 \begin_layout Standard
308 Get expansion of given alias <aname>.
309 \end_layout
311 \begin_layout Subsection
312 set_alias: Set expansion of alias
313 \end_layout
315 \begin_layout Itemize
316 Syntax: none set_alias(string aname, string value)
317 \end_layout
319 \begin_layout Standard
320 Set expansion of given alias.
321 \end_layout
323 \begin_layout Subsection
324 create_ibind: Create invese binding
325 \end_layout
327 \begin_layout Itemize
328 Syntax: INVERSEBIND create_ibind(string name, string cmd)
329 \end_layout
331 \begin_layout Standard
332 Return object representing inverse binding with specified name <name> and
333  specified command <cmd>.
334 \end_layout
336 \begin_layout Itemize
337 Note: To create press/release commands, use aliases +foo and -foo .
338 \end_layout
340 \begin_layout Itemize
341 Note: Keep the returned object around.
342 \end_layout
344 \begin_layout Subsection
345 create_command: Create a command
346 \end_layout
348 \begin_layout Itemize
349 Syntax: COMMANDBIND create_commmand(string name, function a)
350 \end_layout
352 \begin_layout Itemize
353 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
354 \end_layout
356 \begin_layout Standard
357 Return object representing a command (pair).
358 \end_layout
360 \begin_layout Itemize
361 If only one function is specied, the command is level-sensitive, <a> is
362  callback.
363 \end_layout
365 \begin_layout Itemize
366 If <b> is function, the function is edge-sensitive, <a> is positive edge
367  callback and <b> is negative edge callback.
368 \end_layout
370 \begin_layout Itemize
371 All callbacks get single argument: The parameters passed.
372 \end_layout
374 \begin_layout Itemize
375 Keep the returned object around.
376 \end_layout
378 \begin_layout Subsection
379 loadfile: Load Lua script
380 \end_layout
382 \begin_layout Itemize
383 Syntax: function loadfile(string filename[, string base])
384 \end_layout
386 \begin_layout Standard
387 Load lua script from <filename>, resolved relative to <base> (if empty,
388  current directory).
389 \end_layout
391 \begin_layout Subsection
392 dofile: Execute Lua script
393 \end_layout
395 \begin_layout Itemize
396 Syntax: function dofile(string filename[, string base])
397 \end_layout
399 \begin_layout Standard
400 Execute lua script from <filename>, resolved relative to <base> (if empty,
401  current directory) and return all return values.
402 \end_layout
404 \begin_layout Subsection
405 open_file: Open a stream
406 \end_layout
408 \begin_layout Itemize
409 Syntax: FILEREADER open_file(string filename[, string base])
410 \end_layout
412 \begin_layout Standard
413 Open file <filename>, resolved relative to <base> (if empty, current directory)
414  and return a handle.
415 \end_layout
417 \begin_layout Subsection
418 FILEREADER(): Read line/bytes from stream
419 \end_layout
421 \begin_layout Itemize
422 Syntax: string/nil FILEREADER()
423 \end_layout
425 \begin_layout Itemize
426 Syntax: string/nil FILEREADER(number bytes)
427 \end_layout
429 \begin_layout Standard
430 Reads next line or <bytes> bytes from specified file handle.
431  On EOF, nil is returned.
432 \end_layout
434 \begin_layout Itemize
435 Note: The line-oriented variant reads in text mode, so CR at end of line
436  is stripped.
437 \end_layout
439 \begin_layout Subsection
440 FILEREADER:lines: Iterator to read all lines
441 \end_layout
443 \begin_layout Itemize
444 Syntax: for line in <foo>:lines() do ...
445  end
446 \end_layout
448 \begin_layout Standard
449 Iterator for reading all lines of <foo> in a loop.
450 \end_layout
452 \begin_layout Subsection
453 resolve_filename: Resolve name of file relative to another
454 \end_layout
456 \begin_layout Itemize
457 Syntax: string resolve_file(string filename, string base)
458 \end_layout
460 \begin_layout Standard
461 Resolve name of file <filename> relative to <base> and return the result.
462 \end_layout
464 \begin_layout Subsection
465 render_queue_function: Return paint function for render queue
466 \end_layout
468 \begin_layout Itemize
469 Syntax: function render_queue_function(RENDERQUEUE rq)
470 \end_layout
472 \begin_layout Standard
473 Return function that renders render queue <rq>.
474 \end_layout
476 \begin_layout Itemize
477 Handy for paint callback if one is using render queues updated in other
478  callbacks.
479  As in:
480 \end_layout
482 \begin_layout LyX-Code
483 handle = callback.paint:register(render_queue_function(my_rq));
484 \end_layout
486 \begin_layout Subsection
487 iconv_new: Create new character set converter
488 \end_layout
490 \begin_layout Itemize
491 Syntax: ICONV iconv_new(string from, string to)
492 \end_layout
494 \begin_layout Standard
495 Create a character set converter, converting from <from> to <to>.
496 \end_layout
498 \begin_layout Subsection
499 ICONV(): Convert string fragment from character set to another
500 \end_layout
502 \begin_layout Itemize
503 Syntax: boolean, string, (number, string) ICONV(string input)
504 \end_layout
506 \begin_layout Standard
507 Convert string fragment <input> from character set to another.
508 \end_layout
510 \begin_layout Itemize
511 If conversion is successful, returns (true, {converted-string}).
513 \end_layout
515 \begin_layout Itemize
516 If conversion was unsuccessful, returns (false, {converted-part}, {unconverted-b
517 ytes}, {error}).
518  The following errors are defined:
519 \end_layout
521 \begin_deeper
522 \begin_layout Itemize
523 INVALID: Invalid byte sequence in input
524 \end_layout
526 \begin_layout Itemize
527 INCOMPLETE: The input is cut of in middle of multi-byte sequence
528 \end_layout
530 \begin_layout Itemize
531 INTERNALERR: Internal errror
532 \end_layout
534 \end_deeper
535 \begin_layout Subsection
536 identify_class: Identify class of object
537 \end_layout
539 \begin_layout Itemize
540 Syntax: string identify_class(userdata object)
541 \end_layout
543 \begin_layout Standard
544 Identifies the class of userdata <object>, if possible.
545  If no identification is possible, returns 
546 \begin_inset Quotes eld
547 \end_inset
549 unknown
550 \begin_inset Quotes erd
551 \end_inset
554 \end_layout
556 \begin_layout Subsection
557 lookup_class: Lookup class by name
558 \end_layout
560 \begin_layout Itemize
561 Syntax: classobj lookup_class(string name)
562 \end_layout
564 \begin_layout Standard
565 Looks up class corresponding to <name>, if possible.
566  If not found, returns nil.
567  The classobj has following fields:
568 \end_layout
570 \begin_layout Itemize
571 _static_methods: Return static method names
572 \end_layout
574 \begin_layout Itemize
575 _class_methods: Return class method names
576 \end_layout
578 \begin_layout Itemize
579 <static-function-name>: The specified static function.
580 \end_layout
582 \begin_layout Standard
583 \begin_inset Newpage pagebreak
584 \end_inset
587 \end_layout
589 \begin_layout Section
590 Table bit:
591 \end_layout
593 \begin_layout Standard
594 Bitwise logical functions and related.
595 \end_layout
597 \begin_layout Subsection
598 bit.none/bit.bnot: Bitwise none or NOT function
599 \end_layout
601 \begin_layout Itemize
602 Syntax: number bit.none(number...)
603 \end_layout
605 \begin_layout Itemize
606 Syntax: number bit.bnot(number...)
607 \end_layout
609 \begin_layout Standard
610 48-bit bitwise NOT / NONE function (set bits that are set in none of the
611  arguments).
612 \end_layout
614 \begin_layout Subsection
615 bit.any/bit.bor: Bitwise any or OR function
616 \end_layout
618 \begin_layout Itemize
619 Syntax: number bit.any(number...)
620 \end_layout
622 \begin_layout Itemize
623 Syntax: number bit.bor(number...)
624 \end_layout
626 \begin_layout Standard
627 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
628 \end_layout
630 \begin_layout Subsection
631 bit.all/bit.band: Bitwise all or AND function
632 \end_layout
634 \begin_layout Itemize
635 Syntax: number bit.all(number...)
636 \end_layout
638 \begin_layout Itemize
639 Syntax: number bit.band(number...)
640 \end_layout
642 \begin_layout Standard
643 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
645 \end_layout
647 \begin_layout Subsection
648 bit.parity/bit.bxor: Bitwise parity or XOR function
649 \end_layout
651 \begin_layout Itemize
652 Syntax: number bit.parity(number...)
653 \end_layout
655 \begin_layout Itemize
656 Syntax: number bit.bxor(number...)
657 \end_layout
659 \begin_layout Standard
660 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
661  of the arguments).
662 \end_layout
664 \begin_layout Subsection
665 bit.lrotate: Rotate a number left
666 \end_layout
668 \begin_layout Itemize
669 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
670 \end_layout
672 \begin_layout Standard
673 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
674  1) places.
675 \end_layout
677 \begin_layout Subsection
678 bit.rrotate: Rotate a number right
679 \end_layout
681 \begin_layout Itemize
682 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
683 \end_layout
685 \begin_layout Standard
686 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
687  1) places.
688 \end_layout
690 \begin_layout Subsection
691 bit.lshift: Shift a number left
692 \end_layout
694 \begin_layout Itemize
695 Syntax: number bit.lshift(number base[, number amount[, number bits]])
696 \end_layout
698 \begin_layout Standard
699 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
700  1) places.
701  The new bits are filled with zeroes.
702 \end_layout
704 \begin_layout Subsection
705 bit.lrshift: Shift a number right (logical)
706 \end_layout
708 \begin_layout Itemize
709 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
710 \end_layout
712 \begin_layout Standard
713 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
714  (default 1) places.
715  The new bits are filled with zeroes.
716 \end_layout
718 \begin_layout Subsection
719 bit.arshift: Shift a number right (arithmetic)
720 \end_layout
722 \begin_layout Itemize
723 Syntax: number bit.arshift(number base[, number amount[, number bits]])
724 \end_layout
726 \begin_layout Standard
727 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
728  (default 1) places.
729  The new bits are shifted in with copy of the high bit.
730 \end_layout
732 \begin_layout Subsection
733 bit.extract: Extract/shuffle bits from number
734 \end_layout
736 \begin_layout Itemize
737 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
738 \end_layout
740 \begin_layout Standard
741 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
742 \end_layout
744 \begin_layout Itemize
745 Note: Bit numbers up to 51 should work reliably (then things start falling
746  apart due to double precision issues).
747 \end_layout
749 \begin_layout Itemize
750 Note: There are two special bit positions, true and false, standing for
751  always set bit and always clear bit.
752 \end_layout
754 \begin_layout Subsection
755 bit.value: Construct number with specified bits set
756 \end_layout
758 \begin_layout Itemize
759 Syntax: number bit.value([number bit1[, number bit2,...]])
760 \end_layout
762 \begin_layout Standard
763 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
764  <bit2> places and so on.
765  As special value, nil argument is no-op.
766 \end_layout
768 \begin_layout Subsection
769 bit.test_any: Test if any bit is set
770 \end_layout
772 \begin_layout Itemize
773 Syntax: boolean bit.test_any(number a, number b)
774 \end_layout
776 \begin_layout Standard
777 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
778 \end_layout
780 \begin_layout Subsection
781 bit.test_all: Test if all bits are set
782 \end_layout
784 \begin_layout Itemize
785 Syntax: boolean bit.test_all(number a, number b)
786 \end_layout
788 \begin_layout Standard
789 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
790 \end_layout
792 \begin_layout Subsection
793 bit.popcount: Population count
794 \end_layout
796 \begin_layout Itemize
797 Syntax: number bit.popcount(number a)
798 \end_layout
800 \begin_layout Standard
801 Returns number of set bits in <a>.
802 \end_layout
804 \begin_layout Subsection
805 bit.clshift: Chained left shift
806 \end_layout
808 \begin_layout Itemize
809 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
810  bits]])
811 \end_layout
813 \begin_layout Standard
814 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
815  numbers to be of specified number of bits <bits> (default 48).
816 \end_layout
818 \begin_layout Subsection
819 bit.crshift: Chained right shift
820 \end_layout
822 \begin_layout Itemize
823 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
824  bits]])
825 \end_layout
827 \begin_layout Standard
828 Does chained right shift on <a>, <b> by <amount> positions (default 1),
829  assuming numbers to be of specified number of bits <bits> (default 48).
830 \end_layout
832 \begin_layout Subsection
833 bit.flagdecode: Decode bitfield into flags
834 \end_layout
836 \begin_layout Itemize
837 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
838  off]])
839 \end_layout
841 \begin_layout Standard
842 Return string of length bits where ith character is ith character of on
843  if bit i is on, otherwise ith character of off.
844  Out of range reads give last character.
845 \end_layout
847 \begin_layout Itemize
848 Note: <on> defaults to '*' if empty.
849 \end_layout
851 \begin_layout Itemize
852 Note: <off> defaults to '-' if empty.
853 \end_layout
855 \begin_layout Subsection
856 bit.rflagdecode: Decode bitfield into flags
857 \end_layout
859 \begin_layout Itemize
860 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
861  off]])
862 \end_layout
864 \begin_layout Standard
865 Like bit.flagdecode, but outputs the string in the opposite order (most significa
866 nt bit first).
867 \end_layout
869 \begin_layout Subsection
870 bit.swap{,s}{,h,d,q}word: Swap word endian
871 \end_layout
873 \begin_layout Itemize
874 Syntax: number bit.swapword(number n)
875 \end_layout
877 \begin_layout Itemize
878 Syntax: number bit.swaphword(number n)
879 \end_layout
881 \begin_layout Itemize
882 Syntax: number bit.swapdword(number n)
883 \end_layout
885 \begin_layout Itemize
886 Syntax: number bit.swapqword(number n)
887 \end_layout
889 \begin_layout Itemize
890 Syntax: number bit.swapsword(number n)
891 \end_layout
893 \begin_layout Itemize
894 Syntax: number bit.swapshword(number n)
895 \end_layout
897 \begin_layout Itemize
898 Syntax: number bit.swapsdword(number n)
899 \end_layout
901 \begin_layout Itemize
902 Syntax: number bit.swapsqword(number n)
903 \end_layout
905 \begin_layout Standard
906 Swap endianess of (un)signed integer <n>.
907 \end_layout
909 \begin_layout Standard
910 \begin_inset Newpage pagebreak
911 \end_inset
914 \end_layout
916 \begin_layout Section
917 Table gui:
918 \end_layout
920 \begin_layout Itemize
921 Functions that draw to screen can only only be called in on_paint and on_video
922  callbacks or if non-default render queue has been set.
923 \end_layout
925 \begin_layout Itemize
926 Colors are 32-bit.
927  Bits 0-7 are the blue component, bits 8-15 are the green component, bits
928  16-23 are the red component, bits 24-31 are alpha component (0 is fully
929  opaque, 255 is almost transparent).
930  -1 is the fully transparent color.
931  Alternatively, colors can be given as strings naming the color.
932 \end_layout
934 \begin_layout Itemize
935 Alpha values greater than 127 do work properly.
936 \end_layout
938 \begin_layout Itemize
939 Origin of coordinates is at top left corner of game display area.
940  Left and top gaps correspond to negative coordinates.
941 \end_layout
943 \begin_layout Itemize
944 The following color names are known: aliceblue antiquewhite antiquewhite1
945  antiquewhite2 antiquewhite3 antiquewhite4 aqua aquamarine aquamarine1 aquamarin
946 e2 aquamarine3 aquamarine4 azure azure1 azure2 azure3 azure4 beige bisque
947  bisque1 bisque2 bisque3 bisque4 black blanchedalmond blue blue1 blue2 blue3
948  blue4 blueviolet brown brown1 brown2 brown3 brown4 burlywood burlywood1
949  burlywood2 burlywood3 burlywood4 cadet cadetblue cadetblue1 cadetblue2
950  cadetblue3 cadetblue4 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse
951 4 chocolate chocolate1 chocolate2 chocolate3 chocolate4 coral coral1 coral2
952  coral3 coral4 cornflowerblue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4
953  crimson cyan cyan1 cyan2 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgolden
954 rod1 darkgoldenrod2 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey
955  darkkhaki darkmagenta darkolivegreen darkolivegreen1 darkolivegreen2 darkoliveg
956 reen3 darkolivegreen4 darkorange darkorange1 darkorange2 darkorange3 darkorange4
957  darkorchid darkorchid1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon
958  darkseagreen darkseagreen1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateb
959 lue darkslategray darkslategray1 darkslategray2 darkslategray3 darkslategray4
960  darkslategrey darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3
961  deeppink4 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4
962  dimgray dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4
963  firebrick firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen
964  fractal fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod
965  goldenrod1 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100
966  gray11 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20
967  gray21 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30
968  gray31 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40
969  gray41 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50
970  gray51 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60
971  gray61 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70
972  gray71 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80
973  gray81 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90
974  gray91 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1
975  green2 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11
976  grey12 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21
977  grey22 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31
978  grey32 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41
979  grey42 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51
980  grey52 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61
981  grey62 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71
982  grey72 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81
983  grey82 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91
984  grey92 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1
985  honeydew2 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4
986  indianred indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1
987  ivory2 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
988  lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
989 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
990  lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
991  lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
992 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
993  lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
994  lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
995  lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
996  lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
997  lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
998  lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
999  maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
1000  mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
1001  mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
1002 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
1003 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
1004 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
1005  navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
1006  olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
1007  orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
1008  palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
1009 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
1010  palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
1011  peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
1012  pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
1013  purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
1014  rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
1015  saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
1016  seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
1017  seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
1018  skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
1019 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
1020  snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
1021 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
1022  tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
1023  tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
1024  turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
1025  wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
1026  yellow3 yellow4 yellowgreen hsl-{r,ry,o,y,yg,g,gc,c,cb,b,bm,m,mr}{0,1,2,3,4,5,6
1027 ,7,8}{0,1,2,3,4,5,6,7,8}.
1028 \end_layout
1030 \begin_layout Itemize
1031 The following modifiers can be applied: opaque10, opaque20, opaque25, opaque30,
1032  opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
1033  hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
1034 \end_layout
1036 \begin_layout Itemize
1037 HSL base color names: r => Red, ry => Red-Yellow (also o).
1038  y => Yellow, yg => Yellow-Green, g => Green, gc => Green-Cyan, c => Cyan,
1039  cb => Cyan-Blue, b => Blue, bm => Blue-Magenta, m => Magenta, mr => Magenta
1040  red.
1041 \end_layout
1043 \begin_layout Itemize
1044 HSL colors use 8-step scales for saturation and lightness.
1045 \end_layout
1047 \begin_layout Itemize
1048 Modifiers have opaqueness on percent scale (0 is transparent, 100 is fully
1049  opaque).
1050 \end_layout
1052 \begin_layout Itemize
1053 Modifiers have Hue on 24-step scale (4 steps between R->Y->G->C->B->M->R).
1054 \end_layout
1056 \begin_layout Itemize
1057 Modifiers have Saturation/Lightness on 16 step scale.
1058 \end_layout
1060 \begin_layout Subsection
1061 gui.resolution: Get current resolution
1062 \end_layout
1064 \begin_layout Itemize
1065 Syntax: (number, number) gui.resolution()
1066 \end_layout
1068 \begin_layout Standard
1069 Returns 2-tuple (hresolution, vresolution).
1070 \end_layout
1072 \begin_layout Subsection
1073 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
1074 \end_layout
1076 \begin_layout Itemize
1077 Syntax: number gui.left_gap(number gap)
1078 \end_layout
1080 \begin_layout Itemize
1081 Syntax: number gui.right_gap(number gap)
1082 \end_layout
1084 \begin_layout Itemize
1085 Syntax: number gui.top_gap(number gap)
1086 \end_layout
1088 \begin_layout Itemize
1089 Syntax: number gui.bottom_gap(number gap)
1090 \end_layout
1092 \begin_layout Standard
1093 Set the specified edge gap to specified value <gap> (max gap is 8191).
1094  If successful, old gap is returned.
1095 \end_layout
1097 \begin_layout Subsection
1098 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
1099  Adjust edge gaps
1100 \end_layout
1102 \begin_layout Itemize
1103 Syntax: number gui.delta_left_gap(number dgap)
1104 \end_layout
1106 \begin_layout Itemize
1107 Syntax: number gui.delta_right_gap(number dgap)
1108 \end_layout
1110 \begin_layout Itemize
1111 Syntax: number gui.delta_top_gap(number dgap)
1112 \end_layout
1114 \begin_layout Itemize
1115 Syntax: number gui.delta_bottom_gap(number dgap)
1116 \end_layout
1118 \begin_layout Standard
1119 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
1120  and return the old gap (returns nothing on error).
1121 \end_layout
1123 \begin_layout Subsection
1124 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
1125 \end_layout
1127 \begin_layout Itemize
1128 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
1129  bgc]])
1130 \end_layout
1132 \begin_layout Itemize
1133 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
1134  bgc]])
1135 \end_layout
1137 \begin_layout Itemize
1138 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
1139  bgc]])
1140 \end_layout
1142 \begin_layout Itemize
1143 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
1144  bgc]])
1145 \end_layout
1147 \begin_layout Standard
1148 Draw specified text on the GUI (each character cell is 8 or 16 wide and
1149  16 high).
1150  Parameters:
1151 \end_layout
1153 \begin_layout Itemize
1154 x: X-coordinate to start the drawing from (and x-coordinate at begining
1155  of the lines).
1156 \end_layout
1158 \begin_layout Itemize
1159 y: Y-coordinate to start the drawing from.
1160 \end_layout
1162 \begin_layout Itemize
1163 text: The text to draw.
1164 \end_layout
1166 \begin_layout Itemize
1167 fgc: Text color (default is 0xFFFFFF (white))
1168 \end_layout
1170 \begin_layout Itemize
1171 bgc: Background color (default is -1 (transparent))
1172 \end_layout
1174 \begin_layout Standard
1175 Note: The H variants draw at double width and V variants draw at double
1176  height.
1177 \end_layout
1179 \begin_layout Subsection
1180 gui.rectangle: Draw a rectangle
1181 \end_layout
1183 \begin_layout Itemize
1184 Syntax: none gui.rectangle(number x, number y, number width, number height[,
1185  number thickness[, number outline[, number fill]]])
1186 \end_layout
1188 \begin_layout Standard
1189 Draw rectangle on the GUI.
1190  Parameters:
1191 \end_layout
1193 \begin_layout Itemize
1194 x: X-coordinate of left edge.
1195 \end_layout
1197 \begin_layout Itemize
1198 y: Y-coordinate of upper edge.
1199 \end_layout
1201 \begin_layout Itemize
1202 width: Width of rectangle.
1203 \end_layout
1205 \begin_layout Itemize
1206 height: Height of rectangle.
1207 \end_layout
1209 \begin_layout Itemize
1210 thickness: Thickness of outline (default is 1).
1211 \end_layout
1213 \begin_layout Itemize
1214 outline: Color of outline (default is 0xFFFFFF (white))
1215 \end_layout
1217 \begin_layout Itemize
1218 fill: Color of fill (default is -1 (transparent))
1219 \end_layout
1221 \begin_layout Subsection
1222 gui.box: Draw a 3D-effect box
1223 \end_layout
1225 \begin_layout Itemize
1226 Syntax: none gui.box(number x, number y, number width, number height[, number
1227  thickness[, number outline1[,number outline2[, number fill]]]])
1228 \end_layout
1230 \begin_layout Standard
1231 Draw rectangle with 3D effect on the GUI.
1232  Parameters:
1233 \end_layout
1235 \begin_layout Itemize
1236 x: X-coordinate of left edge.
1237 \end_layout
1239 \begin_layout Itemize
1240 y: Y-coordinate of upper edge.
1241 \end_layout
1243 \begin_layout Itemize
1244 width: Width of rectangle.
1245 \end_layout
1247 \begin_layout Itemize
1248 height: Height of rectangle.
1249 \end_layout
1251 \begin_layout Itemize
1252 thickness: Thickness of outline (default is 1).
1253 \end_layout
1255 \begin_layout Itemize
1256 outline1: First color of outline (default is 0xFFFFFF (white))
1257 \end_layout
1259 \begin_layout Itemize
1260 outline2: First color of outline (default is 0x808080 (dark gray))
1261 \end_layout
1263 \begin_layout Itemize
1264 fill: Color of fill (default is 0xC0C0C0 (light grayy))
1265 \end_layout
1267 \begin_layout Subsection
1268 gui.pixel: Draw a single pixel
1269 \end_layout
1271 \begin_layout Itemize
1272 Syntax: none gui.pixel(number x, number y[, number color])
1273 \end_layout
1275 \begin_layout Standard
1276 Draw one pixel on the GUI.
1277  Parameters:
1278 \end_layout
1280 \begin_layout Itemize
1281 x: X-coordinate of the pixel
1282 \end_layout
1284 \begin_layout Itemize
1285 y: Y-coordinate of the pixel
1286 \end_layout
1288 \begin_layout Itemize
1289 color: Color of the pixel (default is 0xFFFFFF (white))
1290 \end_layout
1292 \begin_layout Subsection
1293 gui.crosshair: Draw a crosshair
1294 \end_layout
1296 \begin_layout Itemize
1297 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
1298 \end_layout
1300 \begin_layout Standard
1301 Draw a crosshair.
1302  Parameters:
1303 \end_layout
1305 \begin_layout Itemize
1306 x: X-coordinate of the crosshair
1307 \end_layout
1309 \begin_layout Itemize
1310 y: Y-coordinate of the crosshair
1311 \end_layout
1313 \begin_layout Itemize
1314 length: Length of the crosshair lines (default 10).
1315 \end_layout
1317 \begin_layout Itemize
1318 color: Color of the crosshair (default is 0xFFFFFF (white))
1319 \end_layout
1321 \begin_layout Subsection
1322 gui.line: Draw a line
1323 \end_layout
1325 \begin_layout Itemize
1326 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
1327  color])
1328 \end_layout
1330 \begin_layout Standard
1331 Draw a thin line.
1332  Parameters:
1333 \end_layout
1335 \begin_layout Itemize
1336 x1: X-coordinate of one end.
1337 \end_layout
1339 \begin_layout Itemize
1340 y1: Y-coordinate of one end.
1341 \end_layout
1343 \begin_layout Itemize
1344 x2: X-coordinate of the other end.
1345 \end_layout
1347 \begin_layout Itemize
1348 y2: Y-coordinate of the other end.
1349 \end_layout
1351 \begin_layout Itemize
1352 color: Color of the line (default is 0xFFFFFF (white)).
1353 \end_layout
1355 \begin_layout Subsection
1356 gui.circle: Draw a (filled) circle
1357 \end_layout
1359 \begin_layout Itemize
1360 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
1361  border[, number fil]]])
1362 \end_layout
1364 \begin_layout Standard
1365 Draw a circle.
1366  Parameters.
1367 \end_layout
1369 \begin_layout Itemize
1370 x: X-coordinate of the center
1371 \end_layout
1373 \begin_layout Itemize
1374 y: Y-coordinate of the center
1375 \end_layout
1377 \begin_layout Itemize
1378 r: The radius of the circle
1379 \end_layout
1381 \begin_layout Itemize
1382 thick: Border thickness
1383 \end_layout
1385 \begin_layout Itemize
1386 border: Border color (default is 0xFFFFFF (white))
1387 \end_layout
1389 \begin_layout Itemize
1390 fill: Fill color (default is -1 (transparent)).
1391 \end_layout
1393 \begin_layout Subsection
1394 gui.bitmap_draw/(D)BITMAP:draw: Draw a bitmap
1395 \end_layout
1397 \begin_layout Itemize
1398 Syntax: none gui.bitmap_draw(number x, number y, BITMAP bitmap, PALETTE palette)
1399 \end_layout
1401 \begin_layout Itemize
1402 Syntax: none gui.bitmap_draw(number x, number y, DBITMAP bitmap)
1403 \end_layout
1405 \begin_layout Itemize
1406 Syntax: none BITMAP:draw(number x, number y, PALETTE palette)
1407 \end_layout
1409 \begin_layout Itemize
1410 Syntax: none DBITMAP:draw(number x, number y)
1411 \end_layout
1413 \begin_layout Standard
1414 Draw a bitmap <bitmap> (or object) on screen with specified palette <palette>
1415  (if bitmap is paletted) .
1416  Parameters:
1417 \end_layout
1419 \begin_layout Itemize
1420 x: X-coordinate of left edge.
1421 \end_layout
1423 \begin_layout Itemize
1424 y: Y-coordinate of top edge.
1425 \end_layout
1427 \begin_layout Itemize
1428 bitmap: The bitmap to draw
1429 \end_layout
1431 \begin_layout Itemize
1432 palette: The palette to draw the bitmap using.
1433 \end_layout
1435 \begin_layout Subsection
1436 gui.palette_new: Create a new palette
1437 \end_layout
1439 \begin_layout Itemize
1440 Syntax: PALETTE gui.palette_new()
1441 \end_layout
1443 \begin_layout Standard
1444 Returns a new palette (initially all transparent).
1446 \end_layout
1448 \begin_layout Subsection
1449 gui.bitmap_new: Create a new bitmap
1450 \end_layout
1452 \begin_layout Itemize
1453 Syntax: BITMAP/DBITMAP gui.bitmap_new(number w, number h, boolean direct[,
1454  bool icolor])
1455 \end_layout
1457 \begin_layout Standard
1458 Returns a new bitmap/dbitmap.
1459 \end_layout
1461 \begin_layout Standard
1462 Parameters:
1463 \end_layout
1465 \begin_layout Itemize
1466 w: The width of new bitmap
1467 \end_layout
1469 \begin_layout Itemize
1470 h: The height of new bitmap
1471 \end_layout
1473 \begin_layout Itemize
1474 direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
1475 \end_layout
1477 \begin_layout Itemize
1478 icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
1479 \end_layout
1481 \begin_layout Subsection
1482 gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
1483 \end_layout
1485 \begin_layout Itemize
1486 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
1487 \end_layout
1489 \begin_layout Itemize
1490 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
1491 \end_layout
1493 \begin_layout Standard
1494 Reads file <file> (resolved relative to <base>) or string <content> and
1495  returns loaded bitmap/dbitmap (if bitmap, the second return value is palette
1496  for bitmap).
1497 \end_layout
1499 \begin_layout Subsection
1500 gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
1501 \end_layout
1503 \begin_layout Itemize
1504 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
1505  base])
1506 \end_layout
1508 \begin_layout Itemize
1509 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
1510 \end_layout
1512 \begin_layout Standard
1513 Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
1514  encoded content <content>.
1515 \end_layout
1517 \begin_layout Itemize
1518 If the PNG is of color type 3 (PALETTE), returns two values.
1519  First is BITMAP containing the image data from the PNG and second is PALETTE
1520  containg the palette data from the PNG.
1521 \end_layout
1523 \begin_layout Itemize
1524 For color types 0 (GRAY), 2 (RGB), 4 (GRAY_ALPHA) and 6 (RGBA), returns
1525  one DBITMAP containg the image data loaded from the PNG.
1526 \end_layout
1528 \begin_layout Subsection
1529 gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
1530 \end_layout
1532 \begin_layout Itemize
1533 Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
1534 \end_layout
1536 \begin_layout Itemize
1537 Syntax: PALETTE gui.bitmap_load_pal_str(string content)
1538 \end_layout
1540 \begin_layout Standard
1541 Load a palette from file <file>(resolved relative to <base>) or string <content>.
1542 \end_layout
1544 \begin_layout Itemize
1545 The kinds of lines supported:
1546 \end_layout
1548 \begin_deeper
1549 \begin_layout Itemize
1550 Blank or just whitespace: Ignored
1551 \end_layout
1553 \begin_layout Itemize
1554 First non-whitespace is '#': Ignored
1555 \end_layout
1557 \begin_layout Itemize
1558 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1559 \end_layout
1561 \begin_layout Itemize
1562 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1563  (0-256, 0 being fully transparent and 256 fully opaque).
1564 \end_layout
1566 \begin_layout Itemize
1567 transparent: Fully transparent color
1568 \end_layout
1570 \end_deeper
1571 \begin_layout Subsection
1572 gui.palette_set/PALETTE:set: Set palette entry
1573 \end_layout
1575 \begin_layout Itemize
1576 Syntax: none gui.palette_set(PALETTE palette, number index, number color)
1577 \end_layout
1579 \begin_layout Itemize
1580 Syntax: none PALETTE:set(number index, number color)
1581 \end_layout
1583 \begin_layout Standard
1584 Sets color in palette.
1585  Parameters:
1586 \end_layout
1588 \begin_layout Itemize
1589 palette: The palette to manipulate
1590 \end_layout
1592 \begin_layout Itemize
1593 index: Index of color (0-65535).
1594 \end_layout
1596 \begin_layout Itemize
1597 color: The color value.
1598 \end_layout
1600 \begin_layout Subsection
1601 gui.bitmap_pset/(D)BITMAP:pset: Set pixel in bitmap
1602 \end_layout
1604 \begin_layout Itemize
1605 Syntax: none gui.bitmap_pset(BITMAP/DBITMAP bitmap, number x, number y, number
1606  color)
1607 \end_layout
1609 \begin_layout Itemize
1610 Syntax: none BITMAP:pset(number x, number y, number color)
1611 \end_layout
1613 \begin_layout Itemize
1614 Syntax: none DBITMAP:pset(number x, number y, number color)
1615 \end_layout
1617 \begin_layout Standard
1618 Sets specified pixel in bitmap.
1619  Parameters:
1620 \end_layout
1622 \begin_layout Itemize
1623 bitmap: The bitmap to manipulate
1624 \end_layout
1626 \begin_layout Itemize
1627 x: The x-coordinate of the pixel.
1628 \end_layout
1630 \begin_layout Itemize
1631 y: The y-coordinate of the pixel.
1632 \end_layout
1634 \begin_layout Itemize
1635 color: If bitmap is a bitmap, color index (0-65535).
1636  Otherwise color value.
1637 \end_layout
1639 \begin_layout Subsection
1640 gui.bitmap_pget/(D)BITMAP:pget: Get pixel in bitmap
1641 \end_layout
1643 \begin_layout Itemize
1644 Syntax: number gui.bitmap_pget(BITMAP/DBITMAP bitmap, number x, number y)
1645 \end_layout
1647 \begin_layout Itemize
1648 Syntax: number BITMAP:pget(number x, number y)
1649 \end_layout
1651 \begin_layout Itemize
1652 Syntax: number DBITMAP:pget(number x, number y)
1653 \end_layout
1655 \begin_layout Standard
1656 Gets specified pixel in bitmap.
1657  Parameters:
1658 \end_layout
1660 \begin_layout Itemize
1661 bitmap: The bitmap to query
1662 \end_layout
1664 \begin_layout Itemize
1665 x: The x-coordinate of the pixel.
1666 \end_layout
1668 \begin_layout Itemize
1669 y: The y-coordinate of the pixel.
1670 \end_layout
1672 \begin_layout Standard
1673 The bitmap color (color index if paletted, otherwise color value).
1674 \end_layout
1676 \begin_layout Subsection
1677 gui.bitmap_size/(D)BITMAP:size: Get size of bitmap
1678 \end_layout
1680 \begin_layout Itemize
1681 Syntax: (number, number) gui.bitmap_size(BITMAP/DBITMAP bitmap)
1682 \end_layout
1684 \begin_layout Itemize
1685 Syntax: (number, number) BITMAP:size()
1686 \end_layout
1688 \begin_layout Itemize
1689 Syntax: (number, number) DBITMAP:size()
1690 \end_layout
1692 \begin_layout Standard
1693 Get size of bitmap <bitmap>.
1694  The first return is the width, the second is the height.
1695 \end_layout
1697 \begin_layout Itemize
1698 Note: Can be used anywhere.
1699 \end_layout
1701 \begin_layout Subsection
1702 gui.bitmap_blit/(D)BITMAP:blit: Blit a bitmap into another
1703 \end_layout
1705 \begin_layout Itemize
1706 Syntax: none gui.bitmap_blit(BITMAP dest, number dx, number dy, BITMAP src,
1707  number sx, number sy, number w, number h[, number ck])
1708 \end_layout
1710 \begin_layout Itemize
1711 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, DBITMAP
1712  src, number sx, number sy, number w, number h[, number ck])
1713 \end_layout
1715 \begin_layout Itemize
1716 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, BITMAP src,
1717  PALETTE pal, number sx, number sy, number w, number h[, number ck])
1718 \end_layout
1720 \begin_layout Itemize
1721 Syntax: none BITMAP::blit(number dx, number dy, BITMAP src, number sx, number
1722  sy, number w, number h[, number ck])
1723 \end_layout
1725 \begin_layout Itemize
1726 Syntax: none DBITMAP::blit(number dx, number dy, DBITMAP src, number sx,
1727  number sy, number w, number h[, number ck])
1728 \end_layout
1730 \begin_layout Itemize
1731 Syntax: none DBITMAP:blit(number dx, number dy, BITMAP src, PALETTE pal,
1732  number sx, number sy, number w, number h[, number ck])
1733 \end_layout
1735 \begin_layout Standard
1736 Blit a part of bitmap to another (current object if any is destination).
1737  Parameters:
1738 \end_layout
1740 \begin_layout Itemize
1741 dest: Destination to blit to.
1742 \end_layout
1744 \begin_layout Itemize
1745 dx: left edge of target
1746 \end_layout
1748 \begin_layout Itemize
1749 dy: Top edge of target
1750 \end_layout
1752 \begin_layout Itemize
1753 src: The source to blit from.
1754 \end_layout
1756 \begin_layout Itemize
1757 pal: The palette to use in blit.
1758 \end_layout
1760 \begin_layout Itemize
1761 sx: left edge of source
1762 \end_layout
1764 \begin_layout Itemize
1765 sy: Top edge of source
1766 \end_layout
1768 \begin_layout Itemize
1769 w: Width of region
1770 \end_layout
1772 \begin_layout Itemize
1773 h: Height of region.
1774 \end_layout
1776 \begin_layout Itemize
1777 ck: Color key.
1778  Pixels of this color are not blitted.
1779 \end_layout
1781 \begin_deeper
1782 \begin_layout Itemize
1783 If soruce bitmap is bitmap, this is color index of colorkey.
1784  Values outside range 0-65535 cause no key to be used as colorkey.
1785 \end_layout
1787 \begin_layout Itemize
1788 If source bitmap is dbitmap, this is the color value of colorkey.
1789 \end_layout
1791 \begin_layout Itemize
1792 May be absent or nil for no colorkey blit.
1793 \end_layout
1795 \end_deeper
1796 \begin_layout Subsection
1797 gui.bitmap_blit_scaled/(D)BITMAP:blit_scaled: Blit a bitmap into another
1798  with scaling
1799 \end_layout
1801 \begin_layout Itemize
1802 Syntax: none gui.bitmap_blit_scaled(BITMAP dest, number dx, number dy, BITMAP
1803  src, number sx, number sy, number w, number h, number hscl[, number vscl[,
1804  number ck]])
1805 \end_layout
1807 \begin_layout Itemize
1808 Syntax: none gui.bitmap_blit_scaled(DBITMAP dest, number dx, number dy, DBITMAP
1809  src, number sx, number sy, number w, number h, number hscl[, number vscl[,
1810  number ck]])
1811 \end_layout
1813 \begin_layout Itemize
1814 Syntax: none gui.bitmap_blit_scaled(DBITMAP dest, number dx, number dy, BITMAP
1815  src, PALETTE pal, number sx, number sy, number w, number h, number hscl[,
1816  number vscl[, number ck]])
1817 \end_layout
1819 \begin_layout Itemize
1820 Syntax: none BITMAP::blit_scaled(number dx, number dy, BITMAP src, number
1821  sx, number sy, number w, number h, number hscl[, number vscl[, number ck]])
1822 \end_layout
1824 \begin_layout Itemize
1825 Syntax: none DBITMAP::blit_scaled(number dx, number dy, DBITMAP src, number
1826  sx, number sy, number w, number h, number hscl[, number vscl[, number ck]])
1827 \end_layout
1829 \begin_layout Itemize
1830 Syntax: none DBITMAP:blit_scaled(number dx, number dy, BITMAP src, PALETTE
1831  pal, number sx, number sy, number w, number h, number hscl[, number vscl[,
1832  number ck]])
1833 \end_layout
1835 \begin_layout Standard
1836 Like (D)BITMAP:blit, but also scale the image horizontally by <hscl> and
1837  vertically by <vscl> (if not specified, <vscl> defaults to <hscl>).
1838 \end_layout
1840 \begin_layout Subsection
1841 gui.bitmap_blit_porterduff/(D)BITMAP:blit_porterduff: Blit a bitmap into
1842  another with Porter-Duff composition
1843 \end_layout
1845 \begin_layout Itemize
1846 Syntax: none gui.bitmap_blit_porterduff(BITMAP dest, number dx, number dy,
1847  BITMAP src, number sx, number sy, number w, number h, string operator)
1848 \end_layout
1850 \begin_layout Itemize
1851 Syntax: none gui.bitmap_blit_porterduff(DBITMAP dest, number dx, number dy,
1852  DBITMAP src, number sx, number sy, number w, number h, string operator)
1853 \end_layout
1855 \begin_layout Itemize
1856 Syntax: none gui.bitmap_blit_porterduff(DBITMAP dest, number dx, number dy,
1857  BITMAP src, PALETTE pal, number sx, number sy, number w, number h, string
1858  operator)
1859 \end_layout
1861 \begin_layout Itemize
1862 Syntax: none BITMAP::blit_porterduff(number dx, number dy, BITMAP src, number
1863  sx, number sy, number w, number h, string operator)
1864 \end_layout
1866 \begin_layout Itemize
1867 Syntax: none DBITMAP::blit_porterduff(number dx, number dy, DBITMAP src,
1868  number sx, number sy, number w, number h, string operator)
1869 \end_layout
1871 \begin_layout Itemize
1872 Syntax: none DBITMAP:blit_porterduff(number dx, number dy, BITMAP src, PALETTE
1873  pal, number sx, number sy, number w, number h, string operator)
1874 \end_layout
1876 \begin_layout Standard
1877 Like (D)BITMAP:blit, but applying specified Porter-Duff operator.
1878  BITMAPs always have color 0 treated as background, DBITMAPs treat full
1879  opaque as background.
1880  <operator> may be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver,
1881  DestIn, DestOut, Clear or Xor.
1882 \end_layout
1884 \begin_layout Subsection
1885 gui.bitmap_blit_scaled_porterduff/(D)BITMAP:blit_scaled_porterduff: Blit
1886  a bitmap into another with scaling and Porter-Duff composition
1887 \end_layout
1889 \begin_layout Itemize
1890 Syntax: none gui.bitmap_blit_scaled_porterduff(BITMAP dest, number dx, number
1891  dy, BITMAP src, number sx, number sy, number w, number h, number hscl,
1892  number vscl, string operator)
1893 \end_layout
1895 \begin_layout Itemize
1896 Syntax: none gui.bitmap_blit_scaled_porterduff(DBITMAP dest, number dx, number
1897  dy, DBITMAP src, number sx, number sy, number w, number h, number hscl,
1898  number vscl, string operator)
1899 \end_layout
1901 \begin_layout Itemize
1902 Syntax: none gui.bitmap_blit_scaled_porterduff(DBITMAP dest, number dx, number
1903  dy, BITMAP src, PALETTE pal, number sx, number sy, number w, number h,
1904  number hscl, number vscl, string operator)
1905 \end_layout
1907 \begin_layout Itemize
1908 Syntax: none BITMAP::blit_scaled_porterduff(number dx, number dy, BITMAP
1909  src, number sx, number sy, number w, number h, number hscl, number vscl,
1910  string operator)
1911 \end_layout
1913 \begin_layout Itemize
1914 Syntax: none DBITMAP::blit_scaled_porterduff(number dx, number dy, DBITMAP
1915  src, number sx, number sy, number w, number h, number hscl, number vscl,
1916  string operator)
1917 \end_layout
1919 \begin_layout Itemize
1920 Syntax: none DBITMAP:blit_scaled_porterduff(number dx, number dy, BITMAP
1921  src, PALETTE pal, number sx, number sy, number w, number h, number hscl,
1922  number vscl, string operator)
1923 \end_layout
1925 \begin_layout Standard
1926 Like (D)BITMAP:blit_porterduff, but also scale the image horizontally by
1927  <hscl> and vertically by <vscl> (if nil, <vscl> defaults to <hscl>).
1928 \end_layout
1930 \begin_layout Subsection
1931 gui.bitmap_blit_priority/BITMAP:blit_priority: Blit a bitmap into another
1932  with color priority
1933 \end_layout
1935 \begin_layout Itemize
1936 Syntax: none gui.bitmap_blit_priority(BITMAP dest, number dx, number dy,
1937  BITMAP src, number sx, number sy, number w, number h)
1938 \end_layout
1940 \begin_layout Itemize
1941 Syntax: none BITMAP::blit_priority(number dx, number dy, BITMAP src, number
1942  sx, number sy, number w, number h)
1943 \end_layout
1945 \begin_layout Standard
1946 Like BITMAP:blit, but copy a pixel only if source palette index is greater
1947  than destination palette index.
1948 \end_layout
1950 \begin_layout Subsection
1951 gui.bitmap_blit_scaled_priority/BITMAP:blit_scaled_priority: Blit a bitmap
1952  into another with color priority and scaling
1953 \end_layout
1955 \begin_layout Itemize
1956 Syntax: none gui.bitmap_blit_scaled_priority(BITMAP dest, number dx, number
1957  dy, BITMAP src, number sx, number sy, number w, number h, number hscl[,
1958  number vscl])
1959 \end_layout
1961 \begin_layout Itemize
1962 Syntax: none BITMAP::blit_scaled_priority(number dx, number dy, BITMAP src,
1963  number sx, number sy, number w, number h, number hscl[, number vscl])
1964 \end_layout
1966 \begin_layout Standard
1967 Like BITMAP:blit_scaled, but copy a pixel only if source palette index is
1968  greater than destination palette index.
1969 \end_layout
1971 \begin_layout Subsection
1972 gui.repaint: Arrange a repaint
1973 \end_layout
1975 \begin_layout Itemize
1976 Syntax: none gui.repaint()
1977 \end_layout
1979 \begin_layout Standard
1980 Request on_repaint() to happen as soon as possible.
1981 \end_layout
1983 \begin_layout Subsection
1984 gui.synchronous_repaint/RENDERQUEUE:synchronous_repaint: Paint screen now
1985 \end_layout
1987 \begin_layout Itemize
1988 Syntax: none gui.synchronous_repaint(RENDERQUEUE queue)
1989 \end_layout
1991 \begin_layout Itemize
1992 Syntax: none RENDERQUEUE::synchronous_repaint()
1993 \end_layout
1995 \begin_layout Standard
1996 Paints specified render queue on screen right there and then.
1997 \end_layout
1999 \begin_layout Subsection
2000 gui.subframe_update: Enable/Disable subframe updates
2001 \end_layout
2003 \begin_layout Itemize
2004 Syntax: none gui.subframe_update(boolean on)
2005 \end_layout
2007 \begin_layout Standard
2008 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
2009  or not happen (<on>=false).
2010 \end_layout
2012 \begin_layout Subsection
2013 gui.screenshot: Write a screenshot
2014 \end_layout
2016 \begin_layout Itemize
2017 Syntax: none gui.screenshot(string filename)
2018 \end_layout
2020 \begin_layout Standard
2021 Write PNG screenshot of the current frame (no drawings) to specified file
2022  <filename>.
2023 \end_layout
2025 \begin_layout Subsection
2026 gui.screenshot_bitmap: Write a screenshot to bitmap
2027 \end_layout
2029 \begin_layout Itemize
2030 Syntax: DBITMAP gui.screenshot_bitmap()
2031 \end_layout
2033 \begin_layout Standard
2034 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
2035  the result.
2036 \end_layout
2038 \begin_layout Subsection
2039 gui.color: Compose a color.
2040 \end_layout
2042 \begin_layout Itemize
2043 Syntax: number gui.color(number r, number g, number b[, number a])
2044 \end_layout
2046 \begin_layout Itemize
2047 Syntax: number gui.color(string c)
2048 \end_layout
2050 \begin_layout Standard
2051 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
2052 , each component in scale 0-255.
2053  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
2054  fully opaque).
2055  The default alpha is 256.
2056 \end_layout
2058 \begin_layout Standard
2059 The form taking a string returns color corresponding color name.
2060 \end_layout
2062 \begin_layout Subsection
2063 gui.status: Set status variable
2064 \end_layout
2066 \begin_layout Itemize
2067 Syntax: none gui.status(string name, string value)
2068 \end_layout
2070 \begin_layout Standard
2071 Set status field 
2072 \begin_inset Quotes eld
2073 \end_inset
2075 L[<name>]
2076 \begin_inset Quotes erd
2077 \end_inset
2079  to <value> in status area.
2080 \end_layout
2082 \begin_layout Subsection
2083 gui.rainbow: Rainbow color calculation
2084 \end_layout
2086 \begin_layout Itemize
2087 Syntax: number gui.rainbow(number step, number steps[, number color])
2088 \end_layout
2090 \begin_layout Standard
2091 Perform hue rotation of color <color> (default bright red), by <step> steps.
2092  The number of steps per full rotation is given by absolute value of <steps>.
2093 \end_layout
2095 \begin_layout Standard
2096 If <step> is negative, the rotation will be counterclockwise.
2097 \end_layout
2099 \begin_layout Subsection
2100 gui.renderq_new: Create a render queue
2101 \end_layout
2103 \begin_layout Itemize
2104 Syntax: RENDERQUEUE gui.renderq_new(number width, number height)
2105 \end_layout
2107 \begin_layout Standard
2108 Create render queue with specified reported size and return it.
2109 \end_layout
2111 \begin_layout Subsection
2112 gui.renderq_clear/RENDERQUEUE:clear: Clear a render queue
2113 \end_layout
2115 \begin_layout Itemize
2116 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
2117 \end_layout
2119 \begin_layout Itemize
2120 Syntax: none RENDERQUEUE:clear()
2121 \end_layout
2123 \begin_layout Standard
2124 Clear specified render queue.
2125 \end_layout
2127 \begin_layout Subsection
2128 gui.renderq_set/RENDERQUEUE:set: Change active render queue
2129 \end_layout
2131 \begin_layout Itemize
2132 Syntax: none gui.renderq_set(RENDERQUEUE queue)
2133 \end_layout
2135 \begin_layout Itemize
2136 Syntax: none RENDERQUEUE:set()
2137 \end_layout
2139 \begin_layout Standard
2140 Switch to specified render queue.
2141  Use nil as queue to switch to default queue.
2142 \end_layout
2144 \begin_layout Itemize
2145 Note: When switched to another queue, all drawing functions work and draw
2146  there, even outside on_video/on_paint.
2147 \end_layout
2149 \begin_layout Subsection
2150 gui.renderq_run/RENDERQUEUE:run: Run render queue
2151 \end_layout
2153 \begin_layout Itemize
2154 Syntax: none gui.renderq_run(RENDERQUEUE queue)
2155 \end_layout
2157 \begin_layout Itemize
2158 Syntax: none RENDERQUEUE:run()
2159 \end_layout
2161 \begin_layout Standard
2162 Run specified render queue, copying the objects to current render queue.
2164 \end_layout
2166 \begin_layout Itemize
2167 Warning: Don't try to run the current render queue.
2168 \end_layout
2170 \begin_layout Subsection
2171 RENDERQUEUE:render: Render a queue to DBITMAP
2172 \end_layout
2174 \begin_layout Itemize
2175 Syntax: DBITMAP RENDERQUEUE:render()
2176 \end_layout
2178 \begin_layout Standard
2179 Renders the specified render queue to a bitmap, the base bitmap size (modified
2180  by gaps) being the nominal screen size for render queue.
2181 \end_layout
2183 \begin_layout Subsection
2184 gui.loadfont: Load a font file
2185 \end_layout
2187 \begin_layout Itemize
2188 Syntax: CUSTOMFONT gui.loadfont([string filename[, string relative_to]])
2189 \end_layout
2191 \begin_layout Standard
2192 Loads font from specified file (CUSTOMFONT object).
2193  If filename is not given, loads the system default font.
2194 \end_layout
2196 \begin_layout Subsection
2197 gui.font_new: Return a new empty font
2198 \end_layout
2200 \begin_layout Itemize
2201 Syntax: CUSTOMFONT gui.font_new()
2202 \end_layout
2204 \begin_layout Standard
2205 Returns a new font with no characters.
2206 \end_layout
2208 \begin_layout Subsection
2209 CUSTOMFONT(): Render text to screen
2210 \end_layout
2212 \begin_layout Itemize
2213 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
2214  bgc[, number hlc]]])
2215 \end_layout
2217 \begin_layout Standard
2218 Draw string with custom font to screen.
2219  The parameters are the same as in gui.text, except <hlc> is the halo color
2220  (default is no halo).
2222 \end_layout
2224 \begin_layout Subsection
2225 CUSTOMFONT:edit: Alter glyph in font
2226 \end_layout
2228 \begin_layout Itemize
2229 Syntax: none CUSTOMFONT:edit(string character, BITMAP glyph)
2230 \end_layout
2232 \begin_layout Standard
2233 Alter the character <character> (UTF-8 encoded) in font to use glyph specified
2234  by bitmap <glyph>.
2235  The conversion to monochrome is done by treating color 0 as background,
2236  and everything else as foreground.
2237 \end_layout
2239 \begin_layout Standard
2240 If <character> is empty string, the bad glyph is edited.
2241  If <character> has multiple characters, corresponding ligature glyph is
2242  edited.
2243 \end_layout
2245 \begin_layout Subsection
2246 gui.adjust_transparency/DBITMAP:adjust_transparency/PALETTE:adjust_transparency:
2247  Adjust transparency of DBITMAP or PALETTE
2248 \end_layout
2250 \begin_layout Itemize
2251 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
2252 \end_layout
2254 \begin_layout Itemize
2255 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
2256 \end_layout
2258 \begin_layout Itemize
2259 Syntax: none DBITMAP:adjust_transparency(number adj)
2260 \end_layout
2262 \begin_layout Itemize
2263 Syntax: none PALETTE:adjust_transparency(number adj)
2264 \end_layout
2266 \begin_layout Standard
2267 Multiply alpha channel of <obj> by <adj>/256.
2268  Useful for making 
2269 \begin_inset Quotes eld
2270 \end_inset
2272 ghosts
2273 \begin_inset Quotes erd
2274 \end_inset
2276  out of solid bitmaps.
2277 \end_layout
2279 \begin_layout Subsection
2280 gui.kill_frame: Kill video frame and associated sound
2281 \end_layout
2283 \begin_layout Itemize
2284 Syntax: none gui.kill_frame()
2285 \end_layout
2287 \begin_layout Standard
2288 Kills the currently dumped video frame + the associated sound.
2289  Only valid in on_video callback.
2290 \end_layout
2292 \begin_layout Subsection
2293 gui.set_video_scale: Set video frame scale
2294 \end_layout
2296 \begin_layout Itemize
2297 Syntax: none gui.set_video_scale(number h, number v)
2298 \end_layout
2300 \begin_layout Standard
2301 Sets the scale factors of current frame to <h>x<v>.
2302  Only valid in on_video callback.
2303 \end_layout
2305 \begin_layout Subsection
2306 gui.arrow: Draw an arrow
2307 \end_layout
2309 \begin_layout Itemize
2310 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
2311  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
2313 \end_layout
2315 \begin_layout Standard
2316 Draws an arrow using color <color>.
2317  The tip of arrow is at (<x>, <y>).
2318  Other parameters:
2319 \end_layout
2321 \begin_layout Enumerate
2322 <length>: The length of arrow tail.
2323 \end_layout
2325 \begin_layout Enumerate
2326 <hwidth>: The width of arrow head.
2327  Should be odd.
2328 \end_layout
2330 \begin_layout Enumerate
2331 <direction>: Direction of arrow.
2332  0 is to right, +1 rotates 45 degrees counterclockwise.
2333 \end_layout
2335 \begin_layout Enumerate
2336 <fill>: If true, fill the arrow head.
2337  Default false.
2338 \end_layout
2340 \begin_layout Enumerate
2341 <twidth>: Tail width.
2342  Should be odd.
2343  Default 1.
2344 \end_layout
2346 \begin_layout Enumerate
2347 <hthick>: Head thickness (only used if <fill> is false).
2348  Default is <twidth>.
2349 \end_layout
2351 \begin_layout Subsection
2352 gui.tilemap: Create a tilemap
2353 \end_layout
2355 \begin_layout Itemize
2356 Syntax: TILEMAP gui.tilemap(number w, number h, number bw, number bh)
2357 \end_layout
2359 \begin_layout Standard
2360 Create a new tilemap of size <w>*<h>, with each cell being <bw>*<bh>.
2361 \end_layout
2363 \begin_layout Subsection
2364 TILEMAP:getsize: Query tilemap size
2365 \end_layout
2367 \begin_layout Itemize
2368 Syntax: number, number TILEMAP:getsize()
2369 \end_layout
2371 \begin_layout Standard
2372 Return size of tilemap (width first).
2373 \end_layout
2375 \begin_layout Subsection
2376 TILEMAP:getcsize: Query tilemap cell size
2377 \end_layout
2379 \begin_layout Itemize
2380 Syntax: number, number TILEMAP:getcsize()
2381 \end_layout
2383 \begin_layout Standard
2384 Return size of tilemap cell (width first).
2385 \end_layout
2387 \begin_layout Subsection
2388 TILEMAP:get: Query tilemap cell
2389 \end_layout
2391 \begin_layout Itemize
2392 Syntax: none TILEMAP:get(number x, number y)
2393 \end_layout
2395 \begin_layout Itemize
2396 Syntax: dbitmap TILEMAP:get(number x, number y)
2397 \end_layout
2399 \begin_layout Itemize
2400 Syntax: bitmap,palette TILEMAP:get(number x, number y)
2401 \end_layout
2403 \begin_layout Standard
2404 Return contents of cell at <x>,<y>.
2405 \end_layout
2407 \begin_layout Subsection
2408 TILEMAP:set: Set tilemap cell
2409 \end_layout
2411 \begin_layout Itemize
2412 Syntax: none TILEMAP:set(number x, number y)
2413 \end_layout
2415 \begin_layout Itemize
2416 Syntax: none TILEMAP:set(number x, number y, dbitmap b)
2417 \end_layout
2419 \begin_layout Itemize
2420 Syntax: none TILEMAP:set(number x, number y, bitmap b, palette p)
2421 \end_layout
2423 \begin_layout Standard
2424 Set contents of cell at <x>,<y>.
2425  If no bitmap/dbitmap is given, cell is cleared.
2426  Otherwise specified (d)bitmap is used (with specified palette if bitmap).
2427 \end_layout
2429 \begin_layout Subsection
2430 TILEMAP:scroll: Scroll tilemap
2431 \end_layout
2433 \begin_layout Itemize
2434 Syntax: none TILEMAP:scroll(number ox, number oy)
2435 \end_layout
2437 \begin_layout Itemize
2438 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
2439  w, number h)
2440 \end_layout
2442 \begin_layout Itemize
2443 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
2444  w, number h, boolean circx, boolean circy)
2445 \end_layout
2447 \begin_layout Standard
2448 Scrolls the tilemap tiles by <ox>,<oy>.
2449  If <x>,<y>,<w>,<h> is specified, the scrolling is limited to <w>*<h> window
2450  starting at <x>,<y> (in tiles).
2451 \end_layout
2453 \begin_layout Standard
2454 If <circx> is true, the window is circular in horizontal direction.
2455  Similarly with <circy> and vertical direciton.
2456 \end_layout
2458 \begin_layout Subsection
2459 TILEMAP:draw: Draw tilemap
2460 \end_layout
2462 \begin_layout Itemize
2463 Syntax: none TILEMAP:draw(number x, number y)
2464 \end_layout
2466 \begin_layout Itemize
2467 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0)
2468 \end_layout
2470 \begin_layout Itemize
2471 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0, number
2472  w, number h)
2473 \end_layout
2475 \begin_layout Standard
2476 Draw tilemap at <x>,<y>.
2477  If <x0>,<y0> is given, that is tilemap coordinate (in pixels) of upper
2478  left edge.
2479  If <w>,<h> is given, that is the size of window to draw (in pixels)
2480 \end_layout
2482 \begin_layout Subsection
2483 gui.bitmap_save_png/(D)BITMAP:save_png: Save a bitmap to PNG
2484 \end_layout
2486 \begin_layout Itemize
2487 Syntax: none gui.bitmap_save_png(string filename[, string base], BITMAP bmp,
2488  PALETTE pal)
2489 \end_layout
2491 \begin_layout Itemize
2492 Syntax: none gui.bitmap_save_png(string filename[, string base], DBITMAP
2493  bmp)
2494 \end_layout
2496 \begin_layout Itemize
2497 Syntax: string gui.bitmap_save_png(BITMAP bmp, PALETTE pal)
2498 \end_layout
2500 \begin_layout Itemize
2501 Syntax: string gui.bitmap_save_png(DBITMAP bmp)
2502 \end_layout
2504 \begin_layout Itemize
2505 Syntax: none BITMAP:save_png(string filename[, string base], PALETTE pal)
2506 \end_layout
2508 \begin_layout Itemize
2509 Syntax: none DBITMAP:save_png(string filename[, string base])
2510 \end_layout
2512 \begin_layout Itemize
2513 Syntax: string BITMAP:save_png(PALETTE pal)
2514 \end_layout
2516 \begin_layout Itemize
2517 Syntax: string DBITMAP:save_png()
2518 \end_layout
2520 \begin_layout Standard
2521 Save specified bitmap <bmp> (or current object), with palette <pal> (only
2522  if paletted) into PNG file <filename> (relative to <base>) or return BASE64
2523  encoding as return value.
2524 \end_layout
2526 \begin_layout Subsection
2527 gui.bitmap_hash/(D)BITMAP:hash: Hash a bitmap
2528 \end_layout
2530 \begin_layout Itemize
2531 Syntax: string gui.bitmap_hash(BITMAP bmp)
2532 \end_layout
2534 \begin_layout Itemize
2535 Syntax: string gui.bitmap_hash(DBITMAP bmp)
2536 \end_layout
2538 \begin_layout Itemize
2539 Syntax: string BITMAP:hash()
2540 \end_layout
2542 \begin_layout Itemize
2543 Syntax: string DBITMAP:hash()
2544 \end_layout
2546 \begin_layout Standard
2547 Hashes bitmap <bmp> (or current object) and returns 64-hex digit crypto-strong
2548  hash.
2549  Identical bitmaps result in indentical hashes (but color order in indexed
2550  bitmaps is significant).
2551 \end_layout
2553 \begin_layout Subsection
2554 gui.palette_hash/PALETTE:hash: Hash a palette
2555 \end_layout
2557 \begin_layout Itemize
2558 Syntax: string gui.palette_hash(PALETTE pal)
2559 \end_layout
2561 \begin_layout Itemize
2562 Syntax: string PALETTE:hash(PALETTE pal)
2563 \end_layout
2565 \begin_layout Standard
2566 Hashes palette <pal> (or current object) and retruns 64-hex digit crypto-strong
2567  hash.
2568  Identical palettes result in identical hashes (fully transparent colors
2569  at end of palette don't affect the hash).
2570 \end_layout
2572 \begin_layout Standard
2573 \begin_inset Newpage pagebreak
2574 \end_inset
2577 \end_layout
2579 \begin_layout Section
2580 table input
2581 \end_layout
2583 \begin_layout Standard
2584 Input handling.
2585  Functions manipulating input are only available in on_input callback.
2586 \end_layout
2588 \begin_layout Subsection
2589 input.get: Read controller button/axis (deprecated)
2590 \end_layout
2592 \begin_layout Itemize
2593 Syntax: number input.get(number controller, number index)
2594 \end_layout
2596 \begin_layout Standard
2597 Read the specified index <index> (zero-based) from specified controller
2598  <controller> (zero-based).
2600 \end_layout
2602 \begin_layout Subsection
2603 input.set: Write controller button/axis (deprecated)
2604 \end_layout
2606 \begin_layout Itemize
2607 Syntax: none input.set(number controller, number index, number value)
2608 \end_layout
2610 \begin_layout Standard
2611 Write the specified index <index> (zero-based) from specified controller
2612  <controller> (zero-based), storing value <value>.
2613 \end_layout
2615 \begin_layout Subsection
2616 input.get2: Read controller button/axis
2617 \end_layout
2619 \begin_layout Itemize
2620 Syntax: number input.get2(number port, number controller, number index)
2621 \end_layout
2623 \begin_layout Standard
2624 Read the specified input tuple.
2625  Port 0 is system port.
2626 \end_layout
2628 \begin_layout Subsection
2629 input.set2: Write controller button/axis
2630 \end_layout
2632 \begin_layout Itemize
2633 Syntax: input.set2(number port, number controller, number index, number value)
2634 \end_layout
2636 \begin_layout Standard
2637 Write the specified input tuple.
2638  Port 0 is system port.
2639 \end_layout
2641 \begin_layout Subsection
2642 input.lcid_to_pcid2: Look up logical controller
2643 \end_layout
2645 \begin_layout Itemize
2646 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
2647 \end_layout
2649 \begin_layout Standard
2650 Look up physical pcid pair (port, controller) corresponding to specified
2651  logical controller (1-based).
2652  Returns nothing if controller does not exist.
2653 \end_layout
2655 \begin_layout Subsection
2656 input.port_type: Look up port type
2657 \end_layout
2659 \begin_layout Itemize
2660 Syntax: string input.port_type(number port)
2661 \end_layout
2663 \begin_layout Standard
2664 Return type of specified port.
2665 \end_layout
2667 \begin_layout Subsection
2668 input.controller_info: Get information about controller
2669 \end_layout
2671 \begin_layout Itemize
2672 Syntax: table input.controller_info(number port, number controller)
2673 \end_layout
2675 \begin_layout Standard
2676 Get controller info for specified controller.
2677  If controller does not exist, returns nil.
2678  Otherwise returns a table with following fields:
2679 \end_layout
2681 \begin_layout Itemize
2682 type (string): Type of the controller.
2683 \end_layout
2685 \begin_layout Itemize
2686 class (string): Class of the controller.
2687 \end_layout
2689 \begin_layout Itemize
2690 classnum (number): Number of the controller within its class (1-based)
2691 \end_layout
2693 \begin_layout Itemize
2694 lcid (number): Logical controller number of the controller.
2695 \end_layout
2697 \begin_layout Itemize
2698 button_count (number): Number of buttons on controller
2699 \end_layout
2701 \begin_layout Itemize
2702 buttons (array): Array of following info about each button:
2703 \end_layout
2705 \begin_deeper
2706 \begin_layout Itemize
2707 type (string): Type of button.
2708  Currently one of 
2709 \begin_inset Quotes eld
2710 \end_inset
2712 null
2713 \begin_inset Quotes erd
2714 \end_inset
2717 \begin_inset Quotes eld
2718 \end_inset
2720 button
2721 \begin_inset Quotes erd
2722 \end_inset
2725 \begin_inset Quotes eld
2726 \end_inset
2728 axis
2729 \begin_inset Quotes erd
2730 \end_inset
2733 \begin_inset Quotes eld
2734 \end_inset
2736 raxis
2737 \begin_inset Quotes erd
2738 \end_inset
2741 \end_layout
2743 \begin_layout Itemize
2744 name (string): Name of button.
2745 \end_layout
2747 \begin_layout Itemize
2748 symbol (string): Symbol of button.
2749  Only present for type 
2750 \begin_inset Quotes eld
2751 \end_inset
2753 button
2754 \begin_inset Quotes erd
2755 \end_inset
2758 \end_layout
2760 \begin_layout Itemize
2761 hidden (boolean): True if hidden button.
2763 \end_layout
2765 \end_deeper
2766 \begin_layout Subsection
2767 input.veto_button: Veto a button press
2768 \end_layout
2770 \begin_layout Itemize
2771 Syntax: none input.veto_button()
2772 \end_layout
2774 \begin_layout Standard
2775 Signals that the button event should be vetoed.
2776  Only valid in on_button callback.
2777 \end_layout
2779 \begin_layout Subsection
2780 input.geta: Get all buttons for controller (deprecated)
2781 \end_layout
2783 \begin_layout Itemize
2784 Syntax: (number, number...) input.geta(number controller)
2785 \end_layout
2787 \begin_layout Standard
2788 Get input state for entiere controller.
2789  Returns n return values.
2790 \end_layout
2792 \begin_layout Itemize
2793 1st return value: Bitmask: bit i is set if i:th index is nonzero
2794 \end_layout
2796 \begin_layout Itemize
2797 2nd- return value: value of i:th index.
2798 \end_layout
2800 \begin_layout Subsection
2801 input.seta: Set all buttons for controller (deprecated)
2802 \end_layout
2804 \begin_layout Itemize
2805 Syntax: none input.seta(number controller, number bitmask, number args...)
2806 \end_layout
2808 \begin_layout Standard
2809 Set state for entiere controller.
2810  args is up to N values for indices (overriding values in bitmask if specified).
2811 \end_layout
2813 \begin_layout Subsection
2814 input.controllertype: Get controller type (deprecated)
2815 \end_layout
2817 \begin_layout Itemize
2818 syntax: string input.controllertype(number controller)
2819 \end_layout
2821 \begin_layout Standard
2822 Get the type of controller as string.
2823 \end_layout
2825 \begin_layout Subsection
2826 input.reset: Execute (delayed) reset
2827 \end_layout
2829 \begin_layout Itemize
2830 Syntax: none input.reset([number cycles])
2831 \end_layout
2833 \begin_layout Standard
2834 Execute reset.
2835  If <cycles> is greater than zero, do delayed reset.
2836  0 (or no value) causes immediate reset.
2837 \end_layout
2839 \begin_layout Itemize
2840 Note: Only available with subframe flag false.
2841 \end_layout
2843 \begin_layout Subsection
2844 input.raw: Return raw input data
2845 \end_layout
2847 \begin_layout Itemize
2848 Syntax: table input.raw()
2849 \end_layout
2851 \begin_layout Standard
2852 Returns table of tables of all available keys and axes.
2853  The first table is indexed by key name (platform-dependent!), and the inner
2854  table has the following fields:
2855 \end_layout
2857 \begin_layout Itemize
2858 value: Last reported value for control
2859 \end_layout
2861 \begin_deeper
2862 \begin_layout Itemize
2863 For keys: 1 for pressed, 0 for released.
2864 \end_layout
2866 \begin_layout Itemize
2867 For axes: -32767...32767.
2868 \end_layout
2870 \begin_layout Itemize
2871 For presure-sensitive buttons: 0...32767.
2872 \end_layout
2874 \begin_layout Itemize
2875 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
2876 \end_layout
2878 \begin_layout Itemize
2879 For mouse: Coordinates relative to game area.
2880 \end_layout
2882 \end_deeper
2883 \begin_layout Itemize
2884 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
2885 \end_layout
2887 \begin_layout Subsection
2888 input.keyhook: Hook a key
2889 \end_layout
2891 \begin_layout Itemize
2892 Syntax: none input.keyhook(string key, boolean state)
2893 \end_layout
2895 \begin_layout Standard
2896 Requests that keyhook events to be sent for key <key> (<state>=true) or
2897  not sent (<state>=false).
2898 \end_layout
2900 \begin_layout Subsection
2901 input.joyget: Get controls for controller
2902 \end_layout
2904 \begin_layout Itemize
2905 Syntax: table input.joyget(number logical)
2906 \end_layout
2908 \begin_layout Standard
2909 Returns table for current controls for specified logical controller <logical>.
2910  The names of fields vary by controller type.
2911 \end_layout
2913 \begin_layout Itemize
2914 The buttons have the same name as those are referred to in other contexts
2915  in the emulator
2916 \end_layout
2918 \begin_layout Itemize
2919 The analog axes are usually 
2920 \begin_inset Quotes eld
2921 \end_inset
2923 xaxis
2924 \begin_inset Quotes erd
2925 \end_inset
2927  and 
2928 \begin_inset Quotes eld
2929 \end_inset
2931 yaxis
2932 \begin_inset Quotes erd
2933 \end_inset
2936 \end_layout
2938 \begin_layout Itemize
2939 Each field is numeric or boolean depending on axis/button.
2940 \end_layout
2942 \begin_layout Subsection
2943 input.joyset: Set controls for controller
2944 \end_layout
2946 \begin_layout Itemize
2947 Syntax: none input.joyset(number controller, table controls)
2948 \end_layout
2950 \begin_layout Standard
2951 Set the the state of specified controller to values specified in specified
2952  table.
2953 \end_layout
2955 \begin_layout Itemize
2956 Each field can be boolean or number.
2957 \end_layout
2959 \begin_layout Itemize
2960 Also, buttons allow strings, which cause value to be inverted.
2961 \end_layout
2963 \begin_layout Subsection
2964 input.lcid_to_pcid: Look up logical controller (deprecated)
2965 \end_layout
2967 \begin_layout Itemize
2968 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
2969 \end_layout
2971 \begin_layout Standard
2972 Returns the legacy pcid for controller (or false if there isn't one), followed
2973  by pcid pair.
2974  Returns nothing if controller does not exist.
2975 \end_layout
2977 \begin_layout Standard
2978 \begin_inset Newpage pagebreak
2979 \end_inset
2982 \end_layout
2984 \begin_layout Section
2985 Table keyboard
2986 \end_layout
2988 \begin_layout Standard
2989 Various keybinding-related functions
2990 \end_layout
2992 \begin_layout Subsection
2993 keyboard.bind: Bind a key
2994 \end_layout
2996 \begin_layout Itemize
2997 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
2998 \end_layout
3000 \begin_layout Standard
3001 Bind specified key with specified modifers to specified command.
3002 \end_layout
3004 \begin_layout Subsection
3005 keyboard.unbind: Unbind a key
3006 \end_layout
3008 \begin_layout Itemize
3009 Syntax: none keyboard.unbind(string mod, string mask, string key)
3010 \end_layout
3012 \begin_layout Standard
3013 Unbind specified key with specified modifers.
3014 \end_layout
3016 \begin_layout Subsection
3017 keyboard.alias: Set alias expansion
3018 \end_layout
3020 \begin_layout Itemize
3021 Syntax: none keyboard.alias(string alias, string expansion)
3022 \end_layout
3024 \begin_layout Standard
3025 Set expansion of given command.
3026 \end_layout
3028 \begin_layout Standard
3029 \begin_inset Newpage pagebreak
3030 \end_inset
3033 \end_layout
3035 \begin_layout Section
3036 Table subtitle
3037 \end_layout
3039 \begin_layout Standard
3040 Subtitle handling
3041 \end_layout
3043 \begin_layout Subsection
3044 subtitle.byindex: Look up start and length of subtitle by index
3045 \end_layout
3047 \begin_layout Itemize
3048 Syntax: (number, number) subtitle.byindex(number i)
3049 \end_layout
3051 \begin_layout Standard
3052 Read the frame and length of ith subtitle.
3053  Returns nothing if not present.
3054 \end_layout
3056 \begin_layout Subsection
3057 subtitle.set: Write a subtitle
3058 \end_layout
3060 \begin_layout Itemize
3061 Syntax: none subtitle.set(number f, number l, string txt)
3062 \end_layout
3064 \begin_layout Standard
3065 Set the text of subtitle.
3066 \end_layout
3068 \begin_layout Subsection
3069 subtitle.get: Read a subtitle
3070 \end_layout
3072 \begin_layout Itemize
3073 Syntax: string subtitle.get(number f, number l)
3074 \end_layout
3076 \begin_layout Standard
3077 Get the text of subtitle.
3078 \end_layout
3080 \begin_layout Subsection
3081 subtitle.delete: Delete a subtitle
3082 \end_layout
3084 \begin_layout Itemize
3085 Syntax: nonesubtitle.delete(number f, number l)
3086 \end_layout
3088 \begin_layout Standard
3089 Delete specified subtitle.
3090 \end_layout
3092 \begin_layout Standard
3093 \begin_inset Newpage pagebreak
3094 \end_inset
3097 \end_layout
3099 \begin_layout Section
3100 Table hostmemory
3101 \end_layout
3103 \begin_layout Standard
3104 Host memory handling (extra memory saved to savestates).
3105  Host memory starts empty.
3106 \end_layout
3108 \begin_layout Itemize
3109 Reads out of range return false.
3110 \end_layout
3112 \begin_layout Itemize
3113 Writes out of range extend the memory.
3114 \end_layout
3116 \begin_layout Subsection
3117 hostmemory.read: Read byte from host memory
3118 \end_layout
3120 \begin_layout Itemize
3121 Syntax: number hostmemory.read(number address)
3122 \end_layout
3124 \begin_layout Standard
3125 Reads byte from hostmemory slot address <address>.
3126 \end_layout
3128 \begin_layout Subsection
3129 hostmemory.write: Write byte to host memory
3130 \end_layout
3132 \begin_layout Itemize
3133 Syntax: none hostmemory.write(number address, number value)
3134 \end_layout
3136 \begin_layout Standard
3137 Writes hostmemory slot with value <value> 0-255.
3138 \end_layout
3140 \begin_layout Subsection
3141 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
3142 \end_layout
3144 \begin_layout Itemize
3145 Syntax: number hostmemory.readbyte(number address)
3146 \end_layout
3148 \begin_layout Itemize
3149 Syntax: number hostmemory.readsbyte(number address)
3150 \end_layout
3152 \begin_layout Itemize
3153 Syntax: number hostmemory.readword(number address)
3154 \end_layout
3156 \begin_layout Itemize
3157 Syntax: number hostmemory.readsword(number address)
3158 \end_layout
3160 \begin_layout Itemize
3161 Syntax: number hostmemory.readhword(number address)
3162 \end_layout
3164 \begin_layout Itemize
3165 Syntax: number hostmemory.readshword(number address)
3166 \end_layout
3168 \begin_layout Itemize
3169 Syntax: number hostmemory.readdword(number address)
3170 \end_layout
3172 \begin_layout Itemize
3173 Syntax: number hostmemory.readsdword(number address)
3174 \end_layout
3176 \begin_layout Itemize
3177 Syntax: number hostmemory.readqword(number address)
3178 \end_layout
3180 \begin_layout Itemize
3181 Syntax: number hostmemory.readsqword(number address)
3182 \end_layout
3184 \begin_layout Standard
3185 Read elements (big-endian) from given address <address>.
3186 \end_layout
3188 \begin_layout Itemize
3189 byte is 1 element
3190 \end_layout
3192 \begin_layout Itemize
3193 word is 2 elements
3194 \end_layout
3196 \begin_layout Itemize
3197 hword is 3 elements
3198 \end_layout
3200 \begin_layout Itemize
3201 dword is 4 elements
3202 \end_layout
3204 \begin_layout Itemize
3205 qword is 8 elements.
3206 \end_layout
3208 \begin_layout Itemize
3209 The 's' variants do signed read.
3210 \end_layout
3212 \begin_layout Subsection
3213 hostmemory.read{float,double}: Read from host memory
3214 \end_layout
3216 \begin_layout Itemize
3217 syntax: number hostmemory.readfloat(number address)
3218 \end_layout
3220 \begin_layout Itemize
3221 Syntax: number hostmemory.readdouble(number address)
3222 \end_layout
3224 \begin_layout Standard
3225 Read elements (big-endian) floating-pont from given address <address>.
3226 \end_layout
3228 \begin_layout Subsection
3229 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
3230 \end_layout
3232 \begin_layout Itemize
3233 Syntax: number hostmemory.writebyte(number address, number value)
3234 \end_layout
3236 \begin_layout Itemize
3237 Syntax: number hostmemory.writesbyte(number address, number value)
3238 \end_layout
3240 \begin_layout Itemize
3241 Syntax: number hostmemory.writeword(number address, number value)
3242 \end_layout
3244 \begin_layout Itemize
3245 Syntax: number hostmemory.writesword(number address, number value)
3246 \end_layout
3248 \begin_layout Itemize
3249 Syntax: number hostmemory.writehword(number address, number value)
3250 \end_layout
3252 \begin_layout Itemize
3253 Syntax: number hostmemory.writeshword(number address, number value)
3254 \end_layout
3256 \begin_layout Itemize
3257 Syntax: number hostmemory.writedword(number address, number value)
3258 \end_layout
3260 \begin_layout Itemize
3261 Syntax: number hostmemory.writesdword(number address, number value)
3262 \end_layout
3264 \begin_layout Itemize
3265 Syntax: number hostmemory.writeqword(number address, number value)
3266 \end_layout
3268 \begin_layout Itemize
3269 Syntax: number hostmemory.writesqword(number address, number value)
3270 \end_layout
3272 \begin_layout Standard
3273 Write value <value> to elements (little-endian) starting from given address
3274  <address>.
3275 \end_layout
3277 \begin_layout Itemize
3278 byte is 1 element
3279 \end_layout
3281 \begin_layout Itemize
3282 word is 2 elements
3283 \end_layout
3285 \begin_layout Itemize
3286 hword is 3 elements
3287 \end_layout
3289 \begin_layout Itemize
3290 dword is 4 elements
3291 \end_layout
3293 \begin_layout Itemize
3294 qword is 8 elements.
3295 \end_layout
3297 \begin_layout Itemize
3298 The 's' variants do signed write.
3299 \end_layout
3301 \begin_layout Subsection
3302 hostmemory.write{float,double}: Write to host memory
3303 \end_layout
3305 \begin_layout Itemize
3306 syntax: none hostmemory.readfloat(number address, number value)
3307 \end_layout
3309 \begin_layout Itemize
3310 Syntax: none hostmemory.readdouble(number address, number value)
3311 \end_layout
3313 \begin_layout Standard
3314 Write elements (big-endian) floating-pont to given address <address>, storing
3315  <value>.
3316 \end_layout
3318 \begin_layout Standard
3319 \begin_inset Newpage pagebreak
3320 \end_inset
3323 \end_layout
3325 \begin_layout Section
3326 Table movie
3327 \end_layout
3329 \begin_layout Standard
3330 Movie handling
3331 \end_layout
3333 \begin_layout Subsection
3334 movie.currentframe: Get current frame number
3335 \end_layout
3337 \begin_layout Itemize
3338 Syntax: number movie.currentframe()
3339 \end_layout
3341 \begin_layout Standard
3342 Return number of current frame.
3343 \end_layout
3345 \begin_layout Subsection
3346 movie.framecount: Get move frame count
3347 \end_layout
3349 \begin_layout Itemize
3350 Syntax: number movie.framecount()
3351 \end_layout
3353 \begin_layout Standard
3354 Return number of frames in movie.
3355 \end_layout
3357 \begin_layout Subsection
3358 movie.readonly: Is in readonly mode?
3359 \end_layout
3361 \begin_layout Itemize
3362 Syntax: boolean movie.readonly()
3363 \end_layout
3365 \begin_layout Standard
3366 Return true if in readonly mode, false if in readwrite.
3367 \end_layout
3369 \begin_layout Subsection
3370 movie.rerecords: Movie rerecord count
3371 \end_layout
3373 \begin_layout Itemize
3374 Syntax: number movie.rerecords()
3375 \end_layout
3377 \begin_layout Standard
3378 Returns the current value of rerecord count.
3379 \end_layout
3381 \begin_layout Subsection
3382 movie.set_readwrite: Set read-write mode.
3383 \end_layout
3385 \begin_layout Itemize
3386 Syntax: none movie.set_readwrite()
3387 \end_layout
3389 \begin_layout Standard
3390 Set readwrite mode (does not cause on_readwrite callback).
3391 \end_layout
3393 \begin_layout Subsection
3394 movie.frame_subframes: Count subframes in frame
3395 \end_layout
3397 \begin_layout Itemize
3398 Syntax: number movie.frame_subframes(number frame)
3399 \end_layout
3401 \begin_layout Standard
3402 Count number of subframes in specified frame <frame> (frame numbers are
3403  1-based) and return that.
3404 \end_layout
3406 \begin_layout Subsection
3407 movie.read_subframes: Read subframe data (deprecated)
3408 \end_layout
3410 \begin_layout Itemize
3411 Syntax: table movie.read_subframes(number frame, number subframe)
3412 \end_layout
3414 \begin_layout Standard
3415 Read specifed subframe in specified frame and return data as array.
3416 \end_layout
3418 \begin_layout Subsection
3419 movie.read_rtc: Read current RTC time
3420 \end_layout
3422 \begin_layout Itemize
3423 Syntax: (number, number) movie.read_rtc()
3424 \end_layout
3426 \begin_layout Standard
3427 Returns the current value of the RTC as a pair (second, subsecond).
3428 \end_layout
3430 \begin_layout Subsection
3431 movie.unsafe_rewind: Fast movie rewind to saved state
3432 \end_layout
3434 \begin_layout Itemize
3435 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
3436 \end_layout
3438 \begin_layout Standard
3439 Start setting point for unsafe rewind or jump to point of unsafe rewind.
3440 \end_layout
3442 \begin_layout Itemize
3443 If called without argument, causes emulator to start process of setting
3444  unsafe rewind point.
3445  When this has finished, callback on_set_rewind occurs, passing the rewind
3446  state to lua script.
3447 \end_layout
3449 \begin_layout Itemize
3450 If called with argument, causes emulator rewind to passed rewind point as
3451  soon as possible.
3452  Readwrite mode is implicitly activated.
3453 \end_layout
3455 \begin_layout Standard
3456 The following warnings apply to unsafe rewinding:
3457 \end_layout
3459 \begin_layout Itemize
3460 There are no safety checks against misuse (that's what 
3461 \begin_inset Quotes eld
3462 \end_inset
3464 unsafe
3465 \begin_inset Quotes erd
3466 \end_inset
3468  comes from)!
3469 \end_layout
3471 \begin_layout Itemize
3472 Only call rewind from timeline rewind point was set from.
3473 \end_layout
3475 \begin_layout Itemize
3476 Only call rewind from after the rewind point was set.
3477 \end_layout
3479 \begin_layout Subsection
3480 movie.to_rewind: Load savestate as rewind point
3481 \end_layout
3483 \begin_layout Itemize
3484 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
3485 \end_layout
3487 \begin_layout Standard
3488 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
3489  corresponding to it.
3490 \end_layout
3492 \begin_layout Itemize
3493 Note: This operation does not take emulated time.
3494 \end_layout
3496 \begin_layout Subsection
3497 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
3498 \end_layout
3500 \begin_layout Itemize
3501 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
3502 \end_layout
3504 \begin_layout Itemize
3505 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
3506 \end_layout
3508 \begin_layout Standard
3509 Copies specified movie <movie>/current object (if none or nil, the active
3510  movie) as new movie object.
3511 \end_layout
3513 \begin_layout Subsection
3514 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
3515 \end_layout
3517 \begin_layout Itemize
3518 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
3519 \end_layout
3521 \begin_layout Itemize
3522 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
3523 \end_layout
3525 \begin_layout Standard
3526 Get INPUTFRAME object corresponding to specified frame in specified movie.
3527 \end_layout
3529 \begin_layout Subsection
3530 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
3531 \end_layout
3533 \begin_layout Itemize
3534 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
3535  data)
3536 \end_layout
3538 \begin_layout Itemize
3539 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
3540 \end_layout
3542 \begin_layout Standard
3543 Set data in specified frame.
3544 \end_layout
3546 \begin_layout Itemize
3547 Note: Past can't be edited in active movie.
3548 \end_layout
3550 \begin_layout Subsection
3551 movie.get_size/INPUTMOVIE::get_size: Get size of movie
3552 \end_layout
3554 \begin_layout Itemize
3555 Syntax: integer movie.get_size([INPUTMOVIE movie])
3556 \end_layout
3558 \begin_layout Itemize
3559 Syntax: integer INPUTMOVIE::get_size()
3560 \end_layout
3562 \begin_layout Standard
3563 Return number of subframes in specified movie.
3564 \end_layout
3566 \begin_layout Subsection
3567 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
3568 \end_layout
3570 \begin_layout Itemize
3571 Syntax: number movie.count_frames([INPUTMOVIE movie])
3572 \end_layout
3574 \begin_layout Itemize
3575 Syntax: number INPUTMOVIE::count_frames()
3576 \end_layout
3578 \begin_layout Standard
3579 Return number of frames in movie.
3580 \end_layout
3582 \begin_layout Subsection
3583 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
3584 \end_layout
3586 \begin_layout Itemize
3587 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
3588 \end_layout
3590 \begin_layout Itemize
3591 Syntax: number INPUTMOVIE::find_frame(number frame)
3592 \end_layout
3594 \begin_layout Standard
3595 Returns starting subframe of given frame (frame numbers are 1-based).
3596  Returns -1 if frame number is bad.
3597 \end_layout
3599 \begin_layout Subsection
3600 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
3601 \end_layout
3603 \begin_layout Itemize
3604 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
3605 \end_layout
3607 \begin_layout Itemize
3608 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
3609 \end_layout
3611 \begin_layout Standard
3612 Return blank INPUTFRAME with frame type from specified movie.
3613 \end_layout
3615 \begin_layout Subsection
3616 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
3617 \end_layout
3619 \begin_layout Itemize
3620 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
3621 \end_layout
3623 \begin_layout Itemize
3624 Syntax: none INPUTMOVIE::append_frames(number frames)
3625 \end_layout
3627 \begin_layout Standard
3628 Append specified number <frames> of frames.
3629 \end_layout
3631 \begin_layout Subsection
3632 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
3633 \end_layout
3635 \begin_layout Itemize
3636 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
3637 \end_layout
3639 \begin_layout Itemize
3640 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
3641 \end_layout
3643 \begin_layout Standard
3644 Append specified frame <frame>.
3645  Past of current movie can't be edited.
3646 \end_layout
3648 \begin_layout Subsection
3649 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
3650 \end_layout
3652 \begin_layout Itemize
3653 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
3654 \end_layout
3656 \begin_layout Itemize
3657 Syntax: none INPUTMOVIE::truncate(number frames)
3658 \end_layout
3660 \begin_layout Standard
3661 Truncate the specified movie to specified number of frames.
3662 \end_layout
3664 \begin_layout Subsection
3665 movie.edit/INPUTMOVIE::edit: Edit a movie
3666 \end_layout
3668 \begin_layout Itemize
3669 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
3670  controller, number control, number/bool value)
3671 \end_layout
3673 \begin_layout Itemize
3674 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
3675  number control, number/bool value)
3676 \end_layout
3678 \begin_layout Standard
3679 Change specified control in specified frame in specified movie.
3680  Past can't be edited in active movie.
3681 \end_layout
3683 \begin_layout Subsection
3684 movie.copy_frames2: Copy frames between movies
3685 \end_layout
3687 \begin_layout Itemize
3688 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
3689  srcmov,] number src, number count)
3690 \end_layout
3692 \begin_layout Standard
3693 Copy specified number of frames between two movies.
3694  The copy proceeeds in forward direction.
3695 \end_layout
3697 \begin_layout Subsection
3698 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
3699 \end_layout
3701 \begin_layout Itemize
3702 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
3703  number count, bool backwards)
3704 \end_layout
3706 \begin_layout Itemize
3707 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
3708  bool backwards)
3709 \end_layout
3711 \begin_layout Standard
3712 Copy specified number of frames from one point in movie to another.
3713  If backwards is true, the copy will be done backwards.
3714 \end_layout
3716 \begin_layout Subsection
3717 movie.serialize/INPUTMOVIE::serialize: Serialize movie
3718 \end_layout
3720 \begin_layout Itemize
3721 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
3722 \end_layout
3724 \begin_layout Itemize
3725 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
3726 \end_layout
3728 \begin_layout Standard
3729 Serialize given movie into file.
3730  If binary is true, binary format (more compact and much faster) is used.
3731 \end_layout
3733 \begin_layout Subsection
3734 movie.unserialize: Unserialize movie
3735 \end_layout
3737 \begin_layout Itemize
3738 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
3739  bool binary)
3740 \end_layout
3742 \begin_layout Standard
3743 Unserialize movie from file.
3744  The given frame is used as template to decide the frame type.
3745  If binary is true, binary format is decoded (much faster).
3746 \end_layout
3748 \begin_layout Subsection
3749 movie.current_first_subframe: Return first subframe in current frame
3750 \end_layout
3752 \begin_layout Itemize
3753 Syntax: number movie.current_first_subframe()
3754 \end_layout
3756 \begin_layout Standard
3757 Returns first subframe in current frame.
3758 \end_layout
3760 \begin_layout Subsection
3761 movie.pollcounter: Return poll counter for speified control
3762 \end_layout
3764 \begin_layout Itemize
3765 Syntax: number movie.pollcounter(number port, number controller, number control)
3766 \end_layout
3768 \begin_layout Standard
3769 Returns number of times the specified control has been polled this frame.
3770 \end_layout
3772 \begin_layout Subsection
3773 INPUTFRAME::get_button: Get button
3774 \end_layout
3776 \begin_layout Itemize
3777 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
3778  control)
3779 \end_layout
3781 \begin_layout Standard
3782 Returns state of given button as boolean.
3783 \end_layout
3785 \begin_layout Subsection
3786 INPUTFRAME::get_axis: Get axis
3787 \end_layout
3789 \begin_layout Itemize
3790 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
3791  control)
3792 \end_layout
3794 \begin_layout Standard
3795 Returns state of given axis as number.
3796 \end_layout
3798 \begin_layout Subsection
3799 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
3800 \end_layout
3802 \begin_layout Itemize
3803 Syntax: none INPUTFRAME::set_button(number port, number controller, number
3804  control, number/bool value)
3805 \end_layout
3807 \begin_layout Itemize
3808 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
3809  control)
3810 \end_layout
3812 \begin_layout Standard
3813 Set the given button/axis to given value.
3814 \end_layout
3816 \begin_layout Subsection
3817 INPUTFRAME::serialize: Serialize a frame
3818 \end_layout
3820 \begin_layout Itemize
3821 Syntax: string INPUTFRAME::serialize()
3822 \end_layout
3824 \begin_layout Standard
3825 Return string representation of frame.
3826 \end_layout
3828 \begin_layout Subsection
3829 INPUTFRAME::unserialize: Unserialize a frame
3830 \end_layout
3832 \begin_layout Itemize
3833 Syntax: none INPUTFRAME::unserialize(string data)
3834 \end_layout
3836 \begin_layout Standard
3837 Set current frame from given data.
3838 \end_layout
3840 \begin_layout Subsection
3841 INPUTFRAME::get_stride: Get movie stride
3842 \end_layout
3844 \begin_layout Itemize
3845 Syntax: number INPUTFRAME::get_stride()
3846 \end_layout
3848 \begin_layout Standard
3849 Return number of bytes needed to store the input frame.
3850  Mainly useful for some debugging.
3851 \end_layout
3853 \begin_layout Standard
3854 \begin_inset Newpage pagebreak
3855 \end_inset
3858 \end_layout
3860 \begin_layout Section
3861 Table settings
3862 \end_layout
3864 \begin_layout Standard
3865 Routines for settings manipulation
3866 \end_layout
3868 \begin_layout Subsection
3869 settings.get: Get value of setting
3870 \end_layout
3872 \begin_layout Itemize
3873 Syntax: string settings.get(string name)
3874 \end_layout
3876 \begin_layout Standard
3877 Get value of setting <name>.
3878  If setting value can't be obtained, returns (nil, error message).
3879 \end_layout
3881 \begin_layout Subsection
3882 settings.set: Set value of setting
3883 \end_layout
3885 \begin_layout Itemize
3886 Syntax: none settings.set(string name, string value)
3887 \end_layout
3889 \begin_layout Standard
3890 Set value <value> of setting <name>.
3891  If setting can't be set, returns (nil, error message).
3892 \end_layout
3894 \begin_layout Standard
3895 \begin_inset Newpage pagebreak
3896 \end_inset
3899 \end_layout
3901 \begin_layout Section
3902 Table memory
3903 \end_layout
3905 \begin_layout Standard
3906 Contains various functions for managing memory
3907 \end_layout
3909 \begin_layout Subsection
3910 memory.vma_count: Count number of VMAs.
3911 \end_layout
3913 \begin_layout Itemize
3914 Syntax: number memory.vma_count()
3915 \end_layout
3917 \begin_layout Standard
3918 Returns the number of VMAs
3919 \end_layout
3921 \begin_layout Subsection
3922 memory.read_vma: Lookup VMA info by index
3923 \end_layout
3925 \begin_layout Itemize
3926 Syntax: string memory.read_vma(number index)
3927 \end_layout
3929 \begin_layout Standard
3930 Reads the specified VMA (indices start from zero).
3931  Trying to read invalid VMA gives nil.
3932  The read VMA is table with the following fields:
3933 \end_layout
3935 \begin_layout Itemize
3936 region_name (string): The readable name of the VMA
3937 \end_layout
3939 \begin_layout Itemize
3940 baseaddr (number): Base address of the VMA
3941 \end_layout
3943 \begin_layout Itemize
3944 lastaddr (number): Last address in the VMA.
3945 \end_layout
3947 \begin_layout Itemize
3948 size (number): The size of VMA in bytes.
3949 \end_layout
3951 \begin_layout Itemize
3952 readonly (boolean): True of the VMA corresponds to ROM.
3953 \end_layout
3955 \begin_layout Itemize
3956 iospace (boolean): True if the VMA is I/O space.
3957 \end_layout
3959 \begin_layout Itemize
3960 native_endian (boolean): True if the VMA has native endian as opposed to
3961  little endian.
3962 \end_layout
3964 \begin_layout Subsection
3965 memory.find_vma: Find VMA info by address
3966 \end_layout
3968 \begin_layout Itemize
3969 Syntax: table memory.find_vma(number address)
3970 \end_layout
3972 \begin_layout Standard
3973 Finds the VMA containing specified address.
3974  Returns table in the same format as read_vma or nil if not found.
3975 \end_layout
3977 \begin_layout Subsection
3978 memory.read{,s}{byte,{,h,d,q}word}: Read memory
3979 \end_layout
3981 \begin_layout Itemize
3982 Syntax: none memory.readbyte([string vma, ]number address)
3983 \end_layout
3985 \begin_layout Itemize
3986 Syntax: none memory.readword([string vma, ]number address)
3987 \end_layout
3989 \begin_layout Itemize
3990 Syntax: none memory.readhword([string vma, ]number address)
3991 \end_layout
3993 \begin_layout Itemize
3994 Syntax: none memory.readdword([string vma, ]number address)
3995 \end_layout
3997 \begin_layout Itemize
3998 Syntax: none memory.readqword([string vma, ]number address)
3999 \end_layout
4001 \begin_layout Itemize
4002 Syntax: none memory.readsbyte([string vma, ]number address)
4003 \end_layout
4005 \begin_layout Itemize
4006 Syntax: none memory.readsword([string vma, ]number address)
4007 \end_layout
4009 \begin_layout Itemize
4010 Syntax: none memory.readshword([string vma, ]number address)
4011 \end_layout
4013 \begin_layout Itemize
4014 Syntax: none memory.readsdword([string vma, ]number address)
4015 \end_layout
4017 \begin_layout Itemize
4018 Syntax: none memory.readsqword([string vma, ]number address)
4019 \end_layout
4021 \begin_layout Standard
4022 Reads the specified address <address> (if 's' variant is used, do undergo
4023  2's complement).
4024 \end_layout
4026 \begin_layout Subsection
4027 memory.{,s}read_sg: Scatter/Gather read memory
4028 \end_layout
4030 \begin_layout Itemize
4031 Syntax: none memory.read_sg(string/boolean/number...)
4032 \end_layout
4034 \begin_layout Itemize
4035 Syntax: none memory.sread_sg(string/boolean/number...)
4036 \end_layout
4038 \begin_layout Standard
4039 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
4040  of memory.
4041  Each argument can be string, boolean or number:
4042 \end_layout
4044 \begin_layout Itemize
4045 String: Set VMA addresses are relative to (e.g.
4046  'WRAM').
4047 \end_layout
4049 \begin_layout Itemize
4050 boolean: If true, increment relative address by 1, if false, decrement by
4051  1.
4052  The new address is read as next higher byte.
4053 \end_layout
4055 \begin_layout Itemize
4056 integer: Set the relative address to specified value and read the address
4057  as next higher byte.
4058 \end_layout
4060 \begin_layout Subsection
4061 memory.write_sg: Scatter/Gather write memory
4062 \end_layout
4064 \begin_layout Itemize
4065 Syntax: none memory.write_sg(number value, string/boolean/number...)
4066 \end_layout
4068 \begin_layout Standard
4069 Perform scatter/gather write of value <value> on memory.
4070  Each argument can be string, boolean or number:
4071 \end_layout
4073 \begin_layout Itemize
4074 String: Set VMA addresses are relative to (e.g.
4075  'WRAM').
4076 \end_layout
4078 \begin_layout Itemize
4079 boolean: If true, increment relative address by 1, if false, decrement by
4080  1.
4081  The new address is read as next higher byte.
4082 \end_layout
4084 \begin_layout Itemize
4085 integer: Set the relative address to specified value and read the address
4086  as next higher byte.
4087 \end_layout
4089 \begin_layout Subsection
4090 memory.read{float,double}: Read memory
4091 \end_layout
4093 \begin_layout Itemize
4094 Syntax: none memory.readfloat([string vma, ]number address)
4095 \end_layout
4097 \begin_layout Itemize
4098 Syntax: none memory.readdouble([string vma, ]number address)
4099 \end_layout
4101 \begin_layout Standard
4102 Reads the specified address <address>
4103 \end_layout
4105 \begin_layout Subsection
4106 memory.write{byte,{,h,d,q}word,float,double}: Write memory
4107 \end_layout
4109 \begin_layout Itemize
4110 Syntax: none memory.writebyte([string vma, ]number address, number value)
4111 \end_layout
4113 \begin_layout Itemize
4114 Syntax: none memory.writeword([string vma, ]number address, number value)
4115 \end_layout
4117 \begin_layout Itemize
4118 Syntax: none memory.writehword([string vma, ]number address, number value)
4119 \end_layout
4121 \begin_layout Itemize
4122 Syntax: none memory.writedword([string vma, ]number address, number value)
4123 \end_layout
4125 \begin_layout Itemize
4126 Syntax: none memory.writeqword([string vma, ]number address, number value)
4127 \end_layout
4129 \begin_layout Itemize
4130 Syntax: none memory.writefloat([string vma, ]number address, number value)
4131 \end_layout
4133 \begin_layout Itemize
4134 Syntax: none memory.writedouble([string vma, ]number address, number value)
4135 \end_layout
4137 \begin_layout Standard
4138 Writes the specified value <value> (negative integer values undergo 2's
4139  complement) to specified address <address>.
4140 \end_layout
4142 \begin_layout Subsection
4143 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
4144 \end_layout
4146 \begin_layout Itemize
4147 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
4148 \end_layout
4150 \begin_layout Standard
4151 Returns a table mapping specified memory aperture for read/write.
4152  If parameters are omitted, entiere map space is the aperture.
4153 \end_layout
4155 \begin_layout Itemize
4156 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
4157  qword, sqword, float or double.
4158 \end_layout
4160 \begin_layout Subsection
4161 memory.hash_region: Hash region of memory
4162 \end_layout
4164 \begin_layout Itemize
4165 Syntax: string memory.hash_region([string vma, ]number base, number size)
4166 \end_layout
4168 \begin_layout Standard
4169 Hash specified number of bytes starting from specified address and return
4170  the SHA-256.
4171 \end_layout
4173 \begin_layout Subsection
4174 memory.hash_state: Hash system state
4175 \end_layout
4177 \begin_layout Itemize
4178 Syntax: string memory.hash_state()
4179 \end_layout
4181 \begin_layout Standard
4182 Hash the current system state.
4183  Mainly useful for debugging savestates.
4184 \end_layout
4186 \begin_layout Subsection
4187 memory.readregion: Read region of memory
4188 \end_layout
4190 \begin_layout Itemize
4191 Syntax: table memory.readregion([string vma, ]number base, number size)
4192 \end_layout
4194 \begin_layout Standard
4195 Read a region of memory.
4196 \end_layout
4198 \begin_layout Itemize
4199 Warning: If the region crosses VMA boundary, the results are undefined.
4200 \end_layout
4202 \begin_layout Subsection
4203 memory.writeregion: Write region of memory
4204 \end_layout
4206 \begin_layout Itemize
4207 Syntax: none memory.writeregion([string vma, ]number base, number size, table
4208  data)
4209 \end_layout
4211 \begin_layout Standard
4212 Write a region of memory.
4213 \end_layout
4215 \begin_layout Itemize
4216 Warning: If the region crosses VMA boundary, the results are undefined.
4217 \end_layout
4219 \begin_layout Subsection
4220 memory.map_structure: Create mmap structure
4221 \end_layout
4223 \begin_layout Itemize
4224 syntax: MMAP_STRUCT memory.map_structure()
4225 \end_layout
4227 \begin_layout Standard
4228 Returns a new mapping structure (MMAP_STRUCT)
4229 \end_layout
4231 \begin_layout Subsection
4232 MMAP_STRUCT(): Bind key in mmap structure
4233 \end_layout
4235 \begin_layout Itemize
4236 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
4237  type)
4238 \end_layout
4240 \begin_layout Standard
4241 Bind key <key> in mmap structure to specified address <address> with specified
4242  type <type>.
4243 \end_layout
4245 \begin_layout Itemize
4246 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
4247  qword, sqword, float or double.
4248 \end_layout
4250 \begin_layout Subsection
4251 memory.read_expr: Evaluate memory watch expression
4252 \end_layout
4254 \begin_layout Itemize
4255 Syntax: string memory.read_expr(string expr)
4256 \end_layout
4258 \begin_layout Standard
4259 Evaluate specified watch expression and return result
4260 \end_layout
4262 \begin_layout Subsection
4263 memory.action: Run core action
4264 \end_layout
4266 \begin_layout Itemize
4267 memory.action(string action, [<params>])
4268 \end_layout
4270 \begin_layout Standard
4271 Run core action.
4272  The different models expect parameters as:
4273 \end_layout
4275 \begin_layout Itemize
4276 string: String
4277 \end_layout
4279 \begin_layout Itemize
4280 numeric: numeric
4281 \end_layout
4283 \begin_layout Itemize
4284 enumeration: String
4285 \end_layout
4287 \begin_layout Itemize
4288 boolean: String
4289 \end_layout
4291 \begin_layout Itemize
4292 toggle: None.
4293 \end_layout
4295 \begin_layout Subsection
4296 memory.get_lag_flag: Get lag flag
4297 \end_layout
4299 \begin_layout Itemize
4300 Syntax: boolean memory.get_lag_flag()
4301 \end_layout
4303 \begin_layout Standard
4304 Get the value of core lag flag.
4305  True if this frame has been lag so far, false if poll has been detected.
4306 \end_layout
4308 \begin_layout Subsection
4309 memory.set_lag_flag: Set lag flag
4310 \end_layout
4312 \begin_layout Itemize
4313 Syntax: none memory.set_lag_flag(boolean flag)
4314 \end_layout
4316 \begin_layout Standard
4317 Set the value of core lag flag.
4318  This flag automatically gets cleared if poll is detected, but can be forcibly
4319  set or cleared if game so requires.
4320 \end_layout
4322 \begin_layout Itemize
4323 Should only be used in on_frame_emulated callback.
4324 \end_layout
4326 \begin_layout Itemize
4327 Setting or clearing this affects the emulator lag counter.
4328 \end_layout
4330 \begin_layout Subsection
4331 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
4332  callback
4333 \end_layout
4335 \begin_layout Itemize
4336 Syntax: function memory.registerread([string vma, ] number addr, function
4337  fn);
4338 \end_layout
4340 \begin_layout Itemize
4341 Syntax: function memory.registerwrite([string vma, ] number addr, function
4342  fn);
4343 \end_layout
4345 \begin_layout Itemize
4346 Syntax: function memory.registerexec([string vma, ] number addr, function
4347  fn);
4348 \end_layout
4350 \begin_layout Itemize
4351 Syntax: none memory.unregisterread([string vma, ] number addr, function fn);
4352 \end_layout
4354 \begin_layout Itemize
4355 Syntax: none memory.unregisterwrite([string vma, ] number addr, function
4356  fn);
4357 \end_layout
4359 \begin_layout Itemize
4360 Syntax: none memory.unregisterexec([string vma, ] number addr, function fn);
4361 \end_layout
4363 \begin_layout Standard
4364 Add or remove callback on memory read, write or execute (depending on the
4365  function).
4366  If <vma> is specified, <addr> is relative to it, otherwise <addr> is global.
4367  <fn> is the callback.
4368  The register* functions return <fn> (which can then be passed to unregister*
4369  functions.
4370 \end_layout
4372 \begin_layout Itemize
4373 Not all cores support this, and it may be unsupported for some VMAs.
4374 \end_layout
4376 \begin_layout Itemize
4377 The functions are passed two parameters: Address and value.
4378 \end_layout
4380 \begin_layout Subsection
4381 memory.{,un}registertrace: Set/Clear trace hook
4382 \end_layout
4384 \begin_layout Itemize
4385 Syntax: function memory.registertrace(number processor, function fn);
4386 \end_layout
4388 \begin_layout Itemize
4389 Syntax: none memory.unregistertrace(number processor, function fn);
4390 \end_layout
4392 \begin_layout Standard
4393 Add or remove trace callback.
4394  <processor> is system-dependent processor number (0 is usually main CPU).
4395  The function arguments work like in other (un)register* functions.
4396 \end_layout
4398 \begin_layout Itemize
4399 The functions are passed two parameters: Trace CPU and Trace event string.
4400 \end_layout
4402 \begin_layout Subsection
4403 memory.cheat: Set cheat
4404 \end_layout
4406 \begin_layout Itemize
4407 Syntax: none memory.cheat([string vma, ] number addr, number value);
4408 \end_layout
4410 \begin_layout Itemize
4411 Syntax: none memory.cheat([string vma, ] number addr);
4412 \end_layout
4414 \begin_layout Standard
4415 Set or clear cheat (value <value>) on address <addr>.
4416  If <vma> is specified, <addr> is relative to that.
4417  If <value> is not speicified, clear a cheat.
4418 \end_layout
4420 \begin_layout Itemize
4421 Not all cores support this, and it may be unsupported for some VMAs.
4422 \end_layout
4424 \begin_layout Subsection
4425 memory.setxmask: Set global execute hook mask
4426 \end_layout
4428 \begin_layout Itemize
4429 Syntax: none memory.setxmask(number mask)
4430 \end_layout
4432 \begin_layout Standard
4433 Set the global execute hook mask to <mask>.
4434  The meaning of each bit is system-dependent, but bit 0 should be the main
4435  CPU.
4436 \end_layout
4438 \begin_layout Standard
4439 \begin_inset Newpage pagebreak
4440 \end_inset
4443 \end_layout
4445 \begin_layout Section
4446 Table memory2
4447 \end_layout
4449 \begin_layout Standard
4450 Contains newer memory functions.
4451 \end_layout
4453 \begin_layout Subsection
4454 memory2(): Get all VMA names.
4455 \end_layout
4457 \begin_layout Itemize
4458 Syntax: table memory2()
4459 \end_layout
4461 \begin_layout Standard
4462 Returns array of all valid VMA names.
4463 \end_layout
4465 \begin_layout Subsection
4466 memory2.<vma>:info: Get VMA info
4467 \end_layout
4469 \begin_layout Itemize
4470 Syntax: table memory2.<vma>:info()
4471 \end_layout
4473 \begin_layout Standard
4474 Return table describing given VMA.
4475  Includes fields address, size, last, readonly, special and endian.
4476 \end_layout
4478 \begin_layout Subsection
4479 memory2.<vma>:<op>: Read/Write memory
4480 \end_layout
4482 \begin_layout Itemize
4483 Syntax: none memory2.<vma>:<op>(number offset, number value)
4484 \end_layout
4486 \begin_layout Itemize
4487 Syntax: number memory2.<vma>:<op>(number offset)
4488 \end_layout
4490 \begin_layout Standard
4491 Read/Write value from/to given VMA <vma> at given offset <offset> (must
4492  be in-range).
4493  The value written is <value>.
4494  <Op> is of form: [i][s]<type>, where:
4495 \end_layout
4497 \begin_layout Itemize
4498 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4499 \end_layout
4501 \begin_layout Itemize
4502 'i' signifies that the value is treated as opposite-to-normal endianess,
4503 \end_layout
4505 \begin_layout Itemize
4506 's' signifies that value is treated as signed (not available for floating-point).
4507 \end_layout
4509 \begin_layout Subsection
4510 memory2.<vma>:read: Scatter-gather value read
4511 \end_layout
4513 \begin_layout Itemize
4514 Syntax: number memory2.<vma>:read(number addr...)
4515 \end_layout
4517 \begin_layout Standard
4518 Read value from given VMA <vma> at byte offsets <addr>..., given in order of
4519  increasing significance.
4520  Value of true and false are special.
4521  True increments address by 1, and false decrements address by 1.
4522 \end_layout
4524 \begin_layout Subsection
4525 memory2.<vma>:sread: Signed scatter-gather value read
4526 \end_layout
4528 \begin_layout Itemize
4529 Syntax: number memory2.<vma>:sread(number addr...)
4530 \end_layout
4532 \begin_layout Standard
4533 Like memory2.<vma>:read, but reads signed values.
4534 \end_layout
4536 \begin_layout Subsection
4537 memory2.<vma>:write: Scatter-gather value write
4538 \end_layout
4540 \begin_layout Itemize
4541 Syntax: number memory2.<vma>:write(number val, number addr...)
4542 \end_layout
4544 \begin_layout Standard
4545 Write value <val> to given VMA <vma> at byte offsets <addr>..., given in order
4546  of increasing significance.
4547  Value of true and false are special.
4548  True increments address by 1, and false decrements address by 1.
4549 \end_layout
4551 \begin_layout Standard
4552 \begin_inset Newpage pagebreak
4553 \end_inset
4556 \end_layout
4558 \begin_layout Section
4559 Table random
4560 \end_layout
4562 \begin_layout Standard
4563 Contains random number generation methods.
4564  These functions do not return reproducable results.
4565 \end_layout
4567 \begin_layout Subsection
4568 random.boolean: Random boolean
4569 \end_layout
4571 \begin_layout Itemize
4572 Syntax: boolean random.boolean()
4573 \end_layout
4575 \begin_layout Standard
4576 Returns true or false at random (50-50 chance).
4577 \end_layout
4579 \begin_layout Subsection
4580 random.integer: Random integer
4581 \end_layout
4583 \begin_layout Itemize
4584 Syntax: number random.integer(number highplusone)
4585 \end_layout
4587 \begin_layout Itemize
4588 Syntax: number random.integer(number low, number high)
4589 \end_layout
4591 \begin_layout Standard
4592 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
4593  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
4594 \end_layout
4596 \begin_layout Standard
4597 The returned numbers are from uniform distribution.
4598 \end_layout
4600 \begin_layout Subsection
4601 random.float: Random float
4602 \end_layout
4604 \begin_layout Itemize
4605 Syntax: number random.float()
4606 \end_layout
4608 \begin_layout Standard
4609 Returns random decimal number [0,1).
4610 \end_layout
4612 \begin_layout Subsection
4613 random.among: Random parameter
4614 \end_layout
4616 \begin_layout Itemize
4617 Syntax: value random.among(value values...)
4618 \end_layout
4620 \begin_layout Standard
4621 Returns random parameter value, picked at uniform.
4622  Multiple equivalent values are returned with higher chance.
4623 \end_layout
4625 \begin_layout Subsection
4626 random.amongtable: Random from table
4627 \end_layout
4629 \begin_layout Itemize
4630 Syntax: value random.amongtable(table tab)
4631 \end_layout
4633 \begin_layout Standard
4634 Returns random value from table <tab>.
4635  As in random.among, no equality testing is done.
4636 \end_layout
4638 \begin_layout Standard
4639 \begin_inset Newpage pagebreak
4640 \end_inset
4643 \end_layout
4645 \begin_layout Section
4646 Table zip
4647 \end_layout
4649 \begin_layout Subsection
4650 zip.create: Create a new zipfile
4651 \end_layout
4653 \begin_layout Itemize
4654 Syntax: ZIPWRITER zip.create(string filename[, number compression])
4655 \end_layout
4657 \begin_layout Standard
4658 Creates a new zipfile <filename>, with specified compression level <compression>
4659  (default 9).
4660 \end_layout
4662 \begin_layout Subsection
4663 zip.enumerate: Enumerate members in zipfile
4664 \end_layout
4666 \begin_layout Itemize
4667 Syntax: Table zip.enumerate(string filename[, boolean invert])
4668 \end_layout
4670 \begin_layout Standard
4671 Returns table of files in zip archive <filename>.
4672  If <invert> is true, instead of returning array of names, returns table
4673  with keys being member names and values being true.
4674 \end_layout
4676 \begin_layout Subsection
4677 ZIPWRITER:commit: Finish creating ZIP file.
4678 \end_layout
4680 \begin_layout Itemize
4681 Syntax: none ZIPWRITER:commit()
4682 \end_layout
4684 \begin_layout Standard
4685 Closes the ZIP archive.
4686  Nothing more can be written.
4687 \end_layout
4689 \begin_layout Subsection
4690 ZIPWRITER:rollback: Delete the ZIP file being creted
4691 \end_layout
4693 \begin_layout Itemize
4694 Syntax: none ZIPWRITER:rollback()
4695 \end_layout
4697 \begin_layout Standard
4698 Deletes the newly written ZIP archive.
4699  Nothing more can be written.
4700 \end_layout
4702 \begin_layout Subsection
4703 ZIPWRITER:create_file: Start writing a new member
4704 \end_layout
4706 \begin_layout Itemize
4707 Syntax: none ZIPWRITER:create_file(string filename)
4708 \end_layout
4710 \begin_layout Standard
4711 Starts writing a new member <filename> in ZIP file.
4712  If member is open, it is closed.
4713 \end_layout
4715 \begin_layout Subsection
4716 ZIPWRITER:close_file: Close member
4717 \end_layout
4719 \begin_layout Itemize
4720 Syntax: none ZIPWRITER:close_file()
4721 \end_layout
4723 \begin_layout Standard
4724 Closes member in ZIP file.
4725 \end_layout
4727 \begin_layout Subsection
4728 ZIPWRITER:write: Write data
4729 \end_layout
4731 \begin_layout Itemize
4732 Syntax none ZIPWRITER:write(string data)
4733 \end_layout
4735 \begin_layout Standard
4736 Writes data <data> into ZIP file (binary mode).
4737 \end_layout
4739 \begin_layout Standard
4740 \begin_inset Newpage pagebreak
4741 \end_inset
4744 \end_layout
4746 \begin_layout Section
4747 Table callback
4748 \end_layout
4750 \begin_layout Standard
4751 Various callback-related functions.
4752 \end_layout
4754 \begin_layout Subsection
4755 \begin_inset CommandInset label
4756 LatexCommand label
4757 name "sub:callback.register:-Register-a"
4759 \end_inset
4761 callback.register: Register a callback
4762 \end_layout
4764 \begin_layout Itemize
4765 Syntax: function callback.register(string cbname, function cbfun);
4766 \end_layout
4768 \begin_layout Standard
4769 Instruct function <cbfun> to be added to list of callbacks to call on event
4770  <cbname> (See section 
4771 \begin_inset CommandInset ref
4772 LatexCommand ref
4773 reference "sec:Callbacks"
4775 \end_inset
4778  The callback name does not have the 'on_' prefix (e.g.
4780 \begin_inset Quotes eld
4781 \end_inset
4783 paint
4784 \begin_inset Quotes erd
4785 \end_inset
4788  Returns <cbfun>.
4789 \end_layout
4791 \begin_layout Subsection
4792 \begin_inset CommandInset label
4793 LatexCommand label
4794 name "sub:callback.unregister:-Unregister-"
4796 \end_inset
4798 callback.unregister: Unregister a callback
4799 \end_layout
4801 \begin_layout Itemize
4802 Syntax: function callback.unregister(string cbname, function cbfun);
4803 \end_layout
4805 \begin_layout Standard
4806 Instruct function <cbfun> to be removed from list of callbacks to call on
4807  event <cbname>.
4808 \end_layout
4810 \begin_layout Subsection
4811 callback.<cbname>:register: Register callback
4812 \end_layout
4814 \begin_layout Itemize
4815 Syntax: function callback.<cbname>:register(function cbfun)
4816 \end_layout
4818 \begin_layout Standard
4819 Synonym for callback.register (section 
4820 \begin_inset CommandInset ref
4821 LatexCommand ref
4822 reference "sub:callback.register:-Register-a"
4824 \end_inset
4826 ), albeit with callback name specified differently.
4827 \end_layout
4829 \begin_layout Subsection
4830 callback.<cbname>:unregister: Register callback
4831 \end_layout
4833 \begin_layout Itemize
4834 Syntax: function callback.<cbname>:unregister(function cbfun)
4835 \end_layout
4837 \begin_layout Standard
4838 Synonym for callback.unregister (section 
4839 \begin_inset CommandInset ref
4840 LatexCommand ref
4841 reference "sub:callback.unregister:-Unregister-"
4843 \end_inset
4845 ), albeit with callback name specified differently.
4846 \end_layout
4848 \begin_layout Section
4849 table bsnes
4850 \end_layout
4852 \begin_layout Standard
4853 Various bsnes-specific functions.
4854 \end_layout
4856 \begin_layout Subsection
4857 bsnes.dump_sprite: Dump a sprite
4858 \end_layout
4860 \begin_layout Itemize
4861 Syntax: BITMAP bsnes.dump_sprite([string vma, ] number addr, number width,
4862  number height[, number stride])
4863 \end_layout
4865 \begin_layout Standard
4866 Dumps given sprite (in native format) from memory.
4867  VMA is usually 
4868 \begin_inset Quotes eld
4869 \end_inset
4871 VRAM
4872 \begin_inset Quotes erd
4873 \end_inset
4876  <Width> and <height> are given in 8x8 blocks.
4877  <Stride> overrides row stride (default 512).
4878 \end_layout
4880 \begin_layout Subsection
4881 bsnes.dump_palette: Dump a palette
4882 \end_layout
4884 \begin_layout Itemize
4885 Syntax: PALETTE bsnes.dump_palette([string vma, ] number addr, bool full256,
4886  bool first_trans)
4887 \end_layout
4889 \begin_layout Standard
4890 Dumps a palette from memory.
4891  VMA is usually 
4892 \begin_inset Quotes eld
4893 \end_inset
4895 CGRAM
4896 \begin_inset Quotes erd
4897 \end_inset
4900  If <full256> is true, 256 colors are dumped (otherwise 16).
4901  If <first_trans> is true, first color is forced transparent.
4902 \end_layout
4904 \begin_layout Section
4905 extensions to table string
4906 \end_layout
4908 \begin_layout Subsection
4909 string.charU: string.char, UTF-8 version.
4910 \end_layout
4912 \begin_layout Itemize
4913 Syntax: string string.charU(number n...)
4914 \end_layout
4916 \begin_layout Standard
4917 Like Lua string.char(), but works in terms of Unicode codepoints.
4918  The returned string is UTF-8.
4919 \end_layout
4921 \begin_layout Subsection
4922 string.byteU: string.byte, UTF-8 version.
4923 \end_layout
4925 \begin_layout Itemize
4926 Syntax: number...
4927  string.byteU(string str[, number i[, number j]])
4928 \end_layout
4930 \begin_layout Standard
4931 Like string.byte(), but works in terms of Unicode codepoints.
4932  The input string <str> is assumed UTF-8.
4933 \end_layout
4935 \begin_layout Section
4936 Table _SYSTEM
4937 \end_layout
4939 \begin_layout Standard
4940 Contains copy of global variables from time of Lua initialization.
4941  Non-writeable.
4942 \end_layout
4944 \begin_layout Standard
4945 \begin_inset Newpage pagebreak
4946 \end_inset
4949 \end_layout
4951 \begin_layout Section
4952 \begin_inset CommandInset label
4953 LatexCommand label
4954 name "sec:Callbacks"
4956 \end_inset
4958 Callbacks
4959 \end_layout
4961 \begin_layout Standard
4962 Various callbacks to Lua that can occur.
4963 \end_layout
4965 \begin_layout Subsection
4966 on_paint: Screen is being painted
4967 \end_layout
4969 \begin_layout Itemize
4970 Callback: on_paint(bool not_synth)
4971 \end_layout
4973 \begin_layout Standard
4974 Called when screen is being painted.
4975  Any gui.* calls requiring graphic context draw on the screen.
4976 \end_layout
4978 \begin_layout Itemize
4979 not_synth is true if this hook is being called in response to received frame,
4980  false otherwise.
4981 \end_layout
4983 \begin_layout Subsection
4984 on_video: Dumped video frame is being painted
4985 \end_layout
4987 \begin_layout Itemize
4988 Callback: on_video()
4989 \end_layout
4991 \begin_layout Standard
4992 Called when video dump frame is being painted.
4993  Any gui.* calls requiring graphic context draw on the video.
4994 \end_layout
4996 \begin_layout Subsection
4997 on_frame_emulated: Frame emulation complete
4998 \end_layout
5000 \begin_layout Itemize
5001 Callback: on_frame_emulated()
5002 \end_layout
5004 \begin_layout Standard
5005 Called when emulating frame has completed and on_paint()/on_video() calls
5006  are about to be issued.
5007 \end_layout
5009 \begin_layout Subsection
5010 on_frame: Frame emulation starting.
5011 \end_layout
5013 \begin_layout Itemize
5014 Callback: on_frame()
5015 \end_layout
5017 \begin_layout Standard
5018 Called on each starting whole frame.
5019 \end_layout
5021 \begin_layout Subsection
5022 on_startup: Emulator startup complete
5023 \end_layout
5025 \begin_layout Itemize
5026 Callback: on_startup()
5027 \end_layout
5029 \begin_layout Standard
5030 Called when the emulator is starting (lsnes.rc and --run files has been run).
5031 \end_layout
5033 \begin_layout Subsection
5034 on_rewind: Movie rewound to beginning
5035 \end_layout
5037 \begin_layout Itemize
5038 Callback: on_rewind()
5039 \end_layout
5041 \begin_layout Standard
5042 Called when rewind movie to beginning has completed.
5043 \end_layout
5045 \begin_layout Subsection
5046 on_pre_load: Load operation is about to start
5047 \end_layout
5049 \begin_layout Itemize
5050 Callback: on_pre_load(string name)
5051 \end_layout
5053 \begin_layout Standard
5054 Called just before savestate/movie load occurs (note: loads are always delayed,
5055  so this occurs even when load was initiated by lua).
5056 \end_layout
5058 \begin_layout Subsection
5059 on_err_Load: Load failed
5060 \end_layout
5062 \begin_layout Itemize
5063 Callback: on_err_load(string name)
5064 \end_layout
5066 \begin_layout Standard
5067 Called if loadstate goes wrong.
5068 \end_layout
5070 \begin_layout Subsection
5071 on_post_load: Load completed
5072 \end_layout
5074 \begin_layout Itemize
5075 Callback: on_post_load(string name, boolean was_savestate)
5076 \end_layout
5078 \begin_layout Standard
5079 Called on successful loadstate.
5080  was_savestate gives if this was a savestate or a movie.
5081 \end_layout
5083 \begin_layout Subsection
5084 on_pre_save: Save operation is about to start
5085 \end_layout
5087 \begin_layout Itemize
5088 Callback: on_pre_save(string name, boolean is_savestate)
5089 \end_layout
5091 \begin_layout Standard
5092 Called just before savestate save occurs (note: movie saves are synchronous
5093  and won't trigger these callbacks if called from Lua).
5094 \end_layout
5096 \begin_layout Subsection
5097 on_err_save: Save failed
5098 \end_layout
5100 \begin_layout Itemize
5101 Callback: on_err_save(string name)
5102 \end_layout
5104 \begin_layout Standard
5105 Called if savestate goes wrong.
5106 \end_layout
5108 \begin_layout Subsection
5109 on_post_save: Save completed
5110 \end_layout
5112 \begin_layout Itemize
5113 Callback: on_post_save(string name, boolean is_savestate)
5114 \end_layout
5116 \begin_layout Standard
5117 Called on successful savaestate.
5118  is_savestate gives if this was a savestate or a movie.
5119 \end_layout
5121 \begin_layout Subsection
5122 on_quit: Emulator is shutting down
5123 \end_layout
5125 \begin_layout Itemize
5126 Callback: on_quit()
5127 \end_layout
5129 \begin_layout Standard
5130 Called when emulator is shutting down.
5131 \end_layout
5133 \begin_layout Subsection
5134 on_input: Polling for input
5135 \end_layout
5137 \begin_layout Standard
5138 Called when emulator is just sending input to bsnes core.
5139  Warning: This is called even in readonly mode, but the results are ignored.
5140 \end_layout
5142 \begin_layout Subsection
5143 on_reset: System has been reset
5144 \end_layout
5146 \begin_layout Itemize
5147 Callback: on_reset()
5148 \end_layout
5150 \begin_layout Standard
5151 Called when system is reset.
5152 \end_layout
5154 \begin_layout Subsection
5155 on_readwrite: Entered readwrite mode
5156 \end_layout
5158 \begin_layout Itemize
5159 Callback: on_readwrite()
5160 \end_layout
5162 \begin_layout Standard
5163 Called when moving into readwrite mode as result of 
5164 \begin_inset Quotes eld
5165 \end_inset
5167 set-rwmode
5168 \begin_inset Quotes erd
5169 \end_inset
5171  command (note: moving to rwmode by Lua won't trigger this, as per recursive
5172  entry protection).
5173 \end_layout
5175 \begin_layout Subsection
5176 on_snoop/on_snoop2: Snoop core controller reads
5177 \end_layout
5179 \begin_layout Itemize
5180 Callback: on_snoop(number port, number controller, number index, number
5181  value)
5182 \end_layout
5184 \begin_layout Itemize
5185 Callback: on_snoop2(number port, number controller, number index, number
5186  value)
5187 \end_layout
5189 \begin_layout Standard
5190 Called each time bsnes asks for input.
5191  The value is the final value to be sent to bsnes core (readonly mode, autohold
5192  and autofire have been taken into account).
5193  Might be useful when translating movies to format suitable for console
5194  verification.
5195  Note: There is no way to modify the value to be sent.
5196 \end_layout
5198 \begin_layout Itemize
5199 On_snoop2 is called instead of on_snoop if defined.
5200  Reserves port 0 for system, having first user port be port 1.
5201 \end_layout
5203 \begin_layout Subsection
5204 on_keyhook: Hooked key/axis has been moved
5205 \end_layout
5207 \begin_layout Itemize
5208 Callback: on_keyhook(string keyname, table state)
5209 \end_layout
5211 \begin_layout Standard
5212 Sent when key that has keyhook events requested changes state.
5213  Keyname is name of the key (group) and state is the state (same kind as
5214  table values in input.raw).
5215 \end_layout
5217 \begin_layout Subsection
5218 on_idle: Idle event
5219 \end_layout
5221 \begin_layout Itemize
5222 Callback: on_idle()
5223 \end_layout
5225 \begin_layout Standard
5226 Called when requested by set_idle_timeout(), the timeout has expired and
5227  emulator is waiting.
5228 \end_layout
5230 \begin_layout Subsection
5231 on_timer: Timer event
5232 \end_layout
5234 \begin_layout Itemize
5235 Callback: on_timer()
5236 \end_layout
5238 \begin_layout Standard
5239 Called when requested by set_idle_timeout() and the timeout has expired
5240  (regardless if emulator is waiting).
5241 \end_layout
5243 \begin_layout Subsection
5244 on_set_rewind: Rewind point has been set
5245 \end_layout
5247 \begin_layout Itemize
5248 Callback: on_set_rewind(UNSAFEREWIND r)
5249 \end_layout
5251 \begin_layout Standard
5252 Called when unsafe rewind object has been constructed.
5253 \end_layout
5255 \begin_layout Subsection
5256 on_pre_rewind: Rewind is about to occur
5257 \end_layout
5259 \begin_layout Itemize
5260 Callback: on_pre_rewind() 
5261 \end_layout
5263 \begin_layout Standard
5264 Called just before unsafe rewind is about to occur.
5265 \end_layout
5267 \begin_layout Subsection
5268 on_post_rewind: Rewind has occured
5269 \end_layout
5271 \begin_layout Itemize
5272 Callback: on_post_rewind() 
5273 \end_layout
5275 \begin_layout Standard
5276 Called just after unsafe rewind has occured.
5277 \end_layout
5279 \begin_layout Subsection
5280 on_button: Button has been pressed
5281 \end_layout
5283 \begin_layout Itemize
5284 Callback: on_button(number port, number controller, number index, string
5285  type)
5286 \end_layout
5288 \begin_layout Standard
5289 Called on controller button press, with following parameters:
5290 \end_layout
5292 \begin_layout Itemize
5293 port: Port number (0 is system)
5294 \end_layout
5296 \begin_layout Itemize
5297 controller: Controller within port
5298 \end_layout
5300 \begin_layout Itemize
5301 index: Index of button.
5302 \end_layout
5304 \begin_layout Itemize
5305 type: Type of event, one of:
5306 \end_layout
5308 \begin_deeper
5309 \begin_layout Itemize
5310 \begin_inset Quotes eld
5311 \end_inset
5313 pressed
5314 \begin_inset Quotes erd
5315 \end_inset
5317 : Button was pressed.
5318 \end_layout
5320 \begin_layout Itemize
5321 \begin_inset Quotes eld
5322 \end_inset
5324 released
5325 \begin_inset Quotes erd
5326 \end_inset
5328 : Button was released.
5329 \end_layout
5331 \begin_layout Itemize
5332 \begin_inset Quotes eld
5333 \end_inset
5335 hold
5336 \begin_inset Quotes erd
5337 \end_inset
5339 : Held.
5340 \end_layout
5342 \begin_layout Itemize
5343 \begin_inset Quotes eld
5344 \end_inset
5346 unhold
5347 \begin_inset Quotes erd
5348 \end_inset
5350 : Released from hold.
5351 \end_layout
5353 \begin_layout Itemize
5354 \begin_inset Quotes eld
5355 \end_inset
5357 type
5358 \begin_inset Quotes erd
5359 \end_inset
5361 : Typing input on button.
5362 \end_layout
5364 \begin_layout Itemize
5365 \begin_inset Quotes eld
5366 \end_inset
5368 untype
5369 \begin_inset Quotes erd
5370 \end_inset
5372 : Typing input undone.
5373 \end_layout
5375 \begin_layout Itemize
5376 \begin_inset Quotes eld
5377 \end_inset
5379 autofire <duty> <cycle>
5380 \begin_inset Quotes erd
5381 \end_inset
5383 : Autofire with specifie duty and cycle.
5384 \end_layout
5386 \begin_layout Itemize
5387 \begin_inset Quotes eld
5388 \end_inset
5390 autofire
5391 \begin_inset Quotes erd
5392 \end_inset
5394 : Stop autofire.
5395 \end_layout
5397 \begin_layout Itemize
5398 \begin_inset Quotes eld
5399 \end_inset
5401 analog
5402 \begin_inset Quotes erd
5403 \end_inset
5405 : Analog action on axis.
5406 \end_layout
5408 \end_deeper
5409 \begin_layout Subsection
5410 on_movie_lost: Movie data is about to be lost
5411 \end_layout
5413 \begin_layout Itemize
5414 Callback: on_movie_lost(STRING kind)
5415 \end_layout
5417 \begin_layout Standard
5418 Called just before something would happen that could lose movie data.
5419  Kind can be:
5420 \end_layout
5422 \begin_layout Itemize
5423 readwrite: Switching to readwrite mode.
5424 \end_layout
5426 \begin_layout Itemize
5427 reload: ROM is being reloaded in readwrite mode.
5428 \end_layout
5430 \begin_layout Itemize
5431 load: New movie is being loaded.
5432 \end_layout
5434 \begin_layout Itemize
5435 unsaferewind: Unsafe rewind is happening.
5436 \end_layout
5438 \begin_layout Subsection
5439 on_latch: Latch line is rising
5440 \end_layout
5442 \begin_layout Itemize
5443 Callback: on_latch(<core-dependent-parameters>)
5444 \end_layout
5446 \begin_layout Standard
5447 Called when latch line for controller is rising.
5448  Some cores may not support this.
5449 \end_layout
5451 \begin_layout Section
5452 System-dependent behaviour
5453 \end_layout
5455 \begin_layout Subsection
5456 bsnes core
5457 \end_layout
5459 \begin_layout Itemize
5460 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
5461  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
5462  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
5463 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
5464 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
5465  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
5466  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
5467  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
5468  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
5469 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
5470 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
5471  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
5472 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
5473 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
5474  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
5475 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
5476  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
5477 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
5478 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
5479 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
5480  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
5481 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
5482  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
5483  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
5484 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
5485 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
5486 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
5487  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
5488 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
5489  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
5490  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
5491  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
5492  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
5493 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
5494  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
5495 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
5496  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
5497  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
5498 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
5499  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
5500 \end_layout
5502 \begin_layout Itemize
5503 on_latch has no parameters
5504 \end_layout
5506 \begin_layout Itemize
5507 CPU 0 is S-CPU, 1 is S-SMP.
5508 \end_layout
5510 \begin_layout Itemize
5511 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
5512 \end_layout
5514 \begin_layout Itemize
5515 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
5516 {RAM,ROM}.
5517 \end_layout
5519 \begin_layout Subsection
5520 gambatte core
5521 \end_layout
5523 \begin_layout Itemize
5524 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
5525  d, e, f, h, l
5526 \end_layout
5528 \begin_layout Itemize
5529 on_latch is not supported
5530 \end_layout
5532 \begin_layout Itemize
5533 CPU 0 is main CPU.
5534 \end_layout
5536 \begin_layout Itemize
5537 Cheats are supported for ROM, SRAM and WRAM.
5538 \end_layout
5540 \begin_layout Itemize
5541 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
5542  and WRAM.
5543 \end_layout
5545 \end_body
5546 \end_document