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 MMAP_STRUCT: Quasi-table mapping emulated memory
135 \begin_layout Standard
136 Objects of this class act like tables, except that the values are reflected
140 \begin_layout Subsubsection
141 static function new: Create new instance
144 \begin_layout Itemize
146 alias: memory.map_structure
149 \begin_layout Itemize
150 syntax: classes.MMAP_STRUCT.new()
153 \begin_layout Standard
154 Create and returns a new mapping structure.
157 \begin_layout Subsubsection
158 operator(): Bind key in mmap structure
161 \begin_layout Itemize
162 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
166 \begin_layout Standard
167 Bind key <key> in mmap structure to specified address <address> with specified
171 \begin_layout Itemize
172 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
173 qword, sqword, float or double.
176 \begin_layout Standard
177 \begin_inset Newpage pagebreak
183 \begin_layout Subsection
184 ZIPWRITER: Writes .zip files
187 \begin_layout Standard
188 This class does writing of .zip files.
191 \begin_layout Subsubsection
192 Static function new: Create a new zipfile
195 \begin_layout Itemize
200 \begin_layout Itemize
201 Syntax: classes.ZIPWRITER.new(string filename[, number compression])
204 \begin_layout Standard
205 Creates a new zipfile <filename>, with specified compression level <compression>
209 \begin_layout Subsubsection
210 Method commit: Finish creating ZIP file.
213 \begin_layout Itemize
214 Syntax: none ZIPWRITER:commit()
217 \begin_layout Standard
218 Closes the ZIP archive.
219 Nothing more can be written.
222 \begin_layout Subsubsection
223 Method rollback: Delete the ZIP file being creted
226 \begin_layout Itemize
227 Syntax: none ZIPWRITER:rollback()
230 \begin_layout Standard
231 Deletes the newly written ZIP archive.
232 Nothing more can be written.
235 \begin_layout Subsubsection
236 Method create_file: Start writing a new member
239 \begin_layout Itemize
240 Syntax: none ZIPWRITER:create_file(string filename)
243 \begin_layout Standard
244 Starts writing a new member <filename> in ZIP file.
245 If member is open, it is closed.
248 \begin_layout Subsubsection
249 Method close_file: Close member
252 \begin_layout Itemize
253 Syntax: none ZIPWRITER:close_file()
256 \begin_layout Standard
257 Closes member in ZIP file.
260 \begin_layout Subsubsection
261 Method write: Write data
264 \begin_layout Itemize
265 Syntax none ZIPWRITER:write(string data)
268 \begin_layout Standard
269 Writes data <data> into ZIP file (binary mode).
272 \begin_layout Standard
273 \begin_inset Newpage pagebreak
279 \begin_layout Subsection
280 TILEMAP: Tiled collection of bitmaps.
283 \begin_layout Standard
284 A tilemap is tiled table, each cell holding a bitmap.
287 \begin_layout Subsubsection
288 Static function new: Create a tilemap
291 \begin_layout Itemize
296 \begin_layout Itemize
297 Syntax: TILEMAP classes.TILEMAP.new(number w, number h, number bw, number
301 \begin_layout Standard
302 Create a new tilemap of size <w>*<h>, with each cell being <bw>*<bh>.
305 \begin_layout Subsubsection
306 TILEMAP:getsize: Query tilemap size
309 \begin_layout Itemize
310 Syntax: number, number TILEMAP:getsize()
313 \begin_layout Standard
314 Return size of tilemap (width first).
317 \begin_layout Subsubsection
318 TILEMAP:getcsize: Query tilemap cell size
321 \begin_layout Itemize
322 Syntax: number, number TILEMAP:getcsize()
325 \begin_layout Standard
326 Return size of tilemap cell (width first).
329 \begin_layout Subsubsection
330 TILEMAP:get: Query tilemap cell
333 \begin_layout Itemize
334 Syntax: none TILEMAP:get(number x, number y)
337 \begin_layout Itemize
338 Syntax: dbitmap TILEMAP:get(number x, number y)
341 \begin_layout Itemize
342 Syntax: bitmap,palette TILEMAP:get(number x, number y)
345 \begin_layout Standard
346 Return contents of cell at <x>,<y>.
349 \begin_layout Subsubsection
350 TILEMAP:set: Set tilemap cell
353 \begin_layout Itemize
354 Syntax: none TILEMAP:set(number x, number y)
357 \begin_layout Itemize
358 Syntax: none TILEMAP:set(number x, number y, dbitmap b)
361 \begin_layout Itemize
362 Syntax: none TILEMAP:set(number x, number y, bitmap b, palette p)
365 \begin_layout Standard
366 Set contents of cell at <x>,<y>.
367 If no bitmap/dbitmap is given, cell is cleared.
368 Otherwise specified (d)bitmap is used (with specified palette if bitmap).
371 \begin_layout Subsubsection
372 TILEMAP:scroll: Scroll tilemap
375 \begin_layout Itemize
376 Syntax: none TILEMAP:scroll(number ox, number oy)
379 \begin_layout Itemize
380 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
384 \begin_layout Itemize
385 Syntax: none TILEMAP:scroll(number ox, number oy, number x, number y, number
386 w, number h, boolean circx, boolean circy)
389 \begin_layout Standard
390 Scrolls the tilemap tiles by <ox>,<oy>.
391 If <x>,<y>,<w>,<h> is specified, the scrolling is limited to <w>*<h> window
392 starting at <x>,<y> (in tiles).
395 \begin_layout Standard
396 If <circx> is true, the window is circular in horizontal direction.
397 Similarly with <circy> and vertical direciton.
400 \begin_layout Subsubsection
401 TILEMAP:draw: Draw tilemap
404 \begin_layout Itemize
405 Syntax: none TILEMAP:draw(number x, number y)
408 \begin_layout Itemize
409 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0)
412 \begin_layout Itemize
413 Syntax: none TILEMAP:draw(number x, number y, number x0, number y0, number
417 \begin_layout Standard
418 Draw tilemap at <x>,<y>.
419 If <x0>,<y0> is given, that is tilemap coordinate (in pixels) of upper
421 If <w>,<h> is given, that is the size of window to draw (in pixels)
424 \begin_layout Standard
425 \begin_inset Newpage pagebreak
431 \begin_layout Subsection
432 RENDERCTX: Render queue
435 \begin_layout Subsubsection
436 Static function new: Create a render queue
439 \begin_layout Itemize
441 alias: gui.renderq_new
444 \begin_layout Itemize
445 Syntax: RENDERQUEUE classes.RENDERCTX.new(number width, number height)
448 \begin_layout Standard
449 Create render queue with specified reported size and return it.
452 \begin_layout Subsubsection
453 Static function setnull: Reset to default queue
456 \begin_layout Itemize
458 alias: gui.renderq_set
461 \begin_layout Itemize
462 Syntax: none classes.RENDERCTX:setnull()
465 \begin_layout Standard
466 Reset back to default queue (screen, video or none).
469 \begin_layout Subsubsection
470 Method clear: Clear a render queue
473 \begin_layout Itemize
475 alias: gui.renderq_clear
478 \begin_layout Itemize
479 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
482 \begin_layout Itemize
483 Syntax: none RENDERQUEUE:clear()
486 \begin_layout Standard
487 Clear specified render queue.
490 \begin_layout Subsubsection
491 Method set: Change active render queue
494 \begin_layout Itemize
496 alias: gui.renderq_set
499 \begin_layout Itemize
500 Syntax: none RENDERQUEUE:set()
503 \begin_layout Standard
504 Switch to specified render queue.
505 Use nil as queue to switch to default queue.
508 \begin_layout Itemize
509 Note: When switched to another queue, all drawing functions work and draw
510 there, even outside on_video/on_paint.
513 \begin_layout Subsubsection
514 Method run: Run render queue
517 \begin_layout Itemize
519 alias: gui.renderq_run
522 \begin_layout Itemize
523 Syntax: none RENDERQUEUE:run()
526 \begin_layout Standard
527 Run specified render queue, copying the objects to current render queue.
531 \begin_layout Itemize
532 Warning: Don't try to run the current render queue.
535 \begin_layout Subsubsection
536 Method render: Render a queue to DBITMAP
539 \begin_layout Itemize
540 Syntax: DBITMAP RENDERQUEUE:render()
543 \begin_layout Standard
544 Renders the specified render queue to a bitmap, the base bitmap size (modified
545 by gaps) being the nominal screen size for render queue.
548 \begin_layout Subsection
549 Method synchronous_repaint: Paint screen now
552 \begin_layout Itemize
554 alias: gui.synchronous_repaint
557 \begin_layout Itemize
558 Syntax: none RENDERQUEUE::synchronous_repaint()
561 \begin_layout Standard
562 Paints specified render queue on screen right there and then.
565 \begin_layout Standard
566 \begin_inset Newpage pagebreak
572 \begin_layout Section
576 \begin_layout Subsection
577 print: Print values to console
580 \begin_layout Itemize
581 Syntax: none print(value...
585 \begin_layout Standard
586 Prints specified values to console.
587 Can print any Lua type at least enough to identify the type and instance.
590 \begin_layout Subsection
591 tostringx: Format a value to string
594 \begin_layout Itemize
595 Syntax: string tostringx(value val)
598 \begin_layout Standard
599 Formats value <val> like print would, and returns the result as a string.
602 \begin_layout Subsection
603 exec: Execute lsnes commands
606 \begin_layout Itemize
607 Syntax: none exec(string cmd)
610 \begin_layout Standard
611 Execute lsnes command <cmd>.
614 \begin_layout Subsection
615 utime: Get current time
618 \begin_layout Itemize
619 Syntax: (number,number) utime()
622 \begin_layout Standard
624 First is time since some epoch in seconds, the second is microseconds mod
625 10^6 since that epoch.
628 \begin_layout Subsection
629 emulator_ready: Check if emulator has been fully initialized
632 \begin_layout Itemize
633 Syntax: boolean emulator_ready()
636 \begin_layout Standard
637 Returns true if emulator has finished booting, false if not (on_startup()
638 will be issued later).
641 \begin_layout Subsection
642 set_idle_timeout: Run function after timeout when emulator is idle
645 \begin_layout Itemize
646 Syntax: none set_idle_timeout(number timeout)
649 \begin_layout Standard
650 Set number of microseconds to block idle for.
651 After this timeout has expired, on_idle() will be called once.
654 \begin_layout Subsection
655 set_timer_timeout: Run function after timeout.
658 \begin_layout Itemize
659 Syntax: none set_timer_timeout(number timeout)
662 \begin_layout Standard
663 Set number of microseconds to block timer for.
664 After this timeout has expired, on_timer() will be called once.
667 \begin_layout Subsection
668 bus_address: Look up address in system bus.
671 \begin_layout Itemize
672 Syntax: none bus_address(number bus_addr)
675 \begin_layout Standard
676 Returns virtual address corresponding to specified address on system bus.
679 \begin_layout Subsection
680 loopwrapper: Convert loop into callable function
683 \begin_layout Itemize
684 Syntax: function loopwrapper(function fun, ...)
687 \begin_layout Standard
688 Calls function <fun> with function and specified arguments.
689 The function passed suspends execution until the function returned is called.
690 Handy for linear flow control among multiple invocations of a hook.
694 \begin_layout LyX-Code
695 on_paint = loopwrapper(function(wait)
699 \begin_layout LyX-Code
704 \begin_layout LyX-Code
706 \begin_inset Quotes eld
710 \begin_inset Quotes erd
716 \begin_layout LyX-Code
721 \begin_layout LyX-Code
726 \begin_layout LyX-Code
730 \begin_layout Subsection
731 list_bindings: List keybindings
734 \begin_layout Itemize
735 Syntax: table list_bindings([string cmd])
738 \begin_layout Standard
739 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
740 If <cmd> is specified, the table is limited to that command.
741 Also searches for controller keys.
744 \begin_layout Subsection
745 get_alias: Get expansion of alias
748 \begin_layout Itemize
749 Syntax: string get_alias(string aname)
752 \begin_layout Standard
753 Get expansion of given alias <aname>.
756 \begin_layout Subsection
757 set_alias: Set expansion of alias
760 \begin_layout Itemize
761 Syntax: none set_alias(string aname, string value)
764 \begin_layout Standard
765 Set expansion of given alias.
768 \begin_layout Subsection
769 create_ibind: Create invese binding
772 \begin_layout Itemize
773 Syntax: INVERSEBIND create_ibind(string name, string cmd)
776 \begin_layout Standard
777 Return object representing inverse binding with specified name <name> and
778 specified command <cmd>.
781 \begin_layout Itemize
782 Note: To create press/release commands, use aliases +foo and -foo .
785 \begin_layout Itemize
786 Note: Keep the returned object around.
789 \begin_layout Subsection
790 create_command: Create a command
793 \begin_layout Itemize
794 Syntax: COMMANDBIND create_commmand(string name, function a)
797 \begin_layout Itemize
798 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
801 \begin_layout Standard
802 Return object representing a command (pair).
805 \begin_layout Itemize
806 If only one function is specied, the command is level-sensitive, <a> is
810 \begin_layout Itemize
811 If <b> is function, the function is edge-sensitive, <a> is positive edge
812 callback and <b> is negative edge callback.
815 \begin_layout Itemize
816 All callbacks get single argument: The parameters passed.
819 \begin_layout Itemize
820 Keep the returned object around.
823 \begin_layout Subsection
824 loadfile: Load Lua script
827 \begin_layout Itemize
828 Syntax: function loadfile(string filename[, string base])
831 \begin_layout Standard
832 Load lua script from <filename>, resolved relative to <base> (if empty,
836 \begin_layout Subsection
837 dofile: Execute Lua script
840 \begin_layout Itemize
841 Syntax: function dofile(string filename[, string base])
844 \begin_layout Standard
845 Execute lua script from <filename>, resolved relative to <base> (if empty,
846 current directory) and return all return values.
849 \begin_layout Subsection
850 open_file: Open a stream
853 \begin_layout Itemize
854 Syntax: FILEREADER open_file(string filename[, string base])
857 \begin_layout Standard
858 Open file <filename>, resolved relative to <base> (if empty, current directory)
862 \begin_layout Subsection
863 FILEREADER(): Read line/bytes from stream
866 \begin_layout Itemize
867 Syntax: string/nil FILEREADER()
870 \begin_layout Itemize
871 Syntax: string/nil FILEREADER(number bytes)
874 \begin_layout Standard
875 Reads next line or <bytes> bytes from specified file handle.
876 On EOF, nil is returned.
879 \begin_layout Itemize
880 Note: The line-oriented variant reads in text mode, so CR at end of line
884 \begin_layout Subsection
885 FILEREADER:lines: Iterator to read all lines
888 \begin_layout Itemize
889 Syntax: for line in <foo>:lines() do ...
893 \begin_layout Standard
894 Iterator for reading all lines of <foo> in a loop.
897 \begin_layout Subsection
898 resolve_filename: Resolve name of file relative to another
901 \begin_layout Itemize
902 Syntax: string resolve_file(string filename, string base)
905 \begin_layout Standard
906 Resolve name of file <filename> relative to <base> and return the result.
909 \begin_layout Subsection
910 render_queue_function: Return paint function for render queue
913 \begin_layout Itemize
914 Syntax: function render_queue_function(RENDERQUEUE rq)
917 \begin_layout Standard
918 Return function that renders render queue <rq>.
921 \begin_layout Itemize
922 Handy for paint callback if one is using render queues updated in other
927 \begin_layout LyX-Code
928 handle = callback.paint:register(render_queue_function(my_rq));
931 \begin_layout Subsection
932 iconv_new: Create new character set converter
935 \begin_layout Itemize
936 Syntax: ICONV iconv_new(string from, string to)
939 \begin_layout Standard
940 Create a character set converter, converting from <from> to <to>.
943 \begin_layout Subsection
944 ICONV(): Convert string fragment from character set to another
947 \begin_layout Itemize
948 Syntax: boolean, string, (number, string) ICONV(string input)
951 \begin_layout Standard
952 Convert string fragment <input> from character set to another.
955 \begin_layout Itemize
956 If conversion is successful, returns (true, {converted-string}).
960 \begin_layout Itemize
961 If conversion was unsuccessful, returns (false, {converted-part}, {unconverted-b
963 The following errors are defined:
967 \begin_layout Itemize
968 INVALID: Invalid byte sequence in input
971 \begin_layout Itemize
972 INCOMPLETE: The input is cut of in middle of multi-byte sequence
975 \begin_layout Itemize
976 INTERNALERR: Internal errror
980 \begin_layout Subsection
981 identify_class: Identify class of object
984 \begin_layout Itemize
985 Syntax: string identify_class(userdata object)
988 \begin_layout Standard
989 Identifies the class of userdata <object>, if possible.
990 If no identification is possible, returns
991 \begin_inset Quotes eld
995 \begin_inset Quotes erd
1001 \begin_layout Subsection
1002 lookup_class: Lookup class by name
1005 \begin_layout Itemize
1006 Syntax: classobj lookup_class(string name)
1009 \begin_layout Standard
1010 Looks up class corresponding to <name>, if possible.
1011 If not found, returns nil.
1012 The classobj has following fields:
1015 \begin_layout Itemize
1016 _static_methods: Return static method names
1019 \begin_layout Itemize
1020 _class_methods: Return class method names
1023 \begin_layout Itemize
1024 <static-function-name>: The specified static function.
1027 \begin_layout Standard
1028 \begin_inset Newpage pagebreak
1034 \begin_layout Section
1038 \begin_layout Standard
1039 Bitwise logical functions and related.
1042 \begin_layout Subsection
1043 bit.none/bit.bnot: Bitwise none or NOT function
1046 \begin_layout Itemize
1047 Syntax: number bit.none(number...)
1050 \begin_layout Itemize
1051 Syntax: number bit.bnot(number...)
1054 \begin_layout Standard
1055 48-bit bitwise NOT / NONE function (set bits that are set in none of the
1059 \begin_layout Subsection
1060 bit.any/bit.bor: Bitwise any or OR function
1063 \begin_layout Itemize
1064 Syntax: number bit.any(number...)
1067 \begin_layout Itemize
1068 Syntax: number bit.bor(number...)
1071 \begin_layout Standard
1072 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
1075 \begin_layout Subsection
1076 bit.all/bit.band: Bitwise all or AND function
1079 \begin_layout Itemize
1080 Syntax: number bit.all(number...)
1083 \begin_layout Itemize
1084 Syntax: number bit.band(number...)
1087 \begin_layout Standard
1088 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
1092 \begin_layout Subsection
1093 bit.parity/bit.bxor: Bitwise parity or XOR function
1096 \begin_layout Itemize
1097 Syntax: number bit.parity(number...)
1100 \begin_layout Itemize
1101 Syntax: number bit.bxor(number...)
1104 \begin_layout Standard
1105 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
1109 \begin_layout Subsection
1110 bit.lrotate: Rotate a number left
1113 \begin_layout Itemize
1114 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
1117 \begin_layout Standard
1118 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
1122 \begin_layout Subsection
1123 bit.rrotate: Rotate a number right
1126 \begin_layout Itemize
1127 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
1130 \begin_layout Standard
1131 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
1135 \begin_layout Subsection
1136 bit.lshift: Shift a number left
1139 \begin_layout Itemize
1140 Syntax: number bit.lshift(number base[, number amount[, number bits]])
1143 \begin_layout Standard
1144 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
1146 The new bits are filled with zeroes.
1149 \begin_layout Subsection
1150 bit.lrshift: Shift a number right (logical)
1153 \begin_layout Itemize
1154 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
1157 \begin_layout Standard
1158 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
1160 The new bits are filled with zeroes.
1163 \begin_layout Subsection
1164 bit.arshift: Shift a number right (arithmetic)
1167 \begin_layout Itemize
1168 Syntax: number bit.arshift(number base[, number amount[, number bits]])
1171 \begin_layout Standard
1172 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
1174 The new bits are shifted in with copy of the high bit.
1177 \begin_layout Subsection
1178 bit.extract: Extract/shuffle bits from number
1181 \begin_layout Itemize
1182 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
1185 \begin_layout Standard
1186 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
1189 \begin_layout Itemize
1190 Note: Bit numbers up to 51 should work reliably (then things start falling
1191 apart due to double precision issues).
1194 \begin_layout Itemize
1195 Note: There are two special bit positions, true and false, standing for
1196 always set bit and always clear bit.
1199 \begin_layout Subsection
1200 bit.value: Construct number with specified bits set
1203 \begin_layout Itemize
1204 Syntax: number bit.value([number bit1[, number bit2,...]])
1207 \begin_layout Standard
1208 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
1209 <bit2> places and so on.
1210 As special value, nil argument is no-op.
1213 \begin_layout Subsection
1214 bit.test_any: Test if any bit is set
1217 \begin_layout Itemize
1218 Syntax: boolean bit.test_any(number a, number b)
1221 \begin_layout Standard
1222 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
1225 \begin_layout Subsection
1226 bit.test_all: Test if all bits are set
1229 \begin_layout Itemize
1230 Syntax: boolean bit.test_all(number a, number b)
1233 \begin_layout Standard
1234 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
1237 \begin_layout Subsection
1238 bit.popcount: Population count
1241 \begin_layout Itemize
1242 Syntax: number bit.popcount(number a)
1245 \begin_layout Standard
1246 Returns number of set bits in <a>.
1249 \begin_layout Subsection
1250 bit.clshift: Chained left shift
1253 \begin_layout Itemize
1254 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
1258 \begin_layout Standard
1259 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
1260 numbers to be of specified number of bits <bits> (default 48).
1263 \begin_layout Subsection
1264 bit.crshift: Chained right shift
1267 \begin_layout Itemize
1268 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
1272 \begin_layout Standard
1273 Does chained right shift on <a>, <b> by <amount> positions (default 1),
1274 assuming numbers to be of specified number of bits <bits> (default 48).
1277 \begin_layout Subsection
1278 bit.flagdecode: Decode bitfield into flags
1281 \begin_layout Itemize
1282 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
1286 \begin_layout Standard
1287 Return string of length bits where ith character is ith character of on
1288 if bit i is on, otherwise ith character of off.
1289 Out of range reads give last character.
1292 \begin_layout Itemize
1293 Note: <on> defaults to '*' if empty.
1296 \begin_layout Itemize
1297 Note: <off> defaults to '-' if empty.
1300 \begin_layout Subsection
1301 bit.rflagdecode: Decode bitfield into flags
1304 \begin_layout Itemize
1305 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
1309 \begin_layout Standard
1310 Like bit.flagdecode, but outputs the string in the opposite order (most significa
1314 \begin_layout Subsection
1315 bit.swap{,s}{,h,d,q}word: Swap word endian
1318 \begin_layout Itemize
1319 Syntax: number bit.swapword(number n)
1322 \begin_layout Itemize
1323 Syntax: number bit.swaphword(number n)
1326 \begin_layout Itemize
1327 Syntax: number bit.swapdword(number n)
1330 \begin_layout Itemize
1331 Syntax: number bit.swapqword(number n)
1334 \begin_layout Itemize
1335 Syntax: number bit.swapsword(number n)
1338 \begin_layout Itemize
1339 Syntax: number bit.swapshword(number n)
1342 \begin_layout Itemize
1343 Syntax: number bit.swapsdword(number n)
1346 \begin_layout Itemize
1347 Syntax: number bit.swapsqword(number n)
1350 \begin_layout Standard
1351 Swap endianess of (un)signed integer <n>.
1354 \begin_layout Standard
1355 \begin_inset Newpage pagebreak
1361 \begin_layout Section
1365 \begin_layout Subsection
1366 classes.<foo>: The classobj for class <foo>
1369 \begin_layout Itemize
1370 Syntax: classes.<foo>
1373 \begin_layout Standard
1374 The classobj for class <foo>.
1377 \begin_layout Subsection
1378 classes.<foo>._static_methods: Enumerate static methods
1381 \begin_layout Itemize
1383 classes.<foo>._static_methods()
1386 \begin_layout Standard
1387 Returns all static methods of <foo> as strings.
1390 \begin_layout Subsection
1391 classes.<foo>._class_methods: Enumerate static methods
1394 \begin_layout Itemize
1396 classes.<foo>._class_methods()
1399 \begin_layout Standard
1400 Returns all class methods of <foo> as strings.
1403 \begin_layout Subsection
1404 classes.<foo>.<bar>: Static method
1407 \begin_layout Itemize
1408 Syntax: variable classes.<foo>.<bar>(variable...)
1411 \begin_layout Standard
1412 Invokes static method <bar> of class <foo>.
1415 \begin_layout Section
1419 \begin_layout Itemize
1420 Functions that draw to screen can only only be called in on_paint and on_video
1421 callbacks or if non-default render queue has been set.
1424 \begin_layout Itemize
1426 Bits 0-7 are the blue component, bits 8-15 are the green component, bits
1427 16-23 are the red component, bits 24-31 are alpha component (0 is fully
1428 opaque, 255 is almost transparent).
1429 -1 is the fully transparent color.
1430 Alternatively, colors can be given as strings naming the color.
1433 \begin_layout Itemize
1434 Alpha values greater than 127 do work properly.
1437 \begin_layout Itemize
1438 Origin of coordinates is at top left corner of game display area.
1439 Left and top gaps correspond to negative coordinates.
1442 \begin_layout Itemize
1443 The following color names are known: aliceblue antiquewhite antiquewhite1
1444 antiquewhite2 antiquewhite3 antiquewhite4 aqua aquamarine aquamarine1 aquamarin
1445 e2 aquamarine3 aquamarine4 azure azure1 azure2 azure3 azure4 beige bisque
1446 bisque1 bisque2 bisque3 bisque4 black blanchedalmond blue blue1 blue2 blue3
1447 blue4 blueviolet brown brown1 brown2 brown3 brown4 burlywood burlywood1
1448 burlywood2 burlywood3 burlywood4 cadet cadetblue cadetblue1 cadetblue2
1449 cadetblue3 cadetblue4 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse
1450 4 chocolate chocolate1 chocolate2 chocolate3 chocolate4 coral coral1 coral2
1451 coral3 coral4 cornflowerblue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4
1452 crimson cyan cyan1 cyan2 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgolden
1453 rod1 darkgoldenrod2 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey
1454 darkkhaki darkmagenta darkolivegreen darkolivegreen1 darkolivegreen2 darkoliveg
1455 reen3 darkolivegreen4 darkorange darkorange1 darkorange2 darkorange3 darkorange4
1456 darkorchid darkorchid1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon
1457 darkseagreen darkseagreen1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateb
1458 lue darkslategray darkslategray1 darkslategray2 darkslategray3 darkslategray4
1459 darkslategrey darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3
1460 deeppink4 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4
1461 dimgray dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4
1462 firebrick firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen
1463 fractal fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod
1464 goldenrod1 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100
1465 gray11 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20
1466 gray21 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30
1467 gray31 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40
1468 gray41 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50
1469 gray51 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60
1470 gray61 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70
1471 gray71 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80
1472 gray81 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90
1473 gray91 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1
1474 green2 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11
1475 grey12 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21
1476 grey22 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31
1477 grey32 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41
1478 grey42 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51
1479 grey52 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61
1480 grey62 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71
1481 grey72 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81
1482 grey82 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91
1483 grey92 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1
1484 honeydew2 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4
1485 indianred indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1
1486 ivory2 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
1487 lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
1488 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
1489 lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
1490 lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
1491 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
1492 lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
1493 lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
1494 lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
1495 lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
1496 lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
1497 lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
1498 maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
1499 mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
1500 mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
1501 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
1502 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
1503 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
1504 navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
1505 olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
1506 orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
1507 palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
1508 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
1509 palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
1510 peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
1511 pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
1512 purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
1513 rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
1514 saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
1515 seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
1516 seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
1517 skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
1518 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
1519 snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
1520 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
1521 tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
1522 tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
1523 turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
1524 wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
1525 yellow3 yellow4 yellowgreen hsl-{r,ry,o,y,yg,g,gc,c,cb,b,bm,m,mr}{0,1,2,3,4,5,6
1526 ,7,8}{0,1,2,3,4,5,6,7,8}.
1529 \begin_layout Itemize
1530 The following modifiers can be applied: opaque10, opaque20, opaque25, opaque30,
1531 opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
1532 hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
1535 \begin_layout Itemize
1536 HSL base color names: r => Red, ry => Red-Yellow (also o).
1537 y => Yellow, yg => Yellow-Green, g => Green, gc => Green-Cyan, c => Cyan,
1538 cb => Cyan-Blue, b => Blue, bm => Blue-Magenta, m => Magenta, mr => Magenta
1542 \begin_layout Itemize
1543 HSL colors use 8-step scales for saturation and lightness.
1546 \begin_layout Itemize
1547 Modifiers have opaqueness on percent scale (0 is transparent, 100 is fully
1551 \begin_layout Itemize
1552 Modifiers have Hue on 24-step scale (4 steps between R->Y->G->C->B->M->R).
1555 \begin_layout Itemize
1556 Modifiers have Saturation/Lightness on 16 step scale.
1559 \begin_layout Subsection
1560 gui.resolution: Get current resolution
1563 \begin_layout Itemize
1564 Syntax: (number, number) gui.resolution()
1567 \begin_layout Standard
1568 Returns 2-tuple (hresolution, vresolution).
1571 \begin_layout Subsection
1572 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
1575 \begin_layout Itemize
1576 Syntax: number gui.left_gap(number gap)
1579 \begin_layout Itemize
1580 Syntax: number gui.right_gap(number gap)
1583 \begin_layout Itemize
1584 Syntax: number gui.top_gap(number gap)
1587 \begin_layout Itemize
1588 Syntax: number gui.bottom_gap(number gap)
1591 \begin_layout Standard
1592 Set the specified edge gap to specified value <gap> (max gap is 8191).
1593 If successful, old gap is returned.
1596 \begin_layout Subsection
1597 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
1601 \begin_layout Itemize
1602 Syntax: number gui.delta_left_gap(number dgap)
1605 \begin_layout Itemize
1606 Syntax: number gui.delta_right_gap(number dgap)
1609 \begin_layout Itemize
1610 Syntax: number gui.delta_top_gap(number dgap)
1613 \begin_layout Itemize
1614 Syntax: number gui.delta_bottom_gap(number dgap)
1617 \begin_layout Standard
1618 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
1619 and return the old gap (returns nothing on error).
1622 \begin_layout Subsection
1623 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
1626 \begin_layout Itemize
1627 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
1631 \begin_layout Itemize
1632 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
1636 \begin_layout Itemize
1637 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
1641 \begin_layout Itemize
1642 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
1646 \begin_layout Standard
1647 Draw specified text on the GUI (each character cell is 8 or 16 wide and
1652 \begin_layout Itemize
1653 x: X-coordinate to start the drawing from (and x-coordinate at begining
1657 \begin_layout Itemize
1658 y: Y-coordinate to start the drawing from.
1661 \begin_layout Itemize
1662 text: The text to draw.
1665 \begin_layout Itemize
1666 fgc: Text color (default is 0xFFFFFF (white))
1669 \begin_layout Itemize
1670 bgc: Background color (default is -1 (transparent))
1673 \begin_layout Standard
1674 Note: The H variants draw at double width and V variants draw at double
1678 \begin_layout Subsection
1679 gui.rectangle: Draw a rectangle
1682 \begin_layout Itemize
1683 Syntax: none gui.rectangle(number x, number y, number width, number height[,
1684 number thickness[, number outline[, number fill]]])
1687 \begin_layout Standard
1688 Draw rectangle on the GUI.
1692 \begin_layout Itemize
1693 x: X-coordinate of left edge.
1696 \begin_layout Itemize
1697 y: Y-coordinate of upper edge.
1700 \begin_layout Itemize
1701 width: Width of rectangle.
1704 \begin_layout Itemize
1705 height: Height of rectangle.
1708 \begin_layout Itemize
1709 thickness: Thickness of outline (default is 1).
1712 \begin_layout Itemize
1713 outline: Color of outline (default is 0xFFFFFF (white))
1716 \begin_layout Itemize
1717 fill: Color of fill (default is -1 (transparent))
1720 \begin_layout Subsection
1721 gui.box: Draw a 3D-effect box
1724 \begin_layout Itemize
1725 Syntax: none gui.box(number x, number y, number width, number height[, number
1726 thickness[, number outline1[,number outline2[, number fill]]]])
1729 \begin_layout Standard
1730 Draw rectangle with 3D effect on the GUI.
1734 \begin_layout Itemize
1735 x: X-coordinate of left edge.
1738 \begin_layout Itemize
1739 y: Y-coordinate of upper edge.
1742 \begin_layout Itemize
1743 width: Width of rectangle.
1746 \begin_layout Itemize
1747 height: Height of rectangle.
1750 \begin_layout Itemize
1751 thickness: Thickness of outline (default is 1).
1754 \begin_layout Itemize
1755 outline1: First color of outline (default is 0xFFFFFF (white))
1758 \begin_layout Itemize
1759 outline2: First color of outline (default is 0x808080 (dark gray))
1762 \begin_layout Itemize
1763 fill: Color of fill (default is 0xC0C0C0 (light grayy))
1766 \begin_layout Subsection
1767 gui.pixel: Draw a single pixel
1770 \begin_layout Itemize
1771 Syntax: none gui.pixel(number x, number y[, number color])
1774 \begin_layout Standard
1775 Draw one pixel on the GUI.
1779 \begin_layout Itemize
1780 x: X-coordinate of the pixel
1783 \begin_layout Itemize
1784 y: Y-coordinate of the pixel
1787 \begin_layout Itemize
1788 color: Color of the pixel (default is 0xFFFFFF (white))
1791 \begin_layout Subsection
1792 gui.crosshair: Draw a crosshair
1795 \begin_layout Itemize
1796 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
1799 \begin_layout Standard
1804 \begin_layout Itemize
1805 x: X-coordinate of the crosshair
1808 \begin_layout Itemize
1809 y: Y-coordinate of the crosshair
1812 \begin_layout Itemize
1813 length: Length of the crosshair lines (default 10).
1816 \begin_layout Itemize
1817 color: Color of the crosshair (default is 0xFFFFFF (white))
1820 \begin_layout Subsection
1821 gui.line: Draw a line
1824 \begin_layout Itemize
1825 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
1829 \begin_layout Standard
1834 \begin_layout Itemize
1835 x1: X-coordinate of one end.
1838 \begin_layout Itemize
1839 y1: Y-coordinate of one end.
1842 \begin_layout Itemize
1843 x2: X-coordinate of the other end.
1846 \begin_layout Itemize
1847 y2: Y-coordinate of the other end.
1850 \begin_layout Itemize
1851 color: Color of the line (default is 0xFFFFFF (white)).
1854 \begin_layout Subsection
1855 gui.circle: Draw a (filled) circle
1858 \begin_layout Itemize
1859 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
1860 border[, number fil]]])
1863 \begin_layout Standard
1868 \begin_layout Itemize
1869 x: X-coordinate of the center
1872 \begin_layout Itemize
1873 y: Y-coordinate of the center
1876 \begin_layout Itemize
1877 r: The radius of the circle
1880 \begin_layout Itemize
1881 thick: Border thickness
1884 \begin_layout Itemize
1885 border: Border color (default is 0xFFFFFF (white))
1888 \begin_layout Itemize
1889 fill: Fill color (default is -1 (transparent)).
1892 \begin_layout Subsection
1893 gui.bitmap_draw/(D)BITMAP:draw: Draw a bitmap
1896 \begin_layout Itemize
1897 Syntax: none gui.bitmap_draw(number x, number y, BITMAP bitmap, PALETTE palette)
1900 \begin_layout Itemize
1901 Syntax: none gui.bitmap_draw(number x, number y, DBITMAP bitmap)
1904 \begin_layout Itemize
1905 Syntax: none BITMAP:draw(number x, number y, PALETTE palette)
1908 \begin_layout Itemize
1909 Syntax: none DBITMAP:draw(number x, number y)
1912 \begin_layout Standard
1913 Draw a bitmap <bitmap> (or object) on screen with specified palette <palette>
1914 (if bitmap is paletted) .
1918 \begin_layout Itemize
1919 x: X-coordinate of left edge.
1922 \begin_layout Itemize
1923 y: Y-coordinate of top edge.
1926 \begin_layout Itemize
1927 bitmap: The bitmap to draw
1930 \begin_layout Itemize
1931 palette: The palette to draw the bitmap using.
1934 \begin_layout Subsection
1935 gui.palette_new: Create a new palette
1938 \begin_layout Itemize
1939 Syntax: PALETTE gui.palette_new()
1942 \begin_layout Standard
1943 Returns a new palette (initially all transparent).
1947 \begin_layout Subsection
1948 gui.bitmap_new: Create a new bitmap
1951 \begin_layout Itemize
1952 Syntax: BITMAP/DBITMAP gui.bitmap_new(number w, number h, boolean direct[,
1956 \begin_layout Standard
1957 Returns a new bitmap/dbitmap.
1960 \begin_layout Standard
1964 \begin_layout Itemize
1965 w: The width of new bitmap
1968 \begin_layout Itemize
1969 h: The height of new bitmap
1972 \begin_layout Itemize
1973 direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
1976 \begin_layout Itemize
1977 icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
1980 \begin_layout Subsection
1981 gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
1984 \begin_layout Itemize
1985 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
1988 \begin_layout Itemize
1989 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
1992 \begin_layout Standard
1993 Reads file <file> (resolved relative to <base>) or string <content> and
1994 returns loaded bitmap/dbitmap (if bitmap, the second return value is palette
1998 \begin_layout Subsection
1999 gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
2002 \begin_layout Itemize
2003 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
2007 \begin_layout Itemize
2008 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
2011 \begin_layout Standard
2012 Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
2013 encoded content <content>.
2016 \begin_layout Itemize
2017 If the PNG is of color type 3 (PALETTE), returns two values.
2018 First is BITMAP containing the image data from the PNG and second is PALETTE
2019 containg the palette data from the PNG.
2022 \begin_layout Itemize
2023 For color types 0 (GRAY), 2 (RGB), 4 (GRAY_ALPHA) and 6 (RGBA), returns
2024 one DBITMAP containg the image data loaded from the PNG.
2027 \begin_layout Subsection
2028 gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
2031 \begin_layout Itemize
2032 Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
2035 \begin_layout Itemize
2036 Syntax: PALETTE gui.bitmap_load_pal_str(string content)
2039 \begin_layout Standard
2040 Load a palette from file <file>(resolved relative to <base>) or string <content>.
2043 \begin_layout Itemize
2044 The kinds of lines supported:
2048 \begin_layout Itemize
2049 Blank or just whitespace: Ignored
2052 \begin_layout Itemize
2053 First non-whitespace is '#': Ignored
2056 \begin_layout Itemize
2057 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
2060 \begin_layout Itemize
2061 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
2062 (0-256, 0 being fully transparent and 256 fully opaque).
2065 \begin_layout Itemize
2066 transparent: Fully transparent color
2070 \begin_layout Subsection
2071 gui.palette_set/PALETTE:set: Set palette entry
2074 \begin_layout Itemize
2075 Syntax: none gui.palette_set(PALETTE palette, number index, number color)
2078 \begin_layout Itemize
2079 Syntax: none PALETTE:set(number index, number color)
2082 \begin_layout Standard
2083 Sets color in palette.
2087 \begin_layout Itemize
2088 palette: The palette to manipulate
2091 \begin_layout Itemize
2092 index: Index of color (0-65535).
2095 \begin_layout Itemize
2096 color: The color value.
2099 \begin_layout Subsection
2100 gui.bitmap_pset/(D)BITMAP:pset: Set pixel in bitmap
2103 \begin_layout Itemize
2104 Syntax: none gui.bitmap_pset(BITMAP/DBITMAP bitmap, number x, number y, number
2108 \begin_layout Itemize
2109 Syntax: none BITMAP:pset(number x, number y, number color)
2112 \begin_layout Itemize
2113 Syntax: none DBITMAP:pset(number x, number y, number color)
2116 \begin_layout Standard
2117 Sets specified pixel in bitmap.
2121 \begin_layout Itemize
2122 bitmap: The bitmap to manipulate
2125 \begin_layout Itemize
2126 x: The x-coordinate of the pixel.
2129 \begin_layout Itemize
2130 y: The y-coordinate of the pixel.
2133 \begin_layout Itemize
2134 color: If bitmap is a bitmap, color index (0-65535).
2135 Otherwise color value.
2138 \begin_layout Subsection
2139 gui.bitmap_pget/(D)BITMAP:pget: Get pixel in bitmap
2142 \begin_layout Itemize
2143 Syntax: number gui.bitmap_pget(BITMAP/DBITMAP bitmap, number x, number y)
2146 \begin_layout Itemize
2147 Syntax: number BITMAP:pget(number x, number y)
2150 \begin_layout Itemize
2151 Syntax: number DBITMAP:pget(number x, number y)
2154 \begin_layout Standard
2155 Gets specified pixel in bitmap.
2159 \begin_layout Itemize
2160 bitmap: The bitmap to query
2163 \begin_layout Itemize
2164 x: The x-coordinate of the pixel.
2167 \begin_layout Itemize
2168 y: The y-coordinate of the pixel.
2171 \begin_layout Standard
2172 The bitmap color (color index if paletted, otherwise color value).
2175 \begin_layout Subsection
2176 gui.bitmap_size/(D)BITMAP:size: Get size of bitmap
2179 \begin_layout Itemize
2180 Syntax: (number, number) gui.bitmap_size(BITMAP/DBITMAP bitmap)
2183 \begin_layout Itemize
2184 Syntax: (number, number) BITMAP:size()
2187 \begin_layout Itemize
2188 Syntax: (number, number) DBITMAP:size()
2191 \begin_layout Standard
2192 Get size of bitmap <bitmap>.
2193 The first return is the width, the second is the height.
2196 \begin_layout Itemize
2197 Note: Can be used anywhere.
2200 \begin_layout Subsection
2201 gui.bitmap_blit/(D)BITMAP:blit: Blit a bitmap into another
2204 \begin_layout Itemize
2205 Syntax: none gui.bitmap_blit(BITMAP dest, number dx, number dy, BITMAP src,
2206 number sx, number sy, number w, number h[, number ck])
2209 \begin_layout Itemize
2210 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, DBITMAP
2211 src, number sx, number sy, number w, number h[, number ck])
2214 \begin_layout Itemize
2215 Syntax: none gui.bitmap_blit(DBITMAP dest, number dx, number dy, BITMAP src,
2216 PALETTE pal, number sx, number sy, number w, number h[, number ck])
2219 \begin_layout Itemize
2220 Syntax: none BITMAP::blit(number dx, number dy, BITMAP src, number sx, number
2221 sy, number w, number h[, number ck])
2224 \begin_layout Itemize
2225 Syntax: none DBITMAP::blit(number dx, number dy, DBITMAP src, number sx,
2226 number sy, number w, number h[, number ck])
2229 \begin_layout Itemize
2230 Syntax: none DBITMAP:blit(number dx, number dy, BITMAP src, PALETTE pal,
2231 number sx, number sy, number w, number h[, number ck])
2234 \begin_layout Standard
2235 Blit a part of bitmap to another (current object if any is destination).
2239 \begin_layout Itemize
2240 dest: Destination to blit to.
2243 \begin_layout Itemize
2244 dx: left edge of target
2247 \begin_layout Itemize
2248 dy: Top edge of target
2251 \begin_layout Itemize
2252 src: The source to blit from.
2255 \begin_layout Itemize
2256 pal: The palette to use in blit.
2259 \begin_layout Itemize
2260 sx: left edge of source
2263 \begin_layout Itemize
2264 sy: Top edge of source
2267 \begin_layout Itemize
2271 \begin_layout Itemize
2272 h: Height of region.
2275 \begin_layout Itemize
2277 Pixels of this color are not blitted.
2281 \begin_layout Itemize
2282 If soruce bitmap is bitmap, this is color index of colorkey.
2283 Values outside range 0-65535 cause no key to be used as colorkey.
2286 \begin_layout Itemize
2287 If source bitmap is dbitmap, this is the color value of colorkey.
2290 \begin_layout Itemize
2291 May be absent or nil for no colorkey blit.
2295 \begin_layout Subsection
2296 gui.bitmap_blit_scaled/(D)BITMAP:blit_scaled: Blit a bitmap into another
2300 \begin_layout Itemize
2301 Syntax: none gui.bitmap_blit_scaled(BITMAP dest, number dx, number dy, BITMAP
2302 src, number sx, number sy, number w, number h, number hscl[, number vscl[,
2306 \begin_layout Itemize
2307 Syntax: none gui.bitmap_blit_scaled(DBITMAP dest, number dx, number dy, DBITMAP
2308 src, number sx, number sy, number w, number h, number hscl[, number vscl[,
2312 \begin_layout Itemize
2313 Syntax: none gui.bitmap_blit_scaled(DBITMAP dest, number dx, number dy, BITMAP
2314 src, PALETTE pal, number sx, number sy, number w, number h, number hscl[,
2315 number vscl[, number ck]])
2318 \begin_layout Itemize
2319 Syntax: none BITMAP::blit_scaled(number dx, number dy, BITMAP src, number
2320 sx, number sy, number w, number h, number hscl[, number vscl[, number ck]])
2323 \begin_layout Itemize
2324 Syntax: none DBITMAP::blit_scaled(number dx, number dy, DBITMAP src, number
2325 sx, number sy, number w, number h, number hscl[, number vscl[, number ck]])
2328 \begin_layout Itemize
2329 Syntax: none DBITMAP:blit_scaled(number dx, number dy, BITMAP src, PALETTE
2330 pal, number sx, number sy, number w, number h, number hscl[, number vscl[,
2334 \begin_layout Standard
2335 Like (D)BITMAP:blit, but also scale the image horizontally by <hscl> and
2336 vertically by <vscl> (if not specified, <vscl> defaults to <hscl>).
2339 \begin_layout Subsection
2340 gui.bitmap_blit_porterduff/(D)BITMAP:blit_porterduff: Blit a bitmap into
2341 another with Porter-Duff composition
2344 \begin_layout Itemize
2345 Syntax: none gui.bitmap_blit_porterduff(BITMAP dest, number dx, number dy,
2346 BITMAP src, number sx, number sy, number w, number h, string operator)
2349 \begin_layout Itemize
2350 Syntax: none gui.bitmap_blit_porterduff(DBITMAP dest, number dx, number dy,
2351 DBITMAP src, number sx, number sy, number w, number h, string operator)
2354 \begin_layout Itemize
2355 Syntax: none gui.bitmap_blit_porterduff(DBITMAP dest, number dx, number dy,
2356 BITMAP src, PALETTE pal, number sx, number sy, number w, number h, string
2360 \begin_layout Itemize
2361 Syntax: none BITMAP::blit_porterduff(number dx, number dy, BITMAP src, number
2362 sx, number sy, number w, number h, string operator)
2365 \begin_layout Itemize
2366 Syntax: none DBITMAP::blit_porterduff(number dx, number dy, DBITMAP src,
2367 number sx, number sy, number w, number h, string operator)
2370 \begin_layout Itemize
2371 Syntax: none DBITMAP:blit_porterduff(number dx, number dy, BITMAP src, PALETTE
2372 pal, number sx, number sy, number w, number h, string operator)
2375 \begin_layout Standard
2376 Like (D)BITMAP:blit, but applying specified Porter-Duff operator.
2377 BITMAPs always have color 0 treated as background, DBITMAPs treat full
2378 opaque as background.
2379 <operator> may be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver,
2380 DestIn, DestOut, Clear or Xor.
2383 \begin_layout Subsection
2384 gui.bitmap_blit_scaled_porterduff/(D)BITMAP:blit_scaled_porterduff: Blit
2385 a bitmap into another with scaling and Porter-Duff composition
2388 \begin_layout Itemize
2389 Syntax: none gui.bitmap_blit_scaled_porterduff(BITMAP dest, number dx, number
2390 dy, BITMAP src, number sx, number sy, number w, number h, number hscl,
2391 number vscl, string operator)
2394 \begin_layout Itemize
2395 Syntax: none gui.bitmap_blit_scaled_porterduff(DBITMAP dest, number dx, number
2396 dy, DBITMAP src, number sx, number sy, number w, number h, number hscl,
2397 number vscl, string operator)
2400 \begin_layout Itemize
2401 Syntax: none gui.bitmap_blit_scaled_porterduff(DBITMAP dest, number dx, number
2402 dy, BITMAP src, PALETTE pal, number sx, number sy, number w, number h,
2403 number hscl, number vscl, string operator)
2406 \begin_layout Itemize
2407 Syntax: none BITMAP::blit_scaled_porterduff(number dx, number dy, BITMAP
2408 src, number sx, number sy, number w, number h, number hscl, number vscl,
2412 \begin_layout Itemize
2413 Syntax: none DBITMAP::blit_scaled_porterduff(number dx, number dy, DBITMAP
2414 src, number sx, number sy, number w, number h, number hscl, number vscl,
2418 \begin_layout Itemize
2419 Syntax: none DBITMAP:blit_scaled_porterduff(number dx, number dy, BITMAP
2420 src, PALETTE pal, number sx, number sy, number w, number h, number hscl,
2421 number vscl, string operator)
2424 \begin_layout Standard
2425 Like (D)BITMAP:blit_porterduff, but also scale the image horizontally by
2426 <hscl> and vertically by <vscl> (if nil, <vscl> defaults to <hscl>).
2429 \begin_layout Subsection
2430 gui.bitmap_blit_priority/BITMAP:blit_priority: Blit a bitmap into another
2434 \begin_layout Itemize
2435 Syntax: none gui.bitmap_blit_priority(BITMAP dest, number dx, number dy,
2436 BITMAP src, number sx, number sy, number w, number h)
2439 \begin_layout Itemize
2440 Syntax: none BITMAP::blit_priority(number dx, number dy, BITMAP src, number
2441 sx, number sy, number w, number h)
2444 \begin_layout Standard
2445 Like BITMAP:blit, but copy a pixel only if source palette index is greater
2446 than destination palette index.
2449 \begin_layout Subsection
2450 gui.bitmap_blit_scaled_priority/BITMAP:blit_scaled_priority: Blit a bitmap
2451 into another with color priority and scaling
2454 \begin_layout Itemize
2455 Syntax: none gui.bitmap_blit_scaled_priority(BITMAP dest, number dx, number
2456 dy, BITMAP src, number sx, number sy, number w, number h, number hscl[,
2460 \begin_layout Itemize
2461 Syntax: none BITMAP::blit_scaled_priority(number dx, number dy, BITMAP src,
2462 number sx, number sy, number w, number h, number hscl[, number vscl])
2465 \begin_layout Standard
2466 Like BITMAP:blit_scaled, but copy a pixel only if source palette index is
2467 greater than destination palette index.
2470 \begin_layout Subsection
2471 gui.repaint: Arrange a repaint
2474 \begin_layout Itemize
2475 Syntax: none gui.repaint()
2478 \begin_layout Standard
2479 Request on_repaint() to happen as soon as possible.
2482 \begin_layout Subsection
2483 gui.subframe_update: Enable/Disable subframe updates
2486 \begin_layout Itemize
2487 Syntax: none gui.subframe_update(boolean on)
2490 \begin_layout Standard
2491 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
2492 or not happen (<on>=false).
2495 \begin_layout Subsection
2496 gui.screenshot: Write a screenshot
2499 \begin_layout Itemize
2500 Syntax: none gui.screenshot(string filename)
2503 \begin_layout Standard
2504 Write PNG screenshot of the current frame (no drawings) to specified file
2508 \begin_layout Subsection
2509 gui.screenshot_bitmap: Write a screenshot to bitmap
2512 \begin_layout Itemize
2513 Syntax: DBITMAP gui.screenshot_bitmap()
2516 \begin_layout Standard
2517 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
2521 \begin_layout Subsection
2522 gui.color: Compose a color.
2525 \begin_layout Itemize
2526 Syntax: number gui.color(number r, number g, number b[, number a])
2529 \begin_layout Itemize
2530 Syntax: number gui.color(string c)
2533 \begin_layout Standard
2534 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
2535 , each component in scale 0-255.
2536 If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
2538 The default alpha is 256.
2541 \begin_layout Standard
2542 The form taking a string returns color corresponding color name.
2545 \begin_layout Subsection
2546 gui.status: Set status variable
2549 \begin_layout Itemize
2550 Syntax: none gui.status(string name, string value)
2553 \begin_layout Standard
2555 \begin_inset Quotes eld
2559 \begin_inset Quotes erd
2562 to <value> in status area.
2565 \begin_layout Subsection
2566 gui.rainbow: Rainbow color calculation
2569 \begin_layout Itemize
2570 Syntax: number gui.rainbow(number step, number steps[, number color])
2573 \begin_layout Standard
2574 Perform hue rotation of color <color> (default bright red), by <step> steps.
2575 The number of steps per full rotation is given by absolute value of <steps>.
2578 \begin_layout Standard
2579 If <step> is negative, the rotation will be counterclockwise.
2582 \begin_layout Subsection
2583 gui.loadfont: Load a font file
2586 \begin_layout Itemize
2587 Syntax: CUSTOMFONT gui.loadfont([string filename[, string relative_to]])
2590 \begin_layout Standard
2591 Loads font from specified file (CUSTOMFONT object).
2592 If filename is not given, loads the system default font.
2595 \begin_layout Subsection
2596 gui.font_new: Return a new empty font
2599 \begin_layout Itemize
2600 Syntax: CUSTOMFONT gui.font_new()
2603 \begin_layout Standard
2604 Returns a new font with no characters.
2607 \begin_layout Subsection
2608 CUSTOMFONT(): Render text to screen
2611 \begin_layout Itemize
2612 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
2613 bgc[, number hlc]]])
2616 \begin_layout Standard
2617 Draw string with custom font to screen.
2618 The parameters are the same as in gui.text, except <hlc> is the halo color
2619 (default is no halo).
2623 \begin_layout Subsection
2624 CUSTOMFONT:edit: Alter glyph in font
2627 \begin_layout Itemize
2628 Syntax: none CUSTOMFONT:edit(string character, BITMAP glyph)
2631 \begin_layout Standard
2632 Alter the character <character> (UTF-8 encoded) in font to use glyph specified
2634 The conversion to monochrome is done by treating color 0 as background,
2635 and everything else as foreground.
2638 \begin_layout Standard
2639 If <character> is empty string, the bad glyph is edited.
2640 If <character> has multiple characters, corresponding ligature glyph is
2644 \begin_layout Subsection
2645 gui.adjust_transparency/DBITMAP:adjust_transparency/PALETTE:adjust_transparency:
2646 Adjust transparency of DBITMAP or PALETTE
2649 \begin_layout Itemize
2650 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
2653 \begin_layout Itemize
2654 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
2657 \begin_layout Itemize
2658 Syntax: none DBITMAP:adjust_transparency(number adj)
2661 \begin_layout Itemize
2662 Syntax: none PALETTE:adjust_transparency(number adj)
2665 \begin_layout Standard
2666 Multiply alpha channel of <obj> by <adj>/256.
2668 \begin_inset Quotes eld
2672 \begin_inset Quotes erd
2675 out of solid bitmaps.
2678 \begin_layout Subsection
2679 gui.kill_frame: Kill video frame and associated sound
2682 \begin_layout Itemize
2683 Syntax: none gui.kill_frame()
2686 \begin_layout Standard
2687 Kills the currently dumped video frame + the associated sound.
2688 Only valid in on_video callback.
2691 \begin_layout Subsection
2692 gui.set_video_scale: Set video frame scale
2695 \begin_layout Itemize
2696 Syntax: none gui.set_video_scale(number h, number v)
2699 \begin_layout Standard
2700 Sets the scale factors of current frame to <h>x<v>.
2701 Only valid in on_video callback.
2704 \begin_layout Subsection
2705 gui.arrow: Draw an arrow
2708 \begin_layout Itemize
2709 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
2710 number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
2714 \begin_layout Standard
2715 Draws an arrow using color <color>.
2716 The tip of arrow is at (<x>, <y>).
2720 \begin_layout Enumerate
2721 <length>: The length of arrow tail.
2724 \begin_layout Enumerate
2725 <hwidth>: The width of arrow head.
2729 \begin_layout Enumerate
2730 <direction>: Direction of arrow.
2731 0 is to right, +1 rotates 45 degrees counterclockwise.
2734 \begin_layout Enumerate
2735 <fill>: If true, fill the arrow head.
2739 \begin_layout Enumerate
2740 <twidth>: Tail width.
2745 \begin_layout Enumerate
2746 <hthick>: Head thickness (only used if <fill> is false).
2747 Default is <twidth>.
2750 \begin_layout Subsection
2751 gui.bitmap_save_png/(D)BITMAP:save_png: Save a bitmap to PNG
2754 \begin_layout Itemize
2755 Syntax: none gui.bitmap_save_png(string filename[, string base], BITMAP bmp,
2759 \begin_layout Itemize
2760 Syntax: none gui.bitmap_save_png(string filename[, string base], DBITMAP
2764 \begin_layout Itemize
2765 Syntax: string gui.bitmap_save_png(BITMAP bmp, PALETTE pal)
2768 \begin_layout Itemize
2769 Syntax: string gui.bitmap_save_png(DBITMAP bmp)
2772 \begin_layout Itemize
2773 Syntax: none BITMAP:save_png(string filename[, string base], PALETTE pal)
2776 \begin_layout Itemize
2777 Syntax: none DBITMAP:save_png(string filename[, string base])
2780 \begin_layout Itemize
2781 Syntax: string BITMAP:save_png(PALETTE pal)
2784 \begin_layout Itemize
2785 Syntax: string DBITMAP:save_png()
2788 \begin_layout Standard
2789 Save specified bitmap <bmp> (or current object), with palette <pal> (only
2790 if paletted) into PNG file <filename> (relative to <base>) or return BASE64
2791 encoding as return value.
2794 \begin_layout Subsection
2795 gui.bitmap_hash/(D)BITMAP:hash: Hash a bitmap
2798 \begin_layout Itemize
2799 Syntax: string gui.bitmap_hash(BITMAP bmp)
2802 \begin_layout Itemize
2803 Syntax: string gui.bitmap_hash(DBITMAP bmp)
2806 \begin_layout Itemize
2807 Syntax: string BITMAP:hash()
2810 \begin_layout Itemize
2811 Syntax: string DBITMAP:hash()
2814 \begin_layout Standard
2815 Hashes bitmap <bmp> (or current object) and returns 64-hex digit crypto-strong
2817 Identical bitmaps result in indentical hashes (but color order in indexed
2818 bitmaps is significant).
2821 \begin_layout Subsection
2822 gui.palette_hash/PALETTE:hash: Hash a palette
2825 \begin_layout Itemize
2826 Syntax: string gui.palette_hash(PALETTE pal)
2829 \begin_layout Itemize
2830 Syntax: string PALETTE:hash(PALETTE pal)
2833 \begin_layout Standard
2834 Hashes palette <pal> (or current object) and retruns 64-hex digit crypto-strong
2836 Identical palettes result in identical hashes (fully transparent colors
2837 at end of palette don't affect the hash).
2840 \begin_layout Standard
2841 \begin_inset Newpage pagebreak
2847 \begin_layout Section
2851 \begin_layout Standard
2853 Functions manipulating input are only available in on_input callback.
2856 \begin_layout Subsection
2857 input.get: Read controller button/axis (deprecated)
2860 \begin_layout Itemize
2861 Syntax: number input.get(number controller, number index)
2864 \begin_layout Standard
2865 Read the specified index <index> (zero-based) from specified controller
2866 <controller> (zero-based).
2870 \begin_layout Subsection
2871 input.set: Write controller button/axis (deprecated)
2874 \begin_layout Itemize
2875 Syntax: none input.set(number controller, number index, number value)
2878 \begin_layout Standard
2879 Write the specified index <index> (zero-based) from specified controller
2880 <controller> (zero-based), storing value <value>.
2883 \begin_layout Subsection
2884 input.get2: Read controller button/axis
2887 \begin_layout Itemize
2888 Syntax: number input.get2(number port, number controller, number index)
2891 \begin_layout Standard
2892 Read the specified input tuple.
2893 Port 0 is system port.
2896 \begin_layout Subsection
2897 input.set2: Write controller button/axis
2900 \begin_layout Itemize
2901 Syntax: input.set2(number port, number controller, number index, number value)
2904 \begin_layout Standard
2905 Write the specified input tuple.
2906 Port 0 is system port.
2909 \begin_layout Subsection
2910 input.lcid_to_pcid2: Look up logical controller
2913 \begin_layout Itemize
2914 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
2917 \begin_layout Standard
2918 Look up physical pcid pair (port, controller) corresponding to specified
2919 logical controller (1-based).
2920 Returns nothing if controller does not exist.
2923 \begin_layout Subsection
2924 input.port_type: Look up port type
2927 \begin_layout Itemize
2928 Syntax: string input.port_type(number port)
2931 \begin_layout Standard
2932 Return type of specified port.
2935 \begin_layout Subsection
2936 input.controller_info: Get information about controller
2939 \begin_layout Itemize
2940 Syntax: table input.controller_info(number port, number controller)
2943 \begin_layout Standard
2944 Get controller info for specified controller.
2945 If controller does not exist, returns nil.
2946 Otherwise returns a table with following fields:
2949 \begin_layout Itemize
2950 type (string): Type of the controller.
2953 \begin_layout Itemize
2954 class (string): Class of the controller.
2957 \begin_layout Itemize
2958 classnum (number): Number of the controller within its class (1-based)
2961 \begin_layout Itemize
2962 lcid (number): Logical controller number of the controller.
2965 \begin_layout Itemize
2966 button_count (number): Number of buttons on controller
2969 \begin_layout Itemize
2970 buttons (array): Array of following info about each button:
2974 \begin_layout Itemize
2975 type (string): Type of button.
2977 \begin_inset Quotes eld
2981 \begin_inset Quotes erd
2985 \begin_inset Quotes eld
2989 \begin_inset Quotes erd
2993 \begin_inset Quotes eld
2997 \begin_inset Quotes erd
3001 \begin_inset Quotes eld
3005 \begin_inset Quotes erd
3011 \begin_layout Itemize
3012 name (string): Name of button.
3015 \begin_layout Itemize
3016 symbol (string): Symbol of button.
3017 Only present for type
3018 \begin_inset Quotes eld
3022 \begin_inset Quotes erd
3028 \begin_layout Itemize
3029 hidden (boolean): True if hidden button.
3034 \begin_layout Subsection
3035 input.veto_button: Veto a button press
3038 \begin_layout Itemize
3039 Syntax: none input.veto_button()
3042 \begin_layout Standard
3043 Signals that the button event should be vetoed.
3044 Only valid in on_button callback.
3047 \begin_layout Subsection
3048 input.geta: Get all buttons for controller (deprecated)
3051 \begin_layout Itemize
3052 Syntax: (number, number...) input.geta(number controller)
3055 \begin_layout Standard
3056 Get input state for entiere controller.
3057 Returns n return values.
3060 \begin_layout Itemize
3061 1st return value: Bitmask: bit i is set if i:th index is nonzero
3064 \begin_layout Itemize
3065 2nd- return value: value of i:th index.
3068 \begin_layout Subsection
3069 input.seta: Set all buttons for controller (deprecated)
3072 \begin_layout Itemize
3073 Syntax: none input.seta(number controller, number bitmask, number args...)
3076 \begin_layout Standard
3077 Set state for entiere controller.
3078 args is up to N values for indices (overriding values in bitmask if specified).
3081 \begin_layout Subsection
3082 input.controllertype: Get controller type (deprecated)
3085 \begin_layout Itemize
3086 syntax: string input.controllertype(number controller)
3089 \begin_layout Standard
3090 Get the type of controller as string.
3093 \begin_layout Subsection
3094 input.reset: Execute (delayed) reset
3097 \begin_layout Itemize
3098 Syntax: none input.reset([number cycles])
3101 \begin_layout Standard
3103 If <cycles> is greater than zero, do delayed reset.
3104 0 (or no value) causes immediate reset.
3107 \begin_layout Itemize
3108 Note: Only available with subframe flag false.
3111 \begin_layout Subsection
3112 input.raw: Return raw input data
3115 \begin_layout Itemize
3116 Syntax: table input.raw()
3119 \begin_layout Standard
3120 Returns table of tables of all available keys and axes.
3121 The first table is indexed by key name (platform-dependent!), and the inner
3122 table has the following fields:
3125 \begin_layout Itemize
3126 value: Last reported value for control
3130 \begin_layout Itemize
3131 For keys: 1 for pressed, 0 for released.
3134 \begin_layout Itemize
3135 For axes: -32767...32767.
3138 \begin_layout Itemize
3139 For presure-sensitive buttons: 0...32767.
3142 \begin_layout Itemize
3143 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
3146 \begin_layout Itemize
3147 For mouse: Coordinates relative to game area.
3151 \begin_layout Itemize
3152 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
3155 \begin_layout Subsection
3156 input.keyhook: Hook a key
3159 \begin_layout Itemize
3160 Syntax: none input.keyhook(string key, boolean state)
3163 \begin_layout Standard
3164 Requests that keyhook events to be sent for key <key> (<state>=true) or
3165 not sent (<state>=false).
3168 \begin_layout Subsection
3169 input.joyget: Get controls for controller
3172 \begin_layout Itemize
3173 Syntax: table input.joyget(number logical)
3176 \begin_layout Standard
3177 Returns table for current controls for specified logical controller <logical>.
3178 The names of fields vary by controller type.
3181 \begin_layout Itemize
3182 The buttons have the same name as those are referred to in other contexts
3186 \begin_layout Itemize
3187 The analog axes are usually
3188 \begin_inset Quotes eld
3192 \begin_inset Quotes erd
3196 \begin_inset Quotes eld
3200 \begin_inset Quotes erd
3206 \begin_layout Itemize
3207 Each field is numeric or boolean depending on axis/button.
3210 \begin_layout Subsection
3211 input.joyset: Set controls for controller
3214 \begin_layout Itemize
3215 Syntax: none input.joyset(number controller, table controls)
3218 \begin_layout Standard
3219 Set the the state of specified controller to values specified in specified
3223 \begin_layout Itemize
3224 Each field can be boolean or number.
3227 \begin_layout Itemize
3228 Also, buttons allow strings, which cause value to be inverted.
3231 \begin_layout Subsection
3232 input.lcid_to_pcid: Look up logical controller (deprecated)
3235 \begin_layout Itemize
3236 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
3239 \begin_layout Standard
3240 Returns the legacy pcid for controller (or false if there isn't one), followed
3242 Returns nothing if controller does not exist.
3245 \begin_layout Standard
3246 \begin_inset Newpage pagebreak
3252 \begin_layout Section
3256 \begin_layout Standard
3257 Various keybinding-related functions
3260 \begin_layout Subsection
3261 keyboard.bind: Bind a key
3264 \begin_layout Itemize
3265 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
3268 \begin_layout Standard
3269 Bind specified key with specified modifers to specified command.
3272 \begin_layout Subsection
3273 keyboard.unbind: Unbind a key
3276 \begin_layout Itemize
3277 Syntax: none keyboard.unbind(string mod, string mask, string key)
3280 \begin_layout Standard
3281 Unbind specified key with specified modifers.
3284 \begin_layout Subsection
3285 keyboard.alias: Set alias expansion
3288 \begin_layout Itemize
3289 Syntax: none keyboard.alias(string alias, string expansion)
3292 \begin_layout Standard
3293 Set expansion of given command.
3296 \begin_layout Standard
3297 \begin_inset Newpage pagebreak
3303 \begin_layout Section
3307 \begin_layout Standard
3311 \begin_layout Subsection
3312 subtitle.byindex: Look up start and length of subtitle by index
3315 \begin_layout Itemize
3316 Syntax: (number, number) subtitle.byindex(number i)
3319 \begin_layout Standard
3320 Read the frame and length of ith subtitle.
3321 Returns nothing if not present.
3324 \begin_layout Subsection
3325 subtitle.set: Write a subtitle
3328 \begin_layout Itemize
3329 Syntax: none subtitle.set(number f, number l, string txt)
3332 \begin_layout Standard
3333 Set the text of subtitle.
3336 \begin_layout Subsection
3337 subtitle.get: Read a subtitle
3340 \begin_layout Itemize
3341 Syntax: string subtitle.get(number f, number l)
3344 \begin_layout Standard
3345 Get the text of subtitle.
3348 \begin_layout Subsection
3349 subtitle.delete: Delete a subtitle
3352 \begin_layout Itemize
3353 Syntax: nonesubtitle.delete(number f, number l)
3356 \begin_layout Standard
3357 Delete specified subtitle.
3360 \begin_layout Standard
3361 \begin_inset Newpage pagebreak
3367 \begin_layout Section
3371 \begin_layout Standard
3372 Host memory handling (extra memory saved to savestates).
3373 Host memory starts empty.
3376 \begin_layout Itemize
3377 Reads out of range return false.
3380 \begin_layout Itemize
3381 Writes out of range extend the memory.
3384 \begin_layout Subsection
3385 hostmemory.read: Read byte from host memory
3388 \begin_layout Itemize
3389 Syntax: number hostmemory.read(number address)
3392 \begin_layout Standard
3393 Reads byte from hostmemory slot address <address>.
3396 \begin_layout Subsection
3397 hostmemory.write: Write byte to host memory
3400 \begin_layout Itemize
3401 Syntax: none hostmemory.write(number address, number value)
3404 \begin_layout Standard
3405 Writes hostmemory slot with value <value> 0-255.
3408 \begin_layout Subsection
3409 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
3412 \begin_layout Itemize
3413 Syntax: number hostmemory.readbyte(number address)
3416 \begin_layout Itemize
3417 Syntax: number hostmemory.readsbyte(number address)
3420 \begin_layout Itemize
3421 Syntax: number hostmemory.readword(number address)
3424 \begin_layout Itemize
3425 Syntax: number hostmemory.readsword(number address)
3428 \begin_layout Itemize
3429 Syntax: number hostmemory.readhword(number address)
3432 \begin_layout Itemize
3433 Syntax: number hostmemory.readshword(number address)
3436 \begin_layout Itemize
3437 Syntax: number hostmemory.readdword(number address)
3440 \begin_layout Itemize
3441 Syntax: number hostmemory.readsdword(number address)
3444 \begin_layout Itemize
3445 Syntax: number hostmemory.readqword(number address)
3448 \begin_layout Itemize
3449 Syntax: number hostmemory.readsqword(number address)
3452 \begin_layout Standard
3453 Read elements (big-endian) from given address <address>.
3456 \begin_layout Itemize
3460 \begin_layout Itemize
3464 \begin_layout Itemize
3468 \begin_layout Itemize
3472 \begin_layout Itemize
3473 qword is 8 elements.
3476 \begin_layout Itemize
3477 The 's' variants do signed read.
3480 \begin_layout Subsection
3481 hostmemory.read{float,double}: Read from host memory
3484 \begin_layout Itemize
3485 syntax: number hostmemory.readfloat(number address)
3488 \begin_layout Itemize
3489 Syntax: number hostmemory.readdouble(number address)
3492 \begin_layout Standard
3493 Read elements (big-endian) floating-pont from given address <address>.
3496 \begin_layout Subsection
3497 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
3500 \begin_layout Itemize
3501 Syntax: number hostmemory.writebyte(number address, number value)
3504 \begin_layout Itemize
3505 Syntax: number hostmemory.writesbyte(number address, number value)
3508 \begin_layout Itemize
3509 Syntax: number hostmemory.writeword(number address, number value)
3512 \begin_layout Itemize
3513 Syntax: number hostmemory.writesword(number address, number value)
3516 \begin_layout Itemize
3517 Syntax: number hostmemory.writehword(number address, number value)
3520 \begin_layout Itemize
3521 Syntax: number hostmemory.writeshword(number address, number value)
3524 \begin_layout Itemize
3525 Syntax: number hostmemory.writedword(number address, number value)
3528 \begin_layout Itemize
3529 Syntax: number hostmemory.writesdword(number address, number value)
3532 \begin_layout Itemize
3533 Syntax: number hostmemory.writeqword(number address, number value)
3536 \begin_layout Itemize
3537 Syntax: number hostmemory.writesqword(number address, number value)
3540 \begin_layout Standard
3541 Write value <value> to elements (little-endian) starting from given address
3545 \begin_layout Itemize
3549 \begin_layout Itemize
3553 \begin_layout Itemize
3557 \begin_layout Itemize
3561 \begin_layout Itemize
3562 qword is 8 elements.
3565 \begin_layout Itemize
3566 The 's' variants do signed write.
3569 \begin_layout Subsection
3570 hostmemory.write{float,double}: Write to host memory
3573 \begin_layout Itemize
3574 syntax: none hostmemory.readfloat(number address, number value)
3577 \begin_layout Itemize
3578 Syntax: none hostmemory.readdouble(number address, number value)
3581 \begin_layout Standard
3582 Write elements (big-endian) floating-pont to given address <address>, storing
3586 \begin_layout Standard
3587 \begin_inset Newpage pagebreak
3593 \begin_layout Section
3597 \begin_layout Standard
3601 \begin_layout Subsection
3602 movie.currentframe: Get current frame number
3605 \begin_layout Itemize
3606 Syntax: number movie.currentframe()
3609 \begin_layout Standard
3610 Return number of current frame.
3613 \begin_layout Subsection
3614 movie.framecount: Get move frame count
3617 \begin_layout Itemize
3618 Syntax: number movie.framecount()
3621 \begin_layout Standard
3622 Return number of frames in movie.
3625 \begin_layout Subsection
3626 movie.readonly: Is in readonly mode?
3629 \begin_layout Itemize
3630 Syntax: boolean movie.readonly()
3633 \begin_layout Standard
3634 Return true if in readonly mode, false if in readwrite.
3637 \begin_layout Subsection
3638 movie.rerecords: Movie rerecord count
3641 \begin_layout Itemize
3642 Syntax: number movie.rerecords()
3645 \begin_layout Standard
3646 Returns the current value of rerecord count.
3649 \begin_layout Subsection
3650 movie.set_readwrite: Set read-write mode.
3653 \begin_layout Itemize
3654 Syntax: none movie.set_readwrite()
3657 \begin_layout Standard
3658 Set readwrite mode (does not cause on_readwrite callback).
3661 \begin_layout Subsection
3662 movie.frame_subframes: Count subframes in frame
3665 \begin_layout Itemize
3666 Syntax: number movie.frame_subframes(number frame)
3669 \begin_layout Standard
3670 Count number of subframes in specified frame <frame> (frame numbers are
3671 1-based) and return that.
3674 \begin_layout Subsection
3675 movie.read_subframes: Read subframe data (deprecated)
3678 \begin_layout Itemize
3679 Syntax: table movie.read_subframes(number frame, number subframe)
3682 \begin_layout Standard
3683 Read specifed subframe in specified frame and return data as array.
3686 \begin_layout Subsection
3687 movie.read_rtc: Read current RTC time
3690 \begin_layout Itemize
3691 Syntax: (number, number) movie.read_rtc()
3694 \begin_layout Standard
3695 Returns the current value of the RTC as a pair (second, subsecond).
3698 \begin_layout Subsection
3699 movie.unsafe_rewind: Fast movie rewind to saved state
3702 \begin_layout Itemize
3703 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
3706 \begin_layout Standard
3707 Start setting point for unsafe rewind or jump to point of unsafe rewind.
3710 \begin_layout Itemize
3711 If called without argument, causes emulator to start process of setting
3712 unsafe rewind point.
3713 When this has finished, callback on_set_rewind occurs, passing the rewind
3714 state to lua script.
3717 \begin_layout Itemize
3718 If called with argument, causes emulator rewind to passed rewind point as
3720 Readwrite mode is implicitly activated.
3723 \begin_layout Standard
3724 The following warnings apply to unsafe rewinding:
3727 \begin_layout Itemize
3728 There are no safety checks against misuse (that's what
3729 \begin_inset Quotes eld
3733 \begin_inset Quotes erd
3739 \begin_layout Itemize
3740 Only call rewind from timeline rewind point was set from.
3743 \begin_layout Itemize
3744 Only call rewind from after the rewind point was set.
3747 \begin_layout Subsection
3748 movie.to_rewind: Load savestate as rewind point
3751 \begin_layout Itemize
3752 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
3755 \begin_layout Standard
3756 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
3757 corresponding to it.
3760 \begin_layout Itemize
3761 Note: This operation does not take emulated time.
3764 \begin_layout Subsection
3765 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
3768 \begin_layout Itemize
3769 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
3772 \begin_layout Itemize
3773 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
3776 \begin_layout Standard
3777 Copies specified movie <movie>/current object (if none or nil, the active
3778 movie) as new movie object.
3781 \begin_layout Subsection
3782 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
3785 \begin_layout Itemize
3786 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
3789 \begin_layout Itemize
3790 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
3793 \begin_layout Standard
3794 Get INPUTFRAME object corresponding to specified frame in specified movie.
3797 \begin_layout Subsection
3798 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
3801 \begin_layout Itemize
3802 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
3806 \begin_layout Itemize
3807 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
3810 \begin_layout Standard
3811 Set data in specified frame.
3814 \begin_layout Itemize
3815 Note: Past can't be edited in active movie.
3818 \begin_layout Subsection
3819 movie.get_size/INPUTMOVIE::get_size: Get size of movie
3822 \begin_layout Itemize
3823 Syntax: integer movie.get_size([INPUTMOVIE movie])
3826 \begin_layout Itemize
3827 Syntax: integer INPUTMOVIE::get_size()
3830 \begin_layout Standard
3831 Return number of subframes in specified movie.
3834 \begin_layout Subsection
3835 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
3838 \begin_layout Itemize
3839 Syntax: number movie.count_frames([INPUTMOVIE movie])
3842 \begin_layout Itemize
3843 Syntax: number INPUTMOVIE::count_frames()
3846 \begin_layout Standard
3847 Return number of frames in movie.
3850 \begin_layout Subsection
3851 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
3854 \begin_layout Itemize
3855 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
3858 \begin_layout Itemize
3859 Syntax: number INPUTMOVIE::find_frame(number frame)
3862 \begin_layout Standard
3863 Returns starting subframe of given frame (frame numbers are 1-based).
3864 Returns -1 if frame number is bad.
3867 \begin_layout Subsection
3868 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
3871 \begin_layout Itemize
3872 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
3875 \begin_layout Itemize
3876 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
3879 \begin_layout Standard
3880 Return blank INPUTFRAME with frame type from specified movie.
3883 \begin_layout Subsection
3884 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
3887 \begin_layout Itemize
3888 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
3891 \begin_layout Itemize
3892 Syntax: none INPUTMOVIE::append_frames(number frames)
3895 \begin_layout Standard
3896 Append specified number <frames> of frames.
3899 \begin_layout Subsection
3900 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
3903 \begin_layout Itemize
3904 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
3907 \begin_layout Itemize
3908 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
3911 \begin_layout Standard
3912 Append specified frame <frame>.
3913 Past of current movie can't be edited.
3916 \begin_layout Subsection
3917 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
3920 \begin_layout Itemize
3921 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
3924 \begin_layout Itemize
3925 Syntax: none INPUTMOVIE::truncate(number frames)
3928 \begin_layout Standard
3929 Truncate the specified movie to specified number of frames.
3932 \begin_layout Subsection
3933 movie.edit/INPUTMOVIE::edit: Edit a movie
3936 \begin_layout Itemize
3937 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
3938 controller, number control, number/bool value)
3941 \begin_layout Itemize
3942 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
3943 number control, number/bool value)
3946 \begin_layout Standard
3947 Change specified control in specified frame in specified movie.
3948 Past can't be edited in active movie.
3951 \begin_layout Subsection
3952 movie.copy_frames2: Copy frames between movies
3955 \begin_layout Itemize
3956 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
3957 srcmov,] number src, number count)
3960 \begin_layout Standard
3961 Copy specified number of frames between two movies.
3962 The copy proceeeds in forward direction.
3965 \begin_layout Subsection
3966 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
3969 \begin_layout Itemize
3970 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
3971 number count, bool backwards)
3974 \begin_layout Itemize
3975 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
3979 \begin_layout Standard
3980 Copy specified number of frames from one point in movie to another.
3981 If backwards is true, the copy will be done backwards.
3984 \begin_layout Subsection
3985 movie.serialize/INPUTMOVIE::serialize: Serialize movie
3988 \begin_layout Itemize
3989 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
3992 \begin_layout Itemize
3993 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
3996 \begin_layout Standard
3997 Serialize given movie into file.
3998 If binary is true, binary format (more compact and much faster) is used.
4001 \begin_layout Subsection
4002 movie.unserialize: Unserialize movie
4005 \begin_layout Itemize
4006 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
4010 \begin_layout Standard
4011 Unserialize movie from file.
4012 The given frame is used as template to decide the frame type.
4013 If binary is true, binary format is decoded (much faster).
4016 \begin_layout Subsection
4017 movie.current_first_subframe: Return first subframe in current frame
4020 \begin_layout Itemize
4021 Syntax: number movie.current_first_subframe()
4024 \begin_layout Standard
4025 Returns first subframe in current frame.
4028 \begin_layout Subsection
4029 movie.pollcounter: Return poll counter for speified control
4032 \begin_layout Itemize
4033 Syntax: number movie.pollcounter(number port, number controller, number control)
4036 \begin_layout Standard
4037 Returns number of times the specified control has been polled this frame.
4040 \begin_layout Subsection
4041 INPUTFRAME::get_button: Get button
4044 \begin_layout Itemize
4045 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
4049 \begin_layout Standard
4050 Returns state of given button as boolean.
4053 \begin_layout Subsection
4054 INPUTFRAME::get_axis: Get axis
4057 \begin_layout Itemize
4058 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
4062 \begin_layout Standard
4063 Returns state of given axis as number.
4066 \begin_layout Subsection
4067 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
4070 \begin_layout Itemize
4071 Syntax: none INPUTFRAME::set_button(number port, number controller, number
4072 control, number/bool value)
4075 \begin_layout Itemize
4076 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
4080 \begin_layout Standard
4081 Set the given button/axis to given value.
4084 \begin_layout Subsection
4085 INPUTFRAME::serialize: Serialize a frame
4088 \begin_layout Itemize
4089 Syntax: string INPUTFRAME::serialize()
4092 \begin_layout Standard
4093 Return string representation of frame.
4096 \begin_layout Subsection
4097 INPUTFRAME::unserialize: Unserialize a frame
4100 \begin_layout Itemize
4101 Syntax: none INPUTFRAME::unserialize(string data)
4104 \begin_layout Standard
4105 Set current frame from given data.
4108 \begin_layout Subsection
4109 INPUTFRAME::get_stride: Get movie stride
4112 \begin_layout Itemize
4113 Syntax: number INPUTFRAME::get_stride()
4116 \begin_layout Standard
4117 Return number of bytes needed to store the input frame.
4118 Mainly useful for some debugging.
4121 \begin_layout Standard
4122 \begin_inset Newpage pagebreak
4128 \begin_layout Section
4132 \begin_layout Standard
4133 Routines for settings manipulation
4136 \begin_layout Subsection
4137 settings.get: Get value of setting
4140 \begin_layout Itemize
4141 Syntax: string settings.get(string name)
4144 \begin_layout Standard
4145 Get value of setting <name>.
4146 If setting value can't be obtained, returns (nil, error message).
4149 \begin_layout Subsection
4150 settings.set: Set value of setting
4153 \begin_layout Itemize
4154 Syntax: none settings.set(string name, string value)
4157 \begin_layout Standard
4158 Set value <value> of setting <name>.
4159 If setting can't be set, returns (nil, error message).
4162 \begin_layout Standard
4163 \begin_inset Newpage pagebreak
4169 \begin_layout Section
4173 \begin_layout Standard
4174 Contains various functions for managing memory
4177 \begin_layout Subsection
4178 memory.vma_count: Count number of VMAs.
4181 \begin_layout Itemize
4182 Syntax: number memory.vma_count()
4185 \begin_layout Standard
4186 Returns the number of VMAs
4189 \begin_layout Subsection
4190 memory.read_vma: Lookup VMA info by index
4193 \begin_layout Itemize
4194 Syntax: string memory.read_vma(number index)
4197 \begin_layout Standard
4198 Reads the specified VMA (indices start from zero).
4199 Trying to read invalid VMA gives nil.
4200 The read VMA is table with the following fields:
4203 \begin_layout Itemize
4204 region_name (string): The readable name of the VMA
4207 \begin_layout Itemize
4208 baseaddr (number): Base address of the VMA
4211 \begin_layout Itemize
4212 lastaddr (number): Last address in the VMA.
4215 \begin_layout Itemize
4216 size (number): The size of VMA in bytes.
4219 \begin_layout Itemize
4220 readonly (boolean): True of the VMA corresponds to ROM.
4223 \begin_layout Itemize
4224 iospace (boolean): True if the VMA is I/O space.
4227 \begin_layout Itemize
4228 native_endian (boolean): True if the VMA has native endian as opposed to
4232 \begin_layout Subsection
4233 memory.find_vma: Find VMA info by address
4236 \begin_layout Itemize
4237 Syntax: table memory.find_vma(number address)
4240 \begin_layout Standard
4241 Finds the VMA containing specified address.
4242 Returns table in the same format as read_vma or nil if not found.
4245 \begin_layout Subsection
4246 memory.read{,s}{byte,{,h,d,q}word}: Read memory
4249 \begin_layout Itemize
4250 Syntax: none memory.readbyte([string vma, ]number address)
4253 \begin_layout Itemize
4254 Syntax: none memory.readword([string vma, ]number address)
4257 \begin_layout Itemize
4258 Syntax: none memory.readhword([string vma, ]number address)
4261 \begin_layout Itemize
4262 Syntax: none memory.readdword([string vma, ]number address)
4265 \begin_layout Itemize
4266 Syntax: none memory.readqword([string vma, ]number address)
4269 \begin_layout Itemize
4270 Syntax: none memory.readsbyte([string vma, ]number address)
4273 \begin_layout Itemize
4274 Syntax: none memory.readsword([string vma, ]number address)
4277 \begin_layout Itemize
4278 Syntax: none memory.readshword([string vma, ]number address)
4281 \begin_layout Itemize
4282 Syntax: none memory.readsdword([string vma, ]number address)
4285 \begin_layout Itemize
4286 Syntax: none memory.readsqword([string vma, ]number address)
4289 \begin_layout Standard
4290 Reads the specified address <address> (if 's' variant is used, do undergo
4294 \begin_layout Subsection
4295 memory.{,s}read_sg: Scatter/Gather read memory
4298 \begin_layout Itemize
4299 Syntax: none memory.read_sg(string/boolean/number...)
4302 \begin_layout Itemize
4303 Syntax: none memory.sread_sg(string/boolean/number...)
4306 \begin_layout Standard
4307 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
4309 Each argument can be string, boolean or number:
4312 \begin_layout Itemize
4313 String: Set VMA addresses are relative to (e.g.
4317 \begin_layout Itemize
4318 boolean: If true, increment relative address by 1, if false, decrement by
4320 The new address is read as next higher byte.
4323 \begin_layout Itemize
4324 integer: Set the relative address to specified value and read the address
4325 as next higher byte.
4328 \begin_layout Subsection
4329 memory.write_sg: Scatter/Gather write memory
4332 \begin_layout Itemize
4333 Syntax: none memory.write_sg(number value, string/boolean/number...)
4336 \begin_layout Standard
4337 Perform scatter/gather write of value <value> on memory.
4338 Each argument can be string, boolean or number:
4341 \begin_layout Itemize
4342 String: Set VMA addresses are relative to (e.g.
4346 \begin_layout Itemize
4347 boolean: If true, increment relative address by 1, if false, decrement by
4349 The new address is read as next higher byte.
4352 \begin_layout Itemize
4353 integer: Set the relative address to specified value and read the address
4354 as next higher byte.
4357 \begin_layout Subsection
4358 memory.read{float,double}: Read memory
4361 \begin_layout Itemize
4362 Syntax: none memory.readfloat([string vma, ]number address)
4365 \begin_layout Itemize
4366 Syntax: none memory.readdouble([string vma, ]number address)
4369 \begin_layout Standard
4370 Reads the specified address <address>
4373 \begin_layout Subsection
4374 memory.write{byte,{,h,d,q}word,float,double}: Write memory
4377 \begin_layout Itemize
4378 Syntax: none memory.writebyte([string vma, ]number address, number value)
4381 \begin_layout Itemize
4382 Syntax: none memory.writeword([string vma, ]number address, number value)
4385 \begin_layout Itemize
4386 Syntax: none memory.writehword([string vma, ]number address, number value)
4389 \begin_layout Itemize
4390 Syntax: none memory.writedword([string vma, ]number address, number value)
4393 \begin_layout Itemize
4394 Syntax: none memory.writeqword([string vma, ]number address, number value)
4397 \begin_layout Itemize
4398 Syntax: none memory.writefloat([string vma, ]number address, number value)
4401 \begin_layout Itemize
4402 Syntax: none memory.writedouble([string vma, ]number address, number value)
4405 \begin_layout Standard
4406 Writes the specified value <value> (negative integer values undergo 2's
4407 complement) to specified address <address>.
4410 \begin_layout Subsection
4411 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
4414 \begin_layout Itemize
4415 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
4418 \begin_layout Standard
4419 Returns a table mapping specified memory aperture for read/write.
4420 If parameters are omitted, entiere map space is the aperture.
4423 \begin_layout Itemize
4424 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
4425 qword, sqword, float or double.
4428 \begin_layout Subsection
4429 memory.hash_region: Hash region of memory
4432 \begin_layout Itemize
4433 Syntax: string memory.hash_region([string vma, ]number base, number size)
4436 \begin_layout Standard
4437 Hash specified number of bytes starting from specified address and return
4441 \begin_layout Subsection
4442 memory.hash_state: Hash system state
4445 \begin_layout Itemize
4446 Syntax: string memory.hash_state()
4449 \begin_layout Standard
4450 Hash the current system state.
4451 Mainly useful for debugging savestates.
4454 \begin_layout Subsection
4455 memory.readregion: Read region of memory
4458 \begin_layout Itemize
4459 Syntax: table memory.readregion([string vma, ]number base, number size)
4462 \begin_layout Standard
4463 Read a region of memory.
4466 \begin_layout Itemize
4467 Warning: If the region crosses VMA boundary, the results are undefined.
4470 \begin_layout Subsection
4471 memory.writeregion: Write region of memory
4474 \begin_layout Itemize
4475 Syntax: none memory.writeregion([string vma, ]number base, number size, table
4479 \begin_layout Standard
4480 Write a region of memory.
4483 \begin_layout Itemize
4484 Warning: If the region crosses VMA boundary, the results are undefined.
4487 \begin_layout Subsection
4488 memory.read_expr: Evaluate memory watch expression
4491 \begin_layout Itemize
4492 Syntax: string memory.read_expr(string expr)
4495 \begin_layout Standard
4496 Evaluate specified watch expression and return result
4499 \begin_layout Subsection
4500 memory.action: Run core action
4503 \begin_layout Itemize
4504 memory.action(string action, [<params>])
4507 \begin_layout Standard
4509 The different models expect parameters as:
4512 \begin_layout Itemize
4516 \begin_layout Itemize
4520 \begin_layout Itemize
4524 \begin_layout Itemize
4528 \begin_layout Itemize
4532 \begin_layout Subsection
4533 memory.get_lag_flag: Get lag flag
4536 \begin_layout Itemize
4537 Syntax: boolean memory.get_lag_flag()
4540 \begin_layout Standard
4541 Get the value of core lag flag.
4542 True if this frame has been lag so far, false if poll has been detected.
4545 \begin_layout Subsection
4546 memory.set_lag_flag: Set lag flag
4549 \begin_layout Itemize
4550 Syntax: none memory.set_lag_flag(boolean flag)
4553 \begin_layout Standard
4554 Set the value of core lag flag.
4555 This flag automatically gets cleared if poll is detected, but can be forcibly
4556 set or cleared if game so requires.
4559 \begin_layout Itemize
4560 Should only be used in on_frame_emulated callback.
4563 \begin_layout Itemize
4564 Setting or clearing this affects the emulator lag counter.
4567 \begin_layout Subsection
4568 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
4572 \begin_layout Itemize
4573 Syntax: function memory.registerread([string vma, ] number addr, function
4577 \begin_layout Itemize
4578 Syntax: function memory.registerwrite([string vma, ] number addr, function
4582 \begin_layout Itemize
4583 Syntax: function memory.registerexec([string vma, ] number addr, function
4587 \begin_layout Itemize
4588 Syntax: none memory.unregisterread([string vma, ] number addr, function fn);
4591 \begin_layout Itemize
4592 Syntax: none memory.unregisterwrite([string vma, ] number addr, function
4596 \begin_layout Itemize
4597 Syntax: none memory.unregisterexec([string vma, ] number addr, function fn);
4600 \begin_layout Standard
4601 Add or remove callback on memory read, write or execute (depending on the
4603 If <vma> is specified, <addr> is relative to it, otherwise <addr> is global.
4604 <fn> is the callback.
4605 The register* functions return <fn> (which can then be passed to unregister*
4609 \begin_layout Itemize
4610 Not all cores support this, and it may be unsupported for some VMAs.
4613 \begin_layout Itemize
4614 The functions are passed two parameters: Address and value.
4617 \begin_layout Subsection
4618 memory.{,un}registertrace: Set/Clear trace hook
4621 \begin_layout Itemize
4622 Syntax: function memory.registertrace(number processor, function fn);
4625 \begin_layout Itemize
4626 Syntax: none memory.unregistertrace(number processor, function fn);
4629 \begin_layout Standard
4630 Add or remove trace callback.
4631 <processor> is system-dependent processor number (0 is usually main CPU).
4632 The function arguments work like in other (un)register* functions.
4635 \begin_layout Itemize
4636 The functions are passed two parameters: Trace CPU and Trace event string.
4639 \begin_layout Subsection
4640 memory.cheat: Set cheat
4643 \begin_layout Itemize
4644 Syntax: none memory.cheat([string vma, ] number addr, number value);
4647 \begin_layout Itemize
4648 Syntax: none memory.cheat([string vma, ] number addr);
4651 \begin_layout Standard
4652 Set or clear cheat (value <value>) on address <addr>.
4653 If <vma> is specified, <addr> is relative to that.
4654 If <value> is not speicified, clear a cheat.
4657 \begin_layout Itemize
4658 Not all cores support this, and it may be unsupported for some VMAs.
4661 \begin_layout Subsection
4662 memory.setxmask: Set global execute hook mask
4665 \begin_layout Itemize
4666 Syntax: none memory.setxmask(number mask)
4669 \begin_layout Standard
4670 Set the global execute hook mask to <mask>.
4671 The meaning of each bit is system-dependent, but bit 0 should be the main
4675 \begin_layout Standard
4676 \begin_inset Newpage pagebreak
4682 \begin_layout Section
4686 \begin_layout Standard
4687 Contains newer memory functions.
4690 \begin_layout Subsection
4691 memory2(): Get all VMA names.
4694 \begin_layout Itemize
4695 Syntax: table memory2()
4698 \begin_layout Standard
4699 Returns array of all valid VMA names.
4702 \begin_layout Subsection
4703 memory2.<vma>:info: Get VMA info
4706 \begin_layout Itemize
4707 Syntax: table memory2.<vma>:info()
4710 \begin_layout Standard
4711 Return table describing given VMA.
4712 Includes fields address, size, last, readonly, special and endian.
4715 \begin_layout Subsection
4716 memory2.<vma>:<op>: Read/Write memory
4719 \begin_layout Itemize
4720 Syntax: none memory2.<vma>:<op>(number offset, number value)
4723 \begin_layout Itemize
4724 Syntax: number memory2.<vma>:<op>(number offset)
4727 \begin_layout Standard
4728 Read/Write value from/to given VMA <vma> at given offset <offset> (must
4730 The value written is <value>.
4731 <Op> is of form: [i][s]<type>, where:
4734 \begin_layout Itemize
4735 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4738 \begin_layout Itemize
4739 'i' signifies that the value is treated as opposite-to-normal endianess,
4742 \begin_layout Itemize
4743 's' signifies that value is treated as signed (not available for floating-point).
4746 \begin_layout Subsection
4747 memory2.<vma>:read: Scatter-gather value read
4750 \begin_layout Itemize
4751 Syntax: number memory2.<vma>:read(number addr...)
4754 \begin_layout Standard
4755 Read value from given VMA <vma> at byte offsets <addr>..., given in order of
4756 increasing significance.
4757 Value of true and false are special.
4758 True increments address by 1, and false decrements address by 1.
4761 \begin_layout Subsection
4762 memory2.<vma>:sread: Signed scatter-gather value read
4765 \begin_layout Itemize
4766 Syntax: number memory2.<vma>:sread(number addr...)
4769 \begin_layout Standard
4770 Like memory2.<vma>:read, but reads signed values.
4773 \begin_layout Subsection
4774 memory2.<vma>:write: Scatter-gather value write
4777 \begin_layout Itemize
4778 Syntax: number memory2.<vma>:write(number val, number addr...)
4781 \begin_layout Standard
4782 Write value <val> to given VMA <vma> at byte offsets <addr>..., given in order
4783 of increasing significance.
4784 Value of true and false are special.
4785 True increments address by 1, and false decrements address by 1.
4788 \begin_layout Standard
4789 \begin_inset Newpage pagebreak
4795 \begin_layout Section
4799 \begin_layout Standard
4800 Contains random number generation methods.
4801 These functions do not return reproducable results.
4804 \begin_layout Subsection
4805 random.boolean: Random boolean
4808 \begin_layout Itemize
4809 Syntax: boolean random.boolean()
4812 \begin_layout Standard
4813 Returns true or false at random (50-50 chance).
4816 \begin_layout Subsection
4817 random.integer: Random integer
4820 \begin_layout Itemize
4821 Syntax: number random.integer(number highplusone)
4824 \begin_layout Itemize
4825 Syntax: number random.integer(number low, number high)
4828 \begin_layout Standard
4829 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
4830 With two arguments, return random integer [<low>,<high>] (both ends inclusive).
4833 \begin_layout Standard
4834 The returned numbers are from uniform distribution.
4837 \begin_layout Subsection
4838 random.float: Random float
4841 \begin_layout Itemize
4842 Syntax: number random.float()
4845 \begin_layout Standard
4846 Returns random decimal number [0,1).
4849 \begin_layout Subsection
4850 random.among: Random parameter
4853 \begin_layout Itemize
4854 Syntax: value random.among(value values...)
4857 \begin_layout Standard
4858 Returns random parameter value, picked at uniform.
4859 Multiple equivalent values are returned with higher chance.
4862 \begin_layout Subsection
4863 random.amongtable: Random from table
4866 \begin_layout Itemize
4867 Syntax: value random.amongtable(table tab)
4870 \begin_layout Standard
4871 Returns random value from table <tab>.
4872 As in random.among, no equality testing is done.
4875 \begin_layout Standard
4876 \begin_inset Newpage pagebreak
4882 \begin_layout Section
4886 \begin_layout Subsection
4887 zip.enumerate: Enumerate members in zipfile
4890 \begin_layout Itemize
4891 Syntax: Table zip.enumerate(string filename[, boolean invert])
4894 \begin_layout Standard
4895 Returns table of files in zip archive <filename>.
4896 If <invert> is true, instead of returning array of names, returns table
4897 with keys being member names and values being true.
4900 \begin_layout Standard
4901 \begin_inset Newpage pagebreak
4907 \begin_layout Section
4911 \begin_layout Standard
4912 Various callback-related functions.
4915 \begin_layout Subsection
4916 \begin_inset CommandInset label
4918 name "sub:callback.register:-Register-a"
4922 callback.register: Register a callback
4925 \begin_layout Itemize
4926 Syntax: function callback.register(string cbname, function cbfun);
4929 \begin_layout Standard
4930 Instruct function <cbfun> to be added to list of callbacks to call on event
4931 <cbname> (See section
4932 \begin_inset CommandInset ref
4934 reference "sec:Callbacks"
4939 The callback name does not have the 'on_' prefix (e.g.
4941 \begin_inset Quotes eld
4945 \begin_inset Quotes erd
4952 \begin_layout Subsection
4953 \begin_inset CommandInset label
4955 name "sub:callback.unregister:-Unregister-"
4959 callback.unregister: Unregister a callback
4962 \begin_layout Itemize
4963 Syntax: function callback.unregister(string cbname, function cbfun);
4966 \begin_layout Standard
4967 Instruct function <cbfun> to be removed from list of callbacks to call on
4971 \begin_layout Subsection
4972 callback.<cbname>:register: Register callback
4975 \begin_layout Itemize
4976 Syntax: function callback.<cbname>:register(function cbfun)
4979 \begin_layout Standard
4980 Synonym for callback.register (section
4981 \begin_inset CommandInset ref
4983 reference "sub:callback.register:-Register-a"
4987 ), albeit with callback name specified differently.
4990 \begin_layout Subsection
4991 callback.<cbname>:unregister: Register callback
4994 \begin_layout Itemize
4995 Syntax: function callback.<cbname>:unregister(function cbfun)
4998 \begin_layout Standard
4999 Synonym for callback.unregister (section
5000 \begin_inset CommandInset ref
5002 reference "sub:callback.unregister:-Unregister-"
5006 ), albeit with callback name specified differently.
5009 \begin_layout Section
5013 \begin_layout Standard
5014 Various bsnes-specific functions.
5017 \begin_layout Subsection
5018 bsnes.dump_sprite: Dump a sprite
5021 \begin_layout Itemize
5022 Syntax: BITMAP bsnes.dump_sprite([string vma, ] number addr, number width,
5023 number height[, number stride])
5026 \begin_layout Standard
5027 Dumps given sprite (in native format) from memory.
5029 \begin_inset Quotes eld
5033 \begin_inset Quotes erd
5037 <Width> and <height> are given in 8x8 blocks.
5038 <Stride> overrides row stride (default 512).
5041 \begin_layout Subsection
5042 bsnes.dump_palette: Dump a palette
5045 \begin_layout Itemize
5046 Syntax: PALETTE bsnes.dump_palette([string vma, ] number addr, bool full256,
5050 \begin_layout Standard
5051 Dumps a palette from memory.
5053 \begin_inset Quotes eld
5057 \begin_inset Quotes erd
5061 If <full256> is true, 256 colors are dumped (otherwise 16).
5062 If <first_trans> is true, first color is forced transparent.
5065 \begin_layout Section
5066 extensions to table string
5069 \begin_layout Subsection
5070 string.charU: string.char, UTF-8 version.
5073 \begin_layout Itemize
5074 Syntax: string string.charU(number n...)
5077 \begin_layout Standard
5078 Like Lua string.char(), but works in terms of Unicode codepoints.
5079 The returned string is UTF-8.
5082 \begin_layout Subsection
5083 string.byteU: string.byte, UTF-8 version.
5086 \begin_layout Itemize
5088 string.byteU(string str[, number i[, number j]])
5091 \begin_layout Standard
5092 Like string.byte(), but works in terms of Unicode codepoints.
5093 The input string <str> is assumed UTF-8.
5096 \begin_layout Section
5100 \begin_layout Standard
5101 Contains copy of global variables from time of Lua initialization.
5105 \begin_layout Standard
5106 \begin_inset Newpage pagebreak
5112 \begin_layout Section
5113 \begin_inset CommandInset label
5115 name "sec:Callbacks"
5122 \begin_layout Standard
5123 Various callbacks to Lua that can occur.
5126 \begin_layout Subsection
5127 on_paint: Screen is being painted
5130 \begin_layout Itemize
5131 Callback: on_paint(bool not_synth)
5134 \begin_layout Standard
5135 Called when screen is being painted.
5136 Any gui.* calls requiring graphic context draw on the screen.
5139 \begin_layout Itemize
5140 not_synth is true if this hook is being called in response to received frame,
5144 \begin_layout Subsection
5145 on_video: Dumped video frame is being painted
5148 \begin_layout Itemize
5149 Callback: on_video()
5152 \begin_layout Standard
5153 Called when video dump frame is being painted.
5154 Any gui.* calls requiring graphic context draw on the video.
5157 \begin_layout Subsection
5158 on_frame_emulated: Frame emulation complete
5161 \begin_layout Itemize
5162 Callback: on_frame_emulated()
5165 \begin_layout Standard
5166 Called when emulating frame has completed and on_paint()/on_video() calls
5167 are about to be issued.
5170 \begin_layout Subsection
5171 on_frame: Frame emulation starting.
5174 \begin_layout Itemize
5175 Callback: on_frame()
5178 \begin_layout Standard
5179 Called on each starting whole frame.
5182 \begin_layout Subsection
5183 on_startup: Emulator startup complete
5186 \begin_layout Itemize
5187 Callback: on_startup()
5190 \begin_layout Standard
5191 Called when the emulator is starting (lsnes.rc and --run files has been run).
5194 \begin_layout Subsection
5195 on_rewind: Movie rewound to beginning
5198 \begin_layout Itemize
5199 Callback: on_rewind()
5202 \begin_layout Standard
5203 Called when rewind movie to beginning has completed.
5206 \begin_layout Subsection
5207 on_pre_load: Load operation is about to start
5210 \begin_layout Itemize
5211 Callback: on_pre_load(string name)
5214 \begin_layout Standard
5215 Called just before savestate/movie load occurs (note: loads are always delayed,
5216 so this occurs even when load was initiated by lua).
5219 \begin_layout Subsection
5220 on_err_Load: Load failed
5223 \begin_layout Itemize
5224 Callback: on_err_load(string name)
5227 \begin_layout Standard
5228 Called if loadstate goes wrong.
5231 \begin_layout Subsection
5232 on_post_load: Load completed
5235 \begin_layout Itemize
5236 Callback: on_post_load(string name, boolean was_savestate)
5239 \begin_layout Standard
5240 Called on successful loadstate.
5241 was_savestate gives if this was a savestate or a movie.
5244 \begin_layout Subsection
5245 on_pre_save: Save operation is about to start
5248 \begin_layout Itemize
5249 Callback: on_pre_save(string name, boolean is_savestate)
5252 \begin_layout Standard
5253 Called just before savestate save occurs (note: movie saves are synchronous
5254 and won't trigger these callbacks if called from Lua).
5257 \begin_layout Subsection
5258 on_err_save: Save failed
5261 \begin_layout Itemize
5262 Callback: on_err_save(string name)
5265 \begin_layout Standard
5266 Called if savestate goes wrong.
5269 \begin_layout Subsection
5270 on_post_save: Save completed
5273 \begin_layout Itemize
5274 Callback: on_post_save(string name, boolean is_savestate)
5277 \begin_layout Standard
5278 Called on successful savaestate.
5279 is_savestate gives if this was a savestate or a movie.
5282 \begin_layout Subsection
5283 on_quit: Emulator is shutting down
5286 \begin_layout Itemize
5290 \begin_layout Standard
5291 Called when emulator is shutting down.
5294 \begin_layout Subsection
5295 on_input: Polling for input
5298 \begin_layout Standard
5299 Called when emulator is just sending input to bsnes core.
5300 Warning: This is called even in readonly mode, but the results are ignored.
5303 \begin_layout Subsection
5304 on_reset: System has been reset
5307 \begin_layout Itemize
5308 Callback: on_reset()
5311 \begin_layout Standard
5312 Called when system is reset.
5315 \begin_layout Subsection
5316 on_readwrite: Entered readwrite mode
5319 \begin_layout Itemize
5320 Callback: on_readwrite()
5323 \begin_layout Standard
5324 Called when moving into readwrite mode as result of
5325 \begin_inset Quotes eld
5329 \begin_inset Quotes erd
5332 command (note: moving to rwmode by Lua won't trigger this, as per recursive
5336 \begin_layout Subsection
5337 on_snoop/on_snoop2: Snoop core controller reads
5340 \begin_layout Itemize
5341 Callback: on_snoop(number port, number controller, number index, number
5345 \begin_layout Itemize
5346 Callback: on_snoop2(number port, number controller, number index, number
5350 \begin_layout Standard
5351 Called each time bsnes asks for input.
5352 The value is the final value to be sent to bsnes core (readonly mode, autohold
5353 and autofire have been taken into account).
5354 Might be useful when translating movies to format suitable for console
5356 Note: There is no way to modify the value to be sent.
5359 \begin_layout Itemize
5360 On_snoop2 is called instead of on_snoop if defined.
5361 Reserves port 0 for system, having first user port be port 1.
5364 \begin_layout Subsection
5365 on_keyhook: Hooked key/axis has been moved
5368 \begin_layout Itemize
5369 Callback: on_keyhook(string keyname, table state)
5372 \begin_layout Standard
5373 Sent when key that has keyhook events requested changes state.
5374 Keyname is name of the key (group) and state is the state (same kind as
5375 table values in input.raw).
5378 \begin_layout Subsection
5382 \begin_layout Itemize
5386 \begin_layout Standard
5387 Called when requested by set_idle_timeout(), the timeout has expired and
5388 emulator is waiting.
5391 \begin_layout Subsection
5392 on_timer: Timer event
5395 \begin_layout Itemize
5396 Callback: on_timer()
5399 \begin_layout Standard
5400 Called when requested by set_idle_timeout() and the timeout has expired
5401 (regardless if emulator is waiting).
5404 \begin_layout Subsection
5405 on_set_rewind: Rewind point has been set
5408 \begin_layout Itemize
5409 Callback: on_set_rewind(UNSAFEREWIND r)
5412 \begin_layout Standard
5413 Called when unsafe rewind object has been constructed.
5416 \begin_layout Subsection
5417 on_pre_rewind: Rewind is about to occur
5420 \begin_layout Itemize
5421 Callback: on_pre_rewind()
5424 \begin_layout Standard
5425 Called just before unsafe rewind is about to occur.
5428 \begin_layout Subsection
5429 on_post_rewind: Rewind has occured
5432 \begin_layout Itemize
5433 Callback: on_post_rewind()
5436 \begin_layout Standard
5437 Called just after unsafe rewind has occured.
5440 \begin_layout Subsection
5441 on_button: Button has been pressed
5444 \begin_layout Itemize
5445 Callback: on_button(number port, number controller, number index, string
5449 \begin_layout Standard
5450 Called on controller button press, with following parameters:
5453 \begin_layout Itemize
5454 port: Port number (0 is system)
5457 \begin_layout Itemize
5458 controller: Controller within port
5461 \begin_layout Itemize
5462 index: Index of button.
5465 \begin_layout Itemize
5466 type: Type of event, one of:
5470 \begin_layout Itemize
5471 \begin_inset Quotes eld
5475 \begin_inset Quotes erd
5478 : Button was pressed.
5481 \begin_layout Itemize
5482 \begin_inset Quotes eld
5486 \begin_inset Quotes erd
5489 : Button was released.
5492 \begin_layout Itemize
5493 \begin_inset Quotes eld
5497 \begin_inset Quotes erd
5503 \begin_layout Itemize
5504 \begin_inset Quotes eld
5508 \begin_inset Quotes erd
5511 : Released from hold.
5514 \begin_layout Itemize
5515 \begin_inset Quotes eld
5519 \begin_inset Quotes erd
5522 : Typing input on button.
5525 \begin_layout Itemize
5526 \begin_inset Quotes eld
5530 \begin_inset Quotes erd
5533 : Typing input undone.
5536 \begin_layout Itemize
5537 \begin_inset Quotes eld
5540 autofire <duty> <cycle>
5541 \begin_inset Quotes erd
5544 : Autofire with specifie duty and cycle.
5547 \begin_layout Itemize
5548 \begin_inset Quotes eld
5552 \begin_inset Quotes erd
5558 \begin_layout Itemize
5559 \begin_inset Quotes eld
5563 \begin_inset Quotes erd
5566 : Analog action on axis.
5570 \begin_layout Subsection
5571 on_movie_lost: Movie data is about to be lost
5574 \begin_layout Itemize
5575 Callback: on_movie_lost(STRING kind)
5578 \begin_layout Standard
5579 Called just before something would happen that could lose movie data.
5583 \begin_layout Itemize
5584 readwrite: Switching to readwrite mode.
5587 \begin_layout Itemize
5588 reload: ROM is being reloaded in readwrite mode.
5591 \begin_layout Itemize
5592 load: New movie is being loaded.
5595 \begin_layout Itemize
5596 unsaferewind: Unsafe rewind is happening.
5599 \begin_layout Subsection
5600 on_latch: Latch line is rising
5603 \begin_layout Itemize
5604 Callback: on_latch(<core-dependent-parameters>)
5607 \begin_layout Standard
5608 Called when latch line for controller is rising.
5609 Some cores may not support this.
5612 \begin_layout Section
5613 System-dependent behaviour
5616 \begin_layout Subsection
5620 \begin_layout Itemize
5621 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
5622 p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
5623 p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
5624 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
5625 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
5626 ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
5627 ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
5628 ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
5629 ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
5630 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
5631 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
5632 ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
5633 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
5634 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
5635 ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
5636 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
5637 ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
5638 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
5639 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
5640 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
5641 ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
5642 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
5643 ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
5644 ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
5645 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
5646 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
5647 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
5648 ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
5649 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
5650 ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
5651 ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
5652 ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
5653 ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
5654 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
5655 ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
5656 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
5657 ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
5658 ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
5659 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
5660 ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount,
5663 \begin_layout Itemize
5664 on_latch has no parameters
5667 \begin_layout Itemize
5668 CPU 0 is S-CPU, 1 is S-SMP.
5671 \begin_layout Itemize
5672 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
5675 \begin_layout Itemize
5676 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
5680 \begin_layout Subsection
5684 \begin_layout Itemize
5685 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
5689 \begin_layout Itemize
5690 on_latch is not supported
5693 \begin_layout Itemize
5697 \begin_layout Itemize
5698 Cheats are supported for ROM, SRAM and WRAM.
5701 \begin_layout Itemize
5702 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM