Merge branch 'dev' into comments

This commit is contained in:
white-axe 2024-01-13 21:55:00 -05:00
commit e728b473fa
No known key found for this signature in database
GPG key ID: 7901753DB465B711
63 changed files with 7061 additions and 2598 deletions

View file

@ -70,6 +70,7 @@ jobs:
cp ../mkxp-z.exe .
cp ../../mkxp.json .
cp -r ../../scripts .
cp ../../assets/LICENSE.mkxp-z-with-https.txt .
- uses: actions/upload-artifact@v3
with:
@ -78,6 +79,7 @@ jobs:
build/artifact/*.dll
build/artifact/*.exe
build/artifact/mkxp.json
build/artifact/LICENSE.mkxp-z-with-https.txt
build/artifact/scripts/
build/artifact/stdlib/
@ -125,6 +127,7 @@ jobs:
mv ./3.1.0 ./stdlib
cp ../../mkxp.json .
cp -r ../../scripts .
cp ../../assets/LICENSE.mkxp-z-with-https.txt .
cd ..
zip -r local.zip local
@ -175,6 +178,7 @@ jobs:
- name: Compress app
run: |
cd build/Build/Products/Release
cp ../../../../assets/LICENSE.mkxp-z-with-https.txt ./Z-universal.app/
ditto -c -k --sequesterRsrc --keepParent Z-universal.app Z-universal.app.zip
- name: Upload archive

2
.gitignore vendored
View file

@ -8,6 +8,8 @@
mkxp
xxd+
/res
/build
/builddir

View file

@ -25,7 +25,7 @@ Despite the fact that it was made with Essentials games in mind, there is nothin
It supports Windows, Linux and both Intel and Apple Silicon versions of macOS.
It is licensed under the GNU General Public License v2+.
mkxp-z is licensed under the GNU General Public License v2+. However, if you build mkxp-z with the `enable-https` option turned on (which is the default), you will also need to comply with OpenSSL's Apache v2 license, which in practice means that the resulting binaries are licensed under GPLv3.
## Bindings
Bindings provide the glue code for an interpreted language environment to run game scripts in. mkxp-z focuses on MRI and as such the mruby and null bindings are not included.
@ -53,8 +53,11 @@ In the RMXP version of RGSS, fonts are loaded directly from system specific sear
If a requested font is not found, no error is generated. Instead, a built-in font is used. By default, this font is Liberation Sans.
## What doesn't work
* wma audio files
* Creating Bitmaps with sizes greater than your hardware's texture size limit (around 16384 on modern cards).
* Creating Bitmaps with sizes greater than your hardware's texture size limit.
* To find the limit of various GPU's, [the OpenGL Hardware Database](https://opengl.gpuinfo.org/displaycapability.php?name=GL_MAX_TEXTURE_SIZE) is useful.
* Modern GPU's tend to have a limit of 32 kibipixels for NVIDIA, 16 kibipixels for AMD, Intel, Apple, and LLVMpipe, and 8 kibipixels for Mali and PowerVR. You should check the above database to be sure.
* There is an exception to this, called *mega surface*. When a Bitmap bigger than the texture limit is created from a file, it is not stored in VRAM, but regular RAM. Its sole purpose is to be used as a tileset bitmap. Any other operation to it (besides blitting to a regular Bitmap) will result in an error.
## Notable Thanks

View file

@ -0,0 +1,691 @@
mkxp-z is Copyright (C) 2013 - 2023 the mkxp-z contributors, including
Amaryllis Kulla <ancurio@mapleshrine.eu>, Struma, Splendide Imaginarius,
and others. The full list of contributors can be found by cloning the
mkxp-z Git repository (see below).
mkxp-z 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, version 3.
mkxp-z 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.
The mkxp-z source code is available at:
<https://github.com/mkxp-z/mkxp-z>
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <https://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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
<https://www.gnu.org/licenses/>.
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
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View file

@ -49,6 +49,12 @@ void bitmapInitProps(Bitmap *b, VALUE self) {
b->setInitFont(font);
rb_iv_set(self, "font", fontObj);
// Leave property as default nil if hasHires() is false.
if (b->hasHires()) {
b->assumeRubyGC();
wrapProperty(self, b->getHires(), "hires", BitmapType);
}
}
RB_METHOD(bitmapInitialize) {
@ -94,6 +100,8 @@ RB_METHOD(bitmapHeight) {
return INT2FIX(value);
}
DEF_GFX_PROP_OBJ_REF(Bitmap, Bitmap, Hires, "hires")
RB_METHOD(bitmapRect) {
RB_UNUSED_PARAM;
@ -741,6 +749,9 @@ void bitmapBindingInit() {
_rb_define_method(klass, "width", bitmapWidth);
_rb_define_method(klass, "height", bitmapHeight);
INIT_PROP_BIND(Bitmap, Hires, "hires");
_rb_define_method(klass, "rect", bitmapRect);
_rb_define_method(klass, "blt", bitmapBlt);
_rb_define_method(klass, "stretch_blt", bitmapStretchBlt);

View file

@ -19,6 +19,7 @@
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "graphics.h"
#include "sharedstate.h"
#include "binding-util.h"
@ -367,7 +368,7 @@ DEF_GRA_PROP_B(ShowCursor)
DEF_GRA_PROP_F(Scale)
DEF_GRA_PROP_B(Frameskip)
DEF_GRA_PROP_B(FixedAspectRatio)
DEF_GRA_PROP_B(SmoothScaling)
DEF_GRA_PROP_I(SmoothScaling)
DEF_GRA_PROP_B(IntegerScaling)
DEF_GRA_PROP_B(LastMileScaling)
DEF_GRA_PROP_B(Threadsafe)

View file

@ -309,7 +309,7 @@ $(DOWNLOADS)/openssl/Makefile: $(DOWNLOADS)/openssl/Configure
--openssldir="$(BUILD_PREFIX)"
$(DOWNLOADS)/openssl/Configure:
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl --single-branch --branch OpenSSL_1_1_1i --depth 1
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl --single-branch --branch openssl-3.0.12 --depth 1
# Standard ruby
ruby: init_dirs openssl $(LIBDIR)/libruby.so.3.1

View file

@ -298,8 +298,7 @@ $(DOWNLOADS)/openssl/Makefile: $(DOWNLOADS)/openssl/Configure
--openssldir="$(BUILD_PREFIX)"
$(DOWNLOADS)/openssl/Configure:
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl; \
cd $(DOWNLOADS)/openssl --single-branch --branch OpenSSL_1_1_1i --depth 1
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl --single-branch --branch openssl-3.0.12 --depth 1
# Standard ruby
ruby: init_dirs openssl $(LIBDIR)/libruby.3.1.dylib

View file

@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
02054AB6B60F49E3DF366CBD /* libjxl_dec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 672947DA8FC50921A7ED814A /* libjxl_dec.a */; };
319D403193F13F7989325EEA /* bicubic.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */; };
3389416F9825F408A40824F3 /* libbrotlicommon-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8AA4AE49BB66C97EFAE3055 /* libbrotlicommon-static.a */; };
3B10EC5C2568D40500372D13 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081562568D3A60006849F /* CoreGraphics.framework */; };
3B10EC5D2568D40C00372D13 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081552568D3A60006849F /* Carbon.framework */; };
@ -505,6 +506,7 @@
3BF5B4BF2685883B00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BE2685883B00A3B240 /* libSDL2_sound.a */; };
3BF5B4C02685883B00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BE2685883B00A3B240 /* libSDL2_sound.a */; };
3E2542219A9FD2B16781B1F5 /* libbrotlidec-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C4B4BA780D4407F24279700 /* libbrotlidec-static.a */; };
3F7F41D98CEDE6F418AAB0D2 /* bicubic.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */; };
74E9471FB1A876B0D9F2ABFF /* libbrotlidec-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C254B088D8B18C7E957DE30 /* libbrotlidec-static.a */; };
96563582279A5ABD003D6A75 /* libtheora.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96563581279A5ABD003D6A75 /* libtheora.a */; };
96563583279A5ABD003D6A75 /* libtheora.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96563581279A5ABD003D6A75 /* libtheora.a */; };
@ -534,10 +536,10 @@
ECEC415E939B13D8C959F8D7 /* libhwy.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C3D4EBA94DA7A5C543A337E /* libhwy.a */; };
EF05486C9854302CD39A0B80 /* libhwy.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 667B4E3FBC5B03611D5C334E /* libhwy.a */; };
F7CA439883B85807B560AF67 /* libhwy.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 667B4E3FBC5B03611D5C334E /* libhwy.a */; };
FE5204162A08E27D0070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; };
FE5204172A08E2880070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; };
FE5204182A08E28F0070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; };
FE5204192A08E2950070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; };
FE5204162A08E27D0070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
FE5204172A08E2880070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
FE5204182A08E28F0070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
FE5204192A08E2950070038A /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE5204152A08E27D0070038A /* CoreHaptics.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
FE52041B2A08E58D0070038A /* lanczos3.frag in Resources */ = {isa = PBXBuildFile; fileRef = FE52041A2A08E58D0070038A /* lanczos3.frag */; };
FE52041C2A08E62F0070038A /* lanczos3.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = FE52041A2A08E58D0070038A /* lanczos3.frag */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
/* End PBXBuildFile section */
@ -763,6 +765,7 @@
3B10ECE82568E83D00372D13 /* tilemapvx.vert in CopyFiles */,
3B10ECE92568E83D00372D13 /* trans.frag in CopyFiles */,
3B10ECEA2568E83D00372D13 /* transSimple.frag in CopyFiles */,
3F7F41D98CEDE6F418AAB0D2 /* bicubic.frag in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -773,6 +776,7 @@
dstSubfolderSpec = 7;
files = (
3B10ECF52568E86B00372D13 /* liberation.ttf in CopyFiles */,
319D403193F13F7989325EEA /* bicubic.frag in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1134,6 +1138,7 @@
96573E80279152DC002C3E77 /* TouchBar.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = TouchBar.xcassets; path = views/TouchBar.xcassets; sourceTree = "<group>"; };
96D8EDD028728DCA00A331EA /* gamecontrollerdb.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = gamecontrollerdb.txt; path = ../assets/gamecontrollerdb.txt; sourceTree = "<group>"; };
A8AA4AE49BB66C97EFAE3055 /* libbrotlicommon-static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libbrotlicommon-static.a"; path = "Dependencies/build-macosx-universal/lib/libbrotlicommon-static.a"; sourceTree = "<group>"; };
CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = bicubic.frag; path = ../shader/bicubic.frag; sourceTree = "<group>"; };
FE5204152A08E27D0070038A /* CoreHaptics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreHaptics.framework; path = System/Library/Frameworks/CoreHaptics.framework; sourceTree = SDKROOT; };
FE52041A2A08E58D0070038A /* lanczos3.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = lanczos3.frag; path = ../shader/lanczos3.frag; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -1386,6 +1391,7 @@
3B10EC982568E7B500372D13 /* sprite.vert */,
3B10ECA02568E7B600372D13 /* tilemap.vert */,
3B10EC962568E7B500372D13 /* tilemapvx.vert */,
CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */,
);
name = Shaders;
sourceTree = "<group>";
@ -1942,7 +1948,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 3B1C23EF25A19C600075EF5D /* Build configuration list for PBXNativeTarget "Z-steam" */;
buildPhases = (
FE4F72FE2A179EE0004FED68 /* ShellScript */,
3B1C237025A19C600075EF5D /* Sources */,
3B1C23C225A19C600075EF5D /* Frameworks */,
3B1C23E625A19C600075EF5D /* Resources */,
@ -1951,6 +1956,7 @@
3B1C23EA25A19C600075EF5D /* CopyFiles */,
3B251DAB26DA2EBB00E5D09B /* CopyFiles */,
3B1C23EC25A19C600075EF5D /* Embed Frameworks */,
FE4F72FE2A179EE0004FED68 /* ShellScript */,
);
buildRules = (
);
@ -1986,7 +1992,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 3BBE88062705A73400A574AE /* Build configuration list for PBXNativeTarget "Z-steam-universal" */;
buildPhases = (
FE4F72FD2A179ED5004FED68 /* ShellScript */,
3BBE87852705A73400A574AE /* Sources */,
3BBE87CE2705A73400A574AE /* Frameworks */,
3BBE87F42705A73400A574AE /* Resources */,
@ -1995,6 +2000,7 @@
3BBE87FC2705A73400A574AE /* CopyFiles */,
3BBE87FE2705A73400A574AE /* CopyFiles */,
3BBE88002705A73400A574AE /* Embed Frameworks */,
FE4F72FD2A179ED5004FED68 /* ShellScript */,
);
buildRules = (
);
@ -2011,7 +2017,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 3BC65E122584F3AD0063AFF1 /* Build configuration list for PBXNativeTarget "Z-universal" */;
buildPhases = (
FE4F72FB2A179D9E004FED68 /* ShellScript */,
3BC65D8D2584F3AD0063AFF1 /* Sources */,
3BC65DDB2584F3AD0063AFF1 /* Frameworks */,
3BC65E0D2584F3AD0063AFF1 /* Resources */,
@ -2019,6 +2024,7 @@
3BC65E0F2584F3AD0063AFF1 /* CopyFiles */,
3B251D9F26DA2C2A00E5D09B /* CopyFiles */,
3B522D79259BA0E3003301C4 /* Embed Frameworks */,
FE4F72FB2A179D9E004FED68 /* ShellScript */,
);
buildRules = (
);
@ -2034,7 +2040,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 3BD2B7222565AEC0003DAD8A /* Build configuration list for PBXNativeTarget "Z-intel" */;
buildPhases = (
FE4F72FC2A179ECC004FED68 /* ShellScript */,
3BD2B64C2565AEC0003DAD8A /* Sources */,
3BD2B6E12565AEC0003DAD8A /* Frameworks */,
3BD2B6F82565AEC0003DAD8A /* Resources */,
@ -2042,6 +2047,7 @@
3B5A843B2569F95A00BAF2E5 /* CopyFiles */,
3B251DA726DA2E8A00E5D09B /* CopyFiles */,
3B522D7C259BA0E8003301C4 /* Embed Frameworks */,
FE4F72FC2A179ECC004FED68 /* ShellScript */,
);
buildRules = (
);
@ -2069,7 +2075,7 @@
};
};
};
buildConfigurationList = 3BDB22EF25644FBF00C4A63D /* Build configuration list for PBXProject "mkxp-z" */;
buildConfigurationList = 3BDB22EF25644FBF00C4A63D /* Build configuration list for PBXProject "Assets" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
@ -2154,6 +2160,7 @@
inputFileListPaths = (
);
inputPaths = (
"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}",
);
outputFileListPaths = (
);
@ -2161,7 +2168,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n";
};
FE4F72FC2A179ECC004FED68 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@ -2171,6 +2178,7 @@
inputFileListPaths = (
);
inputPaths = (
"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}",
);
outputFileListPaths = (
);
@ -2178,7 +2186,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n";
};
FE4F72FD2A179ED5004FED68 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@ -2188,6 +2196,7 @@
inputFileListPaths = (
);
inputPaths = (
"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}",
);
outputFileListPaths = (
);
@ -2195,7 +2204,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n";
};
FE4F72FE2A179EE0004FED68 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@ -2205,6 +2214,7 @@
inputFileListPaths = (
);
inputPaths = (
"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}",
);
outputFileListPaths = (
);
@ -2212,7 +2222,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n";
};
/* End PBXShellScriptBuildPhase section */
@ -3686,7 +3696,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
3BDB22EF25644FBF00C4A63D /* Build configuration list for PBXProject "mkxp-z" */ = {
3BDB22EF25644FBF00C4A63D /* Build configuration list for PBXProject "Assets" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3BDB22F025644FBF00C4A63D /* Debug */,

View file

@ -196,7 +196,7 @@ s.d.ca.dir = (axis.value >= 0) ? AxisDir::Positive : AxisDir::Negative;
checkButtonAlt(leftShoulder, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, 12)
checkButtonAlt(rightShoulder, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, 12)
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_14_1
#if defined(__MAC_10_14_1) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_14_1
// Requires macOS 10.14.1+
checkButtonAlt(leftThumbstickButton, SDL_CONTROLLER_BUTTON_LEFTSTICK, 14)
checkButtonAlt(rightThumbstickButton, SDL_CONTROLLER_BUTTON_RIGHTSTICK, 14)
@ -204,7 +204,7 @@ s.d.ca.dir = (axis.value >= 0) ? AxisDir::Positive : AxisDir::Negative;
#warning "This SDK doesn't support the detection of thumbstick buttons. You will not be able to rebind them from the menu on 10.14.1 or higher."
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15
#if defined(__MAC_10_15) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15
// Requires macOS 10.15+
checkButton(Menu, SDL_CONTROLLER_BUTTON_START, 15)
checkButton(Options, SDL_CONTROLLER_BUTTON_BACK, 15)
@ -212,7 +212,7 @@ s.d.ca.dir = (axis.value >= 0) ? AxisDir::Positive : AxisDir::Negative;
#warning "This SDK doesn't support the detection of Start and Back buttons. You will not be able to rebind them from the menu on 10.15 or higher."
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_11_0
#if defined(__MAC_11_0) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_11_0
// Requires macOS 11.0+
checkButton(Home, SDL_CONTROLLER_BUTTON_GUIDE, 16)
#else

View file

@ -125,6 +125,7 @@ global_include_dirs += include_directories('src', 'binding')
rpath = ''
if host_system == 'windows'
windows_resource_directory = '../' + get_option('windows_resource_directory')
subdir('windows')
global_sources += windows_resources
global_include_dirs += include_directories('windows')

View file

@ -11,6 +11,8 @@ option('use_miniffi', type: 'boolean', value: true, description: 'Enable MiniFFI
option('enable-https', type: 'boolean', value: true, description: 'Support HTTPS for get/post requests. Requires OpenSSL.')
option('workdir_current', type: 'boolean', value: false, description: 'Keep current directory on startup')
option('windows_resource_directory', type: 'string', value: 'windows', description: 'Path to Windows EXE resource directory')
option('static_executable', type: 'boolean', value: true, description: 'Build a static executable (Windows-only)')
option('appimagekit_path', type: 'string', value: '', description: 'Path to AppImageTool, used for building AppImages')
option('appimage', type: 'boolean', value: false, description: 'Whether to install to an AppImage or just copy everything')

View file

@ -77,18 +77,52 @@
// "fixedAspectRatio": true,
// Apply linear interpolation when game screen
// Apply smooth interpolation when game screen
// is upscaled
// (default: disabled)
// 0: Nearest-Neighbor
// 1: Bilinear
// 2: Bicubic
// 3: Lanczos3
// (default: 0)
//
// "smoothScaling": false,
// "smoothScaling": 0,
// Apply Lanczos3 interpolation when game screen
// is upscaled (typically higher quality than linear)
// Sharpness when using Bicubic scaling.
// A good starting range is 0 to 100,
// but you may wish to go outside that range in either direction.
// (default: 100)
//
// "bicubicSharpness": 100,
// Replace the game's Bitmap files with external high-res files
// provided in the "Hires" directory.
// (You'll also need to set the below Scaling Factors.)
// (default: disabled)
//
// "lanczos3Scaling": false,
// "enableHires": false,
// Scaling factor for textures (e.g. Bitmaps)
// (higher values will look better if you use high-res textures)
// (default: 1.0)
//
// "textureScalingFactor": 4.0,
// Scaling factor for screen framebuffer
// (higher values will look better if you use high-res textures)
// (default: 1.0)
//
// "framebufferScalingFactor": 4.0,
// Scaling factor for tileset atlas
// (higher values will look better if you use high-res textures)
// (default: 1.0)
//
// "atlasScalingFactor": 4.0,
// Sync screen redraws to the monitor refresh rate
@ -288,7 +322,7 @@
// (default: none)
//
// "preloadScript": [
// "scripts/preload/ruby18_wrap.rb",
// "scripts/preload/ruby_classic_wrap.rb",
// "scripts/preload/mkxp_wrap.rb",
// "scripts/preload/win32_wrap.rb",
// ],
@ -300,8 +334,10 @@
//
// "pathCache": true,
// Add 'rtp1', 'rtp2.zip' and 'game.rgssad' to the
// asset search path (multiple allowed)
// Add 'rtp1', 'rtp2.zip' and 'game.rgssad' to the asset search path
// (multiple allowed). You can use folders, RGSS archives, and any archive
// formats supported by PhysicsFS; see the compatibility list at:
// https://www.icculus.org/physfs/docs/html/
// (default: none)
//
// "RTP": [
@ -310,6 +346,16 @@
// "/path/to/game.rgssad",
// ],
// Similar to the RTP option, except items are loaded before
// the game archive and folder, for incremental game updates
// or modding.
// (default: none)
//
// "patches": [
// "/path/to/patch1.zip",
// "/path/to/patch2",
// ],
// Use the script's name as filename in warnings and error messages
// (default: enabled)
@ -435,4 +481,10 @@
// "x": ...,
// },
// Dump tile atlas (for debugging purposes)
// (default: false)
//
// "dumpAtlas": false,
}

View file

@ -1,17 +0,0 @@
# ruby18_wrap.rb
# Author: Splendide Imaginarius (2022)
# Creative Commons CC0: To the extent possible under law, Splendide Imaginarius
# has waived all copyright and related or neighboring rights to ruby18_wrap.rb.
# https://creativecommons.org/publicdomain/zero/1.0/
# This preload script provides functions that existed in RPG Maker's Ruby v1.8,
# but were renamed in the current Ruby version used in mkxp-z, so that games
# (or other preload scripts) that expect Ruby v1.8's function names can find
# them.
class Hash
def index(*args)
key(*args)
end
end

View file

@ -0,0 +1,44 @@
# ruby_classic_wrap.rb
# Author: WaywardHeart (2023)
# Creative Commons CC0: To the extent possible under law, WaywardHeart has
# dedicated all copyright and related and neighboring rights to this script
# to the public domain worldwide.
# https://creativecommons.org/publicdomain/zero/1.0/
# This preload script provides functions that existed in RPG Maker's versions of Ruby,
# but were renamed or changed in the current Ruby version used in mkxp-z, so that games
# (or other preload scripts) that expect the older Ruby behavior can function.
class Hash
alias_method :index, :key unless method_defined?(:index)
end
class Object
TRUE = true unless const_defined?("TRUE")
FALSE = false unless const_defined?("FALSE")
NIL = nil unless const_defined?("NIL")
alias_method :id, :object_id unless method_defined?(:id)
alias_method :type, :class unless method_defined?(:type)
end
class NilClass
def id
4 # Starting with Ruby2, 64-bit builds of ruby make this 8
end
end
class TrueClass
def id
2 # Starting with Ruby2, 64-bit builds of ruby make this 20
end
end
if defined?(BasicObject) && BasicObject.instance_method(:initialize).arity == 0
# In ruby 1.9.2, and only ruby 1.9.2, BasicObject.initialize accepted any number of arguments
class BasicObject
def initialize(*args)
end
end
end

View file

@ -7,9 +7,18 @@
# all copyright and related or neighboring rights to win32_wrap.rb.
# https://creativecommons.org/publicdomain/zero/1.0/
# Edits by Splendide Imaginarius (2023) also CC0.
# This preload script provides a subset of Win32API in a cross-platform way, so
# you can play Win32API-based games on Linux and macOS.
# To tweak behavior, you can set the following Win32API class constants in an
# earlier preload script (these are usually only helpful for debugging):
#
# NATIVE_ON_WINDOWS=false
# TOLERATE_ERRORS=false
# LOG_NATIVE=true
module Scancodes
SDL = { :UNKNOWN => 0x00,
:A => 0x04, :B => 0x05, :C => 0x06, :D => 0x07,
@ -334,6 +343,11 @@ def kappatalize(s)
end
class Win32API
NATIVE_ON_WINDOWS = true unless const_defined?("NATIVE_ON_WINDOWS")
TOLERATE_ERRORS = true unless const_defined?("TOLERATE_ERRORS")
LOG_NATIVE = false unless const_defined?("LOG_NATIVE")
alias_method :mkxp_native_initialize, :initialize
def initialize(dll, func, *args)
@dll = dll
@func = func
@ -342,21 +356,45 @@ class Win32API
dll = kappatalize(dll.chomp(".dll"))
func = kappatalize(func)
if Win32API_Impl.const_defined?(dll)
dll_impl = Win32API_Impl.const_get(dll)
if dll_impl.const_defined?(func)
@impl = dll_impl.const_get(func).new
if !System.is_windows? or !NATIVE_ON_WINDOWS
if Win32API_Impl.const_defined?(dll)
dll_impl = Win32API_Impl.const_get(dll)
if dll_impl.const_defined?(func)
@mkxp_wrap_impl = dll_impl.const_get(func).new
return
end
end
end
end
def call(*args)
if @impl
return @impl.call(args)
@mkxp_native_available = false
begin
mkxp_native_initialize(@dll, @func, *args)
@mkxp_native_available = true
return
rescue
end
System.puts("[#{@dll}:#{@func}] #{args.to_s}") if !@called
@called = true
return 0
end
alias_method :mkxp_native_call, :call
def call(*args)
if @mkxp_wrap_impl
return @mkxp_wrap_impl.call(args)
end
if @mkxp_native_available
if LOG_NATIVE
System.puts("[Win32API] [#{@dll}:#{@func}] #{args.to_s}")
end
return mkxp_native_call(*args)
end
if TOLERATE_ERRORS
System.puts("[Win32API] [#{@dll}:#{@func}] #{args.to_s}") if !@called
@called = true
return 0
else
raise RuntimeError, "[Win32API] [#{@dll}:#{@func}] #{args.to_s}"
end
end
end

45
shader/bicubic.frag Normal file
View file

@ -0,0 +1,45 @@
// From https://raw.githubusercontent.com/Sentmoraap/doing-sdl-right/f1a0183692abbd5d899fb432ab8dafe228a4929a/assets/bicubic.frag
// Copyright 2020 Lilian Gimenez (Sentmoraap).
// mkxp-z modifications Copyright 2022-2023 Splendide Imaginarius.
// MIT license.
#ifdef GLSLES
precision highp float;
#endif
uniform sampler2D texture;
uniform vec2 sourceSize;
uniform vec2 texSizeInv;
varying vec2 v_texCoord;
uniform vec2 bc;
void main()
{
vec2 pixel = v_texCoord * sourceSize + 0.5;
vec2 frac = fract(pixel);
vec2 frac2 = frac * frac;
vec2 frac3 = frac * frac2;
vec2 onePixel = texSizeInv;
pixel = floor(pixel) * texSizeInv - onePixel / 2.0;
vec4 colours[4];
// 16 reads, unoptimized but forks for every Mitchell-Netravali filter
for(int i = -1; i <= 2; i++)
{
vec4 p0 = texture2D(texture, pixel + vec2( -onePixel.x, float(i) * onePixel.y)).rgba;
vec4 p1 = texture2D(texture, pixel + vec2( 0, float(i) * onePixel.y)).rgba;
vec4 p2 = texture2D(texture, pixel + vec2( onePixel.x, float(i) * onePixel.y)).rgba;
vec4 p3 = texture2D(texture, pixel + vec2(2.0 * onePixel.x, float(i) * onePixel.y)).rgba;
colours[i + 1] = ((-bc.x / 6.0 - bc . y) * p0 + (- 1.5 * bc.x - bc.y + 2.0) * p1
+ (1.5 * bc.x + bc.y - 2.0) * p2 + (bc.x / 6.0 + bc.y) * p3) * frac3.x
+ ((0.5 * bc.x + 2.0 * bc.y) * p0 + (2.0 * bc.x + bc.y - 3.0) * p1
+ (-2.5 * bc.x - 2.0 * bc.y + 3.0) * p2 - bc.y * p3) * frac2.x
+ ((-0.5 * bc.x - bc.y) * p0 + (0.5 * bc.x + bc.y) * p2) * frac.x
+ p0 * bc.x / 6.0 + (-bc.x / 3.0 + 1.0) * p1 + p2 * bc.x / 6.0;
}
gl_FragColor = ((-bc.x / 6.0 - bc . y) * colours[0] + (- 1.5 * bc.x - bc.y + 2.0) * colours[1]
+ (1.5 * bc.x + bc.y - 2.0) * colours[2] + (bc.x / 6.0 + bc.y) * colours[3]) * frac3.y
+ ((0.5 * bc.x + 2.0 * bc.y) * colours[0] + (2.0 * bc.x + bc.y - 3.0) * colours[1]
+ (-2.5 * bc.x - 2.0 * bc.y + 3.0) * colours[2] - bc.y * colours[3]) * frac2.y
+ ((-0.5 * bc.x - bc.y) * colours[0] + (0.5 * bc.x + bc.y) * colours[2]) * frac.y
+ colours[0] * bc.x / 6.0 + (-bc.x / 3.0 + 1.0) * colours[1] + colours[2] * bc.x / 6.0;
}

View file

@ -1,6 +1,9 @@
#ifdef GLSLES
#ifdef FRAGMENT_SHADER
/* Only the fragment shader has no default float precision */
precision mediump float;
#endif
#else

View file

@ -1,7 +1,12 @@
// From https://raw.githubusercontent.com/Sentmoraap/doing-sdl-right/93a52a0db0ff2da5066cce12f5b9a2ac62e6f401/assets/lanczos3.frag
// Copyright 2020 Lilian Gimenez (Sentmoraap).
// mkxp-z modifications Copyright 2022-2023 Splendide Imaginarius.
// MIT license.
#ifdef GLSLES
precision highp float;
#endif
uniform sampler2D texture;
uniform vec2 sourceSize;
uniform vec2 texSizeInv;

View file

@ -15,6 +15,7 @@ embedded_shaders = [
'simpleAlphaUni.frag',
'tilemap.frag',
'flashMap.frag',
'bicubic.frag',
'lanczos3.frag',
'minimal.vert',
'simple.vert',

View file

@ -134,8 +134,12 @@ void Config::read(int argc, char *argv[]) {
{"winResizable", true},
{"fullscreen", false},
{"fixedAspectRatio", true},
{"smoothScaling", false},
{"lanczos3Scaling", false},
{"smoothScaling", 0},
{"bicubicSharpness", 100},
{"enableHires", false},
{"textureScalingFactor", 1.},
{"framebufferScalingFactor", 1.},
{"atlasScalingFactor", 1.},
{"vsync", false},
{"defScreenW", 0},
{"defScreenH", 0},
@ -174,9 +178,10 @@ void Config::read(int argc, char *argv[]) {
{"BGMTrackCount", 1},
{"customScript", ""},
{"pathCache", true},
{"useScriptNames", 1},
{"useScriptNames", true},
{"preloadScript", json::array({})},
{"RTP", json::array({})},
{"patches", json::array({})},
{"fontSub", json::array({})},
{"rubyLoadpath", json::array({})},
{"JITEnable", false},
@ -184,6 +189,7 @@ void Config::read(int argc, char *argv[]) {
{"JITMaxCache", 100},
{"JITMinCalls", 10000},
{"YJITEnable", false},
{"dumpAtlas", false},
{"bindingNames", json::object({
{"a", "A"},
{"b", "B"},
@ -259,8 +265,12 @@ try { exp } catch (...) {}
SET_OPT(printFPS, boolean);
SET_OPT(fullscreen, boolean);
SET_OPT(fixedAspectRatio, boolean);
SET_OPT(smoothScaling, boolean);
SET_OPT(lanczos3Scaling, boolean);
SET_OPT(smoothScaling, integer);
SET_OPT(bicubicSharpness, integer);
SET_OPT(enableHires, boolean);
SET_OPT(textureScalingFactor, number);
SET_OPT(framebufferScalingFactor, number);
SET_OPT(atlasScalingFactor, number);
SET_OPT(winResizable, boolean);
SET_OPT(vsync, boolean);
SET_STRINGOPT(windowTitle, windowTitle);
@ -268,6 +278,9 @@ try { exp } catch (...) {}
SET_OPT(frameSkip, boolean);
SET_OPT(syncToRefreshrate, boolean);
fillStringVec(opts["solidFonts"], solidFonts);
for (std::string & solidFont : solidFonts)
std::transform(solidFont.begin(), solidFont.end(), solidFont.begin(),
[](unsigned char c) { return std::tolower(c); });
#ifdef __APPLE__
SET_OPT(preferMetalRenderer, boolean);
#endif
@ -286,10 +299,15 @@ try { exp } catch (...) {}
SET_OPT_CUSTOMKEY(BGM.trackCount, BGMTrackCount, integer);
SET_STRINGOPT(customScript, customScript);
SET_OPT(useScriptNames, boolean);
SET_OPT(dumpAtlas, boolean);
fillStringVec(opts["preloadScript"], preloadScripts);
fillStringVec(opts["RTP"], rtps);
fillStringVec(opts["patches"], patches);
fillStringVec(opts["fontSub"], fontSubs);
for (std::string & fontSub : fontSubs)
std::transform(fontSub.begin(), fontSub.end(), fontSub.begin(),
[](unsigned char c) { return std::tolower(c); });
fillStringVec(opts["rubyLoadpath"], rubyLoadpaths);
auto &bnames = opts["bindingNames"].as_object();

View file

@ -43,8 +43,12 @@ struct Config {
bool winResizable;
bool fullscreen;
bool fixedAspectRatio;
bool smoothScaling;
bool lanczos3Scaling;
int smoothScaling;
int bicubicSharpness;
bool enableHires;
double textureScalingFactor;
double framebufferScalingFactor;
double atlasScalingFactor;
bool vsync;
int defScreenW;
@ -103,11 +107,12 @@ struct Config {
std::vector<std::string> launchArgs;
std::vector<std::string> preloadScripts;
std::vector<std::string> rtps;
std::vector<std::string> patches;
std::vector<std::string> fontSubs;
std::vector<std::string> rubyLoadpaths;
/* Editor flags */
struct {
bool debug;
@ -133,6 +138,8 @@ struct Config {
bool enabled;
} yjit;
bool dumpAtlas;
// Keybinding action name mappings
struct {
std::string a;

View file

@ -237,11 +237,19 @@ struct BitmapPrivate
* in the texture and blit to it directly, saving
* ourselves the expensive blending calculation */
pixman_region16_t tainted;
// For high-resolution texture replacement.
Bitmap *selfHires;
Bitmap *selfLores;
bool assumingRubyGC;
BitmapPrivate(Bitmap *self)
: self(self),
megaSurface(0),
surface(0)
selfHires(0),
selfLores(0),
surface(0),
assumingRubyGC(false)
{
format = SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
@ -326,16 +334,30 @@ struct BitmapPrivate
return result != PIXMAN_REGION_OUT;
}
void bindTexture(ShaderBase &shader)
void bindTexture(ShaderBase &shader, bool substituteLoresSize = true)
{
if (selfHires) {
selfHires->bindTex(shader);
return;
}
if (animation.enabled) {
if (selfLores) {
Debug() << "BUG: High-res BitmapPrivate bindTexture for animations not implemented";
}
TEXFBO cframe = animation.currentFrame();
TEX::bind(cframe.tex);
shader.setTexSize(Vec2i(cframe.width, cframe.height));
return;
}
TEX::bind(gl.tex);
shader.setTexSize(Vec2i(gl.width, gl.height));
if (selfLores && substituteLoresSize) {
shader.setTexSize(Vec2i(selfLores->width(), selfLores->height()));
}
else {
shader.setTexSize(Vec2i(gl.width, gl.height));
}
}
void bindFBO()
@ -468,6 +490,24 @@ struct BitmapOpenHandler : FileSystem::OpenHandler
Bitmap::Bitmap(const char *filename)
{
std::string hiresPrefix = "Hires/";
std::string filenameStd = filename;
Bitmap *hiresBitmap = nullptr;
// TODO: once C++20 is required, switch to filenameStd.starts_with(hiresPrefix)
if (shState->config().enableHires && filenameStd.compare(0, hiresPrefix.size(), hiresPrefix) != 0) {
// Look for a high-res version of the file.
std::string hiresFilename = hiresPrefix + filenameStd;
try {
hiresBitmap = new Bitmap(hiresFilename.c_str());
hiresBitmap->setLores(this);
}
catch (const Exception &e)
{
Debug() << "No high-res Bitmap found at" << hiresFilename;
hiresBitmap = nullptr;
}
}
BitmapOpenHandler handler;
shState->fileSystem().openRead(handler, filename);
@ -482,6 +522,8 @@ Bitmap::Bitmap(const char *filename)
if (handler.gif) {
p = new BitmapPrivate(this);
p->selfHires = hiresBitmap;
if (handler.gif->width >= (uint32_t)glState.caps.maxTexSize || handler.gif->height > (uint32_t)glState.caps.maxTexSize)
{
@ -510,6 +552,9 @@ Bitmap::Bitmap(const char *filename)
delete handler.gif_data;
p->gl = texfbo;
if (p->selfHires != nullptr) {
p->gl.selfHires = &p->selfHires->getGLTypes();
}
p->addTaintedArea(rect());
return;
}
@ -573,55 +618,36 @@ Bitmap::Bitmap(const char *filename)
p->addTaintedArea(rect());
return;
}
SDL_Surface *imgSurf = handler.surface;
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
if (imgSurf->w > glState.caps.maxTexSize || imgSurf->h > glState.caps.maxTexSize)
{
/* Mega surface */
p = new BitmapPrivate(this);
p->megaSurface = imgSurf;
SDL_SetSurfaceBlendMode(p->megaSurface, SDL_BLENDMODE_NONE);
}
else
{
/* Regular surface */
TEXFBO tex;
try
{
tex = shState->texPool().request(imgSurf->w, imgSurf->h);
}
catch (const Exception &e)
{
SDL_FreeSurface(imgSurf);
throw e;
}
p = new BitmapPrivate(this);
p->gl = tex;
TEX::bind(p->gl.tex);
TEX::uploadImage(p->gl.width, p->gl.height, imgSurf->pixels, GL_RGBA);
SDL_FreeSurface(imgSurf);
}
p->addTaintedArea(rect());
initFromSurface(imgSurf, hiresBitmap, true);
}
Bitmap::Bitmap(int width, int height)
Bitmap::Bitmap(int width, int height, bool isHires)
{
if (width <= 0 || height <= 0)
throw Exception(Exception::RGSSError, "failed to create bitmap");
Bitmap *hiresBitmap = nullptr;
if (shState->config().enableHires && !isHires) {
// Create a high-res version as well.
double scalingFactor = shState->config().textureScalingFactor;
int hiresWidth = (int)lround(scalingFactor * width);
int hiresHeight = (int)lround(scalingFactor * height);
hiresBitmap = new Bitmap(hiresWidth, hiresHeight, true);
hiresBitmap->setLores(this);
}
TEXFBO tex = shState->texPool().request(width, height);
p = new BitmapPrivate(this);
p->gl = tex;
p->selfHires = hiresBitmap;
if (p->selfHires != nullptr) {
p->gl.selfHires = &p->selfHires->getGLTypes();
}
clear();
}
@ -679,6 +705,10 @@ Bitmap::Bitmap(const Bitmap &other, int frame)
other.ensureNonMega();
if (frame > -2) other.ensureAnimated();
if (other.hasHires()) {
Debug() << "BUG: High-res Bitmap from animation not implemented";
}
p = new BitmapPrivate(this);
// TODO: Clean me up
@ -729,11 +759,104 @@ Bitmap::Bitmap(const Bitmap &other, int frame)
p->addTaintedArea(rect());
}
Bitmap::Bitmap(TEXFBO &other)
{
Bitmap *hiresBitmap = nullptr;
if (other.selfHires != nullptr) {
// Create a high-res version as well.
hiresBitmap = new Bitmap(*other.selfHires);
hiresBitmap->setLores(this);
}
p = new BitmapPrivate(this);
p->gl = shState->texPool().request(other.width, other.height);
p->selfHires = hiresBitmap;
if (p->selfHires != nullptr) {
p->gl.selfHires = &p->selfHires->getGLTypes();
}
// Skip blitting to lores texture, since only the hires one will be displayed.
if (p->selfHires == nullptr) {
GLMeta::blitBegin(p->gl);
GLMeta::blitSource(other);
GLMeta::blitRectangle(rect(), rect(), true);
GLMeta::blitEnd();
}
p->addTaintedArea(rect());
}
Bitmap::Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires)
{
Bitmap *hiresBitmap = nullptr;
if (imgSurfHires != nullptr) {
// Create a high-res version as well.
hiresBitmap = new Bitmap(imgSurfHires, nullptr);
hiresBitmap->setLores(this);
}
initFromSurface(imgSurf, hiresBitmap, false);
}
Bitmap::~Bitmap()
{
dispose();
}
void Bitmap::initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool freeSurface)
{
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
if (imgSurf->w > glState.caps.maxTexSize || imgSurf->h > glState.caps.maxTexSize)
{
/* Mega surface */
if(!freeSurface) {
throw Exception(Exception::RGSSError, "Cloning Mega Bitmap from Surface not supported");
}
p = new BitmapPrivate(this);
p->selfHires = hiresBitmap;
p->megaSurface = imgSurf;
SDL_SetSurfaceBlendMode(p->megaSurface, SDL_BLENDMODE_NONE);
}
else
{
/* Regular surface */
TEXFBO tex;
try
{
tex = shState->texPool().request(imgSurf->w, imgSurf->h);
}
catch (const Exception &e)
{
SDL_FreeSurface(imgSurf);
throw e;
}
p = new BitmapPrivate(this);
p->selfHires = hiresBitmap;
p->gl = tex;
if (p->selfHires != nullptr) {
p->gl.selfHires = &p->selfHires->getGLTypes();
}
TEX::bind(p->gl.tex);
TEX::uploadImage(p->gl.width, p->gl.height, imgSurf->pixels, GL_RGBA);
if (freeSurface) {
SDL_FreeSurface(imgSurf);
}
}
p->addTaintedArea(rect());
}
int Bitmap::width() const
{
guardDisposed();
@ -762,6 +885,28 @@ int Bitmap::height() const
return p->gl.height;
}
bool Bitmap::hasHires() const{
guardDisposed();
return p->selfHires;
}
DEF_ATTR_RD_SIMPLE(Bitmap, Hires, Bitmap*, p->selfHires)
void Bitmap::setHires(Bitmap *hires) {
guardDisposed();
Debug() << "BUG: High-res Bitmap setHires not fully implemented, expect bugs";
hires->setLores(this);
p->selfHires = hires;
}
void Bitmap::setLores(Bitmap *lores) {
guardDisposed();
p->selfLores = lores;
}
bool Bitmap::isMega() const{
guardDisposed();
@ -809,13 +954,35 @@ void Bitmap::stretchBlt(const IntRect &destRect,
int opacity)
{
guardDisposed();
// Don't need this, right? This function is fine with megasurfaces it seems
//GUARD_MEGA;
if (source.isDisposed())
return;
if (hasHires()) {
int destX, destY, destWidth, destHeight;
destX = destRect.x * p->selfHires->width() / width();
destY = destRect.y * p->selfHires->height() / height();
destWidth = destRect.w * p->selfHires->width() / width();
destHeight = destRect.h * p->selfHires->height() / height();
p->selfHires->stretchBlt(IntRect(destX, destY, destWidth, destHeight), source, sourceRect, opacity);
return;
}
if (source.hasHires()) {
int sourceX, sourceY, sourceWidth, sourceHeight;
sourceX = sourceRect.x * source.getHires()->width() / source.width();
sourceY = sourceRect.y * source.getHires()->height() / source.height();
sourceWidth = sourceRect.w * source.getHires()->width() / source.width();
sourceHeight = sourceRect.h * source.getHires()->height() / source.height();
stretchBlt(destRect, *source.getHires(), IntRect(sourceX, sourceY, sourceWidth, sourceHeight), opacity);
return;
}
opacity = clamp(opacity, 0, 255);
if (opacity == 0)
@ -936,7 +1103,7 @@ void Bitmap::stretchBlt(const IntRect &destRect,
quad.setTexPosRect(sourceRect, destRect);
quad.setColor(Vec4(1, 1, 1, normOpacity));
source.p->bindTexture(shader);
source.p->bindTexture(shader, false);
p->bindFBO();
p->pushSetViewport(shader);
@ -963,6 +1130,16 @@ void Bitmap::fillRect(const IntRect &rect, const Vec4 &color)
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
int destX, destY, destWidth, destHeight;
destX = rect.x * p->selfHires->width() / width();
destY = rect.y * p->selfHires->height() / height();
destWidth = rect.w * p->selfHires->width() / width();
destHeight = rect.h * p->selfHires->height() / height();
p->selfHires->fillRect(IntRect(destX, destY, destWidth, destHeight), color);
}
p->fillRect(rect, color);
if (color.w == 0)
@ -992,6 +1169,16 @@ void Bitmap::gradientFillRect(const IntRect &rect,
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
int destX, destY, destWidth, destHeight;
destX = rect.x * p->selfHires->width() / width();
destY = rect.y * p->selfHires->height() / height();
destWidth = rect.w * p->selfHires->width() / width();
destHeight = rect.h * p->selfHires->height() / height();
p->selfHires->gradientFillRect(IntRect(destX, destY, destWidth, destHeight), color1, color2, vertical);
}
SimpleColorShader &shader = shState->shaders().simpleColor;
shader.bind();
shader.setTranslation(Vec2i());
@ -1039,6 +1226,16 @@ void Bitmap::clearRect(const IntRect &rect)
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
int destX, destY, destWidth, destHeight;
destX = rect.x * p->selfHires->width() / width();
destY = rect.y * p->selfHires->height() / height();
destWidth = rect.w * p->selfHires->width() / width();
destHeight = rect.h * p->selfHires->height() / height();
p->selfHires->clearRect(IntRect(destX, destY, destWidth, destHeight));
}
p->fillRect(rect, Vec4());
p->onModified();
@ -1051,6 +1248,12 @@ void Bitmap::blur()
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
p->selfHires->blur();
}
// TODO: Is there some kind of blur radius that we need to handle for high-res mode?
Quad &quad = shState->gpQuad();
FloatRect rect(0, 0, width(), height());
quad.setTexPosRect(rect, rect);
@ -1097,6 +1300,11 @@ void Bitmap::radialBlur(int angle, int divisions)
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
p->selfHires->radialBlur(angle, divisions);
return;
}
angle = clamp<int>(angle, 0, 359);
divisions = clamp<int>(divisions, 2, 100);
@ -1161,7 +1369,7 @@ void Bitmap::radialBlur(int angle, int divisions)
SimpleMatrixShader &shader = shState->shaders().simpleMatrix;
shader.bind();
p->bindTexture(shader);
p->bindTexture(shader, false);
TEX::setSmooth(true);
p->pushSetViewport(shader);
@ -1193,6 +1401,10 @@ void Bitmap::clear()
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
p->selfHires->clear();
}
p->bindFBO();
glState.clearColor.pushSet(Vec4());
@ -1221,9 +1433,52 @@ Color Bitmap::getPixel(int x, int y) const
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
Debug() << "GAME BUG: Game is calling getPixel on low-res Bitmap; you may want to patch the game to improve graphics quality.";
int xHires = x * p->selfHires->width() / width();
int yHires = y * p->selfHires->height() / height();
// We take the average color from the high-res Bitmap.
// RGB channels skip fully transparent pixels when averaging.
int w = p->selfHires->width() / width();
int h = p->selfHires->height() / height();
if (w >= 1 && h >= 1) {
double rSum = 0.;
double gSum = 0.;
double bSum = 0.;
double aSum = 0.;
long long rgbCount = 0;
long long aCount = 0;
for (int thisX = xHires; thisX < xHires+w && thisX < p->selfHires->width(); thisX++) {
for (int thisY = yHires; thisY < yHires+h && thisY < p->selfHires->height(); thisY++) {
Color thisColor = p->selfHires->getPixel(thisX, thisY);
if (thisColor.getAlpha() >= 1.0) {
rSum += thisColor.getRed();
gSum += thisColor.getGreen();
bSum += thisColor.getBlue();
rgbCount++;
}
aSum += thisColor.getAlpha();
aCount++;
}
}
double rAvg = rSum / (double)rgbCount;
double gAvg = gSum / (double)rgbCount;
double bAvg = bSum / (double)rgbCount;
double aAvg = aSum / (double)aCount;
return Color(rAvg, gAvg, bAvg, aAvg);
}
}
if (x < 0 || y < 0 || x >= width() || y >= height())
return Vec4();
if (!p->surface)
{
p->allocSurface();
@ -1252,6 +1507,24 @@ void Bitmap::setPixel(int x, int y, const Color &color)
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
Debug() << "GAME BUG: Game is calling setPixel on low-res Bitmap; you may want to patch the game to improve graphics quality.";
int xHires = x * p->selfHires->width() / width();
int yHires = y * p->selfHires->height() / height();
int w = p->selfHires->width() / width();
int h = p->selfHires->height() / height();
if (w >= 1 && h >= 1) {
for (int thisX = xHires; thisX < xHires+w && thisX < p->selfHires->width(); thisX++) {
for (int thisY = yHires; thisY < yHires+h && thisY < p->selfHires->height(); thisY++) {
p->selfHires->setPixel(thisX, thisY, color);
}
}
}
}
uint8_t pixel[] =
{
(uint8_t) clamp<double>(color.red, 0, 255),
@ -1283,6 +1556,10 @@ bool Bitmap::getRaw(void *output, int output_size)
guardDisposed();
if (hasHires()) {
Debug() << "GAME BUG: Game is calling getRaw on low-res Bitmap; you may want to patch the game to improve graphics quality.";
}
if (!p->animation.enabled && (p->surface || p->megaSurface)) {
void *src = (p->megaSurface) ? p->megaSurface->pixels : p->surface->pixels;
memcpy(output, src, output_size);
@ -1300,6 +1577,10 @@ void Bitmap::replaceRaw(void *pixel_data, int size)
GUARD_MEGA;
if (hasHires()) {
Debug() << "GAME BUG: Game is calling replaceRaw on low-res Bitmap; you may want to patch the game to improve graphics quality.";
}
int w = width();
int h = height();
int requiredsize = w*h*4;
@ -1318,6 +1599,10 @@ void Bitmap::saveToFile(const char *filename)
{
guardDisposed();
if (hasHires()) {
Debug() << "GAME BUG: Game is calling saveToFile on low-res Bitmap; you may want to patch the game to improve graphics quality.";
}
SDL_Surface *surf;
if (p->surface || p->megaSurface) {
@ -1377,6 +1662,11 @@ void Bitmap::hueChange(int hue)
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
p->selfHires->hueChange(hue);
return;
}
if ((hue % 360) == 0)
return;
@ -1395,7 +1685,7 @@ void Bitmap::hueChange(int hue)
FBO::bind(newTex.fbo);
p->pushSetViewport(shader);
p->bindTexture(shader);
p->bindTexture(shader, false);
p->blitQuad(quad);
@ -1525,6 +1815,26 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
GUARD_MEGA;
GUARD_ANIMATED;
if (hasHires()) {
Font &loresFont = getFont();
Font &hiresFont = p->selfHires->getFont();
// Disable the illegal font size check when creating a high-res font.
hiresFont.setSize(loresFont.getSize() * p->selfHires->width() / width(), false);
hiresFont.setBold(loresFont.getBold());
hiresFont.setColor(loresFont.getColor());
hiresFont.setItalic(loresFont.getItalic());
hiresFont.setShadow(loresFont.getShadow());
hiresFont.setOutline(loresFont.getOutline());
hiresFont.setOutColor(loresFont.getOutColor());
int rectX = rect.x * p->selfHires->width() / width();
int rectY = rect.y * p->selfHires->height() / height();
int rectWidth = rect.w * p->selfHires->width() / width();
int rectHeight = rect.h * p->selfHires->height() / height();
p->selfHires->drawText(IntRect(rectX, rectY, rectWidth, rectHeight), str, align);
}
std::string fixed = fixupString(str);
str = fixed.c_str();
@ -1564,15 +1874,20 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
SDL_Color co = outColor.toSDLColor();
co.a = 255;
SDL_Surface *outline;
// Handle high-res for outline.
int scaledOutlineSize = OUTLINE_SIZE;
if (p->selfLores) {
scaledOutlineSize = scaledOutlineSize * width() / p->selfLores->width();
}
/* set the next font render to render the outline */
TTF_SetFontOutline(font, OUTLINE_SIZE);
TTF_SetFontOutline(font, scaledOutlineSize);
if (p->font->isSolid())
outline = TTF_RenderUTF8_Solid(font, str, co);
else
outline = TTF_RenderUTF8_Blended(font, str, co);
p->ensureFormat(outline, SDL_PIXELFORMAT_ABGR8888);
SDL_Rect outRect = {OUTLINE_SIZE, OUTLINE_SIZE, txtSurf->w, txtSurf->h};
SDL_Rect outRect = {scaledOutlineSize, scaledOutlineSize, txtSurf->w, txtSurf->h};
SDL_SetSurfaceBlendMode(txtSurf, SDL_BLENDMODE_BLEND);
SDL_BlitSurface(txtSurf, NULL, outline, &outRect);
@ -1787,6 +2102,9 @@ IntRect Bitmap::textSize(const char *str)
GUARD_MEGA;
GUARD_ANIMATED;
// TODO: High-res Bitmap textSize not implemented, but I think it's the same as low-res?
// Need to double-check this.
TTF_Font *font = p->font->getSdlFont();
std::string fixed = fixupString(str);
@ -1811,11 +2129,19 @@ DEF_ATTR_RD_SIMPLE(Bitmap, Font, Font&, *p->font)
void Bitmap::setFont(Font &value)
{
// High-res support handled in drawText, not here.
*p->font = value;
}
void Bitmap::setInitFont(Font *value)
{
if (hasHires()) {
Font *hiresFont = new Font(*value);
// Disable the illegal font size check when creating a high-res font.
hiresFont->setSize(hiresFont->getSize() * p->selfHires->width() / width(), false);
p->selfHires->setInitFont(hiresFont);
}
p->font = value;
}
@ -1826,11 +2152,24 @@ TEXFBO &Bitmap::getGLTypes() const
SDL_Surface *Bitmap::surface() const
{
if (hasHires()) {
Debug() << "BUG: High-res Bitmap surface not implemented";
}
return p->surface;
}
SDL_Surface *Bitmap::megaSurface() const
{
if (hasHires()) {
if (p->megaSurface) {
Debug() << "BUG: High-res Bitmap megaSurface not implemented (low-res has megaSurface)";
}
if (p->selfHires->megaSurface()) {
Debug() << "BUG: High-res Bitmap megaSurface not implemented (high-res has megaSurface)";
}
}
return p->megaSurface;
}
@ -1865,6 +2204,10 @@ void Bitmap::stop()
GUARD_UNANIMATED;
if (!p->animation.playing) return;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap stop not implemented";
}
p->animation.stop();
}
@ -1874,6 +2217,11 @@ void Bitmap::play()
GUARD_UNANIMATED;
if (p->animation.playing) return;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap play not implemented";
}
p->animation.play();
}
@ -1881,6 +2229,10 @@ bool Bitmap::isPlaying() const
{
guardDisposed();
if (hasHires()) {
Debug() << "BUG: High-res Bitmap isPlaying not implemented";
}
if (!p->animation.playing)
return false;
@ -1896,6 +2248,10 @@ void Bitmap::gotoAndStop(int frame)
GUARD_UNANIMATED;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap gotoAndStop not implemented";
}
p->animation.stop();
p->animation.seek(frame);
}
@ -1905,6 +2261,10 @@ void Bitmap::gotoAndPlay(int frame)
GUARD_UNANIMATED;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap gotoAndPlay not implemented";
}
p->animation.stop();
p->animation.seek(frame);
p->animation.play();
@ -1914,6 +2274,10 @@ int Bitmap::numFrames() const
{
guardDisposed();
if (hasHires()) {
Debug() << "BUG: High-res Bitmap numFrames not implemented";
}
if (!p->animation.enabled) return 1;
return (int)p->animation.frames.size();
}
@ -1922,6 +2286,10 @@ int Bitmap::currentFrameI() const
{
guardDisposed();
if (hasHires()) {
Debug() << "BUG: High-res Bitmap currentFrameI not implemented";
}
if (!p->animation.enabled) return 0;
return p->animation.currentFrameI();
}
@ -1932,6 +2300,14 @@ int Bitmap::addFrame(Bitmap &source, int position)
GUARD_MEGA;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap addFrame dest not implemented";
}
if (source.hasHires()) {
Debug() << "BUG: High-res Bitmap addFrame source not implemented";
}
if (source.height() != height() || source.width() != width())
throw Exception(Exception::MKXPError, "Animations with varying dimensions are not supported (%ix%i vs %ix%i)",
source.width(), source.height(), width(), height());
@ -1989,6 +2365,10 @@ void Bitmap::removeFrame(int position) {
GUARD_UNANIMATED;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap removeFrame not implemented";
}
int pos = (position < 0) ? (int)p->animation.frames.size() - 1 : clamp(position, 0, (int)(p->animation.frames.size() - 1));
shState->texPool().release(p->animation.frames[pos]);
p->animation.frames.erase(p->animation.frames.begin() + pos);
@ -2016,6 +2396,10 @@ void Bitmap::nextFrame()
GUARD_UNANIMATED;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap nextFrame not implemented";
}
stop();
if ((uint32_t)p->animation.lastFrame >= p->animation.frames.size() - 1) {
if (!p->animation.loop) return;
@ -2032,6 +2416,10 @@ void Bitmap::previousFrame()
GUARD_UNANIMATED;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap previousFrame not implemented";
}
stop();
if (p->animation.lastFrame <= 0) {
if (!p->animation.loop) {
@ -2051,6 +2439,10 @@ void Bitmap::setAnimationFPS(float FPS)
GUARD_MEGA;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap setAnimationFPS not implemented";
}
bool restart = p->animation.playing;
p->animation.stop();
p->animation.fps = (FPS < 0) ? 0 : FPS;
@ -2059,6 +2451,10 @@ void Bitmap::setAnimationFPS(float FPS)
std::vector<TEXFBO> &Bitmap::getFrames() const
{
if (hasHires()) {
Debug() << "BUG: High-res Bitmap getFrames not implemented";
}
return p->animation.frames;
}
@ -2068,6 +2464,10 @@ float Bitmap::getAnimationFPS() const
GUARD_MEGA;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap getAnimationFPS not implemented";
}
return p->animation.fps;
}
@ -2077,6 +2477,10 @@ void Bitmap::setLooping(bool loop)
GUARD_MEGA;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap setLooping not implemented";
}
p->animation.loop = loop;
}
@ -2086,16 +2490,32 @@ bool Bitmap::getLooping() const
GUARD_MEGA;
if (hasHires()) {
Debug() << "BUG: High-res Bitmap getLooping not implemented";
}
return p->animation.loop;
}
void Bitmap::bindTex(ShaderBase &shader)
{
// Hires mode is handled by p->bindTexture.
p->bindTexture(shader);
}
void Bitmap::taintArea(const IntRect &rect)
{
if (hasHires()) {
int destX, destY, destWidth, destHeight;
destX = rect.x * p->selfHires->width() / width();
destY = rect.y * p->selfHires->height() / height();
destWidth = rect.w * p->selfHires->width() / width();
destHeight = rect.h * p->selfHires->height() / height();
p->selfHires->taintArea(IntRect(destX, destY, destWidth, destHeight));
}
p->addTaintedArea(rect);
}
@ -2121,8 +2541,17 @@ bool Bitmap::invalid() const {
return p == 0;
}
void Bitmap::assumeRubyGC()
{
p->assumingRubyGC = true;
}
void Bitmap::releaseResources()
{
if (p->selfHires && !p->assumingRubyGC) {
delete p->selfHires;
}
if (p->megaSurface)
SDL_FreeSurface(p->megaSurface);
else if (p->animation.enabled) {

View file

@ -39,16 +39,24 @@ class Bitmap : public Disposable
{
public:
Bitmap(const char *filename);
Bitmap(int width, int height);
Bitmap(void *pixeldata, int width, int height);
Bitmap(int width, int height, bool isHires = false);
Bitmap(void *pixeldata, int width, int height);
Bitmap(TEXFBO &other);
Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires);
/* Clone constructor */
// frame is -2 for "any and all", -1 for "current", anything else for a specific frame
Bitmap(const Bitmap &other, int frame = -2);
~Bitmap();
void initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool freeSurface);
int width() const;
int height() const;
bool hasHires() const;
DECL_ATTR(Hires, Bitmap*)
void setLores(Bitmap *lores);
bool isMega() const;
bool isAnimated() const;
@ -161,6 +169,8 @@ public:
bool invalid() const;
void assumeRubyGC();
private:
void releaseResources();
const char *klassName() const { return "bitmap"; }

View file

@ -28,8 +28,12 @@
#include "util.h"
#include "config.h"
#include "debugwriter.h"
#include <string>
#include <utility>
#include <algorithm>
#include <cctype>
#ifdef MKXPZ_BUILD_XCODE
#include "filesystem/filesystem.h"
@ -147,6 +151,9 @@ void SharedFontState::initFontSetCB(SDL_RWops &ops,
std::string family = TTF_FontFaceFamilyName(font);
std::string style = TTF_FontFaceStyleName(font);
std::transform(family.begin(), family.end(), family.begin(),
[](unsigned char c){ return std::tolower(c); });
TTF_CloseFont(font);
FontSet &set = p->sets[family];
@ -160,6 +167,9 @@ void SharedFontState::initFontSetCB(SDL_RWops &ops,
_TTF_Font *SharedFontState::getFont(std::string family,
int size)
{
std::transform(family.begin(), family.end(), family.begin(),
[](unsigned char c){ return std::tolower(c); });
if (family.empty())
family = p->defaultFamily;
@ -217,6 +227,9 @@ _TTF_Font *SharedFontState::getFont(std::string family,
bool SharedFontState::fontPresent(std::string family) const
{
std::transform(family.begin(), family.end(), family.begin(),
[](unsigned char c){ return std::tolower(c); });
/* Check for substitutions */
if (p->subs.contains(family))
family = p->subs[family];
@ -252,6 +265,17 @@ void pickExistingFontName(const std::vector<std::string> &names,
out = names[i];
return;
}
else
{
if (i == 0)
{
Debug() << "Primary font not found:" << names[i];
}
else
{
Debug() << "Fallback font not found:" << names[i];
}
}
}
out = "";
@ -399,14 +423,17 @@ void Font::setName(const std::vector<std::string> &names)
p->sdlFont = 0;
}
void Font::setSize(int value)
void Font::setSize(int value, bool checkIllegal)
{
if (p->size == value)
return;
/* Catch illegal values (according to RMXP) */
if (value < 6 || value > 96)
throw Exception(Exception::ArgumentError, "%s", "bad value for size");
if (value < 6 || value > 96) {
if (checkIllegal) {
throw Exception(Exception::ArgumentError, "%s", "bad value for size");
}
}
p->size = value;
p->sdlFont = 0;

View file

@ -76,7 +76,9 @@ public:
const Font &operator=(const Font &o);
DECL_ATTR( Size, int )
int getSize() const;
void setSize(int value, bool checkIllegal=true);
DECL_ATTR( Bold, bool )
DECL_ATTR( Italic, bool )
DECL_ATTR( Color, Color& )

View file

@ -25,6 +25,12 @@
#include "glstate.h"
#include "quad.h"
#include "config.h"
#include "etc.h"
namespace FBO
{
ID boundFramebufferID;
}
namespace GLMeta
{
@ -138,6 +144,7 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
{
if (HAVE_NATIVE_BLIT)
{
FBO::boundFramebufferID = fbo;
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo.gl);
}
else
@ -145,7 +152,20 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
FBO::bind(fbo);
glState.viewport.pushSet(IntRect(0, 0, size.x, size.y));
if (shState->config().lanczos3Scaling)
switch (shState->config().smoothScaling)
{
case Bicubic:
{
BicubicShader &shader = shState->shaders().bicubic;
shader.bind();
shader.applyViewportProj();
shader.setTranslation(Vec2i());
shader.setTexSize(Vec2i(size.x, size.y));
shader.setSharpness(shState->config().bicubicSharpness);
}
break;
case Lanczos3:
{
Lanczos3Shader &shader = shState->shaders().lanczos3;
shader.bind();
@ -153,7 +173,9 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
shader.setTranslation(Vec2i());
shader.setTexSize(Vec2i(size.x, size.y));
}
else
break;
default:
{
SimpleShader &shader = shState->shaders().simple;
shader.bind();
@ -161,40 +183,97 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
shader.setTranslation(Vec2i());
shader.setTexSize(Vec2i(size.x, size.y));
}
}
}
}
void blitBegin(TEXFBO &target)
int blitDstWidthLores = 1;
int blitDstWidthHires = 1;
int blitDstHeightLores = 1;
int blitDstHeightHires = 1;
int blitSrcWidthLores = 1;
int blitSrcWidthHires = 1;
int blitSrcHeightLores = 1;
int blitSrcHeightHires = 1;
void blitBegin(TEXFBO &target, bool preferHires)
{
_blitBegin(target.fbo, Vec2i(target.width, target.height));
blitDstWidthLores = target.width;
blitDstHeightLores = target.height;
if (preferHires && target.selfHires != nullptr) {
blitDstWidthHires = target.selfHires->width;
blitDstHeightHires = target.selfHires->height;
_blitBegin(target.selfHires->fbo, Vec2i(target.selfHires->width, target.selfHires->height));
}
else {
blitDstWidthHires = blitDstWidthLores;
blitDstHeightHires = blitDstHeightLores;
_blitBegin(target.fbo, Vec2i(target.width, target.height));
}
}
void blitBeginScreen(const Vec2i &size)
{
blitDstWidthLores = 1;
blitDstWidthHires = 1;
blitDstHeightLores = 1;
blitDstHeightHires = 1;
_blitBegin(FBO::ID(0), size);
}
void blitSource(TEXFBO &source)
{
blitSrcWidthLores = source.width;
blitSrcHeightLores = source.height;
if (source.selfHires != nullptr) {
blitSrcWidthHires = source.selfHires->width;
blitSrcHeightHires = source.selfHires->height;
}
else {
blitSrcWidthHires = blitSrcWidthLores;
blitSrcHeightHires = blitSrcHeightLores;
}
if (HAVE_NATIVE_BLIT)
{
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, source.fbo.gl);
}
else
{
if (shState->config().lanczos3Scaling)
switch (shState->config().smoothScaling)
{
case Bicubic:
{
BicubicShader &shader = shState->shaders().bicubic;
shader.bind();
shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires));
}
break;
case Lanczos3:
{
Lanczos3Shader &shader = shState->shaders().lanczos3;
shader.bind();
shader.setTexSize(Vec2i(source.width, source.height));
shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires));
}
else
break;
default:
{
SimpleShader &shader = shState->shaders().simple;
shader.bind();
shader.setTexSize(Vec2i(source.width, source.height));
shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires));
}
}
if (source.selfHires != nullptr) {
TEX::bind(source.selfHires->tex);
}
else {
TEX::bind(source.tex);
}
TEX::bind(source.tex);
}
}
@ -205,10 +284,24 @@ void blitRectangle(const IntRect &src, const Vec2i &dstPos)
void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
{
// Handle high-res dest
int scaledDstX = dst.x * blitDstWidthHires / blitDstWidthLores;
int scaledDstY = dst.y * blitDstHeightHires / blitDstHeightLores;
int scaledDstWidth = dst.w * blitDstWidthHires / blitDstWidthLores;
int scaledDstHeight = dst.h * blitDstHeightHires / blitDstHeightLores;
IntRect dstScaled(scaledDstX, scaledDstY, scaledDstWidth, scaledDstHeight);
// Handle high-res source
int scaledSrcX = src.x * blitSrcWidthHires / blitSrcWidthLores;
int scaledSrcY = src.y * blitSrcHeightHires / blitSrcHeightLores;
int scaledSrcWidth = src.w * blitSrcWidthHires / blitSrcWidthLores;
int scaledSrcHeight = src.h * blitSrcHeightHires / blitSrcHeightLores;
IntRect srcScaled(scaledSrcX, scaledSrcY, scaledSrcWidth, scaledSrcHeight);
if (HAVE_NATIVE_BLIT)
{
gl.BlitFramebuffer(src.x, src.y, src.x+src.w, src.y+src.h,
dst.x, dst.y, dst.x+dst.w, dst.y+dst.h,
gl.BlitFramebuffer(srcScaled.x, srcScaled.y, srcScaled.x+srcScaled.w, srcScaled.y+srcScaled.h,
dstScaled.x, dstScaled.y, dstScaled.x+dstScaled.w, dstScaled.y+dstScaled.h,
GL_COLOR_BUFFER_BIT, smooth ? GL_LINEAR : GL_NEAREST);
}
else
@ -218,7 +311,7 @@ void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
glState.blend.pushSet(false);
Quad &quad = shState->gpQuad();
quad.setTexPosRect(src, dst);
quad.setTexPosRect(srcScaled, dstScaled);
quad.draw();
glState.blend.pop();
@ -229,8 +322,19 @@ void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
void blitEnd()
{
if (!HAVE_NATIVE_BLIT)
blitDstWidthLores = 1;
blitDstWidthHires = 1;
blitDstHeightLores = 1;
blitDstHeightHires = 1;
blitSrcWidthLores = 1;
blitSrcWidthHires = 1;
blitSrcHeightLores = 1;
blitSrcHeightHires = 1;
if (!HAVE_NATIVE_BLIT) {
glState.viewport.pop();
}
}
}

View file

@ -65,7 +65,7 @@ void vaoBind(VAO &vao);
void vaoUnbind(VAO &vao);
/* EXT_framebuffer_blit */
void blitBegin(TEXFBO &target);
void blitBegin(TEXFBO &target, bool preferHires = false);
void blitBeginScreen(const Vec2i &size);
void blitSource(TEXFBO &source);
void blitRectangle(const IntRect &src, const Vec2i &dstPos);

View file

@ -109,6 +109,8 @@ namespace FBO
{
DEF_GL_ID
extern ID boundFramebufferID;
inline ID gen()
{
ID id;
@ -124,6 +126,7 @@ namespace FBO
static inline void bind(ID id)
{
boundFramebufferID = id;
gl.BindFramebuffer(GL_FRAMEBUFFER, id.gl);
}
@ -203,8 +206,10 @@ struct TEXFBO
FBO::ID fbo;
int width, height;
TEXFBO *selfHires;
TEXFBO()
: tex(0), fbo(0), width(0), height(0)
: tex(0), fbo(0), width(0), height(0), selfHires(nullptr)
{}
bool operator==(const TEXFBO &other) const

View file

@ -23,7 +23,9 @@
#include "config.h"
#include "etc.h"
#include "gl-fun.h"
#include "graphics.h"
#include "shader.h"
#include "sharedstate.h"
#include <SDL_rect.h>
@ -36,7 +38,19 @@ void GLClearColor::apply(const Vec4 &value) {
}
void GLScissorBox::apply(const IntRect &value) {
gl.Scissor(value.x, value.y, value.w, value.h);
// High-res: scale the scissorbox if we're rendering to the PingPong framebuffer.
if (shState) {
const double framebufferScalingFactor = shState->config().framebufferScalingFactor;
if (shState->config().enableHires && shState->graphics().isPingPongFramebufferActive()) {
gl.Scissor((int)lround(framebufferScalingFactor * value.x), (int)lround(framebufferScalingFactor * value.y), (int)lround(framebufferScalingFactor * value.w), (int)lround(framebufferScalingFactor * value.h));
}
else {
gl.Scissor(value.x, value.y, value.w, value.h);
}
}
else {
gl.Scissor(value.x, value.y, value.w, value.h);
}
}
void GLScissorBox::setIntersect(const IntRect &value) {

View file

@ -22,6 +22,8 @@
#ifndef QUAD_H
#define QUAD_H
#include "config.h"
#include "graphics.h"
#include "vertex.h"
#include "gl-util.h"
#include "gl-meta.h"

View file

@ -20,6 +20,8 @@
*/
#include "shader.h"
#include "config.h"
#include "graphics.h"
#include "sharedstate.h"
#include "glstate.h"
#include "exception.h"
@ -44,6 +46,7 @@
#include "simpleAlphaUni.frag.xxd"
#include "tilemap.frag.xxd"
#include "flashMap.frag.xxd"
#include "bicubic.frag.xxd"
#include "lanczos3.frag.xxd"
#include "minimal.vert.xxd"
#include "simple.vert.xxd"
@ -293,8 +296,19 @@ void ShaderBase::init()
void ShaderBase::applyViewportProj()
{
// High-res: scale the matrix if we're rendering to the PingPong framebuffer.
const IntRect &vp = glState.viewport.get();
projMat.set(Vec2i(vp.w, vp.h));
if (shState->config().enableHires && shState->graphics().isPingPongFramebufferActive() && framebufferScalingAllowed()) {
projMat.set(Vec2i(shState->graphics().width(), shState->graphics().height()));
}
else {
projMat.set(Vec2i(vp.w, vp.h));
}
}
bool ShaderBase::framebufferScalingAllowed()
{
return true;
}
void ShaderBase::setTexSize(const Vec2i &value)
@ -593,6 +607,13 @@ GrayShader::GrayShader()
GET_U(gray);
}
bool GrayShader::framebufferScalingAllowed()
{
// This shader is used with input textures that have already had a
// framebuffer scale applied. So we don't want to double-apply it.
return false;
}
void GrayShader::setGray(float value)
{
gl.Uniform1f(u_gray, value);
@ -747,6 +768,22 @@ void BltShader::setOpacity(float value)
gl.Uniform1f(u_opacity, value);
}
BicubicShader::BicubicShader()
{
INIT_SHADER(simple, bicubic, BicubicShader);
ShaderBase::init();
GET_U(texOffsetX);
GET_U(sourceSize);
GET_U(bc);
}
void BicubicShader::setSharpness(int sharpness)
{
gl.Uniform2f(u_bc, 1.f - sharpness * 0.01f, sharpness * 0.005f);
}
Lanczos3Shader::Lanczos3Shader()
{
INIT_SHADER(simple, lanczos3, Lanczos3Shader);

View file

@ -91,6 +91,7 @@ public:
protected:
void init();
virtual bool framebufferScalingAllowed();
GLint u_texSizeInv, u_translation;
};
@ -226,6 +227,9 @@ public:
void setGray(float value);
protected:
virtual bool framebufferScalingAllowed();
private:
GLint u_gray;
};
@ -337,6 +341,17 @@ protected:
GLint u_sourceSize;
};
class BicubicShader : public Lanczos3Shader
{
public:
BicubicShader();
void setSharpness(int sharpness);
protected:
GLint u_bc;
};
/* Global object containing all available shaders */
struct ShaderSet
{
@ -358,6 +373,7 @@ struct ShaderSet
SimpleMatrixShader simpleMatrix;
BlurShader blur;
TilemapVXShader tilemapVX;
BicubicShader bicubic;
Lanczos3Shader lanczos3;
};

View file

@ -24,6 +24,7 @@
#include "tilemap-common.h"
#include "bitmap.h"
#include "table.h"
#include "debugwriter.h"
#include "etc-internal.h"
#include "gl-util.h"
#include "gl-meta.h"
@ -273,7 +274,7 @@ void build(TEXFBO &tf, Bitmap *bitmaps[BM_COUNT])
{
assert(tf.width == ATLASVX_W && tf.height == ATLASVX_H);
GLMeta::blitBegin(tf);
GLMeta::blitBegin(tf, true);
glState.clearColor.pushSet(Vec4());
FBO::clear();
@ -282,13 +283,36 @@ void build(TEXFBO &tf, Bitmap *bitmaps[BM_COUNT])
if (rgssVer >= 3)
{
SDL_Surface *shadow = createShadowSet();
TEX::bind(tf.tex);
TEX::uploadSubImage(shadowArea.x*32, shadowArea.y*32,
shadow->w, shadow->h, shadow->pixels, GL_RGBA);
if (tf.selfHires != nullptr) {
SDL_Rect srcRect({0, 0, shadow->w, shadow->h});
int destX = shadowArea.x*32 * tf.selfHires->width / tf.width;
int destY = shadowArea.y*32 * tf.selfHires->height / tf.height;
int destWidth = shadow->w * tf.selfHires->width / tf.width;
int destHeight = shadow->h * tf.selfHires->height / tf.height;
int bpp;
Uint32 rMask, gMask, bMask, aMask;
SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ABGR8888,
&bpp, &rMask, &gMask, &bMask, &aMask);
SDL_Surface *blitTemp =
SDL_CreateRGBSurface(0, destWidth, destHeight, bpp, rMask, gMask, bMask, aMask);
SDL_BlitScaled(shadow, &srcRect, blitTemp, 0);
TEX::bind(tf.selfHires->tex);
TEX::uploadSubImage(destX, destY,
blitTemp->w, blitTemp->h, blitTemp->pixels, GL_RGBA);
}
else {
TEX::bind(tf.tex);
TEX::uploadSubImage(shadowArea.x*32, shadowArea.y*32,
shadow->w, shadow->h, shadow->pixels, GL_RGBA);
}
SDL_FreeSurface(shadow);
}
Bitmap *bm;
#define EXEC_BLITS(part) \
if (!nullOrDisposed(bm = bitmaps[BM_##part])) \
{ \

View file

@ -28,6 +28,7 @@
#include "config.h"
#include "debugwriter.h"
#include "disposable.h"
#include "etc.h"
#include "etc-internal.h"
#include "eventthread.h"
#include "filesystem.h"
@ -178,7 +179,9 @@ struct Movie
SDL_Delay(VIDEO_DELAY);
}
}
videoBitmap = new Bitmap(video->width, video->height);
// Create this Bitmap without a hires replacement, because we don't
// support hires replacement for Movies yet.
videoBitmap = new Bitmap(video->width, video->height, true);
audioQueueHead = NULL;
audioQueueTail = NULL;
@ -772,6 +775,7 @@ struct GraphicsPrivate {
* RGSS renders at (settable with Graphics.resize_screen).
* Can only be changed from within RGSS */
Vec2i scRes;
Vec2i scResLores;
/* Screen size, to which the rendered frames are scaled up.
* This can be smaller than the window size when fixed aspect
@ -828,7 +832,7 @@ struct GraphicsPrivate {
IntruList<Disposable> dispList;
GraphicsPrivate(RGSSThreadData *rtData)
: scRes(DEF_SCREEN_W, DEF_SCREEN_H), scSize(scRes),
: scRes(DEF_SCREEN_W, DEF_SCREEN_H), scResLores(scRes), scSize(scRes),
winSize(rtData->config.defScreenW, rtData->config.defScreenH),
screen(scRes.x, scRes.y), threadData(rtData),
glCtx(SDL_GL_GetCurrentContext()), multithreadedMode(true),
@ -999,11 +1003,15 @@ struct GraphicsPrivate {
}
void compositeToBuffer(TEXFBO &buffer) {
compositeToBufferScaled(buffer, scRes.x, scRes.y);
}
void compositeToBufferScaled(TEXFBO &buffer, int destWidth, int destHeight) {
screen.composite();
GLMeta::blitBegin(buffer);
GLMeta::blitSource(screen.getPP().frontBuffer());
GLMeta::blitRectangle(IntRect(0, 0, scRes.x, scRes.y), Vec2i());
GLMeta::blitRectangle(IntRect(0, 0, scRes.x, scRes.y), IntRect(0, 0, destWidth, destHeight));
GLMeta::blitEnd();
}
@ -1015,13 +1023,13 @@ struct GraphicsPrivate {
(scSize.y + scOffset.y),
scSize.x,
-scSize.y),
threadData->config.smoothScaling);
threadData->config.smoothScaling == Bilinear);
}
void metaBlitBufferFlippedScaled(const Vec2i &sourceSize, bool forceNearestNeighbor=false) {
GLMeta::blitRectangle(IntRect(0, 0, sourceSize.x, sourceSize.y),
IntRect(scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y),
!forceNearestNeighbor && threadData->config.smoothScaling);
!forceNearestNeighbor && threadData->config.smoothScaling == Bilinear);
}
void redrawScreen() {
@ -1229,22 +1237,28 @@ void Graphics::transition(int duration, const char *filename, int vague) {
TransShader &transShader = shState->shaders().trans;
SimpleTransShader &simpleShader = shState->shaders().simpleTrans;
// Handle high-res.
Vec2i transSize(p->scResLores.x, p->scResLores.y);
if (transMap) {
TransShader &shader = transShader;
shader.bind();
shader.applyViewportProj();
shader.setFrozenScene(p->frozenScene.tex);
shader.setCurrentScene(currentScene.tex);
if (transMap->hasHires()) {
Debug() << "BUG: High-res Graphics transMap not implemented";
}
shader.setTransMap(transMap->getGLTypes().tex);
shader.setVague(vague / 256.0f);
shader.setTexSize(p->scRes);
shader.setTexSize(transSize);
} else {
SimpleTransShader &shader = simpleShader;
shader.bind();
shader.applyViewportProj();
shader.setFrozenScene(p->frozenScene.tex);
shader.setCurrentScene(currentScene.tex);
shader.setTexSize(p->scRes);
shader.setTexSize(transSize);
}
glState.blend.pushSet(false);
@ -1389,18 +1403,38 @@ void Graphics::fadein(int duration) {
}
Bitmap *Graphics::snapToBitmap() {
Bitmap *bitmap = new Bitmap(width(), height());
p->compositeToBuffer(bitmap->getGLTypes());
/* Taint entire bitmap */
bitmap->taintArea(IntRect(0, 0, width(), height()));
return bitmap;
if (shState->config().enableHires) {
// TODO: Maybe don't reconstruct this struct every time?
TEXFBO tf;
tf.width = width();
tf.height = height();
tf.selfHires = &p->screen.getPP().frontBuffer();
return new Bitmap(tf);
}
return new Bitmap(p->screen.getPP().frontBuffer());
}
int Graphics::width() const { return p->scRes.x; }
int Graphics::width() const { return p->scResLores.x; }
int Graphics::height() const { return p->scRes.y; }
int Graphics::height() const { return p->scResLores.y; }
int Graphics::widthHires() const { return p->scRes.x; }
int Graphics::heightHires() const { return p->scRes.y; }
bool Graphics::isPingPongFramebufferActive() const {
return p->screen.getPP().frontBuffer().fbo == FBO::boundFramebufferID || p->screen.getPP().backBuffer().fbo == FBO::boundFramebufferID;
}
int Graphics::displayContentWidth() const {
return p->scSize.x;
}
int Graphics::displayContentHeight() const {
return p->scSize.y;
}
int Graphics::displayWidth() const {
SDL_DisplayMode dm{};
@ -1418,12 +1452,21 @@ void Graphics::resizeScreen(int width, int height) {
p->threadData->rqWindowAdjust.wait();
p->checkResize(true);
Vec2i sizeLores(width, height);
if (shState->config().enableHires) {
double framebufferScalingFactor = shState->config().framebufferScalingFactor;
width = (int)lround(framebufferScalingFactor * width);
height = (int)lround(framebufferScalingFactor * height);
}
Vec2i size(width, height);
if (p->scRes == size)
return;
p->scRes = size;
p->scResLores = sizeLores;
p->screen.setResolution(width, height);
@ -1459,6 +1502,10 @@ bool Graphics::updateMovieInput(Movie *movie) {
}
void Graphics::playMovie(const char *filename, int volume_, bool skippable) {
if (shState->config().enableHires) {
Debug() << "BUG: High-res Graphics playMovie not implemented";
}
Movie *movie = new Movie(skippable);
MovieOpenHandler handler(movie->srcOps);
shState->fileSystem().openRead(handler, filename);
@ -1569,13 +1616,13 @@ void Graphics::setFixedAspectRatio(bool value)
p->updateScreenResoRatio(p->threadData);
}
bool Graphics::getSmoothScaling() const
int Graphics::getSmoothScaling() const
{
// Same deal as with fixed aspect ratio
return shState->config().smoothScaling;
}
void Graphics::setSmoothScaling(bool value)
void Graphics::setSmoothScaling(int value)
{
shState->config().smoothScaling = value;
}

View file

@ -58,6 +58,11 @@ public:
int width() const;
int height() const;
int widthHires() const;
int heightHires() const;
bool isPingPongFramebufferActive() const;
int displayContentWidth() const;
int displayContentHeight() const;
int displayWidth() const;
int displayHeight() const;
void resizeScreen(int width, int height);
@ -76,7 +81,7 @@ public:
DECL_ATTR( Scale, double )
DECL_ATTR( Frameskip, bool )
DECL_ATTR( FixedAspectRatio, bool )
DECL_ATTR( SmoothScaling, bool )
DECL_ATTR( SmoothScaling, int )
DECL_ATTR( IntegerScaling, bool )
DECL_ATTR( LastMileScaling, bool )
DECL_ATTR( Threadsafe, bool )

View file

@ -23,6 +23,7 @@
#include "sharedstate.h"
#include "bitmap.h"
#include "debugwriter.h"
#include "etc.h"
#include "etc-internal.h"
#include "util.h"
@ -605,6 +606,10 @@ void Sprite::draw()
shader.setBushOpacity(p->bushOpacity.norm);
if (p->pattern && p->patternOpacity > 0) {
if (p->pattern->hasHires()) {
Debug() << "BUG: High-res Sprite pattern not implemented";
}
shader.setPattern(p->pattern->getGLTypes().tex, Vec2(p->pattern->width(), p->pattern->height()));
shader.setPatternBlendType(p->patternBlendType);
shader.setPatternTile(p->patternTile);

View file

@ -27,6 +27,7 @@
#include "sharedstate.h"
#include "config.h"
#include "debugwriter.h"
#include "glstate.h"
#include "gl-util.h"
#include "gl-meta.h"
@ -550,6 +551,10 @@ struct TilemapPrivate
int blitW = std::min(atW, atAreaW);
int blitH = std::min(atH, autotileH);
if (autotile->hasHires()) {
Debug() << "BUG: High-res Tilemap blit autotiles not implemented";
}
GLMeta::blitSource(autotile->getGLTypes());
if (atW <= autotileW && tiles.animated && !atlas.smallATs[atInd])
@ -639,6 +644,10 @@ struct TilemapPrivate
}
else
{
if (tileset->hasHires()) {
Debug() << "BUG: High-res Tilemap regular tileset not implemented";
}
/* Regular tileset */
GLMeta::blitBegin(atlas.gl);
GLMeta::blitSource(tileset->getGLTypes());

View file

@ -72,6 +72,8 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
VBO::ID vbo;
GLMeta::VAO vao;
TEXFBO atlasHires;
size_t allocQuads;
size_t groundQuads;
@ -132,6 +134,14 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
shState->requestAtlasTex(ATLASVX_W, ATLASVX_H, atlas);
if (shState->config().enableHires) {
double scalingFactor = shState->config().atlasScalingFactor;
int hiresWidth = (int)lround(scalingFactor * ATLASVX_W);
int hiresHeight = (int)lround(scalingFactor * ATLASVX_H);
shState->requestAtlasTex(hiresWidth, hiresHeight, atlasHires);
atlas.selfHires = &atlasHires;
}
vbo = VBO::gen();
GLMeta::vaoFillInVertexData<SVertex>(vao);
@ -151,6 +161,9 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
VBO::del(vbo);
shState->releaseAtlasTex(atlas);
if (shState->config().enableHires) {
shState->releaseAtlasTex(atlasHires);
}
prepareCon.disconnect();
@ -177,6 +190,16 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
void rebuildAtlas()
{
TileAtlasVX::build(atlas, bitmaps);
if (shState->config().dumpAtlas)
{
Bitmap dump(atlas);
dump.saveToFile("dumped_atlas.png");
if (dump.hasHires())
{
dump.getHires()->saveToFile("dumped_atlas_hires.png");
}
}
}
void updateMapViewport()
@ -310,7 +333,12 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
shader->applyViewportProj();
shader->setTranslation(dispPos);
TEX::bind(atlas.tex);
if (atlas.selfHires != nullptr) {
TEX::bind(atlas.selfHires->tex);
}
else {
TEX::bind(atlas.tex);
}
GLMeta::vaoBind(vao);
gl.DrawElements(GL_TRIANGLES, groundQuads*6, _GL_INDEX_TYPE, 0);
@ -329,7 +357,12 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
shader.applyViewportProj();
shader.setTranslation(dispPos);
TEX::bind(atlas.tex);
if (atlas.selfHires != nullptr) {
TEX::bind(atlas.selfHires->tex);
}
else {
TEX::bind(atlas.tex);
}
GLMeta::vaoBind(vao);
gl.DrawElements(GL_TRIANGLES, aboveQuads*6, _GL_INDEX_TYPE,

View file

@ -200,6 +200,14 @@ struct Rect : public Serializable
sigslot::signal<> valueChanged;
};
enum InterpolationMethod
{
NearestNeighbor = 0,
Bilinear = 1,
Bicubic = 2,
Lanczos3 = 3,
};
/* For internal use.
* All drawable classes have properties of one or more of the above
* types, which in an interpreted environment act as independent

View file

@ -125,7 +125,7 @@ bool EventThread::allocUserEvents()
EventThread::EventThread()
: ctrl(0),
fullscreen(false),
showCursor(true)
showCursor(false)
{
textInputLock = SDL_CreateMutex();
}
@ -135,6 +135,20 @@ EventThread::~EventThread()
SDL_DestroyMutex(textInputLock);
}
SDL_TimerID hideCursorTimerID = 0;
Uint32 cursorTimerCallback(Uint32 interval, void* param)
{
EventThread *ethread = static_cast<EventThread*>(param);
hideCursorTimerID = 0;
ethread->requestShowCursor(ethread->getShowCursor());
return 0;
}
void EventThread::cursorTimer()
{
SDL_RemoveTimer(hideCursorTimerID);
hideCursorTimerID = SDL_AddTimer(500, cursorTimerCallback, this);
}
void EventThread::process(RGSSThreadData &rtData)
{
SDL_Event event;
@ -445,6 +459,7 @@ void EventThread::process(RGSSThreadData &rtData)
case SDL_MOUSEMOTION :
mouseState.x = event.motion.x;
mouseState.y = event.motion.y;
cursorTimer();
updateCursorState(cursorInWindow, gameScreen);
break;
@ -687,7 +702,7 @@ void EventThread::updateCursorState(bool inWindow,
bool inScreen = inWindow && SDL_PointInRect(&pos, &screen);
if (inScreen)
SDL_ShowCursor(showCursor ? SDL_TRUE : SDL_FALSE);
SDL_ShowCursor(showCursor || hideCursorTimerID ? SDL_TRUE : SDL_FALSE);
else
SDL_ShowCursor(SDL_TRUE);
}

View file

@ -124,6 +124,7 @@ private:
void setFullscreen(SDL_Window *, bool mode);
void updateCursorState(bool inWindow,
const SDL_Rect &screen);
void cursorTimer();
bool fullscreen;
bool showCursor;

View file

@ -69,7 +69,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#ifdef MKXPZ_BUILD_XCODE
#include <Availability.h>
#include "TouchBar.h"
#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_15
#if !defined(__MAC_10_15) || __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_15
#define MKXPZ_INIT_GL_LATER
#endif
#endif
@ -210,7 +210,7 @@ int main(int argc, char *argv[]) {
#endif
/* initialize SDL first */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0) {
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_TIMER) < 0) {
showInitError(std::string("Error initializing SDL: ") + SDL_GetError());
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -145,10 +145,10 @@ HTTPResponse HTTPRequest::get() {
ret._headers.emplace(h.first, h.second);
}
else {
int err = result.error();
const char *errname = httpErrorNames[err];
auto err = result.error();
std::string errname = httplib::to_string(err);
delete client;
throw Exception(Exception::MKXPError, "Failed to GET %s (%i: %s)", destination.c_str(), err, errname);
throw Exception(Exception::MKXPError, "Failed to GET %s (%i: %s)", destination.c_str(), err, errname.c_str());
}
delete client;
@ -192,10 +192,10 @@ HTTPResponse HTTPRequest::post(StringMap &postData) {
ret._headers.emplace(h.first, h.second);
}
else {
int err = result.error();
const char *errname = httpErrorNames[err];
auto err = result.error();
std::string errname = httplib::to_string(err);
delete client;
throw Exception(Exception::MKXPError, "Failed to POST %s (%i: %s)", destination.c_str(), err, errname);
throw Exception(Exception::MKXPError, "Failed to POST %s (%i: %s)", destination.c_str(), err, errname.c_str());
}
delete client;
return ret;
@ -234,9 +234,10 @@ HTTPResponse HTTPRequest::post(const char *body, const char *content_type) {
ret._headers.emplace(h.first, h.second);
}
else {
int err = result.error();
auto err = result.error();
std::string errname = httplib::to_string(err);
delete client;
throw Exception(Exception::MKXPError, "Failed to POST %s (%i: %s)", destination.c_str(), err, httpErrorNames[err]);
throw Exception(Exception::MKXPError, "Failed to POST %s (%i: %s)", destination.c_str(), err, errname.c_str());
}
delete client;
return ret;

View file

@ -125,6 +125,9 @@ struct SharedStatePrivate
std::string archPath = config.execName + gameArchExt();
for (size_t i = 0; i < config.patches.size(); ++i)
fileSystem.addPath(config.patches[i].c_str());
/* Check if a game archive exists */
FILE *tmp = fopen(archPath.c_str(), "rb");
if (tmp)

View file

@ -0,0 +1,412 @@
# Test suite for mkxp-z high-res Bitmap replacement.
# Bitmap tests.
# Copyright 2023 Splendide Imaginarius.
# License GPLv2+.
# Test images are from https://github.com/xinntao/Real-ESRGAN/
#
# Run the suite via the "customScript" field in mkxp.json.
# Use RGSS v3 for best results.
def dump(bmp, spr, desc)
spr.bitmap = bmp
Graphics.wait(1)
bmp.to_file("test-results/" + desc + "-lo.png")
if !bmp.hires.nil?
bmp.hires.to_file("test-results/" + desc + "-hi.png")
end
System::puts("Finished " + desc)
end
# Setup graphics
Graphics.resize_screen(640, 480)
# Setup font
fnt = Font.new("Liberation Sans", 100)
# Setup splash screen
bmp = Bitmap.new(640, 480)
bmp.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0))
bmp.font = fnt
bmp.draw_text(0, 0, 640, 240, "High-Res Test Suite", 1)
bmp.draw_text(0, 240, 640, 240, "Starting Now", 1)
spr = Sprite.new()
spr.bitmap = bmp
Graphics.wait(1 * 60)
# Tests start here
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
dump(bmp, spr, "constructor-filename")
# TODO: Filename GIF constructor
bmp = Bitmap.new(640, 480)
bmp.clear
dump(bmp, spr, "constructor-dimensions")
# TODO: Animation constructor
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.clear
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-clear-tree-lo-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.clear
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-clear-tree-lo-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.clear
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-clear-tree-lo-children-quarter-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.clear
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-clear-tree-hi-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.clear
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-clear-tree-hi-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.clear
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-clear-tree-hi-children-quarter-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.fill_rect(bmp.rect, Color.new(0, 0, 0))
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-black-tree-lo-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.fill_rect(bmp.rect, Color.new(0, 0, 0))
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-black-tree-lo-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.fill_rect(bmp.rect, Color.new(0, 0, 0))
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-black-tree-lo-children-quarter-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.fill_rect(bmp.rect, Color.new(0, 0, 0))
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-black-tree-hi-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.fill_rect(bmp.rect, Color.new(0, 0, 0))
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-black-tree-hi-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp.fill_rect(bmp.rect, Color.new(0, 0, 0))
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-black-tree-hi-children-quarter-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit-lo")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-lo-tree-lo-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit-lo")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-lo-tree-lo-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit-lo")
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-lo-tree-lo-children-quarter-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit-lo")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-lo-tree-hi-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit-lo")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-lo-tree-hi-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit-lo")
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-lo-tree-hi-children-quarter-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-hi-tree-lo-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-hi-tree-lo-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha-lo")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-hi-tree-lo-children-quarter-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect)
dump(bmp, spr, "stretch-blt-hi-tree-hi-children-full-opaque")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.stretch_blt(bmp.rect, bmp2, bmp2.rect, 127)
dump(bmp, spr, "stretch-blt-hi-tree-hi-children-full-semitransparent")
bmp = Bitmap.new("Graphics/Pictures/tree_alpha_16bit")
rect = bmp.rect
rect.width /= 2
rect.height /= 2
rect.x = rect.width
rect.y = rect.height
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
rect2 = bmp2.rect
rect2.width /= 2
rect2.height /= 2
rect2.x = rect2.width
bmp.stretch_blt(rect, bmp2, rect2, 127)
dump(bmp, spr, "stretch-blt-hi-tree-hi-children-quarter-semitransparent")
bmp = Bitmap.new(640, 480)
bmp.fill_rect(100, 200, 450, 300, Color.new(0, 0, 0))
bmp.fill_rect(50, 100, 220, 150, Color.new(255, 0, 0))
dump(bmp, spr, "fill-rect")
bmp = Bitmap.new(640, 480)
bmp.gradient_fill_rect(100, 200, 450, 300, Color.new(0, 0, 0), Color.new(0, 0, 255))
bmp.gradient_fill_rect(50, 100, 220, 150, Color.new(255, 0, 0), Color.new(255, 255, 0))
dump(bmp, spr, "gradient-fill-rect-horizontal")
bmp = Bitmap.new(640, 480)
bmp.gradient_fill_rect(100, 200, 450, 300, Color.new(0, 0, 0), Color.new(0, 0, 255), true)
bmp.gradient_fill_rect(50, 100, 220, 150, Color.new(255, 0, 0), Color.new(255, 255, 0), true)
dump(bmp, spr, "gradient-fill-rect-vertical")
bmp = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.clear_rect(300, 175, 100, 150)
dump(bmp, spr, "clear-rect-lo-children")
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.clear_rect(300, 175, 100, 150)
dump(bmp, spr, "clear-rect-hi-children")
# TODO: linear-blur is arguably passing but maybe should have stronger blur?
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.blur
dump(bmp, spr, "linear-blur")
bmp = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.radial_blur(0, 10)
dump(bmp, spr, "radial-blur-0-lo-children")
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.radial_blur(0, 10)
dump(bmp, spr, "radial-blur-0-hi-children")
bmp = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.radial_blur(3, 10)
dump(bmp, spr, "radial-blur-3-lo-children")
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.radial_blur(3, 10)
dump(bmp, spr, "radial-blur-3-hi-children")
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.clear
dump(bmp, spr, "clear-full")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp = Bitmap.new(bmp2.width, bmp2.height)
for x in (0...bmp2.width)
for y in (0...bmp2.height)
bmp.set_pixel(x, y, bmp2.get_pixel(x, y))
end
end
dump(bmp, spr, "get-set-pixel-dimensions")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.clear
for x in (0...bmp2.width)
for y in (0...bmp2.height)
bmp.set_pixel(x, y, bmp2.get_pixel(x, y))
end
end
dump(bmp, spr, "get-set-pixel-clear")
bmp2 = Bitmap.new("Graphics/Pictures/children-alpha")
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.hires.clear
for x in (0...bmp2.hires.width)
for y in (0...bmp2.hires.height)
bmp.hires.set_pixel(x, y, bmp2.hires.get_pixel(x, y))
end
end
dump(bmp, spr, "get-set-pixel-direct")
bmp = Bitmap.new("Graphics/Pictures/children-alpha-lo")
bmp.hue_change(180)
dump(bmp, spr, "hue-change-lo-children")
bmp = Bitmap.new("Graphics/Pictures/children-alpha")
bmp.hue_change(180)
dump(bmp, spr, "hue-change-hi-children")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 100)
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 1)
dump(bmp, spr, "draw-text-plain")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 15)
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 0)
dump(bmp, spr, "draw-text-left")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 15)
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 2)
dump(bmp, spr, "draw-text-right")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 100)
fnt.bold = true
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 1)
dump(bmp, spr, "draw-text-bold")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 100)
fnt.italic = true
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 1)
dump(bmp, spr, "draw-text-italic")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 100)
fnt.color = Color.new(255, 0, 0)
fnt.outline = false
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 1)
dump(bmp, spr, "draw-text-red-no-outline")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 100)
fnt.color = Color.new(255, 127, 127)
fnt.shadow = true
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 1)
dump(bmp, spr, "draw-text-pink-shadow")
bmp = Bitmap.new(640, 480)
fnt = Font.new("Liberation Sans", 100)
fnt.out_color = Color.new(0, 255, 0)
bmp.font = fnt
bmp.draw_text(100, 200, 450, 300, "We <3 Real-ESRGAN", 1)
dump(bmp, spr, "draw-text-green-outline")
# TODO: Animation tests, if we can find a good way to test them.
# Tests are finished, show exit screen
bmp = Bitmap.new(640, 480)
bmp.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0))
fnt = Font.new("Liberation Sans", 100)
bmp.font = fnt
bmp.draw_text(0, 0, 640, 240, "High-Res Test Suite", 1)
bmp.draw_text(0, 240, 640, 240, "Has Finished", 1)
spr.bitmap = bmp
Graphics.wait(1 * 60)
exit

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,82 @@
# Test suite for mkxp-z high-res Bitmap replacement.
# Sprite tests.
# Copyright 2023 Splendide Imaginarius.
# License GPLv2+.
# Test images are from https://github.com/xinntao/Real-ESRGAN/
#
# Run the suite via the "customScript" field in mkxp.json.
# Use RGSS v3 for best results.
def dump2(bmp, spr, desc)
spr.bitmap = bmp
Graphics.wait(1)
#Graphics.wait(5*60)
#Graphics.screenshot("test-results/" + desc + ".png")
shot = Graphics.snap_to_bitmap
shot.to_file("test-results/" + desc + "-lo.png")
if !shot.hires.nil?
shot.hires.to_file("test-results/" + desc + "-hi.png")
end
System::puts("Finished " + desc)
end
def dump(bmp, spr, desc)
spr.viewport = nil
dump2(bmp, spr, desc + "-direct")
spr.tone.gray = 128
dump2(bmp, spr, desc + "-directtonegray")
spr.tone.gray = 0
$vp.ox = 0
spr.viewport = $vp
dump2(bmp, spr, desc + "-viewport")
$vp.ox = 250
dump2(bmp, spr, desc + "-viewportshift")
$vp.ox = 0
$vp.rect.width = 320
dump2(bmp, spr, desc + "-viewportsquash")
$vp.rect.width = 640
$vp.tone.green = -128
dump2(bmp, spr, desc + "-viewporttonegreen")
$vp.tone.green = 0
$vp.tone.gray = 128
dump2(bmp, spr, desc + "-viewporttonegray")
$vp.tone.gray = 0
end
# Setup graphics
Graphics.resize_screen(448, 640)
$vp = Viewport.new()
spr = Sprite.new()
bmp = Bitmap.new("Graphics/Pictures/OST_009-Small")
spr.zoom_x = 1.0
spr.zoom_y = 1.0
dump(bmp, spr, "Small")
bmp = Bitmap.new("Graphics/Pictures/OST_009-Big")
spr.zoom_x = 448.0 / 1792.0
spr.zoom_y = 448.0 / 1792.0
dump(bmp, spr, "Big")
bmp = Bitmap.new("Graphics/Pictures/OST_009")
spr.zoom_x = 1.0
spr.zoom_y = 1.0
dump(bmp, spr, "Substituted")
bmp = Bitmap.new("Graphics/Pictures/OST_009")
spr.zoom_x = 1.5
spr.zoom_y = 1.5
dump(bmp, spr, "Substituted-Zoomed")
bmp = Bitmap.new("Graphics/Pictures/OST_009")
spr.zoom_x = 448.0 / 1792.0
spr.zoom_y = 448.0 / 1792.0
dump(bmp.hires, spr, "Substituted-Explicit")
# Test for null pointer
spr_null = Sprite.new()
spr_null.src_rect = Rect.new(0, 0, 448, 640)
exit

