### Install Desktop Entry File Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs the .desktop file, which is used by desktop environments to recognize the application. ```cmake install( FILES ${CMAKE_SOURCE_DIR}/fceux.desktop DESTINATION share/applications ) ``` -------------------------------- ### Set Application Install Path Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Defines the installation path for the application bundle, deferring expansion until the install script is called. ```cmake set(APP ${CMAKE_INSTALL_PREFIX}/${APP_NAME}.app) ``` -------------------------------- ### Install Application Icon Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs the main application icon to the share/pixmaps directory. ```cmake install( FILES ${CMAKE_SOURCE_DIR}/fceux1.png DESTINATION share/pixmaps ) ``` -------------------------------- ### Install Man Pages Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs the main FCEUX man page and the net-server man page to the man6 directory. ```cmake install( FILES ${CMAKE_SOURCE_DIR}/documentation/fceux.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6 ) install( FILES ${CMAKE_SOURCE_DIR}/documentation/fceux-net-server.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6 ) ``` -------------------------------- ### Install Output Directory Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs the contents of the output directory to share/fceux. ```cmake install( DIRECTORY ${CMAKE_SOURCE_DIR}/output/. DESTINATION share/fceux ) ``` -------------------------------- ### RAM Address Example in NL File Source: https://github.com/tasemulators/fceux/blob/master/web/help/NLFilesFormat.html Shows how to define names and comments for RAM addresses (0x0000 - 0x7FFF) in a .ram.nl file, including an example with enumerated values. ```text $00A5#Mic Test OK#00=Not Passed, 01=Passed ``` -------------------------------- ### Install Dependencies for Building FCEUX from Source Source: https://github.com/tasemulators/fceux/blob/master/web/osx.html These commands install the necessary dependencies for building FCEUX from source using Homebrew. Qt5, SDL2, and minizip are essential. Libarchive, ffmpeg, and x264 are optional but recommended for specific features like 7zip support and AVI recording. ```bash brew install qt5 brew install sdl2 brew install minizip brew install libarchive (optional dependency for 7zip archive support) brew install ffmpeg (optional dependency but recommended for AVI recording) brew install x264 (optional dependency but recommended for AVI recording) ``` -------------------------------- ### Install Application Resources Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs the application's resource directory to the correct location within the app bundle. ```cmake install( DIRECTORY ${CMAKE_SOURCE_DIR}/output/. DESTINATION ${APP_NAME}.app/Contents/Resources COMPONENT Extra ) ``` -------------------------------- ### Install Runtime Binaries on macOS Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs the main application executable to the bin directory within the runtime destination. ```cmake install( TARGETS ${APP_NAME} RUNTIME DESTINATION bin ) ``` -------------------------------- ### Bankswitching Initialization Example Source: https://github.com/tasemulators/fceux/blob/master/documentation/tech/nsfspec.txt Illustrates how bankswitching is determined and initialized based on the NSF header. If bytes 0070h-0077h are non-zero, bankswitching is active. The example shows Metroid.nsf's bankswitch values and how they relate to loading data into banks. ```assembly 0070: 05 05 05 05 05 05 05 05 - 00 00 00 00 00 00 00 00 0080: ... music data goes here... ``` -------------------------------- ### Flow Control Structures Source: https://github.com/tasemulators/fceux/blob/master/output/luaScripts/UsingLuaScripting-Documentation.txt Examples of for-loops and while-loops in Lua. ```lua for i=0,15 do -- do stuff here, i runs from 0 to 15 (inclusive!) end; for key,value in pairs(table) do -- do stuff here. pairs will iterate through the table, splitting the keys and values end; while (somethingistrue) do end; ``` -------------------------------- ### Get Pixel Color Source: https://github.com/tasemulators/fceux/blob/master/web/help/LuaFunctionsList.html Retrieves the RGBA components of a pixel previously set by gui.pixel. This function only reads LUA-set pixels, not emulator screen colors. Usage example: local r,g,b,a = gui.getpixel(5, 5). ```lua gui.getpixel(x, y) ``` -------------------------------- ### Initialize Documentation Interface Source: https://github.com/tasemulators/fceux/blob/master/web/help/taseditor/toc.html Sets up the tabbed interface and initializes Dynatree components for the Table of Contents and Index upon document ready. ```javascript #tabs .ui-widget-header { background-color: #EFEFEF; } var bSearchDataLoaded = false; var sHelpIdToActivate = ''; $(document).ready(function() { var sAnchorName = ''; try { sAnchorName = top.location.href.substring(top.location.href.lastIndexOf("#") + 1, top.location.href.length); } catch(err) { sAnchorName = ''; } var nSelectedTab = 0; if (sAnchorName == '\_index') nSelectedTab = 1 else if (sAnchorName == '\_search') nSelectedTab = 2; $("#tabs").tabs({ selected: nSelectedTab, select: function(event, ui) { HideKwPopup(); } }); // Toc if ($("#tab-toc").length) { $("#tab-toc").dynatree({ clickFolderMode: 1, debugLevel: 0, imagePath: 'css/dynatree/chm/', onActivate: function(node){ if ($("#tab-keywords").length && $("#tab-keywords").dynatree && $("#tab-keywords").dynatree("getTree") && $("#tab-keywords").dynatree("getTree").activateKey) $("#tab-keywords").dynatree("getTree").activateKey(null); if(node.data.href && node.data.href != '#'){ window.open(node.data.href, node.data.target); } } }); // Expand all nodes if required $("#tab-toc").dynatree("getRoot").visit(function(node){ node.expand(true); }); // Select the active help id if (sHelpIdToActivate != '') $("#tab-toc").dynatree("getTree").activateKey(sHelpIdToActivate); } // Keywords if ($("#tab-keywords").length) { $("#tab-keywords").dynatree({ clickFolderMode: 1, debugLevel: 0, imagePath: 'css/dynatree/chm/', onClick: function(node, event){ HideKwPopup(); if (node.data && node.data.click) { var aRefList = null; eval('aRefList=' + node.data.click); if (ShowKwPopup(node.li, aRefList)) { if ($("#tab-toc") && $("#tab-toc").dynatree && $("#tab-toc").dynatree("getTree") && $("#tab-toc").dynatree("getTree").activateKey) $("#tab-toc").dynatree("getTree").activateKey(null); if(node.data.href && node.data.href != '#'){ window.open(node.data.href, node.data.target); } } } } }); // Expand all nodes if required $("#tab-keywords").dynatree("getRoot").visit(function(node){ node.expand(true); }); } // Load search data $.getScript("js/searchdata.js", function() { bSearchDataLoaded = true; }); }); $('body').click(function() { HideKwPopup(); }); ``` -------------------------------- ### Install Lua Scripts Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs custom Lua scripts to the share/fceux/luaScripts directory. ```cmake install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/auxlib.lua DESTINATION share/fceux/luaScripts ) ``` -------------------------------- ### NL File Naming Convention Example Source: https://github.com/tasemulators/fceux/blob/master/web/help/NLFilesFormat.html Demonstrates the naming convention for .nl files, including bank-specific files and a separate file for RAM addresses. ```text mygame.nes.ram.nl mygame.nes.0.nl mygame.nes.1.nl mygame.nes.2.nl mygame.nes.3.nl ``` -------------------------------- ### Install Executable on macOS Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Installs the FCEUX application bundle and runtime components to the specified destinations on macOS. ```cmake install( TARGETS ${APP_NAME} BUNDLE DESTINATION . COMPONENT Runtime RUNTIME DESTINATION bin COMPONENT Runtime ) ``` -------------------------------- ### NSF Bankswitching Example Source: https://github.com/tasemulators/fceux/blob/master/web/help/NSFFormat.html Illustrates how bankswitching is detected and handled based on the NSF header's bankswitch initialization values. ```text 0070: 05 05 05 05 05 05 05 05 - 00 00 00 00 00 00 00 00 0080: ... music data goes here... ``` -------------------------------- ### Initialize FCEUX Documentation App Source: https://github.com/tasemulators/fceux/blob/master/web/help/Input.html Initializes the Hnd application instance and boots the documentation interface. ```javascript $(function() { // Create the app var app = new Hnd.App({ searchEngineMinChars: 3 }); // Update translations hnd\_ut(app); // Instanciate imageMapResizer imageMapResize(); // Custom JS // Boot the app app.Boot(); }); ``` -------------------------------- ### PPU Scanline and Frame Start Logic Source: https://github.com/tasemulators/fceux/blob/master/documentation/tech/ppu/loopy1.txt Internal register updates triggered at the start of scanlines and frames when background and sprite rendering are enabled. ```text scanline start (if background and sprites are enabled): v:0000010000011111=t:0000010000011111 frame start (line 0) (if background and sprites are enabled): v=t ``` -------------------------------- ### JavaScript Initialization for HelpNDoc App Source: https://github.com/tasemulators/fceux/blob/master/web/help/NESScrolling1.html Initializes the Hnd.App with search engine settings and calls necessary utility and boot functions. ```javascript $(function() { // Create the app var app = new Hnd.App({ searchEngineMinChars: 3 }); // Update translations hnd_ut(app); // Instanciate imageMapResizer imageMapResize(); // Custom JS // Boot the app app.Boot(); }); ``` -------------------------------- ### Install Development Version of FCEUX via Homebrew Source: https://github.com/tasemulators/fceux/blob/master/web/osx.html Use this command to install the current development revision (git head) of FCEUX using Homebrew. ```bash brew install --HEAD fceux ``` -------------------------------- ### Install Latest FCEUX Release via Homebrew Source: https://github.com/tasemulators/fceux/blob/master/web/osx.html Use this command to install the latest stable release of FCEUX using the Homebrew package manager. ```bash brew install fceux ``` -------------------------------- ### Check if Movie Started from Power-On Source: https://github.com/tasemulators/fceux/blob/master/web/help/LuaFunctionsList.html Returns true if the movie recording or loaded state began from a 'Start' action, indicating it was not loaded from a save state. ```lua movie.ispoweron() ``` -------------------------------- ### Load ROM via Command Line Source: https://github.com/tasemulators/fceux/blob/master/web/help/CommandLineOptions.html Specify the ROM file path as the final argument to launch the game. ```bash fceux smb.nes fceux c:\fceux\roms\smb.zip ``` -------------------------------- ### Custom Breakpoint Example Source: https://github.com/tasemulators/fceux/blob/master/web/help/LuaFunctionsList.html An example of a custom breakpoint function that pauses emulation if the 'y' register exceeds a certain value and displays the register's content. ```lua function CounterBreak() ObjCtr = memory.getregister("y") if ObjCtr > 0x16 then gui.text(1, 9, string.format("%02X",ObjCtr)) emu.pause() -- or debugger.hitbreakpoint() end end memory.registerexecute(0x863C, CounterBreak); ``` -------------------------------- ### Lua Table Initialization Source: https://github.com/tasemulators/fceux/blob/master/web/files/{7375BEB7-A588-45AB-8BC4-F7840D87DADD}.htm Shows how to create an empty table in Lua. Remember that Lua tables are 1-indexed. ```lua local tbl1 = {}; -- empty table ``` -------------------------------- ### NES PPU Scanline Start Register Update Source: https://github.com/tasemulators/fceux/blob/master/web/help/NESScrolling1.html Describes the bitwise update of the VRAM address (v) from the temporary VRAM address (t) at the start of a scanline, if background and sprites are enabled. ```assembly v:0000010000011111=t:0000010000011111 ``` -------------------------------- ### Configure Qt6 Build Source: https://github.com/tasemulators/fceux/blob/master/src/CMakeLists.txt Configures the build for Qt6, including finding required components like Widgets, OpenGL, OpenGLWidgets, Network, Help, Qml, and UiTools. Sets up include directories and defines for found modules. ```cmake if ( ${QT} EQUAL 6 ) message( STATUS "GUI Frontend: Qt6") set( Qt Qt6 ) find_package( Qt6 REQUIRED COMPONENTS Widgets OpenGL OpenGLWidgets) find_package( Qt6 REQUIRED COMPONENTS Network) find_package( Qt6 COMPONENTS Help QUIET) find_package( Qt6 COMPONENTS Qml) find_package( Qt6 COMPONENTS UiTools) include_directories( ${Qt6Widgets_INCLUDE_DIRS} ${Qt6Qml_INCLUDE_DIRS} ${Qt6UiTools_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS} ${Qt6Help_INCLUDE_DIRS} ${Qt6OpenGLWidgets_INCLUDE_DIRS} ) if (${Qt6Help_FOUND}) message( STATUS "Qt6 Help Module Found") if (${QHELP}) add_definitions( -D_USE_QHELP ) endif() else() message( STATUS "Qt6 Help Module Not Found") endif() if (${Qt6Network_FOUND}) message( STATUS "Qt6 Network Module Found") add_definitions( -D__FCEU_QNETWORK_ENABLE__ ) else() message( STATUS "Qt6 Network Module Not Found") endif() if (${Qt6Qml_FOUND}) message( STATUS "Qt6 Qml Module Found") add_definitions( -D__FCEU_QSCRIPT_ENABLE__ ) else() message( STATUS "Qt6 Qml Module Not Found") endif() if (${Qt6UiTools_FOUND}) message( STATUS "Qt6 UiTools Module Found") add_definitions( -D__QT_UI_TOOLS__ ) else() message( STATUS "Qt6 UiTools Module Not Found") endif() else() ``` -------------------------------- ### TAS Editor - Submit Delete Frames Source: https://github.com/tasemulators/fceux/blob/master/web/files/{D3F1816D-0770-4257-98D2-A21456B07D28}.htm Submits an operation to delete a specified number of frames starting from a given frame position. Requires the starting frame and the number of frames to delete. ```lua taseditor.submitdeleteframes(int frame, int number) ``` -------------------------------- ### Load Configuration File Source: https://github.com/tasemulators/fceux/blob/master/web/files/{CFE4B1D4-9F19-48C4-B8A9-4EBEA543848F}.htm Loads a specific configuration file from the base directory. ```bash fceux -cfg fceux-smbconfig.cfg smb.nes ``` -------------------------------- ### NES PPU Frame Start Register Update Source: https://github.com/tasemulators/fceux/blob/master/web/help/NESScrolling1.html Details the VRAM address (v) being set to the temporary VRAM address (t) at the start of frame (line 0), if background and sprites are enabled. ```assembly v=t ``` -------------------------------- ### Hello World EmuLua Script Source: https://github.com/tasemulators/fceux/blob/master/output/luaScripts/UsingLuaScripting-Documentation.txt A basic script demonstrating the main loop required to keep the emulator running while executing custom code. ```lua while (true) do gui.text(50,50,"Hello world!"); FCEU.frameadvance(); end; ``` -------------------------------- ### Interrupt Handling Example Source: https://github.com/tasemulators/fceux/blob/master/web/help/6502CPU.html An example of how to handle interrupts in FCEUX, specifically clearing VIC interrupts and checking for raster interrupts. This code is intended for use within a combined raster/timer interrupt routine. ```assembly ; beginning of combined raster/timer interrupt routine LSR $D019 ; clear VIC interrupts, read raster interrupt flag to C bcs raster ; jump if VIC caused an interrupt ... ; timer interrupt routine ``` -------------------------------- ### Manage Game Lifecycle Source: https://github.com/tasemulators/fceux/blob/master/documentation/porting.txt Functions to initialize the emulator, load/close games, and control the emulation loop. ```c FCEUGI *FCEUI_LoadGame(char *name); int FCEUI_Initialize(void); void FCEUI_SetBaseDirectory(void); void FCEUI_SetDirOverride(int which, char *n); void FCEUI_Emulate(void); void FCEUI_CloseGame(void); void FCEUI_ResetNES(void); ``` -------------------------------- ### Cheat File Format Example Source: https://github.com/tasemulators/fceux/blob/master/documentation/cheat.html This is an example of a single-byte memory patch in the FCE Ultra cheat file format. The format includes optional flags, the address, the value, and an optional compare value, followed by a description. ```plaintext 040e:05:Infinite super power. ``` -------------------------------- ### Load Lua Script Source: https://github.com/tasemulators/fceux/blob/master/web/files/{CFE4B1D4-9F19-48C4-B8A9-4EBEA543848F}.htm Loads a Lua script file on emulator startup. ```bash fceux -lua memwatch.lua ``` -------------------------------- ### Initialize and Boot FCEUX App Source: https://github.com/tasemulators/fceux/blob/master/web/help/CheatSearch.html Initializes the Hnd.App with specified search engine minimum characters, updates translations, resizes image maps, and boots the application. Ensure Hnd.App and hnd_ut are available in the scope. ```javascript $(function() { // Create the app var app = new Hnd.App({ searchEngineMinChars: 3 }); // Update translations hnd_ut(app); // Instanciate imageMapResizer imageMapResize(); // Custom JS // Boot the app app.Boot(); }); ``` -------------------------------- ### Play Movie File Source: https://github.com/tasemulators/fceux/blob/master/web/help/CommandLineOptions.html Use the -playmovie flag followed by the .fm2 file and the required ROM. ```bash fceux -playmovie smb.fm2 smb.nes ```