1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
6 \use_default_options true
7 \maintain_unincluded_children false
9 \language_package default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
23 \default_output_format default
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
48 \paperorientation portrait
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
69 \paperpagestyle default
70 \tracking_changes false
80 lsnes Lua functions reference
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
103 \begin_layout Section
107 \begin_layout Subsection
111 \begin_layout Itemize
112 Coordinates increase to right and down.
115 \begin_layout Itemize
116 The origin is at top left of game area or buffer.
119 \begin_layout Subsection
123 \begin_layout Itemize
124 Methods that draw something (unless stated otherwise) require a valid rendering
126 This context can come in three ways:
130 \begin_layout Enumerate
131 The default rendering context of paint callback (the screen).
134 \begin_layout Enumerate
135 The default rendering context of video callback (the video).
138 \begin_layout Enumerate
139 Explicitly set rendering context (RENDERCTX:set).
143 \begin_layout Itemize
144 The rendering context is always reset when callback ends.
147 \begin_layout Subsection
151 \begin_layout Standard
152 (Direct) colors can be specified either as numbers or strings.
155 \begin_layout Itemize
156 -1 is fully transparent.
159 \begin_layout Itemize
160 Non-negative numbers less than
161 \begin_inset Formula $2^{32}$
164 are partially opaque colors (
165 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
172 \begin_layout Itemize
173 \begin_inset Formula $a$
177 \begin_inset Formula $0-255$
181 \begin_inset Formula $0$
185 \begin_inset Formula $256$
188 would be fully transparent.
192 \begin_layout Itemize
193 Thus, numbers in range
194 \begin_inset Formula $0-16777215$
197 stand for fully opaque colors.
201 \begin_layout Itemize
202 \begin_inset Formula $r$
206 \begin_inset Formula $g$
210 \begin_inset Formula $b$
213 are intensities of base colors on scale
214 \begin_inset Formula $0-255$
221 \begin_layout Itemize
222 Color can also be specified by name as string: The following color names
223 are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
224 antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
225 azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
226 bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
227 brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
228 burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
229 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
230 chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
231 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
232 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
233 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
234 darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
235 darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
236 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
237 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
238 darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
239 darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
240 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
241 dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
242 firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
243 fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
244 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
245 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
246 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
247 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
248 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
249 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
250 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
251 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
252 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
253 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
254 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
255 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
256 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
257 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
258 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
259 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
260 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
261 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
262 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
263 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
264 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
265 indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
266 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
267 lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
268 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
269 lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
270 lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
271 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
272 lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
273 lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
274 lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
275 lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
276 lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
277 lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
278 maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
279 mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
280 mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
281 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
282 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
283 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
284 navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
285 olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
286 orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
287 palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
288 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
289 palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
290 peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
291 pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
292 purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
293 rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
294 saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
295 seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
296 seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
297 skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
298 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
299 snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
300 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
301 tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
302 tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
303 turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
304 wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
305 yellow3 yellow4 yellowgreen
308 \begin_layout Itemize
309 The HSL base color names: hsl-<hue><saturation><lightness>.
313 \begin_layout Itemize
314 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
315 y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
316 (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
319 \begin_layout Itemize
320 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
323 \begin_layout Itemize
324 Lightness is 0-8, where 0 is black and 8 is white.
328 \begin_layout Itemize
329 The color names can have a modifier after space (multiple modifiers are
330 allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
331 opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
332 hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
336 \begin_layout Itemize
337 opaqueness is measured as percentage.
340 \begin_layout Itemize
341 Hue adjustments are on 24-step scale.
344 \begin_layout Itemize
345 Saturation and lightness adjustments are on 16-step scale.
349 \begin_layout Section
353 \begin_layout Standard
354 These tokens are special, and are expanded while the script is being loaded
357 \begin_layout Subsection
358 @@LUA_SCRIPT_FILENAME@@
361 \begin_layout Standard
362 Expanded to string token containing path and filename of this Lua script.
363 Handy for referencing other lua scripts or resources that are relative
367 \begin_layout Standard
368 In practicular, this is suitable to be passed as base argument of various
369 functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
370 ad_png and gui.bitmap_load_pal.
373 \begin_layout Section
377 \begin_layout Subsection
378 MMAP_STRUCT: Quasi-table mapping emulated memory
381 \begin_layout Standard
382 Objects of this class act like tables, except that the values are reflected
383 to and from emulated memory.
386 \begin_layout Subsubsection
387 static function new: Create new instance
390 \begin_layout Itemize
391 Syntax: mmap memory.mmap.new()
394 \begin_layout Itemize
395 Syntax: mmap classes.MMAP_STRUCT.new()
398 \begin_layout Itemize
399 Deprecated: mmap memory.map_structure()
402 \begin_layout Standard
406 \begin_layout Itemize
407 mmap: MMAP_STRUCT: The created mmap structure.
410 \begin_layout Standard
411 Create a new MMAP_STRUCT (with no mappings) and return it.
414 \begin_layout Subsubsection
415 operator(): Bind key in mmap structure
418 \begin_layout Itemize
419 Syntax: obj(key, marea, address, type)
422 \begin_layout Standard
426 \begin_layout Itemize
427 obj: MMAP_STRUCT: The structure to manipulate.
430 \begin_layout Itemize
431 key: String: The name of the key in array to map.
434 \begin_layout Itemize
435 marea: String: The memory area the mapped address is in (default: global
439 \begin_layout Itemize
440 address: Number: The offset of memory addreess, relative to specified memory
441 area or global memory space.
444 \begin_layout Itemize
445 type: String: The type of data to map.
449 \begin_layout Itemize
450 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
455 \begin_layout Standard
456 Bind key <key> in mmap structure <obj> to address <address> (relative to
458 The memory address is treated as type <type>.
461 \begin_layout Itemize
463 \begin_inset Quotes eld
467 \begin_inset Quotes erd
471 \begin_inset Quotes eld
475 \begin_inset Quotes erd
479 \begin_inset Quotes eld
483 \begin_inset Quotes erd
489 \begin_layout Standard
490 This binds signed word at address WRAM+0x2A into key
491 \begin_inset Quotes eld
495 \begin_inset Quotes erd
501 \begin_layout Standard
502 \begin_inset Newpage pagebreak
508 \begin_layout Subsection
509 ZIPWRITER: Write .zip files
512 \begin_layout Standard
513 This class does writing of .zip files.
516 \begin_layout Subsubsection
517 Static function new: Create a new zipfile
520 \begin_layout Itemize
521 Syntax: zip zip.writer.new(filename, [compression])
524 \begin_layout Itemize
525 Deprecated: zip zip.create(filename, [compression])
528 \begin_layout Standard
532 \begin_layout Itemize
533 filename: string: The name of the file to write.
536 \begin_layout Itemize
537 compression: number: Compression level (0-9).
541 \begin_layout Standard
545 \begin_layout Itemize
546 zip: ZIPWRITER: The newly created ZIP writer.
549 \begin_layout Standard
550 Create a new ZIPWRITER object and return it.
553 \begin_layout Subsubsection
554 Method commit: Finish creating ZIP file.
557 \begin_layout Itemize
558 Syntax: zipfile:commit()
561 \begin_layout Standard
565 \begin_layout Itemize
566 zipfile: ZIPFILE: The ZIP file object.
569 \begin_layout Standard
570 Finish writing the ZIP file and actually create it on disk.
573 \begin_layout Itemize
574 If a member is currently open, it is implicitly closed.
577 \begin_layout Itemize
578 Invoking this on already committed or rolled back zipfile causes an error.
581 \begin_layout Subsubsection
582 Method rollback: Cancel writing the ZIP file.
585 \begin_layout Itemize
586 Syntax: zipfile:rollback()
589 \begin_layout Standard
593 \begin_layout Itemize
594 zipfile: ZIPFILE: The ZIP file object.
597 \begin_layout Standard
598 Cancel writing the whole ZIP file.
599 The file on disk will not be modified.
602 \begin_layout Itemize
603 If a member is currently open, it is implicitly closed.
606 \begin_layout Itemize
607 Invoking this on already committed or rolled back zipfile causes an error.
610 \begin_layout Subsubsection
611 Method create_file: Start writing a new member
614 \begin_layout Itemize
615 Syntax: zipfile:create_file(filename)
618 \begin_layout Standard
622 \begin_layout Itemize
623 zipfile: ZIPFILE: The ZIP file object.
626 \begin_layout Itemize
627 string filename: Name of the new member to create
630 \begin_layout Standard
631 Start writing a new member <filename> in ZIP file.
634 \begin_layout Itemize
635 If a member is currently open, it is implicitly closed.
638 \begin_layout Itemize
639 Invoking this on already committed or rolled back zipfile causes an error.
642 \begin_layout Subsubsection
643 Method close_file: Close member
646 \begin_layout Itemize
647 Syntax: zipfile:close_file()
650 \begin_layout Standard
654 \begin_layout Itemize
655 zipfile: ZIPFILE: The ZIP file object.
658 \begin_layout Standard
659 Close the currently open member in zipfile.
662 \begin_layout Itemize
663 Invoking this on already committed or rolled back zipfile causes an error.
666 \begin_layout Itemize
667 Invoking this without an open member causes an error.
670 \begin_layout Subsubsection
671 Method write: Write data
674 \begin_layout Itemize
675 Syntax: zipfile:write(data)
678 \begin_layout Standard
682 \begin_layout Itemize
683 zipfile: ZIPFILE: The ZIP file object.
686 \begin_layout Itemize
687 data: string: The data to write.
690 \begin_layout Standard
691 Write <data> in binary mode (as-is) to currently open member.
694 \begin_layout Itemize
695 Invoking this without a member being open causes an error.
698 \begin_layout Standard
699 \begin_inset Newpage pagebreak
705 \begin_layout Subsection
706 TILEMAP: Tiled collection of bitmaps.
709 \begin_layout Standard
710 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
713 \begin_layout Subsubsection
714 Static function new: Create a tilemap
717 \begin_layout Itemize
718 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
721 \begin_layout Itemize
722 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
725 \begin_layout Itemize
726 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
729 \begin_layout Standard
733 \begin_layout Itemize
734 w: number: Width of the tilemap in tiles
737 \begin_layout Itemize
738 h: number: Height of the tilemap in tiles
741 \begin_layout Itemize
742 bw: number: Width of each tile in pixels.
745 \begin_layout Itemize
746 bh: number: Height of each tile in pixels.
749 \begin_layout Standard
753 \begin_layout Itemize
754 tilemap: TILEMAP: the newly created tilemap
757 \begin_layout Standard
758 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
762 \begin_layout Subsubsection
763 TILEMAP:getsize: Query tilemap size
766 \begin_layout Itemize
767 Syntax: width, height tmap:getsize()
770 \begin_layout Standard
774 \begin_layout Itemize
775 tmap: TILEMAP: The tilemap to query.
778 \begin_layout Standard
782 \begin_layout Itemize
783 width: number : The width of the tilemap in tiles.
786 \begin_layout Itemize
787 height: number: The height of the tilemap in tiles.
790 \begin_layout Standard
791 Get size of tilemap in tiles.
794 \begin_layout Subsubsection
795 TILEMAP:getcsize: Query tilemap cell size
798 \begin_layout Itemize
799 Syntax: width, height tmap:getcsize()
802 \begin_layout Standard
806 \begin_layout Itemize
807 tmap: TILEMAP: The tilemap to query.
810 \begin_layout Standard
814 \begin_layout Itemize
815 width: number: The width of tilemap tile in pixels.
818 \begin_layout Itemize
819 height: number: The height of tilemap tile in pixels.
822 \begin_layout Standard
823 Get size of each tilemap tile in pixels.
826 \begin_layout Subsubsection
827 TILEMAP:get: Query tilemap tile
830 \begin_layout Itemize
831 Syntax: bitmap, palette tmap:get(x, y)
834 \begin_layout Standard
838 \begin_layout Itemize
839 tmap: TILEMAP: The tilemap to query.
842 \begin_layout Itemize
843 x: number: The x-coordinate of tile to query.
846 \begin_layout Itemize
847 y: number: The y-coordinate of tile to query.
850 \begin_layout Standard
854 \begin_layout Itemize
855 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
858 \begin_layout Itemize
859 palette: The palette (PALETTE) associated with indexed-color bitmap, if
864 \begin_layout Standard
865 Return the contents of tile at <x>,<y>.
868 \begin_layout Subsubsection
869 TILEMAP:set: Set tilemap cell
872 \begin_layout Itemize
873 Syntax: tmap:set(x, y)
876 \begin_layout Itemize
877 Syntax: tmap:set(x, y, bitmap)
880 \begin_layout Itemize
881 Syntax: tmap:set(x, y, bitmap, palette)
884 \begin_layout Standard
888 \begin_layout Itemize
889 tmap: TILEMAP: The tilemap to manipulate.
892 \begin_layout Itemize
893 number x: The x-coordinate of tile to set.
896 \begin_layout Itemize
897 number y: The y-coordinate of tile to set.
900 \begin_layout Itemize
901 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
904 \begin_layout Itemize
905 palette: PALETTE: The associated palette for bitmap.
908 \begin_layout Standard
909 Set the contents of tile <x>,<y>.
910 If no <bitmap> is given, clears the tile.
911 Otherwise sets the tile to contain bitmap <bitmap> with associated palette
915 \begin_layout Itemize
916 Specifying index bitmap <bitmap> without palette <palette> causes an error.
919 \begin_layout Subsubsection
920 TILEMAP:scroll: Scroll tilemap
923 \begin_layout Itemize
924 Syntax: tmap:scroll(ox, oy);
927 \begin_layout Itemize
928 Syntax: tmap:scroll(ox, oy, x, y, w, h);
931 \begin_layout Itemize
932 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
935 \begin_layout Standard
939 \begin_layout Itemize
940 tmap: TILEMAP: The tilemap to manipulate.
943 \begin_layout Itemize
944 ox: number: The number of tiles to scroll horizontally (positive is to right).
947 \begin_layout Itemize
948 oy: number: The number of tiles to scroll vertically (positive is to down).
951 \begin_layout Itemize
952 x: number: The left edge of scroll window.
955 \begin_layout Itemize
956 y: number: The top edge of scroll window.
959 \begin_layout Itemize
960 w: number: The width of scroll window.
963 \begin_layout Itemize
964 h: number: The height of scroll window.
967 \begin_layout Itemize
968 circ_x: boolean: If true, treat the window as circular in horizontal direction.
971 \begin_layout Itemize
972 circ_y: boolean: If true, treat the window as circular in vertical direction.
975 \begin_layout Standard
976 Scroll the specified tilemap <tmap> by <ox>,<oy>.
977 If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
978 <circ_x> and <circ_y> control if scroll is circular or not.
981 \begin_layout Itemize
982 Specifying out-of-range window causes an error.
985 \begin_layout Subsubsection
986 TILEMAP:draw: Draw tilemap
989 \begin_layout Itemize
990 Name: tmap:draw(x, y)
993 \begin_layout Itemize
994 Name: tmap:draw(x, y, x0, y0, w, h)
997 \begin_layout Standard
1001 \begin_layout Itemize
1002 tmap: TILEMAP: The tilemap to draw.
1005 \begin_layout Itemize
1006 x: The x coordinate on screen to draw to.
1009 \begin_layout Itemize
1010 y: The y coordinate on screen to draw to.
1013 \begin_layout Itemize
1014 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1017 \begin_layout Itemize
1018 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1021 \begin_layout Itemize
1022 w: number: The width to draw (in pixels).
1025 \begin_layout Itemize
1026 h: number: The height to draw (in pixels).
1029 \begin_layout Standard
1030 Draw tilemap <tmap> to screen at <x>,<y>.
1031 If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1034 \begin_layout Itemize
1035 This method requires a rendering context to work.
1038 \begin_layout Subsubsection
1039 TILEMAP:draw_outside: Draw tilemap outside game area
1042 \begin_layout Itemize
1043 Name: tmap:draw_outside(x, y)
1046 \begin_layout Itemize
1047 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1050 \begin_layout Standard
1051 Like TILEMAP:draw, but draws only outside game area.
1054 \begin_layout Standard
1055 \begin_inset Newpage pagebreak
1061 \begin_layout Subsection
1062 RENDERCTX: Off-screen rendering context
1065 \begin_layout Standard
1066 Object acting as off-screen rendering context.
1069 \begin_layout Subsubsection
1070 Static function new: Create a render queue
1073 \begin_layout Itemize
1074 Syntax: renderctx gui.renderctx.new(width, height);
1077 \begin_layout Itemize
1078 Syntax: renderctx classes.RENDERCTX.new(width, height);
1081 \begin_layout Itemize
1082 Deprecated: renderctx gui.renderq_new(width, height);
1085 \begin_layout Standard
1089 \begin_layout Itemize
1090 width: number: The notional width of the game area.
1093 \begin_layout Itemize
1094 height: number: The notional height of the game area.
1097 \begin_layout Standard
1101 \begin_layout Itemize
1102 rendectx: RENDERCTX: The newly created render context.
1105 \begin_layout Standard
1106 Create a render context with reported size <width>*<height> and return it.
1109 \begin_layout Subsubsection
1110 Static function setnull: Reset to default queue
1113 \begin_layout Itemize
1114 Syntax: gui.renderctx.setnull()
1117 \begin_layout Itemize
1118 Syntax: classes.RENDERCTX:setnull()
1121 \begin_layout Itemize
1122 Deprecated: gui.renderq_set()
1125 \begin_layout Standard
1126 Reset the used render context back to default for the executing callback:
1129 \begin_layout Itemize
1130 The default for paint callback is the screen
1133 \begin_layout Itemize
1134 The default for video callback is the video frame
1137 \begin_layout Itemize
1138 The default otherwise is nothing.
1141 \begin_layout Subsubsection
1142 Method clear: Clear a render queue
1145 \begin_layout Itemize
1146 Syntax: renderctx:clear()
1149 \begin_layout Itemize
1150 Deprecated: gui.renderq_clear(renderctx)
1153 \begin_layout Standard
1157 \begin_layout Itemize
1158 renderctx: RENDERCTX: The render queue to clear.
1161 \begin_layout Standard
1162 Clear all drawing from the context.
1165 \begin_layout Subsubsection
1166 Method set: Change active render context
1169 \begin_layout Itemize
1170 Syntax: renderctx:set()
1173 \begin_layout Itemize
1174 Deprecated: gui.renderq_set(renderctx)
1177 \begin_layout Standard
1181 \begin_layout Itemize
1182 renderctx: RENDERCTX: The render queue to use.
1185 \begin_layout Standard
1186 Switch the current rendering context <renderctx>.
1189 \begin_layout Subsubsection
1190 Method run: Draw all objects in context to another
1193 \begin_layout Itemize
1194 Syntax: renderctx:run()
1197 \begin_layout Itemize
1198 Deprecated: gui.renderq_run(renderctx)
1201 \begin_layout Standard
1205 \begin_layout Itemize
1206 renderctx: RENDERCTX: The render context to overlay.
1209 \begin_layout Standard
1210 Overlay the specified render context <context> upon the active rendering
1214 \begin_layout Itemize
1215 Trying to overlay rendering context upon itself is a bad idea.
1218 \begin_layout Subsubsection
1219 Method render: Render a contex to bitmap
1222 \begin_layout Itemize
1223 Syntax: bitmap renderctx:render()
1226 \begin_layout Standard
1230 \begin_layout Itemize
1231 renderctx: RENDERCTX: The context to render.
1234 \begin_layout Standard
1238 \begin_layout Itemize
1239 bitmap: DBITMAP: The rendered bitmap.
1242 \begin_layout Standard
1243 Render the specified context <renderctx> to a new bitmap.
1246 \begin_layout Itemize
1247 The size of bitmap will be nominal game area size, plus any set gaps.
1250 \begin_layout Itemize
1251 This method does not require active rendering context.
1254 \begin_layout Subsubsection
1255 Method synchronous_repaint: Paint screen now
1258 \begin_layout Itemize
1259 Syntax: renderctx:synchronous_repaint()
1262 \begin_layout Itemize
1263 Deprecated: gui.synchronous_repaint(renderctx)
1266 \begin_layout Standard
1270 \begin_layout Itemize
1271 renderctx: RENDERCTX: The context to paint.
1274 \begin_layout Standard
1275 Immediately redraw the screen with game overlayed by drawings from context
1279 \begin_layout Itemize
1280 This does not require active rendering context.
1283 \begin_layout Itemize
1284 Will not cause paint callback to be invoked.
1287 \begin_layout Standard
1288 \begin_inset Newpage pagebreak
1294 \begin_layout Subsection
1295 PALETTE: Color palette for indexed image
1298 \begin_layout Subsubsection
1299 Static function new: Create a new palette
1302 \begin_layout Itemize
1303 Syntax: palette gui.palette.new()
1306 \begin_layout Itemize
1307 Syntax: palette classes.PALETTE.new()
1310 \begin_layout Itemize
1311 Deprecated: palette gui.palette_new()
1314 \begin_layout Standard
1318 \begin_layout Itemize
1319 palette: PALETTE: The created palette.
1322 \begin_layout Standard
1323 Create a new palette (with all colors transparent) and return it.
1326 \begin_layout Subsubsection
1327 Static function load: Load a palette
1330 \begin_layout Itemize
1331 Syntax: palette gui.palette.load(file, [base])
1334 \begin_layout Itemize
1335 Syntax: palette classes.PALETTE.load(file, [base])
1338 \begin_layout Itemize
1339 Deprecated: palette gui.palette_load(file, [base])
1342 \begin_layout Standard
1346 \begin_layout Itemize
1347 string file: The file to load.
1350 \begin_layout Itemize
1351 string base (optional): The base file to resolve file relative to.
1354 \begin_layout Standard
1358 \begin_layout Itemize
1359 palette: PALETTE: The loaded palette.
1362 \begin_layout Standard
1363 Load a palette from file <file> (resolved relative to <base>).
1366 \begin_layout Itemize
1367 The file format is a series of lines, each with following format:
1371 \begin_layout Itemize
1372 Blank or just whitespace: Ignored
1375 \begin_layout Itemize
1376 First non-whitespace is '#': Ignored
1379 \begin_layout Itemize
1380 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1383 \begin_layout Itemize
1384 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1385 (0-256, 0 being fully transparent and 256 fully opaque).
1388 \begin_layout Itemize
1389 transparent: Fully transparent color
1393 \begin_layout Subsubsection
1394 Static function load_str: Load a palette from string
1397 \begin_layout Itemize
1398 Syntax: palette gui.palette.load(data)
1401 \begin_layout Itemize
1402 Syntax: palette classes.PALETTE.load(data)
1405 \begin_layout Itemize
1406 Deprecated: palette gui.palette_load(data)
1409 \begin_layout Standard
1413 \begin_layout Itemize
1414 string data: The palette data.
1417 \begin_layout Standard
1421 \begin_layout Itemize
1422 palette: PALETTE: The loaded palette.
1425 \begin_layout Standard
1426 Like PALETTE:load, but instead of reading palette from file, reads it from
1430 \begin_layout Subsubsection
1431 Method set: Set palette entry
1434 \begin_layout Itemize
1435 Syntax: palette:set(index, color)
1438 \begin_layout Itemize
1439 Deprecated: gui.palette_set(palette, ...)
1442 \begin_layout Standard
1446 \begin_layout Itemize
1447 palette: PALETTE: The palette to manipulate
1450 \begin_layout Itemize
1451 index: number: The index of color to set (0-65535).
1454 \begin_layout Itemize
1455 color: number/string: The color value to set.
1458 \begin_layout Standard
1459 Set palette <palette> index <index> to color <color>.
1462 \begin_layout Subsubsection
1463 Method hash: Hash a palette
1466 \begin_layout Itemize
1467 Syntax: hash palette:hash()
1470 \begin_layout Itemize
1471 Deprecated: hash gui.palette_hash(palette)
1474 \begin_layout Standard
1478 \begin_layout Itemize
1479 palette: The palette to hash.
1482 \begin_layout Standard
1486 \begin_layout Itemize
1487 hash: string: 64-hex digit hash.
1490 \begin_layout Standard
1491 Obtain crypto-grade hash of palette data of <palette>.
1494 \begin_layout Itemize
1495 All colors after the last non-transparent one are ignored.
1498 \begin_layout Subsubsection
1499 Method adjust_transparency: Adjust transparency
1502 \begin_layout Itemize
1503 Syntax: palette:adjust_transparency(newvalue)
1506 \begin_layout Itemize
1507 Deprecated: gui.adjust_transparency(palette, ...)
1510 \begin_layout Standard
1514 \begin_layout Itemize
1515 palette: PALETTE: The palette to adjust.
1518 \begin_layout Itemize
1519 Number adj: The factor to multiply opaqueness with times 256.
1522 \begin_layout Standard
1523 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1526 \begin_layout Standard
1527 \begin_inset Newpage pagebreak
1533 \begin_layout Subsection
1534 BITMAP: Indexed-color bitmap
1537 \begin_layout Subsubsection
1538 Static function new: Create a new bitmap
1541 \begin_layout Itemize
1542 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1545 \begin_layout Itemize
1546 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1549 \begin_layout Itemize
1550 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1553 \begin_layout Standard
1557 \begin_layout Itemize
1558 w: number: The width of bitmap to create in pixels.
1561 \begin_layout Itemize
1562 h: number: The height of bitmap to create in pixels.
1565 \begin_layout Itemize
1566 false: boolean: Constant boolean false.
1569 \begin_layout Itemize
1570 fillcolor: number: The initial fill index.
1571 Default 0 if not specified.
1574 \begin_layout Standard
1575 Create a new bitmap of size <w>*<h>.
1576 Fill the bitmap with color index <fillcolor>.
1579 \begin_layout Subsubsection
1580 Method draw: Draw a bitmap
1583 \begin_layout Itemize
1584 Syntax: bitmap:draw(x, y, palette)
1587 \begin_layout Itemize
1588 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1591 \begin_layout Standard
1595 \begin_layout Itemize
1596 bitmap: BITMAP: The bitmap to draw
1599 \begin_layout Itemize
1600 x: number: The x-coordinate on screen.
1603 \begin_layout Itemize
1604 y: number: The y-coordinate on screen.
1607 \begin_layout Itemize
1608 palette: The palette to use for drawing.
1611 \begin_layout Standard
1612 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1615 \begin_layout Subsubsection
1616 Method draw_outside: Draw a bitmap outside game area
1619 \begin_layout Itemize
1620 Syntax: bitmap:draw_outside(x, y, palette)
1623 \begin_layout Standard
1624 Like bitmap:draw, but does not draw on game area.
1627 \begin_layout Subsubsection
1628 Method draw_clip: Draw a bitmap, with clipping
1631 \begin_layout Itemize
1632 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1635 \begin_layout Standard
1639 \begin_layout Itemize
1640 bitmap: BITMAP: The bitmap to draw
1643 \begin_layout Itemize
1644 x: number: The x-coordinate on screen.
1647 \begin_layout Itemize
1648 y: number: The y-coordinate on screen.
1651 \begin_layout Itemize
1652 palette: The palette to use for drawing.
1655 \begin_layout Itemize
1656 x0: The smallest bitmap x coordinate to draw.
1659 \begin_layout Itemize
1660 y0: The smallest bitmap y coordinate to draw.
1663 \begin_layout Itemize
1664 width: Width of region to draw
1667 \begin_layout Itemize
1668 height: Height of region to draw.
1671 \begin_layout Standard
1672 Like bitmap:draw, but clip the bitmap area drawn.
1675 \begin_layout Subsubsection
1676 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1679 \begin_layout Itemize
1680 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1683 \begin_layout Standard
1684 Like bitmap:draw_clip, but only draw outside game area.
1687 \begin_layout Subsubsection
1688 Method pset: Set pixel in bitmap
1691 \begin_layout Itemize
1692 Syntax: bitmap:pset(x, y, color)
1695 \begin_layout Itemize
1696 Deprecaed: gui.bitmap_pset(bitmap, ...)
1699 \begin_layout Standard
1703 \begin_layout Itemize
1704 bitmap: BITMAP: The bitmap to manipulate.
1707 \begin_layout Itemize
1708 x: number: x-coordinate of pixel to set.
1711 \begin_layout Itemize
1712 y: number: y-coordinate of pixel to set.
1715 \begin_layout Itemize
1716 color: number: The color index to set.
1719 \begin_layout Standard
1720 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1723 \begin_layout Subsubsection
1724 Method pget: Get pixel in bitmap
1727 \begin_layout Itemize
1728 Syntax: color bitmap:pget(x,y)
1731 \begin_layout Itemize
1732 Deprecated: color gui.bitmap_pget(bitmap, ...)
1735 \begin_layout Standard
1739 \begin_layout Itemize
1740 bitmap: BITMAP: The bitmap to query.
1743 \begin_layout Itemize
1744 x: number: x-coordinate of pixel to get.
1747 \begin_layout Itemize
1748 y: number: y-coordinate of pixel to get.
1751 \begin_layout Standard
1755 \begin_layout Itemize
1756 color: number: The color index in specified pixel.
1759 \begin_layout Standard
1760 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1763 \begin_layout Subsubsection
1764 Method size: Get size of bitmap
1767 \begin_layout Itemize
1768 Syntax: width, height bitmap:size()
1771 \begin_layout Itemize
1772 Syntax: width, height gui.bitmap_size(bitmap)
1775 \begin_layout Standard
1779 \begin_layout Itemize
1780 bitmap: BITMAP: The bitmap to query.
1783 \begin_layout Standard
1787 \begin_layout Itemize
1788 width: number: The width of the bitmap.
1791 \begin_layout Itemize
1792 height: number: The height of the bitmap.
1795 \begin_layout Standard
1796 Get size of bitmap <bitmap>.
1799 \begin_layout Subsubsection
1800 Method blit: Blit a bitmap into another
1803 \begin_layout Itemize
1804 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1807 \begin_layout Itemize
1808 Deprecated: gui.bitmap_blit(dest, ...)
1811 \begin_layout Standard
1815 \begin_layout Itemize
1816 dest: BITMAP: The target bitmap to blit to.
1819 \begin_layout Itemize
1820 dx: number: The x-coordinate in target.
1823 \begin_layout Itemize
1824 dy: number: The y-coordinate in target.
1827 \begin_layout Itemize
1828 src: BITMAP: The source bitmap.
1831 \begin_layout Itemize
1832 sx: number: The x-coordinate in source.
1835 \begin_layout Itemize
1836 sy: number: The y-coordinate in source.
1839 \begin_layout Itemize
1840 w: number: The width of area to blit.
1843 \begin_layout Itemize
1844 h: number: The height of area to blit.
1847 \begin_layout Itemize
1848 ck: number: The color key.
1849 Pixels with this index are not copied.
1853 \begin_layout Itemize
1854 If none is specified, all pixels are copied.
1858 \begin_layout Standard
1859 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1861 If a color key <ck> is specified, pixels of that color are not copied.
1864 \begin_layout Subsubsection
1865 Method blit_scaled: Blit a bitmap into another with scaling
1868 \begin_layout Itemize
1869 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1872 \begin_layout Itemize
1873 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1876 \begin_layout Standard
1880 \begin_layout Itemize
1881 dest: BITMAP: The target bitmap to blit to.
1884 \begin_layout Itemize
1885 dx: number: The x-coordinate in target.
1888 \begin_layout Itemize
1889 dy: number: The y-coordinate in target.
1892 \begin_layout Itemize
1893 src: BITMAP: The source bitmap.
1896 \begin_layout Itemize
1897 sx: number: The x-coordinate in source.
1900 \begin_layout Itemize
1901 sy: number: The y-coordinate in source.
1904 \begin_layout Itemize
1905 w: number: The width of area to blit.
1908 \begin_layout Itemize
1909 h: number: The height of area to blit.
1912 \begin_layout Itemize
1913 hscl: number: Horizontal scale factor (integer).
1916 \begin_layout Itemize
1917 vscl: number: Vertical scale factor (integer).
1918 Defaults to the same as <hscl>.
1921 \begin_layout Itemize
1922 ck: number: The color key.
1923 Pixels with this index are not copied.
1927 \begin_layout Itemize
1928 If none is specified, all pixels are copied.
1932 \begin_layout Standard
1933 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1934 neighbor) by factor of <hscl>*<vscl>.
1937 \begin_layout Subsubsection
1938 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1941 \begin_layout Itemize
1942 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1945 \begin_layout Itemize
1946 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1949 \begin_layout Standard
1953 \begin_layout Itemize
1954 dest: BITMAP: The target bitmap to blit to.
1957 \begin_layout Itemize
1958 dx: number: The x-coordinate in target.
1961 \begin_layout Itemize
1962 dy: number: The y-coordinate in target.
1965 \begin_layout Itemize
1966 src: BITMAP: The source bitmap.
1969 \begin_layout Itemize
1970 sx: number: The x-coordinate in source.
1973 \begin_layout Itemize
1974 sy: number: The y-coordinate in source.
1977 \begin_layout Itemize
1978 w: number: The width of area to blit.
1981 \begin_layout Itemize
1982 h: number: The height of area to blit.
1985 \begin_layout Itemize
1986 operator: string: The operator to use.
1990 \begin_layout Itemize
1991 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
1992 DestOut, Clear or Xor.
1996 \begin_layout Standard
1997 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2002 \begin_layout Itemize
2003 Color index 0 in source and target is treated as background.
2006 \begin_layout Subsubsection
2007 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2008 Porter-Duff composition
2011 \begin_layout Itemize
2012 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2016 \begin_layout Itemize
2017 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2020 \begin_layout Standard
2024 \begin_layout Itemize
2025 dest: BITMAP: The target bitmap to blit to.
2028 \begin_layout Itemize
2029 dx: number: The x-coordinate in target.
2032 \begin_layout Itemize
2033 dy: number: The y-coordinate in target.
2036 \begin_layout Itemize
2037 src: BITMAP: The source bitmap.
2040 \begin_layout Itemize
2041 sx: number: The x-coordinate in source.
2044 \begin_layout Itemize
2045 sy: number: The y-coordinate in source.
2048 \begin_layout Itemize
2049 w: number: The width of area to blit.
2052 \begin_layout Itemize
2053 h: number: The height of area to blit.
2056 \begin_layout Itemize
2057 hscl: number: Horizontal scale factor (integer).
2060 \begin_layout Itemize
2061 vscl: number: Vertical scale factor (integer).
2062 Defaults to the same as <hscl>.
2065 \begin_layout Itemize
2066 operator: string: The operator to use.
2070 \begin_layout Itemize
2071 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2072 DestOut, Clear or Xor.
2076 \begin_layout Standard
2077 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2078 like BITMAP:blit_scaled.
2081 \begin_layout Subsubsection
2082 Method blit_priority: Blit a bitmap into another with color priority
2085 \begin_layout Itemize
2086 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2089 \begin_layout Itemize
2090 Deprecated: gui.bitmap_blit_priority(dest, ...)
2093 \begin_layout Standard
2097 \begin_layout Itemize
2098 dest: BITMAP: The target bitmap to blit to.
2101 \begin_layout Itemize
2102 dx: number: The x-coordinate in target.
2105 \begin_layout Itemize
2106 dy: number: The y-coordinate in target.
2109 \begin_layout Itemize
2110 src: BITMAP: The source bitmap.
2113 \begin_layout Itemize
2114 sx: number: The x-coordinate in source.
2117 \begin_layout Itemize
2118 sy: number: The y-coordinate in source.
2121 \begin_layout Itemize
2122 w: number: The width of area to blit.
2125 \begin_layout Itemize
2126 h: number: The height of area to blit.
2129 \begin_layout Standard
2130 Like BITMAP:blit, but only copy pixels where source color index is greater
2131 than destination color index.
2134 \begin_layout Subsubsection
2135 Method blit_scaled_priority: Blit a bitmap into another with color priority
2139 \begin_layout Itemize
2140 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2143 \begin_layout Itemize
2144 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2147 \begin_layout Standard
2151 \begin_layout Itemize
2152 dest: BITMAP: The target bitmap to blit to.
2155 \begin_layout Itemize
2156 dx: number: The x-coordinate in target.
2159 \begin_layout Itemize
2160 dy: number: The y-coordinate in target.
2163 \begin_layout Itemize
2164 src: BITMAP: The source bitmap.
2167 \begin_layout Itemize
2168 sx: number: The x-coordinate in source.
2171 \begin_layout Itemize
2172 sy: number: The y-coordinate in source.
2175 \begin_layout Itemize
2176 w: number: The width of area to blit.
2179 \begin_layout Itemize
2180 h: number: The height of area to blit.
2183 \begin_layout Itemize
2184 hscl: number: Horizontal scale factor (integer).
2187 \begin_layout Itemize
2188 vscl: number: Vertical scale factor (integer).
2189 Defaults to the same as <hscl>.
2192 \begin_layout Standard
2193 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2197 \begin_layout Subsubsection
2198 Method save_png: Save a bitmap to PNG
2201 \begin_layout Itemize
2202 Syntax: bitmap:save_png(filename, [base], palette)
2205 \begin_layout Itemize
2206 Syntax: data bitmap:save_png(palette)
2209 \begin_layout Itemize
2211 gui.bitmap_save_png(bitmap, ...)
2214 \begin_layout Standard
2218 \begin_layout Itemize
2219 bitmap: BITMAP: The bitmap to save.
2222 \begin_layout Itemize
2223 filename: string: The filename to save to.
2226 \begin_layout Itemize
2227 base: string: The base filename is resolved relative to.
2230 \begin_layout Itemize
2231 palette: PALETTE: The palette to use.
2234 \begin_layout Standard
2238 \begin_layout Itemize
2239 data: string: BASE64 encoded PNG data.
2242 \begin_layout Standard
2243 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2244 to <base>) or return BASE64 encoding of it.
2247 \begin_layout Subsubsection
2248 Method hash: Hash a bitmap
2251 \begin_layout Itemize
2252 Syntax: hash bitmap:hash()
2255 \begin_layout Itemize
2256 Deprecated: hash bitmap:hash(bitmap)
2259 \begin_layout Standard
2263 \begin_layout Itemize
2264 bitmap: BITMAP: The bitmap to hash.
2267 \begin_layout Standard
2271 \begin_layout Itemize
2272 hash: string: 64-hex digit hash
2275 \begin_layout Standard
2276 Hashes bitmap <bitmap> and returns crypto-strong hash.
2280 \begin_layout Itemize
2281 Color order in bitmap is significant.
2284 \begin_layout Standard
2285 \begin_inset Newpage pagebreak
2291 \begin_layout Subsection
2292 DBITMAP: Direct-color bitmap
2295 \begin_layout Subsubsection
2296 Static function: new: Create a new bitmap
2299 \begin_layout Itemize
2300 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2303 \begin_layout Itemize
2304 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2307 \begin_layout Itemize
2308 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2311 \begin_layout Standard
2315 \begin_layout Itemize
2316 w: number: The width of new bitmap.
2319 \begin_layout Itemize
2320 h: number: The height of new bitmap.
2323 \begin_layout Itemize
2324 true: boolean: Fixed boolean true
2327 \begin_layout Itemize
2328 fillcolor: The color to fill the bitmap with (default transparent).
2331 \begin_layout Standard
2335 \begin_layout Itemize
2336 bitmap: DBITMAP: The new bitmap.
2339 \begin_layout Standard
2340 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2344 \begin_layout Subsubsection
2345 Method draw: Draw a bitmap
2348 \begin_layout Itemize
2349 Syntax: bitmap.draw(x, y)
2352 \begin_layout Itemize
2353 Deprecated: gui.bitmap_draw(x, y, bitmap)
2356 \begin_layout Standard
2360 \begin_layout Itemize
2361 bitmap: DBITMAP: The bitmap to draw.
2364 \begin_layout Itemize
2365 x: number: X-coordinate on screen.
2368 \begin_layout Itemize
2369 y: number: Y-coordinate on screen.
2372 \begin_layout Standard
2373 Draw bitmap <bitmap> on screen at <x>,<y>.
2376 \begin_layout Subsubsection
2377 Method draw_outside: Draw a bitmap outside game area
2380 \begin_layout Itemize
2381 Syntax: dbitmap:draw_outside(x, y, palette)
2384 \begin_layout Standard
2385 Like dbitmap:draw, but does not draw on game area.
2388 \begin_layout Subsubsection
2389 Method draw_clip: Draw a bitmap, with clipping
2392 \begin_layout Itemize
2393 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2396 \begin_layout Standard
2400 \begin_layout Itemize
2401 bitmap: DBITMAP: The bitmap to draw
2404 \begin_layout Itemize
2405 x: number: The x-coordinate on screen.
2408 \begin_layout Itemize
2409 y: number: The y-coordinate on screen.
2412 \begin_layout Itemize
2413 x0: The smallest bitmap x coordinate to draw.
2416 \begin_layout Itemize
2417 y0: The smallest bitmap y coordinate to draw.
2420 \begin_layout Itemize
2421 width: Width of region to draw
2424 \begin_layout Itemize
2425 height: Height of region to draw.
2428 \begin_layout Standard
2429 Like dbitmap:draw, but clip the bitmap area drawn.
2432 \begin_layout Subsubsection
2433 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2436 \begin_layout Itemize
2437 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2440 \begin_layout Standard
2441 Like dbitmap:draw_clip, but only draw outside game area.
2444 \begin_layout Subsubsection
2445 Method pset: Set pixel in bitmap
2448 \begin_layout Itemize
2449 Syntax: bitmap:pset(x, y, color)
2452 \begin_layout Itemize
2453 Deprecaed: gui.bitmap_pset(bitmap, ...)
2456 \begin_layout Standard
2460 \begin_layout Itemize
2461 bitmap: DBITMAP: The bitmap to manipulate.
2464 \begin_layout Itemize
2465 x: number: x-coordinate of pixel to set.
2468 \begin_layout Itemize
2469 y: number: y-coordinate of pixel to set.
2472 \begin_layout Itemize
2473 color: number/string: The color to set.
2476 \begin_layout Standard
2477 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2480 \begin_layout Subsubsection
2481 Method pget: Get pixel in bitmap
2484 \begin_layout Itemize
2485 Syntax: color bitmap:pget(x,y)
2488 \begin_layout Itemize
2489 Deprecated: color gui.bitmap_pget(bitmap, ...)
2492 \begin_layout Standard
2496 \begin_layout Itemize
2497 bitmap: DBITMAP: The bitmap to query.
2500 \begin_layout Itemize
2501 x: number: x-coordinate of pixel to get.
2504 \begin_layout Itemize
2505 y: number: y-coordinate of pixel to get.
2508 \begin_layout Standard
2512 \begin_layout Itemize
2513 color: number: The color of specified pixel.
2516 \begin_layout Standard
2517 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2520 \begin_layout Subsubsection
2521 Method size: Get size of bitmap
2524 \begin_layout Itemize
2525 Syntax: width, height bitmap:size()
2528 \begin_layout Itemize
2529 Syntax: width, height gui.bitmap_size(bitmap)
2532 \begin_layout Standard
2536 \begin_layout Itemize
2537 bitmap: DBITMAP: The bitmap to query.
2540 \begin_layout Standard
2544 \begin_layout Itemize
2545 width: number: The width of the bitmap.
2548 \begin_layout Itemize
2549 height: number: The height of the bitmap.
2552 \begin_layout Standard
2553 Get size of bitmap <bitmap>.
2556 \begin_layout Subsubsection
2557 Method blit: Blit a bitmap into another
2560 \begin_layout Itemize
2561 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2564 \begin_layout Itemize
2565 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2568 \begin_layout Itemize
2569 Deprecated: gui.bitmap_blit(dest, ...)
2572 \begin_layout Standard
2576 \begin_layout Itemize
2577 dest: DBITMAP: The target bitmap to blit to.
2580 \begin_layout Itemize
2581 dx: number: The x-coordinate in target.
2584 \begin_layout Itemize
2585 dy: number: The y-coordinate in target.
2588 \begin_layout Itemize
2589 src: BITMAP/DBITMAP: The source bitmap.
2592 \begin_layout Itemize
2593 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2596 \begin_layout Itemize
2597 sx: number: The x-coordinate in source.
2600 \begin_layout Itemize
2601 sy: number: The y-coordinate in source.
2604 \begin_layout Itemize
2605 w: number: The width of area to blit.
2608 \begin_layout Itemize
2609 h: number: The height of area to blit.
2612 \begin_layout Itemize
2613 ck: number: The color key.
2614 Pixels with this index are not copied.
2618 \begin_layout Itemize
2619 If none is specified, all pixels are copied.
2622 \begin_layout Itemize
2623 If <src> is paletted, this is color index, otherwise it is a color.
2627 \begin_layout Standard
2628 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2629 if indexed) into <dest> at <dx>,<dy>.
2630 If a color key <ck> is specified, pixels of that color are not copied.
2633 \begin_layout Subsubsection
2634 Method blit_scaled: Blit a bitmap into another with scaling
2637 \begin_layout Itemize
2638 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2641 \begin_layout Itemize
2642 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2646 \begin_layout Itemize
2647 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2650 \begin_layout Standard
2654 \begin_layout Itemize
2655 dest: DBITMAP: The target bitmap to blit to.
2658 \begin_layout Itemize
2659 dx: number: The x-coordinate in target.
2662 \begin_layout Itemize
2663 dy: number: The y-coordinate in target.
2666 \begin_layout Itemize
2667 src: BITMAP/DBITMAP: The source bitmap.
2670 \begin_layout Itemize
2671 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2674 \begin_layout Itemize
2675 sx: number: The x-coordinate in source.
2678 \begin_layout Itemize
2679 sy: number: The y-coordinate in source.
2682 \begin_layout Itemize
2683 w: number: The width of area to blit.
2686 \begin_layout Itemize
2687 h: number: The height of area to blit.
2690 \begin_layout Itemize
2691 hscl: number: Horizontal scale factor (integer).
2694 \begin_layout Itemize
2695 vscl: number: Vertical scale factor (integer).
2696 Defaults to the same as <hscl>.
2699 \begin_layout Itemize
2700 ck: number: The color key.
2701 Pixels with this index are not copied.
2705 \begin_layout Itemize
2706 If none is specified, all pixels are copied.
2709 \begin_layout Itemize
2710 If <src> is paletted, this is color index, otherwise it is a color.
2714 \begin_layout Standard
2715 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2716 neighbor) by factor of <hscl>*<vscl>.
2719 \begin_layout Subsubsection
2720 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2723 \begin_layout Itemize
2724 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2727 \begin_layout Itemize
2728 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2731 \begin_layout Itemize
2732 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2735 \begin_layout Standard
2739 \begin_layout Itemize
2740 dest: DBITMAP: The target bitmap to blit to.
2743 \begin_layout Itemize
2744 dx: number: The x-coordinate in target.
2747 \begin_layout Itemize
2748 dy: number: The y-coordinate in target.
2751 \begin_layout Itemize
2752 src: BITMAP/DBITMAP: The source bitmap.
2755 \begin_layout Itemize
2756 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2759 \begin_layout Itemize
2760 sx: number: The x-coordinate in source.
2763 \begin_layout Itemize
2764 sy: number: The y-coordinate in source.
2767 \begin_layout Itemize
2768 w: number: The width of area to blit.
2771 \begin_layout Itemize
2772 h: number: The height of area to blit.
2775 \begin_layout Itemize
2776 operator: string: The operator to use.
2780 \begin_layout Itemize
2781 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2782 DestOut, Clear or Xor.
2786 \begin_layout Standard
2787 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2792 \begin_layout Itemize
2793 In target, fully transparent is background.
2794 In source, either fully transparent (if direct) or index 0 (if paletted)
2795 is treated as background.
2798 \begin_layout Subsubsection
2799 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2800 Porter-Duff composition
2803 \begin_layout Itemize
2804 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2808 \begin_layout Itemize
2809 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2813 \begin_layout Itemize
2814 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2817 \begin_layout Standard
2821 \begin_layout Itemize
2822 dest: DBITMAP: The target bitmap to blit to.
2825 \begin_layout Itemize
2826 dx: number: The x-coordinate in target.
2829 \begin_layout Itemize
2830 dy: number: The y-coordinate in target.
2833 \begin_layout Itemize
2834 src: BITMAP/DBITMAP: The source bitmap.
2837 \begin_layout Itemize
2838 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2841 \begin_layout Itemize
2842 sx: number: The x-coordinate in source.
2845 \begin_layout Itemize
2846 sy: number: The y-coordinate in source.
2849 \begin_layout Itemize
2850 w: number: The width of area to blit.
2853 \begin_layout Itemize
2854 h: number: The height of area to blit.
2857 \begin_layout Itemize
2858 hscl: number: Horizontal scale factor (integer).
2861 \begin_layout Itemize
2862 vscl: number: Vertical scale factor (integer).
2863 Defaults to the same as <hscl>.
2866 \begin_layout Itemize
2867 operator: string: The operator to use.
2871 \begin_layout Itemize
2872 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2873 DestOut, Clear or Xor.
2877 \begin_layout Standard
2878 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2879 like DBITMAP:blit_scaled.
2882 \begin_layout Subsubsection
2883 Method adjust_transparency: Adjust transparency of bitmap
2886 \begin_layout Itemize
2887 Syntax: bitmap:adjust_transparency(newvalue)
2890 \begin_layout Itemize
2891 Deprecated: gui.adjust_transparency(bitmap, ...)
2894 \begin_layout Standard
2898 \begin_layout Itemize
2899 bitmap: DBITMAP: The bitmap to adjust.
2902 \begin_layout Itemize
2903 Number adj: The factor to multiply opaqueness with times 256.
2906 \begin_layout Standard
2907 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2910 \begin_layout Subsubsection
2911 Method save_png: Save a bitmap to PNG
2914 \begin_layout Itemize
2915 Syntax: bitmap:save_png(filename, [base])
2918 \begin_layout Itemize
2919 Syntax: data bitmap:save_png()
2922 \begin_layout Itemize
2924 gui.bitmap_save_png(bitmap, ...)
2927 \begin_layout Standard
2931 \begin_layout Itemize
2932 bitmap: DBITMAP: The bitmap to save.
2935 \begin_layout Itemize
2936 filename: string: The filename to save to.
2939 \begin_layout Itemize
2940 base: string: The base filename is resolved relative to.
2943 \begin_layout Standard
2947 \begin_layout Itemize
2948 data: string: BASE64 encoded PNG data.
2951 \begin_layout Standard
2952 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2953 BASE64 encoding of it.
2956 \begin_layout Subsubsection
2957 Method hash: Hash a bitmap
2960 \begin_layout Itemize
2961 Syntax: hash bitmap:hash()
2964 \begin_layout Itemize
2965 Deprecated: hash bitmap:hash(bitmap)
2968 \begin_layout Standard
2972 \begin_layout Itemize
2973 bitmap: DBITMAP: The bitmap to hash.
2976 \begin_layout Standard
2980 \begin_layout Itemize
2981 hash: string: 64-hex digit hash
2984 \begin_layout Standard
2985 Hashes bitmap <bitmap> and returns crypto-strong hash.
2989 \begin_layout Subsection
2990 IMAGELOADER: Load an image
2993 \begin_layout Subsubsection
2994 Static function load: Load a bitmap from file
2997 \begin_layout Itemize
2998 Syntax: bitmap, palette gui.image.load(file, [base])
3001 \begin_layout Itemize
3002 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3005 \begin_layout Itemize
3007 gui.bitmap_load(...)
3010 \begin_layout Standard
3014 \begin_layout Itemize
3015 file: string: The file to read.
3018 \begin_layout Itemize
3019 base: string: The base to resolve <file> relative to.
3022 \begin_layout Standard
3026 \begin_layout Itemize
3027 bitmap: BITMAP/DBITMAP: The new bitmap
3030 \begin_layout Itemize
3031 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3035 \begin_layout Standard
3036 Load a new bitmap and return it (plus associated palette if any).
3039 \begin_layout Subsubsection
3040 Static function load_str: Load a bitmap from string
3043 \begin_layout Itemize
3044 Syntax: bitmap, palette gui.image.load_str(data)
3047 \begin_layout Itemize
3048 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3051 \begin_layout Itemize
3053 gui.bitmap_load_str(...)
3056 \begin_layout Standard
3060 \begin_layout Itemize
3061 data: string: The image data
3064 \begin_layout Standard
3068 \begin_layout Itemize
3069 bitmap: BITMAP/DBITMAP: The new bitmap
3072 \begin_layout Itemize
3073 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3077 \begin_layout Standard
3078 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3082 \begin_layout Subsubsection
3083 Static function load_png: Load a bitmap from PNG file
3086 \begin_layout Itemize
3087 Syntax: bitmap, palette gui.image.load_png(file, [base])
3090 \begin_layout Itemize
3091 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3094 \begin_layout Itemize
3096 gui.bitmap_load_png(...)
3099 \begin_layout Standard
3103 \begin_layout Itemize
3104 file: string: The file to read.
3107 \begin_layout Itemize
3108 base: string: The base to resolve <file> relative to.
3111 \begin_layout Standard
3115 \begin_layout Itemize
3116 bitmap: BITMAP/DBITMAP: The new bitmap
3119 \begin_layout Itemize
3120 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3124 \begin_layout Standard
3125 Like IMAGELOADER:load, but load a PNG file instead.
3128 \begin_layout Subsubsection
3129 Static function load_png_str: Load a PNG bitmap from string
3132 \begin_layout Itemize
3133 Syntax: bitmap, palette gui.image.load_png_str(data)
3136 \begin_layout Itemize
3137 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3140 \begin_layout Itemize
3142 gui.bitmap_load_png_str(...)
3145 \begin_layout Standard
3149 \begin_layout Itemize
3150 data: string: The image data, base64 encoded.
3153 \begin_layout Standard
3157 \begin_layout Itemize
3158 bitmap: BITMAP/DBITMAP: The new bitmap
3161 \begin_layout Itemize
3162 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3166 \begin_layout Standard
3167 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3168 <data> instead of file.
3171 \begin_layout Standard
3172 \begin_inset Newpage pagebreak
3178 \begin_layout Subsection
3179 CUSTOMFONT: Arbitrary-sized bitmap font
3182 \begin_layout Subsubsection
3183 Static function new: Return a new empty font
3186 \begin_layout Itemize
3187 Syntax: font gui.font.new()
3190 \begin_layout Itemize
3191 Syntax: font classes.CUSTOMFONT.new()
3194 \begin_layout Itemize
3195 Deprecated: font gui.font_new()
3198 \begin_layout Standard
3202 \begin_layout Itemize
3203 font: CUSTOMFONT: New font.
3206 \begin_layout Standard
3207 Create a new font with no characters and return it.
3210 \begin_layout Subsubsection
3211 Static function: load: Load a font file
3214 \begin_layout Itemize
3215 Syntax: font gui.font.load(file, [base])
3218 \begin_layout Itemize
3219 Syntax: font gui.font.load()
3222 \begin_layout Itemize
3223 Syntax: font classes.CUSTOMFONT.load(file, [base])
3226 \begin_layout Itemize
3227 Syntax: font classes.CUSTOMFONT.load()
3230 \begin_layout Itemize
3231 Deprecated: font gui.loadfont(...)
3234 \begin_layout Standard
3238 \begin_layout Itemize
3239 file: string: The file to read the font from
3242 \begin_layout Itemize
3243 base: string: The file to resolve <file> relative to.
3246 \begin_layout Standard
3250 \begin_layout Itemize
3251 font: CUSTOMFONT: New font.
3254 \begin_layout Standard
3255 Load font from file <file> (relative to <base>).
3256 If no filename is given, system default font is loaded.
3259 \begin_layout Subsubsection
3260 operator(): Render text to screen
3263 \begin_layout Itemize
3264 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3267 \begin_layout Standard
3271 \begin_layout Itemize
3272 font: CUSTOMFONT: The font to use.
3275 \begin_layout Itemize
3276 x: number: The x-position on screen to draw to.
3279 \begin_layout Itemize
3280 y: number: The y-position on screen to draw to.
3283 \begin_layout Itemize
3284 text: string: The text to draw.
3287 \begin_layout Itemize
3288 fgc: number/string: Foreground color (default white).
3291 \begin_layout Itemize
3292 bgc: number/string: Background color (default transparent).
3295 \begin_layout Itemize
3296 hlc: number/string: Outline color (default transparent).
3299 \begin_layout Standard
3300 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3304 \begin_layout Itemize
3305 If <hlc> is transparent, no outline is drawn.
3308 \begin_layout Subsubsection
3309 Method edit: Alter glyph in font
3312 \begin_layout Itemize
3313 Syntax: font:edit(character, glyph)
3316 \begin_layout Standard
3320 \begin_layout Itemize
3321 font: CUSTOMFONT: The font to edit.
3324 \begin_layout Itemize
3325 character: string: The character to edit (UTF-8 encoded).
3328 \begin_layout Itemize
3329 glyph: BITMAP: The bitmap to use.
3332 \begin_layout Standard
3333 Replace character <character> in font <font> by <glyph>.
3336 \begin_layout Itemize
3337 Color index 0 is background, everything else is foreground.
3340 \begin_layout Itemize
3341 <character> may be empty string, meaning the replacement character used
3345 \begin_layout Itemize
3346 <character> may be multi-codepoint string, meaning character used for that
3350 \begin_layout Standard
3351 \begin_inset Newpage pagebreak
3357 \begin_layout Subsection
3358 ICONV: Character set conversions
3361 \begin_layout Subsubsection
3362 Static function new: Create new character set converter
3365 \begin_layout Itemize
3366 Syntax: iconv iconv.new(from, to);
3369 \begin_layout Itemize
3370 Syntax: iconv classes.ICONV.new(from, to);
3373 \begin_layout Itemize
3374 Deprecated: iconv iconv_new(...);
3377 \begin_layout Standard
3381 \begin_layout Itemize
3382 from: string: The source character set.
3385 \begin_layout Itemize
3386 to: string: The target character set.
3389 \begin_layout Standard
3393 \begin_layout Itemize
3394 iconv: ICONV: The converter.
3397 \begin_layout Standard
3398 Create a character set converter, converting from <from> to <to> and return
3402 \begin_layout Subsubsection
3403 Operator(): Convert string fragment from character set to another
3406 \begin_layout Itemize
3407 Syntax: success, result, unconverted, error iconv(input)
3410 \begin_layout Standard
3414 \begin_layout Itemize
3415 iconv: ICONV: The context to use.
3418 \begin_layout Itemize
3419 input: string: The input to convert.
3422 \begin_layout Standard
3426 \begin_layout Itemize
3427 success: boolean: True if conversion was successful, false if not.
3430 \begin_layout Itemize
3431 result: string: The string (partially) converted.
3434 \begin_layout Itemize
3435 unconvered: number: Number of bytes that were not converted (only if <success>
3439 \begin_layout Itemize
3440 error: string: Error that caused conversion to stop (only if <success> is
3445 \begin_layout Itemize
3446 INVALID: The input string is invalid.
3449 \begin_layout Itemize
3450 INCOMPLETE: The input string cuts off in middle of character.
3453 \begin_layout Itemize
3454 INTERNALERR: Internal error.
3458 \begin_layout Standard
3459 Convert a string <input> using character set converter <iconv> and return
3463 \begin_layout Standard
3464 \begin_inset Newpage pagebreak
3470 \begin_layout Subsection
3471 FILEREADER: Read a file as a stream
3474 \begin_layout Subsubsection
3475 Static function open: Open a stream
3478 \begin_layout Itemize
3479 Syntax: handle filereader.open(file, [base])
3482 \begin_layout Itemize
3483 Syntax: handle classes.FILEREADER.open(file, [base])
3486 \begin_layout Itemize
3487 Deprecated: handle open_file(file, [base])
3490 \begin_layout Standard
3494 \begin_layout Itemize
3495 file: string: The filename to read.
3498 \begin_layout Itemize
3499 base: string: The base <file> is resolved against.
3502 \begin_layout Standard
3506 \begin_layout Itemize
3507 handle: FILEREADER: The new file reader.
3510 \begin_layout Standard
3511 Open file <file> (relative to <base>) and return a handle to it.
3514 \begin_layout Subsubsection
3515 operator(): Read line/bytes from stream
3518 \begin_layout Itemize
3519 Syntax: result handle()
3522 \begin_layout Itemize
3523 Syntax: result handle(bytes)
3526 \begin_layout Standard
3530 \begin_layout Itemize
3531 handle: FILEREADER: The handle to read from.
3534 \begin_layout Itemize
3535 bytes: Number of bytes to read (default is next line).
3538 \begin_layout Standard
3542 \begin_layout Itemize
3543 result: string: The read data, or nil on end-of-file.
3546 \begin_layout Standard
3547 Reads next line or <bytes> bytes from specified file handle <handle>.
3550 \begin_layout Itemize
3551 If reading specified number of bytes, the bytes are read in binary mode
3555 \begin_layout Itemize
3556 If reading next line, the line is read in text mode (any line ending is
3560 \begin_layout Subsubsection
3561 Method lines: Iterator to read all lines
3564 \begin_layout Itemize
3565 Syntax: for line in handle:lines() do ...
3569 \begin_layout Standard
3573 \begin_layout Itemize
3574 handle: FILEREADER: The handle to read.
3577 \begin_layout Standard
3581 \begin_layout Itemize
3582 A lua iterator with one variable.
3585 \begin_layout Standard
3586 Return a Lua iterator that iterates all the lines in <handle>.
3589 \begin_layout Standard
3590 \begin_inset Newpage pagebreak
3596 \begin_layout Subsection
3597 COMPARE_OBJ: Watch memory area for changes
3600 \begin_layout Standard
3601 Objects of this class allow fast checking for modifications to given memory
3605 \begin_layout Subsubsection
3606 Static function new: Create a checker
3609 \begin_layout Itemize
3610 Syntax: handle classes.COMPARE_OBJ.new(marea, offset, size, [rows, stride])
3613 \begin_layout Itemize
3614 Syntax: handle memory.compare_new(marea, offset, size, rows, stride)
3617 \begin_layout Standard
3621 \begin_layout Itemize
3622 marea: string: The memory area to interpret <offset> against.
3625 \begin_layout Itemize
3626 offset: number: The initial offset in memory area.
3629 \begin_layout Itemize
3630 size: number: The number of bytes in each row.
3633 \begin_layout Itemize
3634 rows: number: The number of rows.
3638 \begin_layout Itemize
3639 stride: number: The number of bytes offset increments from one row to next.
3642 \begin_layout Standard
3646 \begin_layout Itemize
3650 \begin_layout Standard
3651 Return an object watching specified memory area.
3654 \begin_layout Itemize
3655 Note: For fastest operation, limit checks to inside one memory area (that
3656 has to be mappable, individual RAM areas often are).
3659 \begin_layout Subsubsection
3660 operator(): Check area for modifications
3663 \begin_layout Itemize
3664 Syntax: boolean handle()
3667 \begin_layout Standard
3671 \begin_layout Itemize
3672 True if memory block has been modified since last call (or object creation
3673 if first call), false if not.
3676 \begin_layout Standard
3677 Check if the block has been modified.
3680 \begin_layout Standard
3681 \begin_inset Newpage pagebreak
3687 \begin_layout Section
3691 \begin_layout Subsection
3692 print: Print values to console
3695 \begin_layout Itemize
3696 Syntax: none print(value...
3700 \begin_layout Standard
3701 Prints specified values to console.
3702 Can print any Lua type at least enough to identify the type and instance.
3705 \begin_layout Subsection
3706 tostringx: Format a value to string
3709 \begin_layout Itemize
3710 Syntax: string tostringx(value val)
3713 \begin_layout Standard
3714 Formats value <val> like print would, and returns the result as a string.
3717 \begin_layout Subsection
3718 exec: Execute lsnes commands
3721 \begin_layout Itemize
3722 Syntax: none exec(string cmd)
3725 \begin_layout Standard
3726 Execute lsnes command <cmd>.
3729 \begin_layout Subsection
3730 utime: Get current time
3733 \begin_layout Itemize
3734 Syntax: (number,number) utime()
3737 \begin_layout Standard
3738 Returns two numbers.
3739 First is time since some epoch in seconds, the second is microseconds mod
3740 10^6 since that epoch.
3743 \begin_layout Subsection
3744 set_idle_timeout: Run function after timeout when emulator is idle
3747 \begin_layout Itemize
3748 Syntax: none set_idle_timeout(number timeout)
3751 \begin_layout Standard
3752 Set number of microseconds to block idle for.
3753 After this timeout has expired, on_idle() will be called once.
3756 \begin_layout Subsection
3757 set_timer_timeout: Run function after timeout.
3760 \begin_layout Itemize
3761 Syntax: none set_timer_timeout(number timeout)
3764 \begin_layout Standard
3765 Set number of microseconds to block timer for.
3766 After this timeout has expired, on_timer() will be called once.
3769 \begin_layout Subsection
3770 bus_address: Look up address in system bus.
3773 \begin_layout Itemize
3774 Syntax: none bus_address(number bus_addr)
3777 \begin_layout Standard
3778 Returns virtual address corresponding to specified address on system bus.
3781 \begin_layout Subsection
3782 loopwrapper: Convert loop into callable function
3785 \begin_layout Itemize
3786 Syntax: function loopwrapper(function fun, ...)
3789 \begin_layout Standard
3790 Calls function <fun> with function and specified arguments.
3791 The function passed suspends execution until the function returned is called.
3792 Handy for linear flow control among multiple invocations of a hook.
3796 \begin_layout LyX-Code
3797 on_paint = loopwrapper(function(wait)
3801 \begin_layout LyX-Code
3806 \begin_layout LyX-Code
3808 \begin_inset Quotes eld
3812 \begin_inset Quotes erd
3818 \begin_layout LyX-Code
3823 \begin_layout LyX-Code
3828 \begin_layout LyX-Code
3832 \begin_layout Subsection
3833 list_bindings: List keybindings
3836 \begin_layout Itemize
3837 Syntax: table list_bindings([string cmd])
3840 \begin_layout Standard
3841 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
3842 If <cmd> is specified, the table is limited to that command.
3843 Also searches for controller keys.
3846 \begin_layout Subsection
3847 get_alias: Get expansion of alias
3850 \begin_layout Itemize
3851 Syntax: string get_alias(string aname)
3854 \begin_layout Standard
3855 Get expansion of given alias <aname>.
3858 \begin_layout Subsection
3859 set_alias: Set expansion of alias
3862 \begin_layout Itemize
3863 Syntax: none set_alias(string aname, string value)
3866 \begin_layout Standard
3867 Set expansion of given alias.
3870 \begin_layout Subsection
3871 create_ibind: Create invese binding
3874 \begin_layout Itemize
3875 Syntax: INVERSEBIND create_ibind(string name, string cmd)
3878 \begin_layout Standard
3879 Return object representing inverse binding with specified name <name> and
3880 specified command <cmd>.
3883 \begin_layout Itemize
3884 Note: To create press/release commands, use aliases +foo and -foo .
3887 \begin_layout Itemize
3888 Note: Keep the returned object around.
3891 \begin_layout Subsection
3892 create_command: Create a command
3895 \begin_layout Itemize
3896 Syntax: COMMANDBIND create_commmand(string name, function a)
3899 \begin_layout Itemize
3900 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
3903 \begin_layout Standard
3904 Return object representing a command (pair).
3907 \begin_layout Itemize
3908 If only one function is specied, the command is level-sensitive, <a> is
3912 \begin_layout Itemize
3913 If <b> is function, the function is edge-sensitive, <a> is positive edge
3914 callback and <b> is negative edge callback.
3917 \begin_layout Itemize
3918 All callbacks get single argument: The parameters passed.
3921 \begin_layout Itemize
3922 Keep the returned object around.
3925 \begin_layout Subsection
3926 loadfile: Load Lua script
3929 \begin_layout Itemize
3930 Syntax: function loadfile(string filename[, string base])
3933 \begin_layout Standard
3934 Load lua script from <filename>, resolved relative to <base> (if empty,
3938 \begin_layout Subsection
3939 dofile: Execute Lua script
3942 \begin_layout Itemize
3943 Syntax: function dofile(string filename[, string base])
3946 \begin_layout Standard
3947 Execute lua script from <filename>, resolved relative to <base> (if empty,
3948 current directory) and return all return values.
3951 \begin_layout Subsection
3952 resolve_filename: Resolve name of file relative to another
3955 \begin_layout Itemize
3956 Syntax: string resolve_file(string filename, string base)
3959 \begin_layout Standard
3960 Resolve name of file <filename> relative to <base> and return the result.
3963 \begin_layout Subsection
3964 render_queue_function: Return paint function for render queue
3967 \begin_layout Itemize
3968 Syntax: function render_queue_function(RENDERQUEUE rq)
3971 \begin_layout Standard
3972 Return function that renders render queue <rq>.
3975 \begin_layout Itemize
3976 Handy for paint callback if one is using render queues updated in other
3981 \begin_layout LyX-Code
3982 handle = callback.paint:register(render_queue_function(my_rq));
3985 \begin_layout Subsection
3986 identify_class: Identify class of object
3989 \begin_layout Itemize
3990 Syntax: string identify_class(userdata object)
3993 \begin_layout Standard
3994 Identifies the class of userdata <object>, if possible.
3995 If no identification is possible, returns
3996 \begin_inset Quotes eld
4000 \begin_inset Quotes erd
4006 \begin_layout Subsection
4007 lookup_class: Lookup class by name
4010 \begin_layout Itemize
4011 Syntax: classobj lookup_class(string name)
4014 \begin_layout Standard
4015 Looks up class corresponding to <name>, if possible.
4016 If not found, returns nil.
4017 The classobj has following fields:
4020 \begin_layout Itemize
4021 _static_methods: Return static method names
4024 \begin_layout Itemize
4025 _class_methods: Return class method names
4028 \begin_layout Itemize
4029 <static-function-name>: The specified static function.
4032 \begin_layout Subsection
4033 all_classes: Get list of all classes
4036 \begin_layout Itemize
4041 \begin_layout Standard
4042 Get names of all classes available.
4045 \begin_layout Subsection
4049 \begin_layout Subsection
4053 \begin_layout Standard
4057 \begin_layout Subsection
4058 filereader: Class FILEREADER
4061 \begin_layout Standard
4062 See class FILEREADER.
4065 \begin_layout Standard
4066 \begin_inset Newpage pagebreak
4072 \begin_layout Section
4076 \begin_layout Standard
4077 Bitwise logical functions and related.
4080 \begin_layout Subsection
4081 bit.none/bit.bnot: Bitwise none or NOT function
4084 \begin_layout Itemize
4085 Syntax: number bit.none(number...)
4088 \begin_layout Itemize
4089 Syntax: number bit.bnot(number...)
4092 \begin_layout Standard
4093 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4097 \begin_layout Subsection
4098 bit.any/bit.bor: Bitwise any or OR function
4101 \begin_layout Itemize
4102 Syntax: number bit.any(number...)
4105 \begin_layout Itemize
4106 Syntax: number bit.bor(number...)
4109 \begin_layout Standard
4110 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4113 \begin_layout Subsection
4114 bit.all/bit.band: Bitwise all or AND function
4117 \begin_layout Itemize
4118 Syntax: number bit.all(number...)
4121 \begin_layout Itemize
4122 Syntax: number bit.band(number...)
4125 \begin_layout Standard
4126 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4130 \begin_layout Subsection
4131 bit.parity/bit.bxor: Bitwise parity or XOR function
4134 \begin_layout Itemize
4135 Syntax: number bit.parity(number...)
4138 \begin_layout Itemize
4139 Syntax: number bit.bxor(number...)
4142 \begin_layout Standard
4143 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4147 \begin_layout Subsection
4148 bit.lrotate: Rotate a number left
4151 \begin_layout Itemize
4152 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4155 \begin_layout Standard
4156 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4160 \begin_layout Subsection
4161 bit.rrotate: Rotate a number right
4164 \begin_layout Itemize
4165 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4168 \begin_layout Standard
4169 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4173 \begin_layout Subsection
4174 bit.lshift: Shift a number left
4177 \begin_layout Itemize
4178 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4181 \begin_layout Standard
4182 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4184 The new bits are filled with zeroes.
4187 \begin_layout Subsection
4188 bit.lrshift: Shift a number right (logical)
4191 \begin_layout Itemize
4192 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4195 \begin_layout Standard
4196 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4198 The new bits are filled with zeroes.
4201 \begin_layout Subsection
4202 bit.arshift: Shift a number right (arithmetic)
4205 \begin_layout Itemize
4206 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4209 \begin_layout Standard
4210 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4212 The new bits are shifted in with copy of the high bit.
4215 \begin_layout Subsection
4216 bit.extract: Extract/shuffle bits from number
4219 \begin_layout Itemize
4220 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4223 \begin_layout Standard
4224 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4227 \begin_layout Itemize
4228 Note: Bit numbers up to 51 should work reliably (then things start falling
4229 apart due to double precision issues).
4232 \begin_layout Itemize
4233 Note: There are two special bit positions, true and false, standing for
4234 always set bit and always clear bit.
4237 \begin_layout Subsection
4238 bit.value: Construct number with specified bits set
4241 \begin_layout Itemize
4242 Syntax: number bit.value([number bit1[, number bit2,...]])
4245 \begin_layout Standard
4246 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4247 <bit2> places and so on.
4248 As special value, nil argument is no-op.
4251 \begin_layout Subsection
4252 bit.test: Test if bit is set
4255 \begin_layout Itemize
4256 Syntax: boolean bit.test(number a, number bit)
4259 \begin_layout Standard
4260 Tests if bit <bit> is set in <a>.
4261 If it is set, returns true, otherwise false.
4264 \begin_layout Subsection
4265 bit.testn: Test if bit is clear
4268 \begin_layout Itemize
4269 Syntax: boolean bit.testn(number a, number bit)
4272 \begin_layout Standard
4273 Tests if bit <bit> is set in <a>.
4274 If it is clear, returns true, otherwise false.
4277 \begin_layout Subsection
4278 bit.test_any: Test if any bit is set
4281 \begin_layout Itemize
4282 Syntax: boolean bit.test_any(number a, number b)
4285 \begin_layout Standard
4286 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4289 \begin_layout Subsection
4290 bit.test_all: Test if all bits are set
4293 \begin_layout Itemize
4294 Syntax: boolean bit.test_all(number a, number b)
4297 \begin_layout Standard
4298 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4301 \begin_layout Subsection
4302 bit.popcount: Population count
4305 \begin_layout Itemize
4306 Syntax: number bit.popcount(number a)
4309 \begin_layout Standard
4310 Returns number of set bits in <a>.
4313 \begin_layout Subsection
4314 bit.clshift: Chained left shift
4317 \begin_layout Itemize
4318 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4322 \begin_layout Standard
4323 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4324 numbers to be of specified number of bits <bits> (default 48).
4327 \begin_layout Subsection
4328 bit.crshift: Chained right shift
4331 \begin_layout Itemize
4332 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4336 \begin_layout Standard
4337 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4338 assuming numbers to be of specified number of bits <bits> (default 48).
4341 \begin_layout Subsection
4342 bit.flagdecode: Decode bitfield into flags
4345 \begin_layout Itemize
4346 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4350 \begin_layout Standard
4351 Return string of length bits where ith character is ith character of on
4352 if bit i is on, otherwise ith character of off.
4353 Out of range reads give last character.
4356 \begin_layout Itemize
4357 Note: <on> defaults to '*' if empty.
4360 \begin_layout Itemize
4361 Note: <off> defaults to '-' if empty.
4364 \begin_layout Subsection
4365 bit.rflagdecode: Decode bitfield into flags
4368 \begin_layout Itemize
4369 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4373 \begin_layout Standard
4374 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4378 \begin_layout Subsection
4379 bit.swap{,s}{,h,d,q}word: Swap word endian
4382 \begin_layout Itemize
4383 Syntax: number bit.swapword(number n)
4386 \begin_layout Itemize
4387 Syntax: number bit.swaphword(number n)
4390 \begin_layout Itemize
4391 Syntax: number bit.swapdword(number n)
4394 \begin_layout Itemize
4395 Syntax: number bit.swapqword(number n)
4398 \begin_layout Itemize
4399 Syntax: number bit.swapsword(number n)
4402 \begin_layout Itemize
4403 Syntax: number bit.swapshword(number n)
4406 \begin_layout Itemize
4407 Syntax: number bit.swapsdword(number n)
4410 \begin_layout Itemize
4411 Syntax: number bit.swapsqword(number n)
4414 \begin_layout Standard
4415 Swap endianess of (un)signed integer <n>.
4418 \begin_layout Subsection
4419 bit.compose: Compose multi-byte number
4422 \begin_layout Itemize
4423 Syntax: number bit.compose(number n...)
4426 \begin_layout Standard
4428 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4434 \begin_layout Subsection
4435 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4438 \begin_layout Itemize
4439 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4442 \begin_layout Itemize
4443 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4446 \begin_layout Standard
4447 Load little (*le) or big (*be) endian binary number from position <pos>
4449 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4453 \begin_layout Subsection
4454 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4457 \begin_layout Itemize
4458 Syntax: string bit.binary_st_<type>le(number x);
4461 \begin_layout Itemize
4462 Syntax: string bit.binary_st_<type>be(number x);
4465 \begin_layout Standard
4466 Store specified number <x> as binary in string and return the result.
4467 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4471 \begin_layout Subsection
4472 bit.quotent: Integer quotent
4475 \begin_layout Itemize
4476 Syntax: number bit.quotent(number a, number b)
4479 \begin_layout Standard
4480 Calculate quotent a/b.
4483 \begin_layout Subsection
4484 bit.multidiv: Divide and split among multiple divisiors
4487 \begin_layout Itemize
4489 bit.multidiv(number v, number q...)
4492 \begin_layout Standard
4493 Does the following steps:
4496 \begin_layout Enumerate
4500 \begin_layout Enumerate
4505 \begin_layout Enumerate
4506 Calculate quotent(v'/q) and add that to numbers returned.
4509 \begin_layout Enumerate
4510 v' <- remainder(v'/q)
4514 \begin_layout Enumerate
4515 Add v' to numbers returned.
4518 \begin_layout Standard
4519 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
4521 <v> may be floating point, <q>s are integers.
4524 \begin_layout Itemize
4526 bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
4529 \begin_layout Itemize
4531 bit.multidiv(a, b) calculates quotent and remainder of a/b.
4534 \begin_layout Subsection
4535 bit.mul32: 32-bit multiply
4538 \begin_layout Itemize
4539 Syntax: number, number bit.mul32(number a, number b)
4542 \begin_layout Standard
4543 Multiply 32-bit numbers <a> and <b>.
4544 The first return value is low 32 bits of result, the second is high 32
4548 \begin_layout Standard
4549 \begin_inset Newpage pagebreak
4555 \begin_layout Section
4559 \begin_layout Subsection
4560 classes.<foo>: The classobj for class <foo>
4563 \begin_layout Itemize
4564 Syntax: classes.<foo>
4567 \begin_layout Standard
4568 The classobj for class <foo>.
4571 \begin_layout Subsection
4572 classes.<foo>._static_methods: Enumerate static methods
4575 \begin_layout Itemize
4577 classes.<foo>._static_methods()
4580 \begin_layout Standard
4581 Returns all static methods of <foo> as strings.
4584 \begin_layout Subsection
4585 classes.<foo>._class_methods: Enumerate static methods
4588 \begin_layout Itemize
4590 classes.<foo>._class_methods()
4593 \begin_layout Standard
4594 Returns all class methods of <foo> as strings.
4597 \begin_layout Subsection
4598 classes.<foo>.<bar>: Static method
4601 \begin_layout Itemize
4602 Syntax: variable classes.<foo>.<bar>(variable...)
4605 \begin_layout Standard
4606 Invokes static method <bar> of class <foo>.
4609 \begin_layout Section
4613 \begin_layout Subsection
4614 gui.resolution: Get current resolution
4617 \begin_layout Itemize
4618 Syntax: (number, number) gui.resolution()
4621 \begin_layout Standard
4622 Returns 2-tuple (hresolution, vresolution).
4625 \begin_layout Subsection
4626 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
4629 \begin_layout Itemize
4630 Syntax: number gui.left_gap(number gap)
4633 \begin_layout Itemize
4634 Syntax: number gui.right_gap(number gap)
4637 \begin_layout Itemize
4638 Syntax: number gui.top_gap(number gap)
4641 \begin_layout Itemize
4642 Syntax: number gui.bottom_gap(number gap)
4645 \begin_layout Standard
4646 Set the specified edge gap to specified value <gap> (max gap is 8191).
4647 If successful, old gap is returned.
4650 \begin_layout Subsection
4651 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
4655 \begin_layout Itemize
4656 Syntax: number gui.delta_left_gap(number dgap)
4659 \begin_layout Itemize
4660 Syntax: number gui.delta_right_gap(number dgap)
4663 \begin_layout Itemize
4664 Syntax: number gui.delta_top_gap(number dgap)
4667 \begin_layout Itemize
4668 Syntax: number gui.delta_bottom_gap(number dgap)
4671 \begin_layout Standard
4672 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
4673 and return the old gap (returns nothing on error).
4676 \begin_layout Subsection
4677 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
4680 \begin_layout Itemize
4681 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
4685 \begin_layout Itemize
4686 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
4690 \begin_layout Itemize
4691 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
4695 \begin_layout Itemize
4696 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
4700 \begin_layout Standard
4701 Draw specified text on the GUI (each character cell is 8 or 16 wide and
4706 \begin_layout Itemize
4707 x: X-coordinate to start the drawing from (and x-coordinate at begining
4711 \begin_layout Itemize
4712 y: Y-coordinate to start the drawing from.
4715 \begin_layout Itemize
4716 text: The text to draw.
4719 \begin_layout Itemize
4720 fgc: Text color (default is 0xFFFFFF (white))
4723 \begin_layout Itemize
4724 bgc: Background color (default is -1 (transparent))
4727 \begin_layout Standard
4728 Note: The H variants draw at double width and V variants draw at double
4732 \begin_layout Subsection
4733 gui.rectangle: Draw a rectangle
4736 \begin_layout Itemize
4737 Syntax: none gui.rectangle(number x, number y, number width, number height[,
4738 number thickness[, number outline[, number fill]]])
4741 \begin_layout Standard
4742 Draw rectangle on the GUI.
4746 \begin_layout Itemize
4747 x: X-coordinate of left edge.
4750 \begin_layout Itemize
4751 y: Y-coordinate of upper edge.
4754 \begin_layout Itemize
4755 width: Width of rectangle.
4758 \begin_layout Itemize
4759 height: Height of rectangle.
4762 \begin_layout Itemize
4763 thickness: Thickness of outline (default is 1).
4766 \begin_layout Itemize
4767 outline: Color of outline (default is 0xFFFFFF (white))
4770 \begin_layout Itemize
4771 fill: Color of fill (default is -1 (transparent))
4774 \begin_layout Subsection
4775 gui.solidrectangle: Draw a solid rectangle
4778 \begin_layout Itemize
4779 Syntax: none gui.rectangle(number x, number y, number width, number height[,
4783 \begin_layout Standard
4784 Draw solid rectangle on the GUI.
4788 \begin_layout Itemize
4789 x: X-coordinate of left edge.
4792 \begin_layout Itemize
4793 y: Y-coordinate of upper edge.
4796 \begin_layout Itemize
4797 width: Width of rectangle.
4800 \begin_layout Itemize
4801 height: Height of rectangle.
4804 \begin_layout Itemize
4805 color: Color of rectangle (default is 0xFFFFFF (white))
4808 \begin_layout Subsection
4809 gui.box: Draw a 3D-effect box
4812 \begin_layout Itemize
4813 Syntax: none gui.box(number x, number y, number width, number height[, number
4814 thickness[, number outline1[,number outline2[, number fill]]]])
4817 \begin_layout Standard
4818 Draw rectangle with 3D effect on the GUI.
4822 \begin_layout Itemize
4823 x: X-coordinate of left edge.
4826 \begin_layout Itemize
4827 y: Y-coordinate of upper edge.
4830 \begin_layout Itemize
4831 width: Width of rectangle.
4834 \begin_layout Itemize
4835 height: Height of rectangle.
4838 \begin_layout Itemize
4839 thickness: Thickness of outline (default is 1).
4842 \begin_layout Itemize
4843 outline1: First color of outline (default is 0xFFFFFF (white))
4846 \begin_layout Itemize
4847 outline2: First color of outline (default is 0x808080 (dark gray))
4850 \begin_layout Itemize
4851 fill: Color of fill (default is 0xC0C0C0 (light grayy))
4854 \begin_layout Subsection
4855 gui.pixel: Draw a single pixel
4858 \begin_layout Itemize
4859 Syntax: none gui.pixel(number x, number y[, number color])
4862 \begin_layout Standard
4863 Draw one pixel on the GUI.
4867 \begin_layout Itemize
4868 x: X-coordinate of the pixel
4871 \begin_layout Itemize
4872 y: Y-coordinate of the pixel
4875 \begin_layout Itemize
4876 color: Color of the pixel (default is 0xFFFFFF (white))
4879 \begin_layout Subsection
4880 gui.crosshair: Draw a crosshair
4883 \begin_layout Itemize
4884 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
4887 \begin_layout Standard
4892 \begin_layout Itemize
4893 x: X-coordinate of the crosshair
4896 \begin_layout Itemize
4897 y: Y-coordinate of the crosshair
4900 \begin_layout Itemize
4901 length: Length of the crosshair lines (default 10).
4904 \begin_layout Itemize
4905 color: Color of the crosshair (default is 0xFFFFFF (white))
4908 \begin_layout Subsection
4909 gui.line: Draw a line
4912 \begin_layout Itemize
4913 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
4917 \begin_layout Standard
4922 \begin_layout Itemize
4923 x1: X-coordinate of one end.
4926 \begin_layout Itemize
4927 y1: Y-coordinate of one end.
4930 \begin_layout Itemize
4931 x2: X-coordinate of the other end.
4934 \begin_layout Itemize
4935 y2: Y-coordinate of the other end.
4938 \begin_layout Itemize
4939 color: Color of the line (default is 0xFFFFFF (white)).
4942 \begin_layout Subsection
4943 gui.circle: Draw a (filled) circle
4946 \begin_layout Itemize
4947 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
4948 border[, number fil]]])
4951 \begin_layout Standard
4956 \begin_layout Itemize
4957 x: X-coordinate of the center
4960 \begin_layout Itemize
4961 y: Y-coordinate of the center
4964 \begin_layout Itemize
4965 r: The radius of the circle
4968 \begin_layout Itemize
4969 thick: Border thickness
4972 \begin_layout Itemize
4973 border: Border color (default is 0xFFFFFF (white))
4976 \begin_layout Itemize
4977 fill: Fill color (default is -1 (transparent)).
4980 \begin_layout Subsection
4981 gui.repaint: Arrange a repaint
4984 \begin_layout Itemize
4985 Syntax: none gui.repaint()
4988 \begin_layout Standard
4989 Request on_repaint() to happen as soon as possible.
4992 \begin_layout Subsection
4993 gui.subframe_update: Enable/Disable subframe updates
4996 \begin_layout Itemize
4997 Syntax: none gui.subframe_update(boolean on)
5000 \begin_layout Standard
5001 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5002 or not happen (<on>=false).
5005 \begin_layout Subsection
5006 gui.screenshot: Write a screenshot
5009 \begin_layout Itemize
5010 Syntax: none gui.screenshot(string filename)
5013 \begin_layout Standard
5014 Write PNG screenshot of the current frame (no drawings) to specified file
5018 \begin_layout Subsection
5019 gui.screenshot_bitmap: Write a screenshot to bitmap
5022 \begin_layout Itemize
5023 Syntax: DBITMAP gui.screenshot_bitmap()
5026 \begin_layout Standard
5027 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5031 \begin_layout Subsection
5032 gui.color: Compose a color.
5035 \begin_layout Itemize
5036 Syntax: number gui.color(number r, number g, number b[, number a])
5039 \begin_layout Itemize
5040 Syntax: number gui.color(string c)
5043 \begin_layout Standard
5044 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5045 , each component in scale 0-255.
5046 If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5048 The default alpha is 256.
5051 \begin_layout Standard
5052 The form taking a string returns color corresponding color name.
5055 \begin_layout Subsection
5056 gui.status: Set status variable
5059 \begin_layout Itemize
5060 Syntax: none gui.status(string name, string value)
5063 \begin_layout Standard
5065 \begin_inset Quotes eld
5069 \begin_inset Quotes erd
5072 to <value> in status area.
5075 \begin_layout Subsection
5076 gui.rainbow: Rainbow color calculation
5079 \begin_layout Itemize
5080 Syntax: number gui.rainbow(number step, number steps[, number color])
5083 \begin_layout Standard
5084 Perform hue rotation of color <color> (default bright red), by <step> steps.
5085 The number of steps per full rotation is given by absolute value of <steps>.
5088 \begin_layout Standard
5089 If <step> is negative, the rotation will be counterclockwise.
5092 \begin_layout Subsection
5093 gui.kill_frame: Kill video frame and associated sound
5096 \begin_layout Itemize
5097 Syntax: none gui.kill_frame()
5100 \begin_layout Standard
5101 Kills the currently dumped video frame + the associated sound.
5102 Only valid in on_video callback.
5105 \begin_layout Subsection
5106 gui.set_video_scale: Set video frame scale
5109 \begin_layout Itemize
5110 Syntax: none gui.set_video_scale(number h, number v)
5113 \begin_layout Standard
5114 Sets the scale factors of current frame to <h>x<v>.
5115 Only valid in on_video callback.
5118 \begin_layout Subsection
5119 gui.arrow: Draw an arrow
5122 \begin_layout Itemize
5123 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5124 number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5128 \begin_layout Standard
5129 Draws an arrow using color <color>.
5130 The tip of arrow is at (<x>, <y>).
5134 \begin_layout Enumerate
5135 <length>: The length of arrow tail.
5138 \begin_layout Enumerate
5139 <hwidth>: The width of arrow head.
5143 \begin_layout Enumerate
5144 <direction>: Direction of arrow.
5145 0 is to right, +1 rotates 45 degrees counterclockwise.
5148 \begin_layout Enumerate
5149 <fill>: If true, fill the arrow head.
5153 \begin_layout Enumerate
5154 <twidth>: Tail width.
5159 \begin_layout Enumerate
5160 <hthick>: Head thickness (only used if <fill> is false).
5161 Default is <twidth>.
5164 \begin_layout Subsection
5165 gui.tiled_bitmap: Class TILEMAP
5168 \begin_layout Standard
5172 \begin_layout Subsection
5173 gui.palette: Class PALETTE
5176 \begin_layout Standard
5180 \begin_layout Subsection
5181 gui.bitmap: Class BITMAP
5184 \begin_layout Standard
5188 \begin_layout Subsection
5189 gui.dbitmap: Class DBITMAP
5192 \begin_layout Standard
5196 \begin_layout Subsection
5197 gui.font: Class CUSTOMFONT
5200 \begin_layout Standard
5201 See class CUSTOMFONT.
5204 \begin_layout Subsection
5205 gui.renderctx: Class RENDERCTX
5208 \begin_layout Standard
5209 See class RENDERCTX.
5212 \begin_layout Subsection
5213 gui.image: Class IMAGELOADER
5216 \begin_layout Standard
5217 See class IMAGELOADER.
5220 \begin_layout Standard
5221 \begin_inset Newpage pagebreak
5227 \begin_layout Section
5231 \begin_layout Standard
5233 Functions manipulating input are only available in on_input callback.
5236 \begin_layout Subsection
5237 input.get: Read controller button/axis (deprecated)
5240 \begin_layout Itemize
5241 Syntax: number input.get(number controller, number index)
5244 \begin_layout Standard
5245 Read the specified index <index> (zero-based) from specified controller
5246 <controller> (zero-based).
5250 \begin_layout Subsection
5251 input.set: Write controller button/axis (deprecated)
5254 \begin_layout Itemize
5255 Syntax: none input.set(number controller, number index, number value)
5258 \begin_layout Standard
5259 Write the specified index <index> (zero-based) from specified controller
5260 <controller> (zero-based), storing value <value>.
5263 \begin_layout Subsection
5264 input.get2: Read controller button/axis
5267 \begin_layout Itemize
5268 Syntax: number input.get2(number port, number controller, number index)
5271 \begin_layout Standard
5272 Read the specified input tuple.
5273 Port 0 is system port.
5276 \begin_layout Subsection
5277 input.set2: Write controller button/axis
5280 \begin_layout Itemize
5281 Syntax: input.set2(number port, number controller, number index, number value)
5284 \begin_layout Standard
5285 Write the specified input tuple.
5286 Port 0 is system port.
5289 \begin_layout Subsection
5290 input.lcid_to_pcid2: Look up logical controller
5293 \begin_layout Itemize
5294 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5297 \begin_layout Standard
5298 Look up physical pcid pair (port, controller) corresponding to specified
5299 logical controller (1-based).
5300 Returns nothing if controller does not exist.
5303 \begin_layout Subsection
5304 input.port_type: Look up port type
5307 \begin_layout Itemize
5308 Syntax: string input.port_type(number port)
5311 \begin_layout Standard
5312 Return type of specified port.
5315 \begin_layout Subsection
5316 input.controller_info: Get information about controller
5319 \begin_layout Itemize
5320 Syntax: table input.controller_info(number port, number controller)
5323 \begin_layout Standard
5324 Get controller info for specified controller.
5325 If controller does not exist, returns nil.
5326 Otherwise returns a table with following fields:
5329 \begin_layout Itemize
5330 type (string): Type of the controller.
5333 \begin_layout Itemize
5334 class (string): Class of the controller.
5337 \begin_layout Itemize
5338 classnum (number): Number of the controller within its class (1-based)
5341 \begin_layout Itemize
5342 lcid (number): Logical controller number of the controller.
5345 \begin_layout Itemize
5346 button_count (number): Number of buttons on controller
5349 \begin_layout Itemize
5350 buttons (array): Array of following info about each button:
5354 \begin_layout Itemize
5355 type (string): Type of button.
5357 \begin_inset Quotes eld
5361 \begin_inset Quotes erd
5365 \begin_inset Quotes eld
5369 \begin_inset Quotes erd
5373 \begin_inset Quotes eld
5377 \begin_inset Quotes erd
5381 \begin_inset Quotes eld
5385 \begin_inset Quotes erd
5391 \begin_layout Itemize
5392 name (string): Name of button.
5395 \begin_layout Itemize
5396 symbol (string): Symbol of button.
5397 Only present for type
5398 \begin_inset Quotes eld
5402 \begin_inset Quotes erd
5408 \begin_layout Itemize
5409 hidden (boolean): True if hidden button.
5414 \begin_layout Subsection
5415 input.veto_button: Veto a button press
5418 \begin_layout Itemize
5419 Syntax: none input.veto_button()
5422 \begin_layout Standard
5423 Signals that the button event should be vetoed.
5424 Only valid in on_button callback.
5427 \begin_layout Subsection
5428 input.geta: Get all buttons for controller (deprecated)
5431 \begin_layout Itemize
5432 Syntax: (number, number...) input.geta(number controller)
5435 \begin_layout Standard
5436 Get input state for entiere controller.
5437 Returns n return values.
5440 \begin_layout Itemize
5441 1st return value: Bitmask: bit i is set if i:th index is nonzero
5444 \begin_layout Itemize
5445 2nd- return value: value of i:th index.
5448 \begin_layout Subsection
5449 input.seta: Set all buttons for controller (deprecated)
5452 \begin_layout Itemize
5453 Syntax: none input.seta(number controller, number bitmask, number args...)
5456 \begin_layout Standard
5457 Set state for entiere controller.
5458 args is up to N values for indices (overriding values in bitmask if specified).
5461 \begin_layout Subsection
5462 input.controllertype: Get controller type (deprecated)
5465 \begin_layout Itemize
5466 syntax: string input.controllertype(number controller)
5469 \begin_layout Standard
5470 Get the type of controller as string.
5473 \begin_layout Subsection
5474 input.reset: Execute (delayed) reset
5477 \begin_layout Itemize
5478 Syntax: none input.reset([number cycles])
5481 \begin_layout Standard
5483 If <cycles> is greater than zero, do delayed reset.
5484 0 (or no value) causes immediate reset.
5487 \begin_layout Itemize
5488 Note: Only available with subframe flag false.
5491 \begin_layout Subsection
5492 input.raw: Return raw input data
5495 \begin_layout Itemize
5496 Syntax: table input.raw()
5499 \begin_layout Standard
5500 Returns table of tables of all available keys and axes.
5501 The first table is indexed by key name (platform-dependent!), and the inner
5502 table has the following fields:
5505 \begin_layout Itemize
5506 value: Last reported value for control
5510 \begin_layout Itemize
5511 For keys: 1 for pressed, 0 for released.
5514 \begin_layout Itemize
5515 For axes: -32767...32767.
5518 \begin_layout Itemize
5519 For presure-sensitive buttons: 0...32767.
5522 \begin_layout Itemize
5523 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
5526 \begin_layout Itemize
5527 For mouse: Coordinates relative to game area.
5531 \begin_layout Itemize
5532 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
5535 \begin_layout Subsection
5536 input.keyhook: Hook a key
5539 \begin_layout Itemize
5540 Syntax: none input.keyhook(string key, boolean state)
5543 \begin_layout Standard
5544 Requests that keyhook events to be sent for key <key> (<state>=true) or
5545 not sent (<state>=false).
5548 \begin_layout Subsection
5549 input.joyget: Get controls for controller
5552 \begin_layout Itemize
5553 Syntax: table input.joyget(number logical)
5556 \begin_layout Standard
5557 Returns table for current controls for specified logical controller <logical>.
5558 The names of fields vary by controller type.
5561 \begin_layout Itemize
5562 The buttons have the same name as those are referred to in other contexts
5566 \begin_layout Itemize
5567 The analog axes are usually
5568 \begin_inset Quotes eld
5572 \begin_inset Quotes erd
5576 \begin_inset Quotes eld
5580 \begin_inset Quotes erd
5586 \begin_layout Itemize
5587 Each field is numeric or boolean depending on axis/button.
5590 \begin_layout Subsection
5591 input.joyset: Set controls for controller
5594 \begin_layout Itemize
5595 Syntax: none input.joyset(number controller, table controls)
5598 \begin_layout Standard
5599 Set the the state of specified controller to values specified in specified
5603 \begin_layout Itemize
5604 Each field can be boolean or number.
5607 \begin_layout Itemize
5608 Also, buttons allow strings, which cause value to be inverted.
5611 \begin_layout Subsection
5612 input.lcid_to_pcid: Look up logical controller (deprecated)
5615 \begin_layout Itemize
5616 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
5619 \begin_layout Standard
5620 Returns the legacy pcid for controller (or false if there isn't one), followed
5622 Returns nothing if controller does not exist.
5625 \begin_layout Standard
5626 \begin_inset Newpage pagebreak
5632 \begin_layout Section
5636 \begin_layout Standard
5637 Various keybinding-related functions
5640 \begin_layout Subsection
5641 keyboard.bind: Bind a key
5644 \begin_layout Itemize
5645 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
5648 \begin_layout Standard
5649 Bind specified key with specified modifers to specified command.
5652 \begin_layout Subsection
5653 keyboard.unbind: Unbind a key
5656 \begin_layout Itemize
5657 Syntax: none keyboard.unbind(string mod, string mask, string key)
5660 \begin_layout Standard
5661 Unbind specified key with specified modifers.
5664 \begin_layout Subsection
5665 keyboard.alias: Set alias expansion
5668 \begin_layout Itemize
5669 Syntax: none keyboard.alias(string alias, string expansion)
5672 \begin_layout Standard
5673 Set expansion of given command.
5676 \begin_layout Standard
5677 \begin_inset Newpage pagebreak
5683 \begin_layout Section
5687 \begin_layout Standard
5691 \begin_layout Subsection
5692 subtitle.byindex: Look up start and length of subtitle by index
5695 \begin_layout Itemize
5696 Syntax: (number, number) subtitle.byindex(number i)
5699 \begin_layout Standard
5700 Read the frame and length of ith subtitle.
5701 Returns nothing if not present.
5704 \begin_layout Subsection
5705 subtitle.set: Write a subtitle
5708 \begin_layout Itemize
5709 Syntax: none subtitle.set(number f, number l, string txt)
5712 \begin_layout Standard
5713 Set the text of subtitle.
5716 \begin_layout Subsection
5717 subtitle.get: Read a subtitle
5720 \begin_layout Itemize
5721 Syntax: string subtitle.get(number f, number l)
5724 \begin_layout Standard
5725 Get the text of subtitle.
5728 \begin_layout Subsection
5729 subtitle.delete: Delete a subtitle
5732 \begin_layout Itemize
5733 Syntax: none subtitle.delete(number f, number l)
5736 \begin_layout Standard
5737 Delete specified subtitle.
5740 \begin_layout Standard
5741 \begin_inset Newpage pagebreak
5747 \begin_layout Section
5751 \begin_layout Standard
5752 Host memory handling (extra memory saved to savestates).
5753 Host memory starts empty.
5756 \begin_layout Itemize
5757 Reads out of range return false.
5760 \begin_layout Itemize
5761 Writes out of range extend the memory.
5764 \begin_layout Subsection
5765 hostmemory.read: Read byte from host memory
5768 \begin_layout Itemize
5769 Syntax: number hostmemory.read(number address)
5772 \begin_layout Standard
5773 Reads byte from hostmemory slot address <address>.
5776 \begin_layout Subsection
5777 hostmemory.write: Write byte to host memory
5780 \begin_layout Itemize
5781 Syntax: none hostmemory.write(number address, number value)
5784 \begin_layout Standard
5785 Writes hostmemory slot with value <value> 0-255.
5788 \begin_layout Subsection
5789 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
5792 \begin_layout Itemize
5793 Syntax: number hostmemory.readbyte(number address)
5796 \begin_layout Itemize
5797 Syntax: number hostmemory.readsbyte(number address)
5800 \begin_layout Itemize
5801 Syntax: number hostmemory.readword(number address)
5804 \begin_layout Itemize
5805 Syntax: number hostmemory.readsword(number address)
5808 \begin_layout Itemize
5809 Syntax: number hostmemory.readhword(number address)
5812 \begin_layout Itemize
5813 Syntax: number hostmemory.readshword(number address)
5816 \begin_layout Itemize
5817 Syntax: number hostmemory.readdword(number address)
5820 \begin_layout Itemize
5821 Syntax: number hostmemory.readsdword(number address)
5824 \begin_layout Itemize
5825 Syntax: number hostmemory.readqword(number address)
5828 \begin_layout Itemize
5829 Syntax: number hostmemory.readsqword(number address)
5832 \begin_layout Standard
5833 Read elements (big-endian) from given address <address>.
5836 \begin_layout Itemize
5840 \begin_layout Itemize
5844 \begin_layout Itemize
5848 \begin_layout Itemize
5852 \begin_layout Itemize
5853 qword is 8 elements.
5856 \begin_layout Itemize
5857 The 's' variants do signed read.
5860 \begin_layout Subsection
5861 hostmemory.read{float,double}: Read from host memory
5864 \begin_layout Itemize
5865 syntax: number hostmemory.readfloat(number address)
5868 \begin_layout Itemize
5869 Syntax: number hostmemory.readdouble(number address)
5872 \begin_layout Standard
5873 Read elements (big-endian) floating-pont from given address <address>.
5876 \begin_layout Subsection
5877 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
5880 \begin_layout Itemize
5881 Syntax: number hostmemory.writebyte(number address, number value)
5884 \begin_layout Itemize
5885 Syntax: number hostmemory.writesbyte(number address, number value)
5888 \begin_layout Itemize
5889 Syntax: number hostmemory.writeword(number address, number value)
5892 \begin_layout Itemize
5893 Syntax: number hostmemory.writesword(number address, number value)
5896 \begin_layout Itemize
5897 Syntax: number hostmemory.writehword(number address, number value)
5900 \begin_layout Itemize
5901 Syntax: number hostmemory.writeshword(number address, number value)
5904 \begin_layout Itemize
5905 Syntax: number hostmemory.writedword(number address, number value)
5908 \begin_layout Itemize
5909 Syntax: number hostmemory.writesdword(number address, number value)
5912 \begin_layout Itemize
5913 Syntax: number hostmemory.writeqword(number address, number value)
5916 \begin_layout Itemize
5917 Syntax: number hostmemory.writesqword(number address, number value)
5920 \begin_layout Standard
5921 Write value <value> to elements (little-endian) starting from given address
5925 \begin_layout Itemize
5929 \begin_layout Itemize
5933 \begin_layout Itemize
5937 \begin_layout Itemize
5941 \begin_layout Itemize
5942 qword is 8 elements.
5945 \begin_layout Itemize
5946 The 's' variants do signed write.
5949 \begin_layout Subsection
5950 hostmemory.write{float,double}: Write to host memory
5953 \begin_layout Itemize
5954 syntax: none hostmemory.readfloat(number address, number value)
5957 \begin_layout Itemize
5958 Syntax: none hostmemory.readdouble(number address, number value)
5961 \begin_layout Standard
5962 Write elements (big-endian) floating-pont to given address <address>, storing
5966 \begin_layout Standard
5967 \begin_inset Newpage pagebreak
5973 \begin_layout Section
5977 \begin_layout Standard
5981 \begin_layout Subsection
5982 movie.currentframe: Get current frame number
5985 \begin_layout Itemize
5986 Syntax: number movie.currentframe()
5989 \begin_layout Standard
5990 Return number of current frame.
5993 \begin_layout Subsection
5994 movie.framecount: Get move frame count
5997 \begin_layout Itemize
5998 Syntax: number movie.framecount()
6001 \begin_layout Standard
6002 Return number of frames in movie.
6005 \begin_layout Subsection
6006 movie.lagcount: Get current lag count
6009 \begin_layout Itemize
6010 Syntax: number movie.lagcount()
6013 \begin_layout Standard
6014 Return number of lag frames recorded so far.
6017 \begin_layout Subsection
6018 movie.readonly: Is in playback mode?
6021 \begin_layout Itemize
6022 Syntax: boolean movie.readonly()
6025 \begin_layout Standard
6026 Return true if in playback mode, false if in recording.
6029 \begin_layout Subsection
6030 movie.rerecords: Movie rerecord count
6033 \begin_layout Itemize
6034 Syntax: number movie.rerecords()
6037 \begin_layout Standard
6038 Returns the current value of rerecord count.
6041 \begin_layout Subsection
6042 movie.set_readwrite: Set recording mode.
6045 \begin_layout Itemize
6046 Syntax: none movie.set_readwrite()
6049 \begin_layout Standard
6050 Set recording mode (does not cause on_readwrite callback).
6053 \begin_layout Subsection
6054 movie.frame_subframes: Count subframes in frame
6057 \begin_layout Itemize
6058 Syntax: number movie.frame_subframes(number frame)
6061 \begin_layout Standard
6062 Count number of subframes in specified frame <frame> (frame numbers are
6063 1-based) and return that.
6066 \begin_layout Subsection
6067 movie.read_subframes: Read subframe data (deprecated)
6070 \begin_layout Itemize
6071 Syntax: table movie.read_subframes(number frame, number subframe)
6074 \begin_layout Standard
6075 Read specifed subframe in specified frame and return data as array.
6078 \begin_layout Subsection
6079 movie.read_rtc: Read current RTC time
6082 \begin_layout Itemize
6083 Syntax: (number, number) movie.read_rtc()
6086 \begin_layout Standard
6087 Returns the current value of the RTC as a pair (second, subsecond).
6090 \begin_layout Subsection
6091 movie.unsafe_rewind: Fast movie rewind to saved state
6094 \begin_layout Itemize
6095 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6098 \begin_layout Standard
6099 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6102 \begin_layout Itemize
6103 If called without argument, causes emulator to start process of setting
6104 unsafe rewind point.
6105 When this has finished, callback on_set_rewind occurs, passing the rewind
6106 state to lua script.
6109 \begin_layout Itemize
6110 If called with argument, causes emulator rewind to passed rewind point as
6112 recording mode is implicitly activated.
6115 \begin_layout Standard
6116 The following warnings apply to unsafe rewinding:
6119 \begin_layout Itemize
6120 There are no safety checks against misuse (that's what
6121 \begin_inset Quotes eld
6125 \begin_inset Quotes erd
6131 \begin_layout Itemize
6132 Only call rewind from timeline rewind point was set from.
6135 \begin_layout Itemize
6136 Only call rewind from after the rewind point was set.
6139 \begin_layout Subsection
6140 movie.to_rewind: Load savestate as rewind point
6143 \begin_layout Itemize
6144 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6147 \begin_layout Standard
6148 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6149 corresponding to it.
6152 \begin_layout Itemize
6153 Note: This operation does not take emulated time.
6156 \begin_layout Subsection
6157 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6160 \begin_layout Itemize
6161 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6164 \begin_layout Itemize
6165 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6168 \begin_layout Standard
6169 Copies specified movie or branch <movie>/current object (if none or nil,
6170 the active movie) as new movie object.
6173 \begin_layout Subsection
6174 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6177 \begin_layout Itemize
6178 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6181 \begin_layout Itemize
6182 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6185 \begin_layout Standard
6186 Get INPUTFRAME object corresponding to specified frame in specified movie
6190 \begin_layout Subsection
6191 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6194 \begin_layout Itemize
6195 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6199 \begin_layout Itemize
6200 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6203 \begin_layout Standard
6204 Set data in specified frame.
6207 \begin_layout Itemize
6208 Note: Past can't be edited in active movie.
6211 \begin_layout Subsection
6212 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6215 \begin_layout Itemize
6216 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6219 \begin_layout Itemize
6220 Syntax: integer INPUTMOVIE::get_size()
6223 \begin_layout Standard
6224 Return number of subframes in specified movie or branch.
6227 \begin_layout Subsection
6228 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6231 \begin_layout Itemize
6232 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6235 \begin_layout Itemize
6236 Syntax: number INPUTMOVIE::count_frames()
6239 \begin_layout Standard
6240 Return number of frames in movie.
6243 \begin_layout Subsection
6244 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6247 \begin_layout Itemize
6248 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6251 \begin_layout Itemize
6252 Syntax: number INPUTMOVIE::find_frame(number frame)
6255 \begin_layout Standard
6256 Returns starting subframe of given frame (frame numbers are 1-based).
6257 Returns -1 if frame number is bad.
6260 \begin_layout Subsection
6261 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6264 \begin_layout Itemize
6265 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6268 \begin_layout Itemize
6269 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6272 \begin_layout Standard
6273 Return blank INPUTFRAME with frame type from specified movie.
6276 \begin_layout Subsection
6277 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6280 \begin_layout Itemize
6281 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6284 \begin_layout Itemize
6285 Syntax: none INPUTMOVIE::append_frames(number frames)
6288 \begin_layout Standard
6289 Append specified number <frames> of frames.
6292 \begin_layout Subsection
6293 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
6296 \begin_layout Itemize
6297 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
6300 \begin_layout Itemize
6301 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
6304 \begin_layout Standard
6305 Append specified frame <frame>.
6306 Past of current movie can't be edited.
6309 \begin_layout Subsection
6310 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
6313 \begin_layout Itemize
6314 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
6317 \begin_layout Itemize
6318 Syntax: none INPUTMOVIE::truncate(number frames)
6321 \begin_layout Standard
6322 Truncate the specified movie to specified number of frames.
6325 \begin_layout Subsection
6326 movie.edit/INPUTMOVIE::edit: Edit a movie
6329 \begin_layout Itemize
6330 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
6331 controller, number control, number/bool value)
6334 \begin_layout Itemize
6335 Syntax: none movie.edit(string branch, number frame, number port, number
6336 controller, number control, number/bool value)
6339 \begin_layout Itemize
6340 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
6341 number control, number/bool value)
6344 \begin_layout Standard
6345 Change specified control in specified frame in specified movie.
6346 Past can't be edited in active movie.
6349 \begin_layout Subsection
6350 movie.copy_frames2: Copy frames between movies
6353 \begin_layout Itemize
6354 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
6355 IE/string srcmov,] number src, number count)
6358 \begin_layout Standard
6359 Copy specified number of frames between two movies.
6360 The copy proceeeds in forward direction.
6363 \begin_layout Subsection
6364 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
6367 \begin_layout Itemize
6368 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
6369 src, number count, bool backwards)
6372 \begin_layout Itemize
6373 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
6377 \begin_layout Standard
6378 Copy specified number of frames from one point in movie to another.
6379 If backwards is true, the copy will be done backwards.
6382 \begin_layout Subsection
6383 movie.serialize/INPUTMOVIE::serialize: Serialize movie
6386 \begin_layout Itemize
6387 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
6391 \begin_layout Itemize
6392 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
6395 \begin_layout Standard
6396 Serialize given movie into file.
6397 If binary is true, binary format (more compact and much faster) is used.
6400 \begin_layout Subsection
6401 movie.unserialize: Unserialize movie
6404 \begin_layout Itemize
6405 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
6409 \begin_layout Standard
6410 Unserialize movie from file.
6411 The given frame is used as template to decide the frame type.
6412 If binary is true, binary format is decoded (much faster).
6415 \begin_layout Subsection
6416 movie.current_first_subframe: Return first subframe in current frame
6419 \begin_layout Itemize
6420 Syntax: number movie.current_first_subframe()
6423 \begin_layout Standard
6424 Returns first subframe in current frame.
6427 \begin_layout Subsection
6428 movie.pollcounter: Return poll counter for speified control
6431 \begin_layout Itemize
6432 Syntax: number movie.pollcounter(number port, number controller, number control)
6435 \begin_layout Standard
6436 Returns number of times the specified control has been polled this frame.
6439 \begin_layout Subsection
6440 movie.current_branch: Return current branch
6443 \begin_layout Itemize
6444 Syntax: string movie.current_branch()
6447 \begin_layout Standard
6448 Returns the name of the current branch.
6451 \begin_layout Subsection
6452 movie.get_branches: Return names of all branches
6455 \begin_layout Itemize
6457 movie.get_branches()
6460 \begin_layout Standard
6461 Returns the name of all branches.
6464 \begin_layout Subsection
6465 INPUTFRAME::get_button: Get button
6468 \begin_layout Itemize
6469 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
6473 \begin_layout Standard
6474 Returns state of given button as boolean.
6477 \begin_layout Subsection
6478 INPUTFRAME::get_axis: Get axis
6481 \begin_layout Itemize
6482 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
6486 \begin_layout Standard
6487 Returns state of given axis as number.
6490 \begin_layout Subsection
6491 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
6494 \begin_layout Itemize
6495 Syntax: none INPUTFRAME::set_button(number port, number controller, number
6496 control, number/bool value)
6499 \begin_layout Itemize
6500 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
6504 \begin_layout Standard
6505 Set the given button/axis to given value.
6508 \begin_layout Subsection
6509 INPUTFRAME::serialize: Serialize a frame
6512 \begin_layout Itemize
6513 Syntax: string INPUTFRAME::serialize()
6516 \begin_layout Standard
6517 Return string representation of frame.
6520 \begin_layout Subsection
6521 INPUTFRAME::unserialize: Unserialize a frame
6524 \begin_layout Itemize
6525 Syntax: none INPUTFRAME::unserialize(string data)
6528 \begin_layout Standard
6529 Set current frame from given data.
6532 \begin_layout Subsection
6533 INPUTFRAME::get_stride: Get movie stride
6536 \begin_layout Itemize
6537 Syntax: number INPUTFRAME::get_stride()
6540 \begin_layout Standard
6541 Return number of bytes needed to store the input frame.
6542 Mainly useful for some debugging.
6545 \begin_layout Standard
6546 \begin_inset Newpage pagebreak
6552 \begin_layout Section
6556 \begin_layout Standard
6557 Routines for settings manipulation
6560 \begin_layout Subsection
6561 settings.get: Get value of setting
6564 \begin_layout Itemize
6565 Syntax: string settings.get(string name)
6568 \begin_layout Standard
6569 Get value of setting <name>.
6570 If setting value can't be obtained, returns (nil, error message).
6573 \begin_layout Subsection
6574 settings.set: Set value of setting
6577 \begin_layout Itemize
6578 Syntax: none settings.set(string name, string value)
6581 \begin_layout Standard
6582 Set value <value> of setting <name>.
6583 If setting can't be set, returns (nil, error message).
6586 \begin_layout Standard
6587 \begin_inset Newpage pagebreak
6593 \begin_layout Section
6597 \begin_layout Standard
6598 Contains various functions for managing memory
6601 \begin_layout Subsection
6602 memory.vma_count: Count number of memory areas.
6605 \begin_layout Itemize
6606 Syntax: number memory.vma_count()
6609 \begin_layout Standard
6610 Returns the number of memory areas
6613 \begin_layout Subsection
6614 memory.read_vma: Lookup memory area info by index
6617 \begin_layout Itemize
6618 Syntax: table memory.read_vma(number index)
6621 \begin_layout Standard
6622 Reads the specified memory area (indices start from zero).
6623 Trying to read invalid memory area gives nil.
6624 The return value is table with the following fields:
6627 \begin_layout Itemize
6628 region_name (string): The readable name of the memory area
6631 \begin_layout Itemize
6632 baseaddr (number): Base address of the memory area
6635 \begin_layout Itemize
6636 lastaddr (number): Last address in the memory area.
6639 \begin_layout Itemize
6640 size (number): The size of memory area in bytes.
6643 \begin_layout Itemize
6644 readonly (boolean): True of the memory area corresponds to ROM.
6647 \begin_layout Itemize
6648 iospace (boolean): True if the memory area is I/O space.
6651 \begin_layout Itemize
6652 native_endian (boolean): True if the memory area has native endian as opposed
6656 \begin_layout Subsection
6657 memory.find_vma: Find memory area info by address
6660 \begin_layout Itemize
6661 Syntax: table memory.find_vma(number address)
6664 \begin_layout Standard
6665 Finds the memory area containing specified address.
6666 Returns table in the same format as read_vma or nil if not found.
6669 \begin_layout Subsection
6670 memory.read{,s}{byte,{,h,d,q}word}: Read memory
6673 \begin_layout Itemize
6674 Syntax: none memory.readbyte(string marea, number address)
6677 \begin_layout Itemize
6678 Syntax: none memory.readword(string marea, number address)
6681 \begin_layout Itemize
6682 Syntax: none memory.readhword(string marea, number address)
6685 \begin_layout Itemize
6686 Syntax: none memory.readdword(string marea, number address)
6689 \begin_layout Itemize
6690 Syntax: none memory.readqword(string marea, number address)
6693 \begin_layout Itemize
6694 Syntax: none memory.readsbyte(string marea, number address)
6697 \begin_layout Itemize
6698 Syntax: none memory.readsword(string marea, number address)
6701 \begin_layout Itemize
6702 Syntax: none memory.readshword(string marea, number address)
6705 \begin_layout Itemize
6706 Syntax: none memory.readsdword(string marea, number address)
6709 \begin_layout Itemize
6710 Syntax: none memory.readsqword(string marea, number address)
6713 \begin_layout Standard
6714 Reads the specified address <address> (if 's' variant is used, do undergo
6718 \begin_layout Subsection
6719 memory.{,s}read_sg: Scatter/Gather read memory
6722 \begin_layout Itemize
6723 Syntax: none memory.read_sg(string/boolean/number...)
6726 \begin_layout Itemize
6727 Syntax: none memory.sread_sg(string/boolean/number...)
6730 \begin_layout Standard
6731 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
6733 Each argument can be string, boolean or number:
6736 \begin_layout Itemize
6737 String: Set memory area addresses are relative to (e.g.
6741 \begin_layout Itemize
6742 boolean: If true, increment relative address by 1, if false, decrement by
6744 The new address is read as next higher byte.
6747 \begin_layout Itemize
6748 integer: Set the relative address to specified value and read the address
6749 as next higher byte.
6752 \begin_layout Subsection
6753 memory.write_sg: Scatter/Gather write memory
6756 \begin_layout Itemize
6757 Syntax: none memory.write_sg(number value, string/boolean/number...)
6760 \begin_layout Standard
6761 Perform scatter/gather write of value <value> on memory.
6762 Each argument can be string, boolean or number:
6765 \begin_layout Itemize
6766 String: Set memory area addresses are relative to (e.g.
6770 \begin_layout Itemize
6771 boolean: If true, increment relative address by 1, if false, decrement by
6773 The new address is read as next higher byte.
6776 \begin_layout Itemize
6777 integer: Set the relative address to specified value and read the address
6778 as next higher byte.
6781 \begin_layout Subsection
6782 memory.read{float,double}: Read memory
6785 \begin_layout Itemize
6786 Syntax: none memory.readfloat(string marea, number address)
6789 \begin_layout Itemize
6790 Syntax: none memory.readdouble(string marea, number address)
6793 \begin_layout Standard
6794 Reads the specified address <address>
6797 \begin_layout Subsection
6798 memory.write{byte,{,h,d,q}word,float,double}: Write memory
6801 \begin_layout Itemize
6802 Syntax: none memory.writebyte(string marea, number address, number value)
6805 \begin_layout Itemize
6806 Syntax: none memory.writeword(string marea, number address, number value)
6809 \begin_layout Itemize
6810 Syntax: none memory.writehword(string marea, number address, number value)
6813 \begin_layout Itemize
6814 Syntax: none memory.writedword(string marea, number address, number value)
6817 \begin_layout Itemize
6818 Syntax: none memory.writeqword(string marea, number address, number value)
6821 \begin_layout Itemize
6822 Syntax: none memory.writefloat(string marea, number address, number value)
6825 \begin_layout Itemize
6826 Syntax: none memory.writedouble(string marea, number address, number value)
6829 \begin_layout Standard
6830 Writes the specified value <value> (negative integer values undergo 2's
6831 complement) to specified address <address>.
6834 \begin_layout Subsection
6835 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
6838 \begin_layout Itemize
6839 Syntax: userdata memory.map<type>(string marea, number base, number size)
6842 \begin_layout Standard
6843 Returns a table mapping specified memory aperture for read/write.
6846 \begin_layout Itemize
6847 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
6848 qword, sqword, float or double.
6851 \begin_layout Subsection
6852 memory.hash_region: Hash region of memory
6855 \begin_layout Itemize
6856 Syntax: string memory.hash_region(string marea, number base, number size)
6859 \begin_layout Standard
6860 Hash <size> bytes starting from address <base> (relative to <marea>) and
6864 \begin_layout Subsection
6865 memory.hash_region2: Hash region of memory
6868 \begin_layout Itemize
6869 Syntax: string memory.hash_region2(string marea, number base, number size[,
6870 number rows, number stride])
6873 \begin_layout Standard
6874 Hash <rows> blocks of <size> bytes starting from address <base> (relative
6876 The blocks are offset by <stride> from one another and return the SHA-256.
6879 \begin_layout Subsection
6880 memory.hash_region_skein: Hash region of memory
6883 \begin_layout Itemize
6884 Syntax: string memory.hash_region_skein(string marea, number base, number
6885 size[, number rows, number stride])
6888 \begin_layout Standard
6889 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
6890 finalists) as hash function.
6893 \begin_layout Subsection
6894 memory.store: Store region of memory
6897 \begin_layout Itemize
6898 Syntax: none memory.store(string marea, number addr, number daddr[, number
6899 rows, number stride]
6902 \begin_layout Standard
6903 Copy memory starting from <addr> in memory area <marea> (each row being
6904 of size <size>, there being <rows> rows, and rows being separated by <stride>
6905 in memory) into savestate-saved memory area, starting from <daadr> (all
6906 rows are written back to back).
6909 \begin_layout Subsection
6910 memory.storecmp: Compare and store region of memory
6913 \begin_layout Itemize
6914 Syntax: bool memory.storecmp(string marea, number addr, number daddr[, number
6915 rows, number stride]
6918 \begin_layout Standard
6919 Like memory.store, but returns true if target of copy already held the value
6920 that would be copied before the copy happened.
6921 Otherwise returns false (if target and source differ before copy).
6924 \begin_layout Subsection
6925 memory.hash_state: Hash system state
6928 \begin_layout Itemize
6929 Syntax: string memory.hash_state()
6932 \begin_layout Standard
6933 Hash the current system state.
6934 Mainly useful for debugging savestates.
6937 \begin_layout Subsection
6938 memory.readregion: Read region of memory
6941 \begin_layout Itemize
6942 Syntax: table memory.readregion(string marea, number base, number size)
6945 \begin_layout Standard
6946 Read a region of memory.
6949 \begin_layout Itemize
6950 Warning: If the region crosses memory area boundary, the results are undefined.
6953 \begin_layout Subsection
6954 memory.writeregion: Write region of memory
6957 \begin_layout Itemize
6958 Syntax: none memory.writeregion(string marea, number base, number size, table
6962 \begin_layout Standard
6963 Write a region of memory.
6966 \begin_layout Itemize
6967 Warning: If the region crosses memory area boundary, the results are undefined.
6970 \begin_layout Subsection
6971 memory.action: Run core action
6974 \begin_layout Itemize
6975 memory.action(string action, [<params>])
6978 \begin_layout Standard
6980 The different models expect parameters as:
6983 \begin_layout Itemize
6987 \begin_layout Itemize
6991 \begin_layout Itemize
6995 \begin_layout Itemize
6999 \begin_layout Itemize
7003 \begin_layout Subsection
7004 memory.get_lag_flag: Get lag flag
7007 \begin_layout Itemize
7008 Syntax: boolean memory.get_lag_flag()
7011 \begin_layout Standard
7012 Get the value of core lag flag.
7013 True if this frame has been lag so far, false if poll has been detected.
7016 \begin_layout Subsection
7017 memory.set_lag_flag: Set lag flag
7020 \begin_layout Itemize
7021 Syntax: none memory.set_lag_flag(boolean flag)
7024 \begin_layout Standard
7025 Set the value of core lag flag.
7026 This flag automatically gets cleared if poll is detected, but can be forcibly
7027 set or cleared if game so requires.
7030 \begin_layout Itemize
7031 Should only be used in on_frame_emulated callback.
7034 \begin_layout Itemize
7035 Setting or clearing this affects the emulator lag counter.
7038 \begin_layout Subsection
7039 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7043 \begin_layout Itemize
7044 Syntax: function memory.registerread(string marea, number addr, function
7048 \begin_layout Itemize
7049 Syntax: function memory.registerwrite(string marea, number addr, function
7053 \begin_layout Itemize
7054 Syntax: function memory.registerexec(string marea, number addr, function
7058 \begin_layout Itemize
7059 Syntax: none memory.unregisterread(string marea, number addr, function fn);
7062 \begin_layout Itemize
7063 Syntax: none memory.unregisterwrite(string marea, number addr, function fn);
7066 \begin_layout Itemize
7067 Syntax: none memory.unregisterexec(string marea, number addr, function fn);
7070 \begin_layout Standard
7071 Add or remove callback on memory read, write or execute (depending on the
7073 <addr> is relative to <marea>.
7074 <fn> is the callback.
7075 The register* functions return <fn> (which can then be passed to unregister*
7079 \begin_layout Itemize
7080 Not all cores support this, and it may be unsupported for some memory areas.
7083 \begin_layout Itemize
7084 The functions are passed two parameters: Address and value.
7087 \begin_layout Subsection
7088 memory.{,un}registertrace: Set/Clear trace hook
7091 \begin_layout Itemize
7092 Syntax: function memory.registertrace(number processor, function fn);
7095 \begin_layout Itemize
7096 Syntax: none memory.unregistertrace(number processor, function fn);
7099 \begin_layout Standard
7100 Add or remove trace callback.
7101 <processor> is system-dependent processor number (0 is usually main CPU).
7102 The function arguments work like in other (un)register* functions.
7105 \begin_layout Itemize
7106 The functions are passed two parameters: Trace CPU and Trace event string.
7109 \begin_layout Subsection
7110 memory.cheat: Set cheat
7113 \begin_layout Itemize
7114 Syntax: none memory.cheat(string marea, number addr, number value);
7117 \begin_layout Itemize
7118 Syntax: none memory.cheat(string marea, number addr);
7121 \begin_layout Standard
7122 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
7123 If <value> is not speicified, clear a cheat.
7126 \begin_layout Itemize
7127 Not all cores support this, and it may be unsupported for some memory areas.
7130 \begin_layout Subsection
7131 memory.setxmask: Set global execute hook mask
7134 \begin_layout Itemize
7135 Syntax: none memory.setxmask(number mask)
7138 \begin_layout Standard
7139 Set the global execute hook mask to <mask>.
7140 The meaning of each bit is system-dependent, but bit 0 should be the main
7144 \begin_layout Subsection
7145 memory.getregister: Get register value
7148 \begin_layout Itemize
7149 Syntax: number/boolean memory.getregister(string register)
7152 \begin_layout Standard
7153 Get the value of named register.
7156 \begin_layout Subsection
7157 memory.getregisters: Get register values
7160 \begin_layout Itemize
7161 Syntax: table memory.getregisters()
7164 \begin_layout Standard
7165 Get the value of all known registers as table.
7168 \begin_layout Subsection
7169 memory.setregister: Set register value
7172 \begin_layout Itemize
7173 Syntax: none memory.setregister(string register, number/boolean value)
7176 \begin_layout Standard
7177 Set the value of named register.
7180 \begin_layout Subsection
7181 memory.mmap: Class MMAP_STRUCT
7184 \begin_layout Standard
7185 See class MMAP_STRUCT
7188 \begin_layout Standard
7189 \begin_inset Newpage pagebreak
7195 \begin_layout Section
7199 \begin_layout Standard
7200 Contains newer memory functions.
7203 \begin_layout Subsection
7204 memory2(): Get all memory area names.
7207 \begin_layout Itemize
7208 Syntax: table memory2()
7211 \begin_layout Standard
7212 Returns array of all valid memory area names.
7215 \begin_layout Subsection
7216 memory2.<marea>:info: Get memory area info
7219 \begin_layout Itemize
7220 Syntax: table memory2.<marea>:info()
7223 \begin_layout Standard
7224 Return table describing given memory area.
7225 Includes fields address, size, last, readonly, special and endian.
7228 \begin_layout Subsection
7229 memory2.<marea>:<op>: Read/Write memory
7232 \begin_layout Itemize
7233 Syntax: none memory2.<marea>:<op>(number offset, number value)
7236 \begin_layout Itemize
7237 Syntax: number memory2.<marea>:<op>(number offset)
7240 \begin_layout Standard
7241 Read/Write value from/to given memory area <marea> at given offset <offset>
7243 The value written is <value>.
7244 <Op> is of form: [i][s]<type>, where:
7247 \begin_layout Itemize
7248 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
7251 \begin_layout Itemize
7252 'i' signifies that the value is treated as opposite-to-normal endianess,
7255 \begin_layout Itemize
7256 's' signifies that value is treated as signed (not available for floating-point).
7259 \begin_layout Subsection
7260 memory2.<marea>:read: Scatter-gather value read
7263 \begin_layout Itemize
7264 Syntax: number memory2.<marea>:read(number addr...)
7267 \begin_layout Standard
7268 Read value from given memory area <marea> at byte offsets <addr>..., given
7269 in order of increasing significance.
7270 Value of true and false are special.
7271 True increments address by 1, and false decrements address by 1.
7274 \begin_layout Subsection
7275 memory2.<marea>:sread: Signed scatter-gather value read
7278 \begin_layout Itemize
7279 Syntax: number memory2.<marea>:sread(number addr...)
7282 \begin_layout Standard
7283 Like memory2.<marea>:read, but reads signed values.
7286 \begin_layout Subsection
7287 memory2.<marea>:write: Scatter-gather value write
7290 \begin_layout Itemize
7291 Syntax: number memory2.<marea>:write(number val, number addr...)
7294 \begin_layout Standard
7295 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
7296 in order of increasing significance.
7297 Value of true and false are special.
7298 True increments address by 1, and false decrements address by 1.
7301 \begin_layout Subsection
7302 memory2.<marea>:cheat: Set/Clear cheat
7305 \begin_layout Itemize
7306 Syntax: none memory2.<marea>:cheat(number addr, [number value])
7309 \begin_layout Standard
7310 Set/Clear cheat at offset <addr> of memory area <marea>.
7311 If <value> is given, cheat with specified value is set.
7312 Otherwise cheat on address is removed.
7315 \begin_layout Subsection
7316 memory2.<marea>:sha256: SHA-256
7319 \begin_layout Itemize
7320 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
7324 \begin_layout Standard
7325 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
7326 from offset <addr> of area <marea>.
7327 The chunks are separated by <stride>.
7330 \begin_layout Subsection
7331 memory2.<marea>:skein: Skein-512-256
7334 \begin_layout Itemize
7335 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
7339 \begin_layout Standard
7340 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
7343 \begin_layout Subsection
7344 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
7347 \begin_layout Itemize
7348 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
7349 number rows, number stride])
7352 \begin_layout Itemize
7353 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
7354 size[, number rows, number stride])
7357 \begin_layout Standard
7358 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
7359 <addr> of area <marea>.
7360 The chunks are separated by <stride>.
7361 The target is Lua host memory, starting from offset <daddr>.
7364 \begin_layout Standard
7365 Additionally, the storecmp method returns false if target was modified (otherwis
7369 \begin_layout Subsection
7370 memory2.<marea>:readregion: Read region
7373 \begin_layout Itemize
7374 Syntax table memory2.<marea>:readregion(number addr, number size)
7377 \begin_layout Standard
7378 Read <size> bytes starting from <addr> in <marea> and return as array.
7381 \begin_layout Subsection
7382 memory2.<marea>:writeregion: Write region
7385 \begin_layout Itemize
7386 Syntax none memory2.<marea>:writeregion(number addr, table data)
7389 \begin_layout Standard
7390 Write array <data> to bytes starting from <addr> in <marea>.
7393 \begin_layout Subsection
7394 memory2.<marea>:register{read,write,exec}: Register hook
7397 \begin_layout Itemize
7398 Syntax: function memory2.<marea>:registerread(number addr, function fn);
7401 \begin_layout Itemize
7402 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
7405 \begin_layout Itemize
7406 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
7409 \begin_layout Standard
7410 Register debug callback <fn> of specified type at offset <addr> of memory
7415 \begin_layout Subsection
7416 memory2.<marea>:unregister{read,write,exec}: Unregister hook
7419 \begin_layout Itemize
7420 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
7423 \begin_layout Itemize
7424 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
7427 \begin_layout Itemize
7428 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
7431 \begin_layout Standard
7432 Unregister debug callback <fn> of specified type at offset <addr> of memory
7436 \begin_layout Standard
7437 \begin_inset Newpage pagebreak
7443 \begin_layout Section
7447 \begin_layout Standard
7448 Contains random number generation methods.
7449 These functions do not return reproducable results.
7452 \begin_layout Subsection
7453 random.boolean: Random boolean
7456 \begin_layout Itemize
7457 Syntax: boolean random.boolean()
7460 \begin_layout Standard
7461 Returns true or false at random (50-50 chance).
7464 \begin_layout Subsection
7465 random.integer: Random integer
7468 \begin_layout Itemize
7469 Syntax: number random.integer(number highplusone)
7472 \begin_layout Itemize
7473 Syntax: number random.integer(number low, number high)
7476 \begin_layout Standard
7477 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
7478 With two arguments, return random integer [<low>,<high>] (both ends inclusive).
7481 \begin_layout Standard
7482 The returned numbers are from uniform distribution.
7485 \begin_layout Subsection
7486 random.float: Random float
7489 \begin_layout Itemize
7490 Syntax: number random.float()
7493 \begin_layout Standard
7494 Returns random decimal number [0,1).
7497 \begin_layout Subsection
7498 random.among: Random parameter
7501 \begin_layout Itemize
7502 Syntax: value random.among(value values...)
7505 \begin_layout Standard
7506 Returns random parameter value, picked at uniform.
7507 Multiple equivalent values are returned with higher chance.
7510 \begin_layout Subsection
7511 random.amongtable: Random from table
7514 \begin_layout Itemize
7515 Syntax: value random.amongtable(table tab)
7518 \begin_layout Standard
7519 Returns random value from table <tab>.
7520 As in random.among, no equality testing is done.
7523 \begin_layout Standard
7524 \begin_inset Newpage pagebreak
7530 \begin_layout Section
7534 \begin_layout Subsection
7535 zip.enumerate: Enumerate members in zipfile
7538 \begin_layout Itemize
7539 Syntax: Table zip.enumerate(string filename[, boolean invert])
7542 \begin_layout Standard
7543 Returns table of files in zip archive <filename>.
7544 If <invert> is true, instead of returning array of names, returns table
7545 with keys being member names and values being true.
7548 \begin_layout Subsection
7549 zip.writer: Class ZIPWRITER
7552 \begin_layout Standard
7553 See class ZIPWRITER.
7556 \begin_layout Standard
7557 \begin_inset Newpage pagebreak
7563 \begin_layout Section
7567 \begin_layout Standard
7568 Various callback-related functions.
7571 \begin_layout Subsection
7572 \begin_inset CommandInset label
7574 name "sub:callback.register:-Register-a"
7578 callback.register: Register a callback
7581 \begin_layout Itemize
7582 Syntax: function callback.register(string cbname, function cbfun);
7585 \begin_layout Standard
7586 Instruct function <cbfun> to be added to list of callbacks to call on event
7587 <cbname> (See section
7588 \begin_inset CommandInset ref
7590 reference "sec:Callbacks"
7595 The callback name does not have the 'on_' prefix (e.g.
7597 \begin_inset Quotes eld
7601 \begin_inset Quotes erd
7608 \begin_layout Subsection
7609 \begin_inset CommandInset label
7611 name "sub:callback.unregister:-Unregister-"
7615 callback.unregister: Unregister a callback
7618 \begin_layout Itemize
7619 Syntax: function callback.unregister(string cbname, function cbfun);
7622 \begin_layout Standard
7623 Instruct function <cbfun> to be removed from list of callbacks to call on
7627 \begin_layout Subsection
7628 callback.<cbname>:register: Register callback
7631 \begin_layout Itemize
7632 Syntax: function callback.<cbname>:register(function cbfun)
7635 \begin_layout Standard
7636 Synonym for callback.register (section
7637 \begin_inset CommandInset ref
7639 reference "sub:callback.register:-Register-a"
7643 ), albeit with callback name specified differently.
7646 \begin_layout Subsection
7647 callback.<cbname>:unregister: Register callback
7650 \begin_layout Itemize
7651 Syntax: function callback.<cbname>:unregister(function cbfun)
7654 \begin_layout Standard
7655 Synonym for callback.unregister (section
7656 \begin_inset CommandInset ref
7658 reference "sub:callback.unregister:-Unregister-"
7662 ), albeit with callback name specified differently.
7665 \begin_layout Section
7669 \begin_layout Standard
7670 Various bsnes-specific functions.
7673 \begin_layout Subsection
7674 bsnes.dump_sprite: Dump a sprite
7677 \begin_layout Itemize
7678 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
7679 number height[, number stride])
7682 \begin_layout Standard
7683 Dumps given sprite (in native format) from memory.
7684 memory area is usually
7685 \begin_inset Quotes eld
7689 \begin_inset Quotes erd
7693 <Width> and <height> are given in 8x8 blocks.
7694 <Stride> overrides row stride (default 512).
7697 \begin_layout Subsection
7698 bsnes.dump_palette: Dump a palette
7701 \begin_layout Itemize
7702 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool full256,
7706 \begin_layout Standard
7707 Dumps a palette from memory.
7708 memory area is usually
7709 \begin_inset Quotes eld
7713 \begin_inset Quotes erd
7717 If <full256> is true, 256 colors are dumped (otherwise 16).
7718 If <first_trans> is true, first color is forced transparent.
7721 \begin_layout Subsection
7722 bsnes.enablelayer: Set layer visibility
7725 \begin_layout Itemize
7726 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
7729 \begin_layout Standard
7730 Enable or disable specified layer at specified priority.
7733 \begin_layout Subsection
7734 bsnes.redump_sprite: Redump a sprite
7737 \begin_layout Itemize
7738 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
7742 \begin_layout Standard
7743 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
7744 The specified bitmap must have size multiple of 8x8.
7747 \begin_layout Subsection
7748 bsnes.redump_palette: Redump a palette
7751 \begin_layout Itemize
7752 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
7756 \begin_layout Standard
7757 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
7758 The specified palette must have either 16 or 256 colors.
7761 \begin_layout Section
7762 extensions to table string
7765 \begin_layout Subsection
7766 string.charU: string.char, UTF-8 version.
7769 \begin_layout Itemize
7770 Syntax: string string.charU(number n...)
7773 \begin_layout Standard
7774 Like Lua string.char(), but works in terms of Unicode codepoints.
7775 The returned string is UTF-8.
7778 \begin_layout Subsection
7779 string.byteU: string.byte, UTF-8 version.
7782 \begin_layout Itemize
7784 string.byteU(string str[, number i[, number j]])
7787 \begin_layout Standard
7788 Like string.byte(), but works in terms of Unicode codepoints.
7789 The input string <str> is assumed UTF-8.
7792 \begin_layout Subsection
7793 string.regex: Match string against regular expression
7796 \begin_layout Itemize
7797 Syntax: boolean/string...
7798 string.regex(string regexp, string against)
7801 \begin_layout Standard
7802 Match POSIX-extended regular expression <regexp> against string <against>.
7803 If no match, false is returned.
7804 Otherwise if string has no subcaptures, true is returned.
7805 Otherwise each subcapture is returned as a string (in order of starting
7809 \begin_layout Subsection
7810 string.hex: Transform integer into hex string
7813 \begin_layout Itemize
7814 Syntax: string string.hex(number n, [number digits])
7817 \begin_layout Standard
7818 Returns hexadecimal string representation of <n>, optionally padded with
7819 zeroes to <digits> digits (default is not to pad).
7822 \begin_layout Subsection
7823 string.lpad: Pad string with spaces from left
7826 \begin_layout Itemize
7827 Syntax: string string.lpad(string x, number n)
7830 \begin_layout Standard
7831 Pad string <x> to <n> bytes by inserting spaces at start and return the
7835 \begin_layout Subsection
7836 string.rpad: Pad string with spaces from right
7839 \begin_layout Itemize
7840 Syntax: string string.rpad(string x, number n)
7843 \begin_layout Standard
7844 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
7847 \begin_layout Section
7851 \begin_layout Standard
7852 Contains copy of global variables from time of Lua initialization.
7856 \begin_layout Standard
7857 \begin_inset Newpage pagebreak
7863 \begin_layout Section
7864 \begin_inset CommandInset label
7866 name "sec:Callbacks"
7873 \begin_layout Standard
7874 Various callbacks to Lua that can occur.
7877 \begin_layout Subsection
7878 on_paint: Screen is being painted
7881 \begin_layout Itemize
7882 Callback: on_paint(bool not_synth)
7885 \begin_layout Standard
7886 Called when screen is being painted.
7887 Any gui.* calls requiring graphic context draw on the screen.
7890 \begin_layout Itemize
7891 not_synth is true if this hook is being called in response to received frame,
7895 \begin_layout Subsection
7896 on_video: Dumped video frame is being painted
7899 \begin_layout Itemize
7900 Callback: on_video()
7903 \begin_layout Standard
7904 Called when video dump frame is being painted.
7905 Any gui.* calls requiring graphic context draw on the video.
7908 \begin_layout Subsection
7909 on_frame_emulated: Frame emulation complete
7912 \begin_layout Itemize
7913 Callback: on_frame_emulated()
7916 \begin_layout Standard
7917 Called when emulating frame has completed and on_paint()/on_video() calls
7918 are about to be issued.
7921 \begin_layout Subsection
7922 on_frame: Frame emulation starting.
7925 \begin_layout Itemize
7926 Callback: on_frame()
7929 \begin_layout Standard
7930 Called on each starting whole frame.
7933 \begin_layout Subsection
7934 on_rewind: Movie rewound to beginning
7937 \begin_layout Itemize
7938 Callback: on_rewind()
7941 \begin_layout Standard
7942 Called when rewind movie to beginning has completed.
7945 \begin_layout Subsection
7946 on_pre_load: Load operation is about to start
7949 \begin_layout Itemize
7950 Callback: on_pre_load(string name)
7953 \begin_layout Standard
7954 Called just before savestate/movie load occurs (note: loads are always delayed,
7955 so this occurs even when load was initiated by lua).
7958 \begin_layout Subsection
7959 on_err_Load: Load failed
7962 \begin_layout Itemize
7963 Callback: on_err_load(string name)
7966 \begin_layout Standard
7967 Called if loadstate goes wrong.
7970 \begin_layout Subsection
7971 on_post_load: Load completed
7974 \begin_layout Itemize
7975 Callback: on_post_load(string name, boolean was_savestate)
7978 \begin_layout Standard
7979 Called on successful loadstate.
7980 was_savestate gives if this was a savestate or a movie.
7983 \begin_layout Subsection
7984 on_pre_save: Save operation is about to start
7987 \begin_layout Itemize
7988 Callback: on_pre_save(string name, boolean is_savestate)
7991 \begin_layout Standard
7992 Called just before savestate save occurs (note: movie saves are synchronous
7993 and won't trigger these callbacks if called from Lua).
7996 \begin_layout Subsection
7997 on_err_save: Save failed
8000 \begin_layout Itemize
8001 Callback: on_err_save(string name)
8004 \begin_layout Standard
8005 Called if savestate goes wrong.
8008 \begin_layout Subsection
8009 on_post_save: Save completed
8012 \begin_layout Itemize
8013 Callback: on_post_save(string name, boolean is_savestate)
8016 \begin_layout Standard
8017 Called on successful savaestate.
8018 is_savestate gives if this was a savestate or a movie.
8021 \begin_layout Subsection
8022 on_quit: Emulator is shutting down
8025 \begin_layout Itemize
8029 \begin_layout Standard
8030 Called when emulator is shutting down.
8033 \begin_layout Subsection
8034 on_input: Polling for input
8037 \begin_layout Standard
8038 Called when emulator is just sending input to bsnes core.
8039 Warning: This is called even in readonly mode, but the results are ignored.
8042 \begin_layout Subsection
8043 on_reset: System has been reset
8046 \begin_layout Itemize
8047 Callback: on_reset()
8050 \begin_layout Standard
8051 Called when system is reset.
8054 \begin_layout Subsection
8055 on_readwrite: Entered recording mode
8058 \begin_layout Itemize
8059 Callback: on_readwrite()
8062 \begin_layout Standard
8063 Called when moving into recording mode as result of
8064 \begin_inset Quotes eld
8068 \begin_inset Quotes erd
8071 command (note: moving to rwmode by Lua won't trigger this, as per recursive
8075 \begin_layout Subsection
8076 on_snoop/on_snoop2: Snoop core controller reads
8079 \begin_layout Itemize
8080 Callback: on_snoop(number port, number controller, number index, number
8084 \begin_layout Itemize
8085 Callback: on_snoop2(number port, number controller, number index, number
8089 \begin_layout Standard
8090 Called each time bsnes asks for input.
8091 The value is the final value to be sent to bsnes core (readonly mode, autohold
8092 and autofire have been taken into account).
8093 Might be useful when translating movies to format suitable for console
8095 Note: There is no way to modify the value to be sent.
8098 \begin_layout Itemize
8099 On_snoop2 is called instead of on_snoop if defined.
8100 Reserves port 0 for system, having first user port be port 1.
8103 \begin_layout Subsection
8104 on_keyhook: Hooked key/axis has been moved
8107 \begin_layout Itemize
8108 Callback: on_keyhook(string keyname, table state)
8111 \begin_layout Standard
8112 Sent when key that has keyhook events requested changes state.
8113 Keyname is name of the key (group) and state is the state (same kind as
8114 table values in input.raw).
8117 \begin_layout Subsection
8121 \begin_layout Itemize
8125 \begin_layout Standard
8126 Called when requested by set_idle_timeout(), the timeout has expired and
8127 emulator is waiting.
8130 \begin_layout Subsection
8131 on_timer: Timer event
8134 \begin_layout Itemize
8135 Callback: on_timer()
8138 \begin_layout Standard
8139 Called when requested by set_idle_timeout() and the timeout has expired
8140 (regardless if emulator is waiting).
8143 \begin_layout Subsection
8144 on_set_rewind: Rewind point has been set
8147 \begin_layout Itemize
8148 Callback: on_set_rewind(UNSAFEREWIND r)
8151 \begin_layout Standard
8152 Called when unsafe rewind object has been constructed.
8155 \begin_layout Subsection
8156 on_pre_rewind: Rewind is about to occur
8159 \begin_layout Itemize
8160 Callback: on_pre_rewind()
8163 \begin_layout Standard
8164 Called just before unsafe rewind is about to occur.
8167 \begin_layout Subsection
8168 on_post_rewind: Rewind has occured
8171 \begin_layout Itemize
8172 Callback: on_post_rewind()
8175 \begin_layout Standard
8176 Called just after unsafe rewind has occured.
8179 \begin_layout Subsection
8180 on_button: Button has been pressed
8183 \begin_layout Itemize
8184 Callback: on_button(number port, number controller, number index, string
8188 \begin_layout Standard
8189 Called on controller button press, with following parameters:
8192 \begin_layout Itemize
8193 port: Port number (0 is system)
8196 \begin_layout Itemize
8197 controller: Controller within port
8200 \begin_layout Itemize
8201 index: Index of button.
8204 \begin_layout Itemize
8205 type: Type of event, one of:
8209 \begin_layout Itemize
8210 \begin_inset Quotes eld
8214 \begin_inset Quotes erd
8217 : Button was pressed.
8220 \begin_layout Itemize
8221 \begin_inset Quotes eld
8225 \begin_inset Quotes erd
8228 : Button was released.
8231 \begin_layout Itemize
8232 \begin_inset Quotes eld
8236 \begin_inset Quotes erd
8242 \begin_layout Itemize
8243 \begin_inset Quotes eld
8247 \begin_inset Quotes erd
8250 : Released from hold.
8253 \begin_layout Itemize
8254 \begin_inset Quotes eld
8258 \begin_inset Quotes erd
8261 : Typing input on button.
8264 \begin_layout Itemize
8265 \begin_inset Quotes eld
8269 \begin_inset Quotes erd
8272 : Typing input undone.
8275 \begin_layout Itemize
8276 \begin_inset Quotes eld
8279 autofire <duty> <cycle>
8280 \begin_inset Quotes erd
8283 : Autofire with specifie duty and cycle.
8286 \begin_layout Itemize
8287 \begin_inset Quotes eld
8291 \begin_inset Quotes erd
8297 \begin_layout Itemize
8298 \begin_inset Quotes eld
8302 \begin_inset Quotes erd
8305 : Analog action on axis.
8309 \begin_layout Subsection
8310 on_movie_lost: Movie data is about to be lost
8313 \begin_layout Itemize
8314 Callback: on_movie_lost(STRING kind)
8317 \begin_layout Standard
8318 Called just before something would happen that could lose movie data.
8322 \begin_layout Itemize
8323 readwrite: Switching to recording mode.
8326 \begin_layout Itemize
8327 reload: ROM is being reloaded in recording mode.
8330 \begin_layout Itemize
8331 load: New movie is being loaded.
8334 \begin_layout Itemize
8335 unsaferewind: Unsafe rewind is happening.
8338 \begin_layout Subsection
8339 on_latch: Latch line is rising
8342 \begin_layout Itemize
8343 Callback: on_latch(<core-dependent-parameters>)
8346 \begin_layout Standard
8347 Called when latch line for controller is rising.
8348 Some cores may not support this.
8351 \begin_layout Section
8352 System-dependent behaviour
8355 \begin_layout Subsection
8359 \begin_layout Itemize
8360 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
8361 p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
8362 p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
8363 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
8364 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
8365 ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
8366 ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
8367 ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
8368 ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
8369 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
8370 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
8371 ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
8372 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
8373 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
8374 ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
8375 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
8376 ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
8377 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
8378 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
8379 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
8380 ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
8381 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
8382 ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
8383 ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
8384 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
8385 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
8386 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
8387 ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
8388 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
8389 ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
8390 ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
8391 ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
8392 ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
8393 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
8394 ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
8395 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
8396 ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
8397 ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
8398 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
8399 ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount,
8402 \begin_layout Itemize
8403 on_latch has no parameters
8406 \begin_layout Itemize
8407 CPU 0 is S-CPU, 1 is S-SMP.
8410 \begin_layout Itemize
8411 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
8414 \begin_layout Itemize
8415 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
8419 \begin_layout Itemize
8420 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
8421 DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
8422 BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
8423 GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
8426 \begin_layout Subsection
8430 \begin_layout Itemize
8431 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
8435 \begin_layout Itemize
8436 on_latch is not supported
8439 \begin_layout Itemize
8443 \begin_layout Itemize
8444 Cheats are supported for ROM, SRAM and WRAM.
8447 \begin_layout Itemize
8448 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
8452 \begin_layout Itemize
8453 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.