63
tests/http/http.rb Executable file
View file

@ -0,0 +1,63 @@
# Test suite for HTTPLite.
# Copyright 2023 Splendide Imaginarius (based on Struma's docs).
# License GPLv2+.
#
# Run the suite via the "customScript" field in mkxp.json.
# Use RGSS v3 for best results.
System::puts "\nGET HTTP"
response = HTTPLite.get("http://httpbin.org/json")
if response[:status] == 200 #OK
System::puts response[:body]
else
System::puts "You got something other than an OK: #{response[:status]}"
end
System::puts "\nGET HTTPS"
response = HTTPLite.get("https://httpbin.org/json")
if response[:status] == 200 #OK
System::puts response[:body]
else
System::puts "You got something other than an OK: #{response[:status]}"
end
postdata = {
"key1" => "value1",
"key2" => "value2"
}
System::puts "\nPOST HTTP"
response = HTTPLite.post("http://httpbin.org/post", postdata)
if response[:status] == 200 #OK
System::puts response[:body]
else
System::puts "You got something other than an OK: #{response[:status]}"
end
System::puts "\nPOST HTTPS"
response = HTTPLite.post("https://httpbin.org/post", postdata)
if response[:status] == 200 #OK
System::puts response[:body]
else
System::puts "You got something other than an OK: #{response[:status]}"
end
postdata = HTTPLite::JSON.stringify(postdata)
System::puts "\nPOST body HTTP"
response = HTTPLite.post_body("http://httpbin.org/post", postdata, "application/json")
if response[:status] == 200 #OK
System::puts response[:body]
else
System::puts "You got something other than an OK: #{response[:status]}"
end
System::puts "\nPOST body HTTPS"
response = HTTPLite.post_body("https://httpbin.org/post", postdata, "application/json")
if response[:status] == 200 #OK
System::puts response[:body]
else
System::puts "You got something other than an OK: #{response[:status]}"
end
exit

View file

@ -297,7 +297,7 @@ $(DOWNLOADS)/openssl/Makefile: $(DOWNLOADS)/openssl/Configure
--openssldir="$(BUILD_PREFIX)"
$(DOWNLOADS)/openssl/Configure:
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl --single-branch --branch OpenSSL_1_1_1i --depth 1
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl --single-branch --branch openssl-3.0.12 --depth 1
# Standard ruby
ruby: init_dirs openssl $(BINDIR)/$(RB_PREFIX)-ruby310.dll

View file

@ -1,10 +1,10 @@
win = import('windows')
res = files(
'resource.h',
'icon.ico',
'mkxpz.manifest',
'resource.rc'
windows_resource_directory + '/resource.h',
windows_resource_directory + '/icon.ico',
windows_resource_directory + '/mkxpz.manifest',
windows_resource_directory + '/resource.rc'
)
windows_resources = win.compile_resources('resource.rc', depend_files: res)
windows_resources = win.compile_resources(windows_resource_directory + '/resource.rc', depend_files: res)