1 #LyX 2.3 created this file. For more info see http://www.lyx.org/
5 \save_transient_properties true
8 \use_default_options true
9 \maintain_unincluded_children false
11 \language_package default
14 \font_roman "default" "default"
15 \font_sans "default" "default"
16 \font_typewriter "default" "default"
17 \font_math "auto" "auto"
18 \font_default_family default
19 \use_non_tex_fonts false
22 \font_sf_scale 100 100
23 \font_tt_scale 100 100
25 \use_dash_ligatures true
27 \default_output_format default
29 \bibtex_command default
30 \index_command default
31 \paperfontsize default
35 \pdf_bookmarksnumbered false
36 \pdf_bookmarksopen false
37 \pdf_bookmarksopenlevel 1
45 \use_package amsmath 1
46 \use_package amssymb 1
49 \use_package mathdots 1
50 \use_package mathtools 1
52 \use_package stackrel 1
53 \use_package stmaryrd 1
54 \use_package undertilde 1
56 \cite_engine_type default
60 \paperorientation portrait
78 \paragraph_separation indent
79 \paragraph_indentation default
81 \math_numbering_side default
86 \paperpagestyle default
87 \tracking_changes false
97 lsnes Lua functions reference
100 \begin_layout Section
104 \begin_layout Standard
105 \begin_inset CommandInset toc
106 LatexCommand tableofcontents
113 \begin_layout Standard
114 \begin_inset Newpage pagebreak
120 \begin_layout Section
124 \begin_layout Subsection
128 \begin_layout Itemize
129 Coordinates increase to right and down.
132 \begin_layout Itemize
133 The origin is at top left of game area or buffer.
136 \begin_layout Subsection
140 \begin_layout Itemize
141 Methods that draw something (unless stated otherwise) require a valid rendering
143 This context can come in three ways:
144 \begin_inset Separator latexpar
151 \begin_layout Enumerate
152 The default rendering context of paint callback (the screen).
155 \begin_layout Enumerate
156 The default rendering context of video callback (the video).
159 \begin_layout Enumerate
160 Explicitly set rendering context (RENDERCTX:set).
164 \begin_layout Itemize
165 The rendering context is always reset when callback ends.
168 \begin_layout Subsection
172 \begin_layout Standard
173 (Direct) colors can be specified either as numbers or strings.
176 \begin_layout Itemize
177 -1 is fully transparent.
180 \begin_layout Itemize
181 Non-negative numbers less than
182 \begin_inset Formula $2^{32}$
185 are partially opaque colors (
186 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
190 \begin_inset Separator latexpar
197 \begin_layout Itemize
198 \begin_inset Formula $a$
202 \begin_inset Formula $0-255$
206 \begin_inset Formula $0$
210 \begin_inset Formula $256$
213 would be fully transparent.
214 \begin_inset Separator latexpar
221 \begin_layout Itemize
222 Thus, numbers in range
223 \begin_inset Formula $0-16777215$
226 stand for fully opaque colors.
230 \begin_layout Itemize
231 \begin_inset Formula $r$
235 \begin_inset Formula $g$
239 \begin_inset Formula $b$
242 are intensities of base colors on scale
243 \begin_inset Formula $0-255$
250 \begin_layout Itemize
251 Color can also be specified by name as string: The following color names
252 are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
253 antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
254 azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
255 bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
256 brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
257 burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
258 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
259 chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
260 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
261 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
262 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
263 darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
264 darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
265 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
266 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
267 darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
268 darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
269 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
270 dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
271 firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
272 fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
273 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
274 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
275 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
276 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
277 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
278 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
279 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
280 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
281 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
282 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
283 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
284 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
285 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
286 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
287 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
288 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
289 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
290 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
291 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
292 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
293 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
294 indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
295 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
296 lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
297 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
298 lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
299 lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
300 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
301 lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
302 lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
303 lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
304 lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
305 lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
306 lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
307 maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
308 mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
309 mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
310 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
311 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
312 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
313 navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
314 olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
315 orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
316 palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
317 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
318 palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
319 peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
320 pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
321 purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
322 rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
323 saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
324 seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
325 seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
326 skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
327 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
328 snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
329 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
330 tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
331 tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
332 turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
333 wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
334 yellow3 yellow4 yellowgreen
337 \begin_layout Itemize
338 The HSL base color names: hsl-<hue><saturation><lightness>.
339 \begin_inset Separator latexpar
346 \begin_layout Itemize
347 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
348 y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
349 (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
352 \begin_layout Itemize
353 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
356 \begin_layout Itemize
357 Lightness is 0-8, where 0 is black and 8 is white.
361 \begin_layout Itemize
362 The color names can have a modifier after space (multiple modifiers are
363 allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
364 opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
365 hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
366 \begin_inset Separator latexpar
373 \begin_layout Itemize
374 opaqueness is measured as percentage.
377 \begin_layout Itemize
378 Hue adjustments are on 24-step scale.
381 \begin_layout Itemize
382 Saturation and lightness adjustments are on 16-step scale.
386 \begin_layout Section
390 \begin_layout Standard
391 These tokens are special, and are expanded while the script is being loaded
394 \begin_layout Subsection
395 @@LUA_SCRIPT_FILENAME@@
398 \begin_layout Standard
399 Expanded to string token containing path and filename of this Lua script.
400 Handy for referencing other lua scripts or resources that are relative
404 \begin_layout Standard
405 In practicular, this is suitable to be passed as base argument of various
406 functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
407 ad_png and gui.bitmap_load_pal.
410 \begin_layout Section
414 \begin_layout Subsection
415 MMAP_STRUCT: Quasi-table mapping emulated memory
418 \begin_layout Standard
419 Objects act like tables, but the values reflect emulated memory.
422 \begin_layout Subsubsection
423 static function new: Create a new instance
426 \begin_layout Itemize
427 Syntax: mmap memory.mmap.new()
430 \begin_layout Itemize
431 Syntax: mmap classes.MMAP_STRUCT.new()
434 \begin_layout Standard
438 \begin_layout Itemize
439 mmap: MMAP_STRUCT: The created mmap structure.
442 \begin_layout Standard
443 Create a new object (with no mappings) and return it.
446 \begin_layout Subsubsection
447 operator(): Bind key in mmap structure
450 \begin_layout Itemize
451 Syntax: obj(key, {marea, address|addrobj}, type)
454 \begin_layout Standard
458 \begin_layout Itemize
459 obj: MMAP_STRUCT: The structure to manipulate.
462 \begin_layout Itemize
463 key: String: The name of the key in array to map.
466 \begin_layout Itemize
467 marea: String: The memory area the mapped address is in (default: global
471 \begin_layout Itemize
472 address: Number: The offset of memory addreess, relative to specified memory
473 area or global memory space.
476 \begin_layout Itemize
477 addrobj: ADDRESS: The memory address.
480 \begin_layout Itemize
481 type: String: The type of data to map.
482 \begin_inset Separator latexpar
489 \begin_layout Itemize
490 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
495 \begin_layout Standard
496 Bind key <key> in mmap structure <obj> to address <address> (relative to
498 The memory address is treated as type <type>.
501 \begin_layout Itemize
503 \begin_inset Quotes eld
507 \begin_inset Quotes erd
511 \begin_inset Quotes eld
515 \begin_inset Quotes erd
519 \begin_inset Quotes eld
523 \begin_inset Quotes erd
529 \begin_layout Standard
530 This binds signed word at address WRAM+0x2A into key
531 \begin_inset Quotes eld
535 \begin_inset Quotes erd
541 \begin_layout Standard
542 \begin_inset Newpage pagebreak
548 \begin_layout Subsection
549 ZIPWRITER: Write .zip files
552 \begin_layout Standard
553 This class does writing of .zip files.
556 \begin_layout Subsubsection
557 Static function new: Create a new zipfile
560 \begin_layout Itemize
561 Syntax: zip zip.writer.new(filename, [compression])
564 \begin_layout Itemize
565 Deprecated: zip zip.create(filename, [compression])
568 \begin_layout Standard
572 \begin_layout Itemize
573 filename: string: The name of the file to write.
576 \begin_layout Itemize
577 compression: number: Compression level (0-9).
581 \begin_layout Standard
585 \begin_layout Itemize
586 zip: ZIPWRITER: The newly created ZIP writer.
589 \begin_layout Standard
590 Create a new ZIPWRITER object and return it.
593 \begin_layout Subsubsection
594 Method commit: Finish creating ZIP file.
597 \begin_layout Itemize
598 Syntax: zipfile:commit()
601 \begin_layout Standard
605 \begin_layout Itemize
606 zipfile: ZIPFILE: The ZIP file object.
609 \begin_layout Standard
610 Finish writing the ZIP file and actually create it on disk.
613 \begin_layout Itemize
614 If a member is currently open, it is implicitly closed.
617 \begin_layout Itemize
618 Invoking this on already committed or rolled back zipfile causes an error.
621 \begin_layout Subsubsection
622 Method rollback: Cancel writing the ZIP file.
625 \begin_layout Itemize
626 Syntax: zipfile:rollback()
629 \begin_layout Standard
633 \begin_layout Itemize
634 zipfile: ZIPFILE: The ZIP file object.
637 \begin_layout Standard
638 Cancel writing the whole ZIP file.
639 The file on disk will not be modified.
642 \begin_layout Itemize
643 If a member is currently open, it is implicitly closed.
646 \begin_layout Itemize
647 Invoking this on already committed or rolled back zipfile causes an error.
650 \begin_layout Subsubsection
651 Method create_file: Start writing a new member
654 \begin_layout Itemize
655 Syntax: zipfile:create_file(filename)
658 \begin_layout Standard
662 \begin_layout Itemize
663 zipfile: ZIPFILE: The ZIP file object.
666 \begin_layout Itemize
667 string filename: Name of the new member to create
670 \begin_layout Standard
671 Start writing a new member <filename> in ZIP file.
674 \begin_layout Itemize
675 If a member is currently open, it is implicitly closed.
678 \begin_layout Itemize
679 Invoking this on already committed or rolled back zipfile causes an error.
682 \begin_layout Subsubsection
683 Method close_file: Close member
686 \begin_layout Itemize
687 Syntax: zipfile:close_file()
690 \begin_layout Standard
694 \begin_layout Itemize
695 zipfile: ZIPFILE: The ZIP file object.
698 \begin_layout Standard
699 Close the currently open member in zipfile.
702 \begin_layout Itemize
703 Invoking this on already committed or rolled back zipfile causes an error.
706 \begin_layout Itemize
707 Invoking this without an open member causes an error.
710 \begin_layout Subsubsection
711 Method write: Write data
714 \begin_layout Itemize
715 Syntax: zipfile:write(data)
718 \begin_layout Standard
722 \begin_layout Itemize
723 zipfile: ZIPFILE: The ZIP file object.
726 \begin_layout Itemize
727 data: string: The data to write.
730 \begin_layout Standard
731 Write <data> in binary mode (as-is) to currently open member.
734 \begin_layout Itemize
735 Invoking this without a member being open causes an error.
738 \begin_layout Standard
739 \begin_inset Newpage pagebreak
745 \begin_layout Subsection
746 TILEMAP: Tiled collection of bitmaps.
749 \begin_layout Standard
750 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
753 \begin_layout Subsubsection
754 Static function new: Create a tilemap
757 \begin_layout Itemize
758 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
761 \begin_layout Itemize
762 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
765 \begin_layout Itemize
766 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
769 \begin_layout Standard
773 \begin_layout Itemize
774 w: number: Width of the tilemap in tiles
777 \begin_layout Itemize
778 h: number: Height of the tilemap in tiles
781 \begin_layout Itemize
782 bw: number: Width of each tile in pixels.
785 \begin_layout Itemize
786 bh: number: Height of each tile in pixels.
789 \begin_layout Standard
793 \begin_layout Itemize
794 tilemap: TILEMAP: the newly created tilemap
797 \begin_layout Standard
798 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
802 \begin_layout Subsubsection
803 TILEMAP:getsize: Query tilemap size
806 \begin_layout Itemize
807 Syntax: width, height tmap:getsize()
810 \begin_layout Standard
814 \begin_layout Itemize
815 tmap: TILEMAP: The tilemap to query.
818 \begin_layout Standard
822 \begin_layout Itemize
823 width: number : The width of the tilemap in tiles.
826 \begin_layout Itemize
827 height: number: The height of the tilemap in tiles.
830 \begin_layout Standard
831 Get size of tilemap in tiles.
834 \begin_layout Subsubsection
835 TILEMAP:getcsize: Query tilemap cell size
838 \begin_layout Itemize
839 Syntax: width, height tmap:getcsize()
842 \begin_layout Standard
846 \begin_layout Itemize
847 tmap: TILEMAP: The tilemap to query.
850 \begin_layout Standard
854 \begin_layout Itemize
855 width: number: The width of tilemap tile in pixels.
858 \begin_layout Itemize
859 height: number: The height of tilemap tile in pixels.
862 \begin_layout Standard
863 Get size of each tilemap tile in pixels.
866 \begin_layout Subsubsection
867 TILEMAP:get: Query tilemap tile
870 \begin_layout Itemize
871 Syntax: bitmap, palette tmap:get(x, y)
874 \begin_layout Standard
878 \begin_layout Itemize
879 tmap: TILEMAP: The tilemap to query.
882 \begin_layout Itemize
883 x: number: The x-coordinate of tile to query.
886 \begin_layout Itemize
887 y: number: The y-coordinate of tile to query.
890 \begin_layout Standard
894 \begin_layout Itemize
895 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
898 \begin_layout Itemize
899 palette: The palette (PALETTE) associated with indexed-color bitmap, if
904 \begin_layout Standard
905 Return the contents of tile at <x>,<y>.
908 \begin_layout Subsubsection
909 TILEMAP:set: Set tilemap cell
912 \begin_layout Itemize
913 Syntax: tmap:set(x, y)
916 \begin_layout Itemize
917 Syntax: tmap:set(x, y, bitmap)
920 \begin_layout Itemize
921 Syntax: tmap:set(x, y, bitmap, palette)
924 \begin_layout Standard
928 \begin_layout Itemize
929 tmap: TILEMAP: The tilemap to manipulate.
932 \begin_layout Itemize
933 number x: The x-coordinate of tile to set.
936 \begin_layout Itemize
937 number y: The y-coordinate of tile to set.
940 \begin_layout Itemize
941 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
944 \begin_layout Itemize
945 palette: PALETTE: The associated palette for bitmap.
948 \begin_layout Standard
949 Set the contents of tile <x>,<y>.
950 If no <bitmap> is given, clears the tile.
951 Otherwise sets the tile to contain bitmap <bitmap> with associated palette
955 \begin_layout Itemize
956 Specifying index bitmap <bitmap> without palette <palette> causes an error.
959 \begin_layout Subsubsection
960 TILEMAP:scroll: Scroll tilemap
963 \begin_layout Itemize
964 Syntax: tmap:scroll(ox, oy);
967 \begin_layout Itemize
968 Syntax: tmap:scroll(ox, oy, x, y, w, h);
971 \begin_layout Itemize
972 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
975 \begin_layout Standard
979 \begin_layout Itemize
980 tmap: TILEMAP: The tilemap to manipulate.
983 \begin_layout Itemize
984 ox: number: The number of tiles to scroll horizontally (positive is to right).
987 \begin_layout Itemize
988 oy: number: The number of tiles to scroll vertically (positive is to down).
991 \begin_layout Itemize
992 x: number: The left edge of scroll window.
995 \begin_layout Itemize
996 y: number: The top edge of scroll window.
999 \begin_layout Itemize
1000 w: number: The width of scroll window.
1003 \begin_layout Itemize
1004 h: number: The height of scroll window.
1007 \begin_layout Itemize
1008 circ_x: boolean: If true, treat the window as circular in horizontal direction.
1011 \begin_layout Itemize
1012 circ_y: boolean: If true, treat the window as circular in vertical direction.
1015 \begin_layout Standard
1016 Scroll the specified tilemap <tmap> by <ox>,<oy>.
1017 If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
1018 <circ_x> and <circ_y> control if scroll is circular or not.
1021 \begin_layout Itemize
1022 Specifying out-of-range window causes an error.
1025 \begin_layout Subsubsection
1026 TILEMAP:draw: Draw tilemap
1029 \begin_layout Itemize
1030 Name: tmap:draw(x, y)
1033 \begin_layout Itemize
1034 Name: tmap:draw(x, y, x0, y0, w, h)
1037 \begin_layout Standard
1041 \begin_layout Itemize
1042 tmap: TILEMAP: The tilemap to draw.
1045 \begin_layout Itemize
1046 x: The x coordinate on screen to draw to.
1049 \begin_layout Itemize
1050 y: The y coordinate on screen to draw to.
1053 \begin_layout Itemize
1054 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1057 \begin_layout Itemize
1058 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1061 \begin_layout Itemize
1062 w: number: The width to draw (in pixels).
1065 \begin_layout Itemize
1066 h: number: The height to draw (in pixels).
1069 \begin_layout Standard
1070 Draw tilemap <tmap> to screen at <x>,<y>.
1071 If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1074 \begin_layout Itemize
1075 This method requires a rendering context to work.
1078 \begin_layout Subsubsection
1079 TILEMAP:draw_outside: Draw tilemap outside game area
1082 \begin_layout Itemize
1083 Name: tmap:draw_outside(x, y)
1086 \begin_layout Itemize
1087 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1090 \begin_layout Standard
1091 Like TILEMAP:draw, but draws only outside game area.
1094 \begin_layout Standard
1095 \begin_inset Newpage pagebreak
1101 \begin_layout Subsection
1102 RENDERCTX: Off-screen rendering context
1105 \begin_layout Standard
1106 Object acting as off-screen rendering context.
1109 \begin_layout Subsubsection
1110 Static function new: Create a render queue
1113 \begin_layout Itemize
1114 Syntax: renderctx gui.renderctx.new(width, height);
1117 \begin_layout Itemize
1118 Syntax: renderctx classes.RENDERCTX.new(width, height);
1121 \begin_layout Itemize
1122 Deprecated: renderctx gui.renderq_new(width, height);
1125 \begin_layout Standard
1129 \begin_layout Itemize
1130 width: number: The notional width of the game area.
1133 \begin_layout Itemize
1134 height: number: The notional height of the game area.
1137 \begin_layout Standard
1141 \begin_layout Itemize
1142 rendectx: RENDERCTX: The newly created render context.
1145 \begin_layout Standard
1146 Create a render context with reported size <width>*<height> and return it.
1149 \begin_layout Subsubsection
1150 Static function setnull: Reset to default queue
1153 \begin_layout Itemize
1154 Syntax: gui.renderctx.setnull()
1157 \begin_layout Itemize
1158 Syntax: classes.RENDERCTX:setnull()
1161 \begin_layout Itemize
1162 Deprecated: gui.renderq_set()
1165 \begin_layout Standard
1166 Reset the used render context back to default for the executing callback:
1169 \begin_layout Itemize
1170 The default for paint callback is the screen
1173 \begin_layout Itemize
1174 The default for video callback is the video frame
1177 \begin_layout Itemize
1178 The default otherwise is nothing.
1181 \begin_layout Subsubsection
1182 Method clear: Clear a render queue
1185 \begin_layout Itemize
1186 Syntax: renderctx:clear()
1189 \begin_layout Itemize
1190 Deprecated: gui.renderq_clear(renderctx)
1193 \begin_layout Standard
1197 \begin_layout Itemize
1198 renderctx: RENDERCTX: The render queue to clear.
1201 \begin_layout Standard
1202 Clear all drawing from the context.
1205 \begin_layout Subsubsection
1206 Method set: Change active render context
1209 \begin_layout Itemize
1210 Syntax: renderctx:set()
1213 \begin_layout Itemize
1214 Deprecated: gui.renderq_set(renderctx)
1217 \begin_layout Standard
1221 \begin_layout Itemize
1222 renderctx: RENDERCTX: The render queue to use.
1225 \begin_layout Standard
1226 Switch the current rendering context <renderctx>.
1229 \begin_layout Subsubsection
1230 Method run: Draw all objects in context to another
1233 \begin_layout Itemize
1234 Syntax: renderctx:run()
1237 \begin_layout Itemize
1238 Deprecated: gui.renderq_run(renderctx)
1241 \begin_layout Standard
1245 \begin_layout Itemize
1246 renderctx: RENDERCTX: The render context to overlay.
1249 \begin_layout Standard
1250 Overlay the specified render context <context> upon the active rendering
1254 \begin_layout Itemize
1255 Trying to overlay rendering context upon itself is a bad idea.
1258 \begin_layout Subsubsection
1259 Method render: Render a contex to bitmap
1262 \begin_layout Itemize
1263 Syntax: bitmap renderctx:render()
1266 \begin_layout Standard
1270 \begin_layout Itemize
1271 renderctx: RENDERCTX: The context to render.
1274 \begin_layout Standard
1278 \begin_layout Itemize
1279 bitmap: DBITMAP: The rendered bitmap.
1282 \begin_layout Standard
1283 Render the specified context <renderctx> to a new bitmap.
1286 \begin_layout Itemize
1287 The size of bitmap will be nominal game area size, plus any set gaps.
1290 \begin_layout Itemize
1291 This method does not require active rendering context.
1294 \begin_layout Subsubsection
1295 Method synchronous_repaint: Paint screen now
1298 \begin_layout Itemize
1299 Syntax: renderctx:synchronous_repaint()
1302 \begin_layout Itemize
1303 Deprecated: gui.synchronous_repaint(renderctx)
1306 \begin_layout Standard
1310 \begin_layout Itemize
1311 renderctx: RENDERCTX: The context to paint.
1314 \begin_layout Standard
1315 Immediately redraw the screen with game overlayed by drawings from context
1319 \begin_layout Itemize
1320 This does not require active rendering context.
1323 \begin_layout Itemize
1324 Will not cause paint callback to be invoked.
1327 \begin_layout Standard
1328 \begin_inset Newpage pagebreak
1334 \begin_layout Subsection
1335 PALETTE: Color palette for indexed image
1338 \begin_layout Subsubsection
1339 Static function new: Create a new palette
1342 \begin_layout Itemize
1343 Syntax: palette gui.palette.new()
1346 \begin_layout Itemize
1347 Syntax: palette classes.PALETTE.new()
1350 \begin_layout Itemize
1351 Deprecated: palette gui.palette_new()
1354 \begin_layout Standard
1358 \begin_layout Itemize
1359 palette: PALETTE: The created palette.
1362 \begin_layout Standard
1363 Create a new palette (with all colors transparent) and return it.
1366 \begin_layout Subsubsection
1367 Static function load: Load a palette
1370 \begin_layout Itemize
1371 Syntax: palette gui.palette.load(file, [base])
1374 \begin_layout Itemize
1375 Syntax: palette classes.PALETTE.load(file, [base])
1378 \begin_layout Itemize
1379 Deprecated: palette gui.palette_load(file, [base])
1382 \begin_layout Standard
1386 \begin_layout Itemize
1387 string file: The file to load.
1390 \begin_layout Itemize
1391 string base (optional): The base file to resolve file relative to.
1394 \begin_layout Standard
1398 \begin_layout Itemize
1399 palette: PALETTE: The loaded palette.
1402 \begin_layout Standard
1403 Load a palette from file <file> (resolved relative to <base>).
1406 \begin_layout Itemize
1407 The file format is a series of lines, each with following format:
1408 \begin_inset Separator latexpar
1415 \begin_layout Itemize
1416 Blank or just whitespace: Ignored
1419 \begin_layout Itemize
1420 First non-whitespace is '#': Ignored
1423 \begin_layout Itemize
1424 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1427 \begin_layout Itemize
1428 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1429 (0-256, 0 being fully transparent and 256 fully opaque).
1432 \begin_layout Itemize
1433 transparent: Fully transparent color
1437 \begin_layout Subsubsection
1438 Static function load_str: Load a palette from string
1441 \begin_layout Itemize
1442 Syntax: palette gui.palette.load(data)
1445 \begin_layout Itemize
1446 Syntax: palette classes.PALETTE.load(data)
1449 \begin_layout Itemize
1450 Deprecated: palette gui.palette_load(data)
1453 \begin_layout Standard
1457 \begin_layout Itemize
1458 string data: The palette data.
1461 \begin_layout Standard
1465 \begin_layout Itemize
1466 palette: PALETTE: The loaded palette.
1469 \begin_layout Standard
1470 Like PALETTE:load, but instead of reading palette from file, reads it from
1474 \begin_layout Subsubsection
1475 Method set: Set palette entry
1478 \begin_layout Itemize
1479 Syntax: palette:set(index, color)
1482 \begin_layout Itemize
1483 Deprecated: gui.palette_set(palette, ...)
1486 \begin_layout Standard
1490 \begin_layout Itemize
1491 palette: PALETTE: The palette to manipulate
1494 \begin_layout Itemize
1495 index: number: The index of color to set (0-65535).
1498 \begin_layout Itemize
1499 color: number/string: The color value to set.
1502 \begin_layout Standard
1503 Set palette <palette> index <index> to color <color>.
1506 \begin_layout Subsubsection
1507 Method get: Get palette entry
1510 \begin_layout Itemize
1511 Syntax: number palette:get(index)
1514 \begin_layout Standard
1518 \begin_layout Itemize
1519 palette: PALETTE: The palette to query
1522 \begin_layout Itemize
1523 index: number: The index of color to get (0-65535).
1526 \begin_layout Standard
1530 \begin_layout Itemize
1531 The palette entry as integer.
1534 \begin_layout Standard
1535 Get palette entry <index> of palette <palette> and return it.
1538 \begin_layout Subsubsection
1539 Method hash: Hash a palette
1542 \begin_layout Itemize
1543 Syntax: hash palette:hash()
1546 \begin_layout Itemize
1547 Deprecated: hash gui.palette_hash(palette)
1550 \begin_layout Standard
1554 \begin_layout Itemize
1555 palette: The palette to hash.
1558 \begin_layout Standard
1562 \begin_layout Itemize
1563 hash: string: 64-hex digit hash.
1566 \begin_layout Standard
1567 Obtain crypto-grade hash of palette data of <palette>.
1570 \begin_layout Itemize
1571 All colors after the last non-transparent one are ignored.
1574 \begin_layout Subsubsection
1575 Method adjust_transparency: Adjust transparency
1578 \begin_layout Itemize
1579 Syntax: palette:adjust_transparency(newvalue)
1582 \begin_layout Itemize
1583 Deprecated: gui.adjust_transparency(palette, ...)
1586 \begin_layout Standard
1590 \begin_layout Itemize
1591 palette: PALETTE: The palette to adjust.
1594 \begin_layout Itemize
1595 Number adj: The factor to multiply opaqueness with times 256.
1598 \begin_layout Standard
1599 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1602 \begin_layout Standard
1603 \begin_inset Newpage pagebreak
1609 \begin_layout Subsection
1610 BITMAP: Indexed-color bitmap
1613 \begin_layout Subsubsection
1614 Static function new: Create a new bitmap
1617 \begin_layout Itemize
1618 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1621 \begin_layout Itemize
1622 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1625 \begin_layout Itemize
1626 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1629 \begin_layout Standard
1633 \begin_layout Itemize
1634 w: number: The width of bitmap to create in pixels.
1637 \begin_layout Itemize
1638 h: number: The height of bitmap to create in pixels.
1641 \begin_layout Itemize
1642 false: boolean: Constant boolean false.
1645 \begin_layout Itemize
1646 fillcolor: number: The initial fill index.
1647 Default 0 if not specified.
1650 \begin_layout Standard
1651 Create a new bitmap of size <w>*<h>.
1652 Fill the bitmap with color index <fillcolor>.
1655 \begin_layout Subsubsection
1656 Method draw: Draw a bitmap
1659 \begin_layout Itemize
1660 Syntax: bitmap:draw(x, y, palette)
1663 \begin_layout Itemize
1664 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1667 \begin_layout Standard
1671 \begin_layout Itemize
1672 bitmap: BITMAP: The bitmap to draw
1675 \begin_layout Itemize
1676 x: number: The x-coordinate on screen.
1679 \begin_layout Itemize
1680 y: number: The y-coordinate on screen.
1683 \begin_layout Itemize
1684 palette: The palette to use for drawing.
1687 \begin_layout Standard
1688 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1691 \begin_layout Subsubsection
1692 Method draw_outside: Draw a bitmap outside game area
1695 \begin_layout Itemize
1696 Syntax: bitmap:draw_outside(x, y, palette)
1699 \begin_layout Standard
1700 Like bitmap:draw, but does not draw on game area.
1703 \begin_layout Subsubsection
1704 Method draw_clip: Draw a bitmap, with clipping
1707 \begin_layout Itemize
1708 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1711 \begin_layout Standard
1715 \begin_layout Itemize
1716 bitmap: BITMAP: The bitmap to draw
1719 \begin_layout Itemize
1720 x: number: The x-coordinate on screen.
1723 \begin_layout Itemize
1724 y: number: The y-coordinate on screen.
1727 \begin_layout Itemize
1728 palette: The palette to use for drawing.
1731 \begin_layout Itemize
1732 x0: The smallest bitmap x coordinate to draw.
1735 \begin_layout Itemize
1736 y0: The smallest bitmap y coordinate to draw.
1739 \begin_layout Itemize
1740 width: Width of region to draw
1743 \begin_layout Itemize
1744 height: Height of region to draw.
1747 \begin_layout Standard
1748 Like bitmap:draw, but clip the bitmap area drawn.
1751 \begin_layout Subsubsection
1752 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1755 \begin_layout Itemize
1756 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1759 \begin_layout Standard
1760 Like bitmap:draw_clip, but only draw outside game area.
1763 \begin_layout Subsubsection
1764 Method pset: Set pixel in bitmap
1767 \begin_layout Itemize
1768 Syntax: bitmap:pset(x, y, color)
1771 \begin_layout Itemize
1772 Deprecaed: gui.bitmap_pset(bitmap, ...)
1775 \begin_layout Standard
1779 \begin_layout Itemize
1780 bitmap: BITMAP: The bitmap to manipulate.
1783 \begin_layout Itemize
1784 x: number: x-coordinate of pixel to set.
1787 \begin_layout Itemize
1788 y: number: y-coordinate of pixel to set.
1791 \begin_layout Itemize
1792 color: number: The color index to set.
1795 \begin_layout Standard
1796 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1799 \begin_layout Subsubsection
1800 Method pget: Get pixel in bitmap
1803 \begin_layout Itemize
1804 Syntax: color bitmap:pget(x,y)
1807 \begin_layout Itemize
1808 Deprecated: color gui.bitmap_pget(bitmap, ...)
1811 \begin_layout Standard
1815 \begin_layout Itemize
1816 bitmap: BITMAP: The bitmap to query.
1819 \begin_layout Itemize
1820 x: number: x-coordinate of pixel to get.
1823 \begin_layout Itemize
1824 y: number: y-coordinate of pixel to get.
1827 \begin_layout Standard
1831 \begin_layout Itemize
1832 color: number: The color index in specified pixel.
1835 \begin_layout Standard
1836 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1839 \begin_layout Subsubsection
1840 Method size: Get size of bitmap
1843 \begin_layout Itemize
1844 Syntax: width, height bitmap:size()
1847 \begin_layout Itemize
1848 Syntax: width, height gui.bitmap_size(bitmap)
1851 \begin_layout Standard
1855 \begin_layout Itemize
1856 bitmap: BITMAP: The bitmap to query.
1859 \begin_layout Standard
1863 \begin_layout Itemize
1864 width: number: The width of the bitmap.
1867 \begin_layout Itemize
1868 height: number: The height of the bitmap.
1871 \begin_layout Standard
1872 Get size of bitmap <bitmap>.
1875 \begin_layout Subsubsection
1876 Method blit: Blit a bitmap into another
1879 \begin_layout Itemize
1880 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1883 \begin_layout Itemize
1884 Deprecated: gui.bitmap_blit(dest, ...)
1887 \begin_layout Standard
1891 \begin_layout Itemize
1892 dest: BITMAP: The target bitmap to blit to.
1895 \begin_layout Itemize
1896 dx: number: The x-coordinate in target.
1899 \begin_layout Itemize
1900 dy: number: The y-coordinate in target.
1903 \begin_layout Itemize
1904 src: BITMAP: The source bitmap.
1907 \begin_layout Itemize
1908 sx: number: The x-coordinate in source.
1911 \begin_layout Itemize
1912 sy: number: The y-coordinate in source.
1915 \begin_layout Itemize
1916 w: number: The width of area to blit.
1919 \begin_layout Itemize
1920 h: number: The height of area to blit.
1923 \begin_layout Itemize
1924 ck: number: The color key.
1925 Pixels with this index are not copied.
1926 \begin_inset Separator latexpar
1933 \begin_layout Itemize
1934 If none is specified, all pixels are copied.
1938 \begin_layout Standard
1939 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1941 If a color key <ck> is specified, pixels of that color are not copied.
1944 \begin_layout Subsubsection
1945 Method blit_scaled: Blit a bitmap into another with scaling
1948 \begin_layout Itemize
1949 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1952 \begin_layout Itemize
1953 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1956 \begin_layout Standard
1960 \begin_layout Itemize
1961 dest: BITMAP: The target bitmap to blit to.
1964 \begin_layout Itemize
1965 dx: number: The x-coordinate in target.
1968 \begin_layout Itemize
1969 dy: number: The y-coordinate in target.
1972 \begin_layout Itemize
1973 src: BITMAP: The source bitmap.
1976 \begin_layout Itemize
1977 sx: number: The x-coordinate in source.
1980 \begin_layout Itemize
1981 sy: number: The y-coordinate in source.
1984 \begin_layout Itemize
1985 w: number: The width of area to blit.
1988 \begin_layout Itemize
1989 h: number: The height of area to blit.
1992 \begin_layout Itemize
1993 hscl: number: Horizontal scale factor (integer).
1996 \begin_layout Itemize
1997 vscl: number: Vertical scale factor (integer).
1998 Defaults to the same as <hscl>.
2001 \begin_layout Itemize
2002 ck: number: The color key.
2003 Pixels with this index are not copied.
2004 \begin_inset Separator latexpar
2011 \begin_layout Itemize
2012 If none is specified, all pixels are copied.
2016 \begin_layout Standard
2017 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
2018 neighbor) by factor of <hscl>*<vscl>.
2021 \begin_layout Subsubsection
2022 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2025 \begin_layout Itemize
2026 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2029 \begin_layout Itemize
2030 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2033 \begin_layout Standard
2037 \begin_layout Itemize
2038 dest: BITMAP: The target bitmap to blit to.
2041 \begin_layout Itemize
2042 dx: number: The x-coordinate in target.
2045 \begin_layout Itemize
2046 dy: number: The y-coordinate in target.
2049 \begin_layout Itemize
2050 src: BITMAP: The source bitmap.
2053 \begin_layout Itemize
2054 sx: number: The x-coordinate in source.
2057 \begin_layout Itemize
2058 sy: number: The y-coordinate in source.
2061 \begin_layout Itemize
2062 w: number: The width of area to blit.
2065 \begin_layout Itemize
2066 h: number: The height of area to blit.
2069 \begin_layout Itemize
2070 operator: string: The operator to use.
2071 \begin_inset Separator latexpar
2078 \begin_layout Itemize
2079 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2080 DestOut, Clear or Xor.
2084 \begin_layout Standard
2085 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2090 \begin_layout Itemize
2091 Color index 0 in source and target is treated as background.
2094 \begin_layout Subsubsection
2095 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2096 Porter-Duff composition
2099 \begin_layout Itemize
2100 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2104 \begin_layout Itemize
2105 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2108 \begin_layout Standard
2112 \begin_layout Itemize
2113 dest: BITMAP: The target bitmap to blit to.
2116 \begin_layout Itemize
2117 dx: number: The x-coordinate in target.
2120 \begin_layout Itemize
2121 dy: number: The y-coordinate in target.
2124 \begin_layout Itemize
2125 src: BITMAP: The source bitmap.
2128 \begin_layout Itemize
2129 sx: number: The x-coordinate in source.
2132 \begin_layout Itemize
2133 sy: number: The y-coordinate in source.
2136 \begin_layout Itemize
2137 w: number: The width of area to blit.
2140 \begin_layout Itemize
2141 h: number: The height of area to blit.
2144 \begin_layout Itemize
2145 hscl: number: Horizontal scale factor (integer).
2148 \begin_layout Itemize
2149 vscl: number: Vertical scale factor (integer).
2150 Defaults to the same as <hscl>.
2153 \begin_layout Itemize
2154 operator: string: The operator to use.
2155 \begin_inset Separator latexpar
2162 \begin_layout Itemize
2163 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2164 DestOut, Clear or Xor.
2168 \begin_layout Standard
2169 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2170 like BITMAP:blit_scaled.
2173 \begin_layout Subsubsection
2174 Method blit_priority: Blit a bitmap into another with color priority
2177 \begin_layout Itemize
2178 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2181 \begin_layout Itemize
2182 Deprecated: gui.bitmap_blit_priority(dest, ...)
2185 \begin_layout Standard
2189 \begin_layout Itemize
2190 dest: BITMAP: The target bitmap to blit to.
2193 \begin_layout Itemize
2194 dx: number: The x-coordinate in target.
2197 \begin_layout Itemize
2198 dy: number: The y-coordinate in target.
2201 \begin_layout Itemize
2202 src: BITMAP: The source bitmap.
2205 \begin_layout Itemize
2206 sx: number: The x-coordinate in source.
2209 \begin_layout Itemize
2210 sy: number: The y-coordinate in source.
2213 \begin_layout Itemize
2214 w: number: The width of area to blit.
2217 \begin_layout Itemize
2218 h: number: The height of area to blit.
2221 \begin_layout Standard
2222 Like BITMAP:blit, but only copy pixels where source color index is greater
2223 than destination color index.
2226 \begin_layout Subsubsection
2227 Method blit_scaled_priority: Blit a bitmap into another with color priority
2231 \begin_layout Itemize
2232 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2235 \begin_layout Itemize
2236 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2239 \begin_layout Standard
2243 \begin_layout Itemize
2244 dest: BITMAP: The target bitmap to blit to.
2247 \begin_layout Itemize
2248 dx: number: The x-coordinate in target.
2251 \begin_layout Itemize
2252 dy: number: The y-coordinate in target.
2255 \begin_layout Itemize
2256 src: BITMAP: The source bitmap.
2259 \begin_layout Itemize
2260 sx: number: The x-coordinate in source.
2263 \begin_layout Itemize
2264 sy: number: The y-coordinate in source.
2267 \begin_layout Itemize
2268 w: number: The width of area to blit.
2271 \begin_layout Itemize
2272 h: number: The height of area to blit.
2275 \begin_layout Itemize
2276 hscl: number: Horizontal scale factor (integer).
2279 \begin_layout Itemize
2280 vscl: number: Vertical scale factor (integer).
2281 Defaults to the same as <hscl>.
2284 \begin_layout Standard
2285 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2289 \begin_layout Subsubsection
2290 Method save_png: Save a bitmap to PNG
2293 \begin_layout Itemize
2294 Syntax: bitmap:save_png(filename, [base], palette)
2297 \begin_layout Itemize
2298 Syntax: data bitmap:save_png(palette)
2301 \begin_layout Itemize
2303 gui.bitmap_save_png(bitmap, ...)
2306 \begin_layout Standard
2310 \begin_layout Itemize
2311 bitmap: BITMAP: The bitmap to save.
2314 \begin_layout Itemize
2315 filename: string: The filename to save to.
2318 \begin_layout Itemize
2319 base: string: The base filename is resolved relative to.
2322 \begin_layout Itemize
2323 palette: PALETTE: The palette to use.
2326 \begin_layout Standard
2330 \begin_layout Itemize
2331 data: string: BASE64 encoded PNG data.
2334 \begin_layout Standard
2335 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2336 to <base>) or return BASE64 encoding of it.
2339 \begin_layout Subsubsection
2340 Method hash: Hash a bitmap
2343 \begin_layout Itemize
2344 Syntax: hash bitmap:hash()
2347 \begin_layout Itemize
2348 Deprecated: hash bitmap:hash(bitmap)
2351 \begin_layout Standard
2355 \begin_layout Itemize
2356 bitmap: BITMAP: The bitmap to hash.
2359 \begin_layout Standard
2363 \begin_layout Itemize
2364 hash: string: 64-hex digit hash
2367 \begin_layout Standard
2368 Hashes bitmap <bitmap> and returns crypto-strong hash.
2372 \begin_layout Itemize
2373 Color order in bitmap is significant.
2376 \begin_layout Subsubsection
2377 Method sample_texture: Sample a texture
2380 \begin_layout Itemize
2381 Syntax: none bitmap:sample_texture(BITMAP source, number xx, number xy,
2382 number x0, number yx, number yy, number y0, number scale, boolean wrap)
2385 \begin_layout Standard
2389 \begin_layout Itemize
2390 source: BITMAP: The bitmap to sample
2393 \begin_layout Itemize
2394 xx: number: s times the source x coefficient of target x axis.
2397 \begin_layout Itemize
2398 xy: number: s times the source y coefficient of target x axis.
2401 \begin_layout Itemize
2402 x0: number: s times the target x axis offset.
2405 \begin_layout Itemize
2406 yx: number: s times the source x coefficient of target y axis.
2409 \begin_layout Itemize
2410 yy: number: s times the source y coefficient of target y axis.
2413 \begin_layout Itemize
2414 y0: number: s times the target y axis offset.
2417 \begin_layout Itemize
2418 s: number: Scale of coordinates
2421 \begin_layout Itemize
2422 wrap: boolean: If true, wrap the texture.
2423 If false, read outside the texture as color 0.
2426 \begin_layout Standard
2427 Samples the source as texture, performing linear transform (with nearest-neighbo
2428 r sampling) and writes the result to this bitmap.
2431 \begin_layout Subsubsection
2432 Method hflip: Horizontally flip a bitmap
2435 \begin_layout Itemize
2436 Syntax: none bitmap:hflip()
2439 \begin_layout Standard
2440 Horizontally flips a bitmap.
2443 \begin_layout Subsubsection
2444 Method vflip: Vertically flip a bitmap
2447 \begin_layout Itemize
2448 Syntax: none bitmap:vflip()
2451 \begin_layout Standard
2452 Vertically flips a bitmap.
2455 \begin_layout Standard
2456 \begin_inset Newpage pagebreak
2462 \begin_layout Subsection
2463 DBITMAP: Direct-color bitmap
2466 \begin_layout Subsubsection
2467 Static function: new: Create a new bitmap
2470 \begin_layout Itemize
2471 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2474 \begin_layout Itemize
2475 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2478 \begin_layout Itemize
2479 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2482 \begin_layout Standard
2486 \begin_layout Itemize
2487 w: number: The width of new bitmap.
2490 \begin_layout Itemize
2491 h: number: The height of new bitmap.
2494 \begin_layout Itemize
2495 true: boolean: Fixed boolean true
2498 \begin_layout Itemize
2499 fillcolor: The color to fill the bitmap with (default transparent).
2502 \begin_layout Standard
2506 \begin_layout Itemize
2507 bitmap: DBITMAP: The new bitmap.
2510 \begin_layout Standard
2511 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2515 \begin_layout Subsubsection
2516 Method draw: Draw a bitmap
2519 \begin_layout Itemize
2520 Syntax: bitmap.draw(x, y)
2523 \begin_layout Itemize
2524 Deprecated: gui.bitmap_draw(x, y, bitmap)
2527 \begin_layout Standard
2531 \begin_layout Itemize
2532 bitmap: DBITMAP: The bitmap to draw.
2535 \begin_layout Itemize
2536 x: number: X-coordinate on screen.
2539 \begin_layout Itemize
2540 y: number: Y-coordinate on screen.
2543 \begin_layout Standard
2544 Draw bitmap <bitmap> on screen at <x>,<y>.
2547 \begin_layout Subsubsection
2548 Method draw_outside: Draw a bitmap outside game area
2551 \begin_layout Itemize
2552 Syntax: dbitmap:draw_outside(x, y, palette)
2555 \begin_layout Standard
2556 Like dbitmap:draw, but does not draw on game area.
2559 \begin_layout Subsubsection
2560 Method draw_clip: Draw a bitmap, with clipping
2563 \begin_layout Itemize
2564 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2567 \begin_layout Standard
2571 \begin_layout Itemize
2572 bitmap: DBITMAP: The bitmap to draw
2575 \begin_layout Itemize
2576 x: number: The x-coordinate on screen.
2579 \begin_layout Itemize
2580 y: number: The y-coordinate on screen.
2583 \begin_layout Itemize
2584 x0: The smallest bitmap x coordinate to draw.
2587 \begin_layout Itemize
2588 y0: The smallest bitmap y coordinate to draw.
2591 \begin_layout Itemize
2592 width: Width of region to draw
2595 \begin_layout Itemize
2596 height: Height of region to draw.
2599 \begin_layout Standard
2600 Like dbitmap:draw, but clip the bitmap area drawn.
2603 \begin_layout Subsubsection
2604 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2607 \begin_layout Itemize
2608 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2611 \begin_layout Standard
2612 Like dbitmap:draw_clip, but only draw outside game area.
2615 \begin_layout Subsubsection
2616 Method pset: Set pixel in bitmap
2619 \begin_layout Itemize
2620 Syntax: bitmap:pset(x, y, color)
2623 \begin_layout Itemize
2624 Deprecaed: gui.bitmap_pset(bitmap, ...)
2627 \begin_layout Standard
2631 \begin_layout Itemize
2632 bitmap: DBITMAP: The bitmap to manipulate.
2635 \begin_layout Itemize
2636 x: number: x-coordinate of pixel to set.
2639 \begin_layout Itemize
2640 y: number: y-coordinate of pixel to set.
2643 \begin_layout Itemize
2644 color: number/string: The color to set.
2647 \begin_layout Standard
2648 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2651 \begin_layout Subsubsection
2652 Method pget: Get pixel in bitmap
2655 \begin_layout Itemize
2656 Syntax: color bitmap:pget(x,y)
2659 \begin_layout Itemize
2660 Deprecated: color gui.bitmap_pget(bitmap, ...)
2663 \begin_layout Standard
2667 \begin_layout Itemize
2668 bitmap: DBITMAP: The bitmap to query.
2671 \begin_layout Itemize
2672 x: number: x-coordinate of pixel to get.
2675 \begin_layout Itemize
2676 y: number: y-coordinate of pixel to get.
2679 \begin_layout Standard
2683 \begin_layout Itemize
2684 color: number: The color of specified pixel.
2687 \begin_layout Standard
2688 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2691 \begin_layout Subsubsection
2692 Method size: Get size of bitmap
2695 \begin_layout Itemize
2696 Syntax: width, height bitmap:size()
2699 \begin_layout Itemize
2700 Syntax: width, height gui.bitmap_size(bitmap)
2703 \begin_layout Standard
2707 \begin_layout Itemize
2708 bitmap: DBITMAP: The bitmap to query.
2711 \begin_layout Standard
2715 \begin_layout Itemize
2716 width: number: The width of the bitmap.
2719 \begin_layout Itemize
2720 height: number: The height of the bitmap.
2723 \begin_layout Standard
2724 Get size of bitmap <bitmap>.
2727 \begin_layout Subsubsection
2728 Method blit: Blit a bitmap into another
2731 \begin_layout Itemize
2732 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2735 \begin_layout Itemize
2736 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2739 \begin_layout Itemize
2740 Deprecated: gui.bitmap_blit(dest, ...)
2743 \begin_layout Standard
2747 \begin_layout Itemize
2748 dest: DBITMAP: The target bitmap to blit to.
2751 \begin_layout Itemize
2752 dx: number: The x-coordinate in target.
2755 \begin_layout Itemize
2756 dy: number: The y-coordinate in target.
2759 \begin_layout Itemize
2760 src: BITMAP/DBITMAP: The source bitmap.
2763 \begin_layout Itemize
2764 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2767 \begin_layout Itemize
2768 sx: number: The x-coordinate in source.
2771 \begin_layout Itemize
2772 sy: number: The y-coordinate in source.
2775 \begin_layout Itemize
2776 w: number: The width of area to blit.
2779 \begin_layout Itemize
2780 h: number: The height of area to blit.
2783 \begin_layout Itemize
2784 ck: number: The color key.
2785 Pixels with this index are not copied.
2786 \begin_inset Separator latexpar
2793 \begin_layout Itemize
2794 If none is specified, all pixels are copied.
2797 \begin_layout Itemize
2798 If <src> is paletted, this is color index, otherwise it is a color.
2802 \begin_layout Standard
2803 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2804 if indexed) into <dest> at <dx>,<dy>.
2805 If a color key <ck> is specified, pixels of that color are not copied.
2808 \begin_layout Subsubsection
2809 Method blit_scaled: Blit a bitmap into another with scaling
2812 \begin_layout Itemize
2813 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2816 \begin_layout Itemize
2817 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2821 \begin_layout Itemize
2822 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2825 \begin_layout Standard
2829 \begin_layout Itemize
2830 dest: DBITMAP: The target bitmap to blit to.
2833 \begin_layout Itemize
2834 dx: number: The x-coordinate in target.
2837 \begin_layout Itemize
2838 dy: number: The y-coordinate in target.
2841 \begin_layout Itemize
2842 src: BITMAP/DBITMAP: The source bitmap.
2845 \begin_layout Itemize
2846 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2849 \begin_layout Itemize
2850 sx: number: The x-coordinate in source.
2853 \begin_layout Itemize
2854 sy: number: The y-coordinate in source.
2857 \begin_layout Itemize
2858 w: number: The width of area to blit.
2861 \begin_layout Itemize
2862 h: number: The height of area to blit.
2865 \begin_layout Itemize
2866 hscl: number: Horizontal scale factor (integer).
2869 \begin_layout Itemize
2870 vscl: number: Vertical scale factor (integer).
2871 Defaults to the same as <hscl>.
2874 \begin_layout Itemize
2875 ck: number: The color key.
2876 Pixels with this index are not copied.
2877 \begin_inset Separator latexpar
2884 \begin_layout Itemize
2885 If none is specified, all pixels are copied.
2888 \begin_layout Itemize
2889 If <src> is paletted, this is color index, otherwise it is a color.
2893 \begin_layout Standard
2894 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2895 neighbor) by factor of <hscl>*<vscl>.
2898 \begin_layout Subsubsection
2899 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2902 \begin_layout Itemize
2903 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2906 \begin_layout Itemize
2907 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2910 \begin_layout Itemize
2911 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2914 \begin_layout Standard
2918 \begin_layout Itemize
2919 dest: DBITMAP: The target bitmap to blit to.
2922 \begin_layout Itemize
2923 dx: number: The x-coordinate in target.
2926 \begin_layout Itemize
2927 dy: number: The y-coordinate in target.
2930 \begin_layout Itemize
2931 src: BITMAP/DBITMAP: The source bitmap.
2934 \begin_layout Itemize
2935 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2938 \begin_layout Itemize
2939 sx: number: The x-coordinate in source.
2942 \begin_layout Itemize
2943 sy: number: The y-coordinate in source.
2946 \begin_layout Itemize
2947 w: number: The width of area to blit.
2950 \begin_layout Itemize
2951 h: number: The height of area to blit.
2954 \begin_layout Itemize
2955 operator: string: The operator to use.
2956 \begin_inset Separator latexpar
2963 \begin_layout Itemize
2964 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2965 DestOut, Clear or Xor.
2969 \begin_layout Standard
2970 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2975 \begin_layout Itemize
2976 In target, fully transparent is background.
2977 In source, either fully transparent (if direct) or index 0 (if paletted)
2978 is treated as background.
2981 \begin_layout Subsubsection
2982 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2983 Porter-Duff composition
2986 \begin_layout Itemize
2987 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2991 \begin_layout Itemize
2992 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2996 \begin_layout Itemize
2997 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
3000 \begin_layout Standard
3004 \begin_layout Itemize
3005 dest: DBITMAP: The target bitmap to blit to.
3008 \begin_layout Itemize
3009 dx: number: The x-coordinate in target.
3012 \begin_layout Itemize
3013 dy: number: The y-coordinate in target.
3016 \begin_layout Itemize
3017 src: BITMAP/DBITMAP: The source bitmap.
3020 \begin_layout Itemize
3021 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
3024 \begin_layout Itemize
3025 sx: number: The x-coordinate in source.
3028 \begin_layout Itemize
3029 sy: number: The y-coordinate in source.
3032 \begin_layout Itemize
3033 w: number: The width of area to blit.
3036 \begin_layout Itemize
3037 h: number: The height of area to blit.
3040 \begin_layout Itemize
3041 hscl: number: Horizontal scale factor (integer).
3044 \begin_layout Itemize
3045 vscl: number: Vertical scale factor (integer).
3046 Defaults to the same as <hscl>.
3049 \begin_layout Itemize
3050 operator: string: The operator to use.
3051 \begin_inset Separator latexpar
3058 \begin_layout Itemize
3059 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
3060 DestOut, Clear or Xor.
3064 \begin_layout Standard
3065 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
3066 like DBITMAP:blit_scaled.
3069 \begin_layout Subsubsection
3070 Method adjust_transparency: Adjust transparency of bitmap
3073 \begin_layout Itemize
3074 Syntax: bitmap:adjust_transparency(newvalue)
3077 \begin_layout Itemize
3078 Deprecated: gui.adjust_transparency(bitmap, ...)
3081 \begin_layout Standard
3085 \begin_layout Itemize
3086 bitmap: DBITMAP: The bitmap to adjust.
3089 \begin_layout Itemize
3090 Number adj: The factor to multiply opaqueness with times 256.
3093 \begin_layout Standard
3094 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
3097 \begin_layout Subsubsection
3098 Method save_png: Save a bitmap to PNG
3101 \begin_layout Itemize
3102 Syntax: bitmap:save_png(filename, [base])
3105 \begin_layout Itemize
3106 Syntax: data bitmap:save_png()
3109 \begin_layout Itemize
3111 gui.bitmap_save_png(bitmap, ...)
3114 \begin_layout Standard
3118 \begin_layout Itemize
3119 bitmap: DBITMAP: The bitmap to save.
3122 \begin_layout Itemize
3123 filename: string: The filename to save to.
3126 \begin_layout Itemize
3127 base: string: The base filename is resolved relative to.
3130 \begin_layout Standard
3134 \begin_layout Itemize
3135 data: string: BASE64 encoded PNG data.
3138 \begin_layout Standard
3139 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
3140 BASE64 encoding of it.
3143 \begin_layout Subsubsection
3144 Method hash: Hash a bitmap
3147 \begin_layout Itemize
3148 Syntax: hash bitmap:hash()
3151 \begin_layout Itemize
3152 Deprecated: hash bitmap:hash(bitmap)
3155 \begin_layout Standard
3159 \begin_layout Itemize
3160 bitmap: DBITMAP: The bitmap to hash.
3163 \begin_layout Standard
3167 \begin_layout Itemize
3168 hash: string: 64-hex digit hash
3171 \begin_layout Standard
3172 Hashes bitmap <bitmap> and returns crypto-strong hash.
3176 \begin_layout Subsubsection
3177 Method sample_texture: Sample a texture
3180 \begin_layout Itemize
3181 Syntax: none bitmap:sample_texture(BITMAP source, number xx, number xy,
3182 number x0, number yx, number yy, number y0, number scale, boolean wrap)
3185 \begin_layout Standard
3189 \begin_layout Itemize
3190 source: BITMAP: The bitmap to sample
3193 \begin_layout Itemize
3194 xx: number: s times the source x coefficient of target x axis.
3197 \begin_layout Itemize
3198 xy: number: s times the source y coefficient of target x axis.
3201 \begin_layout Itemize
3202 x0: number: s times the target x axis offset.
3205 \begin_layout Itemize
3206 yx: number: s times the source x coefficient of target y axis.
3209 \begin_layout Itemize
3210 yy: number: s times the source y coefficient of target y axis.
3213 \begin_layout Itemize
3214 y0: number: s times the target y axis offset.
3217 \begin_layout Itemize
3218 s: number: Scale of coordinates
3221 \begin_layout Itemize
3222 wrap: boolean: If true, wrap the texture.
3223 If false, read outside the texture as color 0.
3226 \begin_layout Standard
3227 Samples the source as texture, performing linear transform (with nearest-neighbo
3228 r sampling) and writes the result to this bitmap.
3231 \begin_layout Subsubsection
3232 Method hflip: Horizontally flip a bitmap
3235 \begin_layout Itemize
3236 Syntax: none dbitmap:hflip()
3239 \begin_layout Standard
3240 Horizontally flips a bitmap.
3243 \begin_layout Subsubsection
3244 Method vflip: Vertically flip a bitmap
3247 \begin_layout Itemize
3248 Syntax: none dbitmap:vflip()
3251 \begin_layout Standard
3252 Vertically flips a bitmap.
3255 \begin_layout Standard
3256 \begin_inset Newpage pagebreak
3262 \begin_layout Subsection
3263 IMAGELOADER: Load an image
3266 \begin_layout Subsubsection
3267 Static function load: Load a bitmap from file
3270 \begin_layout Itemize
3271 Syntax: bitmap, palette gui.image.load(file, [base])
3274 \begin_layout Itemize
3275 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3278 \begin_layout Itemize
3280 gui.bitmap_load(...)
3283 \begin_layout Standard
3287 \begin_layout Itemize
3288 file: string: The file to read.
3291 \begin_layout Itemize
3292 base: string: The base to resolve <file> relative to.
3295 \begin_layout Standard
3299 \begin_layout Itemize
3300 bitmap: BITMAP/DBITMAP: The new bitmap
3303 \begin_layout Itemize
3304 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3308 \begin_layout Standard
3309 Load a new bitmap and return it (plus associated palette if any).
3312 \begin_layout Subsubsection
3313 Static function load_str: Load a bitmap from string
3316 \begin_layout Itemize
3317 Syntax: bitmap, palette gui.image.load_str(data)
3320 \begin_layout Itemize
3321 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3324 \begin_layout Itemize
3326 gui.bitmap_load_str(...)
3329 \begin_layout Standard
3333 \begin_layout Itemize
3334 data: string: The image data
3337 \begin_layout Standard
3341 \begin_layout Itemize
3342 bitmap: BITMAP/DBITMAP: The new bitmap
3345 \begin_layout Itemize
3346 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3350 \begin_layout Standard
3351 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3355 \begin_layout Subsubsection
3356 Static function load_png: Load a bitmap from PNG file
3359 \begin_layout Itemize
3360 Syntax: bitmap, palette gui.image.load_png(file, [base])
3363 \begin_layout Itemize
3364 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3367 \begin_layout Itemize
3369 gui.bitmap_load_png(...)
3372 \begin_layout Standard
3376 \begin_layout Itemize
3377 file: string: The file to read.
3380 \begin_layout Itemize
3381 base: string: The base to resolve <file> relative to.
3384 \begin_layout Standard
3388 \begin_layout Itemize
3389 bitmap: BITMAP/DBITMAP: The new bitmap
3392 \begin_layout Itemize
3393 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3397 \begin_layout Standard
3398 Like IMAGELOADER:load, but load a PNG file instead.
3401 \begin_layout Subsubsection
3402 Static function load_png_str: Load a PNG bitmap from string
3405 \begin_layout Itemize
3406 Syntax: bitmap, palette gui.image.load_png_str(data)
3409 \begin_layout Itemize
3410 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3413 \begin_layout Itemize
3415 gui.bitmap_load_png_str(...)
3418 \begin_layout Standard
3422 \begin_layout Itemize
3423 data: string: The image data, base64 encoded.
3426 \begin_layout Standard
3430 \begin_layout Itemize
3431 bitmap: BITMAP/DBITMAP: The new bitmap
3434 \begin_layout Itemize
3435 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3439 \begin_layout Standard
3440 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3441 <data> instead of file.
3444 \begin_layout Standard
3445 \begin_inset Newpage pagebreak
3451 \begin_layout Subsection
3452 CUSTOMFONT: Arbitrary-sized bitmap font
3455 \begin_layout Subsubsection
3456 Static function new: Return a new empty font
3459 \begin_layout Itemize
3460 Syntax: font gui.font.new()
3463 \begin_layout Itemize
3464 Syntax: font classes.CUSTOMFONT.new()
3467 \begin_layout Itemize
3468 Deprecated: font gui.font_new()
3471 \begin_layout Standard
3475 \begin_layout Itemize
3476 font: CUSTOMFONT: New font.
3479 \begin_layout Standard
3480 Create a new font with no characters and return it.
3483 \begin_layout Subsubsection
3484 Static function: load: Load a font file
3487 \begin_layout Itemize
3488 Syntax: font gui.font.load(file, [base])
3491 \begin_layout Itemize
3492 Syntax: font gui.font.load()
3495 \begin_layout Itemize
3496 Syntax: font classes.CUSTOMFONT.load(file, [base])
3499 \begin_layout Itemize
3500 Syntax: font classes.CUSTOMFONT.load()
3503 \begin_layout Itemize
3504 Deprecated: font gui.loadfont(...)
3507 \begin_layout Standard
3511 \begin_layout Itemize
3512 file: string: The file to read the font from
3515 \begin_layout Itemize
3516 base: string: The file to resolve <file> relative to.
3519 \begin_layout Standard
3523 \begin_layout Itemize
3524 font: CUSTOMFONT: New font.
3527 \begin_layout Standard
3528 Load font from file <file> (relative to <base>).
3529 If no filename is given, system default font is loaded.
3532 \begin_layout Subsubsection
3533 operator(): Render text to screen
3536 \begin_layout Itemize
3537 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3540 \begin_layout Standard
3544 \begin_layout Itemize
3545 font: CUSTOMFONT: The font to use.
3548 \begin_layout Itemize
3549 x: number: The x-position on screen to draw to.
3552 \begin_layout Itemize
3553 y: number: The y-position on screen to draw to.
3556 \begin_layout Itemize
3557 text: string: The text to draw.
3560 \begin_layout Itemize
3561 fgc: number/string: Foreground color (default white).
3564 \begin_layout Itemize
3565 bgc: number/string: Background color (default transparent).
3568 \begin_layout Itemize
3569 hlc: number/string: Outline color (default transparent).
3572 \begin_layout Standard
3573 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3577 \begin_layout Itemize
3578 If <hlc> is transparent, no outline is drawn.
3581 \begin_layout Subsubsection
3582 Method edit: Alter glyph in font
3585 \begin_layout Itemize
3586 Syntax: font:edit(string character, bitmap glyph)
3589 \begin_layout Standard
3593 \begin_layout Itemize
3594 font: CUSTOMFONT: The font to edit.
3597 \begin_layout Itemize
3598 character: string: The character to edit (UTF-8 encoded).
3601 \begin_layout Itemize
3602 glyph: BITMAP: The bitmap to use.
3605 \begin_layout Standard
3606 Replace character <character> in font <font> by <glyph>.
3609 \begin_layout Itemize
3610 Color index 0 is background, everything else is foreground.
3613 \begin_layout Itemize
3614 <character> may be empty string, meaning the replacement character used
3618 \begin_layout Itemize
3619 <character> may be multi-codepoint string, meaning character used for that
3623 \begin_layout Subsubsection
3624 Method dump: Dump font into file
3627 \begin_layout Itemize
3628 Syntax: font:dump(string filename[, string base])
3631 \begin_layout Standard
3635 \begin_layout Itemize
3636 filename: string: The file to dump to
3639 \begin_layout Itemize
3640 base: string: The base filename
3643 \begin_layout Standard
3644 Dump contents of <font> in file <filename> (resolved relative to <base>).
3645 The dump is in format CUSTOMFONT:load() can load.
3648 \begin_layout Standard
3649 \begin_inset Newpage pagebreak
3655 \begin_layout Subsection
3656 ICONV: Character set conversions
3659 \begin_layout Subsubsection
3660 Static function new: Create new character set converter
3663 \begin_layout Itemize
3664 Syntax: iconv iconv.new(from, to);
3667 \begin_layout Itemize
3668 Syntax: iconv classes.ICONV.new(from, to);
3671 \begin_layout Itemize
3672 Deprecated: iconv iconv_new(...);
3675 \begin_layout Standard
3679 \begin_layout Itemize
3680 from: string: The source character set.
3683 \begin_layout Itemize
3684 to: string: The target character set.
3687 \begin_layout Standard
3691 \begin_layout Itemize
3692 iconv: ICONV: The converter.
3695 \begin_layout Standard
3696 Create a character set converter, converting from <from> to <to> and return
3700 \begin_layout Subsubsection
3701 Operator(): Convert string fragment from character set to another
3704 \begin_layout Itemize
3705 Syntax: success, result, unconverted, error iconv(input)
3708 \begin_layout Standard
3712 \begin_layout Itemize
3713 iconv: ICONV: The context to use.
3716 \begin_layout Itemize
3717 input: string: The input to convert.
3720 \begin_layout Standard
3724 \begin_layout Itemize
3725 success: boolean: True if conversion was successful, false if not.
3728 \begin_layout Itemize
3729 result: string: The string (partially) converted.
3732 \begin_layout Itemize
3733 unconvered: number: Number of bytes that were not converted (only if <success>
3737 \begin_layout Itemize
3738 error: string: Error that caused conversion to stop (only if <success> is
3740 \begin_inset Separator latexpar
3747 \begin_layout Itemize
3748 INVALID: The input string is invalid.
3751 \begin_layout Itemize
3752 INCOMPLETE: The input string cuts off in middle of character.
3755 \begin_layout Itemize
3756 INTERNALERR: Internal error.
3760 \begin_layout Standard
3761 Convert a string <input> using character set converter <iconv> and return
3765 \begin_layout Standard
3766 \begin_inset Newpage pagebreak
3772 \begin_layout Subsection
3773 FILEREADER: Read a file as a stream
3776 \begin_layout Subsubsection
3777 Static function open: Open a stream
3780 \begin_layout Itemize
3781 Syntax: handle filereader.open(file, [base])
3784 \begin_layout Itemize
3785 Syntax: handle classes.FILEREADER.open(file, [base])
3788 \begin_layout Itemize
3789 Deprecated: handle open_file(file, [base])
3792 \begin_layout Standard
3796 \begin_layout Itemize
3797 file: string: The filename to read.
3800 \begin_layout Itemize
3801 base: string: The base <file> is resolved against.
3804 \begin_layout Standard
3808 \begin_layout Itemize
3809 handle: FILEREADER: The new file reader.
3812 \begin_layout Standard
3813 Open file <file> (relative to <base>) and return a handle to it.
3816 \begin_layout Subsubsection
3817 operator(): Read line/bytes from stream
3820 \begin_layout Itemize
3821 Syntax: result handle()
3824 \begin_layout Itemize
3825 Syntax: result handle(bytes)
3828 \begin_layout Standard
3832 \begin_layout Itemize
3833 handle: FILEREADER: The handle to read from.
3836 \begin_layout Itemize
3837 bytes: Number of bytes to read (default is next line).
3840 \begin_layout Standard
3844 \begin_layout Itemize
3845 result: string: The read data, or nil on end-of-file.
3848 \begin_layout Standard
3849 Reads next line or <bytes> bytes from specified file handle <handle>.
3852 \begin_layout Itemize
3853 If reading specified number of bytes, the bytes are read in binary mode
3857 \begin_layout Itemize
3858 If reading next line, the line is read in text mode (any line ending is
3862 \begin_layout Subsubsection
3863 Method lines: Iterator to read all lines
3866 \begin_layout Itemize
3867 Syntax: for line in handle:lines() do ...
3871 \begin_layout Standard
3875 \begin_layout Itemize
3876 handle: FILEREADER: The handle to read.
3879 \begin_layout Standard
3883 \begin_layout Itemize
3884 A lua iterator with one variable.
3887 \begin_layout Standard
3888 Return a Lua iterator that iterates all the lines in <handle>.
3891 \begin_layout Standard
3892 \begin_inset Newpage pagebreak
3898 \begin_layout Subsection
3899 COMPARE_OBJ: Watch memory area for changes
3902 \begin_layout Standard
3903 Objects of this class allow fast checking for modifications to given memory
3907 \begin_layout Subsubsection
3908 Static function new: Create a checker
3911 \begin_layout Itemize
3912 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3916 \begin_layout Itemize
3917 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3920 \begin_layout Standard
3924 \begin_layout Itemize
3925 marea: string: The memory area to interpret <offset> against.
3928 \begin_layout Itemize
3929 offset: number: The initial offset in memory area.
3932 \begin_layout Itemize
3933 addrobj: ADDRESS: The memory address.
3936 \begin_layout Itemize
3937 size: number: The number of bytes in each row.
3940 \begin_layout Itemize
3941 rows: number: The number of rows.
3945 \begin_layout Itemize
3946 stride: number: The number of bytes offset increments from one row to next.
3949 \begin_layout Standard
3953 \begin_layout Itemize
3957 \begin_layout Standard
3958 Return an object watching specified memory area.
3961 \begin_layout Itemize
3962 Note: For fastest operation, limit checks to inside one memory area (that
3963 has to be mappable, individual RAM areas often are).
3966 \begin_layout Subsubsection
3967 operator(): Check area for modifications
3970 \begin_layout Itemize
3971 Syntax: boolean handle()
3974 \begin_layout Standard
3978 \begin_layout Itemize
3979 True if memory block has been modified since last call (or object creation
3980 if first call), false if not.
3983 \begin_layout Standard
3984 Check if the block has been modified.
3987 \begin_layout Subsection
3988 ADDRESS: Memory address
3991 \begin_layout Standard
3992 Objects of this class contain a memory address.
3995 \begin_layout Subsubsection
3996 Static function new: Create new memory address
3999 \begin_layout Itemize
4000 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
4003 \begin_layout Itemize
4004 Syntax: ADDRESS memory.address.new(string marea, number offset)
4007 \begin_layout Itemize
4008 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
4011 \begin_layout Standard
4015 \begin_layout Itemize
4016 marea: The memory area
4019 \begin_layout Itemize
4020 offset: The offset in memory area.
4023 \begin_layout Standard
4027 \begin_layout Itemize
4031 \begin_layout Standard
4032 Construct a new memory address object.
4035 \begin_layout Subsubsection
4036 Method: addr: Get global address
4039 \begin_layout Itemize
4040 Syntax: number addr:addr()
4043 \begin_layout Standard
4047 \begin_layout Itemize
4048 addr: ADRESS: The original address.
4051 \begin_layout Standard
4055 \begin_layout Itemize
4056 The global address corresponding to this address.
4059 \begin_layout Subsubsection
4060 Method: vma: Get memory area
4063 \begin_layout Itemize
4064 Syntax: string addr:vma()
4067 \begin_layout Standard
4071 \begin_layout Itemize
4072 addr: ADRESS: The original address.
4075 \begin_layout Standard
4079 \begin_layout Itemize
4080 The memory area corresponding to this address.
4083 \begin_layout Subsubsection
4084 Method: offset: Get memory area offset
4087 \begin_layout Itemize
4088 Syntax: string addr:offset()
4091 \begin_layout Standard
4095 \begin_layout Itemize
4096 addr: ADRESS: The original address.
4099 \begin_layout Standard
4103 \begin_layout Itemize
4104 The offset in memory area corresponding to this address.
4107 \begin_layout Subsubsection
4108 Method: replace: Replace address part
4111 \begin_layout Itemize
4112 Syntax: ADDRESS addr:replace(offset[, bits])
4115 \begin_layout Standard
4119 \begin_layout Itemize
4120 addr: ADRESS: The original address.
4123 \begin_layout Itemize
4124 offset: number: The new offset
4127 \begin_layout Itemize
4128 bits: number: The number of LSB to replace.
4131 \begin_layout Standard
4135 \begin_layout Itemize
4136 The modified address
4139 \begin_layout Standard
4140 Returns a new address, with <bits> (all if missing) least significant bits
4141 of <addr> replaced by LSB of <offset>.
4144 \begin_layout Subsubsection
4145 Method: add: Add to address
4148 \begin_layout Itemize
4149 Syntax: ADDRESS addr:add(offset)
4152 \begin_layout Itemize
4153 Syntax: ADDRESS addr:add(number, stride)
4156 \begin_layout Itemize
4157 Syntax: ADDRESS addr:add(number, stride, offset)
4160 \begin_layout Standard
4164 \begin_layout Itemize
4165 addr: ADRESS: The original address.
4168 \begin_layout Itemize
4169 offset: number: Offset to add.
4172 \begin_layout Itemize
4173 number: number: Number of table strides to add.
4176 \begin_layout Itemize
4177 stride: number: The table stride.
4180 \begin_layout Standard
4184 \begin_layout Itemize
4185 The modified address
4188 \begin_layout Standard
4189 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
4193 \begin_layout Subsection
4194 ADDRESS:<op>: Read/Write memory
4197 \begin_layout Itemize
4198 Syntax: none addr:<op>(value)
4201 \begin_layout Itemize
4202 Syntax: number addr:<op>()
4205 \begin_layout Standard
4209 \begin_layout Itemize
4210 addr: ADDRESS: The address to read/write.
4213 \begin_layout Itemize
4214 value: number: The number to write.
4217 \begin_layout Standard
4221 \begin_layout Itemize
4225 \begin_layout Standard
4226 Read/Write value from/to given address <addr>.
4227 The value written is <value>.
4228 <Op> is of form: [i][s]<type>, where:
4231 \begin_layout Itemize
4232 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4235 \begin_layout Itemize
4236 'i' signifies that the value is treated as opposite-to-normal endianess,
4239 \begin_layout Itemize
4240 's' signifies that value is treated as signed (not available for floating-point).
4243 \begin_layout Standard
4244 \begin_inset Newpage pagebreak
4250 \begin_layout Section
4254 \begin_layout Subsection
4255 print: Print values to console
4258 \begin_layout Itemize
4259 Syntax: none print(value...
4263 \begin_layout Standard
4264 Prints specified values to console.
4265 Can print any Lua type at least enough to identify the type and instance.
4268 \begin_layout Subsection
4269 tostringx: Format a value to string
4272 \begin_layout Itemize
4273 Syntax: string tostringx(value val)
4276 \begin_layout Standard
4277 Formats value <val> like print would, and returns the result as a string.
4280 \begin_layout Subsection
4281 exec: Execute lsnes commands
4284 \begin_layout Itemize
4285 Syntax: none exec(string cmd)
4288 \begin_layout Standard
4289 Execute lsnes command <cmd>.
4292 \begin_layout Subsection
4293 utime: Get current time
4296 \begin_layout Itemize
4297 Syntax: (number,number) utime()
4300 \begin_layout Standard
4301 Returns two numbers.
4302 First is time since some epoch in seconds, the second is microseconds mod
4303 10^6 since that epoch.
4306 \begin_layout Subsection
4307 set_idle_timeout: Run function after timeout when emulator is idle
4310 \begin_layout Itemize
4311 Syntax: none set_idle_timeout(number timeout)
4314 \begin_layout Standard
4315 Set number of microseconds to block idle for.
4316 After this timeout has expired, on_idle() will be called once.
4319 \begin_layout Subsection
4320 set_timer_timeout: Run function after timeout.
4323 \begin_layout Itemize
4324 Syntax: none set_timer_timeout(number timeout)
4327 \begin_layout Standard
4328 Set number of microseconds to block timer for.
4329 After this timeout has expired, on_timer() will be called once.
4332 \begin_layout Subsection
4333 bus_address: Look up address in system bus.
4336 \begin_layout Itemize
4337 Syntax: none bus_address(number bus_addr)
4340 \begin_layout Standard
4341 Returns virtual address corresponding to specified address on system bus.
4344 \begin_layout Subsection
4345 loopwrapper: Convert loop into callable function
4348 \begin_layout Itemize
4349 Syntax: function loopwrapper(function fun, ...)
4352 \begin_layout Standard
4353 Calls function <fun> with function and specified arguments.
4354 The function passed suspends execution until the function returned is called.
4355 Handy for linear flow control among multiple invocations of a hook.
4359 \begin_layout LyX-Code
4360 on_paint = loopwrapper(function(wait)
4361 \begin_inset Separator latexpar
4368 \begin_layout LyX-Code
4370 \begin_inset Separator latexpar
4377 \begin_layout LyX-Code
4379 \begin_inset Quotes eld
4383 \begin_inset Quotes erd
4389 \begin_layout LyX-Code
4394 \begin_layout LyX-Code
4399 \begin_layout LyX-Code
4403 \begin_layout Subsection
4404 list_bindings: List keybindings
4407 \begin_layout Itemize
4408 Syntax: table list_bindings([string cmd])
4411 \begin_layout Standard
4412 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4413 If <cmd> is specified, the table is limited to that command.
4414 Also searches for controller keys.
4417 \begin_layout Subsection
4418 get_alias: Get expansion of alias
4421 \begin_layout Itemize
4422 Syntax: string get_alias(string aname)
4425 \begin_layout Standard
4426 Get expansion of given alias <aname>.
4429 \begin_layout Subsection
4430 set_alias: Set expansion of alias
4433 \begin_layout Itemize
4434 Syntax: none set_alias(string aname, string value)
4437 \begin_layout Standard
4438 Set expansion of given alias.
4441 \begin_layout Subsection
4442 create_ibind: Create invese binding
4445 \begin_layout Itemize
4446 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4449 \begin_layout Standard
4450 Return object representing inverse binding with specified name <name> and
4451 specified command <cmd>.
4454 \begin_layout Itemize
4455 Note: To create press/release commands, use aliases +foo and -foo .
4458 \begin_layout Itemize
4459 Note: Keep the returned object around.
4462 \begin_layout Subsection
4463 create_command: Create a command
4466 \begin_layout Itemize
4467 Syntax: COMMANDBIND create_command(string name, function a)
4470 \begin_layout Itemize
4471 Syntax: COMMANDBIND create_command(string name, function a, function b)
4474 \begin_layout Standard
4475 Return object representing a command (pair).
4478 \begin_layout Itemize
4479 If only one function is specied, the command is level-sensitive, <a> is
4483 \begin_layout Itemize
4484 If <b> is function, the function is edge-sensitive, <a> is positive edge
4485 callback and <b> is negative edge callback.
4488 \begin_layout Itemize
4489 All callbacks get single argument: The parameters passed.
4492 \begin_layout Itemize
4493 Keep the returned object around.
4496 \begin_layout Subsection
4497 loadfile: Load Lua script
4500 \begin_layout Itemize
4501 Syntax: function loadfile(string filename[, string base])
4504 \begin_layout Standard
4505 Load lua script from <filename>, resolved relative to <base> (if empty,
4509 \begin_layout Subsection
4510 dofile: Execute Lua script
4513 \begin_layout Itemize
4514 Syntax: function dofile(string filename[, string base])
4517 \begin_layout Standard
4518 Execute lua script from <filename>, resolved relative to <base> (if empty,
4519 current directory) and return all return values.
4522 \begin_layout Subsection
4523 resolve_filename: Resolve name of file relative to another
4526 \begin_layout Itemize
4527 Syntax: string resolve_filename(string filename[, string base])
4530 \begin_layout Standard
4531 Resolve name of file <filename> relative to <base> and return the result.
4534 \begin_layout Subsection
4535 render_queue_function: Return paint function for render queue
4538 \begin_layout Itemize
4539 Syntax: function render_queue_function(RENDERQUEUE rq)
4542 \begin_layout Standard
4543 Return function that renders render queue <rq>.
4546 \begin_layout Itemize
4547 Handy for paint callback if one is using render queues updated in other
4552 \begin_layout LyX-Code
4553 handle = callback.paint:register(render_queue_function(my_rq));
4556 \begin_layout Subsection
4557 get_directory_contents: Get files in directory
4560 \begin_layout Itemize
4561 Syntax: table get_directory_contents(string name[, string base[, string
4565 \begin_layout Standard
4566 Return array containg all files in specified directory <name> (relative
4568 If <pattern> is specified, the filenames are matched to specified regex.
4569 The returned filenames inherit path.
4572 \begin_layout Subsection
4573 get_file_type: Get type of file
4576 \begin_layout Itemize
4577 Syntax: string/nil get_file_type(string path)
4580 \begin_layout Standard
4581 Return type of file <path>.
4582 Currently possible return values are:
4585 \begin_layout Itemize
4586 regular: regular file
4589 \begin_layout Itemize
4590 directory: subdirectory
4593 \begin_layout Itemize
4594 unknown: Exists, but type not known (not anything above).
4597 \begin_layout Itemize
4598 <nil>: File does not exist.
4601 \begin_layout Subsection
4602 identify_class: Identify class of object
4605 \begin_layout Itemize
4606 Syntax: string identify_class(userdata object)
4609 \begin_layout Standard
4610 Identifies the class of userdata <object>, if possible.
4611 If no identification is possible, returns
4612 \begin_inset Quotes eld
4616 \begin_inset Quotes erd
4622 \begin_layout Subsection
4623 lookup_class: Lookup class by name
4626 \begin_layout Itemize
4627 Syntax: classobj lookup_class(string name)
4630 \begin_layout Standard
4631 Looks up class corresponding to <name>, if possible.
4632 If not found, returns nil.
4633 The classobj has following fields:
4636 \begin_layout Itemize
4637 _static_methods: Return static method names
4640 \begin_layout Itemize
4641 _class_methods: Return class method names
4644 \begin_layout Itemize
4645 <static-function-name>: The specified static function.
4648 \begin_layout Subsection
4649 all_classes: Get list of all classes
4652 \begin_layout Itemize
4657 \begin_layout Standard
4658 Get names of all classes available.
4661 \begin_layout Subsection
4662 lsnes_features: Read feature flags
4665 \begin_layout Itemize
4666 Syntax: boolean lsnes_features(string feature)
4669 \begin_layout Standard
4670 Checks if feature <feature> is available, if it is, returns true, otherwise
4672 The following features are known:
4675 \begin_layout Itemize
4676 text-halos: gui.text supports halos (takes halo color argument).
4679 \begin_layout Subsection
4683 \begin_layout Standard
4687 \begin_layout Subsection
4688 filereader: Class FILEREADER
4691 \begin_layout Standard
4692 See class FILEREADER.
4695 \begin_layout Standard
4696 \begin_inset Newpage pagebreak
4702 \begin_layout Section
4706 \begin_layout Standard
4707 Bitwise logical functions and related.
4710 \begin_layout Subsection
4711 bit.none/bit.bnot: Bitwise none or NOT function
4714 \begin_layout Itemize
4715 Syntax: number bit.none(number...)
4718 \begin_layout Itemize
4719 Syntax: number bit.bnot(number...)
4722 \begin_layout Standard
4723 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4727 \begin_layout Subsection
4728 bit.any/bit.bor: Bitwise any or OR function
4731 \begin_layout Itemize
4732 Syntax: number bit.any(number...)
4735 \begin_layout Itemize
4736 Syntax: number bit.bor(number...)
4739 \begin_layout Standard
4740 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4743 \begin_layout Subsection
4744 bit.all/bit.band: Bitwise all or AND function
4747 \begin_layout Itemize
4748 Syntax: number bit.all(number...)
4751 \begin_layout Itemize
4752 Syntax: number bit.band(number...)
4755 \begin_layout Standard
4756 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4760 \begin_layout Subsection
4761 bit.parity/bit.bxor: Bitwise parity or XOR function
4764 \begin_layout Itemize
4765 Syntax: number bit.parity(number...)
4768 \begin_layout Itemize
4769 Syntax: number bit.bxor(number...)
4772 \begin_layout Standard
4773 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4777 \begin_layout Subsection
4778 bit.lrotate: Rotate a number left
4781 \begin_layout Itemize
4782 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4785 \begin_layout Standard
4786 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4790 \begin_layout Subsection
4791 bit.rrotate: Rotate a number right
4794 \begin_layout Itemize
4795 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4798 \begin_layout Standard
4799 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4803 \begin_layout Subsection
4804 bit.lshift: Shift a number left
4807 \begin_layout Itemize
4808 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4811 \begin_layout Standard
4812 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4814 The new bits are filled with zeroes.
4817 \begin_layout Subsection
4818 bit.lrshift: Shift a number right (logical)
4821 \begin_layout Itemize
4822 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4825 \begin_layout Standard
4826 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4828 The new bits are filled with zeroes.
4831 \begin_layout Subsection
4832 bit.arshift: Shift a number right (arithmetic)
4835 \begin_layout Itemize
4836 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4839 \begin_layout Standard
4840 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4842 The new bits are shifted in with copy of the high bit.
4845 \begin_layout Subsection
4846 bit.extract: Extract/shuffle bits from number
4849 \begin_layout Itemize
4850 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4853 \begin_layout Standard
4854 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4857 \begin_layout Itemize
4858 Note: Bit numbers up to 51 should work reliably (then things start falling
4859 apart due to double precision issues).
4862 \begin_layout Itemize
4863 Note: There are two special bit positions, true and false, standing for
4864 always set bit and always clear bit.
4867 \begin_layout Subsection
4868 bit.value: Construct number with specified bits set
4871 \begin_layout Itemize
4872 Syntax: number bit.value([number bit1[, number bit2,...]])
4875 \begin_layout Standard
4876 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4877 <bit2> places and so on.
4878 As special value, nil argument is no-op.
4881 \begin_layout Subsection
4882 bit.test: Test if bit is set
4885 \begin_layout Itemize
4886 Syntax: boolean bit.test(number a, number bit)
4889 \begin_layout Standard
4890 Tests if bit <bit> is set in <a>.
4891 If it is set, returns true, otherwise false.
4894 \begin_layout Subsection
4895 bit.testn: Test if bit is clear
4898 \begin_layout Itemize
4899 Syntax: boolean bit.testn(number a, number bit)
4902 \begin_layout Standard
4903 Tests if bit <bit> is set in <a>.
4904 If it is clear, returns true, otherwise false.
4907 \begin_layout Subsection
4908 bit.test_any: Test if any bit is set
4911 \begin_layout Itemize
4912 Syntax: boolean bit.test_any(number a, number b)
4915 \begin_layout Standard
4916 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4919 \begin_layout Subsection
4920 bit.test_all: Test if all bits are set
4923 \begin_layout Itemize
4924 Syntax: boolean bit.test_all(number a, number b)
4927 \begin_layout Standard
4928 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4931 \begin_layout Subsection
4932 bit.popcount: Population count
4935 \begin_layout Itemize
4936 Syntax: number bit.popcount(number a)
4939 \begin_layout Standard
4940 Returns number of set bits in <a>.
4943 \begin_layout Subsection
4944 bit.clshift: Chained left shift
4947 \begin_layout Itemize
4948 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4952 \begin_layout Standard
4953 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4954 numbers to be of specified number of bits <bits> (default 48).
4957 \begin_layout Subsection
4958 bit.crshift: Chained right shift
4961 \begin_layout Itemize
4962 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4966 \begin_layout Standard
4967 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4968 assuming numbers to be of specified number of bits <bits> (default 48).
4971 \begin_layout Subsection
4972 bit.flagdecode: Decode bitfield into flags
4975 \begin_layout Itemize
4976 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4980 \begin_layout Standard
4981 Return string of length bits where ith character is ith character of on
4982 if bit i is on, otherwise ith character of off.
4983 Out of range reads give last character.
4986 \begin_layout Itemize
4987 Note: <on> defaults to '*' if empty.
4990 \begin_layout Itemize
4991 Note: <off> defaults to '-' if empty.
4994 \begin_layout Subsection
4995 bit.rflagdecode: Decode bitfield into flags
4998 \begin_layout Itemize
4999 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
5003 \begin_layout Standard
5004 Like bit.flagdecode, but outputs the string in the opposite order (most significa
5008 \begin_layout Subsection
5009 bit.swap{,s}{,h,d,q}word: Swap word endian
5012 \begin_layout Itemize
5013 Syntax: number bit.swapword(number n)
5016 \begin_layout Itemize
5017 Syntax: number bit.swaphword(number n)
5020 \begin_layout Itemize
5021 Syntax: number bit.swapdword(number n)
5024 \begin_layout Itemize
5025 Syntax: number bit.swapqword(number n)
5028 \begin_layout Itemize
5029 Syntax: number bit.swapsword(number n)
5032 \begin_layout Itemize
5033 Syntax: number bit.swapshword(number n)
5036 \begin_layout Itemize
5037 Syntax: number bit.swapsdword(number n)
5040 \begin_layout Itemize
5041 Syntax: number bit.swapsqword(number n)
5044 \begin_layout Standard
5045 Swap endianess of (un)signed integer <n>.
5048 \begin_layout Subsection
5049 bit.compose: Compose multi-byte number
5052 \begin_layout Itemize
5053 Syntax: number bit.compose(number n...)
5056 \begin_layout Standard
5058 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
5064 \begin_layout Subsection
5065 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
5068 \begin_layout Itemize
5069 Syntax: number bit.binary_ld_<type>le(string str, number pos);
5072 \begin_layout Itemize
5073 Syntax: number bit.binary_ld_<type>be(string str, number pos);
5076 \begin_layout Standard
5077 Load little (*le) or big (*be) endian binary number from position <pos>
5079 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5083 \begin_layout Subsection
5084 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
5087 \begin_layout Itemize
5088 Syntax: string bit.binary_st_<type>le(number x);
5091 \begin_layout Itemize
5092 Syntax: string bit.binary_st_<type>be(number x);
5095 \begin_layout Standard
5096 Store specified number <x> as binary in string and return the result.
5097 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5101 \begin_layout Subsection
5102 bit.quotent: Integer quotent
5105 \begin_layout Itemize
5106 Syntax: number bit.quotent(number a, number b)
5109 \begin_layout Standard
5110 Calculate quotent a/b.
5113 \begin_layout Subsection
5114 bit.multidiv: Divide and split among multiple divisiors
5117 \begin_layout Itemize
5119 bit.multidiv(number v, number q...)
5122 \begin_layout Standard
5123 Does the following steps:
5126 \begin_layout Enumerate
5130 \begin_layout Enumerate
5132 \begin_inset Separator latexpar
5139 \begin_layout Enumerate
5140 Calculate quotent(v'/q) and add that to numbers returned.
5143 \begin_layout Enumerate
5144 v' <- remainder(v'/q)
5148 \begin_layout Enumerate
5149 Add v' to numbers returned.
5152 \begin_layout Standard
5153 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
5155 <v> may be floating point, <q>s are integers.
5158 \begin_layout Itemize
5160 bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
5163 \begin_layout Itemize
5165 bit.multidiv(a, b) calculates quotent and remainder of a/b.
5168 \begin_layout Subsection
5169 bit.mul32: 32-bit multiply
5172 \begin_layout Itemize
5173 Syntax: number, number bit.mul32(number a, number b)
5176 \begin_layout Standard
5177 Multiply 32-bit numbers <a> and <b>.
5178 The first return value is low 32 bits of result, the second is high 32
5182 \begin_layout Subsection
5183 bit.fextract: Extract bit field
5186 \begin_layout Itemize
5187 Syntax: number bit.fextract(number value, number shift, number width)
5190 \begin_layout Standard
5191 Extract <width> bits starting from bit <shift> from number <value>.
5192 This is more compact way to write
5193 \begin_inset Formula $\left(value\gg shift\right)\&\left(2^{width}-1\right)$
5199 \begin_layout Subsection
5200 bit.bfields: Split number into bit fields
5203 \begin_layout Itemize
5205 bit.bfields(number v, number q...)
5208 \begin_layout Standard
5209 Split a number <v> into bitfields of <q> bits (in order, from least significant
5210 towards more significant bits), with no padding in between.
5213 \begin_layout Itemize
5215 number of form 0 bbbbb ggggg rrrrr can be decoded to its component fields
5216 using r,g,b = bit.bfields(v, 5, 5, 5).
5220 \begin_layout Itemize
5222 number of form x yyyyyyy w zzzzzzz can be decode to its component fields
5223 using z, w, y, x = bit.bfields(v, 7, 1, 7, 1).
5226 \begin_layout Standard
5227 \begin_inset Newpage pagebreak
5233 \begin_layout Section
5237 \begin_layout Subsection
5238 classes.<foo>: The classobj for class <foo>
5241 \begin_layout Itemize
5242 Syntax: classes.<foo>
5245 \begin_layout Standard
5246 The classobj for class <foo>.
5249 \begin_layout Subsection
5250 classes.<foo>._static_methods: Enumerate static methods
5253 \begin_layout Itemize
5255 classes.<foo>._static_methods()
5258 \begin_layout Standard
5259 Returns all static methods of <foo> as strings.
5262 \begin_layout Subsection
5263 classes.<foo>._class_methods: Enumerate static methods
5266 \begin_layout Itemize
5268 classes.<foo>._class_methods()
5271 \begin_layout Standard
5272 Returns all class methods of <foo> as strings.
5275 \begin_layout Subsection
5276 classes.<foo>.<bar>: Static method
5279 \begin_layout Itemize
5280 Syntax: variable classes.<foo>.<bar>(variable...)
5283 \begin_layout Standard
5284 Invokes static method <bar> of class <foo>.
5287 \begin_layout Section
5291 \begin_layout Subsection
5292 gui.resolution: Get current resolution
5295 \begin_layout Itemize
5296 Syntax: (number, number) gui.resolution()
5299 \begin_layout Standard
5300 Returns 2-tuple (hresolution, vresolution).
5303 \begin_layout Subsection
5304 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
5307 \begin_layout Itemize
5308 Syntax: number gui.left_gap(number gap)
5311 \begin_layout Itemize
5312 Syntax: number gui.right_gap(number gap)
5315 \begin_layout Itemize
5316 Syntax: number gui.top_gap(number gap)
5319 \begin_layout Itemize
5320 Syntax: number gui.bottom_gap(number gap)
5323 \begin_layout Standard
5324 Set the specified edge gap to specified value <gap> (max gap is 8191).
5325 If successful, old gap is returned.
5328 \begin_layout Subsection
5329 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
5333 \begin_layout Itemize
5334 Syntax: number gui.delta_left_gap(number dgap)
5337 \begin_layout Itemize
5338 Syntax: number gui.delta_right_gap(number dgap)
5341 \begin_layout Itemize
5342 Syntax: number gui.delta_top_gap(number dgap)
5345 \begin_layout Itemize
5346 Syntax: number gui.delta_bottom_gap(number dgap)
5349 \begin_layout Standard
5350 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
5351 and return the old gap (returns nothing on error).
5354 \begin_layout Subsection
5355 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
5358 \begin_layout Itemize
5359 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
5360 bgc[, number hlc]]])
5363 \begin_layout Itemize
5364 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
5365 bgc[, number hlc]]])
5368 \begin_layout Itemize
5369 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
5370 bgc[, number hlc]]])
5373 \begin_layout Itemize
5374 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
5375 bgc[, number hlc]]])
5378 \begin_layout Standard
5379 Draw specified text on the GUI (each character cell is 8 or 16 wide and
5384 \begin_layout Itemize
5385 x: X-coordinate to start the drawing from (and x-coordinate at begining
5389 \begin_layout Itemize
5390 y: Y-coordinate to start the drawing from.
5393 \begin_layout Itemize
5394 text: The text to draw.
5397 \begin_layout Itemize
5398 fgc: Text color (default is 0xFFFFFF (white))
5401 \begin_layout Itemize
5402 bgc: Background color (default is -1 (transparent))
5405 \begin_layout Itemize
5406 hlc: Halo color (default is -1 (transparent))
5409 \begin_layout Standard
5410 Note: The H variants draw at double width and V variants draw at double
5412 Halo thickness is always 1 and is not doubled.
5415 \begin_layout Subsection
5416 gui.rectangle: Draw a rectangle
5419 \begin_layout Itemize
5420 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5421 number thickness[, number outline[, number fill]]])
5424 \begin_layout Standard
5425 Draw rectangle on the GUI.
5429 \begin_layout Itemize
5430 x: X-coordinate of left edge.
5433 \begin_layout Itemize
5434 y: Y-coordinate of upper edge.
5437 \begin_layout Itemize
5438 width: Width of rectangle.
5441 \begin_layout Itemize
5442 height: Height of rectangle.
5445 \begin_layout Itemize
5446 thickness: Thickness of outline (default is 1).
5449 \begin_layout Itemize
5450 outline: Color of outline (default is 0xFFFFFF (white))
5453 \begin_layout Itemize
5454 fill: Color of fill (default is -1 (transparent))
5457 \begin_layout Subsection
5458 gui.solidrectangle: Draw a solid rectangle
5461 \begin_layout Itemize
5462 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5466 \begin_layout Standard
5467 Draw solid rectangle on the GUI.
5471 \begin_layout Itemize
5472 x: X-coordinate of left edge.
5475 \begin_layout Itemize
5476 y: Y-coordinate of upper edge.
5479 \begin_layout Itemize
5480 width: Width of rectangle.
5483 \begin_layout Itemize
5484 height: Height of rectangle.
5487 \begin_layout Itemize
5488 color: Color of rectangle (default is 0xFFFFFF (white))
5491 \begin_layout Subsection
5492 gui.box: Draw a 3D-effect box
5495 \begin_layout Itemize
5496 Syntax: none gui.box(number x, number y, number width, number height[, number
5497 thickness[, number outline1[,number outline2[, number fill]]]])
5500 \begin_layout Standard
5501 Draw rectangle with 3D effect on the GUI.
5505 \begin_layout Itemize
5506 x: X-coordinate of left edge.
5509 \begin_layout Itemize
5510 y: Y-coordinate of upper edge.
5513 \begin_layout Itemize
5514 width: Width of rectangle.
5517 \begin_layout Itemize
5518 height: Height of rectangle.
5521 \begin_layout Itemize
5522 thickness: Thickness of outline (default is 1).
5525 \begin_layout Itemize
5526 outline1: First color of outline (default is 0xFFFFFF (white))
5529 \begin_layout Itemize
5530 outline2: First color of outline (default is 0x808080 (dark gray))
5533 \begin_layout Itemize
5534 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5537 \begin_layout Subsection
5538 gui.pixel: Draw a single pixel
5541 \begin_layout Itemize
5542 Syntax: none gui.pixel(number x, number y[, number color])
5545 \begin_layout Standard
5546 Draw one pixel on the GUI.
5550 \begin_layout Itemize
5551 x: X-coordinate of the pixel
5554 \begin_layout Itemize
5555 y: Y-coordinate of the pixel
5558 \begin_layout Itemize
5559 color: Color of the pixel (default is 0xFFFFFF (white))
5562 \begin_layout Subsection
5563 gui.crosshair: Draw a crosshair
5566 \begin_layout Itemize
5567 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5570 \begin_layout Standard
5575 \begin_layout Itemize
5576 x: X-coordinate of the crosshair
5579 \begin_layout Itemize
5580 y: Y-coordinate of the crosshair
5583 \begin_layout Itemize
5584 length: Length of the crosshair lines (default 10).
5587 \begin_layout Itemize
5588 color: Color of the crosshair (default is 0xFFFFFF (white))
5591 \begin_layout Subsection
5592 gui.line: Draw a line
5595 \begin_layout Itemize
5596 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5600 \begin_layout Standard
5605 \begin_layout Itemize
5606 x1: X-coordinate of one end.
5609 \begin_layout Itemize
5610 y1: Y-coordinate of one end.
5613 \begin_layout Itemize
5614 x2: X-coordinate of the other end.
5617 \begin_layout Itemize
5618 y2: Y-coordinate of the other end.
5621 \begin_layout Itemize
5622 color: Color of the line (default is 0xFFFFFF (white)).
5625 \begin_layout Subsection
5626 gui.circle: Draw a (filled) circle
5629 \begin_layout Itemize
5630 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5631 border[, number fil]]])
5634 \begin_layout Standard
5639 \begin_layout Itemize
5640 x: X-coordinate of the center
5643 \begin_layout Itemize
5644 y: Y-coordinate of the center
5647 \begin_layout Itemize
5648 r: The radius of the circle
5651 \begin_layout Itemize
5652 thick: Border thickness
5655 \begin_layout Itemize
5656 border: Border color (default is 0xFFFFFF (white))
5659 \begin_layout Itemize
5660 fill: Fill color (default is -1 (transparent)).
5663 \begin_layout Subsection
5664 gui.repaint: Arrange a repaint
5667 \begin_layout Itemize
5668 Syntax: none gui.repaint()
5671 \begin_layout Standard
5672 Request on_repaint() to happen as soon as possible.
5675 \begin_layout Subsection
5676 gui.subframe_update: Enable/Disable subframe updates
5679 \begin_layout Itemize
5680 Syntax: none gui.subframe_update(boolean on)
5683 \begin_layout Standard
5684 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5685 or not happen (<on>=false).
5688 \begin_layout Subsection
5689 gui.screenshot: Write a screenshot
5692 \begin_layout Itemize
5693 Syntax: none gui.screenshot(string filename)
5696 \begin_layout Standard
5697 Write PNG screenshot of the current frame (no drawings) to specified file
5701 \begin_layout Subsection
5702 gui.screenshot_bitmap: Write a screenshot to bitmap
5705 \begin_layout Itemize
5706 Syntax: DBITMAP gui.screenshot_bitmap()
5709 \begin_layout Standard
5710 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5714 \begin_layout Subsection
5715 gui.color: Compose a color.
5718 \begin_layout Itemize
5719 Syntax: number gui.color(number r, number g, number b[, number a])
5722 \begin_layout Itemize
5723 Syntax: number gui.color(string c)
5726 \begin_layout Standard
5727 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5728 , each component in scale 0-255.
5729 If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5731 The default alpha is 256.
5734 \begin_layout Standard
5735 The form taking a string returns color corresponding color name.
5738 \begin_layout Subsection
5739 gui.status: Set status variable
5742 \begin_layout Itemize
5743 Syntax: none gui.status(string name, string value)
5746 \begin_layout Standard
5748 \begin_inset Quotes eld
5752 \begin_inset Quotes erd
5755 to <value> in status area.
5758 \begin_layout Subsection
5759 gui.rainbow: Rainbow color calculation
5762 \begin_layout Itemize
5763 Syntax: number gui.rainbow(number step, number steps[, number color])
5766 \begin_layout Standard
5767 Perform hue rotation of color <color> (default bright red), by <step> steps.
5768 The number of steps per full rotation is given by absolute value of <steps>.
5771 \begin_layout Standard
5772 If <step> is negative, the rotation will be counterclockwise.
5775 \begin_layout Subsection
5776 gui.kill_frame: Kill video frame and associated sound
5779 \begin_layout Itemize
5780 Syntax: none gui.kill_frame()
5783 \begin_layout Standard
5784 Kills the currently dumped video frame + the associated sound.
5785 Only valid in on_video callback.
5788 \begin_layout Subsection
5789 gui.set_video_scale: Set video frame scale
5792 \begin_layout Itemize
5793 Syntax: none gui.set_video_scale(number h, number v)
5796 \begin_layout Standard
5797 Sets the scale factors of current frame to <h>x<v>.
5798 Only valid in on_video callback.
5801 \begin_layout Subsection
5802 gui.arrow: Draw an arrow
5805 \begin_layout Itemize
5806 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5807 number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5811 \begin_layout Standard
5812 Draws an arrow using color <color>.
5813 The tip of arrow is at (<x>, <y>).
5817 \begin_layout Enumerate
5818 <length>: The length of arrow tail.
5821 \begin_layout Enumerate
5822 <hwidth>: The width of arrow head.
5826 \begin_layout Enumerate
5827 <direction>: Direction of arrow.
5828 0 is to right, +1 rotates 45 degrees counterclockwise.
5831 \begin_layout Enumerate
5832 <fill>: If true, fill the arrow head.
5836 \begin_layout Enumerate
5837 <twidth>: Tail width.
5842 \begin_layout Enumerate
5843 <hthick>: Head thickness (only used if <fill> is false).
5844 Default is <twidth>.
5847 \begin_layout Subsection
5848 gui.tiled_bitmap: Class TILEMAP
5851 \begin_layout Standard
5855 \begin_layout Subsection
5856 gui.palette: Class PALETTE
5859 \begin_layout Standard
5863 \begin_layout Subsection
5864 gui.bitmap: Class BITMAP
5867 \begin_layout Standard
5871 \begin_layout Subsection
5872 gui.dbitmap: Class DBITMAP
5875 \begin_layout Standard
5879 \begin_layout Subsection
5880 gui.font: Class CUSTOMFONT
5883 \begin_layout Standard
5884 See class CUSTOMFONT.
5887 \begin_layout Subsection
5888 gui.renderctx: Class RENDERCTX
5891 \begin_layout Standard
5892 See class RENDERCTX.
5895 \begin_layout Subsection
5896 gui.image: Class IMAGELOADER
5899 \begin_layout Standard
5900 See class IMAGELOADER.
5903 \begin_layout Subsection
5904 gui.get_runmode: Get current emulator mode
5907 \begin_layout Itemize
5908 Syntax: string gui.get_runmode()
5911 \begin_layout Standard
5912 Gets the current emulator runmode.
5913 The possible ones are:
5916 \begin_layout Itemize
5917 quit: Emulator is quitting.
5920 \begin_layout Itemize
5921 normal: Emulator is running emulation
5924 \begin_layout Itemize
5925 load: Emulator is loading a movie/savestate
5928 \begin_layout Itemize
5929 advance_frame: Emulator is doing frame advance
5932 \begin_layout Itemize
5933 advance_subframe: Emulator is doing subframe advance
5936 \begin_layout Itemize
5937 skiplag: Emulator is skipping lag frames
5940 \begin_layout Itemize
5941 skiplag_pending: Emulator will start skipping lag frames next frame
5944 \begin_layout Itemize
5945 pause: Emulator is paused
5948 \begin_layout Itemize
5949 pause_break: Emulator is paused at breakpoint
5952 \begin_layout Itemize
5953 corrupt: Emulator can't run because corrupt emulation state
5956 \begin_layout Itemize
5957 unknown: Unknown state (should not happen).
5960 \begin_layout Standard
5961 \begin_inset Newpage pagebreak
5967 \begin_layout Section
5971 \begin_layout Standard
5973 Functions manipulating input are only available in on_input callback.
5976 \begin_layout Subsection
5977 input.get: Read controller button/axis (deprecated)
5980 \begin_layout Itemize
5981 Syntax: number input.get(number controller, number index)
5984 \begin_layout Standard
5985 Read the specified index <index> (zero-based) from specified controller
5986 <controller> (zero-based).
5990 \begin_layout Subsection
5991 input.set: Write controller button/axis (deprecated)
5994 \begin_layout Itemize
5995 Syntax: none input.set(number controller, number index, number value)
5998 \begin_layout Standard
5999 Write the specified index <index> (zero-based) from specified controller
6000 <controller> (zero-based), storing value <value>.
6003 \begin_layout Subsection
6004 input.get2: Read controller button/axis
6007 \begin_layout Itemize
6008 Syntax: number input.get2(number port, number controller, number index)
6011 \begin_layout Standard
6012 Read the specified input tuple.
6013 Port 0 is system port.
6016 \begin_layout Subsection
6017 input.set2: Write controller button/axis
6020 \begin_layout Itemize
6021 Syntax: input.set2(number port, number controller, number index, number value)
6024 \begin_layout Standard
6025 Write the specified input tuple.
6026 Port 0 is system port.
6029 \begin_layout Subsection
6030 input.lcid_to_pcid2: Look up logical controller
6033 \begin_layout Itemize
6034 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
6037 \begin_layout Standard
6038 Look up physical pcid pair (port, controller) corresponding to specified
6039 logical controller (1-based).
6040 Returns nothing if controller does not exist.
6043 \begin_layout Subsection
6044 input.port_type: Look up port type
6047 \begin_layout Itemize
6048 Syntax: string input.port_type(number port)
6051 \begin_layout Standard
6052 Return type of specified port.
6055 \begin_layout Subsection
6056 input.controller_info: Get information about controller
6059 \begin_layout Itemize
6060 Syntax: table input.controller_info(number port, number controller)
6063 \begin_layout Standard
6064 Get controller info for specified controller.
6065 If controller does not exist, returns nil.
6066 Otherwise returns a table with following fields:
6069 \begin_layout Itemize
6070 type (string): Type of the controller.
6073 \begin_layout Itemize
6074 class (string): Class of the controller.
6077 \begin_layout Itemize
6078 classnum (number): Number of the controller within its class (1-based)
6081 \begin_layout Itemize
6082 lcid (number): Logical controller number of the controller.
6085 \begin_layout Itemize
6086 button_count (number): Number of buttons on controller
6089 \begin_layout Itemize
6090 buttons (array): Array of following info about each button:
6091 \begin_inset Separator latexpar
6098 \begin_layout Itemize
6099 type (string): Type of button.
6101 \begin_inset Quotes eld
6105 \begin_inset Quotes erd
6109 \begin_inset Quotes eld
6113 \begin_inset Quotes erd
6117 \begin_inset Quotes eld
6121 \begin_inset Quotes erd
6125 \begin_inset Quotes eld
6129 \begin_inset Quotes erd
6135 \begin_layout Itemize
6136 name (string): Name of button.
6139 \begin_layout Itemize
6140 symbol (string): Symbol of button.
6141 Only present for type
6142 \begin_inset Quotes eld
6146 \begin_inset Quotes erd
6152 \begin_layout Itemize
6153 hidden (boolean): True if hidden button.
6158 \begin_layout Subsection
6159 input.veto_button: Veto a button press
6162 \begin_layout Itemize
6163 Syntax: none input.veto_button()
6166 \begin_layout Standard
6167 Signals that the button event should be vetoed.
6168 Only valid in on_button callback.
6171 \begin_layout Subsection
6172 input.geta: Get all buttons for controller (deprecated)
6175 \begin_layout Itemize
6176 Syntax: (number, number...) input.geta(number controller)
6179 \begin_layout Standard
6180 Get input state for entiere controller.
6181 Returns n return values.
6184 \begin_layout Itemize
6185 1st return value: Bitmask: bit i is set if i:th index is nonzero
6188 \begin_layout Itemize
6189 2nd- return value: value of i:th index.
6192 \begin_layout Subsection
6193 input.seta: Set all buttons for controller (deprecated)
6196 \begin_layout Itemize
6197 Syntax: none input.seta(number controller, number bitmask, number args...)
6200 \begin_layout Standard
6201 Set state for entiere controller.
6202 args is up to N values for indices (overriding values in bitmask if specified).
6205 \begin_layout Subsection
6206 input.controllertype: Get controller type (deprecated)
6209 \begin_layout Itemize
6210 syntax: string input.controllertype(number controller)
6213 \begin_layout Standard
6214 Get the type of controller as string.
6217 \begin_layout Subsection
6218 input.reset: Execute (delayed) reset
6221 \begin_layout Itemize
6222 Syntax: none input.reset([number cycles])
6225 \begin_layout Standard
6227 If <cycles> is greater than zero, do delayed reset.
6228 0 (or no value) causes immediate reset.
6231 \begin_layout Itemize
6232 Note: Only available with subframe flag false.
6235 \begin_layout Subsection
6236 input.raw: Return raw input data
6239 \begin_layout Itemize
6240 Syntax: table input.raw()
6243 \begin_layout Standard
6244 Returns table of tables of all available keys and axes.
6245 The first table is indexed by key name (platform-dependent!), and the inner
6246 table has the following fields:
6249 \begin_layout Itemize
6250 value: Last reported value for control
6251 \begin_inset Separator latexpar
6258 \begin_layout Itemize
6259 For keys: 1 for pressed, 0 for released.
6262 \begin_layout Itemize
6263 For axes: -32767...32767.
6266 \begin_layout Itemize
6267 For presure-sensitive buttons: 0...32767.
6270 \begin_layout Itemize
6271 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
6274 \begin_layout Itemize
6275 For mouse: Coordinates relative to game area.
6279 \begin_layout Itemize
6280 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
6283 \begin_layout Subsection
6284 input.keyhook: Hook a key
6287 \begin_layout Itemize
6288 Syntax: none input.keyhook(string key, boolean state)
6291 \begin_layout Standard
6292 Requests that keyhook events to be sent for key <key> (<state>=true) or
6293 not sent (<state>=false).
6296 \begin_layout Subsection
6297 input.joyget: Get controls for controller
6300 \begin_layout Itemize
6301 Syntax: table input.joyget(number logical)
6304 \begin_layout Standard
6305 Returns table for current controls for specified logical controller <logical>.
6306 The names of fields vary by controller type.
6309 \begin_layout Itemize
6310 The buttons have the same name as those are referred to in other contexts
6314 \begin_layout Itemize
6315 The analog axes are usually
6316 \begin_inset Quotes eld
6320 \begin_inset Quotes erd
6324 \begin_inset Quotes eld
6328 \begin_inset Quotes erd
6334 \begin_layout Itemize
6335 Each field is numeric or boolean depending on axis/button.
6338 \begin_layout Subsection
6339 input.joyset: Set controls for controller
6342 \begin_layout Itemize
6343 Syntax: none input.joyset(number controller, table controls)
6346 \begin_layout Standard
6347 Set the the state of specified controller to values specified in specified
6351 \begin_layout Itemize
6352 Each field can be boolean or number.
6355 \begin_layout Itemize
6356 Also, buttons allow strings, which cause value to be inverted.
6359 \begin_layout Subsection
6360 input.lcid_to_pcid: Look up logical controller (deprecated)
6363 \begin_layout Itemize
6364 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
6367 \begin_layout Standard
6368 Returns the legacy pcid for controller (or false if there isn't one), followed
6370 Returns nothing if controller does not exist.
6373 \begin_layout Standard
6374 \begin_inset Newpage pagebreak
6380 \begin_layout Section
6384 \begin_layout Standard
6385 Various keybinding-related functions
6388 \begin_layout Subsection
6389 keyboard.bind: Bind a key
6392 \begin_layout Itemize
6393 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
6396 \begin_layout Standard
6397 Bind specified key with specified modifers to specified command.
6400 \begin_layout Subsection
6401 keyboard.unbind: Unbind a key
6404 \begin_layout Itemize
6405 Syntax: none keyboard.unbind(string mod, string mask, string key)
6408 \begin_layout Standard
6409 Unbind specified key with specified modifers.
6412 \begin_layout Subsection
6413 keyboard.alias: Set alias expansion
6416 \begin_layout Itemize
6417 Syntax: none keyboard.alias(string alias, string expansion)
6420 \begin_layout Standard
6421 Set expansion of given command.
6424 \begin_layout Standard
6425 \begin_inset Newpage pagebreak
6431 \begin_layout Section
6435 \begin_layout Standard
6439 \begin_layout Subsection
6440 subtitle.byindex: Look up start and length of subtitle by index
6443 \begin_layout Itemize
6444 Syntax: (number, number) subtitle.byindex(number i)
6447 \begin_layout Standard
6448 Read the frame and length of ith subtitle.
6449 Returns nothing if not present.
6452 \begin_layout Subsection
6453 subtitle.set: Write a subtitle
6456 \begin_layout Itemize
6457 Syntax: none subtitle.set(number f, number l, string txt)
6460 \begin_layout Standard
6461 Set the text of subtitle.
6464 \begin_layout Subsection
6465 subtitle.get: Read a subtitle
6468 \begin_layout Itemize
6469 Syntax: string subtitle.get(number f, number l)
6472 \begin_layout Standard
6473 Get the text of subtitle.
6476 \begin_layout Subsection
6477 subtitle.delete: Delete a subtitle
6480 \begin_layout Itemize
6481 Syntax: none subtitle.delete(number f, number l)
6484 \begin_layout Standard
6485 Delete specified subtitle.
6488 \begin_layout Standard
6489 \begin_inset Newpage pagebreak
6495 \begin_layout Section
6499 \begin_layout Standard
6500 Host memory handling (extra memory saved to savestates).
6501 Host memory starts empty.
6504 \begin_layout Itemize
6505 Reads out of range return false.
6508 \begin_layout Itemize
6509 Writes out of range extend the memory.
6512 \begin_layout Subsection
6513 hostmemory.read: Read byte from host memory
6516 \begin_layout Itemize
6517 Syntax: number hostmemory.read(number address)
6520 \begin_layout Standard
6521 Reads byte from hostmemory slot address <address>.
6524 \begin_layout Subsection
6525 hostmemory.write: Write byte to host memory
6528 \begin_layout Itemize
6529 Syntax: none hostmemory.write(number address, number value)
6532 \begin_layout Standard
6533 Writes hostmemory slot with value <value> 0-255.
6536 \begin_layout Subsection
6537 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6540 \begin_layout Itemize
6541 Syntax: number hostmemory.readbyte(number address)
6544 \begin_layout Itemize
6545 Syntax: number hostmemory.readsbyte(number address)
6548 \begin_layout Itemize
6549 Syntax: number hostmemory.readword(number address)
6552 \begin_layout Itemize
6553 Syntax: number hostmemory.readsword(number address)
6556 \begin_layout Itemize
6557 Syntax: number hostmemory.readhword(number address)
6560 \begin_layout Itemize
6561 Syntax: number hostmemory.readshword(number address)
6564 \begin_layout Itemize
6565 Syntax: number hostmemory.readdword(number address)
6568 \begin_layout Itemize
6569 Syntax: number hostmemory.readsdword(number address)
6572 \begin_layout Itemize
6573 Syntax: number hostmemory.readqword(number address)
6576 \begin_layout Itemize
6577 Syntax: number hostmemory.readsqword(number address)
6580 \begin_layout Standard
6581 Read elements (big-endian) from given address <address>.
6584 \begin_layout Itemize
6588 \begin_layout Itemize
6592 \begin_layout Itemize
6596 \begin_layout Itemize
6600 \begin_layout Itemize
6601 qword is 8 elements.
6604 \begin_layout Itemize
6605 The 's' variants do signed read.
6608 \begin_layout Subsection
6609 hostmemory.read{float,double}: Read from host memory
6612 \begin_layout Itemize
6613 syntax: number hostmemory.readfloat(number address)
6616 \begin_layout Itemize
6617 Syntax: number hostmemory.readdouble(number address)
6620 \begin_layout Standard
6621 Read elements (big-endian) floating-pont from given address <address>.
6624 \begin_layout Subsection
6625 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6628 \begin_layout Itemize
6629 Syntax: number hostmemory.writebyte(number address, number value)
6632 \begin_layout Itemize
6633 Syntax: number hostmemory.writesbyte(number address, number value)
6636 \begin_layout Itemize
6637 Syntax: number hostmemory.writeword(number address, number value)
6640 \begin_layout Itemize
6641 Syntax: number hostmemory.writesword(number address, number value)
6644 \begin_layout Itemize
6645 Syntax: number hostmemory.writehword(number address, number value)
6648 \begin_layout Itemize
6649 Syntax: number hostmemory.writeshword(number address, number value)
6652 \begin_layout Itemize
6653 Syntax: number hostmemory.writedword(number address, number value)
6656 \begin_layout Itemize
6657 Syntax: number hostmemory.writesdword(number address, number value)
6660 \begin_layout Itemize
6661 Syntax: number hostmemory.writeqword(number address, number value)
6664 \begin_layout Itemize
6665 Syntax: number hostmemory.writesqword(number address, number value)
6668 \begin_layout Standard
6669 Write value <value> to elements (little-endian) starting from given address
6673 \begin_layout Itemize
6677 \begin_layout Itemize
6681 \begin_layout Itemize
6685 \begin_layout Itemize
6689 \begin_layout Itemize
6690 qword is 8 elements.
6693 \begin_layout Itemize
6694 The 's' variants do signed write.
6697 \begin_layout Subsection
6698 hostmemory.write{float,double}: Write to host memory
6701 \begin_layout Itemize
6702 syntax: none hostmemory.readfloat(number address, number value)
6705 \begin_layout Itemize
6706 Syntax: none hostmemory.readdouble(number address, number value)
6709 \begin_layout Standard
6710 Write elements (big-endian) floating-pont to given address <address>, storing
6714 \begin_layout Standard
6715 \begin_inset Newpage pagebreak
6721 \begin_layout Section
6725 \begin_layout Standard
6729 \begin_layout Subsection
6730 movie.currentframe: Get current frame number
6733 \begin_layout Itemize
6734 Syntax: number movie.currentframe()
6737 \begin_layout Standard
6738 Return number of current frame.
6741 \begin_layout Subsection
6742 movie.framecount: Get move frame count
6745 \begin_layout Itemize
6746 Syntax: number movie.framecount()
6749 \begin_layout Standard
6750 Return number of frames in movie.
6753 \begin_layout Subsection
6754 movie.lagcount: Get current lag count
6757 \begin_layout Itemize
6758 Syntax: number movie.lagcount()
6761 \begin_layout Standard
6762 Return number of lag frames recorded so far.
6765 \begin_layout Subsection
6766 movie.readonly: Is in playback mode?
6769 \begin_layout Itemize
6770 Syntax: boolean movie.readonly()
6773 \begin_layout Standard
6774 Return true if in playback mode, false if in recording.
6777 \begin_layout Subsection
6778 movie.rerecords: Movie rerecord count
6781 \begin_layout Itemize
6782 Syntax: number movie.rerecords()
6785 \begin_layout Standard
6786 Returns the current value of rerecord count.
6789 \begin_layout Subsection
6790 movie.set_readwrite: Set recording mode.
6793 \begin_layout Itemize
6794 Syntax: none movie.set_readwrite()
6797 \begin_layout Standard
6798 Set recording mode (does not cause on_readwrite callback).
6801 \begin_layout Subsection
6802 movie.frame_subframes: Count subframes in frame
6805 \begin_layout Itemize
6806 Syntax: number movie.frame_subframes(number frame)
6809 \begin_layout Standard
6810 Count number of subframes in specified frame <frame> (frame numbers are
6811 1-based) and return that.
6814 \begin_layout Subsection
6815 movie.read_subframes: Read subframe data (deprecated)
6818 \begin_layout Itemize
6819 Syntax: table movie.read_subframes(number frame, number subframe)
6822 \begin_layout Standard
6823 Read specifed subframe in specified frame and return data as array.
6826 \begin_layout Subsection
6827 movie.read_rtc: Read current RTC time
6830 \begin_layout Itemize
6831 Syntax: (number, number) movie.read_rtc()
6834 \begin_layout Standard
6835 Returns the current value of the RTC as a pair (second, subsecond).
6838 \begin_layout Subsection
6839 movie.unsafe_rewind: Fast movie rewind to saved state
6842 \begin_layout Itemize
6843 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6846 \begin_layout Standard
6847 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6850 \begin_layout Itemize
6851 If called without argument, causes emulator to start process of setting
6852 unsafe rewind point.
6853 When this has finished, callback on_set_rewind occurs, passing the rewind
6854 state to lua script.
6857 \begin_layout Itemize
6858 If called with argument, causes emulator rewind to passed rewind point as
6860 recording mode is implicitly activated.
6863 \begin_layout Standard
6864 The following warnings apply to unsafe rewinding:
6867 \begin_layout Itemize
6868 There are no safety checks against misuse (that's what
6869 \begin_inset Quotes eld
6873 \begin_inset Quotes erd
6879 \begin_layout Itemize
6880 Only call rewind from timeline rewind point was set from.
6883 \begin_layout Itemize
6884 Only call rewind from after the rewind point was set.
6887 \begin_layout Subsection
6888 movie.to_rewind: Load savestate as rewind point
6891 \begin_layout Itemize
6892 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6895 \begin_layout Standard
6896 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6897 corresponding to it.
6900 \begin_layout Itemize
6901 Note: This operation does not take emulated time.
6904 \begin_layout Subsection
6905 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6908 \begin_layout Itemize
6909 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6912 \begin_layout Itemize
6913 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6916 \begin_layout Standard
6917 Copies specified movie or branch <movie>/current object (if none or nil,
6918 the active movie) as new movie object.
6921 \begin_layout Subsection
6922 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6925 \begin_layout Itemize
6926 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6929 \begin_layout Itemize
6930 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6933 \begin_layout Standard
6934 Get INPUTFRAME object corresponding to specified frame in specified movie
6938 \begin_layout Subsection
6939 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6942 \begin_layout Itemize
6943 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6947 \begin_layout Itemize
6948 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6951 \begin_layout Standard
6952 Set data in specified frame.
6955 \begin_layout Itemize
6956 Note: Past can't be edited in active movie.
6959 \begin_layout Subsection
6960 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6963 \begin_layout Itemize
6964 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6967 \begin_layout Itemize
6968 Syntax: integer INPUTMOVIE::get_size()
6971 \begin_layout Standard
6972 Return number of subframes in specified movie or branch.
6975 \begin_layout Subsection
6976 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6979 \begin_layout Itemize
6980 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6983 \begin_layout Itemize
6984 Syntax: number INPUTMOVIE::count_frames()
6987 \begin_layout Standard
6988 Return number of frames in movie.
6991 \begin_layout Subsection
6992 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6995 \begin_layout Itemize
6996 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6999 \begin_layout Itemize
7000 Syntax: number INPUTMOVIE::find_frame(number frame)
7003 \begin_layout Standard
7004 Returns starting subframe of given frame (frame numbers are 1-based).
7005 Returns -1 if frame number is bad.
7008 \begin_layout Subsection
7009 movie.subframe_to_frame/INPUTMOVIE::subframe_to_frame: Find frame corresponding
7013 \begin_layout Itemize
7014 Syntax: number movie.subframe_to_frame([INPUTMOVIE/string movie], number
7018 \begin_layout Itemize
7019 Syntax: number INPUTMOVIE::subframe_to_frame(number subframe)
7022 \begin_layout Standard
7023 Returns frame containing given subframe (subframe numbers are 0-based).
7024 Returns -1 if subframe number is bad.
7027 \begin_layout Subsection
7028 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
7031 \begin_layout Itemize
7032 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
7035 \begin_layout Itemize
7036 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
7039 \begin_layout Standard
7040 Return blank INPUTFRAME with frame type from specified movie.
7043 \begin_layout Subsection
7044 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
7047 \begin_layout Itemize
7048 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
7051 \begin_layout Itemize
7052 Syntax: none INPUTMOVIE::append_frames(number frames)
7055 \begin_layout Standard
7056 Append specified number <frames> of frames.
7059 \begin_layout Subsection
7060 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
7063 \begin_layout Itemize
7064 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
7067 \begin_layout Itemize
7068 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
7071 \begin_layout Standard
7072 Append specified frame <frame>.
7073 Past of current movie can't be edited.
7076 \begin_layout Subsection
7077 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
7080 \begin_layout Itemize
7081 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
7084 \begin_layout Itemize
7085 Syntax: none INPUTMOVIE::truncate(number frames)
7088 \begin_layout Standard
7089 Truncate the specified movie to specified number of frames.
7092 \begin_layout Subsection
7093 movie.edit/INPUTMOVIE::edit: Edit a movie
7096 \begin_layout Itemize
7097 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
7098 controller, number control, number/bool value)
7101 \begin_layout Itemize
7102 Syntax: none movie.edit(string branch, number frame, number port, number
7103 controller, number control, number/bool value)
7106 \begin_layout Itemize
7107 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
7108 number control, number/bool value)
7111 \begin_layout Standard
7112 Change specified control in specified frame in specified movie.
7113 Past can't be edited in active movie.
7116 \begin_layout Subsection
7117 movie.copy_frames2: Copy frames between movies
7120 \begin_layout Itemize
7121 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
7122 IE/string srcmov,] number src, number count)
7125 \begin_layout Standard
7126 Copy specified number of frames between two movies.
7127 The copy proceeeds in forward direction.
7130 \begin_layout Subsection
7131 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
7134 \begin_layout Itemize
7135 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
7136 src, number count, bool backwards)
7139 \begin_layout Itemize
7140 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
7144 \begin_layout Standard
7145 Copy specified number of frames from one point in movie to another.
7146 If backwards is true, the copy will be done backwards.
7149 \begin_layout Subsection
7150 movie.serialize/INPUTMOVIE::serialize: Serialize movie
7153 \begin_layout Itemize
7154 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
7158 \begin_layout Itemize
7159 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
7162 \begin_layout Standard
7163 Serialize given movie into file.
7164 If binary is true, binary format (more compact and much faster) is used.
7167 \begin_layout Subsection
7168 movie.unserialize: Unserialize movie
7171 \begin_layout Itemize
7172 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
7176 \begin_layout Standard
7177 Unserialize movie from file.
7178 The given frame is used as template to decide the frame type.
7179 If binary is true, binary format is decoded (much faster).
7182 \begin_layout Subsection
7183 movie.current_first_subframe: Return first subframe in current frame
7186 \begin_layout Itemize
7187 Syntax: number movie.current_first_subframe()
7190 \begin_layout Standard
7191 Returns first subframe in current frame.
7194 \begin_layout Subsection
7195 movie.pollcounter: Return poll counter for speified control
7198 \begin_layout Itemize
7199 Syntax: number movie.pollcounter(number port, number controller, number control)
7202 \begin_layout Standard
7203 Returns number of times the specified control has been polled this frame.
7206 \begin_layout Subsection
7207 movie.current_branch: Return current branch
7210 \begin_layout Itemize
7211 Syntax: string movie.current_branch()
7214 \begin_layout Standard
7215 Returns the name of the current branch.
7218 \begin_layout Subsection
7219 movie.get_branches: Return names of all branches
7222 \begin_layout Itemize
7224 movie.get_branches()
7227 \begin_layout Standard
7228 Returns the name of all branches.
7231 \begin_layout Subsection
7232 movie.rom_loaded: Is ROM loaded?
7235 \begin_layout Itemize
7236 Syntax: boolean movie.rom_loaded()
7239 \begin_layout Standard
7240 Returns true if ROM is loaded, false otherwise.
7243 \begin_layout Subsection
7244 movie.get_rom_info: Get info about loaded ROM
7247 \begin_layout Itemize
7248 Syntax: Table movie.get_rom_info()
7251 \begin_layout Standard
7252 Returns a table of tables.
7253 The outer table is indexed by ROM slot index.
7254 The inner table has the following fields:
7257 \begin_layout Itemize
7258 filename: The name of file
7261 \begin_layout Itemize
7262 hint: File name hint
7265 \begin_layout Itemize
7266 sha256: SHA-256 hash of ROM.
7269 \begin_layout Itemize
7270 xml_filename: The name of file for markup
7273 \begin_layout Itemize
7274 xml_hint: File name hint for markup
7277 \begin_layout Itemize
7278 xml_sha256: SHA-256 hash of ROM markup.
7281 \begin_layout Standard
7282 If there is no markup, the xml_* fields are absent.
7285 \begin_layout Subsection
7286 movie.get_game_info: Get info about loaded game
7289 \begin_layout Itemize
7290 Syntax: Table movie.get_game_info()
7293 \begin_layout Standard
7294 Returns a table with following fields:
7297 \begin_layout Itemize
7298 core: The name of the core
7301 \begin_layout Itemize
7302 core_short: Short name of the core
7305 \begin_layout Itemize
7306 type: The name of the system type
7309 \begin_layout Itemize
7310 type_long: The long name of the system type
7313 \begin_layout Itemize
7314 region: The name of region
7317 \begin_layout Itemize
7318 region_long: The long name of region
7321 \begin_layout Itemize
7322 gametype: The gametype of movie.
7325 \begin_layout Itemize
7326 fps: Nominal fps as floating-point value
7329 \begin_layout Itemize
7330 fps_n: Exact nominal fps numerator
7333 \begin_layout Itemize
7334 fps_d: Exact nominal fps denominator.
7337 \begin_layout Subsection
7338 movie.get_last_movie: Get name of last movie loaded
7341 \begin_layout Itemize
7342 Syntax: String/Nil movie.get_last_movie()
7345 \begin_layout Standard
7346 Returns the name of last movie loaded as a string, or nil if the last movie
7348 If you are using this for naming something, movie.get_rom_info() might be
7349 useful in case this returns nil or something useless starting with '$'.
7352 \begin_layout Subsection
7353 INPUTFRAME::get_button: Get button
7356 \begin_layout Itemize
7357 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
7361 \begin_layout Standard
7362 Returns state of given button as boolean.
7365 \begin_layout Subsection
7366 INPUTFRAME::get_axis: Get axis
7369 \begin_layout Itemize
7370 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
7374 \begin_layout Standard
7375 Returns state of given axis as number.
7378 \begin_layout Subsection
7379 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
7382 \begin_layout Itemize
7383 Syntax: none INPUTFRAME::set_button(number port, number controller, number
7384 control, number/bool value)
7387 \begin_layout Itemize
7388 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
7392 \begin_layout Standard
7393 Set the given button/axis to given value.
7396 \begin_layout Subsection
7397 INPUTFRAME::serialize: Serialize a frame
7400 \begin_layout Itemize
7401 Syntax: string INPUTFRAME::serialize()
7404 \begin_layout Standard
7405 Return string representation of frame.
7408 \begin_layout Subsection
7409 INPUTFRAME::unserialize: Unserialize a frame
7412 \begin_layout Itemize
7413 Syntax: none INPUTFRAME::unserialize(string data)
7416 \begin_layout Standard
7417 Set current frame from given data.
7420 \begin_layout Subsection
7421 INPUTFRAME::get_stride: Get movie stride
7424 \begin_layout Itemize
7425 Syntax: number INPUTFRAME::get_stride()
7428 \begin_layout Standard
7429 Return number of bytes needed to store the input frame.
7430 Mainly useful for some debugging.
7433 \begin_layout Standard
7434 \begin_inset Newpage pagebreak
7440 \begin_layout Section
7444 \begin_layout Standard
7445 Routines for settings manipulation
7448 \begin_layout Subsection
7449 settings.get: Get value of setting
7452 \begin_layout Itemize
7453 Syntax: string settings.get(string name)
7456 \begin_layout Standard
7457 Get value of setting <name>.
7458 If setting value can't be obtained, returns (nil, error message).
7461 \begin_layout Subsection
7462 settings.set: Set value of setting
7465 \begin_layout Itemize
7466 Syntax: none settings.set(string name, string value)
7469 \begin_layout Standard
7470 Set value <value> of setting <name>.
7471 If setting can't be set, returns (nil, error message).
7474 \begin_layout Subsection
7475 settings.get_all: Get values of all settings
7478 \begin_layout Itemize
7479 Syntax: table settings.get_all()
7482 \begin_layout Standard
7483 Return a table with all setting names as keys and all current values as
7487 \begin_layout Subsection
7488 settings.get_speed: Get current speed
7491 \begin_layout Itemize
7492 Syntax: number/string settings.get_speed()
7495 \begin_layout Standard
7496 Return the current speed multiplier (1 is normal), or
7497 \begin_inset Quotes eld
7501 \begin_inset Quotes erd
7504 if speed is set to turbo (this does not react to turbo toggle).
7507 \begin_layout Subsection
7508 settings.set_speed: Set current speed
7511 \begin_layout Itemize
7512 Syntax: settings.get_speed(number spd)
7515 \begin_layout Itemize
7516 Syntax: settings.get_speed(string special)
7519 \begin_layout Standard
7520 Set the current speed multiplier (1 is normal).
7521 The speed may be positive multiplier or
7522 \begin_inset Quotes eld
7526 \begin_inset Quotes erd
7532 \begin_layout Standard
7533 \begin_inset Newpage pagebreak
7539 \begin_layout Section
7543 \begin_layout Standard
7544 Contains various functions for managing memory
7547 \begin_layout Subsection
7548 memory.vma_count: Count number of memory areas.
7551 \begin_layout Itemize
7552 Syntax: number memory.vma_count()
7555 \begin_layout Standard
7556 Returns the number of memory areas
7559 \begin_layout Subsection
7560 memory.read_vma: Lookup memory area info by index
7563 \begin_layout Itemize
7564 Syntax: table memory.read_vma(number index)
7567 \begin_layout Standard
7568 Reads the specified memory area (indices start from zero).
7569 Trying to read invalid memory area gives nil.
7570 The return value is table with the following fields:
7573 \begin_layout Itemize
7574 region_name (string): The readable name of the memory area
7577 \begin_layout Itemize
7578 baseaddr (number): Base address of the memory area
7581 \begin_layout Itemize
7582 lastaddr (number): Last address in the memory area.
7585 \begin_layout Itemize
7586 size (number): The size of memory area in bytes.
7589 \begin_layout Itemize
7590 readonly (boolean): True of the memory area corresponds to ROM.
7593 \begin_layout Itemize
7594 iospace (boolean): True if the memory area is I/O space.
7597 \begin_layout Itemize
7598 native_endian (boolean): True if the memory area has native endian as opposed
7602 \begin_layout Subsection
7603 memory.find_vma: Find memory area info by address
7606 \begin_layout Itemize
7607 Syntax: table memory.find_vma(number address)
7610 \begin_layout Standard
7611 Finds the memory area containing specified address.
7612 Returns table in the same format as read_vma or nil if not found.
7615 \begin_layout Subsection
7616 memory.read{,s}{byte,{,h,d,q}word}: Read memory
7619 \begin_layout Itemize
7620 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
7623 \begin_layout Itemize
7624 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
7627 \begin_layout Itemize
7628 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
7631 \begin_layout Itemize
7632 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
7635 \begin_layout Itemize
7636 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
7639 \begin_layout Itemize
7640 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
7643 \begin_layout Itemize
7644 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
7647 \begin_layout Itemize
7648 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
7651 \begin_layout Itemize
7652 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
7655 \begin_layout Itemize
7656 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
7659 \begin_layout Standard
7660 Reads the specified address <address> (if 's' variant is used, do undergo
7664 \begin_layout Subsection
7665 memory.{,s}read_sg: Scatter/Gather read memory
7668 \begin_layout Itemize
7669 Syntax: none memory.read_sg(string/boolean/number...)
7672 \begin_layout Itemize
7673 Syntax: none memory.sread_sg(string/boolean/number...)
7676 \begin_layout Standard
7677 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
7679 Each argument can be string, boolean or number:
7682 \begin_layout Itemize
7683 String: Set memory area addresses are relative to (e.g.
7687 \begin_layout Itemize
7688 boolean: If true, increment relative address by 1, if false, decrement by
7690 The new address is read as next higher byte.
7693 \begin_layout Itemize
7694 integer: Set the relative address to specified value and read the address
7695 as next higher byte.
7698 \begin_layout Subsection
7699 memory.write_sg: Scatter/Gather write memory
7702 \begin_layout Itemize
7703 Syntax: none memory.write_sg(number value, string/boolean/number...)
7706 \begin_layout Standard
7707 Perform scatter/gather write of value <value> on memory.
7708 Each argument can be string, boolean or number:
7711 \begin_layout Itemize
7712 String: Set memory area addresses are relative to (e.g.
7716 \begin_layout Itemize
7717 boolean: If true, increment relative address by 1, if false, decrement by
7719 The new address is read as next higher byte.
7722 \begin_layout Itemize
7723 integer: Set the relative address to specified value and read the address
7724 as next higher byte.
7727 \begin_layout Subsection
7728 memory.read{float,double}: Read memory
7731 \begin_layout Itemize
7732 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7735 \begin_layout Itemize
7736 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7739 \begin_layout Standard
7740 Reads the specified address <address>
7743 \begin_layout Subsection
7744 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7747 \begin_layout Itemize
7748 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7752 \begin_layout Itemize
7753 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7757 \begin_layout Itemize
7758 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7762 \begin_layout Itemize
7763 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7767 \begin_layout Itemize
7768 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7772 \begin_layout Itemize
7773 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7777 \begin_layout Itemize
7778 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7782 \begin_layout Standard
7783 Writes the specified value <value> (negative integer values undergo 2's
7784 complement) to specified address <address>.
7787 \begin_layout Subsection
7788 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7791 \begin_layout Itemize
7792 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7796 \begin_layout Standard
7797 Returns a table mapping specified memory aperture for read/write.
7800 \begin_layout Itemize
7801 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7802 qword, sqword, float or double.
7805 \begin_layout Subsection
7806 memory.hash_region: Hash region of memory
7809 \begin_layout Itemize
7810 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7814 \begin_layout Standard
7815 Hash <size> bytes starting from address <base> (relative to <marea>) and
7819 \begin_layout Subsection
7820 memory.hash_region2: Hash region of memory
7823 \begin_layout Itemize
7824 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7825 number size[, number rows, number stride])
7828 \begin_layout Standard
7829 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7831 The blocks are offset by <stride> from one another and return the SHA-256.
7834 \begin_layout Subsection
7835 memory.hash_region_skein: Hash region of memory
7838 \begin_layout Itemize
7839 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7840 addrobj}, number size[, number rows, number stride])
7843 \begin_layout Standard
7844 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7845 finalists) as hash function.
7848 \begin_layout Subsection
7849 memory.store: Store region of memory
7852 \begin_layout Itemize
7853 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7854 daddr[, number rows, number stride]
7857 \begin_layout Standard
7858 Copy memory starting from <addr> in memory area <marea> (each row being
7859 of size <size>, there being <rows> rows, and rows being separated by <stride>
7860 in memory) into savestate-saved memory area, starting from <daadr> (all
7861 rows are written back to back).
7864 \begin_layout Subsection
7865 memory.storecmp: Compare and store region of memory
7868 \begin_layout Itemize
7869 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7870 number daddr[, number rows, number stride]
7873 \begin_layout Standard
7874 Like memory.store, but returns true if target of copy already held the value
7875 that would be copied before the copy happened.
7876 Otherwise returns false (if target and source differ before copy).
7879 \begin_layout Subsection
7880 memory.hash_state: Hash system state
7883 \begin_layout Itemize
7884 Syntax: string memory.hash_state()
7887 \begin_layout Standard
7888 Hash the current system state.
7889 Mainly useful for debugging savestates.
7892 \begin_layout Subsection
7893 memory.readregion: Read region of memory
7896 \begin_layout Itemize
7897 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7901 \begin_layout Standard
7902 Read a region of memory.
7905 \begin_layout Itemize
7906 Warning: If the region crosses memory area boundary, the results are undefined.
7909 \begin_layout Subsection
7910 memory.writeregion: Write region of memory
7913 \begin_layout Itemize
7914 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7915 number size, table data)
7918 \begin_layout Standard
7919 Write a region of memory.
7922 \begin_layout Itemize
7923 Warning: If the region crosses memory area boundary, the results are undefined.
7926 \begin_layout Subsection
7927 memory.action: Run core action
7930 \begin_layout Itemize
7931 memory.action(string action, [<params>])
7934 \begin_layout Standard
7936 The different models expect parameters as:
7939 \begin_layout Itemize
7943 \begin_layout Itemize
7947 \begin_layout Itemize
7951 \begin_layout Itemize
7955 \begin_layout Itemize
7959 \begin_layout Subsection
7960 memory.action_flags: Get core action flags
7963 \begin_layout Itemize
7964 memory.action_flags(string action)
7967 \begin_layout Standard
7968 Get value of action flags for core action <action>.
7971 \begin_layout Itemize
7975 \begin_layout Itemize
7976 Bit 1: Selected (not all actions can be selected)?
7979 \begin_layout Subsection
7980 memory.get_lag_flag: Get lag flag
7983 \begin_layout Itemize
7984 Syntax: boolean memory.get_lag_flag()
7987 \begin_layout Standard
7988 Get the value of core lag flag.
7989 True if this frame has been lag so far, false if poll has been detected.
7992 \begin_layout Subsection
7993 memory.set_lag_flag: Set lag flag
7996 \begin_layout Itemize
7997 Syntax: none memory.set_lag_flag(boolean flag)
8000 \begin_layout Standard
8001 Set the value of core lag flag.
8002 This flag automatically gets cleared if poll is detected, but can be forcibly
8003 set or cleared if game so requires.
8006 \begin_layout Itemize
8007 Should only be used in on_frame_emulated callback.
8010 \begin_layout Itemize
8011 Setting or clearing this affects the emulator lag counter.
8014 \begin_layout Subsection
8015 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
8019 \begin_layout Itemize
8020 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
8024 \begin_layout Itemize
8025 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
8026 addrobj}, function fn);
8029 \begin_layout Itemize
8030 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
8034 \begin_layout Itemize
8035 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
8039 \begin_layout Itemize
8040 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
8044 \begin_layout Itemize
8045 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
8049 \begin_layout Standard
8050 Add or remove callback on memory read, write or execute (depending on the
8052 <addr> is relative to <marea>.
8053 <fn> is the callback.
8054 The register* functions return <fn> (which can then be passed to unregister*
8058 \begin_layout Itemize
8059 Not all cores support this, and it may be unsupported for some memory areas.
8062 \begin_layout Itemize
8063 The functions are passed two parameters: Address and value.
8066 \begin_layout Subsection
8067 memory.{,un}registertrace: Set/Clear trace hook
8070 \begin_layout Itemize
8071 Syntax: function memory.registertrace(number processor, function fn);
8074 \begin_layout Itemize
8075 Syntax: none memory.unregistertrace(number processor, function fn);
8078 \begin_layout Standard
8079 Add or remove trace callback.
8080 <processor> is system-dependent processor number (0 is usually main CPU).
8081 The function arguments work like in other (un)register* functions.
8084 \begin_layout Itemize
8085 The functions are passed two parameters: Trace CPU and Trace event string.
8088 \begin_layout Subsection
8089 memory.cheat: Set cheat
8092 \begin_layout Itemize
8093 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
8097 \begin_layout Itemize
8098 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
8101 \begin_layout Standard
8102 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
8103 If <value> is not speicified, clear a cheat.
8106 \begin_layout Itemize
8107 Not all cores support this, and it may be unsupported for some memory areas.
8110 \begin_layout Subsection
8111 memory.setxmask: Set global execute hook mask
8114 \begin_layout Itemize
8115 Syntax: none memory.setxmask(number mask)
8118 \begin_layout Standard
8119 Set the global execute hook mask to <mask>.
8120 The meaning of each bit is system-dependent, but bit 0 should be the main
8124 \begin_layout Subsection
8125 memory.getregister: Get register value
8128 \begin_layout Itemize
8129 Syntax: number/boolean memory.getregister(string register)
8132 \begin_layout Standard
8133 Get the value of named register.
8136 \begin_layout Subsection
8137 memory.getregisters: Get register values
8140 \begin_layout Itemize
8141 Syntax: table memory.getregisters()
8144 \begin_layout Standard
8145 Get the value of all known registers as table.
8148 \begin_layout Subsection
8149 memory.setregister: Set register value
8152 \begin_layout Itemize
8153 Syntax: none memory.setregister(string register, number/boolean value)
8156 \begin_layout Standard
8157 Set the value of named register.
8160 \begin_layout Subsection
8161 memory.mmap: Class MMAP_STRUCT
8164 \begin_layout Standard
8165 See class MMAP_STRUCT
8168 \begin_layout Standard
8169 \begin_inset Newpage pagebreak
8175 \begin_layout Section
8179 \begin_layout Standard
8180 Contains newer memory functions.
8183 \begin_layout Subsection
8184 memory2(): Get all memory area names.
8187 \begin_layout Itemize
8188 Syntax: table memory2()
8191 \begin_layout Standard
8192 Returns array of all valid memory area names.
8195 \begin_layout Subsection
8196 memory2.<marea>:info: Get memory area info
8199 \begin_layout Itemize
8200 Syntax: table memory2.<marea>:info()
8203 \begin_layout Standard
8204 Return table describing given memory area.
8205 Includes fields address, size, last, readonly, special and endian.
8208 \begin_layout Subsection
8209 memory2.<marea>:<op>: Read/Write memory
8212 \begin_layout Itemize
8213 Syntax: none memory2.<marea>:<op>(number offset, number value)
8216 \begin_layout Itemize
8217 Syntax: number memory2.<marea>:<op>(number offset)
8220 \begin_layout Standard
8221 Read/Write value from/to given memory area <marea> at given offset <offset>
8223 The value written is <value>.
8224 <Op> is of form: [i][s]<type>, where:
8227 \begin_layout Itemize
8228 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
8231 \begin_layout Itemize
8232 'i' signifies that the value is treated as opposite-to-normal endianess,
8235 \begin_layout Itemize
8236 's' signifies that value is treated as signed (not available for floating-point).
8239 \begin_layout Subsection
8240 memory2.<marea>:read: Scatter-gather value read
8243 \begin_layout Itemize
8244 Syntax: number memory2.<marea>:read(number addr...)
8247 \begin_layout Standard
8248 Read value from given memory area <marea> at byte offsets <addr>..., given
8249 in order of increasing significance.
8250 Value of true and false are special.
8251 True increments address by 1, and false decrements address by 1.
8254 \begin_layout Subsection
8255 memory2.<marea>:sread: Signed scatter-gather value read
8258 \begin_layout Itemize
8259 Syntax: number memory2.<marea>:sread(number addr...)
8262 \begin_layout Standard
8263 Like memory2.<marea>:read, but reads signed values.
8266 \begin_layout Subsection
8267 memory2.<marea>:write: Scatter-gather value write
8270 \begin_layout Itemize
8271 Syntax: number memory2.<marea>:write(number val, number addr...)
8274 \begin_layout Standard
8275 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
8276 in order of increasing significance.
8277 Value of true and false are special.
8278 True increments address by 1, and false decrements address by 1.
8281 \begin_layout Subsection
8282 memory2.<marea>:cheat: Set/Clear cheat
8285 \begin_layout Itemize
8286 Syntax: none memory2.<marea>:cheat(number addr, [number value])
8289 \begin_layout Standard
8290 Set/Clear cheat at offset <addr> of memory area <marea>.
8291 If <value> is given, cheat with specified value is set.
8292 Otherwise cheat on address is removed.
8295 \begin_layout Subsection
8296 memory2.<marea>:sha256: SHA-256
8299 \begin_layout Itemize
8300 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
8304 \begin_layout Standard
8305 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
8306 from offset <addr> of area <marea>.
8307 The chunks are separated by <stride>.
8310 \begin_layout Subsection
8311 memory2.<marea>:skein: Skein-512-256
8314 \begin_layout Itemize
8315 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
8319 \begin_layout Standard
8320 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
8323 \begin_layout Subsection
8324 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
8327 \begin_layout Itemize
8328 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
8329 number rows, number stride])
8332 \begin_layout Itemize
8333 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
8334 size[, number rows, number stride])
8337 \begin_layout Standard
8338 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
8339 <addr> of area <marea>.
8340 The chunks are separated by <stride>.
8341 The target is Lua host memory, starting from offset <daddr>.
8344 \begin_layout Standard
8345 Additionally, the storecmp method returns false if target was modified (otherwis
8349 \begin_layout Subsection
8350 memory2.<marea>:readregion: Read region
8353 \begin_layout Itemize
8354 Syntax table memory2.<marea>:readregion(number addr, number size)
8357 \begin_layout Standard
8358 Read <size> bytes starting from <addr> in <marea> and return as array.
8361 \begin_layout Subsection
8362 memory2.<marea>:writeregion: Write region
8365 \begin_layout Itemize
8366 Syntax none memory2.<marea>:writeregion(number addr, table data)
8369 \begin_layout Standard
8370 Write array <data> to bytes starting from <addr> in <marea>.
8373 \begin_layout Subsection
8374 memory2.<marea>:register{read,write,exec}: Register hook
8377 \begin_layout Itemize
8378 Syntax: function memory2.<marea>:registerread(number addr, function fn);
8381 \begin_layout Itemize
8382 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
8385 \begin_layout Itemize
8386 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
8389 \begin_layout Standard
8390 Register debug callback <fn> of specified type at offset <addr> of memory
8395 \begin_layout Subsection
8396 memory2.<marea>:unregister{read,write,exec}: Unregister hook
8399 \begin_layout Itemize
8400 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
8403 \begin_layout Itemize
8404 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
8407 \begin_layout Itemize
8408 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
8411 \begin_layout Standard
8412 Unregister debug callback <fn> of specified type at offset <addr> of memory
8416 \begin_layout Standard
8417 \begin_inset Newpage pagebreak
8423 \begin_layout Section
8427 \begin_layout Standard
8428 Contains random number generation methods.
8429 These functions do not return reproducable results.
8432 \begin_layout Subsection
8433 random.boolean: Random boolean
8436 \begin_layout Itemize
8437 Syntax: boolean random.boolean()
8440 \begin_layout Standard
8441 Returns true or false at random (50-50 chance).
8444 \begin_layout Subsection
8445 random.integer: Random integer
8448 \begin_layout Itemize
8449 Syntax: number random.integer(number highplusone)
8452 \begin_layout Itemize
8453 Syntax: number random.integer(number low, number high)
8456 \begin_layout Standard
8457 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
8458 With two arguments, return random integer [<low>,<high>] (both ends inclusive).
8461 \begin_layout Standard
8462 The returned numbers are from uniform distribution.
8465 \begin_layout Subsection
8466 random.float: Random float
8469 \begin_layout Itemize
8470 Syntax: number random.float()
8473 \begin_layout Standard
8474 Returns random decimal number [0,1).
8477 \begin_layout Subsection
8478 random.among: Random parameter
8481 \begin_layout Itemize
8482 Syntax: value random.among(value values...)
8485 \begin_layout Standard
8486 Returns random parameter value, picked at uniform.
8487 Multiple equivalent values are returned with higher chance.
8490 \begin_layout Subsection
8491 random.amongtable: Random from table
8494 \begin_layout Itemize
8495 Syntax: value random.amongtable(table tab)
8498 \begin_layout Standard
8499 Returns random value from table <tab>.
8500 As in random.among, no equality testing is done.
8503 \begin_layout Standard
8504 \begin_inset Newpage pagebreak
8510 \begin_layout Section
8514 \begin_layout Subsection
8515 zip.enumerate: Enumerate members in zipfile
8518 \begin_layout Itemize
8519 Syntax: Table zip.enumerate(string filename[, boolean invert])
8522 \begin_layout Standard
8523 Returns table of files in zip archive <filename>.
8524 If <invert> is true, instead of returning array of names, returns table
8525 with keys being member names and values being true.
8528 \begin_layout Subsection
8529 zip.writer: Class ZIPWRITER
8532 \begin_layout Standard
8533 See class ZIPWRITER.
8536 \begin_layout Section
8540 \begin_layout Subsection
8541 paths.get_executable_file: Get the name of lsnes executable file
8544 \begin_layout Itemize
8545 Syntax: String paths.get_executable_file()
8548 \begin_layout Standard
8549 Returns the filename of the lsnes executable (together with path), if known.
8550 If unknown, returns nil.
8553 \begin_layout Subsection
8554 paths.get_executable_path: Get the path of lsnes executable file
8557 \begin_layout Itemize
8558 Syntax: String paths.get_executable_path()
8561 \begin_layout Standard
8562 Returns the directory of the lsnes executable path, if known.
8563 If unknown, returns nil.
8566 \begin_layout Subsection
8567 paths.get_config_path: Get the path of lsnes config file
8570 \begin_layout Itemize
8571 Syntax: String paths.get_config_path()
8574 \begin_layout Standard
8575 Returns the directory of the lsnes configuration.
8578 \begin_layout Subsection
8579 paths.get_rompath: Get the path of ROM files
8582 \begin_layout Itemize
8583 Syntax: String paths.get_rompath()
8586 \begin_layout Standard
8587 Returns the default directory for various ROMs.
8590 \begin_layout Subsection
8591 paths.get_firmwarepath: Get the path of firmware files
8594 \begin_layout Itemize
8595 Syntax: String paths.get_firmwarepath()
8598 \begin_layout Standard
8599 Returns the default directory for various firmwares.
8602 \begin_layout Subsection
8603 paths.get_slotpath: Get the path of save slot files
8606 \begin_layout Itemize
8607 Syntax: String paths.get_slotpath()
8610 \begin_layout Standard
8611 Returns the default directory for various save slots.
8612 If in project context, returns the project directory.
8615 \begin_layout Subsection
8616 paths.get_save_slot_file: Get save slot filename
8619 \begin_layout Itemize
8620 Syntax: String paths.get_slotpath(string name)
8623 \begin_layout Itemize
8624 Syntax: String paths.get_slotpath(integer slotnum, bool for_save)
8627 \begin_layout Standard
8628 Resolve the filename of specified save slot <name> or <slotnum>.
8629 Projects and save branches are taken into account.
8630 If <for_save> is true, the filename is always for current branch.
8631 If <for_save> is false, branch tree is walked upwards until root is reached
8632 or desired file is located.
8635 \begin_layout Standard
8636 \begin_inset Newpage pagebreak
8642 \begin_layout Section
8646 \begin_layout Standard
8647 Various callback-related functions.
8650 \begin_layout Subsection
8651 \begin_inset CommandInset label
8653 name "subsec:callback.register:-Register-a"
8657 callback.register: Register a callback
8660 \begin_layout Itemize
8661 Syntax: function callback.register(string cbname, function cbfun);
8664 \begin_layout Standard
8665 Instruct function <cbfun> to be added to list of callbacks to call on event
8666 <cbname> (See section
8667 \begin_inset CommandInset ref
8669 reference "sec:Callbacks"
8674 The callback name does not have the 'on_' prefix (e.g.
8676 \begin_inset Quotes eld
8680 \begin_inset Quotes erd
8687 \begin_layout Subsection
8688 \begin_inset CommandInset label
8690 name "subsec:callback.unregister:-Unregister-"
8694 callback.unregister: Unregister a callback
8697 \begin_layout Itemize
8698 Syntax: function callback.unregister(string cbname, function cbfun);
8701 \begin_layout Standard
8702 Instruct function <cbfun> to be removed from list of callbacks to call on
8706 \begin_layout Subsection
8707 callback.<cbname>:register: Register callback
8710 \begin_layout Itemize
8711 Syntax: function callback.<cbname>:register(function cbfun)
8714 \begin_layout Standard
8715 Synonym for callback.register (section
8716 \begin_inset CommandInset ref
8718 reference "subsec:callback.register:-Register-a"
8722 ), albeit with callback name specified differently.
8725 \begin_layout Subsection
8726 callback.<cbname>:unregister: Register callback
8729 \begin_layout Itemize
8730 Syntax: function callback.<cbname>:unregister(function cbfun)
8733 \begin_layout Standard
8734 Synonym for callback.unregister (section
8735 \begin_inset CommandInset ref
8737 reference "subsec:callback.unregister:-Unregister-"
8741 ), albeit with callback name specified differently.
8744 \begin_layout Section
8748 \begin_layout Standard
8749 Various bsnes-specific functions.
8752 \begin_layout Subsection
8753 bsnes.dump_sprite: Dump a sprite
8756 \begin_layout Itemize
8757 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
8758 number height[, number stride])
8761 \begin_layout Standard
8762 Dumps given sprite (in native format) from memory.
8763 memory area is usually
8764 \begin_inset Quotes eld
8768 \begin_inset Quotes erd
8772 <Width> and <height> are given in 8x8 blocks.
8773 <Stride> overrides row stride (default 512).
8776 \begin_layout Subsection
8777 bsnes.dump_sprite2: Dump a 2bpp sprite
8780 \begin_layout Itemize
8781 Syntax: BITMAP bsnes.dump_sprite2(string marea, number addr, number width,
8782 number height[, number stride])
8785 \begin_layout Standard
8786 Dumps given sprite (in 2bpp format) from memory.
8787 memory area is usually
8788 \begin_inset Quotes eld
8792 \begin_inset Quotes erd
8796 <Width> and <height> are given in 8x8 blocks.
8797 <Stride> overrides row stride (default 256).
8800 \begin_layout Subsection
8801 bsnes.dump_palette: Dump a palette
8804 \begin_layout Itemize
8805 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool/integer
8806 full256, bool first_trans)
8809 \begin_layout Standard
8810 Dumps a palette from memory.
8811 memory area is usually
8812 \begin_inset Quotes eld
8816 \begin_inset Quotes erd
8820 If <full256> is true, 256 colors are dumped (otherwise 16).
8821 <full256> can also be number of colors (4, 16 or 256).
8822 If <first_trans> is true, first color is forced transparent.
8825 \begin_layout Subsection
8826 bsnes.enablelayer: Set layer visibility
8829 \begin_layout Itemize
8830 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8833 \begin_layout Standard
8834 Enable or disable specified layer at specified priority.
8837 \begin_layout Subsection
8838 bsnes.redump_sprite: Redump a sprite
8841 \begin_layout Itemize
8842 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8846 \begin_layout Standard
8847 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8848 The specified bitmap must have size multiple of 8x8.
8851 \begin_layout Subsection
8852 bsnes.redump_sprite2: Redump a 2bpp sprite
8855 \begin_layout Itemize
8856 Syntax: none bsnes.redump_sprite2(BITMAP bitmap, string marea, number addr[,
8860 \begin_layout Standard
8861 Like bsnes.dump_sprite2, but instead dumps to specified bitmap <bitmap>.
8862 The specified bitmap must have size multiple of 8x8.
8865 \begin_layout Subsection
8866 bsnes.redump_palette: Redump a palette
8869 \begin_layout Itemize
8870 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8874 \begin_layout Standard
8875 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8876 The specified palette must have either 16 or 256 colors.
8879 \begin_layout Section
8880 extensions to table string
8883 \begin_layout Subsection
8884 string.charU: string.char, UTF-8 version.
8887 \begin_layout Itemize
8888 Syntax: string string.charU(number n...)
8891 \begin_layout Standard
8892 Like Lua string.char(), but works in terms of Unicode codepoints.
8893 The returned string is UTF-8.
8896 \begin_layout Subsection
8897 string.byteU: string.byte, UTF-8 version.
8900 \begin_layout Itemize
8902 string.byteU(string str[, number i[, number j]])
8905 \begin_layout Standard
8906 Like string.byte(), but works in terms of Unicode codepoints.
8907 The input string <str> is assumed UTF-8.
8910 \begin_layout Subsection
8911 string.regex: Match string against regular expression
8914 \begin_layout Itemize
8915 Syntax: boolean/string...
8916 string.regex(string regexp, string against)
8919 \begin_layout Standard
8920 Match POSIX-extended regular expression <regexp> against string <against>.
8921 If no match, false is returned.
8922 Otherwise if string has no subcaptures, true is returned.
8923 Otherwise each subcapture is returned as a string (in order of starting
8927 \begin_layout Subsection
8928 string.hex: Transform integer into hex string
8931 \begin_layout Itemize
8932 Syntax: string string.hex(number n, [number digits])
8935 \begin_layout Standard
8936 Returns hexadecimal string representation of <n>, optionally padded with
8937 zeroes to <digits> digits (default is not to pad).
8940 \begin_layout Subsection
8941 string.lpad: Pad string with spaces from left
8944 \begin_layout Itemize
8945 Syntax: string string.lpad(string x, number n)
8948 \begin_layout Standard
8949 Pad string <x> to <n> bytes by inserting spaces at start and return the
8953 \begin_layout Subsection
8954 string.rpad: Pad string with spaces from right
8957 \begin_layout Itemize
8958 Syntax: string string.rpad(string x, number n)
8961 \begin_layout Standard
8962 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8965 \begin_layout Section
8969 \begin_layout Standard
8970 Contains copy of global variables from time of Lua initialization.
8974 \begin_layout Standard
8975 \begin_inset Newpage pagebreak
8981 \begin_layout Section
8982 \begin_inset CommandInset label
8984 name "sec:Callbacks"
8991 \begin_layout Standard
8992 Various callbacks to Lua that can occur.
8995 \begin_layout Subsection
8996 on_paint: Screen is being painted
8999 \begin_layout Itemize
9000 Callback: on_paint(bool not_synth)
9003 \begin_layout Standard
9004 Called when screen is being painted.
9005 Any gui.* calls requiring graphic context draw on the screen.
9008 \begin_layout Itemize
9009 not_synth is true if this hook is being called in response to received frame,
9013 \begin_layout Subsection
9014 on_video: Dumped video frame is being painted
9017 \begin_layout Itemize
9018 Callback: on_video()
9021 \begin_layout Standard
9022 Called when video dump frame is being painted.
9023 Any gui.* calls requiring graphic context draw on the video.
9026 \begin_layout Subsection
9027 on_frame_emulated: Frame emulation complete
9030 \begin_layout Itemize
9031 Callback: on_frame_emulated()
9034 \begin_layout Standard
9035 Called when emulating frame has completed and on_paint()/on_video() calls
9036 are about to be issued.
9039 \begin_layout Subsection
9040 on_frame: Frame emulation starting.
9043 \begin_layout Itemize
9044 Callback: on_frame()
9047 \begin_layout Standard
9048 Called on each starting whole frame.
9051 \begin_layout Subsection
9052 on_rewind: Movie rewound to beginning
9055 \begin_layout Itemize
9056 Callback: on_rewind()
9059 \begin_layout Standard
9060 Called when rewind movie to beginning has completed.
9063 \begin_layout Subsection
9064 on_pre_load: Load operation is about to start
9067 \begin_layout Itemize
9068 Callback: on_pre_load(string name)
9071 \begin_layout Standard
9072 Called just before savestate/movie load occurs (note: loads are always delayed,
9073 so this occurs even when load was initiated by lua).
9076 \begin_layout Subsection
9077 on_err_Load: Load failed
9080 \begin_layout Itemize
9081 Callback: on_err_load(string name)
9084 \begin_layout Standard
9085 Called if loadstate goes wrong.
9088 \begin_layout Subsection
9089 on_post_load: Load completed
9092 \begin_layout Itemize
9093 Callback: on_post_load(string name, boolean was_savestate)
9096 \begin_layout Standard
9097 Called on successful loadstate.
9098 was_savestate gives if this was a savestate or a movie.
9101 \begin_layout Subsection
9102 on_pre_save: Save operation is about to start
9105 \begin_layout Itemize
9106 Callback: on_pre_save(string name, boolean is_savestate)
9109 \begin_layout Standard
9110 Called just before savestate save occurs (note: movie saves are synchronous
9111 and won't trigger these callbacks if called from Lua).
9114 \begin_layout Subsection
9115 on_err_save: Save failed
9118 \begin_layout Itemize
9119 Callback: on_err_save(string name)
9122 \begin_layout Standard
9123 Called if savestate goes wrong.
9126 \begin_layout Subsection
9127 on_post_save: Save completed
9130 \begin_layout Itemize
9131 Callback: on_post_save(string name, boolean is_savestate)
9134 \begin_layout Standard
9135 Called on successful savaestate.
9136 is_savestate gives if this was a savestate or a movie.
9139 \begin_layout Subsection
9140 on_quit: Emulator is shutting down
9143 \begin_layout Itemize
9147 \begin_layout Standard
9148 Called when emulator is shutting down.
9151 \begin_layout Subsection
9152 on_input: Polling for input
9155 \begin_layout Standard
9156 Called when emulator is just sending input to bsnes core.
9157 Warning: This is called even in readonly mode, but the results are ignored.
9160 \begin_layout Subsection
9161 on_reset: System has been reset
9164 \begin_layout Itemize
9165 Callback: on_reset()
9168 \begin_layout Standard
9169 Called when system is reset.
9172 \begin_layout Subsection
9173 on_readwrite: Entered recording mode
9176 \begin_layout Itemize
9177 Callback: on_readwrite()
9180 \begin_layout Standard
9181 Called when moving into recording mode as result of
9182 \begin_inset Quotes eld
9186 \begin_inset Quotes erd
9189 command (note: moving to rwmode by Lua won't trigger this, as per recursive
9193 \begin_layout Subsection
9194 on_snoop/on_snoop2: Snoop core controller reads
9197 \begin_layout Itemize
9198 Callback: on_snoop(number port, number controller, number index, number
9202 \begin_layout Itemize
9203 Callback: on_snoop2(number port, number controller, number index, number
9207 \begin_layout Standard
9208 Called each time bsnes asks for input.
9209 The value is the final value to be sent to bsnes core (readonly mode, autohold
9210 and autofire have been taken into account).
9211 Might be useful when translating movies to format suitable for console
9213 Note: There is no way to modify the value to be sent.
9216 \begin_layout Itemize
9217 On_snoop2 is called instead of on_snoop if defined.
9218 Reserves port 0 for system, having first user port be port 1.
9221 \begin_layout Subsection
9222 on_keyhook: Hooked key/axis has been moved
9225 \begin_layout Itemize
9226 Callback: on_keyhook(string keyname, table state)
9229 \begin_layout Standard
9230 Sent when key that has keyhook events requested changes state.
9231 Keyname is name of the key (group) and state is the state (same kind as
9232 table values in input.raw).
9235 \begin_layout Subsection
9239 \begin_layout Itemize
9243 \begin_layout Standard
9244 Called when requested by set_idle_timeout(), the timeout has expired and
9245 emulator is waiting.
9248 \begin_layout Subsection
9249 on_timer: Timer event
9252 \begin_layout Itemize
9253 Callback: on_timer()
9256 \begin_layout Standard
9257 Called when requested by set_idle_timeout() and the timeout has expired
9258 (regardless if emulator is waiting).
9261 \begin_layout Subsection
9262 on_set_rewind: Rewind point has been set
9265 \begin_layout Itemize
9266 Callback: on_set_rewind(UNSAFEREWIND r)
9269 \begin_layout Standard
9270 Called when unsafe rewind object has been constructed.
9273 \begin_layout Subsection
9274 on_pre_rewind: Rewind is about to occur
9277 \begin_layout Itemize
9278 Callback: on_pre_rewind()
9281 \begin_layout Standard
9282 Called just before unsafe rewind is about to occur.
9285 \begin_layout Subsection
9286 on_post_rewind: Rewind has occured
9289 \begin_layout Itemize
9290 Callback: on_post_rewind()
9293 \begin_layout Standard
9294 Called just after unsafe rewind has occured.
9297 \begin_layout Subsection
9298 on_button: Button has been pressed
9301 \begin_layout Itemize
9302 Callback: on_button(number port, number controller, number index, string
9306 \begin_layout Standard
9307 Called on controller button press, with following parameters:
9310 \begin_layout Itemize
9311 port: Port number (0 is system)
9314 \begin_layout Itemize
9315 controller: Controller within port
9318 \begin_layout Itemize
9319 index: Index of button.
9322 \begin_layout Itemize
9323 type: Type of event, one of:
9324 \begin_inset Separator latexpar
9331 \begin_layout Itemize
9332 \begin_inset Quotes eld
9336 \begin_inset Quotes erd
9339 : Button was pressed.
9342 \begin_layout Itemize
9343 \begin_inset Quotes eld
9347 \begin_inset Quotes erd
9350 : Button was released.
9353 \begin_layout Itemize
9354 \begin_inset Quotes eld
9358 \begin_inset Quotes erd
9364 \begin_layout Itemize
9365 \begin_inset Quotes eld
9369 \begin_inset Quotes erd
9372 : Released from hold.
9375 \begin_layout Itemize
9376 \begin_inset Quotes eld
9380 \begin_inset Quotes erd
9383 : Typing input on button.
9386 \begin_layout Itemize
9387 \begin_inset Quotes eld
9391 \begin_inset Quotes erd
9394 : Typing input undone.
9397 \begin_layout Itemize
9398 \begin_inset Quotes eld
9401 autofire <duty> <cycle>
9402 \begin_inset Quotes erd
9405 : Autofire with specifie duty and cycle.
9408 \begin_layout Itemize
9409 \begin_inset Quotes eld
9413 \begin_inset Quotes erd
9419 \begin_layout Itemize
9420 \begin_inset Quotes eld
9424 \begin_inset Quotes erd
9427 : Analog action on axis.
9431 \begin_layout Subsection
9432 on_movie_lost: Movie data is about to be lost
9435 \begin_layout Itemize
9436 Callback: on_movie_lost(STRING kind)
9439 \begin_layout Standard
9440 Called just before something would happen that could lose movie data.
9444 \begin_layout Itemize
9445 readwrite: Switching to recording mode.
9448 \begin_layout Itemize
9449 reload: ROM is being reloaded in recording mode.
9452 \begin_layout Itemize
9453 load: New movie is being loaded.
9456 \begin_layout Itemize
9457 unsaferewind: Unsafe rewind is happening.
9460 \begin_layout Subsection
9461 on_latch: Latch line is rising
9464 \begin_layout Itemize
9465 Callback: on_latch(<core-dependent-parameters>)
9468 \begin_layout Standard
9469 Called when latch line for controller is rising.
9470 Some cores may not support this.
9473 \begin_layout Section
9474 System-dependent behaviour
9477 \begin_layout Subsection
9481 \begin_layout Itemize
9482 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
9483 p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
9484 p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
9485 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
9486 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
9487 ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
9488 ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
9489 ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
9490 ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
9491 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
9492 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
9493 ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
9494 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
9495 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
9496 ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
9497 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
9498 ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
9499 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
9500 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
9501 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
9502 ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
9503 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
9504 ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
9505 ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
9506 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
9507 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
9508 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
9509 ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
9510 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
9511 ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
9512 ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
9513 ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
9514 ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
9515 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
9516 ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
9517 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
9518 ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
9519 ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
9520 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
9521 ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount,
9524 \begin_layout Itemize
9525 on_latch has no parameters
9528 \begin_layout Itemize
9529 CPU 0 is S-CPU, 1 is S-SMP.
9532 \begin_layout Itemize
9533 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
9536 \begin_layout Itemize
9537 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
9541 \begin_layout Itemize
9542 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
9543 DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
9544 BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
9545 GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
9548 \begin_layout Subsection
9552 \begin_layout Itemize
9553 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
9557 \begin_layout Itemize
9558 on_latch is not supported
9561 \begin_layout Itemize
9565 \begin_layout Itemize
9566 Cheats are supported for ROM, SRAM and WRAM.
9569 \begin_layout Itemize
9570 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
9574 \begin_layout Itemize
9575 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.