Fix typo in changelog
[lsnes.git] / lua.lyx
blobf29a5a107ffb0f9b4052776b1898f61ebdd91b61
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 Standard
1043 \begin_inset Newpage pagebreak
1044 \end_inset
1047 \end_layout
1049 \begin_layout Subsection
1050 RENDERCTX: Off-screen rendering context
1051 \end_layout
1053 \begin_layout Standard
1054 Object acting as off-screen rendering context.
1055 \end_layout
1057 \begin_layout Subsubsection
1058 Static function new: Create a render queue
1059 \end_layout
1061 \begin_layout Itemize
1062 Syntax: renderctx gui.renderctx.new(width, height);
1063 \end_layout
1065 \begin_layout Itemize
1066 Syntax: renderctx classes.RENDERCTX.new(width, height);
1067 \end_layout
1069 \begin_layout Itemize
1070 Deprecated: renderctx gui.renderq_new(width, height);
1071 \end_layout
1073 \begin_layout Standard
1074 Parameters:
1075 \end_layout
1077 \begin_layout Itemize
1078 width: number: The notional width of the game area.
1079 \end_layout
1081 \begin_layout Itemize
1082 height: number: The notional height of the game area.
1083 \end_layout
1085 \begin_layout Standard
1086 Returns:
1087 \end_layout
1089 \begin_layout Itemize
1090 rendectx: RENDERCTX: The newly created render context.
1091 \end_layout
1093 \begin_layout Standard
1094 Create a render context with reported size <width>*<height> and return it.
1095 \end_layout
1097 \begin_layout Subsubsection
1098 Static function setnull: Reset to default queue
1099 \end_layout
1101 \begin_layout Itemize
1102 Syntax: gui.renderctx.setnull()
1103 \end_layout
1105 \begin_layout Itemize
1106 Syntax: classes.RENDERCTX:setnull()
1107 \end_layout
1109 \begin_layout Itemize
1110 Deprecated: gui.renderq_set()
1111 \end_layout
1113 \begin_layout Standard
1114 Reset the used render context back to default for the executing callback:
1115 \end_layout
1117 \begin_layout Itemize
1118 The default for paint callback is the screen
1119 \end_layout
1121 \begin_layout Itemize
1122 The default for video callback is the video frame
1123 \end_layout
1125 \begin_layout Itemize
1126 The default otherwise is nothing.
1127 \end_layout
1129 \begin_layout Subsubsection
1130 Method clear: Clear a render queue
1131 \end_layout
1133 \begin_layout Itemize
1134 Syntax: renderctx:clear()
1135 \end_layout
1137 \begin_layout Itemize
1138 Deprecated: gui.renderq_clear(renderctx)
1139 \end_layout
1141 \begin_layout Standard
1142 Parameters:
1143 \end_layout
1145 \begin_layout Itemize
1146 renderctx: RENDERCTX: The render queue to clear.
1147 \end_layout
1149 \begin_layout Standard
1150 Clear all drawing from the context.
1151 \end_layout
1153 \begin_layout Subsubsection
1154 Method set: Change active render context
1155 \end_layout
1157 \begin_layout Itemize
1158 Syntax: renderctx:set()
1159 \end_layout
1161 \begin_layout Itemize
1162 Deprecated: gui.renderq_set(renderctx)
1163 \end_layout
1165 \begin_layout Standard
1166 Parameters:
1167 \end_layout
1169 \begin_layout Itemize
1170 renderctx: RENDERCTX: The render queue to use.
1171 \end_layout
1173 \begin_layout Standard
1174 Switch the current rendering context <renderctx>.
1175 \end_layout
1177 \begin_layout Subsubsection
1178 Method run: Draw all objects in context to another
1179 \end_layout
1181 \begin_layout Itemize
1182 Syntax: renderctx:run()
1183 \end_layout
1185 \begin_layout Itemize
1186 Deprecated: gui.renderq_run(renderctx)
1187 \end_layout
1189 \begin_layout Standard
1190 Parameters:
1191 \end_layout
1193 \begin_layout Itemize
1194 renderctx: RENDERCTX: The render context to overlay.
1195 \end_layout
1197 \begin_layout Standard
1198 Overlay the specified render context <context> upon the active rendering
1199  context.
1200 \end_layout
1202 \begin_layout Itemize
1203 Trying to overlay rendering context upon itself is a bad idea.
1204 \end_layout
1206 \begin_layout Subsubsection
1207 Method render: Render a contex to bitmap
1208 \end_layout
1210 \begin_layout Itemize
1211 Syntax: bitmap renderctx:render()
1212 \end_layout
1214 \begin_layout Standard
1215 Parameters:
1216 \end_layout
1218 \begin_layout Itemize
1219 renderctx: RENDERCTX: The context to render.
1220 \end_layout
1222 \begin_layout Standard
1223 Returns:
1224 \end_layout
1226 \begin_layout Itemize
1227 bitmap: DBITMAP: The rendered bitmap.
1228 \end_layout
1230 \begin_layout Standard
1231 Render the specified context <renderctx> to a new bitmap.
1232 \end_layout
1234 \begin_layout Itemize
1235 The size of bitmap will be nominal game area size, plus any set gaps.
1236 \end_layout
1238 \begin_layout Itemize
1239 This method does not require active rendering context.
1240 \end_layout
1242 \begin_layout Subsubsection
1243 Method synchronous_repaint: Paint screen now
1244 \end_layout
1246 \begin_layout Itemize
1247 Syntax: renderctx:synchronous_repaint()
1248 \end_layout
1250 \begin_layout Itemize
1251 Deprecated: gui.synchronous_repaint(renderctx)
1252 \end_layout
1254 \begin_layout Standard
1255 Parameters:
1256 \end_layout
1258 \begin_layout Itemize
1259 renderctx: RENDERCTX: The context to paint.
1260 \end_layout
1262 \begin_layout Standard
1263 Immediately redraw the screen with game overlayed by drawings from context
1264  <renderctx>.
1265 \end_layout
1267 \begin_layout Itemize
1268 This does not require active rendering context.
1269 \end_layout
1271 \begin_layout Itemize
1272 Will not cause paint callback to be invoked.
1273 \end_layout
1275 \begin_layout Standard
1276 \begin_inset Newpage pagebreak
1277 \end_inset
1280 \end_layout
1282 \begin_layout Subsection
1283 PALETTE: Color palette for indexed image
1284 \end_layout
1286 \begin_layout Subsubsection
1287 Static function new: Create a new palette
1288 \end_layout
1290 \begin_layout Itemize
1291 Syntax: palette gui.palette.new()
1292 \end_layout
1294 \begin_layout Itemize
1295 Syntax: palette classes.PALETTE.new()
1296 \end_layout
1298 \begin_layout Itemize
1299 Deprecated: palette gui.palette_new()
1300 \end_layout
1302 \begin_layout Standard
1303 Returns:
1304 \end_layout
1306 \begin_layout Itemize
1307 palette: PALETTE: The created palette.
1308 \end_layout
1310 \begin_layout Standard
1311 Create a new palette (with all colors transparent) and return it.
1312 \end_layout
1314 \begin_layout Subsubsection
1315 Static function load: Load a palette
1316 \end_layout
1318 \begin_layout Itemize
1319 Syntax: palette gui.palette.load(file, [base])
1320 \end_layout
1322 \begin_layout Itemize
1323 Syntax: palette classes.PALETTE.load(file, [base])
1324 \end_layout
1326 \begin_layout Itemize
1327 Deprecated: palette gui.palette_load(file, [base])
1328 \end_layout
1330 \begin_layout Standard
1331 Parameters:
1332 \end_layout
1334 \begin_layout Itemize
1335 string file: The file to load.
1336 \end_layout
1338 \begin_layout Itemize
1339 string base (optional): The base file to resolve file relative to.
1340 \end_layout
1342 \begin_layout Standard
1343 Returns:
1344 \end_layout
1346 \begin_layout Itemize
1347 palette: PALETTE: The loaded palette.
1348 \end_layout
1350 \begin_layout Standard
1351 Load a palette from file <file> (resolved relative to <base>).
1352 \end_layout
1354 \begin_layout Itemize
1355 The file format is a series of lines, each with following format:
1356 \end_layout
1358 \begin_deeper
1359 \begin_layout Itemize
1360 Blank or just whitespace: Ignored
1361 \end_layout
1363 \begin_layout Itemize
1364 First non-whitespace is '#': Ignored
1365 \end_layout
1367 \begin_layout Itemize
1368 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1369 \end_layout
1371 \begin_layout Itemize
1372 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1373  (0-256, 0 being fully transparent and 256 fully opaque).
1374 \end_layout
1376 \begin_layout Itemize
1377 transparent: Fully transparent color
1378 \end_layout
1380 \end_deeper
1381 \begin_layout Subsubsection
1382 Static function load_str: Load a palette from string
1383 \end_layout
1385 \begin_layout Itemize
1386 Syntax: palette gui.palette.load(data)
1387 \end_layout
1389 \begin_layout Itemize
1390 Syntax: palette classes.PALETTE.load(data)
1391 \end_layout
1393 \begin_layout Itemize
1394 Deprecated: palette gui.palette_load(data)
1395 \end_layout
1397 \begin_layout Standard
1398 Parameters:
1399 \end_layout
1401 \begin_layout Itemize
1402 string data: The palette data.
1403 \end_layout
1405 \begin_layout Standard
1406 Returns:
1407 \end_layout
1409 \begin_layout Itemize
1410 palette: PALETTE: The loaded palette.
1411 \end_layout
1413 \begin_layout Standard
1414 Like PALETTE:load, but instead of reading palette from file, reads it from
1415  a string.
1416 \end_layout
1418 \begin_layout Subsubsection
1419 Method set: Set palette entry
1420 \end_layout
1422 \begin_layout Itemize
1423 Syntax: palette:set(index, color)
1424 \end_layout
1426 \begin_layout Itemize
1427 Deprecated: gui.palette_set(palette, ...)
1428 \end_layout
1430 \begin_layout Standard
1431 Parameters:
1432 \end_layout
1434 \begin_layout Itemize
1435 palette: PALETTE: The palette to manipulate
1436 \end_layout
1438 \begin_layout Itemize
1439 index: number: The index of color to set (0-65535).
1440 \end_layout
1442 \begin_layout Itemize
1443 color: number/string: The color value to set.
1444 \end_layout
1446 \begin_layout Standard
1447 Set palette <palette> index <index> to color <color>.
1448 \end_layout
1450 \begin_layout Subsubsection
1451 Method hash: Hash a palette
1452 \end_layout
1454 \begin_layout Itemize
1455 Syntax: hash palette:hash()
1456 \end_layout
1458 \begin_layout Itemize
1459 Deprecated: hash gui.palette_hash(palette)
1460 \end_layout
1462 \begin_layout Standard
1463 Parameters:
1464 \end_layout
1466 \begin_layout Itemize
1467 palette: The palette to hash.
1468 \end_layout
1470 \begin_layout Standard
1471 Return value:
1472 \end_layout
1474 \begin_layout Itemize
1475 hash: string: 64-hex digit hash.
1476 \end_layout
1478 \begin_layout Standard
1479 Obtain crypto-grade hash of palette data of <palette>.
1480 \end_layout
1482 \begin_layout Itemize
1483 All colors after the last non-transparent one are ignored.
1484 \end_layout
1486 \begin_layout Subsubsection
1487 Method adjust_transparency: Adjust transparency
1488 \end_layout
1490 \begin_layout Itemize
1491 Syntax: palette:adjust_transparency(newvalue)
1492 \end_layout
1494 \begin_layout Itemize
1495 Deprecated: gui.adjust_transparency(palette, ...)
1496 \end_layout
1498 \begin_layout Standard
1499 Parameters:
1500 \end_layout
1502 \begin_layout Itemize
1503 palette: PALETTE: The palette to adjust.
1504 \end_layout
1506 \begin_layout Itemize
1507 Number adj: The factor to multiply opaqueness with times 256.
1508 \end_layout
1510 \begin_layout Standard
1511 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1512 \end_layout
1514 \begin_layout Standard
1515 \begin_inset Newpage pagebreak
1516 \end_inset
1519 \end_layout
1521 \begin_layout Subsection
1522 BITMAP: Indexed-color bitmap
1523 \end_layout
1525 \begin_layout Subsubsection
1526 Static function new: Create a new bitmap
1527 \end_layout
1529 \begin_layout Itemize
1530 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1531 \end_layout
1533 \begin_layout Itemize
1534 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1535 \end_layout
1537 \begin_layout Itemize
1538 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1539 \end_layout
1541 \begin_layout Standard
1542 Parameters:
1543 \end_layout
1545 \begin_layout Itemize
1546 w: number: The width of bitmap to create in pixels.
1547 \end_layout
1549 \begin_layout Itemize
1550 h: number: The height of bitmap to create in pixels.
1551 \end_layout
1553 \begin_layout Itemize
1554 false: boolean: Constant boolean false.
1555 \end_layout
1557 \begin_layout Itemize
1558 fillcolor: number: The initial fill index.
1559  Default 0 if not specified.
1560 \end_layout
1562 \begin_layout Standard
1563 Create a new bitmap of size <w>*<h>.
1564  Fill the bitmap with color index <fillcolor>.
1565 \end_layout
1567 \begin_layout Subsubsection
1568 Method draw: Draw a bitmap
1569 \end_layout
1571 \begin_layout Itemize
1572 Syntax: bitmap:draw(x, y, palette)
1573 \end_layout
1575 \begin_layout Itemize
1576 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1577 \end_layout
1579 \begin_layout Standard
1580 Parameters:
1581 \end_layout
1583 \begin_layout Itemize
1584 bitmap: BITMAP: The bitmap to draw
1585 \end_layout
1587 \begin_layout Itemize
1588 x: number: The x-coordinate on screen.
1589 \end_layout
1591 \begin_layout Itemize
1592 y: number: The y-coordinate on screen.
1593 \end_layout
1595 \begin_layout Itemize
1596 palette: The palette to use for drawing.
1597 \end_layout
1599 \begin_layout Standard
1600 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1601 \end_layout
1603 \begin_layout Subsubsection
1604 Method pset: Set pixel in bitmap
1605 \end_layout
1607 \begin_layout Itemize
1608 Syntax: bitmap:pset(x, y, color)
1609 \end_layout
1611 \begin_layout Itemize
1612 Deprecaed: gui.bitmap_pset(bitmap, ...)
1613 \end_layout
1615 \begin_layout Standard
1616 Parameters:
1617 \end_layout
1619 \begin_layout Itemize
1620 bitmap: BITMAP: The bitmap to manipulate.
1621 \end_layout
1623 \begin_layout Itemize
1624 x: number: x-coordinate of pixel to set.
1625 \end_layout
1627 \begin_layout Itemize
1628 y: number: y-coordinate of pixel to set.
1629 \end_layout
1631 \begin_layout Itemize
1632 color: number: The color index to set.
1633 \end_layout
1635 \begin_layout Standard
1636 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1637 \end_layout
1639 \begin_layout Subsubsection
1640 Method pget: Get pixel in bitmap
1641 \end_layout
1643 \begin_layout Itemize
1644 Syntax: color bitmap:pget(x,y)
1645 \end_layout
1647 \begin_layout Itemize
1648 Deprecated: color gui.bitmap_pget(bitmap, ...)
1649 \end_layout
1651 \begin_layout Standard
1652 Parameters:
1653 \end_layout
1655 \begin_layout Itemize
1656 bitmap: BITMAP: The bitmap to query.
1657 \end_layout
1659 \begin_layout Itemize
1660 x: number: x-coordinate of pixel to get.
1661 \end_layout
1663 \begin_layout Itemize
1664 y: number: y-coordinate of pixel to get.
1665 \end_layout
1667 \begin_layout Standard
1668 Returns:
1669 \end_layout
1671 \begin_layout Itemize
1672 color: number: The color index in specified pixel.
1673 \end_layout
1675 \begin_layout Standard
1676 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1677 \end_layout
1679 \begin_layout Subsubsection
1680 Method size: Get size of bitmap
1681 \end_layout
1683 \begin_layout Itemize
1684 Syntax: width, height bitmap:size()
1685 \end_layout
1687 \begin_layout Itemize
1688 Syntax: width, height gui.bitmap_size(bitmap)
1689 \end_layout
1691 \begin_layout Standard
1692 Parameters:
1693 \end_layout
1695 \begin_layout Itemize
1696 bitmap: BITMAP: The bitmap to query.
1697 \end_layout
1699 \begin_layout Standard
1700 Returns:
1701 \end_layout
1703 \begin_layout Itemize
1704 width: number: The width of the bitmap.
1705 \end_layout
1707 \begin_layout Itemize
1708 height: number: The height of the bitmap.
1709 \end_layout
1711 \begin_layout Standard
1712 Get size of bitmap <bitmap>.
1713 \end_layout
1715 \begin_layout Subsubsection
1716 Method blit: Blit a bitmap into another
1717 \end_layout
1719 \begin_layout Itemize
1720 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1721 \end_layout
1723 \begin_layout Itemize
1724 Deprecated: gui.bitmap_blit(dest, ...)
1725 \end_layout
1727 \begin_layout Standard
1728 Parameters:
1729 \end_layout
1731 \begin_layout Itemize
1732 dest: BITMAP: The target bitmap to blit to.
1733 \end_layout
1735 \begin_layout Itemize
1736 dx: number: The x-coordinate in target.
1737 \end_layout
1739 \begin_layout Itemize
1740 dy: number: The y-coordinate in target.
1741 \end_layout
1743 \begin_layout Itemize
1744 src: BITMAP: The source bitmap.
1745 \end_layout
1747 \begin_layout Itemize
1748 sx: number: The x-coordinate in source.
1749 \end_layout
1751 \begin_layout Itemize
1752 sy: number: The y-coordinate in source.
1753 \end_layout
1755 \begin_layout Itemize
1756 w: number: The width of area to blit.
1757 \end_layout
1759 \begin_layout Itemize
1760 h: number: The height of area to blit.
1761 \end_layout
1763 \begin_layout Itemize
1764 ck: number: The color key.
1765  Pixels with this index are not copied.
1766 \end_layout
1768 \begin_deeper
1769 \begin_layout Itemize
1770 If none is specified, all pixels are copied.
1771 \end_layout
1773 \end_deeper
1774 \begin_layout Standard
1775 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1776  <dx>,<dy>.
1777  If a color key <ck> is specified, pixels of that color are not copied.
1778 \end_layout
1780 \begin_layout Subsubsection
1781 Method blit_scaled: Blit a bitmap into another with scaling
1782 \end_layout
1784 \begin_layout Itemize
1785 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1786 \end_layout
1788 \begin_layout Itemize
1789 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1790 \end_layout
1792 \begin_layout Standard
1793 Parameters:
1794 \end_layout
1796 \begin_layout Itemize
1797 dest: BITMAP: The target bitmap to blit to.
1798 \end_layout
1800 \begin_layout Itemize
1801 dx: number: The x-coordinate in target.
1802 \end_layout
1804 \begin_layout Itemize
1805 dy: number: The y-coordinate in target.
1806 \end_layout
1808 \begin_layout Itemize
1809 src: BITMAP: The source bitmap.
1810 \end_layout
1812 \begin_layout Itemize
1813 sx: number: The x-coordinate in source.
1814 \end_layout
1816 \begin_layout Itemize
1817 sy: number: The y-coordinate in source.
1818 \end_layout
1820 \begin_layout Itemize
1821 w: number: The width of area to blit.
1822 \end_layout
1824 \begin_layout Itemize
1825 h: number: The height of area to blit.
1826 \end_layout
1828 \begin_layout Itemize
1829 hscl: number: Horizontal scale factor (integer).
1830 \end_layout
1832 \begin_layout Itemize
1833 vscl: number: Vertical scale factor (integer).
1834  Defaults to the same as <hscl>.
1835 \end_layout
1837 \begin_layout Itemize
1838 ck: number: The color key.
1839  Pixels with this index are not copied.
1840 \end_layout
1842 \begin_deeper
1843 \begin_layout Itemize
1844 If none is specified, all pixels are copied.
1845 \end_layout
1847 \end_deeper
1848 \begin_layout Standard
1849 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1850  neighbor) by factor of <hscl>*<vscl>.
1851 \end_layout
1853 \begin_layout Subsubsection
1854 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1855 \end_layout
1857 \begin_layout Itemize
1858 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1859 \end_layout
1861 \begin_layout Itemize
1862 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1863 \end_layout
1865 \begin_layout Standard
1866 Parameters:
1867 \end_layout
1869 \begin_layout Itemize
1870 dest: BITMAP: The target bitmap to blit to.
1871 \end_layout
1873 \begin_layout Itemize
1874 dx: number: The x-coordinate in target.
1875 \end_layout
1877 \begin_layout Itemize
1878 dy: number: The y-coordinate in target.
1879 \end_layout
1881 \begin_layout Itemize
1882 src: BITMAP: The source bitmap.
1883 \end_layout
1885 \begin_layout Itemize
1886 sx: number: The x-coordinate in source.
1887 \end_layout
1889 \begin_layout Itemize
1890 sy: number: The y-coordinate in source.
1891 \end_layout
1893 \begin_layout Itemize
1894 w: number: The width of area to blit.
1895 \end_layout
1897 \begin_layout Itemize
1898 h: number: The height of area to blit.
1899 \end_layout
1901 \begin_layout Itemize
1902 operator: string: The operator to use.
1903 \end_layout
1905 \begin_deeper
1906 \begin_layout Itemize
1907 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
1908  DestOut, Clear or Xor.
1909 \end_layout
1911 \end_deeper
1912 \begin_layout Standard
1913 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
1914  operator.
1916 \end_layout
1918 \begin_layout Itemize
1919 Color index 0 in source and target is treated as background.
1920 \end_layout
1922 \begin_layout Subsubsection
1923 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
1924  Porter-Duff composition
1925 \end_layout
1927 \begin_layout Itemize
1928 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
1929  operator)
1930 \end_layout
1932 \begin_layout Itemize
1933 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
1934 \end_layout
1936 \begin_layout Standard
1937 Parameters:
1938 \end_layout
1940 \begin_layout Itemize
1941 dest: BITMAP: The target bitmap to blit to.
1942 \end_layout
1944 \begin_layout Itemize
1945 dx: number: The x-coordinate in target.
1946 \end_layout
1948 \begin_layout Itemize
1949 dy: number: The y-coordinate in target.
1950 \end_layout
1952 \begin_layout Itemize
1953 src: BITMAP: The source bitmap.
1954 \end_layout
1956 \begin_layout Itemize
1957 sx: number: The x-coordinate in source.
1958 \end_layout
1960 \begin_layout Itemize
1961 sy: number: The y-coordinate in source.
1962 \end_layout
1964 \begin_layout Itemize
1965 w: number: The width of area to blit.
1966 \end_layout
1968 \begin_layout Itemize
1969 h: number: The height of area to blit.
1970 \end_layout
1972 \begin_layout Itemize
1973 hscl: number: Horizontal scale factor (integer).
1974 \end_layout
1976 \begin_layout Itemize
1977 vscl: number: Vertical scale factor (integer).
1978  Defaults to the same as <hscl>.
1979 \end_layout
1981 \begin_layout Itemize
1982 operator: string: The operator to use.
1983 \end_layout
1985 \begin_deeper
1986 \begin_layout Itemize
1987 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
1988  DestOut, Clear or Xor.
1989 \end_layout
1991 \end_deeper
1992 \begin_layout Standard
1993 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
1994  like BITMAP:blit_scaled.
1995 \end_layout
1997 \begin_layout Subsubsection
1998 Method blit_priority: Blit a bitmap into another with color priority
1999 \end_layout
2001 \begin_layout Itemize
2002 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2003 \end_layout
2005 \begin_layout Itemize
2006 Deprecated: gui.bitmap_blit_priority(dest, ...)
2007 \end_layout
2009 \begin_layout Standard
2010 Parameters:
2011 \end_layout
2013 \begin_layout Itemize
2014 dest: BITMAP: The target bitmap to blit to.
2015 \end_layout
2017 \begin_layout Itemize
2018 dx: number: The x-coordinate in target.
2019 \end_layout
2021 \begin_layout Itemize
2022 dy: number: The y-coordinate in target.
2023 \end_layout
2025 \begin_layout Itemize
2026 src: BITMAP: The source bitmap.
2027 \end_layout
2029 \begin_layout Itemize
2030 sx: number: The x-coordinate in source.
2031 \end_layout
2033 \begin_layout Itemize
2034 sy: number: The y-coordinate in source.
2035 \end_layout
2037 \begin_layout Itemize
2038 w: number: The width of area to blit.
2039 \end_layout
2041 \begin_layout Itemize
2042 h: number: The height of area to blit.
2043 \end_layout
2045 \begin_layout Standard
2046 Like BITMAP:blit, but only copy pixels where source color index is greater
2047  than destination color index.
2048 \end_layout
2050 \begin_layout Subsubsection
2051 Method blit_scaled_priority: Blit a bitmap into another with color priority
2052  and scaling
2053 \end_layout
2055 \begin_layout Itemize
2056 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2057 \end_layout
2059 \begin_layout Itemize
2060 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2061 \end_layout
2063 \begin_layout Standard
2064 Parameters:
2065 \end_layout
2067 \begin_layout Itemize
2068 dest: BITMAP: The target bitmap to blit to.
2069 \end_layout
2071 \begin_layout Itemize
2072 dx: number: The x-coordinate in target.
2073 \end_layout
2075 \begin_layout Itemize
2076 dy: number: The y-coordinate in target.
2077 \end_layout
2079 \begin_layout Itemize
2080 src: BITMAP: The source bitmap.
2081 \end_layout
2083 \begin_layout Itemize
2084 sx: number: The x-coordinate in source.
2085 \end_layout
2087 \begin_layout Itemize
2088 sy: number: The y-coordinate in source.
2089 \end_layout
2091 \begin_layout Itemize
2092 w: number: The width of area to blit.
2093 \end_layout
2095 \begin_layout Itemize
2096 h: number: The height of area to blit.
2097 \end_layout
2099 \begin_layout Itemize
2100 hscl: number: Horizontal scale factor (integer).
2101 \end_layout
2103 \begin_layout Itemize
2104 vscl: number: Vertical scale factor (integer).
2105  Defaults to the same as <hscl>.
2106 \end_layout
2108 \begin_layout Standard
2109 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2110 caled.
2111 \end_layout
2113 \begin_layout Subsubsection
2114 Method save_png: Save a bitmap to PNG
2115 \end_layout
2117 \begin_layout Itemize
2118 Syntax: bitmap:save_png(filename, [base], palette)
2119 \end_layout
2121 \begin_layout Itemize
2122 Syntax: data bitmap:save_png(palette)
2123 \end_layout
2125 \begin_layout Itemize
2126 Deprecated: ...
2127  gui.bitmap_save_png(bitmap, ...)
2128 \end_layout
2130 \begin_layout Standard
2131 Parameters:
2132 \end_layout
2134 \begin_layout Itemize
2135 bitmap: BITMAP: The bitmap to save.
2136 \end_layout
2138 \begin_layout Itemize
2139 filename: string: The filename to save to.
2140 \end_layout
2142 \begin_layout Itemize
2143 base: string: The base filename is resolved relative to.
2144 \end_layout
2146 \begin_layout Itemize
2147 palette: PALETTE: The palette to use.
2148 \end_layout
2150 \begin_layout Standard
2151 Return value:
2152 \end_layout
2154 \begin_layout Itemize
2155 data: string: BASE64 encoded PNG data.
2156 \end_layout
2158 \begin_layout Standard
2159 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2160  to <base>) or return BASE64 encoding of it.
2161 \end_layout
2163 \begin_layout Subsubsection
2164 Method hash: Hash a bitmap
2165 \end_layout
2167 \begin_layout Itemize
2168 Syntax: hash bitmap:hash()
2169 \end_layout
2171 \begin_layout Itemize
2172 Deprecated: hash bitmap:hash(bitmap)
2173 \end_layout
2175 \begin_layout Standard
2176 Parameters:
2177 \end_layout
2179 \begin_layout Itemize
2180 bitmap: BITMAP: The bitmap to hash.
2181 \end_layout
2183 \begin_layout Standard
2184 Return value:
2185 \end_layout
2187 \begin_layout Itemize
2188 hash: string: 64-hex digit hash
2189 \end_layout
2191 \begin_layout Standard
2192 Hashes bitmap <bitmap> and returns crypto-strong hash.
2194 \end_layout
2196 \begin_layout Itemize
2197 Color order in bitmap is significant.
2198 \end_layout
2200 \begin_layout Standard
2201 \begin_inset Newpage pagebreak
2202 \end_inset
2205 \end_layout
2207 \begin_layout Subsection
2208 DBITMAP: Direct-color bitmap
2209 \end_layout
2211 \begin_layout Subsubsection
2212 Static function: new: Create a new bitmap
2213 \end_layout
2215 \begin_layout Itemize
2216 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2217 \end_layout
2219 \begin_layout Itemize
2220 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2221 \end_layout
2223 \begin_layout Itemize
2224 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2225 \end_layout
2227 \begin_layout Standard
2228 Parameters:
2229 \end_layout
2231 \begin_layout Itemize
2232 w: number: The width of new bitmap.
2233 \end_layout
2235 \begin_layout Itemize
2236 h: number: The height of new bitmap.
2237 \end_layout
2239 \begin_layout Itemize
2240 true: boolean: Fixed boolean true
2241 \end_layout
2243 \begin_layout Itemize
2244 fillcolor: The color to fill the bitmap with (default transparent).
2245 \end_layout
2247 \begin_layout Standard
2248 Return value:
2249 \end_layout
2251 \begin_layout Itemize
2252 bitmap: DBITMAP: The new bitmap.
2253 \end_layout
2255 \begin_layout Standard
2256 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2257  <fillcolor>.
2258 \end_layout
2260 \begin_layout Subsubsection
2261 Method draw: Draw a bitmap
2262 \end_layout
2264 \begin_layout Itemize
2265 Syntax: bitmap.draw(x, y)
2266 \end_layout
2268 \begin_layout Itemize
2269 Deprecated: gui.bitmap_draw(x, y, bitmap)
2270 \end_layout
2272 \begin_layout Standard
2273 Parameters:
2274 \end_layout
2276 \begin_layout Itemize
2277 bitmap: DBITMAP: The bitmap to draw.
2278 \end_layout
2280 \begin_layout Itemize
2281 x: number: X-coordinate on screen.
2282 \end_layout
2284 \begin_layout Itemize
2285 y: number: Y-coordinate on screen.
2286 \end_layout
2288 \begin_layout Standard
2289 Draw bitmap <bitmap> on screen at <x>,<y>.
2290 \end_layout
2292 \begin_layout Subsubsection
2293 Method pset: Set pixel in bitmap
2294 \end_layout
2296 \begin_layout Itemize
2297 Syntax: bitmap:pset(x, y, color)
2298 \end_layout
2300 \begin_layout Itemize
2301 Deprecaed: gui.bitmap_pset(bitmap, ...)
2302 \end_layout
2304 \begin_layout Standard
2305 Parameters:
2306 \end_layout
2308 \begin_layout Itemize
2309 bitmap: DBITMAP: The bitmap to manipulate.
2310 \end_layout
2312 \begin_layout Itemize
2313 x: number: x-coordinate of pixel to set.
2314 \end_layout
2316 \begin_layout Itemize
2317 y: number: y-coordinate of pixel to set.
2318 \end_layout
2320 \begin_layout Itemize
2321 color: number/string: The color to set.
2322 \end_layout
2324 \begin_layout Standard
2325 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2326 \end_layout
2328 \begin_layout Subsubsection
2329 Method pget: Get pixel in bitmap
2330 \end_layout
2332 \begin_layout Itemize
2333 Syntax: color bitmap:pget(x,y)
2334 \end_layout
2336 \begin_layout Itemize
2337 Deprecated: color gui.bitmap_pget(bitmap, ...)
2338 \end_layout
2340 \begin_layout Standard
2341 Parameters:
2342 \end_layout
2344 \begin_layout Itemize
2345 bitmap: DBITMAP: The bitmap to query.
2346 \end_layout
2348 \begin_layout Itemize
2349 x: number: x-coordinate of pixel to get.
2350 \end_layout
2352 \begin_layout Itemize
2353 y: number: y-coordinate of pixel to get.
2354 \end_layout
2356 \begin_layout Standard
2357 Returns:
2358 \end_layout
2360 \begin_layout Itemize
2361 color: number: The color of specified pixel.
2362 \end_layout
2364 \begin_layout Standard
2365 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2366 \end_layout
2368 \begin_layout Subsubsection
2369 Method size: Get size of bitmap
2370 \end_layout
2372 \begin_layout Itemize
2373 Syntax: width, height bitmap:size()
2374 \end_layout
2376 \begin_layout Itemize
2377 Syntax: width, height gui.bitmap_size(bitmap)
2378 \end_layout
2380 \begin_layout Standard
2381 Parameters:
2382 \end_layout
2384 \begin_layout Itemize
2385 bitmap: DBITMAP: The bitmap to query.
2386 \end_layout
2388 \begin_layout Standard
2389 Returns:
2390 \end_layout
2392 \begin_layout Itemize
2393 width: number: The width of the bitmap.
2394 \end_layout
2396 \begin_layout Itemize
2397 height: number: The height of the bitmap.
2398 \end_layout
2400 \begin_layout Standard
2401 Get size of bitmap <bitmap>.
2402 \end_layout
2404 \begin_layout Subsubsection
2405 Method blit: Blit a bitmap into another
2406 \end_layout
2408 \begin_layout Itemize
2409 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2410 \end_layout
2412 \begin_layout Itemize
2413 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2414 \end_layout
2416 \begin_layout Itemize
2417 Deprecated: gui.bitmap_blit(dest, ...)
2418 \end_layout
2420 \begin_layout Standard
2421 Parameters:
2422 \end_layout
2424 \begin_layout Itemize
2425 dest: DBITMAP: The target bitmap to blit to.
2426 \end_layout
2428 \begin_layout Itemize
2429 dx: number: The x-coordinate in target.
2430 \end_layout
2432 \begin_layout Itemize
2433 dy: number: The y-coordinate in target.
2434 \end_layout
2436 \begin_layout Itemize
2437 src: BITMAP/DBITMAP: The source bitmap.
2438 \end_layout
2440 \begin_layout Itemize
2441 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2442 \end_layout
2444 \begin_layout Itemize
2445 sx: number: The x-coordinate in source.
2446 \end_layout
2448 \begin_layout Itemize
2449 sy: number: The y-coordinate in source.
2450 \end_layout
2452 \begin_layout Itemize
2453 w: number: The width of area to blit.
2454 \end_layout
2456 \begin_layout Itemize
2457 h: number: The height of area to blit.
2458 \end_layout
2460 \begin_layout Itemize
2461 ck: number: The color key.
2462  Pixels with this index are not copied.
2463 \end_layout
2465 \begin_deeper
2466 \begin_layout Itemize
2467 If none is specified, all pixels are copied.
2468 \end_layout
2470 \begin_layout Itemize
2471 If <src> is paletted, this is color index, otherwise it is a color.
2472 \end_layout
2474 \end_deeper
2475 \begin_layout Standard
2476 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2477  if indexed) into <dest> at <dx>,<dy>.
2478  If a color key <ck> is specified, pixels of that color are not copied.
2479 \end_layout
2481 \begin_layout Subsubsection
2482 Method blit_scaled: Blit a bitmap into another with scaling
2483 \end_layout
2485 \begin_layout Itemize
2486 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2487 \end_layout
2489 \begin_layout Itemize
2490 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2491  [ck])
2492 \end_layout
2494 \begin_layout Itemize
2495 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2496 \end_layout
2498 \begin_layout Standard
2499 Parameters:
2500 \end_layout
2502 \begin_layout Itemize
2503 dest: DBITMAP: The target bitmap to blit to.
2504 \end_layout
2506 \begin_layout Itemize
2507 dx: number: The x-coordinate in target.
2508 \end_layout
2510 \begin_layout Itemize
2511 dy: number: The y-coordinate in target.
2512 \end_layout
2514 \begin_layout Itemize
2515 src: BITMAP/DBITMAP: The source bitmap.
2516 \end_layout
2518 \begin_layout Itemize
2519 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2520 \end_layout
2522 \begin_layout Itemize
2523 sx: number: The x-coordinate in source.
2524 \end_layout
2526 \begin_layout Itemize
2527 sy: number: The y-coordinate in source.
2528 \end_layout
2530 \begin_layout Itemize
2531 w: number: The width of area to blit.
2532 \end_layout
2534 \begin_layout Itemize
2535 h: number: The height of area to blit.
2536 \end_layout
2538 \begin_layout Itemize
2539 hscl: number: Horizontal scale factor (integer).
2540 \end_layout
2542 \begin_layout Itemize
2543 vscl: number: Vertical scale factor (integer).
2544  Defaults to the same as <hscl>.
2545 \end_layout
2547 \begin_layout Itemize
2548 ck: number: The color key.
2549  Pixels with this index are not copied.
2550 \end_layout
2552 \begin_deeper
2553 \begin_layout Itemize
2554 If none is specified, all pixels are copied.
2555 \end_layout
2557 \begin_layout Itemize
2558 If <src> is paletted, this is color index, otherwise it is a color.
2559 \end_layout
2561 \end_deeper
2562 \begin_layout Standard
2563 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2564  neighbor) by factor of <hscl>*<vscl>.
2565 \end_layout
2567 \begin_layout Subsubsection
2568 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2569 \end_layout
2571 \begin_layout Itemize
2572 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2573 \end_layout
2575 \begin_layout Itemize
2576 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2577 \end_layout
2579 \begin_layout Itemize
2580 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2581 \end_layout
2583 \begin_layout Standard
2584 Parameters:
2585 \end_layout
2587 \begin_layout Itemize
2588 dest: DBITMAP: The target bitmap to blit to.
2589 \end_layout
2591 \begin_layout Itemize
2592 dx: number: The x-coordinate in target.
2593 \end_layout
2595 \begin_layout Itemize
2596 dy: number: The y-coordinate in target.
2597 \end_layout
2599 \begin_layout Itemize
2600 src: BITMAP/DBITMAP: The source bitmap.
2601 \end_layout
2603 \begin_layout Itemize
2604 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2605 \end_layout
2607 \begin_layout Itemize
2608 sx: number: The x-coordinate in source.
2609 \end_layout
2611 \begin_layout Itemize
2612 sy: number: The y-coordinate in source.
2613 \end_layout
2615 \begin_layout Itemize
2616 w: number: The width of area to blit.
2617 \end_layout
2619 \begin_layout Itemize
2620 h: number: The height of area to blit.
2621 \end_layout
2623 \begin_layout Itemize
2624 operator: string: The operator to use.
2625 \end_layout
2627 \begin_deeper
2628 \begin_layout Itemize
2629 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2630  DestOut, Clear or Xor.
2631 \end_layout
2633 \end_deeper
2634 \begin_layout Standard
2635 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2636 f operator.
2638 \end_layout
2640 \begin_layout Itemize
2641 In target, fully transparent is background.
2642  In source, either fully transparent (if direct) or index 0 (if paletted)
2643  is treated as background.
2644 \end_layout
2646 \begin_layout Subsubsection
2647 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2648  Porter-Duff composition
2649 \end_layout
2651 \begin_layout Itemize
2652 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2653  operator)
2654 \end_layout
2656 \begin_layout Itemize
2657 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2658  [vscl], operator)
2659 \end_layout
2661 \begin_layout Itemize
2662 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2663 \end_layout
2665 \begin_layout Standard
2666 Parameters:
2667 \end_layout
2669 \begin_layout Itemize
2670 dest: DBITMAP: The target bitmap to blit to.
2671 \end_layout
2673 \begin_layout Itemize
2674 dx: number: The x-coordinate in target.
2675 \end_layout
2677 \begin_layout Itemize
2678 dy: number: The y-coordinate in target.
2679 \end_layout
2681 \begin_layout Itemize
2682 src: BITMAP/DBITMAP: The source bitmap.
2683 \end_layout
2685 \begin_layout Itemize
2686 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2687 \end_layout
2689 \begin_layout Itemize
2690 sx: number: The x-coordinate in source.
2691 \end_layout
2693 \begin_layout Itemize
2694 sy: number: The y-coordinate in source.
2695 \end_layout
2697 \begin_layout Itemize
2698 w: number: The width of area to blit.
2699 \end_layout
2701 \begin_layout Itemize
2702 h: number: The height of area to blit.
2703 \end_layout
2705 \begin_layout Itemize
2706 hscl: number: Horizontal scale factor (integer).
2707 \end_layout
2709 \begin_layout Itemize
2710 vscl: number: Vertical scale factor (integer).
2711  Defaults to the same as <hscl>.
2712 \end_layout
2714 \begin_layout Itemize
2715 operator: string: The operator to use.
2716 \end_layout
2718 \begin_deeper
2719 \begin_layout Itemize
2720 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2721  DestOut, Clear or Xor.
2722 \end_layout
2724 \end_deeper
2725 \begin_layout Standard
2726 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2727  like DBITMAP:blit_scaled.
2728 \end_layout
2730 \begin_layout Subsubsection
2731 Method adjust_transparency: Adjust transparency of bitmap
2732 \end_layout
2734 \begin_layout Itemize
2735 Syntax: bitmap:adjust_transparency(newvalue)
2736 \end_layout
2738 \begin_layout Itemize
2739 Deprecated: gui.adjust_transparency(bitmap, ...)
2740 \end_layout
2742 \begin_layout Standard
2743 Parameters:
2744 \end_layout
2746 \begin_layout Itemize
2747 bitmap: DBITMAP: The bitmap to adjust.
2748 \end_layout
2750 \begin_layout Itemize
2751 Number adj: The factor to multiply opaqueness with times 256.
2752 \end_layout
2754 \begin_layout Standard
2755 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2756 \end_layout
2758 \begin_layout Subsubsection
2759 Method save_png: Save a bitmap to PNG
2760 \end_layout
2762 \begin_layout Itemize
2763 Syntax: bitmap:save_png(filename, [base])
2764 \end_layout
2766 \begin_layout Itemize
2767 Syntax: data bitmap:save_png()
2768 \end_layout
2770 \begin_layout Itemize
2771 Deprecated: ...
2772  gui.bitmap_save_png(bitmap, ...)
2773 \end_layout
2775 \begin_layout Standard
2776 Parameters:
2777 \end_layout
2779 \begin_layout Itemize
2780 bitmap: DBITMAP: The bitmap to save.
2781 \end_layout
2783 \begin_layout Itemize
2784 filename: string: The filename to save to.
2785 \end_layout
2787 \begin_layout Itemize
2788 base: string: The base filename is resolved relative to.
2789 \end_layout
2791 \begin_layout Standard
2792 Return value:
2793 \end_layout
2795 \begin_layout Itemize
2796 data: string: BASE64 encoded PNG data.
2797 \end_layout
2799 \begin_layout Standard
2800 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2801  BASE64 encoding of it.
2802 \end_layout
2804 \begin_layout Subsubsection
2805 Method hash: Hash a bitmap
2806 \end_layout
2808 \begin_layout Itemize
2809 Syntax: hash bitmap:hash()
2810 \end_layout
2812 \begin_layout Itemize
2813 Deprecated: hash bitmap:hash(bitmap)
2814 \end_layout
2816 \begin_layout Standard
2817 Parameters:
2818 \end_layout
2820 \begin_layout Itemize
2821 bitmap: DBITMAP: The bitmap to hash.
2822 \end_layout
2824 \begin_layout Standard
2825 Return value:
2826 \end_layout
2828 \begin_layout Itemize
2829 hash: string: 64-hex digit hash
2830 \end_layout
2832 \begin_layout Standard
2833 Hashes bitmap <bitmap> and returns crypto-strong hash.
2835 \end_layout
2837 \begin_layout Subsection
2838 IMAGELOADER: Load an image
2839 \end_layout
2841 \begin_layout Subsubsection
2842 Static function load: Load a bitmap from file
2843 \end_layout
2845 \begin_layout Itemize
2846 Syntax: bitmap, palette gui.image.load(file, [base])
2847 \end_layout
2849 \begin_layout Itemize
2850 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
2851 \end_layout
2853 \begin_layout Itemize
2854 Deprecated: ...
2855  gui.bitmap_load(...)
2856 \end_layout
2858 \begin_layout Standard
2859 Parameters:
2860 \end_layout
2862 \begin_layout Itemize
2863 file: string: The file to read.
2864 \end_layout
2866 \begin_layout Itemize
2867 base: string: The base to resolve <file> relative to.
2868 \end_layout
2870 \begin_layout Standard
2871 Returns:
2872 \end_layout
2874 \begin_layout Itemize
2875 bitmap: BITMAP/DBITMAP: The new bitmap
2876 \end_layout
2878 \begin_layout Itemize
2879 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
2880  nil.
2881 \end_layout
2883 \begin_layout Standard
2884 Load a new bitmap and return it (plus associated palette if any).
2885 \end_layout
2887 \begin_layout Subsubsection
2888 Static function load_str: Load a bitmap from string
2889 \end_layout
2891 \begin_layout Itemize
2892 Syntax: bitmap, palette gui.image.load_str(data)
2893 \end_layout
2895 \begin_layout Itemize
2896 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
2897 \end_layout
2899 \begin_layout Itemize
2900 Deprecated: ...
2901  gui.bitmap_load_str(...)
2902 \end_layout
2904 \begin_layout Standard
2905 Parameters:
2906 \end_layout
2908 \begin_layout Itemize
2909 data: string: The image data
2910 \end_layout
2912 \begin_layout Standard
2913 Returns:
2914 \end_layout
2916 \begin_layout Itemize
2917 bitmap: BITMAP/DBITMAP: The new bitmap
2918 \end_layout
2920 \begin_layout Itemize
2921 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
2922  nil.
2923 \end_layout
2925 \begin_layout Standard
2926 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
2927  file.
2928 \end_layout
2930 \begin_layout Subsubsection
2931 Static function load_png: Load a bitmap from PNG file
2932 \end_layout
2934 \begin_layout Itemize
2935 Syntax: bitmap, palette gui.image.load_png(file, [base])
2936 \end_layout
2938 \begin_layout Itemize
2939 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
2940 \end_layout
2942 \begin_layout Itemize
2943 Deprecated: ...
2944  gui.bitmap_load_png(...)
2945 \end_layout
2947 \begin_layout Standard
2948 Parameters:
2949 \end_layout
2951 \begin_layout Itemize
2952 file: string: The file to read.
2953 \end_layout
2955 \begin_layout Itemize
2956 base: string: The base to resolve <file> relative to.
2957 \end_layout
2959 \begin_layout Standard
2960 Returns:
2961 \end_layout
2963 \begin_layout Itemize
2964 bitmap: BITMAP/DBITMAP: The new bitmap
2965 \end_layout
2967 \begin_layout Itemize
2968 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
2969  nil.
2970 \end_layout
2972 \begin_layout Standard
2973 Like IMAGELOADER:load, but load a PNG file instead.
2974 \end_layout
2976 \begin_layout Subsubsection
2977 Static function load_png_str: Load a PNG bitmap from string
2978 \end_layout
2980 \begin_layout Itemize
2981 Syntax: bitmap, palette gui.image.load_png_str(data)
2982 \end_layout
2984 \begin_layout Itemize
2985 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
2986 \end_layout
2988 \begin_layout Itemize
2989 Deprecated: ...
2990  gui.bitmap_load_png_str(...)
2991 \end_layout
2993 \begin_layout Standard
2994 Parameters:
2995 \end_layout
2997 \begin_layout Itemize
2998 data: string: The image data, base64 encoded.
2999 \end_layout
3001 \begin_layout Standard
3002 Returns:
3003 \end_layout
3005 \begin_layout Itemize
3006 bitmap: BITMAP/DBITMAP: The new bitmap
3007 \end_layout
3009 \begin_layout Itemize
3010 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3011  nil.
3012 \end_layout
3014 \begin_layout Standard
3015 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3016  <data> instead of file.
3017 \end_layout
3019 \begin_layout Standard
3020 \begin_inset Newpage pagebreak
3021 \end_inset
3024 \end_layout
3026 \begin_layout Subsection
3027 CUSTOMFONT: Arbitrary-sized bitmap font
3028 \end_layout
3030 \begin_layout Subsubsection
3031 Static function new: Return a new empty font
3032 \end_layout
3034 \begin_layout Itemize
3035 Syntax: font gui.font.new()
3036 \end_layout
3038 \begin_layout Itemize
3039 Syntax: font classes.CUSTOMFONT.new()
3040 \end_layout
3042 \begin_layout Itemize
3043 Deprecated: font gui.font_new()
3044 \end_layout
3046 \begin_layout Standard
3047 Return value:
3048 \end_layout
3050 \begin_layout Itemize
3051 font: CUSTOMFONT: New font.
3052 \end_layout
3054 \begin_layout Standard
3055 Create a new font with no characters and return it.
3056 \end_layout
3058 \begin_layout Subsubsection
3059 Static function: load: Load a font file
3060 \end_layout
3062 \begin_layout Itemize
3063 Syntax: font gui.font.load(file, [base])
3064 \end_layout
3066 \begin_layout Itemize
3067 Syntax: font gui.font.load()
3068 \end_layout
3070 \begin_layout Itemize
3071 Syntax: font classes.CUSTOMFONT.load(file, [base])
3072 \end_layout
3074 \begin_layout Itemize
3075 Syntax: font classes.CUSTOMFONT.load()
3076 \end_layout
3078 \begin_layout Itemize
3079 Deprecated: font gui.loadfont(...)
3080 \end_layout
3082 \begin_layout Standard
3083 Parameters:
3084 \end_layout
3086 \begin_layout Itemize
3087 file: string: The file to read the font from
3088 \end_layout
3090 \begin_layout Itemize
3091 base: string: The file to resolve <file> relative to.
3092 \end_layout
3094 \begin_layout Standard
3095 Return value:
3096 \end_layout
3098 \begin_layout Itemize
3099 font: CUSTOMFONT: New font.
3100 \end_layout
3102 \begin_layout Standard
3103 Load font from file <file> (relative to <base>).
3104  If no filename is given, system default font is loaded.
3105 \end_layout
3107 \begin_layout Subsubsection
3108 operator(): Render text to screen
3109 \end_layout
3111 \begin_layout Itemize
3112 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3113 \end_layout
3115 \begin_layout Standard
3116 Parmeters:
3117 \end_layout
3119 \begin_layout Itemize
3120 font: CUSTOMFONT: The font to use.
3121 \end_layout
3123 \begin_layout Itemize
3124 x: number: The x-position on screen to draw to.
3125 \end_layout
3127 \begin_layout Itemize
3128 y: number: The y-position on screen to draw to.
3129 \end_layout
3131 \begin_layout Itemize
3132 text: string: The text to draw.
3133 \end_layout
3135 \begin_layout Itemize
3136 fgc: number/string: Foreground color (default white).
3137 \end_layout
3139 \begin_layout Itemize
3140 bgc: number/string: Background color (default transparent).
3141 \end_layout
3143 \begin_layout Itemize
3144 hlc: number/string: Outline color (default transparent).
3145 \end_layout
3147 \begin_layout Standard
3148 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3149  onto screen.
3150 \end_layout
3152 \begin_layout Itemize
3153 If <hlc> is transparent, no outline is drawn.
3154 \end_layout
3156 \begin_layout Subsubsection
3157 Method edit: Alter glyph in font
3158 \end_layout
3160 \begin_layout Itemize
3161 Syntax: font:edit(character, glyph)
3162 \end_layout
3164 \begin_layout Standard
3165 Parameters:
3166 \end_layout
3168 \begin_layout Itemize
3169 font: CUSTOMFONT: The font to edit.
3170 \end_layout
3172 \begin_layout Itemize
3173 character: string: The character to edit (UTF-8 encoded).
3174 \end_layout
3176 \begin_layout Itemize
3177 glyph: BITMAP: The bitmap to use.
3178 \end_layout
3180 \begin_layout Standard
3181 Replace character <character> in font <font> by <glyph>.
3182 \end_layout
3184 \begin_layout Itemize
3185 Color index 0 is background, everything else is foreground.
3186 \end_layout
3188 \begin_layout Itemize
3189 <character> may be empty string, meaning the replacement character used
3190  for bad characters.
3191 \end_layout
3193 \begin_layout Itemize
3194 <character> may be multi-codepoint string, meaning character used for that
3195  ligature.
3196 \end_layout
3198 \begin_layout Standard
3199 \begin_inset Newpage pagebreak
3200 \end_inset
3203 \end_layout
3205 \begin_layout Subsection
3206 ICONV: Character set conversions
3207 \end_layout
3209 \begin_layout Subsubsection
3210 Static function new: Create new character set converter
3211 \end_layout
3213 \begin_layout Itemize
3214 Syntax: iconv iconv.new(from, to);
3215 \end_layout
3217 \begin_layout Itemize
3218 Syntax: iconv classes.ICONV.new(from, to);
3219 \end_layout
3221 \begin_layout Itemize
3222 Deprecated: iconv iconv_new(...);
3223 \end_layout
3225 \begin_layout Standard
3226 Parameters:
3227 \end_layout
3229 \begin_layout Itemize
3230 from: string: The source character set.
3231 \end_layout
3233 \begin_layout Itemize
3234 to: string: The target character set.
3235 \end_layout
3237 \begin_layout Standard
3238 Returns:
3239 \end_layout
3241 \begin_layout Itemize
3242 iconv: ICONV: The converter.
3243 \end_layout
3245 \begin_layout Standard
3246 Create a character set converter, converting from <from> to <to> and return
3247  it.
3248 \end_layout
3250 \begin_layout Subsubsection
3251 Operator(): Convert string fragment from character set to another
3252 \end_layout
3254 \begin_layout Itemize
3255 Syntax: success, result, unconverted, error iconv(input)
3256 \end_layout
3258 \begin_layout Standard
3259 Parameters:
3260 \end_layout
3262 \begin_layout Itemize
3263 iconv: ICONV: The context to use.
3264 \end_layout
3266 \begin_layout Itemize
3267 input: string: The input to convert.
3268 \end_layout
3270 \begin_layout Standard
3271 Return value:
3272 \end_layout
3274 \begin_layout Itemize
3275 success: boolean: True if conversion was successful, false if not.
3276 \end_layout
3278 \begin_layout Itemize
3279 result: string: The string (partially) converted.
3280 \end_layout
3282 \begin_layout Itemize
3283 unconvered: number: Number of bytes that were not converted (only if <success>
3284  is false).
3285 \end_layout
3287 \begin_layout Itemize
3288 error: string: Error that caused conversion to stop (only if <success> is
3289  false).
3290 \end_layout
3292 \begin_deeper
3293 \begin_layout Itemize
3294 INVALID: The input string is invalid.
3295 \end_layout
3297 \begin_layout Itemize
3298 INCOMPLETE: The input string cuts off in middle of character.
3299 \end_layout
3301 \begin_layout Itemize
3302 INTERNALERR: Internal error.
3303 \end_layout
3305 \end_deeper
3306 \begin_layout Standard
3307 Convert a string <input> using character set converter <iconv> and return
3308  the result.
3309 \end_layout
3311 \begin_layout Standard
3312 \begin_inset Newpage pagebreak
3313 \end_inset
3316 \end_layout
3318 \begin_layout Subsection
3319 FILEREADER: Read a file as a stream
3320 \end_layout
3322 \begin_layout Subsubsection
3323 Static function open: Open a stream
3324 \end_layout
3326 \begin_layout Itemize
3327 Syntax: handle filereader.open(file, [base])
3328 \end_layout
3330 \begin_layout Itemize
3331 Syntax: handle classes.FILEREADER.open(file, [base])
3332 \end_layout
3334 \begin_layout Itemize
3335 Deprecated: handle open_file(file, [base])
3336 \end_layout
3338 \begin_layout Standard
3339 Parameters:
3340 \end_layout
3342 \begin_layout Itemize
3343 file: string: The filename to read.
3344 \end_layout
3346 \begin_layout Itemize
3347 base: string: The base <file> is resolved against.
3348 \end_layout
3350 \begin_layout Standard
3351 Returns:
3352 \end_layout
3354 \begin_layout Itemize
3355 handle: FILEREADER: The new file reader.
3356 \end_layout
3358 \begin_layout Standard
3359 Open file <file> (relative to <base>) and return a handle to it.
3360 \end_layout
3362 \begin_layout Subsubsection
3363 operator(): Read line/bytes from stream
3364 \end_layout
3366 \begin_layout Itemize
3367 Syntax: result handle()
3368 \end_layout
3370 \begin_layout Itemize
3371 Syntax: result handle(bytes)
3372 \end_layout
3374 \begin_layout Standard
3375 Parameters:
3376 \end_layout
3378 \begin_layout Itemize
3379 handle: FILEREADER: The handle to read from.
3380 \end_layout
3382 \begin_layout Itemize
3383 bytes: Number of bytes to read (default is next line).
3384 \end_layout
3386 \begin_layout Standard
3387 Returns:
3388 \end_layout
3390 \begin_layout Itemize
3391 result: string: The read data, or nil on end-of-file.
3392 \end_layout
3394 \begin_layout Standard
3395 Reads next line or <bytes> bytes from specified file handle <handle>.
3396 \end_layout
3398 \begin_layout Itemize
3399 If reading specified number of bytes, the bytes are read in binary mode
3400  (as-is).
3401 \end_layout
3403 \begin_layout Itemize
3404 If reading next line, the line is read in text mode (any line ending is
3405  skpped).
3406 \end_layout
3408 \begin_layout Subsubsection
3409 Method lines: Iterator to read all lines
3410 \end_layout
3412 \begin_layout Itemize
3413 Syntax: for line in handle:lines() do ...
3414  end
3415 \end_layout
3417 \begin_layout Standard
3418 Parameters:
3419 \end_layout
3421 \begin_layout Itemize
3422 handle: FILEREADER: The handle to read.
3423 \end_layout
3425 \begin_layout Standard
3426 Returns:
3427 \end_layout
3429 \begin_layout Itemize
3430 A lua iterator with one variable.
3431 \end_layout
3433 \begin_layout Standard
3434 Return a Lua iterator that iterates all the lines in <handle>.
3435 \end_layout
3437 \begin_layout Standard
3438 \begin_inset Newpage pagebreak
3439 \end_inset
3442 \end_layout
3444 \begin_layout Subsection
3445 COMPARE_OBJ: Watch memory area for changes
3446 \end_layout
3448 \begin_layout Standard
3449 Objects of this class allow fast checking for modifications to given memory
3450  block.
3451 \end_layout
3453 \begin_layout Subsubsection
3454 Static function new: Create a checker
3455 \end_layout
3457 \begin_layout Itemize
3458 Syntax: handle classes.COMPARE_OBJ.new([marea], offset, size, [rows, stride])
3459 \end_layout
3461 \begin_layout Itemize
3462 Syntax: handle memory.compare_new([marea], offset, size, rows, stride)
3463 \end_layout
3465 \begin_layout Standard
3466 Parameters:
3467 \end_layout
3469 \begin_layout Itemize
3470 marea: string: The memory area to interpret <offset> against.
3471  Default is global space.
3472 \end_layout
3474 \begin_layout Itemize
3475 offset: number: The initial offset in memory area.
3476 \end_layout
3478 \begin_layout Itemize
3479 size: number: The number of bytes in each row.
3480 \end_layout
3482 \begin_layout Itemize
3483 rows: number: The number of rows.
3484  Default is 1.
3485 \end_layout
3487 \begin_layout Itemize
3488 stride: number: The number of bytes offset increments from one row to next.
3489 \end_layout
3491 \begin_layout Standard
3492 Returns:
3493 \end_layout
3495 \begin_layout Itemize
3496 A handle to object.
3497 \end_layout
3499 \begin_layout Standard
3500 Return an object watching specified memory area.
3501 \end_layout
3503 \begin_layout Itemize
3504 Note: For fastest operation, limit checks to inside one memory area (that
3505  has to be mappable, individual RAM areas often are).
3506 \end_layout
3508 \begin_layout Subsubsection
3509 operator(): Check area for modifications
3510 \end_layout
3512 \begin_layout Itemize
3513 Syntax: boolean handle()
3514 \end_layout
3516 \begin_layout Standard
3517 Returns:
3518 \end_layout
3520 \begin_layout Itemize
3521 True if memory block has been modified since last call (or object creation
3522  if first call), false if not.
3523 \end_layout
3525 \begin_layout Standard
3526 Check if the block has been modified.
3527 \end_layout
3529 \begin_layout Standard
3530 \begin_inset Newpage pagebreak
3531 \end_inset
3534 \end_layout
3536 \begin_layout Section
3537 Global
3538 \end_layout
3540 \begin_layout Subsection
3541 print: Print values to console
3542 \end_layout
3544 \begin_layout Itemize
3545 Syntax: none print(value...
3546  values)
3547 \end_layout
3549 \begin_layout Standard
3550 Prints specified values to console.
3551  Can print any Lua type at least enough to identify the type and instance.
3552 \end_layout
3554 \begin_layout Subsection
3555 tostringx: Format a value to string
3556 \end_layout
3558 \begin_layout Itemize
3559 Syntax: string tostringx(value val)
3560 \end_layout
3562 \begin_layout Standard
3563 Formats value <val> like print would, and returns the result as a string.
3564 \end_layout
3566 \begin_layout Subsection
3567 exec: Execute lsnes commands
3568 \end_layout
3570 \begin_layout Itemize
3571 Syntax: none exec(string cmd)
3572 \end_layout
3574 \begin_layout Standard
3575 Execute lsnes command <cmd>.
3576 \end_layout
3578 \begin_layout Subsection
3579 utime: Get current time
3580 \end_layout
3582 \begin_layout Itemize
3583 Syntax: (number,number) utime()
3584 \end_layout
3586 \begin_layout Standard
3587 Returns two numbers.
3588  First is time since some epoch in seconds, the second is microseconds mod
3589  10^6 since that epoch.
3590 \end_layout
3592 \begin_layout Subsection
3593 set_idle_timeout: Run function after timeout when emulator is idle
3594 \end_layout
3596 \begin_layout Itemize
3597 Syntax: none set_idle_timeout(number timeout)
3598 \end_layout
3600 \begin_layout Standard
3601 Set number of microseconds to block idle for.
3602  After this timeout has expired, on_idle() will be called once.
3603 \end_layout
3605 \begin_layout Subsection
3606 set_timer_timeout: Run function after timeout.
3607 \end_layout
3609 \begin_layout Itemize
3610 Syntax: none set_timer_timeout(number timeout)
3611 \end_layout
3613 \begin_layout Standard
3614 Set number of microseconds to block timer for.
3615  After this timeout has expired, on_timer() will be called once.
3616 \end_layout
3618 \begin_layout Subsection
3619 bus_address: Look up address in system bus.
3620 \end_layout
3622 \begin_layout Itemize
3623 Syntax: none bus_address(number bus_addr)
3624 \end_layout
3626 \begin_layout Standard
3627 Returns virtual address corresponding to specified address on system bus.
3628 \end_layout
3630 \begin_layout Subsection
3631 loopwrapper: Convert loop into callable function
3632 \end_layout
3634 \begin_layout Itemize
3635 Syntax: function loopwrapper(function fun, ...)
3636 \end_layout
3638 \begin_layout Standard
3639 Calls function <fun> with function and specified arguments.
3640  The function passed suspends execution until the function returned is called.
3641  Handy for linear flow control among multiple invocations of a hook.
3642  Example code:
3643 \end_layout
3645 \begin_layout LyX-Code
3646 on_paint = loopwrapper(function(wait)
3647 \end_layout
3649 \begin_deeper
3650 \begin_layout LyX-Code
3651 while true do
3652 \end_layout
3654 \begin_deeper
3655 \begin_layout LyX-Code
3656 gui.text(0, 0, 
3657 \begin_inset Quotes eld
3658 \end_inset
3660 Test!
3661 \begin_inset Quotes erd
3662 \end_inset
3665 \end_layout
3667 \begin_layout LyX-Code
3668 wait();
3669 \end_layout
3671 \end_deeper
3672 \begin_layout LyX-Code
3674 \end_layout
3676 \end_deeper
3677 \begin_layout LyX-Code
3678 end);
3679 \end_layout
3681 \begin_layout Subsection
3682 list_bindings: List keybindings
3683 \end_layout
3685 \begin_layout Itemize
3686 Syntax: table list_bindings([string cmd])
3687 \end_layout
3689 \begin_layout Standard
3690 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
3691  If <cmd> is specified, the table is limited to that command.
3692  Also searches for controller keys.
3693 \end_layout
3695 \begin_layout Subsection
3696 get_alias: Get expansion of alias
3697 \end_layout
3699 \begin_layout Itemize
3700 Syntax: string get_alias(string aname)
3701 \end_layout
3703 \begin_layout Standard
3704 Get expansion of given alias <aname>.
3705 \end_layout
3707 \begin_layout Subsection
3708 set_alias: Set expansion of alias
3709 \end_layout
3711 \begin_layout Itemize
3712 Syntax: none set_alias(string aname, string value)
3713 \end_layout
3715 \begin_layout Standard
3716 Set expansion of given alias.
3717 \end_layout
3719 \begin_layout Subsection
3720 create_ibind: Create invese binding
3721 \end_layout
3723 \begin_layout Itemize
3724 Syntax: INVERSEBIND create_ibind(string name, string cmd)
3725 \end_layout
3727 \begin_layout Standard
3728 Return object representing inverse binding with specified name <name> and
3729  specified command <cmd>.
3730 \end_layout
3732 \begin_layout Itemize
3733 Note: To create press/release commands, use aliases +foo and -foo .
3734 \end_layout
3736 \begin_layout Itemize
3737 Note: Keep the returned object around.
3738 \end_layout
3740 \begin_layout Subsection
3741 create_command: Create a command
3742 \end_layout
3744 \begin_layout Itemize
3745 Syntax: COMMANDBIND create_commmand(string name, function a)
3746 \end_layout
3748 \begin_layout Itemize
3749 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
3750 \end_layout
3752 \begin_layout Standard
3753 Return object representing a command (pair).
3754 \end_layout
3756 \begin_layout Itemize
3757 If only one function is specied, the command is level-sensitive, <a> is
3758  callback.
3759 \end_layout
3761 \begin_layout Itemize
3762 If <b> is function, the function is edge-sensitive, <a> is positive edge
3763  callback and <b> is negative edge callback.
3764 \end_layout
3766 \begin_layout Itemize
3767 All callbacks get single argument: The parameters passed.
3768 \end_layout
3770 \begin_layout Itemize
3771 Keep the returned object around.
3772 \end_layout
3774 \begin_layout Subsection
3775 loadfile: Load Lua script
3776 \end_layout
3778 \begin_layout Itemize
3779 Syntax: function loadfile(string filename[, string base])
3780 \end_layout
3782 \begin_layout Standard
3783 Load lua script from <filename>, resolved relative to <base> (if empty,
3784  current directory).
3785 \end_layout
3787 \begin_layout Subsection
3788 dofile: Execute Lua script
3789 \end_layout
3791 \begin_layout Itemize
3792 Syntax: function dofile(string filename[, string base])
3793 \end_layout
3795 \begin_layout Standard
3796 Execute lua script from <filename>, resolved relative to <base> (if empty,
3797  current directory) and return all return values.
3798 \end_layout
3800 \begin_layout Subsection
3801 resolve_filename: Resolve name of file relative to another
3802 \end_layout
3804 \begin_layout Itemize
3805 Syntax: string resolve_file(string filename, string base)
3806 \end_layout
3808 \begin_layout Standard
3809 Resolve name of file <filename> relative to <base> and return the result.
3810 \end_layout
3812 \begin_layout Subsection
3813 render_queue_function: Return paint function for render queue
3814 \end_layout
3816 \begin_layout Itemize
3817 Syntax: function render_queue_function(RENDERQUEUE rq)
3818 \end_layout
3820 \begin_layout Standard
3821 Return function that renders render queue <rq>.
3822 \end_layout
3824 \begin_layout Itemize
3825 Handy for paint callback if one is using render queues updated in other
3826  callbacks.
3827  As in:
3828 \end_layout
3830 \begin_layout LyX-Code
3831 handle = callback.paint:register(render_queue_function(my_rq));
3832 \end_layout
3834 \begin_layout Subsection
3835 identify_class: Identify class of object
3836 \end_layout
3838 \begin_layout Itemize
3839 Syntax: string identify_class(userdata object)
3840 \end_layout
3842 \begin_layout Standard
3843 Identifies the class of userdata <object>, if possible.
3844  If no identification is possible, returns 
3845 \begin_inset Quotes eld
3846 \end_inset
3848 unknown
3849 \begin_inset Quotes erd
3850 \end_inset
3853 \end_layout
3855 \begin_layout Subsection
3856 lookup_class: Lookup class by name
3857 \end_layout
3859 \begin_layout Itemize
3860 Syntax: classobj lookup_class(string name)
3861 \end_layout
3863 \begin_layout Standard
3864 Looks up class corresponding to <name>, if possible.
3865  If not found, returns nil.
3866  The classobj has following fields:
3867 \end_layout
3869 \begin_layout Itemize
3870 _static_methods: Return static method names
3871 \end_layout
3873 \begin_layout Itemize
3874 _class_methods: Return class method names
3875 \end_layout
3877 \begin_layout Itemize
3878 <static-function-name>: The specified static function.
3879 \end_layout
3881 \begin_layout Subsection
3882 all_classes: Get list of all classes
3883 \end_layout
3885 \begin_layout Itemize
3886 Syntax: string...
3887  all_classes()
3888 \end_layout
3890 \begin_layout Standard
3891 Get names of all classes available.
3892 \end_layout
3894 \begin_layout Subsection
3896 \end_layout
3898 \begin_layout Subsection
3899 icnov: Class ICONV
3900 \end_layout
3902 \begin_layout Standard
3903 See class ICONV.
3904 \end_layout
3906 \begin_layout Subsection
3907 filereader: Class FILEREADER
3908 \end_layout
3910 \begin_layout Standard
3911 See class FILEREADER.
3912 \end_layout
3914 \begin_layout Standard
3915 \begin_inset Newpage pagebreak
3916 \end_inset
3919 \end_layout
3921 \begin_layout Section
3922 Table bit:
3923 \end_layout
3925 \begin_layout Standard
3926 Bitwise logical functions and related.
3927 \end_layout
3929 \begin_layout Subsection
3930 bit.none/bit.bnot: Bitwise none or NOT function
3931 \end_layout
3933 \begin_layout Itemize
3934 Syntax: number bit.none(number...)
3935 \end_layout
3937 \begin_layout Itemize
3938 Syntax: number bit.bnot(number...)
3939 \end_layout
3941 \begin_layout Standard
3942 48-bit bitwise NOT / NONE function (set bits that are set in none of the
3943  arguments).
3944 \end_layout
3946 \begin_layout Subsection
3947 bit.any/bit.bor: Bitwise any or OR function
3948 \end_layout
3950 \begin_layout Itemize
3951 Syntax: number bit.any(number...)
3952 \end_layout
3954 \begin_layout Itemize
3955 Syntax: number bit.bor(number...)
3956 \end_layout
3958 \begin_layout Standard
3959 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
3960 \end_layout
3962 \begin_layout Subsection
3963 bit.all/bit.band: Bitwise all or AND function
3964 \end_layout
3966 \begin_layout Itemize
3967 Syntax: number bit.all(number...)
3968 \end_layout
3970 \begin_layout Itemize
3971 Syntax: number bit.band(number...)
3972 \end_layout
3974 \begin_layout Standard
3975 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
3977 \end_layout
3979 \begin_layout Subsection
3980 bit.parity/bit.bxor: Bitwise parity or XOR function
3981 \end_layout
3983 \begin_layout Itemize
3984 Syntax: number bit.parity(number...)
3985 \end_layout
3987 \begin_layout Itemize
3988 Syntax: number bit.bxor(number...)
3989 \end_layout
3991 \begin_layout Standard
3992 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
3993  of the arguments).
3994 \end_layout
3996 \begin_layout Subsection
3997 bit.lrotate: Rotate a number left
3998 \end_layout
4000 \begin_layout Itemize
4001 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4002 \end_layout
4004 \begin_layout Standard
4005 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4006  1) places.
4007 \end_layout
4009 \begin_layout Subsection
4010 bit.rrotate: Rotate a number right
4011 \end_layout
4013 \begin_layout Itemize
4014 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4015 \end_layout
4017 \begin_layout Standard
4018 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4019  1) places.
4020 \end_layout
4022 \begin_layout Subsection
4023 bit.lshift: Shift a number left
4024 \end_layout
4026 \begin_layout Itemize
4027 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4028 \end_layout
4030 \begin_layout Standard
4031 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4032  1) places.
4033  The new bits are filled with zeroes.
4034 \end_layout
4036 \begin_layout Subsection
4037 bit.lrshift: Shift a number right (logical)
4038 \end_layout
4040 \begin_layout Itemize
4041 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4042 \end_layout
4044 \begin_layout Standard
4045 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4046  (default 1) places.
4047  The new bits are filled with zeroes.
4048 \end_layout
4050 \begin_layout Subsection
4051 bit.arshift: Shift a number right (arithmetic)
4052 \end_layout
4054 \begin_layout Itemize
4055 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4056 \end_layout
4058 \begin_layout Standard
4059 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4060  (default 1) places.
4061  The new bits are shifted in with copy of the high bit.
4062 \end_layout
4064 \begin_layout Subsection
4065 bit.extract: Extract/shuffle bits from number
4066 \end_layout
4068 \begin_layout Itemize
4069 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4070 \end_layout
4072 \begin_layout Standard
4073 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4074 \end_layout
4076 \begin_layout Itemize
4077 Note: Bit numbers up to 51 should work reliably (then things start falling
4078  apart due to double precision issues).
4079 \end_layout
4081 \begin_layout Itemize
4082 Note: There are two special bit positions, true and false, standing for
4083  always set bit and always clear bit.
4084 \end_layout
4086 \begin_layout Subsection
4087 bit.value: Construct number with specified bits set
4088 \end_layout
4090 \begin_layout Itemize
4091 Syntax: number bit.value([number bit1[, number bit2,...]])
4092 \end_layout
4094 \begin_layout Standard
4095 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4096  <bit2> places and so on.
4097  As special value, nil argument is no-op.
4098 \end_layout
4100 \begin_layout Subsection
4101 bit.test: Test if bit is set
4102 \end_layout
4104 \begin_layout Itemize
4105 Syntax: boolean bit.test(number a, number bit)
4106 \end_layout
4108 \begin_layout Standard
4109 Tests if bit <bit> is set in <a>.
4110  If it is set, returns true, otherwise false.
4111 \end_layout
4113 \begin_layout Subsection
4114 bit.testn: Test if bit is clear
4115 \end_layout
4117 \begin_layout Itemize
4118 Syntax: boolean bit.testn(number a, number bit)
4119 \end_layout
4121 \begin_layout Standard
4122 Tests if bit <bit> is set in <a>.
4123  If it is clear, returns true, otherwise false.
4124 \end_layout
4126 \begin_layout Subsection
4127 bit.test_any: Test if any bit is set
4128 \end_layout
4130 \begin_layout Itemize
4131 Syntax: boolean bit.test_any(number a, number b)
4132 \end_layout
4134 \begin_layout Standard
4135 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4136 \end_layout
4138 \begin_layout Subsection
4139 bit.test_all: Test if all bits are set
4140 \end_layout
4142 \begin_layout Itemize
4143 Syntax: boolean bit.test_all(number a, number b)
4144 \end_layout
4146 \begin_layout Standard
4147 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4148 \end_layout
4150 \begin_layout Subsection
4151 bit.popcount: Population count
4152 \end_layout
4154 \begin_layout Itemize
4155 Syntax: number bit.popcount(number a)
4156 \end_layout
4158 \begin_layout Standard
4159 Returns number of set bits in <a>.
4160 \end_layout
4162 \begin_layout Subsection
4163 bit.clshift: Chained left shift
4164 \end_layout
4166 \begin_layout Itemize
4167 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4168  bits]])
4169 \end_layout
4171 \begin_layout Standard
4172 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4173  numbers to be of specified number of bits <bits> (default 48).
4174 \end_layout
4176 \begin_layout Subsection
4177 bit.crshift: Chained right shift
4178 \end_layout
4180 \begin_layout Itemize
4181 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4182  bits]])
4183 \end_layout
4185 \begin_layout Standard
4186 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4187  assuming numbers to be of specified number of bits <bits> (default 48).
4188 \end_layout
4190 \begin_layout Subsection
4191 bit.flagdecode: Decode bitfield into flags
4192 \end_layout
4194 \begin_layout Itemize
4195 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4196  off]])
4197 \end_layout
4199 \begin_layout Standard
4200 Return string of length bits where ith character is ith character of on
4201  if bit i is on, otherwise ith character of off.
4202  Out of range reads give last character.
4203 \end_layout
4205 \begin_layout Itemize
4206 Note: <on> defaults to '*' if empty.
4207 \end_layout
4209 \begin_layout Itemize
4210 Note: <off> defaults to '-' if empty.
4211 \end_layout
4213 \begin_layout Subsection
4214 bit.rflagdecode: Decode bitfield into flags
4215 \end_layout
4217 \begin_layout Itemize
4218 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4219  off]])
4220 \end_layout
4222 \begin_layout Standard
4223 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4224 nt bit first).
4225 \end_layout
4227 \begin_layout Subsection
4228 bit.swap{,s}{,h,d,q}word: Swap word endian
4229 \end_layout
4231 \begin_layout Itemize
4232 Syntax: number bit.swapword(number n)
4233 \end_layout
4235 \begin_layout Itemize
4236 Syntax: number bit.swaphword(number n)
4237 \end_layout
4239 \begin_layout Itemize
4240 Syntax: number bit.swapdword(number n)
4241 \end_layout
4243 \begin_layout Itemize
4244 Syntax: number bit.swapqword(number n)
4245 \end_layout
4247 \begin_layout Itemize
4248 Syntax: number bit.swapsword(number n)
4249 \end_layout
4251 \begin_layout Itemize
4252 Syntax: number bit.swapshword(number n)
4253 \end_layout
4255 \begin_layout Itemize
4256 Syntax: number bit.swapsdword(number n)
4257 \end_layout
4259 \begin_layout Itemize
4260 Syntax: number bit.swapsqword(number n)
4261 \end_layout
4263 \begin_layout Standard
4264 Swap endianess of (un)signed integer <n>.
4265 \end_layout
4267 \begin_layout Subsection
4268 bit.compose: Compose multi-byte number
4269 \end_layout
4271 \begin_layout Itemize
4272 Syntax: number bit.compose(number n...)
4273 \end_layout
4275 \begin_layout Standard
4276 Return 
4277 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4278 \end_inset
4281 \end_layout
4283 \begin_layout Subsection
4284 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4285 \end_layout
4287 \begin_layout Itemize
4288 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4289 \end_layout
4291 \begin_layout Itemize
4292 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4293 \end_layout
4295 \begin_layout Standard
4296 Load little (*le) or big (*be) endian binary number from position <pos>
4297  of string <str>.
4298  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4299  double.
4300 \end_layout
4302 \begin_layout Subsection
4303 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4304 \end_layout
4306 \begin_layout Itemize
4307 Syntax: string bit.binary_st_<type>le(number x);
4308 \end_layout
4310 \begin_layout Itemize
4311 Syntax: string bit.binary_st_<type>be(number x);
4312 \end_layout
4314 \begin_layout Standard
4315 Store specified number <x> as binary in string and return the result.
4316  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4317  double.
4318 \end_layout
4320 \begin_layout Subsection
4321 bit.quotent: Integer quotent
4322 \end_layout
4324 \begin_layout Itemize
4325 Syntax: number bit.quotent(number a, number b)
4326 \end_layout
4328 \begin_layout Standard
4329 Calculate quotent a/b.
4330 \end_layout
4332 \begin_layout Subsection
4333 bit.multidiv: Divide and split among multiple divisiors
4334 \end_layout
4336 \begin_layout Itemize
4337 Syntax: number...
4338  bit.multidiv(number v, number q...)
4339 \end_layout
4341 \begin_layout Standard
4342 Does the following steps:
4343 \end_layout
4345 \begin_layout Enumerate
4346 Set v' to <v>.
4347 \end_layout
4349 \begin_layout Enumerate
4350 For each <q> q:
4351 \end_layout
4353 \begin_deeper
4354 \begin_layout Enumerate
4355 Calculate quotent(v'/q) and add that to numbers returned.
4356 \end_layout
4358 \begin_layout Enumerate
4359 v' <- remainder(v'/q)
4360 \end_layout
4362 \end_deeper
4363 \begin_layout Enumerate
4364 Add v' to numbers returned.
4365 \end_layout
4367 \begin_layout Standard
4368 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
4369  at each step.
4370  <v> may be floating point, <q>s are integers.
4371 \end_layout
4373 \begin_layout Itemize
4374 E.g.
4375  bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
4376 \end_layout
4378 \begin_layout Itemize
4379 E.g.
4380  bit.multidiv(a, b) calculates quotent and remainder of a/b.
4381 \end_layout
4383 \begin_layout Subsection
4384 bit.mul32: 32-bit multiply
4385 \end_layout
4387 \begin_layout Itemize
4388 Syntax: number, number bit.mul32(number a, number b)
4389 \end_layout
4391 \begin_layout Standard
4392 Multiply 32-bit numbers <a> and <b>.
4393  The first return value is low 32 bits of result, the second is high 32
4394  bits.
4395 \end_layout
4397 \begin_layout Standard
4398 \begin_inset Newpage pagebreak
4399 \end_inset
4402 \end_layout
4404 \begin_layout Section
4405 Table classes:
4406 \end_layout
4408 \begin_layout Subsection
4409 classes.<foo>: The classobj for class <foo>
4410 \end_layout
4412 \begin_layout Itemize
4413 Syntax: classes.<foo>
4414 \end_layout
4416 \begin_layout Standard
4417 The classobj for class <foo>.
4418 \end_layout
4420 \begin_layout Subsection
4421 classes.<foo>._static_methods: Enumerate static methods
4422 \end_layout
4424 \begin_layout Itemize
4425 Syntax: string...
4426  classes.<foo>._static_methods()
4427 \end_layout
4429 \begin_layout Standard
4430 Returns all static methods of <foo> as strings.
4431 \end_layout
4433 \begin_layout Subsection
4434 classes.<foo>._class_methods: Enumerate static methods
4435 \end_layout
4437 \begin_layout Itemize
4438 Syntax: string...
4439  classes.<foo>._class_methods()
4440 \end_layout
4442 \begin_layout Standard
4443 Returns all class methods of <foo> as strings.
4444 \end_layout
4446 \begin_layout Subsection
4447 classes.<foo>.<bar>: Static method
4448 \end_layout
4450 \begin_layout Itemize
4451 Syntax: variable classes.<foo>.<bar>(variable...)
4452 \end_layout
4454 \begin_layout Standard
4455 Invokes static method <bar> of class <foo>.
4456 \end_layout
4458 \begin_layout Section
4459 Table gui:
4460 \end_layout
4462 \begin_layout Subsection
4463 gui.resolution: Get current resolution
4464 \end_layout
4466 \begin_layout Itemize
4467 Syntax: (number, number) gui.resolution()
4468 \end_layout
4470 \begin_layout Standard
4471 Returns 2-tuple (hresolution, vresolution).
4472 \end_layout
4474 \begin_layout Subsection
4475 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
4476 \end_layout
4478 \begin_layout Itemize
4479 Syntax: number gui.left_gap(number gap)
4480 \end_layout
4482 \begin_layout Itemize
4483 Syntax: number gui.right_gap(number gap)
4484 \end_layout
4486 \begin_layout Itemize
4487 Syntax: number gui.top_gap(number gap)
4488 \end_layout
4490 \begin_layout Itemize
4491 Syntax: number gui.bottom_gap(number gap)
4492 \end_layout
4494 \begin_layout Standard
4495 Set the specified edge gap to specified value <gap> (max gap is 8191).
4496  If successful, old gap is returned.
4497 \end_layout
4499 \begin_layout Subsection
4500 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
4501  Adjust edge gaps
4502 \end_layout
4504 \begin_layout Itemize
4505 Syntax: number gui.delta_left_gap(number dgap)
4506 \end_layout
4508 \begin_layout Itemize
4509 Syntax: number gui.delta_right_gap(number dgap)
4510 \end_layout
4512 \begin_layout Itemize
4513 Syntax: number gui.delta_top_gap(number dgap)
4514 \end_layout
4516 \begin_layout Itemize
4517 Syntax: number gui.delta_bottom_gap(number dgap)
4518 \end_layout
4520 \begin_layout Standard
4521 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
4522  and return the old gap (returns nothing on error).
4523 \end_layout
4525 \begin_layout Subsection
4526 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
4527 \end_layout
4529 \begin_layout Itemize
4530 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
4531  bgc]])
4532 \end_layout
4534 \begin_layout Itemize
4535 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
4536  bgc]])
4537 \end_layout
4539 \begin_layout Itemize
4540 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
4541  bgc]])
4542 \end_layout
4544 \begin_layout Itemize
4545 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
4546  bgc]])
4547 \end_layout
4549 \begin_layout Standard
4550 Draw specified text on the GUI (each character cell is 8 or 16 wide and
4551  16 high).
4552  Parameters:
4553 \end_layout
4555 \begin_layout Itemize
4556 x: X-coordinate to start the drawing from (and x-coordinate at begining
4557  of the lines).
4558 \end_layout
4560 \begin_layout Itemize
4561 y: Y-coordinate to start the drawing from.
4562 \end_layout
4564 \begin_layout Itemize
4565 text: The text to draw.
4566 \end_layout
4568 \begin_layout Itemize
4569 fgc: Text color (default is 0xFFFFFF (white))
4570 \end_layout
4572 \begin_layout Itemize
4573 bgc: Background color (default is -1 (transparent))
4574 \end_layout
4576 \begin_layout Standard
4577 Note: The H variants draw at double width and V variants draw at double
4578  height.
4579 \end_layout
4581 \begin_layout Subsection
4582 gui.rectangle: Draw a rectangle
4583 \end_layout
4585 \begin_layout Itemize
4586 Syntax: none gui.rectangle(number x, number y, number width, number height[,
4587  number thickness[, number outline[, number fill]]])
4588 \end_layout
4590 \begin_layout Standard
4591 Draw rectangle on the GUI.
4592  Parameters:
4593 \end_layout
4595 \begin_layout Itemize
4596 x: X-coordinate of left edge.
4597 \end_layout
4599 \begin_layout Itemize
4600 y: Y-coordinate of upper edge.
4601 \end_layout
4603 \begin_layout Itemize
4604 width: Width of rectangle.
4605 \end_layout
4607 \begin_layout Itemize
4608 height: Height of rectangle.
4609 \end_layout
4611 \begin_layout Itemize
4612 thickness: Thickness of outline (default is 1).
4613 \end_layout
4615 \begin_layout Itemize
4616 outline: Color of outline (default is 0xFFFFFF (white))
4617 \end_layout
4619 \begin_layout Itemize
4620 fill: Color of fill (default is -1 (transparent))
4621 \end_layout
4623 \begin_layout Subsection
4624 gui.box: Draw a 3D-effect box
4625 \end_layout
4627 \begin_layout Itemize
4628 Syntax: none gui.box(number x, number y, number width, number height[, number
4629  thickness[, number outline1[,number outline2[, number fill]]]])
4630 \end_layout
4632 \begin_layout Standard
4633 Draw rectangle with 3D effect on the GUI.
4634  Parameters:
4635 \end_layout
4637 \begin_layout Itemize
4638 x: X-coordinate of left edge.
4639 \end_layout
4641 \begin_layout Itemize
4642 y: Y-coordinate of upper edge.
4643 \end_layout
4645 \begin_layout Itemize
4646 width: Width of rectangle.
4647 \end_layout
4649 \begin_layout Itemize
4650 height: Height of rectangle.
4651 \end_layout
4653 \begin_layout Itemize
4654 thickness: Thickness of outline (default is 1).
4655 \end_layout
4657 \begin_layout Itemize
4658 outline1: First color of outline (default is 0xFFFFFF (white))
4659 \end_layout
4661 \begin_layout Itemize
4662 outline2: First color of outline (default is 0x808080 (dark gray))
4663 \end_layout
4665 \begin_layout Itemize
4666 fill: Color of fill (default is 0xC0C0C0 (light grayy))
4667 \end_layout
4669 \begin_layout Subsection
4670 gui.pixel: Draw a single pixel
4671 \end_layout
4673 \begin_layout Itemize
4674 Syntax: none gui.pixel(number x, number y[, number color])
4675 \end_layout
4677 \begin_layout Standard
4678 Draw one pixel on the GUI.
4679  Parameters:
4680 \end_layout
4682 \begin_layout Itemize
4683 x: X-coordinate of the pixel
4684 \end_layout
4686 \begin_layout Itemize
4687 y: Y-coordinate of the pixel
4688 \end_layout
4690 \begin_layout Itemize
4691 color: Color of the pixel (default is 0xFFFFFF (white))
4692 \end_layout
4694 \begin_layout Subsection
4695 gui.crosshair: Draw a crosshair
4696 \end_layout
4698 \begin_layout Itemize
4699 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
4700 \end_layout
4702 \begin_layout Standard
4703 Draw a crosshair.
4704  Parameters:
4705 \end_layout
4707 \begin_layout Itemize
4708 x: X-coordinate of the crosshair
4709 \end_layout
4711 \begin_layout Itemize
4712 y: Y-coordinate of the crosshair
4713 \end_layout
4715 \begin_layout Itemize
4716 length: Length of the crosshair lines (default 10).
4717 \end_layout
4719 \begin_layout Itemize
4720 color: Color of the crosshair (default is 0xFFFFFF (white))
4721 \end_layout
4723 \begin_layout Subsection
4724 gui.line: Draw a line
4725 \end_layout
4727 \begin_layout Itemize
4728 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
4729  color])
4730 \end_layout
4732 \begin_layout Standard
4733 Draw a thin line.
4734  Parameters:
4735 \end_layout
4737 \begin_layout Itemize
4738 x1: X-coordinate of one end.
4739 \end_layout
4741 \begin_layout Itemize
4742 y1: Y-coordinate of one end.
4743 \end_layout
4745 \begin_layout Itemize
4746 x2: X-coordinate of the other end.
4747 \end_layout
4749 \begin_layout Itemize
4750 y2: Y-coordinate of the other end.
4751 \end_layout
4753 \begin_layout Itemize
4754 color: Color of the line (default is 0xFFFFFF (white)).
4755 \end_layout
4757 \begin_layout Subsection
4758 gui.circle: Draw a (filled) circle
4759 \end_layout
4761 \begin_layout Itemize
4762 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
4763  border[, number fil]]])
4764 \end_layout
4766 \begin_layout Standard
4767 Draw a circle.
4768  Parameters.
4769 \end_layout
4771 \begin_layout Itemize
4772 x: X-coordinate of the center
4773 \end_layout
4775 \begin_layout Itemize
4776 y: Y-coordinate of the center
4777 \end_layout
4779 \begin_layout Itemize
4780 r: The radius of the circle
4781 \end_layout
4783 \begin_layout Itemize
4784 thick: Border thickness
4785 \end_layout
4787 \begin_layout Itemize
4788 border: Border color (default is 0xFFFFFF (white))
4789 \end_layout
4791 \begin_layout Itemize
4792 fill: Fill color (default is -1 (transparent)).
4793 \end_layout
4795 \begin_layout Subsection
4796 gui.repaint: Arrange a repaint
4797 \end_layout
4799 \begin_layout Itemize
4800 Syntax: none gui.repaint()
4801 \end_layout
4803 \begin_layout Standard
4804 Request on_repaint() to happen as soon as possible.
4805 \end_layout
4807 \begin_layout Subsection
4808 gui.subframe_update: Enable/Disable subframe updates
4809 \end_layout
4811 \begin_layout Itemize
4812 Syntax: none gui.subframe_update(boolean on)
4813 \end_layout
4815 \begin_layout Standard
4816 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
4817  or not happen (<on>=false).
4818 \end_layout
4820 \begin_layout Subsection
4821 gui.screenshot: Write a screenshot
4822 \end_layout
4824 \begin_layout Itemize
4825 Syntax: none gui.screenshot(string filename)
4826 \end_layout
4828 \begin_layout Standard
4829 Write PNG screenshot of the current frame (no drawings) to specified file
4830  <filename>.
4831 \end_layout
4833 \begin_layout Subsection
4834 gui.screenshot_bitmap: Write a screenshot to bitmap
4835 \end_layout
4837 \begin_layout Itemize
4838 Syntax: DBITMAP gui.screenshot_bitmap()
4839 \end_layout
4841 \begin_layout Standard
4842 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
4843  the result.
4844 \end_layout
4846 \begin_layout Subsection
4847 gui.color: Compose a color.
4848 \end_layout
4850 \begin_layout Itemize
4851 Syntax: number gui.color(number r, number g, number b[, number a])
4852 \end_layout
4854 \begin_layout Itemize
4855 Syntax: number gui.color(string c)
4856 \end_layout
4858 \begin_layout Standard
4859 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
4860 , each component in scale 0-255.
4861  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
4862  fully opaque).
4863  The default alpha is 256.
4864 \end_layout
4866 \begin_layout Standard
4867 The form taking a string returns color corresponding color name.
4868 \end_layout
4870 \begin_layout Subsection
4871 gui.status: Set status variable
4872 \end_layout
4874 \begin_layout Itemize
4875 Syntax: none gui.status(string name, string value)
4876 \end_layout
4878 \begin_layout Standard
4879 Set status field 
4880 \begin_inset Quotes eld
4881 \end_inset
4883 L[<name>]
4884 \begin_inset Quotes erd
4885 \end_inset
4887  to <value> in status area.
4888 \end_layout
4890 \begin_layout Subsection
4891 gui.rainbow: Rainbow color calculation
4892 \end_layout
4894 \begin_layout Itemize
4895 Syntax: number gui.rainbow(number step, number steps[, number color])
4896 \end_layout
4898 \begin_layout Standard
4899 Perform hue rotation of color <color> (default bright red), by <step> steps.
4900  The number of steps per full rotation is given by absolute value of <steps>.
4901 \end_layout
4903 \begin_layout Standard
4904 If <step> is negative, the rotation will be counterclockwise.
4905 \end_layout
4907 \begin_layout Subsection
4908 gui.kill_frame: Kill video frame and associated sound
4909 \end_layout
4911 \begin_layout Itemize
4912 Syntax: none gui.kill_frame()
4913 \end_layout
4915 \begin_layout Standard
4916 Kills the currently dumped video frame + the associated sound.
4917  Only valid in on_video callback.
4918 \end_layout
4920 \begin_layout Subsection
4921 gui.set_video_scale: Set video frame scale
4922 \end_layout
4924 \begin_layout Itemize
4925 Syntax: none gui.set_video_scale(number h, number v)
4926 \end_layout
4928 \begin_layout Standard
4929 Sets the scale factors of current frame to <h>x<v>.
4930  Only valid in on_video callback.
4931 \end_layout
4933 \begin_layout Subsection
4934 gui.arrow: Draw an arrow
4935 \end_layout
4937 \begin_layout Itemize
4938 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
4939  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
4941 \end_layout
4943 \begin_layout Standard
4944 Draws an arrow using color <color>.
4945  The tip of arrow is at (<x>, <y>).
4946  Other parameters:
4947 \end_layout
4949 \begin_layout Enumerate
4950 <length>: The length of arrow tail.
4951 \end_layout
4953 \begin_layout Enumerate
4954 <hwidth>: The width of arrow head.
4955  Should be odd.
4956 \end_layout
4958 \begin_layout Enumerate
4959 <direction>: Direction of arrow.
4960  0 is to right, +1 rotates 45 degrees counterclockwise.
4961 \end_layout
4963 \begin_layout Enumerate
4964 <fill>: If true, fill the arrow head.
4965  Default false.
4966 \end_layout
4968 \begin_layout Enumerate
4969 <twidth>: Tail width.
4970  Should be odd.
4971  Default 1.
4972 \end_layout
4974 \begin_layout Enumerate
4975 <hthick>: Head thickness (only used if <fill> is false).
4976  Default is <twidth>.
4977 \end_layout
4979 \begin_layout Subsection
4980 gui.tiled_bitmap: Class TILEMAP
4981 \end_layout
4983 \begin_layout Standard
4984 See class TILEMAP.
4985 \end_layout
4987 \begin_layout Subsection
4988 gui.palette: Class PALETTE
4989 \end_layout
4991 \begin_layout Standard
4992 See class PALETTE.
4993 \end_layout
4995 \begin_layout Subsection
4996 gui.bitmap: Class BITMAP
4997 \end_layout
4999 \begin_layout Standard
5000 See class BITMAP.
5001 \end_layout
5003 \begin_layout Subsection
5004 gui.dbitmap: Class DBITMAP
5005 \end_layout
5007 \begin_layout Standard
5008 See class DBITMAP.
5009 \end_layout
5011 \begin_layout Subsection
5012 gui.font: Class CUSTOMFONT
5013 \end_layout
5015 \begin_layout Standard
5016 See class CUSTOMFONT.
5017 \end_layout
5019 \begin_layout Subsection
5020 gui.renderctx: Class RENDERCTX
5021 \end_layout
5023 \begin_layout Standard
5024 See class RENDERCTX.
5025 \end_layout
5027 \begin_layout Subsection
5028 gui.image: Class IMAGELOADER
5029 \end_layout
5031 \begin_layout Standard
5032 See class IMAGELOADER.
5033 \end_layout
5035 \begin_layout Standard
5036 \begin_inset Newpage pagebreak
5037 \end_inset
5040 \end_layout
5042 \begin_layout Section
5043 table input
5044 \end_layout
5046 \begin_layout Standard
5047 Input handling.
5048  Functions manipulating input are only available in on_input callback.
5049 \end_layout
5051 \begin_layout Subsection
5052 input.get: Read controller button/axis (deprecated)
5053 \end_layout
5055 \begin_layout Itemize
5056 Syntax: number input.get(number controller, number index)
5057 \end_layout
5059 \begin_layout Standard
5060 Read the specified index <index> (zero-based) from specified controller
5061  <controller> (zero-based).
5063 \end_layout
5065 \begin_layout Subsection
5066 input.set: Write controller button/axis (deprecated)
5067 \end_layout
5069 \begin_layout Itemize
5070 Syntax: none input.set(number controller, number index, number value)
5071 \end_layout
5073 \begin_layout Standard
5074 Write the specified index <index> (zero-based) from specified controller
5075  <controller> (zero-based), storing value <value>.
5076 \end_layout
5078 \begin_layout Subsection
5079 input.get2: Read controller button/axis
5080 \end_layout
5082 \begin_layout Itemize
5083 Syntax: number input.get2(number port, number controller, number index)
5084 \end_layout
5086 \begin_layout Standard
5087 Read the specified input tuple.
5088  Port 0 is system port.
5089 \end_layout
5091 \begin_layout Subsection
5092 input.set2: Write controller button/axis
5093 \end_layout
5095 \begin_layout Itemize
5096 Syntax: input.set2(number port, number controller, number index, number value)
5097 \end_layout
5099 \begin_layout Standard
5100 Write the specified input tuple.
5101  Port 0 is system port.
5102 \end_layout
5104 \begin_layout Subsection
5105 input.lcid_to_pcid2: Look up logical controller
5106 \end_layout
5108 \begin_layout Itemize
5109 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5110 \end_layout
5112 \begin_layout Standard
5113 Look up physical pcid pair (port, controller) corresponding to specified
5114  logical controller (1-based).
5115  Returns nothing if controller does not exist.
5116 \end_layout
5118 \begin_layout Subsection
5119 input.port_type: Look up port type
5120 \end_layout
5122 \begin_layout Itemize
5123 Syntax: string input.port_type(number port)
5124 \end_layout
5126 \begin_layout Standard
5127 Return type of specified port.
5128 \end_layout
5130 \begin_layout Subsection
5131 input.controller_info: Get information about controller
5132 \end_layout
5134 \begin_layout Itemize
5135 Syntax: table input.controller_info(number port, number controller)
5136 \end_layout
5138 \begin_layout Standard
5139 Get controller info for specified controller.
5140  If controller does not exist, returns nil.
5141  Otherwise returns a table with following fields:
5142 \end_layout
5144 \begin_layout Itemize
5145 type (string): Type of the controller.
5146 \end_layout
5148 \begin_layout Itemize
5149 class (string): Class of the controller.
5150 \end_layout
5152 \begin_layout Itemize
5153 classnum (number): Number of the controller within its class (1-based)
5154 \end_layout
5156 \begin_layout Itemize
5157 lcid (number): Logical controller number of the controller.
5158 \end_layout
5160 \begin_layout Itemize
5161 button_count (number): Number of buttons on controller
5162 \end_layout
5164 \begin_layout Itemize
5165 buttons (array): Array of following info about each button:
5166 \end_layout
5168 \begin_deeper
5169 \begin_layout Itemize
5170 type (string): Type of button.
5171  Currently one of 
5172 \begin_inset Quotes eld
5173 \end_inset
5175 null
5176 \begin_inset Quotes erd
5177 \end_inset
5180 \begin_inset Quotes eld
5181 \end_inset
5183 button
5184 \begin_inset Quotes erd
5185 \end_inset
5188 \begin_inset Quotes eld
5189 \end_inset
5191 axis
5192 \begin_inset Quotes erd
5193 \end_inset
5196 \begin_inset Quotes eld
5197 \end_inset
5199 raxis
5200 \begin_inset Quotes erd
5201 \end_inset
5204 \end_layout
5206 \begin_layout Itemize
5207 name (string): Name of button.
5208 \end_layout
5210 \begin_layout Itemize
5211 symbol (string): Symbol of button.
5212  Only present for type 
5213 \begin_inset Quotes eld
5214 \end_inset
5216 button
5217 \begin_inset Quotes erd
5218 \end_inset
5221 \end_layout
5223 \begin_layout Itemize
5224 hidden (boolean): True if hidden button.
5226 \end_layout
5228 \end_deeper
5229 \begin_layout Subsection
5230 input.veto_button: Veto a button press
5231 \end_layout
5233 \begin_layout Itemize
5234 Syntax: none input.veto_button()
5235 \end_layout
5237 \begin_layout Standard
5238 Signals that the button event should be vetoed.
5239  Only valid in on_button callback.
5240 \end_layout
5242 \begin_layout Subsection
5243 input.geta: Get all buttons for controller (deprecated)
5244 \end_layout
5246 \begin_layout Itemize
5247 Syntax: (number, number...) input.geta(number controller)
5248 \end_layout
5250 \begin_layout Standard
5251 Get input state for entiere controller.
5252  Returns n return values.
5253 \end_layout
5255 \begin_layout Itemize
5256 1st return value: Bitmask: bit i is set if i:th index is nonzero
5257 \end_layout
5259 \begin_layout Itemize
5260 2nd- return value: value of i:th index.
5261 \end_layout
5263 \begin_layout Subsection
5264 input.seta: Set all buttons for controller (deprecated)
5265 \end_layout
5267 \begin_layout Itemize
5268 Syntax: none input.seta(number controller, number bitmask, number args...)
5269 \end_layout
5271 \begin_layout Standard
5272 Set state for entiere controller.
5273  args is up to N values for indices (overriding values in bitmask if specified).
5274 \end_layout
5276 \begin_layout Subsection
5277 input.controllertype: Get controller type (deprecated)
5278 \end_layout
5280 \begin_layout Itemize
5281 syntax: string input.controllertype(number controller)
5282 \end_layout
5284 \begin_layout Standard
5285 Get the type of controller as string.
5286 \end_layout
5288 \begin_layout Subsection
5289 input.reset: Execute (delayed) reset
5290 \end_layout
5292 \begin_layout Itemize
5293 Syntax: none input.reset([number cycles])
5294 \end_layout
5296 \begin_layout Standard
5297 Execute reset.
5298  If <cycles> is greater than zero, do delayed reset.
5299  0 (or no value) causes immediate reset.
5300 \end_layout
5302 \begin_layout Itemize
5303 Note: Only available with subframe flag false.
5304 \end_layout
5306 \begin_layout Subsection
5307 input.raw: Return raw input data
5308 \end_layout
5310 \begin_layout Itemize
5311 Syntax: table input.raw()
5312 \end_layout
5314 \begin_layout Standard
5315 Returns table of tables of all available keys and axes.
5316  The first table is indexed by key name (platform-dependent!), and the inner
5317  table has the following fields:
5318 \end_layout
5320 \begin_layout Itemize
5321 value: Last reported value for control
5322 \end_layout
5324 \begin_deeper
5325 \begin_layout Itemize
5326 For keys: 1 for pressed, 0 for released.
5327 \end_layout
5329 \begin_layout Itemize
5330 For axes: -32767...32767.
5331 \end_layout
5333 \begin_layout Itemize
5334 For presure-sensitive buttons: 0...32767.
5335 \end_layout
5337 \begin_layout Itemize
5338 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
5339 \end_layout
5341 \begin_layout Itemize
5342 For mouse: Coordinates relative to game area.
5343 \end_layout
5345 \end_deeper
5346 \begin_layout Itemize
5347 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
5348 \end_layout
5350 \begin_layout Subsection
5351 input.keyhook: Hook a key
5352 \end_layout
5354 \begin_layout Itemize
5355 Syntax: none input.keyhook(string key, boolean state)
5356 \end_layout
5358 \begin_layout Standard
5359 Requests that keyhook events to be sent for key <key> (<state>=true) or
5360  not sent (<state>=false).
5361 \end_layout
5363 \begin_layout Subsection
5364 input.joyget: Get controls for controller
5365 \end_layout
5367 \begin_layout Itemize
5368 Syntax: table input.joyget(number logical)
5369 \end_layout
5371 \begin_layout Standard
5372 Returns table for current controls for specified logical controller <logical>.
5373  The names of fields vary by controller type.
5374 \end_layout
5376 \begin_layout Itemize
5377 The buttons have the same name as those are referred to in other contexts
5378  in the emulator
5379 \end_layout
5381 \begin_layout Itemize
5382 The analog axes are usually 
5383 \begin_inset Quotes eld
5384 \end_inset
5386 xaxis
5387 \begin_inset Quotes erd
5388 \end_inset
5390  and 
5391 \begin_inset Quotes eld
5392 \end_inset
5394 yaxis
5395 \begin_inset Quotes erd
5396 \end_inset
5399 \end_layout
5401 \begin_layout Itemize
5402 Each field is numeric or boolean depending on axis/button.
5403 \end_layout
5405 \begin_layout Subsection
5406 input.joyset: Set controls for controller
5407 \end_layout
5409 \begin_layout Itemize
5410 Syntax: none input.joyset(number controller, table controls)
5411 \end_layout
5413 \begin_layout Standard
5414 Set the the state of specified controller to values specified in specified
5415  table.
5416 \end_layout
5418 \begin_layout Itemize
5419 Each field can be boolean or number.
5420 \end_layout
5422 \begin_layout Itemize
5423 Also, buttons allow strings, which cause value to be inverted.
5424 \end_layout
5426 \begin_layout Subsection
5427 input.lcid_to_pcid: Look up logical controller (deprecated)
5428 \end_layout
5430 \begin_layout Itemize
5431 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
5432 \end_layout
5434 \begin_layout Standard
5435 Returns the legacy pcid for controller (or false if there isn't one), followed
5436  by pcid pair.
5437  Returns nothing if controller does not exist.
5438 \end_layout
5440 \begin_layout Standard
5441 \begin_inset Newpage pagebreak
5442 \end_inset
5445 \end_layout
5447 \begin_layout Section
5448 Table keyboard
5449 \end_layout
5451 \begin_layout Standard
5452 Various keybinding-related functions
5453 \end_layout
5455 \begin_layout Subsection
5456 keyboard.bind: Bind a key
5457 \end_layout
5459 \begin_layout Itemize
5460 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
5461 \end_layout
5463 \begin_layout Standard
5464 Bind specified key with specified modifers to specified command.
5465 \end_layout
5467 \begin_layout Subsection
5468 keyboard.unbind: Unbind a key
5469 \end_layout
5471 \begin_layout Itemize
5472 Syntax: none keyboard.unbind(string mod, string mask, string key)
5473 \end_layout
5475 \begin_layout Standard
5476 Unbind specified key with specified modifers.
5477 \end_layout
5479 \begin_layout Subsection
5480 keyboard.alias: Set alias expansion
5481 \end_layout
5483 \begin_layout Itemize
5484 Syntax: none keyboard.alias(string alias, string expansion)
5485 \end_layout
5487 \begin_layout Standard
5488 Set expansion of given command.
5489 \end_layout
5491 \begin_layout Standard
5492 \begin_inset Newpage pagebreak
5493 \end_inset
5496 \end_layout
5498 \begin_layout Section
5499 Table subtitle
5500 \end_layout
5502 \begin_layout Standard
5503 Subtitle handling
5504 \end_layout
5506 \begin_layout Subsection
5507 subtitle.byindex: Look up start and length of subtitle by index
5508 \end_layout
5510 \begin_layout Itemize
5511 Syntax: (number, number) subtitle.byindex(number i)
5512 \end_layout
5514 \begin_layout Standard
5515 Read the frame and length of ith subtitle.
5516  Returns nothing if not present.
5517 \end_layout
5519 \begin_layout Subsection
5520 subtitle.set: Write a subtitle
5521 \end_layout
5523 \begin_layout Itemize
5524 Syntax: none subtitle.set(number f, number l, string txt)
5525 \end_layout
5527 \begin_layout Standard
5528 Set the text of subtitle.
5529 \end_layout
5531 \begin_layout Subsection
5532 subtitle.get: Read a subtitle
5533 \end_layout
5535 \begin_layout Itemize
5536 Syntax: string subtitle.get(number f, number l)
5537 \end_layout
5539 \begin_layout Standard
5540 Get the text of subtitle.
5541 \end_layout
5543 \begin_layout Subsection
5544 subtitle.delete: Delete a subtitle
5545 \end_layout
5547 \begin_layout Itemize
5548 Syntax: none subtitle.delete(number f, number l)
5549 \end_layout
5551 \begin_layout Standard
5552 Delete specified subtitle.
5553 \end_layout
5555 \begin_layout Standard
5556 \begin_inset Newpage pagebreak
5557 \end_inset
5560 \end_layout
5562 \begin_layout Section
5563 Table hostmemory
5564 \end_layout
5566 \begin_layout Standard
5567 Host memory handling (extra memory saved to savestates).
5568  Host memory starts empty.
5569 \end_layout
5571 \begin_layout Itemize
5572 Reads out of range return false.
5573 \end_layout
5575 \begin_layout Itemize
5576 Writes out of range extend the memory.
5577 \end_layout
5579 \begin_layout Subsection
5580 hostmemory.read: Read byte from host memory
5581 \end_layout
5583 \begin_layout Itemize
5584 Syntax: number hostmemory.read(number address)
5585 \end_layout
5587 \begin_layout Standard
5588 Reads byte from hostmemory slot address <address>.
5589 \end_layout
5591 \begin_layout Subsection
5592 hostmemory.write: Write byte to host memory
5593 \end_layout
5595 \begin_layout Itemize
5596 Syntax: none hostmemory.write(number address, number value)
5597 \end_layout
5599 \begin_layout Standard
5600 Writes hostmemory slot with value <value> 0-255.
5601 \end_layout
5603 \begin_layout Subsection
5604 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
5605 \end_layout
5607 \begin_layout Itemize
5608 Syntax: number hostmemory.readbyte(number address)
5609 \end_layout
5611 \begin_layout Itemize
5612 Syntax: number hostmemory.readsbyte(number address)
5613 \end_layout
5615 \begin_layout Itemize
5616 Syntax: number hostmemory.readword(number address)
5617 \end_layout
5619 \begin_layout Itemize
5620 Syntax: number hostmemory.readsword(number address)
5621 \end_layout
5623 \begin_layout Itemize
5624 Syntax: number hostmemory.readhword(number address)
5625 \end_layout
5627 \begin_layout Itemize
5628 Syntax: number hostmemory.readshword(number address)
5629 \end_layout
5631 \begin_layout Itemize
5632 Syntax: number hostmemory.readdword(number address)
5633 \end_layout
5635 \begin_layout Itemize
5636 Syntax: number hostmemory.readsdword(number address)
5637 \end_layout
5639 \begin_layout Itemize
5640 Syntax: number hostmemory.readqword(number address)
5641 \end_layout
5643 \begin_layout Itemize
5644 Syntax: number hostmemory.readsqword(number address)
5645 \end_layout
5647 \begin_layout Standard
5648 Read elements (big-endian) from given address <address>.
5649 \end_layout
5651 \begin_layout Itemize
5652 byte is 1 element
5653 \end_layout
5655 \begin_layout Itemize
5656 word is 2 elements
5657 \end_layout
5659 \begin_layout Itemize
5660 hword is 3 elements
5661 \end_layout
5663 \begin_layout Itemize
5664 dword is 4 elements
5665 \end_layout
5667 \begin_layout Itemize
5668 qword is 8 elements.
5669 \end_layout
5671 \begin_layout Itemize
5672 The 's' variants do signed read.
5673 \end_layout
5675 \begin_layout Subsection
5676 hostmemory.read{float,double}: Read from host memory
5677 \end_layout
5679 \begin_layout Itemize
5680 syntax: number hostmemory.readfloat(number address)
5681 \end_layout
5683 \begin_layout Itemize
5684 Syntax: number hostmemory.readdouble(number address)
5685 \end_layout
5687 \begin_layout Standard
5688 Read elements (big-endian) floating-pont from given address <address>.
5689 \end_layout
5691 \begin_layout Subsection
5692 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
5693 \end_layout
5695 \begin_layout Itemize
5696 Syntax: number hostmemory.writebyte(number address, number value)
5697 \end_layout
5699 \begin_layout Itemize
5700 Syntax: number hostmemory.writesbyte(number address, number value)
5701 \end_layout
5703 \begin_layout Itemize
5704 Syntax: number hostmemory.writeword(number address, number value)
5705 \end_layout
5707 \begin_layout Itemize
5708 Syntax: number hostmemory.writesword(number address, number value)
5709 \end_layout
5711 \begin_layout Itemize
5712 Syntax: number hostmemory.writehword(number address, number value)
5713 \end_layout
5715 \begin_layout Itemize
5716 Syntax: number hostmemory.writeshword(number address, number value)
5717 \end_layout
5719 \begin_layout Itemize
5720 Syntax: number hostmemory.writedword(number address, number value)
5721 \end_layout
5723 \begin_layout Itemize
5724 Syntax: number hostmemory.writesdword(number address, number value)
5725 \end_layout
5727 \begin_layout Itemize
5728 Syntax: number hostmemory.writeqword(number address, number value)
5729 \end_layout
5731 \begin_layout Itemize
5732 Syntax: number hostmemory.writesqword(number address, number value)
5733 \end_layout
5735 \begin_layout Standard
5736 Write value <value> to elements (little-endian) starting from given address
5737  <address>.
5738 \end_layout
5740 \begin_layout Itemize
5741 byte is 1 element
5742 \end_layout
5744 \begin_layout Itemize
5745 word is 2 elements
5746 \end_layout
5748 \begin_layout Itemize
5749 hword is 3 elements
5750 \end_layout
5752 \begin_layout Itemize
5753 dword is 4 elements
5754 \end_layout
5756 \begin_layout Itemize
5757 qword is 8 elements.
5758 \end_layout
5760 \begin_layout Itemize
5761 The 's' variants do signed write.
5762 \end_layout
5764 \begin_layout Subsection
5765 hostmemory.write{float,double}: Write to host memory
5766 \end_layout
5768 \begin_layout Itemize
5769 syntax: none hostmemory.readfloat(number address, number value)
5770 \end_layout
5772 \begin_layout Itemize
5773 Syntax: none hostmemory.readdouble(number address, number value)
5774 \end_layout
5776 \begin_layout Standard
5777 Write elements (big-endian) floating-pont to given address <address>, storing
5778  <value>.
5779 \end_layout
5781 \begin_layout Standard
5782 \begin_inset Newpage pagebreak
5783 \end_inset
5786 \end_layout
5788 \begin_layout Section
5789 Table movie
5790 \end_layout
5792 \begin_layout Standard
5793 Movie handling
5794 \end_layout
5796 \begin_layout Subsection
5797 movie.currentframe: Get current frame number
5798 \end_layout
5800 \begin_layout Itemize
5801 Syntax: number movie.currentframe()
5802 \end_layout
5804 \begin_layout Standard
5805 Return number of current frame.
5806 \end_layout
5808 \begin_layout Subsection
5809 movie.framecount: Get move frame count
5810 \end_layout
5812 \begin_layout Itemize
5813 Syntax: number movie.framecount()
5814 \end_layout
5816 \begin_layout Standard
5817 Return number of frames in movie.
5818 \end_layout
5820 \begin_layout Subsection
5821 movie.lagcount: Get current lag count
5822 \end_layout
5824 \begin_layout Itemize
5825 Syntax: number movie.lagcount()
5826 \end_layout
5828 \begin_layout Standard
5829 Return number of lag frames recorded so far.
5830 \end_layout
5832 \begin_layout Subsection
5833 movie.readonly: Is in readonly mode?
5834 \end_layout
5836 \begin_layout Itemize
5837 Syntax: boolean movie.readonly()
5838 \end_layout
5840 \begin_layout Standard
5841 Return true if in readonly mode, false if in readwrite.
5842 \end_layout
5844 \begin_layout Subsection
5845 movie.rerecords: Movie rerecord count
5846 \end_layout
5848 \begin_layout Itemize
5849 Syntax: number movie.rerecords()
5850 \end_layout
5852 \begin_layout Standard
5853 Returns the current value of rerecord count.
5854 \end_layout
5856 \begin_layout Subsection
5857 movie.set_readwrite: Set read-write mode.
5858 \end_layout
5860 \begin_layout Itemize
5861 Syntax: none movie.set_readwrite()
5862 \end_layout
5864 \begin_layout Standard
5865 Set readwrite mode (does not cause on_readwrite callback).
5866 \end_layout
5868 \begin_layout Subsection
5869 movie.frame_subframes: Count subframes in frame
5870 \end_layout
5872 \begin_layout Itemize
5873 Syntax: number movie.frame_subframes(number frame)
5874 \end_layout
5876 \begin_layout Standard
5877 Count number of subframes in specified frame <frame> (frame numbers are
5878  1-based) and return that.
5879 \end_layout
5881 \begin_layout Subsection
5882 movie.read_subframes: Read subframe data (deprecated)
5883 \end_layout
5885 \begin_layout Itemize
5886 Syntax: table movie.read_subframes(number frame, number subframe)
5887 \end_layout
5889 \begin_layout Standard
5890 Read specifed subframe in specified frame and return data as array.
5891 \end_layout
5893 \begin_layout Subsection
5894 movie.read_rtc: Read current RTC time
5895 \end_layout
5897 \begin_layout Itemize
5898 Syntax: (number, number) movie.read_rtc()
5899 \end_layout
5901 \begin_layout Standard
5902 Returns the current value of the RTC as a pair (second, subsecond).
5903 \end_layout
5905 \begin_layout Subsection
5906 movie.unsafe_rewind: Fast movie rewind to saved state
5907 \end_layout
5909 \begin_layout Itemize
5910 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
5911 \end_layout
5913 \begin_layout Standard
5914 Start setting point for unsafe rewind or jump to point of unsafe rewind.
5915 \end_layout
5917 \begin_layout Itemize
5918 If called without argument, causes emulator to start process of setting
5919  unsafe rewind point.
5920  When this has finished, callback on_set_rewind occurs, passing the rewind
5921  state to lua script.
5922 \end_layout
5924 \begin_layout Itemize
5925 If called with argument, causes emulator rewind to passed rewind point as
5926  soon as possible.
5927  Readwrite mode is implicitly activated.
5928 \end_layout
5930 \begin_layout Standard
5931 The following warnings apply to unsafe rewinding:
5932 \end_layout
5934 \begin_layout Itemize
5935 There are no safety checks against misuse (that's what 
5936 \begin_inset Quotes eld
5937 \end_inset
5939 unsafe
5940 \begin_inset Quotes erd
5941 \end_inset
5943  comes from)!
5944 \end_layout
5946 \begin_layout Itemize
5947 Only call rewind from timeline rewind point was set from.
5948 \end_layout
5950 \begin_layout Itemize
5951 Only call rewind from after the rewind point was set.
5952 \end_layout
5954 \begin_layout Subsection
5955 movie.to_rewind: Load savestate as rewind point
5956 \end_layout
5958 \begin_layout Itemize
5959 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
5960 \end_layout
5962 \begin_layout Standard
5963 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
5964  corresponding to it.
5965 \end_layout
5967 \begin_layout Itemize
5968 Note: This operation does not take emulated time.
5969 \end_layout
5971 \begin_layout Subsection
5972 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
5973 \end_layout
5975 \begin_layout Itemize
5976 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
5977 \end_layout
5979 \begin_layout Itemize
5980 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
5981 \end_layout
5983 \begin_layout Standard
5984 Copies specified movie or branch <movie>/current object (if none or nil,
5985  the active movie) as new movie object.
5986 \end_layout
5988 \begin_layout Subsection
5989 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
5990 \end_layout
5992 \begin_layout Itemize
5993 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
5994 \end_layout
5996 \begin_layout Itemize
5997 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
5998 \end_layout
6000 \begin_layout Standard
6001 Get INPUTFRAME object corresponding to specified frame in specified movie
6002  or branch.
6003 \end_layout
6005 \begin_layout Subsection
6006 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6007 \end_layout
6009 \begin_layout Itemize
6010 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6011  data)
6012 \end_layout
6014 \begin_layout Itemize
6015 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6016 \end_layout
6018 \begin_layout Standard
6019 Set data in specified frame.
6020 \end_layout
6022 \begin_layout Itemize
6023 Note: Past can't be edited in active movie.
6024 \end_layout
6026 \begin_layout Subsection
6027 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6028 \end_layout
6030 \begin_layout Itemize
6031 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6032 \end_layout
6034 \begin_layout Itemize
6035 Syntax: integer INPUTMOVIE::get_size()
6036 \end_layout
6038 \begin_layout Standard
6039 Return number of subframes in specified movie or branch.
6040 \end_layout
6042 \begin_layout Subsection
6043 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6044 \end_layout
6046 \begin_layout Itemize
6047 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6048 \end_layout
6050 \begin_layout Itemize
6051 Syntax: number INPUTMOVIE::count_frames()
6052 \end_layout
6054 \begin_layout Standard
6055 Return number of frames in movie.
6056 \end_layout
6058 \begin_layout Subsection
6059 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6060 \end_layout
6062 \begin_layout Itemize
6063 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6064 \end_layout
6066 \begin_layout Itemize
6067 Syntax: number INPUTMOVIE::find_frame(number frame)
6068 \end_layout
6070 \begin_layout Standard
6071 Returns starting subframe of given frame (frame numbers are 1-based).
6072  Returns -1 if frame number is bad.
6073 \end_layout
6075 \begin_layout Subsection
6076 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6077 \end_layout
6079 \begin_layout Itemize
6080 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6081 \end_layout
6083 \begin_layout Itemize
6084 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6085 \end_layout
6087 \begin_layout Standard
6088 Return blank INPUTFRAME with frame type from specified movie.
6089 \end_layout
6091 \begin_layout Subsection
6092 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6093 \end_layout
6095 \begin_layout Itemize
6096 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6097 \end_layout
6099 \begin_layout Itemize
6100 Syntax: none INPUTMOVIE::append_frames(number frames)
6101 \end_layout
6103 \begin_layout Standard
6104 Append specified number <frames> of frames.
6105 \end_layout
6107 \begin_layout Subsection
6108 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
6109 \end_layout
6111 \begin_layout Itemize
6112 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
6113 \end_layout
6115 \begin_layout Itemize
6116 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
6117 \end_layout
6119 \begin_layout Standard
6120 Append specified frame <frame>.
6121  Past of current movie can't be edited.
6122 \end_layout
6124 \begin_layout Subsection
6125 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
6126 \end_layout
6128 \begin_layout Itemize
6129 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
6130 \end_layout
6132 \begin_layout Itemize
6133 Syntax: none INPUTMOVIE::truncate(number frames)
6134 \end_layout
6136 \begin_layout Standard
6137 Truncate the specified movie to specified number of frames.
6138 \end_layout
6140 \begin_layout Subsection
6141 movie.edit/INPUTMOVIE::edit: Edit a movie
6142 \end_layout
6144 \begin_layout Itemize
6145 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
6146  controller, number control, number/bool value)
6147 \end_layout
6149 \begin_layout Itemize
6150 Syntax: none movie.edit(string branch, number frame, number port, number
6151  controller, number control, number/bool value)
6152 \end_layout
6154 \begin_layout Itemize
6155 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
6156  number control, number/bool value)
6157 \end_layout
6159 \begin_layout Standard
6160 Change specified control in specified frame in specified movie.
6161  Past can't be edited in active movie.
6162 \end_layout
6164 \begin_layout Subsection
6165 movie.copy_frames2: Copy frames between movies
6166 \end_layout
6168 \begin_layout Itemize
6169 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
6170 IE/string srcmov,] number src, number count)
6171 \end_layout
6173 \begin_layout Standard
6174 Copy specified number of frames between two movies.
6175  The copy proceeeds in forward direction.
6176 \end_layout
6178 \begin_layout Subsection
6179 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
6180 \end_layout
6182 \begin_layout Itemize
6183 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
6184  src, number count, bool backwards)
6185 \end_layout
6187 \begin_layout Itemize
6188 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
6189  bool backwards)
6190 \end_layout
6192 \begin_layout Standard
6193 Copy specified number of frames from one point in movie to another.
6194  If backwards is true, the copy will be done backwards.
6195 \end_layout
6197 \begin_layout Subsection
6198 movie.serialize/INPUTMOVIE::serialize: Serialize movie
6199 \end_layout
6201 \begin_layout Itemize
6202 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
6203  bool binary)
6204 \end_layout
6206 \begin_layout Itemize
6207 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
6208 \end_layout
6210 \begin_layout Standard
6211 Serialize given movie into file.
6212  If binary is true, binary format (more compact and much faster) is used.
6213 \end_layout
6215 \begin_layout Subsection
6216 movie.unserialize: Unserialize movie
6217 \end_layout
6219 \begin_layout Itemize
6220 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
6221  bool binary)
6222 \end_layout
6224 \begin_layout Standard
6225 Unserialize movie from file.
6226  The given frame is used as template to decide the frame type.
6227  If binary is true, binary format is decoded (much faster).
6228 \end_layout
6230 \begin_layout Subsection
6231 movie.current_first_subframe: Return first subframe in current frame
6232 \end_layout
6234 \begin_layout Itemize
6235 Syntax: number movie.current_first_subframe()
6236 \end_layout
6238 \begin_layout Standard
6239 Returns first subframe in current frame.
6240 \end_layout
6242 \begin_layout Subsection
6243 movie.pollcounter: Return poll counter for speified control
6244 \end_layout
6246 \begin_layout Itemize
6247 Syntax: number movie.pollcounter(number port, number controller, number control)
6248 \end_layout
6250 \begin_layout Standard
6251 Returns number of times the specified control has been polled this frame.
6252 \end_layout
6254 \begin_layout Subsection
6255 movie.current_branch: Return current branch
6256 \end_layout
6258 \begin_layout Itemize
6259 Syntax: string movie.current_branch()
6260 \end_layout
6262 \begin_layout Standard
6263 Returns the name of the current branch.
6264 \end_layout
6266 \begin_layout Subsection
6267 movie.get_branches: Return names of all branches
6268 \end_layout
6270 \begin_layout Itemize
6271 Syntax: string...
6272  movie.get_branches()
6273 \end_layout
6275 \begin_layout Standard
6276 Returns the name of all branches.
6277 \end_layout
6279 \begin_layout Subsection
6280 INPUTFRAME::get_button: Get button
6281 \end_layout
6283 \begin_layout Itemize
6284 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
6285  control)
6286 \end_layout
6288 \begin_layout Standard
6289 Returns state of given button as boolean.
6290 \end_layout
6292 \begin_layout Subsection
6293 INPUTFRAME::get_axis: Get axis
6294 \end_layout
6296 \begin_layout Itemize
6297 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
6298  control)
6299 \end_layout
6301 \begin_layout Standard
6302 Returns state of given axis as number.
6303 \end_layout
6305 \begin_layout Subsection
6306 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
6307 \end_layout
6309 \begin_layout Itemize
6310 Syntax: none INPUTFRAME::set_button(number port, number controller, number
6311  control, number/bool value)
6312 \end_layout
6314 \begin_layout Itemize
6315 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
6316  control)
6317 \end_layout
6319 \begin_layout Standard
6320 Set the given button/axis to given value.
6321 \end_layout
6323 \begin_layout Subsection
6324 INPUTFRAME::serialize: Serialize a frame
6325 \end_layout
6327 \begin_layout Itemize
6328 Syntax: string INPUTFRAME::serialize()
6329 \end_layout
6331 \begin_layout Standard
6332 Return string representation of frame.
6333 \end_layout
6335 \begin_layout Subsection
6336 INPUTFRAME::unserialize: Unserialize a frame
6337 \end_layout
6339 \begin_layout Itemize
6340 Syntax: none INPUTFRAME::unserialize(string data)
6341 \end_layout
6343 \begin_layout Standard
6344 Set current frame from given data.
6345 \end_layout
6347 \begin_layout Subsection
6348 INPUTFRAME::get_stride: Get movie stride
6349 \end_layout
6351 \begin_layout Itemize
6352 Syntax: number INPUTFRAME::get_stride()
6353 \end_layout
6355 \begin_layout Standard
6356 Return number of bytes needed to store the input frame.
6357  Mainly useful for some debugging.
6358 \end_layout
6360 \begin_layout Standard
6361 \begin_inset Newpage pagebreak
6362 \end_inset
6365 \end_layout
6367 \begin_layout Section
6368 Table settings
6369 \end_layout
6371 \begin_layout Standard
6372 Routines for settings manipulation
6373 \end_layout
6375 \begin_layout Subsection
6376 settings.get: Get value of setting
6377 \end_layout
6379 \begin_layout Itemize
6380 Syntax: string settings.get(string name)
6381 \end_layout
6383 \begin_layout Standard
6384 Get value of setting <name>.
6385  If setting value can't be obtained, returns (nil, error message).
6386 \end_layout
6388 \begin_layout Subsection
6389 settings.set: Set value of setting
6390 \end_layout
6392 \begin_layout Itemize
6393 Syntax: none settings.set(string name, string value)
6394 \end_layout
6396 \begin_layout Standard
6397 Set value <value> of setting <name>.
6398  If setting can't be set, returns (nil, error message).
6399 \end_layout
6401 \begin_layout Standard
6402 \begin_inset Newpage pagebreak
6403 \end_inset
6406 \end_layout
6408 \begin_layout Section
6409 Table memory
6410 \end_layout
6412 \begin_layout Standard
6413 Contains various functions for managing memory
6414 \end_layout
6416 \begin_layout Subsection
6417 memory.vma_count: Count number of memory areas.
6418 \end_layout
6420 \begin_layout Itemize
6421 Syntax: number memory.vma_count()
6422 \end_layout
6424 \begin_layout Standard
6425 Returns the number of memory areas
6426 \end_layout
6428 \begin_layout Subsection
6429 memory.read_vma: Lookup memory area info by index
6430 \end_layout
6432 \begin_layout Itemize
6433 Syntax: table memory.read_vma(number index)
6434 \end_layout
6436 \begin_layout Standard
6437 Reads the specified memory area (indices start from zero).
6438  Trying to read invalid memory area gives nil.
6439  The return value is table with the following fields:
6440 \end_layout
6442 \begin_layout Itemize
6443 region_name (string): The readable name of the memory area
6444 \end_layout
6446 \begin_layout Itemize
6447 baseaddr (number): Base address of the memory area
6448 \end_layout
6450 \begin_layout Itemize
6451 lastaddr (number): Last address in the memory area.
6452 \end_layout
6454 \begin_layout Itemize
6455 size (number): The size of memory area in bytes.
6456 \end_layout
6458 \begin_layout Itemize
6459 readonly (boolean): True of the memory area corresponds to ROM.
6460 \end_layout
6462 \begin_layout Itemize
6463 iospace (boolean): True if the memory area is I/O space.
6464 \end_layout
6466 \begin_layout Itemize
6467 native_endian (boolean): True if the memory area has native endian as opposed
6468  to little endian.
6469 \end_layout
6471 \begin_layout Subsection
6472 memory.find_vma: Find memory area info by address
6473 \end_layout
6475 \begin_layout Itemize
6476 Syntax: table memory.find_vma(number address)
6477 \end_layout
6479 \begin_layout Standard
6480 Finds the memory area containing specified address.
6481  Returns table in the same format as read_vma or nil if not found.
6482 \end_layout
6484 \begin_layout Subsection
6485 memory.read{,s}{byte,{,h,d,q}word}: Read memory
6486 \end_layout
6488 \begin_layout Itemize
6489 Syntax: none memory.readbyte([string marea, ]number address)
6490 \end_layout
6492 \begin_layout Itemize
6493 Syntax: none memory.readword([string marea, ]number address)
6494 \end_layout
6496 \begin_layout Itemize
6497 Syntax: none memory.readhword([string marea, ]number address)
6498 \end_layout
6500 \begin_layout Itemize
6501 Syntax: none memory.readdword([string marea, ]number address)
6502 \end_layout
6504 \begin_layout Itemize
6505 Syntax: none memory.readqword([string marea, ]number address)
6506 \end_layout
6508 \begin_layout Itemize
6509 Syntax: none memory.readsbyte([string marea, ]number address)
6510 \end_layout
6512 \begin_layout Itemize
6513 Syntax: none memory.readsword([string marea, ]number address)
6514 \end_layout
6516 \begin_layout Itemize
6517 Syntax: none memory.readshword([string marea, ]number address)
6518 \end_layout
6520 \begin_layout Itemize
6521 Syntax: none memory.readsdword([string marea, ]number address)
6522 \end_layout
6524 \begin_layout Itemize
6525 Syntax: none memory.readsqword([string marea, ]number address)
6526 \end_layout
6528 \begin_layout Standard
6529 Reads the specified address <address> (if 's' variant is used, do undergo
6530  2's complement).
6531 \end_layout
6533 \begin_layout Subsection
6534 memory.{,s}read_sg: Scatter/Gather read memory
6535 \end_layout
6537 \begin_layout Itemize
6538 Syntax: none memory.read_sg(string/boolean/number...)
6539 \end_layout
6541 \begin_layout Itemize
6542 Syntax: none memory.sread_sg(string/boolean/number...)
6543 \end_layout
6545 \begin_layout Standard
6546 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
6547  of memory.
6548  Each argument can be string, boolean or number:
6549 \end_layout
6551 \begin_layout Itemize
6552 String: Set memory area addresses are relative to (e.g.
6553  'WRAM').
6554 \end_layout
6556 \begin_layout Itemize
6557 boolean: If true, increment relative address by 1, if false, decrement by
6558  1.
6559  The new address is read as next higher byte.
6560 \end_layout
6562 \begin_layout Itemize
6563 integer: Set the relative address to specified value and read the address
6564  as next higher byte.
6565 \end_layout
6567 \begin_layout Subsection
6568 memory.write_sg: Scatter/Gather write memory
6569 \end_layout
6571 \begin_layout Itemize
6572 Syntax: none memory.write_sg(number value, string/boolean/number...)
6573 \end_layout
6575 \begin_layout Standard
6576 Perform scatter/gather write of value <value> on memory.
6577  Each argument can be string, boolean or number:
6578 \end_layout
6580 \begin_layout Itemize
6581 String: Set memory area addresses are relative to (e.g.
6582  'WRAM').
6583 \end_layout
6585 \begin_layout Itemize
6586 boolean: If true, increment relative address by 1, if false, decrement by
6587  1.
6588  The new address is read as next higher byte.
6589 \end_layout
6591 \begin_layout Itemize
6592 integer: Set the relative address to specified value and read the address
6593  as next higher byte.
6594 \end_layout
6596 \begin_layout Subsection
6597 memory.read{float,double}: Read memory
6598 \end_layout
6600 \begin_layout Itemize
6601 Syntax: none memory.readfloat([string marea, ]number address)
6602 \end_layout
6604 \begin_layout Itemize
6605 Syntax: none memory.readdouble([string marea, ]number address)
6606 \end_layout
6608 \begin_layout Standard
6609 Reads the specified address <address>
6610 \end_layout
6612 \begin_layout Subsection
6613 memory.write{byte,{,h,d,q}word,float,double}: Write memory
6614 \end_layout
6616 \begin_layout Itemize
6617 Syntax: none memory.writebyte([string marea, ]number address, number value)
6618 \end_layout
6620 \begin_layout Itemize
6621 Syntax: none memory.writeword([string marea, ]number address, number value)
6622 \end_layout
6624 \begin_layout Itemize
6625 Syntax: none memory.writehword([string marea, ]number address, number value)
6626 \end_layout
6628 \begin_layout Itemize
6629 Syntax: none memory.writedword([string marea, ]number address, number value)
6630 \end_layout
6632 \begin_layout Itemize
6633 Syntax: none memory.writeqword([string marea, ]number address, number value)
6634 \end_layout
6636 \begin_layout Itemize
6637 Syntax: none memory.writefloat([string marea, ]number address, number value)
6638 \end_layout
6640 \begin_layout Itemize
6641 Syntax: none memory.writedouble([string marea, ]number address, number value)
6642 \end_layout
6644 \begin_layout Standard
6645 Writes the specified value <value> (negative integer values undergo 2's
6646  complement) to specified address <address>.
6647 \end_layout
6649 \begin_layout Subsection
6650 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
6651 \end_layout
6653 \begin_layout Itemize
6654 Syntax: userdata memory.map<type>([[string marea, ]number base, number size])
6655 \end_layout
6657 \begin_layout Standard
6658 Returns a table mapping specified memory aperture for read/write.
6659  If parameters are omitted, entiere map space is the aperture.
6660 \end_layout
6662 \begin_layout Itemize
6663 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
6664  qword, sqword, float or double.
6665 \end_layout
6667 \begin_layout Subsection
6668 memory.hash_region: Hash region of memory
6669 \end_layout
6671 \begin_layout Itemize
6672 Syntax: string memory.hash_region([string marea, ]number base, number size)
6673 \end_layout
6675 \begin_layout Standard
6676 Hash <size> bytes starting from address <base> (relative to <marea>) and
6677  return the SHA-256.
6678 \end_layout
6680 \begin_layout Subsection
6681 memory.hash_region2: Hash region of memory
6682 \end_layout
6684 \begin_layout Itemize
6685 Syntax: string memory.hash_region2([string marea, ]number base, number size[,
6686  number rows, number stride])
6687 \end_layout
6689 \begin_layout Standard
6690 Hash <rows> blocks of <size> bytes starting from address <base> (relative
6691  to <marea>).
6692  The blocks are offset by <stride> from one another and return the SHA-256.
6693 \end_layout
6695 \begin_layout Subsection
6696 memory.hash_region_skein: Hash region of memory
6697 \end_layout
6699 \begin_layout Itemize
6700 Syntax: string memory.hash_region_skein([string marea, ]number base, number
6701  size[, number rows, number stride])
6702 \end_layout
6704 \begin_layout Standard
6705 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
6706  finalists) as hash function.
6707 \end_layout
6709 \begin_layout Subsection
6710 memory.store: Store region of memory
6711 \end_layout
6713 \begin_layout Itemize
6714 Syntax: none memory.store([string marea, ]number addr, number daddr[, number
6715  rows, number stride]
6716 \end_layout
6718 \begin_layout Standard
6719 Copy memory starting from <addr> in memory area <marea> (each row being
6720  of size <size>, there being <rows> rows, and rows being separated by <stride>
6721  in memory) into savestate-saved memory area, starting from <daadr> (all
6722  rows are written back to back).
6723 \end_layout
6725 \begin_layout Subsection
6726 memory.storecmp: Compare and store region of memory
6727 \end_layout
6729 \begin_layout Itemize
6730 Syntax: bool memory.storecmp([string marea, ]number addr, number daddr[,
6731  number rows, number stride]
6732 \end_layout
6734 \begin_layout Standard
6735 Like memory.store, but returns true if target of copy already held the value
6736  that would be copied before the copy happened.
6737  Otherwise returns false (if target and source differ before copy).
6738 \end_layout
6740 \begin_layout Subsection
6741 memory.hash_state: Hash system state
6742 \end_layout
6744 \begin_layout Itemize
6745 Syntax: string memory.hash_state()
6746 \end_layout
6748 \begin_layout Standard
6749 Hash the current system state.
6750  Mainly useful for debugging savestates.
6751 \end_layout
6753 \begin_layout Subsection
6754 memory.readregion: Read region of memory
6755 \end_layout
6757 \begin_layout Itemize
6758 Syntax: table memory.readregion([string marea, ]number base, number size)
6759 \end_layout
6761 \begin_layout Standard
6762 Read a region of memory.
6763 \end_layout
6765 \begin_layout Itemize
6766 Warning: If the region crosses memory area boundary, the results are undefined.
6767 \end_layout
6769 \begin_layout Subsection
6770 memory.writeregion: Write region of memory
6771 \end_layout
6773 \begin_layout Itemize
6774 Syntax: none memory.writeregion([string marea, ]number base, number size,
6775  table data)
6776 \end_layout
6778 \begin_layout Standard
6779 Write a region of memory.
6780 \end_layout
6782 \begin_layout Itemize
6783 Warning: If the region crosses memory area boundary, the results are undefined.
6784 \end_layout
6786 \begin_layout Subsection
6787 memory.action: Run core action
6788 \end_layout
6790 \begin_layout Itemize
6791 memory.action(string action, [<params>])
6792 \end_layout
6794 \begin_layout Standard
6795 Run core action.
6796  The different models expect parameters as:
6797 \end_layout
6799 \begin_layout Itemize
6800 string: String
6801 \end_layout
6803 \begin_layout Itemize
6804 numeric: numeric
6805 \end_layout
6807 \begin_layout Itemize
6808 enumeration: String
6809 \end_layout
6811 \begin_layout Itemize
6812 boolean: String
6813 \end_layout
6815 \begin_layout Itemize
6816 toggle: None.
6817 \end_layout
6819 \begin_layout Subsection
6820 memory.get_lag_flag: Get lag flag
6821 \end_layout
6823 \begin_layout Itemize
6824 Syntax: boolean memory.get_lag_flag()
6825 \end_layout
6827 \begin_layout Standard
6828 Get the value of core lag flag.
6829  True if this frame has been lag so far, false if poll has been detected.
6830 \end_layout
6832 \begin_layout Subsection
6833 memory.set_lag_flag: Set lag flag
6834 \end_layout
6836 \begin_layout Itemize
6837 Syntax: none memory.set_lag_flag(boolean flag)
6838 \end_layout
6840 \begin_layout Standard
6841 Set the value of core lag flag.
6842  This flag automatically gets cleared if poll is detected, but can be forcibly
6843  set or cleared if game so requires.
6844 \end_layout
6846 \begin_layout Itemize
6847 Should only be used in on_frame_emulated callback.
6848 \end_layout
6850 \begin_layout Itemize
6851 Setting or clearing this affects the emulator lag counter.
6852 \end_layout
6854 \begin_layout Subsection
6855 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
6856  callback
6857 \end_layout
6859 \begin_layout Itemize
6860 Syntax: function memory.registerread([string marea, ] number addr, function
6861  fn);
6862 \end_layout
6864 \begin_layout Itemize
6865 Syntax: function memory.registerwrite([string marea, ] number addr, function
6866  fn);
6867 \end_layout
6869 \begin_layout Itemize
6870 Syntax: function memory.registerexec([string marea, ] number addr, function
6871  fn);
6872 \end_layout
6874 \begin_layout Itemize
6875 Syntax: none memory.unregisterread([string marea, ] number addr, function
6876  fn);
6877 \end_layout
6879 \begin_layout Itemize
6880 Syntax: none memory.unregisterwrite([string marea, ] number addr, function
6881  fn);
6882 \end_layout
6884 \begin_layout Itemize
6885 Syntax: none memory.unregisterexec([string marea, ] number addr, function
6886  fn);
6887 \end_layout
6889 \begin_layout Standard
6890 Add or remove callback on memory read, write or execute (depending on the
6891  function).
6892  If <marea> is specified, <addr> is relative to it, otherwise <addr> is
6893  global.
6894  <fn> is the callback.
6895  The register* functions return <fn> (which can then be passed to unregister*
6896  functions.
6897 \end_layout
6899 \begin_layout Itemize
6900 Not all cores support this, and it may be unsupported for some memory areas.
6901 \end_layout
6903 \begin_layout Itemize
6904 The functions are passed two parameters: Address and value.
6905 \end_layout
6907 \begin_layout Subsection
6908 memory.{,un}registertrace: Set/Clear trace hook
6909 \end_layout
6911 \begin_layout Itemize
6912 Syntax: function memory.registertrace(number processor, function fn);
6913 \end_layout
6915 \begin_layout Itemize
6916 Syntax: none memory.unregistertrace(number processor, function fn);
6917 \end_layout
6919 \begin_layout Standard
6920 Add or remove trace callback.
6921  <processor> is system-dependent processor number (0 is usually main CPU).
6922  The function arguments work like in other (un)register* functions.
6923 \end_layout
6925 \begin_layout Itemize
6926 The functions are passed two parameters: Trace CPU and Trace event string.
6927 \end_layout
6929 \begin_layout Subsection
6930 memory.cheat: Set cheat
6931 \end_layout
6933 \begin_layout Itemize
6934 Syntax: none memory.cheat([string marea, ] number addr, number value);
6935 \end_layout
6937 \begin_layout Itemize
6938 Syntax: none memory.cheat([string marea, ] number addr);
6939 \end_layout
6941 \begin_layout Standard
6942 Set or clear cheat (value <value>) on address <addr>.
6943  If <marea> is specified, <addr> is relative to that.
6944  If <value> is not speicified, clear a cheat.
6945 \end_layout
6947 \begin_layout Itemize
6948 Not all cores support this, and it may be unsupported for some memory areas.
6949 \end_layout
6951 \begin_layout Subsection
6952 memory.setxmask: Set global execute hook mask
6953 \end_layout
6955 \begin_layout Itemize
6956 Syntax: none memory.setxmask(number mask)
6957 \end_layout
6959 \begin_layout Standard
6960 Set the global execute hook mask to <mask>.
6961  The meaning of each bit is system-dependent, but bit 0 should be the main
6962  CPU.
6963 \end_layout
6965 \begin_layout Subsection
6966 memory.mmap: Class MMAP_STRUCT
6967 \end_layout
6969 \begin_layout Standard
6970 See class MMAP_STRUCT
6971 \end_layout
6973 \begin_layout Standard
6974 \begin_inset Newpage pagebreak
6975 \end_inset
6978 \end_layout
6980 \begin_layout Section
6981 Table memory2
6982 \end_layout
6984 \begin_layout Standard
6985 Contains newer memory functions.
6986 \end_layout
6988 \begin_layout Subsection
6989 memory2(): Get all memory area names.
6990 \end_layout
6992 \begin_layout Itemize
6993 Syntax: table memory2()
6994 \end_layout
6996 \begin_layout Standard
6997 Returns array of all valid memory area names.
6998 \end_layout
7000 \begin_layout Subsection
7001 memory2.<marea>:info: Get memory area info
7002 \end_layout
7004 \begin_layout Itemize
7005 Syntax: table memory2.<marea>:info()
7006 \end_layout
7008 \begin_layout Standard
7009 Return table describing given memory area.
7010  Includes fields address, size, last, readonly, special and endian.
7011 \end_layout
7013 \begin_layout Subsection
7014 memory2.<marea>:<op>: Read/Write memory
7015 \end_layout
7017 \begin_layout Itemize
7018 Syntax: none memory2.<marea>:<op>(number offset, number value)
7019 \end_layout
7021 \begin_layout Itemize
7022 Syntax: number memory2.<marea>:<op>(number offset)
7023 \end_layout
7025 \begin_layout Standard
7026 Read/Write value from/to given memory area <marea> at given offset <offset>
7027  (must be in-range).
7028  The value written is <value>.
7029  <Op> is of form: [i][s]<type>, where:
7030 \end_layout
7032 \begin_layout Itemize
7033 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
7034 \end_layout
7036 \begin_layout Itemize
7037 'i' signifies that the value is treated as opposite-to-normal endianess,
7038 \end_layout
7040 \begin_layout Itemize
7041 's' signifies that value is treated as signed (not available for floating-point).
7042 \end_layout
7044 \begin_layout Subsection
7045 memory2.<marea>:read: Scatter-gather value read
7046 \end_layout
7048 \begin_layout Itemize
7049 Syntax: number memory2.<marea>:read(number addr...)
7050 \end_layout
7052 \begin_layout Standard
7053 Read value from given memory area <marea> at byte offsets <addr>..., given
7054  in order of increasing significance.
7055  Value of true and false are special.
7056  True increments address by 1, and false decrements address by 1.
7057 \end_layout
7059 \begin_layout Subsection
7060 memory2.<marea>:sread: Signed scatter-gather value read
7061 \end_layout
7063 \begin_layout Itemize
7064 Syntax: number memory2.<marea>:sread(number addr...)
7065 \end_layout
7067 \begin_layout Standard
7068 Like memory2.<marea>:read, but reads signed values.
7069 \end_layout
7071 \begin_layout Subsection
7072 memory2.<marea>:write: Scatter-gather value write
7073 \end_layout
7075 \begin_layout Itemize
7076 Syntax: number memory2.<marea>:write(number val, number addr...)
7077 \end_layout
7079 \begin_layout Standard
7080 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
7081  in order of increasing significance.
7082  Value of true and false are special.
7083  True increments address by 1, and false decrements address by 1.
7084 \end_layout
7086 \begin_layout Subsection
7087 memory2.<marea>:cheat: Set/Clear cheat
7088 \end_layout
7090 \begin_layout Itemize
7091 Syntax: none memory2.<marea>:cheat(number addr, [number value])
7092 \end_layout
7094 \begin_layout Standard
7095 Set/Clear cheat at offset <addr> of memory area <marea>.
7096  If <value> is given, cheat with specified value is set.
7097  Otherwise cheat on address is removed.
7098 \end_layout
7100 \begin_layout Subsection
7101 memory2.<marea>:sha256: SHA-256
7102 \end_layout
7104 \begin_layout Itemize
7105 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
7106  number stride])
7107 \end_layout
7109 \begin_layout Standard
7110 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
7111  from offset <addr> of area <marea>.
7112  The chunks are separated by <stride>.
7113 \end_layout
7115 \begin_layout Subsection
7116 memory2.<marea>:skein: Skein-512-256
7117 \end_layout
7119 \begin_layout Itemize
7120 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
7121  number stride])
7122 \end_layout
7124 \begin_layout Standard
7125 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
7126 \end_layout
7128 \begin_layout Subsection
7129 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
7130 \end_layout
7132 \begin_layout Itemize
7133 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
7134  number rows, number stride])
7135 \end_layout
7137 \begin_layout Itemize
7138 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
7139  size[, number rows, number stride])
7140 \end_layout
7142 \begin_layout Standard
7143 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
7144  <addr> of area <marea>.
7145  The chunks are separated by <stride>.
7146  The target is Lua host memory, starting from offset <daddr>.
7147 \end_layout
7149 \begin_layout Standard
7150 Additionally, the storecmp method returns false if target was modified (otherwis
7151 e true).
7152 \end_layout
7154 \begin_layout Subsection
7155 memory2.<marea>:readregion: Read region
7156 \end_layout
7158 \begin_layout Itemize
7159 Syntax table memory2.<marea>:readregion(number addr, number size)
7160 \end_layout
7162 \begin_layout Standard
7163 Read <size> bytes starting from <addr> in <marea> and return as array.
7164 \end_layout
7166 \begin_layout Subsection
7167 memory2.<marea>:writeregion: Write region
7168 \end_layout
7170 \begin_layout Itemize
7171 Syntax none memory2.<marea>:writeregion(number addr, table data)
7172 \end_layout
7174 \begin_layout Standard
7175 Write array <data> to bytes starting from <addr> in <marea>.
7176 \end_layout
7178 \begin_layout Subsection
7179 memory2.<marea>:register{read,write,exec}: Register hook
7180 \end_layout
7182 \begin_layout Itemize
7183 Syntax: function memory2.<marea>:registerread(number addr, function fn);
7184 \end_layout
7186 \begin_layout Itemize
7187 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
7188 \end_layout
7190 \begin_layout Itemize
7191 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
7192 \end_layout
7194 \begin_layout Standard
7195 Register debug callback <fn> of specified type at offset <addr> of memory
7196  area <marea>.
7197  Returns <fn>.
7198 \end_layout
7200 \begin_layout Subsection
7201 memory2.<marea>:unregister{read,write,exec}: Unregister hook
7202 \end_layout
7204 \begin_layout Itemize
7205 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
7206 \end_layout
7208 \begin_layout Itemize
7209 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
7210 \end_layout
7212 \begin_layout Itemize
7213 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
7214 \end_layout
7216 \begin_layout Standard
7217 Unregister debug callback <fn> of specified type at offset <addr> of memory
7218  area <marea>.
7219 \end_layout
7221 \begin_layout Standard
7222 \begin_inset Newpage pagebreak
7223 \end_inset
7226 \end_layout
7228 \begin_layout Section
7229 Table random
7230 \end_layout
7232 \begin_layout Standard
7233 Contains random number generation methods.
7234  These functions do not return reproducable results.
7235 \end_layout
7237 \begin_layout Subsection
7238 random.boolean: Random boolean
7239 \end_layout
7241 \begin_layout Itemize
7242 Syntax: boolean random.boolean()
7243 \end_layout
7245 \begin_layout Standard
7246 Returns true or false at random (50-50 chance).
7247 \end_layout
7249 \begin_layout Subsection
7250 random.integer: Random integer
7251 \end_layout
7253 \begin_layout Itemize
7254 Syntax: number random.integer(number highplusone)
7255 \end_layout
7257 \begin_layout Itemize
7258 Syntax: number random.integer(number low, number high)
7259 \end_layout
7261 \begin_layout Standard
7262 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
7263  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
7264 \end_layout
7266 \begin_layout Standard
7267 The returned numbers are from uniform distribution.
7268 \end_layout
7270 \begin_layout Subsection
7271 random.float: Random float
7272 \end_layout
7274 \begin_layout Itemize
7275 Syntax: number random.float()
7276 \end_layout
7278 \begin_layout Standard
7279 Returns random decimal number [0,1).
7280 \end_layout
7282 \begin_layout Subsection
7283 random.among: Random parameter
7284 \end_layout
7286 \begin_layout Itemize
7287 Syntax: value random.among(value values...)
7288 \end_layout
7290 \begin_layout Standard
7291 Returns random parameter value, picked at uniform.
7292  Multiple equivalent values are returned with higher chance.
7293 \end_layout
7295 \begin_layout Subsection
7296 random.amongtable: Random from table
7297 \end_layout
7299 \begin_layout Itemize
7300 Syntax: value random.amongtable(table tab)
7301 \end_layout
7303 \begin_layout Standard
7304 Returns random value from table <tab>.
7305  As in random.among, no equality testing is done.
7306 \end_layout
7308 \begin_layout Standard
7309 \begin_inset Newpage pagebreak
7310 \end_inset
7313 \end_layout
7315 \begin_layout Section
7316 Table zip
7317 \end_layout
7319 \begin_layout Subsection
7320 zip.enumerate: Enumerate members in zipfile
7321 \end_layout
7323 \begin_layout Itemize
7324 Syntax: Table zip.enumerate(string filename[, boolean invert])
7325 \end_layout
7327 \begin_layout Standard
7328 Returns table of files in zip archive <filename>.
7329  If <invert> is true, instead of returning array of names, returns table
7330  with keys being member names and values being true.
7331 \end_layout
7333 \begin_layout Subsection
7334 zip.writer: Class ZIPWRITER
7335 \end_layout
7337 \begin_layout Standard
7338 See class ZIPWRITER.
7339 \end_layout
7341 \begin_layout Standard
7342 \begin_inset Newpage pagebreak
7343 \end_inset
7346 \end_layout
7348 \begin_layout Section
7349 Table callback
7350 \end_layout
7352 \begin_layout Standard
7353 Various callback-related functions.
7354 \end_layout
7356 \begin_layout Subsection
7357 \begin_inset CommandInset label
7358 LatexCommand label
7359 name "sub:callback.register:-Register-a"
7361 \end_inset
7363 callback.register: Register a callback
7364 \end_layout
7366 \begin_layout Itemize
7367 Syntax: function callback.register(string cbname, function cbfun);
7368 \end_layout
7370 \begin_layout Standard
7371 Instruct function <cbfun> to be added to list of callbacks to call on event
7372  <cbname> (See section 
7373 \begin_inset CommandInset ref
7374 LatexCommand ref
7375 reference "sec:Callbacks"
7377 \end_inset
7380  The callback name does not have the 'on_' prefix (e.g.
7382 \begin_inset Quotes eld
7383 \end_inset
7385 paint
7386 \begin_inset Quotes erd
7387 \end_inset
7390  Returns <cbfun>.
7391 \end_layout
7393 \begin_layout Subsection
7394 \begin_inset CommandInset label
7395 LatexCommand label
7396 name "sub:callback.unregister:-Unregister-"
7398 \end_inset
7400 callback.unregister: Unregister a callback
7401 \end_layout
7403 \begin_layout Itemize
7404 Syntax: function callback.unregister(string cbname, function cbfun);
7405 \end_layout
7407 \begin_layout Standard
7408 Instruct function <cbfun> to be removed from list of callbacks to call on
7409  event <cbname>.
7410 \end_layout
7412 \begin_layout Subsection
7413 callback.<cbname>:register: Register callback
7414 \end_layout
7416 \begin_layout Itemize
7417 Syntax: function callback.<cbname>:register(function cbfun)
7418 \end_layout
7420 \begin_layout Standard
7421 Synonym for callback.register (section 
7422 \begin_inset CommandInset ref
7423 LatexCommand ref
7424 reference "sub:callback.register:-Register-a"
7426 \end_inset
7428 ), albeit with callback name specified differently.
7429 \end_layout
7431 \begin_layout Subsection
7432 callback.<cbname>:unregister: Register callback
7433 \end_layout
7435 \begin_layout Itemize
7436 Syntax: function callback.<cbname>:unregister(function cbfun)
7437 \end_layout
7439 \begin_layout Standard
7440 Synonym for callback.unregister (section 
7441 \begin_inset CommandInset ref
7442 LatexCommand ref
7443 reference "sub:callback.unregister:-Unregister-"
7445 \end_inset
7447 ), albeit with callback name specified differently.
7448 \end_layout
7450 \begin_layout Section
7451 table bsnes
7452 \end_layout
7454 \begin_layout Standard
7455 Various bsnes-specific functions.
7456 \end_layout
7458 \begin_layout Subsection
7459 bsnes.dump_sprite: Dump a sprite
7460 \end_layout
7462 \begin_layout Itemize
7463 Syntax: BITMAP bsnes.dump_sprite([string marea, ] number addr, number width,
7464  number height[, number stride])
7465 \end_layout
7467 \begin_layout Standard
7468 Dumps given sprite (in native format) from memory.
7469  memory area is usually 
7470 \begin_inset Quotes eld
7471 \end_inset
7473 VRAM
7474 \begin_inset Quotes erd
7475 \end_inset
7478  <Width> and <height> are given in 8x8 blocks.
7479  <Stride> overrides row stride (default 512).
7480 \end_layout
7482 \begin_layout Subsection
7483 bsnes.dump_palette: Dump a palette
7484 \end_layout
7486 \begin_layout Itemize
7487 Syntax: PALETTE bsnes.dump_palette([string marea, ] number addr, bool full256,
7488  bool first_trans)
7489 \end_layout
7491 \begin_layout Standard
7492 Dumps a palette from memory.
7493  memory area is usually 
7494 \begin_inset Quotes eld
7495 \end_inset
7497 CGRAM
7498 \begin_inset Quotes erd
7499 \end_inset
7502  If <full256> is true, 256 colors are dumped (otherwise 16).
7503  If <first_trans> is true, first color is forced transparent.
7504 \end_layout
7506 \begin_layout Subsection
7507 bsnes.enablelayer: Set layer visibility
7508 \end_layout
7510 \begin_layout Itemize
7511 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
7512 \end_layout
7514 \begin_layout Standard
7515 Enable or disable specified layer at specified priority.
7516 \end_layout
7518 \begin_layout Subsection
7519 bsnes.redump_sprite: Redump a sprite
7520 \end_layout
7522 \begin_layout Itemize
7523 Syntax: none bsnes.redump_sprite(BITMAP bitmap, [string marea, ] number addr[,
7524  number stride])
7525 \end_layout
7527 \begin_layout Standard
7528 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
7529  The specified bitmap must have size multiple of 8x8.
7530 \end_layout
7532 \begin_layout Subsection
7533 bsnes.redump_palette: Redump a palette
7534 \end_layout
7536 \begin_layout Itemize
7537 Syntax: none bsnes.dump_palette(PALETTE pal, [string marea, ] number addr,
7538  bool first_trans)
7539 \end_layout
7541 \begin_layout Standard
7542 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
7543  The specified palette must have either 16 or 256 colors.
7544 \end_layout
7546 \begin_layout Section
7547 extensions to table string
7548 \end_layout
7550 \begin_layout Subsection
7551 string.charU: string.char, UTF-8 version.
7552 \end_layout
7554 \begin_layout Itemize
7555 Syntax: string string.charU(number n...)
7556 \end_layout
7558 \begin_layout Standard
7559 Like Lua string.char(), but works in terms of Unicode codepoints.
7560  The returned string is UTF-8.
7561 \end_layout
7563 \begin_layout Subsection
7564 string.byteU: string.byte, UTF-8 version.
7565 \end_layout
7567 \begin_layout Itemize
7568 Syntax: number...
7569  string.byteU(string str[, number i[, number j]])
7570 \end_layout
7572 \begin_layout Standard
7573 Like string.byte(), but works in terms of Unicode codepoints.
7574  The input string <str> is assumed UTF-8.
7575 \end_layout
7577 \begin_layout Subsection
7578 string.regex: Match string against regular expression
7579 \end_layout
7581 \begin_layout Itemize
7582 Syntax: boolean/string...
7583  string.regex(string regexp, string against)
7584 \end_layout
7586 \begin_layout Standard
7587 Match POSIX-extended regular expression <regexp> against string <against>.
7588  If no match, false is returned.
7589  Otherwise if string has no subcaptures, true is returned.
7590  Otherwise each subcapture is returned as a string (in order of starting
7591  position).
7592 \end_layout
7594 \begin_layout Subsection
7595 string.hex: Transform integer into hex string
7596 \end_layout
7598 \begin_layout Itemize
7599 Syntax: string string.hex(number n, [number digits])
7600 \end_layout
7602 \begin_layout Standard
7603 Returns hexadecimal string representation of <n>, optionally padded with
7604  zeroes to <digits> digits (default is not to pad).
7605 \end_layout
7607 \begin_layout Subsection
7608 string.lpad: Pad string with spaces from left
7609 \end_layout
7611 \begin_layout Itemize
7612 Syntax: string string.lpad(string x, number n)
7613 \end_layout
7615 \begin_layout Standard
7616 Pad string <x> to <n> bytes by inserting spaces at start and return the
7617  result.
7618 \end_layout
7620 \begin_layout Subsection
7621 string.rpad: Pad string with spaces from right
7622 \end_layout
7624 \begin_layout Itemize
7625 Syntax: string string.rpad(string x, number n)
7626 \end_layout
7628 \begin_layout Standard
7629 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
7630 \end_layout
7632 \begin_layout Section
7633 Table _SYSTEM
7634 \end_layout
7636 \begin_layout Standard
7637 Contains copy of global variables from time of Lua initialization.
7638  Non-writeable.
7639 \end_layout
7641 \begin_layout Standard
7642 \begin_inset Newpage pagebreak
7643 \end_inset
7646 \end_layout
7648 \begin_layout Section
7649 \begin_inset CommandInset label
7650 LatexCommand label
7651 name "sec:Callbacks"
7653 \end_inset
7655 Callbacks
7656 \end_layout
7658 \begin_layout Standard
7659 Various callbacks to Lua that can occur.
7660 \end_layout
7662 \begin_layout Subsection
7663 on_paint: Screen is being painted
7664 \end_layout
7666 \begin_layout Itemize
7667 Callback: on_paint(bool not_synth)
7668 \end_layout
7670 \begin_layout Standard
7671 Called when screen is being painted.
7672  Any gui.* calls requiring graphic context draw on the screen.
7673 \end_layout
7675 \begin_layout Itemize
7676 not_synth is true if this hook is being called in response to received frame,
7677  false otherwise.
7678 \end_layout
7680 \begin_layout Subsection
7681 on_video: Dumped video frame is being painted
7682 \end_layout
7684 \begin_layout Itemize
7685 Callback: on_video()
7686 \end_layout
7688 \begin_layout Standard
7689 Called when video dump frame is being painted.
7690  Any gui.* calls requiring graphic context draw on the video.
7691 \end_layout
7693 \begin_layout Subsection
7694 on_frame_emulated: Frame emulation complete
7695 \end_layout
7697 \begin_layout Itemize
7698 Callback: on_frame_emulated()
7699 \end_layout
7701 \begin_layout Standard
7702 Called when emulating frame has completed and on_paint()/on_video() calls
7703  are about to be issued.
7704 \end_layout
7706 \begin_layout Subsection
7707 on_frame: Frame emulation starting.
7708 \end_layout
7710 \begin_layout Itemize
7711 Callback: on_frame()
7712 \end_layout
7714 \begin_layout Standard
7715 Called on each starting whole frame.
7716 \end_layout
7718 \begin_layout Subsection
7719 on_rewind: Movie rewound to beginning
7720 \end_layout
7722 \begin_layout Itemize
7723 Callback: on_rewind()
7724 \end_layout
7726 \begin_layout Standard
7727 Called when rewind movie to beginning has completed.
7728 \end_layout
7730 \begin_layout Subsection
7731 on_pre_load: Load operation is about to start
7732 \end_layout
7734 \begin_layout Itemize
7735 Callback: on_pre_load(string name)
7736 \end_layout
7738 \begin_layout Standard
7739 Called just before savestate/movie load occurs (note: loads are always delayed,
7740  so this occurs even when load was initiated by lua).
7741 \end_layout
7743 \begin_layout Subsection
7744 on_err_Load: Load failed
7745 \end_layout
7747 \begin_layout Itemize
7748 Callback: on_err_load(string name)
7749 \end_layout
7751 \begin_layout Standard
7752 Called if loadstate goes wrong.
7753 \end_layout
7755 \begin_layout Subsection
7756 on_post_load: Load completed
7757 \end_layout
7759 \begin_layout Itemize
7760 Callback: on_post_load(string name, boolean was_savestate)
7761 \end_layout
7763 \begin_layout Standard
7764 Called on successful loadstate.
7765  was_savestate gives if this was a savestate or a movie.
7766 \end_layout
7768 \begin_layout Subsection
7769 on_pre_save: Save operation is about to start
7770 \end_layout
7772 \begin_layout Itemize
7773 Callback: on_pre_save(string name, boolean is_savestate)
7774 \end_layout
7776 \begin_layout Standard
7777 Called just before savestate save occurs (note: movie saves are synchronous
7778  and won't trigger these callbacks if called from Lua).
7779 \end_layout
7781 \begin_layout Subsection
7782 on_err_save: Save failed
7783 \end_layout
7785 \begin_layout Itemize
7786 Callback: on_err_save(string name)
7787 \end_layout
7789 \begin_layout Standard
7790 Called if savestate goes wrong.
7791 \end_layout
7793 \begin_layout Subsection
7794 on_post_save: Save completed
7795 \end_layout
7797 \begin_layout Itemize
7798 Callback: on_post_save(string name, boolean is_savestate)
7799 \end_layout
7801 \begin_layout Standard
7802 Called on successful savaestate.
7803  is_savestate gives if this was a savestate or a movie.
7804 \end_layout
7806 \begin_layout Subsection
7807 on_quit: Emulator is shutting down
7808 \end_layout
7810 \begin_layout Itemize
7811 Callback: on_quit()
7812 \end_layout
7814 \begin_layout Standard
7815 Called when emulator is shutting down.
7816 \end_layout
7818 \begin_layout Subsection
7819 on_input: Polling for input
7820 \end_layout
7822 \begin_layout Standard
7823 Called when emulator is just sending input to bsnes core.
7824  Warning: This is called even in readonly mode, but the results are ignored.
7825 \end_layout
7827 \begin_layout Subsection
7828 on_reset: System has been reset
7829 \end_layout
7831 \begin_layout Itemize
7832 Callback: on_reset()
7833 \end_layout
7835 \begin_layout Standard
7836 Called when system is reset.
7837 \end_layout
7839 \begin_layout Subsection
7840 on_readwrite: Entered readwrite mode
7841 \end_layout
7843 \begin_layout Itemize
7844 Callback: on_readwrite()
7845 \end_layout
7847 \begin_layout Standard
7848 Called when moving into readwrite mode as result of 
7849 \begin_inset Quotes eld
7850 \end_inset
7852 set-rwmode
7853 \begin_inset Quotes erd
7854 \end_inset
7856  command (note: moving to rwmode by Lua won't trigger this, as per recursive
7857  entry protection).
7858 \end_layout
7860 \begin_layout Subsection
7861 on_snoop/on_snoop2: Snoop core controller reads
7862 \end_layout
7864 \begin_layout Itemize
7865 Callback: on_snoop(number port, number controller, number index, number
7866  value)
7867 \end_layout
7869 \begin_layout Itemize
7870 Callback: on_snoop2(number port, number controller, number index, number
7871  value)
7872 \end_layout
7874 \begin_layout Standard
7875 Called each time bsnes asks for input.
7876  The value is the final value to be sent to bsnes core (readonly mode, autohold
7877  and autofire have been taken into account).
7878  Might be useful when translating movies to format suitable for console
7879  verification.
7880  Note: There is no way to modify the value to be sent.
7881 \end_layout
7883 \begin_layout Itemize
7884 On_snoop2 is called instead of on_snoop if defined.
7885  Reserves port 0 for system, having first user port be port 1.
7886 \end_layout
7888 \begin_layout Subsection
7889 on_keyhook: Hooked key/axis has been moved
7890 \end_layout
7892 \begin_layout Itemize
7893 Callback: on_keyhook(string keyname, table state)
7894 \end_layout
7896 \begin_layout Standard
7897 Sent when key that has keyhook events requested changes state.
7898  Keyname is name of the key (group) and state is the state (same kind as
7899  table values in input.raw).
7900 \end_layout
7902 \begin_layout Subsection
7903 on_idle: Idle event
7904 \end_layout
7906 \begin_layout Itemize
7907 Callback: on_idle()
7908 \end_layout
7910 \begin_layout Standard
7911 Called when requested by set_idle_timeout(), the timeout has expired and
7912  emulator is waiting.
7913 \end_layout
7915 \begin_layout Subsection
7916 on_timer: Timer event
7917 \end_layout
7919 \begin_layout Itemize
7920 Callback: on_timer()
7921 \end_layout
7923 \begin_layout Standard
7924 Called when requested by set_idle_timeout() and the timeout has expired
7925  (regardless if emulator is waiting).
7926 \end_layout
7928 \begin_layout Subsection
7929 on_set_rewind: Rewind point has been set
7930 \end_layout
7932 \begin_layout Itemize
7933 Callback: on_set_rewind(UNSAFEREWIND r)
7934 \end_layout
7936 \begin_layout Standard
7937 Called when unsafe rewind object has been constructed.
7938 \end_layout
7940 \begin_layout Subsection
7941 on_pre_rewind: Rewind is about to occur
7942 \end_layout
7944 \begin_layout Itemize
7945 Callback: on_pre_rewind() 
7946 \end_layout
7948 \begin_layout Standard
7949 Called just before unsafe rewind is about to occur.
7950 \end_layout
7952 \begin_layout Subsection
7953 on_post_rewind: Rewind has occured
7954 \end_layout
7956 \begin_layout Itemize
7957 Callback: on_post_rewind() 
7958 \end_layout
7960 \begin_layout Standard
7961 Called just after unsafe rewind has occured.
7962 \end_layout
7964 \begin_layout Subsection
7965 on_button: Button has been pressed
7966 \end_layout
7968 \begin_layout Itemize
7969 Callback: on_button(number port, number controller, number index, string
7970  type)
7971 \end_layout
7973 \begin_layout Standard
7974 Called on controller button press, with following parameters:
7975 \end_layout
7977 \begin_layout Itemize
7978 port: Port number (0 is system)
7979 \end_layout
7981 \begin_layout Itemize
7982 controller: Controller within port
7983 \end_layout
7985 \begin_layout Itemize
7986 index: Index of button.
7987 \end_layout
7989 \begin_layout Itemize
7990 type: Type of event, one of:
7991 \end_layout
7993 \begin_deeper
7994 \begin_layout Itemize
7995 \begin_inset Quotes eld
7996 \end_inset
7998 pressed
7999 \begin_inset Quotes erd
8000 \end_inset
8002 : Button was pressed.
8003 \end_layout
8005 \begin_layout Itemize
8006 \begin_inset Quotes eld
8007 \end_inset
8009 released
8010 \begin_inset Quotes erd
8011 \end_inset
8013 : Button was released.
8014 \end_layout
8016 \begin_layout Itemize
8017 \begin_inset Quotes eld
8018 \end_inset
8020 hold
8021 \begin_inset Quotes erd
8022 \end_inset
8024 : Held.
8025 \end_layout
8027 \begin_layout Itemize
8028 \begin_inset Quotes eld
8029 \end_inset
8031 unhold
8032 \begin_inset Quotes erd
8033 \end_inset
8035 : Released from hold.
8036 \end_layout
8038 \begin_layout Itemize
8039 \begin_inset Quotes eld
8040 \end_inset
8042 type
8043 \begin_inset Quotes erd
8044 \end_inset
8046 : Typing input on button.
8047 \end_layout
8049 \begin_layout Itemize
8050 \begin_inset Quotes eld
8051 \end_inset
8053 untype
8054 \begin_inset Quotes erd
8055 \end_inset
8057 : Typing input undone.
8058 \end_layout
8060 \begin_layout Itemize
8061 \begin_inset Quotes eld
8062 \end_inset
8064 autofire <duty> <cycle>
8065 \begin_inset Quotes erd
8066 \end_inset
8068 : Autofire with specifie duty and cycle.
8069 \end_layout
8071 \begin_layout Itemize
8072 \begin_inset Quotes eld
8073 \end_inset
8075 autofire
8076 \begin_inset Quotes erd
8077 \end_inset
8079 : Stop autofire.
8080 \end_layout
8082 \begin_layout Itemize
8083 \begin_inset Quotes eld
8084 \end_inset
8086 analog
8087 \begin_inset Quotes erd
8088 \end_inset
8090 : Analog action on axis.
8091 \end_layout
8093 \end_deeper
8094 \begin_layout Subsection
8095 on_movie_lost: Movie data is about to be lost
8096 \end_layout
8098 \begin_layout Itemize
8099 Callback: on_movie_lost(STRING kind)
8100 \end_layout
8102 \begin_layout Standard
8103 Called just before something would happen that could lose movie data.
8104  Kind can be:
8105 \end_layout
8107 \begin_layout Itemize
8108 readwrite: Switching to readwrite mode.
8109 \end_layout
8111 \begin_layout Itemize
8112 reload: ROM is being reloaded in readwrite mode.
8113 \end_layout
8115 \begin_layout Itemize
8116 load: New movie is being loaded.
8117 \end_layout
8119 \begin_layout Itemize
8120 unsaferewind: Unsafe rewind is happening.
8121 \end_layout
8123 \begin_layout Subsection
8124 on_latch: Latch line is rising
8125 \end_layout
8127 \begin_layout Itemize
8128 Callback: on_latch(<core-dependent-parameters>)
8129 \end_layout
8131 \begin_layout Standard
8132 Called when latch line for controller is rising.
8133  Some cores may not support this.
8134 \end_layout
8136 \begin_layout Section
8137 System-dependent behaviour
8138 \end_layout
8140 \begin_layout Subsection
8141 bsnes core
8142 \end_layout
8144 \begin_layout Itemize
8145 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
8146  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
8147  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
8148 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
8149 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
8150  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
8151  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
8152  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
8153  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
8154 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
8155 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
8156  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
8157 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
8158 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
8159  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
8160 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
8161  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
8162 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
8163 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
8164 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
8165  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
8166 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
8167  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
8168  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
8169 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
8170 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
8171 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
8172  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
8173 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
8174  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
8175  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
8176  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
8177  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
8178 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
8179  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
8180 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
8181  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
8182  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
8183 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
8184  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
8185 \end_layout
8187 \begin_layout Itemize
8188 on_latch has no parameters
8189 \end_layout
8191 \begin_layout Itemize
8192 CPU 0 is S-CPU, 1 is S-SMP.
8193 \end_layout
8195 \begin_layout Itemize
8196 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
8197 \end_layout
8199 \begin_layout Itemize
8200 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
8201 {RAM,ROM}.
8202 \end_layout
8204 \begin_layout Itemize
8205 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
8206  DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
8207  BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
8208  GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
8209 \end_layout
8211 \begin_layout Subsection
8212 gambatte core
8213 \end_layout
8215 \begin_layout Itemize
8216 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
8217  d, e, f, h, l
8218 \end_layout
8220 \begin_layout Itemize
8221 on_latch is not supported
8222 \end_layout
8224 \begin_layout Itemize
8225 CPU 0 is main CPU.
8226 \end_layout
8228 \begin_layout Itemize
8229 Cheats are supported for ROM, SRAM and WRAM.
8230 \end_layout
8232 \begin_layout Itemize
8233 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
8234  and WRAM.
8235 \end_layout
8237 \begin_layout Itemize
8238 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
8239 \end_layout
8241 \end_body
8242 \end_document