#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass article
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref true
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks false
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4paper
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Hakusana
\shortcut idx
\color #008000
\end_index
\leftmargin 2cm
\topmargin 2cm
\rightmargin 1cm
\bottommargin 2cm
\headheight 1cm
\headsep 1cm
\footskip 1cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
lsnes Lua functions reference
\end_layout

\begin_layout Section
Table of contents
\end_layout

\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Conventions
\end_layout

\begin_layout Subsection
Coordinates:
\end_layout

\begin_layout Itemize
Coordinates increase to right and down.
\end_layout

\begin_layout Itemize
The origin is at top left of game area or buffer.
\end_layout

\begin_layout Subsection
Drawing and contexts
\end_layout

\begin_layout Itemize
Methods that draw something (unless stated otherwise) require a valid rendering
 context.
 This context can come in three ways:
\end_layout

\begin_deeper
\begin_layout Enumerate
The default rendering context of paint callback (the screen).
\end_layout

\begin_layout Enumerate
The default rendering context of video callback (the video).
\end_layout

\begin_layout Enumerate
Explicitly set rendering context (RENDERCTX:set).
\end_layout

\end_deeper
\begin_layout Itemize
The rendering context is always reset when callback ends.
\end_layout

\begin_layout Subsection
Colors
\end_layout

\begin_layout Standard
(Direct) colors can be specified either as numbers or strings.
\end_layout

\begin_layout Itemize
-1 is fully transparent.
\end_layout

\begin_layout Itemize
Non-negative numbers less than 
\begin_inset Formula $2^{32}$
\end_inset

 are partially opaque colors (
\begin_inset Formula $a*2^{24}+r*2^{16}+g*2^{8}+b$
\end_inset

)
\end_layout

\begin_deeper
\begin_layout Itemize
\begin_inset Formula $a$
\end_inset

 is transparency 
\begin_inset Formula $0-255$
\end_inset

, 
\begin_inset Formula $0$
\end_inset

 is fully opaque, 
\begin_inset Formula $256$
\end_inset

 would be fully transparent.
\end_layout

\begin_deeper
\begin_layout Itemize
Thus, numbers in range 
\begin_inset Formula $0-16777215$
\end_inset

 stand for fully opaque colors.
\end_layout

\end_deeper
\begin_layout Itemize
\begin_inset Formula $r$
\end_inset

, 
\begin_inset Formula $g$
\end_inset

 and 
\begin_inset Formula $b$
\end_inset

 are intensities of base colors on scale 
\begin_inset Formula $0-255$
\end_inset

.
\end_layout

\end_deeper
\begin_layout Itemize
Color can also be specified by name as string: The following color names
 are known: aliceblue antiquewhite antiquewhite1 antiquewhite2 antiquewhite3
 antiquewhite4 aqua aquamarine aquamarine1 aquamarine2 aquamarine3 aquamarine4
 azure azure1 azure2 azure3 azure4 beige bisque bisque1 bisque2 bisque3
 bisque4 black blanchedalmond blue blue1 blue2 blue3 blue4 blueviolet brown
 brown1 brown2 brown3 brown4 burlywood burlywood1 burlywood2 burlywood3
 burlywood4 cadet cadetblue cadetblue1 cadetblue2 cadetblue3 cadetblue4
 chartreuse chartreuse1 chartreuse2 chartreuse3 chartreuse4 chocolate chocolate1
 chocolate2 chocolate3 chocolate4 coral coral1 coral2 coral3 coral4 cornflowerbl
ue cornsilk cornsilk1 cornsilk2 cornsilk3 cornsilk4 crimson cyan cyan1 cyan2
 cyan3 cyan4 darkblue darkcyan darkgoldenrod darkgoldenrod1 darkgoldenrod2
 darkgoldenrod3 darkgoldenrod4 darkgray darkgreen darkgrey darkkhaki darkmagenta
 darkolivegreen darkolivegreen1 darkolivegreen2 darkolivegreen3 darkolivegreen4
 darkorange darkorange1 darkorange2 darkorange3 darkorange4 darkorchid darkorchi
d1 darkorchid2 darkorchid3 darkorchid4 darkred darksalmon darkseagreen darkseagr
een1 darkseagreen2 darkseagreen3 darkseagreen4 darkslateblue darkslategray
 darkslategray1 darkslategray2 darkslategray3 darkslategray4 darkslategrey
 darkturquoise darkviolet deeppink deeppink1 deeppink2 deeppink3 deeppink4
 deepskyblue deepskyblue1 deepskyblue2 deepskyblue3 deepskyblue4 dimgray
 dimgrey dodgerblue dodgerblue1 dodgerblue2 dodgerblue3 dodgerblue4 firebrick
 firebrick1 firebrick2 firebrick3 firebrick4 floralwhite forestgreen fractal
 fuchsia gainsboro ghostwhite gold gold1 gold2 gold3 gold4 goldenrod goldenrod1
 goldenrod2 goldenrod3 goldenrod4 gray gray0 gray1 gray10 gray100 gray11
 gray12 gray13 gray14 gray15 gray16 gray17 gray18 gray19 gray2 gray20 gray21
 gray22 gray23 gray24 gray25 gray26 gray27 gray28 gray29 gray3 gray30 gray31
 gray32 gray33 gray34 gray35 gray36 gray37 gray38 gray39 gray4 gray40 gray41
 gray42 gray43 gray44 gray45 gray46 gray47 gray48 gray49 gray5 gray50 gray51
 gray52 gray53 gray54 gray55 gray56 gray57 gray58 gray59 gray6 gray60 gray61
 gray62 gray63 gray64 gray65 gray66 gray67 gray68 gray69 gray7 gray70 gray71
 gray72 gray73 gray74 gray75 gray76 gray77 gray78 gray79 gray8 gray80 gray81
 gray82 gray83 gray84 gray85 gray86 gray87 gray88 gray89 gray9 gray90 gray91
 gray92 gray93 gray94 gray95 gray96 gray97 gray98 gray99 green green1 green2
 green3 green4 greenyellow grey grey0 grey1 grey10 grey100 grey11 grey12
 grey13 grey14 grey15 grey16 grey17 grey18 grey19 grey2 grey20 grey21 grey22
 grey23 grey24 grey25 grey26 grey27 grey28 grey29 grey3 grey30 grey31 grey32
 grey33 grey34 grey35 grey36 grey37 grey38 grey39 grey4 grey40 grey41 grey42
 grey43 grey44 grey45 grey46 grey47 grey48 grey49 grey5 grey50 grey51 grey52
 grey53 grey54 grey55 grey56 grey57 grey58 grey59 grey6 grey60 grey61 grey62
 grey63 grey64 grey65 grey66 grey67 grey68 grey69 grey7 grey70 grey71 grey72
 grey73 grey74 grey75 grey76 grey77 grey78 grey79 grey8 grey80 grey81 grey82
 grey83 grey84 grey85 grey86 grey87 grey88 grey89 grey9 grey90 grey91 grey92
 grey93 grey94 grey95 grey96 grey97 grey98 grey99 honeydew honeydew1 honeydew2
 honeydew3 honeydew4 hotpink hotpink1 hotpink2 hotpink3 hotpink4 indianred
 indianred1 indianred2 indianred3 indianred4 indigo ivory ivory1 ivory2
 ivory3 ivory4 khaki khaki1 khaki2 khaki3 khaki4 lavender lavenderblush
 lavenderblush1 lavenderblush2 lavenderblush3 lavenderblush4 lawngreen lemonchif
fon lemonchiffon1 lemonchiffon2 lemonchiffon3 lemonchiffon4 lightblue lightblue1
 lightblue2 lightblue3 lightblue4 lightcoral lightcyan lightcyan1 lightcyan2
 lightcyan3 lightcyan4 lightgoldenrod lightgoldenrod1 lightgoldenrod2 lightgolde
nrod3 lightgoldenrod4 lightgoldenrodyellow lightgray lightgreen lightgrey
 lightpink lightpink1 lightpink2 lightpink3 lightpink4 lightsalmon lightsalmon1
 lightsalmon2 lightsalmon3 lightsalmon4 lightseagreen lightskyblue lightskyblue1
 lightskyblue2 lightskyblue3 lightskyblue4 lightslateblue lightslategray
 lightslategrey lightsteelblue lightsteelblue1 lightsteelblue2 lightsteelblue3
 lightsteelblue4 lightyellow lightyellow1 lightyellow2 lightyellow3 lightyellow4
 lime limegreen linen magenta magenta1 magenta2 magenta3 magenta4 maroon
 maroon1 maroon2 maroon3 maroon4 mediumaquamarine mediumblue mediumforestgreen
 mediumgoldenrod mediumorchid mediumorchid1 mediumorchid2 mediumorchid3
 mediumorchid4 mediumpurple mediumpurple1 mediumpurple2 mediumpurple3 mediumpurp
le4 mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumviole
tred midnightblue mintcream mistyrose mistyrose1 mistyrose2 mistyrose3 mistyrose
4 moccasin navajowhite navajowhite1 navajowhite2 navajowhite3 navajowhite4
 navy navyblue oldlace olive olivedrab olivedrab1 olivedrab2 olivedrab3
 olivedrab4 orange orange1 orange2 orange3 orange4 orangered orangered1
 orangered2 orangered3 orangered4 orchid orchid1 orchid2 orchid3 orchid4
 palegoldenrod palegreen palegreen1 palegreen2 palegreen3 palegreen4 paleturquoi
se paleturquoise1 paleturquoise2 paleturquoise3 paleturquoise4 palevioletred
 palevioletred1 palevioletred2 palevioletred3 palevioletred4 papayawhip
 peachpuff peachpuff1 peachpuff2 peachpuff3 peachpuff4 peru pink pink1 pink2
 pink3 pink4 plum plum1 plum2 plum3 plum4 powderblue purple purple1 purple2
 purple3 purple4 red red1 red2 red3 red4 rosybrown rosybrown1 rosybrown2
 rosybrown3 rosybrown4 royalblue royalblue1 royalblue2 royalblue3 royalblue4
 saddlebrown salmon salmon1 salmon2 salmon3 salmon4 sandybrown seagreen
 seagreen1 seagreen2 seagreen3 seagreen4 seashell seashell1 seashell2 seashell3
 seashell4 sienna sienna1 sienna2 sienna3 sienna4 silver skyblue skyblue1
 skyblue2 skyblue3 skyblue4 slateblue slateblue1 slateblue2 slateblue3 slateblue
4 slategray slategray1 slategray2 slategray3 slategray4 slategrey snow snow1
 snow2 snow3 snow4 springgreen springgreen1 springgreen2 springgreen3 springgree
n4 steelblue steelblue1 steelblue2 steelblue3 steelblue4 tan tan1 tan2 tan3
 tan4 teal thistle thistle1 thistle2 thistle3 thistle4 tomato tomato1 tomato2
 tomato3 tomato4 transparent turquoise turquoise1 turquoise2 turquoise3
 turquoise4 violet violetred violetred1 violetred2 violetred3 violetred4
 wheat wheat1 wheat2 wheat3 wheat4 white whitesmoke yellow yellow1 yellow2
 yellow3 yellow4 yellowgreen 
\end_layout

\begin_layout Itemize
The HSL base color names: hsl-<hue><saturation><lightness>.
\end_layout

\begin_deeper
\begin_layout Itemize
Hue can be one of: r (red), ry (red-yellow), o (orange, same as red-yellow),
 y (yellow), yg (yellow-green), g (green), gc (green-cyan), c (cyan), cb
 (cyan-blue), b (blue), bm (blue-magenta), m (magenta), mr (magenta-red).
\end_layout

\begin_layout Itemize
Saturation is 0-8, where 0 is greyscale and 8 is fully saturated.
\end_layout

\begin_layout Itemize
Lightness is 0-8, where 0 is black and 8 is white.
\end_layout

\end_deeper
\begin_layout Itemize
The color names can have a modifier after space (multiple modifiers are
 allowed, separated by spaces): opaque10, opaque20, opaque25, opaque30,
 opaque40, opaque50, opaque60, opaque70, opaque75, opaque80, opaque90, opaque,
 hue{+,-}{1-23}, {saturation,lightness}{+,-}{1-16}.
\end_layout

\begin_deeper
\begin_layout Itemize
opaqueness is measured as percentage.
\end_layout

\begin_layout Itemize
Hue adjustments are on 24-step scale.
\end_layout

\begin_layout Itemize
Saturation and lightness adjustments are on 16-step scale.
\end_layout

\end_deeper
\begin_layout Section
Special tokens
\end_layout

\begin_layout Standard
These tokens are special, and are expanded while the script is being loaded
\end_layout

\begin_layout Subsection
@@LUA_SCRIPT_FILENAME@@
\end_layout

\begin_layout Standard
Expanded to string token containing path and filename of this Lua script.
 Handy for referencing other lua scripts or resources that are relative
 to this Lua script.
\end_layout

\begin_layout Standard
In practicular, this is suitable to be passed as base argument of various
 functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
ad_png and gui.bitmap_load_pal.
\end_layout

\begin_layout Section
Classes
\end_layout

\begin_layout Subsection
MMAP_STRUCT: Quasi-table mapping emulated memory
\end_layout

\begin_layout Standard
Objects of this class act like tables, except that the values are reflected
 to and from emulated memory.
\end_layout

\begin_layout Subsubsection
static function new: Create new instance
\end_layout

\begin_layout Itemize
Syntax: mmap memory.mmap.new()
\end_layout

\begin_layout Itemize
Syntax: mmap classes.MMAP_STRUCT.new()
\end_layout

\begin_layout Itemize
Deprecated: mmap memory.map_structure()
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
mmap: MMAP_STRUCT: The created mmap structure.
\end_layout

\begin_layout Standard
Create a new MMAP_STRUCT (with no mappings) and return it.
\end_layout

\begin_layout Subsubsection
operator(): Bind key in mmap structure
\end_layout

\begin_layout Itemize
Syntax: obj(key, {marea, address|addrobj}, type)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
obj: MMAP_STRUCT: The structure to manipulate.
\end_layout

\begin_layout Itemize
key: String: The name of the key in array to map.
\end_layout

\begin_layout Itemize
marea: String: The memory area the mapped address is in (default: global
 memory space).
\end_layout

\begin_layout Itemize
address: Number: The offset of memory addreess, relative to specified memory
 area or global memory space.
\end_layout

\begin_layout Itemize
addrobj: ADDRESS: The memory address.
\end_layout

\begin_layout Itemize
type: String: The type of data to map.
\end_layout

\begin_deeper
\begin_layout Itemize
One of: byte, sbyte, word, sword, hword, shword, dword, sdword, qword, sqword,
 float or double.
\end_layout

\end_deeper
\begin_layout Standard
Bind key <key> in mmap structure <obj> to address <address> (relative to
 <marea>).
 The memory address is treated as type <type>.
\end_layout

\begin_layout Itemize
Example: foomap(
\begin_inset Quotes eld
\end_inset

bar
\begin_inset Quotes erd
\end_inset

, 
\begin_inset Quotes eld
\end_inset

WRAM
\begin_inset Quotes erd
\end_inset

, 0x2A, 
\begin_inset Quotes eld
\end_inset

sword
\begin_inset Quotes erd
\end_inset

)
\end_layout

\begin_layout Standard
This binds signed word at address WRAM+0x2A into key 
\begin_inset Quotes eld
\end_inset

bar
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
ZIPWRITER: Write .zip files
\end_layout

\begin_layout Standard
This class does writing of .zip files.
\end_layout

\begin_layout Subsubsection
Static function new: Create a new zipfile
\end_layout

\begin_layout Itemize
Syntax: zip zip.writer.new(filename, [compression])
\end_layout

\begin_layout Itemize
Deprecated: zip zip.create(filename, [compression])
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
filename: string: The name of the file to write.
\end_layout

\begin_layout Itemize
compression: number: Compression level (0-9).
 Default is 9.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
zip: ZIPWRITER: The newly created ZIP writer.
\end_layout

\begin_layout Standard
Create a new ZIPWRITER object and return it.
\end_layout

\begin_layout Subsubsection
Method commit: Finish creating ZIP file.
\end_layout

\begin_layout Itemize
Syntax: zipfile:commit()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
zipfile: ZIPFILE: The ZIP file object.
\end_layout

\begin_layout Standard
Finish writing the ZIP file and actually create it on disk.
\end_layout

\begin_layout Itemize
If a member is currently open, it is implicitly closed.
\end_layout

\begin_layout Itemize
Invoking this on already committed or rolled back zipfile causes an error.
\end_layout

\begin_layout Subsubsection
Method rollback: Cancel writing the ZIP file.
\end_layout

\begin_layout Itemize
Syntax: zipfile:rollback()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
zipfile: ZIPFILE: The ZIP file object.
\end_layout

\begin_layout Standard
Cancel writing the whole ZIP file.
 The file on disk will not be modified.
\end_layout

\begin_layout Itemize
If a member is currently open, it is implicitly closed.
\end_layout

\begin_layout Itemize
Invoking this on already committed or rolled back zipfile causes an error.
\end_layout

\begin_layout Subsubsection
Method create_file: Start writing a new member
\end_layout

\begin_layout Itemize
Syntax: zipfile:create_file(filename)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
zipfile: ZIPFILE: The ZIP file object.
\end_layout

\begin_layout Itemize
string filename: Name of the new member to create
\end_layout

\begin_layout Standard
Start writing a new member <filename> in ZIP file.
\end_layout

\begin_layout Itemize
If a member is currently open, it is implicitly closed.
\end_layout

\begin_layout Itemize
Invoking this on already committed or rolled back zipfile causes an error.
\end_layout

\begin_layout Subsubsection
Method close_file: Close member
\end_layout

\begin_layout Itemize
Syntax: zipfile:close_file()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
zipfile: ZIPFILE: The ZIP file object.
\end_layout

\begin_layout Standard
Close the currently open member in zipfile.
\end_layout

\begin_layout Itemize
Invoking this on already committed or rolled back zipfile causes an error.
\end_layout

\begin_layout Itemize
Invoking this without an open member causes an error.
\end_layout

\begin_layout Subsubsection
Method write: Write data
\end_layout

\begin_layout Itemize
Syntax: zipfile:write(data)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
zipfile: ZIPFILE: The ZIP file object.
\end_layout

\begin_layout Itemize
data: string: The data to write.
\end_layout

\begin_layout Standard
Write <data> in binary mode (as-is) to currently open member.
\end_layout

\begin_layout Itemize
Invoking this without a member being open causes an error.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
TILEMAP: Tiled collection of bitmaps.
\end_layout

\begin_layout Standard
A tilemap is tiled table, each cell holding a bitmap (indexed or direct).
\end_layout

\begin_layout Subsubsection
Static function new: Create a tilemap
\end_layout

\begin_layout Itemize
Syntax: tilemap gui.tiled_bitmap.new(w, h, bw, bh);
\end_layout

\begin_layout Itemize
Syntax: tilemap classes.TILEMAP.new(w, h, bw, bh);
\end_layout

\begin_layout Itemize
Deprecated: tilemap gui.tilemap(w, h, bw, bh);
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
w: number: Width of the tilemap in tiles
\end_layout

\begin_layout Itemize
h: number: Height of the tilemap in tiles
\end_layout

\begin_layout Itemize
bw: number: Width of each tile in pixels.
\end_layout

\begin_layout Itemize
bh: number: Height of each tile in pixels.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
tilemap: TILEMAP: the newly created tilemap
\end_layout

\begin_layout Standard
Create a new tilemap of <w>*<h> tiles, each of <bw>*<bh> pixels and return
 it.
\end_layout

\begin_layout Subsubsection
TILEMAP:getsize: Query tilemap size
\end_layout

\begin_layout Itemize
Syntax: width, height tmap:getsize()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
tmap: TILEMAP: The tilemap to query.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
width: number : The width of the tilemap in tiles.
\end_layout

\begin_layout Itemize
height: number: The height of the tilemap in tiles.
\end_layout

\begin_layout Standard
Get size of tilemap in tiles.
\end_layout

\begin_layout Subsubsection
TILEMAP:getcsize: Query tilemap cell size
\end_layout

\begin_layout Itemize
Syntax: width, height tmap:getcsize()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
tmap: TILEMAP: The tilemap to query.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
width: number: The width of tilemap tile in pixels.
\end_layout

\begin_layout Itemize
height: number: The height of tilemap tile in pixels.
\end_layout

\begin_layout Standard
Get size of each tilemap tile in pixels.
\end_layout

\begin_layout Subsubsection
TILEMAP:get: Query tilemap tile
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette tmap:get(x, y)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
tmap: TILEMAP: The tilemap to query.
\end_layout

\begin_layout Itemize
x: number: The x-coordinate of tile to query.
\end_layout

\begin_layout Itemize
y: number: The y-coordinate of tile to query.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
bitmap: The associated bitmap (BITMAP or DBITMAP), or nil if none.
\end_layout

\begin_layout Itemize
palette: The palette (PALETTE) associated with indexed-color bitmap, if
 any.
 Otherwise nil.
\end_layout

\begin_layout Standard
Return the contents of tile at <x>,<y>.
\end_layout

