Save: Fix issues with adding an extension if missing
[lsnes.git] / lua.lyx
blob909bac4898e5e67146f02471252ef43deee83477
1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 508
3 \begin_document
4 \begin_header
5 \save_transient_properties true
6 \origin unavailable
7 \textclass article
8 \use_default_options true
9 \maintain_unincluded_children false
10 \language english
11 \language_package default
12 \inputencoding auto
13 \fontencoding global
14 \font_roman "default" "default"
15 \font_sans "default" "default"
16 \font_typewriter "default" "default"
17 \font_math "auto" "auto"
18 \font_default_family default
19 \use_non_tex_fonts false
20 \font_sc false
21 \font_osf false
22 \font_sf_scale 100 100
23 \font_tt_scale 100 100
24 \graphics default
25 \default_output_format default
26 \output_sync 0
27 \bibtex_command default
28 \index_command default
29 \paperfontsize default
30 \spacing single
31 \use_hyperref true
32 \pdf_bookmarks true
33 \pdf_bookmarksnumbered false
34 \pdf_bookmarksopen false
35 \pdf_bookmarksopenlevel 1
36 \pdf_breaklinks false
37 \pdf_pdfborder false
38 \pdf_colorlinks false
39 \pdf_backref false
40 \pdf_pdfusetitle true
41 \papersize a4paper
42 \use_geometry true
43 \use_package amsmath 1
44 \use_package amssymb 1
45 \use_package cancel 1
46 \use_package esint 1
47 \use_package mathdots 1
48 \use_package mathtools 1
49 \use_package mhchem 1
50 \use_package stackrel 1
51 \use_package stmaryrd 1
52 \use_package undertilde 1
53 \cite_engine basic
54 \cite_engine_type default
55 \biblio_style plain
56 \use_bibtopic false
57 \use_indices false
58 \paperorientation portrait
59 \suppress_date false
60 \justification true
61 \use_refstyle 1
62 \index Hakusana
63 \shortcut idx
64 \color #008000
65 \end_index
66 \leftmargin 2cm
67 \topmargin 2cm
68 \rightmargin 1cm
69 \bottommargin 2cm
70 \headheight 1cm
71 \headsep 1cm
72 \footskip 1cm
73 \secnumdepth 3
74 \tocdepth 3
75 \paragraph_separation indent
76 \paragraph_indentation default
77 \quotes_language english
78 \papercolumns 1
79 \papersides 1
80 \paperpagestyle default
81 \tracking_changes false
82 \output_changes false
83 \html_math_output 0
84 \html_css_as_file 0
85 \html_be_strict false
86 \end_header
88 \begin_body
90 \begin_layout Title
91 lsnes Lua functions reference
92 \end_layout
94 \begin_layout Section
95 Table of contents
96 \end_layout
98 \begin_layout Standard
99 \begin_inset CommandInset toc
100 LatexCommand tableofcontents
102 \end_inset
105 \end_layout
107 \begin_layout Standard
108 \begin_inset Newpage pagebreak
109 \end_inset
112 \end_layout
114 \begin_layout Section
115 Conventions
116 \end_layout
118 \begin_layout Subsection
119 Coordinates:
120 \end_layout
122 \begin_layout Itemize
123 Coordinates increase to right and down.
124 \end_layout
126 \begin_layout Itemize
127 The origin is at top left of game area or buffer.
128 \end_layout
130 \begin_layout Subsection
131 Drawing and contexts
132 \end_layout
134 \begin_layout Itemize
135 Methods that draw something (unless stated otherwise) require a valid rendering
136  context.
137  This context can come in three ways:
138 \begin_inset Separator latexpar
139 \end_inset
142 \end_layout
144 \begin_deeper
145 \begin_layout Enumerate
146 The default rendering context of paint callback (the screen).
147 \end_layout
149 \begin_layout Enumerate
150 The default rendering context of video callback (the video).
151 \end_layout
153 \begin_layout Enumerate
154 Explicitly set rendering context (RENDERCTX:set).
155 \end_layout
157 \end_deeper
158 \begin_layout Itemize
159 The rendering context is always reset when callback ends.
160 \end_layout
162 \begin_layout Subsection
163 Colors
164 \end_layout
166 \begin_layout Standard
167 (Direct) colors can be specified either as numbers or strings.
168 \end_layout
170 \begin_layout Itemize
171 -1 is fully transparent.
172 \end_layout
174 \begin_layout Itemize
175 Non-negative numbers less than 
176 \begin_inset Formula $2^{32}$
177 \end_inset
179  are partially opaque colors (
180 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
181 \end_inset
184 \begin_inset Separator latexpar
185 \end_inset
188 \end_layout
190 \begin_deeper
191 \begin_layout Itemize
192 \begin_inset Formula $a$
193 \end_inset
195  is transparency 
196 \begin_inset Formula $0-255$
197 \end_inset
200 \begin_inset Formula $0$
201 \end_inset
203  is fully opaque, 
204 \begin_inset Formula $256$
205 \end_inset
207  would be fully transparent.
208 \begin_inset Separator latexpar
209 \end_inset
212 \end_layout
214 \begin_deeper
215 \begin_layout Itemize
216 Thus, numbers in range 
217 \begin_inset Formula $0-16777215$
218 \end_inset
220  stand for fully opaque colors.
221 \end_layout
223 \end_deeper
224 \begin_layout Itemize
225 \begin_inset Formula $r$
226 \end_inset
229 \begin_inset Formula $g$
230 \end_inset
232  and 
233 \begin_inset Formula $b$
234 \end_inset
236  are intensities of base colors on scale 
237 \begin_inset Formula $0-255$
238 \end_inset
241 \end_layout
243 \end_deeper
244 \begin_layout Itemize
245 Color can also be specified by name as string: The following color names
246  are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
247  antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
248  azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
249  bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
250  brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
251  burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
252  chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
253  chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
254 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
255  cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
256  darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
257  darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
258  darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
259 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
260 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
261  darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
262  darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
263  deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
264  dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
265  firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
266  fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
267  goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
268  gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
269  gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
270  gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
271  gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
272  gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
273  gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
274  gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
275  gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
276  gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
277  green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
278  grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
279  grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
280  grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
281  grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
282  grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
283  grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
284  grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
285  grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
286  grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
287  honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
288  indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
289  ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
290  lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
291 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
292  lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
293  lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
294 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
295  lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
296  lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
297  lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
298  lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
299  lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
300  lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
301  maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
302  mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
303  mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
304 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
305 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
306 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
307  navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
308  olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
309  orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
310  palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
311 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
312  palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
313  peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
314  pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
315  purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
316  rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
317  saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
318  seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
319  seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
320  skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
321 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
322  snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
323 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
324  tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
325  tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
326  turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
327  wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
328  yellow3 yellow4 yellowgreen 
329 \end_layout
331 \begin_layout Itemize
332 The HSL base color names: hsl-<hue><saturation><lightness>.
333 \begin_inset Separator latexpar
334 \end_inset
337 \end_layout
339 \begin_deeper
340 \begin_layout Itemize
341 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
342  y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
343  (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
344 \end_layout
346 \begin_layout Itemize
347 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
348 \end_layout
350 \begin_layout Itemize
351 Lightness is 0-8, where 0 is black and 8 is white.
352 \end_layout
354 \end_deeper
355 \begin_layout Itemize
356 The color names can have a modifier after space (multiple modifiers are
357  allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
358  opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
359  hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
360 \begin_inset Separator latexpar
361 \end_inset
364 \end_layout
366 \begin_deeper
367 \begin_layout Itemize
368 opaqueness is measured as percentage.
369 \end_layout
371 \begin_layout Itemize
372 Hue adjustments are on 24-step scale.
373 \end_layout
375 \begin_layout Itemize
376 Saturation and lightness adjustments are on 16-step scale.
377 \end_layout
379 \end_deeper
380 \begin_layout Section
381 Special tokens
382 \end_layout
384 \begin_layout Standard
385 These tokens are special, and are expanded while the script is being loaded
386 \end_layout
388 \begin_layout Subsection
389 @@LUA_SCRIPT_FILENAME@@
390 \end_layout
392 \begin_layout Standard
393 Expanded to string token containing path and filename of this Lua script.
394  Handy for referencing other lua scripts or resources that are relative
395  to this Lua script.
396 \end_layout
398 \begin_layout Standard
399 In practicular, this is suitable to be passed as base argument of various
400  functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
401 ad_png and gui.bitmap_load_pal.
402 \end_layout
404 \begin_layout Section
405 Classes
406 \end_layout
408 \begin_layout Subsection
409 MMAP_STRUCT: Quasi-table mapping emulated memory
410 \end_layout
412 \begin_layout Standard
413 Objects act like tables, but the values reflect emulated memory.
414 \end_layout
416 \begin_layout Subsubsection
417 static function new: Create a new instance
418 \end_layout
420 \begin_layout Itemize
421 Syntax: mmap memory.mmap.new()
422 \end_layout
424 \begin_layout Itemize
425 Syntax: mmap classes.MMAP_STRUCT.new()
426 \end_layout
428 \begin_layout Standard
429 Return value:
430 \end_layout
432 \begin_layout Itemize
433 mmap: MMAP_STRUCT: The created mmap structure.
434 \end_layout
436 \begin_layout Standard
437 Create a new object (with no mappings) and return it.
438 \end_layout
440 \begin_layout Subsubsection
441 operator(): Bind key in mmap structure
442 \end_layout
444 \begin_layout Itemize
445 Syntax: obj(key, {marea, address|addrobj}, type)
446 \end_layout
448 \begin_layout Standard
449 Parameters:
450 \end_layout
452 \begin_layout Itemize
453 obj: MMAP_STRUCT: The structure to manipulate.
454 \end_layout
456 \begin_layout Itemize
457 key: String: The name of the key in array to map.
458 \end_layout
460 \begin_layout Itemize
461 marea: String: The memory area the mapped address is in (default: global
462  memory space).
463 \end_layout
465 \begin_layout Itemize
466 address: Number: The offset of memory addreess, relative to specified memory
467  area or global memory space.
468 \end_layout
470 \begin_layout Itemize
471 addrobj: ADDRESS: The memory address.
472 \end_layout
474 \begin_layout Itemize
475 type: String: The type of data to map.
476 \begin_inset Separator latexpar
477 \end_inset
480 \end_layout
482 \begin_deeper
483 \begin_layout Itemize
484 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
485  float or double.
486 \end_layout
488 \end_deeper
489 \begin_layout Standard
490 Bind key <key> in mmap structure <obj> to address <address> (relative to
491  <marea>).
492  The memory address is treated as type <type>.
493 \end_layout
495 \begin_layout Itemize
496 Example: foomap(
497 \begin_inset Quotes eld
498 \end_inset
501 \begin_inset Quotes erd
502 \end_inset
505 \begin_inset Quotes eld
506 \end_inset
508 WRAM
509 \begin_inset Quotes erd
510 \end_inset
512 , 0x2A, 
513 \begin_inset Quotes eld
514 \end_inset
516 sword
517 \begin_inset Quotes erd
518 \end_inset
521 \end_layout
523 \begin_layout Standard
524 This binds signed word at address WRAM+0x2A into key 
525 \begin_inset Quotes eld
526 \end_inset
529 \begin_inset Quotes erd
530 \end_inset
533 \end_layout
535 \begin_layout Standard
536 \begin_inset Newpage pagebreak
537 \end_inset
540 \end_layout
542 \begin_layout Subsection
543 ZIPWRITER: Write .zip files
544 \end_layout
546 \begin_layout Standard
547 This class does writing of .zip files.
548 \end_layout
550 \begin_layout Subsubsection
551 Static function new: Create a new zipfile
552 \end_layout
554 \begin_layout Itemize
555 Syntax: zip zip.writer.new(filename, [compression])
556 \end_layout
558 \begin_layout Itemize
559 Deprecated: zip zip.create(filename, [compression])
560 \end_layout
562 \begin_layout Standard
563 Parameters:
564 \end_layout
566 \begin_layout Itemize
567 filename: string: The name of the file to write.
568 \end_layout
570 \begin_layout Itemize
571 compression: number: Compression level (0-9).
572  Default is 9.
573 \end_layout
575 \begin_layout Standard
576 Return value:
577 \end_layout
579 \begin_layout Itemize
580 zip: ZIPWRITER: The newly created ZIP writer.
581 \end_layout
583 \begin_layout Standard
584 Create a new ZIPWRITER object and return it.
585 \end_layout
587 \begin_layout Subsubsection
588 Method commit: Finish creating ZIP file.
589 \end_layout
591 \begin_layout Itemize
592 Syntax: zipfile:commit()
593 \end_layout
595 \begin_layout Standard
596 Parameters:
597 \end_layout
599 \begin_layout Itemize
600 zipfile: ZIPFILE: The ZIP file object.
601 \end_layout
603 \begin_layout Standard
604 Finish writing the ZIP file and actually create it on disk.
605 \end_layout
607 \begin_layout Itemize
608 If a member is currently open, it is implicitly closed.
609 \end_layout
611 \begin_layout Itemize
612 Invoking this on already committed or rolled back zipfile causes an error.
613 \end_layout
615 \begin_layout Subsubsection
616 Method rollback: Cancel writing the ZIP file.
617 \end_layout
619 \begin_layout Itemize
620 Syntax: zipfile:rollback()
621 \end_layout
623 \begin_layout Standard
624 Parameters:
625 \end_layout
627 \begin_layout Itemize
628 zipfile: ZIPFILE: The ZIP file object.
629 \end_layout
631 \begin_layout Standard
632 Cancel writing the whole ZIP file.
633  The file on disk will not be modified.
634 \end_layout
636 \begin_layout Itemize
637 If a member is currently open, it is implicitly closed.
638 \end_layout
640 \begin_layout Itemize
641 Invoking this on already committed or rolled back zipfile causes an error.
642 \end_layout
644 \begin_layout Subsubsection
645 Method create_file: Start writing a new member
646 \end_layout
648 \begin_layout Itemize
649 Syntax: zipfile:create_file(filename)
650 \end_layout
652 \begin_layout Standard
653 Parameters:
654 \end_layout
656 \begin_layout Itemize
657 zipfile: ZIPFILE: The ZIP file object.
658 \end_layout
660 \begin_layout Itemize
661 string filename: Name of the new member to create
662 \end_layout
664 \begin_layout Standard
665 Start writing a new member <filename> in ZIP file.
666 \end_layout
668 \begin_layout Itemize
669 If a member is currently open, it is implicitly closed.
670 \end_layout
672 \begin_layout Itemize
673 Invoking this on already committed or rolled back zipfile causes an error.
674 \end_layout
676 \begin_layout Subsubsection
677 Method close_file: Close member
678 \end_layout
680 \begin_layout Itemize
681 Syntax: zipfile:close_file()
682 \end_layout
684 \begin_layout Standard
685 Parameters:
686 \end_layout
688 \begin_layout Itemize
689 zipfile: ZIPFILE: The ZIP file object.
690 \end_layout
692 \begin_layout Standard
693 Close the currently open member in zipfile.
694 \end_layout
696 \begin_layout Itemize
697 Invoking this on already committed or rolled back zipfile causes an error.
698 \end_layout
700 \begin_layout Itemize
701 Invoking this without an open member causes an error.
702 \end_layout
704 \begin_layout Subsubsection
705 Method write: Write data
706 \end_layout
708 \begin_layout Itemize
709 Syntax: zipfile:write(data)
710 \end_layout
712 \begin_layout Standard
713 Parameters:
714 \end_layout
716 \begin_layout Itemize
717 zipfile: ZIPFILE: The ZIP file object.
718 \end_layout
720 \begin_layout Itemize
721 data: string: The data to write.
722 \end_layout
724 \begin_layout Standard
725 Write <data> in binary mode (as-is) to currently open member.
726 \end_layout
728 \begin_layout Itemize
729 Invoking this without a member being open causes an error.
730 \end_layout
732 \begin_layout Standard
733 \begin_inset Newpage pagebreak
734 \end_inset
737 \end_layout
739 \begin_layout Subsection
740 TILEMAP: Tiled collection of bitmaps.
741 \end_layout
743 \begin_layout Standard
744 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
745 \end_layout
747 \begin_layout Subsubsection
748 Static function new: Create a tilemap
749 \end_layout
751 \begin_layout Itemize
752 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
753 \end_layout
755 \begin_layout Itemize
756 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
757 \end_layout
759 \begin_layout Itemize
760 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
761 \end_layout
763 \begin_layout Standard
764 Parameters:
765 \end_layout
767 \begin_layout Itemize
768 w: number: Width of the tilemap in tiles
769 \end_layout
771 \begin_layout Itemize
772 h: number: Height of the tilemap in tiles
773 \end_layout
775 \begin_layout Itemize
776 bw: number: Width of each tile in pixels.
777 \end_layout
779 \begin_layout Itemize
780 bh: number: Height of each tile in pixels.
781 \end_layout
783 \begin_layout Standard
784 Return value:
785 \end_layout
787 \begin_layout Itemize
788 tilemap: TILEMAP: the newly created tilemap
789 \end_layout
791 \begin_layout Standard
792 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
793  it.
794 \end_layout
796 \begin_layout Subsubsection
797 TILEMAP:getsize: Query tilemap size
798 \end_layout
800 \begin_layout Itemize
801 Syntax: width, height tmap:getsize()
802 \end_layout
804 \begin_layout Standard
805 Parameters:
806 \end_layout
808 \begin_layout Itemize
809 tmap: TILEMAP: The tilemap to query.
810 \end_layout
812 \begin_layout Standard
813 Return value:
814 \end_layout
816 \begin_layout Itemize
817 width: number : The width of the tilemap in tiles.
818 \end_layout
820 \begin_layout Itemize
821 height: number: The height of the tilemap in tiles.
822 \end_layout
824 \begin_layout Standard
825 Get size of tilemap in tiles.
826 \end_layout
828 \begin_layout Subsubsection
829 TILEMAP:getcsize: Query tilemap cell size
830 \end_layout
832 \begin_layout Itemize
833 Syntax: width, height tmap:getcsize()
834 \end_layout
836 \begin_layout Standard
837 Parameters:
838 \end_layout
840 \begin_layout Itemize
841 tmap: TILEMAP: The tilemap to query.
842 \end_layout
844 \begin_layout Standard
845 Return value:
846 \end_layout
848 \begin_layout Itemize
849 width: number: The width of tilemap tile in pixels.
850 \end_layout
852 \begin_layout Itemize
853 height: number: The height of tilemap tile in pixels.
854 \end_layout
856 \begin_layout Standard
857 Get size of each tilemap tile in pixels.
858 \end_layout
860 \begin_layout Subsubsection
861 TILEMAP:get: Query tilemap tile
862 \end_layout
864 \begin_layout Itemize
865 Syntax: bitmap, palette tmap:get(x, y)
866 \end_layout
868 \begin_layout Standard
869 Parameters:
870 \end_layout
872 \begin_layout Itemize
873 tmap: TILEMAP: The tilemap to query.
874 \end_layout
876 \begin_layout Itemize
877 x: number: The x-coordinate of tile to query.
878 \end_layout
880 \begin_layout Itemize
881 y: number: The y-coordinate of tile to query.
882 \end_layout
884 \begin_layout Standard
885 Return value:
886 \end_layout
888 \begin_layout Itemize
889 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
890 \end_layout
892 \begin_layout Itemize
893 palette: The palette (PALETTE) associated with indexed-color bitmap, if
894  any.
895  Otherwise nil.
896 \end_layout
898 \begin_layout Standard
899 Return the contents of tile at <x>,<y>.
900 \end_layout
902 \begin_layout Subsubsection
903 TILEMAP:set: Set tilemap cell
904 \end_layout
906 \begin_layout Itemize
907 Syntax: tmap:set(x, y)
908 \end_layout
910 \begin_layout Itemize
911 Syntax: tmap:set(x, y, bitmap)
912 \end_layout
914 \begin_layout Itemize
915 Syntax: tmap:set(x, y, bitmap, palette)
916 \end_layout
918 \begin_layout Standard
919 Parameters:
920 \end_layout
922 \begin_layout Itemize
923 tmap: TILEMAP: The tilemap to manipulate.
924 \end_layout
926 \begin_layout Itemize
927 number x: The x-coordinate of tile to set.
928 \end_layout
930 \begin_layout Itemize
931 number y: The y-coordinate of tile to set.
932 \end_layout
934 \begin_layout Itemize
935 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
936 \end_layout
938 \begin_layout Itemize
939 palette: PALETTE: The associated palette for bitmap.
940 \end_layout
942 \begin_layout Standard
943 Set the contents of tile <x>,<y>.
944  If no <bitmap> is given, clears the tile.
945  Otherwise sets the tile to contain bitmap <bitmap> with associated palette
946  <palette>.
947 \end_layout
949 \begin_layout Itemize
950 Specifying index bitmap <bitmap> without palette <palette> causes an error.
951 \end_layout
953 \begin_layout Subsubsection
954 TILEMAP:scroll: Scroll tilemap
955 \end_layout
957 \begin_layout Itemize
958 Syntax: tmap:scroll(ox, oy);
959 \end_layout
961 \begin_layout Itemize
962 Syntax: tmap:scroll(ox, oy, x, y, w, h);
963 \end_layout
965 \begin_layout Itemize
966 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
967 \end_layout
969 \begin_layout Standard
970 Parameters:
971 \end_layout
973 \begin_layout Itemize
974 tmap: TILEMAP: The tilemap to manipulate.
975 \end_layout
977 \begin_layout Itemize
978 ox: number: The number of tiles to scroll horizontally (positive is to right).
979 \end_layout
981 \begin_layout Itemize
982 oy: number: The number of tiles to scroll vertically (positive is to down).
983 \end_layout
985 \begin_layout Itemize
986 x: number: The left edge of scroll window.
987 \end_layout
989 \begin_layout Itemize
990 y: number: The top edge of scroll window.
991 \end_layout
993 \begin_layout Itemize
994 w: number: The width of scroll window.
995 \end_layout
997 \begin_layout Itemize
998 h: number: The height of scroll window.
999 \end_layout
1001 \begin_layout Itemize
1002 circ_x: boolean: If true, treat the window as circular in horizontal direction.
1003 \end_layout
1005 \begin_layout Itemize
1006 circ_y: boolean: If true, treat the window as circular in vertical direction.
1007 \end_layout
1009 \begin_layout Standard
1010 Scroll the specified tilemap <tmap> by <ox>,<oy>.
1011  If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
1012  <circ_x> and <circ_y> control if scroll is circular or not.
1013 \end_layout
1015 \begin_layout Itemize
1016 Specifying out-of-range window causes an error.
1017 \end_layout
1019 \begin_layout Subsubsection
1020 TILEMAP:draw: Draw tilemap
1021 \end_layout
1023 \begin_layout Itemize
1024 Name: tmap:draw(x, y)
1025 \end_layout
1027 \begin_layout Itemize
1028 Name: tmap:draw(x, y, x0, y0, w, h)
1029 \end_layout
1031 \begin_layout Standard
1032 Parameters:
1033 \end_layout
1035 \begin_layout Itemize
1036 tmap: TILEMAP: The tilemap to draw.
1037 \end_layout
1039 \begin_layout Itemize
1040 x: The x coordinate on screen to draw to.
1041 \end_layout
1043 \begin_layout Itemize
1044 y: The y coordinate on screen to draw to.
1045 \end_layout
1047 \begin_layout Itemize
1048 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1049 \end_layout
1051 \begin_layout Itemize
1052 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1053 \end_layout
1055 \begin_layout Itemize
1056 w: number: The width to draw (in pixels).
1057 \end_layout
1059 \begin_layout Itemize
1060 h: number: The height to draw (in pixels).
1061 \end_layout
1063 \begin_layout Standard
1064 Draw tilemap <tmap> to screen at <x>,<y>.
1065  If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1066 \end_layout
1068 \begin_layout Itemize
1069 This method requires a rendering context to work.
1070 \end_layout
1072 \begin_layout Subsubsection
1073 TILEMAP:draw_outside: Draw tilemap outside game area
1074 \end_layout
1076 \begin_layout Itemize
1077 Name: tmap:draw_outside(x, y)
1078 \end_layout
1080 \begin_layout Itemize
1081 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1082 \end_layout
1084 \begin_layout Standard
1085 Like TILEMAP:draw, but draws only outside game area.
1086 \end_layout
1088 \begin_layout Standard
1089 \begin_inset Newpage pagebreak
1090 \end_inset
1093 \end_layout
1095 \begin_layout Subsection
1096 RENDERCTX: Off-screen rendering context
1097 \end_layout
1099 \begin_layout Standard
1100 Object acting as off-screen rendering context.
1101 \end_layout
1103 \begin_layout Subsubsection
1104 Static function new: Create a render queue
1105 \end_layout
1107 \begin_layout Itemize
1108 Syntax: renderctx gui.renderctx.new(width, height);
1109 \end_layout
1111 \begin_layout Itemize
1112 Syntax: renderctx classes.RENDERCTX.new(width, height);
1113 \end_layout
1115 \begin_layout Itemize
1116 Deprecated: renderctx gui.renderq_new(width, height);
1117 \end_layout
1119 \begin_layout Standard
1120 Parameters:
1121 \end_layout
1123 \begin_layout Itemize
1124 width: number: The notional width of the game area.
1125 \end_layout
1127 \begin_layout Itemize
1128 height: number: The notional height of the game area.
1129 \end_layout
1131 \begin_layout Standard
1132 Returns:
1133 \end_layout
1135 \begin_layout Itemize
1136 rendectx: RENDERCTX: The newly created render context.
1137 \end_layout
1139 \begin_layout Standard
1140 Create a render context with reported size <width>*<height> and return it.
1141 \end_layout
1143 \begin_layout Subsubsection
1144 Static function setnull: Reset to default queue
1145 \end_layout
1147 \begin_layout Itemize
1148 Syntax: gui.renderctx.setnull()
1149 \end_layout
1151 \begin_layout Itemize
1152 Syntax: classes.RENDERCTX:setnull()
1153 \end_layout
1155 \begin_layout Itemize
1156 Deprecated: gui.renderq_set()
1157 \end_layout
1159 \begin_layout Standard
1160 Reset the used render context back to default for the executing callback:
1161 \end_layout
1163 \begin_layout Itemize
1164 The default for paint callback is the screen
1165 \end_layout
1167 \begin_layout Itemize
1168 The default for video callback is the video frame
1169 \end_layout
1171 \begin_layout Itemize
1172 The default otherwise is nothing.
1173 \end_layout
1175 \begin_layout Subsubsection
1176 Method clear: Clear a render queue
1177 \end_layout
1179 \begin_layout Itemize
1180 Syntax: renderctx:clear()
1181 \end_layout
1183 \begin_layout Itemize
1184 Deprecated: gui.renderq_clear(renderctx)
1185 \end_layout
1187 \begin_layout Standard
1188 Parameters:
1189 \end_layout
1191 \begin_layout Itemize
1192 renderctx: RENDERCTX: The render queue to clear.
1193 \end_layout
1195 \begin_layout Standard
1196 Clear all drawing from the context.
1197 \end_layout
1199 \begin_layout Subsubsection
1200 Method set: Change active render context
1201 \end_layout
1203 \begin_layout Itemize
1204 Syntax: renderctx:set()
1205 \end_layout
1207 \begin_layout Itemize
1208 Deprecated: gui.renderq_set(renderctx)
1209 \end_layout
1211 \begin_layout Standard
1212 Parameters:
1213 \end_layout
1215 \begin_layout Itemize
1216 renderctx: RENDERCTX: The render queue to use.
1217 \end_layout
1219 \begin_layout Standard
1220 Switch the current rendering context <renderctx>.
1221 \end_layout
1223 \begin_layout Subsubsection
1224 Method run: Draw all objects in context to another
1225 \end_layout
1227 \begin_layout Itemize
1228 Syntax: renderctx:run()
1229 \end_layout
1231 \begin_layout Itemize
1232 Deprecated: gui.renderq_run(renderctx)
1233 \end_layout
1235 \begin_layout Standard
1236 Parameters:
1237 \end_layout
1239 \begin_layout Itemize
1240 renderctx: RENDERCTX: The render context to overlay.
1241 \end_layout
1243 \begin_layout Standard
1244 Overlay the specified render context <context> upon the active rendering
1245  context.
1246 \end_layout
1248 \begin_layout Itemize
1249 Trying to overlay rendering context upon itself is a bad idea.
1250 \end_layout
1252 \begin_layout Subsubsection
1253 Method render: Render a contex to bitmap
1254 \end_layout
1256 \begin_layout Itemize
1257 Syntax: bitmap renderctx:render()
1258 \end_layout
1260 \begin_layout Standard
1261 Parameters:
1262 \end_layout
1264 \begin_layout Itemize
1265 renderctx: RENDERCTX: The context to render.
1266 \end_layout
1268 \begin_layout Standard
1269 Returns:
1270 \end_layout
1272 \begin_layout Itemize
1273 bitmap: DBITMAP: The rendered bitmap.
1274 \end_layout
1276 \begin_layout Standard
1277 Render the specified context <renderctx> to a new bitmap.
1278 \end_layout
1280 \begin_layout Itemize
1281 The size of bitmap will be nominal game area size, plus any set gaps.
1282 \end_layout
1284 \begin_layout Itemize
1285 This method does not require active rendering context.
1286 \end_layout
1288 \begin_layout Subsubsection
1289 Method synchronous_repaint: Paint screen now
1290 \end_layout
1292 \begin_layout Itemize
1293 Syntax: renderctx:synchronous_repaint()
1294 \end_layout
1296 \begin_layout Itemize
1297 Deprecated: gui.synchronous_repaint(renderctx)
1298 \end_layout
1300 \begin_layout Standard
1301 Parameters:
1302 \end_layout
1304 \begin_layout Itemize
1305 renderctx: RENDERCTX: The context to paint.
1306 \end_layout
1308 \begin_layout Standard
1309 Immediately redraw the screen with game overlayed by drawings from context
1310  <renderctx>.
1311 \end_layout
1313 \begin_layout Itemize
1314 This does not require active rendering context.
1315 \end_layout
1317 \begin_layout Itemize
1318 Will not cause paint callback to be invoked.
1319 \end_layout
1321 \begin_layout Standard
1322 \begin_inset Newpage pagebreak
1323 \end_inset
1326 \end_layout
1328 \begin_layout Subsection
1329 PALETTE: Color palette for indexed image
1330 \end_layout
1332 \begin_layout Subsubsection
1333 Static function new: Create a new palette
1334 \end_layout
1336 \begin_layout Itemize
1337 Syntax: palette gui.palette.new()
1338 \end_layout
1340 \begin_layout Itemize
1341 Syntax: palette classes.PALETTE.new()
1342 \end_layout
1344 \begin_layout Itemize
1345 Deprecated: palette gui.palette_new()
1346 \end_layout
1348 \begin_layout Standard
1349 Returns:
1350 \end_layout
1352 \begin_layout Itemize
1353 palette: PALETTE: The created palette.
1354 \end_layout
1356 \begin_layout Standard
1357 Create a new palette (with all colors transparent) and return it.
1358 \end_layout
1360 \begin_layout Subsubsection
1361 Static function load: Load a palette
1362 \end_layout
1364 \begin_layout Itemize
1365 Syntax: palette gui.palette.load(file, [base])
1366 \end_layout
1368 \begin_layout Itemize
1369 Syntax: palette classes.PALETTE.load(file, [base])
1370 \end_layout
1372 \begin_layout Itemize
1373 Deprecated: palette gui.palette_load(file, [base])
1374 \end_layout
1376 \begin_layout Standard
1377 Parameters:
1378 \end_layout
1380 \begin_layout Itemize
1381 string file: The file to load.
1382 \end_layout
1384 \begin_layout Itemize
1385 string base (optional): The base file to resolve file relative to.
1386 \end_layout
1388 \begin_layout Standard
1389 Returns:
1390 \end_layout
1392 \begin_layout Itemize
1393 palette: PALETTE: The loaded palette.
1394 \end_layout
1396 \begin_layout Standard
1397 Load a palette from file <file> (resolved relative to <base>).
1398 \end_layout
1400 \begin_layout Itemize
1401 The file format is a series of lines, each with following format:
1402 \begin_inset Separator latexpar
1403 \end_inset
1406 \end_layout
1408 \begin_deeper
1409 \begin_layout Itemize
1410 Blank or just whitespace: Ignored
1411 \end_layout
1413 \begin_layout Itemize
1414 First non-whitespace is '#': Ignored
1415 \end_layout
1417 \begin_layout Itemize
1418 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1419 \end_layout
1421 \begin_layout Itemize
1422 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1423  (0-256, 0 being fully transparent and 256 fully opaque).
1424 \end_layout
1426 \begin_layout Itemize
1427 transparent: Fully transparent color
1428 \end_layout
1430 \end_deeper
1431 \begin_layout Subsubsection
1432 Static function load_str: Load a palette from string
1433 \end_layout
1435 \begin_layout Itemize
1436 Syntax: palette gui.palette.load(data)
1437 \end_layout
1439 \begin_layout Itemize
1440 Syntax: palette classes.PALETTE.load(data)
1441 \end_layout
1443 \begin_layout Itemize
1444 Deprecated: palette gui.palette_load(data)
1445 \end_layout
1447 \begin_layout Standard
1448 Parameters:
1449 \end_layout
1451 \begin_layout Itemize
1452 string data: The palette data.
1453 \end_layout
1455 \begin_layout Standard
1456 Returns:
1457 \end_layout
1459 \begin_layout Itemize
1460 palette: PALETTE: The loaded palette.
1461 \end_layout
1463 \begin_layout Standard
1464 Like PALETTE:load, but instead of reading palette from file, reads it from
1465  a string.
1466 \end_layout
1468 \begin_layout Subsubsection
1469 Method set: Set palette entry
1470 \end_layout
1472 \begin_layout Itemize
1473 Syntax: palette:set(index, color)
1474 \end_layout
1476 \begin_layout Itemize
1477 Deprecated: gui.palette_set(palette, ...)
1478 \end_layout
1480 \begin_layout Standard
1481 Parameters:
1482 \end_layout
1484 \begin_layout Itemize
1485 palette: PALETTE: The palette to manipulate
1486 \end_layout
1488 \begin_layout Itemize
1489 index: number: The index of color to set (0-65535).
1490 \end_layout
1492 \begin_layout Itemize
1493 color: number/string: The color value to set.
1494 \end_layout
1496 \begin_layout Standard
1497 Set palette <palette> index <index> to color <color>.
1498 \end_layout
1500 \begin_layout Subsubsection
1501 Method get: Get palette entry
1502 \end_layout
1504 \begin_layout Itemize
1505 Syntax: number palette:get(index)
1506 \end_layout
1508 \begin_layout Standard
1509 Parameters:
1510 \end_layout
1512 \begin_layout Itemize
1513 palette: PALETTE: The palette to query
1514 \end_layout
1516 \begin_layout Itemize
1517 index: number: The index of color to get (0-65535).
1518 \end_layout
1520 \begin_layout Standard
1521 Returns:
1522 \end_layout
1524 \begin_layout Itemize
1525 The palette entry as integer.
1526 \end_layout
1528 \begin_layout Standard
1529 Get palette entry <index> of palette <palette> and return it.
1530 \end_layout
1532 \begin_layout Subsubsection
1533 Method hash: Hash a palette
1534 \end_layout
1536 \begin_layout Itemize
1537 Syntax: hash palette:hash()
1538 \end_layout
1540 \begin_layout Itemize
1541 Deprecated: hash gui.palette_hash(palette)
1542 \end_layout
1544 \begin_layout Standard
1545 Parameters:
1546 \end_layout
1548 \begin_layout Itemize
1549 palette: The palette to hash.
1550 \end_layout
1552 \begin_layout Standard
1553 Return value:
1554 \end_layout
1556 \begin_layout Itemize
1557 hash: string: 64-hex digit hash.
1558 \end_layout
1560 \begin_layout Standard
1561 Obtain crypto-grade hash of palette data of <palette>.
1562 \end_layout
1564 \begin_layout Itemize
1565 All colors after the last non-transparent one are ignored.
1566 \end_layout
1568 \begin_layout Subsubsection
1569 Method adjust_transparency: Adjust transparency
1570 \end_layout
1572 \begin_layout Itemize
1573 Syntax: palette:adjust_transparency(newvalue)
1574 \end_layout
1576 \begin_layout Itemize
1577 Deprecated: gui.adjust_transparency(palette, ...)
1578 \end_layout
1580 \begin_layout Standard
1581 Parameters:
1582 \end_layout
1584 \begin_layout Itemize
1585 palette: PALETTE: The palette to adjust.
1586 \end_layout
1588 \begin_layout Itemize
1589 Number adj: The factor to multiply opaqueness with times 256.
1590 \end_layout
1592 \begin_layout Standard
1593 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1594 \end_layout
1596 \begin_layout Standard
1597 \begin_inset Newpage pagebreak
1598 \end_inset
1601 \end_layout
1603 \begin_layout Subsection
1604 BITMAP: Indexed-color bitmap
1605 \end_layout
1607 \begin_layout Subsubsection
1608 Static function new: Create a new bitmap
1609 \end_layout
1611 \begin_layout Itemize
1612 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1613 \end_layout
1615 \begin_layout Itemize
1616 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1617 \end_layout
1619 \begin_layout Itemize
1620 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1621 \end_layout
1623 \begin_layout Standard
1624 Parameters:
1625 \end_layout
1627 \begin_layout Itemize
1628 w: number: The width of bitmap to create in pixels.
1629 \end_layout
1631 \begin_layout Itemize
1632 h: number: The height of bitmap to create in pixels.
1633 \end_layout
1635 \begin_layout Itemize
1636 false: boolean: Constant boolean false.
1637 \end_layout
1639 \begin_layout Itemize
1640 fillcolor: number: The initial fill index.
1641  Default 0 if not specified.
1642 \end_layout
1644 \begin_layout Standard
1645 Create a new bitmap of size <w>*<h>.
1646  Fill the bitmap with color index <fillcolor>.
1647 \end_layout
1649 \begin_layout Subsubsection
1650 Method draw: Draw a bitmap
1651 \end_layout
1653 \begin_layout Itemize
1654 Syntax: bitmap:draw(x, y, palette)
1655 \end_layout
1657 \begin_layout Itemize
1658 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1659 \end_layout
1661 \begin_layout Standard
1662 Parameters:
1663 \end_layout
1665 \begin_layout Itemize
1666 bitmap: BITMAP: The bitmap to draw
1667 \end_layout
1669 \begin_layout Itemize
1670 x: number: The x-coordinate on screen.
1671 \end_layout
1673 \begin_layout Itemize
1674 y: number: The y-coordinate on screen.
1675 \end_layout
1677 \begin_layout Itemize
1678 palette: The palette to use for drawing.
1679 \end_layout
1681 \begin_layout Standard
1682 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1683 \end_layout
1685 \begin_layout Subsubsection
1686 Method draw_outside: Draw a bitmap outside game area
1687 \end_layout
1689 \begin_layout Itemize
1690 Syntax: bitmap:draw_outside(x, y, palette)
1691 \end_layout
1693 \begin_layout Standard
1694 Like bitmap:draw, but does not draw on game area.
1695 \end_layout
1697 \begin_layout Subsubsection
1698 Method draw_clip: Draw a bitmap, with clipping
1699 \end_layout
1701 \begin_layout Itemize
1702 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1703 \end_layout
1705 \begin_layout Standard
1706 Parameters:
1707 \end_layout
1709 \begin_layout Itemize
1710 bitmap: BITMAP: The bitmap to draw
1711 \end_layout
1713 \begin_layout Itemize
1714 x: number: The x-coordinate on screen.
1715 \end_layout
1717 \begin_layout Itemize
1718 y: number: The y-coordinate on screen.
1719 \end_layout
1721 \begin_layout Itemize
1722 palette: The palette to use for drawing.
1723 \end_layout
1725 \begin_layout Itemize
1726 x0: The smallest bitmap x coordinate to draw.
1727 \end_layout
1729 \begin_layout Itemize
1730 y0: The smallest bitmap y coordinate to draw.
1731 \end_layout
1733 \begin_layout Itemize
1734 width: Width of region to draw
1735 \end_layout
1737 \begin_layout Itemize
1738 height: Height of region to draw.
1739 \end_layout
1741 \begin_layout Standard
1742 Like bitmap:draw, but clip the bitmap area drawn.
1743 \end_layout
1745 \begin_layout Subsubsection
1746 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1747 \end_layout
1749 \begin_layout Itemize
1750 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1751 \end_layout
1753 \begin_layout Standard
1754 Like bitmap:draw_clip, but only draw outside game area.
1755 \end_layout
1757 \begin_layout Subsubsection
1758 Method pset: Set pixel in bitmap
1759 \end_layout
1761 \begin_layout Itemize
1762 Syntax: bitmap:pset(x, y, color)
1763 \end_layout
1765 \begin_layout Itemize
1766 Deprecaed: gui.bitmap_pset(bitmap, ...)
1767 \end_layout
1769 \begin_layout Standard
1770 Parameters:
1771 \end_layout
1773 \begin_layout Itemize
1774 bitmap: BITMAP: The bitmap to manipulate.
1775 \end_layout
1777 \begin_layout Itemize
1778 x: number: x-coordinate of pixel to set.
1779 \end_layout
1781 \begin_layout Itemize
1782 y: number: y-coordinate of pixel to set.
1783 \end_layout
1785 \begin_layout Itemize
1786 color: number: The color index to set.
1787 \end_layout
1789 \begin_layout Standard
1790 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1791 \end_layout
1793 \begin_layout Subsubsection
1794 Method pget: Get pixel in bitmap
1795 \end_layout
1797 \begin_layout Itemize
1798 Syntax: color bitmap:pget(x,y)
1799 \end_layout
1801 \begin_layout Itemize
1802 Deprecated: color gui.bitmap_pget(bitmap, ...)
1803 \end_layout
1805 \begin_layout Standard
1806 Parameters:
1807 \end_layout
1809 \begin_layout Itemize
1810 bitmap: BITMAP: The bitmap to query.
1811 \end_layout
1813 \begin_layout Itemize
1814 x: number: x-coordinate of pixel to get.
1815 \end_layout
1817 \begin_layout Itemize
1818 y: number: y-coordinate of pixel to get.
1819 \end_layout
1821 \begin_layout Standard
1822 Returns:
1823 \end_layout
1825 \begin_layout Itemize
1826 color: number: The color index in specified pixel.
1827 \end_layout
1829 \begin_layout Standard
1830 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1831 \end_layout
1833 \begin_layout Subsubsection
1834 Method size: Get size of bitmap
1835 \end_layout
1837 \begin_layout Itemize
1838 Syntax: width, height bitmap:size()
1839 \end_layout
1841 \begin_layout Itemize
1842 Syntax: width, height gui.bitmap_size(bitmap)
1843 \end_layout
1845 \begin_layout Standard
1846 Parameters:
1847 \end_layout
1849 \begin_layout Itemize
1850 bitmap: BITMAP: The bitmap to query.
1851 \end_layout
1853 \begin_layout Standard
1854 Returns:
1855 \end_layout
1857 \begin_layout Itemize
1858 width: number: The width of the bitmap.
1859 \end_layout
1861 \begin_layout Itemize
1862 height: number: The height of the bitmap.
1863 \end_layout
1865 \begin_layout Standard
1866 Get size of bitmap <bitmap>.
1867 \end_layout
1869 \begin_layout Subsubsection
1870 Method blit: Blit a bitmap into another
1871 \end_layout
1873 \begin_layout Itemize
1874 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1875 \end_layout
1877 \begin_layout Itemize
1878 Deprecated: gui.bitmap_blit(dest, ...)
1879 \end_layout
1881 \begin_layout Standard
1882 Parameters:
1883 \end_layout
1885 \begin_layout Itemize
1886 dest: BITMAP: The target bitmap to blit to.
1887 \end_layout
1889 \begin_layout Itemize
1890 dx: number: The x-coordinate in target.
1891 \end_layout
1893 \begin_layout Itemize
1894 dy: number: The y-coordinate in target.
1895 \end_layout
1897 \begin_layout Itemize
1898 src: BITMAP: The source bitmap.
1899 \end_layout
1901 \begin_layout Itemize
1902 sx: number: The x-coordinate in source.
1903 \end_layout
1905 \begin_layout Itemize
1906 sy: number: The y-coordinate in source.
1907 \end_layout
1909 \begin_layout Itemize
1910 w: number: The width of area to blit.
1911 \end_layout
1913 \begin_layout Itemize
1914 h: number: The height of area to blit.
1915 \end_layout
1917 \begin_layout Itemize
1918 ck: number: The color key.
1919  Pixels with this index are not copied.
1920 \begin_inset Separator latexpar
1921 \end_inset
1924 \end_layout
1926 \begin_deeper
1927 \begin_layout Itemize
1928 If none is specified, all pixels are copied.
1929 \end_layout
1931 \end_deeper
1932 \begin_layout Standard
1933 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1934  <dx>,<dy>.
1935  If a color key <ck> is specified, pixels of that color are not copied.
1936 \end_layout
1938 \begin_layout Subsubsection
1939 Method blit_scaled: Blit a bitmap into another with scaling
1940 \end_layout
1942 \begin_layout Itemize
1943 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1944 \end_layout
1946 \begin_layout Itemize
1947 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1948 \end_layout
1950 \begin_layout Standard
1951 Parameters:
1952 \end_layout
1954 \begin_layout Itemize
1955 dest: BITMAP: The target bitmap to blit to.
1956 \end_layout
1958 \begin_layout Itemize
1959 dx: number: The x-coordinate in target.
1960 \end_layout
1962 \begin_layout Itemize
1963 dy: number: The y-coordinate in target.
1964 \end_layout
1966 \begin_layout Itemize
1967 src: BITMAP: The source bitmap.
1968 \end_layout
1970 \begin_layout Itemize
1971 sx: number: The x-coordinate in source.
1972 \end_layout
1974 \begin_layout Itemize
1975 sy: number: The y-coordinate in source.
1976 \end_layout
1978 \begin_layout Itemize
1979 w: number: The width of area to blit.
1980 \end_layout
1982 \begin_layout Itemize
1983 h: number: The height of area to blit.
1984 \end_layout
1986 \begin_layout Itemize
1987 hscl: number: Horizontal scale factor (integer).
1988 \end_layout
1990 \begin_layout Itemize
1991 vscl: number: Vertical scale factor (integer).
1992  Defaults to the same as <hscl>.
1993 \end_layout
1995 \begin_layout Itemize
1996 ck: number: The color key.
1997  Pixels with this index are not copied.
1998 \begin_inset Separator latexpar
1999 \end_inset
2002 \end_layout
2004 \begin_deeper
2005 \begin_layout Itemize
2006 If none is specified, all pixels are copied.
2007 \end_layout
2009 \end_deeper
2010 \begin_layout Standard
2011 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
2012  neighbor) by factor of <hscl>*<vscl>.
2013 \end_layout
2015 \begin_layout Subsubsection
2016 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2017 \end_layout
2019 \begin_layout Itemize
2020 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2021 \end_layout
2023 \begin_layout Itemize
2024 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2025 \end_layout
2027 \begin_layout Standard
2028 Parameters:
2029 \end_layout
2031 \begin_layout Itemize
2032 dest: BITMAP: The target bitmap to blit to.
2033 \end_layout
2035 \begin_layout Itemize
2036 dx: number: The x-coordinate in target.
2037 \end_layout
2039 \begin_layout Itemize
2040 dy: number: The y-coordinate in target.
2041 \end_layout
2043 \begin_layout Itemize
2044 src: BITMAP: The source bitmap.
2045 \end_layout
2047 \begin_layout Itemize
2048 sx: number: The x-coordinate in source.
2049 \end_layout
2051 \begin_layout Itemize
2052 sy: number: The y-coordinate in source.
2053 \end_layout
2055 \begin_layout Itemize
2056 w: number: The width of area to blit.
2057 \end_layout
2059 \begin_layout Itemize
2060 h: number: The height of area to blit.
2061 \end_layout
2063 \begin_layout Itemize
2064 operator: string: The operator to use.
2065 \begin_inset Separator latexpar
2066 \end_inset
2069 \end_layout
2071 \begin_deeper
2072 \begin_layout Itemize
2073 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2074  DestOut, Clear or Xor.
2075 \end_layout
2077 \end_deeper
2078 \begin_layout Standard
2079 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2080  operator.
2082 \end_layout
2084 \begin_layout Itemize
2085 Color index 0 in source and target is treated as background.
2086 \end_layout
2088 \begin_layout Subsubsection
2089 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2090  Porter-Duff composition
2091 \end_layout
2093 \begin_layout Itemize
2094 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2095  operator)
2096 \end_layout
2098 \begin_layout Itemize
2099 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2100 \end_layout
2102 \begin_layout Standard
2103 Parameters:
2104 \end_layout
2106 \begin_layout Itemize
2107 dest: BITMAP: The target bitmap to blit to.
2108 \end_layout
2110 \begin_layout Itemize
2111 dx: number: The x-coordinate in target.
2112 \end_layout
2114 \begin_layout Itemize
2115 dy: number: The y-coordinate in target.
2116 \end_layout
2118 \begin_layout Itemize
2119 src: BITMAP: The source bitmap.
2120 \end_layout
2122 \begin_layout Itemize
2123 sx: number: The x-coordinate in source.
2124 \end_layout
2126 \begin_layout Itemize
2127 sy: number: The y-coordinate in source.
2128 \end_layout
2130 \begin_layout Itemize
2131 w: number: The width of area to blit.
2132 \end_layout
2134 \begin_layout Itemize
2135 h: number: The height of area to blit.
2136 \end_layout
2138 \begin_layout Itemize
2139 hscl: number: Horizontal scale factor (integer).
2140 \end_layout
2142 \begin_layout Itemize
2143 vscl: number: Vertical scale factor (integer).
2144  Defaults to the same as <hscl>.
2145 \end_layout
2147 \begin_layout Itemize
2148 operator: string: The operator to use.
2149 \begin_inset Separator latexpar
2150 \end_inset
2153 \end_layout
2155 \begin_deeper
2156 \begin_layout Itemize
2157 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2158  DestOut, Clear or Xor.
2159 \end_layout
2161 \end_deeper
2162 \begin_layout Standard
2163 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2164  like BITMAP:blit_scaled.
2165 \end_layout
2167 \begin_layout Subsubsection
2168 Method blit_priority: Blit a bitmap into another with color priority
2169 \end_layout
2171 \begin_layout Itemize
2172 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2173 \end_layout
2175 \begin_layout Itemize
2176 Deprecated: gui.bitmap_blit_priority(dest, ...)
2177 \end_layout
2179 \begin_layout Standard
2180 Parameters:
2181 \end_layout
2183 \begin_layout Itemize
2184 dest: BITMAP: The target bitmap to blit to.
2185 \end_layout
2187 \begin_layout Itemize
2188 dx: number: The x-coordinate in target.
2189 \end_layout
2191 \begin_layout Itemize
2192 dy: number: The y-coordinate in target.
2193 \end_layout
2195 \begin_layout Itemize
2196 src: BITMAP: The source bitmap.
2197 \end_layout
2199 \begin_layout Itemize
2200 sx: number: The x-coordinate in source.
2201 \end_layout
2203 \begin_layout Itemize
2204 sy: number: The y-coordinate in source.
2205 \end_layout
2207 \begin_layout Itemize
2208 w: number: The width of area to blit.
2209 \end_layout
2211 \begin_layout Itemize
2212 h: number: The height of area to blit.
2213 \end_layout
2215 \begin_layout Standard
2216 Like BITMAP:blit, but only copy pixels where source color index is greater
2217  than destination color index.
2218 \end_layout
2220 \begin_layout Subsubsection
2221 Method blit_scaled_priority: Blit a bitmap into another with color priority
2222  and scaling
2223 \end_layout
2225 \begin_layout Itemize
2226 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2227 \end_layout
2229 \begin_layout Itemize
2230 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2231 \end_layout
2233 \begin_layout Standard
2234 Parameters:
2235 \end_layout
2237 \begin_layout Itemize
2238 dest: BITMAP: The target bitmap to blit to.
2239 \end_layout
2241 \begin_layout Itemize
2242 dx: number: The x-coordinate in target.
2243 \end_layout
2245 \begin_layout Itemize
2246 dy: number: The y-coordinate in target.
2247 \end_layout
2249 \begin_layout Itemize
2250 src: BITMAP: The source bitmap.
2251 \end_layout
2253 \begin_layout Itemize
2254 sx: number: The x-coordinate in source.
2255 \end_layout
2257 \begin_layout Itemize
2258 sy: number: The y-coordinate in source.
2259 \end_layout
2261 \begin_layout Itemize
2262 w: number: The width of area to blit.
2263 \end_layout
2265 \begin_layout Itemize
2266 h: number: The height of area to blit.
2267 \end_layout
2269 \begin_layout Itemize
2270 hscl: number: Horizontal scale factor (integer).
2271 \end_layout
2273 \begin_layout Itemize
2274 vscl: number: Vertical scale factor (integer).
2275  Defaults to the same as <hscl>.
2276 \end_layout
2278 \begin_layout Standard
2279 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2280 caled.
2281 \end_layout
2283 \begin_layout Subsubsection
2284 Method save_png: Save a bitmap to PNG
2285 \end_layout
2287 \begin_layout Itemize
2288 Syntax: bitmap:save_png(filename, [base], palette)
2289 \end_layout
2291 \begin_layout Itemize
2292 Syntax: data bitmap:save_png(palette)
2293 \end_layout
2295 \begin_layout Itemize
2296 Deprecated: ...
2297  gui.bitmap_save_png(bitmap, ...)
2298 \end_layout
2300 \begin_layout Standard
2301 Parameters:
2302 \end_layout
2304 \begin_layout Itemize
2305 bitmap: BITMAP: The bitmap to save.
2306 \end_layout
2308 \begin_layout Itemize
2309 filename: string: The filename to save to.
2310 \end_layout
2312 \begin_layout Itemize
2313 base: string: The base filename is resolved relative to.
2314 \end_layout
2316 \begin_layout Itemize
2317 palette: PALETTE: The palette to use.
2318 \end_layout
2320 \begin_layout Standard
2321 Return value:
2322 \end_layout
2324 \begin_layout Itemize
2325 data: string: BASE64 encoded PNG data.
2326 \end_layout
2328 \begin_layout Standard
2329 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2330  to <base>) or return BASE64 encoding of it.
2331 \end_layout
2333 \begin_layout Subsubsection
2334 Method hash: Hash a bitmap
2335 \end_layout
2337 \begin_layout Itemize
2338 Syntax: hash bitmap:hash()
2339 \end_layout
2341 \begin_layout Itemize
2342 Deprecated: hash bitmap:hash(bitmap)
2343 \end_layout
2345 \begin_layout Standard
2346 Parameters:
2347 \end_layout
2349 \begin_layout Itemize
2350 bitmap: BITMAP: The bitmap to hash.
2351 \end_layout
2353 \begin_layout Standard
2354 Return value:
2355 \end_layout
2357 \begin_layout Itemize
2358 hash: string: 64-hex digit hash
2359 \end_layout
2361 \begin_layout Standard
2362 Hashes bitmap <bitmap> and returns crypto-strong hash.
2364 \end_layout
2366 \begin_layout Itemize
2367 Color order in bitmap is significant.
2368 \end_layout
2370 \begin_layout Subsubsection
2371 Method sample_texture: Sample a texture
2372 \end_layout
2374 \begin_layout Itemize
2375 Syntax: none bitmap:sample_texture(BITMAP source, number xx, number xy,
2376  number x0, number yx, number yy, number y0, number scale, boolean wrap)
2377 \end_layout
2379 \begin_layout Standard
2380 Parameters:
2381 \end_layout
2383 \begin_layout Itemize
2384 source: BITMAP: The bitmap to sample
2385 \end_layout
2387 \begin_layout Itemize
2388 xx: number: s times the source x coefficient of target x axis.
2389 \end_layout
2391 \begin_layout Itemize
2392 xy: number: s times the source y coefficient of target x axis.
2393 \end_layout
2395 \begin_layout Itemize
2396 x0: number: s times the target x axis offset.
2397 \end_layout
2399 \begin_layout Itemize
2400 yx: number: s times the source x coefficient of target y axis.
2401 \end_layout
2403 \begin_layout Itemize
2404 yy: number: s times the source y coefficient of target y axis.
2405 \end_layout
2407 \begin_layout Itemize
2408 y0: number: s times the target y axis offset.
2409 \end_layout
2411 \begin_layout Itemize
2412 s: number: Scale of coordinates
2413 \end_layout
2415 \begin_layout Itemize
2416 wrap: boolean: If true, wrap the texture.
2417  If false, read outside the texture as color 0.
2418 \end_layout
2420 \begin_layout Standard
2421 Samples the source as texture, performing linear transform (with nearest-neighbo
2422 r sampling) and writes the result to this bitmap.
2423 \end_layout
2425 \begin_layout Subsubsection
2426 Method hflip: Horizontally flip a bitmap
2427 \end_layout
2429 \begin_layout Itemize
2430 Syntax: none bitmap:hflip()
2431 \end_layout
2433 \begin_layout Standard
2434 Horizontally flips a bitmap.
2435 \end_layout
2437 \begin_layout Subsubsection
2438 Method vflip: Vertically flip a bitmap
2439 \end_layout
2441 \begin_layout Itemize
2442 Syntax: none bitmap:vflip()
2443 \end_layout
2445 \begin_layout Standard
2446 Vertically flips a bitmap.
2447 \end_layout
2449 \begin_layout Standard
2450 \begin_inset Newpage pagebreak
2451 \end_inset
2454 \end_layout
2456 \begin_layout Subsection
2457 DBITMAP: Direct-color bitmap
2458 \end_layout
2460 \begin_layout Subsubsection
2461 Static function: new: Create a new bitmap
2462 \end_layout
2464 \begin_layout Itemize
2465 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2466 \end_layout
2468 \begin_layout Itemize
2469 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2470 \end_layout
2472 \begin_layout Itemize
2473 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2474 \end_layout
2476 \begin_layout Standard
2477 Parameters:
2478 \end_layout
2480 \begin_layout Itemize
2481 w: number: The width of new bitmap.
2482 \end_layout
2484 \begin_layout Itemize
2485 h: number: The height of new bitmap.
2486 \end_layout
2488 \begin_layout Itemize
2489 true: boolean: Fixed boolean true
2490 \end_layout
2492 \begin_layout Itemize
2493 fillcolor: The color to fill the bitmap with (default transparent).
2494 \end_layout
2496 \begin_layout Standard
2497 Return value:
2498 \end_layout
2500 \begin_layout Itemize
2501 bitmap: DBITMAP: The new bitmap.
2502 \end_layout
2504 \begin_layout Standard
2505 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2506  <fillcolor>.
2507 \end_layout
2509 \begin_layout Subsubsection
2510 Method draw: Draw a bitmap
2511 \end_layout
2513 \begin_layout Itemize
2514 Syntax: bitmap.draw(x, y)
2515 \end_layout
2517 \begin_layout Itemize
2518 Deprecated: gui.bitmap_draw(x, y, bitmap)
2519 \end_layout
2521 \begin_layout Standard
2522 Parameters:
2523 \end_layout
2525 \begin_layout Itemize
2526 bitmap: DBITMAP: The bitmap to draw.
2527 \end_layout
2529 \begin_layout Itemize
2530 x: number: X-coordinate on screen.
2531 \end_layout
2533 \begin_layout Itemize
2534 y: number: Y-coordinate on screen.
2535 \end_layout
2537 \begin_layout Standard
2538 Draw bitmap <bitmap> on screen at <x>,<y>.
2539 \end_layout
2541 \begin_layout Subsubsection
2542 Method draw_outside: Draw a bitmap outside game area
2543 \end_layout
2545 \begin_layout Itemize
2546 Syntax: dbitmap:draw_outside(x, y, palette)
2547 \end_layout
2549 \begin_layout Standard
2550 Like dbitmap:draw, but does not draw on game area.
2551 \end_layout
2553 \begin_layout Subsubsection
2554 Method draw_clip: Draw a bitmap, with clipping
2555 \end_layout
2557 \begin_layout Itemize
2558 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2559 \end_layout
2561 \begin_layout Standard
2562 Parameters:
2563 \end_layout
2565 \begin_layout Itemize
2566 bitmap: DBITMAP: The bitmap to draw
2567 \end_layout
2569 \begin_layout Itemize
2570 x: number: The x-coordinate on screen.
2571 \end_layout
2573 \begin_layout Itemize
2574 y: number: The y-coordinate on screen.
2575 \end_layout
2577 \begin_layout Itemize
2578 x0: The smallest bitmap x coordinate to draw.
2579 \end_layout
2581 \begin_layout Itemize
2582 y0: The smallest bitmap y coordinate to draw.
2583 \end_layout
2585 \begin_layout Itemize
2586 width: Width of region to draw
2587 \end_layout
2589 \begin_layout Itemize
2590 height: Height of region to draw.
2591 \end_layout
2593 \begin_layout Standard
2594 Like dbitmap:draw, but clip the bitmap area drawn.
2595 \end_layout
2597 \begin_layout Subsubsection
2598 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2599 \end_layout
2601 \begin_layout Itemize
2602 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2603 \end_layout
2605 \begin_layout Standard
2606 Like dbitmap:draw_clip, but only draw outside game area.
2607 \end_layout
2609 \begin_layout Subsubsection
2610 Method pset: Set pixel in bitmap
2611 \end_layout
2613 \begin_layout Itemize
2614 Syntax: bitmap:pset(x, y, color)
2615 \end_layout
2617 \begin_layout Itemize
2618 Deprecaed: gui.bitmap_pset(bitmap, ...)
2619 \end_layout
2621 \begin_layout Standard
2622 Parameters:
2623 \end_layout
2625 \begin_layout Itemize
2626 bitmap: DBITMAP: The bitmap to manipulate.
2627 \end_layout
2629 \begin_layout Itemize
2630 x: number: x-coordinate of pixel to set.
2631 \end_layout
2633 \begin_layout Itemize
2634 y: number: y-coordinate of pixel to set.
2635 \end_layout
2637 \begin_layout Itemize
2638 color: number/string: The color to set.
2639 \end_layout
2641 \begin_layout Standard
2642 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2643 \end_layout
2645 \begin_layout Subsubsection
2646 Method pget: Get pixel in bitmap
2647 \end_layout
2649 \begin_layout Itemize
2650 Syntax: color bitmap:pget(x,y)
2651 \end_layout
2653 \begin_layout Itemize
2654 Deprecated: color gui.bitmap_pget(bitmap, ...)
2655 \end_layout
2657 \begin_layout Standard
2658 Parameters:
2659 \end_layout
2661 \begin_layout Itemize
2662 bitmap: DBITMAP: The bitmap to query.
2663 \end_layout
2665 \begin_layout Itemize
2666 x: number: x-coordinate of pixel to get.
2667 \end_layout
2669 \begin_layout Itemize
2670 y: number: y-coordinate of pixel to get.
2671 \end_layout
2673 \begin_layout Standard
2674 Returns:
2675 \end_layout
2677 \begin_layout Itemize
2678 color: number: The color of specified pixel.
2679 \end_layout
2681 \begin_layout Standard
2682 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2683 \end_layout
2685 \begin_layout Subsubsection
2686 Method size: Get size of bitmap
2687 \end_layout
2689 \begin_layout Itemize
2690 Syntax: width, height bitmap:size()
2691 \end_layout
2693 \begin_layout Itemize
2694 Syntax: width, height gui.bitmap_size(bitmap)
2695 \end_layout
2697 \begin_layout Standard
2698 Parameters:
2699 \end_layout
2701 \begin_layout Itemize
2702 bitmap: DBITMAP: The bitmap to query.
2703 \end_layout
2705 \begin_layout Standard
2706 Returns:
2707 \end_layout
2709 \begin_layout Itemize
2710 width: number: The width of the bitmap.
2711 \end_layout
2713 \begin_layout Itemize
2714 height: number: The height of the bitmap.
2715 \end_layout
2717 \begin_layout Standard
2718 Get size of bitmap <bitmap>.
2719 \end_layout
2721 \begin_layout Subsubsection
2722 Method blit: Blit a bitmap into another
2723 \end_layout
2725 \begin_layout Itemize
2726 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2727 \end_layout
2729 \begin_layout Itemize
2730 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2731 \end_layout
2733 \begin_layout Itemize
2734 Deprecated: gui.bitmap_blit(dest, ...)
2735 \end_layout
2737 \begin_layout Standard
2738 Parameters:
2739 \end_layout
2741 \begin_layout Itemize
2742 dest: DBITMAP: The target bitmap to blit to.
2743 \end_layout
2745 \begin_layout Itemize
2746 dx: number: The x-coordinate in target.
2747 \end_layout
2749 \begin_layout Itemize
2750 dy: number: The y-coordinate in target.
2751 \end_layout
2753 \begin_layout Itemize
2754 src: BITMAP/DBITMAP: The source bitmap.
2755 \end_layout
2757 \begin_layout Itemize
2758 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2759 \end_layout
2761 \begin_layout Itemize
2762 sx: number: The x-coordinate in source.
2763 \end_layout
2765 \begin_layout Itemize
2766 sy: number: The y-coordinate in source.
2767 \end_layout
2769 \begin_layout Itemize
2770 w: number: The width of area to blit.
2771 \end_layout
2773 \begin_layout Itemize
2774 h: number: The height of area to blit.
2775 \end_layout
2777 \begin_layout Itemize
2778 ck: number: The color key.
2779  Pixels with this index are not copied.
2780 \begin_inset Separator latexpar
2781 \end_inset
2784 \end_layout
2786 \begin_deeper
2787 \begin_layout Itemize
2788 If none is specified, all pixels are copied.
2789 \end_layout
2791 \begin_layout Itemize
2792 If <src> is paletted, this is color index, otherwise it is a color.
2793 \end_layout
2795 \end_deeper
2796 \begin_layout Standard
2797 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2798  if indexed) into <dest> at <dx>,<dy>.
2799  If a color key <ck> is specified, pixels of that color are not copied.
2800 \end_layout
2802 \begin_layout Subsubsection
2803 Method blit_scaled: Blit a bitmap into another with scaling
2804 \end_layout
2806 \begin_layout Itemize
2807 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2808 \end_layout
2810 \begin_layout Itemize
2811 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2812  [ck])
2813 \end_layout
2815 \begin_layout Itemize
2816 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2817 \end_layout
2819 \begin_layout Standard
2820 Parameters:
2821 \end_layout
2823 \begin_layout Itemize
2824 dest: DBITMAP: The target bitmap to blit to.
2825 \end_layout
2827 \begin_layout Itemize
2828 dx: number: The x-coordinate in target.
2829 \end_layout
2831 \begin_layout Itemize
2832 dy: number: The y-coordinate in target.
2833 \end_layout
2835 \begin_layout Itemize
2836 src: BITMAP/DBITMAP: The source bitmap.
2837 \end_layout
2839 \begin_layout Itemize
2840 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2841 \end_layout
2843 \begin_layout Itemize
2844 sx: number: The x-coordinate in source.
2845 \end_layout
2847 \begin_layout Itemize
2848 sy: number: The y-coordinate in source.
2849 \end_layout
2851 \begin_layout Itemize
2852 w: number: The width of area to blit.
2853 \end_layout
2855 \begin_layout Itemize
2856 h: number: The height of area to blit.
2857 \end_layout
2859 \begin_layout Itemize
2860 hscl: number: Horizontal scale factor (integer).
2861 \end_layout
2863 \begin_layout Itemize
2864 vscl: number: Vertical scale factor (integer).
2865  Defaults to the same as <hscl>.
2866 \end_layout
2868 \begin_layout Itemize
2869 ck: number: The color key.
2870  Pixels with this index are not copied.
2871 \begin_inset Separator latexpar
2872 \end_inset
2875 \end_layout
2877 \begin_deeper
2878 \begin_layout Itemize
2879 If none is specified, all pixels are copied.
2880 \end_layout
2882 \begin_layout Itemize
2883 If <src> is paletted, this is color index, otherwise it is a color.
2884 \end_layout
2886 \end_deeper
2887 \begin_layout Standard
2888 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2889  neighbor) by factor of <hscl>*<vscl>.
2890 \end_layout
2892 \begin_layout Subsubsection
2893 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2894 \end_layout
2896 \begin_layout Itemize
2897 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2898 \end_layout
2900 \begin_layout Itemize
2901 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2902 \end_layout
2904 \begin_layout Itemize
2905 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2906 \end_layout
2908 \begin_layout Standard
2909 Parameters:
2910 \end_layout
2912 \begin_layout Itemize
2913 dest: DBITMAP: The target bitmap to blit to.
2914 \end_layout
2916 \begin_layout Itemize
2917 dx: number: The x-coordinate in target.
2918 \end_layout
2920 \begin_layout Itemize
2921 dy: number: The y-coordinate in target.
2922 \end_layout
2924 \begin_layout Itemize
2925 src: BITMAP/DBITMAP: The source bitmap.
2926 \end_layout
2928 \begin_layout Itemize
2929 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2930 \end_layout
2932 \begin_layout Itemize
2933 sx: number: The x-coordinate in source.
2934 \end_layout
2936 \begin_layout Itemize
2937 sy: number: The y-coordinate in source.
2938 \end_layout
2940 \begin_layout Itemize
2941 w: number: The width of area to blit.
2942 \end_layout
2944 \begin_layout Itemize
2945 h: number: The height of area to blit.
2946 \end_layout
2948 \begin_layout Itemize
2949 operator: string: The operator to use.
2950 \begin_inset Separator latexpar
2951 \end_inset
2954 \end_layout
2956 \begin_deeper
2957 \begin_layout Itemize
2958 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2959  DestOut, Clear or Xor.
2960 \end_layout
2962 \end_deeper
2963 \begin_layout Standard
2964 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2965 f operator.
2967 \end_layout
2969 \begin_layout Itemize
2970 In target, fully transparent is background.
2971  In source, either fully transparent (if direct) or index 0 (if paletted)
2972  is treated as background.
2973 \end_layout
2975 \begin_layout Subsubsection
2976 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2977  Porter-Duff composition
2978 \end_layout
2980 \begin_layout Itemize
2981 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2982  operator)
2983 \end_layout
2985 \begin_layout Itemize
2986 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2987  [vscl], operator)
2988 \end_layout
2990 \begin_layout Itemize
2991 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2992 \end_layout
2994 \begin_layout Standard
2995 Parameters:
2996 \end_layout
2998 \begin_layout Itemize
2999 dest: DBITMAP: The target bitmap to blit to.
3000 \end_layout
3002 \begin_layout Itemize
3003 dx: number: The x-coordinate in target.
3004 \end_layout
3006 \begin_layout Itemize
3007 dy: number: The y-coordinate in target.
3008 \end_layout
3010 \begin_layout Itemize
3011 src: BITMAP/DBITMAP: The source bitmap.
3012 \end_layout
3014 \begin_layout Itemize
3015 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
3016 \end_layout
3018 \begin_layout Itemize
3019 sx: number: The x-coordinate in source.
3020 \end_layout
3022 \begin_layout Itemize
3023 sy: number: The y-coordinate in source.
3024 \end_layout
3026 \begin_layout Itemize
3027 w: number: The width of area to blit.
3028 \end_layout
3030 \begin_layout Itemize
3031 h: number: The height of area to blit.
3032 \end_layout
3034 \begin_layout Itemize
3035 hscl: number: Horizontal scale factor (integer).
3036 \end_layout
3038 \begin_layout Itemize
3039 vscl: number: Vertical scale factor (integer).
3040  Defaults to the same as <hscl>.
3041 \end_layout
3043 \begin_layout Itemize
3044 operator: string: The operator to use.
3045 \begin_inset Separator latexpar
3046 \end_inset
3049 \end_layout
3051 \begin_deeper
3052 \begin_layout Itemize
3053 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
3054  DestOut, Clear or Xor.
3055 \end_layout
3057 \end_deeper
3058 \begin_layout Standard
3059 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
3060  like DBITMAP:blit_scaled.
3061 \end_layout
3063 \begin_layout Subsubsection
3064 Method adjust_transparency: Adjust transparency of bitmap
3065 \end_layout
3067 \begin_layout Itemize
3068 Syntax: bitmap:adjust_transparency(newvalue)
3069 \end_layout
3071 \begin_layout Itemize
3072 Deprecated: gui.adjust_transparency(bitmap, ...)
3073 \end_layout
3075 \begin_layout Standard
3076 Parameters:
3077 \end_layout
3079 \begin_layout Itemize
3080 bitmap: DBITMAP: The bitmap to adjust.
3081 \end_layout
3083 \begin_layout Itemize
3084 Number adj: The factor to multiply opaqueness with times 256.
3085 \end_layout
3087 \begin_layout Standard
3088 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
3089 \end_layout
3091 \begin_layout Subsubsection
3092 Method save_png: Save a bitmap to PNG
3093 \end_layout
3095 \begin_layout Itemize
3096 Syntax: bitmap:save_png(filename, [base])
3097 \end_layout
3099 \begin_layout Itemize
3100 Syntax: data bitmap:save_png()
3101 \end_layout
3103 \begin_layout Itemize
3104 Deprecated: ...
3105  gui.bitmap_save_png(bitmap, ...)
3106 \end_layout
3108 \begin_layout Standard
3109 Parameters:
3110 \end_layout
3112 \begin_layout Itemize
3113 bitmap: DBITMAP: The bitmap to save.
3114 \end_layout
3116 \begin_layout Itemize
3117 filename: string: The filename to save to.
3118 \end_layout
3120 \begin_layout Itemize
3121 base: string: The base filename is resolved relative to.
3122 \end_layout
3124 \begin_layout Standard
3125 Return value:
3126 \end_layout
3128 \begin_layout Itemize
3129 data: string: BASE64 encoded PNG data.
3130 \end_layout
3132 \begin_layout Standard
3133 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
3134  BASE64 encoding of it.
3135 \end_layout
3137 \begin_layout Subsubsection
3138 Method hash: Hash a bitmap
3139 \end_layout
3141 \begin_layout Itemize
3142 Syntax: hash bitmap:hash()
3143 \end_layout
3145 \begin_layout Itemize
3146 Deprecated: hash bitmap:hash(bitmap)
3147 \end_layout
3149 \begin_layout Standard
3150 Parameters:
3151 \end_layout
3153 \begin_layout Itemize
3154 bitmap: DBITMAP: The bitmap to hash.
3155 \end_layout
3157 \begin_layout Standard
3158 Return value:
3159 \end_layout
3161 \begin_layout Itemize
3162 hash: string: 64-hex digit hash
3163 \end_layout
3165 \begin_layout Standard
3166 Hashes bitmap <bitmap> and returns crypto-strong hash.
3168 \end_layout
3170 \begin_layout Subsubsection
3171 Method sample_texture: Sample a texture
3172 \end_layout
3174 \begin_layout Itemize
3175 Syntax: none bitmap:sample_texture(BITMAP source, number xx, number xy,
3176  number x0, number yx, number yy, number y0, number scale, boolean wrap)
3177 \end_layout
3179 \begin_layout Standard
3180 Parameters:
3181 \end_layout
3183 \begin_layout Itemize
3184 source: BITMAP: The bitmap to sample
3185 \end_layout
3187 \begin_layout Itemize
3188 xx: number: s times the source x coefficient of target x axis.
3189 \end_layout
3191 \begin_layout Itemize
3192 xy: number: s times the source y coefficient of target x axis.
3193 \end_layout
3195 \begin_layout Itemize
3196 x0: number: s times the target x axis offset.
3197 \end_layout
3199 \begin_layout Itemize
3200 yx: number: s times the source x coefficient of target y axis.
3201 \end_layout
3203 \begin_layout Itemize
3204 yy: number: s times the source y coefficient of target y axis.
3205 \end_layout
3207 \begin_layout Itemize
3208 y0: number: s times the target y axis offset.
3209 \end_layout
3211 \begin_layout Itemize
3212 s: number: Scale of coordinates
3213 \end_layout
3215 \begin_layout Itemize
3216 wrap: boolean: If true, wrap the texture.
3217  If false, read outside the texture as color 0.
3218 \end_layout
3220 \begin_layout Standard
3221 Samples the source as texture, performing linear transform (with nearest-neighbo
3222 r sampling) and writes the result to this bitmap.
3223 \end_layout
3225 \begin_layout Subsubsection
3226 Method hflip: Horizontally flip a bitmap
3227 \end_layout
3229 \begin_layout Itemize
3230 Syntax: none dbitmap:hflip()
3231 \end_layout
3233 \begin_layout Standard
3234 Horizontally flips a bitmap.
3235 \end_layout
3237 \begin_layout Subsubsection
3238 Method vflip: Vertically flip a bitmap
3239 \end_layout
3241 \begin_layout Itemize
3242 Syntax: none dbitmap:vflip()
3243 \end_layout
3245 \begin_layout Standard
3246 Vertically flips a bitmap.
3247 \end_layout
3249 \begin_layout Standard
3250 \begin_inset Newpage pagebreak
3251 \end_inset
3254 \end_layout
3256 \begin_layout Subsection
3257 IMAGELOADER: Load an image
3258 \end_layout
3260 \begin_layout Subsubsection
3261 Static function load: Load a bitmap from file
3262 \end_layout
3264 \begin_layout Itemize
3265 Syntax: bitmap, palette gui.image.load(file, [base])
3266 \end_layout
3268 \begin_layout Itemize
3269 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3270 \end_layout
3272 \begin_layout Itemize
3273 Deprecated: ...
3274  gui.bitmap_load(...)
3275 \end_layout
3277 \begin_layout Standard
3278 Parameters:
3279 \end_layout
3281 \begin_layout Itemize
3282 file: string: The file to read.
3283 \end_layout
3285 \begin_layout Itemize
3286 base: string: The base to resolve <file> relative to.
3287 \end_layout
3289 \begin_layout Standard
3290 Returns:
3291 \end_layout
3293 \begin_layout Itemize
3294 bitmap: BITMAP/DBITMAP: The new bitmap
3295 \end_layout
3297 \begin_layout Itemize
3298 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3299  nil.
3300 \end_layout
3302 \begin_layout Standard
3303 Load a new bitmap and return it (plus associated palette if any).
3304 \end_layout
3306 \begin_layout Subsubsection
3307 Static function load_str: Load a bitmap from string
3308 \end_layout
3310 \begin_layout Itemize
3311 Syntax: bitmap, palette gui.image.load_str(data)
3312 \end_layout
3314 \begin_layout Itemize
3315 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3316 \end_layout
3318 \begin_layout Itemize
3319 Deprecated: ...
3320  gui.bitmap_load_str(...)
3321 \end_layout
3323 \begin_layout Standard
3324 Parameters:
3325 \end_layout
3327 \begin_layout Itemize
3328 data: string: The image data
3329 \end_layout
3331 \begin_layout Standard
3332 Returns:
3333 \end_layout
3335 \begin_layout Itemize
3336 bitmap: BITMAP/DBITMAP: The new bitmap
3337 \end_layout
3339 \begin_layout Itemize
3340 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3341  nil.
3342 \end_layout
3344 \begin_layout Standard
3345 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3346  file.
3347 \end_layout
3349 \begin_layout Subsubsection
3350 Static function load_png: Load a bitmap from PNG file
3351 \end_layout
3353 \begin_layout Itemize
3354 Syntax: bitmap, palette gui.image.load_png(file, [base])
3355 \end_layout
3357 \begin_layout Itemize
3358 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3359 \end_layout
3361 \begin_layout Itemize
3362 Deprecated: ...
3363  gui.bitmap_load_png(...)
3364 \end_layout
3366 \begin_layout Standard
3367 Parameters:
3368 \end_layout
3370 \begin_layout Itemize
3371 file: string: The file to read.
3372 \end_layout
3374 \begin_layout Itemize
3375 base: string: The base to resolve <file> relative to.
3376 \end_layout
3378 \begin_layout Standard
3379 Returns:
3380 \end_layout
3382 \begin_layout Itemize
3383 bitmap: BITMAP/DBITMAP: The new bitmap
3384 \end_layout
3386 \begin_layout Itemize
3387 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3388  nil.
3389 \end_layout
3391 \begin_layout Standard
3392 Like IMAGELOADER:load, but load a PNG file instead.
3393 \end_layout
3395 \begin_layout Subsubsection
3396 Static function load_png_str: Load a PNG bitmap from string
3397 \end_layout
3399 \begin_layout Itemize
3400 Syntax: bitmap, palette gui.image.load_png_str(data)
3401 \end_layout
3403 \begin_layout Itemize
3404 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3405 \end_layout
3407 \begin_layout Itemize
3408 Deprecated: ...
3409  gui.bitmap_load_png_str(...)
3410 \end_layout
3412 \begin_layout Standard
3413 Parameters:
3414 \end_layout
3416 \begin_layout Itemize
3417 data: string: The image data, base64 encoded.
3418 \end_layout
3420 \begin_layout Standard
3421 Returns:
3422 \end_layout
3424 \begin_layout Itemize
3425 bitmap: BITMAP/DBITMAP: The new bitmap
3426 \end_layout
3428 \begin_layout Itemize
3429 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3430  nil.
3431 \end_layout
3433 \begin_layout Standard
3434 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3435  <data> instead of file.
3436 \end_layout
3438 \begin_layout Standard
3439 \begin_inset Newpage pagebreak
3440 \end_inset
3443 \end_layout
3445 \begin_layout Subsection
3446 CUSTOMFONT: Arbitrary-sized bitmap font
3447 \end_layout
3449 \begin_layout Subsubsection
3450 Static function new: Return a new empty font
3451 \end_layout
3453 \begin_layout Itemize
3454 Syntax: font gui.font.new()
3455 \end_layout
3457 \begin_layout Itemize
3458 Syntax: font classes.CUSTOMFONT.new()
3459 \end_layout
3461 \begin_layout Itemize
3462 Deprecated: font gui.font_new()
3463 \end_layout
3465 \begin_layout Standard
3466 Return value:
3467 \end_layout
3469 \begin_layout Itemize
3470 font: CUSTOMFONT: New font.
3471 \end_layout
3473 \begin_layout Standard
3474 Create a new font with no characters and return it.
3475 \end_layout
3477 \begin_layout Subsubsection
3478 Static function: load: Load a font file
3479 \end_layout
3481 \begin_layout Itemize
3482 Syntax: font gui.font.load(file, [base])
3483 \end_layout
3485 \begin_layout Itemize
3486 Syntax: font gui.font.load()
3487 \end_layout
3489 \begin_layout Itemize
3490 Syntax: font classes.CUSTOMFONT.load(file, [base])
3491 \end_layout
3493 \begin_layout Itemize
3494 Syntax: font classes.CUSTOMFONT.load()
3495 \end_layout
3497 \begin_layout Itemize
3498 Deprecated: font gui.loadfont(...)
3499 \end_layout
3501 \begin_layout Standard
3502 Parameters:
3503 \end_layout
3505 \begin_layout Itemize
3506 file: string: The file to read the font from
3507 \end_layout
3509 \begin_layout Itemize
3510 base: string: The file to resolve <file> relative to.
3511 \end_layout
3513 \begin_layout Standard
3514 Return value:
3515 \end_layout
3517 \begin_layout Itemize
3518 font: CUSTOMFONT: New font.
3519 \end_layout
3521 \begin_layout Standard
3522 Load font from file <file> (relative to <base>).
3523  If no filename is given, system default font is loaded.
3524 \end_layout
3526 \begin_layout Subsubsection
3527 operator(): Render text to screen
3528 \end_layout
3530 \begin_layout Itemize
3531 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3532 \end_layout
3534 \begin_layout Standard
3535 Parmeters:
3536 \end_layout
3538 \begin_layout Itemize
3539 font: CUSTOMFONT: The font to use.
3540 \end_layout
3542 \begin_layout Itemize
3543 x: number: The x-position on screen to draw to.
3544 \end_layout
3546 \begin_layout Itemize
3547 y: number: The y-position on screen to draw to.
3548 \end_layout
3550 \begin_layout Itemize
3551 text: string: The text to draw.
3552 \end_layout
3554 \begin_layout Itemize
3555 fgc: number/string: Foreground color (default white).
3556 \end_layout
3558 \begin_layout Itemize
3559 bgc: number/string: Background color (default transparent).
3560 \end_layout
3562 \begin_layout Itemize
3563 hlc: number/string: Outline color (default transparent).
3564 \end_layout
3566 \begin_layout Standard
3567 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3568  onto screen.
3569 \end_layout
3571 \begin_layout Itemize
3572 If <hlc> is transparent, no outline is drawn.
3573 \end_layout
3575 \begin_layout Subsubsection
3576 Method edit: Alter glyph in font
3577 \end_layout
3579 \begin_layout Itemize
3580 Syntax: font:edit(string character, bitmap glyph)
3581 \end_layout
3583 \begin_layout Standard
3584 Parameters:
3585 \end_layout
3587 \begin_layout Itemize
3588 font: CUSTOMFONT: The font to edit.
3589 \end_layout
3591 \begin_layout Itemize
3592 character: string: The character to edit (UTF-8 encoded).
3593 \end_layout
3595 \begin_layout Itemize
3596 glyph: BITMAP: The bitmap to use.
3597 \end_layout
3599 \begin_layout Standard
3600 Replace character <character> in font <font> by <glyph>.
3601 \end_layout
3603 \begin_layout Itemize
3604 Color index 0 is background, everything else is foreground.
3605 \end_layout
3607 \begin_layout Itemize
3608 <character> may be empty string, meaning the replacement character used
3609  for bad characters.
3610 \end_layout
3612 \begin_layout Itemize
3613 <character> may be multi-codepoint string, meaning character used for that
3614  ligature.
3615 \end_layout
3617 \begin_layout Subsubsection
3618 Method dump: Dump font into file
3619 \end_layout
3621 \begin_layout Itemize
3622 Syntax: font:dump(string filename[, string base])
3623 \end_layout
3625 \begin_layout Standard
3626 Parameters:
3627 \end_layout
3629 \begin_layout Itemize
3630 filename: string: The file to dump to
3631 \end_layout
3633 \begin_layout Itemize
3634 base: string: The base filename
3635 \end_layout
3637 \begin_layout Standard
3638 Dump contents of <font> in file <filename> (resolved relative to <base>).
3639  The dump is in format CUSTOMFONT:load() can load.
3640 \end_layout
3642 \begin_layout Standard
3643 \begin_inset Newpage pagebreak
3644 \end_inset
3647 \end_layout
3649 \begin_layout Subsection
3650 ICONV: Character set conversions
3651 \end_layout
3653 \begin_layout Subsubsection
3654 Static function new: Create new character set converter
3655 \end_layout
3657 \begin_layout Itemize
3658 Syntax: iconv iconv.new(from, to);
3659 \end_layout
3661 \begin_layout Itemize
3662 Syntax: iconv classes.ICONV.new(from, to);
3663 \end_layout
3665 \begin_layout Itemize
3666 Deprecated: iconv iconv_new(...);
3667 \end_layout
3669 \begin_layout Standard
3670 Parameters:
3671 \end_layout
3673 \begin_layout Itemize
3674 from: string: The source character set.
3675 \end_layout
3677 \begin_layout Itemize
3678 to: string: The target character set.
3679 \end_layout
3681 \begin_layout Standard
3682 Returns:
3683 \end_layout
3685 \begin_layout Itemize
3686 iconv: ICONV: The converter.
3687 \end_layout
3689 \begin_layout Standard
3690 Create a character set converter, converting from <from> to <to> and return
3691  it.
3692 \end_layout
3694 \begin_layout Subsubsection
3695 Operator(): Convert string fragment from character set to another
3696 \end_layout
3698 \begin_layout Itemize
3699 Syntax: success, result, unconverted, error iconv(input)
3700 \end_layout
3702 \begin_layout Standard
3703 Parameters:
3704 \end_layout
3706 \begin_layout Itemize
3707 iconv: ICONV: The context to use.
3708 \end_layout
3710 \begin_layout Itemize
3711 input: string: The input to convert.
3712 \end_layout
3714 \begin_layout Standard
3715 Return value:
3716 \end_layout
3718 \begin_layout Itemize
3719 success: boolean: True if conversion was successful, false if not.
3720 \end_layout
3722 \begin_layout Itemize
3723 result: string: The string (partially) converted.
3724 \end_layout
3726 \begin_layout Itemize
3727 unconvered: number: Number of bytes that were not converted (only if <success>
3728  is false).
3729 \end_layout
3731 \begin_layout Itemize
3732 error: string: Error that caused conversion to stop (only if <success> is
3733  false).
3734 \begin_inset Separator latexpar
3735 \end_inset
3738 \end_layout
3740 \begin_deeper
3741 \begin_layout Itemize
3742 INVALID: The input string is invalid.
3743 \end_layout
3745 \begin_layout Itemize
3746 INCOMPLETE: The input string cuts off in middle of character.
3747 \end_layout
3749 \begin_layout Itemize
3750 INTERNALERR: Internal error.
3751 \end_layout
3753 \end_deeper
3754 \begin_layout Standard
3755 Convert a string <input> using character set converter <iconv> and return
3756  the result.
3757 \end_layout
3759 \begin_layout Standard
3760 \begin_inset Newpage pagebreak
3761 \end_inset
3764 \end_layout
3766 \begin_layout Subsection
3767 FILEREADER: Read a file as a stream
3768 \end_layout
3770 \begin_layout Subsubsection
3771 Static function open: Open a stream
3772 \end_layout
3774 \begin_layout Itemize
3775 Syntax: handle filereader.open(file, [base])
3776 \end_layout
3778 \begin_layout Itemize
3779 Syntax: handle classes.FILEREADER.open(file, [base])
3780 \end_layout
3782 \begin_layout Itemize
3783 Deprecated: handle open_file(file, [base])
3784 \end_layout
3786 \begin_layout Standard
3787 Parameters:
3788 \end_layout
3790 \begin_layout Itemize
3791 file: string: The filename to read.
3792 \end_layout
3794 \begin_layout Itemize
3795 base: string: The base <file> is resolved against.
3796 \end_layout
3798 \begin_layout Standard
3799 Returns:
3800 \end_layout
3802 \begin_layout Itemize
3803 handle: FILEREADER: The new file reader.
3804 \end_layout
3806 \begin_layout Standard
3807 Open file <file> (relative to <base>) and return a handle to it.
3808 \end_layout
3810 \begin_layout Subsubsection
3811 operator(): Read line/bytes from stream
3812 \end_layout
3814 \begin_layout Itemize
3815 Syntax: result handle()
3816 \end_layout
3818 \begin_layout Itemize
3819 Syntax: result handle(bytes)
3820 \end_layout
3822 \begin_layout Standard
3823 Parameters:
3824 \end_layout
3826 \begin_layout Itemize
3827 handle: FILEREADER: The handle to read from.
3828 \end_layout
3830 \begin_layout Itemize
3831 bytes: Number of bytes to read (default is next line).
3832 \end_layout
3834 \begin_layout Standard
3835 Returns:
3836 \end_layout
3838 \begin_layout Itemize
3839 result: string: The read data, or nil on end-of-file.
3840 \end_layout
3842 \begin_layout Standard
3843 Reads next line or <bytes> bytes from specified file handle <handle>.
3844 \end_layout
3846 \begin_layout Itemize
3847 If reading specified number of bytes, the bytes are read in binary mode
3848  (as-is).
3849 \end_layout
3851 \begin_layout Itemize
3852 If reading next line, the line is read in text mode (any line ending is
3853  skpped).
3854 \end_layout
3856 \begin_layout Subsubsection
3857 Method lines: Iterator to read all lines
3858 \end_layout
3860 \begin_layout Itemize
3861 Syntax: for line in handle:lines() do ...
3862  end
3863 \end_layout
3865 \begin_layout Standard
3866 Parameters:
3867 \end_layout
3869 \begin_layout Itemize
3870 handle: FILEREADER: The handle to read.
3871 \end_layout
3873 \begin_layout Standard
3874 Returns:
3875 \end_layout
3877 \begin_layout Itemize
3878 A lua iterator with one variable.
3879 \end_layout
3881 \begin_layout Standard
3882 Return a Lua iterator that iterates all the lines in <handle>.
3883 \end_layout
3885 \begin_layout Standard
3886 \begin_inset Newpage pagebreak
3887 \end_inset
3890 \end_layout
3892 \begin_layout Subsection
3893 COMPARE_OBJ: Watch memory area for changes
3894 \end_layout
3896 \begin_layout Standard
3897 Objects of this class allow fast checking for modifications to given memory
3898  block.
3899 \end_layout
3901 \begin_layout Subsubsection
3902 Static function new: Create a checker
3903 \end_layout
3905 \begin_layout Itemize
3906 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3907  stride])
3908 \end_layout
3910 \begin_layout Itemize
3911 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3912 \end_layout
3914 \begin_layout Standard
3915 Parameters:
3916 \end_layout
3918 \begin_layout Itemize
3919 marea: string: The memory area to interpret <offset> against.
3920 \end_layout
3922 \begin_layout Itemize
3923 offset: number: The initial offset in memory area.
3924 \end_layout
3926 \begin_layout Itemize
3927 addrobj: ADDRESS: The memory address.
3928 \end_layout
3930 \begin_layout Itemize
3931 size: number: The number of bytes in each row.
3932 \end_layout
3934 \begin_layout Itemize
3935 rows: number: The number of rows.
3936  Default is 1.
3937 \end_layout
3939 \begin_layout Itemize
3940 stride: number: The number of bytes offset increments from one row to next.
3941 \end_layout
3943 \begin_layout Standard
3944 Returns:
3945 \end_layout
3947 \begin_layout Itemize
3948 A handle to object.
3949 \end_layout
3951 \begin_layout Standard
3952 Return an object watching specified memory area.
3953 \end_layout
3955 \begin_layout Itemize
3956 Note: For fastest operation, limit checks to inside one memory area (that
3957  has to be mappable, individual RAM areas often are).
3958 \end_layout
3960 \begin_layout Subsubsection
3961 operator(): Check area for modifications
3962 \end_layout
3964 \begin_layout Itemize
3965 Syntax: boolean handle()
3966 \end_layout
3968 \begin_layout Standard
3969 Returns:
3970 \end_layout
3972 \begin_layout Itemize
3973 True if memory block has been modified since last call (or object creation
3974  if first call), false if not.
3975 \end_layout
3977 \begin_layout Standard
3978 Check if the block has been modified.
3979 \end_layout
3981 \begin_layout Subsection
3982 ADDRESS: Memory address
3983 \end_layout
3985 \begin_layout Standard
3986 Objects of this class contain a memory address.
3987 \end_layout
3989 \begin_layout Subsubsection
3990 Static function new: Create new memory address
3991 \end_layout
3993 \begin_layout Itemize
3994 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
3995 \end_layout
3997 \begin_layout Itemize
3998 Syntax: ADDRESS memory.address.new(string marea, number offset)
3999 \end_layout
4001 \begin_layout Itemize
4002 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
4003 \end_layout
4005 \begin_layout Standard
4006 Parameters:
4007 \end_layout
4009 \begin_layout Itemize
4010 marea: The memory area
4011 \end_layout
4013 \begin_layout Itemize
4014 offset: The offset in memory area.
4015 \end_layout
4017 \begin_layout Standard
4018 Returns:
4019 \end_layout
4021 \begin_layout Itemize
4022 The memory area.
4023 \end_layout
4025 \begin_layout Standard
4026 Construct a new memory address object.
4027 \end_layout
4029 \begin_layout Subsubsection
4030 Method: addr: Get global address
4031 \end_layout
4033 \begin_layout Itemize
4034 Syntax: number addr:addr()
4035 \end_layout
4037 \begin_layout Standard
4038 Parameters:
4039 \end_layout
4041 \begin_layout Itemize
4042 addr: ADRESS: The original address.
4043 \end_layout
4045 \begin_layout Standard
4046 Returns:
4047 \end_layout
4049 \begin_layout Itemize
4050 The global address corresponding to this address.
4051 \end_layout
4053 \begin_layout Subsubsection
4054 Method: vma: Get memory area
4055 \end_layout
4057 \begin_layout Itemize
4058 Syntax: string addr:vma()
4059 \end_layout
4061 \begin_layout Standard
4062 Parameters:
4063 \end_layout
4065 \begin_layout Itemize
4066 addr: ADRESS: The original address.
4067 \end_layout
4069 \begin_layout Standard
4070 Returns:
4071 \end_layout
4073 \begin_layout Itemize
4074 The memory area corresponding to this address.
4075 \end_layout
4077 \begin_layout Subsubsection
4078 Method: offset: Get memory area offset
4079 \end_layout
4081 \begin_layout Itemize
4082 Syntax: string addr:offset()
4083 \end_layout
4085 \begin_layout Standard
4086 Parameters:
4087 \end_layout
4089 \begin_layout Itemize
4090 addr: ADRESS: The original address.
4091 \end_layout
4093 \begin_layout Standard
4094 Returns:
4095 \end_layout
4097 \begin_layout Itemize
4098 The offset in memory area corresponding to this address.
4099 \end_layout
4101 \begin_layout Subsubsection
4102 Method: replace: Replace address part
4103 \end_layout
4105 \begin_layout Itemize
4106 Syntax: ADDRESS addr:replace(offset[, bits])
4107 \end_layout
4109 \begin_layout Standard
4110 Parameters:
4111 \end_layout
4113 \begin_layout Itemize
4114 addr: ADRESS: The original address.
4115 \end_layout
4117 \begin_layout Itemize
4118 offset: number: The new offset
4119 \end_layout
4121 \begin_layout Itemize
4122 bits: number: The number of LSB to replace.
4123 \end_layout
4125 \begin_layout Standard
4126 Returns:
4127 \end_layout
4129 \begin_layout Itemize
4130 The modified address
4131 \end_layout
4133 \begin_layout Standard
4134 Returns a new address, with <bits> (all if missing) least significant bits
4135  of <addr> replaced by LSB of <offset>.
4136 \end_layout
4138 \begin_layout Subsubsection
4139 Method: add: Add to address
4140 \end_layout
4142 \begin_layout Itemize
4143 Syntax: ADDRESS addr:add(offset)
4144 \end_layout
4146 \begin_layout Itemize
4147 Syntax: ADDRESS addr:add(number, stride)
4148 \end_layout
4150 \begin_layout Itemize
4151 Syntax: ADDRESS addr:add(number, stride, offset)
4152 \end_layout
4154 \begin_layout Standard
4155 Parameters:
4156 \end_layout
4158 \begin_layout Itemize
4159 addr: ADRESS: The original address.
4160 \end_layout
4162 \begin_layout Itemize
4163 offset: number: Offset to add.
4164 \end_layout
4166 \begin_layout Itemize
4167 number: number: Number of table strides to add.
4168 \end_layout
4170 \begin_layout Itemize
4171 stride: number: The table stride.
4172 \end_layout
4174 \begin_layout Standard
4175 Returns:
4176 \end_layout
4178 \begin_layout Itemize
4179 The modified address
4180 \end_layout
4182 \begin_layout Standard
4183 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
4184  address <addr>.
4185 \end_layout
4187 \begin_layout Subsection
4188 ADDRESS:<op>: Read/Write memory
4189 \end_layout
4191 \begin_layout Itemize
4192 Syntax: none addr:<op>(value)
4193 \end_layout
4195 \begin_layout Itemize
4196 Syntax: number addr:<op>()
4197 \end_layout
4199 \begin_layout Standard
4200 Parameters:
4201 \end_layout
4203 \begin_layout Itemize
4204 addr: ADDRESS: The address to read/write.
4205 \end_layout
4207 \begin_layout Itemize
4208 value: number: The number to write.
4209 \end_layout
4211 \begin_layout Standard
4212 Returns:
4213 \end_layout
4215 \begin_layout Itemize
4216 The value read.
4217 \end_layout
4219 \begin_layout Standard
4220 Read/Write value from/to given address <addr>.
4221  The value written is <value>.
4222  <Op> is of form: [i][s]<type>, where:
4223 \end_layout
4225 \begin_layout Itemize
4226 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4227 \end_layout
4229 \begin_layout Itemize
4230 'i' signifies that the value is treated as opposite-to-normal endianess,
4231 \end_layout
4233 \begin_layout Itemize
4234 's' signifies that value is treated as signed (not available for floating-point).
4235 \end_layout
4237 \begin_layout Standard
4238 \begin_inset Newpage pagebreak
4239 \end_inset
4242 \end_layout
4244 \begin_layout Section
4245 Global
4246 \end_layout
4248 \begin_layout Subsection
4249 print: Print values to console
4250 \end_layout
4252 \begin_layout Itemize
4253 Syntax: none print(value...
4254  values)
4255 \end_layout
4257 \begin_layout Standard
4258 Prints specified values to console.
4259  Can print any Lua type at least enough to identify the type and instance.
4260 \end_layout
4262 \begin_layout Subsection
4263 tostringx: Format a value to string
4264 \end_layout
4266 \begin_layout Itemize
4267 Syntax: string tostringx(value val)
4268 \end_layout
4270 \begin_layout Standard
4271 Formats value <val> like print would, and returns the result as a string.
4272 \end_layout
4274 \begin_layout Subsection
4275 exec: Execute lsnes commands
4276 \end_layout
4278 \begin_layout Itemize
4279 Syntax: none exec(string cmd)
4280 \end_layout
4282 \begin_layout Standard
4283 Execute lsnes command <cmd>.
4284 \end_layout
4286 \begin_layout Subsection
4287 utime: Get current time
4288 \end_layout
4290 \begin_layout Itemize
4291 Syntax: (number,number) utime()
4292 \end_layout
4294 \begin_layout Standard
4295 Returns two numbers.
4296  First is time since some epoch in seconds, the second is microseconds mod
4297  10^6 since that epoch.
4298 \end_layout
4300 \begin_layout Subsection
4301 set_idle_timeout: Run function after timeout when emulator is idle
4302 \end_layout
4304 \begin_layout Itemize
4305 Syntax: none set_idle_timeout(number timeout)
4306 \end_layout
4308 \begin_layout Standard
4309 Set number of microseconds to block idle for.
4310  After this timeout has expired, on_idle() will be called once.
4311 \end_layout
4313 \begin_layout Subsection
4314 set_timer_timeout: Run function after timeout.
4315 \end_layout
4317 \begin_layout Itemize
4318 Syntax: none set_timer_timeout(number timeout)
4319 \end_layout
4321 \begin_layout Standard
4322 Set number of microseconds to block timer for.
4323  After this timeout has expired, on_timer() will be called once.
4324 \end_layout
4326 \begin_layout Subsection
4327 bus_address: Look up address in system bus.
4328 \end_layout
4330 \begin_layout Itemize
4331 Syntax: none bus_address(number bus_addr)
4332 \end_layout
4334 \begin_layout Standard
4335 Returns virtual address corresponding to specified address on system bus.
4336 \end_layout
4338 \begin_layout Subsection
4339 loopwrapper: Convert loop into callable function
4340 \end_layout
4342 \begin_layout Itemize
4343 Syntax: function loopwrapper(function fun, ...)
4344 \end_layout
4346 \begin_layout Standard
4347 Calls function <fun> with function and specified arguments.
4348  The function passed suspends execution until the function returned is called.
4349  Handy for linear flow control among multiple invocations of a hook.
4350  Example code:
4351 \end_layout
4353 \begin_layout LyX-Code
4354 on_paint = loopwrapper(function(wait)
4355 \begin_inset Separator latexpar
4356 \end_inset
4359 \end_layout
4361 \begin_deeper
4362 \begin_layout LyX-Code
4363 while true do
4364 \begin_inset Separator latexpar
4365 \end_inset
4368 \end_layout
4370 \begin_deeper
4371 \begin_layout LyX-Code
4372 gui.text(0, 0, 
4373 \begin_inset Quotes eld
4374 \end_inset
4376 Test!
4377 \begin_inset Quotes erd
4378 \end_inset
4381 \end_layout
4383 \begin_layout LyX-Code
4384 wait();
4385 \end_layout
4387 \end_deeper
4388 \begin_layout LyX-Code
4390 \end_layout
4392 \end_deeper
4393 \begin_layout LyX-Code
4394 end);
4395 \end_layout
4397 \begin_layout Subsection
4398 list_bindings: List keybindings
4399 \end_layout
4401 \begin_layout Itemize
4402 Syntax: table list_bindings([string cmd])
4403 \end_layout
4405 \begin_layout Standard
4406 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4407  If <cmd> is specified, the table is limited to that command.
4408  Also searches for controller keys.
4409 \end_layout
4411 \begin_layout Subsection
4412 get_alias: Get expansion of alias
4413 \end_layout
4415 \begin_layout Itemize
4416 Syntax: string get_alias(string aname)
4417 \end_layout
4419 \begin_layout Standard
4420 Get expansion of given alias <aname>.
4421 \end_layout
4423 \begin_layout Subsection
4424 set_alias: Set expansion of alias
4425 \end_layout
4427 \begin_layout Itemize
4428 Syntax: none set_alias(string aname, string value)
4429 \end_layout
4431 \begin_layout Standard
4432 Set expansion of given alias.
4433 \end_layout
4435 \begin_layout Subsection
4436 create_ibind: Create invese binding
4437 \end_layout
4439 \begin_layout Itemize
4440 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4441 \end_layout
4443 \begin_layout Standard
4444 Return object representing inverse binding with specified name <name> and
4445  specified command <cmd>.
4446 \end_layout
4448 \begin_layout Itemize
4449 Note: To create press/release commands, use aliases +foo and -foo .
4450 \end_layout
4452 \begin_layout Itemize
4453 Note: Keep the returned object around.
4454 \end_layout
4456 \begin_layout Subsection
4457 create_command: Create a command
4458 \end_layout
4460 \begin_layout Itemize
4461 Syntax: COMMANDBIND create_command(string name, function a)
4462 \end_layout
4464 \begin_layout Itemize
4465 Syntax: COMMANDBIND create_command(string name, function a, function b)
4466 \end_layout
4468 \begin_layout Standard
4469 Return object representing a command (pair).
4470 \end_layout
4472 \begin_layout Itemize
4473 If only one function is specied, the command is level-sensitive, <a> is
4474  callback.
4475 \end_layout
4477 \begin_layout Itemize
4478 If <b> is function, the function is edge-sensitive, <a> is positive edge
4479  callback and <b> is negative edge callback.
4480 \end_layout
4482 \begin_layout Itemize
4483 All callbacks get single argument: The parameters passed.
4484 \end_layout
4486 \begin_layout Itemize
4487 Keep the returned object around.
4488 \end_layout
4490 \begin_layout Subsection
4491 loadfile: Load Lua script
4492 \end_layout
4494 \begin_layout Itemize
4495 Syntax: function loadfile(string filename[, string base])
4496 \end_layout
4498 \begin_layout Standard
4499 Load lua script from <filename>, resolved relative to <base> (if empty,
4500  current directory).
4501 \end_layout
4503 \begin_layout Subsection
4504 dofile: Execute Lua script
4505 \end_layout
4507 \begin_layout Itemize
4508 Syntax: function dofile(string filename[, string base])
4509 \end_layout
4511 \begin_layout Standard
4512 Execute lua script from <filename>, resolved relative to <base> (if empty,
4513  current directory) and return all return values.
4514 \end_layout
4516 \begin_layout Subsection
4517 resolve_filename: Resolve name of file relative to another
4518 \end_layout
4520 \begin_layout Itemize
4521 Syntax: string resolve_filename(string filename[, string base])
4522 \end_layout
4524 \begin_layout Standard
4525 Resolve name of file <filename> relative to <base> and return the result.
4526 \end_layout
4528 \begin_layout Subsection
4529 render_queue_function: Return paint function for render queue
4530 \end_layout
4532 \begin_layout Itemize
4533 Syntax: function render_queue_function(RENDERQUEUE rq)
4534 \end_layout
4536 \begin_layout Standard
4537 Return function that renders render queue <rq>.
4538 \end_layout
4540 \begin_layout Itemize
4541 Handy for paint callback if one is using render queues updated in other
4542  callbacks.
4543  As in:
4544 \end_layout
4546 \begin_layout LyX-Code
4547 handle = callback.paint:register(render_queue_function(my_rq));
4548 \end_layout
4550 \begin_layout Subsection
4551 get_directory_contents: Get files in directory
4552 \end_layout
4554 \begin_layout Itemize
4555 Syntax: table get_directory_contents(string name[, string base[, string
4556  pattern]])
4557 \end_layout
4559 \begin_layout Standard
4560 Return array containg all files in specified directory <name> (relative
4561  to <base>).
4562  If <pattern> is specified, the filenames are matched to specified regex.
4563  The returned filenames inherit path.
4564 \end_layout
4566 \begin_layout Subsection
4567 get_file_type: Get type of file
4568 \end_layout
4570 \begin_layout Itemize
4571 Syntax: string/nil get_file_type(string path)
4572 \end_layout
4574 \begin_layout Standard
4575 Return type of file <path>.
4576  Currently possible return values are:
4577 \end_layout
4579 \begin_layout Itemize
4580 regular: regular file
4581 \end_layout
4583 \begin_layout Itemize
4584 directory: subdirectory
4585 \end_layout
4587 \begin_layout Itemize
4588 unknown: Exists, but type not known (not anything above).
4589 \end_layout
4591 \begin_layout Itemize
4592 <nil>: File does not exist.
4593 \end_layout
4595 \begin_layout Subsection
4596 identify_class: Identify class of object
4597 \end_layout
4599 \begin_layout Itemize
4600 Syntax: string identify_class(userdata object)
4601 \end_layout
4603 \begin_layout Standard
4604 Identifies the class of userdata <object>, if possible.
4605  If no identification is possible, returns 
4606 \begin_inset Quotes eld
4607 \end_inset
4609 unknown
4610 \begin_inset Quotes erd
4611 \end_inset
4614 \end_layout
4616 \begin_layout Subsection
4617 lookup_class: Lookup class by name
4618 \end_layout
4620 \begin_layout Itemize
4621 Syntax: classobj lookup_class(string name)
4622 \end_layout
4624 \begin_layout Standard
4625 Looks up class corresponding to <name>, if possible.
4626  If not found, returns nil.
4627  The classobj has following fields:
4628 \end_layout
4630 \begin_layout Itemize
4631 _static_methods: Return static method names
4632 \end_layout
4634 \begin_layout Itemize
4635 _class_methods: Return class method names
4636 \end_layout
4638 \begin_layout Itemize
4639 <static-function-name>: The specified static function.
4640 \end_layout
4642 \begin_layout Subsection
4643 all_classes: Get list of all classes
4644 \end_layout
4646 \begin_layout Itemize
4647 Syntax: string...
4648  all_classes()
4649 \end_layout
4651 \begin_layout Standard
4652 Get names of all classes available.
4653 \end_layout
4655 \begin_layout Subsection
4656 lsnes_features: Read feature flags
4657 \end_layout
4659 \begin_layout Itemize
4660 Syntax: boolean lsnes_features(string feature)
4661 \end_layout
4663 \begin_layout Standard
4664 Checks if feature <feature> is available, if it is, returns true, otherwise
4665  returns false.
4666  The following features are known:
4667 \end_layout
4669 \begin_layout Itemize
4670 text-halos: gui.text supports halos (takes halo color argument).
4671 \end_layout
4673 \begin_layout Subsection
4674 icnov: Class ICONV
4675 \end_layout
4677 \begin_layout Standard
4678 See class ICONV.
4679 \end_layout
4681 \begin_layout Subsection
4682 filereader: Class FILEREADER
4683 \end_layout
4685 \begin_layout Standard
4686 See class FILEREADER.
4687 \end_layout
4689 \begin_layout Standard
4690 \begin_inset Newpage pagebreak
4691 \end_inset
4694 \end_layout
4696 \begin_layout Section
4697 Table bit:
4698 \end_layout
4700 \begin_layout Standard
4701 Bitwise logical functions and related.
4702 \end_layout
4704 \begin_layout Subsection
4705 bit.none/bit.bnot: Bitwise none or NOT function
4706 \end_layout
4708 \begin_layout Itemize
4709 Syntax: number bit.none(number...)
4710 \end_layout
4712 \begin_layout Itemize
4713 Syntax: number bit.bnot(number...)
4714 \end_layout
4716 \begin_layout Standard
4717 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4718  arguments).
4719 \end_layout
4721 \begin_layout Subsection
4722 bit.any/bit.bor: Bitwise any or OR function
4723 \end_layout
4725 \begin_layout Itemize
4726 Syntax: number bit.any(number...)
4727 \end_layout
4729 \begin_layout Itemize
4730 Syntax: number bit.bor(number...)
4731 \end_layout
4733 \begin_layout Standard
4734 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4735 \end_layout
4737 \begin_layout Subsection
4738 bit.all/bit.band: Bitwise all or AND function
4739 \end_layout
4741 \begin_layout Itemize
4742 Syntax: number bit.all(number...)
4743 \end_layout
4745 \begin_layout Itemize
4746 Syntax: number bit.band(number...)
4747 \end_layout
4749 \begin_layout Standard
4750 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4752 \end_layout
4754 \begin_layout Subsection
4755 bit.parity/bit.bxor: Bitwise parity or XOR function
4756 \end_layout
4758 \begin_layout Itemize
4759 Syntax: number bit.parity(number...)
4760 \end_layout
4762 \begin_layout Itemize
4763 Syntax: number bit.bxor(number...)
4764 \end_layout
4766 \begin_layout Standard
4767 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4768  of the arguments).
4769 \end_layout
4771 \begin_layout Subsection
4772 bit.lrotate: Rotate a number left
4773 \end_layout
4775 \begin_layout Itemize
4776 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4777 \end_layout
4779 \begin_layout Standard
4780 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4781  1) places.
4782 \end_layout
4784 \begin_layout Subsection
4785 bit.rrotate: Rotate a number right
4786 \end_layout
4788 \begin_layout Itemize
4789 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4790 \end_layout
4792 \begin_layout Standard
4793 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4794  1) places.
4795 \end_layout
4797 \begin_layout Subsection
4798 bit.lshift: Shift a number left
4799 \end_layout
4801 \begin_layout Itemize
4802 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4803 \end_layout
4805 \begin_layout Standard
4806 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4807  1) places.
4808  The new bits are filled with zeroes.
4809 \end_layout
4811 \begin_layout Subsection
4812 bit.lrshift: Shift a number right (logical)
4813 \end_layout
4815 \begin_layout Itemize
4816 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4817 \end_layout
4819 \begin_layout Standard
4820 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4821  (default 1) places.
4822  The new bits are filled with zeroes.
4823 \end_layout
4825 \begin_layout Subsection
4826 bit.arshift: Shift a number right (arithmetic)
4827 \end_layout
4829 \begin_layout Itemize
4830 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4831 \end_layout
4833 \begin_layout Standard
4834 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4835  (default 1) places.
4836  The new bits are shifted in with copy of the high bit.
4837 \end_layout
4839 \begin_layout Subsection
4840 bit.extract: Extract/shuffle bits from number
4841 \end_layout
4843 \begin_layout Itemize
4844 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4845 \end_layout
4847 \begin_layout Standard
4848 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4849 \end_layout
4851 \begin_layout Itemize
4852 Note: Bit numbers up to 51 should work reliably (then things start falling
4853  apart due to double precision issues).
4854 \end_layout
4856 \begin_layout Itemize
4857 Note: There are two special bit positions, true and false, standing for
4858  always set bit and always clear bit.
4859 \end_layout
4861 \begin_layout Subsection
4862 bit.value: Construct number with specified bits set
4863 \end_layout
4865 \begin_layout Itemize
4866 Syntax: number bit.value([number bit1[, number bit2,...]])
4867 \end_layout
4869 \begin_layout Standard
4870 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4871  <bit2> places and so on.
4872  As special value, nil argument is no-op.
4873 \end_layout
4875 \begin_layout Subsection
4876 bit.test: Test if bit is set
4877 \end_layout
4879 \begin_layout Itemize
4880 Syntax: boolean bit.test(number a, number bit)
4881 \end_layout
4883 \begin_layout Standard
4884 Tests if bit <bit> is set in <a>.
4885  If it is set, returns true, otherwise false.
4886 \end_layout
4888 \begin_layout Subsection
4889 bit.testn: Test if bit is clear
4890 \end_layout
4892 \begin_layout Itemize
4893 Syntax: boolean bit.testn(number a, number bit)
4894 \end_layout
4896 \begin_layout Standard
4897 Tests if bit <bit> is set in <a>.
4898  If it is clear, returns true, otherwise false.
4899 \end_layout
4901 \begin_layout Subsection
4902 bit.test_any: Test if any bit is set
4903 \end_layout
4905 \begin_layout Itemize
4906 Syntax: boolean bit.test_any(number a, number b)
4907 \end_layout
4909 \begin_layout Standard
4910 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4911 \end_layout
4913 \begin_layout Subsection
4914 bit.test_all: Test if all bits are set
4915 \end_layout
4917 \begin_layout Itemize
4918 Syntax: boolean bit.test_all(number a, number b)
4919 \end_layout
4921 \begin_layout Standard
4922 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4923 \end_layout
4925 \begin_layout Subsection
4926 bit.popcount: Population count
4927 \end_layout
4929 \begin_layout Itemize
4930 Syntax: number bit.popcount(number a)
4931 \end_layout
4933 \begin_layout Standard
4934 Returns number of set bits in <a>.
4935 \end_layout
4937 \begin_layout Subsection
4938 bit.clshift: Chained left shift
4939 \end_layout
4941 \begin_layout Itemize
4942 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4943  bits]])
4944 \end_layout
4946 \begin_layout Standard
4947 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4948  numbers to be of specified number of bits <bits> (default 48).
4949 \end_layout
4951 \begin_layout Subsection
4952 bit.crshift: Chained right shift
4953 \end_layout
4955 \begin_layout Itemize
4956 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4957  bits]])
4958 \end_layout
4960 \begin_layout Standard
4961 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4962  assuming numbers to be of specified number of bits <bits> (default 48).
4963 \end_layout
4965 \begin_layout Subsection
4966 bit.flagdecode: Decode bitfield into flags
4967 \end_layout
4969 \begin_layout Itemize
4970 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4971  off]])
4972 \end_layout
4974 \begin_layout Standard
4975 Return string of length bits where ith character is ith character of on
4976  if bit i is on, otherwise ith character of off.
4977  Out of range reads give last character.
4978 \end_layout
4980 \begin_layout Itemize
4981 Note: <on> defaults to '*' if empty.
4982 \end_layout
4984 \begin_layout Itemize
4985 Note: <off> defaults to '-' if empty.
4986 \end_layout
4988 \begin_layout Subsection
4989 bit.rflagdecode: Decode bitfield into flags
4990 \end_layout
4992 \begin_layout Itemize
4993 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4994  off]])
4995 \end_layout
4997 \begin_layout Standard
4998 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4999 nt bit first).
5000 \end_layout
5002 \begin_layout Subsection
5003 bit.swap{,s}{,h,d,q}word: Swap word endian
5004 \end_layout
5006 \begin_layout Itemize
5007 Syntax: number bit.swapword(number n)
5008 \end_layout
5010 \begin_layout Itemize
5011 Syntax: number bit.swaphword(number n)
5012 \end_layout
5014 \begin_layout Itemize
5015 Syntax: number bit.swapdword(number n)
5016 \end_layout
5018 \begin_layout Itemize
5019 Syntax: number bit.swapqword(number n)
5020 \end_layout
5022 \begin_layout Itemize
5023 Syntax: number bit.swapsword(number n)
5024 \end_layout
5026 \begin_layout Itemize
5027 Syntax: number bit.swapshword(number n)
5028 \end_layout
5030 \begin_layout Itemize
5031 Syntax: number bit.swapsdword(number n)
5032 \end_layout
5034 \begin_layout Itemize
5035 Syntax: number bit.swapsqword(number n)
5036 \end_layout
5038 \begin_layout Standard
5039 Swap endianess of (un)signed integer <n>.
5040 \end_layout
5042 \begin_layout Subsection
5043 bit.compose: Compose multi-byte number
5044 \end_layout
5046 \begin_layout Itemize
5047 Syntax: number bit.compose(number n...)
5048 \end_layout
5050 \begin_layout Standard
5051 Return 
5052 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
5053 \end_inset
5056 \end_layout
5058 \begin_layout Subsection
5059 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
5060 \end_layout
5062 \begin_layout Itemize
5063 Syntax: number bit.binary_ld_<type>le(string str, number pos);
5064 \end_layout
5066 \begin_layout Itemize
5067 Syntax: number bit.binary_ld_<type>be(string str, number pos);
5068 \end_layout
5070 \begin_layout Standard
5071 Load little (*le) or big (*be) endian binary number from position <pos>
5072  of string <str>.
5073  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5074  double.
5075 \end_layout
5077 \begin_layout Subsection
5078 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
5079 \end_layout
5081 \begin_layout Itemize
5082 Syntax: string bit.binary_st_<type>le(number x);
5083 \end_layout
5085 \begin_layout Itemize
5086 Syntax: string bit.binary_st_<type>be(number x);
5087 \end_layout
5089 \begin_layout Standard
5090 Store specified number <x> as binary in string and return the result.
5091  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5092  double.
5093 \end_layout
5095 \begin_layout Subsection
5096 bit.quotent: Integer quotent
5097 \end_layout
5099 \begin_layout Itemize
5100 Syntax: number bit.quotent(number a, number b)
5101 \end_layout
5103 \begin_layout Standard
5104 Calculate quotent a/b.
5105 \end_layout
5107 \begin_layout Subsection
5108 bit.multidiv: Divide and split among multiple divisiors
5109 \end_layout
5111 \begin_layout Itemize
5112 Syntax: number...
5113  bit.multidiv(number v, number q...)
5114 \end_layout
5116 \begin_layout Standard
5117 Does the following steps:
5118 \end_layout
5120 \begin_layout Enumerate
5121 Set v' to <v>.
5122 \end_layout
5124 \begin_layout Enumerate
5125 For each <q> q:
5126 \begin_inset Separator latexpar
5127 \end_inset
5130 \end_layout
5132 \begin_deeper
5133 \begin_layout Enumerate
5134 Calculate quotent(v'/q) and add that to numbers returned.
5135 \end_layout
5137 \begin_layout Enumerate
5138 v' <- remainder(v'/q)
5139 \end_layout
5141 \end_deeper
5142 \begin_layout Enumerate
5143 Add v' to numbers returned.
5144 \end_layout
5146 \begin_layout Standard
5147 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
5148  at each step.
5149  <v> may be floating point, <q>s are integers.
5150 \end_layout
5152 \begin_layout Itemize
5153 E.g.
5154  bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
5155 \end_layout
5157 \begin_layout Itemize
5158 E.g.
5159  bit.multidiv(a, b) calculates quotent and remainder of a/b.
5160 \end_layout
5162 \begin_layout Subsection
5163 bit.mul32: 32-bit multiply
5164 \end_layout
5166 \begin_layout Itemize
5167 Syntax: number, number bit.mul32(number a, number b)
5168 \end_layout
5170 \begin_layout Standard
5171 Multiply 32-bit numbers <a> and <b>.
5172  The first return value is low 32 bits of result, the second is high 32
5173  bits.
5174 \end_layout
5176 \begin_layout Subsection
5177 bit.fextract: Extract bit field
5178 \end_layout
5180 \begin_layout Itemize
5181 Syntax: number bit.fextract(number value, number shift, number width)
5182 \end_layout
5184 \begin_layout Standard
5185 Extract <width> bits starting from bit <shift> from number <value>.
5186  This is more compact way to write 
5187 \begin_inset Formula $\left(value\gg shift\right)\&\left(2^{width}-1\right)$
5188 \end_inset
5191 \end_layout
5193 \begin_layout Subsection
5194 bit.bfields: Split number into bit fields
5195 \end_layout
5197 \begin_layout Itemize
5198 Syntax: number...
5199  bit.bfields(number v, number q...)
5200 \end_layout
5202 \begin_layout Standard
5203 Split a number <v> into bitfields of <q> bits (in order, from least significant
5204  towards more significant bits), with no padding in between.
5205 \end_layout
5207 \begin_layout Itemize
5209  number of form 0 bbbbb ggggg rrrrr can be decoded to its component fields
5210  using r,g,b = bit.bfields(v, 5, 5, 5).
5212 \end_layout
5214 \begin_layout Itemize
5216  number of form x yyyyyyy w zzzzzzz can be decode to its component fields
5217  using z, w, y, x = bit.bfields(v, 7, 1, 7, 1).
5218 \end_layout
5220 \begin_layout Standard
5221 \begin_inset Newpage pagebreak
5222 \end_inset
5225 \end_layout
5227 \begin_layout Section
5228 Table classes:
5229 \end_layout
5231 \begin_layout Subsection
5232 classes.<foo>: The classobj for class <foo>
5233 \end_layout
5235 \begin_layout Itemize
5236 Syntax: classes.<foo>
5237 \end_layout
5239 \begin_layout Standard
5240 The classobj for class <foo>.
5241 \end_layout
5243 \begin_layout Subsection
5244 classes.<foo>._static_methods: Enumerate static methods
5245 \end_layout
5247 \begin_layout Itemize
5248 Syntax: string...
5249  classes.<foo>._static_methods()
5250 \end_layout
5252 \begin_layout Standard
5253 Returns all static methods of <foo> as strings.
5254 \end_layout
5256 \begin_layout Subsection
5257 classes.<foo>._class_methods: Enumerate static methods
5258 \end_layout
5260 \begin_layout Itemize
5261 Syntax: string...
5262  classes.<foo>._class_methods()
5263 \end_layout
5265 \begin_layout Standard
5266 Returns all class methods of <foo> as strings.
5267 \end_layout
5269 \begin_layout Subsection
5270 classes.<foo>.<bar>: Static method
5271 \end_layout
5273 \begin_layout Itemize
5274 Syntax: variable classes.<foo>.<bar>(variable...)
5275 \end_layout
5277 \begin_layout Standard
5278 Invokes static method <bar> of class <foo>.
5279 \end_layout
5281 \begin_layout Section
5282 Table gui:
5283 \end_layout
5285 \begin_layout Subsection
5286 gui.resolution: Get current resolution
5287 \end_layout
5289 \begin_layout Itemize
5290 Syntax: (number, number) gui.resolution()
5291 \end_layout
5293 \begin_layout Standard
5294 Returns 2-tuple (hresolution, vresolution).
5295 \end_layout
5297 \begin_layout Subsection
5298 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
5299 \end_layout
5301 \begin_layout Itemize
5302 Syntax: number gui.left_gap(number gap)
5303 \end_layout
5305 \begin_layout Itemize
5306 Syntax: number gui.right_gap(number gap)
5307 \end_layout
5309 \begin_layout Itemize
5310 Syntax: number gui.top_gap(number gap)
5311 \end_layout
5313 \begin_layout Itemize
5314 Syntax: number gui.bottom_gap(number gap)
5315 \end_layout
5317 \begin_layout Standard
5318 Set the specified edge gap to specified value <gap> (max gap is 8191).
5319  If successful, old gap is returned.
5320 \end_layout
5322 \begin_layout Subsection
5323 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
5324  Adjust edge gaps
5325 \end_layout
5327 \begin_layout Itemize
5328 Syntax: number gui.delta_left_gap(number dgap)
5329 \end_layout
5331 \begin_layout Itemize
5332 Syntax: number gui.delta_right_gap(number dgap)
5333 \end_layout
5335 \begin_layout Itemize
5336 Syntax: number gui.delta_top_gap(number dgap)
5337 \end_layout
5339 \begin_layout Itemize
5340 Syntax: number gui.delta_bottom_gap(number dgap)
5341 \end_layout
5343 \begin_layout Standard
5344 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
5345  and return the old gap (returns nothing on error).
5346 \end_layout
5348 \begin_layout Subsection
5349 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
5350 \end_layout
5352 \begin_layout Itemize
5353 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
5354  bgc[, number hlc]]])
5355 \end_layout
5357 \begin_layout Itemize
5358 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
5359  bgc[, number hlc]]])
5360 \end_layout
5362 \begin_layout Itemize
5363 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
5364  bgc[, number hlc]]])
5365 \end_layout
5367 \begin_layout Itemize
5368 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
5369  bgc[, number hlc]]])
5370 \end_layout
5372 \begin_layout Standard
5373 Draw specified text on the GUI (each character cell is 8 or 16 wide and
5374  16 high).
5375  Parameters:
5376 \end_layout
5378 \begin_layout Itemize
5379 x: X-coordinate to start the drawing from (and x-coordinate at begining
5380  of the lines).
5381 \end_layout
5383 \begin_layout Itemize
5384 y: Y-coordinate to start the drawing from.
5385 \end_layout
5387 \begin_layout Itemize
5388 text: The text to draw.
5389 \end_layout
5391 \begin_layout Itemize
5392 fgc: Text color (default is 0xFFFFFF (white))
5393 \end_layout
5395 \begin_layout Itemize
5396 bgc: Background color (default is -1 (transparent))
5397 \end_layout
5399 \begin_layout Itemize
5400 hlc: Halo color (default is -1 (transparent))
5401 \end_layout
5403 \begin_layout Standard
5404 Note: The H variants draw at double width and V variants draw at double
5405  height.
5406  Halo thickness is always 1 and is not doubled.
5407 \end_layout
5409 \begin_layout Subsection
5410 gui.rectangle: Draw a rectangle
5411 \end_layout
5413 \begin_layout Itemize
5414 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5415  number thickness[, number outline[, number fill]]])
5416 \end_layout
5418 \begin_layout Standard
5419 Draw rectangle on the GUI.
5420  Parameters:
5421 \end_layout
5423 \begin_layout Itemize
5424 x: X-coordinate of left edge.
5425 \end_layout
5427 \begin_layout Itemize
5428 y: Y-coordinate of upper edge.
5429 \end_layout
5431 \begin_layout Itemize
5432 width: Width of rectangle.
5433 \end_layout
5435 \begin_layout Itemize
5436 height: Height of rectangle.
5437 \end_layout
5439 \begin_layout Itemize
5440 thickness: Thickness of outline (default is 1).
5441 \end_layout
5443 \begin_layout Itemize
5444 outline: Color of outline (default is 0xFFFFFF (white))
5445 \end_layout
5447 \begin_layout Itemize
5448 fill: Color of fill (default is -1 (transparent))
5449 \end_layout
5451 \begin_layout Subsection
5452 gui.solidrectangle: Draw a solid rectangle
5453 \end_layout
5455 \begin_layout Itemize
5456 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5457  number color])
5458 \end_layout
5460 \begin_layout Standard
5461 Draw solid rectangle on the GUI.
5462  Parameters:
5463 \end_layout
5465 \begin_layout Itemize
5466 x: X-coordinate of left edge.
5467 \end_layout
5469 \begin_layout Itemize
5470 y: Y-coordinate of upper edge.
5471 \end_layout
5473 \begin_layout Itemize
5474 width: Width of rectangle.
5475 \end_layout
5477 \begin_layout Itemize
5478 height: Height of rectangle.
5479 \end_layout
5481 \begin_layout Itemize
5482 color: Color of rectangle (default is 0xFFFFFF (white))
5483 \end_layout
5485 \begin_layout Subsection
5486 gui.box: Draw a 3D-effect box
5487 \end_layout
5489 \begin_layout Itemize
5490 Syntax: none gui.box(number x, number y, number width, number height[, number
5491  thickness[, number outline1[,number outline2[, number fill]]]])
5492 \end_layout
5494 \begin_layout Standard
5495 Draw rectangle with 3D effect on the GUI.
5496  Parameters:
5497 \end_layout
5499 \begin_layout Itemize
5500 x: X-coordinate of left edge.
5501 \end_layout
5503 \begin_layout Itemize
5504 y: Y-coordinate of upper edge.
5505 \end_layout
5507 \begin_layout Itemize
5508 width: Width of rectangle.
5509 \end_layout
5511 \begin_layout Itemize
5512 height: Height of rectangle.
5513 \end_layout
5515 \begin_layout Itemize
5516 thickness: Thickness of outline (default is 1).
5517 \end_layout
5519 \begin_layout Itemize
5520 outline1: First color of outline (default is 0xFFFFFF (white))
5521 \end_layout
5523 \begin_layout Itemize
5524 outline2: First color of outline (default is 0x808080 (dark gray))
5525 \end_layout
5527 \begin_layout Itemize
5528 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5529 \end_layout
5531 \begin_layout Subsection
5532 gui.pixel: Draw a single pixel
5533 \end_layout
5535 \begin_layout Itemize
5536 Syntax: none gui.pixel(number x, number y[, number color])
5537 \end_layout
5539 \begin_layout Standard
5540 Draw one pixel on the GUI.
5541  Parameters:
5542 \end_layout
5544 \begin_layout Itemize
5545 x: X-coordinate of the pixel
5546 \end_layout
5548 \begin_layout Itemize
5549 y: Y-coordinate of the pixel
5550 \end_layout
5552 \begin_layout Itemize
5553 color: Color of the pixel (default is 0xFFFFFF (white))
5554 \end_layout
5556 \begin_layout Subsection
5557 gui.crosshair: Draw a crosshair
5558 \end_layout
5560 \begin_layout Itemize
5561 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5562 \end_layout
5564 \begin_layout Standard
5565 Draw a crosshair.
5566  Parameters:
5567 \end_layout
5569 \begin_layout Itemize
5570 x: X-coordinate of the crosshair
5571 \end_layout
5573 \begin_layout Itemize
5574 y: Y-coordinate of the crosshair
5575 \end_layout
5577 \begin_layout Itemize
5578 length: Length of the crosshair lines (default 10).
5579 \end_layout
5581 \begin_layout Itemize
5582 color: Color of the crosshair (default is 0xFFFFFF (white))
5583 \end_layout
5585 \begin_layout Subsection
5586 gui.line: Draw a line
5587 \end_layout
5589 \begin_layout Itemize
5590 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5591  color])
5592 \end_layout
5594 \begin_layout Standard
5595 Draw a thin line.
5596  Parameters:
5597 \end_layout
5599 \begin_layout Itemize
5600 x1: X-coordinate of one end.
5601 \end_layout
5603 \begin_layout Itemize
5604 y1: Y-coordinate of one end.
5605 \end_layout
5607 \begin_layout Itemize
5608 x2: X-coordinate of the other end.
5609 \end_layout
5611 \begin_layout Itemize
5612 y2: Y-coordinate of the other end.
5613 \end_layout
5615 \begin_layout Itemize
5616 color: Color of the line (default is 0xFFFFFF (white)).
5617 \end_layout
5619 \begin_layout Subsection
5620 gui.circle: Draw a (filled) circle
5621 \end_layout
5623 \begin_layout Itemize
5624 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5625  border[, number fil]]])
5626 \end_layout
5628 \begin_layout Standard
5629 Draw a circle.
5630  Parameters.
5631 \end_layout
5633 \begin_layout Itemize
5634 x: X-coordinate of the center
5635 \end_layout
5637 \begin_layout Itemize
5638 y: Y-coordinate of the center
5639 \end_layout
5641 \begin_layout Itemize
5642 r: The radius of the circle
5643 \end_layout
5645 \begin_layout Itemize
5646 thick: Border thickness
5647 \end_layout
5649 \begin_layout Itemize
5650 border: Border color (default is 0xFFFFFF (white))
5651 \end_layout
5653 \begin_layout Itemize
5654 fill: Fill color (default is -1 (transparent)).
5655 \end_layout
5657 \begin_layout Subsection
5658 gui.repaint: Arrange a repaint
5659 \end_layout
5661 \begin_layout Itemize
5662 Syntax: none gui.repaint()
5663 \end_layout
5665 \begin_layout Standard
5666 Request on_repaint() to happen as soon as possible.
5667 \end_layout
5669 \begin_layout Subsection
5670 gui.subframe_update: Enable/Disable subframe updates
5671 \end_layout
5673 \begin_layout Itemize
5674 Syntax: none gui.subframe_update(boolean on)
5675 \end_layout
5677 \begin_layout Standard
5678 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5679  or not happen (<on>=false).
5680 \end_layout
5682 \begin_layout Subsection
5683 gui.screenshot: Write a screenshot
5684 \end_layout
5686 \begin_layout Itemize
5687 Syntax: none gui.screenshot(string filename)
5688 \end_layout
5690 \begin_layout Standard
5691 Write PNG screenshot of the current frame (no drawings) to specified file
5692  <filename>.
5693 \end_layout
5695 \begin_layout Subsection
5696 gui.screenshot_bitmap: Write a screenshot to bitmap
5697 \end_layout
5699 \begin_layout Itemize
5700 Syntax: DBITMAP gui.screenshot_bitmap()
5701 \end_layout
5703 \begin_layout Standard
5704 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5705  the result.
5706 \end_layout
5708 \begin_layout Subsection
5709 gui.color: Compose a color.
5710 \end_layout
5712 \begin_layout Itemize
5713 Syntax: number gui.color(number r, number g, number b[, number a])
5714 \end_layout
5716 \begin_layout Itemize
5717 Syntax: number gui.color(string c)
5718 \end_layout
5720 \begin_layout Standard
5721 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5722 , each component in scale 0-255.
5723  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5724  fully opaque).
5725  The default alpha is 256.
5726 \end_layout
5728 \begin_layout Standard
5729 The form taking a string returns color corresponding color name.
5730 \end_layout
5732 \begin_layout Subsection
5733 gui.status: Set status variable
5734 \end_layout
5736 \begin_layout Itemize
5737 Syntax: none gui.status(string name, string value)
5738 \end_layout
5740 \begin_layout Standard
5741 Set status field 
5742 \begin_inset Quotes eld
5743 \end_inset
5745 L[<name>]
5746 \begin_inset Quotes erd
5747 \end_inset
5749  to <value> in status area.
5750 \end_layout
5752 \begin_layout Subsection
5753 gui.rainbow: Rainbow color calculation
5754 \end_layout
5756 \begin_layout Itemize
5757 Syntax: number gui.rainbow(number step, number steps[, number color])
5758 \end_layout
5760 \begin_layout Standard
5761 Perform hue rotation of color <color> (default bright red), by <step> steps.
5762  The number of steps per full rotation is given by absolute value of <steps>.
5763 \end_layout
5765 \begin_layout Standard
5766 If <step> is negative, the rotation will be counterclockwise.
5767 \end_layout
5769 \begin_layout Subsection
5770 gui.kill_frame: Kill video frame and associated sound
5771 \end_layout
5773 \begin_layout Itemize
5774 Syntax: none gui.kill_frame()
5775 \end_layout
5777 \begin_layout Standard
5778 Kills the currently dumped video frame + the associated sound.
5779  Only valid in on_video callback.
5780 \end_layout
5782 \begin_layout Subsection
5783 gui.set_video_scale: Set video frame scale
5784 \end_layout
5786 \begin_layout Itemize
5787 Syntax: none gui.set_video_scale(number h, number v)
5788 \end_layout
5790 \begin_layout Standard
5791 Sets the scale factors of current frame to <h>x<v>.
5792  Only valid in on_video callback.
5793 \end_layout
5795 \begin_layout Subsection
5796 gui.arrow: Draw an arrow
5797 \end_layout
5799 \begin_layout Itemize
5800 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5801  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5803 \end_layout
5805 \begin_layout Standard
5806 Draws an arrow using color <color>.
5807  The tip of arrow is at (<x>, <y>).
5808  Other parameters:
5809 \end_layout
5811 \begin_layout Enumerate
5812 <length>: The length of arrow tail.
5813 \end_layout
5815 \begin_layout Enumerate
5816 <hwidth>: The width of arrow head.
5817  Should be odd.
5818 \end_layout
5820 \begin_layout Enumerate
5821 <direction>: Direction of arrow.
5822  0 is to right, +1 rotates 45 degrees counterclockwise.
5823 \end_layout
5825 \begin_layout Enumerate
5826 <fill>: If true, fill the arrow head.
5827  Default false.
5828 \end_layout
5830 \begin_layout Enumerate
5831 <twidth>: Tail width.
5832  Should be odd.
5833  Default 1.
5834 \end_layout
5836 \begin_layout Enumerate
5837 <hthick>: Head thickness (only used if <fill> is false).
5838  Default is <twidth>.
5839 \end_layout
5841 \begin_layout Subsection
5842 gui.tiled_bitmap: Class TILEMAP
5843 \end_layout
5845 \begin_layout Standard
5846 See class TILEMAP.
5847 \end_layout
5849 \begin_layout Subsection
5850 gui.palette: Class PALETTE
5851 \end_layout
5853 \begin_layout Standard
5854 See class PALETTE.
5855 \end_layout
5857 \begin_layout Subsection
5858 gui.bitmap: Class BITMAP
5859 \end_layout
5861 \begin_layout Standard
5862 See class BITMAP.
5863 \end_layout
5865 \begin_layout Subsection
5866 gui.dbitmap: Class DBITMAP
5867 \end_layout
5869 \begin_layout Standard
5870 See class DBITMAP.
5871 \end_layout
5873 \begin_layout Subsection
5874 gui.font: Class CUSTOMFONT
5875 \end_layout
5877 \begin_layout Standard
5878 See class CUSTOMFONT.
5879 \end_layout
5881 \begin_layout Subsection
5882 gui.renderctx: Class RENDERCTX
5883 \end_layout
5885 \begin_layout Standard
5886 See class RENDERCTX.
5887 \end_layout
5889 \begin_layout Subsection
5890 gui.image: Class IMAGELOADER
5891 \end_layout
5893 \begin_layout Standard
5894 See class IMAGELOADER.
5895 \end_layout
5897 \begin_layout Subsection
5898 gui.get_runmode: Get current emulator mode
5899 \end_layout
5901 \begin_layout Itemize
5902 Syntax: string gui.get_runmode()
5903 \end_layout
5905 \begin_layout Standard
5906 Gets the current emulator runmode.
5907  The possible ones are:
5908 \end_layout
5910 \begin_layout Itemize
5911 quit: Emulator is quitting.
5912 \end_layout
5914 \begin_layout Itemize
5915 normal: Emulator is running emulation
5916 \end_layout
5918 \begin_layout Itemize
5919 load: Emulator is loading a movie/savestate
5920 \end_layout
5922 \begin_layout Itemize
5923 advance_frame: Emulator is doing frame advance
5924 \end_layout
5926 \begin_layout Itemize
5927 advance_subframe: Emulator is doing subframe advance
5928 \end_layout
5930 \begin_layout Itemize
5931 skiplag: Emulator is skipping lag frames
5932 \end_layout
5934 \begin_layout Itemize
5935 skiplag_pending: Emulator will start skipping lag frames next frame
5936 \end_layout
5938 \begin_layout Itemize
5939 pause: Emulator is paused
5940 \end_layout
5942 \begin_layout Itemize
5943 pause_break: Emulator is paused at breakpoint
5944 \end_layout
5946 \begin_layout Itemize
5947 corrupt: Emulator can't run because corrupt emulation state
5948 \end_layout
5950 \begin_layout Itemize
5951 unknown: Unknown state (should not happen).
5952 \end_layout
5954 \begin_layout Standard
5955 \begin_inset Newpage pagebreak
5956 \end_inset
5959 \end_layout
5961 \begin_layout Section
5962 table input
5963 \end_layout
5965 \begin_layout Standard
5966 Input handling.
5967  Functions manipulating input are only available in on_input callback.
5968 \end_layout
5970 \begin_layout Subsection
5971 input.get: Read controller button/axis (deprecated)
5972 \end_layout
5974 \begin_layout Itemize
5975 Syntax: number input.get(number controller, number index)
5976 \end_layout
5978 \begin_layout Standard
5979 Read the specified index <index> (zero-based) from specified controller
5980  <controller> (zero-based).
5982 \end_layout
5984 \begin_layout Subsection
5985 input.set: Write controller button/axis (deprecated)
5986 \end_layout
5988 \begin_layout Itemize
5989 Syntax: none input.set(number controller, number index, number value)
5990 \end_layout
5992 \begin_layout Standard
5993 Write the specified index <index> (zero-based) from specified controller
5994  <controller> (zero-based), storing value <value>.
5995 \end_layout
5997 \begin_layout Subsection
5998 input.get2: Read controller button/axis
5999 \end_layout
6001 \begin_layout Itemize
6002 Syntax: number input.get2(number port, number controller, number index)
6003 \end_layout
6005 \begin_layout Standard
6006 Read the specified input tuple.
6007  Port 0 is system port.
6008 \end_layout
6010 \begin_layout Subsection
6011 input.set2: Write controller button/axis
6012 \end_layout
6014 \begin_layout Itemize
6015 Syntax: input.set2(number port, number controller, number index, number value)
6016 \end_layout
6018 \begin_layout Standard
6019 Write the specified input tuple.
6020  Port 0 is system port.
6021 \end_layout
6023 \begin_layout Subsection
6024 input.lcid_to_pcid2: Look up logical controller
6025 \end_layout
6027 \begin_layout Itemize
6028 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
6029 \end_layout
6031 \begin_layout Standard
6032 Look up physical pcid pair (port, controller) corresponding to specified
6033  logical controller (1-based).
6034  Returns nothing if controller does not exist.
6035 \end_layout
6037 \begin_layout Subsection
6038 input.port_type: Look up port type
6039 \end_layout
6041 \begin_layout Itemize
6042 Syntax: string input.port_type(number port)
6043 \end_layout
6045 \begin_layout Standard
6046 Return type of specified port.
6047 \end_layout
6049 \begin_layout Subsection
6050 input.controller_info: Get information about controller
6051 \end_layout
6053 \begin_layout Itemize
6054 Syntax: table input.controller_info(number port, number controller)
6055 \end_layout
6057 \begin_layout Standard
6058 Get controller info for specified controller.
6059  If controller does not exist, returns nil.
6060  Otherwise returns a table with following fields:
6061 \end_layout
6063 \begin_layout Itemize
6064 type (string): Type of the controller.
6065 \end_layout
6067 \begin_layout Itemize
6068 class (string): Class of the controller.
6069 \end_layout
6071 \begin_layout Itemize
6072 classnum (number): Number of the controller within its class (1-based)
6073 \end_layout
6075 \begin_layout Itemize
6076 lcid (number): Logical controller number of the controller.
6077 \end_layout
6079 \begin_layout Itemize
6080 button_count (number): Number of buttons on controller
6081 \end_layout
6083 \begin_layout Itemize
6084 buttons (array): Array of following info about each button:
6085 \begin_inset Separator latexpar
6086 \end_inset
6089 \end_layout
6091 \begin_deeper
6092 \begin_layout Itemize
6093 type (string): Type of button.
6094  Currently one of 
6095 \begin_inset Quotes eld
6096 \end_inset
6098 null
6099 \begin_inset Quotes erd
6100 \end_inset
6103 \begin_inset Quotes eld
6104 \end_inset
6106 button
6107 \begin_inset Quotes erd
6108 \end_inset
6111 \begin_inset Quotes eld
6112 \end_inset
6114 axis
6115 \begin_inset Quotes erd
6116 \end_inset
6119 \begin_inset Quotes eld
6120 \end_inset
6122 raxis
6123 \begin_inset Quotes erd
6124 \end_inset
6127 \end_layout
6129 \begin_layout Itemize
6130 name (string): Name of button.
6131 \end_layout
6133 \begin_layout Itemize
6134 symbol (string): Symbol of button.
6135  Only present for type 
6136 \begin_inset Quotes eld
6137 \end_inset
6139 button
6140 \begin_inset Quotes erd
6141 \end_inset
6144 \end_layout
6146 \begin_layout Itemize
6147 hidden (boolean): True if hidden button.
6149 \end_layout
6151 \end_deeper
6152 \begin_layout Subsection
6153 input.veto_button: Veto a button press
6154 \end_layout
6156 \begin_layout Itemize
6157 Syntax: none input.veto_button()
6158 \end_layout
6160 \begin_layout Standard
6161 Signals that the button event should be vetoed.
6162  Only valid in on_button callback.
6163 \end_layout
6165 \begin_layout Subsection
6166 input.geta: Get all buttons for controller (deprecated)
6167 \end_layout
6169 \begin_layout Itemize
6170 Syntax: (number, number...) input.geta(number controller)
6171 \end_layout
6173 \begin_layout Standard
6174 Get input state for entiere controller.
6175  Returns n return values.
6176 \end_layout
6178 \begin_layout Itemize
6179 1st return value: Bitmask: bit i is set if i:th index is nonzero
6180 \end_layout
6182 \begin_layout Itemize
6183 2nd- return value: value of i:th index.
6184 \end_layout
6186 \begin_layout Subsection
6187 input.seta: Set all buttons for controller (deprecated)
6188 \end_layout
6190 \begin_layout Itemize
6191 Syntax: none input.seta(number controller, number bitmask, number args...)
6192 \end_layout
6194 \begin_layout Standard
6195 Set state for entiere controller.
6196  args is up to N values for indices (overriding values in bitmask if specified).
6197 \end_layout
6199 \begin_layout Subsection
6200 input.controllertype: Get controller type (deprecated)
6201 \end_layout
6203 \begin_layout Itemize
6204 syntax: string input.controllertype(number controller)
6205 \end_layout
6207 \begin_layout Standard
6208 Get the type of controller as string.
6209 \end_layout
6211 \begin_layout Subsection
6212 input.reset: Execute (delayed) reset
6213 \end_layout
6215 \begin_layout Itemize
6216 Syntax: none input.reset([number cycles])
6217 \end_layout
6219 \begin_layout Standard
6220 Execute reset.
6221  If <cycles> is greater than zero, do delayed reset.
6222  0 (or no value) causes immediate reset.
6223 \end_layout
6225 \begin_layout Itemize
6226 Note: Only available with subframe flag false.
6227 \end_layout
6229 \begin_layout Subsection
6230 input.raw: Return raw input data
6231 \end_layout
6233 \begin_layout Itemize
6234 Syntax: table input.raw()
6235 \end_layout
6237 \begin_layout Standard
6238 Returns table of tables of all available keys and axes.
6239  The first table is indexed by key name (platform-dependent!), and the inner
6240  table has the following fields:
6241 \end_layout
6243 \begin_layout Itemize
6244 value: Last reported value for control
6245 \begin_inset Separator latexpar
6246 \end_inset
6249 \end_layout
6251 \begin_deeper
6252 \begin_layout Itemize
6253 For keys: 1 for pressed, 0 for released.
6254 \end_layout
6256 \begin_layout Itemize
6257 For axes: -32767...32767.
6258 \end_layout
6260 \begin_layout Itemize
6261 For presure-sensitive buttons: 0...32767.
6262 \end_layout
6264 \begin_layout Itemize
6265 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
6266 \end_layout
6268 \begin_layout Itemize
6269 For mouse: Coordinates relative to game area.
6270 \end_layout
6272 \end_deeper
6273 \begin_layout Itemize
6274 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
6275 \end_layout
6277 \begin_layout Subsection
6278 input.keyhook: Hook a key
6279 \end_layout
6281 \begin_layout Itemize
6282 Syntax: none input.keyhook(string key, boolean state)
6283 \end_layout
6285 \begin_layout Standard
6286 Requests that keyhook events to be sent for key <key> (<state>=true) or
6287  not sent (<state>=false).
6288 \end_layout
6290 \begin_layout Subsection
6291 input.joyget: Get controls for controller
6292 \end_layout
6294 \begin_layout Itemize
6295 Syntax: table input.joyget(number logical)
6296 \end_layout
6298 \begin_layout Standard
6299 Returns table for current controls for specified logical controller <logical>.
6300  The names of fields vary by controller type.
6301 \end_layout
6303 \begin_layout Itemize
6304 The buttons have the same name as those are referred to in other contexts
6305  in the emulator
6306 \end_layout
6308 \begin_layout Itemize
6309 The analog axes are usually 
6310 \begin_inset Quotes eld
6311 \end_inset
6313 xaxis
6314 \begin_inset Quotes erd
6315 \end_inset
6317  and 
6318 \begin_inset Quotes eld
6319 \end_inset
6321 yaxis
6322 \begin_inset Quotes erd
6323 \end_inset
6326 \end_layout
6328 \begin_layout Itemize
6329 Each field is numeric or boolean depending on axis/button.
6330 \end_layout
6332 \begin_layout Subsection
6333 input.joyset: Set controls for controller
6334 \end_layout
6336 \begin_layout Itemize
6337 Syntax: none input.joyset(number controller, table controls)
6338 \end_layout
6340 \begin_layout Standard
6341 Set the the state of specified controller to values specified in specified
6342  table.
6343 \end_layout
6345 \begin_layout Itemize
6346 Each field can be boolean or number.
6347 \end_layout
6349 \begin_layout Itemize
6350 Also, buttons allow strings, which cause value to be inverted.
6351 \end_layout
6353 \begin_layout Subsection
6354 input.lcid_to_pcid: Look up logical controller (deprecated)
6355 \end_layout
6357 \begin_layout Itemize
6358 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
6359 \end_layout
6361 \begin_layout Standard
6362 Returns the legacy pcid for controller (or false if there isn't one), followed
6363  by pcid pair.
6364  Returns nothing if controller does not exist.
6365 \end_layout
6367 \begin_layout Standard
6368 \begin_inset Newpage pagebreak
6369 \end_inset
6372 \end_layout
6374 \begin_layout Section
6375 Table keyboard
6376 \end_layout
6378 \begin_layout Standard
6379 Various keybinding-related functions
6380 \end_layout
6382 \begin_layout Subsection
6383 keyboard.bind: Bind a key
6384 \end_layout
6386 \begin_layout Itemize
6387 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
6388 \end_layout
6390 \begin_layout Standard
6391 Bind specified key with specified modifers to specified command.
6392 \end_layout
6394 \begin_layout Subsection
6395 keyboard.unbind: Unbind a key
6396 \end_layout
6398 \begin_layout Itemize
6399 Syntax: none keyboard.unbind(string mod, string mask, string key)
6400 \end_layout
6402 \begin_layout Standard
6403 Unbind specified key with specified modifers.
6404 \end_layout
6406 \begin_layout Subsection
6407 keyboard.alias: Set alias expansion
6408 \end_layout
6410 \begin_layout Itemize
6411 Syntax: none keyboard.alias(string alias, string expansion)
6412 \end_layout
6414 \begin_layout Standard
6415 Set expansion of given command.
6416 \end_layout
6418 \begin_layout Standard
6419 \begin_inset Newpage pagebreak
6420 \end_inset
6423 \end_layout
6425 \begin_layout Section
6426 Table subtitle
6427 \end_layout
6429 \begin_layout Standard
6430 Subtitle handling
6431 \end_layout
6433 \begin_layout Subsection
6434 subtitle.byindex: Look up start and length of subtitle by index
6435 \end_layout
6437 \begin_layout Itemize
6438 Syntax: (number, number) subtitle.byindex(number i)
6439 \end_layout
6441 \begin_layout Standard
6442 Read the frame and length of ith subtitle.
6443  Returns nothing if not present.
6444 \end_layout
6446 \begin_layout Subsection
6447 subtitle.set: Write a subtitle
6448 \end_layout
6450 \begin_layout Itemize
6451 Syntax: none subtitle.set(number f, number l, string txt)
6452 \end_layout
6454 \begin_layout Standard
6455 Set the text of subtitle.
6456 \end_layout
6458 \begin_layout Subsection
6459 subtitle.get: Read a subtitle
6460 \end_layout
6462 \begin_layout Itemize
6463 Syntax: string subtitle.get(number f, number l)
6464 \end_layout
6466 \begin_layout Standard
6467 Get the text of subtitle.
6468 \end_layout
6470 \begin_layout Subsection
6471 subtitle.delete: Delete a subtitle
6472 \end_layout
6474 \begin_layout Itemize
6475 Syntax: none subtitle.delete(number f, number l)
6476 \end_layout
6478 \begin_layout Standard
6479 Delete specified subtitle.
6480 \end_layout
6482 \begin_layout Standard
6483 \begin_inset Newpage pagebreak
6484 \end_inset
6487 \end_layout
6489 \begin_layout Section
6490 Table hostmemory
6491 \end_layout
6493 \begin_layout Standard
6494 Host memory handling (extra memory saved to savestates).
6495  Host memory starts empty.
6496 \end_layout
6498 \begin_layout Itemize
6499 Reads out of range return false.
6500 \end_layout
6502 \begin_layout Itemize
6503 Writes out of range extend the memory.
6504 \end_layout
6506 \begin_layout Subsection
6507 hostmemory.read: Read byte from host memory
6508 \end_layout
6510 \begin_layout Itemize
6511 Syntax: number hostmemory.read(number address)
6512 \end_layout
6514 \begin_layout Standard
6515 Reads byte from hostmemory slot address <address>.
6516 \end_layout
6518 \begin_layout Subsection
6519 hostmemory.write: Write byte to host memory
6520 \end_layout
6522 \begin_layout Itemize
6523 Syntax: none hostmemory.write(number address, number value)
6524 \end_layout
6526 \begin_layout Standard
6527 Writes hostmemory slot with value <value> 0-255.
6528 \end_layout
6530 \begin_layout Subsection
6531 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6532 \end_layout
6534 \begin_layout Itemize
6535 Syntax: number hostmemory.readbyte(number address)
6536 \end_layout
6538 \begin_layout Itemize
6539 Syntax: number hostmemory.readsbyte(number address)
6540 \end_layout
6542 \begin_layout Itemize
6543 Syntax: number hostmemory.readword(number address)
6544 \end_layout
6546 \begin_layout Itemize
6547 Syntax: number hostmemory.readsword(number address)
6548 \end_layout
6550 \begin_layout Itemize
6551 Syntax: number hostmemory.readhword(number address)
6552 \end_layout
6554 \begin_layout Itemize
6555 Syntax: number hostmemory.readshword(number address)
6556 \end_layout
6558 \begin_layout Itemize
6559 Syntax: number hostmemory.readdword(number address)
6560 \end_layout
6562 \begin_layout Itemize
6563 Syntax: number hostmemory.readsdword(number address)
6564 \end_layout
6566 \begin_layout Itemize
6567 Syntax: number hostmemory.readqword(number address)
6568 \end_layout
6570 \begin_layout Itemize
6571 Syntax: number hostmemory.readsqword(number address)
6572 \end_layout
6574 \begin_layout Standard
6575 Read elements (big-endian) from given address <address>.
6576 \end_layout
6578 \begin_layout Itemize
6579 byte is 1 element
6580 \end_layout
6582 \begin_layout Itemize
6583 word is 2 elements
6584 \end_layout
6586 \begin_layout Itemize
6587 hword is 3 elements
6588 \end_layout
6590 \begin_layout Itemize
6591 dword is 4 elements
6592 \end_layout
6594 \begin_layout Itemize
6595 qword is 8 elements.
6596 \end_layout
6598 \begin_layout Itemize
6599 The 's' variants do signed read.
6600 \end_layout
6602 \begin_layout Subsection
6603 hostmemory.read{float,double}: Read from host memory
6604 \end_layout
6606 \begin_layout Itemize
6607 syntax: number hostmemory.readfloat(number address)
6608 \end_layout
6610 \begin_layout Itemize
6611 Syntax: number hostmemory.readdouble(number address)
6612 \end_layout
6614 \begin_layout Standard
6615 Read elements (big-endian) floating-pont from given address <address>.
6616 \end_layout
6618 \begin_layout Subsection
6619 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6620 \end_layout
6622 \begin_layout Itemize
6623 Syntax: number hostmemory.writebyte(number address, number value)
6624 \end_layout
6626 \begin_layout Itemize
6627 Syntax: number hostmemory.writesbyte(number address, number value)
6628 \end_layout
6630 \begin_layout Itemize
6631 Syntax: number hostmemory.writeword(number address, number value)
6632 \end_layout
6634 \begin_layout Itemize
6635 Syntax: number hostmemory.writesword(number address, number value)
6636 \end_layout
6638 \begin_layout Itemize
6639 Syntax: number hostmemory.writehword(number address, number value)
6640 \end_layout
6642 \begin_layout Itemize
6643 Syntax: number hostmemory.writeshword(number address, number value)
6644 \end_layout
6646 \begin_layout Itemize
6647 Syntax: number hostmemory.writedword(number address, number value)
6648 \end_layout
6650 \begin_layout Itemize
6651 Syntax: number hostmemory.writesdword(number address, number value)
6652 \end_layout
6654 \begin_layout Itemize
6655 Syntax: number hostmemory.writeqword(number address, number value)
6656 \end_layout
6658 \begin_layout Itemize
6659 Syntax: number hostmemory.writesqword(number address, number value)
6660 \end_layout
6662 \begin_layout Standard
6663 Write value <value> to elements (little-endian) starting from given address
6664  <address>.
6665 \end_layout
6667 \begin_layout Itemize
6668 byte is 1 element
6669 \end_layout
6671 \begin_layout Itemize
6672 word is 2 elements
6673 \end_layout
6675 \begin_layout Itemize
6676 hword is 3 elements
6677 \end_layout
6679 \begin_layout Itemize
6680 dword is 4 elements
6681 \end_layout
6683 \begin_layout Itemize
6684 qword is 8 elements.
6685 \end_layout
6687 \begin_layout Itemize
6688 The 's' variants do signed write.
6689 \end_layout
6691 \begin_layout Subsection
6692 hostmemory.write{float,double}: Write to host memory
6693 \end_layout
6695 \begin_layout Itemize
6696 syntax: none hostmemory.readfloat(number address, number value)
6697 \end_layout
6699 \begin_layout Itemize
6700 Syntax: none hostmemory.readdouble(number address, number value)
6701 \end_layout
6703 \begin_layout Standard
6704 Write elements (big-endian) floating-pont to given address <address>, storing
6705  <value>.
6706 \end_layout
6708 \begin_layout Standard
6709 \begin_inset Newpage pagebreak
6710 \end_inset
6713 \end_layout
6715 \begin_layout Section
6716 Table movie
6717 \end_layout
6719 \begin_layout Standard
6720 Movie handling
6721 \end_layout
6723 \begin_layout Subsection
6724 movie.currentframe: Get current frame number
6725 \end_layout
6727 \begin_layout Itemize
6728 Syntax: number movie.currentframe()
6729 \end_layout
6731 \begin_layout Standard
6732 Return number of current frame.
6733 \end_layout
6735 \begin_layout Subsection
6736 movie.framecount: Get move frame count
6737 \end_layout
6739 \begin_layout Itemize
6740 Syntax: number movie.framecount()
6741 \end_layout
6743 \begin_layout Standard
6744 Return number of frames in movie.
6745 \end_layout
6747 \begin_layout Subsection
6748 movie.lagcount: Get current lag count
6749 \end_layout
6751 \begin_layout Itemize
6752 Syntax: number movie.lagcount()
6753 \end_layout
6755 \begin_layout Standard
6756 Return number of lag frames recorded so far.
6757 \end_layout
6759 \begin_layout Subsection
6760 movie.readonly: Is in playback mode?
6761 \end_layout
6763 \begin_layout Itemize
6764 Syntax: boolean movie.readonly()
6765 \end_layout
6767 \begin_layout Standard
6768 Return true if in playback mode, false if in recording.
6769 \end_layout
6771 \begin_layout Subsection
6772 movie.rerecords: Movie rerecord count
6773 \end_layout
6775 \begin_layout Itemize
6776 Syntax: number movie.rerecords()
6777 \end_layout
6779 \begin_layout Standard
6780 Returns the current value of rerecord count.
6781 \end_layout
6783 \begin_layout Subsection
6784 movie.set_readwrite: Set recording mode.
6785 \end_layout
6787 \begin_layout Itemize
6788 Syntax: none movie.set_readwrite()
6789 \end_layout
6791 \begin_layout Standard
6792 Set recording mode (does not cause on_readwrite callback).
6793 \end_layout
6795 \begin_layout Subsection
6796 movie.frame_subframes: Count subframes in frame
6797 \end_layout
6799 \begin_layout Itemize
6800 Syntax: number movie.frame_subframes(number frame)
6801 \end_layout
6803 \begin_layout Standard
6804 Count number of subframes in specified frame <frame> (frame numbers are
6805  1-based) and return that.
6806 \end_layout
6808 \begin_layout Subsection
6809 movie.read_subframes: Read subframe data (deprecated)
6810 \end_layout
6812 \begin_layout Itemize
6813 Syntax: table movie.read_subframes(number frame, number subframe)
6814 \end_layout
6816 \begin_layout Standard
6817 Read specifed subframe in specified frame and return data as array.
6818 \end_layout
6820 \begin_layout Subsection
6821 movie.read_rtc: Read current RTC time
6822 \end_layout
6824 \begin_layout Itemize
6825 Syntax: (number, number) movie.read_rtc()
6826 \end_layout
6828 \begin_layout Standard
6829 Returns the current value of the RTC as a pair (second, subsecond).
6830 \end_layout
6832 \begin_layout Subsection
6833 movie.unsafe_rewind: Fast movie rewind to saved state
6834 \end_layout
6836 \begin_layout Itemize
6837 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6838 \end_layout
6840 \begin_layout Standard
6841 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6842 \end_layout
6844 \begin_layout Itemize
6845 If called without argument, causes emulator to start process of setting
6846  unsafe rewind point.
6847  When this has finished, callback on_set_rewind occurs, passing the rewind
6848  state to lua script.
6849 \end_layout
6851 \begin_layout Itemize
6852 If called with argument, causes emulator rewind to passed rewind point as
6853  soon as possible.
6854  recording mode is implicitly activated.
6855 \end_layout
6857 \begin_layout Standard
6858 The following warnings apply to unsafe rewinding:
6859 \end_layout
6861 \begin_layout Itemize
6862 There are no safety checks against misuse (that's what 
6863 \begin_inset Quotes eld
6864 \end_inset
6866 unsafe
6867 \begin_inset Quotes erd
6868 \end_inset
6870  comes from)!
6871 \end_layout
6873 \begin_layout Itemize
6874 Only call rewind from timeline rewind point was set from.
6875 \end_layout
6877 \begin_layout Itemize
6878 Only call rewind from after the rewind point was set.
6879 \end_layout
6881 \begin_layout Subsection
6882 movie.to_rewind: Load savestate as rewind point
6883 \end_layout
6885 \begin_layout Itemize
6886 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6887 \end_layout
6889 \begin_layout Standard
6890 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6891  corresponding to it.
6892 \end_layout
6894 \begin_layout Itemize
6895 Note: This operation does not take emulated time.
6896 \end_layout
6898 \begin_layout Subsection
6899 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6900 \end_layout
6902 \begin_layout Itemize
6903 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6904 \end_layout
6906 \begin_layout Itemize
6907 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6908 \end_layout
6910 \begin_layout Standard
6911 Copies specified movie or branch <movie>/current object (if none or nil,
6912  the active movie) as new movie object.
6913 \end_layout
6915 \begin_layout Subsection
6916 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6917 \end_layout
6919 \begin_layout Itemize
6920 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6921 \end_layout
6923 \begin_layout Itemize
6924 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6925 \end_layout
6927 \begin_layout Standard
6928 Get INPUTFRAME object corresponding to specified frame in specified movie
6929  or branch.
6930 \end_layout
6932 \begin_layout Subsection
6933 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6934 \end_layout
6936 \begin_layout Itemize
6937 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6938  data)
6939 \end_layout
6941 \begin_layout Itemize
6942 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6943 \end_layout
6945 \begin_layout Standard
6946 Set data in specified frame.
6947 \end_layout
6949 \begin_layout Itemize
6950 Note: Past can't be edited in active movie.
6951 \end_layout
6953 \begin_layout Subsection
6954 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6955 \end_layout
6957 \begin_layout Itemize
6958 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6959 \end_layout
6961 \begin_layout Itemize
6962 Syntax: integer INPUTMOVIE::get_size()
6963 \end_layout
6965 \begin_layout Standard
6966 Return number of subframes in specified movie or branch.
6967 \end_layout
6969 \begin_layout Subsection
6970 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6971 \end_layout
6973 \begin_layout Itemize
6974 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6975 \end_layout
6977 \begin_layout Itemize
6978 Syntax: number INPUTMOVIE::count_frames()
6979 \end_layout
6981 \begin_layout Standard
6982 Return number of frames in movie.
6983 \end_layout
6985 \begin_layout Subsection
6986 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6987 \end_layout
6989 \begin_layout Itemize
6990 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6991 \end_layout
6993 \begin_layout Itemize
6994 Syntax: number INPUTMOVIE::find_frame(number frame)
6995 \end_layout
6997 \begin_layout Standard
6998 Returns starting subframe of given frame (frame numbers are 1-based).
6999  Returns -1 if frame number is bad.
7000 \end_layout
7002 \begin_layout Subsection
7003 movie.subframe_to_frame/INPUTMOVIE::subframe_to_frame: Find frame corresponding
7004  to subframe
7005 \end_layout
7007 \begin_layout Itemize
7008 Syntax: number movie.subframe_to_frame([INPUTMOVIE/string movie], number
7009  subframe)
7010 \end_layout
7012 \begin_layout Itemize
7013 Syntax: number INPUTMOVIE::subframe_to_frame(number subframe)
7014 \end_layout
7016 \begin_layout Standard
7017 Returns frame containing given subframe (subframe numbers are 0-based).
7018  Returns -1 if subframe number is bad.
7019 \end_layout
7021 \begin_layout Subsection
7022 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
7023 \end_layout
7025 \begin_layout Itemize
7026 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
7027 \end_layout
7029 \begin_layout Itemize
7030 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
7031 \end_layout
7033 \begin_layout Standard
7034 Return blank INPUTFRAME with frame type from specified movie.
7035 \end_layout
7037 \begin_layout Subsection
7038 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
7039 \end_layout
7041 \begin_layout Itemize
7042 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
7043 \end_layout
7045 \begin_layout Itemize
7046 Syntax: none INPUTMOVIE::append_frames(number frames)
7047 \end_layout
7049 \begin_layout Standard
7050 Append specified number <frames> of frames.
7051 \end_layout
7053 \begin_layout Subsection
7054 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
7055 \end_layout
7057 \begin_layout Itemize
7058 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
7059 \end_layout
7061 \begin_layout Itemize
7062 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
7063 \end_layout
7065 \begin_layout Standard
7066 Append specified frame <frame>.
7067  Past of current movie can't be edited.
7068 \end_layout
7070 \begin_layout Subsection
7071 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
7072 \end_layout
7074 \begin_layout Itemize
7075 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
7076 \end_layout
7078 \begin_layout Itemize
7079 Syntax: none INPUTMOVIE::truncate(number frames)
7080 \end_layout
7082 \begin_layout Standard
7083 Truncate the specified movie to specified number of frames.
7084 \end_layout
7086 \begin_layout Subsection
7087 movie.edit/INPUTMOVIE::edit: Edit a movie
7088 \end_layout
7090 \begin_layout Itemize
7091 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
7092  controller, number control, number/bool value)
7093 \end_layout
7095 \begin_layout Itemize
7096 Syntax: none movie.edit(string branch, number frame, number port, number
7097  controller, number control, number/bool value)
7098 \end_layout
7100 \begin_layout Itemize
7101 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
7102  number control, number/bool value)
7103 \end_layout
7105 \begin_layout Standard
7106 Change specified control in specified frame in specified movie.
7107  Past can't be edited in active movie.
7108 \end_layout
7110 \begin_layout Subsection
7111 movie.copy_frames2: Copy frames between movies
7112 \end_layout
7114 \begin_layout Itemize
7115 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
7116 IE/string srcmov,] number src, number count)
7117 \end_layout
7119 \begin_layout Standard
7120 Copy specified number of frames between two movies.
7121  The copy proceeeds in forward direction.
7122 \end_layout
7124 \begin_layout Subsection
7125 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
7126 \end_layout
7128 \begin_layout Itemize
7129 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
7130  src, number count, bool backwards)
7131 \end_layout
7133 \begin_layout Itemize
7134 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
7135  bool backwards)
7136 \end_layout
7138 \begin_layout Standard
7139 Copy specified number of frames from one point in movie to another.
7140  If backwards is true, the copy will be done backwards.
7141 \end_layout
7143 \begin_layout Subsection
7144 movie.serialize/INPUTMOVIE::serialize: Serialize movie
7145 \end_layout
7147 \begin_layout Itemize
7148 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
7149  bool binary)
7150 \end_layout
7152 \begin_layout Itemize
7153 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
7154 \end_layout
7156 \begin_layout Standard
7157 Serialize given movie into file.
7158  If binary is true, binary format (more compact and much faster) is used.
7159 \end_layout
7161 \begin_layout Subsection
7162 movie.unserialize: Unserialize movie
7163 \end_layout
7165 \begin_layout Itemize
7166 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
7167  bool binary)
7168 \end_layout
7170 \begin_layout Standard
7171 Unserialize movie from file.
7172  The given frame is used as template to decide the frame type.
7173  If binary is true, binary format is decoded (much faster).
7174 \end_layout
7176 \begin_layout Subsection
7177 movie.current_first_subframe: Return first subframe in current frame
7178 \end_layout
7180 \begin_layout Itemize
7181 Syntax: number movie.current_first_subframe()
7182 \end_layout
7184 \begin_layout Standard
7185 Returns first subframe in current frame.
7186 \end_layout
7188 \begin_layout Subsection
7189 movie.pollcounter: Return poll counter for speified control
7190 \end_layout
7192 \begin_layout Itemize
7193 Syntax: number movie.pollcounter(number port, number controller, number control)
7194 \end_layout
7196 \begin_layout Standard
7197 Returns number of times the specified control has been polled this frame.
7198 \end_layout
7200 \begin_layout Subsection
7201 movie.current_branch: Return current branch
7202 \end_layout
7204 \begin_layout Itemize
7205 Syntax: string movie.current_branch()
7206 \end_layout
7208 \begin_layout Standard
7209 Returns the name of the current branch.
7210 \end_layout
7212 \begin_layout Subsection
7213 movie.get_branches: Return names of all branches
7214 \end_layout
7216 \begin_layout Itemize
7217 Syntax: string...
7218  movie.get_branches()
7219 \end_layout
7221 \begin_layout Standard
7222 Returns the name of all branches.
7223 \end_layout
7225 \begin_layout Subsection
7226 movie.rom_loaded: Is ROM loaded?
7227 \end_layout
7229 \begin_layout Itemize
7230 Syntax: boolean movie.rom_loaded()
7231 \end_layout
7233 \begin_layout Standard
7234 Returns true if ROM is loaded, false otherwise.
7235 \end_layout
7237 \begin_layout Subsection
7238 movie.get_rom_info: Get info about loaded ROM
7239 \end_layout
7241 \begin_layout Itemize
7242 Syntax: Table movie.get_rom_info()
7243 \end_layout
7245 \begin_layout Standard
7246 Returns a table of tables.
7247  The outer table is indexed by ROM slot index.
7248  The inner table has the following fields:
7249 \end_layout
7251 \begin_layout Itemize
7252 filename: The name of file
7253 \end_layout
7255 \begin_layout Itemize
7256 hint: File name hint
7257 \end_layout
7259 \begin_layout Itemize
7260 sha256: SHA-256 hash of ROM.
7261 \end_layout
7263 \begin_layout Itemize
7264 xml_filename: The name of file for markup
7265 \end_layout
7267 \begin_layout Itemize
7268 xml_hint: File name hint for markup
7269 \end_layout
7271 \begin_layout Itemize
7272 xml_sha256: SHA-256 hash of ROM markup.
7273 \end_layout
7275 \begin_layout Standard
7276 If there is no markup, the xml_* fields are absent.
7277 \end_layout
7279 \begin_layout Subsection
7280 movie.get_game_info: Get info about loaded game
7281 \end_layout
7283 \begin_layout Itemize
7284 Syntax: Table movie.get_game_info()
7285 \end_layout
7287 \begin_layout Standard
7288 Returns a table with following fields:
7289 \end_layout
7291 \begin_layout Itemize
7292 core: The name of the core
7293 \end_layout
7295 \begin_layout Itemize
7296 core_short: Short name of the core
7297 \end_layout
7299 \begin_layout Itemize
7300 type: The name of the system type
7301 \end_layout
7303 \begin_layout Itemize
7304 type_long: The long name of the system type
7305 \end_layout
7307 \begin_layout Itemize
7308 region: The name of region
7309 \end_layout
7311 \begin_layout Itemize
7312 region_long: The long name of region
7313 \end_layout
7315 \begin_layout Itemize
7316 gametype: The gametype of movie.
7317 \end_layout
7319 \begin_layout Itemize
7320 fps: Nominal fps as floating-point value
7321 \end_layout
7323 \begin_layout Itemize
7324 fps_n: Exact nominal fps numerator
7325 \end_layout
7327 \begin_layout Itemize
7328 fps_d: Exact nominal fps denominator.
7329 \end_layout
7331 \begin_layout Subsection
7332 INPUTFRAME::get_button: Get button
7333 \end_layout
7335 \begin_layout Itemize
7336 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
7337  control)
7338 \end_layout
7340 \begin_layout Standard
7341 Returns state of given button as boolean.
7342 \end_layout
7344 \begin_layout Subsection
7345 INPUTFRAME::get_axis: Get axis
7346 \end_layout
7348 \begin_layout Itemize
7349 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
7350  control)
7351 \end_layout
7353 \begin_layout Standard
7354 Returns state of given axis as number.
7355 \end_layout
7357 \begin_layout Subsection
7358 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
7359 \end_layout
7361 \begin_layout Itemize
7362 Syntax: none INPUTFRAME::set_button(number port, number controller, number
7363  control, number/bool value)
7364 \end_layout
7366 \begin_layout Itemize
7367 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
7368  control)
7369 \end_layout
7371 \begin_layout Standard
7372 Set the given button/axis to given value.
7373 \end_layout
7375 \begin_layout Subsection
7376 INPUTFRAME::serialize: Serialize a frame
7377 \end_layout
7379 \begin_layout Itemize
7380 Syntax: string INPUTFRAME::serialize()
7381 \end_layout
7383 \begin_layout Standard
7384 Return string representation of frame.
7385 \end_layout
7387 \begin_layout Subsection
7388 INPUTFRAME::unserialize: Unserialize a frame
7389 \end_layout
7391 \begin_layout Itemize
7392 Syntax: none INPUTFRAME::unserialize(string data)
7393 \end_layout
7395 \begin_layout Standard
7396 Set current frame from given data.
7397 \end_layout
7399 \begin_layout Subsection
7400 INPUTFRAME::get_stride: Get movie stride
7401 \end_layout
7403 \begin_layout Itemize
7404 Syntax: number INPUTFRAME::get_stride()
7405 \end_layout
7407 \begin_layout Standard
7408 Return number of bytes needed to store the input frame.
7409  Mainly useful for some debugging.
7410 \end_layout
7412 \begin_layout Standard
7413 \begin_inset Newpage pagebreak
7414 \end_inset
7417 \end_layout
7419 \begin_layout Section
7420 Table settings
7421 \end_layout
7423 \begin_layout Standard
7424 Routines for settings manipulation
7425 \end_layout
7427 \begin_layout Subsection
7428 settings.get: Get value of setting
7429 \end_layout
7431 \begin_layout Itemize
7432 Syntax: string settings.get(string name)
7433 \end_layout
7435 \begin_layout Standard
7436 Get value of setting <name>.
7437  If setting value can't be obtained, returns (nil, error message).
7438 \end_layout
7440 \begin_layout Subsection
7441 settings.set: Set value of setting
7442 \end_layout
7444 \begin_layout Itemize
7445 Syntax: none settings.set(string name, string value)
7446 \end_layout
7448 \begin_layout Standard
7449 Set value <value> of setting <name>.
7450  If setting can't be set, returns (nil, error message).
7451 \end_layout
7453 \begin_layout Subsection
7454 settings.get_all: Get values of all settings
7455 \end_layout
7457 \begin_layout Itemize
7458 Syntax: table settings.get_all()
7459 \end_layout
7461 \begin_layout Standard
7462 Return a table with all setting names as keys and all current values as
7463  values.
7464 \end_layout
7466 \begin_layout Subsection
7467 settings.get_speed: Get current speed
7468 \end_layout
7470 \begin_layout Itemize
7471 Syntax: number/string settings.get_speed()
7472 \end_layout
7474 \begin_layout Standard
7475 Return the current speed multiplier (1 is normal), or 
7476 \begin_inset Quotes eld
7477 \end_inset
7479 turbo
7480 \begin_inset Quotes erd
7481 \end_inset
7483  if speed is set to turbo (this does not react to turbo toggle).
7484 \end_layout
7486 \begin_layout Subsection
7487 settings.set_speed: Set current speed
7488 \end_layout
7490 \begin_layout Itemize
7491 Syntax: settings.get_speed(number spd)
7492 \end_layout
7494 \begin_layout Itemize
7495 Syntax: settings.get_speed(string special)
7496 \end_layout
7498 \begin_layout Standard
7499 Set the current speed multiplier (1 is normal).
7500  The speed may be positive multiplier or 
7501 \begin_inset Quotes eld
7502 \end_inset
7504 turbo
7505 \begin_inset Quotes erd
7506 \end_inset
7508  for turbo speed.
7509 \end_layout
7511 \begin_layout Standard
7512 \begin_inset Newpage pagebreak
7513 \end_inset
7516 \end_layout
7518 \begin_layout Section
7519 Table memory
7520 \end_layout
7522 \begin_layout Standard
7523 Contains various functions for managing memory
7524 \end_layout
7526 \begin_layout Subsection
7527 memory.vma_count: Count number of memory areas.
7528 \end_layout
7530 \begin_layout Itemize
7531 Syntax: number memory.vma_count()
7532 \end_layout
7534 \begin_layout Standard
7535 Returns the number of memory areas
7536 \end_layout
7538 \begin_layout Subsection
7539 memory.read_vma: Lookup memory area info by index
7540 \end_layout
7542 \begin_layout Itemize
7543 Syntax: table memory.read_vma(number index)
7544 \end_layout
7546 \begin_layout Standard
7547 Reads the specified memory area (indices start from zero).
7548  Trying to read invalid memory area gives nil.
7549  The return value is table with the following fields:
7550 \end_layout
7552 \begin_layout Itemize
7553 region_name (string): The readable name of the memory area
7554 \end_layout
7556 \begin_layout Itemize
7557 baseaddr (number): Base address of the memory area
7558 \end_layout
7560 \begin_layout Itemize
7561 lastaddr (number): Last address in the memory area.
7562 \end_layout
7564 \begin_layout Itemize
7565 size (number): The size of memory area in bytes.
7566 \end_layout
7568 \begin_layout Itemize
7569 readonly (boolean): True of the memory area corresponds to ROM.
7570 \end_layout
7572 \begin_layout Itemize
7573 iospace (boolean): True if the memory area is I/O space.
7574 \end_layout
7576 \begin_layout Itemize
7577 native_endian (boolean): True if the memory area has native endian as opposed
7578  to little endian.
7579 \end_layout
7581 \begin_layout Subsection
7582 memory.find_vma: Find memory area info by address
7583 \end_layout
7585 \begin_layout Itemize
7586 Syntax: table memory.find_vma(number address)
7587 \end_layout
7589 \begin_layout Standard
7590 Finds the memory area containing specified address.
7591  Returns table in the same format as read_vma or nil if not found.
7592 \end_layout
7594 \begin_layout Subsection
7595 memory.read{,s}{byte,{,h,d,q}word}: Read memory
7596 \end_layout
7598 \begin_layout Itemize
7599 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
7600 \end_layout
7602 \begin_layout Itemize
7603 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
7604 \end_layout
7606 \begin_layout Itemize
7607 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
7608 \end_layout
7610 \begin_layout Itemize
7611 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
7612 \end_layout
7614 \begin_layout Itemize
7615 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
7616 \end_layout
7618 \begin_layout Itemize
7619 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
7620 \end_layout
7622 \begin_layout Itemize
7623 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
7624 \end_layout
7626 \begin_layout Itemize
7627 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
7628 \end_layout
7630 \begin_layout Itemize
7631 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
7632 \end_layout
7634 \begin_layout Itemize
7635 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
7636 \end_layout
7638 \begin_layout Standard
7639 Reads the specified address <address> (if 's' variant is used, do undergo
7640  2's complement).
7641 \end_layout
7643 \begin_layout Subsection
7644 memory.{,s}read_sg: Scatter/Gather read memory
7645 \end_layout
7647 \begin_layout Itemize
7648 Syntax: none memory.read_sg(string/boolean/number...)
7649 \end_layout
7651 \begin_layout Itemize
7652 Syntax: none memory.sread_sg(string/boolean/number...)
7653 \end_layout
7655 \begin_layout Standard
7656 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
7657  of memory.
7658  Each argument can be string, boolean or number:
7659 \end_layout
7661 \begin_layout Itemize
7662 String: Set memory area addresses are relative to (e.g.
7663  'WRAM').
7664 \end_layout
7666 \begin_layout Itemize
7667 boolean: If true, increment relative address by 1, if false, decrement by
7668  1.
7669  The new address is read as next higher byte.
7670 \end_layout
7672 \begin_layout Itemize
7673 integer: Set the relative address to specified value and read the address
7674  as next higher byte.
7675 \end_layout
7677 \begin_layout Subsection
7678 memory.write_sg: Scatter/Gather write memory
7679 \end_layout
7681 \begin_layout Itemize
7682 Syntax: none memory.write_sg(number value, string/boolean/number...)
7683 \end_layout
7685 \begin_layout Standard
7686 Perform scatter/gather write of value <value> on memory.
7687  Each argument can be string, boolean or number:
7688 \end_layout
7690 \begin_layout Itemize
7691 String: Set memory area addresses are relative to (e.g.
7692  'WRAM').
7693 \end_layout
7695 \begin_layout Itemize
7696 boolean: If true, increment relative address by 1, if false, decrement by
7697  1.
7698  The new address is read as next higher byte.
7699 \end_layout
7701 \begin_layout Itemize
7702 integer: Set the relative address to specified value and read the address
7703  as next higher byte.
7704 \end_layout
7706 \begin_layout Subsection
7707 memory.read{float,double}: Read memory
7708 \end_layout
7710 \begin_layout Itemize
7711 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7712 \end_layout
7714 \begin_layout Itemize
7715 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7716 \end_layout
7718 \begin_layout Standard
7719 Reads the specified address <address>
7720 \end_layout
7722 \begin_layout Subsection
7723 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7724 \end_layout
7726 \begin_layout Itemize
7727 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7728  number value)
7729 \end_layout
7731 \begin_layout Itemize
7732 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7733  number value)
7734 \end_layout
7736 \begin_layout Itemize
7737 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7738  number value)
7739 \end_layout
7741 \begin_layout Itemize
7742 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7743  number value)
7744 \end_layout
7746 \begin_layout Itemize
7747 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7748  number value)
7749 \end_layout
7751 \begin_layout Itemize
7752 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7753  number value)
7754 \end_layout
7756 \begin_layout Itemize
7757 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7758  number value)
7759 \end_layout
7761 \begin_layout Standard
7762 Writes the specified value <value> (negative integer values undergo 2's
7763  complement) to specified address <address>.
7764 \end_layout
7766 \begin_layout Subsection
7767 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7768 \end_layout
7770 \begin_layout Itemize
7771 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7772  number size)
7773 \end_layout
7775 \begin_layout Standard
7776 Returns a table mapping specified memory aperture for read/write.
7777 \end_layout
7779 \begin_layout Itemize
7780 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7781  qword, sqword, float or double.
7782 \end_layout
7784 \begin_layout Subsection
7785 memory.hash_region: Hash region of memory
7786 \end_layout
7788 \begin_layout Itemize
7789 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7790  number size)
7791 \end_layout
7793 \begin_layout Standard
7794 Hash <size> bytes starting from address <base> (relative to <marea>) and
7795  return the SHA-256.
7796 \end_layout
7798 \begin_layout Subsection
7799 memory.hash_region2: Hash region of memory
7800 \end_layout
7802 \begin_layout Itemize
7803 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7804  number size[, number rows, number stride])
7805 \end_layout
7807 \begin_layout Standard
7808 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7809  to <marea>).
7810  The blocks are offset by <stride> from one another and return the SHA-256.
7811 \end_layout
7813 \begin_layout Subsection
7814 memory.hash_region_skein: Hash region of memory
7815 \end_layout
7817 \begin_layout Itemize
7818 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7819  addrobj}, number size[, number rows, number stride])
7820 \end_layout
7822 \begin_layout Standard
7823 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7824  finalists) as hash function.
7825 \end_layout
7827 \begin_layout Subsection
7828 memory.store: Store region of memory
7829 \end_layout
7831 \begin_layout Itemize
7832 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7833  daddr[, number rows, number stride]
7834 \end_layout
7836 \begin_layout Standard
7837 Copy memory starting from <addr> in memory area <marea> (each row being
7838  of size <size>, there being <rows> rows, and rows being separated by <stride>
7839  in memory) into savestate-saved memory area, starting from <daadr> (all
7840  rows are written back to back).
7841 \end_layout
7843 \begin_layout Subsection
7844 memory.storecmp: Compare and store region of memory
7845 \end_layout
7847 \begin_layout Itemize
7848 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7849  number daddr[, number rows, number stride]
7850 \end_layout
7852 \begin_layout Standard
7853 Like memory.store, but returns true if target of copy already held the value
7854  that would be copied before the copy happened.
7855  Otherwise returns false (if target and source differ before copy).
7856 \end_layout
7858 \begin_layout Subsection
7859 memory.hash_state: Hash system state
7860 \end_layout
7862 \begin_layout Itemize
7863 Syntax: string memory.hash_state()
7864 \end_layout
7866 \begin_layout Standard
7867 Hash the current system state.
7868  Mainly useful for debugging savestates.
7869 \end_layout
7871 \begin_layout Subsection
7872 memory.readregion: Read region of memory
7873 \end_layout
7875 \begin_layout Itemize
7876 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7877  number size)
7878 \end_layout
7880 \begin_layout Standard
7881 Read a region of memory.
7882 \end_layout
7884 \begin_layout Itemize
7885 Warning: If the region crosses memory area boundary, the results are undefined.
7886 \end_layout
7888 \begin_layout Subsection
7889 memory.writeregion: Write region of memory
7890 \end_layout
7892 \begin_layout Itemize
7893 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7894  number size, table data)
7895 \end_layout
7897 \begin_layout Standard
7898 Write a region of memory.
7899 \end_layout
7901 \begin_layout Itemize
7902 Warning: If the region crosses memory area boundary, the results are undefined.
7903 \end_layout
7905 \begin_layout Subsection
7906 memory.action: Run core action
7907 \end_layout
7909 \begin_layout Itemize
7910 memory.action(string action, [<params>])
7911 \end_layout
7913 \begin_layout Standard
7914 Run core action.
7915  The different models expect parameters as:
7916 \end_layout
7918 \begin_layout Itemize
7919 string: String
7920 \end_layout
7922 \begin_layout Itemize
7923 numeric: numeric
7924 \end_layout
7926 \begin_layout Itemize
7927 enumeration: String
7928 \end_layout
7930 \begin_layout Itemize
7931 boolean: String
7932 \end_layout
7934 \begin_layout Itemize
7935 toggle: None.
7936 \end_layout
7938 \begin_layout Subsection
7939 memory.action_flags: Get core action flags
7940 \end_layout
7942 \begin_layout Itemize
7943 memory.action_flags(string action)
7944 \end_layout
7946 \begin_layout Standard
7947 Get value of action flags for core action <action>.
7948 \end_layout
7950 \begin_layout Itemize
7951 Bit 0: Enabled?
7952 \end_layout
7954 \begin_layout Itemize
7955 Bit 1: Selected (not all actions can be selected)?
7956 \end_layout
7958 \begin_layout Subsection
7959 memory.get_lag_flag: Get lag flag
7960 \end_layout
7962 \begin_layout Itemize
7963 Syntax: boolean memory.get_lag_flag()
7964 \end_layout
7966 \begin_layout Standard
7967 Get the value of core lag flag.
7968  True if this frame has been lag so far, false if poll has been detected.
7969 \end_layout
7971 \begin_layout Subsection
7972 memory.set_lag_flag: Set lag flag
7973 \end_layout
7975 \begin_layout Itemize
7976 Syntax: none memory.set_lag_flag(boolean flag)
7977 \end_layout
7979 \begin_layout Standard
7980 Set the value of core lag flag.
7981  This flag automatically gets cleared if poll is detected, but can be forcibly
7982  set or cleared if game so requires.
7983 \end_layout
7985 \begin_layout Itemize
7986 Should only be used in on_frame_emulated callback.
7987 \end_layout
7989 \begin_layout Itemize
7990 Setting or clearing this affects the emulator lag counter.
7991 \end_layout
7993 \begin_layout Subsection
7994 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7995  callback
7996 \end_layout
7998 \begin_layout Itemize
7999 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
8000  function fn);
8001 \end_layout
8003 \begin_layout Itemize
8004 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
8005  addrobj}, function fn);
8006 \end_layout
8008 \begin_layout Itemize
8009 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
8010  function fn);
8011 \end_layout
8013 \begin_layout Itemize
8014 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
8015  function fn);
8016 \end_layout
8018 \begin_layout Itemize
8019 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
8020  function fn);
8021 \end_layout
8023 \begin_layout Itemize
8024 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
8025  function fn);
8026 \end_layout
8028 \begin_layout Standard
8029 Add or remove callback on memory read, write or execute (depending on the
8030  function).
8031  <addr> is relative to <marea>.
8032  <fn> is the callback.
8033  The register* functions return <fn> (which can then be passed to unregister*
8034  functions.
8035 \end_layout
8037 \begin_layout Itemize
8038 Not all cores support this, and it may be unsupported for some memory areas.
8039 \end_layout
8041 \begin_layout Itemize
8042 The functions are passed two parameters: Address and value.
8043 \end_layout
8045 \begin_layout Subsection
8046 memory.{,un}registertrace: Set/Clear trace hook
8047 \end_layout
8049 \begin_layout Itemize
8050 Syntax: function memory.registertrace(number processor, function fn);
8051 \end_layout
8053 \begin_layout Itemize
8054 Syntax: none memory.unregistertrace(number processor, function fn);
8055 \end_layout
8057 \begin_layout Standard
8058 Add or remove trace callback.
8059  <processor> is system-dependent processor number (0 is usually main CPU).
8060  The function arguments work like in other (un)register* functions.
8061 \end_layout
8063 \begin_layout Itemize
8064 The functions are passed two parameters: Trace CPU and Trace event string.
8065 \end_layout
8067 \begin_layout Subsection
8068 memory.cheat: Set cheat
8069 \end_layout
8071 \begin_layout Itemize
8072 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
8073  value);
8074 \end_layout
8076 \begin_layout Itemize
8077 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
8078 \end_layout
8080 \begin_layout Standard
8081 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
8082  If <value> is not speicified, clear a cheat.
8083 \end_layout
8085 \begin_layout Itemize
8086 Not all cores support this, and it may be unsupported for some memory areas.
8087 \end_layout
8089 \begin_layout Subsection
8090 memory.setxmask: Set global execute hook mask
8091 \end_layout
8093 \begin_layout Itemize
8094 Syntax: none memory.setxmask(number mask)
8095 \end_layout
8097 \begin_layout Standard
8098 Set the global execute hook mask to <mask>.
8099  The meaning of each bit is system-dependent, but bit 0 should be the main
8100  CPU.
8101 \end_layout
8103 \begin_layout Subsection
8104 memory.getregister: Get register value
8105 \end_layout
8107 \begin_layout Itemize
8108 Syntax: number/boolean memory.getregister(string register)
8109 \end_layout
8111 \begin_layout Standard
8112 Get the value of named register.
8113 \end_layout
8115 \begin_layout Subsection
8116 memory.getregisters: Get register values
8117 \end_layout
8119 \begin_layout Itemize
8120 Syntax: table memory.getregisters()
8121 \end_layout
8123 \begin_layout Standard
8124 Get the value of all known registers as table.
8125 \end_layout
8127 \begin_layout Subsection
8128 memory.setregister: Set register value
8129 \end_layout
8131 \begin_layout Itemize
8132 Syntax: none memory.setregister(string register, number/boolean value)
8133 \end_layout
8135 \begin_layout Standard
8136 Set the value of named register.
8137 \end_layout
8139 \begin_layout Subsection
8140 memory.mmap: Class MMAP_STRUCT
8141 \end_layout
8143 \begin_layout Standard
8144 See class MMAP_STRUCT
8145 \end_layout
8147 \begin_layout Standard
8148 \begin_inset Newpage pagebreak
8149 \end_inset
8152 \end_layout
8154 \begin_layout Section
8155 Table memory2
8156 \end_layout
8158 \begin_layout Standard
8159 Contains newer memory functions.
8160 \end_layout
8162 \begin_layout Subsection
8163 memory2(): Get all memory area names.
8164 \end_layout
8166 \begin_layout Itemize
8167 Syntax: table memory2()
8168 \end_layout
8170 \begin_layout Standard
8171 Returns array of all valid memory area names.
8172 \end_layout
8174 \begin_layout Subsection
8175 memory2.<marea>:info: Get memory area info
8176 \end_layout
8178 \begin_layout Itemize
8179 Syntax: table memory2.<marea>:info()
8180 \end_layout
8182 \begin_layout Standard
8183 Return table describing given memory area.
8184  Includes fields address, size, last, readonly, special and endian.
8185 \end_layout
8187 \begin_layout Subsection
8188 memory2.<marea>:<op>: Read/Write memory
8189 \end_layout
8191 \begin_layout Itemize
8192 Syntax: none memory2.<marea>:<op>(number offset, number value)
8193 \end_layout
8195 \begin_layout Itemize
8196 Syntax: number memory2.<marea>:<op>(number offset)
8197 \end_layout
8199 \begin_layout Standard
8200 Read/Write value from/to given memory area <marea> at given offset <offset>
8201  (must be in-range).
8202  The value written is <value>.
8203  <Op> is of form: [i][s]<type>, where:
8204 \end_layout
8206 \begin_layout Itemize
8207 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
8208 \end_layout
8210 \begin_layout Itemize
8211 'i' signifies that the value is treated as opposite-to-normal endianess,
8212 \end_layout
8214 \begin_layout Itemize
8215 's' signifies that value is treated as signed (not available for floating-point).
8216 \end_layout
8218 \begin_layout Subsection
8219 memory2.<marea>:read: Scatter-gather value read
8220 \end_layout
8222 \begin_layout Itemize
8223 Syntax: number memory2.<marea>:read(number addr...)
8224 \end_layout
8226 \begin_layout Standard
8227 Read value from given memory area <marea> at byte offsets <addr>..., given
8228  in order of increasing significance.
8229  Value of true and false are special.
8230  True increments address by 1, and false decrements address by 1.
8231 \end_layout
8233 \begin_layout Subsection
8234 memory2.<marea>:sread: Signed scatter-gather value read
8235 \end_layout
8237 \begin_layout Itemize
8238 Syntax: number memory2.<marea>:sread(number addr...)
8239 \end_layout
8241 \begin_layout Standard
8242 Like memory2.<marea>:read, but reads signed values.
8243 \end_layout
8245 \begin_layout Subsection
8246 memory2.<marea>:write: Scatter-gather value write
8247 \end_layout
8249 \begin_layout Itemize
8250 Syntax: number memory2.<marea>:write(number val, number addr...)
8251 \end_layout
8253 \begin_layout Standard
8254 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
8255  in order of increasing significance.
8256  Value of true and false are special.
8257  True increments address by 1, and false decrements address by 1.
8258 \end_layout
8260 \begin_layout Subsection
8261 memory2.<marea>:cheat: Set/Clear cheat
8262 \end_layout
8264 \begin_layout Itemize
8265 Syntax: none memory2.<marea>:cheat(number addr, [number value])
8266 \end_layout
8268 \begin_layout Standard
8269 Set/Clear cheat at offset <addr> of memory area <marea>.
8270  If <value> is given, cheat with specified value is set.
8271  Otherwise cheat on address is removed.
8272 \end_layout
8274 \begin_layout Subsection
8275 memory2.<marea>:sha256: SHA-256
8276 \end_layout
8278 \begin_layout Itemize
8279 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
8280  number stride])
8281 \end_layout
8283 \begin_layout Standard
8284 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
8285  from offset <addr> of area <marea>.
8286  The chunks are separated by <stride>.
8287 \end_layout
8289 \begin_layout Subsection
8290 memory2.<marea>:skein: Skein-512-256
8291 \end_layout
8293 \begin_layout Itemize
8294 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
8295  number stride])
8296 \end_layout
8298 \begin_layout Standard
8299 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
8300 \end_layout
8302 \begin_layout Subsection
8303 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
8304 \end_layout
8306 \begin_layout Itemize
8307 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
8308  number rows, number stride])
8309 \end_layout
8311 \begin_layout Itemize
8312 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
8313  size[, number rows, number stride])
8314 \end_layout
8316 \begin_layout Standard
8317 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
8318  <addr> of area <marea>.
8319  The chunks are separated by <stride>.
8320  The target is Lua host memory, starting from offset <daddr>.
8321 \end_layout
8323 \begin_layout Standard
8324 Additionally, the storecmp method returns false if target was modified (otherwis
8325 e true).
8326 \end_layout
8328 \begin_layout Subsection
8329 memory2.<marea>:readregion: Read region
8330 \end_layout
8332 \begin_layout Itemize
8333 Syntax table memory2.<marea>:readregion(number addr, number size)
8334 \end_layout
8336 \begin_layout Standard
8337 Read <size> bytes starting from <addr> in <marea> and return as array.
8338 \end_layout
8340 \begin_layout Subsection
8341 memory2.<marea>:writeregion: Write region
8342 \end_layout
8344 \begin_layout Itemize
8345 Syntax none memory2.<marea>:writeregion(number addr, table data)
8346 \end_layout
8348 \begin_layout Standard
8349 Write array <data> to bytes starting from <addr> in <marea>.
8350 \end_layout
8352 \begin_layout Subsection
8353 memory2.<marea>:register{read,write,exec}: Register hook
8354 \end_layout
8356 \begin_layout Itemize
8357 Syntax: function memory2.<marea>:registerread(number addr, function fn);
8358 \end_layout
8360 \begin_layout Itemize
8361 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
8362 \end_layout
8364 \begin_layout Itemize
8365 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
8366 \end_layout
8368 \begin_layout Standard
8369 Register debug callback <fn> of specified type at offset <addr> of memory
8370  area <marea>.
8371  Returns <fn>.
8372 \end_layout
8374 \begin_layout Subsection
8375 memory2.<marea>:unregister{read,write,exec}: Unregister hook
8376 \end_layout
8378 \begin_layout Itemize
8379 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
8380 \end_layout
8382 \begin_layout Itemize
8383 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
8384 \end_layout
8386 \begin_layout Itemize
8387 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
8388 \end_layout
8390 \begin_layout Standard
8391 Unregister debug callback <fn> of specified type at offset <addr> of memory
8392  area <marea>.
8393 \end_layout
8395 \begin_layout Standard
8396 \begin_inset Newpage pagebreak
8397 \end_inset
8400 \end_layout
8402 \begin_layout Section
8403 Table random
8404 \end_layout
8406 \begin_layout Standard
8407 Contains random number generation methods.
8408  These functions do not return reproducable results.
8409 \end_layout
8411 \begin_layout Subsection
8412 random.boolean: Random boolean
8413 \end_layout
8415 \begin_layout Itemize
8416 Syntax: boolean random.boolean()
8417 \end_layout
8419 \begin_layout Standard
8420 Returns true or false at random (50-50 chance).
8421 \end_layout
8423 \begin_layout Subsection
8424 random.integer: Random integer
8425 \end_layout
8427 \begin_layout Itemize
8428 Syntax: number random.integer(number highplusone)
8429 \end_layout
8431 \begin_layout Itemize
8432 Syntax: number random.integer(number low, number high)
8433 \end_layout
8435 \begin_layout Standard
8436 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
8437  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
8438 \end_layout
8440 \begin_layout Standard
8441 The returned numbers are from uniform distribution.
8442 \end_layout
8444 \begin_layout Subsection
8445 random.float: Random float
8446 \end_layout
8448 \begin_layout Itemize
8449 Syntax: number random.float()
8450 \end_layout
8452 \begin_layout Standard
8453 Returns random decimal number [0,1).
8454 \end_layout
8456 \begin_layout Subsection
8457 random.among: Random parameter
8458 \end_layout
8460 \begin_layout Itemize
8461 Syntax: value random.among(value values...)
8462 \end_layout
8464 \begin_layout Standard
8465 Returns random parameter value, picked at uniform.
8466  Multiple equivalent values are returned with higher chance.
8467 \end_layout
8469 \begin_layout Subsection
8470 random.amongtable: Random from table
8471 \end_layout
8473 \begin_layout Itemize
8474 Syntax: value random.amongtable(table tab)
8475 \end_layout
8477 \begin_layout Standard
8478 Returns random value from table <tab>.
8479  As in random.among, no equality testing is done.
8480 \end_layout
8482 \begin_layout Standard
8483 \begin_inset Newpage pagebreak
8484 \end_inset
8487 \end_layout
8489 \begin_layout Section
8490 Table zip
8491 \end_layout
8493 \begin_layout Subsection
8494 zip.enumerate: Enumerate members in zipfile
8495 \end_layout
8497 \begin_layout Itemize
8498 Syntax: Table zip.enumerate(string filename[, boolean invert])
8499 \end_layout
8501 \begin_layout Standard
8502 Returns table of files in zip archive <filename>.
8503  If <invert> is true, instead of returning array of names, returns table
8504  with keys being member names and values being true.
8505 \end_layout
8507 \begin_layout Subsection
8508 zip.writer: Class ZIPWRITER
8509 \end_layout
8511 \begin_layout Standard
8512 See class ZIPWRITER.
8513 \end_layout
8515 \begin_layout Section
8516 Table paths
8517 \end_layout
8519 \begin_layout Subsection
8520 paths.get_executable_file: Get the name of lsnes executable file
8521 \end_layout
8523 \begin_layout Itemize
8524 Syntax: String paths.get_executable_file()
8525 \end_layout
8527 \begin_layout Standard
8528 Returns the filename of the lsnes executable (together with path), if known.
8529  If unknown, returns nil.
8530 \end_layout
8532 \begin_layout Subsection
8533 paths.get_executable_path: Get the path of lsnes executable file
8534 \end_layout
8536 \begin_layout Itemize
8537 Syntax: String paths.get_executable_path()
8538 \end_layout
8540 \begin_layout Standard
8541 Returns the directory of the lsnes executable path, if known.
8542  If unknown, returns nil.
8543 \end_layout
8545 \begin_layout Subsection
8546 paths.get_config_path: Get the path of lsnes config file
8547 \end_layout
8549 \begin_layout Itemize
8550 Syntax: String paths.get_config_path()
8551 \end_layout
8553 \begin_layout Standard
8554 Returns the directory of the lsnes configuration.
8555 \end_layout
8557 \begin_layout Subsection
8558 paths.get_rompath: Get the path of ROM files
8559 \end_layout
8561 \begin_layout Itemize
8562 Syntax: String paths.get_rompath()
8563 \end_layout
8565 \begin_layout Standard
8566 Returns the default directory for various ROMs.
8567 \end_layout
8569 \begin_layout Subsection
8570 paths.get_firmwarepath: Get the path of firmware files
8571 \end_layout
8573 \begin_layout Itemize
8574 Syntax: String paths.get_firmwarepath()
8575 \end_layout
8577 \begin_layout Standard
8578 Returns the default directory for various firmwares.
8579 \end_layout
8581 \begin_layout Subsection
8582 paths.get_slotpath: Get the path of save slot files
8583 \end_layout
8585 \begin_layout Itemize
8586 Syntax: String paths.get_slotpath()
8587 \end_layout
8589 \begin_layout Standard
8590 Returns the default directory for various save slots.
8591  If in project context, returns the project directory.
8592 \end_layout
8594 \begin_layout Subsection
8595 paths.get_save_slot_file: Get save slot filename
8596 \end_layout
8598 \begin_layout Itemize
8599 Syntax: String paths.get_slotpath(string name)
8600 \end_layout
8602 \begin_layout Itemize
8603 Syntax: String paths.get_slotpath(integer slotnum, bool for_save)
8604 \end_layout
8606 \begin_layout Standard
8607 Resolve the filename of specified save slot <name> or <slotnum>.
8608  Projects and save branches are taken into account.
8609  If <for_save> is true, the filename is always for current branch.
8610  If <for_save> is false, branch tree is walked upwards until root is reached
8611  or desired file is located.
8612 \end_layout
8614 \begin_layout Standard
8615 \begin_inset Newpage pagebreak
8616 \end_inset
8619 \end_layout
8621 \begin_layout Section
8622 Table callback
8623 \end_layout
8625 \begin_layout Standard
8626 Various callback-related functions.
8627 \end_layout
8629 \begin_layout Subsection
8630 \begin_inset CommandInset label
8631 LatexCommand label
8632 name "subsec:callback.register:-Register-a"
8634 \end_inset
8636 callback.register: Register a callback
8637 \end_layout
8639 \begin_layout Itemize
8640 Syntax: function callback.register(string cbname, function cbfun);
8641 \end_layout
8643 \begin_layout Standard
8644 Instruct function <cbfun> to be added to list of callbacks to call on event
8645  <cbname> (See section 
8646 \begin_inset CommandInset ref
8647 LatexCommand ref
8648 reference "sec:Callbacks"
8650 \end_inset
8653  The callback name does not have the 'on_' prefix (e.g.
8655 \begin_inset Quotes eld
8656 \end_inset
8658 paint
8659 \begin_inset Quotes erd
8660 \end_inset
8663  Returns <cbfun>.
8664 \end_layout
8666 \begin_layout Subsection
8667 \begin_inset CommandInset label
8668 LatexCommand label
8669 name "subsec:callback.unregister:-Unregister-"
8671 \end_inset
8673 callback.unregister: Unregister a callback
8674 \end_layout
8676 \begin_layout Itemize
8677 Syntax: function callback.unregister(string cbname, function cbfun);
8678 \end_layout
8680 \begin_layout Standard
8681 Instruct function <cbfun> to be removed from list of callbacks to call on
8682  event <cbname>.
8683 \end_layout
8685 \begin_layout Subsection
8686 callback.<cbname>:register: Register callback
8687 \end_layout
8689 \begin_layout Itemize
8690 Syntax: function callback.<cbname>:register(function cbfun)
8691 \end_layout
8693 \begin_layout Standard
8694 Synonym for callback.register (section 
8695 \begin_inset CommandInset ref
8696 LatexCommand ref
8697 reference "subsec:callback.register:-Register-a"
8699 \end_inset
8701 ), albeit with callback name specified differently.
8702 \end_layout
8704 \begin_layout Subsection
8705 callback.<cbname>:unregister: Register callback
8706 \end_layout
8708 \begin_layout Itemize
8709 Syntax: function callback.<cbname>:unregister(function cbfun)
8710 \end_layout
8712 \begin_layout Standard
8713 Synonym for callback.unregister (section 
8714 \begin_inset CommandInset ref
8715 LatexCommand ref
8716 reference "subsec:callback.unregister:-Unregister-"
8718 \end_inset
8720 ), albeit with callback name specified differently.
8721 \end_layout
8723 \begin_layout Section
8724 table bsnes
8725 \end_layout
8727 \begin_layout Standard
8728 Various bsnes-specific functions.
8729 \end_layout
8731 \begin_layout Subsection
8732 bsnes.dump_sprite: Dump a sprite
8733 \end_layout
8735 \begin_layout Itemize
8736 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
8737  number height[, number stride])
8738 \end_layout
8740 \begin_layout Standard
8741 Dumps given sprite (in native format) from memory.
8742  memory area is usually 
8743 \begin_inset Quotes eld
8744 \end_inset
8746 VRAM
8747 \begin_inset Quotes erd
8748 \end_inset
8751  <Width> and <height> are given in 8x8 blocks.
8752  <Stride> overrides row stride (default 512).
8753 \end_layout
8755 \begin_layout Subsection
8756 bsnes.dump_sprite2: Dump a 2bpp sprite
8757 \end_layout
8759 \begin_layout Itemize
8760 Syntax: BITMAP bsnes.dump_sprite2(string marea, number addr, number width,
8761  number height[, number stride])
8762 \end_layout
8764 \begin_layout Standard
8765 Dumps given sprite (in 2bpp format) from memory.
8766  memory area is usually 
8767 \begin_inset Quotes eld
8768 \end_inset
8770 VRAM
8771 \begin_inset Quotes erd
8772 \end_inset
8775  <Width> and <height> are given in 8x8 blocks.
8776  <Stride> overrides row stride (default 256).
8777 \end_layout
8779 \begin_layout Subsection
8780 bsnes.dump_palette: Dump a palette
8781 \end_layout
8783 \begin_layout Itemize
8784 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool/integer
8785  full256, bool first_trans)
8786 \end_layout
8788 \begin_layout Standard
8789 Dumps a palette from memory.
8790  memory area is usually 
8791 \begin_inset Quotes eld
8792 \end_inset
8794 CGRAM
8795 \begin_inset Quotes erd
8796 \end_inset
8799  If <full256> is true, 256 colors are dumped (otherwise 16).
8800  <full256> can also be number of colors (4, 16 or 256).
8801  If <first_trans> is true, first color is forced transparent.
8802 \end_layout
8804 \begin_layout Subsection
8805 bsnes.enablelayer: Set layer visibility
8806 \end_layout
8808 \begin_layout Itemize
8809 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8810 \end_layout
8812 \begin_layout Standard
8813 Enable or disable specified layer at specified priority.
8814 \end_layout
8816 \begin_layout Subsection
8817 bsnes.redump_sprite: Redump a sprite
8818 \end_layout
8820 \begin_layout Itemize
8821 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8822  number stride])
8823 \end_layout
8825 \begin_layout Standard
8826 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8827  The specified bitmap must have size multiple of 8x8.
8828 \end_layout
8830 \begin_layout Subsection
8831 bsnes.redump_sprite2: Redump a 2bpp sprite
8832 \end_layout
8834 \begin_layout Itemize
8835 Syntax: none bsnes.redump_sprite2(BITMAP bitmap, string marea, number addr[,
8836  number stride])
8837 \end_layout
8839 \begin_layout Standard
8840 Like bsnes.dump_sprite2, but instead dumps to specified bitmap <bitmap>.
8841  The specified bitmap must have size multiple of 8x8.
8842 \end_layout
8844 \begin_layout Subsection
8845 bsnes.redump_palette: Redump a palette
8846 \end_layout
8848 \begin_layout Itemize
8849 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8850  first_trans)
8851 \end_layout
8853 \begin_layout Standard
8854 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8855  The specified palette must have either 16 or 256 colors.
8856 \end_layout
8858 \begin_layout Section
8859 extensions to table string
8860 \end_layout
8862 \begin_layout Subsection
8863 string.charU: string.char, UTF-8 version.
8864 \end_layout
8866 \begin_layout Itemize
8867 Syntax: string string.charU(number n...)
8868 \end_layout
8870 \begin_layout Standard
8871 Like Lua string.char(), but works in terms of Unicode codepoints.
8872  The returned string is UTF-8.
8873 \end_layout
8875 \begin_layout Subsection
8876 string.byteU: string.byte, UTF-8 version.
8877 \end_layout
8879 \begin_layout Itemize
8880 Syntax: number...
8881  string.byteU(string str[, number i[, number j]])
8882 \end_layout
8884 \begin_layout Standard
8885 Like string.byte(), but works in terms of Unicode codepoints.
8886  The input string <str> is assumed UTF-8.
8887 \end_layout
8889 \begin_layout Subsection
8890 string.regex: Match string against regular expression
8891 \end_layout
8893 \begin_layout Itemize
8894 Syntax: boolean/string...
8895  string.regex(string regexp, string against)
8896 \end_layout
8898 \begin_layout Standard
8899 Match POSIX-extended regular expression <regexp> against string <against>.
8900  If no match, false is returned.
8901  Otherwise if string has no subcaptures, true is returned.
8902  Otherwise each subcapture is returned as a string (in order of starting
8903  position).
8904 \end_layout
8906 \begin_layout Subsection
8907 string.hex: Transform integer into hex string
8908 \end_layout
8910 \begin_layout Itemize
8911 Syntax: string string.hex(number n, [number digits])
8912 \end_layout
8914 \begin_layout Standard
8915 Returns hexadecimal string representation of <n>, optionally padded with
8916  zeroes to <digits> digits (default is not to pad).
8917 \end_layout
8919 \begin_layout Subsection
8920 string.lpad: Pad string with spaces from left
8921 \end_layout
8923 \begin_layout Itemize
8924 Syntax: string string.lpad(string x, number n)
8925 \end_layout
8927 \begin_layout Standard
8928 Pad string <x> to <n> bytes by inserting spaces at start and return the
8929  result.
8930 \end_layout
8932 \begin_layout Subsection
8933 string.rpad: Pad string with spaces from right
8934 \end_layout
8936 \begin_layout Itemize
8937 Syntax: string string.rpad(string x, number n)
8938 \end_layout
8940 \begin_layout Standard
8941 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8942 \end_layout
8944 \begin_layout Section
8945 Table _SYSTEM
8946 \end_layout
8948 \begin_layout Standard
8949 Contains copy of global variables from time of Lua initialization.
8950  Non-writeable.
8951 \end_layout
8953 \begin_layout Standard
8954 \begin_inset Newpage pagebreak
8955 \end_inset
8958 \end_layout
8960 \begin_layout Section
8961 \begin_inset CommandInset label
8962 LatexCommand label
8963 name "sec:Callbacks"
8965 \end_inset
8967 Callbacks
8968 \end_layout
8970 \begin_layout Standard
8971 Various callbacks to Lua that can occur.
8972 \end_layout
8974 \begin_layout Subsection
8975 on_paint: Screen is being painted
8976 \end_layout
8978 \begin_layout Itemize
8979 Callback: on_paint(bool not_synth)
8980 \end_layout
8982 \begin_layout Standard
8983 Called when screen is being painted.
8984  Any gui.* calls requiring graphic context draw on the screen.
8985 \end_layout
8987 \begin_layout Itemize
8988 not_synth is true if this hook is being called in response to received frame,
8989  false otherwise.
8990 \end_layout
8992 \begin_layout Subsection
8993 on_video: Dumped video frame is being painted
8994 \end_layout
8996 \begin_layout Itemize
8997 Callback: on_video()
8998 \end_layout
9000 \begin_layout Standard
9001 Called when video dump frame is being painted.
9002  Any gui.* calls requiring graphic context draw on the video.
9003 \end_layout
9005 \begin_layout Subsection
9006 on_frame_emulated: Frame emulation complete
9007 \end_layout
9009 \begin_layout Itemize
9010 Callback: on_frame_emulated()
9011 \end_layout
9013 \begin_layout Standard
9014 Called when emulating frame has completed and on_paint()/on_video() calls
9015  are about to be issued.
9016 \end_layout
9018 \begin_layout Subsection
9019 on_frame: Frame emulation starting.
9020 \end_layout
9022 \begin_layout Itemize
9023 Callback: on_frame()
9024 \end_layout
9026 \begin_layout Standard
9027 Called on each starting whole frame.
9028 \end_layout
9030 \begin_layout Subsection
9031 on_rewind: Movie rewound to beginning
9032 \end_layout
9034 \begin_layout Itemize
9035 Callback: on_rewind()
9036 \end_layout
9038 \begin_layout Standard
9039 Called when rewind movie to beginning has completed.
9040 \end_layout
9042 \begin_layout Subsection
9043 on_pre_load: Load operation is about to start
9044 \end_layout
9046 \begin_layout Itemize
9047 Callback: on_pre_load(string name)
9048 \end_layout
9050 \begin_layout Standard
9051 Called just before savestate/movie load occurs (note: loads are always delayed,
9052  so this occurs even when load was initiated by lua).
9053 \end_layout
9055 \begin_layout Subsection
9056 on_err_Load: Load failed
9057 \end_layout
9059 \begin_layout Itemize
9060 Callback: on_err_load(string name)
9061 \end_layout
9063 \begin_layout Standard
9064 Called if loadstate goes wrong.
9065 \end_layout
9067 \begin_layout Subsection
9068 on_post_load: Load completed
9069 \end_layout
9071 \begin_layout Itemize
9072 Callback: on_post_load(string name, boolean was_savestate)
9073 \end_layout
9075 \begin_layout Standard
9076 Called on successful loadstate.
9077  was_savestate gives if this was a savestate or a movie.
9078 \end_layout
9080 \begin_layout Subsection
9081 on_pre_save: Save operation is about to start
9082 \end_layout
9084 \begin_layout Itemize
9085 Callback: on_pre_save(string name, boolean is_savestate)
9086 \end_layout
9088 \begin_layout Standard
9089 Called just before savestate save occurs (note: movie saves are synchronous
9090  and won't trigger these callbacks if called from Lua).
9091 \end_layout
9093 \begin_layout Subsection
9094 on_err_save: Save failed
9095 \end_layout
9097 \begin_layout Itemize
9098 Callback: on_err_save(string name)
9099 \end_layout
9101 \begin_layout Standard
9102 Called if savestate goes wrong.
9103 \end_layout
9105 \begin_layout Subsection
9106 on_post_save: Save completed
9107 \end_layout
9109 \begin_layout Itemize
9110 Callback: on_post_save(string name, boolean is_savestate)
9111 \end_layout
9113 \begin_layout Standard
9114 Called on successful savaestate.
9115  is_savestate gives if this was a savestate or a movie.
9116 \end_layout
9118 \begin_layout Subsection
9119 on_quit: Emulator is shutting down
9120 \end_layout
9122 \begin_layout Itemize
9123 Callback: on_quit()
9124 \end_layout
9126 \begin_layout Standard
9127 Called when emulator is shutting down.
9128 \end_layout
9130 \begin_layout Subsection
9131 on_input: Polling for input
9132 \end_layout
9134 \begin_layout Standard
9135 Called when emulator is just sending input to bsnes core.
9136  Warning: This is called even in readonly mode, but the results are ignored.
9137 \end_layout
9139 \begin_layout Subsection
9140 on_reset: System has been reset
9141 \end_layout
9143 \begin_layout Itemize
9144 Callback: on_reset()
9145 \end_layout
9147 \begin_layout Standard
9148 Called when system is reset.
9149 \end_layout
9151 \begin_layout Subsection
9152 on_readwrite: Entered recording mode
9153 \end_layout
9155 \begin_layout Itemize
9156 Callback: on_readwrite()
9157 \end_layout
9159 \begin_layout Standard
9160 Called when moving into recording mode as result of 
9161 \begin_inset Quotes eld
9162 \end_inset
9164 set-rwmode
9165 \begin_inset Quotes erd
9166 \end_inset
9168  command (note: moving to rwmode by Lua won't trigger this, as per recursive
9169  entry protection).
9170 \end_layout
9172 \begin_layout Subsection
9173 on_snoop/on_snoop2: Snoop core controller reads
9174 \end_layout
9176 \begin_layout Itemize
9177 Callback: on_snoop(number port, number controller, number index, number
9178  value)
9179 \end_layout
9181 \begin_layout Itemize
9182 Callback: on_snoop2(number port, number controller, number index, number
9183  value)
9184 \end_layout
9186 \begin_layout Standard
9187 Called each time bsnes asks for input.
9188  The value is the final value to be sent to bsnes core (readonly mode, autohold
9189  and autofire have been taken into account).
9190  Might be useful when translating movies to format suitable for console
9191  verification.
9192  Note: There is no way to modify the value to be sent.
9193 \end_layout
9195 \begin_layout Itemize
9196 On_snoop2 is called instead of on_snoop if defined.
9197  Reserves port 0 for system, having first user port be port 1.
9198 \end_layout
9200 \begin_layout Subsection
9201 on_keyhook: Hooked key/axis has been moved
9202 \end_layout
9204 \begin_layout Itemize
9205 Callback: on_keyhook(string keyname, table state)
9206 \end_layout
9208 \begin_layout Standard
9209 Sent when key that has keyhook events requested changes state.
9210  Keyname is name of the key (group) and state is the state (same kind as
9211  table values in input.raw).
9212 \end_layout
9214 \begin_layout Subsection
9215 on_idle: Idle event
9216 \end_layout
9218 \begin_layout Itemize
9219 Callback: on_idle()
9220 \end_layout
9222 \begin_layout Standard
9223 Called when requested by set_idle_timeout(), the timeout has expired and
9224  emulator is waiting.
9225 \end_layout
9227 \begin_layout Subsection
9228 on_timer: Timer event
9229 \end_layout
9231 \begin_layout Itemize
9232 Callback: on_timer()
9233 \end_layout
9235 \begin_layout Standard
9236 Called when requested by set_idle_timeout() and the timeout has expired
9237  (regardless if emulator is waiting).
9238 \end_layout
9240 \begin_layout Subsection
9241 on_set_rewind: Rewind point has been set
9242 \end_layout
9244 \begin_layout Itemize
9245 Callback: on_set_rewind(UNSAFEREWIND r)
9246 \end_layout
9248 \begin_layout Standard
9249 Called when unsafe rewind object has been constructed.
9250 \end_layout
9252 \begin_layout Subsection
9253 on_pre_rewind: Rewind is about to occur
9254 \end_layout
9256 \begin_layout Itemize
9257 Callback: on_pre_rewind() 
9258 \end_layout
9260 \begin_layout Standard
9261 Called just before unsafe rewind is about to occur.
9262 \end_layout
9264 \begin_layout Subsection
9265 on_post_rewind: Rewind has occured
9266 \end_layout
9268 \begin_layout Itemize
9269 Callback: on_post_rewind() 
9270 \end_layout
9272 \begin_layout Standard
9273 Called just after unsafe rewind has occured.
9274 \end_layout
9276 \begin_layout Subsection
9277 on_button: Button has been pressed
9278 \end_layout
9280 \begin_layout Itemize
9281 Callback: on_button(number port, number controller, number index, string
9282  type)
9283 \end_layout
9285 \begin_layout Standard
9286 Called on controller button press, with following parameters:
9287 \end_layout
9289 \begin_layout Itemize
9290 port: Port number (0 is system)
9291 \end_layout
9293 \begin_layout Itemize
9294 controller: Controller within port
9295 \end_layout
9297 \begin_layout Itemize
9298 index: Index of button.
9299 \end_layout
9301 \begin_layout Itemize
9302 type: Type of event, one of:
9303 \begin_inset Separator latexpar
9304 \end_inset
9307 \end_layout
9309 \begin_deeper
9310 \begin_layout Itemize
9311 \begin_inset Quotes eld
9312 \end_inset
9314 pressed
9315 \begin_inset Quotes erd
9316 \end_inset
9318 : Button was pressed.
9319 \end_layout
9321 \begin_layout Itemize
9322 \begin_inset Quotes eld
9323 \end_inset
9325 released
9326 \begin_inset Quotes erd
9327 \end_inset
9329 : Button was released.
9330 \end_layout
9332 \begin_layout Itemize
9333 \begin_inset Quotes eld
9334 \end_inset
9336 hold
9337 \begin_inset Quotes erd
9338 \end_inset
9340 : Held.
9341 \end_layout
9343 \begin_layout Itemize
9344 \begin_inset Quotes eld
9345 \end_inset
9347 unhold
9348 \begin_inset Quotes erd
9349 \end_inset
9351 : Released from hold.
9352 \end_layout
9354 \begin_layout Itemize
9355 \begin_inset Quotes eld
9356 \end_inset
9358 type
9359 \begin_inset Quotes erd
9360 \end_inset
9362 : Typing input on button.
9363 \end_layout
9365 \begin_layout Itemize
9366 \begin_inset Quotes eld
9367 \end_inset
9369 untype
9370 \begin_inset Quotes erd
9371 \end_inset
9373 : Typing input undone.
9374 \end_layout
9376 \begin_layout Itemize
9377 \begin_inset Quotes eld
9378 \end_inset
9380 autofire <duty> <cycle>
9381 \begin_inset Quotes erd
9382 \end_inset
9384 : Autofire with specifie duty and cycle.
9385 \end_layout
9387 \begin_layout Itemize
9388 \begin_inset Quotes eld
9389 \end_inset
9391 autofire
9392 \begin_inset Quotes erd
9393 \end_inset
9395 : Stop autofire.
9396 \end_layout
9398 \begin_layout Itemize
9399 \begin_inset Quotes eld
9400 \end_inset
9402 analog
9403 \begin_inset Quotes erd
9404 \end_inset
9406 : Analog action on axis.
9407 \end_layout
9409 \end_deeper
9410 \begin_layout Subsection
9411 on_movie_lost: Movie data is about to be lost
9412 \end_layout
9414 \begin_layout Itemize
9415 Callback: on_movie_lost(STRING kind)
9416 \end_layout
9418 \begin_layout Standard
9419 Called just before something would happen that could lose movie data.
9420  Kind can be:
9421 \end_layout
9423 \begin_layout Itemize
9424 readwrite: Switching to recording mode.
9425 \end_layout
9427 \begin_layout Itemize
9428 reload: ROM is being reloaded in recording mode.
9429 \end_layout
9431 \begin_layout Itemize
9432 load: New movie is being loaded.
9433 \end_layout
9435 \begin_layout Itemize
9436 unsaferewind: Unsafe rewind is happening.
9437 \end_layout
9439 \begin_layout Subsection
9440 on_latch: Latch line is rising
9441 \end_layout
9443 \begin_layout Itemize
9444 Callback: on_latch(<core-dependent-parameters>)
9445 \end_layout
9447 \begin_layout Standard
9448 Called when latch line for controller is rising.
9449  Some cores may not support this.
9450 \end_layout
9452 \begin_layout Section
9453 System-dependent behaviour
9454 \end_layout
9456 \begin_layout Subsection
9457 bsnes core
9458 \end_layout
9460 \begin_layout Itemize
9461 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
9462  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
9463  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
9464 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
9465 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
9466  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
9467  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
9468  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
9469  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
9470 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
9471 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
9472  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
9473 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
9474 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
9475  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
9476 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
9477  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
9478 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
9479 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
9480 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
9481  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
9482 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
9483  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
9484  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
9485 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
9486 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
9487 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
9488  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
9489 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
9490  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
9491  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
9492  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
9493  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
9494 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
9495  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
9496 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
9497  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
9498  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
9499 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
9500  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
9501 \end_layout
9503 \begin_layout Itemize
9504 on_latch has no parameters
9505 \end_layout
9507 \begin_layout Itemize
9508 CPU 0 is S-CPU, 1 is S-SMP.
9509 \end_layout
9511 \begin_layout Itemize
9512 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
9513 \end_layout
9515 \begin_layout Itemize
9516 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
9517 {RAM,ROM}.
9518 \end_layout
9520 \begin_layout Itemize
9521 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
9522  DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
9523  BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
9524  GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
9525 \end_layout
9527 \begin_layout Subsection
9528 gambatte core
9529 \end_layout
9531 \begin_layout Itemize
9532 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
9533  d, e, f, h, l
9534 \end_layout
9536 \begin_layout Itemize
9537 on_latch is not supported
9538 \end_layout
9540 \begin_layout Itemize
9541 CPU 0 is main CPU.
9542 \end_layout
9544 \begin_layout Itemize
9545 Cheats are supported for ROM, SRAM and WRAM.
9546 \end_layout
9548 \begin_layout Itemize
9549 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
9550  and WRAM.
9551 \end_layout
9553 \begin_layout Itemize
9554 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
9555 \end_layout
9557 \end_body
9558 \end_document