[
  {
    "path": ".gitignore",
    "content": "tools/*.exe\n\n\n## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore\n\n# User-specific files\n*.rsuser\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Mono auto generated files\nmono_crash.*\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\n[Ww][Ii][Nn]32/\n[Aa][Rr][Mm]/\n[Aa][Rr][Mm]64/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n[Ll]ogs/\n\n# Visual Studio 2015/2017 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# Visual Studio 2017 auto generated files\nGenerated\\ Files/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUnit\n*.VisualState.xml\nTestResult.xml\nnunit-*.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# Benchmark Results\nBenchmarkDotNet.Artifacts/\n\n# .NET Core\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n\n# ASP.NET Scaffolding\nScaffoldingReadMe.txt\n\n# StyleCop\nStyleCopReport.xml\n\n# Files built by Visual Studio\n*_i.c\n*_p.c\n*_h.h\n*.ilk\n*.meta\n*.obj\n*.iobj\n*.pch\n*.pdb\n*.ipdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*_wpftmp.csproj\n*.log\n*.tlog\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*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# Visual Studio Trace Files\n*.e2e\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# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# AxoCover is a Code Coverage Tool\n.axoCover/*\n!.axoCover/settings.json\n\n# Coverlet is a free, cross platform Code Coverage Tool\ncoverage*.json\ncoverage*.xml\ncoverage*.info\n\n# Visual Studio code coverage results\n*.coverage\n*.coveragexml\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# Note: Comment the next line if you want to checkin your web deploy settings,\n# but database connection strings (with potential passwords) will be unencrypted\n*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# NuGet Symbol Packages\n*.snupkg\n# The packages folder can be ignored because of Package Restore\n**/[Pp]ackages/*\n# except build/, which is used as an MSBuild target.\n!**/[Pp]ackages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/[Pp]ackages/repositories.config\n# NuGet v3's project.json files produces more ignorable 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# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n*.appx\n*.appxbundle\n*.appxupload\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~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\norleans.codegen.cs\n\n# Including strong name files can present a security risk\n# (https://github.com/github/gitignore/pull/2483#issue-259490424)\n#*.snk\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\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\nServiceFabricBackup/\n*.rptproj.bak\n\n# SQL Server files\n*.mdf\n*.ldf\n*.ndf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n*.rptproj.rsuser\n*- [Bb]ackup.rdl\n*- [Bb]ackup ([0-9]).rdl\n*- [Bb]ackup ([0-9][0-9]).rdl\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\nnode_modules/\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)\n*.vbw\n\n# Visual Studio 6 auto-generated project file (contains which files were open etc.)\n*.vbp\n\n# Visual Studio 6 workspace and project file (working project files containing files to include in project)\n*.dsw\n*.dsp\n\n# Visual Studio 6 technical files\n*.ncb\n*.aps\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# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# CodeRush personal settings\n.cr/personal\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n# Cake - Uncomment if you are using it\n# tools/**\n# !tools/packages.config\n\n# Tabs Studio\n*.tss\n\n# Telerik's JustMock configuration file\n*.jmconfig\n\n# BizTalk build output\n*.btp.cs\n*.btm.cs\n*.odx.cs\n*.xsd.cs\n\n# OpenCover UI analysis results\nOpenCover/\n\n# Azure Stream Analytics local run output\nASALocalRun/\n\n# MSBuild Binary and Structured Log\n*.binlog\n\n# NVidia Nsight GPU debugger configuration file\n*.nvuser\n\n# MFractors (Xamarin productivity tool) working folder\n.mfractor/\n\n# Local History for Visual Studio\n.localhistory/\n\n# Visual Studio History (VSHistory) files\n.vshistory/\n\n# BeatPulse healthcheck temp database\nhealthchecksdb\n\n# Backup folder for Package Reference Convert tool in Visual Studio 2017\nMigrationBackup/\n\n# Ionide (cross platform F# VS Code tools) working folder\n.ionide/\n\n# Fody - auto-generated XML schema\nFodyWeavers.xsd\n\n# VS Code files for those working on multiple tools\n.vscode/*\n!.vscode/settings.json\n!.vscode/tasks.json\n!.vscode/launch.json\n!.vscode/extensions.json\n*.code-workspace\n\n# Local History for Visual Studio Code\n.history/\n\n# Windows Installer files from build outputs\n*.cab\n*.msi\n*.msix\n*.msm\n*.msp\n\n# JetBrains Rider\n*.sln.iml\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\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 3 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, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "\n# 🐜 SmolSharp\nSmolSharp is a repository that demonstrates the ability to use NativeAOT to build extremely small binaries without any kind of external utility or linker. For example, for a simple hello world program, by default, NAOT produces a binary that is `2998272` bytes in size with the following properties:\n```xml\n<PublishAot>true</PublishAot>\n<Optimize>true</Optimize>\n<OptimizationPreference>Size</OptimizationPreference>\n<PublishTrimmed>true</PublishTrimmed>\n```\nWith the `SmolSharp.props` file being imported, the compiler produces a binary that is only `2021` bytes in size - a 0.07% of the original file-size.\n\n## Project overview\n| Project Name     | Binary size | Description                                                        |\n| ---------------- | ----------- | ------------------------------------------------------------------ |\n| HelloWorld       | 2021 B      | A console program that outputs \"Hello World\".\n| Mandelbrot       | 2879 B      | A windowed program that renders a fractal (the Mandelbrot set).\n| Ocean            | 7316 B      | A windowed OpenGL program that renders a ray-marched stylized ocean.\n\nAs of pull-request [Compile as x86](https://github.com/ascpixi/smolsharp/pull/3) by [Michal Strehovský](https://github.com/MichalStrehovsky), the projects may also be compiled in 32-bit mode, which reduces file sizes even further:\n\n| Project Name     | Binary size | Description                                                        |\n| ---------------- | ----------- | ------------------------------------------------------------------ |\n| HelloWorld       | 1711 B      | A console program that outputs \"Hello World\".\n| Mandelbrot       | 2299 B      | A windowed program that renders a fractal (the Mandelbrot set).\n| Ocean            | 5832 B      | A windowed OpenGL program that renders a ray-marched stylized ocean.\n\nYou may find this version in the [`/bit32`](https://github.com/ascpixi/smolsharp/tree/bit32) branch.\n\nhttps://github.com/ascpixi/smolsharp/assets/44982772/c70e1e20-7cef-473d-bbf5-67079bec2487\n###### Screen capture of the Ocean demo\n\n## Inner-workings\nAll of the functionality of SmolSharp is contained in the `SmolSharp.props` file. The following techniques are employed in order to achieve minimal binary sizes:\n1.  **Custom standard library** - SmolSharp uses the [bflat zerolib](https://github.com/bflattened/bflat/tree/master/src/zerolib) standard library, serving as the primary size-saving technique. However, this results in the lack of any kind of GC and removes all built-in BCL classes and functionality, requiring the use of raw P/Invokes to interface with Windows' APIs.\n2. **Raw P/Invokes** - all external `[DllImport]` declarations are specified in the `<DirectPInvoke>` list in the MSBuild `.props` file, removing the need for a dynamic loader. To prevent redundant `RhpReversePInvoke` calls, every `[DllImport]` is marked with the `[SuppressGCTransition]` attribute.\n3. **ILC configuration** - several MSBuild properties instruct the IL compiler (ILC) to optimize and generate code with binary size as its top priority. All Win32 resources (usually embedded in the `.rsrc` section) are omitted by setting the internal property `_Win32ResFile` to an empty string, in a target that executes before the `LinkNative` target (or for .NET 8+, by setting an undocumented property).\n4. **Native object file manipulation** - the alignment of all sections in the native object file is set to their minimum accepted value using `objcopy`. Additionally, since no exception handling is used, the SEH exception data directory (the `.pdata` section) is removed.\n5. **Linker flags** - several MSVC linker flags are specified, significantly reducing the size of the final binary image:\n\t- `/align:16` - sets section alignment to 16 bytes, which, based on testing, is the minimum accepted value\n\t- `/manifestuac:no` - forces the linker to never embed any UAC manifest\n\t- `/opt:ref /opt:icf` - enables linker reference optimization\n\t- `/safeseh:no` - allows the linker to skip embedding SEH data\n\t- `/emittoolversioninfo:no` - removes linker/compiler version information (the Rich header). **Undocumented.**\n\t- `/emitpogophaseinfo` - removes the debug directory from the final output. **Undocumented.**\n\t- `/nodefaultlib` - excludes CRT libraries from the binary\n\t- `/fixed` - instructs the operating system to load the binary at a static address, disabling relocations and making the linker skip emitting the `.reloc` section\n\t- `/merge:.modules=.rdata` - merges the `.modules` and `.rdata` sections due to their identical attributes\n\t- `/merge:.managedcode=.text` - merges the `.managedcode` and `.text` sections due to their identical attributes\n6. **Finishing touches** - all trailing null bytes are stripped from the binary.\n\nPlease note that these steps also may be performed without the use of MSBuild - this is demonstrated by the [`MichalStrehovsky/zerosharp`](https://github.com/MichalStrehovsky/zerosharp) repository.\n\n## Caveats\nAs mentioned in the [Inner-workings](#Inner-workings) section, the lack of a GC means that object allocations are frowned upon, and all memory retrieved via dynamic allocation should be disposed of manually, similarly to C. As all of the BCL classes are missing, this also means that they have to be either re-implemented, or alternatives need to be used, like the host OS's built-in APIs. This project also only works on Windows - it depends on importing Win32 classes, and assumes the output binary format is PE, which is only majorly supported by NT-based OS's.\n\n## Potential improvements\nAs this repository focuses on avoiding any kind of external tools, the default MSVC linker was used. However, specialized linkers such as the [Crinkler](https://github.com/runestubbe/Crinkler) may be used in order to compress the whole binary and avoid any unnecessary sections. \n\n## Building\nIn order to build any given project, in the project's root folder (near the .csproj file), simply run:\n```console\ndotnet publish -r win-x64 -c release\n```\n\nFor the OpenGL ocean demo, you can quickly compress a GLSL fragment shader by using the `ShaderCompressor` project, included with the repository. The shader compressor is a simple C++ program that uses Windows's built-in cabinet compression API in order to create byte arrays that can then be consumed by the compiled application. It's recommended to also minify your shader - for example, with [`laurentlb/Shader_Minifier`](https://github.com/laurentlb/Shader_Minifier). The `shaderpkg` batch file will use the `shader_minifier` binary in the `./tools` directory. The main fragment shader for `SmolSharp.Ocean` is located in `./src/SmolSharp.Ocean/Shaders/frag.glsl`.\n"
  },
  {
    "path": "shaderpkg.bat",
    "content": "@echo off\n\"./tools/shader_minifier.exe\" -o minified.glsl --format text --smoothstep --aggressive-inlining %1\n\"./src/ShaderCompressor/bin/x64/Release/ShaderCompressor.exe\" minified.glsl compressed.txt\n"
  },
  {
    "path": "src/BFlat.ZeroLib/BFlat.ZeroLib.projitems",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup>\n    <MSBuildAllProjects Condition=\"'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'\">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>\n    <HasSharedItems>true</HasSharedItems>\n    <SharedGUID>5898fe8d-6758-42d0-9303-2aeaae32c47b</SharedGUID>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\">\n    <Import_RootNamespace>BFlat.ZeroLib</Import_RootNamespace>\n  </PropertyGroup>\n  <ItemGroup>\n    <Compile Include=\"$(MSBuildThisFileDirectory)Internal\\Startup.Efi.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)Internal\\Startup.Unix.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)Internal\\Startup.Windows.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)Internal\\Stubs.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\AppContext.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Array.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Attribute.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Console.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Console.Efi.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Console.Unix.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Console.Windows.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Delegate.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Enum.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Environment.Efi.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Environment.Unix.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Environment.Windows.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Nullable.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Object.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Primitives.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\ReadOnlySpan.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Reflection\\ReflectionAttributes.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\RuntimeHandles.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Runtime\\CompilerServices\\ClassConstructorRunner.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Runtime\\CompilerServices\\CompilerAttributes.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Runtime\\CompilerServices\\RuntimeFeature.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Runtime\\CompilerServices\\RuntimeHelpers.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Runtime\\CompilerServices\\Unsafe.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Runtime\\InteropServices\\InteropAttributes.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Runtime\\InteropServices\\MemoryMarshal.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\String.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Thread.Efi.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Thread.Unix.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Thread.Windows.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\Type.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\ValueTuple.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)System\\ValueType.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)UnmanagedExports.cs\" />\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "src/BFlat.ZeroLib/BFlat.ZeroLib.shproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>5898fe8d-6758-42d0-9303-2aeaae32c47b</ProjectGuid>\n    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\n  </PropertyGroup>\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.Default.props\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.props\" />\n  <PropertyGroup />\n  <Import Project=\"BFlat.ZeroLib.projitems\" Label=\"Shared\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.CSharp.targets\" />\n</Project>\n"
  },
  {
    "path": "src/BFlat.ZeroLib/Internal/Startup.Efi.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if UEFI\n\nusing System;\nusing System.Runtime;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\nnamespace Internal.Runtime.CompilerHelpers\n{\n    unsafe partial class StartupCodeHelpers\n    {\n        internal static EFI_SYSTEM_TABLE* s_efiSystemTable;\n\n        [RuntimeImport(\"*\", \"__managed__Main\")]\n        [MethodImpl(MethodImplOptions.InternalCall)]\n        static extern int ManagedMain(int argc, char** argv);\n\n        [RuntimeExport(\"EfiMain\")]\n        static long EfiMain(IntPtr imageHandle, EFI_SYSTEM_TABLE* systemTable)\n        {\n            s_efiSystemTable = systemTable;\n            ManagedMain(0, null);\n\n            while (true) ;\n        }\n\n        internal static unsafe void InitializeCommandLineArgsW(int argc, char** argv)\n        {\n            // argc and argv are garbage because EfiMain didn't pass any\n        }\n\n        private static string[] GetMainMethodArguments()\n        {\n            return new string[0];\n        }\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    struct EFI_HANDLE\n    {\n        private IntPtr _handle;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    unsafe readonly struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL\n    {\n        private readonly IntPtr _pad0;\n        public readonly delegate* unmanaged<void*, char*, void*> OutputString;\n        private readonly IntPtr _pad1;\n        private readonly IntPtr _pad2;\n        private readonly IntPtr _pad3;\n        public readonly delegate* unmanaged<void*, uint, void> SetAttribute;\n        private readonly IntPtr _pad4;\n        public readonly delegate* unmanaged<void*, uint, uint, void> SetCursorPosition;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    readonly struct EFI_INPUT_KEY\n    {\n        public readonly ushort ScanCode;\n        public readonly ushort UnicodeChar;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    unsafe readonly struct EFI_SIMPLE_TEXT_INPUT_PROTOCOL\n    {\n        private readonly IntPtr _pad0;\n        public readonly delegate*<void*, EFI_INPUT_KEY*, ulong> ReadKeyStroke;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    readonly struct EFI_TABLE_HEADER\n    {\n        public readonly ulong Signature;\n        public readonly uint Revision;\n        public readonly uint HeaderSize;\n        public readonly uint Crc32;\n        public readonly uint Reserved;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    unsafe readonly struct EFI_SYSTEM_TABLE\n    {\n        public readonly EFI_TABLE_HEADER Hdr;\n        public readonly char* FirmwareVendor;\n        public readonly uint FirmwareRevision;\n        public readonly EFI_HANDLE ConsoleInHandle;\n        public readonly EFI_SIMPLE_TEXT_INPUT_PROTOCOL* ConIn;\n        public readonly EFI_HANDLE ConsoleOutHandle;\n        public readonly EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* ConOut;\n        public readonly EFI_HANDLE StandardErrorHandle;\n        public readonly EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* StdErr;\n        public readonly EFI_RUNTIME_SERVICES* RuntimeServices;\n        public readonly EFI_BOOT_SERVICES* BootServices;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    struct EFI_TIME\n    {\n        public ushort Year;\n        public byte Month;\n        public byte Day;\n        public byte Hour;\n        public byte Minute;\n        public byte Second;\n        public byte Pad1;\n        public uint Nanosecond;\n        public short TimeZone;\n        public byte Daylight;\n        public byte PAD2;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    unsafe readonly struct EFI_RUNTIME_SERVICES\n    {\n        public readonly EFI_TABLE_HEADER Hdr;\n        public readonly delegate*<EFI_TIME*, void*, ulong> GetTime;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    unsafe readonly struct EFI_BOOT_SERVICES\n    {\n        readonly EFI_TABLE_HEADER Hdr;\n        private readonly void* pad0;\n        private readonly void* pad1;\n        private readonly void* pad2;\n        private readonly void* pad3;\n        private readonly void* pad4;\n        public readonly delegate*<int, nint, void**, ulong> AllocatePool;\n        private readonly void* pad6;\n        private readonly void* pad7;\n        private readonly void* pad8;\n        private readonly void* pad9;\n        private readonly void* pad10;\n        private readonly void* pad11;\n        private readonly void* pad12;\n        private readonly void* pad13;\n        private readonly void* pad14;\n        private readonly void* pad15;\n        private readonly void* pad16;\n        private readonly void* pad17;\n        private readonly void* pad18;\n        private readonly void* pad19;\n        private readonly void* pad20;\n        private readonly void* pad21;\n        private readonly void* pad22;\n        private readonly void* pad23;\n        private readonly void* pad24;\n        private readonly void* pad25;\n        private readonly void* pad26;\n        private readonly void* pad27;\n        public readonly delegate*<uint, ulong> Stall;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/Internal/Startup.Unix.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if LINUX\n\nusing System;\nusing System.Runtime;\nusing System.Runtime.InteropServices;\n\nnamespace Internal.Runtime.CompilerHelpers\n{\n    unsafe partial class StartupCodeHelpers\n    {\n        static int s_argc;\n        static sbyte** s_argv;\n\n        internal static unsafe void InitializeCommandLineArgs(int argc, sbyte** argv)\n        {\n            s_argc = argc;\n            s_argv = argv;\n        }\n\n        private static string[] GetMainMethodArguments()\n        {\n            string[] args = new string[s_argc - 1];\n            for (int i = 1; i < s_argc; ++i)\n            {\n                args[i - 1] = new string(s_argv[i]);\n            }\n\n            return args;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/Internal/Startup.Windows.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if WINDOWS\n\nusing System;\nusing System.Runtime;\nusing System.Runtime.InteropServices;\n\nnamespace Internal.Runtime.CompilerHelpers\n{\n    unsafe partial class StartupCodeHelpers\n    {\n        internal static unsafe void InitializeCommandLineArgsW(int argc, char** argv)\n        {\n            // argc and argv are a lie because CRT didn't start the process on Windows\n        }\n\n        private static string[] GetMainMethodArguments()\n        {\n            int argc;\n            char** argv = CommandLineToArgvW(GetCommandLineW(), &argc);\n\n            [DllImport(\"kernel32\")]\n            static extern char* GetCommandLineW();\n\n            [DllImport(\"shell32\")]\n            static extern char** CommandLineToArgvW(char* lpCmdLine, int* pNumArgs);\n\n            string[] args = new string[argc - 1];\n            for (int i = 1; i < argc; ++i)\n            {\n                args[i - 1] = new string(argv[i]);\n            }\n\n            return args;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/Internal/Stubs.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nusing System;\nusing System.Runtime;\nusing System.Runtime.InteropServices;\nusing System.Runtime.CompilerServices;\n\nnamespace System.Runtime\n{\n    internal sealed class RuntimeExportAttribute : Attribute\n    {\n        public RuntimeExportAttribute(string entry) { }\n    }\n\n    internal sealed class RuntimeImportAttribute : Attribute\n    {\n        public RuntimeImportAttribute(string lib) { }\n        public RuntimeImportAttribute(string lib, string entry) { }\n    }\n\n    internal unsafe struct MethodTable\n    {\n        internal ushort _usComponentSize;\n        private ushort _usFlags;\n        internal uint _uBaseSize;\n        internal MethodTable* _relatedType;\n        private ushort _usNumVtableSlots;\n        private ushort _usNumInterfaces;\n        private uint _uHashCode;\n    }\n}\n\nnamespace Internal.Runtime.CompilerHelpers\n{\n    static class ThrowHelpers\n    {\n        static void ThrowIndexOutOfRangeException() => Environment.FailFast(null);\n        static void ThrowDivideByZeroException() => Environment.FailFast(null);\n    }\n\n    static class InteropHelpers\n    {\n\n    }\n\n    // A class that the compiler looks for that has helpers to initialize the\n    // process. The compiler can gracefully handle the helpers not being present,\n    // but the class itself being absent is unhandled. Let's add an empty class.\n    unsafe partial class StartupCodeHelpers\n    {\n        // A couple symbols the generated code will need we park them in this class\n        // for no particular reason. These aid in transitioning to/from managed code.\n        // Since we don't have a GC, the transition is a no-op.\n        [RuntimeExport(\"RhpReversePInvoke\")]\n        static void RhpReversePInvoke() { }\n\n        [RuntimeExport(\"RhpReversePInvokeReturn\")]\n        static void RhpReversePInvokeReturn() { }\n\n        [RuntimeExport(\"RhpPInvoke\")]\n        static void RhpPInvoke() { }\n\n        [RuntimeExport(\"RhpPInvokeReturn\")]\n        static void RhpPInvokeReturn() { }\n\n        [RuntimeExport(\"RhpFallbackFailFast\")]\n        static void RhpFallbackFailFast()\n        {\n#if PERFORM_CHECKS\n            Environment.FailFast(null);\n#endif\n        }\n\n        [RuntimeExport(\"RhpNewFast\")]\n        static unsafe void* RhpNewFast(MethodTable* pMT)\n        {\n            MethodTable** result = AllocObject(pMT->_uBaseSize);\n            *result = pMT;\n            return result;\n        }\n\n        [RuntimeExport(\"RhpNewArray\")]\n        static unsafe void* RhpNewArray(MethodTable* pMT, int numElements)\n        {\n#if PERFORM_CHECKS\n            if (numElements < 0)\n                Environment.FailFast(null);\n#endif\n\n            MethodTable** result = AllocObject((uint)(pMT->_uBaseSize + numElements * pMT->_usComponentSize));\n            *result = pMT;\n            *(int*)(result + 1) = numElements;\n            return result;\n        }\n\n        // These are exported, so that SuppressGCTransition works.\n        // SuppressGCTransition avoids generating calls to RhpReversePInvoke\n        // (an empty method, in our case), which saves us a lot of bytes.\n        // (warning: this is not present in the original BFlat zerolib!)\n        [RuntimeExport(\"RhpGcPoll\")]\n        static void RhpGcPoll() { }\n\n        [RuntimeExport(\"RhpTrapThreads\")]\n        static void RhpTrapThreads() { }\n\n        internal struct ArrayElement\n        {\n            public object Value;\n        }\n\n        [RuntimeExport(\"RhpStelemRef\")]\n        public static unsafe void StelemRef(Array array, nint index, object obj)\n        {\n            ref object element = ref Unsafe.As<ArrayElement[]>(array)[index].Value;\n\n            MethodTable* elementType = array.m_pMethodTable->_relatedType;\n\n            if (obj == null)\n                goto assigningNull;\n\n#if PERFORM_CHECKS\n            if (elementType != obj.m_pMethodTable)\n                Environment.FailFast(null); /* covariance */\n#endif\n\ndoWrite:\n            element = obj;\n            return;\n\nassigningNull:\n            element = null;\n            return;\n        }\n\n        [RuntimeExport(\"RhpCheckedAssignRef\")]\n        public static unsafe void RhpCheckedAssignRef(void** dst, void* r)\n        {\n            *dst = r;\n        }\n\n        [RuntimeExport(\"RhpAssignRef\")]\n        public static unsafe void RhpAssignRef(void** dst, void* r)\n        {\n            *dst = r;\n        }\n\n        static unsafe MethodTable** AllocObject(uint size)\n        {\n#if WINDOWS\n            [DllImport(\"kernel32\")]\n            static extern MethodTable** LocalAlloc(uint flags, uint size);\n            MethodTable** result = LocalAlloc(0x40, size);\n#elif LINUX\n            [DllImport(\"libSystem.Native\")]\n            static extern MethodTable** SystemNative_Malloc(nuint size);\n            MethodTable** result = SystemNative_Malloc(size);\n#elif UEFI\n            MethodTable** result;\n            StartupCodeHelpers.s_efiSystemTable->BootServices->AllocatePool(2 /* LoaderData*/, (nint)size, (void**)&result);\n#endif\n\n            return result;\n        }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/AppContext.cs",
    "content": "﻿using System;\n\nnamespace System\n{\n    public static class AppContext\n    {\n        public static void SetData(string name, object? data) { }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Array.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public abstract class Array\n    {\n        private readonly int _length;\n\n        public int Length => _length;\n    }\n\n    class Array<T> : Array { }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Attribute.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public abstract class Attribute { }\n\n    public enum AttributeTargets { }\n\n    public sealed class AttributeUsageAttribute : Attribute\n    {\n        //Constructors \n        public AttributeUsageAttribute(AttributeTargets validOn) \n        {\n        }\n\n       public bool AllowMultiple\n       {\n           get { return false; }\n           set { }\n       }\n\n       public bool Inherited\n       {\n           get { return false; }\n           set { }\n       }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Console.Efi.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if UEFI\n\nusing Internal.Runtime.CompilerHelpers;\n\nnamespace System\n{\n    public static unsafe partial class Console\n    {\n        public static unsafe void Write(char c)\n        {\n            int cc = c;\n            EFI_SYSTEM_TABLE* tbl = StartupCodeHelpers.s_efiSystemTable;\n            tbl->ConOut->OutputString(tbl->ConOut, (char*)&cc);\n        }\n\n        public static unsafe ConsoleColor ForegroundColor\n        {\n            set\n            {\n                EFI_SYSTEM_TABLE* tbl = StartupCodeHelpers.s_efiSystemTable;\n                tbl->ConOut->SetAttribute(tbl->ConOut, (uint)value);\n            }\n        }\n\n        public static void SetCursorPosition(int x, int y)\n        {\n            EFI_SYSTEM_TABLE* tbl = StartupCodeHelpers.s_efiSystemTable;\n            tbl->ConOut->SetCursorPosition(\n                tbl->ConOut,\n                (uint)x,\n                (uint)y);\n        }\n\n        static char s_keyBuffer;\n        static ushort s_scanCodeBuffer;\n\n        private static unsafe bool FillBuffer()\n        {\n            if (s_scanCodeBuffer == 0)\n            {\n                EFI_INPUT_KEY key;\n                EFI_SYSTEM_TABLE* tbl = StartupCodeHelpers.s_efiSystemTable;\n                if (tbl->ConIn->ReadKeyStroke(tbl->ConIn, &key) == 0)\n                {\n                    s_keyBuffer = (char)key.UnicodeChar;\n                    s_scanCodeBuffer = key.ScanCode;\n                    return true;\n                }\n                return false;\n            }\n            return true;\n        }\n\n        public static bool KeyAvailable => FillBuffer();\n\n        public static ConsoleKeyInfo ReadKey(bool intercept)\n        {\n            if (FillBuffer())\n            {\n                ConsoleKey key = s_scanCodeBuffer switch\n                {\n                    1 => ConsoleKey.UpArrow,\n                    2 => ConsoleKey.DownArrow,\n                    3 => ConsoleKey.RightArrow,\n                    4 => ConsoleKey.LeftArrow,\n                    _ => default(ConsoleKey),\n                };\n                s_scanCodeBuffer = 0;\n                return new ConsoleKeyInfo(s_keyBuffer, key, false, false, false);\n            }\n            return default;\n        }\n\n        public static unsafe void SetWindowSize(int x, int y)\n        {\n        }\n\n        public static void SetBufferSize(int x, int y)\n        {\n        }\n\n        public static unsafe string Title\n        {\n            set\n            {\n                _ = value;\n            }\n        }\n\n        public static unsafe bool CursorVisible\n        {\n            set\n            {\n                _ = value;\n            }\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Console.Unix.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if LINUX\n\nusing System.Runtime.InteropServices;\n\nnamespace System\n{\n    public static unsafe partial class Console\n    {\n        public static unsafe string Title\n        {\n            set\n            {\n                _ = value;\n            }\n        }\n\n        public static unsafe bool CursorVisible\n        {\n            set\n            {\n                _ = value;\n            }\n        }\n\n        public static unsafe void SetWindowSize(int x, int y)\n        {\n        }\n\n        public static void SetBufferSize(int x, int y)\n        {\n        }\n\n        public static ConsoleColor ForegroundColor\n        {\n            set\n            {\n                ConsoleColor adjusted = value;\n                if (value >= ConsoleColor.DarkBlue && value <= ConsoleColor.Gray)\n                    adjusted = value - ConsoleColor.DarkBlue + ConsoleColor.Blue;\n                int colorCode = adjusted switch\n                {\n                    ConsoleColor.Black => 30,\n                    ConsoleColor.Blue => 34,\n                    ConsoleColor.Green => 32,\n                    ConsoleColor.Cyan => 36,\n                    ConsoleColor.Red => 31,\n                    ConsoleColor.Magenta => 35,\n                    ConsoleColor.Yellow => 33,\n                    _ => 37,\n                };\n                byte* pBuf = stackalloc byte[16];\n                pBuf[0] = 0x1B;\n                pBuf[1] = (byte)'[';\n                byte* pCur = Append(&pBuf[2], colorCode);\n                *pCur++ = (byte)'m';\n                SystemNative_Log(pBuf, (int)(pCur - pBuf));\n            }\n        }\n\n        public static void SetCursorPosition(int x, int y)\n        {\n            byte* pBuf = stackalloc byte[32];\n            pBuf[0] = 0x1B;\n            pBuf[1] = (byte)'[';\n            byte* cur = Append(&pBuf[2], y);\n            *cur++ = (byte)';';\n            cur = Append(cur, x);\n            *cur++ = (byte)'H';\n            SystemNative_Log(pBuf, (int)(cur - pBuf));\n        }\n\n        static byte* Append(byte* b, int x)\n        {\n            if (x >= 10)\n                b = Append(b, x / 10);\n            *b = (byte)((x % 10) + '0');\n            return ++b;\n        }\n\n        [DllImport(\"libSystem.Native\")]\n        private static extern void SystemNative_Log(void* pBuffer, int length);\n\n        public static void Write(char c)\n        {\n            if (c <= 0x7F)\n            {\n                SystemNative_Log(&c, 1);\n            }\n            else if (c <= 0x7FF)\n            {\n                ushort twoByte;\n                byte* pOut = (byte*)&twoByte;\n                *pOut++ = (byte)(0xC0 | (c >> 6));\n                *pOut++ = (byte)(0x80 | (c & 0x3F));\n                SystemNative_Log(&twoByte, 2);\n            }\n            else\n            {\n                int threeByte;\n                byte* pOut = (byte*)&threeByte;\n                *pOut++ = (byte)(0xE0 | (c >> 12));\n                *pOut++ = (byte)(0x80 | ((c >> 6) & 0x3F));\n                *pOut++ = (byte)(0x80 | (c & 0x3F));\n                SystemNative_Log(&threeByte, 3);\n            }\n        }\n\n        public static bool KeyAvailable => StdInReader.KeyAvailable();\n\n        public static ConsoleKeyInfo ReadKey(bool intercept) => StdInReader.ReadKey();\n\n        static class StdInReader\n        {\n            static StdInReader()\n            {\n                SystemNative_InitializeTerminalAndSignalHandling();\n\n                [DllImport(\"libSystem.Native\")]\n                static extern int SystemNative_InitializeTerminalAndSignalHandling();\n            }\n\n            private static StdInBuffer s_buffer;\n            \n            struct StdInBuffer\n            {\n                public const int Size = 256;\n                public int StartIndex;\n                public int EndIndex;\n                public bool Empty => StartIndex >= EndIndex;\n                public fixed char Chars[Size];\n            }\n\n            public static bool KeyAvailable()\n            {\n                return SystemNative_StdinReady(1) != 0;\n\n                [DllImport(\"libSystem.Native\")]\n                static extern int SystemNative_StdinReady(int distinguishNewLines);\n            }\n\n            public static ConsoleKeyInfo ReadKey()\n            {\n                SystemNative_InitializeConsoleBeforeRead(0, 1, 0);\n\n                [DllImport(\"libSystem.Native\")]\n                static extern void SystemNative_InitializeConsoleBeforeRead(int distinguishNewLines, byte minChars, byte decisecondsTimeout);\n\n                try\n                {\n                    if (s_buffer.Empty)\n                    {\n                        byte* bufPtr = stackalloc byte[StdInBuffer.Size];\n                        int result = SystemNative_ReadStdin(bufPtr, StdInBuffer.Size);\n\n                        [DllImport(\"libSystem.Native\")]\n                        static extern unsafe int SystemNative_ReadStdin(byte* buffer, int bufferSize);\n\n                        if (result <= 0)\n                        {\n                            return default;\n                        }\n                        s_buffer.StartIndex = 0;\n                        s_buffer.EndIndex = result;\n                        for (int i = 0; i < result; i++)\n                        {\n                            char c = (char)bufPtr[i];\n                            if (c > 0x7F)\n                                Environment.FailFast(null);\n                            s_buffer.Chars[i] = c;\n                        }\n                    }\n\n                    if (s_buffer.EndIndex - s_buffer.StartIndex >= 3 &&\n                        s_buffer.Chars[s_buffer.StartIndex] == 0x1B &&\n                        s_buffer.Chars[s_buffer.StartIndex + 1] == '[')\n                    {\n                        char code = s_buffer.Chars[s_buffer.StartIndex + 2];\n                        s_buffer.StartIndex += 3;\n                        switch (code)\n                        {\n                            case 'A':\n                                return new ConsoleKeyInfo(default, ConsoleKey.UpArrow, false, false, false);\n                            case 'B':\n                                return new ConsoleKeyInfo(default, ConsoleKey.DownArrow, false, false, false);\n                            case 'C':\n                                return new ConsoleKeyInfo(default, ConsoleKey.RightArrow, false, false, false);\n                            case 'D':\n                                return new ConsoleKeyInfo(default, ConsoleKey.LeftArrow, false, false, false);\n                            default:\n                                Environment.FailFast(null);\n                                return default;\n                        }\n                    }\n\n                    return default;\n                    \n                }\n                finally\n                {\n                    SystemNative_UninitializeConsoleAfterRead();\n\n                    [DllImport(\"libSystem.Native\")]\n                    static extern void SystemNative_UninitializeConsoleAfterRead();\n                }\n            }\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Console.Windows.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if WINDOWS\n\nusing System.Runtime.InteropServices;\n\nnamespace System\n{\n    public static partial class Console\n    {\n        private enum BOOL : int\n        {\n            FALSE = 0,\n            TRUE = 1,\n        }\n\n        [DllImport(\"kernel32\")]\n        private static unsafe extern IntPtr GetStdHandle(int c);\n\n        private readonly static IntPtr s_outputHandle = GetStdHandle(-11);\n\n        private readonly static IntPtr s_inputHandle = GetStdHandle(-10);\n\n        [DllImport(\"kernel32\", EntryPoint = \"SetConsoleTitleW\")]\n        private static unsafe extern BOOL SetConsoleTitle(char* c);\n\n        public static unsafe string Title\n        {\n            set\n            {\n                fixed (char* c = value)\n                    SetConsoleTitle(c);\n            }\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        struct CONSOLE_CURSOR_INFO\n        {\n            public uint Size;\n            public BOOL Visible;\n        }\n\n        [DllImport(\"kernel32\")]\n        private static unsafe extern BOOL SetConsoleCursorInfo(IntPtr handle, CONSOLE_CURSOR_INFO* cursorInfo);\n\n        public static unsafe bool CursorVisible\n        {\n            set\n            {\n                CONSOLE_CURSOR_INFO cursorInfo = new CONSOLE_CURSOR_INFO\n                {\n                    Size = 1,\n                    Visible = value ? BOOL.TRUE : BOOL.FALSE\n                };\n                SetConsoleCursorInfo(s_outputHandle, &cursorInfo);\n            }\n        }\n\n        [DllImport(\"kernel32\")]\n        private static unsafe extern BOOL SetConsoleTextAttribute(IntPtr handle, ushort attribute);\n\n        public static ConsoleColor ForegroundColor\n        {\n            set\n            {\n                SetConsoleTextAttribute(s_outputHandle, (ushort)value);\n            }\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        private struct KEY_EVENT_RECORD\n        {\n            public BOOL KeyDown;\n            public short RepeatCount;\n            public short VirtualKeyCode;\n            public short VirtualScanCode;\n            public short UChar;\n            public int ControlKeyState;\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        private struct INPUT_RECORD\n        {\n            public short EventType;\n            public KEY_EVENT_RECORD KeyEvent;\n        }\n\n        [DllImport(\"kernel32\", EntryPoint = \"PeekConsoleInputW\", CharSet = CharSet.Unicode)]\n        private static unsafe extern BOOL PeekConsoleInput(IntPtr hConsoleInput, INPUT_RECORD* lpBuffer, uint nLength, uint* lpNumberOfEventsRead);\n\n        public static unsafe bool KeyAvailable\n        {\n            get\n            {\n                uint nRead;\n                INPUT_RECORD buffer;\n                while (true)\n                {\n                    PeekConsoleInput(s_inputHandle, &buffer, 1, &nRead);\n\n                    if (nRead == 0)\n                        return false;\n\n                    if (buffer.EventType == 1 && buffer.KeyEvent.KeyDown != BOOL.FALSE)\n                        return true;\n\n                    ReadConsoleInput(s_inputHandle, &buffer, 1, &nRead);\n                }\n            }\n        }\n\n        [DllImport(\"kernel32\", EntryPoint = \"ReadConsoleInputW\", CharSet = CharSet.Unicode)]\n        private static unsafe extern BOOL ReadConsoleInput(IntPtr hConsoleInput, INPUT_RECORD* lpBuffer, uint nLength, uint* lpNumberOfEventsRead);\n\n        public static unsafe ConsoleKeyInfo ReadKey()\n        {\n            uint nRead;\n            INPUT_RECORD buffer;\n            do\n            {\n                ReadConsoleInput(s_inputHandle, &buffer, 1, &nRead);\n            }\n            while (buffer.EventType != 1 || buffer.KeyEvent.KeyDown == BOOL.FALSE);\n\n            return new ConsoleKeyInfo((char)buffer.KeyEvent.UChar, (ConsoleKey)buffer.KeyEvent.VirtualKeyCode, false, false, false);\n        }\n\n        struct SMALL_RECT\n        {\n            public short Left, Top, Right, Bottom;\n        }\n\n        [DllImport(\"kernel32\")]\n        private static unsafe extern BOOL SetConsoleWindowInfo(IntPtr handle, BOOL absolute, SMALL_RECT* consoleWindow);\n\n        public static unsafe void SetWindowSize(int x, int y)\n        {\n            SMALL_RECT rect = new SMALL_RECT\n            {\n                Left = 0,\n                Top = 0,\n                Right = (short)(x - 1),\n                Bottom = (short)(y - 1),\n            };\n            SetConsoleWindowInfo(s_outputHandle, BOOL.TRUE, &rect);\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        struct COORD\n        {\n            public short X, Y;\n        }\n\n        [DllImport(\"kernel32\")]\n        private static unsafe extern BOOL SetConsoleScreenBufferSize(IntPtr handle, COORD size);\n\n        public static void SetBufferSize(int x, int y)\n        {\n            SetConsoleScreenBufferSize(s_outputHandle, new COORD { X = (short)x, Y = (short)y });\n        }\n\n        [DllImport(\"kernel32\")]\n        private static unsafe extern BOOL SetConsoleCursorPosition(IntPtr handle, COORD position);\n\n        public static void SetCursorPosition(int x, int y)\n        {\n            SetConsoleCursorPosition(s_outputHandle, new COORD { X = (short)x, Y = (short)y });\n        }\n\n        [DllImport(\"kernel32\", EntryPoint = \"WriteConsoleW\")]\n        private static unsafe extern BOOL WriteConsole(IntPtr handle, void* buffer, int numChars, int* charsWritten, void* reserved);\n\n        public static unsafe void Write(char c)\n        {\n            int dummy;\n            WriteConsole(s_outputHandle, &c, 1, &dummy, null);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Console.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public enum ConsoleColor\n    {\n        Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow,\n        Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White\n    }\n\n    public enum ConsoleKey\n    {\n        Escape = 27,\n        LeftArrow = 37,\n        UpArrow = 38,\n        RightArrow = 39,\n        DownArrow = 40,\n    }\n\n    public readonly struct ConsoleKeyInfo\n    {\n        public ConsoleKeyInfo(char keyChar, ConsoleKey key, bool shift, bool alt, bool control)\n        {\n            Key = key;\n        }\n\n        public readonly ConsoleKey Key;\n    }\n\n    public static unsafe partial class Console\n    {\n        public static void WriteLine(string s)\n        {\n            fixed (char* pStr = s) {\n                for (int i = 0; i < s.Length; i++) {\n                    Write(pStr[i]);\n                }\n            }\n\n#if WINDOWS || UEFI\n            Write('\\r');\n#endif\n            Write('\\n');\n        }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Delegate.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public abstract class Delegate\n    {\n        internal object _firstParameter;\n        internal object _helperObject;\n        internal nint _extraFunctionPointerOrData;\n        internal IntPtr _functionPointer;\n\n        private void InitializeClosedStaticThunk(object firstParameter, IntPtr functionPointer, IntPtr functionPointerThunk)\n        {\n            _extraFunctionPointerOrData = functionPointer;\n            _helperObject = firstParameter;\n            _functionPointer = functionPointerThunk;\n            _firstParameter = this;\n        }\n\n        private void InitializeOpenStaticThunk(object firstParameter, IntPtr functionPointer, IntPtr functionPointerThunk)\n        {\n            _firstParameter = this;\n            _functionPointer = functionPointerThunk;\n            _extraFunctionPointerOrData = functionPointer;\n        }\n\n        private void InitializeClosedInstance(object firstParameter, IntPtr functionPointer)\n        {\n            _functionPointer = functionPointer;\n            _firstParameter = firstParameter;\n        }\n    }\n\n    public abstract class MulticastDelegate : Delegate { }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Enum.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public abstract class Enum : ValueType { }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Environment.Efi.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if UEFI\n\nusing System.Runtime.InteropServices;\nusing Internal.Runtime.CompilerHelpers;\n\nnamespace System\n{\n    public static partial class Environment\n    {\n        public unsafe static void FailFast(string message)\n        {\n            EFI_SYSTEM_TABLE* tbl = StartupCodeHelpers.s_efiSystemTable;\n            fixed (char* pMessage = message)\n            {\n                tbl->ConOut->OutputString(tbl->ConOut, pMessage);\n            }\n            while (true) ;\n        }\n\n        static internal long s_lastTickCount;\n        static internal long s_stallSinceLastTickCount;\n\n        public static unsafe long TickCount64\n        {\n            get\n            {\n                EFI_SYSTEM_TABLE* tbl = StartupCodeHelpers.s_efiSystemTable;\n                EFI_TIME time;\n                tbl->RuntimeServices->GetTime(&time, null);\n                long days = time.Year * 365 + time.Month * 31 + time.Day;\n                long seconds = days * 24 * 60 * 60 + time.Hour * 60 * 60 + time.Minute * 60 + time.Second;\n                long milliseconds = seconds * 1000 + time.Nanosecond / 1000000;\n\n                // HACK: some systems will report a zero Nanosecond part. We keep track of Stall getting\n                // previously called with the same tickcount and artificially inflate the tick count\n                // by the amount of stall if it occured within the same TickCount.\n                if (s_lastTickCount == milliseconds)\n                {\n                    milliseconds += s_stallSinceLastTickCount;\n                }\n                else\n                {\n                    s_lastTickCount = milliseconds;\n                    s_stallSinceLastTickCount = 0;\n                }\n                return milliseconds;\n            }\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Environment.Unix.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if LINUX\n\nusing System.Runtime.InteropServices;\n\nnamespace System\n{\n    public static partial class Environment\n    {\n        [DllImport(\"libSystem.Native\")]\n        public static extern long SystemNative_GetTimestamp();\n\n        public static long TickCount64 => SystemNative_GetTimestamp() / 1_000_000;\n\n        [DllImport(\"libSystem.Native\")]\n        public static extern void SystemNative_Abort();\n\n        public static void FailFast(string message)\n        {\n            SystemNative_Abort();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Environment.Windows.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if WINDOWS\n\nusing System.Runtime.InteropServices;\n\nnamespace System\n{\n    public static partial class Environment\n    {\n        [DllImport(\"kernel32\")]\n        private static extern long GetTickCount64();\n\n        public static long TickCount64 => GetTickCount64();\n\n        [DllImport(\"kernel32\")]\n        private static extern void RaiseFailFastException(IntPtr a, IntPtr b, int flags);\n\n        public static void FailFast(string message)\n        {\n            RaiseFailFastException(default, default, default);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Nullable.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public struct Nullable<T> where T : struct\n    {\n        private readonly bool _hasValue;\n        private T _value;\n\n        public Nullable(T value) => (_hasValue, _value) = (true, value);\n\n        public readonly bool HasValue => _hasValue;\n\n        public readonly T Value\n        {\n            get\n            {\n                if (!_hasValue)\n                    Environment.FailFast(null);\n                return _value;\n            }\n        }\n\n        public static implicit operator Nullable<T>(T value) => new Nullable<T>(value);\n\n        public static explicit operator T(Nullable<T> value) => value.Value;\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Object.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nusing System.Runtime;\n\nnamespace System\n{\n    public class Object\n    {\n#pragma warning disable 169\n        // The layout of object is a contract with the compiler.\n        internal unsafe MethodTable* m_pMethodTable;\n#pragma warning restore 169\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Primitives.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public struct Void { }\n\n    // The layout of primitive types is special cased because it would be recursive.\n    // These really don't need any fields to work.\n    public struct Boolean { }\n    public struct Char { }\n    public struct SByte { }\n    public struct Byte { }\n    public struct Int16 { }\n    public struct UInt16 { }\n    public struct Int32 { }\n    public struct UInt32 { }\n    public struct Int64 { }\n    public struct UInt64 { }\n    public struct IntPtr { }\n    public struct UIntPtr { }\n    public struct Single { }\n    public struct Double { }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/ReadOnlySpan.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\nnamespace System\n{\n    public readonly ref struct ReadOnlySpan<T>\n    {\n        private readonly ref T _reference;\n        public readonly int Length;\n\n        public ReadOnlySpan(in T element)\n        {\n            _reference = element;\n            Length = 1;\n        }\n\n        public ReadOnlySpan(T[] array)\n        {\n            if (array == null) {\n                this = default;\n                return;\n            }\n\n            _reference = ref MemoryMarshal.GetArrayDataReference(array);\n            Length = array.Length;\n        }\n\n        public ReadOnlySpan(T[] array, int start, int length)\n        {\n\n        }\n\n        public unsafe ReadOnlySpan(void* pointer, int length)\n        {\n            _reference = ref Unsafe.As<byte, T>(ref *(byte*)pointer);\n            Length = length;\n        }\n\n        public unsafe T* AsPointer()\n        {\n            return (T*)Unsafe.AsPointer(ref _reference);\n        }\n\n        public ref readonly T this[int index]\n        {\n            [Intrinsic]\n            get\n            {\n                if ((uint)index >= (uint)Length)\n                    Environment.FailFast(null);\n                return ref Unsafe.Add(ref _reference, (nint)(uint)index);\n            }\n        }\n\n        public static implicit operator ReadOnlySpan<T>(T[] array) => new ReadOnlySpan<T>(array);\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Reflection/ReflectionAttributes.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System.Reflection\n{\n    public sealed class DefaultMemberAttribute : Attribute\n    {\n        public DefaultMemberAttribute(string memberName) { }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Runtime/CompilerServices/ClassConstructorRunner.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nusing System.Runtime.InteropServices;\n\nnamespace System.Runtime.CompilerServices\n{\n    // A class responsible for running static constructors. The compiler will call into this\n    // code to ensure static constructors run and that they only run once.\n    internal static class ClassConstructorRunner\n    {\n        private static IntPtr CheckStaticClassConstructionReturnNonGCStaticBase(ref StaticClassConstructionContext context, IntPtr nonGcStaticBase)\n        {\n            CheckStaticClassConstruction(ref context);\n            return nonGcStaticBase;\n        }\n\n        private static unsafe void CheckStaticClassConstruction(ref StaticClassConstructionContext context)\n        {\n            // Not dealing with multithreading issues.\n            if (context.Initialized != 1)\n            {\n                context.Initialized = 1;\n                context.ClassConstructor();\n            }\n        }\n    }\n\n    // This data structure is a contract with the compiler. It holds the address of a static\n    // constructor and a flag that specifies whether the constructor already executed.\n    internal unsafe struct StaticClassConstructionContext\n    {\n        public delegate*<void> ClassConstructor;\n        public int Initialized;\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Runtime/CompilerServices/CompilerAttributes.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System.Runtime.CompilerServices\n{\n    internal sealed class IntrinsicAttribute : Attribute { }\n\n    public enum MethodImplOptions\n    {\n        Unmanaged = 0x0004,\n        NoInlining = 0x0008,\n        ForwardRef = 0x0010,\n        Synchronized = 0x0020,\n        NoOptimization = 0x0040,\n        PreserveSig = 0x0080,\n        AggressiveInlining = 0x0100,\n        AggressiveOptimization = 0x0200,\n        InternalCall = 0x1000\n    }\n\n    public sealed class MethodImplAttribute : Attribute\n    {\n        public MethodImplAttribute(MethodImplOptions methodImplOptions) { }\n    }\n\n    public sealed class IndexerNameAttribute: Attribute\n    {\n        public IndexerNameAttribute(string indexerName) { }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Runtime/CompilerServices/RuntimeFeature.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System.Runtime.CompilerServices\n{\n    public static class RuntimeFeature\n    {\n        public const string PortablePdb = nameof(PortablePdb);\n        public const string DefaultImplementationsOfInterfaces = nameof(DefaultImplementationsOfInterfaces);\n        public const string UnmanagedSignatureCallingConvention = nameof(UnmanagedSignatureCallingConvention);\n        public const string CovariantReturnsOfClasses = nameof(CovariantReturnsOfClasses);\n        public const string ByRefFields = nameof(ByRefFields);\n        public const string VirtualStaticsInInterfaces = nameof(VirtualStaticsInInterfaces);\n        public const string NumericIntPtr = nameof(NumericIntPtr);\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Runtime/CompilerServices/RuntimeHelpers.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nusing System.Runtime.InteropServices;\n\nnamespace System.Runtime.CompilerServices\n{\n    public class RuntimeHelpers\n    {\n        public static unsafe int OffsetToStringData => sizeof(IntPtr) + sizeof(int);\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    internal class RawArrayData\n    {\n        public uint Length; // Array._numComponents padded to IntPtr\n        public uint Padding;\n        public byte Data;\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Runtime/CompilerServices/Unsafe.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System.Runtime.CompilerServices\n{\n    public static unsafe partial class Unsafe\n    {\n        // The body of this method is generated by the compiler.\n        // It will do what Unsafe.Add is expected to do. It's just not possible to express it in C#.\n        [Intrinsic]\n        public static extern ref T Add<T>(ref T source, int elementOffset);\n        [Intrinsic]\n        public static extern ref T Add<T>(ref T source, IntPtr elementOffset);\n        [Intrinsic]\n        public static extern ref TTo As<TFrom, TTo>(ref TFrom source);\n        [Intrinsic]\n        public static extern T As<T>(object o) where T : class;\n        [Intrinsic]\n        public static extern void* AsPointer<T>(ref T value);\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Runtime/InteropServices/InteropAttributes.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System.Runtime.InteropServices\n{\n    public enum CharSet\n    {\n        None = 1,\n        Ansi = 2,\n        Unicode = 3,\n        Auto = 4,\n    }\n\n    public sealed class DllImportAttribute : Attribute\n    {\n        public string EntryPoint;\n        public CharSet CharSet;\n        public bool ExactSpelling;\n        public DllImportAttribute(string dllName) { }\n    }\n\n    public sealed class UnmanagedCallersOnlyAttribute : Attribute\n    {\n        public string EntryPoint;\n        public UnmanagedCallersOnlyAttribute() { }\n    }\n\n    public enum LayoutKind\n    {\n        Sequential = 0,\n        Explicit = 2,\n        Auto = 3,\n    }\n\n    public sealed class StructLayoutAttribute : Attribute\n    {\n        public int Size;\n\n        public StructLayoutAttribute(LayoutKind layoutKind) { }\n    }\n\n    public sealed class SuppressGCTransitionAttribute : Attribute\n    {\n        public SuppressGCTransitionAttribute() { }\n    }\n\n    public sealed class InAttribute : Attribute\n    {\n    }\n\n    public sealed class OutAttribute : Attribute\n    {\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Runtime/InteropServices/MemoryMarshal.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nusing System.Runtime.CompilerServices;\n\nnamespace System.Runtime.InteropServices\n{\n    public static class MemoryMarshal\n    {\n        [Intrinsic]\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static ref T GetArrayDataReference<T>(T[] array) => ref Unsafe.As<byte, T>(ref Unsafe.As<RawArrayData>(array).Data);\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/RuntimeHandles.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public struct RuntimeTypeHandle\n    {\n    }\n\n    public struct RuntimeMethodHandle\n    {\n    }\n\n    public struct RuntimeFieldHandle\n    {\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/String.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nusing System.Runtime;\nusing System.Runtime.CompilerServices;\n\nnamespace System\n{\n    public sealed class String\n    {\n        // The layout of the string type is a contract with the compiler.\n        private readonly int _length;\n        private char _firstChar;\n\n        public int Length => _length;\n\n        [IndexerName(\"Chars\")]\n        public unsafe char this[int index]\n        {\n            [System.Runtime.CompilerServices.Intrinsic]\n            get\n            {\n                return System.Runtime.CompilerServices.Unsafe.Add(ref _firstChar, index);\n            }\n        }\n\n        [MethodImpl(MethodImplOptions.InternalCall)]\n        public extern unsafe String(char* value);\n\n        private static unsafe string Ctor(char* ptr)\n        {\n            char* cur = ptr;\n            while (*cur++ != 0) ;\n\n            string result = FastNewString((int)(cur - ptr - 1));\n            for (int i = 0; i < cur - ptr - 1; i++)\n                Unsafe.Add(ref result._firstChar, i) = ptr[i];\n            return result;\n        }\n\n        [MethodImpl(MethodImplOptions.InternalCall)]\n        public extern unsafe String(sbyte* value);\n\n        private static unsafe string Ctor(sbyte* ptr)\n        {\n            sbyte* cur = ptr;\n            while (*cur++ != 0) ;\n\n            string result = FastNewString((int)(cur - ptr - 1));\n            for (int i = 0; i < cur - ptr - 1; i++)\n            {\n                if (ptr[i] > 0x7F)\n                    Environment.FailFast(null);\n                Unsafe.Add(ref result._firstChar, i) = (char)ptr[i];\n            }\n            return result;\n        }\n\n        static unsafe string FastNewString(int numChars)\n        {\n            return NewString(\"\".m_pMethodTable, numChars);\n\n            [MethodImpl(MethodImplOptions.InternalCall)]\n            [RuntimeImport(\"*\", \"RhpNewArray\")]\n            static extern string NewString(MethodTable* pMT, int numElements);\n        }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Thread.Efi.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if UEFI\n\nusing Internal.Runtime.CompilerHelpers;\n\nnamespace System.Threading\n{\n    public static class Thread\n    {\n        public static unsafe void Sleep(int delayMs)\n        {\n            StartupCodeHelpers.s_efiSystemTable->BootServices->Stall(1000 * (uint)delayMs);\n            Environment.s_stallSinceLastTickCount += delayMs;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Thread.Unix.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if LINUX\n\nusing System.Runtime.InteropServices;\n\nnamespace System.Threading\n{\n    public static class Thread\n    {\n        [DllImport(\"libSystem.Native\")]\n        private static extern IntPtr SystemNative_LowLevelMonitor_Create();\n\n        [DllImport(\"libSystem.Native\")]\n        private static extern void SystemNative_LowLevelMonitor_TimedWait(IntPtr mon, int ms);\n\n        private static IntPtr s_dummyMonitor = SystemNative_LowLevelMonitor_Create();\n\n        public static void Sleep(int delayMs) => SystemNative_LowLevelMonitor_TimedWait(s_dummyMonitor, delayMs);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Thread.Windows.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n#if WINDOWS\n\nusing System.Runtime.InteropServices;\n\nnamespace System.Threading\n{\n    public static class Thread\n    {\n        [DllImport(\"kernel32\")]\n        public static extern void Sleep(int delayMs);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/Type.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public class Type { }\n    public class RuntimeType : Type { }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/ValueTuple.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public struct ValueTuple<T1, T2>\n    {\n        public T1 Item1;\n        public T2 Item2;\n\n        public ValueTuple(T1 t1, T2 t2)\n        {\n            Item1 = t1;\n            Item2 = t2;\n        }\n    }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/System/ValueType.cs",
    "content": "// bflat minimal runtime library\n// Copyright (C) 2021-2022 Michal Strehovsky\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published\n// by the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nnamespace System\n{\n    public abstract class ValueType { }\n}\n"
  },
  {
    "path": "src/BFlat.ZeroLib/UnmanagedExports.cs",
    "content": "﻿using System;\nusing System.Runtime;\nusing System.Runtime.InteropServices;\n\nnamespace BFlat.ZeroLib\n{\n    internal unsafe static class UnmanagedExports\n    {\n        [RuntimeExport(\"memcpy\")]\n        public static void Memcpy(byte* dest, byte* src, ulong num)\n        {\n            for (ulong i = 0; i < num; i++) {\n                dest[i] = src[i];\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/ShaderCompressor/ShaderCompressor.cpp",
    "content": "#include <iostream>\n#include <fstream>\n#include <vector>\n#include <map>\n\n#include <Windows.h>\n#include <compressapi.h>\n\n#pragma comment(lib, \"Cabinet.lib\")\n\nconst char* algoNames[] = {\n\t\"(invalid)\",\n\t\"(null)\",\n\t\"COMPRESS_ALGORITHM_MSZIP\",\n\t\"COMPRESS_ALGORITHM_XPRESS\",\n\t\"COMPRESS_ALGORITHM_XPRESS_HUFF\",\n\t\"COMPRESS_ALGORITHM_LZMS\"\n};\n\nint main(int argc, const char* argv[])\n{\n\tif (argc != 3) {\n\t\tstd::cout << \"usage: \" << argv[0] << \" <shader source file> <output file>\" << std::endl;\n\t\treturn 1;\n\t}\n\n\tstd::ifstream inFile(argv[1], std::ios::binary | std::ios::ate);\n\tif (!inFile.good()) {\n\t\tstd::cout << \"error: could not open input file '\" << argv[1] << \"'\" << std::endl;\n\t\treturn 1;\n\t}\n\n\tauto inSize = inFile.tellg();\n\tinFile.seekg(0, std::ios::beg);\n\n\tstd::vector<char> inBuffer(inSize);\n\tinFile.read(inBuffer.data(), inSize);\n\tinFile.close();\n\n\tstd::vector<char> outBuffer(inSize * 2);\n\tstd::vector<char> finalBuffer(outBuffer.size());\n\n\tDWORD bestAlgo;\n\tSIZE_T bestSize = SIZE_MAX;\n\tfor (DWORD algo = 2; algo < COMPRESS_ALGORITHM_MAX; algo++)\n\t{\n\t\tCOMPRESSOR_HANDLE hCompressor;\n\t\tSIZE_T currentSize;\n\t\tBOOL success;\n\n\t\tsuccess = CreateCompressor(algo, nullptr, &hCompressor);\n\t\tif (!success) {\n\t\t\tstd::cout << \"warning: could not create compressor \" << algoNames[algo] << \", error \" << GetLastError() << std::endl;\n\t\t\tcontinue;\n\t\t}\n\n\t\tsuccess = Compress(\n\t\t\thCompressor,\n\t\t\tinBuffer.data(), inBuffer.size(),\n\t\t\toutBuffer.data(), outBuffer.size(),\n\t\t\t&currentSize\n\t\t);\n\t\tif (!success) {\n\t\t\tstd::cout << \"warning: could not compress using \" << algoNames[algo] << \", error \" << GetLastError() << std::endl;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (currentSize < bestSize) {\n\t\t\tbestSize = currentSize;\n\t\t\tbestAlgo = algo;\n\t\t\tmemcpy(finalBuffer.data(), outBuffer.data(), bestSize);\n\t\t}\n\t}\n\n\tstd::cout << \"Algorithm: \" << algoNames[bestAlgo] << std::endl;\n\tstd::cout << \"Compressed size: \" << bestSize << std::endl;\n\tstd::cout << \"Original size: \" << inBuffer.size() << std::endl;\n\tstd::cout << \"Compression ratio: \" << (bestSize / (float)inBuffer.size()) << std::endl;\n\n\tstd::ofstream outFile(argv[2]);\n\tif (!outFile.good()) {\n\t\tstd::cout << \"error: could not open output file '\" << argv[2] << \"'\" << std::endl;\n\t\treturn 1;\n\t}\n\n\tfor (size_t i = 0; i < bestSize; i++)\n\t{\n\t\toutFile << \"0x\" << std::hex << (uint32_t)(uint8_t)(finalBuffer[i]);\n\t\tif (i != bestSize - 1)\n\t\t\toutFile << \", \";\n\n\t\tif (i % 32 == 0 && i != 0)\n\t\t\toutFile << std::endl;\n\t}\n\n\toutFile.close();\n\tstd::cout << \"Output written to '\" << argv[2] << \"'.\";\n\treturn 0;\n}\n"
  },
  {
    "path": "src/ShaderCompressor/ShaderCompressor.vcxproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" 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=\"Release|Win32\">\n      <Configuration>Release</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|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <VCProjectVersion>16.0</VCProjectVersion>\n    <Keyword>Win32Proj</Keyword>\n    <ProjectGuid>{825d439a-cadc-4473-9381-f06e728d4a9b}</ProjectGuid>\n    <RootNamespace>ShaderCompressor</RootNamespace>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>Application</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v143</PlatformToolset>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>Application</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v143</PlatformToolset>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>Application</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v143</PlatformToolset>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>Application</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v143</PlatformToolset>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"Shared\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <OutDir>bin\\$(Platform)\\$(Configuration)\\</OutDir>\n    <IntDir>obj\\$(Platform)\\$(Configuration)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <OutDir>bin\\$(Platform)\\$(Configuration)\\</OutDir>\n    <IntDir>obj\\$(Platform)\\$(Configuration)\\</IntDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Console</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Console</SubSystem>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <OptimizeReferences>true</OptimizeReferences>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Console</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Console</SubSystem>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <OptimizeReferences>true</OptimizeReferences>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"ShaderCompressor.cpp\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "src/ShaderCompressor/ShaderCompressor.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;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</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=\"ShaderCompressor.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "src/SmolSharp.HelloWorld/Program.cs",
    "content": "﻿#define USE_ASCII\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp\n{\n    internal class Program\n    {\n        // dummy method\n        static void Main() { }\n\n        [UnmanagedCallersOnly(EntryPoint = \"smolsharp_main\")]\n        unsafe static void UnmanagedMain()\n        {\n#if USE_ASCII\n            var hi = \"Hello World!\"u8;\n            for (int i = 0; i < hi.Length; i++) {\n                Console.Write((char)hi[i]);\n            }\n#else\n            Console.WriteLine(\"Hello World!\");\n#endif\n        }\n    }\n}"
  },
  {
    "path": "src/SmolSharp.HelloWorld/SmolSharp.HelloWorld.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\n\t<PropertyGroup>\n\t\t<OutputType>Exe</OutputType>\n\t\t<TargetFramework>net7.0</TargetFramework>\n\t\t<Nullable>enable</Nullable>\n\t</PropertyGroup>\n\n\t<Import Project=\"../SmolSharp.props\" />\n\n</Project>\n"
  },
  {
    "path": "src/SmolSharp.Mandelbrot/FractalRenderer.cs",
    "content": "﻿using SmolSharp.Win32.GDI;\n\nnamespace SmolSharp.Mandelbrot\n{\n    internal static class FractalRenderer\n    {\n        const float OffsetX = 0;\n        const float OffsetY = 0;\n        const int Iterations = 15;\n        const float Zoom = 4f;\n\n        public static void Render(nint hdc)\n        {\n            for (int x = 0; x < 640; x++) {\n                for (int y = 0; y < 480; y++) {\n                    float a = x / 640f;\n                    float b = y / 480f;\n\n                    // Taken from my GLSL implementation @ https://www.shadertoy.com/view/dlG3RR\n                    a = (a - 0.5f) * Zoom + OffsetX;\n                    b = (b - 0.5f) * Zoom * (480f / 640f) + OffsetY;\n\n                    float c = 0.0f; // current real\n                    float d = 0.0f; // current imaginary\n\n                    for (int n = 0; n < Iterations; n++) {\n                        float re = c * c - d * d + a;\n                        float im = 2.0f * c * d + b;\n                        c = re;\n                        d = im;\n                    }\n\n                    uint r = (byte)(255 * c);\n                    uint g = (byte)(255 * d);\n                    uint color = (r) | (g << 8);\n                    Gdi32.SetPixel(hdc, x, y, color);\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Mandelbrot/Program.cs",
    "content": "﻿using SmolSharp.Mandelbrot;\nusing SmolSharp.Win32;\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Raytracer\n{\n    internal static class Program\n    {\n        static void Main() { }\n\n        [UnmanagedCallersOnly(EntryPoint = \"smolsharp_main\")]\n        public static unsafe int UnmanagedMain(nint hInstance, nint hPrevInstance, char* pCmdLine, int nCmdShow)\n        {\n            var name = \"Demo\"u8.AsPointer();\n            var wndClass = new WindowClassA() {\n                WndProc = &WndProc,\n                HInstance = hInstance,\n                ClassName = name\n            };\n\n            User32.RegisterClass(&wndClass);\n\n            nint hwnd = User32.CreateWindowEx(\n                0, name, name,\n                (0x00000000 | 0x00C00000 | 0x00080000 | /*0x00040000 |*/ 0x00020000 /*| 0x00010000*/),\n                64, 64, 640, 480,\n                0, 0, hInstance, 0\n            );\n\n            User32.ShowWindow(hwnd, 5);\n\n            WndMessage msg = default;\n            while (User32.GetMessage(&msg, default, 0, 0) > 0) {\n                //User32.TranslateMessage(&msg);\n                User32.DispatchMessage(&msg);\n            }\n\n            return 0;\n        }\n\n        [UnmanagedCallersOnly]\n        unsafe static nint WndProc(nint hwnd, uint msg, nuint wParam, nint lParam)\n        {\n            switch (msg) {\n                case 0xF: // WM_PAINT\n                    //GDIPaintStruct ps = default;\n                    //nint hdc = User32.BeginPaint(hwnd, &ps);\n                    nint hdc = User32.GetDC(hwnd); // using the HDC directly saves us a couple of bytes\n                    FractalRenderer.Render(hdc);\n                    //User32.EndPaint(hdc, &ps);\n                    break;\n                case 0x10: // WM_DESTROY\n                    *(byte*)0 = 1; // intentionally crash\n                    //User32.PostQuitMessage(0);\n                    break;\n            }\n\n            return User32.DefWindowProc(hwnd, msg, wParam, lParam);\n        }\n    }\n}"
  },
  {
    "path": "src/SmolSharp.Mandelbrot/SmolSharp.Mandelbrot.csproj",
    "content": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n\t<PropertyGroup>\n\t\t<OutputType>WinExe</OutputType>\n\t\t<TargetFramework>net7.0</TargetFramework>\n\t\t<Nullable>enable</Nullable>\n\t</PropertyGroup>\n\n\t<Import Project=\"..\\SmolSharp.Win32\\SmolSharp.Win32.projitems\" Label=\"Shared\" />\n\n\t<Import Project=\"../SmolSharp.props\" />\n\n</Project>\n"
  },
  {
    "path": "src/SmolSharp.Ocean/Buffers.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Ocean\n{\n    [StructLayout(LayoutKind.Explicit, Size = 32)]\n    public struct Buffer32 {\n        public const int Size = 32;\n    }\n\n    [StructLayout(LayoutKind.Explicit, Size = 24)]\n    public struct Buffer24 {\n        public const int Size = 24;\n    }\n\n    [StructLayout(LayoutKind.Explicit, Size = 8192)]\n    public struct Buffer8192 {\n        public const int Size = 8192;\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Ocean/GLLoader.cs",
    "content": "﻿using BFlat.ZeroLib;\nusing SmolSharp.Win32;\nusing SmolSharp.Win32.GDI.OpenGL;\nusing System;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Ocean\n{\n    internal static unsafe class GLLoader\n    {\n        static ReadOnlySpan<byte> SymbolBlob()\n        {\n            return \"CreateShaderCompileShaderAttachShaderSourceCreateProgramLinkProgramUseProgramVertexAttribPointerEnableVertexAttribArrayGenVertexArraysGenBuffersBindVertexArrayBindBufferDataGetUniformLocationUniform3f\"u8;\n        }\n\n        [StructLayout(LayoutKind.Explicit, Size = 32)]\n        struct Buffer32 { }\n\n        public static void* ImportFromBlob(int idx, int length)\n        {\n            return Import(SymbolBlob().AsPointer() + idx, length);\n        }\n\n        public static void* Import(byte* name, int nameLength)\n        {\n            var buffer = new Buffer32();\n            byte* str = (byte*)&buffer;\n\n            str[0] = (byte)'g';\n            str[1] = (byte)'l';\n\n            for (int i = 0; i < nameLength; i++)\n                str[i + 2] = name[i];\n\n            return GL.GetProcAddress(str);\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static void* Import(ReadOnlySpan<byte> name)\n            => Import(name.AsPointer(), name.Length);\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Ocean/Program.cs",
    "content": "﻿using SmolSharp.Win32.GDI.OpenGL;\nusing SmolSharp.Win32;\nusing System;\nusing System.Runtime.InteropServices;\nusing SmolSharp.Win32.GDI;\nusing SmolSharp.Ocean.Shaders;\n\nnamespace SmolSharp.Ocean\n{\n    internal class Program\n    {\n        static ushort windowWidth, windowHeight;\n        static bool windowDimensionsChanged;\n\n        static void Main() { }\n\n        [UnmanagedCallersOnly(EntryPoint = \"smolsharp_main\")]\n        public static unsafe int UnmanagedMain(nint hInstance, nint hPrevInstance, char* pCmdLine, int nCmdShow)\n        {\n            void* name = \"Demo\"u8.AsPointer();\n            var wndClass = new WindowClassA() {\n                WndProc = &WndProc,\n                HInstance = hInstance,\n                ClassName = name\n            };\n\n            User32.RegisterClass(&wndClass);\n\n            nint hwnd = User32.CreateWindowEx(\n                0, name, name,\n                (0x00000000 | 0x00C00000 | 0x00080000 | 0x00040000 | 0x00020000 | 0x00010000),\n                64, 64, 640, 480,\n                0, 0, hInstance, 0\n            );\n\n            windowWidth = 640;\n            windowHeight = 480;\n\n            User32.ShowWindow(hwnd, 5);\n            Kernel32.CreateThread(0, 0, &RenderThread, hwnd);\n\n            WndMessage msg = default;\n            while (User32.GetMessage(&msg, default, 0, 0) > 0) {\n                User32.DispatchMessage(&msg);\n            }\n\n            return 0;\n        }\n\n        [UnmanagedCallersOnly]\n        static unsafe uint RenderThread(nint hwnd)\n        {\n            var pfd = new PixelFormatDescriptor() {\n                Size = 40,\n                Version = 1,\n                Flags = PFDFlags.DoubleBuffered | PFDFlags.DrawToWindow | PFDFlags.SupportOpenGL,\n                // Type = PFD_TYPE_RGBA, // (0)\n                ColorBits = 32,\n                DepthBits = 24,\n                StencilBits = 8\n            };\n\n            nint hdc = User32.GetDC(hwnd);\n            int autoFormat = Gdi32.ChoosePixelFormat(hdc, &pfd);\n            Gdi32.SetPixelFormat(hdc, autoFormat, &pfd);\n\n            nint glCtx = GL.CreateContext(hdc);\n            GL.MakeCurrent(hdc, glCtx);\n\n            #region GL imports\n            // Unfortunately, Windows's GDI only has GL1.1 methods defined...\n            // We have to import them ourselves. For this, we use a decoder\n            // that uses encoded tokens in order to reduce repetition.\n            // This is only done to conserve space, and you could just as well\n            // call GL.GetProcAddress directly.\n            var glCreateShader = (delegate* unmanaged<uint, uint>)\n                GLLoader.ImportFromBlob(0, 12);\n\n            var glCompileShader = (delegate* unmanaged<uint, void>)\n                GLLoader.ImportFromBlob(12, 13);\n\n            var glAttachShader = (delegate* unmanaged<uint, uint, void>)\n                GLLoader.ImportFromBlob(25, 12);\n\n            var glShaderSource = (delegate* unmanaged<uint, int, byte**, int*, void>)\n                GLLoader.ImportFromBlob(31, 12);\n\n            var glCreateProgram = (delegate* unmanaged<uint>)\n                GLLoader.ImportFromBlob(43, 13);\n\n            var glLinkProgram = (delegate* unmanaged<uint, void>)\n                GLLoader.ImportFromBlob(56, 11);\n\n            var glUseProgram = (delegate* unmanaged<uint, void>)\n                GLLoader.ImportFromBlob(67, 10);\n\n            var glVertexAttribPointer = (delegate* unmanaged<uint, int, uint, byte, int, void*, void>)\n                GLLoader.ImportFromBlob(77, 19);\n\n            var glEnableVertexAttribArray = (delegate* unmanaged<uint, void>)\n                GLLoader.ImportFromBlob(96, 23);\n\n            var glGenVertexArrays = (delegate* unmanaged<int, uint*, void>)\n                GLLoader.ImportFromBlob(119, 15);\n\n            var glGenBuffers = (delegate* unmanaged<int, uint*, void>)\n                GLLoader.ImportFromBlob(134, 10);\n\n            var glBindVertexArray = (delegate* unmanaged<uint, void>)\n                GLLoader.ImportFromBlob(144, 15);\n\n            var glBindBuffer = (delegate* unmanaged<uint, uint, void>)\n                GLLoader.ImportFromBlob(159, 10);\n\n            var glBufferData = (delegate* unmanaged<uint, int, void*, uint, void>)\n                GLLoader.ImportFromBlob(163, 10);\n\n            var glGetUniformLocation = (delegate* unmanaged<uint, byte*, int>)\n                GLLoader.ImportFromBlob(173, 18);\n\n            var glUniform3f = (delegate* unmanaged<int, float, float, float, void>)\n                GLLoader.ImportFromBlob(191, 9);\n\n#if DEBUG\n            var glGetShaderiv = (delegate* unmanaged<uint, uint, int*, void>)\n                GLLoader.Import(\"GetShaderiv\"u8);\n\n            var glGetShaderInfoLog = (delegate* unmanaged<uint, uint, int*, byte*, void>)\n                GLLoader.Import(\"GetShaderInfoLog\"u8);\n\n            var glGetProgramiv = (delegate* unmanaged<uint, uint, int*, void>)\n                GLLoader.Import(\"GetProgramiv\"u8);\n\n            var glGetProgramInfoLog = (delegate* unmanaged<uint, uint, int*, byte*, void>)\n                GLLoader.Import(\"GetProgramInfoLog\"u8);\n#endif\n            #endregion\n\n            // Initialize vertices, shaders, etc...\n            uint vertexShader = glCreateShader(GL.VERTEX_SHADER);\n            var vertexShaderCode = OceanShader.VertexShader();\n            glShaderSource(vertexShader, 1, &vertexShaderCode, null);\n            glCompileShader(vertexShader);\n\n            var compressedFragShader = OceanShader.FragmentShader();\n            var fragBuffer = Kernel32.GlobalAlloc(default, 8192);\n            nint hDcmp;\n            nint fragLength;\n            bool success;\n\n            success = CompressAPI.CreateDecompressor(CompressAlgorithm.MSZip, default, &hDcmp);\n            success = CompressAPI.Decompress(\n                hDcmp,\n                compressedFragShader.AsPointer(),\n                compressedFragShader.Length,\n                fragBuffer,\n                8192,\n                &fragLength\n            );\n\n            uint fragShader = glCreateShader(GL.FRAGMENT_SHADER);\n            glShaderSource(fragShader, 1, (byte**)&fragBuffer, (int*)&fragLength);\n            glCompileShader(fragShader);\n\n#if DEBUG\n            int fragShaderCompiled = 0;\n            glGetShaderiv(fragShader, 35713, &fragShaderCompiled);\n            if (fragShaderCompiled == 0) {\n                byte* fragLog = (byte*)Kernel32.GlobalAlloc(0, 4096);\n                glGetShaderInfoLog(fragShader, 4096, null, fragLog);\n                ReportError(\"Couldn't compile the fragment shader!\\n\\n\", fragLog);\n            }\n#endif\n\n            uint shaderProgram = glCreateProgram();\n            glAttachShader(shaderProgram, vertexShader);\n            glAttachShader(shaderProgram, fragShader);\n            glLinkProgram(shaderProgram);\n\n#if DEBUG\n            int shaderLinked = 0;\n            glGetProgramiv(shaderProgram, 35714, &shaderLinked);\n            if (shaderLinked == 0) {\n                byte* linkLog = (byte*)Kernel32.GlobalAlloc(0, 4096);\n                glGetProgramInfoLog(shaderProgram, 4096, null, linkLog);\n                ReportError(\"Couldn't link the shader program!\\n\\n\", linkLog);\n            }\n#endif\n\n            // We use a clipped full-screen triangle in order to render\n            // the fragment shader to the whole screen. This is usually\n            // faster than a quad (see https://wallisc.github.io/rendering/2021/04/18/Fullscreen-Pass.html)\n            // and shaves a couple of bytes of the final binary.\n            var buffer = new Buffer24();\n            float* v = (float*)&buffer;\n            v[0] = -1.0f; v[1] =  3.0f;\n            v[2] = -1.0f; v[3] = -1.0f;\n            v[4] =  3.0f; v[5] = -1.0f;\n\n            uint vbo = 0, vao = 0;\n            glGenVertexArrays(1, &vao);\n            glGenBuffers(1, &vbo);\n\n            glBindVertexArray(vao);\n            glBindBuffer(GL.ARRAY_BUFFER, vbo);\n            glBufferData(GL.ARRAY_BUFFER, 24, v, GL.STATIC_DRAW);\n\n            glVertexAttribPointer(0, 2, GL.FLOAT, 0, 2 * sizeof(float), null);\n            glEnableVertexAttribArray(0);\n\n            uint begin = WinMM.GetTime();\n\n            do {\n                //GL.SetClearColor(0f, 0f, 0f, 1f);\n                //GL.Clear(GL.COLOR_BUFFER_BIT);\n\n                uint timeMs = WinMM.GetTime() - begin;\n                float time = timeMs / 1000f;\n\n                if (windowDimensionsChanged) {\n                    GL.Viewport(0, 0, windowWidth, windowHeight);\n                    windowDimensionsChanged = false;\n                }\n\n                int location = glGetUniformLocation(shaderProgram, \"s\"u8.AsPointer());\n                glUseProgram(shaderProgram);\n                glUniform3f(\n                    location,\n                    windowWidth, windowHeight,\n                    time\n                );\n\n                GL.DrawArrays(GL.TRIANGLES, 0, 3);\n\n                Gdi32.SwapBuffers(hdc);\n            } while (true);\n        }\n\n#if DEBUG\n        unsafe static void ReportError(string error, byte* log)\n        {\n            Kernel32.AllocConsole();\n            Console.WriteLine(error);\n\n            byte c;\n            while ((c = *log++) != 0x00)\n                Console.Write((char)c);\n\n            Console.WriteLine(\"\\n\\n(end)\");\n            Kernel32.Sleep(10000);\n        }\n#endif\n\n        [UnmanagedCallersOnly]\n        unsafe static nint WndProc(nint hwnd, uint msg, nuint wParam, nint lParam)\n        {\n            switch (msg) {\n                case 0x10: // WM_DESTROY\n                    *(byte*)0 = 1; // intentionally crash\n                    break;\n                case 0x05: // WM_SIZE\n                    windowWidth = (ushort)(lParam & 0xFFFF);\n                    windowHeight = (ushort)(lParam >> 16);\n                    windowDimensionsChanged = true;\n                    break;\n            }\n\n            return User32.DefWindowProc(hwnd, msg, wParam, lParam);\n        }\n    }\n}"
  },
  {
    "path": "src/SmolSharp.Ocean/Shaders/OceanShader.cs",
    "content": "﻿using System;\nusing System.Runtime.CompilerServices;\n\nnamespace SmolSharp.Ocean.Shaders\n{\n    internal static unsafe class OceanShader\n    {\n        // no const utf-8 literal support makes me sad :(\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static byte* VertexShader()\n        {\n            return\n            \"\"\"\n            #version 330\n            in vec3 p;void main(){gl_Position=vec4(p,1);}\n            \"\"\"u8\n            .AsPointer();\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public static ReadOnlySpan<byte> FragmentShader()\n        {\n            return new byte[] {\n0xa, 0x51, 0xe5, 0xc0, 0x18, 0x0, 0x98, 0x2, 0x9c, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9c, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xbf, 0x3, 0x0, 0x0, 0x43, 0x4b, 0x5d, 0x55, 0x5d,\n0x6f, 0xab, 0x38, 0x10, 0x7d, 0xdf, 0x5f, 0x11, 0x69, 0x5f, 0x6c, 0x33, 0x38, 0x40, 0x48, 0xda, 0x8a, 0xeb, 0xfb, 0x52, 0x69, 0xff, 0xc6, 0x2a, 0x4b, 0xf0, 0xbd, 0x48, 0x21, 0xe4, 0x62, 0x4a,\n0x81, 0xaa, 0xff, 0x7d, 0xcf, 0x18, 0x93, 0xa4, 0x8d, 0x94, 0xf8, 0x63, 0x6c, 0xcf, 0xcc, 0x39, 0x67, 0x26, 0x7f, 0xf, 0x55, 0xe7, 0xea, 0xf6, 0xb2, 0xd9, 0xed, 0x92, 0xbf, 0xda, 0xb7, 0x7e,\n0x33, 0x54, 0x65, 0xbe, 0x19, 0x8a, 0xb7, 0x4b, 0x6d, 0xdb, 0xae, 0xe1, 0xe5, 0x6e, 0xe3, 0xa, 0x3f, 0x5c, 0x84, 0x1f, 0x6, 0x5a, 0x36, 0x97, 0xc1, 0xca, 0x8f, 0xae, 0xea, 0xdf, 0xba, 0xcb,\n0x66, 0x88, 0x9c, 0x12, 0x22, 0x3e, 0xb5, 0xbd, 0xb0, 0x14, 0xb3, 0x51, 0x24, 0x94, 0x52, 0x22, 0xa5, 0xdf, 0x5b, 0xae, 0xad, 0x5b, 0x72, 0xcb, 0x7b, 0xee, 0xeb, 0x5e, 0xf1, 0xd9, 0x1c, 0xfb,\n0x9b, 0x1f, 0x47, 0xf6, 0xdc, 0x1e, 0x11, 0x91, 0xfc, 0x58, 0x26, 0xd6, 0xb8, 0x1a, 0x36, 0x49, 0x93, 0x29, 0x5b, 0xc7, 0x93, 0xd9, 0xa4, 0x3a, 0x9e, 0x8a, 0x10, 0x0, 0x5f, 0x16, 0xb3, 0x72,\n0x7a, 0xe4, 0x6f, 0x34, 0xd1, 0x3a, 0x9f, 0x62, 0xa7, 0x67, 0x65, 0xfd, 0xda, 0xef, 0x45, 0xd8, 0xb, 0x6b, 0x6f, 0x8f, 0xee, 0xf6, 0xc9, 0xaf, 0xa7, 0xdb, 0x7c, 0x8e, 0xf9, 0xcc, 0xc3, 0xdd,\n0xf8, 0x7e, 0xd7, 0xdb, 0xa3, 0xaf, 0xf6, 0x39, 0x9a, 0x90, 0xc7, 0x1d, 0xaf, 0x6c, 0x33, 0xcb, 0xf, 0x3f, 0xe, 0x66, 0x56, 0x99, 0xb6, 0x71, 0xaa, 0x6d, 0x31, 0xe0, 0x8e, 0xc1, 0xc5, 0x2d,\n0x1e, 0x59, 0xc0, 0xb5, 0xe6, 0x2, 0xbc, 0x8f, 0xe7, 0x7a, 0xae, 0x7c, 0xfa, 0xc0, 0x2b, 0xd5, 0x7b, 0x60, 0xe2, 0xef, 0x96, 0x86, 0x7, 0xc1, 0x2e, 0xd2, 0x4c, 0x13, 0xe3, 0x80, 0xb9, 0x54,\n0x59, 0xa2, 0xa3, 0x7c, 0xaf, 0xe5, 0xa, 0xc1, 0x2, 0x1d, 0x0, 0x8d, 0x19, 0x51, 0x2a, 0xe1, 0x21, 0x7d, 0x4e, 0x34, 0xfc, 0xc2, 0xad, 0x54, 0xc1, 0xc, 0xdb, 0x62, 0x9d, 0xbe, 0x58, 0x6d,\n0x88, 0xbb, 0xf, 0xf8, 0xdf, 0x99, 0xe5, 0x4b, 0x3a, 0xb7, 0xa4, 0x9f, 0x9e, 0xf0, 0xf3, 0xb2, 0xb7, 0xd2, 0xa3, 0xa0, 0xf3, 0xe2, 0x73, 0xa1, 0x26, 0xa4, 0x3a, 0x4, 0xca, 0x56, 0xea, 0x6c,\n0x18, 0xe7, 0x30, 0x4e, 0xe4, 0x8f, 0x35, 0x2b, 0xa3, 0xa3, 0x39, 0xe8, 0xec, 0x79, 0x7b, 0x63, 0x70, 0x56, 0xd7, 0xf6, 0x5d, 0xf8, 0xec, 0xfe, 0x74, 0xbd, 0x78, 0xd1, 0xcf, 0xa9, 0x1a, 0xa5,\n0x72, 0xf1, 0xa8, 0x58, 0x2e, 0xd, 0xd, 0x52, 0x2a, 0xbd, 0x8f, 0xf4, 0x9e, 0xac, 0x5c, 0x7d, 0xf7, 0xab, 0xef, 0xfa, 0xd2, 0xb3, 0x1c, 0x83, 0x2b, 0x93, 0x68, 0xe8, 0x83, 0x11, 0xc3, 0xe9,\n0xd1, 0xec, 0x34, 0x95, 0x50, 0xcb, 0x61, 0x4f, 0x27, 0xf3, 0xac, 0x8b, 0xb2, 0xbd, 0xb8, 0x9e, 0x15, 0x83, 0x68, 0xc, 0xf, 0x82, 0x25, 0xa5, 0x5f, 0xf2, 0x4c, 0x52, 0xcc, 0x1, 0x2c, 0xd3,\n0xfb, 0xec, 0x66, 0xe, 0x8c, 0x54, 0x81, 0x11, 0x7f, 0x60, 0x31, 0xa7, 0x9a, 0xad, 0x28, 0x1b, 0xc1, 0x91, 0x74, 0x26, 0x29, 0xba, 0x1f, 0xb6, 0xe8, 0xa2, 0x48, 0x4e, 0x91, 0x1, 0x42, 0x34,\n0xd3, 0x48, 0x25, 0x9d, 0xa8, 0x92, 0x4, 0xfa, 0x53, 0x9d, 0xe4, 0x54, 0x2a, 0xa3, 0x9f, 0x33, 0x3a, 0xf1, 0xb0, 0xa7, 0x4a, 0x99, 0x66, 0xc5, 0x62, 0xda, 0x22, 0xcc, 0x85, 0x90, 0x6a, 0xc9,\n0xd0, 0xad, 0xb9, 0xd, 0x6, 0xa5, 0xa3, 0xc7, 0x89, 0x76, 0x8, 0xcc, 0x86, 0x45, 0xec, 0xe3, 0xd1, 0x89, 0x27, 0x9e, 0xd, 0x73, 0x30, 0x44, 0xde, 0x90, 0x10, 0x4c, 0xde, 0xb0, 0xe8, 0xcd,\n0x2b, 0x6a, 0xc7, 0x7, 0x68, 0x20, 0x90, 0x79, 0x97, 0xd0, 0x4d, 0x86, 0x65, 0xd7, 0x3a, 0x27, 0xca, 0x78, 0x3d, 0x18, 0xf3, 0xe3, 0xd6, 0x1f, 0xa6, 0xfb, 0x2e, 0xb2, 0xe2, 0x8a, 0xe1, 0xd7,\n0xa5, 0x7c, 0xc, 0xf8, 0xde, 0x29, 0x7c, 0x1, 0xb0, 0xc4, 0x1, 0xc1, 0x83, 0xcc, 0x5d, 0x3c, 0x7c, 0x87, 0x6b, 0x97, 0x79, 0xbc, 0x6e, 0x1c, 0xa2, 0x95, 0xe8, 0x71, 0xa6, 0xf4, 0x20, 0xa1,\n0xd0, 0xa2, 0xb6, 0xc2, 0x3b, 0xfa, 0x69, 0x11, 0x42, 0x8, 0xd7, 0x16, 0x36, 0x42, 0x61, 0xe1, 0xdc, 0x14, 0x73, 0xe5, 0xad, 0x92, 0xd, 0x91, 0x34, 0xdf, 0xb5, 0x5c, 0x9e, 0x8f, 0xcd, 0x55,\n0xa0, 0x53, 0x65, 0x7a, 0x97, 0x2a, 0x87, 0xe7, 0x9e, 0xe4, 0x76, 0x59, 0xe7, 0xbc, 0xdc, 0xe7, 0x12, 0x7b, 0xb9, 0x24, 0xc8, 0x7, 0x45, 0x11, 0x9e, 0x79, 0xf, 0x9, 0x85, 0x4c, 0xe6, 0x5,\n0x3c, 0x16, 0x6b, 0x73, 0x1c, 0x5, 0x8e, 0x2e, 0x1d, 0xee, 0x5b, 0x9, 0xb3, 0x38, 0x58, 0xe0, 0x12, 0xd8, 0xef, 0x7d, 0x8f, 0xd1, 0x49, 0xe6, 0xa5, 0xe2, 0x77, 0xf9, 0x43, 0x4f, 0x28, 0x61,\n0x79, 0x3, 0xdf, 0x35, 0x6d, 0xdb, 0xff, 0x76, 0x7d, 0x75, 0x15, 0xde, 0x3f, 0xa1, 0x9f, 0xe5, 0x89, 0x8e, 0xd1, 0x9, 0xb6, 0xf8, 0x46, 0xb3, 0x3a, 0x24, 0xac, 0x8a, 0xb6, 0x3e, 0x41, 0xbc,\n0x78, 0x3e, 0xf4, 0x96, 0xd9, 0xfc, 0x3a, 0xff, 0xfb, 0x4f, 0x77, 0xfc, 0xf5, 0xda, 0xb6, 0xdd, 0x9, 0xa4, 0x6f, 0x99, 0xf9, 0x5b, 0x67, 0x11, 0x33, 0x18, 0x33, 0xb7, 0x98, 0x10, 0xc9, 0x36,\n0x43, 0xc1, 0xe7, 0xec, 0x2, 0x81, 0x85, 0x6e, 0xe2, 0x23, 0xbb, 0xdb, 0xd0, 0x67, 0x19, 0x71, 0x0, 0xfb, 0x13, 0xb5, 0x24, 0x3d, 0x19, 0x32, 0x7a, 0xc7, 0x4f, 0x51, 0x9d, 0x5d, 0xb5, 0x20,\n0x31, 0xe2, 0xf1, 0x12, 0xa2, 0x58, 0xda, 0xe, 0xf2, 0x39, 0x7d, 0xd9, 0x58, 0xfa, 0x90, 0xa4, 0xda, 0x54, 0x62, 0xa4, 0x93, 0xa4, 0xe, 0x93, 0x1a, 0x94, 0x22, 0x63, 0xd3, 0xd4, 0xa3, 0xe8,\n0x1e, 0xff, 0x1, 0xd0, 0x5f, 0x54, 0x83, 0x60, 0x90, 0xb7, 0xaf, 0xff, 0x53, 0xed, 0xfa, 0xe3, 0xa5, 0x84, 0x12, 0xa9, 0x46, 0xdd, 0x43, 0x61, 0x2a, 0xd5, 0x29, 0xd7, 0x98, 0x97, 0xc7, 0xd1,\n0x80, 0xa8, 0x48, 0xbf, 0x1c, 0x7c, 0xd7, 0xc0, 0x3f, 0xc1, 0x3, 0x17, 0x71, 0x87, 0xe, 0x21, 0x89, 0x5b, 0xa3, 0x8f, 0xf3, 0xfa, 0xa0, 0xbb, 0xae, 0xb2, 0xe7, 0xaa, 0xe4, 0x7f, 0xa9, 0xe,\n0x6f, 0x5d, 0xf5, 0x64, 0x8e, 0xff, 0x39, 0x71, 0xe5, 0x1a, 0xf0, 0x67, 0x5f, 0x91, 0xe9, 0x95, 0x33, 0xbd, 0xca, 0x2, 0x36, 0xf5, 0x1a, 0xf1, 0xe3, 0x47, 0xa9, 0x16, 0x56, 0xe1, 0x14, 0x4d,\n0x30, 0x3d, 0xf0, 0xf, 0x3a, 0xa1, 0x42, 0x3e, 0x53, 0x94, 0xea, 0xc8, 0x57, 0xff, 0xa7, 0xa7, 0xe3, 0xca, 0x8a, 0xc4, 0x9d, 0x59, 0x4f, 0xe3, 0x1a, 0x6d, 0x67, 0xae, 0x68, 0xfa, 0xf0, 0xa2,\n0x76, 0x99, 0x46, 0xf6, 0x1c, 0x73, 0x47, 0x20, 0xb5, 0x98, 0x94, 0xe9, 0x8a, 0x81, 0xe9, 0xc9, 0x45, 0x23, 0x26, 0xb4, 0x63, 0x49, 0x29, 0x9e, 0xfa, 0x1f\n            };\n        }\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Ocean/Shaders/frag-min.glsl",
    "content": "#version 330\nout vec4 FragColor;\n\nuniform vec3 vals; // x = time, y = width, z = height\n\nconst vec3 waterBaseColor = vec3(0.04f, 0.16f, 0.15f);\nconst vec3 skyBaseColor = vec3(0.4f, 0.77f, 0.95f);\n\n// ===================== Animation =================== //\nvec2 getYawPitch() {\n    return vec2(vals.z * 12.0, sin(vals.z) * 20.0 + 45.0);\n}\n\nvec3 getOrigin() {\n    return vec3(\n        sin(vals.z / 2.0) * 4.0,\n        1.5 + (sin(vals.z)),\n        cos(vals.z / 2.0) * 4.0\n    );\n}\n// =================================================== //\n\n// =============== Ray-marching utilties ============= //\n// Calculates the intersection between a ray and a plane.\n// Ported from https://stackoverflow.com/a/53437900/13153269\nvec3 getPlaneIntersection(vec3 rayP, vec3 rayD, vec3 planeP, vec3 planeN) {\n\tfloat d = dot(planeP, -planeN);\n\tfloat t = -(d + dot(rayP, planeN)) / dot(rayD, planeN);\n\treturn rayP + (rayD * t);\n}\n\nmat3 rotationMatrix(vec3 axis, float angle) {\n    float s = sin(angle);\n    float c = cos(angle);\n    float oc = 1.0 - c;\n    return mat3(\n        oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, \n        oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, \n        oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c\n    );\n}\n\n// Gets the normalized direction of a ray pointing forward, beginning\n// from the camera's origin, using the normalized UV screen coordinates.\nvec3 getRayDirection(vec2 uv) {\n    vec2 ndc = (uv * 2.0f) - 1.0f; // [-1.0; 1.0]\n    ndc.x *= (vals.x / vals.y);\n    vec3 forward = normalize(vec3(ndc, 1.5));\n    \n    vec2 angles = getYawPitch();\n    \n    return rotationMatrix(vec3(0.0, -1.0, 0.0), ((angles.x / 180.0) * 2.0 - 1.0)) \n         * rotationMatrix(vec3(1.0, 0.0, 0.0), ((angles.y / 180.0) * 2.0 - 1.0))\n         * forward;\n}\n\n// Computes the sky color.\nvec3 getSkyColor(vec3 rd) {\n    return skyBaseColor - rd.y * 0.4; // keep it simple, silly!\n}\n\nfloat computeGerstnerWaves(vec2 pos, float t, float steepness, float amplitude, float lambda, vec2 dir) {\n    const float g = 9.81;\n\n\tfloat k = (2.0 * 3.14) / lambda;\n    float x = (sqrt(g * k)) * t - k * dot(dir, pos);\n\n    return amplitude * pow(sin(x) * 0.5 + 0.5, steepness);\n}\n\n// Gets the height of the water at (pos).\nfloat getWaterHeightAt(vec2 position, int iterations) {\n    float height = 0.0;\n\n    float time      = vals.z * 0.5;\n    float steepness = 3.0;\n    float amplitude = 1.65;\n    float lambda    = 8.0;\n\n    const float angle   = (3.14 * 2.0) * 0.15;\n\tconst mat2 rotation = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n\n    const vec2 beginDir = vec2(sin(0.9), cos(1.2));\n    vec2 dir = beginDir;\n\n    for(int i = 0; i < iterations; i++) {\n        height += computeGerstnerWaves(position, time, steepness, amplitude, lambda, dir);\n\n        steepness *= 1.04;\n        amplitude *= 0.82;\n        lambda    *= 0.85;\n        dir *= rotation;\n    }\n\n    return height / 8.0;\n} \n\nvec3 getWaterNormal(vec2 pos) {\n    float p0 = getWaterHeightAt(pos.xy, 32) * 1.0; // center\n    float p1 = getWaterHeightAt(pos.xy - vec2(0.01, 0), 32) * 1.0; // left neighbor\n    float p2 = getWaterHeightAt(pos.xy + vec2(0, 0.01), 32) * 1.0; // bottom neighbor\n    vec3 a = vec3(pos.x, p0, pos.y);\n\n    return normalize(cross(a - vec3(pos.x - 0.01, p1, pos.y), a - vec3(pos.x, p2, pos.y + 0.01)));\n}\n\n// Returns the water intersection position on the given ray (line).\nvec3 raymarch(vec3 rayStart, vec3 rayEnd) {\n    vec3 pos = rayStart;\n    vec3 dir = normalize(rayEnd - rayStart);\n    for (int i = 0; i < 32; i++) {\n        // Sample the water height-map. This in theory could be just a perlin\n        // noise texture, but we're using gerstner waves for our purposes instead\n        float y = getWaterHeightAt(pos.xz, 16) * 1.0 - 1.0;\n        if (y + 0.01 > pos.y) {\n            return pos;\n        }\n\n        pos += dir * (pos.y - y);\n    }\n\n    return rayStart;\n}\n\nvec3 aces(vec3 x) {\n    const float a = 2.31; // brightness\n    const float b = 0.07;\n    const float c = 2.4; // gamma\n    const float d = 0.54;\n    const float e = 0.04;\n    return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);\n}\n\nvec3 applyTonemapping(vec3 color) {  \n    return aces(color * 2.0);\n}\n\nvec3 getSunDirection() {\n  return normalize(\n      vec3(\n          sin(2.0 * 3.14),\n          0.05 + vals.z * 0.02,\n          cos(2.0 * 3.14)\n      )\n  );\n}\n\nvec3 getSun(vec3 dir) { \n    float baseScalar = pow(max(0.0, dot(dir, getSunDirection())), 720.0);\n    vec3 base = vec3(baseScalar, baseScalar, baseScalar);\n\n    vec3 sun = smoothstep(0.5, 1.0, base * 40.0);\n    vec3 haze = base * 60.0;\n    return sun + haze;\n}\n\nvoid main() {\n    vec2 uv = gl_FragCoord.xy / vals.xy;\n    vec3 rayDir = getRayDirection(uv);\n    vec3 origin = getOrigin(); \n\n    vec3 fColor; // final color\n\n    if (rayDir.y >= 0.0) {\n        // Ray is pointing upwards - render the sky.\n        fColor = getSkyColor(rayDir) + getSun(rayDir);\n    } else {\n        // Ray is pointing downwards - render the water.\n\n        // Calculate the intersection between the low and high planes.\n        vec3 hp = getPlaneIntersection(origin, rayDir, vec3(0.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0));\n        vec3 lp = getPlaneIntersection(origin, rayDir, vec3(0.0, -1.0, 0.0), vec3(0.0, 1.0, 0.0));\n\n        // Raymarch through the water plane, using the water height-map function (getWaterHeightAt).\n        vec3 wpos = raymarch(hp, lp);\n        float dist = distance(origin, wpos); \n\n        vec3 norm = getWaterNormal(wpos.xz);\n        norm = mix(norm, vec3(0.0, 1.0, 0.0), 0.7 * min(1.0, sqrt(dist * 0.01) * 1.1));\n        \n        float fresnel = (0.04 + (1.0 - 0.04) * (pow(1.0 - max(0.0, dot(-norm, rayDir)), 5.0)));\n        vec3 reflectDir = normalize(reflect(rayDir, norm));\n        reflectDir.y = abs(reflectDir.y);\n\n        vec3 reflectColor = getSkyColor(reflectDir) + getSun(reflectDir);\n        vec3 waterColor = waterBaseColor * (0.2 + (wpos.y + 1.0) / 1.0);\n\n        fColor = fresnel * reflectColor + (1.0 - fresnel) * waterColor;\n    }\n    \n    vec2 uvf = uv * (1.0 - uv.yx);\n    float vig = uvf.x * uvf.y * 32.0;\n    vig = pow(vig, 0.5);\n    \n    fColor *= vig;\n    FragColor = vec4(applyTonemapping(fColor), 1.0);\n}"
  },
  {
    "path": "src/SmolSharp.Ocean/Shaders/frag.glsl",
    "content": "// This is a port of my ocean shader @ https://www.shadertoy.com/view/DtsBzX.\n\n// Stored as a single vec3 in order to minimize code size in the host\nuniform vec3 uniformValues;\n\n#define TIME          uniformValues.z\n#define ASPECT_RATIO  (uniformValues.x / uniformValues.y)\n#define RESOLUTION    uniformValues.xy\n\n// === Settings\n#define RAYMARCH_ITERATIONS   32\n#define WATER_ITERATIONS      16\n#define WATER_ITERATIONS_NORM 32\n\n#define WAVE_AMPLITUDE 1.65\n#define WAVE_STEEPNESS 3.0\n#define WAVE_LENGTH\t   8.0\n#define WAVE_SPEED     0.5\n#define WAVE_DIVISOR   8.0\n#define WAVE_D_STEEPNESS 1.04\n#define WAVE_D_AMPLITUDE 0.82\n#define WAVE_D_LAMBDA    0.85\n\n\n#define FOV           1.5f\n#define PI            3.141592653589793238 // replace when minimizing!\n#define WATER_HEIGHT  1.0f\n#define UP            vec3(0.0f, 1.0f, 0.0f)\n#define ONE           vec3(1.0f, 1.0f, 1.0f)\n\nconst vec3 waterBaseColor = vec3(0.04f, 0.16f, 0.15f);\nconst vec3 skyBaseColor = vec3(0.4f, 0.77f, 0.95f);\n\n// ===================== Animation =================== //\nvec2 getYawPitch() {\n    return vec2(TIME * 12.0, sin(TIME) * 20.0 + 45.0);\n}\n\nvec3 getOrigin() {\n    return vec3(\n        sin(TIME / 2.0) * 4.0,\n        1.5 + (sin(TIME)),\n        cos(TIME / 2.0) * 4.0\n    );\n}\n// =================================================== //\n\n// =============== Ray-marching utilties ============= //\n// Calculates the intersection between a ray and a plane.\n// Ported from https://stackoverflow.com/a/53437900/13153269\nvec3 getPlaneIntersection(vec3 rayP, vec3 rayD, vec3 planeP, vec3 planeN) {\n\tfloat d = dot(planeP, -planeN);\n\tfloat t = -(d + dot(rayP, planeN)) / dot(rayD, planeN);\n\treturn rayP + (rayD * t);\n}\n\nmat3 rotationMatrix(vec3 axis, float angle) {\n    float s = sin(angle);\n    float c = cos(angle);\n    float oc = 1.0 - c;\n    return mat3(\n        oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, \n        oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, \n        oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c\n    );\n}\n\n// Gets the normalized direction of a ray pointing forward, beginning\n// from the camera's origin, using the normalized UV screen coordinates.\nvec3 getRayDirection(vec2 uv) {\n    vec2 ndc = (uv * 2.0f) - 1.0f; // [-1.0; 1.0]\n    ndc.x *= ASPECT_RATIO;\n    vec3 forward = normalize(vec3(ndc, FOV));\n    \n    vec2 angles = getYawPitch();\n    \n    return rotationMatrix(vec3(0.0, -1.0, 0.0), ((angles.x / 180.0) * 2.0 - 1.0)) \n         * rotationMatrix(vec3(1.0, 0.0, 0.0), ((angles.y / 180.0) * 2.0 - 1.0))\n         * forward;\n}\n\n// Computes the sky color.\nvec3 getSkyColor(vec3 rd) {\n    return skyBaseColor - rd.y * 0.4; // keep it simple, silly!\n}\n\nfloat computeGerstnerWaves(vec2 pos, float t, float steepness, float amplitude, float lambda, vec2 dir) {\n    const float g = 9.81;\n\n\tfloat k = (2.0 * PI) / lambda;\n    float x = (sqrt(g * k)) * t - k * dot(dir, pos);\n\n    return amplitude * pow(sin(x) * 0.5 + 0.5, steepness);\n}\n\n// Gets the height of the water at (pos).\nfloat getWaterHeightAt(vec2 position, int iterations) {\n    float height = 0.0;\n\n    float time      = TIME * WAVE_SPEED;\n    float steepness = WAVE_STEEPNESS;\n    float amplitude = WAVE_AMPLITUDE;\n    float lambda    = WAVE_LENGTH;\n\n    const float angle   = (PI * 2.0) * 0.15;\n\tconst mat2 rotation = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n\n    const vec2 beginDir = vec2(sin(0.9), cos(1.2));\n    vec2 dir = beginDir;\n\n    for(int i = 0; i < iterations; i++) {\n        height += computeGerstnerWaves(position, time, steepness, amplitude, lambda, dir);\n\n        steepness *= WAVE_D_STEEPNESS;\n        amplitude *= WAVE_D_AMPLITUDE;\n        lambda    *= WAVE_D_LAMBDA;\n        dir *= rotation;\n    }\n\n    return height / WAVE_DIVISOR;\n} \n\nvec3 getWaterNormal(vec2 pos) {\n    float p0 = getWaterHeightAt(pos.xy, WATER_ITERATIONS_NORM) * WATER_HEIGHT; // center\n    float p1 = getWaterHeightAt(pos.xy - vec2(0.01, 0), WATER_ITERATIONS_NORM) * WATER_HEIGHT; // left neighbor\n    float p2 = getWaterHeightAt(pos.xy + vec2(0, 0.01), WATER_ITERATIONS_NORM) * WATER_HEIGHT; // bottom neighbor\n    vec3 a = vec3(pos.x, p0, pos.y);\n\n    return normalize(cross(a - vec3(pos.x - 0.01, p1, pos.y), a - vec3(pos.x, p2, pos.y + 0.01)));\n}\n\n// Returns the water intersection position on the given ray (line).\nvec3 raymarch(vec3 rayStart, vec3 rayEnd) {\n    vec3 pos = rayStart;\n    vec3 dir = normalize(rayEnd - rayStart);\n    for (int i = 0; i < RAYMARCH_ITERATIONS; i++) {\n        // Sample the water height-map. This in theory could be just a perlin\n        // noise texture, but we're using gerstner waves for our purposes instead\n        float y = getWaterHeightAt(pos.xz, WATER_ITERATIONS) * WATER_HEIGHT - WATER_HEIGHT;\n        if (y + 0.01 > pos.y) {\n            return pos;\n        }\n\n        pos += dir * (pos.y - y);\n    }\n\n    return rayStart;\n}\n\nvec3 aces(vec3 x) {\n    const float a = 2.31; // brightness\n    const float b = 0.07;\n    const float c = 2.4; // gamma\n    const float d = 0.54;\n    const float e = 0.04;\n    return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);\n}\n\nvec3 applyTonemapping(vec3 color) {  \n    return aces(color * 2.0);\n}\n\nvec3 getSunDirection() {\n  return normalize(\n      vec3(\n          sin(2.0 * PI),\n          0.05 + TIME * 0.02,\n          cos(2.0 * PI)\n      )\n  );\n}\n\nvec3 getSun(vec3 dir) { \n    float baseScalar = pow(max(0.0, dot(dir, getSunDirection())), 720.0);\n    vec3 base = vec3(baseScalar, baseScalar, baseScalar);\n\n    vec3 sun = smoothstep(0.5, 1.0, base * 40.0);\n    vec3 haze = base * 60.0;\n    return sun + haze;\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord ) {\n    vec2 uv = fragCoord / RESOLUTION;\n    vec3 rayDir = getRayDirection(uv);\n    vec3 origin = getOrigin(); \n\n    vec3 fColor; // final color\n\n    if (rayDir.y >= 0.0) {\n        // Ray is pointing upwards - render the sky.\n        fColor = getSkyColor(rayDir) + getSun(rayDir);\n    } else {\n        // Ray is pointing downwards - render the water.\n\n        // Calculate the intersection between the low and high planes.\n        vec3 hp = getPlaneIntersection(origin, rayDir, vec3(0.0, 0.0, 0.0), UP);\n        vec3 lp = getPlaneIntersection(origin, rayDir, vec3(0.0, -WATER_HEIGHT, 0.0), UP);\n\n        // Raymarch through the water plane, using the water height-map function (getWaterHeightAt).\n        vec3 wpos = raymarch(hp, lp);\n        float dist = distance(origin, wpos); \n\n        vec3 norm = getWaterNormal(wpos.xz);\n        norm = mix(norm, vec3(0.0, 1.0, 0.0), 0.7 * min(1.0, sqrt(dist * 0.01) * 1.1));\n        \n        float fresnel = (0.04 + (1.0 - 0.04) * (pow(1.0 - max(0.0, dot(-norm, rayDir)), 5.0)));\n        vec3 reflectDir = normalize(reflect(rayDir, norm));\n        reflectDir.y = abs(reflectDir.y);\n\n        vec3 reflectColor = getSkyColor(reflectDir) + getSun(reflectDir);\n        vec3 waterColor = waterBaseColor * (0.2 + (wpos.y + WATER_HEIGHT) / WATER_HEIGHT);\n\n        fColor = fresnel * reflectColor + (1.0 - fresnel) * waterColor;\n    }\n    \n    vec2 uvf = uv * (1.0 - uv.yx);\n    float vig = uvf.x * uvf.y * 32.0;\n    vig = pow(vig, 0.5);\n    \n    fColor *= vig;\n    fragColor = vec4(applyTonemapping(fColor), 1.0);\n}"
  },
  {
    "path": "src/SmolSharp.Ocean/SmolSharp.Ocean.csproj",
    "content": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n\t<PropertyGroup>\n\t\t<OutputType>WinExe</OutputType>\n\t\t<TargetFramework>net7.0</TargetFramework>\n\t\t<Nullable>enable</Nullable>\n\t</PropertyGroup>\n\n\t<ItemGroup>\n\t\t<DirectPInvoke Include=\"opengl32\" />\n\t\t<LinkerArg Include=\"opengl32.lib\" />\n\t\t<DirectPInvoke Include=\"Cabinet\" />\n\t\t<LinkerArg Include=\"Cabinet.lib\" />\n\t\t<DirectPInvoke Include=\"winmm\" />\n\t\t<LinkerArg Include=\"winmm.lib\" />\n\t</ItemGroup>\n\n\t<Import Project=\"..\\SmolSharp.Win32\\SmolSharp.Win32.projitems\" Label=\"Shared\" />\n\n\t<Import Project=\"../SmolSharp.props\" />\n\n</Project>\n"
  },
  {
    "path": "src/SmolSharp.Win32/CompressAPI.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32\n{\n    internal static unsafe class CompressAPI\n    {\n        [SuppressGCTransition, DllImport(\"Cabinet\")]\n        public static extern bool CreateDecompressor(\n            CompressAlgorithm algorithm,\n            nint allocationRoutines,\n            nint* decompressorHandle\n        );\n\n        [SuppressGCTransition, DllImport(\"Cabinet\")]\n        public static extern bool Decompress(\n            nint decompressorHandle,\n            void* compressedData,\n            nint compressedDataSize,\n            void* uncompressedBuffer,\n            nint uncompressedBufferSize,\n            nint* uncompressedDataSize\n        );\n    }\n\n    public enum CompressAlgorithm : uint\n    {\n        MSZip = 2,\n        Xpress = 3,\n        XpressHuffman = 4,\n        LZMS = 5\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/GDI/GDIPaintStruct.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32.GDI\n{\n    [StructLayout(LayoutKind.Sequential)]\n    internal unsafe struct GDIPaintStruct\n    {\n        public nint Hdc;\n        public int Erase; // BOOL\n        public GDIRect RcPaint;\n        public int Restore; // BOOL\n        public int IncUpdate; // BOOL\n        public fixed byte RgbReserved[32];\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/GDI/GDIPoint.cs",
    "content": "﻿using System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32.GDI\n{\n    [StructLayout(LayoutKind.Sequential)]\n    internal struct GDIPoint\n    {\n        public int X;\n        public int Y;\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/GDI/GDIRect.cs",
    "content": "﻿using System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32.GDI\n{\n    [StructLayout(LayoutKind.Sequential)]\n    internal struct GDIRect\n    {\n        public int Left;\n        public int Top;\n        public int Right;\n        public int Bottom;\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/GDI/Gdi32.cs",
    "content": "﻿using SmolSharp.Win32.GDI.OpenGL;\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32.GDI\n{\n    internal static unsafe class Gdi32\n    {\n        [SuppressGCTransition, DllImport(\"gdi32\")]\n        public static extern uint SetPixel(\n            nint hdc,\n            int x, int y,\n            uint color\n        );\n\n        [SuppressGCTransition, DllImport(\"gdi32\")]\n        public static extern int ChoosePixelFormat(\n            nint hdc,\n            PixelFormatDescriptor* ppfd\n        );\n\n        [SuppressGCTransition, DllImport(\"gdi32\")]\n        public static extern bool SetPixelFormat(\n            nint hdc,\n            int format,\n            PixelFormatDescriptor* ppfd\n        );\n\n        [SuppressGCTransition, DllImport(\"gdi32\")]\n        public static extern bool SwapBuffers(\n            nint hdc\n        );\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/GDI/OpenGL/GL.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32.GDI.OpenGL\n{\n    internal static class GL\n    {\n        public const uint COLOR_BUFFER_BIT = 0x00004000;\n        public const uint FRAGMENT_SHADER = 35632;\n        public const uint VERTEX_SHADER = 35633;\n        public const uint ARRAY_BUFFER = 34962;\n        public const uint STATIC_DRAW = 35044;\n        public const uint FLOAT = 0x1406;\n        public const uint FALSE = 0;\n        public const uint TRIANGLES = 0x4;\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"wglCreateContext\")]\n        public static extern nint CreateContext(nint hdc);\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"wglMakeCurrent\")]\n        public static extern bool MakeCurrent(nint hdc, nint ctx);\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"glClearColor\")]\n        public static extern void SetClearColor(float r, float g, float b, float a);\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"glClear\")]\n        public static extern void Clear(uint mask);\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"wglGetProcAddress\")]\n        public static unsafe extern void* GetProcAddress(byte* name);\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"glDrawArrays\")]\n        public static extern void DrawArrays(\n            uint mode,\n            int first,\n            int count\n        );\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"glViewport\")]\n        public static extern void Viewport(int x, int y, uint width, uint height);\n\n        [SuppressGCTransition]\n        [DllImport(\"opengl32\", EntryPoint = \"glGetError\")]\n        public static extern uint GetError();\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/GDI/OpenGL/PixelFormatDescriptor.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32.GDI.OpenGL\n{\n    [StructLayout(LayoutKind.Sequential)]\n    public struct PixelFormatDescriptor\n    {\n        public ushort Size;\n        public ushort Version;\n        public PFDFlags Flags;\n        public byte PixelType;\n        public byte ColorBits;\n        public byte RedBits;\n        public byte RedShift;\n        public byte GreenBits;\n        public byte GreenShift;\n        public byte BlueBits;\n        public byte BlueShift;\n        public byte AlphaBits;\n        public byte AlphaShift;\n        public byte AccumBits;\n        public byte AccumRedBits;\n        public byte AccumGreenBits;\n        public byte AccumBlueBits;\n        public byte AccumAlphaBits;\n        public byte DepthBits;\n        public byte StencilBits;\n        public byte AuxBuffers;\n        public byte LayerType;\n        public byte Reserved;\n        public uint LayerMask;\n        public uint VisibleMask;\n        public uint DamageMask;\n    }\n\n    public enum PFDFlags : uint\n    {\n        DrawToWindow = 0x00000004,\n        SupportOpenGL = 0x00000020,\n        DoubleBuffered = 0x00000001\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/Kernel32.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32\n{\n    internal static unsafe class Kernel32\n    {\n        [SuppressGCTransition, DllImport(\"kernel32\")]\n        public static extern nint CreateThread(\n            nint threadAttributes,\n            nint stackSize,\n            delegate* unmanaged<nint, uint> lpStartAddress,\n            nint lpParameter = 0,\n            uint creationFlags = 0,\n            nint lpThreadId = 0\n        );\n\n        [SuppressGCTransition, DllImport(\"kernel32\")]\n        public static extern void* GlobalAlloc(uint dwFlags, nint dwBytes);\n\n        [SuppressGCTransition, DllImport(\"kernel32\")]\n        public static extern bool AllocConsole();\n\n        [SuppressGCTransition, DllImport(\"kernel32\")]\n        public static extern void Sleep(uint ms);\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/SmolSharp.Win32.projitems",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup>\n    <MSBuildAllProjects Condition=\"'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'\">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>\n    <HasSharedItems>true</HasSharedItems>\n    <SharedGUID>29d02aaa-5c78-42ed-b1b4-5b30357d78a7</SharedGUID>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\">\n    <Import_RootNamespace>SmolSharp.Win32</Import_RootNamespace>\n  </PropertyGroup>\n  <ItemGroup>\n    <Compile Include=\"$(MSBuildThisFileDirectory)CompressAPI.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)GDI\\Gdi32.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)GDI\\GDIPaintStruct.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)GDI\\GDIPoint.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)GDI\\GDIRect.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)GDI\\OpenGL\\GL.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)GDI\\OpenGL\\PixelFormatDescriptor.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)Kernel32.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)User32.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)WindowClassA.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)WinMM.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)WndMessage.cs\" />\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "src/SmolSharp.Win32/SmolSharp.Win32.shproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>29d02aaa-5c78-42ed-b1b4-5b30357d78a7</ProjectGuid>\n    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\n  </PropertyGroup>\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.Default.props\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.props\" />\n  <PropertyGroup />\n  <Import Project=\"SmolSharp.Win32.projitems\" Label=\"Shared\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.CSharp.targets\" />\n</Project>\n"
  },
  {
    "path": "src/SmolSharp.Win32/User32.cs",
    "content": "﻿using SmolSharp.Win32.GDI;\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32\n{\n    internal static unsafe class User32\n    {\n        [SuppressGCTransition]\n        [DllImport(\"user32\", EntryPoint = \"CreateWindowExA\")]\n        public static extern nint CreateWindowEx(\n            uint dwExStyles,\n            void* lpClassName,\n            void* lpWindowName,\n            uint dwStyle,\n            int x,\n            int y,\n            int nWidth,\n            int nHeight,\n            nint hwndParent = 0,\n            nint hMenu = 0,\n            nint hInstance = 0,\n            nint lpParam = 0\n        );\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\", EntryPoint = \"RegisterClassA\")]\n        public static extern nint RegisterClass(WindowClassA* lpWndClass);\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\", EntryPoint = \"ShowWindow\")]\n        public static extern nint ShowWindow(nint hWnd, int nCmdShow);\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\", EntryPoint = \"GetMessageA\")]\n        public static extern int GetMessage(\n            WndMessage* lpMsg,\n            nint hwnd,\n            uint wMsgFilterMin,\n            uint wMsgFilterMax\n        );\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\", EntryPoint = \"TranslateMessage\")]\n        public static extern bool TranslateMessage(WndMessage* lpMsg);\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\", EntryPoint = \"DispatchMessageA\")]\n        public static extern bool DispatchMessage(WndMessage* lpMsg);\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\", EntryPoint = \"DefWindowProcA\")]\n        public static extern nint DefWindowProc(\n            nint hwnd,\n            uint msg,\n            nuint wParam,\n            nint lParam\n        );\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\")]\n        public static extern nint GetDC(nint hwnd);\n\n        //[DllImport(\"user32\")]\n        //public static extern nint BeginPaint(\n        //    nint hWnd,\n        //    GDIPaintStruct* lpPaint\n        //);\n\n        //[DllImport(\"user32\")]\n        //public static extern bool EndPaint(\n        //    nint hWnd,\n        //    GDIPaintStruct* lpPaint\n        //);\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\")]\n        public static extern bool GetWindowRect(\n            nint hwnd,\n            GDIRect* lpRect\n        );\n\n        [SuppressGCTransition]\n        [DllImport(\"user32\")]\n        public static extern void PostQuitMessage(int nExitCode);\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/WinMM.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32\n{\n    internal static class WinMM\n    {\n        [SuppressGCTransition]\n        [DllImport(\"winmm.dll\", EntryPoint = \"timeGetTime\")]\n        public static extern uint GetTime();\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/WindowClassA.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\n\nnamespace SmolSharp.Win32\n{\n    [StructLayout(LayoutKind.Sequential)]\n    internal unsafe struct WindowClassA\n    {\n        public uint Style;\n        public delegate* unmanaged<nint, uint, nuint, nint, nint> WndProc;\n        public int ClsExtra;\n        public int WndExtra;\n        public nint HInstance;\n        public nint HIcon;\n        public nint HCursor;\n        public nint HBrBackground;\n        public void* MenuName;\n        public void* ClassName;\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.Win32/WndMessage.cs",
    "content": "﻿using System;\nusing System.Runtime.InteropServices;\nusing SmolSharp.Win32.GDI;\n\nnamespace SmolSharp.Win32\n{\n    [StructLayout(LayoutKind.Sequential)]\n    internal struct WndMessage\n    {\n        public nint Hwnd;\n        public uint Message;\n        public nuint WParam;\n        public nint LParam;\n        public int Time;\n        public GDIPoint Point;\n        private readonly int lPrivate;\n    }\n}\n"
  },
  {
    "path": "src/SmolSharp.props",
    "content": "<Project>\n\t<PropertyGroup>\n\t\t<DefineConstants>WINDOWS</DefineConstants>\n\t\t<PublishAot>true</PublishAot>\n\t\t<ImplicitUsings>disable</ImplicitUsings>\n\t</PropertyGroup>\n\n\t<!-- Use bflat's zerolib as the standard library -->\n\t<!-- See https://github.com/bflattened/bflat/ for more details! -->\n\t<Import Project=\".\\BFlat.ZeroLib\\BFlat.ZeroLib.projitems\" Label=\"Shared\" />\n\t<PropertyGroup>\n\t\t<NoStdLib>true</NoStdLib>\n\t\t<NoConfig>true</NoConfig>\n\t\t<GenerateAssemblyInfo>false</GenerateAssemblyInfo>\n\t\t<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\n\t\t<RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>\n\t\t<IlcSystemModule>$(MSBuildProjectName)</IlcSystemModule>\n\t\t<AllowUnsafeBlocks>true</AllowUnsafeBlocks>\n\t\t<EntryPointSymbol>smolsharp_main</EntryPointSymbol>\n\t\t<DebugType>none</DebugType>\n\t</PropertyGroup>\n\n\t<ItemGroup>\n\t\t<DirectPInvoke Include=\"kernel32\" />\n\t\t<DirectPInvoke Include=\"shell32\" />\n\t\t<DirectPInvoke Include=\"user32\" />\n\t\t<DirectPInvoke Include=\"ntdll\" />\n\t\t<DirectPInvoke Include=\"gdi32\" />\n\t</ItemGroup>\n\n\t<ItemGroup>\n\t\t<LinkerArg Remove=\"$(LinkerArg)\"/>\n\t\t<LinkerArg Include=\"/align:16\"></LinkerArg>\n\t\t<LinkerArg Include=\"/manifestuac:no\"></LinkerArg>\n\t\t<LinkerArg Include=\"/opt:ref /opt:icf\"></LinkerArg>\n\t\t<LinkerArg Include=\"/safeseh:no\"></LinkerArg>\n\t\t<LinkerArg Include=\"/emittoolversioninfo:no\"></LinkerArg>\n\t\t<LinkerArg Include=\"/emitpogophaseinfo\"></LinkerArg>\n\t\t<LinkerArg Include=\"/nodefaultlib\"></LinkerArg>\n\t\t<LinkerArg Include=\"/fixed\"></LinkerArg> <!-- disabling relocations makes the linker skip emitting the .reloc section, which saves us about ~100 bytes -->\n\t\t<LinkerArg Include=\"/merge:.modules=.rdata\"></LinkerArg>\n\t\t<LinkerArg Include=\"/merge:.managedcode=.text\"></LinkerArg>\n\t\t<LinkerArg Include=\"user32.lib\"></LinkerArg>\n\t\t<LinkerArg Include=\"shell32.lib\"></LinkerArg>\n\t\t<LinkerArg Include=\"gdi32.lib\"></LinkerArg>\n\t</ItemGroup>\n\n\t<PropertyGroup>\n\t\t<IlcDisableReflection>true</IlcDisableReflection>\n\t\t<StackTraceSupport>false</StackTraceSupport> <!-- .NET 8+ -->\n\t\t<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData> <!-- < .NET 8 -->\n\t\t<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>\n\t\t<IlcDehydrate>false</IlcDehydrate>\n\t\t<IlcGenerateWin32Resources>false</IlcGenerateWin32Resources> <!-- .NET 8 -->\n\t\t<Optimize>true</Optimize>\n\t\t<OptimizationPreference>Size</OptimizationPreference>\n\t</PropertyGroup>\n\t\n\t<Target Name=\"ModifyObj\" BeforeTargets=\"LinkNative\">\n\t\t<Exec Command=\"objcopy --remove-section .pdata &quot;$(NativeObject)&quot;\" />\n\t\t<Exec Command=\"objcopy -w --set-section-alignment *=1 &quot;$(NativeObject)&quot;\" />\n\t</Target>\n\n\t<UsingTask\n\t\t  TaskName=\"TrimNullBytes\"\n\t\t  TaskFactory=\"RoslynCodeTaskFactory\"\n\t\t  AssemblyFile=\"$(MSBuildToolsPath)\\Microsoft.Build.Tasks.Core.dll\"\n\t>\n\t\t<ParameterGroup>\n\t\t\t<TargetPath ParameterType=\"System.String\" Required=\"true\"/>\n\t\t</ParameterGroup>\n\t\t\n\t\t<Task>\n\t\t\t<Using Namespace=\"System\"/>\n\t\t\t<Using Namespace=\"System.IO\"/>\n\t\t\t<Code Type=\"Fragment\" Language=\"cs\">\n\t\t\t\t<![CDATA[\n\t\t\t\tvar file = File.ReadAllBytes(TargetPath);\n\t\t\t\tint i = file.Length - 1;\n\t\t\t\twhile (file[i] == 0x00)\n\t\t\t\t\t--i;\n\n\t\t\t\tbyte[] trimmed = new byte[i + 1];\n\t\t\t\tArray.Copy(file, trimmed, i + 1);\n\t\t\t\tFile.WriteAllBytes(TargetPath, trimmed);\n\t\t\t\t]]>\n\t\t\t</Code>\n\t\t</Task>\n\t</UsingTask>\n\n\t<Target Name=\"ModifyBinary\" AfterTargets=\"LinkNative\">\n\t\t<TrimNullBytes TargetPath=\"$(NativeBinary)\"/> \n\t</Target>\n\n\t<Target Name=\"RemoveIlcSwitches\" BeforeTargets=\"IlcCompile\" DependsOnTargets=\"WriteIlcRspFileForCompilation\">\n\t\t<ItemGroup>\n\t\t\t<IlcArg Remove=\"--runtimeknob:RUNTIME_IDENTIFIER=win-x64\" />\n\t\t\t<IlcArg Remove=\"--resilient\" />\n\t\t</ItemGroup>\n\t\t<WriteLinesToFile File=\"%(ManagedBinary.IlcRspFile)\" Lines=\"@(IlcArg)\" Overwrite=\"true\" WriteOnlyWhenDifferent=\"true\" />\n\t</Target>\n\n\t<!-- < .NET 8 -->\n\t<Target Name=\"RemoveWin32Resources\" BeforeTargets=\"LinkNative\" Outputs=\"$(_Win32ResFile)\">\n\t\t<PropertyGroup>\n\t\t\t<_Win32ResFile></_Win32ResFile>\n\t\t</PropertyGroup>\n\t</Target>\n\n\t<Target Name=\"RemoveSDKLibs\" AfterTargets=\"SetupOSSpecificProps\">\n\t\t<ItemGroup>\n\t\t\t<LinkerArg Remove=\"@(NativeLibrary->'&quot;%(Identity)&quot;')\"/>\n\t\t</ItemGroup>\n\t</Target>\n\t\n\t<!-- The project file pretends this is .NET, but it's not .NET. Remove all assembly references the .NET SDK added. -->\n\t<Target Name=\"CustomizeReferences\" BeforeTargets=\"BeforeCompile\" AfterTargets=\"FindReferenceAssembliesForReferences\">\n\t\t<ItemGroup>\n\t\t\t<ReferencePathWithRefAssemblies Remove=\"@(ReferencePathWithRefAssemblies)\" />\n\t\t\t<ReferencePath Remove=\"@(ReferencePath)\" />\n\t\t</ItemGroup>\n\t</Target>\n\n\t<!-- The AOT compiler would want to mirror these as AppContext switches. Prevent that. -->\n\t<Target Name=\"RemoveHostConfigurationOptions\" BeforeTargets=\"WriteIlcRspFileForCompilation\" DependsOnTargets=\"PrepareForILLink\">\n\t\t<ItemGroup>\n\t\t\t<RuntimeHostConfigurationOption Remove=\"@(RuntimeHostConfigurationOption)\" />\n\t\t</ItemGroup>\n\t</Target>\n\n</Project>"
  },
  {
    "path": "src/SmolSharp.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.5.33530.505\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{D954291E-2A0B-460D-934E-DC6B0785DB48}\") = \"BFlat.ZeroLib\", \"BFlat.ZeroLib\\BFlat.ZeroLib.shproj\", \"{5898FE8D-6758-42D0-9303-2AEAAE32C47B}\"\nEndProject\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Solution Items\", \"Solution Items\", \"{CE20C05D-F7EE-485F-B8CA-51A0B3EFC47F}\"\n\tProjectSection(SolutionItems) = preProject\n\t\tSmolSharp.props = SmolSharp.props\n\tEndProjectSection\nEndProject\nProject(\"{D954291E-2A0B-460D-934E-DC6B0785DB48}\") = \"SmolSharp.Win32\", \"SmolSharp.Win32\\SmolSharp.Win32.shproj\", \"{29D02AAA-5C78-42ED-B1B4-5B30357D78A7}\"\nEndProject\nProject(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"SmolSharp.HelloWorld\", \"SmolSharp.HelloWorld\\SmolSharp.HelloWorld.csproj\", \"{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}\"\nEndProject\nProject(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"SmolSharp.Mandelbrot\", \"SmolSharp.Mandelbrot\\SmolSharp.Mandelbrot.csproj\", \"{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}\"\nEndProject\nProject(\"{9A19103F-16F7-4668-BE54-9A1E7A4F7556}\") = \"SmolSharp.Ocean\", \"SmolSharp.Ocean\\SmolSharp.Ocean.csproj\", \"{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}\"\nEndProject\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Tools\", \"Tools\", \"{E0A9C070-823A-4279-9C23-99A056CB0E30}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"ShaderCompressor\", \"ShaderCompressor\\ShaderCompressor.vcxproj\", \"{825D439A-CADC-4473-9381-F06E728D4A9B}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Any CPU = Debug|Any CPU\n\t\tDebug|x64 = Debug|x64\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|Any CPU = Release|Any CPU\n\t\tRelease|x64 = Release|x64\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Debug|x64.Build.0 = Debug|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Release|x64.Build.0 = Release|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{AAF9AE2C-43E1-4739-97CB-5B0B096A1042}.Release|x86.Build.0 = Release|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Debug|x64.Build.0 = Debug|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Release|x64.Build.0 = Release|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{C8C1BA5B-A5BC-4AC8-A562-1645DCDF0425}.Release|x86.Build.0 = Release|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Debug|x64.Build.0 = Debug|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Release|x64.Build.0 = Release|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{AD0302DC-D9B7-42D2-B52E-3D28FED5AE4F}.Release|x86.Build.0 = Release|Any CPU\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Debug|Any CPU.ActiveCfg = Debug|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Debug|Any CPU.Build.0 = Debug|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Debug|x64.Build.0 = Debug|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Debug|x86.Build.0 = Debug|Win32\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Release|Any CPU.ActiveCfg = Release|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Release|Any CPU.Build.0 = Release|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Release|x64.ActiveCfg = Release|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Release|x64.Build.0 = Release|x64\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Release|x86.ActiveCfg = Release|Win32\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B}.Release|x86.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(NestedProjects) = preSolution\n\t\t{825D439A-CADC-4473-9381-F06E728D4A9B} = {E0A9C070-823A-4279-9C23-99A056CB0E30}\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {894863AF-D73C-441C-99AC-88062A8430DD}\n\tEndGlobalSection\n\tGlobalSection(SharedMSBuildProjectFiles) = preSolution\n\t\tSmolSharp.Win32\\SmolSharp.Win32.projitems*{29d02aaa-5c78-42ed-b1b4-5b30357d78a7}*SharedItemsImports = 13\n\t\tBFlat.ZeroLib\\BFlat.ZeroLib.projitems*{5898fe8d-6758-42d0-9303-2aeaae32c47b}*SharedItemsImports = 13\n\t\tSmolSharp.Win32\\SmolSharp.Win32.projitems*{ad0302dc-d9b7-42d2-b52e-3d28fed5ae4f}*SharedItemsImports = 5\n\t\tSmolSharp.Win32\\SmolSharp.Win32.projitems*{c8c1ba5b-a5bc-4ac8-a562-1645dcdf0425}*SharedItemsImports = 5\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "tools/readme.md",
    "content": "This directory is used for external tools. No binaries are included by default.\nGet `shader_minifier.exe` from [here](https://github.com/laurentlb/Shader_Minifier/releases/).\n"
  }
]