Hex editor: Properly erase past-the-end chars for non-mod16 regions
[lsnes.git] / lua.lyx
blob8c594de25cb1a798efdff1970f90acd48dd7caff
1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
2 \lyxformat 413
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options true
7 \maintain_unincluded_children false
8 \language english
9 \language_package default
10 \inputencoding auto
11 \fontencoding global
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
17 \font_sc false
18 \font_osf false
19 \font_sf_scale 100
20 \font_tt_scale 100
22 \graphics default
23 \default_output_format default
24 \output_sync 0
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
28 \spacing single
29 \use_hyperref true
30 \pdf_bookmarks true
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
34 \pdf_breaklinks false
35 \pdf_pdfborder false
36 \pdf_colorlinks false
37 \pdf_backref false
38 \pdf_pdfusetitle true
39 \papersize a4paper
40 \use_geometry true
41 \use_amsmath 1
42 \use_esint 1
43 \use_mhchem 1
44 \use_mathdots 1
45 \cite_engine basic
46 \use_bibtopic false
47 \use_indices false
48 \paperorientation portrait
49 \suppress_date false
50 \use_refstyle 1
51 \index Hakusana
52 \shortcut idx
53 \color #008000
54 \end_index
55 \leftmargin 2cm
56 \topmargin 2cm
57 \rightmargin 1cm
58 \bottommargin 2cm
59 \headheight 1cm
60 \headsep 1cm
61 \footskip 1cm
62 \secnumdepth 3
63 \tocdepth 3
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
67 \papercolumns 1
68 \papersides 1
69 \paperpagestyle default
70 \tracking_changes false
71 \output_changes false
72 \html_math_output 0
73 \html_css_as_file 0
74 \html_be_strict false
75 \end_header
77 \begin_body
79 \begin_layout Title
80 lsnes Lua functions reference
81 \end_layout
83 \begin_layout Section
84 Table of contents
85 \end_layout
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
91 \end_inset
94 \end_layout
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
98 \end_inset
101 \end_layout
103 \begin_layout Section
104 Conventions
105 \end_layout
107 \begin_layout Subsection
108 Coordinates:
109 \end_layout
111 \begin_layout Itemize
112 Coordinates increase to right and down.
113 \end_layout
115 \begin_layout Itemize
116 The origin is at top left of game area or buffer.
117 \end_layout
119 \begin_layout Subsection
120 Drawing and contexts
121 \end_layout
123 \begin_layout Itemize
124 Methods that draw something (unless stated otherwise) require a valid rendering
125  context.
126  This context can come in three ways:
127 \end_layout
129 \begin_deeper
130 \begin_layout Enumerate
131 The default rendering context of paint callback (the screen).
132 \end_layout
134 \begin_layout Enumerate
135 The default rendering context of video callback (the video).
136 \end_layout
138 \begin_layout Enumerate
139 Explicitly set rendering context (RENDERCTX:set).
140 \end_layout
142 \end_deeper
143 \begin_layout Itemize
144 The rendering context is always reset when callback ends.
145 \end_layout
147 \begin_layout Subsection
148 Colors
149 \end_layout
151 \begin_layout Standard
152 (Direct) colors can be specified either as numbers or strings.
153 \end_layout
155 \begin_layout Itemize
156 -1 is fully transparent.
157 \end_layout
159 \begin_layout Itemize
160 Non-negative numbers less than 
161 \begin_inset Formula $2^{32}$
162 \end_inset
164  are partially opaque colors (
165 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
166 \end_inset
169 \end_layout
171 \begin_deeper
172 \begin_layout Itemize
173 \begin_inset Formula $a$
174 \end_inset
176  is transparency 
177 \begin_inset Formula $0-255$
178 \end_inset
181 \begin_inset Formula $0$
182 \end_inset
184  is fully opaque, 
185 \begin_inset Formula $256$
186 \end_inset
188  would be fully transparent.
189 \end_layout
191 \begin_deeper
192 \begin_layout Itemize
193 Thus, numbers in range 
194 \begin_inset Formula $0-16777215$
195 \end_inset
197  stand for fully opaque colors.
198 \end_layout
200 \end_deeper
201 \begin_layout Itemize
202 \begin_inset Formula $r$
203 \end_inset
206 \begin_inset Formula $g$
207 \end_inset
209  and 
210 \begin_inset Formula $b$
211 \end_inset
213  are intensities of base colors on scale 
214 \begin_inset Formula $0-255$
215 \end_inset
218 \end_layout
220 \end_deeper
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 
306 \end_layout
308 \begin_layout Itemize
309 The HSL base color names: hsl-<hue><saturation><lightness>.
310 \end_layout
312 \begin_deeper
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).
317 \end_layout
319 \begin_layout Itemize
320 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
321 \end_layout
323 \begin_layout Itemize
324 Lightness is 0-8, where 0 is black and 8 is white.
325 \end_layout
327 \end_deeper
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}.
333 \end_layout
335 \begin_deeper
336 \begin_layout Itemize
337 opaqueness is measured as percentage.
338 \end_layout
340 \begin_layout Itemize
341 Hue adjustments are on 24-step scale.
342 \end_layout
344 \begin_layout Itemize
345 Saturation and lightness adjustments are on 16-step scale.
346 \end_layout
348 \end_deeper
349 \begin_layout Section
350 Special tokens
351 \end_layout
353 \begin_layout Standard
354 These tokens are special, and are expanded while the script is being loaded
355 \end_layout
357 \begin_layout Subsection
358 @@LUA_SCRIPT_FILENAME@@
359 \end_layout
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
364  to this Lua script.
365 \end_layout
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.
371 \end_layout
373 \begin_layout Section
374 Classes
375 \end_layout
377 \begin_layout Subsection
378 MMAP_STRUCT: Quasi-table mapping emulated memory
379 \end_layout
381 \begin_layout Standard
382 Objects of this class act like tables, except that the values are reflected
383  to and from emulated memory.
384 \end_layout
386 \begin_layout Subsubsection
387 static function new: Create new instance
388 \end_layout
390 \begin_layout Itemize
391 Syntax: mmap memory.mmap.new()
392 \end_layout
394 \begin_layout Itemize
395 Syntax: mmap classes.MMAP_STRUCT.new()
396 \end_layout
398 \begin_layout Itemize
399 Deprecated: mmap memory.map_structure()
400 \end_layout
402 \begin_layout Standard
403 Return value:
404 \end_layout
406 \begin_layout Itemize
407 mmap: MMAP_STRUCT: The created mmap structure.
408 \end_layout
410 \begin_layout Standard
411 Create a new MMAP_STRUCT (with no mappings) and return it.
412 \end_layout
414 \begin_layout Subsubsection
415 operator(): Bind key in mmap structure
416 \end_layout
418 \begin_layout Itemize
419 Syntax: obj(key, address, type)
420 \end_layout
422 \begin_layout Itemize
423 Syntax: obj(key, vma, address, type)
424 \end_layout
426 \begin_layout Standard
427 Parameters:
428 \end_layout
430 \begin_layout Itemize
431 obj: MMAP_STRUCT: The structure to manipulate.
432 \end_layout
434 \begin_layout Itemize
435 key: String: The name of the key in array to map.
436 \end_layout
438 \begin_layout Itemize
439 vma: String: The memory area the mapped address is in (default: global memory
440  space).
441 \end_layout
443 \begin_layout Itemize
444 address: Number: The offset of memory addreess, relative to specified memory
445  area or global memory space.
446 \end_layout
448 \begin_layout Itemize
449 type: String: The type of data to map.
450 \end_layout
452 \begin_deeper
453 \begin_layout Itemize
454 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
455  float or double.
456 \end_layout
458 \end_deeper
459 \begin_layout Standard
460 Bind key <key> in mmap structure <obj> to address <address> (relative to
461  <vma>).
462  The memory address is treated as type <type>.
463 \end_layout
465 \begin_layout Standard
466 \begin_inset Newpage pagebreak
467 \end_inset
470 \end_layout
472 \begin_layout Subsection
473 ZIPWRITER: Write .zip files
474 \end_layout
476 \begin_layout Standard
477 This class does writing of .zip files.
478 \end_layout
480 \begin_layout Subsubsection
481 Static function new: Create a new zipfile
482 \end_layout
484 \begin_layout Itemize
485 Syntax: zip zip.writer.new(filename, [compression])
486 \end_layout
488 \begin_layout Itemize
489 Deprecated: zip zip.create(filename, [compression])
490 \end_layout
492 \begin_layout Standard
493 Parameters:
494 \end_layout
496 \begin_layout Itemize
497 filename: string: The name of the file to write.
498 \end_layout
500 \begin_layout Itemize
501 compression: number: Compression level (0-9).
502  Default is 9.
503 \end_layout
505 \begin_layout Standard
506 Return value:
507 \end_layout
509 \begin_layout Itemize
510 zip: ZIPWRITER: The newly created ZIP writer.
511 \end_layout
513 \begin_layout Standard
514 Create a new ZIPWRITER object and return it.
515 \end_layout
517 \begin_layout Subsubsection
518 Method commit: Finish creating ZIP file.
519 \end_layout
521 \begin_layout Itemize
522 Syntax: zipfile:commit()
523 \end_layout
525 \begin_layout Standard
526 Parameters:
527 \end_layout
529 \begin_layout Itemize
530 zipfile: ZIPFILE: The ZIP file object.
531 \end_layout
533 \begin_layout Standard
534 Finish writing the ZIP file and actually create it on disk.
535 \end_layout
537 \begin_layout Itemize
538 If a member is currently open, it is implicitly closed.
539 \end_layout
541 \begin_layout Itemize
542 Invoking this on already committed or rolled back zipfile causes an error.
543 \end_layout
545 \begin_layout Subsubsection
546 Method rollback: Cancel writing the ZIP file.
547 \end_layout
549 \begin_layout Itemize
550 Syntax: zipfile:rollback()
551 \end_layout
553 \begin_layout Standard
554 Parameters:
555 \end_layout
557 \begin_layout Itemize
558 zipfile: ZIPFILE: The ZIP file object.
559 \end_layout
561 \begin_layout Standard
562 Cancel writing the whole ZIP file.
563  The file on disk will not be modified.
564 \end_layout
566 \begin_layout Itemize
567 If a member is currently open, it is implicitly closed.
568 \end_layout
570 \begin_layout Itemize
571 Invoking this on already committed or rolled back zipfile causes an error.
572 \end_layout
574 \begin_layout Subsubsection
575 Method create_file: Start writing a new member
576 \end_layout
578 \begin_layout Itemize
579 Syntax: zipfile:create_file(filename)
580 \end_layout
582 \begin_layout Standard
583 Parameters:
584 \end_layout
586 \begin_layout Itemize
587 zipfile: ZIPFILE: The ZIP file object.
588 \end_layout
590 \begin_layout Itemize
591 string filename: Name of the new member to create
592 \end_layout
594 \begin_layout Standard
595 Start writing a new member <filename> in ZIP file.
596 \end_layout
598 \begin_layout Itemize
599 If a member is currently open, it is implicitly closed.
600 \end_layout
602 \begin_layout Itemize
603 Invoking this on already committed or rolled back zipfile causes an error.
604 \end_layout
606 \begin_layout Subsubsection
607 Method close_file: Close member
608 \end_layout
610 \begin_layout Itemize
611 Syntax: zipfile:close_file()
612 \end_layout
614 \begin_layout Standard
615 Parameters:
616 \end_layout
618 \begin_layout Itemize
619 zipfile: ZIPFILE: The ZIP file object.
620 \end_layout
622 \begin_layout Standard
623 Close the currently open member in zipfile.
624 \end_layout
626 \begin_layout Itemize
627 Invoking this on already committed or rolled back zipfile causes an error.
628 \end_layout
630 \begin_layout Itemize
631 Invoking this without an open member causes an error.
632 \end_layout
634 \begin_layout Subsubsection
635 Method write: Write data
636 \end_layout
638 \begin_layout Itemize
639 Syntax: zipfile:write(data)
640 \end_layout
642 \begin_layout Standard
643 Parameters:
644 \end_layout
646 \begin_layout Itemize
647 zipfile: ZIPFILE: The ZIP file object.
648 \end_layout
650 \begin_layout Itemize
651 data: string: The data to write.
652 \end_layout
654 \begin_layout Standard
655 Write <data> in binary mode (as-is) to currently open member.
656 \end_layout
658 \begin_layout Itemize
659 Invoking this without a member being open causes an error.
660 \end_layout
662 \begin_layout Standard
663 \begin_inset Newpage pagebreak
664 \end_inset
667 \end_layout
669 \begin_layout Subsection
670 TILEMAP: Tiled collection of bitmaps.
671 \end_layout
673 \begin_layout Standard
674 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
675 \end_layout
677 \begin_layout Subsubsection
678 Static function new: Create a tilemap
679 \end_layout
681 \begin_layout Itemize
682 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
683 \end_layout
685 \begin_layout Itemize
686 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
687 \end_layout
689 \begin_layout Itemize
690 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
691 \end_layout
693 \begin_layout Standard
694 Parameters:
695 \end_layout
697 \begin_layout Itemize
698 w: number: Width of the tilemap in tiles
699 \end_layout
701 \begin_layout Itemize
702 h: number: Height of the tilemap in tiles
703 \end_layout
705 \begin_layout Itemize
706 bw: number: Width of each tile in pixels.
707 \end_layout
709 \begin_layout Itemize
710 bh: number: Height of each tile in pixels.
711 \end_layout
713 \begin_layout Standard
714 Return value:
715 \end_layout
717 \begin_layout Itemize
718 tilemap: TILEMAP: the newly created tilemap
719 \end_layout
721 \begin_layout Standard
722 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
723  it.
724 \end_layout
726 \begin_layout Subsubsection
727 TILEMAP:getsize: Query tilemap size
728 \end_layout
730 \begin_layout Itemize
731 Syntax: width, height tmap:getsize()
732 \end_layout
734 \begin_layout Standard
735 Parameters:
736 \end_layout
738 \begin_layout Itemize
739 tmap: TILEMAP: The tilemap to query.
740 \end_layout
742 \begin_layout Standard
743 Return value:
744 \end_layout
746 \begin_layout Itemize
747 width: number : The width of the tilemap in tiles.
748 \end_layout
750 \begin_layout Itemize
751 height: number: The height of the tilemap in tiles.
752 \end_layout
754 \begin_layout Standard
755 Get size of tilemap in tiles.
756 \end_layout
758 \begin_layout Subsubsection
759 TILEMAP:getcsize: Query tilemap cell size
760 \end_layout
762 \begin_layout Itemize
763 Syntax: width, height tmap:getcsize()
764 \end_layout
766 \begin_layout Standard
767 Parameters:
768 \end_layout
770 \begin_layout Itemize
771 tmap: TILEMAP: The tilemap to query.
772 \end_layout
774 \begin_layout Standard
775 Return value:
776 \end_layout
778 \begin_layout Itemize
779 width: number: The width of tilemap tile in pixels.
780 \end_layout
782 \begin_layout Itemize
783 height: number: The height of tilemap tile in pixels.
784 \end_layout
786 \begin_layout Standard
787 Get size of each tilemap tile in pixels.
788 \end_layout
790 \begin_layout Subsubsection
791 TILEMAP:get: Query tilemap tile
792 \end_layout
794 \begin_layout Itemize
795 Syntax: bitmap, palette tmap:get(x, y)
796 \end_layout
798 \begin_layout Standard
799 Parameters:
800 \end_layout
802 \begin_layout Itemize
803 tmap: TILEMAP: The tilemap to query.
804 \end_layout
806 \begin_layout Itemize
807 x: number: The x-coordinate of tile to query.
808 \end_layout
810 \begin_layout Itemize
811 y: number: The y-coordinate of tile to query.
812 \end_layout
814 \begin_layout Standard
815 Return value:
816 \end_layout
818 \begin_layout Itemize
819 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
820 \end_layout
822 \begin_layout Itemize
823 palette: The palette (PALETTE) associated with indexed-color bitmap, if
824  any.
825  Otherwise nil.
826 \end_layout
828 \begin_layout Standard
829 Return the contents of tile at <x>,<y>.
830 \end_layout
832 \begin_layout Subsubsection
833 TILEMAP:set: Set tilemap cell
834 \end_layout
836 \begin_layout Itemize
837 Syntax: tmap:set(x, y)
838 \end_layout
840 \begin_layout Itemize
841 Syntax: tmap:set(x, y, bitmap)
842 \end_layout
844 \begin_layout Itemize
845 Syntax: tmap:set(x, y, bitmap, palette)
846 \end_layout
848 \begin_layout Standard
849 Parameters:
850 \end_layout
852 \begin_layout Itemize
853 tmap: TILEMAP: The tilemap to manipulate.
854 \end_layout
856 \begin_layout Itemize
857 number x: The x-coordinate of tile to set.
858 \end_layout
860 \begin_layout Itemize
861 number y: The y-coordinate of tile to set.
862 \end_layout
864 \begin_layout Itemize
865 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
866 \end_layout
868 \begin_layout Itemize
869 palette: PALETTE: The associated palette for bitmap.
870 \end_layout
872 \begin_layout Standard
873 Set the contents of tile <x>,<y>.
874  If no <bitmap> is given, clears the tile.
875  Otherwise sets the tile to contain bitmap <bitmap> with associated palette
876  <palette>.
877 \end_layout
879 \begin_layout Itemize
880 Specifying index bitmap <bitmap> without palette <palette> causes an error.
881 \end_layout
883 \begin_layout Subsubsection
884 TILEMAP:scroll: Scroll tilemap
885 \end_layout
887 \begin_layout Itemize
888 Syntax: tmap:scroll(ox, oy);
889 \end_layout
891 \begin_layout Itemize
892 Syntax: tmap:scroll(ox, oy, x, y, w, h);
893 \end_layout
895 \begin_layout Itemize
896 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
897 \end_layout
899 \begin_layout Standard
900 Parameters:
901 \end_layout
903 \begin_layout Itemize
904 tmap: TILEMAP: The tilemap to manipulate.
905 \end_layout
907 \begin_layout Itemize
908 ox: number: The number of tiles to scroll horizontally (positive is to right).
909 \end_layout
911 \begin_layout Itemize
912 oy: number: The number of tiles to scroll vertically (positive is to down).
913 \end_layout
915 \begin_layout Itemize
916 x: number: The left edge of scroll window.
917 \end_layout
919 \begin_layout Itemize
920 y: number: The top edge of scroll window.
921 \end_layout
923 \begin_layout Itemize
924 w: number: The width of scroll window.
925 \end_layout
927 \begin_layout Itemize
928 h: number: The height of scroll window.
929 \end_layout
931 \begin_layout Itemize
932 circ_x: boolean: If true, treat the window as circular in horizontal direction.
933 \end_layout
935 \begin_layout Itemize
936 circ_y: boolean: If true, treat the window as circular in vertical direction.
937 \end_layout
939 \begin_layout Standard
940 Scroll the specified tilemap <tmap> by <ox>,<oy>.
941  If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
942  <circ_x> and <circ_y> control if scroll is circular or not.
943 \end_layout
945 \begin_layout Itemize
946 Specifying out-of-range window causes an error.
947 \end_layout
949 \begin_layout Subsubsection
950 TILEMAP:draw: Draw tilemap
951 \end_layout
953 \begin_layout Itemize
954 Name: tmap:draw(x, y)
955 \end_layout
957 \begin_layout Itemize
958 Name: tmap:draw(x, y, x0, y0, w, h)
959 \end_layout
961 \begin_layout Standard
962 Parameters:
963 \end_layout
965 \begin_layout Itemize
966 tmap: TILEMAP: The tilemap to draw.
967 \end_layout
969 \begin_layout Itemize
970 x: The x coordinate on screen to draw to.
971 \end_layout
973 \begin_layout Itemize
974 y: The y coordinate on screen to draw to.
975 \end_layout
977 \begin_layout Itemize
978 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
979 \end_layout
981 \begin_layout Itemize
982 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
983 \end_layout
985 \begin_layout Itemize
986 w: number: The width to draw (in pixels).
987 \end_layout
989 \begin_layout Itemize
990 h: number: The height to draw (in pixels).
991 \end_layout
993 \begin_layout Standard
994 Draw tilemap <tmap> to screen at <x>,<y>.
995  If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
996 \end_layout
998 \begin_layout Itemize
999 This method requires a rendering context to work.
1000 \end_layout
1002 \begin_layout Standard
1003 \begin_inset Newpage pagebreak
1004 \end_inset
1007 \end_layout
1009 \begin_layout Subsection
1010 RENDERCTX: Off-screen rendering context
1011 \end_layout
1013 \begin_layout Standard
1014 Object acting as off-screen rendering context.
1015 \end_layout
1017 \begin_layout Subsubsection
1018 Static function new: Create a render queue
1019 \end_layout
1021 \begin_layout Itemize
1022 Syntax: renderctx gui.renderctx.new(width, height);
1023 \end_layout
1025 \begin_layout Itemize
1026 Syntax: renderctx classes.RENDERCTX.new(width, height);
1027 \end_layout
1029 \begin_layout Itemize
1030 Deprecated: renderctx gui.renderq_new(width, height);
1031 \end_layout
1033 \begin_layout Standard
1034 Parameters:
1035 \end_layout
1037 \begin_layout Itemize
1038 width: number: The notional width of the game area.
1039 \end_layout
1041 \begin_layout Itemize
1042 height: number: The notional height of the game area.
1043 \end_layout
1045 \begin_layout Standard
1046 Returns:
1047 \end_layout
1049 \begin_layout Itemize
1050 rendectx: RENDERCTX: The newly created render context.
1051 \end_layout
1053 \begin_layout Standard
1054 Create a render context with reported size <width>*<height> and return it.
1055 \end_layout
1057 \begin_layout Subsubsection
1058 Static function setnull: Reset to default queue
1059 \end_layout
1061 \begin_layout Itemize
1062 Syntax: gui.renderctx.setnull()
1063 \end_layout
1065 \begin_layout Itemize
1066 Syntax: classes.RENDERCTX:setnull()
1067 \end_layout
1069 \begin_layout Itemize
1070 Deprecated: gui.renderq_set()
1071 \end_layout
1073 \begin_layout Standard
1074 Reset the used render context back to default for the executing callback:
1075 \end_layout
1077 \begin_layout Itemize
1078 The default for paint callback is the screen
1079 \end_layout
1081 \begin_layout Itemize
1082 The default for video callback is the video frame
1083 \end_layout
1085 \begin_layout Itemize
1086 The default otherwise is nothing.
1087 \end_layout
1089 \begin_layout Subsubsection
1090 Method clear: Clear a render queue
1091 \end_layout
1093 \begin_layout Itemize
1094 Syntax: renderctx:clear()
1095 \end_layout
1097 \begin_layout Itemize
1098 Deprecated: gui.renderq_clear(renderctx)
1099 \end_layout
1101 \begin_layout Standard
1102 Parameters:
1103 \end_layout
1105 \begin_layout Itemize
1106 renderctx: RENDERCTX: The render queue to clear.
1107 \end_layout
1109 \begin_layout Standard
1110 Clear all drawing from the context.
1111 \end_layout
1113 \begin_layout Subsubsection
1114 Method set: Change active render context
1115 \end_layout
1117 \begin_layout Itemize
1118 Syntax: renderctx:set()
1119 \end_layout
1121 \begin_layout Itemize
1122 Deprecated: gui.renderq_set(renderctx)
1123 \end_layout
1125 \begin_layout Standard
1126 Parameters:
1127 \end_layout
1129 \begin_layout Itemize
1130 renderctx: RENDERCTX: The render queue to use.
1131 \end_layout
1133 \begin_layout Standard
1134 Switch the current rendering context <renderctx>.
1135 \end_layout
1137 \begin_layout Subsubsection
1138 Method run: Draw all objects in context to another
1139 \end_layout
1141 \begin_layout Itemize
1142 Syntax: renderctx:run()
1143 \end_layout
1145 \begin_layout Itemize
1146 Deprecated: gui.renderq_run(renderctx)
1147 \end_layout
1149 \begin_layout Standard
1150 Parameters:
1151 \end_layout
1153 \begin_layout Itemize
1154 renderctx: RENDERCTX: The render context to overlay.
1155 \end_layout
1157 \begin_layout Standard
1158 Overlay the specified render context <context> upon the active rendering
1159  context.
1160 \end_layout
1162 \begin_layout Itemize
1163 Trying to overlay rendering context upon itself is a bad idea.
1164 \end_layout
1166 \begin_layout Subsubsection
1167 Method render: Render a contex to bitmap
1168 \end_layout
1170 \begin_layout Itemize
1171 Syntax: bitmap renderctx:render()
1172 \end_layout
1174 \begin_layout Standard
1175 Parameters:
1176 \end_layout
1178 \begin_layout Itemize
1179 renderctx: RENDERCTX: The context to render.
1180 \end_layout
1182 \begin_layout Standard
1183 Returns:
1184 \end_layout
1186 \begin_layout Itemize
1187 bitmap: DBITMAP: The rendered bitmap.
1188 \end_layout
1190 \begin_layout Standard
1191 Render the specified context <renderctx> to a new bitmap.
1192 \end_layout
1194 \begin_layout Itemize
1195 The size of bitmap will be nominal game area size, plus any set gaps.
1196 \end_layout
1198 \begin_layout Itemize
1199 This method does not require active rendering context.
1200 \end_layout
1202 \begin_layout Subsubsection
1203 Method synchronous_repaint: Paint screen now
1204 \end_layout
1206 \begin_layout Itemize
1207 Syntax: renderctx:synchronous_repaint()
1208 \end_layout
1210 \begin_layout Itemize
1211 Deprecated: gui.synchronous_repaint(renderctx)
1212 \end_layout
1214 \begin_layout Standard
1215 Parameters:
1216 \end_layout
1218 \begin_layout Itemize
1219 renderctx: RENDERCTX: The context to paint.
1220 \end_layout
1222 \begin_layout Standard
1223 Immediately redraw the screen with game overlayed by drawings from context
1224  <renderctx>.
1225 \end_layout
1227 \begin_layout Itemize
1228 This does not require active rendering context.
1229 \end_layout
1231 \begin_layout Itemize
1232 Will not cause paint callback to be invoked.
1233 \end_layout
1235 \begin_layout Standard
1236 \begin_inset Newpage pagebreak
1237 \end_inset
1240 \end_layout
1242 \begin_layout Subsection
1243 PALETTE: Color palette for indexed image
1244 \end_layout
1246 \begin_layout Subsubsection
1247 Static function new: Create a new palette
1248 \end_layout
1250 \begin_layout Itemize
1251 Syntax: palette gui.palette.new()
1252 \end_layout
1254 \begin_layout Itemize
1255 Syntax: palette classes.PALETTE.new()
1256 \end_layout
1258 \begin_layout Itemize
1259 Deprecated: palette gui.palette_new()
1260 \end_layout
1262 \begin_layout Standard
1263 Returns:
1264 \end_layout
1266 \begin_layout Itemize
1267 palette: PALETTE: The created palette.
1268 \end_layout
1270 \begin_layout Standard
1271 Create a new palette (with all colors transparent) and return it.
1272 \end_layout
1274 \begin_layout Subsubsection
1275 Static function load: Load a palette
1276 \end_layout
1278 \begin_layout Itemize
1279 Syntax: palette gui.palette.load(file, [base])
1280 \end_layout
1282 \begin_layout Itemize
1283 Syntax: palette classes.PALETTE.load(file, [base])
1284 \end_layout
1286 \begin_layout Itemize
1287 Deprecated: palette gui.palette_load(file, [base])
1288 \end_layout
1290 \begin_layout Standard
1291 Parameters:
1292 \end_layout
1294 \begin_layout Itemize
1295 string file: The file to load.
1296 \end_layout
1298 \begin_layout Itemize
1299 string base (optional): The base file to resolve file relative to.
1300 \end_layout
1302 \begin_layout Standard
1303 Returns:
1304 \end_layout
1306 \begin_layout Itemize
1307 palette: PALETTE: The loaded palette.
1308 \end_layout
1310 \begin_layout Standard
1311 Load a palette from file <file> (resolved relative to <base>).
1312 \end_layout
1314 \begin_layout Itemize
1315 The file format is a series of lines, each with following format:
1316 \end_layout
1318 \begin_deeper
1319 \begin_layout Itemize
1320 Blank or just whitespace: Ignored
1321 \end_layout
1323 \begin_layout Itemize
1324 First non-whitespace is '#': Ignored
1325 \end_layout
1327 \begin_layout Itemize
1328 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1329 \end_layout
1331 \begin_layout Itemize
1332 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1333  (0-256, 0 being fully transparent and 256 fully opaque).
1334 \end_layout
1336 \begin_layout Itemize
1337 transparent: Fully transparent color
1338 \end_layout
1340 \end_deeper
1341 \begin_layout Subsubsection
1342 Static function load_str: Load a palette from string
1343 \end_layout
1345 \begin_layout Itemize
1346 Syntax: palette gui.palette.load(data)
1347 \end_layout
1349 \begin_layout Itemize
1350 Syntax: palette classes.PALETTE.load(data)
1351 \end_layout
1353 \begin_layout Itemize
1354 Deprecated: palette gui.palette_load(data)
1355 \end_layout
1357 \begin_layout Standard
1358 Parameters:
1359 \end_layout
1361 \begin_layout Itemize
1362 string data: The palette data.
1363 \end_layout
1365 \begin_layout Standard
1366 Returns:
1367 \end_layout
1369 \begin_layout Itemize
1370 palette: PALETTE: The loaded palette.
1371 \end_layout
1373 \begin_layout Standard
1374 Like PALETTE:load, but instead of reading palette from file, reads it from
1375  a string.
1376 \end_layout
1378 \begin_layout Subsubsection
1379 Method set: Set palette entry
1380 \end_layout
1382 \begin_layout Itemize
1383 Syntax: palette:set(index, color)
1384 \end_layout
1386 \begin_layout Itemize
1387 Deprecated: gui.palette_set(palette, ...)
1388 \end_layout
1390 \begin_layout Standard
1391 Parameters:
1392 \end_layout
1394 \begin_layout Itemize
1395 palette: PALETTE: The palette to manipulate
1396 \end_layout
1398 \begin_layout Itemize
1399 index: number: The index of color to set (0-65535).
1400 \end_layout
1402 \begin_layout Itemize
1403 color: number/string: The color value to set.
1404 \end_layout
1406 \begin_layout Standard
1407 Set palette <palette> index <index> to color <color>.
1408 \end_layout
1410 \begin_layout Subsubsection
1411 Method hash: Hash a palette
1412 \end_layout
1414 \begin_layout Itemize
1415 Syntax: hash palette:hash()
1416 \end_layout
1418 \begin_layout Itemize
1419 Deprecated: hash gui.palette_hash(palette)
1420 \end_layout
1422 \begin_layout Standard
1423 Parameters:
1424 \end_layout
1426 \begin_layout Itemize
1427 palette: The palette to hash.
1428 \end_layout
1430 \begin_layout Standard
1431 Return value:
1432 \end_layout
1434 \begin_layout Itemize
1435 hash: string: 64-hex digit hash.
1436 \end_layout
1438 \begin_layout Standard
1439 Obtain crypto-grade hash of palette data of <palette>.
1440 \end_layout
1442 \begin_layout Itemize
1443 All colors after the last non-transparent one are ignored.
1444 \end_layout
1446 \begin_layout Subsubsection
1447 Method adjust_transparency: Adjust transparency
1448 \end_layout
1450 \begin_layout Itemize
1451 Syntax: palette:adjust_transparency(newvalue)
1452 \end_layout
1454 \begin_layout Itemize
1455 Deprecated: gui.adjust_transparency(palette, ...)
1456 \end_layout
1458 \begin_layout Standard
1459 Parameters:
1460 \end_layout
1462 \begin_layout Itemize
1463 palette: PALETTE: The palette to adjust.
1464 \end_layout
1466 \begin_layout Itemize
1467 Number adj: The factor to multiply opaqueness with times 256.
1468 \end_layout
1470 \begin_layout Standard
1471 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1472 \end_layout
1474 \begin_layout Standard
1475 \begin_inset Newpage pagebreak
1476 \end_inset
1479 \end_layout
1481 \begin_layout Subsection
1482 BITMAP: Indexed-color bitmap
1483 \end_layout
1485 \begin_layout Subsubsection
1486 Static function new: Create a new bitmap
1487 \end_layout
1489 \begin_layout Itemize
1490 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1491 \end_layout
1493 \begin_layout Itemize
1494 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1495 \end_layout
1497 \begin_layout Itemize
1498 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1499 \end_layout
1501 \begin_layout Standard
1502 Parameters:
1503 \end_layout
1505 \begin_layout Itemize
1506 w: number: The width of bitmap to create in pixels.
1507 \end_layout
1509 \begin_layout Itemize
1510 h: number: The height of bitmap to create in pixels.
1511 \end_layout
1513 \begin_layout Itemize
1514 false: boolean: Constant boolean false.
1515 \end_layout
1517 \begin_layout Itemize
1518 fillcolor: number: The initial fill index.
1519  Default 0 if not specified.
1520 \end_layout
1522 \begin_layout Standard
1523 Create a new bitmap of size <w>*<h>.
1524  Fill the bitmap with color index <fillcolor>.
1525 \end_layout
1527 \begin_layout Subsubsection
1528 Method draw: Draw a bitmap
1529 \end_layout
1531 \begin_layout Itemize
1532 Syntax: bitmap:draw(x, y, palette)
1533 \end_layout
1535 \begin_layout Itemize
1536 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1537 \end_layout
1539 \begin_layout Standard
1540 Parameters:
1541 \end_layout
1543 \begin_layout Itemize
1544 bitmap: BITMAP: The bitmap to draw
1545 \end_layout
1547 \begin_layout Itemize
1548 x: number: The x-coordinate on screen.
1549 \end_layout
1551 \begin_layout Itemize
1552 y: number: The y-coordinate on screen.
1553 \end_layout
1555 \begin_layout Itemize
1556 palette: The palette to use for drawing.
1557 \end_layout
1559 \begin_layout Standard
1560 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1561 \end_layout
1563 \begin_layout Subsubsection
1564 Method pset: Set pixel in bitmap
1565 \end_layout
1567 \begin_layout Itemize
1568 Syntax: bitmap:pset(x, y, color)
1569 \end_layout
1571 \begin_layout Itemize
1572 Deprecaed: gui.bitmap_pset(bitmap, ...)
1573 \end_layout
1575 \begin_layout Standard
1576 Parameters:
1577 \end_layout
1579 \begin_layout Itemize
1580 bitmap: BITMAP: The bitmap to manipulate.
1581 \end_layout
1583 \begin_layout Itemize
1584 x: number: x-coordinate of pixel to set.
1585 \end_layout
1587 \begin_layout Itemize
1588 y: number: y-coordinate of pixel to set.
1589 \end_layout
1591 \begin_layout Itemize
1592 color: number: The color index to set.
1593 \end_layout
1595 \begin_layout Standard
1596 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1597 \end_layout
1599 \begin_layout Subsubsection
1600 Method pget: Get pixel in bitmap
1601 \end_layout
1603 \begin_layout Itemize
1604 Syntax: color bitmap:pget(x,y)
1605 \end_layout
1607 \begin_layout Itemize
1608 Deprecated: color gui.bitmap_pget(bitmap, ...)
1609 \end_layout
1611 \begin_layout Standard
1612 Parameters:
1613 \end_layout
1615 \begin_layout Itemize
1616 bitmap: BITMAP: The bitmap to query.
1617 \end_layout
1619 \begin_layout Itemize
1620 x: number: x-coordinate of pixel to get.
1621 \end_layout
1623 \begin_layout Itemize
1624 y: number: y-coordinate of pixel to get.
1625 \end_layout
1627 \begin_layout Standard
1628 Returns:
1629 \end_layout
1631 \begin_layout Itemize
1632 color: number: The color index in specified pixel.
1633 \end_layout
1635 \begin_layout Standard
1636 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1637 \end_layout
1639 \begin_layout Subsubsection
1640 Method size: Get size of bitmap
1641 \end_layout
1643 \begin_layout Itemize
1644 Syntax: width, height bitmap:size()
1645 \end_layout
1647 \begin_layout Itemize
1648 Syntax: width, height gui.bitmap_size(bitmap)
1649 \end_layout
1651 \begin_layout Standard
1652 Parameters:
1653 \end_layout
1655 \begin_layout Itemize
1656 bitmap: BITMAP: The bitmap to query.
1657 \end_layout
1659 \begin_layout Standard
1660 Returns:
1661 \end_layout
1663 \begin_layout Itemize
1664 width: number: The width of the bitmap.
1665 \end_layout
1667 \begin_layout Itemize
1668 height: number: The height of the bitmap.
1669 \end_layout
1671 \begin_layout Standard
1672 Get size of bitmap <bitmap>.
1673 \end_layout
1675 \begin_layout Subsubsection
1676 Method blit: Blit a bitmap into another
1677 \end_layout
1679 \begin_layout Itemize
1680 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1681 \end_layout
1683 \begin_layout Itemize
1684 Deprecated: gui.bitmap_blit(dest, ...)
1685 \end_layout
1687 \begin_layout Standard
1688 Parameters:
1689 \end_layout
1691 \begin_layout Itemize
1692 dest: BITMAP: The target bitmap to blit to.
1693 \end_layout
1695 \begin_layout Itemize
1696 dx: number: The x-coordinate in target.
1697 \end_layout
1699 \begin_layout Itemize
1700 dy: number: The y-coordinate in target.
1701 \end_layout
1703 \begin_layout Itemize
1704 src: BITMAP: The source bitmap.
1705 \end_layout
1707 \begin_layout Itemize
1708 sx: number: The x-coordinate in source.
1709 \end_layout
1711 \begin_layout Itemize
1712 sy: number: The y-coordinate in source.
1713 \end_layout
1715 \begin_layout Itemize
1716 w: number: The width of area to blit.
1717 \end_layout
1719 \begin_layout Itemize
1720 h: number: The height of area to blit.
1721 \end_layout
1723 \begin_layout Itemize
1724 ck: number: The color key.
1725  Pixels with this index are not copied.
1726 \end_layout
1728 \begin_deeper
1729 \begin_layout Itemize
1730 If none is specified, all pixels are copied.
1731 \end_layout
1733 \end_deeper
1734 \begin_layout Standard
1735 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1736  <dx>,<dy>.
1737  If a color key <ck> is specified, pixels of that color are not copied.
1738 \end_layout
1740 \begin_layout Subsubsection
1741 Method blit_scaled: Blit a bitmap into another with scaling
1742 \end_layout
1744 \begin_layout Itemize
1745 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1746 \end_layout
1748 \begin_layout Itemize
1749 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1750 \end_layout
1752 \begin_layout Standard
1753 Parameters:
1754 \end_layout
1756 \begin_layout Itemize
1757 dest: BITMAP: The target bitmap to blit to.
1758 \end_layout
1760 \begin_layout Itemize
1761 dx: number: The x-coordinate in target.
1762 \end_layout
1764 \begin_layout Itemize
1765 dy: number: The y-coordinate in target.
1766 \end_layout
1768 \begin_layout Itemize
1769 src: BITMAP: The source bitmap.
1770 \end_layout
1772 \begin_layout Itemize
1773 sx: number: The x-coordinate in source.
1774 \end_layout
1776 \begin_layout Itemize
1777 sy: number: The y-coordinate in source.
1778 \end_layout
1780 \begin_layout Itemize
1781 w: number: The width of area to blit.
1782 \end_layout
1784 \begin_layout Itemize
1785 h: number: The height of area to blit.
1786 \end_layout
1788 \begin_layout Itemize
1789 hscl: number: Horizontal scale factor (integer).
1790 \end_layout
1792 \begin_layout Itemize
1793 vscl: number: Vertical scale factor (integer).
1794  Defaults to the same as <hscl>.
1795 \end_layout
1797 \begin_layout Itemize
1798 ck: number: The color key.
1799  Pixels with this index are not copied.
1800 \end_layout
1802 \begin_deeper
1803 \begin_layout Itemize
1804 If none is specified, all pixels are copied.
1805 \end_layout
1807 \end_deeper
1808 \begin_layout Standard
1809 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1810  neighbor) by factor of <hscl>*<vscl>.
1811 \end_layout
1813 \begin_layout Subsubsection
1814 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1815 \end_layout
1817 \begin_layout Itemize
1818 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1819 \end_layout
1821 \begin_layout Itemize
1822 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1823 \end_layout
1825 \begin_layout Standard
1826 Parameters:
1827 \end_layout
1829 \begin_layout Itemize
1830 dest: BITMAP: The target bitmap to blit to.
1831 \end_layout
1833 \begin_layout Itemize
1834 dx: number: The x-coordinate in target.
1835 \end_layout
1837 \begin_layout Itemize
1838 dy: number: The y-coordinate in target.
1839 \end_layout
1841 \begin_layout Itemize
1842 src: BITMAP: The source bitmap.
1843 \end_layout
1845 \begin_layout Itemize
1846 sx: number: The x-coordinate in source.
1847 \end_layout
1849 \begin_layout Itemize
1850 sy: number: The y-coordinate in source.
1851 \end_layout
1853 \begin_layout Itemize
1854 w: number: The width of area to blit.
1855 \end_layout
1857 \begin_layout Itemize
1858 h: number: The height of area to blit.
1859 \end_layout
1861 \begin_layout Itemize
1862 operator: string: The operator to use.
1863 \end_layout
1865 \begin_deeper
1866 \begin_layout Itemize
1867 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
1868  DestOut, Clear or Xor.
1869 \end_layout
1871 \end_deeper
1872 \begin_layout Standard
1873 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
1874  operator.
1876 \end_layout
1878 \begin_layout Itemize
1879 Color index 0 in source and target is treated as background.
1880 \end_layout
1882 \begin_layout Subsubsection
1883 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
1884  Porter-Duff composition
1885 \end_layout
1887 \begin_layout Itemize
1888 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
1889  operator)
1890 \end_layout
1892 \begin_layout Itemize
1893 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
1894 \end_layout
1896 \begin_layout Standard
1897 Parameters:
1898 \end_layout
1900 \begin_layout Itemize
1901 dest: BITMAP: The target bitmap to blit to.
1902 \end_layout
1904 \begin_layout Itemize
1905 dx: number: The x-coordinate in target.
1906 \end_layout
1908 \begin_layout Itemize
1909 dy: number: The y-coordinate in target.
1910 \end_layout
1912 \begin_layout Itemize
1913 src: BITMAP: The source bitmap.
1914 \end_layout
1916 \begin_layout Itemize
1917 sx: number: The x-coordinate in source.
1918 \end_layout
1920 \begin_layout Itemize
1921 sy: number: The y-coordinate in source.
1922 \end_layout
1924 \begin_layout Itemize
1925 w: number: The width of area to blit.
1926 \end_layout
1928 \begin_layout Itemize
1929 h: number: The height of area to blit.
1930 \end_layout
1932 \begin_layout Itemize
1933 hscl: number: Horizontal scale factor (integer).
1934 \end_layout
1936 \begin_layout Itemize
1937 vscl: number: Vertical scale factor (integer).
1938  Defaults to the same as <hscl>.
1939 \end_layout
1941 \begin_layout Itemize
1942 operator: string: The operator to use.
1943 \end_layout
1945 \begin_deeper
1946 \begin_layout Itemize
1947 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
1948  DestOut, Clear or Xor.
1949 \end_layout
1951 \end_deeper
1952 \begin_layout Standard
1953 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
1954  like BITMAP:blit_scaled.
1955 \end_layout
1957 \begin_layout Subsubsection
1958 Method blit_priority: Blit a bitmap into another with color priority
1959 \end_layout
1961 \begin_layout Itemize
1962 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
1963 \end_layout
1965 \begin_layout Itemize
1966 Deprecated: gui.bitmap_blit_priority(dest, ...)
1967 \end_layout
1969 \begin_layout Standard
1970 Parameters:
1971 \end_layout
1973 \begin_layout Itemize
1974 dest: BITMAP: The target bitmap to blit to.
1975 \end_layout
1977 \begin_layout Itemize
1978 dx: number: The x-coordinate in target.
1979 \end_layout
1981 \begin_layout Itemize
1982 dy: number: The y-coordinate in target.
1983 \end_layout
1985 \begin_layout Itemize
1986 src: BITMAP: The source bitmap.
1987 \end_layout
1989 \begin_layout Itemize
1990 sx: number: The x-coordinate in source.
1991 \end_layout
1993 \begin_layout Itemize
1994 sy: number: The y-coordinate in source.
1995 \end_layout
1997 \begin_layout Itemize
1998 w: number: The width of area to blit.
1999 \end_layout
2001 \begin_layout Itemize
2002 h: number: The height of area to blit.
2003 \end_layout
2005 \begin_layout Standard
2006 Like BITMAP:blit, but only copy pixels where source color index is greater
2007  than destination color index.
2008 \end_layout
2010 \begin_layout Subsubsection
2011 Method blit_scaled_priority: Blit a bitmap into another with color priority
2012  and scaling
2013 \end_layout
2015 \begin_layout Itemize
2016 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2017 \end_layout
2019 \begin_layout Itemize
2020 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2021 \end_layout
2023 \begin_layout Standard
2024 Parameters:
2025 \end_layout
2027 \begin_layout Itemize
2028 dest: BITMAP: The target bitmap to blit to.
2029 \end_layout
2031 \begin_layout Itemize
2032 dx: number: The x-coordinate in target.
2033 \end_layout
2035 \begin_layout Itemize
2036 dy: number: The y-coordinate in target.
2037 \end_layout
2039 \begin_layout Itemize
2040 src: BITMAP: The source bitmap.
2041 \end_layout
2043 \begin_layout Itemize
2044 sx: number: The x-coordinate in source.
2045 \end_layout
2047 \begin_layout Itemize
2048 sy: number: The y-coordinate in source.
2049 \end_layout
2051 \begin_layout Itemize
2052 w: number: The width of area to blit.
2053 \end_layout
2055 \begin_layout Itemize
2056 h: number: The height of area to blit.
2057 \end_layout
2059 \begin_layout Itemize
2060 hscl: number: Horizontal scale factor (integer).
2061 \end_layout
2063 \begin_layout Itemize
2064 vscl: number: Vertical scale factor (integer).
2065  Defaults to the same as <hscl>.
2066 \end_layout
2068 \begin_layout Standard
2069 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2070 caled.
2071 \end_layout
2073 \begin_layout Subsubsection
2074 Method save_png: Save a bitmap to PNG
2075 \end_layout
2077 \begin_layout Itemize
2078 Syntax: bitmap:save_png(filename, [base], palette)
2079 \end_layout
2081 \begin_layout Itemize
2082 Syntax: data bitmap:save_png(palette)
2083 \end_layout
2085 \begin_layout Itemize
2086 Deprecated: ...
2087  gui.bitmap_save_png(bitmap, ...)
2088 \end_layout
2090 \begin_layout Standard
2091 Parameters:
2092 \end_layout
2094 \begin_layout Itemize
2095 bitmap: BITMAP: The bitmap to save.
2096 \end_layout
2098 \begin_layout Itemize
2099 filename: string: The filename to save to.
2100 \end_layout
2102 \begin_layout Itemize
2103 base: string: The base filename is resolved relative to.
2104 \end_layout
2106 \begin_layout Itemize
2107 palette: PALETTE: The palette to use.
2108 \end_layout
2110 \begin_layout Standard
2111 Return value:
2112 \end_layout
2114 \begin_layout Itemize
2115 data: string: BASE64 encoded PNG data.
2116 \end_layout
2118 \begin_layout Standard
2119 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2120  to <base>) or return BASE64 encoding of it.
2121 \end_layout
2123 \begin_layout Subsubsection
2124 Method hash: Hash a bitmap
2125 \end_layout
2127 \begin_layout Itemize
2128 Syntax: hash bitmap:hash()
2129 \end_layout
2131 \begin_layout Itemize
2132 Deprecated: hash bitmap:hash(bitmap)
2133 \end_layout
2135 \begin_layout Standard
2136 Parameters:
2137 \end_layout
2139 \begin_layout Itemize
2140 bitmap: BITMAP: The bitmap to hash.
2141 \end_layout
2143 \begin_layout Standard
2144 Return value:
2145 \end_layout
2147 \begin_layout Itemize
2148 hash: string: 64-hex digit hash
2149 \end_layout
2151 \begin_layout Standard
2152 Hashes bitmap <bitmap> and returns crypto-strong hash.
2154 \end_layout
2156 \begin_layout Itemize
2157 Color order in bitmap is significant.
2158 \end_layout
2160 \begin_layout Standard
2161 \begin_inset Newpage pagebreak
2162 \end_inset
2165 \end_layout
2167 \begin_layout Subsection
2168 DBITMAP: Direct-color bitmap
2169 \end_layout
2171 \begin_layout Subsubsection
2172 Static function: new: Create a new bitmap
2173 \end_layout
2175 \begin_layout Itemize
2176 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2177 \end_layout
2179 \begin_layout Itemize
2180 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2181 \end_layout
2183 \begin_layout Itemize
2184 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2185 \end_layout
2187 \begin_layout Standard
2188 Parameters:
2189 \end_layout
2191 \begin_layout Itemize
2192 w: number: The width of new bitmap.
2193 \end_layout
2195 \begin_layout Itemize
2196 h: number: The height of new bitmap.
2197 \end_layout
2199 \begin_layout Itemize
2200 true: boolean: Fixed boolean true
2201 \end_layout
2203 \begin_layout Itemize
2204 fillcolor: The color to fill the bitmap with (default transparent).
2205 \end_layout
2207 \begin_layout Standard
2208 Return value:
2209 \end_layout
2211 \begin_layout Itemize
2212 bitmap: DBITMAP: The new bitmap.
2213 \end_layout
2215 \begin_layout Standard
2216 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2217  <fillcolor>.
2218 \end_layout
2220 \begin_layout Subsubsection
2221 Method draw: Draw a bitmap
2222 \end_layout
2224 \begin_layout Itemize
2225 Syntax: bitmap.draw(x, y)
2226 \end_layout
2228 \begin_layout Itemize
2229 Deprecated: gui.bitmap_draw(x, y, bitmap)
2230 \end_layout
2232 \begin_layout Standard
2233 Parameters:
2234 \end_layout
2236 \begin_layout Itemize
2237 bitmap: DBITMAP: The bitmap to draw.
2238 \end_layout
2240 \begin_layout Itemize
2241 x: number: X-coordinate on screen.
2242 \end_layout
2244 \begin_layout Itemize
2245 y: number: Y-coordinate on screen.
2246 \end_layout
2248 \begin_layout Standard
2249 Draw bitmap <bitmap> on screen at <x>,<y>.
2250 \end_layout
2252 \begin_layout Subsubsection
2253 Method pset: Set pixel in bitmap
2254 \end_layout
2256 \begin_layout Itemize
2257 Syntax: bitmap:pset(x, y, color)
2258 \end_layout
2260 \begin_layout Itemize
2261 Deprecaed: gui.bitmap_pset(bitmap, ...)
2262 \end_layout
2264 \begin_layout Standard
2265 Parameters:
2266 \end_layout
2268 \begin_layout Itemize
2269 bitmap: DBITMAP: The bitmap to manipulate.
2270 \end_layout
2272 \begin_layout Itemize
2273 x: number: x-coordinate of pixel to set.
2274 \end_layout
2276 \begin_layout Itemize
2277 y: number: y-coordinate of pixel to set.
2278 \end_layout
2280 \begin_layout Itemize
2281 color: number/string: The color to set.
2282 \end_layout
2284 \begin_layout Standard
2285 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2286 \end_layout
2288 \begin_layout Subsubsection
2289 Method pget: Get pixel in bitmap
2290 \end_layout
2292 \begin_layout Itemize
2293 Syntax: color bitmap:pget(x,y)
2294 \end_layout
2296 \begin_layout Itemize
2297 Deprecated: color gui.bitmap_pget(bitmap, ...)
2298 \end_layout
2300 \begin_layout Standard
2301 Parameters:
2302 \end_layout
2304 \begin_layout Itemize
2305 bitmap: DBITMAP: The bitmap to query.
2306 \end_layout
2308 \begin_layout Itemize
2309 x: number: x-coordinate of pixel to get.
2310 \end_layout
2312 \begin_layout Itemize
2313 y: number: y-coordinate of pixel to get.
2314 \end_layout
2316 \begin_layout Standard
2317 Returns:
2318 \end_layout
2320 \begin_layout Itemize
2321 color: number: The color of specified pixel.
2322 \end_layout
2324 \begin_layout Standard
2325 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2326 \end_layout
2328 \begin_layout Subsubsection
2329 Method size: Get size of bitmap
2330 \end_layout
2332 \begin_layout Itemize
2333 Syntax: width, height bitmap:size()
2334 \end_layout
2336 \begin_layout Itemize
2337 Syntax: width, height gui.bitmap_size(bitmap)
2338 \end_layout
2340 \begin_layout Standard
2341 Parameters:
2342 \end_layout
2344 \begin_layout Itemize
2345 bitmap: DBITMAP: The bitmap to query.
2346 \end_layout
2348 \begin_layout Standard
2349 Returns:
2350 \end_layout
2352 \begin_layout Itemize
2353 width: number: The width of the bitmap.
2354 \end_layout
2356 \begin_layout Itemize
2357 height: number: The height of the bitmap.
2358 \end_layout
2360 \begin_layout Standard
2361 Get size of bitmap <bitmap>.
2362 \end_layout
2364 \begin_layout Subsubsection
2365 Method blit: Blit a bitmap into another
2366 \end_layout
2368 \begin_layout Itemize
2369 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2370 \end_layout
2372 \begin_layout Itemize
2373 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2374 \end_layout
2376 \begin_layout Itemize
2377 Deprecated: gui.bitmap_blit(dest, ...)
2378 \end_layout
2380 \begin_layout Standard
2381 Parameters:
2382 \end_layout
2384 \begin_layout Itemize
2385 dest: DBITMAP: The target bitmap to blit to.
2386 \end_layout
2388 \begin_layout Itemize
2389 dx: number: The x-coordinate in target.
2390 \end_layout
2392 \begin_layout Itemize
2393 dy: number: The y-coordinate in target.
2394 \end_layout
2396 \begin_layout Itemize
2397 src: BITMAP/DBITMAP: The source bitmap.
2398 \end_layout
2400 \begin_layout Itemize
2401 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2402 \end_layout
2404 \begin_layout Itemize
2405 sx: number: The x-coordinate in source.
2406 \end_layout
2408 \begin_layout Itemize
2409 sy: number: The y-coordinate in source.
2410 \end_layout
2412 \begin_layout Itemize
2413 w: number: The width of area to blit.
2414 \end_layout
2416 \begin_layout Itemize
2417 h: number: The height of area to blit.
2418 \end_layout
2420 \begin_layout Itemize
2421 ck: number: The color key.
2422  Pixels with this index are not copied.
2423 \end_layout
2425 \begin_deeper
2426 \begin_layout Itemize
2427 If none is specified, all pixels are copied.
2428 \end_layout
2430 \begin_layout Itemize
2431 If <src> is paletted, this is color index, otherwise it is a color.
2432 \end_layout
2434 \end_deeper
2435 \begin_layout Standard
2436 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2437  if indexed) into <dest> at <dx>,<dy>.
2438  If a color key <ck> is specified, pixels of that color are not copied.
2439 \end_layout
2441 \begin_layout Subsubsection
2442 Method blit_scaled: Blit a bitmap into another with scaling
2443 \end_layout
2445 \begin_layout Itemize
2446 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2447 \end_layout
2449 \begin_layout Itemize
2450 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2451  [ck])
2452 \end_layout
2454 \begin_layout Itemize
2455 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2456 \end_layout
2458 \begin_layout Standard
2459 Parameters:
2460 \end_layout
2462 \begin_layout Itemize
2463 dest: DBITMAP: The target bitmap to blit to.
2464 \end_layout
2466 \begin_layout Itemize
2467 dx: number: The x-coordinate in target.
2468 \end_layout
2470 \begin_layout Itemize
2471 dy: number: The y-coordinate in target.
2472 \end_layout
2474 \begin_layout Itemize
2475 src: BITMAP/DBITMAP: The source bitmap.
2476 \end_layout
2478 \begin_layout Itemize
2479 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2480 \end_layout
2482 \begin_layout Itemize
2483 sx: number: The x-coordinate in source.
2484 \end_layout
2486 \begin_layout Itemize
2487 sy: number: The y-coordinate in source.
2488 \end_layout
2490 \begin_layout Itemize
2491 w: number: The width of area to blit.
2492 \end_layout
2494 \begin_layout Itemize
2495 h: number: The height of area to blit.
2496 \end_layout
2498 \begin_layout Itemize
2499 hscl: number: Horizontal scale factor (integer).
2500 \end_layout
2502 \begin_layout Itemize
2503 vscl: number: Vertical scale factor (integer).
2504  Defaults to the same as <hscl>.
2505 \end_layout
2507 \begin_layout Itemize
2508 ck: number: The color key.
2509  Pixels with this index are not copied.
2510 \end_layout
2512 \begin_deeper
2513 \begin_layout Itemize
2514 If none is specified, all pixels are copied.
2515 \end_layout
2517 \begin_layout Itemize
2518 If <src> is paletted, this is color index, otherwise it is a color.
2519 \end_layout
2521 \end_deeper
2522 \begin_layout Standard
2523 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2524  neighbor) by factor of <hscl>*<vscl>.
2525 \end_layout
2527 \begin_layout Subsubsection
2528 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2529 \end_layout
2531 \begin_layout Itemize
2532 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2533 \end_layout
2535 \begin_layout Itemize
2536 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2537 \end_layout
2539 \begin_layout Itemize
2540 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2541 \end_layout
2543 \begin_layout Standard
2544 Parameters:
2545 \end_layout
2547 \begin_layout Itemize
2548 dest: DBITMAP: The target bitmap to blit to.
2549 \end_layout
2551 \begin_layout Itemize
2552 dx: number: The x-coordinate in target.
2553 \end_layout
2555 \begin_layout Itemize
2556 dy: number: The y-coordinate in target.
2557 \end_layout
2559 \begin_layout Itemize
2560 src: BITMAP/DBITMAP: The source bitmap.
2561 \end_layout
2563 \begin_layout Itemize
2564 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2565 \end_layout
2567 \begin_layout Itemize
2568 sx: number: The x-coordinate in source.
2569 \end_layout
2571 \begin_layout Itemize
2572 sy: number: The y-coordinate in source.
2573 \end_layout
2575 \begin_layout Itemize
2576 w: number: The width of area to blit.
2577 \end_layout
2579 \begin_layout Itemize
2580 h: number: The height of area to blit.
2581 \end_layout
2583 \begin_layout Itemize
2584 operator: string: The operator to use.
2585 \end_layout
2587 \begin_deeper
2588 \begin_layout Itemize
2589 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2590  DestOut, Clear or Xor.
2591 \end_layout
2593 \end_deeper
2594 \begin_layout Standard
2595 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2596 f operator.
2598 \end_layout
2600 \begin_layout Itemize
2601 In target, fully transparent is background.
2602  In source, either fully transparent (if direct) or index 0 (if paletted)
2603  is treated as background.
2604 \end_layout
2606 \begin_layout Subsubsection
2607 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2608  Porter-Duff composition
2609 \end_layout
2611 \begin_layout Itemize
2612 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2613  operator)
2614 \end_layout
2616 \begin_layout Itemize
2617 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2618  [vscl], operator)
2619 \end_layout
2621 \begin_layout Itemize
2622 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2623 \end_layout
2625 \begin_layout Standard
2626 Parameters:
2627 \end_layout
2629 \begin_layout Itemize
2630 dest: DBITMAP: The target bitmap to blit to.
2631 \end_layout
2633 \begin_layout Itemize
2634 dx: number: The x-coordinate in target.
2635 \end_layout
2637 \begin_layout Itemize
2638 dy: number: The y-coordinate in target.
2639 \end_layout
2641 \begin_layout Itemize
2642 src: BITMAP/DBITMAP: The source bitmap.
2643 \end_layout
2645 \begin_layout Itemize
2646 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2647 \end_layout
2649 \begin_layout Itemize
2650 sx: number: The x-coordinate in source.
2651 \end_layout
2653 \begin_layout Itemize
2654 sy: number: The y-coordinate in source.
2655 \end_layout
2657 \begin_layout Itemize
2658 w: number: The width of area to blit.
2659 \end_layout
2661 \begin_layout Itemize
2662 h: number: The height of area to blit.
2663 \end_layout
2665 \begin_layout Itemize
2666 hscl: number: Horizontal scale factor (integer).
2667 \end_layout
2669 \begin_layout Itemize
2670 vscl: number: Vertical scale factor (integer).
2671  Defaults to the same as <hscl>.
2672 \end_layout
2674 \begin_layout Itemize
2675 operator: string: The operator to use.
2676 \end_layout
2678 \begin_deeper
2679 \begin_layout Itemize
2680 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2681  DestOut, Clear or Xor.
2682 \end_layout
2684 \end_deeper
2685 \begin_layout Standard
2686 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2687  like DBITMAP:blit_scaled.
2688 \end_layout
2690 \begin_layout Subsubsection
2691 Method adjust_transparency: Adjust transparency of bitmap
2692 \end_layout
2694 \begin_layout Itemize
2695 Syntax: bitmap:adjust_transparency(newvalue)
2696 \end_layout
2698 \begin_layout Itemize
2699 Deprecated: gui.adjust_transparency(bitmap, ...)
2700 \end_layout
2702 \begin_layout Standard
2703 Parameters:
2704 \end_layout
2706 \begin_layout Itemize
2707 bitmap: DBITMAP: The bitmap to adjust.
2708 \end_layout
2710 \begin_layout Itemize
2711 Number adj: The factor to multiply opaqueness with times 256.
2712 \end_layout
2714 \begin_layout Standard
2715 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2716 \end_layout
2718 \begin_layout Subsubsection
2719 Method save_png: Save a bitmap to PNG
2720 \end_layout
2722 \begin_layout Itemize
2723 Syntax: bitmap:save_png(filename, [base])
2724 \end_layout
2726 \begin_layout Itemize
2727 Syntax: data bitmap:save_png()
2728 \end_layout
2730 \begin_layout Itemize
2731 Deprecated: ...
2732  gui.bitmap_save_png(bitmap, ...)
2733 \end_layout
2735 \begin_layout Standard
2736 Parameters:
2737 \end_layout
2739 \begin_layout Itemize
2740 bitmap: DBITMAP: The bitmap to save.
2741 \end_layout
2743 \begin_layout Itemize
2744 filename: string: The filename to save to.
2745 \end_layout
2747 \begin_layout Itemize
2748 base: string: The base filename is resolved relative to.
2749 \end_layout
2751 \begin_layout Standard
2752 Return value:
2753 \end_layout
2755 \begin_layout Itemize
2756 data: string: BASE64 encoded PNG data.
2757 \end_layout
2759 \begin_layout Standard
2760 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2761  BASE64 encoding of it.
2762 \end_layout
2764 \begin_layout Subsubsection
2765 Method hash: Hash a bitmap
2766 \end_layout
2768 \begin_layout Itemize
2769 Syntax: hash bitmap:hash()
2770 \end_layout
2772 \begin_layout Itemize
2773 Deprecated: hash bitmap:hash(bitmap)
2774 \end_layout
2776 \begin_layout Standard
2777 Parameters:
2778 \end_layout
2780 \begin_layout Itemize
2781 bitmap: DBITMAP: The bitmap to hash.
2782 \end_layout
2784 \begin_layout Standard
2785 Return value:
2786 \end_layout
2788 \begin_layout Itemize
2789 hash: string: 64-hex digit hash
2790 \end_layout
2792 \begin_layout Standard
2793 Hashes bitmap <bitmap> and returns crypto-strong hash.
2795 \end_layout
2797 \begin_layout Subsection
2798 IMAGELOADER: Load an image
2799 \end_layout
2801 \begin_layout Subsubsection
2802 Static function load: Load a bitmap from file
2803 \end_layout
2805 \begin_layout Itemize
2806 Syntax: bitmap, palette gui.image.load(file, [base])
2807 \end_layout
2809 \begin_layout Itemize
2810 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
2811 \end_layout
2813 \begin_layout Itemize
2814 Deprecated: ...
2815  gui.bitmap_load(...)
2816 \end_layout
2818 \begin_layout Standard
2819 Parameters:
2820 \end_layout
2822 \begin_layout Itemize
2823 file: string: The file to read.
2824 \end_layout
2826 \begin_layout Itemize
2827 base: string: The base to resolve <file> relative to.
2828 \end_layout
2830 \begin_layout Standard
2831 Returns:
2832 \end_layout
2834 \begin_layout Itemize
2835 bitmap: BITMAP/DBITMAP: The new bitmap
2836 \end_layout
2838 \begin_layout Itemize
2839 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
2840  nil.
2841 \end_layout
2843 \begin_layout Standard
2844 Load a new bitmap and return it (plus associated palette if any).
2845 \end_layout
2847 \begin_layout Subsubsection
2848 Static function load_str: Load a bitmap from string
2849 \end_layout
2851 \begin_layout Itemize
2852 Syntax: bitmap, palette gui.image.load_str(data)
2853 \end_layout
2855 \begin_layout Itemize
2856 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
2857 \end_layout
2859 \begin_layout Itemize
2860 Deprecated: ...
2861  gui.bitmap_load_str(...)
2862 \end_layout
2864 \begin_layout Standard
2865 Parameters:
2866 \end_layout
2868 \begin_layout Itemize
2869 data: string: The image data
2870 \end_layout
2872 \begin_layout Standard
2873 Returns:
2874 \end_layout
2876 \begin_layout Itemize
2877 bitmap: BITMAP/DBITMAP: The new bitmap
2878 \end_layout
2880 \begin_layout Itemize
2881 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
2882  nil.
2883 \end_layout
2885 \begin_layout Standard
2886 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
2887  file.
2888 \end_layout
2890 \begin_layout Subsubsection
2891 Static function load_png: Load a bitmap from PNG file
2892 \end_layout
2894 \begin_layout Itemize
2895 Syntax: bitmap, palette gui.image.load_png(file, [base])
2896 \end_layout
2898 \begin_layout Itemize
2899 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
2900 \end_layout
2902 \begin_layout Itemize
2903 Deprecated: ...
2904  gui.bitmap_load_png(...)
2905 \end_layout
2907 \begin_layout Standard
2908 Parameters:
2909 \end_layout
2911 \begin_layout Itemize
2912 file: string: The file to read.
2913 \end_layout
2915 \begin_layout Itemize
2916 base: string: The base to resolve <file> relative to.
2917 \end_layout
2919 \begin_layout Standard
2920 Returns:
2921 \end_layout
2923 \begin_layout Itemize
2924 bitmap: BITMAP/DBITMAP: The new bitmap
2925 \end_layout
2927 \begin_layout Itemize
2928 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
2929  nil.
2930 \end_layout
2932 \begin_layout Standard
2933 Like IMAGELOADER:load, but load a PNG file instead.
2934 \end_layout
2936 \begin_layout Subsubsection
2937 Static function load_png_str: Load a PNG bitmap from string
2938 \end_layout
2940 \begin_layout Itemize
2941 Syntax: bitmap, palette gui.image.load_png_str(data)
2942 \end_layout
2944 \begin_layout Itemize
2945 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
2946 \end_layout
2948 \begin_layout Itemize
2949 Deprecated: ...
2950  gui.bitmap_load_png_str(...)
2951 \end_layout
2953 \begin_layout Standard
2954 Parameters:
2955 \end_layout
2957 \begin_layout Itemize
2958 data: string: The image data, base64 encoded.
2959 \end_layout
2961 \begin_layout Standard
2962 Returns:
2963 \end_layout
2965 \begin_layout Itemize
2966 bitmap: BITMAP/DBITMAP: The new bitmap
2967 \end_layout
2969 \begin_layout Itemize
2970 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
2971  nil.
2972 \end_layout
2974 \begin_layout Standard
2975 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
2976  <data> instead of file.
2977 \end_layout
2979 \begin_layout Standard
2980 \begin_inset Newpage pagebreak
2981 \end_inset
2984 \end_layout
2986 \begin_layout Subsection
2987 CUSTOMFONT: Arbitrary-sized bitmap font
2988 \end_layout
2990 \begin_layout Subsubsection
2991 Static function new: Return a new empty font
2992 \end_layout
2994 \begin_layout Itemize
2995 Syntax: font gui.font.new()
2996 \end_layout
2998 \begin_layout Itemize
2999 Syntax: font classes.CUSTOMFONT.new()
3000 \end_layout
3002 \begin_layout Itemize
3003 Deprecated: font gui.font_new()
3004 \end_layout
3006 \begin_layout Standard
3007 Return value:
3008 \end_layout
3010 \begin_layout Itemize
3011 font: CUSTOMFONT: New font.
3012 \end_layout
3014 \begin_layout Standard
3015 Create a new font with no characters and return it.
3016 \end_layout
3018 \begin_layout Subsubsection
3019 Static function: load: Load a font file
3020 \end_layout
3022 \begin_layout Itemize
3023 Syntax: font gui.font.load(file, [base])
3024 \end_layout
3026 \begin_layout Itemize
3027 Syntax: font gui.font.load()
3028 \end_layout
3030 \begin_layout Itemize
3031 Syntax: font classes.CUSTOMFONT.load(file, [base])
3032 \end_layout
3034 \begin_layout Itemize
3035 Syntax: font classes.CUSTOMFONT.load()
3036 \end_layout
3038 \begin_layout Itemize
3039 Deprecated: font gui.loadfont(...)
3040 \end_layout
3042 \begin_layout Standard
3043 Parameters:
3044 \end_layout
3046 \begin_layout Itemize
3047 file: string: The file to read the font from
3048 \end_layout
3050 \begin_layout Itemize
3051 base: string: The file to resolve <file> relative to.
3052 \end_layout
3054 \begin_layout Standard
3055 Return value:
3056 \end_layout
3058 \begin_layout Itemize
3059 font: CUSTOMFONT: New font.
3060 \end_layout
3062 \begin_layout Standard
3063 Load font from file <file> (relative to <base>).
3064  If no filename is given, system default font is loaded.
3065 \end_layout
3067 \begin_layout Subsubsection
3068 operator(): Render text to screen
3069 \end_layout
3071 \begin_layout Itemize
3072 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3073 \end_layout
3075 \begin_layout Standard
3076 Parmeters:
3077 \end_layout
3079 \begin_layout Itemize
3080 font: CUSTOMFONT: The font to use.
3081 \end_layout
3083 \begin_layout Itemize
3084 x: number: The x-position on screen to draw to.
3085 \end_layout
3087 \begin_layout Itemize
3088 y: number: The y-position on screen to draw to.
3089 \end_layout
3091 \begin_layout Itemize
3092 text: string: The text to draw.
3093 \end_layout
3095 \begin_layout Itemize
3096 fgc: number/string: Foreground color (default white).
3097 \end_layout
3099 \begin_layout Itemize
3100 bgc: number/string: Background color (default transparent).
3101 \end_layout
3103 \begin_layout Itemize
3104 hlc: number/string: Outline color (default transparent).
3105 \end_layout
3107 \begin_layout Standard
3108 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3109  onto screen.
3110 \end_layout
3112 \begin_layout Itemize
3113 If <hlc> is transparent, no outline is drawn.
3114 \end_layout
3116 \begin_layout Subsubsection
3117 Method edit: Alter glyph in font
3118 \end_layout
3120 \begin_layout Itemize
3121 Syntax: font:edit(character, glyph)
3122 \end_layout
3124 \begin_layout Standard
3125 Parameters:
3126 \end_layout
3128 \begin_layout Itemize
3129 font: CUSTOMFONT: The font to edit.
3130 \end_layout
3132 \begin_layout Itemize
3133 character: string: The character to edit (UTF-8 encoded).
3134 \end_layout
3136 \begin_layout Itemize
3137 glyph: BITMAP: The bitmap to use.
3138 \end_layout
3140 \begin_layout Standard
3141 Replace character <character> in font <font> by <glyph>.
3142 \end_layout
3144 \begin_layout Itemize
3145 Color index 0 is background, everything else is foreground.
3146 \end_layout
3148 \begin_layout Itemize
3149 <character> may be empty string, meaning the replacement character used
3150  for bad characters.
3151 \end_layout
3153 \begin_layout Itemize
3154 <character> may be multi-codepoint string, meaning character used for that
3155  ligature.
3156 \end_layout
3158 \begin_layout Standard
3159 \begin_inset Newpage pagebreak
3160 \end_inset
3163 \end_layout
3165 \begin_layout Subsection
3166 ICONV: Character set conversions
3167 \end_layout
3169 \begin_layout Subsubsection
3170 Static function new: Create new character set converter
3171 \end_layout
3173 \begin_layout Itemize
3174 Syntax: iconv iconv.new(from, to);
3175 \end_layout
3177 \begin_layout Itemize
3178 Syntax: iconv classes.ICONV.new(from, to);
3179 \end_layout
3181 \begin_layout Itemize
3182 Deprecated: iconv iconv_new(...);
3183 \end_layout
3185 \begin_layout Standard
3186 Parameters:
3187 \end_layout
3189 \begin_layout Itemize
3190 from: string: The source character set.
3191 \end_layout
3193 \begin_layout Itemize
3194 to: string: The target character set.
3195 \end_layout
3197 \begin_layout Standard
3198 Returns:
3199 \end_layout
3201 \begin_layout Itemize
3202 iconv: ICONV: The converter.
3203 \end_layout
3205 \begin_layout Standard
3206 Create a character set converter, converting from <from> to <to> and return
3207  it.
3208 \end_layout
3210 \begin_layout Subsubsection
3211 Operator(): Convert string fragment from character set to another
3212 \end_layout
3214 \begin_layout Itemize
3215 Syntax: success, result, unconverted, error iconv(input)
3216 \end_layout
3218 \begin_layout Standard
3219 Parameters:
3220 \end_layout
3222 \begin_layout Itemize
3223 iconv: ICONV: The context to use.
3224 \end_layout
3226 \begin_layout Itemize
3227 input: string: The input to convert.
3228 \end_layout
3230 \begin_layout Standard
3231 Return value:
3232 \end_layout
3234 \begin_layout Itemize
3235 success: boolean: True if conversion was successful, false if not.
3236 \end_layout
3238 \begin_layout Itemize
3239 result: string: The string (partially) converted.
3240 \end_layout
3242 \begin_layout Itemize
3243 unconvered: number: Number of bytes that were not converted (only if <success>
3244  is false).
3245 \end_layout
3247 \begin_layout Itemize
3248 error: string: Error that caused conversion to stop (only if <success> is
3249  false).
3250 \end_layout
3252 \begin_deeper
3253 \begin_layout Itemize
3254 INVALID: The input string is invalid.
3255 \end_layout
3257 \begin_layout Itemize
3258 INCOMPLETE: The input string cuts off in middle of character.
3259 \end_layout
3261 \begin_layout Itemize
3262 INTERNALERR: Internal error.
3263 \end_layout
3265 \end_deeper
3266 \begin_layout Standard
3267 Convert a string <input> using character set converter <iconv> and return
3268  the result.
3269 \end_layout
3271 \begin_layout Standard
3272 \begin_inset Newpage pagebreak
3273 \end_inset
3276 \end_layout
3278 \begin_layout Subsection
3279 FILEREADER: Read a file as a stream
3280 \end_layout
3282 \begin_layout Subsubsection
3283 Static function open: Open a stream
3284 \end_layout
3286 \begin_layout Itemize
3287 Syntax: handle filereader.open(file, [base])
3288 \end_layout
3290 \begin_layout Itemize
3291 Syntax: handle classes.FILEREADER.open(file, [base])
3292 \end_layout
3294 \begin_layout Itemize
3295 Deprecated: handle open_file(file, [base])
3296 \end_layout
3298 \begin_layout Standard
3299 Parameters:
3300 \end_layout
3302 \begin_layout Itemize
3303 file: string: The filename to read.
3304 \end_layout
3306 \begin_layout Itemize
3307 base: string: The base <file> is resolved against.
3308 \end_layout
3310 \begin_layout Standard
3311 Returns:
3312 \end_layout
3314 \begin_layout Itemize
3315 handle: FILEREADER: The new file reader.
3316 \end_layout
3318 \begin_layout Standard
3319 Open file <file> (relative to <base>) and return a handle to it.
3320 \end_layout
3322 \begin_layout Subsubsection
3323 operator(): Read line/bytes from stream
3324 \end_layout
3326 \begin_layout Itemize
3327 Syntax: result handle()
3328 \end_layout
3330 \begin_layout Itemize
3331 Syntax: result handle(bytes)
3332 \end_layout
3334 \begin_layout Standard
3335 Parameters:
3336 \end_layout
3338 \begin_layout Itemize
3339 handle: FILEREADER: The handle to read from.
3340 \end_layout
3342 \begin_layout Itemize
3343 bytes: Number of bytes to read (default is next line).
3344 \end_layout
3346 \begin_layout Standard
3347 Returns:
3348 \end_layout
3350 \begin_layout Itemize
3351 result: string: The read data, or nil on end-of-file.
3352 \end_layout
3354 \begin_layout Standard
3355 Reads next line or <bytes> bytes from specified file handle <handle>.
3356 \end_layout
3358 \begin_layout Itemize
3359 If reading specified number of bytes, the bytes are read in binary mode
3360  (as-is).
3361 \end_layout
3363 \begin_layout Itemize
3364 If reading next line, the line is read in text mode (any line ending is
3365  skpped).
3366 \end_layout
3368 \begin_layout Subsubsection
3369 Method lines: Iterator to read all lines
3370 \end_layout
3372 \begin_layout Itemize
3373 Syntax: for line in handle:lines() do ...
3374  end
3375 \end_layout
3377 \begin_layout Standard
3378 Parameters:
3379 \end_layout
3381 \begin_layout Itemize
3382 handle: FILEREADER: The handle to read.
3383 \end_layout
3385 \begin_layout Standard
3386 Returns:
3387 \end_layout
3389 \begin_layout Itemize
3390 A lua iterator with one variable.
3391 \end_layout
3393 \begin_layout Standard
3394 Return a Lua iterator that iterates all the lines in <handle>.
3395 \end_layout
3397 \begin_layout Standard
3398 \begin_inset Newpage pagebreak
3399 \end_inset
3402 \end_layout
3404 \begin_layout Section
3405 Global
3406 \end_layout
3408 \begin_layout Subsection
3409 print: Print values to console
3410 \end_layout
3412 \begin_layout Itemize
3413 Syntax: none print(value...
3414  values)
3415 \end_layout
3417 \begin_layout Standard
3418 Prints specified values to console.
3419  Can print any Lua type at least enough to identify the type and instance.
3420 \end_layout
3422 \begin_layout Subsection
3423 tostringx: Format a value to string
3424 \end_layout
3426 \begin_layout Itemize
3427 Syntax: string tostringx(value val)
3428 \end_layout
3430 \begin_layout Standard
3431 Formats value <val> like print would, and returns the result as a string.
3432 \end_layout
3434 \begin_layout Subsection
3435 exec: Execute lsnes commands
3436 \end_layout
3438 \begin_layout Itemize
3439 Syntax: none exec(string cmd)
3440 \end_layout
3442 \begin_layout Standard
3443 Execute lsnes command <cmd>.
3444 \end_layout
3446 \begin_layout Subsection
3447 utime: Get current time
3448 \end_layout
3450 \begin_layout Itemize
3451 Syntax: (number,number) utime()
3452 \end_layout
3454 \begin_layout Standard
3455 Returns two numbers.
3456  First is time since some epoch in seconds, the second is microseconds mod
3457  10^6 since that epoch.
3458 \end_layout
3460 \begin_layout Subsection
3461 emulator_ready: Check if emulator has been fully initialized
3462 \end_layout
3464 \begin_layout Itemize
3465 Syntax: boolean emulator_ready()
3466 \end_layout
3468 \begin_layout Standard
3469 Returns true if emulator has finished booting, false if not (on_startup()
3470  will be issued later).
3471 \end_layout
3473 \begin_layout Subsection
3474 set_idle_timeout: Run function after timeout when emulator is idle
3475 \end_layout
3477 \begin_layout Itemize
3478 Syntax: none set_idle_timeout(number timeout)
3479 \end_layout
3481 \begin_layout Standard
3482 Set number of microseconds to block idle for.
3483  After this timeout has expired, on_idle() will be called once.
3484 \end_layout
3486 \begin_layout Subsection
3487 set_timer_timeout: Run function after timeout.
3488 \end_layout
3490 \begin_layout Itemize
3491 Syntax: none set_timer_timeout(number timeout)
3492 \end_layout
3494 \begin_layout Standard
3495 Set number of microseconds to block timer for.
3496  After this timeout has expired, on_timer() will be called once.
3497 \end_layout
3499 \begin_layout Subsection
3500 bus_address: Look up address in system bus.
3501 \end_layout
3503 \begin_layout Itemize
3504 Syntax: none bus_address(number bus_addr)
3505 \end_layout
3507 \begin_layout Standard
3508 Returns virtual address corresponding to specified address on system bus.
3509 \end_layout
3511 \begin_layout Subsection
3512 loopwrapper: Convert loop into callable function
3513 \end_layout
3515 \begin_layout Itemize
3516 Syntax: function loopwrapper(function fun, ...)
3517 \end_layout
3519 \begin_layout Standard
3520 Calls function <fun> with function and specified arguments.
3521  The function passed suspends execution until the function returned is called.
3522  Handy for linear flow control among multiple invocations of a hook.
3523  Example code:
3524 \end_layout
3526 \begin_layout LyX-Code
3527 on_paint = loopwrapper(function(wait)
3528 \end_layout
3530 \begin_deeper
3531 \begin_layout LyX-Code
3532 while true do
3533 \end_layout
3535 \begin_deeper
3536 \begin_layout LyX-Code
3537 gui.text(0, 0, 
3538 \begin_inset Quotes eld
3539 \end_inset
3541 Test!
3542 \begin_inset Quotes erd
3543 \end_inset
3546 \end_layout
3548 \begin_layout LyX-Code
3549 wait();
3550 \end_layout
3552 \end_deeper
3553 \begin_layout LyX-Code
3555 \end_layout
3557 \end_deeper
3558 \begin_layout LyX-Code
3559 end);
3560 \end_layout
3562 \begin_layout Subsection
3563 list_bindings: List keybindings
3564 \end_layout
3566 \begin_layout Itemize
3567 Syntax: table list_bindings([string cmd])
3568 \end_layout
3570 \begin_layout Standard
3571 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
3572  If <cmd> is specified, the table is limited to that command.
3573  Also searches for controller keys.
3574 \end_layout
3576 \begin_layout Subsection
3577 get_alias: Get expansion of alias
3578 \end_layout
3580 \begin_layout Itemize
3581 Syntax: string get_alias(string aname)
3582 \end_layout
3584 \begin_layout Standard
3585 Get expansion of given alias <aname>.
3586 \end_layout
3588 \begin_layout Subsection
3589 set_alias: Set expansion of alias
3590 \end_layout
3592 \begin_layout Itemize
3593 Syntax: none set_alias(string aname, string value)
3594 \end_layout
3596 \begin_layout Standard
3597 Set expansion of given alias.
3598 \end_layout
3600 \begin_layout Subsection
3601 create_ibind: Create invese binding
3602 \end_layout
3604 \begin_layout Itemize
3605 Syntax: INVERSEBIND create_ibind(string name, string cmd)
3606 \end_layout
3608 \begin_layout Standard
3609 Return object representing inverse binding with specified name <name> and
3610  specified command <cmd>.
3611 \end_layout
3613 \begin_layout Itemize
3614 Note: To create press/release commands, use aliases +foo and -foo .
3615 \end_layout
3617 \begin_layout Itemize
3618 Note: Keep the returned object around.
3619 \end_layout
3621 \begin_layout Subsection
3622 create_command: Create a command
3623 \end_layout
3625 \begin_layout Itemize
3626 Syntax: COMMANDBIND create_commmand(string name, function a)
3627 \end_layout
3629 \begin_layout Itemize
3630 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
3631 \end_layout
3633 \begin_layout Standard
3634 Return object representing a command (pair).
3635 \end_layout
3637 \begin_layout Itemize
3638 If only one function is specied, the command is level-sensitive, <a> is
3639  callback.
3640 \end_layout
3642 \begin_layout Itemize
3643 If <b> is function, the function is edge-sensitive, <a> is positive edge
3644  callback and <b> is negative edge callback.
3645 \end_layout
3647 \begin_layout Itemize
3648 All callbacks get single argument: The parameters passed.
3649 \end_layout
3651 \begin_layout Itemize
3652 Keep the returned object around.
3653 \end_layout
3655 \begin_layout Subsection
3656 loadfile: Load Lua script
3657 \end_layout
3659 \begin_layout Itemize
3660 Syntax: function loadfile(string filename[, string base])
3661 \end_layout
3663 \begin_layout Standard
3664 Load lua script from <filename>, resolved relative to <base> (if empty,
3665  current directory).
3666 \end_layout
3668 \begin_layout Subsection
3669 dofile: Execute Lua script
3670 \end_layout
3672 \begin_layout Itemize
3673 Syntax: function dofile(string filename[, string base])
3674 \end_layout
3676 \begin_layout Standard
3677 Execute lua script from <filename>, resolved relative to <base> (if empty,
3678  current directory) and return all return values.
3679 \end_layout
3681 \begin_layout Subsection
3682 resolve_filename: Resolve name of file relative to another
3683 \end_layout
3685 \begin_layout Itemize
3686 Syntax: string resolve_file(string filename, string base)
3687 \end_layout
3689 \begin_layout Standard
3690 Resolve name of file <filename> relative to <base> and return the result.
3691 \end_layout
3693 \begin_layout Subsection
3694 render_queue_function: Return paint function for render queue
3695 \end_layout
3697 \begin_layout Itemize
3698 Syntax: function render_queue_function(RENDERQUEUE rq)
3699 \end_layout
3701 \begin_layout Standard
3702 Return function that renders render queue <rq>.
3703 \end_layout
3705 \begin_layout Itemize
3706 Handy for paint callback if one is using render queues updated in other
3707  callbacks.
3708  As in:
3709 \end_layout
3711 \begin_layout LyX-Code
3712 handle = callback.paint:register(render_queue_function(my_rq));
3713 \end_layout
3715 \begin_layout Subsection
3716 identify_class: Identify class of object
3717 \end_layout
3719 \begin_layout Itemize
3720 Syntax: string identify_class(userdata object)
3721 \end_layout
3723 \begin_layout Standard
3724 Identifies the class of userdata <object>, if possible.
3725  If no identification is possible, returns 
3726 \begin_inset Quotes eld
3727 \end_inset
3729 unknown
3730 \begin_inset Quotes erd
3731 \end_inset
3734 \end_layout
3736 \begin_layout Subsection
3737 lookup_class: Lookup class by name
3738 \end_layout
3740 \begin_layout Itemize
3741 Syntax: classobj lookup_class(string name)
3742 \end_layout
3744 \begin_layout Standard
3745 Looks up class corresponding to <name>, if possible.
3746  If not found, returns nil.
3747  The classobj has following fields:
3748 \end_layout
3750 \begin_layout Itemize
3751 _static_methods: Return static method names
3752 \end_layout
3754 \begin_layout Itemize
3755 _class_methods: Return class method names
3756 \end_layout
3758 \begin_layout Itemize
3759 <static-function-name>: The specified static function.
3760 \end_layout
3762 \begin_layout Subsection
3763 all_classes: Get list of all classes
3764 \end_layout
3766 \begin_layout Itemize
3767 Syntax: string...
3768  all_classes()
3769 \end_layout
3771 \begin_layout Standard
3772 Get names of all classes available.
3773 \end_layout
3775 \begin_layout Subsection
3776 icnov: Class ICONV
3777 \end_layout
3779 \begin_layout Standard
3780 See class ICONV.
3781 \end_layout
3783 \begin_layout Subsection
3784 filereader: Class FILEREADER
3785 \end_layout
3787 \begin_layout Standard
3788 See class FILEREADER.
3789 \end_layout
3791 \begin_layout Standard
3792 \begin_inset Newpage pagebreak
3793 \end_inset
3796 \end_layout
3798 \begin_layout Section
3799 Table bit:
3800 \end_layout
3802 \begin_layout Standard
3803 Bitwise logical functions and related.
3804 \end_layout
3806 \begin_layout Subsection
3807 bit.none/bit.bnot: Bitwise none or NOT function
3808 \end_layout
3810 \begin_layout Itemize
3811 Syntax: number bit.none(number...)
3812 \end_layout
3814 \begin_layout Itemize
3815 Syntax: number bit.bnot(number...)
3816 \end_layout
3818 \begin_layout Standard
3819 48-bit bitwise NOT / NONE function (set bits that are set in none of the
3820  arguments).
3821 \end_layout
3823 \begin_layout Subsection
3824 bit.any/bit.bor: Bitwise any or OR function
3825 \end_layout
3827 \begin_layout Itemize
3828 Syntax: number bit.any(number...)
3829 \end_layout
3831 \begin_layout Itemize
3832 Syntax: number bit.bor(number...)
3833 \end_layout
3835 \begin_layout Standard
3836 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
3837 \end_layout
3839 \begin_layout Subsection
3840 bit.all/bit.band: Bitwise all or AND function
3841 \end_layout
3843 \begin_layout Itemize
3844 Syntax: number bit.all(number...)
3845 \end_layout
3847 \begin_layout Itemize
3848 Syntax: number bit.band(number...)
3849 \end_layout
3851 \begin_layout Standard
3852 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
3854 \end_layout
3856 \begin_layout Subsection
3857 bit.parity/bit.bxor: Bitwise parity or XOR function
3858 \end_layout
3860 \begin_layout Itemize
3861 Syntax: number bit.parity(number...)
3862 \end_layout
3864 \begin_layout Itemize
3865 Syntax: number bit.bxor(number...)
3866 \end_layout
3868 \begin_layout Standard
3869 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
3870  of the arguments).
3871 \end_layout
3873 \begin_layout Subsection
3874 bit.lrotate: Rotate a number left
3875 \end_layout
3877 \begin_layout Itemize
3878 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
3879 \end_layout
3881 \begin_layout Standard
3882 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
3883  1) places.
3884 \end_layout
3886 \begin_layout Subsection
3887 bit.rrotate: Rotate a number right
3888 \end_layout
3890 \begin_layout Itemize
3891 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
3892 \end_layout
3894 \begin_layout Standard
3895 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
3896  1) places.
3897 \end_layout
3899 \begin_layout Subsection
3900 bit.lshift: Shift a number left
3901 \end_layout
3903 \begin_layout Itemize
3904 Syntax: number bit.lshift(number base[, number amount[, number bits]])
3905 \end_layout
3907 \begin_layout Standard
3908 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
3909  1) places.
3910  The new bits are filled with zeroes.
3911 \end_layout
3913 \begin_layout Subsection
3914 bit.lrshift: Shift a number right (logical)
3915 \end_layout
3917 \begin_layout Itemize
3918 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
3919 \end_layout
3921 \begin_layout Standard
3922 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
3923  (default 1) places.
3924  The new bits are filled with zeroes.
3925 \end_layout
3927 \begin_layout Subsection
3928 bit.arshift: Shift a number right (arithmetic)
3929 \end_layout
3931 \begin_layout Itemize
3932 Syntax: number bit.arshift(number base[, number amount[, number bits]])
3933 \end_layout
3935 \begin_layout Standard
3936 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
3937  (default 1) places.
3938  The new bits are shifted in with copy of the high bit.
3939 \end_layout
3941 \begin_layout Subsection
3942 bit.extract: Extract/shuffle bits from number
3943 \end_layout
3945 \begin_layout Itemize
3946 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
3947 \end_layout
3949 \begin_layout Standard
3950 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
3951 \end_layout
3953 \begin_layout Itemize
3954 Note: Bit numbers up to 51 should work reliably (then things start falling
3955  apart due to double precision issues).
3956 \end_layout
3958 \begin_layout Itemize
3959 Note: There are two special bit positions, true and false, standing for
3960  always set bit and always clear bit.
3961 \end_layout
3963 \begin_layout Subsection
3964 bit.value: Construct number with specified bits set
3965 \end_layout
3967 \begin_layout Itemize
3968 Syntax: number bit.value([number bit1[, number bit2,...]])
3969 \end_layout
3971 \begin_layout Standard
3972 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
3973  <bit2> places and so on.
3974  As special value, nil argument is no-op.
3975 \end_layout
3977 \begin_layout Subsection
3978 bit.test_any: Test if any bit is set
3979 \end_layout
3981 \begin_layout Itemize
3982 Syntax: boolean bit.test_any(number a, number b)
3983 \end_layout
3985 \begin_layout Standard
3986 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
3987 \end_layout
3989 \begin_layout Subsection
3990 bit.test_all: Test if all bits are set
3991 \end_layout
3993 \begin_layout Itemize
3994 Syntax: boolean bit.test_all(number a, number b)
3995 \end_layout
3997 \begin_layout Standard
3998 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
3999 \end_layout
4001 \begin_layout Subsection
4002 bit.popcount: Population count
4003 \end_layout
4005 \begin_layout Itemize
4006 Syntax: number bit.popcount(number a)
4007 \end_layout
4009 \begin_layout Standard
4010 Returns number of set bits in <a>.
4011 \end_layout
4013 \begin_layout Subsection
4014 bit.clshift: Chained left shift
4015 \end_layout
4017 \begin_layout Itemize
4018 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4019  bits]])
4020 \end_layout
4022 \begin_layout Standard
4023 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4024  numbers to be of specified number of bits <bits> (default 48).
4025 \end_layout
4027 \begin_layout Subsection
4028 bit.crshift: Chained right shift
4029 \end_layout
4031 \begin_layout Itemize
4032 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4033  bits]])
4034 \end_layout
4036 \begin_layout Standard
4037 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4038  assuming numbers to be of specified number of bits <bits> (default 48).
4039 \end_layout
4041 \begin_layout Subsection
4042 bit.flagdecode: Decode bitfield into flags
4043 \end_layout
4045 \begin_layout Itemize
4046 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4047  off]])
4048 \end_layout
4050 \begin_layout Standard
4051 Return string of length bits where ith character is ith character of on
4052  if bit i is on, otherwise ith character of off.
4053  Out of range reads give last character.
4054 \end_layout
4056 \begin_layout Itemize
4057 Note: <on> defaults to '*' if empty.
4058 \end_layout
4060 \begin_layout Itemize
4061 Note: <off> defaults to '-' if empty.
4062 \end_layout
4064 \begin_layout Subsection
4065 bit.rflagdecode: Decode bitfield into flags
4066 \end_layout
4068 \begin_layout Itemize
4069 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4070  off]])
4071 \end_layout
4073 \begin_layout Standard
4074 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4075 nt bit first).
4076 \end_layout
4078 \begin_layout Subsection
4079 bit.swap{,s}{,h,d,q}word: Swap word endian
4080 \end_layout
4082 \begin_layout Itemize
4083 Syntax: number bit.swapword(number n)
4084 \end_layout
4086 \begin_layout Itemize
4087 Syntax: number bit.swaphword(number n)
4088 \end_layout
4090 \begin_layout Itemize
4091 Syntax: number bit.swapdword(number n)
4092 \end_layout
4094 \begin_layout Itemize
4095 Syntax: number bit.swapqword(number n)
4096 \end_layout
4098 \begin_layout Itemize
4099 Syntax: number bit.swapsword(number n)
4100 \end_layout
4102 \begin_layout Itemize
4103 Syntax: number bit.swapshword(number n)
4104 \end_layout
4106 \begin_layout Itemize
4107 Syntax: number bit.swapsdword(number n)
4108 \end_layout
4110 \begin_layout Itemize
4111 Syntax: number bit.swapsqword(number n)
4112 \end_layout
4114 \begin_layout Standard
4115 Swap endianess of (un)signed integer <n>.
4116 \end_layout
4118 \begin_layout Subsection
4119 bit.compose: Compose multi-byte number
4120 \end_layout
4122 \begin_layout Itemize
4123 Syntax: number bit.compose(number n...)
4124 \end_layout
4126 \begin_layout Standard
4127 Return 
4128 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4129 \end_inset
4132 \end_layout
4134 \begin_layout Subsection
4135 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4136 \end_layout
4138 \begin_layout Itemize
4139 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4140 \end_layout
4142 \begin_layout Itemize
4143 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4144 \end_layout
4146 \begin_layout Standard
4147 Load little (*le) or big (*be) endian binary number from position <pos>
4148  of string <str>.
4149  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4150  double.
4151 \end_layout
4153 \begin_layout Subsection
4154 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4155 \end_layout
4157 \begin_layout Itemize
4158 Syntax: string bit.binary_st_<type>le(number x);
4159 \end_layout
4161 \begin_layout Itemize
4162 Syntax: string bit.binary_st_<type>be(number x);
4163 \end_layout
4165 \begin_layout Standard
4166 Store specified number <x> as binary in string and return the result.
4167  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4168  double.
4169 \end_layout
4171 \begin_layout Subsection
4172 bit.quotent: Integer quotent
4173 \end_layout
4175 \begin_layout Itemize
4176 Syntax: number bit.quotent(number a, number b)
4177 \end_layout
4179 \begin_layout Standard
4180 Calculate quotent a/b.
4181 \end_layout
4183 \begin_layout Standard
4184 \begin_inset Newpage pagebreak
4185 \end_inset
4188 \end_layout
4190 \begin_layout Section
4191 Table classes:
4192 \end_layout
4194 \begin_layout Subsection
4195 classes.<foo>: The classobj for class <foo>
4196 \end_layout
4198 \begin_layout Itemize
4199 Syntax: classes.<foo>
4200 \end_layout
4202 \begin_layout Standard
4203 The classobj for class <foo>.
4204 \end_layout
4206 \begin_layout Subsection
4207 classes.<foo>._static_methods: Enumerate static methods
4208 \end_layout
4210 \begin_layout Itemize
4211 Syntax: string...
4212  classes.<foo>._static_methods()
4213 \end_layout
4215 \begin_layout Standard
4216 Returns all static methods of <foo> as strings.
4217 \end_layout
4219 \begin_layout Subsection
4220 classes.<foo>._class_methods: Enumerate static methods
4221 \end_layout
4223 \begin_layout Itemize
4224 Syntax: string...
4225  classes.<foo>._class_methods()
4226 \end_layout
4228 \begin_layout Standard
4229 Returns all class methods of <foo> as strings.
4230 \end_layout
4232 \begin_layout Subsection
4233 classes.<foo>.<bar>: Static method
4234 \end_layout
4236 \begin_layout Itemize
4237 Syntax: variable classes.<foo>.<bar>(variable...)
4238 \end_layout
4240 \begin_layout Standard
4241 Invokes static method <bar> of class <foo>.
4242 \end_layout
4244 \begin_layout Section
4245 Table gui:
4246 \end_layout
4248 \begin_layout Subsection
4249 gui.resolution: Get current resolution
4250 \end_layout
4252 \begin_layout Itemize
4253 Syntax: (number, number) gui.resolution()
4254 \end_layout
4256 \begin_layout Standard
4257 Returns 2-tuple (hresolution, vresolution).
4258 \end_layout
4260 \begin_layout Subsection
4261 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
4262 \end_layout
4264 \begin_layout Itemize
4265 Syntax: number gui.left_gap(number gap)
4266 \end_layout
4268 \begin_layout Itemize
4269 Syntax: number gui.right_gap(number gap)
4270 \end_layout
4272 \begin_layout Itemize
4273 Syntax: number gui.top_gap(number gap)
4274 \end_layout
4276 \begin_layout Itemize
4277 Syntax: number gui.bottom_gap(number gap)
4278 \end_layout
4280 \begin_layout Standard
4281 Set the specified edge gap to specified value <gap> (max gap is 8191).
4282  If successful, old gap is returned.
4283 \end_layout
4285 \begin_layout Subsection
4286 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
4287  Adjust edge gaps
4288 \end_layout
4290 \begin_layout Itemize
4291 Syntax: number gui.delta_left_gap(number dgap)
4292 \end_layout
4294 \begin_layout Itemize
4295 Syntax: number gui.delta_right_gap(number dgap)
4296 \end_layout
4298 \begin_layout Itemize
4299 Syntax: number gui.delta_top_gap(number dgap)
4300 \end_layout
4302 \begin_layout Itemize
4303 Syntax: number gui.delta_bottom_gap(number dgap)
4304 \end_layout
4306 \begin_layout Standard
4307 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
4308  and return the old gap (returns nothing on error).
4309 \end_layout
4311 \begin_layout Subsection
4312 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
4313 \end_layout
4315 \begin_layout Itemize
4316 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
4317  bgc]])
4318 \end_layout
4320 \begin_layout Itemize
4321 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
4322  bgc]])
4323 \end_layout
4325 \begin_layout Itemize
4326 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
4327  bgc]])
4328 \end_layout
4330 \begin_layout Itemize
4331 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
4332  bgc]])
4333 \end_layout
4335 \begin_layout Standard
4336 Draw specified text on the GUI (each character cell is 8 or 16 wide and
4337  16 high).
4338  Parameters:
4339 \end_layout
4341 \begin_layout Itemize
4342 x: X-coordinate to start the drawing from (and x-coordinate at begining
4343  of the lines).
4344 \end_layout
4346 \begin_layout Itemize
4347 y: Y-coordinate to start the drawing from.
4348 \end_layout
4350 \begin_layout Itemize
4351 text: The text to draw.
4352 \end_layout
4354 \begin_layout Itemize
4355 fgc: Text color (default is 0xFFFFFF (white))
4356 \end_layout
4358 \begin_layout Itemize
4359 bgc: Background color (default is -1 (transparent))
4360 \end_layout
4362 \begin_layout Standard
4363 Note: The H variants draw at double width and V variants draw at double
4364  height.
4365 \end_layout
4367 \begin_layout Subsection
4368 gui.rectangle: Draw a rectangle
4369 \end_layout
4371 \begin_layout Itemize
4372 Syntax: none gui.rectangle(number x, number y, number width, number height[,
4373  number thickness[, number outline[, number fill]]])
4374 \end_layout
4376 \begin_layout Standard
4377 Draw rectangle on the GUI.
4378  Parameters:
4379 \end_layout
4381 \begin_layout Itemize
4382 x: X-coordinate of left edge.
4383 \end_layout
4385 \begin_layout Itemize
4386 y: Y-coordinate of upper edge.
4387 \end_layout
4389 \begin_layout Itemize
4390 width: Width of rectangle.
4391 \end_layout
4393 \begin_layout Itemize
4394 height: Height of rectangle.
4395 \end_layout
4397 \begin_layout Itemize
4398 thickness: Thickness of outline (default is 1).
4399 \end_layout
4401 \begin_layout Itemize
4402 outline: Color of outline (default is 0xFFFFFF (white))
4403 \end_layout
4405 \begin_layout Itemize
4406 fill: Color of fill (default is -1 (transparent))
4407 \end_layout
4409 \begin_layout Subsection
4410 gui.box: Draw a 3D-effect box
4411 \end_layout
4413 \begin_layout Itemize
4414 Syntax: none gui.box(number x, number y, number width, number height[, number
4415  thickness[, number outline1[,number outline2[, number fill]]]])
4416 \end_layout
4418 \begin_layout Standard
4419 Draw rectangle with 3D effect on the GUI.
4420  Parameters:
4421 \end_layout
4423 \begin_layout Itemize
4424 x: X-coordinate of left edge.
4425 \end_layout
4427 \begin_layout Itemize
4428 y: Y-coordinate of upper edge.
4429 \end_layout
4431 \begin_layout Itemize
4432 width: Width of rectangle.
4433 \end_layout
4435 \begin_layout Itemize
4436 height: Height of rectangle.
4437 \end_layout
4439 \begin_layout Itemize
4440 thickness: Thickness of outline (default is 1).
4441 \end_layout
4443 \begin_layout Itemize
4444 outline1: First color of outline (default is 0xFFFFFF (white))
4445 \end_layout
4447 \begin_layout Itemize
4448 outline2: First color of outline (default is 0x808080 (dark gray))
4449 \end_layout
4451 \begin_layout Itemize
4452 fill: Color of fill (default is 0xC0C0C0 (light grayy))
4453 \end_layout
4455 \begin_layout Subsection
4456 gui.pixel: Draw a single pixel
4457 \end_layout
4459 \begin_layout Itemize
4460 Syntax: none gui.pixel(number x, number y[, number color])
4461 \end_layout
4463 \begin_layout Standard
4464 Draw one pixel on the GUI.
4465  Parameters:
4466 \end_layout
4468 \begin_layout Itemize
4469 x: X-coordinate of the pixel
4470 \end_layout
4472 \begin_layout Itemize
4473 y: Y-coordinate of the pixel
4474 \end_layout
4476 \begin_layout Itemize
4477 color: Color of the pixel (default is 0xFFFFFF (white))
4478 \end_layout
4480 \begin_layout Subsection
4481 gui.crosshair: Draw a crosshair
4482 \end_layout
4484 \begin_layout Itemize
4485 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
4486 \end_layout
4488 \begin_layout Standard
4489 Draw a crosshair.
4490  Parameters:
4491 \end_layout
4493 \begin_layout Itemize
4494 x: X-coordinate of the crosshair
4495 \end_layout
4497 \begin_layout Itemize
4498 y: Y-coordinate of the crosshair
4499 \end_layout
4501 \begin_layout Itemize
4502 length: Length of the crosshair lines (default 10).
4503 \end_layout
4505 \begin_layout Itemize
4506 color: Color of the crosshair (default is 0xFFFFFF (white))
4507 \end_layout
4509 \begin_layout Subsection
4510 gui.line: Draw a line
4511 \end_layout
4513 \begin_layout Itemize
4514 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
4515  color])
4516 \end_layout
4518 \begin_layout Standard
4519 Draw a thin line.
4520  Parameters:
4521 \end_layout
4523 \begin_layout Itemize
4524 x1: X-coordinate of one end.
4525 \end_layout
4527 \begin_layout Itemize
4528 y1: Y-coordinate of one end.
4529 \end_layout
4531 \begin_layout Itemize
4532 x2: X-coordinate of the other end.
4533 \end_layout
4535 \begin_layout Itemize
4536 y2: Y-coordinate of the other end.
4537 \end_layout
4539 \begin_layout Itemize
4540 color: Color of the line (default is 0xFFFFFF (white)).
4541 \end_layout
4543 \begin_layout Subsection
4544 gui.circle: Draw a (filled) circle
4545 \end_layout
4547 \begin_layout Itemize
4548 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
4549  border[, number fil]]])
4550 \end_layout
4552 \begin_layout Standard
4553 Draw a circle.
4554  Parameters.
4555 \end_layout
4557 \begin_layout Itemize
4558 x: X-coordinate of the center
4559 \end_layout
4561 \begin_layout Itemize
4562 y: Y-coordinate of the center
4563 \end_layout
4565 \begin_layout Itemize
4566 r: The radius of the circle
4567 \end_layout
4569 \begin_layout Itemize
4570 thick: Border thickness
4571 \end_layout
4573 \begin_layout Itemize
4574 border: Border color (default is 0xFFFFFF (white))
4575 \end_layout
4577 \begin_layout Itemize
4578 fill: Fill color (default is -1 (transparent)).
4579 \end_layout
4581 \begin_layout Subsection
4582 gui.repaint: Arrange a repaint
4583 \end_layout
4585 \begin_layout Itemize
4586 Syntax: none gui.repaint()
4587 \end_layout
4589 \begin_layout Standard
4590 Request on_repaint() to happen as soon as possible.
4591 \end_layout
4593 \begin_layout Subsection
4594 gui.subframe_update: Enable/Disable subframe updates
4595 \end_layout
4597 \begin_layout Itemize
4598 Syntax: none gui.subframe_update(boolean on)
4599 \end_layout
4601 \begin_layout Standard
4602 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
4603  or not happen (<on>=false).
4604 \end_layout
4606 \begin_layout Subsection
4607 gui.screenshot: Write a screenshot
4608 \end_layout
4610 \begin_layout Itemize
4611 Syntax: none gui.screenshot(string filename)
4612 \end_layout
4614 \begin_layout Standard
4615 Write PNG screenshot of the current frame (no drawings) to specified file
4616  <filename>.
4617 \end_layout
4619 \begin_layout Subsection
4620 gui.screenshot_bitmap: Write a screenshot to bitmap
4621 \end_layout
4623 \begin_layout Itemize
4624 Syntax: DBITMAP gui.screenshot_bitmap()
4625 \end_layout
4627 \begin_layout Standard
4628 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
4629  the result.
4630 \end_layout
4632 \begin_layout Subsection
4633 gui.color: Compose a color.
4634 \end_layout
4636 \begin_layout Itemize
4637 Syntax: number gui.color(number r, number g, number b[, number a])
4638 \end_layout
4640 \begin_layout Itemize
4641 Syntax: number gui.color(string c)
4642 \end_layout
4644 \begin_layout Standard
4645 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
4646 , each component in scale 0-255.
4647  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
4648  fully opaque).
4649  The default alpha is 256.
4650 \end_layout
4652 \begin_layout Standard
4653 The form taking a string returns color corresponding color name.
4654 \end_layout
4656 \begin_layout Subsection
4657 gui.status: Set status variable
4658 \end_layout
4660 \begin_layout Itemize
4661 Syntax: none gui.status(string name, string value)
4662 \end_layout
4664 \begin_layout Standard
4665 Set status field 
4666 \begin_inset Quotes eld
4667 \end_inset
4669 L[<name>]
4670 \begin_inset Quotes erd
4671 \end_inset
4673  to <value> in status area.
4674 \end_layout
4676 \begin_layout Subsection
4677 gui.rainbow: Rainbow color calculation
4678 \end_layout
4680 \begin_layout Itemize
4681 Syntax: number gui.rainbow(number step, number steps[, number color])
4682 \end_layout
4684 \begin_layout Standard
4685 Perform hue rotation of color <color> (default bright red), by <step> steps.
4686  The number of steps per full rotation is given by absolute value of <steps>.
4687 \end_layout
4689 \begin_layout Standard
4690 If <step> is negative, the rotation will be counterclockwise.
4691 \end_layout
4693 \begin_layout Subsection
4694 gui.kill_frame: Kill video frame and associated sound
4695 \end_layout
4697 \begin_layout Itemize
4698 Syntax: none gui.kill_frame()
4699 \end_layout
4701 \begin_layout Standard
4702 Kills the currently dumped video frame + the associated sound.
4703  Only valid in on_video callback.
4704 \end_layout
4706 \begin_layout Subsection
4707 gui.set_video_scale: Set video frame scale
4708 \end_layout
4710 \begin_layout Itemize
4711 Syntax: none gui.set_video_scale(number h, number v)
4712 \end_layout
4714 \begin_layout Standard
4715 Sets the scale factors of current frame to <h>x<v>.
4716  Only valid in on_video callback.
4717 \end_layout
4719 \begin_layout Subsection
4720 gui.arrow: Draw an arrow
4721 \end_layout
4723 \begin_layout Itemize
4724 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
4725  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
4727 \end_layout
4729 \begin_layout Standard
4730 Draws an arrow using color <color>.
4731  The tip of arrow is at (<x>, <y>).
4732  Other parameters:
4733 \end_layout
4735 \begin_layout Enumerate
4736 <length>: The length of arrow tail.
4737 \end_layout
4739 \begin_layout Enumerate
4740 <hwidth>: The width of arrow head.
4741  Should be odd.
4742 \end_layout
4744 \begin_layout Enumerate
4745 <direction>: Direction of arrow.
4746  0 is to right, +1 rotates 45 degrees counterclockwise.
4747 \end_layout
4749 \begin_layout Enumerate
4750 <fill>: If true, fill the arrow head.
4751  Default false.
4752 \end_layout
4754 \begin_layout Enumerate
4755 <twidth>: Tail width.
4756  Should be odd.
4757  Default 1.
4758 \end_layout
4760 \begin_layout Enumerate
4761 <hthick>: Head thickness (only used if <fill> is false).
4762  Default is <twidth>.
4763 \end_layout
4765 \begin_layout Subsection
4766 gui.tiled_bitmap: Class TILEMAP
4767 \end_layout
4769 \begin_layout Standard
4770 See class TILEMAP.
4771 \end_layout
4773 \begin_layout Subsection
4774 gui.palette: Class PALETTE
4775 \end_layout
4777 \begin_layout Standard
4778 See class PALETTE.
4779 \end_layout
4781 \begin_layout Subsection
4782 gui.bitmap: Class BITMAP
4783 \end_layout
4785 \begin_layout Standard
4786 See class BITMAP.
4787 \end_layout
4789 \begin_layout Subsection
4790 gui.dbitmap: Class DBITMAP
4791 \end_layout
4793 \begin_layout Standard
4794 See class DBITMAP.
4795 \end_layout
4797 \begin_layout Subsection
4798 gui.font: Class CUSTOMFONT
4799 \end_layout
4801 \begin_layout Standard
4802 See class CUSTOMFONT.
4803 \end_layout
4805 \begin_layout Subsection
4806 gui.renderctx: Class RENDERCTX
4807 \end_layout
4809 \begin_layout Standard
4810 See class RENDERCTX.
4811 \end_layout
4813 \begin_layout Subsection
4814 gui.image: Class IMAGELOADER
4815 \end_layout
4817 \begin_layout Standard
4818 See class IMAGELOADER.
4819 \end_layout
4821 \begin_layout Standard
4822 \begin_inset Newpage pagebreak
4823 \end_inset
4826 \end_layout
4828 \begin_layout Section
4829 table input
4830 \end_layout
4832 \begin_layout Standard
4833 Input handling.
4834  Functions manipulating input are only available in on_input callback.
4835 \end_layout
4837 \begin_layout Subsection
4838 input.get: Read controller button/axis (deprecated)
4839 \end_layout
4841 \begin_layout Itemize
4842 Syntax: number input.get(number controller, number index)
4843 \end_layout
4845 \begin_layout Standard
4846 Read the specified index <index> (zero-based) from specified controller
4847  <controller> (zero-based).
4849 \end_layout
4851 \begin_layout Subsection
4852 input.set: Write controller button/axis (deprecated)
4853 \end_layout
4855 \begin_layout Itemize
4856 Syntax: none input.set(number controller, number index, number value)
4857 \end_layout
4859 \begin_layout Standard
4860 Write the specified index <index> (zero-based) from specified controller
4861  <controller> (zero-based), storing value <value>.
4862 \end_layout
4864 \begin_layout Subsection
4865 input.get2: Read controller button/axis
4866 \end_layout
4868 \begin_layout Itemize
4869 Syntax: number input.get2(number port, number controller, number index)
4870 \end_layout
4872 \begin_layout Standard
4873 Read the specified input tuple.
4874  Port 0 is system port.
4875 \end_layout
4877 \begin_layout Subsection
4878 input.set2: Write controller button/axis
4879 \end_layout
4881 \begin_layout Itemize
4882 Syntax: input.set2(number port, number controller, number index, number value)
4883 \end_layout
4885 \begin_layout Standard
4886 Write the specified input tuple.
4887  Port 0 is system port.
4888 \end_layout
4890 \begin_layout Subsection
4891 input.lcid_to_pcid2: Look up logical controller
4892 \end_layout
4894 \begin_layout Itemize
4895 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
4896 \end_layout
4898 \begin_layout Standard
4899 Look up physical pcid pair (port, controller) corresponding to specified
4900  logical controller (1-based).
4901  Returns nothing if controller does not exist.
4902 \end_layout
4904 \begin_layout Subsection
4905 input.port_type: Look up port type
4906 \end_layout
4908 \begin_layout Itemize
4909 Syntax: string input.port_type(number port)
4910 \end_layout
4912 \begin_layout Standard
4913 Return type of specified port.
4914 \end_layout
4916 \begin_layout Subsection
4917 input.controller_info: Get information about controller
4918 \end_layout
4920 \begin_layout Itemize
4921 Syntax: table input.controller_info(number port, number controller)
4922 \end_layout
4924 \begin_layout Standard
4925 Get controller info for specified controller.
4926  If controller does not exist, returns nil.
4927  Otherwise returns a table with following fields:
4928 \end_layout
4930 \begin_layout Itemize
4931 type (string): Type of the controller.
4932 \end_layout
4934 \begin_layout Itemize
4935 class (string): Class of the controller.
4936 \end_layout
4938 \begin_layout Itemize
4939 classnum (number): Number of the controller within its class (1-based)
4940 \end_layout
4942 \begin_layout Itemize
4943 lcid (number): Logical controller number of the controller.
4944 \end_layout
4946 \begin_layout Itemize
4947 button_count (number): Number of buttons on controller
4948 \end_layout
4950 \begin_layout Itemize
4951 buttons (array): Array of following info about each button:
4952 \end_layout
4954 \begin_deeper
4955 \begin_layout Itemize
4956 type (string): Type of button.
4957  Currently one of 
4958 \begin_inset Quotes eld
4959 \end_inset
4961 null
4962 \begin_inset Quotes erd
4963 \end_inset
4966 \begin_inset Quotes eld
4967 \end_inset
4969 button
4970 \begin_inset Quotes erd
4971 \end_inset
4974 \begin_inset Quotes eld
4975 \end_inset
4977 axis
4978 \begin_inset Quotes erd
4979 \end_inset
4982 \begin_inset Quotes eld
4983 \end_inset
4985 raxis
4986 \begin_inset Quotes erd
4987 \end_inset
4990 \end_layout
4992 \begin_layout Itemize
4993 name (string): Name of button.
4994 \end_layout
4996 \begin_layout Itemize
4997 symbol (string): Symbol of button.
4998  Only present for type 
4999 \begin_inset Quotes eld
5000 \end_inset
5002 button
5003 \begin_inset Quotes erd
5004 \end_inset
5007 \end_layout
5009 \begin_layout Itemize
5010 hidden (boolean): True if hidden button.
5012 \end_layout
5014 \end_deeper
5015 \begin_layout Subsection
5016 input.veto_button: Veto a button press
5017 \end_layout
5019 \begin_layout Itemize
5020 Syntax: none input.veto_button()
5021 \end_layout
5023 \begin_layout Standard
5024 Signals that the button event should be vetoed.
5025  Only valid in on_button callback.
5026 \end_layout
5028 \begin_layout Subsection
5029 input.geta: Get all buttons for controller (deprecated)
5030 \end_layout
5032 \begin_layout Itemize
5033 Syntax: (number, number...) input.geta(number controller)
5034 \end_layout
5036 \begin_layout Standard
5037 Get input state for entiere controller.
5038  Returns n return values.
5039 \end_layout
5041 \begin_layout Itemize
5042 1st return value: Bitmask: bit i is set if i:th index is nonzero
5043 \end_layout
5045 \begin_layout Itemize
5046 2nd- return value: value of i:th index.
5047 \end_layout
5049 \begin_layout Subsection
5050 input.seta: Set all buttons for controller (deprecated)
5051 \end_layout
5053 \begin_layout Itemize
5054 Syntax: none input.seta(number controller, number bitmask, number args...)
5055 \end_layout
5057 \begin_layout Standard
5058 Set state for entiere controller.
5059  args is up to N values for indices (overriding values in bitmask if specified).
5060 \end_layout
5062 \begin_layout Subsection
5063 input.controllertype: Get controller type (deprecated)
5064 \end_layout
5066 \begin_layout Itemize
5067 syntax: string input.controllertype(number controller)
5068 \end_layout
5070 \begin_layout Standard
5071 Get the type of controller as string.
5072 \end_layout
5074 \begin_layout Subsection
5075 input.reset: Execute (delayed) reset
5076 \end_layout
5078 \begin_layout Itemize
5079 Syntax: none input.reset([number cycles])
5080 \end_layout
5082 \begin_layout Standard
5083 Execute reset.
5084  If <cycles> is greater than zero, do delayed reset.
5085  0 (or no value) causes immediate reset.
5086 \end_layout
5088 \begin_layout Itemize
5089 Note: Only available with subframe flag false.
5090 \end_layout
5092 \begin_layout Subsection
5093 input.raw: Return raw input data
5094 \end_layout
5096 \begin_layout Itemize
5097 Syntax: table input.raw()
5098 \end_layout
5100 \begin_layout Standard
5101 Returns table of tables of all available keys and axes.
5102  The first table is indexed by key name (platform-dependent!), and the inner
5103  table has the following fields:
5104 \end_layout
5106 \begin_layout Itemize
5107 value: Last reported value for control
5108 \end_layout
5110 \begin_deeper
5111 \begin_layout Itemize
5112 For keys: 1 for pressed, 0 for released.
5113 \end_layout
5115 \begin_layout Itemize
5116 For axes: -32767...32767.
5117 \end_layout
5119 \begin_layout Itemize
5120 For presure-sensitive buttons: 0...32767.
5121 \end_layout
5123 \begin_layout Itemize
5124 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
5125 \end_layout
5127 \begin_layout Itemize
5128 For mouse: Coordinates relative to game area.
5129 \end_layout
5131 \end_deeper
5132 \begin_layout Itemize
5133 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
5134 \end_layout
5136 \begin_layout Subsection
5137 input.keyhook: Hook a key
5138 \end_layout
5140 \begin_layout Itemize
5141 Syntax: none input.keyhook(string key, boolean state)
5142 \end_layout
5144 \begin_layout Standard
5145 Requests that keyhook events to be sent for key <key> (<state>=true) or
5146  not sent (<state>=false).
5147 \end_layout
5149 \begin_layout Subsection
5150 input.joyget: Get controls for controller
5151 \end_layout
5153 \begin_layout Itemize
5154 Syntax: table input.joyget(number logical)
5155 \end_layout
5157 \begin_layout Standard
5158 Returns table for current controls for specified logical controller <logical>.
5159  The names of fields vary by controller type.
5160 \end_layout
5162 \begin_layout Itemize
5163 The buttons have the same name as those are referred to in other contexts
5164  in the emulator
5165 \end_layout
5167 \begin_layout Itemize
5168 The analog axes are usually 
5169 \begin_inset Quotes eld
5170 \end_inset
5172 xaxis
5173 \begin_inset Quotes erd
5174 \end_inset
5176  and 
5177 \begin_inset Quotes eld
5178 \end_inset
5180 yaxis
5181 \begin_inset Quotes erd
5182 \end_inset
5185 \end_layout
5187 \begin_layout Itemize
5188 Each field is numeric or boolean depending on axis/button.
5189 \end_layout
5191 \begin_layout Subsection
5192 input.joyset: Set controls for controller
5193 \end_layout
5195 \begin_layout Itemize
5196 Syntax: none input.joyset(number controller, table controls)
5197 \end_layout
5199 \begin_layout Standard
5200 Set the the state of specified controller to values specified in specified
5201  table.
5202 \end_layout
5204 \begin_layout Itemize
5205 Each field can be boolean or number.
5206 \end_layout
5208 \begin_layout Itemize
5209 Also, buttons allow strings, which cause value to be inverted.
5210 \end_layout
5212 \begin_layout Subsection
5213 input.lcid_to_pcid: Look up logical controller (deprecated)
5214 \end_layout
5216 \begin_layout Itemize
5217 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
5218 \end_layout
5220 \begin_layout Standard
5221 Returns the legacy pcid for controller (or false if there isn't one), followed
5222  by pcid pair.
5223  Returns nothing if controller does not exist.
5224 \end_layout
5226 \begin_layout Standard
5227 \begin_inset Newpage pagebreak
5228 \end_inset
5231 \end_layout
5233 \begin_layout Section
5234 Table keyboard
5235 \end_layout
5237 \begin_layout Standard
5238 Various keybinding-related functions
5239 \end_layout
5241 \begin_layout Subsection
5242 keyboard.bind: Bind a key
5243 \end_layout
5245 \begin_layout Itemize
5246 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
5247 \end_layout
5249 \begin_layout Standard
5250 Bind specified key with specified modifers to specified command.
5251 \end_layout
5253 \begin_layout Subsection
5254 keyboard.unbind: Unbind a key
5255 \end_layout
5257 \begin_layout Itemize
5258 Syntax: none keyboard.unbind(string mod, string mask, string key)
5259 \end_layout
5261 \begin_layout Standard
5262 Unbind specified key with specified modifers.
5263 \end_layout
5265 \begin_layout Subsection
5266 keyboard.alias: Set alias expansion
5267 \end_layout
5269 \begin_layout Itemize
5270 Syntax: none keyboard.alias(string alias, string expansion)
5271 \end_layout
5273 \begin_layout Standard
5274 Set expansion of given command.
5275 \end_layout
5277 \begin_layout Standard
5278 \begin_inset Newpage pagebreak
5279 \end_inset
5282 \end_layout
5284 \begin_layout Section
5285 Table subtitle
5286 \end_layout
5288 \begin_layout Standard
5289 Subtitle handling
5290 \end_layout
5292 \begin_layout Subsection
5293 subtitle.byindex: Look up start and length of subtitle by index
5294 \end_layout
5296 \begin_layout Itemize
5297 Syntax: (number, number) subtitle.byindex(number i)
5298 \end_layout
5300 \begin_layout Standard
5301 Read the frame and length of ith subtitle.
5302  Returns nothing if not present.
5303 \end_layout
5305 \begin_layout Subsection
5306 subtitle.set: Write a subtitle
5307 \end_layout
5309 \begin_layout Itemize
5310 Syntax: none subtitle.set(number f, number l, string txt)
5311 \end_layout
5313 \begin_layout Standard
5314 Set the text of subtitle.
5315 \end_layout
5317 \begin_layout Subsection
5318 subtitle.get: Read a subtitle
5319 \end_layout
5321 \begin_layout Itemize
5322 Syntax: string subtitle.get(number f, number l)
5323 \end_layout
5325 \begin_layout Standard
5326 Get the text of subtitle.
5327 \end_layout
5329 \begin_layout Subsection
5330 subtitle.delete: Delete a subtitle
5331 \end_layout
5333 \begin_layout Itemize
5334 Syntax: none subtitle.delete(number f, number l)
5335 \end_layout
5337 \begin_layout Standard
5338 Delete specified subtitle.
5339 \end_layout
5341 \begin_layout Standard
5342 \begin_inset Newpage pagebreak
5343 \end_inset
5346 \end_layout
5348 \begin_layout Section
5349 Table hostmemory
5350 \end_layout
5352 \begin_layout Standard
5353 Host memory handling (extra memory saved to savestates).
5354  Host memory starts empty.
5355 \end_layout
5357 \begin_layout Itemize
5358 Reads out of range return false.
5359 \end_layout
5361 \begin_layout Itemize
5362 Writes out of range extend the memory.
5363 \end_layout
5365 \begin_layout Subsection
5366 hostmemory.read: Read byte from host memory
5367 \end_layout
5369 \begin_layout Itemize
5370 Syntax: number hostmemory.read(number address)
5371 \end_layout
5373 \begin_layout Standard
5374 Reads byte from hostmemory slot address <address>.
5375 \end_layout
5377 \begin_layout Subsection
5378 hostmemory.write: Write byte to host memory
5379 \end_layout
5381 \begin_layout Itemize
5382 Syntax: none hostmemory.write(number address, number value)
5383 \end_layout
5385 \begin_layout Standard
5386 Writes hostmemory slot with value <value> 0-255.
5387 \end_layout
5389 \begin_layout Subsection
5390 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
5391 \end_layout
5393 \begin_layout Itemize
5394 Syntax: number hostmemory.readbyte(number address)
5395 \end_layout
5397 \begin_layout Itemize
5398 Syntax: number hostmemory.readsbyte(number address)
5399 \end_layout
5401 \begin_layout Itemize
5402 Syntax: number hostmemory.readword(number address)
5403 \end_layout
5405 \begin_layout Itemize
5406 Syntax: number hostmemory.readsword(number address)
5407 \end_layout
5409 \begin_layout Itemize
5410 Syntax: number hostmemory.readhword(number address)
5411 \end_layout
5413 \begin_layout Itemize
5414 Syntax: number hostmemory.readshword(number address)
5415 \end_layout
5417 \begin_layout Itemize
5418 Syntax: number hostmemory.readdword(number address)
5419 \end_layout
5421 \begin_layout Itemize
5422 Syntax: number hostmemory.readsdword(number address)
5423 \end_layout
5425 \begin_layout Itemize
5426 Syntax: number hostmemory.readqword(number address)
5427 \end_layout
5429 \begin_layout Itemize
5430 Syntax: number hostmemory.readsqword(number address)
5431 \end_layout
5433 \begin_layout Standard
5434 Read elements (big-endian) from given address <address>.
5435 \end_layout
5437 \begin_layout Itemize
5438 byte is 1 element
5439 \end_layout
5441 \begin_layout Itemize
5442 word is 2 elements
5443 \end_layout
5445 \begin_layout Itemize
5446 hword is 3 elements
5447 \end_layout
5449 \begin_layout Itemize
5450 dword is 4 elements
5451 \end_layout
5453 \begin_layout Itemize
5454 qword is 8 elements.
5455 \end_layout
5457 \begin_layout Itemize
5458 The 's' variants do signed read.
5459 \end_layout
5461 \begin_layout Subsection
5462 hostmemory.read{float,double}: Read from host memory
5463 \end_layout
5465 \begin_layout Itemize
5466 syntax: number hostmemory.readfloat(number address)
5467 \end_layout
5469 \begin_layout Itemize
5470 Syntax: number hostmemory.readdouble(number address)
5471 \end_layout
5473 \begin_layout Standard
5474 Read elements (big-endian) floating-pont from given address <address>.
5475 \end_layout
5477 \begin_layout Subsection
5478 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
5479 \end_layout
5481 \begin_layout Itemize
5482 Syntax: number hostmemory.writebyte(number address, number value)
5483 \end_layout
5485 \begin_layout Itemize
5486 Syntax: number hostmemory.writesbyte(number address, number value)
5487 \end_layout
5489 \begin_layout Itemize
5490 Syntax: number hostmemory.writeword(number address, number value)
5491 \end_layout
5493 \begin_layout Itemize
5494 Syntax: number hostmemory.writesword(number address, number value)
5495 \end_layout
5497 \begin_layout Itemize
5498 Syntax: number hostmemory.writehword(number address, number value)
5499 \end_layout
5501 \begin_layout Itemize
5502 Syntax: number hostmemory.writeshword(number address, number value)
5503 \end_layout
5505 \begin_layout Itemize
5506 Syntax: number hostmemory.writedword(number address, number value)
5507 \end_layout
5509 \begin_layout Itemize
5510 Syntax: number hostmemory.writesdword(number address, number value)
5511 \end_layout
5513 \begin_layout Itemize
5514 Syntax: number hostmemory.writeqword(number address, number value)
5515 \end_layout
5517 \begin_layout Itemize
5518 Syntax: number hostmemory.writesqword(number address, number value)
5519 \end_layout
5521 \begin_layout Standard
5522 Write value <value> to elements (little-endian) starting from given address
5523  <address>.
5524 \end_layout
5526 \begin_layout Itemize
5527 byte is 1 element
5528 \end_layout
5530 \begin_layout Itemize
5531 word is 2 elements
5532 \end_layout
5534 \begin_layout Itemize
5535 hword is 3 elements
5536 \end_layout
5538 \begin_layout Itemize
5539 dword is 4 elements
5540 \end_layout
5542 \begin_layout Itemize
5543 qword is 8 elements.
5544 \end_layout
5546 \begin_layout Itemize
5547 The 's' variants do signed write.
5548 \end_layout
5550 \begin_layout Subsection
5551 hostmemory.write{float,double}: Write to host memory
5552 \end_layout
5554 \begin_layout Itemize
5555 syntax: none hostmemory.readfloat(number address, number value)
5556 \end_layout
5558 \begin_layout Itemize
5559 Syntax: none hostmemory.readdouble(number address, number value)
5560 \end_layout
5562 \begin_layout Standard
5563 Write elements (big-endian) floating-pont to given address <address>, storing
5564  <value>.
5565 \end_layout
5567 \begin_layout Standard
5568 \begin_inset Newpage pagebreak
5569 \end_inset
5572 \end_layout
5574 \begin_layout Section
5575 Table movie
5576 \end_layout
5578 \begin_layout Standard
5579 Movie handling
5580 \end_layout
5582 \begin_layout Subsection
5583 movie.currentframe: Get current frame number
5584 \end_layout
5586 \begin_layout Itemize
5587 Syntax: number movie.currentframe()
5588 \end_layout
5590 \begin_layout Standard
5591 Return number of current frame.
5592 \end_layout
5594 \begin_layout Subsection
5595 movie.framecount: Get move frame count
5596 \end_layout
5598 \begin_layout Itemize
5599 Syntax: number movie.framecount()
5600 \end_layout
5602 \begin_layout Standard
5603 Return number of frames in movie.
5604 \end_layout
5606 \begin_layout Subsection
5607 movie.readonly: Is in readonly mode?
5608 \end_layout
5610 \begin_layout Itemize
5611 Syntax: boolean movie.readonly()
5612 \end_layout
5614 \begin_layout Standard
5615 Return true if in readonly mode, false if in readwrite.
5616 \end_layout
5618 \begin_layout Subsection
5619 movie.rerecords: Movie rerecord count
5620 \end_layout
5622 \begin_layout Itemize
5623 Syntax: number movie.rerecords()
5624 \end_layout
5626 \begin_layout Standard
5627 Returns the current value of rerecord count.
5628 \end_layout
5630 \begin_layout Subsection
5631 movie.set_readwrite: Set read-write mode.
5632 \end_layout
5634 \begin_layout Itemize
5635 Syntax: none movie.set_readwrite()
5636 \end_layout
5638 \begin_layout Standard
5639 Set readwrite mode (does not cause on_readwrite callback).
5640 \end_layout
5642 \begin_layout Subsection
5643 movie.frame_subframes: Count subframes in frame
5644 \end_layout
5646 \begin_layout Itemize
5647 Syntax: number movie.frame_subframes(number frame)
5648 \end_layout
5650 \begin_layout Standard
5651 Count number of subframes in specified frame <frame> (frame numbers are
5652  1-based) and return that.
5653 \end_layout
5655 \begin_layout Subsection
5656 movie.read_subframes: Read subframe data (deprecated)
5657 \end_layout
5659 \begin_layout Itemize
5660 Syntax: table movie.read_subframes(number frame, number subframe)
5661 \end_layout
5663 \begin_layout Standard
5664 Read specifed subframe in specified frame and return data as array.
5665 \end_layout
5667 \begin_layout Subsection
5668 movie.read_rtc: Read current RTC time
5669 \end_layout
5671 \begin_layout Itemize
5672 Syntax: (number, number) movie.read_rtc()
5673 \end_layout
5675 \begin_layout Standard
5676 Returns the current value of the RTC as a pair (second, subsecond).
5677 \end_layout
5679 \begin_layout Subsection
5680 movie.unsafe_rewind: Fast movie rewind to saved state
5681 \end_layout
5683 \begin_layout Itemize
5684 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
5685 \end_layout
5687 \begin_layout Standard
5688 Start setting point for unsafe rewind or jump to point of unsafe rewind.
5689 \end_layout
5691 \begin_layout Itemize
5692 If called without argument, causes emulator to start process of setting
5693  unsafe rewind point.
5694  When this has finished, callback on_set_rewind occurs, passing the rewind
5695  state to lua script.
5696 \end_layout
5698 \begin_layout Itemize
5699 If called with argument, causes emulator rewind to passed rewind point as
5700  soon as possible.
5701  Readwrite mode is implicitly activated.
5702 \end_layout
5704 \begin_layout Standard
5705 The following warnings apply to unsafe rewinding:
5706 \end_layout
5708 \begin_layout Itemize
5709 There are no safety checks against misuse (that's what 
5710 \begin_inset Quotes eld
5711 \end_inset
5713 unsafe
5714 \begin_inset Quotes erd
5715 \end_inset
5717  comes from)!
5718 \end_layout
5720 \begin_layout Itemize
5721 Only call rewind from timeline rewind point was set from.
5722 \end_layout
5724 \begin_layout Itemize
5725 Only call rewind from after the rewind point was set.
5726 \end_layout
5728 \begin_layout Subsection
5729 movie.to_rewind: Load savestate as rewind point
5730 \end_layout
5732 \begin_layout Itemize
5733 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
5734 \end_layout
5736 \begin_layout Standard
5737 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
5738  corresponding to it.
5739 \end_layout
5741 \begin_layout Itemize
5742 Note: This operation does not take emulated time.
5743 \end_layout
5745 \begin_layout Subsection
5746 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
5747 \end_layout
5749 \begin_layout Itemize
5750 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
5751 \end_layout
5753 \begin_layout Itemize
5754 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
5755 \end_layout
5757 \begin_layout Standard
5758 Copies specified movie or branch <movie>/current object (if none or nil,
5759  the active movie) as new movie object.
5760 \end_layout
5762 \begin_layout Subsection
5763 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
5764 \end_layout
5766 \begin_layout Itemize
5767 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
5768 \end_layout
5770 \begin_layout Itemize
5771 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
5772 \end_layout
5774 \begin_layout Standard
5775 Get INPUTFRAME object corresponding to specified frame in specified movie
5776  or branch.
5777 \end_layout
5779 \begin_layout Subsection
5780 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
5781 \end_layout
5783 \begin_layout Itemize
5784 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
5785  data)
5786 \end_layout
5788 \begin_layout Itemize
5789 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
5790 \end_layout
5792 \begin_layout Standard
5793 Set data in specified frame.
5794 \end_layout
5796 \begin_layout Itemize
5797 Note: Past can't be edited in active movie.
5798 \end_layout
5800 \begin_layout Subsection
5801 movie.get_size/INPUTMOVIE::get_size: Get size of movie
5802 \end_layout
5804 \begin_layout Itemize
5805 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
5806 \end_layout
5808 \begin_layout Itemize
5809 Syntax: integer INPUTMOVIE::get_size()
5810 \end_layout
5812 \begin_layout Standard
5813 Return number of subframes in specified movie or branch.
5814 \end_layout
5816 \begin_layout Subsection
5817 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
5818 \end_layout
5820 \begin_layout Itemize
5821 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
5822 \end_layout
5824 \begin_layout Itemize
5825 Syntax: number INPUTMOVIE::count_frames()
5826 \end_layout
5828 \begin_layout Standard
5829 Return number of frames in movie.
5830 \end_layout
5832 \begin_layout Subsection
5833 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
5834 \end_layout
5836 \begin_layout Itemize
5837 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
5838 \end_layout
5840 \begin_layout Itemize
5841 Syntax: number INPUTMOVIE::find_frame(number frame)
5842 \end_layout
5844 \begin_layout Standard
5845 Returns starting subframe of given frame (frame numbers are 1-based).
5846  Returns -1 if frame number is bad.
5847 \end_layout
5849 \begin_layout Subsection
5850 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
5851 \end_layout
5853 \begin_layout Itemize
5854 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
5855 \end_layout
5857 \begin_layout Itemize
5858 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
5859 \end_layout
5861 \begin_layout Standard
5862 Return blank INPUTFRAME with frame type from specified movie.
5863 \end_layout
5865 \begin_layout Subsection
5866 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
5867 \end_layout
5869 \begin_layout Itemize
5870 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
5871 \end_layout
5873 \begin_layout Itemize
5874 Syntax: none INPUTMOVIE::append_frames(number frames)
5875 \end_layout
5877 \begin_layout Standard
5878 Append specified number <frames> of frames.
5879 \end_layout
5881 \begin_layout Subsection
5882 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
5883 \end_layout
5885 \begin_layout Itemize
5886 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
5887 \end_layout
5889 \begin_layout Itemize
5890 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
5891 \end_layout
5893 \begin_layout Standard
5894 Append specified frame <frame>.
5895  Past of current movie can't be edited.
5896 \end_layout
5898 \begin_layout Subsection
5899 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
5900 \end_layout
5902 \begin_layout Itemize
5903 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
5904 \end_layout
5906 \begin_layout Itemize
5907 Syntax: none INPUTMOVIE::truncate(number frames)
5908 \end_layout
5910 \begin_layout Standard
5911 Truncate the specified movie to specified number of frames.
5912 \end_layout
5914 \begin_layout Subsection
5915 movie.edit/INPUTMOVIE::edit: Edit a movie
5916 \end_layout
5918 \begin_layout Itemize
5919 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
5920  controller, number control, number/bool value)
5921 \end_layout
5923 \begin_layout Itemize
5924 Syntax: none movie.edit(string branch, number frame, number port, number
5925  controller, number control, number/bool value)
5926 \end_layout
5928 \begin_layout Itemize
5929 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
5930  number control, number/bool value)
5931 \end_layout
5933 \begin_layout Standard
5934 Change specified control in specified frame in specified movie.
5935  Past can't be edited in active movie.
5936 \end_layout
5938 \begin_layout Subsection
5939 movie.copy_frames2: Copy frames between movies
5940 \end_layout
5942 \begin_layout Itemize
5943 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
5944 IE/string srcmov,] number src, number count)
5945 \end_layout
5947 \begin_layout Standard
5948 Copy specified number of frames between two movies.
5949  The copy proceeeds in forward direction.
5950 \end_layout
5952 \begin_layout Subsection
5953 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
5954 \end_layout
5956 \begin_layout Itemize
5957 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
5958  src, number count, bool backwards)
5959 \end_layout
5961 \begin_layout Itemize
5962 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
5963  bool backwards)
5964 \end_layout
5966 \begin_layout Standard
5967 Copy specified number of frames from one point in movie to another.
5968  If backwards is true, the copy will be done backwards.
5969 \end_layout
5971 \begin_layout Subsection
5972 movie.serialize/INPUTMOVIE::serialize: Serialize movie
5973 \end_layout
5975 \begin_layout Itemize
5976 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
5977  bool binary)
5978 \end_layout
5980 \begin_layout Itemize
5981 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
5982 \end_layout
5984 \begin_layout Standard
5985 Serialize given movie into file.
5986  If binary is true, binary format (more compact and much faster) is used.
5987 \end_layout
5989 \begin_layout Subsection
5990 movie.unserialize: Unserialize movie
5991 \end_layout
5993 \begin_layout Itemize
5994 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
5995  bool binary)
5996 \end_layout
5998 \begin_layout Standard
5999 Unserialize movie from file.
6000  The given frame is used as template to decide the frame type.
6001  If binary is true, binary format is decoded (much faster).
6002 \end_layout
6004 \begin_layout Subsection
6005 movie.current_first_subframe: Return first subframe in current frame
6006 \end_layout
6008 \begin_layout Itemize
6009 Syntax: number movie.current_first_subframe()
6010 \end_layout
6012 \begin_layout Standard
6013 Returns first subframe in current frame.
6014 \end_layout
6016 \begin_layout Subsection
6017 movie.pollcounter: Return poll counter for speified control
6018 \end_layout
6020 \begin_layout Itemize
6021 Syntax: number movie.pollcounter(number port, number controller, number control)
6022 \end_layout
6024 \begin_layout Standard
6025 Returns number of times the specified control has been polled this frame.
6026 \end_layout
6028 \begin_layout Subsection
6029 movie.current_branch: Return current branch
6030 \end_layout
6032 \begin_layout Itemize
6033 Syntax: string movie.current_branch()
6034 \end_layout
6036 \begin_layout Standard
6037 Returns the name of the current branch.
6038 \end_layout
6040 \begin_layout Subsection
6041 movie.get_branches: Return names of all branches
6042 \end_layout
6044 \begin_layout Itemize
6045 Syntax: string...
6046  movie.get_branches()
6047 \end_layout
6049 \begin_layout Standard
6050 Returns the name of all branches.
6051 \end_layout
6053 \begin_layout Subsection
6054 INPUTFRAME::get_button: Get button
6055 \end_layout
6057 \begin_layout Itemize
6058 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
6059  control)
6060 \end_layout
6062 \begin_layout Standard
6063 Returns state of given button as boolean.
6064 \end_layout
6066 \begin_layout Subsection
6067 INPUTFRAME::get_axis: Get axis
6068 \end_layout
6070 \begin_layout Itemize
6071 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
6072  control)
6073 \end_layout
6075 \begin_layout Standard
6076 Returns state of given axis as number.
6077 \end_layout
6079 \begin_layout Subsection
6080 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
6081 \end_layout
6083 \begin_layout Itemize
6084 Syntax: none INPUTFRAME::set_button(number port, number controller, number
6085  control, number/bool value)
6086 \end_layout
6088 \begin_layout Itemize
6089 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
6090  control)
6091 \end_layout
6093 \begin_layout Standard
6094 Set the given button/axis to given value.
6095 \end_layout
6097 \begin_layout Subsection
6098 INPUTFRAME::serialize: Serialize a frame
6099 \end_layout
6101 \begin_layout Itemize
6102 Syntax: string INPUTFRAME::serialize()
6103 \end_layout
6105 \begin_layout Standard
6106 Return string representation of frame.
6107 \end_layout
6109 \begin_layout Subsection
6110 INPUTFRAME::unserialize: Unserialize a frame
6111 \end_layout
6113 \begin_layout Itemize
6114 Syntax: none INPUTFRAME::unserialize(string data)
6115 \end_layout
6117 \begin_layout Standard
6118 Set current frame from given data.
6119 \end_layout
6121 \begin_layout Subsection
6122 INPUTFRAME::get_stride: Get movie stride
6123 \end_layout
6125 \begin_layout Itemize
6126 Syntax: number INPUTFRAME::get_stride()
6127 \end_layout
6129 \begin_layout Standard
6130 Return number of bytes needed to store the input frame.
6131  Mainly useful for some debugging.
6132 \end_layout
6134 \begin_layout Standard
6135 \begin_inset Newpage pagebreak
6136 \end_inset
6139 \end_layout
6141 \begin_layout Section
6142 Table settings
6143 \end_layout
6145 \begin_layout Standard
6146 Routines for settings manipulation
6147 \end_layout
6149 \begin_layout Subsection
6150 settings.get: Get value of setting
6151 \end_layout
6153 \begin_layout Itemize
6154 Syntax: string settings.get(string name)
6155 \end_layout
6157 \begin_layout Standard
6158 Get value of setting <name>.
6159  If setting value can't be obtained, returns (nil, error message).
6160 \end_layout
6162 \begin_layout Subsection
6163 settings.set: Set value of setting
6164 \end_layout
6166 \begin_layout Itemize
6167 Syntax: none settings.set(string name, string value)
6168 \end_layout
6170 \begin_layout Standard
6171 Set value <value> of setting <name>.
6172  If setting can't be set, returns (nil, error message).
6173 \end_layout
6175 \begin_layout Standard
6176 \begin_inset Newpage pagebreak
6177 \end_inset
6180 \end_layout
6182 \begin_layout Section
6183 Table memory
6184 \end_layout
6186 \begin_layout Standard
6187 Contains various functions for managing memory
6188 \end_layout
6190 \begin_layout Subsection
6191 memory.vma_count: Count number of VMAs.
6192 \end_layout
6194 \begin_layout Itemize
6195 Syntax: number memory.vma_count()
6196 \end_layout
6198 \begin_layout Standard
6199 Returns the number of VMAs
6200 \end_layout
6202 \begin_layout Subsection
6203 memory.read_vma: Lookup VMA info by index
6204 \end_layout
6206 \begin_layout Itemize
6207 Syntax: string memory.read_vma(number index)
6208 \end_layout
6210 \begin_layout Standard
6211 Reads the specified VMA (indices start from zero).
6212  Trying to read invalid VMA gives nil.
6213  The read VMA is table with the following fields:
6214 \end_layout
6216 \begin_layout Itemize
6217 region_name (string): The readable name of the VMA
6218 \end_layout
6220 \begin_layout Itemize
6221 baseaddr (number): Base address of the VMA
6222 \end_layout
6224 \begin_layout Itemize
6225 lastaddr (number): Last address in the VMA.
6226 \end_layout
6228 \begin_layout Itemize
6229 size (number): The size of VMA in bytes.
6230 \end_layout
6232 \begin_layout Itemize
6233 readonly (boolean): True of the VMA corresponds to ROM.
6234 \end_layout
6236 \begin_layout Itemize
6237 iospace (boolean): True if the VMA is I/O space.
6238 \end_layout
6240 \begin_layout Itemize
6241 native_endian (boolean): True if the VMA has native endian as opposed to
6242  little endian.
6243 \end_layout
6245 \begin_layout Subsection
6246 memory.find_vma: Find VMA info by address
6247 \end_layout
6249 \begin_layout Itemize
6250 Syntax: table memory.find_vma(number address)
6251 \end_layout
6253 \begin_layout Standard
6254 Finds the VMA containing specified address.
6255  Returns table in the same format as read_vma or nil if not found.
6256 \end_layout
6258 \begin_layout Subsection
6259 memory.read{,s}{byte,{,h,d,q}word}: Read memory
6260 \end_layout
6262 \begin_layout Itemize
6263 Syntax: none memory.readbyte([string vma, ]number address)
6264 \end_layout
6266 \begin_layout Itemize
6267 Syntax: none memory.readword([string vma, ]number address)
6268 \end_layout
6270 \begin_layout Itemize
6271 Syntax: none memory.readhword([string vma, ]number address)
6272 \end_layout
6274 \begin_layout Itemize
6275 Syntax: none memory.readdword([string vma, ]number address)
6276 \end_layout
6278 \begin_layout Itemize
6279 Syntax: none memory.readqword([string vma, ]number address)
6280 \end_layout
6282 \begin_layout Itemize
6283 Syntax: none memory.readsbyte([string vma, ]number address)
6284 \end_layout
6286 \begin_layout Itemize
6287 Syntax: none memory.readsword([string vma, ]number address)
6288 \end_layout
6290 \begin_layout Itemize
6291 Syntax: none memory.readshword([string vma, ]number address)
6292 \end_layout
6294 \begin_layout Itemize
6295 Syntax: none memory.readsdword([string vma, ]number address)
6296 \end_layout
6298 \begin_layout Itemize
6299 Syntax: none memory.readsqword([string vma, ]number address)
6300 \end_layout
6302 \begin_layout Standard
6303 Reads the specified address <address> (if 's' variant is used, do undergo
6304  2's complement).
6305 \end_layout
6307 \begin_layout Subsection
6308 memory.{,s}read_sg: Scatter/Gather read memory
6309 \end_layout
6311 \begin_layout Itemize
6312 Syntax: none memory.read_sg(string/boolean/number...)
6313 \end_layout
6315 \begin_layout Itemize
6316 Syntax: none memory.sread_sg(string/boolean/number...)
6317 \end_layout
6319 \begin_layout Standard
6320 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
6321  of memory.
6322  Each argument can be string, boolean or number:
6323 \end_layout
6325 \begin_layout Itemize
6326 String: Set VMA addresses are relative to (e.g.
6327  'WRAM').
6328 \end_layout
6330 \begin_layout Itemize
6331 boolean: If true, increment relative address by 1, if false, decrement by
6332  1.
6333  The new address is read as next higher byte.
6334 \end_layout
6336 \begin_layout Itemize
6337 integer: Set the relative address to specified value and read the address
6338  as next higher byte.
6339 \end_layout
6341 \begin_layout Subsection
6342 memory.write_sg: Scatter/Gather write memory
6343 \end_layout
6345 \begin_layout Itemize
6346 Syntax: none memory.write_sg(number value, string/boolean/number...)
6347 \end_layout
6349 \begin_layout Standard
6350 Perform scatter/gather write of value <value> on memory.
6351  Each argument can be string, boolean or number:
6352 \end_layout
6354 \begin_layout Itemize
6355 String: Set VMA addresses are relative to (e.g.
6356  'WRAM').
6357 \end_layout
6359 \begin_layout Itemize
6360 boolean: If true, increment relative address by 1, if false, decrement by
6361  1.
6362  The new address is read as next higher byte.
6363 \end_layout
6365 \begin_layout Itemize
6366 integer: Set the relative address to specified value and read the address
6367  as next higher byte.
6368 \end_layout
6370 \begin_layout Subsection
6371 memory.read{float,double}: Read memory
6372 \end_layout
6374 \begin_layout Itemize
6375 Syntax: none memory.readfloat([string vma, ]number address)
6376 \end_layout
6378 \begin_layout Itemize
6379 Syntax: none memory.readdouble([string vma, ]number address)
6380 \end_layout
6382 \begin_layout Standard
6383 Reads the specified address <address>
6384 \end_layout
6386 \begin_layout Subsection
6387 memory.write{byte,{,h,d,q}word,float,double}: Write memory
6388 \end_layout
6390 \begin_layout Itemize
6391 Syntax: none memory.writebyte([string vma, ]number address, number value)
6392 \end_layout
6394 \begin_layout Itemize
6395 Syntax: none memory.writeword([string vma, ]number address, number value)
6396 \end_layout
6398 \begin_layout Itemize
6399 Syntax: none memory.writehword([string vma, ]number address, number value)
6400 \end_layout
6402 \begin_layout Itemize
6403 Syntax: none memory.writedword([string vma, ]number address, number value)
6404 \end_layout
6406 \begin_layout Itemize
6407 Syntax: none memory.writeqword([string vma, ]number address, number value)
6408 \end_layout
6410 \begin_layout Itemize
6411 Syntax: none memory.writefloat([string vma, ]number address, number value)
6412 \end_layout
6414 \begin_layout Itemize
6415 Syntax: none memory.writedouble([string vma, ]number address, number value)
6416 \end_layout
6418 \begin_layout Standard
6419 Writes the specified value <value> (negative integer values undergo 2's
6420  complement) to specified address <address>.
6421 \end_layout
6423 \begin_layout Subsection
6424 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
6425 \end_layout
6427 \begin_layout Itemize
6428 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
6429 \end_layout
6431 \begin_layout Standard
6432 Returns a table mapping specified memory aperture for read/write.
6433  If parameters are omitted, entiere map space is the aperture.
6434 \end_layout
6436 \begin_layout Itemize
6437 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
6438  qword, sqword, float or double.
6439 \end_layout
6441 \begin_layout Subsection
6442 memory.hash_region: Hash region of memory
6443 \end_layout
6445 \begin_layout Itemize
6446 Syntax: string memory.hash_region([string vma, ]number base, number size)
6447 \end_layout
6449 \begin_layout Standard
6450 Hash specified number of bytes starting from specified address and return
6451  the SHA-256.
6452 \end_layout
6454 \begin_layout Subsection
6455 memory.hash_state: Hash system state
6456 \end_layout
6458 \begin_layout Itemize
6459 Syntax: string memory.hash_state()
6460 \end_layout
6462 \begin_layout Standard
6463 Hash the current system state.
6464  Mainly useful for debugging savestates.
6465 \end_layout
6467 \begin_layout Subsection
6468 memory.readregion: Read region of memory
6469 \end_layout
6471 \begin_layout Itemize
6472 Syntax: table memory.readregion([string vma, ]number base, number size)
6473 \end_layout
6475 \begin_layout Standard
6476 Read a region of memory.
6477 \end_layout
6479 \begin_layout Itemize
6480 Warning: If the region crosses VMA boundary, the results are undefined.
6481 \end_layout
6483 \begin_layout Subsection
6484 memory.writeregion: Write region of memory
6485 \end_layout
6487 \begin_layout Itemize
6488 Syntax: none memory.writeregion([string vma, ]number base, number size, table
6489  data)
6490 \end_layout
6492 \begin_layout Standard
6493 Write a region of memory.
6494 \end_layout
6496 \begin_layout Itemize
6497 Warning: If the region crosses VMA boundary, the results are undefined.
6498 \end_layout
6500 \begin_layout Subsection
6501 memory.read_expr: Evaluate memory watch expression
6502 \end_layout
6504 \begin_layout Itemize
6505 Syntax: string memory.read_expr(string expr)
6506 \end_layout
6508 \begin_layout Standard
6509 Evaluate specified watch expression and return result
6510 \end_layout
6512 \begin_layout Subsection
6513 memory.action: Run core action
6514 \end_layout
6516 \begin_layout Itemize
6517 memory.action(string action, [<params>])
6518 \end_layout
6520 \begin_layout Standard
6521 Run core action.
6522  The different models expect parameters as:
6523 \end_layout
6525 \begin_layout Itemize
6526 string: String
6527 \end_layout
6529 \begin_layout Itemize
6530 numeric: numeric
6531 \end_layout
6533 \begin_layout Itemize
6534 enumeration: String
6535 \end_layout
6537 \begin_layout Itemize
6538 boolean: String
6539 \end_layout
6541 \begin_layout Itemize
6542 toggle: None.
6543 \end_layout
6545 \begin_layout Subsection
6546 memory.get_lag_flag: Get lag flag
6547 \end_layout
6549 \begin_layout Itemize
6550 Syntax: boolean memory.get_lag_flag()
6551 \end_layout
6553 \begin_layout Standard
6554 Get the value of core lag flag.
6555  True if this frame has been lag so far, false if poll has been detected.
6556 \end_layout
6558 \begin_layout Subsection
6559 memory.set_lag_flag: Set lag flag
6560 \end_layout
6562 \begin_layout Itemize
6563 Syntax: none memory.set_lag_flag(boolean flag)
6564 \end_layout
6566 \begin_layout Standard
6567 Set the value of core lag flag.
6568  This flag automatically gets cleared if poll is detected, but can be forcibly
6569  set or cleared if game so requires.
6570 \end_layout
6572 \begin_layout Itemize
6573 Should only be used in on_frame_emulated callback.
6574 \end_layout
6576 \begin_layout Itemize
6577 Setting or clearing this affects the emulator lag counter.
6578 \end_layout
6580 \begin_layout Subsection
6581 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
6582  callback
6583 \end_layout
6585 \begin_layout Itemize
6586 Syntax: function memory.registerread([string vma, ] number addr, function
6587  fn);
6588 \end_layout
6590 \begin_layout Itemize
6591 Syntax: function memory.registerwrite([string vma, ] number addr, function
6592  fn);
6593 \end_layout
6595 \begin_layout Itemize
6596 Syntax: function memory.registerexec([string vma, ] number addr, function
6597  fn);
6598 \end_layout
6600 \begin_layout Itemize
6601 Syntax: none memory.unregisterread([string vma, ] number addr, function fn);
6602 \end_layout
6604 \begin_layout Itemize
6605 Syntax: none memory.unregisterwrite([string vma, ] number addr, function
6606  fn);
6607 \end_layout
6609 \begin_layout Itemize
6610 Syntax: none memory.unregisterexec([string vma, ] number addr, function fn);
6611 \end_layout
6613 \begin_layout Standard
6614 Add or remove callback on memory read, write or execute (depending on the
6615  function).
6616  If <vma> is specified, <addr> is relative to it, otherwise <addr> is global.
6617  <fn> is the callback.
6618  The register* functions return <fn> (which can then be passed to unregister*
6619  functions.
6620 \end_layout
6622 \begin_layout Itemize
6623 Not all cores support this, and it may be unsupported for some VMAs.
6624 \end_layout
6626 \begin_layout Itemize
6627 The functions are passed two parameters: Address and value.
6628 \end_layout
6630 \begin_layout Subsection
6631 memory.{,un}registertrace: Set/Clear trace hook
6632 \end_layout
6634 \begin_layout Itemize
6635 Syntax: function memory.registertrace(number processor, function fn);
6636 \end_layout
6638 \begin_layout Itemize
6639 Syntax: none memory.unregistertrace(number processor, function fn);
6640 \end_layout
6642 \begin_layout Standard
6643 Add or remove trace callback.
6644  <processor> is system-dependent processor number (0 is usually main CPU).
6645  The function arguments work like in other (un)register* functions.
6646 \end_layout
6648 \begin_layout Itemize
6649 The functions are passed two parameters: Trace CPU and Trace event string.
6650 \end_layout
6652 \begin_layout Subsection
6653 memory.cheat: Set cheat
6654 \end_layout
6656 \begin_layout Itemize
6657 Syntax: none memory.cheat([string vma, ] number addr, number value);
6658 \end_layout
6660 \begin_layout Itemize
6661 Syntax: none memory.cheat([string vma, ] number addr);
6662 \end_layout
6664 \begin_layout Standard
6665 Set or clear cheat (value <value>) on address <addr>.
6666  If <vma> is specified, <addr> is relative to that.
6667  If <value> is not speicified, clear a cheat.
6668 \end_layout
6670 \begin_layout Itemize
6671 Not all cores support this, and it may be unsupported for some VMAs.
6672 \end_layout
6674 \begin_layout Subsection
6675 memory.setxmask: Set global execute hook mask
6676 \end_layout
6678 \begin_layout Itemize
6679 Syntax: none memory.setxmask(number mask)
6680 \end_layout
6682 \begin_layout Standard
6683 Set the global execute hook mask to <mask>.
6684  The meaning of each bit is system-dependent, but bit 0 should be the main
6685  CPU.
6686 \end_layout
6688 \begin_layout Subsection
6689 memory.mmap: Class MMAP_STRUCT
6690 \end_layout
6692 \begin_layout Standard
6693 See class MMAP_STRUCT
6694 \end_layout
6696 \begin_layout Standard
6697 \begin_inset Newpage pagebreak
6698 \end_inset
6701 \end_layout
6703 \begin_layout Section
6704 Table memory2
6705 \end_layout
6707 \begin_layout Standard
6708 Contains newer memory functions.
6709 \end_layout
6711 \begin_layout Subsection
6712 memory2(): Get all VMA names.
6713 \end_layout
6715 \begin_layout Itemize
6716 Syntax: table memory2()
6717 \end_layout
6719 \begin_layout Standard
6720 Returns array of all valid VMA names.
6721 \end_layout
6723 \begin_layout Subsection
6724 memory2.<vma>:info: Get VMA info
6725 \end_layout
6727 \begin_layout Itemize
6728 Syntax: table memory2.<vma>:info()
6729 \end_layout
6731 \begin_layout Standard
6732 Return table describing given VMA.
6733  Includes fields address, size, last, readonly, special and endian.
6734 \end_layout
6736 \begin_layout Subsection
6737 memory2.<vma>:<op>: Read/Write memory
6738 \end_layout
6740 \begin_layout Itemize
6741 Syntax: none memory2.<vma>:<op>(number offset, number value)
6742 \end_layout
6744 \begin_layout Itemize
6745 Syntax: number memory2.<vma>:<op>(number offset)
6746 \end_layout
6748 \begin_layout Standard
6749 Read/Write value from/to given VMA <vma> at given offset <offset> (must
6750  be in-range).
6751  The value written is <value>.
6752  <Op> is of form: [i][s]<type>, where:
6753 \end_layout
6755 \begin_layout Itemize
6756 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
6757 \end_layout
6759 \begin_layout Itemize
6760 'i' signifies that the value is treated as opposite-to-normal endianess,
6761 \end_layout
6763 \begin_layout Itemize
6764 's' signifies that value is treated as signed (not available for floating-point).
6765 \end_layout
6767 \begin_layout Subsection
6768 memory2.<vma>:read: Scatter-gather value read
6769 \end_layout
6771 \begin_layout Itemize
6772 Syntax: number memory2.<vma>:read(number addr...)
6773 \end_layout
6775 \begin_layout Standard
6776 Read value from given VMA <vma> at byte offsets <addr>..., given in order of
6777  increasing significance.
6778  Value of true and false are special.
6779  True increments address by 1, and false decrements address by 1.
6780 \end_layout
6782 \begin_layout Subsection
6783 memory2.<vma>:sread: Signed scatter-gather value read
6784 \end_layout
6786 \begin_layout Itemize
6787 Syntax: number memory2.<vma>:sread(number addr...)
6788 \end_layout
6790 \begin_layout Standard
6791 Like memory2.<vma>:read, but reads signed values.
6792 \end_layout
6794 \begin_layout Subsection
6795 memory2.<vma>:write: Scatter-gather value write
6796 \end_layout
6798 \begin_layout Itemize
6799 Syntax: number memory2.<vma>:write(number val, number addr...)
6800 \end_layout
6802 \begin_layout Standard
6803 Write value <val> to given VMA <vma> at byte offsets <addr>..., given in order
6804  of increasing significance.
6805  Value of true and false are special.
6806  True increments address by 1, and false decrements address by 1.
6807 \end_layout
6809 \begin_layout Standard
6810 \begin_inset Newpage pagebreak
6811 \end_inset
6814 \end_layout
6816 \begin_layout Section
6817 Table random
6818 \end_layout
6820 \begin_layout Standard
6821 Contains random number generation methods.
6822  These functions do not return reproducable results.
6823 \end_layout
6825 \begin_layout Subsection
6826 random.boolean: Random boolean
6827 \end_layout
6829 \begin_layout Itemize
6830 Syntax: boolean random.boolean()
6831 \end_layout
6833 \begin_layout Standard
6834 Returns true or false at random (50-50 chance).
6835 \end_layout
6837 \begin_layout Subsection
6838 random.integer: Random integer
6839 \end_layout
6841 \begin_layout Itemize
6842 Syntax: number random.integer(number highplusone)
6843 \end_layout
6845 \begin_layout Itemize
6846 Syntax: number random.integer(number low, number high)
6847 \end_layout
6849 \begin_layout Standard
6850 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
6851  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
6852 \end_layout
6854 \begin_layout Standard
6855 The returned numbers are from uniform distribution.
6856 \end_layout
6858 \begin_layout Subsection
6859 random.float: Random float
6860 \end_layout
6862 \begin_layout Itemize
6863 Syntax: number random.float()
6864 \end_layout
6866 \begin_layout Standard
6867 Returns random decimal number [0,1).
6868 \end_layout
6870 \begin_layout Subsection
6871 random.among: Random parameter
6872 \end_layout
6874 \begin_layout Itemize
6875 Syntax: value random.among(value values...)
6876 \end_layout
6878 \begin_layout Standard
6879 Returns random parameter value, picked at uniform.
6880  Multiple equivalent values are returned with higher chance.
6881 \end_layout
6883 \begin_layout Subsection
6884 random.amongtable: Random from table
6885 \end_layout
6887 \begin_layout Itemize
6888 Syntax: value random.amongtable(table tab)
6889 \end_layout
6891 \begin_layout Standard
6892 Returns random value from table <tab>.
6893  As in random.among, no equality testing is done.
6894 \end_layout
6896 \begin_layout Standard
6897 \begin_inset Newpage pagebreak
6898 \end_inset
6901 \end_layout
6903 \begin_layout Section
6904 Table zip
6905 \end_layout
6907 \begin_layout Subsection
6908 zip.enumerate: Enumerate members in zipfile
6909 \end_layout
6911 \begin_layout Itemize
6912 Syntax: Table zip.enumerate(string filename[, boolean invert])
6913 \end_layout
6915 \begin_layout Standard
6916 Returns table of files in zip archive <filename>.
6917  If <invert> is true, instead of returning array of names, returns table
6918  with keys being member names and values being true.
6919 \end_layout
6921 \begin_layout Subsection
6922 zip.writer: Class ZIPWRITER
6923 \end_layout
6925 \begin_layout Standard
6926 See class ZIPWRITER.
6927 \end_layout
6929 \begin_layout Standard
6930 \begin_inset Newpage pagebreak
6931 \end_inset
6934 \end_layout
6936 \begin_layout Section
6937 Table callback
6938 \end_layout
6940 \begin_layout Standard
6941 Various callback-related functions.
6942 \end_layout
6944 \begin_layout Subsection
6945 \begin_inset CommandInset label
6946 LatexCommand label
6947 name "sub:callback.register:-Register-a"
6949 \end_inset
6951 callback.register: Register a callback
6952 \end_layout
6954 \begin_layout Itemize
6955 Syntax: function callback.register(string cbname, function cbfun);
6956 \end_layout
6958 \begin_layout Standard
6959 Instruct function <cbfun> to be added to list of callbacks to call on event
6960  <cbname> (See section 
6961 \begin_inset CommandInset ref
6962 LatexCommand ref
6963 reference "sec:Callbacks"
6965 \end_inset
6968  The callback name does not have the 'on_' prefix (e.g.
6970 \begin_inset Quotes eld
6971 \end_inset
6973 paint
6974 \begin_inset Quotes erd
6975 \end_inset
6978  Returns <cbfun>.
6979 \end_layout
6981 \begin_layout Subsection
6982 \begin_inset CommandInset label
6983 LatexCommand label
6984 name "sub:callback.unregister:-Unregister-"
6986 \end_inset
6988 callback.unregister: Unregister a callback
6989 \end_layout
6991 \begin_layout Itemize
6992 Syntax: function callback.unregister(string cbname, function cbfun);
6993 \end_layout
6995 \begin_layout Standard
6996 Instruct function <cbfun> to be removed from list of callbacks to call on
6997  event <cbname>.
6998 \end_layout
7000 \begin_layout Subsection
7001 callback.<cbname>:register: Register callback
7002 \end_layout
7004 \begin_layout Itemize
7005 Syntax: function callback.<cbname>:register(function cbfun)
7006 \end_layout
7008 \begin_layout Standard
7009 Synonym for callback.register (section 
7010 \begin_inset CommandInset ref
7011 LatexCommand ref
7012 reference "sub:callback.register:-Register-a"
7014 \end_inset
7016 ), albeit with callback name specified differently.
7017 \end_layout
7019 \begin_layout Subsection
7020 callback.<cbname>:unregister: Register callback
7021 \end_layout
7023 \begin_layout Itemize
7024 Syntax: function callback.<cbname>:unregister(function cbfun)
7025 \end_layout
7027 \begin_layout Standard
7028 Synonym for callback.unregister (section 
7029 \begin_inset CommandInset ref
7030 LatexCommand ref
7031 reference "sub:callback.unregister:-Unregister-"
7033 \end_inset
7035 ), albeit with callback name specified differently.
7036 \end_layout
7038 \begin_layout Section
7039 table bsnes
7040 \end_layout
7042 \begin_layout Standard
7043 Various bsnes-specific functions.
7044 \end_layout
7046 \begin_layout Subsection
7047 bsnes.dump_sprite: Dump a sprite
7048 \end_layout
7050 \begin_layout Itemize
7051 Syntax: BITMAP bsnes.dump_sprite([string vma, ] number addr, number width,
7052  number height[, number stride])
7053 \end_layout
7055 \begin_layout Standard
7056 Dumps given sprite (in native format) from memory.
7057  VMA is usually 
7058 \begin_inset Quotes eld
7059 \end_inset
7061 VRAM
7062 \begin_inset Quotes erd
7063 \end_inset
7066  <Width> and <height> are given in 8x8 blocks.
7067  <Stride> overrides row stride (default 512).
7068 \end_layout
7070 \begin_layout Subsection
7071 bsnes.dump_palette: Dump a palette
7072 \end_layout
7074 \begin_layout Itemize
7075 Syntax: PALETTE bsnes.dump_palette([string vma, ] number addr, bool full256,
7076  bool first_trans)
7077 \end_layout
7079 \begin_layout Standard
7080 Dumps a palette from memory.
7081  VMA is usually 
7082 \begin_inset Quotes eld
7083 \end_inset
7085 CGRAM
7086 \begin_inset Quotes erd
7087 \end_inset
7090  If <full256> is true, 256 colors are dumped (otherwise 16).
7091  If <first_trans> is true, first color is forced transparent.
7092 \end_layout
7094 \begin_layout Subsection
7095 bsnes.enablelayer: Set layer visibility
7096 \end_layout
7098 \begin_layout Itemize
7099 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
7100 \end_layout
7102 \begin_layout Standard
7103 Enable or disable specified layer at specified priority.
7104 \end_layout
7106 \begin_layout Section
7107 extensions to table string
7108 \end_layout
7110 \begin_layout Subsection
7111 string.charU: string.char, UTF-8 version.
7112 \end_layout
7114 \begin_layout Itemize
7115 Syntax: string string.charU(number n...)
7116 \end_layout
7118 \begin_layout Standard
7119 Like Lua string.char(), but works in terms of Unicode codepoints.
7120  The returned string is UTF-8.
7121 \end_layout
7123 \begin_layout Subsection
7124 string.byteU: string.byte, UTF-8 version.
7125 \end_layout
7127 \begin_layout Itemize
7128 Syntax: number...
7129  string.byteU(string str[, number i[, number j]])
7130 \end_layout
7132 \begin_layout Standard
7133 Like string.byte(), but works in terms of Unicode codepoints.
7134  The input string <str> is assumed UTF-8.
7135 \end_layout
7137 \begin_layout Section
7138 Table _SYSTEM
7139 \end_layout
7141 \begin_layout Standard
7142 Contains copy of global variables from time of Lua initialization.
7143  Non-writeable.
7144 \end_layout
7146 \begin_layout Standard
7147 \begin_inset Newpage pagebreak
7148 \end_inset
7151 \end_layout
7153 \begin_layout Section
7154 \begin_inset CommandInset label
7155 LatexCommand label
7156 name "sec:Callbacks"
7158 \end_inset
7160 Callbacks
7161 \end_layout
7163 \begin_layout Standard
7164 Various callbacks to Lua that can occur.
7165 \end_layout
7167 \begin_layout Subsection
7168 on_paint: Screen is being painted
7169 \end_layout
7171 \begin_layout Itemize
7172 Callback: on_paint(bool not_synth)
7173 \end_layout
7175 \begin_layout Standard
7176 Called when screen is being painted.
7177  Any gui.* calls requiring graphic context draw on the screen.
7178 \end_layout
7180 \begin_layout Itemize
7181 not_synth is true if this hook is being called in response to received frame,
7182  false otherwise.
7183 \end_layout
7185 \begin_layout Subsection
7186 on_video: Dumped video frame is being painted
7187 \end_layout
7189 \begin_layout Itemize
7190 Callback: on_video()
7191 \end_layout
7193 \begin_layout Standard
7194 Called when video dump frame is being painted.
7195  Any gui.* calls requiring graphic context draw on the video.
7196 \end_layout
7198 \begin_layout Subsection
7199 on_frame_emulated: Frame emulation complete
7200 \end_layout
7202 \begin_layout Itemize
7203 Callback: on_frame_emulated()
7204 \end_layout
7206 \begin_layout Standard
7207 Called when emulating frame has completed and on_paint()/on_video() calls
7208  are about to be issued.
7209 \end_layout
7211 \begin_layout Subsection
7212 on_frame: Frame emulation starting.
7213 \end_layout
7215 \begin_layout Itemize
7216 Callback: on_frame()
7217 \end_layout
7219 \begin_layout Standard
7220 Called on each starting whole frame.
7221 \end_layout
7223 \begin_layout Subsection
7224 on_startup: Emulator startup complete
7225 \end_layout
7227 \begin_layout Itemize
7228 Callback: on_startup()
7229 \end_layout
7231 \begin_layout Standard
7232 Called when the emulator is starting (lsnes.rc and --run files has been run).
7233 \end_layout
7235 \begin_layout Subsection
7236 on_rewind: Movie rewound to beginning
7237 \end_layout
7239 \begin_layout Itemize
7240 Callback: on_rewind()
7241 \end_layout
7243 \begin_layout Standard
7244 Called when rewind movie to beginning has completed.
7245 \end_layout
7247 \begin_layout Subsection
7248 on_pre_load: Load operation is about to start
7249 \end_layout
7251 \begin_layout Itemize
7252 Callback: on_pre_load(string name)
7253 \end_layout
7255 \begin_layout Standard
7256 Called just before savestate/movie load occurs (note: loads are always delayed,
7257  so this occurs even when load was initiated by lua).
7258 \end_layout
7260 \begin_layout Subsection
7261 on_err_Load: Load failed
7262 \end_layout
7264 \begin_layout Itemize
7265 Callback: on_err_load(string name)
7266 \end_layout
7268 \begin_layout Standard
7269 Called if loadstate goes wrong.
7270 \end_layout
7272 \begin_layout Subsection
7273 on_post_load: Load completed
7274 \end_layout
7276 \begin_layout Itemize
7277 Callback: on_post_load(string name, boolean was_savestate)
7278 \end_layout
7280 \begin_layout Standard
7281 Called on successful loadstate.
7282  was_savestate gives if this was a savestate or a movie.
7283 \end_layout
7285 \begin_layout Subsection
7286 on_pre_save: Save operation is about to start
7287 \end_layout
7289 \begin_layout Itemize
7290 Callback: on_pre_save(string name, boolean is_savestate)
7291 \end_layout
7293 \begin_layout Standard
7294 Called just before savestate save occurs (note: movie saves are synchronous
7295  and won't trigger these callbacks if called from Lua).
7296 \end_layout
7298 \begin_layout Subsection
7299 on_err_save: Save failed
7300 \end_layout
7302 \begin_layout Itemize
7303 Callback: on_err_save(string name)
7304 \end_layout
7306 \begin_layout Standard
7307 Called if savestate goes wrong.
7308 \end_layout
7310 \begin_layout Subsection
7311 on_post_save: Save completed
7312 \end_layout
7314 \begin_layout Itemize
7315 Callback: on_post_save(string name, boolean is_savestate)
7316 \end_layout
7318 \begin_layout Standard
7319 Called on successful savaestate.
7320  is_savestate gives if this was a savestate or a movie.
7321 \end_layout
7323 \begin_layout Subsection
7324 on_quit: Emulator is shutting down
7325 \end_layout
7327 \begin_layout Itemize
7328 Callback: on_quit()
7329 \end_layout
7331 \begin_layout Standard
7332 Called when emulator is shutting down.
7333 \end_layout
7335 \begin_layout Subsection
7336 on_input: Polling for input
7337 \end_layout
7339 \begin_layout Standard
7340 Called when emulator is just sending input to bsnes core.
7341  Warning: This is called even in readonly mode, but the results are ignored.
7342 \end_layout
7344 \begin_layout Subsection
7345 on_reset: System has been reset
7346 \end_layout
7348 \begin_layout Itemize
7349 Callback: on_reset()
7350 \end_layout
7352 \begin_layout Standard
7353 Called when system is reset.
7354 \end_layout
7356 \begin_layout Subsection
7357 on_readwrite: Entered readwrite mode
7358 \end_layout
7360 \begin_layout Itemize
7361 Callback: on_readwrite()
7362 \end_layout
7364 \begin_layout Standard
7365 Called when moving into readwrite mode as result of 
7366 \begin_inset Quotes eld
7367 \end_inset
7369 set-rwmode
7370 \begin_inset Quotes erd
7371 \end_inset
7373  command (note: moving to rwmode by Lua won't trigger this, as per recursive
7374  entry protection).
7375 \end_layout
7377 \begin_layout Subsection
7378 on_snoop/on_snoop2: Snoop core controller reads
7379 \end_layout
7381 \begin_layout Itemize
7382 Callback: on_snoop(number port, number controller, number index, number
7383  value)
7384 \end_layout
7386 \begin_layout Itemize
7387 Callback: on_snoop2(number port, number controller, number index, number
7388  value)
7389 \end_layout
7391 \begin_layout Standard
7392 Called each time bsnes asks for input.
7393  The value is the final value to be sent to bsnes core (readonly mode, autohold
7394  and autofire have been taken into account).
7395  Might be useful when translating movies to format suitable for console
7396  verification.
7397  Note: There is no way to modify the value to be sent.
7398 \end_layout
7400 \begin_layout Itemize
7401 On_snoop2 is called instead of on_snoop if defined.
7402  Reserves port 0 for system, having first user port be port 1.
7403 \end_layout
7405 \begin_layout Subsection
7406 on_keyhook: Hooked key/axis has been moved
7407 \end_layout
7409 \begin_layout Itemize
7410 Callback: on_keyhook(string keyname, table state)
7411 \end_layout
7413 \begin_layout Standard
7414 Sent when key that has keyhook events requested changes state.
7415  Keyname is name of the key (group) and state is the state (same kind as
7416  table values in input.raw).
7417 \end_layout
7419 \begin_layout Subsection
7420 on_idle: Idle event
7421 \end_layout
7423 \begin_layout Itemize
7424 Callback: on_idle()
7425 \end_layout
7427 \begin_layout Standard
7428 Called when requested by set_idle_timeout(), the timeout has expired and
7429  emulator is waiting.
7430 \end_layout
7432 \begin_layout Subsection
7433 on_timer: Timer event
7434 \end_layout
7436 \begin_layout Itemize
7437 Callback: on_timer()
7438 \end_layout
7440 \begin_layout Standard
7441 Called when requested by set_idle_timeout() and the timeout has expired
7442  (regardless if emulator is waiting).
7443 \end_layout
7445 \begin_layout Subsection
7446 on_set_rewind: Rewind point has been set
7447 \end_layout
7449 \begin_layout Itemize
7450 Callback: on_set_rewind(UNSAFEREWIND r)
7451 \end_layout
7453 \begin_layout Standard
7454 Called when unsafe rewind object has been constructed.
7455 \end_layout
7457 \begin_layout Subsection
7458 on_pre_rewind: Rewind is about to occur
7459 \end_layout
7461 \begin_layout Itemize
7462 Callback: on_pre_rewind() 
7463 \end_layout
7465 \begin_layout Standard
7466 Called just before unsafe rewind is about to occur.
7467 \end_layout
7469 \begin_layout Subsection
7470 on_post_rewind: Rewind has occured
7471 \end_layout
7473 \begin_layout Itemize
7474 Callback: on_post_rewind() 
7475 \end_layout
7477 \begin_layout Standard
7478 Called just after unsafe rewind has occured.
7479 \end_layout
7481 \begin_layout Subsection
7482 on_button: Button has been pressed
7483 \end_layout
7485 \begin_layout Itemize
7486 Callback: on_button(number port, number controller, number index, string
7487  type)
7488 \end_layout
7490 \begin_layout Standard
7491 Called on controller button press, with following parameters:
7492 \end_layout
7494 \begin_layout Itemize
7495 port: Port number (0 is system)
7496 \end_layout
7498 \begin_layout Itemize
7499 controller: Controller within port
7500 \end_layout
7502 \begin_layout Itemize
7503 index: Index of button.
7504 \end_layout
7506 \begin_layout Itemize
7507 type: Type of event, one of:
7508 \end_layout
7510 \begin_deeper
7511 \begin_layout Itemize
7512 \begin_inset Quotes eld
7513 \end_inset
7515 pressed
7516 \begin_inset Quotes erd
7517 \end_inset
7519 : Button was pressed.
7520 \end_layout
7522 \begin_layout Itemize
7523 \begin_inset Quotes eld
7524 \end_inset
7526 released
7527 \begin_inset Quotes erd
7528 \end_inset
7530 : Button was released.
7531 \end_layout
7533 \begin_layout Itemize
7534 \begin_inset Quotes eld
7535 \end_inset
7537 hold
7538 \begin_inset Quotes erd
7539 \end_inset
7541 : Held.
7542 \end_layout
7544 \begin_layout Itemize
7545 \begin_inset Quotes eld
7546 \end_inset
7548 unhold
7549 \begin_inset Quotes erd
7550 \end_inset
7552 : Released from hold.
7553 \end_layout
7555 \begin_layout Itemize
7556 \begin_inset Quotes eld
7557 \end_inset
7559 type
7560 \begin_inset Quotes erd
7561 \end_inset
7563 : Typing input on button.
7564 \end_layout
7566 \begin_layout Itemize
7567 \begin_inset Quotes eld
7568 \end_inset
7570 untype
7571 \begin_inset Quotes erd
7572 \end_inset
7574 : Typing input undone.
7575 \end_layout
7577 \begin_layout Itemize
7578 \begin_inset Quotes eld
7579 \end_inset
7581 autofire <duty> <cycle>
7582 \begin_inset Quotes erd
7583 \end_inset
7585 : Autofire with specifie duty and cycle.
7586 \end_layout
7588 \begin_layout Itemize
7589 \begin_inset Quotes eld
7590 \end_inset
7592 autofire
7593 \begin_inset Quotes erd
7594 \end_inset
7596 : Stop autofire.
7597 \end_layout
7599 \begin_layout Itemize
7600 \begin_inset Quotes eld
7601 \end_inset
7603 analog
7604 \begin_inset Quotes erd
7605 \end_inset
7607 : Analog action on axis.
7608 \end_layout
7610 \end_deeper
7611 \begin_layout Subsection
7612 on_movie_lost: Movie data is about to be lost
7613 \end_layout
7615 \begin_layout Itemize
7616 Callback: on_movie_lost(STRING kind)
7617 \end_layout
7619 \begin_layout Standard
7620 Called just before something would happen that could lose movie data.
7621  Kind can be:
7622 \end_layout
7624 \begin_layout Itemize
7625 readwrite: Switching to readwrite mode.
7626 \end_layout
7628 \begin_layout Itemize
7629 reload: ROM is being reloaded in readwrite mode.
7630 \end_layout
7632 \begin_layout Itemize
7633 load: New movie is being loaded.
7634 \end_layout
7636 \begin_layout Itemize
7637 unsaferewind: Unsafe rewind is happening.
7638 \end_layout
7640 \begin_layout Subsection
7641 on_latch: Latch line is rising
7642 \end_layout
7644 \begin_layout Itemize
7645 Callback: on_latch(<core-dependent-parameters>)
7646 \end_layout
7648 \begin_layout Standard
7649 Called when latch line for controller is rising.
7650  Some cores may not support this.
7651 \end_layout
7653 \begin_layout Section
7654 System-dependent behaviour
7655 \end_layout
7657 \begin_layout Subsection
7658 bsnes core
7659 \end_layout
7661 \begin_layout Itemize
7662 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
7663  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
7664  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
7665 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
7666 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
7667  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
7668  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
7669  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
7670  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
7671 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
7672 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
7673  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
7674 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
7675 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
7676  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
7677 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
7678  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
7679 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
7680 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
7681 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
7682  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
7683 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
7684  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
7685  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
7686 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
7687 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
7688 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
7689  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
7690 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
7691  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
7692  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
7693  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
7694  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
7695 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
7696  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
7697 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
7698  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
7699  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
7700 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
7701  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
7702 \end_layout
7704 \begin_layout Itemize
7705 on_latch has no parameters
7706 \end_layout
7708 \begin_layout Itemize
7709 CPU 0 is S-CPU, 1 is S-SMP.
7710 \end_layout
7712 \begin_layout Itemize
7713 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
7714 \end_layout
7716 \begin_layout Itemize
7717 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
7718 {RAM,ROM}.
7719 \end_layout
7721 \begin_layout Subsection
7722 gambatte core
7723 \end_layout
7725 \begin_layout Itemize
7726 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
7727  d, e, f, h, l
7728 \end_layout
7730 \begin_layout Itemize
7731 on_latch is not supported
7732 \end_layout
7734 \begin_layout Itemize
7735 CPU 0 is main CPU.
7736 \end_layout
7738 \begin_layout Itemize
7739 Cheats are supported for ROM, SRAM and WRAM.
7740 \end_layout
7742 \begin_layout Itemize
7743 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
7744  and WRAM.
7745 \end_layout
7747 \end_body
7748 \end_document