1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
6 \use_default_options true
7 \maintain_unincluded_children false
9 \language_package default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
23 \default_output_format default
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
48 \paperorientation portrait
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
69 \paperpagestyle default
70 \tracking_changes false
80 lsnes Lua functions reference
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
103 \begin_layout Section
107 \begin_layout Subsection
111 \begin_layout Itemize
112 Coordinates increase to right and down.
115 \begin_layout Itemize
116 The origin is at top left of game area or buffer.
119 \begin_layout Subsection
123 \begin_layout Itemize
124 Methods that draw something (unless stated otherwise) require a valid rendering
126 This context can come in three ways:
130 \begin_layout Enumerate
131 The default rendering context of paint callback (the screen).
134 \begin_layout Enumerate
135 The default rendering context of video callback (the video).
138 \begin_layout Enumerate
139 Explicitly set rendering context (RENDERCTX:set).
143 \begin_layout Itemize
144 The rendering context is always reset when callback ends.
147 \begin_layout Subsection
151 \begin_layout Standard
152 (Direct) colors can be specified either as numbers or strings.
155 \begin_layout Itemize
156 -1 is fully transparent.
159 \begin_layout Itemize
160 Non-negative numbers less than
161 \begin_inset Formula $2^{32}$
164 are partially opaque colors (
165 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
172 \begin_layout Itemize
173 \begin_inset Formula $a$
177 \begin_inset Formula $0-255$
181 \begin_inset Formula $0$
185 \begin_inset Formula $256$
188 would be fully transparent.
192 \begin_layout Itemize
193 Thus, numbers in range
194 \begin_inset Formula $0-16777215$
197 stand for fully opaque colors.
201 \begin_layout Itemize
202 \begin_inset Formula $r$
206 \begin_inset Formula $g$
210 \begin_inset Formula $b$
213 are intensities of base colors on scale
214 \begin_inset Formula $0-255$
221 \begin_layout Itemize
222 Color can also be specified by name as string: The following color names
223 are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
224 antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
225 azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
226 bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
227 brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
228 burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
229 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
230 chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
231 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
232 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
233 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
234 darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
235 darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
236 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
237 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
238 darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
239 darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
240 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
241 dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
242 firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
243 fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
244 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
245 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
246 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
247 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
248 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
249 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
250 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
251 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
252 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
253 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
254 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
255 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
256 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
257 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
258 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
259 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
260 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
261 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
262 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
263 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
264 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
265 indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
266 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
267 lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
268 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
269 lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
270 lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
271 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
272 lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
273 lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
274 lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
275 lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
276 lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
277 lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
278 maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
279 mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
280 mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
281 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
282 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
283 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
284 navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
285 olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
286 orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
287 palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
288 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
289 palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
290 peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
291 pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
292 purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
293 rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
294 saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
295 seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
296 seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
297 skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
298 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
299 snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
300 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
301 tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
302 tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
303 turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
304 wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
305 yellow3 yellow4 yellowgreen
308 \begin_layout Itemize
309 The HSL base color names: hsl-<hue><saturation><lightness>.
313 \begin_layout Itemize
314 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
315 y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
316 (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
319 \begin_layout Itemize
320 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
323 \begin_layout Itemize
324 Lightness is 0-8, where 0 is black and 8 is white.
328 \begin_layout Itemize
329 The color names can have a modifier after space (multiple modifiers are
330 allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
331 opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
332 hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
336 \begin_layout Itemize
337 opaqueness is measured as percentage.
340 \begin_layout Itemize
341 Hue adjustments are on 24-step scale.
344 \begin_layout Itemize
345 Saturation and lightness adjustments are on 16-step scale.
349 \begin_layout Section
353 \begin_layout Standard
354 These tokens are special, and are expanded while the script is being loaded
357 \begin_layout Subsection
358 @@LUA_SCRIPT_FILENAME@@
361 \begin_layout Standard
362 Expanded to string token containing path and filename of this Lua script.
363 Handy for referencing other lua scripts or resources that are relative
367 \begin_layout Standard
368 In practicular, this is suitable to be passed as base argument of various
369 functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
370 ad_png and gui.bitmap_load_pal.
373 \begin_layout Section
377 \begin_layout Subsection
378 MMAP_STRUCT: Quasi-table mapping emulated memory
381 \begin_layout Standard
382 Objects of this class act like tables, except that the values are reflected
383 to and from emulated memory.
386 \begin_layout Subsubsection
387 static function new: Create new instance
390 \begin_layout Itemize
391 Syntax: mmap memory.mmap.new()
394 \begin_layout Itemize
395 Syntax: mmap classes.MMAP_STRUCT.new()
398 \begin_layout Itemize
399 Deprecated: mmap memory.map_structure()
402 \begin_layout Standard
406 \begin_layout Itemize
407 mmap: MMAP_STRUCT: The created mmap structure.
410 \begin_layout Standard
411 Create a new MMAP_STRUCT (with no mappings) and return it.
414 \begin_layout Subsubsection
415 operator(): Bind key in mmap structure
418 \begin_layout Itemize
419 Syntax: obj(key, {marea, address|addrobj}, type)
422 \begin_layout Standard
426 \begin_layout Itemize
427 obj: MMAP_STRUCT: The structure to manipulate.
430 \begin_layout Itemize
431 key: String: The name of the key in array to map.
434 \begin_layout Itemize
435 marea: String: The memory area the mapped address is in (default: global
439 \begin_layout Itemize
440 address: Number: The offset of memory addreess, relative to specified memory
441 area or global memory space.
444 \begin_layout Itemize
445 addrobj: ADDRESS: The memory address.
448 \begin_layout Itemize
449 type: String: The type of data to map.
453 \begin_layout Itemize
454 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
459 \begin_layout Standard
460 Bind key <key> in mmap structure <obj> to address <address> (relative to
462 The memory address is treated as type <type>.
465 \begin_layout Itemize
467 \begin_inset Quotes eld
471 \begin_inset Quotes erd
475 \begin_inset Quotes eld
479 \begin_inset Quotes erd
483 \begin_inset Quotes eld
487 \begin_inset Quotes erd
493 \begin_layout Standard
494 This binds signed word at address WRAM+0x2A into key
495 \begin_inset Quotes eld
499 \begin_inset Quotes erd
505 \begin_layout Standard
506 \begin_inset Newpage pagebreak
512 \begin_layout Subsection
513 ZIPWRITER: Write .zip files
516 \begin_layout Standard
517 This class does writing of .zip files.
520 \begin_layout Subsubsection
521 Static function new: Create a new zipfile
524 \begin_layout Itemize
525 Syntax: zip zip.writer.new(filename, [compression])
528 \begin_layout Itemize
529 Deprecated: zip zip.create(filename, [compression])
532 \begin_layout Standard
536 \begin_layout Itemize
537 filename: string: The name of the file to write.
540 \begin_layout Itemize
541 compression: number: Compression level (0-9).
545 \begin_layout Standard
549 \begin_layout Itemize
550 zip: ZIPWRITER: The newly created ZIP writer.
553 \begin_layout Standard
554 Create a new ZIPWRITER object and return it.
557 \begin_layout Subsubsection
558 Method commit: Finish creating ZIP file.
561 \begin_layout Itemize
562 Syntax: zipfile:commit()
565 \begin_layout Standard
569 \begin_layout Itemize
570 zipfile: ZIPFILE: The ZIP file object.
573 \begin_layout Standard
574 Finish writing the ZIP file and actually create it on disk.
577 \begin_layout Itemize
578 If a member is currently open, it is implicitly closed.
581 \begin_layout Itemize
582 Invoking this on already committed or rolled back zipfile causes an error.
585 \begin_layout Subsubsection
586 Method rollback: Cancel writing the ZIP file.
589 \begin_layout Itemize
590 Syntax: zipfile:rollback()
593 \begin_layout Standard
597 \begin_layout Itemize
598 zipfile: ZIPFILE: The ZIP file object.
601 \begin_layout Standard
602 Cancel writing the whole ZIP file.
603 The file on disk will not be modified.
606 \begin_layout Itemize
607 If a member is currently open, it is implicitly closed.
610 \begin_layout Itemize
611 Invoking this on already committed or rolled back zipfile causes an error.
614 \begin_layout Subsubsection
615 Method create_file: Start writing a new member
618 \begin_layout Itemize
619 Syntax: zipfile:create_file(filename)
622 \begin_layout Standard
626 \begin_layout Itemize
627 zipfile: ZIPFILE: The ZIP file object.
630 \begin_layout Itemize
631 string filename: Name of the new member to create
634 \begin_layout Standard
635 Start writing a new member <filename> in ZIP file.
638 \begin_layout Itemize
639 If a member is currently open, it is implicitly closed.
642 \begin_layout Itemize
643 Invoking this on already committed or rolled back zipfile causes an error.
646 \begin_layout Subsubsection
647 Method close_file: Close member
650 \begin_layout Itemize
651 Syntax: zipfile:close_file()
654 \begin_layout Standard
658 \begin_layout Itemize
659 zipfile: ZIPFILE: The ZIP file object.
662 \begin_layout Standard
663 Close the currently open member in zipfile.
666 \begin_layout Itemize
667 Invoking this on already committed or rolled back zipfile causes an error.
670 \begin_layout Itemize
671 Invoking this without an open member causes an error.
674 \begin_layout Subsubsection
675 Method write: Write data
678 \begin_layout Itemize
679 Syntax: zipfile:write(data)
682 \begin_layout Standard
686 \begin_layout Itemize
687 zipfile: ZIPFILE: The ZIP file object.
690 \begin_layout Itemize
691 data: string: The data to write.
694 \begin_layout Standard
695 Write <data> in binary mode (as-is) to currently open member.
698 \begin_layout Itemize
699 Invoking this without a member being open causes an error.
702 \begin_layout Standard
703 \begin_inset Newpage pagebreak
709 \begin_layout Subsection
710 TILEMAP: Tiled collection of bitmaps.
713 \begin_layout Standard
714 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
717 \begin_layout Subsubsection
718 Static function new: Create a tilemap
721 \begin_layout Itemize
722 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
725 \begin_layout Itemize
726 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
729 \begin_layout Itemize
730 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
733 \begin_layout Standard
737 \begin_layout Itemize
738 w: number: Width of the tilemap in tiles
741 \begin_layout Itemize
742 h: number: Height of the tilemap in tiles
745 \begin_layout Itemize
746 bw: number: Width of each tile in pixels.
749 \begin_layout Itemize
750 bh: number: Height of each tile in pixels.
753 \begin_layout Standard
757 \begin_layout Itemize
758 tilemap: TILEMAP: the newly created tilemap
761 \begin_layout Standard
762 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
766 \begin_layout Subsubsection
767 TILEMAP:getsize: Query tilemap size
770 \begin_layout Itemize
771 Syntax: width, height tmap:getsize()
774 \begin_layout Standard
778 \begin_layout Itemize
779 tmap: TILEMAP: The tilemap to query.
782 \begin_layout Standard
786 \begin_layout Itemize
787 width: number : The width of the tilemap in tiles.
790 \begin_layout Itemize
791 height: number: The height of the tilemap in tiles.
794 \begin_layout Standard
795 Get size of tilemap in tiles.
798 \begin_layout Subsubsection
799 TILEMAP:getcsize: Query tilemap cell size
802 \begin_layout Itemize
803 Syntax: width, height tmap:getcsize()
806 \begin_layout Standard
810 \begin_layout Itemize
811 tmap: TILEMAP: The tilemap to query.
814 \begin_layout Standard
818 \begin_layout Itemize
819 width: number: The width of tilemap tile in pixels.
822 \begin_layout Itemize
823 height: number: The height of tilemap tile in pixels.
826 \begin_layout Standard
827 Get size of each tilemap tile in pixels.
830 \begin_layout Subsubsection
831 TILEMAP:get: Query tilemap tile
834 \begin_layout Itemize
835 Syntax: bitmap, palette tmap:get(x, y)
838 \begin_layout Standard
842 \begin_layout Itemize
843 tmap: TILEMAP: The tilemap to query.
846 \begin_layout Itemize
847 x: number: The x-coordinate of tile to query.
850 \begin_layout Itemize
851 y: number: The y-coordinate of tile to query.
854 \begin_layout Standard
858 \begin_layout Itemize
859 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
862 \begin_layout Itemize
863 palette: The palette (PALETTE) associated with indexed-color bitmap, if
868 \begin_layout Standard
869 Return the contents of tile at <x>,<y>.
872 \begin_layout Subsubsection
873 TILEMAP:set: Set tilemap cell
876 \begin_layout Itemize
877 Syntax: tmap:set(x, y)
880 \begin_layout Itemize
881 Syntax: tmap:set(x, y, bitmap)
884 \begin_layout Itemize
885 Syntax: tmap:set(x, y, bitmap, palette)
888 \begin_layout Standard
892 \begin_layout Itemize
893 tmap: TILEMAP: The tilemap to manipulate.
896 \begin_layout Itemize
897 number x: The x-coordinate of tile to set.
900 \begin_layout Itemize
901 number y: The y-coordinate of tile to set.
904 \begin_layout Itemize
905 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
908 \begin_layout Itemize
909 palette: PALETTE: The associated palette for bitmap.
912 \begin_layout Standard
913 Set the contents of tile <x>,<y>.
914 If no <bitmap> is given, clears the tile.
915 Otherwise sets the tile to contain bitmap <bitmap> with associated palette
919 \begin_layout Itemize
920 Specifying index bitmap <bitmap> without palette <palette> causes an error.
923 \begin_layout Subsubsection
924 TILEMAP:scroll: Scroll tilemap
927 \begin_layout Itemize
928 Syntax: tmap:scroll(ox, oy);
931 \begin_layout Itemize
932 Syntax: tmap:scroll(ox, oy, x, y, w, h);
935 \begin_layout Itemize
936 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
939 \begin_layout Standard
943 \begin_layout Itemize
944 tmap: TILEMAP: The tilemap to manipulate.
947 \begin_layout Itemize
948 ox: number: The number of tiles to scroll horizontally (positive is to right).
951 \begin_layout Itemize
952 oy: number: The number of tiles to scroll vertically (positive is to down).
955 \begin_layout Itemize
956 x: number: The left edge of scroll window.
959 \begin_layout Itemize
960 y: number: The top edge of scroll window.
963 \begin_layout Itemize
964 w: number: The width of scroll window.
967 \begin_layout Itemize
968 h: number: The height of scroll window.
971 \begin_layout Itemize
972 circ_x: boolean: If true, treat the window as circular in horizontal direction.
975 \begin_layout Itemize
976 circ_y: boolean: If true, treat the window as circular in vertical direction.
979 \begin_layout Standard
980 Scroll the specified tilemap <tmap> by <ox>,<oy>.
981 If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
982 <circ_x> and <circ_y> control if scroll is circular or not.
985 \begin_layout Itemize
986 Specifying out-of-range window causes an error.
989 \begin_layout Subsubsection
990 TILEMAP:draw: Draw tilemap
993 \begin_layout Itemize
994 Name: tmap:draw(x, y)
997 \begin_layout Itemize
998 Name: tmap:draw(x, y, x0, y0, w, h)
1001 \begin_layout Standard
1005 \begin_layout Itemize
1006 tmap: TILEMAP: The tilemap to draw.
1009 \begin_layout Itemize
1010 x: The x coordinate on screen to draw to.
1013 \begin_layout Itemize
1014 y: The y coordinate on screen to draw to.
1017 \begin_layout Itemize
1018 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1021 \begin_layout Itemize
1022 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1025 \begin_layout Itemize
1026 w: number: The width to draw (in pixels).
1029 \begin_layout Itemize
1030 h: number: The height to draw (in pixels).
1033 \begin_layout Standard
1034 Draw tilemap <tmap> to screen at <x>,<y>.
1035 If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1038 \begin_layout Itemize
1039 This method requires a rendering context to work.
1042 \begin_layout Subsubsection
1043 TILEMAP:draw_outside: Draw tilemap outside game area
1046 \begin_layout Itemize
1047 Name: tmap:draw_outside(x, y)
1050 \begin_layout Itemize
1051 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1054 \begin_layout Standard
1055 Like TILEMAP:draw, but draws only outside game area.
1058 \begin_layout Standard
1059 \begin_inset Newpage pagebreak
1065 \begin_layout Subsection
1066 RENDERCTX: Off-screen rendering context
1069 \begin_layout Standard
1070 Object acting as off-screen rendering context.
1073 \begin_layout Subsubsection
1074 Static function new: Create a render queue
1077 \begin_layout Itemize
1078 Syntax: renderctx gui.renderctx.new(width, height);
1081 \begin_layout Itemize
1082 Syntax: renderctx classes.RENDERCTX.new(width, height);
1085 \begin_layout Itemize
1086 Deprecated: renderctx gui.renderq_new(width, height);
1089 \begin_layout Standard
1093 \begin_layout Itemize
1094 width: number: The notional width of the game area.
1097 \begin_layout Itemize
1098 height: number: The notional height of the game area.
1101 \begin_layout Standard
1105 \begin_layout Itemize
1106 rendectx: RENDERCTX: The newly created render context.
1109 \begin_layout Standard
1110 Create a render context with reported size <width>*<height> and return it.
1113 \begin_layout Subsubsection
1114 Static function setnull: Reset to default queue
1117 \begin_layout Itemize
1118 Syntax: gui.renderctx.setnull()
1121 \begin_layout Itemize
1122 Syntax: classes.RENDERCTX:setnull()
1125 \begin_layout Itemize
1126 Deprecated: gui.renderq_set()
1129 \begin_layout Standard
1130 Reset the used render context back to default for the executing callback:
1133 \begin_layout Itemize
1134 The default for paint callback is the screen
1137 \begin_layout Itemize
1138 The default for video callback is the video frame
1141 \begin_layout Itemize
1142 The default otherwise is nothing.
1145 \begin_layout Subsubsection
1146 Method clear: Clear a render queue
1149 \begin_layout Itemize
1150 Syntax: renderctx:clear()
1153 \begin_layout Itemize
1154 Deprecated: gui.renderq_clear(renderctx)
1157 \begin_layout Standard
1161 \begin_layout Itemize
1162 renderctx: RENDERCTX: The render queue to clear.
1165 \begin_layout Standard
1166 Clear all drawing from the context.
1169 \begin_layout Subsubsection
1170 Method set: Change active render context
1173 \begin_layout Itemize
1174 Syntax: renderctx:set()
1177 \begin_layout Itemize
1178 Deprecated: gui.renderq_set(renderctx)
1181 \begin_layout Standard
1185 \begin_layout Itemize
1186 renderctx: RENDERCTX: The render queue to use.
1189 \begin_layout Standard
1190 Switch the current rendering context <renderctx>.
1193 \begin_layout Subsubsection
1194 Method run: Draw all objects in context to another
1197 \begin_layout Itemize
1198 Syntax: renderctx:run()
1201 \begin_layout Itemize
1202 Deprecated: gui.renderq_run(renderctx)
1205 \begin_layout Standard
1209 \begin_layout Itemize
1210 renderctx: RENDERCTX: The render context to overlay.
1213 \begin_layout Standard
1214 Overlay the specified render context <context> upon the active rendering
1218 \begin_layout Itemize
1219 Trying to overlay rendering context upon itself is a bad idea.
1222 \begin_layout Subsubsection
1223 Method render: Render a contex to bitmap
1226 \begin_layout Itemize
1227 Syntax: bitmap renderctx:render()
1230 \begin_layout Standard
1234 \begin_layout Itemize
1235 renderctx: RENDERCTX: The context to render.
1238 \begin_layout Standard
1242 \begin_layout Itemize
1243 bitmap: DBITMAP: The rendered bitmap.
1246 \begin_layout Standard
1247 Render the specified context <renderctx> to a new bitmap.
1250 \begin_layout Itemize
1251 The size of bitmap will be nominal game area size, plus any set gaps.
1254 \begin_layout Itemize
1255 This method does not require active rendering context.
1258 \begin_layout Subsubsection
1259 Method synchronous_repaint: Paint screen now
1262 \begin_layout Itemize
1263 Syntax: renderctx:synchronous_repaint()
1266 \begin_layout Itemize
1267 Deprecated: gui.synchronous_repaint(renderctx)
1270 \begin_layout Standard
1274 \begin_layout Itemize
1275 renderctx: RENDERCTX: The context to paint.
1278 \begin_layout Standard
1279 Immediately redraw the screen with game overlayed by drawings from context
1283 \begin_layout Itemize
1284 This does not require active rendering context.
1287 \begin_layout Itemize
1288 Will not cause paint callback to be invoked.
1291 \begin_layout Standard
1292 \begin_inset Newpage pagebreak
1298 \begin_layout Subsection
1299 PALETTE: Color palette for indexed image
1302 \begin_layout Subsubsection
1303 Static function new: Create a new palette
1306 \begin_layout Itemize
1307 Syntax: palette gui.palette.new()
1310 \begin_layout Itemize
1311 Syntax: palette classes.PALETTE.new()
1314 \begin_layout Itemize
1315 Deprecated: palette gui.palette_new()
1318 \begin_layout Standard
1322 \begin_layout Itemize
1323 palette: PALETTE: The created palette.
1326 \begin_layout Standard
1327 Create a new palette (with all colors transparent) and return it.
1330 \begin_layout Subsubsection
1331 Static function load: Load a palette
1334 \begin_layout Itemize
1335 Syntax: palette gui.palette.load(file, [base])
1338 \begin_layout Itemize
1339 Syntax: palette classes.PALETTE.load(file, [base])
1342 \begin_layout Itemize
1343 Deprecated: palette gui.palette_load(file, [base])
1346 \begin_layout Standard
1350 \begin_layout Itemize
1351 string file: The file to load.
1354 \begin_layout Itemize
1355 string base (optional): The base file to resolve file relative to.
1358 \begin_layout Standard
1362 \begin_layout Itemize
1363 palette: PALETTE: The loaded palette.
1366 \begin_layout Standard
1367 Load a palette from file <file> (resolved relative to <base>).
1370 \begin_layout Itemize
1371 The file format is a series of lines, each with following format:
1375 \begin_layout Itemize
1376 Blank or just whitespace: Ignored
1379 \begin_layout Itemize
1380 First non-whitespace is '#': Ignored
1383 \begin_layout Itemize
1384 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1387 \begin_layout Itemize
1388 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1389 (0-256, 0 being fully transparent and 256 fully opaque).
1392 \begin_layout Itemize
1393 transparent: Fully transparent color
1397 \begin_layout Subsubsection
1398 Static function load_str: Load a palette from string
1401 \begin_layout Itemize
1402 Syntax: palette gui.palette.load(data)
1405 \begin_layout Itemize
1406 Syntax: palette classes.PALETTE.load(data)
1409 \begin_layout Itemize
1410 Deprecated: palette gui.palette_load(data)
1413 \begin_layout Standard
1417 \begin_layout Itemize
1418 string data: The palette data.
1421 \begin_layout Standard
1425 \begin_layout Itemize
1426 palette: PALETTE: The loaded palette.
1429 \begin_layout Standard
1430 Like PALETTE:load, but instead of reading palette from file, reads it from
1434 \begin_layout Subsubsection
1435 Method set: Set palette entry
1438 \begin_layout Itemize
1439 Syntax: palette:set(index, color)
1442 \begin_layout Itemize
1443 Deprecated: gui.palette_set(palette, ...)
1446 \begin_layout Standard
1450 \begin_layout Itemize
1451 palette: PALETTE: The palette to manipulate
1454 \begin_layout Itemize
1455 index: number: The index of color to set (0-65535).
1458 \begin_layout Itemize
1459 color: number/string: The color value to set.
1462 \begin_layout Standard
1463 Set palette <palette> index <index> to color <color>.
1466 \begin_layout Subsubsection
1467 Method hash: Hash a palette
1470 \begin_layout Itemize
1471 Syntax: hash palette:hash()
1474 \begin_layout Itemize
1475 Deprecated: hash gui.palette_hash(palette)
1478 \begin_layout Standard
1482 \begin_layout Itemize
1483 palette: The palette to hash.
1486 \begin_layout Standard
1490 \begin_layout Itemize
1491 hash: string: 64-hex digit hash.
1494 \begin_layout Standard
1495 Obtain crypto-grade hash of palette data of <palette>.
1498 \begin_layout Itemize
1499 All colors after the last non-transparent one are ignored.
1502 \begin_layout Subsubsection
1503 Method adjust_transparency: Adjust transparency
1506 \begin_layout Itemize
1507 Syntax: palette:adjust_transparency(newvalue)
1510 \begin_layout Itemize
1511 Deprecated: gui.adjust_transparency(palette, ...)
1514 \begin_layout Standard
1518 \begin_layout Itemize
1519 palette: PALETTE: The palette to adjust.
1522 \begin_layout Itemize
1523 Number adj: The factor to multiply opaqueness with times 256.
1526 \begin_layout Standard
1527 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1530 \begin_layout Standard
1531 \begin_inset Newpage pagebreak
1537 \begin_layout Subsection
1538 BITMAP: Indexed-color bitmap
1541 \begin_layout Subsubsection
1542 Static function new: Create a new bitmap
1545 \begin_layout Itemize
1546 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1549 \begin_layout Itemize
1550 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1553 \begin_layout Itemize
1554 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1557 \begin_layout Standard
1561 \begin_layout Itemize
1562 w: number: The width of bitmap to create in pixels.
1565 \begin_layout Itemize
1566 h: number: The height of bitmap to create in pixels.
1569 \begin_layout Itemize
1570 false: boolean: Constant boolean false.
1573 \begin_layout Itemize
1574 fillcolor: number: The initial fill index.
1575 Default 0 if not specified.
1578 \begin_layout Standard
1579 Create a new bitmap of size <w>*<h>.
1580 Fill the bitmap with color index <fillcolor>.
1583 \begin_layout Subsubsection
1584 Method draw: Draw a bitmap
1587 \begin_layout Itemize
1588 Syntax: bitmap:draw(x, y, palette)
1591 \begin_layout Itemize
1592 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1595 \begin_layout Standard
1599 \begin_layout Itemize
1600 bitmap: BITMAP: The bitmap to draw
1603 \begin_layout Itemize
1604 x: number: The x-coordinate on screen.
1607 \begin_layout Itemize
1608 y: number: The y-coordinate on screen.
1611 \begin_layout Itemize
1612 palette: The palette to use for drawing.
1615 \begin_layout Standard
1616 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1619 \begin_layout Subsubsection
1620 Method draw_outside: Draw a bitmap outside game area
1623 \begin_layout Itemize
1624 Syntax: bitmap:draw_outside(x, y, palette)
1627 \begin_layout Standard
1628 Like bitmap:draw, but does not draw on game area.
1631 \begin_layout Subsubsection
1632 Method draw_clip: Draw a bitmap, with clipping
1635 \begin_layout Itemize
1636 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1639 \begin_layout Standard
1643 \begin_layout Itemize
1644 bitmap: BITMAP: The bitmap to draw
1647 \begin_layout Itemize
1648 x: number: The x-coordinate on screen.
1651 \begin_layout Itemize
1652 y: number: The y-coordinate on screen.
1655 \begin_layout Itemize
1656 palette: The palette to use for drawing.
1659 \begin_layout Itemize
1660 x0: The smallest bitmap x coordinate to draw.
1663 \begin_layout Itemize
1664 y0: The smallest bitmap y coordinate to draw.
1667 \begin_layout Itemize
1668 width: Width of region to draw
1671 \begin_layout Itemize
1672 height: Height of region to draw.
1675 \begin_layout Standard
1676 Like bitmap:draw, but clip the bitmap area drawn.
1679 \begin_layout Subsubsection
1680 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1683 \begin_layout Itemize
1684 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1687 \begin_layout Standard
1688 Like bitmap:draw_clip, but only draw outside game area.
1691 \begin_layout Subsubsection
1692 Method pset: Set pixel in bitmap
1695 \begin_layout Itemize
1696 Syntax: bitmap:pset(x, y, color)
1699 \begin_layout Itemize
1700 Deprecaed: gui.bitmap_pset(bitmap, ...)
1703 \begin_layout Standard
1707 \begin_layout Itemize
1708 bitmap: BITMAP: The bitmap to manipulate.
1711 \begin_layout Itemize
1712 x: number: x-coordinate of pixel to set.
1715 \begin_layout Itemize
1716 y: number: y-coordinate of pixel to set.
1719 \begin_layout Itemize
1720 color: number: The color index to set.
1723 \begin_layout Standard
1724 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1727 \begin_layout Subsubsection
1728 Method pget: Get pixel in bitmap
1731 \begin_layout Itemize
1732 Syntax: color bitmap:pget(x,y)
1735 \begin_layout Itemize
1736 Deprecated: color gui.bitmap_pget(bitmap, ...)
1739 \begin_layout Standard
1743 \begin_layout Itemize
1744 bitmap: BITMAP: The bitmap to query.
1747 \begin_layout Itemize
1748 x: number: x-coordinate of pixel to get.
1751 \begin_layout Itemize
1752 y: number: y-coordinate of pixel to get.
1755 \begin_layout Standard
1759 \begin_layout Itemize
1760 color: number: The color index in specified pixel.
1763 \begin_layout Standard
1764 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1767 \begin_layout Subsubsection
1768 Method size: Get size of bitmap
1771 \begin_layout Itemize
1772 Syntax: width, height bitmap:size()
1775 \begin_layout Itemize
1776 Syntax: width, height gui.bitmap_size(bitmap)
1779 \begin_layout Standard
1783 \begin_layout Itemize
1784 bitmap: BITMAP: The bitmap to query.
1787 \begin_layout Standard
1791 \begin_layout Itemize
1792 width: number: The width of the bitmap.
1795 \begin_layout Itemize
1796 height: number: The height of the bitmap.
1799 \begin_layout Standard
1800 Get size of bitmap <bitmap>.
1803 \begin_layout Subsubsection
1804 Method blit: Blit a bitmap into another
1807 \begin_layout Itemize
1808 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1811 \begin_layout Itemize
1812 Deprecated: gui.bitmap_blit(dest, ...)
1815 \begin_layout Standard
1819 \begin_layout Itemize
1820 dest: BITMAP: The target bitmap to blit to.
1823 \begin_layout Itemize
1824 dx: number: The x-coordinate in target.
1827 \begin_layout Itemize
1828 dy: number: The y-coordinate in target.
1831 \begin_layout Itemize
1832 src: BITMAP: The source bitmap.
1835 \begin_layout Itemize
1836 sx: number: The x-coordinate in source.
1839 \begin_layout Itemize
1840 sy: number: The y-coordinate in source.
1843 \begin_layout Itemize
1844 w: number: The width of area to blit.
1847 \begin_layout Itemize
1848 h: number: The height of area to blit.
1851 \begin_layout Itemize
1852 ck: number: The color key.
1853 Pixels with this index are not copied.
1857 \begin_layout Itemize
1858 If none is specified, all pixels are copied.
1862 \begin_layout Standard
1863 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1865 If a color key <ck> is specified, pixels of that color are not copied.
1868 \begin_layout Subsubsection
1869 Method blit_scaled: Blit a bitmap into another with scaling
1872 \begin_layout Itemize
1873 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1876 \begin_layout Itemize
1877 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1880 \begin_layout Standard
1884 \begin_layout Itemize
1885 dest: BITMAP: The target bitmap to blit to.
1888 \begin_layout Itemize
1889 dx: number: The x-coordinate in target.
1892 \begin_layout Itemize
1893 dy: number: The y-coordinate in target.
1896 \begin_layout Itemize
1897 src: BITMAP: The source bitmap.
1900 \begin_layout Itemize
1901 sx: number: The x-coordinate in source.
1904 \begin_layout Itemize
1905 sy: number: The y-coordinate in source.
1908 \begin_layout Itemize
1909 w: number: The width of area to blit.
1912 \begin_layout Itemize
1913 h: number: The height of area to blit.
1916 \begin_layout Itemize
1917 hscl: number: Horizontal scale factor (integer).
1920 \begin_layout Itemize
1921 vscl: number: Vertical scale factor (integer).
1922 Defaults to the same as <hscl>.
1925 \begin_layout Itemize
1926 ck: number: The color key.
1927 Pixels with this index are not copied.
1931 \begin_layout Itemize
1932 If none is specified, all pixels are copied.
1936 \begin_layout Standard
1937 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1938 neighbor) by factor of <hscl>*<vscl>.
1941 \begin_layout Subsubsection
1942 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1945 \begin_layout Itemize
1946 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1949 \begin_layout Itemize
1950 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1953 \begin_layout Standard
1957 \begin_layout Itemize
1958 dest: BITMAP: The target bitmap to blit to.
1961 \begin_layout Itemize
1962 dx: number: The x-coordinate in target.
1965 \begin_layout Itemize
1966 dy: number: The y-coordinate in target.
1969 \begin_layout Itemize
1970 src: BITMAP: The source bitmap.
1973 \begin_layout Itemize
1974 sx: number: The x-coordinate in source.
1977 \begin_layout Itemize
1978 sy: number: The y-coordinate in source.
1981 \begin_layout Itemize
1982 w: number: The width of area to blit.
1985 \begin_layout Itemize
1986 h: number: The height of area to blit.
1989 \begin_layout Itemize
1990 operator: string: The operator to use.
1994 \begin_layout Itemize
1995 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
1996 DestOut, Clear or Xor.
2000 \begin_layout Standard
2001 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2006 \begin_layout Itemize
2007 Color index 0 in source and target is treated as background.
2010 \begin_layout Subsubsection
2011 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2012 Porter-Duff composition
2015 \begin_layout Itemize
2016 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2020 \begin_layout Itemize
2021 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2024 \begin_layout Standard
2028 \begin_layout Itemize
2029 dest: BITMAP: The target bitmap to blit to.
2032 \begin_layout Itemize
2033 dx: number: The x-coordinate in target.
2036 \begin_layout Itemize
2037 dy: number: The y-coordinate in target.
2040 \begin_layout Itemize
2041 src: BITMAP: The source bitmap.
2044 \begin_layout Itemize
2045 sx: number: The x-coordinate in source.
2048 \begin_layout Itemize
2049 sy: number: The y-coordinate in source.
2052 \begin_layout Itemize
2053 w: number: The width of area to blit.
2056 \begin_layout Itemize
2057 h: number: The height of area to blit.
2060 \begin_layout Itemize
2061 hscl: number: Horizontal scale factor (integer).
2064 \begin_layout Itemize
2065 vscl: number: Vertical scale factor (integer).
2066 Defaults to the same as <hscl>.
2069 \begin_layout Itemize
2070 operator: string: The operator to use.
2074 \begin_layout Itemize
2075 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2076 DestOut, Clear or Xor.
2080 \begin_layout Standard
2081 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2082 like BITMAP:blit_scaled.
2085 \begin_layout Subsubsection
2086 Method blit_priority: Blit a bitmap into another with color priority
2089 \begin_layout Itemize
2090 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2093 \begin_layout Itemize
2094 Deprecated: gui.bitmap_blit_priority(dest, ...)
2097 \begin_layout Standard
2101 \begin_layout Itemize
2102 dest: BITMAP: The target bitmap to blit to.
2105 \begin_layout Itemize
2106 dx: number: The x-coordinate in target.
2109 \begin_layout Itemize
2110 dy: number: The y-coordinate in target.
2113 \begin_layout Itemize
2114 src: BITMAP: The source bitmap.
2117 \begin_layout Itemize
2118 sx: number: The x-coordinate in source.
2121 \begin_layout Itemize
2122 sy: number: The y-coordinate in source.
2125 \begin_layout Itemize
2126 w: number: The width of area to blit.
2129 \begin_layout Itemize
2130 h: number: The height of area to blit.
2133 \begin_layout Standard
2134 Like BITMAP:blit, but only copy pixels where source color index is greater
2135 than destination color index.
2138 \begin_layout Subsubsection
2139 Method blit_scaled_priority: Blit a bitmap into another with color priority
2143 \begin_layout Itemize
2144 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2147 \begin_layout Itemize
2148 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2151 \begin_layout Standard
2155 \begin_layout Itemize
2156 dest: BITMAP: The target bitmap to blit to.
2159 \begin_layout Itemize
2160 dx: number: The x-coordinate in target.
2163 \begin_layout Itemize
2164 dy: number: The y-coordinate in target.
2167 \begin_layout Itemize
2168 src: BITMAP: The source bitmap.
2171 \begin_layout Itemize
2172 sx: number: The x-coordinate in source.
2175 \begin_layout Itemize
2176 sy: number: The y-coordinate in source.
2179 \begin_layout Itemize
2180 w: number: The width of area to blit.
2183 \begin_layout Itemize
2184 h: number: The height of area to blit.
2187 \begin_layout Itemize
2188 hscl: number: Horizontal scale factor (integer).
2191 \begin_layout Itemize
2192 vscl: number: Vertical scale factor (integer).
2193 Defaults to the same as <hscl>.
2196 \begin_layout Standard
2197 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2201 \begin_layout Subsubsection
2202 Method save_png: Save a bitmap to PNG
2205 \begin_layout Itemize
2206 Syntax: bitmap:save_png(filename, [base], palette)
2209 \begin_layout Itemize
2210 Syntax: data bitmap:save_png(palette)
2213 \begin_layout Itemize
2215 gui.bitmap_save_png(bitmap, ...)
2218 \begin_layout Standard
2222 \begin_layout Itemize
2223 bitmap: BITMAP: The bitmap to save.
2226 \begin_layout Itemize
2227 filename: string: The filename to save to.
2230 \begin_layout Itemize
2231 base: string: The base filename is resolved relative to.
2234 \begin_layout Itemize
2235 palette: PALETTE: The palette to use.
2238 \begin_layout Standard
2242 \begin_layout Itemize
2243 data: string: BASE64 encoded PNG data.
2246 \begin_layout Standard
2247 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2248 to <base>) or return BASE64 encoding of it.
2251 \begin_layout Subsubsection
2252 Method hash: Hash a bitmap
2255 \begin_layout Itemize
2256 Syntax: hash bitmap:hash()
2259 \begin_layout Itemize
2260 Deprecated: hash bitmap:hash(bitmap)
2263 \begin_layout Standard
2267 \begin_layout Itemize
2268 bitmap: BITMAP: The bitmap to hash.
2271 \begin_layout Standard
2275 \begin_layout Itemize
2276 hash: string: 64-hex digit hash
2279 \begin_layout Standard
2280 Hashes bitmap <bitmap> and returns crypto-strong hash.
2284 \begin_layout Itemize
2285 Color order in bitmap is significant.
2288 \begin_layout Standard
2289 \begin_inset Newpage pagebreak
2295 \begin_layout Subsection
2296 DBITMAP: Direct-color bitmap
2299 \begin_layout Subsubsection
2300 Static function: new: Create a new bitmap
2303 \begin_layout Itemize
2304 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2307 \begin_layout Itemize
2308 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2311 \begin_layout Itemize
2312 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2315 \begin_layout Standard
2319 \begin_layout Itemize
2320 w: number: The width of new bitmap.
2323 \begin_layout Itemize
2324 h: number: The height of new bitmap.
2327 \begin_layout Itemize
2328 true: boolean: Fixed boolean true
2331 \begin_layout Itemize
2332 fillcolor: The color to fill the bitmap with (default transparent).
2335 \begin_layout Standard
2339 \begin_layout Itemize
2340 bitmap: DBITMAP: The new bitmap.
2343 \begin_layout Standard
2344 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2348 \begin_layout Subsubsection
2349 Method draw: Draw a bitmap
2352 \begin_layout Itemize
2353 Syntax: bitmap.draw(x, y)
2356 \begin_layout Itemize
2357 Deprecated: gui.bitmap_draw(x, y, bitmap)
2360 \begin_layout Standard
2364 \begin_layout Itemize
2365 bitmap: DBITMAP: The bitmap to draw.
2368 \begin_layout Itemize
2369 x: number: X-coordinate on screen.
2372 \begin_layout Itemize
2373 y: number: Y-coordinate on screen.
2376 \begin_layout Standard
2377 Draw bitmap <bitmap> on screen at <x>,<y>.
2380 \begin_layout Subsubsection
2381 Method draw_outside: Draw a bitmap outside game area
2384 \begin_layout Itemize
2385 Syntax: dbitmap:draw_outside(x, y, palette)
2388 \begin_layout Standard
2389 Like dbitmap:draw, but does not draw on game area.
2392 \begin_layout Subsubsection
2393 Method draw_clip: Draw a bitmap, with clipping
2396 \begin_layout Itemize
2397 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2400 \begin_layout Standard
2404 \begin_layout Itemize
2405 bitmap: DBITMAP: The bitmap to draw
2408 \begin_layout Itemize
2409 x: number: The x-coordinate on screen.
2412 \begin_layout Itemize
2413 y: number: The y-coordinate on screen.
2416 \begin_layout Itemize
2417 x0: The smallest bitmap x coordinate to draw.
2420 \begin_layout Itemize
2421 y0: The smallest bitmap y coordinate to draw.
2424 \begin_layout Itemize
2425 width: Width of region to draw
2428 \begin_layout Itemize
2429 height: Height of region to draw.
2432 \begin_layout Standard
2433 Like dbitmap:draw, but clip the bitmap area drawn.
2436 \begin_layout Subsubsection
2437 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2440 \begin_layout Itemize
2441 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2444 \begin_layout Standard
2445 Like dbitmap:draw_clip, but only draw outside game area.
2448 \begin_layout Subsubsection
2449 Method pset: Set pixel in bitmap
2452 \begin_layout Itemize
2453 Syntax: bitmap:pset(x, y, color)
2456 \begin_layout Itemize
2457 Deprecaed: gui.bitmap_pset(bitmap, ...)
2460 \begin_layout Standard
2464 \begin_layout Itemize
2465 bitmap: DBITMAP: The bitmap to manipulate.
2468 \begin_layout Itemize
2469 x: number: x-coordinate of pixel to set.
2472 \begin_layout Itemize
2473 y: number: y-coordinate of pixel to set.
2476 \begin_layout Itemize
2477 color: number/string: The color to set.
2480 \begin_layout Standard
2481 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2484 \begin_layout Subsubsection
2485 Method pget: Get pixel in bitmap
2488 \begin_layout Itemize
2489 Syntax: color bitmap:pget(x,y)
2492 \begin_layout Itemize
2493 Deprecated: color gui.bitmap_pget(bitmap, ...)
2496 \begin_layout Standard
2500 \begin_layout Itemize
2501 bitmap: DBITMAP: The bitmap to query.
2504 \begin_layout Itemize
2505 x: number: x-coordinate of pixel to get.
2508 \begin_layout Itemize
2509 y: number: y-coordinate of pixel to get.
2512 \begin_layout Standard
2516 \begin_layout Itemize
2517 color: number: The color of specified pixel.
2520 \begin_layout Standard
2521 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2524 \begin_layout Subsubsection
2525 Method size: Get size of bitmap
2528 \begin_layout Itemize
2529 Syntax: width, height bitmap:size()
2532 \begin_layout Itemize
2533 Syntax: width, height gui.bitmap_size(bitmap)
2536 \begin_layout Standard
2540 \begin_layout Itemize
2541 bitmap: DBITMAP: The bitmap to query.
2544 \begin_layout Standard
2548 \begin_layout Itemize
2549 width: number: The width of the bitmap.
2552 \begin_layout Itemize
2553 height: number: The height of the bitmap.
2556 \begin_layout Standard
2557 Get size of bitmap <bitmap>.
2560 \begin_layout Subsubsection
2561 Method blit: Blit a bitmap into another
2564 \begin_layout Itemize
2565 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2568 \begin_layout Itemize
2569 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2572 \begin_layout Itemize
2573 Deprecated: gui.bitmap_blit(dest, ...)
2576 \begin_layout Standard
2580 \begin_layout Itemize
2581 dest: DBITMAP: The target bitmap to blit to.
2584 \begin_layout Itemize
2585 dx: number: The x-coordinate in target.
2588 \begin_layout Itemize
2589 dy: number: The y-coordinate in target.
2592 \begin_layout Itemize
2593 src: BITMAP/DBITMAP: The source bitmap.
2596 \begin_layout Itemize
2597 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2600 \begin_layout Itemize
2601 sx: number: The x-coordinate in source.
2604 \begin_layout Itemize
2605 sy: number: The y-coordinate in source.
2608 \begin_layout Itemize
2609 w: number: The width of area to blit.
2612 \begin_layout Itemize
2613 h: number: The height of area to blit.
2616 \begin_layout Itemize
2617 ck: number: The color key.
2618 Pixels with this index are not copied.
2622 \begin_layout Itemize
2623 If none is specified, all pixels are copied.
2626 \begin_layout Itemize
2627 If <src> is paletted, this is color index, otherwise it is a color.
2631 \begin_layout Standard
2632 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2633 if indexed) into <dest> at <dx>,<dy>.
2634 If a color key <ck> is specified, pixels of that color are not copied.
2637 \begin_layout Subsubsection
2638 Method blit_scaled: Blit a bitmap into another with scaling
2641 \begin_layout Itemize
2642 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2645 \begin_layout Itemize
2646 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2650 \begin_layout Itemize
2651 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2654 \begin_layout Standard
2658 \begin_layout Itemize
2659 dest: DBITMAP: The target bitmap to blit to.
2662 \begin_layout Itemize
2663 dx: number: The x-coordinate in target.
2666 \begin_layout Itemize
2667 dy: number: The y-coordinate in target.
2670 \begin_layout Itemize
2671 src: BITMAP/DBITMAP: The source bitmap.
2674 \begin_layout Itemize
2675 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2678 \begin_layout Itemize
2679 sx: number: The x-coordinate in source.
2682 \begin_layout Itemize
2683 sy: number: The y-coordinate in source.
2686 \begin_layout Itemize
2687 w: number: The width of area to blit.
2690 \begin_layout Itemize
2691 h: number: The height of area to blit.
2694 \begin_layout Itemize
2695 hscl: number: Horizontal scale factor (integer).
2698 \begin_layout Itemize
2699 vscl: number: Vertical scale factor (integer).
2700 Defaults to the same as <hscl>.
2703 \begin_layout Itemize
2704 ck: number: The color key.
2705 Pixels with this index are not copied.
2709 \begin_layout Itemize
2710 If none is specified, all pixels are copied.
2713 \begin_layout Itemize
2714 If <src> is paletted, this is color index, otherwise it is a color.
2718 \begin_layout Standard
2719 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2720 neighbor) by factor of <hscl>*<vscl>.
2723 \begin_layout Subsubsection
2724 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2727 \begin_layout Itemize
2728 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2731 \begin_layout Itemize
2732 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2735 \begin_layout Itemize
2736 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2739 \begin_layout Standard
2743 \begin_layout Itemize
2744 dest: DBITMAP: The target bitmap to blit to.
2747 \begin_layout Itemize
2748 dx: number: The x-coordinate in target.
2751 \begin_layout Itemize
2752 dy: number: The y-coordinate in target.
2755 \begin_layout Itemize
2756 src: BITMAP/DBITMAP: The source bitmap.
2759 \begin_layout Itemize
2760 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2763 \begin_layout Itemize
2764 sx: number: The x-coordinate in source.
2767 \begin_layout Itemize
2768 sy: number: The y-coordinate in source.
2771 \begin_layout Itemize
2772 w: number: The width of area to blit.
2775 \begin_layout Itemize
2776 h: number: The height of area to blit.
2779 \begin_layout Itemize
2780 operator: string: The operator to use.
2784 \begin_layout Itemize
2785 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2786 DestOut, Clear or Xor.
2790 \begin_layout Standard
2791 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2796 \begin_layout Itemize
2797 In target, fully transparent is background.
2798 In source, either fully transparent (if direct) or index 0 (if paletted)
2799 is treated as background.
2802 \begin_layout Subsubsection
2803 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2804 Porter-Duff composition
2807 \begin_layout Itemize
2808 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2812 \begin_layout Itemize
2813 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2817 \begin_layout Itemize
2818 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2821 \begin_layout Standard
2825 \begin_layout Itemize
2826 dest: DBITMAP: The target bitmap to blit to.
2829 \begin_layout Itemize
2830 dx: number: The x-coordinate in target.
2833 \begin_layout Itemize
2834 dy: number: The y-coordinate in target.
2837 \begin_layout Itemize
2838 src: BITMAP/DBITMAP: The source bitmap.
2841 \begin_layout Itemize
2842 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2845 \begin_layout Itemize
2846 sx: number: The x-coordinate in source.
2849 \begin_layout Itemize
2850 sy: number: The y-coordinate in source.
2853 \begin_layout Itemize
2854 w: number: The width of area to blit.
2857 \begin_layout Itemize
2858 h: number: The height of area to blit.
2861 \begin_layout Itemize
2862 hscl: number: Horizontal scale factor (integer).
2865 \begin_layout Itemize
2866 vscl: number: Vertical scale factor (integer).
2867 Defaults to the same as <hscl>.
2870 \begin_layout Itemize
2871 operator: string: The operator to use.
2875 \begin_layout Itemize
2876 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2877 DestOut, Clear or Xor.
2881 \begin_layout Standard
2882 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2883 like DBITMAP:blit_scaled.
2886 \begin_layout Subsubsection
2887 Method adjust_transparency: Adjust transparency of bitmap
2890 \begin_layout Itemize
2891 Syntax: bitmap:adjust_transparency(newvalue)
2894 \begin_layout Itemize
2895 Deprecated: gui.adjust_transparency(bitmap, ...)
2898 \begin_layout Standard
2902 \begin_layout Itemize
2903 bitmap: DBITMAP: The bitmap to adjust.
2906 \begin_layout Itemize
2907 Number adj: The factor to multiply opaqueness with times 256.
2910 \begin_layout Standard
2911 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2914 \begin_layout Subsubsection
2915 Method save_png: Save a bitmap to PNG
2918 \begin_layout Itemize
2919 Syntax: bitmap:save_png(filename, [base])
2922 \begin_layout Itemize
2923 Syntax: data bitmap:save_png()
2926 \begin_layout Itemize
2928 gui.bitmap_save_png(bitmap, ...)
2931 \begin_layout Standard
2935 \begin_layout Itemize
2936 bitmap: DBITMAP: The bitmap to save.
2939 \begin_layout Itemize
2940 filename: string: The filename to save to.
2943 \begin_layout Itemize
2944 base: string: The base filename is resolved relative to.
2947 \begin_layout Standard
2951 \begin_layout Itemize
2952 data: string: BASE64 encoded PNG data.
2955 \begin_layout Standard
2956 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2957 BASE64 encoding of it.
2960 \begin_layout Subsubsection
2961 Method hash: Hash a bitmap
2964 \begin_layout Itemize
2965 Syntax: hash bitmap:hash()
2968 \begin_layout Itemize
2969 Deprecated: hash bitmap:hash(bitmap)
2972 \begin_layout Standard
2976 \begin_layout Itemize
2977 bitmap: DBITMAP: The bitmap to hash.
2980 \begin_layout Standard
2984 \begin_layout Itemize
2985 hash: string: 64-hex digit hash
2988 \begin_layout Standard
2989 Hashes bitmap <bitmap> and returns crypto-strong hash.
2993 \begin_layout Subsection
2994 IMAGELOADER: Load an image
2997 \begin_layout Subsubsection
2998 Static function load: Load a bitmap from file
3001 \begin_layout Itemize
3002 Syntax: bitmap, palette gui.image.load(file, [base])
3005 \begin_layout Itemize
3006 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3009 \begin_layout Itemize
3011 gui.bitmap_load(...)
3014 \begin_layout Standard
3018 \begin_layout Itemize
3019 file: string: The file to read.
3022 \begin_layout Itemize
3023 base: string: The base to resolve <file> relative to.
3026 \begin_layout Standard
3030 \begin_layout Itemize
3031 bitmap: BITMAP/DBITMAP: The new bitmap
3034 \begin_layout Itemize
3035 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3039 \begin_layout Standard
3040 Load a new bitmap and return it (plus associated palette if any).
3043 \begin_layout Subsubsection
3044 Static function load_str: Load a bitmap from string
3047 \begin_layout Itemize
3048 Syntax: bitmap, palette gui.image.load_str(data)
3051 \begin_layout Itemize
3052 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3055 \begin_layout Itemize
3057 gui.bitmap_load_str(...)
3060 \begin_layout Standard
3064 \begin_layout Itemize
3065 data: string: The image data
3068 \begin_layout Standard
3072 \begin_layout Itemize
3073 bitmap: BITMAP/DBITMAP: The new bitmap
3076 \begin_layout Itemize
3077 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3081 \begin_layout Standard
3082 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3086 \begin_layout Subsubsection
3087 Static function load_png: Load a bitmap from PNG file
3090 \begin_layout Itemize
3091 Syntax: bitmap, palette gui.image.load_png(file, [base])
3094 \begin_layout Itemize
3095 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3098 \begin_layout Itemize
3100 gui.bitmap_load_png(...)
3103 \begin_layout Standard
3107 \begin_layout Itemize
3108 file: string: The file to read.
3111 \begin_layout Itemize
3112 base: string: The base to resolve <file> relative to.
3115 \begin_layout Standard
3119 \begin_layout Itemize
3120 bitmap: BITMAP/DBITMAP: The new bitmap
3123 \begin_layout Itemize
3124 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3128 \begin_layout Standard
3129 Like IMAGELOADER:load, but load a PNG file instead.
3132 \begin_layout Subsubsection
3133 Static function load_png_str: Load a PNG bitmap from string
3136 \begin_layout Itemize
3137 Syntax: bitmap, palette gui.image.load_png_str(data)
3140 \begin_layout Itemize
3141 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3144 \begin_layout Itemize
3146 gui.bitmap_load_png_str(...)
3149 \begin_layout Standard
3153 \begin_layout Itemize
3154 data: string: The image data, base64 encoded.
3157 \begin_layout Standard
3161 \begin_layout Itemize
3162 bitmap: BITMAP/DBITMAP: The new bitmap
3165 \begin_layout Itemize
3166 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3170 \begin_layout Standard
3171 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3172 <data> instead of file.
3175 \begin_layout Standard
3176 \begin_inset Newpage pagebreak
3182 \begin_layout Subsection
3183 CUSTOMFONT: Arbitrary-sized bitmap font
3186 \begin_layout Subsubsection
3187 Static function new: Return a new empty font
3190 \begin_layout Itemize
3191 Syntax: font gui.font.new()
3194 \begin_layout Itemize
3195 Syntax: font classes.CUSTOMFONT.new()
3198 \begin_layout Itemize
3199 Deprecated: font gui.font_new()
3202 \begin_layout Standard
3206 \begin_layout Itemize
3207 font: CUSTOMFONT: New font.
3210 \begin_layout Standard
3211 Create a new font with no characters and return it.
3214 \begin_layout Subsubsection
3215 Static function: load: Load a font file
3218 \begin_layout Itemize
3219 Syntax: font gui.font.load(file, [base])
3222 \begin_layout Itemize
3223 Syntax: font gui.font.load()
3226 \begin_layout Itemize
3227 Syntax: font classes.CUSTOMFONT.load(file, [base])
3230 \begin_layout Itemize
3231 Syntax: font classes.CUSTOMFONT.load()
3234 \begin_layout Itemize
3235 Deprecated: font gui.loadfont(...)
3238 \begin_layout Standard
3242 \begin_layout Itemize
3243 file: string: The file to read the font from
3246 \begin_layout Itemize
3247 base: string: The file to resolve <file> relative to.
3250 \begin_layout Standard
3254 \begin_layout Itemize
3255 font: CUSTOMFONT: New font.
3258 \begin_layout Standard
3259 Load font from file <file> (relative to <base>).
3260 If no filename is given, system default font is loaded.
3263 \begin_layout Subsubsection
3264 operator(): Render text to screen
3267 \begin_layout Itemize
3268 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3271 \begin_layout Standard
3275 \begin_layout Itemize
3276 font: CUSTOMFONT: The font to use.
3279 \begin_layout Itemize
3280 x: number: The x-position on screen to draw to.
3283 \begin_layout Itemize
3284 y: number: The y-position on screen to draw to.
3287 \begin_layout Itemize
3288 text: string: The text to draw.
3291 \begin_layout Itemize
3292 fgc: number/string: Foreground color (default white).
3295 \begin_layout Itemize
3296 bgc: number/string: Background color (default transparent).
3299 \begin_layout Itemize
3300 hlc: number/string: Outline color (default transparent).
3303 \begin_layout Standard
3304 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3308 \begin_layout Itemize
3309 If <hlc> is transparent, no outline is drawn.
3312 \begin_layout Subsubsection
3313 Method edit: Alter glyph in font
3316 \begin_layout Itemize
3317 Syntax: font:edit(character, glyph)
3320 \begin_layout Standard
3324 \begin_layout Itemize
3325 font: CUSTOMFONT: The font to edit.
3328 \begin_layout Itemize
3329 character: string: The character to edit (UTF-8 encoded).
3332 \begin_layout Itemize
3333 glyph: BITMAP: The bitmap to use.
3336 \begin_layout Standard
3337 Replace character <character> in font <font> by <glyph>.
3340 \begin_layout Itemize
3341 Color index 0 is background, everything else is foreground.
3344 \begin_layout Itemize
3345 <character> may be empty string, meaning the replacement character used
3349 \begin_layout Itemize
3350 <character> may be multi-codepoint string, meaning character used for that
3354 \begin_layout Standard
3355 \begin_inset Newpage pagebreak
3361 \begin_layout Subsection
3362 ICONV: Character set conversions
3365 \begin_layout Subsubsection
3366 Static function new: Create new character set converter
3369 \begin_layout Itemize
3370 Syntax: iconv iconv.new(from, to);
3373 \begin_layout Itemize
3374 Syntax: iconv classes.ICONV.new(from, to);
3377 \begin_layout Itemize
3378 Deprecated: iconv iconv_new(...);
3381 \begin_layout Standard
3385 \begin_layout Itemize
3386 from: string: The source character set.
3389 \begin_layout Itemize
3390 to: string: The target character set.
3393 \begin_layout Standard
3397 \begin_layout Itemize
3398 iconv: ICONV: The converter.
3401 \begin_layout Standard
3402 Create a character set converter, converting from <from> to <to> and return
3406 \begin_layout Subsubsection
3407 Operator(): Convert string fragment from character set to another
3410 \begin_layout Itemize
3411 Syntax: success, result, unconverted, error iconv(input)
3414 \begin_layout Standard
3418 \begin_layout Itemize
3419 iconv: ICONV: The context to use.
3422 \begin_layout Itemize
3423 input: string: The input to convert.
3426 \begin_layout Standard
3430 \begin_layout Itemize
3431 success: boolean: True if conversion was successful, false if not.
3434 \begin_layout Itemize
3435 result: string: The string (partially) converted.
3438 \begin_layout Itemize
3439 unconvered: number: Number of bytes that were not converted (only if <success>
3443 \begin_layout Itemize
3444 error: string: Error that caused conversion to stop (only if <success> is
3449 \begin_layout Itemize
3450 INVALID: The input string is invalid.
3453 \begin_layout Itemize
3454 INCOMPLETE: The input string cuts off in middle of character.
3457 \begin_layout Itemize
3458 INTERNALERR: Internal error.
3462 \begin_layout Standard
3463 Convert a string <input> using character set converter <iconv> and return
3467 \begin_layout Standard
3468 \begin_inset Newpage pagebreak
3474 \begin_layout Subsection
3475 FILEREADER: Read a file as a stream
3478 \begin_layout Subsubsection
3479 Static function open: Open a stream
3482 \begin_layout Itemize
3483 Syntax: handle filereader.open(file, [base])
3486 \begin_layout Itemize
3487 Syntax: handle classes.FILEREADER.open(file, [base])
3490 \begin_layout Itemize
3491 Deprecated: handle open_file(file, [base])
3494 \begin_layout Standard
3498 \begin_layout Itemize
3499 file: string: The filename to read.
3502 \begin_layout Itemize
3503 base: string: The base <file> is resolved against.
3506 \begin_layout Standard
3510 \begin_layout Itemize
3511 handle: FILEREADER: The new file reader.
3514 \begin_layout Standard
3515 Open file <file> (relative to <base>) and return a handle to it.
3518 \begin_layout Subsubsection
3519 operator(): Read line/bytes from stream
3522 \begin_layout Itemize
3523 Syntax: result handle()
3526 \begin_layout Itemize
3527 Syntax: result handle(bytes)
3530 \begin_layout Standard
3534 \begin_layout Itemize
3535 handle: FILEREADER: The handle to read from.
3538 \begin_layout Itemize
3539 bytes: Number of bytes to read (default is next line).
3542 \begin_layout Standard
3546 \begin_layout Itemize
3547 result: string: The read data, or nil on end-of-file.
3550 \begin_layout Standard
3551 Reads next line or <bytes> bytes from specified file handle <handle>.
3554 \begin_layout Itemize
3555 If reading specified number of bytes, the bytes are read in binary mode
3559 \begin_layout Itemize
3560 If reading next line, the line is read in text mode (any line ending is
3564 \begin_layout Subsubsection
3565 Method lines: Iterator to read all lines
3568 \begin_layout Itemize
3569 Syntax: for line in handle:lines() do ...
3573 \begin_layout Standard
3577 \begin_layout Itemize
3578 handle: FILEREADER: The handle to read.
3581 \begin_layout Standard
3585 \begin_layout Itemize
3586 A lua iterator with one variable.
3589 \begin_layout Standard
3590 Return a Lua iterator that iterates all the lines in <handle>.
3593 \begin_layout Standard
3594 \begin_inset Newpage pagebreak
3600 \begin_layout Subsection
3601 COMPARE_OBJ: Watch memory area for changes
3604 \begin_layout Standard
3605 Objects of this class allow fast checking for modifications to given memory
3609 \begin_layout Subsubsection
3610 Static function new: Create a checker
3613 \begin_layout Itemize
3614 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3618 \begin_layout Itemize
3619 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3622 \begin_layout Standard
3626 \begin_layout Itemize
3627 marea: string: The memory area to interpret <offset> against.
3630 \begin_layout Itemize
3631 offset: number: The initial offset in memory area.
3634 \begin_layout Itemize
3635 addrobj: ADDRESS: The memory address.
3638 \begin_layout Itemize
3639 size: number: The number of bytes in each row.
3642 \begin_layout Itemize
3643 rows: number: The number of rows.
3647 \begin_layout Itemize
3648 stride: number: The number of bytes offset increments from one row to next.
3651 \begin_layout Standard
3655 \begin_layout Itemize
3659 \begin_layout Standard
3660 Return an object watching specified memory area.
3663 \begin_layout Itemize
3664 Note: For fastest operation, limit checks to inside one memory area (that
3665 has to be mappable, individual RAM areas often are).
3668 \begin_layout Subsubsection
3669 operator(): Check area for modifications
3672 \begin_layout Itemize
3673 Syntax: boolean handle()
3676 \begin_layout Standard
3680 \begin_layout Itemize
3681 True if memory block has been modified since last call (or object creation
3682 if first call), false if not.
3685 \begin_layout Standard
3686 Check if the block has been modified.
3689 \begin_layout Subsection
3690 ADDRESS: Memory address
3693 \begin_layout Standard
3694 Objects of this class contain a memory address.
3697 \begin_layout Subsubsection
3698 Static function new: Create new memory address
3701 \begin_layout Itemize
3702 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
3705 \begin_layout Itemize
3706 Syntax: ADDRESS memory.address.new(string marea, number offset)
3709 \begin_layout Itemize
3710 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
3713 \begin_layout Standard
3717 \begin_layout Itemize
3718 marea: The memory area
3721 \begin_layout Itemize
3722 offset: The offset in memory area.
3725 \begin_layout Standard
3729 \begin_layout Itemize
3733 \begin_layout Standard
3734 Construct a new memory address object.
3737 \begin_layout Subsubsection
3738 Method: addr: Get global address
3741 \begin_layout Itemize
3742 Syntax: number addr:addr()
3745 \begin_layout Standard
3749 \begin_layout Itemize
3750 addr: ADRESS: The original address.
3753 \begin_layout Standard
3757 \begin_layout Itemize
3758 The global address corresponding to this address.
3761 \begin_layout Subsubsection
3762 Method: vma: Get memory area
3765 \begin_layout Itemize
3766 Syntax: string addr:vma()
3769 \begin_layout Standard
3773 \begin_layout Itemize
3774 addr: ADRESS: The original address.
3777 \begin_layout Standard
3781 \begin_layout Itemize
3782 The memory area corresponding to this address.
3785 \begin_layout Subsubsection
3786 Method: offset: Get memory area offset
3789 \begin_layout Itemize
3790 Syntax: string addr:offset()
3793 \begin_layout Standard
3797 \begin_layout Itemize
3798 addr: ADRESS: The original address.
3801 \begin_layout Standard
3805 \begin_layout Itemize
3806 The offset in memory area corresponding to this address.
3809 \begin_layout Subsubsection
3810 Method: replace: Replace address part
3813 \begin_layout Itemize
3814 Syntax: ADDRESS addr:replace(offset[, bits])
3817 \begin_layout Standard
3821 \begin_layout Itemize
3822 addr: ADRESS: The original address.
3825 \begin_layout Itemize
3826 offset: number: The new offset
3829 \begin_layout Itemize
3830 bits: number: The number of LSB to replace.
3833 \begin_layout Standard
3837 \begin_layout Itemize
3838 The modified address
3841 \begin_layout Standard
3842 Returns a new address, with <bits> (all if missing) least significant bits
3843 of <addr> replaced by LSB of <offset>.
3846 \begin_layout Subsubsection
3847 Method: add: Add to address
3850 \begin_layout Itemize
3851 Syntax: ADDRESS addr:add(offset)
3854 \begin_layout Itemize
3855 Syntax: ADDRESS addr:add(number, stride)
3858 \begin_layout Itemize
3859 Syntax: ADDRESS addr:add(number, stride, offset)
3862 \begin_layout Standard
3866 \begin_layout Itemize
3867 addr: ADRESS: The original address.
3870 \begin_layout Itemize
3871 offset: number: Offset to add.
3874 \begin_layout Itemize
3875 number: number: Number of table strides to add.
3878 \begin_layout Itemize
3879 stride: number: The table stride.
3882 \begin_layout Standard
3886 \begin_layout Itemize
3887 The modified address
3890 \begin_layout Standard
3891 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
3895 \begin_layout Subsection
3896 ADDRESS:<op>: Read/Write memory
3899 \begin_layout Itemize
3900 Syntax: none addr:<op>(value)
3903 \begin_layout Itemize
3904 Syntax: number addr:<op>()
3907 \begin_layout Standard
3911 \begin_layout Itemize
3912 addr: ADDRESS: The address to read/write.
3915 \begin_layout Itemize
3916 value: number: The number to write.
3919 \begin_layout Standard
3923 \begin_layout Itemize
3927 \begin_layout Standard
3928 Read/Write value from/to given address <addr>.
3929 The value written is <value>.
3930 <Op> is of form: [i][s]<type>, where:
3933 \begin_layout Itemize
3934 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
3937 \begin_layout Itemize
3938 'i' signifies that the value is treated as opposite-to-normal endianess,
3941 \begin_layout Itemize
3942 's' signifies that value is treated as signed (not available for floating-point).
3945 \begin_layout Standard
3946 \begin_inset Newpage pagebreak
3952 \begin_layout Section
3956 \begin_layout Subsection
3957 print: Print values to console
3960 \begin_layout Itemize
3961 Syntax: none print(value...
3965 \begin_layout Standard
3966 Prints specified values to console.
3967 Can print any Lua type at least enough to identify the type and instance.
3970 \begin_layout Subsection
3971 tostringx: Format a value to string
3974 \begin_layout Itemize
3975 Syntax: string tostringx(value val)
3978 \begin_layout Standard
3979 Formats value <val> like print would, and returns the result as a string.
3982 \begin_layout Subsection
3983 exec: Execute lsnes commands
3986 \begin_layout Itemize
3987 Syntax: none exec(string cmd)
3990 \begin_layout Standard
3991 Execute lsnes command <cmd>.
3994 \begin_layout Subsection
3995 utime: Get current time
3998 \begin_layout Itemize
3999 Syntax: (number,number) utime()
4002 \begin_layout Standard
4003 Returns two numbers.
4004 First is time since some epoch in seconds, the second is microseconds mod
4005 10^6 since that epoch.
4008 \begin_layout Subsection
4009 set_idle_timeout: Run function after timeout when emulator is idle
4012 \begin_layout Itemize
4013 Syntax: none set_idle_timeout(number timeout)
4016 \begin_layout Standard
4017 Set number of microseconds to block idle for.
4018 After this timeout has expired, on_idle() will be called once.
4021 \begin_layout Subsection
4022 set_timer_timeout: Run function after timeout.
4025 \begin_layout Itemize
4026 Syntax: none set_timer_timeout(number timeout)
4029 \begin_layout Standard
4030 Set number of microseconds to block timer for.
4031 After this timeout has expired, on_timer() will be called once.
4034 \begin_layout Subsection
4035 bus_address: Look up address in system bus.
4038 \begin_layout Itemize
4039 Syntax: none bus_address(number bus_addr)
4042 \begin_layout Standard
4043 Returns virtual address corresponding to specified address on system bus.
4046 \begin_layout Subsection
4047 loopwrapper: Convert loop into callable function
4050 \begin_layout Itemize
4051 Syntax: function loopwrapper(function fun, ...)
4054 \begin_layout Standard
4055 Calls function <fun> with function and specified arguments.
4056 The function passed suspends execution until the function returned is called.
4057 Handy for linear flow control among multiple invocations of a hook.
4061 \begin_layout LyX-Code
4062 on_paint = loopwrapper(function(wait)
4066 \begin_layout LyX-Code
4071 \begin_layout LyX-Code
4073 \begin_inset Quotes eld
4077 \begin_inset Quotes erd
4083 \begin_layout LyX-Code
4088 \begin_layout LyX-Code
4093 \begin_layout LyX-Code
4097 \begin_layout Subsection
4098 list_bindings: List keybindings
4101 \begin_layout Itemize
4102 Syntax: table list_bindings([string cmd])
4105 \begin_layout Standard
4106 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4107 If <cmd> is specified, the table is limited to that command.
4108 Also searches for controller keys.
4111 \begin_layout Subsection
4112 get_alias: Get expansion of alias
4115 \begin_layout Itemize
4116 Syntax: string get_alias(string aname)
4119 \begin_layout Standard
4120 Get expansion of given alias <aname>.
4123 \begin_layout Subsection
4124 set_alias: Set expansion of alias
4127 \begin_layout Itemize
4128 Syntax: none set_alias(string aname, string value)
4131 \begin_layout Standard
4132 Set expansion of given alias.
4135 \begin_layout Subsection
4136 create_ibind: Create invese binding
4139 \begin_layout Itemize
4140 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4143 \begin_layout Standard
4144 Return object representing inverse binding with specified name <name> and
4145 specified command <cmd>.
4148 \begin_layout Itemize
4149 Note: To create press/release commands, use aliases +foo and -foo .
4152 \begin_layout Itemize
4153 Note: Keep the returned object around.
4156 \begin_layout Subsection
4157 create_command: Create a command
4160 \begin_layout Itemize
4161 Syntax: COMMANDBIND create_commmand(string name, function a)
4164 \begin_layout Itemize
4165 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
4168 \begin_layout Standard
4169 Return object representing a command (pair).
4172 \begin_layout Itemize
4173 If only one function is specied, the command is level-sensitive, <a> is
4177 \begin_layout Itemize
4178 If <b> is function, the function is edge-sensitive, <a> is positive edge
4179 callback and <b> is negative edge callback.
4182 \begin_layout Itemize
4183 All callbacks get single argument: The parameters passed.
4186 \begin_layout Itemize
4187 Keep the returned object around.
4190 \begin_layout Subsection
4191 loadfile: Load Lua script
4194 \begin_layout Itemize
4195 Syntax: function loadfile(string filename[, string base])
4198 \begin_layout Standard
4199 Load lua script from <filename>, resolved relative to <base> (if empty,
4203 \begin_layout Subsection
4204 dofile: Execute Lua script
4207 \begin_layout Itemize
4208 Syntax: function dofile(string filename[, string base])
4211 \begin_layout Standard
4212 Execute lua script from <filename>, resolved relative to <base> (if empty,
4213 current directory) and return all return values.
4216 \begin_layout Subsection
4217 resolve_filename: Resolve name of file relative to another
4220 \begin_layout Itemize
4221 Syntax: string resolve_file(string filename, string base)
4224 \begin_layout Standard
4225 Resolve name of file <filename> relative to <base> and return the result.
4228 \begin_layout Subsection
4229 render_queue_function: Return paint function for render queue
4232 \begin_layout Itemize
4233 Syntax: function render_queue_function(RENDERQUEUE rq)
4236 \begin_layout Standard
4237 Return function that renders render queue <rq>.
4240 \begin_layout Itemize
4241 Handy for paint callback if one is using render queues updated in other
4246 \begin_layout LyX-Code
4247 handle = callback.paint:register(render_queue_function(my_rq));
4250 \begin_layout Subsection
4251 identify_class: Identify class of object
4254 \begin_layout Itemize
4255 Syntax: string identify_class(userdata object)
4258 \begin_layout Standard
4259 Identifies the class of userdata <object>, if possible.
4260 If no identification is possible, returns
4261 \begin_inset Quotes eld
4265 \begin_inset Quotes erd
4271 \begin_layout Subsection
4272 lookup_class: Lookup class by name
4275 \begin_layout Itemize
4276 Syntax: classobj lookup_class(string name)
4279 \begin_layout Standard
4280 Looks up class corresponding to <name>, if possible.
4281 If not found, returns nil.
4282 The classobj has following fields:
4285 \begin_layout Itemize
4286 _static_methods: Return static method names
4289 \begin_layout Itemize
4290 _class_methods: Return class method names
4293 \begin_layout Itemize
4294 <static-function-name>: The specified static function.
4297 \begin_layout Subsection
4298 all_classes: Get list of all classes
4301 \begin_layout Itemize
4306 \begin_layout Standard
4307 Get names of all classes available.
4310 \begin_layout Subsection
4314 \begin_layout Subsection
4318 \begin_layout Standard
4322 \begin_layout Subsection
4323 filereader: Class FILEREADER
4326 \begin_layout Standard
4327 See class FILEREADER.
4330 \begin_layout Standard
4331 \begin_inset Newpage pagebreak
4337 \begin_layout Section
4341 \begin_layout Standard
4342 Bitwise logical functions and related.
4345 \begin_layout Subsection
4346 bit.none/bit.bnot: Bitwise none or NOT function
4349 \begin_layout Itemize
4350 Syntax: number bit.none(number...)
4353 \begin_layout Itemize
4354 Syntax: number bit.bnot(number...)
4357 \begin_layout Standard
4358 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4362 \begin_layout Subsection
4363 bit.any/bit.bor: Bitwise any or OR function
4366 \begin_layout Itemize
4367 Syntax: number bit.any(number...)
4370 \begin_layout Itemize
4371 Syntax: number bit.bor(number...)
4374 \begin_layout Standard
4375 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4378 \begin_layout Subsection
4379 bit.all/bit.band: Bitwise all or AND function
4382 \begin_layout Itemize
4383 Syntax: number bit.all(number...)
4386 \begin_layout Itemize
4387 Syntax: number bit.band(number...)
4390 \begin_layout Standard
4391 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4395 \begin_layout Subsection
4396 bit.parity/bit.bxor: Bitwise parity or XOR function
4399 \begin_layout Itemize
4400 Syntax: number bit.parity(number...)
4403 \begin_layout Itemize
4404 Syntax: number bit.bxor(number...)
4407 \begin_layout Standard
4408 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4412 \begin_layout Subsection
4413 bit.lrotate: Rotate a number left
4416 \begin_layout Itemize
4417 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4420 \begin_layout Standard
4421 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4425 \begin_layout Subsection
4426 bit.rrotate: Rotate a number right
4429 \begin_layout Itemize
4430 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4433 \begin_layout Standard
4434 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4438 \begin_layout Subsection
4439 bit.lshift: Shift a number left
4442 \begin_layout Itemize
4443 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4446 \begin_layout Standard
4447 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4449 The new bits are filled with zeroes.
4452 \begin_layout Subsection
4453 bit.lrshift: Shift a number right (logical)
4456 \begin_layout Itemize
4457 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4460 \begin_layout Standard
4461 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4463 The new bits are filled with zeroes.
4466 \begin_layout Subsection
4467 bit.arshift: Shift a number right (arithmetic)
4470 \begin_layout Itemize
4471 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4474 \begin_layout Standard
4475 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4477 The new bits are shifted in with copy of the high bit.
4480 \begin_layout Subsection
4481 bit.extract: Extract/shuffle bits from number
4484 \begin_layout Itemize
4485 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4488 \begin_layout Standard
4489 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4492 \begin_layout Itemize
4493 Note: Bit numbers up to 51 should work reliably (then things start falling
4494 apart due to double precision issues).
4497 \begin_layout Itemize
4498 Note: There are two special bit positions, true and false, standing for
4499 always set bit and always clear bit.
4502 \begin_layout Subsection
4503 bit.value: Construct number with specified bits set
4506 \begin_layout Itemize
4507 Syntax: number bit.value([number bit1[, number bit2,...]])
4510 \begin_layout Standard
4511 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4512 <bit2> places and so on.
4513 As special value, nil argument is no-op.
4516 \begin_layout Subsection
4517 bit.test: Test if bit is set
4520 \begin_layout Itemize
4521 Syntax: boolean bit.test(number a, number bit)
4524 \begin_layout Standard
4525 Tests if bit <bit> is set in <a>.
4526 If it is set, returns true, otherwise false.
4529 \begin_layout Subsection
4530 bit.testn: Test if bit is clear
4533 \begin_layout Itemize
4534 Syntax: boolean bit.testn(number a, number bit)
4537 \begin_layout Standard
4538 Tests if bit <bit> is set in <a>.
4539 If it is clear, returns true, otherwise false.
4542 \begin_layout Subsection
4543 bit.test_any: Test if any bit is set
4546 \begin_layout Itemize
4547 Syntax: boolean bit.test_any(number a, number b)
4550 \begin_layout Standard
4551 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4554 \begin_layout Subsection
4555 bit.test_all: Test if all bits are set
4558 \begin_layout Itemize
4559 Syntax: boolean bit.test_all(number a, number b)
4562 \begin_layout Standard
4563 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4566 \begin_layout Subsection
4567 bit.popcount: Population count
4570 \begin_layout Itemize
4571 Syntax: number bit.popcount(number a)
4574 \begin_layout Standard
4575 Returns number of set bits in <a>.
4578 \begin_layout Subsection
4579 bit.clshift: Chained left shift
4582 \begin_layout Itemize
4583 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4587 \begin_layout Standard
4588 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4589 numbers to be of specified number of bits <bits> (default 48).
4592 \begin_layout Subsection
4593 bit.crshift: Chained right shift
4596 \begin_layout Itemize
4597 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4601 \begin_layout Standard
4602 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4603 assuming numbers to be of specified number of bits <bits> (default 48).
4606 \begin_layout Subsection
4607 bit.flagdecode: Decode bitfield into flags
4610 \begin_layout Itemize
4611 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4615 \begin_layout Standard
4616 Return string of length bits where ith character is ith character of on
4617 if bit i is on, otherwise ith character of off.
4618 Out of range reads give last character.
4621 \begin_layout Itemize
4622 Note: <on> defaults to '*' if empty.
4625 \begin_layout Itemize
4626 Note: <off> defaults to '-' if empty.
4629 \begin_layout Subsection
4630 bit.rflagdecode: Decode bitfield into flags
4633 \begin_layout Itemize
4634 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4638 \begin_layout Standard
4639 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4643 \begin_layout Subsection
4644 bit.swap{,s}{,h,d,q}word: Swap word endian
4647 \begin_layout Itemize
4648 Syntax: number bit.swapword(number n)
4651 \begin_layout Itemize
4652 Syntax: number bit.swaphword(number n)
4655 \begin_layout Itemize
4656 Syntax: number bit.swapdword(number n)
4659 \begin_layout Itemize
4660 Syntax: number bit.swapqword(number n)
4663 \begin_layout Itemize
4664 Syntax: number bit.swapsword(number n)
4667 \begin_layout Itemize
4668 Syntax: number bit.swapshword(number n)
4671 \begin_layout Itemize
4672 Syntax: number bit.swapsdword(number n)
4675 \begin_layout Itemize
4676 Syntax: number bit.swapsqword(number n)
4679 \begin_layout Standard
4680 Swap endianess of (un)signed integer <n>.
4683 \begin_layout Subsection
4684 bit.compose: Compose multi-byte number
4687 \begin_layout Itemize
4688 Syntax: number bit.compose(number n...)
4691 \begin_layout Standard
4693 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4699 \begin_layout Subsection
4700 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4703 \begin_layout Itemize
4704 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4707 \begin_layout Itemize
4708 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4711 \begin_layout Standard
4712 Load little (*le) or big (*be) endian binary number from position <pos>
4714 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4718 \begin_layout Subsection
4719 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4722 \begin_layout Itemize
4723 Syntax: string bit.binary_st_<type>le(number x);
4726 \begin_layout Itemize
4727 Syntax: string bit.binary_st_<type>be(number x);
4730 \begin_layout Standard
4731 Store specified number <x> as binary in string and return the result.
4732 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4736 \begin_layout Subsection
4737 bit.quotent: Integer quotent
4740 \begin_layout Itemize
4741 Syntax: number bit.quotent(number a, number b)
4744 \begin_layout Standard
4745 Calculate quotent a/b.
4748 \begin_layout Subsection
4749 bit.multidiv: Divide and split among multiple divisiors
4752 \begin_layout Itemize
4754 bit.multidiv(number v, number q...)
4757 \begin_layout Standard
4758 Does the following steps:
4761 \begin_layout Enumerate
4765 \begin_layout Enumerate
4770 \begin_layout Enumerate
4771 Calculate quotent(v'/q) and add that to numbers returned.
4774 \begin_layout Enumerate
4775 v' <- remainder(v'/q)
4779 \begin_layout Enumerate
4780 Add v' to numbers returned.
4783 \begin_layout Standard
4784 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
4786 <v> may be floating point, <q>s are integers.
4789 \begin_layout Itemize
4791 bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
4794 \begin_layout Itemize
4796 bit.multidiv(a, b) calculates quotent and remainder of a/b.
4799 \begin_layout Subsection
4800 bit.mul32: 32-bit multiply
4803 \begin_layout Itemize
4804 Syntax: number, number bit.mul32(number a, number b)
4807 \begin_layout Standard
4808 Multiply 32-bit numbers <a> and <b>.
4809 The first return value is low 32 bits of result, the second is high 32
4813 \begin_layout Standard
4814 \begin_inset Newpage pagebreak
4820 \begin_layout Section
4824 \begin_layout Subsection
4825 classes.<foo>: The classobj for class <foo>
4828 \begin_layout Itemize
4829 Syntax: classes.<foo>
4832 \begin_layout Standard
4833 The classobj for class <foo>.
4836 \begin_layout Subsection
4837 classes.<foo>._static_methods: Enumerate static methods
4840 \begin_layout Itemize
4842 classes.<foo>._static_methods()
4845 \begin_layout Standard
4846 Returns all static methods of <foo> as strings.
4849 \begin_layout Subsection
4850 classes.<foo>._class_methods: Enumerate static methods
4853 \begin_layout Itemize
4855 classes.<foo>._class_methods()
4858 \begin_layout Standard
4859 Returns all class methods of <foo> as strings.
4862 \begin_layout Subsection
4863 classes.<foo>.<bar>: Static method
4866 \begin_layout Itemize
4867 Syntax: variable classes.<foo>.<bar>(variable...)
4870 \begin_layout Standard
4871 Invokes static method <bar> of class <foo>.
4874 \begin_layout Section
4878 \begin_layout Subsection
4879 gui.resolution: Get current resolution
4882 \begin_layout Itemize
4883 Syntax: (number, number) gui.resolution()
4886 \begin_layout Standard
4887 Returns 2-tuple (hresolution, vresolution).
4890 \begin_layout Subsection
4891 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
4894 \begin_layout Itemize
4895 Syntax: number gui.left_gap(number gap)
4898 \begin_layout Itemize
4899 Syntax: number gui.right_gap(number gap)
4902 \begin_layout Itemize
4903 Syntax: number gui.top_gap(number gap)
4906 \begin_layout Itemize
4907 Syntax: number gui.bottom_gap(number gap)
4910 \begin_layout Standard
4911 Set the specified edge gap to specified value <gap> (max gap is 8191).
4912 If successful, old gap is returned.
4915 \begin_layout Subsection
4916 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
4920 \begin_layout Itemize
4921 Syntax: number gui.delta_left_gap(number dgap)
4924 \begin_layout Itemize
4925 Syntax: number gui.delta_right_gap(number dgap)
4928 \begin_layout Itemize
4929 Syntax: number gui.delta_top_gap(number dgap)
4932 \begin_layout Itemize
4933 Syntax: number gui.delta_bottom_gap(number dgap)
4936 \begin_layout Standard
4937 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
4938 and return the old gap (returns nothing on error).
4941 \begin_layout Subsection
4942 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
4945 \begin_layout Itemize
4946 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
4950 \begin_layout Itemize
4951 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
4955 \begin_layout Itemize
4956 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
4960 \begin_layout Itemize
4961 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
4965 \begin_layout Standard
4966 Draw specified text on the GUI (each character cell is 8 or 16 wide and
4971 \begin_layout Itemize
4972 x: X-coordinate to start the drawing from (and x-coordinate at begining
4976 \begin_layout Itemize
4977 y: Y-coordinate to start the drawing from.
4980 \begin_layout Itemize
4981 text: The text to draw.
4984 \begin_layout Itemize
4985 fgc: Text color (default is 0xFFFFFF (white))
4988 \begin_layout Itemize
4989 bgc: Background color (default is -1 (transparent))
4992 \begin_layout Standard
4993 Note: The H variants draw at double width and V variants draw at double
4997 \begin_layout Subsection
4998 gui.rectangle: Draw a rectangle
5001 \begin_layout Itemize
5002 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5003 number thickness[, number outline[, number fill]]])
5006 \begin_layout Standard
5007 Draw rectangle on the GUI.
5011 \begin_layout Itemize
5012 x: X-coordinate of left edge.
5015 \begin_layout Itemize
5016 y: Y-coordinate of upper edge.
5019 \begin_layout Itemize
5020 width: Width of rectangle.
5023 \begin_layout Itemize
5024 height: Height of rectangle.
5027 \begin_layout Itemize
5028 thickness: Thickness of outline (default is 1).
5031 \begin_layout Itemize
5032 outline: Color of outline (default is 0xFFFFFF (white))
5035 \begin_layout Itemize
5036 fill: Color of fill (default is -1 (transparent))
5039 \begin_layout Subsection
5040 gui.solidrectangle: Draw a solid rectangle
5043 \begin_layout Itemize
5044 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5048 \begin_layout Standard
5049 Draw solid rectangle on the GUI.
5053 \begin_layout Itemize
5054 x: X-coordinate of left edge.
5057 \begin_layout Itemize
5058 y: Y-coordinate of upper edge.
5061 \begin_layout Itemize
5062 width: Width of rectangle.
5065 \begin_layout Itemize
5066 height: Height of rectangle.
5069 \begin_layout Itemize
5070 color: Color of rectangle (default is 0xFFFFFF (white))
5073 \begin_layout Subsection
5074 gui.box: Draw a 3D-effect box
5077 \begin_layout Itemize
5078 Syntax: none gui.box(number x, number y, number width, number height[, number
5079 thickness[, number outline1[,number outline2[, number fill]]]])
5082 \begin_layout Standard
5083 Draw rectangle with 3D effect on the GUI.
5087 \begin_layout Itemize
5088 x: X-coordinate of left edge.
5091 \begin_layout Itemize
5092 y: Y-coordinate of upper edge.
5095 \begin_layout Itemize
5096 width: Width of rectangle.
5099 \begin_layout Itemize
5100 height: Height of rectangle.
5103 \begin_layout Itemize
5104 thickness: Thickness of outline (default is 1).
5107 \begin_layout Itemize
5108 outline1: First color of outline (default is 0xFFFFFF (white))
5111 \begin_layout Itemize
5112 outline2: First color of outline (default is 0x808080 (dark gray))
5115 \begin_layout Itemize
5116 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5119 \begin_layout Subsection
5120 gui.pixel: Draw a single pixel
5123 \begin_layout Itemize
5124 Syntax: none gui.pixel(number x, number y[, number color])
5127 \begin_layout Standard
5128 Draw one pixel on the GUI.
5132 \begin_layout Itemize
5133 x: X-coordinate of the pixel
5136 \begin_layout Itemize
5137 y: Y-coordinate of the pixel
5140 \begin_layout Itemize
5141 color: Color of the pixel (default is 0xFFFFFF (white))
5144 \begin_layout Subsection
5145 gui.crosshair: Draw a crosshair
5148 \begin_layout Itemize
5149 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5152 \begin_layout Standard
5157 \begin_layout Itemize
5158 x: X-coordinate of the crosshair
5161 \begin_layout Itemize
5162 y: Y-coordinate of the crosshair
5165 \begin_layout Itemize
5166 length: Length of the crosshair lines (default 10).
5169 \begin_layout Itemize
5170 color: Color of the crosshair (default is 0xFFFFFF (white))
5173 \begin_layout Subsection
5174 gui.line: Draw a line
5177 \begin_layout Itemize
5178 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5182 \begin_layout Standard
5187 \begin_layout Itemize
5188 x1: X-coordinate of one end.
5191 \begin_layout Itemize
5192 y1: Y-coordinate of one end.
5195 \begin_layout Itemize
5196 x2: X-coordinate of the other end.
5199 \begin_layout Itemize
5200 y2: Y-coordinate of the other end.
5203 \begin_layout Itemize
5204 color: Color of the line (default is 0xFFFFFF (white)).
5207 \begin_layout Subsection
5208 gui.circle: Draw a (filled) circle
5211 \begin_layout Itemize
5212 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5213 border[, number fil]]])
5216 \begin_layout Standard
5221 \begin_layout Itemize
5222 x: X-coordinate of the center
5225 \begin_layout Itemize
5226 y: Y-coordinate of the center
5229 \begin_layout Itemize
5230 r: The radius of the circle
5233 \begin_layout Itemize
5234 thick: Border thickness
5237 \begin_layout Itemize
5238 border: Border color (default is 0xFFFFFF (white))
5241 \begin_layout Itemize
5242 fill: Fill color (default is -1 (transparent)).
5245 \begin_layout Subsection
5246 gui.repaint: Arrange a repaint
5249 \begin_layout Itemize
5250 Syntax: none gui.repaint()
5253 \begin_layout Standard
5254 Request on_repaint() to happen as soon as possible.
5257 \begin_layout Subsection
5258 gui.subframe_update: Enable/Disable subframe updates
5261 \begin_layout Itemize
5262 Syntax: none gui.subframe_update(boolean on)
5265 \begin_layout Standard
5266 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5267 or not happen (<on>=false).
5270 \begin_layout Subsection
5271 gui.screenshot: Write a screenshot
5274 \begin_layout Itemize
5275 Syntax: none gui.screenshot(string filename)
5278 \begin_layout Standard
5279 Write PNG screenshot of the current frame (no drawings) to specified file
5283 \begin_layout Subsection
5284 gui.screenshot_bitmap: Write a screenshot to bitmap
5287 \begin_layout Itemize
5288 Syntax: DBITMAP gui.screenshot_bitmap()
5291 \begin_layout Standard
5292 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5296 \begin_layout Subsection
5297 gui.color: Compose a color.
5300 \begin_layout Itemize
5301 Syntax: number gui.color(number r, number g, number b[, number a])
5304 \begin_layout Itemize
5305 Syntax: number gui.color(string c)
5308 \begin_layout Standard
5309 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5310 , each component in scale 0-255.
5311 If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5313 The default alpha is 256.
5316 \begin_layout Standard
5317 The form taking a string returns color corresponding color name.
5320 \begin_layout Subsection
5321 gui.status: Set status variable
5324 \begin_layout Itemize
5325 Syntax: none gui.status(string name, string value)
5328 \begin_layout Standard
5330 \begin_inset Quotes eld
5334 \begin_inset Quotes erd
5337 to <value> in status area.
5340 \begin_layout Subsection
5341 gui.rainbow: Rainbow color calculation
5344 \begin_layout Itemize
5345 Syntax: number gui.rainbow(number step, number steps[, number color])
5348 \begin_layout Standard
5349 Perform hue rotation of color <color> (default bright red), by <step> steps.
5350 The number of steps per full rotation is given by absolute value of <steps>.
5353 \begin_layout Standard
5354 If <step> is negative, the rotation will be counterclockwise.
5357 \begin_layout Subsection
5358 gui.kill_frame: Kill video frame and associated sound
5361 \begin_layout Itemize
5362 Syntax: none gui.kill_frame()
5365 \begin_layout Standard
5366 Kills the currently dumped video frame + the associated sound.
5367 Only valid in on_video callback.
5370 \begin_layout Subsection
5371 gui.set_video_scale: Set video frame scale
5374 \begin_layout Itemize
5375 Syntax: none gui.set_video_scale(number h, number v)
5378 \begin_layout Standard
5379 Sets the scale factors of current frame to <h>x<v>.
5380 Only valid in on_video callback.
5383 \begin_layout Subsection
5384 gui.arrow: Draw an arrow
5387 \begin_layout Itemize
5388 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5389 number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5393 \begin_layout Standard
5394 Draws an arrow using color <color>.
5395 The tip of arrow is at (<x>, <y>).
5399 \begin_layout Enumerate
5400 <length>: The length of arrow tail.
5403 \begin_layout Enumerate
5404 <hwidth>: The width of arrow head.
5408 \begin_layout Enumerate
5409 <direction>: Direction of arrow.
5410 0 is to right, +1 rotates 45 degrees counterclockwise.
5413 \begin_layout Enumerate
5414 <fill>: If true, fill the arrow head.
5418 \begin_layout Enumerate
5419 <twidth>: Tail width.
5424 \begin_layout Enumerate
5425 <hthick>: Head thickness (only used if <fill> is false).
5426 Default is <twidth>.
5429 \begin_layout Subsection
5430 gui.tiled_bitmap: Class TILEMAP
5433 \begin_layout Standard
5437 \begin_layout Subsection
5438 gui.palette: Class PALETTE
5441 \begin_layout Standard
5445 \begin_layout Subsection
5446 gui.bitmap: Class BITMAP
5449 \begin_layout Standard
5453 \begin_layout Subsection
5454 gui.dbitmap: Class DBITMAP
5457 \begin_layout Standard
5461 \begin_layout Subsection
5462 gui.font: Class CUSTOMFONT
5465 \begin_layout Standard
5466 See class CUSTOMFONT.
5469 \begin_layout Subsection
5470 gui.renderctx: Class RENDERCTX
5473 \begin_layout Standard
5474 See class RENDERCTX.
5477 \begin_layout Subsection
5478 gui.image: Class IMAGELOADER
5481 \begin_layout Standard
5482 See class IMAGELOADER.
5485 \begin_layout Standard
5486 \begin_inset Newpage pagebreak
5492 \begin_layout Section
5496 \begin_layout Standard
5498 Functions manipulating input are only available in on_input callback.
5501 \begin_layout Subsection
5502 input.get: Read controller button/axis (deprecated)
5505 \begin_layout Itemize
5506 Syntax: number input.get(number controller, number index)
5509 \begin_layout Standard
5510 Read the specified index <index> (zero-based) from specified controller
5511 <controller> (zero-based).
5515 \begin_layout Subsection
5516 input.set: Write controller button/axis (deprecated)
5519 \begin_layout Itemize
5520 Syntax: none input.set(number controller, number index, number value)
5523 \begin_layout Standard
5524 Write the specified index <index> (zero-based) from specified controller
5525 <controller> (zero-based), storing value <value>.
5528 \begin_layout Subsection
5529 input.get2: Read controller button/axis
5532 \begin_layout Itemize
5533 Syntax: number input.get2(number port, number controller, number index)
5536 \begin_layout Standard
5537 Read the specified input tuple.
5538 Port 0 is system port.
5541 \begin_layout Subsection
5542 input.set2: Write controller button/axis
5545 \begin_layout Itemize
5546 Syntax: input.set2(number port, number controller, number index, number value)
5549 \begin_layout Standard
5550 Write the specified input tuple.
5551 Port 0 is system port.
5554 \begin_layout Subsection
5555 input.lcid_to_pcid2: Look up logical controller
5558 \begin_layout Itemize
5559 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5562 \begin_layout Standard
5563 Look up physical pcid pair (port, controller) corresponding to specified
5564 logical controller (1-based).
5565 Returns nothing if controller does not exist.
5568 \begin_layout Subsection
5569 input.port_type: Look up port type
5572 \begin_layout Itemize
5573 Syntax: string input.port_type(number port)
5576 \begin_layout Standard
5577 Return type of specified port.
5580 \begin_layout Subsection
5581 input.controller_info: Get information about controller
5584 \begin_layout Itemize
5585 Syntax: table input.controller_info(number port, number controller)
5588 \begin_layout Standard
5589 Get controller info for specified controller.
5590 If controller does not exist, returns nil.
5591 Otherwise returns a table with following fields:
5594 \begin_layout Itemize
5595 type (string): Type of the controller.
5598 \begin_layout Itemize
5599 class (string): Class of the controller.
5602 \begin_layout Itemize
5603 classnum (number): Number of the controller within its class (1-based)
5606 \begin_layout Itemize
5607 lcid (number): Logical controller number of the controller.
5610 \begin_layout Itemize
5611 button_count (number): Number of buttons on controller
5614 \begin_layout Itemize
5615 buttons (array): Array of following info about each button:
5619 \begin_layout Itemize
5620 type (string): Type of button.
5622 \begin_inset Quotes eld
5626 \begin_inset Quotes erd
5630 \begin_inset Quotes eld
5634 \begin_inset Quotes erd
5638 \begin_inset Quotes eld
5642 \begin_inset Quotes erd
5646 \begin_inset Quotes eld
5650 \begin_inset Quotes erd
5656 \begin_layout Itemize
5657 name (string): Name of button.
5660 \begin_layout Itemize
5661 symbol (string): Symbol of button.
5662 Only present for type
5663 \begin_inset Quotes eld
5667 \begin_inset Quotes erd
5673 \begin_layout Itemize
5674 hidden (boolean): True if hidden button.
5679 \begin_layout Subsection
5680 input.veto_button: Veto a button press
5683 \begin_layout Itemize
5684 Syntax: none input.veto_button()
5687 \begin_layout Standard
5688 Signals that the button event should be vetoed.
5689 Only valid in on_button callback.
5692 \begin_layout Subsection
5693 input.geta: Get all buttons for controller (deprecated)
5696 \begin_layout Itemize
5697 Syntax: (number, number...) input.geta(number controller)
5700 \begin_layout Standard
5701 Get input state for entiere controller.
5702 Returns n return values.
5705 \begin_layout Itemize
5706 1st return value: Bitmask: bit i is set if i:th index is nonzero
5709 \begin_layout Itemize
5710 2nd- return value: value of i:th index.
5713 \begin_layout Subsection
5714 input.seta: Set all buttons for controller (deprecated)
5717 \begin_layout Itemize
5718 Syntax: none input.seta(number controller, number bitmask, number args...)
5721 \begin_layout Standard
5722 Set state for entiere controller.
5723 args is up to N values for indices (overriding values in bitmask if specified).
5726 \begin_layout Subsection
5727 input.controllertype: Get controller type (deprecated)
5730 \begin_layout Itemize
5731 syntax: string input.controllertype(number controller)
5734 \begin_layout Standard
5735 Get the type of controller as string.
5738 \begin_layout Subsection
5739 input.reset: Execute (delayed) reset
5742 \begin_layout Itemize
5743 Syntax: none input.reset([number cycles])
5746 \begin_layout Standard
5748 If <cycles> is greater than zero, do delayed reset.
5749 0 (or no value) causes immediate reset.
5752 \begin_layout Itemize
5753 Note: Only available with subframe flag false.
5756 \begin_layout Subsection
5757 input.raw: Return raw input data
5760 \begin_layout Itemize
5761 Syntax: table input.raw()
5764 \begin_layout Standard
5765 Returns table of tables of all available keys and axes.
5766 The first table is indexed by key name (platform-dependent!), and the inner
5767 table has the following fields:
5770 \begin_layout Itemize
5771 value: Last reported value for control
5775 \begin_layout Itemize
5776 For keys: 1 for pressed, 0 for released.
5779 \begin_layout Itemize
5780 For axes: -32767...32767.
5783 \begin_layout Itemize
5784 For presure-sensitive buttons: 0...32767.
5787 \begin_layout Itemize
5788 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
5791 \begin_layout Itemize
5792 For mouse: Coordinates relative to game area.
5796 \begin_layout Itemize
5797 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
5800 \begin_layout Subsection
5801 input.keyhook: Hook a key
5804 \begin_layout Itemize
5805 Syntax: none input.keyhook(string key, boolean state)
5808 \begin_layout Standard
5809 Requests that keyhook events to be sent for key <key> (<state>=true) or
5810 not sent (<state>=false).
5813 \begin_layout Subsection
5814 input.joyget: Get controls for controller
5817 \begin_layout Itemize
5818 Syntax: table input.joyget(number logical)
5821 \begin_layout Standard
5822 Returns table for current controls for specified logical controller <logical>.
5823 The names of fields vary by controller type.
5826 \begin_layout Itemize
5827 The buttons have the same name as those are referred to in other contexts
5831 \begin_layout Itemize
5832 The analog axes are usually
5833 \begin_inset Quotes eld
5837 \begin_inset Quotes erd
5841 \begin_inset Quotes eld
5845 \begin_inset Quotes erd
5851 \begin_layout Itemize
5852 Each field is numeric or boolean depending on axis/button.
5855 \begin_layout Subsection
5856 input.joyset: Set controls for controller
5859 \begin_layout Itemize
5860 Syntax: none input.joyset(number controller, table controls)
5863 \begin_layout Standard
5864 Set the the state of specified controller to values specified in specified
5868 \begin_layout Itemize
5869 Each field can be boolean or number.
5872 \begin_layout Itemize
5873 Also, buttons allow strings, which cause value to be inverted.
5876 \begin_layout Subsection
5877 input.lcid_to_pcid: Look up logical controller (deprecated)
5880 \begin_layout Itemize
5881 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
5884 \begin_layout Standard
5885 Returns the legacy pcid for controller (or false if there isn't one), followed
5887 Returns nothing if controller does not exist.
5890 \begin_layout Standard
5891 \begin_inset Newpage pagebreak
5897 \begin_layout Section
5901 \begin_layout Standard
5902 Various keybinding-related functions
5905 \begin_layout Subsection
5906 keyboard.bind: Bind a key
5909 \begin_layout Itemize
5910 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
5913 \begin_layout Standard
5914 Bind specified key with specified modifers to specified command.
5917 \begin_layout Subsection
5918 keyboard.unbind: Unbind a key
5921 \begin_layout Itemize
5922 Syntax: none keyboard.unbind(string mod, string mask, string key)
5925 \begin_layout Standard
5926 Unbind specified key with specified modifers.
5929 \begin_layout Subsection
5930 keyboard.alias: Set alias expansion
5933 \begin_layout Itemize
5934 Syntax: none keyboard.alias(string alias, string expansion)
5937 \begin_layout Standard
5938 Set expansion of given command.
5941 \begin_layout Standard
5942 \begin_inset Newpage pagebreak
5948 \begin_layout Section
5952 \begin_layout Standard
5956 \begin_layout Subsection
5957 subtitle.byindex: Look up start and length of subtitle by index
5960 \begin_layout Itemize
5961 Syntax: (number, number) subtitle.byindex(number i)
5964 \begin_layout Standard
5965 Read the frame and length of ith subtitle.
5966 Returns nothing if not present.
5969 \begin_layout Subsection
5970 subtitle.set: Write a subtitle
5973 \begin_layout Itemize
5974 Syntax: none subtitle.set(number f, number l, string txt)
5977 \begin_layout Standard
5978 Set the text of subtitle.
5981 \begin_layout Subsection
5982 subtitle.get: Read a subtitle
5985 \begin_layout Itemize
5986 Syntax: string subtitle.get(number f, number l)
5989 \begin_layout Standard
5990 Get the text of subtitle.
5993 \begin_layout Subsection
5994 subtitle.delete: Delete a subtitle
5997 \begin_layout Itemize
5998 Syntax: none subtitle.delete(number f, number l)
6001 \begin_layout Standard
6002 Delete specified subtitle.
6005 \begin_layout Standard
6006 \begin_inset Newpage pagebreak
6012 \begin_layout Section
6016 \begin_layout Standard
6017 Host memory handling (extra memory saved to savestates).
6018 Host memory starts empty.
6021 \begin_layout Itemize
6022 Reads out of range return false.
6025 \begin_layout Itemize
6026 Writes out of range extend the memory.
6029 \begin_layout Subsection
6030 hostmemory.read: Read byte from host memory
6033 \begin_layout Itemize
6034 Syntax: number hostmemory.read(number address)
6037 \begin_layout Standard
6038 Reads byte from hostmemory slot address <address>.
6041 \begin_layout Subsection
6042 hostmemory.write: Write byte to host memory
6045 \begin_layout Itemize
6046 Syntax: none hostmemory.write(number address, number value)
6049 \begin_layout Standard
6050 Writes hostmemory slot with value <value> 0-255.
6053 \begin_layout Subsection
6054 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6057 \begin_layout Itemize
6058 Syntax: number hostmemory.readbyte(number address)
6061 \begin_layout Itemize
6062 Syntax: number hostmemory.readsbyte(number address)
6065 \begin_layout Itemize
6066 Syntax: number hostmemory.readword(number address)
6069 \begin_layout Itemize
6070 Syntax: number hostmemory.readsword(number address)
6073 \begin_layout Itemize
6074 Syntax: number hostmemory.readhword(number address)
6077 \begin_layout Itemize
6078 Syntax: number hostmemory.readshword(number address)
6081 \begin_layout Itemize
6082 Syntax: number hostmemory.readdword(number address)
6085 \begin_layout Itemize
6086 Syntax: number hostmemory.readsdword(number address)
6089 \begin_layout Itemize
6090 Syntax: number hostmemory.readqword(number address)
6093 \begin_layout Itemize
6094 Syntax: number hostmemory.readsqword(number address)
6097 \begin_layout Standard
6098 Read elements (big-endian) from given address <address>.
6101 \begin_layout Itemize
6105 \begin_layout Itemize
6109 \begin_layout Itemize
6113 \begin_layout Itemize
6117 \begin_layout Itemize
6118 qword is 8 elements.
6121 \begin_layout Itemize
6122 The 's' variants do signed read.
6125 \begin_layout Subsection
6126 hostmemory.read{float,double}: Read from host memory
6129 \begin_layout Itemize
6130 syntax: number hostmemory.readfloat(number address)
6133 \begin_layout Itemize
6134 Syntax: number hostmemory.readdouble(number address)
6137 \begin_layout Standard
6138 Read elements (big-endian) floating-pont from given address <address>.
6141 \begin_layout Subsection
6142 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6145 \begin_layout Itemize
6146 Syntax: number hostmemory.writebyte(number address, number value)
6149 \begin_layout Itemize
6150 Syntax: number hostmemory.writesbyte(number address, number value)
6153 \begin_layout Itemize
6154 Syntax: number hostmemory.writeword(number address, number value)
6157 \begin_layout Itemize
6158 Syntax: number hostmemory.writesword(number address, number value)
6161 \begin_layout Itemize
6162 Syntax: number hostmemory.writehword(number address, number value)
6165 \begin_layout Itemize
6166 Syntax: number hostmemory.writeshword(number address, number value)
6169 \begin_layout Itemize
6170 Syntax: number hostmemory.writedword(number address, number value)
6173 \begin_layout Itemize
6174 Syntax: number hostmemory.writesdword(number address, number value)
6177 \begin_layout Itemize
6178 Syntax: number hostmemory.writeqword(number address, number value)
6181 \begin_layout Itemize
6182 Syntax: number hostmemory.writesqword(number address, number value)
6185 \begin_layout Standard
6186 Write value <value> to elements (little-endian) starting from given address
6190 \begin_layout Itemize
6194 \begin_layout Itemize
6198 \begin_layout Itemize
6202 \begin_layout Itemize
6206 \begin_layout Itemize
6207 qword is 8 elements.
6210 \begin_layout Itemize
6211 The 's' variants do signed write.
6214 \begin_layout Subsection
6215 hostmemory.write{float,double}: Write to host memory
6218 \begin_layout Itemize
6219 syntax: none hostmemory.readfloat(number address, number value)
6222 \begin_layout Itemize
6223 Syntax: none hostmemory.readdouble(number address, number value)
6226 \begin_layout Standard
6227 Write elements (big-endian) floating-pont to given address <address>, storing
6231 \begin_layout Standard
6232 \begin_inset Newpage pagebreak
6238 \begin_layout Section
6242 \begin_layout Standard
6246 \begin_layout Subsection
6247 movie.currentframe: Get current frame number
6250 \begin_layout Itemize
6251 Syntax: number movie.currentframe()
6254 \begin_layout Standard
6255 Return number of current frame.
6258 \begin_layout Subsection
6259 movie.framecount: Get move frame count
6262 \begin_layout Itemize
6263 Syntax: number movie.framecount()
6266 \begin_layout Standard
6267 Return number of frames in movie.
6270 \begin_layout Subsection
6271 movie.lagcount: Get current lag count
6274 \begin_layout Itemize
6275 Syntax: number movie.lagcount()
6278 \begin_layout Standard
6279 Return number of lag frames recorded so far.
6282 \begin_layout Subsection
6283 movie.readonly: Is in playback mode?
6286 \begin_layout Itemize
6287 Syntax: boolean movie.readonly()
6290 \begin_layout Standard
6291 Return true if in playback mode, false if in recording.
6294 \begin_layout Subsection
6295 movie.rerecords: Movie rerecord count
6298 \begin_layout Itemize
6299 Syntax: number movie.rerecords()
6302 \begin_layout Standard
6303 Returns the current value of rerecord count.
6306 \begin_layout Subsection
6307 movie.set_readwrite: Set recording mode.
6310 \begin_layout Itemize
6311 Syntax: none movie.set_readwrite()
6314 \begin_layout Standard
6315 Set recording mode (does not cause on_readwrite callback).
6318 \begin_layout Subsection
6319 movie.frame_subframes: Count subframes in frame
6322 \begin_layout Itemize
6323 Syntax: number movie.frame_subframes(number frame)
6326 \begin_layout Standard
6327 Count number of subframes in specified frame <frame> (frame numbers are
6328 1-based) and return that.
6331 \begin_layout Subsection
6332 movie.read_subframes: Read subframe data (deprecated)
6335 \begin_layout Itemize
6336 Syntax: table movie.read_subframes(number frame, number subframe)
6339 \begin_layout Standard
6340 Read specifed subframe in specified frame and return data as array.
6343 \begin_layout Subsection
6344 movie.read_rtc: Read current RTC time
6347 \begin_layout Itemize
6348 Syntax: (number, number) movie.read_rtc()
6351 \begin_layout Standard
6352 Returns the current value of the RTC as a pair (second, subsecond).
6355 \begin_layout Subsection
6356 movie.unsafe_rewind: Fast movie rewind to saved state
6359 \begin_layout Itemize
6360 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6363 \begin_layout Standard
6364 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6367 \begin_layout Itemize
6368 If called without argument, causes emulator to start process of setting
6369 unsafe rewind point.
6370 When this has finished, callback on_set_rewind occurs, passing the rewind
6371 state to lua script.
6374 \begin_layout Itemize
6375 If called with argument, causes emulator rewind to passed rewind point as
6377 recording mode is implicitly activated.
6380 \begin_layout Standard
6381 The following warnings apply to unsafe rewinding:
6384 \begin_layout Itemize
6385 There are no safety checks against misuse (that's what
6386 \begin_inset Quotes eld
6390 \begin_inset Quotes erd
6396 \begin_layout Itemize
6397 Only call rewind from timeline rewind point was set from.
6400 \begin_layout Itemize
6401 Only call rewind from after the rewind point was set.
6404 \begin_layout Subsection
6405 movie.to_rewind: Load savestate as rewind point
6408 \begin_layout Itemize
6409 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6412 \begin_layout Standard
6413 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6414 corresponding to it.
6417 \begin_layout Itemize
6418 Note: This operation does not take emulated time.
6421 \begin_layout Subsection
6422 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6425 \begin_layout Itemize
6426 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6429 \begin_layout Itemize
6430 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6433 \begin_layout Standard
6434 Copies specified movie or branch <movie>/current object (if none or nil,
6435 the active movie) as new movie object.
6438 \begin_layout Subsection
6439 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6442 \begin_layout Itemize
6443 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6446 \begin_layout Itemize
6447 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6450 \begin_layout Standard
6451 Get INPUTFRAME object corresponding to specified frame in specified movie
6455 \begin_layout Subsection
6456 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6459 \begin_layout Itemize
6460 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6464 \begin_layout Itemize
6465 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6468 \begin_layout Standard
6469 Set data in specified frame.
6472 \begin_layout Itemize
6473 Note: Past can't be edited in active movie.
6476 \begin_layout Subsection
6477 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6480 \begin_layout Itemize
6481 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6484 \begin_layout Itemize
6485 Syntax: integer INPUTMOVIE::get_size()
6488 \begin_layout Standard
6489 Return number of subframes in specified movie or branch.
6492 \begin_layout Subsection
6493 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6496 \begin_layout Itemize
6497 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6500 \begin_layout Itemize
6501 Syntax: number INPUTMOVIE::count_frames()
6504 \begin_layout Standard
6505 Return number of frames in movie.
6508 \begin_layout Subsection
6509 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6512 \begin_layout Itemize
6513 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6516 \begin_layout Itemize
6517 Syntax: number INPUTMOVIE::find_frame(number frame)
6520 \begin_layout Standard
6521 Returns starting subframe of given frame (frame numbers are 1-based).
6522 Returns -1 if frame number is bad.
6525 \begin_layout Subsection
6526 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6529 \begin_layout Itemize
6530 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6533 \begin_layout Itemize
6534 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6537 \begin_layout Standard
6538 Return blank INPUTFRAME with frame type from specified movie.
6541 \begin_layout Subsection
6542 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6545 \begin_layout Itemize
6546 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6549 \begin_layout Itemize
6550 Syntax: none INPUTMOVIE::append_frames(number frames)
6553 \begin_layout Standard
6554 Append specified number <frames> of frames.
6557 \begin_layout Subsection
6558 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
6561 \begin_layout Itemize
6562 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
6565 \begin_layout Itemize
6566 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
6569 \begin_layout Standard
6570 Append specified frame <frame>.
6571 Past of current movie can't be edited.
6574 \begin_layout Subsection
6575 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
6578 \begin_layout Itemize
6579 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
6582 \begin_layout Itemize
6583 Syntax: none INPUTMOVIE::truncate(number frames)
6586 \begin_layout Standard
6587 Truncate the specified movie to specified number of frames.
6590 \begin_layout Subsection
6591 movie.edit/INPUTMOVIE::edit: Edit a movie
6594 \begin_layout Itemize
6595 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
6596 controller, number control, number/bool value)
6599 \begin_layout Itemize
6600 Syntax: none movie.edit(string branch, number frame, number port, number
6601 controller, number control, number/bool value)
6604 \begin_layout Itemize
6605 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
6606 number control, number/bool value)
6609 \begin_layout Standard
6610 Change specified control in specified frame in specified movie.
6611 Past can't be edited in active movie.
6614 \begin_layout Subsection
6615 movie.copy_frames2: Copy frames between movies
6618 \begin_layout Itemize
6619 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
6620 IE/string srcmov,] number src, number count)
6623 \begin_layout Standard
6624 Copy specified number of frames between two movies.
6625 The copy proceeeds in forward direction.
6628 \begin_layout Subsection
6629 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
6632 \begin_layout Itemize
6633 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
6634 src, number count, bool backwards)
6637 \begin_layout Itemize
6638 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
6642 \begin_layout Standard
6643 Copy specified number of frames from one point in movie to another.
6644 If backwards is true, the copy will be done backwards.
6647 \begin_layout Subsection
6648 movie.serialize/INPUTMOVIE::serialize: Serialize movie
6651 \begin_layout Itemize
6652 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
6656 \begin_layout Itemize
6657 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
6660 \begin_layout Standard
6661 Serialize given movie into file.
6662 If binary is true, binary format (more compact and much faster) is used.
6665 \begin_layout Subsection
6666 movie.unserialize: Unserialize movie
6669 \begin_layout Itemize
6670 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
6674 \begin_layout Standard
6675 Unserialize movie from file.
6676 The given frame is used as template to decide the frame type.
6677 If binary is true, binary format is decoded (much faster).
6680 \begin_layout Subsection
6681 movie.current_first_subframe: Return first subframe in current frame
6684 \begin_layout Itemize
6685 Syntax: number movie.current_first_subframe()
6688 \begin_layout Standard
6689 Returns first subframe in current frame.
6692 \begin_layout Subsection
6693 movie.pollcounter: Return poll counter for speified control
6696 \begin_layout Itemize
6697 Syntax: number movie.pollcounter(number port, number controller, number control)
6700 \begin_layout Standard
6701 Returns number of times the specified control has been polled this frame.
6704 \begin_layout Subsection
6705 movie.current_branch: Return current branch
6708 \begin_layout Itemize
6709 Syntax: string movie.current_branch()
6712 \begin_layout Standard
6713 Returns the name of the current branch.
6716 \begin_layout Subsection
6717 movie.get_branches: Return names of all branches
6720 \begin_layout Itemize
6722 movie.get_branches()
6725 \begin_layout Standard
6726 Returns the name of all branches.
6729 \begin_layout Subsection
6730 INPUTFRAME::get_button: Get button
6733 \begin_layout Itemize
6734 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
6738 \begin_layout Standard
6739 Returns state of given button as boolean.
6742 \begin_layout Subsection
6743 INPUTFRAME::get_axis: Get axis
6746 \begin_layout Itemize
6747 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
6751 \begin_layout Standard
6752 Returns state of given axis as number.
6755 \begin_layout Subsection
6756 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
6759 \begin_layout Itemize
6760 Syntax: none INPUTFRAME::set_button(number port, number controller, number
6761 control, number/bool value)
6764 \begin_layout Itemize
6765 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
6769 \begin_layout Standard
6770 Set the given button/axis to given value.
6773 \begin_layout Subsection
6774 INPUTFRAME::serialize: Serialize a frame
6777 \begin_layout Itemize
6778 Syntax: string INPUTFRAME::serialize()
6781 \begin_layout Standard
6782 Return string representation of frame.
6785 \begin_layout Subsection
6786 INPUTFRAME::unserialize: Unserialize a frame
6789 \begin_layout Itemize
6790 Syntax: none INPUTFRAME::unserialize(string data)
6793 \begin_layout Standard
6794 Set current frame from given data.
6797 \begin_layout Subsection
6798 INPUTFRAME::get_stride: Get movie stride
6801 \begin_layout Itemize
6802 Syntax: number INPUTFRAME::get_stride()
6805 \begin_layout Standard
6806 Return number of bytes needed to store the input frame.
6807 Mainly useful for some debugging.
6810 \begin_layout Standard
6811 \begin_inset Newpage pagebreak
6817 \begin_layout Section
6821 \begin_layout Standard
6822 Routines for settings manipulation
6825 \begin_layout Subsection
6826 settings.get: Get value of setting
6829 \begin_layout Itemize
6830 Syntax: string settings.get(string name)
6833 \begin_layout Standard
6834 Get value of setting <name>.
6835 If setting value can't be obtained, returns (nil, error message).
6838 \begin_layout Subsection
6839 settings.set: Set value of setting
6842 \begin_layout Itemize
6843 Syntax: none settings.set(string name, string value)
6846 \begin_layout Standard
6847 Set value <value> of setting <name>.
6848 If setting can't be set, returns (nil, error message).
6851 \begin_layout Standard
6852 \begin_inset Newpage pagebreak
6858 \begin_layout Section
6862 \begin_layout Standard
6863 Contains various functions for managing memory
6866 \begin_layout Subsection
6867 memory.vma_count: Count number of memory areas.
6870 \begin_layout Itemize
6871 Syntax: number memory.vma_count()
6874 \begin_layout Standard
6875 Returns the number of memory areas
6878 \begin_layout Subsection
6879 memory.read_vma: Lookup memory area info by index
6882 \begin_layout Itemize
6883 Syntax: table memory.read_vma(number index)
6886 \begin_layout Standard
6887 Reads the specified memory area (indices start from zero).
6888 Trying to read invalid memory area gives nil.
6889 The return value is table with the following fields:
6892 \begin_layout Itemize
6893 region_name (string): The readable name of the memory area
6896 \begin_layout Itemize
6897 baseaddr (number): Base address of the memory area
6900 \begin_layout Itemize
6901 lastaddr (number): Last address in the memory area.
6904 \begin_layout Itemize
6905 size (number): The size of memory area in bytes.
6908 \begin_layout Itemize
6909 readonly (boolean): True of the memory area corresponds to ROM.
6912 \begin_layout Itemize
6913 iospace (boolean): True if the memory area is I/O space.
6916 \begin_layout Itemize
6917 native_endian (boolean): True if the memory area has native endian as opposed
6921 \begin_layout Subsection
6922 memory.find_vma: Find memory area info by address
6925 \begin_layout Itemize
6926 Syntax: table memory.find_vma(number address)
6929 \begin_layout Standard
6930 Finds the memory area containing specified address.
6931 Returns table in the same format as read_vma or nil if not found.
6934 \begin_layout Subsection
6935 memory.read{,s}{byte,{,h,d,q}word}: Read memory
6938 \begin_layout Itemize
6939 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
6942 \begin_layout Itemize
6943 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
6946 \begin_layout Itemize
6947 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
6950 \begin_layout Itemize
6951 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
6954 \begin_layout Itemize
6955 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
6958 \begin_layout Itemize
6959 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
6962 \begin_layout Itemize
6963 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
6966 \begin_layout Itemize
6967 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
6970 \begin_layout Itemize
6971 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
6974 \begin_layout Itemize
6975 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
6978 \begin_layout Standard
6979 Reads the specified address <address> (if 's' variant is used, do undergo
6983 \begin_layout Subsection
6984 memory.{,s}read_sg: Scatter/Gather read memory
6987 \begin_layout Itemize
6988 Syntax: none memory.read_sg(string/boolean/number...)
6991 \begin_layout Itemize
6992 Syntax: none memory.sread_sg(string/boolean/number...)
6995 \begin_layout Standard
6996 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
6998 Each argument can be string, boolean or number:
7001 \begin_layout Itemize
7002 String: Set memory area addresses are relative to (e.g.
7006 \begin_layout Itemize
7007 boolean: If true, increment relative address by 1, if false, decrement by
7009 The new address is read as next higher byte.
7012 \begin_layout Itemize
7013 integer: Set the relative address to specified value and read the address
7014 as next higher byte.
7017 \begin_layout Subsection
7018 memory.write_sg: Scatter/Gather write memory
7021 \begin_layout Itemize
7022 Syntax: none memory.write_sg(number value, string/boolean/number...)
7025 \begin_layout Standard
7026 Perform scatter/gather write of value <value> on memory.
7027 Each argument can be string, boolean or number:
7030 \begin_layout Itemize
7031 String: Set memory area addresses are relative to (e.g.
7035 \begin_layout Itemize
7036 boolean: If true, increment relative address by 1, if false, decrement by
7038 The new address is read as next higher byte.
7041 \begin_layout Itemize
7042 integer: Set the relative address to specified value and read the address
7043 as next higher byte.
7046 \begin_layout Subsection
7047 memory.read{float,double}: Read memory
7050 \begin_layout Itemize
7051 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7054 \begin_layout Itemize
7055 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7058 \begin_layout Standard
7059 Reads the specified address <address>
7062 \begin_layout Subsection
7063 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7066 \begin_layout Itemize
7067 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7071 \begin_layout Itemize
7072 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7076 \begin_layout Itemize
7077 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7081 \begin_layout Itemize
7082 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7086 \begin_layout Itemize
7087 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7091 \begin_layout Itemize
7092 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7096 \begin_layout Itemize
7097 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7101 \begin_layout Standard
7102 Writes the specified value <value> (negative integer values undergo 2's
7103 complement) to specified address <address>.
7106 \begin_layout Subsection
7107 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7110 \begin_layout Itemize
7111 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7115 \begin_layout Standard
7116 Returns a table mapping specified memory aperture for read/write.
7119 \begin_layout Itemize
7120 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7121 qword, sqword, float or double.
7124 \begin_layout Subsection
7125 memory.hash_region: Hash region of memory
7128 \begin_layout Itemize
7129 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7133 \begin_layout Standard
7134 Hash <size> bytes starting from address <base> (relative to <marea>) and
7138 \begin_layout Subsection
7139 memory.hash_region2: Hash region of memory
7142 \begin_layout Itemize
7143 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7144 number size[, number rows, number stride])
7147 \begin_layout Standard
7148 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7150 The blocks are offset by <stride> from one another and return the SHA-256.
7153 \begin_layout Subsection
7154 memory.hash_region_skein: Hash region of memory
7157 \begin_layout Itemize
7158 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7159 addrobj}, number size[, number rows, number stride])
7162 \begin_layout Standard
7163 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7164 finalists) as hash function.
7167 \begin_layout Subsection
7168 memory.store: Store region of memory
7171 \begin_layout Itemize
7172 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7173 daddr[, number rows, number stride]
7176 \begin_layout Standard
7177 Copy memory starting from <addr> in memory area <marea> (each row being
7178 of size <size>, there being <rows> rows, and rows being separated by <stride>
7179 in memory) into savestate-saved memory area, starting from <daadr> (all
7180 rows are written back to back).
7183 \begin_layout Subsection
7184 memory.storecmp: Compare and store region of memory
7187 \begin_layout Itemize
7188 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7189 number daddr[, number rows, number stride]
7192 \begin_layout Standard
7193 Like memory.store, but returns true if target of copy already held the value
7194 that would be copied before the copy happened.
7195 Otherwise returns false (if target and source differ before copy).
7198 \begin_layout Subsection
7199 memory.hash_state: Hash system state
7202 \begin_layout Itemize
7203 Syntax: string memory.hash_state()
7206 \begin_layout Standard
7207 Hash the current system state.
7208 Mainly useful for debugging savestates.
7211 \begin_layout Subsection
7212 memory.readregion: Read region of memory
7215 \begin_layout Itemize
7216 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7220 \begin_layout Standard
7221 Read a region of memory.
7224 \begin_layout Itemize
7225 Warning: If the region crosses memory area boundary, the results are undefined.
7228 \begin_layout Subsection
7229 memory.writeregion: Write region of memory
7232 \begin_layout Itemize
7233 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7234 number size, table data)
7237 \begin_layout Standard
7238 Write a region of memory.
7241 \begin_layout Itemize
7242 Warning: If the region crosses memory area boundary, the results are undefined.
7245 \begin_layout Subsection
7246 memory.action: Run core action
7249 \begin_layout Itemize
7250 memory.action(string action, [<params>])
7253 \begin_layout Standard
7255 The different models expect parameters as:
7258 \begin_layout Itemize
7262 \begin_layout Itemize
7266 \begin_layout Itemize
7270 \begin_layout Itemize
7274 \begin_layout Itemize
7278 \begin_layout Subsection
7279 memory.get_lag_flag: Get lag flag
7282 \begin_layout Itemize
7283 Syntax: boolean memory.get_lag_flag()
7286 \begin_layout Standard
7287 Get the value of core lag flag.
7288 True if this frame has been lag so far, false if poll has been detected.
7291 \begin_layout Subsection
7292 memory.set_lag_flag: Set lag flag
7295 \begin_layout Itemize
7296 Syntax: none memory.set_lag_flag(boolean flag)
7299 \begin_layout Standard
7300 Set the value of core lag flag.
7301 This flag automatically gets cleared if poll is detected, but can be forcibly
7302 set or cleared if game so requires.
7305 \begin_layout Itemize
7306 Should only be used in on_frame_emulated callback.
7309 \begin_layout Itemize
7310 Setting or clearing this affects the emulator lag counter.
7313 \begin_layout Subsection
7314 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7318 \begin_layout Itemize
7319 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
7323 \begin_layout Itemize
7324 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
7325 addrobj}, function fn);
7328 \begin_layout Itemize
7329 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
7333 \begin_layout Itemize
7334 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
7338 \begin_layout Itemize
7339 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
7343 \begin_layout Itemize
7344 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
7348 \begin_layout Standard
7349 Add or remove callback on memory read, write or execute (depending on the
7351 <addr> is relative to <marea>.
7352 <fn> is the callback.
7353 The register* functions return <fn> (which can then be passed to unregister*
7357 \begin_layout Itemize
7358 Not all cores support this, and it may be unsupported for some memory areas.
7361 \begin_layout Itemize
7362 The functions are passed two parameters: Address and value.
7365 \begin_layout Subsection
7366 memory.{,un}registertrace: Set/Clear trace hook
7369 \begin_layout Itemize
7370 Syntax: function memory.registertrace(number processor, function fn);
7373 \begin_layout Itemize
7374 Syntax: none memory.unregistertrace(number processor, function fn);
7377 \begin_layout Standard
7378 Add or remove trace callback.
7379 <processor> is system-dependent processor number (0 is usually main CPU).
7380 The function arguments work like in other (un)register* functions.
7383 \begin_layout Itemize
7384 The functions are passed two parameters: Trace CPU and Trace event string.
7387 \begin_layout Subsection
7388 memory.cheat: Set cheat
7391 \begin_layout Itemize
7392 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
7396 \begin_layout Itemize
7397 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
7400 \begin_layout Standard
7401 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
7402 If <value> is not speicified, clear a cheat.
7405 \begin_layout Itemize
7406 Not all cores support this, and it may be unsupported for some memory areas.
7409 \begin_layout Subsection
7410 memory.setxmask: Set global execute hook mask
7413 \begin_layout Itemize
7414 Syntax: none memory.setxmask(number mask)
7417 \begin_layout Standard
7418 Set the global execute hook mask to <mask>.
7419 The meaning of each bit is system-dependent, but bit 0 should be the main
7423 \begin_layout Subsection
7424 memory.getregister: Get register value
7427 \begin_layout Itemize
7428 Syntax: number/boolean memory.getregister(string register)
7431 \begin_layout Standard
7432 Get the value of named register.
7435 \begin_layout Subsection
7436 memory.getregisters: Get register values
7439 \begin_layout Itemize
7440 Syntax: table memory.getregisters()
7443 \begin_layout Standard
7444 Get the value of all known registers as table.
7447 \begin_layout Subsection
7448 memory.setregister: Set register value
7451 \begin_layout Itemize
7452 Syntax: none memory.setregister(string register, number/boolean value)
7455 \begin_layout Standard
7456 Set the value of named register.
7459 \begin_layout Subsection
7460 memory.mmap: Class MMAP_STRUCT
7463 \begin_layout Standard
7464 See class MMAP_STRUCT
7467 \begin_layout Standard
7468 \begin_inset Newpage pagebreak
7474 \begin_layout Section
7478 \begin_layout Standard
7479 Contains newer memory functions.
7482 \begin_layout Subsection
7483 memory2(): Get all memory area names.
7486 \begin_layout Itemize
7487 Syntax: table memory2()
7490 \begin_layout Standard
7491 Returns array of all valid memory area names.
7494 \begin_layout Subsection
7495 memory2.<marea>:info: Get memory area info
7498 \begin_layout Itemize
7499 Syntax: table memory2.<marea>:info()
7502 \begin_layout Standard
7503 Return table describing given memory area.
7504 Includes fields address, size, last, readonly, special and endian.
7507 \begin_layout Subsection
7508 memory2.<marea>:<op>: Read/Write memory
7511 \begin_layout Itemize
7512 Syntax: none memory2.<marea>:<op>(number offset, number value)
7515 \begin_layout Itemize
7516 Syntax: number memory2.<marea>:<op>(number offset)
7519 \begin_layout Standard
7520 Read/Write value from/to given memory area <marea> at given offset <offset>
7522 The value written is <value>.
7523 <Op> is of form: [i][s]<type>, where:
7526 \begin_layout Itemize
7527 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
7530 \begin_layout Itemize
7531 'i' signifies that the value is treated as opposite-to-normal endianess,
7534 \begin_layout Itemize
7535 's' signifies that value is treated as signed (not available for floating-point).
7538 \begin_layout Subsection
7539 memory2.<marea>:read: Scatter-gather value read
7542 \begin_layout Itemize
7543 Syntax: number memory2.<marea>:read(number addr...)
7546 \begin_layout Standard
7547 Read value from given memory area <marea> at byte offsets <addr>..., given
7548 in order of increasing significance.
7549 Value of true and false are special.
7550 True increments address by 1, and false decrements address by 1.
7553 \begin_layout Subsection
7554 memory2.<marea>:sread: Signed scatter-gather value read
7557 \begin_layout Itemize
7558 Syntax: number memory2.<marea>:sread(number addr...)
7561 \begin_layout Standard
7562 Like memory2.<marea>:read, but reads signed values.
7565 \begin_layout Subsection
7566 memory2.<marea>:write: Scatter-gather value write
7569 \begin_layout Itemize
7570 Syntax: number memory2.<marea>:write(number val, number addr...)
7573 \begin_layout Standard
7574 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
7575 in order of increasing significance.
7576 Value of true and false are special.
7577 True increments address by 1, and false decrements address by 1.
7580 \begin_layout Subsection
7581 memory2.<marea>:cheat: Set/Clear cheat
7584 \begin_layout Itemize
7585 Syntax: none memory2.<marea>:cheat(number addr, [number value])
7588 \begin_layout Standard
7589 Set/Clear cheat at offset <addr> of memory area <marea>.
7590 If <value> is given, cheat with specified value is set.
7591 Otherwise cheat on address is removed.
7594 \begin_layout Subsection
7595 memory2.<marea>:sha256: SHA-256
7598 \begin_layout Itemize
7599 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
7603 \begin_layout Standard
7604 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
7605 from offset <addr> of area <marea>.
7606 The chunks are separated by <stride>.
7609 \begin_layout Subsection
7610 memory2.<marea>:skein: Skein-512-256
7613 \begin_layout Itemize
7614 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
7618 \begin_layout Standard
7619 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
7622 \begin_layout Subsection
7623 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
7626 \begin_layout Itemize
7627 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
7628 number rows, number stride])
7631 \begin_layout Itemize
7632 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
7633 size[, number rows, number stride])
7636 \begin_layout Standard
7637 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
7638 <addr> of area <marea>.
7639 The chunks are separated by <stride>.
7640 The target is Lua host memory, starting from offset <daddr>.
7643 \begin_layout Standard
7644 Additionally, the storecmp method returns false if target was modified (otherwis
7648 \begin_layout Subsection
7649 memory2.<marea>:readregion: Read region
7652 \begin_layout Itemize
7653 Syntax table memory2.<marea>:readregion(number addr, number size)
7656 \begin_layout Standard
7657 Read <size> bytes starting from <addr> in <marea> and return as array.
7660 \begin_layout Subsection
7661 memory2.<marea>:writeregion: Write region
7664 \begin_layout Itemize
7665 Syntax none memory2.<marea>:writeregion(number addr, table data)
7668 \begin_layout Standard
7669 Write array <data> to bytes starting from <addr> in <marea>.
7672 \begin_layout Subsection
7673 memory2.<marea>:register{read,write,exec}: Register hook
7676 \begin_layout Itemize
7677 Syntax: function memory2.<marea>:registerread(number addr, function fn);
7680 \begin_layout Itemize
7681 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
7684 \begin_layout Itemize
7685 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
7688 \begin_layout Standard
7689 Register debug callback <fn> of specified type at offset <addr> of memory
7694 \begin_layout Subsection
7695 memory2.<marea>:unregister{read,write,exec}: Unregister hook
7698 \begin_layout Itemize
7699 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
7702 \begin_layout Itemize
7703 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
7706 \begin_layout Itemize
7707 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
7710 \begin_layout Standard
7711 Unregister debug callback <fn> of specified type at offset <addr> of memory
7715 \begin_layout Standard
7716 \begin_inset Newpage pagebreak
7722 \begin_layout Section
7726 \begin_layout Standard
7727 Contains random number generation methods.
7728 These functions do not return reproducable results.
7731 \begin_layout Subsection
7732 random.boolean: Random boolean
7735 \begin_layout Itemize
7736 Syntax: boolean random.boolean()
7739 \begin_layout Standard
7740 Returns true or false at random (50-50 chance).
7743 \begin_layout Subsection
7744 random.integer: Random integer
7747 \begin_layout Itemize
7748 Syntax: number random.integer(number highplusone)
7751 \begin_layout Itemize
7752 Syntax: number random.integer(number low, number high)
7755 \begin_layout Standard
7756 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
7757 With two arguments, return random integer [<low>,<high>] (both ends inclusive).
7760 \begin_layout Standard
7761 The returned numbers are from uniform distribution.
7764 \begin_layout Subsection
7765 random.float: Random float
7768 \begin_layout Itemize
7769 Syntax: number random.float()
7772 \begin_layout Standard
7773 Returns random decimal number [0,1).
7776 \begin_layout Subsection
7777 random.among: Random parameter
7780 \begin_layout Itemize
7781 Syntax: value random.among(value values...)
7784 \begin_layout Standard
7785 Returns random parameter value, picked at uniform.
7786 Multiple equivalent values are returned with higher chance.
7789 \begin_layout Subsection
7790 random.amongtable: Random from table
7793 \begin_layout Itemize
7794 Syntax: value random.amongtable(table tab)
7797 \begin_layout Standard
7798 Returns random value from table <tab>.
7799 As in random.among, no equality testing is done.
7802 \begin_layout Standard
7803 \begin_inset Newpage pagebreak
7809 \begin_layout Section
7813 \begin_layout Subsection
7814 zip.enumerate: Enumerate members in zipfile
7817 \begin_layout Itemize
7818 Syntax: Table zip.enumerate(string filename[, boolean invert])
7821 \begin_layout Standard
7822 Returns table of files in zip archive <filename>.
7823 If <invert> is true, instead of returning array of names, returns table
7824 with keys being member names and values being true.
7827 \begin_layout Subsection
7828 zip.writer: Class ZIPWRITER
7831 \begin_layout Standard
7832 See class ZIPWRITER.
7835 \begin_layout Standard
7836 \begin_inset Newpage pagebreak
7842 \begin_layout Section
7846 \begin_layout Standard
7847 Various callback-related functions.
7850 \begin_layout Subsection
7851 \begin_inset CommandInset label
7853 name "sub:callback.register:-Register-a"
7857 callback.register: Register a callback
7860 \begin_layout Itemize
7861 Syntax: function callback.register(string cbname, function cbfun);
7864 \begin_layout Standard
7865 Instruct function <cbfun> to be added to list of callbacks to call on event
7866 <cbname> (See section
7867 \begin_inset CommandInset ref
7869 reference "sec:Callbacks"
7874 The callback name does not have the 'on_' prefix (e.g.
7876 \begin_inset Quotes eld
7880 \begin_inset Quotes erd
7887 \begin_layout Subsection
7888 \begin_inset CommandInset label
7890 name "sub:callback.unregister:-Unregister-"
7894 callback.unregister: Unregister a callback
7897 \begin_layout Itemize
7898 Syntax: function callback.unregister(string cbname, function cbfun);
7901 \begin_layout Standard
7902 Instruct function <cbfun> to be removed from list of callbacks to call on
7906 \begin_layout Subsection
7907 callback.<cbname>:register: Register callback
7910 \begin_layout Itemize
7911 Syntax: function callback.<cbname>:register(function cbfun)
7914 \begin_layout Standard
7915 Synonym for callback.register (section
7916 \begin_inset CommandInset ref
7918 reference "sub:callback.register:-Register-a"
7922 ), albeit with callback name specified differently.
7925 \begin_layout Subsection
7926 callback.<cbname>:unregister: Register callback
7929 \begin_layout Itemize
7930 Syntax: function callback.<cbname>:unregister(function cbfun)
7933 \begin_layout Standard
7934 Synonym for callback.unregister (section
7935 \begin_inset CommandInset ref
7937 reference "sub:callback.unregister:-Unregister-"
7941 ), albeit with callback name specified differently.
7944 \begin_layout Section
7948 \begin_layout Standard
7949 Various bsnes-specific functions.
7952 \begin_layout Subsection
7953 bsnes.dump_sprite: Dump a sprite
7956 \begin_layout Itemize
7957 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
7958 number height[, number stride])
7961 \begin_layout Standard
7962 Dumps given sprite (in native format) from memory.
7963 memory area is usually
7964 \begin_inset Quotes eld
7968 \begin_inset Quotes erd
7972 <Width> and <height> are given in 8x8 blocks.
7973 <Stride> overrides row stride (default 512).
7976 \begin_layout Subsection
7977 bsnes.dump_palette: Dump a palette
7980 \begin_layout Itemize
7981 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool full256,
7985 \begin_layout Standard
7986 Dumps a palette from memory.
7987 memory area is usually
7988 \begin_inset Quotes eld
7992 \begin_inset Quotes erd
7996 If <full256> is true, 256 colors are dumped (otherwise 16).
7997 If <first_trans> is true, first color is forced transparent.
8000 \begin_layout Subsection
8001 bsnes.enablelayer: Set layer visibility
8004 \begin_layout Itemize
8005 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8008 \begin_layout Standard
8009 Enable or disable specified layer at specified priority.
8012 \begin_layout Subsection
8013 bsnes.redump_sprite: Redump a sprite
8016 \begin_layout Itemize
8017 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8021 \begin_layout Standard
8022 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8023 The specified bitmap must have size multiple of 8x8.
8026 \begin_layout Subsection
8027 bsnes.redump_palette: Redump a palette
8030 \begin_layout Itemize
8031 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8035 \begin_layout Standard
8036 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8037 The specified palette must have either 16 or 256 colors.
8040 \begin_layout Section
8041 extensions to table string
8044 \begin_layout Subsection
8045 string.charU: string.char, UTF-8 version.
8048 \begin_layout Itemize
8049 Syntax: string string.charU(number n...)
8052 \begin_layout Standard
8053 Like Lua string.char(), but works in terms of Unicode codepoints.
8054 The returned string is UTF-8.
8057 \begin_layout Subsection
8058 string.byteU: string.byte, UTF-8 version.
8061 \begin_layout Itemize
8063 string.byteU(string str[, number i[, number j]])
8066 \begin_layout Standard
8067 Like string.byte(), but works in terms of Unicode codepoints.
8068 The input string <str> is assumed UTF-8.
8071 \begin_layout Subsection
8072 string.regex: Match string against regular expression
8075 \begin_layout Itemize
8076 Syntax: boolean/string...
8077 string.regex(string regexp, string against)
8080 \begin_layout Standard
8081 Match POSIX-extended regular expression <regexp> against string <against>.
8082 If no match, false is returned.
8083 Otherwise if string has no subcaptures, true is returned.
8084 Otherwise each subcapture is returned as a string (in order of starting
8088 \begin_layout Subsection
8089 string.hex: Transform integer into hex string
8092 \begin_layout Itemize
8093 Syntax: string string.hex(number n, [number digits])
8096 \begin_layout Standard
8097 Returns hexadecimal string representation of <n>, optionally padded with
8098 zeroes to <digits> digits (default is not to pad).
8101 \begin_layout Subsection
8102 string.lpad: Pad string with spaces from left
8105 \begin_layout Itemize
8106 Syntax: string string.lpad(string x, number n)
8109 \begin_layout Standard
8110 Pad string <x> to <n> bytes by inserting spaces at start and return the
8114 \begin_layout Subsection
8115 string.rpad: Pad string with spaces from right
8118 \begin_layout Itemize
8119 Syntax: string string.rpad(string x, number n)
8122 \begin_layout Standard
8123 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8126 \begin_layout Section
8130 \begin_layout Standard
8131 Contains copy of global variables from time of Lua initialization.
8135 \begin_layout Standard
8136 \begin_inset Newpage pagebreak
8142 \begin_layout Section
8143 \begin_inset CommandInset label
8145 name "sec:Callbacks"
8152 \begin_layout Standard
8153 Various callbacks to Lua that can occur.
8156 \begin_layout Subsection
8157 on_paint: Screen is being painted
8160 \begin_layout Itemize
8161 Callback: on_paint(bool not_synth)
8164 \begin_layout Standard
8165 Called when screen is being painted.
8166 Any gui.* calls requiring graphic context draw on the screen.
8169 \begin_layout Itemize
8170 not_synth is true if this hook is being called in response to received frame,
8174 \begin_layout Subsection
8175 on_video: Dumped video frame is being painted
8178 \begin_layout Itemize
8179 Callback: on_video()
8182 \begin_layout Standard
8183 Called when video dump frame is being painted.
8184 Any gui.* calls requiring graphic context draw on the video.
8187 \begin_layout Subsection
8188 on_frame_emulated: Frame emulation complete
8191 \begin_layout Itemize
8192 Callback: on_frame_emulated()
8195 \begin_layout Standard
8196 Called when emulating frame has completed and on_paint()/on_video() calls
8197 are about to be issued.
8200 \begin_layout Subsection
8201 on_frame: Frame emulation starting.
8204 \begin_layout Itemize
8205 Callback: on_frame()
8208 \begin_layout Standard
8209 Called on each starting whole frame.
8212 \begin_layout Subsection
8213 on_rewind: Movie rewound to beginning
8216 \begin_layout Itemize
8217 Callback: on_rewind()
8220 \begin_layout Standard
8221 Called when rewind movie to beginning has completed.
8224 \begin_layout Subsection
8225 on_pre_load: Load operation is about to start
8228 \begin_layout Itemize
8229 Callback: on_pre_load(string name)
8232 \begin_layout Standard
8233 Called just before savestate/movie load occurs (note: loads are always delayed,
8234 so this occurs even when load was initiated by lua).
8237 \begin_layout Subsection
8238 on_err_Load: Load failed
8241 \begin_layout Itemize
8242 Callback: on_err_load(string name)
8245 \begin_layout Standard
8246 Called if loadstate goes wrong.
8249 \begin_layout Subsection
8250 on_post_load: Load completed
8253 \begin_layout Itemize
8254 Callback: on_post_load(string name, boolean was_savestate)
8257 \begin_layout Standard
8258 Called on successful loadstate.
8259 was_savestate gives if this was a savestate or a movie.
8262 \begin_layout Subsection
8263 on_pre_save: Save operation is about to start
8266 \begin_layout Itemize
8267 Callback: on_pre_save(string name, boolean is_savestate)
8270 \begin_layout Standard
8271 Called just before savestate save occurs (note: movie saves are synchronous
8272 and won't trigger these callbacks if called from Lua).
8275 \begin_layout Subsection
8276 on_err_save: Save failed
8279 \begin_layout Itemize
8280 Callback: on_err_save(string name)
8283 \begin_layout Standard
8284 Called if savestate goes wrong.
8287 \begin_layout Subsection
8288 on_post_save: Save completed
8291 \begin_layout Itemize
8292 Callback: on_post_save(string name, boolean is_savestate)
8295 \begin_layout Standard
8296 Called on successful savaestate.
8297 is_savestate gives if this was a savestate or a movie.
8300 \begin_layout Subsection
8301 on_quit: Emulator is shutting down
8304 \begin_layout Itemize
8308 \begin_layout Standard
8309 Called when emulator is shutting down.
8312 \begin_layout Subsection
8313 on_input: Polling for input
8316 \begin_layout Standard
8317 Called when emulator is just sending input to bsnes core.
8318 Warning: This is called even in readonly mode, but the results are ignored.
8321 \begin_layout Subsection
8322 on_reset: System has been reset
8325 \begin_layout Itemize
8326 Callback: on_reset()
8329 \begin_layout Standard
8330 Called when system is reset.
8333 \begin_layout Subsection
8334 on_readwrite: Entered recording mode
8337 \begin_layout Itemize
8338 Callback: on_readwrite()
8341 \begin_layout Standard
8342 Called when moving into recording mode as result of
8343 \begin_inset Quotes eld
8347 \begin_inset Quotes erd
8350 command (note: moving to rwmode by Lua won't trigger this, as per recursive
8354 \begin_layout Subsection
8355 on_snoop/on_snoop2: Snoop core controller reads
8358 \begin_layout Itemize
8359 Callback: on_snoop(number port, number controller, number index, number
8363 \begin_layout Itemize
8364 Callback: on_snoop2(number port, number controller, number index, number
8368 \begin_layout Standard
8369 Called each time bsnes asks for input.
8370 The value is the final value to be sent to bsnes core (readonly mode, autohold
8371 and autofire have been taken into account).
8372 Might be useful when translating movies to format suitable for console
8374 Note: There is no way to modify the value to be sent.
8377 \begin_layout Itemize
8378 On_snoop2 is called instead of on_snoop if defined.
8379 Reserves port 0 for system, having first user port be port 1.
8382 \begin_layout Subsection
8383 on_keyhook: Hooked key/axis has been moved
8386 \begin_layout Itemize
8387 Callback: on_keyhook(string keyname, table state)
8390 \begin_layout Standard
8391 Sent when key that has keyhook events requested changes state.
8392 Keyname is name of the key (group) and state is the state (same kind as
8393 table values in input.raw).
8396 \begin_layout Subsection
8400 \begin_layout Itemize
8404 \begin_layout Standard
8405 Called when requested by set_idle_timeout(), the timeout has expired and
8406 emulator is waiting.
8409 \begin_layout Subsection
8410 on_timer: Timer event
8413 \begin_layout Itemize
8414 Callback: on_timer()
8417 \begin_layout Standard
8418 Called when requested by set_idle_timeout() and the timeout has expired
8419 (regardless if emulator is waiting).
8422 \begin_layout Subsection
8423 on_set_rewind: Rewind point has been set
8426 \begin_layout Itemize
8427 Callback: on_set_rewind(UNSAFEREWIND r)
8430 \begin_layout Standard
8431 Called when unsafe rewind object has been constructed.
8434 \begin_layout Subsection
8435 on_pre_rewind: Rewind is about to occur
8438 \begin_layout Itemize
8439 Callback: on_pre_rewind()
8442 \begin_layout Standard
8443 Called just before unsafe rewind is about to occur.
8446 \begin_layout Subsection
8447 on_post_rewind: Rewind has occured
8450 \begin_layout Itemize
8451 Callback: on_post_rewind()
8454 \begin_layout Standard
8455 Called just after unsafe rewind has occured.
8458 \begin_layout Subsection
8459 on_button: Button has been pressed
8462 \begin_layout Itemize
8463 Callback: on_button(number port, number controller, number index, string
8467 \begin_layout Standard
8468 Called on controller button press, with following parameters:
8471 \begin_layout Itemize
8472 port: Port number (0 is system)
8475 \begin_layout Itemize
8476 controller: Controller within port
8479 \begin_layout Itemize
8480 index: Index of button.
8483 \begin_layout Itemize
8484 type: Type of event, one of:
8488 \begin_layout Itemize
8489 \begin_inset Quotes eld
8493 \begin_inset Quotes erd
8496 : Button was pressed.
8499 \begin_layout Itemize
8500 \begin_inset Quotes eld
8504 \begin_inset Quotes erd
8507 : Button was released.
8510 \begin_layout Itemize
8511 \begin_inset Quotes eld
8515 \begin_inset Quotes erd
8521 \begin_layout Itemize
8522 \begin_inset Quotes eld
8526 \begin_inset Quotes erd
8529 : Released from hold.
8532 \begin_layout Itemize
8533 \begin_inset Quotes eld
8537 \begin_inset Quotes erd
8540 : Typing input on button.
8543 \begin_layout Itemize
8544 \begin_inset Quotes eld
8548 \begin_inset Quotes erd
8551 : Typing input undone.
8554 \begin_layout Itemize
8555 \begin_inset Quotes eld
8558 autofire <duty> <cycle>
8559 \begin_inset Quotes erd
8562 : Autofire with specifie duty and cycle.
8565 \begin_layout Itemize
8566 \begin_inset Quotes eld
8570 \begin_inset Quotes erd
8576 \begin_layout Itemize
8577 \begin_inset Quotes eld
8581 \begin_inset Quotes erd
8584 : Analog action on axis.
8588 \begin_layout Subsection
8589 on_movie_lost: Movie data is about to be lost
8592 \begin_layout Itemize
8593 Callback: on_movie_lost(STRING kind)
8596 \begin_layout Standard
8597 Called just before something would happen that could lose movie data.
8601 \begin_layout Itemize
8602 readwrite: Switching to recording mode.
8605 \begin_layout Itemize
8606 reload: ROM is being reloaded in recording mode.
8609 \begin_layout Itemize
8610 load: New movie is being loaded.
8613 \begin_layout Itemize
8614 unsaferewind: Unsafe rewind is happening.
8617 \begin_layout Subsection
8618 on_latch: Latch line is rising
8621 \begin_layout Itemize
8622 Callback: on_latch(<core-dependent-parameters>)
8625 \begin_layout Standard
8626 Called when latch line for controller is rising.
8627 Some cores may not support this.
8630 \begin_layout Section
8631 System-dependent behaviour
8634 \begin_layout Subsection
8638 \begin_layout Itemize
8639 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
8640 p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
8641 p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
8642 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
8643 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
8644 ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
8645 ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
8646 ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
8647 ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
8648 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
8649 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
8650 ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
8651 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
8652 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
8653 ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
8654 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
8655 ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
8656 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
8657 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
8658 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
8659 ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
8660 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
8661 ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
8662 ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
8663 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
8664 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
8665 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
8666 ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
8667 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
8668 ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
8669 ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
8670 ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
8671 ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
8672 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
8673 ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
8674 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
8675 ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
8676 ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
8677 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
8678 ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount,
8681 \begin_layout Itemize
8682 on_latch has no parameters
8685 \begin_layout Itemize
8686 CPU 0 is S-CPU, 1 is S-SMP.
8689 \begin_layout Itemize
8690 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
8693 \begin_layout Itemize
8694 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
8698 \begin_layout Itemize
8699 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
8700 DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
8701 BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
8702 GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
8705 \begin_layout Subsection
8709 \begin_layout Itemize
8710 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
8714 \begin_layout Itemize
8715 on_latch is not supported
8718 \begin_layout Itemize
8722 \begin_layout Itemize
8723 Cheats are supported for ROM, SRAM and WRAM.
8726 \begin_layout Itemize
8727 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
8731 \begin_layout Itemize
8732 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.