\begin_layout Subsubsection
TILEMAP:set: Set tilemap cell
\end_layout

\begin_layout Itemize
Syntax: tmap:set(x, y)
\end_layout

\begin_layout Itemize
Syntax: tmap:set(x, y, bitmap)
\end_layout

\begin_layout Itemize
Syntax: tmap:set(x, y, bitmap, palette)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
tmap: TILEMAP: The tilemap to manipulate.
\end_layout

\begin_layout Itemize
number x: The x-coordinate of tile to set.
\end_layout

\begin_layout Itemize
number y: The y-coordinate of tile to set.
\end_layout

\begin_layout Itemize
bitmap: BITMAP/DBITMAP: The bitmap to set to tile.
\end_layout

\begin_layout Itemize
palette: PALETTE: The associated palette for bitmap.
\end_layout

\begin_layout Standard
Set the contents of tile <x>,<y>.
 If no <bitmap> is given, clears the tile.
 Otherwise sets the tile to contain bitmap <bitmap> with associated palette
 <palette>.
\end_layout

\begin_layout Itemize
Specifying index bitmap <bitmap> without palette <palette> causes an error.
\end_layout

\begin_layout Subsubsection
TILEMAP:scroll: Scroll tilemap
\end_layout

\begin_layout Itemize
Syntax: tmap:scroll(ox, oy);
\end_layout

\begin_layout Itemize
Syntax: tmap:scroll(ox, oy, x, y, w, h);
\end_layout

\begin_layout Itemize
Syntax: tmap:scroll(ox, oy, x, y, w, h, circ_x, circ_y);
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
tmap: TILEMAP: The tilemap to manipulate.
\end_layout

\begin_layout Itemize
ox: number: The number of tiles to scroll horizontally (positive is to right).
\end_layout

\begin_layout Itemize
oy: number: The number of tiles to scroll vertically (positive is to down).
\end_layout

\begin_layout Itemize
x: number: The left edge of scroll window.
\end_layout

\begin_layout Itemize
y: number: The top edge of scroll window.
\end_layout

\begin_layout Itemize
w: number: The width of scroll window.
\end_layout

\begin_layout Itemize
h: number: The height of scroll window.
\end_layout

\begin_layout Itemize
circ_x: boolean: If true, treat the window as circular in horizontal direction.
\end_layout

\begin_layout Itemize
circ_y: boolean: If true, treat the window as circular in vertical direction.
\end_layout

\begin_layout Standard
Scroll the specified tilemap <tmap> by <ox>,<oy>.
 If a window <x>,<y>,<w>,<h> is specified, only that part is scrolled.
 <circ_x> and <circ_y> control if scroll is circular or not.
\end_layout

\begin_layout Itemize
Specifying out-of-range window causes an error.
\end_layout

\begin_layout Subsubsection
TILEMAP:draw: Draw tilemap
\end_layout

\begin_layout Itemize
Name: tmap:draw(x, y)
\end_layout

\begin_layout Itemize
Name: tmap:draw(x, y, x0, y0, w, h)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
tmap: TILEMAP: The tilemap to draw.
\end_layout

\begin_layout Itemize
x: The x coordinate on screen to draw to.
\end_layout

\begin_layout Itemize
y: The y coordinate on screen to draw to.
\end_layout

\begin_layout Itemize
x0: number: The x coordinate on tilemap (in pixels) to start drawing from.
\end_layout

\begin_layout Itemize
y0: number: The y coordinate on tilemap (in pixels) to start drawing from.
\end_layout

\begin_layout Itemize
w: number: The width to draw (in pixels).
\end_layout

\begin_layout Itemize
h: number: The height to draw (in pixels).
\end_layout

\begin_layout Standard
Draw tilemap <tmap> to screen at <x>,<y>.
 If a window <x0>,<y0>,<w>,<h> is specified, only that part is drawn.
\end_layout

\begin_layout Itemize
This method requires a rendering context to work.
\end_layout

\begin_layout Subsubsection
TILEMAP:draw_outside: Draw tilemap outside game area
\end_layout

\begin_layout Itemize
Name: tmap:draw_outside(x, y)
\end_layout

\begin_layout Itemize
Name: tmap:draw_outside(x, y, x0, y0, w, h)
\end_layout

\begin_layout Standard
Like TILEMAP:draw, but draws only outside game area.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
RENDERCTX: Off-screen rendering context
\end_layout

\begin_layout Standard
Object acting as off-screen rendering context.
\end_layout

\begin_layout Subsubsection
Static function new: Create a render queue
\end_layout

\begin_layout Itemize
Syntax: renderctx gui.renderctx.new(width, height);
\end_layout

\begin_layout Itemize
Syntax: renderctx classes.RENDERCTX.new(width, height);
\end_layout

\begin_layout Itemize
Deprecated: renderctx gui.renderq_new(width, height);
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
width: number: The notional width of the game area.
\end_layout

\begin_layout Itemize
height: number: The notional height of the game area.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
rendectx: RENDERCTX: The newly created render context.
\end_layout

\begin_layout Standard
Create a render context with reported size <width>*<height> and return it.
\end_layout

\begin_layout Subsubsection
Static function setnull: Reset to default queue
\end_layout

\begin_layout Itemize
Syntax: gui.renderctx.setnull()
\end_layout

\begin_layout Itemize
Syntax: classes.RENDERCTX:setnull()
\end_layout

\begin_layout Itemize
Deprecated: gui.renderq_set()
\end_layout

\begin_layout Standard
Reset the used render context back to default for the executing callback:
\end_layout

\begin_layout Itemize
The default for paint callback is the screen
\end_layout

\begin_layout Itemize
The default for video callback is the video frame
\end_layout

\begin_layout Itemize
The default otherwise is nothing.
\end_layout

\begin_layout Subsubsection
Method clear: Clear a render queue
\end_layout

\begin_layout Itemize
Syntax: renderctx:clear()
\end_layout

\begin_layout Itemize
Deprecated: gui.renderq_clear(renderctx)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
renderctx: RENDERCTX: The render queue to clear.
\end_layout

\begin_layout Standard
Clear all drawing from the context.
\end_layout

\begin_layout Subsubsection
Method set: Change active render context
\end_layout

\begin_layout Itemize
Syntax: renderctx:set()
\end_layout

\begin_layout Itemize
Deprecated: gui.renderq_set(renderctx)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
renderctx: RENDERCTX: The render queue to use.
\end_layout

\begin_layout Standard
Switch the current rendering context <renderctx>.
\end_layout

\begin_layout Subsubsection
Method run: Draw all objects in context to another
\end_layout

\begin_layout Itemize
Syntax: renderctx:run()
\end_layout

\begin_layout Itemize
Deprecated: gui.renderq_run(renderctx)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
renderctx: RENDERCTX: The render context to overlay.
\end_layout

\begin_layout Standard
Overlay the specified render context <context> upon the active rendering
 context.
\end_layout

\begin_layout Itemize
Trying to overlay rendering context upon itself is a bad idea.
\end_layout

\begin_layout Subsubsection
Method render: Render a contex to bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap renderctx:render()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
renderctx: RENDERCTX: The context to render.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The rendered bitmap.
\end_layout

\begin_layout Standard
Render the specified context <renderctx> to a new bitmap.
\end_layout

\begin_layout Itemize
The size of bitmap will be nominal game area size, plus any set gaps.
\end_layout

\begin_layout Itemize
This method does not require active rendering context.
\end_layout

\begin_layout Subsubsection
Method synchronous_repaint: Paint screen now
\end_layout

\begin_layout Itemize
Syntax: renderctx:synchronous_repaint()
\end_layout

\begin_layout Itemize
Deprecated: gui.synchronous_repaint(renderctx)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
renderctx: RENDERCTX: The context to paint.
\end_layout

\begin_layout Standard
Immediately redraw the screen with game overlayed by drawings from context
 <renderctx>.
\end_layout

\begin_layout Itemize
This does not require active rendering context.
\end_layout

\begin_layout Itemize
Will not cause paint callback to be invoked.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
PALETTE: Color palette for indexed image
\end_layout

\begin_layout Subsubsection
Static function new: Create a new palette
\end_layout

\begin_layout Itemize
Syntax: palette gui.palette.new()
\end_layout

\begin_layout Itemize
Syntax: palette classes.PALETTE.new()
\end_layout

\begin_layout Itemize
Deprecated: palette gui.palette_new()
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
palette: PALETTE: The created palette.
\end_layout

\begin_layout Standard
Create a new palette (with all colors transparent) and return it.
\end_layout

\begin_layout Subsubsection
Static function load: Load a palette
\end_layout

\begin_layout Itemize
Syntax: palette gui.palette.load(file, [base])
\end_layout

\begin_layout Itemize
Syntax: palette classes.PALETTE.load(file, [base])
\end_layout

\begin_layout Itemize
Deprecated: palette gui.palette_load(file, [base])
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
string file: The file to load.
\end_layout

\begin_layout Itemize
string base (optional): The base file to resolve file relative to.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
palette: PALETTE: The loaded palette.
\end_layout

\begin_layout Standard
Load a palette from file <file> (resolved relative to <base>).
\end_layout

\begin_layout Itemize
The file format is a series of lines, each with following format:
\end_layout

\begin_deeper
\begin_layout Itemize
Blank or just whitespace: Ignored
\end_layout

\begin_layout Itemize
First non-whitespace is '#': Ignored
\end_layout

\begin_layout Itemize
<r> <g> <b>: Fully opaque color with specified RGB values (0-255)
\end_layout

\begin_layout Itemize
<r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
 (0-256, 0 being fully transparent and 256 fully opaque).
\end_layout

\begin_layout Itemize
transparent: Fully transparent color
\end_layout

\end_deeper
\begin_layout Subsubsection
Static function load_str: Load a palette from string
\end_layout

\begin_layout Itemize
Syntax: palette gui.palette.load(data)
\end_layout

\begin_layout Itemize
Syntax: palette classes.PALETTE.load(data)
\end_layout

\begin_layout Itemize
Deprecated: palette gui.palette_load(data)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
string data: The palette data.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
palette: PALETTE: The loaded palette.
\end_layout

\begin_layout Standard
Like PALETTE:load, but instead of reading palette from file, reads it from
 a string.
\end_layout

\begin_layout Subsubsection
Method set: Set palette entry
\end_layout

\begin_layout Itemize
Syntax: palette:set(index, color)
\end_layout

