Fix macros getting frame duplicated after loadstate
[lsnes.git] / lua.lyx
blobd42d8e9e0b9e5b400cd3a1eed7799cff486b60a2
1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
2 \lyxformat 413
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options true
7 \maintain_unincluded_children false
8 \language english
9 \language_package default
10 \inputencoding auto
11 \fontencoding global
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
17 \font_sc false
18 \font_osf false
19 \font_sf_scale 100
20 \font_tt_scale 100
22 \graphics default
23 \default_output_format default
24 \output_sync 0
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
28 \spacing single
29 \use_hyperref true
30 \pdf_bookmarks true
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
34 \pdf_breaklinks false
35 \pdf_pdfborder false
36 \pdf_colorlinks false
37 \pdf_backref false
38 \pdf_pdfusetitle true
39 \papersize a4paper
40 \use_geometry true
41 \use_amsmath 1
42 \use_esint 1
43 \use_mhchem 1
44 \use_mathdots 1
45 \cite_engine basic
46 \use_bibtopic false
47 \use_indices false
48 \paperorientation portrait
49 \suppress_date false
50 \use_refstyle 1
51 \index Hakusana
52 \shortcut idx
53 \color #008000
54 \end_index
55 \leftmargin 2cm
56 \topmargin 2cm
57 \rightmargin 1cm
58 \bottommargin 2cm
59 \headheight 1cm
60 \headsep 1cm
61 \footskip 1cm
62 \secnumdepth 3
63 \tocdepth 3
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
67 \papercolumns 1
68 \papersides 1
69 \paperpagestyle default
70 \tracking_changes false
71 \output_changes false
72 \html_math_output 0
73 \html_css_as_file 0
74 \html_be_strict false
75 \end_header
77 \begin_body
79 \begin_layout Title
80 lsnes Lua functions reference
81 \end_layout
83 \begin_layout Section
84 Table of contents
85 \end_layout
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
91 \end_inset
94 \end_layout
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
98 \end_inset
101 \end_layout
103 \begin_layout Section
104 Conventions
105 \end_layout
107 \begin_layout Subsection
108 Coordinates:
109 \end_layout
111 \begin_layout Itemize
112 Coordinates increase to right and down.
113 \end_layout
115 \begin_layout Itemize
116 The origin is at top left of game area or buffer.
117 \end_layout
119 \begin_layout Subsection
120 Drawing and contexts
121 \end_layout
123 \begin_layout Itemize
124 Methods that draw something (unless stated otherwise) require a valid rendering
125  context.
126  This context can come in three ways:
127 \end_layout
129 \begin_deeper
130 \begin_layout Enumerate
131 The default rendering context of paint callback (the screen).
132 \end_layout
134 \begin_layout Enumerate
135 The default rendering context of video callback (the video).
136 \end_layout
138 \begin_layout Enumerate
139 Explicitly set rendering context (RENDERCTX:set).
140 \end_layout
142 \end_deeper
143 \begin_layout Itemize
144 The rendering context is always reset when callback ends.
145 \end_layout
147 \begin_layout Subsection
148 Colors
149 \end_layout
151 \begin_layout Standard
152 (Direct) colors can be specified either as numbers or strings.
153 \end_layout
155 \begin_layout Itemize
156 -1 is fully transparent.
157 \end_layout
159 \begin_layout Itemize
160 Non-negative numbers less than 
161 \begin_inset Formula $2^{32}$
162 \end_inset
164  are partially opaque colors (
165 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
166 \end_inset
169 \end_layout
171 \begin_deeper
172 \begin_layout Itemize
173 \begin_inset Formula $a$
174 \end_inset
176  is transparency 
177 \begin_inset Formula $0-255$
178 \end_inset
181 \begin_inset Formula $0$
182 \end_inset
184  is fully opaque, 
185 \begin_inset Formula $256$
186 \end_inset
188  would be fully transparent.
189 \end_layout
191 \begin_deeper
192 \begin_layout Itemize
193 Thus, numbers in range 
194 \begin_inset Formula $0-16777215$
195 \end_inset
197  stand for fully opaque colors.
198 \end_layout
200 \end_deeper
201 \begin_layout Itemize
202 \begin_inset Formula $r$
203 \end_inset
206 \begin_inset Formula $g$
207 \end_inset
209  and 
210 \begin_inset Formula $b$
211 \end_inset
213  are intensities of base colors on scale 
214 \begin_inset Formula $0-255$
215 \end_inset
218 \end_layout
220 \end_deeper
221 \begin_layout Itemize
222 Color can also be specified by name as string: The following color names
223  are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
224  antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
225  azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
226  bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
227  brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
228  burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
229  chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
230  chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
231 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
232  cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
233  darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
234  darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
235  darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
236 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
237 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
238  darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
239  darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
240  deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
241  dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
242  firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
243  fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
244  goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
245  gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
246  gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
247  gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
248  gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
249  gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
250  gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
251  gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
252  gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
253  gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
254  green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
255  grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
256  grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
257  grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
258  grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
259  grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
260  grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
261  grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
262  grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
263  grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
264  honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
265  indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
266  ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
267  lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
268 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
269  lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
270  lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
271 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
272  lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
273  lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
274  lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
275  lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
276  lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
277  lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
278  maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
279  mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
280  mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
281 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
282 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
283 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
284  navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
285  olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
286  orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
287  palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
288 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
289  palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
290  peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
291  pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
292  purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
293  rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
294  saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
295  seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
296  seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
297  skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
298 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
299  snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
300 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
301  tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
302  tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
303  turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
304  wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
305  yellow3 yellow4 yellowgreen 
306 \end_layout
308 \begin_layout Itemize
309 The HSL base color names: hsl-<hue><saturation><lightness>.
310 \end_layout
312 \begin_deeper
313 \begin_layout Itemize
314 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
315  y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
316  (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
317 \end_layout
319 \begin_layout Itemize
320 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
321 \end_layout
323 \begin_layout Itemize
324 Lightness is 0-8, where 0 is black and 8 is white.
325 \end_layout
327 \end_deeper
328 \begin_layout Itemize
329 The color names can have a modifier after space (multiple modifiers are
330  allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
331  opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
332  hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
333 \end_layout
335 \begin_deeper
336 \begin_layout Itemize
337 opaqueness is measured as percentage.
338 \end_layout
340 \begin_layout Itemize
341 Hue adjustments are on 24-step scale.
342 \end_layout
344 \begin_layout Itemize
345 Saturation and lightness adjustments are on 16-step scale.
346 \end_layout
348 \end_deeper
349 \begin_layout Section
350 Special tokens
351 \end_layout
353 \begin_layout Standard
354 These tokens are special, and are expanded while the script is being loaded
355 \end_layout
357 \begin_layout Subsection
358 @@LUA_SCRIPT_FILENAME@@
359 \end_layout
361 \begin_layout Standard
362 Expanded to string token containing path and filename of this Lua script.
363  Handy for referencing other lua scripts or resources that are relative
364  to this Lua script.
365 \end_layout
367 \begin_layout Standard
368 In practicular, this is suitable to be passed as base argument of various
369  functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
370 ad_png and gui.bitmap_load_pal.
371 \end_layout
373 \begin_layout Section
374 Classes
375 \end_layout
377 \begin_layout Subsection
378 MMAP_STRUCT: Quasi-table mapping emulated memory
379 \end_layout
381 \begin_layout Standard
382 Objects of this class act like tables, except that the values are reflected
383  to and from emulated memory.
384 \end_layout
386 \begin_layout Subsubsection
387 static function new: Create new instance
388 \end_layout
390 \begin_layout Itemize
391 Syntax: mmap memory.mmap.new()
392 \end_layout
394 \begin_layout Itemize
395 Syntax: mmap classes.MMAP_STRUCT.new()
396 \end_layout
398 \begin_layout Itemize
399 Deprecated: mmap memory.map_structure()
400 \end_layout
402 \begin_layout Standard
403 Return value:
404 \end_layout
406 \begin_layout Itemize
407 mmap: MMAP_STRUCT: The created mmap structure.
408 \end_layout
410 \begin_layout Standard
411 Create a new MMAP_STRUCT (with no mappings) and return it.
412 \end_layout
414 \begin_layout Subsubsection
415 operator(): Bind key in mmap structure
416 \end_layout
418 \begin_layout Itemize
419 Syntax: obj(key, address, type)
420 \end_layout
422 \begin_layout Itemize
423 Syntax: obj(key, marea, address, type)
424 \end_layout
426 \begin_layout Standard
427 Parameters:
428 \end_layout
430 \begin_layout Itemize
431 obj: MMAP_STRUCT: The structure to manipulate.
432 \end_layout
434 \begin_layout Itemize
435 key: String: The name of the key in array to map.
436 \end_layout
438 \begin_layout Itemize
439 marea: String: The memory area the mapped address is in (default: global
440  memory space).
441 \end_layout
443 \begin_layout Itemize
444 address: Number: The offset of memory addreess, relative to specified memory
445  area or global memory space.
446 \end_layout
448 \begin_layout Itemize
449 type: String: The type of data to map.
450 \end_layout
452 \begin_deeper
453 \begin_layout Itemize
454 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
455  float or double.
456 \end_layout
458 \end_deeper
459 \begin_layout Standard
460 Bind key <key> in mmap structure <obj> to address <address> (relative to
461  <marea>).
462  The memory address is treated as type <type>.
463 \end_layout
465 \begin_layout Itemize
466 Example: foomap(
467 \begin_inset Quotes eld
468 \end_inset
471 \begin_inset Quotes erd
472 \end_inset
475 \begin_inset Quotes eld
476 \end_inset
478 WRAM
479 \begin_inset Quotes erd
480 \end_inset
482 , 0x2A, 
483 \begin_inset Quotes eld
484 \end_inset
486 sword
487 \begin_inset Quotes erd
488 \end_inset
491 \end_layout
493 \begin_layout Standard
494 This binds signed word at address WRAM+0x2A into key 
495 \begin_inset Quotes eld
496 \end_inset
499 \begin_inset Quotes erd
500 \end_inset
503 \end_layout
505 \begin_layout Standard
506 \begin_inset Newpage pagebreak
507 \end_inset
510 \end_layout
512 \begin_layout Subsection
513 ZIPWRITER: Write .zip files
514 \end_layout
516 \begin_layout Standard
517 This class does writing of .zip files.
518 \end_layout
520 \begin_layout Subsubsection
521 Static function new: Create a new zipfile
522 \end_layout
524 \begin_layout Itemize
525 Syntax: zip zip.writer.new(filename, [compression])
526 \end_layout
528 \begin_layout Itemize
529 Deprecated: zip zip.create(filename, [compression])
530 \end_layout
532 \begin_layout Standard
533 Parameters:
534 \end_layout
536 \begin_layout Itemize
537 filename: string: The name of the file to write.
538 \end_layout
540 \begin_layout Itemize
541 compression: number: Compression level (0-9).
542  Default is 9.
543 \end_layout
545 \begin_layout Standard
546 Return value:
547 \end_layout
549 \begin_layout Itemize
550 zip: ZIPWRITER: The newly created ZIP writer.
551 \end_layout
553 \begin_layout Standard
554 Create a new ZIPWRITER object and return it.
555 \end_layout
557 \begin_layout Subsubsection
558 Method commit: Finish creating ZIP file.
559 \end_layout
561 \begin_layout Itemize
562 Syntax: zipfile:commit()
563 \end_layout
565 \begin_layout Standard
566 Parameters:
567 \end_layout
569 \begin_layout Itemize
570 zipfile: ZIPFILE: The ZIP file object.
571 \end_layout
573 \begin_layout Standard
574 Finish writing the ZIP file and actually create it on disk.
575 \end_layout
577 \begin_layout Itemize
578 If a member is currently open, it is implicitly closed.
579 \end_layout
581 \begin_layout Itemize
582 Invoking this on already committed or rolled back zipfile causes an error.
583 \end_layout
585 \begin_layout Subsubsection
586 Method rollback: Cancel writing the ZIP file.
587 \end_layout
589 \begin_layout Itemize
590 Syntax: zipfile:rollback()
591 \end_layout
593 \begin_layout Standard
594 Parameters:
595 \end_layout
597 \begin_layout Itemize
598 zipfile: ZIPFILE: The ZIP file object.
599 \end_layout
601 \begin_layout Standard
602 Cancel writing the whole ZIP file.
603  The file on disk will not be modified.
604 \end_layout
606 \begin_layout Itemize
607 If a member is currently open, it is implicitly closed.
608 \end_layout
610 \begin_layout Itemize
611 Invoking this on already committed or rolled back zipfile causes an error.
612 \end_layout
614 \begin_layout Subsubsection
615 Method create_file: Start writing a new member
616 \end_layout
618 \begin_layout Itemize
619 Syntax: zipfile:create_file(filename)
620 \end_layout
622 \begin_layout Standard
623 Parameters:
624 \end_layout
626 \begin_layout Itemize
627 zipfile: ZIPFILE: The ZIP file object.
628 \end_layout
630 \begin_layout Itemize
631 string filename: Name of the new member to create
632 \end_layout
634 \begin_layout Standard
635 Start writing a new member <filename> in ZIP file.
636 \end_layout
638 \begin_layout Itemize
639 If a member is currently open, it is implicitly closed.
640 \end_layout
642 \begin_layout Itemize
643 Invoking this on already committed or rolled back zipfile causes an error.
644 \end_layout
646 \begin_layout Subsubsection
647 Method close_file: Close member
648 \end_layout
650 \begin_layout Itemize
651 Syntax: zipfile:close_file()
652 \end_layout
654 \begin_layout Standard
655 Parameters:
656 \end_layout
658 \begin_layout Itemize
659 zipfile: ZIPFILE: The ZIP file object.
660 \end_layout
662 \begin_layout Standard
663 Close the currently open member in zipfile.
664 \end_layout
666 \begin_layout Itemize
667 Invoking this on already committed or rolled back zipfile causes an error.
668 \end_layout
670 \begin_layout Itemize
671 Invoking this without an open member causes an error.
672 \end_layout
674 \begin_layout Subsubsection
675 Method write: Write data
676 \end_layout
678 \begin_layout Itemize
679 Syntax: zipfile:write(data)
680 \end_layout
682 \begin_layout Standard
683 Parameters:
684 \end_layout
686 \begin_layout Itemize
687 zipfile: ZIPFILE: The ZIP file object.
688 \end_layout
690 \begin_layout Itemize
691 data: string: The data to write.
692 \end_layout
694 \begin_layout Standard
695 Write <data> in binary mode (as-is) to currently open member.
696 \end_layout
698 \begin_layout Itemize
699 Invoking this without a member being open causes an error.
700 \end_layout
702 \begin_layout Standard
703 \begin_inset Newpage pagebreak
704 \end_inset
707 \end_layout
709 \begin_layout Subsection
710 TILEMAP: Tiled collection of bitmaps.
711 \end_layout
713 \begin_layout Standard
714 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
715 \end_layout
717 \begin_layout Subsubsection
718 Static function new: Create a tilemap
719 \end_layout
721 \begin_layout Itemize
722 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
723 \end_layout
725 \begin_layout Itemize
726 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
727 \end_layout
729 \begin_layout Itemize
730 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
731 \end_layout
733 \begin_layout Standard
734 Parameters:
735 \end_layout
737 \begin_layout Itemize
738 w: number: Width of the tilemap in tiles
739 \end_layout
741 \begin_layout Itemize
742 h: number: Height of the tilemap in tiles
743 \end_layout
745 \begin_layout Itemize
746 bw: number: Width of each tile in pixels.
747 \end_layout
749 \begin_layout Itemize
750 bh: number: Height of each tile in pixels.
751 \end_layout
753 \begin_layout Standard
754 Return value:
755 \end_layout
757 \begin_layout Itemize
758 tilemap: TILEMAP: the newly created tilemap
759 \end_layout
761 \begin_layout Standard
762 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
763  it.
764 \end_layout
766 \begin_layout Subsubsection
767 TILEMAP:getsize: Query tilemap size
768 \end_layout
770 \begin_layout Itemize
771 Syntax: width, height tmap:getsize()
772 \end_layout
774 \begin_layout Standard
775 Parameters:
776 \end_layout
778 \begin_layout Itemize
779 tmap: TILEMAP: The tilemap to query.
780 \end_layout
782 \begin_layout Standard
783 Return value:
784 \end_layout
786 \begin_layout Itemize
787 width: number : The width of the tilemap in tiles.
788 \end_layout
790 \begin_layout Itemize
791 height: number: The height of the tilemap in tiles.
792 \end_layout
794 \begin_layout Standard
795 Get size of tilemap in tiles.
796 \end_layout
798 \begin_layout Subsubsection
799 TILEMAP:getcsize: Query tilemap cell size
800 \end_layout
802 \begin_layout Itemize
803 Syntax: width, height tmap:getcsize()
804 \end_layout
806 \begin_layout Standard
807 Parameters:
808 \end_layout
810 \begin_layout Itemize
811 tmap: TILEMAP: The tilemap to query.
812 \end_layout
814 \begin_layout Standard
815 Return value:
816 \end_layout
818 \begin_layout Itemize
819 width: number: The width of tilemap tile in pixels.
820 \end_layout
822 \begin_layout Itemize
823 height: number: The height of tilemap tile in pixels.
824 \end_layout
826 \begin_layout Standard
827 Get size of each tilemap tile in pixels.
828 \end_layout
830 \begin_layout Subsubsection
831 TILEMAP:get: Query tilemap tile
832 \end_layout
834 \begin_layout Itemize
835 Syntax: bitmap, palette tmap:get(x, y)
836 \end_layout
838 \begin_layout Standard
839 Parameters:
840 \end_layout
842 \begin_layout Itemize
843 tmap: TILEMAP: The tilemap to query.
844 \end_layout
846 \begin_layout Itemize
847 x: number: The x-coordinate of tile to query.
848 \end_layout
850 \begin_layout Itemize
851 y: number: The y-coordinate of tile to query.
852 \end_layout
854 \begin_layout Standard
855 Return value:
856 \end_layout
858 \begin_layout Itemize
859 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
860 \end_layout
862 \begin_layout Itemize
863 palette: The palette (PALETTE) associated with indexed-color bitmap, if
864  any.
865  Otherwise nil.
866 \end_layout
868 \begin_layout Standard
869 Return the contents of tile at <x>,<y>.
870 \end_layout
872 \begin_layout Subsubsection
873 TILEMAP:set: Set tilemap cell
874 \end_layout
876 \begin_layout Itemize
877 Syntax: tmap:set(x, y)
878 \end_layout
880 \begin_layout Itemize
881 Syntax: tmap:set(x, y, bitmap)
882 \end_layout
884 \begin_layout Itemize
885 Syntax: tmap:set(x, y, bitmap, palette)
886 \end_layout
888 \begin_layout Standard
889 Parameters:
890 \end_layout
892 \begin_layout Itemize
893 tmap: TILEMAP: The tilemap to manipulate.
894 \end_layout
896 \begin_layout Itemize
897 number x: The x-coordinate of tile to set.
898 \end_layout
900 \begin_layout Itemize
901 number y: The y-coordinate of tile to set.
902 \end_layout
904 \begin_layout Itemize
905 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
906 \end_layout
908 \begin_layout Itemize
909 palette: PALETTE: The associated palette for bitmap.
910 \end_layout
912 \begin_layout Standard
913 Set the contents of tile <x>,<y>.
914  If no <bitmap> is given, clears the tile.
915  Otherwise sets the tile to contain bitmap <bitmap> with associated palette
916  <palette>.
917 \end_layout
919 \begin_layout Itemize
920 Specifying index bitmap <bitmap> without palette <palette> causes an error.
921 \end_layout
923 \begin_layout Subsubsection
924 TILEMAP:scroll: Scroll tilemap
925 \end_layout
927 \begin_layout Itemize
928 Syntax: tmap:scroll(ox, oy);
929 \end_layout
931 \begin_layout Itemize
932 Syntax: tmap:scroll(ox, oy, x, y, w, h);
933 \end_layout
935 \begin_layout Itemize
936 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
937 \end_layout
939 \begin_layout Standard
940 Parameters:
941 \end_layout
943 \begin_layout Itemize
944 tmap: TILEMAP: The tilemap to manipulate.
945 \end_layout
947 \begin_layout Itemize
948 ox: number: The number of tiles to scroll horizontally (positive is to right).
949 \end_layout
951 \begin_layout Itemize
952 oy: number: The number of tiles to scroll vertically (positive is to down).
953 \end_layout
955 \begin_layout Itemize
956 x: number: The left edge of scroll window.
957 \end_layout
959 \begin_layout Itemize
960 y: number: The top edge of scroll window.
961 \end_layout
963 \begin_layout Itemize
964 w: number: The width of scroll window.
965 \end_layout
967 \begin_layout Itemize
968 h: number: The height of scroll window.
969 \end_layout
971 \begin_layout Itemize
972 circ_x: boolean: If true, treat the window as circular in horizontal direction.
973 \end_layout
975 \begin_layout Itemize
976 circ_y: boolean: If true, treat the window as circular in vertical direction.
977 \end_layout
979 \begin_layout Standard
980 Scroll the specified tilemap <tmap> by <ox>,<oy>.
981  If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
982  <circ_x> and <circ_y> control if scroll is circular or not.
983 \end_layout
985 \begin_layout Itemize
986 Specifying out-of-range window causes an error.
987 \end_layout
989 \begin_layout Subsubsection
990 TILEMAP:draw: Draw tilemap
991 \end_layout
993 \begin_layout Itemize
994 Name: tmap:draw(x, y)
995 \end_layout
997 \begin_layout Itemize
998 Name: tmap:draw(x, y, x0, y0, w, h)
999 \end_layout
1001 \begin_layout Standard
1002 Parameters:
1003 \end_layout
1005 \begin_layout Itemize
1006 tmap: TILEMAP: The tilemap to draw.
1007 \end_layout
1009 \begin_layout Itemize
1010 x: The x coordinate on screen to draw to.
1011 \end_layout
1013 \begin_layout Itemize
1014 y: The y coordinate on screen to draw to.
1015 \end_layout
1017 \begin_layout Itemize
1018 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1019 \end_layout
1021 \begin_layout Itemize
1022 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1023 \end_layout
1025 \begin_layout Itemize
1026 w: number: The width to draw (in pixels).
1027 \end_layout
1029 \begin_layout Itemize
1030 h: number: The height to draw (in pixels).
1031 \end_layout
1033 \begin_layout Standard
1034 Draw tilemap <tmap> to screen at <x>,<y>.
1035  If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1036 \end_layout
1038 \begin_layout Itemize
1039 This method requires a rendering context to work.
1040 \end_layout
1042 \begin_layout Subsubsection
1043 TILEMAP:draw_outside: Draw tilemap outside game area
1044 \end_layout
1046 \begin_layout Itemize
1047 Name: tmap:draw_outside(x, y)
1048 \end_layout
1050 \begin_layout Itemize
1051 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1052 \end_layout
1054 \begin_layout Standard
1055 Like TILEMAP:draw, but draws only outside game area.
1056 \end_layout
1058 \begin_layout Standard
1059 \begin_inset Newpage pagebreak
1060 \end_inset
1063 \end_layout
1065 \begin_layout Subsection
1066 RENDERCTX: Off-screen rendering context
1067 \end_layout
1069 \begin_layout Standard
1070 Object acting as off-screen rendering context.
1071 \end_layout
1073 \begin_layout Subsubsection
1074 Static function new: Create a render queue
1075 \end_layout
1077 \begin_layout Itemize
1078 Syntax: renderctx gui.renderctx.new(width, height);
1079 \end_layout
1081 \begin_layout Itemize
1082 Syntax: renderctx classes.RENDERCTX.new(width, height);
1083 \end_layout
1085 \begin_layout Itemize
1086 Deprecated: renderctx gui.renderq_new(width, height);
1087 \end_layout
1089 \begin_layout Standard
1090 Parameters:
1091 \end_layout
1093 \begin_layout Itemize
1094 width: number: The notional width of the game area.
1095 \end_layout
1097 \begin_layout Itemize
1098 height: number: The notional height of the game area.
1099 \end_layout
1101 \begin_layout Standard
1102 Returns:
1103 \end_layout
1105 \begin_layout Itemize
1106 rendectx: RENDERCTX: The newly created render context.
1107 \end_layout
1109 \begin_layout Standard
1110 Create a render context with reported size <width>*<height> and return it.
1111 \end_layout
1113 \begin_layout Subsubsection
1114 Static function setnull: Reset to default queue
1115 \end_layout
1117 \begin_layout Itemize
1118 Syntax: gui.renderctx.setnull()
1119 \end_layout
1121 \begin_layout Itemize
1122 Syntax: classes.RENDERCTX:setnull()
1123 \end_layout
1125 \begin_layout Itemize
1126 Deprecated: gui.renderq_set()
1127 \end_layout
1129 \begin_layout Standard
1130 Reset the used render context back to default for the executing callback:
1131 \end_layout
1133 \begin_layout Itemize
1134 The default for paint callback is the screen
1135 \end_layout
1137 \begin_layout Itemize
1138 The default for video callback is the video frame
1139 \end_layout
1141 \begin_layout Itemize
1142 The default otherwise is nothing.
1143 \end_layout
1145 \begin_layout Subsubsection
1146 Method clear: Clear a render queue
1147 \end_layout
1149 \begin_layout Itemize
1150 Syntax: renderctx:clear()
1151 \end_layout
1153 \begin_layout Itemize
1154 Deprecated: gui.renderq_clear(renderctx)
1155 \end_layout
1157 \begin_layout Standard
1158 Parameters:
1159 \end_layout
1161 \begin_layout Itemize
1162 renderctx: RENDERCTX: The render queue to clear.
1163 \end_layout
1165 \begin_layout Standard
1166 Clear all drawing from the context.
1167 \end_layout
1169 \begin_layout Subsubsection
1170 Method set: Change active render context
1171 \end_layout
1173 \begin_layout Itemize
1174 Syntax: renderctx:set()
1175 \end_layout
1177 \begin_layout Itemize
1178 Deprecated: gui.renderq_set(renderctx)
1179 \end_layout
1181 \begin_layout Standard
1182 Parameters:
1183 \end_layout
1185 \begin_layout Itemize
1186 renderctx: RENDERCTX: The render queue to use.
1187 \end_layout
1189 \begin_layout Standard
1190 Switch the current rendering context <renderctx>.
1191 \end_layout
1193 \begin_layout Subsubsection
1194 Method run: Draw all objects in context to another
1195 \end_layout
1197 \begin_layout Itemize
1198 Syntax: renderctx:run()
1199 \end_layout
1201 \begin_layout Itemize
1202 Deprecated: gui.renderq_run(renderctx)
1203 \end_layout
1205 \begin_layout Standard
1206 Parameters:
1207 \end_layout
1209 \begin_layout Itemize
1210 renderctx: RENDERCTX: The render context to overlay.
1211 \end_layout
1213 \begin_layout Standard
1214 Overlay the specified render context <context> upon the active rendering
1215  context.
1216 \end_layout
1218 \begin_layout Itemize
1219 Trying to overlay rendering context upon itself is a bad idea.
1220 \end_layout
1222 \begin_layout Subsubsection
1223 Method render: Render a contex to bitmap
1224 \end_layout
1226 \begin_layout Itemize
1227 Syntax: bitmap renderctx:render()
1228 \end_layout
1230 \begin_layout Standard
1231 Parameters:
1232 \end_layout
1234 \begin_layout Itemize
1235 renderctx: RENDERCTX: The context to render.
1236 \end_layout
1238 \begin_layout Standard
1239 Returns:
1240 \end_layout
1242 \begin_layout Itemize
1243 bitmap: DBITMAP: The rendered bitmap.
1244 \end_layout
1246 \begin_layout Standard
1247 Render the specified context <renderctx> to a new bitmap.
1248 \end_layout
1250 \begin_layout Itemize
1251 The size of bitmap will be nominal game area size, plus any set gaps.
1252 \end_layout
1254 \begin_layout Itemize
1255 This method does not require active rendering context.
1256 \end_layout
1258 \begin_layout Subsubsection
1259 Method synchronous_repaint: Paint screen now
1260 \end_layout
1262 \begin_layout Itemize
1263 Syntax: renderctx:synchronous_repaint()
1264 \end_layout
1266 \begin_layout Itemize
1267 Deprecated: gui.synchronous_repaint(renderctx)
1268 \end_layout
1270 \begin_layout Standard
1271 Parameters:
1272 \end_layout
1274 \begin_layout Itemize
1275 renderctx: RENDERCTX: The context to paint.
1276 \end_layout
1278 \begin_layout Standard
1279 Immediately redraw the screen with game overlayed by drawings from context
1280  <renderctx>.
1281 \end_layout
1283 \begin_layout Itemize
1284 This does not require active rendering context.
1285 \end_layout
1287 \begin_layout Itemize
1288 Will not cause paint callback to be invoked.
1289 \end_layout
1291 \begin_layout Standard
1292 \begin_inset Newpage pagebreak
1293 \end_inset
1296 \end_layout
1298 \begin_layout Subsection
1299 PALETTE: Color palette for indexed image
1300 \end_layout
1302 \begin_layout Subsubsection
1303 Static function new: Create a new palette
1304 \end_layout
1306 \begin_layout Itemize
1307 Syntax: palette gui.palette.new()
1308 \end_layout
1310 \begin_layout Itemize
1311 Syntax: palette classes.PALETTE.new()
1312 \end_layout
1314 \begin_layout Itemize
1315 Deprecated: palette gui.palette_new()
1316 \end_layout
1318 \begin_layout Standard
1319 Returns:
1320 \end_layout
1322 \begin_layout Itemize
1323 palette: PALETTE: The created palette.
1324 \end_layout
1326 \begin_layout Standard
1327 Create a new palette (with all colors transparent) and return it.
1328 \end_layout
1330 \begin_layout Subsubsection
1331 Static function load: Load a palette
1332 \end_layout
1334 \begin_layout Itemize
1335 Syntax: palette gui.palette.load(file, [base])
1336 \end_layout
1338 \begin_layout Itemize
1339 Syntax: palette classes.PALETTE.load(file, [base])
1340 \end_layout
1342 \begin_layout Itemize
1343 Deprecated: palette gui.palette_load(file, [base])
1344 \end_layout
1346 \begin_layout Standard
1347 Parameters:
1348 \end_layout
1350 \begin_layout Itemize
1351 string file: The file to load.
1352 \end_layout
1354 \begin_layout Itemize
1355 string base (optional): The base file to resolve file relative to.
1356 \end_layout
1358 \begin_layout Standard
1359 Returns:
1360 \end_layout
1362 \begin_layout Itemize
1363 palette: PALETTE: The loaded palette.
1364 \end_layout
1366 \begin_layout Standard
1367 Load a palette from file <file> (resolved relative to <base>).
1368 \end_layout
1370 \begin_layout Itemize
1371 The file format is a series of lines, each with following format:
1372 \end_layout
1374 \begin_deeper
1375 \begin_layout Itemize
1376 Blank or just whitespace: Ignored
1377 \end_layout
1379 \begin_layout Itemize
1380 First non-whitespace is '#': Ignored
1381 \end_layout
1383 \begin_layout Itemize
1384 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1385 \end_layout
1387 \begin_layout Itemize
1388 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1389  (0-256, 0 being fully transparent and 256 fully opaque).
1390 \end_layout
1392 \begin_layout Itemize
1393 transparent: Fully transparent color
1394 \end_layout
1396 \end_deeper
1397 \begin_layout Subsubsection
1398 Static function load_str: Load a palette from string
1399 \end_layout
1401 \begin_layout Itemize
1402 Syntax: palette gui.palette.load(data)
1403 \end_layout
1405 \begin_layout Itemize
1406 Syntax: palette classes.PALETTE.load(data)
1407 \end_layout
1409 \begin_layout Itemize
1410 Deprecated: palette gui.palette_load(data)
1411 \end_layout
1413 \begin_layout Standard
1414 Parameters:
1415 \end_layout
1417 \begin_layout Itemize
1418 string data: The palette data.
1419 \end_layout
1421 \begin_layout Standard
1422 Returns:
1423 \end_layout
1425 \begin_layout Itemize
1426 palette: PALETTE: The loaded palette.
1427 \end_layout
1429 \begin_layout Standard
1430 Like PALETTE:load, but instead of reading palette from file, reads it from
1431  a string.
1432 \end_layout
1434 \begin_layout Subsubsection
1435 Method set: Set palette entry
1436 \end_layout
1438 \begin_layout Itemize
1439 Syntax: palette:set(index, color)
1440 \end_layout
1442 \begin_layout Itemize
1443 Deprecated: gui.palette_set(palette, ...)
1444 \end_layout
1446 \begin_layout Standard
1447 Parameters:
1448 \end_layout
1450 \begin_layout Itemize
1451 palette: PALETTE: The palette to manipulate
1452 \end_layout
1454 \begin_layout Itemize
1455 index: number: The index of color to set (0-65535).
1456 \end_layout
1458 \begin_layout Itemize
1459 color: number/string: The color value to set.
1460 \end_layout
1462 \begin_layout Standard
1463 Set palette <palette> index <index> to color <color>.
1464 \end_layout
1466 \begin_layout Subsubsection
1467 Method hash: Hash a palette
1468 \end_layout
1470 \begin_layout Itemize
1471 Syntax: hash palette:hash()
1472 \end_layout
1474 \begin_layout Itemize
1475 Deprecated: hash gui.palette_hash(palette)
1476 \end_layout
1478 \begin_layout Standard
1479 Parameters:
1480 \end_layout
1482 \begin_layout Itemize
1483 palette: The palette to hash.
1484 \end_layout
1486 \begin_layout Standard
1487 Return value:
1488 \end_layout
1490 \begin_layout Itemize
1491 hash: string: 64-hex digit hash.
1492 \end_layout
1494 \begin_layout Standard
1495 Obtain crypto-grade hash of palette data of <palette>.
1496 \end_layout
1498 \begin_layout Itemize
1499 All colors after the last non-transparent one are ignored.
1500 \end_layout
1502 \begin_layout Subsubsection
1503 Method adjust_transparency: Adjust transparency
1504 \end_layout
1506 \begin_layout Itemize
1507 Syntax: palette:adjust_transparency(newvalue)
1508 \end_layout
1510 \begin_layout Itemize
1511 Deprecated: gui.adjust_transparency(palette, ...)
1512 \end_layout
1514 \begin_layout Standard
1515 Parameters:
1516 \end_layout
1518 \begin_layout Itemize
1519 palette: PALETTE: The palette to adjust.
1520 \end_layout
1522 \begin_layout Itemize
1523 Number adj: The factor to multiply opaqueness with times 256.
1524 \end_layout
1526 \begin_layout Standard
1527 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1528 \end_layout
1530 \begin_layout Standard
1531 \begin_inset Newpage pagebreak
1532 \end_inset
1535 \end_layout
1537 \begin_layout Subsection
1538 BITMAP: Indexed-color bitmap
1539 \end_layout
1541 \begin_layout Subsubsection
1542 Static function new: Create a new bitmap
1543 \end_layout
1545 \begin_layout Itemize
1546 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1547 \end_layout
1549 \begin_layout Itemize
1550 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1551 \end_layout
1553 \begin_layout Itemize
1554 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1555 \end_layout
1557 \begin_layout Standard
1558 Parameters:
1559 \end_layout
1561 \begin_layout Itemize
1562 w: number: The width of bitmap to create in pixels.
1563 \end_layout
1565 \begin_layout Itemize
1566 h: number: The height of bitmap to create in pixels.
1567 \end_layout
1569 \begin_layout Itemize
1570 false: boolean: Constant boolean false.
1571 \end_layout
1573 \begin_layout Itemize
1574 fillcolor: number: The initial fill index.
1575  Default 0 if not specified.
1576 \end_layout
1578 \begin_layout Standard
1579 Create a new bitmap of size <w>*<h>.
1580  Fill the bitmap with color index <fillcolor>.
1581 \end_layout
1583 \begin_layout Subsubsection
1584 Method draw: Draw a bitmap
1585 \end_layout
1587 \begin_layout Itemize
1588 Syntax: bitmap:draw(x, y, palette)
1589 \end_layout
1591 \begin_layout Itemize
1592 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1593 \end_layout
1595 \begin_layout Standard
1596 Parameters:
1597 \end_layout
1599 \begin_layout Itemize
1600 bitmap: BITMAP: The bitmap to draw
1601 \end_layout
1603 \begin_layout Itemize
1604 x: number: The x-coordinate on screen.
1605 \end_layout
1607 \begin_layout Itemize
1608 y: number: The y-coordinate on screen.
1609 \end_layout
1611 \begin_layout Itemize
1612 palette: The palette to use for drawing.
1613 \end_layout
1615 \begin_layout Standard
1616 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1617 \end_layout
1619 \begin_layout Subsubsection
1620 Method draw_outside: Draw a bitmap outside game area
1621 \end_layout
1623 \begin_layout Itemize
1624 Syntax: bitmap:draw_outside(x, y, palette)
1625 \end_layout
1627 \begin_layout Standard
1628 Like bitmap:draw, but does not draw on game area.
1629 \end_layout
1631 \begin_layout Subsubsection
1632 Method draw_clip: Draw a bitmap, with clipping
1633 \end_layout
1635 \begin_layout Itemize
1636 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1637 \end_layout
1639 \begin_layout Standard
1640 Parameters:
1641 \end_layout
1643 \begin_layout Itemize
1644 bitmap: BITMAP: The bitmap to draw
1645 \end_layout
1647 \begin_layout Itemize
1648 x: number: The x-coordinate on screen.
1649 \end_layout
1651 \begin_layout Itemize
1652 y: number: The y-coordinate on screen.
1653 \end_layout
1655 \begin_layout Itemize
1656 palette: The palette to use for drawing.
1657 \end_layout
1659 \begin_layout Itemize
1660 x0: The smallest bitmap x coordinate to draw.
1661 \end_layout
1663 \begin_layout Itemize
1664 y0: The smallest bitmap y coordinate to draw.
1665 \end_layout
1667 \begin_layout Itemize
1668 width: Width of region to draw
1669 \end_layout
1671 \begin_layout Itemize
1672 height: Height of region to draw.
1673 \end_layout
1675 \begin_layout Standard
1676 Like bitmap:draw, but clip the bitmap area drawn.
1677 \end_layout
1679 \begin_layout Subsubsection
1680 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1681 \end_layout
1683 \begin_layout Itemize
1684 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1685 \end_layout
1687 \begin_layout Standard
1688 Like bitmap:draw_clip, but only draw outside game area.
1689 \end_layout
1691 \begin_layout Subsubsection
1692 Method pset: Set pixel in bitmap
1693 \end_layout
1695 \begin_layout Itemize
1696 Syntax: bitmap:pset(x, y, color)
1697 \end_layout
1699 \begin_layout Itemize
1700 Deprecaed: gui.bitmap_pset(bitmap, ...)
1701 \end_layout
1703 \begin_layout Standard
1704 Parameters:
1705 \end_layout
1707 \begin_layout Itemize
1708 bitmap: BITMAP: The bitmap to manipulate.
1709 \end_layout
1711 \begin_layout Itemize
1712 x: number: x-coordinate of pixel to set.
1713 \end_layout
1715 \begin_layout Itemize
1716 y: number: y-coordinate of pixel to set.
1717 \end_layout
1719 \begin_layout Itemize
1720 color: number: The color index to set.
1721 \end_layout
1723 \begin_layout Standard
1724 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1725 \end_layout
1727 \begin_layout Subsubsection
1728 Method pget: Get pixel in bitmap
1729 \end_layout
1731 \begin_layout Itemize
1732 Syntax: color bitmap:pget(x,y)
1733 \end_layout
1735 \begin_layout Itemize
1736 Deprecated: color gui.bitmap_pget(bitmap, ...)
1737 \end_layout
1739 \begin_layout Standard
1740 Parameters:
1741 \end_layout
1743 \begin_layout Itemize
1744 bitmap: BITMAP: The bitmap to query.
1745 \end_layout
1747 \begin_layout Itemize
1748 x: number: x-coordinate of pixel to get.
1749 \end_layout
1751 \begin_layout Itemize
1752 y: number: y-coordinate of pixel to get.
1753 \end_layout
1755 \begin_layout Standard
1756 Returns:
1757 \end_layout
1759 \begin_layout Itemize
1760 color: number: The color index in specified pixel.
1761 \end_layout
1763 \begin_layout Standard
1764 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1765 \end_layout
1767 \begin_layout Subsubsection
1768 Method size: Get size of bitmap
1769 \end_layout
1771 \begin_layout Itemize
1772 Syntax: width, height bitmap:size()
1773 \end_layout
1775 \begin_layout Itemize
1776 Syntax: width, height gui.bitmap_size(bitmap)
1777 \end_layout
1779 \begin_layout Standard
1780 Parameters:
1781 \end_layout
1783 \begin_layout Itemize
1784 bitmap: BITMAP: The bitmap to query.
1785 \end_layout
1787 \begin_layout Standard
1788 Returns:
1789 \end_layout
1791 \begin_layout Itemize
1792 width: number: The width of the bitmap.
1793 \end_layout
1795 \begin_layout Itemize
1796 height: number: The height of the bitmap.
1797 \end_layout
1799 \begin_layout Standard
1800 Get size of bitmap <bitmap>.
1801 \end_layout
1803 \begin_layout Subsubsection
1804 Method blit: Blit a bitmap into another
1805 \end_layout
1807 \begin_layout Itemize
1808 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1809 \end_layout
1811 \begin_layout Itemize
1812 Deprecated: gui.bitmap_blit(dest, ...)
1813 \end_layout
1815 \begin_layout Standard
1816 Parameters:
1817 \end_layout
1819 \begin_layout Itemize
1820 dest: BITMAP: The target bitmap to blit to.
1821 \end_layout
1823 \begin_layout Itemize
1824 dx: number: The x-coordinate in target.
1825 \end_layout
1827 \begin_layout Itemize
1828 dy: number: The y-coordinate in target.
1829 \end_layout
1831 \begin_layout Itemize
1832 src: BITMAP: The source bitmap.
1833 \end_layout
1835 \begin_layout Itemize
1836 sx: number: The x-coordinate in source.
1837 \end_layout
1839 \begin_layout Itemize
1840 sy: number: The y-coordinate in source.
1841 \end_layout
1843 \begin_layout Itemize
1844 w: number: The width of area to blit.
1845 \end_layout
1847 \begin_layout Itemize
1848 h: number: The height of area to blit.
1849 \end_layout
1851 \begin_layout Itemize
1852 ck: number: The color key.
1853  Pixels with this index are not copied.
1854 \end_layout
1856 \begin_deeper
1857 \begin_layout Itemize
1858 If none is specified, all pixels are copied.
1859 \end_layout
1861 \end_deeper
1862 \begin_layout Standard
1863 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1864  <dx>,<dy>.
1865  If a color key <ck> is specified, pixels of that color are not copied.
1866 \end_layout
1868 \begin_layout Subsubsection
1869 Method blit_scaled: Blit a bitmap into another with scaling
1870 \end_layout
1872 \begin_layout Itemize
1873 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1874 \end_layout
1876 \begin_layout Itemize
1877 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1878 \end_layout
1880 \begin_layout Standard
1881 Parameters:
1882 \end_layout
1884 \begin_layout Itemize
1885 dest: BITMAP: The target bitmap to blit to.
1886 \end_layout
1888 \begin_layout Itemize
1889 dx: number: The x-coordinate in target.
1890 \end_layout
1892 \begin_layout Itemize
1893 dy: number: The y-coordinate in target.
1894 \end_layout
1896 \begin_layout Itemize
1897 src: BITMAP: The source bitmap.
1898 \end_layout
1900 \begin_layout Itemize
1901 sx: number: The x-coordinate in source.
1902 \end_layout
1904 \begin_layout Itemize
1905 sy: number: The y-coordinate in source.
1906 \end_layout
1908 \begin_layout Itemize
1909 w: number: The width of area to blit.
1910 \end_layout
1912 \begin_layout Itemize
1913 h: number: The height of area to blit.
1914 \end_layout
1916 \begin_layout Itemize
1917 hscl: number: Horizontal scale factor (integer).
1918 \end_layout
1920 \begin_layout Itemize
1921 vscl: number: Vertical scale factor (integer).
1922  Defaults to the same as <hscl>.
1923 \end_layout
1925 \begin_layout Itemize
1926 ck: number: The color key.
1927  Pixels with this index are not copied.
1928 \end_layout
1930 \begin_deeper
1931 \begin_layout Itemize
1932 If none is specified, all pixels are copied.
1933 \end_layout
1935 \end_deeper
1936 \begin_layout Standard
1937 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1938  neighbor) by factor of <hscl>*<vscl>.
1939 \end_layout
1941 \begin_layout Subsubsection
1942 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1943 \end_layout
1945 \begin_layout Itemize
1946 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1947 \end_layout
1949 \begin_layout Itemize
1950 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1951 \end_layout
1953 \begin_layout Standard
1954 Parameters:
1955 \end_layout
1957 \begin_layout Itemize
1958 dest: BITMAP: The target bitmap to blit to.
1959 \end_layout
1961 \begin_layout Itemize
1962 dx: number: The x-coordinate in target.
1963 \end_layout
1965 \begin_layout Itemize
1966 dy: number: The y-coordinate in target.
1967 \end_layout
1969 \begin_layout Itemize
1970 src: BITMAP: The source bitmap.
1971 \end_layout
1973 \begin_layout Itemize
1974 sx: number: The x-coordinate in source.
1975 \end_layout
1977 \begin_layout Itemize
1978 sy: number: The y-coordinate in source.
1979 \end_layout
1981 \begin_layout Itemize
1982 w: number: The width of area to blit.
1983 \end_layout
1985 \begin_layout Itemize
1986 h: number: The height of area to blit.
1987 \end_layout
1989 \begin_layout Itemize
1990 operator: string: The operator to use.
1991 \end_layout
1993 \begin_deeper
1994 \begin_layout Itemize
1995 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
1996  DestOut, Clear or Xor.
1997 \end_layout
1999 \end_deeper
2000 \begin_layout Standard
2001 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2002  operator.
2004 \end_layout
2006 \begin_layout Itemize
2007 Color index 0 in source and target is treated as background.
2008 \end_layout
2010 \begin_layout Subsubsection
2011 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2012  Porter-Duff composition
2013 \end_layout
2015 \begin_layout Itemize
2016 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2017  operator)
2018 \end_layout
2020 \begin_layout Itemize
2021 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2022 \end_layout
2024 \begin_layout Standard
2025 Parameters:
2026 \end_layout
2028 \begin_layout Itemize
2029 dest: BITMAP: The target bitmap to blit to.
2030 \end_layout
2032 \begin_layout Itemize
2033 dx: number: The x-coordinate in target.
2034 \end_layout
2036 \begin_layout Itemize
2037 dy: number: The y-coordinate in target.
2038 \end_layout
2040 \begin_layout Itemize
2041 src: BITMAP: The source bitmap.
2042 \end_layout
2044 \begin_layout Itemize
2045 sx: number: The x-coordinate in source.
2046 \end_layout
2048 \begin_layout Itemize
2049 sy: number: The y-coordinate in source.
2050 \end_layout
2052 \begin_layout Itemize
2053 w: number: The width of area to blit.
2054 \end_layout
2056 \begin_layout Itemize
2057 h: number: The height of area to blit.
2058 \end_layout
2060 \begin_layout Itemize
2061 hscl: number: Horizontal scale factor (integer).
2062 \end_layout
2064 \begin_layout Itemize
2065 vscl: number: Vertical scale factor (integer).
2066  Defaults to the same as <hscl>.
2067 \end_layout
2069 \begin_layout Itemize
2070 operator: string: The operator to use.
2071 \end_layout
2073 \begin_deeper
2074 \begin_layout Itemize
2075 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2076  DestOut, Clear or Xor.
2077 \end_layout
2079 \end_deeper
2080 \begin_layout Standard
2081 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2082  like BITMAP:blit_scaled.
2083 \end_layout
2085 \begin_layout Subsubsection
2086 Method blit_priority: Blit a bitmap into another with color priority
2087 \end_layout
2089 \begin_layout Itemize
2090 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2091 \end_layout
2093 \begin_layout Itemize
2094 Deprecated: gui.bitmap_blit_priority(dest, ...)
2095 \end_layout
2097 \begin_layout Standard
2098 Parameters:
2099 \end_layout
2101 \begin_layout Itemize
2102 dest: BITMAP: The target bitmap to blit to.
2103 \end_layout
2105 \begin_layout Itemize
2106 dx: number: The x-coordinate in target.
2107 \end_layout
2109 \begin_layout Itemize
2110 dy: number: The y-coordinate in target.
2111 \end_layout
2113 \begin_layout Itemize
2114 src: BITMAP: The source bitmap.
2115 \end_layout
2117 \begin_layout Itemize
2118 sx: number: The x-coordinate in source.
2119 \end_layout
2121 \begin_layout Itemize
2122 sy: number: The y-coordinate in source.
2123 \end_layout
2125 \begin_layout Itemize
2126 w: number: The width of area to blit.
2127 \end_layout
2129 \begin_layout Itemize
2130 h: number: The height of area to blit.
2131 \end_layout
2133 \begin_layout Standard
2134 Like BITMAP:blit, but only copy pixels where source color index is greater
2135  than destination color index.
2136 \end_layout
2138 \begin_layout Subsubsection
2139 Method blit_scaled_priority: Blit a bitmap into another with color priority
2140  and scaling
2141 \end_layout
2143 \begin_layout Itemize
2144 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2145 \end_layout
2147 \begin_layout Itemize
2148 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2149 \end_layout
2151 \begin_layout Standard
2152 Parameters:
2153 \end_layout
2155 \begin_layout Itemize
2156 dest: BITMAP: The target bitmap to blit to.
2157 \end_layout
2159 \begin_layout Itemize
2160 dx: number: The x-coordinate in target.
2161 \end_layout
2163 \begin_layout Itemize
2164 dy: number: The y-coordinate in target.
2165 \end_layout
2167 \begin_layout Itemize
2168 src: BITMAP: The source bitmap.
2169 \end_layout
2171 \begin_layout Itemize
2172 sx: number: The x-coordinate in source.
2173 \end_layout
2175 \begin_layout Itemize
2176 sy: number: The y-coordinate in source.
2177 \end_layout
2179 \begin_layout Itemize
2180 w: number: The width of area to blit.
2181 \end_layout
2183 \begin_layout Itemize
2184 h: number: The height of area to blit.
2185 \end_layout
2187 \begin_layout Itemize
2188 hscl: number: Horizontal scale factor (integer).
2189 \end_layout
2191 \begin_layout Itemize
2192 vscl: number: Vertical scale factor (integer).
2193  Defaults to the same as <hscl>.
2194 \end_layout
2196 \begin_layout Standard
2197 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2198 caled.
2199 \end_layout
2201 \begin_layout Subsubsection
2202 Method save_png: Save a bitmap to PNG
2203 \end_layout
2205 \begin_layout Itemize
2206 Syntax: bitmap:save_png(filename, [base], palette)
2207 \end_layout
2209 \begin_layout Itemize
2210 Syntax: data bitmap:save_png(palette)
2211 \end_layout
2213 \begin_layout Itemize
2214 Deprecated: ...
2215  gui.bitmap_save_png(bitmap, ...)
2216 \end_layout
2218 \begin_layout Standard
2219 Parameters:
2220 \end_layout
2222 \begin_layout Itemize
2223 bitmap: BITMAP: The bitmap to save.
2224 \end_layout
2226 \begin_layout Itemize
2227 filename: string: The filename to save to.
2228 \end_layout
2230 \begin_layout Itemize
2231 base: string: The base filename is resolved relative to.
2232 \end_layout
2234 \begin_layout Itemize
2235 palette: PALETTE: The palette to use.
2236 \end_layout
2238 \begin_layout Standard
2239 Return value:
2240 \end_layout
2242 \begin_layout Itemize
2243 data: string: BASE64 encoded PNG data.
2244 \end_layout
2246 \begin_layout Standard
2247 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2248  to <base>) or return BASE64 encoding of it.
2249 \end_layout
2251 \begin_layout Subsubsection
2252 Method hash: Hash a bitmap
2253 \end_layout
2255 \begin_layout Itemize
2256 Syntax: hash bitmap:hash()
2257 \end_layout
2259 \begin_layout Itemize
2260 Deprecated: hash bitmap:hash(bitmap)
2261 \end_layout
2263 \begin_layout Standard
2264 Parameters:
2265 \end_layout
2267 \begin_layout Itemize
2268 bitmap: BITMAP: The bitmap to hash.
2269 \end_layout
2271 \begin_layout Standard
2272 Return value:
2273 \end_layout
2275 \begin_layout Itemize
2276 hash: string: 64-hex digit hash
2277 \end_layout
2279 \begin_layout Standard
2280 Hashes bitmap <bitmap> and returns crypto-strong hash.
2282 \end_layout
2284 \begin_layout Itemize
2285 Color order in bitmap is significant.
2286 \end_layout
2288 \begin_layout Standard
2289 \begin_inset Newpage pagebreak
2290 \end_inset
2293 \end_layout
2295 \begin_layout Subsection
2296 DBITMAP: Direct-color bitmap
2297 \end_layout
2299 \begin_layout Subsubsection
2300 Static function: new: Create a new bitmap
2301 \end_layout
2303 \begin_layout Itemize
2304 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2305 \end_layout
2307 \begin_layout Itemize
2308 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2309 \end_layout
2311 \begin_layout Itemize
2312 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2313 \end_layout
2315 \begin_layout Standard
2316 Parameters:
2317 \end_layout
2319 \begin_layout Itemize
2320 w: number: The width of new bitmap.
2321 \end_layout
2323 \begin_layout Itemize
2324 h: number: The height of new bitmap.
2325 \end_layout
2327 \begin_layout Itemize
2328 true: boolean: Fixed boolean true
2329 \end_layout
2331 \begin_layout Itemize
2332 fillcolor: The color to fill the bitmap with (default transparent).
2333 \end_layout
2335 \begin_layout Standard
2336 Return value:
2337 \end_layout
2339 \begin_layout Itemize
2340 bitmap: DBITMAP: The new bitmap.
2341 \end_layout
2343 \begin_layout Standard
2344 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2345  <fillcolor>.
2346 \end_layout
2348 \begin_layout Subsubsection
2349 Method draw: Draw a bitmap
2350 \end_layout
2352 \begin_layout Itemize
2353 Syntax: bitmap.draw(x, y)
2354 \end_layout
2356 \begin_layout Itemize
2357 Deprecated: gui.bitmap_draw(x, y, bitmap)
2358 \end_layout
2360 \begin_layout Standard
2361 Parameters:
2362 \end_layout
2364 \begin_layout Itemize
2365 bitmap: DBITMAP: The bitmap to draw.
2366 \end_layout
2368 \begin_layout Itemize
2369 x: number: X-coordinate on screen.
2370 \end_layout
2372 \begin_layout Itemize
2373 y: number: Y-coordinate on screen.
2374 \end_layout
2376 \begin_layout Standard
2377 Draw bitmap <bitmap> on screen at <x>,<y>.
2378 \end_layout
2380 \begin_layout Subsubsection
2381 Method draw_outside: Draw a bitmap outside game area
2382 \end_layout
2384 \begin_layout Itemize
2385 Syntax: dbitmap:draw_outside(x, y, palette)
2386 \end_layout
2388 \begin_layout Standard
2389 Like dbitmap:draw, but does not draw on game area.
2390 \end_layout
2392 \begin_layout Subsubsection
2393 Method draw_clip: Draw a bitmap, with clipping
2394 \end_layout
2396 \begin_layout Itemize
2397 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2398 \end_layout
2400 \begin_layout Standard
2401 Parameters:
2402 \end_layout
2404 \begin_layout Itemize
2405 bitmap: DBITMAP: The bitmap to draw
2406 \end_layout
2408 \begin_layout Itemize
2409 x: number: The x-coordinate on screen.
2410 \end_layout
2412 \begin_layout Itemize
2413 y: number: The y-coordinate on screen.
2414 \end_layout
2416 \begin_layout Itemize
2417 x0: The smallest bitmap x coordinate to draw.
2418 \end_layout
2420 \begin_layout Itemize
2421 y0: The smallest bitmap y coordinate to draw.
2422 \end_layout
2424 \begin_layout Itemize
2425 width: Width of region to draw
2426 \end_layout
2428 \begin_layout Itemize
2429 height: Height of region to draw.
2430 \end_layout
2432 \begin_layout Standard
2433 Like dbitmap:draw, but clip the bitmap area drawn.
2434 \end_layout
2436 \begin_layout Subsubsection
2437 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2438 \end_layout
2440 \begin_layout Itemize
2441 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2442 \end_layout
2444 \begin_layout Standard
2445 Like dbitmap:draw_clip, but only draw outside game area.
2446 \end_layout
2448 \begin_layout Subsubsection
2449 Method pset: Set pixel in bitmap
2450 \end_layout
2452 \begin_layout Itemize
2453 Syntax: bitmap:pset(x, y, color)
2454 \end_layout
2456 \begin_layout Itemize
2457 Deprecaed: gui.bitmap_pset(bitmap, ...)
2458 \end_layout
2460 \begin_layout Standard
2461 Parameters:
2462 \end_layout
2464 \begin_layout Itemize
2465 bitmap: DBITMAP: The bitmap to manipulate.
2466 \end_layout
2468 \begin_layout Itemize
2469 x: number: x-coordinate of pixel to set.
2470 \end_layout
2472 \begin_layout Itemize
2473 y: number: y-coordinate of pixel to set.
2474 \end_layout
2476 \begin_layout Itemize
2477 color: number/string: The color to set.
2478 \end_layout
2480 \begin_layout Standard
2481 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2482 \end_layout
2484 \begin_layout Subsubsection
2485 Method pget: Get pixel in bitmap
2486 \end_layout
2488 \begin_layout Itemize
2489 Syntax: color bitmap:pget(x,y)
2490 \end_layout
2492 \begin_layout Itemize
2493 Deprecated: color gui.bitmap_pget(bitmap, ...)
2494 \end_layout
2496 \begin_layout Standard
2497 Parameters:
2498 \end_layout
2500 \begin_layout Itemize
2501 bitmap: DBITMAP: The bitmap to query.
2502 \end_layout
2504 \begin_layout Itemize
2505 x: number: x-coordinate of pixel to get.
2506 \end_layout
2508 \begin_layout Itemize
2509 y: number: y-coordinate of pixel to get.
2510 \end_layout
2512 \begin_layout Standard
2513 Returns:
2514 \end_layout
2516 \begin_layout Itemize
2517 color: number: The color of specified pixel.
2518 \end_layout
2520 \begin_layout Standard
2521 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2522 \end_layout
2524 \begin_layout Subsubsection
2525 Method size: Get size of bitmap
2526 \end_layout
2528 \begin_layout Itemize
2529 Syntax: width, height bitmap:size()
2530 \end_layout
2532 \begin_layout Itemize
2533 Syntax: width, height gui.bitmap_size(bitmap)
2534 \end_layout
2536 \begin_layout Standard
2537 Parameters:
2538 \end_layout
2540 \begin_layout Itemize
2541 bitmap: DBITMAP: The bitmap to query.
2542 \end_layout
2544 \begin_layout Standard
2545 Returns:
2546 \end_layout
2548 \begin_layout Itemize
2549 width: number: The width of the bitmap.
2550 \end_layout
2552 \begin_layout Itemize
2553 height: number: The height of the bitmap.
2554 \end_layout
2556 \begin_layout Standard
2557 Get size of bitmap <bitmap>.
2558 \end_layout
2560 \begin_layout Subsubsection
2561 Method blit: Blit a bitmap into another
2562 \end_layout
2564 \begin_layout Itemize
2565 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2566 \end_layout
2568 \begin_layout Itemize
2569 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2570 \end_layout
2572 \begin_layout Itemize
2573 Deprecated: gui.bitmap_blit(dest, ...)
2574 \end_layout
2576 \begin_layout Standard
2577 Parameters:
2578 \end_layout
2580 \begin_layout Itemize
2581 dest: DBITMAP: The target bitmap to blit to.
2582 \end_layout
2584 \begin_layout Itemize
2585 dx: number: The x-coordinate in target.
2586 \end_layout
2588 \begin_layout Itemize
2589 dy: number: The y-coordinate in target.
2590 \end_layout
2592 \begin_layout Itemize
2593 src: BITMAP/DBITMAP: The source bitmap.
2594 \end_layout
2596 \begin_layout Itemize
2597 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2598 \end_layout
2600 \begin_layout Itemize
2601 sx: number: The x-coordinate in source.
2602 \end_layout
2604 \begin_layout Itemize
2605 sy: number: The y-coordinate in source.
2606 \end_layout
2608 \begin_layout Itemize
2609 w: number: The width of area to blit.
2610 \end_layout
2612 \begin_layout Itemize
2613 h: number: The height of area to blit.
2614 \end_layout
2616 \begin_layout Itemize
2617 ck: number: The color key.
2618  Pixels with this index are not copied.
2619 \end_layout
2621 \begin_deeper
2622 \begin_layout Itemize
2623 If none is specified, all pixels are copied.
2624 \end_layout
2626 \begin_layout Itemize
2627 If <src> is paletted, this is color index, otherwise it is a color.
2628 \end_layout
2630 \end_deeper
2631 \begin_layout Standard
2632 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2633  if indexed) into <dest> at <dx>,<dy>.
2634  If a color key <ck> is specified, pixels of that color are not copied.
2635 \end_layout
2637 \begin_layout Subsubsection
2638 Method blit_scaled: Blit a bitmap into another with scaling
2639 \end_layout
2641 \begin_layout Itemize
2642 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2643 \end_layout
2645 \begin_layout Itemize
2646 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2647  [ck])
2648 \end_layout
2650 \begin_layout Itemize
2651 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2652 \end_layout
2654 \begin_layout Standard
2655 Parameters:
2656 \end_layout
2658 \begin_layout Itemize
2659 dest: DBITMAP: The target bitmap to blit to.
2660 \end_layout
2662 \begin_layout Itemize
2663 dx: number: The x-coordinate in target.
2664 \end_layout
2666 \begin_layout Itemize
2667 dy: number: The y-coordinate in target.
2668 \end_layout
2670 \begin_layout Itemize
2671 src: BITMAP/DBITMAP: The source bitmap.
2672 \end_layout
2674 \begin_layout Itemize
2675 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2676 \end_layout
2678 \begin_layout Itemize
2679 sx: number: The x-coordinate in source.
2680 \end_layout
2682 \begin_layout Itemize
2683 sy: number: The y-coordinate in source.
2684 \end_layout
2686 \begin_layout Itemize
2687 w: number: The width of area to blit.
2688 \end_layout
2690 \begin_layout Itemize
2691 h: number: The height of area to blit.
2692 \end_layout
2694 \begin_layout Itemize
2695 hscl: number: Horizontal scale factor (integer).
2696 \end_layout
2698 \begin_layout Itemize
2699 vscl: number: Vertical scale factor (integer).
2700  Defaults to the same as <hscl>.
2701 \end_layout
2703 \begin_layout Itemize
2704 ck: number: The color key.
2705  Pixels with this index are not copied.
2706 \end_layout
2708 \begin_deeper
2709 \begin_layout Itemize
2710 If none is specified, all pixels are copied.
2711 \end_layout
2713 \begin_layout Itemize
2714 If <src> is paletted, this is color index, otherwise it is a color.
2715 \end_layout
2717 \end_deeper
2718 \begin_layout Standard
2719 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2720  neighbor) by factor of <hscl>*<vscl>.
2721 \end_layout
2723 \begin_layout Subsubsection
2724 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2725 \end_layout
2727 \begin_layout Itemize
2728 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2729 \end_layout
2731 \begin_layout Itemize
2732 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2733 \end_layout
2735 \begin_layout Itemize
2736 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2737 \end_layout
2739 \begin_layout Standard
2740 Parameters:
2741 \end_layout
2743 \begin_layout Itemize
2744 dest: DBITMAP: The target bitmap to blit to.
2745 \end_layout
2747 \begin_layout Itemize
2748 dx: number: The x-coordinate in target.
2749 \end_layout
2751 \begin_layout Itemize
2752 dy: number: The y-coordinate in target.
2753 \end_layout
2755 \begin_layout Itemize
2756 src: BITMAP/DBITMAP: The source bitmap.
2757 \end_layout
2759 \begin_layout Itemize
2760 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2761 \end_layout
2763 \begin_layout Itemize
2764 sx: number: The x-coordinate in source.
2765 \end_layout
2767 \begin_layout Itemize
2768 sy: number: The y-coordinate in source.
2769 \end_layout
2771 \begin_layout Itemize
2772 w: number: The width of area to blit.
2773 \end_layout
2775 \begin_layout Itemize
2776 h: number: The height of area to blit.
2777 \end_layout
2779 \begin_layout Itemize
2780 operator: string: The operator to use.
2781 \end_layout
2783 \begin_deeper
2784 \begin_layout Itemize
2785 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2786  DestOut, Clear or Xor.
2787 \end_layout
2789 \end_deeper
2790 \begin_layout Standard
2791 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2792 f operator.
2794 \end_layout
2796 \begin_layout Itemize
2797 In target, fully transparent is background.
2798  In source, either fully transparent (if direct) or index 0 (if paletted)
2799  is treated as background.
2800 \end_layout
2802 \begin_layout Subsubsection
2803 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2804  Porter-Duff composition
2805 \end_layout
2807 \begin_layout Itemize
2808 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2809  operator)
2810 \end_layout
2812 \begin_layout Itemize
2813 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2814  [vscl], operator)
2815 \end_layout
2817 \begin_layout Itemize
2818 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2819 \end_layout
2821 \begin_layout Standard
2822 Parameters:
2823 \end_layout
2825 \begin_layout Itemize
2826 dest: DBITMAP: The target bitmap to blit to.
2827 \end_layout
2829 \begin_layout Itemize
2830 dx: number: The x-coordinate in target.
2831 \end_layout
2833 \begin_layout Itemize
2834 dy: number: The y-coordinate in target.
2835 \end_layout
2837 \begin_layout Itemize
2838 src: BITMAP/DBITMAP: The source bitmap.
2839 \end_layout
2841 \begin_layout Itemize
2842 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2843 \end_layout
2845 \begin_layout Itemize
2846 sx: number: The x-coordinate in source.
2847 \end_layout
2849 \begin_layout Itemize
2850 sy: number: The y-coordinate in source.
2851 \end_layout
2853 \begin_layout Itemize
2854 w: number: The width of area to blit.
2855 \end_layout
2857 \begin_layout Itemize
2858 h: number: The height of area to blit.
2859 \end_layout
2861 \begin_layout Itemize
2862 hscl: number: Horizontal scale factor (integer).
2863 \end_layout
2865 \begin_layout Itemize
2866 vscl: number: Vertical scale factor (integer).
2867  Defaults to the same as <hscl>.
2868 \end_layout
2870 \begin_layout Itemize
2871 operator: string: The operator to use.
2872 \end_layout
2874 \begin_deeper
2875 \begin_layout Itemize
2876 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2877  DestOut, Clear or Xor.
2878 \end_layout
2880 \end_deeper
2881 \begin_layout Standard
2882 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2883  like DBITMAP:blit_scaled.
2884 \end_layout
2886 \begin_layout Subsubsection
2887 Method adjust_transparency: Adjust transparency of bitmap
2888 \end_layout
2890 \begin_layout Itemize
2891 Syntax: bitmap:adjust_transparency(newvalue)
2892 \end_layout
2894 \begin_layout Itemize
2895 Deprecated: gui.adjust_transparency(bitmap, ...)
2896 \end_layout
2898 \begin_layout Standard
2899 Parameters:
2900 \end_layout
2902 \begin_layout Itemize
2903 bitmap: DBITMAP: The bitmap to adjust.
2904 \end_layout
2906 \begin_layout Itemize
2907 Number adj: The factor to multiply opaqueness with times 256.
2908 \end_layout
2910 \begin_layout Standard
2911 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2912 \end_layout
2914 \begin_layout Subsubsection
2915 Method save_png: Save a bitmap to PNG
2916 \end_layout
2918 \begin_layout Itemize
2919 Syntax: bitmap:save_png(filename, [base])
2920 \end_layout
2922 \begin_layout Itemize
2923 Syntax: data bitmap:save_png()
2924 \end_layout
2926 \begin_layout Itemize
2927 Deprecated: ...
2928  gui.bitmap_save_png(bitmap, ...)
2929 \end_layout
2931 \begin_layout Standard
2932 Parameters:
2933 \end_layout
2935 \begin_layout Itemize
2936 bitmap: DBITMAP: The bitmap to save.
2937 \end_layout
2939 \begin_layout Itemize
2940 filename: string: The filename to save to.
2941 \end_layout
2943 \begin_layout Itemize
2944 base: string: The base filename is resolved relative to.
2945 \end_layout
2947 \begin_layout Standard
2948 Return value:
2949 \end_layout
2951 \begin_layout Itemize
2952 data: string: BASE64 encoded PNG data.
2953 \end_layout
2955 \begin_layout Standard
2956 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2957  BASE64 encoding of it.
2958 \end_layout
2960 \begin_layout Subsubsection
2961 Method hash: Hash a bitmap
2962 \end_layout
2964 \begin_layout Itemize
2965 Syntax: hash bitmap:hash()
2966 \end_layout
2968 \begin_layout Itemize
2969 Deprecated: hash bitmap:hash(bitmap)
2970 \end_layout
2972 \begin_layout Standard
2973 Parameters:
2974 \end_layout
2976 \begin_layout Itemize
2977 bitmap: DBITMAP: The bitmap to hash.
2978 \end_layout
2980 \begin_layout Standard
2981 Return value:
2982 \end_layout
2984 \begin_layout Itemize
2985 hash: string: 64-hex digit hash
2986 \end_layout
2988 \begin_layout Standard
2989 Hashes bitmap <bitmap> and returns crypto-strong hash.
2991 \end_layout
2993 \begin_layout Subsection
2994 IMAGELOADER: Load an image
2995 \end_layout
2997 \begin_layout Subsubsection
2998 Static function load: Load a bitmap from file
2999 \end_layout
3001 \begin_layout Itemize
3002 Syntax: bitmap, palette gui.image.load(file, [base])
3003 \end_layout
3005 \begin_layout Itemize
3006 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3007 \end_layout
3009 \begin_layout Itemize
3010 Deprecated: ...
3011  gui.bitmap_load(...)
3012 \end_layout
3014 \begin_layout Standard
3015 Parameters:
3016 \end_layout
3018 \begin_layout Itemize
3019 file: string: The file to read.
3020 \end_layout
3022 \begin_layout Itemize
3023 base: string: The base to resolve <file> relative to.
3024 \end_layout
3026 \begin_layout Standard
3027 Returns:
3028 \end_layout
3030 \begin_layout Itemize
3031 bitmap: BITMAP/DBITMAP: The new bitmap
3032 \end_layout
3034 \begin_layout Itemize
3035 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3036  nil.
3037 \end_layout
3039 \begin_layout Standard
3040 Load a new bitmap and return it (plus associated palette if any).
3041 \end_layout
3043 \begin_layout Subsubsection
3044 Static function load_str: Load a bitmap from string
3045 \end_layout
3047 \begin_layout Itemize
3048 Syntax: bitmap, palette gui.image.load_str(data)
3049 \end_layout
3051 \begin_layout Itemize
3052 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3053 \end_layout
3055 \begin_layout Itemize
3056 Deprecated: ...
3057  gui.bitmap_load_str(...)
3058 \end_layout
3060 \begin_layout Standard
3061 Parameters:
3062 \end_layout
3064 \begin_layout Itemize
3065 data: string: The image data
3066 \end_layout
3068 \begin_layout Standard
3069 Returns:
3070 \end_layout
3072 \begin_layout Itemize
3073 bitmap: BITMAP/DBITMAP: The new bitmap
3074 \end_layout
3076 \begin_layout Itemize
3077 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3078  nil.
3079 \end_layout
3081 \begin_layout Standard
3082 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3083  file.
3084 \end_layout
3086 \begin_layout Subsubsection
3087 Static function load_png: Load a bitmap from PNG file
3088 \end_layout
3090 \begin_layout Itemize
3091 Syntax: bitmap, palette gui.image.load_png(file, [base])
3092 \end_layout
3094 \begin_layout Itemize
3095 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3096 \end_layout
3098 \begin_layout Itemize
3099 Deprecated: ...
3100  gui.bitmap_load_png(...)
3101 \end_layout
3103 \begin_layout Standard
3104 Parameters:
3105 \end_layout
3107 \begin_layout Itemize
3108 file: string: The file to read.
3109 \end_layout
3111 \begin_layout Itemize
3112 base: string: The base to resolve <file> relative to.
3113 \end_layout
3115 \begin_layout Standard
3116 Returns:
3117 \end_layout
3119 \begin_layout Itemize
3120 bitmap: BITMAP/DBITMAP: The new bitmap
3121 \end_layout
3123 \begin_layout Itemize
3124 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3125  nil.
3126 \end_layout
3128 \begin_layout Standard
3129 Like IMAGELOADER:load, but load a PNG file instead.
3130 \end_layout
3132 \begin_layout Subsubsection
3133 Static function load_png_str: Load a PNG bitmap from string
3134 \end_layout
3136 \begin_layout Itemize
3137 Syntax: bitmap, palette gui.image.load_png_str(data)
3138 \end_layout
3140 \begin_layout Itemize
3141 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3142 \end_layout
3144 \begin_layout Itemize
3145 Deprecated: ...
3146  gui.bitmap_load_png_str(...)
3147 \end_layout
3149 \begin_layout Standard
3150 Parameters:
3151 \end_layout
3153 \begin_layout Itemize
3154 data: string: The image data, base64 encoded.
3155 \end_layout
3157 \begin_layout Standard
3158 Returns:
3159 \end_layout
3161 \begin_layout Itemize
3162 bitmap: BITMAP/DBITMAP: The new bitmap
3163 \end_layout
3165 \begin_layout Itemize
3166 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3167  nil.
3168 \end_layout
3170 \begin_layout Standard
3171 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3172  <data> instead of file.
3173 \end_layout
3175 \begin_layout Standard
3176 \begin_inset Newpage pagebreak
3177 \end_inset
3180 \end_layout
3182 \begin_layout Subsection
3183 CUSTOMFONT: Arbitrary-sized bitmap font
3184 \end_layout
3186 \begin_layout Subsubsection
3187 Static function new: Return a new empty font
3188 \end_layout
3190 \begin_layout Itemize
3191 Syntax: font gui.font.new()
3192 \end_layout
3194 \begin_layout Itemize
3195 Syntax: font classes.CUSTOMFONT.new()
3196 \end_layout
3198 \begin_layout Itemize
3199 Deprecated: font gui.font_new()
3200 \end_layout
3202 \begin_layout Standard
3203 Return value:
3204 \end_layout
3206 \begin_layout Itemize
3207 font: CUSTOMFONT: New font.
3208 \end_layout
3210 \begin_layout Standard
3211 Create a new font with no characters and return it.
3212 \end_layout
3214 \begin_layout Subsubsection
3215 Static function: load: Load a font file
3216 \end_layout
3218 \begin_layout Itemize
3219 Syntax: font gui.font.load(file, [base])
3220 \end_layout
3222 \begin_layout Itemize
3223 Syntax: font gui.font.load()
3224 \end_layout
3226 \begin_layout Itemize
3227 Syntax: font classes.CUSTOMFONT.load(file, [base])
3228 \end_layout
3230 \begin_layout Itemize
3231 Syntax: font classes.CUSTOMFONT.load()
3232 \end_layout
3234 \begin_layout Itemize
3235 Deprecated: font gui.loadfont(...)
3236 \end_layout
3238 \begin_layout Standard
3239 Parameters:
3240 \end_layout
3242 \begin_layout Itemize
3243 file: string: The file to read the font from
3244 \end_layout
3246 \begin_layout Itemize
3247 base: string: The file to resolve <file> relative to.
3248 \end_layout
3250 \begin_layout Standard
3251 Return value:
3252 \end_layout
3254 \begin_layout Itemize
3255 font: CUSTOMFONT: New font.
3256 \end_layout
3258 \begin_layout Standard
3259 Load font from file <file> (relative to <base>).
3260  If no filename is given, system default font is loaded.
3261 \end_layout
3263 \begin_layout Subsubsection
3264 operator(): Render text to screen
3265 \end_layout
3267 \begin_layout Itemize
3268 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3269 \end_layout
3271 \begin_layout Standard
3272 Parmeters:
3273 \end_layout
3275 \begin_layout Itemize
3276 font: CUSTOMFONT: The font to use.
3277 \end_layout
3279 \begin_layout Itemize
3280 x: number: The x-position on screen to draw to.
3281 \end_layout
3283 \begin_layout Itemize
3284 y: number: The y-position on screen to draw to.
3285 \end_layout
3287 \begin_layout Itemize
3288 text: string: The text to draw.
3289 \end_layout
3291 \begin_layout Itemize
3292 fgc: number/string: Foreground color (default white).
3293 \end_layout
3295 \begin_layout Itemize
3296 bgc: number/string: Background color (default transparent).
3297 \end_layout
3299 \begin_layout Itemize
3300 hlc: number/string: Outline color (default transparent).
3301 \end_layout
3303 \begin_layout Standard
3304 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3305  onto screen.
3306 \end_layout
3308 \begin_layout Itemize
3309 If <hlc> is transparent, no outline is drawn.
3310 \end_layout
3312 \begin_layout Subsubsection
3313 Method edit: Alter glyph in font
3314 \end_layout
3316 \begin_layout Itemize
3317 Syntax: font:edit(character, glyph)
3318 \end_layout
3320 \begin_layout Standard
3321 Parameters:
3322 \end_layout
3324 \begin_layout Itemize
3325 font: CUSTOMFONT: The font to edit.
3326 \end_layout
3328 \begin_layout Itemize
3329 character: string: The character to edit (UTF-8 encoded).
3330 \end_layout
3332 \begin_layout Itemize
3333 glyph: BITMAP: The bitmap to use.
3334 \end_layout
3336 \begin_layout Standard
3337 Replace character <character> in font <font> by <glyph>.
3338 \end_layout
3340 \begin_layout Itemize
3341 Color index 0 is background, everything else is foreground.
3342 \end_layout
3344 \begin_layout Itemize
3345 <character> may be empty string, meaning the replacement character used
3346  for bad characters.
3347 \end_layout
3349 \begin_layout Itemize
3350 <character> may be multi-codepoint string, meaning character used for that
3351  ligature.
3352 \end_layout
3354 \begin_layout Standard
3355 \begin_inset Newpage pagebreak
3356 \end_inset
3359 \end_layout
3361 \begin_layout Subsection
3362 ICONV: Character set conversions
3363 \end_layout
3365 \begin_layout Subsubsection
3366 Static function new: Create new character set converter
3367 \end_layout
3369 \begin_layout Itemize
3370 Syntax: iconv iconv.new(from, to);
3371 \end_layout
3373 \begin_layout Itemize
3374 Syntax: iconv classes.ICONV.new(from, to);
3375 \end_layout
3377 \begin_layout Itemize
3378 Deprecated: iconv iconv_new(...);
3379 \end_layout
3381 \begin_layout Standard
3382 Parameters:
3383 \end_layout
3385 \begin_layout Itemize
3386 from: string: The source character set.
3387 \end_layout
3389 \begin_layout Itemize
3390 to: string: The target character set.
3391 \end_layout
3393 \begin_layout Standard
3394 Returns:
3395 \end_layout
3397 \begin_layout Itemize
3398 iconv: ICONV: The converter.
3399 \end_layout
3401 \begin_layout Standard
3402 Create a character set converter, converting from <from> to <to> and return
3403  it.
3404 \end_layout
3406 \begin_layout Subsubsection
3407 Operator(): Convert string fragment from character set to another
3408 \end_layout
3410 \begin_layout Itemize
3411 Syntax: success, result, unconverted, error iconv(input)
3412 \end_layout
3414 \begin_layout Standard
3415 Parameters:
3416 \end_layout
3418 \begin_layout Itemize
3419 iconv: ICONV: The context to use.
3420 \end_layout
3422 \begin_layout Itemize
3423 input: string: The input to convert.
3424 \end_layout
3426 \begin_layout Standard
3427 Return value:
3428 \end_layout
3430 \begin_layout Itemize
3431 success: boolean: True if conversion was successful, false if not.
3432 \end_layout
3434 \begin_layout Itemize
3435 result: string: The string (partially) converted.
3436 \end_layout
3438 \begin_layout Itemize
3439 unconvered: number: Number of bytes that were not converted (only if <success>
3440  is false).
3441 \end_layout
3443 \begin_layout Itemize
3444 error: string: Error that caused conversion to stop (only if <success> is
3445  false).
3446 \end_layout
3448 \begin_deeper
3449 \begin_layout Itemize
3450 INVALID: The input string is invalid.
3451 \end_layout
3453 \begin_layout Itemize
3454 INCOMPLETE: The input string cuts off in middle of character.
3455 \end_layout
3457 \begin_layout Itemize
3458 INTERNALERR: Internal error.
3459 \end_layout
3461 \end_deeper
3462 \begin_layout Standard
3463 Convert a string <input> using character set converter <iconv> and return
3464  the result.
3465 \end_layout
3467 \begin_layout Standard
3468 \begin_inset Newpage pagebreak
3469 \end_inset
3472 \end_layout
3474 \begin_layout Subsection
3475 FILEREADER: Read a file as a stream
3476 \end_layout
3478 \begin_layout Subsubsection
3479 Static function open: Open a stream
3480 \end_layout
3482 \begin_layout Itemize
3483 Syntax: handle filereader.open(file, [base])
3484 \end_layout
3486 \begin_layout Itemize
3487 Syntax: handle classes.FILEREADER.open(file, [base])
3488 \end_layout
3490 \begin_layout Itemize
3491 Deprecated: handle open_file(file, [base])
3492 \end_layout
3494 \begin_layout Standard
3495 Parameters:
3496 \end_layout
3498 \begin_layout Itemize
3499 file: string: The filename to read.
3500 \end_layout
3502 \begin_layout Itemize
3503 base: string: The base <file> is resolved against.
3504 \end_layout
3506 \begin_layout Standard
3507 Returns:
3508 \end_layout
3510 \begin_layout Itemize
3511 handle: FILEREADER: The new file reader.
3512 \end_layout
3514 \begin_layout Standard
3515 Open file <file> (relative to <base>) and return a handle to it.
3516 \end_layout
3518 \begin_layout Subsubsection
3519 operator(): Read line/bytes from stream
3520 \end_layout
3522 \begin_layout Itemize
3523 Syntax: result handle()
3524 \end_layout
3526 \begin_layout Itemize
3527 Syntax: result handle(bytes)
3528 \end_layout
3530 \begin_layout Standard
3531 Parameters:
3532 \end_layout
3534 \begin_layout Itemize
3535 handle: FILEREADER: The handle to read from.
3536 \end_layout
3538 \begin_layout Itemize
3539 bytes: Number of bytes to read (default is next line).
3540 \end_layout
3542 \begin_layout Standard
3543 Returns:
3544 \end_layout
3546 \begin_layout Itemize
3547 result: string: The read data, or nil on end-of-file.
3548 \end_layout
3550 \begin_layout Standard
3551 Reads next line or <bytes> bytes from specified file handle <handle>.
3552 \end_layout
3554 \begin_layout Itemize
3555 If reading specified number of bytes, the bytes are read in binary mode
3556  (as-is).
3557 \end_layout
3559 \begin_layout Itemize
3560 If reading next line, the line is read in text mode (any line ending is
3561  skpped).
3562 \end_layout
3564 \begin_layout Subsubsection
3565 Method lines: Iterator to read all lines
3566 \end_layout
3568 \begin_layout Itemize
3569 Syntax: for line in handle:lines() do ...
3570  end
3571 \end_layout
3573 \begin_layout Standard
3574 Parameters:
3575 \end_layout
3577 \begin_layout Itemize
3578 handle: FILEREADER: The handle to read.
3579 \end_layout
3581 \begin_layout Standard
3582 Returns:
3583 \end_layout
3585 \begin_layout Itemize
3586 A lua iterator with one variable.
3587 \end_layout
3589 \begin_layout Standard
3590 Return a Lua iterator that iterates all the lines in <handle>.
3591 \end_layout
3593 \begin_layout Standard
3594 \begin_inset Newpage pagebreak
3595 \end_inset
3598 \end_layout
3600 \begin_layout Subsection
3601 COMPARE_OBJ: Watch memory area for changes
3602 \end_layout
3604 \begin_layout Standard
3605 Objects of this class allow fast checking for modifications to given memory
3606  block.
3607 \end_layout
3609 \begin_layout Subsubsection
3610 Static function new: Create a checker
3611 \end_layout
3613 \begin_layout Itemize
3614 Syntax: handle classes.COMPARE_OBJ.new([marea], offset, size, [rows, stride])
3615 \end_layout
3617 \begin_layout Itemize
3618 Syntax: handle memory.compare_new([marea], offset, size, rows, stride)
3619 \end_layout
3621 \begin_layout Standard
3622 Parameters:
3623 \end_layout
3625 \begin_layout Itemize
3626 marea: string: The memory area to interpret <offset> against.
3627  Default is global space.
3628 \end_layout
3630 \begin_layout Itemize
3631 offset: number: The initial offset in memory area.
3632 \end_layout
3634 \begin_layout Itemize
3635 size: number: The number of bytes in each row.
3636 \end_layout
3638 \begin_layout Itemize
3639 rows: number: The number of rows.
3640  Default is 1.
3641 \end_layout
3643 \begin_layout Itemize
3644 stride: number: The number of bytes offset increments from one row to next.
3645 \end_layout
3647 \begin_layout Standard
3648 Returns:
3649 \end_layout
3651 \begin_layout Itemize
3652 A handle to object.
3653 \end_layout
3655 \begin_layout Standard
3656 Return an object watching specified memory area.
3657 \end_layout
3659 \begin_layout Itemize
3660 Note: For fastest operation, limit checks to inside one memory area (that
3661  has to be mappable, individual RAM areas often are).
3662 \end_layout
3664 \begin_layout Subsubsection
3665 operator(): Check area for modifications
3666 \end_layout
3668 \begin_layout Itemize
3669 Syntax: boolean handle()
3670 \end_layout
3672 \begin_layout Standard
3673 Returns:
3674 \end_layout
3676 \begin_layout Itemize
3677 True if memory block has been modified since last call (or object creation
3678  if first call), false if not.
3679 \end_layout
3681 \begin_layout Standard
3682 Check if the block has been modified.
3683 \end_layout
3685 \begin_layout Standard
3686 \begin_inset Newpage pagebreak
3687 \end_inset
3690 \end_layout
3692 \begin_layout Section
3693 Global
3694 \end_layout
3696 \begin_layout Subsection
3697 print: Print values to console
3698 \end_layout
3700 \begin_layout Itemize
3701 Syntax: none print(value...
3702  values)
3703 \end_layout
3705 \begin_layout Standard
3706 Prints specified values to console.
3707  Can print any Lua type at least enough to identify the type and instance.
3708 \end_layout
3710 \begin_layout Subsection
3711 tostringx: Format a value to string
3712 \end_layout
3714 \begin_layout Itemize
3715 Syntax: string tostringx(value val)
3716 \end_layout
3718 \begin_layout Standard
3719 Formats value <val> like print would, and returns the result as a string.
3720 \end_layout
3722 \begin_layout Subsection
3723 exec: Execute lsnes commands
3724 \end_layout
3726 \begin_layout Itemize
3727 Syntax: none exec(string cmd)
3728 \end_layout
3730 \begin_layout Standard
3731 Execute lsnes command <cmd>.
3732 \end_layout
3734 \begin_layout Subsection
3735 utime: Get current time
3736 \end_layout
3738 \begin_layout Itemize
3739 Syntax: (number,number) utime()
3740 \end_layout
3742 \begin_layout Standard
3743 Returns two numbers.
3744  First is time since some epoch in seconds, the second is microseconds mod
3745  10^6 since that epoch.
3746 \end_layout
3748 \begin_layout Subsection
3749 set_idle_timeout: Run function after timeout when emulator is idle
3750 \end_layout
3752 \begin_layout Itemize
3753 Syntax: none set_idle_timeout(number timeout)
3754 \end_layout
3756 \begin_layout Standard
3757 Set number of microseconds to block idle for.
3758  After this timeout has expired, on_idle() will be called once.
3759 \end_layout
3761 \begin_layout Subsection
3762 set_timer_timeout: Run function after timeout.
3763 \end_layout
3765 \begin_layout Itemize
3766 Syntax: none set_timer_timeout(number timeout)
3767 \end_layout
3769 \begin_layout Standard
3770 Set number of microseconds to block timer for.
3771  After this timeout has expired, on_timer() will be called once.
3772 \end_layout
3774 \begin_layout Subsection
3775 bus_address: Look up address in system bus.
3776 \end_layout
3778 \begin_layout Itemize
3779 Syntax: none bus_address(number bus_addr)
3780 \end_layout
3782 \begin_layout Standard
3783 Returns virtual address corresponding to specified address on system bus.
3784 \end_layout
3786 \begin_layout Subsection
3787 loopwrapper: Convert loop into callable function
3788 \end_layout
3790 \begin_layout Itemize
3791 Syntax: function loopwrapper(function fun, ...)
3792 \end_layout
3794 \begin_layout Standard
3795 Calls function <fun> with function and specified arguments.
3796  The function passed suspends execution until the function returned is called.
3797  Handy for linear flow control among multiple invocations of a hook.
3798  Example code:
3799 \end_layout
3801 \begin_layout LyX-Code
3802 on_paint = loopwrapper(function(wait)
3803 \end_layout
3805 \begin_deeper
3806 \begin_layout LyX-Code
3807 while true do
3808 \end_layout
3810 \begin_deeper
3811 \begin_layout LyX-Code
3812 gui.text(0, 0, 
3813 \begin_inset Quotes eld
3814 \end_inset
3816 Test!
3817 \begin_inset Quotes erd
3818 \end_inset
3821 \end_layout
3823 \begin_layout LyX-Code
3824 wait();
3825 \end_layout
3827 \end_deeper
3828 \begin_layout LyX-Code
3830 \end_layout
3832 \end_deeper
3833 \begin_layout LyX-Code
3834 end);
3835 \end_layout
3837 \begin_layout Subsection
3838 list_bindings: List keybindings
3839 \end_layout
3841 \begin_layout Itemize
3842 Syntax: table list_bindings([string cmd])
3843 \end_layout
3845 \begin_layout Standard
3846 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
3847  If <cmd> is specified, the table is limited to that command.
3848  Also searches for controller keys.
3849 \end_layout
3851 \begin_layout Subsection
3852 get_alias: Get expansion of alias
3853 \end_layout
3855 \begin_layout Itemize
3856 Syntax: string get_alias(string aname)
3857 \end_layout
3859 \begin_layout Standard
3860 Get expansion of given alias <aname>.
3861 \end_layout
3863 \begin_layout Subsection
3864 set_alias: Set expansion of alias
3865 \end_layout
3867 \begin_layout Itemize
3868 Syntax: none set_alias(string aname, string value)
3869 \end_layout
3871 \begin_layout Standard
3872 Set expansion of given alias.
3873 \end_layout
3875 \begin_layout Subsection
3876 create_ibind: Create invese binding
3877 \end_layout
3879 \begin_layout Itemize
3880 Syntax: INVERSEBIND create_ibind(string name, string cmd)
3881 \end_layout
3883 \begin_layout Standard
3884 Return object representing inverse binding with specified name <name> and
3885  specified command <cmd>.
3886 \end_layout
3888 \begin_layout Itemize
3889 Note: To create press/release commands, use aliases +foo and -foo .
3890 \end_layout
3892 \begin_layout Itemize
3893 Note: Keep the returned object around.
3894 \end_layout
3896 \begin_layout Subsection
3897 create_command: Create a command
3898 \end_layout
3900 \begin_layout Itemize
3901 Syntax: COMMANDBIND create_commmand(string name, function a)
3902 \end_layout
3904 \begin_layout Itemize
3905 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
3906 \end_layout
3908 \begin_layout Standard
3909 Return object representing a command (pair).
3910 \end_layout
3912 \begin_layout Itemize
3913 If only one function is specied, the command is level-sensitive, <a> is
3914  callback.
3915 \end_layout
3917 \begin_layout Itemize
3918 If <b> is function, the function is edge-sensitive, <a> is positive edge
3919  callback and <b> is negative edge callback.
3920 \end_layout
3922 \begin_layout Itemize
3923 All callbacks get single argument: The parameters passed.
3924 \end_layout
3926 \begin_layout Itemize
3927 Keep the returned object around.
3928 \end_layout
3930 \begin_layout Subsection
3931 loadfile: Load Lua script
3932 \end_layout
3934 \begin_layout Itemize
3935 Syntax: function loadfile(string filename[, string base])
3936 \end_layout
3938 \begin_layout Standard
3939 Load lua script from <filename>, resolved relative to <base> (if empty,
3940  current directory).
3941 \end_layout
3943 \begin_layout Subsection
3944 dofile: Execute Lua script
3945 \end_layout
3947 \begin_layout Itemize
3948 Syntax: function dofile(string filename[, string base])
3949 \end_layout
3951 \begin_layout Standard
3952 Execute lua script from <filename>, resolved relative to <base> (if empty,
3953  current directory) and return all return values.
3954 \end_layout
3956 \begin_layout Subsection
3957 resolve_filename: Resolve name of file relative to another
3958 \end_layout
3960 \begin_layout Itemize
3961 Syntax: string resolve_file(string filename, string base)
3962 \end_layout
3964 \begin_layout Standard
3965 Resolve name of file <filename> relative to <base> and return the result.
3966 \end_layout
3968 \begin_layout Subsection
3969 render_queue_function: Return paint function for render queue
3970 \end_layout
3972 \begin_layout Itemize
3973 Syntax: function render_queue_function(RENDERQUEUE rq)
3974 \end_layout
3976 \begin_layout Standard
3977 Return function that renders render queue <rq>.
3978 \end_layout
3980 \begin_layout Itemize
3981 Handy for paint callback if one is using render queues updated in other
3982  callbacks.
3983  As in:
3984 \end_layout
3986 \begin_layout LyX-Code
3987 handle = callback.paint:register(render_queue_function(my_rq));
3988 \end_layout
3990 \begin_layout Subsection
3991 identify_class: Identify class of object
3992 \end_layout
3994 \begin_layout Itemize
3995 Syntax: string identify_class(userdata object)
3996 \end_layout
3998 \begin_layout Standard
3999 Identifies the class of userdata <object>, if possible.
4000  If no identification is possible, returns 
4001 \begin_inset Quotes eld
4002 \end_inset
4004 unknown
4005 \begin_inset Quotes erd
4006 \end_inset
4009 \end_layout
4011 \begin_layout Subsection
4012 lookup_class: Lookup class by name
4013 \end_layout
4015 \begin_layout Itemize
4016 Syntax: classobj lookup_class(string name)
4017 \end_layout
4019 \begin_layout Standard
4020 Looks up class corresponding to <name>, if possible.
4021  If not found, returns nil.
4022  The classobj has following fields:
4023 \end_layout
4025 \begin_layout Itemize
4026 _static_methods: Return static method names
4027 \end_layout
4029 \begin_layout Itemize
4030 _class_methods: Return class method names
4031 \end_layout
4033 \begin_layout Itemize
4034 <static-function-name>: The specified static function.
4035 \end_layout
4037 \begin_layout Subsection
4038 all_classes: Get list of all classes
4039 \end_layout
4041 \begin_layout Itemize
4042 Syntax: string...
4043  all_classes()
4044 \end_layout
4046 \begin_layout Standard
4047 Get names of all classes available.
4048 \end_layout
4050 \begin_layout Subsection
4052 \end_layout
4054 \begin_layout Subsection
4055 icnov: Class ICONV
4056 \end_layout
4058 \begin_layout Standard
4059 See class ICONV.
4060 \end_layout
4062 \begin_layout Subsection
4063 filereader: Class FILEREADER
4064 \end_layout
4066 \begin_layout Standard
4067 See class FILEREADER.
4068 \end_layout
4070 \begin_layout Standard
4071 \begin_inset Newpage pagebreak
4072 \end_inset
4075 \end_layout
4077 \begin_layout Section
4078 Table bit:
4079 \end_layout
4081 \begin_layout Standard
4082 Bitwise logical functions and related.
4083 \end_layout
4085 \begin_layout Subsection
4086 bit.none/bit.bnot: Bitwise none or NOT function
4087 \end_layout
4089 \begin_layout Itemize
4090 Syntax: number bit.none(number...)
4091 \end_layout
4093 \begin_layout Itemize
4094 Syntax: number bit.bnot(number...)
4095 \end_layout
4097 \begin_layout Standard
4098 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4099  arguments).
4100 \end_layout
4102 \begin_layout Subsection
4103 bit.any/bit.bor: Bitwise any or OR function
4104 \end_layout
4106 \begin_layout Itemize
4107 Syntax: number bit.any(number...)
4108 \end_layout
4110 \begin_layout Itemize
4111 Syntax: number bit.bor(number...)
4112 \end_layout
4114 \begin_layout Standard
4115 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4116 \end_layout
4118 \begin_layout Subsection
4119 bit.all/bit.band: Bitwise all or AND function
4120 \end_layout
4122 \begin_layout Itemize
4123 Syntax: number bit.all(number...)
4124 \end_layout
4126 \begin_layout Itemize
4127 Syntax: number bit.band(number...)
4128 \end_layout
4130 \begin_layout Standard
4131 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4133 \end_layout
4135 \begin_layout Subsection
4136 bit.parity/bit.bxor: Bitwise parity or XOR function
4137 \end_layout
4139 \begin_layout Itemize
4140 Syntax: number bit.parity(number...)
4141 \end_layout
4143 \begin_layout Itemize
4144 Syntax: number bit.bxor(number...)
4145 \end_layout
4147 \begin_layout Standard
4148 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4149  of the arguments).
4150 \end_layout
4152 \begin_layout Subsection
4153 bit.lrotate: Rotate a number left
4154 \end_layout
4156 \begin_layout Itemize
4157 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4158 \end_layout
4160 \begin_layout Standard
4161 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4162  1) places.
4163 \end_layout
4165 \begin_layout Subsection
4166 bit.rrotate: Rotate a number right
4167 \end_layout
4169 \begin_layout Itemize
4170 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4171 \end_layout
4173 \begin_layout Standard
4174 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4175  1) places.
4176 \end_layout
4178 \begin_layout Subsection
4179 bit.lshift: Shift a number left
4180 \end_layout
4182 \begin_layout Itemize
4183 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4184 \end_layout
4186 \begin_layout Standard
4187 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4188  1) places.
4189  The new bits are filled with zeroes.
4190 \end_layout
4192 \begin_layout Subsection
4193 bit.lrshift: Shift a number right (logical)
4194 \end_layout
4196 \begin_layout Itemize
4197 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4198 \end_layout
4200 \begin_layout Standard
4201 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4202  (default 1) places.
4203  The new bits are filled with zeroes.
4204 \end_layout
4206 \begin_layout Subsection
4207 bit.arshift: Shift a number right (arithmetic)
4208 \end_layout
4210 \begin_layout Itemize
4211 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4212 \end_layout
4214 \begin_layout Standard
4215 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4216  (default 1) places.
4217  The new bits are shifted in with copy of the high bit.
4218 \end_layout
4220 \begin_layout Subsection
4221 bit.extract: Extract/shuffle bits from number
4222 \end_layout
4224 \begin_layout Itemize
4225 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4226 \end_layout
4228 \begin_layout Standard
4229 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4230 \end_layout
4232 \begin_layout Itemize
4233 Note: Bit numbers up to 51 should work reliably (then things start falling
4234  apart due to double precision issues).
4235 \end_layout
4237 \begin_layout Itemize
4238 Note: There are two special bit positions, true and false, standing for
4239  always set bit and always clear bit.
4240 \end_layout
4242 \begin_layout Subsection
4243 bit.value: Construct number with specified bits set
4244 \end_layout
4246 \begin_layout Itemize
4247 Syntax: number bit.value([number bit1[, number bit2,...]])
4248 \end_layout
4250 \begin_layout Standard
4251 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4252  <bit2> places and so on.
4253  As special value, nil argument is no-op.
4254 \end_layout
4256 \begin_layout Subsection
4257 bit.test: Test if bit is set
4258 \end_layout
4260 \begin_layout Itemize
4261 Syntax: boolean bit.test(number a, number bit)
4262 \end_layout
4264 \begin_layout Standard
4265 Tests if bit <bit> is set in <a>.
4266  If it is set, returns true, otherwise false.
4267 \end_layout
4269 \begin_layout Subsection
4270 bit.testn: Test if bit is clear
4271 \end_layout
4273 \begin_layout Itemize
4274 Syntax: boolean bit.testn(number a, number bit)
4275 \end_layout
4277 \begin_layout Standard
4278 Tests if bit <bit> is set in <a>.
4279  If it is clear, returns true, otherwise false.
4280 \end_layout
4282 \begin_layout Subsection
4283 bit.test_any: Test if any bit is set
4284 \end_layout
4286 \begin_layout Itemize
4287 Syntax: boolean bit.test_any(number a, number b)
4288 \end_layout
4290 \begin_layout Standard
4291 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4292 \end_layout
4294 \begin_layout Subsection
4295 bit.test_all: Test if all bits are set
4296 \end_layout
4298 \begin_layout Itemize
4299 Syntax: boolean bit.test_all(number a, number b)
4300 \end_layout
4302 \begin_layout Standard
4303 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4304 \end_layout
4306 \begin_layout Subsection
4307 bit.popcount: Population count
4308 \end_layout
4310 \begin_layout Itemize
4311 Syntax: number bit.popcount(number a)
4312 \end_layout
4314 \begin_layout Standard
4315 Returns number of set bits in <a>.
4316 \end_layout
4318 \begin_layout Subsection
4319 bit.clshift: Chained left shift
4320 \end_layout
4322 \begin_layout Itemize
4323 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4324  bits]])
4325 \end_layout
4327 \begin_layout Standard
4328 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4329  numbers to be of specified number of bits <bits> (default 48).
4330 \end_layout
4332 \begin_layout Subsection
4333 bit.crshift: Chained right shift
4334 \end_layout
4336 \begin_layout Itemize
4337 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4338  bits]])
4339 \end_layout
4341 \begin_layout Standard
4342 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4343  assuming numbers to be of specified number of bits <bits> (default 48).
4344 \end_layout
4346 \begin_layout Subsection
4347 bit.flagdecode: Decode bitfield into flags
4348 \end_layout
4350 \begin_layout Itemize
4351 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4352  off]])
4353 \end_layout
4355 \begin_layout Standard
4356 Return string of length bits where ith character is ith character of on
4357  if bit i is on, otherwise ith character of off.
4358  Out of range reads give last character.
4359 \end_layout
4361 \begin_layout Itemize
4362 Note: <on> defaults to '*' if empty.
4363 \end_layout
4365 \begin_layout Itemize
4366 Note: <off> defaults to '-' if empty.
4367 \end_layout
4369 \begin_layout Subsection
4370 bit.rflagdecode: Decode bitfield into flags
4371 \end_layout
4373 \begin_layout Itemize
4374 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4375  off]])
4376 \end_layout
4378 \begin_layout Standard
4379 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4380 nt bit first).
4381 \end_layout
4383 \begin_layout Subsection
4384 bit.swap{,s}{,h,d,q}word: Swap word endian
4385 \end_layout
4387 \begin_layout Itemize
4388 Syntax: number bit.swapword(number n)
4389 \end_layout
4391 \begin_layout Itemize
4392 Syntax: number bit.swaphword(number n)
4393 \end_layout
4395 \begin_layout Itemize
4396 Syntax: number bit.swapdword(number n)
4397 \end_layout
4399 \begin_layout Itemize
4400 Syntax: number bit.swapqword(number n)
4401 \end_layout
4403 \begin_layout Itemize
4404 Syntax: number bit.swapsword(number n)
4405 \end_layout
4407 \begin_layout Itemize
4408 Syntax: number bit.swapshword(number n)
4409 \end_layout
4411 \begin_layout Itemize
4412 Syntax: number bit.swapsdword(number n)
4413 \end_layout
4415 \begin_layout Itemize
4416 Syntax: number bit.swapsqword(number n)
4417 \end_layout
4419 \begin_layout Standard
4420 Swap endianess of (un)signed integer <n>.
4421 \end_layout
4423 \begin_layout Subsection
4424 bit.compose: Compose multi-byte number
4425 \end_layout
4427 \begin_layout Itemize
4428 Syntax: number bit.compose(number n...)
4429 \end_layout
4431 \begin_layout Standard
4432 Return 
4433 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4434 \end_inset
4437 \end_layout
4439 \begin_layout Subsection
4440 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4441 \end_layout
4443 \begin_layout Itemize
4444 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4445 \end_layout
4447 \begin_layout Itemize
4448 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4449 \end_layout
4451 \begin_layout Standard
4452 Load little (*le) or big (*be) endian binary number from position <pos>
4453  of string <str>.
4454  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4455  double.
4456 \end_layout
4458 \begin_layout Subsection
4459 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4460 \end_layout
4462 \begin_layout Itemize
4463 Syntax: string bit.binary_st_<type>le(number x);
4464 \end_layout
4466 \begin_layout Itemize
4467 Syntax: string bit.binary_st_<type>be(number x);
4468 \end_layout
4470 \begin_layout Standard
4471 Store specified number <x> as binary in string and return the result.
4472  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4473  double.
4474 \end_layout
4476 \begin_layout Subsection
4477 bit.quotent: Integer quotent
4478 \end_layout
4480 \begin_layout Itemize
4481 Syntax: number bit.quotent(number a, number b)
4482 \end_layout
4484 \begin_layout Standard
4485 Calculate quotent a/b.
4486 \end_layout
4488 \begin_layout Subsection
4489 bit.multidiv: Divide and split among multiple divisiors
4490 \end_layout
4492 \begin_layout Itemize
4493 Syntax: number...
4494  bit.multidiv(number v, number q...)
4495 \end_layout
4497 \begin_layout Standard
4498 Does the following steps:
4499 \end_layout
4501 \begin_layout Enumerate
4502 Set v' to <v>.
4503 \end_layout
4505 \begin_layout Enumerate
4506 For each <q> q:
4507 \end_layout
4509 \begin_deeper
4510 \begin_layout Enumerate
4511 Calculate quotent(v'/q) and add that to numbers returned.
4512 \end_layout
4514 \begin_layout Enumerate
4515 v' <- remainder(v'/q)
4516 \end_layout
4518 \end_deeper
4519 \begin_layout Enumerate
4520 Add v' to numbers returned.
4521 \end_layout
4523 \begin_layout Standard
4524 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
4525  at each step.
4526  <v> may be floating point, <q>s are integers.
4527 \end_layout
4529 \begin_layout Itemize
4530 E.g.
4531  bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
4532 \end_layout
4534 \begin_layout Itemize
4535 E.g.
4536  bit.multidiv(a, b) calculates quotent and remainder of a/b.
4537 \end_layout
4539 \begin_layout Subsection
4540 bit.mul32: 32-bit multiply
4541 \end_layout
4543 \begin_layout Itemize
4544 Syntax: number, number bit.mul32(number a, number b)
4545 \end_layout
4547 \begin_layout Standard
4548 Multiply 32-bit numbers <a> and <b>.
4549  The first return value is low 32 bits of result, the second is high 32
4550  bits.
4551 \end_layout
4553 \begin_layout Standard
4554 \begin_inset Newpage pagebreak
4555 \end_inset
4558 \end_layout
4560 \begin_layout Section
4561 Table classes:
4562 \end_layout
4564 \begin_layout Subsection
4565 classes.<foo>: The classobj for class <foo>
4566 \end_layout
4568 \begin_layout Itemize
4569 Syntax: classes.<foo>
4570 \end_layout
4572 \begin_layout Standard
4573 The classobj for class <foo>.
4574 \end_layout
4576 \begin_layout Subsection
4577 classes.<foo>._static_methods: Enumerate static methods
4578 \end_layout
4580 \begin_layout Itemize
4581 Syntax: string...
4582  classes.<foo>._static_methods()
4583 \end_layout
4585 \begin_layout Standard
4586 Returns all static methods of <foo> as strings.
4587 \end_layout
4589 \begin_layout Subsection
4590 classes.<foo>._class_methods: Enumerate static methods
4591 \end_layout
4593 \begin_layout Itemize
4594 Syntax: string...
4595  classes.<foo>._class_methods()
4596 \end_layout
4598 \begin_layout Standard
4599 Returns all class methods of <foo> as strings.
4600 \end_layout
4602 \begin_layout Subsection
4603 classes.<foo>.<bar>: Static method
4604 \end_layout
4606 \begin_layout Itemize
4607 Syntax: variable classes.<foo>.<bar>(variable...)
4608 \end_layout
4610 \begin_layout Standard
4611 Invokes static method <bar> of class <foo>.
4612 \end_layout
4614 \begin_layout Section
4615 Table gui:
4616 \end_layout
4618 \begin_layout Subsection
4619 gui.resolution: Get current resolution
4620 \end_layout
4622 \begin_layout Itemize
4623 Syntax: (number, number) gui.resolution()
4624 \end_layout
4626 \begin_layout Standard
4627 Returns 2-tuple (hresolution, vresolution).
4628 \end_layout
4630 \begin_layout Subsection
4631 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
4632 \end_layout
4634 \begin_layout Itemize
4635 Syntax: number gui.left_gap(number gap)
4636 \end_layout
4638 \begin_layout Itemize
4639 Syntax: number gui.right_gap(number gap)
4640 \end_layout
4642 \begin_layout Itemize
4643 Syntax: number gui.top_gap(number gap)
4644 \end_layout
4646 \begin_layout Itemize
4647 Syntax: number gui.bottom_gap(number gap)
4648 \end_layout
4650 \begin_layout Standard
4651 Set the specified edge gap to specified value <gap> (max gap is 8191).
4652  If successful, old gap is returned.
4653 \end_layout
4655 \begin_layout Subsection
4656 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
4657  Adjust edge gaps
4658 \end_layout
4660 \begin_layout Itemize
4661 Syntax: number gui.delta_left_gap(number dgap)
4662 \end_layout
4664 \begin_layout Itemize
4665 Syntax: number gui.delta_right_gap(number dgap)
4666 \end_layout
4668 \begin_layout Itemize
4669 Syntax: number gui.delta_top_gap(number dgap)
4670 \end_layout
4672 \begin_layout Itemize
4673 Syntax: number gui.delta_bottom_gap(number dgap)
4674 \end_layout
4676 \begin_layout Standard
4677 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
4678  and return the old gap (returns nothing on error).
4679 \end_layout
4681 \begin_layout Subsection
4682 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
4683 \end_layout
4685 \begin_layout Itemize
4686 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
4687  bgc]])
4688 \end_layout
4690 \begin_layout Itemize
4691 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
4692  bgc]])
4693 \end_layout
4695 \begin_layout Itemize
4696 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
4697  bgc]])
4698 \end_layout
4700 \begin_layout Itemize
4701 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
4702  bgc]])
4703 \end_layout
4705 \begin_layout Standard
4706 Draw specified text on the GUI (each character cell is 8 or 16 wide and
4707  16 high).
4708  Parameters:
4709 \end_layout
4711 \begin_layout Itemize
4712 x: X-coordinate to start the drawing from (and x-coordinate at begining
4713  of the lines).
4714 \end_layout
4716 \begin_layout Itemize
4717 y: Y-coordinate to start the drawing from.
4718 \end_layout
4720 \begin_layout Itemize
4721 text: The text to draw.
4722 \end_layout
4724 \begin_layout Itemize
4725 fgc: Text color (default is 0xFFFFFF (white))
4726 \end_layout
4728 \begin_layout Itemize
4729 bgc: Background color (default is -1 (transparent))
4730 \end_layout
4732 \begin_layout Standard
4733 Note: The H variants draw at double width and V variants draw at double
4734  height.
4735 \end_layout
4737 \begin_layout Subsection
4738 gui.rectangle: Draw a rectangle
4739 \end_layout
4741 \begin_layout Itemize
4742 Syntax: none gui.rectangle(number x, number y, number width, number height[,
4743  number thickness[, number outline[, number fill]]])
4744 \end_layout
4746 \begin_layout Standard
4747 Draw rectangle on the GUI.
4748  Parameters:
4749 \end_layout
4751 \begin_layout Itemize
4752 x: X-coordinate of left edge.
4753 \end_layout
4755 \begin_layout Itemize
4756 y: Y-coordinate of upper edge.
4757 \end_layout
4759 \begin_layout Itemize
4760 width: Width of rectangle.
4761 \end_layout
4763 \begin_layout Itemize
4764 height: Height of rectangle.
4765 \end_layout
4767 \begin_layout Itemize
4768 thickness: Thickness of outline (default is 1).
4769 \end_layout
4771 \begin_layout Itemize
4772 outline: Color of outline (default is 0xFFFFFF (white))
4773 \end_layout
4775 \begin_layout Itemize
4776 fill: Color of fill (default is -1 (transparent))
4777 \end_layout
4779 \begin_layout Subsection
4780 gui.solidrectangle: Draw a solid rectangle
4781 \end_layout
4783 \begin_layout Itemize
4784 Syntax: none gui.rectangle(number x, number y, number width, number height[,
4785  number color])
4786 \end_layout
4788 \begin_layout Standard
4789 Draw solid rectangle on the GUI.
4790  Parameters:
4791 \end_layout
4793 \begin_layout Itemize
4794 x: X-coordinate of left edge.
4795 \end_layout
4797 \begin_layout Itemize
4798 y: Y-coordinate of upper edge.
4799 \end_layout
4801 \begin_layout Itemize
4802 width: Width of rectangle.
4803 \end_layout
4805 \begin_layout Itemize
4806 height: Height of rectangle.
4807 \end_layout
4809 \begin_layout Itemize
4810 color: Color of rectangle (default is 0xFFFFFF (white))
4811 \end_layout
4813 \begin_layout Subsection
4814 gui.box: Draw a 3D-effect box
4815 \end_layout
4817 \begin_layout Itemize
4818 Syntax: none gui.box(number x, number y, number width, number height[, number
4819  thickness[, number outline1[,number outline2[, number fill]]]])
4820 \end_layout
4822 \begin_layout Standard
4823 Draw rectangle with 3D effect on the GUI.
4824  Parameters:
4825 \end_layout
4827 \begin_layout Itemize
4828 x: X-coordinate of left edge.
4829 \end_layout
4831 \begin_layout Itemize
4832 y: Y-coordinate of upper edge.
4833 \end_layout
4835 \begin_layout Itemize
4836 width: Width of rectangle.
4837 \end_layout
4839 \begin_layout Itemize
4840 height: Height of rectangle.
4841 \end_layout
4843 \begin_layout Itemize
4844 thickness: Thickness of outline (default is 1).
4845 \end_layout
4847 \begin_layout Itemize
4848 outline1: First color of outline (default is 0xFFFFFF (white))
4849 \end_layout
4851 \begin_layout Itemize
4852 outline2: First color of outline (default is 0x808080 (dark gray))
4853 \end_layout
4855 \begin_layout Itemize
4856 fill: Color of fill (default is 0xC0C0C0 (light grayy))
4857 \end_layout
4859 \begin_layout Subsection
4860 gui.pixel: Draw a single pixel
4861 \end_layout
4863 \begin_layout Itemize
4864 Syntax: none gui.pixel(number x, number y[, number color])
4865 \end_layout
4867 \begin_layout Standard
4868 Draw one pixel on the GUI.
4869  Parameters:
4870 \end_layout
4872 \begin_layout Itemize
4873 x: X-coordinate of the pixel
4874 \end_layout
4876 \begin_layout Itemize
4877 y: Y-coordinate of the pixel
4878 \end_layout
4880 \begin_layout Itemize
4881 color: Color of the pixel (default is 0xFFFFFF (white))
4882 \end_layout
4884 \begin_layout Subsection
4885 gui.crosshair: Draw a crosshair
4886 \end_layout
4888 \begin_layout Itemize
4889 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
4890 \end_layout
4892 \begin_layout Standard
4893 Draw a crosshair.
4894  Parameters:
4895 \end_layout
4897 \begin_layout Itemize
4898 x: X-coordinate of the crosshair
4899 \end_layout
4901 \begin_layout Itemize
4902 y: Y-coordinate of the crosshair
4903 \end_layout
4905 \begin_layout Itemize
4906 length: Length of the crosshair lines (default 10).
4907 \end_layout
4909 \begin_layout Itemize
4910 color: Color of the crosshair (default is 0xFFFFFF (white))
4911 \end_layout
4913 \begin_layout Subsection
4914 gui.line: Draw a line
4915 \end_layout
4917 \begin_layout Itemize
4918 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
4919  color])
4920 \end_layout
4922 \begin_layout Standard
4923 Draw a thin line.
4924  Parameters:
4925 \end_layout
4927 \begin_layout Itemize
4928 x1: X-coordinate of one end.
4929 \end_layout
4931 \begin_layout Itemize
4932 y1: Y-coordinate of one end.
4933 \end_layout
4935 \begin_layout Itemize
4936 x2: X-coordinate of the other end.
4937 \end_layout
4939 \begin_layout Itemize
4940 y2: Y-coordinate of the other end.
4941 \end_layout
4943 \begin_layout Itemize
4944 color: Color of the line (default is 0xFFFFFF (white)).
4945 \end_layout
4947 \begin_layout Subsection
4948 gui.circle: Draw a (filled) circle
4949 \end_layout
4951 \begin_layout Itemize
4952 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
4953  border[, number fil]]])
4954 \end_layout
4956 \begin_layout Standard
4957 Draw a circle.
4958  Parameters.
4959 \end_layout
4961 \begin_layout Itemize
4962 x: X-coordinate of the center
4963 \end_layout
4965 \begin_layout Itemize
4966 y: Y-coordinate of the center
4967 \end_layout
4969 \begin_layout Itemize
4970 r: The radius of the circle
4971 \end_layout
4973 \begin_layout Itemize
4974 thick: Border thickness
4975 \end_layout
4977 \begin_layout Itemize
4978 border: Border color (default is 0xFFFFFF (white))
4979 \end_layout
4981 \begin_layout Itemize
4982 fill: Fill color (default is -1 (transparent)).
4983 \end_layout
4985 \begin_layout Subsection
4986 gui.repaint: Arrange a repaint
4987 \end_layout
4989 \begin_layout Itemize
4990 Syntax: none gui.repaint()
4991 \end_layout
4993 \begin_layout Standard
4994 Request on_repaint() to happen as soon as possible.
4995 \end_layout
4997 \begin_layout Subsection
4998 gui.subframe_update: Enable/Disable subframe updates
4999 \end_layout
5001 \begin_layout Itemize
5002 Syntax: none gui.subframe_update(boolean on)
5003 \end_layout
5005 \begin_layout Standard
5006 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5007  or not happen (<on>=false).
5008 \end_layout
5010 \begin_layout Subsection
5011 gui.screenshot: Write a screenshot
5012 \end_layout
5014 \begin_layout Itemize
5015 Syntax: none gui.screenshot(string filename)
5016 \end_layout
5018 \begin_layout Standard
5019 Write PNG screenshot of the current frame (no drawings) to specified file
5020  <filename>.
5021 \end_layout
5023 \begin_layout Subsection
5024 gui.screenshot_bitmap: Write a screenshot to bitmap
5025 \end_layout
5027 \begin_layout Itemize
5028 Syntax: DBITMAP gui.screenshot_bitmap()
5029 \end_layout
5031 \begin_layout Standard
5032 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5033  the result.
5034 \end_layout
5036 \begin_layout Subsection
5037 gui.color: Compose a color.
5038 \end_layout
5040 \begin_layout Itemize
5041 Syntax: number gui.color(number r, number g, number b[, number a])
5042 \end_layout
5044 \begin_layout Itemize
5045 Syntax: number gui.color(string c)
5046 \end_layout
5048 \begin_layout Standard
5049 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5050 , each component in scale 0-255.
5051  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5052  fully opaque).
5053  The default alpha is 256.
5054 \end_layout
5056 \begin_layout Standard
5057 The form taking a string returns color corresponding color name.
5058 \end_layout
5060 \begin_layout Subsection
5061 gui.status: Set status variable
5062 \end_layout
5064 \begin_layout Itemize
5065 Syntax: none gui.status(string name, string value)
5066 \end_layout
5068 \begin_layout Standard
5069 Set status field 
5070 \begin_inset Quotes eld
5071 \end_inset
5073 L[<name>]
5074 \begin_inset Quotes erd
5075 \end_inset
5077  to <value> in status area.
5078 \end_layout
5080 \begin_layout Subsection
5081 gui.rainbow: Rainbow color calculation
5082 \end_layout
5084 \begin_layout Itemize
5085 Syntax: number gui.rainbow(number step, number steps[, number color])
5086 \end_layout
5088 \begin_layout Standard
5089 Perform hue rotation of color <color> (default bright red), by <step> steps.
5090  The number of steps per full rotation is given by absolute value of <steps>.
5091 \end_layout
5093 \begin_layout Standard
5094 If <step> is negative, the rotation will be counterclockwise.
5095 \end_layout
5097 \begin_layout Subsection
5098 gui.kill_frame: Kill video frame and associated sound
5099 \end_layout
5101 \begin_layout Itemize
5102 Syntax: none gui.kill_frame()
5103 \end_layout
5105 \begin_layout Standard
5106 Kills the currently dumped video frame + the associated sound.
5107  Only valid in on_video callback.
5108 \end_layout
5110 \begin_layout Subsection
5111 gui.set_video_scale: Set video frame scale
5112 \end_layout
5114 \begin_layout Itemize
5115 Syntax: none gui.set_video_scale(number h, number v)
5116 \end_layout
5118 \begin_layout Standard
5119 Sets the scale factors of current frame to <h>x<v>.
5120  Only valid in on_video callback.
5121 \end_layout
5123 \begin_layout Subsection
5124 gui.arrow: Draw an arrow
5125 \end_layout
5127 \begin_layout Itemize
5128 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5129  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5131 \end_layout
5133 \begin_layout Standard
5134 Draws an arrow using color <color>.
5135  The tip of arrow is at (<x>, <y>).
5136  Other parameters:
5137 \end_layout
5139 \begin_layout Enumerate
5140 <length>: The length of arrow tail.
5141 \end_layout
5143 \begin_layout Enumerate
5144 <hwidth>: The width of arrow head.
5145  Should be odd.
5146 \end_layout
5148 \begin_layout Enumerate
5149 <direction>: Direction of arrow.
5150  0 is to right, +1 rotates 45 degrees counterclockwise.
5151 \end_layout
5153 \begin_layout Enumerate
5154 <fill>: If true, fill the arrow head.
5155  Default false.
5156 \end_layout
5158 \begin_layout Enumerate
5159 <twidth>: Tail width.
5160  Should be odd.
5161  Default 1.
5162 \end_layout
5164 \begin_layout Enumerate
5165 <hthick>: Head thickness (only used if <fill> is false).
5166  Default is <twidth>.
5167 \end_layout
5169 \begin_layout Subsection
5170 gui.tiled_bitmap: Class TILEMAP
5171 \end_layout
5173 \begin_layout Standard
5174 See class TILEMAP.
5175 \end_layout
5177 \begin_layout Subsection
5178 gui.palette: Class PALETTE
5179 \end_layout
5181 \begin_layout Standard
5182 See class PALETTE.
5183 \end_layout
5185 \begin_layout Subsection
5186 gui.bitmap: Class BITMAP
5187 \end_layout
5189 \begin_layout Standard
5190 See class BITMAP.
5191 \end_layout
5193 \begin_layout Subsection
5194 gui.dbitmap: Class DBITMAP
5195 \end_layout
5197 \begin_layout Standard
5198 See class DBITMAP.
5199 \end_layout
5201 \begin_layout Subsection
5202 gui.font: Class CUSTOMFONT
5203 \end_layout
5205 \begin_layout Standard
5206 See class CUSTOMFONT.
5207 \end_layout
5209 \begin_layout Subsection
5210 gui.renderctx: Class RENDERCTX
5211 \end_layout
5213 \begin_layout Standard
5214 See class RENDERCTX.
5215 \end_layout
5217 \begin_layout Subsection
5218 gui.image: Class IMAGELOADER
5219 \end_layout
5221 \begin_layout Standard
5222 See class IMAGELOADER.
5223 \end_layout
5225 \begin_layout Standard
5226 \begin_inset Newpage pagebreak
5227 \end_inset
5230 \end_layout
5232 \begin_layout Section
5233 table input
5234 \end_layout
5236 \begin_layout Standard
5237 Input handling.
5238  Functions manipulating input are only available in on_input callback.
5239 \end_layout
5241 \begin_layout Subsection
5242 input.get: Read controller button/axis (deprecated)
5243 \end_layout
5245 \begin_layout Itemize
5246 Syntax: number input.get(number controller, number index)
5247 \end_layout
5249 \begin_layout Standard
5250 Read the specified index <index> (zero-based) from specified controller
5251  <controller> (zero-based).
5253 \end_layout
5255 \begin_layout Subsection
5256 input.set: Write controller button/axis (deprecated)
5257 \end_layout
5259 \begin_layout Itemize
5260 Syntax: none input.set(number controller, number index, number value)
5261 \end_layout
5263 \begin_layout Standard
5264 Write the specified index <index> (zero-based) from specified controller
5265  <controller> (zero-based), storing value <value>.
5266 \end_layout
5268 \begin_layout Subsection
5269 input.get2: Read controller button/axis
5270 \end_layout
5272 \begin_layout Itemize
5273 Syntax: number input.get2(number port, number controller, number index)
5274 \end_layout
5276 \begin_layout Standard
5277 Read the specified input tuple.
5278  Port 0 is system port.
5279 \end_layout
5281 \begin_layout Subsection
5282 input.set2: Write controller button/axis
5283 \end_layout
5285 \begin_layout Itemize
5286 Syntax: input.set2(number port, number controller, number index, number value)
5287 \end_layout
5289 \begin_layout Standard
5290 Write the specified input tuple.
5291  Port 0 is system port.
5292 \end_layout
5294 \begin_layout Subsection
5295 input.lcid_to_pcid2: Look up logical controller
5296 \end_layout
5298 \begin_layout Itemize
5299 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5300 \end_layout
5302 \begin_layout Standard
5303 Look up physical pcid pair (port, controller) corresponding to specified
5304  logical controller (1-based).
5305  Returns nothing if controller does not exist.
5306 \end_layout
5308 \begin_layout Subsection
5309 input.port_type: Look up port type
5310 \end_layout
5312 \begin_layout Itemize
5313 Syntax: string input.port_type(number port)
5314 \end_layout
5316 \begin_layout Standard
5317 Return type of specified port.
5318 \end_layout
5320 \begin_layout Subsection
5321 input.controller_info: Get information about controller
5322 \end_layout
5324 \begin_layout Itemize
5325 Syntax: table input.controller_info(number port, number controller)
5326 \end_layout
5328 \begin_layout Standard
5329 Get controller info for specified controller.
5330  If controller does not exist, returns nil.
5331  Otherwise returns a table with following fields:
5332 \end_layout
5334 \begin_layout Itemize
5335 type (string): Type of the controller.
5336 \end_layout
5338 \begin_layout Itemize
5339 class (string): Class of the controller.
5340 \end_layout
5342 \begin_layout Itemize
5343 classnum (number): Number of the controller within its class (1-based)
5344 \end_layout
5346 \begin_layout Itemize
5347 lcid (number): Logical controller number of the controller.
5348 \end_layout
5350 \begin_layout Itemize
5351 button_count (number): Number of buttons on controller
5352 \end_layout
5354 \begin_layout Itemize
5355 buttons (array): Array of following info about each button:
5356 \end_layout
5358 \begin_deeper
5359 \begin_layout Itemize
5360 type (string): Type of button.
5361  Currently one of 
5362 \begin_inset Quotes eld
5363 \end_inset
5365 null
5366 \begin_inset Quotes erd
5367 \end_inset
5370 \begin_inset Quotes eld
5371 \end_inset
5373 button
5374 \begin_inset Quotes erd
5375 \end_inset
5378 \begin_inset Quotes eld
5379 \end_inset
5381 axis
5382 \begin_inset Quotes erd
5383 \end_inset
5386 \begin_inset Quotes eld
5387 \end_inset
5389 raxis
5390 \begin_inset Quotes erd
5391 \end_inset
5394 \end_layout
5396 \begin_layout Itemize
5397 name (string): Name of button.
5398 \end_layout
5400 \begin_layout Itemize
5401 symbol (string): Symbol of button.
5402  Only present for type 
5403 \begin_inset Quotes eld
5404 \end_inset
5406 button
5407 \begin_inset Quotes erd
5408 \end_inset
5411 \end_layout
5413 \begin_layout Itemize
5414 hidden (boolean): True if hidden button.
5416 \end_layout
5418 \end_deeper
5419 \begin_layout Subsection
5420 input.veto_button: Veto a button press
5421 \end_layout
5423 \begin_layout Itemize
5424 Syntax: none input.veto_button()
5425 \end_layout
5427 \begin_layout Standard
5428 Signals that the button event should be vetoed.
5429  Only valid in on_button callback.
5430 \end_layout
5432 \begin_layout Subsection
5433 input.geta: Get all buttons for controller (deprecated)
5434 \end_layout
5436 \begin_layout Itemize
5437 Syntax: (number, number...) input.geta(number controller)
5438 \end_layout
5440 \begin_layout Standard
5441 Get input state for entiere controller.
5442  Returns n return values.
5443 \end_layout
5445 \begin_layout Itemize
5446 1st return value: Bitmask: bit i is set if i:th index is nonzero
5447 \end_layout
5449 \begin_layout Itemize
5450 2nd- return value: value of i:th index.
5451 \end_layout
5453 \begin_layout Subsection
5454 input.seta: Set all buttons for controller (deprecated)
5455 \end_layout
5457 \begin_layout Itemize
5458 Syntax: none input.seta(number controller, number bitmask, number args...)
5459 \end_layout
5461 \begin_layout Standard
5462 Set state for entiere controller.
5463  args is up to N values for indices (overriding values in bitmask if specified).
5464 \end_layout
5466 \begin_layout Subsection
5467 input.controllertype: Get controller type (deprecated)
5468 \end_layout
5470 \begin_layout Itemize
5471 syntax: string input.controllertype(number controller)
5472 \end_layout
5474 \begin_layout Standard
5475 Get the type of controller as string.
5476 \end_layout
5478 \begin_layout Subsection
5479 input.reset: Execute (delayed) reset
5480 \end_layout
5482 \begin_layout Itemize
5483 Syntax: none input.reset([number cycles])
5484 \end_layout
5486 \begin_layout Standard
5487 Execute reset.
5488  If <cycles> is greater than zero, do delayed reset.
5489  0 (or no value) causes immediate reset.
5490 \end_layout
5492 \begin_layout Itemize
5493 Note: Only available with subframe flag false.
5494 \end_layout
5496 \begin_layout Subsection
5497 input.raw: Return raw input data
5498 \end_layout
5500 \begin_layout Itemize
5501 Syntax: table input.raw()
5502 \end_layout
5504 \begin_layout Standard
5505 Returns table of tables of all available keys and axes.
5506  The first table is indexed by key name (platform-dependent!), and the inner
5507  table has the following fields:
5508 \end_layout
5510 \begin_layout Itemize
5511 value: Last reported value for control
5512 \end_layout
5514 \begin_deeper
5515 \begin_layout Itemize
5516 For keys: 1 for pressed, 0 for released.
5517 \end_layout
5519 \begin_layout Itemize
5520 For axes: -32767...32767.
5521 \end_layout
5523 \begin_layout Itemize
5524 For presure-sensitive buttons: 0...32767.
5525 \end_layout
5527 \begin_layout Itemize
5528 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
5529 \end_layout
5531 \begin_layout Itemize
5532 For mouse: Coordinates relative to game area.
5533 \end_layout
5535 \end_deeper
5536 \begin_layout Itemize
5537 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
5538 \end_layout
5540 \begin_layout Subsection
5541 input.keyhook: Hook a key
5542 \end_layout
5544 \begin_layout Itemize
5545 Syntax: none input.keyhook(string key, boolean state)
5546 \end_layout
5548 \begin_layout Standard
5549 Requests that keyhook events to be sent for key <key> (<state>=true) or
5550  not sent (<state>=false).
5551 \end_layout
5553 \begin_layout Subsection
5554 input.joyget: Get controls for controller
5555 \end_layout
5557 \begin_layout Itemize
5558 Syntax: table input.joyget(number logical)
5559 \end_layout
5561 \begin_layout Standard
5562 Returns table for current controls for specified logical controller <logical>.
5563  The names of fields vary by controller type.
5564 \end_layout
5566 \begin_layout Itemize
5567 The buttons have the same name as those are referred to in other contexts
5568  in the emulator
5569 \end_layout
5571 \begin_layout Itemize
5572 The analog axes are usually 
5573 \begin_inset Quotes eld
5574 \end_inset
5576 xaxis
5577 \begin_inset Quotes erd
5578 \end_inset
5580  and 
5581 \begin_inset Quotes eld
5582 \end_inset
5584 yaxis
5585 \begin_inset Quotes erd
5586 \end_inset
5589 \end_layout
5591 \begin_layout Itemize
5592 Each field is numeric or boolean depending on axis/button.
5593 \end_layout
5595 \begin_layout Subsection
5596 input.joyset: Set controls for controller
5597 \end_layout
5599 \begin_layout Itemize
5600 Syntax: none input.joyset(number controller, table controls)
5601 \end_layout
5603 \begin_layout Standard
5604 Set the the state of specified controller to values specified in specified
5605  table.
5606 \end_layout
5608 \begin_layout Itemize
5609 Each field can be boolean or number.
5610 \end_layout
5612 \begin_layout Itemize
5613 Also, buttons allow strings, which cause value to be inverted.
5614 \end_layout
5616 \begin_layout Subsection
5617 input.lcid_to_pcid: Look up logical controller (deprecated)
5618 \end_layout
5620 \begin_layout Itemize
5621 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
5622 \end_layout
5624 \begin_layout Standard
5625 Returns the legacy pcid for controller (or false if there isn't one), followed
5626  by pcid pair.
5627  Returns nothing if controller does not exist.
5628 \end_layout
5630 \begin_layout Standard
5631 \begin_inset Newpage pagebreak
5632 \end_inset
5635 \end_layout
5637 \begin_layout Section
5638 Table keyboard
5639 \end_layout
5641 \begin_layout Standard
5642 Various keybinding-related functions
5643 \end_layout
5645 \begin_layout Subsection
5646 keyboard.bind: Bind a key
5647 \end_layout
5649 \begin_layout Itemize
5650 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
5651 \end_layout
5653 \begin_layout Standard
5654 Bind specified key with specified modifers to specified command.
5655 \end_layout
5657 \begin_layout Subsection
5658 keyboard.unbind: Unbind a key
5659 \end_layout
5661 \begin_layout Itemize
5662 Syntax: none keyboard.unbind(string mod, string mask, string key)
5663 \end_layout
5665 \begin_layout Standard
5666 Unbind specified key with specified modifers.
5667 \end_layout
5669 \begin_layout Subsection
5670 keyboard.alias: Set alias expansion
5671 \end_layout
5673 \begin_layout Itemize
5674 Syntax: none keyboard.alias(string alias, string expansion)
5675 \end_layout
5677 \begin_layout Standard
5678 Set expansion of given command.
5679 \end_layout
5681 \begin_layout Standard
5682 \begin_inset Newpage pagebreak
5683 \end_inset
5686 \end_layout
5688 \begin_layout Section
5689 Table subtitle
5690 \end_layout
5692 \begin_layout Standard
5693 Subtitle handling
5694 \end_layout
5696 \begin_layout Subsection
5697 subtitle.byindex: Look up start and length of subtitle by index
5698 \end_layout
5700 \begin_layout Itemize
5701 Syntax: (number, number) subtitle.byindex(number i)
5702 \end_layout
5704 \begin_layout Standard
5705 Read the frame and length of ith subtitle.
5706  Returns nothing if not present.
5707 \end_layout
5709 \begin_layout Subsection
5710 subtitle.set: Write a subtitle
5711 \end_layout
5713 \begin_layout Itemize
5714 Syntax: none subtitle.set(number f, number l, string txt)
5715 \end_layout
5717 \begin_layout Standard
5718 Set the text of subtitle.
5719 \end_layout
5721 \begin_layout Subsection
5722 subtitle.get: Read a subtitle
5723 \end_layout
5725 \begin_layout Itemize
5726 Syntax: string subtitle.get(number f, number l)
5727 \end_layout
5729 \begin_layout Standard
5730 Get the text of subtitle.
5731 \end_layout
5733 \begin_layout Subsection
5734 subtitle.delete: Delete a subtitle
5735 \end_layout
5737 \begin_layout Itemize
5738 Syntax: none subtitle.delete(number f, number l)
5739 \end_layout
5741 \begin_layout Standard
5742 Delete specified subtitle.
5743 \end_layout
5745 \begin_layout Standard
5746 \begin_inset Newpage pagebreak
5747 \end_inset
5750 \end_layout
5752 \begin_layout Section
5753 Table hostmemory
5754 \end_layout
5756 \begin_layout Standard
5757 Host memory handling (extra memory saved to savestates).
5758  Host memory starts empty.
5759 \end_layout
5761 \begin_layout Itemize
5762 Reads out of range return false.
5763 \end_layout
5765 \begin_layout Itemize
5766 Writes out of range extend the memory.
5767 \end_layout
5769 \begin_layout Subsection
5770 hostmemory.read: Read byte from host memory
5771 \end_layout
5773 \begin_layout Itemize
5774 Syntax: number hostmemory.read(number address)
5775 \end_layout
5777 \begin_layout Standard
5778 Reads byte from hostmemory slot address <address>.
5779 \end_layout
5781 \begin_layout Subsection
5782 hostmemory.write: Write byte to host memory
5783 \end_layout
5785 \begin_layout Itemize
5786 Syntax: none hostmemory.write(number address, number value)
5787 \end_layout
5789 \begin_layout Standard
5790 Writes hostmemory slot with value <value> 0-255.
5791 \end_layout
5793 \begin_layout Subsection
5794 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
5795 \end_layout
5797 \begin_layout Itemize
5798 Syntax: number hostmemory.readbyte(number address)
5799 \end_layout
5801 \begin_layout Itemize
5802 Syntax: number hostmemory.readsbyte(number address)
5803 \end_layout
5805 \begin_layout Itemize
5806 Syntax: number hostmemory.readword(number address)
5807 \end_layout
5809 \begin_layout Itemize
5810 Syntax: number hostmemory.readsword(number address)
5811 \end_layout
5813 \begin_layout Itemize
5814 Syntax: number hostmemory.readhword(number address)
5815 \end_layout
5817 \begin_layout Itemize
5818 Syntax: number hostmemory.readshword(number address)
5819 \end_layout
5821 \begin_layout Itemize
5822 Syntax: number hostmemory.readdword(number address)
5823 \end_layout
5825 \begin_layout Itemize
5826 Syntax: number hostmemory.readsdword(number address)
5827 \end_layout
5829 \begin_layout Itemize
5830 Syntax: number hostmemory.readqword(number address)
5831 \end_layout
5833 \begin_layout Itemize
5834 Syntax: number hostmemory.readsqword(number address)
5835 \end_layout
5837 \begin_layout Standard
5838 Read elements (big-endian) from given address <address>.
5839 \end_layout
5841 \begin_layout Itemize
5842 byte is 1 element
5843 \end_layout
5845 \begin_layout Itemize
5846 word is 2 elements
5847 \end_layout
5849 \begin_layout Itemize
5850 hword is 3 elements
5851 \end_layout
5853 \begin_layout Itemize
5854 dword is 4 elements
5855 \end_layout
5857 \begin_layout Itemize
5858 qword is 8 elements.
5859 \end_layout
5861 \begin_layout Itemize
5862 The 's' variants do signed read.
5863 \end_layout
5865 \begin_layout Subsection
5866 hostmemory.read{float,double}: Read from host memory
5867 \end_layout
5869 \begin_layout Itemize
5870 syntax: number hostmemory.readfloat(number address)
5871 \end_layout
5873 \begin_layout Itemize
5874 Syntax: number hostmemory.readdouble(number address)
5875 \end_layout
5877 \begin_layout Standard
5878 Read elements (big-endian) floating-pont from given address <address>.
5879 \end_layout
5881 \begin_layout Subsection
5882 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
5883 \end_layout
5885 \begin_layout Itemize
5886 Syntax: number hostmemory.writebyte(number address, number value)
5887 \end_layout
5889 \begin_layout Itemize
5890 Syntax: number hostmemory.writesbyte(number address, number value)
5891 \end_layout
5893 \begin_layout Itemize
5894 Syntax: number hostmemory.writeword(number address, number value)
5895 \end_layout
5897 \begin_layout Itemize
5898 Syntax: number hostmemory.writesword(number address, number value)
5899 \end_layout
5901 \begin_layout Itemize
5902 Syntax: number hostmemory.writehword(number address, number value)
5903 \end_layout
5905 \begin_layout Itemize
5906 Syntax: number hostmemory.writeshword(number address, number value)
5907 \end_layout
5909 \begin_layout Itemize
5910 Syntax: number hostmemory.writedword(number address, number value)
5911 \end_layout
5913 \begin_layout Itemize
5914 Syntax: number hostmemory.writesdword(number address, number value)
5915 \end_layout
5917 \begin_layout Itemize
5918 Syntax: number hostmemory.writeqword(number address, number value)
5919 \end_layout
5921 \begin_layout Itemize
5922 Syntax: number hostmemory.writesqword(number address, number value)
5923 \end_layout
5925 \begin_layout Standard
5926 Write value <value> to elements (little-endian) starting from given address
5927  <address>.
5928 \end_layout
5930 \begin_layout Itemize
5931 byte is 1 element
5932 \end_layout
5934 \begin_layout Itemize
5935 word is 2 elements
5936 \end_layout
5938 \begin_layout Itemize
5939 hword is 3 elements
5940 \end_layout
5942 \begin_layout Itemize
5943 dword is 4 elements
5944 \end_layout
5946 \begin_layout Itemize
5947 qword is 8 elements.
5948 \end_layout
5950 \begin_layout Itemize
5951 The 's' variants do signed write.
5952 \end_layout
5954 \begin_layout Subsection
5955 hostmemory.write{float,double}: Write to host memory
5956 \end_layout
5958 \begin_layout Itemize
5959 syntax: none hostmemory.readfloat(number address, number value)
5960 \end_layout
5962 \begin_layout Itemize
5963 Syntax: none hostmemory.readdouble(number address, number value)
5964 \end_layout
5966 \begin_layout Standard
5967 Write elements (big-endian) floating-pont to given address <address>, storing
5968  <value>.
5969 \end_layout
5971 \begin_layout Standard
5972 \begin_inset Newpage pagebreak
5973 \end_inset
5976 \end_layout
5978 \begin_layout Section
5979 Table movie
5980 \end_layout
5982 \begin_layout Standard
5983 Movie handling
5984 \end_layout
5986 \begin_layout Subsection
5987 movie.currentframe: Get current frame number
5988 \end_layout
5990 \begin_layout Itemize
5991 Syntax: number movie.currentframe()
5992 \end_layout
5994 \begin_layout Standard
5995 Return number of current frame.
5996 \end_layout
5998 \begin_layout Subsection
5999 movie.framecount: Get move frame count
6000 \end_layout
6002 \begin_layout Itemize
6003 Syntax: number movie.framecount()
6004 \end_layout
6006 \begin_layout Standard
6007 Return number of frames in movie.
6008 \end_layout
6010 \begin_layout Subsection
6011 movie.lagcount: Get current lag count
6012 \end_layout
6014 \begin_layout Itemize
6015 Syntax: number movie.lagcount()
6016 \end_layout
6018 \begin_layout Standard
6019 Return number of lag frames recorded so far.
6020 \end_layout
6022 \begin_layout Subsection
6023 movie.readonly: Is in readonly mode?
6024 \end_layout
6026 \begin_layout Itemize
6027 Syntax: boolean movie.readonly()
6028 \end_layout
6030 \begin_layout Standard
6031 Return true if in readonly mode, false if in readwrite.
6032 \end_layout
6034 \begin_layout Subsection
6035 movie.rerecords: Movie rerecord count
6036 \end_layout
6038 \begin_layout Itemize
6039 Syntax: number movie.rerecords()
6040 \end_layout
6042 \begin_layout Standard
6043 Returns the current value of rerecord count.
6044 \end_layout
6046 \begin_layout Subsection
6047 movie.set_readwrite: Set read-write mode.
6048 \end_layout
6050 \begin_layout Itemize
6051 Syntax: none movie.set_readwrite()
6052 \end_layout
6054 \begin_layout Standard
6055 Set readwrite mode (does not cause on_readwrite callback).
6056 \end_layout
6058 \begin_layout Subsection
6059 movie.frame_subframes: Count subframes in frame
6060 \end_layout
6062 \begin_layout Itemize
6063 Syntax: number movie.frame_subframes(number frame)
6064 \end_layout
6066 \begin_layout Standard
6067 Count number of subframes in specified frame <frame> (frame numbers are
6068  1-based) and return that.
6069 \end_layout
6071 \begin_layout Subsection
6072 movie.read_subframes: Read subframe data (deprecated)
6073 \end_layout
6075 \begin_layout Itemize
6076 Syntax: table movie.read_subframes(number frame, number subframe)
6077 \end_layout
6079 \begin_layout Standard
6080 Read specifed subframe in specified frame and return data as array.
6081 \end_layout
6083 \begin_layout Subsection
6084 movie.read_rtc: Read current RTC time
6085 \end_layout
6087 \begin_layout Itemize
6088 Syntax: (number, number) movie.read_rtc()
6089 \end_layout
6091 \begin_layout Standard
6092 Returns the current value of the RTC as a pair (second, subsecond).
6093 \end_layout
6095 \begin_layout Subsection
6096 movie.unsafe_rewind: Fast movie rewind to saved state
6097 \end_layout
6099 \begin_layout Itemize
6100 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6101 \end_layout
6103 \begin_layout Standard
6104 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6105 \end_layout
6107 \begin_layout Itemize
6108 If called without argument, causes emulator to start process of setting
6109  unsafe rewind point.
6110  When this has finished, callback on_set_rewind occurs, passing the rewind
6111  state to lua script.
6112 \end_layout
6114 \begin_layout Itemize
6115 If called with argument, causes emulator rewind to passed rewind point as
6116  soon as possible.
6117  Readwrite mode is implicitly activated.
6118 \end_layout
6120 \begin_layout Standard
6121 The following warnings apply to unsafe rewinding:
6122 \end_layout
6124 \begin_layout Itemize
6125 There are no safety checks against misuse (that's what 
6126 \begin_inset Quotes eld
6127 \end_inset
6129 unsafe
6130 \begin_inset Quotes erd
6131 \end_inset
6133  comes from)!
6134 \end_layout
6136 \begin_layout Itemize
6137 Only call rewind from timeline rewind point was set from.
6138 \end_layout
6140 \begin_layout Itemize
6141 Only call rewind from after the rewind point was set.
6142 \end_layout
6144 \begin_layout Subsection
6145 movie.to_rewind: Load savestate as rewind point
6146 \end_layout
6148 \begin_layout Itemize
6149 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6150 \end_layout
6152 \begin_layout Standard
6153 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6154  corresponding to it.
6155 \end_layout
6157 \begin_layout Itemize
6158 Note: This operation does not take emulated time.
6159 \end_layout
6161 \begin_layout Subsection
6162 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6163 \end_layout
6165 \begin_layout Itemize
6166 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6167 \end_layout
6169 \begin_layout Itemize
6170 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6171 \end_layout
6173 \begin_layout Standard
6174 Copies specified movie or branch <movie>/current object (if none or nil,
6175  the active movie) as new movie object.
6176 \end_layout
6178 \begin_layout Subsection
6179 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6180 \end_layout
6182 \begin_layout Itemize
6183 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6184 \end_layout
6186 \begin_layout Itemize
6187 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6188 \end_layout
6190 \begin_layout Standard
6191 Get INPUTFRAME object corresponding to specified frame in specified movie
6192  or branch.
6193 \end_layout
6195 \begin_layout Subsection
6196 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6197 \end_layout
6199 \begin_layout Itemize
6200 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6201  data)
6202 \end_layout
6204 \begin_layout Itemize
6205 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6206 \end_layout
6208 \begin_layout Standard
6209 Set data in specified frame.
6210 \end_layout
6212 \begin_layout Itemize
6213 Note: Past can't be edited in active movie.
6214 \end_layout
6216 \begin_layout Subsection
6217 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6218 \end_layout
6220 \begin_layout Itemize
6221 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6222 \end_layout
6224 \begin_layout Itemize
6225 Syntax: integer INPUTMOVIE::get_size()
6226 \end_layout
6228 \begin_layout Standard
6229 Return number of subframes in specified movie or branch.
6230 \end_layout
6232 \begin_layout Subsection
6233 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6234 \end_layout
6236 \begin_layout Itemize
6237 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6238 \end_layout
6240 \begin_layout Itemize
6241 Syntax: number INPUTMOVIE::count_frames()
6242 \end_layout
6244 \begin_layout Standard
6245 Return number of frames in movie.
6246 \end_layout
6248 \begin_layout Subsection
6249 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6250 \end_layout
6252 \begin_layout Itemize
6253 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6254 \end_layout
6256 \begin_layout Itemize
6257 Syntax: number INPUTMOVIE::find_frame(number frame)
6258 \end_layout
6260 \begin_layout Standard
6261 Returns starting subframe of given frame (frame numbers are 1-based).
6262  Returns -1 if frame number is bad.
6263 \end_layout
6265 \begin_layout Subsection
6266 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6267 \end_layout
6269 \begin_layout Itemize
6270 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6271 \end_layout
6273 \begin_layout Itemize
6274 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6275 \end_layout
6277 \begin_layout Standard
6278 Return blank INPUTFRAME with frame type from specified movie.
6279 \end_layout
6281 \begin_layout Subsection
6282 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6283 \end_layout
6285 \begin_layout Itemize
6286 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6287 \end_layout
6289 \begin_layout Itemize
6290 Syntax: none INPUTMOVIE::append_frames(number frames)
6291 \end_layout
6293 \begin_layout Standard
6294 Append specified number <frames> of frames.
6295 \end_layout
6297 \begin_layout Subsection
6298 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
6299 \end_layout
6301 \begin_layout Itemize
6302 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
6303 \end_layout
6305 \begin_layout Itemize
6306 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
6307 \end_layout
6309 \begin_layout Standard
6310 Append specified frame <frame>.
6311  Past of current movie can't be edited.
6312 \end_layout
6314 \begin_layout Subsection
6315 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
6316 \end_layout
6318 \begin_layout Itemize
6319 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
6320 \end_layout
6322 \begin_layout Itemize
6323 Syntax: none INPUTMOVIE::truncate(number frames)
6324 \end_layout
6326 \begin_layout Standard
6327 Truncate the specified movie to specified number of frames.
6328 \end_layout
6330 \begin_layout Subsection
6331 movie.edit/INPUTMOVIE::edit: Edit a movie
6332 \end_layout
6334 \begin_layout Itemize
6335 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
6336  controller, number control, number/bool value)
6337 \end_layout
6339 \begin_layout Itemize
6340 Syntax: none movie.edit(string branch, number frame, number port, number
6341  controller, number control, number/bool value)
6342 \end_layout
6344 \begin_layout Itemize
6345 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
6346  number control, number/bool value)
6347 \end_layout
6349 \begin_layout Standard
6350 Change specified control in specified frame in specified movie.
6351  Past can't be edited in active movie.
6352 \end_layout
6354 \begin_layout Subsection
6355 movie.copy_frames2: Copy frames between movies
6356 \end_layout
6358 \begin_layout Itemize
6359 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
6360 IE/string srcmov,] number src, number count)
6361 \end_layout
6363 \begin_layout Standard
6364 Copy specified number of frames between two movies.
6365  The copy proceeeds in forward direction.
6366 \end_layout
6368 \begin_layout Subsection
6369 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
6370 \end_layout
6372 \begin_layout Itemize
6373 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
6374  src, number count, bool backwards)
6375 \end_layout
6377 \begin_layout Itemize
6378 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
6379  bool backwards)
6380 \end_layout
6382 \begin_layout Standard
6383 Copy specified number of frames from one point in movie to another.
6384  If backwards is true, the copy will be done backwards.
6385 \end_layout
6387 \begin_layout Subsection
6388 movie.serialize/INPUTMOVIE::serialize: Serialize movie
6389 \end_layout
6391 \begin_layout Itemize
6392 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
6393  bool binary)
6394 \end_layout
6396 \begin_layout Itemize
6397 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
6398 \end_layout
6400 \begin_layout Standard
6401 Serialize given movie into file.
6402  If binary is true, binary format (more compact and much faster) is used.
6403 \end_layout
6405 \begin_layout Subsection
6406 movie.unserialize: Unserialize movie
6407 \end_layout
6409 \begin_layout Itemize
6410 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
6411  bool binary)
6412 \end_layout
6414 \begin_layout Standard
6415 Unserialize movie from file.
6416  The given frame is used as template to decide the frame type.
6417  If binary is true, binary format is decoded (much faster).
6418 \end_layout
6420 \begin_layout Subsection
6421 movie.current_first_subframe: Return first subframe in current frame
6422 \end_layout
6424 \begin_layout Itemize
6425 Syntax: number movie.current_first_subframe()
6426 \end_layout
6428 \begin_layout Standard
6429 Returns first subframe in current frame.
6430 \end_layout
6432 \begin_layout Subsection
6433 movie.pollcounter: Return poll counter for speified control
6434 \end_layout
6436 \begin_layout Itemize
6437 Syntax: number movie.pollcounter(number port, number controller, number control)
6438 \end_layout
6440 \begin_layout Standard
6441 Returns number of times the specified control has been polled this frame.
6442 \end_layout
6444 \begin_layout Subsection
6445 movie.current_branch: Return current branch
6446 \end_layout
6448 \begin_layout Itemize
6449 Syntax: string movie.current_branch()
6450 \end_layout
6452 \begin_layout Standard
6453 Returns the name of the current branch.
6454 \end_layout
6456 \begin_layout Subsection
6457 movie.get_branches: Return names of all branches
6458 \end_layout
6460 \begin_layout Itemize
6461 Syntax: string...
6462  movie.get_branches()
6463 \end_layout
6465 \begin_layout Standard
6466 Returns the name of all branches.
6467 \end_layout
6469 \begin_layout Subsection
6470 INPUTFRAME::get_button: Get button
6471 \end_layout
6473 \begin_layout Itemize
6474 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
6475  control)
6476 \end_layout
6478 \begin_layout Standard
6479 Returns state of given button as boolean.
6480 \end_layout
6482 \begin_layout Subsection
6483 INPUTFRAME::get_axis: Get axis
6484 \end_layout
6486 \begin_layout Itemize
6487 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
6488  control)
6489 \end_layout
6491 \begin_layout Standard
6492 Returns state of given axis as number.
6493 \end_layout
6495 \begin_layout Subsection
6496 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
6497 \end_layout
6499 \begin_layout Itemize
6500 Syntax: none INPUTFRAME::set_button(number port, number controller, number
6501  control, number/bool value)
6502 \end_layout
6504 \begin_layout Itemize
6505 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
6506  control)
6507 \end_layout
6509 \begin_layout Standard
6510 Set the given button/axis to given value.
6511 \end_layout
6513 \begin_layout Subsection
6514 INPUTFRAME::serialize: Serialize a frame
6515 \end_layout
6517 \begin_layout Itemize
6518 Syntax: string INPUTFRAME::serialize()
6519 \end_layout
6521 \begin_layout Standard
6522 Return string representation of frame.
6523 \end_layout
6525 \begin_layout Subsection
6526 INPUTFRAME::unserialize: Unserialize a frame
6527 \end_layout
6529 \begin_layout Itemize
6530 Syntax: none INPUTFRAME::unserialize(string data)
6531 \end_layout
6533 \begin_layout Standard
6534 Set current frame from given data.
6535 \end_layout
6537 \begin_layout Subsection
6538 INPUTFRAME::get_stride: Get movie stride
6539 \end_layout
6541 \begin_layout Itemize
6542 Syntax: number INPUTFRAME::get_stride()
6543 \end_layout
6545 \begin_layout Standard
6546 Return number of bytes needed to store the input frame.
6547  Mainly useful for some debugging.
6548 \end_layout
6550 \begin_layout Standard
6551 \begin_inset Newpage pagebreak
6552 \end_inset
6555 \end_layout
6557 \begin_layout Section
6558 Table settings
6559 \end_layout
6561 \begin_layout Standard
6562 Routines for settings manipulation
6563 \end_layout
6565 \begin_layout Subsection
6566 settings.get: Get value of setting
6567 \end_layout
6569 \begin_layout Itemize
6570 Syntax: string settings.get(string name)
6571 \end_layout
6573 \begin_layout Standard
6574 Get value of setting <name>.
6575  If setting value can't be obtained, returns (nil, error message).
6576 \end_layout
6578 \begin_layout Subsection
6579 settings.set: Set value of setting
6580 \end_layout
6582 \begin_layout Itemize
6583 Syntax: none settings.set(string name, string value)
6584 \end_layout
6586 \begin_layout Standard
6587 Set value <value> of setting <name>.
6588  If setting can't be set, returns (nil, error message).
6589 \end_layout
6591 \begin_layout Standard
6592 \begin_inset Newpage pagebreak
6593 \end_inset
6596 \end_layout
6598 \begin_layout Section
6599 Table memory
6600 \end_layout
6602 \begin_layout Standard
6603 Contains various functions for managing memory
6604 \end_layout
6606 \begin_layout Subsection
6607 memory.vma_count: Count number of memory areas.
6608 \end_layout
6610 \begin_layout Itemize
6611 Syntax: number memory.vma_count()
6612 \end_layout
6614 \begin_layout Standard
6615 Returns the number of memory areas
6616 \end_layout
6618 \begin_layout Subsection
6619 memory.read_vma: Lookup memory area info by index
6620 \end_layout
6622 \begin_layout Itemize
6623 Syntax: table memory.read_vma(number index)
6624 \end_layout
6626 \begin_layout Standard
6627 Reads the specified memory area (indices start from zero).
6628  Trying to read invalid memory area gives nil.
6629  The return value is table with the following fields:
6630 \end_layout
6632 \begin_layout Itemize
6633 region_name (string): The readable name of the memory area
6634 \end_layout
6636 \begin_layout Itemize
6637 baseaddr (number): Base address of the memory area
6638 \end_layout
6640 \begin_layout Itemize
6641 lastaddr (number): Last address in the memory area.
6642 \end_layout
6644 \begin_layout Itemize
6645 size (number): The size of memory area in bytes.
6646 \end_layout
6648 \begin_layout Itemize
6649 readonly (boolean): True of the memory area corresponds to ROM.
6650 \end_layout
6652 \begin_layout Itemize
6653 iospace (boolean): True if the memory area is I/O space.
6654 \end_layout
6656 \begin_layout Itemize
6657 native_endian (boolean): True if the memory area has native endian as opposed
6658  to little endian.
6659 \end_layout
6661 \begin_layout Subsection
6662 memory.find_vma: Find memory area info by address
6663 \end_layout
6665 \begin_layout Itemize
6666 Syntax: table memory.find_vma(number address)
6667 \end_layout
6669 \begin_layout Standard
6670 Finds the memory area containing specified address.
6671  Returns table in the same format as read_vma or nil if not found.
6672 \end_layout
6674 \begin_layout Subsection
6675 memory.read{,s}{byte,{,h,d,q}word}: Read memory
6676 \end_layout
6678 \begin_layout Itemize
6679 Syntax: none memory.readbyte([string marea, ]number address)
6680 \end_layout
6682 \begin_layout Itemize
6683 Syntax: none memory.readword([string marea, ]number address)
6684 \end_layout
6686 \begin_layout Itemize
6687 Syntax: none memory.readhword([string marea, ]number address)
6688 \end_layout
6690 \begin_layout Itemize
6691 Syntax: none memory.readdword([string marea, ]number address)
6692 \end_layout
6694 \begin_layout Itemize
6695 Syntax: none memory.readqword([string marea, ]number address)
6696 \end_layout
6698 \begin_layout Itemize
6699 Syntax: none memory.readsbyte([string marea, ]number address)
6700 \end_layout
6702 \begin_layout Itemize
6703 Syntax: none memory.readsword([string marea, ]number address)
6704 \end_layout
6706 \begin_layout Itemize
6707 Syntax: none memory.readshword([string marea, ]number address)
6708 \end_layout
6710 \begin_layout Itemize
6711 Syntax: none memory.readsdword([string marea, ]number address)
6712 \end_layout
6714 \begin_layout Itemize
6715 Syntax: none memory.readsqword([string marea, ]number address)
6716 \end_layout
6718 \begin_layout Standard
6719 Reads the specified address <address> (if 's' variant is used, do undergo
6720  2's complement).
6721 \end_layout
6723 \begin_layout Subsection
6724 memory.{,s}read_sg: Scatter/Gather read memory
6725 \end_layout
6727 \begin_layout Itemize
6728 Syntax: none memory.read_sg(string/boolean/number...)
6729 \end_layout
6731 \begin_layout Itemize
6732 Syntax: none memory.sread_sg(string/boolean/number...)
6733 \end_layout
6735 \begin_layout Standard
6736 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
6737  of memory.
6738  Each argument can be string, boolean or number:
6739 \end_layout
6741 \begin_layout Itemize
6742 String: Set memory area addresses are relative to (e.g.
6743  'WRAM').
6744 \end_layout
6746 \begin_layout Itemize
6747 boolean: If true, increment relative address by 1, if false, decrement by
6748  1.
6749  The new address is read as next higher byte.
6750 \end_layout
6752 \begin_layout Itemize
6753 integer: Set the relative address to specified value and read the address
6754  as next higher byte.
6755 \end_layout
6757 \begin_layout Subsection
6758 memory.write_sg: Scatter/Gather write memory
6759 \end_layout
6761 \begin_layout Itemize
6762 Syntax: none memory.write_sg(number value, string/boolean/number...)
6763 \end_layout
6765 \begin_layout Standard
6766 Perform scatter/gather write of value <value> on memory.
6767  Each argument can be string, boolean or number:
6768 \end_layout
6770 \begin_layout Itemize
6771 String: Set memory area addresses are relative to (e.g.
6772  'WRAM').
6773 \end_layout
6775 \begin_layout Itemize
6776 boolean: If true, increment relative address by 1, if false, decrement by
6777  1.
6778  The new address is read as next higher byte.
6779 \end_layout
6781 \begin_layout Itemize
6782 integer: Set the relative address to specified value and read the address
6783  as next higher byte.
6784 \end_layout
6786 \begin_layout Subsection
6787 memory.read{float,double}: Read memory
6788 \end_layout
6790 \begin_layout Itemize
6791 Syntax: none memory.readfloat([string marea, ]number address)
6792 \end_layout
6794 \begin_layout Itemize
6795 Syntax: none memory.readdouble([string marea, ]number address)
6796 \end_layout
6798 \begin_layout Standard
6799 Reads the specified address <address>
6800 \end_layout
6802 \begin_layout Subsection
6803 memory.write{byte,{,h,d,q}word,float,double}: Write memory
6804 \end_layout
6806 \begin_layout Itemize
6807 Syntax: none memory.writebyte([string marea, ]number address, number value)
6808 \end_layout
6810 \begin_layout Itemize
6811 Syntax: none memory.writeword([string marea, ]number address, number value)
6812 \end_layout
6814 \begin_layout Itemize
6815 Syntax: none memory.writehword([string marea, ]number address, number value)
6816 \end_layout
6818 \begin_layout Itemize
6819 Syntax: none memory.writedword([string marea, ]number address, number value)
6820 \end_layout
6822 \begin_layout Itemize
6823 Syntax: none memory.writeqword([string marea, ]number address, number value)
6824 \end_layout
6826 \begin_layout Itemize
6827 Syntax: none memory.writefloat([string marea, ]number address, number value)
6828 \end_layout
6830 \begin_layout Itemize
6831 Syntax: none memory.writedouble([string marea, ]number address, number value)
6832 \end_layout
6834 \begin_layout Standard
6835 Writes the specified value <value> (negative integer values undergo 2's
6836  complement) to specified address <address>.
6837 \end_layout
6839 \begin_layout Subsection
6840 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
6841 \end_layout
6843 \begin_layout Itemize
6844 Syntax: userdata memory.map<type>([[string marea, ]number base, number size])
6845 \end_layout
6847 \begin_layout Standard
6848 Returns a table mapping specified memory aperture for read/write.
6849  If parameters are omitted, entiere map space is the aperture.
6850 \end_layout
6852 \begin_layout Itemize
6853 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
6854  qword, sqword, float or double.
6855 \end_layout
6857 \begin_layout Subsection
6858 memory.hash_region: Hash region of memory
6859 \end_layout
6861 \begin_layout Itemize
6862 Syntax: string memory.hash_region([string marea, ]number base, number size)
6863 \end_layout
6865 \begin_layout Standard
6866 Hash <size> bytes starting from address <base> (relative to <marea>) and
6867  return the SHA-256.
6868 \end_layout
6870 \begin_layout Subsection
6871 memory.hash_region2: Hash region of memory
6872 \end_layout
6874 \begin_layout Itemize
6875 Syntax: string memory.hash_region2([string marea, ]number base, number size[,
6876  number rows, number stride])
6877 \end_layout
6879 \begin_layout Standard
6880 Hash <rows> blocks of <size> bytes starting from address <base> (relative
6881  to <marea>).
6882  The blocks are offset by <stride> from one another and return the SHA-256.
6883 \end_layout
6885 \begin_layout Subsection
6886 memory.hash_region_skein: Hash region of memory
6887 \end_layout
6889 \begin_layout Itemize
6890 Syntax: string memory.hash_region_skein([string marea, ]number base, number
6891  size[, number rows, number stride])
6892 \end_layout
6894 \begin_layout Standard
6895 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
6896  finalists) as hash function.
6897 \end_layout
6899 \begin_layout Subsection
6900 memory.store: Store region of memory
6901 \end_layout
6903 \begin_layout Itemize
6904 Syntax: none memory.store([string marea, ]number addr, number daddr[, number
6905  rows, number stride]
6906 \end_layout
6908 \begin_layout Standard
6909 Copy memory starting from <addr> in memory area <marea> (each row being
6910  of size <size>, there being <rows> rows, and rows being separated by <stride>
6911  in memory) into savestate-saved memory area, starting from <daadr> (all
6912  rows are written back to back).
6913 \end_layout
6915 \begin_layout Subsection
6916 memory.storecmp: Compare and store region of memory
6917 \end_layout
6919 \begin_layout Itemize
6920 Syntax: bool memory.storecmp([string marea, ]number addr, number daddr[,
6921  number rows, number stride]
6922 \end_layout
6924 \begin_layout Standard
6925 Like memory.store, but returns true if target of copy already held the value
6926  that would be copied before the copy happened.
6927  Otherwise returns false (if target and source differ before copy).
6928 \end_layout
6930 \begin_layout Subsection
6931 memory.hash_state: Hash system state
6932 \end_layout
6934 \begin_layout Itemize
6935 Syntax: string memory.hash_state()
6936 \end_layout
6938 \begin_layout Standard
6939 Hash the current system state.
6940  Mainly useful for debugging savestates.
6941 \end_layout
6943 \begin_layout Subsection
6944 memory.readregion: Read region of memory
6945 \end_layout
6947 \begin_layout Itemize
6948 Syntax: table memory.readregion([string marea, ]number base, number size)
6949 \end_layout
6951 \begin_layout Standard
6952 Read a region of memory.
6953 \end_layout
6955 \begin_layout Itemize
6956 Warning: If the region crosses memory area boundary, the results are undefined.
6957 \end_layout
6959 \begin_layout Subsection
6960 memory.writeregion: Write region of memory
6961 \end_layout
6963 \begin_layout Itemize
6964 Syntax: none memory.writeregion([string marea, ]number base, number size,
6965  table data)
6966 \end_layout
6968 \begin_layout Standard
6969 Write a region of memory.
6970 \end_layout
6972 \begin_layout Itemize
6973 Warning: If the region crosses memory area boundary, the results are undefined.
6974 \end_layout
6976 \begin_layout Subsection
6977 memory.action: Run core action
6978 \end_layout
6980 \begin_layout Itemize
6981 memory.action(string action, [<params>])
6982 \end_layout
6984 \begin_layout Standard
6985 Run core action.
6986  The different models expect parameters as:
6987 \end_layout
6989 \begin_layout Itemize
6990 string: String
6991 \end_layout
6993 \begin_layout Itemize
6994 numeric: numeric
6995 \end_layout
6997 \begin_layout Itemize
6998 enumeration: String
6999 \end_layout
7001 \begin_layout Itemize
7002 boolean: String
7003 \end_layout
7005 \begin_layout Itemize
7006 toggle: None.
7007 \end_layout
7009 \begin_layout Subsection
7010 memory.get_lag_flag: Get lag flag
7011 \end_layout
7013 \begin_layout Itemize
7014 Syntax: boolean memory.get_lag_flag()
7015 \end_layout
7017 \begin_layout Standard
7018 Get the value of core lag flag.
7019  True if this frame has been lag so far, false if poll has been detected.
7020 \end_layout
7022 \begin_layout Subsection
7023 memory.set_lag_flag: Set lag flag
7024 \end_layout
7026 \begin_layout Itemize
7027 Syntax: none memory.set_lag_flag(boolean flag)
7028 \end_layout
7030 \begin_layout Standard
7031 Set the value of core lag flag.
7032  This flag automatically gets cleared if poll is detected, but can be forcibly
7033  set or cleared if game so requires.
7034 \end_layout
7036 \begin_layout Itemize
7037 Should only be used in on_frame_emulated callback.
7038 \end_layout
7040 \begin_layout Itemize
7041 Setting or clearing this affects the emulator lag counter.
7042 \end_layout
7044 \begin_layout Subsection
7045 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7046  callback
7047 \end_layout
7049 \begin_layout Itemize
7050 Syntax: function memory.registerread([string marea, ] number addr, function
7051  fn);
7052 \end_layout
7054 \begin_layout Itemize
7055 Syntax: function memory.registerwrite([string marea, ] number addr, function
7056  fn);
7057 \end_layout
7059 \begin_layout Itemize
7060 Syntax: function memory.registerexec([string marea, ] number addr, function
7061  fn);
7062 \end_layout
7064 \begin_layout Itemize
7065 Syntax: none memory.unregisterread([string marea, ] number addr, function
7066  fn);
7067 \end_layout
7069 \begin_layout Itemize
7070 Syntax: none memory.unregisterwrite([string marea, ] number addr, function
7071  fn);
7072 \end_layout
7074 \begin_layout Itemize
7075 Syntax: none memory.unregisterexec([string marea, ] number addr, function
7076  fn);
7077 \end_layout
7079 \begin_layout Standard
7080 Add or remove callback on memory read, write or execute (depending on the
7081  function).
7082  If <marea> is specified, <addr> is relative to it, otherwise <addr> is
7083  global.
7084  <fn> is the callback.
7085  The register* functions return <fn> (which can then be passed to unregister*
7086  functions.
7087 \end_layout
7089 \begin_layout Itemize
7090 Not all cores support this, and it may be unsupported for some memory areas.
7091 \end_layout
7093 \begin_layout Itemize
7094 The functions are passed two parameters: Address and value.
7095 \end_layout
7097 \begin_layout Subsection
7098 memory.{,un}registertrace: Set/Clear trace hook
7099 \end_layout
7101 \begin_layout Itemize
7102 Syntax: function memory.registertrace(number processor, function fn);
7103 \end_layout
7105 \begin_layout Itemize
7106 Syntax: none memory.unregistertrace(number processor, function fn);
7107 \end_layout
7109 \begin_layout Standard
7110 Add or remove trace callback.
7111  <processor> is system-dependent processor number (0 is usually main CPU).
7112  The function arguments work like in other (un)register* functions.
7113 \end_layout
7115 \begin_layout Itemize
7116 The functions are passed two parameters: Trace CPU and Trace event string.
7117 \end_layout
7119 \begin_layout Subsection
7120 memory.cheat: Set cheat
7121 \end_layout
7123 \begin_layout Itemize
7124 Syntax: none memory.cheat([string marea, ] number addr, number value);
7125 \end_layout
7127 \begin_layout Itemize
7128 Syntax: none memory.cheat([string marea, ] number addr);
7129 \end_layout
7131 \begin_layout Standard
7132 Set or clear cheat (value <value>) on address <addr>.
7133  If <marea> is specified, <addr> is relative to that.
7134  If <value> is not speicified, clear a cheat.
7135 \end_layout
7137 \begin_layout Itemize
7138 Not all cores support this, and it may be unsupported for some memory areas.
7139 \end_layout
7141 \begin_layout Subsection
7142 memory.setxmask: Set global execute hook mask
7143 \end_layout
7145 \begin_layout Itemize
7146 Syntax: none memory.setxmask(number mask)
7147 \end_layout
7149 \begin_layout Standard
7150 Set the global execute hook mask to <mask>.
7151  The meaning of each bit is system-dependent, but bit 0 should be the main
7152  CPU.
7153 \end_layout
7155 \begin_layout Subsection
7156 memory.mmap: Class MMAP_STRUCT
7157 \end_layout
7159 \begin_layout Standard
7160 See class MMAP_STRUCT
7161 \end_layout
7163 \begin_layout Standard
7164 \begin_inset Newpage pagebreak
7165 \end_inset
7168 \end_layout
7170 \begin_layout Section
7171 Table memory2
7172 \end_layout
7174 \begin_layout Standard
7175 Contains newer memory functions.
7176 \end_layout
7178 \begin_layout Subsection
7179 memory2(): Get all memory area names.
7180 \end_layout
7182 \begin_layout Itemize
7183 Syntax: table memory2()
7184 \end_layout
7186 \begin_layout Standard
7187 Returns array of all valid memory area names.
7188 \end_layout
7190 \begin_layout Subsection
7191 memory2.<marea>:info: Get memory area info
7192 \end_layout
7194 \begin_layout Itemize
7195 Syntax: table memory2.<marea>:info()
7196 \end_layout
7198 \begin_layout Standard
7199 Return table describing given memory area.
7200  Includes fields address, size, last, readonly, special and endian.
7201 \end_layout
7203 \begin_layout Subsection
7204 memory2.<marea>:<op>: Read/Write memory
7205 \end_layout
7207 \begin_layout Itemize
7208 Syntax: none memory2.<marea>:<op>(number offset, number value)
7209 \end_layout
7211 \begin_layout Itemize
7212 Syntax: number memory2.<marea>:<op>(number offset)
7213 \end_layout
7215 \begin_layout Standard
7216 Read/Write value from/to given memory area <marea> at given offset <offset>
7217  (must be in-range).
7218  The value written is <value>.
7219  <Op> is of form: [i][s]<type>, where:
7220 \end_layout
7222 \begin_layout Itemize
7223 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
7224 \end_layout
7226 \begin_layout Itemize
7227 'i' signifies that the value is treated as opposite-to-normal endianess,
7228 \end_layout
7230 \begin_layout Itemize
7231 's' signifies that value is treated as signed (not available for floating-point).
7232 \end_layout
7234 \begin_layout Subsection
7235 memory2.<marea>:read: Scatter-gather value read
7236 \end_layout
7238 \begin_layout Itemize
7239 Syntax: number memory2.<marea>:read(number addr...)
7240 \end_layout
7242 \begin_layout Standard
7243 Read value from given memory area <marea> at byte offsets <addr>..., given
7244  in order of increasing significance.
7245  Value of true and false are special.
7246  True increments address by 1, and false decrements address by 1.
7247 \end_layout
7249 \begin_layout Subsection
7250 memory2.<marea>:sread: Signed scatter-gather value read
7251 \end_layout
7253 \begin_layout Itemize
7254 Syntax: number memory2.<marea>:sread(number addr...)
7255 \end_layout
7257 \begin_layout Standard
7258 Like memory2.<marea>:read, but reads signed values.
7259 \end_layout
7261 \begin_layout Subsection
7262 memory2.<marea>:write: Scatter-gather value write
7263 \end_layout
7265 \begin_layout Itemize
7266 Syntax: number memory2.<marea>:write(number val, number addr...)
7267 \end_layout
7269 \begin_layout Standard
7270 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
7271  in order of increasing significance.
7272  Value of true and false are special.
7273  True increments address by 1, and false decrements address by 1.
7274 \end_layout
7276 \begin_layout Subsection
7277 memory2.<marea>:cheat: Set/Clear cheat
7278 \end_layout
7280 \begin_layout Itemize
7281 Syntax: none memory2.<marea>:cheat(number addr, [number value])
7282 \end_layout
7284 \begin_layout Standard
7285 Set/Clear cheat at offset <addr> of memory area <marea>.
7286  If <value> is given, cheat with specified value is set.
7287  Otherwise cheat on address is removed.
7288 \end_layout
7290 \begin_layout Subsection
7291 memory2.<marea>:sha256: SHA-256
7292 \end_layout
7294 \begin_layout Itemize
7295 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
7296  number stride])
7297 \end_layout
7299 \begin_layout Standard
7300 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
7301  from offset <addr> of area <marea>.
7302  The chunks are separated by <stride>.
7303 \end_layout
7305 \begin_layout Subsection
7306 memory2.<marea>:skein: Skein-512-256
7307 \end_layout
7309 \begin_layout Itemize
7310 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
7311  number stride])
7312 \end_layout
7314 \begin_layout Standard
7315 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
7316 \end_layout
7318 \begin_layout Subsection
7319 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
7320 \end_layout
7322 \begin_layout Itemize
7323 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
7324  number rows, number stride])
7325 \end_layout
7327 \begin_layout Itemize
7328 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
7329  size[, number rows, number stride])
7330 \end_layout
7332 \begin_layout Standard
7333 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
7334  <addr> of area <marea>.
7335  The chunks are separated by <stride>.
7336  The target is Lua host memory, starting from offset <daddr>.
7337 \end_layout
7339 \begin_layout Standard
7340 Additionally, the storecmp method returns false if target was modified (otherwis
7341 e true).
7342 \end_layout
7344 \begin_layout Subsection
7345 memory2.<marea>:readregion: Read region
7346 \end_layout
7348 \begin_layout Itemize
7349 Syntax table memory2.<marea>:readregion(number addr, number size)
7350 \end_layout
7352 \begin_layout Standard
7353 Read <size> bytes starting from <addr> in <marea> and return as array.
7354 \end_layout
7356 \begin_layout Subsection
7357 memory2.<marea>:writeregion: Write region
7358 \end_layout
7360 \begin_layout Itemize
7361 Syntax none memory2.<marea>:writeregion(number addr, table data)
7362 \end_layout
7364 \begin_layout Standard
7365 Write array <data> to bytes starting from <addr> in <marea>.
7366 \end_layout
7368 \begin_layout Subsection
7369 memory2.<marea>:register{read,write,exec}: Register hook
7370 \end_layout
7372 \begin_layout Itemize
7373 Syntax: function memory2.<marea>:registerread(number addr, function fn);
7374 \end_layout
7376 \begin_layout Itemize
7377 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
7378 \end_layout
7380 \begin_layout Itemize
7381 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
7382 \end_layout
7384 \begin_layout Standard
7385 Register debug callback <fn> of specified type at offset <addr> of memory
7386  area <marea>.
7387  Returns <fn>.
7388 \end_layout
7390 \begin_layout Subsection
7391 memory2.<marea>:unregister{read,write,exec}: Unregister hook
7392 \end_layout
7394 \begin_layout Itemize
7395 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
7396 \end_layout
7398 \begin_layout Itemize
7399 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
7400 \end_layout
7402 \begin_layout Itemize
7403 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
7404 \end_layout
7406 \begin_layout Standard
7407 Unregister debug callback <fn> of specified type at offset <addr> of memory
7408  area <marea>.
7409 \end_layout
7411 \begin_layout Standard
7412 \begin_inset Newpage pagebreak
7413 \end_inset
7416 \end_layout
7418 \begin_layout Section
7419 Table random
7420 \end_layout
7422 \begin_layout Standard
7423 Contains random number generation methods.
7424  These functions do not return reproducable results.
7425 \end_layout
7427 \begin_layout Subsection
7428 random.boolean: Random boolean
7429 \end_layout
7431 \begin_layout Itemize
7432 Syntax: boolean random.boolean()
7433 \end_layout
7435 \begin_layout Standard
7436 Returns true or false at random (50-50 chance).
7437 \end_layout
7439 \begin_layout Subsection
7440 random.integer: Random integer
7441 \end_layout
7443 \begin_layout Itemize
7444 Syntax: number random.integer(number highplusone)
7445 \end_layout
7447 \begin_layout Itemize
7448 Syntax: number random.integer(number low, number high)
7449 \end_layout
7451 \begin_layout Standard
7452 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
7453  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
7454 \end_layout
7456 \begin_layout Standard
7457 The returned numbers are from uniform distribution.
7458 \end_layout
7460 \begin_layout Subsection
7461 random.float: Random float
7462 \end_layout
7464 \begin_layout Itemize
7465 Syntax: number random.float()
7466 \end_layout
7468 \begin_layout Standard
7469 Returns random decimal number [0,1).
7470 \end_layout
7472 \begin_layout Subsection
7473 random.among: Random parameter
7474 \end_layout
7476 \begin_layout Itemize
7477 Syntax: value random.among(value values...)
7478 \end_layout
7480 \begin_layout Standard
7481 Returns random parameter value, picked at uniform.
7482  Multiple equivalent values are returned with higher chance.
7483 \end_layout
7485 \begin_layout Subsection
7486 random.amongtable: Random from table
7487 \end_layout
7489 \begin_layout Itemize
7490 Syntax: value random.amongtable(table tab)
7491 \end_layout
7493 \begin_layout Standard
7494 Returns random value from table <tab>.
7495  As in random.among, no equality testing is done.
7496 \end_layout
7498 \begin_layout Standard
7499 \begin_inset Newpage pagebreak
7500 \end_inset
7503 \end_layout
7505 \begin_layout Section
7506 Table zip
7507 \end_layout
7509 \begin_layout Subsection
7510 zip.enumerate: Enumerate members in zipfile
7511 \end_layout
7513 \begin_layout Itemize
7514 Syntax: Table zip.enumerate(string filename[, boolean invert])
7515 \end_layout
7517 \begin_layout Standard
7518 Returns table of files in zip archive <filename>.
7519  If <invert> is true, instead of returning array of names, returns table
7520  with keys being member names and values being true.
7521 \end_layout
7523 \begin_layout Subsection
7524 zip.writer: Class ZIPWRITER
7525 \end_layout
7527 \begin_layout Standard
7528 See class ZIPWRITER.
7529 \end_layout
7531 \begin_layout Standard
7532 \begin_inset Newpage pagebreak
7533 \end_inset
7536 \end_layout
7538 \begin_layout Section
7539 Table callback
7540 \end_layout
7542 \begin_layout Standard
7543 Various callback-related functions.
7544 \end_layout
7546 \begin_layout Subsection
7547 \begin_inset CommandInset label
7548 LatexCommand label
7549 name "sub:callback.register:-Register-a"
7551 \end_inset
7553 callback.register: Register a callback
7554 \end_layout
7556 \begin_layout Itemize
7557 Syntax: function callback.register(string cbname, function cbfun);
7558 \end_layout
7560 \begin_layout Standard
7561 Instruct function <cbfun> to be added to list of callbacks to call on event
7562  <cbname> (See section 
7563 \begin_inset CommandInset ref
7564 LatexCommand ref
7565 reference "sec:Callbacks"
7567 \end_inset
7570  The callback name does not have the 'on_' prefix (e.g.
7572 \begin_inset Quotes eld
7573 \end_inset
7575 paint
7576 \begin_inset Quotes erd
7577 \end_inset
7580  Returns <cbfun>.
7581 \end_layout
7583 \begin_layout Subsection
7584 \begin_inset CommandInset label
7585 LatexCommand label
7586 name "sub:callback.unregister:-Unregister-"
7588 \end_inset
7590 callback.unregister: Unregister a callback
7591 \end_layout
7593 \begin_layout Itemize
7594 Syntax: function callback.unregister(string cbname, function cbfun);
7595 \end_layout
7597 \begin_layout Standard
7598 Instruct function <cbfun> to be removed from list of callbacks to call on
7599  event <cbname>.
7600 \end_layout
7602 \begin_layout Subsection
7603 callback.<cbname>:register: Register callback
7604 \end_layout
7606 \begin_layout Itemize
7607 Syntax: function callback.<cbname>:register(function cbfun)
7608 \end_layout
7610 \begin_layout Standard
7611 Synonym for callback.register (section 
7612 \begin_inset CommandInset ref
7613 LatexCommand ref
7614 reference "sub:callback.register:-Register-a"
7616 \end_inset
7618 ), albeit with callback name specified differently.
7619 \end_layout
7621 \begin_layout Subsection
7622 callback.<cbname>:unregister: Register callback
7623 \end_layout
7625 \begin_layout Itemize
7626 Syntax: function callback.<cbname>:unregister(function cbfun)
7627 \end_layout
7629 \begin_layout Standard
7630 Synonym for callback.unregister (section 
7631 \begin_inset CommandInset ref
7632 LatexCommand ref
7633 reference "sub:callback.unregister:-Unregister-"
7635 \end_inset
7637 ), albeit with callback name specified differently.
7638 \end_layout
7640 \begin_layout Section
7641 table bsnes
7642 \end_layout
7644 \begin_layout Standard
7645 Various bsnes-specific functions.
7646 \end_layout
7648 \begin_layout Subsection
7649 bsnes.dump_sprite: Dump a sprite
7650 \end_layout
7652 \begin_layout Itemize
7653 Syntax: BITMAP bsnes.dump_sprite([string marea, ] number addr, number width,
7654  number height[, number stride])
7655 \end_layout
7657 \begin_layout Standard
7658 Dumps given sprite (in native format) from memory.
7659  memory area is usually 
7660 \begin_inset Quotes eld
7661 \end_inset
7663 VRAM
7664 \begin_inset Quotes erd
7665 \end_inset
7668  <Width> and <height> are given in 8x8 blocks.
7669  <Stride> overrides row stride (default 512).
7670 \end_layout
7672 \begin_layout Subsection
7673 bsnes.dump_palette: Dump a palette
7674 \end_layout
7676 \begin_layout Itemize
7677 Syntax: PALETTE bsnes.dump_palette([string marea, ] number addr, bool full256,
7678  bool first_trans)
7679 \end_layout
7681 \begin_layout Standard
7682 Dumps a palette from memory.
7683  memory area is usually 
7684 \begin_inset Quotes eld
7685 \end_inset
7687 CGRAM
7688 \begin_inset Quotes erd
7689 \end_inset
7692  If <full256> is true, 256 colors are dumped (otherwise 16).
7693  If <first_trans> is true, first color is forced transparent.
7694 \end_layout
7696 \begin_layout Subsection
7697 bsnes.enablelayer: Set layer visibility
7698 \end_layout
7700 \begin_layout Itemize
7701 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
7702 \end_layout
7704 \begin_layout Standard
7705 Enable or disable specified layer at specified priority.
7706 \end_layout
7708 \begin_layout Subsection
7709 bsnes.redump_sprite: Redump a sprite
7710 \end_layout
7712 \begin_layout Itemize
7713 Syntax: none bsnes.redump_sprite(BITMAP bitmap, [string marea, ] number addr[,
7714  number stride])
7715 \end_layout
7717 \begin_layout Standard
7718 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
7719  The specified bitmap must have size multiple of 8x8.
7720 \end_layout
7722 \begin_layout Subsection
7723 bsnes.redump_palette: Redump a palette
7724 \end_layout
7726 \begin_layout Itemize
7727 Syntax: none bsnes.dump_palette(PALETTE pal, [string marea, ] number addr,
7728  bool first_trans)
7729 \end_layout
7731 \begin_layout Standard
7732 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
7733  The specified palette must have either 16 or 256 colors.
7734 \end_layout
7736 \begin_layout Section
7737 extensions to table string
7738 \end_layout
7740 \begin_layout Subsection
7741 string.charU: string.char, UTF-8 version.
7742 \end_layout
7744 \begin_layout Itemize
7745 Syntax: string string.charU(number n...)
7746 \end_layout
7748 \begin_layout Standard
7749 Like Lua string.char(), but works in terms of Unicode codepoints.
7750  The returned string is UTF-8.
7751 \end_layout
7753 \begin_layout Subsection
7754 string.byteU: string.byte, UTF-8 version.
7755 \end_layout
7757 \begin_layout Itemize
7758 Syntax: number...
7759  string.byteU(string str[, number i[, number j]])
7760 \end_layout
7762 \begin_layout Standard
7763 Like string.byte(), but works in terms of Unicode codepoints.
7764  The input string <str> is assumed UTF-8.
7765 \end_layout
7767 \begin_layout Subsection
7768 string.regex: Match string against regular expression
7769 \end_layout
7771 \begin_layout Itemize
7772 Syntax: boolean/string...
7773  string.regex(string regexp, string against)
7774 \end_layout
7776 \begin_layout Standard
7777 Match POSIX-extended regular expression <regexp> against string <against>.
7778  If no match, false is returned.
7779  Otherwise if string has no subcaptures, true is returned.
7780  Otherwise each subcapture is returned as a string (in order of starting
7781  position).
7782 \end_layout
7784 \begin_layout Subsection
7785 string.hex: Transform integer into hex string
7786 \end_layout
7788 \begin_layout Itemize
7789 Syntax: string string.hex(number n, [number digits])
7790 \end_layout
7792 \begin_layout Standard
7793 Returns hexadecimal string representation of <n>, optionally padded with
7794  zeroes to <digits> digits (default is not to pad).
7795 \end_layout
7797 \begin_layout Subsection
7798 string.lpad: Pad string with spaces from left
7799 \end_layout
7801 \begin_layout Itemize
7802 Syntax: string string.lpad(string x, number n)
7803 \end_layout
7805 \begin_layout Standard
7806 Pad string <x> to <n> bytes by inserting spaces at start and return the
7807  result.
7808 \end_layout
7810 \begin_layout Subsection
7811 string.rpad: Pad string with spaces from right
7812 \end_layout
7814 \begin_layout Itemize
7815 Syntax: string string.rpad(string x, number n)
7816 \end_layout
7818 \begin_layout Standard
7819 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
7820 \end_layout
7822 \begin_layout Section
7823 Table _SYSTEM
7824 \end_layout
7826 \begin_layout Standard
7827 Contains copy of global variables from time of Lua initialization.
7828  Non-writeable.
7829 \end_layout
7831 \begin_layout Standard
7832 \begin_inset Newpage pagebreak
7833 \end_inset
7836 \end_layout
7838 \begin_layout Section
7839 \begin_inset CommandInset label
7840 LatexCommand label
7841 name "sec:Callbacks"
7843 \end_inset
7845 Callbacks
7846 \end_layout
7848 \begin_layout Standard
7849 Various callbacks to Lua that can occur.
7850 \end_layout
7852 \begin_layout Subsection
7853 on_paint: Screen is being painted
7854 \end_layout
7856 \begin_layout Itemize
7857 Callback: on_paint(bool not_synth)
7858 \end_layout
7860 \begin_layout Standard
7861 Called when screen is being painted.
7862  Any gui.* calls requiring graphic context draw on the screen.
7863 \end_layout
7865 \begin_layout Itemize
7866 not_synth is true if this hook is being called in response to received frame,
7867  false otherwise.
7868 \end_layout
7870 \begin_layout Subsection
7871 on_video: Dumped video frame is being painted
7872 \end_layout
7874 \begin_layout Itemize
7875 Callback: on_video()
7876 \end_layout
7878 \begin_layout Standard
7879 Called when video dump frame is being painted.
7880  Any gui.* calls requiring graphic context draw on the video.
7881 \end_layout
7883 \begin_layout Subsection
7884 on_frame_emulated: Frame emulation complete
7885 \end_layout
7887 \begin_layout Itemize
7888 Callback: on_frame_emulated()
7889 \end_layout
7891 \begin_layout Standard
7892 Called when emulating frame has completed and on_paint()/on_video() calls
7893  are about to be issued.
7894 \end_layout
7896 \begin_layout Subsection
7897 on_frame: Frame emulation starting.
7898 \end_layout
7900 \begin_layout Itemize
7901 Callback: on_frame()
7902 \end_layout
7904 \begin_layout Standard
7905 Called on each starting whole frame.
7906 \end_layout
7908 \begin_layout Subsection
7909 on_rewind: Movie rewound to beginning
7910 \end_layout
7912 \begin_layout Itemize
7913 Callback: on_rewind()
7914 \end_layout
7916 \begin_layout Standard
7917 Called when rewind movie to beginning has completed.
7918 \end_layout
7920 \begin_layout Subsection
7921 on_pre_load: Load operation is about to start
7922 \end_layout
7924 \begin_layout Itemize
7925 Callback: on_pre_load(string name)
7926 \end_layout
7928 \begin_layout Standard
7929 Called just before savestate/movie load occurs (note: loads are always delayed,
7930  so this occurs even when load was initiated by lua).
7931 \end_layout
7933 \begin_layout Subsection
7934 on_err_Load: Load failed
7935 \end_layout
7937 \begin_layout Itemize
7938 Callback: on_err_load(string name)
7939 \end_layout
7941 \begin_layout Standard
7942 Called if loadstate goes wrong.
7943 \end_layout
7945 \begin_layout Subsection
7946 on_post_load: Load completed
7947 \end_layout
7949 \begin_layout Itemize
7950 Callback: on_post_load(string name, boolean was_savestate)
7951 \end_layout
7953 \begin_layout Standard
7954 Called on successful loadstate.
7955  was_savestate gives if this was a savestate or a movie.
7956 \end_layout
7958 \begin_layout Subsection
7959 on_pre_save: Save operation is about to start
7960 \end_layout
7962 \begin_layout Itemize
7963 Callback: on_pre_save(string name, boolean is_savestate)
7964 \end_layout
7966 \begin_layout Standard
7967 Called just before savestate save occurs (note: movie saves are synchronous
7968  and won't trigger these callbacks if called from Lua).
7969 \end_layout
7971 \begin_layout Subsection
7972 on_err_save: Save failed
7973 \end_layout
7975 \begin_layout Itemize
7976 Callback: on_err_save(string name)
7977 \end_layout
7979 \begin_layout Standard
7980 Called if savestate goes wrong.
7981 \end_layout
7983 \begin_layout Subsection
7984 on_post_save: Save completed
7985 \end_layout
7987 \begin_layout Itemize
7988 Callback: on_post_save(string name, boolean is_savestate)
7989 \end_layout
7991 \begin_layout Standard
7992 Called on successful savaestate.
7993  is_savestate gives if this was a savestate or a movie.
7994 \end_layout
7996 \begin_layout Subsection
7997 on_quit: Emulator is shutting down
7998 \end_layout
8000 \begin_layout Itemize
8001 Callback: on_quit()
8002 \end_layout
8004 \begin_layout Standard
8005 Called when emulator is shutting down.
8006 \end_layout
8008 \begin_layout Subsection
8009 on_input: Polling for input
8010 \end_layout
8012 \begin_layout Standard
8013 Called when emulator is just sending input to bsnes core.
8014  Warning: This is called even in readonly mode, but the results are ignored.
8015 \end_layout
8017 \begin_layout Subsection
8018 on_reset: System has been reset
8019 \end_layout
8021 \begin_layout Itemize
8022 Callback: on_reset()
8023 \end_layout
8025 \begin_layout Standard
8026 Called when system is reset.
8027 \end_layout
8029 \begin_layout Subsection
8030 on_readwrite: Entered readwrite mode
8031 \end_layout
8033 \begin_layout Itemize
8034 Callback: on_readwrite()
8035 \end_layout
8037 \begin_layout Standard
8038 Called when moving into readwrite mode as result of 
8039 \begin_inset Quotes eld
8040 \end_inset
8042 set-rwmode
8043 \begin_inset Quotes erd
8044 \end_inset
8046  command (note: moving to rwmode by Lua won't trigger this, as per recursive
8047  entry protection).
8048 \end_layout
8050 \begin_layout Subsection
8051 on_snoop/on_snoop2: Snoop core controller reads
8052 \end_layout
8054 \begin_layout Itemize
8055 Callback: on_snoop(number port, number controller, number index, number
8056  value)
8057 \end_layout
8059 \begin_layout Itemize
8060 Callback: on_snoop2(number port, number controller, number index, number
8061  value)
8062 \end_layout
8064 \begin_layout Standard
8065 Called each time bsnes asks for input.
8066  The value is the final value to be sent to bsnes core (readonly mode, autohold
8067  and autofire have been taken into account).
8068  Might be useful when translating movies to format suitable for console
8069  verification.
8070  Note: There is no way to modify the value to be sent.
8071 \end_layout
8073 \begin_layout Itemize
8074 On_snoop2 is called instead of on_snoop if defined.
8075  Reserves port 0 for system, having first user port be port 1.
8076 \end_layout
8078 \begin_layout Subsection
8079 on_keyhook: Hooked key/axis has been moved
8080 \end_layout
8082 \begin_layout Itemize
8083 Callback: on_keyhook(string keyname, table state)
8084 \end_layout
8086 \begin_layout Standard
8087 Sent when key that has keyhook events requested changes state.
8088  Keyname is name of the key (group) and state is the state (same kind as
8089  table values in input.raw).
8090 \end_layout
8092 \begin_layout Subsection
8093 on_idle: Idle event
8094 \end_layout
8096 \begin_layout Itemize
8097 Callback: on_idle()
8098 \end_layout
8100 \begin_layout Standard
8101 Called when requested by set_idle_timeout(), the timeout has expired and
8102  emulator is waiting.
8103 \end_layout
8105 \begin_layout Subsection
8106 on_timer: Timer event
8107 \end_layout
8109 \begin_layout Itemize
8110 Callback: on_timer()
8111 \end_layout
8113 \begin_layout Standard
8114 Called when requested by set_idle_timeout() and the timeout has expired
8115  (regardless if emulator is waiting).
8116 \end_layout
8118 \begin_layout Subsection
8119 on_set_rewind: Rewind point has been set
8120 \end_layout
8122 \begin_layout Itemize
8123 Callback: on_set_rewind(UNSAFEREWIND r)
8124 \end_layout
8126 \begin_layout Standard
8127 Called when unsafe rewind object has been constructed.
8128 \end_layout
8130 \begin_layout Subsection
8131 on_pre_rewind: Rewind is about to occur
8132 \end_layout
8134 \begin_layout Itemize
8135 Callback: on_pre_rewind() 
8136 \end_layout
8138 \begin_layout Standard
8139 Called just before unsafe rewind is about to occur.
8140 \end_layout
8142 \begin_layout Subsection
8143 on_post_rewind: Rewind has occured
8144 \end_layout
8146 \begin_layout Itemize
8147 Callback: on_post_rewind() 
8148 \end_layout
8150 \begin_layout Standard
8151 Called just after unsafe rewind has occured.
8152 \end_layout
8154 \begin_layout Subsection
8155 on_button: Button has been pressed
8156 \end_layout
8158 \begin_layout Itemize
8159 Callback: on_button(number port, number controller, number index, string
8160  type)
8161 \end_layout
8163 \begin_layout Standard
8164 Called on controller button press, with following parameters:
8165 \end_layout
8167 \begin_layout Itemize
8168 port: Port number (0 is system)
8169 \end_layout
8171 \begin_layout Itemize
8172 controller: Controller within port
8173 \end_layout
8175 \begin_layout Itemize
8176 index: Index of button.
8177 \end_layout
8179 \begin_layout Itemize
8180 type: Type of event, one of:
8181 \end_layout
8183 \begin_deeper
8184 \begin_layout Itemize
8185 \begin_inset Quotes eld
8186 \end_inset
8188 pressed
8189 \begin_inset Quotes erd
8190 \end_inset
8192 : Button was pressed.
8193 \end_layout
8195 \begin_layout Itemize
8196 \begin_inset Quotes eld
8197 \end_inset
8199 released
8200 \begin_inset Quotes erd
8201 \end_inset
8203 : Button was released.
8204 \end_layout
8206 \begin_layout Itemize
8207 \begin_inset Quotes eld
8208 \end_inset
8210 hold
8211 \begin_inset Quotes erd
8212 \end_inset
8214 : Held.
8215 \end_layout
8217 \begin_layout Itemize
8218 \begin_inset Quotes eld
8219 \end_inset
8221 unhold
8222 \begin_inset Quotes erd
8223 \end_inset
8225 : Released from hold.
8226 \end_layout
8228 \begin_layout Itemize
8229 \begin_inset Quotes eld
8230 \end_inset
8232 type
8233 \begin_inset Quotes erd
8234 \end_inset
8236 : Typing input on button.
8237 \end_layout
8239 \begin_layout Itemize
8240 \begin_inset Quotes eld
8241 \end_inset
8243 untype
8244 \begin_inset Quotes erd
8245 \end_inset
8247 : Typing input undone.
8248 \end_layout
8250 \begin_layout Itemize
8251 \begin_inset Quotes eld
8252 \end_inset
8254 autofire <duty> <cycle>
8255 \begin_inset Quotes erd
8256 \end_inset
8258 : Autofire with specifie duty and cycle.
8259 \end_layout
8261 \begin_layout Itemize
8262 \begin_inset Quotes eld
8263 \end_inset
8265 autofire
8266 \begin_inset Quotes erd
8267 \end_inset
8269 : Stop autofire.
8270 \end_layout
8272 \begin_layout Itemize
8273 \begin_inset Quotes eld
8274 \end_inset
8276 analog
8277 \begin_inset Quotes erd
8278 \end_inset
8280 : Analog action on axis.
8281 \end_layout
8283 \end_deeper
8284 \begin_layout Subsection
8285 on_movie_lost: Movie data is about to be lost
8286 \end_layout
8288 \begin_layout Itemize
8289 Callback: on_movie_lost(STRING kind)
8290 \end_layout
8292 \begin_layout Standard
8293 Called just before something would happen that could lose movie data.
8294  Kind can be:
8295 \end_layout
8297 \begin_layout Itemize
8298 readwrite: Switching to readwrite mode.
8299 \end_layout
8301 \begin_layout Itemize
8302 reload: ROM is being reloaded in readwrite mode.
8303 \end_layout
8305 \begin_layout Itemize
8306 load: New movie is being loaded.
8307 \end_layout
8309 \begin_layout Itemize
8310 unsaferewind: Unsafe rewind is happening.
8311 \end_layout
8313 \begin_layout Subsection
8314 on_latch: Latch line is rising
8315 \end_layout
8317 \begin_layout Itemize
8318 Callback: on_latch(<core-dependent-parameters>)
8319 \end_layout
8321 \begin_layout Standard
8322 Called when latch line for controller is rising.
8323  Some cores may not support this.
8324 \end_layout
8326 \begin_layout Section
8327 System-dependent behaviour
8328 \end_layout
8330 \begin_layout Subsection
8331 bsnes core
8332 \end_layout
8334 \begin_layout Itemize
8335 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
8336  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
8337  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
8338 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
8339 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
8340  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
8341  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
8342  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
8343  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
8344 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
8345 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
8346  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
8347 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
8348 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
8349  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
8350 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
8351  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
8352 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
8353 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
8354 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
8355  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
8356 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
8357  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
8358  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
8359 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
8360 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
8361 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
8362  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
8363 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
8364  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
8365  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
8366  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
8367  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
8368 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
8369  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
8370 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
8371  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
8372  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
8373 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
8374  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
8375 \end_layout
8377 \begin_layout Itemize
8378 on_latch has no parameters
8379 \end_layout
8381 \begin_layout Itemize
8382 CPU 0 is S-CPU, 1 is S-SMP.
8383 \end_layout
8385 \begin_layout Itemize
8386 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
8387 \end_layout
8389 \begin_layout Itemize
8390 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
8391 {RAM,ROM}.
8392 \end_layout
8394 \begin_layout Itemize
8395 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
8396  DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
8397  BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
8398  GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
8399 \end_layout
8401 \begin_layout Subsection
8402 gambatte core
8403 \end_layout
8405 \begin_layout Itemize
8406 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
8407  d, e, f, h, l
8408 \end_layout
8410 \begin_layout Itemize
8411 on_latch is not supported
8412 \end_layout
8414 \begin_layout Itemize
8415 CPU 0 is main CPU.
8416 \end_layout
8418 \begin_layout Itemize
8419 Cheats are supported for ROM, SRAM and WRAM.
8420 \end_layout
8422 \begin_layout Itemize
8423 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
8424  and WRAM.
8425 \end_layout
8427 \begin_layout Itemize
8428 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
8429 \end_layout
8431 \end_body
8432 \end_document