Specialize (D)BITMAP:sample_texture when s is power of two
[lsnes.git] / lua.lyx
blobdd31c96d00df38f44669b375803e934c01db8540
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 Standard
2426 \begin_inset Newpage pagebreak
2427 \end_inset
2430 \end_layout
2432 \begin_layout Subsection
2433 DBITMAP: Direct-color bitmap
2434 \end_layout
2436 \begin_layout Subsubsection
2437 Static function: new: Create a new bitmap
2438 \end_layout
2440 \begin_layout Itemize
2441 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2442 \end_layout
2444 \begin_layout Itemize
2445 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2446 \end_layout
2448 \begin_layout Itemize
2449 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2450 \end_layout
2452 \begin_layout Standard
2453 Parameters:
2454 \end_layout
2456 \begin_layout Itemize
2457 w: number: The width of new bitmap.
2458 \end_layout
2460 \begin_layout Itemize
2461 h: number: The height of new bitmap.
2462 \end_layout
2464 \begin_layout Itemize
2465 true: boolean: Fixed boolean true
2466 \end_layout
2468 \begin_layout Itemize
2469 fillcolor: The color to fill the bitmap with (default transparent).
2470 \end_layout
2472 \begin_layout Standard
2473 Return value:
2474 \end_layout
2476 \begin_layout Itemize
2477 bitmap: DBITMAP: The new bitmap.
2478 \end_layout
2480 \begin_layout Standard
2481 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2482  <fillcolor>.
2483 \end_layout
2485 \begin_layout Subsubsection
2486 Method draw: Draw a bitmap
2487 \end_layout
2489 \begin_layout Itemize
2490 Syntax: bitmap.draw(x, y)
2491 \end_layout
2493 \begin_layout Itemize
2494 Deprecated: gui.bitmap_draw(x, y, bitmap)
2495 \end_layout
2497 \begin_layout Standard
2498 Parameters:
2499 \end_layout
2501 \begin_layout Itemize
2502 bitmap: DBITMAP: The bitmap to draw.
2503 \end_layout
2505 \begin_layout Itemize
2506 x: number: X-coordinate on screen.
2507 \end_layout
2509 \begin_layout Itemize
2510 y: number: Y-coordinate on screen.
2511 \end_layout
2513 \begin_layout Standard
2514 Draw bitmap <bitmap> on screen at <x>,<y>.
2515 \end_layout
2517 \begin_layout Subsubsection
2518 Method draw_outside: Draw a bitmap outside game area
2519 \end_layout
2521 \begin_layout Itemize
2522 Syntax: dbitmap:draw_outside(x, y, palette)
2523 \end_layout
2525 \begin_layout Standard
2526 Like dbitmap:draw, but does not draw on game area.
2527 \end_layout
2529 \begin_layout Subsubsection
2530 Method draw_clip: Draw a bitmap, with clipping
2531 \end_layout
2533 \begin_layout Itemize
2534 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2535 \end_layout
2537 \begin_layout Standard
2538 Parameters:
2539 \end_layout
2541 \begin_layout Itemize
2542 bitmap: DBITMAP: The bitmap to draw
2543 \end_layout
2545 \begin_layout Itemize
2546 x: number: The x-coordinate on screen.
2547 \end_layout
2549 \begin_layout Itemize
2550 y: number: The y-coordinate on screen.
2551 \end_layout
2553 \begin_layout Itemize
2554 x0: The smallest bitmap x coordinate to draw.
2555 \end_layout
2557 \begin_layout Itemize
2558 y0: The smallest bitmap y coordinate to draw.
2559 \end_layout
2561 \begin_layout Itemize
2562 width: Width of region to draw
2563 \end_layout
2565 \begin_layout Itemize
2566 height: Height of region to draw.
2567 \end_layout
2569 \begin_layout Standard
2570 Like dbitmap:draw, but clip the bitmap area drawn.
2571 \end_layout
2573 \begin_layout Subsubsection
2574 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2575 \end_layout
2577 \begin_layout Itemize
2578 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2579 \end_layout
2581 \begin_layout Standard
2582 Like dbitmap:draw_clip, but only draw outside game area.
2583 \end_layout
2585 \begin_layout Subsubsection
2586 Method pset: Set pixel in bitmap
2587 \end_layout
2589 \begin_layout Itemize
2590 Syntax: bitmap:pset(x, y, color)
2591 \end_layout
2593 \begin_layout Itemize
2594 Deprecaed: gui.bitmap_pset(bitmap, ...)
2595 \end_layout
2597 \begin_layout Standard
2598 Parameters:
2599 \end_layout
2601 \begin_layout Itemize
2602 bitmap: DBITMAP: The bitmap to manipulate.
2603 \end_layout
2605 \begin_layout Itemize
2606 x: number: x-coordinate of pixel to set.
2607 \end_layout
2609 \begin_layout Itemize
2610 y: number: y-coordinate of pixel to set.
2611 \end_layout
2613 \begin_layout Itemize
2614 color: number/string: The color to set.
2615 \end_layout
2617 \begin_layout Standard
2618 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2619 \end_layout
2621 \begin_layout Subsubsection
2622 Method pget: Get pixel in bitmap
2623 \end_layout
2625 \begin_layout Itemize
2626 Syntax: color bitmap:pget(x,y)
2627 \end_layout
2629 \begin_layout Itemize
2630 Deprecated: color gui.bitmap_pget(bitmap, ...)
2631 \end_layout
2633 \begin_layout Standard
2634 Parameters:
2635 \end_layout
2637 \begin_layout Itemize
2638 bitmap: DBITMAP: The bitmap to query.
2639 \end_layout
2641 \begin_layout Itemize
2642 x: number: x-coordinate of pixel to get.
2643 \end_layout
2645 \begin_layout Itemize
2646 y: number: y-coordinate of pixel to get.
2647 \end_layout
2649 \begin_layout Standard
2650 Returns:
2651 \end_layout
2653 \begin_layout Itemize
2654 color: number: The color of specified pixel.
2655 \end_layout
2657 \begin_layout Standard
2658 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2659 \end_layout
2661 \begin_layout Subsubsection
2662 Method size: Get size of bitmap
2663 \end_layout
2665 \begin_layout Itemize
2666 Syntax: width, height bitmap:size()
2667 \end_layout
2669 \begin_layout Itemize
2670 Syntax: width, height gui.bitmap_size(bitmap)
2671 \end_layout
2673 \begin_layout Standard
2674 Parameters:
2675 \end_layout
2677 \begin_layout Itemize
2678 bitmap: DBITMAP: The bitmap to query.
2679 \end_layout
2681 \begin_layout Standard
2682 Returns:
2683 \end_layout
2685 \begin_layout Itemize
2686 width: number: The width of the bitmap.
2687 \end_layout
2689 \begin_layout Itemize
2690 height: number: The height of the bitmap.
2691 \end_layout
2693 \begin_layout Standard
2694 Get size of bitmap <bitmap>.
2695 \end_layout
2697 \begin_layout Subsubsection
2698 Method blit: Blit a bitmap into another
2699 \end_layout
2701 \begin_layout Itemize
2702 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2703 \end_layout
2705 \begin_layout Itemize
2706 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2707 \end_layout
2709 \begin_layout Itemize
2710 Deprecated: gui.bitmap_blit(dest, ...)
2711 \end_layout
2713 \begin_layout Standard
2714 Parameters:
2715 \end_layout
2717 \begin_layout Itemize
2718 dest: DBITMAP: The target bitmap to blit to.
2719 \end_layout
2721 \begin_layout Itemize
2722 dx: number: The x-coordinate in target.
2723 \end_layout
2725 \begin_layout Itemize
2726 dy: number: The y-coordinate in target.
2727 \end_layout
2729 \begin_layout Itemize
2730 src: BITMAP/DBITMAP: The source bitmap.
2731 \end_layout
2733 \begin_layout Itemize
2734 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2735 \end_layout
2737 \begin_layout Itemize
2738 sx: number: The x-coordinate in source.
2739 \end_layout
2741 \begin_layout Itemize
2742 sy: number: The y-coordinate in source.
2743 \end_layout
2745 \begin_layout Itemize
2746 w: number: The width of area to blit.
2747 \end_layout
2749 \begin_layout Itemize
2750 h: number: The height of area to blit.
2751 \end_layout
2753 \begin_layout Itemize
2754 ck: number: The color key.
2755  Pixels with this index are not copied.
2756 \begin_inset Separator latexpar
2757 \end_inset
2760 \end_layout
2762 \begin_deeper
2763 \begin_layout Itemize
2764 If none is specified, all pixels are copied.
2765 \end_layout
2767 \begin_layout Itemize
2768 If <src> is paletted, this is color index, otherwise it is a color.
2769 \end_layout
2771 \end_deeper
2772 \begin_layout Standard
2773 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2774  if indexed) into <dest> at <dx>,<dy>.
2775  If a color key <ck> is specified, pixels of that color are not copied.
2776 \end_layout
2778 \begin_layout Subsubsection
2779 Method blit_scaled: Blit a bitmap into another with scaling
2780 \end_layout
2782 \begin_layout Itemize
2783 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2784 \end_layout
2786 \begin_layout Itemize
2787 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2788  [ck])
2789 \end_layout
2791 \begin_layout Itemize
2792 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2793 \end_layout
2795 \begin_layout Standard
2796 Parameters:
2797 \end_layout
2799 \begin_layout Itemize
2800 dest: DBITMAP: The target bitmap to blit to.
2801 \end_layout
2803 \begin_layout Itemize
2804 dx: number: The x-coordinate in target.
2805 \end_layout
2807 \begin_layout Itemize
2808 dy: number: The y-coordinate in target.
2809 \end_layout
2811 \begin_layout Itemize
2812 src: BITMAP/DBITMAP: The source bitmap.
2813 \end_layout
2815 \begin_layout Itemize
2816 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2817 \end_layout
2819 \begin_layout Itemize
2820 sx: number: The x-coordinate in source.
2821 \end_layout
2823 \begin_layout Itemize
2824 sy: number: The y-coordinate in source.
2825 \end_layout
2827 \begin_layout Itemize
2828 w: number: The width of area to blit.
2829 \end_layout
2831 \begin_layout Itemize
2832 h: number: The height of area to blit.
2833 \end_layout
2835 \begin_layout Itemize
2836 hscl: number: Horizontal scale factor (integer).
2837 \end_layout
2839 \begin_layout Itemize
2840 vscl: number: Vertical scale factor (integer).
2841  Defaults to the same as <hscl>.
2842 \end_layout
2844 \begin_layout Itemize
2845 ck: number: The color key.
2846  Pixels with this index are not copied.
2847 \begin_inset Separator latexpar
2848 \end_inset
2851 \end_layout
2853 \begin_deeper
2854 \begin_layout Itemize
2855 If none is specified, all pixels are copied.
2856 \end_layout
2858 \begin_layout Itemize
2859 If <src> is paletted, this is color index, otherwise it is a color.
2860 \end_layout
2862 \end_deeper
2863 \begin_layout Standard
2864 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2865  neighbor) by factor of <hscl>*<vscl>.
2866 \end_layout
2868 \begin_layout Subsubsection
2869 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2870 \end_layout
2872 \begin_layout Itemize
2873 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2874 \end_layout
2876 \begin_layout Itemize
2877 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2878 \end_layout
2880 \begin_layout Itemize
2881 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2882 \end_layout
2884 \begin_layout Standard
2885 Parameters:
2886 \end_layout
2888 \begin_layout Itemize
2889 dest: DBITMAP: The target bitmap to blit to.
2890 \end_layout
2892 \begin_layout Itemize
2893 dx: number: The x-coordinate in target.
2894 \end_layout
2896 \begin_layout Itemize
2897 dy: number: The y-coordinate in target.
2898 \end_layout
2900 \begin_layout Itemize
2901 src: BITMAP/DBITMAP: The source bitmap.
2902 \end_layout
2904 \begin_layout Itemize
2905 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2906 \end_layout
2908 \begin_layout Itemize
2909 sx: number: The x-coordinate in source.
2910 \end_layout
2912 \begin_layout Itemize
2913 sy: number: The y-coordinate in source.
2914 \end_layout
2916 \begin_layout Itemize
2917 w: number: The width of area to blit.
2918 \end_layout
2920 \begin_layout Itemize
2921 h: number: The height of area to blit.
2922 \end_layout
2924 \begin_layout Itemize
2925 operator: string: The operator to use.
2926 \begin_inset Separator latexpar
2927 \end_inset
2930 \end_layout
2932 \begin_deeper
2933 \begin_layout Itemize
2934 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2935  DestOut, Clear or Xor.
2936 \end_layout
2938 \end_deeper
2939 \begin_layout Standard
2940 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2941 f operator.
2943 \end_layout
2945 \begin_layout Itemize
2946 In target, fully transparent is background.
2947  In source, either fully transparent (if direct) or index 0 (if paletted)
2948  is treated as background.
2949 \end_layout
2951 \begin_layout Subsubsection
2952 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2953  Porter-Duff composition
2954 \end_layout
2956 \begin_layout Itemize
2957 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2958  operator)
2959 \end_layout
2961 \begin_layout Itemize
2962 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2963  [vscl], operator)
2964 \end_layout
2966 \begin_layout Itemize
2967 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2968 \end_layout
2970 \begin_layout Standard
2971 Parameters:
2972 \end_layout
2974 \begin_layout Itemize
2975 dest: DBITMAP: The target bitmap to blit to.
2976 \end_layout
2978 \begin_layout Itemize
2979 dx: number: The x-coordinate in target.
2980 \end_layout
2982 \begin_layout Itemize
2983 dy: number: The y-coordinate in target.
2984 \end_layout
2986 \begin_layout Itemize
2987 src: BITMAP/DBITMAP: The source bitmap.
2988 \end_layout
2990 \begin_layout Itemize
2991 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2992 \end_layout
2994 \begin_layout Itemize
2995 sx: number: The x-coordinate in source.
2996 \end_layout
2998 \begin_layout Itemize
2999 sy: number: The y-coordinate in source.
3000 \end_layout
3002 \begin_layout Itemize
3003 w: number: The width of area to blit.
3004 \end_layout
3006 \begin_layout Itemize
3007 h: number: The height of area to blit.
3008 \end_layout
3010 \begin_layout Itemize
3011 hscl: number: Horizontal scale factor (integer).
3012 \end_layout
3014 \begin_layout Itemize
3015 vscl: number: Vertical scale factor (integer).
3016  Defaults to the same as <hscl>.
3017 \end_layout
3019 \begin_layout Itemize
3020 operator: string: The operator to use.
3021 \begin_inset Separator latexpar
3022 \end_inset
3025 \end_layout
3027 \begin_deeper
3028 \begin_layout Itemize
3029 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
3030  DestOut, Clear or Xor.
3031 \end_layout
3033 \end_deeper
3034 \begin_layout Standard
3035 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
3036  like DBITMAP:blit_scaled.
3037 \end_layout
3039 \begin_layout Subsubsection
3040 Method adjust_transparency: Adjust transparency of bitmap
3041 \end_layout
3043 \begin_layout Itemize
3044 Syntax: bitmap:adjust_transparency(newvalue)
3045 \end_layout
3047 \begin_layout Itemize
3048 Deprecated: gui.adjust_transparency(bitmap, ...)
3049 \end_layout
3051 \begin_layout Standard
3052 Parameters:
3053 \end_layout
3055 \begin_layout Itemize
3056 bitmap: DBITMAP: The bitmap to adjust.
3057 \end_layout
3059 \begin_layout Itemize
3060 Number adj: The factor to multiply opaqueness with times 256.
3061 \end_layout
3063 \begin_layout Standard
3064 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
3065 \end_layout
3067 \begin_layout Subsubsection
3068 Method save_png: Save a bitmap to PNG
3069 \end_layout
3071 \begin_layout Itemize
3072 Syntax: bitmap:save_png(filename, [base])
3073 \end_layout
3075 \begin_layout Itemize
3076 Syntax: data bitmap:save_png()
3077 \end_layout
3079 \begin_layout Itemize
3080 Deprecated: ...
3081  gui.bitmap_save_png(bitmap, ...)
3082 \end_layout
3084 \begin_layout Standard
3085 Parameters:
3086 \end_layout
3088 \begin_layout Itemize
3089 bitmap: DBITMAP: The bitmap to save.
3090 \end_layout
3092 \begin_layout Itemize
3093 filename: string: The filename to save to.
3094 \end_layout
3096 \begin_layout Itemize
3097 base: string: The base filename is resolved relative to.
3098 \end_layout
3100 \begin_layout Standard
3101 Return value:
3102 \end_layout
3104 \begin_layout Itemize
3105 data: string: BASE64 encoded PNG data.
3106 \end_layout
3108 \begin_layout Standard
3109 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
3110  BASE64 encoding of it.
3111 \end_layout
3113 \begin_layout Subsubsection
3114 Method hash: Hash a bitmap
3115 \end_layout
3117 \begin_layout Itemize
3118 Syntax: hash bitmap:hash()
3119 \end_layout
3121 \begin_layout Itemize
3122 Deprecated: hash bitmap:hash(bitmap)
3123 \end_layout
3125 \begin_layout Standard
3126 Parameters:
3127 \end_layout
3129 \begin_layout Itemize
3130 bitmap: DBITMAP: The bitmap to hash.
3131 \end_layout
3133 \begin_layout Standard
3134 Return value:
3135 \end_layout
3137 \begin_layout Itemize
3138 hash: string: 64-hex digit hash
3139 \end_layout
3141 \begin_layout Standard
3142 Hashes bitmap <bitmap> and returns crypto-strong hash.
3144 \end_layout
3146 \begin_layout Subsubsection
3147 Method sample_texture: Sample a texture
3148 \end_layout
3150 \begin_layout Itemize
3151 Syntax: none bitmap:sample_texture(BITMAP source, number xx, number xy,
3152  number x0, number yx, number yy, number y0, number scale, boolean wrap)
3153 \end_layout
3155 \begin_layout Standard
3156 Parameters:
3157 \end_layout
3159 \begin_layout Itemize
3160 source: BITMAP: The bitmap to sample
3161 \end_layout
3163 \begin_layout Itemize
3164 xx: number: s times the source x coefficient of target x axis.
3165 \end_layout
3167 \begin_layout Itemize
3168 xy: number: s times the source y coefficient of target x axis.
3169 \end_layout
3171 \begin_layout Itemize
3172 x0: number: s times the target x axis offset.
3173 \end_layout
3175 \begin_layout Itemize
3176 yx: number: s times the source x coefficient of target y axis.
3177 \end_layout
3179 \begin_layout Itemize
3180 yy: number: s times the source y coefficient of target y axis.
3181 \end_layout
3183 \begin_layout Itemize
3184 y0: number: s times the target y axis offset.
3185 \end_layout
3187 \begin_layout Itemize
3188 s: number: Scale of coordinates
3189 \end_layout
3191 \begin_layout Itemize
3192 wrap: boolean: If true, wrap the texture.
3193  If false, read outside the texture as color 0.
3194 \end_layout
3196 \begin_layout Standard
3197 Samples the source as texture, performing linear transform (with nearest-neighbo
3198 r sampling) and writes the result to this bitmap.
3199 \begin_inset Newpage pagebreak
3200 \end_inset
3203 \end_layout
3205 \begin_layout Subsection
3206 IMAGELOADER: Load an image
3207 \end_layout
3209 \begin_layout Subsubsection
3210 Static function load: Load a bitmap from file
3211 \end_layout
3213 \begin_layout Itemize
3214 Syntax: bitmap, palette gui.image.load(file, [base])
3215 \end_layout
3217 \begin_layout Itemize
3218 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3219 \end_layout
3221 \begin_layout Itemize
3222 Deprecated: ...
3223  gui.bitmap_load(...)
3224 \end_layout
3226 \begin_layout Standard
3227 Parameters:
3228 \end_layout
3230 \begin_layout Itemize
3231 file: string: The file to read.
3232 \end_layout
3234 \begin_layout Itemize
3235 base: string: The base to resolve <file> relative to.
3236 \end_layout
3238 \begin_layout Standard
3239 Returns:
3240 \end_layout
3242 \begin_layout Itemize
3243 bitmap: BITMAP/DBITMAP: The new bitmap
3244 \end_layout
3246 \begin_layout Itemize
3247 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3248  nil.
3249 \end_layout
3251 \begin_layout Standard
3252 Load a new bitmap and return it (plus associated palette if any).
3253 \end_layout
3255 \begin_layout Subsubsection
3256 Static function load_str: Load a bitmap from string
3257 \end_layout
3259 \begin_layout Itemize
3260 Syntax: bitmap, palette gui.image.load_str(data)
3261 \end_layout
3263 \begin_layout Itemize
3264 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3265 \end_layout
3267 \begin_layout Itemize
3268 Deprecated: ...
3269  gui.bitmap_load_str(...)
3270 \end_layout
3272 \begin_layout Standard
3273 Parameters:
3274 \end_layout
3276 \begin_layout Itemize
3277 data: string: The image data
3278 \end_layout
3280 \begin_layout Standard
3281 Returns:
3282 \end_layout
3284 \begin_layout Itemize
3285 bitmap: BITMAP/DBITMAP: The new bitmap
3286 \end_layout
3288 \begin_layout Itemize
3289 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3290  nil.
3291 \end_layout
3293 \begin_layout Standard
3294 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3295  file.
3296 \end_layout
3298 \begin_layout Subsubsection
3299 Static function load_png: Load a bitmap from PNG file
3300 \end_layout
3302 \begin_layout Itemize
3303 Syntax: bitmap, palette gui.image.load_png(file, [base])
3304 \end_layout
3306 \begin_layout Itemize
3307 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3308 \end_layout
3310 \begin_layout Itemize
3311 Deprecated: ...
3312  gui.bitmap_load_png(...)
3313 \end_layout
3315 \begin_layout Standard
3316 Parameters:
3317 \end_layout
3319 \begin_layout Itemize
3320 file: string: The file to read.
3321 \end_layout
3323 \begin_layout Itemize
3324 base: string: The base to resolve <file> relative to.
3325 \end_layout
3327 \begin_layout Standard
3328 Returns:
3329 \end_layout
3331 \begin_layout Itemize
3332 bitmap: BITMAP/DBITMAP: The new bitmap
3333 \end_layout
3335 \begin_layout Itemize
3336 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3337  nil.
3338 \end_layout
3340 \begin_layout Standard
3341 Like IMAGELOADER:load, but load a PNG file instead.
3342 \end_layout
3344 \begin_layout Subsubsection
3345 Static function load_png_str: Load a PNG bitmap from string
3346 \end_layout
3348 \begin_layout Itemize
3349 Syntax: bitmap, palette gui.image.load_png_str(data)
3350 \end_layout
3352 \begin_layout Itemize
3353 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3354 \end_layout
3356 \begin_layout Itemize
3357 Deprecated: ...
3358  gui.bitmap_load_png_str(...)
3359 \end_layout
3361 \begin_layout Standard
3362 Parameters:
3363 \end_layout
3365 \begin_layout Itemize
3366 data: string: The image data, base64 encoded.
3367 \end_layout
3369 \begin_layout Standard
3370 Returns:
3371 \end_layout
3373 \begin_layout Itemize
3374 bitmap: BITMAP/DBITMAP: The new bitmap
3375 \end_layout
3377 \begin_layout Itemize
3378 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3379  nil.
3380 \end_layout
3382 \begin_layout Standard
3383 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3384  <data> instead of file.
3385 \end_layout
3387 \begin_layout Standard
3388 \begin_inset Newpage pagebreak
3389 \end_inset
3392 \end_layout
3394 \begin_layout Subsection
3395 CUSTOMFONT: Arbitrary-sized bitmap font
3396 \end_layout
3398 \begin_layout Subsubsection
3399 Static function new: Return a new empty font
3400 \end_layout
3402 \begin_layout Itemize
3403 Syntax: font gui.font.new()
3404 \end_layout
3406 \begin_layout Itemize
3407 Syntax: font classes.CUSTOMFONT.new()
3408 \end_layout
3410 \begin_layout Itemize
3411 Deprecated: font gui.font_new()
3412 \end_layout
3414 \begin_layout Standard
3415 Return value:
3416 \end_layout
3418 \begin_layout Itemize
3419 font: CUSTOMFONT: New font.
3420 \end_layout
3422 \begin_layout Standard
3423 Create a new font with no characters and return it.
3424 \end_layout
3426 \begin_layout Subsubsection
3427 Static function: load: Load a font file
3428 \end_layout
3430 \begin_layout Itemize
3431 Syntax: font gui.font.load(file, [base])
3432 \end_layout
3434 \begin_layout Itemize
3435 Syntax: font gui.font.load()
3436 \end_layout
3438 \begin_layout Itemize
3439 Syntax: font classes.CUSTOMFONT.load(file, [base])
3440 \end_layout
3442 \begin_layout Itemize
3443 Syntax: font classes.CUSTOMFONT.load()
3444 \end_layout
3446 \begin_layout Itemize
3447 Deprecated: font gui.loadfont(...)
3448 \end_layout
3450 \begin_layout Standard
3451 Parameters:
3452 \end_layout
3454 \begin_layout Itemize
3455 file: string: The file to read the font from
3456 \end_layout
3458 \begin_layout Itemize
3459 base: string: The file to resolve <file> relative to.
3460 \end_layout
3462 \begin_layout Standard
3463 Return value:
3464 \end_layout
3466 \begin_layout Itemize
3467 font: CUSTOMFONT: New font.
3468 \end_layout
3470 \begin_layout Standard
3471 Load font from file <file> (relative to <base>).
3472  If no filename is given, system default font is loaded.
3473 \end_layout
3475 \begin_layout Subsubsection
3476 operator(): Render text to screen
3477 \end_layout
3479 \begin_layout Itemize
3480 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3481 \end_layout
3483 \begin_layout Standard
3484 Parmeters:
3485 \end_layout
3487 \begin_layout Itemize
3488 font: CUSTOMFONT: The font to use.
3489 \end_layout
3491 \begin_layout Itemize
3492 x: number: The x-position on screen to draw to.
3493 \end_layout
3495 \begin_layout Itemize
3496 y: number: The y-position on screen to draw to.
3497 \end_layout
3499 \begin_layout Itemize
3500 text: string: The text to draw.
3501 \end_layout
3503 \begin_layout Itemize
3504 fgc: number/string: Foreground color (default white).
3505 \end_layout
3507 \begin_layout Itemize
3508 bgc: number/string: Background color (default transparent).
3509 \end_layout
3511 \begin_layout Itemize
3512 hlc: number/string: Outline color (default transparent).
3513 \end_layout
3515 \begin_layout Standard
3516 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3517  onto screen.
3518 \end_layout
3520 \begin_layout Itemize
3521 If <hlc> is transparent, no outline is drawn.
3522 \end_layout
3524 \begin_layout Subsubsection
3525 Method edit: Alter glyph in font
3526 \end_layout
3528 \begin_layout Itemize
3529 Syntax: font:edit(string character, bitmap glyph)
3530 \end_layout
3532 \begin_layout Standard
3533 Parameters:
3534 \end_layout
3536 \begin_layout Itemize
3537 font: CUSTOMFONT: The font to edit.
3538 \end_layout
3540 \begin_layout Itemize
3541 character: string: The character to edit (UTF-8 encoded).
3542 \end_layout
3544 \begin_layout Itemize
3545 glyph: BITMAP: The bitmap to use.
3546 \end_layout
3548 \begin_layout Standard
3549 Replace character <character> in font <font> by <glyph>.
3550 \end_layout
3552 \begin_layout Itemize
3553 Color index 0 is background, everything else is foreground.
3554 \end_layout
3556 \begin_layout Itemize
3557 <character> may be empty string, meaning the replacement character used
3558  for bad characters.
3559 \end_layout
3561 \begin_layout Itemize
3562 <character> may be multi-codepoint string, meaning character used for that
3563  ligature.
3564 \end_layout
3566 \begin_layout Subsubsection
3567 Method dump: Dump font into file
3568 \end_layout
3570 \begin_layout Itemize
3571 Syntax: font:dump(string filename[, string base])
3572 \end_layout
3574 \begin_layout Standard
3575 Parameters:
3576 \end_layout
3578 \begin_layout Itemize
3579 filename: string: The file to dump to
3580 \end_layout
3582 \begin_layout Itemize
3583 base: string: The base filename
3584 \end_layout
3586 \begin_layout Standard
3587 Dump contents of <font> in file <filename> (resolved relative to <base>).
3588  The dump is in format CUSTOMFONT:load() can load.
3589 \end_layout
3591 \begin_layout Standard
3592 \begin_inset Newpage pagebreak
3593 \end_inset
3596 \end_layout
3598 \begin_layout Subsection
3599 ICONV: Character set conversions
3600 \end_layout
3602 \begin_layout Subsubsection
3603 Static function new: Create new character set converter
3604 \end_layout
3606 \begin_layout Itemize
3607 Syntax: iconv iconv.new(from, to);
3608 \end_layout
3610 \begin_layout Itemize
3611 Syntax: iconv classes.ICONV.new(from, to);
3612 \end_layout
3614 \begin_layout Itemize
3615 Deprecated: iconv iconv_new(...);
3616 \end_layout
3618 \begin_layout Standard
3619 Parameters:
3620 \end_layout
3622 \begin_layout Itemize
3623 from: string: The source character set.
3624 \end_layout
3626 \begin_layout Itemize
3627 to: string: The target character set.
3628 \end_layout
3630 \begin_layout Standard
3631 Returns:
3632 \end_layout
3634 \begin_layout Itemize
3635 iconv: ICONV: The converter.
3636 \end_layout
3638 \begin_layout Standard
3639 Create a character set converter, converting from <from> to <to> and return
3640  it.
3641 \end_layout
3643 \begin_layout Subsubsection
3644 Operator(): Convert string fragment from character set to another
3645 \end_layout
3647 \begin_layout Itemize
3648 Syntax: success, result, unconverted, error iconv(input)
3649 \end_layout
3651 \begin_layout Standard
3652 Parameters:
3653 \end_layout
3655 \begin_layout Itemize
3656 iconv: ICONV: The context to use.
3657 \end_layout
3659 \begin_layout Itemize
3660 input: string: The input to convert.
3661 \end_layout
3663 \begin_layout Standard
3664 Return value:
3665 \end_layout
3667 \begin_layout Itemize
3668 success: boolean: True if conversion was successful, false if not.
3669 \end_layout
3671 \begin_layout Itemize
3672 result: string: The string (partially) converted.
3673 \end_layout
3675 \begin_layout Itemize
3676 unconvered: number: Number of bytes that were not converted (only if <success>
3677  is false).
3678 \end_layout
3680 \begin_layout Itemize
3681 error: string: Error that caused conversion to stop (only if <success> is
3682  false).
3683 \begin_inset Separator latexpar
3684 \end_inset
3687 \end_layout
3689 \begin_deeper
3690 \begin_layout Itemize
3691 INVALID: The input string is invalid.
3692 \end_layout
3694 \begin_layout Itemize
3695 INCOMPLETE: The input string cuts off in middle of character.
3696 \end_layout
3698 \begin_layout Itemize
3699 INTERNALERR: Internal error.
3700 \end_layout
3702 \end_deeper
3703 \begin_layout Standard
3704 Convert a string <input> using character set converter <iconv> and return
3705  the result.
3706 \end_layout
3708 \begin_layout Standard
3709 \begin_inset Newpage pagebreak
3710 \end_inset
3713 \end_layout
3715 \begin_layout Subsection
3716 FILEREADER: Read a file as a stream
3717 \end_layout
3719 \begin_layout Subsubsection
3720 Static function open: Open a stream
3721 \end_layout
3723 \begin_layout Itemize
3724 Syntax: handle filereader.open(file, [base])
3725 \end_layout
3727 \begin_layout Itemize
3728 Syntax: handle classes.FILEREADER.open(file, [base])
3729 \end_layout
3731 \begin_layout Itemize
3732 Deprecated: handle open_file(file, [base])
3733 \end_layout
3735 \begin_layout Standard
3736 Parameters:
3737 \end_layout
3739 \begin_layout Itemize
3740 file: string: The filename to read.
3741 \end_layout
3743 \begin_layout Itemize
3744 base: string: The base <file> is resolved against.
3745 \end_layout
3747 \begin_layout Standard
3748 Returns:
3749 \end_layout
3751 \begin_layout Itemize
3752 handle: FILEREADER: The new file reader.
3753 \end_layout
3755 \begin_layout Standard
3756 Open file <file> (relative to <base>) and return a handle to it.
3757 \end_layout
3759 \begin_layout Subsubsection
3760 operator(): Read line/bytes from stream
3761 \end_layout
3763 \begin_layout Itemize
3764 Syntax: result handle()
3765 \end_layout
3767 \begin_layout Itemize
3768 Syntax: result handle(bytes)
3769 \end_layout
3771 \begin_layout Standard
3772 Parameters:
3773 \end_layout
3775 \begin_layout Itemize
3776 handle: FILEREADER: The handle to read from.
3777 \end_layout
3779 \begin_layout Itemize
3780 bytes: Number of bytes to read (default is next line).
3781 \end_layout
3783 \begin_layout Standard
3784 Returns:
3785 \end_layout
3787 \begin_layout Itemize
3788 result: string: The read data, or nil on end-of-file.
3789 \end_layout
3791 \begin_layout Standard
3792 Reads next line or <bytes> bytes from specified file handle <handle>.
3793 \end_layout
3795 \begin_layout Itemize
3796 If reading specified number of bytes, the bytes are read in binary mode
3797  (as-is).
3798 \end_layout
3800 \begin_layout Itemize
3801 If reading next line, the line is read in text mode (any line ending is
3802  skpped).
3803 \end_layout
3805 \begin_layout Subsubsection
3806 Method lines: Iterator to read all lines
3807 \end_layout
3809 \begin_layout Itemize
3810 Syntax: for line in handle:lines() do ...
3811  end
3812 \end_layout
3814 \begin_layout Standard
3815 Parameters:
3816 \end_layout
3818 \begin_layout Itemize
3819 handle: FILEREADER: The handle to read.
3820 \end_layout
3822 \begin_layout Standard
3823 Returns:
3824 \end_layout
3826 \begin_layout Itemize
3827 A lua iterator with one variable.
3828 \end_layout
3830 \begin_layout Standard
3831 Return a Lua iterator that iterates all the lines in <handle>.
3832 \end_layout
3834 \begin_layout Standard
3835 \begin_inset Newpage pagebreak
3836 \end_inset
3839 \end_layout
3841 \begin_layout Subsection
3842 COMPARE_OBJ: Watch memory area for changes
3843 \end_layout
3845 \begin_layout Standard
3846 Objects of this class allow fast checking for modifications to given memory
3847  block.
3848 \end_layout
3850 \begin_layout Subsubsection
3851 Static function new: Create a checker
3852 \end_layout
3854 \begin_layout Itemize
3855 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3856  stride])
3857 \end_layout
3859 \begin_layout Itemize
3860 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3861 \end_layout
3863 \begin_layout Standard
3864 Parameters:
3865 \end_layout
3867 \begin_layout Itemize
3868 marea: string: The memory area to interpret <offset> against.
3869 \end_layout
3871 \begin_layout Itemize
3872 offset: number: The initial offset in memory area.
3873 \end_layout
3875 \begin_layout Itemize
3876 addrobj: ADDRESS: The memory address.
3877 \end_layout
3879 \begin_layout Itemize
3880 size: number: The number of bytes in each row.
3881 \end_layout
3883 \begin_layout Itemize
3884 rows: number: The number of rows.
3885  Default is 1.
3886 \end_layout
3888 \begin_layout Itemize
3889 stride: number: The number of bytes offset increments from one row to next.
3890 \end_layout
3892 \begin_layout Standard
3893 Returns:
3894 \end_layout
3896 \begin_layout Itemize
3897 A handle to object.
3898 \end_layout
3900 \begin_layout Standard
3901 Return an object watching specified memory area.
3902 \end_layout
3904 \begin_layout Itemize
3905 Note: For fastest operation, limit checks to inside one memory area (that
3906  has to be mappable, individual RAM areas often are).
3907 \end_layout
3909 \begin_layout Subsubsection
3910 operator(): Check area for modifications
3911 \end_layout
3913 \begin_layout Itemize
3914 Syntax: boolean handle()
3915 \end_layout
3917 \begin_layout Standard
3918 Returns:
3919 \end_layout
3921 \begin_layout Itemize
3922 True if memory block has been modified since last call (or object creation
3923  if first call), false if not.
3924 \end_layout
3926 \begin_layout Standard
3927 Check if the block has been modified.
3928 \end_layout
3930 \begin_layout Subsection
3931 ADDRESS: Memory address
3932 \end_layout
3934 \begin_layout Standard
3935 Objects of this class contain a memory address.
3936 \end_layout
3938 \begin_layout Subsubsection
3939 Static function new: Create new memory address
3940 \end_layout
3942 \begin_layout Itemize
3943 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
3944 \end_layout
3946 \begin_layout Itemize
3947 Syntax: ADDRESS memory.address.new(string marea, number offset)
3948 \end_layout
3950 \begin_layout Itemize
3951 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
3952 \end_layout
3954 \begin_layout Standard
3955 Parameters:
3956 \end_layout
3958 \begin_layout Itemize
3959 marea: The memory area
3960 \end_layout
3962 \begin_layout Itemize
3963 offset: The offset in memory area.
3964 \end_layout
3966 \begin_layout Standard
3967 Returns:
3968 \end_layout
3970 \begin_layout Itemize
3971 The memory area.
3972 \end_layout
3974 \begin_layout Standard
3975 Construct a new memory address object.
3976 \end_layout
3978 \begin_layout Subsubsection
3979 Method: addr: Get global address
3980 \end_layout
3982 \begin_layout Itemize
3983 Syntax: number addr:addr()
3984 \end_layout
3986 \begin_layout Standard
3987 Parameters:
3988 \end_layout
3990 \begin_layout Itemize
3991 addr: ADRESS: The original address.
3992 \end_layout
3994 \begin_layout Standard
3995 Returns:
3996 \end_layout
3998 \begin_layout Itemize
3999 The global address corresponding to this address.
4000 \end_layout
4002 \begin_layout Subsubsection
4003 Method: vma: Get memory area
4004 \end_layout
4006 \begin_layout Itemize
4007 Syntax: string addr:vma()
4008 \end_layout
4010 \begin_layout Standard
4011 Parameters:
4012 \end_layout
4014 \begin_layout Itemize
4015 addr: ADRESS: The original address.
4016 \end_layout
4018 \begin_layout Standard
4019 Returns:
4020 \end_layout
4022 \begin_layout Itemize
4023 The memory area corresponding to this address.
4024 \end_layout
4026 \begin_layout Subsubsection
4027 Method: offset: Get memory area offset
4028 \end_layout
4030 \begin_layout Itemize
4031 Syntax: string addr:offset()
4032 \end_layout
4034 \begin_layout Standard
4035 Parameters:
4036 \end_layout
4038 \begin_layout Itemize
4039 addr: ADRESS: The original address.
4040 \end_layout
4042 \begin_layout Standard
4043 Returns:
4044 \end_layout
4046 \begin_layout Itemize
4047 The offset in memory area corresponding to this address.
4048 \end_layout
4050 \begin_layout Subsubsection
4051 Method: replace: Replace address part
4052 \end_layout
4054 \begin_layout Itemize
4055 Syntax: ADDRESS addr:replace(offset[, bits])
4056 \end_layout
4058 \begin_layout Standard
4059 Parameters:
4060 \end_layout
4062 \begin_layout Itemize
4063 addr: ADRESS: The original address.
4064 \end_layout
4066 \begin_layout Itemize
4067 offset: number: The new offset
4068 \end_layout
4070 \begin_layout Itemize
4071 bits: number: The number of LSB to replace.
4072 \end_layout
4074 \begin_layout Standard
4075 Returns:
4076 \end_layout
4078 \begin_layout Itemize
4079 The modified address
4080 \end_layout
4082 \begin_layout Standard
4083 Returns a new address, with <bits> (all if missing) least significant bits
4084  of <addr> replaced by LSB of <offset>.
4085 \end_layout
4087 \begin_layout Subsubsection
4088 Method: add: Add to address
4089 \end_layout
4091 \begin_layout Itemize
4092 Syntax: ADDRESS addr:add(offset)
4093 \end_layout
4095 \begin_layout Itemize
4096 Syntax: ADDRESS addr:add(number, stride)
4097 \end_layout
4099 \begin_layout Itemize
4100 Syntax: ADDRESS addr:add(number, stride, offset)
4101 \end_layout
4103 \begin_layout Standard
4104 Parameters:
4105 \end_layout
4107 \begin_layout Itemize
4108 addr: ADRESS: The original address.
4109 \end_layout
4111 \begin_layout Itemize
4112 offset: number: Offset to add.
4113 \end_layout
4115 \begin_layout Itemize
4116 number: number: Number of table strides to add.
4117 \end_layout
4119 \begin_layout Itemize
4120 stride: number: The table stride.
4121 \end_layout
4123 \begin_layout Standard
4124 Returns:
4125 \end_layout
4127 \begin_layout Itemize
4128 The modified address
4129 \end_layout
4131 \begin_layout Standard
4132 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
4133  address <addr>.
4134 \end_layout
4136 \begin_layout Subsection
4137 ADDRESS:<op>: Read/Write memory
4138 \end_layout
4140 \begin_layout Itemize
4141 Syntax: none addr:<op>(value)
4142 \end_layout
4144 \begin_layout Itemize
4145 Syntax: number addr:<op>()
4146 \end_layout
4148 \begin_layout Standard
4149 Parameters:
4150 \end_layout
4152 \begin_layout Itemize
4153 addr: ADDRESS: The address to read/write.
4154 \end_layout
4156 \begin_layout Itemize
4157 value: number: The number to write.
4158 \end_layout
4160 \begin_layout Standard
4161 Returns:
4162 \end_layout
4164 \begin_layout Itemize
4165 The value read.
4166 \end_layout
4168 \begin_layout Standard
4169 Read/Write value from/to given address <addr>.
4170  The value written is <value>.
4171  <Op> is of form: [i][s]<type>, where:
4172 \end_layout
4174 \begin_layout Itemize
4175 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
4176 \end_layout
4178 \begin_layout Itemize
4179 'i' signifies that the value is treated as opposite-to-normal endianess,
4180 \end_layout
4182 \begin_layout Itemize
4183 's' signifies that value is treated as signed (not available for floating-point).
4184 \end_layout
4186 \begin_layout Standard
4187 \begin_inset Newpage pagebreak
4188 \end_inset
4191 \end_layout
4193 \begin_layout Section
4194 Global
4195 \end_layout
4197 \begin_layout Subsection
4198 print: Print values to console
4199 \end_layout
4201 \begin_layout Itemize
4202 Syntax: none print(value...
4203  values)
4204 \end_layout
4206 \begin_layout Standard
4207 Prints specified values to console.
4208  Can print any Lua type at least enough to identify the type and instance.
4209 \end_layout
4211 \begin_layout Subsection
4212 tostringx: Format a value to string
4213 \end_layout
4215 \begin_layout Itemize
4216 Syntax: string tostringx(value val)
4217 \end_layout
4219 \begin_layout Standard
4220 Formats value <val> like print would, and returns the result as a string.
4221 \end_layout
4223 \begin_layout Subsection
4224 exec: Execute lsnes commands
4225 \end_layout
4227 \begin_layout Itemize
4228 Syntax: none exec(string cmd)
4229 \end_layout
4231 \begin_layout Standard
4232 Execute lsnes command <cmd>.
4233 \end_layout
4235 \begin_layout Subsection
4236 utime: Get current time
4237 \end_layout
4239 \begin_layout Itemize
4240 Syntax: (number,number) utime()
4241 \end_layout
4243 \begin_layout Standard
4244 Returns two numbers.
4245  First is time since some epoch in seconds, the second is microseconds mod
4246  10^6 since that epoch.
4247 \end_layout
4249 \begin_layout Subsection
4250 set_idle_timeout: Run function after timeout when emulator is idle
4251 \end_layout
4253 \begin_layout Itemize
4254 Syntax: none set_idle_timeout(number timeout)
4255 \end_layout
4257 \begin_layout Standard
4258 Set number of microseconds to block idle for.
4259  After this timeout has expired, on_idle() will be called once.
4260 \end_layout
4262 \begin_layout Subsection
4263 set_timer_timeout: Run function after timeout.
4264 \end_layout
4266 \begin_layout Itemize
4267 Syntax: none set_timer_timeout(number timeout)
4268 \end_layout
4270 \begin_layout Standard
4271 Set number of microseconds to block timer for.
4272  After this timeout has expired, on_timer() will be called once.
4273 \end_layout
4275 \begin_layout Subsection
4276 bus_address: Look up address in system bus.
4277 \end_layout
4279 \begin_layout Itemize
4280 Syntax: none bus_address(number bus_addr)
4281 \end_layout
4283 \begin_layout Standard
4284 Returns virtual address corresponding to specified address on system bus.
4285 \end_layout
4287 \begin_layout Subsection
4288 loopwrapper: Convert loop into callable function
4289 \end_layout
4291 \begin_layout Itemize
4292 Syntax: function loopwrapper(function fun, ...)
4293 \end_layout
4295 \begin_layout Standard
4296 Calls function <fun> with function and specified arguments.
4297  The function passed suspends execution until the function returned is called.
4298  Handy for linear flow control among multiple invocations of a hook.
4299  Example code:
4300 \end_layout
4302 \begin_layout LyX-Code
4303 on_paint = loopwrapper(function(wait)
4304 \begin_inset Separator latexpar
4305 \end_inset
4308 \end_layout
4310 \begin_deeper
4311 \begin_layout LyX-Code
4312 while true do
4313 \begin_inset Separator latexpar
4314 \end_inset
4317 \end_layout
4319 \begin_deeper
4320 \begin_layout LyX-Code
4321 gui.text(0, 0, 
4322 \begin_inset Quotes eld
4323 \end_inset
4325 Test!
4326 \begin_inset Quotes erd
4327 \end_inset
4330 \end_layout
4332 \begin_layout LyX-Code
4333 wait();
4334 \end_layout
4336 \end_deeper
4337 \begin_layout LyX-Code
4339 \end_layout
4341 \end_deeper
4342 \begin_layout LyX-Code
4343 end);
4344 \end_layout
4346 \begin_layout Subsection
4347 list_bindings: List keybindings
4348 \end_layout
4350 \begin_layout Itemize
4351 Syntax: table list_bindings([string cmd])
4352 \end_layout
4354 \begin_layout Standard
4355 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4356  If <cmd> is specified, the table is limited to that command.
4357  Also searches for controller keys.
4358 \end_layout
4360 \begin_layout Subsection
4361 get_alias: Get expansion of alias
4362 \end_layout
4364 \begin_layout Itemize
4365 Syntax: string get_alias(string aname)
4366 \end_layout
4368 \begin_layout Standard
4369 Get expansion of given alias <aname>.
4370 \end_layout
4372 \begin_layout Subsection
4373 set_alias: Set expansion of alias
4374 \end_layout
4376 \begin_layout Itemize
4377 Syntax: none set_alias(string aname, string value)
4378 \end_layout
4380 \begin_layout Standard
4381 Set expansion of given alias.
4382 \end_layout
4384 \begin_layout Subsection
4385 create_ibind: Create invese binding
4386 \end_layout
4388 \begin_layout Itemize
4389 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4390 \end_layout
4392 \begin_layout Standard
4393 Return object representing inverse binding with specified name <name> and
4394  specified command <cmd>.
4395 \end_layout
4397 \begin_layout Itemize
4398 Note: To create press/release commands, use aliases +foo and -foo .
4399 \end_layout
4401 \begin_layout Itemize
4402 Note: Keep the returned object around.
4403 \end_layout
4405 \begin_layout Subsection
4406 create_command: Create a command
4407 \end_layout
4409 \begin_layout Itemize
4410 Syntax: COMMANDBIND create_command(string name, function a)
4411 \end_layout
4413 \begin_layout Itemize
4414 Syntax: COMMANDBIND create_command(string name, function a, function b)
4415 \end_layout
4417 \begin_layout Standard
4418 Return object representing a command (pair).
4419 \end_layout
4421 \begin_layout Itemize
4422 If only one function is specied, the command is level-sensitive, <a> is
4423  callback.
4424 \end_layout
4426 \begin_layout Itemize
4427 If <b> is function, the function is edge-sensitive, <a> is positive edge
4428  callback and <b> is negative edge callback.
4429 \end_layout
4431 \begin_layout Itemize
4432 All callbacks get single argument: The parameters passed.
4433 \end_layout
4435 \begin_layout Itemize
4436 Keep the returned object around.
4437 \end_layout
4439 \begin_layout Subsection
4440 loadfile: Load Lua script
4441 \end_layout
4443 \begin_layout Itemize
4444 Syntax: function loadfile(string filename[, string base])
4445 \end_layout
4447 \begin_layout Standard
4448 Load lua script from <filename>, resolved relative to <base> (if empty,
4449  current directory).
4450 \end_layout
4452 \begin_layout Subsection
4453 dofile: Execute Lua script
4454 \end_layout
4456 \begin_layout Itemize
4457 Syntax: function dofile(string filename[, string base])
4458 \end_layout
4460 \begin_layout Standard
4461 Execute lua script from <filename>, resolved relative to <base> (if empty,
4462  current directory) and return all return values.
4463 \end_layout
4465 \begin_layout Subsection
4466 resolve_filename: Resolve name of file relative to another
4467 \end_layout
4469 \begin_layout Itemize
4470 Syntax: string resolve_filename(string filename[, string base])
4471 \end_layout
4473 \begin_layout Standard
4474 Resolve name of file <filename> relative to <base> and return the result.
4475 \end_layout
4477 \begin_layout Subsection
4478 render_queue_function: Return paint function for render queue
4479 \end_layout
4481 \begin_layout Itemize
4482 Syntax: function render_queue_function(RENDERQUEUE rq)
4483 \end_layout
4485 \begin_layout Standard
4486 Return function that renders render queue <rq>.
4487 \end_layout
4489 \begin_layout Itemize
4490 Handy for paint callback if one is using render queues updated in other
4491  callbacks.
4492  As in:
4493 \end_layout
4495 \begin_layout LyX-Code
4496 handle = callback.paint:register(render_queue_function(my_rq));
4497 \end_layout
4499 \begin_layout Subsection
4500 get_directory_contents: Get files in directory
4501 \end_layout
4503 \begin_layout Itemize
4504 Syntax: table get_directory_contents(string name[, string base[, string
4505  pattern]])
4506 \end_layout
4508 \begin_layout Standard
4509 Return array containg all files in specified directory <name> (relative
4510  to <base>).
4511  If <pattern> is specified, the filenames are matched to specified regex.
4512  The returned filenames inherit path.
4513 \end_layout
4515 \begin_layout Subsection
4516 get_file_type: Get type of file
4517 \end_layout
4519 \begin_layout Itemize
4520 Syntax: string/nil get_file_type(string path)
4521 \end_layout
4523 \begin_layout Standard
4524 Return type of file <path>.
4525  Currently possible return values are:
4526 \end_layout
4528 \begin_layout Itemize
4529 regular: regular file
4530 \end_layout
4532 \begin_layout Itemize
4533 directory: subdirectory
4534 \end_layout
4536 \begin_layout Itemize
4537 unknown: Exists, but type not known (not anything above).
4538 \end_layout
4540 \begin_layout Itemize
4541 <nil>: File does not exist.
4542 \end_layout
4544 \begin_layout Subsection
4545 identify_class: Identify class of object
4546 \end_layout
4548 \begin_layout Itemize
4549 Syntax: string identify_class(userdata object)
4550 \end_layout
4552 \begin_layout Standard
4553 Identifies the class of userdata <object>, if possible.
4554  If no identification is possible, returns 
4555 \begin_inset Quotes eld
4556 \end_inset
4558 unknown
4559 \begin_inset Quotes erd
4560 \end_inset
4563 \end_layout
4565 \begin_layout Subsection
4566 lookup_class: Lookup class by name
4567 \end_layout
4569 \begin_layout Itemize
4570 Syntax: classobj lookup_class(string name)
4571 \end_layout
4573 \begin_layout Standard
4574 Looks up class corresponding to <name>, if possible.
4575  If not found, returns nil.
4576  The classobj has following fields:
4577 \end_layout
4579 \begin_layout Itemize
4580 _static_methods: Return static method names
4581 \end_layout
4583 \begin_layout Itemize
4584 _class_methods: Return class method names
4585 \end_layout
4587 \begin_layout Itemize
4588 <static-function-name>: The specified static function.
4589 \end_layout
4591 \begin_layout Subsection
4592 all_classes: Get list of all classes
4593 \end_layout
4595 \begin_layout Itemize
4596 Syntax: string...
4597  all_classes()
4598 \end_layout
4600 \begin_layout Standard
4601 Get names of all classes available.
4602 \end_layout
4604 \begin_layout Subsection
4605 lsnes_features: Read feature flags
4606 \end_layout
4608 \begin_layout Itemize
4609 Syntax: boolean lsnes_features(string feature)
4610 \end_layout
4612 \begin_layout Standard
4613 Checks if feature <feature> is available, if it is, returns true, otherwise
4614  returns false.
4615  The following features are known:
4616 \end_layout
4618 \begin_layout Itemize
4619 text-halos: gui.text supports halos (takes halo color argument).
4620 \end_layout
4622 \begin_layout Subsection
4623 icnov: Class ICONV
4624 \end_layout
4626 \begin_layout Standard
4627 See class ICONV.
4628 \end_layout
4630 \begin_layout Subsection
4631 filereader: Class FILEREADER
4632 \end_layout
4634 \begin_layout Standard
4635 See class FILEREADER.
4636 \end_layout
4638 \begin_layout Standard
4639 \begin_inset Newpage pagebreak
4640 \end_inset
4643 \end_layout
4645 \begin_layout Section
4646 Table bit:
4647 \end_layout
4649 \begin_layout Standard
4650 Bitwise logical functions and related.
4651 \end_layout
4653 \begin_layout Subsection
4654 bit.none/bit.bnot: Bitwise none or NOT function
4655 \end_layout
4657 \begin_layout Itemize
4658 Syntax: number bit.none(number...)
4659 \end_layout
4661 \begin_layout Itemize
4662 Syntax: number bit.bnot(number...)
4663 \end_layout
4665 \begin_layout Standard
4666 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4667  arguments).
4668 \end_layout
4670 \begin_layout Subsection
4671 bit.any/bit.bor: Bitwise any or OR function
4672 \end_layout
4674 \begin_layout Itemize
4675 Syntax: number bit.any(number...)
4676 \end_layout
4678 \begin_layout Itemize
4679 Syntax: number bit.bor(number...)
4680 \end_layout
4682 \begin_layout Standard
4683 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4684 \end_layout
4686 \begin_layout Subsection
4687 bit.all/bit.band: Bitwise all or AND function
4688 \end_layout
4690 \begin_layout Itemize
4691 Syntax: number bit.all(number...)
4692 \end_layout
4694 \begin_layout Itemize
4695 Syntax: number bit.band(number...)
4696 \end_layout
4698 \begin_layout Standard
4699 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4701 \end_layout
4703 \begin_layout Subsection
4704 bit.parity/bit.bxor: Bitwise parity or XOR function
4705 \end_layout
4707 \begin_layout Itemize
4708 Syntax: number bit.parity(number...)
4709 \end_layout
4711 \begin_layout Itemize
4712 Syntax: number bit.bxor(number...)
4713 \end_layout
4715 \begin_layout Standard
4716 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4717  of the arguments).
4718 \end_layout
4720 \begin_layout Subsection
4721 bit.lrotate: Rotate a number left
4722 \end_layout
4724 \begin_layout Itemize
4725 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4726 \end_layout
4728 \begin_layout Standard
4729 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4730  1) places.
4731 \end_layout
4733 \begin_layout Subsection
4734 bit.rrotate: Rotate a number right
4735 \end_layout
4737 \begin_layout Itemize
4738 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4739 \end_layout
4741 \begin_layout Standard
4742 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4743  1) places.
4744 \end_layout
4746 \begin_layout Subsection
4747 bit.lshift: Shift a number left
4748 \end_layout
4750 \begin_layout Itemize
4751 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4752 \end_layout
4754 \begin_layout Standard
4755 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4756  1) places.
4757  The new bits are filled with zeroes.
4758 \end_layout
4760 \begin_layout Subsection
4761 bit.lrshift: Shift a number right (logical)
4762 \end_layout
4764 \begin_layout Itemize
4765 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4766 \end_layout
4768 \begin_layout Standard
4769 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4770  (default 1) places.
4771  The new bits are filled with zeroes.
4772 \end_layout
4774 \begin_layout Subsection
4775 bit.arshift: Shift a number right (arithmetic)
4776 \end_layout
4778 \begin_layout Itemize
4779 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4780 \end_layout
4782 \begin_layout Standard
4783 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4784  (default 1) places.
4785  The new bits are shifted in with copy of the high bit.
4786 \end_layout
4788 \begin_layout Subsection
4789 bit.extract: Extract/shuffle bits from number
4790 \end_layout
4792 \begin_layout Itemize
4793 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4794 \end_layout
4796 \begin_layout Standard
4797 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4798 \end_layout
4800 \begin_layout Itemize
4801 Note: Bit numbers up to 51 should work reliably (then things start falling
4802  apart due to double precision issues).
4803 \end_layout
4805 \begin_layout Itemize
4806 Note: There are two special bit positions, true and false, standing for
4807  always set bit and always clear bit.
4808 \end_layout
4810 \begin_layout Subsection
4811 bit.value: Construct number with specified bits set
4812 \end_layout
4814 \begin_layout Itemize
4815 Syntax: number bit.value([number bit1[, number bit2,...]])
4816 \end_layout
4818 \begin_layout Standard
4819 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4820  <bit2> places and so on.
4821  As special value, nil argument is no-op.
4822 \end_layout
4824 \begin_layout Subsection
4825 bit.test: Test if bit is set
4826 \end_layout
4828 \begin_layout Itemize
4829 Syntax: boolean bit.test(number a, number bit)
4830 \end_layout
4832 \begin_layout Standard
4833 Tests if bit <bit> is set in <a>.
4834  If it is set, returns true, otherwise false.
4835 \end_layout
4837 \begin_layout Subsection
4838 bit.testn: Test if bit is clear
4839 \end_layout
4841 \begin_layout Itemize
4842 Syntax: boolean bit.testn(number a, number bit)
4843 \end_layout
4845 \begin_layout Standard
4846 Tests if bit <bit> is set in <a>.
4847  If it is clear, returns true, otherwise false.
4848 \end_layout
4850 \begin_layout Subsection
4851 bit.test_any: Test if any bit is set
4852 \end_layout
4854 \begin_layout Itemize
4855 Syntax: boolean bit.test_any(number a, number b)
4856 \end_layout
4858 \begin_layout Standard
4859 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4860 \end_layout
4862 \begin_layout Subsection
4863 bit.test_all: Test if all bits are set
4864 \end_layout
4866 \begin_layout Itemize
4867 Syntax: boolean bit.test_all(number a, number b)
4868 \end_layout
4870 \begin_layout Standard
4871 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4872 \end_layout
4874 \begin_layout Subsection
4875 bit.popcount: Population count
4876 \end_layout
4878 \begin_layout Itemize
4879 Syntax: number bit.popcount(number a)
4880 \end_layout
4882 \begin_layout Standard
4883 Returns number of set bits in <a>.
4884 \end_layout
4886 \begin_layout Subsection
4887 bit.clshift: Chained left shift
4888 \end_layout
4890 \begin_layout Itemize
4891 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4892  bits]])
4893 \end_layout
4895 \begin_layout Standard
4896 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4897  numbers to be of specified number of bits <bits> (default 48).
4898 \end_layout
4900 \begin_layout Subsection
4901 bit.crshift: Chained right shift
4902 \end_layout
4904 \begin_layout Itemize
4905 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4906  bits]])
4907 \end_layout
4909 \begin_layout Standard
4910 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4911  assuming numbers to be of specified number of bits <bits> (default 48).
4912 \end_layout
4914 \begin_layout Subsection
4915 bit.flagdecode: Decode bitfield into flags
4916 \end_layout
4918 \begin_layout Itemize
4919 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4920  off]])
4921 \end_layout
4923 \begin_layout Standard
4924 Return string of length bits where ith character is ith character of on
4925  if bit i is on, otherwise ith character of off.
4926  Out of range reads give last character.
4927 \end_layout
4929 \begin_layout Itemize
4930 Note: <on> defaults to '*' if empty.
4931 \end_layout
4933 \begin_layout Itemize
4934 Note: <off> defaults to '-' if empty.
4935 \end_layout
4937 \begin_layout Subsection
4938 bit.rflagdecode: Decode bitfield into flags
4939 \end_layout
4941 \begin_layout Itemize
4942 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4943  off]])
4944 \end_layout
4946 \begin_layout Standard
4947 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4948 nt bit first).
4949 \end_layout
4951 \begin_layout Subsection
4952 bit.swap{,s}{,h,d,q}word: Swap word endian
4953 \end_layout
4955 \begin_layout Itemize
4956 Syntax: number bit.swapword(number n)
4957 \end_layout
4959 \begin_layout Itemize
4960 Syntax: number bit.swaphword(number n)
4961 \end_layout
4963 \begin_layout Itemize
4964 Syntax: number bit.swapdword(number n)
4965 \end_layout
4967 \begin_layout Itemize
4968 Syntax: number bit.swapqword(number n)
4969 \end_layout
4971 \begin_layout Itemize
4972 Syntax: number bit.swapsword(number n)
4973 \end_layout
4975 \begin_layout Itemize
4976 Syntax: number bit.swapshword(number n)
4977 \end_layout
4979 \begin_layout Itemize
4980 Syntax: number bit.swapsdword(number n)
4981 \end_layout
4983 \begin_layout Itemize
4984 Syntax: number bit.swapsqword(number n)
4985 \end_layout
4987 \begin_layout Standard
4988 Swap endianess of (un)signed integer <n>.
4989 \end_layout
4991 \begin_layout Subsection
4992 bit.compose: Compose multi-byte number
4993 \end_layout
4995 \begin_layout Itemize
4996 Syntax: number bit.compose(number n...)
4997 \end_layout
4999 \begin_layout Standard
5000 Return 
5001 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
5002 \end_inset
5005 \end_layout
5007 \begin_layout Subsection
5008 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
5009 \end_layout
5011 \begin_layout Itemize
5012 Syntax: number bit.binary_ld_<type>le(string str, number pos);
5013 \end_layout
5015 \begin_layout Itemize
5016 Syntax: number bit.binary_ld_<type>be(string str, number pos);
5017 \end_layout
5019 \begin_layout Standard
5020 Load little (*le) or big (*be) endian binary number from position <pos>
5021  of string <str>.
5022  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5023  double.
5024 \end_layout
5026 \begin_layout Subsection
5027 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
5028 \end_layout
5030 \begin_layout Itemize
5031 Syntax: string bit.binary_st_<type>le(number x);
5032 \end_layout
5034 \begin_layout Itemize
5035 Syntax: string bit.binary_st_<type>be(number x);
5036 \end_layout
5038 \begin_layout Standard
5039 Store specified number <x> as binary in string and return the result.
5040  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
5041  double.
5042 \end_layout
5044 \begin_layout Subsection
5045 bit.quotent: Integer quotent
5046 \end_layout
5048 \begin_layout Itemize
5049 Syntax: number bit.quotent(number a, number b)
5050 \end_layout
5052 \begin_layout Standard
5053 Calculate quotent a/b.
5054 \end_layout
5056 \begin_layout Subsection
5057 bit.multidiv: Divide and split among multiple divisiors
5058 \end_layout
5060 \begin_layout Itemize
5061 Syntax: number...
5062  bit.multidiv(number v, number q...)
5063 \end_layout
5065 \begin_layout Standard
5066 Does the following steps:
5067 \end_layout
5069 \begin_layout Enumerate
5070 Set v' to <v>.
5071 \end_layout
5073 \begin_layout Enumerate
5074 For each <q> q:
5075 \begin_inset Separator latexpar
5076 \end_inset
5079 \end_layout
5081 \begin_deeper
5082 \begin_layout Enumerate
5083 Calculate quotent(v'/q) and add that to numbers returned.
5084 \end_layout
5086 \begin_layout Enumerate
5087 v' <- remainder(v'/q)
5088 \end_layout
5090 \end_deeper
5091 \begin_layout Enumerate
5092 Add v' to numbers returned.
5093 \end_layout
5095 \begin_layout Standard
5096 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
5097  at each step.
5098  <v> may be floating point, <q>s are integers.
5099 \end_layout
5101 \begin_layout Itemize
5102 E.g.
5103  bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
5104 \end_layout
5106 \begin_layout Itemize
5107 E.g.
5108  bit.multidiv(a, b) calculates quotent and remainder of a/b.
5109 \end_layout
5111 \begin_layout Subsection
5112 bit.mul32: 32-bit multiply
5113 \end_layout
5115 \begin_layout Itemize
5116 Syntax: number, number bit.mul32(number a, number b)
5117 \end_layout
5119 \begin_layout Standard
5120 Multiply 32-bit numbers <a> and <b>.
5121  The first return value is low 32 bits of result, the second is high 32
5122  bits.
5123 \end_layout
5125 \begin_layout Subsection
5126 bit.fextract: Extract bit field
5127 \end_layout
5129 \begin_layout Itemize
5130 Syntax: number bit.fextract(number value, number shift, number width)
5131 \end_layout
5133 \begin_layout Standard
5134 Extract <width> bits starting from bit <shift> from number <value>.
5135  This is more compact way to write 
5136 \begin_inset Formula $\left(value\gg shift\right)\&\left(2^{width}-1\right)$
5137 \end_inset
5140 \end_layout
5142 \begin_layout Subsection
5143 bit.bfields: Split number into bit fields
5144 \end_layout
5146 \begin_layout Itemize
5147 Syntax: number...
5148  bit.bfields(number v, number q...)
5149 \end_layout
5151 \begin_layout Standard
5152 Split a number <v> into bitfields of <q> bits (in order, from least significant
5153  towards more significant bits), with no padding in between.
5154 \end_layout
5156 \begin_layout Itemize
5158  number of form 0 bbbbb ggggg rrrrr can be decoded to its component fields
5159  using r,g,b = bit.bfields(v, 5, 5, 5).
5161 \end_layout
5163 \begin_layout Itemize
5165  number of form x yyyyyyy w zzzzzzz can be decode to its component fields
5166  using z, w, y, x = bit.bfields(v, 7, 1, 7, 1).
5167 \end_layout
5169 \begin_layout Standard
5170 \begin_inset Newpage pagebreak
5171 \end_inset
5174 \end_layout
5176 \begin_layout Section
5177 Table classes:
5178 \end_layout
5180 \begin_layout Subsection
5181 classes.<foo>: The classobj for class <foo>
5182 \end_layout
5184 \begin_layout Itemize
5185 Syntax: classes.<foo>
5186 \end_layout
5188 \begin_layout Standard
5189 The classobj for class <foo>.
5190 \end_layout
5192 \begin_layout Subsection
5193 classes.<foo>._static_methods: Enumerate static methods
5194 \end_layout
5196 \begin_layout Itemize
5197 Syntax: string...
5198  classes.<foo>._static_methods()
5199 \end_layout
5201 \begin_layout Standard
5202 Returns all static methods of <foo> as strings.
5203 \end_layout
5205 \begin_layout Subsection
5206 classes.<foo>._class_methods: Enumerate static methods
5207 \end_layout
5209 \begin_layout Itemize
5210 Syntax: string...
5211  classes.<foo>._class_methods()
5212 \end_layout
5214 \begin_layout Standard
5215 Returns all class methods of <foo> as strings.
5216 \end_layout
5218 \begin_layout Subsection
5219 classes.<foo>.<bar>: Static method
5220 \end_layout
5222 \begin_layout Itemize
5223 Syntax: variable classes.<foo>.<bar>(variable...)
5224 \end_layout
5226 \begin_layout Standard
5227 Invokes static method <bar> of class <foo>.
5228 \end_layout
5230 \begin_layout Section
5231 Table gui:
5232 \end_layout
5234 \begin_layout Subsection
5235 gui.resolution: Get current resolution
5236 \end_layout
5238 \begin_layout Itemize
5239 Syntax: (number, number) gui.resolution()
5240 \end_layout
5242 \begin_layout Standard
5243 Returns 2-tuple (hresolution, vresolution).
5244 \end_layout
5246 \begin_layout Subsection
5247 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
5248 \end_layout
5250 \begin_layout Itemize
5251 Syntax: number gui.left_gap(number gap)
5252 \end_layout
5254 \begin_layout Itemize
5255 Syntax: number gui.right_gap(number gap)
5256 \end_layout
5258 \begin_layout Itemize
5259 Syntax: number gui.top_gap(number gap)
5260 \end_layout
5262 \begin_layout Itemize
5263 Syntax: number gui.bottom_gap(number gap)
5264 \end_layout
5266 \begin_layout Standard
5267 Set the specified edge gap to specified value <gap> (max gap is 8191).
5268  If successful, old gap is returned.
5269 \end_layout
5271 \begin_layout Subsection
5272 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
5273  Adjust edge gaps
5274 \end_layout
5276 \begin_layout Itemize
5277 Syntax: number gui.delta_left_gap(number dgap)
5278 \end_layout
5280 \begin_layout Itemize
5281 Syntax: number gui.delta_right_gap(number dgap)
5282 \end_layout
5284 \begin_layout Itemize
5285 Syntax: number gui.delta_top_gap(number dgap)
5286 \end_layout
5288 \begin_layout Itemize
5289 Syntax: number gui.delta_bottom_gap(number dgap)
5290 \end_layout
5292 \begin_layout Standard
5293 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
5294  and return the old gap (returns nothing on error).
5295 \end_layout
5297 \begin_layout Subsection
5298 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
5299 \end_layout
5301 \begin_layout Itemize
5302 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
5303  bgc[, number hlc]]])
5304 \end_layout
5306 \begin_layout Itemize
5307 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
5308  bgc[, number hlc]]])
5309 \end_layout
5311 \begin_layout Itemize
5312 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
5313  bgc[, number hlc]]])
5314 \end_layout
5316 \begin_layout Itemize
5317 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
5318  bgc[, number hlc]]])
5319 \end_layout
5321 \begin_layout Standard
5322 Draw specified text on the GUI (each character cell is 8 or 16 wide and
5323  16 high).
5324  Parameters:
5325 \end_layout
5327 \begin_layout Itemize
5328 x: X-coordinate to start the drawing from (and x-coordinate at begining
5329  of the lines).
5330 \end_layout
5332 \begin_layout Itemize
5333 y: Y-coordinate to start the drawing from.
5334 \end_layout
5336 \begin_layout Itemize
5337 text: The text to draw.
5338 \end_layout
5340 \begin_layout Itemize
5341 fgc: Text color (default is 0xFFFFFF (white))
5342 \end_layout
5344 \begin_layout Itemize
5345 bgc: Background color (default is -1 (transparent))
5346 \end_layout
5348 \begin_layout Itemize
5349 hlc: Halo color (default is -1 (transparent))
5350 \end_layout
5352 \begin_layout Standard
5353 Note: The H variants draw at double width and V variants draw at double
5354  height.
5355  Halo thickness is always 1 and is not doubled.
5356 \end_layout
5358 \begin_layout Subsection
5359 gui.rectangle: Draw a rectangle
5360 \end_layout
5362 \begin_layout Itemize
5363 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5364  number thickness[, number outline[, number fill]]])
5365 \end_layout
5367 \begin_layout Standard
5368 Draw rectangle on the GUI.
5369  Parameters:
5370 \end_layout
5372 \begin_layout Itemize
5373 x: X-coordinate of left edge.
5374 \end_layout
5376 \begin_layout Itemize
5377 y: Y-coordinate of upper edge.
5378 \end_layout
5380 \begin_layout Itemize
5381 width: Width of rectangle.
5382 \end_layout
5384 \begin_layout Itemize
5385 height: Height of rectangle.
5386 \end_layout
5388 \begin_layout Itemize
5389 thickness: Thickness of outline (default is 1).
5390 \end_layout
5392 \begin_layout Itemize
5393 outline: Color of outline (default is 0xFFFFFF (white))
5394 \end_layout
5396 \begin_layout Itemize
5397 fill: Color of fill (default is -1 (transparent))
5398 \end_layout
5400 \begin_layout Subsection
5401 gui.solidrectangle: Draw a solid rectangle
5402 \end_layout
5404 \begin_layout Itemize
5405 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5406  number color])
5407 \end_layout
5409 \begin_layout Standard
5410 Draw solid rectangle on the GUI.
5411  Parameters:
5412 \end_layout
5414 \begin_layout Itemize
5415 x: X-coordinate of left edge.
5416 \end_layout
5418 \begin_layout Itemize
5419 y: Y-coordinate of upper edge.
5420 \end_layout
5422 \begin_layout Itemize
5423 width: Width of rectangle.
5424 \end_layout
5426 \begin_layout Itemize
5427 height: Height of rectangle.
5428 \end_layout
5430 \begin_layout Itemize
5431 color: Color of rectangle (default is 0xFFFFFF (white))
5432 \end_layout
5434 \begin_layout Subsection
5435 gui.box: Draw a 3D-effect box
5436 \end_layout
5438 \begin_layout Itemize
5439 Syntax: none gui.box(number x, number y, number width, number height[, number
5440  thickness[, number outline1[,number outline2[, number fill]]]])
5441 \end_layout
5443 \begin_layout Standard
5444 Draw rectangle with 3D effect on the GUI.
5445  Parameters:
5446 \end_layout
5448 \begin_layout Itemize
5449 x: X-coordinate of left edge.
5450 \end_layout
5452 \begin_layout Itemize
5453 y: Y-coordinate of upper edge.
5454 \end_layout
5456 \begin_layout Itemize
5457 width: Width of rectangle.
5458 \end_layout
5460 \begin_layout Itemize
5461 height: Height of rectangle.
5462 \end_layout
5464 \begin_layout Itemize
5465 thickness: Thickness of outline (default is 1).
5466 \end_layout
5468 \begin_layout Itemize
5469 outline1: First color of outline (default is 0xFFFFFF (white))
5470 \end_layout
5472 \begin_layout Itemize
5473 outline2: First color of outline (default is 0x808080 (dark gray))
5474 \end_layout
5476 \begin_layout Itemize
5477 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5478 \end_layout
5480 \begin_layout Subsection
5481 gui.pixel: Draw a single pixel
5482 \end_layout
5484 \begin_layout Itemize
5485 Syntax: none gui.pixel(number x, number y[, number color])
5486 \end_layout
5488 \begin_layout Standard
5489 Draw one pixel on the GUI.
5490  Parameters:
5491 \end_layout
5493 \begin_layout Itemize
5494 x: X-coordinate of the pixel
5495 \end_layout
5497 \begin_layout Itemize
5498 y: Y-coordinate of the pixel
5499 \end_layout
5501 \begin_layout Itemize
5502 color: Color of the pixel (default is 0xFFFFFF (white))
5503 \end_layout
5505 \begin_layout Subsection
5506 gui.crosshair: Draw a crosshair
5507 \end_layout
5509 \begin_layout Itemize
5510 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5511 \end_layout
5513 \begin_layout Standard
5514 Draw a crosshair.
5515  Parameters:
5516 \end_layout
5518 \begin_layout Itemize
5519 x: X-coordinate of the crosshair
5520 \end_layout
5522 \begin_layout Itemize
5523 y: Y-coordinate of the crosshair
5524 \end_layout
5526 \begin_layout Itemize
5527 length: Length of the crosshair lines (default 10).
5528 \end_layout
5530 \begin_layout Itemize
5531 color: Color of the crosshair (default is 0xFFFFFF (white))
5532 \end_layout
5534 \begin_layout Subsection
5535 gui.line: Draw a line
5536 \end_layout
5538 \begin_layout Itemize
5539 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5540  color])
5541 \end_layout
5543 \begin_layout Standard
5544 Draw a thin line.
5545  Parameters:
5546 \end_layout
5548 \begin_layout Itemize
5549 x1: X-coordinate of one end.
5550 \end_layout
5552 \begin_layout Itemize
5553 y1: Y-coordinate of one end.
5554 \end_layout
5556 \begin_layout Itemize
5557 x2: X-coordinate of the other end.
5558 \end_layout
5560 \begin_layout Itemize
5561 y2: Y-coordinate of the other end.
5562 \end_layout
5564 \begin_layout Itemize
5565 color: Color of the line (default is 0xFFFFFF (white)).
5566 \end_layout
5568 \begin_layout Subsection
5569 gui.circle: Draw a (filled) circle
5570 \end_layout
5572 \begin_layout Itemize
5573 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5574  border[, number fil]]])
5575 \end_layout
5577 \begin_layout Standard
5578 Draw a circle.
5579  Parameters.
5580 \end_layout
5582 \begin_layout Itemize
5583 x: X-coordinate of the center
5584 \end_layout
5586 \begin_layout Itemize
5587 y: Y-coordinate of the center
5588 \end_layout
5590 \begin_layout Itemize
5591 r: The radius of the circle
5592 \end_layout
5594 \begin_layout Itemize
5595 thick: Border thickness
5596 \end_layout
5598 \begin_layout Itemize
5599 border: Border color (default is 0xFFFFFF (white))
5600 \end_layout
5602 \begin_layout Itemize
5603 fill: Fill color (default is -1 (transparent)).
5604 \end_layout
5606 \begin_layout Subsection
5607 gui.repaint: Arrange a repaint
5608 \end_layout
5610 \begin_layout Itemize
5611 Syntax: none gui.repaint()
5612 \end_layout
5614 \begin_layout Standard
5615 Request on_repaint() to happen as soon as possible.
5616 \end_layout
5618 \begin_layout Subsection
5619 gui.subframe_update: Enable/Disable subframe updates
5620 \end_layout
5622 \begin_layout Itemize
5623 Syntax: none gui.subframe_update(boolean on)
5624 \end_layout
5626 \begin_layout Standard
5627 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5628  or not happen (<on>=false).
5629 \end_layout
5631 \begin_layout Subsection
5632 gui.screenshot: Write a screenshot
5633 \end_layout
5635 \begin_layout Itemize
5636 Syntax: none gui.screenshot(string filename)
5637 \end_layout
5639 \begin_layout Standard
5640 Write PNG screenshot of the current frame (no drawings) to specified file
5641  <filename>.
5642 \end_layout
5644 \begin_layout Subsection
5645 gui.screenshot_bitmap: Write a screenshot to bitmap
5646 \end_layout
5648 \begin_layout Itemize
5649 Syntax: DBITMAP gui.screenshot_bitmap()
5650 \end_layout
5652 \begin_layout Standard
5653 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5654  the result.
5655 \end_layout
5657 \begin_layout Subsection
5658 gui.color: Compose a color.
5659 \end_layout
5661 \begin_layout Itemize
5662 Syntax: number gui.color(number r, number g, number b[, number a])
5663 \end_layout
5665 \begin_layout Itemize
5666 Syntax: number gui.color(string c)
5667 \end_layout
5669 \begin_layout Standard
5670 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5671 , each component in scale 0-255.
5672  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5673  fully opaque).
5674  The default alpha is 256.
5675 \end_layout
5677 \begin_layout Standard
5678 The form taking a string returns color corresponding color name.
5679 \end_layout
5681 \begin_layout Subsection
5682 gui.status: Set status variable
5683 \end_layout
5685 \begin_layout Itemize
5686 Syntax: none gui.status(string name, string value)
5687 \end_layout
5689 \begin_layout Standard
5690 Set status field 
5691 \begin_inset Quotes eld
5692 \end_inset
5694 L[<name>]
5695 \begin_inset Quotes erd
5696 \end_inset
5698  to <value> in status area.
5699 \end_layout
5701 \begin_layout Subsection
5702 gui.rainbow: Rainbow color calculation
5703 \end_layout
5705 \begin_layout Itemize
5706 Syntax: number gui.rainbow(number step, number steps[, number color])
5707 \end_layout
5709 \begin_layout Standard
5710 Perform hue rotation of color <color> (default bright red), by <step> steps.
5711  The number of steps per full rotation is given by absolute value of <steps>.
5712 \end_layout
5714 \begin_layout Standard
5715 If <step> is negative, the rotation will be counterclockwise.
5716 \end_layout
5718 \begin_layout Subsection
5719 gui.kill_frame: Kill video frame and associated sound
5720 \end_layout
5722 \begin_layout Itemize
5723 Syntax: none gui.kill_frame()
5724 \end_layout
5726 \begin_layout Standard
5727 Kills the currently dumped video frame + the associated sound.
5728  Only valid in on_video callback.
5729 \end_layout
5731 \begin_layout Subsection
5732 gui.set_video_scale: Set video frame scale
5733 \end_layout
5735 \begin_layout Itemize
5736 Syntax: none gui.set_video_scale(number h, number v)
5737 \end_layout
5739 \begin_layout Standard
5740 Sets the scale factors of current frame to <h>x<v>.
5741  Only valid in on_video callback.
5742 \end_layout
5744 \begin_layout Subsection
5745 gui.arrow: Draw an arrow
5746 \end_layout
5748 \begin_layout Itemize
5749 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5750  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5752 \end_layout
5754 \begin_layout Standard
5755 Draws an arrow using color <color>.
5756  The tip of arrow is at (<x>, <y>).
5757  Other parameters:
5758 \end_layout
5760 \begin_layout Enumerate
5761 <length>: The length of arrow tail.
5762 \end_layout
5764 \begin_layout Enumerate
5765 <hwidth>: The width of arrow head.
5766  Should be odd.
5767 \end_layout
5769 \begin_layout Enumerate
5770 <direction>: Direction of arrow.
5771  0 is to right, +1 rotates 45 degrees counterclockwise.
5772 \end_layout
5774 \begin_layout Enumerate
5775 <fill>: If true, fill the arrow head.
5776  Default false.
5777 \end_layout
5779 \begin_layout Enumerate
5780 <twidth>: Tail width.
5781  Should be odd.
5782  Default 1.
5783 \end_layout
5785 \begin_layout Enumerate
5786 <hthick>: Head thickness (only used if <fill> is false).
5787  Default is <twidth>.
5788 \end_layout
5790 \begin_layout Subsection
5791 gui.tiled_bitmap: Class TILEMAP
5792 \end_layout
5794 \begin_layout Standard
5795 See class TILEMAP.
5796 \end_layout
5798 \begin_layout Subsection
5799 gui.palette: Class PALETTE
5800 \end_layout
5802 \begin_layout Standard
5803 See class PALETTE.
5804 \end_layout
5806 \begin_layout Subsection
5807 gui.bitmap: Class BITMAP
5808 \end_layout
5810 \begin_layout Standard
5811 See class BITMAP.
5812 \end_layout
5814 \begin_layout Subsection
5815 gui.dbitmap: Class DBITMAP
5816 \end_layout
5818 \begin_layout Standard
5819 See class DBITMAP.
5820 \end_layout
5822 \begin_layout Subsection
5823 gui.font: Class CUSTOMFONT
5824 \end_layout
5826 \begin_layout Standard
5827 See class CUSTOMFONT.
5828 \end_layout
5830 \begin_layout Subsection
5831 gui.renderctx: Class RENDERCTX
5832 \end_layout
5834 \begin_layout Standard
5835 See class RENDERCTX.
5836 \end_layout
5838 \begin_layout Subsection
5839 gui.image: Class IMAGELOADER
5840 \end_layout
5842 \begin_layout Standard
5843 See class IMAGELOADER.
5844 \end_layout
5846 \begin_layout Subsection
5847 gui.get_runmode: Get current emulator mode
5848 \end_layout
5850 \begin_layout Itemize
5851 Syntax: string gui.get_runmode()
5852 \end_layout
5854 \begin_layout Standard
5855 Gets the current emulator runmode.
5856  The possible ones are:
5857 \end_layout
5859 \begin_layout Itemize
5860 quit: Emulator is quitting.
5861 \end_layout
5863 \begin_layout Itemize
5864 normal: Emulator is running emulation
5865 \end_layout
5867 \begin_layout Itemize
5868 load: Emulator is loading a movie/savestate
5869 \end_layout
5871 \begin_layout Itemize
5872 advance_frame: Emulator is doing frame advance
5873 \end_layout
5875 \begin_layout Itemize
5876 advance_subframe: Emulator is doing subframe advance
5877 \end_layout
5879 \begin_layout Itemize
5880 skiplag: Emulator is skipping lag frames
5881 \end_layout
5883 \begin_layout Itemize
5884 skiplag_pending: Emulator will start skipping lag frames next frame
5885 \end_layout
5887 \begin_layout Itemize
5888 pause: Emulator is paused
5889 \end_layout
5891 \begin_layout Itemize
5892 pause_break: Emulator is paused at breakpoint
5893 \end_layout
5895 \begin_layout Itemize
5896 corrupt: Emulator can't run because corrupt emulation state
5897 \end_layout
5899 \begin_layout Itemize
5900 unknown: Unknown state (should not happen).
5901 \end_layout
5903 \begin_layout Standard
5904 \begin_inset Newpage pagebreak
5905 \end_inset
5908 \end_layout
5910 \begin_layout Section
5911 table input
5912 \end_layout
5914 \begin_layout Standard
5915 Input handling.
5916  Functions manipulating input are only available in on_input callback.
5917 \end_layout
5919 \begin_layout Subsection
5920 input.get: Read controller button/axis (deprecated)
5921 \end_layout
5923 \begin_layout Itemize
5924 Syntax: number input.get(number controller, number index)
5925 \end_layout
5927 \begin_layout Standard
5928 Read the specified index <index> (zero-based) from specified controller
5929  <controller> (zero-based).
5931 \end_layout
5933 \begin_layout Subsection
5934 input.set: Write controller button/axis (deprecated)
5935 \end_layout
5937 \begin_layout Itemize
5938 Syntax: none input.set(number controller, number index, number value)
5939 \end_layout
5941 \begin_layout Standard
5942 Write the specified index <index> (zero-based) from specified controller
5943  <controller> (zero-based), storing value <value>.
5944 \end_layout
5946 \begin_layout Subsection
5947 input.get2: Read controller button/axis
5948 \end_layout
5950 \begin_layout Itemize
5951 Syntax: number input.get2(number port, number controller, number index)
5952 \end_layout
5954 \begin_layout Standard
5955 Read the specified input tuple.
5956  Port 0 is system port.
5957 \end_layout
5959 \begin_layout Subsection
5960 input.set2: Write controller button/axis
5961 \end_layout
5963 \begin_layout Itemize
5964 Syntax: input.set2(number port, number controller, number index, number value)
5965 \end_layout
5967 \begin_layout Standard
5968 Write the specified input tuple.
5969  Port 0 is system port.
5970 \end_layout
5972 \begin_layout Subsection
5973 input.lcid_to_pcid2: Look up logical controller
5974 \end_layout
5976 \begin_layout Itemize
5977 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5978 \end_layout
5980 \begin_layout Standard
5981 Look up physical pcid pair (port, controller) corresponding to specified
5982  logical controller (1-based).
5983  Returns nothing if controller does not exist.
5984 \end_layout
5986 \begin_layout Subsection
5987 input.port_type: Look up port type
5988 \end_layout
5990 \begin_layout Itemize
5991 Syntax: string input.port_type(number port)
5992 \end_layout
5994 \begin_layout Standard
5995 Return type of specified port.
5996 \end_layout
5998 \begin_layout Subsection
5999 input.controller_info: Get information about controller
6000 \end_layout
6002 \begin_layout Itemize
6003 Syntax: table input.controller_info(number port, number controller)
6004 \end_layout
6006 \begin_layout Standard
6007 Get controller info for specified controller.
6008  If controller does not exist, returns nil.
6009  Otherwise returns a table with following fields:
6010 \end_layout
6012 \begin_layout Itemize
6013 type (string): Type of the controller.
6014 \end_layout
6016 \begin_layout Itemize
6017 class (string): Class of the controller.
6018 \end_layout
6020 \begin_layout Itemize
6021 classnum (number): Number of the controller within its class (1-based)
6022 \end_layout
6024 \begin_layout Itemize
6025 lcid (number): Logical controller number of the controller.
6026 \end_layout
6028 \begin_layout Itemize
6029 button_count (number): Number of buttons on controller
6030 \end_layout
6032 \begin_layout Itemize
6033 buttons (array): Array of following info about each button:
6034 \begin_inset Separator latexpar
6035 \end_inset
6038 \end_layout
6040 \begin_deeper
6041 \begin_layout Itemize
6042 type (string): Type of button.
6043  Currently one of 
6044 \begin_inset Quotes eld
6045 \end_inset
6047 null
6048 \begin_inset Quotes erd
6049 \end_inset
6052 \begin_inset Quotes eld
6053 \end_inset
6055 button
6056 \begin_inset Quotes erd
6057 \end_inset
6060 \begin_inset Quotes eld
6061 \end_inset
6063 axis
6064 \begin_inset Quotes erd
6065 \end_inset
6068 \begin_inset Quotes eld
6069 \end_inset
6071 raxis
6072 \begin_inset Quotes erd
6073 \end_inset
6076 \end_layout
6078 \begin_layout Itemize
6079 name (string): Name of button.
6080 \end_layout
6082 \begin_layout Itemize
6083 symbol (string): Symbol of button.
6084  Only present for type 
6085 \begin_inset Quotes eld
6086 \end_inset
6088 button
6089 \begin_inset Quotes erd
6090 \end_inset
6093 \end_layout
6095 \begin_layout Itemize
6096 hidden (boolean): True if hidden button.
6098 \end_layout
6100 \end_deeper
6101 \begin_layout Subsection
6102 input.veto_button: Veto a button press
6103 \end_layout
6105 \begin_layout Itemize
6106 Syntax: none input.veto_button()
6107 \end_layout
6109 \begin_layout Standard
6110 Signals that the button event should be vetoed.
6111  Only valid in on_button callback.
6112 \end_layout
6114 \begin_layout Subsection
6115 input.geta: Get all buttons for controller (deprecated)
6116 \end_layout
6118 \begin_layout Itemize
6119 Syntax: (number, number...) input.geta(number controller)
6120 \end_layout
6122 \begin_layout Standard
6123 Get input state for entiere controller.
6124  Returns n return values.
6125 \end_layout
6127 \begin_layout Itemize
6128 1st return value: Bitmask: bit i is set if i:th index is nonzero
6129 \end_layout
6131 \begin_layout Itemize
6132 2nd- return value: value of i:th index.
6133 \end_layout
6135 \begin_layout Subsection
6136 input.seta: Set all buttons for controller (deprecated)
6137 \end_layout
6139 \begin_layout Itemize
6140 Syntax: none input.seta(number controller, number bitmask, number args...)
6141 \end_layout
6143 \begin_layout Standard
6144 Set state for entiere controller.
6145  args is up to N values for indices (overriding values in bitmask if specified).
6146 \end_layout
6148 \begin_layout Subsection
6149 input.controllertype: Get controller type (deprecated)
6150 \end_layout
6152 \begin_layout Itemize
6153 syntax: string input.controllertype(number controller)
6154 \end_layout
6156 \begin_layout Standard
6157 Get the type of controller as string.
6158 \end_layout
6160 \begin_layout Subsection
6161 input.reset: Execute (delayed) reset
6162 \end_layout
6164 \begin_layout Itemize
6165 Syntax: none input.reset([number cycles])
6166 \end_layout
6168 \begin_layout Standard
6169 Execute reset.
6170  If <cycles> is greater than zero, do delayed reset.
6171  0 (or no value) causes immediate reset.
6172 \end_layout
6174 \begin_layout Itemize
6175 Note: Only available with subframe flag false.
6176 \end_layout
6178 \begin_layout Subsection
6179 input.raw: Return raw input data
6180 \end_layout
6182 \begin_layout Itemize
6183 Syntax: table input.raw()
6184 \end_layout
6186 \begin_layout Standard
6187 Returns table of tables of all available keys and axes.
6188  The first table is indexed by key name (platform-dependent!), and the inner
6189  table has the following fields:
6190 \end_layout
6192 \begin_layout Itemize
6193 value: Last reported value for control
6194 \begin_inset Separator latexpar
6195 \end_inset
6198 \end_layout
6200 \begin_deeper
6201 \begin_layout Itemize
6202 For keys: 1 for pressed, 0 for released.
6203 \end_layout
6205 \begin_layout Itemize
6206 For axes: -32767...32767.
6207 \end_layout
6209 \begin_layout Itemize
6210 For presure-sensitive buttons: 0...32767.
6211 \end_layout
6213 \begin_layout Itemize
6214 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
6215 \end_layout
6217 \begin_layout Itemize
6218 For mouse: Coordinates relative to game area.
6219 \end_layout
6221 \end_deeper
6222 \begin_layout Itemize
6223 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
6224 \end_layout
6226 \begin_layout Subsection
6227 input.keyhook: Hook a key
6228 \end_layout
6230 \begin_layout Itemize
6231 Syntax: none input.keyhook(string key, boolean state)
6232 \end_layout
6234 \begin_layout Standard
6235 Requests that keyhook events to be sent for key <key> (<state>=true) or
6236  not sent (<state>=false).
6237 \end_layout
6239 \begin_layout Subsection
6240 input.joyget: Get controls for controller
6241 \end_layout
6243 \begin_layout Itemize
6244 Syntax: table input.joyget(number logical)
6245 \end_layout
6247 \begin_layout Standard
6248 Returns table for current controls for specified logical controller <logical>.
6249  The names of fields vary by controller type.
6250 \end_layout
6252 \begin_layout Itemize
6253 The buttons have the same name as those are referred to in other contexts
6254  in the emulator
6255 \end_layout
6257 \begin_layout Itemize
6258 The analog axes are usually 
6259 \begin_inset Quotes eld
6260 \end_inset
6262 xaxis
6263 \begin_inset Quotes erd
6264 \end_inset
6266  and 
6267 \begin_inset Quotes eld
6268 \end_inset
6270 yaxis
6271 \begin_inset Quotes erd
6272 \end_inset
6275 \end_layout
6277 \begin_layout Itemize
6278 Each field is numeric or boolean depending on axis/button.
6279 \end_layout
6281 \begin_layout Subsection
6282 input.joyset: Set controls for controller
6283 \end_layout
6285 \begin_layout Itemize
6286 Syntax: none input.joyset(number controller, table controls)
6287 \end_layout
6289 \begin_layout Standard
6290 Set the the state of specified controller to values specified in specified
6291  table.
6292 \end_layout
6294 \begin_layout Itemize
6295 Each field can be boolean or number.
6296 \end_layout
6298 \begin_layout Itemize
6299 Also, buttons allow strings, which cause value to be inverted.
6300 \end_layout
6302 \begin_layout Subsection
6303 input.lcid_to_pcid: Look up logical controller (deprecated)
6304 \end_layout
6306 \begin_layout Itemize
6307 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
6308 \end_layout
6310 \begin_layout Standard
6311 Returns the legacy pcid for controller (or false if there isn't one), followed
6312  by pcid pair.
6313  Returns nothing if controller does not exist.
6314 \end_layout
6316 \begin_layout Standard
6317 \begin_inset Newpage pagebreak
6318 \end_inset
6321 \end_layout
6323 \begin_layout Section
6324 Table keyboard
6325 \end_layout
6327 \begin_layout Standard
6328 Various keybinding-related functions
6329 \end_layout
6331 \begin_layout Subsection
6332 keyboard.bind: Bind a key
6333 \end_layout
6335 \begin_layout Itemize
6336 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
6337 \end_layout
6339 \begin_layout Standard
6340 Bind specified key with specified modifers to specified command.
6341 \end_layout
6343 \begin_layout Subsection
6344 keyboard.unbind: Unbind a key
6345 \end_layout
6347 \begin_layout Itemize
6348 Syntax: none keyboard.unbind(string mod, string mask, string key)
6349 \end_layout
6351 \begin_layout Standard
6352 Unbind specified key with specified modifers.
6353 \end_layout
6355 \begin_layout Subsection
6356 keyboard.alias: Set alias expansion
6357 \end_layout
6359 \begin_layout Itemize
6360 Syntax: none keyboard.alias(string alias, string expansion)
6361 \end_layout
6363 \begin_layout Standard
6364 Set expansion of given command.
6365 \end_layout
6367 \begin_layout Standard
6368 \begin_inset Newpage pagebreak
6369 \end_inset
6372 \end_layout
6374 \begin_layout Section
6375 Table subtitle
6376 \end_layout
6378 \begin_layout Standard
6379 Subtitle handling
6380 \end_layout
6382 \begin_layout Subsection
6383 subtitle.byindex: Look up start and length of subtitle by index
6384 \end_layout
6386 \begin_layout Itemize
6387 Syntax: (number, number) subtitle.byindex(number i)
6388 \end_layout
6390 \begin_layout Standard
6391 Read the frame and length of ith subtitle.
6392  Returns nothing if not present.
6393 \end_layout
6395 \begin_layout Subsection
6396 subtitle.set: Write a subtitle
6397 \end_layout
6399 \begin_layout Itemize
6400 Syntax: none subtitle.set(number f, number l, string txt)
6401 \end_layout
6403 \begin_layout Standard
6404 Set the text of subtitle.
6405 \end_layout
6407 \begin_layout Subsection
6408 subtitle.get: Read a subtitle
6409 \end_layout
6411 \begin_layout Itemize
6412 Syntax: string subtitle.get(number f, number l)
6413 \end_layout
6415 \begin_layout Standard
6416 Get the text of subtitle.
6417 \end_layout
6419 \begin_layout Subsection
6420 subtitle.delete: Delete a subtitle
6421 \end_layout
6423 \begin_layout Itemize
6424 Syntax: none subtitle.delete(number f, number l)
6425 \end_layout
6427 \begin_layout Standard
6428 Delete specified subtitle.
6429 \end_layout
6431 \begin_layout Standard
6432 \begin_inset Newpage pagebreak
6433 \end_inset
6436 \end_layout
6438 \begin_layout Section
6439 Table hostmemory
6440 \end_layout
6442 \begin_layout Standard
6443 Host memory handling (extra memory saved to savestates).
6444  Host memory starts empty.
6445 \end_layout
6447 \begin_layout Itemize
6448 Reads out of range return false.
6449 \end_layout
6451 \begin_layout Itemize
6452 Writes out of range extend the memory.
6453 \end_layout
6455 \begin_layout Subsection
6456 hostmemory.read: Read byte from host memory
6457 \end_layout
6459 \begin_layout Itemize
6460 Syntax: number hostmemory.read(number address)
6461 \end_layout
6463 \begin_layout Standard
6464 Reads byte from hostmemory slot address <address>.
6465 \end_layout
6467 \begin_layout Subsection
6468 hostmemory.write: Write byte to host memory
6469 \end_layout
6471 \begin_layout Itemize
6472 Syntax: none hostmemory.write(number address, number value)
6473 \end_layout
6475 \begin_layout Standard
6476 Writes hostmemory slot with value <value> 0-255.
6477 \end_layout
6479 \begin_layout Subsection
6480 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6481 \end_layout
6483 \begin_layout Itemize
6484 Syntax: number hostmemory.readbyte(number address)
6485 \end_layout
6487 \begin_layout Itemize
6488 Syntax: number hostmemory.readsbyte(number address)
6489 \end_layout
6491 \begin_layout Itemize
6492 Syntax: number hostmemory.readword(number address)
6493 \end_layout
6495 \begin_layout Itemize
6496 Syntax: number hostmemory.readsword(number address)
6497 \end_layout
6499 \begin_layout Itemize
6500 Syntax: number hostmemory.readhword(number address)
6501 \end_layout
6503 \begin_layout Itemize
6504 Syntax: number hostmemory.readshword(number address)
6505 \end_layout
6507 \begin_layout Itemize
6508 Syntax: number hostmemory.readdword(number address)
6509 \end_layout
6511 \begin_layout Itemize
6512 Syntax: number hostmemory.readsdword(number address)
6513 \end_layout
6515 \begin_layout Itemize
6516 Syntax: number hostmemory.readqword(number address)
6517 \end_layout
6519 \begin_layout Itemize
6520 Syntax: number hostmemory.readsqword(number address)
6521 \end_layout
6523 \begin_layout Standard
6524 Read elements (big-endian) from given address <address>.
6525 \end_layout
6527 \begin_layout Itemize
6528 byte is 1 element
6529 \end_layout
6531 \begin_layout Itemize
6532 word is 2 elements
6533 \end_layout
6535 \begin_layout Itemize
6536 hword is 3 elements
6537 \end_layout
6539 \begin_layout Itemize
6540 dword is 4 elements
6541 \end_layout
6543 \begin_layout Itemize
6544 qword is 8 elements.
6545 \end_layout
6547 \begin_layout Itemize
6548 The 's' variants do signed read.
6549 \end_layout
6551 \begin_layout Subsection
6552 hostmemory.read{float,double}: Read from host memory
6553 \end_layout
6555 \begin_layout Itemize
6556 syntax: number hostmemory.readfloat(number address)
6557 \end_layout
6559 \begin_layout Itemize
6560 Syntax: number hostmemory.readdouble(number address)
6561 \end_layout
6563 \begin_layout Standard
6564 Read elements (big-endian) floating-pont from given address <address>.
6565 \end_layout
6567 \begin_layout Subsection
6568 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6569 \end_layout
6571 \begin_layout Itemize
6572 Syntax: number hostmemory.writebyte(number address, number value)
6573 \end_layout
6575 \begin_layout Itemize
6576 Syntax: number hostmemory.writesbyte(number address, number value)
6577 \end_layout
6579 \begin_layout Itemize
6580 Syntax: number hostmemory.writeword(number address, number value)
6581 \end_layout
6583 \begin_layout Itemize
6584 Syntax: number hostmemory.writesword(number address, number value)
6585 \end_layout
6587 \begin_layout Itemize
6588 Syntax: number hostmemory.writehword(number address, number value)
6589 \end_layout
6591 \begin_layout Itemize
6592 Syntax: number hostmemory.writeshword(number address, number value)
6593 \end_layout
6595 \begin_layout Itemize
6596 Syntax: number hostmemory.writedword(number address, number value)
6597 \end_layout
6599 \begin_layout Itemize
6600 Syntax: number hostmemory.writesdword(number address, number value)
6601 \end_layout
6603 \begin_layout Itemize
6604 Syntax: number hostmemory.writeqword(number address, number value)
6605 \end_layout
6607 \begin_layout Itemize
6608 Syntax: number hostmemory.writesqword(number address, number value)
6609 \end_layout
6611 \begin_layout Standard
6612 Write value <value> to elements (little-endian) starting from given address
6613  <address>.
6614 \end_layout
6616 \begin_layout Itemize
6617 byte is 1 element
6618 \end_layout
6620 \begin_layout Itemize
6621 word is 2 elements
6622 \end_layout
6624 \begin_layout Itemize
6625 hword is 3 elements
6626 \end_layout
6628 \begin_layout Itemize
6629 dword is 4 elements
6630 \end_layout
6632 \begin_layout Itemize
6633 qword is 8 elements.
6634 \end_layout
6636 \begin_layout Itemize
6637 The 's' variants do signed write.
6638 \end_layout
6640 \begin_layout Subsection
6641 hostmemory.write{float,double}: Write to host memory
6642 \end_layout
6644 \begin_layout Itemize
6645 syntax: none hostmemory.readfloat(number address, number value)
6646 \end_layout
6648 \begin_layout Itemize
6649 Syntax: none hostmemory.readdouble(number address, number value)
6650 \end_layout
6652 \begin_layout Standard
6653 Write elements (big-endian) floating-pont to given address <address>, storing
6654  <value>.
6655 \end_layout
6657 \begin_layout Standard
6658 \begin_inset Newpage pagebreak
6659 \end_inset
6662 \end_layout
6664 \begin_layout Section
6665 Table movie
6666 \end_layout
6668 \begin_layout Standard
6669 Movie handling
6670 \end_layout
6672 \begin_layout Subsection
6673 movie.currentframe: Get current frame number
6674 \end_layout
6676 \begin_layout Itemize
6677 Syntax: number movie.currentframe()
6678 \end_layout
6680 \begin_layout Standard
6681 Return number of current frame.
6682 \end_layout
6684 \begin_layout Subsection
6685 movie.framecount: Get move frame count
6686 \end_layout
6688 \begin_layout Itemize
6689 Syntax: number movie.framecount()
6690 \end_layout
6692 \begin_layout Standard
6693 Return number of frames in movie.
6694 \end_layout
6696 \begin_layout Subsection
6697 movie.lagcount: Get current lag count
6698 \end_layout
6700 \begin_layout Itemize
6701 Syntax: number movie.lagcount()
6702 \end_layout
6704 \begin_layout Standard
6705 Return number of lag frames recorded so far.
6706 \end_layout
6708 \begin_layout Subsection
6709 movie.readonly: Is in playback mode?
6710 \end_layout
6712 \begin_layout Itemize
6713 Syntax: boolean movie.readonly()
6714 \end_layout
6716 \begin_layout Standard
6717 Return true if in playback mode, false if in recording.
6718 \end_layout
6720 \begin_layout Subsection
6721 movie.rerecords: Movie rerecord count
6722 \end_layout
6724 \begin_layout Itemize
6725 Syntax: number movie.rerecords()
6726 \end_layout
6728 \begin_layout Standard
6729 Returns the current value of rerecord count.
6730 \end_layout
6732 \begin_layout Subsection
6733 movie.set_readwrite: Set recording mode.
6734 \end_layout
6736 \begin_layout Itemize
6737 Syntax: none movie.set_readwrite()
6738 \end_layout
6740 \begin_layout Standard
6741 Set recording mode (does not cause on_readwrite callback).
6742 \end_layout
6744 \begin_layout Subsection
6745 movie.frame_subframes: Count subframes in frame
6746 \end_layout
6748 \begin_layout Itemize
6749 Syntax: number movie.frame_subframes(number frame)
6750 \end_layout
6752 \begin_layout Standard
6753 Count number of subframes in specified frame <frame> (frame numbers are
6754  1-based) and return that.
6755 \end_layout
6757 \begin_layout Subsection
6758 movie.read_subframes: Read subframe data (deprecated)
6759 \end_layout
6761 \begin_layout Itemize
6762 Syntax: table movie.read_subframes(number frame, number subframe)
6763 \end_layout
6765 \begin_layout Standard
6766 Read specifed subframe in specified frame and return data as array.
6767 \end_layout
6769 \begin_layout Subsection
6770 movie.read_rtc: Read current RTC time
6771 \end_layout
6773 \begin_layout Itemize
6774 Syntax: (number, number) movie.read_rtc()
6775 \end_layout
6777 \begin_layout Standard
6778 Returns the current value of the RTC as a pair (second, subsecond).
6779 \end_layout
6781 \begin_layout Subsection
6782 movie.unsafe_rewind: Fast movie rewind to saved state
6783 \end_layout
6785 \begin_layout Itemize
6786 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6787 \end_layout
6789 \begin_layout Standard
6790 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6791 \end_layout
6793 \begin_layout Itemize
6794 If called without argument, causes emulator to start process of setting
6795  unsafe rewind point.
6796  When this has finished, callback on_set_rewind occurs, passing the rewind
6797  state to lua script.
6798 \end_layout
6800 \begin_layout Itemize
6801 If called with argument, causes emulator rewind to passed rewind point as
6802  soon as possible.
6803  recording mode is implicitly activated.
6804 \end_layout
6806 \begin_layout Standard
6807 The following warnings apply to unsafe rewinding:
6808 \end_layout
6810 \begin_layout Itemize
6811 There are no safety checks against misuse (that's what 
6812 \begin_inset Quotes eld
6813 \end_inset
6815 unsafe
6816 \begin_inset Quotes erd
6817 \end_inset
6819  comes from)!
6820 \end_layout
6822 \begin_layout Itemize
6823 Only call rewind from timeline rewind point was set from.
6824 \end_layout
6826 \begin_layout Itemize
6827 Only call rewind from after the rewind point was set.
6828 \end_layout
6830 \begin_layout Subsection
6831 movie.to_rewind: Load savestate as rewind point
6832 \end_layout
6834 \begin_layout Itemize
6835 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6836 \end_layout
6838 \begin_layout Standard
6839 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6840  corresponding to it.
6841 \end_layout
6843 \begin_layout Itemize
6844 Note: This operation does not take emulated time.
6845 \end_layout
6847 \begin_layout Subsection
6848 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6849 \end_layout
6851 \begin_layout Itemize
6852 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6853 \end_layout
6855 \begin_layout Itemize
6856 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6857 \end_layout
6859 \begin_layout Standard
6860 Copies specified movie or branch <movie>/current object (if none or nil,
6861  the active movie) as new movie object.
6862 \end_layout
6864 \begin_layout Subsection
6865 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6866 \end_layout
6868 \begin_layout Itemize
6869 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6870 \end_layout
6872 \begin_layout Itemize
6873 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6874 \end_layout
6876 \begin_layout Standard
6877 Get INPUTFRAME object corresponding to specified frame in specified movie
6878  or branch.
6879 \end_layout
6881 \begin_layout Subsection
6882 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6883 \end_layout
6885 \begin_layout Itemize
6886 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6887  data)
6888 \end_layout
6890 \begin_layout Itemize
6891 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6892 \end_layout
6894 \begin_layout Standard
6895 Set data in specified frame.
6896 \end_layout
6898 \begin_layout Itemize
6899 Note: Past can't be edited in active movie.
6900 \end_layout
6902 \begin_layout Subsection
6903 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6904 \end_layout
6906 \begin_layout Itemize
6907 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6908 \end_layout
6910 \begin_layout Itemize
6911 Syntax: integer INPUTMOVIE::get_size()
6912 \end_layout
6914 \begin_layout Standard
6915 Return number of subframes in specified movie or branch.
6916 \end_layout
6918 \begin_layout Subsection
6919 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6920 \end_layout
6922 \begin_layout Itemize
6923 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6924 \end_layout
6926 \begin_layout Itemize
6927 Syntax: number INPUTMOVIE::count_frames()
6928 \end_layout
6930 \begin_layout Standard
6931 Return number of frames in movie.
6932 \end_layout
6934 \begin_layout Subsection
6935 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6936 \end_layout
6938 \begin_layout Itemize
6939 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6940 \end_layout
6942 \begin_layout Itemize
6943 Syntax: number INPUTMOVIE::find_frame(number frame)
6944 \end_layout
6946 \begin_layout Standard
6947 Returns starting subframe of given frame (frame numbers are 1-based).
6948  Returns -1 if frame number is bad.
6949 \end_layout
6951 \begin_layout Subsection
6952 movie.subframe_to_frame/INPUTMOVIE::subframe_to_frame: Find frame corresponding
6953  to subframe
6954 \end_layout
6956 \begin_layout Itemize
6957 Syntax: number movie.subframe_to_frame([INPUTMOVIE/string movie], number
6958  subframe)
6959 \end_layout
6961 \begin_layout Itemize
6962 Syntax: number INPUTMOVIE::subframe_to_frame(number subframe)
6963 \end_layout
6965 \begin_layout Standard
6966 Returns frame containing given subframe (subframe numbers are 0-based).
6967  Returns -1 if subframe number is bad.
6968 \end_layout
6970 \begin_layout Subsection
6971 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6972 \end_layout
6974 \begin_layout Itemize
6975 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6976 \end_layout
6978 \begin_layout Itemize
6979 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6980 \end_layout
6982 \begin_layout Standard
6983 Return blank INPUTFRAME with frame type from specified movie.
6984 \end_layout
6986 \begin_layout Subsection
6987 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6988 \end_layout
6990 \begin_layout Itemize
6991 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6992 \end_layout
6994 \begin_layout Itemize
6995 Syntax: none INPUTMOVIE::append_frames(number frames)
6996 \end_layout
6998 \begin_layout Standard
6999 Append specified number <frames> of frames.
7000 \end_layout
7002 \begin_layout Subsection
7003 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
7004 \end_layout
7006 \begin_layout Itemize
7007 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
7008 \end_layout
7010 \begin_layout Itemize
7011 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
7012 \end_layout
7014 \begin_layout Standard
7015 Append specified frame <frame>.
7016  Past of current movie can't be edited.
7017 \end_layout
7019 \begin_layout Subsection
7020 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
7021 \end_layout
7023 \begin_layout Itemize
7024 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
7025 \end_layout
7027 \begin_layout Itemize
7028 Syntax: none INPUTMOVIE::truncate(number frames)
7029 \end_layout
7031 \begin_layout Standard
7032 Truncate the specified movie to specified number of frames.
7033 \end_layout
7035 \begin_layout Subsection
7036 movie.edit/INPUTMOVIE::edit: Edit a movie
7037 \end_layout
7039 \begin_layout Itemize
7040 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
7041  controller, number control, number/bool value)
7042 \end_layout
7044 \begin_layout Itemize
7045 Syntax: none movie.edit(string branch, number frame, number port, number
7046  controller, number control, number/bool value)
7047 \end_layout
7049 \begin_layout Itemize
7050 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
7051  number control, number/bool value)
7052 \end_layout
7054 \begin_layout Standard
7055 Change specified control in specified frame in specified movie.
7056  Past can't be edited in active movie.
7057 \end_layout
7059 \begin_layout Subsection
7060 movie.copy_frames2: Copy frames between movies
7061 \end_layout
7063 \begin_layout Itemize
7064 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
7065 IE/string srcmov,] number src, number count)
7066 \end_layout
7068 \begin_layout Standard
7069 Copy specified number of frames between two movies.
7070  The copy proceeeds in forward direction.
7071 \end_layout
7073 \begin_layout Subsection
7074 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
7075 \end_layout
7077 \begin_layout Itemize
7078 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
7079  src, number count, bool backwards)
7080 \end_layout
7082 \begin_layout Itemize
7083 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
7084  bool backwards)
7085 \end_layout
7087 \begin_layout Standard
7088 Copy specified number of frames from one point in movie to another.
7089  If backwards is true, the copy will be done backwards.
7090 \end_layout
7092 \begin_layout Subsection
7093 movie.serialize/INPUTMOVIE::serialize: Serialize movie
7094 \end_layout
7096 \begin_layout Itemize
7097 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
7098  bool binary)
7099 \end_layout
7101 \begin_layout Itemize
7102 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
7103 \end_layout
7105 \begin_layout Standard
7106 Serialize given movie into file.
7107  If binary is true, binary format (more compact and much faster) is used.
7108 \end_layout
7110 \begin_layout Subsection
7111 movie.unserialize: Unserialize movie
7112 \end_layout
7114 \begin_layout Itemize
7115 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
7116  bool binary)
7117 \end_layout
7119 \begin_layout Standard
7120 Unserialize movie from file.
7121  The given frame is used as template to decide the frame type.
7122  If binary is true, binary format is decoded (much faster).
7123 \end_layout
7125 \begin_layout Subsection
7126 movie.current_first_subframe: Return first subframe in current frame
7127 \end_layout
7129 \begin_layout Itemize
7130 Syntax: number movie.current_first_subframe()
7131 \end_layout
7133 \begin_layout Standard
7134 Returns first subframe in current frame.
7135 \end_layout
7137 \begin_layout Subsection
7138 movie.pollcounter: Return poll counter for speified control
7139 \end_layout
7141 \begin_layout Itemize
7142 Syntax: number movie.pollcounter(number port, number controller, number control)
7143 \end_layout
7145 \begin_layout Standard
7146 Returns number of times the specified control has been polled this frame.
7147 \end_layout
7149 \begin_layout Subsection
7150 movie.current_branch: Return current branch
7151 \end_layout
7153 \begin_layout Itemize
7154 Syntax: string movie.current_branch()
7155 \end_layout
7157 \begin_layout Standard
7158 Returns the name of the current branch.
7159 \end_layout
7161 \begin_layout Subsection
7162 movie.get_branches: Return names of all branches
7163 \end_layout
7165 \begin_layout Itemize
7166 Syntax: string...
7167  movie.get_branches()
7168 \end_layout
7170 \begin_layout Standard
7171 Returns the name of all branches.
7172 \end_layout
7174 \begin_layout Subsection
7175 movie.rom_loaded: Is ROM loaded?
7176 \end_layout
7178 \begin_layout Itemize
7179 Syntax: boolean movie.rom_loaded()
7180 \end_layout
7182 \begin_layout Standard
7183 Returns true if ROM is loaded, false otherwise.
7184 \end_layout
7186 \begin_layout Subsection
7187 movie.get_rom_info: Get info about loaded ROM
7188 \end_layout
7190 \begin_layout Itemize
7191 Syntax: Table movie.get_rom_info()
7192 \end_layout
7194 \begin_layout Standard
7195 Returns a table of tables.
7196  The outer table is indexed by ROM slot index.
7197  The inner table has the following fields:
7198 \end_layout
7200 \begin_layout Itemize
7201 filename: The name of file
7202 \end_layout
7204 \begin_layout Itemize
7205 hint: File name hint
7206 \end_layout
7208 \begin_layout Itemize
7209 sha256: SHA-256 hash of ROM.
7210 \end_layout
7212 \begin_layout Itemize
7213 xml_filename: The name of file for markup
7214 \end_layout
7216 \begin_layout Itemize
7217 xml_hint: File name hint for markup
7218 \end_layout
7220 \begin_layout Itemize
7221 xml_sha256: SHA-256 hash of ROM markup.
7222 \end_layout
7224 \begin_layout Standard
7225 If there is no markup, the xml_* fields are absent.
7226 \end_layout
7228 \begin_layout Subsection
7229 movie.get_game_info: Get info about loaded game
7230 \end_layout
7232 \begin_layout Itemize
7233 Syntax: Table movie.get_game_info()
7234 \end_layout
7236 \begin_layout Standard
7237 Returns a table with following fields:
7238 \end_layout
7240 \begin_layout Itemize
7241 core: The name of the core
7242 \end_layout
7244 \begin_layout Itemize
7245 core_short: Short name of the core
7246 \end_layout
7248 \begin_layout Itemize
7249 type: The name of the system type
7250 \end_layout
7252 \begin_layout Itemize
7253 type_long: The long name of the system type
7254 \end_layout
7256 \begin_layout Itemize
7257 region: The name of region
7258 \end_layout
7260 \begin_layout Itemize
7261 region_long: The long name of region
7262 \end_layout
7264 \begin_layout Itemize
7265 gametype: The gametype of movie.
7266 \end_layout
7268 \begin_layout Itemize
7269 fps: Nominal fps as floating-point value
7270 \end_layout
7272 \begin_layout Itemize
7273 fps_n: Exact nominal fps numerator
7274 \end_layout
7276 \begin_layout Itemize
7277 fps_d: Exact nominal fps denominator.
7278 \end_layout
7280 \begin_layout Subsection
7281 INPUTFRAME::get_button: Get button
7282 \end_layout
7284 \begin_layout Itemize
7285 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
7286  control)
7287 \end_layout
7289 \begin_layout Standard
7290 Returns state of given button as boolean.
7291 \end_layout
7293 \begin_layout Subsection
7294 INPUTFRAME::get_axis: Get axis
7295 \end_layout
7297 \begin_layout Itemize
7298 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
7299  control)
7300 \end_layout
7302 \begin_layout Standard
7303 Returns state of given axis as number.
7304 \end_layout
7306 \begin_layout Subsection
7307 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
7308 \end_layout
7310 \begin_layout Itemize
7311 Syntax: none INPUTFRAME::set_button(number port, number controller, number
7312  control, number/bool value)
7313 \end_layout
7315 \begin_layout Itemize
7316 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
7317  control)
7318 \end_layout
7320 \begin_layout Standard
7321 Set the given button/axis to given value.
7322 \end_layout
7324 \begin_layout Subsection
7325 INPUTFRAME::serialize: Serialize a frame
7326 \end_layout
7328 \begin_layout Itemize
7329 Syntax: string INPUTFRAME::serialize()
7330 \end_layout
7332 \begin_layout Standard
7333 Return string representation of frame.
7334 \end_layout
7336 \begin_layout Subsection
7337 INPUTFRAME::unserialize: Unserialize a frame
7338 \end_layout
7340 \begin_layout Itemize
7341 Syntax: none INPUTFRAME::unserialize(string data)
7342 \end_layout
7344 \begin_layout Standard
7345 Set current frame from given data.
7346 \end_layout
7348 \begin_layout Subsection
7349 INPUTFRAME::get_stride: Get movie stride
7350 \end_layout
7352 \begin_layout Itemize
7353 Syntax: number INPUTFRAME::get_stride()
7354 \end_layout
7356 \begin_layout Standard
7357 Return number of bytes needed to store the input frame.
7358  Mainly useful for some debugging.
7359 \end_layout
7361 \begin_layout Standard
7362 \begin_inset Newpage pagebreak
7363 \end_inset
7366 \end_layout
7368 \begin_layout Section
7369 Table settings
7370 \end_layout
7372 \begin_layout Standard
7373 Routines for settings manipulation
7374 \end_layout
7376 \begin_layout Subsection
7377 settings.get: Get value of setting
7378 \end_layout
7380 \begin_layout Itemize
7381 Syntax: string settings.get(string name)
7382 \end_layout
7384 \begin_layout Standard
7385 Get value of setting <name>.
7386  If setting value can't be obtained, returns (nil, error message).
7387 \end_layout
7389 \begin_layout Subsection
7390 settings.set: Set value of setting
7391 \end_layout
7393 \begin_layout Itemize
7394 Syntax: none settings.set(string name, string value)
7395 \end_layout
7397 \begin_layout Standard
7398 Set value <value> of setting <name>.
7399  If setting can't be set, returns (nil, error message).
7400 \end_layout
7402 \begin_layout Subsection
7403 settings.get_all: Get values of all settings
7404 \end_layout
7406 \begin_layout Itemize
7407 Syntax: table settings.get_all()
7408 \end_layout
7410 \begin_layout Standard
7411 Return a table with all setting names as keys and all current values as
7412  values.
7413 \end_layout
7415 \begin_layout Subsection
7416 settings.get_speed: Get current speed
7417 \end_layout
7419 \begin_layout Itemize
7420 Syntax: number/string settings.get_speed()
7421 \end_layout
7423 \begin_layout Standard
7424 Return the current speed multiplier (1 is normal), or 
7425 \begin_inset Quotes eld
7426 \end_inset
7428 turbo
7429 \begin_inset Quotes erd
7430 \end_inset
7432  if speed is set to turbo (this does not react to turbo toggle).
7433 \end_layout
7435 \begin_layout Subsection
7436 settings.set_speed: Set current speed
7437 \end_layout
7439 \begin_layout Itemize
7440 Syntax: settings.get_speed(number spd)
7441 \end_layout
7443 \begin_layout Itemize
7444 Syntax: settings.get_speed(string special)
7445 \end_layout
7447 \begin_layout Standard
7448 Set the current speed multiplier (1 is normal).
7449  The speed may be positive multiplier or 
7450 \begin_inset Quotes eld
7451 \end_inset
7453 turbo
7454 \begin_inset Quotes erd
7455 \end_inset
7457  for turbo speed.
7458 \end_layout
7460 \begin_layout Standard
7461 \begin_inset Newpage pagebreak
7462 \end_inset
7465 \end_layout
7467 \begin_layout Section
7468 Table memory
7469 \end_layout
7471 \begin_layout Standard
7472 Contains various functions for managing memory
7473 \end_layout
7475 \begin_layout Subsection
7476 memory.vma_count: Count number of memory areas.
7477 \end_layout
7479 \begin_layout Itemize
7480 Syntax: number memory.vma_count()
7481 \end_layout
7483 \begin_layout Standard
7484 Returns the number of memory areas
7485 \end_layout
7487 \begin_layout Subsection
7488 memory.read_vma: Lookup memory area info by index
7489 \end_layout
7491 \begin_layout Itemize
7492 Syntax: table memory.read_vma(number index)
7493 \end_layout
7495 \begin_layout Standard
7496 Reads the specified memory area (indices start from zero).
7497  Trying to read invalid memory area gives nil.
7498  The return value is table with the following fields:
7499 \end_layout
7501 \begin_layout Itemize
7502 region_name (string): The readable name of the memory area
7503 \end_layout
7505 \begin_layout Itemize
7506 baseaddr (number): Base address of the memory area
7507 \end_layout
7509 \begin_layout Itemize
7510 lastaddr (number): Last address in the memory area.
7511 \end_layout
7513 \begin_layout Itemize
7514 size (number): The size of memory area in bytes.
7515 \end_layout
7517 \begin_layout Itemize
7518 readonly (boolean): True of the memory area corresponds to ROM.
7519 \end_layout
7521 \begin_layout Itemize
7522 iospace (boolean): True if the memory area is I/O space.
7523 \end_layout
7525 \begin_layout Itemize
7526 native_endian (boolean): True if the memory area has native endian as opposed
7527  to little endian.
7528 \end_layout
7530 \begin_layout Subsection
7531 memory.find_vma: Find memory area info by address
7532 \end_layout
7534 \begin_layout Itemize
7535 Syntax: table memory.find_vma(number address)
7536 \end_layout
7538 \begin_layout Standard
7539 Finds the memory area containing specified address.
7540  Returns table in the same format as read_vma or nil if not found.
7541 \end_layout
7543 \begin_layout Subsection
7544 memory.read{,s}{byte,{,h,d,q}word}: Read memory
7545 \end_layout
7547 \begin_layout Itemize
7548 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
7549 \end_layout
7551 \begin_layout Itemize
7552 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
7553 \end_layout
7555 \begin_layout Itemize
7556 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
7557 \end_layout
7559 \begin_layout Itemize
7560 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
7561 \end_layout
7563 \begin_layout Itemize
7564 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
7565 \end_layout
7567 \begin_layout Itemize
7568 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
7569 \end_layout
7571 \begin_layout Itemize
7572 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
7573 \end_layout
7575 \begin_layout Itemize
7576 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
7577 \end_layout
7579 \begin_layout Itemize
7580 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
7581 \end_layout
7583 \begin_layout Itemize
7584 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
7585 \end_layout
7587 \begin_layout Standard
7588 Reads the specified address <address> (if 's' variant is used, do undergo
7589  2's complement).
7590 \end_layout
7592 \begin_layout Subsection
7593 memory.{,s}read_sg: Scatter/Gather read memory
7594 \end_layout
7596 \begin_layout Itemize
7597 Syntax: none memory.read_sg(string/boolean/number...)
7598 \end_layout
7600 \begin_layout Itemize
7601 Syntax: none memory.sread_sg(string/boolean/number...)
7602 \end_layout
7604 \begin_layout Standard
7605 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
7606  of memory.
7607  Each argument can be string, boolean or number:
7608 \end_layout
7610 \begin_layout Itemize
7611 String: Set memory area addresses are relative to (e.g.
7612  'WRAM').
7613 \end_layout
7615 \begin_layout Itemize
7616 boolean: If true, increment relative address by 1, if false, decrement by
7617  1.
7618  The new address is read as next higher byte.
7619 \end_layout
7621 \begin_layout Itemize
7622 integer: Set the relative address to specified value and read the address
7623  as next higher byte.
7624 \end_layout
7626 \begin_layout Subsection
7627 memory.write_sg: Scatter/Gather write memory
7628 \end_layout
7630 \begin_layout Itemize
7631 Syntax: none memory.write_sg(number value, string/boolean/number...)
7632 \end_layout
7634 \begin_layout Standard
7635 Perform scatter/gather write of value <value> on memory.
7636  Each argument can be string, boolean or number:
7637 \end_layout
7639 \begin_layout Itemize
7640 String: Set memory area addresses are relative to (e.g.
7641  'WRAM').
7642 \end_layout
7644 \begin_layout Itemize
7645 boolean: If true, increment relative address by 1, if false, decrement by
7646  1.
7647  The new address is read as next higher byte.
7648 \end_layout
7650 \begin_layout Itemize
7651 integer: Set the relative address to specified value and read the address
7652  as next higher byte.
7653 \end_layout
7655 \begin_layout Subsection
7656 memory.read{float,double}: Read memory
7657 \end_layout
7659 \begin_layout Itemize
7660 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7661 \end_layout
7663 \begin_layout Itemize
7664 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7665 \end_layout
7667 \begin_layout Standard
7668 Reads the specified address <address>
7669 \end_layout
7671 \begin_layout Subsection
7672 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7673 \end_layout
7675 \begin_layout Itemize
7676 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7677  number value)
7678 \end_layout
7680 \begin_layout Itemize
7681 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7682  number value)
7683 \end_layout
7685 \begin_layout Itemize
7686 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7687  number value)
7688 \end_layout
7690 \begin_layout Itemize
7691 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7692  number value)
7693 \end_layout
7695 \begin_layout Itemize
7696 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7697  number value)
7698 \end_layout
7700 \begin_layout Itemize
7701 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7702  number value)
7703 \end_layout
7705 \begin_layout Itemize
7706 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7707  number value)
7708 \end_layout
7710 \begin_layout Standard
7711 Writes the specified value <value> (negative integer values undergo 2's
7712  complement) to specified address <address>.
7713 \end_layout
7715 \begin_layout Subsection
7716 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7717 \end_layout
7719 \begin_layout Itemize
7720 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7721  number size)
7722 \end_layout
7724 \begin_layout Standard
7725 Returns a table mapping specified memory aperture for read/write.
7726 \end_layout
7728 \begin_layout Itemize
7729 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7730  qword, sqword, float or double.
7731 \end_layout
7733 \begin_layout Subsection
7734 memory.hash_region: Hash region of memory
7735 \end_layout
7737 \begin_layout Itemize
7738 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7739  number size)
7740 \end_layout
7742 \begin_layout Standard
7743 Hash <size> bytes starting from address <base> (relative to <marea>) and
7744  return the SHA-256.
7745 \end_layout
7747 \begin_layout Subsection
7748 memory.hash_region2: Hash region of memory
7749 \end_layout
7751 \begin_layout Itemize
7752 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7753  number size[, number rows, number stride])
7754 \end_layout
7756 \begin_layout Standard
7757 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7758  to <marea>).
7759  The blocks are offset by <stride> from one another and return the SHA-256.
7760 \end_layout
7762 \begin_layout Subsection
7763 memory.hash_region_skein: Hash region of memory
7764 \end_layout
7766 \begin_layout Itemize
7767 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7768  addrobj}, number size[, number rows, number stride])
7769 \end_layout
7771 \begin_layout Standard
7772 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7773  finalists) as hash function.
7774 \end_layout
7776 \begin_layout Subsection
7777 memory.store: Store region of memory
7778 \end_layout
7780 \begin_layout Itemize
7781 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7782  daddr[, number rows, number stride]
7783 \end_layout
7785 \begin_layout Standard
7786 Copy memory starting from <addr> in memory area <marea> (each row being
7787  of size <size>, there being <rows> rows, and rows being separated by <stride>
7788  in memory) into savestate-saved memory area, starting from <daadr> (all
7789  rows are written back to back).
7790 \end_layout
7792 \begin_layout Subsection
7793 memory.storecmp: Compare and store region of memory
7794 \end_layout
7796 \begin_layout Itemize
7797 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7798  number daddr[, number rows, number stride]
7799 \end_layout
7801 \begin_layout Standard
7802 Like memory.store, but returns true if target of copy already held the value
7803  that would be copied before the copy happened.
7804  Otherwise returns false (if target and source differ before copy).
7805 \end_layout
7807 \begin_layout Subsection
7808 memory.hash_state: Hash system state
7809 \end_layout
7811 \begin_layout Itemize
7812 Syntax: string memory.hash_state()
7813 \end_layout
7815 \begin_layout Standard
7816 Hash the current system state.
7817  Mainly useful for debugging savestates.
7818 \end_layout
7820 \begin_layout Subsection
7821 memory.readregion: Read region of memory
7822 \end_layout
7824 \begin_layout Itemize
7825 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7826  number size)
7827 \end_layout
7829 \begin_layout Standard
7830 Read a region of memory.
7831 \end_layout
7833 \begin_layout Itemize
7834 Warning: If the region crosses memory area boundary, the results are undefined.
7835 \end_layout
7837 \begin_layout Subsection
7838 memory.writeregion: Write region of memory
7839 \end_layout
7841 \begin_layout Itemize
7842 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7843  number size, table data)
7844 \end_layout
7846 \begin_layout Standard
7847 Write a region of memory.
7848 \end_layout
7850 \begin_layout Itemize
7851 Warning: If the region crosses memory area boundary, the results are undefined.
7852 \end_layout
7854 \begin_layout Subsection
7855 memory.action: Run core action
7856 \end_layout
7858 \begin_layout Itemize
7859 memory.action(string action, [<params>])
7860 \end_layout
7862 \begin_layout Standard
7863 Run core action.
7864  The different models expect parameters as:
7865 \end_layout
7867 \begin_layout Itemize
7868 string: String
7869 \end_layout
7871 \begin_layout Itemize
7872 numeric: numeric
7873 \end_layout
7875 \begin_layout Itemize
7876 enumeration: String
7877 \end_layout
7879 \begin_layout Itemize
7880 boolean: String
7881 \end_layout
7883 \begin_layout Itemize
7884 toggle: None.
7885 \end_layout
7887 \begin_layout Subsection
7888 memory.action_flags: Get core action flags
7889 \end_layout
7891 \begin_layout Itemize
7892 memory.action_flags(string action)
7893 \end_layout
7895 \begin_layout Standard
7896 Get value of action flags for core action <action>.
7897 \end_layout
7899 \begin_layout Itemize
7900 Bit 0: Enabled?
7901 \end_layout
7903 \begin_layout Itemize
7904 Bit 1: Selected (not all actions can be selected)?
7905 \end_layout
7907 \begin_layout Subsection
7908 memory.get_lag_flag: Get lag flag
7909 \end_layout
7911 \begin_layout Itemize
7912 Syntax: boolean memory.get_lag_flag()
7913 \end_layout
7915 \begin_layout Standard
7916 Get the value of core lag flag.
7917  True if this frame has been lag so far, false if poll has been detected.
7918 \end_layout
7920 \begin_layout Subsection
7921 memory.set_lag_flag: Set lag flag
7922 \end_layout
7924 \begin_layout Itemize
7925 Syntax: none memory.set_lag_flag(boolean flag)
7926 \end_layout
7928 \begin_layout Standard
7929 Set the value of core lag flag.
7930  This flag automatically gets cleared if poll is detected, but can be forcibly
7931  set or cleared if game so requires.
7932 \end_layout
7934 \begin_layout Itemize
7935 Should only be used in on_frame_emulated callback.
7936 \end_layout
7938 \begin_layout Itemize
7939 Setting or clearing this affects the emulator lag counter.
7940 \end_layout
7942 \begin_layout Subsection
7943 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7944  callback
7945 \end_layout
7947 \begin_layout Itemize
7948 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
7949  function fn);
7950 \end_layout
7952 \begin_layout Itemize
7953 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
7954  addrobj}, function fn);
7955 \end_layout
7957 \begin_layout Itemize
7958 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
7959  function fn);
7960 \end_layout
7962 \begin_layout Itemize
7963 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
7964  function fn);
7965 \end_layout
7967 \begin_layout Itemize
7968 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
7969  function fn);
7970 \end_layout
7972 \begin_layout Itemize
7973 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
7974  function fn);
7975 \end_layout
7977 \begin_layout Standard
7978 Add or remove callback on memory read, write or execute (depending on the
7979  function).
7980  <addr> is relative to <marea>.
7981  <fn> is the callback.
7982  The register* functions return <fn> (which can then be passed to unregister*
7983  functions.
7984 \end_layout
7986 \begin_layout Itemize
7987 Not all cores support this, and it may be unsupported for some memory areas.
7988 \end_layout
7990 \begin_layout Itemize
7991 The functions are passed two parameters: Address and value.
7992 \end_layout
7994 \begin_layout Subsection
7995 memory.{,un}registertrace: Set/Clear trace hook
7996 \end_layout
7998 \begin_layout Itemize
7999 Syntax: function memory.registertrace(number processor, function fn);
8000 \end_layout
8002 \begin_layout Itemize
8003 Syntax: none memory.unregistertrace(number processor, function fn);
8004 \end_layout
8006 \begin_layout Standard
8007 Add or remove trace callback.
8008  <processor> is system-dependent processor number (0 is usually main CPU).
8009  The function arguments work like in other (un)register* functions.
8010 \end_layout
8012 \begin_layout Itemize
8013 The functions are passed two parameters: Trace CPU and Trace event string.
8014 \end_layout
8016 \begin_layout Subsection
8017 memory.cheat: Set cheat
8018 \end_layout
8020 \begin_layout Itemize
8021 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
8022  value);
8023 \end_layout
8025 \begin_layout Itemize
8026 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
8027 \end_layout
8029 \begin_layout Standard
8030 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
8031  If <value> is not speicified, clear a cheat.
8032 \end_layout
8034 \begin_layout Itemize
8035 Not all cores support this, and it may be unsupported for some memory areas.
8036 \end_layout
8038 \begin_layout Subsection
8039 memory.setxmask: Set global execute hook mask
8040 \end_layout
8042 \begin_layout Itemize
8043 Syntax: none memory.setxmask(number mask)
8044 \end_layout
8046 \begin_layout Standard
8047 Set the global execute hook mask to <mask>.
8048  The meaning of each bit is system-dependent, but bit 0 should be the main
8049  CPU.
8050 \end_layout
8052 \begin_layout Subsection
8053 memory.getregister: Get register value
8054 \end_layout
8056 \begin_layout Itemize
8057 Syntax: number/boolean memory.getregister(string register)
8058 \end_layout
8060 \begin_layout Standard
8061 Get the value of named register.
8062 \end_layout
8064 \begin_layout Subsection
8065 memory.getregisters: Get register values
8066 \end_layout
8068 \begin_layout Itemize
8069 Syntax: table memory.getregisters()
8070 \end_layout
8072 \begin_layout Standard
8073 Get the value of all known registers as table.
8074 \end_layout
8076 \begin_layout Subsection
8077 memory.setregister: Set register value
8078 \end_layout
8080 \begin_layout Itemize
8081 Syntax: none memory.setregister(string register, number/boolean value)
8082 \end_layout
8084 \begin_layout Standard
8085 Set the value of named register.
8086 \end_layout
8088 \begin_layout Subsection
8089 memory.mmap: Class MMAP_STRUCT
8090 \end_layout
8092 \begin_layout Standard
8093 See class MMAP_STRUCT
8094 \end_layout
8096 \begin_layout Standard
8097 \begin_inset Newpage pagebreak
8098 \end_inset
8101 \end_layout
8103 \begin_layout Section
8104 Table memory2
8105 \end_layout
8107 \begin_layout Standard
8108 Contains newer memory functions.
8109 \end_layout
8111 \begin_layout Subsection
8112 memory2(): Get all memory area names.
8113 \end_layout
8115 \begin_layout Itemize
8116 Syntax: table memory2()
8117 \end_layout
8119 \begin_layout Standard
8120 Returns array of all valid memory area names.
8121 \end_layout
8123 \begin_layout Subsection
8124 memory2.<marea>:info: Get memory area info
8125 \end_layout
8127 \begin_layout Itemize
8128 Syntax: table memory2.<marea>:info()
8129 \end_layout
8131 \begin_layout Standard
8132 Return table describing given memory area.
8133  Includes fields address, size, last, readonly, special and endian.
8134 \end_layout
8136 \begin_layout Subsection
8137 memory2.<marea>:<op>: Read/Write memory
8138 \end_layout
8140 \begin_layout Itemize
8141 Syntax: none memory2.<marea>:<op>(number offset, number value)
8142 \end_layout
8144 \begin_layout Itemize
8145 Syntax: number memory2.<marea>:<op>(number offset)
8146 \end_layout
8148 \begin_layout Standard
8149 Read/Write value from/to given memory area <marea> at given offset <offset>
8150  (must be in-range).
8151  The value written is <value>.
8152  <Op> is of form: [i][s]<type>, where:
8153 \end_layout
8155 \begin_layout Itemize
8156 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
8157 \end_layout
8159 \begin_layout Itemize
8160 'i' signifies that the value is treated as opposite-to-normal endianess,
8161 \end_layout
8163 \begin_layout Itemize
8164 's' signifies that value is treated as signed (not available for floating-point).
8165 \end_layout
8167 \begin_layout Subsection
8168 memory2.<marea>:read: Scatter-gather value read
8169 \end_layout
8171 \begin_layout Itemize
8172 Syntax: number memory2.<marea>:read(number addr...)
8173 \end_layout
8175 \begin_layout Standard
8176 Read value from given memory area <marea> at byte offsets <addr>..., given
8177  in order of increasing significance.
8178  Value of true and false are special.
8179  True increments address by 1, and false decrements address by 1.
8180 \end_layout
8182 \begin_layout Subsection
8183 memory2.<marea>:sread: Signed scatter-gather value read
8184 \end_layout
8186 \begin_layout Itemize
8187 Syntax: number memory2.<marea>:sread(number addr...)
8188 \end_layout
8190 \begin_layout Standard
8191 Like memory2.<marea>:read, but reads signed values.
8192 \end_layout
8194 \begin_layout Subsection
8195 memory2.<marea>:write: Scatter-gather value write
8196 \end_layout
8198 \begin_layout Itemize
8199 Syntax: number memory2.<marea>:write(number val, number addr...)
8200 \end_layout
8202 \begin_layout Standard
8203 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
8204  in order of increasing significance.
8205  Value of true and false are special.
8206  True increments address by 1, and false decrements address by 1.
8207 \end_layout
8209 \begin_layout Subsection
8210 memory2.<marea>:cheat: Set/Clear cheat
8211 \end_layout
8213 \begin_layout Itemize
8214 Syntax: none memory2.<marea>:cheat(number addr, [number value])
8215 \end_layout
8217 \begin_layout Standard
8218 Set/Clear cheat at offset <addr> of memory area <marea>.
8219  If <value> is given, cheat with specified value is set.
8220  Otherwise cheat on address is removed.
8221 \end_layout
8223 \begin_layout Subsection
8224 memory2.<marea>:sha256: SHA-256
8225 \end_layout
8227 \begin_layout Itemize
8228 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
8229  number stride])
8230 \end_layout
8232 \begin_layout Standard
8233 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
8234  from offset <addr> of area <marea>.
8235  The chunks are separated by <stride>.
8236 \end_layout
8238 \begin_layout Subsection
8239 memory2.<marea>:skein: Skein-512-256
8240 \end_layout
8242 \begin_layout Itemize
8243 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
8244  number stride])
8245 \end_layout
8247 \begin_layout Standard
8248 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
8249 \end_layout
8251 \begin_layout Subsection
8252 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
8253 \end_layout
8255 \begin_layout Itemize
8256 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
8257  number rows, number stride])
8258 \end_layout
8260 \begin_layout Itemize
8261 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
8262  size[, number rows, number stride])
8263 \end_layout
8265 \begin_layout Standard
8266 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
8267  <addr> of area <marea>.
8268  The chunks are separated by <stride>.
8269  The target is Lua host memory, starting from offset <daddr>.
8270 \end_layout
8272 \begin_layout Standard
8273 Additionally, the storecmp method returns false if target was modified (otherwis
8274 e true).
8275 \end_layout
8277 \begin_layout Subsection
8278 memory2.<marea>:readregion: Read region
8279 \end_layout
8281 \begin_layout Itemize
8282 Syntax table memory2.<marea>:readregion(number addr, number size)
8283 \end_layout
8285 \begin_layout Standard
8286 Read <size> bytes starting from <addr> in <marea> and return as array.
8287 \end_layout
8289 \begin_layout Subsection
8290 memory2.<marea>:writeregion: Write region
8291 \end_layout
8293 \begin_layout Itemize
8294 Syntax none memory2.<marea>:writeregion(number addr, table data)
8295 \end_layout
8297 \begin_layout Standard
8298 Write array <data> to bytes starting from <addr> in <marea>.
8299 \end_layout
8301 \begin_layout Subsection
8302 memory2.<marea>:register{read,write,exec}: Register hook
8303 \end_layout
8305 \begin_layout Itemize
8306 Syntax: function memory2.<marea>:registerread(number addr, function fn);
8307 \end_layout
8309 \begin_layout Itemize
8310 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
8311 \end_layout
8313 \begin_layout Itemize
8314 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
8315 \end_layout
8317 \begin_layout Standard
8318 Register debug callback <fn> of specified type at offset <addr> of memory
8319  area <marea>.
8320  Returns <fn>.
8321 \end_layout
8323 \begin_layout Subsection
8324 memory2.<marea>:unregister{read,write,exec}: Unregister hook
8325 \end_layout
8327 \begin_layout Itemize
8328 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
8329 \end_layout
8331 \begin_layout Itemize
8332 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
8333 \end_layout
8335 \begin_layout Itemize
8336 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
8337 \end_layout
8339 \begin_layout Standard
8340 Unregister debug callback <fn> of specified type at offset <addr> of memory
8341  area <marea>.
8342 \end_layout
8344 \begin_layout Standard
8345 \begin_inset Newpage pagebreak
8346 \end_inset
8349 \end_layout
8351 \begin_layout Section
8352 Table random
8353 \end_layout
8355 \begin_layout Standard
8356 Contains random number generation methods.
8357  These functions do not return reproducable results.
8358 \end_layout
8360 \begin_layout Subsection
8361 random.boolean: Random boolean
8362 \end_layout
8364 \begin_layout Itemize
8365 Syntax: boolean random.boolean()
8366 \end_layout
8368 \begin_layout Standard
8369 Returns true or false at random (50-50 chance).
8370 \end_layout
8372 \begin_layout Subsection
8373 random.integer: Random integer
8374 \end_layout
8376 \begin_layout Itemize
8377 Syntax: number random.integer(number highplusone)
8378 \end_layout
8380 \begin_layout Itemize
8381 Syntax: number random.integer(number low, number high)
8382 \end_layout
8384 \begin_layout Standard
8385 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
8386  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
8387 \end_layout
8389 \begin_layout Standard
8390 The returned numbers are from uniform distribution.
8391 \end_layout
8393 \begin_layout Subsection
8394 random.float: Random float
8395 \end_layout
8397 \begin_layout Itemize
8398 Syntax: number random.float()
8399 \end_layout
8401 \begin_layout Standard
8402 Returns random decimal number [0,1).
8403 \end_layout
8405 \begin_layout Subsection
8406 random.among: Random parameter
8407 \end_layout
8409 \begin_layout Itemize
8410 Syntax: value random.among(value values...)
8411 \end_layout
8413 \begin_layout Standard
8414 Returns random parameter value, picked at uniform.
8415  Multiple equivalent values are returned with higher chance.
8416 \end_layout
8418 \begin_layout Subsection
8419 random.amongtable: Random from table
8420 \end_layout
8422 \begin_layout Itemize
8423 Syntax: value random.amongtable(table tab)
8424 \end_layout
8426 \begin_layout Standard
8427 Returns random value from table <tab>.
8428  As in random.among, no equality testing is done.
8429 \end_layout
8431 \begin_layout Standard
8432 \begin_inset Newpage pagebreak
8433 \end_inset
8436 \end_layout
8438 \begin_layout Section
8439 Table zip
8440 \end_layout
8442 \begin_layout Subsection
8443 zip.enumerate: Enumerate members in zipfile
8444 \end_layout
8446 \begin_layout Itemize
8447 Syntax: Table zip.enumerate(string filename[, boolean invert])
8448 \end_layout
8450 \begin_layout Standard
8451 Returns table of files in zip archive <filename>.
8452  If <invert> is true, instead of returning array of names, returns table
8453  with keys being member names and values being true.
8454 \end_layout
8456 \begin_layout Subsection
8457 zip.writer: Class ZIPWRITER
8458 \end_layout
8460 \begin_layout Standard
8461 See class ZIPWRITER.
8462 \end_layout
8464 \begin_layout Section
8465 Table paths
8466 \end_layout
8468 \begin_layout Subsection
8469 paths.get_executable_file: Get the name of lsnes executable file
8470 \end_layout
8472 \begin_layout Itemize
8473 Syntax: String paths.get_executable_file()
8474 \end_layout
8476 \begin_layout Standard
8477 Returns the filename of the lsnes executable (together with path), if known.
8478  If unknown, returns nil.
8479 \end_layout
8481 \begin_layout Subsection
8482 paths.get_executable_path: Get the path of lsnes executable file
8483 \end_layout
8485 \begin_layout Itemize
8486 Syntax: String paths.get_executable_path()
8487 \end_layout
8489 \begin_layout Standard
8490 Returns the directory of the lsnes executable path, if known.
8491  If unknown, returns nil.
8492 \end_layout
8494 \begin_layout Subsection
8495 paths.get_config_path: Get the path of lsnes config file
8496 \end_layout
8498 \begin_layout Itemize
8499 Syntax: String paths.get_config_path()
8500 \end_layout
8502 \begin_layout Standard
8503 Returns the directory of the lsnes configuration.
8504 \end_layout
8506 \begin_layout Subsection
8507 paths.get_rompath: Get the path of ROM files
8508 \end_layout
8510 \begin_layout Itemize
8511 Syntax: String paths.get_rompath()
8512 \end_layout
8514 \begin_layout Standard
8515 Returns the default directory for various ROMs.
8516 \end_layout
8518 \begin_layout Subsection
8519 paths.get_firmwarepath: Get the path of firmware files
8520 \end_layout
8522 \begin_layout Itemize
8523 Syntax: String paths.get_firmwarepath()
8524 \end_layout
8526 \begin_layout Standard
8527 Returns the default directory for various firmwares.
8528 \end_layout
8530 \begin_layout Subsection
8531 paths.get_slotpath: Get the path of save slot files
8532 \end_layout
8534 \begin_layout Itemize
8535 Syntax: String paths.get_slotpath()
8536 \end_layout
8538 \begin_layout Standard
8539 Returns the default directory for various save slots.
8540  If in project context, returns the project directory.
8541 \end_layout
8543 \begin_layout Subsection
8544 paths.get_save_slot_file: Get save slot filename
8545 \end_layout
8547 \begin_layout Itemize
8548 Syntax: String paths.get_slotpath(string name)
8549 \end_layout
8551 \begin_layout Itemize
8552 Syntax: String paths.get_slotpath(integer slotnum, bool for_save)
8553 \end_layout
8555 \begin_layout Standard
8556 Resolve the filename of specified save slot <name> or <slotnum>.
8557  Projects and save branches are taken into account.
8558  If <for_save> is true, the filename is always for current branch.
8559  If <for_save> is false, branch tree is walked upwards until root is reached
8560  or desired file is located.
8561 \end_layout
8563 \begin_layout Standard
8564 \begin_inset Newpage pagebreak
8565 \end_inset
8568 \end_layout
8570 \begin_layout Section
8571 Table callback
8572 \end_layout
8574 \begin_layout Standard
8575 Various callback-related functions.
8576 \end_layout
8578 \begin_layout Subsection
8579 \begin_inset CommandInset label
8580 LatexCommand label
8581 name "subsec:callback.register:-Register-a"
8583 \end_inset
8585 callback.register: Register a callback
8586 \end_layout
8588 \begin_layout Itemize
8589 Syntax: function callback.register(string cbname, function cbfun);
8590 \end_layout
8592 \begin_layout Standard
8593 Instruct function <cbfun> to be added to list of callbacks to call on event
8594  <cbname> (See section 
8595 \begin_inset CommandInset ref
8596 LatexCommand ref
8597 reference "sec:Callbacks"
8599 \end_inset
8602  The callback name does not have the 'on_' prefix (e.g.
8604 \begin_inset Quotes eld
8605 \end_inset
8607 paint
8608 \begin_inset Quotes erd
8609 \end_inset
8612  Returns <cbfun>.
8613 \end_layout
8615 \begin_layout Subsection
8616 \begin_inset CommandInset label
8617 LatexCommand label
8618 name "subsec:callback.unregister:-Unregister-"
8620 \end_inset
8622 callback.unregister: Unregister a callback
8623 \end_layout
8625 \begin_layout Itemize
8626 Syntax: function callback.unregister(string cbname, function cbfun);
8627 \end_layout
8629 \begin_layout Standard
8630 Instruct function <cbfun> to be removed from list of callbacks to call on
8631  event <cbname>.
8632 \end_layout
8634 \begin_layout Subsection
8635 callback.<cbname>:register: Register callback
8636 \end_layout
8638 \begin_layout Itemize
8639 Syntax: function callback.<cbname>:register(function cbfun)
8640 \end_layout
8642 \begin_layout Standard
8643 Synonym for callback.register (section 
8644 \begin_inset CommandInset ref
8645 LatexCommand ref
8646 reference "subsec:callback.register:-Register-a"
8648 \end_inset
8650 ), albeit with callback name specified differently.
8651 \end_layout
8653 \begin_layout Subsection
8654 callback.<cbname>:unregister: Register callback
8655 \end_layout
8657 \begin_layout Itemize
8658 Syntax: function callback.<cbname>:unregister(function cbfun)
8659 \end_layout
8661 \begin_layout Standard
8662 Synonym for callback.unregister (section 
8663 \begin_inset CommandInset ref
8664 LatexCommand ref
8665 reference "subsec:callback.unregister:-Unregister-"
8667 \end_inset
8669 ), albeit with callback name specified differently.
8670 \end_layout
8672 \begin_layout Section
8673 table bsnes
8674 \end_layout
8676 \begin_layout Standard
8677 Various bsnes-specific functions.
8678 \end_layout
8680 \begin_layout Subsection
8681 bsnes.dump_sprite: Dump a sprite
8682 \end_layout
8684 \begin_layout Itemize
8685 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
8686  number height[, number stride])
8687 \end_layout
8689 \begin_layout Standard
8690 Dumps given sprite (in native format) from memory.
8691  memory area is usually 
8692 \begin_inset Quotes eld
8693 \end_inset
8695 VRAM
8696 \begin_inset Quotes erd
8697 \end_inset
8700  <Width> and <height> are given in 8x8 blocks.
8701  <Stride> overrides row stride (default 512).
8702 \end_layout
8704 \begin_layout Subsection
8705 bsnes.dump_sprite2: Dump a 2bpp sprite
8706 \end_layout
8708 \begin_layout Itemize
8709 Syntax: BITMAP bsnes.dump_sprite2(string marea, number addr, number width,
8710  number height[, number stride])
8711 \end_layout
8713 \begin_layout Standard
8714 Dumps given sprite (in 2bpp format) from memory.
8715  memory area is usually 
8716 \begin_inset Quotes eld
8717 \end_inset
8719 VRAM
8720 \begin_inset Quotes erd
8721 \end_inset
8724  <Width> and <height> are given in 8x8 blocks.
8725  <Stride> overrides row stride (default 256).
8726 \end_layout
8728 \begin_layout Subsection
8729 bsnes.dump_palette: Dump a palette
8730 \end_layout
8732 \begin_layout Itemize
8733 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool/integer
8734  full256, bool first_trans)
8735 \end_layout
8737 \begin_layout Standard
8738 Dumps a palette from memory.
8739  memory area is usually 
8740 \begin_inset Quotes eld
8741 \end_inset
8743 CGRAM
8744 \begin_inset Quotes erd
8745 \end_inset
8748  If <full256> is true, 256 colors are dumped (otherwise 16).
8749  <full256> can also be number of colors (4, 16 or 256).
8750  If <first_trans> is true, first color is forced transparent.
8751 \end_layout
8753 \begin_layout Subsection
8754 bsnes.enablelayer: Set layer visibility
8755 \end_layout
8757 \begin_layout Itemize
8758 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8759 \end_layout
8761 \begin_layout Standard
8762 Enable or disable specified layer at specified priority.
8763 \end_layout
8765 \begin_layout Subsection
8766 bsnes.redump_sprite: Redump a sprite
8767 \end_layout
8769 \begin_layout Itemize
8770 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8771  number stride])
8772 \end_layout
8774 \begin_layout Standard
8775 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8776  The specified bitmap must have size multiple of 8x8.
8777 \end_layout
8779 \begin_layout Subsection
8780 bsnes.redump_sprite2: Redump a 2bpp sprite
8781 \end_layout
8783 \begin_layout Itemize
8784 Syntax: none bsnes.redump_sprite2(BITMAP bitmap, string marea, number addr[,
8785  number stride])
8786 \end_layout
8788 \begin_layout Standard
8789 Like bsnes.dump_sprite2, but instead dumps to specified bitmap <bitmap>.
8790  The specified bitmap must have size multiple of 8x8.
8791 \end_layout
8793 \begin_layout Subsection
8794 bsnes.redump_palette: Redump a palette
8795 \end_layout
8797 \begin_layout Itemize
8798 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8799  first_trans)
8800 \end_layout
8802 \begin_layout Standard
8803 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8804  The specified palette must have either 16 or 256 colors.
8805 \end_layout
8807 \begin_layout Section
8808 extensions to table string
8809 \end_layout
8811 \begin_layout Subsection
8812 string.charU: string.char, UTF-8 version.
8813 \end_layout
8815 \begin_layout Itemize
8816 Syntax: string string.charU(number n...)
8817 \end_layout
8819 \begin_layout Standard
8820 Like Lua string.char(), but works in terms of Unicode codepoints.
8821  The returned string is UTF-8.
8822 \end_layout
8824 \begin_layout Subsection
8825 string.byteU: string.byte, UTF-8 version.
8826 \end_layout
8828 \begin_layout Itemize
8829 Syntax: number...
8830  string.byteU(string str[, number i[, number j]])
8831 \end_layout
8833 \begin_layout Standard
8834 Like string.byte(), but works in terms of Unicode codepoints.
8835  The input string <str> is assumed UTF-8.
8836 \end_layout
8838 \begin_layout Subsection
8839 string.regex: Match string against regular expression
8840 \end_layout
8842 \begin_layout Itemize
8843 Syntax: boolean/string...
8844  string.regex(string regexp, string against)
8845 \end_layout
8847 \begin_layout Standard
8848 Match POSIX-extended regular expression <regexp> against string <against>.
8849  If no match, false is returned.
8850  Otherwise if string has no subcaptures, true is returned.
8851  Otherwise each subcapture is returned as a string (in order of starting
8852  position).
8853 \end_layout
8855 \begin_layout Subsection
8856 string.hex: Transform integer into hex string
8857 \end_layout
8859 \begin_layout Itemize
8860 Syntax: string string.hex(number n, [number digits])
8861 \end_layout
8863 \begin_layout Standard
8864 Returns hexadecimal string representation of <n>, optionally padded with
8865  zeroes to <digits> digits (default is not to pad).
8866 \end_layout
8868 \begin_layout Subsection
8869 string.lpad: Pad string with spaces from left
8870 \end_layout
8872 \begin_layout Itemize
8873 Syntax: string string.lpad(string x, number n)
8874 \end_layout
8876 \begin_layout Standard
8877 Pad string <x> to <n> bytes by inserting spaces at start and return the
8878  result.
8879 \end_layout
8881 \begin_layout Subsection
8882 string.rpad: Pad string with spaces from right
8883 \end_layout
8885 \begin_layout Itemize
8886 Syntax: string string.rpad(string x, number n)
8887 \end_layout
8889 \begin_layout Standard
8890 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8891 \end_layout
8893 \begin_layout Section
8894 Table _SYSTEM
8895 \end_layout
8897 \begin_layout Standard
8898 Contains copy of global variables from time of Lua initialization.
8899  Non-writeable.
8900 \end_layout
8902 \begin_layout Standard
8903 \begin_inset Newpage pagebreak
8904 \end_inset
8907 \end_layout
8909 \begin_layout Section
8910 \begin_inset CommandInset label
8911 LatexCommand label
8912 name "sec:Callbacks"
8914 \end_inset
8916 Callbacks
8917 \end_layout
8919 \begin_layout Standard
8920 Various callbacks to Lua that can occur.
8921 \end_layout
8923 \begin_layout Subsection
8924 on_paint: Screen is being painted
8925 \end_layout
8927 \begin_layout Itemize
8928 Callback: on_paint(bool not_synth)
8929 \end_layout
8931 \begin_layout Standard
8932 Called when screen is being painted.
8933  Any gui.* calls requiring graphic context draw on the screen.
8934 \end_layout
8936 \begin_layout Itemize
8937 not_synth is true if this hook is being called in response to received frame,
8938  false otherwise.
8939 \end_layout
8941 \begin_layout Subsection
8942 on_video: Dumped video frame is being painted
8943 \end_layout
8945 \begin_layout Itemize
8946 Callback: on_video()
8947 \end_layout
8949 \begin_layout Standard
8950 Called when video dump frame is being painted.
8951  Any gui.* calls requiring graphic context draw on the video.
8952 \end_layout
8954 \begin_layout Subsection
8955 on_frame_emulated: Frame emulation complete
8956 \end_layout
8958 \begin_layout Itemize
8959 Callback: on_frame_emulated()
8960 \end_layout
8962 \begin_layout Standard
8963 Called when emulating frame has completed and on_paint()/on_video() calls
8964  are about to be issued.
8965 \end_layout
8967 \begin_layout Subsection
8968 on_frame: Frame emulation starting.
8969 \end_layout
8971 \begin_layout Itemize
8972 Callback: on_frame()
8973 \end_layout
8975 \begin_layout Standard
8976 Called on each starting whole frame.
8977 \end_layout
8979 \begin_layout Subsection
8980 on_rewind: Movie rewound to beginning
8981 \end_layout
8983 \begin_layout Itemize
8984 Callback: on_rewind()
8985 \end_layout
8987 \begin_layout Standard
8988 Called when rewind movie to beginning has completed.
8989 \end_layout
8991 \begin_layout Subsection
8992 on_pre_load: Load operation is about to start
8993 \end_layout
8995 \begin_layout Itemize
8996 Callback: on_pre_load(string name)
8997 \end_layout
8999 \begin_layout Standard
9000 Called just before savestate/movie load occurs (note: loads are always delayed,
9001  so this occurs even when load was initiated by lua).
9002 \end_layout
9004 \begin_layout Subsection
9005 on_err_Load: Load failed
9006 \end_layout
9008 \begin_layout Itemize
9009 Callback: on_err_load(string name)
9010 \end_layout
9012 \begin_layout Standard
9013 Called if loadstate goes wrong.
9014 \end_layout
9016 \begin_layout Subsection
9017 on_post_load: Load completed
9018 \end_layout
9020 \begin_layout Itemize
9021 Callback: on_post_load(string name, boolean was_savestate)
9022 \end_layout
9024 \begin_layout Standard
9025 Called on successful loadstate.
9026  was_savestate gives if this was a savestate or a movie.
9027 \end_layout
9029 \begin_layout Subsection
9030 on_pre_save: Save operation is about to start
9031 \end_layout
9033 \begin_layout Itemize
9034 Callback: on_pre_save(string name, boolean is_savestate)
9035 \end_layout
9037 \begin_layout Standard
9038 Called just before savestate save occurs (note: movie saves are synchronous
9039  and won't trigger these callbacks if called from Lua).
9040 \end_layout
9042 \begin_layout Subsection
9043 on_err_save: Save failed
9044 \end_layout
9046 \begin_layout Itemize
9047 Callback: on_err_save(string name)
9048 \end_layout
9050 \begin_layout Standard
9051 Called if savestate goes wrong.
9052 \end_layout
9054 \begin_layout Subsection
9055 on_post_save: Save completed
9056 \end_layout
9058 \begin_layout Itemize
9059 Callback: on_post_save(string name, boolean is_savestate)
9060 \end_layout
9062 \begin_layout Standard
9063 Called on successful savaestate.
9064  is_savestate gives if this was a savestate or a movie.
9065 \end_layout
9067 \begin_layout Subsection
9068 on_quit: Emulator is shutting down
9069 \end_layout
9071 \begin_layout Itemize
9072 Callback: on_quit()
9073 \end_layout
9075 \begin_layout Standard
9076 Called when emulator is shutting down.
9077 \end_layout
9079 \begin_layout Subsection
9080 on_input: Polling for input
9081 \end_layout
9083 \begin_layout Standard
9084 Called when emulator is just sending input to bsnes core.
9085  Warning: This is called even in readonly mode, but the results are ignored.
9086 \end_layout
9088 \begin_layout Subsection
9089 on_reset: System has been reset
9090 \end_layout
9092 \begin_layout Itemize
9093 Callback: on_reset()
9094 \end_layout
9096 \begin_layout Standard
9097 Called when system is reset.
9098 \end_layout
9100 \begin_layout Subsection
9101 on_readwrite: Entered recording mode
9102 \end_layout
9104 \begin_layout Itemize
9105 Callback: on_readwrite()
9106 \end_layout
9108 \begin_layout Standard
9109 Called when moving into recording mode as result of 
9110 \begin_inset Quotes eld
9111 \end_inset
9113 set-rwmode
9114 \begin_inset Quotes erd
9115 \end_inset
9117  command (note: moving to rwmode by Lua won't trigger this, as per recursive
9118  entry protection).
9119 \end_layout
9121 \begin_layout Subsection
9122 on_snoop/on_snoop2: Snoop core controller reads
9123 \end_layout
9125 \begin_layout Itemize
9126 Callback: on_snoop(number port, number controller, number index, number
9127  value)
9128 \end_layout
9130 \begin_layout Itemize
9131 Callback: on_snoop2(number port, number controller, number index, number
9132  value)
9133 \end_layout
9135 \begin_layout Standard
9136 Called each time bsnes asks for input.
9137  The value is the final value to be sent to bsnes core (readonly mode, autohold
9138  and autofire have been taken into account).
9139  Might be useful when translating movies to format suitable for console
9140  verification.
9141  Note: There is no way to modify the value to be sent.
9142 \end_layout
9144 \begin_layout Itemize
9145 On_snoop2 is called instead of on_snoop if defined.
9146  Reserves port 0 for system, having first user port be port 1.
9147 \end_layout
9149 \begin_layout Subsection
9150 on_keyhook: Hooked key/axis has been moved
9151 \end_layout
9153 \begin_layout Itemize
9154 Callback: on_keyhook(string keyname, table state)
9155 \end_layout
9157 \begin_layout Standard
9158 Sent when key that has keyhook events requested changes state.
9159  Keyname is name of the key (group) and state is the state (same kind as
9160  table values in input.raw).
9161 \end_layout
9163 \begin_layout Subsection
9164 on_idle: Idle event
9165 \end_layout
9167 \begin_layout Itemize
9168 Callback: on_idle()
9169 \end_layout
9171 \begin_layout Standard
9172 Called when requested by set_idle_timeout(), the timeout has expired and
9173  emulator is waiting.
9174 \end_layout
9176 \begin_layout Subsection
9177 on_timer: Timer event
9178 \end_layout
9180 \begin_layout Itemize
9181 Callback: on_timer()
9182 \end_layout
9184 \begin_layout Standard
9185 Called when requested by set_idle_timeout() and the timeout has expired
9186  (regardless if emulator is waiting).
9187 \end_layout
9189 \begin_layout Subsection
9190 on_set_rewind: Rewind point has been set
9191 \end_layout
9193 \begin_layout Itemize
9194 Callback: on_set_rewind(UNSAFEREWIND r)
9195 \end_layout
9197 \begin_layout Standard
9198 Called when unsafe rewind object has been constructed.
9199 \end_layout
9201 \begin_layout Subsection
9202 on_pre_rewind: Rewind is about to occur
9203 \end_layout
9205 \begin_layout Itemize
9206 Callback: on_pre_rewind() 
9207 \end_layout
9209 \begin_layout Standard
9210 Called just before unsafe rewind is about to occur.
9211 \end_layout
9213 \begin_layout Subsection
9214 on_post_rewind: Rewind has occured
9215 \end_layout
9217 \begin_layout Itemize
9218 Callback: on_post_rewind() 
9219 \end_layout
9221 \begin_layout Standard
9222 Called just after unsafe rewind has occured.
9223 \end_layout
9225 \begin_layout Subsection
9226 on_button: Button has been pressed
9227 \end_layout
9229 \begin_layout Itemize
9230 Callback: on_button(number port, number controller, number index, string
9231  type)
9232 \end_layout
9234 \begin_layout Standard
9235 Called on controller button press, with following parameters:
9236 \end_layout
9238 \begin_layout Itemize
9239 port: Port number (0 is system)
9240 \end_layout
9242 \begin_layout Itemize
9243 controller: Controller within port
9244 \end_layout
9246 \begin_layout Itemize
9247 index: Index of button.
9248 \end_layout
9250 \begin_layout Itemize
9251 type: Type of event, one of:
9252 \begin_inset Separator latexpar
9253 \end_inset
9256 \end_layout
9258 \begin_deeper
9259 \begin_layout Itemize
9260 \begin_inset Quotes eld
9261 \end_inset
9263 pressed
9264 \begin_inset Quotes erd
9265 \end_inset
9267 : Button was pressed.
9268 \end_layout
9270 \begin_layout Itemize
9271 \begin_inset Quotes eld
9272 \end_inset
9274 released
9275 \begin_inset Quotes erd
9276 \end_inset
9278 : Button was released.
9279 \end_layout
9281 \begin_layout Itemize
9282 \begin_inset Quotes eld
9283 \end_inset
9285 hold
9286 \begin_inset Quotes erd
9287 \end_inset
9289 : Held.
9290 \end_layout
9292 \begin_layout Itemize
9293 \begin_inset Quotes eld
9294 \end_inset
9296 unhold
9297 \begin_inset Quotes erd
9298 \end_inset
9300 : Released from hold.
9301 \end_layout
9303 \begin_layout Itemize
9304 \begin_inset Quotes eld
9305 \end_inset
9307 type
9308 \begin_inset Quotes erd
9309 \end_inset
9311 : Typing input on button.
9312 \end_layout
9314 \begin_layout Itemize
9315 \begin_inset Quotes eld
9316 \end_inset
9318 untype
9319 \begin_inset Quotes erd
9320 \end_inset
9322 : Typing input undone.
9323 \end_layout
9325 \begin_layout Itemize
9326 \begin_inset Quotes eld
9327 \end_inset
9329 autofire <duty> <cycle>
9330 \begin_inset Quotes erd
9331 \end_inset
9333 : Autofire with specifie duty and cycle.
9334 \end_layout
9336 \begin_layout Itemize
9337 \begin_inset Quotes eld
9338 \end_inset
9340 autofire
9341 \begin_inset Quotes erd
9342 \end_inset
9344 : Stop autofire.
9345 \end_layout
9347 \begin_layout Itemize
9348 \begin_inset Quotes eld
9349 \end_inset
9351 analog
9352 \begin_inset Quotes erd
9353 \end_inset
9355 : Analog action on axis.
9356 \end_layout
9358 \end_deeper
9359 \begin_layout Subsection
9360 on_movie_lost: Movie data is about to be lost
9361 \end_layout
9363 \begin_layout Itemize
9364 Callback: on_movie_lost(STRING kind)
9365 \end_layout
9367 \begin_layout Standard
9368 Called just before something would happen that could lose movie data.
9369  Kind can be:
9370 \end_layout
9372 \begin_layout Itemize
9373 readwrite: Switching to recording mode.
9374 \end_layout
9376 \begin_layout Itemize
9377 reload: ROM is being reloaded in recording mode.
9378 \end_layout
9380 \begin_layout Itemize
9381 load: New movie is being loaded.
9382 \end_layout
9384 \begin_layout Itemize
9385 unsaferewind: Unsafe rewind is happening.
9386 \end_layout
9388 \begin_layout Subsection
9389 on_latch: Latch line is rising
9390 \end_layout
9392 \begin_layout Itemize
9393 Callback: on_latch(<core-dependent-parameters>)
9394 \end_layout
9396 \begin_layout Standard
9397 Called when latch line for controller is rising.
9398  Some cores may not support this.
9399 \end_layout
9401 \begin_layout Section
9402 System-dependent behaviour
9403 \end_layout
9405 \begin_layout Subsection
9406 bsnes core
9407 \end_layout
9409 \begin_layout Itemize
9410 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
9411  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
9412  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
9413 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
9414 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
9415  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
9416  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
9417  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
9418  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
9419 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
9420 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
9421  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
9422 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
9423 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
9424  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
9425 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
9426  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
9427 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
9428 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
9429 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
9430  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
9431 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
9432  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
9433  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
9434 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
9435 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
9436 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
9437  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
9438 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
9439  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
9440  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
9441  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
9442  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
9443 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
9444  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
9445 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
9446  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
9447  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
9448 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
9449  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
9450 \end_layout
9452 \begin_layout Itemize
9453 on_latch has no parameters
9454 \end_layout
9456 \begin_layout Itemize
9457 CPU 0 is S-CPU, 1 is S-SMP.
9458 \end_layout
9460 \begin_layout Itemize
9461 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
9462 \end_layout
9464 \begin_layout Itemize
9465 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
9466 {RAM,ROM}.
9467 \end_layout
9469 \begin_layout Itemize
9470 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
9471  DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
9472  BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
9473  GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
9474 \end_layout
9476 \begin_layout Subsection
9477 gambatte core
9478 \end_layout
9480 \begin_layout Itemize
9481 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
9482  d, e, f, h, l
9483 \end_layout
9485 \begin_layout Itemize
9486 on_latch is not supported
9487 \end_layout
9489 \begin_layout Itemize
9490 CPU 0 is main CPU.
9491 \end_layout
9493 \begin_layout Itemize
9494 Cheats are supported for ROM, SRAM and WRAM.
9495 \end_layout
9497 \begin_layout Itemize
9498 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
9499  and WRAM.
9500 \end_layout
9502 \begin_layout Itemize
9503 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
9504 \end_layout
9506 \end_body
9507 \end_document