\begin_layout Itemize
Deprecated: gui.palette_set(palette, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
palette: PALETTE: The palette to manipulate
\end_layout

\begin_layout Itemize
index: number: The index of color to set (0-65535).
\end_layout

\begin_layout Itemize
color: number/string: The color value to set.
\end_layout

\begin_layout Standard
Set palette <palette> index <index> to color <color>.
\end_layout

\begin_layout Subsubsection
Method hash: Hash a palette
\end_layout

\begin_layout Itemize
Syntax: hash palette:hash()
\end_layout

\begin_layout Itemize
Deprecated: hash gui.palette_hash(palette)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
palette: The palette to hash.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
hash: string: 64-hex digit hash.
\end_layout

\begin_layout Standard
Obtain crypto-grade hash of palette data of <palette>.
\end_layout

\begin_layout Itemize
All colors after the last non-transparent one are ignored.
\end_layout

\begin_layout Subsubsection
Method adjust_transparency: Adjust transparency
\end_layout

\begin_layout Itemize
Syntax: palette:adjust_transparency(newvalue)
\end_layout

\begin_layout Itemize
Deprecated: gui.adjust_transparency(palette, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
palette: PALETTE: The palette to adjust.
\end_layout

\begin_layout Itemize
Number adj: The factor to multiply opaqueness with times 256.
\end_layout

\begin_layout Standard
Multiply opaqueness of all colors in palette <palette> by factor of <adj>/256.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
BITMAP: Indexed-color bitmap
\end_layout

\begin_layout Subsubsection
Static function new: Create a new bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap gui.bitmap.new(w, h, [fillcolor])
\end_layout

\begin_layout Itemize
Syntax: bitmap classes.BITMAP.new(w, h, [fillcolor])
\end_layout

\begin_layout Itemize
Deprecated: bitmap gui.bitmap_new(w, h, false, [fillcolor])
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
w: number: The width of bitmap to create in pixels.
\end_layout

\begin_layout Itemize
h: number: The height of bitmap to create in pixels.
\end_layout

\begin_layout Itemize
false: boolean: Constant boolean false.
\end_layout

\begin_layout Itemize
fillcolor: number: The initial fill index.
 Default 0 if not specified.
\end_layout

\begin_layout Standard
Create a new bitmap of size <w>*<h>.
 Fill the bitmap with color index <fillcolor>.
\end_layout

\begin_layout Subsubsection
Method draw: Draw a bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap:draw(x, y, palette)
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_draw(x, y, bitmap, palette)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: BITMAP: The bitmap to draw
\end_layout

\begin_layout Itemize
x: number: The x-coordinate on screen.
\end_layout

\begin_layout Itemize
y: number: The y-coordinate on screen.
\end_layout

\begin_layout Itemize
palette: The palette to use for drawing.
\end_layout

\begin_layout Standard
Draw bitmap <bitmap> on screen at <x>,<y> with palette <palette>.
\end_layout

\begin_layout Subsubsection
Method draw_outside: Draw a bitmap outside game area
\end_layout

\begin_layout Itemize
Syntax: bitmap:draw_outside(x, y, palette)
\end_layout

\begin_layout Standard
Like bitmap:draw, but does not draw on game area.
\end_layout

\begin_layout Subsubsection
Method draw_clip: Draw a bitmap, with clipping
\end_layout

\begin_layout Itemize
Syntax: bitmap:draw_clip(x, y, palette, x0, y0, width, height)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: BITMAP: The bitmap to draw
\end_layout

\begin_layout Itemize
x: number: The x-coordinate on screen.
\end_layout

\begin_layout Itemize
y: number: The y-coordinate on screen.
\end_layout

\begin_layout Itemize
palette: The palette to use for drawing.
\end_layout

\begin_layout Itemize
x0: The smallest bitmap x coordinate to draw.
\end_layout

\begin_layout Itemize
y0: The smallest bitmap y coordinate to draw.
\end_layout

\begin_layout Itemize
width: Width of region to draw
\end_layout

\begin_layout Itemize
height: Height of region to draw.
\end_layout

\begin_layout Standard
Like bitmap:draw, but clip the bitmap area drawn.
\end_layout

\begin_layout Subsubsection
Method draw_clip_outside: Draw a bitmap outside game are, with clipping
\end_layout

\begin_layout Itemize
Syntax: bitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
\end_layout

\begin_layout Standard
Like bitmap:draw_clip, but only draw outside game area.
\end_layout

\begin_layout Subsubsection
Method pset: Set pixel in bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap:pset(x, y, color)
\end_layout

\begin_layout Itemize
Deprecaed: gui.bitmap_pset(bitmap, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: BITMAP: The bitmap to manipulate.
\end_layout

\begin_layout Itemize
x: number: x-coordinate of pixel to set.
\end_layout

\begin_layout Itemize
y: number: y-coordinate of pixel to set.
\end_layout

\begin_layout Itemize
color: number: The color index to set.
\end_layout

\begin_layout Standard
Sets specified pixel <x>,<y> in bitmap <bitmap> to color index <color>.
\end_layout

\begin_layout Subsubsection
Method pget: Get pixel in bitmap
\end_layout

\begin_layout Itemize
Syntax: color bitmap:pget(x,y)
\end_layout

\begin_layout Itemize
Deprecated: color gui.bitmap_pget(bitmap, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: BITMAP: The bitmap to query.
\end_layout

\begin_layout Itemize
x: number: x-coordinate of pixel to get.
\end_layout

\begin_layout Itemize
y: number: y-coordinate of pixel to get.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
color: number: The color index in specified pixel.
\end_layout

\begin_layout Standard
Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
\end_layout

\begin_layout Subsubsection
Method size: Get size of bitmap
\end_layout

\begin_layout Itemize
Syntax: width, height bitmap:size()
\end_layout

\begin_layout Itemize
Syntax: width, height gui.bitmap_size(bitmap)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: BITMAP: The bitmap to query.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
width: number: The width of the bitmap.
\end_layout

\begin_layout Itemize
height: number: The height of the bitmap.
\end_layout

\begin_layout Standard
Get size of bitmap <bitmap>.
\end_layout

\begin_layout Subsubsection
Method blit: Blit a bitmap into another
\end_layout

\begin_layout Itemize
Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: BITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
ck: number: The color key.
 Pixels with this index are not copied.
\end_layout

\begin_deeper
\begin_layout Itemize
If none is specified, all pixels are copied.
\end_layout

\end_deeper
\begin_layout Standard
Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> into <dest> at
 <dx>,<dy>.
 If a color key <ck> is specified, pixels of that color are not copied.
\end_layout

\begin_layout Subsubsection
Method blit_scaled: Blit a bitmap into another with scaling
\end_layout

\begin_layout Itemize
Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_scaled(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: BITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
hscl: number: Horizontal scale factor (integer).
\end_layout

\begin_layout Itemize
vscl: number: Vertical scale factor (integer).
 Defaults to the same as <hscl>.
\end_layout

\begin_layout Itemize
ck: number: The color key.
 Pixels with this index are not copied.
\end_layout

\begin_deeper
\begin_layout Itemize
If none is specified, all pixels are copied.
\end_layout

\end_deeper
\begin_layout Standard
Like BITMAP:blit, but also scales the copied part of bitmap (using nearest
 neighbor) by factor of <hscl>*<vscl>.
\end_layout

\begin_layout Subsubsection
Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
\end_layout

\begin_layout Itemize
Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_porterduff(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: BITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
operator: string: The operator to use.
\end_layout

\begin_deeper
\begin_layout Itemize
Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
 DestOut, Clear or Xor.
\end_layout

\end_deeper
\begin_layout Standard
Like BITMAP:blit, but instead of just overwriting, applies specified Porter-Duff
 operator.
 
\end_layout

\begin_layout Itemize
Color index 0 in source and target is treated as background.
\end_layout

\begin_layout Subsubsection
Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
 Porter-Duff composition
\end_layout

\begin_layout Itemize
Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
 operator)
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: BITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
hscl: number: Horizontal scale factor (integer).
\end_layout

\begin_layout Itemize
vscl: number: Vertical scale factor (integer).
 Defaults to the same as <hscl>.
\end_layout

\begin_layout Itemize
operator: string: The operator to use.
\end_layout

\begin_deeper
\begin_layout Itemize
Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
 DestOut, Clear or Xor.
\end_layout

\end_deeper
\begin_layout Standard
Like BITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
 like BITMAP:blit_scaled.
\end_layout

\begin_layout Subsubsection
Method blit_priority: Blit a bitmap into another with color priority
\end_layout

\begin_layout Itemize
Syntax: dest:blit_priority(dx, dy, src, sx, sy, w, h)
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_priority(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: BITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Standard
Like BITMAP:blit, but only copy pixels where source color index is greater
 than destination color index.
\end_layout

\begin_layout Subsubsection
Method blit_scaled_priority: Blit a bitmap into another with color priority
 and scaling
\end_layout

\begin_layout Itemize
Syntax: dest:blit_scaled_priority(dx, dy, src, sx, sy, w, h, hscl, [vscl])
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_scaled_priority(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: BITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
hscl: number: Horizontal scale factor (integer).
\end_layout

\begin_layout Itemize
vscl: number: Vertical scale factor (integer).
 Defaults to the same as <hscl>.
\end_layout

\begin_layout Standard
Like BITMAP:blit_priority, but apply scaling by <hscl>*<vscl> like BITMAP:blit_s
caled.
\end_layout

\begin_layout Subsubsection
Method save_png: Save a bitmap to PNG
\end_layout

\begin_layout Itemize
Syntax: bitmap:save_png(filename, [base], palette)
\end_layout

\begin_layout Itemize
Syntax: data bitmap:save_png(palette)
\end_layout

\begin_layout Itemize
Deprecated: ...
 gui.bitmap_save_png(bitmap, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: BITMAP: The bitmap to save.
\end_layout

\begin_layout Itemize
filename: string: The filename to save to.
\end_layout

\begin_layout Itemize
base: string: The base filename is resolved relative to.
\end_layout

\begin_layout Itemize
palette: PALETTE: The palette to use.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
data: string: BASE64 encoded PNG data.
\end_layout

\begin_layout Standard
Save bitmap <bitmap>, with palette <pal> into PNG file <filename> (relative
 to <base>) or return BASE64 encoding of it.
\end_layout

\begin_layout Subsubsection
Method hash: Hash a bitmap
\end_layout

\begin_layout Itemize
Syntax: hash bitmap:hash()
\end_layout

\begin_layout Itemize
Deprecated: hash bitmap:hash(bitmap)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: BITMAP: The bitmap to hash.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
hash: string: 64-hex digit hash
\end_layout

\begin_layout Standard
Hashes bitmap <bitmap> and returns crypto-strong hash.
 
\end_layout

\begin_layout Itemize
Color order in bitmap is significant.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
DBITMAP: Direct-color bitmap
\end_layout

\begin_layout Subsubsection
Static function: new: Create a new bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap gui.dbitmap.new(w, h, [fillcolor])
\end_layout

\begin_layout Itemize
Syntax: bitmap classes.DBITMAP.new(w, h, [fillcolor])
\end_layout

\begin_layout Itemize
Deprecated: bitmap gui.bitmap_new (w, h, true, [fillcolor]).
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
w: number: The width of new bitmap.
\end_layout

\begin_layout Itemize
h: number: The height of new bitmap.
\end_layout

\begin_layout Itemize
true: boolean: Fixed boolean true
\end_layout

\begin_layout Itemize
fillcolor: The color to fill the bitmap with (default transparent).
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The new bitmap.
\end_layout

\begin_layout Standard
Create a new direct-color bitmap of size <w>*<h>, initially filled with
 <fillcolor>.
\end_layout

\begin_layout Subsubsection
Method draw: Draw a bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap.draw(x, y)
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_draw(x, y, bitmap)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to draw.
\end_layout

\begin_layout Itemize
x: number: X-coordinate on screen.
\end_layout

\begin_layout Itemize
y: number: Y-coordinate on screen.
\end_layout

\begin_layout Standard
Draw bitmap <bitmap> on screen at <x>,<y>.
\end_layout

\begin_layout Subsubsection
Method draw_outside: Draw a bitmap outside game area
\end_layout

\begin_layout Itemize
Syntax: dbitmap:draw_outside(x, y, palette)
\end_layout

\begin_layout Standard
Like dbitmap:draw, but does not draw on game area.
\end_layout

\begin_layout Subsubsection
Method draw_clip: Draw a bitmap, with clipping
\end_layout

\begin_layout Itemize
Syntax: dbitmap:draw(x, y, palette, x0, y0, width, height)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to draw
\end_layout

\begin_layout Itemize
x: number: The x-coordinate on screen.
\end_layout

\begin_layout Itemize
y: number: The y-coordinate on screen.
\end_layout

\begin_layout Itemize
x0: The smallest bitmap x coordinate to draw.
\end_layout

\begin_layout Itemize
y0: The smallest bitmap y coordinate to draw.
\end_layout

\begin_layout Itemize
width: Width of region to draw
\end_layout

\begin_layout Itemize
height: Height of region to draw.
\end_layout

\begin_layout Standard
Like dbitmap:draw, but clip the bitmap area drawn.
\end_layout

\begin_layout Subsubsection
Method draw_clip_outside: Draw a bitmap outside game are, with clipping
\end_layout

\begin_layout Itemize
Syntax: dbitmap:draw_clip_outside(x, y, palette, x0, y0, width, height)
\end_layout

\begin_layout Standard
Like dbitmap:draw_clip, but only draw outside game area.
\end_layout

\begin_layout Subsubsection
Method pset: Set pixel in bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap:pset(x, y, color)
\end_layout

\begin_layout Itemize
Deprecaed: gui.bitmap_pset(bitmap, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to manipulate.
\end_layout

\begin_layout Itemize
x: number: x-coordinate of pixel to set.
\end_layout

\begin_layout Itemize
y: number: y-coordinate of pixel to set.
\end_layout

\begin_layout Itemize
color: number/string: The color to set.
\end_layout

\begin_layout Standard
Sets specified pixel <x>,<y> in bitmap <bitmap> to color <color>.
\end_layout

\begin_layout Subsubsection
Method pget: Get pixel in bitmap
\end_layout

\begin_layout Itemize
Syntax: color bitmap:pget(x,y)
\end_layout

\begin_layout Itemize
Deprecated: color gui.bitmap_pget(bitmap, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to query.
\end_layout

\begin_layout Itemize
x: number: x-coordinate of pixel to get.
\end_layout

\begin_layout Itemize
y: number: y-coordinate of pixel to get.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
color: number: The color of specified pixel.
\end_layout

\begin_layout Standard
Gets color index of specified pixel <x>,<y> in bitmap <bitmap>.
\end_layout

\begin_layout Subsubsection
Method size: Get size of bitmap
\end_layout

\begin_layout Itemize
Syntax: width, height bitmap:size()
\end_layout

\begin_layout Itemize
Syntax: width, height gui.bitmap_size(bitmap)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to query.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
width: number: The width of the bitmap.
\end_layout

\begin_layout Itemize
height: number: The height of the bitmap.
\end_layout

\begin_layout Standard
Get size of bitmap <bitmap>.
\end_layout

\begin_layout Subsubsection
Method blit: Blit a bitmap into another
\end_layout

\begin_layout Itemize
Syntax: dest:blit(dx, dy, src, sx, sy, w, h, [ck])
\end_layout

\begin_layout Itemize
Syntax: dest:blit(dx, dy, src, srcpal, sx, sy, w, h, [ck])
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: DBITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP/DBITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
srcpal: PALETTE: If <src> is indexed, this is the palette for source.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
ck: number: The color key.
 Pixels with this index are not copied.
\end_layout

\begin_deeper
\begin_layout Itemize
If none is specified, all pixels are copied.
\end_layout

\begin_layout Itemize
If <src> is paletted, this is color index, otherwise it is a color.
\end_layout

\end_deeper
\begin_layout Standard
Copy region of size <w>*<h> at <sx>,<sy> in bitmap <src> (with palette <pal>
 if indexed) into <dest> at <dx>,<dy>.
 If a color key <ck> is specified, pixels of that color are not copied.
\end_layout

\begin_layout Subsubsection
Method blit_scaled: Blit a bitmap into another with scaling
\end_layout

\begin_layout Itemize
Syntax: dest:blit_scaled(dx, dy, src, sx, sy, w, h, hscl, [vscl], [ck])
\end_layout

\begin_layout Itemize
Syntax: dest:blit_scaled(dx, dy, src, srcpal, sx, sy, w, h, hscl, [vscl],
 [ck])
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_scaled(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: DBITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP/DBITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
srcpal: PALETTE: If <src> is indexed, this is the palette for source.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
hscl: number: Horizontal scale factor (integer).
\end_layout

\begin_layout Itemize
vscl: number: Vertical scale factor (integer).
 Defaults to the same as <hscl>.
\end_layout

\begin_layout Itemize
ck: number: The color key.
 Pixels with this index are not copied.
\end_layout

\begin_deeper
\begin_layout Itemize
If none is specified, all pixels are copied.
\end_layout

\begin_layout Itemize
If <src> is paletted, this is color index, otherwise it is a color.
\end_layout

\end_deeper
\begin_layout Standard
Like DBITMAP:blit, but also scales the copied part of bitmap (using nearest
 neighbor) by factor of <hscl>*<vscl>.
\end_layout

\begin_layout Subsubsection
Method blit_porterduff: Blit a bitmap into another with Porter-Duff composition
\end_layout

\begin_layout Itemize
Syntax: dest:blit_porterduff(dx, dy, src, sx, sy, w, h, operator)
\end_layout

\begin_layout Itemize
Syntax: dest:blit_porterduff(dx, dy, src, srcpal, sx, sy, w, h, operator)
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_porterduff(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: DBITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP/DBITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
srcpal: PALETTE: If <src> is indexed, this is the palette for source.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
operator: string: The operator to use.
\end_layout

\begin_deeper
\begin_layout Itemize
Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
 DestOut, Clear or Xor.
\end_layout

\end_deeper
\begin_layout Standard
Like DBITMAP:blit, but instead of just overwriting, applies specified Porter-Duf
f operator.
 
\end_layout

\begin_layout Itemize
In target, fully transparent is background.
 In source, either fully transparent (if direct) or index 0 (if paletted)
 is treated as background.
\end_layout

\begin_layout Subsubsection
Method blit_scaled_porterduff: Blit a bitmap into another with scaling and
 Porter-Duff composition
\end_layout

\begin_layout Itemize
Syntax: dest:blit_scaled_porterduff(dx, dy, src, sx, sy, w, h, hscl, [vscl],
 operator)
\end_layout

\begin_layout Itemize
Syntax: dest:blit_scaled_porterduff(dx, dy, src, srcpal, sx, sy, w, h, hscl,
 [vscl], operator)
\end_layout

\begin_layout Itemize
Deprecated: gui.bitmap_blit_scaled_porterduff(dest, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
dest: DBITMAP: The target bitmap to blit to.
\end_layout

\begin_layout Itemize
dx: number: The x-coordinate in target.
\end_layout

\begin_layout Itemize
dy: number: The y-coordinate in target.
\end_layout

\begin_layout Itemize
src: BITMAP/DBITMAP: The source bitmap.
\end_layout

\begin_layout Itemize
srcpal: PALETTE: If <src> is indexed, this is the palette for source.
\end_layout

\begin_layout Itemize
sx: number: The x-coordinate in source.
\end_layout

\begin_layout Itemize
sy: number: The y-coordinate in source.
\end_layout

\begin_layout Itemize
w: number: The width of area to blit.
\end_layout

\begin_layout Itemize
h: number: The height of area to blit.
\end_layout

\begin_layout Itemize
hscl: number: Horizontal scale factor (integer).
\end_layout

\begin_layout Itemize
vscl: number: Vertical scale factor (integer).
 Defaults to the same as <hscl>.
\end_layout

\begin_layout Itemize
operator: string: The operator to use.
\end_layout

\begin_deeper
\begin_layout Itemize
Can be one of: Src, Atop, Over, In, Out, Dest, DestAtop, DestOver, DestIn,
 DestOut, Clear or Xor.
\end_layout

\end_deeper
\begin_layout Standard
Like DBITMAP:blit_porterduff, but also scales the source by <hscl>*<vscl>
 like DBITMAP:blit_scaled.
\end_layout

\begin_layout Subsubsection
Method adjust_transparency: Adjust transparency of bitmap
\end_layout

\begin_layout Itemize
Syntax: bitmap:adjust_transparency(newvalue)
\end_layout

\begin_layout Itemize
Deprecated: gui.adjust_transparency(bitmap, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to adjust.
\end_layout

\begin_layout Itemize
Number adj: The factor to multiply opaqueness with times 256.
\end_layout

\begin_layout Standard
Multiply opaqueness of all colors in bitmap <bitmap> by factor of <adj>/256.
\end_layout

\begin_layout Subsubsection
Method save_png: Save a bitmap to PNG
\end_layout

\begin_layout Itemize
Syntax: bitmap:save_png(filename, [base])
\end_layout

\begin_layout Itemize
Syntax: data bitmap:save_png()
\end_layout

\begin_layout Itemize
Deprecated: ...
 gui.bitmap_save_png(bitmap, ...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to save.
\end_layout

\begin_layout Itemize
filename: string: The filename to save to.
\end_layout

\begin_layout Itemize
base: string: The base filename is resolved relative to.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
data: string: BASE64 encoded PNG data.
\end_layout

\begin_layout Standard
Save bitmap <bitmap> into PNG file <filename> (relative to <base>) or return
 BASE64 encoding of it.
\end_layout

\begin_layout Subsubsection
Method hash: Hash a bitmap
\end_layout

\begin_layout Itemize
Syntax: hash bitmap:hash()
\end_layout

\begin_layout Itemize
Deprecated: hash bitmap:hash(bitmap)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
bitmap: DBITMAP: The bitmap to hash.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
hash: string: 64-hex digit hash
\end_layout

\begin_layout Standard
Hashes bitmap <bitmap> and returns crypto-strong hash.
 
\end_layout

\begin_layout Subsection
IMAGELOADER: Load an image
\end_layout

\begin_layout Subsubsection
Static function load: Load a bitmap from file
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette gui.image.load(file, [base])
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette classes.IMAGELOADER.load(file, [base])
\end_layout

\begin_layout Itemize
Deprecated: ...
 gui.bitmap_load(...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
file: string: The file to read.
\end_layout

\begin_layout Itemize
base: string: The base to resolve <file> relative to.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
bitmap: BITMAP/DBITMAP: The new bitmap
\end_layout

\begin_layout Itemize
palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
 nil.
\end_layout

\begin_layout Standard
Load a new bitmap and return it (plus associated palette if any).
\end_layout

\begin_layout Subsubsection
Static function load_str: Load a bitmap from string
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette gui.image.load_str(data)
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette classes.IMAGELOADER.load_str(data)
\end_layout

\begin_layout Itemize
Deprecated: ...
 gui.bitmap_load_str(...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
data: string: The image data
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
bitmap: BITMAP/DBITMAP: The new bitmap
\end_layout

\begin_layout Itemize
palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
 nil.
\end_layout

\begin_layout Standard
Like IMAGELOADER:load, but read the bitmap from string <data> instead of
 file.
\end_layout

\begin_layout Subsubsection
Static function load_png: Load a bitmap from PNG file
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette gui.image.load_png(file, [base])
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette classes.IMAGELOADER.load_png(file, [base])
\end_layout

\begin_layout Itemize
Deprecated: ...
 gui.bitmap_load_png(...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
file: string: The file to read.
\end_layout

\begin_layout Itemize
base: string: The base to resolve <file> relative to.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
bitmap: BITMAP/DBITMAP: The new bitmap
\end_layout

\begin_layout Itemize
palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
 nil.
\end_layout

\begin_layout Standard
Like IMAGELOADER:load, but load a PNG file instead.
\end_layout

\begin_layout Subsubsection
Static function load_png_str: Load a PNG bitmap from string
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette gui.image.load_png_str(data)
\end_layout

\begin_layout Itemize
Syntax: bitmap, palette classes.IMAGELOADER.load_png_str(data)
\end_layout

\begin_layout Itemize
Deprecated: ...
 gui.bitmap_load_png_str(...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
data: string: The image data, base64 encoded.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
bitmap: BITMAP/DBITMAP: The new bitmap
\end_layout

\begin_layout Itemize
palette: PALETTE: If bitmap is paletted, this is the palette, otherwise
 nil.
\end_layout

\begin_layout Standard
Like IMAGELOADER:load_png, but read the bitmap from BASE64 encoded string
 <data> instead of file.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
CUSTOMFONT: Arbitrary-sized bitmap font
\end_layout

\begin_layout Subsubsection
Static function new: Return a new empty font
\end_layout

\begin_layout Itemize
Syntax: font gui.font.new()
\end_layout

\begin_layout Itemize
Syntax: font classes.CUSTOMFONT.new()
\end_layout

\begin_layout Itemize
Deprecated: font gui.font_new()
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
font: CUSTOMFONT: New font.
\end_layout

\begin_layout Standard
Create a new font with no characters and return it.
\end_layout

\begin_layout Subsubsection
Static function: load: Load a font file
\end_layout

\begin_layout Itemize
Syntax: font gui.font.load(file, [base])
\end_layout

\begin_layout Itemize
Syntax: font gui.font.load()
\end_layout

\begin_layout Itemize
Syntax: font classes.CUSTOMFONT.load(file, [base])
\end_layout

\begin_layout Itemize
Syntax: font classes.CUSTOMFONT.load()
\end_layout

\begin_layout Itemize
Deprecated: font gui.loadfont(...)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
file: string: The file to read the font from
\end_layout

\begin_layout Itemize
base: string: The file to resolve <file> relative to.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
font: CUSTOMFONT: New font.
\end_layout

\begin_layout Standard
Load font from file <file> (relative to <base>).
 If no filename is given, system default font is loaded.
\end_layout

\begin_layout Subsubsection
operator(): Render text to screen
\end_layout

\begin_layout Itemize
Syntax: font(x, y, text, [fgc], [bgc], [hlc])
\end_layout

\begin_layout Standard
Parmeters:
\end_layout

\begin_layout Itemize
font: CUSTOMFONT: The font to use.
\end_layout

\begin_layout Itemize
x: number: The x-position on screen to draw to.
\end_layout

\begin_layout Itemize
y: number: The y-position on screen to draw to.
\end_layout

\begin_layout Itemize
text: string: The text to draw.
\end_layout

\begin_layout Itemize
fgc: number/string: Foreground color (default white).
\end_layout

\begin_layout Itemize
bgc: number/string: Background color (default transparent).
\end_layout

\begin_layout Itemize
hlc: number/string: Outline color (default transparent).
\end_layout

\begin_layout Standard
Draws a string <text> with specified font <font> and colors <fgc>,<bgc>,<hlc>
 onto screen.
\end_layout

\begin_layout Itemize
If <hlc> is transparent, no outline is drawn.
\end_layout

\begin_layout Subsubsection
Method edit: Alter glyph in font
\end_layout

\begin_layout Itemize
Syntax: font:edit(character, glyph)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
font: CUSTOMFONT: The font to edit.
\end_layout

\begin_layout Itemize
character: string: The character to edit (UTF-8 encoded).
\end_layout

\begin_layout Itemize
glyph: BITMAP: The bitmap to use.
\end_layout

\begin_layout Standard
Replace character <character> in font <font> by <glyph>.
\end_layout

\begin_layout Itemize
Color index 0 is background, everything else is foreground.
\end_layout

\begin_layout Itemize
<character> may be empty string, meaning the replacement character used
 for bad characters.
\end_layout

\begin_layout Itemize
<character> may be multi-codepoint string, meaning character used for that
 ligature.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
ICONV: Character set conversions
\end_layout

\begin_layout Subsubsection
Static function new: Create new character set converter
\end_layout

\begin_layout Itemize
Syntax: iconv iconv.new(from, to);
\end_layout

\begin_layout Itemize
Syntax: iconv classes.ICONV.new(from, to);
\end_layout

\begin_layout Itemize
Deprecated: iconv iconv_new(...);
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
from: string: The source character set.
\end_layout

\begin_layout Itemize
to: string: The target character set.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
iconv: ICONV: The converter.
\end_layout

\begin_layout Standard
Create a character set converter, converting from <from> to <to> and return
 it.
\end_layout

\begin_layout Subsubsection
Operator(): Convert string fragment from character set to another
\end_layout

\begin_layout Itemize
Syntax: success, result, unconverted, error iconv(input)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
iconv: ICONV: The context to use.
\end_layout

\begin_layout Itemize
input: string: The input to convert.
\end_layout

\begin_layout Standard
Return value:
\end_layout

\begin_layout Itemize
success: boolean: True if conversion was successful, false if not.
\end_layout

\begin_layout Itemize
result: string: The string (partially) converted.
\end_layout

\begin_layout Itemize
unconvered: number: Number of bytes that were not converted (only if <success>
 is false).
\end_layout

\begin_layout Itemize
error: string: Error that caused conversion to stop (only if <success> is
 false).
\end_layout

\begin_deeper
\begin_layout Itemize
INVALID: The input string is invalid.
\end_layout

\begin_layout Itemize
INCOMPLETE: The input string cuts off in middle of character.
\end_layout

\begin_layout Itemize
INTERNALERR: Internal error.
\end_layout

\end_deeper
\begin_layout Standard
Convert a string <input> using character set converter <iconv> and return
 the result.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
FILEREADER: Read a file as a stream
\end_layout

\begin_layout Subsubsection
Static function open: Open a stream
\end_layout

\begin_layout Itemize
Syntax: handle filereader.open(file, [base])
\end_layout

\begin_layout Itemize
Syntax: handle classes.FILEREADER.open(file, [base])
\end_layout

\begin_layout Itemize
Deprecated: handle open_file(file, [base])
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
file: string: The filename to read.
\end_layout

\begin_layout Itemize
base: string: The base <file> is resolved against.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
handle: FILEREADER: The new file reader.
\end_layout

\begin_layout Standard
Open file <file> (relative to <base>) and return a handle to it.
\end_layout

\begin_layout Subsubsection
operator(): Read line/bytes from stream
\end_layout

\begin_layout Itemize
Syntax: result handle()
\end_layout

\begin_layout Itemize
Syntax: result handle(bytes)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
handle: FILEREADER: The handle to read from.
\end_layout

\begin_layout Itemize
bytes: Number of bytes to read (default is next line).
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
result: string: The read data, or nil on end-of-file.
\end_layout

\begin_layout Standard
Reads next line or <bytes> bytes from specified file handle <handle>.
\end_layout

\begin_layout Itemize
If reading specified number of bytes, the bytes are read in binary mode
 (as-is).
\end_layout

\begin_layout Itemize
If reading next line, the line is read in text mode (any line ending is
 skpped).
\end_layout

\begin_layout Subsubsection
Method lines: Iterator to read all lines
\end_layout

\begin_layout Itemize
Syntax: for line in handle:lines() do ...
 end
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
handle: FILEREADER: The handle to read.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
A lua iterator with one variable.
\end_layout

\begin_layout Standard
Return a Lua iterator that iterates all the lines in <handle>.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Subsection
COMPARE_OBJ: Watch memory area for changes
\end_layout

\begin_layout Standard
Objects of this class allow fast checking for modifications to given memory
 block.
\end_layout

\begin_layout Subsubsection
Static function new: Create a checker
\end_layout

\begin_layout Itemize
Syntax: handle classes.COMPARE_OBJ.new({marea, offset|addrobj}, size, [rows,
 stride])
\end_layout

\begin_layout Itemize
Syntax: handle memory.compare_new({marea, offset|addrobj}, size, rows, stride)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
marea: string: The memory area to interpret <offset> against.
\end_layout

\begin_layout Itemize
offset: number: The initial offset in memory area.
\end_layout

\begin_layout Itemize
addrobj: ADDRESS: The memory address.
\end_layout

\begin_layout Itemize
size: number: The number of bytes in each row.
\end_layout

\begin_layout Itemize
rows: number: The number of rows.
 Default is 1.
\end_layout

\begin_layout Itemize
stride: number: The number of bytes offset increments from one row to next.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
A handle to object.
\end_layout

\begin_layout Standard
Return an object watching specified memory area.
\end_layout

\begin_layout Itemize
Note: For fastest operation, limit checks to inside one memory area (that
 has to be mappable, individual RAM areas often are).
\end_layout

\begin_layout Subsubsection
operator(): Check area for modifications
\end_layout

\begin_layout Itemize
Syntax: boolean handle()
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
True if memory block has been modified since last call (or object creation
 if first call), false if not.
\end_layout

\begin_layout Standard
Check if the block has been modified.
\end_layout

\begin_layout Subsection
ADDRESS: Memory address
\end_layout

\begin_layout Standard
Objects of this class contain a memory address.
\end_layout

\begin_layout Subsubsection
Static function new: Create new memory address
\end_layout

\begin_layout Itemize
Syntax: ADDRESS classes.ADDRESS.new(string marea, number offset)
\end_layout

\begin_layout Itemize
Syntax: ADDRESS memory.address.new(string marea, number offset)
\end_layout

\begin_layout Itemize
Syntax: ADDRESS memory.mkaddr(string marea, number offset)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
marea: The memory area
\end_layout

\begin_layout Itemize
offset: The offset in memory area.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
The memory area.
\end_layout

\begin_layout Standard
Construct a new memory address object.
\end_layout

\begin_layout Subsubsection
Method: addr: Get global address
\end_layout

\begin_layout Itemize
Syntax: number addr:addr()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
addr: ADRESS: The original address.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
The global address corresponding to this address.
\end_layout

\begin_layout Subsubsection
Method: vma: Get memory area
\end_layout

\begin_layout Itemize
Syntax: string addr:vma()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
addr: ADRESS: The original address.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
The memory area corresponding to this address.
\end_layout

\begin_layout Subsubsection
Method: offset: Get memory area offset
\end_layout

\begin_layout Itemize
Syntax: string addr:offset()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
addr: ADRESS: The original address.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
The offset in memory area corresponding to this address.
\end_layout

\begin_layout Subsubsection
Method: replace: Replace address part
\end_layout

\begin_layout Itemize
Syntax: ADDRESS addr:replace(offset[, bits])
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
addr: ADRESS: The original address.
\end_layout

\begin_layout Itemize
offset: number: The new offset
\end_layout

\begin_layout Itemize
bits: number: The number of LSB to replace.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
The modified address
\end_layout

\begin_layout Standard
Returns a new address, with <bits> (all if missing) least significant bits
 of <addr> replaced by LSB of <offset>.
\end_layout

\begin_layout Subsubsection
Method: add: Add to address
\end_layout

\begin_layout Itemize
Syntax: ADDRESS addr:add(offset)
\end_layout

\begin_layout Itemize
Syntax: ADDRESS addr:add(number, stride)
\end_layout

\begin_layout Itemize
Syntax: ADDRESS addr:add(number, stride, offset)
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
addr: ADRESS: The original address.
\end_layout

\begin_layout Itemize
offset: number: Offset to add.
\end_layout

\begin_layout Itemize
number: number: Number of table strides to add.
\end_layout

\begin_layout Itemize
stride: number: The table stride.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
The modified address
\end_layout

\begin_layout Standard
Adds <offset>, <number>*<stride> or <number>*<stride>+<offset> into specified
 address <addr>.
\end_layout

\begin_layout Subsection
ADDRESS:<op>: Read/Write memory
\end_layout

\begin_layout Itemize
Syntax: none addr:<op>(value)
\end_layout

\begin_layout Itemize
Syntax: number addr:<op>()
\end_layout

\begin_layout Standard
Parameters:
\end_layout

\begin_layout Itemize
addr: ADDRESS: The address to read/write.
\end_layout

\begin_layout Itemize
value: number: The number to write.
\end_layout

\begin_layout Standard
Returns:
\end_layout

\begin_layout Itemize
The value read.
\end_layout

\begin_layout Standard
Read/Write value from/to given address <addr>.
 The value written is <value>.
 <Op> is of form: [i][s]<type>, where:
\end_layout

\begin_layout Itemize
<type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
\end_layout

\begin_layout Itemize
'i' signifies that the value is treated as opposite-to-normal endianess,
\end_layout

\begin_layout Itemize
's' signifies that value is treated as signed (not available for floating-point).
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Global
\end_layout

\begin_layout Subsection
print: Print values to console
\end_layout

\begin_layout Itemize
Syntax: none print(value...
 values)
\end_layout

\begin_layout Standard
Prints specified values to console.
 Can print any Lua type at least enough to identify the type and instance.
\end_layout

\begin_layout Subsection
tostringx: Format a value to string
\end_layout

\begin_layout Itemize
Syntax: string tostringx(value val)
\end_layout

\begin_layout Standard
Formats value <val> like print would, and returns the result as a string.
\end_layout

\begin_layout Subsection
exec: Execute lsnes commands
\end_layout

\begin_layout Itemize
Syntax: none exec(string cmd)
\end_layout

\begin_layout Standard
Execute lsnes command <cmd>.
\end_layout

\begin_layout Subsection
utime: Get current time
\end_layout

\begin_layout Itemize
Syntax: (number,number) utime()
\end_layout

\begin_layout Standard
Returns two numbers.
 First is time since some epoch in seconds, the second is microseconds mod
 10^6 since that epoch.
\end_layout

\begin_layout Subsection
set_idle_timeout: Run function after timeout when emulator is idle
\end_layout

\begin_layout Itemize
Syntax: none set_idle_timeout(number timeout)
\end_layout

\begin_layout Standard
Set number of microseconds to block idle for.
 After this timeout has expired, on_idle() will be called once.
\end_layout

\begin_layout Subsection
set_timer_timeout: Run function after timeout.
\end_layout

\begin_layout Itemize
Syntax: none set_timer_timeout(number timeout)
\end_layout

\begin_layout Standard
Set number of microseconds to block timer for.
 After this timeout has expired, on_timer() will be called once.
\end_layout

\begin_layout Subsection
bus_address: Look up address in system bus.
\end_layout

\begin_layout Itemize
Syntax: none bus_address(number bus_addr)
\end_layout

\begin_layout Standard
Returns virtual address corresponding to specified address on system bus.
\end_layout

\begin_layout Subsection
loopwrapper: Convert loop into callable function
\end_layout

\begin_layout Itemize
Syntax: function loopwrapper(function fun, ...)
\end_layout

\begin_layout Standard
Calls function <fun> with function and specified arguments.
 The function passed suspends execution until the function returned is called.
 Handy for linear flow control among multiple invocations of a hook.
 Example code:
\end_layout

\begin_layout LyX-Code
on_paint = loopwrapper(function(wait)
\end_layout

\begin_deeper
\begin_layout LyX-Code
while true do
\end_layout

\begin_deeper
\begin_layout LyX-Code
gui.text(0, 0, 
\begin_inset Quotes eld
\end_inset

Test!
\begin_inset Quotes erd
\end_inset

);
\end_layout

\begin_layout LyX-Code
wait();
\end_layout

\end_deeper
\begin_layout LyX-Code
end
\end_layout

\end_deeper
\begin_layout LyX-Code
end);
\end_layout

\begin_layout Subsection
list_bindings: List keybindings
\end_layout

\begin_layout Itemize
Syntax: table list_bindings([string cmd])
\end_layout

\begin_layout Standard
Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
 If <cmd> is specified, the table is limited to that command.
 Also searches for controller keys.
\end_layout

\begin_layout Subsection
get_alias: Get expansion of alias
\end_layout

\begin_layout Itemize
Syntax: string get_alias(string aname)
\end_layout

\begin_layout Standard
Get expansion of given alias <aname>.
\end_layout

\begin_layout Subsection
set_alias: Set expansion of alias
\end_layout

\begin_layout Itemize
Syntax: none set_alias(string aname, string value)
\end_layout

\begin_layout Standard
Set expansion of given alias.
\end_layout

\begin_layout Subsection
create_ibind: Create invese binding
\end_layout

\begin_layout Itemize
Syntax: INVERSEBIND create_ibind(string name, string cmd)
\end_layout

\begin_layout Standard
Return object representing inverse binding with specified name <name> and
 specified command <cmd>.
\end_layout

\begin_layout Itemize
Note: To create press/release commands, use aliases +foo and -foo .
\end_layout

\begin_layout Itemize
Note: Keep the returned object around.
\end_layout

\begin_layout Subsection
create_command: Create a command
\end_layout

\begin_layout Itemize
Syntax: COMMANDBIND create_commmand(string name, function a)
\end_layout

\begin_layout Itemize
Syntax: COMMANDBIND create_commmand(string name, function a, function b)
\end_layout

\begin_layout Standard
Return object representing a command (pair).
\end_layout

\begin_layout Itemize
If only one function is specied, the command is level-sensitive, <a> is
 callback.
\end_layout

\begin_layout Itemize
If <b> is function, the function is edge-sensitive, <a> is positive edge
 callback and <b> is negative edge callback.
\end_layout

\begin_layout Itemize
All callbacks get single argument: The parameters passed.
\end_layout

\begin_layout Itemize
Keep the returned object around.
\end_layout

\begin_layout Subsection
loadfile: Load Lua script
\end_layout

\begin_layout Itemize
Syntax: function loadfile(string filename[, string base])
\end_layout

\begin_layout Standard
Load lua script from <filename>, resolved relative to <base> (if empty,
 current directory).
\end_layout

\begin_layout Subsection
dofile: Execute Lua script
\end_layout

\begin_layout Itemize
Syntax: function dofile(string filename[, string base])
\end_layout

\begin_layout Standard
Execute lua script from <filename>, resolved relative to <base> (if empty,
 current directory) and return all return values.
\end_layout

\begin_layout Subsection
resolve_filename: Resolve name of file relative to another
\end_layout

\begin_layout Itemize
Syntax: string resolve_file(string filename, string base)
\end_layout

\begin_layout Standard
Resolve name of file <filename> relative to <base> and return the result.
\end_layout

\begin_layout Subsection
render_queue_function: Return paint function for render queue
\end_layout

\begin_layout Itemize
Syntax: function render_queue_function(RENDERQUEUE rq)
\end_layout

\begin_layout Standard
Return function that renders render queue <rq>.
\end_layout

\begin_layout Itemize
Handy for paint callback if one is using render queues updated in other
 callbacks.
 As in:
\end_layout

\begin_layout LyX-Code
handle = callback.paint:register(render_queue_function(my_rq));
\end_layout

\begin_layout Subsection
identify_class: Identify class of object
\end_layout

\begin_layout Itemize
Syntax: string identify_class(userdata object)
\end_layout

\begin_layout Standard
Identifies the class of userdata <object>, if possible.
 If no identification is possible, returns 
\begin_inset Quotes eld
\end_inset

unknown
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Subsection
lookup_class: Lookup class by name
\end_layout

\begin_layout Itemize
Syntax: classobj lookup_class(string name)
\end_layout

\begin_layout Standard
Looks up class corresponding to <name>, if possible.
 If not found, returns nil.
 The classobj has following fields:
\end_layout

\begin_layout Itemize
_static_methods: Return static method names
\end_layout

\begin_layout Itemize
_class_methods: Return class method names
\end_layout

\begin_layout Itemize
<static-function-name>: The specified static function.
\end_layout

\begin_layout Subsection
all_classes: Get list of all classes
\end_layout

\begin_layout Itemize
Syntax: string...
 all_classes()
\end_layout

\begin_layout Standard
Get names of all classes available.
\end_layout

\begin_layout Subsection

\end_layout

\begin_layout Subsection
icnov: Class ICONV
\end_layout

\begin_layout Standard
See class ICONV.
\end_layout

\begin_layout Subsection
filereader: Class FILEREADER
\end_layout

\begin_layout Standard
See class FILEREADER.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table bit:
\end_layout

\begin_layout Standard
Bitwise logical functions and related.
\end_layout

\begin_layout Subsection
bit.none/bit.bnot: Bitwise none or NOT function
\end_layout

\begin_layout Itemize
Syntax: number bit.none(number...)
\end_layout

\begin_layout Itemize
Syntax: number bit.bnot(number...)
\end_layout

\begin_layout Standard
48-bit bitwise NOT / NONE function (set bits that are set in none of the
 arguments).
\end_layout

\begin_layout Subsection
bit.any/bit.bor: Bitwise any or OR function
\end_layout

\begin_layout Itemize
Syntax: number bit.any(number...)
\end_layout

\begin_layout Itemize
Syntax: number bit.bor(number...)
\end_layout

\begin_layout Standard
48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
\end_layout

\begin_layout Subsection
bit.all/bit.band: Bitwise all or AND function
\end_layout

\begin_layout Itemize
Syntax: number bit.all(number...)
\end_layout

\begin_layout Itemize
Syntax: number bit.band(number...)
\end_layout

\begin_layout Standard
48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
).
\end_layout

\begin_layout Subsection
bit.parity/bit.bxor: Bitwise parity or XOR function
\end_layout

\begin_layout Itemize
Syntax: number bit.parity(number...)
\end_layout

\begin_layout Itemize
Syntax: number bit.bxor(number...)
\end_layout

\begin_layout Standard
48-bit bitwise XOR / PARITY function (set bits that are set in odd number
 of the arguments).
\end_layout

\begin_layout Subsection
bit.lrotate: Rotate a number left
\end_layout

\begin_layout Itemize
Syntax: number bit.lrotate(number base[, number amount[, number bits]])
\end_layout

\begin_layout Standard
Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
 1) places.
\end_layout

\begin_layout Subsection
bit.rrotate: Rotate a number right
\end_layout

\begin_layout Itemize
Syntax: number bit.rrotate(number base[, number amount[, number bits]])
\end_layout

\begin_layout Standard
Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
 1) places.
\end_layout

\begin_layout Subsection
bit.lshift: Shift a number left
\end_layout

\begin_layout Itemize
Syntax: number bit.lshift(number base[, number amount[, number bits]])
\end_layout

\begin_layout Standard
Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
 1) places.
 The new bits are filled with zeroes.
\end_layout

\begin_layout Subsection
bit.lrshift: Shift a number right (logical)
\end_layout

\begin_layout Itemize
Syntax: number bit.lrshift(number base[, number amount[, number bits]])
\end_layout

\begin_layout Standard
Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
 (default 1) places.
 The new bits are filled with zeroes.
\end_layout

\begin_layout Subsection
bit.arshift: Shift a number right (arithmetic)
\end_layout

\begin_layout Itemize
Syntax: number bit.arshift(number base[, number amount[, number bits]])
\end_layout

\begin_layout Standard
Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
 (default 1) places.
 The new bits are shifted in with copy of the high bit.
\end_layout

\begin_layout Subsection
bit.extract: Extract/shuffle bits from number
\end_layout

\begin_layout Itemize
Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
\end_layout

\begin_layout Standard
Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
\end_layout

\begin_layout Itemize
Note: Bit numbers up to 51 should work reliably (then things start falling
 apart due to double precision issues).
\end_layout

\begin_layout Itemize
Note: There are two special bit positions, true and false, standing for
 always set bit and always clear bit.
\end_layout

\begin_layout Subsection
bit.value: Construct number with specified bits set
\end_layout

\begin_layout Itemize
Syntax: number bit.value([number bit1[, number bit2,...]])
\end_layout

\begin_layout Standard
Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
 <bit2> places and so on.
 As special value, nil argument is no-op.
\end_layout

\begin_layout Subsection
bit.test: Test if bit is set
\end_layout

\begin_layout Itemize
Syntax: boolean bit.test(number a, number bit)
\end_layout

\begin_layout Standard
Tests if bit <bit> is set in <a>.
 If it is set, returns true, otherwise false.
\end_layout

\begin_layout Subsection
bit.testn: Test if bit is clear
\end_layout

\begin_layout Itemize
Syntax: boolean bit.testn(number a, number bit)
\end_layout

\begin_layout Standard
Tests if bit <bit> is set in <a>.
 If it is clear, returns true, otherwise false.
\end_layout

\begin_layout Subsection
bit.test_any: Test if any bit is set
\end_layout

\begin_layout Itemize
Syntax: boolean bit.test_any(number a, number b)
\end_layout

\begin_layout Standard
Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
\end_layout

\begin_layout Subsection
bit.test_all: Test if all bits are set
\end_layout

\begin_layout Itemize
Syntax: boolean bit.test_all(number a, number b)
\end_layout

\begin_layout Standard
Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
\end_layout

\begin_layout Subsection
bit.popcount: Population count
\end_layout

\begin_layout Itemize
Syntax: number bit.popcount(number a)
\end_layout

\begin_layout Standard
Returns number of set bits in <a>.
\end_layout

\begin_layout Subsection
bit.clshift: Chained left shift
\end_layout

\begin_layout Itemize
Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
 bits]])
\end_layout

\begin_layout Standard
Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
 numbers to be of specified number of bits <bits> (default 48).
\end_layout

\begin_layout Subsection
bit.crshift: Chained right shift
\end_layout

\begin_layout Itemize
Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
 bits]])
\end_layout

\begin_layout Standard
Does chained right shift on <a>, <b> by <amount> positions (default 1),
 assuming numbers to be of specified number of bits <bits> (default 48).
\end_layout

\begin_layout Subsection
bit.flagdecode: Decode bitfield into flags
\end_layout

\begin_layout Itemize
Syntax: string bit.flagdecode(number a, number bits, [string on, [string
 off]])
\end_layout

\begin_layout Standard
Return string of length bits where ith character is ith character of on
 if bit i is on, otherwise ith character of off.
 Out of range reads give last character.
\end_layout

\begin_layout Itemize
Note: <on> defaults to '*' if empty.
\end_layout

\begin_layout Itemize
Note: <off> defaults to '-' if empty.
\end_layout

\begin_layout Subsection
bit.rflagdecode: Decode bitfield into flags
\end_layout

\begin_layout Itemize
Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
 off]])
\end_layout

\begin_layout Standard
Like bit.flagdecode, but outputs the string in the opposite order (most significa
nt bit first).
\end_layout

\begin_layout Subsection
bit.swap{,s}{,h,d,q}word: Swap word endian
\end_layout

\begin_layout Itemize
Syntax: number bit.swapword(number n)
\end_layout

\begin_layout Itemize
Syntax: number bit.swaphword(number n)
\end_layout

\begin_layout Itemize
Syntax: number bit.swapdword(number n)
\end_layout

\begin_layout Itemize
Syntax: number bit.swapqword(number n)
\end_layout

\begin_layout Itemize
Syntax: number bit.swapsword(number n)
\end_layout

\begin_layout Itemize
Syntax: number bit.swapshword(number n)
\end_layout

\begin_layout Itemize
Syntax: number bit.swapsdword(number n)
\end_layout

\begin_layout Itemize
Syntax: number bit.swapsqword(number n)
\end_layout

\begin_layout Standard
Swap endianess of (un)signed integer <n>.
\end_layout

\begin_layout Subsection
bit.compose: Compose multi-byte number
\end_layout

\begin_layout Itemize
Syntax: number bit.compose(number n...)
\end_layout

\begin_layout Standard
Return 
\begin_inset Formula $n_{1}+256n_{2}+256^{2}n_{3}+\ldots$
\end_inset


\end_layout

\begin_layout Subsection
bit.binary_ld_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Load binary integer
\end_layout

\begin_layout Itemize
Syntax: number bit.binary_ld_<type>le(string str, number pos);
\end_layout

\begin_layout Itemize
Syntax: number bit.binary_ld_<type>be(string str, number pos);
\end_layout

\begin_layout Standard
Load little (*le) or big (*be) endian binary number from position <pos>
 of string <str>.
 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
 double.
\end_layout

\begin_layout Subsection
bit.binary_st_{{u,s}{8,16,24,32,64},float,double}{l,b}e: Store binary integer
\end_layout

\begin_layout Itemize
Syntax: string bit.binary_st_<type>le(number x);
\end_layout

\begin_layout Itemize
Syntax: string bit.binary_st_<type>be(number x);
\end_layout

\begin_layout Standard
Store specified number <x> as binary in string and return the result.
 Type may be one of: u8, u16, u24, u32, u64, s8, s16, s24, s32, s64, float,
 double.
\end_layout

\begin_layout Subsection
bit.quotent: Integer quotent
\end_layout

\begin_layout Itemize
Syntax: number bit.quotent(number a, number b)
\end_layout

\begin_layout Standard
Calculate quotent a/b.
\end_layout

\begin_layout Subsection
bit.multidiv: Divide and split among multiple divisiors
\end_layout

\begin_layout Itemize
Syntax: number...
 bit.multidiv(number v, number q...)
\end_layout

\begin_layout Standard
Does the following steps:
\end_layout

\begin_layout Enumerate
Set v' to <v>.
\end_layout

\begin_layout Enumerate
For each <q> q:
\end_layout

\begin_deeper
\begin_layout Enumerate
Calculate quotent(v'/q) and add that to numbers returned.
\end_layout

\begin_layout Enumerate
v' <- remainder(v'/q)
\end_layout

\end_deeper
\begin_layout Enumerate
Add v' to numbers returned.
\end_layout

\begin_layout Standard
That is, it successively divides <v> by <q>s, and reduces <v> modulo <q>
 at each step.
 <v> may be floating point, <q>s are integers.
\end_layout

\begin_layout Itemize
E.g.
 bit.multidiv(time, 3600, 60) splits time into hours, minutes and seconds.
\end_layout

\begin_layout Itemize
E.g.
 bit.multidiv(a, b) calculates quotent and remainder of a/b.
\end_layout

\begin_layout Subsection
bit.mul32: 32-bit multiply
\end_layout

\begin_layout Itemize
Syntax: number, number bit.mul32(number a, number b)
\end_layout

\begin_layout Standard
Multiply 32-bit numbers <a> and <b>.
 The first return value is low 32 bits of result, the second is high 32
 bits.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table classes:
\end_layout

\begin_layout Subsection
classes.<foo>: The classobj for class <foo>
\end_layout

\begin_layout Itemize
Syntax: classes.<foo>
\end_layout

\begin_layout Standard
The classobj for class <foo>.
\end_layout

\begin_layout Subsection
classes.<foo>._static_methods: Enumerate static methods
\end_layout

\begin_layout Itemize
Syntax: string...
 classes.<foo>._static_methods()
\end_layout

\begin_layout Standard
Returns all static methods of <foo> as strings.
\end_layout

\begin_layout Subsection
classes.<foo>._class_methods: Enumerate static methods
\end_layout

\begin_layout Itemize
Syntax: string...
 classes.<foo>._class_methods()
\end_layout

\begin_layout Standard
Returns all class methods of <foo> as strings.
\end_layout

\begin_layout Subsection
classes.<foo>.<bar>: Static method
\end_layout

\begin_layout Itemize
Syntax: variable classes.<foo>.<bar>(variable...)
\end_layout

\begin_layout Standard
Invokes static method <bar> of class <foo>.
\end_layout

\begin_layout Section
Table gui:
\end_layout

\begin_layout Subsection
gui.resolution: Get current resolution
\end_layout

\begin_layout Itemize
Syntax: (number, number) gui.resolution()
\end_layout

\begin_layout Standard
Returns 2-tuple (hresolution, vresolution).
\end_layout

\begin_layout Subsection
gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
\end_layout

\begin_layout Itemize
Syntax: number gui.left_gap(number gap)
\end_layout

\begin_layout Itemize
Syntax: number gui.right_gap(number gap)
\end_layout

\begin_layout Itemize
Syntax: number gui.top_gap(number gap)
\end_layout

\begin_layout Itemize
Syntax: number gui.bottom_gap(number gap)
\end_layout

\begin_layout Standard
Set the specified edge gap to specified value <gap> (max gap is 8191).
 If successful, old gap is returned.
\end_layout

\begin_layout Subsection
gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
 Adjust edge gaps
\end_layout

\begin_layout Itemize
Syntax: number gui.delta_left_gap(number dgap)
\end_layout

\begin_layout Itemize
Syntax: number gui.delta_right_gap(number dgap)
\end_layout

\begin_layout Itemize
Syntax: number gui.delta_top_gap(number dgap)
\end_layout

\begin_layout Itemize
Syntax: number gui.delta_bottom_gap(number dgap)
\end_layout

\begin_layout Standard
Increase the specified edge gap by specified value <dgap> (max gap is 8191)
 and return the old gap (returns nothing on error).
\end_layout

\begin_layout Subsection
gui.text/gui.textH/gui.textV,gui.textHV: Draw text
\end_layout

\begin_layout Itemize
Syntax: none gui.text(number x, number y, string text[, number fgc[, number
 bgc]])
\end_layout

\begin_layout Itemize
Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
 bgc]])
\end_layout

\begin_layout Itemize
Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
 bgc]])
