[
  {
    "path": ".github/workflows/build.yml",
    "content": "name: Angrylion RDP Plus\n\non:\n  push:\n    paths-ignore:\n      - '**/*.md'\n      - '.{gitattributes,gitignore,travis.yml}'\n      - 'appveyor.yml,README'\n  pull_request:\n    paths-ignore:\n      - '**/*.md'\n      - '.{gitattributes,gitignore,travis.yml}'\n      - 'appveyor.yml,README'\n  workflow_dispatch:\n\njobs:\n\n  Linux:\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - cc: GCC\n            platform: x64\n          - cc: GCC\n            platform: x86\n          - cc: Clang\n            platform: x64\n          - cc: Clang\n            platform: x86\n    name: Linux / ${{ matrix.cc }} / ${{ matrix.platform }}\n    runs-on: ubuntu-22.04\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          fetch-depth: 0\n      - name: Get build dependencies and arrange the environment\n        run: |\n          set +e\n          git tag --delete nightly-build\n          set -e\n          echo \"G_REV=$(git describe --dirty --always --tags)\" >> \"${GITHUB_ENV}\"\n          if [[ \"${{ matrix.platform }}\" == \"x86\" ]]; then sudo dpkg --add-architecture i386; fi\n          sudo apt-get update\n          sudo apt-get -y install cmake libgl1-mesa-dev libopengl-dev\n          if [[ \"${{ matrix.platform }}\" == \"x86\" ]]; then\n            sudo apt-get --reinstall -y install gcc-multilib g++-multilib libc6 libc6-dev-i386 libgl1-mesa-glx:i386 libopengl0:i386\n            LINK=\"sudo ln -s -T\"\n            cd /usr/lib/i386-linux-gnu\n            if ! [[ -f libGLX.so ]]; then ${LINK} libGLX.so.0.0.0 libGLX.so; fi\n            if ! [[ -f libOpenGL.so ]]; then ${LINK} libOpenGL.so.0.0.0 libOpenGL.so; fi\n          fi\n          sudo ldconfig\n      - name: Build and related stuff, backup binaries\n        run: |\n          if [[ \"${{ matrix.platform }}\" == \"x86\" ]]; then CPU_TUNE=\"-m32 -msse2 -mtune=pentium4\"; else CPU_TUNE=\"-mtune=core2\"; fi\n          CC=\"gcc\"\n          CXX=\"g++\"\n          if [[ \"${{ matrix.cc }}\" != \"GCC\" ]]; then\n            CC=\"clang\"\n            CXX=\"clang++\"\n          fi\n          ${CC} --version\n          echo \"\"\n          mkdir -p build pkg/usr/local/lib/mupen64plus\n          cd build\n          cmake -DCMAKE_C_COMPILER=\"${CC}\" -DCMAKE_CXX_COMPILER=\"${CXX}\" -DCMAKE_C_FLAGS=\"${CPU_TUNE}\" -DCMAKE_CXX_FLAGS=\"${CPU_TUNE}\" -DCMAKE_BUILD_TYPE=\"Release\" ..\n          cmake --build . -j2\n          echo \"\"\n          chmod 644 *.so\n          cp *.so ../pkg/usr/local/lib/mupen64plus/\n          ls -gG ../pkg/usr/local/lib/mupen64plus/*.so\n          echo \"\"\n          ldd ../pkg/usr/local/lib/mupen64plus/mupen64plus-video-angrylion-plus.so\n          tar cvzf ../pkg/mupen64plus-video-angrylion-plus-linux-${{ matrix.platform }}-${{ env.G_REV }}.tar.gz -C ../pkg/ \"usr\"\n      - name: Upload artifact\n        if: matrix.cc == 'GCC'\n        uses: actions/upload-artifact@v3\n        with:\n          name: mupen64plus-video-angrylion-plus-linux-${{ matrix.platform }}-${{ env.G_REV }}\n          path: pkg/*.tar.gz\n\n  Windows:\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - method: static\n            platform: x64\n            wintag: win64\n            toolset: v143\n            vs: 2022\n          - method: static\n            platform: x86\n            wintag: win32\n            toolset: v143\n            vs: 2022\n          - method: shared\n            platform: x64\n            wintag: win64\n            toolset: v143\n            vs: 2022\n          - method: shared\n            platform: x86\n            wintag: win32\n            toolset: v141_xp\n            vs: 2019\n    name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.platform }} / ${{ matrix.method }}\n    runs-on: windows-${{ matrix.vs }}\n    defaults:\n      run:\n        shell: cmd\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          fetch-depth: 0\n      - uses: microsoft/setup-msbuild@v1\n      - name: Pre-build arrangements\n        run: |\n          for /f \"tokens=1\" %%T in ('git tag -l ^| find \"nightly-build\"') do set \"R_TAG=%%T\"\n          if [%R_TAG%] NEQ [] git tag --delete nightly-build\n          for /f \"tokens=1\" %%R in ('git describe --dirty --always --tags') do echo G_REV=%%R>> \"%GITHUB_ENV%\"\n      - name: Static build and backup binaries\n        if: matrix.method == 'static'\n        run: |\n          msbuild --version\n          echo.\n          msbuild msvc\\angrylion-plus.sln /p:Configuration=Release;Platform=${{ matrix.platform }};PlatformToolset=${{ matrix.toolset }} /t:Rebuild\n          echo.\n          md pkg\n          dir msvc\\build\\Release\\*.dll\n          copy msvc\\build\\Release\\*.dll pkg\\\n      - name: Pre-build arrangement for CMake/MSVC environment\n        if: matrix.method == 'shared'\n        uses: ilammy/msvc-dev-cmd@v1\n      - name: Shared build and backup binaries\n        if: matrix.method == 'shared'\n        run: |\n          set \"TARCH=${{ matrix.platform }}\"\n          if [%TARCH%] == [x86] set \"TARCH=Win32\"\n          msbuild --version\n          echo.\n          md pkg build\n          cd build\n          cmake -DBUILD_PROJECT64=ON -T \"${{ matrix.toolset }}\" -A \"%TARCH%\" ..\n          cmake --build . --config Release\n          echo.\n          dir Release\\*.dll\n          copy Release\\*.dll ..\\pkg\\\n      - name: Upload artifact\n        uses: actions/upload-artifact@v3\n        with:\n          name: angrylion-rdp-plus-${{ matrix.wintag }}-${{ matrix.method }}-${{ env.G_REV }}\n          path: pkg/*\n\n  Nightly-build:\n    runs-on: ubuntu-latest\n    if: github.ref_name == 'master'\n    needs: [Linux, Windows]\n    steps:\n      - uses: actions/checkout@v3\n      - name: Download artifacts\n        uses: actions/download-artifact@v3\n        with:\n          path: binaries\n      - name: Get some tools\n        run: |\n          sudo apt-get update\n          sudo apt-get -y install hashdeep\n      - name: Creating new artifacts and update nightly-build\n        run: |\n          mkdir pkg\n          cd binaries\n          for BIN in *; do\n            cd \"${BIN}\"\n            if [[ \"${BIN:0:11}\" == \"mupen64plus\" ]]; then\n              echo \":: Recovering ${BIN}.tar.gz\"\n              mv *.tar.gz ../../pkg/\n            elif [[ \"${BIN:25:6}\" == \"static\" ]]; then\n              if [[ -f \"./angrylion-plus.dll\" ]]; then\n                echo \":: Creating project64-angrylion-plus-${BIN:19:5}-${BIN:32}.zip\"\n                zip -r \"../../pkg/project64-angrylion-plus-${BIN:19:5}-${BIN:32}.zip\" angrylion-plus.dll\n              fi\n              if [[ -f \"./mupen64plus-video-angrylion-plus.dll\" ]]; then\n                echo \":: Creating mupen64plus-video-angrylion-plus-${BIN:19:5}-${BIN:32}.zip\"\n                zip -r \"../../pkg/mupen64plus-video-angrylion-plus-${BIN:19:5}-${BIN:32}.zip\" mupen64plus-video-angrylion-plus.dll\n              fi\n            else\n              echo \":: Creating project64-angrylion-plus-${BIN:19}.zip\"\n              zip -r \"../../pkg/project64-angrylion-plus-${BIN:19}.zip\" angrylion-plus.dll\n              echo \":: Creating mupen64plus-video-angrylion-plus-${BIN:19}.zip\"\n              zip -r \"../../pkg/mupen64plus-video-angrylion-plus-${BIN:19}.zip\" mupen64plus-video-angrylion-plus.dll\n            fi\n            cd ..\n          done\n          cd ../pkg\n          echo \"\"\n          for BIN in *; do\n            ls -gG ${BIN}\n            tigerdeep -lz ${BIN} >> ../angrylion-rdp-plus.tiger.txt\n            sha256sum ${BIN} >> ../angrylion-rdp-plus.sha256.txt\n            sha512sum ${BIN} >> ../angrylion-rdp-plus.sha512.txt\n          done\n          mv ../*.tiger.txt .\n          mv ../*.sha*.txt .\n          echo \"\"\n          echo \"TIGER:\"\n          cat *.tiger.txt\n          echo \"\"\n          echo \"SHA256:\"\n          cat *.sha256.txt\n          echo \"\"\n          echo \"SHA512:\"\n          cat *.sha512.txt\n          echo \"\"\n          git tag -f nightly-build\n          git push -f origin nightly-build\n      - name: Nightly-build\n        uses: ncipollo/release-action@v1\n        with:\n          prerelease: true\n          allowUpdates: true\n          removeArtifacts: true\n          replacesArtifacts: false\n          tag: nightly-build\n          artifacts: pkg/*\n"
  },
  {
    "path": ".gitignore",
    "content": "# Visual Studio cache/options directory\n.vs/\n\n# Visual C++ cache files\n*.aps\n\nsrc/core/version.h\nprivate/\nbuild/\n"
  },
  {
    "path": "CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.10)\n\noption(BUILD_MUPEN64PLUS \"Enables build of mupen64plus version\" ON)\noption(BUILD_PROJECT64   \"Enables build of project64 version\" WIN32)\noption(GLES \"Set to ON to use OpenGL ES 3.0 renderer instead of OpenGL 3.3 core\")\n\nproject(angrylion-plus)\n\ninclude(GNUInstallDirs)\n\nset(OpenGL_GL_PREFERENCE GLVND)\n\nif (BUILD_PROJECT64 AND NOT WIN32)\n    message(WARNING \"BUILD_PROJECT64 is ON but not supported on current platform, disabling option\")\n    set(BUILD_PROJECT64 OFF)\nendif()\n\nif(GLES)\n    message(\"OpenGL ES 3.0 renderer enabled\")\n    add_definitions(-DGLES)\nendif(GLES)\n\nif(ANDROID)\n    add_definitions(-DANDROID)\nendif()\n\n# set policy CMP0042 for MacOS X\nset(CMAKE_MACOSX_RPATH 1)\n\n# check for INTERPROCEDURAL_OPTIMIZATION support\ncmake_policy(SET CMP0069 NEW)\n\ninclude(CheckIPOSupported)\ncheck_ipo_supported(RESULT ENABLE_IPO)\nif(ENABLE_IPO)\n    message(\"Interprocedural optimizations enabled\")\nendif(ENABLE_IPO)\n\n# C++14 is required for the Parallel utility class\nset(CMAKE_CXX_STANDARD 14)\n\n# disable warnings to use unportable secure file IO\nif(MSVC)\n    add_definitions(-D_CRT_SECURE_NO_WARNINGS)\nendif(MSVC)\n\n# default to release build\nif(NOT CMAKE_BUILD_TYPE)\n    set(CMAKE_BUILD_TYPE Release)\nendif(NOT CMAKE_BUILD_TYPE)\n\nif (NOT ANDROID)\n    find_package(OpenGL REQUIRED)\nendif()\n\n# use warning levels as recommended by\n# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md\nif ( CMAKE_COMPILER_IS_GNUCC )\n    set(CMAKE_CXX_FLAGS  \"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic\")\nendif()\nif ( MSVC )\n    set(CMAKE_CXX_FLAGS  \"${CMAKE_CXX_FLAGS} /W4 /w14640 /permissive-\")\nendif()\n\nset(PATH_SRC \"${CMAKE_CURRENT_SOURCE_DIR}/src\")\n\n# RDP core library\nset(PATH_CORE \"${PATH_SRC}/core\")\n\n# run script to generate version.h\nset(PATH_VERSION \"${PATH_CORE}/version.h\")\n\nadd_custom_command(\n    OUTPUT ${PATH_VERSION}\n    COMMAND\n        ${CMAKE_COMMAND} -DPATH_VERSION=${PATH_VERSION}\n        -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}\n        -P ${CMAKE_CURRENT_SOURCE_DIR}/git-version.cmake\n    COMMENT \"Generate Git version\"\n)\n\n# static core library\nfile(GLOB SOURCES_CORE \"${PATH_CORE}/*.c\" \"${PATH_CORE}/*.cpp\")\n\nif (ANDROID)\n    find_library( # Defines the name of the path variable that stores the\n        # location of the NDK library.\n        OPENGL_LIBRARIES\n\n        # Specifies the name of the NDK library that\n        # CMake needs to locate.\n        GLESv3 )\nendif()\n\nadd_library(alp-core STATIC ${SOURCES_CORE} ${PATH_VERSION})\n\n# output library\nset(PATH_OUTPUT \"${PATH_SRC}/output\")\n\nfile(GLOB SOURCES_OUTPUT \"${PATH_OUTPUT}/*.c\" \"${PATH_OUTPUT}/*.cpp\")\n\nadd_library(alp-output STATIC ${SOURCES_OUTPUT})\n\nif(MINGW)\n    # link libgcc/libstdc++ statically, fixes cryptic \"_ZNSt13runtime_errorC1EPKc\" error\n    set(CMAKE_CXX_FLAGS  \"${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++\")\nelse(MINGW)\n    # set PIC option for non-MinGW targets\n    set_target_properties(alp-core PROPERTIES POSITION_INDEPENDENT_CODE ON)\n    set_target_properties(alp-output PROPERTIES POSITION_INDEPENDENT_CODE ON)\nendif(MINGW)\n\n# set IPO option, if supported\nif(ENABLE_IPO AND (CMAKE_BUILD_TYPE STREQUAL \"Release\"))\n    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)\n    set(CMAKE_SHARED_LINKER_FLAGS \"${CMAKE_SHARED_LINKER_FLAGS} -O3\")\nendif()\n\ninclude_directories(${PATH_SRC})\n\n# Project64 GFX Plugin (Windows only)\nif(BUILD_PROJECT64)\n    set(NAME_PLUGIN_ZILMAR ${CMAKE_PROJECT_NAME})\n    set(PATH_PLUGIN_ZILMAR \"${PATH_SRC}/plugin/zilmar\")\n\n    enable_language(RC)\n    file(GLOB SOURCES_PLUGIN_ZILMAR \"${PATH_PLUGIN_ZILMAR}/*.c\" \"${PATH_PLUGIN_ZILMAR}/*.rc\")\n    add_library(${NAME_PLUGIN_ZILMAR} SHARED ${SOURCES_PLUGIN_ZILMAR})\n\n    set_target_properties(${NAME_PLUGIN_ZILMAR} PROPERTIES PREFIX \"\")\n\n    target_link_libraries(${NAME_PLUGIN_ZILMAR} alp-core alp-output shlwapi ${OPENGL_LIBRARIES})\nendif(BUILD_PROJECT64)\n\n# Mupen64Plus GFX plugin\nif(BUILD_MUPEN64PLUS)\n    set(NAME_PLUGIN_M64P \"mupen64plus-video-${CMAKE_PROJECT_NAME}\")\n    \n    set(PATH_PLUGIN_M64P \"${PATH_SRC}/plugin/mupen64plus\")\n    \n    file(GLOB SOURCES_PLUGIN_M64P \"${PATH_PLUGIN_M64P}/*.c\")\n    add_library(${NAME_PLUGIN_M64P} SHARED ${SOURCES_PLUGIN_M64P})\n    \n    if(NOT ANDROID)\n        set_target_properties(${NAME_PLUGIN_M64P} PROPERTIES PREFIX \"\")\n    endif()\n    \n    target_link_libraries(${NAME_PLUGIN_M64P} alp-core alp-output ${CMAKE_THREAD_LIBS_INIT} ${OPENGL_LIBRARIES})\n    \n    if(UNIX AND NOT APPLE AND NOT ANDROID)\n        install(TARGETS ${NAME_PLUGIN_M64P}\n            DESTINATION \"${CMAKE_INSTALL_LIBDIR}/mupen64plus\"\n        )\n    endif()\nendif(BUILD_MUPEN64PLUS)\n"
  },
  {
    "path": "CREDITS.txt",
    "content": "This little RDP plugin was initially based on MESS 0.128 source code.\r\nMany thanks to Ville Linde, MooglyGuy and other people who wrote the RDP implementation in MESS 0.128. The rest of the code is by me, angrylion.\r\nMany thanks to people who helped me in various ways: olivieryuyu, marshallh, LaC, oman, pinchy, ziggy, FatCat, LegendOfDragoon and other folks I forgot.\r\nThe code comes under MAME license.\r\nSorry for my terrible English.\r\n\r\nangrylion\r\n"
  },
  {
    "path": "MAME License.txt",
    "content": "MAME Legal Information\r\nLicense\r\n\r\nRedistribution and use of the MAME code or any derivative works are permitted provided that the following conditions are met:\r\n\r\n    * Redistributions may not be sold, nor may they be used in a commercial product or activity.\r\n    * Redistributions that are modified from the original source must include the complete source code, including the source code for all components used by a binary built from the modified sources. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.\r\n    * Redistributions must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\nTrademark\r\n\r\nMAME is a registered trademark of Nicola Salmoria. The \"MAME\" name and MAME logo may not be used without first obtaining permission of the trademark holder.\r\nCopyright\r\n\r\nThe code in MAME is the work of hundreds of developers, each of whom owns the copyright to the code they wrote. There is no central copyright authority you can license the code from. The proper way to use the MAME source code is to examine it, using it to understand how the games worked, and then write your own emulation code. Sorry, there is no free lunch here.\r\nCommon Questions\r\n\r\nQ. Can I include MAME with my product?\r\nA. No. MAME is not licensed for commercial use. Using MAME as a \"freebie\" or including it at \"no cost\" with your product still constitutes commerical usage and is forbidden by the license.\r\n\r\nQ. Can I sell my product with the MAME logo on it?\r\nA. No. Putting the logo on your product makes it appear that the product is something officially endorsed by Nicola Salmoria, and constitutes trademark infringement.\r\n\r\nQ. Can I use the MAME logo to advertise my product?\r\nA. No. Using the logo in your advertising makes it appear that the product is something officially endorsed by Nicola Salmoria, and constitutes trademark infringement.\r\n\r\nQ. Can I use the term \"MAME\" in the name of my software?\r\nA. Generally, no, especially if it is something that is sold. However, if you are producing a free MAME-related piece of software, it is common that permission is granted. Send a query to double- check first, please.\r\n\r\nQ. Can I put an arcade cabinet running MAME in a public location?\r\nA. No. This this a commercial use of MAME and is prohibited by the license. Even if you don't charge money, putting a machine in a public location is \"operating\" an arcade machine and falls under commercial rules in most locations.\r\n\r\nQ. Can my non-profit use MAME or an arcade cabinet running MAME to help raise money?\r\nA. No, sorry. Even for the most worthwhile cause, this still is a commercial use of MAME and is prohibited by the license.\r\n\r\nQ. How do I obtain a license to the MAME source code?\r\nA. You can't. See the Copyright section above.\r\n\r\nQ. Is it legal to download ROMs for a game when I own the PCB?\r\nA. This is unclear and depends on where you live. In most cases you would need to obtain permission from the original manufacturer to do so.\r\n\r\nQ. What about the free ROMs on the MAME site? Can I use those with my product?\r\nA. Almost all of the free ROMs on the MAME site are licensed only for non- commercial use, and only for distribution from the MAME site. Just because they are available for \"free\" here does not grant further redistribution rights, nor does it allow you to treat them as \"freebies\" for commercial use.\r\n\r\nQ. If I obtain a license from an original manufacturer to distribute the ROMs can I use MAME to run them?\r\nA. Generally, no, because it constitutes a commercial use of MAME. However, we have in the past made a couple of exceptions for this particular case. We will not consider making any further exceptions without proof that such a license has already been obtained.\r\n\r\nQ. Can I use a PC running MAME to replace a real arcade PCB?\r\nA. In order to do this you would have to use a copy of the original ROMs, which would require obtaining permission from the original manufacturer. Once you had permission from them, if it was used for non-commercial purposes, then you would not technically be violating the MAME license. However we still do not explicitly give permission to use MAME in this way because of the possibility of the game being sold sometime later, which would constitute commercial use of MAME. If you sell your game later you must sell it without MAME included.\r\n\r\nQ. Can I ask for donations for the work I did on my port of MAME to platform X?\r\nA. No. You would be earning money from the MAME trademark and copyrights, and that would be a commercial use, which is prohibited by the license. It is our wish that MAME remain free.\r\n"
  },
  {
    "path": "README.md",
    "content": "# Angrylion RDP Plus\n\nThis is a conservative fork of angrylion's RDP plugin that aims to improve performance and add new features while retaining the accuracy of the original plugin.\n\n### Current features\n* More maintainable code base by dividing the huge n64video.cpp into smaller pieces.\n* Improved portability by separating the emulator plugin interface and window management from the RDP emulation core.\n* Improved performance on multi-core CPUs by using multi-threaded rendering with scan line interleaving.\n* Replaced deprecated DirectDraw interface with a modern OpenGL 3.3 implementation.\n* Added fullscreen support and manual window sizing.\n* Added BMP screenshot support.\n* Added settings GUI.\n* Added Mupen64Plus support.\n\nTested with Project64 2.3+. May also work with Project64 1.7 with a RSP plugin of newer builds (1.7.1+).\n\nThe Mupen64Plus plugin was tested with Mupen64Plus 2.5 using the [mupen64plus-rsp-cxd4](https://github.com/mupen64plus/mupen64plus-rsp-cxd4) plugin.\n\n### Building\n\n#### Visual Studio\n\nTo build the project with Visual Studio (2015+), you currently need to have Python 3 installed, which is used to fetch Git metadata and write it to `version.h`.\nYou can also build without, but then you have to copy `version.h.in` to `version.h` and disable the custom build event in the core project.\n\nThe glLoadGen files (`gl_core_3_3` and `wgl_ext`) were generated using the following parameters:\n\n```bash\nlua LoadGen.lua core_3_3 -style=pointer_c -spec=gl -version=3.3 -profile=core\nlua LoadGen.lua ext -style=pointer_c -spec=wgl -ext WGL_EXT_swap_control -ext ARB_create_context -ext ARB_create_context_profile\n```\n\n#### CMake\n\nInstall dependencies:\n\n```bash\napt install cmake freeglut3-dev\n```\n\nBuilding:\n\n```bash\nmkdir build\ncd build\ncmake ..\nmake\n```\n\nTo create an OpenGL ES 3 build, add ``-DGLES=ON`` to the cmake arguments.\n\nInstalling:\n\n```bash\nsudo make install\n```\n\n### Credits\n* Angrylion, Ville Linde, MooglyGuy and others involved for creating an awesome N64 RDP reference software.\n* theboy181 - Testing. Lots of testing.\n* fallaha56 - Donator.\n* loganmc10 - Mupen64Plus plugin implementation.\n"
  },
  {
    "path": "git-version.cmake",
    "content": "set(GIT_BRANCH \"unknown\")\nset(GIT_COMMIT_DATE \"unknown\")\nset(GIT_COMMIT_HASH \"unknown\")\nset(GIT_TAG \"unknown\")\n\nfind_package(Git)\nif(GIT_FOUND AND EXISTS \"${SOURCE_DIR}/.git/\")\n\texecute_process(\n\t\tCOMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD\n\t\tWORKING_DIRECTORY ${SOURCE_DIR}\n\t\tRESULT_VARIABLE GIT_BRANCH_RESULT\n\t\tOUTPUT_VARIABLE GIT_BRANCH\n\t\tOUTPUT_STRIP_TRAILING_WHITESPACE\n\t)\n\tif(NOT ${GIT_BRANCH_RESULT} EQUAL 0)\n\t\tmessage(WARNING \"git rev-parse failed, unknown branch.\")\n\tendif()\n\n\texecute_process(\n\t\tCOMMAND ${GIT_EXECUTABLE} show -s --format=%cs\n\t\tWORKING_DIRECTORY ${SOURCE_DIR}\n\t\tRESULT_VARIABLE GIT_COMMIT_DATE_RESULT\n\t\tOUTPUT_VARIABLE GIT_COMMIT_DATE\n\t\tOUTPUT_STRIP_TRAILING_WHITESPACE\n\t)\n\tif(NOT ${GIT_COMMIT_DATE_RESULT} EQUAL 0)\n\t\tmessage(WARNING \"git show failed, unknown commit date.\")\n\tendif()\n\n\texecute_process(\n\t\tCOMMAND ${GIT_EXECUTABLE} show -s --format=%h\n\t\tWORKING_DIRECTORY ${SOURCE_DIR}\n\t\tRESULT_VARIABLE GIT_COMMIT_HASH_RESULT\n\t\tOUTPUT_VARIABLE GIT_COMMIT_HASH\n\t\tOUTPUT_STRIP_TRAILING_WHITESPACE\n\t)\n\tif(NOT ${GIT_COMMIT_HASH_RESULT} EQUAL 0)\n\t\tmessage(WARNING \"git show failed, unknown commit hash.\")\n\tendif()\n\n\texecute_process(\n\t\tCOMMAND ${GIT_EXECUTABLE} describe --dirty --always --tags\n\t\tWORKING_DIRECTORY ${SOURCE_DIR}\n\t\tRESULT_VARIABLE GIT_TAG_RESULT\n\t\tOUTPUT_VARIABLE GIT_TAG\n\t\tOUTPUT_STRIP_TRAILING_WHITESPACE\n\t)\n\tif(NOT ${GIT_TAG_RESULT} EQUAL 0)\n\t\tmessage(WARNING \"git describe failed, unknown tag.\")\n\tendif()\nelse()\n\tmessage(WARNING \"git not found or not a git repo.\")\nendif()\n\nconfigure_file(${PATH_VERSION}.in ${PATH_VERSION} @ONLY)\n"
  },
  {
    "path": "make_version.py",
    "content": "#!/usr/bin/env python3\n\nimport sys, os, subprocess\n\ndef system(cmd, default):\n    args = cmd.split()\n    try:\n        return subprocess.check_output(args).decode(\"ascii\").strip()\n    except:\n        return default\n\nif __name__ == \"__main__\":\n    branch = system(\"git rev-parse --abbrev-ref HEAD\", \"master\")\n    hash = system(\"git show -s --format=%h\", \"0\" * 40)\n    date = system(\"git show -s --format=%ci\", \"\")[:10]\n    tag = system(\"git describe --dirty --always --tags\", \"\")\n\n    # remove hash from git describe output\n    tag = tag.split(\"-\")\n    if len(tag) > 2 and tag[2][1:] in hash:\n        del tag[2]\n    tag = \"-\".join(tag)\n\n    mappings = {\n        \"GIT_BRANCH\": branch,\n        \"GIT_TAG\": tag,\n        \"GIT_COMMIT_HASH\": hash,\n        \"GIT_COMMIT_DATE\": date,\n    }\n\n    base_path = os.path.dirname(sys.argv[0])\n    core_path = os.path.join(base_path, \"src\", \"core\")\n    in_path = os.path.join(core_path, \"version.h.in\")\n    out_path = os.path.join(core_path, \"version.h\")\n\n    with open(in_path, \"r\") as f:\n        version_str = f.read()\n\n    for mapping, value in mappings.items():\n        version_str = version_str.replace(\"@\" + mapping + \"@\", value)\n\n    with open(out_path, \"w\") as f:\n        f.write(version_str)\n"
  },
  {
    "path": "msvc/.gitignore",
    "content": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\n# User-specific files\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\n[Xx]64/\n[Xx]86/\n[Bb]uild/\nbld/\n[Bb]in/\n[Oo]bj/\n\n# Visual Studio 2015 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUNIT\n*.VisualState.xml\nTestResult.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# DNX\nproject.lock.json\nartifacts/\n\n*_i.c\n*_p.c\n*_i.h\n*.ilk\n*.meta\n*.obj\n*.pch\n*.pdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# JustCode is a .NET coding add-in\n.JustCode\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n\n# TODO: Un-comment the next line if you do not want to checkin \n# your web deploy settings because they may include unencrypted\n# passwords\n#*.pubxml\n*.publishproj\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/packages/*\n# except build/, which is used as an MSBuild target.\n!**/packages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/packages/repositories.config\n# NuGet v3's project.json files produces more ignoreable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Microsoft Azure ApplicationInsights config file\nApplicationInsights.config\n\n# Windows Store app package directory\nAppPackages/\nBundleArtifacts/\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!*.[Cc]ache/\n\n# Others\nClientBin/\n[Ss]tyle[Cc]op.*\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.pfx\n*.publishsettings\nnode_modules/\norleans.codegen.cs\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\n\n# SQL Server files\n*.mdf\n*.ldf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# LightSwitch generated files\nGeneratedArtifacts/\nModelManifest.xml\n\n# Paket dependency manager\n.paket/paket.exe\n\n# FAKE - F# Make\n.fake/"
  },
  {
    "path": "msvc/angrylion-plus.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.29806.167\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"core\", \"core.vcxproj\", \"{D86C6E84-3371-4B20-8620-A703FF3F2CC5}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"plugin-mupen64plus\", \"plugin-mupen64plus.vcxproj\", \"{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5} = {D86C6E84-3371-4B20-8620-A703FF3F2CC5}\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE} = {B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"plugin-zilmar\", \"plugin-zilmar.vcxproj\", \"{722AD25D-C281-48FB-9A58-7699E50F8E6D}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5} = {D86C6E84-3371-4B20-8620-A703FF3F2CC5}\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE} = {B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"output\", \"output.vcxproj\", \"{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|x64 = Debug|x64\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|x64 = Release|x64\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Debug|x64.Build.0 = Debug|x64\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Debug|x86.Build.0 = Debug|Win32\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Release|x64.ActiveCfg = Release|x64\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Release|x64.Build.0 = Release|x64\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Release|x86.ActiveCfg = Release|Win32\n\t\t{D86C6E84-3371-4B20-8620-A703FF3F2CC5}.Release|x86.Build.0 = Release|Win32\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Debug|x64.Build.0 = Debug|x64\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Debug|x86.Build.0 = Debug|Win32\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Release|x64.ActiveCfg = Release|x64\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Release|x64.Build.0 = Release|x64\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Release|x86.ActiveCfg = Release|Win32\n\t\t{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}.Release|x86.Build.0 = Release|Win32\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Debug|x64.Build.0 = Debug|x64\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Debug|x86.Build.0 = Debug|Win32\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Release|x64.ActiveCfg = Release|x64\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Release|x64.Build.0 = Release|x64\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Release|x86.ActiveCfg = Release|Win32\n\t\t{722AD25D-C281-48FB-9A58-7699E50F8E6D}.Release|x86.Build.0 = Release|Win32\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Debug|x64.Build.0 = Debug|x64\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Debug|x86.Build.0 = Debug|Win32\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Release|x64.ActiveCfg = Release|x64\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Release|x64.Build.0 = Release|x64\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Release|x86.ActiveCfg = Release|Win32\n\t\t{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}.Release|x86.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {2896B5DF-D1A8-4A2B-BB7D-835C07F05863}\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "msvc/core.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\blender.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\combiner.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\coverage.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\dither.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\fbuffer.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\rasterizer.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\rdram.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\tcoord.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\tex.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\tmem.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\zbuffer.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\divot.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\fetch.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\gamma.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\lerp.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\restore.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\video.c\">\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</ExcludedFromBuild>\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">true</ExcludedFromBuild>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\parallel.cpp\" />\n    <ClCompile Include=\"..\\src\\core\\n64video.c\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\core\\common.h\" />\n    <ClInclude Include=\"..\\src\\core\\msg.h\" />\n    <ClInclude Include=\"..\\src\\core\\parallel.h\" />\n    <ClInclude Include=\"..\\src\\core\\n64video.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"..\\src\\core\\version.h.in\" />\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{D86C6E84-3371-4B20-8620-A703FF3F2CC5}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(WindowsTargetPlatformVersion)'==''\">\n    <!-- Latest Target Version property -->\n    <LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>\n    <WindowsTargetPlatformVersion Condition=\"'$(WindowsTargetPlatformVersion)' == ''\">$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>\n    <TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup>\n    <_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader />\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <TargetMachine>MachineX86</TargetMachine>\n    </Link>\n    <PreBuildEvent>\n      <Command>python \"$(SolutionDir)..\\make_version.py\"</Command>\n    </PreBuildEvent>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n    </Link>\n    <PreBuildEvent>\n      <Command>python \"$(SolutionDir)..\\make_version.py\"</Command>\n    </PreBuildEvent>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader />\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <TargetMachine>MachineX86</TargetMachine>\n    </Link>\n    <PreBuildEvent>\n      <Command>python \"$(SolutionDir)..\\make_version.py\"</Command>\n    </PreBuildEvent>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n    </Link>\n    <PreBuildEvent>\n      <Command>python \"$(SolutionDir)..\\make_version.py\"</Command>\n    </PreBuildEvent>\n  </ItemDefinitionGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "msvc/core.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{5467dd49-ff5e-4be4-93ad-8291721fc00d}</UniqueIdentifier>\n      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{142a5325-573c-4fde-9d8f-af10cb6e28e5}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>\n    </Filter>\n    <Filter Include=\"Source Files\\n64video\">\n      <UniqueIdentifier>{201fc67f-a10c-47a3-a9f6-47b9ccdf155a}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\n64video\\vi\">\n      <UniqueIdentifier>{9ac263b1-1e35-44a3-8368-2c88ff3bb096}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\n64video\\rdp\">\n      <UniqueIdentifier>{0def43d5-fe85-4dc1-9b3e-264603cca8fa}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\core\\parallel.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\blender.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\combiner.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\coverage.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\dither.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\fbuffer.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\rasterizer.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\rdram.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\tcoord.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\tex.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\tmem.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp\\zbuffer.c\">\n      <Filter>Source Files\\n64video\\rdp</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\divot.c\">\n      <Filter>Source Files\\n64video\\vi</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\fetch.c\">\n      <Filter>Source Files\\n64video\\vi</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\gamma.c\">\n      <Filter>Source Files\\n64video\\vi</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\lerp.c\">\n      <Filter>Source Files\\n64video\\vi</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\restore.c\">\n      <Filter>Source Files\\n64video\\vi</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi\\video.c\">\n      <Filter>Source Files\\n64video\\vi</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\rdp.c\">\n      <Filter>Source Files\\n64video</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\core\\n64video\\vi.c\">\n      <Filter>Source Files\\n64video</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\core\\common.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\core\\msg.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\core\\parallel.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\core\\n64video.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"..\\src\\core\\version.h.in\">\n      <Filter>Source Files</Filter>\n    </None>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "msvc/output.vcxproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\output\\gl_core_3_3.c\" />\n    <ClCompile Include=\"..\\src\\output\\vdac.c\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\output\\gl_core_3_3.h\" />\n    <ClInclude Include=\"..\\src\\output\\gl_proc.h\" />\n    <ClInclude Include=\"..\\src\\output\\screen.h\" />\n    <ClInclude Include=\"..\\src\\output\\vdac.h\" />\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{B74D5BAF-38F4-4233-9FC1-BE7E02E81FDE}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(WindowsTargetPlatformVersion)'==''\">\n    <!-- Latest Target Version property -->\n    <LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>\n    <WindowsTargetPlatformVersion Condition=\"'$(WindowsTargetPlatformVersion)' == ''\">$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>\n    <TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup>\n    <_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader />\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <TargetMachine>MachineX86</TargetMachine>\n    </Link>\n    <PreBuildEvent />\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n    </Link>\n    <PreBuildEvent />\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader />\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <TargetMachine>MachineX86</TargetMachine>\n    </Link>\n    <PreBuildEvent />\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DisableSpecificWarnings>4204</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n    </Link>\n    <PreBuildEvent />\n  </ItemDefinitionGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "msvc/output.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\output\\gl_core_3_3.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\output\\vdac.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\output\\gl_core_3_3.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\output\\gl_proc.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\output\\screen.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\output\\vdac.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "msvc/plugin-mupen64plus.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_common.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_config.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_plugin.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_types.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_vidext.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\gfx_m64p.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\plugin\\mupen64plus\\gfx_m64p.c\" />\n    <ClCompile Include=\"..\\src\\plugin\\mupen64plus\\msg.c\" />\n    <ClCompile Include=\"..\\src\\plugin\\mupen64plus\\screen.c\" />\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{54BDC4EF-2526-47F7-A73E-C1C0FBC0237C}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(WindowsTargetPlatformVersion)'==''\">\n    <!-- Latest Target Version property -->\n    <LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>\n    <WindowsTargetPlatformVersion Condition=\"'$(WindowsTargetPlatformVersion)' == ''\">$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>\n    <TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup>\n    <_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n    <TargetName>mupen64plus-video-$(SolutionName)</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <TargetName>mupen64plus-video-$(SolutionName)</TargetName>\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n    <TargetName>mupen64plus-video-$(SolutionName)</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <TargetName>mupen64plus-video-$(SolutionName)</TargetName>\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader />\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <DisableSpecificWarnings>4201</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention />\n      <TargetMachine>MachineX86</TargetMachine>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <DisableSpecificWarnings>4201</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention>\n      </DataExecutionPrevention>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <BasicRuntimeChecks>Default</BasicRuntimeChecks>\n      <SmallerTypeCheck>false</SmallerTypeCheck>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader />\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DisableSpecificWarnings>4201</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention />\n      <TargetMachine>MachineX86</TargetMachine>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <BasicRuntimeChecks>Default</BasicRuntimeChecks>\n      <SmallerTypeCheck>false</SmallerTypeCheck>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <DisableSpecificWarnings>4201</DisableSpecificWarnings>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention>\n      </DataExecutionPrevention>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "msvc/plugin-mupen64plus.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{5467dd49-ff5e-4be4-93ad-8291721fc00d}</UniqueIdentifier>\n      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{142a5325-573c-4fde-9d8f-af10cb6e28e5}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>\n    </Filter>\n    <Filter Include=\"Source Files\\api\">\n      <UniqueIdentifier>{363d4ce3-41b8-4b23-8739-7618a5da0345}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_common.h\">\n      <Filter>Source Files\\api</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_config.h\">\n      <Filter>Source Files\\api</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_plugin.h\">\n      <Filter>Source Files\\api</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_types.h\">\n      <Filter>Source Files\\api</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\api\\m64p_vidext.h\">\n      <Filter>Source Files\\api</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\mupen64plus\\gfx_m64p.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\plugin\\mupen64plus\\gfx_m64p.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\plugin\\mupen64plus\\msg.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\plugin\\mupen64plus\\screen.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "msvc/plugin-zilmar.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"..\\src\\plugin\\zilmar\\config.rc\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\config.c\" />\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\gfx_1.3.c\" />\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\msg.c\" />\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\screen.c\" />\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\wgl_ext.c\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\config.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\gfx_1.3.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\resource.h\" />\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\wgl_ext.h\" />\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{722AD25D-C281-48FB-9A58-7699E50F8E6D}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(WindowsTargetPlatformVersion)'==''\">\n    <!-- Latest Target Version property -->\n    <LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>\n    <WindowsTargetPlatformVersion Condition=\"'$(WindowsTargetPlatformVersion)' == ''\">$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>\n    <TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>\n    <CharacterSet>MultiByte</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup>\n    <_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n    <TargetName>$(SolutionName)</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <TargetName>$(SolutionName)</TargetName>\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n    <TargetName>$(SolutionName)</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <TargetName>$(SolutionName)</TargetName>\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)build\\$(Configuration)\\</OutDir>\n    <IntDir>$(SolutionDir)build\\$(Configuration)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader />\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention />\n      <ImportLibrary>$(OutDir)angrylion.lib</ImportLibrary>\n      <TargetMachine>MachineX86</TargetMachine>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <WarningLevel>Level4</WarningLevel>\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention>\n      </DataExecutionPrevention>\n      <ImportLibrary>$(OutDir)angrylion.lib</ImportLibrary>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <BasicRuntimeChecks>Default</BasicRuntimeChecks>\n      <SmallerTypeCheck>false</SmallerTypeCheck>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader />\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention />\n      <ImportLibrary>$(OutDir)angrylion.lib</ImportLibrary>\n      <TargetMachine>MachineX86</TargetMachine>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <Optimization>MaxSpeed</Optimization>\n      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>\n      <OmitFramePointers>true</OmitFramePointers>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <StringPooling>true</StringPooling>\n      <BasicRuntimeChecks>Default</BasicRuntimeChecks>\n      <SmallerTypeCheck>false</SmallerTypeCheck>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n      <BufferSecurityCheck>false</BufferSecurityCheck>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <PrecompiledHeader>\n      </PrecompiledHeader>\n      <BrowseInformation>true</BrowseInformation>\n      <WarningLevel>Level4</WarningLevel>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <FloatingPointModel>Fast</FloatingPointModel>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <AdditionalIncludeDirectories>$(SolutionDir)..\\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <GenerateMapFile>true</GenerateMapFile>\n      <MapExports>true</MapExports>\n      <SubSystem>Windows</SubSystem>\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <RandomizedBaseAddress>false</RandomizedBaseAddress>\n      <DataExecutionPrevention>\n      </DataExecutionPrevention>\n      <ImportLibrary>$(OutDir)angrylion.lib</ImportLibrary>\n      <AdditionalDependencies>opengl32.lib;core.lib;output.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "msvc/plugin-zilmar.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{5467dd49-ff5e-4be4-93ad-8291721fc00d}</UniqueIdentifier>\n      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{142a5325-573c-4fde-9d8f-af10cb6e28e5}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\config.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\gfx_1.3.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\msg.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\screen.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"..\\src\\plugin\\zilmar\\wgl_ext.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\config.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\gfx_1.3.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\resource.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\src\\plugin\\zilmar\\wgl_ext.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"..\\src\\plugin\\zilmar\\config.rc\">\n      <Filter>Resource Files</Filter>\n    </ResourceCompile>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "src/core/common.h",
    "content": "#pragma once\n\n// endianness\n#define LSB_FIRST 1 \n#ifdef LSB_FIRST\n    #define BYTE_ADDR_XOR       3\n    #define WORD_ADDR_XOR       1\n    #define BYTE4_XOR_BE(a)     ((a) ^ BYTE_ADDR_XOR)\n#else\n    #define BYTE_ADDR_XOR       0\n    #define WORD_ADDR_XOR       0\n    #define BYTE4_XOR_BE(a)     (a)\n#endif\n\n#ifdef LSB_FIRST\n    #define BYTE_XOR_DWORD_SWAP 7\n    #define WORD_XOR_DWORD_SWAP 3\n#else\n    #define BYTE_XOR_DWORD_SWAP 4\n    #define WORD_XOR_DWORD_SWAP 2\n#endif\n\n#define DWORD_XOR_DWORD_SWAP 1\n\n// inlining\n#define INLINE inline\n\n#ifdef _MSC_VER\n#define STRICTINLINE __forceinline\n#elif defined(__GNUC__)\n#define STRICTINLINE __attribute__((always_inline)) inline\n#else\n#define STRICTINLINE inline\n#endif\n\n// misc\n#define UNUSED(x) (void)(x)\n"
  },
  {
    "path": "src/core/msg.h",
    "content": "#pragma once\n\nvoid msg_error(const char * err, ...);\nvoid msg_warning(const char* err, ...);\nvoid msg_debug(const char* err, ...);\n"
  },
  {
    "path": "src/core/n64video/rdp/blender.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic int32_t blenderone = 0xff;\n\nstatic uint8_t bldiv_hwaccurate_table[0x8000];\n\nstatic INLINE void set_blender_input(struct rdp_state* wstate, int cycle, int which, int32_t **input_r, int32_t **input_g, int32_t **input_b, int32_t **input_a, int a, int b)\n{\n\n    switch (a & 0x3)\n    {\n        case 0:\n        {\n            if (cycle == 0)\n            {\n                *input_r = &wstate->pixel_color.r;\n                *input_g = &wstate->pixel_color.g;\n                *input_b = &wstate->pixel_color.b;\n            }\n            else\n            {\n                *input_r = &wstate->blended_pixel_color.r;\n                *input_g = &wstate->blended_pixel_color.g;\n                *input_b = &wstate->blended_pixel_color.b;\n            }\n            break;\n        }\n\n        case 1:\n        {\n            *input_r = &wstate->memory_color.r;\n            *input_g = &wstate->memory_color.g;\n            *input_b = &wstate->memory_color.b;\n            break;\n        }\n\n        case 2:\n        {\n            *input_r = &wstate->blend_color.r;      *input_g = &wstate->blend_color.g;      *input_b = &wstate->blend_color.b;\n            break;\n        }\n\n        case 3:\n        {\n            *input_r = &wstate->fog_color.r;        *input_g = &wstate->fog_color.g;        *input_b = &wstate->fog_color.b;\n            break;\n        }\n    }\n\n    if (which == 0)\n    {\n        switch (b & 0x3)\n        {\n            case 0:     *input_a = &wstate->pixel_color.a; break;\n            case 1:     *input_a = &wstate->fog_color.a; break;\n            case 2:     *input_a = &wstate->blender_shade_alpha; break;\n            case 3:     *input_a = &zero_color; break;\n        }\n    }\n    else\n    {\n        switch (b & 0x3)\n        {\n            case 0:     *input_a = &wstate->inv_pixel_color.a; break;\n            case 1:     *input_a = &wstate->memory_color.a; break;\n            case 2:     *input_a = &blenderone; break;\n            case 3:     *input_a = &zero_color; break;\n        }\n    }\n}\n\nstatic STRICTINLINE int alpha_compare(struct rdp_state* wstate, int32_t comb_alpha)\n{\n    int32_t threshold;\n    if (!wstate->other_modes.alpha_compare_en)\n        return 1;\n    else\n    {\n        if (!wstate->other_modes.dither_alpha_en)\n            threshold = wstate->blend_color.a;\n        else\n            threshold = irand(&wstate->rseed) & 0xff;\n\n\n        if (comb_alpha >= threshold)\n            return 1;\n        else\n            return 0;\n    }\n}\n\nstatic STRICTINLINE void blender_equation_cycle0(struct rdp_state* wstate, int* r, int* g, int* b)\n{\n    int blend1a, blend2a;\n    int blr, blg, blb, sum;\n    blend1a = *wstate->blender1b_a[0] >> 3;\n    blend2a = *wstate->blender2b_a[0] >> 3;\n\n    int mulb;\n\n\n\n    if (wstate->blender2b_a[0] == &wstate->memory_color.a)\n    {\n        blend1a = (blend1a >> wstate->blshifta) & 0x3C;\n        blend2a = (blend2a >> wstate->blshiftb) | 3;\n    }\n\n    mulb = blend2a + 1;\n\n\n    blr = (*wstate->blender1a_r[0]) * blend1a + (*wstate->blender2a_r[0]) * mulb;\n    blg = (*wstate->blender1a_g[0]) * blend1a + (*wstate->blender2a_g[0]) * mulb;\n    blb = (*wstate->blender1a_b[0]) * blend1a + (*wstate->blender2a_b[0]) * mulb;\n\n\n\n    if (!wstate->other_modes.force_blend)\n    {\n\n\n\n\n\n        sum = ((blend1a & ~3) + (blend2a & ~3) + 4) << 9;\n        *r = bldiv_hwaccurate_table[sum | ((blr >> 2) & 0x7ff)];\n        *g = bldiv_hwaccurate_table[sum | ((blg >> 2) & 0x7ff)];\n        *b = bldiv_hwaccurate_table[sum | ((blb >> 2) & 0x7ff)];\n    }\n    else\n    {\n        *r = (blr >> 5) & 0xff;\n        *g = (blg >> 5) & 0xff;\n        *b = (blb >> 5) & 0xff;\n    }\n}\n\nstatic STRICTINLINE void blender_equation_cycle0_gval(struct rdp_state* wstate, int* g)\n{\n    int blend1a, blend2a;\n    int blg, sum;\n    blend1a = *wstate->blender1b_a[0] >> 3;\n    blend2a = *wstate->blender2b_a[0] >> 3;\n\n    int mulb;\n    if (wstate->blender2b_a[0] == &wstate->memory_color.a)\n    {\n        blend1a = (blend1a >> wstate->blshifta) & 0x3C;\n        blend2a = (blend2a >> wstate->blshiftb) | 3;\n    }\n\n    mulb = blend2a + 1;\n\n    blg = (*wstate->blender1a_g[0]) * blend1a + (*wstate->blender2a_g[0]) * mulb;\n\n    if (!wstate->other_modes.force_blend)\n    {\n        sum = ((blend1a & ~3) + (blend2a & ~3) + 4) << 9;\n        *g = bldiv_hwaccurate_table[sum | ((blg >> 2) & 0x7ff)];\n    }\n    else\n        *g = (blg >> 5) & 0xff;\n}\n\nstatic STRICTINLINE void blender_equation_cycle0_2(struct rdp_state* wstate, int* r, int* g, int* b)\n{\n    int blend1a, blend2a;\n    blend1a = *wstate->blender1b_a[0] >> 3;\n    blend2a = *wstate->blender2b_a[0] >> 3;\n\n    if (wstate->blender2b_a[0] == &wstate->memory_color.a)\n    {\n        blend1a = (blend1a >> wstate->pastblshifta) & 0x3C;\n        blend2a = (blend2a >> wstate->pastblshiftb) | 3;\n    }\n\n    blend2a += 1;\n    *r = (((*wstate->blender1a_r[0]) * blend1a + (*wstate->blender2a_r[0]) * blend2a) >> 5) & 0xff;\n    *g = (((*wstate->blender1a_g[0]) * blend1a + (*wstate->blender2a_g[0]) * blend2a) >> 5) & 0xff;\n    *b = (((*wstate->blender1a_b[0]) * blend1a + (*wstate->blender2a_b[0]) * blend2a) >> 5) & 0xff;\n}\n\nstatic STRICTINLINE void blender_equation_cycle0_2_gval(struct rdp_state* wstate, int* g)\n{\n    int blend1a, blend2a;\n    blend1a = *wstate->blender1b_a[0] >> 3;\n    blend2a = *wstate->blender2b_a[0] >> 3;\n\n    if (wstate->blender2b_a[0] == &wstate->memory_color.a)\n    {\n        blend1a = (blend1a >> wstate->pastblshifta) & 0x3C;\n        blend2a = (blend2a >> wstate->pastblshiftb) | 3;\n    }\n\n    blend2a += 1;\n    *g = (((*wstate->blender1a_g[0]) * blend1a + (*wstate->blender2a_g[0]) * blend2a) >> 5) & 0xff;\n}\n\nstatic STRICTINLINE void blender_equation_cycle1(struct rdp_state* wstate, int* r, int* g, int* b)\n{\n    int blend1a, blend2a;\n    int blr, blg, blb, sum;\n    blend1a = *wstate->blender1b_a[1] >> 3;\n    blend2a = *wstate->blender2b_a[1] >> 3;\n\n    int mulb;\n    if (wstate->blender2b_a[1] == &wstate->memory_color.a)\n    {\n        blend1a = (blend1a >> wstate->blshifta) & 0x3C;\n        blend2a = (blend2a >> wstate->blshiftb) | 3;\n    }\n\n    mulb = blend2a + 1;\n    blr = (*wstate->blender1a_r[1]) * blend1a + (*wstate->blender2a_r[1]) * mulb;\n    blg = (*wstate->blender1a_g[1]) * blend1a + (*wstate->blender2a_g[1]) * mulb;\n    blb = (*wstate->blender1a_b[1]) * blend1a + (*wstate->blender2a_b[1]) * mulb;\n\n    if (!wstate->other_modes.force_blend)\n    {\n        sum = ((blend1a & ~3) + (blend2a & ~3) + 4) << 9;\n        *r = bldiv_hwaccurate_table[sum | ((blr >> 2) & 0x7ff)];\n        *g = bldiv_hwaccurate_table[sum | ((blg >> 2) & 0x7ff)];\n        *b = bldiv_hwaccurate_table[sum | ((blb >> 2) & 0x7ff)];\n    }\n    else\n    {\n        *r = (blr >> 5) & 0xff;\n        *g = (blg >> 5) & 0xff;\n        *b = (blb >> 5) & 0xff;\n    }\n}\n\nstatic STRICTINLINE void blender_equation_cycle1_gval(struct rdp_state* wstate, int* g)\n{\n    int blend1a, blend2a;\n    int blg, sum;\n    blend1a = *wstate->blender1b_a[1] >> 3;\n    blend2a = *wstate->blender2b_a[1] >> 3;\n\n    int mulb;\n    if (wstate->blender2b_a[1] == &wstate->memory_color.a)\n    {\n        blend1a = (blend1a >> wstate->blshifta) & 0x3C;\n        blend2a = (blend2a >> wstate->blshiftb) | 3;\n    }\n\n    mulb = blend2a + 1;\n    blg = (*wstate->blender1a_g[1]) * blend1a + (*wstate->blender2a_g[1]) * mulb;\n\n    if (!wstate->other_modes.force_blend)\n    {\n        sum = ((blend1a & ~3) + (blend2a & ~3) + 4) << 9;\n        *g = bldiv_hwaccurate_table[sum | ((blg >> 2) & 0x7ff)];\n    }\n    else\n        *g = (blg >> 5) & 0xff;\n}\n\nstatic STRICTINLINE int blender_1cycle(struct rdp_state* wstate, uint32_t* fr, uint32_t* fg, uint32_t* fb, int dith, uint32_t blend_en, uint32_t prewrap, uint32_t curpixel_cvg, uint32_t curpixel_cvbit)\n{\n    int r, g, b, dontblend;\n\n\n    if (alpha_compare(wstate, wstate->pixel_color.a))\n    {\n\n\n\n\n\n\n        if (wstate->other_modes.antialias_en ? curpixel_cvg : curpixel_cvbit)\n        {\n\n            if (!wstate->other_modes.color_on_cvg || prewrap)\n            {\n                dontblend = (wstate->other_modes.f.partialreject_1cycle && wstate->pixel_color.a >= 0xff);\n                if (!blend_en || dontblend)\n                {\n                    r = *wstate->blender1a_r[0];\n                    g = *wstate->blender1a_g[0];\n                    b = *wstate->blender1a_b[0];\n                }\n                else\n                {\n                    wstate->inv_pixel_color.a =  (~(*wstate->blender1b_a[0])) & 0xff;\n\n\n\n\n\n                    blender_equation_cycle0(wstate, &r, &g, &b);\n                }\n            }\n            else\n            {\n                r = *wstate->blender2a_r[0];\n                g = *wstate->blender2a_g[0];\n                b = *wstate->blender2a_b[0];\n            }\n\n            if (wstate->other_modes.rgb_dither_sel != 3)\n                rgb_dither(wstate->other_modes.rgb_dither_sel, &r, &g, &b, dith);\n\n            *fr = r;\n            *fg = g;\n            *fb = b;\n            return 1;\n        }\n        else\n            return 0;\n        }\n    else\n        return 0;\n}\n\nstatic STRICTINLINE int blender_2cycle_cycle0(struct rdp_state* wstate, uint32_t curpixel_cvg, uint32_t curpixel_cvbit)\n{\n    int r, g, b;\n    int wen = (wstate->other_modes.antialias_en ? curpixel_cvg : curpixel_cvbit) > 0 ? 1 : 0;\n\n    if (wen)\n    {\n        wstate->inv_pixel_color.a =  (~(*wstate->blender1b_a[0])) & 0xff;\n\n        blender_equation_cycle0_2(wstate, &r, &g, &b);\n\n        wstate->blended_pixel_color.r = r;\n        wstate->blended_pixel_color.g = g;\n        wstate->blended_pixel_color.b = b;\n    }\n\n    return wen;\n}\n\n\nstatic STRICTINLINE void blender_2cycle_cycle0_gval(struct rdp_state* wstate, uint32_t curpixel)\n{\n    int g, fbsel;\n    uint32_t fb;\n\n    fbsel = wstate->fb_size;\n\n    if (wstate->fb_size == PIXEL_SIZE_8BIT)\n    {\n        fb = wstate->fb_address + curpixel;\n        if (!(fb & 1))\n            fbsel--;\n    }\n\n    if (fbsel & 1)\n    {\n        wstate->inv_pixel_color.a = (~(*wstate->blender1b_a[0])) & 0xff;\n\n        blender_equation_cycle0_2_gval(wstate, &g);\n\n        wstate->blended_pixel_color.g = g;\n    }\n}\n\n\nstatic STRICTINLINE void blender_2cycle_cycle1(struct rdp_state* wstate, uint32_t* fr, uint32_t* fg, uint32_t* fb, int dith, uint32_t blend_en, uint32_t prewrap)\n{\n    int r, g, b, dontblend;\n\n    if (!wstate->other_modes.color_on_cvg || prewrap)\n    {\n        dontblend = (wstate->other_modes.f.partialreject_2cycle && wstate->pixel_color.a >= 0xff);\n        if (!blend_en || dontblend)\n        {\n            r = *wstate->blender1a_r[1];\n            g = *wstate->blender1a_g[1];\n            b = *wstate->blender1a_b[1];\n        }\n        else\n        {\n            wstate->inv_pixel_color.a =  (~(*wstate->blender1b_a[1])) & 0xff;\n            blender_equation_cycle1(wstate, &r, &g, &b);\n        }\n    }\n    else\n    {\n        r = *wstate->blender2a_r[1];\n        g = *wstate->blender2a_g[1];\n        b = *wstate->blender2a_b[1];\n    }\n\n    if (wstate->other_modes.rgb_dither_sel != 3)\n        rgb_dither(wstate->other_modes.rgb_dither_sel, &r, &g, &b, dith);\n\n    *fr = r;\n    *fg = g;\n    *fb = b;\n}\n\nstatic void blender_init_lut(void)\n{\n    int i, k;\n    int d = 0, n = 0, temp = 0, res = 0, invd = 0, nbit = 0;\n    int ps[9];\n    for (i = 0; i < 0x8000; i++)\n    {\n        res = 0;\n        d = (i >> 11) & 0xf;\n        n = i & 0x7ff;\n        invd = (~d) & 0xf;\n\n\n        temp = invd + (n >> 8) + 1;\n        ps[0] = temp & 7;\n        for (k = 0; k < 8; k++)\n        {\n            nbit = (n >> (7 - k)) & 1;\n            if (res & (0x100 >> k))\n                temp = invd + (ps[k] << 1) + nbit + 1;\n            else\n                temp = d + (ps[k] << 1) + nbit;\n            ps[k + 1] = temp & 7;\n            if (temp & 0x10)\n                res |= (1 << (7 - k));\n        }\n        bldiv_hwaccurate_table[i] = (uint8_t)res;\n    }\n}\n\nvoid rdp_set_fog_color(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->fog_color.r = RGBA32_R(args[1]);\n    wstate->fog_color.g = RGBA32_G(args[1]);\n    wstate->fog_color.b = RGBA32_B(args[1]);\n    wstate->fog_color.a = RGBA32_A(args[1]);\n}\n\nvoid rdp_set_blend_color(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->blend_color.r = RGBA32_R(args[1]);\n    wstate->blend_color.g = RGBA32_G(args[1]);\n    wstate->blend_color.b = RGBA32_B(args[1]);\n    wstate->blend_color.a = RGBA32_A(args[1]);\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/combiner.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic uint32_t special_9bit_clamptable[512];\nstatic int32_t special_9bit_exttable[512];\n\nstatic INLINE void set_suba_rgb_input(struct rdp_state* wstate, int32_t **input_r, int32_t **input_g, int32_t **input_b, int code)\n{\n    switch (code & 0xf)\n    {\n        case 0:     *input_r = &wstate->combined_color.r;   *input_g = &wstate->combined_color.g;   *input_b = &wstate->combined_color.b;   break;\n        case 1:     *input_r = &wstate->texel0_color.r;     *input_g = &wstate->texel0_color.g;     *input_b = &wstate->texel0_color.b;     break;\n        case 2:     *input_r = &wstate->texel1_color.r;     *input_g = &wstate->texel1_color.g;     *input_b = &wstate->texel1_color.b;     break;\n        case 3:     *input_r = &wstate->prim_color.r;       *input_g = &wstate->prim_color.g;       *input_b = &wstate->prim_color.b;       break;\n        case 4:     *input_r = &wstate->shade_color.r;      *input_g = &wstate->shade_color.g;      *input_b = &wstate->shade_color.b;      break;\n        case 5:     *input_r = &wstate->env_color.r;        *input_g = &wstate->env_color.g;        *input_b = &wstate->env_color.b;        break;\n        case 6:     *input_r = &one_color;          *input_g = &one_color;          *input_b = &one_color;      break;\n        case 7:     *input_r = &wstate->noise;              *input_g = &wstate->noise;              *input_b = &wstate->noise;              break;\n        case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:\n        {\n            *input_r = &zero_color;     *input_g = &zero_color;     *input_b = &zero_color;     break;\n        }\n    }\n}\n\nstatic INLINE void set_subb_rgb_input(struct rdp_state* wstate, int32_t **input_r, int32_t **input_g, int32_t **input_b, int code)\n{\n    switch (code & 0xf)\n    {\n        case 0:     *input_r = &wstate->combined_color.r;   *input_g = &wstate->combined_color.g;   *input_b = &wstate->combined_color.b;   break;\n        case 1:     *input_r = &wstate->texel0_color.r;     *input_g = &wstate->texel0_color.g;     *input_b = &wstate->texel0_color.b;     break;\n        case 2:     *input_r = &wstate->texel1_color.r;     *input_g = &wstate->texel1_color.g;     *input_b = &wstate->texel1_color.b;     break;\n        case 3:     *input_r = &wstate->prim_color.r;       *input_g = &wstate->prim_color.g;       *input_b = &wstate->prim_color.b;       break;\n        case 4:     *input_r = &wstate->shade_color.r;      *input_g = &wstate->shade_color.g;      *input_b = &wstate->shade_color.b;      break;\n        case 5:     *input_r = &wstate->env_color.r;        *input_g = &wstate->env_color.g;        *input_b = &wstate->env_color.b;        break;\n        case 6:     *input_r = &wstate->key_center.r;       *input_g = &wstate->key_center.g;       *input_b = &wstate->key_center.b;       break;\n        case 7:     *input_r = &wstate->k4;                 *input_g = &wstate->k4;                 *input_b = &wstate->k4;                 break;\n        case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:\n        {\n            *input_r = &zero_color;     *input_g = &zero_color;     *input_b = &zero_color;     break;\n        }\n    }\n}\n\nstatic INLINE void set_mul_rgb_input(struct rdp_state* wstate, int32_t **input_r, int32_t **input_g, int32_t **input_b, int code)\n{\n    switch (code & 0x1f)\n    {\n        case 0:     *input_r = &wstate->combined_color.r;   *input_g = &wstate->combined_color.g;   *input_b = &wstate->combined_color.b;   break;\n        case 1:     *input_r = &wstate->texel0_color.r;     *input_g = &wstate->texel0_color.g;     *input_b = &wstate->texel0_color.b;     break;\n        case 2:     *input_r = &wstate->texel1_color.r;     *input_g = &wstate->texel1_color.g;     *input_b = &wstate->texel1_color.b;     break;\n        case 3:     *input_r = &wstate->prim_color.r;       *input_g = &wstate->prim_color.g;       *input_b = &wstate->prim_color.b;       break;\n        case 4:     *input_r = &wstate->shade_color.r;      *input_g = &wstate->shade_color.g;      *input_b = &wstate->shade_color.b;      break;\n        case 5:     *input_r = &wstate->env_color.r;        *input_g = &wstate->env_color.g;        *input_b = &wstate->env_color.b;        break;\n        case 6:     *input_r = &wstate->key_scale.r;        *input_g = &wstate->key_scale.g;        *input_b = &wstate->key_scale.b;        break;\n        case 7:     *input_r = &wstate->combined_color.a;   *input_g = &wstate->combined_color.a;   *input_b = &wstate->combined_color.a;   break;\n        case 8:     *input_r = &wstate->texel0_color.a;     *input_g = &wstate->texel0_color.a;     *input_b = &wstate->texel0_color.a;     break;\n        case 9:     *input_r = &wstate->texel1_color.a;     *input_g = &wstate->texel1_color.a;     *input_b = &wstate->texel1_color.a;     break;\n        case 10:    *input_r = &wstate->prim_color.a;       *input_g = &wstate->prim_color.a;       *input_b = &wstate->prim_color.a;       break;\n        case 11:    *input_r = &wstate->shade_color.a;      *input_g = &wstate->shade_color.a;      *input_b = &wstate->shade_color.a;      break;\n        case 12:    *input_r = &wstate->env_color.a;        *input_g = &wstate->env_color.a;        *input_b = &wstate->env_color.a;        break;\n        case 13:    *input_r = &wstate->lod_frac;           *input_g = &wstate->lod_frac;           *input_b = &wstate->lod_frac;           break;\n        case 14:    *input_r = &wstate->primitive_lod_frac; *input_g = &wstate->primitive_lod_frac; *input_b = &wstate->primitive_lod_frac; break;\n        case 15:    *input_r = &wstate->k5;                 *input_g = &wstate->k5;                 *input_b = &wstate->k5;                 break;\n        case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:\n        case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31:\n        {\n            *input_r = &zero_color;     *input_g = &zero_color;     *input_b = &zero_color;     break;\n        }\n    }\n}\n\nstatic INLINE void set_add_rgb_input(struct rdp_state* wstate, int32_t **input_r, int32_t **input_g, int32_t **input_b, int code)\n{\n    switch (code & 0x7)\n    {\n        case 0:     *input_r = &wstate->combined_color.r;   *input_g = &wstate->combined_color.g;   *input_b = &wstate->combined_color.b;   break;\n        case 1:     *input_r = &wstate->texel0_color.r;     *input_g = &wstate->texel0_color.g;     *input_b = &wstate->texel0_color.b;     break;\n        case 2:     *input_r = &wstate->texel1_color.r;     *input_g = &wstate->texel1_color.g;     *input_b = &wstate->texel1_color.b;     break;\n        case 3:     *input_r = &wstate->prim_color.r;       *input_g = &wstate->prim_color.g;       *input_b = &wstate->prim_color.b;       break;\n        case 4:     *input_r = &wstate->shade_color.r;      *input_g = &wstate->shade_color.g;      *input_b = &wstate->shade_color.b;      break;\n        case 5:     *input_r = &wstate->env_color.r;        *input_g = &wstate->env_color.g;        *input_b = &wstate->env_color.b;        break;\n        case 6:     *input_r = &one_color;          *input_g = &one_color;          *input_b = &one_color;          break;\n        case 7:     *input_r = &zero_color;         *input_g = &zero_color;         *input_b = &zero_color;         break;\n    }\n}\n\nstatic INLINE void set_sub_alpha_input(struct rdp_state* wstate, int32_t **input, int code)\n{\n    switch (code & 0x7)\n    {\n        case 0:     *input = &wstate->combined_color.a; break;\n        case 1:     *input = &wstate->texel0_color.a; break;\n        case 2:     *input = &wstate->texel1_color.a; break;\n        case 3:     *input = &wstate->prim_color.a; break;\n        case 4:     *input = &wstate->shade_color.a; break;\n        case 5:     *input = &wstate->env_color.a; break;\n        case 6:     *input = &one_color; break;\n        case 7:     *input = &zero_color; break;\n    }\n}\n\nstatic INLINE void set_mul_alpha_input(struct rdp_state* wstate, int32_t **input, int code)\n{\n    switch (code & 0x7)\n    {\n        case 0:     *input = &wstate->lod_frac; break;\n        case 1:     *input = &wstate->texel0_color.a; break;\n        case 2:     *input = &wstate->texel1_color.a; break;\n        case 3:     *input = &wstate->prim_color.a; break;\n        case 4:     *input = &wstate->shade_color.a; break;\n        case 5:     *input = &wstate->env_color.a; break;\n        case 6:     *input = &wstate->primitive_lod_frac; break;\n        case 7:     *input = &zero_color; break;\n    }\n}\n\nstatic STRICTINLINE int32_t color_combiner_equation(int32_t a, int32_t b, int32_t c, int32_t d)\n{\n\n\n\n\n\n    a = special_9bit_exttable[a];\n    b = special_9bit_exttable[b];\n    c = SIGNF(c, 9);\n    d = special_9bit_exttable[d];\n    a = ((a - b) * c) + (d << 8) + 0x80;\n    return (a & 0x1ffff);\n}\n\nstatic STRICTINLINE int32_t alpha_combiner_equation(int32_t a, int32_t b, int32_t c, int32_t d)\n{\n    a = special_9bit_exttable[a];\n    b = special_9bit_exttable[b];\n    c = SIGNF(c, 9);\n    d = special_9bit_exttable[d];\n    a = (((a - b) * c) + (d << 8) + 0x80) >> 8;\n    return (a & 0x1ff);\n}\n\nstatic STRICTINLINE int32_t chroma_key_min(struct rdp_state* wstate, struct color* col)\n{\n    int32_t redkey, greenkey, bluekey, keyalpha;\n\n\n\n\n    redkey = SIGN(col->r, 17);\n    if (redkey > 0)\n        redkey = ((redkey & 0xf) == 8) ? (-redkey + 0x10) : (-redkey);\n\n    redkey = (wstate->key_width.r << 4) + redkey;\n\n    greenkey = SIGN(col->g, 17);\n    if (greenkey > 0)\n        greenkey = ((greenkey & 0xf) == 8) ? (-greenkey + 0x10) : (-greenkey);\n\n    greenkey = (wstate->key_width.g << 4) + greenkey;\n\n    bluekey = SIGN(col->b, 17);\n    if (bluekey > 0)\n        bluekey = ((bluekey & 0xf) == 8) ? (-bluekey + 0x10) : (-bluekey);\n\n    bluekey = (wstate->key_width.b << 4) + bluekey;\n\n    keyalpha = (redkey < greenkey) ? redkey : greenkey;\n    keyalpha = (bluekey < keyalpha) ? bluekey : keyalpha;\n    keyalpha = clamp(keyalpha, 0, 0xff);\n    return keyalpha;\n}\n\nstatic STRICTINLINE void combiner_1cycle(struct rdp_state* wstate, int adseed, uint32_t* curpixel_cvg)\n{\n\n    int32_t keyalpha = 0, temp = 0;\n    struct color chromabypass = { 0 };\n\n    if (wstate->other_modes.key_en)\n    {\n        chromabypass.r = *wstate->combiner_rgbsub_a_r[1];\n        chromabypass.g = *wstate->combiner_rgbsub_a_g[1];\n        chromabypass.b = *wstate->combiner_rgbsub_a_b[1];\n    }\n\n\n\n\n\n\n    if (wstate->combiner_rgbmul_r[1] != &zero_color)\n    {\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n        wstate->combined_color.r = color_combiner_equation(*wstate->combiner_rgbsub_a_r[1],*wstate->combiner_rgbsub_b_r[1],*wstate->combiner_rgbmul_r[1],*wstate->combiner_rgbadd_r[1]);\n        wstate->combined_color.g = color_combiner_equation(*wstate->combiner_rgbsub_a_g[1],*wstate->combiner_rgbsub_b_g[1],*wstate->combiner_rgbmul_g[1],*wstate->combiner_rgbadd_g[1]);\n        wstate->combined_color.b = color_combiner_equation(*wstate->combiner_rgbsub_a_b[1],*wstate->combiner_rgbsub_b_b[1],*wstate->combiner_rgbmul_b[1],*wstate->combiner_rgbadd_b[1]);\n    }\n    else\n    {\n        wstate->combined_color.r = ((special_9bit_exttable[*wstate->combiner_rgbadd_r[1]] << 8) + 0x80) & 0x1ffff;\n        wstate->combined_color.g = ((special_9bit_exttable[*wstate->combiner_rgbadd_g[1]] << 8) + 0x80) & 0x1ffff;\n        wstate->combined_color.b = ((special_9bit_exttable[*wstate->combiner_rgbadd_b[1]] << 8) + 0x80) & 0x1ffff;\n    }\n\n    if (wstate->combiner_alphamul[1] != &zero_color)\n        wstate->combined_color.a = alpha_combiner_equation(*wstate->combiner_alphasub_a[1],*wstate->combiner_alphasub_b[1],*wstate->combiner_alphamul[1],*wstate->combiner_alphaadd[1]);\n    else\n        wstate->combined_color.a = special_9bit_exttable[*wstate->combiner_alphaadd[1]] & 0x1ff;\n\n    wstate->pixel_color.a = special_9bit_clamptable[wstate->combined_color.a];\n    if (wstate->pixel_color.a == 0xff)\n        wstate->pixel_color.a = 0x100;\n\n    if (!wstate->other_modes.key_en)\n    {\n\n        wstate->combined_color.r >>= 8;\n        wstate->combined_color.g >>= 8;\n        wstate->combined_color.b >>= 8;\n        wstate->pixel_color.r = special_9bit_clamptable[wstate->combined_color.r];\n        wstate->pixel_color.g = special_9bit_clamptable[wstate->combined_color.g];\n        wstate->pixel_color.b = special_9bit_clamptable[wstate->combined_color.b];\n    }\n    else\n    {\n        keyalpha = chroma_key_min(wstate, &wstate->combined_color);\n\n\n\n        wstate->pixel_color.r = special_9bit_clamptable[chromabypass.r];\n        wstate->pixel_color.g = special_9bit_clamptable[chromabypass.g];\n        wstate->pixel_color.b = special_9bit_clamptable[chromabypass.b];\n\n\n        wstate->combined_color.r >>= 8;\n        wstate->combined_color.g >>= 8;\n        wstate->combined_color.b >>= 8;\n    }\n\n\n    if (wstate->other_modes.cvg_times_alpha)\n    {\n        temp = (wstate->pixel_color.a * (*curpixel_cvg) + 4) >> 3;\n        *curpixel_cvg = (temp >> 5) & 0xf;\n    }\n\n    if (!wstate->other_modes.alpha_cvg_select)\n    {\n        if (!wstate->other_modes.key_en)\n        {\n            wstate->pixel_color.a += adseed;\n            if (wstate->pixel_color.a & 0x100)\n                wstate->pixel_color.a = 0xff;\n        }\n        else\n            wstate->pixel_color.a = keyalpha;\n    }\n    else\n    {\n        if (wstate->other_modes.cvg_times_alpha)\n            wstate->pixel_color.a = temp;\n        else\n            wstate->pixel_color.a = (*curpixel_cvg) << 5;\n        if (wstate->pixel_color.a > 0xff)\n            wstate->pixel_color.a = 0xff;\n    }\n\n    wstate->blender_shade_alpha = wstate->shade_color.a + adseed;\n    if (wstate->blender_shade_alpha & 0x100)\n        wstate->blender_shade_alpha = 0xff;\n}\n\nstatic STRICTINLINE void combiner_2cycle_cycle0(struct rdp_state* wstate, int adseed, uint32_t cvg, uint32_t* acalpha)\n{\n    if (wstate->combiner_rgbmul_r[0] != &zero_color)\n    {\n        wstate->combined_color.r = color_combiner_equation(*wstate->combiner_rgbsub_a_r[0],*wstate->combiner_rgbsub_b_r[0],*wstate->combiner_rgbmul_r[0],*wstate->combiner_rgbadd_r[0]);\n        wstate->combined_color.g = color_combiner_equation(*wstate->combiner_rgbsub_a_g[0],*wstate->combiner_rgbsub_b_g[0],*wstate->combiner_rgbmul_g[0],*wstate->combiner_rgbadd_g[0]);\n        wstate->combined_color.b = color_combiner_equation(*wstate->combiner_rgbsub_a_b[0],*wstate->combiner_rgbsub_b_b[0],*wstate->combiner_rgbmul_b[0],*wstate->combiner_rgbadd_b[0]);\n    }\n    else\n    {\n        wstate->combined_color.r = ((special_9bit_exttable[*wstate->combiner_rgbadd_r[0]] << 8) + 0x80) & 0x1ffff;\n        wstate->combined_color.g = ((special_9bit_exttable[*wstate->combiner_rgbadd_g[0]] << 8) + 0x80) & 0x1ffff;\n        wstate->combined_color.b = ((special_9bit_exttable[*wstate->combiner_rgbadd_b[0]] << 8) + 0x80) & 0x1ffff;\n    }\n\n    if (wstate->combiner_alphamul[0] != &zero_color)\n        wstate->combined_color.a = alpha_combiner_equation(*wstate->combiner_alphasub_a[0],*wstate->combiner_alphasub_b[0],*wstate->combiner_alphamul[0],*wstate->combiner_alphaadd[0]);\n    else\n        wstate->combined_color.a = special_9bit_exttable[*wstate->combiner_alphaadd[0]] & 0x1ff;\n\n\n\n    if (wstate->other_modes.alpha_compare_en)\n    {\n        int32_t preacalpha = special_9bit_clamptable[wstate->combined_color.a];\n        if (preacalpha == 0xff)\n            preacalpha = 0x100;\n\n        if (!wstate->other_modes.alpha_cvg_select)\n        {\n            preacalpha += adseed;\n            if (preacalpha & 0x100)\n                preacalpha = 0xff;\n        }\n        else\n        {\n            if (wstate->other_modes.cvg_times_alpha)\n                preacalpha = (preacalpha * cvg + 4) >> 3;\n            else\n                preacalpha = cvg << 5;\n\n            if (preacalpha > 0xff)\n                preacalpha = 0xff;\n        }\n\n        *acalpha = preacalpha;\n    }\n\n\n\n\n\n    wstate->combined_color.r >>= 8;\n    wstate->combined_color.g >>= 8;\n    wstate->combined_color.b >>= 8;\n\n    wstate->blender_shade_alpha = wstate->shade_color.a + adseed;\n    if (wstate->blender_shade_alpha & 0x100)\n        wstate->blender_shade_alpha = 0xff;\n}\n\nstatic STRICTINLINE void combiner_2cycle_cycle1(struct rdp_state* wstate, int adseed, uint32_t* curpixel_cvg)\n{\n    int32_t keyalpha = 0, temp = 0;\n    struct color chromabypass = { 0 };\n\n    wstate->texel0_color = wstate->texel1_color;\n    wstate->texel1_color = wstate->nexttexel_color;\n\n\n\n\n\n\n\n\n\n    if (wstate->other_modes.key_en)\n    {\n        chromabypass.r = *wstate->combiner_rgbsub_a_r[1];\n        chromabypass.g = *wstate->combiner_rgbsub_a_g[1];\n        chromabypass.b = *wstate->combiner_rgbsub_a_b[1];\n    }\n\n    if (wstate->combiner_rgbmul_r[1] != &zero_color)\n    {\n        wstate->combined_color.r = color_combiner_equation(*wstate->combiner_rgbsub_a_r[1],*wstate->combiner_rgbsub_b_r[1],*wstate->combiner_rgbmul_r[1],*wstate->combiner_rgbadd_r[1]);\n        wstate->combined_color.g = color_combiner_equation(*wstate->combiner_rgbsub_a_g[1],*wstate->combiner_rgbsub_b_g[1],*wstate->combiner_rgbmul_g[1],*wstate->combiner_rgbadd_g[1]);\n        wstate->combined_color.b = color_combiner_equation(*wstate->combiner_rgbsub_a_b[1],*wstate->combiner_rgbsub_b_b[1],*wstate->combiner_rgbmul_b[1],*wstate->combiner_rgbadd_b[1]);\n    }\n    else\n    {\n        wstate->combined_color.r = ((special_9bit_exttable[*wstate->combiner_rgbadd_r[1]] << 8) + 0x80) & 0x1ffff;\n        wstate->combined_color.g = ((special_9bit_exttable[*wstate->combiner_rgbadd_g[1]] << 8) + 0x80) & 0x1ffff;\n        wstate->combined_color.b = ((special_9bit_exttable[*wstate->combiner_rgbadd_b[1]] << 8) + 0x80) & 0x1ffff;\n    }\n\n    if (wstate->combiner_alphamul[1] != &zero_color)\n        wstate->combined_color.a = alpha_combiner_equation(*wstate->combiner_alphasub_a[1],*wstate->combiner_alphasub_b[1],*wstate->combiner_alphamul[1],*wstate->combiner_alphaadd[1]);\n    else\n        wstate->combined_color.a = special_9bit_exttable[*wstate->combiner_alphaadd[1]] & 0x1ff;\n\n    if (!wstate->other_modes.key_en)\n    {\n\n        wstate->combined_color.r >>= 8;\n        wstate->combined_color.g >>= 8;\n        wstate->combined_color.b >>= 8;\n\n        wstate->pixel_color.r = special_9bit_clamptable[wstate->combined_color.r];\n        wstate->pixel_color.g = special_9bit_clamptable[wstate->combined_color.g];\n        wstate->pixel_color.b = special_9bit_clamptable[wstate->combined_color.b];\n    }\n    else\n    {\n        keyalpha = chroma_key_min(wstate, &wstate->combined_color);\n\n\n\n        wstate->pixel_color.r = special_9bit_clamptable[chromabypass.r];\n        wstate->pixel_color.g = special_9bit_clamptable[chromabypass.g];\n        wstate->pixel_color.b = special_9bit_clamptable[chromabypass.b];\n\n\n        wstate->combined_color.r >>= 8;\n        wstate->combined_color.g >>= 8;\n        wstate->combined_color.b >>= 8;\n    }\n\n    wstate->pixel_color.a = special_9bit_clamptable[wstate->combined_color.a];\n    if (wstate->pixel_color.a == 0xff)\n        wstate->pixel_color.a = 0x100;\n\n\n    if (wstate->other_modes.cvg_times_alpha)\n    {\n        temp = (wstate->pixel_color.a * (*curpixel_cvg) + 4) >> 3;\n\n        *curpixel_cvg = (temp >> 5) & 0xf;\n\n\n    }\n\n    if (!wstate->other_modes.alpha_cvg_select)\n    {\n        if (!wstate->other_modes.key_en)\n        {\n            wstate->pixel_color.a += adseed;\n            if (wstate->pixel_color.a & 0x100)\n                wstate->pixel_color.a = 0xff;\n        }\n        else\n            wstate->pixel_color.a = keyalpha;\n    }\n    else\n    {\n        if (wstate->other_modes.cvg_times_alpha)\n            wstate->pixel_color.a = temp;\n        else\n            wstate->pixel_color.a = (*curpixel_cvg) << 5;\n        if (wstate->pixel_color.a > 0xff)\n            wstate->pixel_color.a = 0xff;\n    }\n\n    wstate->blender_shade_alpha = wstate->shade_color.a + adseed;\n    if (wstate->blender_shade_alpha & 0x100)\n        wstate->blender_shade_alpha = 0xff;\n}\n\nstatic void combiner_init_lut(void)\n{\n    int i;\n    for(i = 0; i < 0x200; i++)\n    {\n        switch((i >> 7) & 3)\n        {\n        case 0:\n        case 1:\n            special_9bit_clamptable[i] = i & 0xff;\n            break;\n        case 2:\n            special_9bit_clamptable[i] = 0xff;\n            break;\n        case 3:\n            special_9bit_clamptable[i] = 0;\n            break;\n        }\n    }\n\n    for (i = 0; i < 0x200; i++)\n    {\n        special_9bit_exttable[i] = ((i & 0x180) == 0x180) ? (i | ~0x1ff) : (i & 0x1ff);\n    }\n}\n\nstatic void combiner_init(struct rdp_state* wstate)\n{\n    wstate->combiner_rgbsub_a_r[0] = wstate->combiner_rgbsub_a_r[1] = &one_color;\n    wstate->combiner_rgbsub_a_g[0] = wstate->combiner_rgbsub_a_g[1] = &one_color;\n    wstate->combiner_rgbsub_a_b[0] = wstate->combiner_rgbsub_a_b[1] = &one_color;\n    wstate->combiner_rgbsub_b_r[0] = wstate->combiner_rgbsub_b_r[1] = &one_color;\n    wstate->combiner_rgbsub_b_g[0] = wstate->combiner_rgbsub_b_g[1] = &one_color;\n    wstate->combiner_rgbsub_b_b[0] = wstate->combiner_rgbsub_b_b[1] = &one_color;\n    wstate->combiner_rgbmul_r[0] = wstate->combiner_rgbmul_r[1] = &one_color;\n    wstate->combiner_rgbmul_g[0] = wstate->combiner_rgbmul_g[1] = &one_color;\n    wstate->combiner_rgbmul_b[0] = wstate->combiner_rgbmul_b[1] = &one_color;\n    wstate->combiner_rgbadd_r[0] = wstate->combiner_rgbadd_r[1] = &one_color;\n    wstate->combiner_rgbadd_g[0] = wstate->combiner_rgbadd_g[1] = &one_color;\n    wstate->combiner_rgbadd_b[0] = wstate->combiner_rgbadd_b[1] = &one_color;\n\n    wstate->combiner_alphasub_a[0] = wstate->combiner_alphasub_a[1] = &one_color;\n    wstate->combiner_alphasub_b[0] = wstate->combiner_alphasub_b[1] = &one_color;\n    wstate->combiner_alphamul[0] = wstate->combiner_alphamul[1] = &one_color;\n    wstate->combiner_alphaadd[0] = wstate->combiner_alphaadd[1] = &one_color;\n}\n\nvoid rdp_set_prim_color(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->min_level = (args[0] >> 8) & 0x1f;\n    wstate->primitive_lod_frac = args[0] & 0xff;\n    wstate->prim_color.r = RGBA32_R(args[1]);\n    wstate->prim_color.g = RGBA32_G(args[1]);\n    wstate->prim_color.b = RGBA32_B(args[1]);\n    wstate->prim_color.a = RGBA32_A(args[1]);\n}\n\nvoid rdp_set_env_color(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->env_color.r = RGBA32_R(args[1]);\n    wstate->env_color.g = RGBA32_G(args[1]);\n    wstate->env_color.b = RGBA32_B(args[1]);\n    wstate->env_color.a = RGBA32_A(args[1]);\n}\n\nvoid rdp_set_combine(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->combine.sub_a_rgb0  = (args[0] >> 20) & 0xf;\n    wstate->combine.mul_rgb0    = (args[0] >> 15) & 0x1f;\n    wstate->combine.sub_a_a0    = (args[0] >> 12) & 0x7;\n    wstate->combine.mul_a0      = (args[0] >>  9) & 0x7;\n    wstate->combine.sub_a_rgb1  = (args[0] >>  5) & 0xf;\n    wstate->combine.mul_rgb1    = (args[0] >>  0) & 0x1f;\n\n    wstate->combine.sub_b_rgb0  = (args[1] >> 28) & 0xf;\n    wstate->combine.sub_b_rgb1  = (args[1] >> 24) & 0xf;\n    wstate->combine.sub_a_a1    = (args[1] >> 21) & 0x7;\n    wstate->combine.mul_a1      = (args[1] >> 18) & 0x7;\n    wstate->combine.add_rgb0    = (args[1] >> 15) & 0x7;\n    wstate->combine.sub_b_a0    = (args[1] >> 12) & 0x7;\n    wstate->combine.add_a0      = (args[1] >>  9) & 0x7;\n    wstate->combine.add_rgb1    = (args[1] >>  6) & 0x7;\n    wstate->combine.sub_b_a1    = (args[1] >>  3) & 0x7;\n    wstate->combine.add_a1      = (args[1] >>  0) & 0x7;\n\n\n    set_suba_rgb_input(wstate, &wstate->combiner_rgbsub_a_r[0], &wstate->combiner_rgbsub_a_g[0], &wstate->combiner_rgbsub_a_b[0], wstate->combine.sub_a_rgb0);\n    set_subb_rgb_input(wstate, &wstate->combiner_rgbsub_b_r[0], &wstate->combiner_rgbsub_b_g[0], &wstate->combiner_rgbsub_b_b[0], wstate->combine.sub_b_rgb0);\n    set_mul_rgb_input(wstate, &wstate->combiner_rgbmul_r[0], &wstate->combiner_rgbmul_g[0], &wstate->combiner_rgbmul_b[0], wstate->combine.mul_rgb0);\n    set_add_rgb_input(wstate, &wstate->combiner_rgbadd_r[0], &wstate->combiner_rgbadd_g[0], &wstate->combiner_rgbadd_b[0], wstate->combine.add_rgb0);\n    set_sub_alpha_input(wstate, &wstate->combiner_alphasub_a[0], wstate->combine.sub_a_a0);\n    set_sub_alpha_input(wstate, &wstate->combiner_alphasub_b[0], wstate->combine.sub_b_a0);\n    set_mul_alpha_input(wstate, &wstate->combiner_alphamul[0], wstate->combine.mul_a0);\n    set_sub_alpha_input(wstate, &wstate->combiner_alphaadd[0], wstate->combine.add_a0);\n\n    set_suba_rgb_input(wstate, &wstate->combiner_rgbsub_a_r[1], &wstate->combiner_rgbsub_a_g[1], &wstate->combiner_rgbsub_a_b[1], wstate->combine.sub_a_rgb1);\n    set_subb_rgb_input(wstate, &wstate->combiner_rgbsub_b_r[1], &wstate->combiner_rgbsub_b_g[1], &wstate->combiner_rgbsub_b_b[1], wstate->combine.sub_b_rgb1);\n    set_mul_rgb_input(wstate, &wstate->combiner_rgbmul_r[1], &wstate->combiner_rgbmul_g[1], &wstate->combiner_rgbmul_b[1], wstate->combine.mul_rgb1);\n    set_add_rgb_input(wstate, &wstate->combiner_rgbadd_r[1], &wstate->combiner_rgbadd_g[1], &wstate->combiner_rgbadd_b[1], wstate->combine.add_rgb1);\n    set_sub_alpha_input(wstate, &wstate->combiner_alphasub_a[1], wstate->combine.sub_a_a1);\n    set_sub_alpha_input(wstate, &wstate->combiner_alphasub_b[1], wstate->combine.sub_b_a1);\n    set_mul_alpha_input(wstate, &wstate->combiner_alphamul[1], wstate->combine.mul_a1);\n    set_sub_alpha_input(wstate, &wstate->combiner_alphaadd[1], wstate->combine.add_a1);\n\n    wstate->other_modes.f.stalederivs = 1;\n}\n\nvoid rdp_set_key_gb(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->key_width.g = (args[0] >> 12) & 0xfff;\n    wstate->key_width.b = args[0] & 0xfff;\n    wstate->key_center.g = (args[1] >> 24) & 0xff;\n    wstate->key_scale.g = (args[1] >> 16) & 0xff;\n    wstate->key_center.b = (args[1] >> 8) & 0xff;\n    wstate->key_scale.b = args[1] & 0xff;\n}\n\nvoid rdp_set_key_r(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->key_width.r = (args[1] >> 16) & 0xfff;\n    wstate->key_center.r = (args[1] >> 8) & 0xff;\n    wstate->key_scale.r = args[1] & 0xff;\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/coverage.c",
    "content": "#ifdef N64VIDEO_C\n\n#define CVG_CLAMP               0\n#define CVG_WRAP                1\n#define CVG_ZAP                 2\n#define CVG_SAVE                3\n\nstatic struct  {\n    uint8_t cvg;\n    uint8_t cvbit;\n    uint8_t xoff;\n    uint8_t yoff;\n} cvarray[0x100];\n\nstatic STRICTINLINE uint32_t rightcvghex(uint32_t x, uint32_t fmask)\n{\n    uint32_t covered = ((x & 7) + 1) >> 1;\n\n    covered = 0xf0 >> covered;\n    return (covered & fmask);\n}\n\nstatic STRICTINLINE uint32_t leftcvghex(uint32_t x, uint32_t fmask)\n{\n    uint32_t covered = ((x & 7) + 1) >> 1;\n    covered = 0xf >> covered;\n    return (covered & fmask);\n}\n\n\n\nstatic STRICTINLINE void compute_cvg_flip(struct rdp_state* wstate, int32_t scanline)\n{\n    int32_t purgestart, purgeend;\n    int i, length, fmask, maskshift, fmaskshifted;\n    int32_t minorcur, majorcur, minorcurint, majorcurint, samecvg;\n\n    purgestart = wstate->span[scanline].rx;\n    purgeend = wstate->span[scanline].lx;\n    length = purgeend - purgestart;\n    if (length >= 0)\n    {\n\n\n\n\n\n\n        memset(&wstate->cvgbuf[purgestart], 0xff, length + 1);\n        for(i = 0; i < 4; i++)\n        {\n\n                fmask = 0xa >> (i & 1);\n\n\n\n\n                maskshift = (i - 2) & 4;\n                fmaskshifted = fmask << maskshift;\n\n                if (!wstate->span[scanline].invalyscan[i])\n                {\n                   int k;\n                    minorcur = wstate->span[scanline].minorx[i];\n                    majorcur = wstate->span[scanline].majorx[i];\n                    minorcurint = minorcur >> 3;\n                    majorcurint = majorcur >> 3;\n\n\n                    for (k = purgestart; k <= majorcurint; k++)\n                        wstate->cvgbuf[k] &= ~fmaskshifted;\n                    for (k = minorcurint; k <= purgeend; k++)\n                        wstate->cvgbuf[k] &= ~fmaskshifted;\n\n\n\n\n\n\n\n\n\n                    if (minorcurint > majorcurint)\n                    {\n                        wstate->cvgbuf[minorcurint] |= (rightcvghex(minorcur, fmask) << maskshift);\n                        wstate->cvgbuf[majorcurint] |= (leftcvghex(majorcur, fmask) << maskshift);\n                    }\n                    else if (minorcurint == majorcurint)\n                    {\n                        samecvg = rightcvghex(minorcur, fmask) & leftcvghex(majorcur, fmask);\n                        wstate->cvgbuf[majorcurint] |= (samecvg << maskshift);\n                    }\n                }\n                else\n                {\n                    int k;\n                    for (k = purgestart; k <= purgeend; k++)\n                        wstate->cvgbuf[k] &= ~fmaskshifted;\n                }\n\n        }\n    }\n\n\n}\n\nstatic STRICTINLINE void compute_cvg_noflip(struct rdp_state* wstate, int32_t scanline)\n{\n    int32_t purgestart, purgeend;\n    int i, length, fmask, maskshift, fmaskshifted;\n    int32_t minorcur, majorcur, minorcurint, majorcurint, samecvg;\n\n    purgestart = wstate->span[scanline].lx;\n    purgeend = wstate->span[scanline].rx;\n    length = purgeend - purgestart;\n\n    if (length >= 0)\n    {\n        memset(&wstate->cvgbuf[purgestart], 0xff, length + 1);\n\n        for(i = 0; i < 4; i++)\n        {\n            fmask = 0xa >> (i & 1);\n            maskshift = (i - 2) & 4;\n            fmaskshifted = fmask << maskshift;\n\n            if (!wstate->span[scanline].invalyscan[i])\n            {\n               int k;\n                minorcur = wstate->span[scanline].minorx[i];\n                majorcur = wstate->span[scanline].majorx[i];\n                minorcurint = minorcur >> 3;\n                majorcurint = majorcur >> 3;\n\n                for (k = purgestart; k <= minorcurint; k++)\n                    wstate->cvgbuf[k] &= ~fmaskshifted;\n                for (k = majorcurint; k <= purgeend; k++)\n                    wstate->cvgbuf[k] &= ~fmaskshifted;\n\n                if (majorcurint > minorcurint)\n                {\n                    wstate->cvgbuf[minorcurint] |= (leftcvghex(minorcur, fmask) << maskshift);\n                    wstate->cvgbuf[majorcurint] |= (rightcvghex(majorcur, fmask) << maskshift);\n                }\n                else if (minorcurint == majorcurint)\n                {\n                    samecvg = leftcvghex(minorcur, fmask) & rightcvghex(majorcur, fmask);\n                    wstate->cvgbuf[majorcurint] |= (samecvg << maskshift);\n                }\n            }\n            else\n            {\n                int k;\n                for (k = purgestart; k <= purgeend; k++)\n                    wstate->cvgbuf[k] &= ~fmaskshifted;\n            }\n        }\n    }\n}\n\nstatic STRICTINLINE int finalize_spanalpha(int cvg_dest, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg)\n{\n    int finalcvg = 0;\n\n\n\n    switch(cvg_dest)\n    {\n    case CVG_CLAMP:\n        if (!blend_en)\n        {\n            finalcvg = curpixel_cvg - 1;\n\n\n        }\n        else\n        {\n            finalcvg = curpixel_cvg + curpixel_memcvg;\n        }\n\n\n\n        if (!(finalcvg & 8))\n            finalcvg &= 7;\n        else\n            finalcvg = 7;\n\n        break;\n    case CVG_WRAP:\n        finalcvg = (curpixel_cvg + curpixel_memcvg) & 7;\n        break;\n    case CVG_ZAP:\n        finalcvg = 7;\n        break;\n    case CVG_SAVE:\n        finalcvg = curpixel_memcvg;\n        break;\n    }\n\n    return finalcvg;\n}\n\nstatic STRICTINLINE uint16_t decompress_cvmask_frombyte(uint8_t x)\n{\n    uint16_t y = (x & 0x5) | ((x & 0x5a) << 4) | ((x & 0xa0) << 8);\n    return y;\n}\n\nstatic STRICTINLINE void lookup_cvmask_derivatives(uint8_t mask, uint8_t* offx, uint8_t* offy, uint32_t* curpixel_cvg, uint32_t* curpixel_cvbit)\n{\n    *curpixel_cvg = cvarray[mask].cvg;\n    *curpixel_cvbit = cvarray[mask].cvbit;\n    *offx = cvarray[mask].xoff;\n    *offy = cvarray[mask].yoff;\n}\n\nstatic void coverage_init_lut(void)\n{\n    uint8_t i = 0, k = 0;\n    uint16_t mask = 0, maskx = 0, masky = 0;\n    uint8_t offx = 0, offy = 0;\n    const uint8_t yarray[16] = {0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0};\n    const uint8_t xarray[16] = {0, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};\n\n    do {\n        mask = decompress_cvmask_frombyte(i);\n        cvarray[i].cvg = cvarray[i].cvbit = 0;\n        cvarray[i].cvbit = (i >> 7) & 1;\n        for (k = 0; k < 8; k++)\n            cvarray[i].cvg += ((i >> k) & 1);\n\n\n        masky = maskx = offx = offy = 0;\n        for (k = 0; k < 4; k++)\n            masky |= ((mask & (0xf000 >> (k << 2))) > 0) << k;\n\n        offy = yarray[masky];\n\n        maskx = (mask & (0xf000 >> (offy << 2))) >> ((offy ^ 3) << 2);\n\n\n        offx = xarray[maskx];\n\n        cvarray[i].xoff = offx;\n        cvarray[i].yoff = offy;\n    } while (i++ != 0xff);\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/dither.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic const uint8_t bayer_matrix[16] =\n{\n     0,  4,  1, 5,\n     4,  0,  5, 1,\n     3,  7,  2, 6,\n     7,  3,  6, 2\n};\n\n\nstatic const uint8_t magic_matrix[16] =\n{\n     0,  6,  1, 7,\n     4,  2,  5, 3,\n     3,  5,  2, 4,\n     7,  1,  6, 0\n};\n\nstatic STRICTINLINE void rgb_dither(int rgb_dither_sel, int* r, int* g, int* b, int dith)\n{\n\n    int32_t newr = *r, newg = *g, newb = *b;\n    int32_t rcomp, gcomp, bcomp;\n\n\n    if (newr > 247)\n        newr = 255;\n    else\n        newr = (newr & 0xf8) + 8;\n    if (newg > 247)\n        newg = 255;\n    else\n        newg = (newg & 0xf8) + 8;\n    if (newb > 247)\n        newb = 255;\n    else\n        newb = (newb & 0xf8) + 8;\n\n    if (rgb_dither_sel != 2)\n        rcomp = gcomp = bcomp = dith;\n    else\n    {\n        rcomp = dith & 7;\n        gcomp = (dith >> 3) & 7;\n        bcomp = (dith >> 6) & 7;\n    }\n\n\n\n\n\n    int32_t replacesign = (rcomp - (*r & 7)) >> 31;\n\n    int32_t ditherdiff = newr - *r;\n    *r = *r + (ditherdiff & replacesign);\n\n    replacesign = (gcomp - (*g & 7)) >> 31;\n    ditherdiff = newg - *g;\n    *g = *g + (ditherdiff & replacesign);\n\n    replacesign = (bcomp - (*b & 7)) >> 31;\n    ditherdiff = newb - *b;\n    *b = *b + (ditherdiff & replacesign);\n}\n\nstatic STRICTINLINE void rgb_dither_gval(int rgb_dither_sel, int* g, int dith)\n{\n    int32_t newg = *g;\n    int32_t gcomp;\n\n    if (newg > 247)\n        newg = 255;\n    else\n        newg = (newg & 0xf8) + 8;\n\n    if (rgb_dither_sel != 2)\n        gcomp = dith;\n    else\n        gcomp = (dith >> 3) & 7;\n\n    int32_t replacesign = (gcomp - (*g & 7)) >> 31;\n    int32_t ditherdiff = newg - *g;\n    *g = *g + (ditherdiff & replacesign);\n}\n\nstatic STRICTINLINE void get_dither_noise(struct rdp_state* wstate, int x, int y, int* cdith, int* adith)\n{\n    if (!wstate->other_modes.f.getditherlevel)\n        wstate->noise = ((irand(&wstate->rseed) & 7) << 6) | 0x20;\n\n    y >>= wstate->scfield;\n\n    int dithindex;\n    switch(wstate->other_modes.f.rgb_alpha_dither)\n    {\n    case 0:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *adith = *cdith = magic_matrix[dithindex];\n        break;\n    case 1:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = magic_matrix[dithindex];\n        *adith = (~(*cdith)) & 7;\n        break;\n    case 2:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = magic_matrix[dithindex];\n        *adith = (wstate->noise >> 6) & 7;\n        break;\n    case 3:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = magic_matrix[dithindex];\n        *adith = 0;\n        break;\n    case 4:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *adith = *cdith = bayer_matrix[dithindex];\n        break;\n    case 5:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = bayer_matrix[dithindex];\n        *adith = (~(*cdith)) & 7;\n        break;\n    case 6:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = bayer_matrix[dithindex];\n        *adith = (wstate->noise >> 6) & 7;\n        break;\n    case 7:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = bayer_matrix[dithindex];\n        *adith = 0;\n        break;\n    case 8:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = irand(&wstate->rseed);\n        *adith = magic_matrix[dithindex];\n        break;\n    case 9:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = irand(&wstate->rseed);\n        *adith = (~magic_matrix[dithindex]) & 7;\n        break;\n    case 10:\n        *cdith = irand(&wstate->rseed);\n        *adith = (wstate->noise >> 6) & 7;\n        break;\n    case 11:\n        *cdith = irand(&wstate->rseed);\n        *adith = 0;\n        break;\n    case 12:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = 7;\n        *adith = bayer_matrix[dithindex];\n        break;\n    case 13:\n        dithindex = ((y & 3) << 2) | (x & 3);\n        *cdith = 7;\n        *adith = (~bayer_matrix[dithindex]) & 7;\n        break;\n    case 14:\n        *cdith = 7;\n        *adith = (wstate->noise >> 6) & 7;\n        break;\n    case 15:\n        *cdith = 7;\n        *adith = 0;\n        break;\n    }\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/fbuffer.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic void fbwrite_4(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx);\nstatic void fbwrite_8(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx);\nstatic void fbwrite_16(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx);\nstatic void fbwrite_32(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx);\nstatic void fbfill_4(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx);\nstatic void fbfill_8(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx);\nstatic void fbfill_16(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx);\nstatic void fbfill_32(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx);\nstatic void fbread_4(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\nstatic void fbread_8(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\nstatic void fbread_16(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\nstatic void fbread_32(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\nstatic void fbread2_4(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\nstatic void fbread2_8(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\nstatic void fbread2_16(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\nstatic void fbread2_32(struct rdp_state* wstate, uint32_t num, uint32_t* curpixel_memcvg);\n\nstatic void (*fbread_func[4])(struct rdp_state*, uint32_t, uint32_t*) =\n{\n    fbread_4, fbread_8, fbread_16, fbread_32\n};\n\nstatic void (*fbread2_func[4])(struct rdp_state*,uint32_t, uint32_t*) =\n{\n    fbread2_4, fbread2_8, fbread2_16, fbread2_32\n};\n\nstatic void (*fbwrite_func[4])(struct rdp_state*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, int, int*) =\n{\n    fbwrite_4, fbwrite_8, fbwrite_16, fbwrite_32\n};\n\nstatic void (*fbfill_func[4])(struct rdp_state*, uint32_t, int, int*) =\n{\n    fbfill_4, fbfill_8, fbfill_16, fbfill_32\n};\n\nstatic void fbwrite_4(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx)\n{\n    UNUSED(r);\n    UNUSED(g);\n    UNUSED(b);\n    UNUSED(blend_en);\n    UNUSED(curpixel_cvg);\n    UNUSED(curpixel_memcvg);\n    UNUSED(flip);\n    UNUSED(delayedhbwidx);\n\n    uint32_t fb = wstate->fb_address + curpixel;\n    RWRITEADDR8(fb, 0);\n}\n\nstatic void fbwrite_8(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx)\n{\n    UNUSED(b);\n    UNUSED(blend_en);\n    UNUSED(curpixel_cvg);\n    UNUSED(curpixel_memcvg);\n\n    uint32_t fb = wstate->fb_address + curpixel;\n    rdram_write_pair8(fb, (fb & 1) ? (g & 0xff) : (r & 0xff), flip, delayedhbwidx);\n}\n\nstatic void fbwrite_16(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx)\n{\n    UNUSED(flip);\n    UNUSED(delayedhbwidx);\n\n#undef CVG_DRAW\n#ifdef CVG_DRAW\n    int covdraw = (curpixel_cvg - 1) << 5;\n    r=covdraw; g=covdraw; b=covdraw;\n#endif\n\n    uint32_t fb;\n    uint16_t rval;\n    uint8_t hval;\n    fb = (wstate->fb_address >> 1) + curpixel;\n\n    int32_t finalcvg = finalize_spanalpha(wstate->other_modes.cvg_dest, blend_en, curpixel_cvg, curpixel_memcvg);\n    int16_t finalcolor;\n\n    if (wstate->fb_format == FORMAT_RGBA)\n    {\n        finalcolor = ((r & ~7) << 8) | ((g & ~7) << 3) | ((b & ~7) >> 2);\n    }\n    else\n    {\n        finalcolor = (int16_t)((r << 8) | (finalcvg << 5));\n        finalcvg = 0;\n    }\n\n\n    rval = finalcolor|(uint16_t)(finalcvg >> 2);\n    hval = finalcvg & 3;\n\n    rdram_write_pair16(fb, rval, hval, 1);\n}\n\nstatic void fbwrite_32(struct rdp_state* wstate, uint32_t curpixel, uint32_t r, uint32_t g, uint32_t b, uint32_t blend_en, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx)\n{\n    UNUSED(flip);\n    UNUSED(delayedhbwidx);\n\n    uint32_t fb = (wstate->fb_address >> 2) + curpixel;\n\n    int32_t finalcolor;\n    int32_t finalcvg = finalize_spanalpha(wstate->other_modes.cvg_dest, blend_en, curpixel_cvg, curpixel_memcvg);\n\n    finalcolor = (r << 24) | (g << 16) | (b << 8);\n    finalcolor |= (finalcvg << 5);\n\n    rdram_write_pair32(fb, finalcolor, (g & 1) ? 3 : 0, 0);\n}\n\nstatic void fbfill_4(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx)\n{\n    UNUSED(wstate);\n    UNUSED(curpixel);\n    UNUSED(flip);\n    UNUSED(delayedhbwidx);\n\n    rdp_pipeline_crashed = 1;\n}\n\nstatic void fbfill_8(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx)\n{\n    uint32_t fb = wstate->fb_address + curpixel;\n    uint8_t val = (wstate->fill_color >> ((fb & 3) ^ 3) << 3) & 0xff;\n    rdram_write_pair8(fb, val, flip, delayedhbwidx);\n}\n\nstatic void fbfill_16(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx)\n{\n    UNUSED(flip);\n    UNUSED(delayedhbwidx);\n\n    uint16_t val;\n    uint8_t hval;\n    uint32_t fb = (wstate->fb_address >> 1) + curpixel;\n    if (fb & 1)\n        val = wstate->fill_color & 0xffff;\n    else\n        val = (wstate->fill_color >> 16) & 0xffff;\n    hval = ((val & 1) << 1) | (val & 1);\n    rdram_write_pair16(fb, val, hval, 1);\n}\n\nstatic void fbfill_32(struct rdp_state* wstate, uint32_t curpixel, int flip, int* delayedhbwidx)\n{\n    UNUSED(flip);\n    UNUSED(delayedhbwidx);\n\n    uint32_t fb = (wstate->fb_address >> 2) + curpixel;\n    rdram_write_pair32(fb, wstate->fill_color, (wstate->fill_color & 0x10000) ? 3 : 0, (wstate->fill_color & 0x1) ? 3 : 0);\n}\n\nstatic void fbread_4(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n    UNUSED(curpixel);\n\n    wstate->memory_color.r = wstate->memory_color.g = wstate->memory_color.b = 0;\n\n    *curpixel_memcvg = 7;\n    wstate->memory_color.a = 0xe0;\n}\n\nstatic void fbread2_4(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n    UNUSED(curpixel);\n\n    wstate->pre_memory_color.r = wstate->pre_memory_color.g = wstate->pre_memory_color.b = 0;\n    wstate->pre_memory_color.a = 0xe0;\n    *curpixel_memcvg = 7;\n}\n\nstatic void fbread_8(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n    if (wstate->other_modes.image_read_en)\n    {\n        uint8_t mem;\n        uint32_t addr = wstate->fb_address + curpixel;\n        RREADADDR8(mem, addr);\n        wstate->memory_color.r = wstate->memory_color.g = wstate->memory_color.b = mem;\n    }\n\n    *curpixel_memcvg = 7;\n    wstate->memory_color.a = 0xe0;\n}\n\nstatic void fbread2_8(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n    if (wstate->other_modes.image_read_en)\n    {\n        uint8_t mem;\n        uint32_t addr = wstate->fb_address + curpixel;\n        RREADADDR8(mem, addr);\n        wstate->pre_memory_color.r = wstate->pre_memory_color.g = wstate->pre_memory_color.b = mem;\n    }\n    wstate->pre_memory_color.a = 0xe0;\n    *curpixel_memcvg = 7;\n}\n\nstatic void fbread_16(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n    if (wstate->other_modes.image_read_en)\n    {\n        uint16_t fword;\n        uint8_t hbyte;\n        uint32_t addr = (wstate->fb_address >> 1) + curpixel;\n\n        uint8_t lowbits;\n\n        PAIRREAD16(fword, hbyte, addr);\n\n        if (wstate->fb_format == FORMAT_RGBA)\n        {\n            wstate->memory_color.r = RGBA16_R(fword);\n            wstate->memory_color.g = RGBA16_G(fword);\n            wstate->memory_color.b = RGBA16_B(fword);\n            lowbits = ((fword & 1) << 2) | hbyte;\n        }\n        else\n        {\n            wstate->memory_color.r = wstate->memory_color.g = wstate->memory_color.b = fword >> 8;\n            lowbits = (fword >> 5) & 7;\n        }\n\n        *curpixel_memcvg = lowbits;\n        wstate->memory_color.a = lowbits << 5;\n    }\n    else\n    {\n        *curpixel_memcvg = 7;\n        wstate->memory_color.a = 0xe0;\n    }\n}\n\nstatic void fbread2_16(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n\n    if (wstate->other_modes.image_read_en)\n    {\n        uint16_t fword;\n        uint8_t hbyte;\n        uint32_t addr = (wstate->fb_address >> 1) + curpixel;\n\n        uint8_t lowbits;\n\n        PAIRREAD16(fword, hbyte, addr);\n\n        if (wstate->fb_format == FORMAT_RGBA)\n        {\n            wstate->pre_memory_color.r = RGBA16_R(fword);\n            wstate->pre_memory_color.g = RGBA16_G(fword);\n            wstate->pre_memory_color.b = RGBA16_B(fword);\n            lowbits = ((fword & 1) << 2) | hbyte;\n        }\n        else\n        {\n            wstate->pre_memory_color.r = wstate->pre_memory_color.g = wstate->pre_memory_color.b = fword >> 8;\n            lowbits = (fword >> 5) & 7;\n        }\n\n        *curpixel_memcvg = lowbits;\n        wstate->pre_memory_color.a = lowbits << 5;\n    }\n    else\n    {\n        *curpixel_memcvg = 7;\n        wstate->pre_memory_color.a = 0xe0;\n    }\n\n}\n\nstatic void fbread_32(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n    if (wstate->other_modes.image_read_en)\n    {\n        uint32_t mem, addr = (wstate->fb_address >> 2) + curpixel;\n        RREADIDX32(mem, addr);\n        wstate->memory_color.r = RGBA32_R(mem);\n        wstate->memory_color.g = RGBA32_G(mem);\n        wstate->memory_color.b = RGBA32_B(mem);\n\n        *curpixel_memcvg = (mem >> 5) & 7;\n        wstate->memory_color.a = mem & 0xe0;\n    }\n    else\n    {\n        *curpixel_memcvg = 7;\n        wstate->memory_color.a = 0xe0;\n    }\n}\n\nstatic INLINE void fbread2_32(struct rdp_state* wstate, uint32_t curpixel, uint32_t* curpixel_memcvg)\n{\n    if (wstate->other_modes.image_read_en)\n    {\n        uint32_t mem, addr = (wstate->fb_address >> 2) + curpixel;\n        RREADIDX32(mem, addr);\n\n        wstate->pre_memory_color.r = RGBA32_R(mem);\n        wstate->pre_memory_color.g = RGBA32_G(mem);\n        wstate->pre_memory_color.b = RGBA32_B(mem);\n\n        *curpixel_memcvg = (mem >> 5) & 7;\n        wstate->pre_memory_color.a = mem & 0xe0;\n    }\n    else\n    {\n        *curpixel_memcvg = 7;\n        wstate->pre_memory_color.a = 0xe0;\n    }\n}\n\nvoid rdp_set_color_image(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->fb_format   = (args[0] >> 21) & 0x7;\n    wstate->fb_size     = (args[0] >> 19) & 0x3;\n    wstate->fb_width    = (args[0] & 0x3ff) + 1;\n    wstate->fb_address  = args[1] & 0x0ffffff;\n\n\n    wstate->fbread1_ptr = fbread_func[wstate->fb_size];\n    wstate->fbread2_ptr = fbread2_func[wstate->fb_size];\n    wstate->fbwrite_ptr = fbwrite_func[wstate->fb_size];\n    wstate->fbfill_ptr = fbfill_func[wstate->fb_size];\n}\n\nvoid rdp_set_fill_color(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->fill_color = args[1];\n}\n\nstatic void fb_init(struct rdp_state* wstate)\n{\n    wstate->fb_format = FORMAT_RGBA;\n    wstate->fb_size = PIXEL_SIZE_4BIT;\n    wstate->fb_width = 0;\n    wstate->fb_address = 0;\n\n\n    wstate->fbread1_ptr = fbread_func[wstate->fb_size];\n    wstate->fbread2_ptr = fbread2_func[wstate->fb_size];\n    wstate->fbwrite_ptr = fbwrite_func[wstate->fb_size];\n    wstate->fbfill_ptr = fbfill_func[wstate->fb_size];\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/rasterizer.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic STRICTINLINE int32_t normalize_dzpix(int32_t sum)\n{\n    int count;\n    if (sum & 0xc000)\n        return 0x8000;\n    if (!(sum & 0xffff))\n        return 1;\n\n    if (sum == 1)\n        return 3;\n\n    for(count = 0x2000; count > 0; count >>= 1)\n    {\n        if (sum & count)\n            return (count << 1);\n    }\n\n    return 0;\n}\n\nstatic void replicate_for_copy(struct rdp_state* wstate, uint32_t* outbyte, uint32_t inshort, uint32_t nybbleoffset, uint32_t tilenum, uint32_t tformat, uint32_t tsize)\n{\n    uint32_t lownib, hinib;\n    switch(tsize)\n    {\n    case PIXEL_SIZE_4BIT:\n        lownib = (nybbleoffset ^ 3) << 2;\n        lownib = hinib = (inshort >> lownib) & 0xf;\n        if (tformat == FORMAT_CI)\n        {\n            *outbyte = (wstate->tile[tilenum].palette << 4) | lownib;\n        }\n        else if (tformat == FORMAT_IA)\n        {\n            lownib = (lownib << 4) | lownib;\n            *outbyte = (lownib & 0xe0) | ((lownib & 0xe0) >> 3) | ((lownib & 0xc0) >> 6);\n        }\n        else\n            *outbyte = (lownib << 4) | lownib;\n        break;\n    case PIXEL_SIZE_8BIT:\n        hinib = ((nybbleoffset ^ 3) | 1) << 2;\n        if (tformat == FORMAT_IA)\n        {\n            lownib = (inshort >> hinib) & 0xf;\n            *outbyte = (lownib << 4) | lownib;\n        }\n        else\n        {\n            lownib = (inshort >> (hinib & ~4)) & 0xf;\n            hinib = (inshort >> hinib) & 0xf;\n            *outbyte = (hinib << 4) | lownib;\n        }\n        break;\n    default:\n        *outbyte = (inshort >> 8) & 0xff;\n        break;\n    }\n}\n\nstatic void fetch_qword_copy(struct rdp_state* wstate, uint32_t* hidword, uint32_t* lowdword, int32_t ssss, int32_t ssst, uint32_t tilenum)\n{\n    uint32_t shorta, shortb, shortc, shortd;\n    uint32_t sortshort[8];\n    int hibits[6];\n    int lowbits[6];\n    int32_t sss = ssss, sst = ssst, sss1 = 0, sss2 = 0, sss3 = 0;\n    int largetex = 0;\n\n    uint32_t tformat, tsize;\n    if (wstate->other_modes.en_tlut)\n    {\n        tsize = PIXEL_SIZE_16BIT;\n        tformat = wstate->other_modes.tlut_type ? FORMAT_IA : FORMAT_RGBA;\n    }\n    else\n    {\n        tsize = wstate->tile[tilenum].size;\n        tformat = wstate->tile[tilenum].format;\n    }\n\n    tc_pipeline_copy(&wstate->tile[tilenum], &sss, &sss1, &sss2, &sss3, &sst);\n    read_tmem_copy(wstate, sss, sss1, sss2, sss3, sst, tilenum, sortshort, hibits, lowbits);\n    largetex = (tformat == FORMAT_YUV || (tformat == FORMAT_RGBA && tsize == PIXEL_SIZE_32BIT));\n\n\n    if (wstate->other_modes.en_tlut)\n    {\n        shorta = sortshort[4];\n        shortb = sortshort[5];\n        shortc = sortshort[6];\n        shortd = sortshort[7];\n    }\n    else if (largetex)\n    {\n        shorta = sortshort[0];\n        shortb = sortshort[1];\n        shortc = sortshort[2];\n        shortd = sortshort[3];\n    }\n    else\n    {\n        shorta = hibits[0] ? sortshort[4] : sortshort[0];\n        shortb = hibits[1] ? sortshort[5] : sortshort[1];\n        shortc = hibits[3] ? sortshort[6] : sortshort[2];\n        shortd = hibits[4] ? sortshort[7] : sortshort[3];\n    }\n\n    *lowdword = (shortc << 16) | shortd;\n\n    if (tsize == PIXEL_SIZE_16BIT)\n        *hidword = (shorta << 16) | shortb;\n    else\n    {\n        replicate_for_copy(wstate, &shorta, shorta, lowbits[0] & 3, tilenum, tformat, tsize);\n        replicate_for_copy(wstate, &shortb, shortb, lowbits[1] & 3, tilenum, tformat, tsize);\n        replicate_for_copy(wstate, &shortc, shortc, lowbits[3] & 3, tilenum, tformat, tsize);\n        replicate_for_copy(wstate, &shortd, shortd, lowbits[4] & 3, tilenum, tformat, tsize);\n        *hidword = (shorta << 24) | (shortb << 16) | (shortc << 8) | shortd;\n    }\n}\n\nstatic STRICTINLINE void rgba_correct(struct rdp_state* wstate, int offx, int offy, int r, int g, int b, int a, uint32_t cvg)\n{\n    int summand_r, summand_b, summand_g, summand_a;\n\n\n\n    if (cvg == 8)\n    {\n        r >>= 2;\n        g >>= 2;\n        b >>= 2;\n        a >>= 2;\n    }\n    else\n    {\n        summand_r = offx * wstate->spans_cdr + offy * wstate->spans_drdy;\n        summand_g = offx * wstate->spans_cdg + offy * wstate->spans_dgdy;\n        summand_b = offx * wstate->spans_cdb + offy * wstate->spans_dbdy;\n        summand_a = offx * wstate->spans_cda + offy * wstate->spans_dady;\n\n        r = ((r << 2) + summand_r) >> 4;\n        g = ((g << 2) + summand_g) >> 4;\n        b = ((b << 2) + summand_b) >> 4;\n        a = ((a << 2) + summand_a) >> 4;\n    }\n\n\n    wstate->shade_color.r = special_9bit_clamptable[r & 0x1ff];\n    wstate->shade_color.g = special_9bit_clamptable[g & 0x1ff];\n    wstate->shade_color.b = special_9bit_clamptable[b & 0x1ff];\n    wstate->shade_color.a = special_9bit_clamptable[a & 0x1ff];\n}\n\nstatic STRICTINLINE void z_correct(struct rdp_state* wstate, int offx, int offy, int* z, uint32_t cvg)\n{\n    int summand_z;\n    int sz = *z;\n    int zanded;\n\n\n\n    if (cvg == 8)\n        sz = sz >> 3;\n    else\n    {\n        summand_z = offx * wstate->spans_cdz + offy * wstate->spans_dzdy;\n\n        sz = ((sz << 2) + summand_z) >> 5;\n    }\n\n\n\n    zanded = (sz & 0x60000) >> 17;\n\n\n    switch (zanded)\n    {\n        case 0: *z = sz & 0x3ffff;                      break;\n        case 1: *z = sz & 0x3ffff;                      break;\n        case 2: *z = 0x3ffff;                           break;\n        case 3: *z = 0;                                 break;\n    }\n}\n\n\nvoid rejected_hbwrite_1cycle(struct rdp_state* wstate, int cdith, uint32_t blend_en, uint32_t prewrap, uint32_t curpixel, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx)\n{\n    int g, dontblend;\n    int gval = 0;\n    uint32_t fb = 0;\n    int32_t hval = 0;\n    int fbsel = wstate->fb_size;\n\n    if (wstate->fb_size == PIXEL_SIZE_8BIT)\n    {\n        fb = wstate->fb_address + curpixel;\n        if (!(fb & 1))\n            fbsel--;\n    }\n\n    if (fbsel & 1)\n    {\n        if (!wstate->other_modes.color_on_cvg || prewrap)\n        {\n            dontblend = (wstate->other_modes.f.partialreject_1cycle && wstate->pixel_color.a >= 0xff);\n            if (!blend_en || dontblend)\n                g = *wstate->blender1a_g[0];\n            else\n            {\n                wstate->inv_pixel_color.a =  (~(*wstate->blender1b_a[0])) & 0xff;\n\n                blender_equation_cycle0_gval(wstate, &g);\n            }\n        }\n        else\n            g = *wstate->blender2a_g[0];\n\n        if (wstate->other_modes.rgb_dither_sel != 3)\n            rgb_dither_gval(wstate->other_modes.rgb_dither_sel, &g, cdith);\n\n        gval = (g & 1) ? 3 : 0;\n    }\n\n    switch (fbsel)\n    {\n    case PIXEL_SIZE_4BIT:\n        break;\n    case PIXEL_SIZE_8BIT:\n        if (flip && *delayedhbwidx >= 0)\n        {\n            if ((uint32_t)*delayedhbwidx < fb)\n            {\n                if (rdram_valid_idx8((uint32_t)*delayedhbwidx))\n                {\n                    int oldhbidx = *delayedhbwidx >> 1;\n                    rdram_hidden[oldhbidx] &= ~2;\n                    rdram_hidden[oldhbidx] |= rdram_hidden_old[oldhbidx & 7] & 2;\n                }\n            }\n            else if (rdram_valid_idx8(fb))\n            {\n                rdram_hidden[fb >> 1] &= ~2;\n                rdram_hidden[fb >> 1] |= gval & 2;\n            }\n\n            *delayedhbwidx = -1;\n        }\n\n        rdram_hidden_old[(fb >> 1) & 7] = gval & 0xff;\n        break;\n    case PIXEL_SIZE_16BIT:\n        fb = (wstate->fb_address >> 1) + curpixel;\n        if (wstate->fb_format == FORMAT_RGBA)\n            hval = finalize_spanalpha(wstate->other_modes.cvg_dest, blend_en, curpixel_cvg, curpixel_memcvg) & 3;\n        rdram_hidden_old[fb & 7] = hval & 0xff;\n        break;\n    case PIXEL_SIZE_32BIT:\n        fb = (wstate->fb_address >> 2) + curpixel;\n        rdram_hidden_old[(fb << 1) & 7] = gval & 0xff;\n        rdram_hidden_old[((fb << 1) + 1) & 7] = 0;\n        break;\n    }\n}\n\nvoid rejected_hbwrite_2cycle(struct rdp_state* wstate, int cdith, uint32_t blend_en, uint32_t prewrap, uint32_t curpixel, uint32_t curpixel_cvg, uint32_t curpixel_memcvg, int flip, int* delayedhbwidx)\n{\n    int g, dontblend;\n    int gval = 0;\n    uint32_t fb = 0;\n    int32_t hval = 0;\n    int fbsel = wstate->fb_size;\n\n    if (wstate->fb_size == PIXEL_SIZE_8BIT)\n    {\n        fb = wstate->fb_address + curpixel;\n        if (!(fb & 1))\n            fbsel--;\n    }\n\n    if (fbsel & 1)\n    {\n        if (!wstate->other_modes.color_on_cvg || prewrap)\n        {\n            dontblend = (wstate->other_modes.f.partialreject_2cycle && wstate->pixel_color.a >= 0xff);\n            if (!blend_en || dontblend)\n                g = *wstate->blender1a_g[1];\n            else\n            {\n                wstate->inv_pixel_color.a =  (~(*wstate->blender1b_a[1])) & 0xff;\n\n                blender_equation_cycle1_gval(wstate, &g);\n            }\n        }\n        else\n            g = *wstate->blender2a_g[1];\n\n        if (wstate->other_modes.rgb_dither_sel != 3)\n            rgb_dither_gval(wstate->other_modes.rgb_dither_sel, &g, cdith);\n\n        gval = (g & 1) ? 3 : 0;\n    }\n\n    switch (fbsel)\n    {\n    case PIXEL_SIZE_4BIT:\n        break;\n    case PIXEL_SIZE_8BIT:\n        if (flip && *delayedhbwidx >= 0)\n        {\n            if ((uint32_t)*delayedhbwidx < fb)\n            {\n                if (rdram_valid_idx8((uint32_t)*delayedhbwidx))\n                {\n                    int oldhbidx = *delayedhbwidx >> 1;\n                    rdram_hidden[oldhbidx] &= ~2;\n                    rdram_hidden[oldhbidx] |= rdram_hidden_old[oldhbidx & 7] & 2;\n                }\n            }\n            else if (rdram_valid_idx8(fb))\n            {\n                rdram_hidden[fb >> 1] &= ~2;\n                rdram_hidden[fb >> 1] |= gval & 2;\n            }\n\n            *delayedhbwidx = -1;\n        }\n\n        rdram_hidden_old[(fb >> 1) & 7] = gval & 0xff;\n        break;\n    case PIXEL_SIZE_16BIT:\n        fb = (wstate->fb_address >> 1) + curpixel;\n        if (wstate->fb_format == FORMAT_RGBA)\n            hval = finalize_spanalpha(wstate->other_modes.cvg_dest, blend_en, curpixel_cvg, curpixel_memcvg) & 3;\n        rdram_hidden_old[fb & 7] = hval & 0xff;\n        break;\n    case PIXEL_SIZE_32BIT:\n        fb = (wstate->fb_address >> 2) + curpixel;\n        rdram_hidden_old[(fb << 1) & 7] = gval & 0xff;\n        rdram_hidden_old[((fb << 1) + 1) & 7] = 0;\n        break;\n    }\n}\n\nstatic void render_spans_1cycle_complete(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    int zb = wstate->zb_address >> 1;\n    int zbcur;\n    uint8_t offx = 0;\n    uint8_t offy = 0;\n    struct spansigs sigs;\n    uint32_t blend_en;\n    uint32_t prewrap;\n    uint32_t curpixel_cvg, curpixel_cvbit, curpixel_memcvg;\n\n    int prim_tile = tilenum;\n    int tile1 = tilenum;\n    int newtile = tilenum;\n    int news, newt;\n\n    int i, j;\n\n    int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;\n    int xinc;\n\n    if (flip)\n    {\n        drinc = wstate->spans_dr;\n        dginc = wstate->spans_dg;\n        dbinc = wstate->spans_db;\n        dainc = wstate->spans_da;\n        dzinc = wstate->spans_dz;\n        dsinc = wstate->spans_ds;\n        dtinc = wstate->spans_dt;\n        dwinc = wstate->spans_dw;\n        xinc = 1;\n    }\n    else\n    {\n        drinc = -wstate->spans_dr;\n        dginc = -wstate->spans_dg;\n        dbinc = -wstate->spans_db;\n        dainc = -wstate->spans_da;\n        dzinc = -wstate->spans_dz;\n        dsinc = -wstate->spans_ds;\n        dtinc = -wstate->spans_dt;\n        dwinc = -wstate->spans_dw;\n        xinc = -1;\n    }\n\n    int dzpix;\n    if (!wstate->other_modes.z_source_sel)\n        dzpix = wstate->spans_dzpix;\n    else\n    {\n        dzpix = wstate->primitive_delta_z;\n        dzinc = wstate->spans_cdz = wstate->spans_dzdy = 0;\n    }\n    int dzpixenc = dz_compress(dzpix);\n\n    int cdith = 7, adith = 0;\n    int r, g, b, a, z, s, t, w;\n    int sr, sg, sb, sa, sz, ss, st, sw;\n    int xstart, xend, xendsc;\n    int sss = 0, sst = 0;\n    int32_t prelodfrac = 0;\n    int curpixel = 0;\n    int x, length, scdiff, lodlength;\n    uint32_t fir = 0, fig = 0, fib = 0;\n    int delayedhbwidx = -1;\n    int wen;\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        r = wstate->span[i].r;\n        g = wstate->span[i].g;\n        b = wstate->span[i].b;\n        a = wstate->span[i].a;\n        z = wstate->other_modes.z_source_sel ? wstate->primitive_z : wstate->span[i].z;\n        s = wstate->span[i].s;\n        t = wstate->span[i].t;\n        w = wstate->span[i].w;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        zbcur = zb + curpixel;\n\n        if (!flip)\n        {\n            length = xendsc - xstart;\n            scdiff = xend - xendsc;\n            compute_cvg_noflip(wstate, i);\n        }\n        else\n        {\n            length = xstart - xendsc;\n            scdiff = xendsc - xend;\n            compute_cvg_flip(wstate, i);\n        }\n\n\n\n        if (scdiff)\n        {\n\n\n            scdiff &= 0xfff;\n            r += (drinc * scdiff);\n            g += (dginc * scdiff);\n            b += (dbinc * scdiff);\n            a += (dainc * scdiff);\n            z += (dzinc * scdiff);\n            s += (dsinc * scdiff);\n            t += (dtinc * scdiff);\n            w += (dwinc * scdiff);\n        }\n\n        lodlength = length + scdiff;\n\n        sigs.longspan = (lodlength > 7);\n        sigs.midspan = (lodlength == 7);\n        sigs.onelessthanmid = (lodlength == 6);\n\n        for (j = 0; j <= length; j++)\n        {\n            sr = r >> 14;\n            sg = g >> 14;\n            sb = b >> 14;\n            sa = a >> 14;\n            ss = s >> 16;\n            st = t >> 16;\n            sw = w >> 16;\n            sz = (z >> 10) & 0x3fffff;\n\n\n            sigs.endspan = (j == length);\n            sigs.preendspan = (j == (length - 1));\n\n            lookup_cvmask_derivatives(wstate->cvgbuf[x], &offx, &offy, &curpixel_cvg, &curpixel_cvbit);\n\n\n            get_texel1_1cycle(wstate, &news, &newt, s, t, w, dsinc, dtinc, dwinc, i, &sigs);\n\n\n\n            if (j)\n            {\n                wstate->texel0_color = wstate->texel1_color;\n                wstate->lod_frac = prelodfrac;\n            }\n            else\n            {\n                wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n\n                tclod_1cycle_current(wstate, &sss, &sst, news, newt, s, t, w, dsinc, dtinc, dwinc, i, prim_tile, &tile1, &sigs);\n\n\n\n\n                texture_pipeline_cycle(wstate, &wstate->texel0_color, &wstate->texel0_color, sss, sst, tile1, 0);\n            }\n\n            sigs.nextspan = sigs.endspan;\n            sigs.endspan = sigs.preendspan;\n            sigs.preendspan = (j == (length - 2));\n\n            s += dsinc;\n            t += dtinc;\n            w += dwinc;\n\n            tclod_1cycle_next(wstate, &news, &newt, s, t, w, dsinc, dtinc, dwinc, i, prim_tile, &newtile, &sigs, &prelodfrac);\n\n            texture_pipeline_cycle(wstate, &wstate->texel1_color, &wstate->texel1_color, news, newt, newtile, 0);\n\n            rgba_correct(wstate, offx, offy, sr, sg, sb, sa, curpixel_cvg);\n            z_correct(wstate, offx, offy, &sz, curpixel_cvg);\n\n            if (wstate->other_modes.f.getditherlevel < 2)\n                get_dither_noise(wstate, x, i, &cdith, &adith);\n\n            combiner_1cycle(wstate, adith, &curpixel_cvg);\n\n            wstate->fbread1_ptr(wstate, curpixel, &curpixel_memcvg);\n\n            wen = z_compare(wstate, zbcur, sz, (uint16_t)dzpix, dzpixenc, &blend_en, &prewrap, &curpixel_cvg, curpixel_memcvg);\n\n            if (wen)\n                wen = blender_1cycle(wstate, &fir, &fig, &fib, cdith, blend_en, prewrap, curpixel_cvg, curpixel_cvbit);\n\n            if (wen)\n            {\n                wstate->fbwrite_ptr(wstate, curpixel, fir, fig, fib, blend_en, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n                if (wstate->other_modes.z_update_en)\n                    z_store(zbcur, sz, dzpixenc);\n            }\n            else if (i >= wstate->last_overwriting_scanline)\n                rejected_hbwrite_1cycle(wstate, cdith, blend_en, prewrap, curpixel, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n\n            r += drinc;\n            g += dginc;\n            b += dbinc;\n            a += dainc;\n            z += dzinc;\n\n            x += xinc;\n            curpixel += xinc;\n            zbcur += xinc;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\n\nstatic void render_spans_1cycle_notexel1(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    int zb = wstate->zb_address >> 1;\n    int zbcur;\n    uint8_t offx = 0;\n    uint8_t offy = 0;\n    struct spansigs sigs;\n    uint32_t blend_en;\n    uint32_t prewrap;\n    uint32_t curpixel_cvg, curpixel_cvbit, curpixel_memcvg;\n\n    int prim_tile = tilenum;\n    int tile1 = tilenum;\n\n    int i, j;\n\n    int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;\n    int xinc;\n    if (flip)\n    {\n        drinc = wstate->spans_dr;\n        dginc = wstate->spans_dg;\n        dbinc = wstate->spans_db;\n        dainc = wstate->spans_da;\n        dzinc = wstate->spans_dz;\n        dsinc = wstate->spans_ds;\n        dtinc = wstate->spans_dt;\n        dwinc = wstate->spans_dw;\n        xinc = 1;\n    }\n    else\n    {\n        drinc = -wstate->spans_dr;\n        dginc = -wstate->spans_dg;\n        dbinc = -wstate->spans_db;\n        dainc = -wstate->spans_da;\n        dzinc = -wstate->spans_dz;\n        dsinc = -wstate->spans_ds;\n        dtinc = -wstate->spans_dt;\n        dwinc = -wstate->spans_dw;\n        xinc = -1;\n    }\n\n    int dzpix;\n    if (!wstate->other_modes.z_source_sel)\n        dzpix = wstate->spans_dzpix;\n    else\n    {\n        dzpix = wstate->primitive_delta_z;\n        dzinc = wstate->spans_cdz = wstate->spans_dzdy = 0;\n    }\n    int dzpixenc = dz_compress(dzpix);\n\n    int cdith = 7, adith = 0;\n    int r, g, b, a, z, s, t, w;\n    int sr, sg, sb, sa, sz, ss, st, sw;\n    int xstart, xend, xendsc;\n    int sss = 0, sst = 0;\n    int curpixel = 0;\n    int x, length, scdiff, lodlength;\n    uint32_t fir = 0, fig = 0, fib = 0;\n    int delayedhbwidx = -1;\n    int wen;\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        r = wstate->span[i].r;\n        g = wstate->span[i].g;\n        b = wstate->span[i].b;\n        a = wstate->span[i].a;\n        z = wstate->other_modes.z_source_sel ? wstate->primitive_z : wstate->span[i].z;\n        s = wstate->span[i].s;\n        t = wstate->span[i].t;\n        w = wstate->span[i].w;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        zbcur = zb + curpixel;\n\n        if (!flip)\n        {\n            length = xendsc - xstart;\n            scdiff = xend - xendsc;\n            compute_cvg_noflip(wstate, i);\n        }\n        else\n        {\n            length = xstart - xendsc;\n            scdiff = xendsc - xend;\n            compute_cvg_flip(wstate, i);\n        }\n\n        if (scdiff)\n        {\n            scdiff &= 0xfff;\n            r += (drinc * scdiff);\n            g += (dginc * scdiff);\n            b += (dbinc * scdiff);\n            a += (dainc * scdiff);\n            z += (dzinc * scdiff);\n            s += (dsinc * scdiff);\n            t += (dtinc * scdiff);\n            w += (dwinc * scdiff);\n        }\n\n        lodlength = length + scdiff;\n\n        sigs.longspan = (lodlength > 7);\n        sigs.midspan = (lodlength == 7);\n\n        for (j = 0; j <= length; j++)\n        {\n            sr = r >> 14;\n            sg = g >> 14;\n            sb = b >> 14;\n            sa = a >> 14;\n            ss = s >> 16;\n            st = t >> 16;\n            sw = w >> 16;\n            sz = (z >> 10) & 0x3fffff;\n\n\n\n            sigs.endspan = (j == length);\n            sigs.preendspan = (j == (length - 1));\n\n            lookup_cvmask_derivatives(wstate->cvgbuf[x], &offx, &offy, &curpixel_cvg, &curpixel_cvbit);\n\n            wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n            tclod_1cycle_current_simple(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, i, prim_tile, &tile1, &sigs);\n\n            texture_pipeline_cycle(wstate, &wstate->texel0_color, &wstate->texel0_color, sss, sst, tile1, 0);\n\n            rgba_correct(wstate, offx, offy, sr, sg, sb, sa, curpixel_cvg);\n            z_correct(wstate, offx, offy, &sz, curpixel_cvg);\n\n            if (wstate->other_modes.f.getditherlevel < 2)\n                get_dither_noise(wstate, x, i, &cdith, &adith);\n\n            combiner_1cycle(wstate, adith, &curpixel_cvg);\n\n            wstate->fbread1_ptr(wstate, curpixel, &curpixel_memcvg);\n\n            wen = z_compare(wstate, zbcur, sz, (uint16_t)dzpix, dzpixenc, &blend_en, &prewrap, &curpixel_cvg, curpixel_memcvg);\n\n            if (wen)\n                wen = blender_1cycle(wstate, &fir, &fig, &fib, cdith, blend_en, prewrap, curpixel_cvg, curpixel_cvbit);\n\n            if (wen)\n            {\n                wstate->fbwrite_ptr(wstate, curpixel, fir, fig, fib, blend_en, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n                if (wstate->other_modes.z_update_en)\n                    z_store(zbcur, sz, dzpixenc);\n            }\n            else if (i >= wstate->last_overwriting_scanline)\n                rejected_hbwrite_1cycle(wstate, cdith, blend_en, prewrap, curpixel, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n\n            s += dsinc;\n            t += dtinc;\n            w += dwinc;\n            r += drinc;\n            g += dginc;\n            b += dbinc;\n            a += dainc;\n            z += dzinc;\n\n            x += xinc;\n            curpixel += xinc;\n            zbcur += xinc;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\n\nstatic void render_spans_1cycle_notex(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    UNUSED(tilenum);\n\n    int zb = wstate->zb_address >> 1;\n    int zbcur;\n    uint8_t offx = 0;\n    uint8_t offy = 0;\n    uint32_t blend_en;\n    uint32_t prewrap;\n    uint32_t curpixel_cvg, curpixel_cvbit, curpixel_memcvg;\n\n    int i, j;\n\n    int drinc, dginc, dbinc, dainc, dzinc;\n    int xinc;\n\n    if (flip)\n    {\n        drinc = wstate->spans_dr;\n        dginc = wstate->spans_dg;\n        dbinc = wstate->spans_db;\n        dainc = wstate->spans_da;\n        dzinc = wstate->spans_dz;\n        xinc = 1;\n    }\n    else\n    {\n        drinc = -wstate->spans_dr;\n        dginc = -wstate->spans_dg;\n        dbinc = -wstate->spans_db;\n        dainc = -wstate->spans_da;\n        dzinc = -wstate->spans_dz;\n        xinc = -1;\n    }\n\n    int dzpix;\n    if (!wstate->other_modes.z_source_sel)\n        dzpix = wstate->spans_dzpix;\n    else\n    {\n        dzpix = wstate->primitive_delta_z;\n        dzinc = wstate->spans_cdz = wstate->spans_dzdy = 0;\n    }\n    int dzpixenc = dz_compress(dzpix);\n\n    int cdith = 7, adith = 0;\n    int r, g, b, a, z;\n    int sr, sg, sb, sa, sz;\n    int xstart, xend, xendsc;\n    int curpixel = 0;\n    int x, length, scdiff;\n    uint32_t fir = 0, fig = 0, fib = 0;\n    int delayedhbwidx = -1;\n    int wen;\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        r = wstate->span[i].r;\n        g = wstate->span[i].g;\n        b = wstate->span[i].b;\n        a = wstate->span[i].a;\n        z = wstate->other_modes.z_source_sel ? wstate->primitive_z : wstate->span[i].z;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        zbcur = zb + curpixel;\n\n        if (!flip)\n        {\n            length = xendsc - xstart;\n            scdiff = xend - xendsc;\n            compute_cvg_noflip(wstate, i);\n        }\n        else\n        {\n            length = xstart - xendsc;\n            scdiff = xendsc - xend;\n            compute_cvg_flip(wstate, i);\n        }\n\n        if (scdiff)\n        {\n            scdiff &= 0xfff;\n            r += (drinc * scdiff);\n            g += (dginc * scdiff);\n            b += (dbinc * scdiff);\n            a += (dainc * scdiff);\n            z += (dzinc * scdiff);\n        }\n\n        for (j = 0; j <= length; j++)\n        {\n            sr = r >> 14;\n            sg = g >> 14;\n            sb = b >> 14;\n            sa = a >> 14;\n            sz = (z >> 10) & 0x3fffff;\n\n            lookup_cvmask_derivatives(wstate->cvgbuf[x], &offx, &offy, &curpixel_cvg, &curpixel_cvbit);\n\n            rgba_correct(wstate, offx, offy, sr, sg, sb, sa, curpixel_cvg);\n            z_correct(wstate, offx, offy, &sz, curpixel_cvg);\n\n            if (wstate->other_modes.f.getditherlevel < 2)\n                get_dither_noise(wstate, x, i, &cdith, &adith);\n\n            combiner_1cycle(wstate, adith, &curpixel_cvg);\n\n            wstate->fbread1_ptr(wstate, curpixel, &curpixel_memcvg);\n\n            wen = z_compare(wstate, zbcur, sz, (uint16_t)dzpix, dzpixenc, &blend_en, &prewrap, &curpixel_cvg, curpixel_memcvg);\n\n            if (wen)\n                wen = blender_1cycle(wstate, &fir, &fig, &fib, cdith, blend_en, prewrap, curpixel_cvg, curpixel_cvbit);\n\n            if (wen)\n            {\n                wstate->fbwrite_ptr(wstate, curpixel, fir, fig, fib, blend_en, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n                if (wstate->other_modes.z_update_en)\n                    z_store(zbcur, sz, dzpixenc);\n            }\n            else if (i >= wstate->last_overwriting_scanline)\n                rejected_hbwrite_1cycle(wstate, cdith, blend_en, prewrap, curpixel, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n\n            r += drinc;\n            g += dginc;\n            b += dbinc;\n            a += dainc;\n            z += dzinc;\n\n            x += xinc;\n            curpixel += xinc;\n            zbcur += xinc;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\nstatic void render_spans_2cycle_complete(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    int zb = wstate->zb_address >> 1;\n    int zbcur;\n    uint8_t offx = 0;\n    uint8_t offy = 0;\n    int32_t prelodfrac;\n    struct color nexttexel1_color;\n    uint32_t blend_en = 0;\n    uint32_t prewrap = 0;\n    uint32_t curpixel_cvg = 0, curpixel_cvbit = 0, curpixel_memcvg = 0;\n    uint32_t nextpixel_cvg;\n    uint32_t acalpha;\n\n\n\n    int tile2 = (tilenum + 1) & 7;\n    int tile1 = tilenum;\n    int prim_tile = tilenum;\n    int tile3 = tilenum;\n\n    int i, j;\n\n    int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;\n    int xinc;\n    if (flip)\n    {\n        drinc = wstate->spans_dr;\n        dginc = wstate->spans_dg;\n        dbinc = wstate->spans_db;\n        dainc = wstate->spans_da;\n        dzinc = wstate->spans_dz;\n        dsinc = wstate->spans_ds;\n        dtinc = wstate->spans_dt;\n        dwinc = wstate->spans_dw;\n        xinc = 1;\n    }\n    else\n    {\n        drinc = -wstate->spans_dr;\n        dginc = -wstate->spans_dg;\n        dbinc = -wstate->spans_db;\n        dainc = -wstate->spans_da;\n        dzinc = -wstate->spans_dz;\n        dsinc = -wstate->spans_ds;\n        dtinc = -wstate->spans_dt;\n        dwinc = -wstate->spans_dw;\n        xinc = -1;\n    }\n\n    int dzpix;\n    if (!wstate->other_modes.z_source_sel)\n        dzpix = wstate->spans_dzpix;\n    else\n    {\n        dzpix = wstate->primitive_delta_z;\n        dzinc = wstate->spans_cdz = wstate->spans_dzdy = 0;\n    }\n    int dzpixenc = dz_compress(dzpix);\n\n    int cdith = 7, adith = 0;\n\n    int r, g, b, a, z, s, t, w;\n    int sr, sg, sb, sa, sz, ss, st, sw;\n    int xstart, xend, xendsc;\n    int sss = 0, sst = 0;\n    uint32_t curpixel = 0;\n    int wen = 0;\n\n    int x, length, scdiff, lodlength;\n    uint32_t fir, fig, fib;\n    int delayedhbwidx = -1;\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        r = wstate->span[i].r;\n        g = wstate->span[i].g;\n        b = wstate->span[i].b;\n        a = wstate->span[i].a;\n        z = wstate->other_modes.z_source_sel ? wstate->primitive_z : wstate->span[i].z;\n        s = wstate->span[i].s;\n        t = wstate->span[i].t;\n        w = wstate->span[i].w;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        zbcur = zb + curpixel;\n\n        if (!flip)\n        {\n            length = xendsc - xstart;\n            scdiff = xend - xendsc;\n            compute_cvg_noflip(wstate, i);\n        }\n        else\n        {\n            length = xstart - xendsc;\n            scdiff = xendsc - xend;\n            compute_cvg_flip(wstate, i);\n        }\n\n\n\n\n\n\n\n\n        if (scdiff)\n        {\n            scdiff &= 0xfff;\n            r += (drinc * scdiff);\n            g += (dginc * scdiff);\n            b += (dbinc * scdiff);\n            a += (dainc * scdiff);\n            z += (dzinc * scdiff);\n            s += (dsinc * scdiff);\n            t += (dtinc * scdiff);\n            w += (dwinc * scdiff);\n        }\n\n        lodlength = length + scdiff;\n\n        for (j = 0; j <= length; j++)\n        {\n            sz = (z >> 10) & 0x3fffff;\n\n            if (!j)\n            {\n                sr = r >> 14;\n                sg = g >> 14;\n                sb = b >> 14;\n                sa = a >> 14;\n                ss = s >> 16;\n                st = t >> 16;\n                sw = w >> 16;\n\n                wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n                tclod_2cycle(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1, &tile2, &wstate->lod_frac);\n\n                texture_pipeline_cycle(wstate, &wstate->texel0_color, &wstate->texel0_color, sss, sst, tile1, 0);\n                texture_pipeline_cycle(wstate, &wstate->texel1_color, &wstate->texel0_color, sss, sst, tile2, 1);\n\n                lookup_cvmask_derivatives(wstate->cvgbuf[x], &offx, &offy, &curpixel_cvg, &curpixel_cvbit);\n\n                rgba_correct(wstate, offx, offy, sr, sg, sb, sa, curpixel_cvg);\n\n                if (wstate->other_modes.f.getditherlevel < 2)\n                    get_dither_noise(wstate, x, i, &cdith, &adith);\n\n                combiner_2cycle_cycle0(wstate, adith, curpixel_cvg, &acalpha);\n            }\n\n\n\n            s += dsinc;\n            t += dtinc;\n            w += dwinc;\n\n            ss = s >> 16;\n            st = t >> 16;\n            sw = w >> 16;\n\n            wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n            if (j < length || !wstate->span[i + 1].validline || lodlength < 3)\n            {\n                tclod_2cycle(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1, &tile2, &prelodfrac);\n\n                texture_pipeline_cycle(wstate, &wstate->nexttexel_color, &wstate->nexttexel_color, sss, sst, tile1, 0);\n                texture_pipeline_cycle(wstate, &nexttexel1_color, &wstate->nexttexel_color, sss, sst, tile2, 1);\n            }\n            else\n            {\n                int sss2, sst2;\n\n                ss = wstate->span[i + 1].s >> 16;\n                st = wstate->span[i + 1].t >> 16;\n                sw = wstate->span[i + 1].w >> 16;\n                wstate->tcdiv_ptr(ss, st, sw, &sss2, &sst2);\n\n                tclod_2cycle_next(wstate, &sss, &sst, &sss2, &sst2, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1, &tile3, &prelodfrac, i);\n\n                texture_pipeline_cycle(wstate, &wstate->nexttexel_color, &wstate->nexttexel_color, sss, sst, tile1, 0);\n                texture_pipeline_cycle(wstate, &nexttexel1_color, &wstate->nexttexel_color, sss2, sst2, tile3, 0);\n            }\n\n            z_correct(wstate, offx, offy, &sz, curpixel_cvg);\n\n            combiner_2cycle_cycle1(wstate, adith, &curpixel_cvg);\n\n            wstate->fbread2_ptr(wstate, curpixel, &curpixel_memcvg);\n\n            wen = z_compare(wstate, zbcur, sz, (uint16_t)dzpix, dzpixenc, &blend_en, &prewrap, &curpixel_cvg, curpixel_memcvg);\n\n            if (wen)\n                wen = blender_2cycle_cycle0(wstate, curpixel_cvg, curpixel_cvbit);\n\n            if (!wen && i >= wstate->last_overwriting_scanline)\n                blender_2cycle_cycle0_gval(wstate, curpixel);\n\n            wstate->memory_color = wstate->pre_memory_color;\n\n            x += xinc;\n\n            r += drinc;\n            g += dginc;\n            b += dbinc;\n            a += dainc;\n\n            sr = r >> 14;\n            sg = g >> 14;\n            sb = b >> 14;\n            sa = a >> 14;\n\n\n\n\n            lookup_cvmask_derivatives(j < length ? wstate->cvgbuf[x] : 0, &offx, &offy, &nextpixel_cvg, &curpixel_cvbit);\n\n            rgba_correct(wstate, offx, offy, sr, sg, sb, sa, nextpixel_cvg);\n\n            wstate->lod_frac = prelodfrac;\n            wstate->texel0_color = wstate->nexttexel_color;\n            wstate->texel1_color = nexttexel1_color;\n\n\n            combiner_2cycle_cycle0(wstate, adith, nextpixel_cvg, &acalpha);\n\n            if (wen)\n                wen = alpha_compare(wstate, acalpha);\n\n            if (wen)\n            {\n                blender_2cycle_cycle1(wstate, &fir, &fig, &fib, cdith, blend_en, prewrap);\n                wstate->fbwrite_ptr(wstate, curpixel, fir, fig, fib, blend_en, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n                if (wstate->other_modes.z_update_en)\n                    z_store(zbcur, sz, dzpixenc);\n            }\n            else if (i >= wstate->last_overwriting_scanline)\n                rejected_hbwrite_2cycle(wstate, cdith, blend_en, prewrap, curpixel, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n\n            if (wstate->other_modes.f.getditherlevel < 2)\n                get_dither_noise(wstate, x, i, &cdith, &adith);\n\n            curpixel_cvg = nextpixel_cvg;\n\n\n\n\n\n\n            z += dzinc;\n\n            curpixel += xinc;\n            zbcur += xinc;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\n\n\nstatic void render_spans_2cycle_notexelnext(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    int zb = wstate->zb_address >> 1;\n    int zbcur;\n    uint8_t offx = 0;\n    uint8_t offy = 0;\n    uint32_t blend_en;\n    uint32_t prewrap;\n    uint32_t curpixel_cvg = 0, curpixel_cvbit = 0, curpixel_memcvg = 0;\n    uint32_t nextpixel_cvg;\n    uint32_t acalpha;\n\n    int tile2 = (tilenum + 1) & 7;\n    int tile1 = tilenum;\n    int prim_tile = tilenum;\n\n    int i, j;\n\n    int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;\n    int xinc;\n    if (flip)\n    {\n        drinc = wstate->spans_dr;\n        dginc = wstate->spans_dg;\n        dbinc = wstate->spans_db;\n        dainc = wstate->spans_da;\n        dzinc = wstate->spans_dz;\n        dsinc = wstate->spans_ds;\n        dtinc = wstate->spans_dt;\n        dwinc = wstate->spans_dw;\n        xinc = 1;\n    }\n    else\n    {\n        drinc = -wstate->spans_dr;\n        dginc = -wstate->spans_dg;\n        dbinc = -wstate->spans_db;\n        dainc = -wstate->spans_da;\n        dzinc = -wstate->spans_dz;\n        dsinc = -wstate->spans_ds;\n        dtinc = -wstate->spans_dt;\n        dwinc = -wstate->spans_dw;\n        xinc = -1;\n    }\n\n    int dzpix;\n    if (!wstate->other_modes.z_source_sel)\n        dzpix = wstate->spans_dzpix;\n    else\n    {\n        dzpix = wstate->primitive_delta_z;\n        dzinc = wstate->spans_cdz = wstate->spans_dzdy = 0;\n    }\n    int dzpixenc = dz_compress(dzpix);\n\n    int cdith = 7, adith = 0;\n\n    int r, g, b, a, z, s, t, w;\n    int sr, sg, sb, sa, sz, ss, st, sw;\n    int xstart, xend, xendsc;\n    int sss = 0, sst = 0;\n    int curpixel = 0;\n    int wen;\n\n    int x, length, scdiff;\n    uint32_t fir, fig, fib;\n    int delayedhbwidx = -1;\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        r = wstate->span[i].r;\n        g = wstate->span[i].g;\n        b = wstate->span[i].b;\n        a = wstate->span[i].a;\n        z = wstate->other_modes.z_source_sel ? wstate->primitive_z : wstate->span[i].z;\n        s = wstate->span[i].s;\n        t = wstate->span[i].t;\n        w = wstate->span[i].w;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        zbcur = zb + curpixel;\n\n        if (!flip)\n        {\n            length = xendsc - xstart;\n            scdiff = xend - xendsc;\n            compute_cvg_noflip(wstate, i);\n        }\n        else\n        {\n            length = xstart - xendsc;\n            scdiff = xendsc - xend;\n            compute_cvg_flip(wstate, i);\n        }\n\n        if (scdiff)\n        {\n            scdiff &= 0xfff;\n            r += (drinc * scdiff);\n            g += (dginc * scdiff);\n            b += (dbinc * scdiff);\n            a += (dainc * scdiff);\n            z += (dzinc * scdiff);\n            s += (dsinc * scdiff);\n            t += (dtinc * scdiff);\n            w += (dwinc * scdiff);\n        }\n\n        for (j = 0; j <= length; j++)\n        {\n            sz = (z >> 10) & 0x3fffff;\n\n            if (!j)\n            {\n                sr = r >> 14;\n                sg = g >> 14;\n                sb = b >> 14;\n                sa = a >> 14;\n                ss = s >> 16;\n                st = t >> 16;\n                sw = w >> 16;\n\n                wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n                tclod_2cycle(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1, &tile2, &wstate->lod_frac);\n\n                texture_pipeline_cycle(wstate, &wstate->texel0_color, &wstate->texel0_color, sss, sst, tile1, 0);\n                texture_pipeline_cycle(wstate, &wstate->texel1_color, &wstate->texel0_color, sss, sst, tile2, 1);\n\n                lookup_cvmask_derivatives(wstate->cvgbuf[x], &offx, &offy, &curpixel_cvg, &curpixel_cvbit);\n\n                rgba_correct(wstate, offx, offy, sr, sg, sb, sa, curpixel_cvg);\n\n                if (wstate->other_modes.f.getditherlevel < 2)\n                    get_dither_noise(wstate, x, i, &cdith, &adith);\n\n                combiner_2cycle_cycle0(wstate, adith, curpixel_cvg, &acalpha);\n            }\n\n            z_correct(wstate, offx, offy, &sz, curpixel_cvg);\n\n            combiner_2cycle_cycle1(wstate, adith, &curpixel_cvg);\n\n            wstate->fbread2_ptr(wstate, curpixel, &curpixel_memcvg);\n\n            wen = z_compare(wstate, zbcur, sz, (uint16_t)dzpix, dzpixenc, &blend_en, &prewrap, &curpixel_cvg, curpixel_memcvg);\n\n            if (wen)\n                wen = blender_2cycle_cycle0(wstate, curpixel_cvg, curpixel_cvbit);\n\n            if (!wen && i >= wstate->last_overwriting_scanline)\n                blender_2cycle_cycle0_gval(wstate, curpixel);\n\n            wstate->memory_color = wstate->pre_memory_color;\n\n            x += xinc;\n\n            r += drinc;\n            g += dginc;\n            b += dbinc;\n            a += dainc;\n            s += dsinc;\n            t += dtinc;\n            w += dwinc;\n\n            sr = r >> 14;\n            sg = g >> 14;\n            sb = b >> 14;\n            sa = a >> 14;\n            ss = s >> 16;\n            st = t >> 16;\n            sw = w >> 16;\n\n            lookup_cvmask_derivatives(j < length ? wstate->cvgbuf[x] : 0, &offx, &offy, &nextpixel_cvg, &curpixel_cvbit);\n\n            rgba_correct(wstate, offx, offy, sr, sg, sb, sa, nextpixel_cvg);\n\n            wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n            tclod_2cycle(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1, &tile2, &wstate->lod_frac);\n\n            texture_pipeline_cycle(wstate, &wstate->texel0_color, &wstate->texel0_color, sss, sst, tile1, 0);\n            texture_pipeline_cycle(wstate, &wstate->texel1_color, &wstate->texel0_color, sss, sst, tile2, 1);\n\n            combiner_2cycle_cycle0(wstate, adith, nextpixel_cvg, &acalpha);\n\n            if (wen)\n                wen = alpha_compare(wstate, acalpha);\n\n            if (wen)\n            {\n                blender_2cycle_cycle1(wstate, &fir, &fig, &fib, cdith, blend_en, prewrap);\n                wstate->fbwrite_ptr(wstate, curpixel, fir, fig, fib, blend_en, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n                if (wstate->other_modes.z_update_en)\n                    z_store(zbcur, sz, dzpixenc);\n            }\n            else if (i >= wstate->last_overwriting_scanline)\n                rejected_hbwrite_2cycle(wstate, cdith, blend_en, prewrap, curpixel, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n\n\n            if (wstate->other_modes.f.getditherlevel < 2)\n                get_dither_noise(wstate, x, i, &cdith, &adith);\n\n            curpixel_cvg = nextpixel_cvg;\n\n            z += dzinc;\n\n            curpixel += xinc;\n            zbcur += xinc;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\n\nstatic void render_spans_2cycle_notexel1(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    int zb = wstate->zb_address >> 1;\n    int zbcur;\n    uint8_t offx = 0;\n    uint8_t offy = 0;\n    uint32_t blend_en;\n    uint32_t prewrap;\n    uint32_t curpixel_cvg = 0, curpixel_cvbit = 0, curpixel_memcvg = 0;\n    uint32_t nextpixel_cvg;\n    uint32_t acalpha;\n\n    int tile1 = tilenum;\n    int prim_tile = tilenum;\n\n    int i, j;\n\n    int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;\n    int xinc;\n    if (flip)\n    {\n        drinc = wstate->spans_dr;\n        dginc = wstate->spans_dg;\n        dbinc = wstate->spans_db;\n        dainc = wstate->spans_da;\n        dzinc = wstate->spans_dz;\n        dsinc = wstate->spans_ds;\n        dtinc = wstate->spans_dt;\n        dwinc = wstate->spans_dw;\n        xinc = 1;\n    }\n    else\n    {\n        drinc = -wstate->spans_dr;\n        dginc = -wstate->spans_dg;\n        dbinc = -wstate->spans_db;\n        dainc = -wstate->spans_da;\n        dzinc = -wstate->spans_dz;\n        dsinc = -wstate->spans_ds;\n        dtinc = -wstate->spans_dt;\n        dwinc = -wstate->spans_dw;\n        xinc = -1;\n    }\n\n    int dzpix;\n    if (!wstate->other_modes.z_source_sel)\n        dzpix = wstate->spans_dzpix;\n    else\n    {\n        dzpix = wstate->primitive_delta_z;\n        dzinc = wstate->spans_cdz = wstate->spans_dzdy = 0;\n    }\n    int dzpixenc = dz_compress(dzpix);\n\n    int cdith = 7, adith = 0;\n\n    int r, g, b, a, z, s, t, w;\n    int sr, sg, sb, sa, sz, ss, st, sw;\n    int xstart, xend, xendsc;\n    int sss = 0, sst = 0;\n    int curpixel = 0;\n    int wen;\n\n    int x, length, scdiff;\n    uint32_t fir, fig, fib;\n    int delayedhbwidx = -1;\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        r = wstate->span[i].r;\n        g = wstate->span[i].g;\n        b = wstate->span[i].b;\n        a = wstate->span[i].a;\n        z = wstate->other_modes.z_source_sel ? wstate->primitive_z : wstate->span[i].z;\n        s = wstate->span[i].s;\n        t = wstate->span[i].t;\n        w = wstate->span[i].w;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        zbcur = zb + curpixel;\n\n        if (!flip)\n        {\n            length = xendsc - xstart;\n            scdiff = xend - xendsc;\n            compute_cvg_noflip(wstate, i);\n        }\n        else\n        {\n            length = xstart - xendsc;\n            scdiff = xendsc - xend;\n            compute_cvg_flip(wstate, i);\n        }\n\n        if (scdiff)\n        {\n            scdiff &= 0xfff;\n            r += (drinc * scdiff);\n            g += (dginc * scdiff);\n            b += (dbinc * scdiff);\n            a += (dainc * scdiff);\n            z += (dzinc * scdiff);\n            s += (dsinc * scdiff);\n            t += (dtinc * scdiff);\n            w += (dwinc * scdiff);\n        }\n\n        for (j = 0; j <= length; j++)\n        {\n            sz = (z >> 10) & 0x3fffff;\n\n            if (!j)\n            {\n                sr = r >> 14;\n                sg = g >> 14;\n                sb = b >> 14;\n                sa = a >> 14;\n                ss = s >> 16;\n                st = t >> 16;\n                sw = w >> 16;\n\n                wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n                tclod_2cycle_notexel1(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1);\n\n                texture_pipeline_cycle(wstate, &wstate->texel0_color, &wstate->texel0_color, sss, sst, tile1, 0);\n\n                lookup_cvmask_derivatives(wstate->cvgbuf[x], &offx, &offy, &curpixel_cvg, &curpixel_cvbit);\n\n                rgba_correct(wstate, offx, offy, sr, sg, sb, sa, curpixel_cvg);\n\n                if (wstate->other_modes.f.getditherlevel < 2)\n                    get_dither_noise(wstate, x, i, &cdith, &adith);\n\n                combiner_2cycle_cycle0(wstate, adith, curpixel_cvg, &acalpha);\n            }\n\n            z_correct(wstate, offx, offy, &sz, curpixel_cvg);\n\n            combiner_2cycle_cycle1(wstate, adith, &curpixel_cvg);\n\n            wstate->fbread2_ptr(wstate, curpixel, &curpixel_memcvg);\n\n            wen = z_compare(wstate, zbcur, sz, (uint16_t)dzpix, dzpixenc, &blend_en, &prewrap, &curpixel_cvg, curpixel_memcvg);\n\n            if (wen)\n                wen = blender_2cycle_cycle0(wstate, curpixel_cvg, curpixel_cvbit);\n\n            if (!wen && i >= wstate->last_overwriting_scanline)\n                blender_2cycle_cycle0_gval(wstate, curpixel);\n\n            wstate->memory_color = wstate->pre_memory_color;\n\n            x += xinc;\n\n            r += drinc;\n            g += dginc;\n            b += dbinc;\n            a += dainc;\n            s += dsinc;\n            t += dtinc;\n            w += dwinc;\n\n            sr = r >> 14;\n            sg = g >> 14;\n            sb = b >> 14;\n            sa = a >> 14;\n            ss = s >> 16;\n            st = t >> 16;\n            sw = w >> 16;\n\n            lookup_cvmask_derivatives(j < length ? wstate->cvgbuf[x] : 0, &offx, &offy, &nextpixel_cvg, &curpixel_cvbit);\n\n            rgba_correct(wstate, offx, offy, sr, sg, sb, sa, nextpixel_cvg);\n\n            wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n            tclod_2cycle_notexel1(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1);\n\n            texture_pipeline_cycle(wstate, &wstate->texel0_color, &wstate->texel0_color, sss, sst, tile1, 0);\n\n            combiner_2cycle_cycle0(wstate, adith, nextpixel_cvg, &acalpha);\n\n            if (wen)\n                wen = alpha_compare(wstate, acalpha);\n\n            if (wen)\n            {\n                blender_2cycle_cycle1(wstate, &fir, &fig, &fib, cdith, blend_en, prewrap);\n                wstate->fbwrite_ptr(wstate, curpixel, fir, fig, fib, blend_en, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n                if (wstate->other_modes.z_update_en)\n                    z_store(zbcur, sz, dzpixenc);\n            }\n            else if (i >= wstate->last_overwriting_scanline)\n                rejected_hbwrite_2cycle(wstate, cdith, blend_en, prewrap, curpixel, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n\n            if (wstate->other_modes.f.getditherlevel < 2)\n                get_dither_noise(wstate, x, i, &cdith, &adith);\n\n            curpixel_cvg = nextpixel_cvg;\n\n            z += dzinc;\n\n            curpixel += xinc;\n            zbcur += xinc;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\n\nstatic void render_spans_2cycle_notex(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    UNUSED(tilenum);\n\n    int zb = wstate->zb_address >> 1;\n    int zbcur;\n    uint8_t offx = 0;\n    uint8_t offy = 0;\n    uint32_t blend_en;\n    uint32_t prewrap;\n    uint32_t curpixel_cvg = 0, curpixel_cvbit = 0, curpixel_memcvg = 0;\n    uint32_t nextpixel_cvg;\n    uint32_t acalpha;\n\n    int i, j;\n\n    int drinc, dginc, dbinc, dainc, dzinc;\n    int xinc;\n    if (flip)\n    {\n        drinc = wstate->spans_dr;\n        dginc = wstate->spans_dg;\n        dbinc = wstate->spans_db;\n        dainc = wstate->spans_da;\n        dzinc = wstate->spans_dz;\n        xinc = 1;\n    }\n    else\n    {\n        drinc = -wstate->spans_dr;\n        dginc = -wstate->spans_dg;\n        dbinc = -wstate->spans_db;\n        dainc = -wstate->spans_da;\n        dzinc = -wstate->spans_dz;\n        xinc = -1;\n    }\n\n    int dzpix;\n    if (!wstate->other_modes.z_source_sel)\n        dzpix = wstate->spans_dzpix;\n    else\n    {\n        dzpix = wstate->primitive_delta_z;\n        dzinc = wstate->spans_cdz = wstate->spans_dzdy = 0;\n    }\n    int dzpixenc = dz_compress(dzpix);\n\n    int cdith = 7, adith = 0;\n\n    int r, g, b, a, z;\n    int sr, sg, sb, sa, sz;\n    int xstart, xend, xendsc;\n    int curpixel = 0;\n    int wen;\n\n    int x, length, scdiff;\n    uint32_t fir, fig, fib;\n    int delayedhbwidx = -1;\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        r = wstate->span[i].r;\n        g = wstate->span[i].g;\n        b = wstate->span[i].b;\n        a = wstate->span[i].a;\n        z = wstate->other_modes.z_source_sel ? wstate->primitive_z : wstate->span[i].z;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        zbcur = zb + curpixel;\n\n        if (!flip)\n        {\n            length = xendsc - xstart;\n            scdiff = xend - xendsc;\n            compute_cvg_noflip(wstate, i);\n        }\n        else\n        {\n            length = xstart - xendsc;\n            scdiff = xendsc - xend;\n            compute_cvg_flip(wstate, i);\n        }\n\n        if (scdiff)\n        {\n            scdiff &= 0xfff;\n            r += (drinc * scdiff);\n            g += (dginc * scdiff);\n            b += (dbinc * scdiff);\n            a += (dainc * scdiff);\n            z += (dzinc * scdiff);\n        }\n\n        for (j = 0; j <= length; j++)\n        {\n            sz = (z >> 10) & 0x3fffff;\n\n            if (!j)\n            {\n                sr = r >> 14;\n                sg = g >> 14;\n                sb = b >> 14;\n                sa = a >> 14;\n\n                lookup_cvmask_derivatives(wstate->cvgbuf[x], &offx, &offy, &curpixel_cvg, &curpixel_cvbit);\n\n                rgba_correct(wstate, offx, offy, sr, sg, sb, sa, curpixel_cvg);\n\n                if (wstate->other_modes.f.getditherlevel < 2)\n                    get_dither_noise(wstate, x, i, &cdith, &adith);\n\n                combiner_2cycle_cycle0(wstate, adith, curpixel_cvg, &acalpha);\n            }\n\n            z_correct(wstate, offx, offy, &sz, curpixel_cvg);\n\n            combiner_2cycle_cycle1(wstate, adith, &curpixel_cvg);\n\n            wstate->fbread2_ptr(wstate, curpixel, &curpixel_memcvg);\n\n            wen = z_compare(wstate, zbcur, sz, (uint16_t)dzpix, dzpixenc, &blend_en, &prewrap, &curpixel_cvg, curpixel_memcvg);\n\n            if (wen)\n                wen = blender_2cycle_cycle0(wstate, curpixel_cvg, curpixel_cvbit);\n\n            if (!wen && i >= wstate->last_overwriting_scanline)\n                blender_2cycle_cycle0_gval(wstate, curpixel);\n\n            wstate->memory_color = wstate->pre_memory_color;\n\n            x += xinc;\n\n            r += drinc;\n            g += dginc;\n            b += dbinc;\n            a += dainc;\n\n            sr = r >> 14;\n            sg = g >> 14;\n            sb = b >> 14;\n            sa = a >> 14;\n\n            lookup_cvmask_derivatives(j < length ? wstate->cvgbuf[x] : 0, &offx, &offy, &nextpixel_cvg, &curpixel_cvbit);\n\n            rgba_correct(wstate, offx, offy, sr, sg, sb, sa, nextpixel_cvg);\n\n            combiner_2cycle_cycle0(wstate, adith, nextpixel_cvg, &acalpha);\n\n            if (wen)\n                wen = alpha_compare(wstate, acalpha);\n\n            if (wen)\n            {\n                blender_2cycle_cycle1(wstate, &fir, &fig, &fib, cdith, blend_en, prewrap);\n                wstate->fbwrite_ptr(wstate, curpixel, fir, fig, fib, blend_en, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n                if (wstate->other_modes.z_update_en)\n                    z_store(zbcur, sz, dzpixenc);\n            }\n            else if (i >= wstate->last_overwriting_scanline)\n                rejected_hbwrite_2cycle(wstate, cdith, blend_en, prewrap, curpixel, curpixel_cvg, curpixel_memcvg, flip, &delayedhbwidx);\n\n\n            if (wstate->other_modes.f.getditherlevel < 2)\n                get_dither_noise(wstate, x, i, &cdith, &adith);\n\n            curpixel_cvg = nextpixel_cvg;\n\n            z += dzinc;\n\n            curpixel += xinc;\n            zbcur += xinc;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\n\nstatic void render_spans_fill(struct rdp_state* wstate, int start, int end, int flip)\n{\n    if (wstate->fb_size == PIXEL_SIZE_4BIT)\n    {\n        rdp_pipeline_crashed = 1;\n        return;\n    }\n\n    int i, j;\n\n    int fastkillbits = wstate->other_modes.image_read_en || wstate->other_modes.z_compare_en;\n    int slowkillbits = wstate->other_modes.z_update_en && !wstate->other_modes.z_source_sel && !fastkillbits;\n\n    int xinc = flip ? 1 : -1;\n\n    int xstart = 0, xendsc;\n    int prevxstart;\n    int curpixel = 0;\n    int x, length;\n    int delayedhbwidx = -1;\n\n    for (i = start; i <= end; i++)\n    {\n        prevxstart = xstart;\n        xstart = wstate->span[i].lx;\n        xendsc = wstate->span[i].rx;\n\n        x = xendsc;\n        curpixel = wstate->fb_width * i + x;\n        length = flip ? (xstart - xendsc) : (xendsc - xstart);\n\n        if (wstate->span[i].validline)\n        {\n            if (fastkillbits && length >= 0)\n            {\n                if (!onetimewarnings.fillmbitcrashes)\n                    msg_warning(\"render_spans_fill: image_read_en %x z_update_en %x z_compare_en %x. RDP crashed\",\n                    wstate->other_modes.image_read_en, wstate->other_modes.z_update_en, wstate->other_modes.z_compare_en);\n                onetimewarnings.fillmbitcrashes = true;\n                rdp_pipeline_crashed = 1;\n                return;\n            }\n\n\n\n\n\n\n\n            for (j = 0; j <= length; j++)\n            {\n                wstate->fbfill_ptr(wstate, curpixel, flip, &delayedhbwidx);\n\n                x += xinc;\n                curpixel += xinc;\n            }\n\n            if (slowkillbits && length >= 0)\n            {\n                if (!onetimewarnings.fillmbitcrashes)\n                    msg_warning(\"render_spans_fill: image_read_en %x z_update_en %x z_compare_en %x z_source_sel %x. RDP crashed\",\n                    wstate->other_modes.image_read_en, wstate->other_modes.z_update_en, wstate->other_modes.z_compare_en, wstate->other_modes.z_source_sel);\n                onetimewarnings.fillmbitcrashes = 1;\n                rdp_pipeline_crashed = 1;\n                return;\n            }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\nstatic void render_spans_copy(struct rdp_state* wstate, int start, int end, int tilenum, int flip)\n{\n    int i, j, k;\n\n    if (wstate->fb_size == PIXEL_SIZE_32BIT)\n    {\n        rdp_pipeline_crashed = 1;\n        return;\n    }\n\n    int tile1 = tilenum;\n    int prim_tile = tilenum;\n\n    int dsinc, dtinc, dwinc;\n    int xinc;\n    if (flip)\n    {\n        dsinc = wstate->spans_ds;\n        dtinc = wstate->spans_dt;\n        dwinc = wstate->spans_dw;\n        xinc = 1;\n    }\n    else\n    {\n        dsinc = -wstate->spans_ds;\n        dtinc = -wstate->spans_dt;\n        dwinc = -wstate->spans_dw;\n        xinc = -1;\n    }\n\n    int xstart = 0, xendsc;\n    int s = 0, t = 0, w = 0, ss = 0, st = 0, sw = 0, sss = 0, sst = 0/*, ssw = 0*/;\n    int fb_index, length;\n    //int diff = 0;\n\n    uint32_t hidword = 0, lowdword = 0;\n    //uint32_t hidword1 = 0, lowdword1 = 0;\n    int fbadvance = (wstate->fb_size == PIXEL_SIZE_4BIT) ? 8 : 16 >> wstate->fb_size;\n    uint32_t fbptr = 0;\n    int fbptr_advance = flip ? 8 : -8;\n    uint64_t copyqword = 0;\n    uint32_t tempdword = 0;\n    uint8_t tempbyte = 0;\n    int copywmask = 0, alphamask = 0;\n    int bytesperpixel = (wstate->fb_size == PIXEL_SIZE_4BIT) ? 1 : (1 << (wstate->fb_size - 1));\n    uint32_t fbendptr = 0;\n    int32_t threshold, currthreshold;\n    int delayedhbwidx = -1;\n\n#define PIXELS_TO_BYTES_SPECIAL4(pix, siz) ((siz) ? PIXELS_TO_BYTES(pix, siz) : (pix))\n\n    for (i = start; i <= end; i++)\n    {\n        if (wstate->span[i].validline)\n        {\n\n        s = wstate->span[i].s;\n        t = wstate->span[i].t;\n        w = wstate->span[i].w;\n\n        xstart = wstate->span[i].lx;\n        xendsc = wstate->span[i].rx;\n\n        fb_index = wstate->fb_width * i + xendsc;\n        fbptr = wstate->fb_address + PIXELS_TO_BYTES_SPECIAL4(fb_index, wstate->fb_size);\n        fbendptr = wstate->fb_address + PIXELS_TO_BYTES_SPECIAL4((wstate->fb_width * i + xstart), wstate->fb_size);\n        length = flip ? (xstart - xendsc) : (xendsc - xstart);\n\n\n\n\n        for (j = 0; j <= length; j += fbadvance)\n        {\n            ss = s >> 16;\n            st = t >> 16;\n            sw = w >> 16;\n\n            wstate->tcdiv_ptr(ss, st, sw, &sss, &sst);\n\n            tclod_copy(wstate, &sss, &sst, s, t, w, dsinc, dtinc, dwinc, prim_tile, &tile1);\n\n\n\n            fetch_qword_copy(wstate, &hidword, &lowdword, sss, sst, tile1);\n\n\n\n            if (wstate->fb_size == PIXEL_SIZE_16BIT || wstate->fb_size == PIXEL_SIZE_8BIT)\n                copyqword = ((uint64_t)hidword << 32) | ((uint64_t)lowdword);\n            else\n                copyqword = 0;\n\n\n            if (!wstate->other_modes.alpha_compare_en)\n                alphamask = 0xff;\n            else if (wstate->fb_size == PIXEL_SIZE_16BIT)\n            {\n                alphamask = 0;\n                alphamask |= (((copyqword >> 48) & 1) ? 0xC0 : 0);\n                alphamask |= (((copyqword >> 32) & 1) ? 0x30 : 0);\n                alphamask |= (((copyqword >> 16) & 1) ? 0xC : 0);\n                alphamask |= ((copyqword & 1) ? 0x3 : 0);\n            }\n            else if (wstate->fb_size == PIXEL_SIZE_8BIT)\n            {\n                alphamask = 0;\n                threshold = (wstate->other_modes.dither_alpha_en) ? (irand(&wstate->rseed) & 0xff) : wstate->blend_color.a;\n                if (wstate->other_modes.dither_alpha_en)\n                {\n                    currthreshold = threshold;\n                    alphamask |= (((copyqword >> 24) & 0xff) >= currthreshold ? 0xC0 : 0);\n                    currthreshold = ((threshold & 3) << 6) | (threshold >> 2);\n                    alphamask |= (((copyqword >> 16) & 0xff) >= currthreshold ? 0x30 : 0);\n                    currthreshold = ((threshold & 0xf) << 4) | (threshold >> 4);\n                    alphamask |= (((copyqword >> 8) & 0xff) >= currthreshold ? 0xC : 0);\n                    currthreshold = ((threshold & 0x3f) << 2) | (threshold >> 6);\n                    alphamask |= ((copyqword & 0xff) >= currthreshold ? 0x3 : 0);\n                }\n                else\n                {\n                    alphamask |= (((copyqword >> 24) & 0xff) >= threshold ? 0xC0 : 0);\n                    alphamask |= (((copyqword >> 16) & 0xff) >= threshold ? 0x30 : 0);\n                    alphamask |= (((copyqword >> 8) & 0xff) >= threshold ? 0xC : 0);\n                    alphamask |= ((copyqword & 0xff) >= threshold ? 0x3 : 0);\n                }\n            }\n            else\n                alphamask = 0;\n\n            copywmask = (flip) ? (fbendptr - fbptr + bytesperpixel) : (fbptr - fbendptr + bytesperpixel);\n\n            if (copywmask > 8)\n                copywmask = 8;\n            tempdword = fbptr;\n            k = 7;\n            while(copywmask > 0)\n            {\n                tempbyte = (uint8_t)((copyqword >> (k << 3)) & 0xff);\n                if (alphamask & (1 << k))\n                    rdram_write_pair8(tempdword, tempbyte, flip, &delayedhbwidx);\n\n                k--;\n                tempdword += xinc;\n                copywmask--;\n            }\n\n            s += dsinc;\n            t += dtinc;\n            w += dwinc;\n            fbptr += fbptr_advance;\n        }\n        }\n    }\n\n    if (delayedhbwidx >= 0 && flip && wstate->fb_size == PIXEL_SIZE_8BIT)\n        rdram_complete_delayed_hbwrites(delayedhbwidx);\n}\n\nstatic void edgewalker_for_prims(struct rdp_state* wstate, int32_t* ewdata)\n{\n    int j = 0;\n    int xleft = 0, xright = 0, xleft_inc = 0, xright_inc = 0;\n    int r = 0, g = 0, b = 0, a = 0, z = 0, s = 0, t = 0, w = 0;\n    //int dr = 0, dg = 0, db = 0, da = 0;\n    int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0, dzdx = 0, dsdx = 0, dtdx = 0, dwdx = 0;\n    int drdy = 0, dgdy = 0, dbdy = 0, dady = 0, dzdy = 0, dsdy = 0, dtdy = 0, dwdy = 0;\n    int drde = 0, dgde = 0, dbde = 0, dade = 0, dzde = 0, dsde = 0, dtde = 0, dwde = 0;\n    int tilenum = 0, flip = 0;\n    int32_t yl = 0, ym = 0, yh = 0;\n    int32_t xl = 0, xm = 0, xh = 0;\n    int32_t dxldy = 0, dxhdy = 0, dxmdy = 0;\n\n    if (wstate->other_modes.f.stalederivs)\n    {\n        deduce_derivatives(wstate);\n        wstate->other_modes.f.stalederivs = 0;\n    }\n\n    if (wstate->fb_size == PIXEL_SIZE_8BIT)\n    {\n        rdram_hidden_old[0] &= ~2;\n        rdram_hidden_old[4] &= ~2;\n    }\n\n    int oldhb_diff = wstate->fb_size == PIXEL_SIZE_16BIT ? 7 : 3;\n    wstate->last_overwriting_scanline = -1;\n\n    flip = (ewdata[0] & 0x800000) != 0;\n    wstate->max_level = (ewdata[0] >> 19) & 7;\n    tilenum = (ewdata[0] >> 16) & 7;\n\n\n    yl = SIGN(ewdata[0], 14);\n    ym = ewdata[1] >> 16;\n    ym = SIGN(ym, 14);\n    yh = SIGN(ewdata[1], 14);\n\n    xl = SIGN(ewdata[2], 28);\n    xh = SIGN(ewdata[4], 28);\n    xm = SIGN(ewdata[6], 28);\n\n    dxldy = SIGN(ewdata[3], 30);\n\n\n\n    dxhdy = SIGN(ewdata[5], 30);\n    dxmdy = SIGN(ewdata[7], 30);\n\n\n    r    = (ewdata[8] & 0xffff0000) | ((ewdata[12] >> 16) & 0x0000ffff);\n    g    = ((ewdata[8] << 16) & 0xffff0000) | (ewdata[12] & 0x0000ffff);\n    b    = (ewdata[9] & 0xffff0000) | ((ewdata[13] >> 16) & 0x0000ffff);\n    a    = ((ewdata[9] << 16) & 0xffff0000) | (ewdata[13] & 0x0000ffff);\n    drdx = (ewdata[10] & 0xffff0000) | ((ewdata[14] >> 16) & 0x0000ffff);\n    dgdx = ((ewdata[10] << 16) & 0xffff0000) | (ewdata[14] & 0x0000ffff);\n    dbdx = (ewdata[11] & 0xffff0000) | ((ewdata[15] >> 16) & 0x0000ffff);\n    dadx = ((ewdata[11] << 16) & 0xffff0000) | (ewdata[15] & 0x0000ffff);\n    drde = (ewdata[16] & 0xffff0000) | ((ewdata[20] >> 16) & 0x0000ffff);\n    dgde = ((ewdata[16] << 16) & 0xffff0000) | (ewdata[20] & 0x0000ffff);\n    dbde = (ewdata[17] & 0xffff0000) | ((ewdata[21] >> 16) & 0x0000ffff);\n    dade = ((ewdata[17] << 16) & 0xffff0000) | (ewdata[21] & 0x0000ffff);\n    drdy = (ewdata[18] & 0xffff0000) | ((ewdata[22] >> 16) & 0x0000ffff);\n    dgdy = ((ewdata[18] << 16) & 0xffff0000) | (ewdata[22] & 0x0000ffff);\n    dbdy = (ewdata[19] & 0xffff0000) | ((ewdata[23] >> 16) & 0x0000ffff);\n    dady = ((ewdata[19] << 16) & 0xffff0000) | (ewdata[23] & 0x0000ffff);\n\n\n    s    = (ewdata[24] & 0xffff0000) | ((ewdata[28] >> 16) & 0x0000ffff);\n    t    = ((ewdata[24] << 16) & 0xffff0000)    | (ewdata[28] & 0x0000ffff);\n    w    = (ewdata[25] & 0xffff0000) | ((ewdata[29] >> 16) & 0x0000ffff);\n    dsdx = (ewdata[26] & 0xffff0000) | ((ewdata[30] >> 16) & 0x0000ffff);\n    dtdx = ((ewdata[26] << 16) & 0xffff0000)    | (ewdata[30] & 0x0000ffff);\n    dwdx = (ewdata[27] & 0xffff0000) | ((ewdata[31] >> 16) & 0x0000ffff);\n    dsde = (ewdata[32] & 0xffff0000) | ((ewdata[36] >> 16) & 0x0000ffff);\n    dtde = ((ewdata[32] << 16) & 0xffff0000)    | (ewdata[36] & 0x0000ffff);\n    dwde = (ewdata[33] & 0xffff0000) | ((ewdata[37] >> 16) & 0x0000ffff);\n    dsdy = (ewdata[34] & 0xffff0000) | ((ewdata[38] >> 16) & 0x0000ffff);\n    dtdy = ((ewdata[34] << 16) & 0xffff0000)    | (ewdata[38] & 0x0000ffff);\n    dwdy = (ewdata[35] & 0xffff0000) | ((ewdata[39] >> 16) & 0x0000ffff);\n\n\n    z    = ewdata[40];\n    dzdx = ewdata[41];\n    dzde = ewdata[42];\n    dzdy = ewdata[43];\n\n\n\n\n\n\n\n    wstate->spans_ds = dsdx & ~0x1f;\n    wstate->spans_dt = dtdx & ~0x1f;\n    wstate->spans_dw = dwdx & ~0x1f;\n    wstate->spans_dr = drdx & ~0x1f;\n    wstate->spans_dg = dgdx & ~0x1f;\n    wstate->spans_db = dbdx & ~0x1f;\n    wstate->spans_da = dadx & ~0x1f;\n    wstate->spans_dz = dzdx;\n\n\n    wstate->spans_drdy = drdy >> 14;\n    wstate->spans_dgdy = dgdy >> 14;\n    wstate->spans_dbdy = dbdy >> 14;\n    wstate->spans_dady = dady >> 14;\n    wstate->spans_dzdy = dzdy >> 10;\n    wstate->spans_drdy = SIGN(wstate->spans_drdy, 13);\n    wstate->spans_dgdy = SIGN(wstate->spans_dgdy, 13);\n    wstate->spans_dbdy = SIGN(wstate->spans_dbdy, 13);\n    wstate->spans_dady = SIGN(wstate->spans_dady, 13);\n    wstate->spans_dzdy = SIGN(wstate->spans_dzdy, 22);\n    wstate->spans_cdr = wstate->spans_dr >> 14;\n    wstate->spans_cdr = SIGN(wstate->spans_cdr, 13);\n    wstate->spans_cdg = wstate->spans_dg >> 14;\n    wstate->spans_cdg = SIGN(wstate->spans_cdg, 13);\n    wstate->spans_cdb = wstate->spans_db >> 14;\n    wstate->spans_cdb = SIGN(wstate->spans_cdb, 13);\n    wstate->spans_cda = wstate->spans_da >> 14;\n    wstate->spans_cda = SIGN(wstate->spans_cda, 13);\n    wstate->spans_cdz = wstate->spans_dz >> 10;\n    wstate->spans_cdz = SIGN(wstate->spans_cdz, 22);\n\n    wstate->spans_dsdy = dsdy & ~0x7fff;\n    wstate->spans_dtdy = dtdy & ~0x7fff;\n    wstate->spans_dwdy = dwdy & ~0x7fff;\n\n\n    int dzdy_dz = (dzdy >> 16) & 0xffff;\n    int dzdx_dz = (dzdx >> 16) & 0xffff;\n\n    wstate->spans_dzpix = ((dzdy_dz & 0x8000) ? ((~dzdy_dz) & 0x7fff) : dzdy_dz) + ((dzdx_dz & 0x8000) ? ((~dzdx_dz) & 0x7fff) : dzdx_dz);\n    wstate->spans_dzpix = normalize_dzpix(wstate->spans_dzpix & 0xffff) & 0xffff;\n\n\n\n    xleft_inc = (dxmdy >> 2) & ~0x1;\n    xright_inc = (dxhdy >> 2) & ~0x1;\n\n\n\n    xright = xh & ~0x1;\n    xleft = xm & ~0x1;\n\n    int k = 0;\n\n    int dsdiff, dtdiff, dwdiff, drdiff, dgdiff, dbdiff, dadiff, dzdiff;\n    int sign_dxhdy = (ewdata[5] & 0x80000000) != 0;\n\n    int dsdeh, dtdeh, dwdeh, drdeh, dgdeh, dbdeh, dadeh, dzdeh, dsdyh, dtdyh, dwdyh, drdyh, dgdyh, dbdyh, dadyh, dzdyh;\n    int do_offset = !(sign_dxhdy ^ flip);\n\n    if (do_offset)\n    {\n        dsdeh = dsde & ~0x1ff;\n        dtdeh = dtde & ~0x1ff;\n        dwdeh = dwde & ~0x1ff;\n        drdeh = drde & ~0x1ff;\n        dgdeh = dgde & ~0x1ff;\n        dbdeh = dbde & ~0x1ff;\n        dadeh = dade & ~0x1ff;\n        dzdeh = dzde & ~0x1ff;\n\n        dsdyh = dsdy & ~0x1ff;\n        dtdyh = dtdy & ~0x1ff;\n        dwdyh = dwdy & ~0x1ff;\n        drdyh = drdy & ~0x1ff;\n        dgdyh = dgdy & ~0x1ff;\n        dbdyh = dbdy & ~0x1ff;\n        dadyh = dady & ~0x1ff;\n        dzdyh = dzdy & ~0x1ff;\n\n\n\n\n\n\n\n        dsdiff = dsdeh - (dsdeh >> 2) - dsdyh + (dsdyh >> 2);\n        dtdiff = dtdeh - (dtdeh >> 2) - dtdyh + (dtdyh >> 2);\n        dwdiff = dwdeh - (dwdeh >> 2) - dwdyh + (dwdyh >> 2);\n        drdiff = drdeh - (drdeh >> 2) - drdyh + (drdyh >> 2);\n        dgdiff = dgdeh - (dgdeh >> 2) - dgdyh + (dgdyh >> 2);\n        dbdiff = dbdeh - (dbdeh >> 2) - dbdyh + (dbdyh >> 2);\n        dadiff = dadeh - (dadeh >> 2) - dadyh + (dadyh >> 2);\n        dzdiff = dzdeh - (dzdeh >> 2) - dzdyh + (dzdyh >> 2);\n\n    }\n    else\n        dsdiff = dtdiff = dwdiff = drdiff = dgdiff = dbdiff = dadiff = dzdiff = 0;\n\n    int xfrac = 0;\n\n    int dsdxh, dtdxh, dwdxh, drdxh, dgdxh, dbdxh, dadxh, dzdxh;\n    if (wstate->other_modes.cycle_type != CYCLE_TYPE_COPY)\n    {\n        dsdxh = (dsdx >> 8) & ~1;\n        dtdxh = (dtdx >> 8) & ~1;\n        dwdxh = (dwdx >> 8) & ~1;\n        drdxh = (drdx >> 8) & ~1;\n        dgdxh = (dgdx >> 8) & ~1;\n        dbdxh = (dbdx >> 8) & ~1;\n        dadxh = (dadx >> 8) & ~1;\n        dzdxh = (dzdx >> 8) & ~1;\n    }\n    else\n        dsdxh = dtdxh = dwdxh = drdxh = dgdxh = dbdxh = dadxh = dzdxh = 0;\n\n\n\n\n\n#define ADJUST_ATTR_PRIM()      \\\n{                           \\\n    wstate->span[j].s = ((s & ~0x1ff) + dsdiff - (xfrac * dsdxh)) & ~0x3ff;             \\\n    wstate->span[j].t = ((t & ~0x1ff) + dtdiff - (xfrac * dtdxh)) & ~0x3ff;             \\\n    wstate->span[j].w = ((w & ~0x1ff) + dwdiff - (xfrac * dwdxh)) & ~0x3ff;             \\\n    wstate->span[j].r = ((r & ~0x1ff) + drdiff - (xfrac * drdxh)) & ~0x3ff;             \\\n    wstate->span[j].g = ((g & ~0x1ff) + dgdiff - (xfrac * dgdxh)) & ~0x3ff;             \\\n    wstate->span[j].b = ((b & ~0x1ff) + dbdiff - (xfrac * dbdxh)) & ~0x3ff;             \\\n    wstate->span[j].a = ((a & ~0x1ff) + dadiff - (xfrac * dadxh)) & ~0x3ff;             \\\n    wstate->span[j].z = ((z & ~0x1ff) + dzdiff - (xfrac * dzdxh)) & ~0x3ff;             \\\n}\n\n\n#define ADDVALUES_PRIM() {  \\\n            s += dsde;  \\\n            t += dtde;  \\\n            w += dwde; \\\n            r += drde; \\\n            g += dgde; \\\n            b += dbde; \\\n            a += dade; \\\n            z += dzde; \\\n}\n\n    int32_t maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;\n\n    int spix = 0;\n    int ycur =  yh & ~3;\n    int ldflag = (sign_dxhdy ^ flip) ? 0 : 3;\n    int invaly = 1;\n    //int length = 0;\n    int32_t xrsc = 0, xlsc = 0, stickybit = 0;\n    int32_t yllimit = 0, yhlimit = 0;\n    if (yl & 0x2000)\n        yllimit = 1;\n    else if (yl & 0x1000)\n        yllimit = 0;\n    else\n        yllimit = (yl & 0xfff) < wstate->clip.yl;\n    yllimit = yllimit ? yl : wstate->clip.yl;\n\n    int ylfar = yllimit | 3;\n    if ((yl >> 2) > (ylfar >> 2))\n        ylfar += 4;\n    else if ((yllimit >> 2) >= 0 && (yllimit >> 2) < 1023)\n        wstate->span[(yllimit >> 2) + 1].validline = 0;\n\n\n    if (yh & 0x2000)\n        yhlimit = 0;\n    else if (yh & 0x1000)\n        yhlimit = 1;\n    else\n        yhlimit = (yh >= wstate->clip.yh);\n    yhlimit = yhlimit ? yh : wstate->clip.yh;\n\n    int yhclose = yhlimit & ~3;\n\n    int32_t clipxlshift = wstate->clip.xl << 1;\n    int32_t clipxhshift = wstate->clip.xh << 1;\n    int allover = 1, allunder = 1, curover = 0, curunder = 0;\n    int allinval = 1;\n    int32_t curcross = 0;\n\n    xfrac = ((xright >> 8) & 0xff);\n\n\n    if (flip)\n    {\n    for (k = ycur; k <= ylfar; k++)\n    {\n        if (k == ym)\n        {\n\n            xleft = xl & ~1;\n            xleft_inc = (dxldy >> 2) & ~1;\n        }\n\n        spix = k & 3;\n\n        if (k >= yhclose)\n        {\n            invaly = k < yhlimit || k >= yllimit;\n\n            j = k >> 2;\n\n            if (spix == 0)\n            {\n                maxxmx = 0;\n                minxhx = 0xfff;\n                allover = allunder = 1;\n                allinval = 1;\n            }\n\n            stickybit = ((xright >> 1) & 0x1fff) > 0;\n            xrsc = ((xright >> 13) & 0x1ffe) | stickybit;\n\n\n            curunder = ((xright & 0x8000000) || (xrsc < clipxhshift && !(xright & 0x4000000)));\n\n            xrsc = curunder ? clipxhshift : (((xright >> 13) & 0x3ffe) | stickybit);\n            curover = ((xrsc & 0x2000) || (xrsc & 0x1fff) >= clipxlshift);\n            xrsc = curover ? clipxlshift : xrsc;\n            wstate->span[j].majorx[spix] = xrsc & 0x1fff;\n            allover &= curover;\n            allunder &= curunder;\n\n            stickybit = ((xleft >> 1) & 0x1fff) > 0;\n            xlsc = ((xleft >> 13) & 0x1ffe) | stickybit;\n            curunder = ((xleft & 0x8000000) || (xlsc < clipxhshift && !(xleft & 0x4000000)));\n            xlsc = curunder ? clipxhshift : (((xleft >> 13) & 0x3ffe) | stickybit);\n            curover = ((xlsc & 0x2000) || (xlsc & 0x1fff) >= clipxlshift);\n            xlsc = curover ? clipxlshift : xlsc;\n            wstate->span[j].minorx[spix] = xlsc & 0x1fff;\n            allover &= curover;\n            allunder &= curunder;\n\n\n\n            curcross = ((xleft ^ (1 << 27)) & (0x3fff << 14)) < ((xright ^ (1 << 27)) & (0x3fff << 14));\n\n\n            invaly |= curcross;\n            wstate->span[j].invalyscan[spix] = invaly;\n            allinval &= invaly;\n\n            if (!invaly)\n            {\n                maxxmx = (((xlsc >> 3) & 0xfff) > maxxmx) ? (xlsc >> 3) & 0xfff : maxxmx;\n                minxhx = (((xrsc >> 3) & 0xfff) < minxhx) ? (xrsc >> 3) & 0xfff : minxhx;\n            }\n\n            if (spix == ldflag)\n            {\n\n\n\n\n                wstate->span[j].unscrx = SIGN(xright >> 16, 12);\n                xfrac = (xright >> 8) & 0xff;\n                ADJUST_ATTR_PRIM();\n            }\n\n            if (spix == 3)\n            {\n                wstate->span[j].lx = maxxmx;\n                wstate->span[j].rx = minxhx;\n                wstate->span[j].validline  = !allinval && !allover && !allunder && (!wstate->scfield || (wstate->scfield && !(wstate->sckeepodd ^ (j & 1))));\n\n                if (wstate->span[j].validline && wstate->fb_size > PIXEL_SIZE_8BIT)\n                    if ((wstate->span[j].lx - wstate->span[j].rx) >= oldhb_diff)\n                        wstate->last_overwriting_scanline = j;\n\n                // skip line if not assigned to this worker\n                wstate->span[j].validline &= (!wstate->stride || j % wstate->stride == wstate->offset);\n            }\n\n\n        }\n\n        if (spix == 3)\n        {\n            ADDVALUES_PRIM();\n        }\n\n\n\n        xleft += xleft_inc;\n        xright += xright_inc;\n\n    }\n    }\n    else\n    {\n    for (k = ycur; k <= ylfar; k++)\n    {\n        if (k == ym)\n        {\n            xleft = xl & ~1;\n            xleft_inc = (dxldy >> 2) & ~1;\n        }\n\n        spix = k & 3;\n\n        if (k >= yhclose)\n        {\n            invaly = k < yhlimit || k >= yllimit;\n            j = k >> 2;\n\n            if (spix == 0)\n            {\n                maxxhx = 0;\n                minxmx = 0xfff;\n                allover = allunder = 1;\n                allinval = 1;\n            }\n\n            stickybit = ((xright >> 1) & 0x1fff) > 0;\n            xrsc = ((xright >> 13) & 0x1ffe) | stickybit;\n            curunder = ((xright & 0x8000000) || (xrsc < clipxhshift && !(xright & 0x4000000)));\n            xrsc = curunder ? clipxhshift : (((xright >> 13) & 0x3ffe) | stickybit);\n            curover = ((xrsc & 0x2000) || (xrsc & 0x1fff) >= clipxlshift);\n            xrsc = curover ? clipxlshift : xrsc;\n            wstate->span[j].majorx[spix] = xrsc & 0x1fff;\n            allover &= curover;\n            allunder &= curunder;\n\n            stickybit = ((xleft >> 1) & 0x1fff) > 0;\n            xlsc = ((xleft >> 13) & 0x1ffe) | stickybit;\n            curunder = ((xleft & 0x8000000) || (xlsc < clipxhshift && !(xleft & 0x4000000)));\n            xlsc = curunder ? clipxhshift : (((xleft >> 13) & 0x3ffe) | stickybit);\n            curover = ((xlsc & 0x2000) || (xlsc & 0x1fff) >= clipxlshift);\n            xlsc = curover ? clipxlshift : xlsc;\n            wstate->span[j].minorx[spix] = xlsc & 0x1fff;\n            allover &= curover;\n            allunder &= curunder;\n\n            curcross = ((xright ^ (1 << 27)) & (0x3fff << 14)) < ((xleft ^ (1 << 27)) & (0x3fff << 14));\n\n            invaly |= curcross;\n            wstate->span[j].invalyscan[spix] = invaly;\n            allinval &= invaly;\n\n            if (!invaly)\n            {\n                minxmx = (((xlsc >> 3) & 0xfff) < minxmx) ? (xlsc >> 3) & 0xfff : minxmx;\n                maxxhx = (((xrsc >> 3) & 0xfff) > maxxhx) ? (xrsc >> 3) & 0xfff : maxxhx;\n            }\n\n            if (spix == ldflag)\n            {\n                wstate->span[j].unscrx  = SIGN(xright >> 16, 12);\n                xfrac = (xright >> 8) & 0xff;\n                ADJUST_ATTR_PRIM();\n            }\n\n            if (spix == 3)\n            {\n                wstate->span[j].lx = minxmx;\n                wstate->span[j].rx = maxxhx;\n                wstate->span[j].validline  = !allinval && !allover && !allunder && (!wstate->scfield || (wstate->scfield && !(wstate->sckeepodd ^ (j & 1))));\n\n                if (wstate->span[j].validline && wstate->fb_size > PIXEL_SIZE_8BIT)\n                    if ((wstate->span[j].rx - wstate->span[j].lx) >= oldhb_diff)\n                        wstate->last_overwriting_scanline = j;\n\n                // skip line if not assigned to this worker\n                wstate->span[j].validline &= (!wstate->stride || j % wstate->stride == wstate->offset);\n            }\n\n        }\n\n        if (spix == 3)\n        {\n            ADDVALUES_PRIM();\n        }\n\n        xleft += xleft_inc;\n        xright += xright_inc;\n\n    }\n    }\n\n\n\n\n    switch(wstate->other_modes.cycle_type)\n    {\n        case CYCLE_TYPE_1:\n            switch (wstate->other_modes.f.textureuselevel0)\n            {\n                case 0: render_spans_1cycle_complete(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n                case 1: render_spans_1cycle_notexel1(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n                case 2: default: render_spans_1cycle_notex(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n            }\n            break;\n        case CYCLE_TYPE_2:\n            switch (wstate->other_modes.f.textureuselevel1)\n            {\n                case 0: render_spans_2cycle_complete(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n                case 1: render_spans_2cycle_notexelnext(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n                case 2: render_spans_2cycle_notexel1(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n                case 3: default: render_spans_2cycle_notex(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n            }\n            break;\n        case CYCLE_TYPE_COPY: render_spans_copy(wstate, yhlimit >> 2, yllimit >> 2, tilenum, flip); break;\n        case CYCLE_TYPE_FILL: render_spans_fill(wstate, yhlimit >> 2, yllimit >> 2, flip); break;\n        default: msg_error(\"cycle_type %d\", wstate->other_modes.cycle_type); break;\n    }\n\n\n}\n\nstatic void rasterizer_init(struct rdp_state* wstate)\n{\n    wstate->clip.xh = 0x2000;\n    wstate->clip.yh = 0x2000;\n}\n\nvoid rdp_tri_noshade(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, 8 * sizeof(int32_t));\n    memset(&ewdata[8], 0, 36 * sizeof(int32_t));\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_tri_noshade_z(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, 8 * sizeof(int32_t));\n    memset(&ewdata[8], 0, 32 * sizeof(int32_t));\n    memcpy(&ewdata[40], args + 8, 4 * sizeof(int32_t));\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_tri_tex(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, 8 * sizeof(int32_t));\n    memset(&ewdata[8], 0, 16 * sizeof(int32_t));\n    memcpy(&ewdata[24], args + 8, 16 * sizeof(int32_t));\n    memset(&ewdata[40], 0, 4 * sizeof(int32_t));\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_tri_tex_z(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, 8 * sizeof(int32_t));\n    memset(&ewdata[8], 0, 16 * sizeof(int32_t));\n    memcpy(&ewdata[24], args + 8, 16 * sizeof(int32_t));\n    memcpy(&ewdata[40], args + 24, 4 * sizeof(int32_t));\n\n\n\n\n\n\n    edgewalker_for_prims(wstate, ewdata);\n\n\n}\n\nvoid rdp_tri_shade(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, 24 * sizeof(int32_t));\n    memset(&ewdata[24], 0, 20 * sizeof(int32_t));\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_tri_shade_z(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, 24 * sizeof(int32_t));\n    memset(&ewdata[24], 0, 16 * sizeof(int32_t));\n    memcpy(&ewdata[40], args + 24, 4 * sizeof(int32_t));\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_tri_texshade(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, 40 * sizeof(int32_t));\n    memset(&ewdata[40], 0, 4 * sizeof(int32_t));\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_tri_texshade_z(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t ewdata[CMD_MAX_INTS];\n    memcpy(&ewdata[0], args, CMD_MAX_SIZE);\n\n\n\n\n\n    edgewalker_for_prims(wstate, ewdata);\n\n\n}\n\nvoid rdp_tex_rect(struct rdp_state* wstate, const uint32_t* args)\n{\n    uint32_t tilenum    = (args[1] >> 24) & 0x7;\n    uint32_t xl = (args[0] >> 12) & 0xfff;\n    uint32_t yl = (args[0] >>  0) & 0xfff;\n    uint32_t xh = (args[1] >> 12) & 0xfff;\n    uint32_t yh = (args[1] >>  0) & 0xfff;\n\n    int32_t s = (args[2] >> 16) & 0xffff;\n    int32_t t = (args[2] >>  0) & 0xffff;\n    int32_t dsdx = (args[3] >> 16) & 0xffff;\n    int32_t dtdy = (args[3] >>  0) & 0xffff;\n\n    dsdx = SIGN16(dsdx);\n    dtdy = SIGN16(dtdy);\n\n    if (wstate->other_modes.cycle_type == CYCLE_TYPE_FILL || wstate->other_modes.cycle_type == CYCLE_TYPE_COPY)\n        yl |= 3;\n\n    uint32_t xlint = (xl >> 2) & 0x3ff;\n    uint32_t xhint = (xh >> 2) & 0x3ff;\n\n    int32_t ewdata[CMD_MAX_INTS];\n    ewdata[0] = (0x24 << 24) | ((0x80 | tilenum) << 16) | yl;\n    ewdata[1] = (yl << 16) | yh;\n    ewdata[2] = (xlint << 16) | ((xl & 3) << 14);\n    ewdata[3] = 0;\n    ewdata[4] = (xhint << 16) | ((xh & 3) << 14);\n    ewdata[5] = 0;\n    ewdata[6] = (xlint << 16) | ((xl & 3) << 14);\n    ewdata[7] = 0;\n    memset(&ewdata[8], 0, 16 * sizeof(uint32_t));\n    ewdata[24] = (s << 16) | t;\n    ewdata[25] = 0;\n    ewdata[26] = ((dsdx >> 5) << 16);\n    ewdata[27] = 0;\n    ewdata[28] = 0;\n    ewdata[29] = 0;\n    ewdata[30] = ((dsdx & 0x1f) << 11) << 16;\n    ewdata[31] = 0;\n    ewdata[32] = (dtdy >> 5) & 0xffff;\n    ewdata[33] = 0;\n    ewdata[34] = (dtdy >> 5) & 0xffff;\n    ewdata[35] = 0;\n    ewdata[36] = (dtdy & 0x1f) << 11;\n    ewdata[37] = 0;\n    ewdata[38] = (dtdy & 0x1f) << 11;\n    ewdata[39] = 0;\n    memset(&ewdata[40], 0, 4 * sizeof(int32_t));\n\n\n\n    edgewalker_for_prims(wstate, ewdata);\n\n}\n\nvoid rdp_tex_rect_flip(struct rdp_state* wstate, const uint32_t* args)\n{\n    uint32_t tilenum    = (args[1] >> 24) & 0x7;\n    uint32_t xl = (args[0] >> 12) & 0xfff;\n    uint32_t yl = (args[0] >>  0) & 0xfff;\n    uint32_t xh = (args[1] >> 12) & 0xfff;\n    uint32_t yh = (args[1] >>  0) & 0xfff;\n\n    int32_t s = (args[2] >> 16) & 0xffff;\n    int32_t t = (args[2] >>  0) & 0xffff;\n    int32_t dsdx = (args[3] >> 16) & 0xffff;\n    int32_t dtdy = (args[3] >>  0) & 0xffff;\n\n    dsdx = SIGN16(dsdx);\n    dtdy = SIGN16(dtdy);\n\n    if (wstate->other_modes.cycle_type == CYCLE_TYPE_FILL || wstate->other_modes.cycle_type == CYCLE_TYPE_COPY)\n        yl |= 3;\n\n    uint32_t xlint = (xl >> 2) & 0x3ff;\n    uint32_t xhint = (xh >> 2) & 0x3ff;\n\n    int32_t ewdata[CMD_MAX_INTS];\n    ewdata[0] = (0x25 << 24) | ((0x80 | tilenum) << 16) | yl;\n    ewdata[1] = (yl << 16) | yh;\n    ewdata[2] = (xlint << 16) | ((xl & 3) << 14);\n    ewdata[3] = 0;\n    ewdata[4] = (xhint << 16) | ((xh & 3) << 14);\n    ewdata[5] = 0;\n    ewdata[6] = (xlint << 16) | ((xl & 3) << 14);\n    ewdata[7] = 0;\n    memset(&ewdata[8], 0, 16 * sizeof(int32_t));\n    ewdata[24] = (s << 16) | t;\n    ewdata[25] = 0;\n\n    ewdata[26] = (dtdy >> 5) & 0xffff;\n    ewdata[27] = 0;\n    ewdata[28] = 0;\n    ewdata[29] = 0;\n    ewdata[30] = ((dtdy & 0x1f) << 11);\n    ewdata[31] = 0;\n    ewdata[32] = (dsdx >> 5) << 16;\n    ewdata[33] = 0;\n    ewdata[34] = (dsdx >> 5) << 16;\n    ewdata[35] = 0;\n    ewdata[36] = (dsdx & 0x1f) << 27;\n    ewdata[37] = 0;\n    ewdata[38] = (dsdx & 0x1f) << 27;\n    ewdata[39] = 0;\n    memset(&ewdata[40], 0, 4 * sizeof(int32_t));\n\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_fill_rect(struct rdp_state* wstate, const uint32_t* args)\n{\n    uint32_t xl = (args[0] >> 12) & 0xfff;\n    uint32_t yl = (args[0] >>  0) & 0xfff;\n    uint32_t xh = (args[1] >> 12) & 0xfff;\n    uint32_t yh = (args[1] >>  0) & 0xfff;\n\n    if (wstate->other_modes.cycle_type == CYCLE_TYPE_FILL || wstate->other_modes.cycle_type == CYCLE_TYPE_COPY)\n        yl |= 3;\n\n    uint32_t xlint = (xl >> 2) & 0x3ff;\n    uint32_t xhint = (xh >> 2) & 0x3ff;\n\n    int32_t ewdata[CMD_MAX_INTS];\n    ewdata[0] = (0x3680 << 16) | yl;\n    ewdata[1] = (yl << 16) | yh;\n    ewdata[2] = (xlint << 16) | ((xl & 3) << 14);\n    ewdata[3] = 0;\n    ewdata[4] = (xhint << 16) | ((xh & 3) << 14);\n    ewdata[5] = 0;\n    ewdata[6] = (xlint << 16) | ((xl & 3) << 14);\n    ewdata[7] = 0;\n    memset(&ewdata[8], 0, 36 * sizeof(int32_t));\n\n    edgewalker_for_prims(wstate, ewdata);\n}\n\nvoid rdp_set_prim_depth(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->primitive_z = args[1] & (0x7fff << 16);\n\n\n    wstate->primitive_delta_z = (uint16_t)(args[1]);\n}\n\nvoid rdp_set_scissor(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->clip.xh = (args[0] >> 12) & 0xfff;\n    wstate->clip.yh = (args[0] >>  0) & 0xfff;\n    wstate->clip.xl = (args[1] >> 12) & 0xfff;\n    wstate->clip.yl = (args[1] >>  0) & 0xfff;\n\n    wstate->scfield = (args[1] >> 25) & 1;\n    wstate->sckeepodd = (args[1] >> 24) & 1;\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/rdram.c",
    "content": "#ifdef N64VIDEO_C\n\n//\n// rdram.c: RDRAM memory interface\n//\n\n#define RDRAM_MASK 0x00ffffff\n\n#define HB_CLEAN 4\n\n// macros used to interface with AL's code\n#define RREADADDR8(rdst, in) {(rdst) = rdram_read_idx8((in));}\n#define RREADIDX16(rdst, in) {(rdst) = rdram_read_idx16((in));}\n#define RREADIDX32(rdst, in) {(rdst) = rdram_read_idx32((in));}\n\n#define RWRITEADDR8(in, val) rdram_write_idx8((in), (val))\n#define RWRITEIDX16(in, val) rdram_write_idx16((in), (val))\n#define RWRITEIDX32(in, val) rdram_write_idx32((in), (val))\n\n#define PAIRREAD16(rdst, hdst, in) rdram_read_pair16(&rdst, &hdst, (in))\n\n// pointer indexing limits for aliasing RDRAM reads and writes\nstatic uint32_t idxlim8;\nstatic uint32_t idxlim16;\nstatic uint32_t idxlim32;\n\nstatic uint32_t* rdram32;\nstatic uint16_t* rdram16;\nstatic uint8_t* rdram8;\nstatic uint8_t rdram_hidden[RDRAM_MAX_SIZE / 2];\nstatic uint8_t rdram_hidden_old[8];\n\nstatic void rdram_init(void)\n{\n    idxlim8 = config.gfx.rdram_size - 1;\n    idxlim16 = (idxlim8 >> 1) & 0xffffffu;\n    idxlim32 = (idxlim8 >> 2) & 0xffffffu;\n\n    rdram32 = (uint32_t*)config.gfx.rdram;\n    rdram16 = (uint16_t*)config.gfx.rdram;\n    rdram8 = config.gfx.rdram;\n\n    memset(rdram_hidden, HB_CLEAN, sizeof(rdram_hidden));\n    memset(&rdram_hidden_old, 0, sizeof(rdram_hidden_old));\n}\n\nstatic STRICTINLINE bool rdram_valid_idx8(uint32_t in)\n{\n    return in <= idxlim8;\n}\n\nstatic STRICTINLINE bool rdram_valid_idx16(uint32_t in)\n{\n    return in <= idxlim16;\n}\n\nstatic STRICTINLINE bool rdram_valid_idx32(uint32_t in)\n{\n    return in <= idxlim32;\n}\n\nstatic STRICTINLINE uint8_t rdram_read_idx8(uint32_t in)\n{\n    in &= RDRAM_MASK;\n    return rdram_valid_idx8(in) ? rdram8[in ^ BYTE_ADDR_XOR] : 0;\n}\n\nstatic STRICTINLINE uint8_t rdram_read_idx8_fast(uint32_t in)\n{\n    return rdram8[in ^ BYTE_ADDR_XOR];\n}\n\nstatic STRICTINLINE uint16_t rdram_read_idx16(uint32_t in)\n{\n    in &= RDRAM_MASK >> 1;\n    return rdram_valid_idx16(in) ? rdram16[in ^ WORD_ADDR_XOR] : 0;\n}\n\nstatic STRICTINLINE uint16_t rdram_read_idx16_fast(uint32_t in)\n{\n    return rdram16[in ^ WORD_ADDR_XOR];\n}\n\nstatic STRICTINLINE uint32_t rdram_read_idx32(uint32_t in)\n{\n    in &= RDRAM_MASK >> 2;\n    return rdram_valid_idx32(in) ? rdram32[in] : 0;\n}\n\nstatic STRICTINLINE uint32_t rdram_read_idx32_fast(uint32_t in)\n{\n    return rdram32[in];\n}\n\nstatic STRICTINLINE void rdram_write_idx8(uint32_t in, uint8_t val)\n{\n    in &= RDRAM_MASK;\n    if (rdram_valid_idx8(in)) {\n        rdram8[in ^ BYTE_ADDR_XOR] = val;\n    }\n}\n\nstatic STRICTINLINE void rdram_write_idx16(uint32_t in, uint16_t val)\n{\n    in &= RDRAM_MASK >> 1;\n    if (rdram_valid_idx16(in)) {\n        rdram16[in ^ WORD_ADDR_XOR] = val;\n    }\n}\n\nstatic STRICTINLINE void rdram_write_idx32(uint32_t in, uint32_t val)\n{\n    in &= RDRAM_MASK >> 2;\n    if (rdram_valid_idx32(in)) {\n        rdram32[in] = val;\n    }\n}\n\nstatic STRICTINLINE void rdram_read_pair16(uint16_t* rdst, uint8_t* hdst, uint32_t in)\n{\n    in &= RDRAM_MASK >> 1;\n    if (rdram_valid_idx16(in)) {\n        *rdst = rdram16[in ^ WORD_ADDR_XOR];\n        *hdst = rdram_hidden[in];\n        if (*hdst & HB_CLEAN) {\n            *hdst = (*rdst & 1) ? 3 : 0;\n        }\n    } else {\n        *rdst = *hdst = 0;\n    }\n}\n\nstatic STRICTINLINE void rdram_write_pair8(uint32_t in, uint8_t rval, int flip, int* delayedhbwidx)\n{\n    in &= RDRAM_MASK;\n    if (!flip) {\n        if (rdram_valid_idx8(in)) {\n            int hdst8 = rdram_hidden[in >> 1];\n\n            if (!(in & 1)) {\n                if (hdst8 & HB_CLEAN) {\n                    rdram_hidden[in >> 1] = (rdram16[(in >> 1) ^ WORD_ADDR_XOR] & 1) != 0;\n                } else {\n                    rdram_hidden[in >> 1] &= ~2;\n                }\n\n                rdram_hidden[in >> 1] |= rdram_hidden_old[(in >> 1) & 7] & 2;\n\n            } else {\n                if (hdst8 & HB_CLEAN) {\n                    rdram_hidden[in >> 1] = (rdram16[(in >> 1) ^ WORD_ADDR_XOR] & 1) ? 2 : 0;\n                } else {\n                    rdram_hidden[in >> 1] &= ~1;\n                }\n\n                rdram_hidden[in >> 1] |= rval & 1;\n            }\n            rdram8[in ^ BYTE_ADDR_XOR] = rval;\n        }\n\n        if (in & 1) {\n            rdram_hidden_old[(in >> 1) & 7] = (rval & 1) ? 3 : 0;\n\n        }\n    } else {\n        if (*delayedhbwidx >= 0 && (uint32_t)*delayedhbwidx < in) {\n            if (rdram_valid_idx8((uint32_t)*delayedhbwidx)) {\n\n                int oldhbidx = *delayedhbwidx >> 1;\n\n                rdram_hidden[oldhbidx] &= ~2;\n                rdram_hidden[oldhbidx] |= rdram_hidden_old[oldhbidx & 7] & 2;\n            }\n\n            *delayedhbwidx = -1;\n        }\n\n        if (in & 1) {\n            if (rdram_valid_idx8(in)) {\n                if (*delayedhbwidx >= 0) {\n                    rdram_hidden[in >> 1] = (rval & 1) ? 3 : 0;\n                } else {\n                    int hdst8 = rdram_hidden[in >> 1];\n                    if (hdst8 & HB_CLEAN) {\n                        rdram_hidden[in >> 1] = (rdram16[(in >> 1) ^ WORD_ADDR_XOR] & 1) ? 2 : 0;\n                    } else {\n                        rdram_hidden[in >> 1] &= ~1;\n                    }\n\n                    rdram_hidden[in >> 1] |= rval & 1;\n                }\n\n                rdram8[in ^ BYTE_ADDR_XOR] = rval;\n            }\n\n            rdram_hidden_old[(in >> 1) & 7] = (rval & 1) ? 3 : 0;\n            *delayedhbwidx = -1;\n        } else {\n            if (rdram_valid_idx8(in)) {\n                int hdst8 = rdram_hidden[in >> 1];\n                if (hdst8 & HB_CLEAN) {\n                    rdram_hidden[in >> 1] = (rdram16[(in >> 1) ^ WORD_ADDR_XOR] & 1) ? 3 : 0;\n                }\n\n                rdram8[in ^ BYTE_ADDR_XOR] = rval;\n            }\n\n            *delayedhbwidx = in + 1;\n        }\n    }\n}\n\nstatic STRICTINLINE void rdram_write_pair16(uint32_t in, uint16_t rval, uint8_t hval, int iscolor)\n{\n    in &= RDRAM_MASK >> 1;\n    if (rdram_valid_idx16(in)) {\n        rdram16[in ^ WORD_ADDR_XOR] = rval;\n        rdram_hidden[in] = hval;\n    }\n\n    if (iscolor) {\n        rdram_hidden_old[in & 7] = hval;\n    }\n}\n\nstatic STRICTINLINE void rdram_write_pair32(uint32_t in, uint32_t rval, uint8_t hval0, uint8_t hval1)\n{\n    in &= RDRAM_MASK >> 2;\n    if (rdram_valid_idx32(in)) {\n        rdram32[in] = rval;\n        rdram_hidden[in << 1] = hval0;\n        rdram_hidden[(in << 1) + 1] = hval1;\n    }\n\n    rdram_hidden_old[(in << 1) & 7] = hval0;\n    rdram_hidden_old[((in << 1) + 1) & 7] = hval1;\n}\n\nstatic void rdram_complete_delayed_hbwrites(int delayedhbwidx)\n{\n    if (rdram_valid_idx8((uint32_t)delayedhbwidx)) {\n        int oldhbidx = delayedhbwidx >> 1;\n\n        rdram_hidden[oldhbidx] &= ~2;\n        rdram_hidden[oldhbidx] |= rdram_hidden_old[oldhbidx & 7] & 2;\n    }\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/tcoord.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic const int32_t norm_point_table[64] = {\n    0x4000, 0x3f04, 0x3e10, 0x3d22, 0x3c3c, 0x3b5d, 0x3a83, 0x39b1,\n    0x38e4, 0x381c, 0x375a, 0x369d, 0x35e5, 0x3532, 0x3483, 0x33d9,\n    0x3333, 0x3291, 0x31f4, 0x3159, 0x30c3, 0x3030, 0x2fa1, 0x2f15,\n    0x2e8c, 0x2e06, 0x2d83, 0x2d03, 0x2c86, 0x2c0b, 0x2b93, 0x2b1e,\n    0x2aab, 0x2a3a, 0x29cc, 0x2960, 0x28f6, 0x288e, 0x2828, 0x27c4,\n    0x2762, 0x2702, 0x26a4, 0x2648, 0x25ed, 0x2594, 0x253d, 0x24e7,\n    0x2492, 0x243f, 0x23ee, 0x239e, 0x234f, 0x2302, 0x22b6, 0x226c,\n    0x2222, 0x21da, 0x2193, 0x214d, 0x2108, 0x20c5, 0x2082, 0x2041\n};\n\nstatic const int32_t norm_slope_table[64] = {\n    0xf03, 0xf0b, 0xf11, 0xf19, 0xf20, 0xf25, 0xf2d, 0xf32,\n    0xf37, 0xf3d, 0xf42, 0xf47, 0xf4c, 0xf50, 0xf55, 0xf59,\n    0xf5d, 0xf62, 0xf64, 0xf69, 0xf6c, 0xf70, 0xf73, 0xf76,\n    0xf79, 0xf7c, 0xf7f, 0xf82, 0xf84, 0xf87, 0xf8a, 0xf8c,\n    0xf8e, 0xf91, 0xf93, 0xf95, 0xf97, 0xf99, 0xf9b, 0xf9d,\n    0xf9f, 0xfa1, 0xfa3, 0xfa4, 0xfa6, 0xfa8, 0xfa9, 0xfaa,\n    0xfac, 0xfae, 0xfaf, 0xfb0, 0xfb2, 0xfb3, 0xfb5, 0xfb5,\n    0xfb7, 0xfb8, 0xfb9, 0xfba, 0xfbc, 0xfbc, 0xfbe, 0xfbe\n};\n\nstatic void tcdiv_persp(int32_t ss, int32_t st, int32_t sw, int32_t* sss, int32_t* sst);\nstatic void tcdiv_nopersp(int32_t ss, int32_t st, int32_t sw, int32_t* sss, int32_t* sst);\n\nstatic void (*tcdiv_func[2])(int32_t, int32_t, int32_t, int32_t*, int32_t*) =\n{\n    tcdiv_nopersp, tcdiv_persp\n};\n\nstatic int32_t maskbits_table[16];\nstatic int32_t log2table[256];\nstatic int32_t tcdiv_table[0x8000];\n\nstatic STRICTINLINE void tcmask_copy(struct tile* tile, int32_t* S, int32_t* S1, int32_t* S2, int32_t* S3, int32_t* T)\n{\n    int32_t wrap;\n    int32_t maskbits_s;\n    int32_t swrapthreshold;\n\n    if (tile->mask_s)\n    {\n        if (tile->ms)\n        {\n            swrapthreshold = tile->f.masksclamped;\n\n            wrap = (*S >> swrapthreshold) & 1;\n            *S ^= (-wrap);\n\n            wrap = (*S1 >> swrapthreshold) & 1;\n            *S1 ^= (-wrap);\n\n            wrap = (*S2 >> swrapthreshold) & 1;\n            *S2 ^= (-wrap);\n\n            wrap = (*S3 >> swrapthreshold) & 1;\n            *S3 ^= (-wrap);\n        }\n\n        maskbits_s = maskbits_table[tile->mask_s];\n        *S &= maskbits_s;\n        *S1 &= maskbits_s;\n        *S2 &= maskbits_s;\n        *S3 &= maskbits_s;\n    }\n\n    if (tile->mask_t)\n    {\n        if (tile->mt)\n        {\n            wrap = *T >> tile->f.masktclamped;\n            wrap &= 1;\n            *T ^= (-wrap);\n        }\n\n        *T &= maskbits_table[tile->mask_t];\n    }\n}\n\n\nstatic STRICTINLINE void tcshift_cycle(struct tile* tile, int32_t* S, int32_t* T, int32_t* maxs, int32_t* maxt)\n{\n\n\n\n    int32_t coord = *S;\n    int32_t shifter = tile->shift_s;\n\n\n    if (shifter < 11)\n    {\n        coord = SIGN16(coord);\n        coord >>= shifter;\n    }\n    else\n    {\n        coord <<= (16 - shifter);\n        coord = SIGN16(coord);\n    }\n    *S = coord;\n\n\n\n\n    *maxs = ((coord >> 3) >= tile->sh);\n\n\n\n    coord = *T;\n    shifter = tile->shift_t;\n\n    if (shifter < 11)\n    {\n        coord = SIGN16(coord);\n        coord >>= shifter;\n    }\n    else\n    {\n        coord <<= (16 - shifter);\n        coord = SIGN16(coord);\n    }\n    *T = coord;\n    *maxt = ((coord >> 3) >= tile->th);\n}\n\nstatic STRICTINLINE void tcclamp_cycle(struct tile* tile, int32_t* S, int32_t* T, int32_t* SFRAC, int32_t* TFRAC, int32_t maxs, int32_t maxt)\n{\n\n\n\n    int32_t locs = *S, loct = *T;\n    if (tile->f.clampens)\n    {\n\n        if (maxs)\n        {\n            *S = tile->f.clampdiffs;\n            *SFRAC = 0;\n        }\n        else if (!(locs & 0x10000))\n            *S = locs >> 5;\n        else\n        {\n            *S = 0;\n            *SFRAC = 0;\n        }\n    }\n    else\n        *S = (locs >> 5);\n\n    if (tile->f.clampent)\n    {\n        if (maxt)\n        {\n            *T = tile->f.clampdifft;\n            *TFRAC = 0;\n        }\n        else if (!(loct & 0x10000))\n            *T = loct >> 5;\n        else\n        {\n            *T = 0;\n            *TFRAC = 0;\n        }\n    }\n    else\n        *T = (loct >> 5);\n}\n\n\nstatic STRICTINLINE void tcclamp_cycle_light(struct tile* tile, int32_t* S, int32_t* T, int32_t maxs, int32_t maxt)\n{\n    int32_t locs = *S, loct = *T;\n    if (tile->f.clampens)\n    {\n        if (maxs)\n            *S = tile->f.clampdiffs;\n        else if (!(locs & 0x10000))\n            *S = locs >> 5;\n        else\n            *S = 0;\n    }\n    else\n        *S = (locs >> 5);\n\n    if (tile->f.clampent)\n    {\n        if (maxt)\n            *T = tile->f.clampdifft;\n        else if (!(loct & 0x10000))\n            *T = loct >> 5;\n        else\n            *T = 0;\n    }\n    else\n        *T = (loct >> 5);\n}\n\nstatic STRICTINLINE void tcshift_copy(struct tile* tile, int32_t* S, int32_t* T)\n{\n    int32_t coord = *S;\n    int32_t shifter = tile->shift_s;\n\n    if (shifter < 11)\n    {\n        coord = SIGN16(coord);\n        coord >>= shifter;\n    }\n    else\n    {\n        coord <<= (16 - shifter);\n        coord = SIGN16(coord);\n    }\n    *S = coord;\n\n    coord = *T;\n    shifter = tile->shift_t;\n\n    if (shifter < 11)\n    {\n        coord = SIGN16(coord);\n        coord >>= shifter;\n    }\n    else\n    {\n        coord <<= (16 - shifter);\n        coord = SIGN16(coord);\n    }\n    *T = coord;\n\n}\n\n\nstatic STRICTINLINE void tclod_4x17_to_15(int32_t scurr, int32_t snext, int32_t tcurr, int32_t tnext, int32_t previous, int32_t* lod)\n{\n\n\n\n    int dels = SIGN(snext, 17) - SIGN(scurr, 17);\n    if (dels & 0x20000)\n        dels = ~dels & 0x1ffff;\n    int delt = SIGN(tnext, 17) - SIGN(tcurr, 17);\n    if(delt & 0x20000)\n        delt = ~delt & 0x1ffff;\n\n\n    dels = (dels > delt) ? dels : delt;\n    dels = (previous > dels) ? previous : dels;\n    *lod = dels & 0x7fff;\n    if (dels & 0x1c000)\n        *lod |= 0x4000;\n}\n\nstatic STRICTINLINE void tclod_tcclamp(int32_t* sss, int32_t* sst)\n{\n    int32_t tempanded, temps = *sss, tempt = *sst;\n\n\n\n\n\n    if (!(temps & 0x40000))\n    {\n        if (!(temps & 0x20000))\n        {\n            tempanded = temps & 0x18000;\n            if (tempanded != 0x8000)\n            {\n                if (tempanded != 0x10000)\n                    *sss &= 0xffff;\n                else\n                    *sss = 0x8000;\n            }\n            else\n                *sss = 0x7fff;\n        }\n        else\n            *sss = 0x8000;\n    }\n    else\n        *sss = 0x7fff;\n\n    if (!(tempt & 0x40000))\n    {\n        if (!(tempt & 0x20000))\n        {\n            tempanded = tempt & 0x18000;\n            if (tempanded != 0x8000)\n            {\n                if (tempanded != 0x10000)\n                    *sst &= 0xffff;\n                else\n                    *sst = 0x8000;\n            }\n            else\n                *sst = 0x7fff;\n        }\n        else\n            *sst = 0x8000;\n    }\n    else\n        *sst = 0x7fff;\n\n}\n\n\nstatic STRICTINLINE void lodfrac_lodtile_signals(struct rdp_state* wstate, int lodclamp, int32_t lod, uint32_t* l_tile, uint32_t* magnify, uint32_t* distant, int32_t* lfdst)\n{\n    uint32_t ltil, dis, mag;\n    int32_t lf;\n\n\n    if ((lod & 0x4000) || lodclamp)\n    {\n\n        mag = 0;\n        ltil = 0;\n        dis = 1;\n        lf = 0xff;\n    }\n    else if (lod < wstate->min_level)\n    {\n\n\n        mag = 1;\n        ltil = 0;\n        dis = wstate->max_level == 0;\n\n        if(!wstate->other_modes.sharpen_tex_en && !wstate->other_modes.detail_tex_en)\n        {\n            if (dis)\n                lf = 0xff;\n            else\n                lf = 0;\n        }\n        else\n        {\n            lf = wstate->min_level << 3;\n            if (wstate->other_modes.sharpen_tex_en)\n                lf |= 0x100;\n        }\n    }\n    else if (lod < 32)\n    {\n        mag = 1;\n        ltil = 0;\n        dis = wstate->max_level == 0;\n\n        if(!wstate->other_modes.sharpen_tex_en && !wstate->other_modes.detail_tex_en)\n        {\n            if (dis)\n                lf = 0xff;\n            else\n                lf = 0;\n        }\n        else\n        {\n            lf = lod << 3;\n            if (wstate->other_modes.sharpen_tex_en)\n                lf |= 0x100;\n        }\n    }\n    else\n    {\n        mag = 0;\n        ltil =  log2table[(lod >> 5) & 0xff];\n\n        if (wstate->max_level)\n            dis = ((lod & 0x6000) || (ltil >= wstate->max_level)) != 0;\n        else\n            dis = 1;\n\n\n        if(!wstate->other_modes.sharpen_tex_en && !wstate->other_modes.detail_tex_en && dis)\n            lf = 0xff;\n        else\n            lf = ((lod << 3) >> ltil) & 0xff;\n\n\n\n\n\n\n    }\n\n    *distant = dis;\n    *l_tile = ltil;\n    *magnify = mag;\n    *lfdst = lf;\n}\n\nstatic STRICTINLINE void tclod_2cycle(struct rdp_state* wstate, int32_t* sss, int32_t* sst, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t prim_tile, int32_t* t1, int32_t* t2, int32_t* lf)\n{\n\n\n\n\n\n\n\n\n    int nextys, nextyt, nextysw, nexts, nextt, nextsw;\n    int lodclamp = 0;\n    int32_t lod = 0;\n    uint32_t l_tile;\n    uint32_t magnify = 0;\n    uint32_t distant = 0;\n    int inits = *sss, initt = *sst;\n\n    tclod_tcclamp(sss, sst);\n\n    if (wstate->other_modes.f.dolod)\n    {\n\n        nextsw = (w + dwinc) >> 16;\n        nexts = (s + dsinc) >> 16;\n        nextt = (t + dtinc) >> 16;\n        nextys = (s + wstate->spans_dsdy) >> 16;\n        nextyt = (t + wstate->spans_dtdy) >> 16;\n        nextysw = (w + wstate->spans_dwdy) >> 16;\n\n        wstate->tcdiv_ptr(nexts, nextt, nextsw, &nexts, &nextt);\n        wstate->tcdiv_ptr(nextys, nextyt, nextysw, &nextys, &nextyt);\n\n        lodclamp = (initt & 0x60000) || (nextt & 0x60000) || (inits & 0x60000) || (nexts & 0x60000) || (nextys & 0x60000) || (nextyt & 0x60000);\n\n\n\n\n        if (!lodclamp)\n        {\n            tclod_4x17_to_15(inits, nexts, initt, nextt, 0, &lod);\n            tclod_4x17_to_15(inits, nextys, initt, nextyt, lod, &lod);\n        }\n\n        lodfrac_lodtile_signals(wstate, lodclamp, lod, &l_tile, &magnify, &distant, lf);\n\n\n        if (wstate->other_modes.tex_lod_en)\n        {\n            if (distant)\n                l_tile = wstate->max_level;\n            if (!wstate->other_modes.detail_tex_en)\n            {\n                *t1 = (prim_tile + l_tile) & 7;\n                if (!(distant || (!wstate->other_modes.sharpen_tex_en && magnify)))\n                    *t2 = (*t1 + 1) & 7;\n                else\n                    *t2 = *t1;\n            }\n            else\n            {\n                if (!magnify)\n                    *t1 = (prim_tile + l_tile + 1);\n                else\n                    *t1 = (prim_tile + l_tile);\n                *t1 &= 7;\n                if (!distant && !magnify)\n                    *t2 = (prim_tile + l_tile + 2) & 7;\n                else\n                    *t2 = (prim_tile + l_tile + 1) & 7;\n            }\n\n\n        }\n    }\n}\n\nstatic STRICTINLINE void tclod_2cycle_next(struct rdp_state* wstate, int32_t* sss, int32_t* sst, int32_t* sss2, int32_t* sst2, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t prim_tile, int32_t* t1, int32_t* t2, int32_t* lf, int scanline)\n{\n    UNUSED(s);\n    UNUSED(t);\n    UNUSED(w);\n\n    int nextys, nextyt, nextysw;\n    int nexts, nextt, nextsw;\n    int lodclamp = 0;\n    int32_t lod = 0;\n    uint32_t l_tile;\n    uint32_t magnify = 0;\n    uint32_t distant = 0;\n\n    int inits2 = *sss2, initt2 = *sst2;\n    int32_t dummy_lf;\n\n    tclod_tcclamp(sss, sst);\n    tclod_tcclamp(sss2, sst2);\n\n    if (wstate->other_modes.f.dolod)\n    {\n        int nextscan = scanline + 1;\n\n        nextys = (wstate->span[nextscan].s + wstate->spans_dsdy) >> 16;\n        nextyt = (wstate->span[nextscan].t + wstate->spans_dtdy) >> 16;\n        nextysw = (wstate->span[nextscan].w + wstate->spans_dwdy) >> 16;\n\n        wstate->tcdiv_ptr(nextys, nextyt, nextysw, &nextys, &nextyt);\n\n        lodclamp = ((initt2 & 0x60000) || (inits2 & 0x60000) || (nextys & 0x60000) || (nextyt & 0x60000));\n\n\n        if (!lodclamp)\n            tclod_4x17_to_15(inits2, nextys, initt2, nextyt, 0, &lod);\n\n        lodfrac_lodtile_signals(wstate, lodclamp, lod, &l_tile, &magnify, &distant, lf);\n\n        if (wstate->other_modes.tex_lod_en)\n        {\n            if (distant)\n                l_tile = wstate->max_level;\n            if (!wstate->other_modes.detail_tex_en)\n                *t1 = (prim_tile + l_tile) & 7;\n            else\n            {\n                if (!magnify)\n                    *t1 = (prim_tile + l_tile + 1);\n                else\n                    *t1 = (prim_tile + l_tile);\n                *t1 &= 7;\n            }\n\n\n\n            nexts = (wstate->span[nextscan].s + dsinc) >> 16;\n            nextt = (wstate->span[nextscan].t + dtinc) >> 16;\n            nextsw = (wstate->span[nextscan].w + dwinc) >> 16;\n\n            wstate->tcdiv_ptr(nexts, nextt, nextsw, &nexts, &nextt);\n\n            lodclamp = (lodclamp || (nextt & 0x60000) || (nexts & 0x60000));\n\n            if (!lodclamp)\n                tclod_4x17_to_15(inits2, nexts, initt2, nextt, lod, &lod);\n\n\n            lodfrac_lodtile_signals(wstate, lodclamp, lod, &l_tile, &magnify, &distant, &dummy_lf);\n\n            if (distant)\n                l_tile = wstate->max_level;\n            if (!wstate->other_modes.detail_tex_en)\n                *t2 = (prim_tile + l_tile) & 7;\n            else\n            {\n                if (!magnify)\n                    *t2 = (prim_tile + l_tile + 1);\n                else\n                    *t2 = (prim_tile + l_tile);\n                *t2 &= 7;\n            }\n        }\n\n    }\n}\n\n\nstatic STRICTINLINE void tclod_2cycle_notexel1(struct rdp_state* wstate, int32_t* sss, int32_t* sst, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t prim_tile, int32_t* t1)\n{\n    int nextys, nextyt, nextysw, nexts, nextt, nextsw;\n    int lodclamp = 0;\n    int32_t lod = 0;\n    uint32_t l_tile;\n    uint32_t magnify = 0;\n    uint32_t distant = 0;\n    int inits = *sss, initt = *sst;\n\n    tclod_tcclamp(sss, sst);\n\n    if (wstate->other_modes.f.dolod)\n    {\n        nextsw = (w + dwinc) >> 16;\n        nexts = (s + dsinc) >> 16;\n        nextt = (t + dtinc) >> 16;\n        nextys = (s + wstate->spans_dsdy) >> 16;\n        nextyt = (t + wstate->spans_dtdy) >> 16;\n        nextysw = (w + wstate->spans_dwdy) >> 16;\n\n        wstate->tcdiv_ptr(nexts, nextt, nextsw, &nexts, &nextt);\n        wstate->tcdiv_ptr(nextys, nextyt, nextysw, &nextys, &nextyt);\n\n        lodclamp = (initt & 0x60000) || (nextt & 0x60000) || (inits & 0x60000) || (nexts & 0x60000) || (nextys & 0x60000) || (nextyt & 0x60000);\n\n        if (!lodclamp)\n        {\n            tclod_4x17_to_15(inits, nexts, initt, nextt, 0, &lod);\n            tclod_4x17_to_15(inits, nextys, initt, nextyt, lod, &lod);\n        }\n\n        lodfrac_lodtile_signals(wstate, lodclamp, lod, &l_tile, &magnify, &distant, &wstate->lod_frac);\n\n        if (wstate->other_modes.tex_lod_en)\n        {\n            if (distant)\n                l_tile = wstate->max_level;\n            if (!wstate->other_modes.detail_tex_en || magnify)\n                *t1 = (prim_tile + l_tile) & 7;\n            else\n                *t1 = (prim_tile + l_tile + 1) & 7;\n        }\n\n    }\n}\n\nstatic STRICTINLINE void tclod_1cycle_current(struct rdp_state* wstate, int32_t* sss, int32_t* sst, int32_t nexts, int32_t nextt, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t scanline, int32_t prim_tile, int32_t* t1, struct spansigs* sigs)\n{\n\n\n\n\n\n\n\n\n\n    int fars, fart, farsw;\n    int lodclamp = 0;\n    int32_t lod = 0;\n    uint32_t l_tile = 0, magnify = 0, distant = 0;\n\n    tclod_tcclamp(sss, sst);\n\n    if (wstate->other_modes.f.dolod)\n    {\n        int nextscan = scanline + 1;\n\n\n        if (wstate->span[nextscan].validline)\n        {\n            if (!sigs->endspan || !sigs->longspan)\n            {\n                if (!(sigs->preendspan && sigs->longspan) && !(sigs->endspan && sigs->midspan))\n                {\n                    farsw = (w + (dwinc << 1)) >> 16;\n                    fars = (s + (dsinc << 1)) >> 16;\n                    fart = (t + (dtinc << 1)) >> 16;\n                }\n                else\n                {\n                    farsw = (w - dwinc) >> 16;\n                    fars = (s - dsinc) >> 16;\n                    fart = (t - dtinc) >> 16;\n                }\n            }\n            else\n            {\n                fart = (wstate->span[nextscan].t + dtinc) >> 16;\n                fars = (wstate->span[nextscan].s + dsinc) >> 16;\n                farsw = (wstate->span[nextscan].w + dwinc) >> 16;\n            }\n        }\n        else\n        {\n            farsw = (w + (dwinc << 1)) >> 16;\n            fars = (s + (dsinc << 1)) >> 16;\n            fart = (t + (dtinc << 1)) >> 16;\n        }\n\n        wstate->tcdiv_ptr(fars, fart, farsw, &fars, &fart);\n\n        lodclamp = (fart & 0x60000) || (nextt & 0x60000) || (fars & 0x60000) || (nexts & 0x60000);\n\n\n\n\n        if (!lodclamp)\n            tclod_4x17_to_15(nexts, fars, nextt, fart, 0, &lod);\n\n        lodfrac_lodtile_signals(wstate, lodclamp, lod, &l_tile, &magnify, &distant, &wstate->lod_frac);\n\n        if (wstate->other_modes.tex_lod_en)\n        {\n            if (distant)\n                l_tile = wstate->max_level;\n\n\n\n            if (!wstate->other_modes.detail_tex_en || magnify)\n                *t1 = (prim_tile + l_tile) & 7;\n            else\n                *t1 = (prim_tile + l_tile + 1) & 7;\n        }\n    }\n}\n\n\n\nstatic STRICTINLINE void tclod_1cycle_current_simple(struct rdp_state* wstate, int32_t* sss, int32_t* sst, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t scanline, int32_t prim_tile, int32_t* t1, struct spansigs* sigs)\n{\n    int fars, fart, farsw, nexts, nextt, nextsw;\n    int lodclamp = 0;\n    int32_t lod = 0;\n    uint32_t l_tile = 0, magnify = 0, distant = 0;\n\n    tclod_tcclamp(sss, sst);\n\n    if (wstate->other_modes.f.dolod)\n    {\n\n        int nextscan = scanline + 1;\n        if (wstate->span[nextscan].validline)\n        {\n            if (!sigs->endspan || !sigs->longspan)\n            {\n                nextsw = (w + dwinc) >> 16;\n                nexts = (s + dsinc) >> 16;\n                nextt = (t + dtinc) >> 16;\n\n                if (!(sigs->preendspan && sigs->longspan) && !(sigs->endspan && sigs->midspan))\n                {\n                    farsw = (w + (dwinc << 1)) >> 16;\n                    fars = (s + (dsinc << 1)) >> 16;\n                    fart = (t + (dtinc << 1)) >> 16;\n                }\n                else\n                {\n                    farsw = (w - dwinc) >> 16;\n                    fars = (s - dsinc) >> 16;\n                    fart = (t - dtinc) >> 16;\n                }\n            }\n            else\n            {\n                nextt = wstate->span[nextscan].t >> 16;\n                nexts = wstate->span[nextscan].s >> 16;\n                nextsw = wstate->span[nextscan].w >> 16;\n                fart = (wstate->span[nextscan].t + dtinc) >> 16;\n                fars = (wstate->span[nextscan].s + dsinc) >> 16;\n                farsw = (wstate->span[nextscan].w + dwinc) >> 16;\n            }\n        }\n        else\n        {\n            nextsw = (w + dwinc) >> 16;\n            nexts = (s + dsinc) >> 16;\n            nextt = (t + dtinc) >> 16;\n            farsw = (w + (dwinc << 1)) >> 16;\n            fars = (s + (dsinc << 1)) >> 16;\n            fart = (t + (dtinc << 1)) >> 16;\n        }\n\n        wstate->tcdiv_ptr(nexts, nextt, nextsw, &nexts, &nextt);\n        wstate->tcdiv_ptr(fars, fart, farsw, &fars, &fart);\n\n        lodclamp = (fart & 0x60000) || (nextt & 0x60000) || (fars & 0x60000) || (nexts & 0x60000);\n\n        if (!lodclamp)\n            tclod_4x17_to_15(nexts, fars, nextt, fart, 0, &lod);\n\n        lodfrac_lodtile_signals(wstate, lodclamp, lod, &l_tile, &magnify, &distant, &wstate->lod_frac);\n\n        if (wstate->other_modes.tex_lod_en)\n        {\n            if (distant)\n                l_tile = wstate->max_level;\n            if (!wstate->other_modes.detail_tex_en || magnify)\n                *t1 = (prim_tile + l_tile) & 7;\n            else\n                *t1 = (prim_tile + l_tile + 1) & 7;\n        }\n    }\n}\n\nstatic STRICTINLINE void tclod_1cycle_next(struct rdp_state* wstate, int32_t* sss, int32_t* sst, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t scanline, int32_t prim_tile, int32_t* t1, struct spansigs* sigs, int32_t* prelodfrac)\n{\n    int nexts, nextt, nextsw, fars, fart, farsw;\n    int lodclamp = 0;\n    int32_t lod = 0;\n    uint32_t l_tile = 0, magnify = 0, distant = 0;\n\n    tclod_tcclamp(sss, sst);\n\n    if (wstate->other_modes.f.dolod)\n    {\n\n        int nextscan = scanline + 1;\n\n        if (wstate->span[nextscan].validline)\n        {\n\n            if (!sigs->nextspan)\n            {\n                if (!sigs->endspan || !sigs->longspan)\n                {\n                    nextsw = (w + dwinc) >> 16;\n                    nexts = (s + dsinc) >> 16;\n                    nextt = (t + dtinc) >> 16;\n\n                    if (!(sigs->preendspan && sigs->longspan) && !(sigs->endspan && sigs->midspan))\n                    {\n                        farsw = (w + (dwinc << 1)) >> 16;\n                        fars = (s + (dsinc << 1)) >> 16;\n                        fart = (t + (dtinc << 1)) >> 16;\n                    }\n                    else\n                    {\n                        farsw = (w - dwinc) >> 16;\n                        fars = (s - dsinc) >> 16;\n                        fart = (t - dtinc) >> 16;\n                    }\n                }\n                else\n                {\n                    nextt = wstate->span[nextscan].t;\n                    nexts = wstate->span[nextscan].s;\n                    nextsw = wstate->span[nextscan].w;\n                    fart = (nextt + dtinc) >> 16;\n                    fars = (nexts + dsinc) >> 16;\n                    farsw = (nextsw + dwinc) >> 16;\n                    nextt >>= 16;\n                    nexts >>= 16;\n                    nextsw >>= 16;\n                }\n            }\n            else\n            {\n\n\n\n\n\n\n\n\n\n                if (sigs->longspan)\n                {\n                    nextt = (wstate->span[nextscan].t + dtinc) >> 16;\n                    nexts = (wstate->span[nextscan].s + dsinc) >> 16;\n                    nextsw = (wstate->span[nextscan].w + dwinc) >> 16;\n                    fart = (wstate->span[nextscan].t + (dtinc << 1)) >> 16;\n                    fars = (wstate->span[nextscan].s + (dsinc << 1)) >> 16;\n                    farsw = (wstate->span[nextscan].w  + (dwinc << 1)) >> 16;\n                }\n                else if (sigs->midspan)\n                {\n                    nextt = wstate->span[nextscan].t >> 16;\n                    nexts = wstate->span[nextscan].s >> 16;\n                    nextsw = wstate->span[nextscan].w >> 16;\n                    fart = (wstate->span[nextscan].t + dtinc) >> 16;\n                    fars = (wstate->span[nextscan].s + dsinc) >> 16;\n                    farsw = (wstate->span[nextscan].w  + dwinc) >> 16;\n                }\n                else if (sigs->onelessthanmid)\n                {\n                    nextsw = (w + dwinc) >> 16;\n                    nexts = (s + dsinc) >> 16;\n                    nextt = (t + dtinc) >> 16;\n                    farsw = (w - dwinc) >> 16;\n                    fars = (s - dsinc) >> 16;\n                    fart = (t - dtinc) >> 16;\n                }\n                else\n                {\n                    nextt = (t + dtinc) >> 16;\n                    nexts = (s + dsinc) >> 16;\n                    nextsw = (w + dwinc) >> 16;\n                    fart = (t + (dtinc << 1)) >> 16;\n                    fars = (s + (dsinc << 1)) >> 16;\n                    farsw = (w + (dwinc << 1)) >> 16;\n                }\n            }\n        }\n        else\n        {\n            nextsw = (w + dwinc) >> 16;\n            nexts = (s + dsinc) >> 16;\n            nextt = (t + dtinc) >> 16;\n            farsw = (w + (dwinc << 1)) >> 16;\n            fars = (s + (dsinc << 1)) >> 16;\n            fart = (t + (dtinc << 1)) >> 16;\n        }\n\n        wstate->tcdiv_ptr(nexts, nextt, nextsw, &nexts, &nextt);\n        wstate->tcdiv_ptr(fars, fart, farsw, &fars, &fart);\n\n        lodclamp = (fart & 0x60000) || (nextt & 0x60000) || (fars & 0x60000) || (nexts & 0x60000);\n\n\n\n        if (!lodclamp)\n            tclod_4x17_to_15(nexts, fars, nextt, fart, 0, &lod);\n\n        lodfrac_lodtile_signals(wstate, lodclamp, lod, &l_tile, &magnify, &distant, prelodfrac);\n\n        if (wstate->other_modes.tex_lod_en)\n        {\n            if (distant)\n                l_tile = wstate->max_level;\n            if (!wstate->other_modes.detail_tex_en || magnify)\n                *t1 = (prim_tile + l_tile) & 7;\n            else\n                *t1 = (prim_tile + l_tile + 1) & 7;\n        }\n    }\n}\n\nstatic STRICTINLINE void tclod_copy(struct rdp_state* wstate, int32_t* sss, int32_t* sst, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t prim_tile, int32_t* t1)\n{\n\n\n\n\n    int nexts, nextt, nextsw, fars, fart, farsw;\n    int lodclamp = 0;\n    int32_t lod = 0;\n    uint32_t l_tile = 0, magnify = 0, distant = 0;\n\n    tclod_tcclamp(sss, sst);\n\n    if (wstate->other_modes.tex_lod_en)\n    {\n\n\n\n        nextsw = (w + dwinc) >> 16;\n        nexts = (s + dsinc) >> 16;\n        nextt = (t + dtinc) >> 16;\n        farsw = (w + (dwinc << 1)) >> 16;\n        fars = (s + (dsinc << 1)) >> 16;\n        fart = (t + (dtinc << 1)) >> 16;\n\n        wstate->tcdiv_ptr(nexts, nextt, nextsw, &nexts, &nextt);\n        wstate->tcdiv_ptr(fars, fart, farsw, &fars, &fart);\n\n        lodclamp = (fart & 0x60000) || (nextt & 0x60000) || (fars & 0x60000) || (nexts & 0x60000);\n\n        if (!lodclamp)\n            tclod_4x17_to_15(nexts, fars, nextt, fart, 0, &lod);\n\n        if ((lod & 0x4000) || lodclamp)\n        {\n\n\n            magnify = 0;\n            l_tile = wstate->max_level;\n        }\n        else if (lod < 32)\n        {\n            magnify = 1;\n            l_tile = 0;\n        }\n        else\n        {\n            magnify = 0;\n            l_tile =  log2table[(lod >> 5) & 0xff];\n\n            if (wstate->max_level)\n                distant = ((lod & 0x6000) || (l_tile >= wstate->max_level)) != 0;\n            else\n                distant = 1;\n\n            if (distant)\n                l_tile = wstate->max_level;\n        }\n\n        if (!wstate->other_modes.detail_tex_en || magnify)\n            *t1 = (prim_tile + l_tile) & 7;\n        else\n            *t1 = (prim_tile + l_tile + 1) & 7;\n    }\n\n}\n\nstatic STRICTINLINE void tc_pipeline_copy(struct tile* tile, int32_t* sss0, int32_t* sss1, int32_t* sss2, int32_t* sss3, int32_t* sst)\n{\n    int ss0 = *sss0, ss1 = 0, ss2 = 0, ss3 = 0, st = *sst;\n\n    tcshift_copy(tile, &ss0, &st);\n\n\n\n    ss0 = TRELATIVE(ss0, tile->sl);\n    st = TRELATIVE(st, tile->tl);\n    ss0 = (ss0 >> 5);\n    st = (st >> 5);\n\n    ss1 = ss0 + 1;\n    ss2 = ss0 + 2;\n    ss3 = ss0 + 3;\n\n    tcmask_copy(tile, &ss0, &ss1, &ss2, &ss3, &st);\n\n    *sss0 = ss0;\n    *sss1 = ss1;\n    *sss2 = ss2;\n    *sss3 = ss3;\n    *sst = st;\n}\n\nstatic STRICTINLINE void tc_pipeline_load(struct tile* tile, int32_t* sss, int32_t* sst, int coord_quad)\n{\n    int sss1 = *sss, sst1 = *sst;\n    sss1 = SIGN16(sss1);\n    sst1 = SIGN16(sst1);\n\n\n    sss1 = TRELATIVE(sss1, tile->sl);\n    sst1 = TRELATIVE(sst1, tile->tl);\n\n\n\n    if (!coord_quad)\n    {\n        sss1 = (sss1 >> 5);\n        sst1 = (sst1 >> 5);\n    }\n    else\n    {\n        sss1 = (sss1 >> 3);\n        sst1 = (sst1 >> 3);\n    }\n\n    *sss = sss1;\n    *sst = sst1;\n}\n\nstatic void tcdiv_nopersp(int32_t ss, int32_t st, int32_t sw, int32_t* sss, int32_t* sst)\n{\n    UNUSED(sw);\n\n\n    *sss = (SIGN16(ss)) & 0x1ffff;\n    *sst = (SIGN16(st)) & 0x1ffff;\n}\n\nstatic void tcdiv_persp(int32_t ss, int32_t st, int32_t sw, int32_t* sss, int32_t* sst)\n{\n\n\n    int w_carry = 0;\n    int shift;\n    int tlu_rcp;\n    int sprod, tprod;\n    int outofbounds_s, outofbounds_t;\n    int tempmask;\n    int shift_value;\n    int32_t temps, tempt;\n\n\n\n    int overunder_s = 0, overunder_t = 0;\n\n\n    if (SIGN16(sw) <= 0)\n        w_carry = 1;\n\n    sw &= 0x7fff;\n\n\n\n    shift = tcdiv_table[sw];\n    tlu_rcp = shift >> 4;\n    shift &= 0xf;\n\n    sprod = SIGN16(ss) * tlu_rcp;\n    tprod = SIGN16(st) * tlu_rcp;\n\n\n\n\n    tempmask = ((1 << 30) - 1) & -((1 << 29) >> shift);\n\n    outofbounds_s = sprod & tempmask;\n    outofbounds_t = tprod & tempmask;\n\n    if (shift != 0xe)\n    {\n        shift_value = 13 - shift;\n        temps = sprod = (sprod >> shift_value);\n        tempt = tprod = (tprod >> shift_value);\n    }\n    else\n    {\n        temps = sprod << 1;\n        tempt = tprod << 1;\n    }\n\n    if (outofbounds_s != tempmask && outofbounds_s != 0)\n    {\n        if (!(sprod & (1 << 29)))\n            overunder_s = 2 << 17;\n        else\n            overunder_s = 1 << 17;\n    }\n\n    if (outofbounds_t != tempmask && outofbounds_t != 0)\n    {\n        if (!(tprod & (1 << 29)))\n            overunder_t = 2 << 17;\n        else\n            overunder_t = 1 << 17;\n    }\n\n    if (w_carry)\n    {\n        overunder_s |= (2 << 17);\n        overunder_t |= (2 << 17);\n    }\n\n    *sss = (temps & 0x1ffff) | overunder_s;\n    *sst = (tempt & 0x1ffff) | overunder_t;\n}\n\nstatic void tcoord_init_lut(void)\n{\n    int i, k;\n\n    log2table[0] = log2table[1] = 0;\n    for (i = 2; i < 256; i++)\n    {\n        for (k = 7; k > 0; k--)\n        {\n            if((i >> k) & 1)\n            {\n                log2table[i] = k;\n                break;\n            }\n        }\n    }\n\n    int temppoint, tempslope;\n    int normout;\n    int wnorm;\n    int shift, tlu_rcp;\n\n    for (i = 0; i < 0x8000; i++)\n    {\n        for (k = 1; k <= 14 && !((i << k) & 0x8000); k++)\n            ;\n        shift = k - 1;\n        normout = (i << shift) & 0x3fff;\n        wnorm = (normout & 0xff) << 2;\n        normout >>= 8;\n\n\n\n        temppoint = norm_point_table[normout];\n        tempslope = norm_slope_table[normout];\n\n        tempslope = (tempslope | ~0x3ff) + 1;\n\n        tlu_rcp = (((tempslope * wnorm) >> 10) + temppoint) & 0x7fff;\n\n        tcdiv_table[i] = shift | (tlu_rcp << 4);\n    }\n\n    maskbits_table[0] = 0x3ff;\n    for (i = 1; i < 16; i++)\n        maskbits_table[i] = ((uint16_t)(0xffff) >> (16 - i)) & 0x3ff;\n}\n\nstatic void tcoord_init(struct rdp_state* wstate)\n{\n    wstate->tcdiv_ptr = tcdiv_func[0];\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/tex.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic STRICTINLINE void tcmask(struct tile* tile, int32_t* S, int32_t* T)\n{\n    int32_t wrap;\n\n\n\n    if (tile->mask_s)\n    {\n        if (tile->ms)\n        {\n            wrap = *S >> tile->f.masksclamped;\n            wrap &= 1;\n            *S ^= (-wrap);\n        }\n        *S &= maskbits_table[tile->mask_s];\n    }\n\n    if (tile->mask_t)\n    {\n        if (tile->mt)\n        {\n            wrap = *T >> tile->f.masktclamped;\n            wrap &= 1;\n            *T ^= (-wrap);\n        }\n\n        *T &= maskbits_table[tile->mask_t];\n    }\n}\n\n\nstatic STRICTINLINE void tcmask_coupled(struct tile* tile, int32_t* S, int32_t* sdiff, int32_t* T, int32_t* tdiff)\n{\n    int32_t wrap;\n    int32_t maskbits;\n    int32_t wrapthreshold;\n\n\n    if (tile->mask_s)\n    {\n        maskbits = maskbits_table[tile->mask_s];\n\n        if (tile->ms)\n        {\n            wrapthreshold = tile->f.masksclamped;\n\n            wrap = (*S >> wrapthreshold) & 1;\n            *S ^= (-wrap);\n            *S &= maskbits;\n\n\n            if (((*S - wrap) & maskbits) == maskbits)\n                *sdiff = 0;\n            else\n                *sdiff = 1 - (wrap << 1);\n        }\n        else\n        {\n            *S &= maskbits;\n            if (*S == maskbits)\n                *sdiff = -(*S);\n            else\n                *sdiff = 1;\n        }\n    }\n    else\n        *sdiff = 1;\n\n    if (tile->mask_t)\n    {\n        maskbits = maskbits_table[tile->mask_t];\n\n        if (tile->mt)\n        {\n            wrapthreshold = tile->f.masktclamped;\n\n            wrap = (*T >> wrapthreshold) & 1;\n            *T ^= (-wrap);\n            *T &= maskbits;\n\n            if (((*T - wrap) & maskbits) == maskbits)\n                *tdiff = 0;\n            else\n                *tdiff = 1 - (wrap << 1);\n        }\n        else\n        {\n            *T &= maskbits;\n            if (*T == maskbits)\n                *tdiff = -(*T & 0xff);\n            else\n                *tdiff = 1;\n        }\n    }\n    else\n        *tdiff = 1;\n}\n\n\nstatic INLINE void calculate_clamp_diffs(struct tile* t)\n{\n    t->f.clampdiffs = ((t->sh >> 2) - (t->sl >> 2)) & 0x3ff;\n    t->f.clampdifft = ((t->th >> 2) - (t->tl >> 2)) & 0x3ff;\n}\n\n\nstatic INLINE void calculate_tile_derivs(struct tile* t)\n{\n    t->f.clampens = t->cs || !t->mask_s;\n    t->f.clampent = t->ct || !t->mask_t;\n    t->f.masksclamped = t->mask_s <= 10 ? t->mask_s : 10;\n    t->f.masktclamped = t->mask_t <= 10 ? t->mask_t : 10;\n    t->f.notlutswitch = (t->format << 2) | t->size;\n    t->f.tlutswitch = (t->size << 2) | ((t->format + 2) & 3);\n\n    if (t->format < 5)\n    {\n        t->f.notlutswitch = (t->format << 2) | t->size;\n        t->f.tlutswitch = (t->size << 2) | ((t->format + 2) & 3);\n    }\n    else\n    {\n        t->f.notlutswitch = 0x10 | t->size;\n        t->f.tlutswitch = (t->size << 2) | 2;\n    }\n}\n\nstatic STRICTINLINE void get_texel1_1cycle(struct rdp_state* wstate, int32_t* s1, int32_t* t1, int32_t s, int32_t t, int32_t w, int32_t dsinc, int32_t dtinc, int32_t dwinc, int32_t scanline, struct spansigs* sigs)\n{\n    int32_t nexts, nextt, nextsw;\n\n    if (!sigs->endspan || !sigs->longspan || !wstate->span[scanline + 1].validline)\n    {\n\n\n        nextsw = (w + dwinc) >> 16;\n        nexts = (s + dsinc) >> 16;\n        nextt = (t + dtinc) >> 16;\n    }\n    else\n    {\n\n\n\n\n\n\n\n        int32_t nextscan = scanline + 1;\n        nextt = wstate->span[nextscan].t >> 16;\n        nexts = wstate->span[nextscan].s >> 16;\n        nextsw = wstate->span[nextscan].w >> 16;\n    }\n\n    wstate->tcdiv_ptr(nexts, nextt, nextsw, s1, t1);\n}\n\nstatic STRICTINLINE void texture_pipeline_cycle(struct rdp_state* wstate, struct color* TEX, struct color* prev, int32_t SSS, int32_t SST, uint32_t tilenum, uint32_t cycle)\n{\n    int32_t maxs, maxt, invt3r, invt3g, invt3b, invt3a;\n    int32_t sfrac, tfrac, invsf, invtf, sfracrg, invsfrg;\n    int upper, upperrg, center, centerrg;\n\n\n    int bilerp = cycle ? wstate->other_modes.bi_lerp1 : wstate->other_modes.bi_lerp0;\n    int convert = wstate->other_modes.convert_one && cycle;\n    struct color t0, t1, t2, t3;\n    int sss1, sst1, sdiff, tdiff;\n\n    sss1 = SSS;\n    sst1 = SST;\n\n    tcshift_cycle(&wstate->tile[tilenum], &sss1, &sst1, &maxs, &maxt);\n\n    sss1 = TRELATIVE(sss1, wstate->tile[tilenum].sl);\n    sst1 = TRELATIVE(sst1, wstate->tile[tilenum].tl);\n\n    if (wstate->other_modes.sample_type || wstate->other_modes.en_tlut)\n    {\n        sfrac = sss1 & 0x1f;\n        tfrac = sst1 & 0x1f;\n\n\n\n\n        tcclamp_cycle(&wstate->tile[tilenum], &sss1, &sst1, &sfrac, &tfrac, maxs, maxt);\n\n\n\n\n\n\n        tcmask_coupled(&wstate->tile[tilenum], &sss1, &sdiff, &sst1, &tdiff);\n\n\n\n\n\n\n\n        upper = (sfrac + tfrac) & 0x20;\n\n\n\n\n        if (wstate->tile[tilenum].format == FORMAT_YUV)\n        {\n            sfracrg = (sfrac >> 1) | ((sss1 & 1) << 4);\n\n\n\n            upperrg = (sfracrg + tfrac) & 0x20;\n        }\n        else\n        {\n            upperrg = upper;\n            sfracrg = sfrac;\n        }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n        if (bilerp)\n        {\n\n            if (!wstate->other_modes.sample_type)\n                fetch_texel_entlut_quadro_nearest(wstate, &t0, &t1, &t2, &t3, sss1, sst1, tilenum, upper, upperrg);\n            else if (wstate->other_modes.en_tlut)\n                fetch_texel_entlut_quadro(wstate, &t0, &t1, &t2, &t3, sss1, sdiff, sst1, tdiff, tilenum, upper, upperrg);\n            else\n                fetch_texel_quadro(wstate, &t0, &t1, &t2, &t3, sss1, sdiff, sst1, tdiff, tilenum, upper - upperrg);\n\n            if (!wstate->other_modes.mid_texel)\n                center = centerrg = 0;\n            else\n            {\n\n                center = (sfrac == 0x10 && tfrac == 0x10);\n                centerrg = (sfracrg == 0x10 && tfrac == 0x10);\n            }\n\n            if (!convert)\n            {\n                invtf = 0x20 - tfrac;\n\n                if (!centerrg)\n                {\n\n\n                    if (upperrg)\n                    {\n\n                        invsfrg = 0x20 - sfracrg;\n\n                        TEX->r = t3.r + ((invsfrg * (t2.r - t3.r) + invtf * (t1.r - t3.r) + 0x10) >> 5);\n                        TEX->g = t3.g + ((invsfrg * (t2.g - t3.g) + invtf * (t1.g - t3.g) + 0x10) >> 5);\n                    }\n                    else\n                    {\n                        TEX->r = t0.r + ((sfracrg * (t1.r - t0.r) + tfrac * (t2.r - t0.r) + 0x10) >> 5);\n                        TEX->g = t0.g + ((sfracrg * (t1.g - t0.g) + tfrac * (t2.g - t0.g) + 0x10) >> 5);\n                    }\n                }\n                else\n                {\n\n                    invt3r = ~t3.r;\n                    invt3g = ~t3.g;\n\n\n                    TEX->r = t3.r + ((((t1.r + t2.r) << 6) - (t3.r << 7) + ((invt3r + t0.r) << 6) + 0xc0) >> 8);\n                    TEX->g = t3.g + ((((t1.g + t2.g) << 6) - (t3.g << 7) + ((invt3g + t0.g) << 6) + 0xc0) >> 8);\n                }\n\n                if (!center)\n                {\n                    if (upper)\n                    {\n                        invsf = 0x20 - sfrac;\n\n                        TEX->b = t3.b + ((invsf * (t2.b - t3.b) + invtf * (t1.b - t3.b) + 0x10) >> 5);\n                        TEX->a = t3.a + ((invsf * (t2.a - t3.a) + invtf * (t1.a - t3.a) + 0x10) >> 5);\n                    }\n                    else\n                    {\n                        TEX->b = t0.b + ((sfrac * (t1.b - t0.b) + tfrac * (t2.b - t0.b) + 0x10) >> 5);\n                        TEX->a = t0.a + ((sfrac * (t1.a - t0.a) + tfrac * (t2.a - t0.a) + 0x10) >> 5);\n                    }\n                }\n                else\n                {\n                    invt3b = ~t3.b;\n                    invt3a = ~t3.a;\n\n                    TEX->b = t3.b + ((((t1.b + t2.b) << 6) - (t3.b << 7) + ((invt3b + t0.b) << 6) + 0xc0) >> 8);\n                    TEX->a = t3.a + ((((t1.a + t2.a) << 6) - (t3.a << 7) + ((invt3a + t0.a) << 6) + 0xc0) >> 8);\n                }\n            }\n            else\n            {\n                int32_t prevr, prevg, prevb;\n                prevr = SIGN(prev->r, 9);\n                prevg = SIGN(prev->g, 9);\n                prevb = SIGN(prev->b, 9);\n\n                if (!centerrg)\n                {\n                    if (upperrg)\n                    {\n                        TEX->r = prevb + ((prevr * (t2.r - t3.r) + prevg * (t1.r - t3.r) + 0x80) >> 8);\n                        TEX->g = prevb + ((prevr * (t2.g - t3.g) + prevg * (t1.g - t3.g) + 0x80) >> 8);\n                    }\n                    else\n                    {\n                        TEX->r = prevb + ((prevr * (t1.r - t0.r) + prevg * (t2.r - t0.r) + 0x80) >> 8);\n                        TEX->g = prevb + ((prevr * (t1.g - t0.g) + prevg * (t2.g - t0.g) + 0x80) >> 8);\n                    }\n                }\n                else\n                {\n                    invt3r = ~t3.r;\n                    invt3g = ~t3.g;\n\n                    TEX->r = prevb + ((prevr * (t2.r - t3.r) + prevg * (t1.r - t3.r) + ((invt3r + t0.r) << 6) + 0xc0) >> 8);\n                    TEX->g = prevb + ((prevr * (t2.g - t3.g) + prevg * (t1.g - t3.g) + ((invt3g + t0.g) << 6) + 0xc0) >> 8);\n                }\n\n                if (!center)\n                {\n                    if (upper)\n                    {\n                        TEX->b = prevb + ((prevr * (t2.b - t3.b) + prevg * (t1.b - t3.b) + 0x80) >> 8);\n                        TEX->a = prevb + ((prevr * (t2.a - t3.a) + prevg * (t1.a - t3.a) + 0x80) >> 8);\n                    }\n                    else\n                    {\n                        TEX->b = prevb + ((prevr * (t1.b - t0.b) + prevg * (t2.b - t0.b) + 0x80) >> 8);\n                        TEX->a = prevb + ((prevr * (t1.a - t0.a) + prevg * (t2.a - t0.a) + 0x80) >> 8);\n                    }\n                }\n                else\n                {\n                    invt3b = ~t3.b;\n                    invt3a = ~t3.a;\n\n                    TEX->b = prevb + ((prevr * (t2.b - t3.b) + prevg * (t1.b - t3.b) + ((invt3b + t0.b) << 6) + 0xc0) >> 8);\n                    TEX->a = prevb + ((prevr * (t2.a - t3.a) + prevg * (t1.a - t3.a) + ((invt3a + t0.a) << 6) + 0xc0) >> 8);\n                }\n            }\n        }\n        else\n        {\n\n\n\n            if (convert)\n            {\n                t0 = t3 = *prev;\n                t0.r = SIGN(t0.r, 9);\n                t0.g = SIGN(t0.g, 9);\n                t0.b = SIGN(t0.b, 9);\n                t3.r = SIGN(t3.r, 9);\n                t3.g = SIGN(t3.g, 9);\n                t3.b = SIGN(t3.b, 9);\n            }\n            else\n            {\n                if (!wstate->other_modes.sample_type)\n                    fetch_texel_entlut_quadro_nearest(wstate, &t0, &t1, &t2, &t3, sss1, sst1, tilenum, upper, upperrg);\n                else if (wstate->other_modes.en_tlut)\n                    fetch_texel_entlut_quadro(wstate, &t0, &t1, &t2, &t3, sss1, sdiff, sst1, tdiff, tilenum, upper, upperrg);\n                else\n                    fetch_texel_quadro(wstate, &t0, &t1, &t2, &t3, sss1, sdiff, sst1, tdiff, tilenum, upper - upperrg);\n            }\n\n\n            if (upperrg)\n            {\n                if (upper)\n                {\n                    TEX->r = t3.b + ((wstate->k0_tf * t3.g + 0x80) >> 8);\n                    TEX->g = t3.b + ((wstate->k1_tf * t3.r + wstate->k2_tf * t3.g + 0x80) >> 8);\n                    TEX->b = t3.b + ((wstate->k3_tf * t3.r + 0x80) >> 8);\n                    TEX->a = t3.b;\n                }\n                else\n                {\n                    TEX->r = t0.b + ((wstate->k0_tf * t3.g + 0x80) >> 8);\n                    TEX->g = t0.b + ((wstate->k1_tf * t3.r + wstate->k2_tf * t3.g + 0x80) >> 8);\n                    TEX->b = t0.b + ((wstate->k3_tf * t3.r + 0x80) >> 8);\n                    TEX->a = t0.b;\n                }\n            }\n            else\n            {\n                if (upper)\n                {\n                    TEX->r = t3.b + ((wstate->k0_tf * t0.g + 0x80) >> 8);\n                    TEX->g = t3.b + ((wstate->k1_tf * t0.r + wstate->k2_tf * t0.g + 0x80) >> 8);\n                    TEX->b = t3.b + ((wstate->k3_tf * t0.r + 0x80) >> 8);\n                    TEX->a = t3.b;\n                }\n                else\n                {\n                    TEX->r = t0.b + ((wstate->k0_tf * t0.g + 0x80) >> 8);\n                    TEX->g = t0.b + ((wstate->k1_tf * t0.r + wstate->k2_tf * t0.g + 0x80) >> 8);\n                    TEX->b = t0.b + ((wstate->k3_tf * t0.r + 0x80) >> 8);\n                    TEX->a = t0.b;\n                }\n            }\n        }\n\n        TEX->r &= 0x1ff;\n        TEX->g &= 0x1ff;\n        TEX->b &= 0x1ff;\n        TEX->a &= 0x1ff;\n\n\n    }\n    else\n    {\n\n\n\n\n        tcclamp_cycle_light(&wstate->tile[tilenum], &sss1, &sst1, maxs, maxt);\n\n        tcmask(&wstate->tile[tilenum], &sss1, &sst1);\n\n\n\n\n        if (bilerp)\n        {\n            if (!convert)\n            {\n\n                fetch_texel(wstate, &t0, sss1, sst1, tilenum);\n\n                TEX->r = t0.r & 0x1ff;\n                TEX->g = t0.g & 0x1ff;\n                TEX->b = t0.b;\n                TEX->a = t0.a;\n            }\n            else\n                TEX->r = TEX->g = TEX->b = TEX->a = prev->b;\n        }\n        else\n        {\n            if (convert)\n            {\n                t0 = *prev;\n                t0.r = SIGN(t0.r, 9);\n                t0.g = SIGN(t0.g, 9);\n                t0.b = SIGN(t0.b, 9);\n            }\n            else\n                fetch_texel(wstate, &t0, sss1, sst1, tilenum);\n\n            TEX->r = t0.b + ((wstate->k0_tf * t0.g + 0x80) >> 8);\n            TEX->g = t0.b + ((wstate->k1_tf * t0.r + wstate->k2_tf * t0.g + 0x80) >> 8);\n            TEX->b = t0.b + ((wstate->k3_tf * t0.r + 0x80) >> 8);\n            TEX->a = t0.b & 0x1ff;\n            TEX->r &= 0x1ff;\n            TEX->g &= 0x1ff;\n            TEX->b &= 0x1ff;\n        }\n    }\n\n}\n\nstatic void loading_pipeline(struct rdp_state* wstate, int start, int end, int tilenum, int coord_quad, int ltlut)\n{\n\n\n    //int localdebugmode = 0, cnt = 0;\n    int i, j;\n\n    int dsinc, dtinc;\n    dsinc = wstate->spans_ds;\n    dtinc = wstate->spans_dt;\n\n    int s, t;\n    int ss, st;\n    int xstart, xend, xendsc;\n    int sss = 0, sst = 0;\n    int ti_index, length;\n\n    uint32_t tmemidx0 = 0, tmemidx1 = 0, tmemidx2 = 0, tmemidx3 = 0;\n    int dswap = 0;\n    uint32_t readval0, readval1, readval2, readval3;\n    uint32_t readidx32;\n    uint64_t loadqword = 0;\n    uint16_t tempshort = 0;\n    int tmem_formatting = 0;\n    uint32_t bit3fl = 0, hibit = 0;\n\n    if (end > start && ltlut)\n    {\n        rdp_pipeline_crashed = 1;\n        return;\n    }\n\n    if (wstate->tile[tilenum].format == FORMAT_YUV)\n        tmem_formatting = 0;\n    else if (wstate->tile[tilenum].format == FORMAT_RGBA && wstate->tile[tilenum].size == PIXEL_SIZE_32BIT)\n        tmem_formatting = 1;\n    else\n        tmem_formatting = 2;\n\n    int tiadvance = 0, spanadvance = 0;\n    int tiptr = 0;\n    switch (wstate->ti_size)\n    {\n    case PIXEL_SIZE_4BIT:\n        rdp_pipeline_crashed = 1;\n        return;\n        break;\n    case PIXEL_SIZE_8BIT:\n        tiadvance = 8;\n        spanadvance = 8;\n        break;\n    case PIXEL_SIZE_16BIT:\n        if (!ltlut)\n        {\n            tiadvance = 8;\n            spanadvance = 4;\n        }\n        else\n        {\n            tiadvance = 2;\n            spanadvance = 1;\n        }\n        break;\n    case PIXEL_SIZE_32BIT:\n        tiadvance = 8;\n        spanadvance = 2;\n        break;\n    }\n\n    for (i = start; i <= end; i++)\n    {\n        xstart = wstate->span[i].lx;\n        xend = wstate->span[i].unscrx;\n        xendsc = wstate->span[i].rx;\n        s = wstate->span[i].s;\n        t = wstate->span[i].t;\n\n        ti_index = wstate->ti_width * i + xend;\n        tiptr = wstate->ti_address + PIXELS_TO_BYTES(ti_index, wstate->ti_size);\n\n        length = (xstart - xend + 1) & 0xfff;\n\n        for (j = 0; j < length; j+= spanadvance)\n        {\n            ss = s >> 16;\n            st = t >> 16;\n\n\n\n\n\n\n\n            sss = ss & 0xffff;\n            sst = st & 0xffff;\n\n            tc_pipeline_load(&wstate->tile[tilenum], &sss, &sst, coord_quad);\n\n            dswap = sst & 1;\n\n\n            get_tmem_idx(wstate, sss, sst, tilenum, &tmemidx0, &tmemidx1, &tmemidx2, &tmemidx3, &bit3fl, &hibit);\n\n            readidx32 = (tiptr >> 2) & ~1;\n            RREADIDX32(readval0, readidx32);\n            readidx32++;\n            RREADIDX32(readval1, readidx32);\n            readidx32++;\n            RREADIDX32(readval2, readidx32);\n            readidx32++;\n            RREADIDX32(readval3, readidx32);\n\n\n            switch(tiptr & 7)\n            {\n            case 0:\n                if (!ltlut)\n                    loadqword = ((uint64_t)readval0 << 32) | readval1;\n                else\n                {\n                    tempshort = readval0 >> 16;\n                    loadqword = ((uint64_t)tempshort << 48) | ((uint64_t) tempshort << 32) | ((uint64_t) tempshort << 16) | tempshort;\n                }\n                break;\n            case 1:\n                loadqword = ((uint64_t)readval0 << 40) | ((uint64_t)readval1 << 8) | (readval2 >> 24);\n                break;\n            case 2:\n                if (!ltlut)\n                    loadqword = ((uint64_t)readval0 << 48) | ((uint64_t)readval1 << 16) | (readval2 >> 16);\n                else\n                {\n                    tempshort = readval0 & 0xffff;\n                    loadqword = ((uint64_t)tempshort << 48) | ((uint64_t) tempshort << 32) | ((uint64_t) tempshort << 16) | tempshort;\n                }\n                break;\n            case 3:\n                loadqword = ((uint64_t)readval0 << 56) | ((uint64_t)readval1 << 24) | (readval2 >> 8);\n                break;\n            case 4:\n                if (!ltlut)\n                    loadqword = ((uint64_t)readval1 << 32) | readval2;\n                else\n                {\n                    tempshort = readval1 >> 16;\n                    loadqword = ((uint64_t)tempshort << 48) | ((uint64_t) tempshort << 32) | ((uint64_t) tempshort << 16) | tempshort;\n                }\n                break;\n            case 5:\n                loadqword = ((uint64_t)readval1 << 40) | ((uint64_t)readval2 << 8) | (readval3 >> 24);\n                break;\n            case 6:\n                if (!ltlut)\n                    loadqword = ((uint64_t)readval1 << 48) | ((uint64_t)readval2 << 16) | (readval3 >> 16);\n                else\n                {\n                    tempshort = readval1 & 0xffff;\n                    loadqword = ((uint64_t)tempshort << 48) | ((uint64_t) tempshort << 32) | ((uint64_t) tempshort << 16) | tempshort;\n                }\n                break;\n            case 7:\n                loadqword = ((uint64_t)readval1 << 56) | ((uint64_t)readval2 << 24) | (readval3 >> 8);\n                break;\n            }\n\n\n            switch(tmem_formatting)\n            {\n            case 0:\n                readval0 = (uint32_t)((((loadqword >> 56) & 0xff) << 24) | (((loadqword >> 40) & 0xff) << 16) | (((loadqword >> 24) & 0xff) << 8) | (((loadqword >> 8) & 0xff) << 0));\n                readval1 = (uint32_t)((((loadqword >> 48) & 0xff) << 24) | (((loadqword >> 32) & 0xff) << 16) | (((loadqword >> 16) & 0xff) << 8) | (((loadqword >> 0) & 0xff) << 0));\n                if (bit3fl)\n                {\n                    tmem16[tmemidx2 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 >> 16);\n                    tmem16[tmemidx3 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 & 0xffff);\n                    tmem16[(tmemidx2 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 >> 16);\n                    tmem16[(tmemidx3 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 & 0xffff);\n                }\n                else\n                {\n                    tmem16[tmemidx0 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 >> 16);\n                    tmem16[tmemidx1 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 & 0xffff);\n                    tmem16[(tmemidx0 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 >> 16);\n                    tmem16[(tmemidx1 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 & 0xffff);\n                }\n                break;\n            case 1:\n                readval0 = (uint32_t)(((loadqword >> 48) << 16) | ((loadqword >> 16) & 0xffff));\n                readval1 = (uint32_t)((((loadqword >> 32) & 0xffff) << 16) | (loadqword & 0xffff));\n\n                if (bit3fl)\n                {\n                    tmem16[tmemidx2 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 >> 16);\n                    tmem16[tmemidx3 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 & 0xffff);\n                    tmem16[(tmemidx2 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 >> 16);\n                    tmem16[(tmemidx3 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 & 0xffff);\n                }\n                else\n                {\n                    tmem16[tmemidx0 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 >> 16);\n                    tmem16[tmemidx1 ^ WORD_ADDR_XOR] = (uint16_t)(readval0 & 0xffff);\n                    tmem16[(tmemidx0 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 >> 16);\n                    tmem16[(tmemidx1 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(readval1 & 0xffff);\n                }\n                break;\n            case 2:\n                if (!dswap)\n                {\n                    if (!hibit)\n                    {\n                        tmem16[tmemidx0 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 48);\n                        tmem16[tmemidx1 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 32);\n                        tmem16[tmemidx2 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 16);\n                        tmem16[tmemidx3 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword & 0xffff);\n                    }\n                    else\n                    {\n                        tmem16[(tmemidx0 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 48);\n                        tmem16[(tmemidx1 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 32);\n                        tmem16[(tmemidx2 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 16);\n                        tmem16[(tmemidx3 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword & 0xffff);\n                    }\n                }\n                else\n                {\n                    if (!hibit)\n                    {\n                        tmem16[tmemidx0 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 16);\n                        tmem16[tmemidx1 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword & 0xffff);\n                        tmem16[tmemidx2 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 48);\n                        tmem16[tmemidx3 ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 32);\n                    }\n                    else\n                    {\n                        tmem16[(tmemidx0 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 16);\n                        tmem16[(tmemidx1 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword & 0xffff);\n                        tmem16[(tmemidx2 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 48);\n                        tmem16[(tmemidx3 | 0x400) ^ WORD_ADDR_XOR] = (uint16_t)(loadqword >> 32);\n                    }\n                }\n            break;\n            }\n\n\n            s = (s + dsinc) & ~0x1f;\n            t = (t + dtinc) & ~0x1f;\n            tiptr += tiadvance;\n        }\n    }\n}\n\nstatic void edgewalker_for_loads(struct rdp_state* wstate, int32_t* lewdata)\n{\n    int j = 0;\n    int xleft = 0, xright = 0;\n    int /*xstart = 0,*/ xend = 0;\n    int s = 0, t = 0, w = 0;\n    int dsdx = 0, dtdx = 0;\n    int dsdy = 0, dtdy = 0;\n    int dsde = 0, dtde = 0;\n    int tilenum = 0, flip = 0;\n    int32_t yl = 0, ym = 0, yh = 0;\n    int32_t xl = 0, xm = 0, xh = 0;\n    int32_t dxldy = 0, dxhdy = 0, dxmdy = 0;\n\n    int cmd_id = CMD_ID(lewdata);\n    int ltlut = (cmd_id == CMD_ID_LOAD_TLUT);\n    int coord_quad = ltlut || (cmd_id == CMD_ID_LOAD_BLOCK);\n    flip = 1;\n    wstate->max_level = 0;\n    tilenum = (lewdata[0] >> 16) & 7;\n\n\n    yl = SIGN(lewdata[0], 14);\n    ym = lewdata[1] >> 16;\n    ym = SIGN(ym, 14);\n    yh = SIGN(lewdata[1], 14);\n\n    xl = SIGN(lewdata[2], 28);\n    xh = SIGN(lewdata[3], 28);\n    xm = SIGN(lewdata[4], 28);\n\n    dxldy = 0;\n    dxhdy = 0;\n    dxmdy = 0;\n\n\n    s    = lewdata[5] & 0xffff0000;\n    t    = (lewdata[5] & 0xffff) << 16;\n    w    = 0;\n    dsdx = (lewdata[7] & 0xffff0000) | ((lewdata[6] >> 16) & 0xffff);\n    dtdx = ((lewdata[7] << 16) & 0xffff0000)    | (lewdata[6] & 0xffff);\n    dsde = 0;\n    dtde = (lewdata[9] & 0xffff) << 16;\n    dsdy = 0;\n    dtdy = (lewdata[8] & 0xffff) << 16;\n\n    wstate->spans_ds = dsdx & ~0x1f;\n    wstate->spans_dt = dtdx & ~0x1f;\n    wstate->spans_dw = 0;\n\n\n\n\n\n\n    xright = xh & ~0x1;\n    xleft = xm & ~0x1;\n\n    int k = 0;\n\n    //int sign_dxhdy = 0;\n\n    //int do_offset = 0;\n\n    int xfrac = 0;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    int32_t maxxmx = 0, minxhx = 0;\n\n    int spix = 0;\n    int ycur =  yh & ~3;\n    int ylfar = yl | 3;\n\n    int valid_y = 1;\n    //int length = 0;\n    int32_t xrsc = 0, xlsc = 0/*, stickybit = 0*/;\n    int32_t yllimit = yl;\n    int32_t yhlimit = yh;\n\n    xfrac = 0;\n    xend = xright >> 16;\n\n\n    for (k = ycur; k <= ylfar; k++)\n    {\n        if (k == ym)\n            xleft = xl & ~1;\n\n        spix = k & 3;\n\n        if (!(k & ~0xfff))\n        {\n            j = k >> 2;\n            valid_y = !(k < yhlimit || k >= yllimit);\n\n            if (spix == 0)\n            {\n                maxxmx = 0;\n                minxhx = 0xfff;\n            }\n\n            xrsc = (xright >> 13) & 0x7ffe;\n\n\n\n            xlsc = (xleft >> 13) & 0x7ffe;\n\n            if (valid_y)\n            {\n                maxxmx = (((xlsc >> 3) & 0xfff) > maxxmx) ? (xlsc >> 3) & 0xfff : maxxmx;\n                minxhx = (((xrsc >> 3) & 0xfff) < minxhx) ? (xrsc >> 3) & 0xfff : minxhx;\n            }\n\n            if (spix == 0)\n            {\n                wstate->span[j].unscrx = xend;\n                wstate->span[j].s = s & ~0x3ff;\n                wstate->span[j].t = t & ~0x3ff;\n            }\n\n            if (spix == 3)\n            {\n                wstate->span[j].lx = maxxmx;\n                wstate->span[j].rx = minxhx;\n\n\n            }\n\n\n        }\n\n        if (spix == 3)\n        {\n            t += dtde;\n        }\n\n\n\n    }\n\n    loading_pipeline(wstate, yhlimit >> 2, yllimit >> 2, tilenum, coord_quad, ltlut);\n}\n\nvoid rdp_set_tile_size(struct rdp_state* wstate, const uint32_t* args)\n{\n    int tilenum = (args[1] >> 24) & 0x7;\n    wstate->tile[tilenum].sl = (args[0] >> 12) & 0xfff;\n    wstate->tile[tilenum].tl = (args[0] >>  0) & 0xfff;\n    wstate->tile[tilenum].sh = (args[1] >> 12) & 0xfff;\n    wstate->tile[tilenum].th = (args[1] >>  0) & 0xfff;\n\n    calculate_clamp_diffs(&wstate->tile[tilenum]);\n}\n\nvoid rdp_load_block(struct rdp_state* wstate, const uint32_t* args)\n{\n    int tilenum = (args[1] >> 24) & 0x7;\n    uint16_t sl, sh, tl, dxt;\n\n\n    wstate->tile[tilenum].sl = sl = ((args[0] >> 12) & 0xfff);\n    wstate->tile[tilenum].tl = tl = ((args[0] >>  0) & 0xfff);\n    wstate->tile[tilenum].sh = sh = ((args[1] >> 12) & 0xfff);\n    wstate->tile[tilenum].th = dxt  = ((args[1] >>  0) & 0xfff);\n\n    calculate_clamp_diffs(&wstate->tile[tilenum]);\n\n    int tlclamped = tl & 0x3ff;\n\n    int32_t lewdata[10];\n\n    lewdata[0] = (args[0] & 0xff000000) | (0x10 << 19) | (tilenum << 16) | ((tlclamped << 2) | 3);\n    lewdata[1] = (((tlclamped << 2) | 3) << 16) | (tlclamped << 2);\n    lewdata[2] = sh << 16;\n    lewdata[3] = sl << 16;\n    lewdata[4] = sh << 16;\n    lewdata[5] = ((sl << 3) << 16) | (tl << 3);\n    lewdata[6] = (dxt & 0xff) << 8;\n    lewdata[7] = ((0x80 >> wstate->ti_size) << 16) | (dxt >> 8);\n    lewdata[8] = 0x20;\n    lewdata[9] = 0x20;\n\n    edgewalker_for_loads(wstate, lewdata);\n\n}\n\nstatic void tile_tlut_common_cs_decoder(struct rdp_state* wstate, const uint32_t* args)\n{\n    int tilenum = (args[1] >> 24) & 0x7;\n    uint16_t sl, tl, sh, th;\n\n\n    wstate->tile[tilenum].sl = sl = ((args[0] >> 12) & 0xfff);\n    wstate->tile[tilenum].tl = tl = ((args[0] >>  0) & 0xfff);\n    wstate->tile[tilenum].sh = sh = ((args[1] >> 12) & 0xfff);\n    wstate->tile[tilenum].th = th = ((args[1] >>  0) & 0xfff);\n\n    calculate_clamp_diffs(&wstate->tile[tilenum]);\n\n\n    int32_t lewdata[10];\n\n    lewdata[0] = (args[0] & 0xff000000) | (0x10 << 19) | (tilenum << 16) | (th | 3);\n    lewdata[1] = ((th | 3) << 16) | (tl);\n    lewdata[2] = ((sh >> 2) << 16) | ((sh & 3) << 14);\n    lewdata[3] = ((sl >> 2) << 16) | ((sl & 3) << 14);\n    lewdata[4] = ((sh >> 2) << 16) | ((sh & 3) << 14);\n    lewdata[5] = ((sl << 3) << 16) | (tl << 3);\n    lewdata[6] = 0;\n    lewdata[7] = (0x200 >> wstate->ti_size) << 16;\n    lewdata[8] = 0x20;\n    lewdata[9] = 0x20;\n\n    edgewalker_for_loads(wstate, lewdata);\n}\n\nvoid rdp_load_tlut(struct rdp_state* wstate, const uint32_t* args)\n{\n    tile_tlut_common_cs_decoder(wstate, args);\n}\n\nvoid rdp_load_tile(struct rdp_state* wstate, const uint32_t* args)\n{\n    tile_tlut_common_cs_decoder(wstate, args);\n}\n\nvoid rdp_set_tile(struct rdp_state* wstate, const uint32_t* args)\n{\n    int tilenum = (args[1] >> 24) & 0x7;\n\n    wstate->tile[tilenum].format    = (args[0] >> 21) & 0x7;\n    wstate->tile[tilenum].size      = (args[0] >> 19) & 0x3;\n    wstate->tile[tilenum].line      = (args[0] >>  9) & 0x1ff;\n    wstate->tile[tilenum].tmem      = (args[0] >>  0) & 0x1ff;\n    wstate->tile[tilenum].palette   = (args[1] >> 20) & 0xf;\n    wstate->tile[tilenum].ct        = (args[1] >> 19) & 0x1;\n    wstate->tile[tilenum].mt        = (args[1] >> 18) & 0x1;\n    wstate->tile[tilenum].mask_t    = (args[1] >> 14) & 0xf;\n    wstate->tile[tilenum].shift_t   = (args[1] >> 10) & 0xf;\n    wstate->tile[tilenum].cs        = (args[1] >>  9) & 0x1;\n    wstate->tile[tilenum].ms        = (args[1] >>  8) & 0x1;\n    wstate->tile[tilenum].mask_s    = (args[1] >>  4) & 0xf;\n    wstate->tile[tilenum].shift_s   = (args[1] >>  0) & 0xf;\n\n    calculate_tile_derivs(&wstate->tile[tilenum]);\n}\n\nvoid rdp_set_texture_image(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->ti_format   = (args[0] >> 21) & 0x7;\n    wstate->ti_size     = (args[0] >> 19) & 0x3;\n    wstate->ti_width    = (args[0] & 0x3ff) + 1;\n    wstate->ti_address  = args[1] & 0x0ffffff;\n\n\n\n}\n\nvoid rdp_set_convert(struct rdp_state* wstate, const uint32_t* args)\n{\n    int32_t k0 = (args[0] >> 13) & 0x1ff;\n    int32_t k1 = (args[0] >> 4) & 0x1ff;\n    int32_t k2 = ((args[0] & 0xf) << 5) | ((args[1] >> 27) & 0x1f);\n    int32_t k3 = (args[1] >> 18) & 0x1ff;\n    wstate->k0_tf = (SIGN(k0, 9) << 1) + 1;\n    wstate->k1_tf = (SIGN(k1, 9) << 1) + 1;\n    wstate->k2_tf = (SIGN(k2, 9) << 1) + 1;\n    wstate->k3_tf = (SIGN(k3, 9) << 1) + 1;\n    wstate->k4 = (args[1] >> 9) & 0x1ff;\n    wstate->k5 = args[1] & 0x1ff;\n}\n\nstatic void tex_init_lut(void)\n{\n    tmem_init_lut();\n    tcoord_init_lut();\n}\n\nstatic void tex_init(struct rdp_state* wstate)\n{\n    int i;\n    tcoord_init(wstate);\n\n    for (i = 0; i < 8; i++)\n    {\n        calculate_tile_derivs(&wstate->tile[i]);\n        calculate_clamp_diffs(&wstate->tile[i]);\n    }\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/tmem.c",
    "content": "#ifdef N64VIDEO_C\n\n#define tmem16 ((uint16_t*)wstate->tmem)\n#define tc16   ((uint16_t*)wstate->tmem)\n#define tlut   ((uint16_t*)(&wstate->tmem[0x800]))\n\nstatic uint8_t replicated_rgba[32];\n\n#define GET_LOW_RGBA16_TMEM(x)  (replicated_rgba[((x) >> 1) & 0x1f])\n#define GET_MED_RGBA16_TMEM(x)  (replicated_rgba[((x) >> 6) & 0x1f])\n#define GET_HI_RGBA16_TMEM(x)   (replicated_rgba[(x) >> 11])\n\nstatic void sort_tmem_idx(uint32_t *idx, uint32_t idxa, uint32_t idxb, uint32_t idxc, uint32_t idxd, uint32_t bankno)\n{\n    if ((idxa & 3) == bankno)\n        *idx = idxa & 0x3ff;\n    else if ((idxb & 3) == bankno)\n        *idx = idxb & 0x3ff;\n    else if ((idxc & 3) == bankno)\n        *idx = idxc & 0x3ff;\n    else if ((idxd & 3) == bankno)\n        *idx = idxd & 0x3ff;\n    else\n        *idx = 0;\n}\n\nstatic void sort_tmem_shorts_lowhalf(uint32_t* bindshort, uint32_t short0, uint32_t short1, uint32_t short2, uint32_t short3, uint32_t bankno)\n{\n    switch(bankno)\n    {\n    case 0:\n        *bindshort = short0;\n        break;\n    case 1:\n        *bindshort = short1;\n        break;\n    case 2:\n        *bindshort = short2;\n        break;\n    case 3:\n        *bindshort = short3;\n        break;\n    }\n}\n\nstatic void compute_color_index(struct rdp_state* wstate, uint32_t* cidx, uint32_t readshort, uint32_t nybbleoffset, uint32_t tilenum)\n{\n    uint32_t lownib, hinib;\n    if (wstate->tile[tilenum].size == PIXEL_SIZE_4BIT)\n    {\n        lownib = (nybbleoffset ^ 3) << 2;\n        hinib = wstate->tile[tilenum].palette;\n    }\n    else\n    {\n        lownib = ((nybbleoffset & 2) ^ 2) << 2;\n        hinib = lownib ? ((readshort >> 12) & 0xf) : ((readshort >> 4) & 0xf);\n    }\n    lownib = (readshort >> lownib) & 0xf;\n    *cidx = (hinib << 4) | lownib;\n}\n\nstatic INLINE void fetch_texel(struct rdp_state* wstate, struct color *color, int s, int t, uint32_t tilenum)\n{\n    uint32_t tbase = wstate->tile[tilenum].line * (t & 0xff) + wstate->tile[tilenum].tmem;\n\n\n\n    uint32_t tpal   = wstate->tile[tilenum].palette;\n\n\n\n\n\n\n\n\n    uint32_t taddr = 0;\n\n\n\n\n\n    switch (wstate->tile[tilenum].f.notlutswitch)\n    {\n    case TEXEL_RGBA4:\n        {\n            taddr = ((tbase << 4) + s) >> 1;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n            uint8_t byteval, c;\n\n            byteval = wstate->tmem[taddr & 0xfff];\n            c = ((s & 1)) ? (byteval & 0xf) : (byteval >> 4);\n            c |= (c << 4);\n            color->r = c;\n            color->g = c;\n            color->b = c;\n            color->a = c;\n        }\n        break;\n    case TEXEL_RGBA8:\n        {\n            taddr = (tbase << 3) + s;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            uint8_t p;\n\n            p = wstate->tmem[taddr & 0xfff];\n            color->r = p;\n            color->g = p;\n            color->b = p;\n            color->a = p;\n        }\n        break;\n    case TEXEL_RGBA16:\n        {\n            taddr = (tbase << 2) + s;\n            taddr ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n\n            uint16_t c;\n\n            c = tc16[taddr & 0x7ff];\n            color->r = GET_HI_RGBA16_TMEM(c);\n            color->g = GET_MED_RGBA16_TMEM(c);\n            color->b = GET_LOW_RGBA16_TMEM(c);\n            color->a = (c & 1) ? 0xff : 0;\n        }\n        break;\n    case TEXEL_RGBA32:\n        {\n\n\n\n            taddr = (tbase << 2) + s;\n            taddr ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n            uint16_t c;\n\n\n            taddr &= 0x3ff;\n            c = tc16[taddr];\n            color->r = c >> 8;\n            color->g = c & 0xff;\n            c = tc16[taddr | 0x400];\n            color->b = c >> 8;\n            color->a = c & 0xff;\n        }\n        break;\n    case TEXEL_YUV4:\n        {\n            taddr = (tbase << 3) + s;\n\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            int32_t u, save;\n\n            save = wstate->tmem[taddr & 0x7ff];\n\n            save &= 0xf0;\n            save |= (save >> 4);\n\n            u = save - 0x80;\n\n            color->r = u;\n            color->g = u;\n            color->b = save;\n            color->a = save;\n        }\n        break;\n    case TEXEL_YUV8:\n        {\n            taddr = (tbase << 3) + s;\n\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            int32_t u, save;\n\n            save = u = wstate->tmem[taddr & 0x7ff];\n\n            u = u - 0x80;\n\n            color->r = u;\n            color->g = u;\n            color->b = save;\n            color->a = save;\n        }\n        break;\n    case TEXEL_YUV16:\n        {\n            taddr = (tbase << 3) + s;\n            int taddrlow = taddr >> 1;\n\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n            taddrlow ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n            taddr &= 0x7ff;\n            taddrlow &= 0x3ff;\n\n            uint16_t c = tc16[taddrlow];\n\n            int32_t y, u, v;\n            y = wstate->tmem[taddr | 0x800];\n            u = c >> 8;\n            v = c & 0xff;\n\n            u = u - 0x80;\n            v = v - 0x80;\n\n\n\n            color->r = u;\n            color->g = v;\n            color->b = y;\n            color->a = y;\n        }\n        break;\n    case TEXEL_YUV32:\n        {\n            int taddrlow;\n            uint16_t c;\n            int32_t y, u, v;\n\n            taddr = (tbase << 3) + s;\n            taddrlow = taddr >> 1;\n\n            taddrlow ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n            taddrlow &= 0x3ff;\n\n            c = tc16[taddrlow];\n\n            u = c >> 8;\n            v = c & 0xff;\n\n            u = u - 0x80;\n            v = v - 0x80;\n\n            color->r = u;\n            color->g = v;\n\n            if (s & 1)\n            {\n                taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n                taddr &= 0x7ff;\n                y = wstate->tmem[taddr | 0x800];\n\n                color->b = y;\n                color->a = y;\n            }\n            else\n            {\n                y = tc16[taddrlow | 0x400];\n\n                color->b = y >> 8;\n                color->a = ((y >> 8) & 0xf) | (y & 0xf0);\n            }\n        }\n        break;\n    case TEXEL_CI4:\n        {\n            taddr = ((tbase << 4) + s) >> 1;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            uint8_t p;\n\n\n\n            p = wstate->tmem[taddr & 0xfff];\n            p = (s & 1) ? (p & 0xf) : (p >> 4);\n            p = (uint8_t)(tpal << 4) | p;\n            color->r = color->g = color->b = color->a = p;\n        }\n        break;\n    case TEXEL_CI8:\n        {\n            taddr = (tbase << 3) + s;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            uint8_t p;\n\n\n            p = wstate->tmem[taddr & 0xfff];\n            color->r = p;\n            color->g = p;\n            color->b = p;\n            color->a = p;\n        }\n        break;\n    case TEXEL_CI16:\n    case TEXEL_CI32:\n        {\n            taddr = (tbase << 2) + s;\n            taddr ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n            uint16_t c;\n\n            c = tc16[taddr & 0x7ff];\n            color->r = c >> 8;\n            color->g = c & 0xff;\n            color->b = color->r;\n            color->a = color->g;\n        }\n        break;\n    case TEXEL_IA4:\n        {\n            taddr = ((tbase << 4) + s) >> 1;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            uint8_t p, i;\n\n\n            p = wstate->tmem[taddr & 0xfff];\n            p = (s & 1) ? (p & 0xf) : (p >> 4);\n            i = p & 0xe;\n            i = (i << 4) | (i << 1) | (i >> 2);\n            color->r = i;\n            color->g = i;\n            color->b = i;\n            color->a = (p & 0x1) ? 0xff : 0;\n        }\n        break;\n    case TEXEL_IA8:\n        {\n            taddr = (tbase << 3) + s;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            uint8_t p, i;\n\n\n            p = wstate->tmem[taddr & 0xfff];\n            i = p & 0xf0;\n            i |= (i >> 4);\n            color->r = i;\n            color->g = i;\n            color->b = i;\n            color->a = ((p & 0xf) << 4) | (p & 0xf);\n        }\n        break;\n    case TEXEL_IA16:\n        {\n\n\n            taddr = (tbase << 2) + s;\n            taddr ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n            uint16_t c;\n\n            c = tc16[taddr & 0x7ff];\n            color->r = color->g = color->b = (c >> 8);\n            color->a = c & 0xff;\n        }\n        break;\n    case TEXEL_IA32:\n        {\n            taddr = (tbase << 2) + s;\n            taddr ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n            uint16_t c;\n\n            c = tc16[taddr & 0x7ff];\n            color->r = c >> 8;\n            color->g = c & 0xff;\n            color->b = color->r;\n            color->a = color->g;\n        }\n        break;\n    case TEXEL_I4:\n        {\n            taddr = ((tbase << 4) + s) >> 1;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            uint8_t byteval, c;\n\n            byteval = wstate->tmem[taddr & 0xfff];\n            c = (s & 1) ? (byteval & 0xf) : (byteval >> 4);\n            c |= (c << 4);\n            color->r = c;\n            color->g = c;\n            color->b = c;\n            color->a = c;\n        }\n        break;\n    case TEXEL_I8:\n        {\n            taddr = (tbase << 3) + s;\n            taddr ^= ((t & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR);\n\n            uint8_t c;\n\n            c = wstate->tmem[taddr & 0xfff];\n            color->r = c;\n            color->g = c;\n            color->b = c;\n            color->a = c;\n        }\n        break;\n    case TEXEL_I16:\n    case TEXEL_I32:\n    default:\n        {\n            taddr = (tbase << 2) + s;\n            taddr ^= ((t & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR);\n\n            uint16_t c;\n\n            c = tc16[taddr & 0x7ff];\n            color->r = c >> 8;\n            color->g = c & 0xff;\n            color->b = color->r;\n            color->a = color->g;\n        }\n        break;\n    }\n}\n\nstatic INLINE void fetch_texel_quadro(struct rdp_state* wstate, struct color *color0, struct color *color1, struct color *color2, struct color *color3, int s0, int sdiff, int t0, int tdiff, uint32_t tilenum, int unequaluppers)\n{\n\n    uint32_t tbase0 = wstate->tile[tilenum].line * (t0 & 0xff) + wstate->tile[tilenum].tmem;\n\n    int t1 = (t0 & 0xff) + tdiff;\n\n\n\n    int s1 = s0 + sdiff;\n\n    uint32_t tbase2 = wstate->tile[tilenum].line * t1 + wstate->tile[tilenum].tmem;\n    uint32_t tpal = wstate->tile[tilenum].palette;\n    uint32_t xort, ands;\n\n\n\n\n    uint32_t taddr0, taddr1, taddr2, taddr3;\n    uint32_t taddrlow0, taddrlow1, taddrlow2, taddrlow3;\n\n    switch (wstate->tile[tilenum].f.notlutswitch)\n    {\n    case TEXEL_RGBA4:\n        {\n            taddr0 = ((tbase0 << 4) + s0) >> 1;\n            taddr1 = ((tbase0 << 4) + s1) >> 1;\n            taddr2 = ((tbase2 << 4) + s0) >> 1;\n            taddr3 = ((tbase2 << 4) + s1) >> 1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t byteval, c;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n            ands = s0 & 1;\n            byteval = wstate->tmem[taddr0];\n            c = (ands) ? (byteval & 0xf) : (byteval >> 4);\n            c |= (c << 4);\n            color0->r = c;\n            color0->g = c;\n            color0->b = c;\n            color0->a = c;\n            byteval = wstate->tmem[taddr2];\n            c = (ands) ? (byteval & 0xf) : (byteval >> 4);\n            c |= (c << 4);\n            color2->r = c;\n            color2->g = c;\n            color2->b = c;\n            color2->a = c;\n\n            ands = s1 & 1;\n            byteval = wstate->tmem[taddr1];\n            c = (ands) ? (byteval & 0xf) : (byteval >> 4);\n            c |= (c << 4);\n            color1->r = c;\n            color1->g = c;\n            color1->b = c;\n            color1->a = c;\n            byteval = wstate->tmem[taddr3];\n            c = (ands) ? (byteval & 0xf) : (byteval >> 4);\n            c |= (c << 4);\n            color3->r = c;\n            color3->g = c;\n            color3->b = c;\n            color3->a = c;\n        }\n        break;\n    case TEXEL_RGBA8:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t p;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n            p = wstate->tmem[taddr0];\n            color0->r = p;\n            color0->g = p;\n            color0->b = p;\n            color0->a = p;\n            p = wstate->tmem[taddr2];\n            color2->r = p;\n            color2->g = p;\n            color2->b = p;\n            color2->a = p;\n            p = wstate->tmem[taddr1];\n            color1->r = p;\n            color1->g = p;\n            color1->b = p;\n            color1->a = p;\n            p = wstate->tmem[taddr3];\n            color3->r = p;\n            color3->g = p;\n            color3->b = p;\n            color3->a = p;\n        }\n        break;\n    case TEXEL_RGBA16:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t c0, c1, c2, c3;\n\n            taddr0 &= 0x7ff;\n            taddr1 &= 0x7ff;\n            taddr2 &= 0x7ff;\n            taddr3 &= 0x7ff;\n            c0 = tc16[taddr0];\n            c1 = tc16[taddr1];\n            c2 = tc16[taddr2];\n            c3 = tc16[taddr3];\n            color0->r = GET_HI_RGBA16_TMEM(c0);\n            color0->g = GET_MED_RGBA16_TMEM(c0);\n            color0->b = GET_LOW_RGBA16_TMEM(c0);\n            color0->a = (c0 & 1) ? 0xff : 0;\n            color1->r = GET_HI_RGBA16_TMEM(c1);\n            color1->g = GET_MED_RGBA16_TMEM(c1);\n            color1->b = GET_LOW_RGBA16_TMEM(c1);\n            color1->a = (c1 & 1) ? 0xff : 0;\n            color2->r = GET_HI_RGBA16_TMEM(c2);\n            color2->g = GET_MED_RGBA16_TMEM(c2);\n            color2->b = GET_LOW_RGBA16_TMEM(c2);\n            color2->a = (c2 & 1) ? 0xff : 0;\n            color3->r = GET_HI_RGBA16_TMEM(c3);\n            color3->g = GET_MED_RGBA16_TMEM(c3);\n            color3->b = GET_LOW_RGBA16_TMEM(c3);\n            color3->a = (c3 & 1) ? 0xff : 0;\n        }\n        break;\n    case TEXEL_RGBA32:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint16_t c0, c1, c2, c3;\n\n            taddr0 &= 0x3ff;\n            taddr1 &= 0x3ff;\n            taddr2 &= 0x3ff;\n            taddr3 &= 0x3ff;\n            c0 = tc16[taddr0];\n            color0->r = c0 >> 8;\n            color0->g = c0 & 0xff;\n            c0 = tc16[taddr0 | 0x400];\n            color0->b = c0 >>  8;\n            color0->a = c0 & 0xff;\n            c1 = tc16[taddr1];\n            color1->r = c1 >> 8;\n            color1->g = c1 & 0xff;\n            c1 = tc16[taddr1 | 0x400];\n            color1->b = c1 >>  8;\n            color1->a = c1 & 0xff;\n            c2 = tc16[taddr2];\n            color2->r = c2 >> 8;\n            color2->g = c2 & 0xff;\n            c2 = tc16[taddr2 | 0x400];\n            color2->b = c2 >>  8;\n            color2->a = c2 & 0xff;\n            c3 = tc16[taddr3];\n            color3->r = c3 >> 8;\n            color3->g = c3 & 0xff;\n            c3 = tc16[taddr3 | 0x400];\n            color3->b = c3 >>  8;\n            color3->a = c3 & 0xff;\n        }\n        break;\n    case TEXEL_YUV4:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1 + sdiff;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1 + sdiff;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            int32_t u0, u1, u2, u3, save0, save1, save2, save3;\n\n            save0 = wstate->tmem[taddr0 & 0x7ff];\n            save0 &= 0xf0;\n            save0 |= (save0 >> 4);\n            u0 = save0 - 0x80;\n\n            save1 = wstate->tmem[taddr1 & 0x7ff];\n            save1 &= 0xf0;\n            save1 |= (save1 >> 4);\n            u1 = save1 - 0x80;\n\n            save2 = wstate->tmem[taddr2 & 0x7ff];\n            save2 &= 0xf0;\n            save2 |= (save2 >> 4);\n            u2 = save2 - 0x80;\n\n            save3 = wstate->tmem[taddr3 & 0x7ff];\n            save3 &= 0xf0;\n            save3 |= (save3 >> 4);\n            u3 = save3 - 0x80;\n\n            color0->r = u0;\n            color0->g = u0;\n            color1->r = u1;\n            color1->g = u1;\n            color2->r = u2;\n            color2->g = u2;\n            color3->r = u3;\n            color3->g = u3;\n\n            if (unequaluppers)\n            {\n                color0->b = color0->a = save3;\n                color1->b = color1->a = save2;\n                color2->b = color2->a = save1;\n                color3->b = color3->a = save0;\n            }\n            else\n            {\n                color0->b = color0->a = save0;\n                color1->b = color1->a = save1;\n                color2->b = color2->a = save2;\n                color3->b = color3->a = save3;\n            }\n        }\n        break;\n    case TEXEL_YUV8:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1 + sdiff;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1 + sdiff;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            int32_t u0, u1, u2, u3, save0, save1, save2, save3;\n\n            save0 = u0 = wstate->tmem[taddr0 & 0x7ff];\n            u0 = u0 - 0x80;\n            save1 = u1 = wstate->tmem[taddr1 & 0x7ff];\n            u1 = u1 - 0x80;\n            save2 = u2 = wstate->tmem[taddr2 & 0x7ff];\n            u2 = u2 - 0x80;\n            save3 = u3 = wstate->tmem[taddr3 & 0x7ff];\n            u3 = u3 - 0x80;\n\n            color0->r = u0;\n            color0->g = u0;\n            color1->r = u1;\n            color1->g = u1;\n            color2->r = u2;\n            color2->g = u2;\n            color3->r = u3;\n            color3->g = u3;\n\n            if (unequaluppers)\n            {\n                color0->b = color0->a = save3;\n                color1->b = color1->a = save2;\n                color2->b = color2->a = save1;\n                color3->b = color3->a = save0;\n            }\n            else\n            {\n                color0->b = color0->a = save0;\n                color1->b = color1->a = save1;\n                color2->b = color2->a = save2;\n                color3->b = color3->a = save3;\n            }\n        }\n        break;\n    case TEXEL_YUV16:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n\n\n            taddrlow0 = (taddr0) >> 1;\n            taddrlow1 = (taddr1 + sdiff) >> 1;\n            taddrlow2 = (taddr2) >> 1;\n            taddrlow3 = (taddr3 + sdiff) >> 1;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddrlow0 ^= xort;\n            taddrlow1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddrlow2 ^= xort;\n            taddrlow3 ^= xort;\n\n            taddr0 &= 0x7ff;\n            taddr1 &= 0x7ff;\n            taddr2 &= 0x7ff;\n            taddr3 &= 0x7ff;\n            taddrlow0 &= 0x3ff;\n            taddrlow1 &= 0x3ff;\n            taddrlow2 &= 0x3ff;\n            taddrlow3 &= 0x3ff;\n\n            uint16_t c0, c1, c2, c3;\n            int32_t y0, y1, y2, y3, u0, u1, u2, u3, v0, v1, v2, v3;\n\n            c0 = tc16[taddrlow0];\n            c1 = tc16[taddrlow1];\n            c2 = tc16[taddrlow2];\n            c3 = tc16[taddrlow3];\n\n            y0 = wstate->tmem[taddr0 | 0x800];\n            u0 = c0 >> 8;\n            v0 = c0 & 0xff;\n            y1 = wstate->tmem[taddr1 | 0x800];\n            u1 = c1 >> 8;\n            v1 = c1 & 0xff;\n            y2 = wstate->tmem[taddr2 | 0x800];\n            u2 = c2 >> 8;\n            v2 = c2 & 0xff;\n            y3 = wstate->tmem[taddr3 | 0x800];\n            u3 = c3 >> 8;\n            v3 = c3 & 0xff;\n\n            u0 = u0 - 0x80;\n            v0 = v0 - 0x80;\n            u1 = u1 - 0x80;\n            v1 = v1 - 0x80;\n            u2 = u2 - 0x80;\n            v2 = v2 - 0x80;\n            u3 = u3 - 0x80;\n            v3 = v3 - 0x80;\n\n            color0->r = u0;\n            color0->g = v0;\n            color1->r = u1;\n            color1->g = v1;\n            color2->r = u2;\n            color2->g = v2;\n            color3->r = u3;\n            color3->g = v3;\n\n            color0->b = color0->a = y0;\n            color1->b = color1->a = y1;\n            color2->b = color2->a = y2;\n            color3->b = color3->a = y3;\n        }\n        break;\n    case TEXEL_YUV32:\n        {\n            uint16_t c0, c1, c2, c3;\n            int32_t y0, y1, y2, y3, u0, u1, u2, u3, v0, v1, v2, v3;\n            uint32_t xort0, xort1;\n\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n\n            taddrlow0 = (taddr0) >> 1;\n            taddrlow1 = (taddr1 + sdiff) >> 1;\n            taddrlow2 = (taddr2) >> 1;\n            taddrlow3 = (taddr3 + sdiff) >> 1;\n\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddrlow0 ^= xort;\n            taddrlow1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddrlow2 ^= xort;\n            taddrlow3 ^= xort;\n\n            taddrlow0 &= 0x3ff;\n            taddrlow1 &= 0x3ff;\n            taddrlow2 &= 0x3ff;\n            taddrlow3 &= 0x3ff;\n\n            c0 = tc16[taddrlow0];\n            c1 = tc16[taddrlow1];\n            c2 = tc16[taddrlow2];\n            c3 = tc16[taddrlow3];\n\n            u0 = c0 >> 8;\n            v0 = c0 & 0xff;\n            u1 = c1 >> 8;\n            v1 = c1 & 0xff;\n            u2 = c2 >> 8;\n            v2 = c2 & 0xff;\n            u3 = c3 >> 8;\n            v3 = c3 & 0xff;\n\n            u0 = u0 - 0x80;\n            v0 = v0 - 0x80;\n            u1 = u1 - 0x80;\n            v1 = v1 - 0x80;\n            u2 = u2 - 0x80;\n            v2 = v2 - 0x80;\n            u3 = u3 - 0x80;\n            v3 = v3 - 0x80;\n\n            color0->r = u0;\n            color0->g = v0;\n            color1->r = u1;\n            color1->g = v1;\n            color2->r = u2;\n            color2->g = v2;\n            color3->r = u3;\n            color3->g = v3;\n\n            xort0 = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            xort1 = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n\n            if (s0 & 1)\n            {\n                taddr0 ^= xort0;\n                taddr2 ^= xort1;\n\n                taddr0 &= 0x7ff;\n                taddr2 &= 0x7ff;\n\n                y0 = wstate->tmem[taddr0 | 0x800];\n                y2 = wstate->tmem[taddr2 | 0x800];\n\n                color0->b = color0->a = y0;\n                color2->b = color2->a = y2;\n            }\n            else\n            {\n                y0 = tc16[taddrlow0 | 0x400];\n                y2 = tc16[taddrlow2 | 0x400];\n\n                color0->b = y0 >> 8;\n                color0->a = ((y0 >> 8) & 0xf) | (y0 & 0xf0);\n                color2->b = y2 >> 8;\n                color2->a = ((y2 >> 8) & 0xf) | (y2 & 0xf0);\n            }\n\n            if (s1 & 1)\n            {\n                taddr1 ^= xort0;\n                taddr3 ^= xort1;\n\n                taddr1 &= 0x7ff;\n                taddr3 &= 0x7ff;\n\n                y1 = wstate->tmem[taddr1 | 0x800];\n                y3 = wstate->tmem[taddr3 | 0x800];\n\n                color1->b = color1->a = y1;\n                color3->b = color3->a = y3;\n            }\n            else\n            {\n                taddr1 ^= xort0;\n                taddr3 ^= xort1;\n\n                taddr1 = (taddr1 >> 1) & 0x3ff;\n                taddr3 = (taddr3 >> 1) & 0x3ff;\n\n                y1 = tc16[taddr1 | 0x400];\n                y3 = tc16[taddr3 | 0x400];\n\n                color1->b = y1 >> 8;\n                color1->a = ((y1 >> 8) & 0xf) | (y1 & 0xf0);\n                color3->b = y3 >> 8;\n                color3->a = ((y3 >> 8) & 0xf) | (y3 & 0xf0);\n            }\n        }\n        break;\n    case TEXEL_CI4:\n        {\n            taddr0 = ((tbase0 << 4) + s0) >> 1;\n            taddr1 = ((tbase0 << 4) + s1) >> 1;\n            taddr2 = ((tbase2 << 4) + s0) >> 1;\n            taddr3 = ((tbase2 << 4) + s1) >> 1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t p;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n            ands = s0 & 1;\n            p = wstate->tmem[taddr0];\n            p = (ands) ? (p & 0xf) : (p >> 4);\n            p = (tpal << 4) | p;\n            color0->r = color0->g = color0->b = color0->a = p;\n            p = wstate->tmem[taddr2];\n            p = (ands) ? (p & 0xf) : (p >> 4);\n            p = (tpal << 4) | p;\n            color2->r = color2->g = color2->b = color2->a = p;\n\n            ands = s1 & 1;\n            p = wstate->tmem[taddr1];\n            p = (ands) ? (p & 0xf) : (p >> 4);\n            p = (tpal << 4) | p;\n            color1->r = color1->g = color1->b = color1->a = p;\n            p = wstate->tmem[taddr3];\n            p = (ands) ? (p & 0xf) : (p >> 4);\n            p = (tpal << 4) | p;\n            color3->r = color3->g = color3->b = color3->a = p;\n        }\n        break;\n    case TEXEL_CI8:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t p;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n            p = wstate->tmem[taddr0];\n            color0->r = p;\n            color0->g = p;\n            color0->b = p;\n            color0->a = p;\n            p = wstate->tmem[taddr2];\n            color2->r = p;\n            color2->g = p;\n            color2->b = p;\n            color2->a = p;\n            p = wstate->tmem[taddr1];\n            color1->r = p;\n            color1->g = p;\n            color1->b = p;\n            color1->a = p;\n            p = wstate->tmem[taddr3];\n            color3->r = p;\n            color3->g = p;\n            color3->b = p;\n            color3->a = p;\n        }\n        break;\n    case TEXEL_CI16:\n    case TEXEL_CI32:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint16_t c0, c1, c2, c3;\n\n            taddr0 &= 0x7ff;\n            taddr1 &= 0x7ff;\n            taddr2 &= 0x7ff;\n            taddr3 &= 0x7ff;\n            c0 = tc16[taddr0];\n            color0->r = c0 >> 8;\n            color0->g = c0 & 0xff;\n            color0->b = c0 >> 8;\n            color0->a = c0 & 0xff;\n            c1 = tc16[taddr1];\n            color1->r = c1 >> 8;\n            color1->g = c1 & 0xff;\n            color1->b = c1 >> 8;\n            color1->a = c1 & 0xff;\n            c2 = tc16[taddr2];\n            color2->r = c2 >> 8;\n            color2->g = c2 & 0xff;\n            color2->b = c2 >> 8;\n            color2->a = c2 & 0xff;\n            c3 = tc16[taddr3];\n            color3->r = c3 >> 8;\n            color3->g = c3 & 0xff;\n            color3->b = c3 >> 8;\n            color3->a = c3 & 0xff;\n        }\n        break;\n    case TEXEL_IA4:\n        {\n            taddr0 = ((tbase0 << 4) + s0) >> 1;\n            taddr1 = ((tbase0 << 4) + s1) >> 1;\n            taddr2 = ((tbase2 << 4) + s0) >> 1;\n            taddr3 = ((tbase2 << 4) + s1) >> 1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t p, i;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n            ands = s0 & 1;\n            p = wstate->tmem[taddr0];\n            p = ands ? (p & 0xf) : (p >> 4);\n            i = p & 0xe;\n            i = (i << 4) | (i << 1) | (i >> 2);\n            color0->r = i;\n            color0->g = i;\n            color0->b = i;\n            color0->a = (p & 0x1) ? 0xff : 0;\n            p = wstate->tmem[taddr2];\n            p = ands ? (p & 0xf) : (p >> 4);\n            i = p & 0xe;\n            i = (i << 4) | (i << 1) | (i >> 2);\n            color2->r = i;\n            color2->g = i;\n            color2->b = i;\n            color2->a = (p & 0x1) ? 0xff : 0;\n\n            ands = s1 & 1;\n            p = wstate->tmem[taddr1];\n            p = ands ? (p & 0xf) : (p >> 4);\n            i = p & 0xe;\n            i = (i << 4) | (i << 1) | (i >> 2);\n            color1->r = i;\n            color1->g = i;\n            color1->b = i;\n            color1->a = (p & 0x1) ? 0xff : 0;\n            p = wstate->tmem[taddr3];\n            p = ands ? (p & 0xf) : (p >> 4);\n            i = p & 0xe;\n            i = (i << 4) | (i << 1) | (i >> 2);\n            color3->r = i;\n            color3->g = i;\n            color3->b = i;\n            color3->a = (p & 0x1) ? 0xff : 0;\n        }\n        break;\n    case TEXEL_IA8:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t p, i;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n            p = wstate->tmem[taddr0];\n            i = p & 0xf0;\n            i |= (i >> 4);\n            color0->r = i;\n            color0->g = i;\n            color0->b = i;\n            color0->a = ((p & 0xf) << 4) | (p & 0xf);\n            p = wstate->tmem[taddr1];\n            i = p & 0xf0;\n            i |= (i >> 4);\n            color1->r = i;\n            color1->g = i;\n            color1->b = i;\n            color1->a = ((p & 0xf) << 4) | (p & 0xf);\n            p = wstate->tmem[taddr2];\n            i = p & 0xf0;\n            i |= (i >> 4);\n            color2->r = i;\n            color2->g = i;\n            color2->b = i;\n            color2->a = ((p & 0xf) << 4) | (p & 0xf);\n            p = wstate->tmem[taddr3];\n            i = p & 0xf0;\n            i |= (i >> 4);\n            color3->r = i;\n            color3->g = i;\n            color3->b = i;\n            color3->a = ((p & 0xf) << 4) | (p & 0xf);\n        }\n        break;\n    case TEXEL_IA16:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint16_t c0, c1, c2, c3;\n\n            taddr0 &= 0x7ff;\n            taddr1 &= 0x7ff;\n            taddr2 &= 0x7ff;\n            taddr3 &= 0x7ff;\n            c0 = tc16[taddr0];\n            color0->r = color0->g = color0->b = c0 >> 8;\n            color0->a = c0 & 0xff;\n            c1 = tc16[taddr1];\n            color1->r = color1->g = color1->b = c1 >> 8;\n            color1->a = c1 & 0xff;\n            c2 = tc16[taddr2];\n            color2->r = color2->g = color2->b = c2 >> 8;\n            color2->a = c2 & 0xff;\n            c3 = tc16[taddr3];\n            color3->r = color3->g = color3->b = c3 >> 8;\n            color3->a = c3 & 0xff;\n\n        }\n        break;\n    case TEXEL_IA32:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint16_t c0, c1, c2, c3;\n\n            taddr0 &= 0x7ff;\n            taddr1 &= 0x7ff;\n            taddr2 &= 0x7ff;\n            taddr3 &= 0x7ff;\n            c0 = tc16[taddr0];\n            color0->r = c0 >> 8;\n            color0->g = c0 & 0xff;\n            color0->b = c0 >> 8;\n            color0->a = c0 & 0xff;\n            c1 = tc16[taddr1];\n            color1->r = c1 >> 8;\n            color1->g = c1 & 0xff;\n            color1->b = c1 >> 8;\n            color1->a = c1 & 0xff;\n            c2 = tc16[taddr2];\n            color2->r = c2 >> 8;\n            color2->g = c2 & 0xff;\n            color2->b = c2 >> 8;\n            color2->a = c2 & 0xff;\n            c3 = tc16[taddr3];\n            color3->r = c3 >> 8;\n            color3->g = c3 & 0xff;\n            color3->b = c3 >> 8;\n            color3->a = c3 & 0xff;\n\n        }\n        break;\n    case TEXEL_I4:\n        {\n            taddr0 = ((tbase0 << 4) + s0) >> 1;\n            taddr1 = ((tbase0 << 4) + s1) >> 1;\n            taddr2 = ((tbase2 << 4) + s0) >> 1;\n            taddr3 = ((tbase2 << 4) + s1) >> 1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t p, c0, c1, c2, c3;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n            ands = s0 & 1;\n            p = wstate->tmem[taddr0];\n            c0 = ands ? (p & 0xf) : (p >> 4);\n            c0 |= (c0 << 4);\n            color0->r = color0->g = color0->b = color0->a = c0;\n            p = wstate->tmem[taddr2];\n            c2 = ands ? (p & 0xf) : (p >> 4);\n            c2 |= (c2 << 4);\n            color2->r = color2->g = color2->b = color2->a = c2;\n\n            ands = s1 & 1;\n            p = wstate->tmem[taddr1];\n            c1 = ands ? (p & 0xf) : (p >> 4);\n            c1 |= (c1 << 4);\n            color1->r = color1->g = color1->b = color1->a = c1;\n            p = wstate->tmem[taddr3];\n            c3 = ands ? (p & 0xf) : (p >> 4);\n            c3 |= (c3 << 4);\n            color3->r = color3->g = color3->b = color3->a = c3;\n\n        }\n        break;\n    case TEXEL_I8:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint32_t p;\n\n            taddr0 &= 0xfff;\n            taddr1 &= 0xfff;\n            taddr2 &= 0xfff;\n            taddr3 &= 0xfff;\n\n            p = wstate->tmem[taddr0];\n            color0->r = p;\n            color0->g = p;\n            color0->b = p;\n            color0->a = p;\n            p = wstate->tmem[taddr1];\n            color1->r = p;\n            color1->g = p;\n            color1->b = p;\n            color1->a = p;\n            p = wstate->tmem[taddr2];\n            color2->r = p;\n            color2->g = p;\n            color2->b = p;\n            color2->a = p;\n            p = wstate->tmem[taddr3];\n            color3->r = p;\n            color3->g = p;\n            color3->b = p;\n            color3->a = p;\n        }\n        break;\n    case TEXEL_I16:\n    case TEXEL_I32:\n    default:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            uint16_t c0, c1, c2, c3;\n\n            taddr0 &= 0x7ff;\n            taddr1 &= 0x7ff;\n            taddr2 &= 0x7ff;\n            taddr3 &= 0x7ff;\n            c0 = tc16[taddr0];\n            color0->r = c0 >> 8;\n            color0->g = c0 & 0xff;\n            color0->b = c0 >> 8;\n            color0->a = c0 & 0xff;\n            c1 = tc16[taddr1];\n            color1->r = c1 >> 8;\n            color1->g = c1 & 0xff;\n            color1->b = c1 >> 8;\n            color1->a = c1 & 0xff;\n            c2 = tc16[taddr2];\n            color2->r = c2 >> 8;\n            color2->g = c2 & 0xff;\n            color2->b = c2 >> 8;\n            color2->a = c2 & 0xff;\n            c3 = tc16[taddr3];\n            color3->r = c3 >> 8;\n            color3->g = c3 & 0xff;\n            color3->b = c3 >> 8;\n            color3->a = c3 & 0xff;\n        }\n        break;\n    }\n}\n\nstatic INLINE void fetch_texel_entlut_quadro(struct rdp_state* wstate, struct color *color0, struct color *color1, struct color *color2, struct color *color3, int s0, int sdiff, int t0, int tdiff, uint32_t tilenum, int isupper, int isupperrg)\n{\n    uint32_t tbase0 = wstate->tile[tilenum].line * (t0 & 0xff) + wstate->tile[tilenum].tmem;\n    int t1 = (t0 & 0xff) + tdiff;\n    int s1;\n\n    uint32_t tbase2 = wstate->tile[tilenum].line * t1 + wstate->tile[tilenum].tmem;\n    uint32_t tpal = wstate->tile[tilenum].palette << 4;\n    uint32_t xort, ands;\n\n    uint32_t taddr0, taddr1, taddr2, taddr3;\n    uint16_t c0, c1, c2, c3;\n\n\n\n\n    uint32_t xorupperrg = isupperrg ? (WORD_ADDR_XOR ^ 3) : WORD_ADDR_XOR;\n\n\n\n    switch(wstate->tile[tilenum].f.tlutswitch)\n    {\n    case 0:\n    case 1:\n    case 2:\n        {\n            s1 = s0 + sdiff;\n            taddr0 = ((tbase0 << 4) + s0) >> 1;\n            taddr1 = ((tbase0 << 4) + s1) >> 1;\n            taddr2 = ((tbase2 << 4) + s0) >> 1;\n            taddr3 = ((tbase2 << 4) + s1) >> 1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            ands = s0 & 1;\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n            c0 = (ands) ? (c0 & 0xf) : (c0 >> 4);\n            taddr0 = (tpal | c0) << 2;\n            c2 = wstate->tmem[taddr2 & 0x7ff];\n            c2 = (ands) ? (c2 & 0xf) : (c2 >> 4);\n            taddr2 = ((tpal | c2) << 2) + 2;\n\n            ands = s1 & 1;\n            c1 = wstate->tmem[taddr1 & 0x7ff];\n            c1 = (ands) ? (c1 & 0xf) : (c1 >> 4);\n            taddr1 = ((tpal | c1) << 2) + 1;\n            c3 = wstate->tmem[taddr3 & 0x7ff];\n            c3 = (ands) ? (c3 & 0xf) : (c3 >> 4);\n            taddr3 = ((tpal | c3) << 2) + 3;\n        }\n        break;\n    case 3:\n        {\n            s1 = s0 + (sdiff << 1);\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n            c0 >>= 4;\n            taddr0 = (tpal | c0) << 2;\n            c2 = wstate->tmem[taddr2 & 0x7ff];\n            c2 >>= 4;\n            taddr2 = ((tpal | c2) << 2) + 2;\n\n            c1 = wstate->tmem[taddr1 & 0x7ff];\n            c1 >>= 4;\n            taddr1 = ((tpal | c1) << 2) + 1;\n            c3 = wstate->tmem[taddr3 & 0x7ff];\n            c3 >>= 4;\n            taddr3 = ((tpal | c3) << 2) + 3;\n        }\n        break;\n    case 4:\n    case 5:\n    case 6:\n        {\n            s1 = s0 + sdiff;\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n            taddr0 = c0 << 2;\n            c2 = wstate->tmem[taddr2 & 0x7ff];\n            taddr2 = (c2 << 2) + 2;\n            c1 = wstate->tmem[taddr1 & 0x7ff];\n            taddr1 = (c1 << 2) + 1;\n            c3 = wstate->tmem[taddr3 & 0x7ff];\n            taddr3 = (c3 << 2) + 3;\n        }\n        break;\n    case 7:\n        {\n            s1 = s0 + (sdiff << 1);\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n            taddr0 = c0 << 2;\n            c2 = wstate->tmem[taddr2 & 0x7ff];\n            taddr2 = (c2 << 2) + 2;\n            c1 = wstate->tmem[taddr1 & 0x7ff];\n            taddr1 = (c1 << 2) + 1;\n            c3 = wstate->tmem[taddr3 & 0x7ff];\n            taddr3 = (c3 << 2) + 3;\n        }\n        break;\n    case 8:\n    case 9:\n    case 10:\n        {\n            s1 = s0 + sdiff;\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            c0 = tc16[taddr0 & 0x3ff];\n            taddr0 = (c0 >> 6) & ~3;\n            c1 = tc16[taddr1 & 0x3ff];\n            taddr1 = ((c1 >> 6) & ~3) + 1;\n            c2 = tc16[taddr2 & 0x3ff];\n            taddr2 = ((c2 >> 6) & ~3) + 2;\n            c3 = tc16[taddr3 & 0x3ff];\n            taddr3 = (c3 >> 6) | 3;\n        }\n        break;\n    case 11:\n        {\n            s1 = s0 + (sdiff << 1);\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n            taddr0 = c0 << 2;\n            c2 = wstate->tmem[taddr2 & 0x7ff];\n            taddr2 = (c2 << 2) + 2;\n            c1 = wstate->tmem[taddr1 & 0x7ff];\n            taddr1 = (c1 << 2) + 1;\n            c3 = wstate->tmem[taddr3 & 0x7ff];\n            taddr3 = (c3 << 2) + 3;\n        }\n        break;\n    case 12:\n    case 13:\n    case 14:\n        {\n            s1 = s0 + sdiff;\n            taddr0 = (tbase0 << 2) + s0;\n            taddr1 = (tbase0 << 2) + s1;\n            taddr2 = (tbase2 << 2) + s0;\n            taddr3 = (tbase2 << 2) + s1;\n\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            c0 = tc16[taddr0 & 0x3ff];\n            taddr0 = (c0 >> 6) & ~3;\n            c1 = tc16[taddr1 & 0x3ff];\n            taddr1 = ((c1 >> 6) & ~3) + 1;\n            c2 = tc16[taddr2 & 0x3ff];\n            taddr2 = ((c2 >> 6) & ~3) + 2;\n            c3 = tc16[taddr3 & 0x3ff];\n            taddr3 = (c3 >> 6) | 3;\n        }\n        break;\n    case 15:\n    default:\n        {\n            s1 = s0 + (sdiff << 1);\n            taddr0 = (tbase0 << 3) + s0;\n            taddr1 = (tbase0 << 3) + s1;\n            taddr2 = (tbase2 << 3) + s0;\n            taddr3 = (tbase2 << 3) + s1;\n\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n            taddr1 ^= xort;\n            xort = (t1 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr2 ^= xort;\n            taddr3 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n            taddr0 = c0 << 2;\n            c2 = wstate->tmem[taddr2 & 0x7ff];\n            taddr2 = (c2 << 2) + 2;\n            c1 = wstate->tmem[taddr1 & 0x7ff];\n            taddr1 = (c1 << 2) + 1;\n            c3 = wstate->tmem[taddr3 & 0x7ff];\n            taddr3 = (c3 << 2) + 3;\n        }\n        break;\n    }\n\n    c0 = tlut[taddr0 ^ xorupperrg];\n    c2 = tlut[taddr2 ^ xorupperrg];\n    c1 = tlut[taddr1 ^ xorupperrg];\n    c3 = tlut[taddr3 ^ xorupperrg];\n\n    if (!wstate->other_modes.tlut_type)\n    {\n        color0->r = GET_HI_RGBA16_TMEM(c0);\n        color0->g = GET_MED_RGBA16_TMEM(c0);\n        color1->r = GET_HI_RGBA16_TMEM(c1);\n        color1->g = GET_MED_RGBA16_TMEM(c1);\n        color2->r = GET_HI_RGBA16_TMEM(c2);\n        color2->g = GET_MED_RGBA16_TMEM(c2);\n        color3->r = GET_HI_RGBA16_TMEM(c3);\n        color3->g = GET_MED_RGBA16_TMEM(c3);\n\n        if (isupper == isupperrg)\n        {\n            color0->b = GET_LOW_RGBA16_TMEM(c0);\n            color0->a = (c0 & 1) ? 0xff : 0;\n            color1->b = GET_LOW_RGBA16_TMEM(c1);\n            color1->a = (c1 & 1) ? 0xff : 0;\n            color2->b = GET_LOW_RGBA16_TMEM(c2);\n            color2->a = (c2 & 1) ? 0xff : 0;\n            color3->b = GET_LOW_RGBA16_TMEM(c3);\n            color3->a = (c3 & 1) ? 0xff : 0;\n        }\n        else\n        {\n            color0->b = GET_LOW_RGBA16_TMEM(c3);\n            color0->a = (c3 & 1) ? 0xff : 0;\n            color1->b = GET_LOW_RGBA16_TMEM(c2);\n            color1->a = (c2 & 1) ? 0xff : 0;\n            color2->b = GET_LOW_RGBA16_TMEM(c1);\n            color2->a = (c1 & 1) ? 0xff : 0;\n            color3->b = GET_LOW_RGBA16_TMEM(c0);\n            color3->a = (c0 & 1) ? 0xff : 0;\n        }\n    }\n    else\n    {\n        color0->r = color0->g = c0 >> 8;\n        color1->r = color1->g = c1 >> 8;\n        color2->r = color2->g = c2 >> 8;\n        color3->r = color3->g = c3 >> 8;\n\n        if (isupper == isupperrg)\n        {\n            color0->b = c0 >> 8;\n            color0->a = c0 & 0xff;\n            color1->b = c1 >> 8;\n            color1->a = c1 & 0xff;\n            color2->b = c2 >> 8;\n            color2->a = c2 & 0xff;\n            color3->b = c3 >> 8;\n            color3->a = c3 & 0xff;\n        }\n        else\n        {\n            color0->b = c3 >> 8;\n            color0->a = c3 & 0xff;\n            color1->b = c2 >> 8;\n            color1->a = c2 & 0xff;\n            color2->b = c1 >> 8;\n            color2->a = c1 & 0xff;\n            color3->b = c0 >> 8;\n            color3->a = c0 & 0xff;\n        }\n    }\n}\n\nstatic INLINE void fetch_texel_entlut_quadro_nearest(struct rdp_state* wstate, struct color *color0, struct color *color1, struct color *color2, struct color *color3, int s0, int t0, uint32_t tilenum, int isupper, int isupperrg)\n{\n    uint32_t tbase0 = wstate->tile[tilenum].line * t0 + wstate->tile[tilenum].tmem;\n    uint32_t tpal = wstate->tile[tilenum].palette << 4;\n    uint32_t xort, ands;\n\n    uint32_t taddr0 = 0;\n    uint16_t c0, c1, c2, c3;\n\n    uint32_t xorupperrg = isupperrg ? (WORD_ADDR_XOR ^ 3) : WORD_ADDR_XOR;\n\n    switch(wstate->tile[tilenum].f.tlutswitch)\n    {\n    case 0:\n    case 1:\n    case 2:\n        {\n            taddr0 = ((tbase0 << 4) + s0) >> 1;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n\n            ands = s0 & 1;\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n            c0 = (ands) ? (c0 & 0xf) : (c0 >> 4);\n\n            taddr0 = (tpal | c0) << 2;\n        }\n        break;\n    case 3:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n\n            c0 >>= 4;\n\n            taddr0 = (tpal | c0) << 2;\n        }\n        break;\n    case 4:\n    case 5:\n    case 6:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n\n            taddr0 = c0 << 2;\n        }\n        break;\n    case 7:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n\n            taddr0 = c0 << 2;\n        }\n        break;\n    case 8:\n    case 9:\n    case 10:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n\n            c0 = tc16[taddr0 & 0x3ff];\n\n            taddr0 = (c0 >> 6) & ~3;\n        }\n        break;\n    case 11:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n\n            taddr0 = c0 << 2;\n        }\n        break;\n    case 12:\n    case 13:\n    case 14:\n        {\n            taddr0 = (tbase0 << 2) + s0;\n            xort = (t0 & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;\n            taddr0 ^= xort;\n\n            c0 = tc16[taddr0 & 0x3ff];\n\n            taddr0 = (c0 >> 6) & ~3;\n        }\n        break;\n    case 15:\n    default:\n        {\n            taddr0 = (tbase0 << 3) + s0;\n            xort = (t0 & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR;\n            taddr0 ^= xort;\n\n            c0 = wstate->tmem[taddr0 & 0x7ff];\n\n            taddr0 = c0 << 2;\n        }\n        break;\n    }\n\n    c0 = tlut[taddr0 ^ xorupperrg];\n    c1 = tlut[(taddr0 + 1) ^ xorupperrg];\n    c2 = tlut[(taddr0 + 2) ^ xorupperrg];\n    c3 = tlut[(taddr0 + 3) ^ xorupperrg];\n\n    if (!wstate->other_modes.tlut_type)\n    {\n        color0->r = GET_HI_RGBA16_TMEM(c0);\n        color0->g = GET_MED_RGBA16_TMEM(c0);\n        color1->r = GET_HI_RGBA16_TMEM(c1);\n        color1->g = GET_MED_RGBA16_TMEM(c1);\n        color2->r = GET_HI_RGBA16_TMEM(c2);\n        color2->g = GET_MED_RGBA16_TMEM(c2);\n        color3->r = GET_HI_RGBA16_TMEM(c3);\n        color3->g = GET_MED_RGBA16_TMEM(c3);\n\n        if (isupper == isupperrg)\n        {\n            color0->b = GET_LOW_RGBA16_TMEM(c0);\n            color0->a = (c0 & 1) ? 0xff : 0;\n            color1->b = GET_LOW_RGBA16_TMEM(c1);\n            color1->a = (c1 & 1) ? 0xff : 0;\n            color2->b = GET_LOW_RGBA16_TMEM(c2);\n            color2->a = (c2 & 1) ? 0xff : 0;\n            color3->b = GET_LOW_RGBA16_TMEM(c3);\n            color3->a = (c3 & 1) ? 0xff : 0;\n        }\n        else\n        {\n            color0->b = GET_LOW_RGBA16_TMEM(c3);\n            color0->a = (c3 & 1) ? 0xff : 0;\n            color1->b = GET_LOW_RGBA16_TMEM(c2);\n            color1->a = (c2 & 1) ? 0xff : 0;\n            color2->b = GET_LOW_RGBA16_TMEM(c1);\n            color2->a = (c1 & 1) ? 0xff : 0;\n            color3->b = GET_LOW_RGBA16_TMEM(c0);\n            color3->a = (c0 & 1) ? 0xff : 0;\n        }\n    }\n    else\n    {\n        color0->r = color0->g = c0 >> 8;\n        color1->r = color1->g = c1 >> 8;\n        color2->r = color2->g = c2 >> 8;\n        color3->r = color3->g = c3 >> 8;\n\n        if (isupper == isupperrg)\n        {\n            color0->b = c0 >> 8;\n            color0->a = c0 & 0xff;\n            color1->b = c1 >> 8;\n            color1->a = c1 & 0xff;\n            color2->b = c2 >> 8;\n            color2->a = c2 & 0xff;\n            color3->b = c3 >> 8;\n            color3->a = c3 & 0xff;\n        }\n        else\n        {\n            color0->b = c3 >> 8;\n            color0->a = c3 & 0xff;\n            color1->b = c2 >> 8;\n            color1->a = c2 & 0xff;\n            color2->b = c1 >> 8;\n            color2->a = c1 & 0xff;\n            color3->b = c0 >> 8;\n            color3->a = c0 & 0xff;\n        }\n    }\n}\n\nstatic void get_tmem_idx(struct rdp_state* wstate, int s, int t, uint32_t tilenum, uint32_t* idx0, uint32_t* idx1, uint32_t* idx2, uint32_t* idx3, uint32_t* bit3flipped, uint32_t* hibit)\n{\n    uint32_t tbase = (wstate->tile[tilenum].line * t) & 0x1ff;\n    tbase += wstate->tile[tilenum].tmem;\n    uint32_t tsize = wstate->tile[tilenum].size;\n    uint32_t tformat = wstate->tile[tilenum].format;\n    uint32_t sshorts = 0;\n\n\n    if (tsize == PIXEL_SIZE_8BIT || tformat == FORMAT_YUV)\n        sshorts = s >> 1;\n    else if (tsize >= PIXEL_SIZE_16BIT)\n        sshorts = s;\n    else\n        sshorts = s >> 2;\n    sshorts &= 0x7ff;\n\n    *bit3flipped = ((sshorts & 2) != 0) ^ (t & 1);\n\n    int tidx_a = ((tbase << 2) + sshorts) & 0x7fd;\n    int tidx_b = (tidx_a + 1) & 0x7ff;\n    int tidx_c = (tidx_a + 2) & 0x7ff;\n    int tidx_d = (tidx_a + 3) & 0x7ff;\n\n    *hibit = (tidx_a & 0x400) != 0;\n\n    if (t & 1)\n    {\n        tidx_a ^= 2;\n        tidx_b ^= 2;\n        tidx_c ^= 2;\n        tidx_d ^= 2;\n    }\n\n\n    sort_tmem_idx(idx0, tidx_a, tidx_b, tidx_c, tidx_d, 0);\n    sort_tmem_idx(idx1, tidx_a, tidx_b, tidx_c, tidx_d, 1);\n    sort_tmem_idx(idx2, tidx_a, tidx_b, tidx_c, tidx_d, 2);\n    sort_tmem_idx(idx3, tidx_a, tidx_b, tidx_c, tidx_d, 3);\n}\n\nstatic void read_tmem_copy(struct rdp_state* wstate, int s, int s1, int s2, int s3, int t, uint32_t tilenum, uint32_t* sortshort, int* hibits, int* lowbits)\n{\n    uint32_t tbase = (wstate->tile[tilenum].line * t) & 0x1ff;\n    tbase += wstate->tile[tilenum].tmem;\n    uint32_t tsize = wstate->tile[tilenum].size;\n    uint32_t tformat = wstate->tile[tilenum].format;\n    uint32_t shbytes = 0, shbytes1 = 0, shbytes2 = 0, shbytes3 = 0;\n    int32_t delta = 0;\n    uint32_t sortidx[8];\n\n\n    if (tsize == PIXEL_SIZE_8BIT || tformat == FORMAT_YUV)\n    {\n        shbytes = s << 1;\n        shbytes1 = s1 << 1;\n        shbytes2 = s2 << 1;\n        shbytes3 = s3 << 1;\n    }\n    else if (tsize >= PIXEL_SIZE_16BIT)\n    {\n        shbytes = s << 2;\n        shbytes1 = s1 << 2;\n        shbytes2 = s2 << 2;\n        shbytes3 = s3 << 2;\n    }\n    else\n    {\n        shbytes = s;\n        shbytes1 = s1;\n        shbytes2 = s2;\n        shbytes3 = s3;\n    }\n\n    shbytes &= 0x1fff;\n    shbytes1 &= 0x1fff;\n    shbytes2 &= 0x1fff;\n    shbytes3 &= 0x1fff;\n\n    int tidx_a, tidx_blow, tidx_bhi, tidx_c, tidx_dlow, tidx_dhi;\n\n    tbase <<= 4;\n    tidx_a = (tbase + shbytes) & 0x1fff;\n    tidx_bhi = (tbase + shbytes1) & 0x1fff;\n    tidx_c = (tbase + shbytes2) & 0x1fff;\n    tidx_dhi = (tbase + shbytes3) & 0x1fff;\n\n    if (tformat == FORMAT_YUV)\n    {\n        delta = shbytes1 - shbytes;\n        tidx_blow = (tidx_a + (delta << 1)) & 0x1fff;\n        tidx_dlow = (tidx_blow + shbytes3 - shbytes) & 0x1fff;\n    }\n    else\n    {\n        tidx_blow = tidx_bhi;\n        tidx_dlow = tidx_dhi;\n    }\n\n    if (t & 1)\n    {\n        tidx_a ^= 8;\n        tidx_blow ^= 8;\n        tidx_bhi ^= 8;\n        tidx_c ^= 8;\n        tidx_dlow ^= 8;\n        tidx_dhi ^= 8;\n    }\n\n    hibits[0] = (tidx_a & 0x1000) != 0;\n    hibits[1] = (tidx_blow & 0x1000) != 0;\n    hibits[2] = (tidx_bhi & 0x1000) != 0;\n    hibits[3] = (tidx_c & 0x1000) != 0;\n    hibits[4] = (tidx_dlow & 0x1000) != 0;\n    hibits[5] = (tidx_dhi & 0x1000) != 0;\n    lowbits[0] = tidx_a & 0xf;\n    lowbits[1] = tidx_blow & 0xf;\n    lowbits[2] = tidx_bhi & 0xf;\n    lowbits[3] = tidx_c & 0xf;\n    lowbits[4] = tidx_dlow & 0xf;\n    lowbits[5] = tidx_dhi & 0xf;\n\n    uint32_t short0, short1, short2, short3;\n\n\n    tidx_a >>= 2;\n    tidx_blow >>= 2;\n    tidx_bhi >>= 2;\n    tidx_c >>= 2;\n    tidx_dlow >>= 2;\n    tidx_dhi >>= 2;\n\n\n    sort_tmem_idx(&sortidx[0], tidx_a, tidx_blow, tidx_c, tidx_dlow, 0);\n    sort_tmem_idx(&sortidx[1], tidx_a, tidx_blow, tidx_c, tidx_dlow, 1);\n    sort_tmem_idx(&sortidx[2], tidx_a, tidx_blow, tidx_c, tidx_dlow, 2);\n    sort_tmem_idx(&sortidx[3], tidx_a, tidx_blow, tidx_c, tidx_dlow, 3);\n\n    short0 = tmem16[sortidx[0] ^ WORD_ADDR_XOR];\n    short1 = tmem16[sortidx[1] ^ WORD_ADDR_XOR];\n    short2 = tmem16[sortidx[2] ^ WORD_ADDR_XOR];\n    short3 = tmem16[sortidx[3] ^ WORD_ADDR_XOR];\n\n\n    sort_tmem_shorts_lowhalf(&sortshort[0], short0, short1, short2, short3, lowbits[0] >> 2);\n    sort_tmem_shorts_lowhalf(&sortshort[1], short0, short1, short2, short3, lowbits[1] >> 2);\n    sort_tmem_shorts_lowhalf(&sortshort[2], short0, short1, short2, short3, lowbits[3] >> 2);\n    sort_tmem_shorts_lowhalf(&sortshort[3], short0, short1, short2, short3, lowbits[4] >> 2);\n\n    if (wstate->other_modes.en_tlut)\n    {\n\n        compute_color_index(wstate, &short0, sortshort[0], lowbits[0] & 3, tilenum);\n        compute_color_index(wstate, &short1, sortshort[1], lowbits[1] & 3, tilenum);\n        compute_color_index(wstate, &short2, sortshort[2], lowbits[3] & 3, tilenum);\n        compute_color_index(wstate, &short3, sortshort[3], lowbits[4] & 3, tilenum);\n\n\n        sortidx[4] = (short0 << 2);\n        sortidx[5] = (short1 << 2) | 1;\n        sortidx[6] = (short2 << 2) | 2;\n        sortidx[7] = (short3 << 2) | 3;\n    }\n    else\n    {\n        sort_tmem_idx(&sortidx[4], tidx_a, tidx_bhi, tidx_c, tidx_dhi, 0);\n        sort_tmem_idx(&sortidx[5], tidx_a, tidx_bhi, tidx_c, tidx_dhi, 1);\n        sort_tmem_idx(&sortidx[6], tidx_a, tidx_bhi, tidx_c, tidx_dhi, 2);\n        sort_tmem_idx(&sortidx[7], tidx_a, tidx_bhi, tidx_c, tidx_dhi, 3);\n    }\n\n    short0 = tmem16[(sortidx[4] | 0x400) ^ WORD_ADDR_XOR];\n    short1 = tmem16[(sortidx[5] | 0x400) ^ WORD_ADDR_XOR];\n    short2 = tmem16[(sortidx[6] | 0x400) ^ WORD_ADDR_XOR];\n    short3 = tmem16[(sortidx[7] | 0x400) ^ WORD_ADDR_XOR];\n\n\n\n    if (wstate->other_modes.en_tlut)\n    {\n        sort_tmem_shorts_lowhalf(&sortshort[4], short0, short1, short2, short3, 0);\n        sort_tmem_shorts_lowhalf(&sortshort[5], short0, short1, short2, short3, 1);\n        sort_tmem_shorts_lowhalf(&sortshort[6], short0, short1, short2, short3, 2);\n        sort_tmem_shorts_lowhalf(&sortshort[7], short0, short1, short2, short3, 3);\n    }\n    else\n    {\n        sort_tmem_shorts_lowhalf(&sortshort[4], short0, short1, short2, short3, lowbits[0] >> 2);\n        sort_tmem_shorts_lowhalf(&sortshort[5], short0, short1, short2, short3, lowbits[2] >> 2);\n        sort_tmem_shorts_lowhalf(&sortshort[6], short0, short1, short2, short3, lowbits[3] >> 2);\n        sort_tmem_shorts_lowhalf(&sortshort[7], short0, short1, short2, short3, lowbits[5] >> 2);\n    }\n}\n\nstatic void tmem_init_lut(void)\n{\n    int i;\n    for (i = 0; i < 32; i++)\n        replicated_rgba[i] = (uint8_t)((i << 3) | ((i >> 2) & 7));\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp/zbuffer.c",
    "content": "#ifdef N64VIDEO_C\n\n#define ZMODE_OPAQUE            0\n#define ZMODE_INTERPENETRATING  1\n#define ZMODE_TRANSPARENT       2\n#define ZMODE_DECAL             3\n\nstatic uint16_t z_com_table[0x40000];\nstatic uint32_t z_complete_dec_table[0x4000];\nstatic uint16_t deltaz_comparator_lut[0x10000];\n\nstatic struct {uint32_t shift; uint32_t add;} z_dec_table[8] = {\n     { 6, 0x00000 },\n     { 5, 0x20000 },\n     { 4, 0x30000 },\n     { 3, 0x38000 },\n     { 2, 0x3c000 },\n     { 1, 0x3e000 },\n     { 0, 0x3f000 },\n     { 0, 0x3f800 },\n};\n\nstatic STRICTINLINE uint32_t z_decompress(uint32_t zb)\n{\n    return z_complete_dec_table[(zb >> 2) & 0x3fff];\n}\n\nstatic INLINE void z_build_com_table(void)\n{\n\n    int z;\n    uint16_t altmem = 0;\n    for(z = 0; z < 0x40000; z++)\n    {\n    switch((z >> 11) & 0x7f)\n    {\n    case 0x00:\n    case 0x01:\n    case 0x02:\n    case 0x03:\n    case 0x04:\n    case 0x05:\n    case 0x06:\n    case 0x07:\n    case 0x08:\n    case 0x09:\n    case 0x0a:\n    case 0x0b:\n    case 0x0c:\n    case 0x0d:\n    case 0x0e:\n    case 0x0f:\n    case 0x10:\n    case 0x11:\n    case 0x12:\n    case 0x13:\n    case 0x14:\n    case 0x15:\n    case 0x16:\n    case 0x17:\n    case 0x18:\n    case 0x19:\n    case 0x1a:\n    case 0x1b:\n    case 0x1c:\n    case 0x1d:\n    case 0x1e:\n    case 0x1f:\n    case 0x20:\n    case 0x21:\n    case 0x22:\n    case 0x23:\n    case 0x24:\n    case 0x25:\n    case 0x26:\n    case 0x27:\n    case 0x28:\n    case 0x29:\n    case 0x2a:\n    case 0x2b:\n    case 0x2c:\n    case 0x2d:\n    case 0x2e:\n    case 0x2f:\n    case 0x30:\n    case 0x31:\n    case 0x32:\n    case 0x33:\n    case 0x34:\n    case 0x35:\n    case 0x36:\n    case 0x37:\n    case 0x38:\n    case 0x39:\n    case 0x3a:\n    case 0x3b:\n    case 0x3c:\n    case 0x3d:\n    case 0x3e:\n    case 0x3f:\n        altmem = (z >> 4) & 0x1ffc;\n        break;\n    case 0x40:\n    case 0x41:\n    case 0x42:\n    case 0x43:\n    case 0x44:\n    case 0x45:\n    case 0x46:\n    case 0x47:\n    case 0x48:\n    case 0x49:\n    case 0x4a:\n    case 0x4b:\n    case 0x4c:\n    case 0x4d:\n    case 0x4e:\n    case 0x4f:\n    case 0x50:\n    case 0x51:\n    case 0x52:\n    case 0x53:\n    case 0x54:\n    case 0x55:\n    case 0x56:\n    case 0x57:\n    case 0x58:\n    case 0x59:\n    case 0x5a:\n    case 0x5b:\n    case 0x5c:\n    case 0x5d:\n    case 0x5e:\n    case 0x5f:\n        altmem = ((z >> 3) & 0x1ffc) | 0x2000;\n        break;\n    case 0x60:\n    case 0x61:\n    case 0x62:\n    case 0x63:\n    case 0x64:\n    case 0x65:\n    case 0x66:\n    case 0x67:\n    case 0x68:\n    case 0x69:\n    case 0x6a:\n    case 0x6b:\n    case 0x6c:\n    case 0x6d:\n    case 0x6e:\n    case 0x6f:\n        altmem = ((z >> 2) & 0x1ffc) | 0x4000;\n        break;\n    case 0x70:\n    case 0x71:\n    case 0x72:\n    case 0x73:\n    case 0x74:\n    case 0x75:\n    case 0x76:\n    case 0x77:\n        altmem = ((z >> 1) & 0x1ffc) | 0x6000;\n        break;\n    case 0x78:\n    case 0x79:\n    case 0x7a:\n    case 0x7b:\n        altmem = (z & 0x1ffc) | 0x8000;\n        break;\n    case 0x7c:\n    case 0x7d:\n        altmem = ((z << 1) & 0x1ffc) | 0xa000;\n        break;\n    case 0x7e:\n        altmem = ((z << 2) & 0x1ffc) | 0xc000;\n        break;\n    case 0x7f:\n        altmem = ((z << 2) & 0x1ffc) | 0xe000;\n        break;\n    default:\n        msg_error(\"z_build_com_table failed\");\n        break;\n    }\n\n    z_com_table[z] = altmem;\n\n    }\n}\n\nstatic STRICTINLINE void z_store(uint32_t zcurpixel, uint32_t z, int dzpixenc)\n{\n    uint16_t zval = z_com_table[z & 0x3ffff]|(uint16_t)(dzpixenc >> 2);\n    uint8_t hval = dzpixenc & 3;\n\n    rdram_write_pair16(zcurpixel, zval, hval, 0);\n}\n\nstatic STRICTINLINE uint32_t dz_decompress(uint32_t dz_compressed)\n{\n    return (1 << dz_compressed);\n}\n\n\nstatic STRICTINLINE uint32_t dz_compress(uint32_t value)\n{\n    int j = 0;\n    if (value & 0xff00)\n        j |= 8;\n    if (value & 0xf0f0)\n        j |= 4;\n    if (value & 0xcccc)\n        j |= 2;\n    if (value & 0xaaaa)\n        j |= 1;\n    return j;\n}\n\nstatic STRICTINLINE uint32_t z_compare(struct rdp_state* wstate, uint32_t zcurpixel, uint32_t sz, uint16_t dzpix, int dzpixenc, uint32_t* blend_en, uint32_t* prewrap, uint32_t* curpixel_cvg, uint32_t curpixel_memcvg)\n{\n\n\n    int force_coplanar = 0;\n    sz &= 0x3ffff;\n\n    uint8_t hval;\n    uint16_t zval;\n    uint32_t oz, dzmem;\n    int32_t rawdzmem;\n\n    if (wstate->other_modes.z_compare_en)\n    {\n        PAIRREAD16(zval, hval, zcurpixel);\n        oz = z_decompress(zval);\n        rawdzmem = ((zval & 3) << 2) | hval;\n        dzmem = dz_decompress(rawdzmem);\n\n\n\n        if (wstate->other_modes.f.realblendershiftersneeded)\n        {\n            wstate->blshifta = clamp(dzpixenc - rawdzmem, 0, 4);\n            wstate->blshiftb = clamp(rawdzmem - dzpixenc, 0, 4);\n\n        }\n\n\n        if (wstate->other_modes.f.interpixelblendershiftersneeded)\n        {\n            wstate->pastblshifta = clamp(dzpixenc - wstate->pastrawdzmem, 0, 4);\n            wstate->pastblshiftb = clamp(wstate->pastrawdzmem - dzpixenc, 0, 4);\n        }\n\n        wstate->pastrawdzmem = rawdzmem;\n\n        int precision_factor = (zval >> 13) & 0xf;\n\n\n\n\n        uint32_t dzmemmodifier;\n        if (precision_factor < 3)\n        {\n            if (dzmem != 0x8000)\n            {\n                dzmemmodifier = 16 >> precision_factor;\n                dzmem <<= 1;\n                if (dzmem < dzmemmodifier)\n                    dzmem = dzmemmodifier;\n\n            }\n            else\n            {\n                force_coplanar = 1;\n                dzmem = 0xffff;\n            }\n        }\n\n\n\n\n\n\n        uint32_t dznew = (uint32_t)deltaz_comparator_lut[dzpix | dzmem];\n\n        uint32_t dznotshift = dznew;\n        dznew <<= 3;\n\n\n        uint32_t farther = force_coplanar || ((sz + dznew) >= oz);\n\n        int overflow = (curpixel_memcvg + *curpixel_cvg) & 8;\n        *blend_en = wstate->other_modes.force_blend || (!overflow && wstate->other_modes.antialias_en && farther);\n\n        *prewrap = overflow;\n\n\n\n        int cvgcoeff = 0;\n        uint32_t dzenc = 0;\n\n        int32_t diff;\n        uint32_t nearer, max, infront;\n\n        switch(wstate->other_modes.z_mode)\n        {\n        case ZMODE_OPAQUE:\n            infront = sz < oz;\n            diff = (int32_t)sz - (int32_t)dznew;\n            nearer = force_coplanar || (diff <= (int32_t)oz);\n            max = (oz == 0x3ffff);\n            return (max || (overflow ? infront : nearer));\n            break;\n        case ZMODE_INTERPENETRATING:\n            infront = sz < oz;\n            if (!infront || !farther || !overflow)\n            {\n                diff = (int32_t)sz - (int32_t)dznew;\n                nearer = force_coplanar || (diff <= (int32_t)oz);\n                max = (oz == 0x3ffff);\n                return (max || (overflow ? infront : nearer));\n            }\n            else\n            {\n                dzenc = dz_compress(dznotshift & 0xffff);\n                cvgcoeff = ((oz >> dzenc) - (sz >> dzenc)) & 0xf;\n                *curpixel_cvg = ((cvgcoeff * (*curpixel_cvg)) >> 3) & 0xf;\n                return 1;\n            }\n            break;\n        case ZMODE_TRANSPARENT:\n            infront = sz < oz;\n            max = (oz == 0x3ffff);\n            return (infront || max);\n            break;\n        case ZMODE_DECAL:\n            diff = (int32_t)sz - (int32_t)dznew;\n            nearer = force_coplanar || (diff <= (int32_t)oz);\n            max = (oz == 0x3ffff);\n            return (farther && nearer && !max);\n            break;\n        }\n        return 0;\n    }\n    else\n    {\n\n\n        if (wstate->other_modes.f.realblendershiftersneeded)\n        {\n            wstate->blshifta = 0;\n            if (dzpixenc < 0xb)\n                wstate->blshiftb = 4;\n            else\n                wstate->blshiftb = 0xf - dzpixenc;\n        }\n\n        if (wstate->other_modes.f.interpixelblendershiftersneeded)\n        {\n            wstate->pastblshifta = 0;\n            if (dzpixenc < 0xb)\n                wstate->pastblshiftb = 4;\n            else\n                wstate->pastblshiftb = 0xf - dzpixenc;\n        }\n\n        wstate->pastrawdzmem = 0xf;\n\n        int overflow = (curpixel_memcvg + *curpixel_cvg) & 8;\n        *blend_en = wstate->other_modes.force_blend || (!overflow && wstate->other_modes.antialias_en);\n        *prewrap = overflow;\n\n        return 1;\n    }\n}\n\nvoid rdp_set_mask_image(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->zb_address  = args[1] & 0x0ffffff;\n}\n\nvoid z_init_lut(void)\n{\n    int i;\n    z_build_com_table();\n\n    uint32_t exponent;\n    uint32_t mantissa;\n    for (i = 0; i < 0x4000; i++)\n    {\n        exponent = (i >> 11) & 7;\n        mantissa = i & 0x7ff;\n        z_complete_dec_table[i] = ((mantissa << z_dec_table[exponent].shift) + z_dec_table[exponent].add) & 0x3ffff;\n    }\n\n    deltaz_comparator_lut[0] = 0;\n    for (i = 1; i < 0x10000; i++)\n    {\n       int k;\n        for (k = 15; k >= 0; k--)\n        {\n            if (i & (1 << k))\n            {\n                deltaz_comparator_lut[i] = 1 << k;\n                break;\n            }\n        }\n    }\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/rdp.c",
    "content": "#ifdef N64VIDEO_C\n\n// bit constants for DP_STATUS\n#define DP_STATUS_XBUS_DMA      0x001   // DMEM DMA mode is set\n#define DP_STATUS_FREEZE        0x002   // Freeze has been set\n#define DP_STATUS_FLUSH         0x004   // Flush has been set\n#define DP_STATUS_START_GCLK    0x008   // Unknown\n#define DP_STATUS_TMEM_BUSY     0x010   // TMEM is in use on the RDP\n#define DP_STATUS_PIPE_BUSY     0x020   // Graphics pipe is in use on the RDP\n#define DP_STATUS_CMD_BUSY      0x040   // RDP is currently executing a command\n#define DP_STATUS_CBUF_BUSY     0x080   // RDRAM RDP command buffer is in use\n#define DP_STATUS_DMA_BUSY      0x100   // DMEM RDP command buffer is in use\n#define DP_STATUS_END_VALID     0x200   // Unknown\n#define DP_STATUS_START_VALID   0x400   // Unknown\n\n#define PIXEL_SIZE_4BIT         0\n#define PIXEL_SIZE_8BIT         1\n#define PIXEL_SIZE_16BIT        2\n#define PIXEL_SIZE_32BIT        3\n\n#define CYCLE_TYPE_1            0\n#define CYCLE_TYPE_2            1\n#define CYCLE_TYPE_COPY         2\n#define CYCLE_TYPE_FILL         3\n\n\n#define FORMAT_RGBA             0\n#define FORMAT_YUV              1\n#define FORMAT_CI               2\n#define FORMAT_IA               3\n#define FORMAT_I                4\n\n\n#define TEXEL_RGBA4             0\n#define TEXEL_RGBA8             1\n#define TEXEL_RGBA16            2\n#define TEXEL_RGBA32            3\n#define TEXEL_YUV4              4\n#define TEXEL_YUV8              5\n#define TEXEL_YUV16             6\n#define TEXEL_YUV32             7\n#define TEXEL_CI4               8\n#define TEXEL_CI8               9\n#define TEXEL_CI16              0xa\n#define TEXEL_CI32              0xb\n#define TEXEL_IA4               0xc\n#define TEXEL_IA8               0xd\n#define TEXEL_IA16              0xe\n#define TEXEL_IA32              0xf\n#define TEXEL_I4                0x10\n#define TEXEL_I8                0x11\n#define TEXEL_I16               0x12\n#define TEXEL_I32               0x13\n\n\n#define SP_INTERRUPT    0x1\n#define SI_INTERRUPT    0x2\n#define AI_INTERRUPT    0x4\n#define VI_INTERRUPT    0x8\n#define PI_INTERRUPT    0x10\n#define DP_INTERRUPT    0x20\n\nstruct color\n{\n    int32_t r, g, b, a;\n};\n\nstruct rectangle\n{\n    uint16_t xl, yl, xh, yh;\n};\n\nstruct other_modes\n{\n    int cycle_type;\n    int persp_tex_en;\n    int detail_tex_en;\n    int sharpen_tex_en;\n    int tex_lod_en;\n    int en_tlut;\n    int tlut_type;\n    int sample_type;\n    int mid_texel;\n    int bi_lerp0;\n    int bi_lerp1;\n    int convert_one;\n    int key_en;\n    int rgb_dither_sel;\n    int alpha_dither_sel;\n    int blend_m1a_0;\n    int blend_m1a_1;\n    int blend_m1b_0;\n    int blend_m1b_1;\n    int blend_m2a_0;\n    int blend_m2a_1;\n    int blend_m2b_0;\n    int blend_m2b_1;\n    int force_blend;\n    int alpha_cvg_select;\n    int cvg_times_alpha;\n    int z_mode;\n    int cvg_dest;\n    int color_on_cvg;\n    int image_read_en;\n    int z_update_en;\n    int z_compare_en;\n    int antialias_en;\n    int z_source_sel;\n    int dither_alpha_en;\n    int alpha_compare_en;\n\n    struct\n    {\n        int stalederivs;\n        int dolod;\n        int partialreject_1cycle;\n        int partialreject_2cycle;\n        int rgb_alpha_dither;\n        int realblendershiftersneeded;\n        int interpixelblendershiftersneeded;\n        int getditherlevel;\n        int textureuselevel0;\n        int textureuselevel1;\n    } f;\n};\n\nstruct spansigs\n{\n    int endspan;\n    int preendspan;\n    int nextspan;\n    int midspan;\n    int longspan;\n    int onelessthanmid;\n};\n\nstruct tile\n{\n    int format;\n    int size;\n    int line;\n    int tmem;\n    int palette;\n    int ct, mt, cs, ms;\n    int mask_t, shift_t, mask_s, shift_s;\n\n    uint16_t sl, tl, sh, th;\n\n    struct\n    {\n        int clampdiffs, clampdifft;\n        int clampens, clampent;\n        int masksclamped, masktclamped;\n        int notlutswitch, tlutswitch;\n    } f;\n};\n\nstruct span\n{\n    int lx, rx;\n    int unscrx;\n    int validline;\n    int32_t r, g, b, a, s, t, w, z;\n    int32_t majorx[4];\n    int32_t minorx[4];\n    int32_t invalyscan[4];\n};\n\nstruct combiner_inputs\n{\n    int sub_a_rgb0;\n    int sub_b_rgb0;\n    int mul_rgb0;\n    int add_rgb0;\n    int sub_a_a0;\n    int sub_b_a0;\n    int mul_a0;\n    int add_a0;\n\n    int sub_a_rgb1;\n    int sub_b_rgb1;\n    int mul_rgb1;\n    int add_rgb1;\n    int sub_a_a1;\n    int sub_b_a1;\n    int mul_a1;\n    int add_a1;\n};\n\nstruct rdp_state\n{\n    uint32_t stride;\n    uint32_t offset;\n\n    int blshifta;\n    int blshiftb;\n    int pastblshifta;\n    int pastblshiftb;\n\n    struct span span[1024];\n\n    // span states\n    int spans_ds;\n    int spans_dt;\n    int spans_dw;\n    int spans_dr;\n    int spans_dg;\n    int spans_db;\n    int spans_da;\n    int spans_dz;\n    int spans_dzpix;\n\n    int spans_drdy;\n    int spans_dgdy;\n    int spans_dbdy;\n    int spans_dady;\n    int spans_dzdy;\n    int spans_cdr;\n    int spans_cdg;\n    int spans_cdb;\n    int spans_cda;\n    int spans_cdz;\n\n    int spans_dsdy;\n    int spans_dtdy;\n    int spans_dwdy;\n\n    struct other_modes other_modes;\n\n    struct color combined_color;\n    struct color texel0_color;\n    struct color texel1_color;\n    struct color nexttexel_color;\n    struct color shade_color;\n    int32_t noise;\n    int32_t primitive_lod_frac;\n\n    struct color pixel_color;\n    struct color memory_color;\n    struct color pre_memory_color;\n\n    struct tile tile[8];\n\n    int32_t k0_tf;\n    int32_t k1_tf;\n    int32_t k2_tf;\n    int32_t k3_tf;\n    int32_t k4;\n    int32_t k5;\n    int32_t lod_frac;\n\n    uint32_t max_level;\n    int32_t min_level;\n\n    // irand\n    uint32_t rseed;\n\n    // blender\n    int32_t *blender1a_r[2];\n    int32_t *blender1a_g[2];\n    int32_t *blender1a_b[2];\n    int32_t *blender1b_a[2];\n    int32_t *blender2a_r[2];\n    int32_t *blender2a_g[2];\n    int32_t *blender2a_b[2];\n    int32_t *blender2b_a[2];\n\n    int32_t blender_shade_alpha;\n\n    struct color blend_color;\n    struct color fog_color;\n    struct color inv_pixel_color;\n    struct color blended_pixel_color;\n\n    // combiner\n    struct combiner_inputs combine;\n\n    int32_t *combiner_rgbsub_a_r[2];\n    int32_t *combiner_rgbsub_a_g[2];\n    int32_t *combiner_rgbsub_a_b[2];\n    int32_t *combiner_rgbsub_b_r[2];\n    int32_t *combiner_rgbsub_b_g[2];\n    int32_t *combiner_rgbsub_b_b[2];\n    int32_t *combiner_rgbmul_r[2];\n    int32_t *combiner_rgbmul_g[2];\n    int32_t *combiner_rgbmul_b[2];\n    int32_t *combiner_rgbadd_r[2];\n    int32_t *combiner_rgbadd_g[2];\n    int32_t *combiner_rgbadd_b[2];\n\n    int32_t *combiner_alphasub_a[2];\n    int32_t *combiner_alphasub_b[2];\n    int32_t *combiner_alphamul[2];\n    int32_t *combiner_alphaadd[2];\n\n    struct color prim_color;\n    struct color env_color;\n    struct color key_scale;\n    struct color key_center;\n    struct color key_width;\n\n    int32_t keyalpha;\n\n    // tcoord\n    void (*tcdiv_ptr)(int32_t, int32_t, int32_t, int32_t*, int32_t*);\n\n    // fbuffer\n    void (*fbread1_ptr)(struct rdp_state*, uint32_t, uint32_t*);\n    void (*fbread2_ptr)(struct rdp_state*, uint32_t, uint32_t*);\n    void (*fbwrite_ptr)(struct rdp_state*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, int, int*);\n    void (*fbfill_ptr)(struct rdp_state*, uint32_t, int, int*);\n\n    int fb_format;\n    int fb_size;\n    int fb_width;\n    uint32_t fb_address;\n    uint32_t fill_color;\n\n    // rasterizer\n    struct rectangle clip;\n    int scfield;\n    int sckeepodd;\n\n    uint32_t primitive_z;\n    uint16_t primitive_delta_z;\n\n    // tex\n    int ti_format;\n    int ti_size;\n    int ti_width;\n    uint32_t ti_address;\n\n    // coverage\n    uint8_t cvgbuf[1024];\n\n    // tmem\n    uint8_t tmem[0x1000];\n\n    // zbuffer\n    uint32_t zb_address;\n    int32_t pastrawdzmem;\n\n    // video interface\n    uint32_t vi_rseed;\n    int last_overwriting_scanline;\n    struct n64video_pixel viaa_array[0xa10 << 1];\n    struct n64video_pixel divot_array[0xa10 << 1];\n};\n\nstruct rdp_state state[PARALLEL_MAX_WORKERS];\n\nstatic int32_t one_color = 0x100;\nstatic int32_t zero_color = 0x00;\n\nvoid rdp_init(struct rdp_state* wstate);\nvoid rdp_invalid(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_noop(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_noshade(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_noshade_z(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_tex(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_tex_z(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_shade(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_shade_z(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_texshade(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tri_texshade_z(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tex_rect(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_tex_rect_flip(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_sync_load(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_sync_pipe(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_sync_tile(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_sync_full(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_key_gb(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_key_r(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_convert(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_scissor(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_prim_depth(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_other_modes(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_tile_size(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_load_block(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_load_tlut(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_load_tile(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_tile(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_fill_rect(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_fill_color(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_fog_color(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_blend_color(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_prim_color(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_env_color(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_combine(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_texture_image(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_mask_image(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_set_color_image(struct rdp_state* wstate, const uint32_t* args);\nvoid rdp_cmd(struct rdp_state* wstate, const uint32_t* args);\n\nstatic const struct\n{\n    // command handler function pointer\n    void (*handler)(struct rdp_state* wstate, const uint32_t*);\n    // command data length in bytes\n    uint32_t length;\n} rdp_commands[] = {\n    {rdp_noop,                8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_tri_noshade,        32},\n    {rdp_tri_noshade_z,      48},\n    {rdp_tri_tex,            96},\n    {rdp_tri_tex_z,         112},\n    {rdp_tri_shade,          96},\n    {rdp_tri_shade_z,       112},\n    {rdp_tri_texshade,      160},\n    {rdp_tri_texshade_z,    176},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_invalid,             8},\n    {rdp_tex_rect,           16},\n    {rdp_tex_rect_flip,      16},\n    {rdp_sync_load,           8},\n    {rdp_sync_pipe,           8},\n    {rdp_sync_tile,           8},\n    {rdp_sync_full,           8},\n    {rdp_set_key_gb,          8},\n    {rdp_set_key_r,           8},\n    {rdp_set_convert,         8},\n    {rdp_set_scissor,         8},\n    {rdp_set_prim_depth,      8},\n    {rdp_set_other_modes,     8},\n    {rdp_load_tlut,           8},\n    {rdp_invalid,             8},\n    {rdp_set_tile_size,       8},\n    {rdp_load_block,          8},\n    {rdp_load_tile,           8},\n    {rdp_set_tile,            8},\n    {rdp_fill_rect,           8},\n    {rdp_set_fill_color,      8},\n    {rdp_set_fog_color,       8},\n    {rdp_set_blend_color,     8},\n    {rdp_set_prim_color,      8},\n    {rdp_set_env_color,       8},\n    {rdp_set_combine,         8},\n    {rdp_set_texture_image,   8},\n    {rdp_set_mask_image,      8},\n    {rdp_set_color_image,     8}\n};\n\nstatic void deduce_derivatives(struct rdp_state* wstate);\n\n#include \"rdp/rdram.c\"\n#include \"rdp/dither.c\"\n#include \"rdp/blender.c\"\n#include \"rdp/combiner.c\"\n#include \"rdp/coverage.c\"\n#include \"rdp/zbuffer.c\"\n#include \"rdp/fbuffer.c\"\n#include \"rdp/tmem.c\"\n#include \"rdp/tcoord.c\"\n#include \"rdp/tex.c\"\n#include \"rdp/rasterizer.c\"\n\nstatic void deduce_derivatives(struct rdp_state* wstate)\n{\n    int special_bsel0, special_bsel1;\n\n\n    wstate->other_modes.f.partialreject_1cycle = (wstate->blender2b_a[0] == &wstate->inv_pixel_color.a && wstate->blender1b_a[0] == &wstate->pixel_color.a);\n    wstate->other_modes.f.partialreject_2cycle = (wstate->blender2b_a[1] == &wstate->inv_pixel_color.a && wstate->blender1b_a[1] == &wstate->pixel_color.a);\n\n\n    special_bsel0 = (wstate->blender2b_a[0] == &wstate->memory_color.a);\n    special_bsel1 = (wstate->blender2b_a[1] == &wstate->memory_color.a);\n\n\n    wstate->other_modes.f.realblendershiftersneeded = (special_bsel0 && wstate->other_modes.cycle_type == CYCLE_TYPE_1) || (special_bsel1 && wstate->other_modes.cycle_type == CYCLE_TYPE_2);\n    wstate->other_modes.f.interpixelblendershiftersneeded = (special_bsel0 && wstate->other_modes.cycle_type == CYCLE_TYPE_2);\n\n    wstate->other_modes.f.rgb_alpha_dither = (wstate->other_modes.rgb_dither_sel << 2) | wstate->other_modes.alpha_dither_sel;\n\n    wstate->tcdiv_ptr = tcdiv_func[wstate->other_modes.persp_tex_en];\n\n\n    int texel1_used_in_cc1 = 0, texel0_used_in_cc1 = 0, texel0_used_in_cc0 = 0, texel1_used_in_cc0 = 0;\n    //int texels_in_cc0 = 0, texels_in_cc1 = 0;\n    int lod_frac_used_in_cc1 = 0, lod_frac_used_in_cc0 = 0;\n    int texels_or_lf_used_in_ac0 = 0, texel0_used_in_ac0 = 0, texel1_used_in_ac0 = 0;\n\n    if ((wstate->combiner_rgbmul_r[1] == &wstate->lod_frac) || (wstate->combiner_alphamul[1] == &wstate->lod_frac))\n        lod_frac_used_in_cc1 = 1;\n    if ((wstate->combiner_rgbmul_r[0] == &wstate->lod_frac) || (wstate->combiner_alphamul[0] == &wstate->lod_frac))\n        lod_frac_used_in_cc0 = 1;\n\n    if (wstate->combiner_rgbmul_r[1] == &wstate->texel1_color.r || wstate->combiner_rgbsub_a_r[1] == &wstate->texel1_color.r || wstate->combiner_rgbsub_b_r[1] == &wstate->texel1_color.r || wstate->combiner_rgbadd_r[1] == &wstate->texel1_color.r || \\\n        wstate->combiner_alphamul[1] == &wstate->texel1_color.a || wstate->combiner_alphasub_a[1] == &wstate->texel1_color.a || wstate->combiner_alphasub_b[1] == &wstate->texel1_color.a || wstate->combiner_alphaadd[1] == &wstate->texel1_color.a || \\\n        wstate->combiner_rgbmul_r[1] == &wstate->texel1_color.a)\n        texel1_used_in_cc1 = 1;\n    if (wstate->combiner_rgbmul_r[1] == &wstate->texel0_color.r || wstate->combiner_rgbsub_a_r[1] == &wstate->texel0_color.r || wstate->combiner_rgbsub_b_r[1] == &wstate->texel0_color.r || wstate->combiner_rgbadd_r[1] == &wstate->texel0_color.r || \\\n        wstate->combiner_alphamul[1] == &wstate->texel0_color.a || wstate->combiner_alphasub_a[1] == &wstate->texel0_color.a || wstate->combiner_alphasub_b[1] == &wstate->texel0_color.a || wstate->combiner_alphaadd[1] == &wstate->texel0_color.a || \\\n        wstate->combiner_rgbmul_r[1] == &wstate->texel0_color.a)\n        texel0_used_in_cc1 = 1;\n    if (wstate->combiner_alphamul[0] == &wstate->texel1_color.a || wstate->combiner_alphasub_a[0] == &wstate->texel1_color.a || wstate->combiner_alphasub_b[0] == &wstate->texel1_color.a || wstate->combiner_alphaadd[0] == &wstate->texel1_color.a)\n        texel1_used_in_ac0 = 1;\n    if (wstate->combiner_alphamul[0] == &wstate->texel0_color.a || wstate->combiner_alphasub_a[0] == &wstate->texel0_color.a || wstate->combiner_alphasub_b[0] == &wstate->texel0_color.a || wstate->combiner_alphaadd[0] == &wstate->texel0_color.a)\n        texel0_used_in_ac0 = 1;\n    if (wstate->combiner_rgbmul_r[0] == &wstate->texel1_color.r || wstate->combiner_rgbsub_a_r[0] == &wstate->texel1_color.r || wstate->combiner_rgbsub_b_r[0] == &wstate->texel1_color.r || wstate->combiner_rgbadd_r[0] == &wstate->texel1_color.r || \\\n        texel1_used_in_ac0 || wstate->combiner_rgbmul_r[0] == &wstate->texel1_color.a)\n        texel1_used_in_cc0 = 1;\n    if (wstate->combiner_rgbmul_r[0] == &wstate->texel0_color.r || wstate->combiner_rgbsub_a_r[0] == &wstate->texel0_color.r || wstate->combiner_rgbsub_b_r[0] == &wstate->texel0_color.r || wstate->combiner_rgbadd_r[0] == &wstate->texel0_color.r || \\\n        texel0_used_in_ac0 || wstate->combiner_rgbmul_r[0] == &wstate->texel0_color.a)\n        texel0_used_in_cc0 = 1;\n    texels_or_lf_used_in_ac0 = texel0_used_in_ac0 || texel1_used_in_ac0 || (wstate->combiner_alphamul[0] == &wstate->lod_frac);\n    //texels_in_cc0 = texel0_used_in_cc0 || texel1_used_in_cc0;\n    //texels_in_cc1 = texel0_used_in_cc1 || texel1_used_in_cc1;\n\n\n    if (texel1_used_in_cc1)\n        wstate->other_modes.f.textureuselevel0 = 0;\n    else if (texel0_used_in_cc1 || lod_frac_used_in_cc1)\n        wstate->other_modes.f.textureuselevel0 = 1;\n    else\n        wstate->other_modes.f.textureuselevel0 = 2;\n\n    if (texel1_used_in_cc1 || (wstate->other_modes.alpha_compare_en && texels_or_lf_used_in_ac0))\n        wstate->other_modes.f.textureuselevel1 = 0;\n    else if (texel1_used_in_cc0 || texel0_used_in_cc1)\n        wstate->other_modes.f.textureuselevel1 = 1;\n    else if (texel0_used_in_cc0 || lod_frac_used_in_cc0 || lod_frac_used_in_cc1)\n        wstate->other_modes.f.textureuselevel1 = 2;\n    else\n        wstate->other_modes.f.textureuselevel1 = 3;\n\n\n    int lodfracused = 0;\n\n    if ((wstate->other_modes.cycle_type == CYCLE_TYPE_2 && (lod_frac_used_in_cc0 || lod_frac_used_in_cc1)) || \\\n        (wstate->other_modes.cycle_type == CYCLE_TYPE_1 && lod_frac_used_in_cc1))\n        lodfracused = 1;\n\n    if ((wstate->other_modes.cycle_type == CYCLE_TYPE_1 && wstate->combiner_rgbsub_a_r[1] == &wstate->noise) || \\\n        (wstate->other_modes.cycle_type == CYCLE_TYPE_2 && (wstate->combiner_rgbsub_a_r[0] == &wstate->noise || wstate->combiner_rgbsub_a_r[1] == &wstate->noise)) || \\\n        wstate->other_modes.alpha_dither_sel == 2)\n        wstate->other_modes.f.getditherlevel = 0;\n    else if (wstate->other_modes.f.rgb_alpha_dither != 0xf)\n        wstate->other_modes.f.getditherlevel = 1;\n    else\n        wstate->other_modes.f.getditherlevel = 2;\n\n    wstate->other_modes.f.dolod = wstate->other_modes.tex_lod_en || lodfracused;\n}\n\nvoid rdp_init(struct rdp_state* wstate)\n{\n    memset(wstate, 0, sizeof(*wstate));\n    fb_init(wstate);\n    combiner_init(wstate);\n    tex_init(wstate);\n    rasterizer_init(wstate);\n\n    uint32_t tmp[2] = { 0 };\n    rdp_set_other_modes(wstate, tmp);\n}\n\nvoid rdp_invalid(struct rdp_state* wstate, const uint32_t* args)\n{\n    UNUSED(wstate);\n    UNUSED(args);\n}\n\nvoid rdp_noop(struct rdp_state* wstate, const uint32_t* args)\n{\n    UNUSED(wstate);\n    UNUSED(args);\n}\n\nvoid rdp_sync_load(struct rdp_state* wstate, const uint32_t* args)\n{\n    UNUSED(wstate);\n    UNUSED(args);\n}\n\nvoid rdp_sync_pipe(struct rdp_state* wstate, const uint32_t* args)\n{\n    UNUSED(wstate);\n    UNUSED(args);\n}\n\nvoid rdp_sync_tile(struct rdp_state* wstate, const uint32_t* args)\n{\n    UNUSED(wstate);\n    UNUSED(args);\n}\n\nvoid rdp_sync_full(struct rdp_state* wstate, const uint32_t* args)\n{\n    UNUSED(wstate);\n    UNUSED(args);\n\n    // signal DP interrupt\n    *config.gfx.mi_intr_reg |= DP_INTERRUPT;\n    config.gfx.mi_intr_cb();\n}\n\nvoid rdp_set_other_modes(struct rdp_state* wstate, const uint32_t* args)\n{\n    wstate->other_modes.cycle_type          = (args[0] >> 20) & 3;\n    wstate->other_modes.persp_tex_en        = (args[0] >> 19) & 1;\n    wstate->other_modes.detail_tex_en       = (args[0] >> 18) & 1;\n    wstate->other_modes.sharpen_tex_en      = (args[0] >> 17) & 1;\n    wstate->other_modes.tex_lod_en          = (args[0] >> 16) & 1;\n    wstate->other_modes.en_tlut             = (args[0] >> 15) & 1;\n    wstate->other_modes.tlut_type           = (args[0] >> 14) & 1;\n    wstate->other_modes.sample_type         = (args[0] >> 13) & 1;\n    wstate->other_modes.mid_texel           = (args[0] >> 12) & 1;\n    wstate->other_modes.bi_lerp0            = (args[0] >> 11) & 1;\n    wstate->other_modes.bi_lerp1            = (args[0] >> 10) & 1;\n    wstate->other_modes.convert_one         = (args[0] >>  9) & 1;\n    wstate->other_modes.key_en              = (args[0] >>  8) & 1;\n    wstate->other_modes.rgb_dither_sel      = (args[0] >>  6) & 3;\n    wstate->other_modes.alpha_dither_sel    = (args[0] >>  4) & 3;\n    wstate->other_modes.blend_m1a_0         = (args[1] >> 30) & 3;\n    wstate->other_modes.blend_m1a_1         = (args[1] >> 28) & 3;\n    wstate->other_modes.blend_m1b_0         = (args[1] >> 26) & 3;\n    wstate->other_modes.blend_m1b_1         = (args[1] >> 24) & 3;\n    wstate->other_modes.blend_m2a_0         = (args[1] >> 22) & 3;\n    wstate->other_modes.blend_m2a_1         = (args[1] >> 20) & 3;\n    wstate->other_modes.blend_m2b_0         = (args[1] >> 18) & 3;\n    wstate->other_modes.blend_m2b_1         = (args[1] >> 16) & 3;\n    wstate->other_modes.force_blend         = (args[1] >> 14) & 1;\n    wstate->other_modes.alpha_cvg_select    = (args[1] >> 13) & 1;\n    wstate->other_modes.cvg_times_alpha     = (args[1] >> 12) & 1;\n    wstate->other_modes.z_mode              = (args[1] >> 10) & 3;\n    wstate->other_modes.cvg_dest            = (args[1] >>  8) & 3;\n    wstate->other_modes.color_on_cvg        = (args[1] >>  7) & 1;\n    wstate->other_modes.image_read_en       = (args[1] >>  6) & 1;\n    wstate->other_modes.z_update_en         = (args[1] >>  5) & 1;\n    wstate->other_modes.z_compare_en        = (args[1] >>  4) & 1;\n    wstate->other_modes.antialias_en        = (args[1] >>  3) & 1;\n    wstate->other_modes.z_source_sel        = (args[1] >>  2) & 1;\n    wstate->other_modes.dither_alpha_en     = (args[1] >>  1) & 1;\n    wstate->other_modes.alpha_compare_en    = (args[1] >>  0) & 1;\n\n    set_blender_input(wstate, 0, 0, &wstate->blender1a_r[0], &wstate->blender1a_g[0], &wstate->blender1a_b[0], &wstate->blender1b_a[0],\n                      wstate->other_modes.blend_m1a_0, wstate->other_modes.blend_m1b_0);\n    set_blender_input(wstate, 0, 1, &wstate->blender2a_r[0], &wstate->blender2a_g[0], &wstate->blender2a_b[0], &wstate->blender2b_a[0],\n                      wstate->other_modes.blend_m2a_0, wstate->other_modes.blend_m2b_0);\n    set_blender_input(wstate, 1, 0, &wstate->blender1a_r[1], &wstate->blender1a_g[1], &wstate->blender1a_b[1], &wstate->blender1b_a[1],\n                      wstate->other_modes.blend_m1a_1, wstate->other_modes.blend_m1b_1);\n    set_blender_input(wstate, 1, 1, &wstate->blender2a_r[1], &wstate->blender2a_g[1], &wstate->blender2a_b[1], &wstate->blender2b_a[1],\n                      wstate->other_modes.blend_m2a_1, wstate->other_modes.blend_m2b_1);\n\n    wstate->other_modes.f.stalederivs = 1;\n}\n\nvoid rdp_cmd(struct rdp_state* wstate, const uint32_t* args)\n{\n    uint32_t cmd_id = CMD_ID(args);\n    rdp_commands[cmd_id].handler(wstate, args);\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/vi/divot.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic STRICTINLINE void divot_filter(struct n64video_pixel* final, struct n64video_pixel center, struct n64video_pixel left, struct n64video_pixel right)\n{\n    *final = center;\n\n    if ((center.a & left.a & right.a) == 7)\n    {\n        return;\n    }\n\n    if ((left.r >= center.r && right.r >= left.r) || (left.r >= right.r && center.r >= left.r))\n        final->r = left.r;\n    else if ((right.r >= center.r && left.r >= right.r) || (right.r >= left.r && center.r >= right.r))\n        final->r = right.r;\n\n    if ((left.g >= center.g && right.g >= left.g) || (left.g >= right.g && center.g >= left.g))\n        final->g = left.g;\n    else if ((right.g >= center.g && left.g >= right.g) || (right.g >= left.g && center.g >= right.g))\n        final->g = right.g;\n\n    if ((left.b >= center.b && right.b >= left.b) || (left.b >= right.b && center.b >= left.b))\n        final->b = left.b;\n    else if ((right.b >= center.b && left.b >= right.b) || (right.b >= left.b && center.b >= right.b))\n        final->b = right.b;\n}\n\n#endif // N64VIDEO_C\n\n"
  },
  {
    "path": "src/core/n64video/vi/fetch.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic void vi_fetch_filter16(struct n64video_pixel* res, uint32_t fboffset, uint32_t cur_x, struct vi_reg_ctrl ctrl, uint32_t hres, uint32_t fetchstate)\n{\n    int r, g, b;\n    uint32_t idx = (fboffset >> 1) + cur_x;\n    uint8_t hval;\n    uint16_t pix;\n    uint32_t cur_cvg;\n    if (ctrl.aa_mode <= VI_AA_RESAMP_EXTRA)\n    {\n        PAIRREAD16(pix, hval, idx);\n        cur_cvg = ((pix & 1) << 2) | hval;\n    }\n    else\n    {\n        RREADIDX16(pix, idx);\n        cur_cvg = 7;\n    }\n    r = RGBA16_R(pix);\n    g = RGBA16_G(pix);\n    b = RGBA16_B(pix);\n\n    if (cur_cvg == 7)\n    {\n        if (ctrl.dither_filter_enable)\n            restore_filter16(&r, &g, &b, fboffset, cur_x, hres, fetchstate);\n    }\n    else\n    {\n        video_filter16(&r, &g, &b, fboffset, cur_x, hres, cur_cvg, fetchstate);\n    }\n\n\n    res->r = (uint8_t)r;\n    res->g = (uint8_t)g;\n    res->b = (uint8_t)b;\n    res->a = (uint8_t)cur_cvg;\n}\n\nstatic void vi_fetch_filter32(struct n64video_pixel* res, uint32_t fboffset, uint32_t cur_x, struct vi_reg_ctrl ctrl, uint32_t hres, uint32_t fetchstate)\n{\n    int r, g, b;\n    uint32_t pix, addr = (fboffset >> 2) + cur_x;\n    RREADIDX32(pix, addr);\n    uint32_t cur_cvg;\n    if (ctrl.aa_mode <= VI_AA_RESAMP_EXTRA)\n        cur_cvg = (pix >> 5) & 7;\n    else\n        cur_cvg = 7;\n    r = RGBA32_R(pix) & 0xff;\n    g = RGBA32_G(pix) & 0xff;\n    b = RGBA32_B(pix) & 0xff;\n\n    if (cur_cvg == 7)\n    {\n        if (ctrl.dither_filter_enable)\n            restore_filter32(&r, &g, &b, fboffset, cur_x, hres, fetchstate);\n    }\n    else\n    {\n        video_filter32(&r, &g, &b, fboffset, cur_x, hres, cur_cvg, fetchstate);\n    }\n\n    res->r = (uint8_t)r;\n    res->g = (uint8_t)g;\n    res->b = (uint8_t)b;\n    res->a = (uint8_t)cur_cvg;\n}\n\n#endif // N64VIDEO_C\n\n"
  },
  {
    "path": "src/core/n64video/vi/gamma.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic uint8_t gamma_table[0x100];\nstatic uint8_t gamma_dither_table[0x4000];\n\nstatic uint32_t vi_integer_sqrt(uint32_t a)\n{\n    unsigned long op = a, res = 0, one = 1 << 30;\n\n    while (one > op)\n        one >>= 2;\n\n    while (one != 0)\n    {\n        if (op >= res + one)\n        {\n            op -= res + one;\n            res += one << 1;\n        }\n        res >>= 1;\n        one >>= 2;\n    }\n    return res;\n}\n\nstatic STRICTINLINE void gamma_filters(struct n64video_pixel* pixel, bool gamma_enable, bool gamma_dither_enable, uint32_t* rstate)\n{\n    int cdith, dith;\n\n    switch((gamma_enable << 1) | gamma_dither_enable)\n    {\n    case 0: // no gamma, no dithering\n        return;\n    case 1: // no gamma, dithering enabled\n        cdith = irand(rstate);\n        dith = cdith & 1;\n        if (pixel->r < 255)\n            pixel->r += (uint8_t)dith;\n        dith = (cdith >> 1) & 1;\n        if (pixel->g < 255)\n            pixel->g += (uint8_t)dith;\n        dith = (cdith >> 2) & 1;\n        if (pixel->b < 255)\n            pixel->b += (uint8_t)dith;\n        break;\n    case 2: // gamma enabled, no dithering\n        pixel->r = gamma_table[pixel->r];\n        pixel->g = gamma_table[pixel->g];\n        pixel->b = gamma_table[pixel->b];\n        break;\n    case 3: // gamma and dithering enabled\n        cdith = irand(rstate);\n        dith = cdith & 0x3f;\n        pixel->r = gamma_dither_table[((pixel->r) << 6)|dith];\n        dith = (cdith >> 6) & 0x3f;\n        pixel->g = gamma_dither_table[((pixel->g) << 6)|dith];\n        dith = ((cdith >> 9) & 0x38) | (cdith & 7);\n        pixel->b = gamma_dither_table[((pixel->b) << 6)|dith];\n        break;\n    }\n}\n\nvoid vi_gamma_init(void)\n{\n    int i;\n    for (i = 0; i < 256; i++)\n    {\n        gamma_table[i] = (uint8_t)vi_integer_sqrt(i << 6);\n        gamma_table[i] <<= 1;\n    }\n\n    for (i = 0; i < 0x4000; i++)\n    {\n        gamma_dither_table[i] = (uint8_t)vi_integer_sqrt(i);\n        gamma_dither_table[i] <<= 1;\n    }\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/vi/lerp.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic STRICTINLINE void vi_vl_lerp(struct n64video_pixel* up, struct n64video_pixel down, uint32_t frac)\n{\n    uint32_t r0, g0, b0;\n    if (!frac)\n        return;\n\n    r0 = up->r;\n    g0 = up->g;\n    b0 = up->b;\n\n    up->r = ((((down.r - r0) * frac + 16) >> 5) + r0) & 0xff;\n    up->g = ((((down.g - g0) * frac + 16) >> 5) + g0) & 0xff;\n    up->b = ((((down.b - b0) * frac + 16) >> 5) + b0) & 0xff;\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/vi/restore.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic int vi_restore_table[0x400];\n\nstatic STRICTINLINE void restore_filter16(int* r, int* g, int* b, uint32_t fboffset, uint32_t num, uint32_t hres, uint32_t fetchbugstate)\n{\n    int i;\n    uint32_t idx = (fboffset >> 1) + num;\n\n    uint32_t toleftpix = idx - 1;\n\n    uint32_t leftuppix, leftdownpix, maxpix;\n\n    leftuppix = idx - hres - 1;\n\n    if (fetchbugstate != 1)\n    {\n        leftdownpix = idx + hres - 1;\n        maxpix = idx + hres + 1;\n    }\n    else\n    {\n        leftdownpix = toleftpix;\n        maxpix = toleftpix + 2;\n    }\n\n    int rend = *r;\n    int gend = *g;\n    int bend = *b;\n    const int* redptr = &vi_restore_table[(rend << 2) & 0x3e0];\n    const int* greenptr = &vi_restore_table[(gend << 2) & 0x3e0];\n    const int* blueptr = &vi_restore_table[(bend << 2) & 0x3e0];\n\n    uint32_t tempr, tempg, tempb;\n    uint16_t pix;\n\n    const uint32_t dirs[] =\n    {\n        leftuppix, leftuppix + 1, leftuppix + 2, leftdownpix,\n        leftdownpix + 1, maxpix, toleftpix, toleftpix + 2\n    };\n\n    if (rdram_valid_idx16(maxpix) && rdram_valid_idx16(leftuppix))\n    {\n        for (i = 0; i < 8; i++)\n        {\n            pix = rdram_read_idx16_fast(dirs[i]);\n            tempr = (pix >> 11) & 0x1f;\n            tempg = (pix >> 6) & 0x1f;\n            tempb = (pix >> 1) & 0x1f;\n            rend += redptr[tempr];\n            gend += greenptr[tempg];\n            bend += blueptr[tempb];\n        }\n    }\n    else\n    {\n        for (i = 0; i < 8; i++)\n        {\n            pix = rdram_read_idx16(dirs[i]);\n            tempr = (pix >> 11) & 0x1f;\n            tempg = (pix >> 6) & 0x1f;\n            tempb = (pix >> 1) & 0x1f;\n            rend += redptr[tempr];\n            gend += greenptr[tempg];\n            bend += blueptr[tempb];\n        }\n    }\n\n\n    *r = rend;\n    *g = gend;\n    *b = bend;\n}\n\nstatic STRICTINLINE void restore_filter32(int* r, int* g, int* b, uint32_t fboffset, uint32_t num, uint32_t hres, uint32_t fetchbugstate)\n{\n    int i;\n    uint32_t idx = (fboffset >> 2) + num;\n\n    uint32_t toleftpix = idx - 1;\n\n    uint32_t leftuppix, leftdownpix, maxpix;\n\n    leftuppix = idx - hres - 1;\n\n    if (fetchbugstate != 1)\n    {\n        leftdownpix = idx + hres - 1;\n        maxpix = idx +hres + 1;\n    }\n    else\n    {\n        leftdownpix = toleftpix;\n        maxpix = toleftpix + 2;\n    }\n\n    int rend = *r;\n    int gend = *g;\n    int bend = *b;\n    const int* redptr = &vi_restore_table[(rend << 2) & 0x3e0];\n    const int* greenptr = &vi_restore_table[(gend << 2) & 0x3e0];\n    const int* blueptr = &vi_restore_table[(bend << 2) & 0x3e0];\n\n    uint32_t tempr, tempg, tempb;\n    uint32_t pix;\n\n    const uint32_t dirs[] =\n    {\n        leftuppix, leftuppix + 1, leftuppix + 2, leftdownpix,\n        leftdownpix + 1, maxpix, toleftpix, toleftpix + 2\n    };\n\n    if (rdram_valid_idx32(maxpix) && rdram_valid_idx32(leftuppix))\n    {\n        for (i = 0; i < 8; i++)\n        {\n            pix = rdram_read_idx32_fast(dirs[i]);\n            tempr = (pix >> 27) & 0x1f;\n            tempg = (pix >> 19) & 0x1f;\n            tempb = (pix >> 11) & 0x1f;\n            rend += redptr[tempr];\n            gend += greenptr[tempg];\n            bend += blueptr[tempb];\n        }\n    }\n    else\n    {\n        for (i = 0; i < 8; i++)\n        {\n            pix = rdram_read_idx32(dirs[i]);\n            tempr = (pix >> 27) & 0x1f;\n            tempg = (pix >> 19) & 0x1f;\n            tempb = (pix >> 11) & 0x1f;\n            rend += redptr[tempr];\n            gend += greenptr[tempg];\n            bend += blueptr[tempb];\n        }\n    }\n\n    *r = rend;\n    *g = gend;\n    *b = bend;\n}\n\nvoid vi_restore_init()\n{\n    int i;\n    for (i = 0; i < 0x400; i++)\n    {\n        if (((i >> 5) & 0x1f) < (i & 0x1f))\n            vi_restore_table[i] = 1;\n        else if (((i >> 5) & 0x1f) > (i & 0x1f))\n            vi_restore_table[i] = -1;\n        else\n            vi_restore_table[i] = 0;\n    }\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/vi/video.c",
    "content": "#ifdef N64VIDEO_C\n\nstatic STRICTINLINE void video_max_optimized(uint32_t* pixels, uint32_t* penumin, uint32_t* penumax, int numofels)\n{\n    int i;\n    int posmax = 0, posmin = 0;\n    uint32_t curpenmax = pixels[0], curpenmin = pixels[0];\n    uint32_t max, min;\n\n    for (i = 1; i < numofels; i++)\n    {\n        if (pixels[i] > pixels[posmax])\n        {\n            curpenmax = pixels[posmax];\n            posmax = i;\n        }\n        else if (pixels[i] < pixels[posmin])\n        {\n            curpenmin = pixels[posmin];\n            posmin = i;\n        }\n    }\n    max = pixels[posmax];\n    min = pixels[posmin];\n    if (curpenmax != max)\n    {\n        for (i = posmax + 1; i < numofels; i++)\n        {\n            if (pixels[i] > curpenmax)\n                curpenmax = pixels[i];\n        }\n    }\n    if (curpenmin != min)\n    {\n        for (i = posmin + 1; i < numofels; i++)\n        {\n            if (pixels[i] < curpenmin)\n                curpenmin = pixels[i];\n        }\n    }\n    *penumax = curpenmax;\n    *penumin = curpenmin;\n}\n\n\nstatic STRICTINLINE void video_filter16(int* endr, int* endg, int* endb, uint32_t fboffset, uint32_t num, uint32_t hres, uint32_t centercvg, uint32_t fetchbugstate)\n{\n    int i;\n    uint32_t penumaxr, penumaxg, penumaxb, penuminr, penuming, penuminb;\n    uint16_t pix;\n    uint32_t numoffull = 1;\n    uint8_t hidval;\n    uint32_t r, g, b;\n    uint32_t backr[7], backg[7], backb[7];\n\n    r = *endr;\n    g = *endg;\n    b = *endb;\n\n    backr[0] = r;\n    backg[0] = g;\n    backb[0] = b;\n\n    uint32_t idx = (fboffset >> 1) + num;\n\n    uint32_t toleft = idx - 2;\n    uint32_t toright = idx + 2;\n\n    uint32_t leftup, rightup, leftdown, rightdown;\n\n    leftup = idx - hres - 1;\n    rightup = idx - hres + 1;\n\n    if (fetchbugstate != 1)\n    {\n        leftdown = idx + hres - 1;\n        rightdown = idx + hres + 1;\n    }\n    else\n    {\n        leftdown = toleft;\n        rightdown = toright;\n    }\n\n    const uint32_t dirs[] = {leftup, rightup, toleft, toright, leftdown, rightdown};\n\n    for (i = 0; i < 6; i++)\n    {\n        rdram_read_pair16(&pix, &hidval, dirs[i]);\n        if (hidval == 3 && (pix & 1))\n        {\n            backr[numoffull] = RGBA16_R(pix);\n            backg[numoffull] = RGBA16_G(pix);\n            backb[numoffull] = RGBA16_B(pix);\n            numoffull++;\n        }\n    }\n\n    uint32_t colr, colg, colb;\n\n    video_max_optimized(backr, &penuminr, &penumaxr, numoffull);\n    video_max_optimized(backg, &penuming, &penumaxg, numoffull);\n    video_max_optimized(backb, &penuminb, &penumaxb, numoffull);\n\n    uint32_t coeff = 7 - centercvg;\n    colr = penuminr + penumaxr - (r << 1);\n    colg = penuming + penumaxg - (g << 1);\n    colb = penuminb + penumaxb - (b << 1);\n\n    colr = (((colr * coeff) + 4) >> 3) + r;\n    colg = (((colg * coeff) + 4) >> 3) + g;\n    colb = (((colb * coeff) + 4) >> 3) + b;\n\n    *endr = colr & 0xff;\n    *endg = colg & 0xff;\n    *endb = colb & 0xff;\n}\n\nstatic STRICTINLINE void video_filter32(int* endr, int* endg, int* endb, uint32_t fboffset, uint32_t num, uint32_t hres, uint32_t centercvg, uint32_t fetchbugstate)\n{\n    int i;\n    uint32_t penumaxr, penumaxg, penumaxb, penuminr, penuming, penuminb;\n    uint32_t numoffull = 1;\n    uint32_t pix = 0, pixcvg = 0;\n    uint32_t r, g, b;\n    uint32_t backr[7], backg[7], backb[7];\n\n    r = *endr;\n    g = *endg;\n    b = *endb;\n\n    backr[0] = r;\n    backg[0] = g;\n    backb[0] = b;\n\n    uint32_t idx = (fboffset >> 2) + num;\n\n    uint32_t toleft = idx - 2;\n    uint32_t toright = idx + 2;\n\n    uint32_t leftup, rightup, leftdown, rightdown;\n\n    leftup = idx - hres - 1;\n    rightup = idx - hres + 1;\n\n    if (fetchbugstate != 1)\n    {\n        leftdown = idx + hres - 1;\n        rightdown = idx + hres + 1;\n    }\n    else\n    {\n        leftdown = toleft;\n        rightdown = toright;\n    }\n\n    const uint32_t dirs[] = {leftup, rightup, toleft, toright, leftdown, rightdown};\n\n    for (i = 0; i < 6; i++)\n    {\n        pix = rdram_read_idx32(dirs[i]);\n        pixcvg = (pix >> 5) & 7;\n        if (pixcvg == 7)\n        {\n            backr[numoffull] = (pix >> 24) & 0xff;\n            backg[numoffull] = (pix >> 16) & 0xff;\n            backb[numoffull] = (pix >> 8) & 0xff;\n            numoffull++;\n        }\n    }\n\n    uint32_t colr, colg, colb;\n\n    video_max_optimized(backr, &penuminr, &penumaxr, numoffull);\n    video_max_optimized(backg, &penuming, &penumaxg, numoffull);\n    video_max_optimized(backb, &penuminb, &penumaxb, numoffull);\n\n    uint32_t coeff = 7 - centercvg;\n    colr = penuminr + penumaxr - (r << 1);\n    colg = penuming + penumaxg - (g << 1);\n    colb = penuminb + penumaxb - (b << 1);\n\n    colr = (((colr * coeff) + 4) >> 3) + r;\n    colg = (((colg * coeff) + 4) >> 3) + g;\n    colb = (((colb * coeff) + 4) >> 3) + b;\n\n    *endr = colr & 0xff;\n    *endg = colg & 0xff;\n    *endb = colb & 0xff;\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video/vi.c",
    "content": "#ifdef N64VIDEO_C\n\n// anamorphic NTSC resolution\n#define H_RES_NTSC 640\n#define V_RES_NTSC 480\n\n// anamorphic PAL resolution\n#define H_RES_PAL 768\n#define V_RES_PAL 576\n\n// typical VI_V_SYNC values for NTSC and PAL\n#define V_SYNC_NTSC 525\n#define V_SYNC_PAL 625\n\n// maximum possible size of the prescale area\n#define PRESCALE_WIDTH H_RES_NTSC\n#define PRESCALE_HEIGHT V_SYNC_PAL\n\nenum vi_type\n{\n    VI_TYPE_BLANK,      // no data, no sync\n    VI_TYPE_RESERVED,   // unused, should never be set\n    VI_TYPE_RGBA5551,   // 16 bit color (internally 18 bit RGBA5553)\n    VI_TYPE_RGBA8888    // 32 bit color\n};\n\nenum vi_aa\n{\n    VI_AA_RESAMP_EXTRA_ALWAYS,  // resample and AA (always fetch extra lines)\n    VI_AA_RESAMP_EXTRA,         // resample and AA (fetch extra lines if needed)\n    VI_AA_RESAMP_ONLY,          // only resample (treat as all fully covered)\n    VI_AA_REPLICATE             // replicate pixels, no interpolation\n};\n\nstruct vi_reg_ctrl\n{\n    uint8_t type;\n    bool gamma_dither_enable;\n    bool gamma_enable;\n    bool divot_enable;\n    bool vbus_clock_enable;\n    bool serrate;\n    bool test_mode;\n    uint8_t aa_mode;\n    bool kill_we;\n    uint8_t pixel_advance;\n    bool dither_filter_enable;\n};\n\ntypedef void(*vi_fetch_filter_func)(struct n64video_pixel*, uint32_t, uint32_t, struct vi_reg_ctrl, uint32_t, uint32_t);\n\n#include \"vi/gamma.c\"\n#include \"vi/lerp.c\"\n#include \"vi/divot.c\"\n#include \"vi/video.c\"\n#include \"vi/restore.c\"\n#include \"vi/fetch.c\"\n\n// states\nstatic int32_t prevvicurrent;\nstatic int32_t emucontrolsvicurrent;\nstatic bool prevserrate;\nstatic bool lowerfield;\nstatic int32_t oldvstart;\nstatic bool prevwasblank;\nstatic int32_t vactivelines;\nstatic bool ispal;\nstatic int32_t minhpass;\nstatic int32_t maxhpass;\nstatic uint32_t x_add;\nstatic uint32_t x_start;\nstatic uint32_t y_add;\nstatic uint32_t y_start;\nstatic int32_t v_sync;\nstatic int32_t vi_width_low;\nstatic uint32_t frame_buffer;\nstatic uint32_t tvfadeoutstate[PRESCALE_HEIGHT];\nstatic uint32_t zb_address;\nstatic int32_t vinnglitch;\n\n// prescale buffer\nstatic struct n64video_pixel prescale[PRESCALE_WIDTH * PRESCALE_HEIGHT];\nstatic uint32_t prescale_ptr;\nstatic int32_t linecount;\n\n// parsed VI registers\nstatic uint32_t** vi_reg_ptr;\nstatic struct vi_reg_ctrl ctrl;\nstatic int32_t hres, vres;\nstatic int32_t hres_raw, vres_raw;\nstatic int32_t v_start;\nstatic int32_t h_start;\nstatic int32_t v_current_line;\n\nstatic void vi_init(void)\n{\n    vi_gamma_init();\n    vi_restore_init();\n\n    memset(prescale, 0, sizeof(prescale));\n\n    prevvicurrent = 0;\n    emucontrolsvicurrent = -1;\n    prevserrate = false;\n    oldvstart = 1337;\n    prevwasblank = false;\n    zb_address = 0;\n}\n\nstatic void vi_process_full_parallel(uint32_t worker_id)\n{\n    int32_t y;\n    struct n64video_pixel *viaa_array = state[worker_id].viaa_array;\n    struct n64video_pixel *divot_array = state[worker_id].divot_array;\n\n    int32_t cache_marker = 0, cache_next_marker = 0, divot_cache_marker = 0, divot_cache_next_marker = 0;\n    int32_t cache_marker_init = (x_start >> 10) - 1;\n\n    struct n64video_pixel *viaa_cache = &viaa_array[0];\n    struct n64video_pixel *viaa_cache_next = &viaa_array[0xa10];\n    struct n64video_pixel *divot_cache = &divot_array[0];\n    struct n64video_pixel *divot_cache_next = &divot_array[0xa10];\n\n    struct n64video_pixel color, nextcolor, scancolor, scannextcolor;\n\n    vi_fetch_filter_func vi_fetch_filter_ptr = ctrl.type & 1 ? vi_fetch_filter32 : vi_fetch_filter16;\n\n    uint32_t pixels = 0, nextpixels = 0, fetchbugstate = 0;\n\n    int32_t xfrac = 0, yfrac = 0;\n    int32_t line_x = 0, next_line_x = 0, prev_line_x = 0, far_line_x = 0;\n    int32_t prev_scan_x = 0, scan_x = 0, next_scan_x = 0, far_scan_x = 0;\n    int32_t prev_x = 0, cur_x = 0, next_x = 0, far_x = 0;\n\n    bool cache_init = false;\n\n    pixels = 0;\n\n    int32_t y_begin = 0;\n    int32_t y_end = vres;\n    int32_t y_inc = 1;\n\n    if (config.parallel) {\n        y_begin = worker_id;\n        y_inc = parallel_num_workers();\n    }\n\n    for (y = y_begin; y < y_end; y += y_inc) {\n        int32_t x;\n        uint32_t x_offs = x_start;\n        uint32_t curry = y_start + y * y_add;\n        uint32_t nexty = y_start + (y + 1) * y_add;\n        uint32_t prevy = curry >> 10;\n\n        cache_marker = cache_next_marker = cache_marker_init;\n        if (ctrl.divot_enable) {\n            divot_cache_marker = divot_cache_next_marker = cache_marker_init;\n        }\n\n        struct n64video_pixel* pixel_row = &prescale[prescale_ptr + linecount * y];\n\n        yfrac = (curry >> 5) & 0x1f;\n        pixels = vi_width_low * prevy;\n        nextpixels = vi_width_low + pixels;\n\n        if (prevy == (nexty >> 10)) {\n            fetchbugstate = 2;\n        } else {\n            fetchbugstate >>= 1;\n        }\n\n        for (x = 0; x < hres; x++, x_offs += x_add) {\n            line_x = x_offs >> 10;\n            prev_line_x = line_x - 1;\n            next_line_x = line_x + 1;\n            far_line_x = line_x + 2;\n\n            cur_x = pixels + line_x;\n            prev_x = pixels + prev_line_x;\n            next_x = pixels + next_line_x;\n            far_x = pixels + far_line_x;\n\n            scan_x = nextpixels + line_x;\n            prev_scan_x = nextpixels + prev_line_x;\n            next_scan_x = nextpixels + next_line_x;\n            far_scan_x = nextpixels + far_line_x;\n\n            line_x++;\n            prev_line_x++;\n            next_line_x++;\n            far_line_x++;\n\n            xfrac = (x_offs >> 5) & 0x1f;\n\n            if (prev_line_x > cache_marker) {\n                vi_fetch_filter_ptr(&viaa_cache[prev_line_x], frame_buffer, prev_x, ctrl, vi_width_low, 0);\n                vi_fetch_filter_ptr(&viaa_cache[line_x], frame_buffer, cur_x, ctrl, vi_width_low, 0);\n                vi_fetch_filter_ptr(&viaa_cache[next_line_x], frame_buffer, next_x, ctrl, vi_width_low, 0);\n                cache_marker = next_line_x;\n            } else if (line_x > cache_marker) {\n                vi_fetch_filter_ptr(&viaa_cache[line_x], frame_buffer, cur_x, ctrl, vi_width_low, 0);\n                vi_fetch_filter_ptr(&viaa_cache[next_line_x], frame_buffer, next_x, ctrl, vi_width_low, 0);\n                cache_marker = next_line_x;\n            } else if (next_line_x > cache_marker) {\n                vi_fetch_filter_ptr(&viaa_cache[next_line_x], frame_buffer, next_x, ctrl, vi_width_low, 0);\n                cache_marker = next_line_x;\n            }\n\n            if (prev_line_x > cache_next_marker) {\n                vi_fetch_filter_ptr(&viaa_cache_next[prev_line_x], frame_buffer, prev_scan_x, ctrl, vi_width_low, fetchbugstate);\n                vi_fetch_filter_ptr(&viaa_cache_next[line_x], frame_buffer, scan_x, ctrl, vi_width_low, fetchbugstate);\n                vi_fetch_filter_ptr(&viaa_cache_next[next_line_x], frame_buffer, next_scan_x, ctrl, vi_width_low, fetchbugstate);\n                cache_next_marker = next_line_x;\n            } else if (line_x > cache_next_marker) {\n                vi_fetch_filter_ptr(&viaa_cache_next[line_x], frame_buffer, scan_x, ctrl, vi_width_low, fetchbugstate);\n                vi_fetch_filter_ptr(&viaa_cache_next[next_line_x], frame_buffer, next_scan_x, ctrl, vi_width_low, fetchbugstate);\n                cache_next_marker = next_line_x;\n            } else if (next_line_x > cache_next_marker) {\n                vi_fetch_filter_ptr(&viaa_cache_next[next_line_x], frame_buffer, next_scan_x, ctrl, vi_width_low, fetchbugstate);\n                cache_next_marker = next_line_x;\n            }\n\n            if (ctrl.divot_enable) {\n                if (far_line_x > cache_marker) {\n                    vi_fetch_filter_ptr(&viaa_cache[far_line_x], frame_buffer, far_x, ctrl, vi_width_low, 0);\n                    cache_marker = far_line_x;\n                }\n\n                if (far_line_x > cache_next_marker) {\n                    vi_fetch_filter_ptr(&viaa_cache_next[far_line_x], frame_buffer, far_scan_x, ctrl, vi_width_low, fetchbugstate);\n                    cache_next_marker = far_line_x;\n                }\n\n                if (line_x > divot_cache_marker) {\n                    divot_filter(&divot_cache[line_x], viaa_cache[line_x], viaa_cache[prev_line_x], viaa_cache[next_line_x]);\n                    divot_filter(&divot_cache[next_line_x], viaa_cache[next_line_x], viaa_cache[line_x], viaa_cache[far_line_x]);\n                    divot_cache_marker = next_line_x;\n                } else if (next_line_x > divot_cache_marker) {\n                    divot_filter(&divot_cache[next_line_x], viaa_cache[next_line_x], viaa_cache[line_x], viaa_cache[far_line_x]);\n                    divot_cache_marker = next_line_x;\n                }\n\n                if (line_x > divot_cache_next_marker) {\n                    divot_filter(&divot_cache_next[line_x], viaa_cache_next[line_x], viaa_cache_next[prev_line_x], viaa_cache_next[next_line_x]);\n                    divot_filter(&divot_cache_next[next_line_x], viaa_cache_next[next_line_x], viaa_cache_next[line_x], viaa_cache_next[far_line_x]);\n                    divot_cache_next_marker = next_line_x;\n                } else if (next_line_x > divot_cache_next_marker) {\n                    divot_filter(&divot_cache_next[next_line_x], viaa_cache_next[next_line_x], viaa_cache_next[line_x], viaa_cache_next[far_line_x]);\n                    divot_cache_next_marker = next_line_x;\n                }\n\n                color = divot_cache[line_x];\n            } else {\n                color = viaa_cache[line_x];\n            }\n\n            bool lerping = ctrl.aa_mode != VI_AA_REPLICATE && (xfrac || yfrac);\n\n            if (lerping) {\n                if (ctrl.divot_enable) {\n                    nextcolor = divot_cache[next_line_x];\n                    scancolor = divot_cache_next[line_x];\n                    scannextcolor = divot_cache_next[next_line_x];\n                } else {\n                    nextcolor = viaa_cache[next_line_x];\n                    scancolor = viaa_cache_next[line_x];\n                    scannextcolor = viaa_cache_next[next_line_x];\n                }\n\n                vi_vl_lerp(&color, scancolor, yfrac);\n                vi_vl_lerp(&nextcolor, scannextcolor, yfrac);\n                vi_vl_lerp(&color, nextcolor, xfrac);\n            } else if (vinnglitch) {\n                if (prev_line_x & vinnglitch) {\n                    color.r = color.g = color.b = 0;\n                } else {\n                    cur_x = pixels + (prev_line_x & (vinnglitch - 1));\n                    vi_fetch_filter_ptr(&color, frame_buffer, cur_x, ctrl, vres, 0);\n\n                    if (ctrl.divot_enable) {\n                        struct n64video_pixel prevcol, nextcol;\n                        prev_x = pixels + ((prev_line_x - 1) & (vinnglitch - 1));\n                        next_x = pixels + (line_x & (vinnglitch - 1));\n                        vi_fetch_filter_ptr(&prevcol, frame_buffer, prev_x, ctrl, vres, 0);\n                        vi_fetch_filter_ptr(&nextcol, frame_buffer, next_x, ctrl, vres, 0);\n                        divot_filter(&color, color, prevcol, nextcol);\n                    }\n                }\n            }\n\n            struct n64video_pixel* pixel = &pixel_row[x];\n\n            if (x >= minhpass && x < maxhpass) {\n                *pixel = color;\n                gamma_filters(pixel, ctrl.gamma_enable, ctrl.gamma_dither_enable, &state[worker_id].vi_rseed);\n            } else {\n                pixel->r = pixel->g = pixel->b = 0;\n            }\n        }\n\n        if (!cache_init && y_add == 0x400) {\n            cache_marker = cache_next_marker;\n            cache_next_marker = cache_marker_init;\n\n            struct n64video_pixel* tempccvgptr = viaa_cache;\n            viaa_cache = viaa_cache_next;\n            viaa_cache_next = tempccvgptr;\n            if (ctrl.divot_enable) {\n                divot_cache_marker = divot_cache_next_marker;\n                divot_cache_next_marker = cache_marker_init;\n                tempccvgptr = divot_cache;\n                divot_cache = divot_cache_next;\n                divot_cache_next = tempccvgptr;\n            }\n\n            cache_init = true;\n        }\n    }\n}\n\nstatic bool vi_process_full(struct n64video_frame_buffer* fb)\n{\n    bool isblank = (ctrl.type & 2) == 0;\n    bool validinterlace = !isblank && ctrl.serrate;\n\n    if (validinterlace) {\n        if (prevserrate && emucontrolsvicurrent < 0) {\n            emucontrolsvicurrent = v_current_line != prevvicurrent;\n        }\n\n        if (emucontrolsvicurrent == 1) {\n            lowerfield = v_current_line ^ 1;\n        } else if (!emucontrolsvicurrent) {\n            if (v_start == oldvstart) {\n                lowerfield ^= true;\n            } else {\n                lowerfield = v_start < oldvstart;\n            }\n        }\n\n        prevvicurrent = v_current_line;\n    }\n\n    oldvstart = v_start;\n    prevserrate = validinterlace;\n\n    bool validh = hres > 0 && h_start < PRESCALE_WIDTH;\n    int32_t h_end = hres + h_start; // note: the result appears to be different to VI_H_END\n    int32_t hrightblank = PRESCALE_WIDTH - h_end;\n\n    if (isblank && prevwasblank) {\n        return false;\n    }\n\n    prevwasblank = isblank;\n\n    linecount = PRESCALE_WIDTH << ctrl.serrate;\n    prescale_ptr = v_start * linecount + h_start + (lowerfield ? PRESCALE_WIDTH : 0);\n\n    int32_t i;\n    if (isblank) {\n        // blank signal, clear entire screen buffer\n        memset(tvfadeoutstate, 0, PRESCALE_HEIGHT * sizeof(uint32_t));\n        memset(prescale, 0, sizeof(prescale));\n    } else {\n        // clear left border\n        int32_t j;\n        if (h_start > 0 && h_start < PRESCALE_WIDTH) {\n            for (i = 0; i < vactivelines; i++) {\n                memset(&prescale[i * PRESCALE_WIDTH], 0, h_start * sizeof(uint32_t));\n            }\n        }\n\n        // clear right border\n        if (h_end >= 0 && h_end < PRESCALE_WIDTH) {\n            for (i = 0; i < vactivelines; i++) {\n                memset(&prescale[i * PRESCALE_WIDTH + h_end], 0, hrightblank * sizeof(uint32_t));\n            }\n        }\n\n        // clear top border\n        for (i = 0; i < ((v_start << ctrl.serrate) + lowerfield); i++) {\n            if (tvfadeoutstate[i]) {\n                tvfadeoutstate[i]--;\n                if (!tvfadeoutstate[i]) {\n                    if (validh) {\n                        memset(&prescale[i * PRESCALE_WIDTH + h_start], 0, hres * sizeof(uint32_t));\n                    } else {\n                        memset(&prescale[i * PRESCALE_WIDTH], 0, PRESCALE_WIDTH * sizeof(uint32_t));\n                    }\n                }\n            }\n        }\n\n        if (!ctrl.serrate) {\n            for(j = 0; j < vres; j++) {\n                if (validh) {\n                    tvfadeoutstate[i] = 2;\n                } else if (tvfadeoutstate[i]) {\n                    tvfadeoutstate[i]--;\n                    if (!tvfadeoutstate[i]) {\n                        memset(&prescale[i * PRESCALE_WIDTH], 0, PRESCALE_WIDTH * sizeof(uint32_t));\n                    }\n                }\n\n                i++;\n            }\n        } else {\n            for(j = 0; j < vres; j++) {\n                if (validh) {\n                    tvfadeoutstate[i] = 2;\n                } else if (tvfadeoutstate[i]) {\n                    tvfadeoutstate[i]--;\n                    if (!tvfadeoutstate[i]) {\n                        memset(&prescale[i * PRESCALE_WIDTH], 0, PRESCALE_WIDTH * sizeof(uint32_t));\n                    }\n                }\n\n                if (tvfadeoutstate[i + 1]) {\n                    tvfadeoutstate[i + 1]--;\n                    if (!tvfadeoutstate[i + 1]) {\n                        if (validh) {\n                            memset(&prescale[(i + 1) * PRESCALE_WIDTH + h_start], 0, hres * sizeof(uint32_t));\n                        } else {\n                            memset(&prescale[(i + 1) * PRESCALE_WIDTH], 0, PRESCALE_WIDTH * sizeof(uint32_t));\n                        }\n                    }\n                }\n\n                i += 2;\n            }\n        }\n\n        // clear bottom border\n        for (; i < vactivelines; i++) {\n            if (tvfadeoutstate[i]) {\n                tvfadeoutstate[i]--;\n            }\n            if (!tvfadeoutstate[i]) {\n                if (validh) {\n                    memset(&prescale[i * PRESCALE_WIDTH + h_start], 0, hres * sizeof(uint32_t));\n                } else {\n                    memset(&prescale[i * PRESCALE_WIDTH], 0, PRESCALE_WIDTH * sizeof(uint32_t));\n                }\n            }\n        }\n    }\n\n    if (!validh) {\n        return false;\n    }\n\n    // run filter update in parallel if enabled\n    if (config.parallel) {\n        parallel_run(vi_process_full_parallel);\n    } else {\n        vi_process_full_parallel(0);\n    }\n\n    // finish and send buffer to screen\n    fb->pixels = prescale;\n    fb->pitch = PRESCALE_WIDTH;\n\n    if (config.vi.hide_overscan) {\n        // crop away overscan area from prescale\n        fb->width = maxhpass - minhpass;\n        fb->height = vres << ctrl.serrate;\n        fb->height_out = (vres << 1) * V_SYNC_NTSC / v_sync;\n        int32_t x = h_start + minhpass;\n        int32_t y = (v_start + (emucontrolsvicurrent ? lowerfield : 0)) << ctrl.serrate;\n        fb->pixels += x + y * fb->pitch;\n    } else {\n        // use entire prescale buffer\n        fb->width = PRESCALE_WIDTH;\n        fb->height = (ispal ? V_RES_PAL : V_RES_NTSC) >> !ctrl.serrate;\n        fb->height_out = V_RES_NTSC;\n    }\n\n    // convert to 16:9 if enabled\n    if (config.vi.widescreen) {\n        fb->height_out = fb->height_out * 3 / 4;\n    }\n\n    return fb->width > 0 && fb->height > 0;\n}\n\nstatic void vi_process_fast_parallel(uint32_t worker_id)\n{\n    int32_t y;\n    int32_t y_begin = 0;\n    int32_t y_end = vres_raw;\n    int32_t y_inc = 1;\n\n    // drop every other interlaced frame to avoid \"wobbly\" output due to the\n    // vertical offset\n    // TODO: completely skip rendering these frames in unfiltered to improve\n    // performance?\n    if (ctrl.serrate && v_current_line) {\n        return;\n    }\n\n    if (config.parallel) {\n        y_begin = worker_id;\n        y_inc = parallel_num_workers();\n    }\n\n    for (y = y_begin; y < y_end; y += y_inc) {\n        int32_t x;\n        int32_t line = y * vi_width_low;\n\n        struct n64video_pixel* pixel_row = &prescale[y * hres_raw];\n\n        for (x = 0; x < hres_raw; x++) {\n            struct n64video_pixel* pixel = &pixel_row[x];\n\n            switch (config.vi.mode) {\n                case VI_MODE_COLOR:\n                    switch (ctrl.type) {\n                        case VI_TYPE_RGBA5551: {\n                            uint16_t pix = rdram_read_idx16((frame_buffer >> 1) + line + x);\n                            pixel->r = (uint8_t)RGBA16_R(pix);\n                            pixel->g = (uint8_t)RGBA16_G(pix);\n                            pixel->b = (uint8_t)RGBA16_B(pix);\n                            break;\n                        }\n\n                        case VI_TYPE_RGBA8888: {\n                            uint32_t pix = rdram_read_idx32((frame_buffer >> 2) + line + x);\n                            pixel->r = (uint8_t)RGBA32_R(pix);\n                            pixel->g = (uint8_t)RGBA32_G(pix);\n                            pixel->b = (uint8_t)RGBA32_B(pix);\n                            break;\n                        }\n\n                        default:\n                            return;\n                    }\n\n                    gamma_filters(pixel, ctrl.gamma_enable, false, &state[worker_id].vi_rseed);\n                    break;\n\n                case VI_MODE_DEPTH: {\n                    if (zb_address) {\n                        pixel->r = pixel->g = pixel->b = rdram_read_idx16((zb_address >> 1) + line + x) >> 8;\n                    }\n                    break;\n                }\n\n                case VI_MODE_COVERAGE: {\n                    // TODO: incorrect for RGBA8888?\n                    uint8_t hval;\n                    uint16_t pix;\n                    rdram_read_pair16(&pix, &hval, (frame_buffer >> 1) + line + x);\n                    pixel->r = pixel->g = pixel->b = (((pix & 1) << 2) | hval) << 5;\n                    break;\n                }\n\n                default:\n                    return;\n            }\n        }\n    }\n}\n\nstatic bool vi_process_fast(struct n64video_frame_buffer* fb)\n{\n    // note: this is probably a very, very crude method to get the frame size,\n    // but should hopefully work most of the time\n    hres_raw = (int32_t)x_add * hres / 1024;\n    vres_raw = (int32_t)y_add * vres / 1024;\n\n    // skip invalid frame sizes\n    if (hres_raw <= 0 || vres_raw <= 0) {\n        return false;\n    }\n\n    // skip blank/invalid modes\n    if (!(ctrl.type & 2)) {\n        return false;\n    }\n\n    // run filter update in parallel if enabled\n    if (config.parallel) {\n        parallel_run(vi_process_fast_parallel);\n    } else {\n        vi_process_fast_parallel(0);\n    }\n\n    // finish and send buffer to screen\n    fb->pixels = prescale;\n    fb->width = hres_raw;\n    fb->height = vres_raw;\n    fb->pitch = hres_raw;\n\n    // get display size of filtered mode\n    int32_t filtered_width = maxhpass - minhpass;\n    int32_t filtered_height = (vres << 1) * V_SYNC_NTSC / v_sync;\n\n    // re-calculate cropped 8 pixel area on the left and right from filtered mode\n    int32_t border_width = (hres - filtered_width) * hres_raw / hres;\n    fb->pixels += (border_width / 2) + 1;\n    fb->width -= border_width;\n\n    // force aspect ratio of filtered mode\n    fb->height_out = fb->width * filtered_height / filtered_width;\n\n    // convert to 16:9 if enabled\n    if (config.vi.widescreen) {\n        fb->height_out = fb->height_out * 3 / 4;\n    }\n\n    return fb->width > 0 && fb->height > 0;\n}\n\nvoid vi_set_zbuffer_address(uint32_t address)\n{\n    zb_address = address;\n}\n\nvoid n64video_update_screen(struct n64video_frame_buffer* fb)\n{\n    // check for configuration errors\n    if (config.vi.mode >= VI_MODE_NUM) {\n        msg_error(\"Invalid VI mode: %d\", config.vi.mode);\n    }\n\n    // parse and check some common registers\n    vi_reg_ptr = config.gfx.vi_reg;\n\n    v_start = (*vi_reg_ptr[VI_V_START] >> 16) & 0x3ff;\n    h_start = (*vi_reg_ptr[VI_H_START] >> 16) & 0x3ff;\n\n    int32_t v_end = *vi_reg_ptr[VI_V_START] & 0x3ff;\n    int32_t h_end = *vi_reg_ptr[VI_H_START] & 0x3ff;\n\n    hres =  h_end - h_start;\n    vres = (v_end - v_start) >> 1; // vertical is measured in half-lines\n\n    x_add = *vi_reg_ptr[VI_X_SCALE] & 0xfff;\n    x_start = (*vi_reg_ptr[VI_X_SCALE] >> 16) & 0xfff;\n\n    y_add = *vi_reg_ptr[VI_Y_SCALE] & 0xfff;\n    y_start = (*vi_reg_ptr[VI_Y_SCALE] >> 16) & 0xfff;\n\n    v_sync = *vi_reg_ptr[VI_V_SYNC] & 0x3ff;\n    v_current_line = *vi_reg_ptr[VI_V_CURRENT_LINE] & 1;\n\n    vi_width_low = *vi_reg_ptr[VI_WIDTH] & 0xfff;\n    frame_buffer = *vi_reg_ptr[VI_ORIGIN] & 0xffffff;\n\n    if (ctrl.aa_mode == VI_AA_REPLICATE && (ctrl.type & 2) && h_start < (ctrl.type == VI_TYPE_RGBA5551 ? 0x80 : 0x40) && x_add <= 0x200) {\n        vinnglitch = ctrl.type == VI_TYPE_RGBA5551 ? 0x40 : 0x20;\n    } else {\n        vinnglitch = 0;\n    }\n\n    // cancel if the frame buffer contains no valid address\n    if (!frame_buffer) {\n        fb->valid = false;\n        return;\n    }\n\n    // split up VI_CONTROL bits\n    uint32_t vi_control = *vi_reg_ptr[VI_STATUS];\n    ctrl.type = vi_control & 3;\n    ctrl.gamma_dither_enable = (vi_control >> 2) & 1;\n    ctrl.gamma_enable = (vi_control >> 3) & 1;\n    ctrl.divot_enable = (vi_control >> 4) & 1;\n    ctrl.vbus_clock_enable = (vi_control >> 5) & 1;\n    ctrl.serrate = (vi_control >> 6) & 1;\n    ctrl.test_mode = (vi_control >> 7) & 1;\n    ctrl.aa_mode = (vi_control >> 8) & 3;\n    ctrl.kill_we = (vi_control >> 11) & 1;\n    ctrl.pixel_advance = (vi_control >> 12) & 0x7;\n    ctrl.dither_filter_enable = (vi_control >> 16) & 1;\n\n    // check for unexpected VI type bits set\n    if (ctrl.type & ~3) {\n        msg_error(\"Unknown framebuffer format %d\", ctrl.type);\n    }\n\n    // check for the dangerous vbus_clock_enable flag. it was introduced to\n    // configure Ultra 64 prototypes and enabling it on final hardware will\n    // enable two output drivers on the same bus at the same time\n    if (ctrl.vbus_clock_enable && !onetimewarnings.vbusclock) {\n        msg_warning(\"vi_update: vbus_clock_enable bit set in VI_CONTROL_REG \"\n                    \"register. Never run this code on your N64! It's rumored \"\n                    \"that turning this bit on will result in permanent damage \"\n                    \"to the hardware! Emulation will now continue.\");\n        onetimewarnings.vbusclock = true;\n    }\n\n    // adjust sizes and offsets\n    ispal = v_sync > (V_SYNC_NTSC + 25);\n    h_start -= (ispal ? 128 : 108);\n\n    bool h_start_clamped = false;\n\n    if (h_start < 0) {\n        x_start += (x_add * (-h_start));\n        hres += h_start;\n\n        h_start = 0;\n        h_start_clamped = true;\n    }\n\n    int32_t vstartoffset = ispal ? 44 : 34;\n    v_start = (v_start - vstartoffset) / 2;\n\n    if (v_start < 0) {\n        y_start += (y_add * (uint32_t)(-v_start));\n        v_start = 0;\n    }\n\n    bool hres_clamped = false;\n\n    if ((hres + h_start) > PRESCALE_WIDTH) {\n        hres = PRESCALE_WIDTH - h_start;\n        hres_clamped = true;\n    }\n\n    if ((vres + v_start) > PRESCALE_HEIGHT) {\n        vres = PRESCALE_HEIGHT - v_start;\n        msg_warning(\"vres = %d v_start = %d v_video_start = %d\", vres, v_start, (*vi_reg_ptr[VI_V_START] >> 16) & 0x3ff);\n    }\n\n    vactivelines = v_sync - vstartoffset;\n\n    if (vactivelines > PRESCALE_HEIGHT) {\n        msg_error(\"VI_V_SYNC_REG too big\");\n    }\n\n    fb->valid = true;\n\n    if (vactivelines >= 0) {\n        uint32_t lineshifter = !ctrl.serrate;\n        vactivelines >>= lineshifter;\n\n        minhpass = h_start_clamped ? 0 : 8;\n        maxhpass = hres_clamped ? hres : (hres - 7);\n\n        // run filter update in parallel if enabled\n        if (config.vi.mode == VI_MODE_NORMAL) {\n            fb->valid = vi_process_full(fb);\n        } else {\n            fb->valid = vi_process_fast(fb);\n        }\n    }\n}\n\nstatic void vi_close(void)\n{\n}\n\n#endif // N64VIDEO_C\n"
  },
  {
    "path": "src/core/n64video.c",
    "content": "#include \"n64video.h\"\n#include \"common.h\"\n#include \"msg.h\"\n#include \"parallel.h\"\n\n#include <memory.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n\n#define MIN(a, b) (((a) < (b)) ? (a) : (b))\n#define MAX(a, b) (((a) > (b)) ? (a) : (b))\n#define CLAMP(x, lo, hi) (((x) > (hi)) ? (hi) : (((x) < (lo)) ? (lo) : (x)))\n\n#define SIGN16(x)   ((int16_t)(x))\n#define SIGN8(x)    ((int8_t)(x))\n\n#define SIGN(x, numb)\t(((x) & ((1 << (numb)) - 1)) | -((x) & (1 << ((numb) - 1))))\n#define SIGNF(x, numb)\t((x) | -((x) & (1 << ((numb) - 1))))\n\n#define TRELATIVE(x, y)     ((x) - ((y) << 3))\n\n#define PIXELS_TO_BYTES(pix, siz) (((pix) << (siz)) >> 1)\n\n// RGBA5551 to RGBA8888 helper\n#define RGBA16_R(x) (((x) >> 8) & 0xf8)\n#define RGBA16_G(x) (((x) & 0x7c0) >> 3)\n#define RGBA16_B(x) (((x) & 0x3e) << 2)\n\n// RGBA8888 helper\n#define RGBA32_R(x) (((x) >> 24) & 0xff)\n#define RGBA32_G(x) (((x) >> 16) & 0xff)\n#define RGBA32_B(x) (((x) >> 8) & 0xff)\n#define RGBA32_A(x) ((x) & 0xff)\n\n// maximum number of commands to buffer for parallel processing\n#define CMD_BUFFER_SIZE 1024\n\n// maximum data size of a single command in bytes\n#define CMD_MAX_SIZE 176\n\n// maximum data size of a single command in 32 bit integers\n#define CMD_MAX_INTS (CMD_MAX_SIZE / sizeof(int32_t))\n\n// extracts the command ID from a command buffer\n#define CMD_ID(cmd) ((*(cmd) >> 24) & 0x3f)\n\n// list of command IDs\n#define CMD_ID_NO_OP                           0x00\n#define CMD_ID_FILL_TRIANGLE                   0x08\n#define CMD_ID_FILL_ZBUFFER_TRIANGLE           0x09\n#define CMD_ID_TEXTURE_TRIANGLE                0x0a\n#define CMD_ID_TEXTURE_ZBUFFER_TRIANGLE        0x0b\n#define CMD_ID_SHADE_TRIANGLE                  0x0c\n#define CMD_ID_SHADE_ZBUFFER_TRIANGLE          0x0d\n#define CMD_ID_SHADE_TEXTURE_TRIANGLE          0x0e\n#define CMD_ID_SHADE_TEXTURE_Z_BUFFER_TRIANGLE 0x0f\n#define CMD_ID_TEXTURE_RECTANGLE               0x24\n#define CMD_ID_TEXTURE_RECTANGLE_FLIP          0x25\n#define CMD_ID_SYNC_LOAD                       0x26\n#define CMD_ID_SYNC_PIPE                       0x27\n#define CMD_ID_SYNC_TILE                       0x28\n#define CMD_ID_SYNC_FULL                       0x29\n#define CMD_ID_SET_KEY_GB                      0x2a\n#define CMD_ID_SET_KEY_R                       0x2b\n#define CMD_ID_SET_CONVERT                     0x2c\n#define CMD_ID_SET_SCISSOR                     0x2d\n#define CMD_ID_SET_PRIM_DEPTH                  0x2e\n#define CMD_ID_SET_OTHER_MODES                 0x2f\n#define CMD_ID_LOAD_TLUT                       0x30\n#define CMD_ID_SET_TILE_SIZE                   0x32\n#define CMD_ID_LOAD_BLOCK                      0x33\n#define CMD_ID_LOAD_TILE                       0x34\n#define CMD_ID_SET_TILE                        0x35\n#define CMD_ID_FILL_RECTANGLE                  0x36\n#define CMD_ID_SET_FILL_COLOR                  0x37\n#define CMD_ID_SET_FOG_COLOR                   0x38\n#define CMD_ID_SET_BLEND_COLOR                 0x39\n#define CMD_ID_SET_PRIM_COLOR                  0x3a\n#define CMD_ID_SET_ENV_COLOR                   0x3b\n#define CMD_ID_SET_COMBINE                     0x3c\n#define CMD_ID_SET_TEXTURE_IMAGE               0x3d\n#define CMD_ID_SET_MASK_IMAGE                  0x3e\n#define CMD_ID_SET_COLOR_IMAGE                 0x3f\n\nstatic struct n64video_config config;\n\nstatic struct\n{\n    bool fillmbitcrashes, vbusclock;\n} onetimewarnings;\n\nstatic int rdp_pipeline_crashed = 0;\n\nstatic STRICTINLINE int32_t clamp(int32_t value, int32_t min, int32_t max)\n{\n    if (value < min)\n        return min;\n    else if (value > max)\n        return max;\n    else\n        return value;\n}\n\nstatic STRICTINLINE uint32_t irand(uint32_t* state)\n{\n    *state = *state * 0x343fd + 0x269ec3;\n    return ((*state >> 16) & 0x7fff);\n}\n\n// include guard to prevent compilation of code modules\n// as translation units\n#define N64VIDEO_C\n\n#include \"n64video/rdp.c\"\n#include \"n64video/vi.c\"\n\nstatic uint32_t rdp_cmd_buf[CMD_BUFFER_SIZE][CMD_MAX_INTS];\nstatic uint32_t rdp_cmd_buf_pos;\n\nstatic uint32_t rdp_cmd_pos;\nstatic uint32_t rdp_cmd_id;\nstatic uint32_t rdp_cmd_len;\n\n// table of commands that require thread synchronization in\n// multithreaded mode\nstatic bool rdp_cmd_sync[64];\n\nstatic void cmd_run_buffered(uint32_t worker_id)\n{\n    uint32_t pos;\n    for (pos = 0; pos < rdp_cmd_buf_pos; pos++) {\n        rdp_cmd(&state[worker_id], rdp_cmd_buf[pos]);\n    }\n}\n\nstatic void cmd_flush(void)\n{\n    // only run if there's something buffered\n    if (rdp_cmd_buf_pos) {\n        // let workers run all buffered commands in parallel\n        parallel_run(cmd_run_buffered);\n        // reset buffer by starting from the beginning\n        rdp_cmd_buf_pos = 0;\n    }\n}\n\nstatic void cmd_init(void)\n{\n    rdp_cmd_pos = 0;\n    rdp_cmd_id = 0;\n    rdp_cmd_len = CMD_MAX_INTS;\n}\n\nvoid n64video_config_init(struct n64video_config* conf)\n{\n    memset(conf, 0, sizeof(*conf));\n\n    // config defaults that aren't false or 0\n    conf->parallel = true;\n    conf->vi.vsync = true;\n    conf->vi.interp = VI_INTERP_HYBRID;\n}\n\nstatic void n64video_init_parallel(uint32_t worker_id)\n{\n    struct rdp_state* wstate = &state[worker_id];\n\n    wstate->stride = parallel_num_workers();\n    wstate->offset = worker_id;\n    wstate->rseed = wstate->vi_rseed = 3 + worker_id * 13;\n}\n\nvoid n64video_init(struct n64video_config* _config)\n{\n    if (_config) {\n        config = *_config;\n    }\n\n    // initialize static lookup tables and RDP state, once is enough\n    static bool static_init;\n    if (!static_init) {\n        blender_init_lut();\n        coverage_init_lut();\n        combiner_init_lut();\n        tex_init_lut();\n        z_init_lut();\n\n        for (uint32_t i = 1; i < PARALLEL_MAX_WORKERS; i++) {\n            rdp_init(&state[i]);\n        }\n\n        static_init = true;\n    }\n\n    // enable sync switches depending on compatibility mode\n    memset(rdp_cmd_sync, 0, sizeof(rdp_cmd_sync));\n    switch (config.dp.compat) {\n        case DP_COMPAT_HIGH:\n            rdp_cmd_sync[CMD_ID_SET_TEXTURE_IMAGE] = true;\n        case DP_COMPAT_MEDIUM:\n            rdp_cmd_sync[CMD_ID_SET_MASK_IMAGE] = true;\n            rdp_cmd_sync[CMD_ID_SET_COLOR_IMAGE] = true;\n        case DP_COMPAT_LOW:\n            rdp_cmd_sync[CMD_ID_SYNC_FULL] = true;\n    }\n\n    // init internals\n    rdram_init();\n    vi_init();\n    cmd_init();\n\n    rdp_pipeline_crashed = 0;\n    memset(&onetimewarnings, 0, sizeof(onetimewarnings));\n\n    if (config.parallel) {\n        // init worker system, use busy looping\n        parallel_init(config.num_workers, config.busyloop);\n\n        // sync states from main worker\n        for (uint32_t i = 1; i < parallel_num_workers(); i++) {\n            memcpy(&state[i], &state[0], sizeof(struct rdp_state));\n        }\n\n        // init workers\n        parallel_run(n64video_init_parallel);\n    } else {\n        struct rdp_state* wstate = &state[0];\n        wstate->stride = 1;\n        wstate->offset = 0;\n        wstate->rseed = 3;\n    }\n}\n\nvoid n64video_process_list(void)\n{\n    uint32_t** dp_reg = config.gfx.dp_reg;\n    uint32_t dp_current_al = (*dp_reg[DP_CURRENT] & ~7) >> 2;\n    uint32_t dp_end_al = (*dp_reg[DP_END] & ~7) >> 2;\n\n    // don't do anything if the RDP has crashed or the registers are not set up correctly\n    if (rdp_pipeline_crashed || dp_end_al <= dp_current_al) {\n        return;\n    }\n\n    // while there's data in the command buffer...\n    while (dp_end_al - dp_current_al > 0) {\n        uint32_t i, toload;\n        bool xbus_dma = (*dp_reg[DP_STATUS] & DP_STATUS_XBUS_DMA) != 0;\n        uint32_t* dmem = (uint32_t*)config.gfx.dmem;\n        uint32_t* cmd_buf = rdp_cmd_buf[rdp_cmd_buf_pos];\n\n        // when reading the first int, extract the command ID and update the buffer length\n        if (rdp_cmd_pos == 0) {\n            if (xbus_dma) {\n                cmd_buf[rdp_cmd_pos++] = dmem[dp_current_al++ & 0x3ff];\n            } else {\n                cmd_buf[rdp_cmd_pos++] = rdram_read_idx32(dp_current_al++);\n            }\n\n            rdp_cmd_id = CMD_ID(cmd_buf);\n            rdp_cmd_len = rdp_commands[rdp_cmd_id].length >> 2;\n        }\n\n        // copy more data from the N64 to the local command buffer\n        toload = MIN(dp_end_al - dp_current_al, rdp_cmd_len - 1);\n\n        if (xbus_dma) {\n            for (i = 0; i < toload; i++) {\n                cmd_buf[rdp_cmd_pos++] = dmem[dp_current_al++ & 0x3ff];\n            }\n        } else {\n            for (i = 0; i < toload; i++) {\n                cmd_buf[rdp_cmd_pos++] = rdram_read_idx32(dp_current_al++);\n            }\n        }\n\n        // if there's enough data for the current command...\n        if (rdp_cmd_pos == rdp_cmd_len) {\n            // check if parallel processing is enabled\n            if (config.parallel) {\n                // special case: sync_full always needs to be run in main thread\n                if (rdp_cmd_id == CMD_ID_SYNC_FULL) {\n                    // first, run all pending commands\n                    cmd_flush();\n\n                    // parameters are unused, so NULL is fine\n                    rdp_sync_full(NULL, NULL);\n                } else {\n                    // increment buffer position\n                    rdp_cmd_buf_pos++;\n\n                    // flush buffer when it is full or when the current command requires a sync\n                    if (rdp_cmd_buf_pos >= CMD_BUFFER_SIZE || rdp_cmd_sync[rdp_cmd_id]) {\n                        cmd_flush();\n                    }\n                }\n            } else {\n                // run command directly\n                rdp_cmd(&state[0], cmd_buf);\n            }\n\n            // send Z-buffer address to VI for \"depth\" output mode\n            if (rdp_cmd_id == CMD_ID_SET_MASK_IMAGE) {\n                vi_set_zbuffer_address(cmd_buf[1] & 0x0ffffff);\n            }\n\n            // reset current command buffer to prepare for the next one\n            cmd_init();\n        }\n    }\n\n    // update DP registers to indicate that all bytes have been read\n    *dp_reg[DP_START] = *dp_reg[DP_CURRENT] = *dp_reg[DP_END];\n}\n\nvoid n64video_close(void)\n{\n    vi_close();\n    parallel_close();\n}\n"
  },
  {
    "path": "src/core/n64video.h",
    "content": "#pragma once\n\n#include <stdint.h>\n#include <stdbool.h>\n\n#define RDRAM_MAX_SIZE 0x800000\n\n// register enums\nenum dp_register\n{\n    DP_START,\n    DP_END,\n    DP_CURRENT,\n    DP_STATUS,\n    DP_CLOCK,\n    DP_BUFBUSY,\n    DP_PIPEBUSY,\n    DP_TMEM,\n    DP_NUM_REG\n};\n\nenum vi_register\n{\n    VI_STATUS,  // aka VI_CONTROL\n    VI_ORIGIN,  // aka VI_DRAM_ADDR\n    VI_WIDTH,\n    VI_INTR,\n    VI_V_CURRENT_LINE,\n    VI_TIMING,\n    VI_V_SYNC,\n    VI_H_SYNC,\n    VI_LEAP,    // aka VI_H_SYNC_LEAP\n    VI_H_START, // aka VI_H_VIDEO\n    VI_V_START, // aka VI_V_VIDEO\n    VI_V_BURST,\n    VI_X_SCALE,\n    VI_Y_SCALE,\n    VI_NUM_REG\n};\n\n// config enums\nenum vi_mode\n{\n    VI_MODE_NORMAL,     // color buffer with VI filter\n    VI_MODE_COLOR,      // direct color buffer, unfiltered\n    VI_MODE_DEPTH,      // depth buffer as grayscale\n    VI_MODE_COVERAGE,   // coverage as grayscale\n    VI_MODE_NUM\n};\n\nenum vi_interp\n{\n    VI_INTERP_NEAREST,\n    VI_INTERP_LINEAR,\n    VI_INTERP_HYBRID,\n    VI_INTERP_NUM\n};\n\nenum dp_compat_profile\n{\n    DP_COMPAT_LOW,\n    DP_COMPAT_MEDIUM,\n    DP_COMPAT_HIGH,\n    DP_COMPAT_NUM\n};\n\nstruct n64video_pixel\n{\n    uint8_t r;\n    uint8_t g;\n    uint8_t b;\n    uint8_t a;\n};\n\nstruct n64video_frame_buffer\n{\n    struct n64video_pixel* pixels;\n    uint32_t width;\n    uint32_t height;\n    uint32_t height_out;\n    uint32_t pitch;\n    bool valid;\n};\n\nstruct n64video_config\n{\n    struct {\n        uint8_t* rdram;             // RDRAM pointer\n        uint32_t rdram_size;        // size of RDRAM, typically 4 or 8 MiB\n        uint8_t* dmem;              // RSP data memory pointer\n        uint32_t** vi_reg;          // video interface registers\n        uint32_t** dp_reg;          // display processor registers\n        uint32_t* mi_intr_reg;      // MIPS interface interrupt register\n        void (*mi_intr_cb)(void);   // interrupt callback function\n    } gfx;\n    struct {\n        enum vi_mode mode;          // output mode\n        enum vi_interp interp;      // output interpolation method\n        bool widescreen;            // force 16:9 aspect ratio if true\n        bool hide_overscan;         // crop to visible area if true\n        bool vsync;                 // enable vsync if true\n        bool exclusive;             // run in exclusive mode when in fullscreen if true\n        bool integer_scaling;       // one native pixel is displayed as a multiple of a screen pixel if true\n    } vi;\n    struct {\n        enum dp_compat_profile compat;  // multithreading compatibility mode\n    } dp;\n    bool parallel;                  // use multithreaded renderer if true\n    bool busyloop;                  // use a busyloop while waiting for work\n    uint32_t num_workers;           // number of rendering workers\n};\n\nvoid n64video_config_init(struct n64video_config* config);\nvoid n64video_init(struct n64video_config* config);\nvoid n64video_update_screen(struct n64video_frame_buffer* fb);\nvoid n64video_process_list(void);\nvoid n64video_close(void);\n"
  },
  {
    "path": "src/core/parallel.cpp",
    "content": "#include \"parallel.h\"\n\n#include <atomic>\n#include <algorithm>\n#include <condition_variable>\n#include <cstdint>\n#include <functional>\n#include <mutex>\n#include <thread>\n#include <vector>\n#include <stdexcept>\n\nclass Parallel\n{\npublic:\n    Parallel(std::uint32_t num_workers)\n    {\n        if (num_workers == 0) {\n            // auto-select number of workers based on the number of cores\n            m_num_workers = std::thread::hardware_concurrency();\n        } else {\n            m_num_workers = std::min(num_workers, PARALLEL_MAX_WORKERS);\n        }\n\n        // mask for m_tasks_done when all workers have finished their task\n        if (m_num_workers == PARALLEL_MAX_WORKERS) {\n            m_all_tasks_done = ~0ULL;\n        } else {\n            m_all_tasks_done = (1ULL << m_num_workers) - 1;\n        }\n\n        // except worker 0, which runs in the main thread\n        m_all_tasks_done--;\n    }\n\n    virtual ~Parallel()\n    {\n        // wait for all workers to finish their current work\n        wait();\n\n        // exit worker main loops\n        m_accept_work = false;\n        start_work();\n\n        // join worker threads to make sure they have finished\n        for (auto& thread : m_workers) {\n            thread.join();\n        }\n\n        // destroy all worker threads\n        m_workers.clear();\n    }\n\n    void begin()\n    {\n        // give workers an empty task\n        m_task = [](std::uint32_t) {};\n        m_accept_work = true;\n        start_work();\n\n        // create worker threads\n        for (std::uint32_t worker_id = 1; worker_id < m_num_workers; worker_id++) {\n            create_worker(worker_id);\n        }\n\n        // synchronize workers to prepare them for real tasks\n        wait();\n    }\n\n    void run(std::function<void(std::uint32_t)>&& task)\n    {\n        // don't allow more tasks if workers are stopping\n        if (!m_accept_work) {\n            throw std::runtime_error(\"Workers are exiting and no longer accept work\");\n        }\n\n        // prepare task for workers and send signal so they start working\n        m_task = std::move(task);\n        start_work();\n\n        // run worker 0 directly on main thread\n        m_task(0);\n\n        // wait for all workers to finish\n        wait();\n    }\n\n    std::uint32_t num_workers()\n    {\n        return m_num_workers;\n    }\n\nprotected:\n    std::function<void(std::uint32_t)> m_task;\n    std::vector<std::thread> m_workers;\n    std::mutex m_signal_mutex;\n    std::condition_variable m_signal_work;\n    std::condition_variable m_signal_done;\n    std::atomic<uint64_t> m_tasks_done;\n    std::uint64_t m_all_tasks_done;\n    std::atomic<bool> m_accept_work;\n    std::uint32_t m_num_workers;\n\n    virtual void create_worker(std::uint32_t worker_id)\n    {\n        m_workers.emplace_back(std::thread(&Parallel::do_work, this, worker_id));\n    }\n\n    virtual void start_work()\n    {\n        std::unique_lock<std::mutex> ul(m_signal_mutex);\n\n        // clear task bits for all workers\n        m_tasks_done = 0;\n\n        // wake up all workers\n        m_signal_work.notify_all();\n    }\n\n    virtual void do_work(std::uint32_t worker_id)\n    {\n        const std::uint64_t worker_mask = 1LL << worker_id;\n\n        while (m_accept_work) {\n            // do the work\n            m_task(worker_id);\n\n            {\n                std::unique_lock<std::mutex> ul(m_signal_mutex);\n\n                // mark task as done\n                m_tasks_done |= worker_mask;\n\n                // notify main thread\n                m_signal_done.notify_one();\n\n                // take a break and wait for more work\n                m_signal_work.wait(ul, [worker_mask, this] {\n                    return (m_tasks_done & worker_mask) == 0;\n                });\n            }\n        }\n    }\n\n    virtual void wait()\n    {\n        // wait for all workers to set their task bits\n        std::unique_lock<std::mutex> ul(m_signal_mutex);\n        m_signal_done.wait(ul, [this] {\n            return m_tasks_done == m_all_tasks_done;\n        });\n    }\n\n    void operator=(const Parallel&) = delete;\n    Parallel(const Parallel&) = delete;\n};\n\n// busy-looping variant that is more suitable for ARM processors\nclass ParallelBusy : public Parallel\n{\npublic:\n    ParallelBusy(std::uint32_t num_workers) : Parallel(num_workers)\n    {\n    }\n\n    virtual void create_worker(std::uint32_t worker_id)\n    {\n        m_workers.emplace_back(std::thread(&ParallelBusy::do_work, this, worker_id));\n    }\n\n    virtual void start_work()\n    {\n        // clear task bits for all workers\n        m_tasks_done = 0;\n    }\n\n    virtual void do_work(std::uint32_t worker_id)\n    {\n        const std::uint64_t worker_mask = 1LL << worker_id;\n\n        while (m_accept_work) {\n            if ((m_tasks_done & worker_mask) != 0) {\n                std::this_thread::yield();\n                continue;\n            }\n\n            // do the work\n            m_task(worker_id);\n\n            // mark task as done\n            m_tasks_done |= worker_mask;\n        }\n    }\n\n    virtual void wait()\n    {\n        while (m_tasks_done != m_all_tasks_done) {\n            std::this_thread::yield();\n        }\n    }\n};\n\n// C interface for the Parallel class\nstatic std::shared_ptr<Parallel> parallel;\n\nvoid parallel_init(uint32_t num, bool busy)\n{\n    if (busy) {\n        parallel = std::make_unique<ParallelBusy>(num);\n    } else {\n        parallel = std::make_unique<Parallel>(num);\n    }\n\n    parallel->begin();\n}\n\nvoid parallel_run(void task(uint32_t))\n{\n    parallel->run(task);\n}\n\nuint32_t parallel_num_workers()\n{\n    return parallel->num_workers();\n}\n\nvoid parallel_close()\n{\n    parallel.reset();\n}\n"
  },
  {
    "path": "src/core/parallel.h",
    "content": "#pragma once\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdint.h>\n#include <stdbool.h>\n\n#define PARALLEL_MAX_WORKERS 64u\n\nvoid parallel_init(uint32_t num, bool busy);\nvoid parallel_run(void task(uint32_t));\nuint32_t parallel_num_workers();\nvoid parallel_close();\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "src/core/version.h.in",
    "content": "#pragma once\n\n#define GIT_BRANCH \"@GIT_BRANCH@\"\n#define GIT_TAG \"@GIT_TAG@\"\n#define GIT_COMMIT_HASH \"@GIT_COMMIT_HASH@\"\n#define GIT_COMMIT_DATE \"@GIT_COMMIT_DATE@\"\n\n#define CORE_BASE_NAME \"angrylion's RDP Plus\"\n\n#ifdef _DEBUG\n#define CORE_NAME CORE_BASE_NAME \" \" GIT_TAG \" (Debug)\"\n#else\n#define CORE_NAME CORE_BASE_NAME \" \" GIT_TAG\n#endif\n\n#define CORE_SIMPLE_NAME \"angrylion-plus\"\n"
  },
  {
    "path": "src/output/gl_core_3_3.c",
    "content": "#ifndef GLES\n\n#include \"gl_core_3_3.h\"\n#include \"gl_proc.h\"\n#include <stdlib.h>\n#include <string.h>\n#include <stddef.h>\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum sfactor, GLenum dfactor) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield mask) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble depth) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint s) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum mode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum func) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean flag) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble ren_near, GLdouble ren_far) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum cap) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum buf) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum cap) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFinish)(void) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFlush)(void) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum mode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum pname, GLboolean * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum pname, GLdouble * data) = NULL;\nGLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(void) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum pname, GLfloat * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum pname, GLint * data) = NULL;\nconst GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum target, GLenum mode) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum cap) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat width) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum opcode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum pname, GLfloat param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum pname, GLint param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat size) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum face, GLenum mode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum src) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint x, GLint y, GLsizei width, GLsizei height) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum func, GLint ref, GLuint mask) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint mask) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum target, GLenum pname, GLfloat param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum target, GLenum pname, GLint param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum target, GLenum pname, const GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum target, GLuint texture) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei n, const GLuint * textures) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum mode, GLint first, GLsizei count) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei n, GLuint * textures) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint texture) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat factor, GLfloat units) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum texture) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum target, GLint level, void * img) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat value, GLboolean invert) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum mode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum pname, GLfloat param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum pname, const GLfloat * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum pname, GLint param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum pname, const GLint * params) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum target, GLuint id) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum target, GLuint buffer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei n, const GLuint * buffers) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei n, const GLuint * ids) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum target) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei n, GLuint * buffers) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei n, GLuint * ids) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum target, GLenum pname, void ** params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, void * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint id, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum target, GLenum pname, GLint * params) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint buffer) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint id) = NULL;\nvoid * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum target, GLenum access) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum target) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint program, GLuint shader) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint program, GLuint index, const GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint shader) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(void) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum type) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint program) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint shader) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint program, GLuint shader) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint index) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei n, const GLenum * bufs) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint index) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint program, const GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint program, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint shader, GLenum pname, GLint * params) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint program, const GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint program, GLint location, GLfloat * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint program, GLint location, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void ** pointer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint * params) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint program) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint shader) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint program) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum face, GLuint mask) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint location, GLfloat v0) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint location, GLsizei count, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint location, GLint v0) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint location, GLsizei count, const GLint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint location, GLfloat v0, GLfloat v1) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint location, GLsizei count, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint location, GLint v0, GLint v1) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint location, GLsizei count, const GLint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint location, GLsizei count, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint location, GLsizei count, const GLint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint location, GLsizei count, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint location, GLsizei count, const GLint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint program) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint program) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint index, GLdouble x) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint index, const GLdouble * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint index, GLfloat x) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint index, const GLfloat * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint index, GLshort x) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint index, const GLshort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint index, const GLdouble * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint index, const GLfloat * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint index, GLshort x, GLshort y) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint index, const GLshort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint index, const GLdouble * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint index, const GLfloat * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint index, const GLshort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint index, const GLbyte * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint index, const GLint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint index, const GLshort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint index, const GLubyte * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint index, const GLuint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint index, const GLushort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint index, const GLbyte * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint index, const GLdouble * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint index, const GLfloat * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint index, const GLint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint index, const GLshort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint index, const GLubyte * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint index, const GLuint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint index, const GLushort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint id, GLenum mode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum primitiveMode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum target, GLuint index, GLuint buffer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint program, GLuint color, const GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum target, GLuint framebuffer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum target, GLuint renderbuffer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint ren_array) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = NULL;\nGLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum target) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum target, GLenum clamp) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei n, const GLuint * framebuffers) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei n, const GLuint * renderbuffers) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei n, const GLuint * arrays) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum target, GLuint index) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum target, GLuint index) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(void) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(void) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei n, GLuint * framebuffers) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei n, GLuint * renderbuffers) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei n, GLuint * arrays) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum target) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum target, GLuint index, GLboolean * data) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint program, const GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum target, GLuint index, GLint * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL;\nconst GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum name, GLuint index) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum target, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum target, GLenum pname, GLuint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint program, GLint location, GLuint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint * params) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum target, GLuint index) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint framebuffer) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint renderbuffer) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint ren_array) = NULL;\nvoid * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum target, GLenum pname, const GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum target, GLenum pname, const GLuint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint location, GLuint v0) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint location, GLsizei count, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint location, GLuint v0, GLuint v1) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint location, GLsizei count, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint location, GLsizei count, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint location, GLsizei count, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint index, GLint x) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint index, const GLint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint index, GLuint x) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint index, const GLuint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint index, GLint x, GLint y) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint index, const GLint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint index, GLuint x, GLuint y) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint index, const GLuint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint index, const GLint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint index, const GLuint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint index, const GLbyte * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint index, const GLint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint index, const GLshort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint index, const GLubyte * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint index, const GLuint * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint index, const GLushort * v) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params) = NULL;\nGLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint program, const GLchar * uniformBlockName) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint index) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum target, GLenum internalformat, GLuint buffer) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = NULL;\n\nGLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync sync) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex) = NULL;\nGLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum condition, GLbitfield flags) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum target, GLenum attachment, GLuint texture, GLint level) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum target, GLuint index, GLint64 * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum pname, GLint64 * data) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat * val) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync sync) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum mode) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint maskNumber, GLbitfield mask) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = NULL;\n\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint unit, GLuint sampler) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei count, const GLuint * samplers) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei count, GLuint * samplers) = NULL;\nGLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint program, const GLchar * name) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint sampler, GLenum pname, GLint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint sampler, GLenum pname, GLuint * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat * params) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint * params) = NULL;\nGLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint sampler) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint id, GLenum target) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint sampler, GLenum pname, const GLint * param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint sampler, GLenum pname, const GLuint * param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat * param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint * param) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint index, GLuint divisor) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL;\nvoid (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL;\n\nstatic int Load_Version_3_3(void)\n{\n\tint numFailed = 0;\n\tif(!_ptrc_glBlendFunc)\n\t\t_ptrc_glBlendFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glBlendFunc\");\n\tif(!_ptrc_glBlendFunc) numFailed++;\n\tif(!_ptrc_glClear)\n\t\t_ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress(\"glClear\");\n\tif(!_ptrc_glClear) numFailed++;\n\tif(!_ptrc_glClearColor)\n\t\t_ptrc_glClearColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glClearColor\");\n\tif(!_ptrc_glClearColor) numFailed++;\n\tif(!_ptrc_glClearDepth)\n\t\t_ptrc_glClearDepth = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress(\"glClearDepth\");\n\tif(!_ptrc_glClearDepth) numFailed++;\n\tif(!_ptrc_glClearStencil)\n\t\t_ptrc_glClearStencil = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress(\"glClearStencil\");\n\tif(!_ptrc_glClearStencil) numFailed++;\n\tif(!_ptrc_glColorMask)\n\t\t_ptrc_glColorMask = (void (CODEGEN_FUNCPTR *)(GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress(\"glColorMask\");\n\tif(!_ptrc_glColorMask) numFailed++;\n\tif(!_ptrc_glCullFace)\n\t\t_ptrc_glCullFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCullFace\");\n\tif(!_ptrc_glCullFace) numFailed++;\n\tif(!_ptrc_glDepthFunc)\n\t\t_ptrc_glDepthFunc = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDepthFunc\");\n\tif(!_ptrc_glDepthFunc) numFailed++;\n\tif(!_ptrc_glDepthMask)\n\t\t_ptrc_glDepthMask = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress(\"glDepthMask\");\n\tif(!_ptrc_glDepthMask) numFailed++;\n\tif(!_ptrc_glDepthRange)\n\t\t_ptrc_glDepthRange = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress(\"glDepthRange\");\n\tif(!_ptrc_glDepthRange) numFailed++;\n\tif(!_ptrc_glDisable)\n\t\t_ptrc_glDisable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDisable\");\n\tif(!_ptrc_glDisable) numFailed++;\n\tif(!_ptrc_glDrawBuffer)\n\t\t_ptrc_glDrawBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glDrawBuffer\");\n\tif(!_ptrc_glDrawBuffer) numFailed++;\n\tif(!_ptrc_glEnable)\n\t\t_ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glEnable\");\n\tif(!_ptrc_glEnable) numFailed++;\n\tif(!_ptrc_glFinish)\n\t\t_ptrc_glFinish = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress(\"glFinish\");\n\tif(!_ptrc_glFinish) numFailed++;\n\tif(!_ptrc_glFlush)\n\t\t_ptrc_glFlush = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress(\"glFlush\");\n\tif(!_ptrc_glFlush) numFailed++;\n\tif(!_ptrc_glFrontFace)\n\t\t_ptrc_glFrontFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glFrontFace\");\n\tif(!_ptrc_glFrontFace) numFailed++;\n\tif(!_ptrc_glGetBooleanv)\n\t\t_ptrc_glGetBooleanv = (void (CODEGEN_FUNCPTR *)(GLenum, GLboolean *))IntGetProcAddress(\"glGetBooleanv\");\n\tif(!_ptrc_glGetBooleanv) numFailed++;\n\tif(!_ptrc_glGetDoublev)\n\t\t_ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress(\"glGetDoublev\");\n\tif(!_ptrc_glGetDoublev) numFailed++;\n\tif(!_ptrc_glGetError)\n\t\t_ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)(void))IntGetProcAddress(\"glGetError\");\n\tif(!_ptrc_glGetError) numFailed++;\n\tif(!_ptrc_glGetFloatv)\n\t\t_ptrc_glGetFloatv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress(\"glGetFloatv\");\n\tif(!_ptrc_glGetFloatv) numFailed++;\n\tif(!_ptrc_glGetIntegerv)\n\t\t_ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress(\"glGetIntegerv\");\n\tif(!_ptrc_glGetIntegerv) numFailed++;\n\tif(!_ptrc_glGetString)\n\t\t_ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glGetString\");\n\tif(!_ptrc_glGetString) numFailed++;\n\tif(!_ptrc_glGetTexImage)\n\t\t_ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, void *))IntGetProcAddress(\"glGetTexImage\");\n\tif(!_ptrc_glGetTexImage) numFailed++;\n\tif(!_ptrc_glGetTexLevelParameterfv)\n\t\t_ptrc_glGetTexLevelParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLfloat *))IntGetProcAddress(\"glGetTexLevelParameterfv\");\n\tif(!_ptrc_glGetTexLevelParameterfv) numFailed++;\n\tif(!_ptrc_glGetTexLevelParameteriv)\n\t\t_ptrc_glGetTexLevelParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint *))IntGetProcAddress(\"glGetTexLevelParameteriv\");\n\tif(!_ptrc_glGetTexLevelParameteriv) numFailed++;\n\tif(!_ptrc_glGetTexParameterfv)\n\t\t_ptrc_glGetTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress(\"glGetTexParameterfv\");\n\tif(!_ptrc_glGetTexParameterfv) numFailed++;\n\tif(!_ptrc_glGetTexParameteriv)\n\t\t_ptrc_glGetTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetTexParameteriv\");\n\tif(!_ptrc_glGetTexParameteriv) numFailed++;\n\tif(!_ptrc_glHint)\n\t\t_ptrc_glHint = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glHint\");\n\tif(!_ptrc_glHint) numFailed++;\n\tif(!_ptrc_glIsEnabled)\n\t\t_ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glIsEnabled\");\n\tif(!_ptrc_glIsEnabled) numFailed++;\n\tif(!_ptrc_glLineWidth)\n\t\t_ptrc_glLineWidth = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glLineWidth\");\n\tif(!_ptrc_glLineWidth) numFailed++;\n\tif(!_ptrc_glLogicOp)\n\t\t_ptrc_glLogicOp = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glLogicOp\");\n\tif(!_ptrc_glLogicOp) numFailed++;\n\tif(!_ptrc_glPixelStoref)\n\t\t_ptrc_glPixelStoref = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress(\"glPixelStoref\");\n\tif(!_ptrc_glPixelStoref) numFailed++;\n\tif(!_ptrc_glPixelStorei)\n\t\t_ptrc_glPixelStorei = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPixelStorei\");\n\tif(!_ptrc_glPixelStorei) numFailed++;\n\tif(!_ptrc_glPointSize)\n\t\t_ptrc_glPointSize = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress(\"glPointSize\");\n\tif(!_ptrc_glPointSize) numFailed++;\n\tif(!_ptrc_glPolygonMode)\n\t\t_ptrc_glPolygonMode = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glPolygonMode\");\n\tif(!_ptrc_glPolygonMode) numFailed++;\n\tif(!_ptrc_glReadBuffer)\n\t\t_ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glReadBuffer\");\n\tif(!_ptrc_glReadBuffer) numFailed++;\n\tif(!_ptrc_glReadPixels)\n\t\t_ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *))IntGetProcAddress(\"glReadPixels\");\n\tif(!_ptrc_glReadPixels) numFailed++;\n\tif(!_ptrc_glScissor)\n\t\t_ptrc_glScissor = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glScissor\");\n\tif(!_ptrc_glScissor) numFailed++;\n\tif(!_ptrc_glStencilFunc)\n\t\t_ptrc_glStencilFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint))IntGetProcAddress(\"glStencilFunc\");\n\tif(!_ptrc_glStencilFunc) numFailed++;\n\tif(!_ptrc_glStencilMask)\n\t\t_ptrc_glStencilMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glStencilMask\");\n\tif(!_ptrc_glStencilMask) numFailed++;\n\tif(!_ptrc_glStencilOp)\n\t\t_ptrc_glStencilOp = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum))IntGetProcAddress(\"glStencilOp\");\n\tif(!_ptrc_glStencilOp) numFailed++;\n\tif(!_ptrc_glTexImage1D)\n\t\t_ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress(\"glTexImage1D\");\n\tif(!_ptrc_glTexImage1D) numFailed++;\n\tif(!_ptrc_glTexImage2D)\n\t\t_ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress(\"glTexImage2D\");\n\tif(!_ptrc_glTexImage2D) numFailed++;\n\tif(!_ptrc_glTexParameterf)\n\t\t_ptrc_glTexParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress(\"glTexParameterf\");\n\tif(!_ptrc_glTexParameterf) numFailed++;\n\tif(!_ptrc_glTexParameterfv)\n\t\t_ptrc_glTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress(\"glTexParameterfv\");\n\tif(!_ptrc_glTexParameterfv) numFailed++;\n\tif(!_ptrc_glTexParameteri)\n\t\t_ptrc_glTexParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress(\"glTexParameteri\");\n\tif(!_ptrc_glTexParameteri) numFailed++;\n\tif(!_ptrc_glTexParameteriv)\n\t\t_ptrc_glTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress(\"glTexParameteriv\");\n\tif(!_ptrc_glTexParameteriv) numFailed++;\n\tif(!_ptrc_glViewport)\n\t\t_ptrc_glViewport = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glViewport\");\n\tif(!_ptrc_glViewport) numFailed++;\n\tif(!_ptrc_glBindTexture)\n\t\t_ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindTexture\");\n\tif(!_ptrc_glBindTexture) numFailed++;\n\tif(!_ptrc_glCopyTexImage1D)\n\t\t_ptrc_glCopyTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))IntGetProcAddress(\"glCopyTexImage1D\");\n\tif(!_ptrc_glCopyTexImage1D) numFailed++;\n\tif(!_ptrc_glCopyTexImage2D)\n\t\t_ptrc_glCopyTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))IntGetProcAddress(\"glCopyTexImage2D\");\n\tif(!_ptrc_glCopyTexImage2D) numFailed++;\n\tif(!_ptrc_glCopyTexSubImage1D)\n\t\t_ptrc_glCopyTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei))IntGetProcAddress(\"glCopyTexSubImage1D\");\n\tif(!_ptrc_glCopyTexSubImage1D) numFailed++;\n\tif(!_ptrc_glCopyTexSubImage2D)\n\t\t_ptrc_glCopyTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glCopyTexSubImage2D\");\n\tif(!_ptrc_glCopyTexSubImage2D) numFailed++;\n\tif(!_ptrc_glDeleteTextures)\n\t\t_ptrc_glDeleteTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteTextures\");\n\tif(!_ptrc_glDeleteTextures) numFailed++;\n\tif(!_ptrc_glDrawArrays)\n\t\t_ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress(\"glDrawArrays\");\n\tif(!_ptrc_glDrawArrays) numFailed++;\n\tif(!_ptrc_glDrawElements)\n\t\t_ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *))IntGetProcAddress(\"glDrawElements\");\n\tif(!_ptrc_glDrawElements) numFailed++;\n\tif(!_ptrc_glGenTextures)\n\t\t_ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenTextures\");\n\tif(!_ptrc_glGenTextures) numFailed++;\n\tif(!_ptrc_glIsTexture)\n\t\t_ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsTexture\");\n\tif(!_ptrc_glIsTexture) numFailed++;\n\tif(!_ptrc_glPolygonOffset)\n\t\t_ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress(\"glPolygonOffset\");\n\tif(!_ptrc_glPolygonOffset) numFailed++;\n\tif(!_ptrc_glTexSubImage1D)\n\t\t_ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress(\"glTexSubImage1D\");\n\tif(!_ptrc_glTexSubImage1D) numFailed++;\n\tif(!_ptrc_glTexSubImage2D)\n\t\t_ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress(\"glTexSubImage2D\");\n\tif(!_ptrc_glTexSubImage2D) numFailed++;\n\tif(!_ptrc_glCopyTexSubImage3D)\n\t\t_ptrc_glCopyTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glCopyTexSubImage3D\");\n\tif(!_ptrc_glCopyTexSubImage3D) numFailed++;\n\tif(!_ptrc_glDrawRangeElements)\n\t\t_ptrc_glDrawRangeElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const void *))IntGetProcAddress(\"glDrawRangeElements\");\n\tif(!_ptrc_glDrawRangeElements) numFailed++;\n\tif(!_ptrc_glTexImage3D)\n\t\t_ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress(\"glTexImage3D\");\n\tif(!_ptrc_glTexImage3D) numFailed++;\n\tif(!_ptrc_glTexSubImage3D)\n\t\t_ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress(\"glTexSubImage3D\");\n\tif(!_ptrc_glTexSubImage3D) numFailed++;\n\tif(!_ptrc_glActiveTexture)\n\t\t_ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glActiveTexture\");\n\tif(!_ptrc_glActiveTexture) numFailed++;\n\tif(!_ptrc_glCompressedTexImage1D)\n\t\t_ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress(\"glCompressedTexImage1D\");\n\tif(!_ptrc_glCompressedTexImage1D) numFailed++;\n\tif(!_ptrc_glCompressedTexImage2D)\n\t\t_ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress(\"glCompressedTexImage2D\");\n\tif(!_ptrc_glCompressedTexImage2D) numFailed++;\n\tif(!_ptrc_glCompressedTexImage3D)\n\t\t_ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress(\"glCompressedTexImage3D\");\n\tif(!_ptrc_glCompressedTexImage3D) numFailed++;\n\tif(!_ptrc_glCompressedTexSubImage1D)\n\t\t_ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress(\"glCompressedTexSubImage1D\");\n\tif(!_ptrc_glCompressedTexSubImage1D) numFailed++;\n\tif(!_ptrc_glCompressedTexSubImage2D)\n\t\t_ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress(\"glCompressedTexSubImage2D\");\n\tif(!_ptrc_glCompressedTexSubImage2D) numFailed++;\n\tif(!_ptrc_glCompressedTexSubImage3D)\n\t\t_ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress(\"glCompressedTexSubImage3D\");\n\tif(!_ptrc_glCompressedTexSubImage3D) numFailed++;\n\tif(!_ptrc_glGetCompressedTexImage)\n\t\t_ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, void *))IntGetProcAddress(\"glGetCompressedTexImage\");\n\tif(!_ptrc_glGetCompressedTexImage) numFailed++;\n\tif(!_ptrc_glSampleCoverage)\n\t\t_ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress(\"glSampleCoverage\");\n\tif(!_ptrc_glSampleCoverage) numFailed++;\n\tif(!_ptrc_glBlendColor)\n\t\t_ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glBlendColor\");\n\tif(!_ptrc_glBlendColor) numFailed++;\n\tif(!_ptrc_glBlendEquation)\n\t\t_ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glBlendEquation\");\n\tif(!_ptrc_glBlendEquation) numFailed++;\n\tif(!_ptrc_glBlendFuncSeparate)\n\t\t_ptrc_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glBlendFuncSeparate\");\n\tif(!_ptrc_glBlendFuncSeparate) numFailed++;\n\tif(!_ptrc_glMultiDrawArrays)\n\t\t_ptrc_glMultiDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *, const GLsizei *, GLsizei))IntGetProcAddress(\"glMultiDrawArrays\");\n\tif(!_ptrc_glMultiDrawArrays) numFailed++;\n\tif(!_ptrc_glMultiDrawElements)\n\t\t_ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const void *const*, GLsizei))IntGetProcAddress(\"glMultiDrawElements\");\n\tif(!_ptrc_glMultiDrawElements) numFailed++;\n\tif(!_ptrc_glPointParameterf)\n\t\t_ptrc_glPointParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress(\"glPointParameterf\");\n\tif(!_ptrc_glPointParameterf) numFailed++;\n\tif(!_ptrc_glPointParameterfv)\n\t\t_ptrc_glPointParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress(\"glPointParameterfv\");\n\tif(!_ptrc_glPointParameterfv) numFailed++;\n\tif(!_ptrc_glPointParameteri)\n\t\t_ptrc_glPointParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress(\"glPointParameteri\");\n\tif(!_ptrc_glPointParameteri) numFailed++;\n\tif(!_ptrc_glPointParameteriv)\n\t\t_ptrc_glPointParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress(\"glPointParameteriv\");\n\tif(!_ptrc_glPointParameteriv) numFailed++;\n\tif(!_ptrc_glBeginQuery)\n\t\t_ptrc_glBeginQuery = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBeginQuery\");\n\tif(!_ptrc_glBeginQuery) numFailed++;\n\tif(!_ptrc_glBindBuffer)\n\t\t_ptrc_glBindBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindBuffer\");\n\tif(!_ptrc_glBindBuffer) numFailed++;\n\tif(!_ptrc_glBufferData)\n\t\t_ptrc_glBufferData = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const void *, GLenum))IntGetProcAddress(\"glBufferData\");\n\tif(!_ptrc_glBufferData) numFailed++;\n\tif(!_ptrc_glBufferSubData)\n\t\t_ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const void *))IntGetProcAddress(\"glBufferSubData\");\n\tif(!_ptrc_glBufferSubData) numFailed++;\n\tif(!_ptrc_glDeleteBuffers)\n\t\t_ptrc_glDeleteBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteBuffers\");\n\tif(!_ptrc_glDeleteBuffers) numFailed++;\n\tif(!_ptrc_glDeleteQueries)\n\t\t_ptrc_glDeleteQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteQueries\");\n\tif(!_ptrc_glDeleteQueries) numFailed++;\n\tif(!_ptrc_glEndQuery)\n\t\t_ptrc_glEndQuery = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glEndQuery\");\n\tif(!_ptrc_glEndQuery) numFailed++;\n\tif(!_ptrc_glGenBuffers)\n\t\t_ptrc_glGenBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenBuffers\");\n\tif(!_ptrc_glGenBuffers) numFailed++;\n\tif(!_ptrc_glGenQueries)\n\t\t_ptrc_glGenQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenQueries\");\n\tif(!_ptrc_glGenQueries) numFailed++;\n\tif(!_ptrc_glGetBufferParameteriv)\n\t\t_ptrc_glGetBufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetBufferParameteriv\");\n\tif(!_ptrc_glGetBufferParameteriv) numFailed++;\n\tif(!_ptrc_glGetBufferPointerv)\n\t\t_ptrc_glGetBufferPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, void **))IntGetProcAddress(\"glGetBufferPointerv\");\n\tif(!_ptrc_glGetBufferPointerv) numFailed++;\n\tif(!_ptrc_glGetBufferSubData)\n\t\t_ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, void *))IntGetProcAddress(\"glGetBufferSubData\");\n\tif(!_ptrc_glGetBufferSubData) numFailed++;\n\tif(!_ptrc_glGetQueryObjectiv)\n\t\t_ptrc_glGetQueryObjectiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetQueryObjectiv\");\n\tif(!_ptrc_glGetQueryObjectiv) numFailed++;\n\tif(!_ptrc_glGetQueryObjectuiv)\n\t\t_ptrc_glGetQueryObjectuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetQueryObjectuiv\");\n\tif(!_ptrc_glGetQueryObjectuiv) numFailed++;\n\tif(!_ptrc_glGetQueryiv)\n\t\t_ptrc_glGetQueryiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetQueryiv\");\n\tif(!_ptrc_glGetQueryiv) numFailed++;\n\tif(!_ptrc_glIsBuffer)\n\t\t_ptrc_glIsBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsBuffer\");\n\tif(!_ptrc_glIsBuffer) numFailed++;\n\tif(!_ptrc_glIsQuery)\n\t\t_ptrc_glIsQuery = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsQuery\");\n\tif(!_ptrc_glIsQuery) numFailed++;\n\tif(!_ptrc_glMapBuffer)\n\t\t_ptrc_glMapBuffer = (void * (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glMapBuffer\");\n\tif(!_ptrc_glMapBuffer) numFailed++;\n\tif(!_ptrc_glUnmapBuffer)\n\t\t_ptrc_glUnmapBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glUnmapBuffer\");\n\tif(!_ptrc_glUnmapBuffer) numFailed++;\n\tif(!_ptrc_glAttachShader)\n\t\t_ptrc_glAttachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glAttachShader\");\n\tif(!_ptrc_glAttachShader) numFailed++;\n\tif(!_ptrc_glBindAttribLocation)\n\t\t_ptrc_glBindAttribLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindAttribLocation\");\n\tif(!_ptrc_glBindAttribLocation) numFailed++;\n\tif(!_ptrc_glBlendEquationSeparate)\n\t\t_ptrc_glBlendEquationSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glBlendEquationSeparate\");\n\tif(!_ptrc_glBlendEquationSeparate) numFailed++;\n\tif(!_ptrc_glCompileShader)\n\t\t_ptrc_glCompileShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glCompileShader\");\n\tif(!_ptrc_glCompileShader) numFailed++;\n\tif(!_ptrc_glCreateProgram)\n\t\t_ptrc_glCreateProgram = (GLuint (CODEGEN_FUNCPTR *)(void))IntGetProcAddress(\"glCreateProgram\");\n\tif(!_ptrc_glCreateProgram) numFailed++;\n\tif(!_ptrc_glCreateShader)\n\t\t_ptrc_glCreateShader = (GLuint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCreateShader\");\n\tif(!_ptrc_glCreateShader) numFailed++;\n\tif(!_ptrc_glDeleteProgram)\n\t\t_ptrc_glDeleteProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDeleteProgram\");\n\tif(!_ptrc_glDeleteProgram) numFailed++;\n\tif(!_ptrc_glDeleteShader)\n\t\t_ptrc_glDeleteShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDeleteShader\");\n\tif(!_ptrc_glDeleteShader) numFailed++;\n\tif(!_ptrc_glDetachShader)\n\t\t_ptrc_glDetachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glDetachShader\");\n\tif(!_ptrc_glDetachShader) numFailed++;\n\tif(!_ptrc_glDisableVertexAttribArray)\n\t\t_ptrc_glDisableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glDisableVertexAttribArray\");\n\tif(!_ptrc_glDisableVertexAttribArray) numFailed++;\n\tif(!_ptrc_glDrawBuffers)\n\t\t_ptrc_glDrawBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLenum *))IntGetProcAddress(\"glDrawBuffers\");\n\tif(!_ptrc_glDrawBuffers) numFailed++;\n\tif(!_ptrc_glEnableVertexAttribArray)\n\t\t_ptrc_glEnableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glEnableVertexAttribArray\");\n\tif(!_ptrc_glEnableVertexAttribArray) numFailed++;\n\tif(!_ptrc_glGetActiveAttrib)\n\t\t_ptrc_glGetActiveAttrib = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress(\"glGetActiveAttrib\");\n\tif(!_ptrc_glGetActiveAttrib) numFailed++;\n\tif(!_ptrc_glGetActiveUniform)\n\t\t_ptrc_glGetActiveUniform = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress(\"glGetActiveUniform\");\n\tif(!_ptrc_glGetActiveUniform) numFailed++;\n\tif(!_ptrc_glGetAttachedShaders)\n\t\t_ptrc_glGetAttachedShaders = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLuint *))IntGetProcAddress(\"glGetAttachedShaders\");\n\tif(!_ptrc_glGetAttachedShaders) numFailed++;\n\tif(!_ptrc_glGetAttribLocation)\n\t\t_ptrc_glGetAttribLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetAttribLocation\");\n\tif(!_ptrc_glGetAttribLocation) numFailed++;\n\tif(!_ptrc_glGetProgramInfoLog)\n\t\t_ptrc_glGetProgramInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetProgramInfoLog\");\n\tif(!_ptrc_glGetProgramInfoLog) numFailed++;\n\tif(!_ptrc_glGetProgramiv)\n\t\t_ptrc_glGetProgramiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetProgramiv\");\n\tif(!_ptrc_glGetProgramiv) numFailed++;\n\tif(!_ptrc_glGetShaderInfoLog)\n\t\t_ptrc_glGetShaderInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetShaderInfoLog\");\n\tif(!_ptrc_glGetShaderInfoLog) numFailed++;\n\tif(!_ptrc_glGetShaderSource)\n\t\t_ptrc_glGetShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetShaderSource\");\n\tif(!_ptrc_glGetShaderSource) numFailed++;\n\tif(!_ptrc_glGetShaderiv)\n\t\t_ptrc_glGetShaderiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetShaderiv\");\n\tif(!_ptrc_glGetShaderiv) numFailed++;\n\tif(!_ptrc_glGetUniformLocation)\n\t\t_ptrc_glGetUniformLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetUniformLocation\");\n\tif(!_ptrc_glGetUniformLocation) numFailed++;\n\tif(!_ptrc_glGetUniformfv)\n\t\t_ptrc_glGetUniformfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLfloat *))IntGetProcAddress(\"glGetUniformfv\");\n\tif(!_ptrc_glGetUniformfv) numFailed++;\n\tif(!_ptrc_glGetUniformiv)\n\t\t_ptrc_glGetUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint *))IntGetProcAddress(\"glGetUniformiv\");\n\tif(!_ptrc_glGetUniformiv) numFailed++;\n\tif(!_ptrc_glGetVertexAttribPointerv)\n\t\t_ptrc_glGetVertexAttribPointerv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, void **))IntGetProcAddress(\"glGetVertexAttribPointerv\");\n\tif(!_ptrc_glGetVertexAttribPointerv) numFailed++;\n\tif(!_ptrc_glGetVertexAttribdv)\n\t\t_ptrc_glGetVertexAttribdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLdouble *))IntGetProcAddress(\"glGetVertexAttribdv\");\n\tif(!_ptrc_glGetVertexAttribdv) numFailed++;\n\tif(!_ptrc_glGetVertexAttribfv)\n\t\t_ptrc_glGetVertexAttribfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress(\"glGetVertexAttribfv\");\n\tif(!_ptrc_glGetVertexAttribfv) numFailed++;\n\tif(!_ptrc_glGetVertexAttribiv)\n\t\t_ptrc_glGetVertexAttribiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetVertexAttribiv\");\n\tif(!_ptrc_glGetVertexAttribiv) numFailed++;\n\tif(!_ptrc_glIsProgram)\n\t\t_ptrc_glIsProgram = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsProgram\");\n\tif(!_ptrc_glIsProgram) numFailed++;\n\tif(!_ptrc_glIsShader)\n\t\t_ptrc_glIsShader = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsShader\");\n\tif(!_ptrc_glIsShader) numFailed++;\n\tif(!_ptrc_glLinkProgram)\n\t\t_ptrc_glLinkProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glLinkProgram\");\n\tif(!_ptrc_glLinkProgram) numFailed++;\n\tif(!_ptrc_glShaderSource)\n\t\t_ptrc_glShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, const GLint *))IntGetProcAddress(\"glShaderSource\");\n\tif(!_ptrc_glShaderSource) numFailed++;\n\tif(!_ptrc_glStencilFuncSeparate)\n\t\t_ptrc_glStencilFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint, GLuint))IntGetProcAddress(\"glStencilFuncSeparate\");\n\tif(!_ptrc_glStencilFuncSeparate) numFailed++;\n\tif(!_ptrc_glStencilMaskSeparate)\n\t\t_ptrc_glStencilMaskSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glStencilMaskSeparate\");\n\tif(!_ptrc_glStencilMaskSeparate) numFailed++;\n\tif(!_ptrc_glStencilOpSeparate)\n\t\t_ptrc_glStencilOpSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress(\"glStencilOpSeparate\");\n\tif(!_ptrc_glStencilOpSeparate) numFailed++;\n\tif(!_ptrc_glUniform1f)\n\t\t_ptrc_glUniform1f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat))IntGetProcAddress(\"glUniform1f\");\n\tif(!_ptrc_glUniform1f) numFailed++;\n\tif(!_ptrc_glUniform1fv)\n\t\t_ptrc_glUniform1fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform1fv\");\n\tif(!_ptrc_glUniform1fv) numFailed++;\n\tif(!_ptrc_glUniform1i)\n\t\t_ptrc_glUniform1i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress(\"glUniform1i\");\n\tif(!_ptrc_glUniform1i) numFailed++;\n\tif(!_ptrc_glUniform1iv)\n\t\t_ptrc_glUniform1iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform1iv\");\n\tif(!_ptrc_glUniform1iv) numFailed++;\n\tif(!_ptrc_glUniform2f)\n\t\t_ptrc_glUniform2f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress(\"glUniform2f\");\n\tif(!_ptrc_glUniform2f) numFailed++;\n\tif(!_ptrc_glUniform2fv)\n\t\t_ptrc_glUniform2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform2fv\");\n\tif(!_ptrc_glUniform2fv) numFailed++;\n\tif(!_ptrc_glUniform2i)\n\t\t_ptrc_glUniform2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress(\"glUniform2i\");\n\tif(!_ptrc_glUniform2i) numFailed++;\n\tif(!_ptrc_glUniform2iv)\n\t\t_ptrc_glUniform2iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform2iv\");\n\tif(!_ptrc_glUniform2iv) numFailed++;\n\tif(!_ptrc_glUniform3f)\n\t\t_ptrc_glUniform3f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glUniform3f\");\n\tif(!_ptrc_glUniform3f) numFailed++;\n\tif(!_ptrc_glUniform3fv)\n\t\t_ptrc_glUniform3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform3fv\");\n\tif(!_ptrc_glUniform3fv) numFailed++;\n\tif(!_ptrc_glUniform3i)\n\t\t_ptrc_glUniform3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress(\"glUniform3i\");\n\tif(!_ptrc_glUniform3i) numFailed++;\n\tif(!_ptrc_glUniform3iv)\n\t\t_ptrc_glUniform3iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform3iv\");\n\tif(!_ptrc_glUniform3iv) numFailed++;\n\tif(!_ptrc_glUniform4f)\n\t\t_ptrc_glUniform4f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glUniform4f\");\n\tif(!_ptrc_glUniform4f) numFailed++;\n\tif(!_ptrc_glUniform4fv)\n\t\t_ptrc_glUniform4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress(\"glUniform4fv\");\n\tif(!_ptrc_glUniform4fv) numFailed++;\n\tif(!_ptrc_glUniform4i)\n\t\t_ptrc_glUniform4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint))IntGetProcAddress(\"glUniform4i\");\n\tif(!_ptrc_glUniform4i) numFailed++;\n\tif(!_ptrc_glUniform4iv)\n\t\t_ptrc_glUniform4iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress(\"glUniform4iv\");\n\tif(!_ptrc_glUniform4iv) numFailed++;\n\tif(!_ptrc_glUniformMatrix2fv)\n\t\t_ptrc_glUniformMatrix2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2fv\");\n\tif(!_ptrc_glUniformMatrix2fv) numFailed++;\n\tif(!_ptrc_glUniformMatrix3fv)\n\t\t_ptrc_glUniformMatrix3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3fv\");\n\tif(!_ptrc_glUniformMatrix3fv) numFailed++;\n\tif(!_ptrc_glUniformMatrix4fv)\n\t\t_ptrc_glUniformMatrix4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4fv\");\n\tif(!_ptrc_glUniformMatrix4fv) numFailed++;\n\tif(!_ptrc_glUseProgram)\n\t\t_ptrc_glUseProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glUseProgram\");\n\tif(!_ptrc_glUseProgram) numFailed++;\n\tif(!_ptrc_glValidateProgram)\n\t\t_ptrc_glValidateProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glValidateProgram\");\n\tif(!_ptrc_glValidateProgram) numFailed++;\n\tif(!_ptrc_glVertexAttrib1d)\n\t\t_ptrc_glVertexAttrib1d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble))IntGetProcAddress(\"glVertexAttrib1d\");\n\tif(!_ptrc_glVertexAttrib1d) numFailed++;\n\tif(!_ptrc_glVertexAttrib1dv)\n\t\t_ptrc_glVertexAttrib1dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib1dv\");\n\tif(!_ptrc_glVertexAttrib1dv) numFailed++;\n\tif(!_ptrc_glVertexAttrib1f)\n\t\t_ptrc_glVertexAttrib1f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat))IntGetProcAddress(\"glVertexAttrib1f\");\n\tif(!_ptrc_glVertexAttrib1f) numFailed++;\n\tif(!_ptrc_glVertexAttrib1fv)\n\t\t_ptrc_glVertexAttrib1fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib1fv\");\n\tif(!_ptrc_glVertexAttrib1fv) numFailed++;\n\tif(!_ptrc_glVertexAttrib1s)\n\t\t_ptrc_glVertexAttrib1s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort))IntGetProcAddress(\"glVertexAttrib1s\");\n\tif(!_ptrc_glVertexAttrib1s) numFailed++;\n\tif(!_ptrc_glVertexAttrib1sv)\n\t\t_ptrc_glVertexAttrib1sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib1sv\");\n\tif(!_ptrc_glVertexAttrib1sv) numFailed++;\n\tif(!_ptrc_glVertexAttrib2d)\n\t\t_ptrc_glVertexAttrib2d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib2d\");\n\tif(!_ptrc_glVertexAttrib2d) numFailed++;\n\tif(!_ptrc_glVertexAttrib2dv)\n\t\t_ptrc_glVertexAttrib2dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib2dv\");\n\tif(!_ptrc_glVertexAttrib2dv) numFailed++;\n\tif(!_ptrc_glVertexAttrib2f)\n\t\t_ptrc_glVertexAttrib2f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib2f\");\n\tif(!_ptrc_glVertexAttrib2f) numFailed++;\n\tif(!_ptrc_glVertexAttrib2fv)\n\t\t_ptrc_glVertexAttrib2fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib2fv\");\n\tif(!_ptrc_glVertexAttrib2fv) numFailed++;\n\tif(!_ptrc_glVertexAttrib2s)\n\t\t_ptrc_glVertexAttrib2s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib2s\");\n\tif(!_ptrc_glVertexAttrib2s) numFailed++;\n\tif(!_ptrc_glVertexAttrib2sv)\n\t\t_ptrc_glVertexAttrib2sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib2sv\");\n\tif(!_ptrc_glVertexAttrib2sv) numFailed++;\n\tif(!_ptrc_glVertexAttrib3d)\n\t\t_ptrc_glVertexAttrib3d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib3d\");\n\tif(!_ptrc_glVertexAttrib3d) numFailed++;\n\tif(!_ptrc_glVertexAttrib3dv)\n\t\t_ptrc_glVertexAttrib3dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib3dv\");\n\tif(!_ptrc_glVertexAttrib3dv) numFailed++;\n\tif(!_ptrc_glVertexAttrib3f)\n\t\t_ptrc_glVertexAttrib3f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib3f\");\n\tif(!_ptrc_glVertexAttrib3f) numFailed++;\n\tif(!_ptrc_glVertexAttrib3fv)\n\t\t_ptrc_glVertexAttrib3fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib3fv\");\n\tif(!_ptrc_glVertexAttrib3fv) numFailed++;\n\tif(!_ptrc_glVertexAttrib3s)\n\t\t_ptrc_glVertexAttrib3s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib3s\");\n\tif(!_ptrc_glVertexAttrib3s) numFailed++;\n\tif(!_ptrc_glVertexAttrib3sv)\n\t\t_ptrc_glVertexAttrib3sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib3sv\");\n\tif(!_ptrc_glVertexAttrib3sv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4Nbv)\n\t\t_ptrc_glVertexAttrib4Nbv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttrib4Nbv\");\n\tif(!_ptrc_glVertexAttrib4Nbv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4Niv)\n\t\t_ptrc_glVertexAttrib4Niv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttrib4Niv\");\n\tif(!_ptrc_glVertexAttrib4Niv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4Nsv)\n\t\t_ptrc_glVertexAttrib4Nsv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib4Nsv\");\n\tif(!_ptrc_glVertexAttrib4Nsv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4Nub)\n\t\t_ptrc_glVertexAttrib4Nub = (void (CODEGEN_FUNCPTR *)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte))IntGetProcAddress(\"glVertexAttrib4Nub\");\n\tif(!_ptrc_glVertexAttrib4Nub) numFailed++;\n\tif(!_ptrc_glVertexAttrib4Nubv)\n\t\t_ptrc_glVertexAttrib4Nubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttrib4Nubv\");\n\tif(!_ptrc_glVertexAttrib4Nubv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4Nuiv)\n\t\t_ptrc_glVertexAttrib4Nuiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttrib4Nuiv\");\n\tif(!_ptrc_glVertexAttrib4Nuiv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4Nusv)\n\t\t_ptrc_glVertexAttrib4Nusv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttrib4Nusv\");\n\tif(!_ptrc_glVertexAttrib4Nusv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4bv)\n\t\t_ptrc_glVertexAttrib4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttrib4bv\");\n\tif(!_ptrc_glVertexAttrib4bv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4d)\n\t\t_ptrc_glVertexAttrib4d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress(\"glVertexAttrib4d\");\n\tif(!_ptrc_glVertexAttrib4d) numFailed++;\n\tif(!_ptrc_glVertexAttrib4dv)\n\t\t_ptrc_glVertexAttrib4dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress(\"glVertexAttrib4dv\");\n\tif(!_ptrc_glVertexAttrib4dv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4f)\n\t\t_ptrc_glVertexAttrib4f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress(\"glVertexAttrib4f\");\n\tif(!_ptrc_glVertexAttrib4f) numFailed++;\n\tif(!_ptrc_glVertexAttrib4fv)\n\t\t_ptrc_glVertexAttrib4fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress(\"glVertexAttrib4fv\");\n\tif(!_ptrc_glVertexAttrib4fv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4iv)\n\t\t_ptrc_glVertexAttrib4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttrib4iv\");\n\tif(!_ptrc_glVertexAttrib4iv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4s)\n\t\t_ptrc_glVertexAttrib4s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort, GLshort))IntGetProcAddress(\"glVertexAttrib4s\");\n\tif(!_ptrc_glVertexAttrib4s) numFailed++;\n\tif(!_ptrc_glVertexAttrib4sv)\n\t\t_ptrc_glVertexAttrib4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttrib4sv\");\n\tif(!_ptrc_glVertexAttrib4sv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4ubv)\n\t\t_ptrc_glVertexAttrib4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttrib4ubv\");\n\tif(!_ptrc_glVertexAttrib4ubv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4uiv)\n\t\t_ptrc_glVertexAttrib4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttrib4uiv\");\n\tif(!_ptrc_glVertexAttrib4uiv) numFailed++;\n\tif(!_ptrc_glVertexAttrib4usv)\n\t\t_ptrc_glVertexAttrib4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttrib4usv\");\n\tif(!_ptrc_glVertexAttrib4usv) numFailed++;\n\tif(!_ptrc_glVertexAttribPointer)\n\t\t_ptrc_glVertexAttribPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *))IntGetProcAddress(\"glVertexAttribPointer\");\n\tif(!_ptrc_glVertexAttribPointer) numFailed++;\n\tif(!_ptrc_glUniformMatrix2x3fv)\n\t\t_ptrc_glUniformMatrix2x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2x3fv\");\n\tif(!_ptrc_glUniformMatrix2x3fv) numFailed++;\n\tif(!_ptrc_glUniformMatrix2x4fv)\n\t\t_ptrc_glUniformMatrix2x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix2x4fv\");\n\tif(!_ptrc_glUniformMatrix2x4fv) numFailed++;\n\tif(!_ptrc_glUniformMatrix3x2fv)\n\t\t_ptrc_glUniformMatrix3x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3x2fv\");\n\tif(!_ptrc_glUniformMatrix3x2fv) numFailed++;\n\tif(!_ptrc_glUniformMatrix3x4fv)\n\t\t_ptrc_glUniformMatrix3x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix3x4fv\");\n\tif(!_ptrc_glUniformMatrix3x4fv) numFailed++;\n\tif(!_ptrc_glUniformMatrix4x2fv)\n\t\t_ptrc_glUniformMatrix4x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4x2fv\");\n\tif(!_ptrc_glUniformMatrix4x2fv) numFailed++;\n\tif(!_ptrc_glUniformMatrix4x3fv)\n\t\t_ptrc_glUniformMatrix4x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress(\"glUniformMatrix4x3fv\");\n\tif(!_ptrc_glUniformMatrix4x3fv) numFailed++;\n\tif(!_ptrc_glBeginConditionalRender)\n\t\t_ptrc_glBeginConditionalRender = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glBeginConditionalRender\");\n\tif(!_ptrc_glBeginConditionalRender) numFailed++;\n\tif(!_ptrc_glBeginTransformFeedback)\n\t\t_ptrc_glBeginTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glBeginTransformFeedback\");\n\tif(!_ptrc_glBeginTransformFeedback) numFailed++;\n\tif(!_ptrc_glBindBufferBase)\n\t\t_ptrc_glBindBufferBase = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress(\"glBindBufferBase\");\n\tif(!_ptrc_glBindBufferBase) numFailed++;\n\tif(!_ptrc_glBindBufferRange)\n\t\t_ptrc_glBindBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr))IntGetProcAddress(\"glBindBufferRange\");\n\tif(!_ptrc_glBindBufferRange) numFailed++;\n\tif(!_ptrc_glBindFragDataLocation)\n\t\t_ptrc_glBindFragDataLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindFragDataLocation\");\n\tif(!_ptrc_glBindFragDataLocation) numFailed++;\n\tif(!_ptrc_glBindFramebuffer)\n\t\t_ptrc_glBindFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindFramebuffer\");\n\tif(!_ptrc_glBindFramebuffer) numFailed++;\n\tif(!_ptrc_glBindRenderbuffer)\n\t\t_ptrc_glBindRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glBindRenderbuffer\");\n\tif(!_ptrc_glBindRenderbuffer) numFailed++;\n\tif(!_ptrc_glBindVertexArray)\n\t\t_ptrc_glBindVertexArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glBindVertexArray\");\n\tif(!_ptrc_glBindVertexArray) numFailed++;\n\tif(!_ptrc_glBlitFramebuffer)\n\t\t_ptrc_glBlitFramebuffer = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum))IntGetProcAddress(\"glBlitFramebuffer\");\n\tif(!_ptrc_glBlitFramebuffer) numFailed++;\n\tif(!_ptrc_glCheckFramebufferStatus)\n\t\t_ptrc_glCheckFramebufferStatus = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glCheckFramebufferStatus\");\n\tif(!_ptrc_glCheckFramebufferStatus) numFailed++;\n\tif(!_ptrc_glClampColor)\n\t\t_ptrc_glClampColor = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress(\"glClampColor\");\n\tif(!_ptrc_glClampColor) numFailed++;\n\tif(!_ptrc_glClearBufferfi)\n\t\t_ptrc_glClearBufferfi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLfloat, GLint))IntGetProcAddress(\"glClearBufferfi\");\n\tif(!_ptrc_glClearBufferfi) numFailed++;\n\tif(!_ptrc_glClearBufferfv)\n\t\t_ptrc_glClearBufferfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLfloat *))IntGetProcAddress(\"glClearBufferfv\");\n\tif(!_ptrc_glClearBufferfv) numFailed++;\n\tif(!_ptrc_glClearBufferiv)\n\t\t_ptrc_glClearBufferiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLint *))IntGetProcAddress(\"glClearBufferiv\");\n\tif(!_ptrc_glClearBufferiv) numFailed++;\n\tif(!_ptrc_glClearBufferuiv)\n\t\t_ptrc_glClearBufferuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLuint *))IntGetProcAddress(\"glClearBufferuiv\");\n\tif(!_ptrc_glClearBufferuiv) numFailed++;\n\tif(!_ptrc_glColorMaski)\n\t\t_ptrc_glColorMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress(\"glColorMaski\");\n\tif(!_ptrc_glColorMaski) numFailed++;\n\tif(!_ptrc_glDeleteFramebuffers)\n\t\t_ptrc_glDeleteFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteFramebuffers\");\n\tif(!_ptrc_glDeleteFramebuffers) numFailed++;\n\tif(!_ptrc_glDeleteRenderbuffers)\n\t\t_ptrc_glDeleteRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteRenderbuffers\");\n\tif(!_ptrc_glDeleteRenderbuffers) numFailed++;\n\tif(!_ptrc_glDeleteVertexArrays)\n\t\t_ptrc_glDeleteVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteVertexArrays\");\n\tif(!_ptrc_glDeleteVertexArrays) numFailed++;\n\tif(!_ptrc_glDisablei)\n\t\t_ptrc_glDisablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glDisablei\");\n\tif(!_ptrc_glDisablei) numFailed++;\n\tif(!_ptrc_glEnablei)\n\t\t_ptrc_glEnablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glEnablei\");\n\tif(!_ptrc_glEnablei) numFailed++;\n\tif(!_ptrc_glEndConditionalRender)\n\t\t_ptrc_glEndConditionalRender = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress(\"glEndConditionalRender\");\n\tif(!_ptrc_glEndConditionalRender) numFailed++;\n\tif(!_ptrc_glEndTransformFeedback)\n\t\t_ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress(\"glEndTransformFeedback\");\n\tif(!_ptrc_glEndTransformFeedback) numFailed++;\n\tif(!_ptrc_glFlushMappedBufferRange)\n\t\t_ptrc_glFlushMappedBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr))IntGetProcAddress(\"glFlushMappedBufferRange\");\n\tif(!_ptrc_glFlushMappedBufferRange) numFailed++;\n\tif(!_ptrc_glFramebufferRenderbuffer)\n\t\t_ptrc_glFramebufferRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress(\"glFramebufferRenderbuffer\");\n\tif(!_ptrc_glFramebufferRenderbuffer) numFailed++;\n\tif(!_ptrc_glFramebufferTexture1D)\n\t\t_ptrc_glFramebufferTexture1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture1D\");\n\tif(!_ptrc_glFramebufferTexture1D) numFailed++;\n\tif(!_ptrc_glFramebufferTexture2D)\n\t\t_ptrc_glFramebufferTexture2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture2D\");\n\tif(!_ptrc_glFramebufferTexture2D) numFailed++;\n\tif(!_ptrc_glFramebufferTexture3D)\n\t\t_ptrc_glFramebufferTexture3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress(\"glFramebufferTexture3D\");\n\tif(!_ptrc_glFramebufferTexture3D) numFailed++;\n\tif(!_ptrc_glFramebufferTextureLayer)\n\t\t_ptrc_glFramebufferTextureLayer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress(\"glFramebufferTextureLayer\");\n\tif(!_ptrc_glFramebufferTextureLayer) numFailed++;\n\tif(!_ptrc_glGenFramebuffers)\n\t\t_ptrc_glGenFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenFramebuffers\");\n\tif(!_ptrc_glGenFramebuffers) numFailed++;\n\tif(!_ptrc_glGenRenderbuffers)\n\t\t_ptrc_glGenRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenRenderbuffers\");\n\tif(!_ptrc_glGenRenderbuffers) numFailed++;\n\tif(!_ptrc_glGenVertexArrays)\n\t\t_ptrc_glGenVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenVertexArrays\");\n\tif(!_ptrc_glGenVertexArrays) numFailed++;\n\tif(!_ptrc_glGenerateMipmap)\n\t\t_ptrc_glGenerateMipmap = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glGenerateMipmap\");\n\tif(!_ptrc_glGenerateMipmap) numFailed++;\n\tif(!_ptrc_glGetBooleani_v)\n\t\t_ptrc_glGetBooleani_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLboolean *))IntGetProcAddress(\"glGetBooleani_v\");\n\tif(!_ptrc_glGetBooleani_v) numFailed++;\n\tif(!_ptrc_glGetFragDataLocation)\n\t\t_ptrc_glGetFragDataLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetFragDataLocation\");\n\tif(!_ptrc_glGetFragDataLocation) numFailed++;\n\tif(!_ptrc_glGetFramebufferAttachmentParameteriv)\n\t\t_ptrc_glGetFramebufferAttachmentParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetFramebufferAttachmentParameteriv\");\n\tif(!_ptrc_glGetFramebufferAttachmentParameteriv) numFailed++;\n\tif(!_ptrc_glGetIntegeri_v)\n\t\t_ptrc_glGetIntegeri_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint *))IntGetProcAddress(\"glGetIntegeri_v\");\n\tif(!_ptrc_glGetIntegeri_v) numFailed++;\n\tif(!_ptrc_glGetRenderbufferParameteriv)\n\t\t_ptrc_glGetRenderbufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetRenderbufferParameteriv\");\n\tif(!_ptrc_glGetRenderbufferParameteriv) numFailed++;\n\tif(!_ptrc_glGetStringi)\n\t\t_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glGetStringi\");\n\tif(!_ptrc_glGetStringi) numFailed++;\n\tif(!_ptrc_glGetTexParameterIiv)\n\t\t_ptrc_glGetTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress(\"glGetTexParameterIiv\");\n\tif(!_ptrc_glGetTexParameterIiv) numFailed++;\n\tif(!_ptrc_glGetTexParameterIuiv)\n\t\t_ptrc_glGetTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint *))IntGetProcAddress(\"glGetTexParameterIuiv\");\n\tif(!_ptrc_glGetTexParameterIuiv) numFailed++;\n\tif(!_ptrc_glGetTransformFeedbackVarying)\n\t\t_ptrc_glGetTransformFeedbackVarying = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *))IntGetProcAddress(\"glGetTransformFeedbackVarying\");\n\tif(!_ptrc_glGetTransformFeedbackVarying) numFailed++;\n\tif(!_ptrc_glGetUniformuiv)\n\t\t_ptrc_glGetUniformuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLuint *))IntGetProcAddress(\"glGetUniformuiv\");\n\tif(!_ptrc_glGetUniformuiv) numFailed++;\n\tif(!_ptrc_glGetVertexAttribIiv)\n\t\t_ptrc_glGetVertexAttribIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetVertexAttribIiv\");\n\tif(!_ptrc_glGetVertexAttribIiv) numFailed++;\n\tif(!_ptrc_glGetVertexAttribIuiv)\n\t\t_ptrc_glGetVertexAttribIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetVertexAttribIuiv\");\n\tif(!_ptrc_glGetVertexAttribIuiv) numFailed++;\n\tif(!_ptrc_glIsEnabledi)\n\t\t_ptrc_glIsEnabledi = (GLboolean (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glIsEnabledi\");\n\tif(!_ptrc_glIsEnabledi) numFailed++;\n\tif(!_ptrc_glIsFramebuffer)\n\t\t_ptrc_glIsFramebuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsFramebuffer\");\n\tif(!_ptrc_glIsFramebuffer) numFailed++;\n\tif(!_ptrc_glIsRenderbuffer)\n\t\t_ptrc_glIsRenderbuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsRenderbuffer\");\n\tif(!_ptrc_glIsRenderbuffer) numFailed++;\n\tif(!_ptrc_glIsVertexArray)\n\t\t_ptrc_glIsVertexArray = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsVertexArray\");\n\tif(!_ptrc_glIsVertexArray) numFailed++;\n\tif(!_ptrc_glMapBufferRange)\n\t\t_ptrc_glMapBufferRange = (void * (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLbitfield))IntGetProcAddress(\"glMapBufferRange\");\n\tif(!_ptrc_glMapBufferRange) numFailed++;\n\tif(!_ptrc_glRenderbufferStorage)\n\t\t_ptrc_glRenderbufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress(\"glRenderbufferStorage\");\n\tif(!_ptrc_glRenderbufferStorage) numFailed++;\n\tif(!_ptrc_glRenderbufferStorageMultisample)\n\t\t_ptrc_glRenderbufferStorageMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))IntGetProcAddress(\"glRenderbufferStorageMultisample\");\n\tif(!_ptrc_glRenderbufferStorageMultisample) numFailed++;\n\tif(!_ptrc_glTexParameterIiv)\n\t\t_ptrc_glTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress(\"glTexParameterIiv\");\n\tif(!_ptrc_glTexParameterIiv) numFailed++;\n\tif(!_ptrc_glTexParameterIuiv)\n\t\t_ptrc_glTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLuint *))IntGetProcAddress(\"glTexParameterIuiv\");\n\tif(!_ptrc_glTexParameterIuiv) numFailed++;\n\tif(!_ptrc_glTransformFeedbackVaryings)\n\t\t_ptrc_glTransformFeedbackVaryings = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLenum))IntGetProcAddress(\"glTransformFeedbackVaryings\");\n\tif(!_ptrc_glTransformFeedbackVaryings) numFailed++;\n\tif(!_ptrc_glUniform1ui)\n\t\t_ptrc_glUniform1ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint))IntGetProcAddress(\"glUniform1ui\");\n\tif(!_ptrc_glUniform1ui) numFailed++;\n\tif(!_ptrc_glUniform1uiv)\n\t\t_ptrc_glUniform1uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform1uiv\");\n\tif(!_ptrc_glUniform1uiv) numFailed++;\n\tif(!_ptrc_glUniform2ui)\n\t\t_ptrc_glUniform2ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint))IntGetProcAddress(\"glUniform2ui\");\n\tif(!_ptrc_glUniform2ui) numFailed++;\n\tif(!_ptrc_glUniform2uiv)\n\t\t_ptrc_glUniform2uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform2uiv\");\n\tif(!_ptrc_glUniform2uiv) numFailed++;\n\tif(!_ptrc_glUniform3ui)\n\t\t_ptrc_glUniform3ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniform3ui\");\n\tif(!_ptrc_glUniform3ui) numFailed++;\n\tif(!_ptrc_glUniform3uiv)\n\t\t_ptrc_glUniform3uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform3uiv\");\n\tif(!_ptrc_glUniform3uiv) numFailed++;\n\tif(!_ptrc_glUniform4ui)\n\t\t_ptrc_glUniform4ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniform4ui\");\n\tif(!_ptrc_glUniform4ui) numFailed++;\n\tif(!_ptrc_glUniform4uiv)\n\t\t_ptrc_glUniform4uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress(\"glUniform4uiv\");\n\tif(!_ptrc_glUniform4uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribI1i)\n\t\t_ptrc_glVertexAttribI1i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint))IntGetProcAddress(\"glVertexAttribI1i\");\n\tif(!_ptrc_glVertexAttribI1i) numFailed++;\n\tif(!_ptrc_glVertexAttribI1iv)\n\t\t_ptrc_glVertexAttribI1iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI1iv\");\n\tif(!_ptrc_glVertexAttribI1iv) numFailed++;\n\tif(!_ptrc_glVertexAttribI1ui)\n\t\t_ptrc_glVertexAttribI1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI1ui\");\n\tif(!_ptrc_glVertexAttribI1ui) numFailed++;\n\tif(!_ptrc_glVertexAttribI1uiv)\n\t\t_ptrc_glVertexAttribI1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI1uiv\");\n\tif(!_ptrc_glVertexAttribI1uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribI2i)\n\t\t_ptrc_glVertexAttribI2i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI2i\");\n\tif(!_ptrc_glVertexAttribI2i) numFailed++;\n\tif(!_ptrc_glVertexAttribI2iv)\n\t\t_ptrc_glVertexAttribI2iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI2iv\");\n\tif(!_ptrc_glVertexAttribI2iv) numFailed++;\n\tif(!_ptrc_glVertexAttribI2ui)\n\t\t_ptrc_glVertexAttribI2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI2ui\");\n\tif(!_ptrc_glVertexAttribI2ui) numFailed++;\n\tif(!_ptrc_glVertexAttribI2uiv)\n\t\t_ptrc_glVertexAttribI2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI2uiv\");\n\tif(!_ptrc_glVertexAttribI2uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribI3i)\n\t\t_ptrc_glVertexAttribI3i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI3i\");\n\tif(!_ptrc_glVertexAttribI3i) numFailed++;\n\tif(!_ptrc_glVertexAttribI3iv)\n\t\t_ptrc_glVertexAttribI3iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI3iv\");\n\tif(!_ptrc_glVertexAttribI3iv) numFailed++;\n\tif(!_ptrc_glVertexAttribI3ui)\n\t\t_ptrc_glVertexAttribI3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI3ui\");\n\tif(!_ptrc_glVertexAttribI3ui) numFailed++;\n\tif(!_ptrc_glVertexAttribI3uiv)\n\t\t_ptrc_glVertexAttribI3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI3uiv\");\n\tif(!_ptrc_glVertexAttribI3uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribI4bv)\n\t\t_ptrc_glVertexAttribI4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress(\"glVertexAttribI4bv\");\n\tif(!_ptrc_glVertexAttribI4bv) numFailed++;\n\tif(!_ptrc_glVertexAttribI4i)\n\t\t_ptrc_glVertexAttribI4i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint, GLint))IntGetProcAddress(\"glVertexAttribI4i\");\n\tif(!_ptrc_glVertexAttribI4i) numFailed++;\n\tif(!_ptrc_glVertexAttribI4iv)\n\t\t_ptrc_glVertexAttribI4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress(\"glVertexAttribI4iv\");\n\tif(!_ptrc_glVertexAttribI4iv) numFailed++;\n\tif(!_ptrc_glVertexAttribI4sv)\n\t\t_ptrc_glVertexAttribI4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress(\"glVertexAttribI4sv\");\n\tif(!_ptrc_glVertexAttribI4sv) numFailed++;\n\tif(!_ptrc_glVertexAttribI4ubv)\n\t\t_ptrc_glVertexAttribI4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress(\"glVertexAttribI4ubv\");\n\tif(!_ptrc_glVertexAttribI4ubv) numFailed++;\n\tif(!_ptrc_glVertexAttribI4ui)\n\t\t_ptrc_glVertexAttribI4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress(\"glVertexAttribI4ui\");\n\tif(!_ptrc_glVertexAttribI4ui) numFailed++;\n\tif(!_ptrc_glVertexAttribI4uiv)\n\t\t_ptrc_glVertexAttribI4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress(\"glVertexAttribI4uiv\");\n\tif(!_ptrc_glVertexAttribI4uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribI4usv)\n\t\t_ptrc_glVertexAttribI4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress(\"glVertexAttribI4usv\");\n\tif(!_ptrc_glVertexAttribI4usv) numFailed++;\n\tif(!_ptrc_glVertexAttribIPointer)\n\t\t_ptrc_glVertexAttribIPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLsizei, const void *))IntGetProcAddress(\"glVertexAttribIPointer\");\n\tif(!_ptrc_glVertexAttribIPointer) numFailed++;\n\tif(!_ptrc_glCopyBufferSubData)\n\t\t_ptrc_glCopyBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr))IntGetProcAddress(\"glCopyBufferSubData\");\n\tif(!_ptrc_glCopyBufferSubData) numFailed++;\n\tif(!_ptrc_glDrawArraysInstanced)\n\t\t_ptrc_glDrawArraysInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei, GLsizei))IntGetProcAddress(\"glDrawArraysInstanced\");\n\tif(!_ptrc_glDrawArraysInstanced) numFailed++;\n\tif(!_ptrc_glDrawElementsInstanced)\n\t\t_ptrc_glDrawElementsInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *, GLsizei))IntGetProcAddress(\"glDrawElementsInstanced\");\n\tif(!_ptrc_glDrawElementsInstanced) numFailed++;\n\tif(!_ptrc_glGetActiveUniformBlockName)\n\t\t_ptrc_glGetActiveUniformBlockName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveUniformBlockName\");\n\tif(!_ptrc_glGetActiveUniformBlockName) numFailed++;\n\tif(!_ptrc_glGetActiveUniformBlockiv)\n\t\t_ptrc_glGetActiveUniformBlockiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetActiveUniformBlockiv\");\n\tif(!_ptrc_glGetActiveUniformBlockiv) numFailed++;\n\tif(!_ptrc_glGetActiveUniformName)\n\t\t_ptrc_glGetActiveUniformName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress(\"glGetActiveUniformName\");\n\tif(!_ptrc_glGetActiveUniformName) numFailed++;\n\tif(!_ptrc_glGetActiveUniformsiv)\n\t\t_ptrc_glGetActiveUniformsiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLuint *, GLenum, GLint *))IntGetProcAddress(\"glGetActiveUniformsiv\");\n\tif(!_ptrc_glGetActiveUniformsiv) numFailed++;\n\tif(!_ptrc_glGetUniformBlockIndex)\n\t\t_ptrc_glGetUniformBlockIndex = (GLuint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetUniformBlockIndex\");\n\tif(!_ptrc_glGetUniformBlockIndex) numFailed++;\n\tif(!_ptrc_glGetUniformIndices)\n\t\t_ptrc_glGetUniformIndices = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLuint *))IntGetProcAddress(\"glGetUniformIndices\");\n\tif(!_ptrc_glGetUniformIndices) numFailed++;\n\tif(!_ptrc_glPrimitiveRestartIndex)\n\t\t_ptrc_glPrimitiveRestartIndex = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glPrimitiveRestartIndex\");\n\tif(!_ptrc_glPrimitiveRestartIndex) numFailed++;\n\tif(!_ptrc_glTexBuffer)\n\t\t_ptrc_glTexBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint))IntGetProcAddress(\"glTexBuffer\");\n\tif(!_ptrc_glTexBuffer) numFailed++;\n\tif(!_ptrc_glUniformBlockBinding)\n\t\t_ptrc_glUniformBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress(\"glUniformBlockBinding\");\n\tif(!_ptrc_glUniformBlockBinding) numFailed++;\n\tif(!_ptrc_glClientWaitSync)\n\t\t_ptrc_glClientWaitSync = (GLenum (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress(\"glClientWaitSync\");\n\tif(!_ptrc_glClientWaitSync) numFailed++;\n\tif(!_ptrc_glDeleteSync)\n\t\t_ptrc_glDeleteSync = (void (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress(\"glDeleteSync\");\n\tif(!_ptrc_glDeleteSync) numFailed++;\n\tif(!_ptrc_glDrawElementsBaseVertex)\n\t\t_ptrc_glDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *, GLint))IntGetProcAddress(\"glDrawElementsBaseVertex\");\n\tif(!_ptrc_glDrawElementsBaseVertex) numFailed++;\n\tif(!_ptrc_glDrawElementsInstancedBaseVertex)\n\t\t_ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *, GLsizei, GLint))IntGetProcAddress(\"glDrawElementsInstancedBaseVertex\");\n\tif(!_ptrc_glDrawElementsInstancedBaseVertex) numFailed++;\n\tif(!_ptrc_glDrawRangeElementsBaseVertex)\n\t\t_ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const void *, GLint))IntGetProcAddress(\"glDrawRangeElementsBaseVertex\");\n\tif(!_ptrc_glDrawRangeElementsBaseVertex) numFailed++;\n\tif(!_ptrc_glFenceSync)\n\t\t_ptrc_glFenceSync = (GLsync (CODEGEN_FUNCPTR *)(GLenum, GLbitfield))IntGetProcAddress(\"glFenceSync\");\n\tif(!_ptrc_glFenceSync) numFailed++;\n\tif(!_ptrc_glFramebufferTexture)\n\t\t_ptrc_glFramebufferTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint))IntGetProcAddress(\"glFramebufferTexture\");\n\tif(!_ptrc_glFramebufferTexture) numFailed++;\n\tif(!_ptrc_glGetBufferParameteri64v)\n\t\t_ptrc_glGetBufferParameteri64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint64 *))IntGetProcAddress(\"glGetBufferParameteri64v\");\n\tif(!_ptrc_glGetBufferParameteri64v) numFailed++;\n\tif(!_ptrc_glGetInteger64i_v)\n\t\t_ptrc_glGetInteger64i_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint64 *))IntGetProcAddress(\"glGetInteger64i_v\");\n\tif(!_ptrc_glGetInteger64i_v) numFailed++;\n\tif(!_ptrc_glGetInteger64v)\n\t\t_ptrc_glGetInteger64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLint64 *))IntGetProcAddress(\"glGetInteger64v\");\n\tif(!_ptrc_glGetInteger64v) numFailed++;\n\tif(!_ptrc_glGetMultisamplefv)\n\t\t_ptrc_glGetMultisamplefv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLfloat *))IntGetProcAddress(\"glGetMultisamplefv\");\n\tif(!_ptrc_glGetMultisamplefv) numFailed++;\n\tif(!_ptrc_glGetSynciv)\n\t\t_ptrc_glGetSynciv = (void (CODEGEN_FUNCPTR *)(GLsync, GLenum, GLsizei, GLsizei *, GLint *))IntGetProcAddress(\"glGetSynciv\");\n\tif(!_ptrc_glGetSynciv) numFailed++;\n\tif(!_ptrc_glIsSync)\n\t\t_ptrc_glIsSync = (GLboolean (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress(\"glIsSync\");\n\tif(!_ptrc_glIsSync) numFailed++;\n\tif(!_ptrc_glMultiDrawElementsBaseVertex)\n\t\t_ptrc_glMultiDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const void *const*, GLsizei, const GLint *))IntGetProcAddress(\"glMultiDrawElementsBaseVertex\");\n\tif(!_ptrc_glMultiDrawElementsBaseVertex) numFailed++;\n\tif(!_ptrc_glProvokingVertex)\n\t\t_ptrc_glProvokingVertex = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress(\"glProvokingVertex\");\n\tif(!_ptrc_glProvokingVertex) numFailed++;\n\tif(!_ptrc_glSampleMaski)\n\t\t_ptrc_glSampleMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLbitfield))IntGetProcAddress(\"glSampleMaski\");\n\tif(!_ptrc_glSampleMaski) numFailed++;\n\tif(!_ptrc_glTexImage2DMultisample)\n\t\t_ptrc_glTexImage2DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLboolean))IntGetProcAddress(\"glTexImage2DMultisample\");\n\tif(!_ptrc_glTexImage2DMultisample) numFailed++;\n\tif(!_ptrc_glTexImage3DMultisample)\n\t\t_ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, GLboolean))IntGetProcAddress(\"glTexImage3DMultisample\");\n\tif(!_ptrc_glTexImage3DMultisample) numFailed++;\n\tif(!_ptrc_glWaitSync)\n\t\t_ptrc_glWaitSync = (void (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress(\"glWaitSync\");\n\tif(!_ptrc_glWaitSync) numFailed++;\n\tif(!_ptrc_glBindFragDataLocationIndexed)\n\t\t_ptrc_glBindFragDataLocationIndexed = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, const GLchar *))IntGetProcAddress(\"glBindFragDataLocationIndexed\");\n\tif(!_ptrc_glBindFragDataLocationIndexed) numFailed++;\n\tif(!_ptrc_glBindSampler)\n\t\t_ptrc_glBindSampler = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glBindSampler\");\n\tif(!_ptrc_glBindSampler) numFailed++;\n\tif(!_ptrc_glDeleteSamplers)\n\t\t_ptrc_glDeleteSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress(\"glDeleteSamplers\");\n\tif(!_ptrc_glDeleteSamplers) numFailed++;\n\tif(!_ptrc_glGenSamplers)\n\t\t_ptrc_glGenSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress(\"glGenSamplers\");\n\tif(!_ptrc_glGenSamplers) numFailed++;\n\tif(!_ptrc_glGetFragDataIndex)\n\t\t_ptrc_glGetFragDataIndex = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress(\"glGetFragDataIndex\");\n\tif(!_ptrc_glGetFragDataIndex) numFailed++;\n\tif(!_ptrc_glGetQueryObjecti64v)\n\t\t_ptrc_glGetQueryObjecti64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint64 *))IntGetProcAddress(\"glGetQueryObjecti64v\");\n\tif(!_ptrc_glGetQueryObjecti64v) numFailed++;\n\tif(!_ptrc_glGetQueryObjectui64v)\n\t\t_ptrc_glGetQueryObjectui64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint64 *))IntGetProcAddress(\"glGetQueryObjectui64v\");\n\tif(!_ptrc_glGetQueryObjectui64v) numFailed++;\n\tif(!_ptrc_glGetSamplerParameterIiv)\n\t\t_ptrc_glGetSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetSamplerParameterIiv\");\n\tif(!_ptrc_glGetSamplerParameterIiv) numFailed++;\n\tif(!_ptrc_glGetSamplerParameterIuiv)\n\t\t_ptrc_glGetSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress(\"glGetSamplerParameterIuiv\");\n\tif(!_ptrc_glGetSamplerParameterIuiv) numFailed++;\n\tif(!_ptrc_glGetSamplerParameterfv)\n\t\t_ptrc_glGetSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress(\"glGetSamplerParameterfv\");\n\tif(!_ptrc_glGetSamplerParameterfv) numFailed++;\n\tif(!_ptrc_glGetSamplerParameteriv)\n\t\t_ptrc_glGetSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress(\"glGetSamplerParameteriv\");\n\tif(!_ptrc_glGetSamplerParameteriv) numFailed++;\n\tif(!_ptrc_glIsSampler)\n\t\t_ptrc_glIsSampler = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress(\"glIsSampler\");\n\tif(!_ptrc_glIsSampler) numFailed++;\n\tif(!_ptrc_glQueryCounter)\n\t\t_ptrc_glQueryCounter = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress(\"glQueryCounter\");\n\tif(!_ptrc_glQueryCounter) numFailed++;\n\tif(!_ptrc_glSamplerParameterIiv)\n\t\t_ptrc_glSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress(\"glSamplerParameterIiv\");\n\tif(!_ptrc_glSamplerParameterIiv) numFailed++;\n\tif(!_ptrc_glSamplerParameterIuiv)\n\t\t_ptrc_glSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLuint *))IntGetProcAddress(\"glSamplerParameterIuiv\");\n\tif(!_ptrc_glSamplerParameterIuiv) numFailed++;\n\tif(!_ptrc_glSamplerParameterf)\n\t\t_ptrc_glSamplerParameterf = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat))IntGetProcAddress(\"glSamplerParameterf\");\n\tif(!_ptrc_glSamplerParameterf) numFailed++;\n\tif(!_ptrc_glSamplerParameterfv)\n\t\t_ptrc_glSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLfloat *))IntGetProcAddress(\"glSamplerParameterfv\");\n\tif(!_ptrc_glSamplerParameterfv) numFailed++;\n\tif(!_ptrc_glSamplerParameteri)\n\t\t_ptrc_glSamplerParameteri = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint))IntGetProcAddress(\"glSamplerParameteri\");\n\tif(!_ptrc_glSamplerParameteri) numFailed++;\n\tif(!_ptrc_glSamplerParameteriv)\n\t\t_ptrc_glSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress(\"glSamplerParameteriv\");\n\tif(!_ptrc_glSamplerParameteriv) numFailed++;\n\tif(!_ptrc_glVertexAttribDivisor)\n\t\t_ptrc_glVertexAttribDivisor = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress(\"glVertexAttribDivisor\");\n\tif(!_ptrc_glVertexAttribDivisor) numFailed++;\n\tif(!_ptrc_glVertexAttribP1ui)\n\t\t_ptrc_glVertexAttribP1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP1ui\");\n\tif(!_ptrc_glVertexAttribP1ui) numFailed++;\n\tif(!_ptrc_glVertexAttribP1uiv)\n\t\t_ptrc_glVertexAttribP1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP1uiv\");\n\tif(!_ptrc_glVertexAttribP1uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribP2ui)\n\t\t_ptrc_glVertexAttribP2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP2ui\");\n\tif(!_ptrc_glVertexAttribP2ui) numFailed++;\n\tif(!_ptrc_glVertexAttribP2uiv)\n\t\t_ptrc_glVertexAttribP2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP2uiv\");\n\tif(!_ptrc_glVertexAttribP2uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribP3ui)\n\t\t_ptrc_glVertexAttribP3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP3ui\");\n\tif(!_ptrc_glVertexAttribP3ui) numFailed++;\n\tif(!_ptrc_glVertexAttribP3uiv)\n\t\t_ptrc_glVertexAttribP3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP3uiv\");\n\tif(!_ptrc_glVertexAttribP3uiv) numFailed++;\n\tif(!_ptrc_glVertexAttribP4ui)\n\t\t_ptrc_glVertexAttribP4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress(\"glVertexAttribP4ui\");\n\tif(!_ptrc_glVertexAttribP4ui) numFailed++;\n\tif(!_ptrc_glVertexAttribP4uiv)\n\t\t_ptrc_glVertexAttribP4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress(\"glVertexAttribP4uiv\");\n\tif(!_ptrc_glVertexAttribP4uiv) numFailed++;\n\treturn numFailed;\n}\n\ntypedef int (*PFN_LOADFUNCPOINTERS)(void);\ntypedef struct ogl_StrToExtMap_s\n{\n\tchar *extensionName;\n\tint *extensionVariable;\n\tPFN_LOADFUNCPOINTERS LoadExtension;\n} ogl_StrToExtMap;\n\nstatic ogl_StrToExtMap ExtensionMap[1] = {\n\t{\"\", NULL, NULL},\n};\n\nstatic int g_extensionMapSize = 0;\n\nstatic ogl_StrToExtMap *FindExtEntry(const char *extensionName)\n{\n\tint loop;\n\togl_StrToExtMap *currLoc = ExtensionMap;\n\tfor(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)\n\t{\n\t\tif(strcmp(extensionName, currLoc->extensionName) == 0)\n\t\t\treturn currLoc;\n\t}\n\t\n\treturn NULL;\n}\n\nstatic void ClearExtensionVars(void)\n{\n}\n\n\nstatic void LoadExtByName(const char *extensionName)\n{\n\togl_StrToExtMap *entry = NULL;\n\tentry = FindExtEntry(extensionName);\n\tif(entry)\n\t{\n\t\tif(entry->LoadExtension)\n\t\t{\n\t\t\tint numFailed = entry->LoadExtension();\n\t\t\tif(numFailed == 0)\n\t\t\t{\n\t\t\t\t*(entry->extensionVariable) = ogl_LOAD_SUCCEEDED;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*(entry->extensionVariable) = ogl_LOAD_SUCCEEDED + numFailed;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t*(entry->extensionVariable) = ogl_LOAD_SUCCEEDED;\n\t\t}\n\t}\n}\n\n\nstatic void ProcExtsFromExtList(void)\n{\n\tGLint iLoop;\n\tGLint iNumExtensions = 0;\n\t_ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions);\n\n\tfor(iLoop = 0; iLoop < iNumExtensions; iLoop++)\n\t{\n\t\tconst char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop);\n\t\tLoadExtByName(strExtensionName);\n\t}\n}\n\nint ogl_LoadFunctions()\n{\n\tint numFailed = 0;\n\tClearExtensionVars();\n\t\n\t_ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress(\"glGetIntegerv\");\n\tif(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED;\n\t_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress(\"glGetStringi\");\n\tif(!_ptrc_glGetStringi) return ogl_LOAD_FAILED;\n\t\n\tProcExtsFromExtList();\n\tnumFailed = Load_Version_3_3();\n\t\n\tif(numFailed == 0)\n\t\treturn ogl_LOAD_SUCCEEDED;\n\telse\n\t\treturn ogl_LOAD_SUCCEEDED + numFailed;\n}\n\nstatic int g_major_version = 0;\nstatic int g_minor_version = 0;\n\nstatic void GetGLVersion(void)\n{\n\tglGetIntegerv(GL_MAJOR_VERSION, &g_major_version);\n\tglGetIntegerv(GL_MINOR_VERSION, &g_minor_version);\n}\n\nint ogl_GetMajorVersion(void)\n{\n\tif(g_major_version == 0)\n\t\tGetGLVersion();\n\treturn g_major_version;\n}\n\nint ogl_GetMinorVersion(void)\n{\n\tif(g_major_version == 0) /*Yes, check the major version to get the minor one.*/\n\t\tGetGLVersion();\n\treturn g_minor_version;\n}\n\nint ogl_IsVersionGEQ(int majorVersion, int minorVersion)\n{\n\tif(g_major_version == 0)\n\t\tGetGLVersion();\n\t\n\tif(majorVersion < g_major_version) return 1;\n\tif(majorVersion > g_major_version) return 0;\n\tif(minorVersion <= g_minor_version) return 1;\n\treturn 0;\n}\n\n#endif // GLES\n"
  },
  {
    "path": "src/output/gl_core_3_3.h",
    "content": "#ifndef GLES\n\n#ifndef POINTER_C_GENERATED_HEADER_OPENGL_H\n#define POINTER_C_GENERATED_HEADER_OPENGL_H\n\n#if defined(__glew_h__) || defined(__GLEW_H__)\n#error Attempt to include auto-generated header after including glew.h\n#endif\n#if defined(__gl_h_) || defined(__GL_H__)\n#error Attempt to include auto-generated header after including gl.h\n#endif\n#if defined(__glext_h_) || defined(__GLEXT_H_)\n#error Attempt to include auto-generated header after including glext.h\n#endif\n#if defined(__gltypes_h_)\n#error Attempt to include auto-generated header after gltypes.h\n#endif\n#if defined(__gl_ATI_h_)\n#error Attempt to include auto-generated header after including glATI.h\n#endif\n\n#define __glew_h__\n#define __GLEW_H__\n#define __gl_h_\n#define __GL_H__\n#define __glext_h_\n#define __GLEXT_H_\n#define __gltypes_h_\n#define __gl_ATI_h_\n\n#ifndef APIENTRY\n\t#if defined(__MINGW32__)\n\t\t#ifndef WIN32_LEAN_AND_MEAN\n\t\t\t#define WIN32_LEAN_AND_MEAN 1\n\t\t#endif\n\t\t#ifndef NOMINMAX\n\t\t\t#define NOMINMAX\n\t\t#endif\n\t\t#include <windows.h>\n\t#elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__)\n\t\t#ifndef WIN32_LEAN_AND_MEAN\n\t\t\t#define WIN32_LEAN_AND_MEAN 1\n\t\t#endif\n\t\t#ifndef NOMINMAX\n\t\t\t#define NOMINMAX\n\t\t#endif\n\t\t#include <windows.h>\n\t#else\n\t\t#define APIENTRY\n\t#endif\n#endif /*APIENTRY*/\n\n#ifndef CODEGEN_FUNCPTR\n\t#define CODEGEN_REMOVE_FUNCPTR\n\t#if defined(_WIN32)\n\t\t#define CODEGEN_FUNCPTR APIENTRY\n\t#else\n\t\t#define CODEGEN_FUNCPTR\n\t#endif\n#endif /*CODEGEN_FUNCPTR*/\n\n#ifndef GLAPI\n\t#define GLAPI extern\n#endif\n\n\n#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n\n\n#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/\n\n\n#include <stddef.h>\n#ifndef GLEXT_64_TYPES_DEFINED\n/* This code block is duplicated in glxext.h, so must be protected */\n#define GLEXT_64_TYPES_DEFINED\n/* Define int32_t, int64_t, and uint64_t types for UST/MSC */\n/* (as used in the GL_EXT_timer_query extension). */\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n#include <inttypes.h>\n#elif defined(__sun__) || defined(__digital__)\n#include <inttypes.h>\n#if defined(__STDC__)\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int int64_t;\ntypedef unsigned long int uint64_t;\n#else\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#endif /* __arch64__ */\n#endif /* __STDC__ */\n#elif defined( __VMS ) || defined(__sgi)\n#include <inttypes.h>\n#elif defined(__SCO__) || defined(__USLC__)\n#include <stdint.h>\n#elif defined(__UNIXOS2__) || defined(__SOL64__)\ntypedef long int int32_t;\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#elif defined(_WIN32) && defined(__GNUC__)\n#include <stdint.h>\n#elif defined(_WIN32)\ntypedef __int32 int32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n#else\n/* Fallback if nothing above works */\n#include <inttypes.h>\n#endif\n#endif\n\ttypedef unsigned int GLenum;\n\ttypedef unsigned char GLboolean;\n\ttypedef unsigned int GLbitfield;\n\ttypedef void GLvoid;\n\ttypedef signed char GLbyte;\n\ttypedef short GLshort;\n\ttypedef int GLint;\n\ttypedef unsigned char GLubyte;\n\ttypedef unsigned short GLushort;\n\ttypedef unsigned int GLuint;\n\ttypedef int GLsizei;\n\ttypedef float GLfloat;\n\ttypedef float GLclampf;\n\ttypedef double GLdouble;\n\ttypedef double GLclampd;\n\ttypedef char GLchar;\n\ttypedef char GLcharARB;\n\t#ifdef __APPLE__\ntypedef void *GLhandleARB;\n#else\ntypedef unsigned int GLhandleARB;\n#endif\n\t\ttypedef unsigned short GLhalfARB;\n\t\ttypedef unsigned short GLhalf;\n\t\ttypedef GLint GLfixed;\n\t\ttypedef ptrdiff_t GLintptr;\n\t\ttypedef ptrdiff_t GLsizeiptr;\n\t\ttypedef int64_t GLint64;\n\t\ttypedef uint64_t GLuint64;\n\t\ttypedef ptrdiff_t GLintptrARB;\n\t\ttypedef ptrdiff_t GLsizeiptrARB;\n\t\ttypedef int64_t GLint64EXT;\n\t\ttypedef uint64_t GLuint64EXT;\n\t\ttypedef struct __GLsync *GLsync;\n\t\tstruct _cl_context;\n\t\tstruct _cl_event;\n\t\ttypedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\n\t\ttypedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\n\t\ttypedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);\n\t\ttypedef unsigned short GLhalfNV;\n\t\ttypedef GLintptr GLvdpauSurfaceNV;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /*__cplusplus*/\n\n#define GL_ALPHA 0x1906\n#define GL_ALWAYS 0x0207\n#define GL_AND 0x1501\n#define GL_AND_INVERTED 0x1504\n#define GL_AND_REVERSE 0x1502\n#define GL_BACK 0x0405\n#define GL_BACK_LEFT 0x0402\n#define GL_BACK_RIGHT 0x0403\n#define GL_BLEND 0x0BE2\n#define GL_BLEND_DST 0x0BE0\n#define GL_BLEND_SRC 0x0BE1\n#define GL_BLUE 0x1905\n#define GL_BYTE 0x1400\n#define GL_CCW 0x0901\n#define GL_CLEAR 0x1500\n#define GL_COLOR 0x1800\n#define GL_COLOR_BUFFER_BIT 0x00004000\n#define GL_COLOR_CLEAR_VALUE 0x0C22\n#define GL_COLOR_LOGIC_OP 0x0BF2\n#define GL_COLOR_WRITEMASK 0x0C23\n#define GL_COPY 0x1503\n#define GL_COPY_INVERTED 0x150C\n#define GL_CULL_FACE 0x0B44\n#define GL_CULL_FACE_MODE 0x0B45\n#define GL_CW 0x0900\n#define GL_DECR 0x1E03\n#define GL_DEPTH 0x1801\n#define GL_DEPTH_BUFFER_BIT 0x00000100\n#define GL_DEPTH_CLEAR_VALUE 0x0B73\n#define GL_DEPTH_COMPONENT 0x1902\n#define GL_DEPTH_FUNC 0x0B74\n#define GL_DEPTH_RANGE 0x0B70\n#define GL_DEPTH_TEST 0x0B71\n#define GL_DEPTH_WRITEMASK 0x0B72\n#define GL_DITHER 0x0BD0\n#define GL_DONT_CARE 0x1100\n#define GL_DOUBLE 0x140A\n#define GL_DOUBLEBUFFER 0x0C32\n#define GL_DRAW_BUFFER 0x0C01\n#define GL_DST_ALPHA 0x0304\n#define GL_DST_COLOR 0x0306\n#define GL_EQUAL 0x0202\n#define GL_EQUIV 0x1509\n#define GL_EXTENSIONS 0x1F03\n#define GL_FALSE 0\n#define GL_FASTEST 0x1101\n#define GL_FILL 0x1B02\n#define GL_FLOAT 0x1406\n#define GL_FRONT 0x0404\n#define GL_FRONT_AND_BACK 0x0408\n#define GL_FRONT_FACE 0x0B46\n#define GL_FRONT_LEFT 0x0400\n#define GL_FRONT_RIGHT 0x0401\n#define GL_GEQUAL 0x0206\n#define GL_GREATER 0x0204\n#define GL_GREEN 0x1904\n#define GL_INCR 0x1E02\n#define GL_INT 0x1404\n#define GL_INVALID_ENUM 0x0500\n#define GL_INVALID_OPERATION 0x0502\n#define GL_INVALID_VALUE 0x0501\n#define GL_INVERT 0x150A\n#define GL_KEEP 0x1E00\n#define GL_LEFT 0x0406\n#define GL_LEQUAL 0x0203\n#define GL_LESS 0x0201\n#define GL_LINE 0x1B01\n#define GL_LINEAR 0x2601\n#define GL_LINEAR_MIPMAP_LINEAR 0x2703\n#define GL_LINEAR_MIPMAP_NEAREST 0x2701\n#define GL_LINES 0x0001\n#define GL_LINE_LOOP 0x0002\n#define GL_LINE_SMOOTH 0x0B20\n#define GL_LINE_SMOOTH_HINT 0x0C52\n#define GL_LINE_STRIP 0x0003\n#define GL_LINE_WIDTH 0x0B21\n#define GL_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_LINE_WIDTH_RANGE 0x0B22\n#define GL_LOGIC_OP_MODE 0x0BF0\n#define GL_MAX_TEXTURE_SIZE 0x0D33\n#define GL_MAX_VIEWPORT_DIMS 0x0D3A\n#define GL_NAND 0x150E\n#define GL_NEAREST 0x2600\n#define GL_NEAREST_MIPMAP_LINEAR 0x2702\n#define GL_NEAREST_MIPMAP_NEAREST 0x2700\n#define GL_NEVER 0x0200\n#define GL_NICEST 0x1102\n#define GL_NONE 0\n#define GL_NOOP 0x1505\n#define GL_NOR 0x1508\n#define GL_NOTEQUAL 0x0205\n#define GL_NO_ERROR 0\n#define GL_ONE 1\n#define GL_ONE_MINUS_DST_ALPHA 0x0305\n#define GL_ONE_MINUS_DST_COLOR 0x0307\n#define GL_ONE_MINUS_SRC_ALPHA 0x0303\n#define GL_ONE_MINUS_SRC_COLOR 0x0301\n#define GL_OR 0x1507\n#define GL_OR_INVERTED 0x150D\n#define GL_OR_REVERSE 0x150B\n#define GL_OUT_OF_MEMORY 0x0505\n#define GL_PACK_ALIGNMENT 0x0D05\n#define GL_PACK_LSB_FIRST 0x0D01\n#define GL_PACK_ROW_LENGTH 0x0D02\n#define GL_PACK_SKIP_PIXELS 0x0D04\n#define GL_PACK_SKIP_ROWS 0x0D03\n#define GL_PACK_SWAP_BYTES 0x0D00\n#define GL_POINT 0x1B00\n#define GL_POINTS 0x0000\n#define GL_POINT_SIZE 0x0B11\n#define GL_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_POINT_SIZE_RANGE 0x0B12\n#define GL_POLYGON_MODE 0x0B40\n#define GL_POLYGON_OFFSET_FACTOR 0x8038\n#define GL_POLYGON_OFFSET_FILL 0x8037\n#define GL_POLYGON_OFFSET_LINE 0x2A02\n#define GL_POLYGON_OFFSET_POINT 0x2A01\n#define GL_POLYGON_OFFSET_UNITS 0x2A00\n#define GL_POLYGON_SMOOTH 0x0B41\n#define GL_POLYGON_SMOOTH_HINT 0x0C53\n#define GL_PROXY_TEXTURE_1D 0x8063\n#define GL_PROXY_TEXTURE_2D 0x8064\n#define GL_R3_G3_B2 0x2A10\n#define GL_READ_BUFFER 0x0C02\n#define GL_RED 0x1903\n#define GL_RENDERER 0x1F01\n#define GL_REPEAT 0x2901\n#define GL_REPLACE 0x1E01\n#define GL_RGB 0x1907\n#define GL_RGB10 0x8052\n#define GL_RGB10_A2 0x8059\n#define GL_RGB12 0x8053\n#define GL_RGB16 0x8054\n#define GL_RGB4 0x804F\n#define GL_RGB5 0x8050\n#define GL_RGB5_A1 0x8057\n#define GL_RGB8 0x8051\n#define GL_RGBA 0x1908\n#define GL_RGBA12 0x805A\n#define GL_RGBA16 0x805B\n#define GL_RGBA2 0x8055\n#define GL_RGBA4 0x8056\n#define GL_RGBA8 0x8058\n#define GL_RIGHT 0x0407\n#define GL_SCISSOR_BOX 0x0C10\n#define GL_SCISSOR_TEST 0x0C11\n#define GL_SET 0x150F\n#define GL_SHORT 0x1402\n#define GL_SRC_ALPHA 0x0302\n#define GL_SRC_ALPHA_SATURATE 0x0308\n#define GL_SRC_COLOR 0x0300\n#define GL_STENCIL 0x1802\n#define GL_STENCIL_BUFFER_BIT 0x00000400\n#define GL_STENCIL_CLEAR_VALUE 0x0B91\n#define GL_STENCIL_FAIL 0x0B94\n#define GL_STENCIL_FUNC 0x0B92\n#define GL_STENCIL_INDEX 0x1901\n#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95\n#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96\n#define GL_STENCIL_REF 0x0B97\n#define GL_STENCIL_TEST 0x0B90\n#define GL_STENCIL_VALUE_MASK 0x0B93\n#define GL_STENCIL_WRITEMASK 0x0B98\n#define GL_STEREO 0x0C33\n#define GL_SUBPIXEL_BITS 0x0D50\n#define GL_TEXTURE 0x1702\n#define GL_TEXTURE_1D 0x0DE0\n#define GL_TEXTURE_2D 0x0DE1\n#define GL_TEXTURE_ALPHA_SIZE 0x805F\n#define GL_TEXTURE_BINDING_1D 0x8068\n#define GL_TEXTURE_BINDING_2D 0x8069\n#define GL_TEXTURE_BLUE_SIZE 0x805E\n#define GL_TEXTURE_BORDER_COLOR 0x1004\n#define GL_TEXTURE_GREEN_SIZE 0x805D\n#define GL_TEXTURE_HEIGHT 0x1001\n#define GL_TEXTURE_INTERNAL_FORMAT 0x1003\n#define GL_TEXTURE_MAG_FILTER 0x2800\n#define GL_TEXTURE_MIN_FILTER 0x2801\n#define GL_TEXTURE_RED_SIZE 0x805C\n#define GL_TEXTURE_WIDTH 0x1000\n#define GL_TEXTURE_WRAP_S 0x2802\n#define GL_TEXTURE_WRAP_T 0x2803\n#define GL_TRIANGLES 0x0004\n#define GL_TRIANGLE_FAN 0x0006\n#define GL_TRIANGLE_STRIP 0x0005\n#define GL_TRUE 1\n#define GL_UNPACK_ALIGNMENT 0x0CF5\n#define GL_UNPACK_LSB_FIRST 0x0CF1\n#define GL_UNPACK_ROW_LENGTH 0x0CF2\n#define GL_UNPACK_SKIP_PIXELS 0x0CF4\n#define GL_UNPACK_SKIP_ROWS 0x0CF3\n#define GL_UNPACK_SWAP_BYTES 0x0CF0\n#define GL_UNSIGNED_BYTE 0x1401\n#define GL_UNSIGNED_INT 0x1405\n#define GL_UNSIGNED_SHORT 0x1403\n#define GL_VENDOR 0x1F00\n#define GL_VERSION 0x1F02\n#define GL_VIEWPORT 0x0BA2\n#define GL_XOR 0x1506\n#define GL_ZERO 0\n\n#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E\n#define GL_BGR 0x80E0\n#define GL_BGRA 0x80E1\n#define GL_CLAMP_TO_EDGE 0x812F\n#define GL_MAX_3D_TEXTURE_SIZE 0x8073\n#define GL_MAX_ELEMENTS_INDICES 0x80E9\n#define GL_MAX_ELEMENTS_VERTICES 0x80E8\n#define GL_PACK_IMAGE_HEIGHT 0x806C\n#define GL_PACK_SKIP_IMAGES 0x806B\n#define GL_PROXY_TEXTURE_3D 0x8070\n#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22\n#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12\n#define GL_TEXTURE_3D 0x806F\n#define GL_TEXTURE_BASE_LEVEL 0x813C\n#define GL_TEXTURE_BINDING_3D 0x806A\n#define GL_TEXTURE_DEPTH 0x8071\n#define GL_TEXTURE_MAX_LEVEL 0x813D\n#define GL_TEXTURE_MAX_LOD 0x813B\n#define GL_TEXTURE_MIN_LOD 0x813A\n#define GL_TEXTURE_WRAP_R 0x8072\n#define GL_UNPACK_IMAGE_HEIGHT 0x806E\n#define GL_UNPACK_SKIP_IMAGES 0x806D\n#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362\n#define GL_UNSIGNED_BYTE_3_3_2 0x8032\n#define GL_UNSIGNED_INT_10_10_10_2 0x8036\n#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368\n#define GL_UNSIGNED_INT_8_8_8_8 0x8035\n#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366\n#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365\n#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034\n#define GL_UNSIGNED_SHORT_5_6_5 0x8363\n#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364\n\n#define GL_ACTIVE_TEXTURE 0x84E0\n#define GL_CLAMP_TO_BORDER 0x812D\n#define GL_COMPRESSED_RGB 0x84ED\n#define GL_COMPRESSED_RGBA 0x84EE\n#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C\n#define GL_MULTISAMPLE 0x809D\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\n#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B\n#define GL_SAMPLES 0x80A9\n#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE 0x809F\n#define GL_SAMPLE_BUFFERS 0x80A8\n#define GL_SAMPLE_COVERAGE 0x80A0\n#define GL_SAMPLE_COVERAGE_INVERT 0x80AB\n#define GL_SAMPLE_COVERAGE_VALUE 0x80AA\n#define GL_TEXTURE0 0x84C0\n#define GL_TEXTURE1 0x84C1\n#define GL_TEXTURE10 0x84CA\n#define GL_TEXTURE11 0x84CB\n#define GL_TEXTURE12 0x84CC\n#define GL_TEXTURE13 0x84CD\n#define GL_TEXTURE14 0x84CE\n#define GL_TEXTURE15 0x84CF\n#define GL_TEXTURE16 0x84D0\n#define GL_TEXTURE17 0x84D1\n#define GL_TEXTURE18 0x84D2\n#define GL_TEXTURE19 0x84D3\n#define GL_TEXTURE2 0x84C2\n#define GL_TEXTURE20 0x84D4\n#define GL_TEXTURE21 0x84D5\n#define GL_TEXTURE22 0x84D6\n#define GL_TEXTURE23 0x84D7\n#define GL_TEXTURE24 0x84D8\n#define GL_TEXTURE25 0x84D9\n#define GL_TEXTURE26 0x84DA\n#define GL_TEXTURE27 0x84DB\n#define GL_TEXTURE28 0x84DC\n#define GL_TEXTURE29 0x84DD\n#define GL_TEXTURE3 0x84C3\n#define GL_TEXTURE30 0x84DE\n#define GL_TEXTURE31 0x84DF\n#define GL_TEXTURE4 0x84C4\n#define GL_TEXTURE5 0x84C5\n#define GL_TEXTURE6 0x84C6\n#define GL_TEXTURE7 0x84C7\n#define GL_TEXTURE8 0x84C8\n#define GL_TEXTURE9 0x84C9\n#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514\n#define GL_TEXTURE_COMPRESSED 0x86A1\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0\n#define GL_TEXTURE_COMPRESSION_HINT 0x84EF\n#define GL_TEXTURE_CUBE_MAP 0x8513\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519\n\n#define GL_BLEND_COLOR 0x8005\n#define GL_BLEND_DST_ALPHA 0x80CA\n#define GL_BLEND_DST_RGB 0x80C8\n#define GL_BLEND_SRC_ALPHA 0x80CB\n#define GL_BLEND_SRC_RGB 0x80C9\n#define GL_CONSTANT_ALPHA 0x8003\n#define GL_CONSTANT_COLOR 0x8001\n#define GL_DECR_WRAP 0x8508\n#define GL_DEPTH_COMPONENT16 0x81A5\n#define GL_DEPTH_COMPONENT24 0x81A6\n#define GL_DEPTH_COMPONENT32 0x81A7\n#define GL_FUNC_ADD 0x8006\n#define GL_FUNC_REVERSE_SUBTRACT 0x800B\n#define GL_FUNC_SUBTRACT 0x800A\n#define GL_INCR_WRAP 0x8507\n#define GL_MAX 0x8008\n#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD\n#define GL_MIN 0x8007\n#define GL_MIRRORED_REPEAT 0x8370\n#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004\n#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002\n#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128\n#define GL_TEXTURE_COMPARE_FUNC 0x884D\n#define GL_TEXTURE_COMPARE_MODE 0x884C\n#define GL_TEXTURE_DEPTH_SIZE 0x884A\n#define GL_TEXTURE_LOD_BIAS 0x8501\n\n#define GL_ARRAY_BUFFER 0x8892\n#define GL_ARRAY_BUFFER_BINDING 0x8894\n#define GL_BUFFER_ACCESS 0x88BB\n#define GL_BUFFER_MAPPED 0x88BC\n#define GL_BUFFER_MAP_POINTER 0x88BD\n#define GL_BUFFER_SIZE 0x8764\n#define GL_BUFFER_USAGE 0x8765\n#define GL_CURRENT_QUERY 0x8865\n#define GL_DYNAMIC_COPY 0x88EA\n#define GL_DYNAMIC_DRAW 0x88E8\n#define GL_DYNAMIC_READ 0x88E9\n#define GL_ELEMENT_ARRAY_BUFFER 0x8893\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895\n#define GL_QUERY_COUNTER_BITS 0x8864\n#define GL_QUERY_RESULT 0x8866\n#define GL_QUERY_RESULT_AVAILABLE 0x8867\n#define GL_READ_ONLY 0x88B8\n#define GL_READ_WRITE 0x88BA\n#define GL_SAMPLES_PASSED 0x8914\n#define GL_SRC1_ALPHA 0x8589\n#define GL_STATIC_COPY 0x88E6\n#define GL_STATIC_DRAW 0x88E4\n#define GL_STATIC_READ 0x88E5\n#define GL_STREAM_COPY 0x88E2\n#define GL_STREAM_DRAW 0x88E0\n#define GL_STREAM_READ 0x88E1\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\n#define GL_WRITE_ONLY 0x88B9\n\n#define GL_ACTIVE_ATTRIBUTES 0x8B89\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A\n#define GL_ACTIVE_UNIFORMS 0x8B86\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87\n#define GL_ATTACHED_SHADERS 0x8B85\n#define GL_BLEND_EQUATION_ALPHA 0x883D\n#define GL_BLEND_EQUATION_RGB 0x8009\n#define GL_BOOL 0x8B56\n#define GL_BOOL_VEC2 0x8B57\n#define GL_BOOL_VEC3 0x8B58\n#define GL_BOOL_VEC4 0x8B59\n#define GL_COMPILE_STATUS 0x8B81\n#define GL_CURRENT_PROGRAM 0x8B8D\n#define GL_CURRENT_VERTEX_ATTRIB 0x8626\n#define GL_DELETE_STATUS 0x8B80\n#define GL_DRAW_BUFFER0 0x8825\n#define GL_DRAW_BUFFER1 0x8826\n#define GL_DRAW_BUFFER10 0x882F\n#define GL_DRAW_BUFFER11 0x8830\n#define GL_DRAW_BUFFER12 0x8831\n#define GL_DRAW_BUFFER13 0x8832\n#define GL_DRAW_BUFFER14 0x8833\n#define GL_DRAW_BUFFER15 0x8834\n#define GL_DRAW_BUFFER2 0x8827\n#define GL_DRAW_BUFFER3 0x8828\n#define GL_DRAW_BUFFER4 0x8829\n#define GL_DRAW_BUFFER5 0x882A\n#define GL_DRAW_BUFFER6 0x882B\n#define GL_DRAW_BUFFER7 0x882C\n#define GL_DRAW_BUFFER8 0x882D\n#define GL_DRAW_BUFFER9 0x882E\n#define GL_FLOAT_MAT2 0x8B5A\n#define GL_FLOAT_MAT3 0x8B5B\n#define GL_FLOAT_MAT4 0x8B5C\n#define GL_FLOAT_VEC2 0x8B50\n#define GL_FLOAT_VEC3 0x8B51\n#define GL_FLOAT_VEC4 0x8B52\n#define GL_FRAGMENT_SHADER 0x8B30\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B\n#define GL_INFO_LOG_LENGTH 0x8B84\n#define GL_INT_VEC2 0x8B53\n#define GL_INT_VEC3 0x8B54\n#define GL_INT_VEC4 0x8B55\n#define GL_LINK_STATUS 0x8B82\n#define GL_LOWER_LEFT 0x8CA1\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\n#define GL_MAX_DRAW_BUFFERS 0x8824\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49\n#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872\n#define GL_MAX_VARYING_FLOATS 0x8B4B\n#define GL_MAX_VERTEX_ATTRIBS 0x8869\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A\n#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0\n#define GL_SAMPLER_1D 0x8B5D\n#define GL_SAMPLER_1D_SHADOW 0x8B61\n#define GL_SAMPLER_2D 0x8B5E\n#define GL_SAMPLER_2D_SHADOW 0x8B62\n#define GL_SAMPLER_3D 0x8B5F\n#define GL_SAMPLER_CUBE 0x8B60\n#define GL_SHADER_SOURCE_LENGTH 0x8B88\n#define GL_SHADER_TYPE 0x8B4F\n#define GL_SHADING_LANGUAGE_VERSION 0x8B8C\n#define GL_STENCIL_BACK_FAIL 0x8801\n#define GL_STENCIL_BACK_FUNC 0x8800\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803\n#define GL_STENCIL_BACK_REF 0x8CA3\n#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4\n#define GL_STENCIL_BACK_WRITEMASK 0x8CA5\n#define GL_UPPER_LEFT 0x8CA2\n#define GL_VALIDATE_STATUS 0x8B83\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625\n#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642\n#define GL_VERTEX_SHADER 0x8B31\n\n#define GL_COMPRESSED_SRGB 0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA 0x8C49\n#define GL_FLOAT_MAT2x3 0x8B65\n#define GL_FLOAT_MAT2x4 0x8B66\n#define GL_FLOAT_MAT3x2 0x8B67\n#define GL_FLOAT_MAT3x4 0x8B68\n#define GL_FLOAT_MAT4x2 0x8B69\n#define GL_FLOAT_MAT4x3 0x8B6A\n#define GL_PIXEL_PACK_BUFFER 0x88EB\n#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED\n#define GL_PIXEL_UNPACK_BUFFER 0x88EC\n#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF\n#define GL_SRGB 0x8C40\n#define GL_SRGB8 0x8C41\n#define GL_SRGB8_ALPHA8 0x8C43\n#define GL_SRGB_ALPHA 0x8C42\n\n#define GL_BGRA_INTEGER 0x8D9B\n#define GL_BGR_INTEGER 0x8D9A\n#define GL_BLUE_INTEGER 0x8D96\n#define GL_BUFFER_ACCESS_FLAGS 0x911F\n#define GL_BUFFER_MAP_LENGTH 0x9120\n#define GL_BUFFER_MAP_OFFSET 0x9121\n#define GL_CLAMP_READ_COLOR 0x891C\n#define GL_CLIP_DISTANCE0 0x3000\n#define GL_CLIP_DISTANCE1 0x3001\n#define GL_CLIP_DISTANCE2 0x3002\n#define GL_CLIP_DISTANCE3 0x3003\n#define GL_CLIP_DISTANCE4 0x3004\n#define GL_CLIP_DISTANCE5 0x3005\n#define GL_CLIP_DISTANCE6 0x3006\n#define GL_CLIP_DISTANCE7 0x3007\n#define GL_COLOR_ATTACHMENT0 0x8CE0\n#define GL_COLOR_ATTACHMENT1 0x8CE1\n#define GL_COLOR_ATTACHMENT10 0x8CEA\n#define GL_COLOR_ATTACHMENT11 0x8CEB\n#define GL_COLOR_ATTACHMENT12 0x8CEC\n#define GL_COLOR_ATTACHMENT13 0x8CED\n#define GL_COLOR_ATTACHMENT14 0x8CEE\n#define GL_COLOR_ATTACHMENT15 0x8CEF\n#define GL_COLOR_ATTACHMENT16 0x8CF0\n#define GL_COLOR_ATTACHMENT17 0x8CF1\n#define GL_COLOR_ATTACHMENT18 0x8CF2\n#define GL_COLOR_ATTACHMENT19 0x8CF3\n#define GL_COLOR_ATTACHMENT2 0x8CE2\n#define GL_COLOR_ATTACHMENT20 0x8CF4\n#define GL_COLOR_ATTACHMENT21 0x8CF5\n#define GL_COLOR_ATTACHMENT22 0x8CF6\n#define GL_COLOR_ATTACHMENT23 0x8CF7\n#define GL_COLOR_ATTACHMENT24 0x8CF8\n#define GL_COLOR_ATTACHMENT25 0x8CF9\n#define GL_COLOR_ATTACHMENT26 0x8CFA\n#define GL_COLOR_ATTACHMENT27 0x8CFB\n#define GL_COLOR_ATTACHMENT28 0x8CFC\n#define GL_COLOR_ATTACHMENT29 0x8CFD\n#define GL_COLOR_ATTACHMENT3 0x8CE3\n#define GL_COLOR_ATTACHMENT30 0x8CFE\n#define GL_COLOR_ATTACHMENT31 0x8CFF\n#define GL_COLOR_ATTACHMENT4 0x8CE4\n#define GL_COLOR_ATTACHMENT5 0x8CE5\n#define GL_COLOR_ATTACHMENT6 0x8CE6\n#define GL_COLOR_ATTACHMENT7 0x8CE7\n#define GL_COLOR_ATTACHMENT8 0x8CE8\n#define GL_COLOR_ATTACHMENT9 0x8CE9\n#define GL_COMPARE_REF_TO_TEXTURE 0x884E\n#define GL_COMPRESSED_RED 0x8225\n#define GL_COMPRESSED_RED_RGTC1 0x8DBB\n#define GL_COMPRESSED_RG 0x8226\n#define GL_COMPRESSED_RG_RGTC2 0x8DBD\n#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC\n#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE\n#define GL_CONTEXT_FLAGS 0x821E\n#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001\n#define GL_DEPTH24_STENCIL8 0x88F0\n#define GL_DEPTH32F_STENCIL8 0x8CAD\n#define GL_DEPTH_ATTACHMENT 0x8D00\n#define GL_DEPTH_COMPONENT32F 0x8CAC\n#define GL_DEPTH_STENCIL 0x84F9\n#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A\n#define GL_DRAW_FRAMEBUFFER 0x8CA9\n#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_FIXED_ONLY 0x891D\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD\n#define GL_FRAMEBUFFER 0x8D40\n#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215\n#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214\n#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210\n#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211\n#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216\n#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212\n#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2\n#define GL_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_FRAMEBUFFER_COMPLETE 0x8CD5\n#define GL_FRAMEBUFFER_DEFAULT 0x8218\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC\n#define GL_FRAMEBUFFER_SRGB 0x8DB9\n#define GL_FRAMEBUFFER_UNDEFINED 0x8219\n#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD\n#define GL_GREEN_INTEGER 0x8D95\n#define GL_HALF_FLOAT 0x140B\n#define GL_INTERLEAVED_ATTRIBS 0x8C8C\n#define GL_INT_SAMPLER_1D 0x8DC9\n#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE\n#define GL_INT_SAMPLER_2D 0x8DCA\n#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF\n#define GL_INT_SAMPLER_3D 0x8DCB\n#define GL_INT_SAMPLER_CUBE 0x8DCC\n#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506\n#define GL_MAJOR_VERSION 0x821B\n#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010\n#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008\n#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004\n#define GL_MAP_READ_BIT 0x0001\n#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020\n#define GL_MAP_WRITE_BIT 0x0002\n#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF\n#define GL_MAX_CLIP_DISTANCES 0x0D32\n#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF\n#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905\n#define GL_MAX_RENDERBUFFER_SIZE 0x84E8\n#define GL_MAX_SAMPLES 0x8D57\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80\n#define GL_MAX_VARYING_COMPONENTS 0x8B4B\n#define GL_MINOR_VERSION 0x821C\n#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904\n#define GL_NUM_EXTENSIONS 0x821D\n#define GL_PRIMITIVES_GENERATED 0x8C87\n#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19\n#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B\n#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16\n#define GL_QUERY_BY_REGION_WAIT 0x8E15\n#define GL_QUERY_NO_WAIT 0x8E14\n#define GL_QUERY_WAIT 0x8E13\n#define GL_R11F_G11F_B10F 0x8C3A\n#define GL_R16 0x822A\n#define GL_R16F 0x822D\n#define GL_R16I 0x8233\n#define GL_R16UI 0x8234\n#define GL_R32F 0x822E\n#define GL_R32I 0x8235\n#define GL_R32UI 0x8236\n#define GL_R8 0x8229\n#define GL_R8I 0x8231\n#define GL_R8UI 0x8232\n#define GL_RASTERIZER_DISCARD 0x8C89\n#define GL_READ_FRAMEBUFFER 0x8CA8\n#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA\n#define GL_RED_INTEGER 0x8D94\n#define GL_RENDERBUFFER 0x8D41\n#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53\n#define GL_RENDERBUFFER_BINDING 0x8CA7\n#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52\n#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54\n#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51\n#define GL_RENDERBUFFER_HEIGHT 0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44\n#define GL_RENDERBUFFER_RED_SIZE 0x8D50\n#define GL_RENDERBUFFER_SAMPLES 0x8CAB\n#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55\n#define GL_RENDERBUFFER_WIDTH 0x8D42\n#define GL_RG 0x8227\n#define GL_RG16 0x822C\n#define GL_RG16F 0x822F\n#define GL_RG16I 0x8239\n#define GL_RG16UI 0x823A\n#define GL_RG32F 0x8230\n#define GL_RG32I 0x823B\n#define GL_RG32UI 0x823C\n#define GL_RG8 0x822B\n#define GL_RG8I 0x8237\n#define GL_RG8UI 0x8238\n#define GL_RGB16F 0x881B\n#define GL_RGB16I 0x8D89\n#define GL_RGB16UI 0x8D77\n#define GL_RGB32F 0x8815\n#define GL_RGB32I 0x8D83\n#define GL_RGB32UI 0x8D71\n#define GL_RGB8I 0x8D8F\n#define GL_RGB8UI 0x8D7D\n#define GL_RGB9_E5 0x8C3D\n#define GL_RGBA16F 0x881A\n#define GL_RGBA16I 0x8D88\n#define GL_RGBA16UI 0x8D76\n#define GL_RGBA32F 0x8814\n#define GL_RGBA32I 0x8D82\n#define GL_RGBA32UI 0x8D70\n#define GL_RGBA8I 0x8D8E\n#define GL_RGBA8UI 0x8D7C\n#define GL_RGBA_INTEGER 0x8D99\n#define GL_RGB_INTEGER 0x8D98\n#define GL_RG_INTEGER 0x8228\n#define GL_SAMPLER_1D_ARRAY 0x8DC0\n#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3\n#define GL_SAMPLER_2D_ARRAY 0x8DC1\n#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW 0x8DC5\n#define GL_SEPARATE_ATTRIBS 0x8C8D\n#define GL_STENCIL_ATTACHMENT 0x8D20\n#define GL_STENCIL_INDEX1 0x8D46\n#define GL_STENCIL_INDEX16 0x8D49\n#define GL_STENCIL_INDEX4 0x8D47\n#define GL_STENCIL_INDEX8 0x8D48\n#define GL_TEXTURE_1D_ARRAY 0x8C18\n#define GL_TEXTURE_2D_ARRAY 0x8C1A\n#define GL_TEXTURE_ALPHA_TYPE 0x8C13\n#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D\n#define GL_TEXTURE_BLUE_TYPE 0x8C12\n#define GL_TEXTURE_DEPTH_TYPE 0x8C16\n#define GL_TEXTURE_GREEN_TYPE 0x8C11\n#define GL_TEXTURE_RED_TYPE 0x8C10\n#define GL_TEXTURE_SHARED_SIZE 0x8C3F\n#define GL_TEXTURE_STENCIL_SIZE 0x88F1\n#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88\n#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76\n#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B\n#define GL_UNSIGNED_INT_24_8 0x84FA\n#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E\n#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7\n#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4\n#define GL_UNSIGNED_INT_VEC2 0x8DC6\n#define GL_UNSIGNED_INT_VEC3 0x8DC7\n#define GL_UNSIGNED_INT_VEC4 0x8DC8\n#define GL_UNSIGNED_NORMALIZED 0x8C17\n#define GL_VERTEX_ARRAY_BINDING 0x85B5\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD\n\n#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36\n#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35\n#define GL_COPY_READ_BUFFER 0x8F36\n#define GL_COPY_WRITE_BUFFER 0x8F37\n#define GL_INT_SAMPLER_2D_RECT 0x8DCD\n#define GL_INT_SAMPLER_BUFFER 0x8DD0\n#define GL_INVALID_INDEX 0xFFFFFFFF\n#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33\n#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32\n#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E\n#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31\n#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D\n#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8\n#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B\n#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30\n#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F\n#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B\n#define GL_PRIMITIVE_RESTART 0x8F9D\n#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E\n#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7\n#define GL_R16_SNORM 0x8F98\n#define GL_R8_SNORM 0x8F94\n#define GL_RG16_SNORM 0x8F99\n#define GL_RG8_SNORM 0x8F95\n#define GL_RGB16_SNORM 0x8F9A\n#define GL_RGB8_SNORM 0x8F96\n#define GL_RGBA16_SNORM 0x8F9B\n#define GL_RGBA8_SNORM 0x8F97\n#define GL_SAMPLER_2D_RECT 0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64\n#define GL_SAMPLER_BUFFER 0x8DC2\n#define GL_SIGNED_NORMALIZED 0x8F9C\n#define GL_TEXTURE_BINDING_BUFFER 0x8C2C\n#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6\n#define GL_TEXTURE_BUFFER 0x8C2A\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D\n#define GL_TEXTURE_RECTANGLE 0x84F5\n#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43\n#define GL_UNIFORM_BLOCK_BINDING 0x8A3F\n#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40\n#define GL_UNIFORM_BLOCK_INDEX 0x8A3A\n#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44\n#define GL_UNIFORM_BUFFER 0x8A11\n#define GL_UNIFORM_BUFFER_BINDING 0x8A28\n#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34\n#define GL_UNIFORM_BUFFER_SIZE 0x8A2A\n#define GL_UNIFORM_BUFFER_START 0x8A29\n#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E\n#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D\n#define GL_UNIFORM_NAME_LENGTH 0x8A39\n#define GL_UNIFORM_OFFSET 0x8A3B\n#define GL_UNIFORM_SIZE 0x8A38\n#define GL_UNIFORM_TYPE 0x8A37\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8\n\n#define GL_ALREADY_SIGNALED 0x911A\n#define GL_CONDITION_SATISFIED 0x911C\n#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002\n#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001\n#define GL_CONTEXT_PROFILE_MASK 0x9126\n#define GL_DEPTH_CLAMP 0x864F\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8\n#define GL_GEOMETRY_INPUT_TYPE 0x8917\n#define GL_GEOMETRY_OUTPUT_TYPE 0x8918\n#define GL_GEOMETRY_SHADER 0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT 0x8916\n#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109\n#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\n#define GL_LINES_ADJACENCY 0x000A\n#define GL_LINE_STRIP_ADJACENCY 0x000B\n#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E\n#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F\n#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125\n#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123\n#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF\n#define GL_MAX_INTEGER_SAMPLES 0x9110\n#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59\n#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111\n#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122\n#define GL_OBJECT_TYPE 0x9112\n#define GL_PROGRAM_POINT_SIZE 0x8642\n#define GL_PROVOKING_VERTEX 0x8E4F\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C\n#define GL_SAMPLER_2D_MULTISAMPLE 0x9108\n#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B\n#define GL_SAMPLE_MASK 0x8E51\n#define GL_SAMPLE_MASK_VALUE 0x8E52\n#define GL_SAMPLE_POSITION 0x8E50\n#define GL_SIGNALED 0x9119\n#define GL_SYNC_CONDITION 0x9113\n#define GL_SYNC_FENCE 0x9116\n#define GL_SYNC_FLAGS 0x9115\n#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001\n#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117\n#define GL_SYNC_STATUS 0x9114\n#define GL_TEXTURE_2D_MULTISAMPLE 0x9100\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F\n#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107\n#define GL_TEXTURE_SAMPLES 0x9106\n#define GL_TIMEOUT_EXPIRED 0x911B\n#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF\n#define GL_TRIANGLES_ADJACENCY 0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D\n#define GL_UNSIGNALED 0x9118\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D\n#define GL_WAIT_FAILED 0x911D\n\n#define GL_ANY_SAMPLES_PASSED 0x8C2F\n#define GL_INT_2_10_10_10_REV 0x8D9F\n#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC\n#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB\n#define GL_ONE_MINUS_SRC1_COLOR 0x88FA\n#define GL_RGB10_A2UI 0x906F\n#define GL_SAMPLER_BINDING 0x8919\n#define GL_SRC1_COLOR 0x88F9\n#define GL_TEXTURE_SWIZZLE_A 0x8E45\n#define GL_TEXTURE_SWIZZLE_B 0x8E44\n#define GL_TEXTURE_SWIZZLE_G 0x8E43\n#define GL_TEXTURE_SWIZZLE_R 0x8E42\n#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46\n#define GL_TIMESTAMP 0x8E28\n#define GL_TIME_ELAPSED 0x88BF\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum sfactor, GLenum dfactor);\n#define glBlendFunc _ptrc_glBlendFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield mask);\n#define glClear _ptrc_glClear\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\n#define glClearColor _ptrc_glClearColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble depth);\n#define glClearDepth _ptrc_glClearDepth\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint s);\n#define glClearStencil _ptrc_glClearStencil\nextern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\n#define glColorMask _ptrc_glColorMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum mode);\n#define glCullFace _ptrc_glCullFace\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum func);\n#define glDepthFunc _ptrc_glDepthFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean flag);\n#define glDepthMask _ptrc_glDepthMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble ren_near, GLdouble ren_far);\n#define glDepthRange _ptrc_glDepthRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum cap);\n#define glDisable _ptrc_glDisable\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum buf);\n#define glDrawBuffer _ptrc_glDrawBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum cap);\n#define glEnable _ptrc_glEnable\nextern void (CODEGEN_FUNCPTR *_ptrc_glFinish)(void);\n#define glFinish _ptrc_glFinish\nextern void (CODEGEN_FUNCPTR *_ptrc_glFlush)(void);\n#define glFlush _ptrc_glFlush\nextern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum mode);\n#define glFrontFace _ptrc_glFrontFace\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum pname, GLboolean * data);\n#define glGetBooleanv _ptrc_glGetBooleanv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum pname, GLdouble * data);\n#define glGetDoublev _ptrc_glGetDoublev\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(void);\n#define glGetError _ptrc_glGetError\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum pname, GLfloat * data);\n#define glGetFloatv _ptrc_glGetFloatv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum pname, GLint * data);\n#define glGetIntegerv _ptrc_glGetIntegerv\nextern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum name);\n#define glGetString _ptrc_glGetString\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels);\n#define glGetTexImage _ptrc_glGetTexImage\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params);\n#define glGetTexLevelParameterfv _ptrc_glGetTexLevelParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params);\n#define glGetTexLevelParameteriv _ptrc_glGetTexLevelParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params);\n#define glGetTexParameterfv _ptrc_glGetTexParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params);\n#define glGetTexParameteriv _ptrc_glGetTexParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum target, GLenum mode);\n#define glHint _ptrc_glHint\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum cap);\n#define glIsEnabled _ptrc_glIsEnabled\nextern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat width);\n#define glLineWidth _ptrc_glLineWidth\nextern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum opcode);\n#define glLogicOp _ptrc_glLogicOp\nextern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum pname, GLfloat param);\n#define glPixelStoref _ptrc_glPixelStoref\nextern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum pname, GLint param);\n#define glPixelStorei _ptrc_glPixelStorei\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat size);\n#define glPointSize _ptrc_glPointSize\nextern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum face, GLenum mode);\n#define glPolygonMode _ptrc_glPolygonMode\nextern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum src);\n#define glReadBuffer _ptrc_glReadBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);\n#define glReadPixels _ptrc_glReadPixels\nextern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint x, GLint y, GLsizei width, GLsizei height);\n#define glScissor _ptrc_glScissor\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum func, GLint ref, GLuint mask);\n#define glStencilFunc _ptrc_glStencilFunc\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint mask);\n#define glStencilMask _ptrc_glStencilMask\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass);\n#define glStencilOp _ptrc_glStencilOp\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels);\n#define glTexImage1D _ptrc_glTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);\n#define glTexImage2D _ptrc_glTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum target, GLenum pname, GLfloat param);\n#define glTexParameterf _ptrc_glTexParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params);\n#define glTexParameterfv _ptrc_glTexParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum target, GLenum pname, GLint param);\n#define glTexParameteri _ptrc_glTexParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum target, GLenum pname, const GLint * params);\n#define glTexParameteriv _ptrc_glTexParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint x, GLint y, GLsizei width, GLsizei height);\n#define glViewport _ptrc_glViewport\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum target, GLuint texture);\n#define glBindTexture _ptrc_glBindTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\n#define glCopyTexImage1D _ptrc_glCopyTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\n#define glCopyTexImage2D _ptrc_glCopyTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\n#define glCopyTexSubImage1D _ptrc_glCopyTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\n#define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei n, const GLuint * textures);\n#define glDeleteTextures _ptrc_glDeleteTextures\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum mode, GLint first, GLsizei count);\n#define glDrawArrays _ptrc_glDrawArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices);\n#define glDrawElements _ptrc_glDrawElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei n, GLuint * textures);\n#define glGenTextures _ptrc_glGenTextures\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint texture);\n#define glIsTexture _ptrc_glIsTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat factor, GLfloat units);\n#define glPolygonOffset _ptrc_glPolygonOffset\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels);\n#define glTexSubImage1D _ptrc_glTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);\n#define glTexSubImage2D _ptrc_glTexSubImage2D\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\n#define glCopyTexSubImage3D _ptrc_glCopyTexSubImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices);\n#define glDrawRangeElements _ptrc_glDrawRangeElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);\n#define glTexImage3D _ptrc_glTexImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);\n#define glTexSubImage3D _ptrc_glTexSubImage3D\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum texture);\n#define glActiveTexture _ptrc_glActiveTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data);\n#define glCompressedTexImage1D _ptrc_glCompressedTexImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);\n#define glCompressedTexImage2D _ptrc_glCompressedTexImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);\n#define glCompressedTexImage3D _ptrc_glCompressedTexImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data);\n#define glCompressedTexSubImage1D _ptrc_glCompressedTexSubImage1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);\n#define glCompressedTexSubImage2D _ptrc_glCompressedTexSubImage2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);\n#define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum target, GLint level, void * img);\n#define glGetCompressedTexImage _ptrc_glGetCompressedTexImage\nextern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat value, GLboolean invert);\n#define glSampleCoverage _ptrc_glSampleCoverage\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\n#define glBlendColor _ptrc_glBlendColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum mode);\n#define glBlendEquation _ptrc_glBlendEquation\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\n#define glBlendFuncSeparate _ptrc_glBlendFuncSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount);\n#define glMultiDrawArrays _ptrc_glMultiDrawArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount);\n#define glMultiDrawElements _ptrc_glMultiDrawElements\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum pname, GLfloat param);\n#define glPointParameterf _ptrc_glPointParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum pname, const GLfloat * params);\n#define glPointParameterfv _ptrc_glPointParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum pname, GLint param);\n#define glPointParameteri _ptrc_glPointParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum pname, const GLint * params);\n#define glPointParameteriv _ptrc_glPointParameteriv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum target, GLuint id);\n#define glBeginQuery _ptrc_glBeginQuery\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum target, GLuint buffer);\n#define glBindBuffer _ptrc_glBindBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);\n#define glBufferData _ptrc_glBufferData\nextern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);\n#define glBufferSubData _ptrc_glBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei n, const GLuint * buffers);\n#define glDeleteBuffers _ptrc_glDeleteBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei n, const GLuint * ids);\n#define glDeleteQueries _ptrc_glDeleteQueries\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum target);\n#define glEndQuery _ptrc_glEndQuery\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei n, GLuint * buffers);\n#define glGenBuffers _ptrc_glGenBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei n, GLuint * ids);\n#define glGenQueries _ptrc_glGenQueries\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params);\n#define glGetBufferParameteriv _ptrc_glGetBufferParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum target, GLenum pname, void ** params);\n#define glGetBufferPointerv _ptrc_glGetBufferPointerv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, void * data);\n#define glGetBufferSubData _ptrc_glGetBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint id, GLenum pname, GLint * params);\n#define glGetQueryObjectiv _ptrc_glGetQueryObjectiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params);\n#define glGetQueryObjectuiv _ptrc_glGetQueryObjectuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum target, GLenum pname, GLint * params);\n#define glGetQueryiv _ptrc_glGetQueryiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint buffer);\n#define glIsBuffer _ptrc_glIsBuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint id);\n#define glIsQuery _ptrc_glIsQuery\nextern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum target, GLenum access);\n#define glMapBuffer _ptrc_glMapBuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum target);\n#define glUnmapBuffer _ptrc_glUnmapBuffer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint program, GLuint shader);\n#define glAttachShader _ptrc_glAttachShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint program, GLuint index, const GLchar * name);\n#define glBindAttribLocation _ptrc_glBindAttribLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);\n#define glBlendEquationSeparate _ptrc_glBlendEquationSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint shader);\n#define glCompileShader _ptrc_glCompileShader\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(void);\n#define glCreateProgram _ptrc_glCreateProgram\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum type);\n#define glCreateShader _ptrc_glCreateShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint program);\n#define glDeleteProgram _ptrc_glDeleteProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint shader);\n#define glDeleteShader _ptrc_glDeleteShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint program, GLuint shader);\n#define glDetachShader _ptrc_glDetachShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint index);\n#define glDisableVertexAttribArray _ptrc_glDisableVertexAttribArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei n, const GLenum * bufs);\n#define glDrawBuffers _ptrc_glDrawBuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint index);\n#define glEnableVertexAttribArray _ptrc_glEnableVertexAttribArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);\n#define glGetActiveAttrib _ptrc_glGetActiveAttrib\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);\n#define glGetActiveUniform _ptrc_glGetActiveUniform\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);\n#define glGetAttachedShaders _ptrc_glGetAttachedShaders\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint program, const GLchar * name);\n#define glGetAttribLocation _ptrc_glGetAttribLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);\n#define glGetProgramInfoLog _ptrc_glGetProgramInfoLog\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint program, GLenum pname, GLint * params);\n#define glGetProgramiv _ptrc_glGetProgramiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);\n#define glGetShaderInfoLog _ptrc_glGetShaderInfoLog\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);\n#define glGetShaderSource _ptrc_glGetShaderSource\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint shader, GLenum pname, GLint * params);\n#define glGetShaderiv _ptrc_glGetShaderiv\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint program, const GLchar * name);\n#define glGetUniformLocation _ptrc_glGetUniformLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint program, GLint location, GLfloat * params);\n#define glGetUniformfv _ptrc_glGetUniformfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint program, GLint location, GLint * params);\n#define glGetUniformiv _ptrc_glGetUniformiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void ** pointer);\n#define glGetVertexAttribPointerv _ptrc_glGetVertexAttribPointerv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble * params);\n#define glGetVertexAttribdv _ptrc_glGetVertexAttribdv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat * params);\n#define glGetVertexAttribfv _ptrc_glGetVertexAttribfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint * params);\n#define glGetVertexAttribiv _ptrc_glGetVertexAttribiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint program);\n#define glIsProgram _ptrc_glIsProgram\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint shader);\n#define glIsShader _ptrc_glIsShader\nextern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint program);\n#define glLinkProgram _ptrc_glLinkProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);\n#define glShaderSource _ptrc_glShaderSource\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);\n#define glStencilFuncSeparate _ptrc_glStencilFuncSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum face, GLuint mask);\n#define glStencilMaskSeparate _ptrc_glStencilMaskSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\n#define glStencilOpSeparate _ptrc_glStencilOpSeparate\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint location, GLfloat v0);\n#define glUniform1f _ptrc_glUniform1f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint location, GLsizei count, const GLfloat * value);\n#define glUniform1fv _ptrc_glUniform1fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint location, GLint v0);\n#define glUniform1i _ptrc_glUniform1i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint location, GLsizei count, const GLint * value);\n#define glUniform1iv _ptrc_glUniform1iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint location, GLfloat v0, GLfloat v1);\n#define glUniform2f _ptrc_glUniform2f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint location, GLsizei count, const GLfloat * value);\n#define glUniform2fv _ptrc_glUniform2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint location, GLint v0, GLint v1);\n#define glUniform2i _ptrc_glUniform2i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint location, GLsizei count, const GLint * value);\n#define glUniform2iv _ptrc_glUniform2iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\n#define glUniform3f _ptrc_glUniform3f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint location, GLsizei count, const GLfloat * value);\n#define glUniform3fv _ptrc_glUniform3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2);\n#define glUniform3i _ptrc_glUniform3i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint location, GLsizei count, const GLint * value);\n#define glUniform3iv _ptrc_glUniform3iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\n#define glUniform4f _ptrc_glUniform4f\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint location, GLsizei count, const GLfloat * value);\n#define glUniform4fv _ptrc_glUniform4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\n#define glUniform4i _ptrc_glUniform4i\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint location, GLsizei count, const GLint * value);\n#define glUniform4iv _ptrc_glUniform4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix2fv _ptrc_glUniformMatrix2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix3fv _ptrc_glUniformMatrix3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix4fv _ptrc_glUniformMatrix4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint program);\n#define glUseProgram _ptrc_glUseProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint program);\n#define glValidateProgram _ptrc_glValidateProgram\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint index, GLdouble x);\n#define glVertexAttrib1d _ptrc_glVertexAttrib1d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint index, const GLdouble * v);\n#define glVertexAttrib1dv _ptrc_glVertexAttrib1dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint index, GLfloat x);\n#define glVertexAttrib1f _ptrc_glVertexAttrib1f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint index, const GLfloat * v);\n#define glVertexAttrib1fv _ptrc_glVertexAttrib1fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint index, GLshort x);\n#define glVertexAttrib1s _ptrc_glVertexAttrib1s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint index, const GLshort * v);\n#define glVertexAttrib1sv _ptrc_glVertexAttrib1sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y);\n#define glVertexAttrib2d _ptrc_glVertexAttrib2d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint index, const GLdouble * v);\n#define glVertexAttrib2dv _ptrc_glVertexAttrib2dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y);\n#define glVertexAttrib2f _ptrc_glVertexAttrib2f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint index, const GLfloat * v);\n#define glVertexAttrib2fv _ptrc_glVertexAttrib2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint index, GLshort x, GLshort y);\n#define glVertexAttrib2s _ptrc_glVertexAttrib2s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint index, const GLshort * v);\n#define glVertexAttrib2sv _ptrc_glVertexAttrib2sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z);\n#define glVertexAttrib3d _ptrc_glVertexAttrib3d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint index, const GLdouble * v);\n#define glVertexAttrib3dv _ptrc_glVertexAttrib3dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z);\n#define glVertexAttrib3f _ptrc_glVertexAttrib3f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint index, const GLfloat * v);\n#define glVertexAttrib3fv _ptrc_glVertexAttrib3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z);\n#define glVertexAttrib3s _ptrc_glVertexAttrib3s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint index, const GLshort * v);\n#define glVertexAttrib3sv _ptrc_glVertexAttrib3sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint index, const GLbyte * v);\n#define glVertexAttrib4Nbv _ptrc_glVertexAttrib4Nbv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint index, const GLint * v);\n#define glVertexAttrib4Niv _ptrc_glVertexAttrib4Niv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint index, const GLshort * v);\n#define glVertexAttrib4Nsv _ptrc_glVertexAttrib4Nsv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\n#define glVertexAttrib4Nub _ptrc_glVertexAttrib4Nub\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint index, const GLubyte * v);\n#define glVertexAttrib4Nubv _ptrc_glVertexAttrib4Nubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint index, const GLuint * v);\n#define glVertexAttrib4Nuiv _ptrc_glVertexAttrib4Nuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint index, const GLushort * v);\n#define glVertexAttrib4Nusv _ptrc_glVertexAttrib4Nusv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint index, const GLbyte * v);\n#define glVertexAttrib4bv _ptrc_glVertexAttrib4bv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\n#define glVertexAttrib4d _ptrc_glVertexAttrib4d\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint index, const GLdouble * v);\n#define glVertexAttrib4dv _ptrc_glVertexAttrib4dv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\n#define glVertexAttrib4f _ptrc_glVertexAttrib4f\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint index, const GLfloat * v);\n#define glVertexAttrib4fv _ptrc_glVertexAttrib4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint index, const GLint * v);\n#define glVertexAttrib4iv _ptrc_glVertexAttrib4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\n#define glVertexAttrib4s _ptrc_glVertexAttrib4s\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint index, const GLshort * v);\n#define glVertexAttrib4sv _ptrc_glVertexAttrib4sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint index, const GLubyte * v);\n#define glVertexAttrib4ubv _ptrc_glVertexAttrib4ubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint index, const GLuint * v);\n#define glVertexAttrib4uiv _ptrc_glVertexAttrib4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint index, const GLushort * v);\n#define glVertexAttrib4usv _ptrc_glVertexAttrib4usv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);\n#define glVertexAttribPointer _ptrc_glVertexAttribPointer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix2x3fv _ptrc_glUniformMatrix2x3fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix2x4fv _ptrc_glUniformMatrix2x4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix3x2fv _ptrc_glUniformMatrix3x2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix3x4fv _ptrc_glUniformMatrix3x4fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix4x2fv _ptrc_glUniformMatrix4x2fv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);\n#define glUniformMatrix4x3fv _ptrc_glUniformMatrix4x3fv\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint id, GLenum mode);\n#define glBeginConditionalRender _ptrc_glBeginConditionalRender\nextern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum primitiveMode);\n#define glBeginTransformFeedback _ptrc_glBeginTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum target, GLuint index, GLuint buffer);\n#define glBindBufferBase _ptrc_glBindBufferBase\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\n#define glBindBufferRange _ptrc_glBindBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint program, GLuint color, const GLchar * name);\n#define glBindFragDataLocation _ptrc_glBindFragDataLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum target, GLuint framebuffer);\n#define glBindFramebuffer _ptrc_glBindFramebuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum target, GLuint renderbuffer);\n#define glBindRenderbuffer _ptrc_glBindRenderbuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint ren_array);\n#define glBindVertexArray _ptrc_glBindVertexArray\nextern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#define glBlitFramebuffer _ptrc_glBlitFramebuffer\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum target);\n#define glCheckFramebufferStatus _ptrc_glCheckFramebufferStatus\nextern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum target, GLenum clamp);\n#define glClampColor _ptrc_glClampColor\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);\n#define glClearBufferfi _ptrc_glClearBufferfi\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat * value);\n#define glClearBufferfv _ptrc_glClearBufferfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint * value);\n#define glClearBufferiv _ptrc_glClearBufferiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint * value);\n#define glClearBufferuiv _ptrc_glClearBufferuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\n#define glColorMaski _ptrc_glColorMaski\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei n, const GLuint * framebuffers);\n#define glDeleteFramebuffers _ptrc_glDeleteFramebuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei n, const GLuint * renderbuffers);\n#define glDeleteRenderbuffers _ptrc_glDeleteRenderbuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei n, const GLuint * arrays);\n#define glDeleteVertexArrays _ptrc_glDeleteVertexArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum target, GLuint index);\n#define glDisablei _ptrc_glDisablei\nextern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum target, GLuint index);\n#define glEnablei _ptrc_glEnablei\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(void);\n#define glEndConditionalRender _ptrc_glEndConditionalRender\nextern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(void);\n#define glEndTransformFeedback _ptrc_glEndTransformFeedback\nextern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length);\n#define glFlushMappedBufferRange _ptrc_glFlushMappedBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\n#define glFramebufferRenderbuffer _ptrc_glFramebufferRenderbuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\n#define glFramebufferTexture1D _ptrc_glFramebufferTexture1D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\n#define glFramebufferTexture2D _ptrc_glFramebufferTexture2D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\n#define glFramebufferTexture3D _ptrc_glFramebufferTexture3D\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\n#define glFramebufferTextureLayer _ptrc_glFramebufferTextureLayer\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei n, GLuint * framebuffers);\n#define glGenFramebuffers _ptrc_glGenFramebuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei n, GLuint * renderbuffers);\n#define glGenRenderbuffers _ptrc_glGenRenderbuffers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei n, GLuint * arrays);\n#define glGenVertexArrays _ptrc_glGenVertexArrays\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum target);\n#define glGenerateMipmap _ptrc_glGenerateMipmap\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum target, GLuint index, GLboolean * data);\n#define glGetBooleani_v _ptrc_glGetBooleani_v\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint program, const GLchar * name);\n#define glGetFragDataLocation _ptrc_glGetFragDataLocation\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint * params);\n#define glGetFramebufferAttachmentParameteriv _ptrc_glGetFramebufferAttachmentParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum target, GLuint index, GLint * data);\n#define glGetIntegeri_v _ptrc_glGetIntegeri_v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint * params);\n#define glGetRenderbufferParameteriv _ptrc_glGetRenderbufferParameteriv\nextern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum name, GLuint index);\n#define glGetStringi _ptrc_glGetStringi\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum target, GLenum pname, GLint * params);\n#define glGetTexParameterIiv _ptrc_glGetTexParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum target, GLenum pname, GLuint * params);\n#define glGetTexParameterIuiv _ptrc_glGetTexParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name);\n#define glGetTransformFeedbackVarying _ptrc_glGetTransformFeedbackVarying\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint program, GLint location, GLuint * params);\n#define glGetUniformuiv _ptrc_glGetUniformuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint * params);\n#define glGetVertexAttribIiv _ptrc_glGetVertexAttribIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint * params);\n#define glGetVertexAttribIuiv _ptrc_glGetVertexAttribIuiv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum target, GLuint index);\n#define glIsEnabledi _ptrc_glIsEnabledi\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint framebuffer);\n#define glIsFramebuffer _ptrc_glIsFramebuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint renderbuffer);\n#define glIsRenderbuffer _ptrc_glIsRenderbuffer\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint ren_array);\n#define glIsVertexArray _ptrc_glIsVertexArray\nextern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);\n#define glMapBufferRange _ptrc_glMapBufferRange\nextern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\n#define glRenderbufferStorage _ptrc_glRenderbufferStorage\nextern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\n#define glRenderbufferStorageMultisample _ptrc_glRenderbufferStorageMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum target, GLenum pname, const GLint * params);\n#define glTexParameterIiv _ptrc_glTexParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum target, GLenum pname, const GLuint * params);\n#define glTexParameterIuiv _ptrc_glTexParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode);\n#define glTransformFeedbackVaryings _ptrc_glTransformFeedbackVaryings\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint location, GLuint v0);\n#define glUniform1ui _ptrc_glUniform1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint location, GLsizei count, const GLuint * value);\n#define glUniform1uiv _ptrc_glUniform1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint location, GLuint v0, GLuint v1);\n#define glUniform2ui _ptrc_glUniform2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint location, GLsizei count, const GLuint * value);\n#define glUniform2uiv _ptrc_glUniform2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2);\n#define glUniform3ui _ptrc_glUniform3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint location, GLsizei count, const GLuint * value);\n#define glUniform3uiv _ptrc_glUniform3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\n#define glUniform4ui _ptrc_glUniform4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint location, GLsizei count, const GLuint * value);\n#define glUniform4uiv _ptrc_glUniform4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint index, GLint x);\n#define glVertexAttribI1i _ptrc_glVertexAttribI1i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint index, const GLint * v);\n#define glVertexAttribI1iv _ptrc_glVertexAttribI1iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint index, GLuint x);\n#define glVertexAttribI1ui _ptrc_glVertexAttribI1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint index, const GLuint * v);\n#define glVertexAttribI1uiv _ptrc_glVertexAttribI1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint index, GLint x, GLint y);\n#define glVertexAttribI2i _ptrc_glVertexAttribI2i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint index, const GLint * v);\n#define glVertexAttribI2iv _ptrc_glVertexAttribI2iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint index, GLuint x, GLuint y);\n#define glVertexAttribI2ui _ptrc_glVertexAttribI2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint index, const GLuint * v);\n#define glVertexAttribI2uiv _ptrc_glVertexAttribI2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z);\n#define glVertexAttribI3i _ptrc_glVertexAttribI3i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint index, const GLint * v);\n#define glVertexAttribI3iv _ptrc_glVertexAttribI3iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z);\n#define glVertexAttribI3ui _ptrc_glVertexAttribI3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint index, const GLuint * v);\n#define glVertexAttribI3uiv _ptrc_glVertexAttribI3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint index, const GLbyte * v);\n#define glVertexAttribI4bv _ptrc_glVertexAttribI4bv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w);\n#define glVertexAttribI4i _ptrc_glVertexAttribI4i\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint index, const GLint * v);\n#define glVertexAttribI4iv _ptrc_glVertexAttribI4iv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint index, const GLshort * v);\n#define glVertexAttribI4sv _ptrc_glVertexAttribI4sv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint index, const GLubyte * v);\n#define glVertexAttribI4ubv _ptrc_glVertexAttribI4ubv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\n#define glVertexAttribI4ui _ptrc_glVertexAttribI4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint index, const GLuint * v);\n#define glVertexAttribI4uiv _ptrc_glVertexAttribI4uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint index, const GLushort * v);\n#define glVertexAttribI4usv _ptrc_glVertexAttribI4usv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer);\n#define glVertexAttribIPointer _ptrc_glVertexAttribIPointer\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\n#define glCopyBufferSubData _ptrc_glCopyBufferSubData\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);\n#define glDrawArraysInstanced _ptrc_glDrawArraysInstanced\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount);\n#define glDrawElementsInstanced _ptrc_glDrawElementsInstanced\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName);\n#define glGetActiveUniformBlockName _ptrc_glGetActiveUniformBlockName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params);\n#define glGetActiveUniformBlockiv _ptrc_glGetActiveUniformBlockiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName);\n#define glGetActiveUniformName _ptrc_glGetActiveUniformName\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params);\n#define glGetActiveUniformsiv _ptrc_glGetActiveUniformsiv\nextern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint program, const GLchar * uniformBlockName);\n#define glGetUniformBlockIndex _ptrc_glGetUniformBlockIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices);\n#define glGetUniformIndices _ptrc_glGetUniformIndices\nextern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint index);\n#define glPrimitiveRestartIndex _ptrc_glPrimitiveRestartIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum target, GLenum internalformat, GLuint buffer);\n#define glTexBuffer _ptrc_glTexBuffer\nextern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);\n#define glUniformBlockBinding _ptrc_glUniformBlockBinding\n\nextern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout);\n#define glClientWaitSync _ptrc_glClientWaitSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync sync);\n#define glDeleteSync _ptrc_glDeleteSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);\n#define glDrawElementsBaseVertex _ptrc_glDrawElementsBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);\n#define glDrawElementsInstancedBaseVertex _ptrc_glDrawElementsInstancedBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);\n#define glDrawRangeElementsBaseVertex _ptrc_glDrawRangeElementsBaseVertex\nextern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum condition, GLbitfield flags);\n#define glFenceSync _ptrc_glFenceSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum target, GLenum attachment, GLuint texture, GLint level);\n#define glFramebufferTexture _ptrc_glFramebufferTexture\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 * params);\n#define glGetBufferParameteri64v _ptrc_glGetBufferParameteri64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum target, GLuint index, GLint64 * data);\n#define glGetInteger64i_v _ptrc_glGetInteger64i_v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum pname, GLint64 * data);\n#define glGetInteger64v _ptrc_glGetInteger64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat * val);\n#define glGetMultisamplefv _ptrc_glGetMultisamplefv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values);\n#define glGetSynciv _ptrc_glGetSynciv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync sync);\n#define glIsSync _ptrc_glIsSync\nextern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex);\n#define glMultiDrawElementsBaseVertex _ptrc_glMultiDrawElementsBaseVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum mode);\n#define glProvokingVertex _ptrc_glProvokingVertex\nextern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint maskNumber, GLbitfield mask);\n#define glSampleMaski _ptrc_glSampleMaski\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\n#define glTexImage2DMultisample _ptrc_glTexImage2DMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\n#define glTexImage3DMultisample _ptrc_glTexImage3DMultisample\nextern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout);\n#define glWaitSync _ptrc_glWaitSync\n\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);\n#define glBindFragDataLocationIndexed _ptrc_glBindFragDataLocationIndexed\nextern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint unit, GLuint sampler);\n#define glBindSampler _ptrc_glBindSampler\nextern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei count, const GLuint * samplers);\n#define glDeleteSamplers _ptrc_glDeleteSamplers\nextern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei count, GLuint * samplers);\n#define glGenSamplers _ptrc_glGenSamplers\nextern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint program, const GLchar * name);\n#define glGetFragDataIndex _ptrc_glGetFragDataIndex\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 * params);\n#define glGetQueryObjecti64v _ptrc_glGetQueryObjecti64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 * params);\n#define glGetQueryObjectui64v _ptrc_glGetQueryObjectui64v\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint sampler, GLenum pname, GLint * params);\n#define glGetSamplerParameterIiv _ptrc_glGetSamplerParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint sampler, GLenum pname, GLuint * params);\n#define glGetSamplerParameterIuiv _ptrc_glGetSamplerParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat * params);\n#define glGetSamplerParameterfv _ptrc_glGetSamplerParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint * params);\n#define glGetSamplerParameteriv _ptrc_glGetSamplerParameteriv\nextern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint sampler);\n#define glIsSampler _ptrc_glIsSampler\nextern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint id, GLenum target);\n#define glQueryCounter _ptrc_glQueryCounter\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint sampler, GLenum pname, const GLint * param);\n#define glSamplerParameterIiv _ptrc_glSamplerParameterIiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint sampler, GLenum pname, const GLuint * param);\n#define glSamplerParameterIuiv _ptrc_glSamplerParameterIuiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param);\n#define glSamplerParameterf _ptrc_glSamplerParameterf\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat * param);\n#define glSamplerParameterfv _ptrc_glSamplerParameterfv\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param);\n#define glSamplerParameteri _ptrc_glSamplerParameteri\nextern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint * param);\n#define glSamplerParameteriv _ptrc_glSamplerParameteriv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint index, GLuint divisor);\n#define glVertexAttribDivisor _ptrc_glVertexAttribDivisor\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value);\n#define glVertexAttribP1ui _ptrc_glVertexAttribP1ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);\n#define glVertexAttribP1uiv _ptrc_glVertexAttribP1uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value);\n#define glVertexAttribP2ui _ptrc_glVertexAttribP2ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);\n#define glVertexAttribP2uiv _ptrc_glVertexAttribP2uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value);\n#define glVertexAttribP3ui _ptrc_glVertexAttribP3ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);\n#define glVertexAttribP3uiv _ptrc_glVertexAttribP3uiv\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value);\n#define glVertexAttribP4ui _ptrc_glVertexAttribP4ui\nextern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);\n#define glVertexAttribP4uiv _ptrc_glVertexAttribP4uiv\n\nenum ogl_LoadStatus\n{\n\togl_LOAD_FAILED = 0,\n\togl_LOAD_SUCCEEDED = 1,\n};\n\nint ogl_LoadFunctions();\n\nint ogl_GetMinorVersion(void);\nint ogl_GetMajorVersion(void);\nint ogl_IsVersionGEQ(int majorVersion, int minorVersion);\n\n#ifdef __cplusplus\n}\n#endif /*__cplusplus*/\n\n#endif /*POINTER_C_GENERATED_HEADER_OPENGL_H*/\n\n#endif // GLES\n"
  },
  {
    "path": "src/output/gl_proc.h",
    "content": "#pragma once\n\ntypedef void (*funcptr)(void);\n\nfuncptr IntGetProcAddress(const char* name);\n"
  },
  {
    "path": "src/output/screen.h",
    "content": "#pragma once\n\n#include \"core/n64video.h\"\n\n#include <stdint.h>\n#include <stdbool.h>\n\nvoid screen_init(struct n64video_config* config);\nvoid screen_adjust(int32_t width_out, int32_t height_out, int32_t* width, int32_t* height, int32_t* x, int32_t* y);\nvoid screen_update(void);\nvoid screen_toggle_fullscreen(void);\nvoid screen_close(void);\n"
  },
  {
    "path": "src/output/vdac.c",
    "content": "#include \"vdac.h\"\n#include \"screen.h\"\n#include \"core/msg.h\"\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdio.h>\n\n#ifdef GLES\n#include <GLES3/gl3.h>\n#else\n#include \"gl_core_3_3.h\"\n#endif\n\n#define GLES_SHADER_HEADER \"#version 300 es\\nprecision lowp float;\\n\"\n#define GL_SHADER_HEADER \"#version 330 core\\n\"\n\n#define TEX_FORMAT GL_RGBA\n#define TEX_TYPE GL_UNSIGNED_BYTE\n\nstatic bool m_fbo_enabled;\nstatic GLuint m_fbo;\nstatic bool m_integer_scaling;\n\nstatic GLuint m_fbtex;\nstatic uint32_t m_fbtex_width;\nstatic uint32_t m_fbtex_height;\n\nstatic GLuint m_rawtex;\nstatic uint32_t m_rawtex_width;\nstatic uint32_t m_rawtex_height;\nstatic bool m_rawtex_read;\n\nstatic GLuint m_program;\nstatic GLuint m_vao;\n\n#ifdef _DEBUG\nstatic void gl_check_errors(void)\n{\n    GLenum err;\n    static int32_t invalid_op_count = 0;\n    while ((err = glGetError()) != GL_NO_ERROR) {\n        // if gl_check_errors is called from a thread with no valid\n        // GL context, it would be stuck in an infinite loop here, since\n        // glGetError itself causes GL_INVALID_OPERATION, so check for a few\n        // cycles and abort if there are too many errors of that kind\n        if (err == GL_INVALID_OPERATION) {\n            if (++invalid_op_count >= 100) {\n                msg_error(\"gl_check_errors: invalid OpenGL context!\");\n            }\n        } else {\n            invalid_op_count = 0;\n        }\n\n        char* err_str;\n        switch (err) {\n            case GL_INVALID_OPERATION:\n                err_str = \"INVALID_OPERATION\";\n                break;\n            case GL_INVALID_ENUM:\n                err_str = \"INVALID_ENUM\";\n                break;\n            case GL_INVALID_VALUE:\n                err_str = \"INVALID_VALUE\";\n                break;\n            case GL_OUT_OF_MEMORY:\n                err_str = \"OUT_OF_MEMORY\";\n                break;\n            case GL_INVALID_FRAMEBUFFER_OPERATION:\n                err_str = \"INVALID_FRAMEBUFFER_OPERATION\";\n                break;\n            default:\n                err_str = \"unknown\";\n        }\n        msg_debug(\"gl_check_errors: %d (%s)\", err, err_str);\n    }\n}\n#else\n#define gl_check_errors(...)\n#endif\n\nstatic void gl_fbo_create(uint32_t width, uint32_t height)\n{\n    // prepare FB texture\n    glGenTextures(1, &m_fbtex);\n    glBindTexture(GL_TEXTURE_2D, m_fbtex);\n\n    // reallocate texture buffer on GPU\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, TEX_FORMAT, TEX_TYPE, NULL);\n\n    // prepare framebuffer object\n    glGenFramebuffers(1, &m_fbo);\n    glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);\n\n    // attach texture\n    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fbtex, 0);\n\n    // bind raw texture again\n    glBindTexture(GL_TEXTURE_2D, m_rawtex);\n\n    // check framebuffer object\n    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {\n        msg_error(\"FBO creation failed!\");\n    }\n}\n\nstatic void gl_fbo_delete(void)\n{\n    if (m_fbo) {\n        glDeleteFramebuffers(1, &m_fbo);\n        m_fbo = 0;\n    }\n\n    if (m_fbtex) {\n        glDeleteTextures(1, &m_fbtex);\n        m_fbtex = 0;\n    }\n}\n\nstatic bool gl_shader_load_file(GLuint shader, const char* path)\n{\n    bool success = false;\n    GLchar* source = NULL;\n    FILE* fp = fopen(path, \"rb\");\n    if (!fp) {\n        // fail quietly\n        goto end;\n    }\n\n    // get file size\n    fseek(fp, 0, SEEK_END);\n    uint32_t source_size = ftell(fp);\n    fseek(fp, 0, SEEK_SET);\n\n    // allocate buffer for shader code\n    source = malloc(source_size + 1);\n    if (source == NULL) {\n        msg_error(\"Can't allocate memory for shader file %s\", path);\n        goto end;\n    }\n\n    // read shader code\n    if (fread(source, source_size, 1, fp) != 1) {\n        msg_warning(\"Can't read shader file %s\", path);\n        goto end;\n    }\n\n    // terminate shader code string\n    source[source_size] = 0;\n\n    // send string to OpenGL\n    const GLchar* source_ptr = source;\n    glShaderSource(shader, 1, &source_ptr, NULL);\n\n    success = true;\n\nend:\n    if (fp) {\n        fclose(fp);\n    }\n    if (source) {\n        free(source);\n    }\n\n    return success;\n}\n\nstatic GLuint gl_shader_compile(GLenum type, const GLchar* source, const char* path)\n{\n    GLuint shader = glCreateShader(type);\n\n    // try to load external shader file first, otherwise use embedded fallback shader\n    if (!gl_shader_load_file(shader, path)) {\n        glShaderSource(shader, 1, &source, NULL);\n    }\n\n    glCompileShader(shader);\n\n    GLint param;\n    glGetShaderiv(shader, GL_COMPILE_STATUS, &param);\n\n    if (!param) {\n        GLchar log[4096];\n        glGetShaderInfoLog(shader, sizeof(log), NULL, log);\n        msg_error(\"%s shader error: %s\\n\", type == GL_FRAGMENT_SHADER ? \"Frag\" : \"Vert\", log);\n    }\n\n    return shader;\n}\n\nstatic GLuint gl_shader_link(GLuint vert, GLuint frag)\n{\n    GLuint program = glCreateProgram();\n    glAttachShader(program, vert);\n    glAttachShader(program, frag);\n    glLinkProgram(program);\n\n    GLint param;\n    glGetProgramiv(program, GL_LINK_STATUS, &param);\n\n    if (!param) {\n        GLchar log[4096];\n        glGetProgramInfoLog(program, sizeof(log), NULL, log);\n        msg_error(\"Shader link error: %s\\n\", log);\n    }\n\n    glDeleteShader(frag);\n    glDeleteShader(vert);\n\n    return program;\n}\n\nvoid vdac_init(struct n64video_config* config)\n{\n    screen_init(config);\n\n#ifndef GLES\n    // load OpenGL function pointers\n    ogl_LoadFunctions();\n#endif\n\n    const char* gl_version = (const char*)glGetString(GL_VERSION);\n\n#ifndef GLES\n    const int is_gles = strstr(gl_version, \"OpenGL ES\") != NULL;\n#else\n    const int is_gles = 1;\n#endif\n\n    msg_debug(\"%s: GL_VERSION='%s'\", __FUNCTION__, gl_version);\n    msg_debug(\"%s: GL_VENDOR='%s'\", __FUNCTION__, glGetString(GL_VENDOR));\n    msg_debug(\"%s: GL_RENDERER='%s'\", __FUNCTION__, glGetString(GL_RENDERER));\n    msg_debug(\"%s: GL_SHADING_LANGUAGE_VERSION='%s'\", __FUNCTION__, glGetString(GL_SHADING_LANGUAGE_VERSION));\n\n    // shader sources for drawing a clipped full-screen triangle. the geometry\n    // is defined by the vertex ID, so a VBO is not required.\n    GLchar vert_shader[256];\n    sprintf(vert_shader, \"%s%s\", (is_gles ? GLES_SHADER_HEADER : GL_SHADER_HEADER),\n        \"out vec2 uv;\\n\"\n        \"void main(void) {\\n\"\n        \"    uv = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2);\\n\"\n        \"    gl_Position = vec4(uv * vec2(2.0, -2.0) + vec2(-1.0, 1.0), 0.0, 1.0);\\n\"\n        \"}\\n\"\n    );\n\n    GLchar frag_shader[256];\n    sprintf(frag_shader, \"%s%s\", (is_gles ? GLES_SHADER_HEADER : GL_SHADER_HEADER),\n        \"in vec2 uv;\\n\"\n        \"layout(location = 0) out vec4 color;\\n\"\n        \"uniform sampler2D tex0;\\n\"\n        \"void main(void) {\\n\"\n        \"    color = texture(tex0, uv);\\n\"\n        \"}\\n\"\n    );\n\n    // compile and link OpenGL program\n    GLuint vert = gl_shader_compile(GL_VERTEX_SHADER, vert_shader, \"alp_screen.vert\");\n    GLuint frag = gl_shader_compile(GL_FRAGMENT_SHADER, frag_shader, \"alp_screen.frag\");\n    m_program = gl_shader_link(vert, frag);\n    glUseProgram(m_program);\n\n    // prepare dummy VAO\n    glGenVertexArrays(1, &m_vao);\n    glBindVertexArray(m_vao);\n\n    // prepare texture\n    glGenTextures(1, &m_rawtex);\n    glBindTexture(GL_TEXTURE_2D, m_rawtex);\n\n    // select interpolation method\n    GLint filter;\n    switch (config->vi.interp) {\n        case VI_INTERP_HYBRID:\n            m_fbo_enabled = true;\n            filter = GL_LINEAR;\n            break;\n        case VI_INTERP_LINEAR:\n            m_fbo_enabled = false;\n            filter = GL_LINEAR;\n            break;\n        case VI_INTERP_NEAREST:\n        default:\n            m_fbo_enabled = false;\n            filter = GL_NEAREST;\n    }\n\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);\n\n    // read with exact FB size in non-filtered modes\n    m_rawtex_read = config->vi.mode != VI_MODE_NORMAL;\n\n    // save integer scaling flag, will be used later\n    m_integer_scaling = config->vi.integer_scaling;\n\n    // check if there was an error when using any of the commands above\n    gl_check_errors();\n}\n\nvoid vdac_read(struct n64video_frame_buffer* fb, bool alpha)\n{\n    uint32_t width, height;\n\n    if (m_rawtex_read) {\n        width = m_rawtex_width;\n        height = m_rawtex_height;\n    } else {\n        width = m_fbtex_width;\n        height = m_fbtex_height;\n    }\n\n    // create temporary FBO if none has been created so far or if the existing\n    // one has the wrong size\n    bool temp_fbo = !m_fbo_enabled || width != m_fbtex_width || height != m_fbtex_height;\n\n    fb->width = width;\n    fb->height = fb->height_out = height;\n    fb->pitch = fb->width;\n\n    if (fb->pixels) {\n        // create temporary FBO\n        if (temp_fbo) {\n            gl_fbo_delete(); // in case m_fbo_enabled is true\n            gl_fbo_create(width, height);\n\n            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);\n            glViewport(0, 0, width, height);\n            glDrawArrays(GL_TRIANGLES, 0, 3);\n        }\n\n        glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo);\n        glReadPixels(0, 0, width, height, alpha ? GL_RGBA : GL_RGB, TEX_TYPE, fb->pixels);\n\n        // delete temporary FBO\n        if (temp_fbo) {\n            if (!m_fbo_enabled) {\n                // bind default FB\n                glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);\n            }\n\n            gl_fbo_delete();\n\n            if (m_fbo_enabled) {\n                // restore previous FBO\n                gl_fbo_create(m_fbtex_width, m_fbtex_height);\n            }\n        }\n    }\n}\n\nvoid vdac_write(struct n64video_frame_buffer* fb)\n{\n    bool raw_size_changed = m_rawtex_width != fb->width || m_rawtex_height != fb->height;\n    bool fb_size_changed = m_fbtex_width != fb->width || m_fbtex_height != fb->height_out;\n\n    // check if the framebuffer size has changed\n    if (raw_size_changed) {\n        m_rawtex_width = fb->width;\n        m_rawtex_height = fb->height;\n\n        // set pitch for all unpacking operations\n        glPixelStorei(GL_UNPACK_ROW_LENGTH, fb->pitch);\n\n        // reallocate texture buffer on GPU\n        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_rawtex_width,\n            m_rawtex_height, 0, TEX_FORMAT, TEX_TYPE, fb->pixels);\n\n        msg_debug(\"%s: resized framebuffer texture: %dx%d\", __FUNCTION__, m_rawtex_width, m_rawtex_height);\n    } else {\n        // copy local buffer to GPU texture buffer\n        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_rawtex_width, m_rawtex_height,\n            TEX_FORMAT, TEX_TYPE, fb->pixels);\n    }\n\n    if (fb_size_changed) {\n        m_fbtex_width = fb->width;\n        m_fbtex_height = fb->height_out;\n\n        if (m_fbo_enabled) {\n            // rebuild FBO\n            gl_fbo_delete();\n            gl_fbo_create(m_fbtex_width, m_fbtex_height);\n        }\n    }\n}\n\nvoid vdac_sync(bool valid)\n{\n    // clear old buffers\n    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\n    // get current window size and position\n    int32_t win_width;\n    int32_t win_height;\n    int32_t out_width;\n    int32_t out_height;\n    int32_t out_x;\n    int32_t out_y;\n\n    screen_adjust(m_fbtex_width, m_fbtex_height, &win_width, &win_height, &out_x, &out_y);\n\n    // if the screen is invalid or hidden, do nothing\n    if (win_width <= 0 || win_height <= 0) {\n        return;\n    }\n\n    // skip rendering and leave buffer blank if there's no valid input\n    if (!valid) {\n        screen_update();\n        return;\n    }\n\n    if (m_integer_scaling) {\n        out_width = (int32_t)m_fbtex_width;\n        out_height = (int32_t)m_fbtex_height;\n\n        // scale down if output is bigger than window\n        while (out_width > win_width || out_height > win_height) {\n            out_width /= 2;\n            out_height /= 2;\n        }\n\n        // scale up if doubled size is smaller than window\n        while (out_width * 2 <= win_width && out_height * 2 <= win_height) {\n            out_width *= 2;\n            out_height *= 2;\n        }\n\n        // apply new size and offset\n        out_x += (win_width - out_width) / 2;\n        out_y += (win_height - out_height) / 2;\n    } else {\n        int32_t hw = m_fbtex_height * win_width;\n        int32_t wh = m_fbtex_width * win_height;\n\n        // add letterboxes or pillarboxes if the window has a different aspect ratio\n        // than the current display mode\n        if (hw > wh) {\n            int32_t w_max = wh / m_fbtex_height;\n            out_x += (win_width - w_max) / 2;\n            out_width = w_max;\n            out_height = win_height;\n        } else if (hw < wh) {\n            int32_t h_max = hw / m_fbtex_width;\n            out_y += (win_height - h_max) / 2;\n            out_width = win_width;\n            out_height = h_max;\n        } else {\n            out_width = win_width;\n            out_height = win_height;\n        }\n    }\n\n    if (m_fbo_enabled) {\n        // framebuffer post-processing\n        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);\n        glViewport(0, 0, m_fbtex_width, m_fbtex_height);\n        glDrawArrays(GL_TRIANGLES, 0, 3);\n\n        // final upscale and output\n        glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo);\n        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);\n\n        GLint src_x0 = 0;\n        GLint src_y0 = 0;\n        GLint src_x1 = m_fbtex_width - 1;\n        GLint src_y1 = m_fbtex_height - 1;\n        GLint dst_x0 = out_x;\n        GLint dst_y0 = out_y;\n        GLint dst_x1 = dst_x0 + out_width - 1;\n        GLint dst_y1 = dst_y0 + out_height - 1;\n\n        glBlitFramebuffer(src_x0, src_y0, src_x1, src_y1, dst_x0, dst_y0, dst_x1, dst_y1, GL_COLOR_BUFFER_BIT, GL_NEAREST);\n    } else {\n        // configure viewport\n        glViewport(out_x, out_y, out_width, out_height);\n\n        // draw fullscreen triangle\n        glDrawArrays(GL_TRIANGLES, 0, 3);\n    }\n\n    // check if there was an error when using any of the commands above\n    gl_check_errors();\n\n    // refresh screen with new frame\n    screen_update();\n}\n\nvoid vdac_close(void)\n{\n    m_rawtex_width = 0;\n    m_rawtex_height = 0;\n\n    m_fbtex_width = 0;\n    m_fbtex_height = 0;\n\n    if (m_rawtex) {\n        glDeleteTextures(1, &m_rawtex);\n        m_rawtex = 0;\n    }\n\n    if (m_vao) {\n        glDeleteVertexArrays(1, &m_vao);\n        m_vao = 0;\n    }\n\n    if (m_program) {\n        glDeleteProgram(m_program);\n        m_program = 0;\n    }\n\n    gl_fbo_delete();\n\n    screen_close();\n}\n"
  },
  {
    "path": "src/output/vdac.h",
    "content": "#pragma once\n\n#include \"core/n64video.h\"\n\n#include <stdint.h>\n#include <stdbool.h>\n\nvoid vdac_init(struct n64video_config* config);\nvoid vdac_read(struct n64video_frame_buffer* fb, bool alpha);\nvoid vdac_write(struct n64video_frame_buffer* fb);\nvoid vdac_sync(bool invaid);\nvoid vdac_close(void);\n"
  },
  {
    "path": "src/plugin/mupen64plus/api/m64p_common.h",
    "content": "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *   Mupen64plus-core - m64p_common.h                                      *\n *   Mupen64Plus homepage: https://mupen64plus.org/                        *\n *   Copyright (C) 2009 Richard Goedeken                                   *\n *                                                                         *\n *   This program is free software; you can redistribute it and/or modify  *\n *   it under the terms of the GNU General Public License as published by  *\n *   the Free Software Foundation; either version 2 of the License, or     *\n *   (at your option) any later version.                                   *\n *                                                                         *\n *   This program is distributed in the hope that it will be useful,       *\n *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\n *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\n *   GNU General Public License for more details.                          *\n *                                                                         *\n *   You should have received a copy of the GNU General Public License     *\n *   along with this program; if not, write to the                         *\n *   Free Software Foundation, Inc.,                                       *\n *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n/* This header file defines typedefs for function pointers to common Core\n * and plugin functions, for use by the front-end and plugin modules to attach\n * to the dynamic libraries.\n */\n\n#if !defined(M64P_COMMON_H)\n#define M64P_COMMON_H\n\n#include \"m64p_types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* PluginGetVersion()\n *\n * This function retrieves version information from a library. This\n * function is the same for the core library and the plugins.\n */\ntypedef m64p_error (*ptr_PluginGetVersion)(m64p_plugin_type *, int *, int *, const char **, int *);\n#if defined(M64P_PLUGIN_PROTOTYPES) || defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *, int *, int *, const char **, int *);\n#endif\n\n/* CoreGetAPIVersions()\n *\n * This function retrieves API version information from the core.\n */\ntypedef m64p_error (*ptr_CoreGetAPIVersions)(int *, int *, int *, int *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL CoreGetAPIVersions(int *, int *, int *, int *);\n#endif\n\n/* CoreErrorMessage()\n *\n * This function returns a pointer to a NULL-terminated string giving a\n * human-readable description of the error.\n*/\ntypedef const char * (*ptr_CoreErrorMessage)(m64p_error);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT const char * CALL CoreErrorMessage(m64p_error);\n#endif\n\n/* PluginStartup()\n *\n * This function initializes a plugin for use by allocating memory, creating\n * data structures, and loading the configuration data.\n*/\ntypedef m64p_error (*ptr_PluginStartup)(m64p_dynlib_handle, void *, void (*)(void *, int, const char *));\n#if defined(M64P_PLUGIN_PROTOTYPES) || defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle, void *, void (*)(void *, int, const char *));\n#endif\n\n/* PluginShutdown()\n *\n * This function destroys data structures and releases memory allocated by\n * the plugin library.\n*/\ntypedef m64p_error (*ptr_PluginShutdown)(void);\n#if defined(M64P_PLUGIN_PROTOTYPES) || defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL PluginShutdown(void);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* #define M64P_COMMON_H */\n\n"
  },
  {
    "path": "src/plugin/mupen64plus/api/m64p_config.h",
    "content": "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *   Mupen64plus-core - m64p_config.h                                      *\n *   Mupen64Plus homepage: https://mupen64plus.org/                        *\n *   Copyright (C) 2009 Richard Goedeken                                   *\n *                                                                         *\n *   This program is free software; you can redistribute it and/or modify  *\n *   it under the terms of the GNU General Public License as published by  *\n *   the Free Software Foundation; either version 2 of the License, or     *\n *   (at your option) any later version.                                   *\n *                                                                         *\n *   This program is distributed in the hope that it will be useful,       *\n *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\n *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\n *   GNU General Public License for more details.                          *\n *                                                                         *\n *   You should have received a copy of the GNU General Public License     *\n *   along with this program; if not, write to the                         *\n *   Free Software Foundation, Inc.,                                       *\n *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n/* This header file defines typedefs for function pointers to the Core's\n * configuration handling functions.\n */\n\n#if !defined(M64P_CONFIG_H)\n#define M64P_CONFIG_H\n\n#include \"m64p_types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* ConfigListSections()\n *\n * This function is called to enumerate the list of Sections in the Mupen64Plus\n * configuration file. It is expected that there will be a section named \"Core\"\n * for core-specific configuration data, \"Graphics\" for common graphics options,\n * and one or more sections for each plugin library. \n */\ntypedef m64p_error (*ptr_ConfigListSections)(void *, void (*)(void *, const char *));\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigListSections(void *, void (*)(void *, const char *));\n#endif\n\n/* ConfigOpenSection()\n *\n * This function is used to give a configuration section handle to the front-end\n * which may be used to read or write configuration parameter values in a given\n * section of the configuration file.\n */\ntypedef m64p_error (*ptr_ConfigOpenSection)(const char *, m64p_handle *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigOpenSection(const char *, m64p_handle *);\n#endif\n\n/* ConfigListParameters()\n *\n * This function is called to enumerate the list of Parameters in a given\n * Section of the Mupen64Plus configuration file. \n */\ntypedef m64p_error (*ptr_ConfigListParameters)(m64p_handle, void *, void (*)(void *, const char *, m64p_type));\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigListParameters(m64p_handle, void *, void (*)(void *, const char *, m64p_type));\n#endif\n\n/* ConfigSaveFile()\n *\n * This function saves the entire current Mupen64Plus configuration to disk.\n */\ntypedef m64p_error (*ptr_ConfigSaveFile)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigSaveFile(void);\n#endif\n\n/* ConfigSaveSection()\n *\n * This function saves one section of the current Mupen64Plus configuration to disk.\n */\ntypedef m64p_error (*ptr_ConfigSaveSection)(const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigSaveSection(const char *);\n#endif\n\n/* ConfigHasUnsavedChanges()\n *\n * This function determines if a given Section (or all sections) of the Mupen64Plus Core configuration file has been modified since it was last saved or loaded.\n */\ntypedef int (*ptr_ConfigHasUnsavedChanges)(const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT int CALL ConfigHasUnsavedChanges(const char *);\n#endif\n\n/* ConfigDeleteSection()\n *\n * This function deletes a section from the Mupen64Plus configuration data.\n */\ntypedef m64p_error (*ptr_ConfigDeleteSection)(const char *SectionName);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigDeleteSection(const char *SectionName);\n#endif\n\n/* ConfigRevertChanges()\n *\n * This function reverts changes previously made to one section of the configuration file, so that it will match with the configuration at the last time that it was loaded from or saved to disk.\n */\ntypedef m64p_error (*ptr_ConfigRevertChanges)(const char *SectionName);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigRevertChanges(const char *SectionName);\n#endif\n\n/* ConfigSetParameter()\n *\n * This function sets the value of one of the emulator's configuration\n * parameters.\n */\ntypedef m64p_error (*ptr_ConfigSetParameter)(m64p_handle, const char *, m64p_type, const void *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigSetParameter(m64p_handle, const char *, m64p_type, const void *);\n#endif\n\n/* ConfigSetParameterHelp()\n *\n * This function sets the help string of one of the emulator's configuration\n * parameters.\n */\ntypedef m64p_error (*ptr_ConfigSetParameterHelp)(m64p_handle, const char *, const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigSetParameterHelp(m64p_handle, const char *, const char *);\n#endif\n\n/* ConfigGetParameter()\n *\n * This function retrieves the value of one of the emulator's parameters. \n */\ntypedef m64p_error (*ptr_ConfigGetParameter)(m64p_handle, const char *, m64p_type, void *, int);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigGetParameter(m64p_handle, const char *, m64p_type, void *, int);\n#endif\n\n/* ConfigGetParameterType()\n *\n * This function retrieves the type of one of the emulator's parameters. \n */\ntypedef m64p_error (*ptr_ConfigGetParameterType)(m64p_handle, const char *, m64p_type *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigGetParameterType(m64p_handle, const char *, m64p_type *);\n#endif\n\n/* ConfigGetParameterHelp()\n *\n * This function retrieves the help information about one of the emulator's\n * parameters.\n */\ntypedef const char * (*ptr_ConfigGetParameterHelp)(m64p_handle, const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT const char * CALL ConfigGetParameterHelp(m64p_handle, const char *);\n#endif\n\n/* ConfigSetDefault***()\n *\n * These functions are used to set the value of a configuration parameter if it\n * is not already present in the configuration file. This may happen if a new\n * user runs the emulator, or an upgraded module uses a new parameter, or the\n * user deletes his or her configuration file. If the parameter is already\n * present in the given section of the configuration file, then no action will\n * be taken and this function will return successfully.\n */\ntypedef m64p_error (*ptr_ConfigSetDefaultInt)(m64p_handle, const char *, int, const char *);\ntypedef m64p_error (*ptr_ConfigSetDefaultFloat)(m64p_handle, const char *, float, const char *);\ntypedef m64p_error (*ptr_ConfigSetDefaultBool)(m64p_handle, const char *, int, const char *);\ntypedef m64p_error (*ptr_ConfigSetDefaultString)(m64p_handle, const char *, const char *, const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigSetDefaultInt(m64p_handle, const char *, int, const char *);\nEXPORT m64p_error CALL ConfigSetDefaultFloat(m64p_handle, const char *, float, const char *);\nEXPORT m64p_error CALL ConfigSetDefaultBool(m64p_handle, const char *, int, const char *);\nEXPORT m64p_error CALL ConfigSetDefaultString(m64p_handle, const char *, const char *, const char *);\n#endif\n\n/* ConfigGetParam***()\n *\n * These functions retrieve the value of one of the emulator's parameters in\n * the given section, and return the value directly to the calling function. If\n * an errors occurs (such as an invalid Section handle, or invalid\n * configuration parameter name), then an error will be sent to the front-end\n * via the DebugCallback() function, and either a 0 (zero) or an empty string\n * will be returned.\n */\ntypedef int          (*ptr_ConfigGetParamInt)(m64p_handle, const char *);\ntypedef float        (*ptr_ConfigGetParamFloat)(m64p_handle, const char *);\ntypedef int          (*ptr_ConfigGetParamBool)(m64p_handle, const char *);\ntypedef const char * (*ptr_ConfigGetParamString)(m64p_handle, const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT int          CALL ConfigGetParamInt(m64p_handle, const char *);\nEXPORT float        CALL ConfigGetParamFloat(m64p_handle, const char *);\nEXPORT int          CALL ConfigGetParamBool(m64p_handle, const char *);\nEXPORT const char * CALL ConfigGetParamString(m64p_handle, const char *);\n#endif\n\n/* ConfigGetSharedDataFilepath()\n *\n * This function is provided to allow a plugin to retrieve a full pathname to a\n * given shared data file. This type of file is intended to be shared among\n * multiple users on a system, so it is likely to be read-only.\n */\ntypedef const char * (*ptr_ConfigGetSharedDataFilepath)(const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT const char * CALL ConfigGetSharedDataFilepath(const char *);\n#endif\n\n/* ConfigGetUserConfigPath()\n *\n * This function may be used by the plugins or front-end to get a path to the\n * directory for storing user-specific configuration files. This will be the\n * directory where \"mupen64plus.cfg\" is located.\n */\ntypedef const char * (*ptr_ConfigGetUserConfigPath)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT const char * CALL ConfigGetUserConfigPath(void);\n#endif\n\n/* ConfigGetUserDataPath()\n *\n * This function may be used by the plugins or front-end to get a path to the\n * directory for storing user-specific data files. This may be used to store\n * files such as screenshots, saved game states, or hi-res textures.\n */\ntypedef const char * (*ptr_ConfigGetUserDataPath)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT const char * CALL ConfigGetUserDataPath(void);\n#endif\n\n/* ConfigGetUserCachePath()\n *\n * This function may be used by the plugins or front-end to get a path to the\n * directory for storing cached user-specific data files. Files in this\n * directory may be deleted by the user to save space, so critical information\n * should not be stored here.  This directory may be used to store files such\n * as the ROM browser cache.\n */\ntypedef const char * (*ptr_ConfigGetUserCachePath)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT const char * CALL ConfigGetUserCachePath(void);\n#endif\n\n/* ConfigExternalOpen()\n *\n * This function reads the contents of the config file into memory\n * and returns M64ERR_SUCCESS if successful.\n */\ntypedef m64p_error (*ptr_ConfigExternalOpen)(const char *, m64p_handle *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigExternalOpen(const char *, m64p_handle *);\n#endif\n\n/* ConfigExternalClose()\n *\n * Frees the memory pointer created by ConfigExternalOpen.\n */\ntypedef m64p_error (*ptr_ConfigExternalClose)(m64p_handle);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigExternalClose(m64p_handle);\n#endif\n\n/* ConfigExternalGetParameter()\n *\n * This functions allows a plugin to leverage the built-in ini parser to read\n * any cfg/ini file. It will return M64ERR_SUCCESS if the item was found.\n */\ntypedef m64p_error (*ptr_ConfigExternalGetParameter)(m64p_handle, const char *, const char *, char *, int);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL ConfigExternalGetParameter(m64p_handle, const char *, const char *, char *, int);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* #define M64P_CONFIG_H */\n"
  },
  {
    "path": "src/plugin/mupen64plus/api/m64p_plugin.h",
    "content": "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *   Mupen64plus-core - m64p_plugin.h                                      *\n *   Mupen64Plus homepage: https://mupen64plus.org/                        *\n *   Copyright (C) 2002 Hacktarux                                          *\n *   Copyright (C) 2009 Richard Goedeken                                   *\n *                                                                         *\n *   This program is free software; you can redistribute it and/or modify  *\n *   it under the terms of the GNU General Public License as published by  *\n *   the Free Software Foundation; either version 2 of the License, or     *\n *   (at your option) any later version.                                   *\n *                                                                         *\n *   This program is distributed in the hope that it will be useful,       *\n *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\n *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\n *   GNU General Public License for more details.                          *\n *                                                                         *\n *   You should have received a copy of the GNU General Public License     *\n *   along with this program; if not, write to the                         *\n *   Free Software Foundation, Inc.,                                       *\n *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n#if !defined(M64P_PLUGIN_H)\n#define M64P_PLUGIN_H\n\n#include \"m64p_types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*** Controller plugin's ****/\n#define PLUGIN_NONE                 1\n#define PLUGIN_MEMPAK               2\n#define PLUGIN_RUMBLE_PAK           3 /* not implemented for non raw data */\n#define PLUGIN_TRANSFER_PAK         4 /* not implemented for non raw data */\n#define PLUGIN_RAW                  5 /* the controller plugin is passed in raw data */\n#define PLUGIN_BIO_PAK              6\n\n/***** Structures *****/\ntypedef struct {\n    unsigned char * RDRAM;\n    unsigned char * DMEM;\n    unsigned char * IMEM;\n\n    unsigned int * MI_INTR_REG;\n\n    unsigned int * SP_MEM_ADDR_REG;\n    unsigned int * SP_DRAM_ADDR_REG;\n    unsigned int * SP_RD_LEN_REG;\n    unsigned int * SP_WR_LEN_REG;\n    unsigned int * SP_STATUS_REG;\n    unsigned int * SP_DMA_FULL_REG;\n    unsigned int * SP_DMA_BUSY_REG;\n    unsigned int * SP_PC_REG;\n    unsigned int * SP_SEMAPHORE_REG;\n\n    unsigned int * DPC_START_REG;\n    unsigned int * DPC_END_REG;\n    unsigned int * DPC_CURRENT_REG;\n    unsigned int * DPC_STATUS_REG;\n    unsigned int * DPC_CLOCK_REG;\n    unsigned int * DPC_BUFBUSY_REG;\n    unsigned int * DPC_PIPEBUSY_REG;\n    unsigned int * DPC_TMEM_REG;\n\n    void (*CheckInterrupts)(void);\n    void (*ProcessDlistList)(void);\n    void (*ProcessAlistList)(void);\n    void (*ProcessRdpList)(void);\n    void (*ShowCFB)(void);\n} RSP_INFO;\n\ntypedef struct {\n    unsigned char * HEADER;  /* This is the rom header (first 40h bytes of the rom) */\n    unsigned char * RDRAM;\n    unsigned char * DMEM;\n    unsigned char * IMEM;\n\n    unsigned int * MI_INTR_REG;\n\n    unsigned int * DPC_START_REG;\n    unsigned int * DPC_END_REG;\n    unsigned int * DPC_CURRENT_REG;\n    unsigned int * DPC_STATUS_REG;\n    unsigned int * DPC_CLOCK_REG;\n    unsigned int * DPC_BUFBUSY_REG;\n    unsigned int * DPC_PIPEBUSY_REG;\n    unsigned int * DPC_TMEM_REG;\n\n    unsigned int * VI_STATUS_REG;\n    unsigned int * VI_ORIGIN_REG;\n    unsigned int * VI_WIDTH_REG;\n    unsigned int * VI_INTR_REG;\n    unsigned int * VI_V_CURRENT_LINE_REG;\n    unsigned int * VI_TIMING_REG;\n    unsigned int * VI_V_SYNC_REG;\n    unsigned int * VI_H_SYNC_REG;\n    unsigned int * VI_LEAP_REG;\n    unsigned int * VI_H_START_REG;\n    unsigned int * VI_V_START_REG;\n    unsigned int * VI_V_BURST_REG;\n    unsigned int * VI_X_SCALE_REG;\n    unsigned int * VI_Y_SCALE_REG;\n\n    void (*CheckInterrupts)(void);\n\n    /* The GFX_INFO.version parameter was added in version 2.5.1 of the core.\n       Plugins should ensure the core is at least this version before\n       attempting to read GFX_INFO.version. */\n    unsigned int version;\n    /* SP_STATUS_REG and RDRAM_SIZE were added in version 2 of GFX_INFO.version.\n       Plugins should only attempt to read these values if GFX_INFO.version is at least 2. */\n\n    /* The RSP plugin should set (HALT | BROKE | TASKDONE) *before* calling ProcessDList.\n       It should not modify SP_STATUS_REG after ProcessDList has returned.\n       This will allow the GFX plugin to unset these bits if it needs. */\n    unsigned int * SP_STATUS_REG;\n    const unsigned int * RDRAM_SIZE;\n} GFX_INFO;\n\ntypedef struct {\n    unsigned char * RDRAM;\n    unsigned char * DMEM;\n    unsigned char * IMEM;\n\n    unsigned int * MI_INTR_REG;\n\n    unsigned int * AI_DRAM_ADDR_REG;\n    unsigned int * AI_LEN_REG;\n    unsigned int * AI_CONTROL_REG;\n    unsigned int * AI_STATUS_REG;\n    unsigned int * AI_DACRATE_REG;\n    unsigned int * AI_BITRATE_REG;\n\n    void (*CheckInterrupts)(void);\n} AUDIO_INFO;\n\ntypedef struct {\n    int Present;\n    int RawData;\n    int Plugin;\n} CONTROL;\n\ntypedef union {\n    unsigned int Value;\n    struct {\n        unsigned R_DPAD       : 1;\n        unsigned L_DPAD       : 1;\n        unsigned D_DPAD       : 1;\n        unsigned U_DPAD       : 1;\n        unsigned START_BUTTON : 1;\n        unsigned Z_TRIG       : 1;\n        unsigned B_BUTTON     : 1;\n        unsigned A_BUTTON     : 1;\n\n        unsigned R_CBUTTON    : 1;\n        unsigned L_CBUTTON    : 1;\n        unsigned D_CBUTTON    : 1;\n        unsigned U_CBUTTON    : 1;\n        unsigned R_TRIG       : 1;\n        unsigned L_TRIG       : 1;\n        unsigned Reserved1    : 1;\n        unsigned Reserved2    : 1;\n\n        signed   X_AXIS       : 8;\n        signed   Y_AXIS       : 8;\n    };\n} BUTTONS;\n\ntypedef struct {\n    CONTROL *Controls;      /* A pointer to an array of 4 controllers .. eg:\n                               CONTROL Controls[4]; */\n} CONTROL_INFO;\n\n/* common plugin function pointer types */\ntypedef void (*ptr_RomClosed)(void);\ntypedef int  (*ptr_RomOpen)(void);\n#if defined(M64P_PLUGIN_PROTOTYPES)\nEXPORT int  CALL RomOpen(void);\nEXPORT void CALL RomClosed(void);\n#endif\n\n/* video plugin function pointer types */\ntypedef void (*ptr_ChangeWindow)(void);\ntypedef int  (*ptr_InitiateGFX)(GFX_INFO Gfx_Info);\ntypedef void (*ptr_MoveScreen)(int x, int y);\ntypedef void (*ptr_ProcessDList)(void);\ntypedef void (*ptr_ProcessRDPList)(void);\ntypedef void (*ptr_ShowCFB)(void);\ntypedef void (*ptr_UpdateScreen)(void);\ntypedef void (*ptr_ViStatusChanged)(void);\ntypedef void (*ptr_ViWidthChanged)(void);\ntypedef void (*ptr_ReadScreen2)(void *dest, int *width, int *height, int front);\ntypedef void (*ptr_SetRenderingCallback)(void (*callback)(int));\ntypedef void (*ptr_ResizeVideoOutput)(int width, int height);\n#if defined(M64P_PLUGIN_PROTOTYPES)\nEXPORT void CALL ChangeWindow(void);\nEXPORT int  CALL InitiateGFX(GFX_INFO Gfx_Info);\nEXPORT void CALL MoveScreen(int x, int y);\nEXPORT void CALL ProcessDList(void);\nEXPORT void CALL ProcessRDPList(void);\nEXPORT void CALL ShowCFB(void);\nEXPORT void CALL UpdateScreen(void);\nEXPORT void CALL ViStatusChanged(void);\nEXPORT void CALL ViWidthChanged(void);\nEXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front);\nEXPORT void CALL SetRenderingCallback(void (*callback)(int));\nEXPORT void CALL ResizeVideoOutput(int width, int height);\n#endif\n\n/* frame buffer plugin spec extension */\ntypedef struct\n{\n   unsigned int addr;\n   unsigned int size;\n   unsigned int width;\n   unsigned int height;\n} FrameBufferInfo;\ntypedef void (*ptr_FBRead)(unsigned int addr);\ntypedef void (*ptr_FBWrite)(unsigned int addr, unsigned int size);\ntypedef void (*ptr_FBGetFrameBufferInfo)(void *p);\n#if defined(M64P_PLUGIN_PROTOTYPES)\nEXPORT void CALL FBRead(unsigned int addr);\nEXPORT void CALL FBWrite(unsigned int addr, unsigned int size);\nEXPORT void CALL FBGetFrameBufferInfo(void *p);\n#endif\n\n/* audio plugin function pointers */\ntypedef void (*ptr_AiDacrateChanged)(int SystemType);\ntypedef void (*ptr_AiLenChanged)(void);\ntypedef int  (*ptr_InitiateAudio)(AUDIO_INFO Audio_Info);\ntypedef void (*ptr_ProcessAList)(void);\ntypedef void (*ptr_SetSpeedFactor)(int percent);\ntypedef void (*ptr_VolumeUp)(void);\ntypedef void (*ptr_VolumeDown)(void);\ntypedef int  (*ptr_VolumeGetLevel)(void);\ntypedef void (*ptr_VolumeSetLevel)(int level);\ntypedef void (*ptr_VolumeMute)(void);\ntypedef const char * (*ptr_VolumeGetString)(void);\n#if defined(M64P_PLUGIN_PROTOTYPES)\nEXPORT void CALL AiDacrateChanged(int SystemType);\nEXPORT void CALL AiLenChanged(void);\nEXPORT int  CALL InitiateAudio(AUDIO_INFO Audio_Info);\nEXPORT void CALL ProcessAList(void);\nEXPORT void CALL SetSpeedFactor(int percent);\nEXPORT void CALL VolumeUp(void);\nEXPORT void CALL VolumeDown(void);\nEXPORT int  CALL VolumeGetLevel(void);\nEXPORT void CALL VolumeSetLevel(int level);\nEXPORT void CALL VolumeMute(void);\nEXPORT const char * CALL VolumeGetString(void);\n#endif\n\n/* input plugin function pointers */\ntypedef void (*ptr_ControllerCommand)(int Control, unsigned char *Command);\ntypedef void (*ptr_GetKeys)(int Control, BUTTONS *Keys);\ntypedef void (*ptr_InitiateControllers)(CONTROL_INFO ControlInfo);\ntypedef void (*ptr_ReadController)(int Control, unsigned char *Command);\ntypedef void (*ptr_SDL_KeyDown)(int keymod, int keysym);\ntypedef void (*ptr_SDL_KeyUp)(int keymod, int keysym);\ntypedef void (*ptr_RenderCallback)(void);\n#if defined(M64P_PLUGIN_PROTOTYPES)\nEXPORT void CALL ControllerCommand(int Control, unsigned char *Command);\nEXPORT void CALL GetKeys(int Control, BUTTONS *Keys);\nEXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo);\nEXPORT void CALL ReadController(int Control, unsigned char *Command);\nEXPORT void CALL SDL_KeyDown(int keymod, int keysym);\nEXPORT void CALL SDL_KeyUp(int keymod, int keysym);\nEXPORT void CALL RenderCallback(void);\n#endif\n\n/* RSP plugin function pointers */\ntypedef unsigned int (*ptr_DoRspCycles)(unsigned int Cycles);\ntypedef void (*ptr_InitiateRSP)(RSP_INFO Rsp_Info, unsigned int *CycleCount);\n#if defined(M64P_PLUGIN_PROTOTYPES)\nEXPORT unsigned int CALL DoRspCycles(unsigned int Cycles);\nEXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, unsigned int *CycleCount);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* M64P_PLUGIN_H */\n\n\n"
  },
  {
    "path": "src/plugin/mupen64plus/api/m64p_types.h",
    "content": "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *   Mupen64plus-core - m64p_types.h                                       *\n *   Mupen64Plus homepage: https://mupen64plus.org/                        *\n *   Copyright (C) 2012 CasualJames                                        *\n *   Copyright (C) 2009 Richard Goedeken                                   *\n *                                                                         *\n *   This program is free software; you can redistribute it and/or modify  *\n *   it under the terms of the GNU General Public License as published by  *\n *   the Free Software Foundation; either version 2 of the License, or     *\n *   (at your option) any later version.                                   *\n *                                                                         *\n *   This program is distributed in the hope that it will be useful,       *\n *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\n *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\n *   GNU General Public License for more details.                          *\n *                                                                         *\n *   You should have received a copy of the GNU General Public License     *\n *   along with this program; if not, write to the                         *\n *   Free Software Foundation, Inc.,                                       *\n *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n#if !defined(M64P_TYPES_H)\n#define M64P_TYPES_H\n\n/* ----------------------------------------- */\n/* Platform-specific stuff                   */\n/* ----------------------------------------- */\n\n/* necessary headers */\n#include <stdint.h>\n#if defined(WIN32)\n  #include <windows.h>\n#endif\n\n/* DLL handles and function declaration specifiers */\n#if defined(WIN32)\n  #define IMPORT extern \"C\" __declspec(dllimport)\n  #define EXPORT __declspec(dllexport)\n  #define CALL   __cdecl\n  typedef HMODULE m64p_dynlib_handle;\n#else\n  #define IMPORT extern \"C\"\n  #define EXPORT __attribute__((visibility(\"default\")))\n  #define CALL\n  typedef void * m64p_dynlib_handle;\n#endif\n\n/* ----------------------------------------- */\n/* Structures and Types for Core library API */\n/* ----------------------------------------- */\n\ntypedef void * m64p_handle;\n\n/* Generic function pointer returned from osal_dynlib_getproc (and the like)\n * Don't use it directly, cast to proper type before using it.\n */\ntypedef void (*m64p_function)(void);\n\ntypedef void (*m64p_frame_callback)(unsigned int FrameIndex);\ntypedef void (*m64p_input_callback)(void);\ntypedef void (*m64p_audio_callback)(void);\ntypedef void (*m64p_vi_callback)(void);\n\ntypedef enum {\n  M64TYPE_INT = 1,\n  M64TYPE_FLOAT,\n  M64TYPE_BOOL,\n  M64TYPE_STRING\n} m64p_type;\n\ntypedef enum {\n  M64MSG_ERROR = 1,\n  M64MSG_WARNING,\n  M64MSG_INFO,\n  M64MSG_STATUS,\n  M64MSG_VERBOSE\n} m64p_msg_level;\n\ntypedef enum {\n  M64ERR_SUCCESS = 0,\n  M64ERR_NOT_INIT,        /* Function is disallowed before InitMupen64Plus() is called */\n  M64ERR_ALREADY_INIT,    /* InitMupen64Plus() was called twice */\n  M64ERR_INCOMPATIBLE,    /* API versions between components are incompatible */\n  M64ERR_INPUT_ASSERT,    /* Invalid parameters for function call, such as ParamValue=NULL for GetCoreParameter() */\n  M64ERR_INPUT_INVALID,   /* Invalid input data, such as ParamValue=\"maybe\" for SetCoreParameter() to set a BOOL-type value */\n  M64ERR_INPUT_NOT_FOUND, /* The input parameter(s) specified a particular item which was not found */\n  M64ERR_NO_MEMORY,       /* Memory allocation failed */\n  M64ERR_FILES,           /* Error opening, creating, reading, or writing to a file */\n  M64ERR_INTERNAL,        /* Internal error (bug) */\n  M64ERR_INVALID_STATE,   /* Current program state does not allow operation */\n  M64ERR_PLUGIN_FAIL,     /* A plugin function returned a fatal error */\n  M64ERR_SYSTEM_FAIL,     /* A system function call, such as an SDL or file operation, failed */\n  M64ERR_UNSUPPORTED,     /* Function call is not supported (ie, core not built with debugger) */\n  M64ERR_WRONG_TYPE       /* A given input type parameter cannot be used for desired operation */\n} m64p_error;\n\ntypedef enum {\n  M64CAPS_DYNAREC = 1,\n  M64CAPS_DEBUGGER = 2,\n  M64CAPS_CORE_COMPARE = 4\n} m64p_core_caps;\n\ntypedef enum {\n  M64PLUGIN_NULL = 0,\n  M64PLUGIN_RSP = 1,\n  M64PLUGIN_GFX,\n  M64PLUGIN_AUDIO,\n  M64PLUGIN_INPUT,\n  M64PLUGIN_CORE\n} m64p_plugin_type;\n\ntypedef enum {\n  M64EMU_STOPPED = 1,\n  M64EMU_RUNNING,\n  M64EMU_PAUSED\n} m64p_emu_state;\n\ntypedef enum {\n  M64VIDEO_NONE = 1,\n  M64VIDEO_WINDOWED,\n  M64VIDEO_FULLSCREEN\n} m64p_video_mode;\n\ntypedef enum {\n  M64VIDEOFLAG_SUPPORT_RESIZING = 1\n} m64p_video_flags;\n\ntypedef enum {\n  M64CORE_EMU_STATE = 1,\n  M64CORE_VIDEO_MODE,\n  M64CORE_SAVESTATE_SLOT,\n  M64CORE_SPEED_FACTOR,\n  M64CORE_SPEED_LIMITER,\n  M64CORE_VIDEO_SIZE,\n  M64CORE_AUDIO_VOLUME,\n  M64CORE_AUDIO_MUTE,\n  M64CORE_INPUT_GAMESHARK,\n  M64CORE_STATE_LOADCOMPLETE,\n  M64CORE_STATE_SAVECOMPLETE\n} m64p_core_param;\n\ntypedef enum {\n  M64CMD_NOP = 0,\n  M64CMD_ROM_OPEN,\n  M64CMD_ROM_CLOSE,\n  M64CMD_ROM_GET_HEADER,\n  M64CMD_ROM_GET_SETTINGS,\n  M64CMD_EXECUTE,\n  M64CMD_STOP,\n  M64CMD_PAUSE,\n  M64CMD_RESUME,\n  M64CMD_CORE_STATE_QUERY,\n  M64CMD_STATE_LOAD,\n  M64CMD_STATE_SAVE,\n  M64CMD_STATE_SET_SLOT,\n  M64CMD_SEND_SDL_KEYDOWN,\n  M64CMD_SEND_SDL_KEYUP,\n  M64CMD_SET_FRAME_CALLBACK,\n  M64CMD_TAKE_NEXT_SCREENSHOT,\n  M64CMD_CORE_STATE_SET,\n  M64CMD_READ_SCREEN,\n  M64CMD_RESET,\n  M64CMD_ADVANCE_FRAME,\n  M64CMD_SET_MEDIA_LOADER\n} m64p_command;\n\ntypedef struct {\n  uint32_t address;\n  int      value;\n} m64p_cheat_code;\n\ntypedef struct {\n  /* Frontend-defined callback data. */\n  void* cb_data;\n\n  /* Allow the frontend to specify the GB cart ROM file to load\n   * cb_data: points to frontend-defined callback data.\n   * controller_num: (0-3) tell the frontend which controller is about to load a GB cart\n   * Returns a NULL-terminated string owned by the core specifying the GB cart ROM filename to load.\n   * Empty or NULL string results in no GB cart being loaded (eg. empty transferpak).\n   */\n  char* (*get_gb_cart_rom)(void* cb_data, int controller_num);\n\n  /* Allow the frontend to specify the GB cart RAM file to load\n   * cb_data: points to frontend-defined callback data.\n   * controller_num: (0-3) tell the frontend which controller is about to load a GB cart\n   * Returns a NULL-terminated string owned by the core specifying the GB cart RAM filename to load\n   * Empty or NULL string results in the core generating a default save file with empty content.\n   */\n  char* (*get_gb_cart_ram)(void* cb_data, int controller_num);\n\n  /* Allow the frontend to specify the DD IPL ROM file to load\n   * cb_data: points to frontend-defined callback data.\n   * Returns a NULL-terminated string owned by the core specifying the DD IPL ROM filename to load\n   * Empty or NULL string results in disabled 64DD.\n   */\n  char* (*get_dd_rom)(void* cb_data);\n\n  /* Allow the frontend to specify the DD disk file to load\n   * cb_data: points to frontend-defined callback data.\n   * Returns a NULL-terminated string owned by the core specifying the DD disk filename to load\n   * Empty or NULL string results in no DD disk being loaded (eg. empty disk drive).\n   */\n  char* (*get_dd_disk)(void* cb_data);\n} m64p_media_loader;\n\n/* ----------------------------------------- */\n/* Structures to hold ROM image information  */\n/* ----------------------------------------- */\n\ntypedef enum\n{\n    SYSTEM_NTSC = 0,\n    SYSTEM_PAL,\n    SYSTEM_MPAL\n} m64p_system_type;\n\ntypedef struct\n{\n   uint8_t  init_PI_BSB_DOM1_LAT_REG;  /* 0x00 */\n   uint8_t  init_PI_BSB_DOM1_PGS_REG;  /* 0x01 */\n   uint8_t  init_PI_BSB_DOM1_PWD_REG;  /* 0x02 */\n   uint8_t  init_PI_BSB_DOM1_PGS_REG2; /* 0x03 */\n   uint32_t ClockRate;                 /* 0x04 */\n   uint32_t PC;                        /* 0x08 */\n   uint32_t Release;                   /* 0x0C */\n   uint32_t CRC1;                      /* 0x10 */\n   uint32_t CRC2;                      /* 0x14 */\n   uint32_t Unknown[2];                /* 0x18 */\n   uint8_t  Name[20];                  /* 0x20 */\n   uint32_t unknown;                   /* 0x34 */\n   uint32_t Manufacturer_ID;           /* 0x38 */\n   uint16_t Cartridge_ID;              /* 0x3C - Game serial number  */\n   uint16_t Country_code;              /* 0x3E */\n} m64p_rom_header;\n\ntypedef struct\n{\n   char goodname[256];\n   char MD5[33];\n   unsigned char savetype;\n   unsigned char status;  /* Rom status on a scale from 0-5. */\n   unsigned char players; /* Local players 0-4, 2/3/4 way Netplay indicated by 5/6/7. */\n   unsigned char rumble;  /* 0 - No, 1 - Yes boolean for rumble support. */\n   unsigned char transferpak; /* 0 - No, 1 - Yes boolean for transfer pak support. */\n   unsigned char mempak; /* 0 - No, 1 - Yes boolean for memory pak support. */\n   unsigned char biopak; /* 0 - No, 1 - Yes boolean for bio pak support. */\n} m64p_rom_settings;\n\n/* ----------------------------------------- */\n/* Structures and Types for the Debugger     */\n/* ----------------------------------------- */\n\ntypedef enum {\n  M64P_DBG_RUN_STATE = 1,\n  M64P_DBG_PREVIOUS_PC,\n  M64P_DBG_NUM_BREAKPOINTS,\n  M64P_DBG_CPU_DYNACORE,\n  M64P_DBG_CPU_NEXT_INTERRUPT\n} m64p_dbg_state;\n\ntypedef enum {\n  M64P_DBG_RUNSTATE_PAUSED = 0,\n  M64P_DBG_RUNSTATE_STEPPING,\n  M64P_DBG_RUNSTATE_RUNNING\n} m64p_dbg_runstate;\n\ntypedef enum {\n  M64P_DBG_MEM_TYPE = 1,\n  M64P_DBG_MEM_FLAGS,\n  M64P_DBG_MEM_HAS_RECOMPILED,\n  M64P_DBG_MEM_NUM_RECOMPILED,\n  M64P_DBG_RECOMP_OPCODE = 16,\n  M64P_DBG_RECOMP_ARGS,\n  M64P_DBG_RECOMP_ADDR\n} m64p_dbg_mem_info;\n\ntypedef enum {\n  M64P_MEM_NOMEM = 0,\n  M64P_MEM_NOTHING,\n  M64P_MEM_RDRAM,\n  M64P_MEM_RDRAMREG,\n  M64P_MEM_RSPMEM,\n  M64P_MEM_RSPREG,\n  M64P_MEM_RSP,\n  M64P_MEM_DP,\n  M64P_MEM_DPS,\n  M64P_MEM_VI,\n  M64P_MEM_AI,\n  M64P_MEM_PI,\n  M64P_MEM_RI,\n  M64P_MEM_SI,\n  M64P_MEM_FLASHRAMSTAT,\n  M64P_MEM_ROM,\n  M64P_MEM_PIF,\n  M64P_MEM_MI,\n  M64P_MEM_BREAKPOINT\n} m64p_dbg_mem_type;\n\ntypedef enum {\n  M64P_MEM_FLAG_READABLE = 0x01,\n  M64P_MEM_FLAG_WRITABLE = 0x02,\n  M64P_MEM_FLAG_READABLE_EMUONLY = 0x04,  /* the EMUONLY flags signify that emulated code can read/write here, but debugger cannot */\n  M64P_MEM_FLAG_WRITABLE_EMUONLY = 0x08\n} m64p_dbg_mem_flags;\n\ntypedef enum {\n  M64P_DBG_PTR_RDRAM = 1,\n  M64P_DBG_PTR_PI_REG,\n  M64P_DBG_PTR_SI_REG,\n  M64P_DBG_PTR_VI_REG,\n  M64P_DBG_PTR_RI_REG,\n  M64P_DBG_PTR_AI_REG\n} m64p_dbg_memptr_type;\n\ntypedef enum {\n  M64P_CPU_PC = 1,\n  M64P_CPU_REG_REG,\n  M64P_CPU_REG_HI,\n  M64P_CPU_REG_LO,\n  M64P_CPU_REG_COP0,\n  M64P_CPU_REG_COP1_DOUBLE_PTR,\n  M64P_CPU_REG_COP1_SIMPLE_PTR,\n  M64P_CPU_REG_COP1_FGR_64,\n  M64P_CPU_TLB\n} m64p_dbg_cpu_data;\n\ntypedef enum {\n  M64P_BKP_CMD_ADD_ADDR = 1,\n  M64P_BKP_CMD_ADD_STRUCT,\n  M64P_BKP_CMD_REPLACE,\n  M64P_BKP_CMD_REMOVE_ADDR,\n  M64P_BKP_CMD_REMOVE_IDX,\n  M64P_BKP_CMD_ENABLE,\n  M64P_BKP_CMD_DISABLE,\n  M64P_BKP_CMD_CHECK\n} m64p_dbg_bkp_command;\n\n#define M64P_MEM_INVALID        0xFFFFFFFF  /* invalid memory read will return this */\n\n#define BREAKPOINTS_MAX_NUMBER  128\n\ntypedef enum {\n  M64P_BKP_FLAG_ENABLED = 0x01,\n  M64P_BKP_FLAG_READ = 0x02,\n  M64P_BKP_FLAG_WRITE = 0x04,\n  M64P_BKP_FLAG_EXEC = 0x08,\n  M64P_BKP_FLAG_LOG = 0x10 /* Log to the console when this breakpoint hits */\n} m64p_dbg_bkp_flags;\n\n#define BPT_CHECK_FLAG(a, b)  ((a.flags & b) == b)\n#define BPT_SET_FLAG(a, b)    a.flags = (a.flags | b);\n#define BPT_CLEAR_FLAG(a, b)  a.flags = (a.flags & (~b));\n#define BPT_TOGGLE_FLAG(a, b) a.flags = (a.flags ^ b);\n\ntypedef struct {\n  uint32_t     address;\n  uint32_t     endaddr;\n  unsigned int flags;\n} m64p_breakpoint;\n\n/* ------------------------------------------------- */\n/* Structures and Types for Core Video Extension API */\n/* ------------------------------------------------- */\n\ntypedef struct {\n  unsigned int uiWidth;\n  unsigned int uiHeight;\n} m64p_2d_size;\n\ntypedef enum {\n  M64P_GL_DOUBLEBUFFER = 1,\n  M64P_GL_BUFFER_SIZE,\n  M64P_GL_DEPTH_SIZE,\n  M64P_GL_RED_SIZE,\n  M64P_GL_GREEN_SIZE,\n  M64P_GL_BLUE_SIZE,\n  M64P_GL_ALPHA_SIZE,\n  M64P_GL_SWAP_CONTROL,\n  M64P_GL_MULTISAMPLEBUFFERS,\n  M64P_GL_MULTISAMPLESAMPLES,\n  M64P_GL_CONTEXT_MAJOR_VERSION,\n  M64P_GL_CONTEXT_MINOR_VERSION,\n  M64P_GL_CONTEXT_PROFILE_MASK\n} m64p_GLattr;\n\ntypedef enum {\n  M64P_GL_CONTEXT_PROFILE_CORE,\n  M64P_GL_CONTEXT_PROFILE_COMPATIBILITY,\n  M64P_GL_CONTEXT_PROFILE_ES\n} m64p_GLContextType;\n\ntypedef struct {\n  unsigned int Functions;\n  m64p_error    (*VidExtFuncInit)(void);\n  m64p_error    (*VidExtFuncQuit)(void);\n  m64p_error    (*VidExtFuncListModes)(m64p_2d_size *, int *);\n  m64p_error    (*VidExtFuncSetMode)(int, int, int, int, int);\n  m64p_function (*VidExtFuncGLGetProc)(const char*);\n  m64p_error    (*VidExtFuncGLSetAttr)(m64p_GLattr, int);\n  m64p_error    (*VidExtFuncGLGetAttr)(m64p_GLattr, int *);\n  m64p_error    (*VidExtFuncGLSwapBuf)(void);\n  m64p_error    (*VidExtFuncSetCaption)(const char *);\n  m64p_error    (*VidExtFuncToggleFS)(void);\n  m64p_error    (*VidExtFuncResizeWindow)(int, int);\n  uint32_t      (*VidExtFuncGLGetDefaultFramebuffer)(void);\n} m64p_video_extension_functions;\n\n#endif /* define M64P_TYPES_H */\n\n"
  },
  {
    "path": "src/plugin/mupen64plus/api/m64p_vidext.h",
    "content": "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *   Mupen64plus-core - m64p_vidext.h                                      *\n *   Mupen64Plus homepage: https://mupen64plus.org/                        *\n *   Copyright (C) 2009 Richard Goedeken                                   *\n *                                                                         *\n *   This program is free software; you can redistribute it and/or modify  *\n *   it under the terms of the GNU General Public License as published by  *\n *   the Free Software Foundation; either version 2 of the License, or     *\n *   (at your option) any later version.                                   *\n *                                                                         *\n *   This program is distributed in the hope that it will be useful,       *\n *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\n *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\n *   GNU General Public License for more details.                          *\n *                                                                         *\n *   You should have received a copy of the GNU General Public License     *\n *   along with this program; if not, write to the                         *\n *   Free Software Foundation, Inc.,                                       *\n *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n/* This header file defines typedefs for function pointers to the core's\n * video extension functions.\n */\n\n#if !defined(M64P_VIDEXT_H)\n#define M64P_VIDEXT_H\n\n#include \"m64p_types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* VidExt_Init()\n *\n * This function should be called from within the InitiateGFX() video plugin\n * function call. The default SDL implementation of this function simply calls\n * SDL_InitSubSystem(SDL_INIT_VIDEO). It does not open a rendering window or\n * switch video modes.\n */\ntypedef m64p_error (*ptr_VidExt_Init)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_Init(void);\n#endif\n\n/* VidExt_Quit()\n *\n * This function closes any open rendering window and shuts down the video\n * system. The default SDL implementation of this function calls\n * SDL_QuitSubSystem(SDL_INIT_VIDEO). This function should be called from\n * within the RomClose() video plugin function.\n */\ntypedef m64p_error (*ptr_VidExt_Quit)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_Quit(void);\n#endif\n\n/* VidExt_ListFullscreenModes()\n *\n * This function is used to enumerate the available resolutions for fullscreen\n * video modes. A pointer to an array is passed into the function, which is\n * then filled with resolution sizes.\n */\ntypedef m64p_error (*ptr_VidExt_ListFullscreenModes)(m64p_2d_size *, int *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_ListFullscreenModes(m64p_2d_size *, int *);\n#endif\n\n/* VidExt_SetVideoMode()\n *\n * This function creates a rendering window or switches into a fullscreen\n * video mode. Any desired OpenGL attributes should be set before calling\n * this function.\n */\ntypedef m64p_error (*ptr_VidExt_SetVideoMode)(int, int, int, m64p_video_mode, m64p_video_flags);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_SetVideoMode(int, int, int, m64p_video_mode, m64p_video_flags);\n#endif\n\n/* VidExt_ResizeWindow()\n *\n * This function resizes the opengl rendering window to match the given size.\n */\ntypedef m64p_error (*ptr_VidExt_ResizeWindow)(int, int);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_ResizeWindow(int, int);\n#endif\n\n/* VidExt_SetCaption()\n *\n * This function sets the caption text of the emulator rendering window.\n */\ntypedef m64p_error (*ptr_VidExt_SetCaption)(const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_SetCaption(const char *);\n#endif\n\n/* VidExt_ToggleFullScreen()\n *\n * This function toggles between fullscreen and windowed rendering modes.\n */\ntypedef m64p_error (*ptr_VidExt_ToggleFullScreen)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_ToggleFullScreen(void);\n#endif\n\n/* VidExt_GL_GetProcAddress()\n *\n * This function is used to get a pointer to an OpenGL extension function. This\n * is only necessary on the Windows platform, because the OpenGL implementation\n * shipped with Windows only supports OpenGL version 1.1.\n */\ntypedef m64p_function (*ptr_VidExt_GL_GetProcAddress)(const char *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_function CALL VidExt_GL_GetProcAddress(const char *);\n#endif\n\n/* VidExt_GL_SetAttribute()\n *\n * This function is used to set certain OpenGL attributes which must be\n * specified before creating the rendering window with VidExt_SetVideoMode.\n */\ntypedef m64p_error (*ptr_VidExt_GL_SetAttribute)(m64p_GLattr, int);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_GL_SetAttribute(m64p_GLattr, int);\n#endif\n\n/* VidExt_GL_GetAttribute()\n *\n * This function is used to get the value of OpenGL attributes.  These values may\n * be changed when calling VidExt_SetVideoMode.\n */\ntypedef m64p_error (*ptr_VidExt_GL_GetAttribute)(m64p_GLattr, int *);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_GL_GetAttribute(m64p_GLattr, int *);\n#endif\n\n/* VidExt_GL_SwapBuffers()\n *\n * This function is used to swap the front/back buffers after rendering an\n * output video frame.\n */\ntypedef m64p_error (*ptr_VidExt_GL_SwapBuffers)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT m64p_error CALL VidExt_GL_SwapBuffers(void);\n#endif\n\n/* VidExt_GL_GetDefaultFramebuffer()\n *\n * On some platforms (for instance, iOS) the default framebuffer object\n * depends on the surface being rendered to, and might be different from 0.\n * This function should be called after VidExt_SetVideoMode to retrieve the\n * name of the default FBO.\n * Calling this function may have performance implications\n * and it should not be called every time the default FBO is bound.\n */\ntypedef uint32_t (*ptr_VidExt_GL_GetDefaultFramebuffer)(void);\n#if defined(M64P_CORE_PROTOTYPES)\nEXPORT uint32_t CALL VidExt_GL_GetDefaultFramebuffer(void);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* #define M64P_VIDEXT_H */\n\n"
  },
  {
    "path": "src/plugin/mupen64plus/gfx_m64p.c",
    "content": "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *   Mupen64plus-video-angrylionplus - plugin.c                            *\n *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *\n *   Copyright (C) 2014 Bobby Smiles                                       *\n *   Copyright (C) 2009 Richard Goedeken                                   *\n *   Copyright (C) 2002 Hacktarux                                          *\n *                                                                         *\n *   This program is free software; you can redistribute it and/or modify  *\n *   it under the terms of the GNU General Public License as published by  *\n *   the Free Software Foundation; either version 2 of the License, or     *\n *   (at your option) any later version.                                   *\n *                                                                         *\n *   This program is distributed in the hope that it will be useful,       *\n *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\n *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\n *   GNU General Public License for more details.                          *\n *                                                                         *\n *   You should have received a copy of the GNU General Public License     *\n *   along with this program; if not, write to the                         *\n *   Free Software Foundation, Inc.,                                       *\n *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n#define M64P_PLUGIN_PROTOTYPES 1\n\n#define KEY_FULLSCREEN \"Fullscreen\"\n#define KEY_SCREEN_WIDTH \"ScreenWidth\"\n#define KEY_SCREEN_HEIGHT \"ScreenHeight\"\n#define KEY_PARALLEL \"Parallel\"\n#define KEY_NUM_WORKERS \"NumWorkers\"\n#define KEY_BUSY_LOOP \"BusyLoop\"\n\n#define KEY_VI_MODE \"ViMode\"\n#define KEY_VI_INTERP \"ViInterpolation\"\n#define KEY_VI_WIDESCREEN \"ViWidescreen\"\n#define KEY_VI_HIDE_OVERSCAN \"ViHideOverscan\"\n#define KEY_VI_INTEGER_SCALING \"ViIntegerScaling\"\n#define KEY_VI_VSYNC \"ViVsync\"\n\n#define KEY_DP_COMPAT \"DpCompat\"\n\n#include <stdlib.h>\n#include <string.h>\n#include <ctype.h>\n\n#include \"gfx_m64p.h\"\n\n#include \"api/m64p_types.h\"\n#include \"api/m64p_config.h\"\n\n#include \"core/common.h\"\n#include \"core/version.h\"\n#include \"core/msg.h\"\n\n#include \"output/screen.h\"\n#include \"output/vdac.h\"\n\nstatic ptr_ConfigOpenSection      ConfigOpenSection = NULL;\nstatic ptr_ConfigSaveSection      ConfigSaveSection = NULL;\nstatic ptr_ConfigSetDefaultInt    ConfigSetDefaultInt = NULL;\nstatic ptr_ConfigSetDefaultBool   ConfigSetDefaultBool = NULL;\nstatic ptr_ConfigGetParamInt      ConfigGetParamInt = NULL;\nstatic ptr_ConfigGetParamBool     ConfigGetParamBool = NULL;\nstatic ptr_PluginGetVersion       CoreGetVersion = NULL;\n\nstatic bool warn_hle;\nstatic bool plugin_initialized;\nvoid (*debug_callback)(void *, int, const char *);\nvoid *debug_call_context;\nstatic struct n64video_config config;\n\nm64p_dynlib_handle CoreLibHandle;\nGFX_INFO gfx;\nvoid (*render_callback)(int);\n\nstatic m64p_handle configVideoGeneral = NULL;\nstatic m64p_handle configVideoAngrylionPlus = NULL;\n\n#define PLUGIN_VERSION              0x010600\n#define VIDEO_PLUGIN_API_VERSION    0x020500\n\nextern int32_t win_width;\nextern int32_t win_height;\nextern int32_t win_fullscreen;\n\nEXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle _CoreLibHandle, void *Context,\n                                     void (*DebugCallback)(void *, int, const char *))\n{\n    if (plugin_initialized) {\n        return M64ERR_ALREADY_INIT;\n    }\n\n    /* first thing is to set the callback function for debug info */\n    debug_callback = DebugCallback;\n    debug_call_context = Context;\n\n    CoreLibHandle = _CoreLibHandle;\n\n    ConfigOpenSection = (ptr_ConfigOpenSection)DLSYM(CoreLibHandle, \"ConfigOpenSection\");\n    ConfigSaveSection = (ptr_ConfigSaveSection)DLSYM(CoreLibHandle, \"ConfigSaveSection\");\n    ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt)DLSYM(CoreLibHandle, \"ConfigSetDefaultInt\");\n    ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool)DLSYM(CoreLibHandle, \"ConfigSetDefaultBool\");\n    ConfigGetParamInt = (ptr_ConfigGetParamInt)DLSYM(CoreLibHandle, \"ConfigGetParamInt\");\n    ConfigGetParamBool = (ptr_ConfigGetParamBool)DLSYM(CoreLibHandle, \"ConfigGetParamBool\");\n\n    ConfigOpenSection(\"Video-General\", &configVideoGeneral);\n    ConfigOpenSection(\"Video-AngrylionPlus\", &configVideoAngrylionPlus);\n\n    ConfigSetDefaultBool(configVideoGeneral, KEY_FULLSCREEN, 0, \"Use fullscreen mode if True, or windowed mode if False\");\n    ConfigSetDefaultInt(configVideoGeneral, KEY_SCREEN_WIDTH, 640, \"Width of output window or fullscreen width\");\n    ConfigSetDefaultInt(configVideoGeneral, KEY_SCREEN_HEIGHT, 480, \"Height of output window or fullscreen height\");\n\n    CoreGetVersion = (ptr_PluginGetVersion)DLSYM(CoreLibHandle, \"PluginGetVersion\");\n\n    n64video_config_init(&config);\n\n    ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_PARALLEL, config.parallel, \"Distribute rendering between multiple processors if True\");\n    ConfigSetDefaultInt(configVideoAngrylionPlus, KEY_NUM_WORKERS, config.num_workers, \"Rendering Workers (0=Use all logical processors)\");\n    ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_BUSY_LOOP, config.busyloop, \"Use a busyloop while waiting for work\");\n    ConfigSetDefaultInt(configVideoAngrylionPlus, KEY_VI_MODE, config.vi.mode, \"VI mode (0=Filtered, 1=Unfiltered, 2=Depth, 3=Coverage)\");\n    ConfigSetDefaultInt(configVideoAngrylionPlus, KEY_VI_INTERP, config.vi.interp, \"Scaling interpolation type (0=Blocky (Nearest-neighbor), 1=Blurry (Bilinear), 2=Soft (Bilinear + Nearest-neighbor))\");\n    ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_WIDESCREEN, config.vi.widescreen, \"Use anamorphic 16:9 output mode if True\");\n    ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_HIDE_OVERSCAN, config.vi.hide_overscan, \"Hide overscan area in filteded mode if True\");\n    ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_INTEGER_SCALING, config.vi.integer_scaling, \"Display upscaled pixels as groups of 1x1, 2x2, 3x3, etc. if True\");\n    ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_VSYNC, config.vi.vsync, \"Enable vsync to prevent tearing\");\n    ConfigSetDefaultInt(configVideoAngrylionPlus, KEY_DP_COMPAT, config.dp.compat, \"Compatibility mode (0=Fast 1=Moderate 2=Slow\");\n\n    ConfigSaveSection(\"Video-General\");\n    ConfigSaveSection(\"Video-AngrylionPlus\");\n\n    plugin_initialized = true;\n    return M64ERR_SUCCESS;\n}\n\nEXPORT m64p_error CALL PluginShutdown(void)\n{\n    if (!plugin_initialized) {\n        return M64ERR_NOT_INIT;\n    }\n\n    /* reset some local variable */\n    debug_callback = NULL;\n    debug_call_context = NULL;\n\n    plugin_initialized = false;\n    return M64ERR_SUCCESS;\n}\n\nEXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, int *APIVersion, const char **PluginNamePtr, int *Capabilities)\n{\n    /* set version info */\n    if (PluginType != NULL) {\n        *PluginType = M64PLUGIN_GFX;\n    }\n\n    if (PluginVersion != NULL) {\n        *PluginVersion = PLUGIN_VERSION;\n    }\n\n    if (APIVersion != NULL) {\n        *APIVersion = VIDEO_PLUGIN_API_VERSION;\n    }\n\n    if (PluginNamePtr != NULL) {\n        *PluginNamePtr = CORE_BASE_NAME;\n    }\n\n    if (Capabilities != NULL) {\n        *Capabilities = 0;\n    }\n\n    return M64ERR_SUCCESS;\n}\n\nEXPORT int CALL InitiateGFX (GFX_INFO Gfx_Info)\n{\n    gfx = Gfx_Info;\n\n    return 1;\n}\n\nEXPORT void CALL MoveScreen (int xpos, int ypos)\n{\n    UNUSED(xpos);\n    UNUSED(ypos);\n}\n\nEXPORT void CALL ProcessDList(void)\n{\n    if (!warn_hle) {\n        msg_warning(\"HLE video emulation not supported, please use a LLE RSP plugin like mupen64plus-rsp-cxd4\");\n        warn_hle = true;\n    }\n}\n\nEXPORT void CALL ProcessRDPList(void)\n{\n    n64video_process_list();\n}\n\nEXPORT int CALL RomOpen (void)\n{\n    win_fullscreen = ConfigGetParamBool(configVideoGeneral, KEY_FULLSCREEN);\n    win_width = ConfigGetParamInt(configVideoGeneral, KEY_SCREEN_WIDTH);\n    win_height = ConfigGetParamInt(configVideoGeneral, KEY_SCREEN_HEIGHT);\n\n    config.parallel = ConfigGetParamBool(configVideoAngrylionPlus, KEY_PARALLEL);\n    config.num_workers = ConfigGetParamInt(configVideoAngrylionPlus, KEY_NUM_WORKERS);\n    config.busyloop = ConfigGetParamBool(configVideoAngrylionPlus, KEY_BUSY_LOOP);\n    config.vi.mode = ConfigGetParamInt(configVideoAngrylionPlus, KEY_VI_MODE);\n    config.vi.interp = ConfigGetParamInt(configVideoAngrylionPlus, KEY_VI_INTERP);\n    config.vi.widescreen = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_WIDESCREEN);\n    config.vi.hide_overscan = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_HIDE_OVERSCAN);\n    config.vi.integer_scaling = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_INTEGER_SCALING);\n    config.vi.vsync = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_VSYNC);\n\n    config.dp.compat = ConfigGetParamInt(configVideoAngrylionPlus, KEY_DP_COMPAT);\n\n    config.gfx.rdram = gfx.RDRAM;\n\n    int core_version;\n    CoreGetVersion(NULL, &core_version, NULL, NULL, NULL);\n    if (core_version >= 0x020501) {\n        config.gfx.rdram_size = *gfx.RDRAM_SIZE;\n    } else {\n        config.gfx.rdram_size = RDRAM_MAX_SIZE;\n    }\n\n    config.gfx.dmem = gfx.DMEM;\n    config.gfx.mi_intr_reg = (uint32_t*)gfx.MI_INTR_REG;\n    config.gfx.mi_intr_cb = gfx.CheckInterrupts;\n\n    config.gfx.vi_reg = (uint32_t**)&gfx.VI_STATUS_REG;\n    config.gfx.dp_reg = (uint32_t**)&gfx.DPC_START_REG;\n\n    n64video_init(&config);\n    vdac_init(&config);\n\n    return 1;\n}\n\nEXPORT void CALL RomClosed (void)\n{\n    vdac_close();\n    n64video_close();\n}\n\nEXPORT void CALL ShowCFB (void)\n{\n}\n\nEXPORT void CALL UpdateScreen (void)\n{\n    struct n64video_frame_buffer fb;\n    n64video_update_screen(&fb);\n\n    if (fb.valid) {\n        vdac_write(&fb);\n    }\n\n    vdac_sync(fb.valid);\n}\n\nEXPORT void CALL ViStatusChanged (void)\n{\n}\n\nEXPORT void CALL ViWidthChanged (void)\n{\n}\n\nEXPORT void CALL ChangeWindow(void)\n{\n    screen_toggle_fullscreen();\n}\n\nEXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front)\n{\n    UNUSED(front);\n\n    struct n64video_frame_buffer fb = { 0 };\n    fb.pixels = dest;\n    vdac_read(&fb, false);\n\n    *width = fb.width;\n    *height = fb.height;\n}\n\nEXPORT void CALL SetRenderingCallback(void (*callback)(int))\n{\n    render_callback = callback;\n}\n\nEXPORT void CALL ResizeVideoOutput(int width, int height)\n{\n    win_width = width;\n    win_height = height;\n}\n\nEXPORT void CALL FBWrite(unsigned int addr, unsigned int size)\n{\n    UNUSED(addr);\n    UNUSED(size);\n}\n\nEXPORT void CALL FBRead(unsigned int addr)\n{\n    UNUSED(addr);\n}\n\nEXPORT void CALL FBGetFrameBufferInfo(void *pinfo)\n{\n    UNUSED(pinfo);\n}\n"
  },
  {
    "path": "src/plugin/mupen64plus/gfx_m64p.h",
    "content": "#pragma once\n\n#include \"core/n64video.h\"\n#include \"api/m64p_plugin.h\"\n#include \"api/m64p_common.h\"\n\n#ifdef _WIN32\n#define DLSYM(a, b) GetProcAddress(a, b)\n#else\n#include <dlfcn.h>\n#define DLSYM(a, b) dlsym(a, b)\n#endif\n\nextern GFX_INFO gfx;\nextern m64p_dynlib_handle CoreLibHandle;\nextern void(*render_callback)(int);\nextern void (*debug_callback)(void *, int, const char *);\nextern void *debug_call_context;\n"
  },
  {
    "path": "src/plugin/mupen64plus/msg.c",
    "content": "#include \"core/msg.h\"\n#include \"core/version.h\"\n#include \"gfx_m64p.h\"\n\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#define MSG_BUFFER_LEN 256\n\nvoid msg_error(const char * err, ...)\n{\n    if (debug_callback == NULL) {\n        return;\n    }\n\n    va_list arg;\n    va_start(arg, err);\n    char buf[MSG_BUFFER_LEN];\n    vsprintf(buf, err, arg);\n\n    (*debug_callback)(debug_call_context, M64MSG_ERROR, buf);\n\n    va_end(arg);\n    exit(0);\n}\n\nvoid msg_warning(const char* err, ...)\n{\n    if (debug_callback == NULL) {\n        return;\n    }\n\n    va_list arg;\n    va_start(arg, err);\n    char buf[MSG_BUFFER_LEN];\n    vsprintf(buf, err, arg);\n\n    (*debug_callback)(debug_call_context, M64MSG_WARNING, buf);\n\n    va_end(arg);\n}\n\nvoid msg_debug(const char* err, ...)\n{\n    if (debug_callback == NULL) {\n        return;\n    }\n\n    va_list arg;\n    va_start(arg, err);\n    char buf[MSG_BUFFER_LEN];\n    vsprintf(buf, err, arg);\n\n    (*debug_callback)(debug_call_context, M64MSG_INFO, buf);\n\n    va_end(arg);\n}\n"
  },
  {
    "path": "src/plugin/mupen64plus/screen.c",
    "content": "#include \"gfx_m64p.h\"\n#include \"api/m64p_vidext.h\"\n\n#include \"core/common.h\"\n#include \"core/msg.h\"\n#include \"core/version.h\"\n\n#include \"output/screen.h\"\n\n#include <stdlib.h>\n\n/* definitions of pointers to Core video extension functions */\nstatic ptr_VidExt_Init                  CoreVideo_Init = NULL;\nstatic ptr_VidExt_Quit                  CoreVideo_Quit = NULL;\nstatic ptr_VidExt_ListFullscreenModes   CoreVideo_ListFullscreenModes = NULL;\nstatic ptr_VidExt_SetVideoMode          CoreVideo_SetVideoMode = NULL;\nstatic ptr_VidExt_SetCaption            CoreVideo_SetCaption = NULL;\nstatic ptr_VidExt_ToggleFullScreen      CoreVideo_ToggleFullScreen = NULL;\nstatic ptr_VidExt_ResizeWindow          CoreVideo_ResizeWindow = NULL;\nstatic ptr_VidExt_GL_GetProcAddress     CoreVideo_GL_GetProcAddress = NULL;\nstatic ptr_VidExt_GL_SetAttribute       CoreVideo_GL_SetAttribute = NULL;\nstatic ptr_VidExt_GL_GetAttribute       CoreVideo_GL_GetAttribute = NULL;\nstatic ptr_VidExt_GL_SwapBuffers        CoreVideo_GL_SwapBuffers = NULL;\n\n// framebuffer texture states\nint32_t win_width;\nint32_t win_height;\nint32_t win_fullscreen;\n\nvoid* IntGetProcAddress(const char *name)\n{\n    return (void*)CoreVideo_GL_GetProcAddress(name);\n}\n\nvoid screen_init(struct n64video_config* config)\n{\n    /* Get the core Video Extension function pointers from the library handle */\n    CoreVideo_Init = (ptr_VidExt_Init) DLSYM(CoreLibHandle, \"VidExt_Init\");\n    CoreVideo_Quit = (ptr_VidExt_Quit) DLSYM(CoreLibHandle, \"VidExt_Quit\");\n    CoreVideo_ListFullscreenModes = (ptr_VidExt_ListFullscreenModes) DLSYM(CoreLibHandle, \"VidExt_ListFullscreenModes\");\n    CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) DLSYM(CoreLibHandle, \"VidExt_SetVideoMode\");\n    CoreVideo_SetCaption = (ptr_VidExt_SetCaption) DLSYM(CoreLibHandle, \"VidExt_SetCaption\");\n    CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) DLSYM(CoreLibHandle, \"VidExt_ToggleFullScreen\");\n    CoreVideo_ResizeWindow = (ptr_VidExt_ResizeWindow) DLSYM(CoreLibHandle, \"VidExt_ResizeWindow\");\n    CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) DLSYM(CoreLibHandle, \"VidExt_GL_GetProcAddress\");\n    CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) DLSYM(CoreLibHandle, \"VidExt_GL_SetAttribute\");\n    CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) DLSYM(CoreLibHandle, \"VidExt_GL_GetAttribute\");\n    CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) DLSYM(CoreLibHandle, \"VidExt_GL_SwapBuffers\");\n\n    CoreVideo_Init();\n    CoreVideo_SetCaption(CORE_NAME);\n\n#ifndef GLES\n    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_CORE);\n    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);\n    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 3);\n#else\n    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_ES);\n    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3);\n    CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 0);\n#endif\n\n    CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, config->vi.vsync);\n\n    CoreVideo_SetVideoMode(win_width, win_height, 0, win_fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED, M64VIDEOFLAG_SUPPORT_RESIZING);\n}\n\nvoid screen_adjust(int32_t width_out, int32_t height_out, int32_t* width, int32_t* height, int32_t* x, int32_t* y)\n{\n    UNUSED(width_out);\n    UNUSED(height_out);\n\n    *width = win_width;\n    *height = win_height;\n    *x = 0;\n    *y = 0;\n}\n\nvoid screen_update(void)\n{\n    (*render_callback)(1);\n    CoreVideo_GL_SwapBuffers();\n}\n\nvoid screen_toggle_fullscreen(void)\n{\n    CoreVideo_ToggleFullScreen();\n}\n\nvoid screen_close(void)\n{\n    CoreVideo_Quit();\n}\n"
  },
  {
    "path": "src/plugin/zilmar/config.c",
    "content": "#include \"config.h\"\n#include \"resource.h\"\n\n#include \"core/common.h\"\n#include \"core/version.h\"\n#include \"core/n64video.h\"\n#include \"output/screen.h\"\n#include \"output/vdac.h\"\n\n#include <Commctrl.h>\n#include <Shlwapi.h>\n\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n\n#define SECTION_GENERAL \"General\"\n#define SECTION_VIDEO_INTERFACE \"VideoInterface\"\n#define SECTION_DISPLAY_PROCESSOR \"DisplayProcessor\"\n\n#define KEY_GEN_PARALLEL \"parallel\"\n#define KEY_GEN_NUM_WORKERS \"num_workers\"\n\n#define KEY_VI_MODE \"mode\"\n#define KEY_VI_INTERP \"interpolation\"\n#define KEY_VI_WIDESCREEN \"widescreen\"\n#define KEY_VI_HIDE_OVERSCAN \"hide_overscan\"\n#define KEY_VI_EXCLUSIVE \"exclusive\"\n#define KEY_VI_VSYNC \"vsync\"\n#define KEY_VI_INT_SCALING \"integer_scaling\"\n#define KEY_BUSYLOOP \"busyloop\"\n\n#define KEY_DP_COMPAT \"compat\"\n\n#define CONFIG_FILE_NAME CORE_SIMPLE_NAME \"-config.ini\"\n\n#define CONFIG_DLG_INIT_CHECKBOX(id, var, config) \\\n    var = GetDlgItem(hwnd, id); \\\n    SendMessage(var, BM_SETCHECK, (WPARAM)config, 0);\n\nstatic HINSTANCE inst;\nstatic struct n64video_config config;\nstatic bool config_stale;\nstatic char config_path[MAX_PATH + 1];\n\nstatic HWND dlg_combo_vi_mode;\nstatic HWND dlg_combo_vi_interp;\nstatic HWND dlg_check_trace;\nstatic HWND dlg_check_multithread;\nstatic HWND dlg_check_vi_widescreen;\nstatic HWND dlg_check_vi_overscan;\nstatic HWND dlg_check_vi_exclusive;\nstatic HWND dlg_check_vi_vsync;\nstatic HWND dlg_check_vi_integer_scaling;\nstatic HWND dlg_check_vi_busyloop;\nstatic HWND dlg_combo_dp_compat;\nstatic HWND dlg_spin_workers;\nstatic HWND dlg_edit_workers;\n\nstatic void config_dialog_update_multithread(void)\n{\n    BOOL check = (BOOL)SendMessage(dlg_check_multithread, BM_GETCHECK, 0, 0);\n    EnableWindow(dlg_spin_workers, check);\n    EnableWindow(dlg_edit_workers, check);\n    EnableWindow(dlg_combo_dp_compat, check);\n}\n\nstatic void config_dialog_update_vi_mode(void)\n{\n    LRESULT sel = SendMessage(dlg_combo_vi_mode, CB_GETCURSEL, 0, 0);\n    EnableWindow(dlg_check_vi_overscan, sel == VI_MODE_NORMAL);\n}\n\nstatic void config_dialog_fill_combo(HWND dialog, char** entries, size_t num_entries, uint32_t selected)\n{\n    SendMessage(dialog, CB_RESETCONTENT, 0, 0);\n    for (size_t i = 0; i < num_entries; i++) {\n        SendMessage(dialog, CB_ADDSTRING, i, (LPARAM)entries[i]);\n    }\n    SendMessage(dialog, CB_SETCURSEL, (WPARAM)selected, 0);\n}\n\nINT_PTR CALLBACK config_dialog_proc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam)\n{\n    UNUSED(lParam);\n\n    switch (iMessage) {\n        case WM_INITDIALOG: {\n            SetWindowText(hwnd, CORE_BASE_NAME \" Config\");\n\n            config_load();\n\n            char* vi_mode_strings[] = {\n                \"Filtered\",   // VI_MODE_NORMAL\n                \"Unfiltered\", // VI_MODE_COLOR\n                \"Depth\",      // VI_MODE_DEPTH\n                \"Coverage\"    // VI_MODE_COVERAGE\n            };\n\n            dlg_combo_vi_mode = GetDlgItem(hwnd, IDC_COMBO_VI_MODE);\n            config_dialog_fill_combo(dlg_combo_vi_mode, vi_mode_strings, VI_MODE_NUM, config.vi.mode);\n\n            char* vi_interp_strings[] = {\n                \"Blocky (nearest-neighbor)\",    // VI_INTERP_NEAREST\n                \"Blurry (bilinear)\",            // VI_INTERP_LINEAR\n                \"Soft (bilinear + NN)\"          // VI_INTERP_HYBRID\n            };\n\n            dlg_combo_vi_interp = GetDlgItem(hwnd, IDC_COMBO_VI_INTERP);\n            config_dialog_fill_combo(dlg_combo_vi_interp, vi_interp_strings, VI_INTERP_NUM, config.vi.interp);\n\n            char* dp_compat_strings[] = {\n                \"Fast, most glitches\",      // DP_COMPAT_LOW\n                \"Moderate, some glitches\",  // DP_COMPAT_MEDIUM\n                \"Slow, few glitches\"        // DP_COMPAT_HIGH\n            };\n\n            dlg_combo_dp_compat = GetDlgItem(hwnd, IDC_COMBO_DP_COMPAT);\n            config_dialog_fill_combo(dlg_combo_dp_compat, dp_compat_strings, DP_COMPAT_NUM, config.dp.compat);\n\n            CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_MULTITHREAD, dlg_check_multithread, config.parallel);\n            CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_VI_WIDESCREEN, dlg_check_vi_widescreen, config.vi.widescreen);\n            CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_VI_OVERSCAN, dlg_check_vi_overscan, config.vi.hide_overscan);\n            CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_VI_EXCLUSIVE, dlg_check_vi_exclusive, config.vi.exclusive);\n            CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_VI_VSYNC, dlg_check_vi_vsync, config.vi.vsync);\n            CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_VI_INTEGER_SCALING, dlg_check_vi_integer_scaling, config.vi.integer_scaling);\n            CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_BUSYLOOP, dlg_check_vi_busyloop, config.busyloop);\n\n            dlg_edit_workers = GetDlgItem(hwnd, IDC_EDIT_WORKERS);\n            SetDlgItemInt(hwnd, IDC_EDIT_WORKERS, config.num_workers, FALSE);\n\n            dlg_spin_workers = GetDlgItem(hwnd, IDC_SPIN_WORKERS);\n            SendMessage(dlg_spin_workers, UDM_SETRANGE, 0, MAKELPARAM(128, 0));\n\n            // update enabled/disabled state\n            config_dialog_update_multithread();\n            config_dialog_update_vi_mode();\n\n            break;\n        }\n        case WM_COMMAND: {\n            WORD cmdid = LOWORD(wParam);\n            switch (cmdid) {\n                // disable or enable multithreading options when the checkbox is\n                // checked or unchecked\n                case IDC_CHECK_MULTITHREAD:\n                    config_dialog_update_multithread();\n                    break;\n\n                // disable overscan option if a non-compatible mode is selected\n                case IDC_COMBO_VI_MODE:\n                    switch (HIWORD(wParam)) {\n                        case CBN_SELCHANGE:\n                            config_dialog_update_vi_mode();\n                            break;\n                    }\n                    break;\n\n                // button events\n                case IDOK:\n                case IDAPPLY:\n                    config.vi.mode = SendMessage(dlg_combo_vi_mode, CB_GETCURSEL, 0, 0);\n                    config.vi.interp = SendMessage(dlg_combo_vi_interp, CB_GETCURSEL, 0, 0);\n                    config.vi.widescreen = SendMessage(dlg_check_vi_widescreen, BM_GETCHECK, 0, 0);\n                    config.vi.hide_overscan = SendMessage(dlg_check_vi_overscan, BM_GETCHECK, 0, 0);\n                    config.vi.exclusive = SendMessage(dlg_check_vi_exclusive, BM_GETCHECK, 0, 0);\n                    config.vi.vsync = SendMessage(dlg_check_vi_vsync, BM_GETCHECK, 0, 0);\n                    config.vi.integer_scaling = SendMessage(dlg_check_vi_integer_scaling, BM_GETCHECK, 0, 0);\n                    config.busyloop = SendMessage(dlg_check_vi_busyloop, BM_GETCHECK, 0, 0);\n                    config.dp.compat = SendMessage(dlg_combo_dp_compat, CB_GETCURSEL, 0, 0);\n                    config.parallel = SendMessage(dlg_check_multithread, BM_GETCHECK, 0, 0);\n                    config.num_workers = GetDlgItemInt(hwnd, IDC_EDIT_WORKERS, FALSE, FALSE);\n                    config_stale = true;\n                    config_save();\n\n                    // don't close dialog if \"Apply\" was pressed\n                    if (cmdid == IDAPPLY) {\n                        break;\n                    }\n                case IDCANCEL:\n                    EndDialog(hwnd, 0);\n                    break;\n            }\n            break;\n        }\n        default:\n            return FALSE;\n    }\n    return TRUE;\n}\n\nstatic void config_handle(const char* key, const char* value, const char* section)\n{\n    if (!_strcmpi(section, SECTION_GENERAL)) {\n        if (!_strcmpi(key, KEY_GEN_PARALLEL)) {\n            config.parallel = strtol(value, NULL, 0) != 0;\n        }\n        if (!_strcmpi(key, KEY_GEN_NUM_WORKERS)) {\n            config.num_workers = strtoul(value, NULL, 0);\n        }\n    } else if (!_strcmpi(section, SECTION_VIDEO_INTERFACE)) {\n        if (!_strcmpi(key, KEY_VI_MODE)) {\n            config.vi.mode = strtol(value, NULL, 0);\n        } else if (!_strcmpi(key, KEY_VI_INTERP)) {\n            config.vi.interp = strtol(value, NULL, 0);\n        } else if (!_strcmpi(key, KEY_VI_WIDESCREEN)) {\n            config.vi.widescreen = strtol(value, NULL, 0) != 0;\n        } else if (!_strcmpi(key, KEY_VI_HIDE_OVERSCAN)) {\n            config.vi.hide_overscan = strtol(value, NULL, 0) != 0;\n        } else if (!_strcmpi(key, KEY_VI_EXCLUSIVE)) {\n            config.vi.exclusive = strtol(value, NULL, 0) != 0;\n        } else if (!_strcmpi(key, KEY_VI_VSYNC)) {\n            config.vi.vsync = strtol(value, NULL, 0) != 0;\n        } else if (!_strcmpi(key, KEY_VI_INT_SCALING)) {\n            config.vi.integer_scaling = strtol(value, NULL, 0) != 0;\n        } else if (!_strcmpi(key, KEY_BUSYLOOP)) {\n            config.busyloop = strtol(value, NULL, 0) != 0;\n        }\n    } else if (!_strcmpi(section, SECTION_DISPLAY_PROCESSOR)) {\n        if (!_strcmpi(key, KEY_DP_COMPAT)) {\n            config.dp.compat = strtol(value, NULL, 0);\n        }\n    }\n}\n\nvoid config_init(HINSTANCE hInst)\n{\n    inst = hInst;\n    config_path[0] = 0;\n\n    // create path to config file relative to the DLL path\n    GetModuleFileName(inst, config_path, sizeof(config_path));\n    PathRemoveFileSpec(config_path);\n    PathAppend(config_path, CONFIG_FILE_NAME);\n\n    // load default config\n    n64video_config_init(&config);\n}\n\nvoid config_dialog(HWND hParent)\n{\n    DialogBox(inst, MAKEINTRESOURCE(IDD_DIALOG1), hParent, config_dialog_proc);\n}\n\nstruct n64video_config* config_get(void)\n{\n    return &config;\n}\n\nbool config_load()\n{\n    FILE* fp = fopen(config_path, \"r\");\n    if (!fp) {\n        return false;\n    }\n\n    char line[128];\n    char section[128];\n    while (fgets(line, sizeof(line), fp) != NULL) {\n        // remove newline characters\n        size_t trim_pos = strcspn(line, \"\\r\\n\");\n        line[trim_pos] = 0;\n\n        // ignore blank lines\n        size_t len = strlen(line);\n        if (!len) {\n            continue;\n        }\n\n        // key-values\n        char* eq_ptr = strchr(line, '=');\n        if (eq_ptr) {\n            *eq_ptr = 0;\n            char* key = line;\n            char* value = eq_ptr + 1;\n            config_handle(key, value, section);\n            continue;\n        }\n\n        // sections\n        if (line[0] == '[' && line[len - 1] == ']') {\n            section[0] = 0;\n            strncat(section, line + 1, len - 2);\n            continue;\n        }\n    }\n\n    fclose(fp);\n\n    return true;\n}\n\nstatic void config_write_section(FILE* fp, const char* section)\n{\n    fprintf(fp, \"[%s]\\n\", section);\n}\n\nstatic void config_write_uint32(FILE* fp, const char* key, uint32_t value)\n{\n    fprintf(fp, \"%s=%u\\n\", key, value);\n}\n\nstatic void config_write_int32(FILE* fp, const char* key, int32_t value)\n{\n    fprintf(fp, \"%s=%d\\n\", key, value);\n}\n\nbool config_save(void)\n{\n    FILE* fp = fopen(config_path, \"w\");\n    if (!fp) {\n        return false;\n    }\n\n    config_write_section(fp, SECTION_GENERAL);\n    config_write_int32(fp, KEY_GEN_PARALLEL, config.parallel);\n    config_write_uint32(fp, KEY_GEN_NUM_WORKERS, config.num_workers);\n    fputs(\"\\n\", fp);\n\n    config_write_section(fp, SECTION_VIDEO_INTERFACE);\n    config_write_int32(fp, KEY_VI_MODE, config.vi.mode);\n    config_write_int32(fp, KEY_VI_INTERP, config.vi.interp);\n    config_write_int32(fp, KEY_VI_WIDESCREEN, config.vi.widescreen);\n    config_write_int32(fp, KEY_VI_HIDE_OVERSCAN, config.vi.hide_overscan);\n    config_write_int32(fp, KEY_VI_EXCLUSIVE, config.vi.exclusive);\n    config_write_int32(fp, KEY_VI_VSYNC, config.vi.vsync);\n    config_write_int32(fp, KEY_VI_INT_SCALING, config.vi.integer_scaling);\n    config_write_int32(fp, KEY_BUSYLOOP, config.busyloop);\n    fputs(\"\\n\", fp);\n\n    config_write_section(fp, SECTION_DISPLAY_PROCESSOR);\n    config_write_int32(fp, KEY_DP_COMPAT, config.dp.compat);\n\n    fclose(fp);\n\n    return true;\n}\n\nvoid config_update(void)\n{\n    if (config_stale) {\n        vdac_close();\n        screen_close();\n        n64video_close();\n\n        n64video_init(&config);\n        screen_init(&config);\n        vdac_init(&config);\n\n        config_stale = false;\n    }\n}\n"
  },
  {
    "path": "src/plugin/zilmar/config.h",
    "content": "#pragma once\n\n#include \"core/n64video.h\"\n\n#include <Windows.h>\n\nvoid config_init(HINSTANCE hInst);\nvoid config_dialog(HWND hParent);\nstruct n64video_config* config_get(void);\nbool config_load(void);\nbool config_save(void);\nvoid config_update(void);\n"
  },
  {
    "path": "src/plugin/zilmar/gfx_1.3.c",
    "content": "#include \"gfx_1.3.h\"\n#include \"config.h\"\n#include \"resource.h\"\n\n#include \"core/common.h\"\n#include \"core/n64video.h\"\n#include \"core/version.h\"\n#include \"core/msg.h\"\n\n#include \"output/screen.h\"\n#include \"output/vdac.h\"\n\n#include <stdio.h>\n#include <ctype.h>\n\nGFX_INFO gfx;\nstatic bool m_warn_hle;\nstatic char m_screenshot_path[MAX_PATH];\n\nstatic bool is_valid_ptr(void *ptr, uint32_t bytes)\n{\n    SIZE_T dwSize;\n    MEMORY_BASIC_INFORMATION meminfo;\n    if (!ptr) {\n        return false;\n    }\n    memset(&meminfo, 0x00, sizeof(meminfo));\n    dwSize = VirtualQuery(ptr, &meminfo, sizeof(meminfo));\n    if (!dwSize) {\n        return false;\n    }\n    if (MEM_COMMIT != meminfo.State) {\n        return false;\n    }\n    if (!(meminfo.Protect & (PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY))) {\n        return false;\n    }\n    if (bytes > meminfo.RegionSize) {\n        return false;\n    }\n    if ((uint64_t)((char*)ptr - (char*)meminfo.BaseAddress) > (uint64_t)(meminfo.RegionSize - bytes)) {\n        return false;\n    }\n    return true;\n}\n\nstatic char filter_char(char c)\n{\n    // only allow valid ASCII chars\n    if (c & 0x80) {\n        return ' ';\n    }\n\n    // only allow certain ASCII chars\n    if (!isalnum(c) && c != '_' && c != '-') {\n        return ' ';\n    }\n\n    return c;\n}\n\nstatic char* get_rom_name(void)\n{\n    static char rom_name[128];\n\n    // copy game name from ROM header, which is encoded in Shift_JIS.\n    // most games just use the ASCII subset, so filter out the rest.\n    // TODO: convert Shift_JIS string to UTF-16 for Win32 API?\n    int i = 0;\n    for (; i < 20; i++) {\n        rom_name[i] = filter_char(gfx.HEADER[(32 + i) ^ BYTE_ADDR_XOR]);\n    }\n\n    // make sure there's at least one whitespace that will terminate the string\n    // below\n    rom_name[i] = ' ';\n\n    // trim trailing whitespaces\n    for (; i > 0; i--) {\n        if (rom_name[i] != ' ') {\n            i++;\n            break;\n        }\n    }\n\n    if (i == 0) {\n        // game title is empty or invalid, use safe fallback using the\n        // four-character game ID\n        for (; i < 4; i++) {\n            rom_name[i] = filter_char(gfx.HEADER[(59 + i) ^ BYTE_ADDR_XOR]);\n        }\n    }\n\n    // terminate string\n    rom_name[i] = '\\0';\n\n    return rom_name;\n}\n\nstatic void mi_intr(void)\n{\n    gfx.CheckInterrupts();\n    config_update();\n}\n\nstatic void write_screenshot(char* path)\n{\n    struct n64video_frame_buffer fb = { 0 };\n    vdac_read(&fb, true);\n\n    // prepare bitmap headers\n    BITMAPINFOHEADER ihdr = {0};\n    ihdr.biSize = sizeof(ihdr);\n    ihdr.biWidth = fb.width;\n    ihdr.biHeight = fb.height;\n    ihdr.biPlanes = 1;\n    ihdr.biBitCount = 32;\n    ihdr.biSizeImage = fb.width * fb.height * sizeof(int32_t);\n\n    BITMAPFILEHEADER fhdr = {0};\n    fhdr.bfType = 'B' | ('M' << 8);\n    fhdr.bfOffBits = sizeof(fhdr) + sizeof(ihdr) + 10;\n    fhdr.bfSize = ihdr.biSizeImage + fhdr.bfOffBits;\n\n    FILE* fp = fopen(path, \"wb\");\n\n    if (!fp) {\n        msg_warning(\"Can't open screenshot file %s!\", path);\n        return;\n    }\n\n    // write bitmap headers\n    fwrite(&fhdr, sizeof(fhdr), 1, fp);\n    fwrite(&ihdr, sizeof(ihdr), 1, fp);\n\n    // write bitmap contents\n    fseek(fp, fhdr.bfOffBits, SEEK_SET);\n\n    fb.pixels = malloc(ihdr.biSizeImage);\n    vdac_read(&fb, true);\n\n    // convert RGBA to BGRA\n    for (uint32_t i = 0; i < fb.width * fb.height; i++) {\n        struct n64video_pixel* pixel = &fb.pixels[i];\n        uint8_t tmp = pixel->r;\n        pixel->r = pixel->b;\n        pixel->b = tmp;\n    }\n\n    fwrite(fb.pixels, ihdr.biSizeImage, 1, fp);\n    free(fb.pixels);\n\n    fclose(fp);\n}\n\nBOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)\n{\n    UNUSED(lpvReserved);\n    switch (fdwReason) {\n        case DLL_PROCESS_ATTACH:\n            config_init(hinstDLL);\n            break;\n    }\n    return TRUE;\n}\n\nEXPORT void CALL CaptureScreen(char* directory)\n{\n    char* rom_name = get_rom_name();\n\n    for (int32_t i = 0; i < 10000; i++) {\n        sprintf(m_screenshot_path, \"%s\\\\%s_%04d.bmp\", directory, rom_name, i);\n        DWORD dwAttrib = GetFileAttributes(m_screenshot_path);\n        if (dwAttrib == INVALID_FILE_ATTRIBUTES || (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {\n            break;\n        }\n    }\n}\n\nEXPORT void CALL ChangeWindow(void)\n{\n    screen_toggle_fullscreen();\n}\n\nEXPORT void CALL CloseDLL(void)\n{\n}\n\nEXPORT void CALL DllAbout(HWND hParent)\n{\n    UNUSED(hParent);\n\n    msg_warning(\n        CORE_NAME \"\\n\\n\"\n        \"Branch: \" GIT_BRANCH \"\\n\"\n        \"Commit hash: \" GIT_COMMIT_HASH \"\\n\"\n        \"Commit date: \" GIT_COMMIT_DATE \"\\n\"\n        \"Build date: \" __DATE__ \" \" __TIME__ \"\\n\\n\"\n        \"https://github.com/ata4/angrylion-rdp-plus\"\n    );\n}\n\nEXPORT void CALL DllConfig(HWND hParent)\n{\n    config_dialog(hParent);\n}\n\nEXPORT void CALL ReadScreen(void **dest, long *width, long *height)\n{\n    UNUSED(dest);\n    UNUSED(width);\n    UNUSED(height);\n}\n\nEXPORT void CALL DrawScreen(void)\n{\n}\n\nEXPORT void CALL GetDllInfo(PLUGIN_INFO* PluginInfo)\n{\n    PluginInfo->Version = 0x0103;\n    PluginInfo->Type  = PLUGIN_TYPE_GFX;\n    sprintf(PluginInfo->Name, CORE_NAME);\n\n    PluginInfo->NormalMemory = TRUE;\n    PluginInfo->MemoryBswaped = TRUE;\n}\n\nEXPORT BOOL CALL InitiateGFX(GFX_INFO Gfx_Info)\n{\n    gfx = Gfx_Info;\n\n    return TRUE;\n}\n\nEXPORT void CALL MoveScreen(int xpos, int ypos)\n{\n    UNUSED(xpos);\n    UNUSED(ypos);\n}\n\nEXPORT void CALL ProcessDList(void)\n{\n    if (!m_warn_hle) {\n        msg_warning(\"Please disable 'Graphic HLE' in the plugin settings.\");\n        m_warn_hle = true;\n    }\n}\n\nEXPORT void CALL ProcessRDPList(void)\n{\n    n64video_process_list();\n}\n\nEXPORT void CALL RomClosed(void)\n{\n    vdac_close();\n    n64video_close();\n}\n\nEXPORT void CALL RomOpen(void)\n{\n    config_load();\n    struct n64video_config* config = config_get();\n\n    config->gfx.rdram = gfx.RDRAM;\n    config->gfx.rdram_size = RDRAM_MAX_SIZE;\n\n    // Zilmar's API doesn't provide a way to check the amount of RDRAM available.\n    // It can only be 4 MiB or 8 MiB, so check if the last 16 bytes of the provided\n    // buffer in the 8 MiB range are valid. If not, it must be 4 MiB.\n    if (!is_valid_ptr(&gfx.RDRAM[0x7f0000], 16)) {\n        config->gfx.rdram_size /= 2;\n    }\n\n    config->gfx.dmem = gfx.DMEM;\n    config->gfx.mi_intr_reg = (uint32_t*)gfx.MI_INTR_REG;\n    config->gfx.mi_intr_cb = mi_intr;\n\n    config->gfx.vi_reg = (uint32_t**)&gfx.VI_STATUS_REG;\n    config->gfx.dp_reg = (uint32_t**)&gfx.DPC_START_REG;\n\n    n64video_init(config);\n    vdac_init(config);\n}\n\nEXPORT void CALL ShowCFB(void)\n{\n}\n\nEXPORT void CALL UpdateScreen(void)\n{\n    struct n64video_frame_buffer fb;\n    n64video_update_screen(&fb);\n\n    if (fb.valid) {\n        vdac_write(&fb);\n    }\n\n    vdac_sync(fb.valid);\n\n    // write screenshot file if requested\n    if (m_screenshot_path[0]) {\n        write_screenshot(m_screenshot_path);\n        m_screenshot_path[0] = 0;\n    }\n}\n\nEXPORT void CALL ViStatusChanged(void)\n{\n}\n\nEXPORT void CALL ViWidthChanged(void)\n{\n}\n\nEXPORT void CALL FBWrite(DWORD addr, DWORD val)\n{\n    UNUSED(addr);\n    UNUSED(val);\n}\n\nEXPORT void CALL FBWList(FrameBufferModifyEntry *plist, DWORD size)\n{\n    UNUSED(plist);\n    UNUSED(size);\n}\n\nEXPORT void CALL FBRead(DWORD addr)\n{\n    UNUSED(addr);\n}\n\nEXPORT void CALL FBGetFrameBufferInfo(void *pinfo)\n{\n    UNUSED(pinfo);\n}\n"
  },
  {
    "path": "src/plugin/zilmar/gfx_1.3.h",
    "content": "/**********************************************************************************\nCommon gfx plugin spec, version #1.3 maintained by zilmar (zilmar@emulation64.com)\n\nAll questions or suggestions should go through the mailing list.\nhttp://www.egroups.com/group/Plugin64-Dev\n***********************************************************************************\n\nNotes:\n------\n\nSetting the approprate bits in the MI_INTR_REG and calling CheckInterrupts which\nare both passed to the DLL in InitiateGFX will generate an Interrupt from with in\nthe plugin.\n\nThe Setting of the RSP flags and generating an SP interrupt  should not be done in\nthe plugin\n\n**********************************************************************************/\n#ifndef _GFX_H_INCLUDED__\n#define _GFX_H_INCLUDED__\n\n#include <Windows.h>\n\n#if defined(__cplusplus)\nextern \"C\" {\n#endif\n\n/* Plugin types */\n#define PLUGIN_TYPE_GFX             2\n\n#define EXPORT                      __declspec(dllexport)\n#define CALL                        _cdecl\n\n/***** Structures *****/\ntypedef struct {\n    WORD Version;        /* Set to 0x0103 */\n    WORD Type;           /* Set to PLUGIN_TYPE_GFX */\n    char Name[100];      /* Name of the DLL */\n\n    /* If DLL supports memory these memory options then set them to TRUE or FALSE\n       if it does not support it */\n    BOOL NormalMemory;    /* a normal BYTE array */\n    BOOL MemoryBswaped;  /* a normal BYTE array where the memory has been pre\n                              bswap on a dword (32 bits) boundry */\n} PLUGIN_INFO;\n\ntypedef struct {\n    HWND hWnd;          /* Render window */\n    HWND hStatusBar;    /* if render window does not have a status bar then this is NULL */\n\n    BOOL MemoryBswaped;    // If this is set to TRUE, then the memory has been pre\n                           //   bswap on a dword (32 bits) boundry\n                           //   eg. the first 8 bytes are stored like this:\n                           //        4 3 2 1   8 7 6 5\n\n    BYTE * HEADER;  // This is the rom header (first 40h bytes of the rom\n                    // This will be in the same memory format as the rest of the memory.\n    BYTE * RDRAM;\n    BYTE * DMEM;\n    BYTE * IMEM;\n\n    DWORD * MI_INTR_REG;\n\n    DWORD * DPC_START_REG;\n    DWORD * DPC_END_REG;\n    DWORD * DPC_CURRENT_REG;\n    DWORD * DPC_STATUS_REG;\n    DWORD * DPC_CLOCK_REG;\n    DWORD * DPC_BUFBUSY_REG;\n    DWORD * DPC_PIPEBUSY_REG;\n    DWORD * DPC_TMEM_REG;\n\n    DWORD * VI_STATUS_REG;\n    DWORD * VI_ORIGIN_REG;\n    DWORD * VI_WIDTH_REG;\n    DWORD * VI_INTR_REG;\n    DWORD * VI_V_CURRENT_LINE_REG;\n    DWORD * VI_TIMING_REG;\n    DWORD * VI_V_SYNC_REG;\n    DWORD * VI_H_SYNC_REG;\n    DWORD * VI_LEAP_REG;\n    DWORD * VI_H_START_REG;\n    DWORD * VI_V_START_REG;\n    DWORD * VI_V_BURST_REG;\n    DWORD * VI_X_SCALE_REG;\n    DWORD * VI_Y_SCALE_REG;\n\n    void (*CheckInterrupts)( void );\n} GFX_INFO;\n\n/******************************************************************\n  Function: CaptureScreen\n  Purpose:  This function dumps the current frame to a file\n  input:    pointer to the directory to save the file to\n  output:   none\n*******************************************************************/\nEXPORT void CALL CaptureScreen ( char * Directory );\n\n/******************************************************************\n  Function: ChangeWindow\n  Purpose:  to change the window between fullscreen and window\n            mode. If the window was in fullscreen this should\n            change the screen to window mode and vice vesa.\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL ChangeWindow (void);\n\n/******************************************************************\n  Function: CloseDLL\n  Purpose:  This function is called when the emulator is closing\n            down allowing the dll to de-initialise.\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL CloseDLL (void);\n\n/******************************************************************\n  Function: DllAbout\n  Purpose:  This function is optional function that is provided\n            to give further information about the DLL.\n  input:    a handle to the window that calls this function\n  output:   none\n*******************************************************************/\nEXPORT void CALL DllAbout ( HWND hParent );\n\n/******************************************************************\n  Function: DllConfig\n  Purpose:  This function is optional function that is provided\n            to allow the user to configure the dll\n  input:    a handle to the window that calls this function\n  output:   none\n*******************************************************************/\nEXPORT void CALL DllConfig ( HWND hParent );\n\n/******************************************************************\n  Function: DllTest\n  Purpose:  This function is optional function that is provided\n            to allow the user to test the dll\n  input:    a handle to the window that calls this function\n  output:   none\n*******************************************************************/\nEXPORT void CALL DllTest ( HWND hParent );\n\n\nEXPORT void CALL ReadScreen(void **dest, long *width, long *height);\n\n/******************************************************************\n  Function: DrawScreen\n  Purpose:  This function is called when the emulator receives a\n            WM_PAINT message. This allows the gfx to fit in when\n            it is being used in the desktop.\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL DrawScreen (void);\n\n/******************************************************************\n  Function: GetDllInfo\n  Purpose:  This function allows the emulator to gather information\n            about the dll by filling in the PluginInfo structure.\n  input:    a pointer to a PLUGIN_INFO stucture that needs to be\n            filled by the function. (see def above)\n  output:   none\n*******************************************************************/\nEXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo );\n\n/******************************************************************\n  Function: InitiateGFX\n  Purpose:  This function is called when the DLL is started to give\n            information from the emulator that the n64 graphics\n            uses. This is not called from the emulation thread.\n  Input:    Gfx_Info is passed to this function which is defined\n            above.\n  Output:   TRUE on success\n            FALSE on failure to initialise\n\n  ** note on interrupts **:\n  To generate an interrupt set the appropriate bit in MI_INTR_REG\n  and then call the function CheckInterrupts to tell the emulator\n  that there is a waiting interrupt.\n*******************************************************************/\nEXPORT BOOL CALL InitiateGFX (GFX_INFO Gfx_Info);\n\n/******************************************************************\n  Function: MoveScreen\n  Purpose:  This function is called in response to the emulator\n            receiving a WM_MOVE passing the xpos and ypos passed\n            from that message.\n  input:    xpos - the x-coordinate of the upper-left corner of the\n            client area of the window.\n            ypos - y-coordinate of the upper-left corner of the\n            client area of the window.\n  output:   none\n*******************************************************************/\nEXPORT void CALL MoveScreen (int xpos, int ypos);\n\n/******************************************************************\n  Function: ProcessDList\n  Purpose:  This function is called when there is a Dlist to be\n            processed. (High level GFX list)\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL ProcessDList(void);\n\n/******************************************************************\n  Function: ProcessRDPList\n  Purpose:  This function is called when there is a Dlist to be\n            processed. (Low level GFX list)\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL ProcessRDPList(void);\n\n/******************************************************************\n  Function: RomClosed\n  Purpose:  This function is called when a rom is closed.\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL RomClosed (void);\n\n/******************************************************************\n  Function: RomOpen\n  Purpose:  This function is called when a rom is open. (from the\n            emulation thread)\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL RomOpen (void);\n\n/******************************************************************\n  Function: ShowCFB\n  Purpose:  Useally once Dlists are started being displayed, cfb is\n            ignored. This function tells the dll to start displaying\n            them again.\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL ShowCFB (void);\n\n/******************************************************************\n  Function: UpdateScreen\n  Purpose:  This function is called in response to a vsync of the\n            screen were the VI bit in MI_INTR_REG has already been\n            set\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL UpdateScreen (void);\n\n/******************************************************************\n  Function: ViStatusChanged\n  Purpose:  This function is called to notify the dll that the\n            ViStatus registers value has been changed.\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL ViStatusChanged (void);\n\n/******************************************************************\n  Function: ViWidthChanged\n  Purpose:  This function is called to notify the dll that the\n            ViWidth registers value has been changed.\n  input:    none\n  output:   none\n*******************************************************************/\nEXPORT void CALL ViWidthChanged (void);\n\n\n/******************************************************************\n  Function: FrameBufferWrite\n  Purpose:  This function is called to notify the dll that the\n            frame buffer has been modified by CPU at the given address.\n  input:    addr        rdram address\n            val         val\n            size        1 = BYTE, 2 = WORD, 4 = DWORD\n  output:   none\n*******************************************************************/\nEXPORT void CALL FBWrite(DWORD, DWORD);\n\ntypedef struct\n{\n    DWORD addr;\n    DWORD val;\n    DWORD size;             // 1 = BYTE, 2 = WORD, 4=DWORD\n} FrameBufferModifyEntry;\n\n/******************************************************************\n  Function: FrameBufferWriteList\n  Purpose:  This function is called to notify the dll that the\n            frame buffer has been modified by CPU at the given address.\n  input:    FrameBufferModifyEntry *plist\n            size = size of the plist, max = 1024\n  output:   none\n*******************************************************************/\nEXPORT void CALL FBWList(FrameBufferModifyEntry *plist, DWORD size);\n\n/******************************************************************\n  Function: FrameBufferRead\n  Purpose:  This function is called to notify the dll that the\n            frame buffer memory is beening read at the given address.\n            DLL should copy content from its render buffer to the frame buffer\n            in N64 RDRAM\n            DLL is responsible to maintain its own frame buffer memory addr list\n            DLL should copy 4KB block content back to RDRAM frame buffer.\n            Emulator should not call this function again if other memory\n            is read within the same 4KB range\n  input:    addr        rdram address\n            val         val\n            size        1 = BYTE, 2 = WORD, 4 = DWORD\n  output:   none\n*******************************************************************/\nEXPORT void CALL FBRead(DWORD addr);\n\n/************************************************************************\nFunction: FBGetFrameBufferInfo\nPurpose:  This function is called by the emulator core to retrieve depth\nbuffer information from the video plugin in order to be able\nto notify the video plugin about CPU depth buffer read/write\noperations\n\nsize:\n= 1     byte\n= 2     word (16 bit) <-- this is N64 default depth buffer format\n= 4     dword (32 bit)\n\nwhen depth buffer information is not available yet, set all values\nin the FrameBufferInfo structure to 0\n\ninput:    FrameBufferInfo *pinfo\npinfo is pointed to a FrameBufferInfo structure which to be\nfilled in by this function\noutput:   Values are return in the FrameBufferInfo structure\n************************************************************************/\nEXPORT void CALL FBGetFrameBufferInfo(void *pinfo);\n\n#if defined(__cplusplus)\n}\n#endif\n#endif //_GFX_H_INCLUDED__\n"
  },
  {
    "path": "src/plugin/zilmar/msg.c",
    "content": "#include \"core/msg.h\"\n#include \"core/version.h\"\n\n#include <Windows.h>\n\n#include <stdio.h>\n#include <stdarg.h>\n\n#define MSG_BUFFER_LEN 256\n\nvoid msg_error(const char * err, ...)\n{\n    va_list arg;\n    va_start(arg, err);\n    char buf[MSG_BUFFER_LEN];\n    vsprintf_s(buf, sizeof(buf), err, arg);\n    MessageBoxA(0, buf, CORE_SIMPLE_NAME \": fatal error\", MB_OK);\n    va_end(arg);\n    exit(0);\n}\n\nvoid msg_warning(const char* err, ...)\n{\n    va_list arg;\n    va_start(arg, err);\n    char buf[MSG_BUFFER_LEN];\n    vsprintf_s(buf, sizeof(buf), err, arg);\n    MessageBoxA(0, buf, CORE_SIMPLE_NAME \": warning\", MB_OK);\n    va_end(arg);\n}\n\nvoid msg_debug(const char* err, ...)\n{\n    va_list arg;\n    va_start(arg, err);\n    char buf[MSG_BUFFER_LEN];\n    vsprintf_s(buf, sizeof(buf), err, arg);\n    strcat_s(buf, sizeof(buf), \"\\n\");\n    OutputDebugStringA(buf);\n    va_end(arg);\n}\n"
  },
  {
    "path": "src/plugin/zilmar/screen.c",
    "content": "#include \"gfx_1.3.h\"\n\n#include \"wgl_ext.h\"\n\n#include \"output/screen.h\"\n#include \"output/gl_proc.h\"\n#include \"core/common.h\"\n#include \"core/msg.h\"\n\n#include <stdlib.h>\n#include <stdint.h>\n#include <stdio.h>\n\nextern GFX_INFO gfx;\n\n// default size of the window\n#define WINDOW_DEFAULT_WIDTH 640\n#define WINDOW_DEFAULT_HEIGHT 480\n\n// previous size of the window\nstatic int32_t m_win_width;\nstatic int32_t m_win_height;\n\n// context states\nstatic HDC m_dc;\nstatic HGLRC m_glrc;\nstatic HGLRC m_glrc_core;\nstatic bool m_fullscreen;\n\n// config states\nstatic bool m_exclusive;\n\n// Win32 helpers\nvoid win32_client_resize(HWND hWnd, HWND hStatus, int32_t nWidth, int32_t nHeight)\n{\n    RECT rclient;\n    if (!GetClientRect(hWnd, &rclient)) {\n        return;\n    }\n\n    RECT rwin;\n    if (!GetWindowRect(hWnd, &rwin)) {\n        return;\n    }\n\n    RECT rstatus;\n    if (hStatus && GetClientRect(hStatus, &rstatus)) {\n        rclient.bottom -= rstatus.bottom;\n    }\n\n    POINT pdiff;\n    pdiff.x = (rwin.right - rwin.left) - rclient.right;\n    pdiff.y = (rwin.bottom - rwin.top) - rclient.bottom;\n\n    MoveWindow(hWnd, rwin.left, rwin.top, nWidth + pdiff.x, nHeight + pdiff.y, TRUE);\n}\n\nstatic int TestPointer(const PROC pTest)\n{\n    if (!pTest) {\n        return 0;\n    }\n\n    ptrdiff_t iTest = (ptrdiff_t)pTest;\n\n    return iTest != 1 && iTest != 2 && iTest != 3 && iTest != -1;\n}\n\nfuncptr IntGetProcAddress(const char* name)\n{\n    PROC pFunc = wglGetProcAddress((LPCSTR)name);\n    if (TestPointer(pFunc)) {\n        return (funcptr)pFunc;\n    }\n    HMODULE glMod = GetModuleHandleA(\"OpenGL32.dll\");\n    if (glMod == NULL) {\n        return (funcptr)glMod;\n    } else {\n        return (funcptr)GetProcAddress(glMod, (LPCSTR)name);\n    }\n}\n\nvoid screen_init(struct n64video_config* config)\n{\n    m_exclusive = config->vi.exclusive;\n\n    // reset windowed size state\n    m_win_width = 0;\n    m_win_height = 0;\n\n    // make window resizable for the user\n    if (!m_fullscreen) {\n        LONG style = GetWindowLong(gfx.hWnd, GWL_STYLE);\n\n        if ((style & (WS_SIZEBOX | WS_MAXIMIZEBOX)) == 0) {\n            style |= WS_SIZEBOX | WS_MAXIMIZEBOX;\n            SetWindowLong(gfx.hWnd, GWL_STYLE, style);\n\n            // Fix client size after changing the window style, otherwise the PJ64\n            // menu will be displayed incorrectly.\n            // For some reason, this needs to be called twice, probably because the\n            // style set above isn't applied immediately.\n            for (int i = 0; i < 2; i++) {\n                win32_client_resize(gfx.hWnd, gfx.hStatusBar, WINDOW_DEFAULT_WIDTH, WINDOW_DEFAULT_HEIGHT);\n            }\n        }\n    }\n\n    PIXELFORMATDESCRIPTOR win_pfd = {\n        sizeof(PIXELFORMATDESCRIPTOR), 1,\n        PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, // Flags\n        PFD_TYPE_RGBA, // The kind of framebuffer. RGBA or palette.\n        32,            // Colordepth of the framebuffer.\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n        24, // Number of bits for the depthbuffer\n        8,  // Number of bits for the stencilbuffer\n        0,  // Number of Aux buffers in the framebuffer.\n        PFD_MAIN_PLANE, 0, 0, 0, 0\n    };\n\n    m_dc = GetDC(gfx.hWnd);\n    if (!m_dc) {\n        msg_error(\"Can't get device context.\");\n        return;\n    }\n\n    int32_t win_pf = ChoosePixelFormat(m_dc, &win_pfd);\n    if (!win_pf) {\n        msg_error(\"Can't choose pixel format.\");\n        return;\n    }\n    SetPixelFormat(m_dc, win_pf, &win_pfd);\n\n    // create legacy context, required for wglGetProcAddress to work properly\n    m_glrc = wglCreateContext(m_dc);\n    if (!m_glrc || !wglMakeCurrent(m_dc, m_glrc)) {\n        msg_error(\"Can't create OpenGL context.\");\n        return;\n    }\n\n    // load wgl extension\n    wgl_LoadFunctions(m_dc);\n\n    // attributes for a 3.3 core profile without all the legacy stuff\n    GLint attribs[] = {\n        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,\n        WGL_CONTEXT_MINOR_VERSION_ARB, 3,\n        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,\n        0\n    };\n\n    // create the actual context\n    m_glrc_core = wglCreateContextAttribsARB(m_dc, m_glrc, attribs);\n    if (!m_glrc_core || !wglMakeCurrent(m_dc, m_glrc_core)) {\n        // rendering probably still works with the legacy context, so just send\n        // a warning\n        msg_warning(\"Can't create OpenGL 3.3 core context.\");\n    }\n\n    // enable or disable vsync\n    wglSwapIntervalEXT(config->vi.vsync ? 1 : 0);\n}\n\nvoid screen_adjust(int32_t width_out, int32_t height_out, int32_t* width, int32_t* height, int32_t* x, int32_t* y)\n{\n    UNUSED(width_out);\n    UNUSED(height_out);\n\n    // get size of window\n    RECT rect;\n    if (!GetClientRect(gfx.hWnd, &rect)) {\n        // window handle invalid?\n        *width = 0;\n        *height = 0;\n        *x = 0;\n        *y = 0;\n        return;\n    }\n\n    // status bar covers the client area, so exclude it from calculation\n    RECT statusrect;\n    SetRectEmpty(&statusrect);\n\n    if (gfx.hStatusBar && GetClientRect(gfx.hStatusBar, &statusrect)) {\n        rect.bottom -= statusrect.bottom;\n    }\n\n    int32_t win_width = rect.right - rect.left;\n    int32_t win_height = rect.bottom - rect.top;\n\n    // default to bottom left corner of the window above the status bar\n    int32_t win_x = 0;\n    int32_t win_y = statusrect.bottom;\n\n    // adjust windowed size after the output size has changed so that\n    // the output remains pixel-perfect until the user changes the window size\n    if (win_width != win_width || win_height != win_height) {\n        int32_t win_width_tmp = win_width = win_width;\n        int32_t win_height_tmp = win_height = win_height;\n\n        // double resolution for very small frame sizes, typically when\n        // unfiltered option is enabled\n        if (win_width_tmp <= 320) {\n            win_width_tmp <<= 1;\n            win_height_tmp <<= 1;\n        }\n\n        WINDOWPLACEMENT wndpl = { 0 };\n        GetWindowPlacement(gfx.hWnd, &wndpl);\n\n        // only fix size if windowed and not maximized\n        if (!m_fullscreen && wndpl.showCmd != SW_MAXIMIZE) {\n            win32_client_resize(gfx.hWnd, gfx.hStatusBar,\n                win_width_tmp, win_height_tmp);\n        }\n    }\n\n    *width = win_width;\n    *height = win_height;\n    *x = win_x;\n    *y = win_y;\n}\n\nvoid screen_update(void)\n{\n    // don't render when the window is minimized\n    if (!IsIconic(gfx.hWnd)) {\n        // swap front and back buffers\n        SwapBuffers(m_dc);\n    }\n}\n\nvoid screen_toggle_fullscreen(void)\n{\n    static HMENU old_menu;\n    static LONG old_style;\n    static WINDOWPLACEMENT old_pos;\n\n    m_fullscreen = !m_fullscreen;\n\n    if (m_fullscreen) {\n        // hide curser\n        ShowCursor(FALSE);\n\n        // hide status bar\n        if (gfx.hStatusBar) {\n            ShowWindow(gfx.hStatusBar, SW_HIDE);\n        }\n\n        // disable menu and save it to restore it later\n        old_menu = GetMenu(gfx.hWnd);\n        if (old_menu) {\n            SetMenu(gfx.hWnd, NULL);\n        }\n\n        // save old window position and size\n        GetWindowPlacement(gfx.hWnd, &old_pos);\n\n        // use virtual screen dimensions for fullscreen mode\n        int32_t vs_width = GetSystemMetrics(SM_CXSCREEN);\n        int32_t vs_height = GetSystemMetrics(SM_CYSCREEN);\n\n        // disable all styles to get a borderless window and save it to restore\n        // it later\n        old_style = GetWindowLong(gfx.hWnd, GWL_STYLE);\n        LONG style = WS_VISIBLE;\n        if (m_exclusive) {\n            style |= WS_POPUP;\n        }\n        SetWindowLong(gfx.hWnd, GWL_STYLE, style);\n\n        // resize window so it covers the entire virtual screen\n        SetWindowPos(gfx.hWnd, HWND_TOP, 0, 0, vs_width, vs_height, SWP_SHOWWINDOW);\n    }\n    else {\n        // restore cursor\n        ShowCursor(TRUE);\n\n        // restore status bar\n        if (gfx.hStatusBar) {\n            ShowWindow(gfx.hStatusBar, SW_SHOW);\n        }\n\n        // restore menu\n        if (old_menu) {\n            SetMenu(gfx.hWnd, old_menu);\n            old_menu = NULL;\n        }\n\n        // restore style\n        SetWindowLong(gfx.hWnd, GWL_STYLE, old_style);\n\n        // restore window size and position\n        SetWindowPlacement(gfx.hWnd, &old_pos);\n    }\n}\n\nvoid screen_close(void)\n{\n    if (m_glrc_core) {\n        wglDeleteContext(m_glrc_core);\n    }\n\n    wglDeleteContext(m_glrc);\n}\n"
  },
  {
    "path": "src/plugin/zilmar/wgl_ext.c",
    "content": "#include \"wgl_ext.h\"\n#include \"output/gl_proc.h\"\n\n#include <stdlib.h>\n#include <string.h>\n#include <stddef.h>\n\nint wgl_ext_EXT_swap_control = wgl_LOAD_FAILED;\nint wgl_ext_ARB_create_context = wgl_LOAD_FAILED;\nint wgl_ext_ARB_create_context_profile = wgl_LOAD_FAILED;\n\nint (CODEGEN_FUNCPTR *_ptrc_wglGetSwapIntervalEXT)(void) = NULL;\nBOOL (CODEGEN_FUNCPTR *_ptrc_wglSwapIntervalEXT)(int interval) = NULL;\n\nstatic int Load_EXT_swap_control(void)\n{\n\tint numFailed = 0;\n\t_ptrc_wglGetSwapIntervalEXT = (int (CODEGEN_FUNCPTR *)(void))IntGetProcAddress(\"wglGetSwapIntervalEXT\");\n\tif(!_ptrc_wglGetSwapIntervalEXT) numFailed++;\n\t_ptrc_wglSwapIntervalEXT = (BOOL (CODEGEN_FUNCPTR *)(int))IntGetProcAddress(\"wglSwapIntervalEXT\");\n\tif(!_ptrc_wglSwapIntervalEXT) numFailed++;\n\treturn numFailed;\n}\n\nHGLRC (CODEGEN_FUNCPTR *_ptrc_wglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext, const int * attribList) = NULL;\n\nstatic int Load_ARB_create_context(void)\n{\n\tint numFailed = 0;\n\t_ptrc_wglCreateContextAttribsARB = (HGLRC (CODEGEN_FUNCPTR *)(HDC, HGLRC, const int *))IntGetProcAddress(\"wglCreateContextAttribsARB\");\n\tif(!_ptrc_wglCreateContextAttribsARB) numFailed++;\n\treturn numFailed;\n}\n\n\nstatic const char * (CODEGEN_FUNCPTR *_ptrc_wglGetExtensionsStringARB)(HDC hdc) = NULL;\n\ntypedef int (*PFN_LOADFUNCPOINTERS)(void);\ntypedef struct wgl_StrToExtMap_s\n{\n\tchar *extensionName;\n\tint *extensionVariable;\n\tPFN_LOADFUNCPOINTERS LoadExtension;\n} wgl_StrToExtMap;\n\nstatic wgl_StrToExtMap ExtensionMap[3] = {\n\t{\"WGL_EXT_swap_control\", &wgl_ext_EXT_swap_control, Load_EXT_swap_control},\n\t{\"WGL_ARB_create_context\", &wgl_ext_ARB_create_context, Load_ARB_create_context},\n\t{\"WGL_ARB_create_context_profile\", &wgl_ext_ARB_create_context_profile, NULL},\n};\n\nstatic int g_extensionMapSize = 3;\n\nstatic wgl_StrToExtMap *FindExtEntry(const char *extensionName)\n{\n\tint loop;\n\twgl_StrToExtMap *currLoc = ExtensionMap;\n\tfor(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)\n\t{\n\t\tif(strcmp(extensionName, currLoc->extensionName) == 0)\n\t\t\treturn currLoc;\n\t}\n\t\n\treturn NULL;\n}\n\nstatic void ClearExtensionVars(void)\n{\n\twgl_ext_EXT_swap_control = wgl_LOAD_FAILED;\n\twgl_ext_ARB_create_context = wgl_LOAD_FAILED;\n\twgl_ext_ARB_create_context_profile = wgl_LOAD_FAILED;\n}\n\n\nstatic void LoadExtByName(const char *extensionName)\n{\n\twgl_StrToExtMap *entry = NULL;\n\tentry = FindExtEntry(extensionName);\n\tif(entry)\n\t{\n\t\tif(entry->LoadExtension)\n\t\t{\n\t\t\tint numFailed = entry->LoadExtension();\n\t\t\tif(numFailed == 0)\n\t\t\t{\n\t\t\t\t*(entry->extensionVariable) = wgl_LOAD_SUCCEEDED;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*(entry->extensionVariable) = wgl_LOAD_SUCCEEDED + numFailed;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t*(entry->extensionVariable) = wgl_LOAD_SUCCEEDED;\n\t\t}\n\t}\n}\n\n\nstatic void ProcExtsFromExtString(const char *strExtList)\n{\n\tsize_t iExtListLen = strlen(strExtList);\n\tconst char *strExtListEnd = strExtList + iExtListLen;\n\tconst char *strCurrPos = strExtList;\n\tchar strWorkBuff[256];\n\n\twhile(*strCurrPos)\n\t{\n\t\t/*Get the extension at our position.*/\n\t\tint iStrLen = 0;\n\t\tconst char *strEndStr = strchr(strCurrPos, ' ');\n\t\tint iStop = 0;\n\t\tif(strEndStr == NULL)\n\t\t{\n\t\t\tstrEndStr = strExtListEnd;\n\t\t\tiStop = 1;\n\t\t}\n\n\t\tiStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos);\n\n\t\tif(iStrLen > 255)\n\t\t\treturn;\n\n\t\tstrncpy(strWorkBuff, strCurrPos, iStrLen);\n\t\tstrWorkBuff[iStrLen] = '\\0';\n\n\t\tLoadExtByName(strWorkBuff);\n\n\t\tstrCurrPos = strEndStr + 1;\n\t\tif(iStop) break;\n\t}\n}\n\nint wgl_LoadFunctions(HDC hdc)\n{\n\tClearExtensionVars();\n\t\n\t_ptrc_wglGetExtensionsStringARB = (const char * (CODEGEN_FUNCPTR *)(HDC))IntGetProcAddress(\"wglGetExtensionsStringARB\");\n\tif(!_ptrc_wglGetExtensionsStringARB) return wgl_LOAD_FAILED;\n\t\n\tProcExtsFromExtString((const char *)_ptrc_wglGetExtensionsStringARB(hdc));\n\treturn wgl_LOAD_SUCCEEDED;\n}\n\n"
  },
  {
    "path": "src/plugin/zilmar/wgl_ext.h",
    "content": "#ifndef POINTER_C_GENERATED_HEADER_WINDOWSGL_H\n#define POINTER_C_GENERATED_HEADER_WINDOWSGL_H\n\n#ifdef __wglext_h_\n#error Attempt to include auto-generated WGL header after wglext.h\n#endif\n\n#define __wglext_h_\n\n#ifndef WIN32_LEAN_AND_MEAN\n\t#define WIN32_LEAN_AND_MEAN 1\n#endif\n#ifndef NOMINMAX\n\t#define NOMINMAX\n#endif\n#include <windows.h>\n\n#ifdef CODEGEN_FUNCPTR\n#undef CODEGEN_FUNCPTR\n#endif /*CODEGEN_FUNCPTR*/\n#define CODEGEN_FUNCPTR WINAPI\n\n#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n\ntypedef unsigned int GLenum;\ntypedef unsigned char GLboolean;\ntypedef unsigned int GLbitfield;\ntypedef signed char GLbyte;\ntypedef short GLshort;\ntypedef int GLint;\ntypedef int GLsizei;\ntypedef unsigned char GLubyte;\ntypedef unsigned short GLushort;\ntypedef unsigned int GLuint;\ntypedef float GLfloat;\ntypedef float GLclampf;\ntypedef double GLdouble;\ntypedef double GLclampd;\n#define GLvoid void\n\n#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/\n\n\n#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS\n\n\n#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/\n\n\nstruct _GPU_DEVICE {\n    DWORD  cb;\n    CHAR   DeviceName[32];\n    CHAR   DeviceString[128];\n    DWORD  Flags;\n    RECT   rcVirtualScreen;\n};\nDECLARE_HANDLE(HPBUFFERARB);\nDECLARE_HANDLE(HPBUFFEREXT);\nDECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);\nDECLARE_HANDLE(HPVIDEODEV);\nDECLARE_HANDLE(HGPUNV);\nDECLARE_HANDLE(HVIDEOINPUTDEVICENV);\ntypedef struct _GPU_DEVICE *PGPU_DEVICE;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /*__cplusplus*/\n\nextern int wgl_ext_EXT_swap_control;\nextern int wgl_ext_ARB_create_context;\nextern int wgl_ext_ARB_create_context_profile;\n\n#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001\n#define WGL_CONTEXT_FLAGS_ARB 0x2094\n#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002\n#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093\n#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091\n#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092\n#define WGL_ERROR_INVALID_VERSION_ARB 0x2095\n\n#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\n#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001\n#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126\n#define WGL_ERROR_INVALID_PROFILE_ARB 0x2096\n\n#ifndef WGL_EXT_swap_control\n#define WGL_EXT_swap_control 1\nextern int (CODEGEN_FUNCPTR *_ptrc_wglGetSwapIntervalEXT)(void);\n#define wglGetSwapIntervalEXT _ptrc_wglGetSwapIntervalEXT\nextern BOOL (CODEGEN_FUNCPTR *_ptrc_wglSwapIntervalEXT)(int interval);\n#define wglSwapIntervalEXT _ptrc_wglSwapIntervalEXT\n#endif /*WGL_EXT_swap_control*/ \n\n#ifndef WGL_ARB_create_context\n#define WGL_ARB_create_context 1\nextern HGLRC (CODEGEN_FUNCPTR *_ptrc_wglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext, const int * attribList);\n#define wglCreateContextAttribsARB _ptrc_wglCreateContextAttribsARB\n#endif /*WGL_ARB_create_context*/ \n\n\nenum wgl_LoadStatus\n{\n\twgl_LOAD_FAILED = 0,\n\twgl_LOAD_SUCCEEDED = 1,\n};\n\nint wgl_LoadFunctions(HDC hdc);\n\n\n#ifdef __cplusplus\n}\n#endif /*__cplusplus*/\n\n#endif /*POINTER_C_GENERATED_HEADER_WINDOWSGL_H*/\n"
  }
]