Add a internal TODO list
[lsnes.git] / lua.lyx
blob71b3c77b8ce6f3cf7da22d1fdffb6a862cf2f51a
1 #LyX 2.1 created this file. For more info see http://www.lyx.org/
2 \lyxformat 474
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options true
7 \maintain_unincluded_children false
8 \language english
9 \language_package default
10 \inputencoding auto
11 \fontencoding global
12 \font_roman default
13 \font_sans default
14 \font_typewriter default
15 \font_math auto
16 \font_default_family default
17 \use_non_tex_fonts false
18 \font_sc false
19 \font_osf false
20 \font_sf_scale 100
21 \font_tt_scale 100
22 \graphics default
23 \default_output_format default
24 \output_sync 0
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
28 \spacing single
29 \use_hyperref true
30 \pdf_bookmarks true
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
34 \pdf_breaklinks false
35 \pdf_pdfborder false
36 \pdf_colorlinks false
37 \pdf_backref false
38 \pdf_pdfusetitle true
39 \papersize a4paper
40 \use_geometry true
41 \use_package amsmath 1
42 \use_package amssymb 1
43 \use_package cancel 1
44 \use_package esint 1
45 \use_package mathdots 1
46 \use_package mathtools 1
47 \use_package mhchem 1
48 \use_package stackrel 1
49 \use_package stmaryrd 1
50 \use_package undertilde 1
51 \cite_engine basic
52 \cite_engine_type default
53 \biblio_style plain
54 \use_bibtopic false
55 \use_indices false
56 \paperorientation portrait
57 \suppress_date false
58 \justification true
59 \use_refstyle 1
60 \index Hakusana
61 \shortcut idx
62 \color #008000
63 \end_index
64 \leftmargin 2cm
65 \topmargin 2cm
66 \rightmargin 1cm
67 \bottommargin 2cm
68 \headheight 1cm
69 \headsep 1cm
70 \footskip 1cm
71 \secnumdepth 3
72 \tocdepth 3
73 \paragraph_separation indent
74 \paragraph_indentation default
75 \quotes_language english
76 \papercolumns 1
77 \papersides 1
78 \paperpagestyle default
79 \tracking_changes false
80 \output_changes false
81 \html_math_output 0
82 \html_css_as_file 0
83 \html_be_strict false
84 \end_header
86 \begin_body
88 \begin_layout Title
89 lsnes Lua functions reference
90 \end_layout
92 \begin_layout Section
93 Table of contents
94 \end_layout
96 \begin_layout Standard
97 \begin_inset CommandInset toc
98 LatexCommand tableofcontents
100 \end_inset
103 \end_layout
105 \begin_layout Standard
106 \begin_inset Newpage pagebreak
107 \end_inset
110 \end_layout
112 \begin_layout Section
113 Conventions
114 \end_layout
116 \begin_layout Subsection
117 Coordinates:
118 \end_layout
120 \begin_layout Itemize
121 Coordinates increase to right and down.
122 \end_layout
124 \begin_layout Itemize
125 The origin is at top left of game area or buffer.
126 \end_layout
128 \begin_layout Subsection
129 Drawing and contexts
130 \end_layout
132 \begin_layout Itemize
133 Methods that draw something (unless stated otherwise) require a valid rendering
134  context.
135  This context can come in three ways:
136 \end_layout
138 \begin_deeper
139 \begin_layout Enumerate
140 The default rendering context of paint callback (the screen).
141 \end_layout
143 \begin_layout Enumerate
144 The default rendering context of video callback (the video).
145 \end_layout
147 \begin_layout Enumerate
148 Explicitly set rendering context (RENDERCTX:set).
149 \end_layout
151 \end_deeper
152 \begin_layout Itemize
153 The rendering context is always reset when callback ends.
154 \end_layout
156 \begin_layout Subsection
157 Colors
158 \end_layout
160 \begin_layout Standard
161 (Direct) colors can be specified either as numbers or strings.
162 \end_layout
164 \begin_layout Itemize
165 -1 is fully transparent.
166 \end_layout
168 \begin_layout Itemize
169 Non-negative numbers less than 
170 \begin_inset Formula $2^{32}$
171 \end_inset
173  are partially opaque colors (
174 \begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
175 \end_inset
178 \end_layout
180 \begin_deeper
181 \begin_layout Itemize
182 \begin_inset Formula $a$
183 \end_inset
185  is transparency 
186 \begin_inset Formula $0-255$
187 \end_inset
190 \begin_inset Formula $0$
191 \end_inset
193  is fully opaque, 
194 \begin_inset Formula $256$
195 \end_inset
197  would be fully transparent.
198 \end_layout
200 \begin_deeper
201 \begin_layout Itemize
202 Thus, numbers in range 
203 \begin_inset Formula $0-16777215$
204 \end_inset
206  stand for fully opaque colors.
207 \end_layout
209 \end_deeper
210 \begin_layout Itemize
211 \begin_inset Formula $r$
212 \end_inset
215 \begin_inset Formula $g$
216 \end_inset
218  and 
219 \begin_inset Formula $b$
220 \end_inset
222  are intensities of base colors on scale 
223 \begin_inset Formula $0-255$
224 \end_inset
227 \end_layout
229 \end_deeper
230 \begin_layout Itemize
231 Color can also be specified by name as string: The following color names
232  are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
233  antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
234  azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
235  bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
236  brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
237  burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
238  chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
239  chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
240 ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
241  cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
242  darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
243  darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
244  darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
245 d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
246 een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
247  darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
248  darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
249  deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
250  dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
251  firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
252  fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
253  goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
254  gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
255  gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
256  gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
257  gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
258  gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
259  gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
260  gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
261  gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
262  gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
263  green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
264  grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
265  grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
266  grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
267  grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
268  grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
269  grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
270  grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
271  grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
272  grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
273  honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
274  indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
275  ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
276  lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
277 fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
278  lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
279  lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
280 nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
281  lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
282  lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
283  lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
284  lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
285  lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
286  lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
287  maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
288  mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
289  mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
290 le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
291 tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
292 4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
293  navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
294  olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
295  orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
296  palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
297 se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
298  palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
299  peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
300  pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
301  purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
302  rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
303  saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
304  seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
305  seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
306  skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
307 4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
308  snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
309 n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
310  tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
311  tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
312  turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
313  wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
314  yellow3 yellow4 yellowgreen 
315 \end_layout
317 \begin_layout Itemize
318 The HSL base color names: hsl-<hue><saturation><lightness>.
319 \end_layout
321 \begin_deeper
322 \begin_layout Itemize
323 Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
324  y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
325  (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
326 \end_layout
328 \begin_layout Itemize
329 Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
330 \end_layout
332 \begin_layout Itemize
333 Lightness is 0-8, where 0 is black and 8 is white.
334 \end_layout
336 \end_deeper
337 \begin_layout Itemize
338 The color names can have a modifier after space (multiple modifiers are
339  allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
340  opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
341  hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
342 \end_layout
344 \begin_deeper
345 \begin_layout Itemize
346 opaqueness is measured as percentage.
347 \end_layout
349 \begin_layout Itemize
350 Hue adjustments are on 24-step scale.
351 \end_layout
353 \begin_layout Itemize
354 Saturation and lightness adjustments are on 16-step scale.
355 \end_layout
357 \end_deeper
358 \begin_layout Section
359 Special tokens
360 \end_layout
362 \begin_layout Standard
363 These tokens are special, and are expanded while the script is being loaded
364 \end_layout
366 \begin_layout Subsection
367 @@LUA_SCRIPT_FILENAME@@
368 \end_layout
370 \begin_layout Standard
371 Expanded to string token containing path and filename of this Lua script.
372  Handy for referencing other lua scripts or resources that are relative
373  to this Lua script.
374 \end_layout
376 \begin_layout Standard
377 In practicular, this is suitable to be passed as base argument of various
378  functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
379 ad_png and gui.bitmap_load_pal.
380 \end_layout
382 \begin_layout Section
383 Classes
384 \end_layout
386 \begin_layout Subsection
387 MMAP_STRUCT: Quasi-table mapping emulated memory
388 \end_layout
390 \begin_layout Standard
391 Objects of this class act like tables, except that the values are reflected
392  to and from emulated memory.
393 \end_layout
395 \begin_layout Subsubsection
396 static function new: Create new instance
397 \end_layout
399 \begin_layout Itemize
400 Syntax: mmap memory.mmap.new()
401 \end_layout
403 \begin_layout Itemize
404 Syntax: mmap classes.MMAP_STRUCT.new()
405 \end_layout
407 \begin_layout Itemize
408 Deprecated: mmap memory.map_structure()
409 \end_layout
411 \begin_layout Standard
412 Return value:
413 \end_layout
415 \begin_layout Itemize
416 mmap: MMAP_STRUCT: The created mmap structure.
417 \end_layout
419 \begin_layout Standard
420 Create a new MMAP_STRUCT (with no mappings) and return it.
421 \end_layout
423 \begin_layout Subsubsection
424 operator(): Bind key in mmap structure
425 \end_layout
427 \begin_layout Itemize
428 Syntax: obj(key, {marea, address|addrobj}, type)
429 \end_layout
431 \begin_layout Standard
432 Parameters:
433 \end_layout
435 \begin_layout Itemize
436 obj: MMAP_STRUCT: The structure to manipulate.
437 \end_layout
439 \begin_layout Itemize
440 key: String: The name of the key in array to map.
441 \end_layout
443 \begin_layout Itemize
444 marea: String: The memory area the mapped address is in (default: global
445  memory space).
446 \end_layout
448 \begin_layout Itemize
449 address: Number: The offset of memory addreess, relative to specified memory
450  area or global memory space.
451 \end_layout
453 \begin_layout Itemize
454 addrobj: ADDRESS: The memory address.
455 \end_layout
457 \begin_layout Itemize
458 type: String: The type of data to map.
459 \end_layout
461 \begin_deeper
462 \begin_layout Itemize
463 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
464  float or double.
465 \end_layout
467 \end_deeper
468 \begin_layout Standard
469 Bind key <key> in mmap structure <obj> to address <address> (relative to
470  <marea>).
471  The memory address is treated as type <type>.
472 \end_layout
474 \begin_layout Itemize
475 Example: foomap(
476 \begin_inset Quotes eld
477 \end_inset
480 \begin_inset Quotes erd
481 \end_inset
484 \begin_inset Quotes eld
485 \end_inset
487 WRAM
488 \begin_inset Quotes erd
489 \end_inset
491 , 0x2A, 
492 \begin_inset Quotes eld
493 \end_inset
495 sword
496 \begin_inset Quotes erd
497 \end_inset
500 \end_layout
502 \begin_layout Standard
503 This binds signed word at address WRAM+0x2A into key 
504 \begin_inset Quotes eld
505 \end_inset
508 \begin_inset Quotes erd
509 \end_inset
512 \end_layout
514 \begin_layout Standard
515 \begin_inset Newpage pagebreak
516 \end_inset
519 \end_layout
521 \begin_layout Subsection
522 ZIPWRITER: Write .zip files
523 \end_layout
525 \begin_layout Standard
526 This class does writing of .zip files.
527 \end_layout
529 \begin_layout Subsubsection
530 Static function new: Create a new zipfile
531 \end_layout
533 \begin_layout Itemize
534 Syntax: zip zip.writer.new(filename, [compression])
535 \end_layout
537 \begin_layout Itemize
538 Deprecated: zip zip.create(filename, [compression])
539 \end_layout
541 \begin_layout Standard
542 Parameters:
543 \end_layout
545 \begin_layout Itemize
546 filename: string: The name of the file to write.
547 \end_layout
549 \begin_layout Itemize
550 compression: number: Compression level (0-9).
551  Default is 9.
552 \end_layout
554 \begin_layout Standard
555 Return value:
556 \end_layout
558 \begin_layout Itemize
559 zip: ZIPWRITER: The newly created ZIP writer.
560 \end_layout
562 \begin_layout Standard
563 Create a new ZIPWRITER object and return it.
564 \end_layout
566 \begin_layout Subsubsection
567 Method commit: Finish creating ZIP file.
568 \end_layout
570 \begin_layout Itemize
571 Syntax: zipfile:commit()
572 \end_layout
574 \begin_layout Standard
575 Parameters:
576 \end_layout
578 \begin_layout Itemize
579 zipfile: ZIPFILE: The ZIP file object.
580 \end_layout
582 \begin_layout Standard
583 Finish writing the ZIP file and actually create it on disk.
584 \end_layout
586 \begin_layout Itemize
587 If a member is currently open, it is implicitly closed.
588 \end_layout
590 \begin_layout Itemize
591 Invoking this on already committed or rolled back zipfile causes an error.
592 \end_layout
594 \begin_layout Subsubsection
595 Method rollback: Cancel writing the ZIP file.
596 \end_layout
598 \begin_layout Itemize
599 Syntax: zipfile:rollback()
600 \end_layout
602 \begin_layout Standard
603 Parameters:
604 \end_layout
606 \begin_layout Itemize
607 zipfile: ZIPFILE: The ZIP file object.
608 \end_layout
610 \begin_layout Standard
611 Cancel writing the whole ZIP file.
612  The file on disk will not be modified.
613 \end_layout
615 \begin_layout Itemize
616 If a member is currently open, it is implicitly closed.
617 \end_layout
619 \begin_layout Itemize
620 Invoking this on already committed or rolled back zipfile causes an error.
621 \end_layout
623 \begin_layout Subsubsection
624 Method create_file: Start writing a new member
625 \end_layout
627 \begin_layout Itemize
628 Syntax: zipfile:create_file(filename)
629 \end_layout
631 \begin_layout Standard
632 Parameters:
633 \end_layout
635 \begin_layout Itemize
636 zipfile: ZIPFILE: The ZIP file object.
637 \end_layout
639 \begin_layout Itemize
640 string filename: Name of the new member to create
641 \end_layout
643 \begin_layout Standard
644 Start writing a new member <filename> in ZIP file.
645 \end_layout
647 \begin_layout Itemize
648 If a member is currently open, it is implicitly closed.
649 \end_layout
651 \begin_layout Itemize
652 Invoking this on already committed or rolled back zipfile causes an error.
653 \end_layout
655 \begin_layout Subsubsection
656 Method close_file: Close member
657 \end_layout
659 \begin_layout Itemize
660 Syntax: zipfile:close_file()
661 \end_layout
663 \begin_layout Standard
664 Parameters:
665 \end_layout
667 \begin_layout Itemize
668 zipfile: ZIPFILE: The ZIP file object.
669 \end_layout
671 \begin_layout Standard
672 Close the currently open member in zipfile.
673 \end_layout
675 \begin_layout Itemize
676 Invoking this on already committed or rolled back zipfile causes an error.
677 \end_layout
679 \begin_layout Itemize
680 Invoking this without an open member causes an error.
681 \end_layout
683 \begin_layout Subsubsection
684 Method write: Write data
685 \end_layout
687 \begin_layout Itemize
688 Syntax: zipfile:write(data)
689 \end_layout
691 \begin_layout Standard
692 Parameters:
693 \end_layout
695 \begin_layout Itemize
696 zipfile: ZIPFILE: The ZIP file object.
697 \end_layout
699 \begin_layout Itemize
700 data: string: The data to write.
701 \end_layout
703 \begin_layout Standard
704 Write <data> in binary mode (as-is) to currently open member.
705 \end_layout
707 \begin_layout Itemize
708 Invoking this without a member being open causes an error.
709 \end_layout
711 \begin_layout Standard
712 \begin_inset Newpage pagebreak
713 \end_inset
716 \end_layout
718 \begin_layout Subsection
719 TILEMAP: Tiled collection of bitmaps.
720 \end_layout
722 \begin_layout Standard
723 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
724 \end_layout
726 \begin_layout Subsubsection
727 Static function new: Create a tilemap
728 \end_layout
730 \begin_layout Itemize
731 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
732 \end_layout
734 \begin_layout Itemize
735 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
736 \end_layout
738 \begin_layout Itemize
739 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
740 \end_layout
742 \begin_layout Standard
743 Parameters:
744 \end_layout
746 \begin_layout Itemize
747 w: number: Width of the tilemap in tiles
748 \end_layout
750 \begin_layout Itemize
751 h: number: Height of the tilemap in tiles
752 \end_layout
754 \begin_layout Itemize
755 bw: number: Width of each tile in pixels.
756 \end_layout
758 \begin_layout Itemize
759 bh: number: Height of each tile in pixels.
760 \end_layout
762 \begin_layout Standard
763 Return value:
764 \end_layout
766 \begin_layout Itemize
767 tilemap: TILEMAP: the newly created tilemap
768 \end_layout
770 \begin_layout Standard
771 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
772  it.
773 \end_layout
775 \begin_layout Subsubsection
776 TILEMAP:getsize: Query tilemap size
777 \end_layout
779 \begin_layout Itemize
780 Syntax: width, height tmap:getsize()
781 \end_layout
783 \begin_layout Standard
784 Parameters:
785 \end_layout
787 \begin_layout Itemize
788 tmap: TILEMAP: The tilemap to query.
789 \end_layout
791 \begin_layout Standard
792 Return value:
793 \end_layout
795 \begin_layout Itemize
796 width: number : The width of the tilemap in tiles.
797 \end_layout
799 \begin_layout Itemize
800 height: number: The height of the tilemap in tiles.
801 \end_layout
803 \begin_layout Standard
804 Get size of tilemap in tiles.
805 \end_layout
807 \begin_layout Subsubsection
808 TILEMAP:getcsize: Query tilemap cell size
809 \end_layout
811 \begin_layout Itemize
812 Syntax: width, height tmap:getcsize()
813 \end_layout
815 \begin_layout Standard
816 Parameters:
817 \end_layout
819 \begin_layout Itemize
820 tmap: TILEMAP: The tilemap to query.
821 \end_layout
823 \begin_layout Standard
824 Return value:
825 \end_layout
827 \begin_layout Itemize
828 width: number: The width of tilemap tile in pixels.
829 \end_layout
831 \begin_layout Itemize
832 height: number: The height of tilemap tile in pixels.
833 \end_layout
835 \begin_layout Standard
836 Get size of each tilemap tile in pixels.
837 \end_layout
839 \begin_layout Subsubsection
840 TILEMAP:get: Query tilemap tile
841 \end_layout
843 \begin_layout Itemize
844 Syntax: bitmap, palette tmap:get(x, y)
845 \end_layout
847 \begin_layout Standard
848 Parameters:
849 \end_layout
851 \begin_layout Itemize
852 tmap: TILEMAP: The tilemap to query.
853 \end_layout
855 \begin_layout Itemize
856 x: number: The x-coordinate of tile to query.
857 \end_layout
859 \begin_layout Itemize
860 y: number: The y-coordinate of tile to query.
861 \end_layout
863 \begin_layout Standard
864 Return value:
865 \end_layout
867 \begin_layout Itemize
868 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
869 \end_layout
871 \begin_layout Itemize
872 palette: The palette (PALETTE) associated with indexed-color bitmap, if
873  any.
874  Otherwise nil.
875 \end_layout
877 \begin_layout Standard
878 Return the contents of tile at <x>,<y>.
879 \end_layout
881 \begin_layout Subsubsection
882 TILEMAP:set: Set tilemap cell
883 \end_layout
885 \begin_layout Itemize
886 Syntax: tmap:set(x, y)
887 \end_layout
889 \begin_layout Itemize
890 Syntax: tmap:set(x, y, bitmap)
891 \end_layout
893 \begin_layout Itemize
894 Syntax: tmap:set(x, y, bitmap, palette)
895 \end_layout
897 \begin_layout Standard
898 Parameters:
899 \end_layout
901 \begin_layout Itemize
902 tmap: TILEMAP: The tilemap to manipulate.
903 \end_layout
905 \begin_layout Itemize
906 number x: The x-coordinate of tile to set.
907 \end_layout
909 \begin_layout Itemize
910 number y: The y-coordinate of tile to set.
911 \end_layout
913 \begin_layout Itemize
914 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
915 \end_layout
917 \begin_layout Itemize
918 palette: PALETTE: The associated palette for bitmap.
919 \end_layout
921 \begin_layout Standard
922 Set the contents of tile <x>,<y>.
923  If no <bitmap> is given, clears the tile.
924  Otherwise sets the tile to contain bitmap <bitmap> with associated palette
925  <palette>.
926 \end_layout
928 \begin_layout Itemize
929 Specifying index bitmap <bitmap> without palette <palette> causes an error.
930 \end_layout
932 \begin_layout Subsubsection
933 TILEMAP:scroll: Scroll tilemap
934 \end_layout
936 \begin_layout Itemize
937 Syntax: tmap:scroll(ox, oy);
938 \end_layout
940 \begin_layout Itemize
941 Syntax: tmap:scroll(ox, oy, x, y, w, h);
942 \end_layout
944 \begin_layout Itemize
945 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
946 \end_layout
948 \begin_layout Standard
949 Parameters:
950 \end_layout
952 \begin_layout Itemize
953 tmap: TILEMAP: The tilemap to manipulate.
954 \end_layout
956 \begin_layout Itemize
957 ox: number: The number of tiles to scroll horizontally (positive is to right).
958 \end_layout
960 \begin_layout Itemize
961 oy: number: The number of tiles to scroll vertically (positive is to down).
962 \end_layout
964 \begin_layout Itemize
965 x: number: The left edge of scroll window.
966 \end_layout
968 \begin_layout Itemize
969 y: number: The top edge of scroll window.
970 \end_layout
972 \begin_layout Itemize
973 w: number: The width of scroll window.
974 \end_layout
976 \begin_layout Itemize
977 h: number: The height of scroll window.
978 \end_layout
980 \begin_layout Itemize
981 circ_x: boolean: If true, treat the window as circular in horizontal direction.
982 \end_layout
984 \begin_layout Itemize
985 circ_y: boolean: If true, treat the window as circular in vertical direction.
986 \end_layout
988 \begin_layout Standard
989 Scroll the specified tilemap <tmap> by <ox>,<oy>.
990  If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
991  <circ_x> and <circ_y> control if scroll is circular or not.
992 \end_layout
994 \begin_layout Itemize
995 Specifying out-of-range window causes an error.
996 \end_layout
998 \begin_layout Subsubsection
999 TILEMAP:draw: Draw tilemap
1000 \end_layout
1002 \begin_layout Itemize
1003 Name: tmap:draw(x, y)
1004 \end_layout
1006 \begin_layout Itemize
1007 Name: tmap:draw(x, y, x0, y0, w, h)
1008 \end_layout
1010 \begin_layout Standard
1011 Parameters:
1012 \end_layout
1014 \begin_layout Itemize
1015 tmap: TILEMAP: The tilemap to draw.
1016 \end_layout
1018 \begin_layout Itemize
1019 x: The x coordinate on screen to draw to.
1020 \end_layout
1022 \begin_layout Itemize
1023 y: The y coordinate on screen to draw to.
1024 \end_layout
1026 \begin_layout Itemize
1027 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1028 \end_layout
1030 \begin_layout Itemize
1031 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1032 \end_layout
1034 \begin_layout Itemize
1035 w: number: The width to draw (in pixels).
1036 \end_layout
1038 \begin_layout Itemize
1039 h: number: The height to draw (in pixels).
1040 \end_layout
1042 \begin_layout Standard
1043 Draw tilemap <tmap> to screen at <x>,<y>.
1044  If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1045 \end_layout
1047 \begin_layout Itemize
1048 This method requires a rendering context to work.
1049 \end_layout
1051 \begin_layout Subsubsection
1052 TILEMAP:draw_outside: Draw tilemap outside game area
1053 \end_layout
1055 \begin_layout Itemize
1056 Name: tmap:draw_outside(x, y)
1057 \end_layout
1059 \begin_layout Itemize
1060 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1061 \end_layout
1063 \begin_layout Standard
1064 Like TILEMAP:draw, but draws only outside game area.
1065 \end_layout
1067 \begin_layout Standard
1068 \begin_inset Newpage pagebreak
1069 \end_inset
1072 \end_layout
1074 \begin_layout Subsection
1075 RENDERCTX: Off-screen rendering context
1076 \end_layout
1078 \begin_layout Standard
1079 Object acting as off-screen rendering context.
1080 \end_layout
1082 \begin_layout Subsubsection
1083 Static function new: Create a render queue
1084 \end_layout
1086 \begin_layout Itemize
1087 Syntax: renderctx gui.renderctx.new(width, height);
1088 \end_layout
1090 \begin_layout Itemize
1091 Syntax: renderctx classes.RENDERCTX.new(width, height);
1092 \end_layout
1094 \begin_layout Itemize
1095 Deprecated: renderctx gui.renderq_new(width, height);
1096 \end_layout
1098 \begin_layout Standard
1099 Parameters:
1100 \end_layout
1102 \begin_layout Itemize
1103 width: number: The notional width of the game area.
1104 \end_layout
1106 \begin_layout Itemize
1107 height: number: The notional height of the game area.
1108 \end_layout
1110 \begin_layout Standard
1111 Returns:
1112 \end_layout
1114 \begin_layout Itemize
1115 rendectx: RENDERCTX: The newly created render context.
1116 \end_layout
1118 \begin_layout Standard
1119 Create a render context with reported size <width>*<height> and return it.
1120 \end_layout
1122 \begin_layout Subsubsection
1123 Static function setnull: Reset to default queue
1124 \end_layout
1126 \begin_layout Itemize
1127 Syntax: gui.renderctx.setnull()
1128 \end_layout
1130 \begin_layout Itemize
1131 Syntax: classes.RENDERCTX:setnull()
1132 \end_layout
1134 \begin_layout Itemize
1135 Deprecated: gui.renderq_set()
1136 \end_layout
1138 \begin_layout Standard
1139 Reset the used render context back to default for the executing callback:
1140 \end_layout
1142 \begin_layout Itemize
1143 The default for paint callback is the screen
1144 \end_layout
1146 \begin_layout Itemize
1147 The default for video callback is the video frame
1148 \end_layout
1150 \begin_layout Itemize
1151 The default otherwise is nothing.
1152 \end_layout
1154 \begin_layout Subsubsection
1155 Method clear: Clear a render queue
1156 \end_layout
1158 \begin_layout Itemize
1159 Syntax: renderctx:clear()
1160 \end_layout
1162 \begin_layout Itemize
1163 Deprecated: gui.renderq_clear(renderctx)
1164 \end_layout
1166 \begin_layout Standard
1167 Parameters:
1168 \end_layout
1170 \begin_layout Itemize
1171 renderctx: RENDERCTX: The render queue to clear.
1172 \end_layout
1174 \begin_layout Standard
1175 Clear all drawing from the context.
1176 \end_layout
1178 \begin_layout Subsubsection
1179 Method set: Change active render context
1180 \end_layout
1182 \begin_layout Itemize
1183 Syntax: renderctx:set()
1184 \end_layout
1186 \begin_layout Itemize
1187 Deprecated: gui.renderq_set(renderctx)
1188 \end_layout
1190 \begin_layout Standard
1191 Parameters:
1192 \end_layout
1194 \begin_layout Itemize
1195 renderctx: RENDERCTX: The render queue to use.
1196 \end_layout
1198 \begin_layout Standard
1199 Switch the current rendering context <renderctx>.
1200 \end_layout
1202 \begin_layout Subsubsection
1203 Method run: Draw all objects in context to another
1204 \end_layout
1206 \begin_layout Itemize
1207 Syntax: renderctx:run()
1208 \end_layout
1210 \begin_layout Itemize
1211 Deprecated: gui.renderq_run(renderctx)
1212 \end_layout
1214 \begin_layout Standard
1215 Parameters:
1216 \end_layout
1218 \begin_layout Itemize
1219 renderctx: RENDERCTX: The render context to overlay.
1220 \end_layout
1222 \begin_layout Standard
1223 Overlay the specified render context <context> upon the active rendering
1224  context.
1225 \end_layout
1227 \begin_layout Itemize
1228 Trying to overlay rendering context upon itself is a bad idea.
1229 \end_layout
1231 \begin_layout Subsubsection
1232 Method render: Render a contex to bitmap
1233 \end_layout
1235 \begin_layout Itemize
1236 Syntax: bitmap renderctx:render()
1237 \end_layout
1239 \begin_layout Standard
1240 Parameters:
1241 \end_layout
1243 \begin_layout Itemize
1244 renderctx: RENDERCTX: The context to render.
1245 \end_layout
1247 \begin_layout Standard
1248 Returns:
1249 \end_layout
1251 \begin_layout Itemize
1252 bitmap: DBITMAP: The rendered bitmap.
1253 \end_layout
1255 \begin_layout Standard
1256 Render the specified context <renderctx> to a new bitmap.
1257 \end_layout
1259 \begin_layout Itemize
1260 The size of bitmap will be nominal game area size, plus any set gaps.
1261 \end_layout
1263 \begin_layout Itemize
1264 This method does not require active rendering context.
1265 \end_layout
1267 \begin_layout Subsubsection
1268 Method synchronous_repaint: Paint screen now
1269 \end_layout
1271 \begin_layout Itemize
1272 Syntax: renderctx:synchronous_repaint()
1273 \end_layout
1275 \begin_layout Itemize
1276 Deprecated: gui.synchronous_repaint(renderctx)
1277 \end_layout
1279 \begin_layout Standard
1280 Parameters:
1281 \end_layout
1283 \begin_layout Itemize
1284 renderctx: RENDERCTX: The context to paint.
1285 \end_layout
1287 \begin_layout Standard
1288 Immediately redraw the screen with game overlayed by drawings from context
1289  <renderctx>.
1290 \end_layout
1292 \begin_layout Itemize
1293 This does not require active rendering context.
1294 \end_layout
1296 \begin_layout Itemize
1297 Will not cause paint callback to be invoked.
1298 \end_layout
1300 \begin_layout Standard
1301 \begin_inset Newpage pagebreak
1302 \end_inset
1305 \end_layout
1307 \begin_layout Subsection
1308 PALETTE: Color palette for indexed image
1309 \end_layout
1311 \begin_layout Subsubsection
1312 Static function new: Create a new palette
1313 \end_layout
1315 \begin_layout Itemize
1316 Syntax: palette gui.palette.new()
1317 \end_layout
1319 \begin_layout Itemize
1320 Syntax: palette classes.PALETTE.new()
1321 \end_layout
1323 \begin_layout Itemize
1324 Deprecated: palette gui.palette_new()
1325 \end_layout
1327 \begin_layout Standard
1328 Returns:
1329 \end_layout
1331 \begin_layout Itemize
1332 palette: PALETTE: The created palette.
1333 \end_layout
1335 \begin_layout Standard
1336 Create a new palette (with all colors transparent) and return it.
1337 \end_layout
1339 \begin_layout Subsubsection
1340 Static function load: Load a palette
1341 \end_layout
1343 \begin_layout Itemize
1344 Syntax: palette gui.palette.load(file, [base])
1345 \end_layout
1347 \begin_layout Itemize
1348 Syntax: palette classes.PALETTE.load(file, [base])
1349 \end_layout
1351 \begin_layout Itemize
1352 Deprecated: palette gui.palette_load(file, [base])
1353 \end_layout
1355 \begin_layout Standard
1356 Parameters:
1357 \end_layout
1359 \begin_layout Itemize
1360 string file: The file to load.
1361 \end_layout
1363 \begin_layout Itemize
1364 string base (optional): The base file to resolve file relative to.
1365 \end_layout
1367 \begin_layout Standard
1368 Returns:
1369 \end_layout
1371 \begin_layout Itemize
1372 palette: PALETTE: The loaded palette.
1373 \end_layout
1375 \begin_layout Standard
1376 Load a palette from file <file> (resolved relative to <base>).
1377 \end_layout
1379 \begin_layout Itemize
1380 The file format is a series of lines, each with following format:
1381 \end_layout
1383 \begin_deeper
1384 \begin_layout Itemize
1385 Blank or just whitespace: Ignored
1386 \end_layout
1388 \begin_layout Itemize
1389 First non-whitespace is '#': Ignored
1390 \end_layout
1392 \begin_layout Itemize
1393 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1394 \end_layout
1396 \begin_layout Itemize
1397 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1398  (0-256, 0 being fully transparent and 256 fully opaque).
1399 \end_layout
1401 \begin_layout Itemize
1402 transparent: Fully transparent color
1403 \end_layout
1405 \end_deeper
1406 \begin_layout Subsubsection
1407 Static function load_str: Load a palette from string
1408 \end_layout
1410 \begin_layout Itemize
1411 Syntax: palette gui.palette.load(data)
1412 \end_layout
1414 \begin_layout Itemize
1415 Syntax: palette classes.PALETTE.load(data)
1416 \end_layout
1418 \begin_layout Itemize
1419 Deprecated: palette gui.palette_load(data)
1420 \end_layout
1422 \begin_layout Standard
1423 Parameters:
1424 \end_layout
1426 \begin_layout Itemize
1427 string data: The palette data.
1428 \end_layout
1430 \begin_layout Standard
1431 Returns:
1432 \end_layout
1434 \begin_layout Itemize
1435 palette: PALETTE: The loaded palette.
1436 \end_layout
1438 \begin_layout Standard
1439 Like PALETTE:load, but instead of reading palette from file, reads it from
1440  a string.
1441 \end_layout
1443 \begin_layout Subsubsection
1444 Method set: Set palette entry
1445 \end_layout
1447 \begin_layout Itemize
1448 Syntax: palette:set(index, color)
1449 \end_layout
1451 \begin_layout Itemize
1452 Deprecated: gui.palette_set(palette, ...)
1453 \end_layout
1455 \begin_layout Standard
1456 Parameters:
1457 \end_layout
1459 \begin_layout Itemize
1460 palette: PALETTE: The palette to manipulate
1461 \end_layout
1463 \begin_layout Itemize
1464 index: number: The index of color to set (0-65535).
1465 \end_layout
1467 \begin_layout Itemize
1468 color: number/string: The color value to set.
1469 \end_layout
1471 \begin_layout Standard
1472 Set palette <palette> index <index> to color <color>.
1473 \end_layout
1475 \begin_layout Subsubsection
1476 Method hash: Hash a palette
1477 \end_layout
1479 \begin_layout Itemize
1480 Syntax: hash palette:hash()
1481 \end_layout
1483 \begin_layout Itemize
1484 Deprecated: hash gui.palette_hash(palette)
1485 \end_layout
1487 \begin_layout Standard
1488 Parameters:
1489 \end_layout
1491 \begin_layout Itemize
1492 palette: The palette to hash.
1493 \end_layout
1495 \begin_layout Standard
1496 Return value:
1497 \end_layout
1499 \begin_layout Itemize
1500 hash: string: 64-hex digit hash.
1501 \end_layout
1503 \begin_layout Standard
1504 Obtain crypto-grade hash of palette data of <palette>.
1505 \end_layout
1507 \begin_layout Itemize
1508 All colors after the last non-transparent one are ignored.
1509 \end_layout
1511 \begin_layout Subsubsection
1512 Method adjust_transparency: Adjust transparency
1513 \end_layout
1515 \begin_layout Itemize
1516 Syntax: palette:adjust_transparency(newvalue)
1517 \end_layout
1519 \begin_layout Itemize
1520 Deprecated: gui.adjust_transparency(palette, ...)
1521 \end_layout
1523 \begin_layout Standard
1524 Parameters:
1525 \end_layout
1527 \begin_layout Itemize
1528 palette: PALETTE: The palette to adjust.
1529 \end_layout
1531 \begin_layout Itemize
1532 Number adj: The factor to multiply opaqueness with times 256.
1533 \end_layout
1535 \begin_layout Standard
1536 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1537 \end_layout
1539 \begin_layout Standard
1540 \begin_inset Newpage pagebreak
1541 \end_inset
1544 \end_layout
1546 \begin_layout Subsection
1547 BITMAP: Indexed-color bitmap
1548 \end_layout
1550 \begin_layout Subsubsection
1551 Static function new: Create a new bitmap
1552 \end_layout
1554 \begin_layout Itemize
1555 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1556 \end_layout
1558 \begin_layout Itemize
1559 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1560 \end_layout
1562 \begin_layout Itemize
1563 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1564 \end_layout
1566 \begin_layout Standard
1567 Parameters:
1568 \end_layout
1570 \begin_layout Itemize
1571 w: number: The width of bitmap to create in pixels.
1572 \end_layout
1574 \begin_layout Itemize
1575 h: number: The height of bitmap to create in pixels.
1576 \end_layout
1578 \begin_layout Itemize
1579 false: boolean: Constant boolean false.
1580 \end_layout
1582 \begin_layout Itemize
1583 fillcolor: number: The initial fill index.
1584  Default 0 if not specified.
1585 \end_layout
1587 \begin_layout Standard
1588 Create a new bitmap of size <w>*<h>.
1589  Fill the bitmap with color index <fillcolor>.
1590 \end_layout
1592 \begin_layout Subsubsection
1593 Method draw: Draw a bitmap
1594 \end_layout
1596 \begin_layout Itemize
1597 Syntax: bitmap:draw(x, y, palette)
1598 \end_layout
1600 \begin_layout Itemize
1601 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1602 \end_layout
1604 \begin_layout Standard
1605 Parameters:
1606 \end_layout
1608 \begin_layout Itemize
1609 bitmap: BITMAP: The bitmap to draw
1610 \end_layout
1612 \begin_layout Itemize
1613 x: number: The x-coordinate on screen.
1614 \end_layout
1616 \begin_layout Itemize
1617 y: number: The y-coordinate on screen.
1618 \end_layout
1620 \begin_layout Itemize
1621 palette: The palette to use for drawing.
1622 \end_layout
1624 \begin_layout Standard
1625 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1626 \end_layout
1628 \begin_layout Subsubsection
1629 Method draw_outside: Draw a bitmap outside game area
1630 \end_layout
1632 \begin_layout Itemize
1633 Syntax: bitmap:draw_outside(x, y, palette)
1634 \end_layout
1636 \begin_layout Standard
1637 Like bitmap:draw, but does not draw on game area.
1638 \end_layout
1640 \begin_layout Subsubsection
1641 Method draw_clip: Draw a bitmap, with clipping
1642 \end_layout
1644 \begin_layout Itemize
1645 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1646 \end_layout
1648 \begin_layout Standard
1649 Parameters:
1650 \end_layout
1652 \begin_layout Itemize
1653 bitmap: BITMAP: The bitmap to draw
1654 \end_layout
1656 \begin_layout Itemize
1657 x: number: The x-coordinate on screen.
1658 \end_layout
1660 \begin_layout Itemize
1661 y: number: The y-coordinate on screen.
1662 \end_layout
1664 \begin_layout Itemize
1665 palette: The palette to use for drawing.
1666 \end_layout
1668 \begin_layout Itemize
1669 x0: The smallest bitmap x coordinate to draw.
1670 \end_layout
1672 \begin_layout Itemize
1673 y0: The smallest bitmap y coordinate to draw.
1674 \end_layout
1676 \begin_layout Itemize
1677 width: Width of region to draw
1678 \end_layout
1680 \begin_layout Itemize
1681 height: Height of region to draw.
1682 \end_layout
1684 \begin_layout Standard
1685 Like bitmap:draw, but clip the bitmap area drawn.
1686 \end_layout
1688 \begin_layout Subsubsection
1689 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1690 \end_layout
1692 \begin_layout Itemize
1693 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1694 \end_layout
1696 \begin_layout Standard
1697 Like bitmap:draw_clip, but only draw outside game area.
1698 \end_layout
1700 \begin_layout Subsubsection
1701 Method pset: Set pixel in bitmap
1702 \end_layout
1704 \begin_layout Itemize
1705 Syntax: bitmap:pset(x, y, color)
1706 \end_layout
1708 \begin_layout Itemize
1709 Deprecaed: gui.bitmap_pset(bitmap, ...)
1710 \end_layout
1712 \begin_layout Standard
1713 Parameters:
1714 \end_layout
1716 \begin_layout Itemize
1717 bitmap: BITMAP: The bitmap to manipulate.
1718 \end_layout
1720 \begin_layout Itemize
1721 x: number: x-coordinate of pixel to set.
1722 \end_layout
1724 \begin_layout Itemize
1725 y: number: y-coordinate of pixel to set.
1726 \end_layout
1728 \begin_layout Itemize
1729 color: number: The color index to set.
1730 \end_layout
1732 \begin_layout Standard
1733 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1734 \end_layout
1736 \begin_layout Subsubsection
1737 Method pget: Get pixel in bitmap
1738 \end_layout
1740 \begin_layout Itemize
1741 Syntax: color bitmap:pget(x,y)
1742 \end_layout
1744 \begin_layout Itemize
1745 Deprecated: color gui.bitmap_pget(bitmap, ...)
1746 \end_layout
1748 \begin_layout Standard
1749 Parameters:
1750 \end_layout
1752 \begin_layout Itemize
1753 bitmap: BITMAP: The bitmap to query.
1754 \end_layout
1756 \begin_layout Itemize
1757 x: number: x-coordinate of pixel to get.
1758 \end_layout
1760 \begin_layout Itemize
1761 y: number: y-coordinate of pixel to get.
1762 \end_layout
1764 \begin_layout Standard
1765 Returns:
1766 \end_layout
1768 \begin_layout Itemize
1769 color: number: The color index in specified pixel.
1770 \end_layout
1772 \begin_layout Standard
1773 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1774 \end_layout
1776 \begin_layout Subsubsection
1777 Method size: Get size of bitmap
1778 \end_layout
1780 \begin_layout Itemize
1781 Syntax: width, height bitmap:size()
1782 \end_layout
1784 \begin_layout Itemize
1785 Syntax: width, height gui.bitmap_size(bitmap)
1786 \end_layout
1788 \begin_layout Standard
1789 Parameters:
1790 \end_layout
1792 \begin_layout Itemize
1793 bitmap: BITMAP: The bitmap to query.
1794 \end_layout
1796 \begin_layout Standard
1797 Returns:
1798 \end_layout
1800 \begin_layout Itemize
1801 width: number: The width of the bitmap.
1802 \end_layout
1804 \begin_layout Itemize
1805 height: number: The height of the bitmap.
1806 \end_layout
1808 \begin_layout Standard
1809 Get size of bitmap <bitmap>.
1810 \end_layout
1812 \begin_layout Subsubsection
1813 Method blit: Blit a bitmap into another
1814 \end_layout
1816 \begin_layout Itemize
1817 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1818 \end_layout
1820 \begin_layout Itemize
1821 Deprecated: gui.bitmap_blit(dest, ...)
1822 \end_layout
1824 \begin_layout Standard
1825 Parameters:
1826 \end_layout
1828 \begin_layout Itemize
1829 dest: BITMAP: The target bitmap to blit to.
1830 \end_layout
1832 \begin_layout Itemize
1833 dx: number: The x-coordinate in target.
1834 \end_layout
1836 \begin_layout Itemize
1837 dy: number: The y-coordinate in target.
1838 \end_layout
1840 \begin_layout Itemize
1841 src: BITMAP: The source bitmap.
1842 \end_layout
1844 \begin_layout Itemize
1845 sx: number: The x-coordinate in source.
1846 \end_layout
1848 \begin_layout Itemize
1849 sy: number: The y-coordinate in source.
1850 \end_layout
1852 \begin_layout Itemize
1853 w: number: The width of area to blit.
1854 \end_layout
1856 \begin_layout Itemize
1857 h: number: The height of area to blit.
1858 \end_layout
1860 \begin_layout Itemize
1861 ck: number: The color key.
1862  Pixels with this index are not copied.
1863 \end_layout
1865 \begin_deeper
1866 \begin_layout Itemize
1867 If none is specified, all pixels are copied.
1868 \end_layout
1870 \end_deeper
1871 \begin_layout Standard
1872 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1873  <dx>,<dy>.
1874  If a color key <ck> is specified, pixels of that color are not copied.
1875 \end_layout
1877 \begin_layout Subsubsection
1878 Method blit_scaled: Blit a bitmap into another with scaling
1879 \end_layout
1881 \begin_layout Itemize
1882 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1883 \end_layout
1885 \begin_layout Itemize
1886 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1887 \end_layout
1889 \begin_layout Standard
1890 Parameters:
1891 \end_layout
1893 \begin_layout Itemize
1894 dest: BITMAP: The target bitmap to blit to.
1895 \end_layout
1897 \begin_layout Itemize
1898 dx: number: The x-coordinate in target.
1899 \end_layout
1901 \begin_layout Itemize
1902 dy: number: The y-coordinate in target.
1903 \end_layout
1905 \begin_layout Itemize
1906 src: BITMAP: The source bitmap.
1907 \end_layout
1909 \begin_layout Itemize
1910 sx: number: The x-coordinate in source.
1911 \end_layout
1913 \begin_layout Itemize
1914 sy: number: The y-coordinate in source.
1915 \end_layout
1917 \begin_layout Itemize
1918 w: number: The width of area to blit.
1919 \end_layout
1921 \begin_layout Itemize
1922 h: number: The height of area to blit.
1923 \end_layout
1925 \begin_layout Itemize
1926 hscl: number: Horizontal scale factor (integer).
1927 \end_layout
1929 \begin_layout Itemize
1930 vscl: number: Vertical scale factor (integer).
1931  Defaults to the same as <hscl>.
1932 \end_layout
1934 \begin_layout Itemize
1935 ck: number: The color key.
1936  Pixels with this index are not copied.
1937 \end_layout
1939 \begin_deeper
1940 \begin_layout Itemize
1941 If none is specified, all pixels are copied.
1942 \end_layout
1944 \end_deeper
1945 \begin_layout Standard
1946 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1947  neighbor) by factor of <hscl>*<vscl>.
1948 \end_layout
1950 \begin_layout Subsubsection
1951 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1952 \end_layout
1954 \begin_layout Itemize
1955 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1956 \end_layout
1958 \begin_layout Itemize
1959 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1960 \end_layout
1962 \begin_layout Standard
1963 Parameters:
1964 \end_layout
1966 \begin_layout Itemize
1967 dest: BITMAP: The target bitmap to blit to.
1968 \end_layout
1970 \begin_layout Itemize
1971 dx: number: The x-coordinate in target.
1972 \end_layout
1974 \begin_layout Itemize
1975 dy: number: The y-coordinate in target.
1976 \end_layout
1978 \begin_layout Itemize
1979 src: BITMAP: The source bitmap.
1980 \end_layout
1982 \begin_layout Itemize
1983 sx: number: The x-coordinate in source.
1984 \end_layout
1986 \begin_layout Itemize
1987 sy: number: The y-coordinate in source.
1988 \end_layout
1990 \begin_layout Itemize
1991 w: number: The width of area to blit.
1992 \end_layout
1994 \begin_layout Itemize
1995 h: number: The height of area to blit.
1996 \end_layout
1998 \begin_layout Itemize
1999 operator: string: The operator to use.
2000 \end_layout
2002 \begin_deeper
2003 \begin_layout Itemize
2004 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2005  DestOut, Clear or Xor.
2006 \end_layout
2008 \end_deeper
2009 \begin_layout Standard
2010 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2011  operator.
2013 \end_layout
2015 \begin_layout Itemize
2016 Color index 0 in source and target is treated as background.
2017 \end_layout
2019 \begin_layout Subsubsection
2020 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2021  Porter-Duff composition
2022 \end_layout
2024 \begin_layout Itemize
2025 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2026  operator)
2027 \end_layout
2029 \begin_layout Itemize
2030 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2031 \end_layout
2033 \begin_layout Standard
2034 Parameters:
2035 \end_layout
2037 \begin_layout Itemize
2038 dest: BITMAP: The target bitmap to blit to.
2039 \end_layout
2041 \begin_layout Itemize
2042 dx: number: The x-coordinate in target.
2043 \end_layout
2045 \begin_layout Itemize
2046 dy: number: The y-coordinate in target.
2047 \end_layout
2049 \begin_layout Itemize
2050 src: BITMAP: The source bitmap.
2051 \end_layout
2053 \begin_layout Itemize
2054 sx: number: The x-coordinate in source.
2055 \end_layout
2057 \begin_layout Itemize
2058 sy: number: The y-coordinate in source.
2059 \end_layout
2061 \begin_layout Itemize
2062 w: number: The width of area to blit.
2063 \end_layout
2065 \begin_layout Itemize
2066 h: number: The height of area to blit.
2067 \end_layout
2069 \begin_layout Itemize
2070 hscl: number: Horizontal scale factor (integer).
2071 \end_layout
2073 \begin_layout Itemize
2074 vscl: number: Vertical scale factor (integer).
2075  Defaults to the same as <hscl>.
2076 \end_layout
2078 \begin_layout Itemize
2079 operator: string: The operator to use.
2080 \end_layout
2082 \begin_deeper
2083 \begin_layout Itemize
2084 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2085  DestOut, Clear or Xor.
2086 \end_layout
2088 \end_deeper
2089 \begin_layout Standard
2090 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2091  like BITMAP:blit_scaled.
2092 \end_layout
2094 \begin_layout Subsubsection
2095 Method blit_priority: Blit a bitmap into another with color priority
2096 \end_layout
2098 \begin_layout Itemize
2099 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2100 \end_layout
2102 \begin_layout Itemize
2103 Deprecated: gui.bitmap_blit_priority(dest, ...)
2104 \end_layout
2106 \begin_layout Standard
2107 Parameters:
2108 \end_layout
2110 \begin_layout Itemize
2111 dest: BITMAP: The target bitmap to blit to.
2112 \end_layout
2114 \begin_layout Itemize
2115 dx: number: The x-coordinate in target.
2116 \end_layout
2118 \begin_layout Itemize
2119 dy: number: The y-coordinate in target.
2120 \end_layout
2122 \begin_layout Itemize
2123 src: BITMAP: The source bitmap.
2124 \end_layout
2126 \begin_layout Itemize
2127 sx: number: The x-coordinate in source.
2128 \end_layout
2130 \begin_layout Itemize
2131 sy: number: The y-coordinate in source.
2132 \end_layout
2134 \begin_layout Itemize
2135 w: number: The width of area to blit.
2136 \end_layout
2138 \begin_layout Itemize
2139 h: number: The height of area to blit.
2140 \end_layout
2142 \begin_layout Standard
2143 Like BITMAP:blit, but only copy pixels where source color index is greater
2144  than destination color index.
2145 \end_layout
2147 \begin_layout Subsubsection
2148 Method blit_scaled_priority: Blit a bitmap into another with color priority
2149  and scaling
2150 \end_layout
2152 \begin_layout Itemize
2153 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2154 \end_layout
2156 \begin_layout Itemize
2157 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2158 \end_layout
2160 \begin_layout Standard
2161 Parameters:
2162 \end_layout
2164 \begin_layout Itemize
2165 dest: BITMAP: The target bitmap to blit to.
2166 \end_layout
2168 \begin_layout Itemize
2169 dx: number: The x-coordinate in target.
2170 \end_layout
2172 \begin_layout Itemize
2173 dy: number: The y-coordinate in target.
2174 \end_layout
2176 \begin_layout Itemize
2177 src: BITMAP: The source bitmap.
2178 \end_layout
2180 \begin_layout Itemize
2181 sx: number: The x-coordinate in source.
2182 \end_layout
2184 \begin_layout Itemize
2185 sy: number: The y-coordinate in source.
2186 \end_layout
2188 \begin_layout Itemize
2189 w: number: The width of area to blit.
2190 \end_layout
2192 \begin_layout Itemize
2193 h: number: The height of area to blit.
2194 \end_layout
2196 \begin_layout Itemize
2197 hscl: number: Horizontal scale factor (integer).
2198 \end_layout
2200 \begin_layout Itemize
2201 vscl: number: Vertical scale factor (integer).
2202  Defaults to the same as <hscl>.
2203 \end_layout
2205 \begin_layout Standard
2206 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2207 caled.
2208 \end_layout
2210 \begin_layout Subsubsection
2211 Method save_png: Save a bitmap to PNG
2212 \end_layout
2214 \begin_layout Itemize
2215 Syntax: bitmap:save_png(filename, [base], palette)
2216 \end_layout
2218 \begin_layout Itemize
2219 Syntax: data bitmap:save_png(palette)
2220 \end_layout
2222 \begin_layout Itemize
2223 Deprecated: ...
2224  gui.bitmap_save_png(bitmap, ...)
2225 \end_layout
2227 \begin_layout Standard
2228 Parameters:
2229 \end_layout
2231 \begin_layout Itemize
2232 bitmap: BITMAP: The bitmap to save.
2233 \end_layout
2235 \begin_layout Itemize
2236 filename: string: The filename to save to.
2237 \end_layout
2239 \begin_layout Itemize
2240 base: string: The base filename is resolved relative to.
2241 \end_layout
2243 \begin_layout Itemize
2244 palette: PALETTE: The palette to use.
2245 \end_layout
2247 \begin_layout Standard
2248 Return value:
2249 \end_layout
2251 \begin_layout Itemize
2252 data: string: BASE64 encoded PNG data.
2253 \end_layout
2255 \begin_layout Standard
2256 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2257  to <base>) or return BASE64 encoding of it.
2258 \end_layout
2260 \begin_layout Subsubsection
2261 Method hash: Hash a bitmap
2262 \end_layout
2264 \begin_layout Itemize
2265 Syntax: hash bitmap:hash()
2266 \end_layout
2268 \begin_layout Itemize
2269 Deprecated: hash bitmap:hash(bitmap)
2270 \end_layout
2272 \begin_layout Standard
2273 Parameters:
2274 \end_layout
2276 \begin_layout Itemize
2277 bitmap: BITMAP: The bitmap to hash.
2278 \end_layout
2280 \begin_layout Standard
2281 Return value:
2282 \end_layout
2284 \begin_layout Itemize
2285 hash: string: 64-hex digit hash
2286 \end_layout
2288 \begin_layout Standard
2289 Hashes bitmap <bitmap> and returns crypto-strong hash.
2291 \end_layout
2293 \begin_layout Itemize
2294 Color order in bitmap is significant.
2295 \end_layout
2297 \begin_layout Standard
2298 \begin_inset Newpage pagebreak
2299 \end_inset
2302 \end_layout
2304 \begin_layout Subsection
2305 DBITMAP: Direct-color bitmap
2306 \end_layout
2308 \begin_layout Subsubsection
2309 Static function: new: Create a new bitmap
2310 \end_layout
2312 \begin_layout Itemize
2313 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2314 \end_layout
2316 \begin_layout Itemize
2317 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2318 \end_layout
2320 \begin_layout Itemize
2321 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2322 \end_layout
2324 \begin_layout Standard
2325 Parameters:
2326 \end_layout
2328 \begin_layout Itemize
2329 w: number: The width of new bitmap.
2330 \end_layout
2332 \begin_layout Itemize
2333 h: number: The height of new bitmap.
2334 \end_layout
2336 \begin_layout Itemize
2337 true: boolean: Fixed boolean true
2338 \end_layout
2340 \begin_layout Itemize
2341 fillcolor: The color to fill the bitmap with (default transparent).
2342 \end_layout
2344 \begin_layout Standard
2345 Return value:
2346 \end_layout
2348 \begin_layout Itemize
2349 bitmap: DBITMAP: The new bitmap.
2350 \end_layout
2352 \begin_layout Standard
2353 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2354  <fillcolor>.
2355 \end_layout
2357 \begin_layout Subsubsection
2358 Method draw: Draw a bitmap
2359 \end_layout
2361 \begin_layout Itemize
2362 Syntax: bitmap.draw(x, y)
2363 \end_layout
2365 \begin_layout Itemize
2366 Deprecated: gui.bitmap_draw(x, y, bitmap)
2367 \end_layout
2369 \begin_layout Standard
2370 Parameters:
2371 \end_layout
2373 \begin_layout Itemize
2374 bitmap: DBITMAP: The bitmap to draw.
2375 \end_layout
2377 \begin_layout Itemize
2378 x: number: X-coordinate on screen.
2379 \end_layout
2381 \begin_layout Itemize
2382 y: number: Y-coordinate on screen.
2383 \end_layout
2385 \begin_layout Standard
2386 Draw bitmap <bitmap> on screen at <x>,<y>.
2387 \end_layout
2389 \begin_layout Subsubsection
2390 Method draw_outside: Draw a bitmap outside game area
2391 \end_layout
2393 \begin_layout Itemize
2394 Syntax: dbitmap:draw_outside(x, y, palette)
2395 \end_layout
2397 \begin_layout Standard
2398 Like dbitmap:draw, but does not draw on game area.
2399 \end_layout
2401 \begin_layout Subsubsection
2402 Method draw_clip: Draw a bitmap, with clipping
2403 \end_layout
2405 \begin_layout Itemize
2406 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2407 \end_layout
2409 \begin_layout Standard
2410 Parameters:
2411 \end_layout
2413 \begin_layout Itemize
2414 bitmap: DBITMAP: The bitmap to draw
2415 \end_layout
2417 \begin_layout Itemize
2418 x: number: The x-coordinate on screen.
2419 \end_layout
2421 \begin_layout Itemize
2422 y: number: The y-coordinate on screen.
2423 \end_layout
2425 \begin_layout Itemize
2426 x0: The smallest bitmap x coordinate to draw.
2427 \end_layout
2429 \begin_layout Itemize
2430 y0: The smallest bitmap y coordinate to draw.
2431 \end_layout
2433 \begin_layout Itemize
2434 width: Width of region to draw
2435 \end_layout
2437 \begin_layout Itemize
2438 height: Height of region to draw.
2439 \end_layout
2441 \begin_layout Standard
2442 Like dbitmap:draw, but clip the bitmap area drawn.
2443 \end_layout
2445 \begin_layout Subsubsection
2446 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2447 \end_layout
2449 \begin_layout Itemize
2450 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2451 \end_layout
2453 \begin_layout Standard
2454 Like dbitmap:draw_clip, but only draw outside game area.
2455 \end_layout
2457 \begin_layout Subsubsection
2458 Method pset: Set pixel in bitmap
2459 \end_layout
2461 \begin_layout Itemize
2462 Syntax: bitmap:pset(x, y, color)
2463 \end_layout
2465 \begin_layout Itemize
2466 Deprecaed: gui.bitmap_pset(bitmap, ...)
2467 \end_layout
2469 \begin_layout Standard
2470 Parameters:
2471 \end_layout
2473 \begin_layout Itemize
2474 bitmap: DBITMAP: The bitmap to manipulate.
2475 \end_layout
2477 \begin_layout Itemize
2478 x: number: x-coordinate of pixel to set.
2479 \end_layout
2481 \begin_layout Itemize
2482 y: number: y-coordinate of pixel to set.
2483 \end_layout
2485 \begin_layout Itemize
2486 color: number/string: The color to set.
2487 \end_layout
2489 \begin_layout Standard
2490 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2491 \end_layout
2493 \begin_layout Subsubsection
2494 Method pget: Get pixel in bitmap
2495 \end_layout
2497 \begin_layout Itemize
2498 Syntax: color bitmap:pget(x,y)
2499 \end_layout
2501 \begin_layout Itemize
2502 Deprecated: color gui.bitmap_pget(bitmap, ...)
2503 \end_layout
2505 \begin_layout Standard
2506 Parameters:
2507 \end_layout
2509 \begin_layout Itemize
2510 bitmap: DBITMAP: The bitmap to query.
2511 \end_layout
2513 \begin_layout Itemize
2514 x: number: x-coordinate of pixel to get.
2515 \end_layout
2517 \begin_layout Itemize
2518 y: number: y-coordinate of pixel to get.
2519 \end_layout
2521 \begin_layout Standard
2522 Returns:
2523 \end_layout
2525 \begin_layout Itemize
2526 color: number: The color of specified pixel.
2527 \end_layout
2529 \begin_layout Standard
2530 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2531 \end_layout
2533 \begin_layout Subsubsection
2534 Method size: Get size of bitmap
2535 \end_layout
2537 \begin_layout Itemize
2538 Syntax: width, height bitmap:size()
2539 \end_layout
2541 \begin_layout Itemize
2542 Syntax: width, height gui.bitmap_size(bitmap)
2543 \end_layout
2545 \begin_layout Standard
2546 Parameters:
2547 \end_layout
2549 \begin_layout Itemize
2550 bitmap: DBITMAP: The bitmap to query.
2551 \end_layout
2553 \begin_layout Standard
2554 Returns:
2555 \end_layout
2557 \begin_layout Itemize
2558 width: number: The width of the bitmap.
2559 \end_layout
2561 \begin_layout Itemize
2562 height: number: The height of the bitmap.
2563 \end_layout
2565 \begin_layout Standard
2566 Get size of bitmap <bitmap>.
2567 \end_layout
2569 \begin_layout Subsubsection
2570 Method blit: Blit a bitmap into another
2571 \end_layout
2573 \begin_layout Itemize
2574 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2575 \end_layout
2577 \begin_layout Itemize
2578 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2579 \end_layout
2581 \begin_layout Itemize
2582 Deprecated: gui.bitmap_blit(dest, ...)
2583 \end_layout
2585 \begin_layout Standard
2586 Parameters:
2587 \end_layout
2589 \begin_layout Itemize
2590 dest: DBITMAP: The target bitmap to blit to.
2591 \end_layout
2593 \begin_layout Itemize
2594 dx: number: The x-coordinate in target.
2595 \end_layout
2597 \begin_layout Itemize
2598 dy: number: The y-coordinate in target.
2599 \end_layout
2601 \begin_layout Itemize
2602 src: BITMAP/DBITMAP: The source bitmap.
2603 \end_layout
2605 \begin_layout Itemize
2606 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2607 \end_layout
2609 \begin_layout Itemize
2610 sx: number: The x-coordinate in source.
2611 \end_layout
2613 \begin_layout Itemize
2614 sy: number: The y-coordinate in source.
2615 \end_layout
2617 \begin_layout Itemize
2618 w: number: The width of area to blit.
2619 \end_layout
2621 \begin_layout Itemize
2622 h: number: The height of area to blit.
2623 \end_layout
2625 \begin_layout Itemize
2626 ck: number: The color key.
2627  Pixels with this index are not copied.
2628 \end_layout
2630 \begin_deeper
2631 \begin_layout Itemize
2632 If none is specified, all pixels are copied.
2633 \end_layout
2635 \begin_layout Itemize
2636 If <src> is paletted, this is color index, otherwise it is a color.
2637 \end_layout
2639 \end_deeper
2640 \begin_layout Standard
2641 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2642  if indexed) into <dest> at <dx>,<dy>.
2643  If a color key <ck> is specified, pixels of that color are not copied.
2644 \end_layout
2646 \begin_layout Subsubsection
2647 Method blit_scaled: Blit a bitmap into another with scaling
2648 \end_layout
2650 \begin_layout Itemize
2651 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2652 \end_layout
2654 \begin_layout Itemize
2655 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2656  [ck])
2657 \end_layout
2659 \begin_layout Itemize
2660 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2661 \end_layout
2663 \begin_layout Standard
2664 Parameters:
2665 \end_layout
2667 \begin_layout Itemize
2668 dest: DBITMAP: The target bitmap to blit to.
2669 \end_layout
2671 \begin_layout Itemize
2672 dx: number: The x-coordinate in target.
2673 \end_layout
2675 \begin_layout Itemize
2676 dy: number: The y-coordinate in target.
2677 \end_layout
2679 \begin_layout Itemize
2680 src: BITMAP/DBITMAP: The source bitmap.
2681 \end_layout
2683 \begin_layout Itemize
2684 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2685 \end_layout
2687 \begin_layout Itemize
2688 sx: number: The x-coordinate in source.
2689 \end_layout
2691 \begin_layout Itemize
2692 sy: number: The y-coordinate in source.
2693 \end_layout
2695 \begin_layout Itemize
2696 w: number: The width of area to blit.
2697 \end_layout
2699 \begin_layout Itemize
2700 h: number: The height of area to blit.
2701 \end_layout
2703 \begin_layout Itemize
2704 hscl: number: Horizontal scale factor (integer).
2705 \end_layout
2707 \begin_layout Itemize
2708 vscl: number: Vertical scale factor (integer).
2709  Defaults to the same as <hscl>.
2710 \end_layout
2712 \begin_layout Itemize
2713 ck: number: The color key.
2714  Pixels with this index are not copied.
2715 \end_layout
2717 \begin_deeper
2718 \begin_layout Itemize
2719 If none is specified, all pixels are copied.
2720 \end_layout
2722 \begin_layout Itemize
2723 If <src> is paletted, this is color index, otherwise it is a color.
2724 \end_layout
2726 \end_deeper
2727 \begin_layout Standard
2728 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2729  neighbor) by factor of <hscl>*<vscl>.
2730 \end_layout
2732 \begin_layout Subsubsection
2733 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2734 \end_layout
2736 \begin_layout Itemize
2737 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2738 \end_layout
2740 \begin_layout Itemize
2741 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2742 \end_layout
2744 \begin_layout Itemize
2745 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2746 \end_layout
2748 \begin_layout Standard
2749 Parameters:
2750 \end_layout
2752 \begin_layout Itemize
2753 dest: DBITMAP: The target bitmap to blit to.
2754 \end_layout
2756 \begin_layout Itemize
2757 dx: number: The x-coordinate in target.
2758 \end_layout
2760 \begin_layout Itemize
2761 dy: number: The y-coordinate in target.
2762 \end_layout
2764 \begin_layout Itemize
2765 src: BITMAP/DBITMAP: The source bitmap.
2766 \end_layout
2768 \begin_layout Itemize
2769 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2770 \end_layout
2772 \begin_layout Itemize
2773 sx: number: The x-coordinate in source.
2774 \end_layout
2776 \begin_layout Itemize
2777 sy: number: The y-coordinate in source.
2778 \end_layout
2780 \begin_layout Itemize
2781 w: number: The width of area to blit.
2782 \end_layout
2784 \begin_layout Itemize
2785 h: number: The height of area to blit.
2786 \end_layout
2788 \begin_layout Itemize
2789 operator: string: The operator to use.
2790 \end_layout
2792 \begin_deeper
2793 \begin_layout Itemize
2794 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2795  DestOut, Clear or Xor.
2796 \end_layout
2798 \end_deeper
2799 \begin_layout Standard
2800 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2801 f operator.
2803 \end_layout
2805 \begin_layout Itemize
2806 In target, fully transparent is background.
2807  In source, either fully transparent (if direct) or index 0 (if paletted)
2808  is treated as background.
2809 \end_layout
2811 \begin_layout Subsubsection
2812 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2813  Porter-Duff composition
2814 \end_layout
2816 \begin_layout Itemize
2817 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2818  operator)
2819 \end_layout
2821 \begin_layout Itemize
2822 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2823  [vscl], operator)
2824 \end_layout
2826 \begin_layout Itemize
2827 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2828 \end_layout
2830 \begin_layout Standard
2831 Parameters:
2832 \end_layout
2834 \begin_layout Itemize
2835 dest: DBITMAP: The target bitmap to blit to.
2836 \end_layout
2838 \begin_layout Itemize
2839 dx: number: The x-coordinate in target.
2840 \end_layout
2842 \begin_layout Itemize
2843 dy: number: The y-coordinate in target.
2844 \end_layout
2846 \begin_layout Itemize
2847 src: BITMAP/DBITMAP: The source bitmap.
2848 \end_layout
2850 \begin_layout Itemize
2851 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2852 \end_layout
2854 \begin_layout Itemize
2855 sx: number: The x-coordinate in source.
2856 \end_layout
2858 \begin_layout Itemize
2859 sy: number: The y-coordinate in source.
2860 \end_layout
2862 \begin_layout Itemize
2863 w: number: The width of area to blit.
2864 \end_layout
2866 \begin_layout Itemize
2867 h: number: The height of area to blit.
2868 \end_layout
2870 \begin_layout Itemize
2871 hscl: number: Horizontal scale factor (integer).
2872 \end_layout
2874 \begin_layout Itemize
2875 vscl: number: Vertical scale factor (integer).
2876  Defaults to the same as <hscl>.
2877 \end_layout
2879 \begin_layout Itemize
2880 operator: string: The operator to use.
2881 \end_layout
2883 \begin_deeper
2884 \begin_layout Itemize
2885 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2886  DestOut, Clear or Xor.
2887 \end_layout
2889 \end_deeper
2890 \begin_layout Standard
2891 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2892  like DBITMAP:blit_scaled.
2893 \end_layout
2895 \begin_layout Subsubsection
2896 Method adjust_transparency: Adjust transparency of bitmap
2897 \end_layout
2899 \begin_layout Itemize
2900 Syntax: bitmap:adjust_transparency(newvalue)
2901 \end_layout
2903 \begin_layout Itemize
2904 Deprecated: gui.adjust_transparency(bitmap, ...)
2905 \end_layout
2907 \begin_layout Standard
2908 Parameters:
2909 \end_layout
2911 \begin_layout Itemize
2912 bitmap: DBITMAP: The bitmap to adjust.
2913 \end_layout
2915 \begin_layout Itemize
2916 Number adj: The factor to multiply opaqueness with times 256.
2917 \end_layout
2919 \begin_layout Standard
2920 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2921 \end_layout
2923 \begin_layout Subsubsection
2924 Method save_png: Save a bitmap to PNG
2925 \end_layout
2927 \begin_layout Itemize
2928 Syntax: bitmap:save_png(filename, [base])
2929 \end_layout
2931 \begin_layout Itemize
2932 Syntax: data bitmap:save_png()
2933 \end_layout
2935 \begin_layout Itemize
2936 Deprecated: ...
2937  gui.bitmap_save_png(bitmap, ...)
2938 \end_layout
2940 \begin_layout Standard
2941 Parameters:
2942 \end_layout
2944 \begin_layout Itemize
2945 bitmap: DBITMAP: The bitmap to save.
2946 \end_layout
2948 \begin_layout Itemize
2949 filename: string: The filename to save to.
2950 \end_layout
2952 \begin_layout Itemize
2953 base: string: The base filename is resolved relative to.
2954 \end_layout
2956 \begin_layout Standard
2957 Return value:
2958 \end_layout
2960 \begin_layout Itemize
2961 data: string: BASE64 encoded PNG data.
2962 \end_layout
2964 \begin_layout Standard
2965 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2966  BASE64 encoding of it.
2967 \end_layout
2969 \begin_layout Subsubsection
2970 Method hash: Hash a bitmap
2971 \end_layout
2973 \begin_layout Itemize
2974 Syntax: hash bitmap:hash()
2975 \end_layout
2977 \begin_layout Itemize
2978 Deprecated: hash bitmap:hash(bitmap)
2979 \end_layout
2981 \begin_layout Standard
2982 Parameters:
2983 \end_layout
2985 \begin_layout Itemize
2986 bitmap: DBITMAP: The bitmap to hash.
2987 \end_layout
2989 \begin_layout Standard
2990 Return value:
2991 \end_layout
2993 \begin_layout Itemize
2994 hash: string: 64-hex digit hash
2995 \end_layout
2997 \begin_layout Standard
2998 Hashes bitmap <bitmap> and returns crypto-strong hash.
3000 \end_layout
3002 \begin_layout Subsection
3003 IMAGELOADER: Load an image
3004 \end_layout
3006 \begin_layout Subsubsection
3007 Static function load: Load a bitmap from file
3008 \end_layout
3010 \begin_layout Itemize
3011 Syntax: bitmap, palette gui.image.load(file, [base])
3012 \end_layout
3014 \begin_layout Itemize
3015 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3016 \end_layout
3018 \begin_layout Itemize
3019 Deprecated: ...
3020  gui.bitmap_load(...)
3021 \end_layout
3023 \begin_layout Standard
3024 Parameters:
3025 \end_layout
3027 \begin_layout Itemize
3028 file: string: The file to read.
3029 \end_layout
3031 \begin_layout Itemize
3032 base: string: The base to resolve <file> relative to.
3033 \end_layout
3035 \begin_layout Standard
3036 Returns:
3037 \end_layout
3039 \begin_layout Itemize
3040 bitmap: BITMAP/DBITMAP: The new bitmap
3041 \end_layout
3043 \begin_layout Itemize
3044 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3045  nil.
3046 \end_layout
3048 \begin_layout Standard
3049 Load a new bitmap and return it (plus associated palette if any).
3050 \end_layout
3052 \begin_layout Subsubsection
3053 Static function load_str: Load a bitmap from string
3054 \end_layout
3056 \begin_layout Itemize
3057 Syntax: bitmap, palette gui.image.load_str(data)
3058 \end_layout
3060 \begin_layout Itemize
3061 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3062 \end_layout
3064 \begin_layout Itemize
3065 Deprecated: ...
3066  gui.bitmap_load_str(...)
3067 \end_layout
3069 \begin_layout Standard
3070 Parameters:
3071 \end_layout
3073 \begin_layout Itemize
3074 data: string: The image data
3075 \end_layout
3077 \begin_layout Standard
3078 Returns:
3079 \end_layout
3081 \begin_layout Itemize
3082 bitmap: BITMAP/DBITMAP: The new bitmap
3083 \end_layout
3085 \begin_layout Itemize
3086 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3087  nil.
3088 \end_layout
3090 \begin_layout Standard
3091 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3092  file.
3093 \end_layout
3095 \begin_layout Subsubsection
3096 Static function load_png: Load a bitmap from PNG file
3097 \end_layout
3099 \begin_layout Itemize
3100 Syntax: bitmap, palette gui.image.load_png(file, [base])
3101 \end_layout
3103 \begin_layout Itemize
3104 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3105 \end_layout
3107 \begin_layout Itemize
3108 Deprecated: ...
3109  gui.bitmap_load_png(...)
3110 \end_layout
3112 \begin_layout Standard
3113 Parameters:
3114 \end_layout
3116 \begin_layout Itemize
3117 file: string: The file to read.
3118 \end_layout
3120 \begin_layout Itemize
3121 base: string: The base to resolve <file> relative to.
3122 \end_layout
3124 \begin_layout Standard
3125 Returns:
3126 \end_layout
3128 \begin_layout Itemize
3129 bitmap: BITMAP/DBITMAP: The new bitmap
3130 \end_layout
3132 \begin_layout Itemize
3133 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3134  nil.
3135 \end_layout
3137 \begin_layout Standard
3138 Like IMAGELOADER:load, but load a PNG file instead.
3139 \end_layout
3141 \begin_layout Subsubsection
3142 Static function load_png_str: Load a PNG bitmap from string
3143 \end_layout
3145 \begin_layout Itemize
3146 Syntax: bitmap, palette gui.image.load_png_str(data)
3147 \end_layout
3149 \begin_layout Itemize
3150 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3151 \end_layout
3153 \begin_layout Itemize
3154 Deprecated: ...
3155  gui.bitmap_load_png_str(...)
3156 \end_layout
3158 \begin_layout Standard
3159 Parameters:
3160 \end_layout
3162 \begin_layout Itemize
3163 data: string: The image data, base64 encoded.
3164 \end_layout
3166 \begin_layout Standard
3167 Returns:
3168 \end_layout
3170 \begin_layout Itemize
3171 bitmap: BITMAP/DBITMAP: The new bitmap
3172 \end_layout
3174 \begin_layout Itemize
3175 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3176  nil.
3177 \end_layout
3179 \begin_layout Standard
3180 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3181  <data> instead of file.
3182 \end_layout
3184 \begin_layout Standard
3185 \begin_inset Newpage pagebreak
3186 \end_inset
3189 \end_layout
3191 \begin_layout Subsection
3192 CUSTOMFONT: Arbitrary-sized bitmap font
3193 \end_layout
3195 \begin_layout Subsubsection
3196 Static function new: Return a new empty font
3197 \end_layout
3199 \begin_layout Itemize
3200 Syntax: font gui.font.new()
3201 \end_layout
3203 \begin_layout Itemize
3204 Syntax: font classes.CUSTOMFONT.new()
3205 \end_layout
3207 \begin_layout Itemize
3208 Deprecated: font gui.font_new()
3209 \end_layout
3211 \begin_layout Standard
3212 Return value:
3213 \end_layout
3215 \begin_layout Itemize
3216 font: CUSTOMFONT: New font.
3217 \end_layout
3219 \begin_layout Standard
3220 Create a new font with no characters and return it.
3221 \end_layout
3223 \begin_layout Subsubsection
3224 Static function: load: Load a font file
3225 \end_layout
3227 \begin_layout Itemize
3228 Syntax: font gui.font.load(file, [base])
3229 \end_layout
3231 \begin_layout Itemize
3232 Syntax: font gui.font.load()
3233 \end_layout
3235 \begin_layout Itemize
3236 Syntax: font classes.CUSTOMFONT.load(file, [base])
3237 \end_layout
3239 \begin_layout Itemize
3240 Syntax: font classes.CUSTOMFONT.load()
3241 \end_layout
3243 \begin_layout Itemize
3244 Deprecated: font gui.loadfont(...)
3245 \end_layout
3247 \begin_layout Standard
3248 Parameters:
3249 \end_layout
3251 \begin_layout Itemize
3252 file: string: The file to read the font from
3253 \end_layout
3255 \begin_layout Itemize
3256 base: string: The file to resolve <file> relative to.
3257 \end_layout
3259 \begin_layout Standard
3260 Return value:
3261 \end_layout
3263 \begin_layout Itemize
3264 font: CUSTOMFONT: New font.
3265 \end_layout
3267 \begin_layout Standard
3268 Load font from file <file> (relative to <base>).
3269  If no filename is given, system default font is loaded.
3270 \end_layout
3272 \begin_layout Subsubsection
3273 operator(): Render text to screen
3274 \end_layout
3276 \begin_layout Itemize
3277 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3278 \end_layout
3280 \begin_layout Standard
3281 Parmeters:
3282 \end_layout
3284 \begin_layout Itemize
3285 font: CUSTOMFONT: The font to use.
3286 \end_layout
3288 \begin_layout Itemize
3289 x: number: The x-position on screen to draw to.
3290 \end_layout
3292 \begin_layout Itemize
3293 y: number: The y-position on screen to draw to.
3294 \end_layout
3296 \begin_layout Itemize
3297 text: string: The text to draw.
3298 \end_layout
3300 \begin_layout Itemize
3301 fgc: number/string: Foreground color (default white).
3302 \end_layout
3304 \begin_layout Itemize
3305 bgc: number/string: Background color (default transparent).
3306 \end_layout
3308 \begin_layout Itemize
3309 hlc: number/string: Outline color (default transparent).
3310 \end_layout
3312 \begin_layout Standard
3313 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3314  onto screen.
3315 \end_layout
3317 \begin_layout Itemize
3318 If <hlc> is transparent, no outline is drawn.
3319 \end_layout
3321 \begin_layout Subsubsection
3322 Method edit: Alter glyph in font
3323 \end_layout
3325 \begin_layout Itemize
3326 Syntax: font:edit(character, glyph)
3327 \end_layout
3329 \begin_layout Standard
3330 Parameters:
3331 \end_layout
3333 \begin_layout Itemize
3334 font: CUSTOMFONT: The font to edit.
3335 \end_layout
3337 \begin_layout Itemize
3338 character: string: The character to edit (UTF-8 encoded).
3339 \end_layout
3341 \begin_layout Itemize
3342 glyph: BITMAP: The bitmap to use.
3343 \end_layout
3345 \begin_layout Standard
3346 Replace character <character> in font <font> by <glyph>.
3347 \end_layout
3349 \begin_layout Itemize
3350 Color index 0 is background, everything else is foreground.
3351 \end_layout
3353 \begin_layout Itemize
3354 <character> may be empty string, meaning the replacement character used
3355  for bad characters.
3356 \end_layout
3358 \begin_layout Itemize
3359 <character> may be multi-codepoint string, meaning character used for that
3360  ligature.
3361 \end_layout
3363 \begin_layout Standard
3364 \begin_inset Newpage pagebreak
3365 \end_inset
3368 \end_layout
3370 \begin_layout Subsection
3371 ICONV: Character set conversions
3372 \end_layout
3374 \begin_layout Subsubsection
3375 Static function new: Create new character set converter
3376 \end_layout
3378 \begin_layout Itemize
3379 Syntax: iconv iconv.new(from, to);
3380 \end_layout
3382 \begin_layout Itemize
3383 Syntax: iconv classes.ICONV.new(from, to);
3384 \end_layout
3386 \begin_layout Itemize
3387 Deprecated: iconv iconv_new(...);
3388 \end_layout
3390 \begin_layout Standard
3391 Parameters:
3392 \end_layout
3394 \begin_layout Itemize
3395 from: string: The source character set.
3396 \end_layout
3398 \begin_layout Itemize
3399 to: string: The target character set.
3400 \end_layout
3402 \begin_layout Standard
3403 Returns:
3404 \end_layout
3406 \begin_layout Itemize
3407 iconv: ICONV: The converter.
3408 \end_layout
3410 \begin_layout Standard
3411 Create a character set converter, converting from <from> to <to> and return
3412  it.
3413 \end_layout
3415 \begin_layout Subsubsection
3416 Operator(): Convert string fragment from character set to another
3417 \end_layout
3419 \begin_layout Itemize
3420 Syntax: success, result, unconverted, error iconv(input)
3421 \end_layout
3423 \begin_layout Standard
3424 Parameters:
3425 \end_layout
3427 \begin_layout Itemize
3428 iconv: ICONV: The context to use.
3429 \end_layout
3431 \begin_layout Itemize
3432 input: string: The input to convert.
3433 \end_layout
3435 \begin_layout Standard
3436 Return value:
3437 \end_layout
3439 \begin_layout Itemize
3440 success: boolean: True if conversion was successful, false if not.
3441 \end_layout
3443 \begin_layout Itemize
3444 result: string: The string (partially) converted.
3445 \end_layout
3447 \begin_layout Itemize
3448 unconvered: number: Number of bytes that were not converted (only if <success>
3449  is false).
3450 \end_layout
3452 \begin_layout Itemize
3453 error: string: Error that caused conversion to stop (only if <success> is
3454  false).
3455 \end_layout
3457 \begin_deeper
3458 \begin_layout Itemize
3459 INVALID: The input string is invalid.
3460 \end_layout
3462 \begin_layout Itemize
3463 INCOMPLETE: The input string cuts off in middle of character.
3464 \end_layout
3466 \begin_layout Itemize
3467 INTERNALERR: Internal error.
3468 \end_layout
3470 \end_deeper
3471 \begin_layout Standard
3472 Convert a string <input> using character set converter <iconv> and return
3473  the result.
3474 \end_layout
3476 \begin_layout Standard
3477 \begin_inset Newpage pagebreak
3478 \end_inset
3481 \end_layout
3483 \begin_layout Subsection
3484 FILEREADER: Read a file as a stream
3485 \end_layout
3487 \begin_layout Subsubsection
3488 Static function open: Open a stream
3489 \end_layout
3491 \begin_layout Itemize
3492 Syntax: handle filereader.open(file, [base])
3493 \end_layout
3495 \begin_layout Itemize
3496 Syntax: handle classes.FILEREADER.open(file, [base])
3497 \end_layout
3499 \begin_layout Itemize
3500 Deprecated: handle open_file(file, [base])
3501 \end_layout
3503 \begin_layout Standard
3504 Parameters:
3505 \end_layout
3507 \begin_layout Itemize
3508 file: string: The filename to read.
3509 \end_layout
3511 \begin_layout Itemize
3512 base: string: The base <file> is resolved against.
3513 \end_layout
3515 \begin_layout Standard
3516 Returns:
3517 \end_layout
3519 \begin_layout Itemize
3520 handle: FILEREADER: The new file reader.
3521 \end_layout
3523 \begin_layout Standard
3524 Open file <file> (relative to <base>) and return a handle to it.
3525 \end_layout
3527 \begin_layout Subsubsection
3528 operator(): Read line/bytes from stream
3529 \end_layout
3531 \begin_layout Itemize
3532 Syntax: result handle()
3533 \end_layout
3535 \begin_layout Itemize
3536 Syntax: result handle(bytes)
3537 \end_layout
3539 \begin_layout Standard
3540 Parameters:
3541 \end_layout
3543 \begin_layout Itemize
3544 handle: FILEREADER: The handle to read from.
3545 \end_layout
3547 \begin_layout Itemize
3548 bytes: Number of bytes to read (default is next line).
3549 \end_layout
3551 \begin_layout Standard
3552 Returns:
3553 \end_layout
3555 \begin_layout Itemize
3556 result: string: The read data, or nil on end-of-file.
3557 \end_layout
3559 \begin_layout Standard
3560 Reads next line or <bytes> bytes from specified file handle <handle>.
3561 \end_layout
3563 \begin_layout Itemize
3564 If reading specified number of bytes, the bytes are read in binary mode
3565  (as-is).
3566 \end_layout
3568 \begin_layout Itemize
3569 If reading next line, the line is read in text mode (any line ending is
3570  skpped).
3571 \end_layout
3573 \begin_layout Subsubsection
3574 Method lines: Iterator to read all lines
3575 \end_layout
3577 \begin_layout Itemize
3578 Syntax: for line in handle:lines() do ...
3579  end
3580 \end_layout
3582 \begin_layout Standard
3583 Parameters:
3584 \end_layout
3586 \begin_layout Itemize
3587 handle: FILEREADER: The handle to read.
3588 \end_layout
3590 \begin_layout Standard
3591 Returns:
3592 \end_layout
3594 \begin_layout Itemize
3595 A lua iterator with one variable.
3596 \end_layout
3598 \begin_layout Standard
3599 Return a Lua iterator that iterates all the lines in <handle>.
3600 \end_layout
3602 \begin_layout Standard
3603 \begin_inset Newpage pagebreak
3604 \end_inset
3607 \end_layout
3609 \begin_layout Subsection
3610 COMPARE_OBJ: Watch memory area for changes
3611 \end_layout
3613 \begin_layout Standard
3614 Objects of this class allow fast checking for modifications to given memory
3615  block.
3616 \end_layout
3618 \begin_layout Subsubsection
3619 Static function new: Create a checker
3620 \end_layout
3622 \begin_layout Itemize
3623 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3624  stride])
3625 \end_layout
3627 \begin_layout Itemize
3628 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3629 \end_layout
3631 \begin_layout Standard
3632 Parameters:
3633 \end_layout
3635 \begin_layout Itemize
3636 marea: string: The memory area to interpret <offset> against.
3637 \end_layout
3639 \begin_layout Itemize
3640 offset: number: The initial offset in memory area.
3641 \end_layout
3643 \begin_layout Itemize
3644 addrobj: ADDRESS: The memory address.
3645 \end_layout
3647 \begin_layout Itemize
3648 size: number: The number of bytes in each row.
3649 \end_layout
3651 \begin_layout Itemize
3652 rows: number: The number of rows.
3653  Default is 1.
3654 \end_layout
3656 \begin_layout Itemize
3657 stride: number: The number of bytes offset increments from one row to next.
3658 \end_layout
3660 \begin_layout Standard
3661 Returns:
3662 \end_layout
3664 \begin_layout Itemize
3665 A handle to object.
3666 \end_layout
3668 \begin_layout Standard
3669 Return an object watching specified memory area.
3670 \end_layout
3672 \begin_layout Itemize
3673 Note: For fastest operation, limit checks to inside one memory area (that
3674  has to be mappable, individual RAM areas often are).
3675 \end_layout
3677 \begin_layout Subsubsection
3678 operator(): Check area for modifications
3679 \end_layout
3681 \begin_layout Itemize
3682 Syntax: boolean handle()
3683 \end_layout
3685 \begin_layout Standard
3686 Returns:
3687 \end_layout
3689 \begin_layout Itemize
3690 True if memory block has been modified since last call (or object creation
3691  if first call), false if not.
3692 \end_layout
3694 \begin_layout Standard
3695 Check if the block has been modified.
3696 \end_layout
3698 \begin_layout Subsection
3699 ADDRESS: Memory address
3700 \end_layout
3702 \begin_layout Standard
3703 Objects of this class contain a memory address.
3704 \end_layout
3706 \begin_layout Subsubsection
3707 Static function new: Create new memory address
3708 \end_layout
3710 \begin_layout Itemize
3711 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
3712 \end_layout
3714 \begin_layout Itemize
3715 Syntax: ADDRESS memory.address.new(string marea, number offset)
3716 \end_layout
3718 \begin_layout Itemize
3719 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
3720 \end_layout
3722 \begin_layout Standard
3723 Parameters:
3724 \end_layout
3726 \begin_layout Itemize
3727 marea: The memory area
3728 \end_layout
3730 \begin_layout Itemize
3731 offset: The offset in memory area.
3732 \end_layout
3734 \begin_layout Standard
3735 Returns:
3736 \end_layout
3738 \begin_layout Itemize
3739 The memory area.
3740 \end_layout
3742 \begin_layout Standard
3743 Construct a new memory address object.
3744 \end_layout
3746 \begin_layout Subsubsection
3747 Method: addr: Get global address
3748 \end_layout
3750 \begin_layout Itemize
3751 Syntax: number addr:addr()
3752 \end_layout
3754 \begin_layout Standard
3755 Parameters:
3756 \end_layout
3758 \begin_layout Itemize
3759 addr: ADRESS: The original address.
3760 \end_layout
3762 \begin_layout Standard
3763 Returns:
3764 \end_layout
3766 \begin_layout Itemize
3767 The global address corresponding to this address.
3768 \end_layout
3770 \begin_layout Subsubsection
3771 Method: vma: Get memory area
3772 \end_layout
3774 \begin_layout Itemize
3775 Syntax: string addr:vma()
3776 \end_layout
3778 \begin_layout Standard
3779 Parameters:
3780 \end_layout
3782 \begin_layout Itemize
3783 addr: ADRESS: The original address.
3784 \end_layout
3786 \begin_layout Standard
3787 Returns:
3788 \end_layout
3790 \begin_layout Itemize
3791 The memory area corresponding to this address.
3792 \end_layout
3794 \begin_layout Subsubsection
3795 Method: offset: Get memory area offset
3796 \end_layout
3798 \begin_layout Itemize
3799 Syntax: string addr:offset()
3800 \end_layout
3802 \begin_layout Standard
3803 Parameters:
3804 \end_layout
3806 \begin_layout Itemize
3807 addr: ADRESS: The original address.
3808 \end_layout
3810 \begin_layout Standard
3811 Returns:
3812 \end_layout
3814 \begin_layout Itemize
3815 The offset in memory area corresponding to this address.
3816 \end_layout
3818 \begin_layout Subsubsection
3819 Method: replace: Replace address part
3820 \end_layout
3822 \begin_layout Itemize
3823 Syntax: ADDRESS addr:replace(offset[, bits])
3824 \end_layout
3826 \begin_layout Standard
3827 Parameters:
3828 \end_layout
3830 \begin_layout Itemize
3831 addr: ADRESS: The original address.
3832 \end_layout
3834 \begin_layout Itemize
3835 offset: number: The new offset
3836 \end_layout
3838 \begin_layout Itemize
3839 bits: number: The number of LSB to replace.
3840 \end_layout
3842 \begin_layout Standard
3843 Returns:
3844 \end_layout
3846 \begin_layout Itemize
3847 The modified address
3848 \end_layout
3850 \begin_layout Standard
3851 Returns a new address, with <bits> (all if missing) least significant bits
3852  of <addr> replaced by LSB of <offset>.
3853 \end_layout
3855 \begin_layout Subsubsection
3856 Method: add: Add to address
3857 \end_layout
3859 \begin_layout Itemize
3860 Syntax: ADDRESS addr:add(offset)
3861 \end_layout
3863 \begin_layout Itemize
3864 Syntax: ADDRESS addr:add(number, stride)
3865 \end_layout
3867 \begin_layout Itemize
3868 Syntax: ADDRESS addr:add(number, stride, offset)
3869 \end_layout
3871 \begin_layout Standard
3872 Parameters:
3873 \end_layout
3875 \begin_layout Itemize
3876 addr: ADRESS: The original address.
3877 \end_layout
3879 \begin_layout Itemize
3880 offset: number: Offset to add.
3881 \end_layout
3883 \begin_layout Itemize
3884 number: number: Number of table strides to add.
3885 \end_layout
3887 \begin_layout Itemize
3888 stride: number: The table stride.
3889 \end_layout
3891 \begin_layout Standard
3892 Returns:
3893 \end_layout
3895 \begin_layout Itemize
3896 The modified address
3897 \end_layout
3899 \begin_layout Standard
3900 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
3901  address <addr>.
3902 \end_layout
3904 \begin_layout Subsection
3905 ADDRESS:<op>: Read/Write memory
3906 \end_layout
3908 \begin_layout Itemize
3909 Syntax: none addr:<op>(value)
3910 \end_layout
3912 \begin_layout Itemize
3913 Syntax: number addr:<op>()
3914 \end_layout
3916 \begin_layout Standard
3917 Parameters:
3918 \end_layout
3920 \begin_layout Itemize
3921 addr: ADDRESS: The address to read/write.
3922 \end_layout
3924 \begin_layout Itemize
3925 value: number: The number to write.
3926 \end_layout
3928 \begin_layout Standard
3929 Returns:
3930 \end_layout
3932 \begin_layout Itemize
3933 The value read.
3934 \end_layout
3936 \begin_layout Standard
3937 Read/Write value from/to given address <addr>.
3938  The value written is <value>.
3939  <Op> is of form: [i][s]<type>, where:
3940 \end_layout
3942 \begin_layout Itemize
3943 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
3944 \end_layout
3946 \begin_layout Itemize
3947 'i' signifies that the value is treated as opposite-to-normal endianess,
3948 \end_layout
3950 \begin_layout Itemize
3951 's' signifies that value is treated as signed (not available for floating-point).
3952 \end_layout
3954 \begin_layout Standard
3955 \begin_inset Newpage pagebreak
3956 \end_inset
3959 \end_layout
3961 \begin_layout Section
3962 Global
3963 \end_layout
3965 \begin_layout Subsection
3966 print: Print values to console
3967 \end_layout
3969 \begin_layout Itemize
3970 Syntax: none print(value...
3971  values)
3972 \end_layout
3974 \begin_layout Standard
3975 Prints specified values to console.
3976  Can print any Lua type at least enough to identify the type and instance.
3977 \end_layout
3979 \begin_layout Subsection
3980 tostringx: Format a value to string
3981 \end_layout
3983 \begin_layout Itemize
3984 Syntax: string tostringx(value val)
3985 \end_layout
3987 \begin_layout Standard
3988 Formats value <val> like print would, and returns the result as a string.
3989 \end_layout
3991 \begin_layout Subsection
3992 exec: Execute lsnes commands
3993 \end_layout
3995 \begin_layout Itemize
3996 Syntax: none exec(string cmd)
3997 \end_layout
3999 \begin_layout Standard
4000 Execute lsnes command <cmd>.
4001 \end_layout
4003 \begin_layout Subsection
4004 utime: Get current time
4005 \end_layout
4007 \begin_layout Itemize
4008 Syntax: (number,number) utime()
4009 \end_layout
4011 \begin_layout Standard
4012 Returns two numbers.
4013  First is time since some epoch in seconds, the second is microseconds mod
4014  10^6 since that epoch.
4015 \end_layout
4017 \begin_layout Subsection
4018 set_idle_timeout: Run function after timeout when emulator is idle
4019 \end_layout
4021 \begin_layout Itemize
4022 Syntax: none set_idle_timeout(number timeout)
4023 \end_layout
4025 \begin_layout Standard
4026 Set number of microseconds to block idle for.
4027  After this timeout has expired, on_idle() will be called once.
4028 \end_layout
4030 \begin_layout Subsection
4031 set_timer_timeout: Run function after timeout.
4032 \end_layout
4034 \begin_layout Itemize
4035 Syntax: none set_timer_timeout(number timeout)
4036 \end_layout
4038 \begin_layout Standard
4039 Set number of microseconds to block timer for.
4040  After this timeout has expired, on_timer() will be called once.
4041 \end_layout
4043 \begin_layout Subsection
4044 bus_address: Look up address in system bus.
4045 \end_layout
4047 \begin_layout Itemize
4048 Syntax: none bus_address(number bus_addr)
4049 \end_layout
4051 \begin_layout Standard
4052 Returns virtual address corresponding to specified address on system bus.
4053 \end_layout
4055 \begin_layout Subsection
4056 loopwrapper: Convert loop into callable function
4057 \end_layout
4059 \begin_layout Itemize
4060 Syntax: function loopwrapper(function fun, ...)
4061 \end_layout
4063 \begin_layout Standard
4064 Calls function <fun> with function and specified arguments.
4065  The function passed suspends execution until the function returned is called.
4066  Handy for linear flow control among multiple invocations of a hook.
4067  Example code:
4068 \end_layout
4070 \begin_layout LyX-Code
4071 on_paint = loopwrapper(function(wait)
4072 \end_layout
4074 \begin_deeper
4075 \begin_layout LyX-Code
4076 while true do
4077 \end_layout
4079 \begin_deeper
4080 \begin_layout LyX-Code
4081 gui.text(0, 0, 
4082 \begin_inset Quotes eld
4083 \end_inset
4085 Test!
4086 \begin_inset Quotes erd
4087 \end_inset
4090 \end_layout
4092 \begin_layout LyX-Code
4093 wait();
4094 \end_layout
4096 \end_deeper
4097 \begin_layout LyX-Code
4099 \end_layout
4101 \end_deeper
4102 \begin_layout LyX-Code
4103 end);
4104 \end_layout
4106 \begin_layout Subsection
4107 list_bindings: List keybindings
4108 \end_layout
4110 \begin_layout Itemize
4111 Syntax: table list_bindings([string cmd])
4112 \end_layout
4114 \begin_layout Standard
4115 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4116  If <cmd> is specified, the table is limited to that command.
4117  Also searches for controller keys.
4118 \end_layout
4120 \begin_layout Subsection
4121 get_alias: Get expansion of alias
4122 \end_layout
4124 \begin_layout Itemize
4125 Syntax: string get_alias(string aname)
4126 \end_layout
4128 \begin_layout Standard
4129 Get expansion of given alias <aname>.
4130 \end_layout
4132 \begin_layout Subsection
4133 set_alias: Set expansion of alias
4134 \end_layout
4136 \begin_layout Itemize
4137 Syntax: none set_alias(string aname, string value)
4138 \end_layout
4140 \begin_layout Standard
4141 Set expansion of given alias.
4142 \end_layout
4144 \begin_layout Subsection
4145 create_ibind: Create invese binding
4146 \end_layout
4148 \begin_layout Itemize
4149 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4150 \end_layout
4152 \begin_layout Standard
4153 Return object representing inverse binding with specified name <name> and
4154  specified command <cmd>.
4155 \end_layout
4157 \begin_layout Itemize
4158 Note: To create press/release commands, use aliases +foo and -foo .
4159 \end_layout
4161 \begin_layout Itemize
4162 Note: Keep the returned object around.
4163 \end_layout
4165 \begin_layout Subsection
4166 create_command: Create a command
4167 \end_layout
4169 \begin_layout Itemize
4170 Syntax: COMMANDBIND create_commmand(string name, function a)
4171 \end_layout
4173 \begin_layout Itemize
4174 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
4175 \end_layout
4177 \begin_layout Standard
4178 Return object representing a command (pair).
4179 \end_layout
4181 \begin_layout Itemize
4182 If only one function is specied, the command is level-sensitive, <a> is
4183  callback.
4184 \end_layout
4186 \begin_layout Itemize
4187 If <b> is function, the function is edge-sensitive, <a> is positive edge
4188  callback and <b> is negative edge callback.
4189 \end_layout
4191 \begin_layout Itemize
4192 All callbacks get single argument: The parameters passed.
4193 \end_layout
4195 \begin_layout Itemize
4196 Keep the returned object around.
4197 \end_layout
4199 \begin_layout Subsection
4200 loadfile: Load Lua script
4201 \end_layout
4203 \begin_layout Itemize
4204 Syntax: function loadfile(string filename[, string base])
4205 \end_layout
4207 \begin_layout Standard
4208 Load lua script from <filename>, resolved relative to <base> (if empty,
4209  current directory).
4210 \end_layout
4212 \begin_layout Subsection
4213 dofile: Execute Lua script
4214 \end_layout
4216 \begin_layout Itemize
4217 Syntax: function dofile(string filename[, string base])
4218 \end_layout
4220 \begin_layout Standard
4221 Execute lua script from <filename>, resolved relative to <base> (if empty,
4222  current directory) and return all return values.
4223 \end_layout
4225 \begin_layout Subsection
4226 resolve_filename: Resolve name of file relative to another
4227 \end_layout
4229 \begin_layout Itemize
4230 Syntax: string resolve_file(string filename, string base)
4231 \end_layout
4233 \begin_layout Standard
4234 Resolve name of file <filename> relative to <base> and return the result.
4235 \end_layout
4237 \begin_layout Subsection
4238 render_queue_function: Return paint function for render queue
4239 \end_layout
4241 \begin_layout Itemize
4242 Syntax: function render_queue_function(RENDERQUEUE rq)
4243 \end_layout
4245 \begin_layout Standard
4246 Return function that renders render queue <rq>.
4247 \end_layout
4249 \begin_layout Itemize
4250 Handy for paint callback if one is using render queues updated in other
4251  callbacks.
4252  As in:
4253 \end_layout
4255 \begin_layout LyX-Code
4256 handle = callback.paint:register(render_queue_function(my_rq));
4257 \end_layout
4259 \begin_layout Subsection
4260 identify_class: Identify class of object
4261 \end_layout
4263 \begin_layout Itemize
4264 Syntax: string identify_class(userdata object)
4265 \end_layout
4267 \begin_layout Standard
4268 Identifies the class of userdata <object>, if possible.
4269  If no identification is possible, returns 
4270 \begin_inset Quotes eld
4271 \end_inset
4273 unknown
4274 \begin_inset Quotes erd
4275 \end_inset
4278 \end_layout
4280 \begin_layout Subsection
4281 lookup_class: Lookup class by name
4282 \end_layout
4284 \begin_layout Itemize
4285 Syntax: classobj lookup_class(string name)
4286 \end_layout
4288 \begin_layout Standard
4289 Looks up class corresponding to <name>, if possible.
4290  If not found, returns nil.
4291  The classobj has following fields:
4292 \end_layout
4294 \begin_layout Itemize
4295 _static_methods: Return static method names
4296 \end_layout
4298 \begin_layout Itemize
4299 _class_methods: Return class method names
4300 \end_layout
4302 \begin_layout Itemize
4303 <static-function-name>: The specified static function.
4304 \end_layout
4306 \begin_layout Subsection
4307 all_classes: Get list of all classes
4308 \end_layout
4310 \begin_layout Itemize
4311 Syntax: string...
4312  all_classes()
4313 \end_layout
4315 \begin_layout Standard
4316 Get names of all classes available.
4317 \end_layout
4319 \begin_layout Subsection
4321 \end_layout
4323 \begin_layout Subsection
4324 icnov: Class ICONV
4325 \end_layout
4327 \begin_layout Standard
4328 See class ICONV.
4329 \end_layout
4331 \begin_layout Subsection
4332 filereader: Class FILEREADER
4333 \end_layout
4335 \begin_layout Standard
4336 See class FILEREADER.
4337 \end_layout
4339 \begin_layout Standard
4340 \begin_inset Newpage pagebreak
4341 \end_inset
4344 \end_layout
4346 \begin_layout Section
4347 Table bit:
4348 \end_layout
4350 \begin_layout Standard
4351 Bitwise logical functions and related.
4352 \end_layout
4354 \begin_layout Subsection
4355 bit.none/bit.bnot: Bitwise none or NOT function
4356 \end_layout
4358 \begin_layout Itemize
4359 Syntax: number bit.none(number...)
4360 \end_layout
4362 \begin_layout Itemize
4363 Syntax: number bit.bnot(number...)
4364 \end_layout
4366 \begin_layout Standard
4367 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4368  arguments).
4369 \end_layout
4371 \begin_layout Subsection
4372 bit.any/bit.bor: Bitwise any or OR function
4373 \end_layout
4375 \begin_layout Itemize
4376 Syntax: number bit.any(number...)
4377 \end_layout
4379 \begin_layout Itemize
4380 Syntax: number bit.bor(number...)
4381 \end_layout
4383 \begin_layout Standard
4384 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4385 \end_layout
4387 \begin_layout Subsection
4388 bit.all/bit.band: Bitwise all or AND function
4389 \end_layout
4391 \begin_layout Itemize
4392 Syntax: number bit.all(number...)
4393 \end_layout
4395 \begin_layout Itemize
4396 Syntax: number bit.band(number...)
4397 \end_layout
4399 \begin_layout Standard
4400 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4402 \end_layout
4404 \begin_layout Subsection
4405 bit.parity/bit.bxor: Bitwise parity or XOR function
4406 \end_layout
4408 \begin_layout Itemize
4409 Syntax: number bit.parity(number...)
4410 \end_layout
4412 \begin_layout Itemize
4413 Syntax: number bit.bxor(number...)
4414 \end_layout
4416 \begin_layout Standard
4417 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4418  of the arguments).
4419 \end_layout
4421 \begin_layout Subsection
4422 bit.lrotate: Rotate a number left
4423 \end_layout
4425 \begin_layout Itemize
4426 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4427 \end_layout
4429 \begin_layout Standard
4430 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4431  1) places.
4432 \end_layout
4434 \begin_layout Subsection
4435 bit.rrotate: Rotate a number right
4436 \end_layout
4438 \begin_layout Itemize
4439 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4440 \end_layout
4442 \begin_layout Standard
4443 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4444  1) places.
4445 \end_layout
4447 \begin_layout Subsection
4448 bit.lshift: Shift a number left
4449 \end_layout
4451 \begin_layout Itemize
4452 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4453 \end_layout
4455 \begin_layout Standard
4456 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4457  1) places.
4458  The new bits are filled with zeroes.
4459 \end_layout
4461 \begin_layout Subsection
4462 bit.lrshift: Shift a number right (logical)
4463 \end_layout
4465 \begin_layout Itemize
4466 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4467 \end_layout
4469 \begin_layout Standard
4470 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4471  (default 1) places.
4472  The new bits are filled with zeroes.
4473 \end_layout
4475 \begin_layout Subsection
4476 bit.arshift: Shift a number right (arithmetic)
4477 \end_layout
4479 \begin_layout Itemize
4480 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4481 \end_layout
4483 \begin_layout Standard
4484 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4485  (default 1) places.
4486  The new bits are shifted in with copy of the high bit.
4487 \end_layout
4489 \begin_layout Subsection
4490 bit.extract: Extract/shuffle bits from number
4491 \end_layout
4493 \begin_layout Itemize
4494 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4495 \end_layout
4497 \begin_layout Standard
4498 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4499 \end_layout
4501 \begin_layout Itemize
4502 Note: Bit numbers up to 51 should work reliably (then things start falling
4503  apart due to double precision issues).
4504 \end_layout
4506 \begin_layout Itemize
4507 Note: There are two special bit positions, true and false, standing for
4508  always set bit and always clear bit.
4509 \end_layout
4511 \begin_layout Subsection
4512 bit.value: Construct number with specified bits set
4513 \end_layout
4515 \begin_layout Itemize
4516 Syntax: number bit.value([number bit1[, number bit2,...]])
4517 \end_layout
4519 \begin_layout Standard
4520 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4521  <bit2> places and so on.
4522  As special value, nil argument is no-op.
4523 \end_layout
4525 \begin_layout Subsection
4526 bit.test: Test if bit is set
4527 \end_layout
4529 \begin_layout Itemize
4530 Syntax: boolean bit.test(number a, number bit)
4531 \end_layout
4533 \begin_layout Standard
4534 Tests if bit <bit> is set in <a>.
4535  If it is set, returns true, otherwise false.
4536 \end_layout
4538 \begin_layout Subsection
4539 bit.testn: Test if bit is clear
4540 \end_layout
4542 \begin_layout Itemize
4543 Syntax: boolean bit.testn(number a, number bit)
4544 \end_layout
4546 \begin_layout Standard
4547 Tests if bit <bit> is set in <a>.
4548  If it is clear, returns true, otherwise false.
4549 \end_layout
4551 \begin_layout Subsection
4552 bit.test_any: Test if any bit is set
4553 \end_layout
4555 \begin_layout Itemize
4556 Syntax: boolean bit.test_any(number a, number b)
4557 \end_layout
4559 \begin_layout Standard
4560 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4561 \end_layout
4563 \begin_layout Subsection
4564 bit.test_all: Test if all bits are set
4565 \end_layout
4567 \begin_layout Itemize
4568 Syntax: boolean bit.test_all(number a, number b)
4569 \end_layout
4571 \begin_layout Standard
4572 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4573 \end_layout
4575 \begin_layout Subsection
4576 bit.popcount: Population count
4577 \end_layout
4579 \begin_layout Itemize
4580 Syntax: number bit.popcount(number a)
4581 \end_layout
4583 \begin_layout Standard
4584 Returns number of set bits in <a>.
4585 \end_layout
4587 \begin_layout Subsection
4588 bit.clshift: Chained left shift
4589 \end_layout
4591 \begin_layout Itemize
4592 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4593  bits]])
4594 \end_layout
4596 \begin_layout Standard
4597 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4598  numbers to be of specified number of bits <bits> (default 48).
4599 \end_layout
4601 \begin_layout Subsection
4602 bit.crshift: Chained right shift
4603 \end_layout
4605 \begin_layout Itemize
4606 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4607  bits]])
4608 \end_layout
4610 \begin_layout Standard
4611 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4612  assuming numbers to be of specified number of bits <bits> (default 48).
4613 \end_layout
4615 \begin_layout Subsection
4616 bit.flagdecode: Decode bitfield into flags
4617 \end_layout
4619 \begin_layout Itemize
4620 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4621  off]])
4622 \end_layout
4624 \begin_layout Standard
4625 Return string of length bits where ith character is ith character of on
4626  if bit i is on, otherwise ith character of off.
4627  Out of range reads give last character.
4628 \end_layout
4630 \begin_layout Itemize
4631 Note: <on> defaults to '*' if empty.
4632 \end_layout
4634 \begin_layout Itemize
4635 Note: <off> defaults to '-' if empty.
4636 \end_layout
4638 \begin_layout Subsection
4639 bit.rflagdecode: Decode bitfield into flags
4640 \end_layout
4642 \begin_layout Itemize
4643 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4644  off]])
4645 \end_layout
4647 \begin_layout Standard
4648 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4649 nt bit first).
4650 \end_layout
4652 \begin_layout Subsection
4653 bit.swap{,s}{,h,d,q}word: Swap word endian
4654 \end_layout
4656 \begin_layout Itemize
4657 Syntax: number bit.swapword(number n)
4658 \end_layout
4660 \begin_layout Itemize
4661 Syntax: number bit.swaphword(number n)
4662 \end_layout
4664 \begin_layout Itemize
4665 Syntax: number bit.swapdword(number n)
4666 \end_layout
4668 \begin_layout Itemize
4669 Syntax: number bit.swapqword(number n)
4670 \end_layout
4672 \begin_layout Itemize
4673 Syntax: number bit.swapsword(number n)
4674 \end_layout
4676 \begin_layout Itemize
4677 Syntax: number bit.swapshword(number n)
4678 \end_layout
4680 \begin_layout Itemize
4681 Syntax: number bit.swapsdword(number n)
4682 \end_layout
4684 \begin_layout Itemize
4685 Syntax: number bit.swapsqword(number n)
4686 \end_layout
4688 \begin_layout Standard
4689 Swap endianess of (un)signed integer <n>.
4690 \end_layout
4692 \begin_layout Subsection
4693 bit.compose: Compose multi-byte number
4694 \end_layout
4696 \begin_layout Itemize
4697 Syntax: number bit.compose(number n...)
4698 \end_layout
4700 \begin_layout Standard
4701 Return 
4702 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4703 \end_inset
4706 \end_layout
4708 \begin_layout Subsection
4709 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4710 \end_layout
4712 \begin_layout Itemize
4713 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4714 \end_layout
4716 \begin_layout Itemize
4717 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4718 \end_layout
4720 \begin_layout Standard
4721 Load little (*le) or big (*be) endian binary number from position <pos>
4722  of string <str>.
4723  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4724  double.
4725 \end_layout
4727 \begin_layout Subsection
4728 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4729 \end_layout
4731 \begin_layout Itemize
4732 Syntax: string bit.binary_st_<type>le(number x);
4733 \end_layout
4735 \begin_layout Itemize
4736 Syntax: string bit.binary_st_<type>be(number x);
4737 \end_layout
4739 \begin_layout Standard
4740 Store specified number <x> as binary in string and return the result.
4741  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4742  double.
4743 \end_layout
4745 \begin_layout Subsection
4746 bit.quotent: Integer quotent
4747 \end_layout
4749 \begin_layout Itemize
4750 Syntax: number bit.quotent(number a, number b)
4751 \end_layout
4753 \begin_layout Standard
4754 Calculate quotent a/b.
4755 \end_layout
4757 \begin_layout Subsection
4758 bit.multidiv: Divide and split among multiple divisiors
4759 \end_layout
4761 \begin_layout Itemize
4762 Syntax: number...
4763  bit.multidiv(number v, number q...)
4764 \end_layout
4766 \begin_layout Standard
4767 Does the following steps:
4768 \end_layout
4770 \begin_layout Enumerate
4771 Set v' to <v>.
4772 \end_layout
4774 \begin_layout Enumerate
4775 For each <q> q:
4776 \end_layout
4778 \begin_deeper
4779 \begin_layout Enumerate
4780 Calculate quotent(v'/q) and add that to numbers returned.
4781 \end_layout
4783 \begin_layout Enumerate
4784 v' <- remainder(v'/q)
4785 \end_layout
4787 \end_deeper
4788 \begin_layout Enumerate
4789 Add v' to numbers returned.
4790 \end_layout
4792 \begin_layout Standard
4793 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
4794  at each step.
4795  <v> may be floating point, <q>s are integers.
4796 \end_layout
4798 \begin_layout Itemize
4799 E.g.
4800  bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
4801 \end_layout
4803 \begin_layout Itemize
4804 E.g.
4805  bit.multidiv(a, b) calculates quotent and remainder of a/b.
4806 \end_layout
4808 \begin_layout Subsection
4809 bit.mul32: 32-bit multiply
4810 \end_layout
4812 \begin_layout Itemize
4813 Syntax: number, number bit.mul32(number a, number b)
4814 \end_layout
4816 \begin_layout Standard
4817 Multiply 32-bit numbers <a> and <b>.
4818  The first return value is low 32 bits of result, the second is high 32
4819  bits.
4820 \end_layout
4822 \begin_layout Standard
4823 \begin_inset Newpage pagebreak
4824 \end_inset
4827 \end_layout
4829 \begin_layout Section
4830 Table classes:
4831 \end_layout
4833 \begin_layout Subsection
4834 classes.<foo>: The classobj for class <foo>
4835 \end_layout
4837 \begin_layout Itemize
4838 Syntax: classes.<foo>
4839 \end_layout
4841 \begin_layout Standard
4842 The classobj for class <foo>.
4843 \end_layout
4845 \begin_layout Subsection
4846 classes.<foo>._static_methods: Enumerate static methods
4847 \end_layout
4849 \begin_layout Itemize
4850 Syntax: string...
4851  classes.<foo>._static_methods()
4852 \end_layout
4854 \begin_layout Standard
4855 Returns all static methods of <foo> as strings.
4856 \end_layout
4858 \begin_layout Subsection
4859 classes.<foo>._class_methods: Enumerate static methods
4860 \end_layout
4862 \begin_layout Itemize
4863 Syntax: string...
4864  classes.<foo>._class_methods()
4865 \end_layout
4867 \begin_layout Standard
4868 Returns all class methods of <foo> as strings.
4869 \end_layout
4871 \begin_layout Subsection
4872 classes.<foo>.<bar>: Static method
4873 \end_layout
4875 \begin_layout Itemize
4876 Syntax: variable classes.<foo>.<bar>(variable...)
4877 \end_layout
4879 \begin_layout Standard
4880 Invokes static method <bar> of class <foo>.
4881 \end_layout
4883 \begin_layout Section
4884 Table gui:
4885 \end_layout
4887 \begin_layout Subsection
4888 gui.resolution: Get current resolution
4889 \end_layout
4891 \begin_layout Itemize
4892 Syntax: (number, number) gui.resolution()
4893 \end_layout
4895 \begin_layout Standard
4896 Returns 2-tuple (hresolution, vresolution).
4897 \end_layout
4899 \begin_layout Subsection
4900 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
4901 \end_layout
4903 \begin_layout Itemize
4904 Syntax: number gui.left_gap(number gap)
4905 \end_layout
4907 \begin_layout Itemize
4908 Syntax: number gui.right_gap(number gap)
4909 \end_layout
4911 \begin_layout Itemize
4912 Syntax: number gui.top_gap(number gap)
4913 \end_layout
4915 \begin_layout Itemize
4916 Syntax: number gui.bottom_gap(number gap)
4917 \end_layout
4919 \begin_layout Standard
4920 Set the specified edge gap to specified value <gap> (max gap is 8191).
4921  If successful, old gap is returned.
4922 \end_layout
4924 \begin_layout Subsection
4925 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
4926  Adjust edge gaps
4927 \end_layout
4929 \begin_layout Itemize
4930 Syntax: number gui.delta_left_gap(number dgap)
4931 \end_layout
4933 \begin_layout Itemize
4934 Syntax: number gui.delta_right_gap(number dgap)
4935 \end_layout
4937 \begin_layout Itemize
4938 Syntax: number gui.delta_top_gap(number dgap)
4939 \end_layout
4941 \begin_layout Itemize
4942 Syntax: number gui.delta_bottom_gap(number dgap)
4943 \end_layout
4945 \begin_layout Standard
4946 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
4947  and return the old gap (returns nothing on error).
4948 \end_layout
4950 \begin_layout Subsection
4951 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
4952 \end_layout
4954 \begin_layout Itemize
4955 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
4956  bgc]])
4957 \end_layout
4959 \begin_layout Itemize
4960 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
4961  bgc]])
4962 \end_layout
4964 \begin_layout Itemize
4965 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
4966  bgc]])
4967 \end_layout
4969 \begin_layout Itemize
4970 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
4971  bgc]])
4972 \end_layout
4974 \begin_layout Standard
4975 Draw specified text on the GUI (each character cell is 8 or 16 wide and
4976  16 high).
4977  Parameters:
4978 \end_layout
4980 \begin_layout Itemize
4981 x: X-coordinate to start the drawing from (and x-coordinate at begining
4982  of the lines).
4983 \end_layout
4985 \begin_layout Itemize
4986 y: Y-coordinate to start the drawing from.
4987 \end_layout
4989 \begin_layout Itemize
4990 text: The text to draw.
4991 \end_layout
4993 \begin_layout Itemize
4994 fgc: Text color (default is 0xFFFFFF (white))
4995 \end_layout
4997 \begin_layout Itemize
4998 bgc: Background color (default is -1 (transparent))
4999 \end_layout
5001 \begin_layout Standard
5002 Note: The H variants draw at double width and V variants draw at double
5003  height.
5004 \end_layout
5006 \begin_layout Subsection
5007 gui.rectangle: Draw a rectangle
5008 \end_layout
5010 \begin_layout Itemize
5011 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5012  number thickness[, number outline[, number fill]]])
5013 \end_layout
5015 \begin_layout Standard
5016 Draw rectangle on the GUI.
5017  Parameters:
5018 \end_layout
5020 \begin_layout Itemize
5021 x: X-coordinate of left edge.
5022 \end_layout
5024 \begin_layout Itemize
5025 y: Y-coordinate of upper edge.
5026 \end_layout
5028 \begin_layout Itemize
5029 width: Width of rectangle.
5030 \end_layout
5032 \begin_layout Itemize
5033 height: Height of rectangle.
5034 \end_layout
5036 \begin_layout Itemize
5037 thickness: Thickness of outline (default is 1).
5038 \end_layout
5040 \begin_layout Itemize
5041 outline: Color of outline (default is 0xFFFFFF (white))
5042 \end_layout
5044 \begin_layout Itemize
5045 fill: Color of fill (default is -1 (transparent))
5046 \end_layout
5048 \begin_layout Subsection
5049 gui.solidrectangle: Draw a solid rectangle
5050 \end_layout
5052 \begin_layout Itemize
5053 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5054  number color])
5055 \end_layout
5057 \begin_layout Standard
5058 Draw solid rectangle on the GUI.
5059  Parameters:
5060 \end_layout
5062 \begin_layout Itemize
5063 x: X-coordinate of left edge.
5064 \end_layout
5066 \begin_layout Itemize
5067 y: Y-coordinate of upper edge.
5068 \end_layout
5070 \begin_layout Itemize
5071 width: Width of rectangle.
5072 \end_layout
5074 \begin_layout Itemize
5075 height: Height of rectangle.
5076 \end_layout
5078 \begin_layout Itemize
5079 color: Color of rectangle (default is 0xFFFFFF (white))
5080 \end_layout
5082 \begin_layout Subsection
5083 gui.box: Draw a 3D-effect box
5084 \end_layout
5086 \begin_layout Itemize
5087 Syntax: none gui.box(number x, number y, number width, number height[, number
5088  thickness[, number outline1[,number outline2[, number fill]]]])
5089 \end_layout
5091 \begin_layout Standard
5092 Draw rectangle with 3D effect on the GUI.
5093  Parameters:
5094 \end_layout
5096 \begin_layout Itemize
5097 x: X-coordinate of left edge.
5098 \end_layout
5100 \begin_layout Itemize
5101 y: Y-coordinate of upper edge.
5102 \end_layout
5104 \begin_layout Itemize
5105 width: Width of rectangle.
5106 \end_layout
5108 \begin_layout Itemize
5109 height: Height of rectangle.
5110 \end_layout
5112 \begin_layout Itemize
5113 thickness: Thickness of outline (default is 1).
5114 \end_layout
5116 \begin_layout Itemize
5117 outline1: First color of outline (default is 0xFFFFFF (white))
5118 \end_layout
5120 \begin_layout Itemize
5121 outline2: First color of outline (default is 0x808080 (dark gray))
5122 \end_layout
5124 \begin_layout Itemize
5125 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5126 \end_layout
5128 \begin_layout Subsection
5129 gui.pixel: Draw a single pixel
5130 \end_layout
5132 \begin_layout Itemize
5133 Syntax: none gui.pixel(number x, number y[, number color])
5134 \end_layout
5136 \begin_layout Standard
5137 Draw one pixel on the GUI.
5138  Parameters:
5139 \end_layout
5141 \begin_layout Itemize
5142 x: X-coordinate of the pixel
5143 \end_layout
5145 \begin_layout Itemize
5146 y: Y-coordinate of the pixel
5147 \end_layout
5149 \begin_layout Itemize
5150 color: Color of the pixel (default is 0xFFFFFF (white))
5151 \end_layout
5153 \begin_layout Subsection
5154 gui.crosshair: Draw a crosshair
5155 \end_layout
5157 \begin_layout Itemize
5158 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5159 \end_layout
5161 \begin_layout Standard
5162 Draw a crosshair.
5163  Parameters:
5164 \end_layout
5166 \begin_layout Itemize
5167 x: X-coordinate of the crosshair
5168 \end_layout
5170 \begin_layout Itemize
5171 y: Y-coordinate of the crosshair
5172 \end_layout
5174 \begin_layout Itemize
5175 length: Length of the crosshair lines (default 10).
5176 \end_layout
5178 \begin_layout Itemize
5179 color: Color of the crosshair (default is 0xFFFFFF (white))
5180 \end_layout
5182 \begin_layout Subsection
5183 gui.line: Draw a line
5184 \end_layout
5186 \begin_layout Itemize
5187 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5188  color])
5189 \end_layout
5191 \begin_layout Standard
5192 Draw a thin line.
5193  Parameters:
5194 \end_layout
5196 \begin_layout Itemize
5197 x1: X-coordinate of one end.
5198 \end_layout
5200 \begin_layout Itemize
5201 y1: Y-coordinate of one end.
5202 \end_layout
5204 \begin_layout Itemize
5205 x2: X-coordinate of the other end.
5206 \end_layout
5208 \begin_layout Itemize
5209 y2: Y-coordinate of the other end.
5210 \end_layout
5212 \begin_layout Itemize
5213 color: Color of the line (default is 0xFFFFFF (white)).
5214 \end_layout
5216 \begin_layout Subsection
5217 gui.circle: Draw a (filled) circle
5218 \end_layout
5220 \begin_layout Itemize
5221 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5222  border[, number fil]]])
5223 \end_layout
5225 \begin_layout Standard
5226 Draw a circle.
5227  Parameters.
5228 \end_layout
5230 \begin_layout Itemize
5231 x: X-coordinate of the center
5232 \end_layout
5234 \begin_layout Itemize
5235 y: Y-coordinate of the center
5236 \end_layout
5238 \begin_layout Itemize
5239 r: The radius of the circle
5240 \end_layout
5242 \begin_layout Itemize
5243 thick: Border thickness
5244 \end_layout
5246 \begin_layout Itemize
5247 border: Border color (default is 0xFFFFFF (white))
5248 \end_layout
5250 \begin_layout Itemize
5251 fill: Fill color (default is -1 (transparent)).
5252 \end_layout
5254 \begin_layout Subsection
5255 gui.repaint: Arrange a repaint
5256 \end_layout
5258 \begin_layout Itemize
5259 Syntax: none gui.repaint()
5260 \end_layout
5262 \begin_layout Standard
5263 Request on_repaint() to happen as soon as possible.
5264 \end_layout
5266 \begin_layout Subsection
5267 gui.subframe_update: Enable/Disable subframe updates
5268 \end_layout
5270 \begin_layout Itemize
5271 Syntax: none gui.subframe_update(boolean on)
5272 \end_layout
5274 \begin_layout Standard
5275 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5276  or not happen (<on>=false).
5277 \end_layout
5279 \begin_layout Subsection
5280 gui.screenshot: Write a screenshot
5281 \end_layout
5283 \begin_layout Itemize
5284 Syntax: none gui.screenshot(string filename)
5285 \end_layout
5287 \begin_layout Standard
5288 Write PNG screenshot of the current frame (no drawings) to specified file
5289  <filename>.
5290 \end_layout
5292 \begin_layout Subsection
5293 gui.screenshot_bitmap: Write a screenshot to bitmap
5294 \end_layout
5296 \begin_layout Itemize
5297 Syntax: DBITMAP gui.screenshot_bitmap()
5298 \end_layout
5300 \begin_layout Standard
5301 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5302  the result.
5303 \end_layout
5305 \begin_layout Subsection
5306 gui.color: Compose a color.
5307 \end_layout
5309 \begin_layout Itemize
5310 Syntax: number gui.color(number r, number g, number b[, number a])
5311 \end_layout
5313 \begin_layout Itemize
5314 Syntax: number gui.color(string c)
5315 \end_layout
5317 \begin_layout Standard
5318 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5319 , each component in scale 0-255.
5320  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5321  fully opaque).
5322  The default alpha is 256.
5323 \end_layout
5325 \begin_layout Standard
5326 The form taking a string returns color corresponding color name.
5327 \end_layout
5329 \begin_layout Subsection
5330 gui.status: Set status variable
5331 \end_layout
5333 \begin_layout Itemize
5334 Syntax: none gui.status(string name, string value)
5335 \end_layout
5337 \begin_layout Standard
5338 Set status field 
5339 \begin_inset Quotes eld
5340 \end_inset
5342 L[<name>]
5343 \begin_inset Quotes erd
5344 \end_inset
5346  to <value> in status area.
5347 \end_layout
5349 \begin_layout Subsection
5350 gui.rainbow: Rainbow color calculation
5351 \end_layout
5353 \begin_layout Itemize
5354 Syntax: number gui.rainbow(number step, number steps[, number color])
5355 \end_layout
5357 \begin_layout Standard
5358 Perform hue rotation of color <color> (default bright red), by <step> steps.
5359  The number of steps per full rotation is given by absolute value of <steps>.
5360 \end_layout
5362 \begin_layout Standard
5363 If <step> is negative, the rotation will be counterclockwise.
5364 \end_layout
5366 \begin_layout Subsection
5367 gui.kill_frame: Kill video frame and associated sound
5368 \end_layout
5370 \begin_layout Itemize
5371 Syntax: none gui.kill_frame()
5372 \end_layout
5374 \begin_layout Standard
5375 Kills the currently dumped video frame + the associated sound.
5376  Only valid in on_video callback.
5377 \end_layout
5379 \begin_layout Subsection
5380 gui.set_video_scale: Set video frame scale
5381 \end_layout
5383 \begin_layout Itemize
5384 Syntax: none gui.set_video_scale(number h, number v)
5385 \end_layout
5387 \begin_layout Standard
5388 Sets the scale factors of current frame to <h>x<v>.
5389  Only valid in on_video callback.
5390 \end_layout
5392 \begin_layout Subsection
5393 gui.arrow: Draw an arrow
5394 \end_layout
5396 \begin_layout Itemize
5397 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5398  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5400 \end_layout
5402 \begin_layout Standard
5403 Draws an arrow using color <color>.
5404  The tip of arrow is at (<x>, <y>).
5405  Other parameters:
5406 \end_layout
5408 \begin_layout Enumerate
5409 <length>: The length of arrow tail.
5410 \end_layout
5412 \begin_layout Enumerate
5413 <hwidth>: The width of arrow head.
5414  Should be odd.
5415 \end_layout
5417 \begin_layout Enumerate
5418 <direction>: Direction of arrow.
5419  0 is to right, +1 rotates 45 degrees counterclockwise.
5420 \end_layout
5422 \begin_layout Enumerate
5423 <fill>: If true, fill the arrow head.
5424  Default false.
5425 \end_layout
5427 \begin_layout Enumerate
5428 <twidth>: Tail width.
5429  Should be odd.
5430  Default 1.
5431 \end_layout
5433 \begin_layout Enumerate
5434 <hthick>: Head thickness (only used if <fill> is false).
5435  Default is <twidth>.
5436 \end_layout
5438 \begin_layout Subsection
5439 gui.tiled_bitmap: Class TILEMAP
5440 \end_layout
5442 \begin_layout Standard
5443 See class TILEMAP.
5444 \end_layout
5446 \begin_layout Subsection
5447 gui.palette: Class PALETTE
5448 \end_layout
5450 \begin_layout Standard
5451 See class PALETTE.
5452 \end_layout
5454 \begin_layout Subsection
5455 gui.bitmap: Class BITMAP
5456 \end_layout
5458 \begin_layout Standard
5459 See class BITMAP.
5460 \end_layout
5462 \begin_layout Subsection
5463 gui.dbitmap: Class DBITMAP
5464 \end_layout
5466 \begin_layout Standard
5467 See class DBITMAP.
5468 \end_layout
5470 \begin_layout Subsection
5471 gui.font: Class CUSTOMFONT
5472 \end_layout
5474 \begin_layout Standard
5475 See class CUSTOMFONT.
5476 \end_layout
5478 \begin_layout Subsection
5479 gui.renderctx: Class RENDERCTX
5480 \end_layout
5482 \begin_layout Standard
5483 See class RENDERCTX.
5484 \end_layout
5486 \begin_layout Subsection
5487 gui.image: Class IMAGELOADER
5488 \end_layout
5490 \begin_layout Standard
5491 See class IMAGELOADER.
5492 \end_layout
5494 \begin_layout Standard
5495 \begin_inset Newpage pagebreak
5496 \end_inset
5499 \end_layout
5501 \begin_layout Section
5502 table input
5503 \end_layout
5505 \begin_layout Standard
5506 Input handling.
5507  Functions manipulating input are only available in on_input callback.
5508 \end_layout
5510 \begin_layout Subsection
5511 input.get: Read controller button/axis (deprecated)
5512 \end_layout
5514 \begin_layout Itemize
5515 Syntax: number input.get(number controller, number index)
5516 \end_layout
5518 \begin_layout Standard
5519 Read the specified index <index> (zero-based) from specified controller
5520  <controller> (zero-based).
5522 \end_layout
5524 \begin_layout Subsection
5525 input.set: Write controller button/axis (deprecated)
5526 \end_layout
5528 \begin_layout Itemize
5529 Syntax: none input.set(number controller, number index, number value)
5530 \end_layout
5532 \begin_layout Standard
5533 Write the specified index <index> (zero-based) from specified controller
5534  <controller> (zero-based), storing value <value>.
5535 \end_layout
5537 \begin_layout Subsection
5538 input.get2: Read controller button/axis
5539 \end_layout
5541 \begin_layout Itemize
5542 Syntax: number input.get2(number port, number controller, number index)
5543 \end_layout
5545 \begin_layout Standard
5546 Read the specified input tuple.
5547  Port 0 is system port.
5548 \end_layout
5550 \begin_layout Subsection
5551 input.set2: Write controller button/axis
5552 \end_layout
5554 \begin_layout Itemize
5555 Syntax: input.set2(number port, number controller, number index, number value)
5556 \end_layout
5558 \begin_layout Standard
5559 Write the specified input tuple.
5560  Port 0 is system port.
5561 \end_layout
5563 \begin_layout Subsection
5564 input.lcid_to_pcid2: Look up logical controller
5565 \end_layout
5567 \begin_layout Itemize
5568 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5569 \end_layout
5571 \begin_layout Standard
5572 Look up physical pcid pair (port, controller) corresponding to specified
5573  logical controller (1-based).
5574  Returns nothing if controller does not exist.
5575 \end_layout
5577 \begin_layout Subsection
5578 input.port_type: Look up port type
5579 \end_layout
5581 \begin_layout Itemize
5582 Syntax: string input.port_type(number port)
5583 \end_layout
5585 \begin_layout Standard
5586 Return type of specified port.
5587 \end_layout
5589 \begin_layout Subsection
5590 input.controller_info: Get information about controller
5591 \end_layout
5593 \begin_layout Itemize
5594 Syntax: table input.controller_info(number port, number controller)
5595 \end_layout
5597 \begin_layout Standard
5598 Get controller info for specified controller.
5599  If controller does not exist, returns nil.
5600  Otherwise returns a table with following fields:
5601 \end_layout
5603 \begin_layout Itemize
5604 type (string): Type of the controller.
5605 \end_layout
5607 \begin_layout Itemize
5608 class (string): Class of the controller.
5609 \end_layout
5611 \begin_layout Itemize
5612 classnum (number): Number of the controller within its class (1-based)
5613 \end_layout
5615 \begin_layout Itemize
5616 lcid (number): Logical controller number of the controller.
5617 \end_layout
5619 \begin_layout Itemize
5620 button_count (number): Number of buttons on controller
5621 \end_layout
5623 \begin_layout Itemize
5624 buttons (array): Array of following info about each button:
5625 \end_layout
5627 \begin_deeper
5628 \begin_layout Itemize
5629 type (string): Type of button.
5630  Currently one of 
5631 \begin_inset Quotes eld
5632 \end_inset
5634 null
5635 \begin_inset Quotes erd
5636 \end_inset
5639 \begin_inset Quotes eld
5640 \end_inset
5642 button
5643 \begin_inset Quotes erd
5644 \end_inset
5647 \begin_inset Quotes eld
5648 \end_inset
5650 axis
5651 \begin_inset Quotes erd
5652 \end_inset
5655 \begin_inset Quotes eld
5656 \end_inset
5658 raxis
5659 \begin_inset Quotes erd
5660 \end_inset
5663 \end_layout
5665 \begin_layout Itemize
5666 name (string): Name of button.
5667 \end_layout
5669 \begin_layout Itemize
5670 symbol (string): Symbol of button.
5671  Only present for type 
5672 \begin_inset Quotes eld
5673 \end_inset
5675 button
5676 \begin_inset Quotes erd
5677 \end_inset
5680 \end_layout
5682 \begin_layout Itemize
5683 hidden (boolean): True if hidden button.
5685 \end_layout
5687 \end_deeper
5688 \begin_layout Subsection
5689 input.veto_button: Veto a button press
5690 \end_layout
5692 \begin_layout Itemize
5693 Syntax: none input.veto_button()
5694 \end_layout
5696 \begin_layout Standard
5697 Signals that the button event should be vetoed.
5698  Only valid in on_button callback.
5699 \end_layout
5701 \begin_layout Subsection
5702 input.geta: Get all buttons for controller (deprecated)
5703 \end_layout
5705 \begin_layout Itemize
5706 Syntax: (number, number...) input.geta(number controller)
5707 \end_layout
5709 \begin_layout Standard
5710 Get input state for entiere controller.
5711  Returns n return values.
5712 \end_layout
5714 \begin_layout Itemize
5715 1st return value: Bitmask: bit i is set if i:th index is nonzero
5716 \end_layout
5718 \begin_layout Itemize
5719 2nd- return value: value of i:th index.
5720 \end_layout
5722 \begin_layout Subsection
5723 input.seta: Set all buttons for controller (deprecated)
5724 \end_layout
5726 \begin_layout Itemize
5727 Syntax: none input.seta(number controller, number bitmask, number args...)
5728 \end_layout
5730 \begin_layout Standard
5731 Set state for entiere controller.
5732  args is up to N values for indices (overriding values in bitmask if specified).
5733 \end_layout
5735 \begin_layout Subsection
5736 input.controllertype: Get controller type (deprecated)
5737 \end_layout
5739 \begin_layout Itemize
5740 syntax: string input.controllertype(number controller)
5741 \end_layout
5743 \begin_layout Standard
5744 Get the type of controller as string.
5745 \end_layout
5747 \begin_layout Subsection
5748 input.reset: Execute (delayed) reset
5749 \end_layout
5751 \begin_layout Itemize
5752 Syntax: none input.reset([number cycles])
5753 \end_layout
5755 \begin_layout Standard
5756 Execute reset.
5757  If <cycles> is greater than zero, do delayed reset.
5758  0 (or no value) causes immediate reset.
5759 \end_layout
5761 \begin_layout Itemize
5762 Note: Only available with subframe flag false.
5763 \end_layout
5765 \begin_layout Subsection
5766 input.raw: Return raw input data
5767 \end_layout
5769 \begin_layout Itemize
5770 Syntax: table input.raw()
5771 \end_layout
5773 \begin_layout Standard
5774 Returns table of tables of all available keys and axes.
5775  The first table is indexed by key name (platform-dependent!), and the inner
5776  table has the following fields:
5777 \end_layout
5779 \begin_layout Itemize
5780 value: Last reported value for control
5781 \end_layout
5783 \begin_deeper
5784 \begin_layout Itemize
5785 For keys: 1 for pressed, 0 for released.
5786 \end_layout
5788 \begin_layout Itemize
5789 For axes: -32767...32767.
5790 \end_layout
5792 \begin_layout Itemize
5793 For presure-sensitive buttons: 0...32767.
5794 \end_layout
5796 \begin_layout Itemize
5797 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
5798 \end_layout
5800 \begin_layout Itemize
5801 For mouse: Coordinates relative to game area.
5802 \end_layout
5804 \end_deeper
5805 \begin_layout Itemize
5806 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
5807 \end_layout
5809 \begin_layout Subsection
5810 input.keyhook: Hook a key
5811 \end_layout
5813 \begin_layout Itemize
5814 Syntax: none input.keyhook(string key, boolean state)
5815 \end_layout
5817 \begin_layout Standard
5818 Requests that keyhook events to be sent for key <key> (<state>=true) or
5819  not sent (<state>=false).
5820 \end_layout
5822 \begin_layout Subsection
5823 input.joyget: Get controls for controller
5824 \end_layout
5826 \begin_layout Itemize
5827 Syntax: table input.joyget(number logical)
5828 \end_layout
5830 \begin_layout Standard
5831 Returns table for current controls for specified logical controller <logical>.
5832  The names of fields vary by controller type.
5833 \end_layout
5835 \begin_layout Itemize
5836 The buttons have the same name as those are referred to in other contexts
5837  in the emulator
5838 \end_layout
5840 \begin_layout Itemize
5841 The analog axes are usually 
5842 \begin_inset Quotes eld
5843 \end_inset
5845 xaxis
5846 \begin_inset Quotes erd
5847 \end_inset
5849  and 
5850 \begin_inset Quotes eld
5851 \end_inset
5853 yaxis
5854 \begin_inset Quotes erd
5855 \end_inset
5858 \end_layout
5860 \begin_layout Itemize
5861 Each field is numeric or boolean depending on axis/button.
5862 \end_layout
5864 \begin_layout Subsection
5865 input.joyset: Set controls for controller
5866 \end_layout
5868 \begin_layout Itemize
5869 Syntax: none input.joyset(number controller, table controls)
5870 \end_layout
5872 \begin_layout Standard
5873 Set the the state of specified controller to values specified in specified
5874  table.
5875 \end_layout
5877 \begin_layout Itemize
5878 Each field can be boolean or number.
5879 \end_layout
5881 \begin_layout Itemize
5882 Also, buttons allow strings, which cause value to be inverted.
5883 \end_layout
5885 \begin_layout Subsection
5886 input.lcid_to_pcid: Look up logical controller (deprecated)
5887 \end_layout
5889 \begin_layout Itemize
5890 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
5891 \end_layout
5893 \begin_layout Standard
5894 Returns the legacy pcid for controller (or false if there isn't one), followed
5895  by pcid pair.
5896  Returns nothing if controller does not exist.
5897 \end_layout
5899 \begin_layout Standard
5900 \begin_inset Newpage pagebreak
5901 \end_inset
5904 \end_layout
5906 \begin_layout Section
5907 Table keyboard
5908 \end_layout
5910 \begin_layout Standard
5911 Various keybinding-related functions
5912 \end_layout
5914 \begin_layout Subsection
5915 keyboard.bind: Bind a key
5916 \end_layout
5918 \begin_layout Itemize
5919 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
5920 \end_layout
5922 \begin_layout Standard
5923 Bind specified key with specified modifers to specified command.
5924 \end_layout
5926 \begin_layout Subsection
5927 keyboard.unbind: Unbind a key
5928 \end_layout
5930 \begin_layout Itemize
5931 Syntax: none keyboard.unbind(string mod, string mask, string key)
5932 \end_layout
5934 \begin_layout Standard
5935 Unbind specified key with specified modifers.
5936 \end_layout
5938 \begin_layout Subsection
5939 keyboard.alias: Set alias expansion
5940 \end_layout
5942 \begin_layout Itemize
5943 Syntax: none keyboard.alias(string alias, string expansion)
5944 \end_layout
5946 \begin_layout Standard
5947 Set expansion of given command.
5948 \end_layout
5950 \begin_layout Standard
5951 \begin_inset Newpage pagebreak
5952 \end_inset
5955 \end_layout
5957 \begin_layout Section
5958 Table subtitle
5959 \end_layout
5961 \begin_layout Standard
5962 Subtitle handling
5963 \end_layout
5965 \begin_layout Subsection
5966 subtitle.byindex: Look up start and length of subtitle by index
5967 \end_layout
5969 \begin_layout Itemize
5970 Syntax: (number, number) subtitle.byindex(number i)
5971 \end_layout
5973 \begin_layout Standard
5974 Read the frame and length of ith subtitle.
5975  Returns nothing if not present.
5976 \end_layout
5978 \begin_layout Subsection
5979 subtitle.set: Write a subtitle
5980 \end_layout
5982 \begin_layout Itemize
5983 Syntax: none subtitle.set(number f, number l, string txt)
5984 \end_layout
5986 \begin_layout Standard
5987 Set the text of subtitle.
5988 \end_layout
5990 \begin_layout Subsection
5991 subtitle.get: Read a subtitle
5992 \end_layout
5994 \begin_layout Itemize
5995 Syntax: string subtitle.get(number f, number l)
5996 \end_layout
5998 \begin_layout Standard
5999 Get the text of subtitle.
6000 \end_layout
6002 \begin_layout Subsection
6003 subtitle.delete: Delete a subtitle
6004 \end_layout
6006 \begin_layout Itemize
6007 Syntax: none subtitle.delete(number f, number l)
6008 \end_layout
6010 \begin_layout Standard
6011 Delete specified subtitle.
6012 \end_layout
6014 \begin_layout Standard
6015 \begin_inset Newpage pagebreak
6016 \end_inset
6019 \end_layout
6021 \begin_layout Section
6022 Table hostmemory
6023 \end_layout
6025 \begin_layout Standard
6026 Host memory handling (extra memory saved to savestates).
6027  Host memory starts empty.
6028 \end_layout
6030 \begin_layout Itemize
6031 Reads out of range return false.
6032 \end_layout
6034 \begin_layout Itemize
6035 Writes out of range extend the memory.
6036 \end_layout
6038 \begin_layout Subsection
6039 hostmemory.read: Read byte from host memory
6040 \end_layout
6042 \begin_layout Itemize
6043 Syntax: number hostmemory.read(number address)
6044 \end_layout
6046 \begin_layout Standard
6047 Reads byte from hostmemory slot address <address>.
6048 \end_layout
6050 \begin_layout Subsection
6051 hostmemory.write: Write byte to host memory
6052 \end_layout
6054 \begin_layout Itemize
6055 Syntax: none hostmemory.write(number address, number value)
6056 \end_layout
6058 \begin_layout Standard
6059 Writes hostmemory slot with value <value> 0-255.
6060 \end_layout
6062 \begin_layout Subsection
6063 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6064 \end_layout
6066 \begin_layout Itemize
6067 Syntax: number hostmemory.readbyte(number address)
6068 \end_layout
6070 \begin_layout Itemize
6071 Syntax: number hostmemory.readsbyte(number address)
6072 \end_layout
6074 \begin_layout Itemize
6075 Syntax: number hostmemory.readword(number address)
6076 \end_layout
6078 \begin_layout Itemize
6079 Syntax: number hostmemory.readsword(number address)
6080 \end_layout
6082 \begin_layout Itemize
6083 Syntax: number hostmemory.readhword(number address)
6084 \end_layout
6086 \begin_layout Itemize
6087 Syntax: number hostmemory.readshword(number address)
6088 \end_layout
6090 \begin_layout Itemize
6091 Syntax: number hostmemory.readdword(number address)
6092 \end_layout
6094 \begin_layout Itemize
6095 Syntax: number hostmemory.readsdword(number address)
6096 \end_layout
6098 \begin_layout Itemize
6099 Syntax: number hostmemory.readqword(number address)
6100 \end_layout
6102 \begin_layout Itemize
6103 Syntax: number hostmemory.readsqword(number address)
6104 \end_layout
6106 \begin_layout Standard
6107 Read elements (big-endian) from given address <address>.
6108 \end_layout
6110 \begin_layout Itemize
6111 byte is 1 element
6112 \end_layout
6114 \begin_layout Itemize
6115 word is 2 elements
6116 \end_layout
6118 \begin_layout Itemize
6119 hword is 3 elements
6120 \end_layout
6122 \begin_layout Itemize
6123 dword is 4 elements
6124 \end_layout
6126 \begin_layout Itemize
6127 qword is 8 elements.
6128 \end_layout
6130 \begin_layout Itemize
6131 The 's' variants do signed read.
6132 \end_layout
6134 \begin_layout Subsection
6135 hostmemory.read{float,double}: Read from host memory
6136 \end_layout
6138 \begin_layout Itemize
6139 syntax: number hostmemory.readfloat(number address)
6140 \end_layout
6142 \begin_layout Itemize
6143 Syntax: number hostmemory.readdouble(number address)
6144 \end_layout
6146 \begin_layout Standard
6147 Read elements (big-endian) floating-pont from given address <address>.
6148 \end_layout
6150 \begin_layout Subsection
6151 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6152 \end_layout
6154 \begin_layout Itemize
6155 Syntax: number hostmemory.writebyte(number address, number value)
6156 \end_layout
6158 \begin_layout Itemize
6159 Syntax: number hostmemory.writesbyte(number address, number value)
6160 \end_layout
6162 \begin_layout Itemize
6163 Syntax: number hostmemory.writeword(number address, number value)
6164 \end_layout
6166 \begin_layout Itemize
6167 Syntax: number hostmemory.writesword(number address, number value)
6168 \end_layout
6170 \begin_layout Itemize
6171 Syntax: number hostmemory.writehword(number address, number value)
6172 \end_layout
6174 \begin_layout Itemize
6175 Syntax: number hostmemory.writeshword(number address, number value)
6176 \end_layout
6178 \begin_layout Itemize
6179 Syntax: number hostmemory.writedword(number address, number value)
6180 \end_layout
6182 \begin_layout Itemize
6183 Syntax: number hostmemory.writesdword(number address, number value)
6184 \end_layout
6186 \begin_layout Itemize
6187 Syntax: number hostmemory.writeqword(number address, number value)
6188 \end_layout
6190 \begin_layout Itemize
6191 Syntax: number hostmemory.writesqword(number address, number value)
6192 \end_layout
6194 \begin_layout Standard
6195 Write value <value> to elements (little-endian) starting from given address
6196  <address>.
6197 \end_layout
6199 \begin_layout Itemize
6200 byte is 1 element
6201 \end_layout
6203 \begin_layout Itemize
6204 word is 2 elements
6205 \end_layout
6207 \begin_layout Itemize
6208 hword is 3 elements
6209 \end_layout
6211 \begin_layout Itemize
6212 dword is 4 elements
6213 \end_layout
6215 \begin_layout Itemize
6216 qword is 8 elements.
6217 \end_layout
6219 \begin_layout Itemize
6220 The 's' variants do signed write.
6221 \end_layout
6223 \begin_layout Subsection
6224 hostmemory.write{float,double}: Write to host memory
6225 \end_layout
6227 \begin_layout Itemize
6228 syntax: none hostmemory.readfloat(number address, number value)
6229 \end_layout
6231 \begin_layout Itemize
6232 Syntax: none hostmemory.readdouble(number address, number value)
6233 \end_layout
6235 \begin_layout Standard
6236 Write elements (big-endian) floating-pont to given address <address>, storing
6237  <value>.
6238 \end_layout
6240 \begin_layout Standard
6241 \begin_inset Newpage pagebreak
6242 \end_inset
6245 \end_layout
6247 \begin_layout Section
6248 Table movie
6249 \end_layout
6251 \begin_layout Standard
6252 Movie handling
6253 \end_layout
6255 \begin_layout Subsection
6256 movie.currentframe: Get current frame number
6257 \end_layout
6259 \begin_layout Itemize
6260 Syntax: number movie.currentframe()
6261 \end_layout
6263 \begin_layout Standard
6264 Return number of current frame.
6265 \end_layout
6267 \begin_layout Subsection
6268 movie.framecount: Get move frame count
6269 \end_layout
6271 \begin_layout Itemize
6272 Syntax: number movie.framecount()
6273 \end_layout
6275 \begin_layout Standard
6276 Return number of frames in movie.
6277 \end_layout
6279 \begin_layout Subsection
6280 movie.lagcount: Get current lag count
6281 \end_layout
6283 \begin_layout Itemize
6284 Syntax: number movie.lagcount()
6285 \end_layout
6287 \begin_layout Standard
6288 Return number of lag frames recorded so far.
6289 \end_layout
6291 \begin_layout Subsection
6292 movie.readonly: Is in playback mode?
6293 \end_layout
6295 \begin_layout Itemize
6296 Syntax: boolean movie.readonly()
6297 \end_layout
6299 \begin_layout Standard
6300 Return true if in playback mode, false if in recording.
6301 \end_layout
6303 \begin_layout Subsection
6304 movie.rerecords: Movie rerecord count
6305 \end_layout
6307 \begin_layout Itemize
6308 Syntax: number movie.rerecords()
6309 \end_layout
6311 \begin_layout Standard
6312 Returns the current value of rerecord count.
6313 \end_layout
6315 \begin_layout Subsection
6316 movie.set_readwrite: Set recording mode.
6317 \end_layout
6319 \begin_layout Itemize
6320 Syntax: none movie.set_readwrite()
6321 \end_layout
6323 \begin_layout Standard
6324 Set recording mode (does not cause on_readwrite callback).
6325 \end_layout
6327 \begin_layout Subsection
6328 movie.frame_subframes: Count subframes in frame
6329 \end_layout
6331 \begin_layout Itemize
6332 Syntax: number movie.frame_subframes(number frame)
6333 \end_layout
6335 \begin_layout Standard
6336 Count number of subframes in specified frame <frame> (frame numbers are
6337  1-based) and return that.
6338 \end_layout
6340 \begin_layout Subsection
6341 movie.read_subframes: Read subframe data (deprecated)
6342 \end_layout
6344 \begin_layout Itemize
6345 Syntax: table movie.read_subframes(number frame, number subframe)
6346 \end_layout
6348 \begin_layout Standard
6349 Read specifed subframe in specified frame and return data as array.
6350 \end_layout
6352 \begin_layout Subsection
6353 movie.read_rtc: Read current RTC time
6354 \end_layout
6356 \begin_layout Itemize
6357 Syntax: (number, number) movie.read_rtc()
6358 \end_layout
6360 \begin_layout Standard
6361 Returns the current value of the RTC as a pair (second, subsecond).
6362 \end_layout
6364 \begin_layout Subsection
6365 movie.unsafe_rewind: Fast movie rewind to saved state
6366 \end_layout
6368 \begin_layout Itemize
6369 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6370 \end_layout
6372 \begin_layout Standard
6373 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6374 \end_layout
6376 \begin_layout Itemize
6377 If called without argument, causes emulator to start process of setting
6378  unsafe rewind point.
6379  When this has finished, callback on_set_rewind occurs, passing the rewind
6380  state to lua script.
6381 \end_layout
6383 \begin_layout Itemize
6384 If called with argument, causes emulator rewind to passed rewind point as
6385  soon as possible.
6386  recording mode is implicitly activated.
6387 \end_layout
6389 \begin_layout Standard
6390 The following warnings apply to unsafe rewinding:
6391 \end_layout
6393 \begin_layout Itemize
6394 There are no safety checks against misuse (that's what 
6395 \begin_inset Quotes eld
6396 \end_inset
6398 unsafe
6399 \begin_inset Quotes erd
6400 \end_inset
6402  comes from)!
6403 \end_layout
6405 \begin_layout Itemize
6406 Only call rewind from timeline rewind point was set from.
6407 \end_layout
6409 \begin_layout Itemize
6410 Only call rewind from after the rewind point was set.
6411 \end_layout
6413 \begin_layout Subsection
6414 movie.to_rewind: Load savestate as rewind point
6415 \end_layout
6417 \begin_layout Itemize
6418 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6419 \end_layout
6421 \begin_layout Standard
6422 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6423  corresponding to it.
6424 \end_layout
6426 \begin_layout Itemize
6427 Note: This operation does not take emulated time.
6428 \end_layout
6430 \begin_layout Subsection
6431 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6432 \end_layout
6434 \begin_layout Itemize
6435 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6436 \end_layout
6438 \begin_layout Itemize
6439 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6440 \end_layout
6442 \begin_layout Standard
6443 Copies specified movie or branch <movie>/current object (if none or nil,
6444  the active movie) as new movie object.
6445 \end_layout
6447 \begin_layout Subsection
6448 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6449 \end_layout
6451 \begin_layout Itemize
6452 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6453 \end_layout
6455 \begin_layout Itemize
6456 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6457 \end_layout
6459 \begin_layout Standard
6460 Get INPUTFRAME object corresponding to specified frame in specified movie
6461  or branch.
6462 \end_layout
6464 \begin_layout Subsection
6465 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6466 \end_layout
6468 \begin_layout Itemize
6469 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6470  data)
6471 \end_layout
6473 \begin_layout Itemize
6474 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6475 \end_layout
6477 \begin_layout Standard
6478 Set data in specified frame.
6479 \end_layout
6481 \begin_layout Itemize
6482 Note: Past can't be edited in active movie.
6483 \end_layout
6485 \begin_layout Subsection
6486 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6487 \end_layout
6489 \begin_layout Itemize
6490 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6491 \end_layout
6493 \begin_layout Itemize
6494 Syntax: integer INPUTMOVIE::get_size()
6495 \end_layout
6497 \begin_layout Standard
6498 Return number of subframes in specified movie or branch.
6499 \end_layout
6501 \begin_layout Subsection
6502 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6503 \end_layout
6505 \begin_layout Itemize
6506 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6507 \end_layout
6509 \begin_layout Itemize
6510 Syntax: number INPUTMOVIE::count_frames()
6511 \end_layout
6513 \begin_layout Standard
6514 Return number of frames in movie.
6515 \end_layout
6517 \begin_layout Subsection
6518 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6519 \end_layout
6521 \begin_layout Itemize
6522 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6523 \end_layout
6525 \begin_layout Itemize
6526 Syntax: number INPUTMOVIE::find_frame(number frame)
6527 \end_layout
6529 \begin_layout Standard
6530 Returns starting subframe of given frame (frame numbers are 1-based).
6531  Returns -1 if frame number is bad.
6532 \end_layout
6534 \begin_layout Subsection
6535 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6536 \end_layout
6538 \begin_layout Itemize
6539 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6540 \end_layout
6542 \begin_layout Itemize
6543 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6544 \end_layout
6546 \begin_layout Standard
6547 Return blank INPUTFRAME with frame type from specified movie.
6548 \end_layout
6550 \begin_layout Subsection
6551 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6552 \end_layout
6554 \begin_layout Itemize
6555 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6556 \end_layout
6558 \begin_layout Itemize
6559 Syntax: none INPUTMOVIE::append_frames(number frames)
6560 \end_layout
6562 \begin_layout Standard
6563 Append specified number <frames> of frames.
6564 \end_layout
6566 \begin_layout Subsection
6567 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
6568 \end_layout
6570 \begin_layout Itemize
6571 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
6572 \end_layout
6574 \begin_layout Itemize
6575 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
6576 \end_layout
6578 \begin_layout Standard
6579 Append specified frame <frame>.
6580  Past of current movie can't be edited.
6581 \end_layout
6583 \begin_layout Subsection
6584 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
6585 \end_layout
6587 \begin_layout Itemize
6588 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
6589 \end_layout
6591 \begin_layout Itemize
6592 Syntax: none INPUTMOVIE::truncate(number frames)
6593 \end_layout
6595 \begin_layout Standard
6596 Truncate the specified movie to specified number of frames.
6597 \end_layout
6599 \begin_layout Subsection
6600 movie.edit/INPUTMOVIE::edit: Edit a movie
6601 \end_layout
6603 \begin_layout Itemize
6604 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
6605  controller, number control, number/bool value)
6606 \end_layout
6608 \begin_layout Itemize
6609 Syntax: none movie.edit(string branch, number frame, number port, number
6610  controller, number control, number/bool value)
6611 \end_layout
6613 \begin_layout Itemize
6614 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
6615  number control, number/bool value)
6616 \end_layout
6618 \begin_layout Standard
6619 Change specified control in specified frame in specified movie.
6620  Past can't be edited in active movie.
6621 \end_layout
6623 \begin_layout Subsection
6624 movie.copy_frames2: Copy frames between movies
6625 \end_layout
6627 \begin_layout Itemize
6628 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
6629 IE/string srcmov,] number src, number count)
6630 \end_layout
6632 \begin_layout Standard
6633 Copy specified number of frames between two movies.
6634  The copy proceeeds in forward direction.
6635 \end_layout
6637 \begin_layout Subsection
6638 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
6639 \end_layout
6641 \begin_layout Itemize
6642 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
6643  src, number count, bool backwards)
6644 \end_layout
6646 \begin_layout Itemize
6647 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
6648  bool backwards)
6649 \end_layout
6651 \begin_layout Standard
6652 Copy specified number of frames from one point in movie to another.
6653  If backwards is true, the copy will be done backwards.
6654 \end_layout
6656 \begin_layout Subsection
6657 movie.serialize/INPUTMOVIE::serialize: Serialize movie
6658 \end_layout
6660 \begin_layout Itemize
6661 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
6662  bool binary)
6663 \end_layout
6665 \begin_layout Itemize
6666 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
6667 \end_layout
6669 \begin_layout Standard
6670 Serialize given movie into file.
6671  If binary is true, binary format (more compact and much faster) is used.
6672 \end_layout
6674 \begin_layout Subsection
6675 movie.unserialize: Unserialize movie
6676 \end_layout
6678 \begin_layout Itemize
6679 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
6680  bool binary)
6681 \end_layout
6683 \begin_layout Standard
6684 Unserialize movie from file.
6685  The given frame is used as template to decide the frame type.
6686  If binary is true, binary format is decoded (much faster).
6687 \end_layout
6689 \begin_layout Subsection
6690 movie.current_first_subframe: Return first subframe in current frame
6691 \end_layout
6693 \begin_layout Itemize
6694 Syntax: number movie.current_first_subframe()
6695 \end_layout
6697 \begin_layout Standard
6698 Returns first subframe in current frame.
6699 \end_layout
6701 \begin_layout Subsection
6702 movie.pollcounter: Return poll counter for speified control
6703 \end_layout
6705 \begin_layout Itemize
6706 Syntax: number movie.pollcounter(number port, number controller, number control)
6707 \end_layout
6709 \begin_layout Standard
6710 Returns number of times the specified control has been polled this frame.
6711 \end_layout
6713 \begin_layout Subsection
6714 movie.current_branch: Return current branch
6715 \end_layout
6717 \begin_layout Itemize
6718 Syntax: string movie.current_branch()
6719 \end_layout
6721 \begin_layout Standard
6722 Returns the name of the current branch.
6723 \end_layout
6725 \begin_layout Subsection
6726 movie.get_branches: Return names of all branches
6727 \end_layout
6729 \begin_layout Itemize
6730 Syntax: string...
6731  movie.get_branches()
6732 \end_layout
6734 \begin_layout Standard
6735 Returns the name of all branches.
6736 \end_layout
6738 \begin_layout Subsection
6739 INPUTFRAME::get_button: Get button
6740 \end_layout
6742 \begin_layout Itemize
6743 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
6744  control)
6745 \end_layout
6747 \begin_layout Standard
6748 Returns state of given button as boolean.
6749 \end_layout
6751 \begin_layout Subsection
6752 INPUTFRAME::get_axis: Get axis
6753 \end_layout
6755 \begin_layout Itemize
6756 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
6757  control)
6758 \end_layout
6760 \begin_layout Standard
6761 Returns state of given axis as number.
6762 \end_layout
6764 \begin_layout Subsection
6765 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
6766 \end_layout
6768 \begin_layout Itemize
6769 Syntax: none INPUTFRAME::set_button(number port, number controller, number
6770  control, number/bool value)
6771 \end_layout
6773 \begin_layout Itemize
6774 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
6775  control)
6776 \end_layout
6778 \begin_layout Standard
6779 Set the given button/axis to given value.
6780 \end_layout
6782 \begin_layout Subsection
6783 INPUTFRAME::serialize: Serialize a frame
6784 \end_layout
6786 \begin_layout Itemize
6787 Syntax: string INPUTFRAME::serialize()
6788 \end_layout
6790 \begin_layout Standard
6791 Return string representation of frame.
6792 \end_layout
6794 \begin_layout Subsection
6795 INPUTFRAME::unserialize: Unserialize a frame
6796 \end_layout
6798 \begin_layout Itemize
6799 Syntax: none INPUTFRAME::unserialize(string data)
6800 \end_layout
6802 \begin_layout Standard
6803 Set current frame from given data.
6804 \end_layout
6806 \begin_layout Subsection
6807 INPUTFRAME::get_stride: Get movie stride
6808 \end_layout
6810 \begin_layout Itemize
6811 Syntax: number INPUTFRAME::get_stride()
6812 \end_layout
6814 \begin_layout Standard
6815 Return number of bytes needed to store the input frame.
6816  Mainly useful for some debugging.
6817 \end_layout
6819 \begin_layout Standard
6820 \begin_inset Newpage pagebreak
6821 \end_inset
6824 \end_layout
6826 \begin_layout Section
6827 Table settings
6828 \end_layout
6830 \begin_layout Standard
6831 Routines for settings manipulation
6832 \end_layout
6834 \begin_layout Subsection
6835 settings.get: Get value of setting
6836 \end_layout
6838 \begin_layout Itemize
6839 Syntax: string settings.get(string name)
6840 \end_layout
6842 \begin_layout Standard
6843 Get value of setting <name>.
6844  If setting value can't be obtained, returns (nil, error message).
6845 \end_layout
6847 \begin_layout Subsection
6848 settings.set: Set value of setting
6849 \end_layout
6851 \begin_layout Itemize
6852 Syntax: none settings.set(string name, string value)
6853 \end_layout
6855 \begin_layout Standard
6856 Set value <value> of setting <name>.
6857  If setting can't be set, returns (nil, error message).
6858 \end_layout
6860 \begin_layout Subsection
6861 settings.get_all: Get values of all settings
6862 \end_layout
6864 \begin_layout Itemize
6865 Syntax: table settings.get_all()
6866 \end_layout
6868 \begin_layout Standard
6869 Return a table with all setting names as keys and all current values as
6870  values.
6871 \end_layout
6873 \begin_layout Subsection
6874 settings.get_speed: Get current speed
6875 \end_layout
6877 \begin_layout Itemize
6878 Syntax: number/string settings.get_speed()
6879 \end_layout
6881 \begin_layout Standard
6882 Return the current speed multiplier (1 is normal), or 
6883 \begin_inset Quotes eld
6884 \end_inset
6886 turbo
6887 \begin_inset Quotes erd
6888 \end_inset
6890  if speed is set to turbo (this does not react to turbo toggle).
6891 \end_layout
6893 \begin_layout Subsection
6894 settings.set_speed: Set current speed
6895 \end_layout
6897 \begin_layout Itemize
6898 Syntax: settings.get_speed(number spd)
6899 \end_layout
6901 \begin_layout Itemize
6902 Syntax: settings.get_speed(string special)
6903 \end_layout
6905 \begin_layout Standard
6906 Set the current speed multiplier (1 is normal).
6907  The speed may be positive multiplier or 
6908 \begin_inset Quotes eld
6909 \end_inset
6911 turbo
6912 \begin_inset Quotes erd
6913 \end_inset
6915  for turbo speed.
6916 \end_layout
6918 \begin_layout Standard
6919 \begin_inset Newpage pagebreak
6920 \end_inset
6923 \end_layout
6925 \begin_layout Section
6926 Table memory
6927 \end_layout
6929 \begin_layout Standard
6930 Contains various functions for managing memory
6931 \end_layout
6933 \begin_layout Subsection
6934 memory.vma_count: Count number of memory areas.
6935 \end_layout
6937 \begin_layout Itemize
6938 Syntax: number memory.vma_count()
6939 \end_layout
6941 \begin_layout Standard
6942 Returns the number of memory areas
6943 \end_layout
6945 \begin_layout Subsection
6946 memory.read_vma: Lookup memory area info by index
6947 \end_layout
6949 \begin_layout Itemize
6950 Syntax: table memory.read_vma(number index)
6951 \end_layout
6953 \begin_layout Standard
6954 Reads the specified memory area (indices start from zero).
6955  Trying to read invalid memory area gives nil.
6956  The return value is table with the following fields:
6957 \end_layout
6959 \begin_layout Itemize
6960 region_name (string): The readable name of the memory area
6961 \end_layout
6963 \begin_layout Itemize
6964 baseaddr (number): Base address of the memory area
6965 \end_layout
6967 \begin_layout Itemize
6968 lastaddr (number): Last address in the memory area.
6969 \end_layout
6971 \begin_layout Itemize
6972 size (number): The size of memory area in bytes.
6973 \end_layout
6975 \begin_layout Itemize
6976 readonly (boolean): True of the memory area corresponds to ROM.
6977 \end_layout
6979 \begin_layout Itemize
6980 iospace (boolean): True if the memory area is I/O space.
6981 \end_layout
6983 \begin_layout Itemize
6984 native_endian (boolean): True if the memory area has native endian as opposed
6985  to little endian.
6986 \end_layout
6988 \begin_layout Subsection
6989 memory.find_vma: Find memory area info by address
6990 \end_layout
6992 \begin_layout Itemize
6993 Syntax: table memory.find_vma(number address)
6994 \end_layout
6996 \begin_layout Standard
6997 Finds the memory area containing specified address.
6998  Returns table in the same format as read_vma or nil if not found.
6999 \end_layout
7001 \begin_layout Subsection
7002 memory.read{,s}{byte,{,h,d,q}word}: Read memory
7003 \end_layout
7005 \begin_layout Itemize
7006 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
7007 \end_layout
7009 \begin_layout Itemize
7010 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
7011 \end_layout
7013 \begin_layout Itemize
7014 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
7015 \end_layout
7017 \begin_layout Itemize
7018 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
7019 \end_layout
7021 \begin_layout Itemize
7022 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
7023 \end_layout
7025 \begin_layout Itemize
7026 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
7027 \end_layout
7029 \begin_layout Itemize
7030 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
7031 \end_layout
7033 \begin_layout Itemize
7034 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
7035 \end_layout
7037 \begin_layout Itemize
7038 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
7039 \end_layout
7041 \begin_layout Itemize
7042 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
7043 \end_layout
7045 \begin_layout Standard
7046 Reads the specified address <address> (if 's' variant is used, do undergo
7047  2's complement).
7048 \end_layout
7050 \begin_layout Subsection
7051 memory.{,s}read_sg: Scatter/Gather read memory
7052 \end_layout
7054 \begin_layout Itemize
7055 Syntax: none memory.read_sg(string/boolean/number...)
7056 \end_layout
7058 \begin_layout Itemize
7059 Syntax: none memory.sread_sg(string/boolean/number...)
7060 \end_layout
7062 \begin_layout Standard
7063 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
7064  of memory.
7065  Each argument can be string, boolean or number:
7066 \end_layout
7068 \begin_layout Itemize
7069 String: Set memory area addresses are relative to (e.g.
7070  'WRAM').
7071 \end_layout
7073 \begin_layout Itemize
7074 boolean: If true, increment relative address by 1, if false, decrement by
7075  1.
7076  The new address is read as next higher byte.
7077 \end_layout
7079 \begin_layout Itemize
7080 integer: Set the relative address to specified value and read the address
7081  as next higher byte.
7082 \end_layout
7084 \begin_layout Subsection
7085 memory.write_sg: Scatter/Gather write memory
7086 \end_layout
7088 \begin_layout Itemize
7089 Syntax: none memory.write_sg(number value, string/boolean/number...)
7090 \end_layout
7092 \begin_layout Standard
7093 Perform scatter/gather write of value <value> on memory.
7094  Each argument can be string, boolean or number:
7095 \end_layout
7097 \begin_layout Itemize
7098 String: Set memory area addresses are relative to (e.g.
7099  'WRAM').
7100 \end_layout
7102 \begin_layout Itemize
7103 boolean: If true, increment relative address by 1, if false, decrement by
7104  1.
7105  The new address is read as next higher byte.
7106 \end_layout
7108 \begin_layout Itemize
7109 integer: Set the relative address to specified value and read the address
7110  as next higher byte.
7111 \end_layout
7113 \begin_layout Subsection
7114 memory.read{float,double}: Read memory
7115 \end_layout
7117 \begin_layout Itemize
7118 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7119 \end_layout
7121 \begin_layout Itemize
7122 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7123 \end_layout
7125 \begin_layout Standard
7126 Reads the specified address <address>
7127 \end_layout
7129 \begin_layout Subsection
7130 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7131 \end_layout
7133 \begin_layout Itemize
7134 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7135  number value)
7136 \end_layout
7138 \begin_layout Itemize
7139 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7140  number value)
7141 \end_layout
7143 \begin_layout Itemize
7144 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7145  number value)
7146 \end_layout
7148 \begin_layout Itemize
7149 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7150  number value)
7151 \end_layout
7153 \begin_layout Itemize
7154 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7155  number value)
7156 \end_layout
7158 \begin_layout Itemize
7159 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7160  number value)
7161 \end_layout
7163 \begin_layout Itemize
7164 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7165  number value)
7166 \end_layout
7168 \begin_layout Standard
7169 Writes the specified value <value> (negative integer values undergo 2's
7170  complement) to specified address <address>.
7171 \end_layout
7173 \begin_layout Subsection
7174 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7175 \end_layout
7177 \begin_layout Itemize
7178 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7179  number size)
7180 \end_layout
7182 \begin_layout Standard
7183 Returns a table mapping specified memory aperture for read/write.
7184 \end_layout
7186 \begin_layout Itemize
7187 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7188  qword, sqword, float or double.
7189 \end_layout
7191 \begin_layout Subsection
7192 memory.hash_region: Hash region of memory
7193 \end_layout
7195 \begin_layout Itemize
7196 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7197  number size)
7198 \end_layout
7200 \begin_layout Standard
7201 Hash <size> bytes starting from address <base> (relative to <marea>) and
7202  return the SHA-256.
7203 \end_layout
7205 \begin_layout Subsection
7206 memory.hash_region2: Hash region of memory
7207 \end_layout
7209 \begin_layout Itemize
7210 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7211  number size[, number rows, number stride])
7212 \end_layout
7214 \begin_layout Standard
7215 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7216  to <marea>).
7217  The blocks are offset by <stride> from one another and return the SHA-256.
7218 \end_layout
7220 \begin_layout Subsection
7221 memory.hash_region_skein: Hash region of memory
7222 \end_layout
7224 \begin_layout Itemize
7225 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7226  addrobj}, number size[, number rows, number stride])
7227 \end_layout
7229 \begin_layout Standard
7230 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7231  finalists) as hash function.
7232 \end_layout
7234 \begin_layout Subsection
7235 memory.store: Store region of memory
7236 \end_layout
7238 \begin_layout Itemize
7239 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7240  daddr[, number rows, number stride]
7241 \end_layout
7243 \begin_layout Standard
7244 Copy memory starting from <addr> in memory area <marea> (each row being
7245  of size <size>, there being <rows> rows, and rows being separated by <stride>
7246  in memory) into savestate-saved memory area, starting from <daadr> (all
7247  rows are written back to back).
7248 \end_layout
7250 \begin_layout Subsection
7251 memory.storecmp: Compare and store region of memory
7252 \end_layout
7254 \begin_layout Itemize
7255 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7256  number daddr[, number rows, number stride]
7257 \end_layout
7259 \begin_layout Standard
7260 Like memory.store, but returns true if target of copy already held the value
7261  that would be copied before the copy happened.
7262  Otherwise returns false (if target and source differ before copy).
7263 \end_layout
7265 \begin_layout Subsection
7266 memory.hash_state: Hash system state
7267 \end_layout
7269 \begin_layout Itemize
7270 Syntax: string memory.hash_state()
7271 \end_layout
7273 \begin_layout Standard
7274 Hash the current system state.
7275  Mainly useful for debugging savestates.
7276 \end_layout
7278 \begin_layout Subsection
7279 memory.readregion: Read region of memory
7280 \end_layout
7282 \begin_layout Itemize
7283 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7284  number size)
7285 \end_layout
7287 \begin_layout Standard
7288 Read a region of memory.
7289 \end_layout
7291 \begin_layout Itemize
7292 Warning: If the region crosses memory area boundary, the results are undefined.
7293 \end_layout
7295 \begin_layout Subsection
7296 memory.writeregion: Write region of memory
7297 \end_layout
7299 \begin_layout Itemize
7300 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7301  number size, table data)
7302 \end_layout
7304 \begin_layout Standard
7305 Write a region of memory.
7306 \end_layout
7308 \begin_layout Itemize
7309 Warning: If the region crosses memory area boundary, the results are undefined.
7310 \end_layout
7312 \begin_layout Subsection
7313 memory.action: Run core action
7314 \end_layout
7316 \begin_layout Itemize
7317 memory.action(string action, [<params>])
7318 \end_layout
7320 \begin_layout Standard
7321 Run core action.
7322  The different models expect parameters as:
7323 \end_layout
7325 \begin_layout Itemize
7326 string: String
7327 \end_layout
7329 \begin_layout Itemize
7330 numeric: numeric
7331 \end_layout
7333 \begin_layout Itemize
7334 enumeration: String
7335 \end_layout
7337 \begin_layout Itemize
7338 boolean: String
7339 \end_layout
7341 \begin_layout Itemize
7342 toggle: None.
7343 \end_layout
7345 \begin_layout Subsection
7346 memory.action_flags: Get core action flags
7347 \end_layout
7349 \begin_layout Itemize
7350 memory.action_flags(string action)
7351 \end_layout
7353 \begin_layout Standard
7354 Get value of action flags for core action <action>.
7355 \end_layout
7357 \begin_layout Itemize
7358 Bit 0: Enabled?
7359 \end_layout
7361 \begin_layout Itemize
7362 Bit 1: Selected (not all actions can be selected)?
7363 \end_layout
7365 \begin_layout Subsection
7366 memory.get_lag_flag: Get lag flag
7367 \end_layout
7369 \begin_layout Itemize
7370 Syntax: boolean memory.get_lag_flag()
7371 \end_layout
7373 \begin_layout Standard
7374 Get the value of core lag flag.
7375  True if this frame has been lag so far, false if poll has been detected.
7376 \end_layout
7378 \begin_layout Subsection
7379 memory.set_lag_flag: Set lag flag
7380 \end_layout
7382 \begin_layout Itemize
7383 Syntax: none memory.set_lag_flag(boolean flag)
7384 \end_layout
7386 \begin_layout Standard
7387 Set the value of core lag flag.
7388  This flag automatically gets cleared if poll is detected, but can be forcibly
7389  set or cleared if game so requires.
7390 \end_layout
7392 \begin_layout Itemize
7393 Should only be used in on_frame_emulated callback.
7394 \end_layout
7396 \begin_layout Itemize
7397 Setting or clearing this affects the emulator lag counter.
7398 \end_layout
7400 \begin_layout Subsection
7401 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7402  callback
7403 \end_layout
7405 \begin_layout Itemize
7406 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
7407  function fn);
7408 \end_layout
7410 \begin_layout Itemize
7411 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
7412  addrobj}, function fn);
7413 \end_layout
7415 \begin_layout Itemize
7416 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
7417  function fn);
7418 \end_layout
7420 \begin_layout Itemize
7421 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
7422  function fn);
7423 \end_layout
7425 \begin_layout Itemize
7426 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
7427  function fn);
7428 \end_layout
7430 \begin_layout Itemize
7431 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
7432  function fn);
7433 \end_layout
7435 \begin_layout Standard
7436 Add or remove callback on memory read, write or execute (depending on the
7437  function).
7438  <addr> is relative to <marea>.
7439  <fn> is the callback.
7440  The register* functions return <fn> (which can then be passed to unregister*
7441  functions.
7442 \end_layout
7444 \begin_layout Itemize
7445 Not all cores support this, and it may be unsupported for some memory areas.
7446 \end_layout
7448 \begin_layout Itemize
7449 The functions are passed two parameters: Address and value.
7450 \end_layout
7452 \begin_layout Subsection
7453 memory.{,un}registertrace: Set/Clear trace hook
7454 \end_layout
7456 \begin_layout Itemize
7457 Syntax: function memory.registertrace(number processor, function fn);
7458 \end_layout
7460 \begin_layout Itemize
7461 Syntax: none memory.unregistertrace(number processor, function fn);
7462 \end_layout
7464 \begin_layout Standard
7465 Add or remove trace callback.
7466  <processor> is system-dependent processor number (0 is usually main CPU).
7467  The function arguments work like in other (un)register* functions.
7468 \end_layout
7470 \begin_layout Itemize
7471 The functions are passed two parameters: Trace CPU and Trace event string.
7472 \end_layout
7474 \begin_layout Subsection
7475 memory.cheat: Set cheat
7476 \end_layout
7478 \begin_layout Itemize
7479 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
7480  value);
7481 \end_layout
7483 \begin_layout Itemize
7484 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
7485 \end_layout
7487 \begin_layout Standard
7488 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
7489  If <value> is not speicified, clear a cheat.
7490 \end_layout
7492 \begin_layout Itemize
7493 Not all cores support this, and it may be unsupported for some memory areas.
7494 \end_layout
7496 \begin_layout Subsection
7497 memory.setxmask: Set global execute hook mask
7498 \end_layout
7500 \begin_layout Itemize
7501 Syntax: none memory.setxmask(number mask)
7502 \end_layout
7504 \begin_layout Standard
7505 Set the global execute hook mask to <mask>.
7506  The meaning of each bit is system-dependent, but bit 0 should be the main
7507  CPU.
7508 \end_layout
7510 \begin_layout Subsection
7511 memory.getregister: Get register value
7512 \end_layout
7514 \begin_layout Itemize
7515 Syntax: number/boolean memory.getregister(string register)
7516 \end_layout
7518 \begin_layout Standard
7519 Get the value of named register.
7520 \end_layout
7522 \begin_layout Subsection
7523 memory.getregisters: Get register values
7524 \end_layout
7526 \begin_layout Itemize
7527 Syntax: table memory.getregisters()
7528 \end_layout
7530 \begin_layout Standard
7531 Get the value of all known registers as table.
7532 \end_layout
7534 \begin_layout Subsection
7535 memory.setregister: Set register value
7536 \end_layout
7538 \begin_layout Itemize
7539 Syntax: none memory.setregister(string register, number/boolean value)
7540 \end_layout
7542 \begin_layout Standard
7543 Set the value of named register.
7544 \end_layout
7546 \begin_layout Subsection
7547 memory.mmap: Class MMAP_STRUCT
7548 \end_layout
7550 \begin_layout Standard
7551 See class MMAP_STRUCT
7552 \end_layout
7554 \begin_layout Standard
7555 \begin_inset Newpage pagebreak
7556 \end_inset
7559 \end_layout
7561 \begin_layout Section
7562 Table memory2
7563 \end_layout
7565 \begin_layout Standard
7566 Contains newer memory functions.
7567 \end_layout
7569 \begin_layout Subsection
7570 memory2(): Get all memory area names.
7571 \end_layout
7573 \begin_layout Itemize
7574 Syntax: table memory2()
7575 \end_layout
7577 \begin_layout Standard
7578 Returns array of all valid memory area names.
7579 \end_layout
7581 \begin_layout Subsection
7582 memory2.<marea>:info: Get memory area info
7583 \end_layout
7585 \begin_layout Itemize
7586 Syntax: table memory2.<marea>:info()
7587 \end_layout
7589 \begin_layout Standard
7590 Return table describing given memory area.
7591  Includes fields address, size, last, readonly, special and endian.
7592 \end_layout
7594 \begin_layout Subsection
7595 memory2.<marea>:<op>: Read/Write memory
7596 \end_layout
7598 \begin_layout Itemize
7599 Syntax: none memory2.<marea>:<op>(number offset, number value)
7600 \end_layout
7602 \begin_layout Itemize
7603 Syntax: number memory2.<marea>:<op>(number offset)
7604 \end_layout
7606 \begin_layout Standard
7607 Read/Write value from/to given memory area <marea> at given offset <offset>
7608  (must be in-range).
7609  The value written is <value>.
7610  <Op> is of form: [i][s]<type>, where:
7611 \end_layout
7613 \begin_layout Itemize
7614 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
7615 \end_layout
7617 \begin_layout Itemize
7618 'i' signifies that the value is treated as opposite-to-normal endianess,
7619 \end_layout
7621 \begin_layout Itemize
7622 's' signifies that value is treated as signed (not available for floating-point).
7623 \end_layout
7625 \begin_layout Subsection
7626 memory2.<marea>:read: Scatter-gather value read
7627 \end_layout
7629 \begin_layout Itemize
7630 Syntax: number memory2.<marea>:read(number addr...)
7631 \end_layout
7633 \begin_layout Standard
7634 Read value from given memory area <marea> at byte offsets <addr>..., given
7635  in order of increasing significance.
7636  Value of true and false are special.
7637  True increments address by 1, and false decrements address by 1.
7638 \end_layout
7640 \begin_layout Subsection
7641 memory2.<marea>:sread: Signed scatter-gather value read
7642 \end_layout
7644 \begin_layout Itemize
7645 Syntax: number memory2.<marea>:sread(number addr...)
7646 \end_layout
7648 \begin_layout Standard
7649 Like memory2.<marea>:read, but reads signed values.
7650 \end_layout
7652 \begin_layout Subsection
7653 memory2.<marea>:write: Scatter-gather value write
7654 \end_layout
7656 \begin_layout Itemize
7657 Syntax: number memory2.<marea>:write(number val, number addr...)
7658 \end_layout
7660 \begin_layout Standard
7661 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
7662  in order of increasing significance.
7663  Value of true and false are special.
7664  True increments address by 1, and false decrements address by 1.
7665 \end_layout
7667 \begin_layout Subsection
7668 memory2.<marea>:cheat: Set/Clear cheat
7669 \end_layout
7671 \begin_layout Itemize
7672 Syntax: none memory2.<marea>:cheat(number addr, [number value])
7673 \end_layout
7675 \begin_layout Standard
7676 Set/Clear cheat at offset <addr> of memory area <marea>.
7677  If <value> is given, cheat with specified value is set.
7678  Otherwise cheat on address is removed.
7679 \end_layout
7681 \begin_layout Subsection
7682 memory2.<marea>:sha256: SHA-256
7683 \end_layout
7685 \begin_layout Itemize
7686 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
7687  number stride])
7688 \end_layout
7690 \begin_layout Standard
7691 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
7692  from offset <addr> of area <marea>.
7693  The chunks are separated by <stride>.
7694 \end_layout
7696 \begin_layout Subsection
7697 memory2.<marea>:skein: Skein-512-256
7698 \end_layout
7700 \begin_layout Itemize
7701 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
7702  number stride])
7703 \end_layout
7705 \begin_layout Standard
7706 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
7707 \end_layout
7709 \begin_layout Subsection
7710 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
7711 \end_layout
7713 \begin_layout Itemize
7714 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
7715  number rows, number stride])
7716 \end_layout
7718 \begin_layout Itemize
7719 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
7720  size[, number rows, number stride])
7721 \end_layout
7723 \begin_layout Standard
7724 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
7725  <addr> of area <marea>.
7726  The chunks are separated by <stride>.
7727  The target is Lua host memory, starting from offset <daddr>.
7728 \end_layout
7730 \begin_layout Standard
7731 Additionally, the storecmp method returns false if target was modified (otherwis
7732 e true).
7733 \end_layout
7735 \begin_layout Subsection
7736 memory2.<marea>:readregion: Read region
7737 \end_layout
7739 \begin_layout Itemize
7740 Syntax table memory2.<marea>:readregion(number addr, number size)
7741 \end_layout
7743 \begin_layout Standard
7744 Read <size> bytes starting from <addr> in <marea> and return as array.
7745 \end_layout
7747 \begin_layout Subsection
7748 memory2.<marea>:writeregion: Write region
7749 \end_layout
7751 \begin_layout Itemize
7752 Syntax none memory2.<marea>:writeregion(number addr, table data)
7753 \end_layout
7755 \begin_layout Standard
7756 Write array <data> to bytes starting from <addr> in <marea>.
7757 \end_layout
7759 \begin_layout Subsection
7760 memory2.<marea>:register{read,write,exec}: Register hook
7761 \end_layout
7763 \begin_layout Itemize
7764 Syntax: function memory2.<marea>:registerread(number addr, function fn);
7765 \end_layout
7767 \begin_layout Itemize
7768 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
7769 \end_layout
7771 \begin_layout Itemize
7772 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
7773 \end_layout
7775 \begin_layout Standard
7776 Register debug callback <fn> of specified type at offset <addr> of memory
7777  area <marea>.
7778  Returns <fn>.
7779 \end_layout
7781 \begin_layout Subsection
7782 memory2.<marea>:unregister{read,write,exec}: Unregister hook
7783 \end_layout
7785 \begin_layout Itemize
7786 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
7787 \end_layout
7789 \begin_layout Itemize
7790 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
7791 \end_layout
7793 \begin_layout Itemize
7794 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
7795 \end_layout
7797 \begin_layout Standard
7798 Unregister debug callback <fn> of specified type at offset <addr> of memory
7799  area <marea>.
7800 \end_layout
7802 \begin_layout Standard
7803 \begin_inset Newpage pagebreak
7804 \end_inset
7807 \end_layout
7809 \begin_layout Section
7810 Table random
7811 \end_layout
7813 \begin_layout Standard
7814 Contains random number generation methods.
7815  These functions do not return reproducable results.
7816 \end_layout
7818 \begin_layout Subsection
7819 random.boolean: Random boolean
7820 \end_layout
7822 \begin_layout Itemize
7823 Syntax: boolean random.boolean()
7824 \end_layout
7826 \begin_layout Standard
7827 Returns true or false at random (50-50 chance).
7828 \end_layout
7830 \begin_layout Subsection
7831 random.integer: Random integer
7832 \end_layout
7834 \begin_layout Itemize
7835 Syntax: number random.integer(number highplusone)
7836 \end_layout
7838 \begin_layout Itemize
7839 Syntax: number random.integer(number low, number high)
7840 \end_layout
7842 \begin_layout Standard
7843 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
7844  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
7845 \end_layout
7847 \begin_layout Standard
7848 The returned numbers are from uniform distribution.
7849 \end_layout
7851 \begin_layout Subsection
7852 random.float: Random float
7853 \end_layout
7855 \begin_layout Itemize
7856 Syntax: number random.float()
7857 \end_layout
7859 \begin_layout Standard
7860 Returns random decimal number [0,1).
7861 \end_layout
7863 \begin_layout Subsection
7864 random.among: Random parameter
7865 \end_layout
7867 \begin_layout Itemize
7868 Syntax: value random.among(value values...)
7869 \end_layout
7871 \begin_layout Standard
7872 Returns random parameter value, picked at uniform.
7873  Multiple equivalent values are returned with higher chance.
7874 \end_layout
7876 \begin_layout Subsection
7877 random.amongtable: Random from table
7878 \end_layout
7880 \begin_layout Itemize
7881 Syntax: value random.amongtable(table tab)
7882 \end_layout
7884 \begin_layout Standard
7885 Returns random value from table <tab>.
7886  As in random.among, no equality testing is done.
7887 \end_layout
7889 \begin_layout Standard
7890 \begin_inset Newpage pagebreak
7891 \end_inset
7894 \end_layout
7896 \begin_layout Section
7897 Table zip
7898 \end_layout
7900 \begin_layout Subsection
7901 zip.enumerate: Enumerate members in zipfile
7902 \end_layout
7904 \begin_layout Itemize
7905 Syntax: Table zip.enumerate(string filename[, boolean invert])
7906 \end_layout
7908 \begin_layout Standard
7909 Returns table of files in zip archive <filename>.
7910  If <invert> is true, instead of returning array of names, returns table
7911  with keys being member names and values being true.
7912 \end_layout
7914 \begin_layout Subsection
7915 zip.writer: Class ZIPWRITER
7916 \end_layout
7918 \begin_layout Standard
7919 See class ZIPWRITER.
7920 \end_layout
7922 \begin_layout Standard
7923 \begin_inset Newpage pagebreak
7924 \end_inset
7927 \end_layout
7929 \begin_layout Section
7930 Table callback
7931 \end_layout
7933 \begin_layout Standard
7934 Various callback-related functions.
7935 \end_layout
7937 \begin_layout Subsection
7938 \begin_inset CommandInset label
7939 LatexCommand label
7940 name "sub:callback.register:-Register-a"
7942 \end_inset
7944 callback.register: Register a callback
7945 \end_layout
7947 \begin_layout Itemize
7948 Syntax: function callback.register(string cbname, function cbfun);
7949 \end_layout
7951 \begin_layout Standard
7952 Instruct function <cbfun> to be added to list of callbacks to call on event
7953  <cbname> (See section 
7954 \begin_inset CommandInset ref
7955 LatexCommand ref
7956 reference "sec:Callbacks"
7958 \end_inset
7961  The callback name does not have the 'on_' prefix (e.g.
7963 \begin_inset Quotes eld
7964 \end_inset
7966 paint
7967 \begin_inset Quotes erd
7968 \end_inset
7971  Returns <cbfun>.
7972 \end_layout
7974 \begin_layout Subsection
7975 \begin_inset CommandInset label
7976 LatexCommand label
7977 name "sub:callback.unregister:-Unregister-"
7979 \end_inset
7981 callback.unregister: Unregister a callback
7982 \end_layout
7984 \begin_layout Itemize
7985 Syntax: function callback.unregister(string cbname, function cbfun);
7986 \end_layout
7988 \begin_layout Standard
7989 Instruct function <cbfun> to be removed from list of callbacks to call on
7990  event <cbname>.
7991 \end_layout
7993 \begin_layout Subsection
7994 callback.<cbname>:register: Register callback
7995 \end_layout
7997 \begin_layout Itemize
7998 Syntax: function callback.<cbname>:register(function cbfun)
7999 \end_layout
8001 \begin_layout Standard
8002 Synonym for callback.register (section 
8003 \begin_inset CommandInset ref
8004 LatexCommand ref
8005 reference "sub:callback.register:-Register-a"
8007 \end_inset
8009 ), albeit with callback name specified differently.
8010 \end_layout
8012 \begin_layout Subsection
8013 callback.<cbname>:unregister: Register callback
8014 \end_layout
8016 \begin_layout Itemize
8017 Syntax: function callback.<cbname>:unregister(function cbfun)
8018 \end_layout
8020 \begin_layout Standard
8021 Synonym for callback.unregister (section 
8022 \begin_inset CommandInset ref
8023 LatexCommand ref
8024 reference "sub:callback.unregister:-Unregister-"
8026 \end_inset
8028 ), albeit with callback name specified differently.
8029 \end_layout
8031 \begin_layout Section
8032 table bsnes
8033 \end_layout
8035 \begin_layout Standard
8036 Various bsnes-specific functions.
8037 \end_layout
8039 \begin_layout Subsection
8040 bsnes.dump_sprite: Dump a sprite
8041 \end_layout
8043 \begin_layout Itemize
8044 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
8045  number height[, number stride])
8046 \end_layout
8048 \begin_layout Standard
8049 Dumps given sprite (in native format) from memory.
8050  memory area is usually 
8051 \begin_inset Quotes eld
8052 \end_inset
8054 VRAM
8055 \begin_inset Quotes erd
8056 \end_inset
8059  <Width> and <height> are given in 8x8 blocks.
8060  <Stride> overrides row stride (default 512).
8061 \end_layout
8063 \begin_layout Subsection
8064 bsnes.dump_palette: Dump a palette
8065 \end_layout
8067 \begin_layout Itemize
8068 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool full256,
8069  bool first_trans)
8070 \end_layout
8072 \begin_layout Standard
8073 Dumps a palette from memory.
8074  memory area is usually 
8075 \begin_inset Quotes eld
8076 \end_inset
8078 CGRAM
8079 \begin_inset Quotes erd
8080 \end_inset
8083  If <full256> is true, 256 colors are dumped (otherwise 16).
8084  If <first_trans> is true, first color is forced transparent.
8085 \end_layout
8087 \begin_layout Subsection
8088 bsnes.enablelayer: Set layer visibility
8089 \end_layout
8091 \begin_layout Itemize
8092 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8093 \end_layout
8095 \begin_layout Standard
8096 Enable or disable specified layer at specified priority.
8097 \end_layout
8099 \begin_layout Subsection
8100 bsnes.redump_sprite: Redump a sprite
8101 \end_layout
8103 \begin_layout Itemize
8104 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8105  number stride])
8106 \end_layout
8108 \begin_layout Standard
8109 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8110  The specified bitmap must have size multiple of 8x8.
8111 \end_layout
8113 \begin_layout Subsection
8114 bsnes.redump_palette: Redump a palette
8115 \end_layout
8117 \begin_layout Itemize
8118 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8119  first_trans)
8120 \end_layout
8122 \begin_layout Standard
8123 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8124  The specified palette must have either 16 or 256 colors.
8125 \end_layout
8127 \begin_layout Section
8128 extensions to table string
8129 \end_layout
8131 \begin_layout Subsection
8132 string.charU: string.char, UTF-8 version.
8133 \end_layout
8135 \begin_layout Itemize
8136 Syntax: string string.charU(number n...)
8137 \end_layout
8139 \begin_layout Standard
8140 Like Lua string.char(), but works in terms of Unicode codepoints.
8141  The returned string is UTF-8.
8142 \end_layout
8144 \begin_layout Subsection
8145 string.byteU: string.byte, UTF-8 version.
8146 \end_layout
8148 \begin_layout Itemize
8149 Syntax: number...
8150  string.byteU(string str[, number i[, number j]])
8151 \end_layout
8153 \begin_layout Standard
8154 Like string.byte(), but works in terms of Unicode codepoints.
8155  The input string <str> is assumed UTF-8.
8156 \end_layout
8158 \begin_layout Subsection
8159 string.regex: Match string against regular expression
8160 \end_layout
8162 \begin_layout Itemize
8163 Syntax: boolean/string...
8164  string.regex(string regexp, string against)
8165 \end_layout
8167 \begin_layout Standard
8168 Match POSIX-extended regular expression <regexp> against string <against>.
8169  If no match, false is returned.
8170  Otherwise if string has no subcaptures, true is returned.
8171  Otherwise each subcapture is returned as a string (in order of starting
8172  position).
8173 \end_layout
8175 \begin_layout Subsection
8176 string.hex: Transform integer into hex string
8177 \end_layout
8179 \begin_layout Itemize
8180 Syntax: string string.hex(number n, [number digits])
8181 \end_layout
8183 \begin_layout Standard
8184 Returns hexadecimal string representation of <n>, optionally padded with
8185  zeroes to <digits> digits (default is not to pad).
8186 \end_layout
8188 \begin_layout Subsection
8189 string.lpad: Pad string with spaces from left
8190 \end_layout
8192 \begin_layout Itemize
8193 Syntax: string string.lpad(string x, number n)
8194 \end_layout
8196 \begin_layout Standard
8197 Pad string <x> to <n> bytes by inserting spaces at start and return the
8198  result.
8199 \end_layout
8201 \begin_layout Subsection
8202 string.rpad: Pad string with spaces from right
8203 \end_layout
8205 \begin_layout Itemize
8206 Syntax: string string.rpad(string x, number n)
8207 \end_layout
8209 \begin_layout Standard
8210 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8211 \end_layout
8213 \begin_layout Section
8214 Table _SYSTEM
8215 \end_layout
8217 \begin_layout Standard
8218 Contains copy of global variables from time of Lua initialization.
8219  Non-writeable.
8220 \end_layout
8222 \begin_layout Standard
8223 \begin_inset Newpage pagebreak
8224 \end_inset
8227 \end_layout
8229 \begin_layout Section
8230 \begin_inset CommandInset label
8231 LatexCommand label
8232 name "sec:Callbacks"
8234 \end_inset
8236 Callbacks
8237 \end_layout
8239 \begin_layout Standard
8240 Various callbacks to Lua that can occur.
8241 \end_layout
8243 \begin_layout Subsection
8244 on_paint: Screen is being painted
8245 \end_layout
8247 \begin_layout Itemize
8248 Callback: on_paint(bool not_synth)
8249 \end_layout
8251 \begin_layout Standard
8252 Called when screen is being painted.
8253  Any gui.* calls requiring graphic context draw on the screen.
8254 \end_layout
8256 \begin_layout Itemize
8257 not_synth is true if this hook is being called in response to received frame,
8258  false otherwise.
8259 \end_layout
8261 \begin_layout Subsection
8262 on_video: Dumped video frame is being painted
8263 \end_layout
8265 \begin_layout Itemize
8266 Callback: on_video()
8267 \end_layout
8269 \begin_layout Standard
8270 Called when video dump frame is being painted.
8271  Any gui.* calls requiring graphic context draw on the video.
8272 \end_layout
8274 \begin_layout Subsection
8275 on_frame_emulated: Frame emulation complete
8276 \end_layout
8278 \begin_layout Itemize
8279 Callback: on_frame_emulated()
8280 \end_layout
8282 \begin_layout Standard
8283 Called when emulating frame has completed and on_paint()/on_video() calls
8284  are about to be issued.
8285 \end_layout
8287 \begin_layout Subsection
8288 on_frame: Frame emulation starting.
8289 \end_layout
8291 \begin_layout Itemize
8292 Callback: on_frame()
8293 \end_layout
8295 \begin_layout Standard
8296 Called on each starting whole frame.
8297 \end_layout
8299 \begin_layout Subsection
8300 on_rewind: Movie rewound to beginning
8301 \end_layout
8303 \begin_layout Itemize
8304 Callback: on_rewind()
8305 \end_layout
8307 \begin_layout Standard
8308 Called when rewind movie to beginning has completed.
8309 \end_layout
8311 \begin_layout Subsection
8312 on_pre_load: Load operation is about to start
8313 \end_layout
8315 \begin_layout Itemize
8316 Callback: on_pre_load(string name)
8317 \end_layout
8319 \begin_layout Standard
8320 Called just before savestate/movie load occurs (note: loads are always delayed,
8321  so this occurs even when load was initiated by lua).
8322 \end_layout
8324 \begin_layout Subsection
8325 on_err_Load: Load failed
8326 \end_layout
8328 \begin_layout Itemize
8329 Callback: on_err_load(string name)
8330 \end_layout
8332 \begin_layout Standard
8333 Called if loadstate goes wrong.
8334 \end_layout
8336 \begin_layout Subsection
8337 on_post_load: Load completed
8338 \end_layout
8340 \begin_layout Itemize
8341 Callback: on_post_load(string name, boolean was_savestate)
8342 \end_layout
8344 \begin_layout Standard
8345 Called on successful loadstate.
8346  was_savestate gives if this was a savestate or a movie.
8347 \end_layout
8349 \begin_layout Subsection
8350 on_pre_save: Save operation is about to start
8351 \end_layout
8353 \begin_layout Itemize
8354 Callback: on_pre_save(string name, boolean is_savestate)
8355 \end_layout
8357 \begin_layout Standard
8358 Called just before savestate save occurs (note: movie saves are synchronous
8359  and won't trigger these callbacks if called from Lua).
8360 \end_layout
8362 \begin_layout Subsection
8363 on_err_save: Save failed
8364 \end_layout
8366 \begin_layout Itemize
8367 Callback: on_err_save(string name)
8368 \end_layout
8370 \begin_layout Standard
8371 Called if savestate goes wrong.
8372 \end_layout
8374 \begin_layout Subsection
8375 on_post_save: Save completed
8376 \end_layout
8378 \begin_layout Itemize
8379 Callback: on_post_save(string name, boolean is_savestate)
8380 \end_layout
8382 \begin_layout Standard
8383 Called on successful savaestate.
8384  is_savestate gives if this was a savestate or a movie.
8385 \end_layout
8387 \begin_layout Subsection
8388 on_quit: Emulator is shutting down
8389 \end_layout
8391 \begin_layout Itemize
8392 Callback: on_quit()
8393 \end_layout
8395 \begin_layout Standard
8396 Called when emulator is shutting down.
8397 \end_layout
8399 \begin_layout Subsection
8400 on_input: Polling for input
8401 \end_layout
8403 \begin_layout Standard
8404 Called when emulator is just sending input to bsnes core.
8405  Warning: This is called even in readonly mode, but the results are ignored.
8406 \end_layout
8408 \begin_layout Subsection
8409 on_reset: System has been reset
8410 \end_layout
8412 \begin_layout Itemize
8413 Callback: on_reset()
8414 \end_layout
8416 \begin_layout Standard
8417 Called when system is reset.
8418 \end_layout
8420 \begin_layout Subsection
8421 on_readwrite: Entered recording mode
8422 \end_layout
8424 \begin_layout Itemize
8425 Callback: on_readwrite()
8426 \end_layout
8428 \begin_layout Standard
8429 Called when moving into recording mode as result of 
8430 \begin_inset Quotes eld
8431 \end_inset
8433 set-rwmode
8434 \begin_inset Quotes erd
8435 \end_inset
8437  command (note: moving to rwmode by Lua won't trigger this, as per recursive
8438  entry protection).
8439 \end_layout
8441 \begin_layout Subsection
8442 on_snoop/on_snoop2: Snoop core controller reads
8443 \end_layout
8445 \begin_layout Itemize
8446 Callback: on_snoop(number port, number controller, number index, number
8447  value)
8448 \end_layout
8450 \begin_layout Itemize
8451 Callback: on_snoop2(number port, number controller, number index, number
8452  value)
8453 \end_layout
8455 \begin_layout Standard
8456 Called each time bsnes asks for input.
8457  The value is the final value to be sent to bsnes core (readonly mode, autohold
8458  and autofire have been taken into account).
8459  Might be useful when translating movies to format suitable for console
8460  verification.
8461  Note: There is no way to modify the value to be sent.
8462 \end_layout
8464 \begin_layout Itemize
8465 On_snoop2 is called instead of on_snoop if defined.
8466  Reserves port 0 for system, having first user port be port 1.
8467 \end_layout
8469 \begin_layout Subsection
8470 on_keyhook: Hooked key/axis has been moved
8471 \end_layout
8473 \begin_layout Itemize
8474 Callback: on_keyhook(string keyname, table state)
8475 \end_layout
8477 \begin_layout Standard
8478 Sent when key that has keyhook events requested changes state.
8479  Keyname is name of the key (group) and state is the state (same kind as
8480  table values in input.raw).
8481 \end_layout
8483 \begin_layout Subsection
8484 on_idle: Idle event
8485 \end_layout
8487 \begin_layout Itemize
8488 Callback: on_idle()
8489 \end_layout
8491 \begin_layout Standard
8492 Called when requested by set_idle_timeout(), the timeout has expired and
8493  emulator is waiting.
8494 \end_layout
8496 \begin_layout Subsection
8497 on_timer: Timer event
8498 \end_layout
8500 \begin_layout Itemize
8501 Callback: on_timer()
8502 \end_layout
8504 \begin_layout Standard
8505 Called when requested by set_idle_timeout() and the timeout has expired
8506  (regardless if emulator is waiting).
8507 \end_layout
8509 \begin_layout Subsection
8510 on_set_rewind: Rewind point has been set
8511 \end_layout
8513 \begin_layout Itemize
8514 Callback: on_set_rewind(UNSAFEREWIND r)
8515 \end_layout
8517 \begin_layout Standard
8518 Called when unsafe rewind object has been constructed.
8519 \end_layout
8521 \begin_layout Subsection
8522 on_pre_rewind: Rewind is about to occur
8523 \end_layout
8525 \begin_layout Itemize
8526 Callback: on_pre_rewind() 
8527 \end_layout
8529 \begin_layout Standard
8530 Called just before unsafe rewind is about to occur.
8531 \end_layout
8533 \begin_layout Subsection
8534 on_post_rewind: Rewind has occured
8535 \end_layout
8537 \begin_layout Itemize
8538 Callback: on_post_rewind() 
8539 \end_layout
8541 \begin_layout Standard
8542 Called just after unsafe rewind has occured.
8543 \end_layout
8545 \begin_layout Subsection
8546 on_button: Button has been pressed
8547 \end_layout
8549 \begin_layout Itemize
8550 Callback: on_button(number port, number controller, number index, string
8551  type)
8552 \end_layout
8554 \begin_layout Standard
8555 Called on controller button press, with following parameters:
8556 \end_layout
8558 \begin_layout Itemize
8559 port: Port number (0 is system)
8560 \end_layout
8562 \begin_layout Itemize
8563 controller: Controller within port
8564 \end_layout
8566 \begin_layout Itemize
8567 index: Index of button.
8568 \end_layout
8570 \begin_layout Itemize
8571 type: Type of event, one of:
8572 \end_layout
8574 \begin_deeper
8575 \begin_layout Itemize
8576 \begin_inset Quotes eld
8577 \end_inset
8579 pressed
8580 \begin_inset Quotes erd
8581 \end_inset
8583 : Button was pressed.
8584 \end_layout
8586 \begin_layout Itemize
8587 \begin_inset Quotes eld
8588 \end_inset
8590 released
8591 \begin_inset Quotes erd
8592 \end_inset
8594 : Button was released.
8595 \end_layout
8597 \begin_layout Itemize
8598 \begin_inset Quotes eld
8599 \end_inset
8601 hold
8602 \begin_inset Quotes erd
8603 \end_inset
8605 : Held.
8606 \end_layout
8608 \begin_layout Itemize
8609 \begin_inset Quotes eld
8610 \end_inset
8612 unhold
8613 \begin_inset Quotes erd
8614 \end_inset
8616 : Released from hold.
8617 \end_layout
8619 \begin_layout Itemize
8620 \begin_inset Quotes eld
8621 \end_inset
8623 type
8624 \begin_inset Quotes erd
8625 \end_inset
8627 : Typing input on button.
8628 \end_layout
8630 \begin_layout Itemize
8631 \begin_inset Quotes eld
8632 \end_inset
8634 untype
8635 \begin_inset Quotes erd
8636 \end_inset
8638 : Typing input undone.
8639 \end_layout
8641 \begin_layout Itemize
8642 \begin_inset Quotes eld
8643 \end_inset
8645 autofire <duty> <cycle>
8646 \begin_inset Quotes erd
8647 \end_inset
8649 : Autofire with specifie duty and cycle.
8650 \end_layout
8652 \begin_layout Itemize
8653 \begin_inset Quotes eld
8654 \end_inset
8656 autofire
8657 \begin_inset Quotes erd
8658 \end_inset
8660 : Stop autofire.
8661 \end_layout
8663 \begin_layout Itemize
8664 \begin_inset Quotes eld
8665 \end_inset
8667 analog
8668 \begin_inset Quotes erd
8669 \end_inset
8671 : Analog action on axis.
8672 \end_layout
8674 \end_deeper
8675 \begin_layout Subsection
8676 on_movie_lost: Movie data is about to be lost
8677 \end_layout
8679 \begin_layout Itemize
8680 Callback: on_movie_lost(STRING kind)
8681 \end_layout
8683 \begin_layout Standard
8684 Called just before something would happen that could lose movie data.
8685  Kind can be:
8686 \end_layout
8688 \begin_layout Itemize
8689 readwrite: Switching to recording mode.
8690 \end_layout
8692 \begin_layout Itemize
8693 reload: ROM is being reloaded in recording mode.
8694 \end_layout
8696 \begin_layout Itemize
8697 load: New movie is being loaded.
8698 \end_layout
8700 \begin_layout Itemize
8701 unsaferewind: Unsafe rewind is happening.
8702 \end_layout
8704 \begin_layout Subsection
8705 on_latch: Latch line is rising
8706 \end_layout
8708 \begin_layout Itemize
8709 Callback: on_latch(<core-dependent-parameters>)
8710 \end_layout
8712 \begin_layout Standard
8713 Called when latch line for controller is rising.
8714  Some cores may not support this.
8715 \end_layout
8717 \begin_layout Section
8718 System-dependent behaviour
8719 \end_layout
8721 \begin_layout Subsection
8722 bsnes core
8723 \end_layout
8725 \begin_layout Itemize
8726 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
8727  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
8728  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
8729 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
8730 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
8731  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
8732  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
8733  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
8734  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
8735 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
8736 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
8737  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
8738 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
8739 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
8740  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
8741 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
8742  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
8743 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
8744 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
8745 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
8746  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
8747 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
8748  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
8749  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
8750 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
8751 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
8752 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
8753  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
8754 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
8755  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
8756  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
8757  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
8758  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
8759 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
8760  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
8761 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
8762  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
8763  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
8764 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
8765  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
8766 \end_layout
8768 \begin_layout Itemize
8769 on_latch has no parameters
8770 \end_layout
8772 \begin_layout Itemize
8773 CPU 0 is S-CPU, 1 is S-SMP.
8774 \end_layout
8776 \begin_layout Itemize
8777 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
8778 \end_layout
8780 \begin_layout Itemize
8781 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
8782 {RAM,ROM}.
8783 \end_layout
8785 \begin_layout Itemize
8786 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
8787  DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
8788  BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
8789  GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
8790 \end_layout
8792 \begin_layout Subsection
8793 gambatte core
8794 \end_layout
8796 \begin_layout Itemize
8797 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
8798  d, e, f, h, l
8799 \end_layout
8801 \begin_layout Itemize
8802 on_latch is not supported
8803 \end_layout
8805 \begin_layout Itemize
8806 CPU 0 is main CPU.
8807 \end_layout
8809 \begin_layout Itemize
8810 Cheats are supported for ROM, SRAM and WRAM.
8811 \end_layout
8813 \begin_layout Itemize
8814 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
8815  and WRAM.
8816 \end_layout
8818 \begin_layout Itemize
8819 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
8820 \end_layout
8822 \end_body
8823 \end_document