\end_layout

\begin_layout Itemize
Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
 bgc]])
\end_layout

\begin_layout Standard
Draw specified text on the GUI (each character cell is 8 or 16 wide and
 16 high).
 Parameters:
\end_layout

\begin_layout Itemize
x: X-coordinate to start the drawing from (and x-coordinate at begining
 of the lines).
\end_layout

\begin_layout Itemize
y: Y-coordinate to start the drawing from.
\end_layout

\begin_layout Itemize
text: The text to draw.
\end_layout

\begin_layout Itemize
fgc: Text color (default is 0xFFFFFF (white))
\end_layout

\begin_layout Itemize
bgc: Background color (default is -1 (transparent))
\end_layout

\begin_layout Standard
Note: The H variants draw at double width and V variants draw at double
 height.
\end_layout

\begin_layout Subsection
gui.rectangle: Draw a rectangle
\end_layout

\begin_layout Itemize
Syntax: none gui.rectangle(number x, number y, number width, number height[,
 number thickness[, number outline[, number fill]]])
\end_layout

\begin_layout Standard
Draw rectangle on the GUI.
 Parameters:
\end_layout

\begin_layout Itemize
x: X-coordinate of left edge.
\end_layout

\begin_layout Itemize
y: Y-coordinate of upper edge.
\end_layout

