From ef18155db1f71adf253531dfa72701748668386c Mon Sep 17 00:00:00 2001 From: Michael McMaster Date: Mon, 31 Jan 2011 21:22:24 +1000 Subject: [PATCH] First release - OpenGL hq4x shader works! --- COPYING | 674 +++++ Resample.cc | 0 mm80.hh => glBoy.hh | 0 hq4x.cc | 5320 ++++++++++++++++++++++++++++++++++++ hq4x.hh | 0 retired/GameboyGraphics.cc | 1056 +++++++ retired/README | 26 + retired/Resample.cc | 137 + retired/hq4x.cc | 5267 +++++++++++++++++++++++++++++++++++ shaders/scale2x.slf | 83 + shaders/scale2x.slv | 54 + 11 files changed, 12617 insertions(+) create mode 100644 COPYING create mode 100644 Resample.cc rename mm80.hh => glBoy.hh (100%) create mode 100644 hq4x.cc create mode 100644 hq4x.hh create mode 100644 retired/GameboyGraphics.cc create mode 100644 retired/README create mode 100644 retired/Resample.cc create mode 100644 retired/hq4x.cc create mode 100644 shaders/scale2x.slf create mode 100644 shaders/scale2x.slv diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Resample.cc b/Resample.cc new file mode 100644 index 0000000..e69de29 diff --git a/mm80.hh b/glBoy.hh similarity index 100% rename from mm80.hh rename to glBoy.hh diff --git a/hq4x.cc b/hq4x.cc new file mode 100644 index 0000000..6c145d2 --- /dev/null +++ b/hq4x.cc @@ -0,0 +1,5320 @@ +//hq4x filter demo program +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) + +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +// Converted to grayscale 2010 by Michael McMaster (Michael.McMaster@gmail.com) +// Then converted to generate a lookup table, inspired by +// Phill Djonov XNA implementation (http://github.com/pdjonov/hqnx/wiki) +// -But, each 3x3 weight matrix is packed into a single 32bit RGBA value, +// instead of 2 RGBA's. + +/* +Each weight = number between 0 and 8 inclusive. 4 bits. +Treated as weight/8f + +So, for each input pixel, build a 3x3 matrix of surrounding +pixels. + 1 2 3 12bits + 4 5 6 12bits + 7 8 9 12bits + ------ + 36 bits. +hmm. Skip the 5th weight. The matrix has to Sum to 8, so we can +make up 1 missing value. + 1 2 3 12bits + 4 _ 6 8bits + 7 8 9 12bits + ------ + 32 bits TICK + +We then produce a 4x4 matrix of output pixels. + +Need 256 sets of 16 x 3x3 matrices or, + +1) 3x3 matrix fix in 32bits. So just need a 256 sets of 4x4 matrix. +4096 pixels. + +2) There are 4 choices (2^4 outcomes = 16) +Diff (w[2], w[6]) +Diff (w[6], w[8]) +Diff (w[8], w[4]) +Diff (w[4], w[2]) + +Layout of texture: +Y = pattern # (0 -> 255) +X = + Top 4 bits = diff bitmask + Lower 4 bits = output pixel # +*/ + +#include "hq4x.hh" + +#include +#include +#include +#include +#include + +enum Diff { Diff_2_6 = 1, Diff_6_8 = 2, Diff_8_4 = 4, Diff_4_2 = 8 }; + +struct weight +{ + weight() : w1(0),w2(0),w3(0),w4(0),w5(0),w6(0),w7(0),w8(0),w9(0){} + uint32_t w1; uint32_t w2; uint32_t w3; + uint32_t w4; uint32_t w5; uint32_t w6; + uint32_t w7; uint32_t w8; uint32_t w9; +}; + +inline void Interp1(uint32_t& c1, uint32_t& c2) +{ + c1 = 6; + c2 = 2; +} + +inline void Interp2(uint32_t& c1, uint32_t& c2, uint32_t& c3) +{ + c1 = 4; + c2 = 2; + c3 = 2; +} + +inline void Interp3(uint32_t& c1, uint32_t& c2) +{ + c1 = 7; + c2 = 1; +} + +inline void Interp5(uint32_t& c1, uint32_t& c2) +{ + c1 = 4; + c2 = 4; +} + +inline void Interp6(uint32_t& c1, uint32_t& c2, uint32_t& c3) +{ + c1 = 5; + c2 = 2; + c3 = 1; +} + +inline void Interp7(uint32_t& c1, uint32_t& c2, uint32_t& c3) +{ + c1 = 6; + c2 = 1; + c3 = 1; +} + +inline void Interp8(uint32_t& c1, uint32_t& c2) +{ + c1 = 5; + c2 = 3; +} + + + +#define p1 weights[0][0] +#define p2 weights[0][1] +#define p3 weights[0][2] +#define p4 weights[0][3] +#define p5 weights[1][0] +#define p6 weights[1][1] +#define p7 weights[1][2] +#define p8 weights[1][3] +#define p9 weights[2][0] +#define p10 weights[2][1] +#define p11 weights[2][2] +#define p12 weights[2][3] +#define p13 weights[3][0] +#define p14 weights[3][1] +#define p15 weights[3][2] +#define p16 weights[3][3] + +#define PIXEL00_0 p1.w5 = 8; +#define PIXEL00_11 Interp1(p1.w5, p1.w4); +#define PIXEL00_12 Interp1(p1.w5, p1.w2);; +#define PIXEL00_20 Interp2(p1.w5, p1.w2, p1.w4); +#define PIXEL00_50 Interp5(p1.w2, p1.w4); +#define PIXEL00_80 Interp8(p1.w5, p1.w1); +#define PIXEL00_81 Interp8(p1.w5, p1.w4); +#define PIXEL00_82 Interp8(p1.w5, p1.w2); + +#define PIXEL01_0 p2.w5 = 8; +#define PIXEL01_10 Interp1(p2.w5, p2.w1); +#define PIXEL01_12 Interp1(p2.w5, p2.w2); +#define PIXEL01_14 Interp1(p2.w2, p2.w5); +#define PIXEL01_21 Interp2(p2.w2, p2.w5, p2.w4); +#define PIXEL01_31 Interp3(p2.w5, p2.w4); +#define PIXEL01_50 Interp5(p2.w2, p2.w5); +#define PIXEL01_60 Interp6(p2.w5, p2.w2, p2.w4); +#define PIXEL01_61 Interp6(p2.w5, p2.w2, p2.w1); +#define PIXEL01_82 Interp8(p2.w5, p2.w2); +#define PIXEL01_83 Interp8(p2.w2, p2.w4); + +#define PIXEL02_0 p3.w5 = 8; +#define PIXEL02_10 Interp1(p3.w5, p3.w3); +#define PIXEL02_11 Interp1(p3.w5, p3.w2); +#define PIXEL02_13 Interp1(p3.w2, p3.w5); +#define PIXEL02_21 Interp2(p3.w2, p3.w5, p3.w6); +#define PIXEL02_32 Interp3(p3.w5, p3.w6); +#define PIXEL02_50 Interp5(p3.w2, p3.w5); +#define PIXEL02_60 Interp6(p3.w5, p3.w2, p3.w6); +#define PIXEL02_61 Interp6(p3.w5, p3.w2, p3.w3); +#define PIXEL02_81 Interp8(p3.w5, p3.w2); +#define PIXEL02_83 Interp8(p3.w2, p3.w6); + +#define PIXEL03_0 p4.w5 = 8; +#define PIXEL03_11 Interp1(p4.w5, p4.w2); +#define PIXEL03_12 Interp1(p4.w5, p4.w6); +#define PIXEL03_20 Interp2(p4.w5, p4.w2, p4.w6); +#define PIXEL03_50 Interp5(p4.w2, p4.w6); +#define PIXEL03_80 Interp8(p4.w5, p4.w3); +#define PIXEL03_81 Interp8(p4.w5, p4.w2); +#define PIXEL03_82 Interp8(p4.w5, p4.w6); + +#define PIXEL10_0 p5.w5 = 8; +#define PIXEL10_10 Interp1(p5.w5, p5.w1); +#define PIXEL10_11 Interp1(p5.w5, p5.w4); +#define PIXEL10_13 Interp1(p5.w4, p5.w5); +#define PIXEL10_21 Interp2(p5.w4, p5.w5, p5.w2); +#define PIXEL10_32 Interp3(p5.w5, p5.w2); +#define PIXEL10_50 Interp5(p5.w4, p5.w5); +#define PIXEL10_60 Interp6(p5.w5, p5.w4, p5.w2); +#define PIXEL10_61 Interp6(p5.w5, p5.w4, p5.w1); +#define PIXEL10_81 Interp8(p5.w5, p5.w4); +#define PIXEL10_83 Interp8(p5.w4, p5.w2); + +#define PIXEL11_0 p6.w5 = 8; +#define PIXEL11_30 Interp3(p6.w5, p6.w1); +#define PIXEL11_31 Interp3(p6.w5, p6.w4); +#define PIXEL11_32 Interp3(p6.w5, p6.w2); +#define PIXEL11_70 Interp7(p6.w5, p6.w4, p6.w2); + +#define PIXEL12_0 p7.w5 = 8; +#define PIXEL12_30 Interp3(p7.w5, p7.w3); +#define PIXEL12_31 Interp3(p7.w5, p7.w2); +#define PIXEL12_32 Interp3(p7.w5, p7.w6); +#define PIXEL12_70 Interp7(p7.w5, p7.w6, p7.w2); + +#define PIXEL13_0 p8.w5 = 8; +#define PIXEL13_10 Interp1(p8.w5, p8.w3); +#define PIXEL13_12 Interp1(p8.w5, p8.w6); +#define PIXEL13_14 Interp1(p8.w6, p8.w5); +#define PIXEL13_21 Interp2(p8.w6, p8.w5, p8.w2); +#define PIXEL13_31 Interp3(p8.w5, p8.w2); +#define PIXEL13_50 Interp5(p8.w6, p8.w5); +#define PIXEL13_60 Interp6(p8.w5, p8.w6, p8.w2); +#define PIXEL13_61 Interp6(p8.w5, p8.w6, p8.w3); +#define PIXEL13_82 Interp8(p8.w5, p8.w6); +#define PIXEL13_83 Interp8(p8.w6, p8.w2); + +#define PIXEL20_0 p9.w5 = 8; +#define PIXEL20_10 Interp1(p9.w5, p9.w7); +#define PIXEL20_12 Interp1(p9.w5, p9.w4); +#define PIXEL20_14 Interp1(p9.w4, p9.w5); +#define PIXEL20_21 Interp2(p9.w4, p9.w5, p9.w8); +#define PIXEL20_31 Interp3(p9.w5, p9.w8); +#define PIXEL20_50 Interp5(p9.w4, p9.w5); +#define PIXEL20_60 Interp6(p9.w5, p9.w4, p9.w8); +#define PIXEL20_61 Interp6(p9.w5, p9.w4, p9.w7); +#define PIXEL20_82 Interp8(p9.w5, p9.w4); +#define PIXEL20_83 Interp8(p9.w4, p9.w8); + +#define PIXEL21_0 p10.w5 = 8; +#define PIXEL21_30 Interp3(p10.w5, p10.w7); +#define PIXEL21_31 Interp3(p10.w5, p10.w8); +#define PIXEL21_32 Interp3(p10.w5, p10.w4); +#define PIXEL21_70 Interp7(p10.w5, p10.w4, p10.w8); + +#define PIXEL22_0 p11.w5 = 8; +#define PIXEL22_30 Interp3(p11.w5, p11.w9); +#define PIXEL22_31 Interp3(p11.w5, p11.w6); +#define PIXEL22_32 Interp3(p11.w5, p11.w8); +#define PIXEL22_70 Interp7(p11.w5, p11.w6, p11.w8); + +#define PIXEL23_0 p12.w5 = 8; +#define PIXEL23_10 Interp1(p12.w5, p12.w9); +#define PIXEL23_11 Interp1(p12.w5, p12.w6); +#define PIXEL23_13 Interp1(p12.w6, p12.w5); +#define PIXEL23_21 Interp2(p12.w6, p12.w5, p12.w8); +#define PIXEL23_32 Interp3(p12.w5, p12.w8); +#define PIXEL23_50 Interp5(p12.w6, p12.w5); +#define PIXEL23_60 Interp6(p12.w5, p12.w6, p12.w8); +#define PIXEL23_61 Interp6(p12.w5, p12.w6, p12.w9); +#define PIXEL23_81 Interp8(p12.w5, p12.w6); +#define PIXEL23_83 Interp8(p12.w6, p12.w8); + +#define PIXEL30_0 p13.w5 = 8; +#define PIXEL30_11 Interp1(p13.w5, p13.w8); +#define PIXEL30_12 Interp1(p13.w5, p13.w4); +#define PIXEL30_20 Interp2(p13.w5, p13.w8, p13.w4); +#define PIXEL30_50 Interp5(p13.w8, p13.w4); +#define PIXEL30_80 Interp8(p13.w5, p13.w7); +#define PIXEL30_81 Interp8(p13.w5, p13.w8); +#define PIXEL30_82 Interp8(p13.w5, p13.w4); + +#define PIXEL31_0 p14.w5 = 8; +#define PIXEL31_10 Interp1(p14.w5, p14.w7); +#define PIXEL31_11 Interp1(p14.w5, p14.w8); +#define PIXEL31_13 Interp1(p14.w8, p14.w5); +#define PIXEL31_21 Interp2(p14.w8, p14.w5, p14.w4); +#define PIXEL31_32 Interp3(p14.w5, p14.w4); +#define PIXEL31_50 Interp5(p14.w8, p14.w5); +#define PIXEL31_60 Interp6(p14.w5, p14.w8, p14.w4); +#define PIXEL31_61 Interp6(p14.w5, p14.w8, p14.w7); +#define PIXEL31_81 Interp8(p14.w5, p14.w8); +#define PIXEL31_83 Interp8(p14.w8, p14.w4); + +#define PIXEL32_0 p15.w5 = 8; +#define PIXEL32_10 Interp1(p15.w5, p15.w9); +#define PIXEL32_12 Interp1(p15.w5, p15.w8); +#define PIXEL32_14 Interp1(p15.w8, p15.w5); +#define PIXEL32_21 Interp2(p15.w8, p15.w5, p15.w6); +#define PIXEL32_31 Interp3(p15.w5, p15.w6); +#define PIXEL32_50 Interp5(p15.w8, p15.w5); +#define PIXEL32_60 Interp6(p15.w5, p15.w8, p15.w6); +#define PIXEL32_61 Interp6(p15.w5, p15.w8, p15.w9); +#define PIXEL32_82 Interp8(p15.w5, p15.w8); +#define PIXEL32_83 Interp8(p15.w8, p15.w6); + +#define PIXEL33_0 p16.w5 = 8; +#define PIXEL33_11 Interp1(p16.w5, p16.w6); +#define PIXEL33_12 Interp1(p16.w5, p16.w8); +#define PIXEL33_20 Interp2(p16.w5, p16.w8, p16.w6); +#define PIXEL33_50 Interp5(p16.w8, p16.w6); +#define PIXEL33_80 Interp8(p16.w5, p16.w9); +#define PIXEL33_81 Interp8(p16.w5, p16.w6); +#define PIXEL33_82 Interp8(p16.w5, p16.w8); + + + +uint32_t* getHq4xLookupTable() +{ + static uint32_t* s_table(0); + + if (s_table) + { + return s_table; + } + else + { + for (int pattern = 0; pattern < 256; ++pattern) + { + weight weights[4][4]; + + for (int diff = 0; diff < 16; ++diff) + { + switch (pattern) + { + case 0: + case 1: + case 4: + case 32: + case 128: + case 5: + case 132: + case 160: + case 33: + case 129: + case 36: + case 133: + case 164: + case 161: + case 37: + case 165: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_60; + PIXEL03_20; + PIXEL10_60; + PIXEL11_70; + PIXEL12_70; + PIXEL13_60; + PIXEL20_60; + PIXEL21_70; + PIXEL22_70; + PIXEL23_60; + PIXEL30_20; + PIXEL31_60; + PIXEL32_60; + PIXEL33_20; + break; + } + case 2: + case 34: + case 130: + case 162: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_61; + PIXEL11_30; + PIXEL12_30; + PIXEL13_61; + PIXEL20_60; + PIXEL21_70; + PIXEL22_70; + PIXEL23_60; + PIXEL30_20; + PIXEL31_60; + PIXEL32_60; + PIXEL33_20; + break; + } + case 16: + case 17: + case 48: + case 49: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_61; + PIXEL03_80; + PIXEL10_60; + PIXEL11_70; + PIXEL12_30; + PIXEL13_10; + PIXEL20_60; + PIXEL21_70; + PIXEL22_30; + PIXEL23_10; + PIXEL30_20; + PIXEL31_60; + PIXEL32_61; + PIXEL33_80; + break; + } + case 64: + case 65: + case 68: + case 69: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_60; + PIXEL03_20; + PIXEL10_60; + PIXEL11_70; + PIXEL12_70; + PIXEL13_60; + PIXEL20_61; + PIXEL21_30; + PIXEL22_30; + PIXEL23_61; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 8: + case 12: + case 136: + case 140: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_60; + PIXEL03_20; + PIXEL10_10; + PIXEL11_30; + PIXEL12_70; + PIXEL13_60; + PIXEL20_10; + PIXEL21_30; + PIXEL22_70; + PIXEL23_60; + PIXEL30_80; + PIXEL31_61; + PIXEL32_60; + PIXEL33_20; + break; + } + case 3: + case 35: + case 131: + case 163: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL10_81; + PIXEL11_31; + PIXEL12_30; + PIXEL13_61; + PIXEL20_60; + PIXEL21_70; + PIXEL22_70; + PIXEL23_60; + PIXEL30_20; + PIXEL31_60; + PIXEL32_60; + PIXEL33_20; + break; + } + case 6: + case 38: + case 134: + case 166: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_61; + PIXEL11_30; + PIXEL12_32; + PIXEL13_82; + PIXEL20_60; + PIXEL21_70; + PIXEL22_70; + PIXEL23_60; + PIXEL30_20; + PIXEL31_60; + PIXEL32_60; + PIXEL33_20; + break; + } + case 20: + case 21: + case 52: + case 53: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_81; + PIXEL03_81; + PIXEL10_60; + PIXEL11_70; + PIXEL12_31; + PIXEL13_31; + PIXEL20_60; + PIXEL21_70; + PIXEL22_30; + PIXEL23_10; + PIXEL30_20; + PIXEL31_60; + PIXEL32_61; + PIXEL33_80; + break; + } + case 144: + case 145: + case 176: + case 177: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_61; + PIXEL03_80; + PIXEL10_60; + PIXEL11_70; + PIXEL12_30; + PIXEL13_10; + PIXEL20_60; + PIXEL21_70; + PIXEL22_32; + PIXEL23_32; + PIXEL30_20; + PIXEL31_60; + PIXEL32_82; + PIXEL33_82; + break; + } + case 192: + case 193: + case 196: + case 197: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_60; + PIXEL03_20; + PIXEL10_60; + PIXEL11_70; + PIXEL12_70; + PIXEL13_60; + PIXEL20_61; + PIXEL21_30; + PIXEL22_31; + PIXEL23_81; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + break; + } + case 96: + case 97: + case 100: + case 101: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_60; + PIXEL03_20; + PIXEL10_60; + PIXEL11_70; + PIXEL12_70; + PIXEL13_60; + PIXEL20_82; + PIXEL21_32; + PIXEL22_30; + PIXEL23_61; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + break; + } + case 40: + case 44: + case 168: + case 172: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_60; + PIXEL03_20; + PIXEL10_10; + PIXEL11_30; + PIXEL12_70; + PIXEL13_60; + PIXEL20_31; + PIXEL21_31; + PIXEL22_70; + PIXEL23_60; + PIXEL30_81; + PIXEL31_81; + PIXEL32_60; + PIXEL33_20; + break; + } + case 9: + case 13: + case 137: + case 141: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_60; + PIXEL03_20; + PIXEL10_32; + PIXEL11_32; + PIXEL12_70; + PIXEL13_60; + PIXEL20_10; + PIXEL21_30; + PIXEL22_70; + PIXEL23_60; + PIXEL30_80; + PIXEL31_61; + PIXEL32_60; + PIXEL33_20; + break; + } + case 18: + case 50: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL12_0; + PIXEL13_50; + } + PIXEL10_61; + PIXEL11_30; + PIXEL20_60; + PIXEL21_70; + PIXEL22_30; + PIXEL23_10; + PIXEL30_20; + PIXEL31_60; + PIXEL32_61; + PIXEL33_80; + break; + } + case 80: + case 81: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_61; + PIXEL03_80; + PIXEL10_60; + PIXEL11_70; + PIXEL12_30; + PIXEL13_10; + PIXEL20_61; + PIXEL21_30; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 72: + case 76: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_60; + PIXEL03_20; + PIXEL10_10; + PIXEL11_30; + PIXEL12_70; + PIXEL13_60; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_50; + PIXEL21_0; + PIXEL30_50; + PIXEL31_50; + } + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 10: + case 138: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + PIXEL11_0; + } + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_61; + PIXEL20_10; + PIXEL21_30; + PIXEL22_70; + PIXEL23_60; + PIXEL30_80; + PIXEL31_61; + PIXEL32_60; + PIXEL33_20; + break; + } + case 66: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_61; + PIXEL11_30; + PIXEL12_30; + PIXEL13_61; + PIXEL20_61; + PIXEL21_30; + PIXEL22_30; + PIXEL23_61; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 24: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_61; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_61; + PIXEL32_61; + PIXEL33_80; + break; + } + case 7: + case 39: + case 135: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_32; + PIXEL03_82; + PIXEL10_81; + PIXEL11_31; + PIXEL12_32; + PIXEL13_82; + PIXEL20_60; + PIXEL21_70; + PIXEL22_70; + PIXEL23_60; + PIXEL30_20; + PIXEL31_60; + PIXEL32_60; + PIXEL33_20; + break; + } + case 148: + case 149: + case 180: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_81; + PIXEL03_81; + PIXEL10_60; + PIXEL11_70; + PIXEL12_31; + PIXEL13_31; + PIXEL20_60; + PIXEL21_70; + PIXEL22_32; + PIXEL23_32; + PIXEL30_20; + PIXEL31_60; + PIXEL32_82; + PIXEL33_82; + break; + } + case 224: + case 228: + case 225: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_60; + PIXEL03_20; + PIXEL10_60; + PIXEL11_70; + PIXEL12_70; + PIXEL13_60; + PIXEL20_82; + PIXEL21_32; + PIXEL22_31; + PIXEL23_81; + PIXEL30_82; + PIXEL31_32; + PIXEL32_31; + PIXEL33_81; + break; + } + case 41: + case 169: + case 45: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_60; + PIXEL03_20; + PIXEL10_32; + PIXEL11_32; + PIXEL12_70; + PIXEL13_60; + PIXEL20_31; + PIXEL21_31; + PIXEL22_70; + PIXEL23_60; + PIXEL30_81; + PIXEL31_81; + PIXEL32_60; + PIXEL33_20; + break; + } + case 22: + case 54: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_61; + PIXEL11_30; + PIXEL12_0; + PIXEL20_60; + PIXEL21_70; + PIXEL22_30; + PIXEL23_10; + PIXEL30_20; + PIXEL31_60; + PIXEL32_61; + PIXEL33_80; + break; + } + case 208: + case 209: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_61; + PIXEL03_80; + PIXEL10_60; + PIXEL11_70; + PIXEL12_30; + PIXEL13_10; + PIXEL20_61; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 104: + case 108: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_60; + PIXEL03_20; + PIXEL10_10; + PIXEL11_30; + PIXEL12_70; + PIXEL13_60; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 11: + case 139: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_61; + PIXEL20_10; + PIXEL21_30; + PIXEL22_70; + PIXEL23_60; + PIXEL30_80; + PIXEL31_61; + PIXEL32_60; + PIXEL33_20; + break; + } + case 19: + case 51: + { + if (diff & Diff_2_6) + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL00_12; + PIXEL01_14; + PIXEL02_83; + PIXEL03_50; + PIXEL12_70; + PIXEL13_21; + } + PIXEL10_81; + PIXEL11_31; + PIXEL20_60; + PIXEL21_70; + PIXEL22_30; + PIXEL23_10; + PIXEL30_20; + PIXEL31_60; + PIXEL32_61; + PIXEL33_80; + break; + } + case 146: + case 178: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + PIXEL23_32; + PIXEL33_82; + } + else + { + PIXEL02_21; + PIXEL03_50; + PIXEL12_70; + PIXEL13_83; + PIXEL23_13; + PIXEL33_11; + } + PIXEL10_61; + PIXEL11_30; + PIXEL20_60; + PIXEL21_70; + PIXEL22_32; + PIXEL30_20; + PIXEL31_60; + PIXEL32_82; + break; + } + case 84: + case 85: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_81; + if (diff & Diff_6_8) + { + PIXEL03_81; + PIXEL13_31; + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL03_12; + PIXEL13_14; + PIXEL22_70; + PIXEL23_83; + PIXEL32_21; + PIXEL33_50; + } + PIXEL10_60; + PIXEL11_70; + PIXEL12_31; + PIXEL20_61; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + break; + } + case 112: + case 113: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_61; + PIXEL03_80; + PIXEL10_60; + PIXEL11_70; + PIXEL12_30; + PIXEL13_10; + PIXEL20_82; + PIXEL21_32; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_70; + PIXEL23_21; + PIXEL30_11; + PIXEL31_13; + PIXEL32_83; + PIXEL33_50; + } + break; + } + case 200: + case 204: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_60; + PIXEL03_20; + PIXEL10_10; + PIXEL11_30; + PIXEL12_70; + PIXEL13_60; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + } + else + { + PIXEL20_21; + PIXEL21_70; + PIXEL30_50; + PIXEL31_83; + PIXEL32_14; + PIXEL33_12; + } + PIXEL22_31; + PIXEL23_81; + break; + } + case 73: + case 77: + { + if (diff & Diff_8_4) + { + PIXEL00_82; + PIXEL10_32; + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL00_11; + PIXEL10_13; + PIXEL20_83; + PIXEL21_70; + PIXEL30_50; + PIXEL31_21; + } + PIXEL01_82; + PIXEL02_60; + PIXEL03_20; + PIXEL11_32; + PIXEL12_70; + PIXEL13_60; + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 42: + case 170: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + PIXEL20_31; + PIXEL30_81; + } + else + { + PIXEL00_50; + PIXEL01_21; + PIXEL10_83; + PIXEL11_70; + PIXEL20_14; + PIXEL30_12; + } + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_61; + PIXEL21_31; + PIXEL22_70; + PIXEL23_60; + PIXEL31_81; + PIXEL32_60; + PIXEL33_20; + break; + } + case 14: + case 142: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_50; + PIXEL01_83; + PIXEL02_13; + PIXEL03_11; + PIXEL10_21; + PIXEL11_70; + } + PIXEL12_32; + PIXEL13_82; + PIXEL20_10; + PIXEL21_30; + PIXEL22_70; + PIXEL23_60; + PIXEL30_80; + PIXEL31_61; + PIXEL32_60; + PIXEL33_20; + break; + } + case 67: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL10_81; + PIXEL11_31; + PIXEL12_30; + PIXEL13_61; + PIXEL20_61; + PIXEL21_30; + PIXEL22_30; + PIXEL23_61; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 70: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_61; + PIXEL11_30; + PIXEL12_32; + PIXEL13_82; + PIXEL20_61; + PIXEL21_30; + PIXEL22_30; + PIXEL23_61; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 28: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_61; + PIXEL32_61; + PIXEL33_80; + break; + } + case 152: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_61; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 194: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_61; + PIXEL11_30; + PIXEL12_30; + PIXEL13_61; + PIXEL20_61; + PIXEL21_30; + PIXEL22_31; + PIXEL23_81; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + break; + } + case 98: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_61; + PIXEL11_30; + PIXEL12_30; + PIXEL13_61; + PIXEL20_82; + PIXEL21_32; + PIXEL22_30; + PIXEL23_61; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + break; + } + case 56: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_61; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 25: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_61; + PIXEL32_61; + PIXEL33_80; + break; + } + case 26: + case 31: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL11_0; + PIXEL12_0; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_61; + PIXEL32_61; + PIXEL33_80; + break; + } + case 82: + case 214: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_61; + PIXEL11_30; + PIXEL12_0; + PIXEL20_61; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 88: + case 248: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_61; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + break; + } + case 74: + case 107: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_61; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 27: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_61; + PIXEL32_61; + PIXEL33_80; + break; + } + case 86: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_61; + PIXEL11_30; + PIXEL12_0; + PIXEL20_61; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 216: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_61; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 106: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_61; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 30: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_10; + PIXEL11_30; + PIXEL12_0; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_61; + PIXEL32_61; + PIXEL33_80; + break; + } + case 210: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_61; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + PIXEL20_61; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 120: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_61; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 75: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_61; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_61; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 29: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_81; + PIXEL03_81; + PIXEL10_32; + PIXEL11_32; + PIXEL12_31; + PIXEL13_31; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_61; + PIXEL32_61; + PIXEL33_80; + break; + } + case 198: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_61; + PIXEL11_30; + PIXEL12_32; + PIXEL13_82; + PIXEL20_61; + PIXEL21_30; + PIXEL22_31; + PIXEL23_81; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + break; + } + case 184: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_61; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + PIXEL20_31; + PIXEL21_31; + PIXEL22_32; + PIXEL23_32; + PIXEL30_81; + PIXEL31_81; + PIXEL32_82; + PIXEL33_82; + break; + } + case 99: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL10_81; + PIXEL11_31; + PIXEL12_30; + PIXEL13_61; + PIXEL20_82; + PIXEL21_32; + PIXEL22_30; + PIXEL23_61; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + break; + } + case 57: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 71: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_32; + PIXEL03_82; + PIXEL10_81; + PIXEL11_31; + PIXEL12_32; + PIXEL13_82; + PIXEL20_61; + PIXEL21_30; + PIXEL22_30; + PIXEL23_61; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 156: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 226: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_61; + PIXEL11_30; + PIXEL12_30; + PIXEL13_61; + PIXEL20_82; + PIXEL21_32; + PIXEL22_31; + PIXEL23_81; + PIXEL30_82; + PIXEL31_32; + PIXEL32_31; + PIXEL33_81; + break; + } + case 60: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 195: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL10_81; + PIXEL11_31; + PIXEL12_30; + PIXEL13_61; + PIXEL20_61; + PIXEL21_30; + PIXEL22_31; + PIXEL23_81; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + break; + } + case 102: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_61; + PIXEL11_30; + PIXEL12_32; + PIXEL13_82; + PIXEL20_82; + PIXEL21_32; + PIXEL22_30; + PIXEL23_61; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + break; + } + case 153: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 58: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 83: + { + PIXEL00_81; + PIXEL01_31; + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL10_81; + PIXEL11_31; + PIXEL20_61; + PIXEL21_30; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 92: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 202: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_61; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + PIXEL22_31; + PIXEL23_81; + PIXEL32_31; + PIXEL33_81; + break; + } + case 78: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + PIXEL02_32; + PIXEL03_82; + PIXEL12_32; + PIXEL13_82; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 154: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 114: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL10_61; + PIXEL11_30; + PIXEL20_82; + PIXEL21_32; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + PIXEL30_82; + PIXEL31_32; + break; + } + case 89: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 90: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 55: + case 23: + { + if (diff & Diff_2_6) + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_0; + PIXEL03_0; + PIXEL12_0; + PIXEL13_0; + } + else + { + PIXEL00_12; + PIXEL01_14; + PIXEL02_83; + PIXEL03_50; + PIXEL12_70; + PIXEL13_21; + } + PIXEL10_81; + PIXEL11_31; + PIXEL20_60; + PIXEL21_70; + PIXEL22_30; + PIXEL23_10; + PIXEL30_20; + PIXEL31_60; + PIXEL32_61; + PIXEL33_80; + break; + } + case 182: + case 150: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL12_0; + PIXEL13_0; + PIXEL23_32; + PIXEL33_82; + } + else + { + PIXEL02_21; + PIXEL03_50; + PIXEL12_70; + PIXEL13_83; + PIXEL23_13; + PIXEL33_11; + } + PIXEL10_61; + PIXEL11_30; + PIXEL20_60; + PIXEL21_70; + PIXEL22_32; + PIXEL30_20; + PIXEL31_60; + PIXEL32_82; + break; + } + case 213: + case 212: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_81; + if (diff & Diff_6_8) + { + PIXEL03_81; + PIXEL13_31; + PIXEL22_0; + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL03_12; + PIXEL13_14; + PIXEL22_70; + PIXEL23_83; + PIXEL32_21; + PIXEL33_50; + } + PIXEL10_60; + PIXEL11_70; + PIXEL12_31; + PIXEL20_61; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + break; + } + case 241: + case 240: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_61; + PIXEL03_80; + PIXEL10_60; + PIXEL11_70; + PIXEL12_30; + PIXEL13_10; + PIXEL20_82; + PIXEL21_32; + if (diff & Diff_6_8) + { + PIXEL22_0; + PIXEL23_0; + PIXEL30_82; + PIXEL31_32; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL22_70; + PIXEL23_21; + PIXEL30_11; + PIXEL31_13; + PIXEL32_83; + PIXEL33_50; + } + break; + } + case 236: + case 232: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_60; + PIXEL03_20; + PIXEL10_10; + PIXEL11_30; + PIXEL12_70; + PIXEL13_60; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL21_0; + PIXEL30_0; + PIXEL31_0; + PIXEL32_31; + PIXEL33_81; + } + else + { + PIXEL20_21; + PIXEL21_70; + PIXEL30_50; + PIXEL31_83; + PIXEL32_14; + PIXEL33_12; + } + PIXEL22_31; + PIXEL23_81; + break; + } + case 109: + case 105: + { + if (diff & Diff_8_4) + { + PIXEL00_82; + PIXEL10_32; + PIXEL20_0; + PIXEL21_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL00_11; + PIXEL10_13; + PIXEL20_83; + PIXEL21_70; + PIXEL30_50; + PIXEL31_21; + } + PIXEL01_82; + PIXEL02_60; + PIXEL03_20; + PIXEL11_32; + PIXEL12_70; + PIXEL13_60; + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 171: + case 43: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + PIXEL11_0; + PIXEL20_31; + PIXEL30_81; + } + else + { + PIXEL00_50; + PIXEL01_21; + PIXEL10_83; + PIXEL11_70; + PIXEL20_14; + PIXEL30_12; + } + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_61; + PIXEL21_31; + PIXEL22_70; + PIXEL23_60; + PIXEL31_81; + PIXEL32_60; + PIXEL33_20; + break; + } + case 143: + case 15: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL02_32; + PIXEL03_82; + PIXEL10_0; + PIXEL11_0; + } + else + { + PIXEL00_50; + PIXEL01_83; + PIXEL02_13; + PIXEL03_11; + PIXEL10_21; + PIXEL11_70; + } + PIXEL12_32; + PIXEL13_82; + PIXEL20_10; + PIXEL21_30; + PIXEL22_70; + PIXEL23_60; + PIXEL30_80; + PIXEL31_61; + PIXEL32_60; + PIXEL33_20; + break; + } + case 124: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 203: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_61; + PIXEL20_10; + PIXEL21_30; + PIXEL22_31; + PIXEL23_81; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + break; + } + case 62: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_10; + PIXEL11_30; + PIXEL12_0; + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 211: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL10_81; + PIXEL11_31; + PIXEL12_30; + PIXEL13_10; + PIXEL20_61; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 118: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_61; + PIXEL11_30; + PIXEL12_0; + PIXEL20_82; + PIXEL21_32; + PIXEL22_30; + PIXEL23_10; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + break; + } + case 217: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 110: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_10; + PIXEL11_30; + PIXEL12_32; + PIXEL13_82; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 155: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 188: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + PIXEL20_31; + PIXEL21_31; + PIXEL22_32; + PIXEL23_32; + PIXEL30_81; + PIXEL31_81; + PIXEL32_82; + PIXEL33_82; + break; + } + case 185: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + PIXEL20_31; + PIXEL21_31; + PIXEL22_32; + PIXEL23_32; + PIXEL30_81; + PIXEL31_81; + PIXEL32_82; + PIXEL33_82; + break; + } + case 61: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_81; + PIXEL03_81; + PIXEL10_32; + PIXEL11_32; + PIXEL12_31; + PIXEL13_31; + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 157: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_81; + PIXEL03_81; + PIXEL10_32; + PIXEL11_32; + PIXEL12_31; + PIXEL13_31; + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 103: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_32; + PIXEL03_82; + PIXEL10_81; + PIXEL11_31; + PIXEL12_32; + PIXEL13_82; + PIXEL20_82; + PIXEL21_32; + PIXEL22_30; + PIXEL23_61; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + break; + } + case 227: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL10_81; + PIXEL11_31; + PIXEL12_30; + PIXEL13_61; + PIXEL20_82; + PIXEL21_32; + PIXEL22_31; + PIXEL23_81; + PIXEL30_82; + PIXEL31_32; + PIXEL32_31; + PIXEL33_81; + break; + } + case 230: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_61; + PIXEL11_30; + PIXEL12_32; + PIXEL13_82; + PIXEL20_82; + PIXEL21_32; + PIXEL22_31; + PIXEL23_81; + PIXEL30_82; + PIXEL31_32; + PIXEL32_31; + PIXEL33_81; + break; + } + case 199: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_32; + PIXEL03_82; + PIXEL10_81; + PIXEL11_31; + PIXEL12_32; + PIXEL13_82; + PIXEL20_61; + PIXEL21_30; + PIXEL22_31; + PIXEL23_81; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + break; + } + case 220: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + break; + } + case 158: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL12_0; + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 234: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_61; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_31; + PIXEL23_81; + PIXEL32_31; + PIXEL33_81; + break; + } + case 242: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL10_61; + PIXEL11_30; + PIXEL20_82; + PIXEL21_32; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_82; + PIXEL31_32; + break; + } + case 59: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL11_0; + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 121: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 87: + { + PIXEL00_81; + PIXEL01_31; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_81; + PIXEL11_31; + PIXEL12_0; + PIXEL20_61; + PIXEL21_30; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 79: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_32; + PIXEL03_82; + PIXEL11_0; + PIXEL12_32; + PIXEL13_82; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 122: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 94: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL12_0; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 218: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + break; + } + case 91: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL11_0; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 229: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_60; + PIXEL03_20; + PIXEL10_60; + PIXEL11_70; + PIXEL12_70; + PIXEL13_60; + PIXEL20_82; + PIXEL21_32; + PIXEL22_31; + PIXEL23_81; + PIXEL30_82; + PIXEL31_32; + PIXEL32_31; + PIXEL33_81; + break; + } + case 167: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_32; + PIXEL03_82; + PIXEL10_81; + PIXEL11_31; + PIXEL12_32; + PIXEL13_82; + PIXEL20_60; + PIXEL21_70; + PIXEL22_70; + PIXEL23_60; + PIXEL30_20; + PIXEL31_60; + PIXEL32_60; + PIXEL33_20; + break; + } + case 173: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_60; + PIXEL03_20; + PIXEL10_32; + PIXEL11_32; + PIXEL12_70; + PIXEL13_60; + PIXEL20_31; + PIXEL21_31; + PIXEL22_70; + PIXEL23_60; + PIXEL30_81; + PIXEL31_81; + PIXEL32_60; + PIXEL33_20; + break; + } + case 181: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_81; + PIXEL03_81; + PIXEL10_60; + PIXEL11_70; + PIXEL12_31; + PIXEL13_31; + PIXEL20_60; + PIXEL21_70; + PIXEL22_32; + PIXEL23_32; + PIXEL30_20; + PIXEL31_60; + PIXEL32_82; + PIXEL33_82; + break; + } + case 186: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL20_31; + PIXEL21_31; + PIXEL22_32; + PIXEL23_32; + PIXEL30_81; + PIXEL31_81; + PIXEL32_82; + PIXEL33_82; + break; + } + case 115: + { + PIXEL00_81; + PIXEL01_31; + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL10_81; + PIXEL11_31; + PIXEL20_82; + PIXEL21_32; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + PIXEL30_82; + PIXEL31_32; + break; + } + case 93: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_81; + PIXEL03_81; + PIXEL10_32; + PIXEL11_32; + PIXEL12_31; + PIXEL13_31; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + break; + } + case 206: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + PIXEL02_32; + PIXEL03_82; + PIXEL12_32; + PIXEL13_82; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + PIXEL22_31; + PIXEL23_81; + PIXEL32_31; + PIXEL33_81; + break; + } + case 205: + case 201: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_60; + PIXEL03_20; + PIXEL10_32; + PIXEL11_32; + PIXEL12_70; + PIXEL13_60; + if (diff & Diff_8_4) + { + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + } + else + { + PIXEL20_12; + PIXEL21_0; + PIXEL30_20; + PIXEL31_11; + } + PIXEL22_31; + PIXEL23_81; + PIXEL32_31; + PIXEL33_81; + break; + } + case 174: + case 46: + { + if (diff & Diff_4_2) + { + PIXEL00_80; + PIXEL01_10; + PIXEL10_10; + PIXEL11_30; + } + else + { + PIXEL00_20; + PIXEL01_12; + PIXEL10_11; + PIXEL11_0; + } + PIXEL02_32; + PIXEL03_82; + PIXEL12_32; + PIXEL13_82; + PIXEL20_31; + PIXEL21_31; + PIXEL22_70; + PIXEL23_60; + PIXEL30_81; + PIXEL31_81; + PIXEL32_60; + PIXEL33_20; + break; + } + case 179: + case 147: + { + PIXEL00_81; + PIXEL01_31; + if (diff & Diff_2_6) + { + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + } + else + { + PIXEL02_11; + PIXEL03_20; + PIXEL12_0; + PIXEL13_12; + } + PIXEL10_81; + PIXEL11_31; + PIXEL20_60; + PIXEL21_70; + PIXEL22_32; + PIXEL23_32; + PIXEL30_20; + PIXEL31_60; + PIXEL32_82; + PIXEL33_82; + break; + } + case 117: + case 116: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_81; + PIXEL03_81; + PIXEL10_60; + PIXEL11_70; + PIXEL12_31; + PIXEL13_31; + PIXEL20_82; + PIXEL21_32; + if (diff & Diff_6_8) + { + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + } + else + { + PIXEL22_0; + PIXEL23_11; + PIXEL32_12; + PIXEL33_20; + } + PIXEL30_82; + PIXEL31_32; + break; + } + case 189: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_81; + PIXEL03_81; + PIXEL10_32; + PIXEL11_32; + PIXEL12_31; + PIXEL13_31; + PIXEL20_31; + PIXEL21_31; + PIXEL22_32; + PIXEL23_32; + PIXEL30_81; + PIXEL31_81; + PIXEL32_82; + PIXEL33_82; + break; + } + case 231: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_32; + PIXEL03_82; + PIXEL10_81; + PIXEL11_31; + PIXEL12_32; + PIXEL13_82; + PIXEL20_82; + PIXEL21_32; + PIXEL22_31; + PIXEL23_81; + PIXEL30_82; + PIXEL31_32; + PIXEL32_31; + PIXEL33_81; + break; + } + case 126: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_10; + PIXEL11_30; + PIXEL12_0; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 219: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_10; + PIXEL20_10; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 125: + { + if (diff & Diff_8_4) + { + PIXEL00_82; + PIXEL10_32; + PIXEL20_0; + PIXEL21_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL00_11; + PIXEL10_13; + PIXEL20_83; + PIXEL21_70; + PIXEL30_50; + PIXEL31_21; + } + PIXEL01_82; + PIXEL02_81; + PIXEL03_81; + PIXEL11_32; + PIXEL12_31; + PIXEL13_31; + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 221: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_81; + if (diff & Diff_6_8) + { + PIXEL03_81; + PIXEL13_31; + PIXEL22_0; + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL03_12; + PIXEL13_14; + PIXEL22_70; + PIXEL23_83; + PIXEL32_21; + PIXEL33_50; + } + PIXEL10_32; + PIXEL11_32; + PIXEL12_31; + PIXEL20_10; + PIXEL21_30; + PIXEL30_80; + PIXEL31_10; + break; + } + case 207: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL02_32; + PIXEL03_82; + PIXEL10_0; + PIXEL11_0; + } + else + { + PIXEL00_50; + PIXEL01_83; + PIXEL02_13; + PIXEL03_11; + PIXEL10_21; + PIXEL11_70; + } + PIXEL12_32; + PIXEL13_82; + PIXEL20_10; + PIXEL21_30; + PIXEL22_31; + PIXEL23_81; + PIXEL30_80; + PIXEL31_10; + PIXEL32_31; + PIXEL33_81; + break; + } + case 238: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_32; + PIXEL03_82; + PIXEL10_10; + PIXEL11_30; + PIXEL12_32; + PIXEL13_82; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL21_0; + PIXEL30_0; + PIXEL31_0; + PIXEL32_31; + PIXEL33_81; + } + else + { + PIXEL20_21; + PIXEL21_70; + PIXEL30_50; + PIXEL31_83; + PIXEL32_14; + PIXEL33_12; + } + PIXEL22_31; + PIXEL23_81; + break; + } + case 190: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL12_0; + PIXEL13_0; + PIXEL23_32; + PIXEL33_82; + } + else + { + PIXEL02_21; + PIXEL03_50; + PIXEL12_70; + PIXEL13_83; + PIXEL23_13; + PIXEL33_11; + } + PIXEL10_10; + PIXEL11_30; + PIXEL20_31; + PIXEL21_31; + PIXEL22_32; + PIXEL30_81; + PIXEL31_81; + PIXEL32_82; + break; + } + case 187: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + PIXEL11_0; + PIXEL20_31; + PIXEL30_81; + } + else + { + PIXEL00_50; + PIXEL01_21; + PIXEL10_83; + PIXEL11_70; + PIXEL20_14; + PIXEL30_12; + } + PIXEL02_10; + PIXEL03_80; + PIXEL12_30; + PIXEL13_10; + PIXEL21_31; + PIXEL22_32; + PIXEL23_32; + PIXEL31_81; + PIXEL32_82; + PIXEL33_82; + break; + } + case 243: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_10; + PIXEL03_80; + PIXEL10_81; + PIXEL11_31; + PIXEL12_30; + PIXEL13_10; + PIXEL20_82; + PIXEL21_32; + if (diff & Diff_6_8) + { + PIXEL22_0; + PIXEL23_0; + PIXEL30_82; + PIXEL31_32; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL22_70; + PIXEL23_21; + PIXEL30_11; + PIXEL31_13; + PIXEL32_83; + PIXEL33_50; + } + break; + } + case 119: + { + if (diff & Diff_2_6) + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_0; + PIXEL03_0; + PIXEL12_0; + PIXEL13_0; + } + else + { + PIXEL00_12; + PIXEL01_14; + PIXEL02_83; + PIXEL03_50; + PIXEL12_70; + PIXEL13_21; + } + PIXEL10_81; + PIXEL11_31; + PIXEL20_82; + PIXEL21_32; + PIXEL22_30; + PIXEL23_10; + PIXEL30_82; + PIXEL31_32; + PIXEL32_10; + PIXEL33_80; + break; + } + case 237: + case 233: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_60; + PIXEL03_20; + PIXEL10_32; + PIXEL11_32; + PIXEL12_70; + PIXEL13_60; + PIXEL20_0; + PIXEL21_0; + PIXEL22_31; + PIXEL23_81; + if (diff & Diff_8_4) + { + PIXEL30_0; + } + else + { + PIXEL30_20; + } + PIXEL31_0; + PIXEL32_31; + PIXEL33_81; + break; + } + case 175: + case 47: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + } + else + { + PIXEL00_20; + } + PIXEL01_0; + PIXEL02_32; + PIXEL03_82; + PIXEL10_0; + PIXEL11_0; + PIXEL12_32; + PIXEL13_82; + PIXEL20_31; + PIXEL21_31; + PIXEL22_70; + PIXEL23_60; + PIXEL30_81; + PIXEL31_81; + PIXEL32_60; + PIXEL33_20; + break; + } + case 183: + case 151: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_0; + if (diff & Diff_2_6) + { + PIXEL03_0; + } + else + { + PIXEL03_20; + } + PIXEL10_81; + PIXEL11_31; + PIXEL12_0; + PIXEL13_0; + PIXEL20_60; + PIXEL21_70; + PIXEL22_32; + PIXEL23_32; + PIXEL30_20; + PIXEL31_60; + PIXEL32_82; + PIXEL33_82; + break; + } + case 245: + case 244: + { + PIXEL00_20; + PIXEL01_60; + PIXEL02_81; + PIXEL03_81; + PIXEL10_60; + PIXEL11_70; + PIXEL12_31; + PIXEL13_31; + PIXEL20_82; + PIXEL21_32; + PIXEL22_0; + PIXEL23_0; + PIXEL30_82; + PIXEL31_32; + PIXEL32_0; + if (diff & Diff_6_8) + { + PIXEL33_0; + } + else + { + PIXEL33_20; + } + break; + } + case 250: + { + PIXEL00_80; + PIXEL01_10; + PIXEL02_10; + PIXEL03_80; + PIXEL10_10; + PIXEL11_30; + PIXEL12_30; + PIXEL13_10; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + break; + } + case 123: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_10; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 95: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL11_0; + PIXEL12_0; + PIXEL20_10; + PIXEL21_30; + PIXEL22_30; + PIXEL23_10; + PIXEL30_80; + PIXEL31_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 222: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_10; + PIXEL11_30; + PIXEL12_0; + PIXEL20_10; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 252: + { + PIXEL00_80; + PIXEL01_61; + PIXEL02_81; + PIXEL03_81; + PIXEL10_10; + PIXEL11_30; + PIXEL12_31; + PIXEL13_31; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_0; + PIXEL23_0; + PIXEL32_0; + if (diff & Diff_6_8) + { + PIXEL33_0; + } + else + { + PIXEL33_20; + } + break; + } + case 249: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_61; + PIXEL03_80; + PIXEL10_32; + PIXEL11_32; + PIXEL12_30; + PIXEL13_10; + PIXEL20_0; + PIXEL21_0; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + if (diff & Diff_8_4) + { + PIXEL30_0; + } + else + { + PIXEL30_20; + } + PIXEL31_0; + break; + } + case 235: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_61; + PIXEL20_0; + PIXEL21_0; + PIXEL22_31; + PIXEL23_81; + if (diff & Diff_8_4) + { + PIXEL30_0; + } + else + { + PIXEL30_20; + } + PIXEL31_0; + PIXEL32_31; + PIXEL33_81; + break; + } + case 111: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + } + else + { + PIXEL00_20; + } + PIXEL01_0; + PIXEL02_32; + PIXEL03_82; + PIXEL10_0; + PIXEL11_0; + PIXEL12_32; + PIXEL13_82; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_61; + PIXEL32_10; + PIXEL33_80; + break; + } + case 63: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + } + else + { + PIXEL00_20; + } + PIXEL01_0; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_0; + PIXEL11_0; + PIXEL12_0; + PIXEL20_31; + PIXEL21_31; + PIXEL22_30; + PIXEL23_10; + PIXEL30_81; + PIXEL31_81; + PIXEL32_61; + PIXEL33_80; + break; + } + case 159: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_0; + if (diff & Diff_2_6) + { + PIXEL03_0; + } + else + { + PIXEL03_20; + } + PIXEL11_0; + PIXEL12_0; + PIXEL13_0; + PIXEL20_10; + PIXEL21_30; + PIXEL22_32; + PIXEL23_32; + PIXEL30_80; + PIXEL31_61; + PIXEL32_82; + PIXEL33_82; + break; + } + case 215: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_0; + if (diff & Diff_2_6) + { + PIXEL03_0; + } + else + { + PIXEL03_20; + } + PIXEL10_81; + PIXEL11_31; + PIXEL12_0; + PIXEL13_0; + PIXEL20_61; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 246: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_61; + PIXEL11_30; + PIXEL12_0; + PIXEL20_82; + PIXEL21_32; + PIXEL22_0; + PIXEL23_0; + PIXEL30_82; + PIXEL31_32; + PIXEL32_0; + if (diff & Diff_6_8) + { + PIXEL33_0; + } + else + { + PIXEL33_20; + } + break; + } + case 254: + { + PIXEL00_80; + PIXEL01_10; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_10; + PIXEL11_30; + PIXEL12_0; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_0; + PIXEL23_0; + PIXEL32_0; + if (diff & Diff_6_8) + { + PIXEL33_0; + } + else + { + PIXEL33_20; + } + break; + } + case 253: + { + PIXEL00_82; + PIXEL01_82; + PIXEL02_81; + PIXEL03_81; + PIXEL10_32; + PIXEL11_32; + PIXEL12_31; + PIXEL13_31; + PIXEL20_0; + PIXEL21_0; + PIXEL22_0; + PIXEL23_0; + if (diff & Diff_8_4) + { + PIXEL30_0; + } + else + { + PIXEL30_20; + } + PIXEL31_0; + PIXEL32_0; + if (diff & Diff_6_8) + { + PIXEL33_0; + } + else + { + PIXEL33_20; + } + break; + } + case 251: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_10; + PIXEL03_80; + PIXEL11_0; + PIXEL12_30; + PIXEL13_10; + PIXEL20_0; + PIXEL21_0; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + if (diff & Diff_8_4) + { + PIXEL30_0; + } + else + { + PIXEL30_20; + } + PIXEL31_0; + break; + } + case 239: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + } + else + { + PIXEL00_20; + } + PIXEL01_0; + PIXEL02_32; + PIXEL03_82; + PIXEL10_0; + PIXEL11_0; + PIXEL12_32; + PIXEL13_82; + PIXEL20_0; + PIXEL21_0; + PIXEL22_31; + PIXEL23_81; + if (diff & Diff_8_4) + { + PIXEL30_0; + } + else + { + PIXEL30_20; + } + PIXEL31_0; + PIXEL32_31; + PIXEL33_81; + break; + } + case 127: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + } + else + { + PIXEL00_20; + } + PIXEL01_0; + if (diff & Diff_2_6) + { + PIXEL02_0; + PIXEL03_0; + PIXEL13_0; + } + else + { + PIXEL02_50; + PIXEL03_50; + PIXEL13_50; + } + PIXEL10_0; + PIXEL11_0; + PIXEL12_0; + if (diff & Diff_8_4) + { + PIXEL20_0; + PIXEL30_0; + PIXEL31_0; + } + else + { + PIXEL20_50; + PIXEL30_50; + PIXEL31_50; + } + PIXEL21_0; + PIXEL22_30; + PIXEL23_10; + PIXEL32_10; + PIXEL33_80; + break; + } + case 191: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + } + else + { + PIXEL00_20; + } + PIXEL01_0; + PIXEL02_0; + if (diff & Diff_2_6) + { + PIXEL03_0; + } + else + { + PIXEL03_20; + } + PIXEL10_0; + PIXEL11_0; + PIXEL12_0; + PIXEL13_0; + PIXEL20_31; + PIXEL21_31; + PIXEL22_32; + PIXEL23_32; + PIXEL30_81; + PIXEL31_81; + PIXEL32_82; + PIXEL33_82; + break; + } + case 223: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + PIXEL01_0; + PIXEL10_0; + } + else + { + PIXEL00_50; + PIXEL01_50; + PIXEL10_50; + } + PIXEL02_0; + if (diff & Diff_2_6) + { + PIXEL03_0; + } + else + { + PIXEL03_20; + } + PIXEL11_0; + PIXEL12_0; + PIXEL13_0; + PIXEL20_10; + PIXEL21_30; + PIXEL22_0; + if (diff & Diff_6_8) + { + PIXEL23_0; + PIXEL32_0; + PIXEL33_0; + } + else + { + PIXEL23_50; + PIXEL32_50; + PIXEL33_50; + } + PIXEL30_80; + PIXEL31_10; + break; + } + case 247: + { + PIXEL00_81; + PIXEL01_31; + PIXEL02_0; + if (diff & Diff_2_6) + { + PIXEL03_0; + } + else + { + PIXEL03_20; + } + PIXEL10_81; + PIXEL11_31; + PIXEL12_0; + PIXEL13_0; + PIXEL20_82; + PIXEL21_32; + PIXEL22_0; + PIXEL23_0; + PIXEL30_82; + PIXEL31_32; + PIXEL32_0; + if (diff & Diff_6_8) + { + PIXEL33_0; + } + else + { + PIXEL33_20; + } + break; + } + case 255: + { + if (diff & Diff_4_2) + { + PIXEL00_0; + } + else + { + PIXEL00_20; + } + PIXEL01_0; + PIXEL02_0; + if (diff & Diff_2_6) + { + PIXEL03_0; + } + else + { + PIXEL03_20; + } + PIXEL10_0; + PIXEL11_0; + PIXEL12_0; + PIXEL13_0; + PIXEL20_0; + PIXEL21_0; + PIXEL22_0; + PIXEL23_0; + if (diff & Diff_8_4) + { + PIXEL30_0; + } + else + { + PIXEL30_20; + } + PIXEL31_0; + PIXEL32_0; + if (diff & Diff_6_8) + { + PIXEL33_0; + } + else + { + PIXEL33_20; + } + break; + } + } + + for (int pixely = 0; pixely < 4; ++pixely) + { + for (int pixelx = 0; pixelx < 4; ++pixelx) + { + weight w(weights[pixely][pixelx]); + + uint32_t rgba = + (w.w1 << 28) | + (w.w2 << 24) | + (w.w3 << 20) | + (w.w4 << 16) | + (w.w6 << 12) | + (w.w7 << 8) | + (w.w8 << 4) | + w.w9; + + } + } + } + } + } + + return s_lookup; +} + diff --git a/hq4x.hh b/hq4x.hh new file mode 100644 index 0000000..e69de29 diff --git a/retired/GameboyGraphics.cc b/retired/GameboyGraphics.cc new file mode 100644 index 0000000..54e5d71 --- /dev/null +++ b/retired/GameboyGraphics.cc @@ -0,0 +1,1056 @@ + +#include "mm80.hh" +#include "GameboyGraphics.hh" +#include "Log.hh" +#include "MemoryMap.hh" + +#ifdef MM80_SHADER +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include +#endif + +#include + +#include +#include + +#include + + +using namespace mm80; + +namespace +{ + class VRAM : public MemoryMap::Memory + { + public: + VRAM(uint8_t* mem, + const std::function& changed + ) : + m_mem(mem), + m_changed(changed) + {} + + virtual uint8_t read8(uint16_t address) { return m_mem[address]; } + virtual void write8(uint16_t address, uint8_t value) + { + m_mem[address] = value; + m_changed(); + } + + virtual void copy(uint8_t* dest, uint16_t address, int bytes) + { + memcpy(dest, m_mem + address, bytes); + } + + private: + uint8_t* m_mem; + std::function m_changed; + }; + + + // Operates on 8bit grayscale only. + // Uses the Scale2x algorithm documented at http://scale2x.sourceforge.net + void scale2x(uint8_t* dest, const uint8_t* src, int srcWidth, int srcHeight) + { + // First row + for (int x = 0; x < srcWidth; ++x) + { + uint8_t E(src[x]); + + dest[x*2] = E; + dest[x*2+1] = E; + dest[srcWidth*2 + x*2] = E; + dest[srcWidth*2 + x*2+1] = E; + } + + for (int y = 1; y < srcHeight - 1; ++y) + { + // First col. + { + uint8_t E(src[y*srcWidth]); + dest[y*2*srcWidth*2] = E; + dest[y*2*srcWidth*2 + 1] = E; + dest[(y*2+1)*srcWidth*2] = E; + dest[(y*2+1)*srcWidth*2 + 1] = E; + } + + for (int x = 1; x < srcWidth - 1; ++x) + { + uint8_t B(src[(y-1) * srcWidth + x]); + uint8_t D(src[y*srcWidth + (x-1)]); + uint8_t E(src[y*srcWidth + x]); + uint8_t F(src[y * srcWidth + (x+1)]); + uint8_t H(src[(y+1) * srcWidth + x]); + + if (B != H && D != F) + { + dest[y*2*srcWidth*2 + x*2] = D == B ? D : E; + dest[y*2*srcWidth*2 + x*2+1] = B == F ? F : E; + dest[(y*2+1)*srcWidth*2 + x*2] = D == H ? D : E; + dest[(y*2+1)*srcWidth*2 + (x*2+1)] = H == F ? F : E; + } + else + { + dest[y*2*srcWidth*2 + x*2] = E; + dest[y*2*srcWidth*2 + x*2+1] = E; + dest[(y*2+1)*srcWidth*2 + x*2] = E; + dest[(y*2+1)*srcWidth*2 + x*2+1] = E; + } + } + + // Last col. + { + int x = srcWidth - 1; + uint8_t E(src[y*srcWidth + x]); + dest[y*2*srcWidth*2 + x*2] = E; + dest[y*2*srcWidth*2 + x*2+1] = E; + dest[(y*2+1)*srcWidth*2 + x*2] = E; + dest[(y*2+1)*srcWidth*2 + x*2+1] = E; + } + } + + // Last row + for (int x = 0; x < srcWidth; ++x) + { + int y = srcHeight - 1; + uint8_t E(src[y*srcWidth + x]); + + dest[y*2*srcWidth*2 + x*2] = E; + dest[y*2*srcWidth*2 + x*2+1] = E; + dest[(y*2+1)*srcWidth*2 + x*2] = E; + dest[(y*2+1)*srcWidth*2 + x*2+1] = E; + } + } + + // Provides a weighted mix between a 2x2 set of grayscale pixels. + // + // a1 a2 + // + // result + // + // b1 b2 + // + // xWeight = 16* (1 - (result - a1.x)) + // yWeight = 16* (1 - (result - a1.y)) +/* + inline int bilinearInterpolate( + int a1, int a2, + int b1, int b2, + int xw, int yw + ) + { + const int s(16); + + return ( + xw*(yw*(a1-b1) + s*b1) + + (s-xw)*(yw*(a2-b2)+s*b2) + ) / (s*s); + }*/ +inline uint8_t bilinearInterpolate( + uint8_t a1, uint8_t a2, + uint8_t b1, uint8_t b2, + uint16_t xw, // 0 -> FP + uint16_t yw // 0 -> FP + ) +{ +/* + // 16bit clean! +#define FP 16 + + return ( + xw*uint16_t(yw*(int16_t(a1)-b1) + uint16_t(b1)*uint16_t(FP)) + + (FP-xw)*uint16_t(yw*(int16_t(a2)-b2)+uint16_t(b2)*uint16_t(FP)) + ) / (FP*FP); +*/ +#define s 16 + return (xw*uint16_t(yw*(int16_t(a1)-b1 -a2 +b2) + s*(int16_t(b1) -b2)) + + s*uint16_t(yw*((int16_t(a2)-b2)+s*int16_t(b2)))) / (s * s); +} +} + +class GameboyGraphics::GraphicsRegisters : public MemoryMap::Memory +{ +public: + uint8_t LCDC; + uint8_t STAT; + uint8_t SCY; + uint8_t SCX; + uint8_t LY; + uint8_t LYC; + // uint8_t DMA; No need to store this - write-only. + uint8_t BGP; + uint8_t OBP0; + uint8_t OBP1; + uint8_t WY; + uint8_t WX; + + GraphicsRegisters( + Core& core, + uint8_t* oam, + const std::function& backgroundChanged + ) : + LCDC(0), + STAT(0), + SCY(0), + SCX(0), + LY(0), + LYC(0), + BGP(0), + OBP0(0), + OBP1(0), + WY(0), + WX(0), + m_core(core), + m_mapping(core.getMemoryMap()), + m_oam(oam), + m_backgroundChanged(backgroundChanged) + { + } + + virtual uint8_t read8(uint16_t address) + { + assert(address < 12); + + switch (address) + { + case 0: // LCDC + { + return LCDC; + } break; + case 1: // STAT + { + return STAT; + } break; + case 2: // SCY + { + return SCY; + } break; + case 3: // SCX + { + return SCX; + } break; + case 4: // LY + { + return LY; + } break; + case 5: // LYC + { + return LYC; + } break; + case 6: // DMA + { + return 0; + } break; + case 7: // BGP + { + return BGP; + } break; + case 8: // OBP0 + { + return OBP0; + } break; + case 9: // OBP1 + { + return OBP1; + } break; + case 10: // WY + { + return WY; + } break; + case 11: // WX + { + return WX; + } break; + } + return 0; // make g++ happy. + } + + virtual void write8(uint16_t address, uint8_t value) + { + assert(address < 12); + + switch (address) + { + case 0: // LCDC + { + LCDC = value; + m_backgroundChanged(); + } break; + case 1: // STAT + { + // bits 0-2 are read only. + uint8_t tmp(STAT & 0x7); + STAT = value & 0xF8; + STAT |= tmp; + } break; + case 2: // SCY + { + SCY = value; + } break; + case 3: // SCX + { + SCX = value; + } break; + case 4: // LY + { + // Readonly. + } break; + case 5: // LYC + { + LYC = value; + } break; + case 6: // DMA + { + // Start a DMA transfer to the OAM memory area. This should + // take 160 microseconds, but there's no real need to simulate + // this. CPU may only access zero-page mem during the + // transfer, and will spin the required number of cycles. + uint16_t dmaStart(static_cast(value) << 8); + m_mapping.copy(m_oam, dmaStart, 0x9F); + } break; + case 7: // BGP + { + BGP = value; + m_backgroundChanged(); + } break; + case 8: // OBP0 + { + OBP0 = value; + } break; + case 9: // OBP1 + { + OBP1 = value; + } break; + case 10: // WY + { + WY = value; + } break; + case 11: // WX + { + WX = value; + } break; + } + } + + private: + Core& m_core; + MemoryMap& m_mapping; // For DMA transfers. + uint8_t* m_oam; + std::function m_backgroundChanged; +}; + +#ifdef MM80_SHADER +GLint program; +#endif + + +GameboyGraphics::GameboyGraphics( + Core& core, + SDL_Surface* surface, + bool openGL, + PixelScaler scaler, + ResampleMethod resampler + ) : + m_core(core), + m_useOpenGL(openGL), + m_scaler(scaler), + m_resampler(resampler), + m_vram(new uint8_t[0x2000]), + m_oam(new uint8_t[0x100]), // Should be 0x9F, but many access to 100 + m_reg( + new GraphicsRegisters( + core, + m_oam, + std::bind(&GameboyGraphics::backgroundChanged, this) + ) + ), + m_backgroundRedraw(true), + m_surface(surface), + m_stat_frames(0), + m_stat_redraw(0) +{ + MemoryMap& mapping(core.getMemoryMap()); + mapping.map( + 0x8000, + 0x2000, + std::shared_ptr( + new VRAM( + m_vram, + std::bind(&GameboyGraphics::backgroundChanged, this) + ) + ) + ); + mapping.map( + 0xFE00, + 0x100, + std::shared_ptr( + new VRAM( + m_oam, + std::bind(&GameboyGraphics::oamChanged, this) + ) + ) + ); + mapping.map(0xFF40, 12, m_reg); + + using namespace std::tr1::placeholders; + m_mode0 = core.registerPeriodic( + 456, 252, std::tr1::bind(&mm80::GameboyGraphics::periodicCallback, this, _1) + ); + m_mode2 = core.registerPeriodic( + 456, 0, std::tr1::bind(&mm80::GameboyGraphics::periodicCallback, this, _1) + ); + m_mode3 = core.registerPeriodic( + 456, 80, std::tr1::bind(&mm80::GameboyGraphics::periodicCallback, this, _1) + ); + + gettimeofday(&m_stat_fpsTimer, NULL); + + +#ifdef MM80_SHADER + if (m_useOpenGL) + { + GLint vertexShader(glCreateShader(GL_VERTEX_SHADER)); + GLint fragShader(glCreateShader(GL_FRAGMENT_SHADER)); + + char vertSource[8192]; + int fd = open("hq4x.slv", O_RDONLY); + read(fd, vertSource, 8192); + close(fd); + + char fragSource[8192]; + fd = open("hq4x.slf", O_RDONLY); + read(fd, fragSource, 8192); + close(fd); + + const GLchar* foo(&vertSource[0]); + const GLchar* bar(&fragSource[0]); + glShaderSource(vertexShader, 1, &foo, NULL); + glShaderSource(fragShader, 1, &bar, NULL); + + glCompileShader(vertexShader); + +int len(0); +char log[2048]; +glGetShaderInfoLog(vertexShader, 2048, &len, &log[0]); +std::cerr << std::string(log, len) << std::endl; + glCompileShader(fragShader); +glGetShaderInfoLog(vertexShader, 2048, &len, &log[0]); +std::cerr << std::string(log, len) << std::endl; + + program = glCreateProgram(); +glGetProgramInfoLog(vertexShader, 2048, &len, &log[0]); +std::cerr << std::string(log, len) << std::endl; + glAttachShader(program, vertexShader); + glAttachShader(program, fragShader); + glLinkProgram(program); + glUseProgram(program); + } +#endif +} + +GameboyGraphics::~GameboyGraphics() +{ + delete[] m_vram; + delete[] m_oam; +} + +void +GameboyGraphics::periodicCallback(Core::CallbackId id) +{ + // Mode 0: H-Blank + // Mode 1: V-Blank + // Mode 2: Reading from OAM + // Mode 3: Reading from OAM and VRAM + uint8_t mode; + + if (id == m_mode0) + { + renderScanLine(); + + mode = (m_reg->LY > 143) ? 1 : 0; + } + else if (id == m_mode2) + { + startScanLine(); + mode = (m_reg->LY > 143) ? 1 : 2; + } + else // mode3 + { + mode = (m_reg->LY > 143) ? 1 : 3; + } + + m_reg->STAT = (m_reg->STAT & 0xF8) | mode; +} + +void +GameboyGraphics::startScanLine() +{ + ++m_reg->LY; + if (m_reg->LY > 153) m_reg->LY = 0; + + m_lineScrollX[m_reg->LY] = m_reg->SCX; + m_lineScrollY[m_reg->LY] = m_reg->SCY; + + bool equal(m_reg->LY == m_reg->LYC); + if (equal) + { + m_reg->STAT |= 0x4; + } + else + { + m_reg->STAT &= 0xFB; + } + + if ((m_reg->LY == 144)) + { + // Draw the entire screen when entering vblank. This will be done just + // under 60 times per second. + renderScreen(); + + //if (m_reg->STAT & 0x10) Seems to need to trigger regardless ? + // Maybe we need to trigger 0x40 as well, depending on STAT ? + { + m_core.raiseInterrupt(0x40); // Start of vblank + } + } + else if ( + (equal && (m_reg->STAT & 0x40)) || // Coincidence Interrupt + (m_reg->STAT & 0x20) // OAM interrupt + ) + { + m_core.raiseInterrupt(0x48); + } +} + +void +GameboyGraphics::renderScanLine() +{ + // Entering H-Blank + if (m_reg->STAT & 0x08 && (m_reg->LY <= 143)) + { + m_core.raiseInterrupt(0x48); + } + + // Don't bother drawing individual scanlines - just draw the entire screen + // when entering VBLANK (which is actually done in the startScanLine method) +} + +// Render the given tile to the screen at the given coordinates. +// The x and y may be outside the bounds of the screen, and may be negative. +// Only the visible part of the tile will be rendered. +void GameboyGraphics::renderTile( + uint8_t tile, + int x, + int y, + const FrameBuffer& frameBuffer + ) +{ + uint16_t tileAddr; + if (m_reg->LCDC & 0x10) + { + tileAddr = 0x8000 + static_cast(tile) * 16; + } + else + { + tileAddr = 0x9000 + + (static_cast(tile) * static_cast(16)); + } + + + renderTile(tileAddr, x, y, frameBuffer, RENDER_BLIT, m_reg->BGP); +} + +void GameboyGraphics::renderTile( + uint16_t tileAddr, + int x, + int y, + const FrameBuffer& frameBuffer, + RenderMode mode, + uint8_t palette, + uint8_t sprite, // 0x80 -> 0xA8, 0 for background/window + bool horizFlip, + bool vertFlip, + int tileHeight // 8 or 16 + ) +{ + // Render an 8x8 or 8x16 tile. + + tileAddr -= 0x8000; // Use vram directly. + + if (vertFlip) tileAddr += (tileHeight - 1) * 2; + int yStep = vertFlip ? -2 : 2; // Each row takes 2 bytes. + if (y < 0) tileAddr += yStep * (-y); + + for (int posY = (y < 0 ? -y : 0); + (posY < tileHeight) && (y + posY < frameBuffer.height); + ++posY, tileAddr += yStep + ) + { + uint8_t rowLSB(m_vram[tileAddr]); + uint8_t rowMSB(m_vram[tileAddr + 1]); + + size_t pixelRowAddr((y + posY) * frameBuffer.width + x); + + int xStep = horizFlip ? 1 : -1; + int xBit = horizFlip ? 0 : 7; + if (x < 0) xBit += xStep * (-x); + + for (int posX = (x < 0 ? -x : 0); + (posX < 8) && (x + posX < frameBuffer.width); + ++posX, xBit += xStep + ) + { + uint8_t col = + (rowMSB >> xBit) & 0x01; + col <<= 1; + col |= + (rowLSB >> xBit) & 0x01; + + Pixel& pixel = frameBuffer.frame[pixelRowAddr + posX]; + + bool display; + if (!sprite) + { + // Always display background and window data. + // window data overwrites background data + display = true; + } + else if (pixel.tileX != std::numeric_limits::max()) + { + if (col) + { + if (x < pixel.tileX) + { + display = true; + } + else + { + // Existing pixel has priority. Note that transparent + // areas of sprites are never output (ie. it remains + // background), so there is no need to check of the + // oldSprite was actually transparent. + // Also note that we draw sprites in order, so this + // sprite number can never be less than the already- + // drawn sprite (and thus will not have priority) + display = false; + } + } + else + { + // Ignore transparent areas of the sprite. + display = false; + } + } + else + { + // Should this sprite pixel overwrite the background ? + // Sprite colour 0 is transparent (shows background) + // Background colour 0 is always "behind" the sprite. + display = + col && + ((mode == RENDER_BLIT) || (pixel.colourIndex == 0)); + } + + if (display) + { + pixel.tileX = sprite ? x : std::numeric_limits::max(); + pixel.palette = palette; + pixel.colourIndex = col; + } + } + } +} + +void +GameboyGraphics::renderScreen() +{ + FrameBuffer screenBuffer = { 160, 144, &m_screen[0][0]}; + + if (m_reg->LCDC & 0x1) + { + // Draw background. Background tile map is a 256x256 virtual screen, + // that is scrolled via SCX/SCY. + + if (m_backgroundRedraw) + { + m_backgroundRedraw = false; + ++m_stat_redraw; + + // Select one of two maps at 0x9800/0x9C00 + uint16_t tileMapAddr(m_reg->LCDC & 0x08 ? 0x1C00 : 0x1800); + + // Render entire tile map, then copy to the screen. + memset(m_background, 0, sizeof(m_background)); + FrameBuffer buffer = { 256, 256, &m_background[0][0] }; + + for (int y = 0; y < 32; ++y) + { + uint16_t yAddr(tileMapAddr + (y * 32)); + for (int x = 0; x < 32; ++x) + { + renderTile( + m_vram[yAddr + x], + x * 8, + y * 8, + buffer + ); + } + } + } + + for (int y = 0; y < 144; ++y) + { + int scrollY = y + m_lineScrollY[y]; + if (scrollY > 255) scrollY -= 256; + + for (int x = 0; x < 160; ++x) + { + int scrollX = x + m_lineScrollX[y]; + if (scrollX > 255) scrollX -= 256; + + m_screen[y][x] = m_background[scrollY][scrollX]; + } + } + } + else + { + // clear screen. + memset(m_screen, 0, sizeof(Pixel) * 144 * 160); + } + + + if (m_reg->LCDC & 0x20) + { + // Draw window over top of existing background. + + // Draw background. Window tile map is a screen, + // that is positioned via WX/WY. + + // Select one of two maps at 0x9800/0x9C00 + uint16_t tileMapAddr(m_reg->LCDC & 0x40 ? 0x1C00 : 0x1800); + + for (int y = 0; y < 18; ++y) + { + uint16_t yAddr(tileMapAddr + (y * 32)); + + for (int x = 0; x < 20; ++x) + { + renderTile( + m_vram[yAddr + x], + x * 8 + m_reg->WX - 7, + y * 8 + m_reg->WY, + screenBuffer // Render directly to the screen. + ); + } + } + } + + std::vector sprite; + sprite.resize(160); + if (m_reg->LCDC & 0x2) + { + // Draw sprites + + for (int spriteNum = 0; spriteNum < 40; ++spriteNum) + { + Sprite sprite(getSprite(spriteNum)); + + renderTile( + 0x8000 + static_cast(sprite.tile) * 16, + sprite.x, + sprite.y, + screenBuffer, + (sprite.flags & 0x80) ? RENDER_SPRITE : RENDER_BLIT, + (sprite.flags & 0x10) ? m_reg->OBP1 : m_reg->OBP0, + static_cast(spriteNum) | 0x80, + (sprite.flags & 0x20) ? true : false, // horizontal flip + (sprite.flags & 0x40) ? true : false, // vertical flip + (m_reg->LCDC & 0x04) ? 16 : 8 // 8x8 or 8x16 + ); + } + } + updateOutputDevice(); + + + m_stat_frames++; + if (m_stat_frames == 300) + { + timeval startTime(m_stat_fpsTimer); + gettimeofday(&m_stat_fpsTimer, 0); + + const double usec(1000000.0); + double fps = static_cast(m_stat_frames) / + ( + (m_stat_fpsTimer.tv_sec + m_stat_fpsTimer.tv_usec / usec) - + (startTime.tv_sec + startTime.tv_usec / usec) + ); + + Log::Instance()(Log::DBG_STAT) << + "FPS = " << fps << " (error=" << (100 - (fps * 100 / 59.73)) << "%) " + "redraw=" << m_stat_redraw << std::endl; + m_stat_frames = 0; + m_stat_redraw = 0; + } +} + +GameboyGraphics::Sprite +GameboyGraphics::getSprite(int spriteNum) const +{ + Sprite result; + + result.y = static_cast(m_oam[spriteNum * 4]) - 16; + result.x = static_cast(m_oam[spriteNum * 4 + 1]) - 8; + result.tile = m_oam[spriteNum * 4 + 2]; + result.flags = m_oam[spriteNum * 4 + 3]; + + return result; +} + +void +GameboyGraphics::blitGreyscale(uint8_t* dest) +{ + for (int y = 0; y < 144; ++y) + { + uint8_t* row(dest + y*160); + for (int x = 0; x < 160; ++x) + { + int index(m_screen[y][x].colourIndex); + int colour((m_screen[y][x].palette >> (index * 2)) & 0x3); + row[x] = 255 - ( colour * 85); + } + } +} + +extern void hq4x_32(const uint8_t* pIn, uint8_t* pOut, int Xres, int Yres, int BpL ); + +void +GameboyGraphics:: updateOutputDevice() +{ + if (SDL_MUSTLOCK(m_surface)) + { + if (SDL_LockSurface(m_surface) < 0) + { + return; + } + } + + // Use static buffers to reduce stack usage + static uint8_t scaled[144*4*160*4]; // Max size + blitGreyscale(&scaled[0]); + + int scaledX = 160; + int scaledY = 144;; + + if (m_scaler == Scaler_Scale2x && (m_surface->w > 160*3)) + { + static uint8_t scale2[144*2][160*2]; + + scale2x(&scale2[0][0], &scaled[0], 160, 144); + scale2x(&scaled[0], &scale2[0][0], 320, 288); + + scaledX *= 4; + scaledY *= 4; + } + else if (m_scaler == Scaler_Scale2x && (m_surface->w > 160)) + { + static uint8_t scale2[144*2][160*2]; + + scale2x(&scale2[0][0], &scaled[0], 160, 144); + memcpy(scaled, scale2, sizeof(scale2)); + + scaledX *= 2; + scaledY *= 2;; + } + else if (m_scaler == Scaler_hq4x && (m_surface->w > 160)) + { + static uint8_t hqxScale[144*4*160*4]; + + hq4x_32(&scaled[0], &hqxScale[0], 160, 144, 4*160); + memcpy(scaled, hqxScale, sizeof(hqxScale)); + + scaledX *= 4; + scaledY *= 4; + } + + if (m_useOpenGL) + { + // Allocate texture + GLuint texture; + glGenTextures(1, &texture); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texture); + + // Set the texture's stretching properties + uint32_t resample( + (m_resampler == Resample_Bilinear) ? GL_LINEAR : GL_NEAREST + ); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, resample); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, resample); + + // Create the texture image + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RGBA, + scaledX, + scaledY, + 0, + GL_LUMINANCE, + GL_UNSIGNED_BYTE, + &scaled + ); + +#ifdef MM80_SHADER + GLint param(glGetUniformLocation(program, "OGL2Param")); + GLint size(glGetUniformLocation(program, "OGL2Size")); + GLint tex(glGetUniformLocation(program, "OGL2Texture")); + + // x = texture x-size. y = texture y-size. + glUniform4f(size, 160,144,0,0); + + // Shader effect level. + // texel sizes + glUniform4f(param, 1.0/160,1.0/144,1,1); + + glUniform1i(tex, 0); // Bind Texture 0 +#endif + + // Output texture. + glBegin(GL_QUADS); + glTexCoord2i( 0, 0 ); glVertex2i( 0, 0 ); + glTexCoord2i( 1, 0 ); glVertex2i( 160, 0 ); + glTexCoord2i( 1, 1 ); glVertex2i( 160, 144 ); + glTexCoord2i( 0, 1 ); glVertex2i( 0, 144); + glEnd(); + + glLoadIdentity(); + SDL_GL_SwapBuffers(); + glDeleteTextures( 1, &texture ); + } + else + { + if ((scaledY == m_surface->h) && (scaledX == m_surface->w)) + { + for (int y = 0; y < scaledY; ++y) + { + Uint32 *bufp( + reinterpret_cast(m_surface->pixels) + + y * m_surface->pitch / 4 + ); + + uint8_t* srcLine1 = &scaled[y*scaledX]; + + for (int x = 0; x < scaledX; ++x) + { + int luminance(srcLine1[x]); + bufp[x] = + SDL_MapRGB( + m_surface->format, luminance, luminance, luminance + ); + } + } + } + else + { + double heightRatio = static_cast(m_surface->h) / scaledY; + double widthRatio = static_cast(m_surface->w) / scaledX; + + if (m_resampler == Resample_Bilinear) + { + // Bilinear scale to final dimensions + for (int y = 0; y < m_surface->h; ++y) + { + Uint32 *bufp( + reinterpret_cast(m_surface->pixels) + + y * m_surface->pitch / 4 + ); + + int y1 = y/heightRatio; + int y2 = std::min(y1 + 1, scaledY); + int y1Weight = 16*(1 - (y/heightRatio - y1)); + + uint8_t* srcLine1 = &scaled[y1*scaledX]; + uint8_t* srcLine2 = &scaled[y2*scaledX]; + + int x = 0; + for (; x < m_surface->w - 1; ++x) + { + //int x1 = x/widthRatio; + int x1 = x*scaledX / m_surface->w; + int x2 = x1 + 1; +// int x1Weight = 16*(1 - (x/widthRatio - x1)); + int x1Weight = 16*(1 - (x*scaledX/m_surface->w - x1)); + + int luminance( + bilinearInterpolate( + srcLine1[x1], srcLine1[x2], + srcLine2[x1], srcLine2[x2], + x1Weight, y1Weight + ) + ); + + bufp[x] = + SDL_MapRGB( + m_surface->format, luminance, luminance, luminance + ); + } + + int x1 = x/widthRatio; + int x2 = scaledX;; + int x1Weight = 16*(1 - (x/widthRatio - x1)); + + int luminance( + bilinearInterpolate( + srcLine1[x1], srcLine1[x2], + srcLine2[x1], srcLine2[x2], + x1Weight, y1Weight + ) + ); + + bufp[x] = + SDL_MapRGB( + m_surface->format, luminance, luminance, luminance + ); + } + } + else + { + // Nearest-Neighbour + for (int y = 0; y < m_surface->h; ++y) + { + Uint32 *bufp( + reinterpret_cast(m_surface->pixels) + + y * m_surface->pitch / 4 + ); + int y1 = (y/heightRatio + 0.5); + uint8_t* srcLine1 = &scaled[y1*scaledX]; + + for (int x = 0; x < m_surface->w; ++x) + { + int x1 = (x/widthRatio + 0.5); + int luminance(srcLine1[x1]); + + bufp[x] = + SDL_MapRGB( + m_surface->format, luminance, luminance, luminance + ); + } + } + + } + } + // Make sure our updates become visible. + SDL_UpdateRect(m_surface, 0, 0, 0, 0); + } + + if (SDL_MUSTLOCK(m_surface)) + { + SDL_UnlockSurface(m_surface); + } +} + diff --git a/retired/README b/retired/README new file mode 100644 index 0000000..e8f2110 --- /dev/null +++ b/retired/README @@ -0,0 +1,26 @@ +Fourth attempt at a Z80 CPU emulator. +michael@codesrc.com 2009-08-19 + + + +Hardware/OS Requirements: + +Nanosleep must support microsecond sleeps via nanosleep for best performance. +(Under linux CONFIG_NO_HZ and CONFIG_HIGH_RES_TIMERS) + +Target Environment: +This code is not going to run on a micro that I could solder. There is no way +to get more than 1FPS out of a 40MHz micro running bilinear filtering or hq4x. + +The target LCD won't have identical dimensions to the original 160x144 screen, +so some sort of scaling is necessary. This requires either a fast CPU, +or hardware GPU. + +Options: +1) Fast ARM + - Expensive +2) Slow ARM + OpenGL ES 2.0 (See TI OMAP35xx line for integrated ARM/opengl). + - hq4x can run as a shader on the GPU + - Same source tree will compile on a normal PC + - $150 beagleboard provides everything necessary. Similar processor in iPhone. +3) Slow ARM + FPGA. Can't use emulator on a desktop. diff --git a/retired/Resample.cc b/retired/Resample.cc new file mode 100644 index 0000000..28ac2fd --- /dev/null +++ b/retired/Resample.cc @@ -0,0 +1,137 @@ + +#include "mm80.hh" +#include "Resample.hh" + +// Requires 16bit CPU with 16x16 multiplier support. + +namespace +{ + +enum Constants { FP = 16 }; // Fixed point scaled by 8 + +// Provides a weighted mix between a 2x2 set of grayscale pixels. +// +// a1 a2 +// +// result +// +// b1 b2 +// +// xWeight = 16* (1 - (result - a1.x)) +// yWeight = 16* (1 - (result - a1.y)) +inline uint8_t bilinearInterpolate( + uint8_t a1, uint8_t a2, + uint8_t b1, uint8_t b2, + uint16_t xw, // 0 -> FP + uint16_t yw // 0 -> FP + ) +{ + // 16bit clean! + + return ( + xw*uint16_t(yw*(int16_t(a1)-b1) + uint16_t(b1)*uint16_t(FP)) + + (FP-xw)*uint16_t(yw*(int16_t(a2)-b2)+uint16_t(b2)*uint16_t(FP)) + ) / (FP*FP); + +better + return (xw*(yw*(int16_t(a1)-b1 -a2 +b2) + s*(int16_t(b1) -b2)) + + s*(yw*((int16_t(a2)-b2)+s*int16_t(b2)))) / (s * s); + + +NO! Need a1 >> something + a2 >> something etc. +NO MULTIPLICATION NEEDED +This also means it could be 8-bit clean! + + +tmp = 256 * targetX * srcWidth / destWidth == src X + 0 -> 256. +srcX = tmp >> 8; +srcWeight = log2(tmp & 0xFF); + +srcWeight should be shift RIGHT number, between 0 (100%) and 8 (0%) +} + + xw*(yw*(a1-b1) + s*b1) + + (s-xw)*(yw*(a2-b2)+s*b2) + + + xw*(yw*(a1-b1) + s*b1) + + s*(yw*(a2-b2)+s*b2) -1 * + xw*(yw*(a2-b2)+s*b2) + + + xw*(yw*(a1-b1) + s*b1 - yw*(a2-b2) -s*b2) + + s*(yw*(a2-b2)+s*b2) + + + xw*(yw*(a1-b1 -a2 +b2) + s(b1 -b2)) + + s*(yw*(a2-b2)+s*b2) + +void +Resample::Bilinear( + uint8_t* dest, + int destX, + int destY, + int destPitch, + const uint8_t* src, + int srcX, + int srcY, + int srcPitch + ) +{ + + //double heightRatio = static_cast(m_surface->h) / scaledY; + //double widthRatio = static_cast(m_surface->w) / scaledX; + for (int y = 0; y < destY; ++y) + { + uint8_t* outRow(dest + y * destPitch); + + int y1 = y * srcY / destY; + int y2 = std::min(y1 + 1, destY); +TODO + int yWeight = FP - FP * (y/heightRatio - y1)); + + uint8_t* srcLine1 = &scaled[y1*scaledX]; + uint8_t* srcLine2 = &scaled[y2*scaledX]; + + int x = 0; + for (; x < m_surface->w - 1; ++x) + { + //int x1 = x/widthRatio; + int x1 = x*scaledX / m_surface->w; + int x2 = x1 + 1; +// int x1Weight = 16*(1 - (x/widthRatio - x1)); + int x1Weight = 16*(1 - (x*scaledX/m_surface->w - x1)); + + int luminance( + bilinearInterpolate( + srcLine1[x1], srcLine1[x2], + srcLine2[x1], srcLine2[x2], + x1Weight, y1Weight + ) + ); + + bufp[x] = + SDL_MapRGB( + m_surface->format, luminance, luminance, luminance + ); + } + + int x1 = x/widthRatio; + int x2 = scaledX;; + int x1Weight = 16*(1 - (x/widthRatio - x1)); + + int luminance( + bilinearInterpolate( + srcLine1[x1], srcLine1[x2], + srcLine2[x1], srcLine2[x2], + x1Weight, y1Weight + ) + ); + + bufp[x] = + SDL_MapRGB( + m_surface->format, luminance, luminance, luminance + ); + } + + diff --git a/retired/hq4x.cc b/retired/hq4x.cc new file mode 100644 index 0000000..1280e6b --- /dev/null +++ b/retired/hq4x.cc @@ -0,0 +1,5267 @@ +//hq4x filter demo program +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) + +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +// Converted to grayscale 2010 by Michael McMaster (Michael.McMaster@gmail.com) + +#include +#include +#include + +inline void Interp1(uint8_t* pc, uint8_t c1, uint8_t c2) +{ + *pc = (c1*3l+c2) >> 2; +} + +inline void Interp2(uint8_t* pc, uint8_t c1, uint8_t c2, uint8_t c3) +{ + *pc = (c1*2l+c2+c3) >> 2; +} + +inline void Interp3(uint8_t* pc, uint8_t c1, uint8_t c2) +{ + *pc = (c1*7l+c2)/8; +} + +inline void Interp5(uint8_t* pc, uint8_t c1, uint8_t c2) +{ + *pc = (static_cast(c1)+c2) >> 1; +} + +inline void Interp6(uint8_t* pc, uint8_t c1, uint8_t c2, uint8_t c3) +{ + *pc = (c1*5l+c2*2l+c3)/8; + +} + +inline void Interp7(uint8_t* pc, uint8_t c1, uint8_t c2, uint8_t c3) +{ + *pc = (c1*6l+c2+c3)/8; +} + +inline void Interp8(uint8_t* pc, uint8_t c1, uint8_t c2) +{ + *pc = (c1*5l+c2*3l)/8; +} + +#define PIXEL00_0 *pOut = c[5]; +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]); +#define PIXEL00_50 Interp5(pOut, c[2], c[4]); +#define PIXEL00_80 Interp8(pOut, c[5], c[1]); +#define PIXEL00_81 Interp8(pOut, c[5], c[4]); +#define PIXEL00_82 Interp8(pOut, c[5], c[2]); +#define PIXEL01_0 *(pOut+1) = c[5]; +#define PIXEL01_10 Interp1(pOut+1, c[5], c[1]); +#define PIXEL01_12 Interp1(pOut+1, c[5], c[2]); +#define PIXEL01_14 Interp1(pOut+1, c[2], c[5]); +#define PIXEL01_21 Interp2(pOut+1, c[2], c[5], c[4]); +#define PIXEL01_31 Interp3(pOut+1, c[5], c[4]); +#define PIXEL01_50 Interp5(pOut+1, c[2], c[5]); +#define PIXEL01_60 Interp6(pOut+1, c[5], c[2], c[4]); +#define PIXEL01_61 Interp6(pOut+1, c[5], c[2], c[1]); +#define PIXEL01_82 Interp8(pOut+1, c[5], c[2]); +#define PIXEL01_83 Interp8(pOut+1, c[2], c[4]); +#define PIXEL02_0 *(pOut+2) = c[5]; +#define PIXEL02_10 Interp1(pOut+2, c[5], c[3]); +#define PIXEL02_11 Interp1(pOut+2, c[5], c[2]); +#define PIXEL02_13 Interp1(pOut+2, c[2], c[5]); +#define PIXEL02_21 Interp2(pOut+2, c[2], c[5], c[6]); +#define PIXEL02_32 Interp3(pOut+2, c[5], c[6]); +#define PIXEL02_50 Interp5(pOut+2, c[2], c[5]); +#define PIXEL02_60 Interp6(pOut+2, c[5], c[2], c[6]); +#define PIXEL02_61 Interp6(pOut+2, c[5], c[2], c[3]); +#define PIXEL02_81 Interp8(pOut+2, c[5], c[2]); +#define PIXEL02_83 Interp8(pOut+2, c[2], c[6]); +#define PIXEL03_0 *(pOut+3) = c[5]; +#define PIXEL03_11 Interp1(pOut+3, c[5], c[2]); +#define PIXEL03_12 Interp1(pOut+3, c[5], c[6]); +#define PIXEL03_20 Interp2(pOut+3, c[5], c[2], c[6]); +#define PIXEL03_50 Interp5(pOut+3, c[2], c[6]); +#define PIXEL03_80 Interp8(pOut+3, c[5], c[3]); +#define PIXEL03_81 Interp8(pOut+3, c[5], c[2]); +#define PIXEL03_82 Interp8(pOut+3, c[5], c[6]); +#define PIXEL10_0 *(pOut+BpL) = c[5]; +#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[1]); +#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_13 Interp1(pOut+BpL, c[4], c[5]); +#define PIXEL10_21 Interp2(pOut+BpL, c[4], c[5], c[2]); +#define PIXEL10_32 Interp3(pOut+BpL, c[5], c[2]); +#define PIXEL10_50 Interp5(pOut+BpL, c[4], c[5]); +#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[2]); +#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[4], c[1]); +#define PIXEL10_81 Interp8(pOut+BpL, c[5], c[4]); +#define PIXEL10_83 Interp8(pOut+BpL, c[4], c[2]); +#define PIXEL11_0 *(pOut+BpL+1) = c[5]; +#define PIXEL11_30 Interp3(pOut+BpL+1, c[5], c[1]); +#define PIXEL11_31 Interp3(pOut+BpL+1, c[5], c[4]); +#define PIXEL11_32 Interp3(pOut+BpL+1, c[5], c[2]); +#define PIXEL11_70 Interp7(pOut+BpL+1, c[5], c[4], c[2]); +#define PIXEL12_0 *(pOut+BpL+2) = c[5]; +#define PIXEL12_30 Interp3(pOut+BpL+2, c[5], c[3]); +#define PIXEL12_31 Interp3(pOut+BpL+2, c[5], c[2]); +#define PIXEL12_32 Interp3(pOut+BpL+2, c[5], c[6]); +#define PIXEL12_70 Interp7(pOut+BpL+2, c[5], c[6], c[2]); +#define PIXEL13_0 *(pOut+BpL+3) = c[5]; +#define PIXEL13_10 Interp1(pOut+BpL+3, c[5], c[3]); +#define PIXEL13_12 Interp1(pOut+BpL+3, c[5], c[6]); +#define PIXEL13_14 Interp1(pOut+BpL+3, c[6], c[5]); +#define PIXEL13_21 Interp2(pOut+BpL+3, c[6], c[5], c[2]); +#define PIXEL13_31 Interp3(pOut+BpL+3, c[5], c[2]); +#define PIXEL13_50 Interp5(pOut+BpL+3, c[6], c[5]); +#define PIXEL13_60 Interp6(pOut+BpL+3, c[5], c[6], c[2]); +#define PIXEL13_61 Interp6(pOut+BpL+3, c[5], c[6], c[3]); +#define PIXEL13_82 Interp8(pOut+BpL+3, c[5], c[6]); +#define PIXEL13_83 Interp8(pOut+BpL+3, c[6], c[2]); +#define PIXEL20_0 *(pOut+BpL+BpL) = c[5]; +#define PIXEL20_10 Interp1(pOut+BpL+BpL, c[5], c[7]); +#define PIXEL20_12 Interp1(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_14 Interp1(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_21 Interp2(pOut+BpL+BpL, c[4], c[5], c[8]); +#define PIXEL20_31 Interp3(pOut+BpL+BpL, c[5], c[8]); +#define PIXEL20_50 Interp5(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_60 Interp6(pOut+BpL+BpL, c[5], c[4], c[8]); +#define PIXEL20_61 Interp6(pOut+BpL+BpL, c[5], c[4], c[7]); +#define PIXEL20_82 Interp8(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_83 Interp8(pOut+BpL+BpL, c[4], c[8]); +#define PIXEL21_0 *(pOut+BpL+BpL+1) = c[5]; +#define PIXEL21_30 Interp3(pOut+BpL+BpL+1, c[5], c[7]); +#define PIXEL21_31 Interp3(pOut+BpL+BpL+1, c[5], c[8]); +#define PIXEL21_32 Interp3(pOut+BpL+BpL+1, c[5], c[4]); +#define PIXEL21_70 Interp7(pOut+BpL+BpL+1, c[5], c[4], c[8]); +#define PIXEL22_0 *(pOut+BpL+BpL+2) = c[5]; +#define PIXEL22_30 Interp3(pOut+BpL+BpL+2, c[5], c[9]); +#define PIXEL22_31 Interp3(pOut+BpL+BpL+2, c[5], c[6]); +#define PIXEL22_32 Interp3(pOut+BpL+BpL+2, c[5], c[8]); +#define PIXEL22_70 Interp7(pOut+BpL+BpL+2, c[5], c[6], c[8]); +#define PIXEL23_0 *(pOut+BpL+BpL+3) = c[5]; +#define PIXEL23_10 Interp1(pOut+BpL+BpL+3, c[5], c[9]); +#define PIXEL23_11 Interp1(pOut+BpL+BpL+3, c[5], c[6]); +#define PIXEL23_13 Interp1(pOut+BpL+BpL+3, c[6], c[5]); +#define PIXEL23_21 Interp2(pOut+BpL+BpL+3, c[6], c[5], c[8]); +#define PIXEL23_32 Interp3(pOut+BpL+BpL+3, c[5], c[8]); +#define PIXEL23_50 Interp5(pOut+BpL+BpL+3, c[6], c[5]); +#define PIXEL23_60 Interp6(pOut+BpL+BpL+3, c[5], c[6], c[8]); +#define PIXEL23_61 Interp6(pOut+BpL+BpL+3, c[5], c[6], c[9]); +#define PIXEL23_81 Interp8(pOut+BpL+BpL+3, c[5], c[6]); +#define PIXEL23_83 Interp8(pOut+BpL+BpL+3, c[6], c[8]); +#define PIXEL30_0 *(pOut+BpL+BpL+BpL) = c[5]; +#define PIXEL30_11 Interp1(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_12 Interp1(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL30_20 Interp2(pOut+BpL+BpL+BpL, c[5], c[8], c[4]); +#define PIXEL30_50 Interp5(pOut+BpL+BpL+BpL, c[8], c[4]); +#define PIXEL30_80 Interp8(pOut+BpL+BpL+BpL, c[5], c[7]); +#define PIXEL30_81 Interp8(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_82 Interp8(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL31_0 *(pOut+BpL+BpL+BpL+1) = c[5]; +#define PIXEL31_10 Interp1(pOut+BpL+BpL+BpL+1, c[5], c[7]); +#define PIXEL31_11 Interp1(pOut+BpL+BpL+BpL+1, c[5], c[8]); +#define PIXEL31_13 Interp1(pOut+BpL+BpL+BpL+1, c[8], c[5]); +#define PIXEL31_21 Interp2(pOut+BpL+BpL+BpL+1, c[8], c[5], c[4]); +#define PIXEL31_32 Interp3(pOut+BpL+BpL+BpL+1, c[5], c[4]); +#define PIXEL31_50 Interp5(pOut+BpL+BpL+BpL+1, c[8], c[5]); +#define PIXEL31_60 Interp6(pOut+BpL+BpL+BpL+1, c[5], c[8], c[4]); +#define PIXEL31_61 Interp6(pOut+BpL+BpL+BpL+1, c[5], c[8], c[7]); +#define PIXEL31_81 Interp8(pOut+BpL+BpL+BpL+1, c[5], c[8]); +#define PIXEL31_83 Interp8(pOut+BpL+BpL+BpL+1, c[8], c[4]); +#define PIXEL32_0 *(pOut+BpL+BpL+BpL+2) = c[5]; +#define PIXEL32_10 Interp1(pOut+BpL+BpL+BpL+2, c[5], c[9]); +#define PIXEL32_12 Interp1(pOut+BpL+BpL+BpL+2, c[5], c[8]); +#define PIXEL32_14 Interp1(pOut+BpL+BpL+BpL+2, c[8], c[5]); +#define PIXEL32_21 Interp2(pOut+BpL+BpL+BpL+2, c[8], c[5], c[6]); +#define PIXEL32_31 Interp3(pOut+BpL+BpL+BpL+2, c[5], c[6]); +#define PIXEL32_50 Interp5(pOut+BpL+BpL+BpL+2, c[8], c[5]); +#define PIXEL32_60 Interp6(pOut+BpL+BpL+BpL+2, c[5], c[8], c[6]); +#define PIXEL32_61 Interp6(pOut+BpL+BpL+BpL+2, c[5], c[8], c[9]); +#define PIXEL32_82 Interp8(pOut+BpL+BpL+BpL+2, c[5], c[8]); +#define PIXEL32_83 Interp8(pOut+BpL+BpL+BpL+2, c[8], c[6]); +#define PIXEL33_0 *(pOut+BpL+BpL+BpL+3) = c[5]; +#define PIXEL33_11 Interp1(pOut+BpL+BpL+BpL+3, c[5], c[6]); +#define PIXEL33_12 Interp1(pOut+BpL+BpL+BpL+3, c[5], c[8]); +#define PIXEL33_20 Interp2(pOut+BpL+BpL+BpL+3, c[5], c[8], c[6]); +#define PIXEL33_50 Interp5(pOut+BpL+BpL+BpL+3, c[8], c[6]); +#define PIXEL33_80 Interp8(pOut+BpL+BpL+BpL+3, c[5], c[9]); +#define PIXEL33_81 Interp8(pOut+BpL+BpL+BpL+3, c[5], c[6]); +#define PIXEL33_82 Interp8(pOut+BpL+BpL+BpL+3, c[5], c[8]); + + + +inline bool Diff(uint8_t w1, uint8_t w2) +{ + return std::labs(w1 - w2) > 0x30; +} + +void hq4x_32(const uint8_t* pIn, uint8_t* pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int prevline, nextline; + uint8_t w[10]; + uint8_t c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) prevline = -Xres; else prevline = 0; + if (j0) + { + w[1] = *(pIn + prevline - 1); + w[4] = *(pIn - 1); + w[7] = *(pIn + nextline - 1); + } + else + { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } + + if (i 0x30) pattern |= flag; + } + flag <<= 1; + } + + for (k=1; k<=9; k++) + c[k] = w[k]; + + switch (pattern) + { + case 0: + case 1: + case 4: + case 32: + case 128: + case 5: + case 132: + case 160: + case 33: + case 129: + case 36: + case 133: + case 164: + case 161: + case 37: + case 165: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 2: + case 34: + case 130: + case 162: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 16: + case 17: + case 48: + case 49: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 64: + case 65: + case 68: + case 69: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 8: + case 12: + case 136: + case 140: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 3: + case 35: + case 131: + case 163: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 6: + case 38: + case 134: + case 166: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 20: + case 21: + case 52: + case 53: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 144: + case 145: + case 176: + case 177: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 192: + case 193: + case 196: + case 197: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 96: + case 97: + case 100: + case 101: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 40: + case 44: + case 168: + case 172: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 9: + case 13: + case 137: + case 141: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 18: + case 50: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL12_0 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 80: + case 81: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 72: + case 76: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_50 + PIXEL21_0 + PIXEL30_50 + PIXEL31_50 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 10: + case 138: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 66: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 24: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 7: + case 39: + case 135: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 148: + case 149: + case 180: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 224: + case 228: + case 225: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 41: + case 169: + case 45: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 22: + case 54: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 208: + case 209: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 104: + case 108: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 11: + case 139: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 19: + case 51: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 146: + case 178: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 84: + case 85: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 112: + case 113: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 200: + case 204: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 73: + case 77: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 42: + case 170: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 14: + case 142: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 67: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 70: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 28: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 152: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 194: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 98: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 56: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 25: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 26: + case 31: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 82: + case 214: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 88: + case 248: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 74: + case 107: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 27: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 86: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 216: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 106: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 30: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 210: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 120: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 75: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 29: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 198: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 184: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 99: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 57: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 71: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 156: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 226: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 60: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 195: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 102: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 153: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 58: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 83: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 92: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 202: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 78: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 154: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 114: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 89: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 90: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 55: + case 23: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 182: + case 150: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 213: + case 212: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 241: + case 240: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 236: + case 232: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 109: + case 105: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 171: + case 43: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 143: + case 15: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 124: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 203: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 62: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 211: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 118: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 217: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 110: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 155: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 188: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 185: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 61: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 157: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 103: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 227: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 230: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 199: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 220: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 158: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 234: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 242: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 59: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 121: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 87: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 79: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_32 + PIXEL03_82 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 122: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 94: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 218: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 91: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 229: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 167: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 173: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 181: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 186: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 115: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 93: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 206: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 205: + case 201: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 174: + case 46: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 179: + case 147: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 117: + case 116: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 189: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 231: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 126: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 219: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 125: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 221: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 207: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 238: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 190: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + break; + } + case 187: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 243: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 119: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 237: + case 233: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 175: + case 47: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 183: + case 151: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 245: + case 244: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 250: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 123: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 95: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 222: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 252: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 249: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 235: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 111: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 63: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 159: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 215: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 246: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 254: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 253: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 251: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 239: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 127: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 191: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 223: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 247: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 255: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + } + pIn+=1; + pOut+=4; + } + pOut+=BpL; + pOut+=BpL; + pOut+=BpL; + } +} + diff --git a/shaders/scale2x.slf b/shaders/scale2x.slf new file mode 100644 index 0000000..7f4cb3c --- /dev/null +++ b/shaders/scale2x.slf @@ -0,0 +1,83 @@ +// http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/loading.php + +#version 130 + +uniform sampler2D OGL2Texture; +uniform vec4 OGL2Size; + +/* +void main (void) +{ + // Every pixel becomes green + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); +} +*/ + +in vec4 vTexCoord; // supplied from vertex processor +in vec4 B; +in vec4 D; +in vec4 F; +in vec4 H; + +void main(void) + +{ + vec4 fragmentLocation; + + vec4 eColour; + vec4 bColour; + vec4 dColour; + vec4 fColour; + vec4 hColour; + + vec4 E0; + vec4 E1; + vec4 E2; + vec4 E3; + + eColour = texture2DProj(OGL2Texture, vTexCoord); + bColour = texture2DProj(OGL2Texture, B); + dColour = texture2DProj(OGL2Texture, D); + fColour = texture2DProj(OGL2Texture, F); + hColour = texture2DProj(OGL2Texture, H); + + if (bColour != hColour && dColour != fColour) { + E0 = dColour == bColour ? dColour : eColour; + E1 = bColour == fColour ? fColour : eColour; + E2 = dColour == hColour ? dColour : eColour; + E3 = hColour == fColour ? fColour : eColour; + } else { + E0 = eColour; + E1 = eColour; + E2 = eColour; + E3 = eColour; + } + + // Is this pixel E0,E1,E2 or E3, or somewhere in between ? + fragmentLocation = fract(vTexCoord * OGL2Size); + //fragmentLocation = fract(vTexCoord * texturesize(OGL2Texture)); + + // TODO interpolate + if (fragmentLocation.x < 0.5) + { + if (fragmentLocation.y < 0.5) + { + gl_FragColor = E0; + } + else + { + gl_FragColor = E2; + } + } + else + { + if (fragmentLocation.y < 0.5) + { + gl_FragColor = E1; + } + else + { + gl_FragColor = E3; + } + } +} diff --git a/shaders/scale2x.slv b/shaders/scale2x.slv new file mode 100644 index 0000000..2297a09 --- /dev/null +++ b/shaders/scale2x.slv @@ -0,0 +1,54 @@ +// http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/loading.php + + +// Built-in vertex attributes (per vertex) +// gl_Vertex Position of current vertex (vec4) +// gl_Color Primary colour of vertex (vec4) +//gl_MultiTexCoord0 Texture Coordinate of texture unit 0 + +// Built-in variables (passed from vertex to fragment) +// Will be interpolated between vertex and fragment. + +// Scales output, so image only takes up top left of screen (1/4 of image); +/* +void main(void) +{ + vec4 a = gl_Vertex; + a.x = a.x * 2.0;//0.5; + a.y = a.y * 0.5; + + + gl_Position = gl_ModelViewProjectionMatrix * a; + // gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; normal code + +} +*/ + +#version 130 + +uniform vec4 OGL2Param; + +out vec4 vTexCoord; // Passed to fragment +out vec4 B; // Passed to fragment +out vec4 D; // Passed to fragment +out vec4 F; // Passed to fragment +out vec4 H; // Passed to fragment + + +void main(void) +{ + vec4 offsetx; + vec4 offsety; + + offsetx = vec4(OGL2Param.x, 0, 0, 0); + offsety = vec4(0, OGL2Param.y, 0, 0); + + B = gl_MultiTexCoord0 - offsety; + D = gl_MultiTexCoord0 - offsetx; + F = gl_MultiTexCoord0 + offsetx; + H = gl_MultiTexCoord0 + offsety; + + vTexCoord = gl_MultiTexCoord0; + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +} + -- 2.38.5