Lua: Fix type confusion between signed and unsigned
[lsnes.git] / lua.lyx
blobbdebfc71b3eb2b1df0d7566cf2eaa796d7caddbb
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 act like tables, but the values reflect emulated memory.
392 \end_layout
394 \begin_layout Subsubsection
395 static function new: Create a new instance
396 \end_layout
398 \begin_layout Itemize
399 Syntax: mmap memory.mmap.new()
400 \end_layout
402 \begin_layout Itemize
403 Syntax: mmap classes.MMAP_STRUCT.new()
404 \end_layout
406 \begin_layout Standard
407 Return value:
408 \end_layout
410 \begin_layout Itemize
411 mmap: MMAP_STRUCT: The created mmap structure.
412 \end_layout
414 \begin_layout Standard
415 Create a new object (with no mappings) and return it.
416 \end_layout
418 \begin_layout Subsubsection
419 operator(): Bind key in mmap structure
420 \end_layout
422 \begin_layout Itemize
423 Syntax: obj(key, {marea, address|addrobj}, type)
424 \end_layout
426 \begin_layout Standard
427 Parameters:
428 \end_layout
430 \begin_layout Itemize
431 obj: MMAP_STRUCT: The structure to manipulate.
432 \end_layout
434 \begin_layout Itemize
435 key: String: The name of the key in array to map.
436 \end_layout
438 \begin_layout Itemize
439 marea: String: The memory area the mapped address is in (default: global
440  memory space).
441 \end_layout
443 \begin_layout Itemize
444 address: Number: The offset of memory addreess, relative to specified memory
445  area or global memory space.
446 \end_layout
448 \begin_layout Itemize
449 addrobj: ADDRESS: The memory address.
450 \end_layout
452 \begin_layout Itemize
453 type: String: The type of data to map.
454 \end_layout
456 \begin_deeper
457 \begin_layout Itemize
458 One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
459  float or double.
460 \end_layout
462 \end_deeper
463 \begin_layout Standard
464 Bind key <key> in mmap structure <obj> to address <address> (relative to
465  <marea>).
466  The memory address is treated as type <type>.
467 \end_layout
469 \begin_layout Itemize
470 Example: foomap(
471 \begin_inset Quotes eld
472 \end_inset
475 \begin_inset Quotes erd
476 \end_inset
479 \begin_inset Quotes eld
480 \end_inset
482 WRAM
483 \begin_inset Quotes erd
484 \end_inset
486 , 0x2A, 
487 \begin_inset Quotes eld
488 \end_inset
490 sword
491 \begin_inset Quotes erd
492 \end_inset
495 \end_layout
497 \begin_layout Standard
498 This binds signed word at address WRAM+0x2A into key 
499 \begin_inset Quotes eld
500 \end_inset
503 \begin_inset Quotes erd
504 \end_inset
507 \end_layout
509 \begin_layout Standard
510 \begin_inset Newpage pagebreak
511 \end_inset
514 \end_layout
516 \begin_layout Subsection
517 ZIPWRITER: Write .zip files
518 \end_layout
520 \begin_layout Standard
521 This class does writing of .zip files.
522 \end_layout
524 \begin_layout Subsubsection
525 Static function new: Create a new zipfile
526 \end_layout
528 \begin_layout Itemize
529 Syntax: zip zip.writer.new(filename, [compression])
530 \end_layout
532 \begin_layout Itemize
533 Deprecated: zip zip.create(filename, [compression])
534 \end_layout
536 \begin_layout Standard
537 Parameters:
538 \end_layout
540 \begin_layout Itemize
541 filename: string: The name of the file to write.
542 \end_layout
544 \begin_layout Itemize
545 compression: number: Compression level (0-9).
546  Default is 9.
547 \end_layout
549 \begin_layout Standard
550 Return value:
551 \end_layout
553 \begin_layout Itemize
554 zip: ZIPWRITER: The newly created ZIP writer.
555 \end_layout
557 \begin_layout Standard
558 Create a new ZIPWRITER object and return it.
559 \end_layout
561 \begin_layout Subsubsection
562 Method commit: Finish creating ZIP file.
563 \end_layout
565 \begin_layout Itemize
566 Syntax: zipfile:commit()
567 \end_layout
569 \begin_layout Standard
570 Parameters:
571 \end_layout
573 \begin_layout Itemize
574 zipfile: ZIPFILE: The ZIP file object.
575 \end_layout
577 \begin_layout Standard
578 Finish writing the ZIP file and actually create it on disk.
579 \end_layout
581 \begin_layout Itemize
582 If a member is currently open, it is implicitly closed.
583 \end_layout
585 \begin_layout Itemize
586 Invoking this on already committed or rolled back zipfile causes an error.
587 \end_layout
589 \begin_layout Subsubsection
590 Method rollback: Cancel writing the ZIP file.
591 \end_layout
593 \begin_layout Itemize
594 Syntax: zipfile:rollback()
595 \end_layout
597 \begin_layout Standard
598 Parameters:
599 \end_layout
601 \begin_layout Itemize
602 zipfile: ZIPFILE: The ZIP file object.
603 \end_layout
605 \begin_layout Standard
606 Cancel writing the whole ZIP file.
607  The file on disk will not be modified.
608 \end_layout
610 \begin_layout Itemize
611 If a member is currently open, it is implicitly closed.
612 \end_layout
614 \begin_layout Itemize
615 Invoking this on already committed or rolled back zipfile causes an error.
616 \end_layout
618 \begin_layout Subsubsection
619 Method create_file: Start writing a new member
620 \end_layout
622 \begin_layout Itemize
623 Syntax: zipfile:create_file(filename)
624 \end_layout
626 \begin_layout Standard
627 Parameters:
628 \end_layout
630 \begin_layout Itemize
631 zipfile: ZIPFILE: The ZIP file object.
632 \end_layout
634 \begin_layout Itemize
635 string filename: Name of the new member to create
636 \end_layout
638 \begin_layout Standard
639 Start writing a new member <filename> in ZIP file.
640 \end_layout
642 \begin_layout Itemize
643 If a member is currently open, it is implicitly closed.
644 \end_layout
646 \begin_layout Itemize
647 Invoking this on already committed or rolled back zipfile causes an error.
648 \end_layout
650 \begin_layout Subsubsection
651 Method close_file: Close member
652 \end_layout
654 \begin_layout Itemize
655 Syntax: zipfile:close_file()
656 \end_layout
658 \begin_layout Standard
659 Parameters:
660 \end_layout
662 \begin_layout Itemize
663 zipfile: ZIPFILE: The ZIP file object.
664 \end_layout
666 \begin_layout Standard
667 Close the currently open member in zipfile.
668 \end_layout
670 \begin_layout Itemize
671 Invoking this on already committed or rolled back zipfile causes an error.
672 \end_layout
674 \begin_layout Itemize
675 Invoking this without an open member causes an error.
676 \end_layout
678 \begin_layout Subsubsection
679 Method write: Write data
680 \end_layout
682 \begin_layout Itemize
683 Syntax: zipfile:write(data)
684 \end_layout
686 \begin_layout Standard
687 Parameters:
688 \end_layout
690 \begin_layout Itemize
691 zipfile: ZIPFILE: The ZIP file object.
692 \end_layout
694 \begin_layout Itemize
695 data: string: The data to write.
696 \end_layout
698 \begin_layout Standard
699 Write <data> in binary mode (as-is) to currently open member.
700 \end_layout
702 \begin_layout Itemize
703 Invoking this without a member being open causes an error.
704 \end_layout
706 \begin_layout Standard
707 \begin_inset Newpage pagebreak
708 \end_inset
711 \end_layout
713 \begin_layout Subsection
714 TILEMAP: Tiled collection of bitmaps.
715 \end_layout
717 \begin_layout Standard
718 A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
719 \end_layout
721 \begin_layout Subsubsection
722 Static function new: Create a tilemap
723 \end_layout
725 \begin_layout Itemize
726 Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
727 \end_layout
729 \begin_layout Itemize
730 Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
731 \end_layout
733 \begin_layout Itemize
734 Deprecated: tilemap gui.tilemap(w, h, bw, bh);
735 \end_layout
737 \begin_layout Standard
738 Parameters:
739 \end_layout
741 \begin_layout Itemize
742 w: number: Width of the tilemap in tiles
743 \end_layout
745 \begin_layout Itemize
746 h: number: Height of the tilemap in tiles
747 \end_layout
749 \begin_layout Itemize
750 bw: number: Width of each tile in pixels.
751 \end_layout
753 \begin_layout Itemize
754 bh: number: Height of each tile in pixels.
755 \end_layout
757 \begin_layout Standard
758 Return value:
759 \end_layout
761 \begin_layout Itemize
762 tilemap: TILEMAP: the newly created tilemap
763 \end_layout
765 \begin_layout Standard
766 Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
767  it.
768 \end_layout
770 \begin_layout Subsubsection
771 TILEMAP:getsize: Query tilemap size
772 \end_layout
774 \begin_layout Itemize
775 Syntax: width, height tmap:getsize()
776 \end_layout
778 \begin_layout Standard
779 Parameters:
780 \end_layout
782 \begin_layout Itemize
783 tmap: TILEMAP: The tilemap to query.
784 \end_layout
786 \begin_layout Standard
787 Return value:
788 \end_layout
790 \begin_layout Itemize
791 width: number : The width of the tilemap in tiles.
792 \end_layout
794 \begin_layout Itemize
795 height: number: The height of the tilemap in tiles.
796 \end_layout
798 \begin_layout Standard
799 Get size of tilemap in tiles.
800 \end_layout
802 \begin_layout Subsubsection
803 TILEMAP:getcsize: Query tilemap cell size
804 \end_layout
806 \begin_layout Itemize
807 Syntax: width, height tmap:getcsize()
808 \end_layout
810 \begin_layout Standard
811 Parameters:
812 \end_layout
814 \begin_layout Itemize
815 tmap: TILEMAP: The tilemap to query.
816 \end_layout
818 \begin_layout Standard
819 Return value:
820 \end_layout
822 \begin_layout Itemize
823 width: number: The width of tilemap tile in pixels.
824 \end_layout
826 \begin_layout Itemize
827 height: number: The height of tilemap tile in pixels.
828 \end_layout
830 \begin_layout Standard
831 Get size of each tilemap tile in pixels.
832 \end_layout
834 \begin_layout Subsubsection
835 TILEMAP:get: Query tilemap tile
836 \end_layout
838 \begin_layout Itemize
839 Syntax: bitmap, palette tmap:get(x, y)
840 \end_layout
842 \begin_layout Standard
843 Parameters:
844 \end_layout
846 \begin_layout Itemize
847 tmap: TILEMAP: The tilemap to query.
848 \end_layout
850 \begin_layout Itemize
851 x: number: The x-coordinate of tile to query.
852 \end_layout
854 \begin_layout Itemize
855 y: number: The y-coordinate of tile to query.
856 \end_layout
858 \begin_layout Standard
859 Return value:
860 \end_layout
862 \begin_layout Itemize
863 bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
864 \end_layout
866 \begin_layout Itemize
867 palette: The palette (PALETTE) associated with indexed-color bitmap, if
868  any.
869  Otherwise nil.
870 \end_layout
872 \begin_layout Standard
873 Return the contents of tile at <x>,<y>.
874 \end_layout
876 \begin_layout Subsubsection
877 TILEMAP:set: Set tilemap cell
878 \end_layout
880 \begin_layout Itemize
881 Syntax: tmap:set(x, y)
882 \end_layout
884 \begin_layout Itemize
885 Syntax: tmap:set(x, y, bitmap)
886 \end_layout
888 \begin_layout Itemize
889 Syntax: tmap:set(x, y, bitmap, palette)
890 \end_layout
892 \begin_layout Standard
893 Parameters:
894 \end_layout
896 \begin_layout Itemize
897 tmap: TILEMAP: The tilemap to manipulate.
898 \end_layout
900 \begin_layout Itemize
901 number x: The x-coordinate of tile to set.
902 \end_layout
904 \begin_layout Itemize
905 number y: The y-coordinate of tile to set.
906 \end_layout
908 \begin_layout Itemize
909 bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
910 \end_layout
912 \begin_layout Itemize
913 palette: PALETTE: The associated palette for bitmap.
914 \end_layout
916 \begin_layout Standard
917 Set the contents of tile <x>,<y>.
918  If no <bitmap> is given, clears the tile.
919  Otherwise sets the tile to contain bitmap <bitmap> with associated palette
920  <palette>.
921 \end_layout
923 \begin_layout Itemize
924 Specifying index bitmap <bitmap> without palette <palette> causes an error.
925 \end_layout
927 \begin_layout Subsubsection
928 TILEMAP:scroll: Scroll tilemap
929 \end_layout
931 \begin_layout Itemize
932 Syntax: tmap:scroll(ox, oy);
933 \end_layout
935 \begin_layout Itemize
936 Syntax: tmap:scroll(ox, oy, x, y, w, h);
937 \end_layout
939 \begin_layout Itemize
940 Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
941 \end_layout
943 \begin_layout Standard
944 Parameters:
945 \end_layout
947 \begin_layout Itemize
948 tmap: TILEMAP: The tilemap to manipulate.
949 \end_layout
951 \begin_layout Itemize
952 ox: number: The number of tiles to scroll horizontally (positive is to right).
953 \end_layout
955 \begin_layout Itemize
956 oy: number: The number of tiles to scroll vertically (positive is to down).
957 \end_layout
959 \begin_layout Itemize
960 x: number: The left edge of scroll window.
961 \end_layout
963 \begin_layout Itemize
964 y: number: The top edge of scroll window.
965 \end_layout
967 \begin_layout Itemize
968 w: number: The width of scroll window.
969 \end_layout
971 \begin_layout Itemize
972 h: number: The height of scroll window.
973 \end_layout
975 \begin_layout Itemize
976 circ_x: boolean: If true, treat the window as circular in horizontal direction.
977 \end_layout
979 \begin_layout Itemize
980 circ_y: boolean: If true, treat the window as circular in vertical direction.
981 \end_layout
983 \begin_layout Standard
984 Scroll the specified tilemap <tmap> by <ox>,<oy>.
985  If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
986  <circ_x> and <circ_y> control if scroll is circular or not.
987 \end_layout
989 \begin_layout Itemize
990 Specifying out-of-range window causes an error.
991 \end_layout
993 \begin_layout Subsubsection
994 TILEMAP:draw: Draw tilemap
995 \end_layout
997 \begin_layout Itemize
998 Name: tmap:draw(x, y)
999 \end_layout
1001 \begin_layout Itemize
1002 Name: tmap:draw(x, y, x0, y0, w, h)
1003 \end_layout
1005 \begin_layout Standard
1006 Parameters:
1007 \end_layout
1009 \begin_layout Itemize
1010 tmap: TILEMAP: The tilemap to draw.
1011 \end_layout
1013 \begin_layout Itemize
1014 x: The x coordinate on screen to draw to.
1015 \end_layout
1017 \begin_layout Itemize
1018 y: The y coordinate on screen to draw to.
1019 \end_layout
1021 \begin_layout Itemize
1022 x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
1023 \end_layout
1025 \begin_layout Itemize
1026 y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
1027 \end_layout
1029 \begin_layout Itemize
1030 w: number: The width to draw (in pixels).
1031 \end_layout
1033 \begin_layout Itemize
1034 h: number: The height to draw (in pixels).
1035 \end_layout
1037 \begin_layout Standard
1038 Draw tilemap <tmap> to screen at <x>,<y>.
1039  If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
1040 \end_layout
1042 \begin_layout Itemize
1043 This method requires a rendering context to work.
1044 \end_layout
1046 \begin_layout Subsubsection
1047 TILEMAP:draw_outside: Draw tilemap outside game area
1048 \end_layout
1050 \begin_layout Itemize
1051 Name: tmap:draw_outside(x, y)
1052 \end_layout
1054 \begin_layout Itemize
1055 Name: tmap:draw_outside(x, y, x0, y0, w, h)
1056 \end_layout
1058 \begin_layout Standard
1059 Like TILEMAP:draw, but draws only outside game area.
1060 \end_layout
1062 \begin_layout Standard
1063 \begin_inset Newpage pagebreak
1064 \end_inset
1067 \end_layout
1069 \begin_layout Subsection
1070 RENDERCTX: Off-screen rendering context
1071 \end_layout
1073 \begin_layout Standard
1074 Object acting as off-screen rendering context.
1075 \end_layout
1077 \begin_layout Subsubsection
1078 Static function new: Create a render queue
1079 \end_layout
1081 \begin_layout Itemize
1082 Syntax: renderctx gui.renderctx.new(width, height);
1083 \end_layout
1085 \begin_layout Itemize
1086 Syntax: renderctx classes.RENDERCTX.new(width, height);
1087 \end_layout
1089 \begin_layout Itemize
1090 Deprecated: renderctx gui.renderq_new(width, height);
1091 \end_layout
1093 \begin_layout Standard
1094 Parameters:
1095 \end_layout
1097 \begin_layout Itemize
1098 width: number: The notional width of the game area.
1099 \end_layout
1101 \begin_layout Itemize
1102 height: number: The notional height of the game area.
1103 \end_layout
1105 \begin_layout Standard
1106 Returns:
1107 \end_layout
1109 \begin_layout Itemize
1110 rendectx: RENDERCTX: The newly created render context.
1111 \end_layout
1113 \begin_layout Standard
1114 Create a render context with reported size <width>*<height> and return it.
1115 \end_layout
1117 \begin_layout Subsubsection
1118 Static function setnull: Reset to default queue
1119 \end_layout
1121 \begin_layout Itemize
1122 Syntax: gui.renderctx.setnull()
1123 \end_layout
1125 \begin_layout Itemize
1126 Syntax: classes.RENDERCTX:setnull()
1127 \end_layout
1129 \begin_layout Itemize
1130 Deprecated: gui.renderq_set()
1131 \end_layout
1133 \begin_layout Standard
1134 Reset the used render context back to default for the executing callback:
1135 \end_layout
1137 \begin_layout Itemize
1138 The default for paint callback is the screen
1139 \end_layout
1141 \begin_layout Itemize
1142 The default for video callback is the video frame
1143 \end_layout
1145 \begin_layout Itemize
1146 The default otherwise is nothing.
1147 \end_layout
1149 \begin_layout Subsubsection
1150 Method clear: Clear a render queue
1151 \end_layout
1153 \begin_layout Itemize
1154 Syntax: renderctx:clear()
1155 \end_layout
1157 \begin_layout Itemize
1158 Deprecated: gui.renderq_clear(renderctx)
1159 \end_layout
1161 \begin_layout Standard
1162 Parameters:
1163 \end_layout
1165 \begin_layout Itemize
1166 renderctx: RENDERCTX: The render queue to clear.
1167 \end_layout
1169 \begin_layout Standard
1170 Clear all drawing from the context.
1171 \end_layout
1173 \begin_layout Subsubsection
1174 Method set: Change active render context
1175 \end_layout
1177 \begin_layout Itemize
1178 Syntax: renderctx:set()
1179 \end_layout
1181 \begin_layout Itemize
1182 Deprecated: gui.renderq_set(renderctx)
1183 \end_layout
1185 \begin_layout Standard
1186 Parameters:
1187 \end_layout
1189 \begin_layout Itemize
1190 renderctx: RENDERCTX: The render queue to use.
1191 \end_layout
1193 \begin_layout Standard
1194 Switch the current rendering context <renderctx>.
1195 \end_layout
1197 \begin_layout Subsubsection
1198 Method run: Draw all objects in context to another
1199 \end_layout
1201 \begin_layout Itemize
1202 Syntax: renderctx:run()
1203 \end_layout
1205 \begin_layout Itemize
1206 Deprecated: gui.renderq_run(renderctx)
1207 \end_layout
1209 \begin_layout Standard
1210 Parameters:
1211 \end_layout
1213 \begin_layout Itemize
1214 renderctx: RENDERCTX: The render context to overlay.
1215 \end_layout
1217 \begin_layout Standard
1218 Overlay the specified render context <context> upon the active rendering
1219  context.
1220 \end_layout
1222 \begin_layout Itemize
1223 Trying to overlay rendering context upon itself is a bad idea.
1224 \end_layout
1226 \begin_layout Subsubsection
1227 Method render: Render a contex to bitmap
1228 \end_layout
1230 \begin_layout Itemize
1231 Syntax: bitmap renderctx:render()
1232 \end_layout
1234 \begin_layout Standard
1235 Parameters:
1236 \end_layout
1238 \begin_layout Itemize
1239 renderctx: RENDERCTX: The context to render.
1240 \end_layout
1242 \begin_layout Standard
1243 Returns:
1244 \end_layout
1246 \begin_layout Itemize
1247 bitmap: DBITMAP: The rendered bitmap.
1248 \end_layout
1250 \begin_layout Standard
1251 Render the specified context <renderctx> to a new bitmap.
1252 \end_layout
1254 \begin_layout Itemize
1255 The size of bitmap will be nominal game area size, plus any set gaps.
1256 \end_layout
1258 \begin_layout Itemize
1259 This method does not require active rendering context.
1260 \end_layout
1262 \begin_layout Subsubsection
1263 Method synchronous_repaint: Paint screen now
1264 \end_layout
1266 \begin_layout Itemize
1267 Syntax: renderctx:synchronous_repaint()
1268 \end_layout
1270 \begin_layout Itemize
1271 Deprecated: gui.synchronous_repaint(renderctx)
1272 \end_layout
1274 \begin_layout Standard
1275 Parameters:
1276 \end_layout
1278 \begin_layout Itemize
1279 renderctx: RENDERCTX: The context to paint.
1280 \end_layout
1282 \begin_layout Standard
1283 Immediately redraw the screen with game overlayed by drawings from context
1284  <renderctx>.
1285 \end_layout
1287 \begin_layout Itemize
1288 This does not require active rendering context.
1289 \end_layout
1291 \begin_layout Itemize
1292 Will not cause paint callback to be invoked.
1293 \end_layout
1295 \begin_layout Standard
1296 \begin_inset Newpage pagebreak
1297 \end_inset
1300 \end_layout
1302 \begin_layout Subsection
1303 PALETTE: Color palette for indexed image
1304 \end_layout
1306 \begin_layout Subsubsection
1307 Static function new: Create a new palette
1308 \end_layout
1310 \begin_layout Itemize
1311 Syntax: palette gui.palette.new()
1312 \end_layout
1314 \begin_layout Itemize
1315 Syntax: palette classes.PALETTE.new()
1316 \end_layout
1318 \begin_layout Itemize
1319 Deprecated: palette gui.palette_new()
1320 \end_layout
1322 \begin_layout Standard
1323 Returns:
1324 \end_layout
1326 \begin_layout Itemize
1327 palette: PALETTE: The created palette.
1328 \end_layout
1330 \begin_layout Standard
1331 Create a new palette (with all colors transparent) and return it.
1332 \end_layout
1334 \begin_layout Subsubsection
1335 Static function load: Load a palette
1336 \end_layout
1338 \begin_layout Itemize
1339 Syntax: palette gui.palette.load(file, [base])
1340 \end_layout
1342 \begin_layout Itemize
1343 Syntax: palette classes.PALETTE.load(file, [base])
1344 \end_layout
1346 \begin_layout Itemize
1347 Deprecated: palette gui.palette_load(file, [base])
1348 \end_layout
1350 \begin_layout Standard
1351 Parameters:
1352 \end_layout
1354 \begin_layout Itemize
1355 string file: The file to load.
1356 \end_layout
1358 \begin_layout Itemize
1359 string base (optional): The base file to resolve file relative to.
1360 \end_layout
1362 \begin_layout Standard
1363 Returns:
1364 \end_layout
1366 \begin_layout Itemize
1367 palette: PALETTE: The loaded palette.
1368 \end_layout
1370 \begin_layout Standard
1371 Load a palette from file <file> (resolved relative to <base>).
1372 \end_layout
1374 \begin_layout Itemize
1375 The file format is a series of lines, each with following format:
1376 \end_layout
1378 \begin_deeper
1379 \begin_layout Itemize
1380 Blank or just whitespace: Ignored
1381 \end_layout
1383 \begin_layout Itemize
1384 First non-whitespace is '#': Ignored
1385 \end_layout
1387 \begin_layout Itemize
1388 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1389 \end_layout
1391 \begin_layout Itemize
1392 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1393  (0-256, 0 being fully transparent and 256 fully opaque).
1394 \end_layout
1396 \begin_layout Itemize
1397 transparent: Fully transparent color
1398 \end_layout
1400 \end_deeper
1401 \begin_layout Subsubsection
1402 Static function load_str: Load a palette from string
1403 \end_layout
1405 \begin_layout Itemize
1406 Syntax: palette gui.palette.load(data)
1407 \end_layout
1409 \begin_layout Itemize
1410 Syntax: palette classes.PALETTE.load(data)
1411 \end_layout
1413 \begin_layout Itemize
1414 Deprecated: palette gui.palette_load(data)
1415 \end_layout
1417 \begin_layout Standard
1418 Parameters:
1419 \end_layout
1421 \begin_layout Itemize
1422 string data: The palette data.
1423 \end_layout
1425 \begin_layout Standard
1426 Returns:
1427 \end_layout
1429 \begin_layout Itemize
1430 palette: PALETTE: The loaded palette.
1431 \end_layout
1433 \begin_layout Standard
1434 Like PALETTE:load, but instead of reading palette from file, reads it from
1435  a string.
1436 \end_layout
1438 \begin_layout Subsubsection
1439 Method set: Set palette entry
1440 \end_layout
1442 \begin_layout Itemize
1443 Syntax: palette:set(index, color)
1444 \end_layout
1446 \begin_layout Itemize
1447 Deprecated: gui.palette_set(palette, ...)
1448 \end_layout
1450 \begin_layout Standard
1451 Parameters:
1452 \end_layout
1454 \begin_layout Itemize
1455 palette: PALETTE: The palette to manipulate
1456 \end_layout
1458 \begin_layout Itemize
1459 index: number: The index of color to set (0-65535).
1460 \end_layout
1462 \begin_layout Itemize
1463 color: number/string: The color value to set.
1464 \end_layout
1466 \begin_layout Standard
1467 Set palette <palette> index <index> to color <color>.
1468 \end_layout
1470 \begin_layout Subsubsection
1471 Method get: Get palette entry
1472 \end_layout
1474 \begin_layout Itemize
1475 Syntax: number palette:get(index)
1476 \end_layout
1478 \begin_layout Standard
1479 Parameters:
1480 \end_layout
1482 \begin_layout Itemize
1483 palette: PALETTE: The palette to query
1484 \end_layout
1486 \begin_layout Itemize
1487 index: number: The index of color to get (0-65535).
1488 \end_layout
1490 \begin_layout Standard
1491 Returns:
1492 \end_layout
1494 \begin_layout Itemize
1495 The palette entry as integer.
1496 \end_layout
1498 \begin_layout Standard
1499 Get palette entry <index> of palette <palette> and return it.
1500 \end_layout
1502 \begin_layout Subsubsection
1503 Method hash: Hash a palette
1504 \end_layout
1506 \begin_layout Itemize
1507 Syntax: hash palette:hash()
1508 \end_layout
1510 \begin_layout Itemize
1511 Deprecated: hash gui.palette_hash(palette)
1512 \end_layout
1514 \begin_layout Standard
1515 Parameters:
1516 \end_layout
1518 \begin_layout Itemize
1519 palette: The palette to hash.
1520 \end_layout
1522 \begin_layout Standard
1523 Return value:
1524 \end_layout
1526 \begin_layout Itemize
1527 hash: string: 64-hex digit hash.
1528 \end_layout
1530 \begin_layout Standard
1531 Obtain crypto-grade hash of palette data of <palette>.
1532 \end_layout
1534 \begin_layout Itemize
1535 All colors after the last non-transparent one are ignored.
1536 \end_layout
1538 \begin_layout Subsubsection
1539 Method adjust_transparency: Adjust transparency
1540 \end_layout
1542 \begin_layout Itemize
1543 Syntax: palette:adjust_transparency(newvalue)
1544 \end_layout
1546 \begin_layout Itemize
1547 Deprecated: gui.adjust_transparency(palette, ...)
1548 \end_layout
1550 \begin_layout Standard
1551 Parameters:
1552 \end_layout
1554 \begin_layout Itemize
1555 palette: PALETTE: The palette to adjust.
1556 \end_layout
1558 \begin_layout Itemize
1559 Number adj: The factor to multiply opaqueness with times 256.
1560 \end_layout
1562 \begin_layout Standard
1563 Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
1564 \end_layout
1566 \begin_layout Standard
1567 \begin_inset Newpage pagebreak
1568 \end_inset
1571 \end_layout
1573 \begin_layout Subsection
1574 BITMAP: Indexed-color bitmap
1575 \end_layout
1577 \begin_layout Subsubsection
1578 Static function new: Create a new bitmap
1579 \end_layout
1581 \begin_layout Itemize
1582 Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
1583 \end_layout
1585 \begin_layout Itemize
1586 Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
1587 \end_layout
1589 \begin_layout Itemize
1590 Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
1591 \end_layout
1593 \begin_layout Standard
1594 Parameters:
1595 \end_layout
1597 \begin_layout Itemize
1598 w: number: The width of bitmap to create in pixels.
1599 \end_layout
1601 \begin_layout Itemize
1602 h: number: The height of bitmap to create in pixels.
1603 \end_layout
1605 \begin_layout Itemize
1606 false: boolean: Constant boolean false.
1607 \end_layout
1609 \begin_layout Itemize
1610 fillcolor: number: The initial fill index.
1611  Default 0 if not specified.
1612 \end_layout
1614 \begin_layout Standard
1615 Create a new bitmap of size <w>*<h>.
1616  Fill the bitmap with color index <fillcolor>.
1617 \end_layout
1619 \begin_layout Subsubsection
1620 Method draw: Draw a bitmap
1621 \end_layout
1623 \begin_layout Itemize
1624 Syntax: bitmap:draw(x, y, palette)
1625 \end_layout
1627 \begin_layout Itemize
1628 Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
1629 \end_layout
1631 \begin_layout Standard
1632 Parameters:
1633 \end_layout
1635 \begin_layout Itemize
1636 bitmap: BITMAP: The bitmap to draw
1637 \end_layout
1639 \begin_layout Itemize
1640 x: number: The x-coordinate on screen.
1641 \end_layout
1643 \begin_layout Itemize
1644 y: number: The y-coordinate on screen.
1645 \end_layout
1647 \begin_layout Itemize
1648 palette: The palette to use for drawing.
1649 \end_layout
1651 \begin_layout Standard
1652 Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
1653 \end_layout
1655 \begin_layout Subsubsection
1656 Method draw_outside: Draw a bitmap outside game area
1657 \end_layout
1659 \begin_layout Itemize
1660 Syntax: bitmap:draw_outside(x, y, palette)
1661 \end_layout
1663 \begin_layout Standard
1664 Like bitmap:draw, but does not draw on game area.
1665 \end_layout
1667 \begin_layout Subsubsection
1668 Method draw_clip: Draw a bitmap, with clipping
1669 \end_layout
1671 \begin_layout Itemize
1672 Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
1673 \end_layout
1675 \begin_layout Standard
1676 Parameters:
1677 \end_layout
1679 \begin_layout Itemize
1680 bitmap: BITMAP: The bitmap to draw
1681 \end_layout
1683 \begin_layout Itemize
1684 x: number: The x-coordinate on screen.
1685 \end_layout
1687 \begin_layout Itemize
1688 y: number: The y-coordinate on screen.
1689 \end_layout
1691 \begin_layout Itemize
1692 palette: The palette to use for drawing.
1693 \end_layout
1695 \begin_layout Itemize
1696 x0: The smallest bitmap x coordinate to draw.
1697 \end_layout
1699 \begin_layout Itemize
1700 y0: The smallest bitmap y coordinate to draw.
1701 \end_layout
1703 \begin_layout Itemize
1704 width: Width of region to draw
1705 \end_layout
1707 \begin_layout Itemize
1708 height: Height of region to draw.
1709 \end_layout
1711 \begin_layout Standard
1712 Like bitmap:draw, but clip the bitmap area drawn.
1713 \end_layout
1715 \begin_layout Subsubsection
1716 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
1717 \end_layout
1719 \begin_layout Itemize
1720 Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
1721 \end_layout
1723 \begin_layout Standard
1724 Like bitmap:draw_clip, but only draw outside game area.
1725 \end_layout
1727 \begin_layout Subsubsection
1728 Method pset: Set pixel in bitmap
1729 \end_layout
1731 \begin_layout Itemize
1732 Syntax: bitmap:pset(x, y, color)
1733 \end_layout
1735 \begin_layout Itemize
1736 Deprecaed: gui.bitmap_pset(bitmap, ...)
1737 \end_layout
1739 \begin_layout Standard
1740 Parameters:
1741 \end_layout
1743 \begin_layout Itemize
1744 bitmap: BITMAP: The bitmap to manipulate.
1745 \end_layout
1747 \begin_layout Itemize
1748 x: number: x-coordinate of pixel to set.
1749 \end_layout
1751 \begin_layout Itemize
1752 y: number: y-coordinate of pixel to set.
1753 \end_layout
1755 \begin_layout Itemize
1756 color: number: The color index to set.
1757 \end_layout
1759 \begin_layout Standard
1760 Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
1761 \end_layout
1763 \begin_layout Subsubsection
1764 Method pget: Get pixel in bitmap
1765 \end_layout
1767 \begin_layout Itemize
1768 Syntax: color bitmap:pget(x,y)
1769 \end_layout
1771 \begin_layout Itemize
1772 Deprecated: color gui.bitmap_pget(bitmap, ...)
1773 \end_layout
1775 \begin_layout Standard
1776 Parameters:
1777 \end_layout
1779 \begin_layout Itemize
1780 bitmap: BITMAP: The bitmap to query.
1781 \end_layout
1783 \begin_layout Itemize
1784 x: number: x-coordinate of pixel to get.
1785 \end_layout
1787 \begin_layout Itemize
1788 y: number: y-coordinate of pixel to get.
1789 \end_layout
1791 \begin_layout Standard
1792 Returns:
1793 \end_layout
1795 \begin_layout Itemize
1796 color: number: The color index in specified pixel.
1797 \end_layout
1799 \begin_layout Standard
1800 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
1801 \end_layout
1803 \begin_layout Subsubsection
1804 Method size: Get size of bitmap
1805 \end_layout
1807 \begin_layout Itemize
1808 Syntax: width, height bitmap:size()
1809 \end_layout
1811 \begin_layout Itemize
1812 Syntax: width, height gui.bitmap_size(bitmap)
1813 \end_layout
1815 \begin_layout Standard
1816 Parameters:
1817 \end_layout
1819 \begin_layout Itemize
1820 bitmap: BITMAP: The bitmap to query.
1821 \end_layout
1823 \begin_layout Standard
1824 Returns:
1825 \end_layout
1827 \begin_layout Itemize
1828 width: number: The width of the bitmap.
1829 \end_layout
1831 \begin_layout Itemize
1832 height: number: The height of the bitmap.
1833 \end_layout
1835 \begin_layout Standard
1836 Get size of bitmap <bitmap>.
1837 \end_layout
1839 \begin_layout Subsubsection
1840 Method blit: Blit a bitmap into another
1841 \end_layout
1843 \begin_layout Itemize
1844 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
1845 \end_layout
1847 \begin_layout Itemize
1848 Deprecated: gui.bitmap_blit(dest, ...)
1849 \end_layout
1851 \begin_layout Standard
1852 Parameters:
1853 \end_layout
1855 \begin_layout Itemize
1856 dest: BITMAP: The target bitmap to blit to.
1857 \end_layout
1859 \begin_layout Itemize
1860 dx: number: The x-coordinate in target.
1861 \end_layout
1863 \begin_layout Itemize
1864 dy: number: The y-coordinate in target.
1865 \end_layout
1867 \begin_layout Itemize
1868 src: BITMAP: The source bitmap.
1869 \end_layout
1871 \begin_layout Itemize
1872 sx: number: The x-coordinate in source.
1873 \end_layout
1875 \begin_layout Itemize
1876 sy: number: The y-coordinate in source.
1877 \end_layout
1879 \begin_layout Itemize
1880 w: number: The width of area to blit.
1881 \end_layout
1883 \begin_layout Itemize
1884 h: number: The height of area to blit.
1885 \end_layout
1887 \begin_layout Itemize
1888 ck: number: The color key.
1889  Pixels with this index are not copied.
1890 \end_layout
1892 \begin_deeper
1893 \begin_layout Itemize
1894 If none is specified, all pixels are copied.
1895 \end_layout
1897 \end_deeper
1898 \begin_layout Standard
1899 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
1900  <dx>,<dy>.
1901  If a color key <ck> is specified, pixels of that color are not copied.
1902 \end_layout
1904 \begin_layout Subsubsection
1905 Method blit_scaled: Blit a bitmap into another with scaling
1906 \end_layout
1908 \begin_layout Itemize
1909 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
1910 \end_layout
1912 \begin_layout Itemize
1913 Deprecated: gui.bitmap_blit_scaled(dest, ...)
1914 \end_layout
1916 \begin_layout Standard
1917 Parameters:
1918 \end_layout
1920 \begin_layout Itemize
1921 dest: BITMAP: The target bitmap to blit to.
1922 \end_layout
1924 \begin_layout Itemize
1925 dx: number: The x-coordinate in target.
1926 \end_layout
1928 \begin_layout Itemize
1929 dy: number: The y-coordinate in target.
1930 \end_layout
1932 \begin_layout Itemize
1933 src: BITMAP: The source bitmap.
1934 \end_layout
1936 \begin_layout Itemize
1937 sx: number: The x-coordinate in source.
1938 \end_layout
1940 \begin_layout Itemize
1941 sy: number: The y-coordinate in source.
1942 \end_layout
1944 \begin_layout Itemize
1945 w: number: The width of area to blit.
1946 \end_layout
1948 \begin_layout Itemize
1949 h: number: The height of area to blit.
1950 \end_layout
1952 \begin_layout Itemize
1953 hscl: number: Horizontal scale factor (integer).
1954 \end_layout
1956 \begin_layout Itemize
1957 vscl: number: Vertical scale factor (integer).
1958  Defaults to the same as <hscl>.
1959 \end_layout
1961 \begin_layout Itemize
1962 ck: number: The color key.
1963  Pixels with this index are not copied.
1964 \end_layout
1966 \begin_deeper
1967 \begin_layout Itemize
1968 If none is specified, all pixels are copied.
1969 \end_layout
1971 \end_deeper
1972 \begin_layout Standard
1973 Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
1974  neighbor) by factor of <hscl>*<vscl>.
1975 \end_layout
1977 \begin_layout Subsubsection
1978 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
1979 \end_layout
1981 \begin_layout Itemize
1982 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
1983 \end_layout
1985 \begin_layout Itemize
1986 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
1987 \end_layout
1989 \begin_layout Standard
1990 Parameters:
1991 \end_layout
1993 \begin_layout Itemize
1994 dest: BITMAP: The target bitmap to blit to.
1995 \end_layout
1997 \begin_layout Itemize
1998 dx: number: The x-coordinate in target.
1999 \end_layout
2001 \begin_layout Itemize
2002 dy: number: The y-coordinate in target.
2003 \end_layout
2005 \begin_layout Itemize
2006 src: BITMAP: The source bitmap.
2007 \end_layout
2009 \begin_layout Itemize
2010 sx: number: The x-coordinate in source.
2011 \end_layout
2013 \begin_layout Itemize
2014 sy: number: The y-coordinate in source.
2015 \end_layout
2017 \begin_layout Itemize
2018 w: number: The width of area to blit.
2019 \end_layout
2021 \begin_layout Itemize
2022 h: number: The height of area to blit.
2023 \end_layout
2025 \begin_layout Itemize
2026 operator: string: The operator to use.
2027 \end_layout
2029 \begin_deeper
2030 \begin_layout Itemize
2031 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2032  DestOut, Clear or Xor.
2033 \end_layout
2035 \end_deeper
2036 \begin_layout Standard
2037 Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
2038  operator.
2040 \end_layout
2042 \begin_layout Itemize
2043 Color index 0 in source and target is treated as background.
2044 \end_layout
2046 \begin_layout Subsubsection
2047 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2048  Porter-Duff composition
2049 \end_layout
2051 \begin_layout Itemize
2052 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2053  operator)
2054 \end_layout
2056 \begin_layout Itemize
2057 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2058 \end_layout
2060 \begin_layout Standard
2061 Parameters:
2062 \end_layout
2064 \begin_layout Itemize
2065 dest: BITMAP: The target bitmap to blit to.
2066 \end_layout
2068 \begin_layout Itemize
2069 dx: number: The x-coordinate in target.
2070 \end_layout
2072 \begin_layout Itemize
2073 dy: number: The y-coordinate in target.
2074 \end_layout
2076 \begin_layout Itemize
2077 src: BITMAP: The source bitmap.
2078 \end_layout
2080 \begin_layout Itemize
2081 sx: number: The x-coordinate in source.
2082 \end_layout
2084 \begin_layout Itemize
2085 sy: number: The y-coordinate in source.
2086 \end_layout
2088 \begin_layout Itemize
2089 w: number: The width of area to blit.
2090 \end_layout
2092 \begin_layout Itemize
2093 h: number: The height of area to blit.
2094 \end_layout
2096 \begin_layout Itemize
2097 hscl: number: Horizontal scale factor (integer).
2098 \end_layout
2100 \begin_layout Itemize
2101 vscl: number: Vertical scale factor (integer).
2102  Defaults to the same as <hscl>.
2103 \end_layout
2105 \begin_layout Itemize
2106 operator: string: The operator to use.
2107 \end_layout
2109 \begin_deeper
2110 \begin_layout Itemize
2111 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2112  DestOut, Clear or Xor.
2113 \end_layout
2115 \end_deeper
2116 \begin_layout Standard
2117 Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2118  like BITMAP:blit_scaled.
2119 \end_layout
2121 \begin_layout Subsubsection
2122 Method blit_priority: Blit a bitmap into another with color priority
2123 \end_layout
2125 \begin_layout Itemize
2126 Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
2127 \end_layout
2129 \begin_layout Itemize
2130 Deprecated: gui.bitmap_blit_priority(dest, ...)
2131 \end_layout
2133 \begin_layout Standard
2134 Parameters:
2135 \end_layout
2137 \begin_layout Itemize
2138 dest: BITMAP: The target bitmap to blit to.
2139 \end_layout
2141 \begin_layout Itemize
2142 dx: number: The x-coordinate in target.
2143 \end_layout
2145 \begin_layout Itemize
2146 dy: number: The y-coordinate in target.
2147 \end_layout
2149 \begin_layout Itemize
2150 src: BITMAP: The source bitmap.
2151 \end_layout
2153 \begin_layout Itemize
2154 sx: number: The x-coordinate in source.
2155 \end_layout
2157 \begin_layout Itemize
2158 sy: number: The y-coordinate in source.
2159 \end_layout
2161 \begin_layout Itemize
2162 w: number: The width of area to blit.
2163 \end_layout
2165 \begin_layout Itemize
2166 h: number: The height of area to blit.
2167 \end_layout
2169 \begin_layout Standard
2170 Like BITMAP:blit, but only copy pixels where source color index is greater
2171  than destination color index.
2172 \end_layout
2174 \begin_layout Subsubsection
2175 Method blit_scaled_priority: Blit a bitmap into another with color priority
2176  and scaling
2177 \end_layout
2179 \begin_layout Itemize
2180 Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
2181 \end_layout
2183 \begin_layout Itemize
2184 Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
2185 \end_layout
2187 \begin_layout Standard
2188 Parameters:
2189 \end_layout
2191 \begin_layout Itemize
2192 dest: BITMAP: The target bitmap to blit to.
2193 \end_layout
2195 \begin_layout Itemize
2196 dx: number: The x-coordinate in target.
2197 \end_layout
2199 \begin_layout Itemize
2200 dy: number: The y-coordinate in target.
2201 \end_layout
2203 \begin_layout Itemize
2204 src: BITMAP: The source bitmap.
2205 \end_layout
2207 \begin_layout Itemize
2208 sx: number: The x-coordinate in source.
2209 \end_layout
2211 \begin_layout Itemize
2212 sy: number: The y-coordinate in source.
2213 \end_layout
2215 \begin_layout Itemize
2216 w: number: The width of area to blit.
2217 \end_layout
2219 \begin_layout Itemize
2220 h: number: The height of area to blit.
2221 \end_layout
2223 \begin_layout Itemize
2224 hscl: number: Horizontal scale factor (integer).
2225 \end_layout
2227 \begin_layout Itemize
2228 vscl: number: Vertical scale factor (integer).
2229  Defaults to the same as <hscl>.
2230 \end_layout
2232 \begin_layout Standard
2233 Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
2234 caled.
2235 \end_layout
2237 \begin_layout Subsubsection
2238 Method save_png: Save a bitmap to PNG
2239 \end_layout
2241 \begin_layout Itemize
2242 Syntax: bitmap:save_png(filename, [base], palette)
2243 \end_layout
2245 \begin_layout Itemize
2246 Syntax: data bitmap:save_png(palette)
2247 \end_layout
2249 \begin_layout Itemize
2250 Deprecated: ...
2251  gui.bitmap_save_png(bitmap, ...)
2252 \end_layout
2254 \begin_layout Standard
2255 Parameters:
2256 \end_layout
2258 \begin_layout Itemize
2259 bitmap: BITMAP: The bitmap to save.
2260 \end_layout
2262 \begin_layout Itemize
2263 filename: string: The filename to save to.
2264 \end_layout
2266 \begin_layout Itemize
2267 base: string: The base filename is resolved relative to.
2268 \end_layout
2270 \begin_layout Itemize
2271 palette: PALETTE: The palette to use.
2272 \end_layout
2274 \begin_layout Standard
2275 Return value:
2276 \end_layout
2278 \begin_layout Itemize
2279 data: string: BASE64 encoded PNG data.
2280 \end_layout
2282 \begin_layout Standard
2283 Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
2284  to <base>) or return BASE64 encoding of it.
2285 \end_layout
2287 \begin_layout Subsubsection
2288 Method hash: Hash a bitmap
2289 \end_layout
2291 \begin_layout Itemize
2292 Syntax: hash bitmap:hash()
2293 \end_layout
2295 \begin_layout Itemize
2296 Deprecated: hash bitmap:hash(bitmap)
2297 \end_layout
2299 \begin_layout Standard
2300 Parameters:
2301 \end_layout
2303 \begin_layout Itemize
2304 bitmap: BITMAP: The bitmap to hash.
2305 \end_layout
2307 \begin_layout Standard
2308 Return value:
2309 \end_layout
2311 \begin_layout Itemize
2312 hash: string: 64-hex digit hash
2313 \end_layout
2315 \begin_layout Standard
2316 Hashes bitmap <bitmap> and returns crypto-strong hash.
2318 \end_layout
2320 \begin_layout Itemize
2321 Color order in bitmap is significant.
2322 \end_layout
2324 \begin_layout Standard
2325 \begin_inset Newpage pagebreak
2326 \end_inset
2329 \end_layout
2331 \begin_layout Subsection
2332 DBITMAP: Direct-color bitmap
2333 \end_layout
2335 \begin_layout Subsubsection
2336 Static function: new: Create a new bitmap
2337 \end_layout
2339 \begin_layout Itemize
2340 Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
2341 \end_layout
2343 \begin_layout Itemize
2344 Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
2345 \end_layout
2347 \begin_layout Itemize
2348 Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
2349 \end_layout
2351 \begin_layout Standard
2352 Parameters:
2353 \end_layout
2355 \begin_layout Itemize
2356 w: number: The width of new bitmap.
2357 \end_layout
2359 \begin_layout Itemize
2360 h: number: The height of new bitmap.
2361 \end_layout
2363 \begin_layout Itemize
2364 true: boolean: Fixed boolean true
2365 \end_layout
2367 \begin_layout Itemize
2368 fillcolor: The color to fill the bitmap with (default transparent).
2369 \end_layout
2371 \begin_layout Standard
2372 Return value:
2373 \end_layout
2375 \begin_layout Itemize
2376 bitmap: DBITMAP: The new bitmap.
2377 \end_layout
2379 \begin_layout Standard
2380 Create a new direct-color bitmap of size <w>*<h>, initially filled with
2381  <fillcolor>.
2382 \end_layout
2384 \begin_layout Subsubsection
2385 Method draw: Draw a bitmap
2386 \end_layout
2388 \begin_layout Itemize
2389 Syntax: bitmap.draw(x, y)
2390 \end_layout
2392 \begin_layout Itemize
2393 Deprecated: gui.bitmap_draw(x, y, bitmap)
2394 \end_layout
2396 \begin_layout Standard
2397 Parameters:
2398 \end_layout
2400 \begin_layout Itemize
2401 bitmap: DBITMAP: The bitmap to draw.
2402 \end_layout
2404 \begin_layout Itemize
2405 x: number: X-coordinate on screen.
2406 \end_layout
2408 \begin_layout Itemize
2409 y: number: Y-coordinate on screen.
2410 \end_layout
2412 \begin_layout Standard
2413 Draw bitmap <bitmap> on screen at <x>,<y>.
2414 \end_layout
2416 \begin_layout Subsubsection
2417 Method draw_outside: Draw a bitmap outside game area
2418 \end_layout
2420 \begin_layout Itemize
2421 Syntax: dbitmap:draw_outside(x, y, palette)
2422 \end_layout
2424 \begin_layout Standard
2425 Like dbitmap:draw, but does not draw on game area.
2426 \end_layout
2428 \begin_layout Subsubsection
2429 Method draw_clip: Draw a bitmap, with clipping
2430 \end_layout
2432 \begin_layout Itemize
2433 Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
2434 \end_layout
2436 \begin_layout Standard
2437 Parameters:
2438 \end_layout
2440 \begin_layout Itemize
2441 bitmap: DBITMAP: The bitmap to draw
2442 \end_layout
2444 \begin_layout Itemize
2445 x: number: The x-coordinate on screen.
2446 \end_layout
2448 \begin_layout Itemize
2449 y: number: The y-coordinate on screen.
2450 \end_layout
2452 \begin_layout Itemize
2453 x0: The smallest bitmap x coordinate to draw.
2454 \end_layout
2456 \begin_layout Itemize
2457 y0: The smallest bitmap y coordinate to draw.
2458 \end_layout
2460 \begin_layout Itemize
2461 width: Width of region to draw
2462 \end_layout
2464 \begin_layout Itemize
2465 height: Height of region to draw.
2466 \end_layout
2468 \begin_layout Standard
2469 Like dbitmap:draw, but clip the bitmap area drawn.
2470 \end_layout
2472 \begin_layout Subsubsection
2473 Method draw_clip_outside: Draw a bitmap outside game are, with clipping
2474 \end_layout
2476 \begin_layout Itemize
2477 Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
2478 \end_layout
2480 \begin_layout Standard
2481 Like dbitmap:draw_clip, but only draw outside game area.
2482 \end_layout
2484 \begin_layout Subsubsection
2485 Method pset: Set pixel in bitmap
2486 \end_layout
2488 \begin_layout Itemize
2489 Syntax: bitmap:pset(x, y, color)
2490 \end_layout
2492 \begin_layout Itemize
2493 Deprecaed: gui.bitmap_pset(bitmap, ...)
2494 \end_layout
2496 \begin_layout Standard
2497 Parameters:
2498 \end_layout
2500 \begin_layout Itemize
2501 bitmap: DBITMAP: The bitmap to manipulate.
2502 \end_layout
2504 \begin_layout Itemize
2505 x: number: x-coordinate of pixel to set.
2506 \end_layout
2508 \begin_layout Itemize
2509 y: number: y-coordinate of pixel to set.
2510 \end_layout
2512 \begin_layout Itemize
2513 color: number/string: The color to set.
2514 \end_layout
2516 \begin_layout Standard
2517 Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
2518 \end_layout
2520 \begin_layout Subsubsection
2521 Method pget: Get pixel in bitmap
2522 \end_layout
2524 \begin_layout Itemize
2525 Syntax: color bitmap:pget(x,y)
2526 \end_layout
2528 \begin_layout Itemize
2529 Deprecated: color gui.bitmap_pget(bitmap, ...)
2530 \end_layout
2532 \begin_layout Standard
2533 Parameters:
2534 \end_layout
2536 \begin_layout Itemize
2537 bitmap: DBITMAP: The bitmap to query.
2538 \end_layout
2540 \begin_layout Itemize
2541 x: number: x-coordinate of pixel to get.
2542 \end_layout
2544 \begin_layout Itemize
2545 y: number: y-coordinate of pixel to get.
2546 \end_layout
2548 \begin_layout Standard
2549 Returns:
2550 \end_layout
2552 \begin_layout Itemize
2553 color: number: The color of specified pixel.
2554 \end_layout
2556 \begin_layout Standard
2557 Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
2558 \end_layout
2560 \begin_layout Subsubsection
2561 Method size: Get size of bitmap
2562 \end_layout
2564 \begin_layout Itemize
2565 Syntax: width, height bitmap:size()
2566 \end_layout
2568 \begin_layout Itemize
2569 Syntax: width, height gui.bitmap_size(bitmap)
2570 \end_layout
2572 \begin_layout Standard
2573 Parameters:
2574 \end_layout
2576 \begin_layout Itemize
2577 bitmap: DBITMAP: The bitmap to query.
2578 \end_layout
2580 \begin_layout Standard
2581 Returns:
2582 \end_layout
2584 \begin_layout Itemize
2585 width: number: The width of the bitmap.
2586 \end_layout
2588 \begin_layout Itemize
2589 height: number: The height of the bitmap.
2590 \end_layout
2592 \begin_layout Standard
2593 Get size of bitmap <bitmap>.
2594 \end_layout
2596 \begin_layout Subsubsection
2597 Method blit: Blit a bitmap into another
2598 \end_layout
2600 \begin_layout Itemize
2601 Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
2602 \end_layout
2604 \begin_layout Itemize
2605 Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
2606 \end_layout
2608 \begin_layout Itemize
2609 Deprecated: gui.bitmap_blit(dest, ...)
2610 \end_layout
2612 \begin_layout Standard
2613 Parameters:
2614 \end_layout
2616 \begin_layout Itemize
2617 dest: DBITMAP: The target bitmap to blit to.
2618 \end_layout
2620 \begin_layout Itemize
2621 dx: number: The x-coordinate in target.
2622 \end_layout
2624 \begin_layout Itemize
2625 dy: number: The y-coordinate in target.
2626 \end_layout
2628 \begin_layout Itemize
2629 src: BITMAP/DBITMAP: The source bitmap.
2630 \end_layout
2632 \begin_layout Itemize
2633 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2634 \end_layout
2636 \begin_layout Itemize
2637 sx: number: The x-coordinate in source.
2638 \end_layout
2640 \begin_layout Itemize
2641 sy: number: The y-coordinate in source.
2642 \end_layout
2644 \begin_layout Itemize
2645 w: number: The width of area to blit.
2646 \end_layout
2648 \begin_layout Itemize
2649 h: number: The height of area to blit.
2650 \end_layout
2652 \begin_layout Itemize
2653 ck: number: The color key.
2654  Pixels with this index are not copied.
2655 \end_layout
2657 \begin_deeper
2658 \begin_layout Itemize
2659 If none is specified, all pixels are copied.
2660 \end_layout
2662 \begin_layout Itemize
2663 If <src> is paletted, this is color index, otherwise it is a color.
2664 \end_layout
2666 \end_deeper
2667 \begin_layout Standard
2668 Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
2669  if indexed) into <dest> at <dx>,<dy>.
2670  If a color key <ck> is specified, pixels of that color are not copied.
2671 \end_layout
2673 \begin_layout Subsubsection
2674 Method blit_scaled: Blit a bitmap into another with scaling
2675 \end_layout
2677 \begin_layout Itemize
2678 Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
2679 \end_layout
2681 \begin_layout Itemize
2682 Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
2683  [ck])
2684 \end_layout
2686 \begin_layout Itemize
2687 Deprecated: gui.bitmap_blit_scaled(dest, ...)
2688 \end_layout
2690 \begin_layout Standard
2691 Parameters:
2692 \end_layout
2694 \begin_layout Itemize
2695 dest: DBITMAP: The target bitmap to blit to.
2696 \end_layout
2698 \begin_layout Itemize
2699 dx: number: The x-coordinate in target.
2700 \end_layout
2702 \begin_layout Itemize
2703 dy: number: The y-coordinate in target.
2704 \end_layout
2706 \begin_layout Itemize
2707 src: BITMAP/DBITMAP: The source bitmap.
2708 \end_layout
2710 \begin_layout Itemize
2711 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2712 \end_layout
2714 \begin_layout Itemize
2715 sx: number: The x-coordinate in source.
2716 \end_layout
2718 \begin_layout Itemize
2719 sy: number: The y-coordinate in source.
2720 \end_layout
2722 \begin_layout Itemize
2723 w: number: The width of area to blit.
2724 \end_layout
2726 \begin_layout Itemize
2727 h: number: The height of area to blit.
2728 \end_layout
2730 \begin_layout Itemize
2731 hscl: number: Horizontal scale factor (integer).
2732 \end_layout
2734 \begin_layout Itemize
2735 vscl: number: Vertical scale factor (integer).
2736  Defaults to the same as <hscl>.
2737 \end_layout
2739 \begin_layout Itemize
2740 ck: number: The color key.
2741  Pixels with this index are not copied.
2742 \end_layout
2744 \begin_deeper
2745 \begin_layout Itemize
2746 If none is specified, all pixels are copied.
2747 \end_layout
2749 \begin_layout Itemize
2750 If <src> is paletted, this is color index, otherwise it is a color.
2751 \end_layout
2753 \end_deeper
2754 \begin_layout Standard
2755 Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
2756  neighbor) by factor of <hscl>*<vscl>.
2757 \end_layout
2759 \begin_layout Subsubsection
2760 Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
2761 \end_layout
2763 \begin_layout Itemize
2764 Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
2765 \end_layout
2767 \begin_layout Itemize
2768 Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
2769 \end_layout
2771 \begin_layout Itemize
2772 Deprecated: gui.bitmap_blit_porterduff(dest, ...)
2773 \end_layout
2775 \begin_layout Standard
2776 Parameters:
2777 \end_layout
2779 \begin_layout Itemize
2780 dest: DBITMAP: The target bitmap to blit to.
2781 \end_layout
2783 \begin_layout Itemize
2784 dx: number: The x-coordinate in target.
2785 \end_layout
2787 \begin_layout Itemize
2788 dy: number: The y-coordinate in target.
2789 \end_layout
2791 \begin_layout Itemize
2792 src: BITMAP/DBITMAP: The source bitmap.
2793 \end_layout
2795 \begin_layout Itemize
2796 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2797 \end_layout
2799 \begin_layout Itemize
2800 sx: number: The x-coordinate in source.
2801 \end_layout
2803 \begin_layout Itemize
2804 sy: number: The y-coordinate in source.
2805 \end_layout
2807 \begin_layout Itemize
2808 w: number: The width of area to blit.
2809 \end_layout
2811 \begin_layout Itemize
2812 h: number: The height of area to blit.
2813 \end_layout
2815 \begin_layout Itemize
2816 operator: string: The operator to use.
2817 \end_layout
2819 \begin_deeper
2820 \begin_layout Itemize
2821 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2822  DestOut, Clear or Xor.
2823 \end_layout
2825 \end_deeper
2826 \begin_layout Standard
2827 Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
2828 f operator.
2830 \end_layout
2832 \begin_layout Itemize
2833 In target, fully transparent is background.
2834  In source, either fully transparent (if direct) or index 0 (if paletted)
2835  is treated as background.
2836 \end_layout
2838 \begin_layout Subsubsection
2839 Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
2840  Porter-Duff composition
2841 \end_layout
2843 \begin_layout Itemize
2844 Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
2845  operator)
2846 \end_layout
2848 \begin_layout Itemize
2849 Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
2850  [vscl], operator)
2851 \end_layout
2853 \begin_layout Itemize
2854 Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
2855 \end_layout
2857 \begin_layout Standard
2858 Parameters:
2859 \end_layout
2861 \begin_layout Itemize
2862 dest: DBITMAP: The target bitmap to blit to.
2863 \end_layout
2865 \begin_layout Itemize
2866 dx: number: The x-coordinate in target.
2867 \end_layout
2869 \begin_layout Itemize
2870 dy: number: The y-coordinate in target.
2871 \end_layout
2873 \begin_layout Itemize
2874 src: BITMAP/DBITMAP: The source bitmap.
2875 \end_layout
2877 \begin_layout Itemize
2878 srcpal: PALETTE: If <src> is indexed, this is the palette for source.
2879 \end_layout
2881 \begin_layout Itemize
2882 sx: number: The x-coordinate in source.
2883 \end_layout
2885 \begin_layout Itemize
2886 sy: number: The y-coordinate in source.
2887 \end_layout
2889 \begin_layout Itemize
2890 w: number: The width of area to blit.
2891 \end_layout
2893 \begin_layout Itemize
2894 h: number: The height of area to blit.
2895 \end_layout
2897 \begin_layout Itemize
2898 hscl: number: Horizontal scale factor (integer).
2899 \end_layout
2901 \begin_layout Itemize
2902 vscl: number: Vertical scale factor (integer).
2903  Defaults to the same as <hscl>.
2904 \end_layout
2906 \begin_layout Itemize
2907 operator: string: The operator to use.
2908 \end_layout
2910 \begin_deeper
2911 \begin_layout Itemize
2912 Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
2913  DestOut, Clear or Xor.
2914 \end_layout
2916 \end_deeper
2917 \begin_layout Standard
2918 Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
2919  like DBITMAP:blit_scaled.
2920 \end_layout
2922 \begin_layout Subsubsection
2923 Method adjust_transparency: Adjust transparency of bitmap
2924 \end_layout
2926 \begin_layout Itemize
2927 Syntax: bitmap:adjust_transparency(newvalue)
2928 \end_layout
2930 \begin_layout Itemize
2931 Deprecated: gui.adjust_transparency(bitmap, ...)
2932 \end_layout
2934 \begin_layout Standard
2935 Parameters:
2936 \end_layout
2938 \begin_layout Itemize
2939 bitmap: DBITMAP: The bitmap to adjust.
2940 \end_layout
2942 \begin_layout Itemize
2943 Number adj: The factor to multiply opaqueness with times 256.
2944 \end_layout
2946 \begin_layout Standard
2947 Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
2948 \end_layout
2950 \begin_layout Subsubsection
2951 Method save_png: Save a bitmap to PNG
2952 \end_layout
2954 \begin_layout Itemize
2955 Syntax: bitmap:save_png(filename, [base])
2956 \end_layout
2958 \begin_layout Itemize
2959 Syntax: data bitmap:save_png()
2960 \end_layout
2962 \begin_layout Itemize
2963 Deprecated: ...
2964  gui.bitmap_save_png(bitmap, ...)
2965 \end_layout
2967 \begin_layout Standard
2968 Parameters:
2969 \end_layout
2971 \begin_layout Itemize
2972 bitmap: DBITMAP: The bitmap to save.
2973 \end_layout
2975 \begin_layout Itemize
2976 filename: string: The filename to save to.
2977 \end_layout
2979 \begin_layout Itemize
2980 base: string: The base filename is resolved relative to.
2981 \end_layout
2983 \begin_layout Standard
2984 Return value:
2985 \end_layout
2987 \begin_layout Itemize
2988 data: string: BASE64 encoded PNG data.
2989 \end_layout
2991 \begin_layout Standard
2992 Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
2993  BASE64 encoding of it.
2994 \end_layout
2996 \begin_layout Subsubsection
2997 Method hash: Hash a bitmap
2998 \end_layout
3000 \begin_layout Itemize
3001 Syntax: hash bitmap:hash()
3002 \end_layout
3004 \begin_layout Itemize
3005 Deprecated: hash bitmap:hash(bitmap)
3006 \end_layout
3008 \begin_layout Standard
3009 Parameters:
3010 \end_layout
3012 \begin_layout Itemize
3013 bitmap: DBITMAP: The bitmap to hash.
3014 \end_layout
3016 \begin_layout Standard
3017 Return value:
3018 \end_layout
3020 \begin_layout Itemize
3021 hash: string: 64-hex digit hash
3022 \end_layout
3024 \begin_layout Standard
3025 Hashes bitmap <bitmap> and returns crypto-strong hash.
3027 \end_layout
3029 \begin_layout Subsection
3030 IMAGELOADER: Load an image
3031 \end_layout
3033 \begin_layout Subsubsection
3034 Static function load: Load a bitmap from file
3035 \end_layout
3037 \begin_layout Itemize
3038 Syntax: bitmap, palette gui.image.load(file, [base])
3039 \end_layout
3041 \begin_layout Itemize
3042 Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
3043 \end_layout
3045 \begin_layout Itemize
3046 Deprecated: ...
3047  gui.bitmap_load(...)
3048 \end_layout
3050 \begin_layout Standard
3051 Parameters:
3052 \end_layout
3054 \begin_layout Itemize
3055 file: string: The file to read.
3056 \end_layout
3058 \begin_layout Itemize
3059 base: string: The base to resolve <file> relative to.
3060 \end_layout
3062 \begin_layout Standard
3063 Returns:
3064 \end_layout
3066 \begin_layout Itemize
3067 bitmap: BITMAP/DBITMAP: The new bitmap
3068 \end_layout
3070 \begin_layout Itemize
3071 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3072  nil.
3073 \end_layout
3075 \begin_layout Standard
3076 Load a new bitmap and return it (plus associated palette if any).
3077 \end_layout
3079 \begin_layout Subsubsection
3080 Static function load_str: Load a bitmap from string
3081 \end_layout
3083 \begin_layout Itemize
3084 Syntax: bitmap, palette gui.image.load_str(data)
3085 \end_layout
3087 \begin_layout Itemize
3088 Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
3089 \end_layout
3091 \begin_layout Itemize
3092 Deprecated: ...
3093  gui.bitmap_load_str(...)
3094 \end_layout
3096 \begin_layout Standard
3097 Parameters:
3098 \end_layout
3100 \begin_layout Itemize
3101 data: string: The image data
3102 \end_layout
3104 \begin_layout Standard
3105 Returns:
3106 \end_layout
3108 \begin_layout Itemize
3109 bitmap: BITMAP/DBITMAP: The new bitmap
3110 \end_layout
3112 \begin_layout Itemize
3113 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3114  nil.
3115 \end_layout
3117 \begin_layout Standard
3118 Like IMAGELOADER:load, but read the bitmap from string <data> instead of
3119  file.
3120 \end_layout
3122 \begin_layout Subsubsection
3123 Static function load_png: Load a bitmap from PNG file
3124 \end_layout
3126 \begin_layout Itemize
3127 Syntax: bitmap, palette gui.image.load_png(file, [base])
3128 \end_layout
3130 \begin_layout Itemize
3131 Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
3132 \end_layout
3134 \begin_layout Itemize
3135 Deprecated: ...
3136  gui.bitmap_load_png(...)
3137 \end_layout
3139 \begin_layout Standard
3140 Parameters:
3141 \end_layout
3143 \begin_layout Itemize
3144 file: string: The file to read.
3145 \end_layout
3147 \begin_layout Itemize
3148 base: string: The base to resolve <file> relative to.
3149 \end_layout
3151 \begin_layout Standard
3152 Returns:
3153 \end_layout
3155 \begin_layout Itemize
3156 bitmap: BITMAP/DBITMAP: The new bitmap
3157 \end_layout
3159 \begin_layout Itemize
3160 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3161  nil.
3162 \end_layout
3164 \begin_layout Standard
3165 Like IMAGELOADER:load, but load a PNG file instead.
3166 \end_layout
3168 \begin_layout Subsubsection
3169 Static function load_png_str: Load a PNG bitmap from string
3170 \end_layout
3172 \begin_layout Itemize
3173 Syntax: bitmap, palette gui.image.load_png_str(data)
3174 \end_layout
3176 \begin_layout Itemize
3177 Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
3178 \end_layout
3180 \begin_layout Itemize
3181 Deprecated: ...
3182  gui.bitmap_load_png_str(...)
3183 \end_layout
3185 \begin_layout Standard
3186 Parameters:
3187 \end_layout
3189 \begin_layout Itemize
3190 data: string: The image data, base64 encoded.
3191 \end_layout
3193 \begin_layout Standard
3194 Returns:
3195 \end_layout
3197 \begin_layout Itemize
3198 bitmap: BITMAP/DBITMAP: The new bitmap
3199 \end_layout
3201 \begin_layout Itemize
3202 palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
3203  nil.
3204 \end_layout
3206 \begin_layout Standard
3207 Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
3208  <data> instead of file.
3209 \end_layout
3211 \begin_layout Standard
3212 \begin_inset Newpage pagebreak
3213 \end_inset
3216 \end_layout
3218 \begin_layout Subsection
3219 CUSTOMFONT: Arbitrary-sized bitmap font
3220 \end_layout
3222 \begin_layout Subsubsection
3223 Static function new: Return a new empty font
3224 \end_layout
3226 \begin_layout Itemize
3227 Syntax: font gui.font.new()
3228 \end_layout
3230 \begin_layout Itemize
3231 Syntax: font classes.CUSTOMFONT.new()
3232 \end_layout
3234 \begin_layout Itemize
3235 Deprecated: font gui.font_new()
3236 \end_layout
3238 \begin_layout Standard
3239 Return value:
3240 \end_layout
3242 \begin_layout Itemize
3243 font: CUSTOMFONT: New font.
3244 \end_layout
3246 \begin_layout Standard
3247 Create a new font with no characters and return it.
3248 \end_layout
3250 \begin_layout Subsubsection
3251 Static function: load: Load a font file
3252 \end_layout
3254 \begin_layout Itemize
3255 Syntax: font gui.font.load(file, [base])
3256 \end_layout
3258 \begin_layout Itemize
3259 Syntax: font gui.font.load()
3260 \end_layout
3262 \begin_layout Itemize
3263 Syntax: font classes.CUSTOMFONT.load(file, [base])
3264 \end_layout
3266 \begin_layout Itemize
3267 Syntax: font classes.CUSTOMFONT.load()
3268 \end_layout
3270 \begin_layout Itemize
3271 Deprecated: font gui.loadfont(...)
3272 \end_layout
3274 \begin_layout Standard
3275 Parameters:
3276 \end_layout
3278 \begin_layout Itemize
3279 file: string: The file to read the font from
3280 \end_layout
3282 \begin_layout Itemize
3283 base: string: The file to resolve <file> relative to.
3284 \end_layout
3286 \begin_layout Standard
3287 Return value:
3288 \end_layout
3290 \begin_layout Itemize
3291 font: CUSTOMFONT: New font.
3292 \end_layout
3294 \begin_layout Standard
3295 Load font from file <file> (relative to <base>).
3296  If no filename is given, system default font is loaded.
3297 \end_layout
3299 \begin_layout Subsubsection
3300 operator(): Render text to screen
3301 \end_layout
3303 \begin_layout Itemize
3304 Syntax: font(x, y, text, [fgc], [bgc], [hlc])
3305 \end_layout
3307 \begin_layout Standard
3308 Parmeters:
3309 \end_layout
3311 \begin_layout Itemize
3312 font: CUSTOMFONT: The font to use.
3313 \end_layout
3315 \begin_layout Itemize
3316 x: number: The x-position on screen to draw to.
3317 \end_layout
3319 \begin_layout Itemize
3320 y: number: The y-position on screen to draw to.
3321 \end_layout
3323 \begin_layout Itemize
3324 text: string: The text to draw.
3325 \end_layout
3327 \begin_layout Itemize
3328 fgc: number/string: Foreground color (default white).
3329 \end_layout
3331 \begin_layout Itemize
3332 bgc: number/string: Background color (default transparent).
3333 \end_layout
3335 \begin_layout Itemize
3336 hlc: number/string: Outline color (default transparent).
3337 \end_layout
3339 \begin_layout Standard
3340 Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
3341  onto screen.
3342 \end_layout
3344 \begin_layout Itemize
3345 If <hlc> is transparent, no outline is drawn.
3346 \end_layout
3348 \begin_layout Subsubsection
3349 Method edit: Alter glyph in font
3350 \end_layout
3352 \begin_layout Itemize
3353 Syntax: font:edit(string character, bitmap glyph)
3354 \end_layout
3356 \begin_layout Standard
3357 Parameters:
3358 \end_layout
3360 \begin_layout Itemize
3361 font: CUSTOMFONT: The font to edit.
3362 \end_layout
3364 \begin_layout Itemize
3365 character: string: The character to edit (UTF-8 encoded).
3366 \end_layout
3368 \begin_layout Itemize
3369 glyph: BITMAP: The bitmap to use.
3370 \end_layout
3372 \begin_layout Standard
3373 Replace character <character> in font <font> by <glyph>.
3374 \end_layout
3376 \begin_layout Itemize
3377 Color index 0 is background, everything else is foreground.
3378 \end_layout
3380 \begin_layout Itemize
3381 <character> may be empty string, meaning the replacement character used
3382  for bad characters.
3383 \end_layout
3385 \begin_layout Itemize
3386 <character> may be multi-codepoint string, meaning character used for that
3387  ligature.
3388 \end_layout
3390 \begin_layout Subsubsection
3391 Method dump: Dump font into file
3392 \end_layout
3394 \begin_layout Itemize
3395 Syntax: font:dump(string filename[, string base])
3396 \end_layout
3398 \begin_layout Standard
3399 Parameters:
3400 \end_layout
3402 \begin_layout Itemize
3403 filename: string: The file to dump to
3404 \end_layout
3406 \begin_layout Itemize
3407 base: string: The base filename
3408 \end_layout
3410 \begin_layout Standard
3411 Dump contents of <font> in file <filename> (resolved relative to <base>).
3412  The dump is in format CUSTOMFONT:load() can load.
3413 \end_layout
3415 \begin_layout Standard
3416 \begin_inset Newpage pagebreak
3417 \end_inset
3420 \end_layout
3422 \begin_layout Subsection
3423 ICONV: Character set conversions
3424 \end_layout
3426 \begin_layout Subsubsection
3427 Static function new: Create new character set converter
3428 \end_layout
3430 \begin_layout Itemize
3431 Syntax: iconv iconv.new(from, to);
3432 \end_layout
3434 \begin_layout Itemize
3435 Syntax: iconv classes.ICONV.new(from, to);
3436 \end_layout
3438 \begin_layout Itemize
3439 Deprecated: iconv iconv_new(...);
3440 \end_layout
3442 \begin_layout Standard
3443 Parameters:
3444 \end_layout
3446 \begin_layout Itemize
3447 from: string: The source character set.
3448 \end_layout
3450 \begin_layout Itemize
3451 to: string: The target character set.
3452 \end_layout
3454 \begin_layout Standard
3455 Returns:
3456 \end_layout
3458 \begin_layout Itemize
3459 iconv: ICONV: The converter.
3460 \end_layout
3462 \begin_layout Standard
3463 Create a character set converter, converting from <from> to <to> and return
3464  it.
3465 \end_layout
3467 \begin_layout Subsubsection
3468 Operator(): Convert string fragment from character set to another
3469 \end_layout
3471 \begin_layout Itemize
3472 Syntax: success, result, unconverted, error iconv(input)
3473 \end_layout
3475 \begin_layout Standard
3476 Parameters:
3477 \end_layout
3479 \begin_layout Itemize
3480 iconv: ICONV: The context to use.
3481 \end_layout
3483 \begin_layout Itemize
3484 input: string: The input to convert.
3485 \end_layout
3487 \begin_layout Standard
3488 Return value:
3489 \end_layout
3491 \begin_layout Itemize
3492 success: boolean: True if conversion was successful, false if not.
3493 \end_layout
3495 \begin_layout Itemize
3496 result: string: The string (partially) converted.
3497 \end_layout
3499 \begin_layout Itemize
3500 unconvered: number: Number of bytes that were not converted (only if <success>
3501  is false).
3502 \end_layout
3504 \begin_layout Itemize
3505 error: string: Error that caused conversion to stop (only if <success> is
3506  false).
3507 \end_layout
3509 \begin_deeper
3510 \begin_layout Itemize
3511 INVALID: The input string is invalid.
3512 \end_layout
3514 \begin_layout Itemize
3515 INCOMPLETE: The input string cuts off in middle of character.
3516 \end_layout
3518 \begin_layout Itemize
3519 INTERNALERR: Internal error.
3520 \end_layout
3522 \end_deeper
3523 \begin_layout Standard
3524 Convert a string <input> using character set converter <iconv> and return
3525  the result.
3526 \end_layout
3528 \begin_layout Standard
3529 \begin_inset Newpage pagebreak
3530 \end_inset
3533 \end_layout
3535 \begin_layout Subsection
3536 FILEREADER: Read a file as a stream
3537 \end_layout
3539 \begin_layout Subsubsection
3540 Static function open: Open a stream
3541 \end_layout
3543 \begin_layout Itemize
3544 Syntax: handle filereader.open(file, [base])
3545 \end_layout
3547 \begin_layout Itemize
3548 Syntax: handle classes.FILEREADER.open(file, [base])
3549 \end_layout
3551 \begin_layout Itemize
3552 Deprecated: handle open_file(file, [base])
3553 \end_layout
3555 \begin_layout Standard
3556 Parameters:
3557 \end_layout
3559 \begin_layout Itemize
3560 file: string: The filename to read.
3561 \end_layout
3563 \begin_layout Itemize
3564 base: string: The base <file> is resolved against.
3565 \end_layout
3567 \begin_layout Standard
3568 Returns:
3569 \end_layout
3571 \begin_layout Itemize
3572 handle: FILEREADER: The new file reader.
3573 \end_layout
3575 \begin_layout Standard
3576 Open file <file> (relative to <base>) and return a handle to it.
3577 \end_layout
3579 \begin_layout Subsubsection
3580 operator(): Read line/bytes from stream
3581 \end_layout
3583 \begin_layout Itemize
3584 Syntax: result handle()
3585 \end_layout
3587 \begin_layout Itemize
3588 Syntax: result handle(bytes)
3589 \end_layout
3591 \begin_layout Standard
3592 Parameters:
3593 \end_layout
3595 \begin_layout Itemize
3596 handle: FILEREADER: The handle to read from.
3597 \end_layout
3599 \begin_layout Itemize
3600 bytes: Number of bytes to read (default is next line).
3601 \end_layout
3603 \begin_layout Standard
3604 Returns:
3605 \end_layout
3607 \begin_layout Itemize
3608 result: string: The read data, or nil on end-of-file.
3609 \end_layout
3611 \begin_layout Standard
3612 Reads next line or <bytes> bytes from specified file handle <handle>.
3613 \end_layout
3615 \begin_layout Itemize
3616 If reading specified number of bytes, the bytes are read in binary mode
3617  (as-is).
3618 \end_layout
3620 \begin_layout Itemize
3621 If reading next line, the line is read in text mode (any line ending is
3622  skpped).
3623 \end_layout
3625 \begin_layout Subsubsection
3626 Method lines: Iterator to read all lines
3627 \end_layout
3629 \begin_layout Itemize
3630 Syntax: for line in handle:lines() do ...
3631  end
3632 \end_layout
3634 \begin_layout Standard
3635 Parameters:
3636 \end_layout
3638 \begin_layout Itemize
3639 handle: FILEREADER: The handle to read.
3640 \end_layout
3642 \begin_layout Standard
3643 Returns:
3644 \end_layout
3646 \begin_layout Itemize
3647 A lua iterator with one variable.
3648 \end_layout
3650 \begin_layout Standard
3651 Return a Lua iterator that iterates all the lines in <handle>.
3652 \end_layout
3654 \begin_layout Standard
3655 \begin_inset Newpage pagebreak
3656 \end_inset
3659 \end_layout
3661 \begin_layout Subsection
3662 COMPARE_OBJ: Watch memory area for changes
3663 \end_layout
3665 \begin_layout Standard
3666 Objects of this class allow fast checking for modifications to given memory
3667  block.
3668 \end_layout
3670 \begin_layout Subsubsection
3671 Static function new: Create a checker
3672 \end_layout
3674 \begin_layout Itemize
3675 Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
3676  stride])
3677 \end_layout
3679 \begin_layout Itemize
3680 Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
3681 \end_layout
3683 \begin_layout Standard
3684 Parameters:
3685 \end_layout
3687 \begin_layout Itemize
3688 marea: string: The memory area to interpret <offset> against.
3689 \end_layout
3691 \begin_layout Itemize
3692 offset: number: The initial offset in memory area.
3693 \end_layout
3695 \begin_layout Itemize
3696 addrobj: ADDRESS: The memory address.
3697 \end_layout
3699 \begin_layout Itemize
3700 size: number: The number of bytes in each row.
3701 \end_layout
3703 \begin_layout Itemize
3704 rows: number: The number of rows.
3705  Default is 1.
3706 \end_layout
3708 \begin_layout Itemize
3709 stride: number: The number of bytes offset increments from one row to next.
3710 \end_layout
3712 \begin_layout Standard
3713 Returns:
3714 \end_layout
3716 \begin_layout Itemize
3717 A handle to object.
3718 \end_layout
3720 \begin_layout Standard
3721 Return an object watching specified memory area.
3722 \end_layout
3724 \begin_layout Itemize
3725 Note: For fastest operation, limit checks to inside one memory area (that
3726  has to be mappable, individual RAM areas often are).
3727 \end_layout
3729 \begin_layout Subsubsection
3730 operator(): Check area for modifications
3731 \end_layout
3733 \begin_layout Itemize
3734 Syntax: boolean handle()
3735 \end_layout
3737 \begin_layout Standard
3738 Returns:
3739 \end_layout
3741 \begin_layout Itemize
3742 True if memory block has been modified since last call (or object creation
3743  if first call), false if not.
3744 \end_layout
3746 \begin_layout Standard
3747 Check if the block has been modified.
3748 \end_layout
3750 \begin_layout Subsection
3751 ADDRESS: Memory address
3752 \end_layout
3754 \begin_layout Standard
3755 Objects of this class contain a memory address.
3756 \end_layout
3758 \begin_layout Subsubsection
3759 Static function new: Create new memory address
3760 \end_layout
3762 \begin_layout Itemize
3763 Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
3764 \end_layout
3766 \begin_layout Itemize
3767 Syntax: ADDRESS memory.address.new(string marea, number offset)
3768 \end_layout
3770 \begin_layout Itemize
3771 Syntax: ADDRESS memory.mkaddr(string marea, number offset)
3772 \end_layout
3774 \begin_layout Standard
3775 Parameters:
3776 \end_layout
3778 \begin_layout Itemize
3779 marea: The memory area
3780 \end_layout
3782 \begin_layout Itemize
3783 offset: The offset in memory area.
3784 \end_layout
3786 \begin_layout Standard
3787 Returns:
3788 \end_layout
3790 \begin_layout Itemize
3791 The memory area.
3792 \end_layout
3794 \begin_layout Standard
3795 Construct a new memory address object.
3796 \end_layout
3798 \begin_layout Subsubsection
3799 Method: addr: Get global address
3800 \end_layout
3802 \begin_layout Itemize
3803 Syntax: number addr:addr()
3804 \end_layout
3806 \begin_layout Standard
3807 Parameters:
3808 \end_layout
3810 \begin_layout Itemize
3811 addr: ADRESS: The original address.
3812 \end_layout
3814 \begin_layout Standard
3815 Returns:
3816 \end_layout
3818 \begin_layout Itemize
3819 The global address corresponding to this address.
3820 \end_layout
3822 \begin_layout Subsubsection
3823 Method: vma: Get memory area
3824 \end_layout
3826 \begin_layout Itemize
3827 Syntax: string addr:vma()
3828 \end_layout
3830 \begin_layout Standard
3831 Parameters:
3832 \end_layout
3834 \begin_layout Itemize
3835 addr: ADRESS: The original address.
3836 \end_layout
3838 \begin_layout Standard
3839 Returns:
3840 \end_layout
3842 \begin_layout Itemize
3843 The memory area corresponding to this address.
3844 \end_layout
3846 \begin_layout Subsubsection
3847 Method: offset: Get memory area offset
3848 \end_layout
3850 \begin_layout Itemize
3851 Syntax: string addr:offset()
3852 \end_layout
3854 \begin_layout Standard
3855 Parameters:
3856 \end_layout
3858 \begin_layout Itemize
3859 addr: ADRESS: The original address.
3860 \end_layout
3862 \begin_layout Standard
3863 Returns:
3864 \end_layout
3866 \begin_layout Itemize
3867 The offset in memory area corresponding to this address.
3868 \end_layout
3870 \begin_layout Subsubsection
3871 Method: replace: Replace address part
3872 \end_layout
3874 \begin_layout Itemize
3875 Syntax: ADDRESS addr:replace(offset[, bits])
3876 \end_layout
3878 \begin_layout Standard
3879 Parameters:
3880 \end_layout
3882 \begin_layout Itemize
3883 addr: ADRESS: The original address.
3884 \end_layout
3886 \begin_layout Itemize
3887 offset: number: The new offset
3888 \end_layout
3890 \begin_layout Itemize
3891 bits: number: The number of LSB to replace.
3892 \end_layout
3894 \begin_layout Standard
3895 Returns:
3896 \end_layout
3898 \begin_layout Itemize
3899 The modified address
3900 \end_layout
3902 \begin_layout Standard
3903 Returns a new address, with <bits> (all if missing) least significant bits
3904  of <addr> replaced by LSB of <offset>.
3905 \end_layout
3907 \begin_layout Subsubsection
3908 Method: add: Add to address
3909 \end_layout
3911 \begin_layout Itemize
3912 Syntax: ADDRESS addr:add(offset)
3913 \end_layout
3915 \begin_layout Itemize
3916 Syntax: ADDRESS addr:add(number, stride)
3917 \end_layout
3919 \begin_layout Itemize
3920 Syntax: ADDRESS addr:add(number, stride, offset)
3921 \end_layout
3923 \begin_layout Standard
3924 Parameters:
3925 \end_layout
3927 \begin_layout Itemize
3928 addr: ADRESS: The original address.
3929 \end_layout
3931 \begin_layout Itemize
3932 offset: number: Offset to add.
3933 \end_layout
3935 \begin_layout Itemize
3936 number: number: Number of table strides to add.
3937 \end_layout
3939 \begin_layout Itemize
3940 stride: number: The table stride.
3941 \end_layout
3943 \begin_layout Standard
3944 Returns:
3945 \end_layout
3947 \begin_layout Itemize
3948 The modified address
3949 \end_layout
3951 \begin_layout Standard
3952 Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
3953  address <addr>.
3954 \end_layout
3956 \begin_layout Subsection
3957 ADDRESS:<op>: Read/Write memory
3958 \end_layout
3960 \begin_layout Itemize
3961 Syntax: none addr:<op>(value)
3962 \end_layout
3964 \begin_layout Itemize
3965 Syntax: number addr:<op>()
3966 \end_layout
3968 \begin_layout Standard
3969 Parameters:
3970 \end_layout
3972 \begin_layout Itemize
3973 addr: ADDRESS: The address to read/write.
3974 \end_layout
3976 \begin_layout Itemize
3977 value: number: The number to write.
3978 \end_layout
3980 \begin_layout Standard
3981 Returns:
3982 \end_layout
3984 \begin_layout Itemize
3985 The value read.
3986 \end_layout
3988 \begin_layout Standard
3989 Read/Write value from/to given address <addr>.
3990  The value written is <value>.
3991  <Op> is of form: [i][s]<type>, where:
3992 \end_layout
3994 \begin_layout Itemize
3995 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
3996 \end_layout
3998 \begin_layout Itemize
3999 'i' signifies that the value is treated as opposite-to-normal endianess,
4000 \end_layout
4002 \begin_layout Itemize
4003 's' signifies that value is treated as signed (not available for floating-point).
4004 \end_layout
4006 \begin_layout Standard
4007 \begin_inset Newpage pagebreak
4008 \end_inset
4011 \end_layout
4013 \begin_layout Section
4014 Global
4015 \end_layout
4017 \begin_layout Subsection
4018 print: Print values to console
4019 \end_layout
4021 \begin_layout Itemize
4022 Syntax: none print(value...
4023  values)
4024 \end_layout
4026 \begin_layout Standard
4027 Prints specified values to console.
4028  Can print any Lua type at least enough to identify the type and instance.
4029 \end_layout
4031 \begin_layout Subsection
4032 tostringx: Format a value to string
4033 \end_layout
4035 \begin_layout Itemize
4036 Syntax: string tostringx(value val)
4037 \end_layout
4039 \begin_layout Standard
4040 Formats value <val> like print would, and returns the result as a string.
4041 \end_layout
4043 \begin_layout Subsection
4044 exec: Execute lsnes commands
4045 \end_layout
4047 \begin_layout Itemize
4048 Syntax: none exec(string cmd)
4049 \end_layout
4051 \begin_layout Standard
4052 Execute lsnes command <cmd>.
4053 \end_layout
4055 \begin_layout Subsection
4056 utime: Get current time
4057 \end_layout
4059 \begin_layout Itemize
4060 Syntax: (number,number) utime()
4061 \end_layout
4063 \begin_layout Standard
4064 Returns two numbers.
4065  First is time since some epoch in seconds, the second is microseconds mod
4066  10^6 since that epoch.
4067 \end_layout
4069 \begin_layout Subsection
4070 set_idle_timeout: Run function after timeout when emulator is idle
4071 \end_layout
4073 \begin_layout Itemize
4074 Syntax: none set_idle_timeout(number timeout)
4075 \end_layout
4077 \begin_layout Standard
4078 Set number of microseconds to block idle for.
4079  After this timeout has expired, on_idle() will be called once.
4080 \end_layout
4082 \begin_layout Subsection
4083 set_timer_timeout: Run function after timeout.
4084 \end_layout
4086 \begin_layout Itemize
4087 Syntax: none set_timer_timeout(number timeout)
4088 \end_layout
4090 \begin_layout Standard
4091 Set number of microseconds to block timer for.
4092  After this timeout has expired, on_timer() will be called once.
4093 \end_layout
4095 \begin_layout Subsection
4096 bus_address: Look up address in system bus.
4097 \end_layout
4099 \begin_layout Itemize
4100 Syntax: none bus_address(number bus_addr)
4101 \end_layout
4103 \begin_layout Standard
4104 Returns virtual address corresponding to specified address on system bus.
4105 \end_layout
4107 \begin_layout Subsection
4108 loopwrapper: Convert loop into callable function
4109 \end_layout
4111 \begin_layout Itemize
4112 Syntax: function loopwrapper(function fun, ...)
4113 \end_layout
4115 \begin_layout Standard
4116 Calls function <fun> with function and specified arguments.
4117  The function passed suspends execution until the function returned is called.
4118  Handy for linear flow control among multiple invocations of a hook.
4119  Example code:
4120 \end_layout
4122 \begin_layout LyX-Code
4123 on_paint = loopwrapper(function(wait)
4124 \end_layout
4126 \begin_deeper
4127 \begin_layout LyX-Code
4128 while true do
4129 \end_layout
4131 \begin_deeper
4132 \begin_layout LyX-Code
4133 gui.text(0, 0, 
4134 \begin_inset Quotes eld
4135 \end_inset
4137 Test!
4138 \begin_inset Quotes erd
4139 \end_inset
4142 \end_layout
4144 \begin_layout LyX-Code
4145 wait();
4146 \end_layout
4148 \end_deeper
4149 \begin_layout LyX-Code
4151 \end_layout
4153 \end_deeper
4154 \begin_layout LyX-Code
4155 end);
4156 \end_layout
4158 \begin_layout Subsection
4159 list_bindings: List keybindings
4160 \end_layout
4162 \begin_layout Itemize
4163 Syntax: table list_bindings([string cmd])
4164 \end_layout
4166 \begin_layout Standard
4167 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
4168  If <cmd> is specified, the table is limited to that command.
4169  Also searches for controller keys.
4170 \end_layout
4172 \begin_layout Subsection
4173 get_alias: Get expansion of alias
4174 \end_layout
4176 \begin_layout Itemize
4177 Syntax: string get_alias(string aname)
4178 \end_layout
4180 \begin_layout Standard
4181 Get expansion of given alias <aname>.
4182 \end_layout
4184 \begin_layout Subsection
4185 set_alias: Set expansion of alias
4186 \end_layout
4188 \begin_layout Itemize
4189 Syntax: none set_alias(string aname, string value)
4190 \end_layout
4192 \begin_layout Standard
4193 Set expansion of given alias.
4194 \end_layout
4196 \begin_layout Subsection
4197 create_ibind: Create invese binding
4198 \end_layout
4200 \begin_layout Itemize
4201 Syntax: INVERSEBIND create_ibind(string name, string cmd)
4202 \end_layout
4204 \begin_layout Standard
4205 Return object representing inverse binding with specified name <name> and
4206  specified command <cmd>.
4207 \end_layout
4209 \begin_layout Itemize
4210 Note: To create press/release commands, use aliases +foo and -foo .
4211 \end_layout
4213 \begin_layout Itemize
4214 Note: Keep the returned object around.
4215 \end_layout
4217 \begin_layout Subsection
4218 create_command: Create a command
4219 \end_layout
4221 \begin_layout Itemize
4222 Syntax: COMMANDBIND create_command(string name, function a)
4223 \end_layout
4225 \begin_layout Itemize
4226 Syntax: COMMANDBIND create_command(string name, function a, function b)
4227 \end_layout
4229 \begin_layout Standard
4230 Return object representing a command (pair).
4231 \end_layout
4233 \begin_layout Itemize
4234 If only one function is specied, the command is level-sensitive, <a> is
4235  callback.
4236 \end_layout
4238 \begin_layout Itemize
4239 If <b> is function, the function is edge-sensitive, <a> is positive edge
4240  callback and <b> is negative edge callback.
4241 \end_layout
4243 \begin_layout Itemize
4244 All callbacks get single argument: The parameters passed.
4245 \end_layout
4247 \begin_layout Itemize
4248 Keep the returned object around.
4249 \end_layout
4251 \begin_layout Subsection
4252 loadfile: Load Lua script
4253 \end_layout
4255 \begin_layout Itemize
4256 Syntax: function loadfile(string filename[, string base])
4257 \end_layout
4259 \begin_layout Standard
4260 Load lua script from <filename>, resolved relative to <base> (if empty,
4261  current directory).
4262 \end_layout
4264 \begin_layout Subsection
4265 dofile: Execute Lua script
4266 \end_layout
4268 \begin_layout Itemize
4269 Syntax: function dofile(string filename[, string base])
4270 \end_layout
4272 \begin_layout Standard
4273 Execute lua script from <filename>, resolved relative to <base> (if empty,
4274  current directory) and return all return values.
4275 \end_layout
4277 \begin_layout Subsection
4278 resolve_filename: Resolve name of file relative to another
4279 \end_layout
4281 \begin_layout Itemize
4282 Syntax: string resolve_filename(string filename[, string base])
4283 \end_layout
4285 \begin_layout Standard
4286 Resolve name of file <filename> relative to <base> and return the result.
4287 \end_layout
4289 \begin_layout Subsection
4290 render_queue_function: Return paint function for render queue
4291 \end_layout
4293 \begin_layout Itemize
4294 Syntax: function render_queue_function(RENDERQUEUE rq)
4295 \end_layout
4297 \begin_layout Standard
4298 Return function that renders render queue <rq>.
4299 \end_layout
4301 \begin_layout Itemize
4302 Handy for paint callback if one is using render queues updated in other
4303  callbacks.
4304  As in:
4305 \end_layout
4307 \begin_layout LyX-Code
4308 handle = callback.paint:register(render_queue_function(my_rq));
4309 \end_layout
4311 \begin_layout Subsection
4312 get_directory_contents: Get files in directory
4313 \end_layout
4315 \begin_layout Itemize
4316 Syntax: table get_directory_contents(string name[, string base[, string
4317  pattern]])
4318 \end_layout
4320 \begin_layout Standard
4321 Return array containg all files in specified directory <name> (relative
4322  to <base>).
4323  If <pattern> is specified, the filenames are matched to specified regex.
4324  The returned filenames inherit path.
4325 \end_layout
4327 \begin_layout Subsection
4328 get_file_type: Get type of file
4329 \end_layout
4331 \begin_layout Itemize
4332 Syntax: string/nil get_file_type(string path)
4333 \end_layout
4335 \begin_layout Standard
4336 Return type of file <path>.
4337  Currently possible return values are:
4338 \end_layout
4340 \begin_layout Itemize
4341 regular: regular file
4342 \end_layout
4344 \begin_layout Itemize
4345 directory: subdirectory
4346 \end_layout
4348 \begin_layout Itemize
4349 unknown: Exists, but type not known (not anything above).
4350 \end_layout
4352 \begin_layout Itemize
4353 <nil>: File does not exist.
4354 \end_layout
4356 \begin_layout Subsection
4357 identify_class: Identify class of object
4358 \end_layout
4360 \begin_layout Itemize
4361 Syntax: string identify_class(userdata object)
4362 \end_layout
4364 \begin_layout Standard
4365 Identifies the class of userdata <object>, if possible.
4366  If no identification is possible, returns 
4367 \begin_inset Quotes eld
4368 \end_inset
4370 unknown
4371 \begin_inset Quotes erd
4372 \end_inset
4375 \end_layout
4377 \begin_layout Subsection
4378 lookup_class: Lookup class by name
4379 \end_layout
4381 \begin_layout Itemize
4382 Syntax: classobj lookup_class(string name)
4383 \end_layout
4385 \begin_layout Standard
4386 Looks up class corresponding to <name>, if possible.
4387  If not found, returns nil.
4388  The classobj has following fields:
4389 \end_layout
4391 \begin_layout Itemize
4392 _static_methods: Return static method names
4393 \end_layout
4395 \begin_layout Itemize
4396 _class_methods: Return class method names
4397 \end_layout
4399 \begin_layout Itemize
4400 <static-function-name>: The specified static function.
4401 \end_layout
4403 \begin_layout Subsection
4404 all_classes: Get list of all classes
4405 \end_layout
4407 \begin_layout Itemize
4408 Syntax: string...
4409  all_classes()
4410 \end_layout
4412 \begin_layout Standard
4413 Get names of all classes available.
4414 \end_layout
4416 \begin_layout Subsection
4417 lsnes_features: Read feature flags
4418 \end_layout
4420 \begin_layout Itemize
4421 Syntax: boolean lsnes_features(string feature)
4422 \end_layout
4424 \begin_layout Standard
4425 Checks if feature <feature> is available, if it is, returns true, otherwise
4426  returns false.
4427  The following features are known:
4428 \end_layout
4430 \begin_layout Itemize
4431 text-halos: gui.text supports halos (takes halo color argument).
4432 \end_layout
4434 \begin_layout Subsection
4435 icnov: Class ICONV
4436 \end_layout
4438 \begin_layout Standard
4439 See class ICONV.
4440 \end_layout
4442 \begin_layout Subsection
4443 filereader: Class FILEREADER
4444 \end_layout
4446 \begin_layout Standard
4447 See class FILEREADER.
4448 \end_layout
4450 \begin_layout Standard
4451 \begin_inset Newpage pagebreak
4452 \end_inset
4455 \end_layout
4457 \begin_layout Section
4458 Table bit:
4459 \end_layout
4461 \begin_layout Standard
4462 Bitwise logical functions and related.
4463 \end_layout
4465 \begin_layout Subsection
4466 bit.none/bit.bnot: Bitwise none or NOT function
4467 \end_layout
4469 \begin_layout Itemize
4470 Syntax: number bit.none(number...)
4471 \end_layout
4473 \begin_layout Itemize
4474 Syntax: number bit.bnot(number...)
4475 \end_layout
4477 \begin_layout Standard
4478 48-bit bitwise NOT / NONE function (set bits that are set in none of the
4479  arguments).
4480 \end_layout
4482 \begin_layout Subsection
4483 bit.any/bit.bor: Bitwise any or OR function
4484 \end_layout
4486 \begin_layout Itemize
4487 Syntax: number bit.any(number...)
4488 \end_layout
4490 \begin_layout Itemize
4491 Syntax: number bit.bor(number...)
4492 \end_layout
4494 \begin_layout Standard
4495 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
4496 \end_layout
4498 \begin_layout Subsection
4499 bit.all/bit.band: Bitwise all or AND function
4500 \end_layout
4502 \begin_layout Itemize
4503 Syntax: number bit.all(number...)
4504 \end_layout
4506 \begin_layout Itemize
4507 Syntax: number bit.band(number...)
4508 \end_layout
4510 \begin_layout Standard
4511 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
4513 \end_layout
4515 \begin_layout Subsection
4516 bit.parity/bit.bxor: Bitwise parity or XOR function
4517 \end_layout
4519 \begin_layout Itemize
4520 Syntax: number bit.parity(number...)
4521 \end_layout
4523 \begin_layout Itemize
4524 Syntax: number bit.bxor(number...)
4525 \end_layout
4527 \begin_layout Standard
4528 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
4529  of the arguments).
4530 \end_layout
4532 \begin_layout Subsection
4533 bit.lrotate: Rotate a number left
4534 \end_layout
4536 \begin_layout Itemize
4537 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
4538 \end_layout
4540 \begin_layout Standard
4541 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4542  1) places.
4543 \end_layout
4545 \begin_layout Subsection
4546 bit.rrotate: Rotate a number right
4547 \end_layout
4549 \begin_layout Itemize
4550 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
4551 \end_layout
4553 \begin_layout Standard
4554 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
4555  1) places.
4556 \end_layout
4558 \begin_layout Subsection
4559 bit.lshift: Shift a number left
4560 \end_layout
4562 \begin_layout Itemize
4563 Syntax: number bit.lshift(number base[, number amount[, number bits]])
4564 \end_layout
4566 \begin_layout Standard
4567 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
4568  1) places.
4569  The new bits are filled with zeroes.
4570 \end_layout
4572 \begin_layout Subsection
4573 bit.lrshift: Shift a number right (logical)
4574 \end_layout
4576 \begin_layout Itemize
4577 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
4578 \end_layout
4580 \begin_layout Standard
4581 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4582  (default 1) places.
4583  The new bits are filled with zeroes.
4584 \end_layout
4586 \begin_layout Subsection
4587 bit.arshift: Shift a number right (arithmetic)
4588 \end_layout
4590 \begin_layout Itemize
4591 Syntax: number bit.arshift(number base[, number amount[, number bits]])
4592 \end_layout
4594 \begin_layout Standard
4595 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
4596  (default 1) places.
4597  The new bits are shifted in with copy of the high bit.
4598 \end_layout
4600 \begin_layout Subsection
4601 bit.extract: Extract/shuffle bits from number
4602 \end_layout
4604 \begin_layout Itemize
4605 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
4606 \end_layout
4608 \begin_layout Standard
4609 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
4610 \end_layout
4612 \begin_layout Itemize
4613 Note: Bit numbers up to 51 should work reliably (then things start falling
4614  apart due to double precision issues).
4615 \end_layout
4617 \begin_layout Itemize
4618 Note: There are two special bit positions, true and false, standing for
4619  always set bit and always clear bit.
4620 \end_layout
4622 \begin_layout Subsection
4623 bit.value: Construct number with specified bits set
4624 \end_layout
4626 \begin_layout Itemize
4627 Syntax: number bit.value([number bit1[, number bit2,...]])
4628 \end_layout
4630 \begin_layout Standard
4631 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
4632  <bit2> places and so on.
4633  As special value, nil argument is no-op.
4634 \end_layout
4636 \begin_layout Subsection
4637 bit.test: Test if bit is set
4638 \end_layout
4640 \begin_layout Itemize
4641 Syntax: boolean bit.test(number a, number bit)
4642 \end_layout
4644 \begin_layout Standard
4645 Tests if bit <bit> is set in <a>.
4646  If it is set, returns true, otherwise false.
4647 \end_layout
4649 \begin_layout Subsection
4650 bit.testn: Test if bit is clear
4651 \end_layout
4653 \begin_layout Itemize
4654 Syntax: boolean bit.testn(number a, number bit)
4655 \end_layout
4657 \begin_layout Standard
4658 Tests if bit <bit> is set in <a>.
4659  If it is clear, returns true, otherwise false.
4660 \end_layout
4662 \begin_layout Subsection
4663 bit.test_any: Test if any bit is set
4664 \end_layout
4666 \begin_layout Itemize
4667 Syntax: boolean bit.test_any(number a, number b)
4668 \end_layout
4670 \begin_layout Standard
4671 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
4672 \end_layout
4674 \begin_layout Subsection
4675 bit.test_all: Test if all bits are set
4676 \end_layout
4678 \begin_layout Itemize
4679 Syntax: boolean bit.test_all(number a, number b)
4680 \end_layout
4682 \begin_layout Standard
4683 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
4684 \end_layout
4686 \begin_layout Subsection
4687 bit.popcount: Population count
4688 \end_layout
4690 \begin_layout Itemize
4691 Syntax: number bit.popcount(number a)
4692 \end_layout
4694 \begin_layout Standard
4695 Returns number of set bits in <a>.
4696 \end_layout
4698 \begin_layout Subsection
4699 bit.clshift: Chained left shift
4700 \end_layout
4702 \begin_layout Itemize
4703 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
4704  bits]])
4705 \end_layout
4707 \begin_layout Standard
4708 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
4709  numbers to be of specified number of bits <bits> (default 48).
4710 \end_layout
4712 \begin_layout Subsection
4713 bit.crshift: Chained right shift
4714 \end_layout
4716 \begin_layout Itemize
4717 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
4718  bits]])
4719 \end_layout
4721 \begin_layout Standard
4722 Does chained right shift on <a>, <b> by <amount> positions (default 1),
4723  assuming numbers to be of specified number of bits <bits> (default 48).
4724 \end_layout
4726 \begin_layout Subsection
4727 bit.flagdecode: Decode bitfield into flags
4728 \end_layout
4730 \begin_layout Itemize
4731 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
4732  off]])
4733 \end_layout
4735 \begin_layout Standard
4736 Return string of length bits where ith character is ith character of on
4737  if bit i is on, otherwise ith character of off.
4738  Out of range reads give last character.
4739 \end_layout
4741 \begin_layout Itemize
4742 Note: <on> defaults to '*' if empty.
4743 \end_layout
4745 \begin_layout Itemize
4746 Note: <off> defaults to '-' if empty.
4747 \end_layout
4749 \begin_layout Subsection
4750 bit.rflagdecode: Decode bitfield into flags
4751 \end_layout
4753 \begin_layout Itemize
4754 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
4755  off]])
4756 \end_layout
4758 \begin_layout Standard
4759 Like bit.flagdecode, but outputs the string in the opposite order (most significa
4760 nt bit first).
4761 \end_layout
4763 \begin_layout Subsection
4764 bit.swap{,s}{,h,d,q}word: Swap word endian
4765 \end_layout
4767 \begin_layout Itemize
4768 Syntax: number bit.swapword(number n)
4769 \end_layout
4771 \begin_layout Itemize
4772 Syntax: number bit.swaphword(number n)
4773 \end_layout
4775 \begin_layout Itemize
4776 Syntax: number bit.swapdword(number n)
4777 \end_layout
4779 \begin_layout Itemize
4780 Syntax: number bit.swapqword(number n)
4781 \end_layout
4783 \begin_layout Itemize
4784 Syntax: number bit.swapsword(number n)
4785 \end_layout
4787 \begin_layout Itemize
4788 Syntax: number bit.swapshword(number n)
4789 \end_layout
4791 \begin_layout Itemize
4792 Syntax: number bit.swapsdword(number n)
4793 \end_layout
4795 \begin_layout Itemize
4796 Syntax: number bit.swapsqword(number n)
4797 \end_layout
4799 \begin_layout Standard
4800 Swap endianess of (un)signed integer <n>.
4801 \end_layout
4803 \begin_layout Subsection
4804 bit.compose: Compose multi-byte number
4805 \end_layout
4807 \begin_layout Itemize
4808 Syntax: number bit.compose(number n...)
4809 \end_layout
4811 \begin_layout Standard
4812 Return 
4813 \begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
4814 \end_inset
4817 \end_layout
4819 \begin_layout Subsection
4820 bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
4821 \end_layout
4823 \begin_layout Itemize
4824 Syntax: number bit.binary_ld_<type>le(string str, number pos);
4825 \end_layout
4827 \begin_layout Itemize
4828 Syntax: number bit.binary_ld_<type>be(string str, number pos);
4829 \end_layout
4831 \begin_layout Standard
4832 Load little (*le) or big (*be) endian binary number from position <pos>
4833  of string <str>.
4834  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4835  double.
4836 \end_layout
4838 \begin_layout Subsection
4839 bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
4840 \end_layout
4842 \begin_layout Itemize
4843 Syntax: string bit.binary_st_<type>le(number x);
4844 \end_layout
4846 \begin_layout Itemize
4847 Syntax: string bit.binary_st_<type>be(number x);
4848 \end_layout
4850 \begin_layout Standard
4851 Store specified number <x> as binary in string and return the result.
4852  Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
4853  double.
4854 \end_layout
4856 \begin_layout Subsection
4857 bit.quotent: Integer quotent
4858 \end_layout
4860 \begin_layout Itemize
4861 Syntax: number bit.quotent(number a, number b)
4862 \end_layout
4864 \begin_layout Standard
4865 Calculate quotent a/b.
4866 \end_layout
4868 \begin_layout Subsection
4869 bit.multidiv: Divide and split among multiple divisiors
4870 \end_layout
4872 \begin_layout Itemize
4873 Syntax: number...
4874  bit.multidiv(number v, number q...)
4875 \end_layout
4877 \begin_layout Standard
4878 Does the following steps:
4879 \end_layout
4881 \begin_layout Enumerate
4882 Set v' to <v>.
4883 \end_layout
4885 \begin_layout Enumerate
4886 For each <q> q:
4887 \end_layout
4889 \begin_deeper
4890 \begin_layout Enumerate
4891 Calculate quotent(v'/q) and add that to numbers returned.
4892 \end_layout
4894 \begin_layout Enumerate
4895 v' <- remainder(v'/q)
4896 \end_layout
4898 \end_deeper
4899 \begin_layout Enumerate
4900 Add v' to numbers returned.
4901 \end_layout
4903 \begin_layout Standard
4904 That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
4905  at each step.
4906  <v> may be floating point, <q>s are integers.
4907 \end_layout
4909 \begin_layout Itemize
4910 E.g.
4911  bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
4912 \end_layout
4914 \begin_layout Itemize
4915 E.g.
4916  bit.multidiv(a, b) calculates quotent and remainder of a/b.
4917 \end_layout
4919 \begin_layout Subsection
4920 bit.mul32: 32-bit multiply
4921 \end_layout
4923 \begin_layout Itemize
4924 Syntax: number, number bit.mul32(number a, number b)
4925 \end_layout
4927 \begin_layout Standard
4928 Multiply 32-bit numbers <a> and <b>.
4929  The first return value is low 32 bits of result, the second is high 32
4930  bits.
4931 \end_layout
4933 \begin_layout Subsection
4934 bit.fextract: Extract bit field
4935 \end_layout
4937 \begin_layout Itemize
4938 Syntax: number bit.fextract(number value, number shift, number width)
4939 \end_layout
4941 \begin_layout Standard
4942 Extract <width> bits starting from bit <shift> from number <value>.
4943  This is more compact way to write 
4944 \begin_inset Formula $\left(value\gg shift\right)\&\left(2^{width}-1\right)$
4945 \end_inset
4948 \end_layout
4950 \begin_layout Subsection
4951 bit.bfields: Split number into bit fields
4952 \end_layout
4954 \begin_layout Itemize
4955 Syntax: number...
4956  bit.bfields(number v, number q...)
4957 \end_layout
4959 \begin_layout Standard
4960 Split a number <v> into bitfields of <q> bits (in order, from least significant
4961  towards more significant bits), with no padding in between.
4962 \end_layout
4964 \begin_layout Itemize
4966  number of form 0 bbbbb ggggg rrrrr can be decoded to its component fields
4967  using r,g,b = bit.bfields(v, 5, 5, 5).
4969 \end_layout
4971 \begin_layout Itemize
4973  number of form x yyyyyyy w zzzzzzz can be decode to its component fields
4974  using z, w, y, x = bit.bfields(v, 7, 1, 7, 1).
4975 \end_layout
4977 \begin_layout Standard
4978 \begin_inset Newpage pagebreak
4979 \end_inset
4982 \end_layout
4984 \begin_layout Section
4985 Table classes:
4986 \end_layout
4988 \begin_layout Subsection
4989 classes.<foo>: The classobj for class <foo>
4990 \end_layout
4992 \begin_layout Itemize
4993 Syntax: classes.<foo>
4994 \end_layout
4996 \begin_layout Standard
4997 The classobj for class <foo>.
4998 \end_layout
5000 \begin_layout Subsection
5001 classes.<foo>._static_methods: Enumerate static methods
5002 \end_layout
5004 \begin_layout Itemize
5005 Syntax: string...
5006  classes.<foo>._static_methods()
5007 \end_layout
5009 \begin_layout Standard
5010 Returns all static methods of <foo> as strings.
5011 \end_layout
5013 \begin_layout Subsection
5014 classes.<foo>._class_methods: Enumerate static methods
5015 \end_layout
5017 \begin_layout Itemize
5018 Syntax: string...
5019  classes.<foo>._class_methods()
5020 \end_layout
5022 \begin_layout Standard
5023 Returns all class methods of <foo> as strings.
5024 \end_layout
5026 \begin_layout Subsection
5027 classes.<foo>.<bar>: Static method
5028 \end_layout
5030 \begin_layout Itemize
5031 Syntax: variable classes.<foo>.<bar>(variable...)
5032 \end_layout
5034 \begin_layout Standard
5035 Invokes static method <bar> of class <foo>.
5036 \end_layout
5038 \begin_layout Section
5039 Table gui:
5040 \end_layout
5042 \begin_layout Subsection
5043 gui.resolution: Get current resolution
5044 \end_layout
5046 \begin_layout Itemize
5047 Syntax: (number, number) gui.resolution()
5048 \end_layout
5050 \begin_layout Standard
5051 Returns 2-tuple (hresolution, vresolution).
5052 \end_layout
5054 \begin_layout Subsection
5055 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
5056 \end_layout
5058 \begin_layout Itemize
5059 Syntax: number gui.left_gap(number gap)
5060 \end_layout
5062 \begin_layout Itemize
5063 Syntax: number gui.right_gap(number gap)
5064 \end_layout
5066 \begin_layout Itemize
5067 Syntax: number gui.top_gap(number gap)
5068 \end_layout
5070 \begin_layout Itemize
5071 Syntax: number gui.bottom_gap(number gap)
5072 \end_layout
5074 \begin_layout Standard
5075 Set the specified edge gap to specified value <gap> (max gap is 8191).
5076  If successful, old gap is returned.
5077 \end_layout
5079 \begin_layout Subsection
5080 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
5081  Adjust edge gaps
5082 \end_layout
5084 \begin_layout Itemize
5085 Syntax: number gui.delta_left_gap(number dgap)
5086 \end_layout
5088 \begin_layout Itemize
5089 Syntax: number gui.delta_right_gap(number dgap)
5090 \end_layout
5092 \begin_layout Itemize
5093 Syntax: number gui.delta_top_gap(number dgap)
5094 \end_layout
5096 \begin_layout Itemize
5097 Syntax: number gui.delta_bottom_gap(number dgap)
5098 \end_layout
5100 \begin_layout Standard
5101 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
5102  and return the old gap (returns nothing on error).
5103 \end_layout
5105 \begin_layout Subsection
5106 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
5107 \end_layout
5109 \begin_layout Itemize
5110 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
5111  bgc[, number hlc]]])
5112 \end_layout
5114 \begin_layout Itemize
5115 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
5116  bgc[, number hlc]]])
5117 \end_layout
5119 \begin_layout Itemize
5120 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
5121  bgc[, number hlc]]])
5122 \end_layout
5124 \begin_layout Itemize
5125 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
5126  bgc[, number hlc]]])
5127 \end_layout
5129 \begin_layout Standard
5130 Draw specified text on the GUI (each character cell is 8 or 16 wide and
5131  16 high).
5132  Parameters:
5133 \end_layout
5135 \begin_layout Itemize
5136 x: X-coordinate to start the drawing from (and x-coordinate at begining
5137  of the lines).
5138 \end_layout
5140 \begin_layout Itemize
5141 y: Y-coordinate to start the drawing from.
5142 \end_layout
5144 \begin_layout Itemize
5145 text: The text to draw.
5146 \end_layout
5148 \begin_layout Itemize
5149 fgc: Text color (default is 0xFFFFFF (white))
5150 \end_layout
5152 \begin_layout Itemize
5153 bgc: Background color (default is -1 (transparent))
5154 \end_layout
5156 \begin_layout Itemize
5157 hlc: Halo color (default is -1 (transparent))
5158 \end_layout
5160 \begin_layout Standard
5161 Note: The H variants draw at double width and V variants draw at double
5162  height.
5163  Halo thickness is always 1 and is not doubled.
5164 \end_layout
5166 \begin_layout Subsection
5167 gui.rectangle: Draw a rectangle
5168 \end_layout
5170 \begin_layout Itemize
5171 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5172  number thickness[, number outline[, number fill]]])
5173 \end_layout
5175 \begin_layout Standard
5176 Draw rectangle on the GUI.
5177  Parameters:
5178 \end_layout
5180 \begin_layout Itemize
5181 x: X-coordinate of left edge.
5182 \end_layout
5184 \begin_layout Itemize
5185 y: Y-coordinate of upper edge.
5186 \end_layout
5188 \begin_layout Itemize
5189 width: Width of rectangle.
5190 \end_layout
5192 \begin_layout Itemize
5193 height: Height of rectangle.
5194 \end_layout
5196 \begin_layout Itemize
5197 thickness: Thickness of outline (default is 1).
5198 \end_layout
5200 \begin_layout Itemize
5201 outline: Color of outline (default is 0xFFFFFF (white))
5202 \end_layout
5204 \begin_layout Itemize
5205 fill: Color of fill (default is -1 (transparent))
5206 \end_layout
5208 \begin_layout Subsection
5209 gui.solidrectangle: Draw a solid rectangle
5210 \end_layout
5212 \begin_layout Itemize
5213 Syntax: none gui.rectangle(number x, number y, number width, number height[,
5214  number color])
5215 \end_layout
5217 \begin_layout Standard
5218 Draw solid rectangle on the GUI.
5219  Parameters:
5220 \end_layout
5222 \begin_layout Itemize
5223 x: X-coordinate of left edge.
5224 \end_layout
5226 \begin_layout Itemize
5227 y: Y-coordinate of upper edge.
5228 \end_layout
5230 \begin_layout Itemize
5231 width: Width of rectangle.
5232 \end_layout
5234 \begin_layout Itemize
5235 height: Height of rectangle.
5236 \end_layout
5238 \begin_layout Itemize
5239 color: Color of rectangle (default is 0xFFFFFF (white))
5240 \end_layout
5242 \begin_layout Subsection
5243 gui.box: Draw a 3D-effect box
5244 \end_layout
5246 \begin_layout Itemize
5247 Syntax: none gui.box(number x, number y, number width, number height[, number
5248  thickness[, number outline1[,number outline2[, number fill]]]])
5249 \end_layout
5251 \begin_layout Standard
5252 Draw rectangle with 3D effect on the GUI.
5253  Parameters:
5254 \end_layout
5256 \begin_layout Itemize
5257 x: X-coordinate of left edge.
5258 \end_layout
5260 \begin_layout Itemize
5261 y: Y-coordinate of upper edge.
5262 \end_layout
5264 \begin_layout Itemize
5265 width: Width of rectangle.
5266 \end_layout
5268 \begin_layout Itemize
5269 height: Height of rectangle.
5270 \end_layout
5272 \begin_layout Itemize
5273 thickness: Thickness of outline (default is 1).
5274 \end_layout
5276 \begin_layout Itemize
5277 outline1: First color of outline (default is 0xFFFFFF (white))
5278 \end_layout
5280 \begin_layout Itemize
5281 outline2: First color of outline (default is 0x808080 (dark gray))
5282 \end_layout
5284 \begin_layout Itemize
5285 fill: Color of fill (default is 0xC0C0C0 (light grayy))
5286 \end_layout
5288 \begin_layout Subsection
5289 gui.pixel: Draw a single pixel
5290 \end_layout
5292 \begin_layout Itemize
5293 Syntax: none gui.pixel(number x, number y[, number color])
5294 \end_layout
5296 \begin_layout Standard
5297 Draw one pixel on the GUI.
5298  Parameters:
5299 \end_layout
5301 \begin_layout Itemize
5302 x: X-coordinate of the pixel
5303 \end_layout
5305 \begin_layout Itemize
5306 y: Y-coordinate of the pixel
5307 \end_layout
5309 \begin_layout Itemize
5310 color: Color of the pixel (default is 0xFFFFFF (white))
5311 \end_layout
5313 \begin_layout Subsection
5314 gui.crosshair: Draw a crosshair
5315 \end_layout
5317 \begin_layout Itemize
5318 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
5319 \end_layout
5321 \begin_layout Standard
5322 Draw a crosshair.
5323  Parameters:
5324 \end_layout
5326 \begin_layout Itemize
5327 x: X-coordinate of the crosshair
5328 \end_layout
5330 \begin_layout Itemize
5331 y: Y-coordinate of the crosshair
5332 \end_layout
5334 \begin_layout Itemize
5335 length: Length of the crosshair lines (default 10).
5336 \end_layout
5338 \begin_layout Itemize
5339 color: Color of the crosshair (default is 0xFFFFFF (white))
5340 \end_layout
5342 \begin_layout Subsection
5343 gui.line: Draw a line
5344 \end_layout
5346 \begin_layout Itemize
5347 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
5348  color])
5349 \end_layout
5351 \begin_layout Standard
5352 Draw a thin line.
5353  Parameters:
5354 \end_layout
5356 \begin_layout Itemize
5357 x1: X-coordinate of one end.
5358 \end_layout
5360 \begin_layout Itemize
5361 y1: Y-coordinate of one end.
5362 \end_layout
5364 \begin_layout Itemize
5365 x2: X-coordinate of the other end.
5366 \end_layout
5368 \begin_layout Itemize
5369 y2: Y-coordinate of the other end.
5370 \end_layout
5372 \begin_layout Itemize
5373 color: Color of the line (default is 0xFFFFFF (white)).
5374 \end_layout
5376 \begin_layout Subsection
5377 gui.circle: Draw a (filled) circle
5378 \end_layout
5380 \begin_layout Itemize
5381 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
5382  border[, number fil]]])
5383 \end_layout
5385 \begin_layout Standard
5386 Draw a circle.
5387  Parameters.
5388 \end_layout
5390 \begin_layout Itemize
5391 x: X-coordinate of the center
5392 \end_layout
5394 \begin_layout Itemize
5395 y: Y-coordinate of the center
5396 \end_layout
5398 \begin_layout Itemize
5399 r: The radius of the circle
5400 \end_layout
5402 \begin_layout Itemize
5403 thick: Border thickness
5404 \end_layout
5406 \begin_layout Itemize
5407 border: Border color (default is 0xFFFFFF (white))
5408 \end_layout
5410 \begin_layout Itemize
5411 fill: Fill color (default is -1 (transparent)).
5412 \end_layout
5414 \begin_layout Subsection
5415 gui.repaint: Arrange a repaint
5416 \end_layout
5418 \begin_layout Itemize
5419 Syntax: none gui.repaint()
5420 \end_layout
5422 \begin_layout Standard
5423 Request on_repaint() to happen as soon as possible.
5424 \end_layout
5426 \begin_layout Subsection
5427 gui.subframe_update: Enable/Disable subframe updates
5428 \end_layout
5430 \begin_layout Itemize
5431 Syntax: none gui.subframe_update(boolean on)
5432 \end_layout
5434 \begin_layout Standard
5435 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
5436  or not happen (<on>=false).
5437 \end_layout
5439 \begin_layout Subsection
5440 gui.screenshot: Write a screenshot
5441 \end_layout
5443 \begin_layout Itemize
5444 Syntax: none gui.screenshot(string filename)
5445 \end_layout
5447 \begin_layout Standard
5448 Write PNG screenshot of the current frame (no drawings) to specified file
5449  <filename>.
5450 \end_layout
5452 \begin_layout Subsection
5453 gui.screenshot_bitmap: Write a screenshot to bitmap
5454 \end_layout
5456 \begin_layout Itemize
5457 Syntax: DBITMAP gui.screenshot_bitmap()
5458 \end_layout
5460 \begin_layout Standard
5461 Write PNG screenshot of the current frame (no drawings) to dbitmap and return
5462  the result.
5463 \end_layout
5465 \begin_layout Subsection
5466 gui.color: Compose a color.
5467 \end_layout
5469 \begin_layout Itemize
5470 Syntax: number gui.color(number r, number g, number b[, number a])
5471 \end_layout
5473 \begin_layout Itemize
5474 Syntax: number gui.color(string c)
5475 \end_layout
5477 \begin_layout Standard
5478 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
5479 , each component in scale 0-255.
5480  If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
5481  fully opaque).
5482  The default alpha is 256.
5483 \end_layout
5485 \begin_layout Standard
5486 The form taking a string returns color corresponding color name.
5487 \end_layout
5489 \begin_layout Subsection
5490 gui.status: Set status variable
5491 \end_layout
5493 \begin_layout Itemize
5494 Syntax: none gui.status(string name, string value)
5495 \end_layout
5497 \begin_layout Standard
5498 Set status field 
5499 \begin_inset Quotes eld
5500 \end_inset
5502 L[<name>]
5503 \begin_inset Quotes erd
5504 \end_inset
5506  to <value> in status area.
5507 \end_layout
5509 \begin_layout Subsection
5510 gui.rainbow: Rainbow color calculation
5511 \end_layout
5513 \begin_layout Itemize
5514 Syntax: number gui.rainbow(number step, number steps[, number color])
5515 \end_layout
5517 \begin_layout Standard
5518 Perform hue rotation of color <color> (default bright red), by <step> steps.
5519  The number of steps per full rotation is given by absolute value of <steps>.
5520 \end_layout
5522 \begin_layout Standard
5523 If <step> is negative, the rotation will be counterclockwise.
5524 \end_layout
5526 \begin_layout Subsection
5527 gui.kill_frame: Kill video frame and associated sound
5528 \end_layout
5530 \begin_layout Itemize
5531 Syntax: none gui.kill_frame()
5532 \end_layout
5534 \begin_layout Standard
5535 Kills the currently dumped video frame + the associated sound.
5536  Only valid in on_video callback.
5537 \end_layout
5539 \begin_layout Subsection
5540 gui.set_video_scale: Set video frame scale
5541 \end_layout
5543 \begin_layout Itemize
5544 Syntax: none gui.set_video_scale(number h, number v)
5545 \end_layout
5547 \begin_layout Standard
5548 Sets the scale factors of current frame to <h>x<v>.
5549  Only valid in on_video callback.
5550 \end_layout
5552 \begin_layout Subsection
5553 gui.arrow: Draw an arrow
5554 \end_layout
5556 \begin_layout Itemize
5557 Syntax: none gui.arrow(number x, number y, number length, number hwidth,
5558  number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
5560 \end_layout
5562 \begin_layout Standard
5563 Draws an arrow using color <color>.
5564  The tip of arrow is at (<x>, <y>).
5565  Other parameters:
5566 \end_layout
5568 \begin_layout Enumerate
5569 <length>: The length of arrow tail.
5570 \end_layout
5572 \begin_layout Enumerate
5573 <hwidth>: The width of arrow head.
5574  Should be odd.
5575 \end_layout
5577 \begin_layout Enumerate
5578 <direction>: Direction of arrow.
5579  0 is to right, +1 rotates 45 degrees counterclockwise.
5580 \end_layout
5582 \begin_layout Enumerate
5583 <fill>: If true, fill the arrow head.
5584  Default false.
5585 \end_layout
5587 \begin_layout Enumerate
5588 <twidth>: Tail width.
5589  Should be odd.
5590  Default 1.
5591 \end_layout
5593 \begin_layout Enumerate
5594 <hthick>: Head thickness (only used if <fill> is false).
5595  Default is <twidth>.
5596 \end_layout
5598 \begin_layout Subsection
5599 gui.tiled_bitmap: Class TILEMAP
5600 \end_layout
5602 \begin_layout Standard
5603 See class TILEMAP.
5604 \end_layout
5606 \begin_layout Subsection
5607 gui.palette: Class PALETTE
5608 \end_layout
5610 \begin_layout Standard
5611 See class PALETTE.
5612 \end_layout
5614 \begin_layout Subsection
5615 gui.bitmap: Class BITMAP
5616 \end_layout
5618 \begin_layout Standard
5619 See class BITMAP.
5620 \end_layout
5622 \begin_layout Subsection
5623 gui.dbitmap: Class DBITMAP
5624 \end_layout
5626 \begin_layout Standard
5627 See class DBITMAP.
5628 \end_layout
5630 \begin_layout Subsection
5631 gui.font: Class CUSTOMFONT
5632 \end_layout
5634 \begin_layout Standard
5635 See class CUSTOMFONT.
5636 \end_layout
5638 \begin_layout Subsection
5639 gui.renderctx: Class RENDERCTX
5640 \end_layout
5642 \begin_layout Standard
5643 See class RENDERCTX.
5644 \end_layout
5646 \begin_layout Subsection
5647 gui.image: Class IMAGELOADER
5648 \end_layout
5650 \begin_layout Standard
5651 See class IMAGELOADER.
5652 \end_layout
5654 \begin_layout Subsection
5655 gui.get_runmode: Get current emulator mode
5656 \end_layout
5658 \begin_layout Itemize
5659 Syntax: string gui.get_runmode()
5660 \end_layout
5662 \begin_layout Standard
5663 Gets the current emulator runmode.
5664  The possible ones are:
5665 \end_layout
5667 \begin_layout Itemize
5668 quit: Emulator is quitting.
5669 \end_layout
5671 \begin_layout Itemize
5672 normal: Emulator is running emulation
5673 \end_layout
5675 \begin_layout Itemize
5676 load: Emulator is loading a movie/savestate
5677 \end_layout
5679 \begin_layout Itemize
5680 advance_frame: Emulator is doing frame advance
5681 \end_layout
5683 \begin_layout Itemize
5684 advance_subframe: Emulator is doing subframe advance
5685 \end_layout
5687 \begin_layout Itemize
5688 skiplag: Emulator is skipping lag frames
5689 \end_layout
5691 \begin_layout Itemize
5692 skiplag_pending: Emulator will start skipping lag frames next frame
5693 \end_layout
5695 \begin_layout Itemize
5696 pause: Emulator is paused
5697 \end_layout
5699 \begin_layout Itemize
5700 pause_break: Emulator is paused at breakpoint
5701 \end_layout
5703 \begin_layout Itemize
5704 corrupt: Emulator can't run because corrupt emulation state
5705 \end_layout
5707 \begin_layout Itemize
5708 unknown: Unknown state (should not happen).
5709 \end_layout
5711 \begin_layout Standard
5712 \begin_inset Newpage pagebreak
5713 \end_inset
5716 \end_layout
5718 \begin_layout Section
5719 table input
5720 \end_layout
5722 \begin_layout Standard
5723 Input handling.
5724  Functions manipulating input are only available in on_input callback.
5725 \end_layout
5727 \begin_layout Subsection
5728 input.get: Read controller button/axis (deprecated)
5729 \end_layout
5731 \begin_layout Itemize
5732 Syntax: number input.get(number controller, number index)
5733 \end_layout
5735 \begin_layout Standard
5736 Read the specified index <index> (zero-based) from specified controller
5737  <controller> (zero-based).
5739 \end_layout
5741 \begin_layout Subsection
5742 input.set: Write controller button/axis (deprecated)
5743 \end_layout
5745 \begin_layout Itemize
5746 Syntax: none input.set(number controller, number index, number value)
5747 \end_layout
5749 \begin_layout Standard
5750 Write the specified index <index> (zero-based) from specified controller
5751  <controller> (zero-based), storing value <value>.
5752 \end_layout
5754 \begin_layout Subsection
5755 input.get2: Read controller button/axis
5756 \end_layout
5758 \begin_layout Itemize
5759 Syntax: number input.get2(number port, number controller, number index)
5760 \end_layout
5762 \begin_layout Standard
5763 Read the specified input tuple.
5764  Port 0 is system port.
5765 \end_layout
5767 \begin_layout Subsection
5768 input.set2: Write controller button/axis
5769 \end_layout
5771 \begin_layout Itemize
5772 Syntax: input.set2(number port, number controller, number index, number value)
5773 \end_layout
5775 \begin_layout Standard
5776 Write the specified input tuple.
5777  Port 0 is system port.
5778 \end_layout
5780 \begin_layout Subsection
5781 input.lcid_to_pcid2: Look up logical controller
5782 \end_layout
5784 \begin_layout Itemize
5785 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
5786 \end_layout
5788 \begin_layout Standard
5789 Look up physical pcid pair (port, controller) corresponding to specified
5790  logical controller (1-based).
5791  Returns nothing if controller does not exist.
5792 \end_layout
5794 \begin_layout Subsection
5795 input.port_type: Look up port type
5796 \end_layout
5798 \begin_layout Itemize
5799 Syntax: string input.port_type(number port)
5800 \end_layout
5802 \begin_layout Standard
5803 Return type of specified port.
5804 \end_layout
5806 \begin_layout Subsection
5807 input.controller_info: Get information about controller
5808 \end_layout
5810 \begin_layout Itemize
5811 Syntax: table input.controller_info(number port, number controller)
5812 \end_layout
5814 \begin_layout Standard
5815 Get controller info for specified controller.
5816  If controller does not exist, returns nil.
5817  Otherwise returns a table with following fields:
5818 \end_layout
5820 \begin_layout Itemize
5821 type (string): Type of the controller.
5822 \end_layout
5824 \begin_layout Itemize
5825 class (string): Class of the controller.
5826 \end_layout
5828 \begin_layout Itemize
5829 classnum (number): Number of the controller within its class (1-based)
5830 \end_layout
5832 \begin_layout Itemize
5833 lcid (number): Logical controller number of the controller.
5834 \end_layout
5836 \begin_layout Itemize
5837 button_count (number): Number of buttons on controller
5838 \end_layout
5840 \begin_layout Itemize
5841 buttons (array): Array of following info about each button:
5842 \end_layout
5844 \begin_deeper
5845 \begin_layout Itemize
5846 type (string): Type of button.
5847  Currently one of 
5848 \begin_inset Quotes eld
5849 \end_inset
5851 null
5852 \begin_inset Quotes erd
5853 \end_inset
5856 \begin_inset Quotes eld
5857 \end_inset
5859 button
5860 \begin_inset Quotes erd
5861 \end_inset
5864 \begin_inset Quotes eld
5865 \end_inset
5867 axis
5868 \begin_inset Quotes erd
5869 \end_inset
5872 \begin_inset Quotes eld
5873 \end_inset
5875 raxis
5876 \begin_inset Quotes erd
5877 \end_inset
5880 \end_layout
5882 \begin_layout Itemize
5883 name (string): Name of button.
5884 \end_layout
5886 \begin_layout Itemize
5887 symbol (string): Symbol of button.
5888  Only present for type 
5889 \begin_inset Quotes eld
5890 \end_inset
5892 button
5893 \begin_inset Quotes erd
5894 \end_inset
5897 \end_layout
5899 \begin_layout Itemize
5900 hidden (boolean): True if hidden button.
5902 \end_layout
5904 \end_deeper
5905 \begin_layout Subsection
5906 input.veto_button: Veto a button press
5907 \end_layout
5909 \begin_layout Itemize
5910 Syntax: none input.veto_button()
5911 \end_layout
5913 \begin_layout Standard
5914 Signals that the button event should be vetoed.
5915  Only valid in on_button callback.
5916 \end_layout
5918 \begin_layout Subsection
5919 input.geta: Get all buttons for controller (deprecated)
5920 \end_layout
5922 \begin_layout Itemize
5923 Syntax: (number, number...) input.geta(number controller)
5924 \end_layout
5926 \begin_layout Standard
5927 Get input state for entiere controller.
5928  Returns n return values.
5929 \end_layout
5931 \begin_layout Itemize
5932 1st return value: Bitmask: bit i is set if i:th index is nonzero
5933 \end_layout
5935 \begin_layout Itemize
5936 2nd- return value: value of i:th index.
5937 \end_layout
5939 \begin_layout Subsection
5940 input.seta: Set all buttons for controller (deprecated)
5941 \end_layout
5943 \begin_layout Itemize
5944 Syntax: none input.seta(number controller, number bitmask, number args...)
5945 \end_layout
5947 \begin_layout Standard
5948 Set state for entiere controller.
5949  args is up to N values for indices (overriding values in bitmask if specified).
5950 \end_layout
5952 \begin_layout Subsection
5953 input.controllertype: Get controller type (deprecated)
5954 \end_layout
5956 \begin_layout Itemize
5957 syntax: string input.controllertype(number controller)
5958 \end_layout
5960 \begin_layout Standard
5961 Get the type of controller as string.
5962 \end_layout
5964 \begin_layout Subsection
5965 input.reset: Execute (delayed) reset
5966 \end_layout
5968 \begin_layout Itemize
5969 Syntax: none input.reset([number cycles])
5970 \end_layout
5972 \begin_layout Standard
5973 Execute reset.
5974  If <cycles> is greater than zero, do delayed reset.
5975  0 (or no value) causes immediate reset.
5976 \end_layout
5978 \begin_layout Itemize
5979 Note: Only available with subframe flag false.
5980 \end_layout
5982 \begin_layout Subsection
5983 input.raw: Return raw input data
5984 \end_layout
5986 \begin_layout Itemize
5987 Syntax: table input.raw()
5988 \end_layout
5990 \begin_layout Standard
5991 Returns table of tables of all available keys and axes.
5992  The first table is indexed by key name (platform-dependent!), and the inner
5993  table has the following fields:
5994 \end_layout
5996 \begin_layout Itemize
5997 value: Last reported value for control
5998 \end_layout
6000 \begin_deeper
6001 \begin_layout Itemize
6002 For keys: 1 for pressed, 0 for released.
6003 \end_layout
6005 \begin_layout Itemize
6006 For axes: -32767...32767.
6007 \end_layout
6009 \begin_layout Itemize
6010 For presure-sensitive buttons: 0...32767.
6011 \end_layout
6013 \begin_layout Itemize
6014 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
6015 \end_layout
6017 \begin_layout Itemize
6018 For mouse: Coordinates relative to game area.
6019 \end_layout
6021 \end_deeper
6022 \begin_layout Itemize
6023 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
6024 \end_layout
6026 \begin_layout Subsection
6027 input.keyhook: Hook a key
6028 \end_layout
6030 \begin_layout Itemize
6031 Syntax: none input.keyhook(string key, boolean state)
6032 \end_layout
6034 \begin_layout Standard
6035 Requests that keyhook events to be sent for key <key> (<state>=true) or
6036  not sent (<state>=false).
6037 \end_layout
6039 \begin_layout Subsection
6040 input.joyget: Get controls for controller
6041 \end_layout
6043 \begin_layout Itemize
6044 Syntax: table input.joyget(number logical)
6045 \end_layout
6047 \begin_layout Standard
6048 Returns table for current controls for specified logical controller <logical>.
6049  The names of fields vary by controller type.
6050 \end_layout
6052 \begin_layout Itemize
6053 The buttons have the same name as those are referred to in other contexts
6054  in the emulator
6055 \end_layout
6057 \begin_layout Itemize
6058 The analog axes are usually 
6059 \begin_inset Quotes eld
6060 \end_inset
6062 xaxis
6063 \begin_inset Quotes erd
6064 \end_inset
6066  and 
6067 \begin_inset Quotes eld
6068 \end_inset
6070 yaxis
6071 \begin_inset Quotes erd
6072 \end_inset
6075 \end_layout
6077 \begin_layout Itemize
6078 Each field is numeric or boolean depending on axis/button.
6079 \end_layout
6081 \begin_layout Subsection
6082 input.joyset: Set controls for controller
6083 \end_layout
6085 \begin_layout Itemize
6086 Syntax: none input.joyset(number controller, table controls)
6087 \end_layout
6089 \begin_layout Standard
6090 Set the the state of specified controller to values specified in specified
6091  table.
6092 \end_layout
6094 \begin_layout Itemize
6095 Each field can be boolean or number.
6096 \end_layout
6098 \begin_layout Itemize
6099 Also, buttons allow strings, which cause value to be inverted.
6100 \end_layout
6102 \begin_layout Subsection
6103 input.lcid_to_pcid: Look up logical controller (deprecated)
6104 \end_layout
6106 \begin_layout Itemize
6107 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
6108 \end_layout
6110 \begin_layout Standard
6111 Returns the legacy pcid for controller (or false if there isn't one), followed
6112  by pcid pair.
6113  Returns nothing if controller does not exist.
6114 \end_layout
6116 \begin_layout Standard
6117 \begin_inset Newpage pagebreak
6118 \end_inset
6121 \end_layout
6123 \begin_layout Section
6124 Table keyboard
6125 \end_layout
6127 \begin_layout Standard
6128 Various keybinding-related functions
6129 \end_layout
6131 \begin_layout Subsection
6132 keyboard.bind: Bind a key
6133 \end_layout
6135 \begin_layout Itemize
6136 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
6137 \end_layout
6139 \begin_layout Standard
6140 Bind specified key with specified modifers to specified command.
6141 \end_layout
6143 \begin_layout Subsection
6144 keyboard.unbind: Unbind a key
6145 \end_layout
6147 \begin_layout Itemize
6148 Syntax: none keyboard.unbind(string mod, string mask, string key)
6149 \end_layout
6151 \begin_layout Standard
6152 Unbind specified key with specified modifers.
6153 \end_layout
6155 \begin_layout Subsection
6156 keyboard.alias: Set alias expansion
6157 \end_layout
6159 \begin_layout Itemize
6160 Syntax: none keyboard.alias(string alias, string expansion)
6161 \end_layout
6163 \begin_layout Standard
6164 Set expansion of given command.
6165 \end_layout
6167 \begin_layout Standard
6168 \begin_inset Newpage pagebreak
6169 \end_inset
6172 \end_layout
6174 \begin_layout Section
6175 Table subtitle
6176 \end_layout
6178 \begin_layout Standard
6179 Subtitle handling
6180 \end_layout
6182 \begin_layout Subsection
6183 subtitle.byindex: Look up start and length of subtitle by index
6184 \end_layout
6186 \begin_layout Itemize
6187 Syntax: (number, number) subtitle.byindex(number i)
6188 \end_layout
6190 \begin_layout Standard
6191 Read the frame and length of ith subtitle.
6192  Returns nothing if not present.
6193 \end_layout
6195 \begin_layout Subsection
6196 subtitle.set: Write a subtitle
6197 \end_layout
6199 \begin_layout Itemize
6200 Syntax: none subtitle.set(number f, number l, string txt)
6201 \end_layout
6203 \begin_layout Standard
6204 Set the text of subtitle.
6205 \end_layout
6207 \begin_layout Subsection
6208 subtitle.get: Read a subtitle
6209 \end_layout
6211 \begin_layout Itemize
6212 Syntax: string subtitle.get(number f, number l)
6213 \end_layout
6215 \begin_layout Standard
6216 Get the text of subtitle.
6217 \end_layout
6219 \begin_layout Subsection
6220 subtitle.delete: Delete a subtitle
6221 \end_layout
6223 \begin_layout Itemize
6224 Syntax: none subtitle.delete(number f, number l)
6225 \end_layout
6227 \begin_layout Standard
6228 Delete specified subtitle.
6229 \end_layout
6231 \begin_layout Standard
6232 \begin_inset Newpage pagebreak
6233 \end_inset
6236 \end_layout
6238 \begin_layout Section
6239 Table hostmemory
6240 \end_layout
6242 \begin_layout Standard
6243 Host memory handling (extra memory saved to savestates).
6244  Host memory starts empty.
6245 \end_layout
6247 \begin_layout Itemize
6248 Reads out of range return false.
6249 \end_layout
6251 \begin_layout Itemize
6252 Writes out of range extend the memory.
6253 \end_layout
6255 \begin_layout Subsection
6256 hostmemory.read: Read byte from host memory
6257 \end_layout
6259 \begin_layout Itemize
6260 Syntax: number hostmemory.read(number address)
6261 \end_layout
6263 \begin_layout Standard
6264 Reads byte from hostmemory slot address <address>.
6265 \end_layout
6267 \begin_layout Subsection
6268 hostmemory.write: Write byte to host memory
6269 \end_layout
6271 \begin_layout Itemize
6272 Syntax: none hostmemory.write(number address, number value)
6273 \end_layout
6275 \begin_layout Standard
6276 Writes hostmemory slot with value <value> 0-255.
6277 \end_layout
6279 \begin_layout Subsection
6280 hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
6281 \end_layout
6283 \begin_layout Itemize
6284 Syntax: number hostmemory.readbyte(number address)
6285 \end_layout
6287 \begin_layout Itemize
6288 Syntax: number hostmemory.readsbyte(number address)
6289 \end_layout
6291 \begin_layout Itemize
6292 Syntax: number hostmemory.readword(number address)
6293 \end_layout
6295 \begin_layout Itemize
6296 Syntax: number hostmemory.readsword(number address)
6297 \end_layout
6299 \begin_layout Itemize
6300 Syntax: number hostmemory.readhword(number address)
6301 \end_layout
6303 \begin_layout Itemize
6304 Syntax: number hostmemory.readshword(number address)
6305 \end_layout
6307 \begin_layout Itemize
6308 Syntax: number hostmemory.readdword(number address)
6309 \end_layout
6311 \begin_layout Itemize
6312 Syntax: number hostmemory.readsdword(number address)
6313 \end_layout
6315 \begin_layout Itemize
6316 Syntax: number hostmemory.readqword(number address)
6317 \end_layout
6319 \begin_layout Itemize
6320 Syntax: number hostmemory.readsqword(number address)
6321 \end_layout
6323 \begin_layout Standard
6324 Read elements (big-endian) from given address <address>.
6325 \end_layout
6327 \begin_layout Itemize
6328 byte is 1 element
6329 \end_layout
6331 \begin_layout Itemize
6332 word is 2 elements
6333 \end_layout
6335 \begin_layout Itemize
6336 hword is 3 elements
6337 \end_layout
6339 \begin_layout Itemize
6340 dword is 4 elements
6341 \end_layout
6343 \begin_layout Itemize
6344 qword is 8 elements.
6345 \end_layout
6347 \begin_layout Itemize
6348 The 's' variants do signed read.
6349 \end_layout
6351 \begin_layout Subsection
6352 hostmemory.read{float,double}: Read from host memory
6353 \end_layout
6355 \begin_layout Itemize
6356 syntax: number hostmemory.readfloat(number address)
6357 \end_layout
6359 \begin_layout Itemize
6360 Syntax: number hostmemory.readdouble(number address)
6361 \end_layout
6363 \begin_layout Standard
6364 Read elements (big-endian) floating-pont from given address <address>.
6365 \end_layout
6367 \begin_layout Subsection
6368 hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
6369 \end_layout
6371 \begin_layout Itemize
6372 Syntax: number hostmemory.writebyte(number address, number value)
6373 \end_layout
6375 \begin_layout Itemize
6376 Syntax: number hostmemory.writesbyte(number address, number value)
6377 \end_layout
6379 \begin_layout Itemize
6380 Syntax: number hostmemory.writeword(number address, number value)
6381 \end_layout
6383 \begin_layout Itemize
6384 Syntax: number hostmemory.writesword(number address, number value)
6385 \end_layout
6387 \begin_layout Itemize
6388 Syntax: number hostmemory.writehword(number address, number value)
6389 \end_layout
6391 \begin_layout Itemize
6392 Syntax: number hostmemory.writeshword(number address, number value)
6393 \end_layout
6395 \begin_layout Itemize
6396 Syntax: number hostmemory.writedword(number address, number value)
6397 \end_layout
6399 \begin_layout Itemize
6400 Syntax: number hostmemory.writesdword(number address, number value)
6401 \end_layout
6403 \begin_layout Itemize
6404 Syntax: number hostmemory.writeqword(number address, number value)
6405 \end_layout
6407 \begin_layout Itemize
6408 Syntax: number hostmemory.writesqword(number address, number value)
6409 \end_layout
6411 \begin_layout Standard
6412 Write value <value> to elements (little-endian) starting from given address
6413  <address>.
6414 \end_layout
6416 \begin_layout Itemize
6417 byte is 1 element
6418 \end_layout
6420 \begin_layout Itemize
6421 word is 2 elements
6422 \end_layout
6424 \begin_layout Itemize
6425 hword is 3 elements
6426 \end_layout
6428 \begin_layout Itemize
6429 dword is 4 elements
6430 \end_layout
6432 \begin_layout Itemize
6433 qword is 8 elements.
6434 \end_layout
6436 \begin_layout Itemize
6437 The 's' variants do signed write.
6438 \end_layout
6440 \begin_layout Subsection
6441 hostmemory.write{float,double}: Write to host memory
6442 \end_layout
6444 \begin_layout Itemize
6445 syntax: none hostmemory.readfloat(number address, number value)
6446 \end_layout
6448 \begin_layout Itemize
6449 Syntax: none hostmemory.readdouble(number address, number value)
6450 \end_layout
6452 \begin_layout Standard
6453 Write elements (big-endian) floating-pont to given address <address>, storing
6454  <value>.
6455 \end_layout
6457 \begin_layout Standard
6458 \begin_inset Newpage pagebreak
6459 \end_inset
6462 \end_layout
6464 \begin_layout Section
6465 Table movie
6466 \end_layout
6468 \begin_layout Standard
6469 Movie handling
6470 \end_layout
6472 \begin_layout Subsection
6473 movie.currentframe: Get current frame number
6474 \end_layout
6476 \begin_layout Itemize
6477 Syntax: number movie.currentframe()
6478 \end_layout
6480 \begin_layout Standard
6481 Return number of current frame.
6482 \end_layout
6484 \begin_layout Subsection
6485 movie.framecount: Get move frame count
6486 \end_layout
6488 \begin_layout Itemize
6489 Syntax: number movie.framecount()
6490 \end_layout
6492 \begin_layout Standard
6493 Return number of frames in movie.
6494 \end_layout
6496 \begin_layout Subsection
6497 movie.lagcount: Get current lag count
6498 \end_layout
6500 \begin_layout Itemize
6501 Syntax: number movie.lagcount()
6502 \end_layout
6504 \begin_layout Standard
6505 Return number of lag frames recorded so far.
6506 \end_layout
6508 \begin_layout Subsection
6509 movie.readonly: Is in playback mode?
6510 \end_layout
6512 \begin_layout Itemize
6513 Syntax: boolean movie.readonly()
6514 \end_layout
6516 \begin_layout Standard
6517 Return true if in playback mode, false if in recording.
6518 \end_layout
6520 \begin_layout Subsection
6521 movie.rerecords: Movie rerecord count
6522 \end_layout
6524 \begin_layout Itemize
6525 Syntax: number movie.rerecords()
6526 \end_layout
6528 \begin_layout Standard
6529 Returns the current value of rerecord count.
6530 \end_layout
6532 \begin_layout Subsection
6533 movie.set_readwrite: Set recording mode.
6534 \end_layout
6536 \begin_layout Itemize
6537 Syntax: none movie.set_readwrite()
6538 \end_layout
6540 \begin_layout Standard
6541 Set recording mode (does not cause on_readwrite callback).
6542 \end_layout
6544 \begin_layout Subsection
6545 movie.frame_subframes: Count subframes in frame
6546 \end_layout
6548 \begin_layout Itemize
6549 Syntax: number movie.frame_subframes(number frame)
6550 \end_layout
6552 \begin_layout Standard
6553 Count number of subframes in specified frame <frame> (frame numbers are
6554  1-based) and return that.
6555 \end_layout
6557 \begin_layout Subsection
6558 movie.read_subframes: Read subframe data (deprecated)
6559 \end_layout
6561 \begin_layout Itemize
6562 Syntax: table movie.read_subframes(number frame, number subframe)
6563 \end_layout
6565 \begin_layout Standard
6566 Read specifed subframe in specified frame and return data as array.
6567 \end_layout
6569 \begin_layout Subsection
6570 movie.read_rtc: Read current RTC time
6571 \end_layout
6573 \begin_layout Itemize
6574 Syntax: (number, number) movie.read_rtc()
6575 \end_layout
6577 \begin_layout Standard
6578 Returns the current value of the RTC as a pair (second, subsecond).
6579 \end_layout
6581 \begin_layout Subsection
6582 movie.unsafe_rewind: Fast movie rewind to saved state
6583 \end_layout
6585 \begin_layout Itemize
6586 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
6587 \end_layout
6589 \begin_layout Standard
6590 Start setting point for unsafe rewind or jump to point of unsafe rewind.
6591 \end_layout
6593 \begin_layout Itemize
6594 If called without argument, causes emulator to start process of setting
6595  unsafe rewind point.
6596  When this has finished, callback on_set_rewind occurs, passing the rewind
6597  state to lua script.
6598 \end_layout
6600 \begin_layout Itemize
6601 If called with argument, causes emulator rewind to passed rewind point as
6602  soon as possible.
6603  recording mode is implicitly activated.
6604 \end_layout
6606 \begin_layout Standard
6607 The following warnings apply to unsafe rewinding:
6608 \end_layout
6610 \begin_layout Itemize
6611 There are no safety checks against misuse (that's what 
6612 \begin_inset Quotes eld
6613 \end_inset
6615 unsafe
6616 \begin_inset Quotes erd
6617 \end_inset
6619  comes from)!
6620 \end_layout
6622 \begin_layout Itemize
6623 Only call rewind from timeline rewind point was set from.
6624 \end_layout
6626 \begin_layout Itemize
6627 Only call rewind from after the rewind point was set.
6628 \end_layout
6630 \begin_layout Subsection
6631 movie.to_rewind: Load savestate as rewind point
6632 \end_layout
6634 \begin_layout Itemize
6635 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
6636 \end_layout
6638 \begin_layout Standard
6639 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
6640  corresponding to it.
6641 \end_layout
6643 \begin_layout Itemize
6644 Note: This operation does not take emulated time.
6645 \end_layout
6647 \begin_layout Subsection
6648 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
6649 \end_layout
6651 \begin_layout Itemize
6652 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
6653 \end_layout
6655 \begin_layout Itemize
6656 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
6657 \end_layout
6659 \begin_layout Standard
6660 Copies specified movie or branch <movie>/current object (if none or nil,
6661  the active movie) as new movie object.
6662 \end_layout
6664 \begin_layout Subsection
6665 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
6666 \end_layout
6668 \begin_layout Itemize
6669 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
6670 \end_layout
6672 \begin_layout Itemize
6673 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
6674 \end_layout
6676 \begin_layout Standard
6677 Get INPUTFRAME object corresponding to specified frame in specified movie
6678  or branch.
6679 \end_layout
6681 \begin_layout Subsection
6682 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
6683 \end_layout
6685 \begin_layout Itemize
6686 Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
6687  data)
6688 \end_layout
6690 \begin_layout Itemize
6691 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
6692 \end_layout
6694 \begin_layout Standard
6695 Set data in specified frame.
6696 \end_layout
6698 \begin_layout Itemize
6699 Note: Past can't be edited in active movie.
6700 \end_layout
6702 \begin_layout Subsection
6703 movie.get_size/INPUTMOVIE::get_size: Get size of movie
6704 \end_layout
6706 \begin_layout Itemize
6707 Syntax: integer movie.get_size([INPUTMOVIE/string movie])
6708 \end_layout
6710 \begin_layout Itemize
6711 Syntax: integer INPUTMOVIE::get_size()
6712 \end_layout
6714 \begin_layout Standard
6715 Return number of subframes in specified movie or branch.
6716 \end_layout
6718 \begin_layout Subsection
6719 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
6720 \end_layout
6722 \begin_layout Itemize
6723 Syntax: number movie.count_frames([INPUTMOVIE/string movie])
6724 \end_layout
6726 \begin_layout Itemize
6727 Syntax: number INPUTMOVIE::count_frames()
6728 \end_layout
6730 \begin_layout Standard
6731 Return number of frames in movie.
6732 \end_layout
6734 \begin_layout Subsection
6735 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
6736 \end_layout
6738 \begin_layout Itemize
6739 Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
6740 \end_layout
6742 \begin_layout Itemize
6743 Syntax: number INPUTMOVIE::find_frame(number frame)
6744 \end_layout
6746 \begin_layout Standard
6747 Returns starting subframe of given frame (frame numbers are 1-based).
6748  Returns -1 if frame number is bad.
6749 \end_layout
6751 \begin_layout Subsection
6752 movie.subframe_to_frame/INPUTMOVIE::subframe_to_frame: Find frame corresponding
6753  to subframe
6754 \end_layout
6756 \begin_layout Itemize
6757 Syntax: number movie.subframe_to_frame([INPUTMOVIE/string movie], number
6758  subframe)
6759 \end_layout
6761 \begin_layout Itemize
6762 Syntax: number INPUTMOVIE::subframe_to_frame(number subframe)
6763 \end_layout
6765 \begin_layout Standard
6766 Returns frame containing given subframe (subframe numbers are 0-based).
6767  Returns -1 if subframe number is bad.
6768 \end_layout
6770 \begin_layout Subsection
6771 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
6772 \end_layout
6774 \begin_layout Itemize
6775 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
6776 \end_layout
6778 \begin_layout Itemize
6779 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
6780 \end_layout
6782 \begin_layout Standard
6783 Return blank INPUTFRAME with frame type from specified movie.
6784 \end_layout
6786 \begin_layout Subsection
6787 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
6788 \end_layout
6790 \begin_layout Itemize
6791 Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
6792 \end_layout
6794 \begin_layout Itemize
6795 Syntax: none INPUTMOVIE::append_frames(number frames)
6796 \end_layout
6798 \begin_layout Standard
6799 Append specified number <frames> of frames.
6800 \end_layout
6802 \begin_layout Subsection
6803 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
6804 \end_layout
6806 \begin_layout Itemize
6807 Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
6808 \end_layout
6810 \begin_layout Itemize
6811 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
6812 \end_layout
6814 \begin_layout Standard
6815 Append specified frame <frame>.
6816  Past of current movie can't be edited.
6817 \end_layout
6819 \begin_layout Subsection
6820 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
6821 \end_layout
6823 \begin_layout Itemize
6824 Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
6825 \end_layout
6827 \begin_layout Itemize
6828 Syntax: none INPUTMOVIE::truncate(number frames)
6829 \end_layout
6831 \begin_layout Standard
6832 Truncate the specified movie to specified number of frames.
6833 \end_layout
6835 \begin_layout Subsection
6836 movie.edit/INPUTMOVIE::edit: Edit a movie
6837 \end_layout
6839 \begin_layout Itemize
6840 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
6841  controller, number control, number/bool value)
6842 \end_layout
6844 \begin_layout Itemize
6845 Syntax: none movie.edit(string branch, number frame, number port, number
6846  controller, number control, number/bool value)
6847 \end_layout
6849 \begin_layout Itemize
6850 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
6851  number control, number/bool value)
6852 \end_layout
6854 \begin_layout Standard
6855 Change specified control in specified frame in specified movie.
6856  Past can't be edited in active movie.
6857 \end_layout
6859 \begin_layout Subsection
6860 movie.copy_frames2: Copy frames between movies
6861 \end_layout
6863 \begin_layout Itemize
6864 Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
6865 IE/string srcmov,] number src, number count)
6866 \end_layout
6868 \begin_layout Standard
6869 Copy specified number of frames between two movies.
6870  The copy proceeeds in forward direction.
6871 \end_layout
6873 \begin_layout Subsection
6874 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
6875 \end_layout
6877 \begin_layout Itemize
6878 Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
6879  src, number count, bool backwards)
6880 \end_layout
6882 \begin_layout Itemize
6883 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
6884  bool backwards)
6885 \end_layout
6887 \begin_layout Standard
6888 Copy specified number of frames from one point in movie to another.
6889  If backwards is true, the copy will be done backwards.
6890 \end_layout
6892 \begin_layout Subsection
6893 movie.serialize/INPUTMOVIE::serialize: Serialize movie
6894 \end_layout
6896 \begin_layout Itemize
6897 Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
6898  bool binary)
6899 \end_layout
6901 \begin_layout Itemize
6902 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
6903 \end_layout
6905 \begin_layout Standard
6906 Serialize given movie into file.
6907  If binary is true, binary format (more compact and much faster) is used.
6908 \end_layout
6910 \begin_layout Subsection
6911 movie.unserialize: Unserialize movie
6912 \end_layout
6914 \begin_layout Itemize
6915 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
6916  bool binary)
6917 \end_layout
6919 \begin_layout Standard
6920 Unserialize movie from file.
6921  The given frame is used as template to decide the frame type.
6922  If binary is true, binary format is decoded (much faster).
6923 \end_layout
6925 \begin_layout Subsection
6926 movie.current_first_subframe: Return first subframe in current frame
6927 \end_layout
6929 \begin_layout Itemize
6930 Syntax: number movie.current_first_subframe()
6931 \end_layout
6933 \begin_layout Standard
6934 Returns first subframe in current frame.
6935 \end_layout
6937 \begin_layout Subsection
6938 movie.pollcounter: Return poll counter for speified control
6939 \end_layout
6941 \begin_layout Itemize
6942 Syntax: number movie.pollcounter(number port, number controller, number control)
6943 \end_layout
6945 \begin_layout Standard
6946 Returns number of times the specified control has been polled this frame.
6947 \end_layout
6949 \begin_layout Subsection
6950 movie.current_branch: Return current branch
6951 \end_layout
6953 \begin_layout Itemize
6954 Syntax: string movie.current_branch()
6955 \end_layout
6957 \begin_layout Standard
6958 Returns the name of the current branch.
6959 \end_layout
6961 \begin_layout Subsection
6962 movie.get_branches: Return names of all branches
6963 \end_layout
6965 \begin_layout Itemize
6966 Syntax: string...
6967  movie.get_branches()
6968 \end_layout
6970 \begin_layout Standard
6971 Returns the name of all branches.
6972 \end_layout
6974 \begin_layout Subsection
6975 movie.rom_loaded: Is ROM loaded?
6976 \end_layout
6978 \begin_layout Itemize
6979 Syntax: boolean movie.rom_loaded()
6980 \end_layout
6982 \begin_layout Standard
6983 Returns true if ROM is loaded, false otherwise.
6984 \end_layout
6986 \begin_layout Subsection
6987 movie.get_rom_info: Get info about loaded ROM
6988 \end_layout
6990 \begin_layout Itemize
6991 Syntax: Table movie.get_rom_info()
6992 \end_layout
6994 \begin_layout Standard
6995 Returns a table of tables.
6996  The outer table is indexed by ROM slot index.
6997  The inner table has the following fields:
6998 \end_layout
7000 \begin_layout Itemize
7001 filename: The name of file
7002 \end_layout
7004 \begin_layout Itemize
7005 hint: File name hint
7006 \end_layout
7008 \begin_layout Itemize
7009 sha256: SHA-256 hash of ROM.
7010 \end_layout
7012 \begin_layout Itemize
7013 xml_filename: The name of file for markup
7014 \end_layout
7016 \begin_layout Itemize
7017 xml_hint: File name hint for markup
7018 \end_layout
7020 \begin_layout Itemize
7021 xml_sha256: SHA-256 hash of ROM markup.
7022 \end_layout
7024 \begin_layout Standard
7025 If there is no markup, the xml_* fields are absent.
7026 \end_layout
7028 \begin_layout Subsection
7029 movie.get_game_info: Get info about loaded game
7030 \end_layout
7032 \begin_layout Itemize
7033 Syntax: Table movie.get_game_info()
7034 \end_layout
7036 \begin_layout Standard
7037 Returns a table with following fields:
7038 \end_layout
7040 \begin_layout Itemize
7041 core: The name of the core
7042 \end_layout
7044 \begin_layout Itemize
7045 core_short: Short name of the core
7046 \end_layout
7048 \begin_layout Itemize
7049 type: The name of the system type
7050 \end_layout
7052 \begin_layout Itemize
7053 type_long: The long name of the system type
7054 \end_layout
7056 \begin_layout Itemize
7057 region: The name of region
7058 \end_layout
7060 \begin_layout Itemize
7061 region_long: The long name of region
7062 \end_layout
7064 \begin_layout Itemize
7065 gametype: The gametype of movie.
7066 \end_layout
7068 \begin_layout Itemize
7069 fps: Nominal fps as floating-point value
7070 \end_layout
7072 \begin_layout Itemize
7073 fps_n: Exact nominal fps numerator
7074 \end_layout
7076 \begin_layout Itemize
7077 fps_d: Exact nominal fps denominator.
7078 \end_layout
7080 \begin_layout Subsection
7081 INPUTFRAME::get_button: Get button
7082 \end_layout
7084 \begin_layout Itemize
7085 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
7086  control)
7087 \end_layout
7089 \begin_layout Standard
7090 Returns state of given button as boolean.
7091 \end_layout
7093 \begin_layout Subsection
7094 INPUTFRAME::get_axis: Get axis
7095 \end_layout
7097 \begin_layout Itemize
7098 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
7099  control)
7100 \end_layout
7102 \begin_layout Standard
7103 Returns state of given axis as number.
7104 \end_layout
7106 \begin_layout Subsection
7107 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
7108 \end_layout
7110 \begin_layout Itemize
7111 Syntax: none INPUTFRAME::set_button(number port, number controller, number
7112  control, number/bool value)
7113 \end_layout
7115 \begin_layout Itemize
7116 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
7117  control)
7118 \end_layout
7120 \begin_layout Standard
7121 Set the given button/axis to given value.
7122 \end_layout
7124 \begin_layout Subsection
7125 INPUTFRAME::serialize: Serialize a frame
7126 \end_layout
7128 \begin_layout Itemize
7129 Syntax: string INPUTFRAME::serialize()
7130 \end_layout
7132 \begin_layout Standard
7133 Return string representation of frame.
7134 \end_layout
7136 \begin_layout Subsection
7137 INPUTFRAME::unserialize: Unserialize a frame
7138 \end_layout
7140 \begin_layout Itemize
7141 Syntax: none INPUTFRAME::unserialize(string data)
7142 \end_layout
7144 \begin_layout Standard
7145 Set current frame from given data.
7146 \end_layout
7148 \begin_layout Subsection
7149 INPUTFRAME::get_stride: Get movie stride
7150 \end_layout
7152 \begin_layout Itemize
7153 Syntax: number INPUTFRAME::get_stride()
7154 \end_layout
7156 \begin_layout Standard
7157 Return number of bytes needed to store the input frame.
7158  Mainly useful for some debugging.
7159 \end_layout
7161 \begin_layout Standard
7162 \begin_inset Newpage pagebreak
7163 \end_inset
7166 \end_layout
7168 \begin_layout Section
7169 Table settings
7170 \end_layout
7172 \begin_layout Standard
7173 Routines for settings manipulation
7174 \end_layout
7176 \begin_layout Subsection
7177 settings.get: Get value of setting
7178 \end_layout
7180 \begin_layout Itemize
7181 Syntax: string settings.get(string name)
7182 \end_layout
7184 \begin_layout Standard
7185 Get value of setting <name>.
7186  If setting value can't be obtained, returns (nil, error message).
7187 \end_layout
7189 \begin_layout Subsection
7190 settings.set: Set value of setting
7191 \end_layout
7193 \begin_layout Itemize
7194 Syntax: none settings.set(string name, string value)
7195 \end_layout
7197 \begin_layout Standard
7198 Set value <value> of setting <name>.
7199  If setting can't be set, returns (nil, error message).
7200 \end_layout
7202 \begin_layout Subsection
7203 settings.get_all: Get values of all settings
7204 \end_layout
7206 \begin_layout Itemize
7207 Syntax: table settings.get_all()
7208 \end_layout
7210 \begin_layout Standard
7211 Return a table with all setting names as keys and all current values as
7212  values.
7213 \end_layout
7215 \begin_layout Subsection
7216 settings.get_speed: Get current speed
7217 \end_layout
7219 \begin_layout Itemize
7220 Syntax: number/string settings.get_speed()
7221 \end_layout
7223 \begin_layout Standard
7224 Return the current speed multiplier (1 is normal), or 
7225 \begin_inset Quotes eld
7226 \end_inset
7228 turbo
7229 \begin_inset Quotes erd
7230 \end_inset
7232  if speed is set to turbo (this does not react to turbo toggle).
7233 \end_layout
7235 \begin_layout Subsection
7236 settings.set_speed: Set current speed
7237 \end_layout
7239 \begin_layout Itemize
7240 Syntax: settings.get_speed(number spd)
7241 \end_layout
7243 \begin_layout Itemize
7244 Syntax: settings.get_speed(string special)
7245 \end_layout
7247 \begin_layout Standard
7248 Set the current speed multiplier (1 is normal).
7249  The speed may be positive multiplier or 
7250 \begin_inset Quotes eld
7251 \end_inset
7253 turbo
7254 \begin_inset Quotes erd
7255 \end_inset
7257  for turbo speed.
7258 \end_layout
7260 \begin_layout Standard
7261 \begin_inset Newpage pagebreak
7262 \end_inset
7265 \end_layout
7267 \begin_layout Section
7268 Table memory
7269 \end_layout
7271 \begin_layout Standard
7272 Contains various functions for managing memory
7273 \end_layout
7275 \begin_layout Subsection
7276 memory.vma_count: Count number of memory areas.
7277 \end_layout
7279 \begin_layout Itemize
7280 Syntax: number memory.vma_count()
7281 \end_layout
7283 \begin_layout Standard
7284 Returns the number of memory areas
7285 \end_layout
7287 \begin_layout Subsection
7288 memory.read_vma: Lookup memory area info by index
7289 \end_layout
7291 \begin_layout Itemize
7292 Syntax: table memory.read_vma(number index)
7293 \end_layout
7295 \begin_layout Standard
7296 Reads the specified memory area (indices start from zero).
7297  Trying to read invalid memory area gives nil.
7298  The return value is table with the following fields:
7299 \end_layout
7301 \begin_layout Itemize
7302 region_name (string): The readable name of the memory area
7303 \end_layout
7305 \begin_layout Itemize
7306 baseaddr (number): Base address of the memory area
7307 \end_layout
7309 \begin_layout Itemize
7310 lastaddr (number): Last address in the memory area.
7311 \end_layout
7313 \begin_layout Itemize
7314 size (number): The size of memory area in bytes.
7315 \end_layout
7317 \begin_layout Itemize
7318 readonly (boolean): True of the memory area corresponds to ROM.
7319 \end_layout
7321 \begin_layout Itemize
7322 iospace (boolean): True if the memory area is I/O space.
7323 \end_layout
7325 \begin_layout Itemize
7326 native_endian (boolean): True if the memory area has native endian as opposed
7327  to little endian.
7328 \end_layout
7330 \begin_layout Subsection
7331 memory.find_vma: Find memory area info by address
7332 \end_layout
7334 \begin_layout Itemize
7335 Syntax: table memory.find_vma(number address)
7336 \end_layout
7338 \begin_layout Standard
7339 Finds the memory area containing specified address.
7340  Returns table in the same format as read_vma or nil if not found.
7341 \end_layout
7343 \begin_layout Subsection
7344 memory.read{,s}{byte,{,h,d,q}word}: Read memory
7345 \end_layout
7347 \begin_layout Itemize
7348 Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
7349 \end_layout
7351 \begin_layout Itemize
7352 Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
7353 \end_layout
7355 \begin_layout Itemize
7356 Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
7357 \end_layout
7359 \begin_layout Itemize
7360 Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
7361 \end_layout
7363 \begin_layout Itemize
7364 Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
7365 \end_layout
7367 \begin_layout Itemize
7368 Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
7369 \end_layout
7371 \begin_layout Itemize
7372 Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
7373 \end_layout
7375 \begin_layout Itemize
7376 Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
7377 \end_layout
7379 \begin_layout Itemize
7380 Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
7381 \end_layout
7383 \begin_layout Itemize
7384 Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
7385 \end_layout
7387 \begin_layout Standard
7388 Reads the specified address <address> (if 's' variant is used, do undergo
7389  2's complement).
7390 \end_layout
7392 \begin_layout Subsection
7393 memory.{,s}read_sg: Scatter/Gather read memory
7394 \end_layout
7396 \begin_layout Itemize
7397 Syntax: none memory.read_sg(string/boolean/number...)
7398 \end_layout
7400 \begin_layout Itemize
7401 Syntax: none memory.sread_sg(string/boolean/number...)
7402 \end_layout
7404 \begin_layout Standard
7405 Perform (2s complement signed if using memory.sread_sg) scatter/gather read
7406  of memory.
7407  Each argument can be string, boolean or number:
7408 \end_layout
7410 \begin_layout Itemize
7411 String: Set memory area addresses are relative to (e.g.
7412  'WRAM').
7413 \end_layout
7415 \begin_layout Itemize
7416 boolean: If true, increment relative address by 1, if false, decrement by
7417  1.
7418  The new address is read as next higher byte.
7419 \end_layout
7421 \begin_layout Itemize
7422 integer: Set the relative address to specified value and read the address
7423  as next higher byte.
7424 \end_layout
7426 \begin_layout Subsection
7427 memory.write_sg: Scatter/Gather write memory
7428 \end_layout
7430 \begin_layout Itemize
7431 Syntax: none memory.write_sg(number value, string/boolean/number...)
7432 \end_layout
7434 \begin_layout Standard
7435 Perform scatter/gather write of value <value> on memory.
7436  Each argument can be string, boolean or number:
7437 \end_layout
7439 \begin_layout Itemize
7440 String: Set memory area addresses are relative to (e.g.
7441  'WRAM').
7442 \end_layout
7444 \begin_layout Itemize
7445 boolean: If true, increment relative address by 1, if false, decrement by
7446  1.
7447  The new address is read as next higher byte.
7448 \end_layout
7450 \begin_layout Itemize
7451 integer: Set the relative address to specified value and read the address
7452  as next higher byte.
7453 \end_layout
7455 \begin_layout Subsection
7456 memory.read{float,double}: Read memory
7457 \end_layout
7459 \begin_layout Itemize
7460 Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
7461 \end_layout
7463 \begin_layout Itemize
7464 Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
7465 \end_layout
7467 \begin_layout Standard
7468 Reads the specified address <address>
7469 \end_layout
7471 \begin_layout Subsection
7472 memory.write{byte,{,h,d,q}word,float,double}: Write memory
7473 \end_layout
7475 \begin_layout Itemize
7476 Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
7477  number value)
7478 \end_layout
7480 \begin_layout Itemize
7481 Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
7482  number value)
7483 \end_layout
7485 \begin_layout Itemize
7486 Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
7487  number value)
7488 \end_layout
7490 \begin_layout Itemize
7491 Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
7492  number value)
7493 \end_layout
7495 \begin_layout Itemize
7496 Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
7497  number value)
7498 \end_layout
7500 \begin_layout Itemize
7501 Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
7502  number value)
7503 \end_layout
7505 \begin_layout Itemize
7506 Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
7507  number value)
7508 \end_layout
7510 \begin_layout Standard
7511 Writes the specified value <value> (negative integer values undergo 2's
7512  complement) to specified address <address>.
7513 \end_layout
7515 \begin_layout Subsection
7516 memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
7517 \end_layout
7519 \begin_layout Itemize
7520 Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
7521  number size)
7522 \end_layout
7524 \begin_layout Standard
7525 Returns a table mapping specified memory aperture for read/write.
7526 \end_layout
7528 \begin_layout Itemize
7529 Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
7530  qword, sqword, float or double.
7531 \end_layout
7533 \begin_layout Subsection
7534 memory.hash_region: Hash region of memory
7535 \end_layout
7537 \begin_layout Itemize
7538 Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
7539  number size)
7540 \end_layout
7542 \begin_layout Standard
7543 Hash <size> bytes starting from address <base> (relative to <marea>) and
7544  return the SHA-256.
7545 \end_layout
7547 \begin_layout Subsection
7548 memory.hash_region2: Hash region of memory
7549 \end_layout
7551 \begin_layout Itemize
7552 Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
7553  number size[, number rows, number stride])
7554 \end_layout
7556 \begin_layout Standard
7557 Hash <rows> blocks of <size> bytes starting from address <base> (relative
7558  to <marea>).
7559  The blocks are offset by <stride> from one another and return the SHA-256.
7560 \end_layout
7562 \begin_layout Subsection
7563 memory.hash_region_skein: Hash region of memory
7564 \end_layout
7566 \begin_layout Itemize
7567 Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
7568  addrobj}, number size[, number rows, number stride])
7569 \end_layout
7571 \begin_layout Standard
7572 Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
7573  finalists) as hash function.
7574 \end_layout
7576 \begin_layout Subsection
7577 memory.store: Store region of memory
7578 \end_layout
7580 \begin_layout Itemize
7581 Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
7582  daddr[, number rows, number stride]
7583 \end_layout
7585 \begin_layout Standard
7586 Copy memory starting from <addr> in memory area <marea> (each row being
7587  of size <size>, there being <rows> rows, and rows being separated by <stride>
7588  in memory) into savestate-saved memory area, starting from <daadr> (all
7589  rows are written back to back).
7590 \end_layout
7592 \begin_layout Subsection
7593 memory.storecmp: Compare and store region of memory
7594 \end_layout
7596 \begin_layout Itemize
7597 Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
7598  number daddr[, number rows, number stride]
7599 \end_layout
7601 \begin_layout Standard
7602 Like memory.store, but returns true if target of copy already held the value
7603  that would be copied before the copy happened.
7604  Otherwise returns false (if target and source differ before copy).
7605 \end_layout
7607 \begin_layout Subsection
7608 memory.hash_state: Hash system state
7609 \end_layout
7611 \begin_layout Itemize
7612 Syntax: string memory.hash_state()
7613 \end_layout
7615 \begin_layout Standard
7616 Hash the current system state.
7617  Mainly useful for debugging savestates.
7618 \end_layout
7620 \begin_layout Subsection
7621 memory.readregion: Read region of memory
7622 \end_layout
7624 \begin_layout Itemize
7625 Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
7626  number size)
7627 \end_layout
7629 \begin_layout Standard
7630 Read a region of memory.
7631 \end_layout
7633 \begin_layout Itemize
7634 Warning: If the region crosses memory area boundary, the results are undefined.
7635 \end_layout
7637 \begin_layout Subsection
7638 memory.writeregion: Write region of memory
7639 \end_layout
7641 \begin_layout Itemize
7642 Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
7643  number size, table data)
7644 \end_layout
7646 \begin_layout Standard
7647 Write a region of memory.
7648 \end_layout
7650 \begin_layout Itemize
7651 Warning: If the region crosses memory area boundary, the results are undefined.
7652 \end_layout
7654 \begin_layout Subsection
7655 memory.action: Run core action
7656 \end_layout
7658 \begin_layout Itemize
7659 memory.action(string action, [<params>])
7660 \end_layout
7662 \begin_layout Standard
7663 Run core action.
7664  The different models expect parameters as:
7665 \end_layout
7667 \begin_layout Itemize
7668 string: String
7669 \end_layout
7671 \begin_layout Itemize
7672 numeric: numeric
7673 \end_layout
7675 \begin_layout Itemize
7676 enumeration: String
7677 \end_layout
7679 \begin_layout Itemize
7680 boolean: String
7681 \end_layout
7683 \begin_layout Itemize
7684 toggle: None.
7685 \end_layout
7687 \begin_layout Subsection
7688 memory.action_flags: Get core action flags
7689 \end_layout
7691 \begin_layout Itemize
7692 memory.action_flags(string action)
7693 \end_layout
7695 \begin_layout Standard
7696 Get value of action flags for core action <action>.
7697 \end_layout
7699 \begin_layout Itemize
7700 Bit 0: Enabled?
7701 \end_layout
7703 \begin_layout Itemize
7704 Bit 1: Selected (not all actions can be selected)?
7705 \end_layout
7707 \begin_layout Subsection
7708 memory.get_lag_flag: Get lag flag
7709 \end_layout
7711 \begin_layout Itemize
7712 Syntax: boolean memory.get_lag_flag()
7713 \end_layout
7715 \begin_layout Standard
7716 Get the value of core lag flag.
7717  True if this frame has been lag so far, false if poll has been detected.
7718 \end_layout
7720 \begin_layout Subsection
7721 memory.set_lag_flag: Set lag flag
7722 \end_layout
7724 \begin_layout Itemize
7725 Syntax: none memory.set_lag_flag(boolean flag)
7726 \end_layout
7728 \begin_layout Standard
7729 Set the value of core lag flag.
7730  This flag automatically gets cleared if poll is detected, but can be forcibly
7731  set or cleared if game so requires.
7732 \end_layout
7734 \begin_layout Itemize
7735 Should only be used in on_frame_emulated callback.
7736 \end_layout
7738 \begin_layout Itemize
7739 Setting or clearing this affects the emulator lag counter.
7740 \end_layout
7742 \begin_layout Subsection
7743 memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
7744  callback
7745 \end_layout
7747 \begin_layout Itemize
7748 Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
7749  function fn);
7750 \end_layout
7752 \begin_layout Itemize
7753 Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
7754  addrobj}, function fn);
7755 \end_layout
7757 \begin_layout Itemize
7758 Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
7759  function fn);
7760 \end_layout
7762 \begin_layout Itemize
7763 Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
7764  function fn);
7765 \end_layout
7767 \begin_layout Itemize
7768 Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
7769  function fn);
7770 \end_layout
7772 \begin_layout Itemize
7773 Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
7774  function fn);
7775 \end_layout
7777 \begin_layout Standard
7778 Add or remove callback on memory read, write or execute (depending on the
7779  function).
7780  <addr> is relative to <marea>.
7781  <fn> is the callback.
7782  The register* functions return <fn> (which can then be passed to unregister*
7783  functions.
7784 \end_layout
7786 \begin_layout Itemize
7787 Not all cores support this, and it may be unsupported for some memory areas.
7788 \end_layout
7790 \begin_layout Itemize
7791 The functions are passed two parameters: Address and value.
7792 \end_layout
7794 \begin_layout Subsection
7795 memory.{,un}registertrace: Set/Clear trace hook
7796 \end_layout
7798 \begin_layout Itemize
7799 Syntax: function memory.registertrace(number processor, function fn);
7800 \end_layout
7802 \begin_layout Itemize
7803 Syntax: none memory.unregistertrace(number processor, function fn);
7804 \end_layout
7806 \begin_layout Standard
7807 Add or remove trace callback.
7808  <processor> is system-dependent processor number (0 is usually main CPU).
7809  The function arguments work like in other (un)register* functions.
7810 \end_layout
7812 \begin_layout Itemize
7813 The functions are passed two parameters: Trace CPU and Trace event string.
7814 \end_layout
7816 \begin_layout Subsection
7817 memory.cheat: Set cheat
7818 \end_layout
7820 \begin_layout Itemize
7821 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
7822  value);
7823 \end_layout
7825 \begin_layout Itemize
7826 Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
7827 \end_layout
7829 \begin_layout Standard
7830 Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
7831  If <value> is not speicified, clear a cheat.
7832 \end_layout
7834 \begin_layout Itemize
7835 Not all cores support this, and it may be unsupported for some memory areas.
7836 \end_layout
7838 \begin_layout Subsection
7839 memory.setxmask: Set global execute hook mask
7840 \end_layout
7842 \begin_layout Itemize
7843 Syntax: none memory.setxmask(number mask)
7844 \end_layout
7846 \begin_layout Standard
7847 Set the global execute hook mask to <mask>.
7848  The meaning of each bit is system-dependent, but bit 0 should be the main
7849  CPU.
7850 \end_layout
7852 \begin_layout Subsection
7853 memory.getregister: Get register value
7854 \end_layout
7856 \begin_layout Itemize
7857 Syntax: number/boolean memory.getregister(string register)
7858 \end_layout
7860 \begin_layout Standard
7861 Get the value of named register.
7862 \end_layout
7864 \begin_layout Subsection
7865 memory.getregisters: Get register values
7866 \end_layout
7868 \begin_layout Itemize
7869 Syntax: table memory.getregisters()
7870 \end_layout
7872 \begin_layout Standard
7873 Get the value of all known registers as table.
7874 \end_layout
7876 \begin_layout Subsection
7877 memory.setregister: Set register value
7878 \end_layout
7880 \begin_layout Itemize
7881 Syntax: none memory.setregister(string register, number/boolean value)
7882 \end_layout
7884 \begin_layout Standard
7885 Set the value of named register.
7886 \end_layout
7888 \begin_layout Subsection
7889 memory.mmap: Class MMAP_STRUCT
7890 \end_layout
7892 \begin_layout Standard
7893 See class MMAP_STRUCT
7894 \end_layout
7896 \begin_layout Standard
7897 \begin_inset Newpage pagebreak
7898 \end_inset
7901 \end_layout
7903 \begin_layout Section
7904 Table memory2
7905 \end_layout
7907 \begin_layout Standard
7908 Contains newer memory functions.
7909 \end_layout
7911 \begin_layout Subsection
7912 memory2(): Get all memory area names.
7913 \end_layout
7915 \begin_layout Itemize
7916 Syntax: table memory2()
7917 \end_layout
7919 \begin_layout Standard
7920 Returns array of all valid memory area names.
7921 \end_layout
7923 \begin_layout Subsection
7924 memory2.<marea>:info: Get memory area info
7925 \end_layout
7927 \begin_layout Itemize
7928 Syntax: table memory2.<marea>:info()
7929 \end_layout
7931 \begin_layout Standard
7932 Return table describing given memory area.
7933  Includes fields address, size, last, readonly, special and endian.
7934 \end_layout
7936 \begin_layout Subsection
7937 memory2.<marea>:<op>: Read/Write memory
7938 \end_layout
7940 \begin_layout Itemize
7941 Syntax: none memory2.<marea>:<op>(number offset, number value)
7942 \end_layout
7944 \begin_layout Itemize
7945 Syntax: number memory2.<marea>:<op>(number offset)
7946 \end_layout
7948 \begin_layout Standard
7949 Read/Write value from/to given memory area <marea> at given offset <offset>
7950  (must be in-range).
7951  The value written is <value>.
7952  <Op> is of form: [i][s]<type>, where:
7953 \end_layout
7955 \begin_layout Itemize
7956 <type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
7957 \end_layout
7959 \begin_layout Itemize
7960 'i' signifies that the value is treated as opposite-to-normal endianess,
7961 \end_layout
7963 \begin_layout Itemize
7964 's' signifies that value is treated as signed (not available for floating-point).
7965 \end_layout
7967 \begin_layout Subsection
7968 memory2.<marea>:read: Scatter-gather value read
7969 \end_layout
7971 \begin_layout Itemize
7972 Syntax: number memory2.<marea>:read(number addr...)
7973 \end_layout
7975 \begin_layout Standard
7976 Read value from given memory area <marea> at byte offsets <addr>..., given
7977  in order of increasing significance.
7978  Value of true and false are special.
7979  True increments address by 1, and false decrements address by 1.
7980 \end_layout
7982 \begin_layout Subsection
7983 memory2.<marea>:sread: Signed scatter-gather value read
7984 \end_layout
7986 \begin_layout Itemize
7987 Syntax: number memory2.<marea>:sread(number addr...)
7988 \end_layout
7990 \begin_layout Standard
7991 Like memory2.<marea>:read, but reads signed values.
7992 \end_layout
7994 \begin_layout Subsection
7995 memory2.<marea>:write: Scatter-gather value write
7996 \end_layout
7998 \begin_layout Itemize
7999 Syntax: number memory2.<marea>:write(number val, number addr...)
8000 \end_layout
8002 \begin_layout Standard
8003 Write value <val> to given memory area <marea> at byte offsets <addr>..., given
8004  in order of increasing significance.
8005  Value of true and false are special.
8006  True increments address by 1, and false decrements address by 1.
8007 \end_layout
8009 \begin_layout Subsection
8010 memory2.<marea>:cheat: Set/Clear cheat
8011 \end_layout
8013 \begin_layout Itemize
8014 Syntax: none memory2.<marea>:cheat(number addr, [number value])
8015 \end_layout
8017 \begin_layout Standard
8018 Set/Clear cheat at offset <addr> of memory area <marea>.
8019  If <value> is given, cheat with specified value is set.
8020  Otherwise cheat on address is removed.
8021 \end_layout
8023 \begin_layout Subsection
8024 memory2.<marea>:sha256: SHA-256
8025 \end_layout
8027 \begin_layout Itemize
8028 Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
8029  number stride])
8030 \end_layout
8032 \begin_layout Standard
8033 Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
8034  from offset <addr> of area <marea>.
8035  The chunks are separated by <stride>.
8036 \end_layout
8038 \begin_layout Subsection
8039 memory2.<marea>:skein: Skein-512-256
8040 \end_layout
8042 \begin_layout Itemize
8043 Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
8044  number stride])
8045 \end_layout
8047 \begin_layout Standard
8048 Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
8049 \end_layout
8051 \begin_layout Subsection
8052 memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
8053 \end_layout
8055 \begin_layout Itemize
8056 Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
8057  number rows, number stride])
8058 \end_layout
8060 \begin_layout Itemize
8061 Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
8062  size[, number rows, number stride])
8063 \end_layout
8065 \begin_layout Standard
8066 Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
8067  <addr> of area <marea>.
8068  The chunks are separated by <stride>.
8069  The target is Lua host memory, starting from offset <daddr>.
8070 \end_layout
8072 \begin_layout Standard
8073 Additionally, the storecmp method returns false if target was modified (otherwis
8074 e true).
8075 \end_layout
8077 \begin_layout Subsection
8078 memory2.<marea>:readregion: Read region
8079 \end_layout
8081 \begin_layout Itemize
8082 Syntax table memory2.<marea>:readregion(number addr, number size)
8083 \end_layout
8085 \begin_layout Standard
8086 Read <size> bytes starting from <addr> in <marea> and return as array.
8087 \end_layout
8089 \begin_layout Subsection
8090 memory2.<marea>:writeregion: Write region
8091 \end_layout
8093 \begin_layout Itemize
8094 Syntax none memory2.<marea>:writeregion(number addr, table data)
8095 \end_layout
8097 \begin_layout Standard
8098 Write array <data> to bytes starting from <addr> in <marea>.
8099 \end_layout
8101 \begin_layout Subsection
8102 memory2.<marea>:register{read,write,exec}: Register hook
8103 \end_layout
8105 \begin_layout Itemize
8106 Syntax: function memory2.<marea>:registerread(number addr, function fn);
8107 \end_layout
8109 \begin_layout Itemize
8110 Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
8111 \end_layout
8113 \begin_layout Itemize
8114 Syntax: function memory2.<marea>:registerexec(number addr, function fn);
8115 \end_layout
8117 \begin_layout Standard
8118 Register debug callback <fn> of specified type at offset <addr> of memory
8119  area <marea>.
8120  Returns <fn>.
8121 \end_layout
8123 \begin_layout Subsection
8124 memory2.<marea>:unregister{read,write,exec}: Unregister hook
8125 \end_layout
8127 \begin_layout Itemize
8128 Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
8129 \end_layout
8131 \begin_layout Itemize
8132 Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
8133 \end_layout
8135 \begin_layout Itemize
8136 Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
8137 \end_layout
8139 \begin_layout Standard
8140 Unregister debug callback <fn> of specified type at offset <addr> of memory
8141  area <marea>.
8142 \end_layout
8144 \begin_layout Standard
8145 \begin_inset Newpage pagebreak
8146 \end_inset
8149 \end_layout
8151 \begin_layout Section
8152 Table random
8153 \end_layout
8155 \begin_layout Standard
8156 Contains random number generation methods.
8157  These functions do not return reproducable results.
8158 \end_layout
8160 \begin_layout Subsection
8161 random.boolean: Random boolean
8162 \end_layout
8164 \begin_layout Itemize
8165 Syntax: boolean random.boolean()
8166 \end_layout
8168 \begin_layout Standard
8169 Returns true or false at random (50-50 chance).
8170 \end_layout
8172 \begin_layout Subsection
8173 random.integer: Random integer
8174 \end_layout
8176 \begin_layout Itemize
8177 Syntax: number random.integer(number highplusone)
8178 \end_layout
8180 \begin_layout Itemize
8181 Syntax: number random.integer(number low, number high)
8182 \end_layout
8184 \begin_layout Standard
8185 With one argument, return random integer [0,<highplusone>) (upper end exclusive).
8186  With two arguments, return random integer [<low>,<high>] (both ends inclusive).
8187 \end_layout
8189 \begin_layout Standard
8190 The returned numbers are from uniform distribution.
8191 \end_layout
8193 \begin_layout Subsection
8194 random.float: Random float
8195 \end_layout
8197 \begin_layout Itemize
8198 Syntax: number random.float()
8199 \end_layout
8201 \begin_layout Standard
8202 Returns random decimal number [0,1).
8203 \end_layout
8205 \begin_layout Subsection
8206 random.among: Random parameter
8207 \end_layout
8209 \begin_layout Itemize
8210 Syntax: value random.among(value values...)
8211 \end_layout
8213 \begin_layout Standard
8214 Returns random parameter value, picked at uniform.
8215  Multiple equivalent values are returned with higher chance.
8216 \end_layout
8218 \begin_layout Subsection
8219 random.amongtable: Random from table
8220 \end_layout
8222 \begin_layout Itemize
8223 Syntax: value random.amongtable(table tab)
8224 \end_layout
8226 \begin_layout Standard
8227 Returns random value from table <tab>.
8228  As in random.among, no equality testing is done.
8229 \end_layout
8231 \begin_layout Standard
8232 \begin_inset Newpage pagebreak
8233 \end_inset
8236 \end_layout
8238 \begin_layout Section
8239 Table zip
8240 \end_layout
8242 \begin_layout Subsection
8243 zip.enumerate: Enumerate members in zipfile
8244 \end_layout
8246 \begin_layout Itemize
8247 Syntax: Table zip.enumerate(string filename[, boolean invert])
8248 \end_layout
8250 \begin_layout Standard
8251 Returns table of files in zip archive <filename>.
8252  If <invert> is true, instead of returning array of names, returns table
8253  with keys being member names and values being true.
8254 \end_layout
8256 \begin_layout Subsection
8257 zip.writer: Class ZIPWRITER
8258 \end_layout
8260 \begin_layout Standard
8261 See class ZIPWRITER.
8262 \end_layout
8264 \begin_layout Section
8265 Table paths
8266 \end_layout
8268 \begin_layout Subsection
8269 paths.get_executable_file: Get the name of lsnes executable file
8270 \end_layout
8272 \begin_layout Itemize
8273 Syntax: String paths.get_executable_file()
8274 \end_layout
8276 \begin_layout Standard
8277 Returns the filename of the lsnes executable (together with path), if known.
8278  If unknown, returns nil.
8279 \end_layout
8281 \begin_layout Subsection
8282 paths.get_executable_path: Get the path of lsnes executable file
8283 \end_layout
8285 \begin_layout Itemize
8286 Syntax: String paths.get_executable_path()
8287 \end_layout
8289 \begin_layout Standard
8290 Returns the directory of the lsnes executable path, if known.
8291  If unknown, returns nil.
8292 \end_layout
8294 \begin_layout Subsection
8295 paths.get_config_path: Get the path of lsnes config file
8296 \end_layout
8298 \begin_layout Itemize
8299 Syntax: String paths.get_config_path()
8300 \end_layout
8302 \begin_layout Standard
8303 Returns the directory of the lsnes configuration.
8304 \end_layout
8306 \begin_layout Subsection
8307 paths.get_rompath: Get the path of ROM files
8308 \end_layout
8310 \begin_layout Itemize
8311 Syntax: String paths.get_rompath()
8312 \end_layout
8314 \begin_layout Standard
8315 Returns the default directory for various ROMs.
8316 \end_layout
8318 \begin_layout Subsection
8319 paths.get_firmwarepath: Get the path of firmware files
8320 \end_layout
8322 \begin_layout Itemize
8323 Syntax: String paths.get_firmwarepath()
8324 \end_layout
8326 \begin_layout Standard
8327 Returns the default directory for various firmwares.
8328 \end_layout
8330 \begin_layout Subsection
8331 paths.get_slotpath: Get the path of save slot files
8332 \end_layout
8334 \begin_layout Itemize
8335 Syntax: String paths.get_slotpath()
8336 \end_layout
8338 \begin_layout Standard
8339 Returns the default directory for various save slots.
8340  If in project context, returns the project directory.
8341 \end_layout
8343 \begin_layout Subsection
8344 paths.get_save_slot_file: Get save slot filename
8345 \end_layout
8347 \begin_layout Itemize
8348 Syntax: String paths.get_slotpath(string name)
8349 \end_layout
8351 \begin_layout Itemize
8352 Syntax: String paths.get_slotpath(integer slotnum, bool for_save)
8353 \end_layout
8355 \begin_layout Standard
8356 Resolve the filename of specified save slot <name> or <slotnum>.
8357  Projects and save branches are taken into account.
8358  If <for_save> is true, the filename is always for current branch.
8359  If <for_save> is false, branch tree is walked upwards until root is reached
8360  or desired file is located.
8361 \end_layout
8363 \begin_layout Standard
8364 \begin_inset Newpage pagebreak
8365 \end_inset
8368 \end_layout
8370 \begin_layout Section
8371 Table callback
8372 \end_layout
8374 \begin_layout Standard
8375 Various callback-related functions.
8376 \end_layout
8378 \begin_layout Subsection
8379 \begin_inset CommandInset label
8380 LatexCommand label
8381 name "sub:callback.register:-Register-a"
8383 \end_inset
8385 callback.register: Register a callback
8386 \end_layout
8388 \begin_layout Itemize
8389 Syntax: function callback.register(string cbname, function cbfun);
8390 \end_layout
8392 \begin_layout Standard
8393 Instruct function <cbfun> to be added to list of callbacks to call on event
8394  <cbname> (See section 
8395 \begin_inset CommandInset ref
8396 LatexCommand ref
8397 reference "sec:Callbacks"
8399 \end_inset
8402  The callback name does not have the 'on_' prefix (e.g.
8404 \begin_inset Quotes eld
8405 \end_inset
8407 paint
8408 \begin_inset Quotes erd
8409 \end_inset
8412  Returns <cbfun>.
8413 \end_layout
8415 \begin_layout Subsection
8416 \begin_inset CommandInset label
8417 LatexCommand label
8418 name "sub:callback.unregister:-Unregister-"
8420 \end_inset
8422 callback.unregister: Unregister a callback
8423 \end_layout
8425 \begin_layout Itemize
8426 Syntax: function callback.unregister(string cbname, function cbfun);
8427 \end_layout
8429 \begin_layout Standard
8430 Instruct function <cbfun> to be removed from list of callbacks to call on
8431  event <cbname>.
8432 \end_layout
8434 \begin_layout Subsection
8435 callback.<cbname>:register: Register callback
8436 \end_layout
8438 \begin_layout Itemize
8439 Syntax: function callback.<cbname>:register(function cbfun)
8440 \end_layout
8442 \begin_layout Standard
8443 Synonym for callback.register (section 
8444 \begin_inset CommandInset ref
8445 LatexCommand ref
8446 reference "sub:callback.register:-Register-a"
8448 \end_inset
8450 ), albeit with callback name specified differently.
8451 \end_layout
8453 \begin_layout Subsection
8454 callback.<cbname>:unregister: Register callback
8455 \end_layout
8457 \begin_layout Itemize
8458 Syntax: function callback.<cbname>:unregister(function cbfun)
8459 \end_layout
8461 \begin_layout Standard
8462 Synonym for callback.unregister (section 
8463 \begin_inset CommandInset ref
8464 LatexCommand ref
8465 reference "sub:callback.unregister:-Unregister-"
8467 \end_inset
8469 ), albeit with callback name specified differently.
8470 \end_layout
8472 \begin_layout Section
8473 table bsnes
8474 \end_layout
8476 \begin_layout Standard
8477 Various bsnes-specific functions.
8478 \end_layout
8480 \begin_layout Subsection
8481 bsnes.dump_sprite: Dump a sprite
8482 \end_layout
8484 \begin_layout Itemize
8485 Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
8486  number height[, number stride])
8487 \end_layout
8489 \begin_layout Standard
8490 Dumps given sprite (in native format) from memory.
8491  memory area is usually 
8492 \begin_inset Quotes eld
8493 \end_inset
8495 VRAM
8496 \begin_inset Quotes erd
8497 \end_inset
8500  <Width> and <height> are given in 8x8 blocks.
8501  <Stride> overrides row stride (default 512).
8502 \end_layout
8504 \begin_layout Subsection
8505 bsnes.dump_sprite2: Dump a 2bpp sprite
8506 \end_layout
8508 \begin_layout Itemize
8509 Syntax: BITMAP bsnes.dump_sprite2(string marea, number addr, number width,
8510  number height[, number stride])
8511 \end_layout
8513 \begin_layout Standard
8514 Dumps given sprite (in 2bpp format) from memory.
8515  memory area is usually 
8516 \begin_inset Quotes eld
8517 \end_inset
8519 VRAM
8520 \begin_inset Quotes erd
8521 \end_inset
8524  <Width> and <height> are given in 8x8 blocks.
8525  <Stride> overrides row stride (default 256).
8526 \end_layout
8528 \begin_layout Subsection
8529 bsnes.dump_palette: Dump a palette
8530 \end_layout
8532 \begin_layout Itemize
8533 Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool/integer
8534  full256, bool first_trans)
8535 \end_layout
8537 \begin_layout Standard
8538 Dumps a palette from memory.
8539  memory area is usually 
8540 \begin_inset Quotes eld
8541 \end_inset
8543 CGRAM
8544 \begin_inset Quotes erd
8545 \end_inset
8548  If <full256> is true, 256 colors are dumped (otherwise 16).
8549  <full256> can also be number of colors (4, 16 or 256).
8550  If <first_trans> is true, first color is forced transparent.
8551 \end_layout
8553 \begin_layout Subsection
8554 bsnes.enablelayer: Set layer visibility
8555 \end_layout
8557 \begin_layout Itemize
8558 Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
8559 \end_layout
8561 \begin_layout Standard
8562 Enable or disable specified layer at specified priority.
8563 \end_layout
8565 \begin_layout Subsection
8566 bsnes.redump_sprite: Redump a sprite
8567 \end_layout
8569 \begin_layout Itemize
8570 Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
8571  number stride])
8572 \end_layout
8574 \begin_layout Standard
8575 Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
8576  The specified bitmap must have size multiple of 8x8.
8577 \end_layout
8579 \begin_layout Subsection
8580 bsnes.redump_sprite2: Redump a 2bpp sprite
8581 \end_layout
8583 \begin_layout Itemize
8584 Syntax: none bsnes.redump_sprite2(BITMAP bitmap, string marea, number addr[,
8585  number stride])
8586 \end_layout
8588 \begin_layout Standard
8589 Like bsnes.dump_sprite2, but instead dumps to specified bitmap <bitmap>.
8590  The specified bitmap must have size multiple of 8x8.
8591 \end_layout
8593 \begin_layout Subsection
8594 bsnes.redump_palette: Redump a palette
8595 \end_layout
8597 \begin_layout Itemize
8598 Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
8599  first_trans)
8600 \end_layout
8602 \begin_layout Standard
8603 Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
8604  The specified palette must have either 16 or 256 colors.
8605 \end_layout
8607 \begin_layout Section
8608 extensions to table string
8609 \end_layout
8611 \begin_layout Subsection
8612 string.charU: string.char, UTF-8 version.
8613 \end_layout
8615 \begin_layout Itemize
8616 Syntax: string string.charU(number n...)
8617 \end_layout
8619 \begin_layout Standard
8620 Like Lua string.char(), but works in terms of Unicode codepoints.
8621  The returned string is UTF-8.
8622 \end_layout
8624 \begin_layout Subsection
8625 string.byteU: string.byte, UTF-8 version.
8626 \end_layout
8628 \begin_layout Itemize
8629 Syntax: number...
8630  string.byteU(string str[, number i[, number j]])
8631 \end_layout
8633 \begin_layout Standard
8634 Like string.byte(), but works in terms of Unicode codepoints.
8635  The input string <str> is assumed UTF-8.
8636 \end_layout
8638 \begin_layout Subsection
8639 string.regex: Match string against regular expression
8640 \end_layout
8642 \begin_layout Itemize
8643 Syntax: boolean/string...
8644  string.regex(string regexp, string against)
8645 \end_layout
8647 \begin_layout Standard
8648 Match POSIX-extended regular expression <regexp> against string <against>.
8649  If no match, false is returned.
8650  Otherwise if string has no subcaptures, true is returned.
8651  Otherwise each subcapture is returned as a string (in order of starting
8652  position).
8653 \end_layout
8655 \begin_layout Subsection
8656 string.hex: Transform integer into hex string
8657 \end_layout
8659 \begin_layout Itemize
8660 Syntax: string string.hex(number n, [number digits])
8661 \end_layout
8663 \begin_layout Standard
8664 Returns hexadecimal string representation of <n>, optionally padded with
8665  zeroes to <digits> digits (default is not to pad).
8666 \end_layout
8668 \begin_layout Subsection
8669 string.lpad: Pad string with spaces from left
8670 \end_layout
8672 \begin_layout Itemize
8673 Syntax: string string.lpad(string x, number n)
8674 \end_layout
8676 \begin_layout Standard
8677 Pad string <x> to <n> bytes by inserting spaces at start and return the
8678  result.
8679 \end_layout
8681 \begin_layout Subsection
8682 string.rpad: Pad string with spaces from right
8683 \end_layout
8685 \begin_layout Itemize
8686 Syntax: string string.rpad(string x, number n)
8687 \end_layout
8689 \begin_layout Standard
8690 Pad string <x> to <n> bytes by inserting spaces at end and return the result.
8691 \end_layout
8693 \begin_layout Section
8694 Table _SYSTEM
8695 \end_layout
8697 \begin_layout Standard
8698 Contains copy of global variables from time of Lua initialization.
8699  Non-writeable.
8700 \end_layout
8702 \begin_layout Standard
8703 \begin_inset Newpage pagebreak
8704 \end_inset
8707 \end_layout
8709 \begin_layout Section
8710 \begin_inset CommandInset label
8711 LatexCommand label
8712 name "sec:Callbacks"
8714 \end_inset
8716 Callbacks
8717 \end_layout
8719 \begin_layout Standard
8720 Various callbacks to Lua that can occur.
8721 \end_layout
8723 \begin_layout Subsection
8724 on_paint: Screen is being painted
8725 \end_layout
8727 \begin_layout Itemize
8728 Callback: on_paint(bool not_synth)
8729 \end_layout
8731 \begin_layout Standard
8732 Called when screen is being painted.
8733  Any gui.* calls requiring graphic context draw on the screen.
8734 \end_layout
8736 \begin_layout Itemize
8737 not_synth is true if this hook is being called in response to received frame,
8738  false otherwise.
8739 \end_layout
8741 \begin_layout Subsection
8742 on_video: Dumped video frame is being painted
8743 \end_layout
8745 \begin_layout Itemize
8746 Callback: on_video()
8747 \end_layout
8749 \begin_layout Standard
8750 Called when video dump frame is being painted.
8751  Any gui.* calls requiring graphic context draw on the video.
8752 \end_layout
8754 \begin_layout Subsection
8755 on_frame_emulated: Frame emulation complete
8756 \end_layout
8758 \begin_layout Itemize
8759 Callback: on_frame_emulated()
8760 \end_layout
8762 \begin_layout Standard
8763 Called when emulating frame has completed and on_paint()/on_video() calls
8764  are about to be issued.
8765 \end_layout
8767 \begin_layout Subsection
8768 on_frame: Frame emulation starting.
8769 \end_layout
8771 \begin_layout Itemize
8772 Callback: on_frame()
8773 \end_layout
8775 \begin_layout Standard
8776 Called on each starting whole frame.
8777 \end_layout
8779 \begin_layout Subsection
8780 on_rewind: Movie rewound to beginning
8781 \end_layout
8783 \begin_layout Itemize
8784 Callback: on_rewind()
8785 \end_layout
8787 \begin_layout Standard
8788 Called when rewind movie to beginning has completed.
8789 \end_layout
8791 \begin_layout Subsection
8792 on_pre_load: Load operation is about to start
8793 \end_layout
8795 \begin_layout Itemize
8796 Callback: on_pre_load(string name)
8797 \end_layout
8799 \begin_layout Standard
8800 Called just before savestate/movie load occurs (note: loads are always delayed,
8801  so this occurs even when load was initiated by lua).
8802 \end_layout
8804 \begin_layout Subsection
8805 on_err_Load: Load failed
8806 \end_layout
8808 \begin_layout Itemize
8809 Callback: on_err_load(string name)
8810 \end_layout
8812 \begin_layout Standard
8813 Called if loadstate goes wrong.
8814 \end_layout
8816 \begin_layout Subsection
8817 on_post_load: Load completed
8818 \end_layout
8820 \begin_layout Itemize
8821 Callback: on_post_load(string name, boolean was_savestate)
8822 \end_layout
8824 \begin_layout Standard
8825 Called on successful loadstate.
8826  was_savestate gives if this was a savestate or a movie.
8827 \end_layout
8829 \begin_layout Subsection
8830 on_pre_save: Save operation is about to start
8831 \end_layout
8833 \begin_layout Itemize
8834 Callback: on_pre_save(string name, boolean is_savestate)
8835 \end_layout
8837 \begin_layout Standard
8838 Called just before savestate save occurs (note: movie saves are synchronous
8839  and won't trigger these callbacks if called from Lua).
8840 \end_layout
8842 \begin_layout Subsection
8843 on_err_save: Save failed
8844 \end_layout
8846 \begin_layout Itemize
8847 Callback: on_err_save(string name)
8848 \end_layout
8850 \begin_layout Standard
8851 Called if savestate goes wrong.
8852 \end_layout
8854 \begin_layout Subsection
8855 on_post_save: Save completed
8856 \end_layout
8858 \begin_layout Itemize
8859 Callback: on_post_save(string name, boolean is_savestate)
8860 \end_layout
8862 \begin_layout Standard
8863 Called on successful savaestate.
8864  is_savestate gives if this was a savestate or a movie.
8865 \end_layout
8867 \begin_layout Subsection
8868 on_quit: Emulator is shutting down
8869 \end_layout
8871 \begin_layout Itemize
8872 Callback: on_quit()
8873 \end_layout
8875 \begin_layout Standard
8876 Called when emulator is shutting down.
8877 \end_layout
8879 \begin_layout Subsection
8880 on_input: Polling for input
8881 \end_layout
8883 \begin_layout Standard
8884 Called when emulator is just sending input to bsnes core.
8885  Warning: This is called even in readonly mode, but the results are ignored.
8886 \end_layout
8888 \begin_layout Subsection
8889 on_reset: System has been reset
8890 \end_layout
8892 \begin_layout Itemize
8893 Callback: on_reset()
8894 \end_layout
8896 \begin_layout Standard
8897 Called when system is reset.
8898 \end_layout
8900 \begin_layout Subsection
8901 on_readwrite: Entered recording mode
8902 \end_layout
8904 \begin_layout Itemize
8905 Callback: on_readwrite()
8906 \end_layout
8908 \begin_layout Standard
8909 Called when moving into recording mode as result of 
8910 \begin_inset Quotes eld
8911 \end_inset
8913 set-rwmode
8914 \begin_inset Quotes erd
8915 \end_inset
8917  command (note: moving to rwmode by Lua won't trigger this, as per recursive
8918  entry protection).
8919 \end_layout
8921 \begin_layout Subsection
8922 on_snoop/on_snoop2: Snoop core controller reads
8923 \end_layout
8925 \begin_layout Itemize
8926 Callback: on_snoop(number port, number controller, number index, number
8927  value)
8928 \end_layout
8930 \begin_layout Itemize
8931 Callback: on_snoop2(number port, number controller, number index, number
8932  value)
8933 \end_layout
8935 \begin_layout Standard
8936 Called each time bsnes asks for input.
8937  The value is the final value to be sent to bsnes core (readonly mode, autohold
8938  and autofire have been taken into account).
8939  Might be useful when translating movies to format suitable for console
8940  verification.
8941  Note: There is no way to modify the value to be sent.
8942 \end_layout
8944 \begin_layout Itemize
8945 On_snoop2 is called instead of on_snoop if defined.
8946  Reserves port 0 for system, having first user port be port 1.
8947 \end_layout
8949 \begin_layout Subsection
8950 on_keyhook: Hooked key/axis has been moved
8951 \end_layout
8953 \begin_layout Itemize
8954 Callback: on_keyhook(string keyname, table state)
8955 \end_layout
8957 \begin_layout Standard
8958 Sent when key that has keyhook events requested changes state.
8959  Keyname is name of the key (group) and state is the state (same kind as
8960  table values in input.raw).
8961 \end_layout
8963 \begin_layout Subsection
8964 on_idle: Idle event
8965 \end_layout
8967 \begin_layout Itemize
8968 Callback: on_idle()
8969 \end_layout
8971 \begin_layout Standard
8972 Called when requested by set_idle_timeout(), the timeout has expired and
8973  emulator is waiting.
8974 \end_layout
8976 \begin_layout Subsection
8977 on_timer: Timer event
8978 \end_layout
8980 \begin_layout Itemize
8981 Callback: on_timer()
8982 \end_layout
8984 \begin_layout Standard
8985 Called when requested by set_idle_timeout() and the timeout has expired
8986  (regardless if emulator is waiting).
8987 \end_layout
8989 \begin_layout Subsection
8990 on_set_rewind: Rewind point has been set
8991 \end_layout
8993 \begin_layout Itemize
8994 Callback: on_set_rewind(UNSAFEREWIND r)
8995 \end_layout
8997 \begin_layout Standard
8998 Called when unsafe rewind object has been constructed.
8999 \end_layout
9001 \begin_layout Subsection
9002 on_pre_rewind: Rewind is about to occur
9003 \end_layout
9005 \begin_layout Itemize
9006 Callback: on_pre_rewind() 
9007 \end_layout
9009 \begin_layout Standard
9010 Called just before unsafe rewind is about to occur.
9011 \end_layout
9013 \begin_layout Subsection
9014 on_post_rewind: Rewind has occured
9015 \end_layout
9017 \begin_layout Itemize
9018 Callback: on_post_rewind() 
9019 \end_layout
9021 \begin_layout Standard
9022 Called just after unsafe rewind has occured.
9023 \end_layout
9025 \begin_layout Subsection
9026 on_button: Button has been pressed
9027 \end_layout
9029 \begin_layout Itemize
9030 Callback: on_button(number port, number controller, number index, string
9031  type)
9032 \end_layout
9034 \begin_layout Standard
9035 Called on controller button press, with following parameters:
9036 \end_layout
9038 \begin_layout Itemize
9039 port: Port number (0 is system)
9040 \end_layout
9042 \begin_layout Itemize
9043 controller: Controller within port
9044 \end_layout
9046 \begin_layout Itemize
9047 index: Index of button.
9048 \end_layout
9050 \begin_layout Itemize
9051 type: Type of event, one of:
9052 \end_layout
9054 \begin_deeper
9055 \begin_layout Itemize
9056 \begin_inset Quotes eld
9057 \end_inset
9059 pressed
9060 \begin_inset Quotes erd
9061 \end_inset
9063 : Button was pressed.
9064 \end_layout
9066 \begin_layout Itemize
9067 \begin_inset Quotes eld
9068 \end_inset
9070 released
9071 \begin_inset Quotes erd
9072 \end_inset
9074 : Button was released.
9075 \end_layout
9077 \begin_layout Itemize
9078 \begin_inset Quotes eld
9079 \end_inset
9081 hold
9082 \begin_inset Quotes erd
9083 \end_inset
9085 : Held.
9086 \end_layout
9088 \begin_layout Itemize
9089 \begin_inset Quotes eld
9090 \end_inset
9092 unhold
9093 \begin_inset Quotes erd
9094 \end_inset
9096 : Released from hold.
9097 \end_layout
9099 \begin_layout Itemize
9100 \begin_inset Quotes eld
9101 \end_inset
9103 type
9104 \begin_inset Quotes erd
9105 \end_inset
9107 : Typing input on button.
9108 \end_layout
9110 \begin_layout Itemize
9111 \begin_inset Quotes eld
9112 \end_inset
9114 untype
9115 \begin_inset Quotes erd
9116 \end_inset
9118 : Typing input undone.
9119 \end_layout
9121 \begin_layout Itemize
9122 \begin_inset Quotes eld
9123 \end_inset
9125 autofire <duty> <cycle>
9126 \begin_inset Quotes erd
9127 \end_inset
9129 : Autofire with specifie duty and cycle.
9130 \end_layout
9132 \begin_layout Itemize
9133 \begin_inset Quotes eld
9134 \end_inset
9136 autofire
9137 \begin_inset Quotes erd
9138 \end_inset
9140 : Stop autofire.
9141 \end_layout
9143 \begin_layout Itemize
9144 \begin_inset Quotes eld
9145 \end_inset
9147 analog
9148 \begin_inset Quotes erd
9149 \end_inset
9151 : Analog action on axis.
9152 \end_layout
9154 \end_deeper
9155 \begin_layout Subsection
9156 on_movie_lost: Movie data is about to be lost
9157 \end_layout
9159 \begin_layout Itemize
9160 Callback: on_movie_lost(STRING kind)
9161 \end_layout
9163 \begin_layout Standard
9164 Called just before something would happen that could lose movie data.
9165  Kind can be:
9166 \end_layout
9168 \begin_layout Itemize
9169 readwrite: Switching to recording mode.
9170 \end_layout
9172 \begin_layout Itemize
9173 reload: ROM is being reloaded in recording mode.
9174 \end_layout
9176 \begin_layout Itemize
9177 load: New movie is being loaded.
9178 \end_layout
9180 \begin_layout Itemize
9181 unsaferewind: Unsafe rewind is happening.
9182 \end_layout
9184 \begin_layout Subsection
9185 on_latch: Latch line is rising
9186 \end_layout
9188 \begin_layout Itemize
9189 Callback: on_latch(<core-dependent-parameters>)
9190 \end_layout
9192 \begin_layout Standard
9193 Called when latch line for controller is rising.
9194  Some cores may not support this.
9195 \end_layout
9197 \begin_layout Section
9198 System-dependent behaviour
9199 \end_layout
9201 \begin_layout Subsection
9202 bsnes core
9203 \end_layout
9205 \begin_layout Itemize
9206 Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
9207  p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
9208  p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
9209 lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
9210 enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
9211  ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
9212  ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
9213  ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
9214  ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
9215 1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
9216 1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
9217  ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
9218 w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
9219 ], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
9220  ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
9221 d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
9222  ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
9223 _enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
9224 w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
9225 ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
9226  ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
9227 bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
9228  ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
9229  ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
9230 , ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
9231 dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
9232 , ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
9233  ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
9234 addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
9235  ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
9236  ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
9237  ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
9238  ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
9239 ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
9240  ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
9241 t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
9242  ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
9243  ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
9244 , ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
9245  ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
9246 \end_layout
9248 \begin_layout Itemize
9249 on_latch has no parameters
9250 \end_layout
9252 \begin_layout Itemize
9253 CPU 0 is S-CPU, 1 is S-SMP.
9254 \end_layout
9256 \begin_layout Itemize
9257 Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
9258 \end_layout
9260 \begin_layout Itemize
9261 Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
9262 {RAM,ROM}.
9263 \end_layout
9265 \begin_layout Itemize
9266 Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
9267  DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
9268  BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
9269  GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
9270 \end_layout
9272 \begin_layout Subsection
9273 gambatte core
9274 \end_layout
9276 \begin_layout Itemize
9277 Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
9278  d, e, f, h, l
9279 \end_layout
9281 \begin_layout Itemize
9282 on_latch is not supported
9283 \end_layout
9285 \begin_layout Itemize
9286 CPU 0 is main CPU.
9287 \end_layout
9289 \begin_layout Itemize
9290 Cheats are supported for ROM, SRAM and WRAM.
9291 \end_layout
9293 \begin_layout Itemize
9294 Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
9295  and WRAM.
9296 \end_layout
9298 \begin_layout Itemize
9299 Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
9300 \end_layout
9302 \end_body
9303 \end_document