Remove Mac OS support
[lsnes.git] / lua.lyx
blobabbb91d88dffd5a546331dada6d0215c99e678b1
1 #LyX 2.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 544
3 \begin_document
4 \begin_header
5 \save_transient_properties true
6 \origin unavailable
7 \textclass article
8 \use_default_options true
9 \maintain_unincluded_children false
10 \language english
11 \language_package default
12 \inputencoding auto
13 \fontencoding global
14 \font_roman "default" "default"
15 \font_sans "default" "default"
16 \font_typewriter "default" "default"
17 \font_math "auto" "auto"
18 \font_default_family default
19 \use_non_tex_fonts false
20 \font_sc false
21 \font_osf false
22 \font_sf_scale 100 100
23 \font_tt_scale 100 100
24 \use_microtype false
25 \use_dash_ligatures true
26 \graphics default
27 \default_output_format default
28 \output_sync 0
29 \bibtex_command default
30 \index_command default
31 \paperfontsize default
32 \spacing single
33 \use_hyperref true
34 \pdf_bookmarks true
35 \pdf_bookmarksnumbered false
36 \pdf_bookmarksopen false
37 \pdf_bookmarksopenlevel 1
38 \pdf_breaklinks false
39 \pdf_pdfborder false
40 \pdf_colorlinks false
41 \pdf_backref false
42 \pdf_pdfusetitle true
43 \papersize a4paper
44 \use_geometry true
45 \use_package amsmath 1
46 \use_package amssymb 1
47 \use_package cancel 1
48 \use_package esint 1
49 \use_package mathdots 1
50 \use_package mathtools 1
51 \use_package mhchem 1
52 \use_package stackrel 1
53 \use_package stmaryrd 1
54 \use_package undertilde 1
55 \cite_engine basic
56 \cite_engine_type default
57 \biblio_style plain
58 \use_bibtopic false
59 \use_indices false
60 \paperorientation portrait
61 \suppress_date false
62 \justification true
63 \use_refstyle 1
64 \use_minted 0
65 \index Hakusana
66 \shortcut idx
67 \color #008000
68 \end_index
69 \leftmargin 2cm
70 \topmargin 2cm
71 \rightmargin 1cm
72 \bottommargin 2cm
73 \headheight 1cm
74 \headsep 1cm
75 \footskip 1cm
76 \secnumdepth 3
77 \tocdepth 3
78 \paragraph_separation indent
79 \paragraph_indentation default
80 \is_math_indent 0
81 \math_numbering_side default
82 \quotes_style english
83 \dynamic_quotes 0
84 \papercolumns 1
85 \papersides 1
86 \paperpagestyle default
87 \tracking_changes false
88 \output_changes false
89 \html_math_output 0
90 \html_css_as_file 0
91 \html_be_strict false
92 \end_header
94 \begin_body
96 \begin_layout Title
97 lsnes Lua functions reference
98 \end_layout
100 \begin_layout Section
101 Table of contents
102 \end_layout
104 \begin_layout Standard
105 \begin_inset CommandInset toc
106 LatexCommand tableofcontents
108 \end_inset
111 \end_layout
113 \begin_layout Standard
114 \begin_inset Newpage pagebreak
115 \end_inset
118 \end_layout
120 \begin_layout Section
121 Conventions
122 \end_layout
124 \begin_layout Subsection
125 Coordinates:
126 \end_layout
128 \begin_layout Itemize
129 Coordinates increase to right and down.
130 \end_layout
132 \begin_layout Itemize
133 The origin is at top left of game area or buffer.
134 \end_layout
136 \begin_layout Subsection
137 Drawing and contexts
138 \end_layout
140 \begin_layout Itemize
141 Methods that draw something (unless stated otherwise) require a valid rendering
142  context.
143  This context can come in three ways:
144 \begin_inset Separator latexpar
145 \end_inset
148 \end_layout
150 \begin_deeper
151 \begin_layout Enumerate
152 The default rendering context of paint callback (the screen).
153 \end_layout
155 \begin_layout Enumerate
156 The default rendering context of video callback (the video).
157 \end_layout
159 \begin_layout Enumerate
160 Explicitly set rendering context (RENDERCTX:set).
161 \end_layout
163 \end_deeper
164 \begin_layout Itemize
165 The rendering context is always reset when callback ends.
166 \end_layout
168 \begin_layout Subsection
169 Colors
170 \end_layout
172 \begin_layout Standard
173 (Direct) colors can be specified either as numbers or strings.
174 \end_layout
176 \begin_layout Itemize
177 -1 is fully transparent.
178 \end_layout
180 \begin_layout Itemize
181 Non-negative numbers less than 
182 \begin_inset Formula $2^{32}$
183 \end_inset
185  are partially opaque colors (
186 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
187 \end_inset
190 \begin_inset Separator latexpar
191 \end_inset
194 \end_layout
196 \begin_deeper
197 \begin_layout Itemize
198 \begin_inset Formula $a$
199 \end_inset
201  is transparency 
202 \begin_inset Formula $0-255$
203 \end_inset
206 \begin_inset Formula $0$
207 \end_inset
209  is fully opaque, 
210 \begin_inset Formula $256$
211 \end_inset
213  would be fully transparent.
214 \begin_inset Separator latexpar
215 \end_inset
218 \end_layout
220 \begin_deeper
221 \begin_layout Itemize
222 Thus, numbers in range 
223 \begin_inset Formula $0-16777215$
224 \end_inset
226  stand for fully opaque colors.
227 \end_layout
229 \end_deeper
230 \begin_layout Itemize
231 \begin_inset Formula $r$
232 \end_inset
235 \begin_inset Formula $g$
236 \end_inset
238  and 
239 \begin_inset Formula $b$
240 \end_inset
242  are intensities of base colors on scale 
243 \begin_inset Formula $0-255$
244 \end_inset
247 \end_layout
249 \end_deeper
250 \begin_layout Itemize
251 Color can also be specified by name as string: The following color names
252  are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
253  antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
254  azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
255  bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
256  brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
257  burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
258  chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
259  chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
260 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
261  cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
262  darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
263  darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
264  darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
265 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
266 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
267  darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
268  darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
269  deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
270  dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
271  firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
272  fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
273  goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
274  gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
275  gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
276  gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
277  gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
278  gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
279  gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
280  gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
281  gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
282  gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
283  green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
284  grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
285  grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
286  grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
287  grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
288  grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
289  grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
290  grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
291  grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
292  grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
293  honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
294  indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
295  ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
296  lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
297 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
298  lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
299  lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
300 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
301  lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
302  lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
303  lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
304  lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
305  lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
306  lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
307  maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
308  mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
309  mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
310 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
311 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
312 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
313  navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
314  olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
315  orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
316  palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
317 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
318  palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
319  peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
320  pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
321  purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
322  rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
323  saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
324  seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
325  seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
326  skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
327 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
328  snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
329 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
330  tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
331  tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
332  turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
333  wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
334  yellow3 yellow4 yellowgreen 
335 \end_layout
337 \begin_layout Itemize
338 The HSL base color names: hsl-<hue><saturation><lightness>.
339 \begin_inset Separator latexpar
340 \end_inset
343 \end_layout
345 \begin_deeper
346 \begin_layout Itemize
347 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
348  y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
349  (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
350 \end_layout
352 \begin_layout Itemize
353 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
354 \end_layout
356 \begin_layout Itemize
357 Lightness is 0-8, where 0 is black and 8 is white.
358 \end_layout
360 \end_deeper
361 \begin_layout Itemize
362 The color names can have a modifier after space (multiple modifiers are
363  allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
364  opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
365  hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
366 \begin_inset Separator latexpar
367 \end_inset
370 \end_layout
372 \begin_deeper
373 \begin_layout Itemize
374 opaqueness is measured as percentage.
375 \end_layout
377 \begin_layout Itemize
378 Hue adjustments are on 24-step scale.
379 \end_layout
381 \begin_layout Itemize
382 Saturation and lightness adjustments are on 16-step scale.
383 \end_layout
385 \end_deeper
386 \begin_layout Section
387 Special tokens
388 \end_layout
390 \begin_layout Standard
391 These tokens are special, and are expanded while the script is being loaded
392 \end_layout
394 \begin_layout Subsection
395 @@LUA_SCRIPT_FILENAME@@
396 \end_layout
398 \begin_layout Standard
399 Expanded to string token containing path and filename of this Lua script.
400  Handy for referencing other lua scripts or resources that are relative
401  to this Lua script.
402 \end_layout
404 \begin_layout Standard
405 In practicular, this is suitable to be passed as base argument of various
406  functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
407 ad_png and gui.bitmap_load_pal.
408 \end_layout
410 \begin_layout Section
411 Classes
412 \end_layout
414 \begin_layout Subsection
415 MMAP_STRUCT: Quasi-table mapping emulated memory
416 \end_layout
418 \begin_layout Standard
419 Objects act like tables, but the values reflect emulated memory.
420 \end_layout
422 \begin_layout Subsubsection
423 static function new: Create a new instance
424 \end_layout
426 \begin_layout Itemize
427 Syntax: mmap memory.mmap.new()
428 \end_layout
430 \begin_layout Itemize
431 Syntax: mmap classes.MMAP_STRUCT.new()
432 \end_layout
434 \begin_layout Standard
435 Return value:
436 \end_layout
438 \begin_layout Itemize
439 mmap: MMAP_STRUCT: The created mmap structure.
440 \end_layout
442 \begin_layout Standard
443 Create a new object (with no mappings) and return it.
444 \end_layout
446 \begin_layout Subsubsection
447 operator(): Bind key in mmap structure
448 \end_layout
450 \begin_layout Itemize
451 Syntax: obj(key, {marea, address|addrobj}, type)
452 \end_layout
454 \begin_layout Standard
455 Parameters:
456 \end_layout
458 \begin_layout Itemize
459 obj: MMAP_STRUCT: The structure to manipulate.
460 \end_layout
462 \begin_layout Itemize
463 key: String: The name of the key in array to map.
464 \end_layout
466 \begin_layout Itemize
467 marea: String: The memory area the mapped address is in (default: global
468  memory space).
469 \end_layout
471 \begin_layout Itemize
472 address: Number: The offset of memory addreess, relative to specified memory
473  area or global memory space.
474 \end_layout
476 \begin_layout Itemize
477 addrobj: ADDRESS: The memory address.
478 \end_layout
480 \begin_layout Itemize
481 type: String: The type of data to map.
482 \begin_inset Separator latexpar
483 \end_inset
486 \end_layout
488 \begin_deeper
489 \begin_layout Itemize
490 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
491  float or double.
492 \end_layout
494 \end_deeper
495 \begin_layout Standard
496 Bind key <key> in mmap structure <obj> to address <address> (relative to
497  <marea>).
498  The memory address is treated as type <type>.
499 \end_layout
501 \begin_layout Itemize
502 Example: foomap(
503 \begin_inset Quotes eld
504 \end_inset
507 \begin_inset Quotes erd
508 \end_inset
511 \begin_inset Quotes eld
512 \end_inset
514 WRAM
515 \begin_inset Quotes erd
516 \end_inset
518 , 0x2A, 
519 \begin_inset Quotes eld
520 \end_inset
522 sword
523 \begin_inset Quotes erd
524 \end_inset
527 \end_layout
529 \begin_layout Standard
530 This binds signed word at address WRAM+0x2A into key 
531 \begin_inset Quotes eld
532 \end_inset
535 \begin_inset Quotes erd
536 \end_inset
539 \end_layout
541 \begin_layout Standard
542 \begin_inset Newpage pagebreak
543 \end_inset
546 \end_layout
548 \begin_layout Subsection
549 ZIPWRITER: Write .zip files
550 \end_layout
552 \begin_layout Standard
553 This class does writing of .zip files.
554 \end_layout
556 \begin_layout Subsubsection
557 Static function new: Create a new zipfile
558 \end_layout
560 \begin_layout Itemize
561 Syntax: zip zip.writer.new(filename, [compression])
562 \end_layout
564 \begin_layout Itemize
565 Deprecated: zip zip.create(filename, [compression])
566 \end_layout
568 \begin_layout Standard
569 Parameters:
570 \end_layout
572 \begin_layout Itemize
573 filename: string: The name of the file to write.
574 \end_layout
576 \begin_layout Itemize
577 compression: number: Compression level (0-9).
578  Default is 9.
579 \end_layout
581 \begin_layout Standard
582 Return value:
583 \end_layout
585 \begin_layout Itemize
586 zip: ZIPWRITER: The newly created ZIP writer.
587 \end_layout
589 \begin_layout Standard
590 Create a new ZIPWRITER object and return it.
591 \end_layout
593 \begin_layout Subsubsection
594 Method commit: Finish creating ZIP file.
595 \end_layout
597 \begin_layout Itemize
598 Syntax: zipfile:commit()
599 \end_layout
601 \begin_layout Standard
602 Parameters:
603 \end_layout
605 \begin_layout Itemize
606 zipfile: ZIPFILE: The ZIP file object.
607 \end_layout
609 \begin_layout Standard
610 Finish writing the ZIP file and actually create it on disk.
611 \end_layout
613 \begin_layout Itemize
614 If a member is currently open, it is implicitly closed.
615 \end_layout
617 \begin_layout Itemize
618 Invoking this on already committed or rolled back zipfile causes an error.
619 \end_layout
621 \begin_layout Subsubsection
622 Method rollback: Cancel writing the ZIP file.
623 \end_layout
625 \begin_layout Itemize
626 Syntax: zipfile:rollback()
627 \end_layout
629 \begin_layout Standard
630 Parameters:
631 \end_layout
633 \begin_layout Itemize
634 zipfile: ZIPFILE: The ZIP file object.
635 \end_layout
637 \begin_layout Standard
638 Cancel writing the whole ZIP file.
639  The file on disk will not be modified.
640 \end_layout
642 \begin_layout Itemize
643 If a member is currently open, it is implicitly closed.
644 \end_layout
646 \begin_layout Itemize
647 Invoking this on already committed or rolled back zipfile causes an error.
648 \end_layout
650 \begin_layout Subsubsection
651 Method create_file: Start writing a new member
652 \end_layout
654 \begin_layout Itemize
655 Syntax: zipfile:create_file(filename)
656 \end_layout
658 \begin_layout Standard
659 Parameters:
660 \end_layout
662 \begin_layout Itemize
663 zipfile: ZIPFILE: The ZIP file object.
664 \end_layout
666 \begin_layout Itemize
667 string filename: Name of the new member to create
668 \end_layout
670 \begin_layout Standard
671 Start writing a new member <filename> in ZIP file.
672 \end_layout
674 \begin_layout Itemize
675 If a member is currently open, it is implicitly closed.
676 \end_layout
678 \begin_layout Itemize
679 Invoking this on already committed or rolled back zipfile causes an error.
680 \end_layout
682 \begin_layout Subsubsection
683 Method close_file: Close member
684 \end_layout
686 \begin_layout Itemize
687 Syntax: zipfile:close_file()
688 \end_layout
690 \begin_layout Standard
691 Parameters:
692 \end_layout
694 \begin_layout Itemize
695 zipfile: ZIPFILE: The ZIP file object.
696 \end_layout
698 \begin_layout Standard
699 Close the currently open member in zipfile.
700 \end_layout
702 \begin_layout Itemize
703 Invoking this on already committed or rolled back zipfile causes an error.
704 \end_layout
706 \begin_layout Itemize
707 Invoking this without an open member causes an error.
708 \end_layout
710 \begin_layout Subsubsection
711 Method write: Write data
712 \end_layout
714 \begin_layout Itemize
715 Syntax: zipfile:write(data)
716 \end_layout
718 \begin_layout Standard
719 Parameters:
720 \end_layout
722 \begin_layout Itemize
723 zipfile: ZIPFILE: The ZIP file object.
724 \end_layout
726 \begin_layout Itemize
727 data: string: The data to write.
728 \end_layout
730 \begin_layout Standard
731 Write <data> in binary mode (as-is) to currently open member.
732 \end_layout
734 \begin_layout Itemize
735 Invoking this without a member being open causes an error.
736 \end_layout
738 \begin_layout Standard
739 \begin_inset Newpage pagebreak
740 \end_inset
743 \end_layout
745 \begin_layout Subsection
746 TILEMAP: Tiled collection of bitmaps.
747 \end_layout
749 \begin_layout Standard
750 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
751 \end_layout
753 \begin_layout Subsubsection
754 Static function new: Create a tilemap
755 \end_layout
757 \begin_layout Itemize
758 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
759 \end_layout
761 \begin_layout Itemize
762 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
763 \end_layout
765 \begin_layout Itemize
766 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
767 \end_layout
769 \begin_layout Standard
770 Parameters:
771 \end_layout
773 \begin_layout Itemize
774 w: number: Width of the tilemap in tiles
775 \end_layout
777 \begin_layout Itemize
778 h: number: Height of the tilemap in tiles
779 \end_layout
781 \begin_layout Itemize
782 bw: number: Width of each tile in pixels.
783 \end_layout
785 \begin_layout Itemize
786 bh: number: Height of each tile in pixels.
787 \end_layout
789 \begin_layout Standard
790 Return value:
791 \end_layout
793 \begin_layout Itemize
794 tilemap: TILEMAP: the newly created tilemap
795 \end_layout
797 \begin_layout Standard
798 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
799  it.
800 \end_layout
802 \begin_layout Subsubsection
803 TILEMAP:getsize: Query tilemap size
804 \end_layout
806 \begin_layout Itemize
807 Syntax: width, height tmap:getsize()
808 \end_layout
810 \begin_layout Standard
811 Parameters:
812 \end_layout
814 \begin_layout Itemize
815 tmap: TILEMAP: The tilemap to query.
816 \end_layout
818 \begin_layout Standard
819 Return value:
820 \end_layout
822 \begin_layout Itemize
823 width: number : The width of the tilemap in tiles.
824 \end_layout
826 \begin_layout Itemize
827 height: number: The height of the tilemap in tiles.
828 \end_layout
830 \begin_layout Standard
831 Get size of tilemap in tiles.
832 \end_layout
834 \begin_layout Subsubsection
835 TILEMAP:getcsize: Query tilemap cell size
836 \end_layout
838 \begin_layout Itemize
839 Syntax: width, height tmap:getcsize()
840 \end_layout
842 \begin_layout Standard
843 Parameters:
844 \end_layout
846 \begin_layout Itemize
847 tmap: TILEMAP: The tilemap to query.
848 \end_layout
850 \begin_layout Standard
851 Return value:
852 \end_layout
854 \begin_layout Itemize
855 width: number: The width of tilemap tile in pixels.
856 \end_layout
858 \begin_layout Itemize
859 height: number: The height of tilemap tile in pixels.
860 \end_layout
862 \begin_layout Standard
863 Get size of each tilemap tile in pixels.
864 \end_layout
866 \begin_layout Subsubsection
867 TILEMAP:get: Query tilemap tile
868 \end_layout
870 \begin_layout Itemize
871 Syntax: bitmap, palette tmap:get(x, y)
872 \end_layout
874 \begin_layout Standard
875 Parameters:
876 \end_layout
878 \begin_layout Itemize
879 tmap: TILEMAP: The tilemap to query.
880 \end_layout
882 \begin_layout Itemize
883 x: number: The x-coordinate of tile to query.
884 \end_layout
886 \begin_layout Itemize
887 y: number: The y-coordinate of tile to query.
888 \end_layout
890 \begin_layout Standard
891 Return value:
892 \end_layout
894 \begin_layout Itemize
895 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
896 \end_layout
898 \begin_layout Itemize
899 palette: The palette (PALETTE) associated with indexed-color bitmap, if
900  any.
901  Otherwise nil.
902 \end_layout
904 \begin_layout Standard
905 Return the contents of tile at <x>,<y>.
906 \end_layout
908 \begin_layout Subsubsection
909 TILEMAP:set: Set tilemap cell
910 \end_layout
912 \begin_layout Itemize
913 Syntax: tmap:set(x, y)
914 \end_layout
916 \begin_layout Itemize
917 Syntax: tmap:set(x, y, bitmap)
918 \end_layout
920 \begin_layout Itemize
921 Syntax: tmap:set(x, y, bitmap, palette)
922 \end_layout
924 \begin_layout Standard
925 Parameters:
926 \end_layout
928 \begin_layout Itemize
929 tmap: TILEMAP: The tilemap to manipulate.
930 \end_layout
932 \begin_layout Itemize
933 number x: The x-coordinate of tile to set.
934 \end_layout
936 \begin_layout Itemize
937 number y: The y-coordinate of tile to set.
938 \end_layout
940 \begin_layout Itemize
941 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
942 \end_layout
944 \begin_layout Itemize
945 palette: PALETTE: The associated palette for bitmap.
946 \end_layout
948 \begin_layout Standard
949 Set the contents of tile <x>,<y>.
950  If no <bitmap> is given, clears the tile.
951  Otherwise sets the tile to contain bitmap <bitmap> with associated palette
952  <palette>.
953 \end_layout
955 \begin_layout Itemize
956 Specifying index bitmap <bitmap> without palette <palette> causes an error.
957 \end_layout
959 \begin_layout Subsubsection
960 TILEMAP:scroll: Scroll tilemap
961 \end_layout
963 \begin_layout Itemize
964 Syntax: tmap:scroll(ox, oy);
965 \end_layout
967 \begin_layout Itemize
968 Syntax: tmap:scroll(ox, oy, x, y, w, h);
969 \end_layout
971 \begin_layout Itemize
972 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
973 \end_layout
975 \begin_layout Standard
976 Parameters:
977 \end_layout
979 \begin_layout Itemize
980 tmap: TILEMAP: The tilemap to manipulate.
981 \end_layout
983 \begin_layout Itemize
984 ox: number: The number of tiles to scroll horizontally (positive is to right).
985 \end_layout
987 \begin_layout Itemize
988 oy: number: The number of tiles to scroll vertically (positive is to down).
989 \end_layout
991 \begin_layout Itemize
992 x: number: The left edge of scroll window.
993 \end_layout
995 \begin_layout Itemize
996 y: number: The top edge of scroll window.
997 \end_layout
999 \begin_layout Itemize
1000 w: number: The width of scroll window.
1001 \end_layout
1003 \begin_layout Itemize
1004 h: number: The height of scroll window.
1005 \end_layout
1007 \begin_layout Itemize
1008 circ_x: boolean: If true, treat the window as circular in horizontal direction.
1009 \end_layout
1011 \begin_layout Itemize
1012 circ_y: boolean: If true, treat the window as circular in vertical direction.
1013 \end_layout
1015 \begin_layout Standard
1016 Scroll the specified tilemap <tmap> by <ox>,<oy>.
1017  If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
1018  <circ_x> and <circ_y> control if scroll is circular or not.
1019 \end_layout
1021 \begin_layout Itemize
1022 Specifying out-of-range window causes an error.
1023 \end_layout
1025 \begin_layout Subsubsection
1026 TILEMAP:draw: Draw tilemap
1027 \end_layout
1029 \begin_layout Itemize
1030 Name: tmap:draw(x, y)
1031 \end_layout
1033 \begin_layout Itemize
1034 Name: tmap:draw(x, y, x0, y0, w, h)
1035 \end_layout
1037 \begin_layout Standard
1038 Parameters:
1039 \end_layout
1041 \begin_layout Itemize
1042 tmap: TILEMAP: The tilemap to draw.
1043 \end_layout
1045 \begin_layout Itemize
1046 x: The x coordinate on screen to draw to.
1047 \end_layout
1049 \begin_layout Itemize
1050 y: The y coordinate on screen to draw to.
1051 \end_layout
1053 \begin_layout Itemize
1054 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1055 \end_layout
1057 \begin_layout Itemize
1058 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1059 \end_layout
1061 \begin_layout Itemize
1062 w: number: The width to draw (in pixels).
1063 \end_layout
1065 \begin_layout Itemize
1066 h: number: The height to draw (in pixels).
1067 \end_layout
1069 \begin_layout Standard
1070 Draw tilemap <tmap> to screen at <x>,<y>.
1071  If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1072 \end_layout
1074 \begin_layout Itemize
1075 This method requires a rendering context to work.
1076 \end_layout
1078 \begin_layout Subsubsection
1079 TILEMAP:draw_outside: Draw tilemap outside game area
1080 \end_layout
1082 \begin_layout Itemize
1083 Name: tmap:draw_outside(x, y)
1084 \end_layout
1086 \begin_layout Itemize
1087 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1088 \end_layout
1090 \begin_layout Standard
1091 Like TILEMAP:draw, but draws only outside game area.
1092 \end_layout
1094 \begin_layout Standard
1095 \begin_inset Newpage pagebreak
1096 \end_inset
1099 \end_layout
1101 \begin_layout Subsection
1102 RENDERCTX: Off-screen rendering context
1103 \end_layout
1105 \begin_layout Standard
1106 Object acting as off-screen rendering context.
1107 \end_layout
1109 \begin_layout Subsubsection
1110 Static function new: Create a render queue
1111 \end_layout
1113 \begin_layout Itemize
1114 Syntax: renderctx gui.renderctx.new(width, height);
1115 \end_layout
1117 \begin_layout Itemize
1118 Syntax: renderctx classes.RENDERCTX.new(width, height);
1119 \end_layout
1121 \begin_layout Itemize
1122 Deprecated: renderctx gui.renderq_new(width, height);
1123 \end_layout
1125 \begin_layout Standard
1126 Parameters:
1127 \end_layout
1129 \begin_layout Itemize
1130 width: number: The notional width of the game area.
1131 \end_layout
1133 \begin_layout Itemize
1134 height: number: The notional height of the game area.
1135 \end_layout
1137 \begin_layout Standard
1138 Returns:
1139 \end_layout
1141 \begin_layout Itemize
1142 rendectx: RENDERCTX: The newly created render context.
1143 \end_layout
1145 \begin_layout Standard
1146 Create a render context with reported size <width>*<height> and return it.
1147 \end_layout
1149 \begin_layout Subsubsection
1150 Static function setnull: Reset to default queue
1151 \end_layout
1153 \begin_layout Itemize
1154 Syntax: gui.renderctx.setnull()
1155 \end_layout
1157 \begin_layout Itemize
1158 Syntax: classes.RENDERCTX:setnull()
1159 \end_layout
1161 \begin_layout Itemize
1162 Deprecated: gui.renderq_set()
1163 \end_layout
1165 \begin_layout Standard
1166 Reset the used render context back to default for the executing callback:
1167 \end_layout
1169 \begin_layout Itemize
1170 The default for paint callback is the screen
1171 \end_layout
1173 \begin_layout Itemize
1174 The default for video callback is the video frame
1175 \end_layout
1177 \begin_layout Itemize
1178 The default otherwise is nothing.
1179 \end_layout
1181 \begin_layout Subsubsection
1182 Method clear: Clear a render queue
1183 \end_layout
1185 \begin_layout Itemize
1186 Syntax: renderctx:clear()
1187 \end_layout
1189 \begin_layout Itemize
1190 Deprecated: gui.renderq_clear(renderctx)
1191 \end_layout
1193 \begin_layout Standard
1194 Parameters:
1195 \end_layout
1197 \begin_layout Itemize
1198 renderctx: RENDERCTX: The render queue to clear.
1199 \end_layout
1201 \begin_layout Standard
1202 Clear all drawing from the context.
1203 \end_layout
1205 \begin_layout Subsubsection
1206 Method set: Change active render context
1207 \end_layout
1209 \begin_layout Itemize
1210 Syntax: renderctx:set()
1211 \end_layout
1213 \begin_layout Itemize
1214 Deprecated: gui.renderq_set(renderctx)
1215 \end_layout
1217 \begin_layout Standard
1218 Parameters:
1219 \end_layout
1221 \begin_layout Itemize
1222 renderctx: RENDERCTX: The render queue to use.
1223 \end_layout
1225 \begin_layout Standard
1226 Switch the current rendering context <renderctx>.
1227 \end_layout
1229 \begin_layout Subsubsection
1230 Method run: Draw all objects in context to another
1231 \end_layout
1233 \begin_layout Itemize
1234 Syntax: renderctx:run()
1235 \end_layout
1237 \begin_layout Itemize
1238 Deprecated: gui.renderq_run(renderctx)
1239 \end_layout
1241 \begin_layout Standard
1242 Parameters:
1243 \end_layout
1245 \begin_layout Itemize
1246 renderctx: RENDERCTX: The render context to overlay.
1247 \end_layout
1249 \begin_layout Standard
1250 Overlay the specified render context <context> upon the active rendering
1251  context.
1252 \end_layout
1254 \begin_layout Itemize
1255 Trying to overlay rendering context upon itself is a bad idea.
1256 \end_layout
1258 \begin_layout Subsubsection
1259 Method render: Render a contex to bitmap
1260 \end_layout
1262 \begin_layout Itemize
1263 Syntax: bitmap renderctx:render()
1264 \end_layout
1266 \begin_layout Standard
1267 Parameters:
1268 \end_layout
1270 \begin_layout Itemize
1271 renderctx: RENDERCTX: The context to render.
1272 \end_layout
1274 \begin_layout Standard
1275 Returns:
1276 \end_layout
1278 \begin_layout Itemize
1279 bitmap: DBITMAP: The rendered bitmap.
1280 \end_layout
1282 \begin_layout Standard
1283 Render the specified context <renderctx> to a new bitmap.
1284 \end_layout
1286 \begin_layout Itemize
1287 The size of bitmap will be nominal game area size, plus any set gaps.
1288 \end_layout
1290 \begin_layout Itemize
1291 This method does not require active rendering context.
1292 \end_layout
1294 \begin_layout Subsubsection
1295 Method synchronous_repaint: Paint screen now
1296 \end_layout
1298 \begin_layout Itemize
1299 Syntax: renderctx:synchronous_repaint()
1300 \end_layout
1302 \begin_layout Itemize
1303 Deprecated: gui.synchronous_repaint(renderctx)
1304 \end_layout
1306 \begin_layout Standard
1307 Parameters:
1308 \end_layout
1310 \begin_layout Itemize
1311 renderctx: RENDERCTX: The context to paint.
1312 \end_layout
1314 \begin_layout Standard
1315 Immediately redraw the screen with game overlayed by drawings from context
1316  <renderctx>.
1317 \end_layout
1319 \begin_layout Itemize
1320 This does not require active rendering context.
1321 \end_layout
1323 \begin_layout Itemize
1324 Will not cause paint callback to be invoked.
1325 \end_layout
1327 \begin_layout Standard
1328 \begin_inset Newpage pagebreak
1329 \end_inset
1332 \end_layout
1334 \begin_layout Subsection
1335 PALETTE: Color palette for indexed image
1336 \end_layout
1338 \begin_layout Subsubsection
1339 Static function new: Create a new palette
1340 \end_layout
1342 \begin_layout Itemize
1343 Syntax: palette gui.palette.new()
1344 \end_layout
1346 \begin_layout Itemize
1347 Syntax: palette classes.PALETTE.new()
1348 \end_layout
1350 \begin_layout Itemize
1351 Deprecated: palette gui.palette_new()
1352 \end_layout
1354 \begin_layout Standard
1355 Returns:
1356 \end_layout
1358 \begin_layout Itemize
1359 palette: PALETTE: The created palette.
1360 \end_layout
1362 \begin_layout Standard
1363 Create a new palette (with all colors transparent) and return it.
1364 \end_layout
1366 \begin_layout Subsubsection
1367 Static function load: Load a palette
1368 \end_layout
1370 \begin_layout Itemize
1371 Syntax: palette gui.palette.load(file, [base])
1372 \end_layout
1374 \begin_layout Itemize
1375 Syntax: palette classes.PALETTE.load(file, [base])
1376 \end_layout
1378 \begin_layout Itemize
1379 Deprecated: palette gui.palette_load(file, [base])
1380 \end_layout
1382 \begin_layout Standard
1383 Parameters:
1384 \end_layout
1386 \begin_layout Itemize
1387 string file: The file to load.
1388 \end_layout
1390 \begin_layout Itemize
1391 string base (optional): The base file to resolve file relative to.
1392 \end_layout
1394 \begin_layout Standard
1395 Returns:
1396 \end_layout
1398 \begin_layout Itemize
1399 palette: PALETTE: The loaded palette.
1400 \end_layout
1402 \begin_layout Standard
1403 Load a palette from file <file> (resolved relative to <base>).
1404 \end_layout
1406 \begin_layout Itemize
1407 The file format is a series of lines, each with following format:
1408 \begin_inset Separator latexpar
1409 \end_inset
1412 \end_layout
1414 \begin_deeper
1415 \begin_layout Itemize
1416 Blank or just whitespace: Ignored
1417 \end_layout
1419 \begin_layout Itemize
1420 First non-whitespace is '#': Ignored
1421 \end_layout
1423 \begin_layout Itemize
1424 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1425 \end_layout
1427 \begin_layout Itemize
1428 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1429  (0-256, 0 being fully transparent and 256 fully opaque).
1430 \end_layout
1432 \begin_layout Itemize
1433 transparent: Fully transparent color
1434 \end_layout
1436 \end_deeper
1437 \begin_layout Subsubsection
1438 Static function load_str: Load a palette from string
1439 \end_layout
1441 \begin_layout Itemize
1442 Syntax: palette gui.palette.load(data)
1443 \end_layout
1445 \begin_layout Itemize
1446 Syntax: palette classes.PALETTE.load(data)
1447 \end_layout
1449 \begin_layout Itemize
1450 Deprecated: palette gui.palette_load(data)
1451 \end_layout
1453 \begin_layout Standard
1454 Parameters:
1455 \end_layout
1457 \begin_layout Itemize
1458 string data: The palette data.
1459 \end_layout
1461 \begin_layout Standard
1462 Returns:
1463 \end_layout
1465 \begin_layout Itemize
1466 palette: PALETTE: The loaded palette.
1467 \end_layout
1469 \begin_layout Standard
1470 Like PALETTE:load, but instead of reading palette from file, reads it from
1471  a string.
1472 \end_layout
1474 \begin_layout Subsubsection
1475 Method set: Set palette entry
1476 \end_layout
1478 \begin_layout Itemize
1479 Syntax: palette:set(index, color)
1480 \end_layout
1482 \begin_layout Itemize
1483 Deprecated: gui.palette_set(palette, ...)
1484 \end_layout
1486 \begin_layout Standard
1487 Parameters:
1488 \end_layout
1490 \begin_layout Itemize
1491 palette: PALETTE: The palette to manipulate
1492 \end_layout
1494 \begin_layout Itemize
1495 index: number: The index of color to set (0-65535).
1496 \end_layout
1498 \begin_layout Itemize
1499 color: number/string: The color value to set.
1500 \end_layout
1502 \begin_layout Standard
1503 Set palette <palette> index <index> to color <color>.
1504 \end_layout
1506 \begin_layout Subsubsection
1507 Method get: Get palette entry
1508 \end_layout
1510 \begin_layout Itemize
1511 Syntax: number palette:get(index)
1512 \end_layout
1514 \begin_layout Standard
1515 Parameters:
1516 \end_layout
1518 \begin_layout Itemize
1519 palette: PALETTE: The palette to query
1520 \end_layout
1522 \begin_layout Itemize
1523 index: number: The index of color to get (0-65535).
1524 \end_layout
1526 \begin_layout Standard
1527 Returns:
1528 \end_layout
1530 \begin_layout Itemize
1531 The palette entry as integer.
1532 \end_layout
1534 \begin_layout Standard
1535 Get palette entry <index> of palette <palette> and return it.
1536 \end_layout
1538 \begin_layout Subsubsection
1539 Method hash: Hash a palette
1540 \end_layout
1542 \begin_layout Itemize
1543 Syntax: hash palette:hash()
1544 \end_layout
1546 \begin_layout Itemize
1547 Deprecated: hash gui.palette_hash(palette)
1548 \end_layout
1550 \begin_layout Standard
1551 Parameters:
1552 \end_layout
1554 \begin_layout Itemize
1555 palette: The palette to hash.
1556 \end_layout
1558 \begin_layout Standard
1559 Return value:
1560 \end_layout
1562 \begin_layout Itemize
1563 hash: string: 64-hex digit hash.
1564 \end_layout
1566 \begin_layout Standard
1567 Obtain crypto-grade hash of palette data of <palette>.
1568 \end_layout
1570 \begin_layout Itemize
1571 All colors after the last non-transparent one are ignored.
1572 \end_layout
1574 \begin_layout Subsubsection
1575 Method adjust_transparency: Adjust transparency
1576 \end_layout
1578 \begin_layout Itemize
1579 Syntax: palette:adjust_transparency(newvalue)
1580 \end_layout
1582 \begin_layout Itemize
1583 Deprecated: gui.adjust_transparency(palette, ...)
1584 \end_layout
1586 \begin_layout Standard
1587 Parameters:
1588 \end_layout
1590 \begin_layout Itemize
1591 palette: PALETTE: The palette to adjust.
1592 \end_layout
1594 \begin_layout Itemize
1595 Number adj: The factor to multiply opaqueness with times 256.
1596 \end_layout
1598 \begin_layout Standard
1599 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1600 \end_layout
1602 \begin_layout Standard
1603 \begin_inset Newpage pagebreak
1604 \end_inset
1607 \end_layout
1609 \begin_layout Subsection
1610 BITMAP: Indexed-color bitmap
1611 \end_layout
1613 \begin_layout Subsubsection
1614 Static function new: Create a new bitmap
1615 \end_layout
1617 \begin_layout Itemize
1618 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1619 \end_layout
1621 \begin_layout Itemize
1622 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1623 \end_layout
1625 \begin_layout Itemize
1626 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1627 \end_layout
1629 \begin_layout Standard
1630 Parameters:
1631 \end_layout
1633 \begin_layout Itemize
1634 w: number: The width of bitmap to create in pixels.
1635 \end_layout
1637 \begin_layout Itemize
1638 h: number: The height of bitmap to create in pixels.
1639 \end_layout
1641 \begin_layout Itemize
1642 false: boolean: Constant boolean false.
1643 \end_layout
1645 \begin_layout Itemize
1646 fillcolor: number: The initial fill index.
1647  Default 0 if not specified.
1648 \end_layout
1650 \begin_layout Standard
1651 Create a new bitmap of size <w>*<h>.
1652  Fill the bitmap with color index <fillcolor>.
1653 \end_layout
1655 \begin_layout Subsubsection
1656 Method draw: Draw a bitmap
1657 \end_layout
1659 \begin_layout Itemize
1660 Syntax: bitmap:draw(x, y, palette)
1661 \end_layout
1663 \begin_layout Itemize
1664 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1665 \end_layout
1667 \begin_layout Standard
1668 Parameters:
1669 \end_layout
1671 \begin_layout Itemize
1672 bitmap: BITMAP: The bitmap to draw
1673 \end_layout
1675 \begin_layout Itemize
1676 x: number: The x-coordinate on screen.
1677 \end_layout
1679 \begin_layout Itemize
1680 y: number: The y-coordinate on screen.
1681 \end_layout
1683 \begin_layout Itemize
1684 palette: The palette to use for drawing.
1685 \end_layout
1687 \begin_layout Standard
1688 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1689 \end_layout
1691 \begin_layout Subsubsection
1692 Method draw_outside: Draw a bitmap outside game area
1693 \end_layout
1695 \begin_layout Itemize
1696 Syntax: bitmap:draw_outside(x, y, palette)
1697 \end_layout
1699 \begin_layout Standard
1700 Like bitmap:draw, but does not draw on game area.
1701 \end_layout
1703 \begin_layout Subsubsection
1704 Method draw_clip: Draw a bitmap, with clipping
1705 \end_layout
1707 \begin_layout Itemize
1708 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1709 \end_layout
1711 \begin_layout Standard
1712 Parameters:
1713 \end_layout
1715 \begin_layout Itemize
1716 bitmap: BITMAP: The bitmap to draw
1717 \end_layout
1719 \begin_layout Itemize
1720 x: number: The x-coordinate on screen.
1721 \end_layout
1723 \begin_layout Itemize
1724 y: number: The y-coordinate on screen.
1725 \end_layout
1727 \begin_layout Itemize
1728 palette: The palette to use for drawing.
1729 \end_layout
1731 \begin_layout Itemize
1732 x0: The smallest bitmap x coordinate to draw.
1733 \end_layout
1735 \begin_layout Itemize
1736 y0: The smallest bitmap y coordinate to draw.
1737 \end_layout
1739 \begin_layout Itemize
1740 width: Width of region to draw
1741 \end_layout
1743 \begin_layout Itemize
1744 height: Height of region to draw.
1745 \end_layout
1747 \begin_layout Standard
1748 Like bitmap:draw, but clip the bitmap area drawn.
1749 \end_layout
1751 \begin_layout Subsubsection
1752 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1753 \end_layout
1755 \begin_layout Itemize
1756 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1757 \end_layout
1759 \begin_layout Standard
1760 Like bitmap:draw_clip, but only draw outside game area.
1761 \end_layout
1763 \begin_layout Subsubsection
1764 Method pset: Set pixel in bitmap
1765 \end_layout
1767 \begin_layout Itemize
1768 Syntax: bitmap:pset(x, y, color)
1769 \end_layout
1771 \begin_layout Itemize
1772 Deprecaed: gui.bitmap_pset(bitmap, ...)
1773 \end_layout
1775 \begin_layout Standard
1776 Parameters:
1777 \end_layout
1779 \begin_layout Itemize
1780 bitmap: BITMAP: The bitmap to manipulate.
1781 \end_layout
1783 \begin_layout Itemize
1784 x: number: x-coordinate of pixel to set.
1785 \end_layout
1787 \begin_layout Itemize
1788 y: number: y-coordinate of pixel to set.
1789 \end_layout
1791 \begin_layout Itemize
1792 color: number: The color index to set.
1793 \end_layout
1795 \begin_layout Standard
1796 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1797 \end_layout
1799 \begin_layout Subsubsection
1800 Method pget: Get pixel in bitmap
1801 \end_layout
1803 \begin_layout Itemize
1804 Syntax: color bitmap:pget(x,y)
1805 \end_layout
1807 \begin_layout Itemize
1808 Deprecated: color gui.bitmap_pget(bitmap, ...)
1809 \end_layout
1811 \begin_layout Standard
1812 Parameters:
1813 \end_layout
1815 \begin_layout Itemize
1816 bitmap: BITMAP: The bitmap to query.
1817 \end_layout
1819 \begin_layout Itemize
1820 x: number: x-coordinate of pixel to get.
1821 \end_layout
1823 \begin_layout Itemize
1824 y: number: y-coordinate of pixel to get.
1825 \end_layout
1827 \begin_layout Standard
1828 Returns:
1829 \end_layout
1831 \begin_layout Itemize
1832 color: number: The color index in specified pixel.
1833 \end_layout
1835 \begin_layout Standard
1836 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1837 \end_layout
1839 \begin_layout Subsubsection
1840 Method size: Get size of bitmap
1841 \end_layout
1843 \begin_layout Itemize
1844 Syntax: width, height bitmap:size()
1845 \end_layout
1847 \begin_layout Itemize
1848 Syntax: width, height gui.bitmap_size(bitmap)
1849 \end_layout
1851 \begin_layout Standard
1852 Parameters:
1853 \end_layout
1855 \begin_layout Itemize
1856 bitmap: BITMAP: The bitmap to query.
1857 \end_layout
1859 \begin_layout Standard
1860 Returns:
1861 \end_layout
1863 \begin_layout Itemize
1864 width: number: The width of the bitmap.
1865 \end_layout
1867 \begin_layout Itemize
1868 height: number: The height of the bitmap.
1869 \end_layout
1871 \begin_layout Standard
1872 Get size of bitmap <bitmap>.
1873 \end_layout
1875 \begin_layout Subsubsection
1876 Method blit: Blit a bitmap into another
1877 \end_layout
1879 \begin_layout Itemize
1880 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1881 \end_layout
1883 \begin_layout Itemize
1884 Deprecated: gui.bitmap_blit(dest, ...)
1885 \end_layout
1887 \begin_layout Standard
1888 Parameters:
1889 \end_layout
1891 \begin_layout Itemize
1892 dest: BITMAP: The target bitmap to blit to.
1893 \end_layout
1895 \begin_layout Itemize
1896 dx: number: The x-coordinate in target.
1897 \end_layout
1899 \begin_layout Itemize
1900 dy: number: The y-coordinate in target.
1901 \end_layout
1903 \begin_layout Itemize
1904 src: BITMAP: The source bitmap.
1905 \end_layout
1907 \begin_layout Itemize
1908 sx: number: The x-coordinate in source.
1909 \end_layout
1911 \begin_layout Itemize
1912 sy: number: The y-coordinate in source.
1913 \end_layout
1915 \begin_layout Itemize
1916 w: number: The width of area to blit.
1917 \end_layout
1919 \begin_layout Itemize
1920 h: number: The height of area to blit.
1921 \end_layout
1923 \begin_layout Itemize
1924 ck: number: The color key.
1925  Pixels with this index are not copied.
1926 \begin_inset Separator latexpar
1927 \end_inset
1930 \end_layout
1932 \begin_deeper
1933 \begin_layout Itemize
1934 If none is specified, all pixels are copied.
1935 \end_layout
1937 \end_deeper
1938 \begin_layout Standard
1939 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1940  <dx>,<dy>.
1941  If a color key <ck> is specified, pixels of that color are not copied.
1942 \end_layout
1944 \begin_layout Subsubsection
1945 Method blit_scaled: Blit a bitmap into another with scaling
1946 \end_layout
1948 \begin_layout Itemize
1949 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1950 \end_layout
1952 \begin_layout Itemize
1953 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1954 \end_layout
1956 \begin_layout Standard
1957 Parameters:
1958 \end_layout
1960 \begin_layout Itemize
1961 dest: BITMAP: The target bitmap to blit to.
1962 \end_layout
1964 \begin_layout Itemize
1965 dx: number: The x-coordinate in target.
1966 \end_layout
1968 \begin_layout Itemize
1969 dy: number: The y-coordinate in target.
1970 \end_layout
1972 \begin_layout Itemize
1973 src: BITMAP: The source bitmap.
1974 \end_layout
1976 \begin_layout Itemize
1977 sx: number: The x-coordinate in source.
1978 \end_layout
1980 \begin_layout Itemize
1981 sy: number: The y-coordinate in source.
1982 \end_layout
1984 \begin_layout Itemize
1985 w: number: The width of area to blit.
1986 \end_layout
1988 \begin_layout Itemize
1989 h: number: The height of area to blit.
1990 \end_layout
1992 \begin_layout Itemize
1993 hscl: number: Horizontal scale factor (integer).
1994 \end_layout
1996 \begin_layout Itemize
1997 vscl: number: Vertical scale factor (integer).
1998  Defaults to the same as <hscl>.
1999 \end_layout
2001 \begin_layout Itemize
2002 ck: number: The color key.
2003  Pixels with this index are not copied.
2004 \begin_inset Separator latexpar
2005 \end_inset
2008 \end_layout
2010 \begin_deeper
2011 \begin_layout Itemize
2012 If none is specified, all pixels are copied.
2013 \end_layout
2015 \end_deeper
2016 \begin_layout Standard
2017 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
2018  neighbor) by factor of <hscl>*<vscl>.
2019 \end_layout
2021 \begin_layout Subsubsection
2022 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2023 \end_layout
2025 \begin_layout Itemize
2026 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2027 \end_layout
2029 \begin_layout Itemize
2030 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2031 \end_layout
2033 \begin_layout Standard
2034 Parameters:
2035 \end_layout
2037 \begin_layout Itemize
2038 dest: BITMAP: The target bitmap to blit to.
2039 \end_layout
2041 \begin_layout Itemize
2042 dx: number: The x-coordinate in target.
2043 \end_layout
2045 \begin_layout Itemize
2046 dy: number: The y-coordinate in target.
2047 \end_layout
2049 \begin_layout Itemize
2050 src: BITMAP: The source bitmap.
2051 \end_layout
2053 \begin_layout Itemize
2054 sx: number: The x-coordinate in source.
2055 \end_layout
2057 \begin_layout Itemize
2058 sy: number: The y-coordinate in source.
2059 \end_layout
2061 \begin_layout Itemize
2062 w: number: The width of area to blit.
2063 \end_layout
2065 \begin_layout Itemize
2066 h: number: The height of area to blit.
2067 \end_layout
2069 \begin_layout Itemize
2070 operator: string: The operator to use.
2071 \begin_inset Separator latexpar
2072 \end_inset
2075 \end_layout
2077 \begin_deeper
2078 \begin_layout Itemize
2079 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2080  DestOut, Clear or Xor.
2081 \end_layout
2083 \end_deeper
2084 \begin_layout Standard
2085 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2086  operator.
2088 \end_layout
2090 \begin_layout Itemize
2091 Color index 0 in source and target is treated as background.
2092 \end_layout
2094 \begin_layout Subsubsection
2095 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2096  Porter-Duff composition
2097 \end_layout
2099 \begin_layout Itemize
2100 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2101  operator)
2102 \end_layout
2104 \begin_layout Itemize
2105 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2106 \end_layout
2108 \begin_layout Standard
2109 Parameters:
2110 \end_layout
2112 \begin_layout Itemize
2113 dest: BITMAP: The target bitmap to blit to.
2114 \end_layout
2116 \begin_layout Itemize
2117 dx: number: The x-coordinate in target.
2118 \end_layout
2120 \begin_layout Itemize
2121 dy: number: The y-coordinate in target.
2122 \end_layout
2124 \begin_layout Itemize
2125 src: BITMAP: The source bitmap.
2126 \end_layout
2128 \begin_layout Itemize
2129 sx: number: The x-coordinate in source.
2130 \end_layout
2132 \begin_layout Itemize
2133 sy: number: The y-coordinate in source.
2134 \end_layout
2136 \begin_layout Itemize
2137 w: number: The width of area to blit.
2138 \end_layout
2140 \begin_layout Itemize
2141 h: number: The height of area to blit.
2142 \end_layout
2144 \begin_layout Itemize
2145 hscl: number: Horizontal scale factor (integer).
2146 \end_layout
2148 \begin_layout Itemize
2149 vscl: number: Vertical scale factor (integer).
2150  Defaults to the same as <hscl>.
2151 \end_layout
2153 \begin_layout Itemize
2154 operator: string: The operator to use.
2155 \begin_inset Separator latexpar
2156 \end_inset
2159 \end_layout
2161 \begin_deeper
2162 \begin_layout Itemize
2163 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2164  DestOut, Clear or Xor.
2165 \end_layout
2167 \end_deeper
2168 \begin_layout Standard
2169 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2170  like BITMAP:blit_scaled.
2171 \end_layout
2173 \begin_layout Subsubsection
2174 Method blit_priority: Blit a bitmap into another with color priority
2175 \end_layout
2177 \begin_layout Itemize
2178 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2179 \end_layout
2181 \begin_layout Itemize
2182 Deprecated: gui.bitmap_blit_priority(dest, ...)
2183 \end_layout
2185 \begin_layout Standard
2186 Parameters:
2187 \end_layout
2189 \begin_layout Itemize
2190 dest: BITMAP: The target bitmap to blit to.
2191 \end_layout
2193 \begin_layout Itemize
2194 dx: number: The x-coordinate in target.
2195 \end_layout
2197 \begin_layout Itemize
2198 dy: number: The y-coordinate in target.
2199 \end_layout
2201 \begin_layout Itemize
2202 src: BITMAP: The source bitmap.
2203 \end_layout
2205 \begin_layout Itemize
2206 sx: number: The x-coordinate in source.
2207 \end_layout
2209 \begin_layout Itemize
2210 sy: number: The y-coordinate in source.
2211 \end_layout
2213 \begin_layout Itemize
2214 w: number: The width of area to blit.
2215 \end_layout
2217 \begin_layout Itemize
2218 h: number: The height of area to blit.
2219 \end_layout
2221 \begin_layout Standard
2222 Like BITMAP:blit, but only copy pixels where source color index is greater
2223  than destination color index.
2224 \end_layout
2226 \begin_layout Subsubsection
2227 Method blit_scaled_priority: Blit a bitmap into another with color priority
2228  and scaling
2229 \end_layout
2231 \begin_layout Itemize
2232 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2233 \end_layout
2235 \begin_layout Itemize
2236 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2237 \end_layout
2239 \begin_layout Standard
2240 Parameters:
2241 \end_layout
2243 \begin_layout Itemize
2244 dest: BITMAP: The target bitmap to blit to.
2245 \end_layout
2247 \begin_layout Itemize
2248 dx: number: The x-coordinate in target.
2249 \end_layout
2251 \begin_layout Itemize
2252 dy: number: The y-coordinate in target.
2253 \end_layout
2255 \begin_layout Itemize
2256 src: BITMAP: The source bitmap.
2257 \end_layout
2259 \begin_layout Itemize
2260 sx: number: The x-coordinate in source.
2261 \end_layout
2263 \begin_layout Itemize
2264 sy: number: The y-coordinate in source.
2265 \end_layout
2267 \begin_layout Itemize
2268 w: number: The width of area to blit.
2269 \end_layout
2271 \begin_layout Itemize
2272 h: number: The height of area to blit.
2273 \end_layout
2275 \begin_layout Itemize
2276 hscl: number: Horizontal scale factor (integer).
2277 \end_layout
2279 \begin_layout Itemize
2280 vscl: number: Vertical scale factor (integer).
2281  Defaults to the same as <hscl>.
2282 \end_layout
2284 \begin_layout Standard
2285 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2286 caled.
2287 \end_layout
2289 \begin_layout Subsubsection
2290 Method save_png: Save a bitmap to PNG
2291 \end_layout
2293 \begin_layout Itemize
2294 Syntax: bitmap:save_png(filename, [base], palette)
2295 \end_layout
2297 \begin_layout Itemize
2298 Syntax: data bitmap:save_png(palette)
2299 \end_layout
2301 \begin_layout Itemize
2302 Deprecated: ...
2303  gui.bitmap_save_png(bitmap, ...)
2304 \end_layout
2306 \begin_layout Standard
2307 Parameters:
2308 \end_layout
2310 \begin_layout Itemize
2311 bitmap: BITMAP: The bitmap to save.
2312 \end_layout
2314 \begin_layout Itemize
2315 filename: string: The filename to save to.
2316 \end_layout
2318 \begin_layout Itemize
2319 base: string: The base filename is resolved relative to.
2320 \end_layout
2322 \begin_layout Itemize
2323 palette: PALETTE: The palette to use.
2324 \end_layout
2326 \begin_layout Standard
2327 Return value:
2328 \end_layout
2330 \begin_layout Itemize
2331 data: string: BASE64 encoded PNG data.
2332 \end_layout
2334 \begin_layout Standard
2335 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2336  to <base>) or return BASE64 encoding of it.
2337 \end_layout
2339 \begin_layout Subsubsection
2340 Method hash: Hash a bitmap
2341 \end_layout
2343 \begin_layout Itemize
2344 Syntax: hash bitmap:hash()
2345 \end_layout
2347 \begin_layout Itemize
2348 Deprecated: hash bitmap:hash(bitmap)
2349 \end_layout
2351 \begin_layout Standard
2352 Parameters:
2353 \end_layout
2355 \begin_layout Itemize
2356 bitmap: BITMAP: The bitmap to hash.
2357 \end_layout
2359 \begin_layout Standard
2360 Return value:
2361 \end_layout
2363 \begin_layout Itemize
2364 hash: string: 64-hex digit hash
2365 \end_layout
2367 \begin_layout Standard
2368 Hashes bitmap <bitmap> and returns crypto-strong hash.
2370 \end_layout
2372 \begin_layout Itemize
2373 Color order in bitmap is significant.
2374 \end_layout
2376 \begin_layout Subsubsection
2377 Method sample_texture: Sample a texture
2378 \end_layout
2380 \begin_layout Itemize
2381 Syntax: none bitmap:sample_texture(BITMAP source, number xx, number xy,
2382  number x0, number yx, number yy, number y0, number scale, boolean wrap)
2383 \end_layout
2385 \begin_layout Standard
2386 Parameters:
2387 \end_layout
2389 \begin_layout Itemize
2390 source: BITMAP: The bitmap to sample
2391 \end_layout
2393 \begin_layout Itemize
2394 xx: number: s times the source x coefficient of target x axis.
2395 \end_layout
2397 \begin_layout Itemize
2398 xy: number: s times the source y coefficient of target x axis.
2399 \end_layout
2401 \begin_layout Itemize
2402 x0: number: s times the target x axis offset.
2403 \end_layout
2405 \begin_layout Itemize
2406 yx: number: s times the source x coefficient of target y axis.
2407 \end_layout
2409 \begin_layout Itemize
2410 yy: number: s times the source y coefficient of target y axis.
2411 \end_layout
2413 \begin_layout Itemize
2414 y0: number: s times the target y axis offset.
2415 \end_layout
2417 \begin_layout Itemize
2418 s: number: Scale of coordinates
2419 \end_layout
2421 \begin_layout Itemize
2422 wrap: boolean: If true, wrap the texture.
2423  If false, read outside the texture as color 0.
2424 \end_layout
2426 \begin_layout Standard
2427 Samples the source as texture, performing linear transform (with nearest-neighbo
2428 r sampling) and writes the result to this bitmap.
2429 \end_layout
2431 \begin_layout Subsubsection
2432 Method hflip: Horizontally flip a bitmap
2433 \end_layout
2435 \begin_layout Itemize
2436 Syntax: none bitmap:hflip()
2437 \end_layout
2439 \begin_layout Standard
2440 Horizontally flips a bitmap.
2441 \end_layout
2443 \begin_layout Subsubsection
2444 Method vflip: Vertically flip a bitmap
2445 \end_layout
2447 \begin_layout Itemize
2448 Syntax: none bitmap:vflip()
2449 \end_layout
2451 \begin_layout Standard
2452 Vertically flips a bitmap.
2453 \end_layout
2455 \begin_layout Standard
2456 \begin_inset Newpage pagebreak
2457 \end_inset
2460 \end_layout
2462 \begin_layout Subsection
2463 DBITMAP: Direct-color bitmap
2464 \end_layout
2466 \begin_layout Subsubsection
2467 Static function: new: Create a new bitmap
2468 \end_layout
2470 \begin_layout Itemize
2471 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2472 \end_layout
2474 \begin_layout Itemize
2475 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2476 \end_layout
2478 \begin_layout Itemize
2479 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2480 \end_layout
2482 \begin_layout Standard
2483 Parameters:
2484 \end_layout
2486 \begin_layout Itemize
2487 w: number: The width of new bitmap.
2488 \end_layout
2490 \begin_layout Itemize
2491 h: number: The height of new bitmap.
2492 \end_layout
2494 \begin_layout Itemize
2495 true: boolean: Fixed boolean true
2496 \end_layout
2498 \begin_layout Itemize
2499 fillcolor: The color to fill the bitmap with (default transparent).
2500 \end_layout
2502 \begin_layout Standard
2503 Return value:
2504 \end_layout
2506 \begin_layout Itemize
2507 bitmap: DBITMAP: The new bitmap.
2508 \end_layout
2510 \begin_layout Standard
2511 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2512  <fillcolor>.
2513 \end_layout
2515 \begin_layout Subsubsection
2516 Method draw: Draw a bitmap
2517 \end_layout
2519 \begin_layout Itemize
2520 Syntax: bitmap.draw(x, y)
2521 \end_layout
2523 \begin_layout Itemize
2524 Deprecated: gui.bitmap_draw(x, y, bitmap)
2525 \end_layout
2527 \begin_layout Standard
2528 Parameters:
2529 \end_layout
2531 \begin_layout Itemize
2532 bitmap: DBITMAP: The bitmap to draw.
2533 \end_layout
2535 \begin_layout Itemize
2536 x: number: X-coordinate on screen.
2537 \end_layout
2539 \begin_layout Itemize
2540 y: number: Y-coordinate on screen.
2541 \end_layout
2543 \begin_layout Standard
2544 Draw bitmap <bitmap> on screen at <x>,<y>.
2545 \end_layout
2547 \begin_layout Subsubsection
2548 Method draw_outside: Draw a bitmap outside game area
2549 \end_layout
2551 \begin_layout Itemize
2552 Syntax: dbitmap:draw_outside(x, y, palette)
2553 \end_layout
2555 \begin_layout Standard
2556 Like dbitmap:draw, but does not draw on game area.
2557 \end_layout
2559 \begin_layout Subsubsection
2560 Method draw_clip: Draw a bitmap, with clipping
2561 \end_layout
2563 \begin_layout Itemize
2564 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2565 \end_layout
2567 \begin_layout Standard
2568 Parameters:
2569 \end_layout
2571 \begin_layout Itemize
2572 bitmap: DBITMAP: The bitmap to draw
2573 \end_layout
2575 \begin_layout Itemize
2576 x: number: The x-coordinate on screen.
2577 \end_layout
2579 \begin_layout Itemize
2580 y: number: The y-coordinate on screen.
2581 \end_layout
2583 \begin_layout Itemize
2584 x0: The smallest bitmap x coordinate to draw.
2585 \end_layout
2587 \begin_layout Itemize
2588 y0: The smallest bitmap y coordinate to draw.
2589 \end_layout
2591 \begin_layout Itemize
2592 width: Width of region to draw
2593 \end_layout
2595 \begin_layout Itemize
2596 height: Height of region to draw.
2597 \end_layout
2599 \begin_layout Standard
2600 Like dbitmap:draw, but clip the bitmap area drawn.
2601 \end_layout
2603 \begin_layout Subsubsection
2604 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2605 \end_layout
2607 \begin_layout Itemize
2608 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2609 \end_layout
2611 \begin_layout Standard
2612 Like dbitmap:draw_clip, but only draw outside game area.
2613 \end_layout
2615 \begin_layout Subsubsection
2616 Method pset: Set pixel in bitmap
2617 \end_layout
2619 \begin_layout Itemize
2620 Syntax: bitmap:pset(x, y, color)
2621 \end_layout
2623 \begin_layout Itemize
2624 Deprecaed: gui.bitmap_pset(bitmap, ...)
2625 \end_layout
2627 \begin_layout Standard
2628 Parameters:
2629 \end_layout
2631 \begin_layout Itemize
2632 bitmap: DBITMAP: The bitmap to manipulate.
2633 \end_layout
2635 \begin_layout Itemize
2636 x: number: x-coordinate of pixel to set.
2637 \end_layout
2639 \begin_layout Itemize
2640 y: number: y-coordinate of pixel to set.
2641 \end_layout
2643 \begin_layout Itemize
2644 color: number/string: The color to set.
2645 \end_layout
2647 \begin_layout Standard
2648 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2649 \end_layout
2651 \begin_layout Subsubsection
2652 Method pget: Get pixel in bitmap
2653 \end_layout
2655 \begin_layout Itemize
2656 Syntax: color bitmap:pget(x,y)
2657 \end_layout
2659 \begin_layout Itemize
2660 Deprecated: color gui.bitmap_pget(bitmap, ...)
2661 \end_layout
2663 \begin_layout Standard
2664 Parameters:
2665 \end_layout
2667 \begin_layout Itemize
2668 bitmap: DBITMAP: The bitmap to query.
2669 \end_layout
2671 \begin_layout Itemize
2672 x: number: x-coordinate of pixel to get.
2673 \end_layout
2675 \begin_layout Itemize
2676 y: number: y-coordinate of pixel to get.
2677 \end_layout
2679 \begin_layout Standard
2680 Returns:
2681 \end_layout
2683 \begin_layout Itemize
2684 color: number: The color of specified pixel.
2685 \end_layout
2687 \begin_layout Standard
2688 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2689 \end_layout
2691 \begin_layout Subsubsection
2692 Method size: Get size of bitmap
2693 \end_layout
2695 \begin_layout Itemize
2696 Syntax: width, height bitmap:size()
2697 \end_layout
2699 \begin_layout Itemize
2700 Syntax: width, height gui.bitmap_size(bitmap)
2701 \end_layout
2703 \begin_layout Standard
2704 Parameters:
2705 \end_layout
2707 \begin_layout Itemize
2708 bitmap: DBITMAP: The bitmap to query.
2709 \end_layout
2711 \begin_layout Standard
2712 Returns:
2713 \end_layout
2715 \begin_layout Itemize
2716 width: number: The width of the bitmap.
2717 \end_layout
2719 \begin_layout Itemize
2720 height: number: The height of the bitmap.
2721 \end_layout
2723 \begin_layout Standard
2724 Get size of bitmap <bitmap>.
2725 \end_layout
2727 \begin_layout Subsubsection
2728 Method blit: Blit a bitmap into another
2729 \end_layout
2731 \begin_layout Itemize
2732 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2733 \end_layout
2735 \begin_layout Itemize
2736 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2737 \end_layout
2739 \begin_layout Itemize
2740 Deprecated: gui.bitmap_blit(dest, ...)
2741 \end_layout
2743 \begin_layout Standard
2744 Parameters:
2745 \end_layout
2747 \begin_layout Itemize
2748 dest: DBITMAP: The target bitmap to blit to.
2749 \end_layout
2751 \begin_layout Itemize
2752 dx: number: The x-coordinate in target.
2753 \end_layout
2755 \begin_layout Itemize
2756 dy: number: The y-coordinate in target.
2757 \end_layout
2759 \begin_layout Itemize
2760 src: BITMAP/DBITMAP: The source bitmap.
2761 \end_layout
2763 \begin_layout Itemize
2764 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2765 \end_layout
2767 \begin_layout Itemize
2768 sx: number: The x-coordinate in source.
2769 \end_layout
2771 \begin_layout Itemize
2772 sy: number: The y-coordinate in source.
2773 \end_layout
2775 \begin_layout Itemize
2776 w: number: The width of area to blit.
2777 \end_layout
2779 \begin_layout Itemize
2780 h: number: The height of area to blit.
2781 \end_layout
2783 \begin_layout Itemize
2784 ck: number: The color key.
2785  Pixels with this index are not copied.
2786 \begin_inset Separator latexpar
2787 \end_inset
2790 \end_layout
2792 \begin_deeper
2793 \begin_layout Itemize
2794 If none is specified, all pixels are copied.
2795 \end_layout
2797 \begin_layout Itemize
2798 If <src> is paletted, this is color index, otherwise it is a color.
2799 \end_layout
2801 \end_deeper
2802 \begin_layout Standard
2803 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2804  if indexed) into <dest> at <dx>,<dy>.
2805  If a color key <ck> is specified, pixels of that color are not copied.
2806 \end_layout
2808 \begin_layout Subsubsection
2809 Method blit_scaled: Blit a bitmap into another with scaling
2810 \end_layout
2812 \begin_layout Itemize
2813 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2814 \end_layout
2816 \begin_layout Itemize
2817 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2818  [ck])
2819 \end_layout
2821 \begin_layout Itemize
2822 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2823 \end_layout
2825 \begin_layout Standard
2826 Parameters:
2827 \end_layout
2829 \begin_layout Itemize
2830 dest: DBITMAP: The target bitmap to blit to.
2831 \end_layout
2833 \begin_layout Itemize
2834 dx: number: The x-coordinate in target.
2835 \end_layout
2837 \begin_layout Itemize
2838 dy: number: The y-coordinate in target.
2839 \end_layout
2841 \begin_layout Itemize
2842 src: BITMAP/DBITMAP: The source bitmap.
2843 \end_layout
2845 \begin_layout Itemize
2846 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2847 \end_layout
2849 \begin_layout Itemize
2850 sx: number: The x-coordinate in source.
2851 \end_layout
2853 \begin_layout Itemize
2854 sy: number: The y-coordinate in source.
2855 \end_layout
2857 \begin_layout Itemize
2858 w: number: The width of area to blit.
2859 \end_layout
2861 \begin_layout Itemize
2862 h: number: The height of area to blit.
2863 \end_layout
2865 \begin_layout Itemize
2866 hscl: number: Horizontal scale factor (integer).
2867 \end_layout
2869 \begin_layout Itemize
2870 vscl: number: Vertical scale factor (integer).
2871  Defaults to the same as <hscl>.
2872 \end_layout
2874 \begin_layout Itemize
2875 ck: number: The color key.
2876  Pixels with this index are not copied.
2877 \begin_inset Separator latexpar
2878 \end_inset
2881 \end_layout
2883 \begin_deeper
2884 \begin_layout Itemize
2885 If none is specified, all pixels are copied.
2886 \end_layout
2888 \begin_layout Itemize
2889 If <src> is paletted, this is color index, otherwise it is a color.
2890 \end_layout
2892 \end_deeper
2893 \begin_layout Standard
2894 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2895  neighbor) by factor of <hscl>*<vscl>.
2896 \end_layout
2898 \begin_layout Subsubsection
2899 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2900 \end_layout
2902 \begin_layout Itemize
2903 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2904 \end_layout
2906 \begin_layout Itemize
2907 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2908 \end_layout
2910 \begin_layout Itemize
2911 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2912 \end_layout
2914 \begin_layout Standard
2915 Parameters:
2916 \end_layout
2918 \begin_layout Itemize
2919 dest: DBITMAP: The target bitmap to blit to.
2920 \end_layout
2922 \begin_layout Itemize
2923 dx: number: The x-coordinate in target.
2924 \end_layout
2926 \begin_layout Itemize
2927 dy: number: The y-coordinate in target.
2928 \end_layout
2930 \begin_layout Itemize
2931 src: BITMAP/DBITMAP: The source bitmap.
2932 \end_layout
2934 \begin_layout Itemize
2935 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2936 \end_layout
2938 \begin_layout Itemize
2939 sx: number: The x-coordinate in source.
2940 \end_layout
2942 \begin_layout Itemize
2943 sy: number: The y-coordinate in source.
2944 \end_layout
2946 \begin_layout Itemize
2947 w: number: The width of area to blit.
2948 \end_layout
2950 \begin_layout Itemize
2951 h: number: The height of area to blit.
2952 \end_layout
2954 \begin_layout Itemize
2955 operator: string: The operator to use.
2956 \begin_inset Separator latexpar
2957 \end_inset
2960 \end_layout
2962 \begin_deeper
2963 \begin_layout Itemize
2964 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2965  DestOut, Clear or Xor.
2966 \end_layout
2968 \end_deeper
2969 \begin_layout Standard
2970 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2971 f operator.
2973 \end_layout
2975 \begin_layout Itemize
2976 In target, fully transparent is background.
2977  In source, either fully transparent (if direct) or index 0 (if paletted)
2978  is treated as background.
2979 \end_layout
2981 \begin_layout Subsubsection
2982 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2983  Porter-Duff composition
2984 \end_layout
2986 \begin_layout Itemize
2987 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2988  operator)
2989 \end_layout
2991 \begin_layout Itemize
2992 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2993  [vscl], operator)
2994 \end_layout
2996 \begin_layout Itemize
2997 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2998 \end_layout
3000 \begin_layout Standard
3001 Parameters:
3002 \end_layout
3004 \begin_layout Itemize
3005 dest: DBITMAP: The target bitmap to blit to.
3006 \end_layout
3008 \begin_layout Itemize
3009 dx: number: The x-coordinate in target.
3010 \end_layout
3012 \begin_layout Itemize
3013 dy: number: The y-coordinate in target.
3014 \end_layout
3016 \begin_layout Itemize
3017 src: BITMAP/DBITMAP: The source bitmap.
3018 \end_layout
3020 \begin_layout Itemize
3021 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
3022 \end_layout
3024 \begin_layout Itemize
3025 sx: number: The x-coordinate in source.
3026 \end_layout
3028 \begin_layout Itemize
3029 sy: number: The y-coordinate in source.
3030 \end_layout
3032 \begin_layout Itemize
3033 w: number: The width of area to blit.
3034 \end_layout
3036 \begin_layout Itemize
3037 h: number: The height of area to blit.
3038 \end_layout
3040 \begin_layout Itemize
3041 hscl: number: Horizontal scale factor (integer).
3042 \end_layout
3044 \begin_layout Itemize
3045 vscl: number: Vertical scale factor (integer).
3046  Defaults to the same as <hscl>.
3047 \end_layout
3049 \begin_layout Itemize
3050 operator: string: The operator to use.
3051 \begin_inset Separator latexpar
3052 \end_inset
3055 \end_layout
3057 \begin_deeper
3058 \begin_layout Itemize
3059 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
3060  DestOut, Clear or Xor.
3061 \end_layout
3063 \end_deeper
3064 \begin_layout Standard
3065 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
3066  like DBITMAP:blit_scaled.
3067 \end_layout
3069 \begin_layout Subsubsection
3070 Method adjust_transparency: Adjust transparency of bitmap
3071 \end_layout
3073 \begin_layout Itemize
3074 Syntax: bitmap:adjust_transparency(newvalue)
3075 \end_layout
3077 \begin_layout Itemize
3078 Deprecated: gui.adjust_transparency(bitmap, ...)
3079 \end_layout
3081 \begin_layout Standard
3082 Parameters:
3083 \end_layout
3085 \begin_layout Itemize
3086 bitmap: DBITMAP: The bitmap to adjust.
3087 \end_layout
3089 \begin_layout Itemize
3090 Number adj: The factor to multiply opaqueness with times 256.
3091 \end_layout
3093 \begin_layout Standard
3094 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
3095 \end_layout
3097 \begin_layout Subsubsection
3098 Method save_png: Save a bitmap to PNG
3099 \end_layout
3101 \begin_layout Itemize
3102 Syntax: bitmap:save_png(filename, [base])
3103 \end_layout
3105 \begin_layout Itemize
3106 Syntax: data bitmap:save_png()
3107 \end_layout
3109 \begin_layout Itemize
3110 Deprecated: ...
3111  gui.bitmap_save_png(bitmap, ...)
3112 \end_layout
3114 \begin_layout Standard
3115 Parameters:
3116 \end_layout
3118 \begin_layout Itemize
3119 bitmap: DBITMAP: The bitmap to save.
3120 \end_layout
3122 \begin_layout Itemize
3123 filename: string: The filename to save to.
3124 \end_layout
3126 \begin_layout Itemize
3127 base: string: The base filename is resolved relative to.
3128 \end_layout
3130 \begin_layout Standard
3131 Return value:
3132 \end_layout
3134 \begin_layout Itemize
3135 data: string: BASE64 encoded PNG data.
3136 \end_layout
3138 \begin_layout Standard
3139 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
3140  BASE64 encoding of it.
3141 \end_layout
3143 \begin_layout Subsubsection
3144 Method hash: Hash a bitmap
3145 \end_layout
3147 \begin_layout Itemize
3148 Syntax: hash bitmap:hash()
3149 \end_layout
3151 \begin_layout Itemize
3152 Deprecated: hash bitmap:hash(bitmap)
3153 \end_layout
3155 \begin_layout Standard
3156 Parameters:
3157 \end_layout
3159 \begin_layout Itemize
3160 bitmap: DBITMAP: The bitmap to hash.
3161 \end_layout
3163 \begin_layout Standard
3164 Return value:
3165 \end_layout
3167 \begin_layout Itemize
3168 hash: string: 64-hex digit hash
3169 \end_layout
3171 \begin_layout Standard
3172 Hashes bitmap <bitmap> and returns crypto-strong hash.
3174 \end_layout
3176 \begin_layout Subsubsection
3177 Method sample_texture: Sample a texture
3178 \end_layout
3180 \begin_layout Itemize
3181 Syntax: none bitmap:sample_texture(BITMAP source, number xx, number xy,
3182  number x0, number yx, number yy, number y0, number scale, boolean wrap)
3183 \end_layout
3185 \begin_layout Standard
3186 Parameters:
3187 \end_layout
3189 \begin_layout Itemize
3190 source: BITMAP: The bitmap to sample
3191 \end_layout
3193 \begin_layout Itemize
3194 xx: number: s times the source x coefficient of target x axis.
3195 \end_layout
3197 \begin_layout Itemize
3198 xy: number: s times the source y coefficient of target x axis.
3199 \end_layout
3201 \begin_layout Itemize
3202 x0: number: s times the target x axis offset.
3203 \end_layout
3205 \begin_layout Itemize
3206 yx: number: s times the source x coefficient of target y axis.
3207 \end_layout
3209 \begin_layout Itemize
3210 yy: number: s times the source y coefficient of target y axis.
3211 \end_layout
3213 \begin_layout Itemize
3214 y0: number: s times the target y axis offset.
3215 \end_layout
3217 \begin_layout Itemize
3218 s: number: Scale of coordinates
3219 \end_layout
3221 \begin_layout Itemize
3222 wrap: boolean: If true, wrap the texture.
3223  If false, read outside the texture as color 0.
3224 \end_layout
3226 \begin_layout Standard
3227 Samples the source as texture, performing linear transform (with nearest-neighbo
3228 r sampling) and writes the result to this bitmap.
3229 \end_layout
3231 \begin_layout Subsubsection
3232 Method hflip: Horizontally flip a bitmap
3233 \end_layout
3235 \begin_layout Itemize
3236 Syntax: none dbitmap:hflip()
3237 \end_layout
3239 \begin_layout Standard
3240 Horizontally flips a bitmap.
3241 \end_layout
3243 \begin_layout Subsubsection
3244 Method vflip: Vertically flip a bitmap
3245 \end_layout
3247 \begin_layout Itemize
3248 Syntax: none dbitmap:vflip()
3249 \end_layout
3251 \begin_layout Standard
3252 Vertically flips a bitmap.
3253 \end_layout
3255 \begin_layout Standard
3256 \begin_inset Newpage pagebreak
3257 \end_inset
3260 \end_layout
3262 \begin_layout Subsection
3263 IMAGELOADER: Load an image
3264 \end_layout
3266 \begin_layout Subsubsection
3267 Static function load: Load a bitmap from file
3268 \end_layout
3270 \begin_layout Itemize
3271 Syntax: bitmap, palette gui.image.load(file, [base])
3272 \end_layout
3274 \begin_layout Itemize
3275 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3276 \end_layout
3278 \begin_layout Itemize
3279 Deprecated: ...
3280  gui.bitmap_load(...)
3281 \end_layout
3283 \begin_layout Standard
3284 Parameters:
3285 \end_layout
3287 \begin_layout Itemize
3288 file: string: The file to read.
3289 \end_layout
3291 \begin_layout Itemize
3292 base: string: The base to resolve <file> relative to.
3293 \end_layout
3295 \begin_layout Standard
3296 Returns:
3297 \end_layout
3299 \begin_layout Itemize
3300 bitmap: BITMAP/DBITMAP: The new bitmap
3301 \end_layout
3303 \begin_layout Itemize
3304 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3305  nil.
3306 \end_layout
3308 \begin_layout Standard
3309 Load a new bitmap and return it (plus associated palette if any).
3310 \end_layout
3312 \begin_layout Subsubsection
3313 Static function load_str: Load a bitmap from string
3314 \end_layout
3316 \begin_layout Itemize
3317 Syntax: bitmap, palette gui.image.load_str(data)
3318 \end_layout
3320 \begin_layout Itemize
3321 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3322 \end_layout
3324 \begin_layout Itemize
3325 Deprecated: ...
3326  gui.bitmap_load_str(...)
3327 \end_layout
3329 \begin_layout Standard
3330 Parameters:
3331 \end_layout
3333 \begin_layout Itemize
3334 data: string: The image data
3335 \end_layout
3337 \begin_layout Standard
3338 Returns:
3339 \end_layout
3341 \begin_layout Itemize
3342 bitmap: BITMAP/DBITMAP: The new bitmap
3343 \end_layout
3345 \begin_layout Itemize
3346 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3347  nil.
3348 \end_layout
3350 \begin_layout Standard
3351 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3352  file.
3353 \end_layout
3355 \begin_layout Subsubsection
3356 Static function load_png: Load a bitmap from PNG file
3357 \end_layout
3359 \begin_layout Itemize
3360 Syntax: bitmap, palette gui.image.load_png(file, [base])
3361 \end_layout
3363 \begin_layout Itemize
3364 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3365 \end_layout
3367 \begin_layout Itemize
3368 Deprecated: ...
3369  gui.bitmap_load_png(...)
3370 \end_layout
3372 \begin_layout Standard
3373 Parameters:
3374 \end_layout
3376 \begin_layout Itemize
3377 file: string: The file to read.
3378 \end_layout
3380 \begin_layout Itemize
3381 base: string: The base to resolve <file> relative to.
3382 \end_layout
3384 \begin_layout Standard
3385 Returns:
3386 \end_layout
3388 \begin_layout Itemize
3389 bitmap: BITMAP/DBITMAP: The new bitmap
3390 \end_layout
3392 \begin_layout Itemize
3393 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3394  nil.
3395 \end_layout
3397 \begin_layout Standard
3398 Like IMAGELOADER:load, but load a PNG file instead.
3399 \end_layout
3401 \begin_layout Subsubsection
3402 Static function load_png_str: Load a PNG bitmap from string
3403 \end_layout
3405 \begin_layout Itemize
3406 Syntax: bitmap, palette gui.image.load_png_str(data)
3407 \end_layout
3409 \begin_layout Itemize
3410 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3411 \end_layout
3413 \begin_layout Itemize
3414 Deprecated: ...
3415  gui.bitmap_load_png_str(...)
3416 \end_layout
3418 \begin_layout Standard
3419 Parameters:
3420 \end_layout
3422 \begin_layout Itemize
3423 data: string: The image data, base64 encoded.
3424 \end_layout
3426 \begin_layout Standard
3427 Returns:
3428 \end_layout
3430 \begin_layout Itemize
3431 bitmap: BITMAP/DBITMAP: The new bitmap
3432 \end_layout
3434 \begin_layout Itemize
3435 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3436  nil.
3437 \end_layout
3439 \begin_layout Standard
3440 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3441  <data> instead of file.
3442 \end_layout
3444 \begin_layout Standard
3445 \begin_inset Newpage pagebreak
3446 \end_inset
3449 \end_layout
3451 \begin_layout Subsection
3452 CUSTOMFONT: Arbitrary-sized bitmap font
3453 \end_layout
3455 \begin_layout Subsubsection
3456 Static function new: Return a new empty font
3457 \end_layout
3459 \begin_layout Itemize
3460 Syntax: font gui.font.new()
3461 \end_layout
3463 \begin_layout Itemize
3464 Syntax: font classes.CUSTOMFONT.new()
3465 \end_layout
3467 \begin_layout Itemize
3468 Deprecated: font gui.font_new()
3469 \end_layout
3471 \begin_layout Standard
3472 Return value:
3473 \end_layout
3475 \begin_layout Itemize
3476 font: CUSTOMFONT: New font.
3477 \end_layout
3479 \begin_layout Standard
3480 Create a new font with no characters and return it.
3481 \end_layout
3483 \begin_layout Subsubsection
3484 Static function: load: Load a font file
3485 \end_layout
3487 \begin_layout Itemize
3488 Syntax: font gui.font.load(file, [base])
3489 \end_layout
3491 \begin_layout Itemize
3492 Syntax: font gui.font.load()
3493 \end_layout
3495 \begin_layout Itemize
3496 Syntax: font classes.CUSTOMFONT.load(file, [base])
3497 \end_layout
3499 \begin_layout Itemize
3500 Syntax: font classes.CUSTOMFONT.load()
3501 \end_layout
3503 \begin_layout Itemize
3504 Deprecated: font gui.loadfont(...)
3505 \end_layout
3507 \begin_layout Standard
3508 Parameters:
3509 \end_layout
3511 \begin_layout Itemize
3512 file: string: The file to read the font from
3513 \end_layout
3515 \begin_layout Itemize
3516 base: string: The file to resolve <file> relative to.
3517 \end_layout
3519 \begin_layout Standard
3520 Return value:
3521 \end_layout
3523 \begin_layout Itemize
3524 font: CUSTOMFONT: New font.
3525 \end_layout
3527 \begin_layout Standard
3528 Load font from file <file> (relative to <base>).
3529  If no filename is given, system default font is loaded.
3530 \end_layout
3532 \begin_layout Subsubsection
3533 operator(): Render text to screen
3534 \end_layout
3536 \begin_layout Itemize
3537 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3538 \end_layout
3540 \begin_layout Standard
3541 Parmeters:
3542 \end_layout
3544 \begin_layout Itemize
3545 font: CUSTOMFONT: The font to use.
3546 \end_layout
3548 \begin_layout Itemize
3549 x: number: The x-position on screen to draw to.
3550 \end_layout
3552 \begin_layout Itemize
3553 y: number: The y-position on screen to draw to.
3554 \end_layout
3556 \begin_layout Itemize
3557 text: string: The text to draw.
3558 \end_layout
3560 \begin_layout Itemize
3561 fgc: number/string: Foreground color (default white).
3562 \end_layout
3564 \begin_layout Itemize
3565 bgc: number/string: Background color (default transparent).
3566 \end_layout
3568 \begin_layout Itemize
3569 hlc: number/string: Outline color (default transparent).
3570 \end_layout
3572 \begin_layout Standard
3573 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3574  onto screen.
3575 \end_layout
3577 \begin_layout Itemize
3578 If <hlc> is transparent, no outline is drawn.
3579 \end_layout
3581 \begin_layout Subsubsection
3582 Method edit: Alter glyph in font
3583 \end_layout
3585 \begin_layout Itemize
3586 Syntax: font:edit(string character, bitmap glyph)
3587 \end_layout
3589 \begin_layout Standard
3590 Parameters:
3591 \end_layout
3593 \begin_layout Itemize
3594 font: CUSTOMFONT: The font to edit.
3595 \end_layout
3597 \begin_layout Itemize
3598 character: string: The character to edit (UTF-8 encoded).
3599 \end_layout
3601 \begin_layout Itemize
3602 glyph: BITMAP: The bitmap to use.
3603 \end_layout
3605 \begin_layout Standard
3606 Replace character <character> in font <font> by <glyph>.
3607 \end_layout
3609 \begin_layout Itemize
3610 Color index 0 is background, everything else is foreground.
3611 \end_layout
3613 \begin_layout Itemize
3614 <character> may be empty string, meaning the replacement character used
3615  for bad characters.
3616 \end_layout
3618 \begin_layout Itemize
3619 <character> may be multi-codepoint string, meaning character used for that
3620  ligature.
3621 \end_layout
3623 \begin_layout Subsubsection
3624 Method dump: Dump font into file
3625 \end_layout
3627 \begin_layout Itemize
3628 Syntax: font:dump(string filename[, string base])
3629 \end_layout
3631 \begin_layout Standard
3632 Parameters:
3633 \end_layout
3635 \begin_layout Itemize
3636 filename: string: The file to dump to
3637 \end_layout
3639 \begin_layout Itemize
3640 base: string: The base filename
3641 \end_layout
3643 \begin_layout Standard
3644 Dump contents of <font> in file <filename> (resolved relative to <base>).
3645  The dump is in format CUSTOMFONT:load() can load.
3646 \end_layout
3648 \begin_layout Standard
3649 \begin_inset Newpage pagebreak
3650 \end_inset
3653 \end_layout
3655 \begin_layout Subsection
3656 ICONV: Character set conversions
3657 \end_layout
3659 \begin_layout Subsubsection
3660 Static function new: Create new character set converter
3661 \end_layout
3663 \begin_layout Itemize
3664 Syntax: iconv iconv.new(from, to);
3665 \end_layout
3667 \begin_layout Itemize
3668 Syntax: iconv classes.ICONV.new(from, to);
3669 \end_layout
3671 \begin_layout Itemize
3672 Deprecated: iconv iconv_new(...);
3673 \end_layout
3675 \begin_layout Standard
3676 Parameters:
3677 \end_layout
3679 \begin_layout Itemize
3680 from: string: The source character set.
3681 \end_layout
3683 \begin_layout Itemize
3684 to: string: The target character set.
3685 \end_layout
3687 \begin_layout Standard
3688 Returns:
3689 \end_layout
3691 \begin_layout Itemize
3692 iconv: ICONV: The converter.
3693 \end_layout
3695 \begin_layout Standard
3696 Create a character set converter, converting from <from> to <to> and return
3697  it.
3698 \end_layout
3700 \begin_layout Subsubsection
3701 Operator(): Convert string fragment from character set to another
3702 \end_layout
3704 \begin_layout Itemize
3705 Syntax: success, result, unconverted, error iconv(input)
3706 \end_layout
3708 \begin_layout Standard
3709 Parameters:
3710 \end_layout
3712 \begin_layout Itemize
3713 iconv: ICONV: The context to use.
3714 \end_layout
3716 \begin_layout Itemize
3717 input: string: The input to convert.
3718 \end_layout
3720 \begin_layout Standard
3721 Return value:
3722 \end_layout
3724 \begin_layout Itemize
3725 success: boolean: True if conversion was successful, false if not.
3726 \end_layout
3728 \begin_layout Itemize
3729 result: string: The string (partially) converted.
3730 \end_layout
3732 \begin_layout Itemize
3733 unconvered: number: Number of bytes that were not converted (only if <success>
3734  is false).
3735 \end_layout
3737 \begin_layout Itemize
3738 error: string: Error that caused conversion to stop (only if <success> is
3739  false).
3740 \begin_inset Separator latexpar
3741 \end_inset
3744 \end_layout
3746 \begin_deeper
3747 \begin_layout Itemize
3748 INVALID: The input string is invalid.
3749 \end_layout
3751 \begin_layout Itemize
3752 INCOMPLETE: The input string cuts off in middle of character.
3753 \end_layout
3755 \begin_layout Itemize
3756 INTERNALERR: Internal error.
3757 \end_layout
3759 \end_deeper
3760 \begin_layout Standard
3761 Convert a string <input> using character set converter <iconv> and return
3762  the result.
3763 \end_layout
3765 \begin_layout Standard
3766 \begin_inset Newpage pagebreak
3767 \end_inset
3770 \end_layout
3772 \begin_layout Subsection
3773 FILEREADER: Read a file as a stream
3774 \end_layout
3776 \begin_layout Subsubsection
3777 Static function open: Open a stream
3778 \end_layout
3780 \begin_layout Itemize
3781 Syntax: handle filereader.open(file, [base])
3782 \end_layout
3784 \begin_layout Itemize
3785 Syntax: handle classes.FILEREADER.open(file, [base])
3786 \end_layout
3788 \begin_layout Itemize
3789 Deprecated: handle open_file(file, [base])
3790 \end_layout
3792 \begin_layout Standard
3793 Parameters:
3794 \end_layout
3796 \begin_layout Itemize
3797 file: string: The filename to read.
3798 \end_layout
3800 \begin_layout Itemize
3801 base: string: The base <file> is resolved against.
3802 \end_layout
3804 \begin_layout Standard
3805 Returns:
3806 \end_layout
3808 \begin_layout Itemize
3809 handle: FILEREADER: The new file reader.
3810 \end_layout
3812 \begin_layout Standard
3813 Open file <file> (relative to <base>) and return a handle to it.
3814 \end_layout
3816 \begin_layout Subsubsection
3817 operator(): Read line/bytes from stream
3818 \end_layout
3820 \begin_layout Itemize
3821 Syntax: result handle()
3822 \end_layout
3824 \begin_layout Itemize
3825 Syntax: result handle(bytes)
3826 \end_layout
3828 \begin_layout Standard
3829 Parameters:
3830 \end_layout
3832 \begin_layout Itemize
3833 handle: FILEREADER: The handle to read from.
3834 \end_layout
3836 \begin_layout Itemize
3837 bytes: Number of bytes to read (default is next line).
3838 \end_layout
3840 \begin_layout Standard
3841 Returns:
3842 \end_layout
3844 \begin_layout Itemize
3845 result: string: The read data, or nil on end-of-file.
3846 \end_layout
3848 \begin_layout Standard
3849 Reads next line or <bytes> bytes from specified file handle <handle>.
3850 \end_layout
3852 \begin_layout Itemize
3853 If reading specified number of bytes, the bytes are read in binary mode
3854  (as-is).
3855 \end_layout
3857 \begin_layout Itemize
3858 If reading next line, the line is read in text mode (any line ending is
3859  skpped).
3860 \end_layout
3862 \begin_layout Subsubsection
3863 Method lines: Iterator to read all lines
3864 \end_layout
3866 \begin_layout Itemize
3867 Syntax: for line in handle:lines() do ...
3868  end
3869 \end_layout
3871 \begin_layout Standard
3872 Parameters:
3873 \end_layout
3875 \begin_layout Itemize
3876 handle: FILEREADER: The handle to read.
3877 \end_layout
3879 \begin_layout Standard
3880 Returns:
3881 \end_layout
3883 \begin_layout Itemize
3884 A lua iterator with one variable.
3885 \end_layout
3887 \begin_layout Standard
3888 Return a Lua iterator that iterates all the lines in <handle>.
3889 \end_layout
3891 \begin_layout Standard
3892 \begin_inset Newpage pagebreak
3893 \end_inset
3896 \end_layout
3898 \begin_layout Subsection
3899 COMPARE_OBJ: Watch memory area for changes
3900 \end_layout
3902 \begin_layout Standard
3903 Objects of this class allow fast checking for modifications to given memory
3904  block.
3905 \end_layout
3907 \begin_layout Subsubsection
3908 Static function new: Create a checker
3909 \end_layout
3911 \begin_layout Itemize
3912 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3913  stride])
3914 \end_layout
3916 \begin_layout Itemize
3917 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3918 \end_layout
3920 \begin_layout Standard
3921 Parameters:
3922 \end_layout
3924 \begin_layout Itemize
3925 marea: string: The memory area to interpret <offset> against.
3926 \end_layout
3928 \begin_layout Itemize
3929 offset: number: The initial offset in memory area.
3930 \end_layout
3932 \begin_layout Itemize
3933 addrobj: ADDRESS: The memory address.
3934 \end_layout
3936 \begin_layout Itemize
3937 size: number: The number of bytes in each row.
3938 \end_layout
3940 \begin_layout Itemize
3941 rows: number: The number of rows.
3942  Default is 1.
3943 \end_layout
3945 \begin_layout Itemize
3946 stride: number: The number of bytes offset increments from one row to next.
3947 \end_layout
3949 \begin_layout Standard
3950 Returns:
3951 \end_layout
3953 \begin_layout Itemize
3954 A handle to object.
3955 \end_layout
3957 \begin_layout Standard
3958 Return an object watching specified memory area.
3959 \end_layout
3961 \begin_layout Itemize
3962 Note: For fastest operation, limit checks to inside one memory area (that
3963  has to be mappable, individual RAM areas often are).
3964 \end_layout
3966 \begin_layout Subsubsection
3967 operator(): Check area for modifications
3968 \end_layout
3970 \begin_layout Itemize
3971 Syntax: boolean handle()
3972 \end_layout
3974 \begin_layout Standard
3975 Returns:
3976 \end_layout
3978 \begin_layout Itemize
3979 True if memory block has been modified since last call (or object creation
3980  if first call), false if not.
3981 \end_layout
3983 \begin_layout Standard
3984 Check if the block has been modified.
3985 \end_layout
3987 \begin_layout Subsection
3988 ADDRESS: Memory address
3989 \end_layout
3991 \begin_layout Standard
3992 Objects of this class contain a memory address.
3993 \end_layout
3995 \begin_layout Subsubsection
3996 Static function new: Create new memory address
3997 \end_layout
3999 \begin_layout Itemize
4000 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
4001 \end_layout
4003 \begin_layout Itemize
4004 Syntax: ADDRESS memory.address.new(string marea, number offset)
4005 \end_layout
4007 \begin_layout Itemize
4008 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
4009 \end_layout
4011 \begin_layout Standard
4012 Parameters:
4013 \end_layout
4015 \begin_layout Itemize
4016 marea: The memory area
4017 \end_layout
4019 \begin_layout Itemize
4020 offset: The offset in memory area.
4021 \end_layout
4023 \begin_layout Standard
4024 Returns:
4025 \end_layout
4027 \begin_layout Itemize
4028 The memory area.
4029 \end_layout
4031 \begin_layout Standard
4032 Construct a new memory address object.
4033 \end_layout
4035 \begin_layout Subsubsection
4036 Method: addr: Get global address
4037 \end_layout
4039 \begin_layout Itemize
4040 Syntax: number addr:addr()
4041 \end_layout
4043 \begin_layout Standard
4044 Parameters:
4045 \end_layout
4047 \begin_layout Itemize
4048 addr: ADRESS: The original address.
4049 \end_layout
4051 \begin_layout Standard
4052 Returns:
4053 \end_layout
4055 \begin_layout Itemize
4056 The global address corresponding to this address.
4057 \end_layout
4059 \begin_layout Subsubsection
4060 Method: vma: Get memory area
4061 \end_layout
4063 \begin_layout Itemize
4064 Syntax: string addr:vma()
4065 \end_layout
4067 \begin_layout Standard
4068 Parameters:
4069 \end_layout
4071 \begin_layout Itemize
4072 addr: ADRESS: The original address.
4073 \end_layout
4075 \begin_layout Standard
4076 Returns:
4077 \end_layout
4079 \begin_layout Itemize
4080 The memory area corresponding to this address.
4081 \end_layout
4083 \begin_layout Subsubsection
4084 Method: offset: Get memory area offset
4085 \end_layout
4087 \begin_layout Itemize
4088 Syntax: string addr:offset()
4089 \end_layout
4091 \begin_layout Standard
4092 Parameters:
4093 \end_layout
4095 \begin_layout Itemize
4096 addr: ADRESS: The original address.
4097 \end_layout
4099 \begin_layout Standard
4100 Returns:
4101 \end_layout
4103 \begin_layout Itemize
4104 The offset in memory area corresponding to this address.
4105 \end_layout
4107 \begin_layout Subsubsection
4108 Method: replace: Replace address part
4109 \end_layout
4111 \begin_layout Itemize
4112 Syntax: ADDRESS addr:replace(offset[, bits])
4113 \end_layout
4115 \begin_layout Standard
4116 Parameters:
4117 \end_layout
4119 \begin_layout Itemize
4120 addr: ADRESS: The original address.
4121 \end_layout
4123 \begin_layout Itemize
4124 offset: number: The new offset
4125 \end_layout
4127 \begin_layout Itemize
4128 bits: number: The number of LSB to replace.
4129 \end_layout
4131 \begin_layout Standard
4132 Returns:
4133 \end_layout
4135 \begin_layout Itemize
4136 The modified address
4137 \end_layout
4139 \begin_layout Standard
4140 Returns a new address, with <bits> (all if missing) least significant bits
4141  of <addr> replaced by LSB of <offset>.
4142 \end_layout
4144 \begin_layout Subsubsection
4145 Method: add: Add to address
4146 \end_layout
4148 \begin_layout Itemize
4149 Syntax: ADDRESS addr:add(offset)
4150 \end_layout
4152 \begin_layout Itemize
4153 Syntax: ADDRESS addr:add(number, stride)
4154 \end_layout
4156 \begin_layout Itemize
4157 Syntax: ADDRESS addr:add(number, stride, offset)
4158 \end_layout
4160 \begin_layout Standard
4161 Parameters:
4162 \end_layout
4164 \begin_layout Itemize
4165 addr: ADRESS: The original address.
4166 \end_layout
4168 \begin_layout Itemize
4169 offset: number: Offset to add.
4170 \end_layout
4172 \begin_layout Itemize
4173 number: number: Number of table strides to add.
4174 \end_layout
4176 \begin_layout Itemize
4177 stride: number: The table stride.
4178 \end_layout
4180 \begin_layout Standard
4181 Returns:
4182 \end_layout
4184 \begin_layout Itemize
4185 The modified address
4186 \end_layout
4188 \begin_layout Standard
4189 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
4190  address <addr>.
4191 \end_layout
4193 \begin_layout Subsection
4194 ADDRESS:<op>: Read/Write memory
4195 \end_layout
4197 \begin_layout Itemize
4198 Syntax: none addr:<op>(value)
4199 \end_layout
4201 \begin_layout Itemize
4202 Syntax: number addr:<op>()
4203 \end_layout
4205 \begin_layout Standard
4206 Parameters:
4207 \end_layout
4209 \begin_layout Itemize
4210 addr: ADDRESS: The address to read/write.
4211 \end_layout
4213 \begin_layout Itemize
4214 value: number: The number to write.
4215 \end_layout
4217 \begin_layout Standard
4218 Returns:
4219 \end_layout
4221 \begin_layout Itemize
4222 The value read.
4223 \end_layout
4225 \begin_layout Standard
4226 Read/Write value from/to given address <addr>.
4227  The value written is <value>.
4228  <Op> is of form: [i][s]<type>, where:
4229 \end_layout
4231 \begin_layout Itemize
4232 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4233 \end_layout
4235 \begin_layout Itemize
4236 'i' signifies that the value is treated as opposite-to-normal endianess,
4237 \end_layout
4239 \begin_layout Itemize
4240 's' signifies that value is treated as signed (not available for floating-point).
4241 \end_layout
4243 \begin_layout Standard
4244 \begin_inset Newpage pagebreak
4245 \end_inset
4248 \end_layout
4250 \begin_layout Section
4251 Global
4252 \end_layout
4254 \begin_layout Subsection
4255 print: Print values to console
4256 \end_layout
4258 \begin_layout Itemize
4259 Syntax: none print(value...
4260  values)
4261 \end_layout
4263 \begin_layout Standard
4264 Prints specified values to console.
4265  Can print any Lua type at least enough to identify the type and instance.
4266 \end_layout
4268 \begin_layout Subsection
4269 tostringx: Format a value to string
4270 \end_layout
4272 \begin_layout Itemize
4273 Syntax: string tostringx(value val)
4274 \end_layout
4276 \begin_layout Standard
4277 Formats value <val> like print would, and returns the result as a string.
4278 \end_layout
4280 \begin_layout Subsection
4281 exec: Execute lsnes commands
4282 \end_layout
4284 \begin_layout Itemize
4285 Syntax: none exec(string cmd)
4286 \end_layout
4288 \begin_layout Standard
4289 Execute lsnes command <cmd>.
4290 \end_layout
4292 \begin_layout Subsection
4293 utime: Get current time
4294 \end_layout
4296 \begin_layout Itemize
4297 Syntax: (number,number) utime()
4298 \end_layout
4300 \begin_layout Standard
4301 Returns two numbers.
4302  First is time since some epoch in seconds, the second is microseconds mod
4303  10^6 since that epoch.
4304 \end_layout
4306 \begin_layout Subsection
4307 set_idle_timeout: Run function after timeout when emulator is idle
4308 \end_layout
4310 \begin_layout Itemize
4311 Syntax: none set_idle_timeout(number timeout)
4312 \end_layout
4314 \begin_layout Standard
4315 Set number of microseconds to block idle for.
4316  After this timeout has expired, on_idle() will be called once.
4317 \end_layout
4319 \begin_layout Subsection
4320 set_timer_timeout: Run function after timeout.
4321 \end_layout
4323 \begin_layout Itemize
4324 Syntax: none set_timer_timeout(number timeout)
4325 \end_layout
4327 \begin_layout Standard
4328 Set number of microseconds to block timer for.
4329  After this timeout has expired, on_timer() will be called once.
4330 \end_layout
4332 \begin_layout Subsection
4333 bus_address: Look up address in system bus.
4334 \end_layout
4336 \begin_layout Itemize
4337 Syntax: none bus_address(number bus_addr)
4338 \end_layout
4340 \begin_layout Standard
4341 Returns virtual address corresponding to specified address on system bus.
4342 \end_layout
4344 \begin_layout Subsection
4345 loopwrapper: Convert loop into callable function
4346 \end_layout
4348 \begin_layout Itemize
4349 Syntax: function loopwrapper(function fun, ...)
4350 \end_layout
4352 \begin_layout Standard
4353 Calls function <fun> with function and specified arguments.
4354  The function passed suspends execution until the function returned is called.
4355  Handy for linear flow control among multiple invocations of a hook.
4356  Example code:
4357 \end_layout
4359 \begin_layout LyX-Code
4360 on_paint = loopwrapper(function(wait)
4361 \begin_inset Separator latexpar
4362 \end_inset
4365 \end_layout
4367 \begin_deeper
4368 \begin_layout LyX-Code
4369 while true do
4370 \begin_inset Separator latexpar
4371 \end_inset
4374 \end_layout
4376 \begin_deeper
4377 \begin_layout LyX-Code
4378 gui.text(0, 0, 
4379 \begin_inset Quotes eld
4380 \end_inset
4382 Test!
4383 \begin_inset Quotes erd
4384 \end_inset
4387 \end_layout
4389 \begin_layout LyX-Code
4390 wait();
4391 \end_layout
4393 \end_deeper
4394 \begin_layout LyX-Code
4396 \end_layout
4398 \end_deeper
4399 \begin_layout LyX-Code
4400 end);
4401 \end_layout
4403 \begin_layout Subsection
4404 list_bindings: List keybindings
4405 \end_layout
4407 \begin_layout Itemize
4408 Syntax: table list_bindings([string cmd])
4409 \end_layout
4411 \begin_layout Standard
4412 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4413  If <cmd> is specified, the table is limited to that command.
4414  Also searches for controller keys.
4415 \end_layout
4417 \begin_layout Subsection
4418 get_alias: Get expansion of alias
4419 \end_layout
4421 \begin_layout Itemize
4422 Syntax: string get_alias(string aname)
4423 \end_layout
4425 \begin_layout Standard
4426 Get expansion of given alias <aname>.
4427 \end_layout
4429 \begin_layout Subsection
4430 set_alias: Set expansion of alias
4431 \end_layout
4433 \begin_layout Itemize
4434 Syntax: none set_alias(string aname, string value)
4435 \end_layout
4437 \begin_layout Standard
4438 Set expansion of given alias.
4439 \end_layout
4441 \begin_layout Subsection
4442 create_ibind: Create invese binding
4443 \end_layout
4445 \begin_layout Itemize
4446 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4447 \end_layout
4449 \begin_layout Standard
4450 Return object representing inverse binding with specified name <name> and
4451  specified command <cmd>.
4452 \end_layout
4454 \begin_layout Itemize
4455 Note: To create press/release commands, use aliases +foo and -foo .
4456 \end_layout
4458 \begin_layout Itemize
4459 Note: Keep the returned object around.
4460 \end_layout
4462 \begin_layout Subsection
4463 create_command: Create a command
4464 \end_layout
4466 \begin_layout Itemize
4467 Syntax: COMMANDBIND create_command(string name, function a)
4468 \end_layout
4470 \begin_layout Itemize
4471 Syntax: COMMANDBIND create_command(string name, function a, function b)
4472 \end_layout
4474 \begin_layout Standard
4475 Return object representing a command (pair).
4476 \end_layout
4478 \begin_layout Itemize
4479 If only one function is specied, the command is level-sensitive, <a> is
4480  callback.
4481 \end_layout
4483 \begin_layout Itemize
4484 If <b> is function, the function is edge-sensitive, <a> is positive edge
4485  callback and <b> is negative edge callback.
4486 \end_layout
4488 \begin_layout Itemize
4489 All callbacks get single argument: The parameters passed.
4490 \end_layout
4492 \begin_layout Itemize
4493 Keep the returned object around.
4494 \end_layout
4496 \begin_layout Subsection
4497 loadfile: Load Lua script
4498 \end_layout
4500 \begin_layout Itemize
4501 Syntax: function loadfile(string filename[, string base])
4502 \end_layout
4504 \begin_layout Standard
4505 Load lua script from <filename>, resolved relative to <base> (if empty,
4506  current directory).
4507 \end_layout
4509 \begin_layout Subsection
4510 dofile: Execute Lua script
4511 \end_layout
4513 \begin_layout Itemize
4514 Syntax: function dofile(string filename[, string base])
4515 \end_layout
4517 \begin_layout Standard
4518 Execute lua script from <filename>, resolved relative to <base> (if empty,
4519  current directory) and return all return values.
4520 \end_layout
4522 \begin_layout Subsection
4523 resolve_filename: Resolve name of file relative to another
4524 \end_layout
4526 \begin_layout Itemize
4527 Syntax: string resolve_filename(string filename[, string base])
4528 \end_layout
4530 \begin_layout Standard
4531 Resolve name of file <filename> relative to <base> and return the result.
4532 \end_layout
4534 \begin_layout Subsection
4535 render_queue_function: Return paint function for render queue
4536 \end_layout
4538 \begin_layout Itemize
4539 Syntax: function render_queue_function(RENDERQUEUE rq)
4540 \end_layout
4542 \begin_layout Standard
4543 Return function that renders render queue <rq>.
4544 \end_layout
4546 \begin_layout Itemize
4547 Handy for paint callback if one is using render queues updated in other
4548  callbacks.
4549  As in:
4550 \end_layout
4552 \begin_layout LyX-Code
4553 handle = callback.paint:register(render_queue_function(my_rq));
4554 \end_layout
4556 \begin_layout Subsection
4557 get_directory_contents: Get files in directory
4558 \end_layout
4560 \begin_layout Itemize
4561 Syntax: table get_directory_contents(string name[, string base[, string
4562  pattern]])
4563 \end_layout
4565 \begin_layout Standard
4566 Return array containg all files in specified directory <name> (relative
4567  to <base>).
4568  If <pattern> is specified, the filenames are matched to specified regex.
4569  The returned filenames inherit path.
4570 \end_layout
4572 \begin_layout Subsection
4573 get_file_type: Get type of file
4574 \end_layout
4576 \begin_layout Itemize
4577 Syntax: string/nil get_file_type(string path)
4578 \end_layout
4580 \begin_layout Standard
4581 Return type of file <path>.
4582  Currently possible return values are:
4583 \end_layout
4585 \begin_layout Itemize
4586 regular: regular file
4587 \end_layout
4589 \begin_layout Itemize
4590 directory: subdirectory
4591 \end_layout
4593 \begin_layout Itemize
4594 unknown: Exists, but type not known (not anything above).
4595 \end_layout
4597 \begin_layout Itemize
4598 <nil>: File does not exist.
4599 \end_layout
4601 \begin_layout Subsection
4602 identify_class: Identify class of object
4603 \end_layout
4605 \begin_layout Itemize
4606 Syntax: string identify_class(userdata object)
4607 \end_layout
4609 \begin_layout Standard
4610 Identifies the class of userdata <object>, if possible.
4611  If no identification is possible, returns 
4612 \begin_inset Quotes eld
4613 \end_inset
4615 unknown
4616 \begin_inset Quotes erd
4617 \end_inset
4620 \end_layout
4622 \begin_layout Subsection
4623 lookup_class: Lookup class by name
4624 \end_layout
4626 \begin_layout Itemize
4627 Syntax: classobj lookup_class(string name)
4628 \end_layout
4630 \begin_layout Standard
4631 Looks up class corresponding to <name>, if possible.
4632  If not found, returns nil.
4633  The classobj has following fields:
4634 \end_layout
4636 \begin_layout Itemize
4637 _static_methods: Return static method names
4638 \end_layout
4640 \begin_layout Itemize
4641 _class_methods: Return class method names
4642 \end_layout
4644 \begin_layout Itemize
4645 <static-function-name>: The specified static function.
4646 \end_layout
4648 \begin_layout Subsection
4649 all_classes: Get list of all classes
4650 \end_layout
4652 \begin_layout Itemize
4653 Syntax: string...
4654  all_classes()
4655 \end_layout
4657 \begin_layout Standard
4658 Get names of all classes available.
4659 \end_layout
4661 \begin_layout Subsection
4662 lsnes_features: Read feature flags
4663 \end_layout
4665 \begin_layout Itemize
4666 Syntax: boolean lsnes_features(string feature)
4667 \end_layout
4669 \begin_layout Standard
4670 Checks if feature <feature> is available, if it is, returns true, otherwise
4671  returns false.
4672  The following features are known:
4673 \end_layout
4675 \begin_layout Itemize
4676 text-halos: gui.text supports halos (takes halo color argument).
4677 \end_layout
4679 \begin_layout Subsection
4680 icnov: Class ICONV
4681 \end_layout
4683 \begin_layout Standard
4684 See class ICONV.
4685 \end_layout
4687 \begin_layout Subsection
4688 filereader: Class FILEREADER
4689 \end_layout
4691 \begin_layout Standard
4692 See class FILEREADER.
4693 \end_layout
4695 \begin_layout Standard
4696 \begin_inset Newpage pagebreak
4697 \end_inset
4700 \end_layout
4702 \begin_layout Section
4703 Table bit:
4704 \end_layout
4706 \begin_layout Standard
4707 Bitwise logical functions and related.
4708 \end_layout
4710 \begin_layout Subsection
4711 bit.none/bit.bnot: Bitwise none or NOT function
4712 \end_layout
4714 \begin_layout Itemize
4715 Syntax: number bit.none(number...)
4716 \end_layout
4718 \begin_layout Itemize
4719 Syntax: number bit.bnot(number...)
4720 \end_layout
4722 \begin_layout Standard
4723 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4724  arguments).
4725 \end_layout
4727 \begin_layout Subsection
4728 bit.any/bit.bor: Bitwise any or OR function
4729 \end_layout
4731 \begin_layout Itemize
4732 Syntax: number bit.any(number...)
4733 \end_layout
4735 \begin_layout Itemize
4736 Syntax: number bit.bor(number...)
4737 \end_layout
4739 \begin_layout Standard
4740 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4741 \end_layout
4743 \begin_layout Subsection
4744 bit.all/bit.band: Bitwise all or AND function
4745 \end_layout
4747 \begin_layout Itemize
4748 Syntax: number bit.all(number...)
4749 \end_layout
4751 \begin_layout Itemize
4752 Syntax: number bit.band(number...)
4753 \end_layout
4755 \begin_layout Standard
4756 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4758 \end_layout
4760 \begin_layout Subsection
4761 bit.parity/bit.bxor: Bitwise parity or XOR function
4762 \end_layout
4764 \begin_layout Itemize
4765 Syntax: number bit.parity(number...)
4766 \end_layout
4768 \begin_layout Itemize
4769 Syntax: number bit.bxor(number...)
4770 \end_layout
4772 \begin_layout Standard
4773 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4774  of the arguments).
4775 \end_layout
4777 \begin_layout Subsection
4778 bit.lrotate: Rotate a number left
4779 \end_layout
4781 \begin_layout Itemize
4782 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4783 \end_layout
4785 \begin_layout Standard
4786 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4787  1) places.
4788 \end_layout
4790 \begin_layout Subsection
4791 bit.rrotate: Rotate a number right
4792 \end_layout
4794 \begin_layout Itemize
4795 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4796 \end_layout
4798 \begin_layout Standard
4799 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4800  1) places.
4801 \end_layout
4803 \begin_layout Subsection
4804 bit.lshift: Shift a number left
4805 \end_layout
4807 \begin_layout Itemize
4808 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4809 \end_layout
4811 \begin_layout Standard
4812 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4813  1) places.
4814  The new bits are filled with zeroes.
4815 \end_layout
4817 \begin_layout Subsection
4818 bit.lrshift: Shift a number right (logical)
4819 \end_layout
4821 \begin_layout Itemize
4822 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4823 \end_layout
4825 \begin_layout Standard
4826 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4827  (default 1) places.
4828  The new bits are filled with zeroes.
4829 \end_layout
4831 \begin_layout Subsection
4832 bit.arshift: Shift a number right (arithmetic)
4833 \end_layout
4835 \begin_layout Itemize
4836 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4837 \end_layout
4839 \begin_layout Standard
4840 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4841  (default 1) places.
4842  The new bits are shifted in with copy of the high bit.
4843 \end_layout
4845 \begin_layout Subsection
4846 bit.extract: Extract/shuffle bits from number
4847 \end_layout
4849 \begin_layout Itemize
4850 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4851 \end_layout
4853 \begin_layout Standard
4854 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4855 \end_layout
4857 \begin_layout Itemize
4858 Note: Bit numbers up to 51 should work reliably (then things start falling
4859  apart due to double precision issues).
4860 \end_layout
4862 \begin_layout Itemize
4863 Note: There are two special bit positions, true and false, standing for
4864  always set bit and always clear bit.
4865 \end_layout
4867 \begin_layout Subsection
4868 bit.value: Construct number with specified bits set
4869 \end_layout
4871 \begin_layout Itemize
4872 Syntax: number bit.value([number bit1[, number bit2,...]])
4873 \end_layout
4875 \begin_layout Standard
4876 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4877  <bit2> places and so on.
4878  As special value, nil argument is no-op.
4879 \end_layout
4881 \begin_layout Subsection
4882 bit.test: Test if bit is set
4883 \end_layout
4885 \begin_layout Itemize
4886 Syntax: boolean bit.test(number a, number bit)
4887 \end_layout
4889 \begin_layout Standard
4890 Tests if bit <bit> is set in <a>.
4891  If it is set, returns true, otherwise false.
4892 \end_layout
4894 \begin_layout Subsection
4895 bit.testn: Test if bit is clear
4896 \end_layout
4898 \begin_layout Itemize
4899 Syntax: boolean bit.testn(number a, number bit)
4900 \end_layout
4902 \begin_layout Standard
4903 Tests if bit <bit> is set in <a>.
4904  If it is clear, returns true, otherwise false.
4905 \end_layout
4907 \begin_layout Subsection
4908 bit.test_any: Test if any bit is set
4909 \end_layout
4911 \begin_layout Itemize
4912 Syntax: boolean bit.test_any(number a, number b)
4913 \end_layout
4915 \begin_layout Standard
4916 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4917 \end_layout
4919 \begin_layout Subsection
4920 bit.test_all: Test if all bits are set
4921 \end_layout
4923 \begin_layout Itemize
4924 Syntax: boolean bit.test_all(number a, number b)
4925 \end_layout
4927 \begin_layout Standard
4928 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4929 \end_layout
4931 \begin_layout Subsection
4932 bit.popcount: Population count
4933 \end_layout
4935 \begin_layout Itemize
4936 Syntax: number bit.popcount(number a)
4937 \end_layout
4939 \begin_layout Standard
4940 Returns number of set bits in <a>.
4941 \end_layout
4943 \begin_layout Subsection
4944 bit.clshift: Chained left shift
4945 \end_layout
4947 \begin_layout Itemize
4948 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4949  bits]])
4950 \end_layout
4952 \begin_layout Standard
4953 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4954  numbers to be of specified number of bits <bits> (default 48).
4955 \end_layout
4957 \begin_layout Subsection
4958 bit.crshift: Chained right shift
4959 \end_layout
4961 \begin_layout Itemize
4962 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4963  bits]])
4964 \end_layout
4966 \begin_layout Standard
4967 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4968  assuming numbers to be of specified number of bits <bits> (default 48).
4969 \end_layout
4971 \begin_layout Subsection
4972 bit.flagdecode: Decode bitfield into flags
4973 \end_layout
4975 \begin_layout Itemize
4976 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4977  off]])
4978 \end_layout
4980 \begin_layout Standard
4981 Return string of length bits where ith character is ith character of on
4982  if bit i is on, otherwise ith character of off.
4983  Out of range reads give last character.
4984 \end_layout
4986 \begin_layout Itemize
4987 Note: <on> defaults to '*' if empty.
4988 \end_layout
4990 \begin_layout Itemize
4991 Note: <off> defaults to '-' if empty.
4992 \end_layout
4994 \begin_layout Subsection
4995 bit.rflagdecode: Decode bitfield into flags
4996 \end_layout
4998 \begin_layout Itemize
4999 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
5000  off]])
5001 \end_layout
5003 \begin_layout Standard
5004 Like bit.flagdecode, but outputs the string in the opposite order (most significa
5005 nt bit first).
5006 \end_layout
5008 \begin_layout Subsection
5009 bit.swap{,s}{,h,d,q}word: Swap word endian
5010 \end_layout
5012 \begin_layout Itemize
5013 Syntax: number bit.swapword(number n)
5014 \end_layout
5016 \begin_layout Itemize
5017 Syntax: number bit.swaphword(number n)
5018 \end_layout
5020 \begin_layout Itemize
5021 Syntax: number bit.swapdword(number n)
5022 \end_layout
5024 \begin_layout Itemize
5025 Syntax: number bit.swapqword(number n)
5026 \end_layout
5028 \begin_layout Itemize
5029 Syntax: number bit.swapsword(number n)
5030 \end_layout
5032 \begin_layout Itemize
5033 Syntax: number bit.swapshword(number n)
5034 \end_layout
5036 \begin_layout Itemize
5037 Syntax: number bit.swapsdword(number n)
5038 \end_layout
5040 \begin_layout Itemize
5041 Syntax: number bit.swapsqword(number n)
5042 \end_layout
5044 \begin_layout Standard
5045 Swap endianess of (un)signed integer <n>.
5046 \end_layout
5048 \begin_layout Subsection
5049 bit.compose: Compose multi-byte number
5050 \end_layout
5052 \begin_layout Itemize
5053 Syntax: number bit.compose(number n...)
5054 \end_layout
5056 \begin_layout Standard
5057 Return 
5058 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
5059 \end_inset
5062 \end_layout
5064 \begin_layout Subsection
5065 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
5066 \end_layout
5068 \begin_layout Itemize
5069 Syntax: number bit.binary_ld_<type>le(string str, number pos);
5070 \end_layout
5072 \begin_layout Itemize
5073 Syntax: number bit.binary_ld_<type>be(string str, number pos);
5074 \end_layout
5076 \begin_layout Standard
5077 Load little (*le) or big (*be) endian binary number from position <pos>
5078  of string <str>.
5079  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5080  double.
5081 \end_layout
5083 \begin_layout Subsection
5084 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
5085 \end_layout
5087 \begin_layout Itemize
5088 Syntax: string bit.binary_st_<type>le(number x);
5089 \end_layout
5091 \begin_layout Itemize
5092 Syntax: string bit.binary_st_<type>be(number x);
5093 \end_layout
5095 \begin_layout Standard
5096 Store specified number <x> as binary in string and return the result.
5097  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5098  double.
5099 \end_layout
5101 \begin_layout Subsection
5102 bit.quotent: Integer quotent
5103 \end_layout
5105 \begin_layout Itemize
5106 Syntax: number bit.quotent(number a, number b)
5107 \end_layout
5109 \begin_layout Standard
5110 Calculate quotent a/b.
5111 \end_layout
5113 \begin_layout Subsection
5114 bit.multidiv: Divide and split among multiple divisiors
5115 \end_layout
5117 \begin_layout Itemize
5118 Syntax: number...
5119  bit.multidiv(number v, number q...)
5120 \end_layout
5122 \begin_layout Standard
5123 Does the following steps:
5124 \end_layout
5126 \begin_layout Enumerate
5127 Set v' to <v>.
5128 \end_layout
5130 \begin_layout Enumerate
5131 For each <q> q:
5132 \begin_inset Separator latexpar
5133 \end_inset
5136 \end_layout
5138 \begin_deeper
5139 \begin_layout Enumerate
5140 Calculate quotent(v'/q) and add that to numbers returned.
5141 \end_layout
5143 \begin_layout Enumerate
5144 v' <- remainder(v'/q)
5145 \end_layout
5147 \end_deeper
5148 \begin_layout Enumerate
5149 Add v' to numbers returned.
5150 \end_layout
5152 \begin_layout Standard
5153 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
5154  at each step.
5155  <v> may be floating point, <q>s are integers.
5156 \end_layout
5158 \begin_layout Itemize
5159 E.g.
5160  bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
5161 \end_layout
5163 \begin_layout Itemize
5164 E.g.
5165  bit.multidiv(a, b) calculates quotent and remainder of a/b.
5166 \end_layout
5168 \begin_layout Subsection
5169 bit.mul32: 32-bit multiply
5170 \end_layout
5172 \begin_layout Itemize
5173 Syntax: number, number bit.mul32(number a, number b)
5174 \end_layout
5176 \begin_layout Standard
5177 Multiply 32-bit numbers <a> and <b>.
5178  The first return value is low 32 bits of result, the second is high 32
5179  bits.
5180 \end_layout
5182 \begin_layout Subsection
5183 bit.fextract: Extract bit field
5184 \end_layout
5186 \begin_layout Itemize
5187 Syntax: number bit.fextract(number value, number shift, number width)
5188 \end_layout
5190 \begin_layout Standard
5191 Extract <width> bits starting from bit <shift> from number <value>.
5192  This is more compact way to write 
5193 \begin_inset Formula $\left(value\gg shift\right)\&\left(2^{width}-1\right)$
5194 \end_inset
5197 \end_layout
5199 \begin_layout Subsection
5200 bit.bfields: Split number into bit fields
5201 \end_layout
5203 \begin_layout Itemize
5204 Syntax: number...
5205  bit.bfields(number v, number q...)
5206 \end_layout
5208 \begin_layout Standard
5209 Split a number <v> into bitfields of <q> bits (in order, from least significant
5210  towards more significant bits), with no padding in between.
5211 \end_layout
5213 \begin_layout Itemize
5215  number of form 0 bbbbb ggggg rrrrr can be decoded to its component fields
5216  using r,g,b = bit.bfields(v, 5, 5, 5).
5218 \end_layout
5220 \begin_layout Itemize
5222  number of form x yyyyyyy w zzzzzzz can be decode to its component fields
5223  using z, w, y, x = bit.bfields(v, 7, 1, 7, 1).
5224 \end_layout
5226 \begin_layout Standard
5227 \begin_inset Newpage pagebreak
5228 \end_inset
5231 \end_layout
5233 \begin_layout Section
5234 Table classes:
5235 \end_layout
5237 \begin_layout Subsection
5238 classes.<foo>: The classobj for class <foo>
5239 \end_layout
5241 \begin_layout Itemize
5242 Syntax: classes.<foo>
5243 \end_layout
5245 \begin_layout Standard
5246 The classobj for class <foo>.
5247 \end_layout
5249 \begin_layout Subsection
5250 classes.<foo>._static_methods: Enumerate static methods
5251 \end_layout
5253 \begin_layout Itemize
5254 Syntax: string...
5255  classes.<foo>._static_methods()
5256 \end_layout
5258 \begin_layout Standard
5259 Returns all static methods of <foo> as strings.
5260 \end_layout
5262 \begin_layout Subsection
5263 classes.<foo>._class_methods: Enumerate static methods
5264 \end_layout
5266 \begin_layout Itemize
5267 Syntax: string...
5268  classes.<foo>._class_methods()
5269 \end_layout
5271 \begin_layout Standard
5272 Returns all class methods of <foo> as strings.
5273 \end_layout
5275 \begin_layout Subsection
5276 classes.<foo>.<bar>: Static method
5277 \end_layout
5279 \begin_layout Itemize
5280 Syntax: variable classes.<foo>.<bar>(variable...)
5281 \end_layout
5283 \begin_layout Standard
5284 Invokes static method <bar> of class <foo>.
5285 \end_layout
5287 \begin_layout Section
5288 Table gui:
5289 \end_layout
5291 \begin_layout Subsection
5292 gui.resolution: Get current resolution
5293 \end_layout
5295 \begin_layout Itemize
5296 Syntax: (number, number) gui.resolution()
5297 \end_layout
5299 \begin_layout Standard
5300 Returns 2-tuple (hresolution, vresolution).
5301 \end_layout
5303 \begin_layout Subsection
5304 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
5305 \end_layout
5307 \begin_layout Itemize
5308 Syntax: number gui.left_gap(number gap)
5309 \end_layout
5311 \begin_layout Itemize
5312 Syntax: number gui.right_gap(number gap)
5313 \end_layout
5315 \begin_layout Itemize
5316 Syntax: number gui.top_gap(number gap)
5317 \end_layout
5319 \begin_layout Itemize
5320 Syntax: number gui.bottom_gap(number gap)
5321 \end_layout
5323 \begin_layout Standard
5324 Set the specified edge gap to specified value <gap> (max gap is 8191).
5325  If successful, old gap is returned.
5326 \end_layout
5328 \begin_layout Subsection
5329 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
5330  Adjust edge gaps
5331 \end_layout
5333 \begin_layout Itemize
5334 Syntax: number gui.delta_left_gap(number dgap)
5335 \end_layout
5337 \begin_layout Itemize
5338 Syntax: number gui.delta_right_gap(number dgap)
5339 \end_layout
5341 \begin_layout Itemize
5342 Syntax: number gui.delta_top_gap(number dgap)
5343 \end_layout
5345 \begin_layout Itemize
5346 Syntax: number gui.delta_bottom_gap(number dgap)
5347 \end_layout
5349 \begin_layout Standard
5350 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
5351  and return the old gap (returns nothing on error).
5352 \end_layout
5354 \begin_layout Subsection
5355 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
5356 \end_layout
5358 \begin_layout Itemize
5359 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
5360  bgc[, number hlc]]])
5361 \end_layout
5363 \begin_layout Itemize
5364 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
5365  bgc[, number hlc]]])
5366 \end_layout
5368 \begin_layout Itemize
5369 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
5370  bgc[, number hlc]]])
5371 \end_layout
5373 \begin_layout Itemize
5374 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
5375  bgc[, number hlc]]])
5376 \end_layout
5378 \begin_layout Standard
5379 Draw specified text on the GUI (each character cell is 8 or 16 wide and
5380  16 high).
5381  Parameters:
5382 \end_layout
5384 \begin_layout Itemize
5385 x: X-coordinate to start the drawing from (and x-coordinate at begining
5386  of the lines).
5387 \end_layout
5389 \begin_layout Itemize
5390 y: Y-coordinate to start the drawing from.
5391 \end_layout
5393 \begin_layout Itemize
5394 text: The text to draw.
5395 \end_layout
5397 \begin_layout Itemize
5398 fgc: Text color (default is 0xFFFFFF (white))
5399 \end_layout
5401 \begin_layout Itemize
5402 bgc: Background color (default is -1 (transparent))
5403 \end_layout
5405 \begin_layout Itemize
5406 hlc: Halo color (default is -1 (transparent))
5407 \end_layout
5409 \begin_layout Standard
5410 Note: The H variants draw at double width and V variants draw at double
5411  height.
5412  Halo thickness is always 1 and is not doubled.
5413 \end_layout
5415 \begin_layout Subsection
5416 gui.rectangle: Draw a rectangle
5417 \end_layout
5419 \begin_layout Itemize
5420 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5421  number thickness[, number outline[, number fill]]])
5422 \end_layout
5424 \begin_layout Standard
5425 Draw rectangle on the GUI.
5426  Parameters:
5427 \end_layout
5429 \begin_layout Itemize
5430 x: X-coordinate of left edge.
5431 \end_layout
5433 \begin_layout Itemize
5434 y: Y-coordinate of upper edge.
5435 \end_layout
5437 \begin_layout Itemize
5438 width: Width of rectangle.
5439 \end_layout
5441 \begin_layout Itemize
5442 height: Height of rectangle.
5443 \end_layout
5445 \begin_layout Itemize
5446 thickness: Thickness of outline (default is 1).
5447 \end_layout
5449 \begin_layout Itemize
5450 outline: Color of outline (default is 0xFFFFFF (white))
5451 \end_layout
5453 \begin_layout Itemize
5454 fill: Color of fill (default is -1 (transparent))
5455 \end_layout
5457 \begin_layout Subsection
5458 gui.solidrectangle: Draw a solid rectangle
5459 \end_layout
5461 \begin_layout Itemize
5462 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5463  number color])
5464 \end_layout
5466 \begin_layout Standard
5467 Draw solid rectangle on the GUI.
5468  Parameters:
5469 \end_layout
5471 \begin_layout Itemize
5472 x: X-coordinate of left edge.
5473 \end_layout
5475 \begin_layout Itemize
5476 y: Y-coordinate of upper edge.
5477 \end_layout
5479 \begin_layout Itemize
5480 width: Width of rectangle.
5481 \end_layout
5483 \begin_layout Itemize
5484 height: Height of rectangle.
5485 \end_layout
5487 \begin_layout Itemize
5488 color: Color of rectangle (default is 0xFFFFFF (white))
5489 \end_layout
5491 \begin_layout Subsection
5492 gui.box: Draw a 3D-effect box
5493 \end_layout
5495 \begin_layout Itemize
5496 Syntax: none gui.box(number x, number y, number width, number height[, number
5497  thickness[, number outline1[,number outline2[, number fill]]]])
5498 \end_layout
5500 \begin_layout Standard
5501 Draw rectangle with 3D effect on the GUI.
5502  Parameters:
5503 \end_layout
5505 \begin_layout Itemize
5506 x: X-coordinate of left edge.
5507 \end_layout
5509 \begin_layout Itemize
5510 y: Y-coordinate of upper edge.
5511 \end_layout
5513 \begin_layout Itemize
5514 width: Width of rectangle.
5515 \end_layout
5517 \begin_layout Itemize
5518 height: Height of rectangle.
5519 \end_layout
5521 \begin_layout Itemize
5522 thickness: Thickness of outline (default is 1).
5523 \end_layout
5525 \begin_layout Itemize
5526 outline1: First color of outline (default is 0xFFFFFF (white))
5527 \end_layout
5529 \begin_layout Itemize
5530 outline2: First color of outline (default is 0x808080 (dark gray))
5531 \end_layout
5533 \begin_layout Itemize
5534 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5535 \end_layout
5537 \begin_layout Subsection
5538 gui.pixel: Draw a single pixel
5539 \end_layout
5541 \begin_layout Itemize
5542 Syntax: none gui.pixel(number x, number y[, number color])
5543 \end_layout
5545 \begin_layout Standard
5546 Draw one pixel on the GUI.
5547  Parameters:
5548 \end_layout
5550 \begin_layout Itemize
5551 x: X-coordinate of the pixel
5552 \end_layout
5554 \begin_layout Itemize
5555 y: Y-coordinate of the pixel
5556 \end_layout
5558 \begin_layout Itemize
5559 color: Color of the pixel (default is 0xFFFFFF (white))
5560 \end_layout
5562 \begin_layout Subsection
5563 gui.crosshair: Draw a crosshair
5564 \end_layout
5566 \begin_layout Itemize
5567 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5568 \end_layout
5570 \begin_layout Standard
5571 Draw a crosshair.
5572  Parameters:
5573 \end_layout
5575 \begin_layout Itemize
5576 x: X-coordinate of the crosshair
5577 \end_layout
5579 \begin_layout Itemize
5580 y: Y-coordinate of the crosshair
5581 \end_layout
5583 \begin_layout Itemize
5584 length: Length of the crosshair lines (default 10).
5585 \end_layout
5587 \begin_layout Itemize
5588 color: Color of the crosshair (default is 0xFFFFFF (white))
5589 \end_layout
5591 \begin_layout Subsection
5592 gui.line: Draw a line
5593 \end_layout
5595 \begin_layout Itemize
5596 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5597  color])
5598 \end_layout
5600 \begin_layout Standard
5601 Draw a thin line.
5602  Parameters:
5603 \end_layout
5605 \begin_layout Itemize
5606 x1: X-coordinate of one end.
5607 \end_layout
5609 \begin_layout Itemize
5610 y1: Y-coordinate of one end.
5611 \end_layout
5613 \begin_layout Itemize
5614 x2: X-coordinate of the other end.
5615 \end_layout
5617 \begin_layout Itemize
5618 y2: Y-coordinate of the other end.
5619 \end_layout
5621 \begin_layout Itemize
5622 color: Color of the line (default is 0xFFFFFF (white)).
5623 \end_layout
5625 \begin_layout Subsection
5626 gui.circle: Draw a (filled) circle
5627 \end_layout
5629 \begin_layout Itemize
5630 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5631  border[, number fil]]])
5632 \end_layout
5634 \begin_layout Standard
5635 Draw a circle.
5636  Parameters.
5637 \end_layout
5639 \begin_layout Itemize
5640 x: X-coordinate of the center
5641 \end_layout
5643 \begin_layout Itemize
5644 y: Y-coordinate of the center
5645 \end_layout
5647 \begin_layout Itemize
5648 r: The radius of the circle
5649 \end_layout
5651 \begin_layout Itemize
5652 thick: Border thickness
5653 \end_layout
5655 \begin_layout Itemize
5656 border: Border color (default is 0xFFFFFF (white))
5657 \end_layout
5659 \begin_layout Itemize
5660 fill: Fill color (default is -1 (transparent)).
5661 \end_layout
5663 \begin_layout Subsection
5664 gui.repaint: Arrange a repaint
5665 \end_layout
5667 \begin_layout Itemize
5668 Syntax: none gui.repaint()
5669 \end_layout
5671 \begin_layout Standard
5672 Request on_repaint() to happen as soon as possible.
5673 \end_layout
5675 \begin_layout Subsection
5676 gui.subframe_update: Enable/Disable subframe updates
5677 \end_layout
5679 \begin_layout Itemize
5680 Syntax: none gui.subframe_update(boolean on)
5681 \end_layout
5683 \begin_layout Standard
5684 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5685  or not happen (<on>=false).
5686 \end_layout
5688 \begin_layout Subsection
5689 gui.screenshot: Write a screenshot
5690 \end_layout
5692 \begin_layout Itemize
5693 Syntax: none gui.screenshot(string filename)
5694 \end_layout
5696 \begin_layout Standard
5697 Write PNG screenshot of the current frame (no drawings) to specified file
5698  <filename>.
5699 \end_layout
5701 \begin_layout Subsection
5702 gui.screenshot_bitmap: Write a screenshot to bitmap
5703 \end_layout
5705 \begin_layout Itemize
5706 Syntax: DBITMAP gui.screenshot_bitmap()
5707 \end_layout
5709 \begin_layout Standard
5710 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5711  the result.
5712 \end_layout
5714 \begin_layout Subsection
5715 gui.color: Compose a color.
5716 \end_layout
5718 \begin_layout Itemize
5719 Syntax: number gui.color(number r, number g, number b[, number a])
5720 \end_layout
5722 \begin_layout Itemize
5723 Syntax: number gui.color(string c)
5724 \end_layout
5726 \begin_layout Standard
5727 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5728 , each component in scale 0-255.
5729  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5730  fully opaque).
5731  The default alpha is 256.
5732 \end_layout
5734 \begin_layout Standard
5735 The form taking a string returns color corresponding color name.
5736 \end_layout
5738 \begin_layout Subsection
5739 gui.status: Set status variable
5740 \end_layout
5742 \begin_layout Itemize
5743 Syntax: none gui.status(string name, string value)
5744 \end_layout
5746 \begin_layout Standard
5747 Set status field 
5748 \begin_inset Quotes eld
5749 \end_inset
5751 L[<name>]
5752 \begin_inset Quotes erd
5753 \end_inset
5755  to <value> in status area.
5756 \end_layout
5758 \begin_layout Subsection
5759 gui.rainbow: Rainbow color calculation
5760 \end_layout
5762 \begin_layout Itemize
5763 Syntax: number gui.rainbow(number step, number steps[, number color])
5764 \end_layout
5766 \begin_layout Standard
5767 Perform hue rotation of color <color> (default bright red), by <step> steps.
5768  The number of steps per full rotation is given by absolute value of <steps>.
5769 \end_layout
5771 \begin_layout Standard
5772 If <step> is negative, the rotation will be counterclockwise.
5773 \end_layout
5775 \begin_layout Subsection
5776 gui.kill_frame: Kill video frame and associated sound
5777 \end_layout
5779 \begin_layout Itemize
5780 Syntax: none gui.kill_frame()
5781 \end_layout
5783 \begin_layout Standard
5784 Kills the currently dumped video frame + the associated sound.
5785  Only valid in on_video callback.
5786 \end_layout
5788 \begin_layout Subsection
5789 gui.set_video_scale: Set video frame scale
5790 \end_layout
5792 \begin_layout Itemize
5793 Syntax: none gui.set_video_scale(number h, number v)
5794 \end_layout
5796 \begin_layout Standard
5797 Sets the scale factors of current frame to <h>x<v>.
5798  Only valid in on_video callback.
5799 \end_layout
5801 \begin_layout Subsection
5802 gui.arrow: Draw an arrow
5803 \end_layout
5805 \begin_layout Itemize
5806 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5807  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5809 \end_layout
5811 \begin_layout Standard
5812 Draws an arrow using color <color>.
5813  The tip of arrow is at (<x>, <y>).
5814  Other parameters:
5815 \end_layout
5817 \begin_layout Enumerate
5818 <length>: The length of arrow tail.
5819 \end_layout
5821 \begin_layout Enumerate
5822 <hwidth>: The width of arrow head.
5823  Should be odd.
5824 \end_layout
5826 \begin_layout Enumerate
5827 <direction>: Direction of arrow.
5828  0 is to right, +1 rotates 45 degrees counterclockwise.
5829 \end_layout
5831 \begin_layout Enumerate
5832 <fill>: If true, fill the arrow head.
5833  Default false.
5834 \end_layout
5836 \begin_layout Enumerate
5837 <twidth>: Tail width.
5838  Should be odd.
5839  Default 1.
5840 \end_layout
5842 \begin_layout Enumerate
5843 <hthick>: Head thickness (only used if <fill> is false).
5844  Default is <twidth>.
5845 \end_layout
5847 \begin_layout Subsection
5848 gui.tiled_bitmap: Class TILEMAP
5849 \end_layout
5851 \begin_layout Standard
5852 See class TILEMAP.
5853 \end_layout
5855 \begin_layout Subsection
5856 gui.palette: Class PALETTE
5857 \end_layout
5859 \begin_layout Standard
5860 See class PALETTE.
5861 \end_layout
5863 \begin_layout Subsection
5864 gui.bitmap: Class BITMAP
5865 \end_layout
5867 \begin_layout Standard
5868 See class BITMAP.
5869 \end_layout
5871 \begin_layout Subsection
5872 gui.dbitmap: Class DBITMAP
5873 \end_layout
5875 \begin_layout Standard
5876 See class DBITMAP.
5877 \end_layout
5879 \begin_layout Subsection
5880 gui.font: Class CUSTOMFONT
5881 \end_layout
5883 \begin_layout Standard
5884 See class CUSTOMFONT.
5885 \end_layout
5887 \begin_layout Subsection
5888 gui.renderctx: Class RENDERCTX
5889 \end_layout
5891 \begin_layout Standard
5892 See class RENDERCTX.
5893 \end_layout
5895 \begin_layout Subsection
5896 gui.image: Class IMAGELOADER
5897 \end_layout
5899 \begin_layout Standard
5900 See class IMAGELOADER.
5901 \end_layout
5903 \begin_layout Subsection
5904 gui.get_runmode: Get current emulator mode
5905 \end_layout
5907 \begin_layout Itemize
5908 Syntax: string gui.get_runmode()
5909 \end_layout
5911 \begin_layout Standard
5912 Gets the current emulator runmode.
5913  The possible ones are:
5914 \end_layout
5916 \begin_layout Itemize
5917 quit: Emulator is quitting.
5918 \end_layout
5920 \begin_layout Itemize
5921 normal: Emulator is running emulation
5922 \end_layout
5924 \begin_layout Itemize
5925 load: Emulator is loading a movie/savestate
5926 \end_layout
5928 \begin_layout Itemize
5929 advance_frame: Emulator is doing frame advance
5930 \end_layout
5932 \begin_layout Itemize
5933 advance_subframe: Emulator is doing subframe advance
5934 \end_layout
5936 \begin_layout Itemize
5937 skiplag: Emulator is skipping lag frames
5938 \end_layout
5940 \begin_layout Itemize
5941 skiplag_pending: Emulator will start skipping lag frames next frame
5942 \end_layout
5944 \begin_layout Itemize
5945 pause: Emulator is paused
5946 \end_layout
5948 \begin_layout Itemize
5949 pause_break: Emulator is paused at breakpoint
5950 \end_layout
5952 \begin_layout Itemize
5953 corrupt: Emulator can't run because corrupt emulation state
5954 \end_layout
5956 \begin_layout Itemize
5957 unknown: Unknown state (should not happen).
5958 \end_layout
5960 \begin_layout Standard
5961 \begin_inset Newpage pagebreak
5962 \end_inset
5965 \end_layout
5967 \begin_layout Section
5968 table input
5969 \end_layout
5971 \begin_layout Standard
5972 Input handling.
5973  Functions manipulating input are only available in on_input callback.
5974 \end_layout
5976 \begin_layout Subsection
5977 input.get: Read controller button/axis (deprecated)
5978 \end_layout
5980 \begin_layout Itemize
5981 Syntax: number input.get(number controller, number index)
5982 \end_layout
5984 \begin_layout Standard
5985 Read the specified index <index> (zero-based) from specified controller
5986  <controller> (zero-based).
5988 \end_layout
5990 \begin_layout Subsection
5991 input.set: Write controller button/axis (deprecated)
5992 \end_layout
5994 \begin_layout Itemize
5995 Syntax: none input.set(number controller, number index, number value)
5996 \end_layout
5998 \begin_layout Standard
5999 Write the specified index <index> (zero-based) from specified controller
6000  <controller> (zero-based), storing value <value>.
6001 \end_layout
6003 \begin_layout Subsection
6004 input.get2: Read controller button/axis
6005 \end_layout
6007 \begin_layout Itemize
6008 Syntax: number input.get2(number port, number controller, number index)
6009 \end_layout
6011 \begin_layout Standard
6012 Read the specified input tuple.
6013  Port 0 is system port.
6014 \end_layout
6016 \begin_layout Subsection
6017 input.set2: Write controller button/axis
6018 \end_layout
6020 \begin_layout Itemize
6021 Syntax: input.set2(number port, number controller, number index, number value)
6022 \end_layout
6024 \begin_layout Standard
6025 Write the specified input tuple.
6026  Port 0 is system port.
6027 \end_layout
6029 \begin_layout Subsection
6030 input.lcid_to_pcid2: Look up logical controller
6031 \end_layout
6033 \begin_layout Itemize
6034 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
6035 \end_layout
6037 \begin_layout Standard
6038 Look up physical pcid pair (port, controller) corresponding to specified
6039  logical controller (1-based).
6040  Returns nothing if controller does not exist.
6041 \end_layout
6043 \begin_layout Subsection
6044 input.port_type: Look up port type
6045 \end_layout
6047 \begin_layout Itemize
6048 Syntax: string input.port_type(number port)
6049 \end_layout
6051 \begin_layout Standard
6052 Return type of specified port.
6053 \end_layout
6055 \begin_layout Subsection
6056 input.controller_info: Get information about controller
6057 \end_layout
6059 \begin_layout Itemize
6060 Syntax: table input.controller_info(number port, number controller)
6061 \end_layout
6063 \begin_layout Standard
6064 Get controller info for specified controller.
6065  If controller does not exist, returns nil.
6066  Otherwise returns a table with following fields:
6067 \end_layout
6069 \begin_layout Itemize
6070 type (string): Type of the controller.
6071 \end_layout
6073 \begin_layout Itemize
6074 class (string): Class of the controller.
6075 \end_layout
6077 \begin_layout Itemize
6078 classnum (number): Number of the controller within its class (1-based)
6079 \end_layout
6081 \begin_layout Itemize
6082 lcid (number): Logical controller number of the controller.
6083 \end_layout
6085 \begin_layout Itemize
6086 button_count (number): Number of buttons on controller
6087 \end_layout
6089 \begin_layout Itemize
6090 buttons (array): Array of following info about each button:
6091 \begin_inset Separator latexpar
6092 \end_inset
6095 \end_layout
6097 \begin_deeper
6098 \begin_layout Itemize
6099 type (string): Type of button.
6100  Currently one of 
6101 \begin_inset Quotes eld
6102 \end_inset
6104 null
6105 \begin_inset Quotes erd
6106 \end_inset
6109 \begin_inset Quotes eld
6110 \end_inset
6112 button
6113 \begin_inset Quotes erd
6114 \end_inset
6117 \begin_inset Quotes eld
6118 \end_inset
6120 axis
6121 \begin_inset Quotes erd
6122 \end_inset
6125 \begin_inset Quotes eld
6126 \end_inset
6128 raxis
6129 \begin_inset Quotes erd
6130 \end_inset
6133 \end_layout
6135 \begin_layout Itemize
6136 name (string): Name of button.
6137 \end_layout
6139 \begin_layout Itemize
6140 symbol (string): Symbol of button.
6141  Only present for type 
6142 \begin_inset Quotes eld
6143 \end_inset
6145 button
6146 \begin_inset Quotes erd
6147 \end_inset
6150 \end_layout
6152 \begin_layout Itemize
6153 hidden (boolean): True if hidden button.
6155 \end_layout
6157 \end_deeper
6158 \begin_layout Subsection
6159 input.veto_button: Veto a button press
6160 \end_layout
6162 \begin_layout Itemize
6163 Syntax: none input.veto_button()
6164 \end_layout
6166 \begin_layout Standard
6167 Signals that the button event should be vetoed.
6168  Only valid in on_button callback.
6169 \end_layout
6171 \begin_layout Subsection
6172 input.geta: Get all buttons for controller (deprecated)
6173 \end_layout
6175 \begin_layout Itemize
6176 Syntax: (number, number...) input.geta(number controller)
6177 \end_layout
6179 \begin_layout Standard
6180 Get input state for entiere controller.
6181  Returns n return values.
6182 \end_layout
6184 \begin_layout Itemize
6185 1st return value: Bitmask: bit i is set if i:th index is nonzero
6186 \end_layout
6188 \begin_layout Itemize
6189 2nd- return value: value of i:th index.
6190 \end_layout
6192 \begin_layout Subsection
6193 input.seta: Set all buttons for controller (deprecated)
6194 \end_layout
6196 \begin_layout Itemize
6197 Syntax: none input.seta(number controller, number bitmask, number args...)
6198 \end_layout
6200 \begin_layout Standard
6201 Set state for entiere controller.
6202  args is up to N values for indices (overriding values in bitmask if specified).
6203 \end_layout
6205 \begin_layout Subsection
6206 input.controllertype: Get controller type (deprecated)
6207 \end_layout
6209 \begin_layout Itemize
6210 syntax: string input.controllertype(number controller)
6211 \end_layout
6213 \begin_layout Standard
6214 Get the type of controller as string.
6215 \end_layout
6217 \begin_layout Subsection
6218 input.reset: Execute (delayed) reset
6219 \end_layout
6221 \begin_layout Itemize
6222 Syntax: none input.reset([number cycles])
6223 \end_layout
6225 \begin_layout Standard
6226 Execute reset.
6227  If <cycles> is greater than zero, do delayed reset.
6228  0 (or no value) causes immediate reset.
6229 \end_layout
6231 \begin_layout Itemize
6232 Note: Only available with subframe flag false.
6233 \end_layout
6235 \begin_layout Subsection
6236 input.raw: Return raw input data
6237 \end_layout
6239 \begin_layout Itemize
6240 Syntax: table input.raw()
6241 \end_layout
6243 \begin_layout Standard
6244 Returns table of tables of all available keys and axes.
6245  The first table is indexed by key name (platform-dependent!), and the inner
6246  table has the following fields:
6247 \end_layout
6249 \begin_layout Itemize
6250 value: Last reported value for control
6251 \begin_inset Separator latexpar
6252 \end_inset
6255 \end_layout
6257 \begin_deeper
6258 \begin_layout Itemize
6259 For keys: 1 for pressed, 0 for released.
6260 \end_layout
6262 \begin_layout Itemize
6263 For axes: -32767...32767.
6264 \end_layout
6266 \begin_layout Itemize
6267 For presure-sensitive buttons: 0...32767.
6268 \end_layout
6270 \begin_layout Itemize
6271 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
6272 \end_layout
6274 \begin_layout Itemize
6275 For mouse: Coordinates relative to game area.
6276 \end_layout
6278 \end_deeper
6279 \begin_layout Itemize
6280 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
6281 \end_layout
6283 \begin_layout Subsection
6284 input.keyhook: Hook a key
6285 \end_layout
6287 \begin_layout Itemize
6288 Syntax: none input.keyhook(string key, boolean state)
6289 \end_layout
6291 \begin_layout Standard
6292 Requests that keyhook events to be sent for key <key> (<state>=true) or
6293  not sent (<state>=false).
6294 \end_layout
6296 \begin_layout Subsection
6297 input.joyget: Get controls for controller
6298 \end_layout
6300 \begin_layout Itemize
6301 Syntax: table input.joyget(number logical)
6302 \end_layout
6304 \begin_layout Standard
6305 Returns table for current controls for specified logical controller <logical>.
6306  The names of fields vary by controller type.
6307 \end_layout
6309 \begin_layout Itemize
6310 The buttons have the same name as those are referred to in other contexts
6311  in the emulator
6312 \end_layout
6314 \begin_layout Itemize
6315 The analog axes are usually 
6316 \begin_inset Quotes eld
6317 \end_inset
6319 xaxis
6320 \begin_inset Quotes erd
6321 \end_inset
6323  and 
6324 \begin_inset Quotes eld
6325 \end_inset
6327 yaxis
6328 \begin_inset Quotes erd
6329 \end_inset
6332 \end_layout
6334 \begin_layout Itemize
6335 Each field is numeric or boolean depending on axis/button.
6336 \end_layout
6338 \begin_layout Subsection
6339 input.joyset: Set controls for controller
6340 \end_layout
6342 \begin_layout Itemize
6343 Syntax: none input.joyset(number controller, table controls)
6344 \end_layout
6346 \begin_layout Standard
6347 Set the the state of specified controller to values specified in specified
6348  table.
6349 \end_layout
6351 \begin_layout Itemize
6352 Each field can be boolean or number.
6353 \end_layout
6355 \begin_layout Itemize
6356 Also, buttons allow strings, which cause value to be inverted.
6357 \end_layout
6359 \begin_layout Subsection
6360 input.lcid_to_pcid: Look up logical controller (deprecated)
6361 \end_layout
6363 \begin_layout Itemize
6364 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
6365 \end_layout
6367 \begin_layout Standard
6368 Returns the legacy pcid for controller (or false if there isn't one), followed
6369  by pcid pair.
6370  Returns nothing if controller does not exist.
6371 \end_layout
6373 \begin_layout Standard
6374 \begin_inset Newpage pagebreak
6375 \end_inset
6378 \end_layout
6380 \begin_layout Section
6381 Table keyboard
6382 \end_layout
6384 \begin_layout Standard
6385 Various keybinding-related functions
6386 \end_layout
6388 \begin_layout Subsection
6389 keyboard.bind: Bind a key
6390 \end_layout
6392 \begin_layout Itemize
6393 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
6394 \end_layout
6396 \begin_layout Standard
6397 Bind specified key with specified modifers to specified command.
6398 \end_layout
6400 \begin_layout Subsection
6401 keyboard.unbind: Unbind a key
6402 \end_layout
6404 \begin_layout Itemize
6405 Syntax: none keyboard.unbind(string mod, string mask, string key)
6406 \end_layout
6408 \begin_layout Standard
6409 Unbind specified key with specified modifers.
6410 \end_layout
6412 \begin_layout Subsection
6413 keyboard.alias: Set alias expansion
6414 \end_layout
6416 \begin_layout Itemize
6417 Syntax: none keyboard.alias(string alias, string expansion)
6418 \end_layout
6420 \begin_layout Standard
6421 Set expansion of given command.
6422 \end_layout
6424 \begin_layout Standard
6425 \begin_inset Newpage pagebreak
6426 \end_inset
6429 \end_layout
6431 \begin_layout Section
6432 Table subtitle
6433 \end_layout
6435 \begin_layout Standard
6436 Subtitle handling
6437 \end_layout
6439 \begin_layout Subsection
6440 subtitle.byindex: Look up start and length of subtitle by index
6441 \end_layout
6443 \begin_layout Itemize
6444 Syntax: (number, number) subtitle.byindex(number i)
6445 \end_layout
6447 \begin_layout Standard
6448 Read the frame and length of ith subtitle.
6449  Returns nothing if not present.
6450 \end_layout
6452 \begin_layout Subsection
6453 subtitle.set: Write a subtitle
6454 \end_layout
6456 \begin_layout Itemize
6457 Syntax: none subtitle.set(number f, number l, string txt)
6458 \end_layout
6460 \begin_layout Standard
6461 Set the text of subtitle.
6462 \end_layout
6464 \begin_layout Subsection
6465 subtitle.get: Read a subtitle
6466 \end_layout
6468 \begin_layout Itemize
6469 Syntax: string subtitle.get(number f, number l)
6470 \end_layout
6472 \begin_layout Standard
6473 Get the text of subtitle.
6474 \end_layout
6476 \begin_layout Subsection
6477 subtitle.delete: Delete a subtitle
6478 \end_layout
6480 \begin_layout Itemize
6481 Syntax: none subtitle.delete(number f, number l)
6482 \end_layout
6484 \begin_layout Standard
6485 Delete specified subtitle.
6486 \end_layout
6488 \begin_layout Standard
6489 \begin_inset Newpage pagebreak
6490 \end_inset
6493 \end_layout
6495 \begin_layout Section
6496 Table hostmemory
6497 \end_layout
6499 \begin_layout Standard
6500 Host memory handling (extra memory saved to savestates).
6501  Host memory starts empty.
6502 \end_layout
6504 \begin_layout Itemize
6505 Reads out of range return false.
6506 \end_layout
6508 \begin_layout Itemize
6509 Writes out of range extend the memory.
6510 \end_layout
6512 \begin_layout Subsection
6513 hostmemory.read: Read byte from host memory
6514 \end_layout
6516 \begin_layout Itemize
6517 Syntax: number hostmemory.read(number address)
6518 \end_layout
6520 \begin_layout Standard
6521 Reads byte from hostmemory slot address <address>.
6522 \end_layout
6524 \begin_layout Subsection
6525 hostmemory.write: Write byte to host memory
6526 \end_layout
6528 \begin_layout Itemize
6529 Syntax: none hostmemory.write(number address, number value)
6530 \end_layout
6532 \begin_layout Standard
6533 Writes hostmemory slot with value <value> 0-255.
6534 \end_layout
6536 \begin_layout Subsection
6537 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6538 \end_layout
6540 \begin_layout Itemize
6541 Syntax: number hostmemory.readbyte(number address)
6542 \end_layout
6544 \begin_layout Itemize
6545 Syntax: number hostmemory.readsbyte(number address)
6546 \end_layout
6548 \begin_layout Itemize
6549 Syntax: number hostmemory.readword(number address)
6550 \end_layout
6552 \begin_layout Itemize
6553 Syntax: number hostmemory.readsword(number address)
6554 \end_layout
6556 \begin_layout Itemize
6557 Syntax: number hostmemory.readhword(number address)
6558 \end_layout
6560 \begin_layout Itemize
6561 Syntax: number hostmemory.readshword(number address)
6562 \end_layout
6564 \begin_layout Itemize
6565 Syntax: number hostmemory.readdword(number address)
6566 \end_layout
6568 \begin_layout Itemize
6569 Syntax: number hostmemory.readsdword(number address)
6570 \end_layout
6572 \begin_layout Itemize
6573 Syntax: number hostmemory.readqword(number address)
6574 \end_layout
6576 \begin_layout Itemize
6577 Syntax: number hostmemory.readsqword(number address)
6578 \end_layout
6580 \begin_layout Standard
6581 Read elements (big-endian) from given address <address>.
6582 \end_layout
6584 \begin_layout Itemize
6585 byte is 1 element
6586 \end_layout
6588 \begin_layout Itemize
6589 word is 2 elements
6590 \end_layout
6592 \begin_layout Itemize
6593 hword is 3 elements
6594 \end_layout
6596 \begin_layout Itemize
6597 dword is 4 elements
6598 \end_layout
6600 \begin_layout Itemize
6601 qword is 8 elements.
6602 \end_layout
6604 \begin_layout Itemize
6605 The 's' variants do signed read.
6606 \end_layout
6608 \begin_layout Subsection
6609 hostmemory.read{float,double}: Read from host memory
6610 \end_layout
6612 \begin_layout Itemize
6613 syntax: number hostmemory.readfloat(number address)
6614 \end_layout
6616 \begin_layout Itemize
6617 Syntax: number hostmemory.readdouble(number address)
6618 \end_layout
6620 \begin_layout Standard
6621 Read elements (big-endian) floating-pont from given address <address>.
6622 \end_layout
6624 \begin_layout Subsection
6625 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6626 \end_layout
6628 \begin_layout Itemize
6629 Syntax: number hostmemory.writebyte(number address, number value)
6630 \end_layout
6632 \begin_layout Itemize
6633 Syntax: number hostmemory.writesbyte(number address, number value)
6634 \end_layout
6636 \begin_layout Itemize
6637 Syntax: number hostmemory.writeword(number address, number value)
6638 \end_layout
6640 \begin_layout Itemize
6641 Syntax: number hostmemory.writesword(number address, number value)
6642 \end_layout
6644 \begin_layout Itemize
6645 Syntax: number hostmemory.writehword(number address, number value)
6646 \end_layout
6648 \begin_layout Itemize
6649 Syntax: number hostmemory.writeshword(number address, number value)
6650 \end_layout
6652 \begin_layout Itemize
6653 Syntax: number hostmemory.writedword(number address, number value)
6654 \end_layout
6656 \begin_layout Itemize
6657 Syntax: number hostmemory.writesdword(number address, number value)
6658 \end_layout
6660 \begin_layout Itemize
6661 Syntax: number hostmemory.writeqword(number address, number value)
6662 \end_layout
6664 \begin_layout Itemize
6665 Syntax: number hostmemory.writesqword(number address, number value)
6666 \end_layout
6668 \begin_layout Standard
6669 Write value <value> to elements (little-endian) starting from given address
6670  <address>.
6671 \end_layout
6673 \begin_layout Itemize
6674 byte is 1 element
6675 \end_layout
6677 \begin_layout Itemize
6678 word is 2 elements
6679 \end_layout
6681 \begin_layout Itemize
6682 hword is 3 elements
6683 \end_layout
6685 \begin_layout Itemize
6686 dword is 4 elements
6687 \end_layout
6689 \begin_layout Itemize
6690 qword is 8 elements.
6691 \end_layout
6693 \begin_layout Itemize
6694 The 's' variants do signed write.
6695 \end_layout
6697 \begin_layout Subsection
6698 hostmemory.write{float,double}: Write to host memory
6699 \end_layout
6701 \begin_layout Itemize
6702 syntax: none hostmemory.readfloat(number address, number value)
6703 \end_layout
6705 \begin_layout Itemize
6706 Syntax: none hostmemory.readdouble(number address, number value)
6707 \end_layout
6709 \begin_layout Standard
6710 Write elements (big-endian) floating-pont to given address <address>, storing
6711  <value>.
6712 \end_layout
6714 \begin_layout Standard
6715 \begin_inset Newpage pagebreak
6716 \end_inset
6719 \end_layout
6721 \begin_layout Section
6722 Table movie
6723 \end_layout
6725 \begin_layout Standard
6726 Movie handling
6727 \end_layout
6729 \begin_layout Subsection
6730 movie.currentframe: Get current frame number
6731 \end_layout
6733 \begin_layout Itemize
6734 Syntax: number movie.currentframe()
6735 \end_layout
6737 \begin_layout Standard
6738 Return number of current frame.
6739 \end_layout
6741 \begin_layout Subsection
6742 movie.framecount: Get move frame count
6743 \end_layout
6745 \begin_layout Itemize
6746 Syntax: number movie.framecount()
6747 \end_layout
6749 \begin_layout Standard
6750 Return number of frames in movie.
6751 \end_layout
6753 \begin_layout Subsection
6754 movie.lagcount: Get current lag count
6755 \end_layout
6757 \begin_layout Itemize
6758 Syntax: number movie.lagcount()
6759 \end_layout
6761 \begin_layout Standard
6762 Return number of lag frames recorded so far.
6763 \end_layout
6765 \begin_layout Subsection
6766 movie.readonly: Is in playback mode?
6767 \end_layout
6769 \begin_layout Itemize
6770 Syntax: boolean movie.readonly()
6771 \end_layout
6773 \begin_layout Standard
6774 Return true if in playback mode, false if in recording.
6775 \end_layout
6777 \begin_layout Subsection
6778 movie.rerecords: Movie rerecord count
6779 \end_layout
6781 \begin_layout Itemize
6782 Syntax: number movie.rerecords()
6783 \end_layout
6785 \begin_layout Standard
6786 Returns the current value of rerecord count.
6787 \end_layout
6789 \begin_layout Subsection
6790 movie.set_readwrite: Set recording mode.
6791 \end_layout
6793 \begin_layout Itemize
6794 Syntax: none movie.set_readwrite()
6795 \end_layout
6797 \begin_layout Standard
6798 Set recording mode (does not cause on_readwrite callback).
6799 \end_layout
6801 \begin_layout Subsection
6802 movie.frame_subframes: Count subframes in frame
6803 \end_layout
6805 \begin_layout Itemize
6806 Syntax: number movie.frame_subframes(number frame)
6807 \end_layout
6809 \begin_layout Standard
6810 Count number of subframes in specified frame <frame> (frame numbers are
6811  1-based) and return that.
6812 \end_layout
6814 \begin_layout Subsection
6815 movie.read_subframes: Read subframe data (deprecated)
6816 \end_layout
6818 \begin_layout Itemize
6819 Syntax: table movie.read_subframes(number frame, number subframe)
6820 \end_layout
6822 \begin_layout Standard
6823 Read specifed subframe in specified frame and return data as array.
6824 \end_layout
6826 \begin_layout Subsection
6827 movie.read_rtc: Read current RTC time
6828 \end_layout
6830 \begin_layout Itemize
6831 Syntax: (number, number) movie.read_rtc()
6832 \end_layout
6834 \begin_layout Standard
6835 Returns the current value of the RTC as a pair (second, subsecond).
6836 \end_layout
6838 \begin_layout Subsection
6839 movie.unsafe_rewind: Fast movie rewind to saved state
6840 \end_layout
6842 \begin_layout Itemize
6843 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6844 \end_layout
6846 \begin_layout Standard
6847 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6848 \end_layout
6850 \begin_layout Itemize
6851 If called without argument, causes emulator to start process of setting
6852  unsafe rewind point.
6853  When this has finished, callback on_set_rewind occurs, passing the rewind
6854  state to lua script.
6855 \end_layout
6857 \begin_layout Itemize
6858 If called with argument, causes emulator rewind to passed rewind point as
6859  soon as possible.
6860  recording mode is implicitly activated.
6861 \end_layout
6863 \begin_layout Standard
6864 The following warnings apply to unsafe rewinding:
6865 \end_layout
6867 \begin_layout Itemize
6868 There are no safety checks against misuse (that's what 
6869 \begin_inset Quotes eld
6870 \end_inset
6872 unsafe
6873 \begin_inset Quotes erd
6874 \end_inset
6876  comes from)!
6877 \end_layout
6879 \begin_layout Itemize
6880 Only call rewind from timeline rewind point was set from.
6881 \end_layout
6883 \begin_layout Itemize
6884 Only call rewind from after the rewind point was set.
6885 \end_layout
6887 \begin_layout Subsection
6888 movie.to_rewind: Load savestate as rewind point
6889 \end_layout
6891 \begin_layout Itemize
6892 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6893 \end_layout
6895 \begin_layout Standard
6896 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6897  corresponding to it.
6898 \end_layout
6900 \begin_layout Itemize
6901 Note: This operation does not take emulated time.
6902 \end_layout
6904 \begin_layout Subsection
6905 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6906 \end_layout
6908 \begin_layout Itemize
6909 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6910 \end_layout
6912 \begin_layout Itemize
6913 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6914 \end_layout
6916 \begin_layout Standard
6917 Copies specified movie or branch <movie>/current object (if none or nil,
6918  the active movie) as new movie object.
6919 \end_layout
6921 \begin_layout Subsection
6922 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6923 \end_layout
6925 \begin_layout Itemize
6926 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6927 \end_layout
6929 \begin_layout Itemize
6930 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6931 \end_layout
6933 \begin_layout Standard
6934 Get INPUTFRAME object corresponding to specified frame in specified movie
6935  or branch.
6936 \end_layout
6938 \begin_layout Subsection
6939 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6940 \end_layout
6942 \begin_layout Itemize
6943 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6944  data)
6945 \end_layout
6947 \begin_layout Itemize
6948 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6949 \end_layout
6951 \begin_layout Standard
6952 Set data in specified frame.
6953 \end_layout
6955 \begin_layout Itemize
6956 Note: Past can't be edited in active movie.
6957 \end_layout
6959 \begin_layout Subsection
6960 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6961 \end_layout
6963 \begin_layout Itemize
6964 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6965 \end_layout
6967 \begin_layout Itemize
6968 Syntax: integer INPUTMOVIE::get_size()
6969 \end_layout
6971 \begin_layout Standard
6972 Return number of subframes in specified movie or branch.
6973 \end_layout
6975 \begin_layout Subsection
6976 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6977 \end_layout
6979 \begin_layout Itemize
6980 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6981 \end_layout
6983 \begin_layout Itemize
6984 Syntax: number INPUTMOVIE::count_frames()
6985 \end_layout
6987 \begin_layout Standard
6988 Return number of frames in movie.
6989 \end_layout
6991 \begin_layout Subsection
6992 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6993 \end_layout
6995 \begin_layout Itemize
6996 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6997 \end_layout
6999 \begin_layout Itemize
7000 Syntax: number INPUTMOVIE::find_frame(number frame)
7001 \end_layout
7003 \begin_layout Standard
7004 Returns starting subframe of given frame (frame numbers are 1-based).
7005  Returns -1 if frame number is bad.
7006 \end_layout
7008 \begin_layout Subsection
7009 movie.subframe_to_frame/INPUTMOVIE::subframe_to_frame: Find frame corresponding
7010  to subframe
7011 \end_layout
7013 \begin_layout Itemize
7014 Syntax: number movie.subframe_to_frame([INPUTMOVIE/string movie], number
7015  subframe)
7016 \end_layout
7018 \begin_layout Itemize
7019 Syntax: number INPUTMOVIE::subframe_to_frame(number subframe)
7020 \end_layout
7022 \begin_layout Standard
7023 Returns frame containing given subframe (subframe numbers are 0-based).
7024  Returns -1 if subframe number is bad.
7025 \end_layout
7027 \begin_layout Subsection
7028 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
7029 \end_layout
7031 \begin_layout Itemize
7032 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
7033 \end_layout
7035 \begin_layout Itemize
7036 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
7037 \end_layout
7039 \begin_layout Standard
7040 Return blank INPUTFRAME with frame type from specified movie.
7041 \end_layout
7043 \begin_layout Subsection
7044 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
7045 \end_layout
7047 \begin_layout Itemize
7048 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
7049 \end_layout
7051 \begin_layout Itemize
7052 Syntax: none INPUTMOVIE::append_frames(number frames)
7053 \end_layout
7055 \begin_layout Standard
7056 Append specified number <frames> of frames.
7057 \end_layout
7059 \begin_layout Subsection
7060 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
7061 \end_layout
7063 \begin_layout Itemize
7064 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
7065 \end_layout
7067 \begin_layout Itemize
7068 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
7069 \end_layout
7071 \begin_layout Standard
7072 Append specified frame <frame>.
7073  Past of current movie can't be edited.
7074 \end_layout
7076 \begin_layout Subsection
7077 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
7078 \end_layout
7080 \begin_layout Itemize
7081 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
7082 \end_layout
7084 \begin_layout Itemize
7085 Syntax: none INPUTMOVIE::truncate(number frames)
7086 \end_layout
7088 \begin_layout Standard
7089 Truncate the specified movie to specified number of frames.
7090 \end_layout
7092 \begin_layout Subsection
7093 movie.edit/INPUTMOVIE::edit: Edit a movie
7094 \end_layout
7096 \begin_layout Itemize
7097 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
7098  controller, number control, number/bool value)
7099 \end_layout
7101 \begin_layout Itemize
7102 Syntax: none movie.edit(string branch, number frame, number port, number
7103  controller, number control, number/bool value)
7104 \end_layout
7106 \begin_layout Itemize
7107 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
7108  number control, number/bool value)
7109 \end_layout
7111 \begin_layout Standard
7112 Change specified control in specified frame in specified movie.
7113  Past can't be edited in active movie.
7114 \end_layout
7116 \begin_layout Subsection
7117 movie.copy_frames2: Copy frames between movies
7118 \end_layout
7120 \begin_layout Itemize
7121 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
7122 IE/string srcmov,] number src, number count)
7123 \end_layout
7125 \begin_layout Standard
7126 Copy specified number of frames between two movies.
7127  The copy proceeeds in forward direction.
7128 \end_layout
7130 \begin_layout Subsection
7131 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
7132 \end_layout
7134 \begin_layout Itemize
7135 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
7136  src, number count, bool backwards)
7137 \end_layout
7139 \begin_layout Itemize
7140 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
7141  bool backwards)
7142 \end_layout
7144 \begin_layout Standard
7145 Copy specified number of frames from one point in movie to another.
7146  If backwards is true, the copy will be done backwards.
7147 \end_layout
7149 \begin_layout Subsection
7150 movie.serialize/INPUTMOVIE::serialize: Serialize movie
7151 \end_layout
7153 \begin_layout Itemize
7154 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
7155  bool binary)
7156 \end_layout
7158 \begin_layout Itemize
7159 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
7160 \end_layout
7162 \begin_layout Standard
7163 Serialize given movie into file.
7164  If binary is true, binary format (more compact and much faster) is used.
7165 \end_layout
7167 \begin_layout Subsection
7168 movie.unserialize: Unserialize movie
7169 \end_layout
7171 \begin_layout Itemize
7172 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
7173  bool binary)
7174 \end_layout
7176 \begin_layout Standard
7177 Unserialize movie from file.
7178  The given frame is used as template to decide the frame type.
7179  If binary is true, binary format is decoded (much faster).
7180 \end_layout
7182 \begin_layout Subsection
7183 movie.current_first_subframe: Return first subframe in current frame
7184 \end_layout
7186 \begin_layout Itemize
7187 Syntax: number movie.current_first_subframe()
7188 \end_layout
7190 \begin_layout Standard
7191 Returns first subframe in current frame.
7192 \end_layout
7194 \begin_layout Subsection
7195 movie.pollcounter: Return poll counter for speified control
7196 \end_layout
7198 \begin_layout Itemize
7199 Syntax: number movie.pollcounter(number port, number controller, number control)
7200 \end_layout
7202 \begin_layout Standard
7203 Returns number of times the specified control has been polled this frame.
7204 \end_layout
7206 \begin_layout Subsection
7207 movie.current_branch: Return current branch
7208 \end_layout
7210 \begin_layout Itemize
7211 Syntax: string movie.current_branch()
7212 \end_layout
7214 \begin_layout Standard
7215 Returns the name of the current branch.
7216 \end_layout
7218 \begin_layout Subsection
7219 movie.get_branches: Return names of all branches
7220 \end_layout
7222 \begin_layout Itemize
7223 Syntax: string...
7224  movie.get_branches()
7225 \end_layout
7227 \begin_layout Standard
7228 Returns the name of all branches.
7229 \end_layout
7231 \begin_layout Subsection
7232 movie.rom_loaded: Is ROM loaded?
7233 \end_layout
7235 \begin_layout Itemize
7236 Syntax: boolean movie.rom_loaded()
7237 \end_layout
7239 \begin_layout Standard
7240 Returns true if ROM is loaded, false otherwise.
7241 \end_layout
7243 \begin_layout Subsection
7244 movie.get_rom_info: Get info about loaded ROM
7245 \end_layout
7247 \begin_layout Itemize
7248 Syntax: Table movie.get_rom_info()
7249 \end_layout
7251 \begin_layout Standard
7252 Returns a table of tables.
7253  The outer table is indexed by ROM slot index.
7254  The inner table has the following fields:
7255 \end_layout
7257 \begin_layout Itemize
7258 filename: The name of file
7259 \end_layout
7261 \begin_layout Itemize
7262 hint: File name hint
7263 \end_layout
7265 \begin_layout Itemize
7266 sha256: SHA-256 hash of ROM.
7267 \end_layout
7269 \begin_layout Itemize
7270 xml_filename: The name of file for markup
7271 \end_layout
7273 \begin_layout Itemize
7274 xml_hint: File name hint for markup
7275 \end_layout
7277 \begin_layout Itemize
7278 xml_sha256: SHA-256 hash of ROM markup.
7279 \end_layout
7281 \begin_layout Standard
7282 If there is no markup, the xml_* fields are absent.
7283 \end_layout
7285 \begin_layout Subsection
7286 movie.get_game_info: Get info about loaded game
7287 \end_layout
7289 \begin_layout Itemize
7290 Syntax: Table movie.get_game_info()
7291 \end_layout
7293 \begin_layout Standard
7294 Returns a table with following fields:
7295 \end_layout
7297 \begin_layout Itemize
7298 core: The name of the core
7299 \end_layout
7301 \begin_layout Itemize
7302 core_short: Short name of the core
7303 \end_layout
7305 \begin_layout Itemize
7306 type: The name of the system type
7307 \end_layout
7309 \begin_layout Itemize
7310 type_long: The long name of the system type
7311 \end_layout
7313 \begin_layout Itemize
7314 region: The name of region
7315 \end_layout
7317 \begin_layout Itemize
7318 region_long: The long name of region
7319 \end_layout
7321 \begin_layout Itemize
7322 gametype: The gametype of movie.
7323 \end_layout
7325 \begin_layout Itemize
7326 fps: Nominal fps as floating-point value
7327 \end_layout
7329 \begin_layout Itemize
7330 fps_n: Exact nominal fps numerator
7331 \end_layout
7333 \begin_layout Itemize
7334 fps_d: Exact nominal fps denominator.
7335 \end_layout
7337 \begin_layout Subsection
7338 movie.get_last_movie: Get name of last movie loaded
7339 \end_layout
7341 \begin_layout Itemize
7342 Syntax: String/Nil movie.get_last_movie()
7343 \end_layout
7345 \begin_layout Standard
7346 Returns the name of last movie loaded as a string, or nil if the last movie
7347  loaded was unnamed.
7348  If you are using this for naming something, movie.get_rom_info() might be
7349  useful in case this returns nil or something useless starting with '$'.
7350 \end_layout
7352 \begin_layout Subsection
7353 INPUTFRAME::get_button: Get button
7354 \end_layout
7356 \begin_layout Itemize
7357 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
7358  control)
7359 \end_layout
7361 \begin_layout Standard
7362 Returns state of given button as boolean.
7363 \end_layout
7365 \begin_layout Subsection
7366 INPUTFRAME::get_axis: Get axis
7367 \end_layout
7369 \begin_layout Itemize
7370 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
7371  control)
7372 \end_layout
7374 \begin_layout Standard
7375 Returns state of given axis as number.
7376 \end_layout
7378 \begin_layout Subsection
7379 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
7380 \end_layout
7382 \begin_layout Itemize
7383 Syntax: none INPUTFRAME::set_button(number port, number controller, number
7384  control, number/bool value)
7385 \end_layout
7387 \begin_layout Itemize
7388 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
7389  control)
7390 \end_layout
7392 \begin_layout Standard
7393 Set the given button/axis to given value.
7394 \end_layout
7396 \begin_layout Subsection
7397 INPUTFRAME::serialize: Serialize a frame
7398 \end_layout
7400 \begin_layout Itemize
7401 Syntax: string INPUTFRAME::serialize()
7402 \end_layout
7404 \begin_layout Standard
7405 Return string representation of frame.
7406 \end_layout
7408 \begin_layout Subsection
7409 INPUTFRAME::unserialize: Unserialize a frame
7410 \end_layout
7412 \begin_layout Itemize
7413 Syntax: none INPUTFRAME::unserialize(string data)
7414 \end_layout
7416 \begin_layout Standard
7417 Set current frame from given data.
7418 \end_layout
7420 \begin_layout Subsection
7421 INPUTFRAME::get_stride: Get movie stride
7422 \end_layout
7424 \begin_layout Itemize
7425 Syntax: number INPUTFRAME::get_stride()
7426 \end_layout
7428 \begin_layout Standard
7429 Return number of bytes needed to store the input frame.
7430  Mainly useful for some debugging.
7431 \end_layout
7433 \begin_layout Standard
7434 \begin_inset Newpage pagebreak
7435 \end_inset
7438 \end_layout
7440 \begin_layout Section
7441 Table settings
7442 \end_layout
7444 \begin_layout Standard
7445 Routines for settings manipulation
7446 \end_layout
7448 \begin_layout Subsection
7449 settings.get: Get value of setting
7450 \end_layout
7452 \begin_layout Itemize
7453 Syntax: string settings.get(string name)
7454 \end_layout
7456 \begin_layout Standard
7457 Get value of setting <name>.
7458  If setting value can't be obtained, returns (nil, error message).
7459 \end_layout
7461 \begin_layout Subsection
7462 settings.set: Set value of setting
7463 \end_layout
7465 \begin_layout Itemize
7466 Syntax: none settings.set(string name, string value)
7467 \end_layout
7469 \begin_layout Standard
7470 Set value <value> of setting <name>.
7471  If setting can't be set, returns (nil, error message).
7472 \end_layout
7474 \begin_layout Subsection
7475 settings.get_all: Get values of all settings
7476 \end_layout
7478 \begin_layout Itemize
7479 Syntax: table settings.get_all()
7480 \end_layout
7482 \begin_layout Standard
7483 Return a table with all setting names as keys and all current values as
7484  values.
7485 \end_layout
7487 \begin_layout Subsection
7488 settings.get_speed: Get current speed
7489 \end_layout
7491 \begin_layout Itemize
7492 Syntax: number/string settings.get_speed()
7493 \end_layout
7495 \begin_layout Standard
7496 Return the current speed multiplier (1 is normal), or 
7497 \begin_inset Quotes eld
7498 \end_inset
7500 turbo
7501 \begin_inset Quotes erd
7502 \end_inset
7504  if speed is set to turbo (this does not react to turbo toggle).
7505 \end_layout
7507 \begin_layout Subsection
7508 settings.set_speed: Set current speed
7509 \end_layout
7511 \begin_layout Itemize
7512 Syntax: settings.get_speed(number spd)
7513 \end_layout
7515 \begin_layout Itemize
7516 Syntax: settings.get_speed(string special)
7517 \end_layout
7519 \begin_layout Standard
7520 Set the current speed multiplier (1 is normal).
7521  The speed may be positive multiplier or 
7522 \begin_inset Quotes eld
7523 \end_inset
7525 turbo
7526 \begin_inset Quotes erd
7527 \end_inset
7529  for turbo speed.
7530 \end_layout
7532 \begin_layout Standard
7533 \begin_inset Newpage pagebreak
7534 \end_inset
7537 \end_layout
7539 \begin_layout Section
7540 Table memory
7541 \end_layout
7543 \begin_layout Standard
7544 Contains various functions for managing memory
7545 \end_layout
7547 \begin_layout Subsection
7548 memory.vma_count: Count number of memory areas.
7549 \end_layout
7551 \begin_layout Itemize
7552 Syntax: number memory.vma_count()
7553 \end_layout
7555 \begin_layout Standard
7556 Returns the number of memory areas
7557 \end_layout
7559 \begin_layout Subsection
7560 memory.read_vma: Lookup memory area info by index
7561 \end_layout
7563 \begin_layout Itemize
7564 Syntax: table memory.read_vma(number index)
7565 \end_layout
7567 \begin_layout Standard
7568 Reads the specified memory area (indices start from zero).
7569  Trying to read invalid memory area gives nil.
7570  The return value is table with the following fields:
7571 \end_layout
7573 \begin_layout Itemize
7574 region_name (string): The readable name of the memory area
7575 \end_layout
7577 \begin_layout Itemize
7578 baseaddr (number): Base address of the memory area
7579 \end_layout
7581 \begin_layout Itemize
7582 lastaddr (number): Last address in the memory area.
7583 \end_layout
7585 \begin_layout Itemize
7586 size (number): The size of memory area in bytes.
7587 \end_layout
7589 \begin_layout Itemize
7590 readonly (boolean): True of the memory area corresponds to ROM.
7591 \end_layout
7593 \begin_layout Itemize
7594 iospace (boolean): True if the memory area is I/O space.
7595 \end_layout
7597 \begin_layout Itemize
7598 native_endian (boolean): True if the memory area has native endian as opposed
7599  to little endian.
7600 \end_layout
7602 \begin_layout Subsection
7603 memory.find_vma: Find memory area info by address
7604 \end_layout
7606 \begin_layout Itemize
7607 Syntax: table memory.find_vma(number address)
7608 \end_layout
7610 \begin_layout Standard
7611 Finds the memory area containing specified address.
7612  Returns table in the same format as read_vma or nil if not found.
7613 \end_layout
7615 \begin_layout Subsection
7616 memory.read{,s}{byte,{,h,d,q}word}: Read memory
7617 \end_layout
7619 \begin_layout Itemize
7620 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
7621 \end_layout
7623 \begin_layout Itemize
7624 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
7625 \end_layout
7627 \begin_layout Itemize
7628 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
7629 \end_layout
7631 \begin_layout Itemize
7632 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
7633 \end_layout
7635 \begin_layout Itemize
7636 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
7637 \end_layout
7639 \begin_layout Itemize
7640 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
7641 \end_layout
7643 \begin_layout Itemize
7644 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
7645 \end_layout
7647 \begin_layout Itemize
7648 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
7649 \end_layout
7651 \begin_layout Itemize
7652 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
7653 \end_layout
7655 \begin_layout Itemize
7656 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
7657 \end_layout
7659 \begin_layout Standard
7660 Reads the specified address <address> (if 's' variant is used, do undergo
7661  2's complement).
7662 \end_layout
7664 \begin_layout Subsection
7665 memory.{,s}read_sg: Scatter/Gather read memory
7666 \end_layout
7668 \begin_layout Itemize
7669 Syntax: none memory.read_sg(string/boolean/number...)
7670 \end_layout
7672 \begin_layout Itemize
7673 Syntax: none memory.sread_sg(string/boolean/number...)
7674 \end_layout
7676 \begin_layout Standard
7677 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
7678  of memory.
7679  Each argument can be string, boolean or number:
7680 \end_layout
7682 \begin_layout Itemize
7683 String: Set memory area addresses are relative to (e.g.
7684  'WRAM').
7685 \end_layout
7687 \begin_layout Itemize
7688 boolean: If true, increment relative address by 1, if false, decrement by
7689  1.
7690  The new address is read as next higher byte.
7691 \end_layout
7693 \begin_layout Itemize
7694 integer: Set the relative address to specified value and read the address
7695  as next higher byte.
7696 \end_layout
7698 \begin_layout Subsection
7699 memory.write_sg: Scatter/Gather write memory
7700 \end_layout
7702 \begin_layout Itemize
7703 Syntax: none memory.write_sg(number value, string/boolean/number...)
7704 \end_layout
7706 \begin_layout Standard
7707 Perform scatter/gather write of value <value> on memory.
7708  Each argument can be string, boolean or number:
7709 \end_layout
7711 \begin_layout Itemize
7712 String: Set memory area addresses are relative to (e.g.
7713  'WRAM').
7714 \end_layout
7716 \begin_layout Itemize
7717 boolean: If true, increment relative address by 1, if false, decrement by
7718  1.
7719  The new address is read as next higher byte.
7720 \end_layout
7722 \begin_layout Itemize
7723 integer: Set the relative address to specified value and read the address
7724  as next higher byte.
7725 \end_layout
7727 \begin_layout Subsection
7728 memory.read{float,double}: Read memory
7729 \end_layout
7731 \begin_layout Itemize
7732 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7733 \end_layout
7735 \begin_layout Itemize
7736 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7737 \end_layout
7739 \begin_layout Standard
7740 Reads the specified address <address>
7741 \end_layout
7743 \begin_layout Subsection
7744 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7745 \end_layout
7747 \begin_layout Itemize
7748 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7749  number value)
7750 \end_layout
7752 \begin_layout Itemize
7753 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7754  number value)
7755 \end_layout
7757 \begin_layout Itemize
7758 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7759  number value)
7760 \end_layout
7762 \begin_layout Itemize
7763 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7764  number value)
7765 \end_layout
7767 \begin_layout Itemize
7768 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7769  number value)
7770 \end_layout
7772 \begin_layout Itemize
7773 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7774  number value)
7775 \end_layout
7777 \begin_layout Itemize
7778 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7779  number value)
7780 \end_layout
7782 \begin_layout Standard
7783 Writes the specified value <value> (negative integer values undergo 2's
7784  complement) to specified address <address>.
7785 \end_layout
7787 \begin_layout Subsection
7788 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7789 \end_layout
7791 \begin_layout Itemize
7792 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7793  number size)
7794 \end_layout
7796 \begin_layout Standard
7797 Returns a table mapping specified memory aperture for read/write.
7798 \end_layout
7800 \begin_layout Itemize
7801 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7802  qword, sqword, float or double.
7803 \end_layout
7805 \begin_layout Subsection
7806 memory.hash_region: Hash region of memory
7807 \end_layout
7809 \begin_layout Itemize
7810 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7811  number size)
7812 \end_layout
7814 \begin_layout Standard
7815 Hash <size> bytes starting from address <base> (relative to <marea>) and
7816  return the SHA-256.
7817 \end_layout
7819 \begin_layout Subsection
7820 memory.hash_region2: Hash region of memory
7821 \end_layout
7823 \begin_layout Itemize
7824 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7825  number size[, number rows, number stride])
7826 \end_layout
7828 \begin_layout Standard
7829 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7830  to <marea>).
7831  The blocks are offset by <stride> from one another and return the SHA-256.
7832 \end_layout
7834 \begin_layout Subsection
7835 memory.hash_region_skein: Hash region of memory
7836 \end_layout
7838 \begin_layout Itemize
7839 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7840  addrobj}, number size[, number rows, number stride])
7841 \end_layout
7843 \begin_layout Standard
7844 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7845  finalists) as hash function.
7846 \end_layout
7848 \begin_layout Subsection
7849 memory.store: Store region of memory
7850 \end_layout
7852 \begin_layout Itemize
7853 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7854  daddr[, number rows, number stride]
7855 \end_layout
7857 \begin_layout Standard
7858 Copy memory starting from <addr> in memory area <marea> (each row being
7859  of size <size>, there being <rows> rows, and rows being separated by <stride>
7860  in memory) into savestate-saved memory area, starting from <daadr> (all
7861  rows are written back to back).
7862 \end_layout
7864 \begin_layout Subsection
7865 memory.storecmp: Compare and store region of memory
7866 \end_layout
7868 \begin_layout Itemize
7869 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7870  number daddr[, number rows, number stride]
7871 \end_layout
7873 \begin_layout Standard
7874 Like memory.store, but returns true if target of copy already held the value
7875  that would be copied before the copy happened.
7876  Otherwise returns false (if target and source differ before copy).
7877 \end_layout
7879 \begin_layout Subsection
7880 memory.hash_state: Hash system state
7881 \end_layout
7883 \begin_layout Itemize
7884 Syntax: string memory.hash_state()
7885 \end_layout
7887 \begin_layout Standard
7888 Hash the current system state.
7889  Mainly useful for debugging savestates.
7890 \end_layout
7892 \begin_layout Subsection
7893 memory.readregion: Read region of memory
7894 \end_layout
7896 \begin_layout Itemize
7897 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7898  number size)
7899 \end_layout
7901 \begin_layout Standard
7902 Read a region of memory.
7903 \end_layout
7905 \begin_layout Itemize
7906 Warning: If the region crosses memory area boundary, the results are undefined.
7907 \end_layout
7909 \begin_layout Subsection
7910 memory.writeregion: Write region of memory
7911 \end_layout
7913 \begin_layout Itemize
7914 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7915  number size, table data)
7916 \end_layout
7918 \begin_layout Standard
7919 Write a region of memory.
7920 \end_layout
7922 \begin_layout Itemize
7923 Warning: If the region crosses memory area boundary, the results are undefined.
7924 \end_layout
7926 \begin_layout Subsection
7927 memory.action: Run core action
7928 \end_layout
7930 \begin_layout Itemize
7931 memory.action(string action, [<params>])
7932 \end_layout
7934 \begin_layout Standard
7935 Run core action.
7936  The different models expect parameters as:
7937 \end_layout
7939 \begin_layout Itemize
7940 string: String
7941 \end_layout
7943 \begin_layout Itemize
7944 numeric: numeric
7945 \end_layout
7947 \begin_layout Itemize
7948 enumeration: String
7949 \end_layout
7951 \begin_layout Itemize
7952 boolean: String
7953 \end_layout
7955 \begin_layout Itemize
7956 toggle: None.
7957 \end_layout
7959 \begin_layout Subsection
7960 memory.action_flags: Get core action flags
7961 \end_layout
7963 \begin_layout Itemize
7964 memory.action_flags(string action)
7965 \end_layout
7967 \begin_layout Standard
7968 Get value of action flags for core action <action>.
7969 \end_layout
7971 \begin_layout Itemize
7972 Bit 0: Enabled?
7973 \end_layout
7975 \begin_layout Itemize
7976 Bit 1: Selected (not all actions can be selected)?
7977 \end_layout
7979 \begin_layout Subsection
7980 memory.get_lag_flag: Get lag flag
7981 \end_layout
7983 \begin_layout Itemize
7984 Syntax: boolean memory.get_lag_flag()
7985 \end_layout
7987 \begin_layout Standard
7988 Get the value of core lag flag.
7989  True if this frame has been lag so far, false if poll has been detected.
7990 \end_layout
7992 \begin_layout Subsection
7993 memory.set_lag_flag: Set lag flag
7994 \end_layout
7996 \begin_layout Itemize
7997 Syntax: none memory.set_lag_flag(boolean flag)
7998 \end_layout
8000 \begin_layout Standard
8001 Set the value of core lag flag.
8002  This flag automatically gets cleared if poll is detected, but can be forcibly
8003  set or cleared if game so requires.
8004 \end_layout
8006 \begin_layout Itemize
8007 Should only be used in on_frame_emulated callback.
8008 \end_layout
8010 \begin_layout Itemize
8011 Setting or clearing this affects the emulator lag counter.
8012 \end_layout
8014 \begin_layout Subsection
8015 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
8016  callback
8017 \end_layout
8019 \begin_layout Itemize
8020 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
8021  function fn);
8022 \end_layout
8024 \begin_layout Itemize
8025 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
8026  addrobj}, function fn);
8027 \end_layout
8029 \begin_layout Itemize
8030 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
8031  function fn);
8032 \end_layout
8034 \begin_layout Itemize
8035 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
8036  function fn);
8037 \end_layout
8039 \begin_layout Itemize
8040 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
8041  function fn);
8042 \end_layout
8044 \begin_layout Itemize
8045 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
8046  function fn);
8047 \end_layout
8049 \begin_layout Standard
8050 Add or remove callback on memory read, write or execute (depending on the
8051  function).
8052  <addr> is relative to <marea>.
8053  <fn> is the callback.
8054  The register* functions return <fn> (which can then be passed to unregister*
8055  functions.
8056 \end_layout
8058 \begin_layout Itemize
8059 Not all cores support this, and it may be unsupported for some memory areas.
8060 \end_layout
8062 \begin_layout Itemize
8063 The functions are passed two parameters: Address and value.
8064 \end_layout
8066 \begin_layout Subsection
8067 memory.{,un}registertrace: Set/Clear trace hook
8068 \end_layout
8070 \begin_layout Itemize
8071 Syntax: function memory.registertrace(number processor, function fn);
8072 \end_layout
8074 \begin_layout Itemize
8075 Syntax: none memory.unregistertrace(number processor, function fn);
8076 \end_layout
8078 \begin_layout Standard
8079 Add or remove trace callback.
8080  <processor> is system-dependent processor number (0 is usually main CPU).
8081  The function arguments work like in other (un)register* functions.
8082 \end_layout
8084 \begin_layout Itemize
8085 The functions are passed two parameters: Trace CPU and Trace event string.
8086 \end_layout
8088 \begin_layout Subsection
8089 memory.cheat: Set cheat
8090 \end_layout
8092 \begin_layout Itemize
8093 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
8094  value);
8095 \end_layout
8097 \begin_layout Itemize
8098 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
8099 \end_layout
8101 \begin_layout Standard
8102 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
8103  If <value> is not speicified, clear a cheat.
8104 \end_layout
8106 \begin_layout Itemize
8107 Not all cores support this, and it may be unsupported for some memory areas.
8108 \end_layout
8110 \begin_layout Subsection
8111 memory.setxmask: Set global execute hook mask
8112 \end_layout
8114 \begin_layout Itemize
8115 Syntax: none memory.setxmask(number mask)
8116 \end_layout
8118 \begin_layout Standard
8119 Set the global execute hook mask to <mask>.
8120  The meaning of each bit is system-dependent, but bit 0 should be the main
8121  CPU.
8122 \end_layout
8124 \begin_layout Subsection
8125 memory.getregister: Get register value
8126 \end_layout
8128 \begin_layout Itemize
8129 Syntax: number/boolean memory.getregister(string register)
8130 \end_layout
8132 \begin_layout Standard
8133 Get the value of named register.
8134 \end_layout
8136 \begin_layout Subsection
8137 memory.getregisters: Get register values
8138 \end_layout
8140 \begin_layout Itemize
8141 Syntax: table memory.getregisters()
8142 \end_layout
8144 \begin_layout Standard
8145 Get the value of all known registers as table.
8146 \end_layout
8148 \begin_layout Subsection
8149 memory.setregister: Set register value
8150 \end_layout
8152 \begin_layout Itemize
8153 Syntax: none memory.setregister(string register, number/boolean value)
8154 \end_layout
8156 \begin_layout Standard
8157 Set the value of named register.
8158 \end_layout
8160 \begin_layout Subsection
8161 memory.mmap: Class MMAP_STRUCT
8162 \end_layout
8164 \begin_layout Standard
8165 See class MMAP_STRUCT
8166 \end_layout
8168 \begin_layout Standard
8169 \begin_inset Newpage pagebreak
8170 \end_inset
8173 \end_layout
8175 \begin_layout Section
8176 Table memory2
8177 \end_layout
8179 \begin_layout Standard
8180 Contains newer memory functions.
8181 \end_layout
8183 \begin_layout Subsection
8184 memory2(): Get all memory area names.
8185 \end_layout
8187 \begin_layout Itemize
8188 Syntax: table memory2()
8189 \end_layout
8191 \begin_layout Standard
8192 Returns array of all valid memory area names.
8193 \end_layout
8195 \begin_layout Subsection
8196 memory2.<marea>:info: Get memory area info
8197 \end_layout
8199 \begin_layout Itemize
8200 Syntax: table memory2.<marea>:info()
8201 \end_layout
8203 \begin_layout Standard
8204 Return table describing given memory area.
8205  Includes fields address, size, last, readonly, special and endian.
8206 \end_layout
8208 \begin_layout Subsection
8209 memory2.<marea>:<op>: Read/Write memory
8210 \end_layout
8212 \begin_layout Itemize
8213 Syntax: none memory2.<marea>:<op>(number offset, number value)
8214 \end_layout
8216 \begin_layout Itemize
8217 Syntax: number memory2.<marea>:<op>(number offset)
8218 \end_layout
8220 \begin_layout Standard
8221 Read/Write value from/to given memory area <marea> at given offset <offset>
8222  (must be in-range).
8223  The value written is <value>.
8224  <Op> is of form: [i][s]<type>, where:
8225 \end_layout
8227 \begin_layout Itemize
8228 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
8229 \end_layout
8231 \begin_layout Itemize
8232 'i' signifies that the value is treated as opposite-to-normal endianess,
8233 \end_layout
8235 \begin_layout Itemize
8236 's' signifies that value is treated as signed (not available for floating-point).
8237 \end_layout
8239 \begin_layout Subsection
8240 memory2.<marea>:read: Scatter-gather value read
8241 \end_layout
8243 \begin_layout Itemize
8244 Syntax: number memory2.<marea>:read(number addr...)
8245 \end_layout
8247 \begin_layout Standard
8248 Read value from given memory area <marea> at byte offsets <addr>..., given
8249  in order of increasing significance.
8250  Value of true and false are special.
8251  True increments address by 1, and false decrements address by 1.
8252 \end_layout
8254 \begin_layout Subsection
8255 memory2.<marea>:sread: Signed scatter-gather value read
8256 \end_layout
8258 \begin_layout Itemize
8259 Syntax: number memory2.<marea>:sread(number addr...)
8260 \end_layout
8262 \begin_layout Standard
8263 Like memory2.<marea>:read, but reads signed values.
8264 \end_layout
8266 \begin_layout Subsection
8267 memory2.<marea>:write: Scatter-gather value write
8268 \end_layout
8270 \begin_layout Itemize
8271 Syntax: number memory2.<marea>:write(number val, number addr...)
8272 \end_layout
8274 \begin_layout Standard
8275 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
8276  in order of increasing significance.
8277  Value of true and false are special.
8278  True increments address by 1, and false decrements address by 1.
8279 \end_layout
8281 \begin_layout Subsection
8282 memory2.<marea>:cheat: Set/Clear cheat
8283 \end_layout
8285 \begin_layout Itemize
8286 Syntax: none memory2.<marea>:cheat(number addr, [number value])
8287 \end_layout
8289 \begin_layout Standard
8290 Set/Clear cheat at offset <addr> of memory area <marea>.
8291  If <value> is given, cheat with specified value is set.
8292  Otherwise cheat on address is removed.
8293 \end_layout
8295 \begin_layout Subsection
8296 memory2.<marea>:sha256: SHA-256
8297 \end_layout
8299 \begin_layout Itemize
8300 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
8301  number stride])
8302 \end_layout
8304 \begin_layout Standard
8305 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
8306  from offset <addr> of area <marea>.
8307  The chunks are separated by <stride>.
8308 \end_layout
8310 \begin_layout Subsection
8311 memory2.<marea>:skein: Skein-512-256
8312 \end_layout
8314 \begin_layout Itemize
8315 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
8316  number stride])
8317 \end_layout
8319 \begin_layout Standard
8320 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
8321 \end_layout
8323 \begin_layout Subsection
8324 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
8325 \end_layout
8327 \begin_layout Itemize
8328 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
8329  number rows, number stride])
8330 \end_layout
8332 \begin_layout Itemize
8333 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
8334  size[, number rows, number stride])
8335 \end_layout
8337 \begin_layout Standard
8338 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
8339  <addr> of area <marea>.
8340  The chunks are separated by <stride>.
8341  The target is Lua host memory, starting from offset <daddr>.
8342 \end_layout
8344 \begin_layout Standard
8345 Additionally, the storecmp method returns false if target was modified (otherwis
8346 e true).
8347 \end_layout
8349 \begin_layout Subsection
8350 memory2.<marea>:readregion: Read region
8351 \end_layout
8353 \begin_layout Itemize
8354 Syntax table memory2.<marea>:readregion(number addr, number size)
8355 \end_layout
8357 \begin_layout Standard
8358 Read <size> bytes starting from <addr> in <marea> and return as array.
8359 \end_layout
8361 \begin_layout Subsection
8362 memory2.<marea>:writeregion: Write region
8363 \end_layout
8365 \begin_layout Itemize
8366 Syntax none memory2.<marea>:writeregion(number addr, table data)
8367 \end_layout
8369 \begin_layout Standard
8370 Write array <data> to bytes starting from <addr> in <marea>.
8371 \end_layout
8373 \begin_layout Subsection
8374 memory2.<marea>:register{read,write,exec}: Register hook
8375 \end_layout
8377 \begin_layout Itemize
8378 Syntax: function memory2.<marea>:registerread(number addr, function fn);
8379 \end_layout
8381 \begin_layout Itemize
8382 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
8383 \end_layout
8385 \begin_layout Itemize
8386 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
8387 \end_layout
8389 \begin_layout Standard
8390 Register debug callback <fn> of specified type at offset <addr> of memory
8391  area <marea>.
8392  Returns <fn>.
8393 \end_layout
8395 \begin_layout Subsection
8396 memory2.<marea>:unregister{read,write,exec}: Unregister hook
8397 \end_layout
8399 \begin_layout Itemize
8400 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
8401 \end_layout
8403 \begin_layout Itemize
8404 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
8405 \end_layout
8407 \begin_layout Itemize
8408 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
8409 \end_layout
8411 \begin_layout Standard
8412 Unregister debug callback <fn> of specified type at offset <addr> of memory
8413  area <marea>.
8414 \end_layout
8416 \begin_layout Standard
8417 \begin_inset Newpage pagebreak
8418 \end_inset
8421 \end_layout
8423 \begin_layout Section
8424 Table random
8425 \end_layout
8427 \begin_layout Standard
8428 Contains random number generation methods.
8429  These functions do not return reproducable results.
8430 \end_layout
8432 \begin_layout Subsection
8433 random.boolean: Random boolean
8434 \end_layout
8436 \begin_layout Itemize
8437 Syntax: boolean random.boolean()
8438 \end_layout
8440 \begin_layout Standard
8441 Returns true or false at random (50-50 chance).
8442 \end_layout
8444 \begin_layout Subsection
8445 random.integer: Random integer
8446 \end_layout
8448 \begin_layout Itemize
8449 Syntax: number random.integer(number highplusone)
8450 \end_layout
8452 \begin_layout Itemize
8453 Syntax: number random.integer(number low, number high)
8454 \end_layout
8456 \begin_layout Standard
8457 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
8458  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
8459 \end_layout
8461 \begin_layout Standard
8462 The returned numbers are from uniform distribution.
8463 \end_layout
8465 \begin_layout Subsection
8466 random.float: Random float
8467 \end_layout
8469 \begin_layout Itemize
8470 Syntax: number random.float()
8471 \end_layout
8473 \begin_layout Standard
8474 Returns random decimal number [0,1).
8475 \end_layout
8477 \begin_layout Subsection
8478 random.among: Random parameter
8479 \end_layout
8481 \begin_layout Itemize
8482 Syntax: value random.among(value values...)
8483 \end_layout
8485 \begin_layout Standard
8486 Returns random parameter value, picked at uniform.
8487  Multiple equivalent values are returned with higher chance.
8488 \end_layout
8490 \begin_layout Subsection
8491 random.amongtable: Random from table
8492 \end_layout
8494 \begin_layout Itemize
8495 Syntax: value random.amongtable(table tab)
8496 \end_layout
8498 \begin_layout Standard
8499 Returns random value from table <tab>.
8500  As in random.among, no equality testing is done.
8501 \end_layout
8503 \begin_layout Standard
8504 \begin_inset Newpage pagebreak
8505 \end_inset
8508 \end_layout
8510 \begin_layout Section
8511 Table zip
8512 \end_layout
8514 \begin_layout Subsection
8515 zip.enumerate: Enumerate members in zipfile
8516 \end_layout
8518 \begin_layout Itemize
8519 Syntax: Table zip.enumerate(string filename[, boolean invert])
8520 \end_layout
8522 \begin_layout Standard
8523 Returns table of files in zip archive <filename>.
8524  If <invert> is true, instead of returning array of names, returns table
8525  with keys being member names and values being true.
8526 \end_layout
8528 \begin_layout Subsection
8529 zip.writer: Class ZIPWRITER
8530 \end_layout
8532 \begin_layout Standard
8533 See class ZIPWRITER.
8534 \end_layout
8536 \begin_layout Section
8537 Table paths
8538 \end_layout
8540 \begin_layout Subsection
8541 paths.get_executable_file: Get the name of lsnes executable file
8542 \end_layout
8544 \begin_layout Itemize
8545 Syntax: String paths.get_executable_file()
8546 \end_layout
8548 \begin_layout Standard
8549 Returns the filename of the lsnes executable (together with path), if known.
8550  If unknown, returns nil.
8551 \end_layout
8553 \begin_layout Subsection
8554 paths.get_executable_path: Get the path of lsnes executable file
8555 \end_layout
8557 \begin_layout Itemize
8558 Syntax: String paths.get_executable_path()
8559 \end_layout
8561 \begin_layout Standard
8562 Returns the directory of the lsnes executable path, if known.
8563  If unknown, returns nil.
8564 \end_layout
8566 \begin_layout Subsection
8567 paths.get_config_path: Get the path of lsnes config file
8568 \end_layout
8570 \begin_layout Itemize
8571 Syntax: String paths.get_config_path()
8572 \end_layout
8574 \begin_layout Standard
8575 Returns the directory of the lsnes configuration.
8576 \end_layout
8578 \begin_layout Subsection
8579 paths.get_rompath: Get the path of ROM files
8580 \end_layout
8582 \begin_layout Itemize
8583 Syntax: String paths.get_rompath()
8584 \end_layout
8586 \begin_layout Standard
8587 Returns the default directory for various ROMs.
8588 \end_layout
8590 \begin_layout Subsection
8591 paths.get_firmwarepath: Get the path of firmware files
8592 \end_layout
8594 \begin_layout Itemize
8595 Syntax: String paths.get_firmwarepath()
8596 \end_layout
8598 \begin_layout Standard
8599 Returns the default directory for various firmwares.
8600 \end_layout
8602 \begin_layout Subsection
8603 paths.get_slotpath: Get the path of save slot files
8604 \end_layout
8606 \begin_layout Itemize
8607 Syntax: String paths.get_slotpath()
8608 \end_layout
8610 \begin_layout Standard
8611 Returns the default directory for various save slots.
8612  If in project context, returns the project directory.
8613 \end_layout
8615 \begin_layout Subsection
8616 paths.get_save_slot_file: Get save slot filename
8617 \end_layout
8619 \begin_layout Itemize
8620 Syntax: String paths.get_slotpath(string name)
8621 \end_layout
8623 \begin_layout Itemize
8624 Syntax: String paths.get_slotpath(integer slotnum, bool for_save)
8625 \end_layout
8627 \begin_layout Standard
8628 Resolve the filename of specified save slot <name> or <slotnum>.
8629  Projects and save branches are taken into account.
8630  If <for_save> is true, the filename is always for current branch.
8631  If <for_save> is false, branch tree is walked upwards until root is reached
8632  or desired file is located.
8633 \end_layout
8635 \begin_layout Standard
8636 \begin_inset Newpage pagebreak
8637 \end_inset
8640 \end_layout
8642 \begin_layout Section
8643 Table callback
8644 \end_layout
8646 \begin_layout Standard
8647 Various callback-related functions.
8648 \end_layout
8650 \begin_layout Subsection
8651 \begin_inset CommandInset label
8652 LatexCommand label
8653 name "subsec:callback.register:-Register-a"
8655 \end_inset
8657 callback.register: Register a callback
8658 \end_layout
8660 \begin_layout Itemize
8661 Syntax: function callback.register(string cbname, function cbfun);
8662 \end_layout
8664 \begin_layout Standard
8665 Instruct function <cbfun> to be added to list of callbacks to call on event
8666  <cbname> (See section 
8667 \begin_inset CommandInset ref
8668 LatexCommand ref
8669 reference "sec:Callbacks"
8671 \end_inset
8674  The callback name does not have the 'on_' prefix (e.g.
8676 \begin_inset Quotes eld
8677 \end_inset
8679 paint
8680 \begin_inset Quotes erd
8681 \end_inset
8684  Returns <cbfun>.
8685 \end_layout
8687 \begin_layout Subsection
8688 \begin_inset CommandInset label
8689 LatexCommand label
8690 name "subsec:callback.unregister:-Unregister-"
8692 \end_inset
8694 callback.unregister: Unregister a callback
8695 \end_layout
8697 \begin_layout Itemize
8698 Syntax: function callback.unregister(string cbname, function cbfun);
8699 \end_layout
8701 \begin_layout Standard
8702 Instruct function <cbfun> to be removed from list of callbacks to call on
8703  event <cbname>.
8704 \end_layout
8706 \begin_layout Subsection
8707 callback.<cbname>:register: Register callback
8708 \end_layout
8710 \begin_layout Itemize
8711 Syntax: function callback.<cbname>:register(function cbfun)
8712 \end_layout
8714 \begin_layout Standard
8715 Synonym for callback.register (section 
8716 \begin_inset CommandInset ref
8717 LatexCommand ref
8718 reference "subsec:callback.register:-Register-a"
8720 \end_inset
8722 ), albeit with callback name specified differently.
8723 \end_layout
8725 \begin_layout Subsection
8726 callback.<cbname>:unregister: Register callback
8727 \end_layout
8729 \begin_layout Itemize
8730 Syntax: function callback.<cbname>:unregister(function cbfun)
8731 \end_layout
8733 \begin_layout Standard
8734 Synonym for callback.unregister (section 
8735 \begin_inset CommandInset ref
8736 LatexCommand ref
8737 reference "subsec:callback.unregister:-Unregister-"
8739 \end_inset
8741 ), albeit with callback name specified differently.
8742 \end_layout
8744 \begin_layout Section
8745 table bsnes
8746 \end_layout
8748 \begin_layout Standard
8749 Various bsnes-specific functions.
8750 \end_layout
8752 \begin_layout Subsection
8753 bsnes.dump_sprite: Dump a sprite
8754 \end_layout
8756 \begin_layout Itemize
8757 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
8758  number height[, number stride])
8759 \end_layout
8761 \begin_layout Standard
8762 Dumps given sprite (in native format) from memory.
8763  memory area is usually 
8764 \begin_inset Quotes eld
8765 \end_inset
8767 VRAM
8768 \begin_inset Quotes erd
8769 \end_inset
8772  <Width> and <height> are given in 8x8 blocks.
8773  <Stride> overrides row stride (default 512).
8774 \end_layout
8776 \begin_layout Subsection
8777 bsnes.dump_sprite2: Dump a 2bpp sprite
8778 \end_layout
8780 \begin_layout Itemize
8781 Syntax: BITMAP bsnes.dump_sprite2(string marea, number addr, number width,
8782  number height[, number stride])
8783 \end_layout
8785 \begin_layout Standard
8786 Dumps given sprite (in 2bpp format) from memory.
8787  memory area is usually 
8788 \begin_inset Quotes eld
8789 \end_inset
8791 VRAM
8792 \begin_inset Quotes erd
8793 \end_inset
8796  <Width> and <height> are given in 8x8 blocks.
8797  <Stride> overrides row stride (default 256).
8798 \end_layout
8800 \begin_layout Subsection
8801 bsnes.dump_palette: Dump a palette
8802 \end_layout
8804 \begin_layout Itemize
8805 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool/integer
8806  full256, bool first_trans)
8807 \end_layout
8809 \begin_layout Standard
8810 Dumps a palette from memory.
8811  memory area is usually 
8812 \begin_inset Quotes eld
8813 \end_inset
8815 CGRAM
8816 \begin_inset Quotes erd
8817 \end_inset
8820  If <full256> is true, 256 colors are dumped (otherwise 16).
8821  <full256> can also be number of colors (4, 16 or 256).
8822  If <first_trans> is true, first color is forced transparent.
8823 \end_layout
8825 \begin_layout Subsection
8826 bsnes.enablelayer: Set layer visibility
8827 \end_layout
8829 \begin_layout Itemize
8830 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8831 \end_layout
8833 \begin_layout Standard
8834 Enable or disable specified layer at specified priority.
8835 \end_layout
8837 \begin_layout Subsection
8838 bsnes.redump_sprite: Redump a sprite
8839 \end_layout
8841 \begin_layout Itemize
8842 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8843  number stride])
8844 \end_layout
8846 \begin_layout Standard
8847 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8848  The specified bitmap must have size multiple of 8x8.
8849 \end_layout
8851 \begin_layout Subsection
8852 bsnes.redump_sprite2: Redump a 2bpp sprite
8853 \end_layout
8855 \begin_layout Itemize
8856 Syntax: none bsnes.redump_sprite2(BITMAP bitmap, string marea, number addr[,
8857  number stride])
8858 \end_layout
8860 \begin_layout Standard
8861 Like bsnes.dump_sprite2, but instead dumps to specified bitmap <bitmap>.
8862  The specified bitmap must have size multiple of 8x8.
8863 \end_layout
8865 \begin_layout Subsection
8866 bsnes.redump_palette: Redump a palette
8867 \end_layout
8869 \begin_layout Itemize
8870 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8871  first_trans)
8872 \end_layout
8874 \begin_layout Standard
8875 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8876  The specified palette must have either 16 or 256 colors.
8877 \end_layout
8879 \begin_layout Section
8880 extensions to table string
8881 \end_layout
8883 \begin_layout Subsection
8884 string.charU: string.char, UTF-8 version.
8885 \end_layout
8887 \begin_layout Itemize
8888 Syntax: string string.charU(number n...)
8889 \end_layout
8891 \begin_layout Standard
8892 Like Lua string.char(), but works in terms of Unicode codepoints.
8893  The returned string is UTF-8.
8894 \end_layout
8896 \begin_layout Subsection
8897 string.byteU: string.byte, UTF-8 version.
8898 \end_layout
8900 \begin_layout Itemize
8901 Syntax: number...
8902  string.byteU(string str[, number i[, number j]])
8903 \end_layout
8905 \begin_layout Standard
8906 Like string.byte(), but works in terms of Unicode codepoints.
8907  The input string <str> is assumed UTF-8.
8908 \end_layout
8910 \begin_layout Subsection
8911 string.regex: Match string against regular expression
8912 \end_layout
8914 \begin_layout Itemize
8915 Syntax: boolean/string...
8916  string.regex(string regexp, string against)
8917 \end_layout
8919 \begin_layout Standard
8920 Match POSIX-extended regular expression <regexp> against string <against>.
8921  If no match, false is returned.
8922  Otherwise if string has no subcaptures, true is returned.
8923  Otherwise each subcapture is returned as a string (in order of starting
8924  position).
8925 \end_layout
8927 \begin_layout Subsection
8928 string.hex: Transform integer into hex string
8929 \end_layout
8931 \begin_layout Itemize
8932 Syntax: string string.hex(number n, [number digits])
8933 \end_layout
8935 \begin_layout Standard
8936 Returns hexadecimal string representation of <n>, optionally padded with
8937  zeroes to <digits> digits (default is not to pad).
8938 \end_layout
8940 \begin_layout Subsection
8941 string.lpad: Pad string with spaces from left
8942 \end_layout
8944 \begin_layout Itemize
8945 Syntax: string string.lpad(string x, number n)
8946 \end_layout
8948 \begin_layout Standard
8949 Pad string <x> to <n> bytes by inserting spaces at start and return the
8950  result.
8951 \end_layout
8953 \begin_layout Subsection
8954 string.rpad: Pad string with spaces from right
8955 \end_layout
8957 \begin_layout Itemize
8958 Syntax: string string.rpad(string x, number n)
8959 \end_layout
8961 \begin_layout Standard
8962 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8963 \end_layout
8965 \begin_layout Section
8966 Table _SYSTEM
8967 \end_layout
8969 \begin_layout Standard
8970 Contains copy of global variables from time of Lua initialization.
8971  Non-writeable.
8972 \end_layout
8974 \begin_layout Standard
8975 \begin_inset Newpage pagebreak
8976 \end_inset
8979 \end_layout
8981 \begin_layout Section
8982 \begin_inset CommandInset label
8983 LatexCommand label
8984 name "sec:Callbacks"
8986 \end_inset
8988 Callbacks
8989 \end_layout
8991 \begin_layout Standard
8992 Various callbacks to Lua that can occur.
8993 \end_layout
8995 \begin_layout Subsection
8996 on_paint: Screen is being painted
8997 \end_layout
8999 \begin_layout Itemize
9000 Callback: on_paint(bool not_synth)
9001 \end_layout
9003 \begin_layout Standard
9004 Called when screen is being painted.
9005  Any gui.* calls requiring graphic context draw on the screen.
9006 \end_layout
9008 \begin_layout Itemize
9009 not_synth is true if this hook is being called in response to received frame,
9010  false otherwise.
9011 \end_layout
9013 \begin_layout Subsection
9014 on_video: Dumped video frame is being painted
9015 \end_layout
9017 \begin_layout Itemize
9018 Callback: on_video()
9019 \end_layout
9021 \begin_layout Standard
9022 Called when video dump frame is being painted.
9023  Any gui.* calls requiring graphic context draw on the video.
9024 \end_layout
9026 \begin_layout Subsection
9027 on_frame_emulated: Frame emulation complete
9028 \end_layout
9030 \begin_layout Itemize
9031 Callback: on_frame_emulated()
9032 \end_layout
9034 \begin_layout Standard
9035 Called when emulating frame has completed and on_paint()/on_video() calls
9036  are about to be issued.
9037 \end_layout
9039 \begin_layout Subsection
9040 on_frame: Frame emulation starting.
9041 \end_layout
9043 \begin_layout Itemize
9044 Callback: on_frame()
9045 \end_layout
9047 \begin_layout Standard
9048 Called on each starting whole frame.
9049 \end_layout
9051 \begin_layout Subsection
9052 on_rewind: Movie rewound to beginning
9053 \end_layout
9055 \begin_layout Itemize
9056 Callback: on_rewind()
9057 \end_layout
9059 \begin_layout Standard
9060 Called when rewind movie to beginning has completed.
9061 \end_layout
9063 \begin_layout Subsection
9064 on_pre_load: Load operation is about to start
9065 \end_layout
9067 \begin_layout Itemize
9068 Callback: on_pre_load(string name)
9069 \end_layout
9071 \begin_layout Standard
9072 Called just before savestate/movie load occurs (note: loads are always delayed,
9073  so this occurs even when load was initiated by lua).
9074 \end_layout
9076 \begin_layout Subsection
9077 on_err_Load: Load failed
9078 \end_layout
9080 \begin_layout Itemize
9081 Callback: on_err_load(string name)
9082 \end_layout
9084 \begin_layout Standard
9085 Called if loadstate goes wrong.
9086 \end_layout
9088 \begin_layout Subsection
9089 on_post_load: Load completed
9090 \end_layout
9092 \begin_layout Itemize
9093 Callback: on_post_load(string name, boolean was_savestate)
9094 \end_layout
9096 \begin_layout Standard
9097 Called on successful loadstate.
9098  was_savestate gives if this was a savestate or a movie.
9099 \end_layout
9101 \begin_layout Subsection
9102 on_pre_save: Save operation is about to start
9103 \end_layout
9105 \begin_layout Itemize
9106 Callback: on_pre_save(string name, boolean is_savestate)
9107 \end_layout
9109 \begin_layout Standard
9110 Called just before savestate save occurs (note: movie saves are synchronous
9111  and won't trigger these callbacks if called from Lua).
9112 \end_layout
9114 \begin_layout Subsection
9115 on_err_save: Save failed
9116 \end_layout
9118 \begin_layout Itemize
9119 Callback: on_err_save(string name)
9120 \end_layout
9122 \begin_layout Standard
9123 Called if savestate goes wrong.
9124 \end_layout
9126 \begin_layout Subsection
9127 on_post_save: Save completed
9128 \end_layout
9130 \begin_layout Itemize
9131 Callback: on_post_save(string name, boolean is_savestate)
9132 \end_layout
9134 \begin_layout Standard
9135 Called on successful savaestate.
9136  is_savestate gives if this was a savestate or a movie.
9137 \end_layout
9139 \begin_layout Subsection
9140 on_quit: Emulator is shutting down
9141 \end_layout
9143 \begin_layout Itemize
9144 Callback: on_quit()
9145 \end_layout
9147 \begin_layout Standard
9148 Called when emulator is shutting down.
9149 \end_layout
9151 \begin_layout Subsection
9152 on_input: Polling for input
9153 \end_layout
9155 \begin_layout Standard
9156 Called when emulator is just sending input to bsnes core.
9157  Warning: This is called even in readonly mode, but the results are ignored.
9158 \end_layout
9160 \begin_layout Subsection
9161 on_reset: System has been reset
9162 \end_layout
9164 \begin_layout Itemize
9165 Callback: on_reset()
9166 \end_layout
9168 \begin_layout Standard
9169 Called when system is reset.
9170 \end_layout
9172 \begin_layout Subsection
9173 on_readwrite: Entered recording mode
9174 \end_layout
9176 \begin_layout Itemize
9177 Callback: on_readwrite()
9178 \end_layout
9180 \begin_layout Standard
9181 Called when moving into recording mode as result of 
9182 \begin_inset Quotes eld
9183 \end_inset
9185 set-rwmode
9186 \begin_inset Quotes erd
9187 \end_inset
9189  command (note: moving to rwmode by Lua won't trigger this, as per recursive
9190  entry protection).
9191 \end_layout
9193 \begin_layout Subsection
9194 on_snoop/on_snoop2: Snoop core controller reads
9195 \end_layout
9197 \begin_layout Itemize
9198 Callback: on_snoop(number port, number controller, number index, number
9199  value)
9200 \end_layout
9202 \begin_layout Itemize
9203 Callback: on_snoop2(number port, number controller, number index, number
9204  value)
9205 \end_layout
9207 \begin_layout Standard
9208 Called each time bsnes asks for input.
9209  The value is the final value to be sent to bsnes core (readonly mode, autohold
9210  and autofire have been taken into account).
9211  Might be useful when translating movies to format suitable for console
9212  verification.
9213  Note: There is no way to modify the value to be sent.
9214 \end_layout
9216 \begin_layout Itemize
9217 On_snoop2 is called instead of on_snoop if defined.
9218  Reserves port 0 for system, having first user port be port 1.
9219 \end_layout
9221 \begin_layout Subsection
9222 on_keyhook: Hooked key/axis has been moved
9223 \end_layout
9225 \begin_layout Itemize
9226 Callback: on_keyhook(string keyname, table state)
9227 \end_layout
9229 \begin_layout Standard
9230 Sent when key that has keyhook events requested changes state.
9231  Keyname is name of the key (group) and state is the state (same kind as
9232  table values in input.raw).
9233 \end_layout
9235 \begin_layout Subsection
9236 on_idle: Idle event
9237 \end_layout
9239 \begin_layout Itemize
9240 Callback: on_idle()
9241 \end_layout
9243 \begin_layout Standard
9244 Called when requested by set_idle_timeout(), the timeout has expired and
9245  emulator is waiting.
9246 \end_layout
9248 \begin_layout Subsection
9249 on_timer: Timer event
9250 \end_layout
9252 \begin_layout Itemize
9253 Callback: on_timer()
9254 \end_layout
9256 \begin_layout Standard
9257 Called when requested by set_idle_timeout() and the timeout has expired
9258  (regardless if emulator is waiting).
9259 \end_layout
9261 \begin_layout Subsection
9262 on_set_rewind: Rewind point has been set
9263 \end_layout
9265 \begin_layout Itemize
9266 Callback: on_set_rewind(UNSAFEREWIND r)
9267 \end_layout
9269 \begin_layout Standard
9270 Called when unsafe rewind object has been constructed.
9271 \end_layout
9273 \begin_layout Subsection
9274 on_pre_rewind: Rewind is about to occur
9275 \end_layout
9277 \begin_layout Itemize
9278 Callback: on_pre_rewind() 
9279 \end_layout
9281 \begin_layout Standard
9282 Called just before unsafe rewind is about to occur.
9283 \end_layout
9285 \begin_layout Subsection
9286 on_post_rewind: Rewind has occured
9287 \end_layout
9289 \begin_layout Itemize
9290 Callback: on_post_rewind() 
9291 \end_layout
9293 \begin_layout Standard
9294 Called just after unsafe rewind has occured.
9295 \end_layout
9297 \begin_layout Subsection
9298 on_button: Button has been pressed
9299 \end_layout
9301 \begin_layout Itemize
9302 Callback: on_button(number port, number controller, number index, string
9303  type)
9304 \end_layout
9306 \begin_layout Standard
9307 Called on controller button press, with following parameters:
9308 \end_layout
9310 \begin_layout Itemize
9311 port: Port number (0 is system)
9312 \end_layout
9314 \begin_layout Itemize
9315 controller: Controller within port
9316 \end_layout
9318 \begin_layout Itemize
9319 index: Index of button.
9320 \end_layout
9322 \begin_layout Itemize
9323 type: Type of event, one of:
9324 \begin_inset Separator latexpar
9325 \end_inset
9328 \end_layout
9330 \begin_deeper
9331 \begin_layout Itemize
9332 \begin_inset Quotes eld
9333 \end_inset
9335 pressed
9336 \begin_inset Quotes erd
9337 \end_inset
9339 : Button was pressed.
9340 \end_layout
9342 \begin_layout Itemize
9343 \begin_inset Quotes eld
9344 \end_inset
9346 released
9347 \begin_inset Quotes erd
9348 \end_inset
9350 : Button was released.
9351 \end_layout
9353 \begin_layout Itemize
9354 \begin_inset Quotes eld
9355 \end_inset
9357 hold
9358 \begin_inset Quotes erd
9359 \end_inset
9361 : Held.
9362 \end_layout
9364 \begin_layout Itemize
9365 \begin_inset Quotes eld
9366 \end_inset
9368 unhold
9369 \begin_inset Quotes erd
9370 \end_inset
9372 : Released from hold.
9373 \end_layout
9375 \begin_layout Itemize
9376 \begin_inset Quotes eld
9377 \end_inset
9379 type
9380 \begin_inset Quotes erd
9381 \end_inset
9383 : Typing input on button.
9384 \end_layout
9386 \begin_layout Itemize
9387 \begin_inset Quotes eld
9388 \end_inset
9390 untype
9391 \begin_inset Quotes erd
9392 \end_inset
9394 : Typing input undone.
9395 \end_layout
9397 \begin_layout Itemize
9398 \begin_inset Quotes eld
9399 \end_inset
9401 autofire <duty> <cycle>
9402 \begin_inset Quotes erd
9403 \end_inset
9405 : Autofire with specifie duty and cycle.
9406 \end_layout
9408 \begin_layout Itemize
9409 \begin_inset Quotes eld
9410 \end_inset
9412 autofire
9413 \begin_inset Quotes erd
9414 \end_inset
9416 : Stop autofire.
9417 \end_layout
9419 \begin_layout Itemize
9420 \begin_inset Quotes eld
9421 \end_inset
9423 analog
9424 \begin_inset Quotes erd
9425 \end_inset
9427 : Analog action on axis.
9428 \end_layout
9430 \end_deeper
9431 \begin_layout Subsection
9432 on_movie_lost: Movie data is about to be lost
9433 \end_layout
9435 \begin_layout Itemize
9436 Callback: on_movie_lost(STRING kind)
9437 \end_layout
9439 \begin_layout Standard
9440 Called just before something would happen that could lose movie data.
9441  Kind can be:
9442 \end_layout
9444 \begin_layout Itemize
9445 readwrite: Switching to recording mode.
9446 \end_layout
9448 \begin_layout Itemize
9449 reload: ROM is being reloaded in recording mode.
9450 \end_layout
9452 \begin_layout Itemize
9453 load: New movie is being loaded.
9454 \end_layout
9456 \begin_layout Itemize
9457 unsaferewind: Unsafe rewind is happening.
9458 \end_layout
9460 \begin_layout Subsection
9461 on_latch: Latch line is rising
9462 \end_layout
9464 \begin_layout Itemize
9465 Callback: on_latch(<core-dependent-parameters>)
9466 \end_layout
9468 \begin_layout Standard
9469 Called when latch line for controller is rising.
9470  Some cores may not support this.
9471 \end_layout
9473 \begin_layout Section
9474 System-dependent behaviour
9475 \end_layout
9477 \begin_layout Subsection
9478 bsnes core
9479 \end_layout
9481 \begin_layout Itemize
9482 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
9483  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
9484  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
9485 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
9486 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
9487  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
9488  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
9489  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
9490  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
9491 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
9492 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
9493  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
9494 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
9495 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
9496  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
9497 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
9498  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
9499 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
9500 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
9501 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
9502  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
9503 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
9504  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
9505  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
9506 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
9507 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
9508 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
9509  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
9510 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
9511  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
9512  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
9513  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
9514  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
9515 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
9516  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
9517 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
9518  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
9519  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
9520 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
9521  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
9522 \end_layout
9524 \begin_layout Itemize
9525 on_latch has no parameters
9526 \end_layout
9528 \begin_layout Itemize
9529 CPU 0 is S-CPU, 1 is S-SMP.
9530 \end_layout
9532 \begin_layout Itemize
9533 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
9534 \end_layout
9536 \begin_layout Itemize
9537 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
9538 {RAM,ROM}.
9539 \end_layout
9541 \begin_layout Itemize
9542 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
9543  DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
9544  BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
9545  GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
9546 \end_layout
9548 \begin_layout Subsection
9549 gambatte core
9550 \end_layout
9552 \begin_layout Itemize
9553 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
9554  d, e, f, h, l
9555 \end_layout
9557 \begin_layout Itemize
9558 on_latch is not supported
9559 \end_layout
9561 \begin_layout Itemize
9562 CPU 0 is main CPU.
9563 \end_layout
9565 \begin_layout Itemize
9566 Cheats are supported for ROM, SRAM and WRAM.
9567 \end_layout
9569 \begin_layout Itemize
9570 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
9571  and WRAM.
9572 \end_layout
9574 \begin_layout Itemize
9575 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
9576 \end_layout
9578 \end_body
9579 \end_document