\begin_layout Itemize
width: Width of rectangle.
\end_layout

\begin_layout Itemize
height: Height of rectangle.
\end_layout

\begin_layout Itemize
thickness: Thickness of outline (default is 1).
\end_layout

\begin_layout Itemize
outline: Color of outline (default is 0xFFFFFF (white))
\end_layout

\begin_layout Itemize
fill: Color of fill (default is -1 (transparent))
\end_layout

\begin_layout Subsection
gui.solidrectangle: Draw a solid rectangle
\end_layout

\begin_layout Itemize
Syntax: none gui.rectangle(number x, number y, number width, number height[,
 number color])
\end_layout

\begin_layout Standard
Draw solid rectangle on the GUI.
 Parameters:
\end_layout

\begin_layout Itemize
x: X-coordinate of left edge.
\end_layout

\begin_layout Itemize
y: Y-coordinate of upper edge.
\end_layout

\begin_layout Itemize
width: Width of rectangle.
\end_layout

\begin_layout Itemize
height: Height of rectangle.
\end_layout

\begin_layout Itemize
color: Color of rectangle (default is 0xFFFFFF (white))
\end_layout

\begin_layout Subsection
gui.box: Draw a 3D-effect box
\end_layout

\begin_layout Itemize
Syntax: none gui.box(number x, number y, number width, number height[, number
 thickness[, number outline1[,number outline2[, number fill]]]])
\end_layout

\begin_layout Standard
Draw rectangle with 3D effect on the GUI.
 Parameters:
\end_layout

\begin_layout Itemize
x: X-coordinate of left edge.
\end_layout

\begin_layout Itemize
y: Y-coordinate of upper edge.
\end_layout

\begin_layout Itemize
width: Width of rectangle.
\end_layout

\begin_layout Itemize
height: Height of rectangle.
\end_layout

\begin_layout Itemize
thickness: Thickness of outline (default is 1).
\end_layout

\begin_layout Itemize
outline1: First color of outline (default is 0xFFFFFF (white))
\end_layout

\begin_layout Itemize
outline2: First color of outline (default is 0x808080 (dark gray))
\end_layout

\begin_layout Itemize
fill: Color of fill (default is 0xC0C0C0 (light grayy))
\end_layout

\begin_layout Subsection
gui.pixel: Draw a single pixel
\end_layout

\begin_layout Itemize
Syntax: none gui.pixel(number x, number y[, number color])
\end_layout

\begin_layout Standard
Draw one pixel on the GUI.
 Parameters:
\end_layout

\begin_layout Itemize
x: X-coordinate of the pixel
\end_layout

\begin_layout Itemize
y: Y-coordinate of the pixel
\end_layout

\begin_layout Itemize
color: Color of the pixel (default is 0xFFFFFF (white))
\end_layout

\begin_layout Subsection
gui.crosshair: Draw a crosshair
\end_layout

\begin_layout Itemize
Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
\end_layout

\begin_layout Standard
Draw a crosshair.
 Parameters:
\end_layout

\begin_layout Itemize
x: X-coordinate of the crosshair
\end_layout

\begin_layout Itemize
y: Y-coordinate of the crosshair
\end_layout

\begin_layout Itemize
length: Length of the crosshair lines (default 10).
\end_layout

\begin_layout Itemize
color: Color of the crosshair (default is 0xFFFFFF (white))
\end_layout

\begin_layout Subsection
gui.line: Draw a line
\end_layout

\begin_layout Itemize
Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
 color])
\end_layout

\begin_layout Standard
Draw a thin line.
 Parameters:
\end_layout

\begin_layout Itemize
x1: X-coordinate of one end.
\end_layout

\begin_layout Itemize
y1: Y-coordinate of one end.
\end_layout

\begin_layout Itemize
x2: X-coordinate of the other end.
\end_layout

\begin_layout Itemize
y2: Y-coordinate of the other end.
\end_layout

\begin_layout Itemize
color: Color of the line (default is 0xFFFFFF (white)).
\end_layout

\begin_layout Subsection
gui.circle: Draw a (filled) circle
\end_layout

\begin_layout Itemize
Syntax: none gui.circle(number x, number y, number r[, number thick[, number
 border[, number fil]]])
\end_layout

\begin_layout Standard
Draw a circle.
 Parameters.
\end_layout

\begin_layout Itemize
x: X-coordinate of the center
\end_layout

\begin_layout Itemize
y: Y-coordinate of the center
\end_layout

\begin_layout Itemize
r: The radius of the circle
\end_layout

\begin_layout Itemize
thick: Border thickness
\end_layout

\begin_layout Itemize
border: Border color (default is 0xFFFFFF (white))
\end_layout

\begin_layout Itemize
fill: Fill color (default is -1 (transparent)).
\end_layout

\begin_layout Subsection
gui.repaint: Arrange a repaint
\end_layout

\begin_layout Itemize
Syntax: none gui.repaint()
\end_layout

\begin_layout Standard
Request on_repaint() to happen as soon as possible.
\end_layout

\begin_layout Subsection
gui.subframe_update: Enable/Disable subframe updates
\end_layout

\begin_layout Itemize
Syntax: none gui.subframe_update(boolean on)
\end_layout

\begin_layout Standard
Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
 or not happen (<on>=false).
\end_layout

\begin_layout Subsection
gui.screenshot: Write a screenshot
\end_layout

\begin_layout Itemize
Syntax: none gui.screenshot(string filename)
\end_layout

\begin_layout Standard
Write PNG screenshot of the current frame (no drawings) to specified file
 <filename>.
\end_layout

\begin_layout Subsection
gui.screenshot_bitmap: Write a screenshot to bitmap
\end_layout

\begin_layout Itemize
Syntax: DBITMAP gui.screenshot_bitmap()
\end_layout

\begin_layout Standard
Write PNG screenshot of the current frame (no drawings) to dbitmap and return
 the result.
\end_layout

\begin_layout Subsection
gui.color: Compose a color.
\end_layout

\begin_layout Itemize
Syntax: number gui.color(number r, number g, number b[, number a])
\end_layout

\begin_layout Itemize
Syntax: number gui.color(string c)
\end_layout

\begin_layout Standard
Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
, each component in scale 0-255.
 If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
 fully opaque).
 The default alpha is 256.
\end_layout

\begin_layout Standard
The form taking a string returns color corresponding color name.
\end_layout

\begin_layout Subsection
gui.status: Set status variable
\end_layout

\begin_layout Itemize
Syntax: none gui.status(string name, string value)
\end_layout

\begin_layout Standard
Set status field 
\begin_inset Quotes eld
\end_inset

L[<name>]
\begin_inset Quotes erd
\end_inset

 to <value> in status area.
\end_layout

\begin_layout Subsection
gui.rainbow: Rainbow color calculation
\end_layout

\begin_layout Itemize
Syntax: number gui.rainbow(number step, number steps[, number color])
\end_layout

\begin_layout Standard
Perform hue rotation of color <color> (default bright red), by <step> steps.
 The number of steps per full rotation is given by absolute value of <steps>.
\end_layout

\begin_layout Standard
If <step> is negative, the rotation will be counterclockwise.
\end_layout

\begin_layout Subsection
gui.kill_frame: Kill video frame and associated sound
\end_layout

\begin_layout Itemize
Syntax: none gui.kill_frame()
\end_layout

\begin_layout Standard
Kills the currently dumped video frame + the associated sound.
 Only valid in on_video callback.
\end_layout

\begin_layout Subsection
gui.set_video_scale: Set video frame scale
\end_layout

\begin_layout Itemize
Syntax: none gui.set_video_scale(number h, number v)
\end_layout

\begin_layout Standard
Sets the scale factors of current frame to <h>x<v>.
 Only valid in on_video callback.
\end_layout

\begin_layout Subsection
gui.arrow: Draw an arrow
\end_layout

\begin_layout Itemize
Syntax: none gui.arrow(number x, number y, number length, number hwidth,
 number direction[, bool fill[, number color[, number twidth[, number hthick]]]]
)
\end_layout

\begin_layout Standard
Draws an arrow using color <color>.
 The tip of arrow is at (<x>, <y>).
 Other parameters:
\end_layout

\begin_layout Enumerate
<length>: The length of arrow tail.
\end_layout

\begin_layout Enumerate
<hwidth>: The width of arrow head.
 Should be odd.
\end_layout

\begin_layout Enumerate
<direction>: Direction of arrow.
 0 is to right, +1 rotates 45 degrees counterclockwise.
\end_layout

\begin_layout Enumerate
<fill>: If true, fill the arrow head.
 Default false.
\end_layout

\begin_layout Enumerate
<twidth>: Tail width.
 Should be odd.
 Default 1.
\end_layout

\begin_layout Enumerate
<hthick>: Head thickness (only used if <fill> is false).
 Default is <twidth>.
\end_layout

\begin_layout Subsection
gui.tiled_bitmap: Class TILEMAP
\end_layout

\begin_layout Standard
See class TILEMAP.
\end_layout

\begin_layout Subsection
gui.palette: Class PALETTE
\end_layout

\begin_layout Standard
See class PALETTE.
\end_layout

\begin_layout Subsection
gui.bitmap: Class BITMAP
\end_layout

\begin_layout Standard
See class BITMAP.
\end_layout

\begin_layout Subsection
gui.dbitmap: Class DBITMAP
\end_layout

\begin_layout Standard
See class DBITMAP.
\end_layout

\begin_layout Subsection
gui.font: Class CUSTOMFONT
\end_layout

\begin_layout Standard
See class CUSTOMFONT.
\end_layout

\begin_layout Subsection
gui.renderctx: Class RENDERCTX
\end_layout

\begin_layout Standard
See class RENDERCTX.
\end_layout

\begin_layout Subsection
gui.image: Class IMAGELOADER
\end_layout

\begin_layout Standard
See class IMAGELOADER.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
table input
\end_layout

\begin_layout Standard
Input handling.
 Functions manipulating input are only available in on_input callback.
\end_layout

\begin_layout Subsection
input.get: Read controller button/axis (deprecated)
\end_layout

\begin_layout Itemize
Syntax: number input.get(number controller, number index)
\end_layout

\begin_layout Standard
Read the specified index <index> (zero-based) from specified controller
 <controller> (zero-based).
 
\end_layout

\begin_layout Subsection
input.set: Write controller button/axis (deprecated)
\end_layout

\begin_layout Itemize
Syntax: none input.set(number controller, number index, number value)
\end_layout

\begin_layout Standard
Write the specified index <index> (zero-based) from specified controller
 <controller> (zero-based), storing value <value>.
\end_layout

\begin_layout Subsection
input.get2: Read controller button/axis
\end_layout

\begin_layout Itemize
Syntax: number input.get2(number port, number controller, number index)
\end_layout

\begin_layout Standard
Read the specified input tuple.
 Port 0 is system port.
\end_layout

\begin_layout Subsection
input.set2: Write controller button/axis
\end_layout

\begin_layout Itemize
Syntax: input.set2(number port, number controller, number index, number value)
\end_layout

\begin_layout Standard
Write the specified input tuple.
 Port 0 is system port.
\end_layout

\begin_layout Subsection
input.lcid_to_pcid2: Look up logical controller
\end_layout

\begin_layout Itemize
Syntax: (number, number) input.lcid_to_pcid2(number lcid)
\end_layout

\begin_layout Standard
Look up physical pcid pair (port, controller) corresponding to specified
 logical controller (1-based).
 Returns nothing if controller does not exist.
\end_layout

\begin_layout Subsection
input.port_type: Look up port type
\end_layout

\begin_layout Itemize
Syntax: string input.port_type(number port)
\end_layout

\begin_layout Standard
Return type of specified port.
\end_layout

\begin_layout Subsection
input.controller_info: Get information about controller
\end_layout

\begin_layout Itemize
Syntax: table input.controller_info(number port, number controller)
\end_layout

\begin_layout Standard
Get controller info for specified controller.
 If controller does not exist, returns nil.
 Otherwise returns a table with following fields:
\end_layout

\begin_layout Itemize
type (string): Type of the controller.
\end_layout

\begin_layout Itemize
class (string): Class of the controller.
\end_layout

\begin_layout Itemize
classnum (number): Number of the controller within its class (1-based)
\end_layout

\begin_layout Itemize
lcid (number): Logical controller number of the controller.
\end_layout

\begin_layout Itemize
button_count (number): Number of buttons on controller
\end_layout

\begin_layout Itemize
buttons (array): Array of following info about each button:
\end_layout

\begin_deeper
\begin_layout Itemize
type (string): Type of button.
 Currently one of 
\begin_inset Quotes eld
\end_inset

null
\begin_inset Quotes erd
\end_inset

, 
\begin_inset Quotes eld
\end_inset

button
\begin_inset Quotes erd
\end_inset

, 
\begin_inset Quotes eld
\end_inset

axis
\begin_inset Quotes erd
\end_inset

, 
\begin_inset Quotes eld
\end_inset

raxis
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Itemize
name (string): Name of button.
\end_layout

\begin_layout Itemize
symbol (string): Symbol of button.
 Only present for type 
\begin_inset Quotes eld
\end_inset

button
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Itemize
hidden (boolean): True if hidden button.
 
\end_layout

\end_deeper
\begin_layout Subsection
input.veto_button: Veto a button press
\end_layout

\begin_layout Itemize
Syntax: none input.veto_button()
\end_layout

\begin_layout Standard
Signals that the button event should be vetoed.
 Only valid in on_button callback.
\end_layout

\begin_layout Subsection
input.geta: Get all buttons for controller (deprecated)
\end_layout

\begin_layout Itemize
Syntax: (number, number...) input.geta(number controller)
\end_layout

\begin_layout Standard
Get input state for entiere controller.
 Returns n return values.
\end_layout

\begin_layout Itemize
1st return value: Bitmask: bit i is set if i:th index is nonzero
\end_layout

\begin_layout Itemize
2nd- return value: value of i:th index.
\end_layout

\begin_layout Subsection
input.seta: Set all buttons for controller (deprecated)
\end_layout

\begin_layout Itemize
Syntax: none input.seta(number controller, number bitmask, number args...)
\end_layout

\begin_layout Standard
Set state for entiere controller.
 args is up to N values for indices (overriding values in bitmask if specified).
\end_layout

\begin_layout Subsection
input.controllertype: Get controller type (deprecated)
\end_layout

\begin_layout Itemize
syntax: string input.controllertype(number controller)
\end_layout

\begin_layout Standard
Get the type of controller as string.
\end_layout

\begin_layout Subsection
input.reset: Execute (delayed) reset
\end_layout

\begin_layout Itemize
Syntax: none input.reset([number cycles])
\end_layout

\begin_layout Standard
Execute reset.
 If <cycles> is greater than zero, do delayed reset.
 0 (or no value) causes immediate reset.
\end_layout

\begin_layout Itemize
Note: Only available with subframe flag false.
\end_layout

\begin_layout Subsection
input.raw: Return raw input data
\end_layout

\begin_layout Itemize
Syntax: table input.raw()
\end_layout

\begin_layout Standard
Returns table of tables of all available keys and axes.
 The first table is indexed by key name (platform-dependent!), and the inner
 table has the following fields:
\end_layout

\begin_layout Itemize
value: Last reported value for control
\end_layout

\begin_deeper
\begin_layout Itemize
For keys: 1 for pressed, 0 for released.
\end_layout

\begin_layout Itemize
For axes: -32767...32767.
\end_layout

\begin_layout Itemize
For presure-sensitive buttons: 0...32767.
\end_layout

\begin_layout Itemize
For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
\end_layout

\begin_layout Itemize
For mouse: Coordinates relative to game area.
\end_layout

\end_deeper
\begin_layout Itemize
ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
\end_layout

\begin_layout Subsection
input.keyhook: Hook a key
\end_layout

\begin_layout Itemize
Syntax: none input.keyhook(string key, boolean state)
\end_layout

\begin_layout Standard
Requests that keyhook events to be sent for key <key> (<state>=true) or
 not sent (<state>=false).
