1 #LyX 2.1 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
16 \font_default_family default
17 \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
41 \use_package amsmath 1
42 \use_package amssymb 1
45 \use_package mathdots 1
46 \use_package mathtools 1
48 \use_package stackrel 1
49 \use_package stmaryrd 1
50 \use_package undertilde 1
52 \cite_engine_type default
56 \paperorientation portrait
73 \paragraph_separation indent
74 \paragraph_indentation default
75 \quotes_language english
78 \paperpagestyle default
79 \tracking_changes false
89 lsnes Lua functions reference
96 \begin_layout Standard
97 \begin_inset CommandInset toc
98 LatexCommand tableofcontents
105 \begin_layout Standard
106 \begin_inset Newpage pagebreak
112 \begin_layout Section
116 \begin_layout Subsection
120 \begin_layout Itemize
121 Coordinates increase to right and down.
124 \begin_layout Itemize
125 The origin is at top left of game area or buffer.
128 \begin_layout Subsection
132 \begin_layout Itemize
133 Methods that draw something (unless stated otherwise) require a valid rendering
135 This context can come in three ways:
139 \begin_layout Enumerate
140 The default rendering context of paint callback (the screen).
143 \begin_layout Enumerate
144 The default rendering context of video callback (the video).
147 \begin_layout Enumerate
148 Explicitly set rendering context (RENDERCTX:set).
152 \begin_layout Itemize
153 The rendering context is always reset when callback ends.
156 \begin_layout Subsection
160 \begin_layout Standard
161 (Direct) colors can be specified either as numbers or strings.
164 \begin_layout Itemize
165 -1 is fully transparent.
168 \begin_layout Itemize
169 Non-negative numbers less than
170 \begin_inset Formula $2^{32}$
173 are partially opaque colors (
174 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
181 \begin_layout Itemize
182 \begin_inset Formula $a$
186 \begin_inset Formula $0-255$
190 \begin_inset Formula $0$
194 \begin_inset Formula $256$
197 would be fully transparent.
201 \begin_layout Itemize
202 Thus, numbers in range
203 \begin_inset Formula $0-16777215$
206 stand for fully opaque colors.
210 \begin_layout Itemize
211 \begin_inset Formula $r$
215 \begin_inset Formula $g$
219 \begin_inset Formula $b$
222 are intensities of base colors on scale
223 \begin_inset Formula $0-255$
230 \begin_layout Itemize
231 Color can also be specified by name as string: The following color names
232 are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
233 antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
234 azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
235 bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
236 brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
237 burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
238 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
239 chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
240 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
241 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
242 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
243 darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
244 darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
245 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
246 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
247 darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
248 darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
249 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
250 dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
251 firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
252 fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
253 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
254 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
255 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
256 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
257 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
258 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
259 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
260 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
261 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
262 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
263 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
264 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
265 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
266 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
267 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
268 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
269 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
270 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
271 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
272 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
273 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
274 indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
275 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
276 lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
277 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
278 lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
279 lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
280 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
281 lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
282 lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
283 lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
284 lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
285 lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
286 lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
287 maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
288 mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
289 mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
290 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
291 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
292 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
293 navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
294 olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
295 orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
296 palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
297 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
298 palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
299 peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
300 pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
301 purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
302 rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
303 saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
304 seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
305 seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
306 skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
307 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
308 snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
309 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
310 tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
311 tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
312 turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
313 wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
314 yellow3 yellow4 yellowgreen
317 \begin_layout Itemize
318 The HSL base color names: hsl-<hue><saturation><lightness>.
322 \begin_layout Itemize
323 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
324 y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
325 (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
328 \begin_layout Itemize
329 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
332 \begin_layout Itemize
333 Lightness is 0-8, where 0 is black and 8 is white.
337 \begin_layout Itemize
338 The color names can have a modifier after space (multiple modifiers are
339 allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
340 opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
341 hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
345 \begin_layout Itemize
346 opaqueness is measured as percentage.
349 \begin_layout Itemize
350 Hue adjustments are on 24-step scale.
353 \begin_layout Itemize
354 Saturation and lightness adjustments are on 16-step scale.
358 \begin_layout Section
362 \begin_layout Standard
363 These tokens are special, and are expanded while the script is being loaded
366 \begin_layout Subsection
367 @@LUA_SCRIPT_FILENAME@@
370 \begin_layout Standard
371 Expanded to string token containing path and filename of this Lua script.
372 Handy for referencing other lua scripts or resources that are relative
376 \begin_layout Standard
377 In practicular, this is suitable to be passed as base argument of various
378 functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
379 ad_png and gui.bitmap_load_pal.
382 \begin_layout Section
386 \begin_layout Subsection
387 MMAP_STRUCT: Quasi-table mapping emulated memory
390 \begin_layout Standard
391 Objects act like tables, but the values reflect emulated memory.
394 \begin_layout Subsubsection
395 static function new: Create a new instance
398 \begin_layout Itemize
399 Syntax: mmap memory.mmap.new()
402 \begin_layout Itemize
403 Syntax: mmap classes.MMAP_STRUCT.new()
406 \begin_layout Standard
410 \begin_layout Itemize
411 mmap: MMAP_STRUCT: The created mmap structure.
414 \begin_layout Standard
415 Create a new object (with no mappings) and return it.
418 \begin_layout Subsubsection
419 operator(): Bind key in mmap structure
422 \begin_layout Itemize
423 Syntax: obj(key, {marea, address|addrobj}, type)
426 \begin_layout Standard
430 \begin_layout Itemize
431 obj: MMAP_STRUCT: The structure to manipulate.
434 \begin_layout Itemize
435 key: String: The name of the key in array to map.
438 \begin_layout Itemize
439 marea: String: The memory area the mapped address is in (default: global
443 \begin_layout Itemize
444 address: Number: The offset of memory addreess, relative to specified memory
445 area or global memory space.
448 \begin_layout Itemize
449 addrobj: ADDRESS: The memory address.
452 \begin_layout Itemize
453 type: String: The type of data to map.
457 \begin_layout Itemize
458 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
463 \begin_layout Standard
464 Bind key <key> in mmap structure <obj> to address <address> (relative to
466 The memory address is treated as type <type>.
469 \begin_layout Itemize
471 \begin_inset Quotes eld
475 \begin_inset Quotes erd
479 \begin_inset Quotes eld
483 \begin_inset Quotes erd
487 \begin_inset Quotes eld
491 \begin_inset Quotes erd
497 \begin_layout Standard
498 This binds signed word at address WRAM+0x2A into key
499 \begin_inset Quotes eld
503 \begin_inset Quotes erd
509 \begin_layout Standard
510 \begin_inset Newpage pagebreak
516 \begin_layout Subsection
517 ZIPWRITER: Write .zip files
520 \begin_layout Standard
521 This class does writing of .zip files.
524 \begin_layout Subsubsection
525 Static function new: Create a new zipfile
528 \begin_layout Itemize
529 Syntax: zip zip.writer.new(filename, [compression])
532 \begin_layout Itemize
533 Deprecated: zip zip.create(filename, [compression])
536 \begin_layout Standard
540 \begin_layout Itemize
541 filename: string: The name of the file to write.
544 \begin_layout Itemize
545 compression: number: Compression level (0-9).
549 \begin_layout Standard
553 \begin_layout Itemize
554 zip: ZIPWRITER: The newly created ZIP writer.
557 \begin_layout Standard
558 Create a new ZIPWRITER object and return it.
561 \begin_layout Subsubsection
562 Method commit: Finish creating ZIP file.
565 \begin_layout Itemize
566 Syntax: zipfile:commit()
569 \begin_layout Standard
573 \begin_layout Itemize
574 zipfile: ZIPFILE: The ZIP file object.
577 \begin_layout Standard
578 Finish writing the ZIP file and actually create it on disk.
581 \begin_layout Itemize
582 If a member is currently open, it is implicitly closed.
585 \begin_layout Itemize
586 Invoking this on already committed or rolled back zipfile causes an error.
589 \begin_layout Subsubsection
590 Method rollback: Cancel writing the ZIP file.
593 \begin_layout Itemize
594 Syntax: zipfile:rollback()
597 \begin_layout Standard
601 \begin_layout Itemize
602 zipfile: ZIPFILE: The ZIP file object.
605 \begin_layout Standard
606 Cancel writing the whole ZIP file.
607 The file on disk will not be modified.
610 \begin_layout Itemize
611 If a member is currently open, it is implicitly closed.
614 \begin_layout Itemize
615 Invoking this on already committed or rolled back zipfile causes an error.
618 \begin_layout Subsubsection
619 Method create_file: Start writing a new member
622 \begin_layout Itemize
623 Syntax: zipfile:create_file(filename)
626 \begin_layout Standard
630 \begin_layout Itemize
631 zipfile: ZIPFILE: The ZIP file object.
634 \begin_layout Itemize
635 string filename: Name of the new member to create
638 \begin_layout Standard
639 Start writing a new member <filename> in ZIP file.
642 \begin_layout Itemize
643 If a member is currently open, it is implicitly closed.
646 \begin_layout Itemize
647 Invoking this on already committed or rolled back zipfile causes an error.
650 \begin_layout Subsubsection
651 Method close_file: Close member
654 \begin_layout Itemize
655 Syntax: zipfile:close_file()
658 \begin_layout Standard
662 \begin_layout Itemize
663 zipfile: ZIPFILE: The ZIP file object.
666 \begin_layout Standard
667 Close the currently open member in zipfile.
670 \begin_layout Itemize
671 Invoking this on already committed or rolled back zipfile causes an error.
674 \begin_layout Itemize
675 Invoking this without an open member causes an error.
678 \begin_layout Subsubsection
679 Method write: Write data
682 \begin_layout Itemize
683 Syntax: zipfile:write(data)
686 \begin_layout Standard
690 \begin_layout Itemize
691 zipfile: ZIPFILE: The ZIP file object.
694 \begin_layout Itemize
695 data: string: The data to write.
698 \begin_layout Standard
699 Write <data> in binary mode (as-is) to currently open member.
702 \begin_layout Itemize
703 Invoking this without a member being open causes an error.
706 \begin_layout Standard
707 \begin_inset Newpage pagebreak
713 \begin_layout Subsection
714 TILEMAP: Tiled collection of bitmaps.
717 \begin_layout Standard
718 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
721 \begin_layout Subsubsection
722 Static function new: Create a tilemap
725 \begin_layout Itemize
726 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
729 \begin_layout Itemize
730 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
733 \begin_layout Itemize
734 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
737 \begin_layout Standard
741 \begin_layout Itemize
742 w: number: Width of the tilemap in tiles
745 \begin_layout Itemize
746 h: number: Height of the tilemap in tiles
749 \begin_layout Itemize
750 bw: number: Width of each tile in pixels.
753 \begin_layout Itemize
754 bh: number: Height of each tile in pixels.
757 \begin_layout Standard
761 \begin_layout Itemize
762 tilemap: TILEMAP: the newly created tilemap
765 \begin_layout Standard
766 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
770 \begin_layout Subsubsection
771 TILEMAP:getsize: Query tilemap size
774 \begin_layout Itemize
775 Syntax: width, height tmap:getsize()
778 \begin_layout Standard
782 \begin_layout Itemize
783 tmap: TILEMAP: The tilemap to query.
786 \begin_layout Standard
790 \begin_layout Itemize
791 width: number : The width of the tilemap in tiles.
794 \begin_layout Itemize
795 height: number: The height of the tilemap in tiles.
798 \begin_layout Standard
799 Get size of tilemap in tiles.
802 \begin_layout Subsubsection
803 TILEMAP:getcsize: Query tilemap cell size
806 \begin_layout Itemize
807 Syntax: width, height tmap:getcsize()
810 \begin_layout Standard
814 \begin_layout Itemize
815 tmap: TILEMAP: The tilemap to query.
818 \begin_layout Standard
822 \begin_layout Itemize
823 width: number: The width of tilemap tile in pixels.
826 \begin_layout Itemize
827 height: number: The height of tilemap tile in pixels.
830 \begin_layout Standard
831 Get size of each tilemap tile in pixels.
834 \begin_layout Subsubsection
835 TILEMAP:get: Query tilemap tile
838 \begin_layout Itemize
839 Syntax: bitmap, palette tmap:get(x, y)
842 \begin_layout Standard
846 \begin_layout Itemize
847 tmap: TILEMAP: The tilemap to query.
850 \begin_layout Itemize
851 x: number: The x-coordinate of tile to query.
854 \begin_layout Itemize
855 y: number: The y-coordinate of tile to query.
858 \begin_layout Standard
862 \begin_layout Itemize
863 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
866 \begin_layout Itemize
867 palette: The palette (PALETTE) associated with indexed-color bitmap, if
872 \begin_layout Standard
873 Return the contents of tile at <x>,<y>.
876 \begin_layout Subsubsection
877 TILEMAP:set: Set tilemap cell
880 \begin_layout Itemize
881 Syntax: tmap:set(x, y)
884 \begin_layout Itemize
885 Syntax: tmap:set(x, y, bitmap)
888 \begin_layout Itemize
889 Syntax: tmap:set(x, y, bitmap, palette)
892 \begin_layout Standard
896 \begin_layout Itemize
897 tmap: TILEMAP: The tilemap to manipulate.
900 \begin_layout Itemize
901 number x: The x-coordinate of tile to set.
904 \begin_layout Itemize
905 number y: The y-coordinate of tile to set.
908 \begin_layout Itemize
909 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
912 \begin_layout Itemize
913 palette: PALETTE: The associated palette for bitmap.
916 \begin_layout Standard
917 Set the contents of tile <x>,<y>.
918 If no <bitmap> is given, clears the tile.
919 Otherwise sets the tile to contain bitmap <bitmap> with associated palette
923 \begin_layout Itemize
924 Specifying index bitmap <bitmap> without palette <palette> causes an error.
927 \begin_layout Subsubsection
928 TILEMAP:scroll: Scroll tilemap
931 \begin_layout Itemize
932 Syntax: tmap:scroll(ox, oy);
935 \begin_layout Itemize
936 Syntax: tmap:scroll(ox, oy, x, y, w, h);
939 \begin_layout Itemize
940 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
943 \begin_layout Standard
947 \begin_layout Itemize
948 tmap: TILEMAP: The tilemap to manipulate.
951 \begin_layout Itemize
952 ox: number: The number of tiles to scroll horizontally (positive is to right).
955 \begin_layout Itemize
956 oy: number: The number of tiles to scroll vertically (positive is to down).
959 \begin_layout Itemize
960 x: number: The left edge of scroll window.
963 \begin_layout Itemize
964 y: number: The top edge of scroll window.
967 \begin_layout Itemize
968 w: number: The width of scroll window.
971 \begin_layout Itemize
972 h: number: The height of scroll window.
975 \begin_layout Itemize
976 circ_x: boolean: If true, treat the window as circular in horizontal direction.
979 \begin_layout Itemize
980 circ_y: boolean: If true, treat the window as circular in vertical direction.
983 \begin_layout Standard
984 Scroll the specified tilemap <tmap> by <ox>,<oy>.
985 If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
986 <circ_x> and <circ_y> control if scroll is circular or not.
989 \begin_layout Itemize
990 Specifying out-of-range window causes an error.
993 \begin_layout Subsubsection
994 TILEMAP:draw: Draw tilemap
997 \begin_layout Itemize
998 Name: tmap:draw(x, y)
1001 \begin_layout Itemize
1002 Name: tmap:draw(x, y, x0, y0, w, h)
1005 \begin_layout Standard
1009 \begin_layout Itemize
1010 tmap: TILEMAP: The tilemap to draw.
1013 \begin_layout Itemize
1014 x: The x coordinate on screen to draw to.
1017 \begin_layout Itemize
1018 y: The y coordinate on screen to draw to.
1021 \begin_layout Itemize
1022 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1025 \begin_layout Itemize
1026 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1029 \begin_layout Itemize
1030 w: number: The width to draw (in pixels).
1033 \begin_layout Itemize
1034 h: number: The height to draw (in pixels).
1037 \begin_layout Standard
1038 Draw tilemap <tmap> to screen at <x>,<y>.
1039 If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1042 \begin_layout Itemize
1043 This method requires a rendering context to work.
1046 \begin_layout Subsubsection
1047 TILEMAP:draw_outside: Draw tilemap outside game area
1050 \begin_layout Itemize
1051 Name: tmap:draw_outside(x, y)
1054 \begin_layout Itemize
1055 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1058 \begin_layout Standard
1059 Like TILEMAP:draw, but draws only outside game area.
1062 \begin_layout Standard
1063 \begin_inset Newpage pagebreak
1069 \begin_layout Subsection
1070 RENDERCTX: Off-screen rendering context
1073 \begin_layout Standard
1074 Object acting as off-screen rendering context.
1077 \begin_layout Subsubsection
1078 Static function new: Create a render queue
1081 \begin_layout Itemize
1082 Syntax: renderctx gui.renderctx.new(width, height);
1085 \begin_layout Itemize
1086 Syntax: renderctx classes.RENDERCTX.new(width, height);
1089 \begin_layout Itemize
1090 Deprecated: renderctx gui.renderq_new(width, height);
1093 \begin_layout Standard
1097 \begin_layout Itemize
1098 width: number: The notional width of the game area.
1101 \begin_layout Itemize
1102 height: number: The notional height of the game area.
1105 \begin_layout Standard
1109 \begin_layout Itemize
1110 rendectx: RENDERCTX: The newly created render context.
1113 \begin_layout Standard
1114 Create a render context with reported size <width>*<height> and return it.
1117 \begin_layout Subsubsection
1118 Static function setnull: Reset to default queue
1121 \begin_layout Itemize
1122 Syntax: gui.renderctx.setnull()
1125 \begin_layout Itemize
1126 Syntax: classes.RENDERCTX:setnull()
1129 \begin_layout Itemize
1130 Deprecated: gui.renderq_set()
1133 \begin_layout Standard
1134 Reset the used render context back to default for the executing callback:
1137 \begin_layout Itemize
1138 The default for paint callback is the screen
1141 \begin_layout Itemize
1142 The default for video callback is the video frame
1145 \begin_layout Itemize
1146 The default otherwise is nothing.
1149 \begin_layout Subsubsection
1150 Method clear: Clear a render queue
1153 \begin_layout Itemize
1154 Syntax: renderctx:clear()
1157 \begin_layout Itemize
1158 Deprecated: gui.renderq_clear(renderctx)
1161 \begin_layout Standard
1165 \begin_layout Itemize
1166 renderctx: RENDERCTX: The render queue to clear.
1169 \begin_layout Standard
1170 Clear all drawing from the context.
1173 \begin_layout Subsubsection
1174 Method set: Change active render context
1177 \begin_layout Itemize
1178 Syntax: renderctx:set()
1181 \begin_layout Itemize
1182 Deprecated: gui.renderq_set(renderctx)
1185 \begin_layout Standard
1189 \begin_layout Itemize
1190 renderctx: RENDERCTX: The render queue to use.
1193 \begin_layout Standard
1194 Switch the current rendering context <renderctx>.
1197 \begin_layout Subsubsection
1198 Method run: Draw all objects in context to another
1201 \begin_layout Itemize
1202 Syntax: renderctx:run()
1205 \begin_layout Itemize
1206 Deprecated: gui.renderq_run(renderctx)
1209 \begin_layout Standard
1213 \begin_layout Itemize
1214 renderctx: RENDERCTX: The render context to overlay.
1217 \begin_layout Standard
1218 Overlay the specified render context <context> upon the active rendering
1222 \begin_layout Itemize
1223 Trying to overlay rendering context upon itself is a bad idea.
1226 \begin_layout Subsubsection
1227 Method render: Render a contex to bitmap
1230 \begin_layout Itemize
1231 Syntax: bitmap renderctx:render()
1234 \begin_layout Standard
1238 \begin_layout Itemize
1239 renderctx: RENDERCTX: The context to render.
1242 \begin_layout Standard
1246 \begin_layout Itemize
1247 bitmap: DBITMAP: The rendered bitmap.
1250 \begin_layout Standard
1251 Render the specified context <renderctx> to a new bitmap.
1254 \begin_layout Itemize
1255 The size of bitmap will be nominal game area size, plus any set gaps.
1258 \begin_layout Itemize
1259 This method does not require active rendering context.
1262 \begin_layout Subsubsection
1263 Method synchronous_repaint: Paint screen now
1266 \begin_layout Itemize
1267 Syntax: renderctx:synchronous_repaint()
1270 \begin_layout Itemize
1271 Deprecated: gui.synchronous_repaint(renderctx)
1274 \begin_layout Standard
1278 \begin_layout Itemize
1279 renderctx: RENDERCTX: The context to paint.
1282 \begin_layout Standard
1283 Immediately redraw the screen with game overlayed by drawings from context
1287 \begin_layout Itemize
1288 This does not require active rendering context.
1291 \begin_layout Itemize
1292 Will not cause paint callback to be invoked.
1295 \begin_layout Standard
1296 \begin_inset Newpage pagebreak
1302 \begin_layout Subsection
1303 PALETTE: Color palette for indexed image
1306 \begin_layout Subsubsection
1307 Static function new: Create a new palette
1310 \begin_layout Itemize
1311 Syntax: palette gui.palette.new()
1314 \begin_layout Itemize
1315 Syntax: palette classes.PALETTE.new()
1318 \begin_layout Itemize
1319 Deprecated: palette gui.palette_new()
1322 \begin_layout Standard
1326 \begin_layout Itemize
1327 palette: PALETTE: The created palette.
1330 \begin_layout Standard
1331 Create a new palette (with all colors transparent) and return it.
1334 \begin_layout Subsubsection
1335 Static function load: Load a palette
1338 \begin_layout Itemize
1339 Syntax: palette gui.palette.load(file, [base])
1342 \begin_layout Itemize
1343 Syntax: palette classes.PALETTE.load(file, [base])
1346 \begin_layout Itemize
1347 Deprecated: palette gui.palette_load(file, [base])
1350 \begin_layout Standard
1354 \begin_layout Itemize
1355 string file: The file to load.
1358 \begin_layout Itemize
1359 string base (optional): The base file to resolve file relative to.
1362 \begin_layout Standard
1366 \begin_layout Itemize
1367 palette: PALETTE: The loaded palette.
1370 \begin_layout Standard
1371 Load a palette from file <file> (resolved relative to <base>).
1374 \begin_layout Itemize
1375 The file format is a series of lines, each with following format:
1379 \begin_layout Itemize
1380 Blank or just whitespace: Ignored
1383 \begin_layout Itemize
1384 First non-whitespace is '#': Ignored
1387 \begin_layout Itemize
1388 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1391 \begin_layout Itemize
1392 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1393 (0-256, 0 being fully transparent and 256 fully opaque).
1396 \begin_layout Itemize
1397 transparent: Fully transparent color
1401 \begin_layout Subsubsection
1402 Static function load_str: Load a palette from string
1405 \begin_layout Itemize
1406 Syntax: palette gui.palette.load(data)
1409 \begin_layout Itemize
1410 Syntax: palette classes.PALETTE.load(data)
1413 \begin_layout Itemize
1414 Deprecated: palette gui.palette_load(data)
1417 \begin_layout Standard
1421 \begin_layout Itemize
1422 string data: The palette data.
1425 \begin_layout Standard
1429 \begin_layout Itemize
1430 palette: PALETTE: The loaded palette.
1433 \begin_layout Standard
1434 Like PALETTE:load, but instead of reading palette from file, reads it from
1438 \begin_layout Subsubsection
1439 Method set: Set palette entry
1442 \begin_layout Itemize
1443 Syntax: palette:set(index, color)
1446 \begin_layout Itemize
1447 Deprecated: gui.palette_set(palette, ...)
1450 \begin_layout Standard
1454 \begin_layout Itemize
1455 palette: PALETTE: The palette to manipulate
1458 \begin_layout Itemize
1459 index: number: The index of color to set (0-65535).
1462 \begin_layout Itemize
1463 color: number/string: The color value to set.
1466 \begin_layout Standard
1467 Set palette <palette> index <index> to color <color>.
1470 \begin_layout Subsubsection
1471 Method get: Get palette entry
1474 \begin_layout Itemize
1475 Syntax: number palette:get(index)
1478 \begin_layout Standard
1482 \begin_layout Itemize
1483 palette: PALETTE: The palette to query
1486 \begin_layout Itemize
1487 index: number: The index of color to get (0-65535).
1490 \begin_layout Standard
1494 \begin_layout Itemize
1495 The palette entry as integer.
1498 \begin_layout Standard
1499 Get palette entry <index> of palette <palette> and return it.
1502 \begin_layout Subsubsection
1503 Method hash: Hash a palette
1506 \begin_layout Itemize
1507 Syntax: hash palette:hash()
1510 \begin_layout Itemize
1511 Deprecated: hash gui.palette_hash(palette)
1514 \begin_layout Standard
1518 \begin_layout Itemize
1519 palette: The palette to hash.
1522 \begin_layout Standard
1526 \begin_layout Itemize
1527 hash: string: 64-hex digit hash.
1530 \begin_layout Standard
1531 Obtain crypto-grade hash of palette data of <palette>.
1534 \begin_layout Itemize
1535 All colors after the last non-transparent one are ignored.
1538 \begin_layout Subsubsection
1539 Method adjust_transparency: Adjust transparency
1542 \begin_layout Itemize
1543 Syntax: palette:adjust_transparency(newvalue)
1546 \begin_layout Itemize
1547 Deprecated: gui.adjust_transparency(palette, ...)
1550 \begin_layout Standard
1554 \begin_layout Itemize
1555 palette: PALETTE: The palette to adjust.
1558 \begin_layout Itemize
1559 Number adj: The factor to multiply opaqueness with times 256.
1562 \begin_layout Standard
1563 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1566 \begin_layout Standard
1567 \begin_inset Newpage pagebreak
1573 \begin_layout Subsection
1574 BITMAP: Indexed-color bitmap
1577 \begin_layout Subsubsection
1578 Static function new: Create a new bitmap
1581 \begin_layout Itemize
1582 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1585 \begin_layout Itemize
1586 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1589 \begin_layout Itemize
1590 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1593 \begin_layout Standard
1597 \begin_layout Itemize
1598 w: number: The width of bitmap to create in pixels.
1601 \begin_layout Itemize
1602 h: number: The height of bitmap to create in pixels.
1605 \begin_layout Itemize
1606 false: boolean: Constant boolean false.
1609 \begin_layout Itemize
1610 fillcolor: number: The initial fill index.
1611 Default 0 if not specified.
1614 \begin_layout Standard
1615 Create a new bitmap of size <w>*<h>.
1616 Fill the bitmap with color index <fillcolor>.
1619 \begin_layout Subsubsection
1620 Method draw: Draw a bitmap
1623 \begin_layout Itemize
1624 Syntax: bitmap:draw(x, y, palette)
1627 \begin_layout Itemize
1628 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1631 \begin_layout Standard
1635 \begin_layout Itemize
1636 bitmap: BITMAP: The bitmap to draw
1639 \begin_layout Itemize
1640 x: number: The x-coordinate on screen.
1643 \begin_layout Itemize
1644 y: number: The y-coordinate on screen.
1647 \begin_layout Itemize
1648 palette: The palette to use for drawing.
1651 \begin_layout Standard
1652 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1655 \begin_layout Subsubsection
1656 Method draw_outside: Draw a bitmap outside game area
1659 \begin_layout Itemize
1660 Syntax: bitmap:draw_outside(x, y, palette)
1663 \begin_layout Standard
1664 Like bitmap:draw, but does not draw on game area.
1667 \begin_layout Subsubsection
1668 Method draw_clip: Draw a bitmap, with clipping
1671 \begin_layout Itemize
1672 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1675 \begin_layout Standard
1679 \begin_layout Itemize
1680 bitmap: BITMAP: The bitmap to draw
1683 \begin_layout Itemize
1684 x: number: The x-coordinate on screen.
1687 \begin_layout Itemize
1688 y: number: The y-coordinate on screen.
1691 \begin_layout Itemize
1692 palette: The palette to use for drawing.
1695 \begin_layout Itemize
1696 x0: The smallest bitmap x coordinate to draw.
1699 \begin_layout Itemize
1700 y0: The smallest bitmap y coordinate to draw.
1703 \begin_layout Itemize
1704 width: Width of region to draw
1707 \begin_layout Itemize
1708 height: Height of region to draw.
1711 \begin_layout Standard
1712 Like bitmap:draw, but clip the bitmap area drawn.
1715 \begin_layout Subsubsection
1716 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1719 \begin_layout Itemize
1720 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1723 \begin_layout Standard
1724 Like bitmap:draw_clip, but only draw outside game area.
1727 \begin_layout Subsubsection
1728 Method pset: Set pixel in bitmap
1731 \begin_layout Itemize
1732 Syntax: bitmap:pset(x, y, color)
1735 \begin_layout Itemize
1736 Deprecaed: gui.bitmap_pset(bitmap, ...)
1739 \begin_layout Standard
1743 \begin_layout Itemize
1744 bitmap: BITMAP: The bitmap to manipulate.
1747 \begin_layout Itemize
1748 x: number: x-coordinate of pixel to set.
1751 \begin_layout Itemize
1752 y: number: y-coordinate of pixel to set.
1755 \begin_layout Itemize
1756 color: number: The color index to set.
1759 \begin_layout Standard
1760 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1763 \begin_layout Subsubsection
1764 Method pget: Get pixel in bitmap
1767 \begin_layout Itemize
1768 Syntax: color bitmap:pget(x,y)
1771 \begin_layout Itemize
1772 Deprecated: color gui.bitmap_pget(bitmap, ...)
1775 \begin_layout Standard
1779 \begin_layout Itemize
1780 bitmap: BITMAP: The bitmap to query.
1783 \begin_layout Itemize
1784 x: number: x-coordinate of pixel to get.
1787 \begin_layout Itemize
1788 y: number: y-coordinate of pixel to get.
1791 \begin_layout Standard
1795 \begin_layout Itemize
1796 color: number: The color index in specified pixel.
1799 \begin_layout Standard
1800 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1803 \begin_layout Subsubsection
1804 Method size: Get size of bitmap
1807 \begin_layout Itemize
1808 Syntax: width, height bitmap:size()
1811 \begin_layout Itemize
1812 Syntax: width, height gui.bitmap_size(bitmap)
1815 \begin_layout Standard
1819 \begin_layout Itemize
1820 bitmap: BITMAP: The bitmap to query.
1823 \begin_layout Standard
1827 \begin_layout Itemize
1828 width: number: The width of the bitmap.
1831 \begin_layout Itemize
1832 height: number: The height of the bitmap.
1835 \begin_layout Standard
1836 Get size of bitmap <bitmap>.
1839 \begin_layout Subsubsection
1840 Method blit: Blit a bitmap into another
1843 \begin_layout Itemize
1844 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1847 \begin_layout Itemize
1848 Deprecated: gui.bitmap_blit(dest, ...)
1851 \begin_layout Standard
1855 \begin_layout Itemize
1856 dest: BITMAP: The target bitmap to blit to.
1859 \begin_layout Itemize
1860 dx: number: The x-coordinate in target.
1863 \begin_layout Itemize
1864 dy: number: The y-coordinate in target.
1867 \begin_layout Itemize
1868 src: BITMAP: The source bitmap.
1871 \begin_layout Itemize
1872 sx: number: The x-coordinate in source.
1875 \begin_layout Itemize
1876 sy: number: The y-coordinate in source.
1879 \begin_layout Itemize
1880 w: number: The width of area to blit.
1883 \begin_layout Itemize
1884 h: number: The height of area to blit.
1887 \begin_layout Itemize
1888 ck: number: The color key.
1889 Pixels with this index are not copied.
1893 \begin_layout Itemize
1894 If none is specified, all pixels are copied.
1898 \begin_layout Standard
1899 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1901 If a color key <ck> is specified, pixels of that color are not copied.
1904 \begin_layout Subsubsection
1905 Method blit_scaled: Blit a bitmap into another with scaling
1908 \begin_layout Itemize
1909 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1912 \begin_layout Itemize
1913 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1916 \begin_layout Standard
1920 \begin_layout Itemize
1921 dest: BITMAP: The target bitmap to blit to.
1924 \begin_layout Itemize
1925 dx: number: The x-coordinate in target.
1928 \begin_layout Itemize
1929 dy: number: The y-coordinate in target.
1932 \begin_layout Itemize
1933 src: BITMAP: The source bitmap.
1936 \begin_layout Itemize
1937 sx: number: The x-coordinate in source.
1940 \begin_layout Itemize
1941 sy: number: The y-coordinate in source.
1944 \begin_layout Itemize
1945 w: number: The width of area to blit.
1948 \begin_layout Itemize
1949 h: number: The height of area to blit.
1952 \begin_layout Itemize
1953 hscl: number: Horizontal scale factor (integer).
1956 \begin_layout Itemize
1957 vscl: number: Vertical scale factor (integer).
1958 Defaults to the same as <hscl>.
1961 \begin_layout Itemize
1962 ck: number: The color key.
1963 Pixels with this index are not copied.
1967 \begin_layout Itemize
1968 If none is specified, all pixels are copied.
1972 \begin_layout Standard
1973 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1974 neighbor) by factor of <hscl>*<vscl>.
1977 \begin_layout Subsubsection
1978 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1981 \begin_layout Itemize
1982 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1985 \begin_layout Itemize
1986 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1989 \begin_layout Standard
1993 \begin_layout Itemize
1994 dest: BITMAP: The target bitmap to blit to.
1997 \begin_layout Itemize
1998 dx: number: The x-coordinate in target.
2001 \begin_layout Itemize
2002 dy: number: The y-coordinate in target.
2005 \begin_layout Itemize
2006 src: BITMAP: The source bitmap.
2009 \begin_layout Itemize
2010 sx: number: The x-coordinate in source.
2013 \begin_layout Itemize
2014 sy: number: The y-coordinate in source.
2017 \begin_layout Itemize
2018 w: number: The width of area to blit.
2021 \begin_layout Itemize
2022 h: number: The height of area to blit.
2025 \begin_layout Itemize
2026 operator: string: The operator to use.
2030 \begin_layout Itemize
2031 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2032 DestOut, Clear or Xor.
2036 \begin_layout Standard
2037 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2042 \begin_layout Itemize
2043 Color index 0 in source and target is treated as background.
2046 \begin_layout Subsubsection
2047 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2048 Porter-Duff composition
2051 \begin_layout Itemize
2052 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2056 \begin_layout Itemize
2057 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2060 \begin_layout Standard
2064 \begin_layout Itemize
2065 dest: BITMAP: The target bitmap to blit to.
2068 \begin_layout Itemize
2069 dx: number: The x-coordinate in target.
2072 \begin_layout Itemize
2073 dy: number: The y-coordinate in target.
2076 \begin_layout Itemize
2077 src: BITMAP: The source bitmap.
2080 \begin_layout Itemize
2081 sx: number: The x-coordinate in source.
2084 \begin_layout Itemize
2085 sy: number: The y-coordinate in source.
2088 \begin_layout Itemize
2089 w: number: The width of area to blit.
2092 \begin_layout Itemize
2093 h: number: The height of area to blit.
2096 \begin_layout Itemize
2097 hscl: number: Horizontal scale factor (integer).
2100 \begin_layout Itemize
2101 vscl: number: Vertical scale factor (integer).
2102 Defaults to the same as <hscl>.
2105 \begin_layout Itemize
2106 operator: string: The operator to use.
2110 \begin_layout Itemize
2111 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2112 DestOut, Clear or Xor.
2116 \begin_layout Standard
2117 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2118 like BITMAP:blit_scaled.
2121 \begin_layout Subsubsection
2122 Method blit_priority: Blit a bitmap into another with color priority
2125 \begin_layout Itemize
2126 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2129 \begin_layout Itemize
2130 Deprecated: gui.bitmap_blit_priority(dest, ...)
2133 \begin_layout Standard
2137 \begin_layout Itemize
2138 dest: BITMAP: The target bitmap to blit to.
2141 \begin_layout Itemize
2142 dx: number: The x-coordinate in target.
2145 \begin_layout Itemize
2146 dy: number: The y-coordinate in target.
2149 \begin_layout Itemize
2150 src: BITMAP: The source bitmap.
2153 \begin_layout Itemize
2154 sx: number: The x-coordinate in source.
2157 \begin_layout Itemize
2158 sy: number: The y-coordinate in source.
2161 \begin_layout Itemize
2162 w: number: The width of area to blit.
2165 \begin_layout Itemize
2166 h: number: The height of area to blit.
2169 \begin_layout Standard
2170 Like BITMAP:blit, but only copy pixels where source color index is greater
2171 than destination color index.
2174 \begin_layout Subsubsection
2175 Method blit_scaled_priority: Blit a bitmap into another with color priority
2179 \begin_layout Itemize
2180 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2183 \begin_layout Itemize
2184 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2187 \begin_layout Standard
2191 \begin_layout Itemize
2192 dest: BITMAP: The target bitmap to blit to.
2195 \begin_layout Itemize
2196 dx: number: The x-coordinate in target.
2199 \begin_layout Itemize
2200 dy: number: The y-coordinate in target.
2203 \begin_layout Itemize
2204 src: BITMAP: The source bitmap.
2207 \begin_layout Itemize
2208 sx: number: The x-coordinate in source.
2211 \begin_layout Itemize
2212 sy: number: The y-coordinate in source.
2215 \begin_layout Itemize
2216 w: number: The width of area to blit.
2219 \begin_layout Itemize
2220 h: number: The height of area to blit.
2223 \begin_layout Itemize
2224 hscl: number: Horizontal scale factor (integer).
2227 \begin_layout Itemize
2228 vscl: number: Vertical scale factor (integer).
2229 Defaults to the same as <hscl>.
2232 \begin_layout Standard
2233 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2237 \begin_layout Subsubsection
2238 Method save_png: Save a bitmap to PNG
2241 \begin_layout Itemize
2242 Syntax: bitmap:save_png(filename, [base], palette)
2245 \begin_layout Itemize
2246 Syntax: data bitmap:save_png(palette)
2249 \begin_layout Itemize
2251 gui.bitmap_save_png(bitmap, ...)
2254 \begin_layout Standard
2258 \begin_layout Itemize
2259 bitmap: BITMAP: The bitmap to save.
2262 \begin_layout Itemize
2263 filename: string: The filename to save to.
2266 \begin_layout Itemize
2267 base: string: The base filename is resolved relative to.
2270 \begin_layout Itemize
2271 palette: PALETTE: The palette to use.
2274 \begin_layout Standard
2278 \begin_layout Itemize
2279 data: string: BASE64 encoded PNG data.
2282 \begin_layout Standard
2283 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2284 to <base>) or return BASE64 encoding of it.
2287 \begin_layout Subsubsection
2288 Method hash: Hash a bitmap
2291 \begin_layout Itemize
2292 Syntax: hash bitmap:hash()
2295 \begin_layout Itemize
2296 Deprecated: hash bitmap:hash(bitmap)
2299 \begin_layout Standard
2303 \begin_layout Itemize
2304 bitmap: BITMAP: The bitmap to hash.
2307 \begin_layout Standard
2311 \begin_layout Itemize
2312 hash: string: 64-hex digit hash
2315 \begin_layout Standard
2316 Hashes bitmap <bitmap> and returns crypto-strong hash.
2320 \begin_layout Itemize
2321 Color order in bitmap is significant.
2324 \begin_layout Standard
2325 \begin_inset Newpage pagebreak
2331 \begin_layout Subsection
2332 DBITMAP: Direct-color bitmap
2335 \begin_layout Subsubsection
2336 Static function: new: Create a new bitmap
2339 \begin_layout Itemize
2340 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2343 \begin_layout Itemize
2344 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2347 \begin_layout Itemize
2348 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2351 \begin_layout Standard
2355 \begin_layout Itemize
2356 w: number: The width of new bitmap.
2359 \begin_layout Itemize
2360 h: number: The height of new bitmap.
2363 \begin_layout Itemize
2364 true: boolean: Fixed boolean true
2367 \begin_layout Itemize
2368 fillcolor: The color to fill the bitmap with (default transparent).
2371 \begin_layout Standard
2375 \begin_layout Itemize
2376 bitmap: DBITMAP: The new bitmap.
2379 \begin_layout Standard
2380 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2384 \begin_layout Subsubsection
2385 Method draw: Draw a bitmap
2388 \begin_layout Itemize
2389 Syntax: bitmap.draw(x, y)
2392 \begin_layout Itemize
2393 Deprecated: gui.bitmap_draw(x, y, bitmap)
2396 \begin_layout Standard
2400 \begin_layout Itemize
2401 bitmap: DBITMAP: The bitmap to draw.
2404 \begin_layout Itemize
2405 x: number: X-coordinate on screen.
2408 \begin_layout Itemize
2409 y: number: Y-coordinate on screen.
2412 \begin_layout Standard
2413 Draw bitmap <bitmap> on screen at <x>,<y>.
2416 \begin_layout Subsubsection
2417 Method draw_outside: Draw a bitmap outside game area
2420 \begin_layout Itemize
2421 Syntax: dbitmap:draw_outside(x, y, palette)
2424 \begin_layout Standard
2425 Like dbitmap:draw, but does not draw on game area.
2428 \begin_layout Subsubsection
2429 Method draw_clip: Draw a bitmap, with clipping
2432 \begin_layout Itemize
2433 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2436 \begin_layout Standard
2440 \begin_layout Itemize
2441 bitmap: DBITMAP: The bitmap to draw
2444 \begin_layout Itemize
2445 x: number: The x-coordinate on screen.
2448 \begin_layout Itemize
2449 y: number: The y-coordinate on screen.
2452 \begin_layout Itemize
2453 x0: The smallest bitmap x coordinate to draw.
2456 \begin_layout Itemize
2457 y0: The smallest bitmap y coordinate to draw.
2460 \begin_layout Itemize
2461 width: Width of region to draw
2464 \begin_layout Itemize
2465 height: Height of region to draw.
2468 \begin_layout Standard
2469 Like dbitmap:draw, but clip the bitmap area drawn.
2472 \begin_layout Subsubsection
2473 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2476 \begin_layout Itemize
2477 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2480 \begin_layout Standard
2481 Like dbitmap:draw_clip, but only draw outside game area.
2484 \begin_layout Subsubsection
2485 Method pset: Set pixel in bitmap
2488 \begin_layout Itemize
2489 Syntax: bitmap:pset(x, y, color)
2492 \begin_layout Itemize
2493 Deprecaed: gui.bitmap_pset(bitmap, ...)
2496 \begin_layout Standard
2500 \begin_layout Itemize
2501 bitmap: DBITMAP: The bitmap to manipulate.
2504 \begin_layout Itemize
2505 x: number: x-coordinate of pixel to set.
2508 \begin_layout Itemize
2509 y: number: y-coordinate of pixel to set.
2512 \begin_layout Itemize
2513 color: number/string: The color to set.
2516 \begin_layout Standard
2517 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2520 \begin_layout Subsubsection
2521 Method pget: Get pixel in bitmap
2524 \begin_layout Itemize
2525 Syntax: color bitmap:pget(x,y)
2528 \begin_layout Itemize
2529 Deprecated: color gui.bitmap_pget(bitmap, ...)
2532 \begin_layout Standard
2536 \begin_layout Itemize
2537 bitmap: DBITMAP: The bitmap to query.
2540 \begin_layout Itemize
2541 x: number: x-coordinate of pixel to get.
2544 \begin_layout Itemize
2545 y: number: y-coordinate of pixel to get.
2548 \begin_layout Standard
2552 \begin_layout Itemize
2553 color: number: The color of specified pixel.
2556 \begin_layout Standard
2557 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2560 \begin_layout Subsubsection
2561 Method size: Get size of bitmap
2564 \begin_layout Itemize
2565 Syntax: width, height bitmap:size()
2568 \begin_layout Itemize
2569 Syntax: width, height gui.bitmap_size(bitmap)
2572 \begin_layout Standard
2576 \begin_layout Itemize
2577 bitmap: DBITMAP: The bitmap to query.
2580 \begin_layout Standard
2584 \begin_layout Itemize
2585 width: number: The width of the bitmap.
2588 \begin_layout Itemize
2589 height: number: The height of the bitmap.
2592 \begin_layout Standard
2593 Get size of bitmap <bitmap>.
2596 \begin_layout Subsubsection
2597 Method blit: Blit a bitmap into another
2600 \begin_layout Itemize
2601 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2604 \begin_layout Itemize
2605 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2608 \begin_layout Itemize
2609 Deprecated: gui.bitmap_blit(dest, ...)
2612 \begin_layout Standard
2616 \begin_layout Itemize
2617 dest: DBITMAP: The target bitmap to blit to.
2620 \begin_layout Itemize
2621 dx: number: The x-coordinate in target.
2624 \begin_layout Itemize
2625 dy: number: The y-coordinate in target.
2628 \begin_layout Itemize
2629 src: BITMAP/DBITMAP: The source bitmap.
2632 \begin_layout Itemize
2633 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2636 \begin_layout Itemize
2637 sx: number: The x-coordinate in source.
2640 \begin_layout Itemize
2641 sy: number: The y-coordinate in source.
2644 \begin_layout Itemize
2645 w: number: The width of area to blit.
2648 \begin_layout Itemize
2649 h: number: The height of area to blit.
2652 \begin_layout Itemize
2653 ck: number: The color key.
2654 Pixels with this index are not copied.
2658 \begin_layout Itemize
2659 If none is specified, all pixels are copied.
2662 \begin_layout Itemize
2663 If <src> is paletted, this is color index, otherwise it is a color.
2667 \begin_layout Standard
2668 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2669 if indexed) into <dest> at <dx>,<dy>.
2670 If a color key <ck> is specified, pixels of that color are not copied.
2673 \begin_layout Subsubsection
2674 Method blit_scaled: Blit a bitmap into another with scaling
2677 \begin_layout Itemize
2678 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2681 \begin_layout Itemize
2682 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2686 \begin_layout Itemize
2687 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2690 \begin_layout Standard
2694 \begin_layout Itemize
2695 dest: DBITMAP: The target bitmap to blit to.
2698 \begin_layout Itemize
2699 dx: number: The x-coordinate in target.
2702 \begin_layout Itemize
2703 dy: number: The y-coordinate in target.
2706 \begin_layout Itemize
2707 src: BITMAP/DBITMAP: The source bitmap.
2710 \begin_layout Itemize
2711 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2714 \begin_layout Itemize
2715 sx: number: The x-coordinate in source.
2718 \begin_layout Itemize
2719 sy: number: The y-coordinate in source.
2722 \begin_layout Itemize
2723 w: number: The width of area to blit.
2726 \begin_layout Itemize
2727 h: number: The height of area to blit.
2730 \begin_layout Itemize
2731 hscl: number: Horizontal scale factor (integer).
2734 \begin_layout Itemize
2735 vscl: number: Vertical scale factor (integer).
2736 Defaults to the same as <hscl>.
2739 \begin_layout Itemize
2740 ck: number: The color key.
2741 Pixels with this index are not copied.
2745 \begin_layout Itemize
2746 If none is specified, all pixels are copied.
2749 \begin_layout Itemize
2750 If <src> is paletted, this is color index, otherwise it is a color.
2754 \begin_layout Standard
2755 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2756 neighbor) by factor of <hscl>*<vscl>.
2759 \begin_layout Subsubsection
2760 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2763 \begin_layout Itemize
2764 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2767 \begin_layout Itemize
2768 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2771 \begin_layout Itemize
2772 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2775 \begin_layout Standard
2779 \begin_layout Itemize
2780 dest: DBITMAP: The target bitmap to blit to.
2783 \begin_layout Itemize
2784 dx: number: The x-coordinate in target.
2787 \begin_layout Itemize
2788 dy: number: The y-coordinate in target.
2791 \begin_layout Itemize
2792 src: BITMAP/DBITMAP: The source bitmap.
2795 \begin_layout Itemize
2796 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2799 \begin_layout Itemize
2800 sx: number: The x-coordinate in source.
2803 \begin_layout Itemize
2804 sy: number: The y-coordinate in source.
2807 \begin_layout Itemize
2808 w: number: The width of area to blit.
2811 \begin_layout Itemize
2812 h: number: The height of area to blit.
2815 \begin_layout Itemize
2816 operator: string: The operator to use.
2820 \begin_layout Itemize
2821 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2822 DestOut, Clear or Xor.
2826 \begin_layout Standard
2827 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2832 \begin_layout Itemize
2833 In target, fully transparent is background.
2834 In source, either fully transparent (if direct) or index 0 (if paletted)
2835 is treated as background.
2838 \begin_layout Subsubsection
2839 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2840 Porter-Duff composition
2843 \begin_layout Itemize
2844 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2848 \begin_layout Itemize
2849 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2853 \begin_layout Itemize
2854 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2857 \begin_layout Standard
2861 \begin_layout Itemize
2862 dest: DBITMAP: The target bitmap to blit to.
2865 \begin_layout Itemize
2866 dx: number: The x-coordinate in target.
2869 \begin_layout Itemize
2870 dy: number: The y-coordinate in target.
2873 \begin_layout Itemize
2874 src: BITMAP/DBITMAP: The source bitmap.
2877 \begin_layout Itemize
2878 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2881 \begin_layout Itemize
2882 sx: number: The x-coordinate in source.
2885 \begin_layout Itemize
2886 sy: number: The y-coordinate in source.
2889 \begin_layout Itemize
2890 w: number: The width of area to blit.
2893 \begin_layout Itemize
2894 h: number: The height of area to blit.
2897 \begin_layout Itemize
2898 hscl: number: Horizontal scale factor (integer).
2901 \begin_layout Itemize
2902 vscl: number: Vertical scale factor (integer).
2903 Defaults to the same as <hscl>.
2906 \begin_layout Itemize
2907 operator: string: The operator to use.
2911 \begin_layout Itemize
2912 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2913 DestOut, Clear or Xor.
2917 \begin_layout Standard
2918 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2919 like DBITMAP:blit_scaled.
2922 \begin_layout Subsubsection
2923 Method adjust_transparency: Adjust transparency of bitmap
2926 \begin_layout Itemize
2927 Syntax: bitmap:adjust_transparency(newvalue)
2930 \begin_layout Itemize
2931 Deprecated: gui.adjust_transparency(bitmap, ...)
2934 \begin_layout Standard
2938 \begin_layout Itemize
2939 bitmap: DBITMAP: The bitmap to adjust.
2942 \begin_layout Itemize
2943 Number adj: The factor to multiply opaqueness with times 256.
2946 \begin_layout Standard
2947 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2950 \begin_layout Subsubsection
2951 Method save_png: Save a bitmap to PNG
2954 \begin_layout Itemize
2955 Syntax: bitmap:save_png(filename, [base])
2958 \begin_layout Itemize
2959 Syntax: data bitmap:save_png()
2962 \begin_layout Itemize
2964 gui.bitmap_save_png(bitmap, ...)
2967 \begin_layout Standard
2971 \begin_layout Itemize
2972 bitmap: DBITMAP: The bitmap to save.
2975 \begin_layout Itemize
2976 filename: string: The filename to save to.
2979 \begin_layout Itemize
2980 base: string: The base filename is resolved relative to.
2983 \begin_layout Standard
2987 \begin_layout Itemize
2988 data: string: BASE64 encoded PNG data.
2991 \begin_layout Standard
2992 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2993 BASE64 encoding of it.
2996 \begin_layout Subsubsection
2997 Method hash: Hash a bitmap
3000 \begin_layout Itemize
3001 Syntax: hash bitmap:hash()
3004 \begin_layout Itemize
3005 Deprecated: hash bitmap:hash(bitmap)
3008 \begin_layout Standard
3012 \begin_layout Itemize
3013 bitmap: DBITMAP: The bitmap to hash.
3016 \begin_layout Standard
3020 \begin_layout Itemize
3021 hash: string: 64-hex digit hash
3024 \begin_layout Standard
3025 Hashes bitmap <bitmap> and returns crypto-strong hash.
3029 \begin_layout Subsection
3030 IMAGELOADER: Load an image
3033 \begin_layout Subsubsection
3034 Static function load: Load a bitmap from file
3037 \begin_layout Itemize
3038 Syntax: bitmap, palette gui.image.load(file, [base])
3041 \begin_layout Itemize
3042 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3045 \begin_layout Itemize
3047 gui.bitmap_load(...)
3050 \begin_layout Standard
3054 \begin_layout Itemize
3055 file: string: The file to read.
3058 \begin_layout Itemize
3059 base: string: The base to resolve <file> relative to.
3062 \begin_layout Standard
3066 \begin_layout Itemize
3067 bitmap: BITMAP/DBITMAP: The new bitmap
3070 \begin_layout Itemize
3071 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3075 \begin_layout Standard
3076 Load a new bitmap and return it (plus associated palette if any).
3079 \begin_layout Subsubsection
3080 Static function load_str: Load a bitmap from string
3083 \begin_layout Itemize
3084 Syntax: bitmap, palette gui.image.load_str(data)
3087 \begin_layout Itemize
3088 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3091 \begin_layout Itemize
3093 gui.bitmap_load_str(...)
3096 \begin_layout Standard
3100 \begin_layout Itemize
3101 data: string: The image data
3104 \begin_layout Standard
3108 \begin_layout Itemize
3109 bitmap: BITMAP/DBITMAP: The new bitmap
3112 \begin_layout Itemize
3113 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3117 \begin_layout Standard
3118 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3122 \begin_layout Subsubsection
3123 Static function load_png: Load a bitmap from PNG file
3126 \begin_layout Itemize
3127 Syntax: bitmap, palette gui.image.load_png(file, [base])
3130 \begin_layout Itemize
3131 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3134 \begin_layout Itemize
3136 gui.bitmap_load_png(...)
3139 \begin_layout Standard
3143 \begin_layout Itemize
3144 file: string: The file to read.
3147 \begin_layout Itemize
3148 base: string: The base to resolve <file> relative to.
3151 \begin_layout Standard
3155 \begin_layout Itemize
3156 bitmap: BITMAP/DBITMAP: The new bitmap
3159 \begin_layout Itemize
3160 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3164 \begin_layout Standard
3165 Like IMAGELOADER:load, but load a PNG file instead.
3168 \begin_layout Subsubsection
3169 Static function load_png_str: Load a PNG bitmap from string
3172 \begin_layout Itemize
3173 Syntax: bitmap, palette gui.image.load_png_str(data)
3176 \begin_layout Itemize
3177 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3180 \begin_layout Itemize
3182 gui.bitmap_load_png_str(...)
3185 \begin_layout Standard
3189 \begin_layout Itemize
3190 data: string: The image data, base64 encoded.
3193 \begin_layout Standard
3197 \begin_layout Itemize
3198 bitmap: BITMAP/DBITMAP: The new bitmap
3201 \begin_layout Itemize
3202 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3206 \begin_layout Standard
3207 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3208 <data> instead of file.
3211 \begin_layout Standard
3212 \begin_inset Newpage pagebreak
3218 \begin_layout Subsection
3219 CUSTOMFONT: Arbitrary-sized bitmap font
3222 \begin_layout Subsubsection
3223 Static function new: Return a new empty font
3226 \begin_layout Itemize
3227 Syntax: font gui.font.new()
3230 \begin_layout Itemize
3231 Syntax: font classes.CUSTOMFONT.new()
3234 \begin_layout Itemize
3235 Deprecated: font gui.font_new()
3238 \begin_layout Standard
3242 \begin_layout Itemize
3243 font: CUSTOMFONT: New font.
3246 \begin_layout Standard
3247 Create a new font with no characters and return it.
3250 \begin_layout Subsubsection
3251 Static function: load: Load a font file
3254 \begin_layout Itemize
3255 Syntax: font gui.font.load(file, [base])
3258 \begin_layout Itemize
3259 Syntax: font gui.font.load()
3262 \begin_layout Itemize
3263 Syntax: font classes.CUSTOMFONT.load(file, [base])
3266 \begin_layout Itemize
3267 Syntax: font classes.CUSTOMFONT.load()
3270 \begin_layout Itemize
3271 Deprecated: font gui.loadfont(...)
3274 \begin_layout Standard
3278 \begin_layout Itemize
3279 file: string: The file to read the font from
3282 \begin_layout Itemize
3283 base: string: The file to resolve <file> relative to.
3286 \begin_layout Standard
3290 \begin_layout Itemize
3291 font: CUSTOMFONT: New font.
3294 \begin_layout Standard
3295 Load font from file <file> (relative to <base>).
3296 If no filename is given, system default font is loaded.
3299 \begin_layout Subsubsection
3300 operator(): Render text to screen
3303 \begin_layout Itemize
3304 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3307 \begin_layout Standard
3311 \begin_layout Itemize
3312 font: CUSTOMFONT: The font to use.
3315 \begin_layout Itemize
3316 x: number: The x-position on screen to draw to.
3319 \begin_layout Itemize
3320 y: number: The y-position on screen to draw to.
3323 \begin_layout Itemize
3324 text: string: The text to draw.
3327 \begin_layout Itemize
3328 fgc: number/string: Foreground color (default white).
3331 \begin_layout Itemize
3332 bgc: number/string: Background color (default transparent).
3335 \begin_layout Itemize
3336 hlc: number/string: Outline color (default transparent).
3339 \begin_layout Standard
3340 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3344 \begin_layout Itemize
3345 If <hlc> is transparent, no outline is drawn.
3348 \begin_layout Subsubsection
3349 Method edit: Alter glyph in font
3352 \begin_layout Itemize
3353 Syntax: font:edit(character, glyph)
3356 \begin_layout Standard
3360 \begin_layout Itemize
3361 font: CUSTOMFONT: The font to edit.
3364 \begin_layout Itemize
3365 character: string: The character to edit (UTF-8 encoded).
3368 \begin_layout Itemize
3369 glyph: BITMAP: The bitmap to use.
3372 \begin_layout Standard
3373 Replace character <character> in font <font> by <glyph>.
3376 \begin_layout Itemize
3377 Color index 0 is background, everything else is foreground.
3380 \begin_layout Itemize
3381 <character> may be empty string, meaning the replacement character used
3385 \begin_layout Itemize
3386 <character> may be multi-codepoint string, meaning character used for that
3390 \begin_layout Standard
3391 \begin_inset Newpage pagebreak
3397 \begin_layout Subsection
3398 ICONV: Character set conversions
3401 \begin_layout Subsubsection
3402 Static function new: Create new character set converter
3405 \begin_layout Itemize
3406 Syntax: iconv iconv.new(from, to);
3409 \begin_layout Itemize
3410 Syntax: iconv classes.ICONV.new(from, to);
3413 \begin_layout Itemize
3414 Deprecated: iconv iconv_new(...);
3417 \begin_layout Standard
3421 \begin_layout Itemize
3422 from: string: The source character set.
3425 \begin_layout Itemize
3426 to: string: The target character set.
3429 \begin_layout Standard
3433 \begin_layout Itemize
3434 iconv: ICONV: The converter.
3437 \begin_layout Standard
3438 Create a character set converter, converting from <from> to <to> and return
3442 \begin_layout Subsubsection
3443 Operator(): Convert string fragment from character set to another
3446 \begin_layout Itemize
3447 Syntax: success, result, unconverted, error iconv(input)
3450 \begin_layout Standard
3454 \begin_layout Itemize
3455 iconv: ICONV: The context to use.
3458 \begin_layout Itemize
3459 input: string: The input to convert.
3462 \begin_layout Standard
3466 \begin_layout Itemize
3467 success: boolean: True if conversion was successful, false if not.
3470 \begin_layout Itemize
3471 result: string: The string (partially) converted.
3474 \begin_layout Itemize
3475 unconvered: number: Number of bytes that were not converted (only if <success>
3479 \begin_layout Itemize
3480 error: string: Error that caused conversion to stop (only if <success> is
3485 \begin_layout Itemize
3486 INVALID: The input string is invalid.
3489 \begin_layout Itemize
3490 INCOMPLETE: The input string cuts off in middle of character.
3493 \begin_layout Itemize
3494 INTERNALERR: Internal error.
3498 \begin_layout Standard
3499 Convert a string <input> using character set converter <iconv> and return
3503 \begin_layout Standard
3504 \begin_inset Newpage pagebreak
3510 \begin_layout Subsection
3511 FILEREADER: Read a file as a stream
3514 \begin_layout Subsubsection
3515 Static function open: Open a stream
3518 \begin_layout Itemize
3519 Syntax: handle filereader.open(file, [base])
3522 \begin_layout Itemize
3523 Syntax: handle classes.FILEREADER.open(file, [base])
3526 \begin_layout Itemize
3527 Deprecated: handle open_file(file, [base])
3530 \begin_layout Standard
3534 \begin_layout Itemize
3535 file: string: The filename to read.
3538 \begin_layout Itemize
3539 base: string: The base <file> is resolved against.
3542 \begin_layout Standard
3546 \begin_layout Itemize
3547 handle: FILEREADER: The new file reader.
3550 \begin_layout Standard
3551 Open file <file> (relative to <base>) and return a handle to it.
3554 \begin_layout Subsubsection
3555 operator(): Read line/bytes from stream
3558 \begin_layout Itemize
3559 Syntax: result handle()
3562 \begin_layout Itemize
3563 Syntax: result handle(bytes)
3566 \begin_layout Standard
3570 \begin_layout Itemize
3571 handle: FILEREADER: The handle to read from.
3574 \begin_layout Itemize
3575 bytes: Number of bytes to read (default is next line).
3578 \begin_layout Standard
3582 \begin_layout Itemize
3583 result: string: The read data, or nil on end-of-file.
3586 \begin_layout Standard
3587 Reads next line or <bytes> bytes from specified file handle <handle>.
3590 \begin_layout Itemize
3591 If reading specified number of bytes, the bytes are read in binary mode
3595 \begin_layout Itemize
3596 If reading next line, the line is read in text mode (any line ending is
3600 \begin_layout Subsubsection
3601 Method lines: Iterator to read all lines
3604 \begin_layout Itemize
3605 Syntax: for line in handle:lines() do ...
3609 \begin_layout Standard
3613 \begin_layout Itemize
3614 handle: FILEREADER: The handle to read.
3617 \begin_layout Standard
3621 \begin_layout Itemize
3622 A lua iterator with one variable.
3625 \begin_layout Standard
3626 Return a Lua iterator that iterates all the lines in <handle>.
3629 \begin_layout Standard
3630 \begin_inset Newpage pagebreak
3636 \begin_layout Subsection
3637 COMPARE_OBJ: Watch memory area for changes
3640 \begin_layout Standard
3641 Objects of this class allow fast checking for modifications to given memory
3645 \begin_layout Subsubsection
3646 Static function new: Create a checker
3649 \begin_layout Itemize
3650 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3654 \begin_layout Itemize
3655 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3658 \begin_layout Standard
3662 \begin_layout Itemize
3663 marea: string: The memory area to interpret <offset> against.
3666 \begin_layout Itemize
3667 offset: number: The initial offset in memory area.
3670 \begin_layout Itemize
3671 addrobj: ADDRESS: The memory address.
3674 \begin_layout Itemize
3675 size: number: The number of bytes in each row.
3678 \begin_layout Itemize
3679 rows: number: The number of rows.
3683 \begin_layout Itemize
3684 stride: number: The number of bytes offset increments from one row to next.
3687 \begin_layout Standard
3691 \begin_layout Itemize
3695 \begin_layout Standard
3696 Return an object watching specified memory area.
3699 \begin_layout Itemize
3700 Note: For fastest operation, limit checks to inside one memory area (that
3701 has to be mappable, individual RAM areas often are).
3704 \begin_layout Subsubsection
3705 operator(): Check area for modifications
3708 \begin_layout Itemize
3709 Syntax: boolean handle()
3712 \begin_layout Standard
3716 \begin_layout Itemize
3717 True if memory block has been modified since last call (or object creation
3718 if first call), false if not.
3721 \begin_layout Standard
3722 Check if the block has been modified.
3725 \begin_layout Subsection
3726 ADDRESS: Memory address
3729 \begin_layout Standard
3730 Objects of this class contain a memory address.
3733 \begin_layout Subsubsection
3734 Static function new: Create new memory address
3737 \begin_layout Itemize
3738 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
3741 \begin_layout Itemize
3742 Syntax: ADDRESS memory.address.new(string marea, number offset)
3745 \begin_layout Itemize
3746 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
3749 \begin_layout Standard
3753 \begin_layout Itemize
3754 marea: The memory area
3757 \begin_layout Itemize
3758 offset: The offset in memory area.
3761 \begin_layout Standard
3765 \begin_layout Itemize
3769 \begin_layout Standard
3770 Construct a new memory address object.
3773 \begin_layout Subsubsection
3774 Method: addr: Get global address
3777 \begin_layout Itemize
3778 Syntax: number addr:addr()
3781 \begin_layout Standard
3785 \begin_layout Itemize
3786 addr: ADRESS: The original address.
3789 \begin_layout Standard
3793 \begin_layout Itemize
3794 The global address corresponding to this address.
3797 \begin_layout Subsubsection
3798 Method: vma: Get memory area
3801 \begin_layout Itemize
3802 Syntax: string addr:vma()
3805 \begin_layout Standard
3809 \begin_layout Itemize
3810 addr: ADRESS: The original address.
3813 \begin_layout Standard
3817 \begin_layout Itemize
3818 The memory area corresponding to this address.
3821 \begin_layout Subsubsection
3822 Method: offset: Get memory area offset
3825 \begin_layout Itemize
3826 Syntax: string addr:offset()
3829 \begin_layout Standard
3833 \begin_layout Itemize
3834 addr: ADRESS: The original address.
3837 \begin_layout Standard
3841 \begin_layout Itemize
3842 The offset in memory area corresponding to this address.
3845 \begin_layout Subsubsection
3846 Method: replace: Replace address part
3849 \begin_layout Itemize
3850 Syntax: ADDRESS addr:replace(offset[, bits])
3853 \begin_layout Standard
3857 \begin_layout Itemize
3858 addr: ADRESS: The original address.
3861 \begin_layout Itemize
3862 offset: number: The new offset
3865 \begin_layout Itemize
3866 bits: number: The number of LSB to replace.
3869 \begin_layout Standard
3873 \begin_layout Itemize
3874 The modified address
3877 \begin_layout Standard
3878 Returns a new address, with <bits> (all if missing) least significant bits
3879 of <addr> replaced by LSB of <offset>.
3882 \begin_layout Subsubsection
3883 Method: add: Add to address
3886 \begin_layout Itemize
3887 Syntax: ADDRESS addr:add(offset)
3890 \begin_layout Itemize
3891 Syntax: ADDRESS addr:add(number, stride)
3894 \begin_layout Itemize
3895 Syntax: ADDRESS addr:add(number, stride, offset)
3898 \begin_layout Standard
3902 \begin_layout Itemize
3903 addr: ADRESS: The original address.
3906 \begin_layout Itemize
3907 offset: number: Offset to add.
3910 \begin_layout Itemize
3911 number: number: Number of table strides to add.
3914 \begin_layout Itemize
3915 stride: number: The table stride.
3918 \begin_layout Standard
3922 \begin_layout Itemize
3923 The modified address
3926 \begin_layout Standard
3927 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
3931 \begin_layout Subsection
3932 ADDRESS:<op>: Read/Write memory
3935 \begin_layout Itemize
3936 Syntax: none addr:<op>(value)
3939 \begin_layout Itemize
3940 Syntax: number addr:<op>()
3943 \begin_layout Standard
3947 \begin_layout Itemize
3948 addr: ADDRESS: The address to read/write.
3951 \begin_layout Itemize
3952 value: number: The number to write.
3955 \begin_layout Standard
3959 \begin_layout Itemize
3963 \begin_layout Standard
3964 Read/Write value from/to given address <addr>.
3965 The value written is <value>.
3966 <Op> is of form: [i][s]<type>, where:
3969 \begin_layout Itemize
3970 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
3973 \begin_layout Itemize
3974 'i' signifies that the value is treated as opposite-to-normal endianess,
3977 \begin_layout Itemize
3978 's' signifies that value is treated as signed (not available for floating-point).
3981 \begin_layout Standard
3982 \begin_inset Newpage pagebreak
3988 \begin_layout Section
3992 \begin_layout Subsection
3993 print: Print values to console
3996 \begin_layout Itemize
3997 Syntax: none print(value...
4001 \begin_layout Standard
4002 Prints specified values to console.
4003 Can print any Lua type at least enough to identify the type and instance.
4006 \begin_layout Subsection
4007 tostringx: Format a value to string
4010 \begin_layout Itemize
4011 Syntax: string tostringx(value val)
4014 \begin_layout Standard
4015 Formats value <val> like print would, and returns the result as a string.
4018 \begin_layout Subsection
4019 exec: Execute lsnes commands
4022 \begin_layout Itemize
4023 Syntax: none exec(string cmd)
4026 \begin_layout Standard
4027 Execute lsnes command <cmd>.
4030 \begin_layout Subsection
4031 utime: Get current time
4034 \begin_layout Itemize
4035 Syntax: (number,number) utime()
4038 \begin_layout Standard
4039 Returns two numbers.
4040 First is time since some epoch in seconds, the second is microseconds mod
4041 10^6 since that epoch.
4044 \begin_layout Subsection
4045 set_idle_timeout: Run function after timeout when emulator is idle
4048 \begin_layout Itemize
4049 Syntax: none set_idle_timeout(number timeout)
4052 \begin_layout Standard
4053 Set number of microseconds to block idle for.
4054 After this timeout has expired, on_idle() will be called once.
4057 \begin_layout Subsection
4058 set_timer_timeout: Run function after timeout.
4061 \begin_layout Itemize
4062 Syntax: none set_timer_timeout(number timeout)
4065 \begin_layout Standard
4066 Set number of microseconds to block timer for.
4067 After this timeout has expired, on_timer() will be called once.
4070 \begin_layout Subsection
4071 bus_address: Look up address in system bus.
4074 \begin_layout Itemize
4075 Syntax: none bus_address(number bus_addr)
4078 \begin_layout Standard
4079 Returns virtual address corresponding to specified address on system bus.
4082 \begin_layout Subsection
4083 loopwrapper: Convert loop into callable function
4086 \begin_layout Itemize
4087 Syntax: function loopwrapper(function fun, ...)
4090 \begin_layout Standard
4091 Calls function <fun> with function and specified arguments.
4092 The function passed suspends execution until the function returned is called.
4093 Handy for linear flow control among multiple invocations of a hook.
4097 \begin_layout LyX-Code
4098 on_paint = loopwrapper(function(wait)
4102 \begin_layout LyX-Code
4107 \begin_layout LyX-Code
4109 \begin_inset Quotes eld
4113 \begin_inset Quotes erd
4119 \begin_layout LyX-Code
4124 \begin_layout LyX-Code
4129 \begin_layout LyX-Code
4133 \begin_layout Subsection
4134 list_bindings: List keybindings
4137 \begin_layout Itemize
4138 Syntax: table list_bindings([string cmd])
4141 \begin_layout Standard
4142 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4143 If <cmd> is specified, the table is limited to that command.
4144 Also searches for controller keys.
4147 \begin_layout Subsection
4148 get_alias: Get expansion of alias
4151 \begin_layout Itemize
4152 Syntax: string get_alias(string aname)
4155 \begin_layout Standard
4156 Get expansion of given alias <aname>.
4159 \begin_layout Subsection
4160 set_alias: Set expansion of alias
4163 \begin_layout Itemize
4164 Syntax: none set_alias(string aname, string value)
4167 \begin_layout Standard
4168 Set expansion of given alias.
4171 \begin_layout Subsection
4172 create_ibind: Create invese binding
4175 \begin_layout Itemize
4176 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4179 \begin_layout Standard
4180 Return object representing inverse binding with specified name <name> and
4181 specified command <cmd>.
4184 \begin_layout Itemize
4185 Note: To create press/release commands, use aliases +foo and -foo .
4188 \begin_layout Itemize
4189 Note: Keep the returned object around.
4192 \begin_layout Subsection
4193 create_command: Create a command
4196 \begin_layout Itemize
4197 Syntax: COMMANDBIND create_command(string name, function a)
4200 \begin_layout Itemize
4201 Syntax: COMMANDBIND create_command(string name, function a, function b)
4204 \begin_layout Standard
4205 Return object representing a command (pair).
4208 \begin_layout Itemize
4209 If only one function is specied, the command is level-sensitive, <a> is
4213 \begin_layout Itemize
4214 If <b> is function, the function is edge-sensitive, <a> is positive edge
4215 callback and <b> is negative edge callback.
4218 \begin_layout Itemize
4219 All callbacks get single argument: The parameters passed.
4222 \begin_layout Itemize
4223 Keep the returned object around.
4226 \begin_layout Subsection
4227 loadfile: Load Lua script
4230 \begin_layout Itemize
4231 Syntax: function loadfile(string filename[, string base])
4234 \begin_layout Standard
4235 Load lua script from <filename>, resolved relative to <base> (if empty,
4239 \begin_layout Subsection
4240 dofile: Execute Lua script
4243 \begin_layout Itemize
4244 Syntax: function dofile(string filename[, string base])
4247 \begin_layout Standard
4248 Execute lua script from <filename>, resolved relative to <base> (if empty,
4249 current directory) and return all return values.
4252 \begin_layout Subsection
4253 resolve_filename: Resolve name of file relative to another
4256 \begin_layout Itemize
4257 Syntax: string resolve_filename(string filename[, string base])
4260 \begin_layout Standard
4261 Resolve name of file <filename> relative to <base> and return the result.
4264 \begin_layout Subsection
4265 render_queue_function: Return paint function for render queue
4268 \begin_layout Itemize
4269 Syntax: function render_queue_function(RENDERQUEUE rq)
4272 \begin_layout Standard
4273 Return function that renders render queue <rq>.
4276 \begin_layout Itemize
4277 Handy for paint callback if one is using render queues updated in other
4282 \begin_layout LyX-Code
4283 handle = callback.paint:register(render_queue_function(my_rq));
4286 \begin_layout Subsection
4287 get_directory_contents: Get files in directory
4290 \begin_layout Itemize
4291 Syntax: table get_directory_contents(string name[, string base[, string
4295 \begin_layout Standard
4296 Return array containg all files in specified directory <name> (relative
4298 If <pattern> is specified, the filenames are matched to specified regex.
4299 The returned filenames inherit path.
4302 \begin_layout Subsection
4303 get_file_type: Get type of file
4306 \begin_layout Itemize
4307 Syntax: string/nil get_file_type(string path)
4310 \begin_layout Standard
4311 Return type of file <path>.
4312 Currently possible return values are:
4315 \begin_layout Itemize
4316 regular: regular file
4319 \begin_layout Itemize
4320 directory: subdirectory
4323 \begin_layout Itemize
4324 unknown: Exists, but type not known (not anything above).
4327 \begin_layout Itemize
4328 <nil>: File does not exist.
4331 \begin_layout Subsection
4332 identify_class: Identify class of object
4335 \begin_layout Itemize
4336 Syntax: string identify_class(userdata object)
4339 \begin_layout Standard
4340 Identifies the class of userdata <object>, if possible.
4341 If no identification is possible, returns
4342 \begin_inset Quotes eld
4346 \begin_inset Quotes erd
4352 \begin_layout Subsection
4353 lookup_class: Lookup class by name
4356 \begin_layout Itemize
4357 Syntax: classobj lookup_class(string name)
4360 \begin_layout Standard
4361 Looks up class corresponding to <name>, if possible.
4362 If not found, returns nil.
4363 The classobj has following fields:
4366 \begin_layout Itemize
4367 _static_methods: Return static method names
4370 \begin_layout Itemize
4371 _class_methods: Return class method names
4374 \begin_layout Itemize
4375 <static-function-name>: The specified static function.
4378 \begin_layout Subsection
4379 all_classes: Get list of all classes
4382 \begin_layout Itemize
4387 \begin_layout Standard
4388 Get names of all classes available.
4391 \begin_layout Subsection
4392 lsnes_features: Read feature flags
4395 \begin_layout Itemize
4396 Syntax: boolean lsnes_features(string feature)
4399 \begin_layout Standard
4400 Checks if feature <feature> is available, if it is, returns true, otherwise
4402 The following features are known:
4405 \begin_layout Itemize
4406 text-halos: gui.text supports halos (takes halo color argument).
4409 \begin_layout Subsection
4413 \begin_layout Standard
4417 \begin_layout Subsection
4418 filereader: Class FILEREADER
4421 \begin_layout Standard
4422 See class FILEREADER.
4425 \begin_layout Standard
4426 \begin_inset Newpage pagebreak
4432 \begin_layout Section
4436 \begin_layout Standard
4437 Bitwise logical functions and related.
4440 \begin_layout Subsection
4441 bit.none/bit.bnot: Bitwise none or NOT function
4444 \begin_layout Itemize
4445 Syntax: number bit.none(number...)
4448 \begin_layout Itemize
4449 Syntax: number bit.bnot(number...)
4452 \begin_layout Standard
4453 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4457 \begin_layout Subsection
4458 bit.any/bit.bor: Bitwise any or OR function
4461 \begin_layout Itemize
4462 Syntax: number bit.any(number...)
4465 \begin_layout Itemize
4466 Syntax: number bit.bor(number...)
4469 \begin_layout Standard
4470 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4473 \begin_layout Subsection
4474 bit.all/bit.band: Bitwise all or AND function
4477 \begin_layout Itemize
4478 Syntax: number bit.all(number...)
4481 \begin_layout Itemize
4482 Syntax: number bit.band(number...)
4485 \begin_layout Standard
4486 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4490 \begin_layout Subsection
4491 bit.parity/bit.bxor: Bitwise parity or XOR function
4494 \begin_layout Itemize
4495 Syntax: number bit.parity(number...)
4498 \begin_layout Itemize
4499 Syntax: number bit.bxor(number...)
4502 \begin_layout Standard
4503 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4507 \begin_layout Subsection
4508 bit.lrotate: Rotate a number left
4511 \begin_layout Itemize
4512 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4515 \begin_layout Standard
4516 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4520 \begin_layout Subsection
4521 bit.rrotate: Rotate a number right
4524 \begin_layout Itemize
4525 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4528 \begin_layout Standard
4529 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4533 \begin_layout Subsection
4534 bit.lshift: Shift a number left
4537 \begin_layout Itemize
4538 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4541 \begin_layout Standard
4542 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4544 The new bits are filled with zeroes.
4547 \begin_layout Subsection
4548 bit.lrshift: Shift a number right (logical)
4551 \begin_layout Itemize
4552 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4555 \begin_layout Standard
4556 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4558 The new bits are filled with zeroes.
4561 \begin_layout Subsection
4562 bit.arshift: Shift a number right (arithmetic)
4565 \begin_layout Itemize
4566 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4569 \begin_layout Standard
4570 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4572 The new bits are shifted in with copy of the high bit.
4575 \begin_layout Subsection
4576 bit.extract: Extract/shuffle bits from number
4579 \begin_layout Itemize
4580 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4583 \begin_layout Standard
4584 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4587 \begin_layout Itemize
4588 Note: Bit numbers up to 51 should work reliably (then things start falling
4589 apart due to double precision issues).
4592 \begin_layout Itemize
4593 Note: There are two special bit positions, true and false, standing for
4594 always set bit and always clear bit.
4597 \begin_layout Subsection
4598 bit.value: Construct number with specified bits set
4601 \begin_layout Itemize
4602 Syntax: number bit.value([number bit1[, number bit2,...]])
4605 \begin_layout Standard
4606 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4607 <bit2> places and so on.
4608 As special value, nil argument is no-op.
4611 \begin_layout Subsection
4612 bit.test: Test if bit is set
4615 \begin_layout Itemize
4616 Syntax: boolean bit.test(number a, number bit)
4619 \begin_layout Standard
4620 Tests if bit <bit> is set in <a>.
4621 If it is set, returns true, otherwise false.
4624 \begin_layout Subsection
4625 bit.testn: Test if bit is clear
4628 \begin_layout Itemize
4629 Syntax: boolean bit.testn(number a, number bit)
4632 \begin_layout Standard
4633 Tests if bit <bit> is set in <a>.
4634 If it is clear, returns true, otherwise false.
4637 \begin_layout Subsection
4638 bit.test_any: Test if any bit is set
4641 \begin_layout Itemize
4642 Syntax: boolean bit.test_any(number a, number b)
4645 \begin_layout Standard
4646 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4649 \begin_layout Subsection
4650 bit.test_all: Test if all bits are set
4653 \begin_layout Itemize
4654 Syntax: boolean bit.test_all(number a, number b)
4657 \begin_layout Standard
4658 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4661 \begin_layout Subsection
4662 bit.popcount: Population count
4665 \begin_layout Itemize
4666 Syntax: number bit.popcount(number a)
4669 \begin_layout Standard
4670 Returns number of set bits in <a>.
4673 \begin_layout Subsection
4674 bit.clshift: Chained left shift
4677 \begin_layout Itemize
4678 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4682 \begin_layout Standard
4683 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4684 numbers to be of specified number of bits <bits> (default 48).
4687 \begin_layout Subsection
4688 bit.crshift: Chained right shift
4691 \begin_layout Itemize
4692 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4696 \begin_layout Standard
4697 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4698 assuming numbers to be of specified number of bits <bits> (default 48).
4701 \begin_layout Subsection
4702 bit.flagdecode: Decode bitfield into flags
4705 \begin_layout Itemize
4706 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4710 \begin_layout Standard
4711 Return string of length bits where ith character is ith character of on
4712 if bit i is on, otherwise ith character of off.
4713 Out of range reads give last character.
4716 \begin_layout Itemize
4717 Note: <on> defaults to '*' if empty.
4720 \begin_layout Itemize
4721 Note: <off> defaults to '-' if empty.
4724 \begin_layout Subsection
4725 bit.rflagdecode: Decode bitfield into flags
4728 \begin_layout Itemize
4729 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4733 \begin_layout Standard
4734 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4738 \begin_layout Subsection
4739 bit.swap{,s}{,h,d,q}word: Swap word endian
4742 \begin_layout Itemize
4743 Syntax: number bit.swapword(number n)
4746 \begin_layout Itemize
4747 Syntax: number bit.swaphword(number n)
4750 \begin_layout Itemize
4751 Syntax: number bit.swapdword(number n)
4754 \begin_layout Itemize
4755 Syntax: number bit.swapqword(number n)
4758 \begin_layout Itemize
4759 Syntax: number bit.swapsword(number n)
4762 \begin_layout Itemize
4763 Syntax: number bit.swapshword(number n)
4766 \begin_layout Itemize
4767 Syntax: number bit.swapsdword(number n)
4770 \begin_layout Itemize
4771 Syntax: number bit.swapsqword(number n)
4774 \begin_layout Standard
4775 Swap endianess of (un)signed integer <n>.
4778 \begin_layout Subsection
4779 bit.compose: Compose multi-byte number
4782 \begin_layout Itemize
4783 Syntax: number bit.compose(number n...)
4786 \begin_layout Standard
4788 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4794 \begin_layout Subsection
4795 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4798 \begin_layout Itemize
4799 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4802 \begin_layout Itemize
4803 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4806 \begin_layout Standard
4807 Load little (*le) or big (*be) endian binary number from position <pos>
4809 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4813 \begin_layout Subsection
4814 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4817 \begin_layout Itemize
4818 Syntax: string bit.binary_st_<type>le(number x);
4821 \begin_layout Itemize
4822 Syntax: string bit.binary_st_<type>be(number x);
4825 \begin_layout Standard
4826 Store specified number <x> as binary in string and return the result.
4827 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4831 \begin_layout Subsection
4832 bit.quotent: Integer quotent
4835 \begin_layout Itemize
4836 Syntax: number bit.quotent(number a, number b)
4839 \begin_layout Standard
4840 Calculate quotent a/b.
4843 \begin_layout Subsection
4844 bit.multidiv: Divide and split among multiple divisiors
4847 \begin_layout Itemize
4849 bit.multidiv(number v, number q...)
4852 \begin_layout Standard
4853 Does the following steps:
4856 \begin_layout Enumerate
4860 \begin_layout Enumerate
4865 \begin_layout Enumerate
4866 Calculate quotent(v'/q) and add that to numbers returned.
4869 \begin_layout Enumerate
4870 v' <- remainder(v'/q)
4874 \begin_layout Enumerate
4875 Add v' to numbers returned.
4878 \begin_layout Standard
4879 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
4881 <v> may be floating point, <q>s are integers.
4884 \begin_layout Itemize
4886 bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
4889 \begin_layout Itemize
4891 bit.multidiv(a, b) calculates quotent and remainder of a/b.
4894 \begin_layout Subsection
4895 bit.mul32: 32-bit multiply
4898 \begin_layout Itemize
4899 Syntax: number, number bit.mul32(number a, number b)
4902 \begin_layout Standard
4903 Multiply 32-bit numbers <a> and <b>.
4904 The first return value is low 32 bits of result, the second is high 32
4908 \begin_layout Standard
4909 \begin_inset Newpage pagebreak
4915 \begin_layout Section
4919 \begin_layout Subsection
4920 classes.<foo>: The classobj for class <foo>
4923 \begin_layout Itemize
4924 Syntax: classes.<foo>
4927 \begin_layout Standard
4928 The classobj for class <foo>.
4931 \begin_layout Subsection
4932 classes.<foo>._static_methods: Enumerate static methods
4935 \begin_layout Itemize
4937 classes.<foo>._static_methods()
4940 \begin_layout Standard
4941 Returns all static methods of <foo> as strings.
4944 \begin_layout Subsection
4945 classes.<foo>._class_methods: Enumerate static methods
4948 \begin_layout Itemize
4950 classes.<foo>._class_methods()
4953 \begin_layout Standard
4954 Returns all class methods of <foo> as strings.
4957 \begin_layout Subsection
4958 classes.<foo>.<bar>: Static method
4961 \begin_layout Itemize
4962 Syntax: variable classes.<foo>.<bar>(variable...)
4965 \begin_layout Standard
4966 Invokes static method <bar> of class <foo>.
4969 \begin_layout Section
4973 \begin_layout Subsection
4974 gui.resolution: Get current resolution
4977 \begin_layout Itemize
4978 Syntax: (number, number) gui.resolution()
4981 \begin_layout Standard
4982 Returns 2-tuple (hresolution, vresolution).
4985 \begin_layout Subsection
4986 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
4989 \begin_layout Itemize
4990 Syntax: number gui.left_gap(number gap)
4993 \begin_layout Itemize
4994 Syntax: number gui.right_gap(number gap)
4997 \begin_layout Itemize
4998 Syntax: number gui.top_gap(number gap)
5001 \begin_layout Itemize
5002 Syntax: number gui.bottom_gap(number gap)
5005 \begin_layout Standard
5006 Set the specified edge gap to specified value <gap> (max gap is 8191).
5007 If successful, old gap is returned.
5010 \begin_layout Subsection
5011 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
5015 \begin_layout Itemize
5016 Syntax: number gui.delta_left_gap(number dgap)
5019 \begin_layout Itemize
5020 Syntax: number gui.delta_right_gap(number dgap)
5023 \begin_layout Itemize
5024 Syntax: number gui.delta_top_gap(number dgap)
5027 \begin_layout Itemize
5028 Syntax: number gui.delta_bottom_gap(number dgap)
5031 \begin_layout Standard
5032 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
5033 and return the old gap (returns nothing on error).
5036 \begin_layout Subsection
5037 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
5040 \begin_layout Itemize
5041 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
5042 bgc[, number hlc]]])
5045 \begin_layout Itemize
5046 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
5047 bgc[, number hlc]]])
5050 \begin_layout Itemize
5051 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
5052 bgc[, number hlc]]])
5055 \begin_layout Itemize
5056 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
5057 bgc[, number hlc]]])
5060 \begin_layout Standard
5061 Draw specified text on the GUI (each character cell is 8 or 16 wide and
5066 \begin_layout Itemize
5067 x: X-coordinate to start the drawing from (and x-coordinate at begining
5071 \begin_layout Itemize
5072 y: Y-coordinate to start the drawing from.
5075 \begin_layout Itemize
5076 text: The text to draw.
5079 \begin_layout Itemize
5080 fgc: Text color (default is 0xFFFFFF (white))
5083 \begin_layout Itemize
5084 bgc: Background color (default is -1 (transparent))
5087 \begin_layout Itemize
5088 hlc: Halo color (default is -1 (transparent))
5091 \begin_layout Standard
5092 Note: The H variants draw at double width and V variants draw at double
5094 Halo thickness is always 1 and is not doubled.
5097 \begin_layout Subsection
5098 gui.rectangle: Draw a rectangle
5101 \begin_layout Itemize
5102 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5103 number thickness[, number outline[, number fill]]])
5106 \begin_layout Standard
5107 Draw rectangle on the GUI.
5111 \begin_layout Itemize
5112 x: X-coordinate of left edge.
5115 \begin_layout Itemize
5116 y: Y-coordinate of upper edge.
5119 \begin_layout Itemize
5120 width: Width of rectangle.
5123 \begin_layout Itemize
5124 height: Height of rectangle.
5127 \begin_layout Itemize
5128 thickness: Thickness of outline (default is 1).
5131 \begin_layout Itemize
5132 outline: Color of outline (default is 0xFFFFFF (white))
5135 \begin_layout Itemize
5136 fill: Color of fill (default is -1 (transparent))
5139 \begin_layout Subsection
5140 gui.solidrectangle: Draw a solid rectangle
5143 \begin_layout Itemize
5144 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5148 \begin_layout Standard
5149 Draw solid rectangle on the GUI.
5153 \begin_layout Itemize
5154 x: X-coordinate of left edge.
5157 \begin_layout Itemize
5158 y: Y-coordinate of upper edge.
5161 \begin_layout Itemize
5162 width: Width of rectangle.
5165 \begin_layout Itemize
5166 height: Height of rectangle.
5169 \begin_layout Itemize
5170 color: Color of rectangle (default is 0xFFFFFF (white))
5173 \begin_layout Subsection
5174 gui.box: Draw a 3D-effect box
5177 \begin_layout Itemize
5178 Syntax: none gui.box(number x, number y, number width, number height[, number
5179 thickness[, number outline1[,number outline2[, number fill]]]])
5182 \begin_layout Standard
5183 Draw rectangle with 3D effect on the GUI.
5187 \begin_layout Itemize
5188 x: X-coordinate of left edge.
5191 \begin_layout Itemize
5192 y: Y-coordinate of upper edge.
5195 \begin_layout Itemize
5196 width: Width of rectangle.
5199 \begin_layout Itemize
5200 height: Height of rectangle.
5203 \begin_layout Itemize
5204 thickness: Thickness of outline (default is 1).
5207 \begin_layout Itemize
5208 outline1: First color of outline (default is 0xFFFFFF (white))
5211 \begin_layout Itemize
5212 outline2: First color of outline (default is 0x808080 (dark gray))
5215 \begin_layout Itemize
5216 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5219 \begin_layout Subsection
5220 gui.pixel: Draw a single pixel
5223 \begin_layout Itemize
5224 Syntax: none gui.pixel(number x, number y[, number color])
5227 \begin_layout Standard
5228 Draw one pixel on the GUI.
5232 \begin_layout Itemize
5233 x: X-coordinate of the pixel
5236 \begin_layout Itemize
5237 y: Y-coordinate of the pixel
5240 \begin_layout Itemize
5241 color: Color of the pixel (default is 0xFFFFFF (white))
5244 \begin_layout Subsection
5245 gui.crosshair: Draw a crosshair
5248 \begin_layout Itemize
5249 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5252 \begin_layout Standard
5257 \begin_layout Itemize
5258 x: X-coordinate of the crosshair
5261 \begin_layout Itemize
5262 y: Y-coordinate of the crosshair
5265 \begin_layout Itemize
5266 length: Length of the crosshair lines (default 10).
5269 \begin_layout Itemize
5270 color: Color of the crosshair (default is 0xFFFFFF (white))
5273 \begin_layout Subsection
5274 gui.line: Draw a line
5277 \begin_layout Itemize
5278 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5282 \begin_layout Standard
5287 \begin_layout Itemize
5288 x1: X-coordinate of one end.
5291 \begin_layout Itemize
5292 y1: Y-coordinate of one end.
5295 \begin_layout Itemize
5296 x2: X-coordinate of the other end.
5299 \begin_layout Itemize
5300 y2: Y-coordinate of the other end.
5303 \begin_layout Itemize
5304 color: Color of the line (default is 0xFFFFFF (white)).
5307 \begin_layout Subsection
5308 gui.circle: Draw a (filled) circle
5311 \begin_layout Itemize
5312 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5313 border[, number fil]]])
5316 \begin_layout Standard
5321 \begin_layout Itemize
5322 x: X-coordinate of the center
5325 \begin_layout Itemize
5326 y: Y-coordinate of the center
5329 \begin_layout Itemize
5330 r: The radius of the circle
5333 \begin_layout Itemize
5334 thick: Border thickness
5337 \begin_layout Itemize
5338 border: Border color (default is 0xFFFFFF (white))
5341 \begin_layout Itemize
5342 fill: Fill color (default is -1 (transparent)).
5345 \begin_layout Subsection
5346 gui.repaint: Arrange a repaint
5349 \begin_layout Itemize
5350 Syntax: none gui.repaint()
5353 \begin_layout Standard
5354 Request on_repaint() to happen as soon as possible.
5357 \begin_layout Subsection
5358 gui.subframe_update: Enable/Disable subframe updates
5361 \begin_layout Itemize
5362 Syntax: none gui.subframe_update(boolean on)
5365 \begin_layout Standard
5366 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5367 or not happen (<on>=false).
5370 \begin_layout Subsection
5371 gui.screenshot: Write a screenshot
5374 \begin_layout Itemize
5375 Syntax: none gui.screenshot(string filename)
5378 \begin_layout Standard
5379 Write PNG screenshot of the current frame (no drawings) to specified file
5383 \begin_layout Subsection
5384 gui.screenshot_bitmap: Write a screenshot to bitmap
5387 \begin_layout Itemize
5388 Syntax: DBITMAP gui.screenshot_bitmap()
5391 \begin_layout Standard
5392 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5396 \begin_layout Subsection
5397 gui.color: Compose a color.
5400 \begin_layout Itemize
5401 Syntax: number gui.color(number r, number g, number b[, number a])
5404 \begin_layout Itemize
5405 Syntax: number gui.color(string c)
5408 \begin_layout Standard
5409 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5410 , each component in scale 0-255.
5411 If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5413 The default alpha is 256.
5416 \begin_layout Standard
5417 The form taking a string returns color corresponding color name.
5420 \begin_layout Subsection
5421 gui.status: Set status variable
5424 \begin_layout Itemize
5425 Syntax: none gui.status(string name, string value)
5428 \begin_layout Standard
5430 \begin_inset Quotes eld
5434 \begin_inset Quotes erd
5437 to <value> in status area.
5440 \begin_layout Subsection
5441 gui.rainbow: Rainbow color calculation
5444 \begin_layout Itemize
5445 Syntax: number gui.rainbow(number step, number steps[, number color])
5448 \begin_layout Standard
5449 Perform hue rotation of color <color> (default bright red), by <step> steps.
5450 The number of steps per full rotation is given by absolute value of <steps>.
5453 \begin_layout Standard
5454 If <step> is negative, the rotation will be counterclockwise.
5457 \begin_layout Subsection
5458 gui.kill_frame: Kill video frame and associated sound
5461 \begin_layout Itemize
5462 Syntax: none gui.kill_frame()
5465 \begin_layout Standard
5466 Kills the currently dumped video frame + the associated sound.
5467 Only valid in on_video callback.
5470 \begin_layout Subsection
5471 gui.set_video_scale: Set video frame scale
5474 \begin_layout Itemize
5475 Syntax: none gui.set_video_scale(number h, number v)
5478 \begin_layout Standard
5479 Sets the scale factors of current frame to <h>x<v>.
5480 Only valid in on_video callback.
5483 \begin_layout Subsection
5484 gui.arrow: Draw an arrow
5487 \begin_layout Itemize
5488 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5489 number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5493 \begin_layout Standard
5494 Draws an arrow using color <color>.
5495 The tip of arrow is at (<x>, <y>).
5499 \begin_layout Enumerate
5500 <length>: The length of arrow tail.
5503 \begin_layout Enumerate
5504 <hwidth>: The width of arrow head.
5508 \begin_layout Enumerate
5509 <direction>: Direction of arrow.
5510 0 is to right, +1 rotates 45 degrees counterclockwise.
5513 \begin_layout Enumerate
5514 <fill>: If true, fill the arrow head.
5518 \begin_layout Enumerate
5519 <twidth>: Tail width.
5524 \begin_layout Enumerate
5525 <hthick>: Head thickness (only used if <fill> is false).
5526 Default is <twidth>.
5529 \begin_layout Subsection
5530 gui.tiled_bitmap: Class TILEMAP
5533 \begin_layout Standard
5537 \begin_layout Subsection
5538 gui.palette: Class PALETTE
5541 \begin_layout Standard
5545 \begin_layout Subsection
5546 gui.bitmap: Class BITMAP
5549 \begin_layout Standard
5553 \begin_layout Subsection
5554 gui.dbitmap: Class DBITMAP
5557 \begin_layout Standard
5561 \begin_layout Subsection
5562 gui.font: Class CUSTOMFONT
5565 \begin_layout Standard
5566 See class CUSTOMFONT.
5569 \begin_layout Subsection
5570 gui.renderctx: Class RENDERCTX
5573 \begin_layout Standard
5574 See class RENDERCTX.
5577 \begin_layout Subsection
5578 gui.image: Class IMAGELOADER
5581 \begin_layout Standard
5582 See class IMAGELOADER.
5585 \begin_layout Subsection
5586 gui.get_runmode: Get current emulator mode
5589 \begin_layout Itemize
5590 Syntax: string gui.get_runmode()
5593 \begin_layout Standard
5594 Gets the current emulator runmode.
5595 The possible ones are:
5598 \begin_layout Itemize
5599 quit: Emulator is quitting.
5602 \begin_layout Itemize
5603 normal: Emulator is running emulation
5606 \begin_layout Itemize
5607 load: Emulator is loading a movie/savestate
5610 \begin_layout Itemize
5611 advance_frame: Emulator is doing frame advance
5614 \begin_layout Itemize
5615 advance_subframe: Emulator is doing subframe advance
5618 \begin_layout Itemize
5619 skiplag: Emulator is skipping lag frames
5622 \begin_layout Itemize
5623 skiplag_pending: Emulator will start skipping lag frames next frame
5626 \begin_layout Itemize
5627 pause: Emulator is paused
5630 \begin_layout Itemize
5631 pause_break: Emulator is paused at breakpoint
5634 \begin_layout Itemize
5635 corrupt: Emulator can't run because corrupt emulation state
5638 \begin_layout Itemize
5639 unknown: Unknown state (should not happen).
5642 \begin_layout Standard
5643 \begin_inset Newpage pagebreak
5649 \begin_layout Section
5653 \begin_layout Standard
5655 Functions manipulating input are only available in on_input callback.
5658 \begin_layout Subsection
5659 input.get: Read controller button/axis (deprecated)
5662 \begin_layout Itemize
5663 Syntax: number input.get(number controller, number index)
5666 \begin_layout Standard
5667 Read the specified index <index> (zero-based) from specified controller
5668 <controller> (zero-based).
5672 \begin_layout Subsection
5673 input.set: Write controller button/axis (deprecated)
5676 \begin_layout Itemize
5677 Syntax: none input.set(number controller, number index, number value)
5680 \begin_layout Standard
5681 Write the specified index <index> (zero-based) from specified controller
5682 <controller> (zero-based), storing value <value>.
5685 \begin_layout Subsection
5686 input.get2: Read controller button/axis
5689 \begin_layout Itemize
5690 Syntax: number input.get2(number port, number controller, number index)
5693 \begin_layout Standard
5694 Read the specified input tuple.
5695 Port 0 is system port.
5698 \begin_layout Subsection
5699 input.set2: Write controller button/axis
5702 \begin_layout Itemize
5703 Syntax: input.set2(number port, number controller, number index, number value)
5706 \begin_layout Standard
5707 Write the specified input tuple.
5708 Port 0 is system port.
5711 \begin_layout Subsection
5712 input.lcid_to_pcid2: Look up logical controller
5715 \begin_layout Itemize
5716 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5719 \begin_layout Standard
5720 Look up physical pcid pair (port, controller) corresponding to specified
5721 logical controller (1-based).
5722 Returns nothing if controller does not exist.
5725 \begin_layout Subsection
5726 input.port_type: Look up port type
5729 \begin_layout Itemize
5730 Syntax: string input.port_type(number port)
5733 \begin_layout Standard
5734 Return type of specified port.
5737 \begin_layout Subsection
5738 input.controller_info: Get information about controller
5741 \begin_layout Itemize
5742 Syntax: table input.controller_info(number port, number controller)
5745 \begin_layout Standard
5746 Get controller info for specified controller.
5747 If controller does not exist, returns nil.
5748 Otherwise returns a table with following fields:
5751 \begin_layout Itemize
5752 type (string): Type of the controller.
5755 \begin_layout Itemize
5756 class (string): Class of the controller.
5759 \begin_layout Itemize
5760 classnum (number): Number of the controller within its class (1-based)
5763 \begin_layout Itemize
5764 lcid (number): Logical controller number of the controller.
5767 \begin_layout Itemize
5768 button_count (number): Number of buttons on controller
5771 \begin_layout Itemize
5772 buttons (array): Array of following info about each button:
5776 \begin_layout Itemize
5777 type (string): Type of button.
5779 \begin_inset Quotes eld
5783 \begin_inset Quotes erd
5787 \begin_inset Quotes eld
5791 \begin_inset Quotes erd
5795 \begin_inset Quotes eld
5799 \begin_inset Quotes erd
5803 \begin_inset Quotes eld
5807 \begin_inset Quotes erd
5813 \begin_layout Itemize
5814 name (string): Name of button.
5817 \begin_layout Itemize
5818 symbol (string): Symbol of button.
5819 Only present for type
5820 \begin_inset Quotes eld
5824 \begin_inset Quotes erd
5830 \begin_layout Itemize
5831 hidden (boolean): True if hidden button.
5836 \begin_layout Subsection
5837 input.veto_button: Veto a button press
5840 \begin_layout Itemize
5841 Syntax: none input.veto_button()
5844 \begin_layout Standard
5845 Signals that the button event should be vetoed.
5846 Only valid in on_button callback.
5849 \begin_layout Subsection
5850 input.geta: Get all buttons for controller (deprecated)
5853 \begin_layout Itemize
5854 Syntax: (number, number...) input.geta(number controller)
5857 \begin_layout Standard
5858 Get input state for entiere controller.
5859 Returns n return values.
5862 \begin_layout Itemize
5863 1st return value: Bitmask: bit i is set if i:th index is nonzero
5866 \begin_layout Itemize
5867 2nd- return value: value of i:th index.
5870 \begin_layout Subsection
5871 input.seta: Set all buttons for controller (deprecated)
5874 \begin_layout Itemize
5875 Syntax: none input.seta(number controller, number bitmask, number args...)
5878 \begin_layout Standard
5879 Set state for entiere controller.
5880 args is up to N values for indices (overriding values in bitmask if specified).
5883 \begin_layout Subsection
5884 input.controllertype: Get controller type (deprecated)
5887 \begin_layout Itemize
5888 syntax: string input.controllertype(number controller)
5891 \begin_layout Standard
5892 Get the type of controller as string.
5895 \begin_layout Subsection
5896 input.reset: Execute (delayed) reset
5899 \begin_layout Itemize
5900 Syntax: none input.reset([number cycles])
5903 \begin_layout Standard
5905 If <cycles> is greater than zero, do delayed reset.
5906 0 (or no value) causes immediate reset.
5909 \begin_layout Itemize
5910 Note: Only available with subframe flag false.
5913 \begin_layout Subsection
5914 input.raw: Return raw input data
5917 \begin_layout Itemize
5918 Syntax: table input.raw()
5921 \begin_layout Standard
5922 Returns table of tables of all available keys and axes.
5923 The first table is indexed by key name (platform-dependent!), and the inner
5924 table has the following fields:
5927 \begin_layout Itemize
5928 value: Last reported value for control
5932 \begin_layout Itemize
5933 For keys: 1 for pressed, 0 for released.
5936 \begin_layout Itemize
5937 For axes: -32767...32767.
5940 \begin_layout Itemize
5941 For presure-sensitive buttons: 0...32767.
5944 \begin_layout Itemize
5945 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
5948 \begin_layout Itemize
5949 For mouse: Coordinates relative to game area.
5953 \begin_layout Itemize
5954 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
5957 \begin_layout Subsection
5958 input.keyhook: Hook a key
5961 \begin_layout Itemize
5962 Syntax: none input.keyhook(string key, boolean state)
5965 \begin_layout Standard
5966 Requests that keyhook events to be sent for key <key> (<state>=true) or
5967 not sent (<state>=false).
5970 \begin_layout Subsection
5971 input.joyget: Get controls for controller
5974 \begin_layout Itemize
5975 Syntax: table input.joyget(number logical)
5978 \begin_layout Standard
5979 Returns table for current controls for specified logical controller <logical>.
5980 The names of fields vary by controller type.
5983 \begin_layout Itemize
5984 The buttons have the same name as those are referred to in other contexts
5988 \begin_layout Itemize
5989 The analog axes are usually
5990 \begin_inset Quotes eld
5994 \begin_inset Quotes erd
5998 \begin_inset Quotes eld
6002 \begin_inset Quotes erd
6008 \begin_layout Itemize
6009 Each field is numeric or boolean depending on axis/button.
6012 \begin_layout Subsection
6013 input.joyset: Set controls for controller
6016 \begin_layout Itemize
6017 Syntax: none input.joyset(number controller, table controls)
6020 \begin_layout Standard
6021 Set the the state of specified controller to values specified in specified
6025 \begin_layout Itemize
6026 Each field can be boolean or number.
6029 \begin_layout Itemize
6030 Also, buttons allow strings, which cause value to be inverted.
6033 \begin_layout Subsection
6034 input.lcid_to_pcid: Look up logical controller (deprecated)
6037 \begin_layout Itemize
6038 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
6041 \begin_layout Standard
6042 Returns the legacy pcid for controller (or false if there isn't one), followed
6044 Returns nothing if controller does not exist.
6047 \begin_layout Standard
6048 \begin_inset Newpage pagebreak
6054 \begin_layout Section
6058 \begin_layout Standard
6059 Various keybinding-related functions
6062 \begin_layout Subsection
6063 keyboard.bind: Bind a key
6066 \begin_layout Itemize
6067 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
6070 \begin_layout Standard
6071 Bind specified key with specified modifers to specified command.
6074 \begin_layout Subsection
6075 keyboard.unbind: Unbind a key
6078 \begin_layout Itemize
6079 Syntax: none keyboard.unbind(string mod, string mask, string key)
6082 \begin_layout Standard
6083 Unbind specified key with specified modifers.
6086 \begin_layout Subsection
6087 keyboard.alias: Set alias expansion
6090 \begin_layout Itemize
6091 Syntax: none keyboard.alias(string alias, string expansion)
6094 \begin_layout Standard
6095 Set expansion of given command.
6098 \begin_layout Standard
6099 \begin_inset Newpage pagebreak
6105 \begin_layout Section
6109 \begin_layout Standard
6113 \begin_layout Subsection
6114 subtitle.byindex: Look up start and length of subtitle by index
6117 \begin_layout Itemize
6118 Syntax: (number, number) subtitle.byindex(number i)
6121 \begin_layout Standard
6122 Read the frame and length of ith subtitle.
6123 Returns nothing if not present.
6126 \begin_layout Subsection
6127 subtitle.set: Write a subtitle
6130 \begin_layout Itemize
6131 Syntax: none subtitle.set(number f, number l, string txt)
6134 \begin_layout Standard
6135 Set the text of subtitle.
6138 \begin_layout Subsection
6139 subtitle.get: Read a subtitle
6142 \begin_layout Itemize
6143 Syntax: string subtitle.get(number f, number l)
6146 \begin_layout Standard
6147 Get the text of subtitle.
6150 \begin_layout Subsection
6151 subtitle.delete: Delete a subtitle
6154 \begin_layout Itemize
6155 Syntax: none subtitle.delete(number f, number l)
6158 \begin_layout Standard
6159 Delete specified subtitle.
6162 \begin_layout Standard
6163 \begin_inset Newpage pagebreak
6169 \begin_layout Section
6173 \begin_layout Standard
6174 Host memory handling (extra memory saved to savestates).
6175 Host memory starts empty.
6178 \begin_layout Itemize
6179 Reads out of range return false.
6182 \begin_layout Itemize
6183 Writes out of range extend the memory.
6186 \begin_layout Subsection
6187 hostmemory.read: Read byte from host memory
6190 \begin_layout Itemize
6191 Syntax: number hostmemory.read(number address)
6194 \begin_layout Standard
6195 Reads byte from hostmemory slot address <address>.
6198 \begin_layout Subsection
6199 hostmemory.write: Write byte to host memory
6202 \begin_layout Itemize
6203 Syntax: none hostmemory.write(number address, number value)
6206 \begin_layout Standard
6207 Writes hostmemory slot with value <value> 0-255.
6210 \begin_layout Subsection
6211 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6214 \begin_layout Itemize
6215 Syntax: number hostmemory.readbyte(number address)
6218 \begin_layout Itemize
6219 Syntax: number hostmemory.readsbyte(number address)
6222 \begin_layout Itemize
6223 Syntax: number hostmemory.readword(number address)
6226 \begin_layout Itemize
6227 Syntax: number hostmemory.readsword(number address)
6230 \begin_layout Itemize
6231 Syntax: number hostmemory.readhword(number address)
6234 \begin_layout Itemize
6235 Syntax: number hostmemory.readshword(number address)
6238 \begin_layout Itemize
6239 Syntax: number hostmemory.readdword(number address)
6242 \begin_layout Itemize
6243 Syntax: number hostmemory.readsdword(number address)
6246 \begin_layout Itemize
6247 Syntax: number hostmemory.readqword(number address)
6250 \begin_layout Itemize
6251 Syntax: number hostmemory.readsqword(number address)
6254 \begin_layout Standard
6255 Read elements (big-endian) from given address <address>.
6258 \begin_layout Itemize
6262 \begin_layout Itemize
6266 \begin_layout Itemize
6270 \begin_layout Itemize
6274 \begin_layout Itemize
6275 qword is 8 elements.
6278 \begin_layout Itemize
6279 The 's' variants do signed read.
6282 \begin_layout Subsection
6283 hostmemory.read{float,double}: Read from host memory
6286 \begin_layout Itemize
6287 syntax: number hostmemory.readfloat(number address)
6290 \begin_layout Itemize
6291 Syntax: number hostmemory.readdouble(number address)
6294 \begin_layout Standard
6295 Read elements (big-endian) floating-pont from given address <address>.
6298 \begin_layout Subsection
6299 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6302 \begin_layout Itemize
6303 Syntax: number hostmemory.writebyte(number address, number value)
6306 \begin_layout Itemize
6307 Syntax: number hostmemory.writesbyte(number address, number value)
6310 \begin_layout Itemize
6311 Syntax: number hostmemory.writeword(number address, number value)
6314 \begin_layout Itemize
6315 Syntax: number hostmemory.writesword(number address, number value)
6318 \begin_layout Itemize
6319 Syntax: number hostmemory.writehword(number address, number value)
6322 \begin_layout Itemize
6323 Syntax: number hostmemory.writeshword(number address, number value)
6326 \begin_layout Itemize
6327 Syntax: number hostmemory.writedword(number address, number value)
6330 \begin_layout Itemize
6331 Syntax: number hostmemory.writesdword(number address, number value)
6334 \begin_layout Itemize
6335 Syntax: number hostmemory.writeqword(number address, number value)
6338 \begin_layout Itemize
6339 Syntax: number hostmemory.writesqword(number address, number value)
6342 \begin_layout Standard
6343 Write value <value> to elements (little-endian) starting from given address
6347 \begin_layout Itemize
6351 \begin_layout Itemize
6355 \begin_layout Itemize
6359 \begin_layout Itemize
6363 \begin_layout Itemize
6364 qword is 8 elements.
6367 \begin_layout Itemize
6368 The 's' variants do signed write.
6371 \begin_layout Subsection
6372 hostmemory.write{float,double}: Write to host memory
6375 \begin_layout Itemize
6376 syntax: none hostmemory.readfloat(number address, number value)
6379 \begin_layout Itemize
6380 Syntax: none hostmemory.readdouble(number address, number value)
6383 \begin_layout Standard
6384 Write elements (big-endian) floating-pont to given address <address>, storing
6388 \begin_layout Standard
6389 \begin_inset Newpage pagebreak
6395 \begin_layout Section
6399 \begin_layout Standard
6403 \begin_layout Subsection
6404 movie.currentframe: Get current frame number
6407 \begin_layout Itemize
6408 Syntax: number movie.currentframe()
6411 \begin_layout Standard
6412 Return number of current frame.
6415 \begin_layout Subsection
6416 movie.framecount: Get move frame count
6419 \begin_layout Itemize
6420 Syntax: number movie.framecount()
6423 \begin_layout Standard
6424 Return number of frames in movie.
6427 \begin_layout Subsection
6428 movie.lagcount: Get current lag count
6431 \begin_layout Itemize
6432 Syntax: number movie.lagcount()
6435 \begin_layout Standard
6436 Return number of lag frames recorded so far.
6439 \begin_layout Subsection
6440 movie.readonly: Is in playback mode?
6443 \begin_layout Itemize
6444 Syntax: boolean movie.readonly()
6447 \begin_layout Standard
6448 Return true if in playback mode, false if in recording.
6451 \begin_layout Subsection
6452 movie.rerecords: Movie rerecord count
6455 \begin_layout Itemize
6456 Syntax: number movie.rerecords()
6459 \begin_layout Standard
6460 Returns the current value of rerecord count.
6463 \begin_layout Subsection
6464 movie.set_readwrite: Set recording mode.
6467 \begin_layout Itemize
6468 Syntax: none movie.set_readwrite()
6471 \begin_layout Standard
6472 Set recording mode (does not cause on_readwrite callback).
6475 \begin_layout Subsection
6476 movie.frame_subframes: Count subframes in frame
6479 \begin_layout Itemize
6480 Syntax: number movie.frame_subframes(number frame)
6483 \begin_layout Standard
6484 Count number of subframes in specified frame <frame> (frame numbers are
6485 1-based) and return that.
6488 \begin_layout Subsection
6489 movie.read_subframes: Read subframe data (deprecated)
6492 \begin_layout Itemize
6493 Syntax: table movie.read_subframes(number frame, number subframe)
6496 \begin_layout Standard
6497 Read specifed subframe in specified frame and return data as array.
6500 \begin_layout Subsection
6501 movie.read_rtc: Read current RTC time
6504 \begin_layout Itemize
6505 Syntax: (number, number) movie.read_rtc()
6508 \begin_layout Standard
6509 Returns the current value of the RTC as a pair (second, subsecond).
6512 \begin_layout Subsection
6513 movie.unsafe_rewind: Fast movie rewind to saved state
6516 \begin_layout Itemize
6517 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6520 \begin_layout Standard
6521 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6524 \begin_layout Itemize
6525 If called without argument, causes emulator to start process of setting
6526 unsafe rewind point.
6527 When this has finished, callback on_set_rewind occurs, passing the rewind
6528 state to lua script.
6531 \begin_layout Itemize
6532 If called with argument, causes emulator rewind to passed rewind point as
6534 recording mode is implicitly activated.
6537 \begin_layout Standard
6538 The following warnings apply to unsafe rewinding:
6541 \begin_layout Itemize
6542 There are no safety checks against misuse (that's what
6543 \begin_inset Quotes eld
6547 \begin_inset Quotes erd
6553 \begin_layout Itemize
6554 Only call rewind from timeline rewind point was set from.
6557 \begin_layout Itemize
6558 Only call rewind from after the rewind point was set.
6561 \begin_layout Subsection
6562 movie.to_rewind: Load savestate as rewind point
6565 \begin_layout Itemize
6566 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6569 \begin_layout Standard
6570 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6571 corresponding to it.
6574 \begin_layout Itemize
6575 Note: This operation does not take emulated time.
6578 \begin_layout Subsection
6579 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6582 \begin_layout Itemize
6583 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6586 \begin_layout Itemize
6587 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6590 \begin_layout Standard
6591 Copies specified movie or branch <movie>/current object (if none or nil,
6592 the active movie) as new movie object.
6595 \begin_layout Subsection
6596 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6599 \begin_layout Itemize
6600 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6603 \begin_layout Itemize
6604 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6607 \begin_layout Standard
6608 Get INPUTFRAME object corresponding to specified frame in specified movie
6612 \begin_layout Subsection
6613 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6616 \begin_layout Itemize
6617 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6621 \begin_layout Itemize
6622 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6625 \begin_layout Standard
6626 Set data in specified frame.
6629 \begin_layout Itemize
6630 Note: Past can't be edited in active movie.
6633 \begin_layout Subsection
6634 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6637 \begin_layout Itemize
6638 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6641 \begin_layout Itemize
6642 Syntax: integer INPUTMOVIE::get_size()
6645 \begin_layout Standard
6646 Return number of subframes in specified movie or branch.
6649 \begin_layout Subsection
6650 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6653 \begin_layout Itemize
6654 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6657 \begin_layout Itemize
6658 Syntax: number INPUTMOVIE::count_frames()
6661 \begin_layout Standard
6662 Return number of frames in movie.
6665 \begin_layout Subsection
6666 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6669 \begin_layout Itemize
6670 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6673 \begin_layout Itemize
6674 Syntax: number INPUTMOVIE::find_frame(number frame)
6677 \begin_layout Standard
6678 Returns starting subframe of given frame (frame numbers are 1-based).
6679 Returns -1 if frame number is bad.
6682 \begin_layout Subsection
6683 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6686 \begin_layout Itemize
6687 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6690 \begin_layout Itemize
6691 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6694 \begin_layout Standard
6695 Return blank INPUTFRAME with frame type from specified movie.
6698 \begin_layout Subsection
6699 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6702 \begin_layout Itemize
6703 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6706 \begin_layout Itemize
6707 Syntax: none INPUTMOVIE::append_frames(number frames)
6710 \begin_layout Standard
6711 Append specified number <frames> of frames.
6714 \begin_layout Subsection
6715 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
6718 \begin_layout Itemize
6719 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
6722 \begin_layout Itemize
6723 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
6726 \begin_layout Standard
6727 Append specified frame <frame>.
6728 Past of current movie can't be edited.
6731 \begin_layout Subsection
6732 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
6735 \begin_layout Itemize
6736 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
6739 \begin_layout Itemize
6740 Syntax: none INPUTMOVIE::truncate(number frames)
6743 \begin_layout Standard
6744 Truncate the specified movie to specified number of frames.
6747 \begin_layout Subsection
6748 movie.edit/INPUTMOVIE::edit: Edit a movie
6751 \begin_layout Itemize
6752 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
6753 controller, number control, number/bool value)
6756 \begin_layout Itemize
6757 Syntax: none movie.edit(string branch, number frame, number port, number
6758 controller, number control, number/bool value)
6761 \begin_layout Itemize
6762 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
6763 number control, number/bool value)
6766 \begin_layout Standard
6767 Change specified control in specified frame in specified movie.
6768 Past can't be edited in active movie.
6771 \begin_layout Subsection
6772 movie.copy_frames2: Copy frames between movies
6775 \begin_layout Itemize
6776 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
6777 IE/string srcmov,] number src, number count)
6780 \begin_layout Standard
6781 Copy specified number of frames between two movies.
6782 The copy proceeeds in forward direction.
6785 \begin_layout Subsection
6786 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
6789 \begin_layout Itemize
6790 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
6791 src, number count, bool backwards)
6794 \begin_layout Itemize
6795 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
6799 \begin_layout Standard
6800 Copy specified number of frames from one point in movie to another.
6801 If backwards is true, the copy will be done backwards.
6804 \begin_layout Subsection
6805 movie.serialize/INPUTMOVIE::serialize: Serialize movie
6808 \begin_layout Itemize
6809 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
6813 \begin_layout Itemize
6814 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
6817 \begin_layout Standard
6818 Serialize given movie into file.
6819 If binary is true, binary format (more compact and much faster) is used.
6822 \begin_layout Subsection
6823 movie.unserialize: Unserialize movie
6826 \begin_layout Itemize
6827 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
6831 \begin_layout Standard
6832 Unserialize movie from file.
6833 The given frame is used as template to decide the frame type.
6834 If binary is true, binary format is decoded (much faster).
6837 \begin_layout Subsection
6838 movie.current_first_subframe: Return first subframe in current frame
6841 \begin_layout Itemize
6842 Syntax: number movie.current_first_subframe()
6845 \begin_layout Standard
6846 Returns first subframe in current frame.
6849 \begin_layout Subsection
6850 movie.pollcounter: Return poll counter for speified control
6853 \begin_layout Itemize
6854 Syntax: number movie.pollcounter(number port, number controller, number control)
6857 \begin_layout Standard
6858 Returns number of times the specified control has been polled this frame.
6861 \begin_layout Subsection
6862 movie.current_branch: Return current branch
6865 \begin_layout Itemize
6866 Syntax: string movie.current_branch()
6869 \begin_layout Standard
6870 Returns the name of the current branch.
6873 \begin_layout Subsection
6874 movie.get_branches: Return names of all branches
6877 \begin_layout Itemize
6879 movie.get_branches()
6882 \begin_layout Standard
6883 Returns the name of all branches.
6886 \begin_layout Subsection
6887 movie.rom_loaded: Is ROM loaded?
6890 \begin_layout Itemize
6891 Syntax: boolean movie.rom_loaded()
6894 \begin_layout Standard
6895 Returns true if ROM is loaded, false otherwise.
6898 \begin_layout Subsection
6899 movie.get_rom_info: Get info about loaded ROM
6902 \begin_layout Itemize
6903 Syntax: Table movie.get_rom_info()
6906 \begin_layout Standard
6907 Returns a table of tables.
6908 The outer table is indexed by ROM slot index.
6909 The inner table has the following fields:
6912 \begin_layout Itemize
6913 filename: The name of file
6916 \begin_layout Itemize
6917 hint: File name hint
6920 \begin_layout Itemize
6921 sha256: SHA-256 hash of ROM.
6924 \begin_layout Itemize
6925 xml_filename: The name of file for markup
6928 \begin_layout Itemize
6929 xml_hint: File name hint for markup
6932 \begin_layout Itemize
6933 xml_sha256: SHA-256 hash of ROM markup.
6936 \begin_layout Standard
6937 If there is no markup, the xml_* fields are absent.
6940 \begin_layout Subsection
6941 movie.get_game_info: Get info about loaded game
6944 \begin_layout Itemize
6945 Syntax: Table movie.get_game_info()
6948 \begin_layout Standard
6949 Returns a table with following fields:
6952 \begin_layout Itemize
6953 core: The name of the core
6956 \begin_layout Itemize
6957 core_short: Short name of the core
6960 \begin_layout Itemize
6961 type: The name of the system type
6964 \begin_layout Itemize
6965 type_long: The long name of the system type
6968 \begin_layout Itemize
6969 region: The name of region
6972 \begin_layout Itemize
6973 region_long: The long name of region
6976 \begin_layout Itemize
6977 gametype: The gametype of movie.
6980 \begin_layout Itemize
6981 fps: Nominal fps as floating-point value
6984 \begin_layout Itemize
6985 fps_n: Exact nominal fps numerator
6988 \begin_layout Itemize
6989 fps_d: Exact nominal fps denominator.
6992 \begin_layout Subsection
6993 INPUTFRAME::get_button: Get button
6996 \begin_layout Itemize
6997 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
7001 \begin_layout Standard
7002 Returns state of given button as boolean.
7005 \begin_layout Subsection
7006 INPUTFRAME::get_axis: Get axis
7009 \begin_layout Itemize
7010 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
7014 \begin_layout Standard
7015 Returns state of given axis as number.
7018 \begin_layout Subsection
7019 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
7022 \begin_layout Itemize
7023 Syntax: none INPUTFRAME::set_button(number port, number controller, number
7024 control, number/bool value)
7027 \begin_layout Itemize
7028 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
7032 \begin_layout Standard
7033 Set the given button/axis to given value.
7036 \begin_layout Subsection
7037 INPUTFRAME::serialize: Serialize a frame
7040 \begin_layout Itemize
7041 Syntax: string INPUTFRAME::serialize()
7044 \begin_layout Standard
7045 Return string representation of frame.
7048 \begin_layout Subsection
7049 INPUTFRAME::unserialize: Unserialize a frame
7052 \begin_layout Itemize
7053 Syntax: none INPUTFRAME::unserialize(string data)
7056 \begin_layout Standard
7057 Set current frame from given data.
7060 \begin_layout Subsection
7061 INPUTFRAME::get_stride: Get movie stride
7064 \begin_layout Itemize
7065 Syntax: number INPUTFRAME::get_stride()
7068 \begin_layout Standard
7069 Return number of bytes needed to store the input frame.
7070 Mainly useful for some debugging.
7073 \begin_layout Standard
7074 \begin_inset Newpage pagebreak
7080 \begin_layout Section
7084 \begin_layout Standard
7085 Routines for settings manipulation
7088 \begin_layout Subsection
7089 settings.get: Get value of setting
7092 \begin_layout Itemize
7093 Syntax: string settings.get(string name)
7096 \begin_layout Standard
7097 Get value of setting <name>.
7098 If setting value can't be obtained, returns (nil, error message).
7101 \begin_layout Subsection
7102 settings.set: Set value of setting
7105 \begin_layout Itemize
7106 Syntax: none settings.set(string name, string value)
7109 \begin_layout Standard
7110 Set value <value> of setting <name>.
7111 If setting can't be set, returns (nil, error message).
7114 \begin_layout Subsection
7115 settings.get_all: Get values of all settings
7118 \begin_layout Itemize
7119 Syntax: table settings.get_all()
7122 \begin_layout Standard
7123 Return a table with all setting names as keys and all current values as
7127 \begin_layout Subsection
7128 settings.get_speed: Get current speed
7131 \begin_layout Itemize
7132 Syntax: number/string settings.get_speed()
7135 \begin_layout Standard
7136 Return the current speed multiplier (1 is normal), or
7137 \begin_inset Quotes eld
7141 \begin_inset Quotes erd
7144 if speed is set to turbo (this does not react to turbo toggle).
7147 \begin_layout Subsection
7148 settings.set_speed: Set current speed
7151 \begin_layout Itemize
7152 Syntax: settings.get_speed(number spd)
7155 \begin_layout Itemize
7156 Syntax: settings.get_speed(string special)
7159 \begin_layout Standard
7160 Set the current speed multiplier (1 is normal).
7161 The speed may be positive multiplier or
7162 \begin_inset Quotes eld
7166 \begin_inset Quotes erd
7172 \begin_layout Standard
7173 \begin_inset Newpage pagebreak
7179 \begin_layout Section
7183 \begin_layout Standard
7184 Contains various functions for managing memory
7187 \begin_layout Subsection
7188 memory.vma_count: Count number of memory areas.
7191 \begin_layout Itemize
7192 Syntax: number memory.vma_count()
7195 \begin_layout Standard
7196 Returns the number of memory areas
7199 \begin_layout Subsection
7200 memory.read_vma: Lookup memory area info by index
7203 \begin_layout Itemize
7204 Syntax: table memory.read_vma(number index)
7207 \begin_layout Standard
7208 Reads the specified memory area (indices start from zero).
7209 Trying to read invalid memory area gives nil.
7210 The return value is table with the following fields:
7213 \begin_layout Itemize
7214 region_name (string): The readable name of the memory area
7217 \begin_layout Itemize
7218 baseaddr (number): Base address of the memory area
7221 \begin_layout Itemize
7222 lastaddr (number): Last address in the memory area.
7225 \begin_layout Itemize
7226 size (number): The size of memory area in bytes.
7229 \begin_layout Itemize
7230 readonly (boolean): True of the memory area corresponds to ROM.
7233 \begin_layout Itemize
7234 iospace (boolean): True if the memory area is I/O space.
7237 \begin_layout Itemize
7238 native_endian (boolean): True if the memory area has native endian as opposed
7242 \begin_layout Subsection
7243 memory.find_vma: Find memory area info by address
7246 \begin_layout Itemize
7247 Syntax: table memory.find_vma(number address)
7250 \begin_layout Standard
7251 Finds the memory area containing specified address.
7252 Returns table in the same format as read_vma or nil if not found.
7255 \begin_layout Subsection
7256 memory.read{,s}{byte,{,h,d,q}word}: Read memory
7259 \begin_layout Itemize
7260 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
7263 \begin_layout Itemize
7264 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
7267 \begin_layout Itemize
7268 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
7271 \begin_layout Itemize
7272 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
7275 \begin_layout Itemize
7276 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
7279 \begin_layout Itemize
7280 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
7283 \begin_layout Itemize
7284 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
7287 \begin_layout Itemize
7288 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
7291 \begin_layout Itemize
7292 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
7295 \begin_layout Itemize
7296 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
7299 \begin_layout Standard
7300 Reads the specified address <address> (if 's' variant is used, do undergo
7304 \begin_layout Subsection
7305 memory.{,s}read_sg: Scatter/Gather read memory
7308 \begin_layout Itemize
7309 Syntax: none memory.read_sg(string/boolean/number...)
7312 \begin_layout Itemize
7313 Syntax: none memory.sread_sg(string/boolean/number...)
7316 \begin_layout Standard
7317 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
7319 Each argument can be string, boolean or number:
7322 \begin_layout Itemize
7323 String: Set memory area addresses are relative to (e.g.
7327 \begin_layout Itemize
7328 boolean: If true, increment relative address by 1, if false, decrement by
7330 The new address is read as next higher byte.
7333 \begin_layout Itemize
7334 integer: Set the relative address to specified value and read the address
7335 as next higher byte.
7338 \begin_layout Subsection
7339 memory.write_sg: Scatter/Gather write memory
7342 \begin_layout Itemize
7343 Syntax: none memory.write_sg(number value, string/boolean/number...)
7346 \begin_layout Standard
7347 Perform scatter/gather write of value <value> on memory.
7348 Each argument can be string, boolean or number:
7351 \begin_layout Itemize
7352 String: Set memory area addresses are relative to (e.g.
7356 \begin_layout Itemize
7357 boolean: If true, increment relative address by 1, if false, decrement by
7359 The new address is read as next higher byte.
7362 \begin_layout Itemize
7363 integer: Set the relative address to specified value and read the address
7364 as next higher byte.
7367 \begin_layout Subsection
7368 memory.read{float,double}: Read memory
7371 \begin_layout Itemize
7372 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7375 \begin_layout Itemize
7376 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7379 \begin_layout Standard
7380 Reads the specified address <address>
7383 \begin_layout Subsection
7384 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7387 \begin_layout Itemize
7388 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7392 \begin_layout Itemize
7393 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7397 \begin_layout Itemize
7398 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7402 \begin_layout Itemize
7403 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7407 \begin_layout Itemize
7408 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7412 \begin_layout Itemize
7413 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7417 \begin_layout Itemize
7418 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7422 \begin_layout Standard
7423 Writes the specified value <value> (negative integer values undergo 2's
7424 complement) to specified address <address>.
7427 \begin_layout Subsection
7428 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7431 \begin_layout Itemize
7432 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7436 \begin_layout Standard
7437 Returns a table mapping specified memory aperture for read/write.
7440 \begin_layout Itemize
7441 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7442 qword, sqword, float or double.
7445 \begin_layout Subsection
7446 memory.hash_region: Hash region of memory
7449 \begin_layout Itemize
7450 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7454 \begin_layout Standard
7455 Hash <size> bytes starting from address <base> (relative to <marea>) and
7459 \begin_layout Subsection
7460 memory.hash_region2: Hash region of memory
7463 \begin_layout Itemize
7464 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7465 number size[, number rows, number stride])
7468 \begin_layout Standard
7469 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7471 The blocks are offset by <stride> from one another and return the SHA-256.
7474 \begin_layout Subsection
7475 memory.hash_region_skein: Hash region of memory
7478 \begin_layout Itemize
7479 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7480 addrobj}, number size[, number rows, number stride])
7483 \begin_layout Standard
7484 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7485 finalists) as hash function.
7488 \begin_layout Subsection
7489 memory.store: Store region of memory
7492 \begin_layout Itemize
7493 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7494 daddr[, number rows, number stride]
7497 \begin_layout Standard
7498 Copy memory starting from <addr> in memory area <marea> (each row being
7499 of size <size>, there being <rows> rows, and rows being separated by <stride>
7500 in memory) into savestate-saved memory area, starting from <daadr> (all
7501 rows are written back to back).
7504 \begin_layout Subsection
7505 memory.storecmp: Compare and store region of memory
7508 \begin_layout Itemize
7509 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7510 number daddr[, number rows, number stride]
7513 \begin_layout Standard
7514 Like memory.store, but returns true if target of copy already held the value
7515 that would be copied before the copy happened.
7516 Otherwise returns false (if target and source differ before copy).
7519 \begin_layout Subsection
7520 memory.hash_state: Hash system state
7523 \begin_layout Itemize
7524 Syntax: string memory.hash_state()
7527 \begin_layout Standard
7528 Hash the current system state.
7529 Mainly useful for debugging savestates.
7532 \begin_layout Subsection
7533 memory.readregion: Read region of memory
7536 \begin_layout Itemize
7537 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7541 \begin_layout Standard
7542 Read a region of memory.
7545 \begin_layout Itemize
7546 Warning: If the region crosses memory area boundary, the results are undefined.
7549 \begin_layout Subsection
7550 memory.writeregion: Write region of memory
7553 \begin_layout Itemize
7554 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7555 number size, table data)
7558 \begin_layout Standard
7559 Write a region of memory.
7562 \begin_layout Itemize
7563 Warning: If the region crosses memory area boundary, the results are undefined.
7566 \begin_layout Subsection
7567 memory.action: Run core action
7570 \begin_layout Itemize
7571 memory.action(string action, [<params>])
7574 \begin_layout Standard
7576 The different models expect parameters as:
7579 \begin_layout Itemize
7583 \begin_layout Itemize
7587 \begin_layout Itemize
7591 \begin_layout Itemize
7595 \begin_layout Itemize
7599 \begin_layout Subsection
7600 memory.action_flags: Get core action flags
7603 \begin_layout Itemize
7604 memory.action_flags(string action)
7607 \begin_layout Standard
7608 Get value of action flags for core action <action>.
7611 \begin_layout Itemize
7615 \begin_layout Itemize
7616 Bit 1: Selected (not all actions can be selected)?
7619 \begin_layout Subsection
7620 memory.get_lag_flag: Get lag flag
7623 \begin_layout Itemize
7624 Syntax: boolean memory.get_lag_flag()
7627 \begin_layout Standard
7628 Get the value of core lag flag.
7629 True if this frame has been lag so far, false if poll has been detected.
7632 \begin_layout Subsection
7633 memory.set_lag_flag: Set lag flag
7636 \begin_layout Itemize
7637 Syntax: none memory.set_lag_flag(boolean flag)
7640 \begin_layout Standard
7641 Set the value of core lag flag.
7642 This flag automatically gets cleared if poll is detected, but can be forcibly
7643 set or cleared if game so requires.
7646 \begin_layout Itemize
7647 Should only be used in on_frame_emulated callback.
7650 \begin_layout Itemize
7651 Setting or clearing this affects the emulator lag counter.
7654 \begin_layout Subsection
7655 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7659 \begin_layout Itemize
7660 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
7664 \begin_layout Itemize
7665 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
7666 addrobj}, function fn);
7669 \begin_layout Itemize
7670 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
7674 \begin_layout Itemize
7675 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
7679 \begin_layout Itemize
7680 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
7684 \begin_layout Itemize
7685 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
7689 \begin_layout Standard
7690 Add or remove callback on memory read, write or execute (depending on the
7692 <addr> is relative to <marea>.
7693 <fn> is the callback.
7694 The register* functions return <fn> (which can then be passed to unregister*
7698 \begin_layout Itemize
7699 Not all cores support this, and it may be unsupported for some memory areas.
7702 \begin_layout Itemize
7703 The functions are passed two parameters: Address and value.
7706 \begin_layout Subsection
7707 memory.{,un}registertrace: Set/Clear trace hook
7710 \begin_layout Itemize
7711 Syntax: function memory.registertrace(number processor, function fn);
7714 \begin_layout Itemize
7715 Syntax: none memory.unregistertrace(number processor, function fn);
7718 \begin_layout Standard
7719 Add or remove trace callback.
7720 <processor> is system-dependent processor number (0 is usually main CPU).
7721 The function arguments work like in other (un)register* functions.
7724 \begin_layout Itemize
7725 The functions are passed two parameters: Trace CPU and Trace event string.
7728 \begin_layout Subsection
7729 memory.cheat: Set cheat
7732 \begin_layout Itemize
7733 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
7737 \begin_layout Itemize
7738 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
7741 \begin_layout Standard
7742 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
7743 If <value> is not speicified, clear a cheat.
7746 \begin_layout Itemize
7747 Not all cores support this, and it may be unsupported for some memory areas.
7750 \begin_layout Subsection
7751 memory.setxmask: Set global execute hook mask
7754 \begin_layout Itemize
7755 Syntax: none memory.setxmask(number mask)
7758 \begin_layout Standard
7759 Set the global execute hook mask to <mask>.
7760 The meaning of each bit is system-dependent, but bit 0 should be the main
7764 \begin_layout Subsection
7765 memory.getregister: Get register value
7768 \begin_layout Itemize
7769 Syntax: number/boolean memory.getregister(string register)
7772 \begin_layout Standard
7773 Get the value of named register.
7776 \begin_layout Subsection
7777 memory.getregisters: Get register values
7780 \begin_layout Itemize
7781 Syntax: table memory.getregisters()
7784 \begin_layout Standard
7785 Get the value of all known registers as table.
7788 \begin_layout Subsection
7789 memory.setregister: Set register value
7792 \begin_layout Itemize
7793 Syntax: none memory.setregister(string register, number/boolean value)
7796 \begin_layout Standard
7797 Set the value of named register.
7800 \begin_layout Subsection
7801 memory.mmap: Class MMAP_STRUCT
7804 \begin_layout Standard
7805 See class MMAP_STRUCT
7808 \begin_layout Standard
7809 \begin_inset Newpage pagebreak
7815 \begin_layout Section
7819 \begin_layout Standard
7820 Contains newer memory functions.
7823 \begin_layout Subsection
7824 memory2(): Get all memory area names.
7827 \begin_layout Itemize
7828 Syntax: table memory2()
7831 \begin_layout Standard
7832 Returns array of all valid memory area names.
7835 \begin_layout Subsection
7836 memory2.<marea>:info: Get memory area info
7839 \begin_layout Itemize
7840 Syntax: table memory2.<marea>:info()
7843 \begin_layout Standard
7844 Return table describing given memory area.
7845 Includes fields address, size, last, readonly, special and endian.
7848 \begin_layout Subsection
7849 memory2.<marea>:<op>: Read/Write memory
7852 \begin_layout Itemize
7853 Syntax: none memory2.<marea>:<op>(number offset, number value)
7856 \begin_layout Itemize
7857 Syntax: number memory2.<marea>:<op>(number offset)
7860 \begin_layout Standard
7861 Read/Write value from/to given memory area <marea> at given offset <offset>
7863 The value written is <value>.
7864 <Op> is of form: [i][s]<type>, where:
7867 \begin_layout Itemize
7868 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
7871 \begin_layout Itemize
7872 'i' signifies that the value is treated as opposite-to-normal endianess,
7875 \begin_layout Itemize
7876 's' signifies that value is treated as signed (not available for floating-point).
7879 \begin_layout Subsection
7880 memory2.<marea>:read: Scatter-gather value read
7883 \begin_layout Itemize
7884 Syntax: number memory2.<marea>:read(number addr...)
7887 \begin_layout Standard
7888 Read value from given memory area <marea> at byte offsets <addr>..., given
7889 in order of increasing significance.
7890 Value of true and false are special.
7891 True increments address by 1, and false decrements address by 1.
7894 \begin_layout Subsection
7895 memory2.<marea>:sread: Signed scatter-gather value read
7898 \begin_layout Itemize
7899 Syntax: number memory2.<marea>:sread(number addr...)
7902 \begin_layout Standard
7903 Like memory2.<marea>:read, but reads signed values.
7906 \begin_layout Subsection
7907 memory2.<marea>:write: Scatter-gather value write
7910 \begin_layout Itemize
7911 Syntax: number memory2.<marea>:write(number val, number addr...)
7914 \begin_layout Standard
7915 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
7916 in order of increasing significance.
7917 Value of true and false are special.
7918 True increments address by 1, and false decrements address by 1.
7921 \begin_layout Subsection
7922 memory2.<marea>:cheat: Set/Clear cheat
7925 \begin_layout Itemize
7926 Syntax: none memory2.<marea>:cheat(number addr, [number value])
7929 \begin_layout Standard
7930 Set/Clear cheat at offset <addr> of memory area <marea>.
7931 If <value> is given, cheat with specified value is set.
7932 Otherwise cheat on address is removed.
7935 \begin_layout Subsection
7936 memory2.<marea>:sha256: SHA-256
7939 \begin_layout Itemize
7940 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
7944 \begin_layout Standard
7945 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
7946 from offset <addr> of area <marea>.
7947 The chunks are separated by <stride>.
7950 \begin_layout Subsection
7951 memory2.<marea>:skein: Skein-512-256
7954 \begin_layout Itemize
7955 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
7959 \begin_layout Standard
7960 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
7963 \begin_layout Subsection
7964 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
7967 \begin_layout Itemize
7968 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
7969 number rows, number stride])
7972 \begin_layout Itemize
7973 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
7974 size[, number rows, number stride])
7977 \begin_layout Standard
7978 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
7979 <addr> of area <marea>.
7980 The chunks are separated by <stride>.
7981 The target is Lua host memory, starting from offset <daddr>.
7984 \begin_layout Standard
7985 Additionally, the storecmp method returns false if target was modified (otherwis
7989 \begin_layout Subsection
7990 memory2.<marea>:readregion: Read region
7993 \begin_layout Itemize
7994 Syntax table memory2.<marea>:readregion(number addr, number size)
7997 \begin_layout Standard
7998 Read <size> bytes starting from <addr> in <marea> and return as array.
8001 \begin_layout Subsection
8002 memory2.<marea>:writeregion: Write region
8005 \begin_layout Itemize
8006 Syntax none memory2.<marea>:writeregion(number addr, table data)
8009 \begin_layout Standard
8010 Write array <data> to bytes starting from <addr> in <marea>.
8013 \begin_layout Subsection
8014 memory2.<marea>:register{read,write,exec}: Register hook
8017 \begin_layout Itemize
8018 Syntax: function memory2.<marea>:registerread(number addr, function fn);
8021 \begin_layout Itemize
8022 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
8025 \begin_layout Itemize
8026 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
8029 \begin_layout Standard
8030 Register debug callback <fn> of specified type at offset <addr> of memory
8035 \begin_layout Subsection
8036 memory2.<marea>:unregister{read,write,exec}: Unregister hook
8039 \begin_layout Itemize
8040 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
8043 \begin_layout Itemize
8044 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
8047 \begin_layout Itemize
8048 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
8051 \begin_layout Standard
8052 Unregister debug callback <fn> of specified type at offset <addr> of memory
8056 \begin_layout Standard
8057 \begin_inset Newpage pagebreak
8063 \begin_layout Section
8067 \begin_layout Standard
8068 Contains random number generation methods.
8069 These functions do not return reproducable results.
8072 \begin_layout Subsection
8073 random.boolean: Random boolean
8076 \begin_layout Itemize
8077 Syntax: boolean random.boolean()
8080 \begin_layout Standard
8081 Returns true or false at random (50-50 chance).
8084 \begin_layout Subsection
8085 random.integer: Random integer
8088 \begin_layout Itemize
8089 Syntax: number random.integer(number highplusone)
8092 \begin_layout Itemize
8093 Syntax: number random.integer(number low, number high)
8096 \begin_layout Standard
8097 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
8098 With two arguments, return random integer [<low>,<high>] (both ends inclusive).
8101 \begin_layout Standard
8102 The returned numbers are from uniform distribution.
8105 \begin_layout Subsection
8106 random.float: Random float
8109 \begin_layout Itemize
8110 Syntax: number random.float()
8113 \begin_layout Standard
8114 Returns random decimal number [0,1).
8117 \begin_layout Subsection
8118 random.among: Random parameter
8121 \begin_layout Itemize
8122 Syntax: value random.among(value values...)
8125 \begin_layout Standard
8126 Returns random parameter value, picked at uniform.
8127 Multiple equivalent values are returned with higher chance.
8130 \begin_layout Subsection
8131 random.amongtable: Random from table
8134 \begin_layout Itemize
8135 Syntax: value random.amongtable(table tab)
8138 \begin_layout Standard
8139 Returns random value from table <tab>.
8140 As in random.among, no equality testing is done.
8143 \begin_layout Standard
8144 \begin_inset Newpage pagebreak
8150 \begin_layout Section
8154 \begin_layout Subsection
8155 zip.enumerate: Enumerate members in zipfile
8158 \begin_layout Itemize
8159 Syntax: Table zip.enumerate(string filename[, boolean invert])
8162 \begin_layout Standard
8163 Returns table of files in zip archive <filename>.
8164 If <invert> is true, instead of returning array of names, returns table
8165 with keys being member names and values being true.
8168 \begin_layout Subsection
8169 zip.writer: Class ZIPWRITER
8172 \begin_layout Standard
8173 See class ZIPWRITER.
8176 \begin_layout Standard
8177 \begin_inset Newpage pagebreak
8183 \begin_layout Section
8187 \begin_layout Standard
8188 Various callback-related functions.
8191 \begin_layout Subsection
8192 \begin_inset CommandInset label
8194 name "sub:callback.register:-Register-a"
8198 callback.register: Register a callback
8201 \begin_layout Itemize
8202 Syntax: function callback.register(string cbname, function cbfun);
8205 \begin_layout Standard
8206 Instruct function <cbfun> to be added to list of callbacks to call on event
8207 <cbname> (See section
8208 \begin_inset CommandInset ref
8210 reference "sec:Callbacks"
8215 The callback name does not have the 'on_' prefix (e.g.
8217 \begin_inset Quotes eld
8221 \begin_inset Quotes erd
8228 \begin_layout Subsection
8229 \begin_inset CommandInset label
8231 name "sub:callback.unregister:-Unregister-"
8235 callback.unregister: Unregister a callback
8238 \begin_layout Itemize
8239 Syntax: function callback.unregister(string cbname, function cbfun);
8242 \begin_layout Standard
8243 Instruct function <cbfun> to be removed from list of callbacks to call on
8247 \begin_layout Subsection
8248 callback.<cbname>:register: Register callback
8251 \begin_layout Itemize
8252 Syntax: function callback.<cbname>:register(function cbfun)
8255 \begin_layout Standard
8256 Synonym for callback.register (section
8257 \begin_inset CommandInset ref
8259 reference "sub:callback.register:-Register-a"
8263 ), albeit with callback name specified differently.
8266 \begin_layout Subsection
8267 callback.<cbname>:unregister: Register callback
8270 \begin_layout Itemize
8271 Syntax: function callback.<cbname>:unregister(function cbfun)
8274 \begin_layout Standard
8275 Synonym for callback.unregister (section
8276 \begin_inset CommandInset ref
8278 reference "sub:callback.unregister:-Unregister-"
8282 ), albeit with callback name specified differently.
8285 \begin_layout Section
8289 \begin_layout Standard
8290 Various bsnes-specific functions.
8293 \begin_layout Subsection
8294 bsnes.dump_sprite: Dump a sprite
8297 \begin_layout Itemize
8298 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
8299 number height[, number stride])
8302 \begin_layout Standard
8303 Dumps given sprite (in native format) from memory.
8304 memory area is usually
8305 \begin_inset Quotes eld
8309 \begin_inset Quotes erd
8313 <Width> and <height> are given in 8x8 blocks.
8314 <Stride> overrides row stride (default 512).
8317 \begin_layout Subsection
8318 bsnes.dump_palette: Dump a palette
8321 \begin_layout Itemize
8322 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool full256,
8326 \begin_layout Standard
8327 Dumps a palette from memory.
8328 memory area is usually
8329 \begin_inset Quotes eld
8333 \begin_inset Quotes erd
8337 If <full256> is true, 256 colors are dumped (otherwise 16).
8338 If <first_trans> is true, first color is forced transparent.
8341 \begin_layout Subsection
8342 bsnes.enablelayer: Set layer visibility
8345 \begin_layout Itemize
8346 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8349 \begin_layout Standard
8350 Enable or disable specified layer at specified priority.
8353 \begin_layout Subsection
8354 bsnes.redump_sprite: Redump a sprite
8357 \begin_layout Itemize
8358 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8362 \begin_layout Standard
8363 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8364 The specified bitmap must have size multiple of 8x8.
8367 \begin_layout Subsection
8368 bsnes.redump_palette: Redump a palette
8371 \begin_layout Itemize
8372 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8376 \begin_layout Standard
8377 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8378 The specified palette must have either 16 or 256 colors.
8381 \begin_layout Section
8382 extensions to table string
8385 \begin_layout Subsection
8386 string.charU: string.char, UTF-8 version.
8389 \begin_layout Itemize
8390 Syntax: string string.charU(number n...)
8393 \begin_layout Standard
8394 Like Lua string.char(), but works in terms of Unicode codepoints.
8395 The returned string is UTF-8.
8398 \begin_layout Subsection
8399 string.byteU: string.byte, UTF-8 version.
8402 \begin_layout Itemize
8404 string.byteU(string str[, number i[, number j]])
8407 \begin_layout Standard
8408 Like string.byte(), but works in terms of Unicode codepoints.
8409 The input string <str> is assumed UTF-8.
8412 \begin_layout Subsection
8413 string.regex: Match string against regular expression
8416 \begin_layout Itemize
8417 Syntax: boolean/string...
8418 string.regex(string regexp, string against)
8421 \begin_layout Standard
8422 Match POSIX-extended regular expression <regexp> against string <against>.
8423 If no match, false is returned.
8424 Otherwise if string has no subcaptures, true is returned.
8425 Otherwise each subcapture is returned as a string (in order of starting
8429 \begin_layout Subsection
8430 string.hex: Transform integer into hex string
8433 \begin_layout Itemize
8434 Syntax: string string.hex(number n, [number digits])
8437 \begin_layout Standard
8438 Returns hexadecimal string representation of <n>, optionally padded with
8439 zeroes to <digits> digits (default is not to pad).
8442 \begin_layout Subsection
8443 string.lpad: Pad string with spaces from left
8446 \begin_layout Itemize
8447 Syntax: string string.lpad(string x, number n)
8450 \begin_layout Standard
8451 Pad string <x> to <n> bytes by inserting spaces at start and return the
8455 \begin_layout Subsection
8456 string.rpad: Pad string with spaces from right
8459 \begin_layout Itemize
8460 Syntax: string string.rpad(string x, number n)
8463 \begin_layout Standard
8464 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8467 \begin_layout Section
8471 \begin_layout Standard
8472 Contains copy of global variables from time of Lua initialization.
8476 \begin_layout Standard
8477 \begin_inset Newpage pagebreak
8483 \begin_layout Section
8484 \begin_inset CommandInset label
8486 name "sec:Callbacks"
8493 \begin_layout Standard
8494 Various callbacks to Lua that can occur.
8497 \begin_layout Subsection
8498 on_paint: Screen is being painted
8501 \begin_layout Itemize
8502 Callback: on_paint(bool not_synth)
8505 \begin_layout Standard
8506 Called when screen is being painted.
8507 Any gui.* calls requiring graphic context draw on the screen.
8510 \begin_layout Itemize
8511 not_synth is true if this hook is being called in response to received frame,
8515 \begin_layout Subsection
8516 on_video: Dumped video frame is being painted
8519 \begin_layout Itemize
8520 Callback: on_video()
8523 \begin_layout Standard
8524 Called when video dump frame is being painted.
8525 Any gui.* calls requiring graphic context draw on the video.
8528 \begin_layout Subsection
8529 on_frame_emulated: Frame emulation complete
8532 \begin_layout Itemize
8533 Callback: on_frame_emulated()
8536 \begin_layout Standard
8537 Called when emulating frame has completed and on_paint()/on_video() calls
8538 are about to be issued.
8541 \begin_layout Subsection
8542 on_frame: Frame emulation starting.
8545 \begin_layout Itemize
8546 Callback: on_frame()
8549 \begin_layout Standard
8550 Called on each starting whole frame.
8553 \begin_layout Subsection
8554 on_rewind: Movie rewound to beginning
8557 \begin_layout Itemize
8558 Callback: on_rewind()
8561 \begin_layout Standard
8562 Called when rewind movie to beginning has completed.
8565 \begin_layout Subsection
8566 on_pre_load: Load operation is about to start
8569 \begin_layout Itemize
8570 Callback: on_pre_load(string name)
8573 \begin_layout Standard
8574 Called just before savestate/movie load occurs (note: loads are always delayed,
8575 so this occurs even when load was initiated by lua).
8578 \begin_layout Subsection
8579 on_err_Load: Load failed
8582 \begin_layout Itemize
8583 Callback: on_err_load(string name)
8586 \begin_layout Standard
8587 Called if loadstate goes wrong.
8590 \begin_layout Subsection
8591 on_post_load: Load completed
8594 \begin_layout Itemize
8595 Callback: on_post_load(string name, boolean was_savestate)
8598 \begin_layout Standard
8599 Called on successful loadstate.
8600 was_savestate gives if this was a savestate or a movie.
8603 \begin_layout Subsection
8604 on_pre_save: Save operation is about to start
8607 \begin_layout Itemize
8608 Callback: on_pre_save(string name, boolean is_savestate)
8611 \begin_layout Standard
8612 Called just before savestate save occurs (note: movie saves are synchronous
8613 and won't trigger these callbacks if called from Lua).
8616 \begin_layout Subsection
8617 on_err_save: Save failed
8620 \begin_layout Itemize
8621 Callback: on_err_save(string name)
8624 \begin_layout Standard
8625 Called if savestate goes wrong.
8628 \begin_layout Subsection
8629 on_post_save: Save completed
8632 \begin_layout Itemize
8633 Callback: on_post_save(string name, boolean is_savestate)
8636 \begin_layout Standard
8637 Called on successful savaestate.
8638 is_savestate gives if this was a savestate or a movie.
8641 \begin_layout Subsection
8642 on_quit: Emulator is shutting down
8645 \begin_layout Itemize
8649 \begin_layout Standard
8650 Called when emulator is shutting down.
8653 \begin_layout Subsection
8654 on_input: Polling for input
8657 \begin_layout Standard
8658 Called when emulator is just sending input to bsnes core.
8659 Warning: This is called even in readonly mode, but the results are ignored.
8662 \begin_layout Subsection
8663 on_reset: System has been reset
8666 \begin_layout Itemize
8667 Callback: on_reset()
8670 \begin_layout Standard
8671 Called when system is reset.
8674 \begin_layout Subsection
8675 on_readwrite: Entered recording mode
8678 \begin_layout Itemize
8679 Callback: on_readwrite()
8682 \begin_layout Standard
8683 Called when moving into recording mode as result of
8684 \begin_inset Quotes eld
8688 \begin_inset Quotes erd
8691 command (note: moving to rwmode by Lua won't trigger this, as per recursive
8695 \begin_layout Subsection
8696 on_snoop/on_snoop2: Snoop core controller reads
8699 \begin_layout Itemize
8700 Callback: on_snoop(number port, number controller, number index, number
8704 \begin_layout Itemize
8705 Callback: on_snoop2(number port, number controller, number index, number
8709 \begin_layout Standard
8710 Called each time bsnes asks for input.
8711 The value is the final value to be sent to bsnes core (readonly mode, autohold
8712 and autofire have been taken into account).
8713 Might be useful when translating movies to format suitable for console
8715 Note: There is no way to modify the value to be sent.
8718 \begin_layout Itemize
8719 On_snoop2 is called instead of on_snoop if defined.
8720 Reserves port 0 for system, having first user port be port 1.
8723 \begin_layout Subsection
8724 on_keyhook: Hooked key/axis has been moved
8727 \begin_layout Itemize
8728 Callback: on_keyhook(string keyname, table state)
8731 \begin_layout Standard
8732 Sent when key that has keyhook events requested changes state.
8733 Keyname is name of the key (group) and state is the state (same kind as
8734 table values in input.raw).
8737 \begin_layout Subsection
8741 \begin_layout Itemize
8745 \begin_layout Standard
8746 Called when requested by set_idle_timeout(), the timeout has expired and
8747 emulator is waiting.
8750 \begin_layout Subsection
8751 on_timer: Timer event
8754 \begin_layout Itemize
8755 Callback: on_timer()
8758 \begin_layout Standard
8759 Called when requested by set_idle_timeout() and the timeout has expired
8760 (regardless if emulator is waiting).
8763 \begin_layout Subsection
8764 on_set_rewind: Rewind point has been set
8767 \begin_layout Itemize
8768 Callback: on_set_rewind(UNSAFEREWIND r)
8771 \begin_layout Standard
8772 Called when unsafe rewind object has been constructed.
8775 \begin_layout Subsection
8776 on_pre_rewind: Rewind is about to occur
8779 \begin_layout Itemize
8780 Callback: on_pre_rewind()
8783 \begin_layout Standard
8784 Called just before unsafe rewind is about to occur.
8787 \begin_layout Subsection
8788 on_post_rewind: Rewind has occured
8791 \begin_layout Itemize
8792 Callback: on_post_rewind()
8795 \begin_layout Standard
8796 Called just after unsafe rewind has occured.
8799 \begin_layout Subsection
8800 on_button: Button has been pressed
8803 \begin_layout Itemize
8804 Callback: on_button(number port, number controller, number index, string
8808 \begin_layout Standard
8809 Called on controller button press, with following parameters:
8812 \begin_layout Itemize
8813 port: Port number (0 is system)
8816 \begin_layout Itemize
8817 controller: Controller within port
8820 \begin_layout Itemize
8821 index: Index of button.
8824 \begin_layout Itemize
8825 type: Type of event, one of:
8829 \begin_layout Itemize
8830 \begin_inset Quotes eld
8834 \begin_inset Quotes erd
8837 : Button was pressed.
8840 \begin_layout Itemize
8841 \begin_inset Quotes eld
8845 \begin_inset Quotes erd
8848 : Button was released.
8851 \begin_layout Itemize
8852 \begin_inset Quotes eld
8856 \begin_inset Quotes erd
8862 \begin_layout Itemize
8863 \begin_inset Quotes eld
8867 \begin_inset Quotes erd
8870 : Released from hold.
8873 \begin_layout Itemize
8874 \begin_inset Quotes eld
8878 \begin_inset Quotes erd
8881 : Typing input on button.
8884 \begin_layout Itemize
8885 \begin_inset Quotes eld
8889 \begin_inset Quotes erd
8892 : Typing input undone.
8895 \begin_layout Itemize
8896 \begin_inset Quotes eld
8899 autofire <duty> <cycle>
8900 \begin_inset Quotes erd
8903 : Autofire with specifie duty and cycle.
8906 \begin_layout Itemize
8907 \begin_inset Quotes eld
8911 \begin_inset Quotes erd
8917 \begin_layout Itemize
8918 \begin_inset Quotes eld
8922 \begin_inset Quotes erd
8925 : Analog action on axis.
8929 \begin_layout Subsection
8930 on_movie_lost: Movie data is about to be lost
8933 \begin_layout Itemize
8934 Callback: on_movie_lost(STRING kind)
8937 \begin_layout Standard
8938 Called just before something would happen that could lose movie data.
8942 \begin_layout Itemize
8943 readwrite: Switching to recording mode.
8946 \begin_layout Itemize
8947 reload: ROM is being reloaded in recording mode.
8950 \begin_layout Itemize
8951 load: New movie is being loaded.
8954 \begin_layout Itemize
8955 unsaferewind: Unsafe rewind is happening.
8958 \begin_layout Subsection
8959 on_latch: Latch line is rising
8962 \begin_layout Itemize
8963 Callback: on_latch(<core-dependent-parameters>)
8966 \begin_layout Standard
8967 Called when latch line for controller is rising.
8968 Some cores may not support this.
8971 \begin_layout Section
8972 System-dependent behaviour
8975 \begin_layout Subsection
8979 \begin_layout Itemize
8980 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
8981 p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
8982 p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
8983 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
8984 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
8985 ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
8986 ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
8987 ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
8988 ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
8989 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
8990 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
8991 ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
8992 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
8993 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
8994 ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
8995 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
8996 ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
8997 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
8998 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
8999 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
9000 ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
9001 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
9002 ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
9003 ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
9004 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
9005 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
9006 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
9007 ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
9008 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
9009 ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
9010 ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
9011 ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
9012 ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
9013 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
9014 ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
9015 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
9016 ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
9017 ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
9018 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
9019 ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount,
9022 \begin_layout Itemize
9023 on_latch has no parameters
9026 \begin_layout Itemize
9027 CPU 0 is S-CPU, 1 is S-SMP.
9030 \begin_layout Itemize
9031 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
9034 \begin_layout Itemize
9035 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
9039 \begin_layout Itemize
9040 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
9041 DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
9042 BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
9043 GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
9046 \begin_layout Subsection
9050 \begin_layout Itemize
9051 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
9055 \begin_layout Itemize
9056 on_latch is not supported
9059 \begin_layout Itemize
9063 \begin_layout Itemize
9064 Cheats are supported for ROM, SRAM and WRAM.
9067 \begin_layout Itemize
9068 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
9072 \begin_layout Itemize
9073 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.