DialogResultresult=MessageBox.Show("You have unsaved changes for this script - would you like to save them?","Script Window",MessageBoxButtons.YesNoCancel);
DialogResultresult=MessageBox.Show("You have unsaved changes for this script and the file has been modified by another process - would you like to discard the changes and reload the script from the disk?","Script Window",MessageBoxButtons.YesNo);
newList<string>{"func","emu.addEventCallback","emu.addEventCallback(function, type)","function - A Lua function.\ntype - *Enum* See eventType.","Returns an integer value that can be used to remove the callback by calling removeEventCallback.","Registers a callback function to be called whenever the specified event occurs.",},
newList<string>{"func","emu.removeEventCallback","emu.removeEventCallback(reference, type)","reference - The value returned by the call to addEventCallback.\ntype - *Enum* See eventType.","","Removes a previously registered callback function.",},
newList<string>{"func","emu.addMemoryCallback","emu.addMemoryCallback(function, type, startAddress, endAddress)","function - A Lua function.\ntype - *Enum* See memCallbackType\nstartAddress - *Integer* Start of the CPU memory address range to register the callback on.\nendAddress - (optional) *Integer* End of the CPU memory address range to register the callback on.","Returns an integer value that can be used to remove the callback by callingremoveMemoryCallback.","Registers a callback function to be called whenever the specified event occurs."},
newList<string>{"func","emu.removeMemoryCallback","emu.removeMemoryCallback(reference, type, startAddress, endAddress)","reference - The value returned by the call to addMemoryCallback.\ntype - *Enum* See memCallbackType.\nstartAddress - *Integer* Start of the CPU memory address range to unregister the callback from.\nendAddress - (optional) *Integer* End of the CPU memory address range to unregister the callback from.","","Removes a previously registered callback function."},
newList<string>{"func","emu.read","emu.read(address, type, signed)","address - *Integer* The address/offset to read from.\ntype - *Enum* The type of memory to read from. See memType.\nsigned - (optional) *Boolean* If true, the value returned will be interpreted as a signed value.","An 8-bit (read) or 16-bit (readWord) value.","Reads a value from the specified memory type.\n\nWhen calling read / readWord with the memType.cpu or memType.ppu memory types, emulation side-effects may occur.\nTo avoid triggering side-effects, use the memType.cpuDebug or memType.ppuDebug types, which will not cause side-effects."},
newList<string>{"func","emu.readWord","emu.readWord(address, type, signed)","address - *Integer* The address/offset to read from.\ntype - *Enum* The type of memory to read from. See memType.\nsigned - (optional) *Boolean* If true, the value returned will be interpreted as a signed value.","An 8-bit (read) or 16-bit (readWord) value.","Reads a value from the specified memory type.\n\nWhen calling read / readWord with the memType.cpu or memType.ppu memory types, emulation side-effects may occur.\nTo avoid triggering side-effects, use the memType.cpuDebug or memType.ppuDebug types, which will not cause side-effects."},
newList<string>{"func","emu.write","emu.write(address, value, type)","address - *Integer* The address/offset to write to.\nvalue - *Integer* The value to write.\ntype - *Enum* The type of memory to write to. See memType.","","Writes an 8-bit or 16-bit value to the specified memory type.\n\nNormally read-only types such as PRG-ROM or CHR-ROM can be written to when using memType.prgRom or memType.chrRom.\nChanges will remain in effect until a power cycle occurs.\nTo revert changes done to ROM, see revertPrgChrChanges.\n\nWhen calling write / writeWord with the memType.cpu or memType.ppu memory types, emulation side-effects may occur.\nTo avoid triggering side-effects, use the memType.cpuDebug or memType.ppuDebug types, which will not cause side-effects."},
newList<string>{"func","emu.writeWord","emu.writeWord(address, value, type)","address - *Integer* The address/offset to write to.\nvalue - *Integer* The value to write.\ntype - *Enum* The type of memory to write to. See memType.","","Writes an 8-bit or 16-bit value to the specified memory type.\n\nNormally read-only types such as PRG-ROM or CHR-ROM can be written to when using memType.prgRom or memType.chrRom.\nChanges will remain in effect until a power cycle occurs.\nTo revert changes done to ROM, see revertPrgChrChanges.\n\nWhen calling write / writeWord with the memType.cpu or memType.ppu memory types, emulation side-effects may occur.\nTo avoid triggering side-effects, use the memType.cpuDebug or memType.ppuDebug types, which will not cause side-effects."},
newList<string>{"func","emu.revertPrgChrChanges","emu.revertPrgChrChanges()","","","Reverts all modifications done to PRG-ROM and CHR-ROM via write/writeWord calls."},
newList<string>{"func","emu.drawPixel","emu.drawPixel(x, y, color, duration, delay)","x - *Integer* X position\ny - *Integer* Y position\ncolor - *Integer* Color\nduration - *Integer* Number of frames to display (Default: 1 frame)\ndelay - *Integer* Number of frames to wait before drawing the pixel (Default: 0 frames)","","Draws a pixel at the specified (x, y) coordinates using the specified color for a specific number of frames."},
newList<string>{"func","emu.drawLine","emu.drawLine(x, y, x2, y2, color, duration, delay)","x - *Integer* X position (start of line)\ny - *Integer* Y position (start of line)\nx2 - *Integer* X position (end of line)\ny2 - *Integer* Y position (end of line)\ncolor - *Integer* Color\nduration - *Integer* Number of frames to display (Default: 1 frame)\ndelay - *Integer* Number of frames to wait before drawing the line (Default: 0 frames)","","Draws a line between (x, y) to (x2, y2) using the specified color for a specific number of frames."},
newList<string>{"func","emu.drawRectangle","emu.drawRectangle(x, y, width, height, color, fill, duration, delay)","x - *Integer* X position\ny - *Integer* Y position\nwidth - *Integer* The rectangle's width\nheight - *Integer* The rectangle's height\ncolor - *Integer* Color\nfill - *Boolean* Whether or not to draw an outline, or a filled rectangle.\nduration - *Integer* Number of frames to display (Default: 1 frame)\ndelay - *Integer* Number of frames to wait before drawing the rectangle (Default: 0 frames)","","Draws a rectangle between (x, y) to (x+width, y+height) using the specified color for a specific number of frames.\nIf *fill* is false, only the rectangle's outline will be drawn."},
newList<string>{"func","emu.drawString","emu.drawString(x, y, text, textColor, backgroundColor, duration, delay)","x - *Integer* X position\ny - *Integer* Y position\ntext- *String* The text to display\ntextColor - *Integer* Color to use for the text\nbackgroundColor - *Integer* Color to use for the text's background color\nduration - *Integer* Number of frames to display (Default: 1 frame)\ndelay - *Integer* Number of frames to wait before drawing the text (Default: 0 frames)","","Draws text at (x, y) using the specified text and colors for a specific number of frames."},
newList<string>{"func","emu.getPixel","emu.getPixel(x, y)","x - *Integer* X position\ny - *Integer* Y position","*Integer* ARGB color","Returns the color (in ARGB format) of the PPU's output for the specified location."},
newList<string>{"func","emu.displayMessage","emu.displayMessage(category, text)","category - *String* The category is the portion shown between brackets[]\ntext - *String* Text to show on the screen","","Displays a message on the main window in the format '[category] text'"},
newList<string>{"func","emu.log","emu.log(text)","text - *String* Text to log","","Logs the given string in the script's log window - useful for debugging scripts."},
newList<string>{"func","emu.getState","emu.getState()","","* Table* Current emulation state","Return a table containing information about the state of the CPU, PPU, APU and cartridge."},
newList<string>{"func","emu.setState","emu.setState(state)","state - *Table* A table containing the state of the emulation to apply.","","Updates the CPU and PPU's state.\nThe* state* parameter must be a table in the same format as the one returned by getState()\nNote: the state of the APU or cartridge cannot be modified by using setState()."},
newList<string>{"func","emu.breakExecution","emu.breakExecution()","","","Breaks the execution of the game and displays the debugger window."},
newList<string>{"func","emu.execute","emu.execute(count, type)","count - *Integer* The number of cycles or instructions to run before breaking\ntype - *Enum* See executeCountType","","Runs the emulator for the specified number of cycles/instructions and then breaks the execution."},
newList<string>{"func","emu.reset","emu.reset()","","","Resets the current game."},
newList<string>{"func","emu.resume","emu.resume()","","","Resumes execution after breaking."},
newList<string>{"func","emu.rewind","emu.rewind(seconds)","seconds - *Integer* The number of seconds to rewind","","Instantly rewinds the emulation by the number of seconds specified.\n Note: this can only be called from within a 'StartFrame' event callback."},
newList<string>{"func","emu.getLabelAddress","emu.getLabelAddress(label)","label - *String* The label to look up.","","Returns the integer address of the given label."},
newList<string>{"func","emu.getScreenBuffer","emu.getScreenBuffer()","","*Array* 32-bit integers in ARGB format","Returns an array of ARGB values for the entire screen (256px by 240px) - can be used with emu.setScreenBuffer() to alter the frame."},
newList<string>{"func","emu.setScreenBuffer","emu.setScreenBuffer(screenBuffer)","screenBuffer - *Array* An array of 32-bit integers in ARGB format","","Replaces the current frame with the contents of the specified array."},
newList<string>{"func","emu.getAccessCounters","emu.getAccessCounters(counterMemType, counterOpType)","counterMemType - *Enum* A value from the emu.counterMemType enum\ncounterOpType - *Enum* A value from the emu.counterOpType enum","*Array* 32-bit integers","Returns an array of access counters for the specified memory and operation types."},
newList<string>{"func","emu.getPrgRomOffset","emu.getPrgRomOffset(address)","address - *Integer* A CPU address (Valid range: $0000-$FFFF)","*Integer* The corresponding byte offset in PRG ROM","Returns an integer representing the byte offset of the specified CPU address in PRG ROM based on the mapper's current configuration.\nReturns -1 when the specified address is not mapped to PRG ROM."},
newList<string>{"func","emu.getChrRomOffset","emu.getChrRomOffset(address)","address - *Integer* A PPU address (Valid range: $0000-$3FFF)","*Integer* The corresponding byte offset in CHR ROM","Returns an integer representing the byte offset of the specified PPU address in CHR ROM based on the mapper's current configuration.\nReturns -1 when the specified address is not mapped to CHR ROM."},
newList<string>{"func","emu.saveSavestate","emu.saveSavestate()","","*String* A string containing a binary blob representing the emulation's current state.","Creates a savestate and returns it as a binary string. (The savestate is not saved on disk)\n Note: this can only be called from within a “startFrame” event callback or “cpuExec” memory callback."},
newList<string>{"func","emu.loadSavestate","emu.loadSavestate(savestate)","savestate - *String* A binary blob representing a savestate, as returned by saveSavestate()","","Loads the specified savestate.\nNote: this can only be called from within a “startFrame” event callback or “cpuExec” memory callback."},
newList<string>{"func","emu.saveSavestateAsync","emu.saveSavestateAsync()","slotNumber - *Integer* A slot number to which the savestate data will be stored (slotNumber must be >= 0)","","Queues a save savestate request. As soon at the emulator is able to process the request, it will be saved into the specified slot.\nThis API is asynchronous because save states can only be taken in-between 2 CPU instructions, not in the middle of an instruction.\nWhen called while the CPU is in-between 2 instructions (e.g: inside the callback of an cpuExec or startFrame event),\nthe save state will be taken immediately and its data will be available via getSavestateData right after the call to saveSavestateAsync.\nThe savestate can be loaded by calling the loadSavestateAsync function."},
newList<string>{"func","emu.loadSavestateAsync","emu.loadSavestateAsync()","slotNumber - *Integer* The slot number to load the savestate data from (must be a slot number that was used in a preceding saveSavestateAsync call)","*Boolean* Returns true if the slot number was valid.","Queues a load savestate request. As soon at the emulator is able to process the request, the savestate will be loaded from the specified slot.\nThis API is asynchronous because save states can only be loaded in-between 2 CPU instructions, not in the middle of an instruction.\nWhen called while the CPU is in-between 2 instructions (e.g: inside the callback of an cpuExec or startFrame event), the savestate will be loaded immediately."},
newList<string>{"func","emu.getSavestateData","emu.getSavestateData()","slotNumber - *Integer* The slot number to get the savestate data from (must be a slot number that was used in a preceding saveSavestateAsync call)","*String* A binary string containing the savestate","Returns the savestate stored in the specified savestate slot."},
newList<string>{"func","emu.clearSavestateData","emu.clearSavestateData()","slotNumber - *Integer* The slot number to get the savestate data from (must be a slot number that was used in a preceding saveSavestateAsync call)","","Clears the specified savestate slot (any savestate data in that slot will be removed from memory)."},
newList<string>{"func","emu.getInput","emu.getInput(port)","port - *Integer* The port number to read (0 to 3)","*Table* A table containing the status of all 8 buttons.","Returns a table containing the status of all 8 buttons: { a, b, select, start, up, down, left, right }"},
newList<string>{"func","emu.setInput","emu.setInput(port, input)","port - *Integer* The port number to apply the input to (0 to 3)\ninput - *Table* A table containing the state of some (or all) of the 8 buttons (same format as returned by getInput)","","Buttons enabled or disabled via setInput will keep their state until the next inputPolled event.\nIf a button’s value is not specified to either true or false in the input argument, then the player retains control of that button.\nFor example, setInput(0, { select = false, start = false}) will prevent the player 1 from using both the start and select buttons,\nbut all other buttons will still work as normal.To properly control the emulation, it is recommended to use this function\nwithin a callback for the inputPolled event.\nOtherwise, the inputs may not be applied before the ROM has the chance to read them."},
newList<string>{"func","emu.getMouseState","emu.getMouseState()","","*Table* The mouse's state","Returns a table containing the position and the state of all 3 buttons: { x, y, left, middle, right }"},
newList<string>{"func","emu.isKeyPressed","emu.isKeyPressed(keyName)","keyName - *String* The name of the key to check","*Boolean* The key’s state (true = pressed)","Returns whether or not a specific key is pressed. The “keyName” must be the same as the string shown in the UI when the key is bound to a button."},
newList<string>{"func","emu.addCheat","emu.addCheat(cheatCode)","cheatCode - *String* A game genie format cheat code.","","Activates a game genie cheat code (6 or 8 characters).\nNote: cheat codes added via this function are not permanent and not visible in the UI."},
newList<string>{"func","emu.clearCheats","emu.clearCheats()","","","Removes all active cheat codes (has no impact on cheat codes saved within the UI)"},
newList<string>{"func","emu.getLogWindowLog","emu.getLogWindowLog()","","*Table* A string containing the log shown in the log window","Returns the same text as what is shown in the emulator's Log Window."},
newList<string>{"func","emu.getRomInfo","emu.getRomInfo()","","*Table* Information about the current ROM","Returns information about the ROM file that is currently running."},
newList<string>{"func","emu.getScriptDataFolder","emu.getScriptDataFolder()","","*String* The script’s data folder.","This function returns the path to a unique folder (based on the script’s filename) where the script should store its data (if any data needs to be saved).\nThe data will be saved in subfolders inside the LuaScriptData folder in Mesen’s home folder."},
newList<string>{"func","emu.takeScreenshot","emu.takeScreenshot()","","*String* A binary string containing a PNG image.","Takes a screenshot and returns a PNG file as a string.\nThe screenshot is not saved to the disk."},
newList<string>{"enum","emu.eventType.stateLoaded","Triggered when a user manually loads a savestate","","",""},
newList<string>{"enum","emu.eventType.stateSaved","Triggered when a user manually saves a savestate","","",""},
newList<string>{"enum","emu.eventType.inputPolled","Triggered when the emulation core polls the state of the input devices for the next frame","","",""},
newList<string>{"enum","emu.eventType.spriteZeroHit","Triggered when the PPU sets the sprite zero hit flag","","",""},
newList<string>{"enum","emu.eventType.scriptEnded","Triggered when the current Lua script ends (script window closed, execution stopped, etc.)","","",""},
newList<string>{"enum","emu.memType.cpu","CPU memory - $0000 to $FFFF","","","Warning: Reading or writing to this memory type may cause side-effects!"},
newList<string>{"enum","emu.memType.ppu","PPU memory - $0000 to $3FFF","","","Warning: Reading or writing to this memory type may cause side-effects!"},