\end_layout

\begin_layout Subsection
input.joyget: Get controls for controller
\end_layout

\begin_layout Itemize
Syntax: table input.joyget(number logical)
\end_layout

\begin_layout Standard
Returns table for current controls for specified logical controller <logical>.
 The names of fields vary by controller type.
\end_layout

\begin_layout Itemize
The buttons have the same name as those are referred to in other contexts
 in the emulator
\end_layout

\begin_layout Itemize
The analog axes are usually 
\begin_inset Quotes eld
\end_inset

xaxis
\begin_inset Quotes erd
\end_inset

 and 
\begin_inset Quotes eld
\end_inset

yaxis
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Itemize
Each field is numeric or boolean depending on axis/button.
\end_layout

\begin_layout Subsection
input.joyset: Set controls for controller
\end_layout

\begin_layout Itemize
Syntax: none input.joyset(number controller, table controls)
\end_layout

\begin_layout Standard
Set the the state of specified controller to values specified in specified
 table.
\end_layout

\begin_layout Itemize
Each field can be boolean or number.
\end_layout

\begin_layout Itemize
Also, buttons allow strings, which cause value to be inverted.
\end_layout

\begin_layout Subsection
input.lcid_to_pcid: Look up logical controller (deprecated)
\end_layout

\begin_layout Itemize
Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
\end_layout

\begin_layout Standard
Returns the legacy pcid for controller (or false if there isn't one), followed
 by pcid pair.
 Returns nothing if controller does not exist.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table keyboard
\end_layout

\begin_layout Standard
Various keybinding-related functions
\end_layout

\begin_layout Subsection
keyboard.bind: Bind a key
\end_layout

\begin_layout Itemize
Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
\end_layout

\begin_layout Standard
Bind specified key with specified modifers to specified command.
\end_layout

\begin_layout Subsection
keyboard.unbind: Unbind a key
\end_layout

\begin_layout Itemize
Syntax: none keyboard.unbind(string mod, string mask, string key)
\end_layout

\begin_layout Standard
Unbind specified key with specified modifers.
\end_layout

\begin_layout Subsection
keyboard.alias: Set alias expansion
\end_layout

\begin_layout Itemize
Syntax: none keyboard.alias(string alias, string expansion)
\end_layout

\begin_layout Standard
Set expansion of given command.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table subtitle
\end_layout

\begin_layout Standard
Subtitle handling
\end_layout

\begin_layout Subsection
subtitle.byindex: Look up start and length of subtitle by index
\end_layout

\begin_layout Itemize
Syntax: (number, number) subtitle.byindex(number i)
\end_layout

\begin_layout Standard
Read the frame and length of ith subtitle.
 Returns nothing if not present.
\end_layout

\begin_layout Subsection
subtitle.set: Write a subtitle
\end_layout

\begin_layout Itemize
Syntax: none subtitle.set(number f, number l, string txt)
\end_layout

\begin_layout Standard
Set the text of subtitle.
\end_layout

\begin_layout Subsection
subtitle.get: Read a subtitle
\end_layout

\begin_layout Itemize
Syntax: string subtitle.get(number f, number l)
\end_layout

\begin_layout Standard
Get the text of subtitle.
\end_layout

\begin_layout Subsection
subtitle.delete: Delete a subtitle
\end_layout

\begin_layout Itemize
Syntax: none subtitle.delete(number f, number l)
\end_layout

\begin_layout Standard
Delete specified subtitle.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table hostmemory
\end_layout

\begin_layout Standard
Host memory handling (extra memory saved to savestates).
 Host memory starts empty.
\end_layout

\begin_layout Itemize
Reads out of range return false.
\end_layout

\begin_layout Itemize
Writes out of range extend the memory.
\end_layout

\begin_layout Subsection
hostmemory.read: Read byte from host memory
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.read(number address)
\end_layout

\begin_layout Standard
Reads byte from hostmemory slot address <address>.
\end_layout

\begin_layout Subsection
hostmemory.write: Write byte to host memory
\end_layout

\begin_layout Itemize
Syntax: none hostmemory.write(number address, number value)
\end_layout

\begin_layout Standard
Writes hostmemory slot with value <value> 0-255.
\end_layout

\begin_layout Subsection
hostmemory.read{,s}{byte,{,h,d,q}word}: Read from host memory
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readbyte(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readsbyte(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readword(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readsword(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readhword(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readshword(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readdword(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readsdword(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readqword(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readsqword(number address)
\end_layout

\begin_layout Standard
Read elements (big-endian) from given address <address>.
\end_layout

\begin_layout Itemize
byte is 1 element
\end_layout

\begin_layout Itemize
word is 2 elements
\end_layout

\begin_layout Itemize
hword is 3 elements
\end_layout

\begin_layout Itemize
dword is 4 elements
\end_layout

\begin_layout Itemize
qword is 8 elements.
\end_layout

\begin_layout Itemize
The 's' variants do signed read.
\end_layout

\begin_layout Subsection
hostmemory.read{float,double}: Read from host memory
\end_layout

\begin_layout Itemize
syntax: number hostmemory.readfloat(number address)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.readdouble(number address)
\end_layout

\begin_layout Standard
Read elements (big-endian) floating-pont from given address <address>.
\end_layout

\begin_layout Subsection
hostmemory.write{,s}{byte,{,h,d,q}word}: Write to host memory
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writebyte(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writesbyte(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writeword(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writesword(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writehword(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writeshword(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writedword(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writesdword(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writeqword(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: number hostmemory.writesqword(number address, number value)
\end_layout

\begin_layout Standard
Write value <value> to elements (little-endian) starting from given address
 <address>.
\end_layout

\begin_layout Itemize
byte is 1 element
\end_layout

\begin_layout Itemize
word is 2 elements
\end_layout

\begin_layout Itemize
hword is 3 elements
\end_layout

\begin_layout Itemize
dword is 4 elements
\end_layout

\begin_layout Itemize
qword is 8 elements.
\end_layout

\begin_layout Itemize
The 's' variants do signed write.
\end_layout

\begin_layout Subsection
hostmemory.write{float,double}: Write to host memory
\end_layout

\begin_layout Itemize
syntax: none hostmemory.readfloat(number address, number value)
\end_layout

\begin_layout Itemize
Syntax: none hostmemory.readdouble(number address, number value)
\end_layout

\begin_layout Standard
Write elements (big-endian) floating-pont to given address <address>, storing
 <value>.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table movie
\end_layout

\begin_layout Standard
Movie handling
\end_layout

\begin_layout Subsection
movie.currentframe: Get current frame number
\end_layout

\begin_layout Itemize
Syntax: number movie.currentframe()
\end_layout

\begin_layout Standard
Return number of current frame.
\end_layout

\begin_layout Subsection
movie.framecount: Get move frame count
\end_layout

\begin_layout Itemize
Syntax: number movie.framecount()
\end_layout

\begin_layout Standard
Return number of frames in movie.
\end_layout

\begin_layout Subsection
movie.lagcount: Get current lag count
\end_layout

\begin_layout Itemize
Syntax: number movie.lagcount()
\end_layout

\begin_layout Standard
Return number of lag frames recorded so far.
\end_layout

\begin_layout Subsection
movie.readonly: Is in playback mode?
\end_layout

\begin_layout Itemize
Syntax: boolean movie.readonly()
\end_layout

\begin_layout Standard
Return true if in playback mode, false if in recording.
\end_layout

\begin_layout Subsection
movie.rerecords: Movie rerecord count
\end_layout

\begin_layout Itemize
Syntax: number movie.rerecords()
\end_layout

\begin_layout Standard
Returns the current value of rerecord count.
\end_layout

\begin_layout Subsection
movie.set_readwrite: Set recording mode.
\end_layout

\begin_layout Itemize
Syntax: none movie.set_readwrite()
\end_layout

\begin_layout Standard
Set recording mode (does not cause on_readwrite callback).
\end_layout

\begin_layout Subsection
movie.frame_subframes: Count subframes in frame
\end_layout

\begin_layout Itemize
Syntax: number movie.frame_subframes(number frame)
\end_layout

\begin_layout Standard
Count number of subframes in specified frame <frame> (frame numbers are
 1-based) and return that.
\end_layout

\begin_layout Subsection
movie.read_subframes: Read subframe data (deprecated)
\end_layout

\begin_layout Itemize
Syntax: table movie.read_subframes(number frame, number subframe)
\end_layout

\begin_layout Standard
Read specifed subframe in specified frame and return data as array.
\end_layout

\begin_layout Subsection
movie.read_rtc: Read current RTC time
\end_layout

\begin_layout Itemize
Syntax: (number, number) movie.read_rtc()
\end_layout

\begin_layout Standard
Returns the current value of the RTC as a pair (second, subsecond).
\end_layout

\begin_layout Subsection
movie.unsafe_rewind: Fast movie rewind to saved state
\end_layout

\begin_layout Itemize
Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
\end_layout

\begin_layout Standard
Start setting point for unsafe rewind or jump to point of unsafe rewind.
\end_layout

\begin_layout Itemize
If called without argument, causes emulator to start process of setting
 unsafe rewind point.
 When this has finished, callback on_set_rewind occurs, passing the rewind
 state to lua script.
\end_layout

\begin_layout Itemize
If called with argument, causes emulator rewind to passed rewind point as
 soon as possible.
 recording mode is implicitly activated.
\end_layout

\begin_layout Standard
The following warnings apply to unsafe rewinding:
\end_layout

\begin_layout Itemize
There are no safety checks against misuse (that's what 
\begin_inset Quotes eld
\end_inset

unsafe
\begin_inset Quotes erd
\end_inset

 comes from)!
\end_layout

\begin_layout Itemize
Only call rewind from timeline rewind point was set from.
\end_layout

\begin_layout Itemize
Only call rewind from after the rewind point was set.
\end_layout

\begin_layout Subsection
movie.to_rewind: Load savestate as rewind point
\end_layout

\begin_layout Itemize
Syntax: UNSAFEREWIND movie.to_rewind(string filename)
\end_layout

\begin_layout Standard
Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
 corresponding to it.
\end_layout

\begin_layout Itemize
Note: This operation does not take emulated time.
\end_layout

\begin_layout Subsection
movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
\end_layout

\begin_layout Itemize
Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE/string movie])
\end_layout

\begin_layout Itemize
Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
\end_layout

\begin_layout Standard
Copies specified movie or branch <movie>/current object (if none or nil,
 the active movie) as new movie object.
\end_layout

\begin_layout Subsection
movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
\end_layout

\begin_layout Itemize
Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE/string movie,] number frame)
\end_layout

\begin_layout Itemize
Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
\end_layout

\begin_layout Standard
Get INPUTFRAME object corresponding to specified frame in specified movie
 or branch.
\end_layout

\begin_layout Subsection
movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
\end_layout

\begin_layout Itemize
Syntax: none movie.set_frame([INPUTMOVIE/string movie,] number frame, INPUTFRAME
 data)
\end_layout

\begin_layout Itemize
Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
\end_layout

\begin_layout Standard
Set data in specified frame.
\end_layout

\begin_layout Itemize
Note: Past can't be edited in active movie.
\end_layout

\begin_layout Subsection
movie.get_size/INPUTMOVIE::get_size: Get size of movie
\end_layout

\begin_layout Itemize
Syntax: integer movie.get_size([INPUTMOVIE/string movie])
\end_layout

\begin_layout Itemize
Syntax: integer INPUTMOVIE::get_size()
\end_layout

\begin_layout Standard
Return number of subframes in specified movie or branch.
\end_layout

\begin_layout Subsection
movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
\end_layout

\begin_layout Itemize
Syntax: number movie.count_frames([INPUTMOVIE/string movie])
\end_layout

\begin_layout Itemize
Syntax: number INPUTMOVIE::count_frames()
\end_layout

\begin_layout Standard
Return number of frames in movie.
\end_layout

\begin_layout Subsection
movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
\end_layout

\begin_layout Itemize
Syntax: number movie.find_frame([INPUTMOVIE/string movie], number frame)
\end_layout

\begin_layout Itemize
Syntax: number INPUTMOVIE::find_frame(number frame)
\end_layout

\begin_layout Standard
Returns starting subframe of given frame (frame numbers are 1-based).
 Returns -1 if frame number is bad.
\end_layout

\begin_layout Subsection
movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
\end_layout

\begin_layout Itemize
Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE/string movie])
\end_layout

\begin_layout Itemize
Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
\end_layout

\begin_layout Standard
Return blank INPUTFRAME with frame type from specified movie.
\end_layout

\begin_layout Subsection
movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
\end_layout

\begin_layout Itemize
Syntax: none movie.append_frames([INPUTMOVIE/string movie,] number frames)
\end_layout

\begin_layout Itemize
Syntax: none INPUTMOVIE::append_frames(number frames)
\end_layout

\begin_layout Standard
Append specified number <frames> of frames.
\end_layout

\begin_layout Subsection
movie.append_frame/INPUTMOVIE::append_frame: Append a frame
\end_layout

\begin_layout Itemize
Syntax: none movie.append_frame([INPUTMOVIE/string movie,] INPUTFRAME frame)
\end_layout

\begin_layout Itemize
Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
\end_layout

\begin_layout Standard
Append specified frame <frame>.
 Past of current movie can't be edited.
\end_layout

\begin_layout Subsection
movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
\end_layout

\begin_layout Itemize
Syntax: none movie.truncate([INPUTMOVIE/string movie,] number frames)
\end_layout

\begin_layout Itemize
Syntax: none INPUTMOVIE::truncate(number frames)
\end_layout

\begin_layout Standard
Truncate the specified movie to specified number of frames.
\end_layout

\begin_layout Subsection
movie.edit/INPUTMOVIE::edit: Edit a movie
\end_layout

\begin_layout Itemize
Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
 controller, number control, number/bool value)
\end_layout

\begin_layout Itemize
Syntax: none movie.edit(string branch, number frame, number port, number
 controller, number control, number/bool value)
\end_layout

\begin_layout Itemize
Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
 number control, number/bool value)
\end_layout

\begin_layout Standard
Change specified control in specified frame in specified movie.
 Past can't be edited in active movie.
\end_layout

\begin_layout Subsection
movie.copy_frames2: Copy frames between movies
\end_layout

\begin_layout Itemize
Syntax: none movie.copy_frames2([INPUTMOVIE/string dstmov,] number dst, [INPUTMOV
IE/string srcmov,] number src, number count)
\end_layout

\begin_layout Standard
Copy specified number of frames between two movies.
 The copy proceeeds in forward direction.
\end_layout

\begin_layout Subsection
movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
\end_layout

\begin_layout Itemize
Syntax: none movie.copy_frames([INPUTMOVIE/string mov,] number dst, number
 src, number count, bool backwards)
\end_layout

\begin_layout Itemize
Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
 bool backwards)
\end_layout

\begin_layout Standard
Copy specified number of frames from one point in movie to another.
 If backwards is true, the copy will be done backwards.
\end_layout

\begin_layout Subsection
movie.serialize/INPUTMOVIE::serialize: Serialize movie
\end_layout

\begin_layout Itemize
Syntax: none movie.serialize([INPUTMOVIE movie/string,] string filename,
 bool binary)
\end_layout

\begin_layout Itemize
Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
\end_layout

\begin_layout Standard
Serialize given movie into file.
 If binary is true, binary format (more compact and much faster) is used.
\end_layout

\begin_layout Subsection
movie.unserialize: Unserialize movie
\end_layout

\begin_layout Itemize
Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
 bool binary)
\end_layout

\begin_layout Standard
Unserialize movie from file.
 The given frame is used as template to decide the frame type.
 If binary is true, binary format is decoded (much faster).
\end_layout

\begin_layout Subsection
movie.current_first_subframe: Return first subframe in current frame
\end_layout

\begin_layout Itemize
Syntax: number movie.current_first_subframe()
\end_layout

\begin_layout Standard
Returns first subframe in current frame.
\end_layout

\begin_layout Subsection
movie.pollcounter: Return poll counter for speified control
\end_layout

\begin_layout Itemize
Syntax: number movie.pollcounter(number port, number controller, number control)
\end_layout

\begin_layout Standard
Returns number of times the specified control has been polled this frame.
\end_layout

\begin_layout Subsection
movie.current_branch: Return current branch
\end_layout

\begin_layout Itemize
Syntax: string movie.current_branch()
\end_layout

\begin_layout Standard
Returns the name of the current branch.
\end_layout

\begin_layout Subsection
movie.get_branches: Return names of all branches
\end_layout

\begin_layout Itemize
Syntax: string...
 movie.get_branches()
\end_layout

\begin_layout Standard
Returns the name of all branches.
\end_layout

\begin_layout Subsection
INPUTFRAME::get_button: Get button
\end_layout

\begin_layout Itemize
Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
 control)
\end_layout

\begin_layout Standard
Returns state of given button as boolean.
\end_layout

\begin_layout Subsection
INPUTFRAME::get_axis: Get axis
\end_layout

\begin_layout Itemize
Syntax: number INPUTFRAME::get_axis(number port, number controller, number
 control)
\end_layout

\begin_layout Standard
Returns state of given axis as number.
\end_layout

\begin_layout Subsection
INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
\end_layout

\begin_layout Itemize
Syntax: none INPUTFRAME::set_button(number port, number controller, number
 control, number/bool value)
\end_layout

\begin_layout Itemize
Syntax: none INPUTFRAME::set_axis(number port, number controller, number
 control)
\end_layout

\begin_layout Standard
Set the given button/axis to given value.
\end_layout

\begin_layout Subsection
INPUTFRAME::serialize: Serialize a frame
\end_layout

\begin_layout Itemize
Syntax: string INPUTFRAME::serialize()
\end_layout

\begin_layout Standard
Return string representation of frame.
\end_layout

\begin_layout Subsection
INPUTFRAME::unserialize: Unserialize a frame
\end_layout

\begin_layout Itemize
Syntax: none INPUTFRAME::unserialize(string data)
\end_layout

\begin_layout Standard
Set current frame from given data.
\end_layout

\begin_layout Subsection
INPUTFRAME::get_stride: Get movie stride
\end_layout

\begin_layout Itemize
Syntax: number INPUTFRAME::get_stride()
\end_layout

\begin_layout Standard
Return number of bytes needed to store the input frame.
 Mainly useful for some debugging.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table settings
\end_layout

\begin_layout Standard
Routines for settings manipulation
\end_layout

\begin_layout Subsection
settings.get: Get value of setting
\end_layout

\begin_layout Itemize
Syntax: string settings.get(string name)
\end_layout

\begin_layout Standard
Get value of setting <name>.
 If setting value can't be obtained, returns (nil, error message).
\end_layout

\begin_layout Subsection
settings.set: Set value of setting
\end_layout

\begin_layout Itemize
Syntax: none settings.set(string name, string value)
\end_layout

\begin_layout Standard
Set value <value> of setting <name>.
 If setting can't be set, returns (nil, error message).
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table memory
\end_layout

\begin_layout Standard
Contains various functions for managing memory
\end_layout

\begin_layout Subsection
memory.vma_count: Count number of memory areas.
\end_layout

\begin_layout Itemize
Syntax: number memory.vma_count()
\end_layout

\begin_layout Standard
Returns the number of memory areas
\end_layout

\begin_layout Subsection
memory.read_vma: Lookup memory area info by index
\end_layout

\begin_layout Itemize
Syntax: table memory.read_vma(number index)
\end_layout

\begin_layout Standard
Reads the specified memory area (indices start from zero).
 Trying to read invalid memory area gives nil.
 The return value is table with the following fields:
\end_layout

\begin_layout Itemize
region_name (string): The readable name of the memory area
\end_layout

\begin_layout Itemize
baseaddr (number): Base address of the memory area
\end_layout

\begin_layout Itemize
lastaddr (number): Last address in the memory area.
\end_layout

\begin_layout Itemize
size (number): The size of memory area in bytes.
\end_layout

\begin_layout Itemize
readonly (boolean): True of the memory area corresponds to ROM.
\end_layout

\begin_layout Itemize
iospace (boolean): True if the memory area is I/O space.
\end_layout

\begin_layout Itemize
native_endian (boolean): True if the memory area has native endian as opposed
 to little endian.
\end_layout

\begin_layout Subsection
memory.find_vma: Find memory area info by address
\end_layout

\begin_layout Itemize
Syntax: table memory.find_vma(number address)
\end_layout

\begin_layout Standard
Finds the memory area containing specified address.
 Returns table in the same format as read_vma or nil if not found.
\end_layout

\begin_layout Subsection
memory.read{,s}{byte,{,h,d,q}word}: Read memory
\end_layout

\begin_layout Itemize
Syntax: none memory.readbyte({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readhword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readdword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readqword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readsbyte({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readsword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readshword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readsdword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readsqword({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Standard
Reads the specified address <address> (if 's' variant is used, do undergo
 2's complement).
\end_layout

\begin_layout Subsection
memory.{,s}read_sg: Scatter/Gather read memory
\end_layout

\begin_layout Itemize
Syntax: none memory.read_sg(string/boolean/number...)
\end_layout

\begin_layout Itemize
Syntax: none memory.sread_sg(string/boolean/number...)
\end_layout

\begin_layout Standard
Perform (2s complement signed if using memory.sread_sg) scatter/gather read
 of memory.
 Each argument can be string, boolean or number:
\end_layout

\begin_layout Itemize
String: Set memory area addresses are relative to (e.g.
 'WRAM').
\end_layout

\begin_layout Itemize
boolean: If true, increment relative address by 1, if false, decrement by
 1.
 The new address is read as next higher byte.
\end_layout

\begin_layout Itemize
integer: Set the relative address to specified value and read the address
 as next higher byte.
\end_layout

\begin_layout Subsection
memory.write_sg: Scatter/Gather write memory
\end_layout

\begin_layout Itemize
Syntax: none memory.write_sg(number value, string/boolean/number...)
\end_layout

\begin_layout Standard
Perform scatter/gather write of value <value> on memory.
 Each argument can be string, boolean or number:
\end_layout

\begin_layout Itemize
String: Set memory area addresses are relative to (e.g.
 'WRAM').
\end_layout

\begin_layout Itemize
boolean: If true, increment relative address by 1, if false, decrement by
 1.
 The new address is read as next higher byte.
\end_layout

\begin_layout Itemize
integer: Set the relative address to specified value and read the address
 as next higher byte.
\end_layout

\begin_layout Subsection
memory.read{float,double}: Read memory
\end_layout

\begin_layout Itemize
Syntax: none memory.readfloat({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Itemize
Syntax: none memory.readdouble({string marea, number address|ADDRESS addrobj})
\end_layout

\begin_layout Standard
Reads the specified address <address>
\end_layout

\begin_layout Subsection
memory.write{byte,{,h,d,q}word,float,double}: Write memory
\end_layout

\begin_layout Itemize
Syntax: none memory.writebyte({string marea, number address|ADDRESS addrobj},
 number value)
\end_layout

\begin_layout Itemize
Syntax: none memory.writeword({string marea, number address|ADDRESS addrobj},
 number value)
\end_layout

\begin_layout Itemize
Syntax: none memory.writehword({string marea, number address|ADDRESS addrobj},
 number value)
\end_layout

\begin_layout Itemize
Syntax: none memory.writedword({string marea, number address|ADDRESS addrobj},
 number value)
\end_layout

\begin_layout Itemize
Syntax: none memory.writeqword({string marea, number address|ADDRESS addrobj},
 number value)
\end_layout

\begin_layout Itemize
Syntax: none memory.writefloat({string marea, number address|ADDRESS addrobj},
 number value)
\end_layout

\begin_layout Itemize
Syntax: none memory.writedouble({string marea, number address|ADDRESS addrobj},
 number value)
\end_layout

\begin_layout Standard
Writes the specified value <value> (negative integer values undergo 2's
 complement) to specified address <address>.
\end_layout

\begin_layout Subsection
memory.map{{,s}{byte,{,h,d,q}word},float,double}: Map an array
\end_layout

\begin_layout Itemize
Syntax: userdata memory.map<type>({string marea, number base|ADDRESS addrobj},
 number size)
\end_layout

\begin_layout Standard
Returns a table mapping specified memory aperture for read/write.
\end_layout

\begin_layout Itemize
Type may be one of: byte, sbyte, word, sword, hword, shword, dword, sdword,
 qword, sqword, float or double.
\end_layout

\begin_layout Subsection
memory.hash_region: Hash region of memory
\end_layout

\begin_layout Itemize
Syntax: string memory.hash_region({string marea, number base|ADDRESS addrobj},
 number size)
\end_layout

\begin_layout Standard
Hash <size> bytes starting from address <base> (relative to <marea>) and
 return the SHA-256.
\end_layout

\begin_layout Subsection
memory.hash_region2: Hash region of memory
\end_layout

\begin_layout Itemize
Syntax: string memory.hash_region2({string marea, number base|ADDRESS addrobj},
 number size[, number rows, number stride])
\end_layout

\begin_layout Standard
Hash <rows> blocks of <size> bytes starting from address <base> (relative
 to <marea>).
 The blocks are offset by <stride> from one another and return the SHA-256.
\end_layout

\begin_layout Subsection
memory.hash_region_skein: Hash region of memory
\end_layout

\begin_layout Itemize
Syntax: string memory.hash_region_skein({string marea, number base|ADDRESS
 addrobj}, number size[, number rows, number stride])
\end_layout

\begin_layout Standard
Same as memory.hash_region2, but uses Skein-512-256 (v1.3; one of the SHA-3
 finalists) as hash function.
\end_layout

\begin_layout Subsection
memory.store: Store region of memory
\end_layout

\begin_layout Itemize
Syntax: none memory.store({string marea, number addr|ADDRESS addrobj}, number
 daddr[, number rows, number stride]
\end_layout

\begin_layout Standard
Copy memory starting from <addr> in memory area <marea> (each row being
 of size <size>, there being <rows> rows, and rows being separated by <stride>
 in memory) into savestate-saved memory area, starting from <daadr> (all
 rows are written back to back).
\end_layout

\begin_layout Subsection
memory.storecmp: Compare and store region of memory
\end_layout

\begin_layout Itemize
Syntax: bool memory.storecmp({string marea, number addr|ADDRESS addrobj},
 number daddr[, number rows, number stride]
\end_layout

\begin_layout Standard
Like memory.store, but returns true if target of copy already held the value
 that would be copied before the copy happened.
 Otherwise returns false (if target and source differ before copy).
\end_layout

\begin_layout Subsection
memory.hash_state: Hash system state
\end_layout

\begin_layout Itemize
Syntax: string memory.hash_state()
\end_layout

\begin_layout Standard
Hash the current system state.
 Mainly useful for debugging savestates.
\end_layout

\begin_layout Subsection
memory.readregion: Read region of memory
\end_layout

\begin_layout Itemize
Syntax: table memory.readregion({string marea, number base|ADDRESS addrobj},
 number size)
\end_layout

\begin_layout Standard
Read a region of memory.
\end_layout

\begin_layout Itemize
Warning: If the region crosses memory area boundary, the results are undefined.
\end_layout

\begin_layout Subsection
memory.writeregion: Write region of memory
\end_layout

\begin_layout Itemize
Syntax: none memory.writeregion({string marea, number base|ADDRESS addrobj},
 number size, table data)
\end_layout

\begin_layout Standard
Write a region of memory.
\end_layout

\begin_layout Itemize
Warning: If the region crosses memory area boundary, the results are undefined.
\end_layout

\begin_layout Subsection
memory.action: Run core action
\end_layout

\begin_layout Itemize
memory.action(string action, [<params>])
\end_layout

\begin_layout Standard
Run core action.
 The different models expect parameters as:
\end_layout

\begin_layout Itemize
string: String
\end_layout

\begin_layout Itemize
numeric: numeric
\end_layout

\begin_layout Itemize
enumeration: String
\end_layout

\begin_layout Itemize
boolean: String
\end_layout

\begin_layout Itemize
toggle: None.
\end_layout

\begin_layout Subsection
memory.action_flags: Get core action flags
\end_layout

\begin_layout Itemize
memory.action_flags(string action)
\end_layout

\begin_layout Standard
Get value of action flags for core action <action>.
\end_layout

\begin_layout Itemize
Bit 0: Enabled?
\end_layout

\begin_layout Itemize
Bit 1: Selected (not all actions can be selected)?
\end_layout

\begin_layout Subsection
memory.get_lag_flag: Get lag flag
\end_layout

\begin_layout Itemize
Syntax: boolean memory.get_lag_flag()
\end_layout

\begin_layout Standard
Get the value of core lag flag.
 True if this frame has been lag so far, false if poll has been detected.
\end_layout

\begin_layout Subsection
memory.set_lag_flag: Set lag flag
\end_layout

\begin_layout Itemize
Syntax: none memory.set_lag_flag(boolean flag)
\end_layout

\begin_layout Standard
Set the value of core lag flag.
 This flag automatically gets cleared if poll is detected, but can be forcibly
 set or cleared if game so requires.
\end_layout

\begin_layout Itemize
Should only be used in on_frame_emulated callback.
\end_layout

\begin_layout Itemize
Setting or clearing this affects the emulator lag counter.
\end_layout

\begin_layout Subsection
memory.{,un}register{read,write,exec}: (Un)Register read / write / execute
 callback
\end_layout

\begin_layout Itemize
Syntax: function memory.registerread({string marea, number addr|ADDRESS addrobj},
 function fn);
\end_layout

\begin_layout Itemize
Syntax: function memory.registerwrite({string marea, number addr|ADDRESS
 addrobj}, function fn);
\end_layout

\begin_layout Itemize
Syntax: function memory.registerexec({string marea, number addr|ADDRESS addrobj},
 function fn);
\end_layout

\begin_layout Itemize
Syntax: none memory.unregisterread({string marea, number addr|ADDRESS addrobj},
 function fn);
\end_layout

\begin_layout Itemize
Syntax: none memory.unregisterwrite({string marea, number addr|ADDRESS addrobj},
 function fn);
\end_layout

\begin_layout Itemize
Syntax: none memory.unregisterexec({string marea, number addr|ADDRESS addrobj},
 function fn);
\end_layout

\begin_layout Standard
Add or remove callback on memory read, write or execute (depending on the
 function).
 <addr> is relative to <marea>.
 <fn> is the callback.
 The register* functions return <fn> (which can then be passed to unregister*
 functions.
\end_layout

\begin_layout Itemize
Not all cores support this, and it may be unsupported for some memory areas.
\end_layout

\begin_layout Itemize
The functions are passed two parameters: Address and value.
\end_layout

\begin_layout Subsection
memory.{,un}registertrace: Set/Clear trace hook
\end_layout

\begin_layout Itemize
Syntax: function memory.registertrace(number processor, function fn);
\end_layout

\begin_layout Itemize
Syntax: none memory.unregistertrace(number processor, function fn);
\end_layout

\begin_layout Standard
Add or remove trace callback.
 <processor> is system-dependent processor number (0 is usually main CPU).
 The function arguments work like in other (un)register* functions.
\end_layout

\begin_layout Itemize
The functions are passed two parameters: Trace CPU and Trace event string.
\end_layout

\begin_layout Subsection
memory.cheat: Set cheat
\end_layout

\begin_layout Itemize
Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj}, number
 value);
\end_layout

\begin_layout Itemize
Syntax: none memory.cheat({string marea, number addr|ADDRESS addrobj});
\end_layout

\begin_layout Standard
Set or clear cheat (value <value>) on address <addr> (relative to <marea>).
 If <value> is not speicified, clear a cheat.
\end_layout

\begin_layout Itemize
Not all cores support this, and it may be unsupported for some memory areas.
\end_layout

\begin_layout Subsection
memory.setxmask: Set global execute hook mask
\end_layout

\begin_layout Itemize
Syntax: none memory.setxmask(number mask)
\end_layout

\begin_layout Standard
Set the global execute hook mask to <mask>.
 The meaning of each bit is system-dependent, but bit 0 should be the main
 CPU.
\end_layout

\begin_layout Subsection
memory.getregister: Get register value
\end_layout

\begin_layout Itemize
Syntax: number/boolean memory.getregister(string register)
\end_layout

\begin_layout Standard
Get the value of named register.
\end_layout

\begin_layout Subsection
memory.getregisters: Get register values
\end_layout

\begin_layout Itemize
Syntax: table memory.getregisters()
\end_layout

\begin_layout Standard
Get the value of all known registers as table.
\end_layout

\begin_layout Subsection
memory.setregister: Set register value
\end_layout

\begin_layout Itemize
Syntax: none memory.setregister(string register, number/boolean value)
\end_layout

\begin_layout Standard
Set the value of named register.
\end_layout

\begin_layout Subsection
memory.mmap: Class MMAP_STRUCT
\end_layout

\begin_layout Standard
See class MMAP_STRUCT
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table memory2
\end_layout

\begin_layout Standard
Contains newer memory functions.
\end_layout

\begin_layout Subsection
memory2(): Get all memory area names.
\end_layout

\begin_layout Itemize
Syntax: table memory2()
\end_layout

\begin_layout Standard
Returns array of all valid memory area names.
\end_layout

\begin_layout Subsection
memory2.<marea>:info: Get memory area info
\end_layout

\begin_layout Itemize
Syntax: table memory2.<marea>:info()
\end_layout

\begin_layout Standard
Return table describing given memory area.
 Includes fields address, size, last, readonly, special and endian.
\end_layout

\begin_layout Subsection
memory2.<marea>:<op>: Read/Write memory
\end_layout

\begin_layout Itemize
Syntax: none memory2.<marea>:<op>(number offset, number value)
\end_layout

\begin_layout Itemize
Syntax: number memory2.<marea>:<op>(number offset)
\end_layout

\begin_layout Standard
Read/Write value from/to given memory area <marea> at given offset <offset>
 (must be in-range).
 The value written is <value>.
 <Op> is of form: [i][s]<type>, where:
\end_layout

\begin_layout Itemize
<type> is one of 'byte', 'word', 'hword', 'dword', 'qword', 'float', 'double'.
\end_layout

\begin_layout Itemize
'i' signifies that the value is treated as opposite-to-normal endianess,
\end_layout

\begin_layout Itemize
's' signifies that value is treated as signed (not available for floating-point).
\end_layout

\begin_layout Subsection
memory2.<marea>:read: Scatter-gather value read
\end_layout

\begin_layout Itemize
Syntax: number memory2.<marea>:read(number addr...)
\end_layout

\begin_layout Standard
Read value from given memory area <marea> at byte offsets <addr>..., given
 in order of increasing significance.
 Value of true and false are special.
 True increments address by 1, and false decrements address by 1.
\end_layout

\begin_layout Subsection
memory2.<marea>:sread: Signed scatter-gather value read
\end_layout

\begin_layout Itemize
Syntax: number memory2.<marea>:sread(number addr...)
\end_layout

\begin_layout Standard
Like memory2.<marea>:read, but reads signed values.
\end_layout

\begin_layout Subsection
memory2.<marea>:write: Scatter-gather value write
\end_layout

\begin_layout Itemize
Syntax: number memory2.<marea>:write(number val, number addr...)
\end_layout

\begin_layout Standard
Write value <val> to given memory area <marea> at byte offsets <addr>..., given
 in order of increasing significance.
 Value of true and false are special.
 True increments address by 1, and false decrements address by 1.
\end_layout

\begin_layout Subsection
memory2.<marea>:cheat: Set/Clear cheat
\end_layout

\begin_layout Itemize
Syntax: none memory2.<marea>:cheat(number addr, [number value])
\end_layout

\begin_layout Standard
Set/Clear cheat at offset <addr> of memory area <marea>.
 If <value> is given, cheat with specified value is set.
 Otherwise cheat on address is removed.
\end_layout

\begin_layout Subsection
memory2.<marea>:sha256: SHA-256
\end_layout

\begin_layout Itemize
Syntax: string memory2.<marea>:sha256(number addr, number size[, number rows,
 number stride])
\end_layout

\begin_layout Standard
Compute SHA-256 of <rows> (default 1) chunks of <size> bytes each, starting
 from offset <addr> of area <marea>.
 The chunks are separated by <stride>.
\end_layout

\begin_layout Subsection
memory2.<marea>:skein: Skein-512-256
\end_layout

\begin_layout Itemize
Syntax: string memory2.<marea>:skein(number addr, number size[, number rows,
 number stride])
\end_layout

\begin_layout Standard
Same as memory2.<marea>:sha256, except with Skein-512-256 as hash function.
\end_layout

\begin_layout Subsection
memory2.<marea>:store{,cmp}: Copy region to Lua memory with compare
\end_layout

\begin_layout Itemize
Syntax: none memory2.<marea>:store(number addr, number daddr, number size[,
 number rows, number stride])
\end_layout

\begin_layout Itemize
Syntax: boolean memory2.<marea>:storecmp(number addr, number daddr, number
 size[, number rows, number stride])
\end_layout

\begin_layout Standard
Copy <rows> (default 1) chunks of <size> bytes each, starting from offset
 <addr> of area <marea>.
 The chunks are separated by <stride>.
 The target is Lua host memory, starting from offset <daddr>.
\end_layout

\begin_layout Standard
Additionally, the storecmp method returns false if target was modified (otherwis
e true).
\end_layout

\begin_layout Subsection
memory2.<marea>:readregion: Read region
\end_layout

\begin_layout Itemize
Syntax table memory2.<marea>:readregion(number addr, number size)
\end_layout

\begin_layout Standard
Read <size> bytes starting from <addr> in <marea> and return as array.
\end_layout

\begin_layout Subsection
memory2.<marea>:writeregion: Write region
\end_layout

\begin_layout Itemize
Syntax none memory2.<marea>:writeregion(number addr, table data)
\end_layout

\begin_layout Standard
Write array <data> to bytes starting from <addr> in <marea>.
\end_layout

\begin_layout Subsection
memory2.<marea>:register{read,write,exec}: Register hook
\end_layout

\begin_layout Itemize
Syntax: function memory2.<marea>:registerread(number addr, function fn);
\end_layout

\begin_layout Itemize
Syntax: function memory2.<marea>:registerwrite(number addr, function fn);
\end_layout

\begin_layout Itemize
Syntax: function memory2.<marea>:registerexec(number addr, function fn);
\end_layout

\begin_layout Standard
Register debug callback <fn> of specified type at offset <addr> of memory
 area <marea>.
 Returns <fn>.
\end_layout

\begin_layout Subsection
memory2.<marea>:unregister{read,write,exec}: Unregister hook
\end_layout

\begin_layout Itemize
Syntax: none memory2.<marea>:unregisterread(number addr, function fn);
\end_layout

\begin_layout Itemize
Syntax: none memory2.<marea>:unregisterwrite(number addr, function fn);
\end_layout

\begin_layout Itemize
Syntax: none memory2.<marea>:unregisterexec(number addr, function fn);
\end_layout

\begin_layout Standard
Unregister debug callback <fn> of specified type at offset <addr> of memory
 area <marea>.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table random
\end_layout

\begin_layout Standard
Contains random number generation methods.
 These functions do not return reproducable results.
\end_layout

\begin_layout Subsection
random.boolean: Random boolean
\end_layout

\begin_layout Itemize
Syntax: boolean random.boolean()
\end_layout

\begin_layout Standard
Returns true or false at random (50-50 chance).
\end_layout

\begin_layout Subsection
random.integer: Random integer
\end_layout

\begin_layout Itemize
Syntax: number random.integer(number highplusone)
\end_layout

\begin_layout Itemize
Syntax: number random.integer(number low, number high)
\end_layout

\begin_layout Standard
With one argument, return random integer [0,<highplusone>) (upper end exclusive).
 With two arguments, return random integer [<low>,<high>] (both ends inclusive).
\end_layout

\begin_layout Standard
The returned numbers are from uniform distribution.
\end_layout

\begin_layout Subsection
random.float: Random float
\end_layout

\begin_layout Itemize
Syntax: number random.float()
\end_layout

\begin_layout Standard
Returns random decimal number [0,1).
\end_layout

\begin_layout Subsection
random.among: Random parameter
\end_layout

\begin_layout Itemize
Syntax: value random.among(value values...)
\end_layout

\begin_layout Standard
Returns random parameter value, picked at uniform.
 Multiple equivalent values are returned with higher chance.
\end_layout

\begin_layout Subsection
random.amongtable: Random from table
\end_layout

\begin_layout Itemize
Syntax: value random.amongtable(table tab)
\end_layout

\begin_layout Standard
Returns random value from table <tab>.
 As in random.among, no equality testing is done.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table zip
\end_layout

\begin_layout Subsection
zip.enumerate: Enumerate members in zipfile
\end_layout

\begin_layout Itemize
Syntax: Table zip.enumerate(string filename[, boolean invert])
\end_layout

\begin_layout Standard
Returns table of files in zip archive <filename>.
 If <invert> is true, instead of returning array of names, returns table
 with keys being member names and values being true.
\end_layout

\begin_layout Subsection
zip.writer: Class ZIPWRITER
\end_layout

\begin_layout Standard
See class ZIPWRITER.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
Table callback
\end_layout

\begin_layout Standard
Various callback-related functions.
\end_layout

\begin_layout Subsection
\begin_inset CommandInset label
LatexCommand label
name "sub:callback.register:-Register-a"

\end_inset

callback.register: Register a callback
\end_layout

\begin_layout Itemize
Syntax: function callback.register(string cbname, function cbfun);
\end_layout

\begin_layout Standard
Instruct function <cbfun> to be added to list of callbacks to call on event
 <cbname> (See section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:Callbacks"

\end_inset

).
 The callback name does not have the 'on_' prefix (e.g.
 
\begin_inset Quotes eld
\end_inset

paint
\begin_inset Quotes erd
\end_inset

).
 Returns <cbfun>.
\end_layout

\begin_layout Subsection
\begin_inset CommandInset label
LatexCommand label
name "sub:callback.unregister:-Unregister-"

\end_inset

callback.unregister: Unregister a callback
\end_layout

\begin_layout Itemize
Syntax: function callback.unregister(string cbname, function cbfun);
\end_layout

\begin_layout Standard
Instruct function <cbfun> to be removed from list of callbacks to call on
 event <cbname>.
\end_layout

\begin_layout Subsection
callback.<cbname>:register: Register callback
\end_layout

\begin_layout Itemize
Syntax: function callback.<cbname>:register(function cbfun)
\end_layout

\begin_layout Standard
Synonym for callback.register (section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sub:callback.register:-Register-a"

\end_inset

), albeit with callback name specified differently.
\end_layout

\begin_layout Subsection
callback.<cbname>:unregister: Register callback
\end_layout

\begin_layout Itemize
Syntax: function callback.<cbname>:unregister(function cbfun)
\end_layout

\begin_layout Standard
Synonym for callback.unregister (section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sub:callback.unregister:-Unregister-"

\end_inset

), albeit with callback name specified differently.
\end_layout

\begin_layout Section
table bsnes
\end_layout

\begin_layout Standard
Various bsnes-specific functions.
\end_layout

\begin_layout Subsection
bsnes.dump_sprite: Dump a sprite
\end_layout

\begin_layout Itemize
Syntax: BITMAP bsnes.dump_sprite(string marea, number addr, number width,
 number height[, number stride])
\end_layout

\begin_layout Standard
Dumps given sprite (in native format) from memory.
 memory area is usually 
\begin_inset Quotes eld
\end_inset

VRAM
\begin_inset Quotes erd
\end_inset

.
 <Width> and <height> are given in 8x8 blocks.
 <Stride> overrides row stride (default 512).
\end_layout

\begin_layout Subsection
bsnes.dump_palette: Dump a palette
\end_layout

\begin_layout Itemize
Syntax: PALETTE bsnes.dump_palette(string marea, number addr, bool full256,
 bool first_trans)
\end_layout

\begin_layout Standard
Dumps a palette from memory.
 memory area is usually 
\begin_inset Quotes eld
\end_inset

CGRAM
\begin_inset Quotes erd
\end_inset

.
 If <full256> is true, 256 colors are dumped (otherwise 16).
 If <first_trans> is true, first color is forced transparent.
\end_layout

\begin_layout Subsection
bsnes.enablelayer: Set layer visibility
\end_layout

\begin_layout Itemize
Syntax: none bsnes.enablelayer(number layer, number priority, boolean enabled)
\end_layout

\begin_layout Standard
Enable or disable specified layer at specified priority.
\end_layout

\begin_layout Subsection
bsnes.redump_sprite: Redump a sprite
\end_layout

\begin_layout Itemize
Syntax: none bsnes.redump_sprite(BITMAP bitmap, string marea, number addr[,
 number stride])
\end_layout

\begin_layout Standard
Like bsnes.dump_sprite, but instead dumps to specified bitmap <bitmap>.
 The specified bitmap must have size multiple of 8x8.
\end_layout

\begin_layout Subsection
bsnes.redump_palette: Redump a palette
\end_layout

\begin_layout Itemize
Syntax: none bsnes.dump_palette(PALETTE pal, string marea, number addr, bool
 first_trans)
\end_layout

\begin_layout Standard
Like bsnes.dump_palette, but instead dumps to specified palette <pal>.
 The specified palette must have either 16 or 256 colors.
\end_layout

\begin_layout Section
extensions to table string
\end_layout

\begin_layout Subsection
string.charU: string.char, UTF-8 version.
\end_layout

\begin_layout Itemize
Syntax: string string.charU(number n...)
\end_layout

\begin_layout Standard
Like Lua string.char(), but works in terms of Unicode codepoints.
 The returned string is UTF-8.
\end_layout

\begin_layout Subsection
string.byteU: string.byte, UTF-8 version.
\end_layout

\begin_layout Itemize
Syntax: number...
 string.byteU(string str[, number i[, number j]])
\end_layout

\begin_layout Standard
Like string.byte(), but works in terms of Unicode codepoints.
 The input string <str> is assumed UTF-8.
\end_layout

\begin_layout Subsection
string.regex: Match string against regular expression
\end_layout

\begin_layout Itemize
Syntax: boolean/string...
 string.regex(string regexp, string against)
\end_layout

\begin_layout Standard
Match POSIX-extended regular expression <regexp> against string <against>.
 If no match, false is returned.
 Otherwise if string has no subcaptures, true is returned.
 Otherwise each subcapture is returned as a string (in order of starting
 position).
\end_layout

\begin_layout Subsection
string.hex: Transform integer into hex string
\end_layout

\begin_layout Itemize
Syntax: string string.hex(number n, [number digits])
\end_layout

\begin_layout Standard
Returns hexadecimal string representation of <n>, optionally padded with
 zeroes to <digits> digits (default is not to pad).
\end_layout

\begin_layout Subsection
string.lpad: Pad string with spaces from left
\end_layout

\begin_layout Itemize
Syntax: string string.lpad(string x, number n)
\end_layout

\begin_layout Standard
Pad string <x> to <n> bytes by inserting spaces at start and return the
 result.
\end_layout

\begin_layout Subsection
string.rpad: Pad string with spaces from right
\end_layout

\begin_layout Itemize
Syntax: string string.rpad(string x, number n)
\end_layout

\begin_layout Standard
Pad string <x> to <n> bytes by inserting spaces at end and return the result.
\end_layout

\begin_layout Section
Table _SYSTEM
\end_layout

\begin_layout Standard
Contains copy of global variables from time of Lua initialization.
 Non-writeable.
\end_layout

\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset


\end_layout

\begin_layout Section
\begin_inset CommandInset label
LatexCommand label
name "sec:Callbacks"

\end_inset

Callbacks
\end_layout

\begin_layout Standard
Various callbacks to Lua that can occur.
\end_layout

\begin_layout Subsection
on_paint: Screen is being painted
\end_layout

\begin_layout Itemize
Callback: on_paint(bool not_synth)
\end_layout

\begin_layout Standard
Called when screen is being painted.
 Any gui.* calls requiring graphic context draw on the screen.
\end_layout

\begin_layout Itemize
not_synth is true if this hook is being called in response to received frame,
 false otherwise.
\end_layout

\begin_layout Subsection
on_video: Dumped video frame is being painted
\end_layout

\begin_layout Itemize
Callback: on_video()
\end_layout

\begin_layout Standard
Called when video dump frame is being painted.
 Any gui.* calls requiring graphic context draw on the video.
\end_layout

\begin_layout Subsection
on_frame_emulated: Frame emulation complete
\end_layout

\begin_layout Itemize
Callback: on_frame_emulated()
\end_layout

\begin_layout Standard
Called when emulating frame has completed and on_paint()/on_video() calls
 are about to be issued.
\end_layout

\begin_layout Subsection
on_frame: Frame emulation starting.
\end_layout

\begin_layout Itemize
Callback: on_frame()
\end_layout

\begin_layout Standard
Called on each starting whole frame.
\end_layout

\begin_layout Subsection
on_rewind: Movie rewound to beginning
\end_layout

\begin_layout Itemize
Callback: on_rewind()
\end_layout

\begin_layout Standard
Called when rewind movie to beginning has completed.
\end_layout

\begin_layout Subsection
on_pre_load: Load operation is about to start
\end_layout

\begin_layout Itemize
Callback: on_pre_load(string name)
\end_layout

\begin_layout Standard
Called just before savestate/movie load occurs (note: loads are always delayed,
 so this occurs even when load was initiated by lua).
\end_layout

\begin_layout Subsection
on_err_Load: Load failed
\end_layout

\begin_layout Itemize
Callback: on_err_load(string name)
\end_layout

\begin_layout Standard
Called if loadstate goes wrong.
\end_layout

\begin_layout Subsection
on_post_load: Load completed
\end_layout

\begin_layout Itemize
Callback: on_post_load(string name, boolean was_savestate)
\end_layout

\begin_layout Standard
Called on successful loadstate.
 was_savestate gives if this was a savestate or a movie.
\end_layout

\begin_layout Subsection
on_pre_save: Save operation is about to start
\end_layout

\begin_layout Itemize
Callback: on_pre_save(string name, boolean is_savestate)
\end_layout

\begin_layout Standard
Called just before savestate save occurs (note: movie saves are synchronous
 and won't trigger these callbacks if called from Lua).
\end_layout

\begin_layout Subsection
on_err_save: Save failed
\end_layout

\begin_layout Itemize
Callback: on_err_save(string name)
\end_layout

\begin_layout Standard
Called if savestate goes wrong.
\end_layout

\begin_layout Subsection
on_post_save: Save completed
\end_layout

\begin_layout Itemize
Callback: on_post_save(string name, boolean is_savestate)
\end_layout

\begin_layout Standard
Called on successful savaestate.
 is_savestate gives if this was a savestate or a movie.
\end_layout

\begin_layout Subsection
on_quit: Emulator is shutting down
\end_layout

\begin_layout Itemize
Callback: on_quit()
\end_layout

\begin_layout Standard
Called when emulator is shutting down.
\end_layout

\begin_layout Subsection
on_input: Polling for input
\end_layout

\begin_layout Standard
Called when emulator is just sending input to bsnes core.
 Warning: This is called even in readonly mode, but the results are ignored.
\end_layout

\begin_layout Subsection
on_reset: System has been reset
\end_layout

\begin_layout Itemize
Callback: on_reset()
\end_layout

\begin_layout Standard
Called when system is reset.
\end_layout

\begin_layout Subsection
on_readwrite: Entered recording mode
\end_layout

\begin_layout Itemize
Callback: on_readwrite()
\end_layout

\begin_layout Standard
Called when moving into recording mode as result of 
\begin_inset Quotes eld
\end_inset

set-rwmode
\begin_inset Quotes erd
\end_inset

 command (note: moving to rwmode by Lua won't trigger this, as per recursive
 entry protection).
\end_layout

\begin_layout Subsection
on_snoop/on_snoop2: Snoop core controller reads
\end_layout

\begin_layout Itemize
Callback: on_snoop(number port, number controller, number index, number
 value)
\end_layout

\begin_layout Itemize
Callback: on_snoop2(number port, number controller, number index, number
 value)
\end_layout

\begin_layout Standard
Called each time bsnes asks for input.
 The value is the final value to be sent to bsnes core (readonly mode, autohold
 and autofire have been taken into account).
 Might be useful when translating movies to format suitable for console
 verification.
 Note: There is no way to modify the value to be sent.
\end_layout

\begin_layout Itemize
On_snoop2 is called instead of on_snoop if defined.
 Reserves port 0 for system, having first user port be port 1.
\end_layout

\begin_layout Subsection
on_keyhook: Hooked key/axis has been moved
\end_layout

\begin_layout Itemize
Callback: on_keyhook(string keyname, table state)
\end_layout

\begin_layout Standard
Sent when key that has keyhook events requested changes state.
 Keyname is name of the key (group) and state is the state (same kind as
 table values in input.raw).
\end_layout

\begin_layout Subsection
on_idle: Idle event
\end_layout

\begin_layout Itemize
Callback: on_idle()
\end_layout

\begin_layout Standard
Called when requested by set_idle_timeout(), the timeout has expired and
 emulator is waiting.
\end_layout

\begin_layout Subsection
on_timer: Timer event
\end_layout

\begin_layout Itemize
Callback: on_timer()
\end_layout

\begin_layout Standard
Called when requested by set_idle_timeout() and the timeout has expired
 (regardless if emulator is waiting).
\end_layout

\begin_layout Subsection
on_set_rewind: Rewind point has been set
\end_layout

\begin_layout Itemize
Callback: on_set_rewind(UNSAFEREWIND r)
\end_layout

\begin_layout Standard
Called when unsafe rewind object has been constructed.
\end_layout

\begin_layout Subsection
on_pre_rewind: Rewind is about to occur
\end_layout

\begin_layout Itemize
Callback: on_pre_rewind() 
\end_layout

\begin_layout Standard
Called just before unsafe rewind is about to occur.
\end_layout

\begin_layout Subsection
on_post_rewind: Rewind has occured
\end_layout

\begin_layout Itemize
Callback: on_post_rewind() 
\end_layout

\begin_layout Standard
Called just after unsafe rewind has occured.
\end_layout

\begin_layout Subsection
on_button: Button has been pressed
\end_layout

\begin_layout Itemize
Callback: on_button(number port, number controller, number index, string
 type)
\end_layout

\begin_layout Standard
Called on controller button press, with following parameters:
\end_layout

\begin_layout Itemize
port: Port number (0 is system)
\end_layout

\begin_layout Itemize
controller: Controller within port
\end_layout

\begin_layout Itemize
index: Index of button.
\end_layout

\begin_layout Itemize
type: Type of event, one of:
\end_layout

\begin_deeper
\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

pressed
\begin_inset Quotes erd
\end_inset

: Button was pressed.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

released
\begin_inset Quotes erd
\end_inset

: Button was released.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

hold
\begin_inset Quotes erd
\end_inset

: Held.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

unhold
\begin_inset Quotes erd
\end_inset

: Released from hold.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

type
\begin_inset Quotes erd
\end_inset

: Typing input on button.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

untype
\begin_inset Quotes erd
\end_inset

: Typing input undone.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

autofire <duty> <cycle>
\begin_inset Quotes erd
\end_inset

: Autofire with specifie duty and cycle.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

autofire
\begin_inset Quotes erd
\end_inset

: Stop autofire.
\end_layout

\begin_layout Itemize
\begin_inset Quotes eld
\end_inset

analog
\begin_inset Quotes erd
\end_inset

: Analog action on axis.
\end_layout

\end_deeper
\begin_layout Subsection
on_movie_lost: Movie data is about to be lost
\end_layout

\begin_layout Itemize
Callback: on_movie_lost(STRING kind)
\end_layout

\begin_layout Standard
Called just before something would happen that could lose movie data.
 Kind can be:
\end_layout

\begin_layout Itemize
readwrite: Switching to recording mode.
\end_layout

\begin_layout Itemize
reload: ROM is being reloaded in recording mode.
\end_layout

\begin_layout Itemize
load: New movie is being loaded.
\end_layout

\begin_layout Itemize
unsaferewind: Unsafe rewind is happening.
\end_layout

\begin_layout Subsection
on_latch: Latch line is rising
\end_layout

\begin_layout Itemize
Callback: on_latch(<core-dependent-parameters>)
\end_layout

\begin_layout Standard
Called when latch line for controller is rising.
 Some cores may not support this.
\end_layout

\begin_layout Section
System-dependent behaviour
\end_layout

\begin_layout Subsection
bsnes core
\end_layout

\begin_layout Itemize
Registers are: pbpc, pb, pc, r0, r1, r2, r3, r4, r5, a, x, y, z, s, d, db,
 p, e, irq, wai, mdr, vector, aa, rd, sp, dp, p_n, p_v, p_m, p_x, p_d, p_i,
 p_z, p_c, ppu_display_disabled, ppu_oam_priority, ppu_bg_tilesize[0], ppu_bg_ti
lesize[1], ppu_bg_tilesize[2], ppu_bg_tilesize[3], ppu_bg3_priority, ppu_mosaic_
enabled[0], ppu_mosaic_enabled[1], ppu_mosaic_enabled[2], ppu_mosaic_enabled[3],
 ppu_vram_incmode, ppu_mode7_vflip, ppu_mode7_hflip, ppu_window1_enabled[0],
 ppu_window1_enabled[1], ppu_window1_enabled[2], ppu_window1_enabled[3],
 ppu_window1_enabled[4], ppu_window1_enabled[5], ppu_window1_invert[0],
 ppu_window1_invert[1], ppu_window1_invert[2], ppu_window1_invert[3], ppu_window
1_invert[4], ppu_window1_invert[5], ppu_window2_enabled[0], ppu_window2_enabled[
1], ppu_window2_enabled[2], ppu_window2_enabled[3], ppu_window2_enabled[4],
 ppu_window2_enabled[5], ppu_window2_invert[0], ppu_window2_invert[1], ppu_windo
w2_invert[2], ppu_window2_invert[3], ppu_window2_invert[4], ppu_window2_invert[5
], ppu_bg_enabled[0], ppu_bg_enabled[1], ppu_bg_enabled[2], ppu_bg_enabled[3],
 ppu_bg_enabled[4], ppu_bgsub_enabled[0], ppu_bgsub_enabled[1], ppu_bgsub_enable
d[2], ppu_bgsub_enabled[3], ppu_bgsub_enabled[4], ppu_window_enabled[0],
 ppu_window_enabled[1], ppu_window_enabled[2], ppu_window_enabled[3], ppu_window
_enabled[4], ppu_sub_window_enabled[0], ppu_sub_window_enabled[1], ppu_sub_windo
w_enabled[2], ppu_sub_window_enabled[3], ppu_sub_window_enabled[4], ppu_addsub_m
ode, ppu_direct_color, ppu_color_mode, ppu_color_halve, ppu_color_enabled[0],
 ppu_color_enabled[1], ppu_color_enabled[2], ppu_color_enabled[3], ppu_color_ena
bled[4], ppu_color_enabled[5], ppu_mode7_extbg, ppu_pseudo_hires, ppu_overscan,
 ppu_oam_interlace, ppu_interlace, ppu_latch_hcounter, ppu_latch_vcounter,
 ppu_counters_latched, ppu_time_over, ppu_range_over, ppu_ppu1_mdr, ppu_ppu2_mdr
, ppu_bg_y[0], ppu_bg_y[1], ppu_bg_y[2], ppu_bg_y[3], ppu_ioamaddr, ppu_icgramad
dr, ppu_display_brightness, ppu_oam_basesize, ppu_oam_nameselect, ppu_oam_tdaddr
, ppu_oam_baseaddr, ppu_oam_addr, ppu_oam_firstsprite, ppu_oam_latchdata,
 ppu_bg_mode, ppu_mosaic_size, ppu_mosaic_countdown, ppu_bg_scaddr[0], ppu_bg_sc
addr[1], ppu_bg_scaddr[2], ppu_bg_scaddr[3], ppu_bg_scsize[0], ppu_bg_scsize[1],
 ppu_bg_scsize[2], ppu_bg_scsize[3], ppu_bg_tdaddr[0], ppu_bg_tdaddr[1],
 ppu_bg_tdaddr[2], ppu_bg_tdaddr[3], ppu_bg_ofslatch, ppu_m7_hofs, ppu_m7_vofs,
 ppu_bg_hofs[0], ppu_bg_hofs[1], ppu_bg_hofs[2], ppu_bg_hofs[3], ppu_bg_vofs[0],
 ppu_bg_vofs[1], ppu_bg_vofs[2], ppu_bg_vofs[3], ppu_vram_mapping, ppu_vram_incs
ize, ppu_vram_addr, ppu_mode7_repeat, ppu_m7_latch, ppu_m7a, ppu_m7b, ppu_m7c,
 ppu_m7d, ppu_m7x, ppu_m7y, ppu_cgram_addr, ppu_cgram_latchdata, ppu_window1_lef
t, ppu_window1_right, ppu_window2_left, ppu_window2_right, ppu_window_mask[0],
 ppu_window_mask[1], ppu_window_mask[2], ppu_window_mask[3], ppu_window_mask[4],
 ppu_window_mask[5], ppu_color_mask, ppu_colorsub_mask, ppu_color_r, ppu_color_g
, ppu_color_b, ppu_color_rgb, ppu_scanlines, ppu_hcounter, ppu_vcounter,
 ppu_vram_readbuffer, ppu_oam_itemcount, ppu_oam_tilecount, 
\end_layout

\begin_layout Itemize
on_latch has no parameters
\end_layout

\begin_layout Itemize
CPU 0 is S-CPU, 1 is S-SMP.
\end_layout

\begin_layout Itemize
Cheats are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_{RAM,ROM}.
\end_layout

\begin_layout Itemize
Read/Write/Execute hooks are supported for ROM, SRAM, WRAM, BSXFLASH, SLOT{A,B}_
{RAM,ROM}.
\end_layout

\begin_layout Itemize
Memory areas are: WRAM, APURAM, VRAM, OAM, CGRAM, RTC, DSPRAM, DSPPROM,
 DSPDROM, SRAM, ROM, BUS, PTRTABLE, CPU_STATE, PPU_STATE, SMP_STATE, DSP_STATE,
 BSXFLASH, BSX_RAM, BSX_PRAM, SLOTA_ROM, SLOTB_ROM, SLOTA_RAM, SLOTB_RAM,
 GBCPU_STATE, GBROM, GBRAM, GBWRAM, GBHRAM.
\end_layout

\begin_layout Subsection
gambatte core
\end_layout

\begin_layout Itemize
Registers are: wrambank, cyclecounter, pc, sp, hf1, hf2, zf, cf, a, b, c,
 d, e, f, h, l
\end_layout

\begin_layout Itemize
on_latch is not supported
\end_layout

\begin_layout Itemize
CPU 0 is main CPU.
\end_layout

\begin_layout Itemize
Cheats are supported for ROM, SRAM and WRAM.
\end_layout

\begin_layout Itemize
Read/Write/Execute hooks are supported for ROM (read/execute only), SRAM
 and WRAM.
\end_layout

\begin_layout Itemize
Memory areas are: SRAM, WRAM, VRAM, IOAMHRAM, ROM, BUS.
\end_layout

\end_body
\end_document
