1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
6 \use_default_options true
7 \maintain_unincluded_children false
9 \language_package default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
23 \default_output_format default
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
31 \pdf_bookmarksnumbered false
32 \pdf_bookmarksopen false
33 \pdf_bookmarksopenlevel 1
48 \paperorientation portrait
64 \paragraph_separation indent
65 \paragraph_indentation default
66 \quotes_language english
69 \paperpagestyle default
70 \tracking_changes false
80 lsnes Lua functions reference
87 \begin_layout Standard
88 \begin_inset CommandInset toc
89 LatexCommand tableofcontents
96 \begin_layout Standard
97 \begin_inset Newpage pagebreak
103 \begin_layout Section
107 \begin_layout Standard
108 These tokens are special, and are expanded while the script is being loaded
111 \begin_layout Subsection
112 @@LUA_SCRIPT_FILENAME@@
115 \begin_layout Standard
116 Expanded to string token containing path and filename of this Lua script.
117 Handy for referencing other lua scripts or resources that are relative
121 \begin_layout Standard
122 In practicular, this is suitable to be passed as base argument of various
123 functions like loadfile, dofile, resolve_filename, gui.bitmap_load, gui.bitmap_lo
124 ad_png and gui.bitmap_load_pal.
127 \begin_layout Section
131 \begin_layout Subsection
132 print: Print values to console
135 \begin_layout Itemize
136 Syntax: none print(value...
140 \begin_layout Standard
141 Prints specified values to console.
144 \begin_layout Subsection
145 exec: Execute lsnes commands
148 \begin_layout Itemize
149 Syntax: none exec(string cmd)
152 \begin_layout Standard
153 Execute lsnes command <cmd>.
156 \begin_layout Subsection
157 utime: Get current time
160 \begin_layout Itemize
161 Syntax: (number,number) utime()
164 \begin_layout Standard
166 First is time since some epoch in seconds, the second is microseconds mod
167 10^6 since that epoch.
170 \begin_layout Subsection
171 emulator_ready: Check if emulator has been fully initialized
174 \begin_layout Itemize
175 Syntax: boolean emulator_ready()
178 \begin_layout Standard
179 Returns true if emulator has finished booting, false if not (on_startup()
180 will be issued later).
183 \begin_layout Subsection
184 set_idle_timeout: Run function after timeout when emulator is idle
187 \begin_layout Itemize
188 Syntax: none set_idle_timeout(number timeout)
191 \begin_layout Standard
192 Set number of microseconds to block idle for.
193 After this timeout has expired, on_idle() will be called once.
196 \begin_layout Subsection
197 set_timer_timeout: Run function after timeout.
200 \begin_layout Itemize
201 Syntax: none set_timer_timeout(number timeout)
204 \begin_layout Standard
205 Set number of microseconds to block timer for.
206 After this timeout has expired, on_timer() will be called once.
209 \begin_layout Subsection
210 bus_address: Look up address in system bus.
213 \begin_layout Itemize
214 Syntax: none bus_address(number bus_addr)
217 \begin_layout Standard
218 Returns virtual address corresponding to specified address on system bus.
221 \begin_layout Subsection
222 loopwrapper: Convert loop into callable function
225 \begin_layout Itemize
226 Syntax: function loopwrapper(function fun, ...)
229 \begin_layout Standard
230 Calls function <fun> with function and specified arguments.
231 The function passed suspends execution until the function returned is called.
232 Handy for linear flow control among multiple invocations of a hook.
236 \begin_layout LyX-Code
237 on_paint = loopwrapper(function(wait)
241 \begin_layout LyX-Code
246 \begin_layout LyX-Code
248 \begin_inset Quotes eld
252 \begin_inset Quotes erd
258 \begin_layout LyX-Code
263 \begin_layout LyX-Code
268 \begin_layout LyX-Code
272 \begin_layout Subsection
273 list_bindings: List keybindings
276 \begin_layout Itemize
277 Syntax: table list_bindings([string cmd])
280 \begin_layout Standard
281 Get table of all keybindings, indexed by keyspec (modifiers|mask/key).
282 If <cmd> is specified, the table is limited to that command.
283 Also searches for controller keys.
286 \begin_layout Subsection
287 get_alias: Get expansion of alias
290 \begin_layout Itemize
291 Syntax: string get_alias(string aname)
294 \begin_layout Standard
295 Get expansion of given alias <aname>.
298 \begin_layout Subsection
299 set_alias: Set expansion of alias
302 \begin_layout Itemize
303 Syntax: none set_alias(string aname, string value)
306 \begin_layout Standard
307 Set expansion of given alias.
310 \begin_layout Subsection
311 create_ibind: Create invese binding
314 \begin_layout Itemize
315 Syntax: INVERSEBIND create_ibind(string name, string cmd)
318 \begin_layout Standard
319 Return object representing inverse binding with specified name <name> and
320 specified command <cmd>.
323 \begin_layout Itemize
324 Note: To create press/release commands, use aliases +foo and -foo .
327 \begin_layout Itemize
328 Note: Keep the returned object around.
331 \begin_layout Subsection
332 create_command: Create a command
335 \begin_layout Itemize
336 Syntax: COMMANDBIND create_commmand(string name, function a)
339 \begin_layout Itemize
340 Syntax: COMMANDBIND create_commmand(string name, function a, function b)
343 \begin_layout Standard
344 Return object representing a command (pair).
347 \begin_layout Itemize
348 If only one function is specied, the command is level-sensitive, <a> is
352 \begin_layout Itemize
353 If <b> is function, the function is edge-sensitive, <a> is positive edge
354 callback and <b> is negative edge callback.
357 \begin_layout Itemize
358 All callbacks get single argument: The parameters passed.
361 \begin_layout Itemize
362 Keep the returned object around.
365 \begin_layout Subsection
366 loadfile: Load Lua script
369 \begin_layout Itemize
370 Syntax: function loadfile(string filename[, string base])
373 \begin_layout Standard
374 Load lua script from <filename>, resolved relative to <base> (if empty,
378 \begin_layout Subsection
379 dofile: Execute Lua script
382 \begin_layout Itemize
383 Syntax: function dofile(string filename[, string base])
386 \begin_layout Standard
387 Execute lua script from <filename>, resolved relative to <base> (if empty,
388 current directory) and return all return values.
391 \begin_layout Subsection
392 resolve_filename: Resolve name of file relative to another
395 \begin_layout Itemize
396 Syntax: string resolve_file(string filename, string base)
399 \begin_layout Standard
400 Resolve name of file <filename> relative to <base> and return the result.
403 \begin_layout Standard
404 \begin_inset Newpage pagebreak
410 \begin_layout Section
414 \begin_layout Standard
415 Bitwise logical functions and related.
418 \begin_layout Subsection
419 bit.none/bit.bnot: Bitwise none or NOT function
422 \begin_layout Itemize
423 Syntax: number bit.none(number...)
426 \begin_layout Itemize
427 Syntax: number bit.bnot(number...)
430 \begin_layout Standard
431 48-bit bitwise NOT / NONE function (set bits that are set in none of the
435 \begin_layout Subsection
436 bit.any/bit.bor: Bitwise any or OR function
439 \begin_layout Itemize
440 Syntax: number bit.any(number...)
443 \begin_layout Itemize
444 Syntax: number bit.bor(number...)
447 \begin_layout Standard
448 48-bit bitwise OR / ANY function (set bits that are set in any of the arguments).
451 \begin_layout Subsection
452 bit.all/bit.band: Bitwise all or AND function
455 \begin_layout Itemize
456 Syntax: number bit.all(number...)
459 \begin_layout Itemize
460 Syntax: number bit.band(number...)
463 \begin_layout Standard
464 48-bit bitwise AND / ALL function (set bits that are set in all of the arguments
468 \begin_layout Subsection
469 bit.parity/bit.bxor: Bitwise parity or XOR function
472 \begin_layout Itemize
473 Syntax: number bit.parity(number...)
476 \begin_layout Itemize
477 Syntax: number bit.bxor(number...)
480 \begin_layout Standard
481 48-bit bitwise XOR / PARITY function (set bits that are set in odd number
485 \begin_layout Subsection
486 bit.lrotate: Rotate a number left
489 \begin_layout Itemize
490 Syntax: number bit.lrotate(number base[, number amount[, number bits]])
493 \begin_layout Standard
494 Rotate <bits>-bit (max 48, default 48) number <base> left by <amount> (default
498 \begin_layout Subsection
499 bit.rrotate: Rotate a number right
502 \begin_layout Itemize
503 Syntax: number bit.rrotate(number base[, number amount[, number bits]])
506 \begin_layout Standard
507 Rotate <bits>-bit (max 48, default 48) number <base> right by <amount> (default
511 \begin_layout Subsection
512 bit.lshift: Shift a number left
515 \begin_layout Itemize
516 Syntax: number bit.lshift(number base[, number amount[, number bits]])
519 \begin_layout Standard
520 Shift <bits>-bit (max 48, default 48) number <base> left by <amount> (default
522 The new bits are filled with zeroes.
525 \begin_layout Subsection
526 bit.lrshift: Shift a number right (logical)
529 \begin_layout Itemize
530 Syntax: number bit.lrshift(number base[, number amount[, number bits]])
533 \begin_layout Standard
534 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
536 The new bits are filled with zeroes.
539 \begin_layout Subsection
540 bit.arshift: Shift a number right (arithmetic)
543 \begin_layout Itemize
544 Syntax: number bit.arshift(number base[, number amount[, number bits]])
547 \begin_layout Standard
548 Shift <bits>-bit (max 48, default 48) number <base> logically right by <amount>
550 The new bits are shifted in with copy of the high bit.
553 \begin_layout Subsection
554 bit.extract: Extract/shuffle bits from number
557 \begin_layout Itemize
558 Syntax: number bit.extract(number base[, number bit0[, number bit1,...]])
561 \begin_layout Standard
562 Returns number that has bit0-th bit as bit 0, bit1-th bit as 1 and so on.
565 \begin_layout Itemize
566 Note: Bit numbers up to 51 should work reliably (then things start falling
567 apart due to double precision issues).
570 \begin_layout Itemize
571 Note: There are two special bit positions, true and false, standing for
572 always set bit and always clear bit.
575 \begin_layout Subsection
576 bit.value: Construct number with specified bits set
579 \begin_layout Itemize
580 Syntax: number bit.value([number bit1[, number bit2,...]])
583 \begin_layout Standard
584 Returns bitwise OR of 1 left shifted by <bit1> places, 1 left shifted by
585 <bit2> places and so on.
586 As special value, nil argument is no-op.
589 \begin_layout Subsection
590 bit.test_any: Test if any bit is set
593 \begin_layout Itemize
594 Syntax: boolean bit.test_any(number a, number b)
597 \begin_layout Standard
598 Returns true if bitwise and of <a> and <b> is nonzero, otherwise false.
601 \begin_layout Subsection
602 bit.test_all: Test if all bits are set
605 \begin_layout Itemize
606 Syntax: boolean bit.test_all(number a, number b)
609 \begin_layout Standard
610 Returns true if bitwise and of <a> and <b> equals <b>, otherwise false.
613 \begin_layout Subsection
614 bit.popcount: Population count
617 \begin_layout Itemize
618 Syntax: number bit.popcount(number a)
621 \begin_layout Standard
622 Returns number of set bits in <a>.
625 \begin_layout Subsection
626 bit.clshift: Chained left shift
629 \begin_layout Itemize
630 Syntax: (number, number) bit.clshift(number a, number b, [number amount,[number
634 \begin_layout Standard
635 Does chained left shift on <a>, <b> by <amount> positions (default 1), assuming
636 numbers to be of specified number of bits <bits> (default 48).
639 \begin_layout Subsection
640 bit.crshift: Chained right shift
643 \begin_layout Itemize
644 Syntax: (number, number) bit.crshift(number a, number b, [number amount,[number
648 \begin_layout Standard
649 Does chained right shift on <a>, <b> by <amount> positions (default 1),
650 assuming numbers to be of specified number of bits <bits> (default 48).
653 \begin_layout Subsection
654 bit.flagdecode: Decode bitfield into flags
657 \begin_layout Itemize
658 Syntax: string bit.flagdecode(number a, number bits, [string on, [string
662 \begin_layout Standard
663 Return string of length bits where ith character is ith character of on
664 if bit i is on, otherwise ith character of off.
665 Out of range reads give last character.
668 \begin_layout Itemize
669 Note: <on> defaults to '*' if empty.
672 \begin_layout Itemize
673 Note: <off> defaults to '-' if empty.
676 \begin_layout Subsection
677 bit.rflagdecode: Decode bitfield into flags
680 \begin_layout Itemize
681 Syntax: string bit.rflagdecode(number a, number bits, [string on, [string
685 \begin_layout Standard
686 Like bit.flagdecode, but outputs the string in the opposite order (most significa
690 \begin_layout Standard
691 \begin_inset Newpage pagebreak
697 \begin_layout Section
701 \begin_layout Itemize
702 Functions that draw to screen can only only be called in on_paint and on_video
703 callbacks or if non-default render queue has been set.
706 \begin_layout Itemize
708 Bits 0-7 are the blue component, bits 8-15 are the green component, bits
709 16-23 are the red component, bits 24-31 are alpha component (0 is fully
710 opaque, 255 is almost transparent).
711 -1 is the fully transparent color.
714 \begin_layout Itemize
715 Alpha values greater than 127 do work properly.
718 \begin_layout Itemize
719 Origin of coordinates is at top left corner of game display area.
720 Left and top gaps correspond to negative coordinates.
723 \begin_layout Subsection
724 gui.resolution: Get current resolution
727 \begin_layout Itemize
728 Syntax: (number, number) gui.resolution()
731 \begin_layout Standard
732 Returns 2-tuple (hresolution, vresolution).
735 \begin_layout Subsection
736 gui.left_gap/gui.right_gap/gui.top_gap/gui.bottom_gap: Set edge gaps
739 \begin_layout Itemize
740 Syntax: number gui.left_gap(number gap)
743 \begin_layout Itemize
744 Syntax: number gui.right_gap(number gap)
747 \begin_layout Itemize
748 Syntax: number gui.top_gap(number gap)
751 \begin_layout Itemize
752 Syntax: number gui.bottom_gap(number gap)
755 \begin_layout Standard
756 Set the specified edge gap to specified value <gap> (max gap is 8191).
757 If successful, old gap is returned.
760 \begin_layout Subsection
761 gui.delta_left_gap/gui.delta_right_gap/gui.delta_top_gap/gui.delta_bottom_gap:
765 \begin_layout Itemize
766 Syntax: number gui.delta_left_gap(number dgap)
769 \begin_layout Itemize
770 Syntax: number gui.delta_right_gap(number dgap)
773 \begin_layout Itemize
774 Syntax: number gui.delta_top_gap(number dgap)
777 \begin_layout Itemize
778 Syntax: number gui.delta_bottom_gap(number dgap)
781 \begin_layout Standard
782 Increase the specified edge gap by specified value <dgap> (max gap is 8191)
783 and return the old gap (returns nothing on error).
786 \begin_layout Subsection
787 gui.text/gui.textH/gui.textV,gui.textHV: Draw text
790 \begin_layout Itemize
791 Syntax: none gui.text(number x, number y, string text[, number fgc[, number
795 \begin_layout Itemize
796 Syntax: none gui.textH(number x, number y, string text[, number fgc[, number
800 \begin_layout Itemize
801 Syntax: none gui.textV(number x, number y, string text[, number fgc[, number
805 \begin_layout Itemize
806 Syntax: none gui.textHV(number x, number y, string text[, number fgc[, number
810 \begin_layout Standard
811 Draw specified text on the GUI (each character cell is 8 or 16 wide and
816 \begin_layout Itemize
817 x: X-coordinate to start the drawing from (and x-coordinate at begining
821 \begin_layout Itemize
822 y: Y-coordinate to start the drawing from.
825 \begin_layout Itemize
826 text: The text to draw.
829 \begin_layout Itemize
830 fgc: Text color (default is 0xFFFFFF (white))
833 \begin_layout Itemize
834 bgc: Background color (default is -1 (transparent))
837 \begin_layout Standard
838 Note: The H variants draw at double width and V variants draw at double
842 \begin_layout Subsection
843 gui.rectangle: Draw a rectangle
846 \begin_layout Itemize
847 Syntax: none gui.rectangle(number x, number y, number width, number height[,
848 number thickness[, number outline[, number fill]]])
851 \begin_layout Standard
852 Draw rectangle on the GUI.
856 \begin_layout Itemize
857 x: X-coordinate of left edge.
860 \begin_layout Itemize
861 y: Y-coordinate of upper edge.
864 \begin_layout Itemize
865 width: Width of rectangle.
868 \begin_layout Itemize
869 height: Height of rectangle.
872 \begin_layout Itemize
873 thickness: Thickness of outline (default is 1).
876 \begin_layout Itemize
877 outline: Color of outline (default is 0xFFFFFF (white))
880 \begin_layout Itemize
881 fill: Color of fill (default is -1 (transparent))
884 \begin_layout Subsection
885 gui.box: Draw a 3D-effect box
888 \begin_layout Itemize
889 Syntax: none gui.box(number x, number y, number width, number height[, number
890 thickness[, number outline1[,number outline2[, number fill]]]])
893 \begin_layout Standard
894 Draw rectangle with 3D effect on the GUI.
898 \begin_layout Itemize
899 x: X-coordinate of left edge.
902 \begin_layout Itemize
903 y: Y-coordinate of upper edge.
906 \begin_layout Itemize
907 width: Width of rectangle.
910 \begin_layout Itemize
911 height: Height of rectangle.
914 \begin_layout Itemize
915 thickness: Thickness of outline (default is 1).
918 \begin_layout Itemize
919 outline1: First color of outline (default is 0xFFFFFF (white))
922 \begin_layout Itemize
923 outline2: First color of outline (default is 0x808080 (dark gray))
926 \begin_layout Itemize
927 fill: Color of fill (default is 0xC0C0C0 (light grayy))
930 \begin_layout Subsection
931 gui.pixel: Draw a single pixel
934 \begin_layout Itemize
935 Syntax: none gui.pixel(number x, number y[, number color])
938 \begin_layout Standard
939 Draw one pixel on the GUI.
943 \begin_layout Itemize
944 x: X-coordinate of the pixel
947 \begin_layout Itemize
948 y: Y-coordinate of the pixel
951 \begin_layout Itemize
952 color: Color of the pixel (default is 0xFFFFFF (white))
955 \begin_layout Subsection
956 gui.crosshair: Draw a crosshair
959 \begin_layout Itemize
960 Syntax: none gui.crosshair(number x, number y[, number length[, number color]])
963 \begin_layout Standard
968 \begin_layout Itemize
969 x: X-coordinate of the crosshair
972 \begin_layout Itemize
973 y: Y-coordinate of the crosshair
976 \begin_layout Itemize
977 length: Length of the crosshair lines (default 10).
980 \begin_layout Itemize
981 color: Color of the crosshair (default is 0xFFFFFF (white))
984 \begin_layout Subsection
985 gui.line: Draw a line
988 \begin_layout Itemize
989 Syntax: none gui.line(number x1, number y1, number x2, number y2[, number
993 \begin_layout Standard
998 \begin_layout Itemize
999 x1: X-coordinate of one end.
1002 \begin_layout Itemize
1003 y1: Y-coordinate of one end.
1006 \begin_layout Itemize
1007 x2: X-coordinate of the other end.
1010 \begin_layout Itemize
1011 y2: Y-coordinate of the other end.
1014 \begin_layout Itemize
1015 color: Color of the line (default is 0xFFFFFF (white)).
1018 \begin_layout Subsection
1019 gui.circle: Draw a (filled) circle
1022 \begin_layout Itemize
1023 Syntax: none gui.circle(number x, number y, number r[, number thick[, number
1024 border[, number fil]]])
1027 \begin_layout Standard
1032 \begin_layout Itemize
1033 x: X-coordinate of the center
1036 \begin_layout Itemize
1037 y: Y-coordinate of the center
1040 \begin_layout Itemize
1041 r: The radius of the circle
1044 \begin_layout Itemize
1045 thick: Border thickness
1048 \begin_layout Itemize
1049 border: Border color (default is 0xFFFFFF (white))
1052 \begin_layout Itemize
1053 fill: Fill color (default is -1 (transparent)).
1056 \begin_layout Subsection
1057 gui.bitmap_draw: Draw a bitmap
1060 \begin_layout Itemize
1061 Syntax: none gui.bitmap_draw(number x, number y, BITMAP bitmap, PALETTE palette)
1064 \begin_layout Itemize
1065 Syntax: none gui.bitmap_draw(number x, number y, DBITMAP bitmap)
1068 \begin_layout Standard
1069 Draw a bitmap <bitmap> on screen with specified palette <palette> (if bitmap
1074 \begin_layout Itemize
1075 x: X-coordinate of left edge.
1078 \begin_layout Itemize
1079 y: Y-coordinate of top edge.
1082 \begin_layout Itemize
1083 bitmap: The bitmap to draw
1086 \begin_layout Itemize
1087 palette: The palette to draw the bitmap using.
1090 \begin_layout Subsection
1091 gui.palette_new: Create a new palette
1094 \begin_layout Itemize
1095 Syntax: PALETTE gui.palette_new()
1098 \begin_layout Standard
1099 Returns a new palette (initially all transparent).
1103 \begin_layout Subsection
1104 gui.bitmap_new: Create a new bitmap
1107 \begin_layout Itemize
1108 Syntax: BITMAP/DBITMAP gui.bitmap_new(number w, number h, boolean direct[,
1112 \begin_layout Standard
1113 Returns a new bitmap/dbitmap.
1116 \begin_layout Standard
1120 \begin_layout Itemize
1121 w: The width of new bitmap
1124 \begin_layout Itemize
1125 h: The height of new bitmap
1128 \begin_layout Itemize
1129 direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
1132 \begin_layout Itemize
1133 icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
1136 \begin_layout Subsection
1137 gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
1140 \begin_layout Itemize
1141 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
1144 \begin_layout Itemize
1145 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
1148 \begin_layout Standard
1149 Reads file <file> (resolved relative to <base>) or string <content> and
1150 returns loaded bitmap/dbitmap (if bitmap, the second return value is palette
1154 \begin_layout Subsection
1155 gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
1158 \begin_layout Itemize
1159 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
1163 \begin_layout Itemize
1164 Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
1167 \begin_layout Standard
1168 Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
1169 encoded content <content>.
1172 \begin_layout Itemize
1173 If the PNG is of color type 3 (PALETTE), returns two value.
1174 First is BITMAP containing the image data from the PNG and second is PALETTE
1175 containg the palette data from the PNG.
1178 \begin_layout Itemize
1179 For color types 0 (GRAY), 2 (RGB), 4 (GRAY_ALPHA) and 6 (RGBA), returns
1180 one DBITMAP containg the image data loaded from the PNG.
1183 \begin_layout Subsection
1184 gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
1187 \begin_layout Itemize
1188 Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
1191 \begin_layout Itemize
1192 Syntax: PALETTE gui.bitmap_load_pal_str(string content)
1195 \begin_layout Standard
1196 Load a palette from file <file>(resolved relative to <base>) or string <content>.
1199 \begin_layout Itemize
1200 The kinds of lines supported:
1204 \begin_layout Itemize
1205 Blank or just whitespace: Ignored
1208 \begin_layout Itemize
1209 First non-whitespace is '#': Ignored
1212 \begin_layout Itemize
1213 <r> <g> <b>: Fully opaque color with specified RGB values (0-255)
1216 \begin_layout Itemize
1217 <r> <g> <b> <a>: Color with specified RGB values (0-255) and specified alpha
1218 (0-256, 0 being fully transparent and 256 fully opaque).
1221 \begin_layout Itemize
1222 transparent: Fully transparent color
1226 \begin_layout Subsection
1227 gui.palette_set: Set palette entry
1230 \begin_layout Itemize
1231 Syntax: none gui.palette_set(PALETTE palette, number index, number color)
1234 \begin_layout Standard
1235 Sets color in palette.
1239 \begin_layout Itemize
1240 palette: The palette to manipulate
1243 \begin_layout Itemize
1244 index: Index of color (0-65535).
1247 \begin_layout Itemize
1248 color: The color value.
1251 \begin_layout Subsection
1252 gui.bitmap_pset: Set pixel in bitmap
1255 \begin_layout Itemize
1256 Syntax: none gui.bitmap_pset(BITMAP/DBITMAP bitmap, number x, number y, number
1260 \begin_layout Standard
1261 Sets specified pixel in bitmap.
1265 \begin_layout Itemize
1266 bitmap: The bitmap to manipulate
1269 \begin_layout Itemize
1270 x: The x-coordinate of the pixel.
1273 \begin_layout Itemize
1274 y: The y-coordinate of the pixel.
1277 \begin_layout Itemize
1278 color: If bitmap is a bitmap, color index (0-65535).
1279 Otherwise color value.
1282 \begin_layout Subsection
1283 gui.bitmap_pget: Get pixel in bitmap
1286 \begin_layout Itemize
1287 Syntax: number gui.bitmap_pget(BITMAP/DBITMAP bitmap, number x, number y)
1290 \begin_layout Standard
1291 Gets specified pixel in bitmap.
1295 \begin_layout Itemize
1296 bitmap: The bitmap to query
1299 \begin_layout Itemize
1300 x: The x-coordinate of the pixel.
1303 \begin_layout Itemize
1304 y: The y-coordinate of the pixel.
1307 \begin_layout Standard
1308 The bitmap color (color index if paletted, otherwise color value).
1311 \begin_layout Subsection
1312 gui.bitmap_size: Get size of bitmap
1315 \begin_layout Itemize
1316 Syntax: (number, number) gui.bitmap_size(BITMAP/DBITMAP bitmap)
1319 \begin_layout Standard
1320 Get size of bitmap <bitmap>.
1321 The first return is the width, the second is the height.
1324 \begin_layout Itemize
1325 Note: Can be used anywhere.
1328 \begin_layout Subsection
1329 gui.bitmap_blit: Blit a bitmap into another
1332 \begin_layout Itemize
1333 Syntax: none gui.bitmap_blit(BITMAP/DBITMAP dest, number dx, number dy, BITMAP/DB
1334 ITMAP src, number sx, number sy, number w, number h[, number ck])
1337 \begin_layout Standard
1338 Blit a part of bitmap to another.
1342 \begin_layout Itemize
1343 dest: Destination to blit to.
1346 \begin_layout Itemize
1347 dx: left edge of target
1350 \begin_layout Itemize
1351 dy: Top edge of target
1354 \begin_layout Itemize
1355 src: The source to blit from.
1356 Must be of the same type as destination.
1359 \begin_layout Itemize
1360 sx: left edge of source
1363 \begin_layout Itemize
1364 sy: Top edge of source
1367 \begin_layout Itemize
1371 \begin_layout Itemize
1372 h: Height of region.
1375 \begin_layout Itemize
1377 Pixels of this color are not blitted.
1381 \begin_layout Itemize
1382 If bitmaps are bitmaps, this is color index of colorkey.
1383 Values outside range 0-65535 cause no key to be used as colorkey.
1386 \begin_layout Itemize
1387 If bitmaps are dbitmaps, this color value of colorkey.
1390 \begin_layout Itemize
1391 May be absent or nil for no colorkey blit.
1395 \begin_layout Subsection
1396 gui.repaint: Arrange a repaint
1399 \begin_layout Itemize
1400 Syntax: none gui.repaint()
1403 \begin_layout Standard
1404 Request on_repaint() to happen as soon as possible.
1407 \begin_layout Subsection
1408 gui.subframe_update: Enable/Disable subframe updates
1411 \begin_layout Itemize
1412 Syntax: none gui.subframe_update(boolean on)
1415 \begin_layout Standard
1416 Request subframe updates (calling on_paint() on subframes) to happen (<on>=true)
1417 or not happen (<on>=false).
1420 \begin_layout Subsection
1421 gui.screenshot: Write a screenshot
1424 \begin_layout Itemize
1425 Syntax: none gui.screenshot(string filename)
1428 \begin_layout Standard
1429 Write PNG screenshot of the current frame (no drawings) to specified file
1433 \begin_layout Subsection
1434 gui.color: Compose a color.
1437 \begin_layout Itemize
1438 Syntax: number gui.color(number r, number g, number b[, number a])
1441 \begin_layout Standard
1442 Returns color (in notation Lua scripts use) corresponding to color (<r>,<g>,<b>)
1443 , each component in scale 0-255.
1444 If <a> is specified, that is alpha (0 is fully transparent, 256(sic) is
1446 The default alpha is 256.
1449 \begin_layout Subsection
1450 gui.status: Set status variable
1453 \begin_layout Itemize
1454 Syntax: none gui.status(string name, string value)
1457 \begin_layout Standard
1459 \begin_inset Quotes eld
1463 \begin_inset Quotes erd
1466 to <value> in status area.
1469 \begin_layout Subsection
1470 gui.rainbow: Rainbow color calculation
1473 \begin_layout Itemize
1474 Syntax: number gui.rainbow(number step, number steps[, number color])
1477 \begin_layout Standard
1478 Perform hue rotation of color <color> (default bright red), by <step> steps.
1479 The number of steps per full rotation is given by absolute value of <steps>.
1482 \begin_layout Standard
1483 If <steps> is negative, the rotation will be counterclockwise.
1486 \begin_layout Subsection
1487 gui.renderq_new: Create a render queue
1490 \begin_layout Itemize
1491 Syntax: RENDERQUEUE gui.renderq_new(number width, number height)
1494 \begin_layout Standard
1495 Create render queue with specified reported size and return it.
1498 \begin_layout Subsection
1499 gui.renderq_clear: Clear a render queue
1502 \begin_layout Itemize
1503 Syntax: none gui.renderq_clear(RENDERQUEUE queue)
1506 \begin_layout Standard
1507 Clear specified render queue.
1510 \begin_layout Subsection
1511 gui.renderq_set: Change active render queue
1514 \begin_layout Itemize
1515 Syntax: none gui.renderq_set(RENDERQUEUE queue)
1518 \begin_layout Standard
1519 Switch to specified render queue.
1520 Use nil as queue to switch to default queue.
1523 \begin_layout Itemize
1524 Note: When switched to another queue, all drawing functions work and draw
1525 there, even outside on_video/on_paint.
1528 \begin_layout Subsection
1529 gui.renderq_run: Run render queue
1532 \begin_layout Itemize
1533 Syntax: none gui.renderq_run(RENDERQUEUE queue)
1536 \begin_layout Standard
1537 Run specified render queue, copying the objects to current render queue.
1541 \begin_layout Itemize
1542 Warning: Don't try to run the current render queue.
1545 \begin_layout Subsection
1546 gui.loadfont: Load a font file
1549 \begin_layout Itemize
1550 Syntax: CUSTOMFONT gui.loadfont(string filename)
1553 \begin_layout Standard
1554 Loads font from specified file (CUSTOMFONT object).
1557 \begin_layout Subsection
1558 CUSTOMFONT(): Render text to screen
1561 \begin_layout Itemize
1562 Syntax: none CUSTOMFONT(number x, number y, string text[, number fgc[, number
1563 bgc[, number hlc]]])
1566 \begin_layout Standard
1567 Draw string with custom font to screen.
1568 The parameters are the same as in gui.text, except <hlc> is the halo color
1569 (default is no halo).
1573 \begin_layout Subsection
1574 gui.adjust_transparency: Adjust transparency of DBITMAP or PALETTE
1577 \begin_layout Itemize
1578 Syntax: none gui.adjust_transparency(DBITMAP obj, number adj)
1581 \begin_layout Itemize
1582 Syntax: none gui.adjust_transparency(PALETTE obj, number adj)
1585 \begin_layout Standard
1586 Multiply alpha channel of <obj> by <adj>/256.
1588 \begin_inset Quotes eld
1592 \begin_inset Quotes erd
1595 out of solid bitmaps.
1598 \begin_layout Subsection
1599 gui.kill_frame: Kill video frame and associated sound
1602 \begin_layout Itemize
1603 Syntax: none gui.kill_frame()
1606 \begin_layout Standard
1607 Kills the currently dumped video frame + the associated sound.
1608 Only valid in on_video callback.
1611 \begin_layout Standard
1612 \begin_inset Newpage pagebreak
1618 \begin_layout Section
1622 \begin_layout Standard
1624 Functions manipulating input are only available in on_input callback.
1627 \begin_layout Subsection
1628 input.get: Read controller button/axis (deprecated)
1631 \begin_layout Itemize
1632 Syntax: number input.get(number controller, number index)
1635 \begin_layout Standard
1636 Read the specified index <index> (zero-based) from specified controller
1637 <controller> (zero-based).
1641 \begin_layout Subsection
1642 input.set: Write controller button/axis (deprecated)
1645 \begin_layout Itemize
1646 Syntax: none input.set(number controller, number index, number value)
1649 \begin_layout Standard
1650 Write the specified index <index> (zero-based) from specified controller
1651 <controller> (zero-based), storing value <value>.
1654 \begin_layout Subsection
1655 input.get2: Read controller button/axis
1658 \begin_layout Itemize
1659 Syntax: number input.get2(number port, number controller, number index)
1662 \begin_layout Standard
1663 Read the specified input tuple.
1664 Port 0 is system port.
1667 \begin_layout Subsection
1668 input.set2: Write controller button/axis
1671 \begin_layout Itemize
1672 Syntax: input.set2(number port, number controller, number index, number value)
1675 \begin_layout Standard
1676 Write the specified input tuple.
1677 Port 0 is system port.
1680 \begin_layout Subsection
1681 input.lcid_to_pcid2: Look up logical controller
1684 \begin_layout Itemize
1685 Syntax: (number, number) input.lcid_to_pcid2(number lcid)
1688 \begin_layout Standard
1689 Look up physical pcid pair (port, controller) corresponding to specified
1690 logical controller (1-based).
1691 Returns nothing if controller does not exist.
1694 \begin_layout Subsection
1695 input.port_type: Look up port type
1698 \begin_layout Itemize
1699 Syntax: string input.port_type(number port)
1702 \begin_layout Standard
1703 Return type of specified port.
1706 \begin_layout Subsection
1707 input.controller_info: Get information about controller
1710 \begin_layout Itemize
1711 Syntax: table input.controller_info(number port, number controller)
1714 \begin_layout Standard
1715 Get controller info for specified controller.
1716 If controller does not exist, returns nil.
1717 Otherwise returns a table with following fields:
1720 \begin_layout Itemize
1721 type (string): Type of the controller.
1724 \begin_layout Itemize
1725 class (string): Class of the controller.
1728 \begin_layout Itemize
1729 classnum (number): Number of the controller within its class (1-based)
1732 \begin_layout Itemize
1733 lcid (number): Logical controller number of the controller.
1736 \begin_layout Itemize
1737 button_count (number): Number of buttons on controller
1740 \begin_layout Itemize
1741 buttons (array): Array of following info about each button:
1745 \begin_layout Itemize
1746 type (string): Type of button.
1748 \begin_inset Quotes eld
1752 \begin_inset Quotes erd
1756 \begin_inset Quotes eld
1760 \begin_inset Quotes erd
1764 \begin_inset Quotes eld
1768 \begin_inset Quotes erd
1772 \begin_inset Quotes eld
1776 \begin_inset Quotes erd
1782 \begin_layout Itemize
1783 name (string): Name of button.
1786 \begin_layout Itemize
1787 symbol (string): Symbol of button.
1788 Only present for type
1789 \begin_inset Quotes eld
1793 \begin_inset Quotes erd
1799 \begin_layout Itemize
1800 hidden (boolean): True if hidden button.
1805 \begin_layout Subsection
1806 input.veto_button: Veto a button press
1809 \begin_layout Itemize
1810 Syntax: none input.veto_button()
1813 \begin_layout Standard
1814 Signals that the button event should be vetoed.
1815 Only valid in on_button callback.
1818 \begin_layout Subsection
1819 input.geta: Get all buttons for controller (deprecated)
1822 \begin_layout Itemize
1823 Syntax: (number, number...) input.geta(number controller)
1826 \begin_layout Standard
1827 Get input state for entiere controller.
1828 Returns n return values.
1831 \begin_layout Itemize
1832 1st return value: Bitmask: bit i is set if i:th index is nonzero
1835 \begin_layout Itemize
1836 2nd- return value: value of i:th index.
1839 \begin_layout Subsection
1840 input.seta: Set all buttons for controller (deprecated)
1843 \begin_layout Itemize
1844 Syntax: none input.seta(number controller, number bitmask, number args...)
1847 \begin_layout Standard
1848 Set state for entiere controller.
1849 args is up to N values for indices (overriding values in bitmask if specified).
1852 \begin_layout Subsection
1853 input.controllertype: Get controller type (deprecated)
1856 \begin_layout Itemize
1857 syntax: string input.controllertype(number controller)
1860 \begin_layout Standard
1861 Get the type of controller as string.
1864 \begin_layout Subsection
1865 input.reset: Execute (delayed) reset
1868 \begin_layout Itemize
1869 Syntax: none input.reset([number cycles])
1872 \begin_layout Standard
1874 If <cycles> is greater than zero, do delayed reset.
1875 0 (or no value) causes immediate reset.
1878 \begin_layout Itemize
1879 Note: Only available with subframe flag false.
1882 \begin_layout Subsection
1883 input.raw: Return raw input data
1886 \begin_layout Itemize
1887 Syntax: table input.raw()
1890 \begin_layout Standard
1891 Returns table of tables of all available keys and axes.
1892 The first table is indexed by key name (platform-dependent!), and the inner
1893 table has the following fields:
1896 \begin_layout Itemize
1897 value: Last reported value for control
1901 \begin_layout Itemize
1902 For keys: 1 for pressed, 0 for released.
1905 \begin_layout Itemize
1906 For axes: -32767...32767.
1909 \begin_layout Itemize
1910 For presure-sensitive buttons: 0...32767.
1913 \begin_layout Itemize
1914 For hats: Bitmask: 1=>Up, 2=>Right, 4=>Down, 8=>Left.
1917 \begin_layout Itemize
1918 For mouse: Coordinates relative to game area.
1922 \begin_layout Itemize
1923 ktype: Type of key (disabled, key, mouse, axis, hat, pressure).
1926 \begin_layout Subsection
1927 input.keyhook: Hook a key
1930 \begin_layout Itemize
1931 Syntax: none input.keyhook(string key, boolean state)
1934 \begin_layout Standard
1935 Requests that keyhook events to be sent for key <key> (<state>=true) or
1936 not sent (<state>=false).
1939 \begin_layout Subsection
1940 input.joyget: Get controls for controller
1943 \begin_layout Itemize
1944 Syntax: table input.joyget(number logical)
1947 \begin_layout Standard
1948 Returns table for current controls for specified logical controller <logical>.
1949 The names of fields vary by controller type.
1952 \begin_layout Itemize
1953 The buttons have the same name as those are referred to in other contexts
1957 \begin_layout Itemize
1958 The analog axes are usually
1959 \begin_inset Quotes eld
1963 \begin_inset Quotes erd
1967 \begin_inset Quotes eld
1971 \begin_inset Quotes erd
1977 \begin_layout Itemize
1978 Each field is numeric or boolean depending on axis/button.
1981 \begin_layout Subsection
1982 input.joyset: Set controls for controller
1985 \begin_layout Itemize
1986 Syntax: none input.joyset(number controller, table controls)
1989 \begin_layout Standard
1990 Set the the state of specified controller to values specified in specified
1994 \begin_layout Itemize
1995 Each field can be boolean or number.
1998 \begin_layout Itemize
1999 Also, buttons allow strings, which cause value to be inverted.
2002 \begin_layout Subsection
2003 input.lcid_to_pcid: Look up logical controller (deprecated)
2006 \begin_layout Itemize
2007 Syntax: (number, number, number) input.lcid_to_pcid(number lcid)
2010 \begin_layout Standard
2011 Returns the legacy pcid for controller (or false if there isn't one), followed
2013 Returns nothing if controller does not exist.
2016 \begin_layout Standard
2017 \begin_inset Newpage pagebreak
2023 \begin_layout Section
2027 \begin_layout Standard
2028 Various keybinding-related functions
2031 \begin_layout Subsection
2032 keyboard.bind: Bind a key
2035 \begin_layout Itemize
2036 Syntax: none keyboard.bind(string mod, string mask, string key, string cmd)
2039 \begin_layout Standard
2040 Bind specified key with specified modifers to specified command.
2043 \begin_layout Subsection
2044 keyboard.unbind: Unbind a key
2047 \begin_layout Itemize
2048 Syntax: none keyboard.unbind(string mod, string mask, string key)
2051 \begin_layout Standard
2052 Unbind specified key with specified modifers.
2055 \begin_layout Subsection
2056 keyboard.alias: Set alias expansion
2059 \begin_layout Itemize
2060 Syntax: none keyboard.alias(string alias, string expansion)
2063 \begin_layout Standard
2064 Set expansion of given command.
2067 \begin_layout Standard
2068 \begin_inset Newpage pagebreak
2074 \begin_layout Section
2078 \begin_layout Standard
2082 \begin_layout Subsection
2083 subtitle.byindex: Look up start and length of subtitle by index
2086 \begin_layout Itemize
2087 Syntax: (number, number) subtitle.byindex(number i)
2090 \begin_layout Standard
2091 Read the frame and length of ith subtitle.
2092 Returns nothing if not present.
2095 \begin_layout Subsection
2096 subtitle.set: Write a subtitle
2099 \begin_layout Itemize
2100 Syntax: none subtitle.set(number f, number l, string txt)
2103 \begin_layout Standard
2104 Set the text of subtitle.
2107 \begin_layout Subsection
2108 subtitle.get: Read a subtitle
2111 \begin_layout Itemize
2112 Syntax: string subtitle.get(number f, number l)
2115 \begin_layout Standard
2116 Get the text of subtitle.
2119 \begin_layout Subsection
2120 subtitle.delete: Delete a subtitle
2123 \begin_layout Itemize
2124 Syntax: nonesubtitle.delete(number f, number l)
2127 \begin_layout Standard
2128 Delete specified subtitle.
2131 \begin_layout Standard
2132 \begin_inset Newpage pagebreak
2138 \begin_layout Section
2142 \begin_layout Standard
2143 Host memory handling (extra memory saved to savestates).
2144 Host memory starts empty.
2147 \begin_layout Itemize
2148 Reads out of range return false.
2151 \begin_layout Itemize
2152 Writes out of range extend the memory.
2155 \begin_layout Subsection
2156 hostmemory.read: Read byte from host memory
2159 \begin_layout Itemize
2160 Syntax: number hostmemory.read(number address)
2163 \begin_layout Standard
2164 Reads byte from hostmemory slot address <address>.
2167 \begin_layout Subsection
2168 hostmemory.write: Write byte to host memory
2171 \begin_layout Itemize
2172 Syntax: none hostmemory.write(number address, number value)
2175 \begin_layout Standard
2176 Writes hostmemory slot with value <value> 0-255.
2179 \begin_layout Subsection
2180 hostmemory.read{,s}{byte,{,d,q}word}: Read from host memory
2183 \begin_layout Itemize
2184 Syntax: number hostmemory.readbyte(number address)
2187 \begin_layout Itemize
2188 Syntax: number hostmemory.readsbyte(number address)
2191 \begin_layout Itemize
2192 Syntax: number hostmemory.readword(number address)
2195 \begin_layout Itemize
2196 Syntax: number hostmemory.readsword(number address)
2199 \begin_layout Itemize
2200 Syntax: number hostmemory.readdword(number address)
2203 \begin_layout Itemize
2204 Syntax: number hostmemory.readsdword(number address)
2207 \begin_layout Itemize
2208 Syntax: number hostmemory.readqword(number address)
2211 \begin_layout Itemize
2212 Syntax: number hostmemory.readsqword(number address)
2215 \begin_layout Standard
2216 Read elements (little-endian) from given address <address>.
2219 \begin_layout Itemize
2223 \begin_layout Itemize
2227 \begin_layout Itemize
2231 \begin_layout Itemize
2232 qword is 8 elements.
2235 \begin_layout Itemize
2236 The 's' variants do signed read.
2239 \begin_layout Subsection
2240 hostmemory.write{,s}{byte,{,d,q}word}: Write to host memory
2243 \begin_layout Itemize
2244 Syntax: number hostmemory.writebyte(number address, number value)
2247 \begin_layout Itemize
2248 Syntax: number hostmemory.writesbyte(number address, number value)
2251 \begin_layout Itemize
2252 Syntax: number hostmemory.writeword(number address, number value)
2255 \begin_layout Itemize
2256 Syntax: number hostmemory.writesword(number address, number value)
2259 \begin_layout Itemize
2260 Syntax: number hostmemory.writedword(number address, number value)
2263 \begin_layout Itemize
2264 Syntax: number hostmemory.writesdword(number address, number value)
2267 \begin_layout Itemize
2268 Syntax: number hostmemory.writeqword(number address, number value)
2271 \begin_layout Itemize
2272 Syntax: number hostmemory.writesqword(number address, number value)
2275 \begin_layout Standard
2276 Write value <value> to elements (little-endian) starting from given address
2280 \begin_layout Itemize
2284 \begin_layout Itemize
2288 \begin_layout Itemize
2292 \begin_layout Itemize
2293 qword is 8 elements.
2296 \begin_layout Itemize
2297 The 's' variants do signed write.
2300 \begin_layout Standard
2301 \begin_inset Newpage pagebreak
2307 \begin_layout Section
2311 \begin_layout Standard
2315 \begin_layout Subsection
2316 movie.currentframe: Get current frame number
2319 \begin_layout Itemize
2320 Syntax: number movie.currentframe()
2323 \begin_layout Standard
2324 Return number of current frame.
2327 \begin_layout Subsection
2328 movie.framecount: Get move frame count
2331 \begin_layout Itemize
2332 Syntax: number movie.framecount()
2335 \begin_layout Standard
2336 Return number of frames in movie.
2339 \begin_layout Subsection
2340 movie.readonly: Is in readonly mode?
2343 \begin_layout Itemize
2344 Syntax: boolean movie.readonly()
2347 \begin_layout Standard
2348 Return true if in readonly mode, false if in readwrite.
2351 \begin_layout Subsection
2352 movie.rerecords: Movie rerecord count
2355 \begin_layout Itemize
2356 Syntax: number movie.rerecords()
2359 \begin_layout Standard
2360 Returns the current value of rerecord count.
2363 \begin_layout Subsection
2364 movie.set_readwrite: Set read-write mode.
2367 \begin_layout Itemize
2368 Syntax: none movie.set_readwrite()
2371 \begin_layout Standard
2372 Set readwrite mode (does not cause on_readwrite callback).
2375 \begin_layout Subsection
2376 movie.frame_subframes: Count subframes in frame
2379 \begin_layout Itemize
2380 Syntax: number movie.frame_subframes(number frame)
2383 \begin_layout Standard
2384 Count number of subframes in specified frame <frame> (frame numbers are
2385 1-based) and return that.
2388 \begin_layout Subsection
2389 movie.read_subframes: Read subframe data (deprecated)
2392 \begin_layout Itemize
2393 Syntax: table movie.read_subframes(number frame, number subframe)
2396 \begin_layout Standard
2397 Read specifed subframe in specified frame and return data as array.
2400 \begin_layout Subsection
2401 movie.read_rtc: Read current RTC time
2404 \begin_layout Itemize
2405 Syntax: (number, number) movie.read_rtc()
2408 \begin_layout Standard
2409 Returns the current value of the RTC as a pair (second, subsecond).
2412 \begin_layout Subsection
2413 movie.unsafe_rewind: Fast movie rewind to saved state
2416 \begin_layout Itemize
2417 Syntax: none movie.unsafe_rewind([UNSAFEREWIND state])
2420 \begin_layout Standard
2421 Start setting point for unsafe rewind or jump to point of unsafe rewind.
2424 \begin_layout Itemize
2425 If called without argument, causes emulator to start process of setting
2426 unsafe rewind point.
2427 When this has finished, callback on_set_rewind occurs, passing the rewind
2428 state to lua script.
2431 \begin_layout Itemize
2432 If called with argument, causes emulator rewind to passed rewind point as
2434 Readwrite mode is implicitly activated.
2437 \begin_layout Standard
2438 The following warnings apply to unsafe rewinding:
2441 \begin_layout Itemize
2442 There are no safety checks against misuse (that's what
2443 \begin_inset Quotes eld
2447 \begin_inset Quotes erd
2453 \begin_layout Itemize
2454 Only call rewind from timeline rewind point was set from.
2457 \begin_layout Itemize
2458 Only call rewind from after the rewind point was set.
2461 \begin_layout Subsection
2462 movie.to_rewind: Load savestate as rewind point
2465 \begin_layout Itemize
2466 Syntax: UNSAFEREWIND movie.to_rewind(string filename)
2469 \begin_layout Standard
2470 Load specified savestate file <filename> as rewind point and return UNSAFEREWIND
2471 corresponding to it.
2474 \begin_layout Itemize
2475 Note: This operation does not take emulated time.
2478 \begin_layout Subsection
2479 movie.copy_movie/INPUTMOVIE::copy_movie: Copy movie to movie object
2482 \begin_layout Itemize
2483 Syntax: INPUTMOVIE movie.copy_movie([INPUTMOVIE movie])
2486 \begin_layout Itemize
2487 Syntax: INPUTMOVIE INPUTMOVIE::copy_movie()
2490 \begin_layout Standard
2491 Copies specified movie <movie>/current object (if none or nil, the active
2492 movie) as new movie object.
2495 \begin_layout Subsection
2496 movie.get_frame/INPUTMOVIE::get_frame: Read specified frame in movie.
2499 \begin_layout Itemize
2500 Syntax: INPUTFRAME movie.get_frame([INPUTMOVIE movie,] number frame)
2503 \begin_layout Itemize
2504 Syntax: INPUTFRAME INPUTMOVIE::get_frame(number frame);
2507 \begin_layout Standard
2508 Get INPUTFRAME object corresponding to specified frame in specified movie.
2511 \begin_layout Subsection
2512 movie.set_frame/INPUTMOVIE::set_frame: Write speicifed frame in movie.
2515 \begin_layout Itemize
2516 Syntax: none movie.set_frame([INPUTMOVIE movie,] number frame, INPUTFRAME
2520 \begin_layout Itemize
2521 Syntax: none INPUTMOVIE::set_frame(number frame, INPUTFRAME data)
2524 \begin_layout Standard
2525 Set data in specified frame.
2528 \begin_layout Itemize
2529 Note: Past can't be edited in active movie.
2532 \begin_layout Subsection
2533 movie.get_size/INPUTMOVIE::get_size: Get size of movie
2536 \begin_layout Itemize
2537 Syntax: integer movie.get_size([INPUTMOVIE movie])
2540 \begin_layout Itemize
2541 Syntax: integer INPUTMOVIE::get_size()
2544 \begin_layout Standard
2545 Return number of subframes in specified movie.
2548 \begin_layout Subsection
2549 movie.count_frames/INPUTMOVIE::count_frames: Count frames in movie
2552 \begin_layout Itemize
2553 Syntax: number movie.count_frames([INPUTMOVIE movie])
2556 \begin_layout Itemize
2557 Syntax: number INPUTMOVIE::count_frames()
2560 \begin_layout Standard
2561 Return number of frames in movie.
2564 \begin_layout Subsection
2565 movie.find_frame/INPUTMOVIE::find_frame: Find subframe corresponding to frame
2568 \begin_layout Itemize
2569 Syntax: number movie.find_frame([INPUTMOVIE movie], number frame)
2572 \begin_layout Itemize
2573 Syntax: number INPUTMOVIE::find_frame(number frame)
2576 \begin_layout Standard
2577 Returns starting subframe of given frame (frame numbers are 1-based).
2578 Returns -1 if frame number is bad.
2581 \begin_layout Subsection
2582 movie.blank_frame/INPUTMOVIE::blank_frame: Return a blank frame
2585 \begin_layout Itemize
2586 Syntax: INPUTFRAME movie.blank_frame([INPUTMOVIE movie])
2589 \begin_layout Itemize
2590 Syntax: INPUTFRAME INPUTMOVIE::blank_frame()
2593 \begin_layout Standard
2594 Return blank INPUTFRAME with frame type from specified movie.
2597 \begin_layout Subsection
2598 movie.append_frames/INPUTMOVIE::append_frames: Append blank frames
2601 \begin_layout Itemize
2602 Syntax: none movie.append_frames([INPUTMOVIE movie,] number frames)
2605 \begin_layout Itemize
2606 Syntax: none INPUTMOVIE::append_frames(number frames)
2609 \begin_layout Standard
2610 Append specified number <frames> of frames.
2613 \begin_layout Subsection
2614 movie.append_frame/INPUTMOVIE::append_frame: Append a frame
2617 \begin_layout Itemize
2618 Syntax: none movie.append_frame([INPUTMOVIE movie,] INPUTFRAME frame)
2621 \begin_layout Itemize
2622 Syntax: none INPUTMOVIE::append_frame(INPUTFRAME frame)
2625 \begin_layout Standard
2626 Append specified frame <frame>.
2627 Past of current movie can't be edited.
2630 \begin_layout Subsection
2631 movie.truncate/INPUTMOVIE::truncate: Truncate a movie.
2634 \begin_layout Itemize
2635 Syntax: none movie.truncate([INPUTMOVIE movie,] number frames)
2638 \begin_layout Itemize
2639 Syntax: none INPUTMOVIE::truncate(number frames)
2642 \begin_layout Standard
2643 Truncate the specified movie to specified number of frames.
2646 \begin_layout Subsection
2647 movie.edit/INPUTMOVIE::edit: Edit a movie
2650 \begin_layout Itemize
2651 Syntax: none movie.edit([INPUTMOVIE movie,] number frame, number port, number
2652 controller, number control, number/bool value)
2655 \begin_layout Itemize
2656 Syntax: none INPUTMOVIE::edit(number frame, number port, number controller,
2657 number control, number/bool value)
2660 \begin_layout Standard
2661 Change specified control in specified frame in specified movie.
2662 Past can't be edited in active movie.
2665 \begin_layout Subsection
2666 movie.copy_frames2: Copy frames between movies
2669 \begin_layout Itemize
2670 Syntax: none movie.copy_frames2([INPUTMOVIE dstmov,] number dst, [INPUTMOVIE
2671 srcmov,] number src, number count)
2674 \begin_layout Standard
2675 Copy specified number of frames between two movies.
2676 The copy proceeeds in forward direction.
2679 \begin_layout Subsection
2680 movie.copy_frames/INPUTMOVIE::copy_frames: Copy frames in movie
2683 \begin_layout Itemize
2684 Syntax: none movie.copy_frames([INPUTMOVIE mov,] number dst, number src,
2685 number count, bool backwards)
2688 \begin_layout Itemize
2689 Syntax: none INPUTMOVIE::copy_frames(number dst, number src, number count,
2693 \begin_layout Standard
2694 Copy specified number of frames from one point in movie to another.
2695 If backwards is true, the copy will be done backwards.
2698 \begin_layout Subsection
2699 movie.serialize/INPUTMOVIE::serialize: Serialize movie
2702 \begin_layout Itemize
2703 Syntax: none movie.serialize([INPUTMOVIE movie,] string filename, bool binary)
2706 \begin_layout Itemize
2707 Syntax: none INPUTMOIVE::serialize(string filename, bool binary)
2710 \begin_layout Standard
2711 Serialize given movie into file.
2712 If binary is true, binary format (more compact and much faster) is used.
2715 \begin_layout Subsection
2716 movie.unserialize: Unserialize movie
2719 \begin_layout Itemize
2720 Syntax: INPUTMOVIE movie.unserialize(INPUTFRAME template, string filename,
2724 \begin_layout Standard
2725 Unserialize movie from file.
2726 The given frame is used as template to decide the frame type.
2727 If binary is true, binary format is decoded (much faster).
2730 \begin_layout Subsection
2731 movie.current_first_subframe: Return first subframe in current frame
2734 \begin_layout Itemize
2735 Syntax: number movie.current_first_subframe()
2738 \begin_layout Standard
2739 Returns first subframe in current frame.
2742 \begin_layout Subsection
2743 movie.pollcounter: Return poll counter for speified control
2746 \begin_layout Itemize
2747 Syntax: number movie.pollcounter(number port, number controller, number control)
2750 \begin_layout Standard
2751 Returns number of times the specified control has been polled this frame.
2754 \begin_layout Subsection
2755 INPUTFRAME::get_button: Get button
2758 \begin_layout Itemize
2759 Syntax: boolean INPUTFRAME::get_button(number port, number controller, number
2763 \begin_layout Standard
2764 Returns state of given button as boolean.
2767 \begin_layout Subsection
2768 INPUTFRAME::get_axis: Get axis
2771 \begin_layout Itemize
2772 Syntax: number INPUTFRAME::get_axis(number port, number controller, number
2776 \begin_layout Standard
2777 Returns state of given axis as number.
2780 \begin_layout Subsection
2781 INPUTFRAME::set_button/INPUTFRAME::set_axis: Set button or axis
2784 \begin_layout Itemize
2785 Syntax: none INPUTFRAME::set_button(number port, number controller, number
2786 control, number/bool value)
2789 \begin_layout Itemize
2790 Syntax: none INPUTFRAME::set_axis(number port, number controller, number
2794 \begin_layout Standard
2795 Set the given button/axis to given value.
2798 \begin_layout Subsection
2799 INPUTFRAME::serialize: Serialize a frame
2802 \begin_layout Itemize
2803 Syntax: string INPUTFRAME::serialize()
2806 \begin_layout Standard
2807 Return string representation of frame.
2810 \begin_layout Subsection
2811 INPUTFRAME::unserialize: Unserialize a frame
2814 \begin_layout Itemize
2815 Syntax: none INPUTFRAME::unserialize(string data)
2818 \begin_layout Standard
2819 Set current frame from given data.
2822 \begin_layout Subsection
2823 INPUTFRAME::get_stride: Get movie stride
2826 \begin_layout Itemize
2827 Syntax: number INPUTFRAME::get_stride()
2830 \begin_layout Standard
2831 Return number of bytes needed to store the input frame.
2832 Mainly useful for some debugging.
2835 \begin_layout Standard
2836 \begin_inset Newpage pagebreak
2842 \begin_layout Section
2846 \begin_layout Standard
2847 Routines for settings manipulation
2850 \begin_layout Subsection
2851 settings.get: Get value of setting
2854 \begin_layout Itemize
2855 Syntax: string settings.get(string name)
2858 \begin_layout Standard
2859 Get value of setting <name>.
2860 If setting value can't be obtained, returns (nil, error message).
2863 \begin_layout Subsection
2864 settings.set: Set value of setting
2867 \begin_layout Itemize
2868 Syntax: none settings.set(string name, string value)
2871 \begin_layout Standard
2872 Set value <value> of setting <name>.
2873 If setting can't be set, returns (nil, error message).
2876 \begin_layout Standard
2877 \begin_inset Newpage pagebreak
2883 \begin_layout Section
2887 \begin_layout Standard
2888 Contains various functions for managing memory
2891 \begin_layout Subsection
2892 memory.vma_count: Count number of VMAs.
2895 \begin_layout Itemize
2896 Syntax: number memory.vma_count()
2899 \begin_layout Standard
2900 Returns the number of VMAs
2903 \begin_layout Subsection
2904 memory.read_vma: Lookup VMA info by index
2907 \begin_layout Itemize
2908 Syntax: string memory.read_vma(number index)
2911 \begin_layout Standard
2912 Reads the specified VMA (indices start from zero).
2913 Trying to read invalid VMA gives nil.
2914 The read VMA is table with the following fields:
2917 \begin_layout Itemize
2918 region_name (string): The readable name of the VMA
2921 \begin_layout Itemize
2922 baseaddr (number): Base address of the VMA
2925 \begin_layout Itemize
2926 lastaddr (number): Last address in the VMA.
2929 \begin_layout Itemize
2930 size (number): The size of VMA in bytes.
2933 \begin_layout Itemize
2934 readonly (boolean): True of the VMA corresponds to ROM.
2937 \begin_layout Itemize
2938 iospace (boolean): True if the VMA is I/O space.
2941 \begin_layout Itemize
2942 native_endian (boolean): True if the VMA has native endian as opposed to
2946 \begin_layout Subsection
2947 memory.find_vma: Find VMA info by address
2950 \begin_layout Itemize
2951 Syntax: table memory.find_vma(number address)
2954 \begin_layout Standard
2955 Finds the VMA containing specified address.
2956 Returns table in the same format as read_vma or nil if not found.
2959 \begin_layout Subsection
2960 memory.read{,s}{byte,{,d,q}word}: Write memory
2963 \begin_layout Itemize
2964 Syntax: none memory.readbyte([string vma, ]number address)
2967 \begin_layout Itemize
2968 Syntax: none memory.readword([string vma, ]number address)
2971 \begin_layout Itemize
2972 Syntax: none memory.readdword([string vma, ]number address)
2975 \begin_layout Itemize
2976 Syntax: none memory.readqword([string vma, ]number address)
2979 \begin_layout Itemize
2980 Syntax: none memory.readsbyte([string vma, ]number address)
2983 \begin_layout Itemize
2984 Syntax: none memory.readsword([string vma, ]number address)
2987 \begin_layout Itemize
2988 Syntax: none memory.readsdword([string vma, ]number address)
2991 \begin_layout Itemize
2992 Syntax: none memory.readsqword([string vma, ]number address)
2995 \begin_layout Standard
2996 Reads the specified address <ddress> (if 's' variant is used, do undergo
3000 \begin_layout Subsection
3001 memory.write{byte,{,d,q}word}: Write memory
3004 \begin_layout Itemize
3005 Syntax: none memory.writebyte([string vma, ]number address, number value)
3008 \begin_layout Itemize
3009 Syntax: none memory.writeword([string vma, ]number address, number value)
3012 \begin_layout Itemize
3013 Syntax: none memory.writedword([string vma, ]number address, number value)
3016 \begin_layout Itemize
3017 Syntax: none memory.writeqword([string vma, ]number address, number value)
3020 \begin_layout Standard
3021 Writes the specified value <value> (negative values undergo 2's complement)
3022 to specified address <address>.
3025 \begin_layout Subsection
3026 memory.map{,s}{byte,{,d,q}word}: Map an array
3029 \begin_layout Itemize
3030 Syntax: userdata memory.map<type>([[string vma, ]number base, number size])
3033 \begin_layout Standard
3034 Returns a table mapping specified memory aperture for read/write.
3035 If parameters are omitted, entiere map space is the aperture.
3038 \begin_layout Itemize
3039 Type may be one of: byte, sbyte, word, sword, dword, sdword, qword or sqword.
3042 \begin_layout Subsection
3043 memory.hash_region: Hash region of memory
3046 \begin_layout Itemize
3047 Syntax: string memory.hash_region([string vma, ]number base, number size)
3050 \begin_layout Standard
3051 Hash specified number of bytes starting from specified address and return
3055 \begin_layout Subsection
3056 memory.hash_state: Hash system state
3059 \begin_layout Itemize
3060 Syntax: string memory.hash_state()
3063 \begin_layout Standard
3064 Hash the current system state.
3065 Mainly useful for debugging savestates.
3068 \begin_layout Subsection
3069 memory.readregion: Read region of memory
3072 \begin_layout Itemize
3073 Syntax: table memory.readregion([string vma, ]number base, number size)
3076 \begin_layout Standard
3077 Read a region of memory.
3080 \begin_layout Itemize
3081 Warning: If the region crosses VMA boundary, the results are undefined.
3084 \begin_layout Subsection
3085 memory.writeregion: Write region of memory
3088 \begin_layout Itemize
3089 Syntax: none memory.writeregion([string vma, ]number base, number size, table
3093 \begin_layout Standard
3094 Write a region of memory.
3097 \begin_layout Itemize
3098 Warning: If the region crosses VMA boundary, the results are undefined.
3101 \begin_layout Subsection
3102 memory.map_structure: Create mmap structure
3105 \begin_layout Itemize
3106 syntax: MMAP_STRUCT memory.map_structure()
3109 \begin_layout Standard
3110 Returns a new mapping structure (MMAP_STRUCT)
3113 \begin_layout Subsection
3114 MMAP_STRUCT(): Bind key in mmap structure
3117 \begin_layout Itemize
3118 Syntax: none MMAP_STRUCT(string key, [string vma, ]number address, string
3122 \begin_layout Standard
3123 Bind key <key> in mmap structure to specified address <address> with specified
3127 \begin_layout Itemize
3128 Type may be one of: byte, sbyte, word, sword, dword, sdword, qword or sqword.
3131 \begin_layout Subsection
3132 memory.read_expr: Evaluate memory watch expression
3135 \begin_layout Itemize
3136 Syntax: string memory.read_expr(string expr)
3139 \begin_layout Standard
3140 Evaluate specified watch expression and return result
3143 \begin_layout Subsection
3144 memory.action: Run core action
3147 \begin_layout Itemize
3148 memory.action(string action, [<params>])
3151 \begin_layout Standard
3153 The different models expect parameters as:
3156 \begin_layout Itemize
3160 \begin_layout Itemize
3164 \begin_layout Itemize
3168 \begin_layout Itemize
3172 \begin_layout Itemize
3176 \begin_layout Subsection
3177 memory.get_lag_flag: Get lag flag
3180 \begin_layout Itemize
3181 Syntax: boolean memory.get_lag_flag()
3184 \begin_layout Standard
3185 Get the value of core lag flag.
3186 True if this frame has been lag so far, false if poll has been detected.
3189 \begin_layout Subsection
3190 memory.set_lag_flag: Set lag flag
3193 \begin_layout Itemize
3194 Syntax: none memory.set_lag_flag(boolean flag)
3197 \begin_layout Standard
3198 Set the value of core lag flag.
3199 This flag automatically gets cleared if poll is detected, but can be forcibly
3200 set or cleared if game so requires.
3203 \begin_layout Itemize
3204 Should only be used in on_frame_emulated callback.
3207 \begin_layout Itemize
3208 Setting or clearing this affects the emulator lag counter.
3211 \begin_layout Standard
3212 \begin_inset Newpage pagebreak
3218 \begin_layout Section
3222 \begin_layout Standard
3223 Contains newer memory functions.
3226 \begin_layout Subsection
3227 memory2(): Get all VMA names.
3230 \begin_layout Itemize
3231 Syntax: table memory2()
3234 \begin_layout Standard
3235 Returns array of all valid VMA names.
3238 \begin_layout Subsection
3239 memory2.<vma>:info: Get VMA info
3242 \begin_layout Itemize
3243 Syntax: table memory2.<vma>:info()
3246 \begin_layout Standard
3247 Return table describing given VMA.
3248 Includes fields address, size, last, readonly, special and endian.
3251 \begin_layout Subsection
3252 memory2.<vma>:<op>: Read/Write memory
3255 \begin_layout Itemize
3256 Syntax: none memory2.<vma>:<op>(number offset, number value)
3259 \begin_layout Itemize
3260 Syntax: number memory2.<vma>:<op>(number offset)
3263 \begin_layout Standard
3264 Read/Write value from/to given VMA <vma> at given offset <offset> (must
3266 The value written is <value>.
3267 <Op> is of form: [i][s]<type>, where:
3270 \begin_layout Itemize
3271 <type> is one of 'byte', 'word', 'dword', 'qword'.
3274 \begin_layout Itemize
3275 'i' signifies that the value is treated as opposite-to-normal endianess,
3278 \begin_layout Itemize
3279 's' signifies that value is treated as signed.
3282 \begin_layout Standard
3283 \begin_inset Newpage pagebreak
3289 \begin_layout Section
3293 \begin_layout Standard
3294 Various callback-related functions.
3297 \begin_layout Subsection
3298 \begin_inset CommandInset label
3300 name "sub:callback.register:-Register-a"
3304 callback.register: Register a callback
3307 \begin_layout Itemize
3308 Syntax: function callback.register(string cbname, function cbfun);
3311 \begin_layout Standard
3312 Instruct function <cbfun> to be added to list of callbacks to call on event
3313 <cbname> (See section
3314 \begin_inset CommandInset ref
3316 reference "sec:Callbacks"
3321 The callback name does not have the 'on_' prefix (e.g.
3323 \begin_inset Quotes eld
3327 \begin_inset Quotes erd
3334 \begin_layout Subsection
3335 \begin_inset CommandInset label
3337 name "sub:callback.unregister:-Unregister-"
3341 callback.unregister: Unregister a callback
3344 \begin_layout Itemize
3345 Syntax: function callback.unregister(string cbname, function cbfun);
3348 \begin_layout Standard
3349 Instruct function <cbfun> to be removed from list of callbacks to call on
3353 \begin_layout Subsection
3354 callback.<cbname>:register: Register callback
3357 \begin_layout Itemize
3358 Syntax: function callback.<cbname>:register(function cbfun)
3361 \begin_layout Standard
3362 Synonym for callback.register (section
3363 \begin_inset CommandInset ref
3365 reference "sub:callback.register:-Register-a"
3369 ), albeit with callback name specified differently.
3372 \begin_layout Subsection
3373 callback.<cbname>:unregister: Register callback
3376 \begin_layout Itemize
3377 Syntax: function callback.<cbname>:unregister(function cbfun)
3380 \begin_layout Standard
3381 Synonym for callback.unregister (section
3382 \begin_inset CommandInset ref
3384 reference "sub:callback.unregister:-Unregister-"
3388 ), albeit with callback name specified differently.
3391 \begin_layout Section
3395 \begin_layout Standard
3396 Contains copy of global variables from time of Lua initialization.
3400 \begin_layout Standard
3401 \begin_inset Newpage pagebreak
3407 \begin_layout Section
3408 \begin_inset CommandInset label
3410 name "sec:Callbacks"
3417 \begin_layout Standard
3418 Various callbacks to Lua that can occur.
3421 \begin_layout Subsection
3422 on_paint: Screen is being painted
3425 \begin_layout Itemize
3426 Callback: on_paint(bool not_synth)
3429 \begin_layout Standard
3430 Called when screen is being painted.
3431 Any gui.* calls requiring graphic context draw on the screen.
3434 \begin_layout Itemize
3435 not_synth is true if this hook is being called in response to received frame,
3439 \begin_layout Subsection
3440 on_video: Dumped video frame is being painted
3443 \begin_layout Itemize
3444 Callback: on_video()
3447 \begin_layout Standard
3448 Called when video dump frame is being painted.
3449 Any gui.* calls requiring graphic context draw on the video.
3452 \begin_layout Subsection
3453 on_frame_emulated: Frame emulation complete
3456 \begin_layout Itemize
3457 Callback: on_frame_emulated()
3460 \begin_layout Standard
3461 Called when emulating frame has completed and on_paint()/on_video() calls
3462 are about to be issued.
3465 \begin_layout Subsection
3466 on_frame: Frame emulation starting.
3469 \begin_layout Itemize
3470 Callback: on_frame()
3473 \begin_layout Standard
3474 Called on each starting whole frame.
3477 \begin_layout Subsection
3478 on_startup: Emulator startup complete
3481 \begin_layout Itemize
3482 Callback: on_startup()
3485 \begin_layout Standard
3486 Called when the emulator is starting (lsnes.rc and --run files has been run).
3489 \begin_layout Subsection
3490 on_rewind: Movie rewound to beginning
3493 \begin_layout Itemize
3494 Callback: on_rewind()
3497 \begin_layout Standard
3498 Called when rewind movie to beginning has completed.
3501 \begin_layout Subsection
3502 on_pre_load: Load operation is about to start
3505 \begin_layout Itemize
3506 Callback: on_pre_load(string name)
3509 \begin_layout Standard
3510 Called just before savestate/movie load occurs (note: loads are always delayed,
3511 so this occurs even when load was initiated by lua).
3514 \begin_layout Subsection
3515 on_err_Load: Load failed
3518 \begin_layout Itemize
3519 Callback: on_err_load(string name)
3522 \begin_layout Standard
3523 Called if loadstate goes wrong.
3526 \begin_layout Subsection
3527 on_post_load: Load completed
3530 \begin_layout Itemize
3531 Callback: on_post_load(string name, boolean was_savestate)
3534 \begin_layout Standard
3535 Called on successful loadstate.
3536 was_savestate gives if this was a savestate or a movie.
3539 \begin_layout Subsection
3540 on_pre_save: Save operation is about to start
3543 \begin_layout Itemize
3544 Callback: on_pre_save(string name, boolean is_savestate)
3547 \begin_layout Standard
3548 Called just before savestate save occurs (note: movie saves are synchronous
3549 and won't trigger these callbacks if called from Lua).
3552 \begin_layout Subsection
3553 on_err_save: Save failed
3556 \begin_layout Itemize
3557 Callback: on_err_save(string name)
3560 \begin_layout Standard
3561 Called if savestate goes wrong.
3564 \begin_layout Subsection
3565 on_post_save: Save completed
3568 \begin_layout Itemize
3569 Callback: on_post_save(string name, boolean is_savestate)
3572 \begin_layout Standard
3573 Called on successful savaestate.
3574 is_savestate gives if this was a savestate or a movie.
3577 \begin_layout Subsection
3578 on_quit: Emulator is shutting down
3581 \begin_layout Itemize
3585 \begin_layout Standard
3586 Called when emulator is shutting down.
3589 \begin_layout Subsection
3590 on_input: Polling for input
3593 \begin_layout Standard
3594 Called when emulator is just sending input to bsnes core.
3595 Warning: This is called even in readonly mode, but the results are ignored.
3598 \begin_layout Subsection
3599 on_reset: System has been reset
3602 \begin_layout Itemize
3603 Callback: on_reset()
3606 \begin_layout Standard
3607 Called when system is reset.
3610 \begin_layout Subsection
3611 on_readwrite: Entered readwrite mode
3614 \begin_layout Itemize
3615 Callback: on_readwrite()
3618 \begin_layout Standard
3619 Called when moving into readwrite mode as result of
3620 \begin_inset Quotes eld
3624 \begin_inset Quotes erd
3627 command (note: moving to rwmode by Lua won't trigger this, as per recursive
3631 \begin_layout Subsection
3632 on_snoop/on_snoop2: Snoop core controller reads
3635 \begin_layout Itemize
3636 Callback: on_snoop(number port, number controller, number index, number
3640 \begin_layout Itemize
3641 Callback: on_snoop2(number port, number controller, number index, number
3645 \begin_layout Standard
3646 Called each time bsnes asks for input.
3647 The value is the final value to be sent to bsnes core (readonly mode, autohold
3648 and autofire have been taken into account).
3649 Might be useful when translating movies to format suitable for console
3651 Note: There is no way to modify the value to be sent.
3654 \begin_layout Itemize
3655 On_snoop2 is called instead of on_snoop if defined.
3656 Reserves port 0 for system, having first user port be port 1.
3659 \begin_layout Subsection
3660 on_keyhook: Hooked key/axis has been moved
3663 \begin_layout Itemize
3664 Callback: on_keyhook(string keyname, table state)
3667 \begin_layout Standard
3668 Sent when key that has keyhook events requested changes state.
3669 Keyname is name of the key (group) and state is the state (same kind as
3670 table values in input.raw).
3673 \begin_layout Subsection
3677 \begin_layout Itemize
3681 \begin_layout Standard
3682 Called when requested by set_idle_timeout(), the timeout has expired and
3683 emulator is waiting.
3686 \begin_layout Subsection
3687 on_timer: Timer event
3690 \begin_layout Itemize
3691 Callback: on_timer()
3694 \begin_layout Standard
3695 Called when requested by set_idle_timeout() and the timeout has expired
3696 (regardless if emulator is waiting).
3699 \begin_layout Subsection
3700 on_set_rewind: Rewind point has been set
3703 \begin_layout Itemize
3704 Callback: on_set_rewind(UNSAFEREWIND r)
3707 \begin_layout Standard
3708 Called when unsafe rewind object has been constructed.
3711 \begin_layout Subsection
3712 on_pre_rewind: Rewind is about to occur
3715 \begin_layout Itemize
3716 Callback: on_pre_rewind()
3719 \begin_layout Standard
3720 Called just before unsafe rewind is about to occur.
3723 \begin_layout Subsection
3724 on_post_rewind: Rewind has occured
3727 \begin_layout Itemize
3728 Callback: on_post_rewind()
3731 \begin_layout Standard
3732 Called just after unsafe rewind has occured.
3735 \begin_layout Subsection
3736 on_button: Button has been pressed
3739 \begin_layout Itemize
3740 Callback: on_button(number port, number controller, number index, string
3744 \begin_layout Standard
3745 Called on controller button press, with following parameters:
3748 \begin_layout Itemize
3749 port: Port number (0 is system)
3752 \begin_layout Itemize
3753 controller: Controller within port
3756 \begin_layout Itemize
3757 index: Index of button.
3760 \begin_layout Itemize
3761 type: Type of event, one of:
3765 \begin_layout Itemize
3766 \begin_inset Quotes eld
3770 \begin_inset Quotes erd
3773 : Button was pressed.
3776 \begin_layout Itemize
3777 \begin_inset Quotes eld
3781 \begin_inset Quotes erd
3784 : Button was released.
3787 \begin_layout Itemize
3788 \begin_inset Quotes eld
3792 \begin_inset Quotes erd
3798 \begin_layout Itemize
3799 \begin_inset Quotes eld
3803 \begin_inset Quotes erd
3806 : Released from hold.
3809 \begin_layout Itemize
3810 \begin_inset Quotes eld
3814 \begin_inset Quotes erd
3817 : Typing input on button.
3820 \begin_layout Itemize
3821 \begin_inset Quotes eld
3825 \begin_inset Quotes erd
3828 : Typing input undone.
3831 \begin_layout Itemize
3832 \begin_inset Quotes eld
3835 autofire <duty> <cycle>
3836 \begin_inset Quotes erd
3839 : Autofire with specifie duty and cycle.
3842 \begin_layout Itemize
3843 \begin_inset Quotes eld
3847 \begin_inset Quotes erd
3853 \begin_layout Itemize
3854 \begin_inset Quotes eld
3858 \begin_inset Quotes erd
3861 : Analog action on axis.
3865 \begin_layout Subsection
3866 on_movie_lost: Movie data is about to be lost
3869 \begin_layout Itemize
3870 Callback: on_movie_lost(STRING kind)
3873 \begin_layout Standard
3874 Called just before something would happen that could lose movie data.
3878 \begin_layout Itemize
3879 readwrite: Switching to readwrite mode.
3882 \begin_layout Itemize
3883 reload: ROM is being reloaded in readwrite mode.
3886 \begin_layout Itemize
3887 load: New movie is being loaded.
3890 \begin_layout Itemize
3891 unsaferewind: Unsafe rewind is happening.