1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
6 \use_default_options true
7 \maintain_unincluded_children false
9 \language_package default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
23 \default_output_format default
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
48 \paperorientation portrait
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
69 \paperpagestyle default
70 \tracking_changes false
80 lsnes Lua functions reference
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
103 \begin_layout Section
107 \begin_layout Standard
108 These tokens are special, and are expanded while the script is being loaded
111 \begin_layout Subsection
112 @@LUA_SCRIPT_FILENAME@@
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
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.
127 \begin_layout Section
131 \begin_layout Subsection
132 print: Print values to console
135 \begin_layout Itemize
136 Syntax: none print(value...
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.
145 \begin_layout Subsection
146 tostringx: Format a value to string
149 \begin_layout Itemize
150 Syntax: string tostringx(value val)
153 \begin_layout Standard
154 Formats value <val> like print would, and returns the result as a string.
157 \begin_layout Subsection
158 exec: Execute lsnes commands
161 \begin_layout Itemize
162 Syntax: none exec(string cmd)
165 \begin_layout Standard
166 Execute lsnes command <cmd>.
169 \begin_layout Subsection
170 utime: Get current time
173 \begin_layout Itemize
174 Syntax: (number,number) utime()
177 \begin_layout Standard
179 First is time since some epoch in seconds, the second is microseconds mod
180 10^6 since that epoch.
183 \begin_layout Subsection
184 emulator_ready: Check if emulator has been fully initialized
187 \begin_layout Itemize
188 Syntax: boolean emulator_ready()
191 \begin_layout Standard
192 Returns true if emulator has finished booting, false if not (on_startup()
193 will be issued later).
196 \begin_layout Subsection
197 set_idle_timeout: Run function after timeout when emulator is idle
200 \begin_layout Itemize
201 Syntax: none set_idle_timeout(number timeout)
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.
209 \begin_layout Subsection
210 set_timer_timeout: Run function after timeout.
213 \begin_layout Itemize
214 Syntax: none set_timer_timeout(number timeout)
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.
222 \begin_layout Subsection
223 bus_address: Look up address in system bus.
226 \begin_layout Itemize
227 Syntax: none bus_address(number bus_addr)
230 \begin_layout Standard
231 Returns virtual address corresponding to specified address on system bus.
234 \begin_layout Subsection
235 loopwrapper: Convert loop into callable function
238 \begin_layout Itemize
239 Syntax: function loopwrapper(function fun, ...)
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.
249 \begin_layout LyX-Code
250 on_paint = loopwrapper(function(wait)
254 \begin_layout LyX-Code
259 \begin_layout LyX-Code
261 \begin_inset Quotes eld
265 \begin_inset Quotes erd
271 \begin_layout LyX-Code
276 \begin_layout LyX-Code
281 \begin_layout LyX-Code
285 \begin_layout Subsection
286 list_bindings: List keybindings
289 \begin_layout Itemize
290 Syntax: table list_bindings([string cmd])
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.
299 \begin_layout Subsection
300 get_alias: Get expansion of alias
303 \begin_layout Itemize
304 Syntax: string get_alias(string aname)
307 \begin_layout Standard
308 Get expansion of given alias <aname>.
311 \begin_layout Subsection
312 set_alias: Set expansion of alias
315 \begin_layout Itemize
316 Syntax: none set_alias(string aname, string value)
319 \begin_layout Standard
320 Set expansion of given alias.
323 \begin_layout Subsection
324 create_ibind: Create invese binding
327 \begin_layout Itemize
328 Syntax: INVERSEBIND create_ibind(string name, string cmd)
331 \begin_layout Standard
332 Return object representing inverse binding with specified name <name> and
333 specified command <cmd>.
336 \begin_layout Itemize
337 Note: To create press/release commands, use aliases +foo and -foo .
340 \begin_layout Itemize
341 Note: Keep the returned object around.
344 \begin_layout Subsection
345 create_command: Create a command
348 \begin_layout Itemize
349 Syntax: COMMANDBIND create_commmand(string name, function a)
352 \begin_layout Itemize
353 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
356 \begin_layout Standard
357 Return object representing a command (pair).
360 \begin_layout Itemize
361 If only one function is specied, the command is level-sensitive, <a> is
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.
370 \begin_layout Itemize
371 All callbacks get single argument: The parameters passed.
374 \begin_layout Itemize
375 Keep the returned object around.
378 \begin_layout Subsection
379 loadfile: Load Lua script
382 \begin_layout Itemize
383 Syntax: function loadfile(string filename[, string base])
386 \begin_layout Standard
387 Load lua script from <filename>, resolved relative to <base> (if empty,
391 \begin_layout Subsection
392 dofile: Execute Lua script
395 \begin_layout Itemize
396 Syntax: function dofile(string filename[, string base])
399 \begin_layout Standard
400 Execute lua script from <filename>, resolved relative to <base> (if empty,
401 current directory) and return all return values.
404 \begin_layout Subsection
405 open_file: Open a stream
408 \begin_layout Itemize
409 Syntax: FILEREADER open_file(string filename[, string base])
412 \begin_layout Standard
413 Open file <filename>, resolved relative to <base> (if empty, current directory)
417 \begin_layout Subsection
418 FILEREADER(): Read line/bytes from stream
421 \begin_layout Itemize
422 Syntax: string/nil FILEREADER()
425 \begin_layout Itemize
426 Syntax: string/nil FILEREADER(number bytes)
429 \begin_layout Standard
430 Reads next line or <bytes> bytes from specified file handle.
431 On EOF, nil is returned.
434 \begin_layout Itemize
435 Note: The line-oriented variant reads in text mode, so CR at end of line
439 \begin_layout Subsection
440 FILEREADER:lines: Iterator to read all lines
443 \begin_layout Itemize
444 Syntax: for line in <foo>:lines() do ...
448 \begin_layout Standard
449 Iterator for reading all lines of <foo> in a loop.
452 \begin_layout Subsection
453 resolve_filename: Resolve name of file relative to another
456 \begin_layout Itemize
457 Syntax: string resolve_file(string filename, string base)
460 \begin_layout Standard
461 Resolve name of file <filename> relative to <base> and return the result.
464 \begin_layout Subsection
465 render_queue_function: Return paint function for render queue
468 \begin_layout Itemize
469 Syntax: function render_queue_function(RENDERQUEUE rq)
472 \begin_layout Standard
473 Return function that renders render queue <rq>.
476 \begin_layout Itemize
477 Handy for paint callback if one is using render queues updated in other
482 \begin_layout LyX-Code
483 handle = callback.paint:register(render_queue_function(my_rq));
486 \begin_layout Subsection
487 iconv_new: Create new character set converter
490 \begin_layout Itemize
491 Syntax: ICONV iconv_new(string from, string to)
494 \begin_layout Standard
495 Create a character set converter, converting from <from> to <to>.
498 \begin_layout Subsection
499 ICONV(): Convert string fragment from character set to another
502 \begin_layout Itemize
503 Syntax: boolean, string, (number, string) ICONV(string input)
506 \begin_layout Standard
507 Convert string fragment <input> from character set to another.
510 \begin_layout Itemize
511 If conversion is successful, returns (true, {converted-string}).
515 \begin_layout Itemize
516 If conversion was unsuccessful, returns (false, {converted-part}, {unconverted-b
518 The following errors are defined:
522 \begin_layout Itemize
523 INVALID: Invalid byte sequence in input
526 \begin_layout Itemize
527 INCOMPLETE: The input is cut of in middle of multi-byte sequence
530 \begin_layout Itemize
531 INTERNALERR: Internal errror
535 \begin_layout Subsection
536 identify_class: Identify class of object
539 \begin_layout Itemize
540 Syntax: string identify_class(userdata object)
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
550 \begin_inset Quotes erd
556 \begin_layout Subsection
557 lookup_class: Lookup class by name
560 \begin_layout Itemize
561 Syntax: classobj lookup_class(string name)
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:
570 \begin_layout Itemize
571 _static_methods: Return static method names
574 \begin_layout Itemize
575 _class_methods: Return class method names
578 \begin_layout Itemize
579 <static-function-name>: The specified static function.
582 \begin_layout Standard
583 \begin_inset Newpage pagebreak
589 \begin_layout Section
593 \begin_layout Standard
594 Bitwise logical functions and related.
597 \begin_layout Subsection
598 bit.none/bit.bnot: Bitwise none or NOT function
601 \begin_layout Itemize
602 Syntax: number bit.none(number...)
605 \begin_layout Itemize
606 Syntax: number bit.bnot(number...)
609 \begin_layout Standard
610 48-bit bitwise NOT / NONE function (set bits that are set in none of the
614 \begin_layout Subsection
615 bit.any/bit.bor: Bitwise any or OR function
618 \begin_layout Itemize
619 Syntax: number bit.any(number...)
622 \begin_layout Itemize
623 Syntax: number bit.bor(number...)
626 \begin_layout Standard
627 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
630 \begin_layout Subsection
631 bit.all/bit.band: Bitwise all or AND function
634 \begin_layout Itemize
635 Syntax: number bit.all(number...)
638 \begin_layout Itemize
639 Syntax: number bit.band(number...)
642 \begin_layout Standard
643 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
647 \begin_layout Subsection
648 bit.parity/bit.bxor: Bitwise parity or XOR function
651 \begin_layout Itemize
652 Syntax: number bit.parity(number...)
655 \begin_layout Itemize
656 Syntax: number bit.bxor(number...)
659 \begin_layout Standard
660 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
664 \begin_layout Subsection
665 bit.lrotate: Rotate a number left
668 \begin_layout Itemize
669 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
672 \begin_layout Standard
673 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
677 \begin_layout Subsection
678 bit.rrotate: Rotate a number right
681 \begin_layout Itemize
682 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
685 \begin_layout Standard
686 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
690 \begin_layout Subsection
691 bit.lshift: Shift a number left
694 \begin_layout Itemize
695 Syntax: number bit.lshift(number base[, number amount[, number bits]])
698 \begin_layout Standard
699 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
701 The new bits are filled with zeroes.
704 \begin_layout Subsection
705 bit.lrshift: Shift a number right (logical)
708 \begin_layout Itemize
709 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
712 \begin_layout Standard
713 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
715 The new bits are filled with zeroes.
718 \begin_layout Subsection
719 bit.arshift: Shift a number right (arithmetic)
722 \begin_layout Itemize
723 Syntax: number bit.arshift(number base[, number amount[, number bits]])
726 \begin_layout Standard
727 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
729 The new bits are shifted in with copy of the high bit.
732 \begin_layout Subsection
733 bit.extract: Extract/shuffle bits from number
736 \begin_layout Itemize
737 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
740 \begin_layout Standard
741 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
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).
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.
754 \begin_layout Subsection
755 bit.value: Construct number with specified bits set
758 \begin_layout Itemize
759 Syntax: number bit.value([number bit1[, number bit2,...]])
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.
768 \begin_layout Subsection
769 bit.test_any: Test if any bit is set
772 \begin_layout Itemize
773 Syntax: boolean bit.test_any(number a, number b)
776 \begin_layout Standard
777 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
780 \begin_layout Subsection
781 bit.test_all: Test if all bits are set
784 \begin_layout Itemize
785 Syntax: boolean bit.test_all(number a, number b)
788 \begin_layout Standard
789 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
792 \begin_layout Subsection
793 bit.popcount: Population count
796 \begin_layout Itemize
797 Syntax: number bit.popcount(number a)
800 \begin_layout Standard
801 Returns number of set bits in <a>.
804 \begin_layout Subsection
805 bit.clshift: Chained left shift
808 \begin_layout Itemize
809 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
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).
818 \begin_layout Subsection
819 bit.crshift: Chained right shift
822 \begin_layout Itemize
823 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
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).
832 \begin_layout Subsection
833 bit.flagdecode: Decode bitfield into flags
836 \begin_layout Itemize
837 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
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.
847 \begin_layout Itemize
848 Note: <on> defaults to '*' if empty.
851 \begin_layout Itemize
852 Note: <off> defaults to '-' if empty.
855 \begin_layout Subsection
856 bit.rflagdecode: Decode bitfield into flags
859 \begin_layout Itemize
860 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
864 \begin_layout Standard
865 Like bit.flagdecode, but outputs the string in the opposite order (most significa
869 \begin_layout Subsection
870 bit.swap{,s}{,h,d,q}word: Swap word endian
873 \begin_layout Itemize
874 Syntax: number bit.swapword(number n)
877 \begin_layout Itemize
878 Syntax: number bit.swaphword(number n)
881 \begin_layout Itemize
882 Syntax: number bit.swapdword(number n)
885 \begin_layout Itemize
886 Syntax: number bit.swapqword(number n)
889 \begin_layout Itemize
890 Syntax: number bit.swapsword(number n)
893 \begin_layout Itemize
894 Syntax: number bit.swapshword(number n)
897 \begin_layout Itemize
898 Syntax: number bit.swapsdword(number n)
901 \begin_layout Itemize
902 Syntax: number bit.swapsqword(number n)
905 \begin_layout Standard
906 Swap endianess of (un)signed integer <n>.
909 \begin_layout Standard
910 \begin_inset Newpage pagebreak
916 \begin_layout Section
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.
925 \begin_layout Itemize
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.
934 \begin_layout Itemize
935 Alpha values greater than 127 do work properly.
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.
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}.
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}.
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
1043 \begin_layout Itemize
1044 HSL colors use 8-step scales for saturation and lightness.
1047 \begin_layout Itemize
1048 Modifiers have opaqueness on percent scale (0 is transparent, 100 is fully
1052 \begin_layout Itemize
1053 Modifiers have Hue on 24-step scale (4 steps between R->Y->G->C->B->M->R).
1056 \begin_layout Itemize
1057 Modifiers have Saturation/Lightness on 16 step scale.
1060 \begin_layout Subsection
1061 gui.resolution: Get current resolution
1064 \begin_layout Itemize
1065 Syntax: (number, number) gui.resolution()
1068 \begin_layout Standard
1069 Returns 2-tuple (hresolution, vresolution).
1072 \begin_layout Subsection
1073 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
1076 \begin_layout Itemize
1077 Syntax: number gui.left_gap(number gap)
1080 \begin_layout Itemize
1081 Syntax: number gui.right_gap(number gap)
1084 \begin_layout Itemize
1085 Syntax: number gui.top_gap(number gap)
1088 \begin_layout Itemize
1089 Syntax: number gui.bottom_gap(number gap)
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.
1097 \begin_layout Subsection
1098 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
1102 \begin_layout Itemize
1103 Syntax: number gui.delta_left_gap(number dgap)
1106 \begin_layout Itemize
1107 Syntax: number gui.delta_right_gap(number dgap)
1110 \begin_layout Itemize
1111 Syntax: number gui.delta_top_gap(number dgap)
1114 \begin_layout Itemize
1115 Syntax: number gui.delta_bottom_gap(number dgap)
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).
1123 \begin_layout Subsection
1124 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
1127 \begin_layout Itemize
1128 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
1132 \begin_layout Itemize
1133 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
1137 \begin_layout Itemize
1138 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
1142 \begin_layout Itemize
1143 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
1147 \begin_layout Standard
1148 Draw specified text on the GUI (each character cell is 8 or 16 wide and
1153 \begin_layout Itemize
1154 x: X-coordinate to start the drawing from (and x-coordinate at begining
1158 \begin_layout Itemize
1159 y: Y-coordinate to start the drawing from.
1162 \begin_layout Itemize
1163 text: The text to draw.
1166 \begin_layout Itemize
1167 fgc: Text color (default is 0xFFFFFF (white))
1170 \begin_layout Itemize
1171 bgc: Background color (default is -1 (transparent))
1174 \begin_layout Standard
1175 Note: The H variants draw at double width and V variants draw at double
1179 \begin_layout Subsection
1180 gui.rectangle: Draw a rectangle
1183 \begin_layout Itemize
1184 Syntax: none gui.rectangle(number x, number y, number width, number height[,
1185 number thickness[, number outline[, number fill]]])
1188 \begin_layout Standard
1189 Draw rectangle on the GUI.
1193 \begin_layout Itemize
1194 x: X-coordinate of left edge.
1197 \begin_layout Itemize
1198 y: Y-coordinate of upper edge.
1201 \begin_layout Itemize
1202 width: Width of rectangle.
1205 \begin_layout Itemize
1206 height: Height of rectangle.
1209 \begin_layout Itemize
1210 thickness: Thickness of outline (default is 1).
1213 \begin_layout Itemize
1214 outline: Color of outline (default is 0xFFFFFF (white))
1217 \begin_layout Itemize
1218 fill: Color of fill (default is -1 (transparent))
1221 \begin_layout Subsection
1222 gui.box: Draw a 3D-effect box
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]]]])
1230 \begin_layout Standard
1231 Draw rectangle with 3D effect on the GUI.
1235 \begin_layout Itemize
1236 x: X-coordinate of left edge.
1239 \begin_layout Itemize
1240 y: Y-coordinate of upper edge.
1243 \begin_layout Itemize
1244 width: Width of rectangle.
1247 \begin_layout Itemize
1248 height: Height of rectangle.
1251 \begin_layout Itemize
1252 thickness: Thickness of outline (default is 1).
1255 \begin_layout Itemize
1256 outline1: First color of outline (default is 0xFFFFFF (white))
1259 \begin_layout Itemize
1260 outline2: First color of outline (default is 0x808080 (dark gray))
1263 \begin_layout Itemize
1264 fill: Color of fill (default is 0xC0C0C0 (light grayy))
1267 \begin_layout Subsection
1268 gui.pixel: Draw a single pixel
1271 \begin_layout Itemize
1272 Syntax: none gui.pixel(number x, number y[, number color])
1275 \begin_layout Standard
1276 Draw one pixel on the GUI.
1280 \begin_layout Itemize
1281 x: X-coordinate of the pixel
1284 \begin_layout Itemize
1285 y: Y-coordinate of the pixel
1288 \begin_layout Itemize
1289 color: Color of the pixel (default is 0xFFFFFF (white))
1292 \begin_layout Subsection
1293 gui.crosshair: Draw a crosshair
1296 \begin_layout Itemize
1297 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
1300 \begin_layout Standard
1305 \begin_layout Itemize
1306 x: X-coordinate of the crosshair
1309 \begin_layout Itemize
1310 y: Y-coordinate of the crosshair
1313 \begin_layout Itemize
1314 length: Length of the crosshair lines (default 10).
1317 \begin_layout Itemize
1318 color: Color of the crosshair (default is 0xFFFFFF (white))
1321 \begin_layout Subsection
1322 gui.line: Draw a line
1325 \begin_layout Itemize
1326 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
1330 \begin_layout Standard
1335 \begin_layout Itemize
1336 x1: X-coordinate of one end.
1339 \begin_layout Itemize
1340 y1: Y-coordinate of one end.
1343 \begin_layout Itemize
1344 x2: X-coordinate of the other end.
1347 \begin_layout Itemize
1348 y2: Y-coordinate of the other end.
1351 \begin_layout Itemize
1352 color: Color of the line (default is 0xFFFFFF (white)).
1355 \begin_layout Subsection
1356 gui.circle: Draw a (filled) circle
1359 \begin_layout Itemize
1360 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
1361 border[, number fil]]])
1364 \begin_layout Standard
1369 \begin_layout Itemize
1370 x: X-coordinate of the center
1373 \begin_layout Itemize
1374 y: Y-coordinate of the center
1377 \begin_layout Itemize
1378 r: The radius of the circle
1381 \begin_layout Itemize
1382 thick: Border thickness
1385 \begin_layout Itemize
1386 border: Border color (default is 0xFFFFFF (white))
1389 \begin_layout Itemize
1390 fill: Fill color (default is -1 (transparent)).
1393 \begin_layout Subsection
1394 gui.bitmap_draw/(D)BITMAP:draw: Draw a bitmap
1397 \begin_layout Itemize
1398 Syntax: none gui.bitmap_draw(number x, number y, BITMAP bitmap, PALETTE palette)
1401 \begin_layout Itemize
1402 Syntax: none gui.bitmap_draw(number x, number y, DBITMAP bitmap)
1405 \begin_layout Itemize
1406 Syntax: none BITMAP:draw(number x, number y, PALETTE palette)
1409 \begin_layout Itemize
1410 Syntax: none DBITMAP:draw(number x, number y)
1413 \begin_layout Standard
1414 Draw a bitmap <bitmap> (or object) on screen with specified palette <palette>
1415 (if bitmap is paletted) .
1419 \begin_layout Itemize
1420 x: X-coordinate of left edge.
1423 \begin_layout Itemize
1424 y: Y-coordinate of top edge.
1427 \begin_layout Itemize
1428 bitmap: The bitmap to draw
1431 \begin_layout Itemize
1432 palette: The palette to draw the bitmap using.
1435 \begin_layout Subsection
1436 gui.palette_new: Create a new palette
1439 \begin_layout Itemize
1440 Syntax: PALETTE gui.palette_new()
1443 \begin_layout Standard
1444 Returns a new palette (initially all transparent).
1448 \begin_layout Subsection
1449 gui.bitmap_new: Create a new bitmap
1452 \begin_layout Itemize
1453 Syntax: BITMAP/DBITMAP gui.bitmap_new(number w, number h, boolean direct[,
1457 \begin_layout Standard
1458 Returns a new bitmap/dbitmap.
1461 \begin_layout Standard
1465 \begin_layout Itemize
1466 w: The width of new bitmap
1469 \begin_layout Itemize
1470 h: The height of new bitmap
1473 \begin_layout Itemize
1474 direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
1477 \begin_layout Itemize
1478 icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
1481 \begin_layout Subsection
1482 gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
1485 \begin_layout Itemize
1486 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
1489 \begin_layout Itemize
1490 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
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
1499 \begin_layout Subsection
1500 gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
1503 \begin_layout Itemize
1504 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
1508 \begin_layout Itemize
1509 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
1512 \begin_layout Standard
1513 Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
1514 encoded content <content>.
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.
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.
1528 \begin_layout Subsection
1529 gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
1532 \begin_layout Itemize
1533 Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
1536 \begin_layout Itemize
1537 Syntax: PALETTE gui.bitmap_load_pal_str(string content)
1540 \begin_layout Standard
1541 Load a palette from file <file>(resolved relative to <base>) or string <content>.
1544 \begin_layout Itemize
1545 The kinds of lines supported:
1549 \begin_layout Itemize
1550 Blank or just whitespace: Ignored
1553 \begin_layout Itemize
1554 First non-whitespace is '#': Ignored
1557 \begin_layout Itemize
1558 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
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).
1566 \begin_layout Itemize
1567 transparent: Fully transparent color
1571 \begin_layout Subsection
1572 gui.palette_set/PALETTE:set: Set palette entry
1575 \begin_layout Itemize
1576 Syntax: none gui.palette_set(PALETTE palette, number index, number color)
1579 \begin_layout Itemize
1580 Syntax: none PALETTE:set(number index, number color)
1583 \begin_layout Standard
1584 Sets color in palette.
1588 \begin_layout Itemize
1589 palette: The palette to manipulate
1592 \begin_layout Itemize
1593 index: Index of color (0-65535).
1596 \begin_layout Itemize
1597 color: The color value.
1600 \begin_layout Subsection
1601 gui.bitmap_pset/(D)BITMAP:pset: Set pixel in bitmap
1604 \begin_layout Itemize
1605 Syntax: none gui.bitmap_pset(BITMAP/DBITMAP bitmap, number x, number y, number
1609 \begin_layout Itemize
1610 Syntax: none BITMAP:pset(number x, number y, number color)
1613 \begin_layout Itemize
1614 Syntax: none DBITMAP:pset(number x, number y, number color)
1617 \begin_layout Standard
1618 Sets specified pixel in bitmap.
1622 \begin_layout Itemize
1623 bitmap: The bitmap to manipulate
1626 \begin_layout Itemize
1627 x: The x-coordinate of the pixel.
1630 \begin_layout Itemize
1631 y: The y-coordinate of the pixel.
1634 \begin_layout Itemize
1635 color: If bitmap is a bitmap, color index (0-65535).
1636 Otherwise color value.
1639 \begin_layout Subsection
1640 gui.bitmap_pget/(D)BITMAP:pget: Get pixel in bitmap
1643 \begin_layout Itemize
1644 Syntax: number gui.bitmap_pget(BITMAP/DBITMAP bitmap, number x, number y)
1647 \begin_layout Itemize
1648 Syntax: number BITMAP:pget(number x, number y)
1651 \begin_layout Itemize
1652 Syntax: number DBITMAP:pget(number x, number y)
1655 \begin_layout Standard
1656 Gets specified pixel in bitmap.
1660 \begin_layout Itemize
1661 bitmap: The bitmap to query
1664 \begin_layout Itemize
1665 x: The x-coordinate of the pixel.
1668 \begin_layout Itemize
1669 y: The y-coordinate of the pixel.
1672 \begin_layout Standard
1673 The bitmap color (color index if paletted, otherwise color value).
1676 \begin_layout Subsection
1677 gui.bitmap_size/(D)BITMAP:size: Get size of bitmap
1680 \begin_layout Itemize
1681 Syntax: (number, number) gui.bitmap_size(BITMAP/DBITMAP bitmap)
1684 \begin_layout Itemize
1685 Syntax: (number, number) BITMAP:size()
1688 \begin_layout Itemize
1689 Syntax: (number, number) DBITMAP:size()
1692 \begin_layout Standard
1693 Get size of bitmap <bitmap>.
1694 The first return is the width, the second is the height.
1697 \begin_layout Itemize
1698 Note: Can be used anywhere.
1701 \begin_layout Subsection
1702 gui.bitmap_blit/(D)BITMAP:blit: Blit a bitmap into another
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])
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])
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])
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])
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])
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])
1735 \begin_layout Standard
1736 Blit a part of bitmap to another (current object if any is destination).
1740 \begin_layout Itemize
1741 dest: Destination to blit to.
1744 \begin_layout Itemize
1745 dx: left edge of target
1748 \begin_layout Itemize
1749 dy: Top edge of target
1752 \begin_layout Itemize
1753 src: The source to blit from.
1756 \begin_layout Itemize
1757 pal: The palette to use in blit.
1760 \begin_layout Itemize
1761 sx: left edge of source
1764 \begin_layout Itemize
1765 sy: Top edge of source
1768 \begin_layout Itemize
1772 \begin_layout Itemize
1773 h: Height of region.
1776 \begin_layout Itemize
1778 Pixels of this color are not blitted.
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.
1787 \begin_layout Itemize
1788 If source bitmap is dbitmap, this is the color value of colorkey.
1791 \begin_layout Itemize
1792 May be absent or nil for no colorkey blit.
1796 \begin_layout Subsection
1797 gui.bitmap_blit_scaled/(D)BITMAP:blit_scaled: Blit a bitmap into another
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[,
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[,
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]])
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]])
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]])
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[,
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>).
1840 \begin_layout Subsection
1841 gui.bitmap_blit_porterduff/(D)BITMAP:blit_porterduff: Blit a bitmap into
1842 another with Porter-Duff composition
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)
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)
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
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)
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)
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)
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.
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
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)
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)
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)
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,
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,
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)
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>).
1930 \begin_layout Subsection
1931 gui.bitmap_blit_priority/BITMAP:blit_priority: Blit a bitmap into another
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)
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)
1945 \begin_layout Standard
1946 Like BITMAP:blit, but copy a pixel only if source palette index is greater
1947 than destination palette index.
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
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[,
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])
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.
1971 \begin_layout Subsection
1972 gui.repaint: Arrange a repaint
1975 \begin_layout Itemize
1976 Syntax: none gui.repaint()
1979 \begin_layout Standard
1980 Request on_repaint() to happen as soon as possible.
1983 \begin_layout Subsection
1984 gui.synchronous_repaint/RENDERQUEUE:synchronous_repaint: Paint screen now
1987 \begin_layout Itemize
1988 Syntax: none gui.synchronous_repaint(RENDERQUEUE queue)
1991 \begin_layout Itemize
1992 Syntax: none RENDERQUEUE::synchronous_repaint()
1995 \begin_layout Standard
1996 Paints specified render queue on screen right there and then.
1999 \begin_layout Subsection
2000 gui.subframe_update: Enable/Disable subframe updates
2003 \begin_layout Itemize
2004 Syntax: none gui.subframe_update(boolean on)
2007 \begin_layout Standard
2008 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
2009 or not happen (<on>=false).
2012 \begin_layout Subsection
2013 gui.screenshot: Write a screenshot
2016 \begin_layout Itemize
2017 Syntax: none gui.screenshot(string filename)
2020 \begin_layout Standard
2021 Write PNG screenshot of the current frame (no drawings) to specified file
2025 \begin_layout Subsection
2026 gui.screenshot_bitmap: Write a screenshot to bitmap
2029 \begin_layout Itemize
2030 Syntax: DBITMAP gui.screenshot_bitmap()
2033 \begin_layout Standard
2034 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
2038 \begin_layout Subsection
2039 gui.color: Compose a color.
2042 \begin_layout Itemize
2043 Syntax: number gui.color(number r, number g, number b[, number a])
2046 \begin_layout Itemize
2047 Syntax: number gui.color(string c)
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
2055 The default alpha is 256.
2058 \begin_layout Standard
2059 The form taking a string returns color corresponding color name.
2062 \begin_layout Subsection
2063 gui.status: Set status variable
2066 \begin_layout Itemize
2067 Syntax: none gui.status(string name, string value)
2070 \begin_layout Standard
2072 \begin_inset Quotes eld
2076 \begin_inset Quotes erd
2079 to <value> in status area.
2082 \begin_layout Subsection
2083 gui.rainbow: Rainbow color calculation
2086 \begin_layout Itemize
2087 Syntax: number gui.rainbow(number step, number steps[, number color])
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>.
2095 \begin_layout Standard
2096 If <step> is negative, the rotation will be counterclockwise.
2099 \begin_layout Subsection
2100 gui.renderq_new: Create a render queue
2103 \begin_layout Itemize
2104 Syntax: RENDERQUEUE gui.renderq_new(number width, number height)
2107 \begin_layout Standard
2108 Create render queue with specified reported size and return it.
2111 \begin_layout Subsection
2112 gui.renderq_clear/RENDERQUEUE:clear: Clear a render queue
2115 \begin_layout Itemize
2116 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
2119 \begin_layout Itemize
2120 Syntax: none RENDERQUEUE:clear()
2123 \begin_layout Standard
2124 Clear specified render queue.
2127 \begin_layout Subsection
2128 gui.renderq_set/RENDERQUEUE:set: Change active render queue
2131 \begin_layout Itemize
2132 Syntax: none gui.renderq_set(RENDERQUEUE queue)
2135 \begin_layout Itemize
2136 Syntax: none RENDERQUEUE:set()
2139 \begin_layout Standard
2140 Switch to specified render queue.
2141 Use nil as queue to switch to default queue.
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.
2149 \begin_layout Subsection
2150 gui.renderq_run/RENDERQUEUE:run: Run render queue
2153 \begin_layout Itemize
2154 Syntax: none gui.renderq_run(RENDERQUEUE queue)
2157 \begin_layout Itemize
2158 Syntax: none RENDERQUEUE:run()
2161 \begin_layout Standard
2162 Run specified render queue, copying the objects to current render queue.
2166 \begin_layout Itemize
2167 Warning: Don't try to run the current render queue.
2170 \begin_layout Subsection
2171 RENDERQUEUE:render: Render a queue to DBITMAP
2174 \begin_layout Itemize
2175 Syntax: DBITMAP RENDERQUEUE:render()
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.
2183 \begin_layout Subsection
2184 gui.loadfont: Load a font file
2187 \begin_layout Itemize
2188 Syntax: CUSTOMFONT gui.loadfont([string filename[, string relative_to]])
2191 \begin_layout Standard
2192 Loads font from specified file (CUSTOMFONT object).
2193 If filename is not given, loads the system default font.
2196 \begin_layout Subsection
2197 gui.font_new: Return a new empty font
2200 \begin_layout Itemize
2201 Syntax: CUSTOMFONT gui.font_new()
2204 \begin_layout Standard
2205 Returns a new font with no characters.
2208 \begin_layout Subsection
2209 CUSTOMFONT(): Render text to screen
2212 \begin_layout Itemize
2213 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
2214 bgc[, number hlc]]])
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).
2224 \begin_layout Subsection
2225 CUSTOMFONT:edit: Alter glyph in font
2228 \begin_layout Itemize
2229 Syntax: none CUSTOMFONT:edit(string character, BITMAP glyph)
2232 \begin_layout Standard
2233 Alter the character <character> (UTF-8 encoded) in font to use glyph specified
2235 The conversion to monochrome is done by treating color 0 as background,
2236 and everything else as foreground.
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
2245 \begin_layout Subsection
2246 gui.adjust_transparency/DBITMAP:adjust_transparency/PALETTE:adjust_transparency:
2247 Adjust transparency of DBITMAP or PALETTE
2250 \begin_layout Itemize
2251 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
2254 \begin_layout Itemize
2255 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
2258 \begin_layout Itemize
2259 Syntax: none DBITMAP:adjust_transparency(number adj)
2262 \begin_layout Itemize
2263 Syntax: none PALETTE:adjust_transparency(number adj)
2266 \begin_layout Standard
2267 Multiply alpha channel of <obj> by <adj>/256.
2269 \begin_inset Quotes eld
2273 \begin_inset Quotes erd
2276 out of solid bitmaps.
2279 \begin_layout Subsection
2280 gui.kill_frame: Kill video frame and associated sound
2283 \begin_layout Itemize
2284 Syntax: none gui.kill_frame()
2287 \begin_layout Standard
2288 Kills the currently dumped video frame + the associated sound.
2289 Only valid in on_video callback.
2292 \begin_layout Subsection
2293 gui.set_video_scale: Set video frame scale
2296 \begin_layout Itemize
2297 Syntax: none gui.set_video_scale(number h, number v)
2300 \begin_layout Standard
2301 Sets the scale factors of current frame to <h>x<v>.
2302 Only valid in on_video callback.
2305 \begin_layout Subsection
2306 gui.arrow: Draw an arrow
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]]]]
2315 \begin_layout Standard
2316 Draws an arrow using color <color>.
2317 The tip of arrow is at (<x>, <y>).
2321 \begin_layout Enumerate
2322 <length>: The length of arrow tail.
2325 \begin_layout Enumerate
2326 <hwidth>: The width of arrow head.
2330 \begin_layout Enumerate
2331 <direction>: Direction of arrow.
2332 0 is to right, +1 rotates 45 degrees counterclockwise.
2335 \begin_layout Enumerate
2336 <fill>: If true, fill the arrow head.
2340 \begin_layout Enumerate
2341 <twidth>: Tail width.
2346 \begin_layout Enumerate
2347 <hthick>: Head thickness (only used if <fill> is false).
2348 Default is <twidth>.
2351 \begin_layout Subsection
2352 gui.tilemap: Create a tilemap
2355 \begin_layout Itemize
2356 Syntax: TILEMAP gui.tilemap(number w, number h, number bw, number bh)
2359 \begin_layout Standard
2360 Create a new tilemap of size <w>*<h>, with each cell being <bw>*<bh>.
2363 \begin_layout Subsection
2364 TILEMAP:getsize: Query tilemap size
2367 \begin_layout Itemize
2368 Syntax: number, number TILEMAP:getsize()
2371 \begin_layout Standard
2372 Return size of tilemap (width first).
2375 \begin_layout Subsection
2376 TILEMAP:getcsize: Query tilemap cell size
2379 \begin_layout Itemize
2380 Syntax: number, number TILEMAP:getcsize()
2383 \begin_layout Standard
2384 Return size of tilemap cell (width first).
2387 \begin_layout Subsection
2388 TILEMAP:get: Query tilemap cell
2391 \begin_layout Itemize
2392 Syntax: none TILEMAP:get(number x, number y)
2395 \begin_layout Itemize
2396 Syntax: dbitmap TILEMAP:get(number x, number y)
2399 \begin_layout Itemize
2400 Syntax: bitmap,palette TILEMAP:get(number x, number y)
2403 \begin_layout Standard
2404 Return contents of cell at <x>,<y>.
2407 \begin_layout Subsection
2408 TILEMAP:set: Set tilemap cell
2411 \begin_layout Itemize
2412 Syntax: none TILEMAP:set(number x, number y)
2415 \begin_layout Itemize
2416 Syntax: none TILEMAP:set(number x, number y, dbitmap b)
2419 \begin_layout Itemize
2420 Syntax: none TILEMAP:set(number x, number y, bitmap b, palette p)
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).
2429 \begin_layout Subsection
2430 TILEMAP:scroll: Scroll tilemap
2433 \begin_layout Itemize
2434 Syntax: none TILEMAP:scroll(number ox, number oy)
2437 \begin_layout Itemize
2438 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
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)
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).
2453 \begin_layout Standard
2454 If <circx> is true, the window is circular in horizontal direction.
2455 Similarly with <circy> and vertical direciton.
2458 \begin_layout Subsection
2459 TILEMAP:draw: Draw tilemap
2462 \begin_layout Itemize
2463 Syntax: none TILEMAP:draw(number x, number y)
2466 \begin_layout Itemize
2467 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0)
2470 \begin_layout Itemize
2471 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0, number
2475 \begin_layout Standard
2476 Draw tilemap at <x>,<y>.
2477 If <x0>,<y0> is given, that is tilemap coordinate (in pixels) of upper
2479 If <w>,<h> is given, that is the size of window to draw (in pixels)
2482 \begin_layout Subsection
2483 gui.bitmap_save_png/(D)BITMAP:save_png: Save a bitmap to PNG
2486 \begin_layout Itemize
2487 Syntax: none gui.bitmap_save_png(string filename[, string base], BITMAP bmp,
2491 \begin_layout Itemize
2492 Syntax: none gui.bitmap_save_png(string filename[, string base], DBITMAP
2496 \begin_layout Itemize
2497 Syntax: string gui.bitmap_save_png(BITMAP bmp, PALETTE pal)
2500 \begin_layout Itemize
2501 Syntax: string gui.bitmap_save_png(DBITMAP bmp)
2504 \begin_layout Itemize
2505 Syntax: none BITMAP:save_png(string filename[, string base], PALETTE pal)
2508 \begin_layout Itemize
2509 Syntax: none DBITMAP:save_png(string filename[, string base])
2512 \begin_layout Itemize
2513 Syntax: string BITMAP:save_png(PALETTE pal)
2516 \begin_layout Itemize
2517 Syntax: string DBITMAP:save_png()
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.
2526 \begin_layout Subsection
2527 gui.bitmap_hash/(D)BITMAP:hash: Hash a bitmap
2530 \begin_layout Itemize
2531 Syntax: string gui.bitmap_hash(BITMAP bmp)
2534 \begin_layout Itemize
2535 Syntax: string gui.bitmap_hash(DBITMAP bmp)
2538 \begin_layout Itemize
2539 Syntax: string BITMAP:hash()
2542 \begin_layout Itemize
2543 Syntax: string DBITMAP:hash()
2546 \begin_layout Standard
2547 Hashes bitmap <bmp> (or current object) and returns 64-hex digit crypto-strong
2549 Identical bitmaps result in indentical hashes (but color order in indexed
2550 bitmaps is significant).
2553 \begin_layout Subsection
2554 gui.palette_hash/PALETTE:hash: Hash a palette
2557 \begin_layout Itemize
2558 Syntax: string gui.palette_hash(PALETTE pal)
2561 \begin_layout Itemize
2562 Syntax: string PALETTE:hash(PALETTE pal)
2565 \begin_layout Standard
2566 Hashes palette <pal> (or current object) and retruns 64-hex digit crypto-strong
2568 Identical palettes result in identical hashes (fully transparent colors
2569 at end of palette don't affect the hash).
2572 \begin_layout Standard
2573 \begin_inset Newpage pagebreak
2579 \begin_layout Section
2583 \begin_layout Standard
2585 Functions manipulating input are only available in on_input callback.
2588 \begin_layout Subsection
2589 input.get: Read controller button/axis (deprecated)
2592 \begin_layout Itemize
2593 Syntax: number input.get(number controller, number index)
2596 \begin_layout Standard
2597 Read the specified index <index> (zero-based) from specified controller
2598 <controller> (zero-based).
2602 \begin_layout Subsection
2603 input.set: Write controller button/axis (deprecated)
2606 \begin_layout Itemize
2607 Syntax: none input.set(number controller, number index, number value)
2610 \begin_layout Standard
2611 Write the specified index <index> (zero-based) from specified controller
2612 <controller> (zero-based), storing value <value>.
2615 \begin_layout Subsection
2616 input.get2: Read controller button/axis
2619 \begin_layout Itemize
2620 Syntax: number input.get2(number port, number controller, number index)
2623 \begin_layout Standard
2624 Read the specified input tuple.
2625 Port 0 is system port.
2628 \begin_layout Subsection
2629 input.set2: Write controller button/axis
2632 \begin_layout Itemize
2633 Syntax: input.set2(number port, number controller, number index, number value)
2636 \begin_layout Standard
2637 Write the specified input tuple.
2638 Port 0 is system port.
2641 \begin_layout Subsection
2642 input.lcid_to_pcid2: Look up logical controller
2645 \begin_layout Itemize
2646 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
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.
2655 \begin_layout Subsection
2656 input.port_type: Look up port type
2659 \begin_layout Itemize
2660 Syntax: string input.port_type(number port)
2663 \begin_layout Standard
2664 Return type of specified port.
2667 \begin_layout Subsection
2668 input.controller_info: Get information about controller
2671 \begin_layout Itemize
2672 Syntax: table input.controller_info(number port, number controller)
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:
2681 \begin_layout Itemize
2682 type (string): Type of the controller.
2685 \begin_layout Itemize
2686 class (string): Class of the controller.
2689 \begin_layout Itemize
2690 classnum (number): Number of the controller within its class (1-based)
2693 \begin_layout Itemize
2694 lcid (number): Logical controller number of the controller.
2697 \begin_layout Itemize
2698 button_count (number): Number of buttons on controller
2701 \begin_layout Itemize
2702 buttons (array): Array of following info about each button:
2706 \begin_layout Itemize
2707 type (string): Type of button.
2709 \begin_inset Quotes eld
2713 \begin_inset Quotes erd
2717 \begin_inset Quotes eld
2721 \begin_inset Quotes erd
2725 \begin_inset Quotes eld
2729 \begin_inset Quotes erd
2733 \begin_inset Quotes eld
2737 \begin_inset Quotes erd
2743 \begin_layout Itemize
2744 name (string): Name of button.
2747 \begin_layout Itemize
2748 symbol (string): Symbol of button.
2749 Only present for type
2750 \begin_inset Quotes eld
2754 \begin_inset Quotes erd
2760 \begin_layout Itemize
2761 hidden (boolean): True if hidden button.
2766 \begin_layout Subsection
2767 input.veto_button: Veto a button press
2770 \begin_layout Itemize
2771 Syntax: none input.veto_button()
2774 \begin_layout Standard
2775 Signals that the button event should be vetoed.
2776 Only valid in on_button callback.
2779 \begin_layout Subsection
2780 input.geta: Get all buttons for controller (deprecated)
2783 \begin_layout Itemize
2784 Syntax: (number, number...) input.geta(number controller)
2787 \begin_layout Standard
2788 Get input state for entiere controller.
2789 Returns n return values.
2792 \begin_layout Itemize
2793 1st return value: Bitmask: bit i is set if i:th index is nonzero
2796 \begin_layout Itemize
2797 2nd- return value: value of i:th index.
2800 \begin_layout Subsection
2801 input.seta: Set all buttons for controller (deprecated)
2804 \begin_layout Itemize
2805 Syntax: none input.seta(number controller, number bitmask, number args...)
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).
2813 \begin_layout Subsection
2814 input.controllertype: Get controller type (deprecated)
2817 \begin_layout Itemize
2818 syntax: string input.controllertype(number controller)
2821 \begin_layout Standard
2822 Get the type of controller as string.
2825 \begin_layout Subsection
2826 input.reset: Execute (delayed) reset
2829 \begin_layout Itemize
2830 Syntax: none input.reset([number cycles])
2833 \begin_layout Standard
2835 If <cycles> is greater than zero, do delayed reset.
2836 0 (or no value) causes immediate reset.
2839 \begin_layout Itemize
2840 Note: Only available with subframe flag false.
2843 \begin_layout Subsection
2844 input.raw: Return raw input data
2847 \begin_layout Itemize
2848 Syntax: table input.raw()
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:
2857 \begin_layout Itemize
2858 value: Last reported value for control
2862 \begin_layout Itemize
2863 For keys: 1 for pressed, 0 for released.
2866 \begin_layout Itemize
2867 For axes: -32767...32767.
2870 \begin_layout Itemize
2871 For presure-sensitive buttons: 0...32767.
2874 \begin_layout Itemize
2875 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
2878 \begin_layout Itemize
2879 For mouse: Coordinates relative to game area.
2883 \begin_layout Itemize
2884 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
2887 \begin_layout Subsection
2888 input.keyhook: Hook a key
2891 \begin_layout Itemize
2892 Syntax: none input.keyhook(string key, boolean state)
2895 \begin_layout Standard
2896 Requests that keyhook events to be sent for key <key> (<state>=true) or
2897 not sent (<state>=false).
2900 \begin_layout Subsection
2901 input.joyget: Get controls for controller
2904 \begin_layout Itemize
2905 Syntax: table input.joyget(number logical)
2908 \begin_layout Standard
2909 Returns table for current controls for specified logical controller <logical>.
2910 The names of fields vary by controller type.
2913 \begin_layout Itemize
2914 The buttons have the same name as those are referred to in other contexts
2918 \begin_layout Itemize
2919 The analog axes are usually
2920 \begin_inset Quotes eld
2924 \begin_inset Quotes erd
2928 \begin_inset Quotes eld
2932 \begin_inset Quotes erd
2938 \begin_layout Itemize
2939 Each field is numeric or boolean depending on axis/button.
2942 \begin_layout Subsection
2943 input.joyset: Set controls for controller
2946 \begin_layout Itemize
2947 Syntax: none input.joyset(number controller, table controls)
2950 \begin_layout Standard
2951 Set the the state of specified controller to values specified in specified
2955 \begin_layout Itemize
2956 Each field can be boolean or number.
2959 \begin_layout Itemize
2960 Also, buttons allow strings, which cause value to be inverted.
2963 \begin_layout Subsection
2964 input.lcid_to_pcid: Look up logical controller (deprecated)
2967 \begin_layout Itemize
2968 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
2971 \begin_layout Standard
2972 Returns the legacy pcid for controller (or false if there isn't one), followed
2974 Returns nothing if controller does not exist.
2977 \begin_layout Standard
2978 \begin_inset Newpage pagebreak
2984 \begin_layout Section
2988 \begin_layout Standard
2989 Various keybinding-related functions
2992 \begin_layout Subsection
2993 keyboard.bind: Bind a key
2996 \begin_layout Itemize
2997 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
3000 \begin_layout Standard
3001 Bind specified key with specified modifers to specified command.
3004 \begin_layout Subsection
3005 keyboard.unbind: Unbind a key
3008 \begin_layout Itemize
3009 Syntax: none keyboard.unbind(string mod, string mask, string key)
3012 \begin_layout Standard
3013 Unbind specified key with specified modifers.
3016 \begin_layout Subsection
3017 keyboard.alias: Set alias expansion
3020 \begin_layout Itemize
3021 Syntax: none keyboard.alias(string alias, string expansion)
3024 \begin_layout Standard
3025 Set expansion of given command.
3028 \begin_layout Standard
3029 \begin_inset Newpage pagebreak
3035 \begin_layout Section
3039 \begin_layout Standard
3043 \begin_layout Subsection
3044 subtitle.byindex: Look up start and length of subtitle by index
3047 \begin_layout Itemize
3048 Syntax: (number, number) subtitle.byindex(number i)
3051 \begin_layout Standard
3052 Read the frame and length of ith subtitle.
3053 Returns nothing if not present.
3056 \begin_layout Subsection
3057 subtitle.set: Write a subtitle
3060 \begin_layout Itemize
3061 Syntax: none subtitle.set(number f, number l, string txt)
3064 \begin_layout Standard
3065 Set the text of subtitle.
3068 \begin_layout Subsection
3069 subtitle.get: Read a subtitle
3072 \begin_layout Itemize
3073 Syntax: string subtitle.get(number f, number l)
3076 \begin_layout Standard
3077 Get the text of subtitle.
3080 \begin_layout Subsection
3081 subtitle.delete: Delete a subtitle
3084 \begin_layout Itemize
3085 Syntax: nonesubtitle.delete(number f, number l)
3088 \begin_layout Standard
3089 Delete specified subtitle.
3092 \begin_layout Standard
3093 \begin_inset Newpage pagebreak
3099 \begin_layout Section
3103 \begin_layout Standard
3104 Host memory handling (extra memory saved to savestates).
3105 Host memory starts empty.
3108 \begin_layout Itemize
3109 Reads out of range return false.
3112 \begin_layout Itemize
3113 Writes out of range extend the memory.
3116 \begin_layout Subsection
3117 hostmemory.read: Read byte from host memory
3120 \begin_layout Itemize
3121 Syntax: number hostmemory.read(number address)
3124 \begin_layout Standard
3125 Reads byte from hostmemory slot address <address>.
3128 \begin_layout Subsection
3129 hostmemory.write: Write byte to host memory
3132 \begin_layout Itemize
3133 Syntax: none hostmemory.write(number address, number value)
3136 \begin_layout Standard
3137 Writes hostmemory slot with value <value> 0-255.
3140 \begin_layout Subsection
3141 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
3144 \begin_layout Itemize
3145 Syntax: number hostmemory.readbyte(number address)
3148 \begin_layout Itemize
3149 Syntax: number hostmemory.readsbyte(number address)
3152 \begin_layout Itemize
3153 Syntax: number hostmemory.readword(number address)
3156 \begin_layout Itemize
3157 Syntax: number hostmemory.readsword(number address)
3160 \begin_layout Itemize
3161 Syntax: number hostmemory.readhword(number address)
3164 \begin_layout Itemize
3165 Syntax: number hostmemory.readshword(number address)
3168 \begin_layout Itemize
3169 Syntax: number hostmemory.readdword(number address)
3172 \begin_layout Itemize
3173 Syntax: number hostmemory.readsdword(number address)
3176 \begin_layout Itemize
3177 Syntax: number hostmemory.readqword(number address)
3180 \begin_layout Itemize
3181 Syntax: number hostmemory.readsqword(number address)
3184 \begin_layout Standard
3185 Read elements (big-endian) from given address <address>.
3188 \begin_layout Itemize
3192 \begin_layout Itemize
3196 \begin_layout Itemize
3200 \begin_layout Itemize
3204 \begin_layout Itemize
3205 qword is 8 elements.
3208 \begin_layout Itemize
3209 The 's' variants do signed read.
3212 \begin_layout Subsection
3213 hostmemory.read{float,double}: Read from host memory
3216 \begin_layout Itemize
3217 syntax: number hostmemory.readfloat(number address)
3220 \begin_layout Itemize
3221 Syntax: number hostmemory.readdouble(number address)
3224 \begin_layout Standard
3225 Read elements (big-endian) floating-pont from given address <address>.
3228 \begin_layout Subsection
3229 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
3232 \begin_layout Itemize
3233 Syntax: number hostmemory.writebyte(number address, number value)
3236 \begin_layout Itemize
3237 Syntax: number hostmemory.writesbyte(number address, number value)
3240 \begin_layout Itemize
3241 Syntax: number hostmemory.writeword(number address, number value)
3244 \begin_layout Itemize
3245 Syntax: number hostmemory.writesword(number address, number value)
3248 \begin_layout Itemize
3249 Syntax: number hostmemory.writehword(number address, number value)
3252 \begin_layout Itemize
3253 Syntax: number hostmemory.writeshword(number address, number value)
3256 \begin_layout Itemize
3257 Syntax: number hostmemory.writedword(number address, number value)
3260 \begin_layout Itemize
3261 Syntax: number hostmemory.writesdword(number address, number value)
3264 \begin_layout Itemize
3265 Syntax: number hostmemory.writeqword(number address, number value)
3268 \begin_layout Itemize
3269 Syntax: number hostmemory.writesqword(number address, number value)
3272 \begin_layout Standard
3273 Write value <value> to elements (little-endian) starting from given address
3277 \begin_layout Itemize
3281 \begin_layout Itemize
3285 \begin_layout Itemize
3289 \begin_layout Itemize
3293 \begin_layout Itemize
3294 qword is 8 elements.
3297 \begin_layout Itemize
3298 The 's' variants do signed write.
3301 \begin_layout Subsection
3302 hostmemory.write{float,double}: Write to host memory
3305 \begin_layout Itemize
3306 syntax: none hostmemory.readfloat(number address, number value)
3309 \begin_layout Itemize
3310 Syntax: none hostmemory.readdouble(number address, number value)
3313 \begin_layout Standard
3314 Write elements (big-endian) floating-pont to given address <address>, storing
3318 \begin_layout Standard
3319 \begin_inset Newpage pagebreak
3325 \begin_layout Section
3329 \begin_layout Standard
3333 \begin_layout Subsection
3334 movie.currentframe: Get current frame number
3337 \begin_layout Itemize
3338 Syntax: number movie.currentframe()
3341 \begin_layout Standard
3342 Return number of current frame.
3345 \begin_layout Subsection
3346 movie.framecount: Get move frame count
3349 \begin_layout Itemize
3350 Syntax: number movie.framecount()
3353 \begin_layout Standard
3354 Return number of frames in movie.
3357 \begin_layout Subsection
3358 movie.readonly: Is in readonly mode?
3361 \begin_layout Itemize
3362 Syntax: boolean movie.readonly()
3365 \begin_layout Standard
3366 Return true if in readonly mode, false if in readwrite.
3369 \begin_layout Subsection
3370 movie.rerecords: Movie rerecord count
3373 \begin_layout Itemize
3374 Syntax: number movie.rerecords()
3377 \begin_layout Standard
3378 Returns the current value of rerecord count.
3381 \begin_layout Subsection
3382 movie.set_readwrite: Set read-write mode.
3385 \begin_layout Itemize
3386 Syntax: none movie.set_readwrite()
3389 \begin_layout Standard
3390 Set readwrite mode (does not cause on_readwrite callback).
3393 \begin_layout Subsection
3394 movie.frame_subframes: Count subframes in frame
3397 \begin_layout Itemize
3398 Syntax: number movie.frame_subframes(number frame)
3401 \begin_layout Standard
3402 Count number of subframes in specified frame <frame> (frame numbers are
3403 1-based) and return that.
3406 \begin_layout Subsection
3407 movie.read_subframes: Read subframe data (deprecated)
3410 \begin_layout Itemize
3411 Syntax: table movie.read_subframes(number frame, number subframe)
3414 \begin_layout Standard
3415 Read specifed subframe in specified frame and return data as array.
3418 \begin_layout Subsection
3419 movie.read_rtc: Read current RTC time
3422 \begin_layout Itemize
3423 Syntax: (number, number) movie.read_rtc()
3426 \begin_layout Standard
3427 Returns the current value of the RTC as a pair (second, subsecond).
3430 \begin_layout Subsection
3431 movie.unsafe_rewind: Fast movie rewind to saved state
3434 \begin_layout Itemize
3435 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
3438 \begin_layout Standard
3439 Start setting point for unsafe rewind or jump to point of unsafe rewind.
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.
3449 \begin_layout Itemize
3450 If called with argument, causes emulator rewind to passed rewind point as
3452 Readwrite mode is implicitly activated.
3455 \begin_layout Standard
3456 The following warnings apply to unsafe rewinding:
3459 \begin_layout Itemize
3460 There are no safety checks against misuse (that's what
3461 \begin_inset Quotes eld
3465 \begin_inset Quotes erd
3471 \begin_layout Itemize
3472 Only call rewind from timeline rewind point was set from.
3475 \begin_layout Itemize
3476 Only call rewind from after the rewind point was set.
3479 \begin_layout Subsection
3480 movie.to_rewind: Load savestate as rewind point
3483 \begin_layout Itemize
3484 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
3487 \begin_layout Standard
3488 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
3489 corresponding to it.
3492 \begin_layout Itemize
3493 Note: This operation does not take emulated time.
3496 \begin_layout Subsection
3497 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
3500 \begin_layout Itemize
3501 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
3504 \begin_layout Itemize
3505 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
3508 \begin_layout Standard
3509 Copies specified movie <movie>/current object (if none or nil, the active
3510 movie) as new movie object.
3513 \begin_layout Subsection
3514 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
3517 \begin_layout Itemize
3518 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
3521 \begin_layout Itemize
3522 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
3525 \begin_layout Standard
3526 Get INPUTFRAME object corresponding to specified frame in specified movie.
3529 \begin_layout Subsection
3530 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
3533 \begin_layout Itemize
3534 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
3538 \begin_layout Itemize
3539 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
3542 \begin_layout Standard
3543 Set data in specified frame.
3546 \begin_layout Itemize
3547 Note: Past can't be edited in active movie.
3550 \begin_layout Subsection
3551 movie.get_size/INPUTMOVIE::get_size: Get size of movie
3554 \begin_layout Itemize
3555 Syntax: integer movie.get_size([INPUTMOVIE movie])
3558 \begin_layout Itemize
3559 Syntax: integer INPUTMOVIE::get_size()
3562 \begin_layout Standard
3563 Return number of subframes in specified movie.
3566 \begin_layout Subsection
3567 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
3570 \begin_layout Itemize
3571 Syntax: number movie.count_frames([INPUTMOVIE movie])
3574 \begin_layout Itemize
3575 Syntax: number INPUTMOVIE::count_frames()
3578 \begin_layout Standard
3579 Return number of frames in movie.
3582 \begin_layout Subsection
3583 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
3586 \begin_layout Itemize
3587 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
3590 \begin_layout Itemize
3591 Syntax: number INPUTMOVIE::find_frame(number frame)
3594 \begin_layout Standard
3595 Returns starting subframe of given frame (frame numbers are 1-based).
3596 Returns -1 if frame number is bad.
3599 \begin_layout Subsection
3600 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
3603 \begin_layout Itemize
3604 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
3607 \begin_layout Itemize
3608 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
3611 \begin_layout Standard
3612 Return blank INPUTFRAME with frame type from specified movie.
3615 \begin_layout Subsection
3616 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
3619 \begin_layout Itemize
3620 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
3623 \begin_layout Itemize
3624 Syntax: none INPUTMOVIE::append_frames(number frames)
3627 \begin_layout Standard
3628 Append specified number <frames> of frames.
3631 \begin_layout Subsection
3632 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
3635 \begin_layout Itemize
3636 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
3639 \begin_layout Itemize
3640 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
3643 \begin_layout Standard
3644 Append specified frame <frame>.
3645 Past of current movie can't be edited.
3648 \begin_layout Subsection
3649 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
3652 \begin_layout Itemize
3653 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
3656 \begin_layout Itemize
3657 Syntax: none INPUTMOVIE::truncate(number frames)
3660 \begin_layout Standard
3661 Truncate the specified movie to specified number of frames.
3664 \begin_layout Subsection
3665 movie.edit/INPUTMOVIE::edit: Edit a movie
3668 \begin_layout Itemize
3669 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
3670 controller, number control, number/bool value)
3673 \begin_layout Itemize
3674 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
3675 number control, number/bool value)
3678 \begin_layout Standard
3679 Change specified control in specified frame in specified movie.
3680 Past can't be edited in active movie.
3683 \begin_layout Subsection
3684 movie.copy_frames2: Copy frames between movies
3687 \begin_layout Itemize
3688 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
3689 srcmov,] number src, number count)
3692 \begin_layout Standard
3693 Copy specified number of frames between two movies.
3694 The copy proceeeds in forward direction.
3697 \begin_layout Subsection
3698 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
3701 \begin_layout Itemize
3702 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
3703 number count, bool backwards)
3706 \begin_layout Itemize
3707 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
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.
3716 \begin_layout Subsection
3717 movie.serialize/INPUTMOVIE::serialize: Serialize movie
3720 \begin_layout Itemize
3721 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
3724 \begin_layout Itemize
3725 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
3728 \begin_layout Standard
3729 Serialize given movie into file.
3730 If binary is true, binary format (more compact and much faster) is used.
3733 \begin_layout Subsection
3734 movie.unserialize: Unserialize movie
3737 \begin_layout Itemize
3738 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
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).
3748 \begin_layout Subsection
3749 movie.current_first_subframe: Return first subframe in current frame
3752 \begin_layout Itemize
3753 Syntax: number movie.current_first_subframe()
3756 \begin_layout Standard
3757 Returns first subframe in current frame.
3760 \begin_layout Subsection
3761 movie.pollcounter: Return poll counter for speified control
3764 \begin_layout Itemize
3765 Syntax: number movie.pollcounter(number port, number controller, number control)
3768 \begin_layout Standard
3769 Returns number of times the specified control has been polled this frame.
3772 \begin_layout Subsection
3773 INPUTFRAME::get_button: Get button
3776 \begin_layout Itemize
3777 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
3781 \begin_layout Standard
3782 Returns state of given button as boolean.
3785 \begin_layout Subsection
3786 INPUTFRAME::get_axis: Get axis
3789 \begin_layout Itemize
3790 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
3794 \begin_layout Standard
3795 Returns state of given axis as number.
3798 \begin_layout Subsection
3799 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
3802 \begin_layout Itemize
3803 Syntax: none INPUTFRAME::set_button(number port, number controller, number
3804 control, number/bool value)
3807 \begin_layout Itemize
3808 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
3812 \begin_layout Standard
3813 Set the given button/axis to given value.
3816 \begin_layout Subsection
3817 INPUTFRAME::serialize: Serialize a frame
3820 \begin_layout Itemize
3821 Syntax: string INPUTFRAME::serialize()
3824 \begin_layout Standard
3825 Return string representation of frame.
3828 \begin_layout Subsection
3829 INPUTFRAME::unserialize: Unserialize a frame
3832 \begin_layout Itemize
3833 Syntax: none INPUTFRAME::unserialize(string data)
3836 \begin_layout Standard
3837 Set current frame from given data.
3840 \begin_layout Subsection
3841 INPUTFRAME::get_stride: Get movie stride
3844 \begin_layout Itemize
3845 Syntax: number INPUTFRAME::get_stride()
3848 \begin_layout Standard
3849 Return number of bytes needed to store the input frame.
3850 Mainly useful for some debugging.
3853 \begin_layout Standard
3854 \begin_inset Newpage pagebreak
3860 \begin_layout Section
3864 \begin_layout Standard
3865 Routines for settings manipulation
3868 \begin_layout Subsection
3869 settings.get: Get value of setting
3872 \begin_layout Itemize
3873 Syntax: string settings.get(string name)
3876 \begin_layout Standard
3877 Get value of setting <name>.
3878 If setting value can't be obtained, returns (nil, error message).
3881 \begin_layout Subsection
3882 settings.set: Set value of setting
3885 \begin_layout Itemize
3886 Syntax: none settings.set(string name, string value)
3889 \begin_layout Standard
3890 Set value <value> of setting <name>.
3891 If setting can't be set, returns (nil, error message).
3894 \begin_layout Standard
3895 \begin_inset Newpage pagebreak
3901 \begin_layout Section
3905 \begin_layout Standard
3906 Contains various functions for managing memory
3909 \begin_layout Subsection
3910 memory.vma_count: Count number of VMAs.
3913 \begin_layout Itemize
3914 Syntax: number memory.vma_count()
3917 \begin_layout Standard
3918 Returns the number of VMAs
3921 \begin_layout Subsection
3922 memory.read_vma: Lookup VMA info by index
3925 \begin_layout Itemize
3926 Syntax: string memory.read_vma(number index)
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:
3935 \begin_layout Itemize
3936 region_name (string): The readable name of the VMA
3939 \begin_layout Itemize
3940 baseaddr (number): Base address of the VMA
3943 \begin_layout Itemize
3944 lastaddr (number): Last address in the VMA.
3947 \begin_layout Itemize
3948 size (number): The size of VMA in bytes.
3951 \begin_layout Itemize
3952 readonly (boolean): True of the VMA corresponds to ROM.
3955 \begin_layout Itemize
3956 iospace (boolean): True if the VMA is I/O space.
3959 \begin_layout Itemize
3960 native_endian (boolean): True if the VMA has native endian as opposed to
3964 \begin_layout Subsection
3965 memory.find_vma: Find VMA info by address
3968 \begin_layout Itemize
3969 Syntax: table memory.find_vma(number address)
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.
3977 \begin_layout Subsection
3978 memory.read{,s}{byte,{,h,d,q}word}: Read memory
3981 \begin_layout Itemize
3982 Syntax: none memory.readbyte([string vma, ]number address)
3985 \begin_layout Itemize
3986 Syntax: none memory.readword([string vma, ]number address)
3989 \begin_layout Itemize
3990 Syntax: none memory.readhword([string vma, ]number address)
3993 \begin_layout Itemize
3994 Syntax: none memory.readdword([string vma, ]number address)
3997 \begin_layout Itemize
3998 Syntax: none memory.readqword([string vma, ]number address)
4001 \begin_layout Itemize
4002 Syntax: none memory.readsbyte([string vma, ]number address)
4005 \begin_layout Itemize
4006 Syntax: none memory.readsword([string vma, ]number address)
4009 \begin_layout Itemize
4010 Syntax: none memory.readshword([string vma, ]number address)
4013 \begin_layout Itemize
4014 Syntax: none memory.readsdword([string vma, ]number address)
4017 \begin_layout Itemize
4018 Syntax: none memory.readsqword([string vma, ]number address)
4021 \begin_layout Standard
4022 Reads the specified address <address> (if 's' variant is used, do undergo
4026 \begin_layout Subsection
4027 memory.{,s}read_sg: Scatter/Gather read memory
4030 \begin_layout Itemize
4031 Syntax: none memory.read_sg(string/boolean/number...)
4034 \begin_layout Itemize
4035 Syntax: none memory.sread_sg(string/boolean/number...)
4038 \begin_layout Standard
4039 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
4041 Each argument can be string, boolean or number:
4044 \begin_layout Itemize
4045 String: Set VMA addresses are relative to (e.g.
4049 \begin_layout Itemize
4050 boolean: If true, increment relative address by 1, if false, decrement by
4052 The new address is read as next higher byte.
4055 \begin_layout Itemize
4056 integer: Set the relative address to specified value and read the address
4057 as next higher byte.
4060 \begin_layout Subsection
4061 memory.write_sg: Scatter/Gather write memory
4064 \begin_layout Itemize
4065 Syntax: none memory.write_sg(number value, string/boolean/number...)
4068 \begin_layout Standard
4069 Perform scatter/gather write of value <value> on memory.
4070 Each argument can be string, boolean or number:
4073 \begin_layout Itemize
4074 String: Set VMA addresses are relative to (e.g.
4078 \begin_layout Itemize
4079 boolean: If true, increment relative address by 1, if false, decrement by
4081 The new address is read as next higher byte.
4084 \begin_layout Itemize
4085 integer: Set the relative address to specified value and read the address
4086 as next higher byte.
4089 \begin_layout Subsection
4090 memory.read{float,double}: Read memory
4093 \begin_layout Itemize
4094 Syntax: none memory.readfloat([string vma, ]number address)
4097 \begin_layout Itemize
4098 Syntax: none memory.readdouble([string vma, ]number address)
4101 \begin_layout Standard
4102 Reads the specified address <address>
4105 \begin_layout Subsection
4106 memory.write{byte,{,h,d,q}word,float,double}: Write memory
4109 \begin_layout Itemize
4110 Syntax: none memory.writebyte([string vma, ]number address, number value)
4113 \begin_layout Itemize
4114 Syntax: none memory.writeword([string vma, ]number address, number value)
4117 \begin_layout Itemize
4118 Syntax: none memory.writehword([string vma, ]number address, number value)
4121 \begin_layout Itemize
4122 Syntax: none memory.writedword([string vma, ]number address, number value)
4125 \begin_layout Itemize
4126 Syntax: none memory.writeqword([string vma, ]number address, number value)
4129 \begin_layout Itemize
4130 Syntax: none memory.writefloat([string vma, ]number address, number value)
4133 \begin_layout Itemize
4134 Syntax: none memory.writedouble([string vma, ]number address, number value)
4137 \begin_layout Standard
4138 Writes the specified value <value> (negative integer values undergo 2's
4139 complement) to specified address <address>.
4142 \begin_layout Subsection
4143 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
4146 \begin_layout Itemize
4147 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
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.
4155 \begin_layout Itemize
4156 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
4157 qword, sqword, float or double.
4160 \begin_layout Subsection
4161 memory.hash_region: Hash region of memory
4164 \begin_layout Itemize
4165 Syntax: string memory.hash_region([string vma, ]number base, number size)
4168 \begin_layout Standard
4169 Hash specified number of bytes starting from specified address and return
4173 \begin_layout Subsection
4174 memory.hash_state: Hash system state
4177 \begin_layout Itemize
4178 Syntax: string memory.hash_state()
4181 \begin_layout Standard
4182 Hash the current system state.
4183 Mainly useful for debugging savestates.
4186 \begin_layout Subsection
4187 memory.readregion: Read region of memory
4190 \begin_layout Itemize
4191 Syntax: table memory.readregion([string vma, ]number base, number size)
4194 \begin_layout Standard
4195 Read a region of memory.
4198 \begin_layout Itemize
4199 Warning: If the region crosses VMA boundary, the results are undefined.
4202 \begin_layout Subsection
4203 memory.writeregion: Write region of memory
4206 \begin_layout Itemize
4207 Syntax: none memory.writeregion([string vma, ]number base, number size, table
4211 \begin_layout Standard
4212 Write a region of memory.
4215 \begin_layout Itemize
4216 Warning: If the region crosses VMA boundary, the results are undefined.
4219 \begin_layout Subsection
4220 memory.map_structure: Create mmap structure
4223 \begin_layout Itemize
4224 syntax: MMAP_STRUCT memory.map_structure()
4227 \begin_layout Standard
4228 Returns a new mapping structure (MMAP_STRUCT)
4231 \begin_layout Subsection
4232 MMAP_STRUCT(): Bind key in mmap structure
4235 \begin_layout Itemize
4236 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
4240 \begin_layout Standard
4241 Bind key <key> in mmap structure to specified address <address> with specified
4245 \begin_layout Itemize
4246 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
4247 qword, sqword, float or double.
4250 \begin_layout Subsection
4251 memory.read_expr: Evaluate memory watch expression
4254 \begin_layout Itemize
4255 Syntax: string memory.read_expr(string expr)
4258 \begin_layout Standard
4259 Evaluate specified watch expression and return result
4262 \begin_layout Subsection
4263 memory.action: Run core action
4266 \begin_layout Itemize
4267 memory.action(string action, [<params>])
4270 \begin_layout Standard
4272 The different models expect parameters as:
4275 \begin_layout Itemize
4279 \begin_layout Itemize
4283 \begin_layout Itemize
4287 \begin_layout Itemize
4291 \begin_layout Itemize
4295 \begin_layout Subsection
4296 memory.get_lag_flag: Get lag flag
4299 \begin_layout Itemize
4300 Syntax: boolean memory.get_lag_flag()
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.
4308 \begin_layout Subsection
4309 memory.set_lag_flag: Set lag flag
4312 \begin_layout Itemize
4313 Syntax: none memory.set_lag_flag(boolean flag)
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.
4322 \begin_layout Itemize
4323 Should only be used in on_frame_emulated callback.
4326 \begin_layout Itemize
4327 Setting or clearing this affects the emulator lag counter.
4330 \begin_layout Subsection
4331 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
4335 \begin_layout Itemize
4336 Syntax: function memory.registerread([string vma, ] number addr, function
4340 \begin_layout Itemize
4341 Syntax: function memory.registerwrite([string vma, ] number addr, function
4345 \begin_layout Itemize
4346 Syntax: function memory.registerexec([string vma, ] number addr, function
4350 \begin_layout Itemize
4351 Syntax: none memory.unregisterread([string vma, ] number addr, function fn);
4354 \begin_layout Itemize
4355 Syntax: none memory.unregisterwrite([string vma, ] number addr, function
4359 \begin_layout Itemize
4360 Syntax: none memory.unregisterexec([string vma, ] number addr, function fn);
4363 \begin_layout Standard
4364 Add or remove callback on memory read, write or execute (depending on the
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*
4372 \begin_layout Itemize
4373 Not all cores support this, and it may be unsupported for some VMAs.
4376 \begin_layout Itemize
4377 The functions are passed two parameters: Address and value.
4380 \begin_layout Subsection
4381 memory.{,un}registertrace: Set/Clear trace hook
4384 \begin_layout Itemize
4385 Syntax: function memory.registertrace(number processor, function fn);
4388 \begin_layout Itemize
4389 Syntax: none memory.unregistertrace(number processor, function fn);
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.
4398 \begin_layout Itemize
4399 The functions are passed two parameters: Trace CPU and Trace event string.
4402 \begin_layout Subsection
4403 memory.cheat: Set cheat
4406 \begin_layout Itemize
4407 Syntax: none memory.cheat([string vma, ] number addr, number value);
4410 \begin_layout Itemize
4411 Syntax: none memory.cheat([string vma, ] number addr);
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.
4420 \begin_layout Itemize
4421 Not all cores support this, and it may be unsupported for some VMAs.
4424 \begin_layout Subsection
4425 memory.setxmask: Set global execute hook mask
4428 \begin_layout Itemize
4429 Syntax: none memory.setxmask(number mask)
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
4438 \begin_layout Standard
4439 \begin_inset Newpage pagebreak
4445 \begin_layout Section
4449 \begin_layout Standard
4450 Contains newer memory functions.
4453 \begin_layout Subsection
4454 memory2(): Get all VMA names.
4457 \begin_layout Itemize
4458 Syntax: table memory2()
4461 \begin_layout Standard
4462 Returns array of all valid VMA names.
4465 \begin_layout Subsection
4466 memory2.<vma>:info: Get VMA info
4469 \begin_layout Itemize
4470 Syntax: table memory2.<vma>:info()
4473 \begin_layout Standard
4474 Return table describing given VMA.
4475 Includes fields address, size, last, readonly, special and endian.
4478 \begin_layout Subsection
4479 memory2.<vma>:<op>: Read/Write memory
4482 \begin_layout Itemize
4483 Syntax: none memory2.<vma>:<op>(number offset, number value)
4486 \begin_layout Itemize
4487 Syntax: number memory2.<vma>:<op>(number offset)
4490 \begin_layout Standard
4491 Read/Write value from/to given VMA <vma> at given offset <offset> (must
4493 The value written is <value>.
4494 <Op> is of form: [i][s]<type>, where:
4497 \begin_layout Itemize
4498 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4501 \begin_layout Itemize
4502 'i' signifies that the value is treated as opposite-to-normal endianess,
4505 \begin_layout Itemize
4506 's' signifies that value is treated as signed (not available for floating-point).
4509 \begin_layout Subsection
4510 memory2.<vma>:read: Scatter-gather value read
4513 \begin_layout Itemize
4514 Syntax: number memory2.<vma>:read(number addr...)
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.
4524 \begin_layout Subsection
4525 memory2.<vma>:sread: Signed scatter-gather value read
4528 \begin_layout Itemize
4529 Syntax: number memory2.<vma>:sread(number addr...)
4532 \begin_layout Standard
4533 Like memory2.<vma>:read, but reads signed values.
4536 \begin_layout Subsection
4537 memory2.<vma>:write: Scatter-gather value write
4540 \begin_layout Itemize
4541 Syntax: number memory2.<vma>:write(number val, number addr...)
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.
4551 \begin_layout Standard
4552 \begin_inset Newpage pagebreak
4558 \begin_layout Section
4562 \begin_layout Standard
4563 Contains random number generation methods.
4564 These functions do not return reproducable results.
4567 \begin_layout Subsection
4568 random.boolean: Random boolean
4571 \begin_layout Itemize
4572 Syntax: boolean random.boolean()
4575 \begin_layout Standard
4576 Returns true or false at random (50-50 chance).
4579 \begin_layout Subsection
4580 random.integer: Random integer
4583 \begin_layout Itemize
4584 Syntax: number random.integer(number highplusone)
4587 \begin_layout Itemize
4588 Syntax: number random.integer(number low, number high)
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).
4596 \begin_layout Standard
4597 The returned numbers are from uniform distribution.
4600 \begin_layout Subsection
4601 random.float: Random float
4604 \begin_layout Itemize
4605 Syntax: number random.float()
4608 \begin_layout Standard
4609 Returns random decimal number [0,1).
4612 \begin_layout Subsection
4613 random.among: Random parameter
4616 \begin_layout Itemize
4617 Syntax: value random.among(value values...)
4620 \begin_layout Standard
4621 Returns random parameter value, picked at uniform.
4622 Multiple equivalent values are returned with higher chance.
4625 \begin_layout Subsection
4626 random.amongtable: Random from table
4629 \begin_layout Itemize
4630 Syntax: value random.amongtable(table tab)
4633 \begin_layout Standard
4634 Returns random value from table <tab>.
4635 As in random.among, no equality testing is done.
4638 \begin_layout Standard
4639 \begin_inset Newpage pagebreak
4645 \begin_layout Section
4649 \begin_layout Subsection
4650 zip.create: Create a new zipfile
4653 \begin_layout Itemize
4654 Syntax: ZIPWRITER zip.create(string filename[, number compression])
4657 \begin_layout Standard
4658 Creates a new zipfile <filename>, with specified compression level <compression>
4662 \begin_layout Subsection
4663 zip.enumerate: Enumerate members in zipfile
4666 \begin_layout Itemize
4667 Syntax: Table zip.enumerate(string filename[, boolean invert])
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.
4676 \begin_layout Subsection
4677 ZIPWRITER:commit: Finish creating ZIP file.
4680 \begin_layout Itemize
4681 Syntax: none ZIPWRITER:commit()
4684 \begin_layout Standard
4685 Closes the ZIP archive.
4686 Nothing more can be written.
4689 \begin_layout Subsection
4690 ZIPWRITER:rollback: Delete the ZIP file being creted
4693 \begin_layout Itemize
4694 Syntax: none ZIPWRITER:rollback()
4697 \begin_layout Standard
4698 Deletes the newly written ZIP archive.
4699 Nothing more can be written.
4702 \begin_layout Subsection
4703 ZIPWRITER:create_file: Start writing a new member
4706 \begin_layout Itemize
4707 Syntax: none ZIPWRITER:create_file(string filename)
4710 \begin_layout Standard
4711 Starts writing a new member <filename> in ZIP file.
4712 If member is open, it is closed.
4715 \begin_layout Subsection
4716 ZIPWRITER:close_file: Close member
4719 \begin_layout Itemize
4720 Syntax: none ZIPWRITER:close_file()
4723 \begin_layout Standard
4724 Closes member in ZIP file.
4727 \begin_layout Subsection
4728 ZIPWRITER:write: Write data
4731 \begin_layout Itemize
4732 Syntax none ZIPWRITER:write(string data)
4735 \begin_layout Standard
4736 Writes data <data> into ZIP file (binary mode).
4739 \begin_layout Standard
4740 \begin_inset Newpage pagebreak
4746 \begin_layout Section
4750 \begin_layout Standard
4751 Various callback-related functions.
4754 \begin_layout Subsection
4755 \begin_inset CommandInset label
4757 name "sub:callback.register:-Register-a"
4761 callback.register: Register a callback
4764 \begin_layout Itemize
4765 Syntax: function callback.register(string cbname, function cbfun);
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
4773 reference "sec:Callbacks"
4778 The callback name does not have the 'on_' prefix (e.g.
4780 \begin_inset Quotes eld
4784 \begin_inset Quotes erd
4791 \begin_layout Subsection
4792 \begin_inset CommandInset label
4794 name "sub:callback.unregister:-Unregister-"
4798 callback.unregister: Unregister a callback
4801 \begin_layout Itemize
4802 Syntax: function callback.unregister(string cbname, function cbfun);
4805 \begin_layout Standard
4806 Instruct function <cbfun> to be removed from list of callbacks to call on
4810 \begin_layout Subsection
4811 callback.<cbname>:register: Register callback
4814 \begin_layout Itemize
4815 Syntax: function callback.<cbname>:register(function cbfun)
4818 \begin_layout Standard
4819 Synonym for callback.register (section
4820 \begin_inset CommandInset ref
4822 reference "sub:callback.register:-Register-a"
4826 ), albeit with callback name specified differently.
4829 \begin_layout Subsection
4830 callback.<cbname>:unregister: Register callback
4833 \begin_layout Itemize
4834 Syntax: function callback.<cbname>:unregister(function cbfun)
4837 \begin_layout Standard
4838 Synonym for callback.unregister (section
4839 \begin_inset CommandInset ref
4841 reference "sub:callback.unregister:-Unregister-"
4845 ), albeit with callback name specified differently.
4848 \begin_layout Section
4852 \begin_layout Standard
4853 Various bsnes-specific functions.
4856 \begin_layout Subsection
4857 bsnes.dump_sprite: Dump a sprite
4860 \begin_layout Itemize
4861 Syntax: BITMAP bsnes.dump_sprite([string vma, ] number addr, number width,
4862 number height[, number stride])
4865 \begin_layout Standard
4866 Dumps given sprite (in native format) from memory.
4868 \begin_inset Quotes eld
4872 \begin_inset Quotes erd
4876 <Width> and <height> are given in 8x8 blocks.
4877 <Stride> overrides row stride (default 512).
4880 \begin_layout Subsection
4881 bsnes.dump_palette: Dump a palette
4884 \begin_layout Itemize
4885 Syntax: PALETTE bsnes.dump_palette([string vma, ] number addr, bool full256,
4889 \begin_layout Standard
4890 Dumps a palette from memory.
4892 \begin_inset Quotes eld
4896 \begin_inset Quotes erd
4900 If <full256> is true, 256 colors are dumped (otherwise 16).
4901 If <first_trans> is true, first color is forced transparent.
4904 \begin_layout Section
4905 extensions to table string
4908 \begin_layout Subsection
4909 string.charU: string.char, UTF-8 version.
4912 \begin_layout Itemize
4913 Syntax: string string.charU(number n...)
4916 \begin_layout Standard
4917 Like Lua string.char(), but works in terms of Unicode codepoints.
4918 The returned string is UTF-8.
4921 \begin_layout Subsection
4922 string.byteU: string.byte, UTF-8 version.
4925 \begin_layout Itemize
4927 string.byteU(string str[, number i[, number j]])
4930 \begin_layout Standard
4931 Like string.byte(), but works in terms of Unicode codepoints.
4932 The input string <str> is assumed UTF-8.
4935 \begin_layout Section
4939 \begin_layout Standard
4940 Contains copy of global variables from time of Lua initialization.
4944 \begin_layout Standard
4945 \begin_inset Newpage pagebreak
4951 \begin_layout Section
4952 \begin_inset CommandInset label
4954 name "sec:Callbacks"
4961 \begin_layout Standard
4962 Various callbacks to Lua that can occur.
4965 \begin_layout Subsection
4966 on_paint: Screen is being painted
4969 \begin_layout Itemize
4970 Callback: on_paint(bool not_synth)
4973 \begin_layout Standard
4974 Called when screen is being painted.
4975 Any gui.* calls requiring graphic context draw on the screen.
4978 \begin_layout Itemize
4979 not_synth is true if this hook is being called in response to received frame,
4983 \begin_layout Subsection
4984 on_video: Dumped video frame is being painted
4987 \begin_layout Itemize
4988 Callback: on_video()
4991 \begin_layout Standard
4992 Called when video dump frame is being painted.
4993 Any gui.* calls requiring graphic context draw on the video.
4996 \begin_layout Subsection
4997 on_frame_emulated: Frame emulation complete
5000 \begin_layout Itemize
5001 Callback: on_frame_emulated()
5004 \begin_layout Standard
5005 Called when emulating frame has completed and on_paint()/on_video() calls
5006 are about to be issued.
5009 \begin_layout Subsection
5010 on_frame: Frame emulation starting.
5013 \begin_layout Itemize
5014 Callback: on_frame()
5017 \begin_layout Standard
5018 Called on each starting whole frame.
5021 \begin_layout Subsection
5022 on_startup: Emulator startup complete
5025 \begin_layout Itemize
5026 Callback: on_startup()
5029 \begin_layout Standard
5030 Called when the emulator is starting (lsnes.rc and --run files has been run).
5033 \begin_layout Subsection
5034 on_rewind: Movie rewound to beginning
5037 \begin_layout Itemize
5038 Callback: on_rewind()
5041 \begin_layout Standard
5042 Called when rewind movie to beginning has completed.
5045 \begin_layout Subsection
5046 on_pre_load: Load operation is about to start
5049 \begin_layout Itemize
5050 Callback: on_pre_load(string name)
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).
5058 \begin_layout Subsection
5059 on_err_Load: Load failed
5062 \begin_layout Itemize
5063 Callback: on_err_load(string name)
5066 \begin_layout Standard
5067 Called if loadstate goes wrong.
5070 \begin_layout Subsection
5071 on_post_load: Load completed
5074 \begin_layout Itemize
5075 Callback: on_post_load(string name, boolean was_savestate)
5078 \begin_layout Standard
5079 Called on successful loadstate.
5080 was_savestate gives if this was a savestate or a movie.
5083 \begin_layout Subsection
5084 on_pre_save: Save operation is about to start
5087 \begin_layout Itemize
5088 Callback: on_pre_save(string name, boolean is_savestate)
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).
5096 \begin_layout Subsection
5097 on_err_save: Save failed
5100 \begin_layout Itemize
5101 Callback: on_err_save(string name)
5104 \begin_layout Standard
5105 Called if savestate goes wrong.
5108 \begin_layout Subsection
5109 on_post_save: Save completed
5112 \begin_layout Itemize
5113 Callback: on_post_save(string name, boolean is_savestate)
5116 \begin_layout Standard
5117 Called on successful savaestate.
5118 is_savestate gives if this was a savestate or a movie.
5121 \begin_layout Subsection
5122 on_quit: Emulator is shutting down
5125 \begin_layout Itemize
5129 \begin_layout Standard
5130 Called when emulator is shutting down.
5133 \begin_layout Subsection
5134 on_input: Polling for input
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.
5142 \begin_layout Subsection
5143 on_reset: System has been reset
5146 \begin_layout Itemize
5147 Callback: on_reset()
5150 \begin_layout Standard
5151 Called when system is reset.
5154 \begin_layout Subsection
5155 on_readwrite: Entered readwrite mode
5158 \begin_layout Itemize
5159 Callback: on_readwrite()
5162 \begin_layout Standard
5163 Called when moving into readwrite mode as result of
5164 \begin_inset Quotes eld
5168 \begin_inset Quotes erd
5171 command (note: moving to rwmode by Lua won't trigger this, as per recursive
5175 \begin_layout Subsection
5176 on_snoop/on_snoop2: Snoop core controller reads
5179 \begin_layout Itemize
5180 Callback: on_snoop(number port, number controller, number index, number
5184 \begin_layout Itemize
5185 Callback: on_snoop2(number port, number controller, number index, number
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
5195 Note: There is no way to modify the value to be sent.
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.
5203 \begin_layout Subsection
5204 on_keyhook: Hooked key/axis has been moved
5207 \begin_layout Itemize
5208 Callback: on_keyhook(string keyname, table state)
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).
5217 \begin_layout Subsection
5221 \begin_layout Itemize
5225 \begin_layout Standard
5226 Called when requested by set_idle_timeout(), the timeout has expired and
5227 emulator is waiting.
5230 \begin_layout Subsection
5231 on_timer: Timer event
5234 \begin_layout Itemize
5235 Callback: on_timer()
5238 \begin_layout Standard
5239 Called when requested by set_idle_timeout() and the timeout has expired
5240 (regardless if emulator is waiting).
5243 \begin_layout Subsection
5244 on_set_rewind: Rewind point has been set
5247 \begin_layout Itemize
5248 Callback: on_set_rewind(UNSAFEREWIND r)
5251 \begin_layout Standard
5252 Called when unsafe rewind object has been constructed.
5255 \begin_layout Subsection
5256 on_pre_rewind: Rewind is about to occur
5259 \begin_layout Itemize
5260 Callback: on_pre_rewind()
5263 \begin_layout Standard
5264 Called just before unsafe rewind is about to occur.
5267 \begin_layout Subsection
5268 on_post_rewind: Rewind has occured
5271 \begin_layout Itemize
5272 Callback: on_post_rewind()
5275 \begin_layout Standard
5276 Called just after unsafe rewind has occured.
5279 \begin_layout Subsection
5280 on_button: Button has been pressed
5283 \begin_layout Itemize
5284 Callback: on_button(number port, number controller, number index, string
5288 \begin_layout Standard
5289 Called on controller button press, with following parameters:
5292 \begin_layout Itemize
5293 port: Port number (0 is system)
5296 \begin_layout Itemize
5297 controller: Controller within port
5300 \begin_layout Itemize
5301 index: Index of button.
5304 \begin_layout Itemize
5305 type: Type of event, one of:
5309 \begin_layout Itemize
5310 \begin_inset Quotes eld
5314 \begin_inset Quotes erd
5317 : Button was pressed.
5320 \begin_layout Itemize
5321 \begin_inset Quotes eld
5325 \begin_inset Quotes erd
5328 : Button was released.
5331 \begin_layout Itemize
5332 \begin_inset Quotes eld
5336 \begin_inset Quotes erd
5342 \begin_layout Itemize
5343 \begin_inset Quotes eld
5347 \begin_inset Quotes erd
5350 : Released from hold.
5353 \begin_layout Itemize
5354 \begin_inset Quotes eld
5358 \begin_inset Quotes erd
5361 : Typing input on button.
5364 \begin_layout Itemize
5365 \begin_inset Quotes eld
5369 \begin_inset Quotes erd
5372 : Typing input undone.
5375 \begin_layout Itemize
5376 \begin_inset Quotes eld
5379 autofire <duty> <cycle>
5380 \begin_inset Quotes erd
5383 : Autofire with specifie duty and cycle.
5386 \begin_layout Itemize
5387 \begin_inset Quotes eld
5391 \begin_inset Quotes erd
5397 \begin_layout Itemize
5398 \begin_inset Quotes eld
5402 \begin_inset Quotes erd
5405 : Analog action on axis.
5409 \begin_layout Subsection
5410 on_movie_lost: Movie data is about to be lost
5413 \begin_layout Itemize
5414 Callback: on_movie_lost(STRING kind)
5417 \begin_layout Standard
5418 Called just before something would happen that could lose movie data.
5422 \begin_layout Itemize
5423 readwrite: Switching to readwrite mode.
5426 \begin_layout Itemize
5427 reload: ROM is being reloaded in readwrite mode.
5430 \begin_layout Itemize
5431 load: New movie is being loaded.
5434 \begin_layout Itemize
5435 unsaferewind: Unsafe rewind is happening.
5438 \begin_layout Subsection
5439 on_latch: Latch line is rising
5442 \begin_layout Itemize
5443 Callback: on_latch(<core-dependent-parameters>)
5446 \begin_layout Standard
5447 Called when latch line for controller is rising.
5448 Some cores may not support this.
5451 \begin_layout Section
5452 System-dependent behaviour
5455 \begin_layout Subsection
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,
5502 \begin_layout Itemize
5503 on_latch has no parameters
5506 \begin_layout Itemize
5507 CPU 0 is S-CPU, 1 is S-SMP.
5510 \begin_layout Itemize
5511 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
5514 \begin_layout Itemize
5515 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
5519 \begin_layout Subsection
5523 \begin_layout Itemize
5524 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
5528 \begin_layout Itemize
5529 on_latch is not supported
5532 \begin_layout Itemize
5536 \begin_layout Itemize
5537 Cheats are supported for ROM, SRAM and WRAM.
5540 \begin_layout Itemize
5541 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM