I guess I can just put this up. Most of these have been sitting here forever.
This commit is contained in:
commit
d2777092d1
26 changed files with 5347 additions and 0 deletions
674
COPYING
Normal file
674
COPYING
Normal file
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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
|
||||||
|
<http://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
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
37
README.md
Normal file
37
README.md
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
Random single-file programs I've written in my spare time for small tasks.
|
||||||
|
|
||||||
|
* ckmextract: Extracts ESP and BSA from Skyrim steam workshop mod archives.
|
||||||
|
* ddsinfo: Shows contents of a DDS header.
|
||||||
|
* dood: Reads an ENDOOM lump and mirrors every word "down the middle".
|
||||||
|
* fmod\_playbank (formerly fuck\_fmod): Tool for playback of .fsb files.
|
||||||
|
* fuzz: A fancy blocky noise filter using proto-AliceGL designs.
|
||||||
|
* glfuzz: OpenGL version of the filter.
|
||||||
|
* lutconv: A program for converting various "3D" LUT textures to actual 3D LUTs
|
||||||
|
in DDS volume maps. Successor to mkvolume. Used for MariENB.
|
||||||
|
* memrd/memsk/memwr: Quick 'n dirty tools for memory manipulation on running
|
||||||
|
programs.
|
||||||
|
* mkgauss: Make an array of gaussian blur kernel values with passed radius and
|
||||||
|
sigma. Used for shader development.
|
||||||
|
* mksoundwad: Program used during the early days of Tim Allen Doom. Deprecated
|
||||||
|
as notsanae now also replaces sounds through an OpenAL hook.
|
||||||
|
* mkssao: Make an array of SSAO samples. Also for shader development.
|
||||||
|
* mkvolume: Old program for making LUT volume maps.
|
||||||
|
* mkwall: A program I use on a daily basis to set my wallpaper on every Linux
|
||||||
|
machine.
|
||||||
|
* osnorm: Experiment for generating object-space normals from an .obj model.
|
||||||
|
* schange: Program used along with mkwall to update the wallpaper on screen
|
||||||
|
geometry changes.
|
||||||
|
* skse_cosave: Experiment for dumping information in SKSE co-saves.
|
||||||
|
* soapstone: Random soapstone messages from all 3 dark souls games. Messages
|
||||||
|
can be generated in bulk.
|
||||||
|
* totty: Sends text from stdin to tty1. Used to send certain commands when
|
||||||
|
remoting into a Raspberry Pi.
|
||||||
|
* vc2sdl: Passes the contents of the VC4 framebuffer to a SDL window. Was used
|
||||||
|
for video playback experiments on a Raspberry Pi with a SPI LCD.
|
||||||
|
* withhands: Talk like W.D. Gaster.
|
||||||
|
* zfs-rootfs.patch: The original patch for archzfs to support my specific
|
||||||
|
rootfs dataset mountpoint quirks.
|
||||||
|
* zimagekver: Quick program to extract version info from an ARM Linux kernel
|
||||||
|
image.
|
||||||
|
|
||||||
|
All programs and code here are under the GPLv3 unless stated otherwise.
|
||||||
37
ckmextract.c
Normal file
37
ckmextract.c
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 2 ) return 1;
|
||||||
|
FILE *ckm = fopen(argv[1],"rb");
|
||||||
|
char *ckmfil = basename(argv[1]);
|
||||||
|
char bsafil[256];
|
||||||
|
char espfil[256];
|
||||||
|
strcpy(bsafil,ckmfil);
|
||||||
|
strcpy(espfil,ckmfil);
|
||||||
|
strcpy(strchr(bsafil,'.'),".bsa");
|
||||||
|
strcpy(strchr(espfil,'.'),".esp");
|
||||||
|
int siz;
|
||||||
|
fread(&siz,1,4,ckm);
|
||||||
|
FILE *bsa = fopen(bsafil,"wb");
|
||||||
|
while ( (siz > 0) )
|
||||||
|
{
|
||||||
|
char buf[8192];
|
||||||
|
int rd = fread(buf,1,(siz>8192)?8192:siz,ckm);
|
||||||
|
fwrite(buf,1,rd,bsa);
|
||||||
|
siz -= rd;
|
||||||
|
}
|
||||||
|
fclose(bsa);
|
||||||
|
fread(&siz,1,4,ckm);
|
||||||
|
FILE *esp = fopen(espfil,"wb");
|
||||||
|
while ( !feof(ckm) )
|
||||||
|
{
|
||||||
|
char buf[8192];
|
||||||
|
int rd = fread(buf,1,8192,ckm);
|
||||||
|
fwrite(buf,1,rd,esp);
|
||||||
|
}
|
||||||
|
fclose(esp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
271
ddsinfo.c
Normal file
271
ddsinfo.c
Normal file
|
|
@ -0,0 +1,271 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define dword __UINT32_TYPE__
|
||||||
|
#define byte __UINT8_TYPE__
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char magic[4];
|
||||||
|
dword size, flags, height, width, pitch, depth, mipmaps;
|
||||||
|
char reserved1[44];
|
||||||
|
dword pf_size, pf_flags;
|
||||||
|
char pf_fourcc[4];
|
||||||
|
dword pf_bitcount, pf_rmask, pf_gmask, pf_bmask, pf_amask, caps[4],
|
||||||
|
reserved2;
|
||||||
|
} __attribute__((packed)) ddsheader_t;
|
||||||
|
|
||||||
|
// flags
|
||||||
|
#define DDSD_CAPS 0x1
|
||||||
|
#define DDSD_HEIGHT 0x2
|
||||||
|
#define DDSD_WIDTH 0x4
|
||||||
|
#define DDSD_PITCH 0x8
|
||||||
|
#define DDSD_PIXELFORMAT 0x1000
|
||||||
|
#define DDSD_MIPMAPCOUNT 0x20000
|
||||||
|
#define DDSD_LINEARSIZE 0x80000
|
||||||
|
#define DDSD_DEPTH 0x800000
|
||||||
|
|
||||||
|
// caps[0]
|
||||||
|
#define DDSCAPS_COMPLEX 0x8
|
||||||
|
#define DDSCAPS_MIPMAP 0x400000
|
||||||
|
#define DDSCAPS_TEXTURE 0x1000
|
||||||
|
|
||||||
|
// caps[1]
|
||||||
|
#define DDSCAPS2_CUBEMAP 0x200
|
||||||
|
#define DDSCAPS2_CUBEMAP_POSITIVEX 0x400
|
||||||
|
#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x800
|
||||||
|
#define DDSCAPS2_CUBEMAP_POSITIVEY 0x1000
|
||||||
|
#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x2000
|
||||||
|
#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x4000
|
||||||
|
#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x8000
|
||||||
|
#define DDSCAPS2_VOLUME 0x200000
|
||||||
|
|
||||||
|
// pf_flags
|
||||||
|
#define DDPF_ALPHAPIXELS 0x1
|
||||||
|
#define DDPF_ALPHA 0x2
|
||||||
|
#define DDPF_FOURCC 0x4
|
||||||
|
#define DDPF_RGB 0x40
|
||||||
|
#define DDPF_YUV 0x200
|
||||||
|
#define DDPF_LUMINANCE 0x20000
|
||||||
|
|
||||||
|
enum DXGI_FORMAT
|
||||||
|
{
|
||||||
|
DXGI_FORMAT_UNKNOWN = 0,
|
||||||
|
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
|
||||||
|
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
|
||||||
|
DXGI_FORMAT_R32G32B32A32_UINT = 3,
|
||||||
|
DXGI_FORMAT_R32G32B32A32_SINT = 4,
|
||||||
|
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
|
||||||
|
DXGI_FORMAT_R32G32B32_FLOAT = 6,
|
||||||
|
DXGI_FORMAT_R32G32B32_UINT = 7,
|
||||||
|
DXGI_FORMAT_R32G32B32_SINT = 8,
|
||||||
|
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
|
||||||
|
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
|
||||||
|
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
|
||||||
|
DXGI_FORMAT_R16G16B16A16_UINT = 12,
|
||||||
|
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
|
||||||
|
DXGI_FORMAT_R16G16B16A16_SINT = 14,
|
||||||
|
DXGI_FORMAT_R32G32_TYPELESS = 15,
|
||||||
|
DXGI_FORMAT_R32G32_FLOAT = 16,
|
||||||
|
DXGI_FORMAT_R32G32_UINT = 17,
|
||||||
|
DXGI_FORMAT_R32G32_SINT = 18,
|
||||||
|
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
|
||||||
|
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
|
||||||
|
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
|
||||||
|
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
|
||||||
|
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
|
||||||
|
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
|
||||||
|
DXGI_FORMAT_R10G10B10A2_UINT = 25,
|
||||||
|
DXGI_FORMAT_R11G11B10_FLOAT = 26,
|
||||||
|
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
|
||||||
|
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
|
||||||
|
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
|
||||||
|
DXGI_FORMAT_R8G8B8A8_UINT = 30,
|
||||||
|
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
|
||||||
|
DXGI_FORMAT_R8G8B8A8_SINT = 32,
|
||||||
|
DXGI_FORMAT_R16G16_TYPELESS = 33,
|
||||||
|
DXGI_FORMAT_R16G16_FLOAT = 34,
|
||||||
|
DXGI_FORMAT_R16G16_UNORM = 35,
|
||||||
|
DXGI_FORMAT_R16G16_UINT = 36,
|
||||||
|
DXGI_FORMAT_R16G16_SNORM = 37,
|
||||||
|
DXGI_FORMAT_R16G16_SINT = 38,
|
||||||
|
DXGI_FORMAT_R32_TYPELESS = 39,
|
||||||
|
DXGI_FORMAT_D32_FLOAT = 40,
|
||||||
|
DXGI_FORMAT_R32_FLOAT = 41,
|
||||||
|
DXGI_FORMAT_R32_UINT = 42,
|
||||||
|
DXGI_FORMAT_R32_SINT = 43,
|
||||||
|
DXGI_FORMAT_R24G8_TYPELESS = 44,
|
||||||
|
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
|
||||||
|
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
|
||||||
|
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
|
||||||
|
DXGI_FORMAT_R8G8_TYPELESS = 48,
|
||||||
|
DXGI_FORMAT_R8G8_UNORM = 49,
|
||||||
|
DXGI_FORMAT_R8G8_UINT = 50,
|
||||||
|
DXGI_FORMAT_R8G8_SNORM = 51,
|
||||||
|
DXGI_FORMAT_R8G8_SINT = 52,
|
||||||
|
DXGI_FORMAT_R16_TYPELESS = 53,
|
||||||
|
DXGI_FORMAT_R16_FLOAT = 54,
|
||||||
|
DXGI_FORMAT_D16_UNORM = 55,
|
||||||
|
DXGI_FORMAT_R16_UNORM = 56,
|
||||||
|
DXGI_FORMAT_R16_UINT = 57,
|
||||||
|
DXGI_FORMAT_R16_SNORM = 58,
|
||||||
|
DXGI_FORMAT_R16_SINT = 59,
|
||||||
|
DXGI_FORMAT_R8_TYPELESS = 60,
|
||||||
|
DXGI_FORMAT_R8_UNORM = 61,
|
||||||
|
DXGI_FORMAT_R8_UINT = 62,
|
||||||
|
DXGI_FORMAT_R8_SNORM = 63,
|
||||||
|
DXGI_FORMAT_R8_SINT = 64,
|
||||||
|
DXGI_FORMAT_A8_UNORM = 65,
|
||||||
|
DXGI_FORMAT_R1_UNORM = 66,
|
||||||
|
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
|
||||||
|
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
|
||||||
|
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
|
||||||
|
DXGI_FORMAT_BC1_TYPELESS = 70,
|
||||||
|
DXGI_FORMAT_BC1_UNORM = 71,
|
||||||
|
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
|
||||||
|
DXGI_FORMAT_BC2_TYPELESS = 73,
|
||||||
|
DXGI_FORMAT_BC2_UNORM = 74,
|
||||||
|
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
|
||||||
|
DXGI_FORMAT_BC3_TYPELESS = 76,
|
||||||
|
DXGI_FORMAT_BC3_UNORM = 77,
|
||||||
|
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
|
||||||
|
DXGI_FORMAT_BC4_TYPELESS = 79,
|
||||||
|
DXGI_FORMAT_BC4_UNORM = 80,
|
||||||
|
DXGI_FORMAT_BC4_SNORM = 81,
|
||||||
|
DXGI_FORMAT_BC5_TYPELESS = 82,
|
||||||
|
DXGI_FORMAT_BC5_UNORM = 83,
|
||||||
|
DXGI_FORMAT_BC5_SNORM = 84,
|
||||||
|
DXGI_FORMAT_B5G6R5_UNORM = 85,
|
||||||
|
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
|
||||||
|
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
|
||||||
|
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
|
||||||
|
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
|
||||||
|
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
|
||||||
|
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
|
||||||
|
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
|
||||||
|
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
|
||||||
|
DXGI_FORMAT_BC6H_TYPELESS = 94,
|
||||||
|
DXGI_FORMAT_BC6H_UF16 = 95,
|
||||||
|
DXGI_FORMAT_BC6H_SF16 = 96,
|
||||||
|
DXGI_FORMAT_BC7_TYPELESS = 97,
|
||||||
|
DXGI_FORMAT_BC7_UNORM = 98,
|
||||||
|
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
|
||||||
|
DXGI_FORMAT_AYUV = 100,
|
||||||
|
DXGI_FORMAT_Y410 = 101,
|
||||||
|
DXGI_FORMAT_Y416 = 102,
|
||||||
|
DXGI_FORMAT_NV12 = 103,
|
||||||
|
DXGI_FORMAT_P010 = 104,
|
||||||
|
DXGI_FORMAT_P016 = 105,
|
||||||
|
DXGI_FORMAT_420_OPAQUE = 106,
|
||||||
|
DXGI_FORMAT_YUY2 = 107,
|
||||||
|
DXGI_FORMAT_Y210 = 108,
|
||||||
|
DXGI_FORMAT_Y216 = 109,
|
||||||
|
DXGI_FORMAT_NV11 = 110,
|
||||||
|
DXGI_FORMAT_AI44 = 111,
|
||||||
|
DXGI_FORMAT_IA44 = 112,
|
||||||
|
DXGI_FORMAT_P8 = 113,
|
||||||
|
DXGI_FORMAT_A8P8 = 114,
|
||||||
|
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
|
||||||
|
DXGI_FORMAT_P208 = 130,
|
||||||
|
DXGI_FORMAT_V208 = 131,
|
||||||
|
DXGI_FORMAT_V408 = 132,
|
||||||
|
DXGI_FORMAT_FORCE_UINT = 0xffffffff
|
||||||
|
};
|
||||||
|
|
||||||
|
enum D3D10_RESOURCE_DIMENSION
|
||||||
|
{
|
||||||
|
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
|
||||||
|
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
|
||||||
|
D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
|
||||||
|
D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
|
||||||
|
D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
dword dxgiformat, resourcedimension, miscflag, arraysize, miscflags2;
|
||||||
|
} __attribute__((packed)) ddsheader_dx10_t;
|
||||||
|
|
||||||
|
// miscflag
|
||||||
|
#define DDS_RESOURCE_MISC_TEXTURECUBE 0x4
|
||||||
|
|
||||||
|
// miscflags2
|
||||||
|
#define DDS_ALPHA_MODE_UNKNOWN 0x0
|
||||||
|
#define DDS_ALPHA_MODE_STRAIGHT 0x1
|
||||||
|
#define DDS_ALPHA_MODE_PREMULTILIED 0x2
|
||||||
|
#define DDS_ALPHA_MODE_OPAQUE 0x3
|
||||||
|
#define DDS_ALPHA_MODE_CUSTOM 0x4
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 2 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"usage: %s <ddsfile>\n",argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
FILE *ddsf = fopen(argv[1],"r");
|
||||||
|
if ( !ddsf )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s: %s\n",argv[0],strerror(errno));
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
ddsheader_t head;
|
||||||
|
ddsheader_dx10_t head10;
|
||||||
|
fread(&head,sizeof(ddsheader_t),1,ddsf);
|
||||||
|
if ( strncmp(head.magic,"DDS ",4) )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s: %s not a dds file (bad magic)",argv[0],
|
||||||
|
argv[1]);
|
||||||
|
fclose(ddsf);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
if ( !strncmp(head.pf_fourcc,"DX10",4) )
|
||||||
|
fread(&head10,sizeof(ddsheader_dx10_t),1,ddsf);
|
||||||
|
fclose(ddsf);
|
||||||
|
/* print out header */
|
||||||
|
printf("%.4s\n%u bytes\n",head.magic,head.size);
|
||||||
|
printf("flags:");
|
||||||
|
if ( head.flags&DDSD_CAPS ) printf(" CAPS");
|
||||||
|
if ( head.flags&DDSD_HEIGHT ) printf(" HEIGHT");
|
||||||
|
if ( head.flags&DDSD_WIDTH ) printf(" WIDTH");
|
||||||
|
if ( head.flags&DDSD_PITCH ) printf(" PITCH");
|
||||||
|
if ( head.flags&DDSD_PIXELFORMAT ) printf(" PIXELFORMAT");
|
||||||
|
if ( head.flags&DDSD_MIPMAPCOUNT ) printf(" MIPMAPCOUNT");
|
||||||
|
if ( head.flags&DDSD_LINEARSIZE ) printf(" LINEARSIZE");
|
||||||
|
if ( head.flags&DDSD_DEPTH ) printf(" DEPTH");
|
||||||
|
if ( head.flags&DDSD_DEPTH )
|
||||||
|
printf("\n%u x %u x %u\n",head.width,head.height,head.depth);
|
||||||
|
else printf("\n%u x %u\n",head.width,head.height);
|
||||||
|
if ( head.flags&DDSD_PITCH ) printf("pitch: %u bytes\n",head.pitch);
|
||||||
|
if ( head.flags&DDSD_MIPMAPCOUNT ) printf("%u mipmaps\n",head.mipmaps);
|
||||||
|
if ( head.reserved1[0] ) printf("comment: %.44s\n",head.reserved1);
|
||||||
|
printf("pixelformat: %u bytes\n",head.pf_size);
|
||||||
|
printf("flags:");
|
||||||
|
if ( head.pf_flags&DDPF_ALPHAPIXELS ) printf(" ALPHAPIXELS");
|
||||||
|
if ( head.pf_flags&DDPF_ALPHA ) printf(" ALPHA");
|
||||||
|
if ( head.pf_flags&DDPF_FOURCC ) printf(" FOURCC");
|
||||||
|
if ( head.pf_flags&DDPF_RGB ) printf(" RGB");
|
||||||
|
if ( head.pf_flags&DDPF_YUV ) printf(" YUV");
|
||||||
|
if ( head.pf_flags&DDPF_LUMINANCE ) printf(" LUMINANCE");
|
||||||
|
if ( head.pf_flags&DDPF_FOURCC )
|
||||||
|
printf("\nfourcc: %.4s",head.pf_fourcc);
|
||||||
|
printf("\n%u bits (mask: R %08x G %08x B %08x A %08x)\n",
|
||||||
|
head.pf_bitcount,head.pf_rmask,head.pf_gmask,head.pf_bmask,
|
||||||
|
head.pf_amask);
|
||||||
|
printf("caps[0]:");
|
||||||
|
if ( head.caps[0]&DDSCAPS_COMPLEX ) printf(" COMPLEX");
|
||||||
|
if ( head.caps[0]&DDSCAPS_MIPMAP ) printf(" MIPMAP");
|
||||||
|
if ( head.caps[0]&DDSCAPS_TEXTURE ) printf(" TEXTURE");
|
||||||
|
printf("\ncaps[1]:");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_CUBEMAP ) printf(" CUBEMAP");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_CUBEMAP_POSITIVEX ) printf(" POSITIVEX");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_CUBEMAP_NEGATIVEX ) printf(" NEGATIVEX");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_CUBEMAP_POSITIVEY ) printf(" POSITIVEY");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_CUBEMAP_NEGATIVEY ) printf(" NEGATIVEY");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_CUBEMAP_POSITIVEZ ) printf(" POSITIVEZ");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_CUBEMAP_NEGATIVEZ ) printf(" NEGATIVEZ");
|
||||||
|
if ( head.caps[1]&DDSCAPS2_VOLUME ) printf(" VOLUME");
|
||||||
|
printf("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
30
dood.c
Normal file
30
dood.c
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
unsigned short endoom[80*25];
|
||||||
|
|
||||||
|
int val( unsigned short ch )
|
||||||
|
{
|
||||||
|
return ((ch>0x2F)&&(ch<0x3A))||((ch>0x40)&&(ch<0x5B))
|
||||||
|
||((ch>0x60)&&(ch<0x7B));
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( void )
|
||||||
|
{
|
||||||
|
fread(endoom,sizeof(short),80*25,stdin);
|
||||||
|
int c = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ( val(endoom[c]&0xFF) )
|
||||||
|
{
|
||||||
|
int s = c;
|
||||||
|
while ( (c++ < 80*25 ) && val(endoom[c]&0xFF) );
|
||||||
|
int e = c;
|
||||||
|
for ( int i=0; i<(e-s)/2; i++ )
|
||||||
|
endoom[e-i-1] = endoom[s+i];
|
||||||
|
}
|
||||||
|
else c++;
|
||||||
|
}
|
||||||
|
while ( c < 80*25 );
|
||||||
|
fwrite(endoom,sizeof(short),80*25,stdout);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
37
fmod_playbank.c
Normal file
37
fmod_playbank.c
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include <fmodex/fmod.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
FMOD_SYSTEM *sys;
|
||||||
|
FMOD_SOUND *bank;
|
||||||
|
FMOD_SOUND *snd;
|
||||||
|
FMOD_CHANNEL *ch = 0;
|
||||||
|
FMOD_System_Create(&sys);
|
||||||
|
FMOD_System_Init(sys,32,FMOD_INIT_NORMAL,0);
|
||||||
|
FMOD_System_CreateSound(sys,argv[1],FMOD_SOFTWARE,0,&bank);
|
||||||
|
int iss = 0, ss = 0;
|
||||||
|
sscanf(argv[2],"%d",&iss);
|
||||||
|
FMOD_Sound_GetNumSubSounds(bank,&ss);
|
||||||
|
printf("%s : %d\n",argv[1],ss);
|
||||||
|
int i;
|
||||||
|
char name[256];
|
||||||
|
for ( i=iss; i<ss; i++ )
|
||||||
|
{
|
||||||
|
FMOD_Sound_GetSubSound(bank,i,&snd);
|
||||||
|
FMOD_Sound_GetName(snd,name,255);
|
||||||
|
printf("Playing: %s\n",name);
|
||||||
|
FMOD_System_PlaySound(sys,FMOD_CHANNEL_FREE,snd,0,&ch);
|
||||||
|
int active = 1;
|
||||||
|
while ( active )
|
||||||
|
{
|
||||||
|
FMOD_System_Update(sys);
|
||||||
|
FMOD_Channel_IsPlaying(ch,&active);
|
||||||
|
}
|
||||||
|
FMOD_Sound_Release(snd);
|
||||||
|
}
|
||||||
|
FMOD_Sound_Release(bank);
|
||||||
|
FMOD_System_Close(sys);
|
||||||
|
FMOD_System_Release(sys);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
200
fuzz.c
Normal file
200
fuzz.c
Normal file
|
|
@ -0,0 +1,200 @@
|
||||||
|
/*
|
||||||
|
fuzz.c : Fancy software filter.
|
||||||
|
I was bored.
|
||||||
|
(C)2016 Marisa Kirisame, UnSX Team.
|
||||||
|
Released under the GNU GPLv3 (or later).
|
||||||
|
*/
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_ttf.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
float r,g,b,a;
|
||||||
|
} rgbfpx_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Uint8 r,g,b,a;
|
||||||
|
} __attribute__((packed)) rgb8px_t;
|
||||||
|
|
||||||
|
float t = 0.f;
|
||||||
|
const int fw = 640, fh = 480;
|
||||||
|
|
||||||
|
float rn( float sdx, float sdy )
|
||||||
|
{
|
||||||
|
return cosf(sdy*3874.8674f+sdx*6783.5325f)*2737.8474f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float fract( float x )
|
||||||
|
{
|
||||||
|
return x-floorf(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Window *w;
|
||||||
|
SDL_Surface *ws, *fz;
|
||||||
|
|
||||||
|
rgbfpx_t *fl1, *fl2, *fl3;
|
||||||
|
const int fw1 = 320, fw2 = 160, fw3 = 80, fh1 = 240, fh2 = 120, fh3 = 60;
|
||||||
|
|
||||||
|
void mklayer1( void )
|
||||||
|
{
|
||||||
|
for ( int y=0; y<fh1; y++ )
|
||||||
|
{
|
||||||
|
float rg;
|
||||||
|
for ( int x=0; x<fw1; x++ )
|
||||||
|
{
|
||||||
|
rg = 2.f*fabsf(fract(rn(x,y)+t*1.3526f)-0.5f);
|
||||||
|
fl1[x+y*fw1].r = 0.71f*rg;
|
||||||
|
fl1[x+y*fw1].g = 0.67f*rg;
|
||||||
|
fl1[x+y*fw1].b = 0.95f*rg;
|
||||||
|
fl1[x+y*fw1].a = 1.f*rg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mklayer2( void )
|
||||||
|
{
|
||||||
|
for ( int y=0; y<fh2; y++ )
|
||||||
|
{
|
||||||
|
float rg;
|
||||||
|
for ( int x=0; x<fw2; x++ )
|
||||||
|
{
|
||||||
|
rg = 2.f*fabsf(fract(rn(x,y)+t*0.7843f)-0.5f);
|
||||||
|
fl2[x+y*fw2].r = 0.66f*rg;
|
||||||
|
fl2[x+y*fw2].g = 0.84f*rg;
|
||||||
|
fl2[x+y*fw2].b = 0.73f*rg;
|
||||||
|
fl2[x+y*fw2].a = 1.f*rg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mklayer3( void )
|
||||||
|
{
|
||||||
|
for ( int y=0; y<fh3; y++ )
|
||||||
|
{
|
||||||
|
float rg;
|
||||||
|
for ( int x=0; x<fw3; x++ )
|
||||||
|
{
|
||||||
|
rg = 2.f*fabsf(fract(rn(x,y)+t*0.3725f)-0.5f);
|
||||||
|
fl3[x+y*fw3].r = 0.95f*rg;
|
||||||
|
fl3[x+y*fw3].g = 0.73f*rg;
|
||||||
|
fl3[x+y*fw3].b = 0.81f*rg;
|
||||||
|
fl3[x+y*fw3].a = 1.f*rg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mergedown( void )
|
||||||
|
{
|
||||||
|
rgbfpx_t twofivefive = {255.f,255.f,255.f,255.f};
|
||||||
|
#pragma omp parallel for
|
||||||
|
for ( int y=0; y<fh; y++ )
|
||||||
|
{
|
||||||
|
int y1, y2, y3;
|
||||||
|
rgb8px_t *stripe;
|
||||||
|
rgbfpx_t merged;
|
||||||
|
y1 = y>>1;
|
||||||
|
y2 = y>>2;
|
||||||
|
y3 = y>>3;
|
||||||
|
stripe = (rgb8px_t*)((Uint8*)fz->pixels+y*fz->pitch);
|
||||||
|
for ( int x=0; x<fw; x++ )
|
||||||
|
{
|
||||||
|
int x1, x2, x3;
|
||||||
|
x1 = x>>1;
|
||||||
|
x2 = x>>2;
|
||||||
|
x3 = x>>3;
|
||||||
|
// gcc is stupid
|
||||||
|
asm( "movaps %1,%%xmm0\n"
|
||||||
|
"mulps %2,%%xmm0\n"
|
||||||
|
"mulps %3,%%xmm0\n"
|
||||||
|
"mulps %4,%%xmm0\n"
|
||||||
|
"movaps %%xmm0,%0\n"
|
||||||
|
:"=m"(merged)
|
||||||
|
:"m"(fl1[x1+y1*fw1]),"m"(fl2[x2+y2*fw2]),
|
||||||
|
"m"(fl3[x3+y3*fw3]),"m"(twofivefive));
|
||||||
|
stripe[x].r = merged.r;
|
||||||
|
stripe[x].g = merged.g;
|
||||||
|
stripe[x].b = merged.b;
|
||||||
|
stripe[x].a = merged.a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TMAX 64
|
||||||
|
int ti = 0;
|
||||||
|
float ts = 0.f, tl[TMAX] = {0.f};
|
||||||
|
|
||||||
|
float avg_fps( float nt )
|
||||||
|
{
|
||||||
|
ts = ts-tl[ti]+nt;
|
||||||
|
tl[ti] = nt;
|
||||||
|
if ( ++ti == TMAX ) ti = 0;
|
||||||
|
return ts/TMAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NANOS_SEC 1000000000L
|
||||||
|
|
||||||
|
long ticker( void )
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
|
||||||
|
return ts.tv_nsec+ts.tv_sec*NANOS_SEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( void )
|
||||||
|
{
|
||||||
|
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS);
|
||||||
|
w = SDL_CreateWindow("Fuzz",SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,fw,fh,SDL_WINDOW_SHOWN);
|
||||||
|
ws = SDL_GetWindowSurface(w);
|
||||||
|
fz = SDL_CreateRGBSurface(0,fw,fh,32,0xFF,0xFF00,0xFF0000,0xFF000000);
|
||||||
|
SDL_SetSurfaceBlendMode(fz,SDL_BLENDMODE_NONE);
|
||||||
|
fl1 = malloc(sizeof(rgbfpx_t)*fw1*fh1);
|
||||||
|
fl2 = malloc(sizeof(rgbfpx_t)*fw2*fh2);
|
||||||
|
fl3 = malloc(sizeof(rgbfpx_t)*fw3*fh3);
|
||||||
|
TTF_Init();
|
||||||
|
TTF_Font *fon = TTF_OpenFont("/usr/share/fonts/misc/unifont.bdf",16);
|
||||||
|
SDL_Event e;
|
||||||
|
SDL_Color fpscol = {160,0,0,255};
|
||||||
|
int active = 1;
|
||||||
|
long tick, tock;
|
||||||
|
float frame = 0.f, fps = NAN, fpsmin = INFINITY, fpsmax = -INFINITY,
|
||||||
|
fpsavg = 0.f;
|
||||||
|
char fpst[16];
|
||||||
|
while ( active )
|
||||||
|
{
|
||||||
|
tick = ticker();
|
||||||
|
while ( SDL_PollEvent(&e) ) if ( (e.type == SDL_QUIT)
|
||||||
|
|| ((e.type == SDL_KEYDOWN)
|
||||||
|
&& (e.key.keysym.sym == SDLK_ESCAPE)) ) active = 0;
|
||||||
|
mklayer1();
|
||||||
|
mklayer2();
|
||||||
|
mklayer3();
|
||||||
|
mergedown();
|
||||||
|
SDL_BlitSurface(fz,0,ws,0);
|
||||||
|
snprintf(fpst,15,"%.2f FPS",fps);
|
||||||
|
SDL_Surface *txt = TTF_RenderText_Blended(fon,fpst,fpscol);
|
||||||
|
SDL_BlitSurface(txt,0,ws,0);
|
||||||
|
SDL_FreeSurface(txt);
|
||||||
|
SDL_UpdateWindowSurface(w);
|
||||||
|
tock = ticker();
|
||||||
|
frame = (float)(tock-tick)/NANOS_SEC;
|
||||||
|
fps = 1.f/frame;
|
||||||
|
fpsavg = avg_fps(fps);
|
||||||
|
if ( fps > fpsmax ) fpsmax = fps;
|
||||||
|
if ( fps < fpsmin ) fpsmin = fps;
|
||||||
|
printf("FPS: %.2f (%.2f min, %.2f max, %.2f avg)\n",fps,
|
||||||
|
fpsmin,fpsmax,fpsavg);
|
||||||
|
t += frame;
|
||||||
|
}
|
||||||
|
TTF_CloseFont(fon);
|
||||||
|
TTF_Quit();
|
||||||
|
free(fl3);
|
||||||
|
free(fl2);
|
||||||
|
free(fl1);
|
||||||
|
SDL_FreeSurface(fz);
|
||||||
|
SDL_DestroyWindow(w);
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
158
glfuzz.c
Normal file
158
glfuzz.c
Normal file
|
|
@ -0,0 +1,158 @@
|
||||||
|
/*
|
||||||
|
glfuzz.c : Fancy hardware filter.
|
||||||
|
I was bored.
|
||||||
|
(C)2016 Marisa Kirisame, UnSX Team.
|
||||||
|
Released under the GNU GPLv3 (or later).
|
||||||
|
*/
|
||||||
|
#include <epoxy/gl.h>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
GLuint prog, frag, vert;
|
||||||
|
GLuint flat;
|
||||||
|
|
||||||
|
const char *vcode =
|
||||||
|
"varying vec2 coord;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
"coord=(gl_Vertex.xy+1.0)*0.5;\n"
|
||||||
|
"gl_Position=gl_Vertex;\n"
|
||||||
|
"}\n";
|
||||||
|
const char *fcode =
|
||||||
|
"uniform float timer;\n"
|
||||||
|
"uniform vec2 resolution;\n"
|
||||||
|
"varying vec2 coord;\n"
|
||||||
|
"float rnd(in vec2 sd)\n"
|
||||||
|
"{\n"
|
||||||
|
"return cos(sd.y*3874.8674+sd.x*6783.5325)*2737.8474;\n"
|
||||||
|
"}\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
"vec2 uv=floor(coord*resolution*0.5);\n"
|
||||||
|
"vec3 col=vec3(0.71,0.67,0.95)*2.0*abs(fract(rnd(uv)+timer*1.3526)-0.5);\n"
|
||||||
|
"uv=floor(coord*resolution*0.25);\n"
|
||||||
|
"col*=vec3(0.66,0.84,0.73)*2.0*abs(fract(rnd(uv)+timer*0.7843)-0.5);\n"
|
||||||
|
"uv=floor(coord*resolution*0.125);\n"
|
||||||
|
"col*=vec3(0.95,0.73,0.81)*2.0*abs(fract(rnd(uv)+timer*0.3725)-0.5);\n"
|
||||||
|
"gl_FragColor=vec4(col,1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
float t = 0.f;
|
||||||
|
const int fw = 640, fh = 480;
|
||||||
|
|
||||||
|
SDL_Window *w;
|
||||||
|
SDL_GLContext *ctx;
|
||||||
|
|
||||||
|
#define NANOS_SEC 1000000000L
|
||||||
|
|
||||||
|
long ticker( void )
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
|
||||||
|
return ts.tv_nsec+ts.tv_sec*NANOS_SEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFrame( void )
|
||||||
|
{
|
||||||
|
GLint uf;
|
||||||
|
glUseProgram(prog);
|
||||||
|
uf = glGetUniformLocation(prog,"timer");
|
||||||
|
glUniform1f(uf,t);
|
||||||
|
uf = glGetUniformLocation(prog,"resolution");
|
||||||
|
glUniform2f(uf,fw,fh);
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,flat);
|
||||||
|
glVertexPointer(3,GL_FLOAT,0,0);
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||||
|
glFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,2);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,1);
|
||||||
|
w = SDL_CreateWindow("Fuzz (OpenGL)",SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,fw,fh,
|
||||||
|
SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN);
|
||||||
|
ctx = SDL_GL_CreateContext(w);
|
||||||
|
SDL_GL_SetSwapInterval(!((argc>1)&&!strcmp(argv[1],"--novsync")));
|
||||||
|
GLint len, suc;
|
||||||
|
char *log;
|
||||||
|
/* fragment */
|
||||||
|
frag = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
len = strlen(fcode);
|
||||||
|
glShaderSource(frag,1,&fcode,&len);
|
||||||
|
glCompileShader(frag);
|
||||||
|
glGetShaderiv(frag,GL_COMPILE_STATUS,&suc);
|
||||||
|
if ( !suc )
|
||||||
|
{
|
||||||
|
glGetShaderiv(frag,GL_INFO_LOG_LENGTH,&len);
|
||||||
|
log = malloc(len);
|
||||||
|
glGetShaderInfoLog(frag,len,&suc,log);
|
||||||
|
printf("fragment:\n%s\n",log);
|
||||||
|
free(log);
|
||||||
|
}
|
||||||
|
/* vertex */
|
||||||
|
vert = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
len = strlen(vcode);
|
||||||
|
glShaderSource(vert,1,&vcode,&len);
|
||||||
|
glCompileShader(vert);
|
||||||
|
glGetShaderiv(vert,GL_COMPILE_STATUS,&suc);
|
||||||
|
if ( !suc )
|
||||||
|
{
|
||||||
|
glGetShaderiv(vert,GL_INFO_LOG_LENGTH,&len);
|
||||||
|
log = malloc(len);
|
||||||
|
glGetShaderInfoLog(vert,len,&suc,log);
|
||||||
|
printf("vertex:\n%s\n",log);
|
||||||
|
free(log);
|
||||||
|
}
|
||||||
|
/* program */
|
||||||
|
prog = glCreateProgram();
|
||||||
|
glAttachShader(prog,frag);
|
||||||
|
glAttachShader(prog,vert);
|
||||||
|
glLinkProgram(prog);
|
||||||
|
glGetProgramiv(prog,GL_LINK_STATUS,&suc);
|
||||||
|
if ( !suc )
|
||||||
|
{
|
||||||
|
glGetProgramiv(prog,GL_INFO_LOG_LENGTH,&len);
|
||||||
|
log = malloc(len);
|
||||||
|
glGetProgramInfoLog(prog,len,&suc,log);
|
||||||
|
printf("program:\n%s\n",log);
|
||||||
|
free(log);
|
||||||
|
}
|
||||||
|
glDeleteShader(frag);
|
||||||
|
glDeleteShader(vert);
|
||||||
|
/* flat */
|
||||||
|
GLfloat v[12] =
|
||||||
|
{
|
||||||
|
-1.0,-1.0, 0.0, 1.0,-1.0, 0.0,
|
||||||
|
-1.0, 1.0, 0.0, 1.0, 1.0, 0.0,
|
||||||
|
};
|
||||||
|
glGenBuffers(1,&flat);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER,flat);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER,sizeof(GLfloat)*12,v,GL_STATIC_DRAW_ARB);
|
||||||
|
SDL_Event e;
|
||||||
|
int active = 1;
|
||||||
|
long tick, tock;
|
||||||
|
while ( active )
|
||||||
|
{
|
||||||
|
while ( SDL_PollEvent(&e) ) if ( (e.type == SDL_QUIT)
|
||||||
|
|| ((e.type == SDL_KEYDOWN)
|
||||||
|
&& (e.key.keysym.sym == SDLK_ESCAPE)) ) active = 0;
|
||||||
|
tick = ticker();
|
||||||
|
DrawFrame();
|
||||||
|
SDL_GL_SwapWindow(w);
|
||||||
|
tock = ticker();
|
||||||
|
float frame = (float)(tock-tick)/NANOS_SEC;
|
||||||
|
printf("FPS: %.2f\n",1.f/frame);
|
||||||
|
t += frame;
|
||||||
|
}
|
||||||
|
glDeleteBuffers(1,&flat);
|
||||||
|
glDeleteProgram(prog);
|
||||||
|
SDL_GL_DeleteContext(ctx);
|
||||||
|
SDL_DestroyWindow(w);
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
578
lutconv2.c
Normal file
578
lutconv2.c
Normal file
|
|
@ -0,0 +1,578 @@
|
||||||
|
/*
|
||||||
|
lutconv2.c : Improved, general purpose LUT converter.
|
||||||
|
Turns 2D LUT textures into DDS Volume Maps for convenience.
|
||||||
|
(C)2017 Marisa Kirisame, UnSX Team.
|
||||||
|
Released under the GNU General Public License version 3 (or later).
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <png.h>
|
||||||
|
|
||||||
|
#define dword uint32_t
|
||||||
|
#define byte uint8_t
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
dword magic, size, flags, height, width, pitch, depth, mipmaps,
|
||||||
|
reserved1[11], pf_size, pf_flags, pf_fourcc, pf_bitcount, pf_rmask,
|
||||||
|
pf_gmask, pf_bmask, pf_amask, caps[4], reserved2;
|
||||||
|
} ddsheader_t;
|
||||||
|
#pragma pack(pop)
|
||||||
|
ddsheader_t ddshead =
|
||||||
|
{
|
||||||
|
.magic = 0x20534444, .size = 124, .flags = 0x0080100f, .height = 0,
|
||||||
|
.width = 0, .pitch = 0, .depth = 0, .mipmaps = 0,
|
||||||
|
.reserved1 = {0,0,0,0,0,0,0,0,0,0,0}, .pf_size = 32, .pf_flags = 0x41,
|
||||||
|
.pf_fourcc = 0, .pf_bitcount = 32, .pf_rmask = 0xff,
|
||||||
|
.pf_gmask = 0xff00, .pf_bmask = 0xff0000, .pf_amask = 0xff000000,
|
||||||
|
.caps = {0x1000,0x200000,0,0}, .reserved2 = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t *indata, *outdata;
|
||||||
|
int width, height, depth, alpha;
|
||||||
|
|
||||||
|
/* vertical strip LUT, the format I use */
|
||||||
|
int vertconv( void )
|
||||||
|
{
|
||||||
|
int x, y, z, i, s;
|
||||||
|
ddshead.pf_flags = 0x41;
|
||||||
|
ddshead.pf_bitcount = 32;
|
||||||
|
/* guess the format */
|
||||||
|
if ( (width == 8) && (height == 4096) )
|
||||||
|
{
|
||||||
|
/* VGA 8x16 font table */
|
||||||
|
printf("conv: VGA 8x16 font table\n");
|
||||||
|
ddshead.width = width = 8;
|
||||||
|
ddshead.height = height = 16;
|
||||||
|
ddshead.depth = depth = 256;
|
||||||
|
ddshead.pitch = 8*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
if ( alpha ) outdata[i++] = indata[x++];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 16) && (height == 256) )
|
||||||
|
{
|
||||||
|
/* unpadded 16x16x16 LUT */
|
||||||
|
printf("conv: vertical 16x16x16 LUT\n");
|
||||||
|
ddshead.width = width = 16;
|
||||||
|
ddshead.height = height = 16;
|
||||||
|
ddshead.depth = depth = 16;
|
||||||
|
ddshead.pitch = 16*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
if ( alpha ) outdata[i++] = indata[x++];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 32) && (height == 512) )
|
||||||
|
{
|
||||||
|
/* padded 16x16x16 LUT */
|
||||||
|
printf("conv: vertical padded 16x16x16 LUT\n");
|
||||||
|
ddshead.width = width = 16;
|
||||||
|
ddshead.height = height = 16;
|
||||||
|
ddshead.depth = depth = 16;
|
||||||
|
ddshead.pitch = 16*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 8;
|
||||||
|
y = 8;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*32+z*512)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*32+z*512)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*32+z*512)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[(x+y*32+z*512)
|
||||||
|
*(3+alpha)+3];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 24 )
|
||||||
|
{
|
||||||
|
x = 8;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 24 )
|
||||||
|
{
|
||||||
|
y = 8;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 64) && (height == 64) )
|
||||||
|
{
|
||||||
|
/* square 16x16x16 LUT (assuming column-major grid) */
|
||||||
|
printf("conv: column-major 4x4 grid 16x16x16 LUT\n");
|
||||||
|
ddshead.width = width = 16;
|
||||||
|
ddshead.height = height = 16;
|
||||||
|
ddshead.depth = depth = 16;
|
||||||
|
ddshead.pitch = 16*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*64+(z&0x3)*1024
|
||||||
|
+(z&0xc)*4)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*64+(z&0x3)*1024
|
||||||
|
+(z&0xc)*4)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*64+(z&0x3)*1024
|
||||||
|
+(z&0xc)*4)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[indata[(x+y*64+(z&0x3)
|
||||||
|
*1024+(z&0xc)*4)*(3+alpha)+3]];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 16 )
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 16 )
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 64) && (height == 4096) )
|
||||||
|
{
|
||||||
|
/* unpadded 64x64x64 LUT */
|
||||||
|
printf("conv: vertical 64x64x64 LUT\n");
|
||||||
|
ddshead.width = width = 64;
|
||||||
|
ddshead.height = height = 64;
|
||||||
|
ddshead.depth = depth = 64;
|
||||||
|
ddshead.pitch = 64*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
if ( alpha ) outdata[i++] = indata[x++];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 128) && (height == 8192) )
|
||||||
|
{
|
||||||
|
/* padded 64x64x64 LUT */
|
||||||
|
printf("conv: vertical padded 64x64x64 LUT\n");
|
||||||
|
ddshead.width = width = 64;
|
||||||
|
ddshead.height = height = 64;
|
||||||
|
ddshead.depth = depth = 64;
|
||||||
|
ddshead.pitch = 64*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 32;
|
||||||
|
y = 32;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*128+z*16384)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*128+z*16384)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*128+z*16384)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[(x+y*128+z*16384)
|
||||||
|
*(3+alpha)+3];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 96 )
|
||||||
|
{
|
||||||
|
x = 32;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 96 )
|
||||||
|
{
|
||||||
|
y = 32;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 512) && (height == 512) )
|
||||||
|
{
|
||||||
|
/* square 64x64x64 LUT (assuming column-major grid) */
|
||||||
|
printf("conv: column-major 8x8 grid 64x64x64 LUT\n");
|
||||||
|
ddshead.width = width = 64;
|
||||||
|
ddshead.height = height = 64;
|
||||||
|
ddshead.depth = depth = 64;
|
||||||
|
ddshead.pitch = 64*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*512+(z&0x7)*32768
|
||||||
|
+(z&0x38)*8)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*512+(z&0x7)*32768
|
||||||
|
+(z&0x38)*8)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*512+(z&0x7)*32768
|
||||||
|
+(z&0x38)*8)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[indata[(x+y*512+(z&0x7)
|
||||||
|
*32768+(z&0x38)*16)*(3+alpha)+3]];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 64 )
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 64 )
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 256) && (height == 65536) )
|
||||||
|
{
|
||||||
|
/* unpadded 256x256x256 LUT (rare) */
|
||||||
|
printf("conv: vertical 256x256x256 LUT\n");
|
||||||
|
ddshead.width = width = 256;
|
||||||
|
ddshead.height = height = 256;
|
||||||
|
ddshead.depth = depth = 256;
|
||||||
|
ddshead.pitch = 256*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
outdata[i++] = indata[x++];
|
||||||
|
if ( alpha ) outdata[i++] = indata[x++];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 512) && (height == 131072) )
|
||||||
|
{
|
||||||
|
/* padded 256x256x256 LUT (very rare) */
|
||||||
|
printf("conv: vertical padded 256x256x256 LUT\n");
|
||||||
|
ddshead.width = width = 256;
|
||||||
|
ddshead.height = height = 256;
|
||||||
|
ddshead.depth = depth = 256;
|
||||||
|
ddshead.pitch = 256*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 128;
|
||||||
|
y = 128;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*512+z*262144)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*512+z*262144)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*512+z*262144)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[(x+y*512+z*262144)
|
||||||
|
*(3+alpha)+3];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 384 )
|
||||||
|
{
|
||||||
|
x = 128;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 384 )
|
||||||
|
{
|
||||||
|
y = 128;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( (width == 4096) && (height == 4096) )
|
||||||
|
{
|
||||||
|
/* square 256x256x256 LUT (assuming column-major grid) */
|
||||||
|
printf("conv: column-major 16x16 grid 256x256x256 LUT\n");
|
||||||
|
ddshead.width = width = 256;
|
||||||
|
ddshead.height = height = 256;
|
||||||
|
ddshead.depth = depth = 256;
|
||||||
|
ddshead.pitch = 256*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*4096+(z&0x0F)*1048576
|
||||||
|
+(z&0xF0)*16)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*4096+(z&0x0F)*1048576
|
||||||
|
+(z&0xF0)*16)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*4096+(z&0x0F)*1048576
|
||||||
|
+(z&0xF0)*16)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[indata[(x+y*4096+(z&0x0F)
|
||||||
|
*1048576+(z&0xF0)*16)*(3+alpha)+3]];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 256 )
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 256 )
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("conv: Never heard of a LUT texture of %ux%u\n",width,height);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* horizontal strip LUT, what everyone else except me uses */
|
||||||
|
int horconv( void )
|
||||||
|
{
|
||||||
|
int x, y, z, i, s;
|
||||||
|
ddshead.pf_flags = 0x41;
|
||||||
|
ddshead.pf_bitcount = 32;
|
||||||
|
/* guess the format */
|
||||||
|
if ( (width == 256) && (height == 16) )
|
||||||
|
{
|
||||||
|
/* 16x16x16 LUT */
|
||||||
|
printf("conv: horizontal 16x16x16 LUT\n");
|
||||||
|
ddshead.width = width = 16;
|
||||||
|
ddshead.height = height = 16;
|
||||||
|
ddshead.depth = depth = 16;
|
||||||
|
ddshead.pitch = 16*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*256+z*16)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*256+z*16)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*256+z*16)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[(x+y*256+z*16)
|
||||||
|
*(3+alpha)+3];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 16 )
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 16 )
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ( (width == 512) && (height == 32) )
|
||||||
|
{
|
||||||
|
/* padded 16x16x16 LUT */
|
||||||
|
printf("conv: horizontal padded 16x16x16 LUT\n");
|
||||||
|
ddshead.width = width = 16;
|
||||||
|
ddshead.height = height = 16;
|
||||||
|
ddshead.depth = depth = 16;
|
||||||
|
ddshead.pitch = 16*4;
|
||||||
|
s = width*height*depth*4;
|
||||||
|
outdata = malloc(s);
|
||||||
|
i = 0;
|
||||||
|
x = 8;
|
||||||
|
y = 8;
|
||||||
|
z = 0;
|
||||||
|
while ( i < s )
|
||||||
|
{
|
||||||
|
outdata[i++] = indata[(x+y*512+z*32)*(3+alpha)];
|
||||||
|
outdata[i++] = indata[(x+y*512+z*32)*(3+alpha)+1];
|
||||||
|
outdata[i++] = indata[(x+y*512+z*32)*(3+alpha)+2];
|
||||||
|
if ( alpha )
|
||||||
|
outdata[i++] = indata[(x+y*512+z*32)
|
||||||
|
*(3+alpha)+3];
|
||||||
|
else outdata[i++] = 255;
|
||||||
|
x++;
|
||||||
|
if ( x >= 24 )
|
||||||
|
{
|
||||||
|
x = 8;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if ( y >= 24 )
|
||||||
|
{
|
||||||
|
y = 8;
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("conv: Never heard of a LUT texture of %ux%u\n",width,height);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* png loader code, boilerplate written according to official docs */
|
||||||
|
int loadpng( const char *filename )
|
||||||
|
{
|
||||||
|
if ( !filename )
|
||||||
|
{
|
||||||
|
printf("png: no filename passed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
png_structp pngp;
|
||||||
|
png_infop infp;
|
||||||
|
unsigned int sread = 0;
|
||||||
|
int col, inter;
|
||||||
|
FILE *pf;
|
||||||
|
if ( !(pf = fopen(filename,"rb")) )
|
||||||
|
{
|
||||||
|
printf("png: could not open file: %s\n",strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
unsigned char header[8];
|
||||||
|
fread(header,8,1,pf);
|
||||||
|
if ( png_sig_cmp(header,0,8) )
|
||||||
|
{
|
||||||
|
printf("png: bad signature, not a PNG file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
sread += 8;
|
||||||
|
pngp = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||||
|
if ( !pngp )
|
||||||
|
{
|
||||||
|
printf("png: failed to create png_struct\n");
|
||||||
|
fclose(pf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
infp = png_create_info_struct(pngp);
|
||||||
|
if ( !infp )
|
||||||
|
{
|
||||||
|
printf("png: failed to create png_info\n");
|
||||||
|
fclose(pf);
|
||||||
|
png_destroy_read_struct(&pngp,0,0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ( setjmp(png_jmpbuf(pngp)) )
|
||||||
|
{
|
||||||
|
printf("png: failed to set up error handler\n");
|
||||||
|
png_destroy_read_struct(&pngp,&infp,0);
|
||||||
|
fclose(pf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
png_init_io(pngp,pf);
|
||||||
|
png_set_sig_bytes(pngp,sread);
|
||||||
|
png_read_png(pngp,infp,PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_PACKING
|
||||||
|
|PNG_TRANSFORM_EXPAND,0);
|
||||||
|
png_uint_32 w,h;
|
||||||
|
int dep;
|
||||||
|
png_get_IHDR(pngp,infp,&w,&h,&dep,&col,&inter,0,0);
|
||||||
|
if ( (col != PNG_COLOR_TYPE_RGB) && (col != PNG_COLOR_TYPE_RGB_ALPHA) )
|
||||||
|
{
|
||||||
|
printf("png: only RGB or RGBA are supported\n");
|
||||||
|
png_destroy_read_struct(&pngp,&infp,0);
|
||||||
|
fclose(pf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ( dep != 8 )
|
||||||
|
{
|
||||||
|
printf("png: only 8-bit channels are supported\n");
|
||||||
|
png_destroy_read_struct(&pngp,&infp,0);
|
||||||
|
fclose(pf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
alpha = (col==PNG_COLOR_TYPE_RGB_ALPHA);
|
||||||
|
int rbytes = png_get_rowbytes(pngp,infp);
|
||||||
|
indata = malloc(rbytes*h);
|
||||||
|
png_bytepp rptr = png_get_rows(pngp,infp);
|
||||||
|
for ( unsigned i=0; i<h; i++ )
|
||||||
|
memcpy(indata+(rbytes*i),rptr[i],rbytes);
|
||||||
|
png_destroy_read_struct(&pngp,&infp,0);
|
||||||
|
fclose(pf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
printf("LUTCONV 2.0 - (C)2017 Marisa Kirisame, UnSX Team.\n"
|
||||||
|
"This program is free software under the GNU GPL v3.\n"
|
||||||
|
"See https://www.gnu.org/licenses/gpl.html for details.\n\n");
|
||||||
|
if ( argc < 2 )
|
||||||
|
{
|
||||||
|
printf("No files have been passed for processing.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
FILE *fout;
|
||||||
|
char fname[255] = {0};
|
||||||
|
char *ext;
|
||||||
|
for ( int i=1; i<argc; i++ )
|
||||||
|
{
|
||||||
|
if ( loadpng(argv[i]) )
|
||||||
|
{
|
||||||
|
printf("Failed to load %s\n",argv[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int res = (width>height)?horconv():vertconv();
|
||||||
|
free(indata);
|
||||||
|
if ( !res )
|
||||||
|
{
|
||||||
|
printf("Failed to process %s\n",argv[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
strcpy(fname,argv[i]);
|
||||||
|
ext = strrchr(fname,'.');
|
||||||
|
if ( ext ) *ext = 0;
|
||||||
|
strcat(fname,".dds");
|
||||||
|
fout = fopen(fname,"wb");
|
||||||
|
if ( !fout )
|
||||||
|
{
|
||||||
|
printf("Cannot open %s: %s\n",fname,strerror(errno));
|
||||||
|
free(outdata);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fwrite(&ddshead,sizeof(ddsheader_t),1,fout);
|
||||||
|
fwrite(outdata,width*height*depth*4,1,fout);
|
||||||
|
fclose(fout);
|
||||||
|
free(outdata);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
37
memrd.c
Normal file
37
memrd.c
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#define BUFSZ 8192
|
||||||
|
|
||||||
|
int main( int argc, char** argv )
|
||||||
|
{
|
||||||
|
if ( argc < 3 )
|
||||||
|
{
|
||||||
|
fputs("usage: memread <pid> <offset> <size>\n",stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
char fn[256];
|
||||||
|
snprintf(fn,256,"/proc/%s/mem",argv[1]);
|
||||||
|
int fd = open(fn,O_RDONLY);
|
||||||
|
if ( !fd )
|
||||||
|
{
|
||||||
|
perror("could not open process");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
off_t memofs = 0;
|
||||||
|
off_t siz = 0, srd;
|
||||||
|
sscanf(argv[2],"%llx",&memofs);
|
||||||
|
sscanf(argv[3],"%lld",&siz);
|
||||||
|
lseek(fd,memofs,SEEK_SET);
|
||||||
|
unsigned char buf[BUFSZ];
|
||||||
|
while ( siz > 0 )
|
||||||
|
{
|
||||||
|
srd = read(fd,buf,(siz>BUFSZ)?BUFSZ:siz);
|
||||||
|
write(1,buf,srd);
|
||||||
|
siz -= srd;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
41
memsk.c
Normal file
41
memsk.c
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
int main( int argc, char** argv )
|
||||||
|
{
|
||||||
|
if ( argc < 3 )
|
||||||
|
{
|
||||||
|
fputs("usage: memseek <pid> <range> <size>\n",stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
char fn[256];
|
||||||
|
snprintf(fn,256,"/proc/%s/mem",argv[1]);
|
||||||
|
int fd = open(fn,O_RDONLY);
|
||||||
|
if ( !fd )
|
||||||
|
{
|
||||||
|
perror("could not open process");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
off_t memofs[2] = {0,0};
|
||||||
|
off_t siz = 0, rsiz;
|
||||||
|
sscanf(argv[2],"%llx-%llx",&memofs[0],&memofs[1]);
|
||||||
|
sscanf(argv[3],"%lld",&siz);
|
||||||
|
unsigned char *seekme = malloc(siz);
|
||||||
|
if ( !seekme ) return 4;
|
||||||
|
rsiz = read(0,seekme,siz);
|
||||||
|
if ( rsiz <= 0 ) return 8;
|
||||||
|
off_t seeksiz = memofs[1]-memofs[0];
|
||||||
|
lseek(fd,memofs[0],SEEK_SET);
|
||||||
|
unsigned char *seekarea = malloc(seeksiz);
|
||||||
|
if ( !seekarea ) return 16;
|
||||||
|
read(fd,seekarea,seeksiz);
|
||||||
|
close(fd);
|
||||||
|
off_t i;
|
||||||
|
for ( i=0; i<seeksiz-rsiz; i++ ) if ( !memcmp(seekme,seekarea+i,rsiz) )
|
||||||
|
printf("%x\n",memofs[0]+i);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
37
memwr.c
Normal file
37
memwr.c
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#define BUFSZ 8192
|
||||||
|
|
||||||
|
int main( int argc, char** argv )
|
||||||
|
{
|
||||||
|
if ( argc < 3 )
|
||||||
|
{
|
||||||
|
fputs("usage: memwrite <pid> <offset> <size>\n",stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
char fn[256];
|
||||||
|
snprintf(fn,256,"/proc/%s/mem",argv[1]);
|
||||||
|
int fd = open(fn,O_WRONLY);
|
||||||
|
if ( !fd )
|
||||||
|
{
|
||||||
|
perror("could not open process");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
off_t memofs = 0;
|
||||||
|
off_t siz = 0, srd;
|
||||||
|
sscanf(argv[2],"%llx",&memofs);
|
||||||
|
sscanf(argv[3],"%lld",&siz);
|
||||||
|
lseek(fd,memofs,SEEK_SET);
|
||||||
|
unsigned char buf[BUFSZ];
|
||||||
|
while ( siz > 0 )
|
||||||
|
{
|
||||||
|
srd = read(0,buf,(siz>BUFSZ)?BUFSZ:siz);
|
||||||
|
write(fd,buf,srd);
|
||||||
|
siz -= srd;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
27
mkgauss.c
Normal file
27
mkgauss.c
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define pi 3.14159265358979323846264338327950288419716939937510
|
||||||
|
#define e 2.71828182845904523536028747135266249775724709369995
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 3 ) return 1;
|
||||||
|
double sigma;
|
||||||
|
unsigned range;
|
||||||
|
sscanf(argv[1],"%u",&range);
|
||||||
|
sscanf(argv[2],"%lf",&sigma);
|
||||||
|
double kernel[range];
|
||||||
|
unsigned i;
|
||||||
|
for ( i=0; i<range; i++ )
|
||||||
|
{
|
||||||
|
kernel[i] = 1.0/sqrt(2*pi*sigma*sigma)
|
||||||
|
*pow(e,-((i*i)/(2*sigma*sigma)));
|
||||||
|
}
|
||||||
|
double sum = kernel[0];
|
||||||
|
for ( i=1; i<range; i++ ) sum += 2*kernel[i];
|
||||||
|
printf("sum: %.50lf\n",sum);
|
||||||
|
for ( i=0; i<range; i++ )
|
||||||
|
printf("%.6lf%s",kernel[i]/sum,(i<range-1)?", ":"\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1085
mksoundwad.c
Normal file
1085
mksoundwad.c
Normal file
File diff suppressed because it is too large
Load diff
32
mkssao.c
Normal file
32
mkssao.c
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define frand() ((double)rand()/(double)(RAND_MAX))
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
double samp[3];
|
||||||
|
unsigned i, max = 16, domult = 0, hemi = 0;
|
||||||
|
if ( argc > 1 ) sscanf(argv[1],"%u",&max);
|
||||||
|
if ( argc > 2 ) sscanf(argv[2],"%u",&domult);
|
||||||
|
if ( argc > 3 ) sscanf(argv[3],"%u",&hemi);
|
||||||
|
double sum, mult;
|
||||||
|
srand(time(0));
|
||||||
|
for ( i=0; i<max; i++ )
|
||||||
|
{
|
||||||
|
mult = domult?((double)(i+1)/(double)max):1.;
|
||||||
|
if ( domult > 1 ) mult = pow(mult,domult);
|
||||||
|
samp[0] = frand()*2.-1.;
|
||||||
|
samp[1] = frand()*2.-1.;
|
||||||
|
samp[2] = (hemi)?(frand()):(frand()*2.-1.);
|
||||||
|
sum = sqrt(samp[0]*samp[0]+samp[1]*samp[1]+samp[2]*samp[2]);
|
||||||
|
samp[0] = (samp[0]/sum)*mult;
|
||||||
|
samp[1] = (samp[1]/sum)*mult;
|
||||||
|
samp[2] = (samp[2]/sum)*mult;
|
||||||
|
printf("float3(% .4lf,% .4lf,% .4lf)%s",samp[0],samp[1],
|
||||||
|
samp[2],(i%2)?(i<max-1)?",\n":"\n":",");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
131
mkvolume.c
Normal file
131
mkvolume.c
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
mkvolume.c : Hastily written program to turn 2D LUTs into volume maps.
|
||||||
|
Reads raw RGB8 data and writes uncompressed RGB8 DDS because I'm lazy.
|
||||||
|
(C)2015 Marisa Kirisame, UnSX Team.
|
||||||
|
Released under the MIT License (see bottom of file).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#define dword __UINT32_TYPE__
|
||||||
|
#define byte __UINT8_TYPE__
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char magic[4];
|
||||||
|
dword size, flags, height, width, pitch, depth, mipmaps, reserved1[11],
|
||||||
|
pf_size, pf_flags;
|
||||||
|
char pf_fourcc[4];
|
||||||
|
dword pf_bitcount, pf_rmask, pf_gmask, pf_bmask, pf_amask, caps[4],
|
||||||
|
reserved2;
|
||||||
|
} __attribute__((packed)) ddsheader_t;
|
||||||
|
|
||||||
|
ddsheader_t head =
|
||||||
|
{
|
||||||
|
.magic = "DDS ", .size = 124,
|
||||||
|
.flags = 0x0080100F, /* caps|height|width|pitch|pixelformat|depth */
|
||||||
|
.height = 0, .width = 0, .pitch = 0, .depth = 0, /* set later */
|
||||||
|
.mipmaps = 0, .reserved1 = {0,0,0,0,0,0,0,0,0,0,0}, .pf_size = 32,
|
||||||
|
.pf_flags = 0x40 /* uncompressed */, .pf_fourcc = {0}, /* N/A */
|
||||||
|
.pf_bitcount = 24, .pf_rmask = 0xff, .pf_gmask = 0xff00,
|
||||||
|
.pf_bmask = 0xff0000, .pf_amask = 0, /* RGB8 mask, no alpha */
|
||||||
|
.caps = {0x1000,0x200000,0,0}, /* texture, volume */ .reserved2 = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct { byte r,g,b; } __attribute__((packed)) pixel_t;
|
||||||
|
|
||||||
|
pixel_t *tex = 0;
|
||||||
|
unsigned length = 0, numLUTs = 0;
|
||||||
|
#define area (length*length)
|
||||||
|
#define volume (length*length*length)
|
||||||
|
FILE *dat;
|
||||||
|
|
||||||
|
int readLUT( unsigned n )
|
||||||
|
{
|
||||||
|
char fn[256];
|
||||||
|
snprintf(fn,256,"lutout_%u.dds",n);
|
||||||
|
FILE *lf = fopen(fn,"w");
|
||||||
|
if ( !lf )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Could not open %s: %s\n",fn,strerror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
unsigned c = fwrite(&head,1,128,lf);
|
||||||
|
/* header goes here */
|
||||||
|
if ( c != 128 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Failed to write header (%u != %u)\n",c,128);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* read entire LUT into memory */
|
||||||
|
c = fread(tex,1,3*volume,dat);
|
||||||
|
if ( c != 3*volume )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Failed to read data (%u != %u)\n",c,3*volume);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* write slices */
|
||||||
|
for ( unsigned i=0; i<length; i++ ) for ( unsigned j=0; j<length; j++ )
|
||||||
|
{
|
||||||
|
c = fwrite(&tex[i*length+j*area],1,3*length,lf);
|
||||||
|
if ( c == 3*length ) continue;
|
||||||
|
fprintf(stderr,"Failed to write line %u, layer %u (%u != %u)",
|
||||||
|
j,i,c,3*length);
|
||||||
|
}
|
||||||
|
fclose(lf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 4 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Usage: %s <file> <length> <numLUTs>",argv[0]);
|
||||||
|
fprintf(stderr," Data is read as raw RGB8\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
dat = fopen(argv[1],"r");
|
||||||
|
if ( !dat )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Could not open %s: %s\n",argv[1],
|
||||||
|
strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
sscanf(argv[2],"%u",&length);
|
||||||
|
sscanf(argv[3],"%u",&numLUTs);
|
||||||
|
head.width = head.height = head.depth = length;
|
||||||
|
head.pitch = length*3;
|
||||||
|
tex = malloc(3*length*length*length);
|
||||||
|
printf("Ready to read %u %u³ LUTs from stdin\n",numLUTs,length);
|
||||||
|
printf("%u bytes each, %u bytes total\n",3*volume,3*volume*numLUTs);
|
||||||
|
for ( unsigned i=0; i<numLUTs; i++ )
|
||||||
|
printf("Table %u %s\n",i,readLUT(i)?"OK":"FAIL");
|
||||||
|
free(tex);
|
||||||
|
fclose(dat);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015 UnSX Team
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
134
mkwall.c
Normal file
134
mkwall.c
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
mkwall.c : The de-facto sayachan network wallpaper generator.
|
||||||
|
(C)2015-2017 Marisa Kirisame, UnSX Team. For personal use mostly.
|
||||||
|
Released under the GNU GPLv3 (or any later version).
|
||||||
|
Please refer to <https://gnu.org/licenses/gpl.txt> for license terms.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#include <Imlib2.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO:
|
||||||
|
- Option to put waifu on all screens
|
||||||
|
- Find a faster library for imaging
|
||||||
|
- Use xcb instead of Xlib
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* helper macro for linear interpolation */
|
||||||
|
#define lerp(a,b,t) ((1.f-(t))*(a)+(t)*(b))
|
||||||
|
|
||||||
|
/* a BGRA pixel (packed just in case, even if pointless) */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned char b,g,r,a;
|
||||||
|
} __attribute__((packed)) pixel_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
generate a BGRA8 image filled with a 4x4 diagonal stripe pattern
|
||||||
|
interpolating between two specific colours
|
||||||
|
*/
|
||||||
|
void* generate_diag( int w, int h, pixel_t cup, pixel_t cdn )
|
||||||
|
{
|
||||||
|
const float stripe[4] = {0.625f,0.375f,0.f,1.f};
|
||||||
|
int x, y, i;
|
||||||
|
pixel_t *diag = malloc(sizeof(pixel_t)*w*h);
|
||||||
|
i = 0;
|
||||||
|
for ( y=0; y<h; y++ )
|
||||||
|
{
|
||||||
|
for ( x=0; x<w; x++ )
|
||||||
|
{
|
||||||
|
diag[y*w+x].b = lerp(cup.b,cdn.b,stripe[i%4]);
|
||||||
|
diag[y*w+x].g = lerp(cup.g,cdn.g,stripe[i%4]);
|
||||||
|
diag[y*w+x].r = lerp(cup.r,cdn.r,stripe[i%4]);
|
||||||
|
diag[y*w+x].a = 255;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i=y%4;
|
||||||
|
}
|
||||||
|
return diag;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
clock_t tick, tock;
|
||||||
|
if ( argc < 6 )
|
||||||
|
{
|
||||||
|
printf("usage: %s <waifu> <RGB8> <RGB8> <l|c|r> <screen>"
|
||||||
|
" <filename>\n",basename(argv[0]));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Display *d = XOpenDisplay(0);
|
||||||
|
Screen *s = ScreenOfDisplay(d,DefaultScreen(d));
|
||||||
|
int rw = s->width, rh = s->height;
|
||||||
|
Imlib_Image wall, waifu;
|
||||||
|
tick = clock();
|
||||||
|
waifu = imlib_load_image(argv[1]);
|
||||||
|
if ( !waifu ) return 2;
|
||||||
|
tock = clock();
|
||||||
|
printf("load waifu: %fs\n",(double)(tock-tick)/CLOCKS_PER_SEC);
|
||||||
|
imlib_context_set_image(waifu);
|
||||||
|
int ww = imlib_image_get_width(), wh = imlib_image_get_height();
|
||||||
|
pixel_t cup, cdn;
|
||||||
|
/* read the hex RGB8 gradient colours */
|
||||||
|
sscanf(argv[2],"%02hhx%02hhx%02hhx",&cup.r,&cup.g,&cup.b);
|
||||||
|
sscanf(argv[3],"%02hhx%02hhx%02hhx",&cdn.r,&cdn.g,&cdn.b);
|
||||||
|
tick = clock();
|
||||||
|
wall = imlib_create_image_using_data(rw,rh,
|
||||||
|
generate_diag(rw,rh,cup,cdn));
|
||||||
|
tock = clock();
|
||||||
|
printf("generate diag: %fs\n",(double)(tock-tick)/CLOCKS_PER_SEC);
|
||||||
|
imlib_context_set_image(wall);
|
||||||
|
/*
|
||||||
|
get the specified screen geometry if xinerama is active, otherwise
|
||||||
|
just use the full virtual screen
|
||||||
|
*/
|
||||||
|
int sw, sh, ox = 0, oy = 0;
|
||||||
|
int dummy1, dummy2;
|
||||||
|
if ( XineramaQueryExtension(d,&dummy1,&dummy2) && XineramaIsActive(d) )
|
||||||
|
{
|
||||||
|
printf("xinerama active, querying...\n");
|
||||||
|
int nxs, sno;
|
||||||
|
XineramaScreenInfo *xs = XineramaQueryScreens(d,&nxs);
|
||||||
|
sscanf(argv[5],"%d",&sno);
|
||||||
|
if ( (nxs+sno) < 0 ) sno = 0;
|
||||||
|
if ( sno >= nxs ) sno = nxs-1;
|
||||||
|
if ( sno < 0 ) sno = nxs+sno;
|
||||||
|
printf("%d screens available, #%d selected\n",nxs,sno);
|
||||||
|
for ( int i=0; i<nxs; i++ )
|
||||||
|
{
|
||||||
|
printf(" Screen %d: %hdx%hd+%hd+%hd\n",
|
||||||
|
xs[i].screen_number,xs[i].width,xs[i].height,
|
||||||
|
xs[i].x_org,xs[i].y_org);
|
||||||
|
}
|
||||||
|
rw = xs[sno].width;
|
||||||
|
rh = xs[sno].height;
|
||||||
|
ox = xs[sno].x_org;
|
||||||
|
oy = xs[sno].y_org;
|
||||||
|
XFree(xs);
|
||||||
|
}
|
||||||
|
sw = (ww*rh)/wh;
|
||||||
|
sh = rh;
|
||||||
|
ox += (*argv[4]=='l')?(0):(*argv[4]=='r')?(rw-sw):((rw-sw)/2);
|
||||||
|
tick = clock();
|
||||||
|
imlib_blend_image_onto_image(waifu,0,0,0,ww,wh,ox,oy,sw,sh);
|
||||||
|
tock = clock();
|
||||||
|
printf("blend images: %fs\n",(double)(tock-tick)/CLOCKS_PER_SEC);
|
||||||
|
/* save to file */
|
||||||
|
char *ext = strrchr(argv[6],'.');
|
||||||
|
if ( ext ) imlib_image_set_format(ext+1);
|
||||||
|
tick = clock();
|
||||||
|
imlib_save_image(argv[6]);
|
||||||
|
tock = clock();
|
||||||
|
printf("save image: %fs\n",(double)(tock-tick)/CLOCKS_PER_SEC);
|
||||||
|
XCloseDisplay(d);
|
||||||
|
imlib_free_image();
|
||||||
|
imlib_context_set_image(waifu);
|
||||||
|
imlib_free_image();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
437
osnorm.c
Normal file
437
osnorm.c
Normal file
|
|
@ -0,0 +1,437 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define dword __UINT32_TYPE__
|
||||||
|
#define byte __UINT8_TYPE__
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char magic[4];
|
||||||
|
dword size, flags, height, width, pitch, depth, mipmaps, reserved1[11],
|
||||||
|
pf_size, pf_flags;
|
||||||
|
char pf_fourcc[4];
|
||||||
|
dword pf_bitcount, pf_rmask, pf_gmask, pf_bmask, pf_amask, caps[4],
|
||||||
|
reserved2;
|
||||||
|
} __attribute__((packed)) ddsheader_t;
|
||||||
|
|
||||||
|
ddsheader_t head =
|
||||||
|
{
|
||||||
|
.magic = "DDS ", .size = 124,
|
||||||
|
.flags = 0x0000100F, /* caps|height|width|pitch|pixelformat */
|
||||||
|
.height = 0, .width = 0, .pitch = 0, .depth = 0, /* set later */
|
||||||
|
.mipmaps = 0, .reserved1 = {0,0,0,0,0,0,0,0,0,0,0}, .pf_size = 32,
|
||||||
|
.pf_flags = 0x41 /* uncompressed|alpha */, .pf_fourcc = {0}, /* N/A */
|
||||||
|
.pf_bitcount = 32, .pf_rmask = 0xff, .pf_gmask = 0xff00,
|
||||||
|
.pf_bmask = 0xff0000, .pf_amask = 0xff000000, /* RGBA mask */
|
||||||
|
.caps = {0x1000,0,0,0}, /* texture */ .reserved2 = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct { byte r,g,b,a; } __attribute__((packed)) pixel_t;
|
||||||
|
|
||||||
|
unsigned w = 0, h = 0;
|
||||||
|
pixel_t *tex = 0, *ttex = 0;
|
||||||
|
FILE *obj, *dds, *tmap;
|
||||||
|
|
||||||
|
typedef struct { float x,y,z; } vect_t;
|
||||||
|
typedef struct { float u,v; } uv_t;
|
||||||
|
typedef struct { int v,c,n; } vert_t;
|
||||||
|
typedef struct { vert_t a,b,c; } tri_t;
|
||||||
|
typedef struct { int x,y; } vec2_t;
|
||||||
|
typedef struct { pixel_t c[2]; vec2_t p[2]; } edge_t;
|
||||||
|
|
||||||
|
vect_t *verts = 0, *norms = 0, *tangents = 0, *binormals = 0;
|
||||||
|
uv_t *uvs = 0;
|
||||||
|
tri_t *tris = 0;
|
||||||
|
int nvert = 0, nnorm = 0, ncoord = 0, nface = 0;
|
||||||
|
|
||||||
|
void cross( vect_t *a, vect_t b, vect_t c )
|
||||||
|
{
|
||||||
|
a->x = b.y*c.z-b.z*c.y;
|
||||||
|
a->y = b.z*c.x-b.x*c.z;
|
||||||
|
a->z = b.x*c.y-b.y*c.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void normalize( vect_t *a )
|
||||||
|
{
|
||||||
|
float scale = sqrtf(powf(a->x,2.f)+powf(a->y,2.f)+powf(a->z,2.f));
|
||||||
|
a->x /= scale;
|
||||||
|
a->y /= scale;
|
||||||
|
a->z /= scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void normalize2( uv_t *a )
|
||||||
|
{
|
||||||
|
float scale = sqrtf(powf(a->u,2.f)+powf(a->v,2.f));
|
||||||
|
a->u /= scale;
|
||||||
|
a->v /= scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
float dot( vect_t a, vect_t b )
|
||||||
|
{
|
||||||
|
return a.x*b.x+a.y*b.y+a.z*b.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tangent( vect_t *t, vect_t *b, int n )
|
||||||
|
{
|
||||||
|
vect_t t1 = {0,0,0}, t2 = {0,0,0};
|
||||||
|
for ( int j=0; j<nface; j++ )
|
||||||
|
{
|
||||||
|
if ( (tris[j].a.n != n) && (tris[j].b.n != n)
|
||||||
|
&& (tris[j].c.n != n) ) continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void calctangents( void )
|
||||||
|
{
|
||||||
|
if ( tangents ) free(tangents);
|
||||||
|
if ( binormals ) free(binormals);
|
||||||
|
tangents = malloc(sizeof(vect_t)*nnorm);
|
||||||
|
binormals = malloc(sizeof(vect_t)*nnorm);
|
||||||
|
memset(tangents,0,sizeof(vect_t)*nnorm);
|
||||||
|
memset(binormals,0,sizeof(vect_t)*nnorm);
|
||||||
|
vect_t *t1, *t2;
|
||||||
|
t1 = malloc(sizeof(vect_t)*nnorm);
|
||||||
|
t2 = malloc(sizeof(vect_t)*nnorm);
|
||||||
|
memset(t1,0,sizeof(vect_t)*nnorm);
|
||||||
|
memset(t2,0,sizeof(vect_t)*nnorm);
|
||||||
|
for ( int j=0; j<nface; j++ )
|
||||||
|
{
|
||||||
|
vect_t abv, acv;
|
||||||
|
uv_t abc, acc;
|
||||||
|
float r;
|
||||||
|
vect_t ud, vd;
|
||||||
|
abv.x = verts[tris[j].b.v].x-verts[tris[j].a.v].x;
|
||||||
|
abv.y = verts[tris[j].b.v].y-verts[tris[j].a.v].y;
|
||||||
|
abv.z = verts[tris[j].b.v].z-verts[tris[j].a.v].z;
|
||||||
|
acv.x = verts[tris[j].c.v].x-verts[tris[j].a.v].x;
|
||||||
|
acv.y = verts[tris[j].c.v].y-verts[tris[j].a.v].y;
|
||||||
|
acv.z = verts[tris[j].c.v].z-verts[tris[j].a.v].z;
|
||||||
|
abc.u = uvs[tris[j].b.c].u-uvs[tris[j].a.c].u;
|
||||||
|
abc.v = uvs[tris[j].b.c].v-uvs[tris[j].a.c].v;
|
||||||
|
acc.u = uvs[tris[j].c.c].u-uvs[tris[j].a.c].u;
|
||||||
|
acc.v = uvs[tris[j].c.c].v-uvs[tris[j].a.c].v;
|
||||||
|
r = 1.f/(abc.u*acc.v-acc.u*abc.v);
|
||||||
|
ud.x = (acc.v*abv.x-abc.v-acv.x)*r;
|
||||||
|
ud.y = (acc.v*abv.y-abc.v-acv.y)*r;
|
||||||
|
ud.z = (acc.v*abv.z-abc.v-acv.z)*r;
|
||||||
|
vd.x = (abc.u*acv.x-acc.u-abv.x)*r;
|
||||||
|
vd.y = (abc.u*acv.y-acc.u-abv.y)*r;
|
||||||
|
vd.z = (abc.u*acv.z-acc.u-abv.z)*r;
|
||||||
|
t1[tris[j].a.n].x += ud.x;
|
||||||
|
t1[tris[j].a.n].y += ud.y;
|
||||||
|
t1[tris[j].a.n].z += ud.z;
|
||||||
|
t1[tris[j].b.n].x += ud.x;
|
||||||
|
t1[tris[j].b.n].y += ud.y;
|
||||||
|
t1[tris[j].b.n].z += ud.z;
|
||||||
|
t1[tris[j].c.n].x += ud.x;
|
||||||
|
t1[tris[j].c.n].y += ud.y;
|
||||||
|
t1[tris[j].c.n].z += ud.z;
|
||||||
|
t2[tris[j].a.n].x += vd.x;
|
||||||
|
t2[tris[j].a.n].y += vd.y;
|
||||||
|
t2[tris[j].a.n].z += vd.z;
|
||||||
|
t2[tris[j].b.n].x += vd.x;
|
||||||
|
t2[tris[j].b.n].y += vd.y;
|
||||||
|
t2[tris[j].b.n].z += vd.z;
|
||||||
|
t2[tris[j].c.n].x += vd.x;
|
||||||
|
t2[tris[j].c.n].y += vd.y;
|
||||||
|
t2[tris[j].c.n].z += vd.z;
|
||||||
|
}
|
||||||
|
for ( int i=0; i<nnorm; i++ )
|
||||||
|
{
|
||||||
|
float dotnt = dot(norms[i],t1[i]);
|
||||||
|
tangents[i].x = t1[i].x-norms[i].x*dotnt;
|
||||||
|
tangents[i].y = t1[i].y-norms[i].y*dotnt;
|
||||||
|
tangents[i].z = t1[i].z-norms[i].z*dotnt;
|
||||||
|
normalize(&tangents[i]);
|
||||||
|
cross(&binormals[i],norms[i],t1[i]);
|
||||||
|
float hand = (dot(binormals[i],t2[i])<0.f)?-1.f:1.f;
|
||||||
|
binormals[i].x *= hand;
|
||||||
|
binormals[i].y *= hand;
|
||||||
|
binormals[i].z *= hand;
|
||||||
|
}
|
||||||
|
free(t1);
|
||||||
|
free(t2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void calcnormals( void )
|
||||||
|
{
|
||||||
|
if ( norms ) free(norms);
|
||||||
|
norms = malloc(sizeof(vect_t)*nvert);
|
||||||
|
memset(norms,0,sizeof(vect_t)*nvert);
|
||||||
|
nnorm = nvert;
|
||||||
|
for ( int i=0; i<nface; i++ )
|
||||||
|
{
|
||||||
|
tris[i].a.n = tris[i].a.v;
|
||||||
|
tris[i].b.n = tris[i].b.v;
|
||||||
|
tris[i].c.n = tris[i].c.v;
|
||||||
|
}
|
||||||
|
for ( int i=0; i<nvert; i++ )
|
||||||
|
{
|
||||||
|
for ( int j=0; j<nface; j++ )
|
||||||
|
{
|
||||||
|
if ( (tris[j].a.v != i) && (tris[j].b.v != i)
|
||||||
|
&& (tris[j].c.v != i) ) continue;
|
||||||
|
vect_t facet, ab, ac;
|
||||||
|
ab.x = verts[tris[j].b.v].x-verts[tris[j].a.v].x;
|
||||||
|
ab.y = verts[tris[j].b.v].y-verts[tris[j].a.v].y;
|
||||||
|
ab.z = verts[tris[j].b.v].z-verts[tris[j].a.v].z;
|
||||||
|
ac.x = verts[tris[j].c.v].x-verts[tris[j].a.v].x;
|
||||||
|
ac.y = verts[tris[j].c.v].y-verts[tris[j].a.v].y;
|
||||||
|
ac.z = verts[tris[j].c.v].z-verts[tris[j].a.v].z;
|
||||||
|
cross(&facet,ab,ac);
|
||||||
|
normalize(&facet);
|
||||||
|
norms[i].x += facet.x;
|
||||||
|
norms[i].y += facet.y;
|
||||||
|
norms[i].z += facet.z;
|
||||||
|
}
|
||||||
|
normalize(&norms[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadobj( void )
|
||||||
|
{
|
||||||
|
char rbuf[131072];
|
||||||
|
char *txt = 0;
|
||||||
|
size_t nread, len = 0, pos = 0;
|
||||||
|
fseek(obj,0,SEEK_END);
|
||||||
|
len = ftell(obj);
|
||||||
|
fseek(obj,0,SEEK_SET);
|
||||||
|
txt = malloc(len+1);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
nread = fread(rbuf,1,131072,obj);
|
||||||
|
memcpy(txt+pos,rbuf,nread);
|
||||||
|
pos += nread;
|
||||||
|
}
|
||||||
|
while ( !feof(obj) );
|
||||||
|
txt[pos] = 0;
|
||||||
|
char *line = txt;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ( !strncmp(line,"v ",2) ) nvert++;
|
||||||
|
else if ( !strncmp(line,"vt ",3) ) ncoord++;
|
||||||
|
else if ( !strncmp(line,"vn ",3) ) nnorm++;
|
||||||
|
else if ( !strncmp(line,"f ",2) ) nface++;
|
||||||
|
line = strchr(line,'\n');
|
||||||
|
}
|
||||||
|
while ( line && *(line++) );
|
||||||
|
verts = malloc(sizeof(vect_t)*nvert);
|
||||||
|
norms = malloc(sizeof(vect_t)*nnorm);
|
||||||
|
uvs = malloc(sizeof(uv_t)*ncoord);
|
||||||
|
tris = malloc(sizeof(tri_t)*nface);
|
||||||
|
memset(verts,0,sizeof(vect_t)*nvert);
|
||||||
|
memset(norms,0,sizeof(vect_t)*nnorm);
|
||||||
|
memset(uvs,0,sizeof(uv_t)*ncoord);
|
||||||
|
memset(tris,0,sizeof(tri_t)*nface);
|
||||||
|
int cv = 0, cc = 0, cn = 0, cf = 0;
|
||||||
|
line = strtok(txt,"\n");
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ( !strncmp(line,"v ",2) )
|
||||||
|
{
|
||||||
|
sscanf(line,"v %f %f %f",&verts[cv].x,&verts[cv].y,
|
||||||
|
&verts[cv].z);
|
||||||
|
cv++;
|
||||||
|
}
|
||||||
|
else if ( !strncmp(line,"vt ",3) )
|
||||||
|
{
|
||||||
|
sscanf(line,"vt %f %f",&uvs[cc].u,&uvs[cc].v);
|
||||||
|
uvs[cc].v = 1.0-uvs[cc].v;
|
||||||
|
cc++;
|
||||||
|
}
|
||||||
|
else if ( !strncmp(line,"vn ",3) )
|
||||||
|
{
|
||||||
|
sscanf(line,"vn %f %f %f",&norms[cn].x,&norms[cn].y,
|
||||||
|
&norms[cn].z);
|
||||||
|
cn++;
|
||||||
|
}
|
||||||
|
else if ( !strncmp(line,"f ",2) )
|
||||||
|
{
|
||||||
|
if ( cn <= 0 )
|
||||||
|
{
|
||||||
|
sscanf(line,"f %d/%d %d/%d %d/%d",
|
||||||
|
&tris[cf].a.v,&tris[cf].a.c,
|
||||||
|
&tris[cf].b.v,&tris[cf].b.c,
|
||||||
|
&tris[cf].c.v,&tris[cf].c.c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sscanf(line,"f %d/%d/%d %d/%d/%d %d/%d/%d",
|
||||||
|
&tris[cf].a.v,&tris[cf].a.c,
|
||||||
|
&tris[cf].a.n,&tris[cf].b.v,
|
||||||
|
&tris[cf].b.c,&tris[cf].b.n,
|
||||||
|
&tris[cf].c.v,&tris[cf].c.c,
|
||||||
|
&tris[cf].c.n);
|
||||||
|
}
|
||||||
|
tris[cf].a.v--;
|
||||||
|
tris[cf].a.c--;
|
||||||
|
tris[cf].a.n--;
|
||||||
|
tris[cf].b.v--;
|
||||||
|
tris[cf].b.c--;
|
||||||
|
tris[cf].b.n--;
|
||||||
|
tris[cf].c.v--;
|
||||||
|
tris[cf].c.c--;
|
||||||
|
tris[cf].c.n--;
|
||||||
|
cf++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while ( (line = strtok(0,"\n")) );
|
||||||
|
free(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mkedge( edge_t *e, pixel_t c1, vec2_t p1, pixel_t c2, vec2_t p2 )
|
||||||
|
{
|
||||||
|
if ( p1.y < p2.y )
|
||||||
|
{
|
||||||
|
e->c[0] = c1;
|
||||||
|
e->p[0] = p1;
|
||||||
|
e->c[1] = c2;
|
||||||
|
e->p[1] = p2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e->c[0] = c2;
|
||||||
|
e->p[0] = p2;
|
||||||
|
e->c[1] = c1;
|
||||||
|
e->p[1] = p1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void lerpcolor( pixel_t *o, pixel_t a, pixel_t b, float f )
|
||||||
|
{
|
||||||
|
f = (f>0.f)?(f>1.f)?1.f:f:0.f;
|
||||||
|
o->r = a.r*(1.f-f)+b.r*f;
|
||||||
|
o->g = a.g*(1.f-f)+b.g*f;
|
||||||
|
o->b = a.b*(1.f-f)+b.b*f;
|
||||||
|
o->a = a.a*(1.f-f)+b.a*f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawspans( edge_t a, edge_t b )
|
||||||
|
{
|
||||||
|
float e1 = a.p[1].y-a.p[0].y;
|
||||||
|
if ( e1 == 0.f ) return;
|
||||||
|
float e2 = b.p[1].y-b.p[0].y;
|
||||||
|
if ( e2 == 0.f ) return;
|
||||||
|
float is1 = (float)(a.p[1].x-a.p[0].x);
|
||||||
|
float is2 = (float)(b.p[1].x-b.p[0].x);
|
||||||
|
float f1 = (float)(b.p[0].y-a.p[0].y)/e1;
|
||||||
|
float fs1 = 1.f/e1;
|
||||||
|
float f2 = 0.f;
|
||||||
|
float fs2 = 1.f/e2;
|
||||||
|
for ( int y=b.p[0].y; y<b.p[1].y; y++ )
|
||||||
|
{
|
||||||
|
pixel_t c1, c2, c3;
|
||||||
|
lerpcolor(&c1,a.c[0],a.c[1],f1);
|
||||||
|
lerpcolor(&c2,b.c[0],b.c[1],f2);
|
||||||
|
int x1 = a.p[0].x+(int)(is1*f1);
|
||||||
|
int x2 = b.p[0].x+(int)(is2*f2);
|
||||||
|
if ( x1>x2 )
|
||||||
|
{
|
||||||
|
int tmp = x1;
|
||||||
|
x1 = x2;
|
||||||
|
x2 = tmp;
|
||||||
|
pixel_t tmpc = c1;
|
||||||
|
c1 = c2;
|
||||||
|
c2 = tmpc;
|
||||||
|
}
|
||||||
|
int xd = x2-x1;
|
||||||
|
if ( xd != 0 )
|
||||||
|
{
|
||||||
|
float fx = 0.f, fsx = 1.f/(float)xd;
|
||||||
|
for ( int x=x1; x<x2; x++ )
|
||||||
|
{
|
||||||
|
lerpcolor(&c3,c1,c2,fx);
|
||||||
|
if ( (x >= 0) && (x < w) && (y >= 0)
|
||||||
|
&& (y < h) )
|
||||||
|
if ( !tex[x+y*w].a ) tex[x+y*w] = c3;
|
||||||
|
fx += fsx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f1 += fs1;
|
||||||
|
f2 += fs2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawtriangle( int t1, int t2, int t3, int n1, int n2, int n3 )
|
||||||
|
{
|
||||||
|
pixel_t col[3] =
|
||||||
|
{
|
||||||
|
{(norms[n1].x*0.5f+0.5f)*255,(norms[n1].z*0.5f+0.5f)*255,
|
||||||
|
(norms[n1].y*0.5+0.5)*255,255},
|
||||||
|
{(norms[n2].x*0.5f+0.5f)*255,(norms[n2].z*0.5f+0.5f)*255,
|
||||||
|
(norms[n2].y*0.5+0.5)*255,255},
|
||||||
|
{(norms[n3].x*0.5f+0.5f)*255,(norms[n3].z*0.5f+0.5f)*255,
|
||||||
|
(norms[n3].y*0.5f+0.5f)*255,255},
|
||||||
|
};
|
||||||
|
vec2_t pts[3] =
|
||||||
|
{
|
||||||
|
{uvs[t1].u*w,uvs[t1].v*h},
|
||||||
|
{uvs[t2].u*w,uvs[t2].v*h},
|
||||||
|
{uvs[t3].u*w,uvs[t3].v*h}
|
||||||
|
};
|
||||||
|
edge_t edges[3];
|
||||||
|
mkedge(&edges[0],col[0],pts[0],col[1],pts[1]);
|
||||||
|
mkedge(&edges[1],col[1],pts[1],col[2],pts[2]);
|
||||||
|
mkedge(&edges[2],col[2],pts[2],col[0],pts[0]);
|
||||||
|
float ml = 0;
|
||||||
|
int longest = 0, short1 = 0, short2 = 0;
|
||||||
|
for ( int i=0; i<3; i++ )
|
||||||
|
{
|
||||||
|
float l = edges[i].p[1].y-edges[i].p[0].y;
|
||||||
|
if ( l > ml )
|
||||||
|
{
|
||||||
|
ml = l;
|
||||||
|
longest = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
short1 = (longest+1)%3;
|
||||||
|
short2 = (longest+2)%3;
|
||||||
|
drawspans(edges[longest],edges[short1]);
|
||||||
|
drawspans(edges[longest],edges[short2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void plotnormals( void )
|
||||||
|
{
|
||||||
|
int x1, y1, x2, y2, x3, y3;
|
||||||
|
for ( int i=0; i<nface; i++ )
|
||||||
|
drawtriangle(tris[i].a.c,tris[i].b.c,tris[i].c.c,
|
||||||
|
tris[i].a.n,tris[i].b.n,tris[i].c.n);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 4 ) return 1;
|
||||||
|
sscanf(argv[3],"%ux%u",&w,&h);
|
||||||
|
head.width = w;
|
||||||
|
head.height = h;
|
||||||
|
head.pitch = w*4;
|
||||||
|
/* load model */
|
||||||
|
if ( !(obj = fopen(argv[1],"r")) ) return 2;
|
||||||
|
loadobj();
|
||||||
|
fclose(obj);
|
||||||
|
/* plot pixels */
|
||||||
|
tex = malloc(sizeof(pixel_t)*w*h);
|
||||||
|
memset(tex,0,sizeof(pixel_t)*w*h);
|
||||||
|
printf("calculate normals\n");
|
||||||
|
calcnormals();
|
||||||
|
printf("calculate tangents and binormals\n");
|
||||||
|
calctangents();
|
||||||
|
printf("plot normals\n");
|
||||||
|
plotnormals();
|
||||||
|
/* clean up */
|
||||||
|
if ( !verts ) free(verts);
|
||||||
|
if ( !norms ) free(norms);
|
||||||
|
if ( !tangents ) free(tangents);
|
||||||
|
if ( !binormals ) free(binormals);
|
||||||
|
if ( !uvs ) free(uvs);
|
||||||
|
if ( !tris ) free(tris);
|
||||||
|
/* save texture */
|
||||||
|
if ( !(dds = fopen(argv[2],"w")) ) { fclose(obj); return 4; }
|
||||||
|
fwrite(&head,sizeof(ddsheader_t),1,dds);
|
||||||
|
fwrite(tex,sizeof(pixel_t),w*h,dds);
|
||||||
|
free(tex);
|
||||||
|
fclose(dds);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
47
schange.c
Normal file
47
schange.c
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
schange.c : run command on screen change events from RandR.
|
||||||
|
(C)2015 Marisa Kirisame, UnSX Team. For personal use mostly.
|
||||||
|
Released under the GNU GPLv3 (or any later version).
|
||||||
|
Please refer to <https://gnu.org/licenses/gpl.txt> for license terms.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_event.h>
|
||||||
|
#include <xcb/randr.h>
|
||||||
|
|
||||||
|
xcb_connection_t *c;
|
||||||
|
xcb_screen_t *s;
|
||||||
|
|
||||||
|
char **cmdline;
|
||||||
|
|
||||||
|
void handle_event( xcb_generic_event_t *e )
|
||||||
|
{
|
||||||
|
const xcb_query_extension_reply_t *r;
|
||||||
|
r = xcb_get_extension_data(c,&xcb_randr_id);
|
||||||
|
if ( (e->response_type&0x7f) != (r->first_event+XCB_RANDR_NOTIFY) )
|
||||||
|
return;
|
||||||
|
/* fork and exec command */
|
||||||
|
int pid = fork();
|
||||||
|
if ( !pid ) execvp(cmdline[0],cmdline);
|
||||||
|
else waitpid(pid,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 2 ) return 1;
|
||||||
|
cmdline = argv+1;
|
||||||
|
c = xcb_connect(0,0);
|
||||||
|
s = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
|
||||||
|
xcb_randr_select_input(c,s->root,XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE);
|
||||||
|
xcb_flush(c);
|
||||||
|
xcb_generic_event_t *e;
|
||||||
|
while ( (e=xcb_wait_for_event(c)) )
|
||||||
|
{
|
||||||
|
handle_event(e);
|
||||||
|
free(e);
|
||||||
|
}
|
||||||
|
xcb_disconnect(c);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
126
skse_cosave.c
Normal file
126
skse_cosave.c
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
uint8_t type[4];
|
||||||
|
uint32_t typehex;
|
||||||
|
};
|
||||||
|
uint32_t ver, len;
|
||||||
|
uint8_t *data;
|
||||||
|
} __attribute__((packed)) skse_chunk_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
uint8_t magic[4];
|
||||||
|
uint32_t magichex;
|
||||||
|
};
|
||||||
|
uint32_t nchunks, len;
|
||||||
|
skse_chunk_t *chunks;
|
||||||
|
} __attribute__((packed)) skse_plugin_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
uint8_t magic[4];
|
||||||
|
uint32_t magichex;
|
||||||
|
};
|
||||||
|
uint32_t fmtver;
|
||||||
|
uint32_t sksever;
|
||||||
|
uint32_t rtver;
|
||||||
|
uint32_t nplugins;
|
||||||
|
skse_plugin_t *plugins;
|
||||||
|
} __attribute__((packed)) skse_t;
|
||||||
|
|
||||||
|
void rawdatadump( const skse_chunk_t *chnk )
|
||||||
|
{
|
||||||
|
int i = 0, len = chnk->len;
|
||||||
|
while ( i<len )
|
||||||
|
{
|
||||||
|
int j, jmax = ((len-i)<16)?(len-i):16;
|
||||||
|
for ( j=0; j<jmax; j++ ) printf("%02x ",chnk->data[i+j]);
|
||||||
|
for ( ; j<16; j++ ) printf(" ");
|
||||||
|
for ( j=0; j<jmax; j++ ) if ( (chnk->data[i+j] >= 0x20)
|
||||||
|
&& (chnk->data[i+j] < 0x7f) )
|
||||||
|
putchar(chnk->data[i+j]);
|
||||||
|
else putchar('.');
|
||||||
|
for ( ; j<16; j++ ) putchar(' ');
|
||||||
|
putchar('\n');
|
||||||
|
i += jmax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getmodlist( const uint8_t *dat )
|
||||||
|
{
|
||||||
|
int nmods = dat[0];
|
||||||
|
printf("Listing %u plugin files:\n",dat[0]);
|
||||||
|
int i, p = 1;
|
||||||
|
for ( i=0; i<nmods; i++ )
|
||||||
|
{
|
||||||
|
int sl, ps = 0;
|
||||||
|
sl = dat[p++]|((dat[p++]<<8)&0xFF00);
|
||||||
|
printf(" %02X - ",i);
|
||||||
|
while ( ps++ < sl ) putchar(dat[p++]);
|
||||||
|
putchar('\n');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 1 ) return 1;
|
||||||
|
FILE *sf = fopen(argv[1],"r");
|
||||||
|
if ( !sf ) return 2;
|
||||||
|
skse_t skse = {0};
|
||||||
|
fread(&skse,20,1,sf);
|
||||||
|
skse.plugins = malloc(sizeof(skse_plugin_t)*skse.nplugins);
|
||||||
|
printf("Magic: %08x \"%.4s\"\n",skse.magichex,skse.magic);
|
||||||
|
printf("Format version: %u\n",skse.fmtver);
|
||||||
|
int maj, min, beta, sub;
|
||||||
|
maj = (skse.sksever>>24)&0xFF;
|
||||||
|
min = (skse.sksever>>16)&0xFF;
|
||||||
|
beta = (skse.sksever>>4)&0xFFF;
|
||||||
|
printf("SKSE version: %d.%d.%d\n",maj,min,beta);
|
||||||
|
maj = (skse.rtver>>24)&0xFF;
|
||||||
|
min = (skse.rtver>>16)&0xFF;
|
||||||
|
beta = (skse.rtver>>4)&0xFFF;
|
||||||
|
printf("Runtime version: 1.%d.%d.%d\n",maj,min,beta);
|
||||||
|
printf("Number of plugins: %u\n",skse.nplugins);
|
||||||
|
skse_plugin_t *plug;
|
||||||
|
int i;
|
||||||
|
for ( i=0; i<skse.nplugins; i++ )
|
||||||
|
{
|
||||||
|
plug = &skse.plugins[i];
|
||||||
|
fread(plug,12,1,sf);
|
||||||
|
printf("------ %08x \"%c%c%c%c\" ",plug->magichex,
|
||||||
|
plug->magic[3],plug->magic[2],plug->magic[1],
|
||||||
|
plug->magic[0]);
|
||||||
|
printf("%u chunks ",plug->nchunks);
|
||||||
|
printf("%u bytes\n",plug->len);
|
||||||
|
plug->chunks = malloc(sizeof(skse_chunk_t)*plug->nchunks);
|
||||||
|
skse_chunk_t *chnk;
|
||||||
|
int j;
|
||||||
|
for ( j=0; j<plug->nchunks; j++ )
|
||||||
|
{
|
||||||
|
chnk = &plug->chunks[j];
|
||||||
|
fread(chnk,12,1,sf);
|
||||||
|
chnk->data = malloc(chnk->len);
|
||||||
|
fread(chnk->data,chnk->len,1,sf);
|
||||||
|
printf("--- %08x \"%c%c%c%c\" ",chnk->typehex,
|
||||||
|
chnk->type[3],chnk->type[2],chnk->type[1],
|
||||||
|
chnk->type[0]);
|
||||||
|
printf("v%u ",chnk->ver);
|
||||||
|
printf("%u bytes\n",chnk->len);
|
||||||
|
if ( chnk->typehex == 0x4d4f4453 )
|
||||||
|
getmodlist(chnk->data);
|
||||||
|
else rawdatadump(chnk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(sf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
965
soapstone.c
Normal file
965
soapstone.c
Normal file
|
|
@ -0,0 +1,965 @@
|
||||||
|
/*
|
||||||
|
soapstone.c : Random orange soapstone message generator.
|
||||||
|
(C)2016 Marisa Kirisame, UnSX Team.
|
||||||
|
Released under the GNU GPLv3 (or later).
|
||||||
|
Dark Souls is (C)2011-2016 From Software.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
const char templates1[13][32] =
|
||||||
|
{
|
||||||
|
"%s ahead",
|
||||||
|
"Be wary of %s",
|
||||||
|
"Try %s",
|
||||||
|
"Need %s",
|
||||||
|
"Imminent %s...",
|
||||||
|
"Weakness: %s",
|
||||||
|
"%s",
|
||||||
|
"%s?",
|
||||||
|
"Good luck",
|
||||||
|
"I did it!",
|
||||||
|
"Here!",
|
||||||
|
"I can't take this...",
|
||||||
|
"Praise the Sun!"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char words1[173][32] =
|
||||||
|
{
|
||||||
|
"Enemy",
|
||||||
|
"Tough enemy",
|
||||||
|
"Hollow",
|
||||||
|
"Soldier",
|
||||||
|
"Knight",
|
||||||
|
"Sniper",
|
||||||
|
"Caster",
|
||||||
|
"Giant",
|
||||||
|
"Skeleton",
|
||||||
|
"Ghost",
|
||||||
|
"Bug",
|
||||||
|
"Poison bug",
|
||||||
|
"Lizard",
|
||||||
|
"Drake",
|
||||||
|
"Flier",
|
||||||
|
"Golem",
|
||||||
|
"Statue",
|
||||||
|
"Monster",
|
||||||
|
"Strange creature",
|
||||||
|
"Demon",
|
||||||
|
"Darkwraith",
|
||||||
|
"Dragon",
|
||||||
|
"Boss",
|
||||||
|
"Saint",
|
||||||
|
"Wretch",
|
||||||
|
"Charmer",
|
||||||
|
"Miscreant",
|
||||||
|
"Liar",
|
||||||
|
"Fatty",
|
||||||
|
"Beanpole",
|
||||||
|
"Merchant",
|
||||||
|
"Blacksmith",
|
||||||
|
"Master",
|
||||||
|
"Prisoner",
|
||||||
|
"Bonfire",
|
||||||
|
"Fog wall",
|
||||||
|
"Humanity",
|
||||||
|
"Lever",
|
||||||
|
"Switch",
|
||||||
|
"Key",
|
||||||
|
"Treasure",
|
||||||
|
"Chest",
|
||||||
|
"Weapon",
|
||||||
|
"Shield",
|
||||||
|
"Projectile",
|
||||||
|
"Armour",
|
||||||
|
"Item",
|
||||||
|
"Ring",
|
||||||
|
"Sorcery scroll",
|
||||||
|
"Pyromancy scroll",
|
||||||
|
"Miracle scroll",
|
||||||
|
"Ember",
|
||||||
|
"Trap",
|
||||||
|
"Covenant",
|
||||||
|
"Amazing key",
|
||||||
|
"Amazing treasure",
|
||||||
|
"Amazing chest",
|
||||||
|
"Amazing weapon",
|
||||||
|
"Amazing armour",
|
||||||
|
"Amazing item",
|
||||||
|
"Amazing ring",
|
||||||
|
"Amazing sorcery scroll",
|
||||||
|
"Amazing pyromancy scroll",
|
||||||
|
"Amazing miracle scroll",
|
||||||
|
"Amazing ember",
|
||||||
|
"Amazing trap",
|
||||||
|
"Close-ranged battle",
|
||||||
|
"Ranged battle",
|
||||||
|
"Eliminating one at a time",
|
||||||
|
"Luring it out",
|
||||||
|
"Beating to a pulp",
|
||||||
|
"Lying in ambush",
|
||||||
|
"Stealth",
|
||||||
|
"Mimicry",
|
||||||
|
"Pincer attack",
|
||||||
|
"Hitting them in one swoop",
|
||||||
|
"Fleeing",
|
||||||
|
"Charging",
|
||||||
|
"Stabbing in the back",
|
||||||
|
"Sweeping attack",
|
||||||
|
"Shield breaking",
|
||||||
|
"Head shots",
|
||||||
|
"Sorcery",
|
||||||
|
"Pyromancy",
|
||||||
|
"Miracles",
|
||||||
|
"Jumping off",
|
||||||
|
"Sliding down",
|
||||||
|
"Dashing through",
|
||||||
|
"Rolling",
|
||||||
|
"Backstepping",
|
||||||
|
"Jumping",
|
||||||
|
"Attacking",
|
||||||
|
"Holding with both hands",
|
||||||
|
"Kicking",
|
||||||
|
"A plunging attack",
|
||||||
|
"Blocking",
|
||||||
|
"Parrying",
|
||||||
|
"Locking-on",
|
||||||
|
"Path",
|
||||||
|
"Hidden path",
|
||||||
|
"Shortcut",
|
||||||
|
"Detour",
|
||||||
|
"Illusory wall",
|
||||||
|
"Shortcut",
|
||||||
|
"Dead end",
|
||||||
|
"Swamp",
|
||||||
|
"Lava",
|
||||||
|
"Forest",
|
||||||
|
"Cave",
|
||||||
|
"Labyrinth",
|
||||||
|
"Safe zone",
|
||||||
|
"Danger zone",
|
||||||
|
"Sniper spot",
|
||||||
|
"Bright spot",
|
||||||
|
"Dark spot",
|
||||||
|
"Open area",
|
||||||
|
"Tight spot",
|
||||||
|
"Hiding place",
|
||||||
|
"Exchange",
|
||||||
|
"Gorgeous view",
|
||||||
|
"Fall",
|
||||||
|
"Front",
|
||||||
|
"Back",
|
||||||
|
"Left",
|
||||||
|
"Right",
|
||||||
|
"Up",
|
||||||
|
"Down",
|
||||||
|
"Feet",
|
||||||
|
"Head",
|
||||||
|
"Back",
|
||||||
|
"Head",
|
||||||
|
"Neck",
|
||||||
|
"Stomach",
|
||||||
|
"Back",
|
||||||
|
"Arm",
|
||||||
|
"Leg",
|
||||||
|
"Heel",
|
||||||
|
"Rear",
|
||||||
|
"Tail",
|
||||||
|
"Wings",
|
||||||
|
"Anywhere",
|
||||||
|
"Strike",
|
||||||
|
"Thrust",
|
||||||
|
"Slash",
|
||||||
|
"Magic",
|
||||||
|
"Fire",
|
||||||
|
"Lightning",
|
||||||
|
"Critical hits",
|
||||||
|
"Bleeding",
|
||||||
|
"Poison",
|
||||||
|
"Strong poison",
|
||||||
|
"Curses",
|
||||||
|
"Divine",
|
||||||
|
"Occult",
|
||||||
|
"Crystal",
|
||||||
|
"Chance",
|
||||||
|
"Hint",
|
||||||
|
"Secret",
|
||||||
|
"Happiness",
|
||||||
|
"Sorrow",
|
||||||
|
"Life",
|
||||||
|
"Death",
|
||||||
|
"Undead",
|
||||||
|
"Elation",
|
||||||
|
"Grief",
|
||||||
|
"Hope",
|
||||||
|
"Despair",
|
||||||
|
"Light",
|
||||||
|
"Dark",
|
||||||
|
"Bravery",
|
||||||
|
"Resignation",
|
||||||
|
"Comfort",
|
||||||
|
"Tears"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char templates2[11][32] =
|
||||||
|
{
|
||||||
|
"%s ahead",
|
||||||
|
"%s required ahead",
|
||||||
|
"be wary of %s",
|
||||||
|
"try %s",
|
||||||
|
"weakness: %s",
|
||||||
|
"visions of %s...",
|
||||||
|
"%s",
|
||||||
|
"%s!",
|
||||||
|
"%s?",
|
||||||
|
"%s...",
|
||||||
|
"hurrah for %s!",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char conjunctions2[7][32] =
|
||||||
|
{
|
||||||
|
" and then ",
|
||||||
|
" but ",
|
||||||
|
" therefore ",
|
||||||
|
" in short ",
|
||||||
|
" or ",
|
||||||
|
" by the way ",
|
||||||
|
", "
|
||||||
|
};
|
||||||
|
|
||||||
|
const char words2[247][32] =
|
||||||
|
{
|
||||||
|
"enemy",
|
||||||
|
"monster",
|
||||||
|
"lesser foe",
|
||||||
|
"tough enemy",
|
||||||
|
"boss",
|
||||||
|
"Hollow",
|
||||||
|
"skeleton",
|
||||||
|
"ghost",
|
||||||
|
"bug",
|
||||||
|
"Gyrm",
|
||||||
|
"beast",
|
||||||
|
"giant",
|
||||||
|
"dwarf",
|
||||||
|
"sniper",
|
||||||
|
"caster",
|
||||||
|
"duo",
|
||||||
|
"trio",
|
||||||
|
"saint",
|
||||||
|
"wretch",
|
||||||
|
"charmer",
|
||||||
|
"poor soul",
|
||||||
|
"oddball",
|
||||||
|
"nimble one",
|
||||||
|
"laggard",
|
||||||
|
"moneybags",
|
||||||
|
"beggar",
|
||||||
|
"miscreant",
|
||||||
|
"liar",
|
||||||
|
"fatty",
|
||||||
|
"beanpole",
|
||||||
|
"merchant",
|
||||||
|
"artisan",
|
||||||
|
"master",
|
||||||
|
"friend",
|
||||||
|
"ally",
|
||||||
|
"Dark Spirit",
|
||||||
|
"Phantom",
|
||||||
|
"Shade",
|
||||||
|
"bonfire",
|
||||||
|
"fog wall",
|
||||||
|
"lever",
|
||||||
|
"switch",
|
||||||
|
"key",
|
||||||
|
"trap",
|
||||||
|
"torch",
|
||||||
|
"door",
|
||||||
|
"treasure",
|
||||||
|
"chest",
|
||||||
|
"something",
|
||||||
|
"quite something",
|
||||||
|
"weapon",
|
||||||
|
"shield",
|
||||||
|
"projectile",
|
||||||
|
"armor",
|
||||||
|
"item",
|
||||||
|
"ring",
|
||||||
|
"scroll",
|
||||||
|
"ore",
|
||||||
|
"message",
|
||||||
|
"bloodstain",
|
||||||
|
"illusion",
|
||||||
|
"close-ranged battle",
|
||||||
|
"ranged battle",
|
||||||
|
"eliminating one at a time",
|
||||||
|
"luring it out",
|
||||||
|
"beating to a pulp",
|
||||||
|
"ambush",
|
||||||
|
"pincer attack",
|
||||||
|
"hitting them in one swoop",
|
||||||
|
"dual-wielding",
|
||||||
|
"stealth",
|
||||||
|
"mimicry",
|
||||||
|
"fleeing",
|
||||||
|
"charging",
|
||||||
|
"jumping off",
|
||||||
|
"dashing through",
|
||||||
|
"circling around",
|
||||||
|
"trapping inside",
|
||||||
|
"rescue",
|
||||||
|
"sorcery",
|
||||||
|
"pyromancy",
|
||||||
|
"miracles",
|
||||||
|
"hexes",
|
||||||
|
"pure luck",
|
||||||
|
"prudence",
|
||||||
|
"brief respite",
|
||||||
|
"play dead",
|
||||||
|
"jog",
|
||||||
|
"dash",
|
||||||
|
"rolling",
|
||||||
|
"backstepping",
|
||||||
|
"jumping",
|
||||||
|
"attacking",
|
||||||
|
"jump attack",
|
||||||
|
"dash attack",
|
||||||
|
"counter attack",
|
||||||
|
"stabbing in the back",
|
||||||
|
"guard stun & stab",
|
||||||
|
"parry stun & stab",
|
||||||
|
"plunging attack",
|
||||||
|
"sweeping attack",
|
||||||
|
"shield breaking",
|
||||||
|
"blocking",
|
||||||
|
"parrying",
|
||||||
|
"spell parry",
|
||||||
|
"locking-on",
|
||||||
|
"no lock-on",
|
||||||
|
"two-handing",
|
||||||
|
"gesture",
|
||||||
|
"control",
|
||||||
|
"destroy",
|
||||||
|
"boulder",
|
||||||
|
"lava",
|
||||||
|
"poison gas",
|
||||||
|
"enemy horde",
|
||||||
|
"forest",
|
||||||
|
"cave",
|
||||||
|
"arena",
|
||||||
|
"hidden path",
|
||||||
|
"detour",
|
||||||
|
"shortcut",
|
||||||
|
"dead end",
|
||||||
|
"labyrinth",
|
||||||
|
"hole",
|
||||||
|
"bright spot",
|
||||||
|
"dark spot",
|
||||||
|
"open area",
|
||||||
|
"tight spot",
|
||||||
|
"safe zone",
|
||||||
|
"danger zone",
|
||||||
|
"sniper spot",
|
||||||
|
"hiding place",
|
||||||
|
"illusory wall",
|
||||||
|
"ladder",
|
||||||
|
"lift",
|
||||||
|
"exchange",
|
||||||
|
"gorgeous view",
|
||||||
|
"looking away",
|
||||||
|
"overconfidence",
|
||||||
|
"slip-up",
|
||||||
|
"oversight",
|
||||||
|
"fatigue",
|
||||||
|
"bad luck",
|
||||||
|
"inattention",
|
||||||
|
"loss of stamina",
|
||||||
|
"front",
|
||||||
|
"back",
|
||||||
|
"left",
|
||||||
|
"right",
|
||||||
|
"up",
|
||||||
|
"down",
|
||||||
|
"below",
|
||||||
|
"above",
|
||||||
|
"behind",
|
||||||
|
"head",
|
||||||
|
"neck",
|
||||||
|
"stomach",
|
||||||
|
"back",
|
||||||
|
"arm",
|
||||||
|
"leg",
|
||||||
|
"rear",
|
||||||
|
"tail",
|
||||||
|
"wings",
|
||||||
|
"anywhere",
|
||||||
|
"tongue",
|
||||||
|
"right arm",
|
||||||
|
"left arm",
|
||||||
|
"right leg",
|
||||||
|
"left leg",
|
||||||
|
"right side",
|
||||||
|
"left side",
|
||||||
|
"pincer",
|
||||||
|
"wheel",
|
||||||
|
"core",
|
||||||
|
"horse",
|
||||||
|
"strike",
|
||||||
|
"thrust",
|
||||||
|
"slash",
|
||||||
|
"magic",
|
||||||
|
"sorcery",
|
||||||
|
"fire",
|
||||||
|
"lightning",
|
||||||
|
"critical hits",
|
||||||
|
"bleeding",
|
||||||
|
"poison",
|
||||||
|
"toxic",
|
||||||
|
"curse",
|
||||||
|
"equipment breakage",
|
||||||
|
"chance",
|
||||||
|
"quagmire",
|
||||||
|
"hint",
|
||||||
|
"secret",
|
||||||
|
"happiness",
|
||||||
|
"misfortune",
|
||||||
|
"life",
|
||||||
|
"death",
|
||||||
|
"joy",
|
||||||
|
"sadness",
|
||||||
|
"tears",
|
||||||
|
"hope",
|
||||||
|
"despair",
|
||||||
|
"victory",
|
||||||
|
"defeat",
|
||||||
|
"light",
|
||||||
|
"dark",
|
||||||
|
"bravery",
|
||||||
|
"confidence",
|
||||||
|
"vigor",
|
||||||
|
"revenge",
|
||||||
|
"resignation",
|
||||||
|
"overwhelming",
|
||||||
|
"regret",
|
||||||
|
"pointless",
|
||||||
|
"man",
|
||||||
|
"woman",
|
||||||
|
"recklessness",
|
||||||
|
"composure",
|
||||||
|
"guts",
|
||||||
|
"comfort",
|
||||||
|
"silence",
|
||||||
|
"good luck",
|
||||||
|
"fine work",
|
||||||
|
"I did it!",
|
||||||
|
"I've failed...",
|
||||||
|
"here!",
|
||||||
|
"not here!",
|
||||||
|
"I can't take this...",
|
||||||
|
"don't you dare!",
|
||||||
|
"do it!",
|
||||||
|
"look carefully",
|
||||||
|
"listen carefully",
|
||||||
|
"think carefully",
|
||||||
|
"this place again?",
|
||||||
|
"now the real fight begins",
|
||||||
|
"keep moving",
|
||||||
|
"pull back",
|
||||||
|
"give it up",
|
||||||
|
"don't give up",
|
||||||
|
"help me...",
|
||||||
|
"impossible...",
|
||||||
|
"bloody expensive...",
|
||||||
|
"nice job",
|
||||||
|
"let me out of here...",
|
||||||
|
"stay calm",
|
||||||
|
"like a dream...",
|
||||||
|
"are you ready?",
|
||||||
|
"praise the Sun!"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char templates3[17][32] =
|
||||||
|
{
|
||||||
|
"%s ahead",
|
||||||
|
"No %s ahead",
|
||||||
|
"%s required ahead",
|
||||||
|
"be wary of %s",
|
||||||
|
"try %s",
|
||||||
|
"Could this be a %s?",
|
||||||
|
"If only I had a %s...",
|
||||||
|
"visions of %s...",
|
||||||
|
"Time for %s",
|
||||||
|
"%s",
|
||||||
|
"%s!",
|
||||||
|
"%s?",
|
||||||
|
"%s...",
|
||||||
|
"Huh. It's a %s...",
|
||||||
|
"praise the %s!",
|
||||||
|
"Let there be %s",
|
||||||
|
"Ahh, %s..."
|
||||||
|
};
|
||||||
|
|
||||||
|
const char conjunctions3[10][32] =
|
||||||
|
{
|
||||||
|
" and then ",
|
||||||
|
" but ",
|
||||||
|
" therefore ",
|
||||||
|
" in short ",
|
||||||
|
" or ",
|
||||||
|
" only ",
|
||||||
|
" by the way ",
|
||||||
|
" so to speak ",
|
||||||
|
" all the more ",
|
||||||
|
", ",
|
||||||
|
};
|
||||||
|
|
||||||
|
const char gestures3[33][32] =
|
||||||
|
{
|
||||||
|
"Point forward",
|
||||||
|
"Point up",
|
||||||
|
"Point down",
|
||||||
|
"Wave",
|
||||||
|
"Beckon",
|
||||||
|
"Call over",
|
||||||
|
"Welcome",
|
||||||
|
"Applause",
|
||||||
|
"Quiet Resolve",
|
||||||
|
"Jump for joy",
|
||||||
|
"Joy",
|
||||||
|
"Rejoice",
|
||||||
|
"Hurrah!",
|
||||||
|
"Praise the Sun",
|
||||||
|
"My thanks!",
|
||||||
|
"Bow",
|
||||||
|
"Proper bow",
|
||||||
|
"Dignified bow",
|
||||||
|
"Duel bow",
|
||||||
|
"Legion Etiquette",
|
||||||
|
"Darkmoon Loyalty",
|
||||||
|
"By my sword",
|
||||||
|
"Prayer",
|
||||||
|
"Silent Ally",
|
||||||
|
"Rest",
|
||||||
|
"Collapse",
|
||||||
|
"Patches Squat",
|
||||||
|
"Prostration",
|
||||||
|
"Toast",
|
||||||
|
"Sleep",
|
||||||
|
"Curl up",
|
||||||
|
"Stretch out",
|
||||||
|
"Path of the Dragon"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char words3[322][32] =
|
||||||
|
{
|
||||||
|
"enemy",
|
||||||
|
"monster",
|
||||||
|
"mob enemy",
|
||||||
|
"tough enemy",
|
||||||
|
"critical foe",
|
||||||
|
"Hollow",
|
||||||
|
"pilgrim",
|
||||||
|
"prisoner",
|
||||||
|
"monstrosity",
|
||||||
|
"skeleton",
|
||||||
|
"ghost",
|
||||||
|
"beast",
|
||||||
|
"lizard",
|
||||||
|
"bug",
|
||||||
|
"grub",
|
||||||
|
"crab",
|
||||||
|
"dwarf",
|
||||||
|
"giant",
|
||||||
|
"demon",
|
||||||
|
"dragon",
|
||||||
|
"knight",
|
||||||
|
"sellsword",
|
||||||
|
"warrior",
|
||||||
|
"herald",
|
||||||
|
"bandit",
|
||||||
|
"assassin",
|
||||||
|
"sorcerer",
|
||||||
|
"pyromancer",
|
||||||
|
"cleric",
|
||||||
|
"deprived",
|
||||||
|
"sniper",
|
||||||
|
"duo",
|
||||||
|
"trio",
|
||||||
|
"you",
|
||||||
|
"you bastard",
|
||||||
|
"good fellow",
|
||||||
|
"saint",
|
||||||
|
"wretch",
|
||||||
|
"charmer",
|
||||||
|
"poor soul",
|
||||||
|
"oddball",
|
||||||
|
"nimble one",
|
||||||
|
"laggard",
|
||||||
|
"moneybags",
|
||||||
|
"beggar",
|
||||||
|
"miscreant",
|
||||||
|
"liar",
|
||||||
|
"fatty",
|
||||||
|
"beanpole",
|
||||||
|
"youth",
|
||||||
|
"elder",
|
||||||
|
"old codger",
|
||||||
|
"old dear",
|
||||||
|
"miscreant",
|
||||||
|
"artisan",
|
||||||
|
"master",
|
||||||
|
"sage",
|
||||||
|
"champion",
|
||||||
|
"Lord of Cinder",
|
||||||
|
"king",
|
||||||
|
"queen",
|
||||||
|
"prince",
|
||||||
|
"princess",
|
||||||
|
"angel",
|
||||||
|
"god",
|
||||||
|
"friend",
|
||||||
|
"ally",
|
||||||
|
"spouse",
|
||||||
|
"covenantor",
|
||||||
|
"Phantom",
|
||||||
|
"Dark Spirit",
|
||||||
|
"bonfire",
|
||||||
|
"ember",
|
||||||
|
"fog wall",
|
||||||
|
"lever",
|
||||||
|
"contraption",
|
||||||
|
"key",
|
||||||
|
"trap",
|
||||||
|
"torch",
|
||||||
|
"door",
|
||||||
|
"treasure",
|
||||||
|
"chest",
|
||||||
|
"something",
|
||||||
|
"quite something",
|
||||||
|
"rubbish",
|
||||||
|
"filth",
|
||||||
|
"weapon",
|
||||||
|
"shield",
|
||||||
|
"projectile",
|
||||||
|
"armor",
|
||||||
|
"item",
|
||||||
|
"ring",
|
||||||
|
"ore",
|
||||||
|
"coal",
|
||||||
|
"transposing kiln",
|
||||||
|
"scroll",
|
||||||
|
"umbral ash",
|
||||||
|
"throne",
|
||||||
|
"rite",
|
||||||
|
"coffin",
|
||||||
|
"cinder",
|
||||||
|
"ash",
|
||||||
|
"moon",
|
||||||
|
"eye",
|
||||||
|
"brew",
|
||||||
|
"soup",
|
||||||
|
"message",
|
||||||
|
"bloodstain",
|
||||||
|
"illusion",
|
||||||
|
"close-ranged battle",
|
||||||
|
"ranged battle",
|
||||||
|
"eliminating one at a time",
|
||||||
|
"luring it out",
|
||||||
|
"beating to a pulp",
|
||||||
|
"ambush",
|
||||||
|
"pincer attack",
|
||||||
|
"hitting them in one swoop",
|
||||||
|
"dual-wielding",
|
||||||
|
"stealth",
|
||||||
|
"mimicry",
|
||||||
|
"fleeing",
|
||||||
|
"charging",
|
||||||
|
"jumping off",
|
||||||
|
"dashing through",
|
||||||
|
"circling around",
|
||||||
|
"trapping inside",
|
||||||
|
"rescue",
|
||||||
|
"Skill",
|
||||||
|
"sorcery",
|
||||||
|
"pyromancy",
|
||||||
|
"miracles",
|
||||||
|
"pure luck",
|
||||||
|
"prudence",
|
||||||
|
"brief respite",
|
||||||
|
"play dead",
|
||||||
|
"jog",
|
||||||
|
"dash",
|
||||||
|
"rolling",
|
||||||
|
"backstepping",
|
||||||
|
"jumping",
|
||||||
|
"attacking",
|
||||||
|
"jump attack",
|
||||||
|
"dash attack",
|
||||||
|
"counter attack",
|
||||||
|
"stabbing in the back",
|
||||||
|
"guard stun & stab",
|
||||||
|
"plunging attack",
|
||||||
|
"sweeping attack",
|
||||||
|
"shield breaking",
|
||||||
|
"blocking",
|
||||||
|
"parrying",
|
||||||
|
"locking-on",
|
||||||
|
"no lock-on",
|
||||||
|
"two-handing",
|
||||||
|
"gesture",
|
||||||
|
"control",
|
||||||
|
"destroy",
|
||||||
|
"boulder",
|
||||||
|
"lava",
|
||||||
|
"poison gas",
|
||||||
|
"enemy horde",
|
||||||
|
"forest",
|
||||||
|
"swamp",
|
||||||
|
"cave",
|
||||||
|
"shortcut",
|
||||||
|
"detour",
|
||||||
|
"hidden path",
|
||||||
|
"secret passage",
|
||||||
|
"dead end",
|
||||||
|
"labyrinth",
|
||||||
|
"hole",
|
||||||
|
"bright spot",
|
||||||
|
"dark spot",
|
||||||
|
"open area",
|
||||||
|
"tight spot",
|
||||||
|
"safe zone",
|
||||||
|
"danger zone",
|
||||||
|
"sniper spot",
|
||||||
|
"hiding place",
|
||||||
|
"illusory wall",
|
||||||
|
"ladder",
|
||||||
|
"lift",
|
||||||
|
"gorgeous view",
|
||||||
|
"looking away",
|
||||||
|
"overconfidence",
|
||||||
|
"slip-up",
|
||||||
|
"oversight",
|
||||||
|
"fatigue",
|
||||||
|
"bad luck",
|
||||||
|
"inattention",
|
||||||
|
"loss of stamina",
|
||||||
|
"chance encounter",
|
||||||
|
"planned encounter",
|
||||||
|
"front",
|
||||||
|
"back",
|
||||||
|
"left",
|
||||||
|
"right",
|
||||||
|
"up",
|
||||||
|
"down",
|
||||||
|
"below",
|
||||||
|
"above",
|
||||||
|
"behind",
|
||||||
|
"head",
|
||||||
|
"neck",
|
||||||
|
"stomach",
|
||||||
|
"back",
|
||||||
|
"arm",
|
||||||
|
"finger",
|
||||||
|
"leg",
|
||||||
|
"rear",
|
||||||
|
"tail",
|
||||||
|
"wings",
|
||||||
|
"anywhere",
|
||||||
|
"tongue",
|
||||||
|
"right arm",
|
||||||
|
"left arm",
|
||||||
|
"thumb",
|
||||||
|
"indexfinger",
|
||||||
|
"longfinger",
|
||||||
|
"ringfinger",
|
||||||
|
"smallfinger",
|
||||||
|
"right leg",
|
||||||
|
"left leg",
|
||||||
|
"right side",
|
||||||
|
"left side",
|
||||||
|
"pincer",
|
||||||
|
"wheel",
|
||||||
|
"core",
|
||||||
|
"mount",
|
||||||
|
"regular",
|
||||||
|
"strike",
|
||||||
|
"thrust",
|
||||||
|
"slash",
|
||||||
|
"magic",
|
||||||
|
"crystal",
|
||||||
|
"fire",
|
||||||
|
"chaos",
|
||||||
|
"lightning",
|
||||||
|
"blessing",
|
||||||
|
"dark",
|
||||||
|
"critical hits",
|
||||||
|
"bleeding",
|
||||||
|
"poison",
|
||||||
|
"toxic",
|
||||||
|
"frost",
|
||||||
|
"curse",
|
||||||
|
"equipment breakage",
|
||||||
|
"chance",
|
||||||
|
"quagmire",
|
||||||
|
"hint",
|
||||||
|
"secret",
|
||||||
|
"sleeptalk",
|
||||||
|
"happiness",
|
||||||
|
"misfortune",
|
||||||
|
"life",
|
||||||
|
"death",
|
||||||
|
"demise",
|
||||||
|
"joy",
|
||||||
|
"fury",
|
||||||
|
"agony",
|
||||||
|
"sadness",
|
||||||
|
"tears",
|
||||||
|
"loyalty",
|
||||||
|
"betrayal",
|
||||||
|
"hope",
|
||||||
|
"despair",
|
||||||
|
"fear",
|
||||||
|
"losing sanity",
|
||||||
|
"victory",
|
||||||
|
"defeat",
|
||||||
|
"sacrifice",
|
||||||
|
"light",
|
||||||
|
"dark",
|
||||||
|
"bravery",
|
||||||
|
"confidence",
|
||||||
|
"vigor",
|
||||||
|
"revenge",
|
||||||
|
"resignation",
|
||||||
|
"overwhelming",
|
||||||
|
"regret",
|
||||||
|
"pointless",
|
||||||
|
"man",
|
||||||
|
"woman",
|
||||||
|
"friendship",
|
||||||
|
"love",
|
||||||
|
"recklessness",
|
||||||
|
"composure",
|
||||||
|
"guts",
|
||||||
|
"comfort",
|
||||||
|
"silence",
|
||||||
|
"deep",
|
||||||
|
"good luck",
|
||||||
|
"fine work",
|
||||||
|
"I did it!",
|
||||||
|
"I've failed...",
|
||||||
|
"here!",
|
||||||
|
"not here!",
|
||||||
|
"I can't take this...",
|
||||||
|
"lonely...",
|
||||||
|
"don't you dare!",
|
||||||
|
"do it!",
|
||||||
|
"look carefully",
|
||||||
|
"listen carefully",
|
||||||
|
"think carefully",
|
||||||
|
"this place again?",
|
||||||
|
"now the real fight begins",
|
||||||
|
"you don't deserve this",
|
||||||
|
"keep moving",
|
||||||
|
"pull back",
|
||||||
|
"give it up",
|
||||||
|
"don't give up",
|
||||||
|
"help me...",
|
||||||
|
"impossible...",
|
||||||
|
"bloody expensive...",
|
||||||
|
"let me out of here...",
|
||||||
|
"stay calm",
|
||||||
|
"like a dream...",
|
||||||
|
"seems familiar...",
|
||||||
|
"are you ready?",
|
||||||
|
"it'll happen to you too",
|
||||||
|
"praise the Sun!",
|
||||||
|
"may the flames guide thee"
|
||||||
|
};
|
||||||
|
|
||||||
|
void print_soapstone_ds1( void )
|
||||||
|
{
|
||||||
|
int template = rand()%13;
|
||||||
|
int word = rand()%173;
|
||||||
|
char mesg[256];
|
||||||
|
if ( template < 8 ) sprintf(mesg,templates1[template],words1[word]);
|
||||||
|
else strcpy(mesg,templates1[template]);
|
||||||
|
printf("%s\n",mesg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_soapstone_ds2( void )
|
||||||
|
{
|
||||||
|
int template = rand()%11;
|
||||||
|
int word = rand()%(((template>5)&&(template<10))?247:220);
|
||||||
|
char mesg[256];
|
||||||
|
sprintf(mesg,templates2[template],words2[word]);
|
||||||
|
if ( rand()&1 )
|
||||||
|
{
|
||||||
|
char mesg2[256];
|
||||||
|
int template2 = rand()%11;
|
||||||
|
int word2 = rand()%(((template2>5)&&(template2<10))?247:220);
|
||||||
|
int conj = rand()%7;
|
||||||
|
sprintf(mesg2,templates2[template2],words2[word2]);
|
||||||
|
printf("%s%s%s\n",mesg,conjunctions2[conj],mesg2);
|
||||||
|
}
|
||||||
|
else printf("%s\n",mesg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_soapstone_ds3( void )
|
||||||
|
{
|
||||||
|
if ( rand()&1 ) printf("[%s] ",gestures3[rand()%33]);
|
||||||
|
int template = rand()%17;
|
||||||
|
int word = rand()%322;
|
||||||
|
char mesg[256];
|
||||||
|
sprintf(mesg,templates3[template],words3[word]);
|
||||||
|
if ( rand()&1 )
|
||||||
|
{
|
||||||
|
char mesg2[256];
|
||||||
|
int template2 = rand()%17;
|
||||||
|
int word2 = rand()%211;
|
||||||
|
int conj = rand()%10;
|
||||||
|
sprintf(mesg2,templates3[template2],words3[word2]);
|
||||||
|
printf("%s%s%s\n",mesg,conjunctions3[conj],mesg2);
|
||||||
|
}
|
||||||
|
else printf("%s\n",mesg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
int rsd = 0;
|
||||||
|
#ifndef WINDOWS
|
||||||
|
FILE *r;
|
||||||
|
if ( (r = fopen("/dev/random","r")) )
|
||||||
|
{
|
||||||
|
fread(&rsd,sizeof(int),1,r);
|
||||||
|
fclose(r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
rsd = time(0);
|
||||||
|
srand(rsd);
|
||||||
|
if ( argc < 2 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"usage: %s <gamenumber> [lines]\n",argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int times = 1;
|
||||||
|
if ( argc > 2 ) sscanf(argv[2],"%d",×);
|
||||||
|
switch( *argv[1] )
|
||||||
|
{
|
||||||
|
case '1':
|
||||||
|
for ( int i=0; i<times; i++ ) print_soapstone_ds1();
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
for ( int i=0; i<times; i++ ) print_soapstone_ds2();
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
for ( int i=0; i<times; i++ ) print_soapstone_ds3();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"unknown gamenum %c\n",*argv[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
21
totty.c
Normal file
21
totty.c
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
char *tty = "/dev/tty1";
|
||||||
|
if ( argc > 1 ) tty = argv[1];
|
||||||
|
int fd = open(tty,O_RDWR);
|
||||||
|
if ( !fd == -1 )
|
||||||
|
{
|
||||||
|
perror("open tty failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int mchar = 0;
|
||||||
|
while ( (mchar = getchar()) != EOF )
|
||||||
|
ioctl(fd,TIOCSTI,&mchar);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
90
vc2sdl.c
Normal file
90
vc2sdl.c
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
#include <bcm_host.h>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define TMAX 64
|
||||||
|
int ti = 0;
|
||||||
|
float ts = 0.f, tl[TMAX] = {0.f};
|
||||||
|
|
||||||
|
float avg_fps( float nt )
|
||||||
|
{
|
||||||
|
ts = ts-tl[ti]+nt;
|
||||||
|
tl[ti] = nt;
|
||||||
|
if ( ++ti == TMAX ) ti = 0;
|
||||||
|
return ts/TMAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NANOS_SEC 1000000000L
|
||||||
|
|
||||||
|
long ticker( void )
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
|
||||||
|
return ts.tv_nsec+ts.tv_sec*NANOS_SEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
unsigned reduce = 1;
|
||||||
|
unsigned width = 720, height = 480;
|
||||||
|
if ( argc > 2 )
|
||||||
|
{
|
||||||
|
sscanf(argv[2],"%u",&reduce);
|
||||||
|
sscanf(argv[1],"%ux%u",&width,&height);
|
||||||
|
}
|
||||||
|
width /= reduce;
|
||||||
|
height /= reduce;
|
||||||
|
bcm_host_init();
|
||||||
|
DISPMANX_DISPLAY_HANDLE_T d = vc_dispmanx_display_open(0);
|
||||||
|
if ( !d ) return 1;
|
||||||
|
DISPMANX_MODEINFO_T m;
|
||||||
|
if ( vc_dispmanx_display_get_info(d,&m) )
|
||||||
|
{
|
||||||
|
vc_dispmanx_display_close(d);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
unsigned pt;
|
||||||
|
DISPMANX_RESOURCE_HANDLE_T r =
|
||||||
|
vc_dispmanx_resource_create(VC_IMAGE_RGB888,width,height,&pt);
|
||||||
|
if ( !r )
|
||||||
|
{
|
||||||
|
vc_dispmanx_display_close(d);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
VC_RECT_T rt;
|
||||||
|
vc_dispmanx_rect_set(&rt,0,0,width,height);
|
||||||
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
SDL_Window *w = SDL_CreateWindow("VC4 Feed",SDL_WINDOWPOS_CENTERED,
|
||||||
|
SDL_WINDOWPOS_CENTERED,width,height,SDL_WINDOW_SHOWN);
|
||||||
|
SDL_Surface *ws = SDL_GetWindowSurface(w);
|
||||||
|
SDL_Surface *copy = SDL_CreateRGBSurface(0,width,height,24,0xFF,0xFF00,
|
||||||
|
0xFF0000,0);
|
||||||
|
int active = 1;
|
||||||
|
SDL_Event e;
|
||||||
|
long tick, tock;
|
||||||
|
float frame = 0.f, fps = NAN, fpsmin = INFINITY, fpsmax = -INFINITY,
|
||||||
|
fpsavg = 0.f;
|
||||||
|
while ( active )
|
||||||
|
{
|
||||||
|
tick = ticker();
|
||||||
|
while ( SDL_PollEvent(&e) )
|
||||||
|
if ( e.type == SDL_QUIT ) active = 0;
|
||||||
|
vc_dispmanx_snapshot(d,r,0);
|
||||||
|
vc_dispmanx_resource_read_data(r,&rt,copy->pixels,copy->pitch);
|
||||||
|
SDL_BlitSurface(copy,0,ws,0);
|
||||||
|
SDL_UpdateWindowSurface(w);
|
||||||
|
tock = ticker();
|
||||||
|
frame = (float)(tock-tick)/NANOS_SEC;
|
||||||
|
fps = 1.f/frame;
|
||||||
|
fpsavg = avg_fps(fps);
|
||||||
|
if ( fps > fpsmax ) fpsmax = fps;
|
||||||
|
if ( fps < fpsmin ) fpsmin = fps;
|
||||||
|
printf("FPS: %.2f (%.2f min, %.2f max, %.2f avg)\n",fps,
|
||||||
|
fpsmin,fpsmax,fpsavg);
|
||||||
|
}
|
||||||
|
vc_dispmanx_display_close(d);
|
||||||
|
SDL_FreeSurface(copy);
|
||||||
|
SDL_DestroyWindow(w);
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
23
withhands.c
Normal file
23
withhands.c
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
const char* asciitab[96] =
|
||||||
|
{
|
||||||
|
" ","🖉","✂","✁","👓","🕭","🕮","🕯","🕿","✆","🖂","🖃","📪","📫","📬","📭","🗀",
|
||||||
|
"🗁","🗎","🗏","🗐","🗄","⌛","🖮","🖰","🖲","🖳","🖴","🖫","🖬","✇","✍","🖎","✌",
|
||||||
|
"🖏","🖒","🖓","🖘","🖙","🖞","🖟","🖐","☺","😐","☹","💣","☠","⚐","🏱","✈","☼",
|
||||||
|
"🌢","❄","🕆","✞","🕈","✠","✡","☪","☯","ॐ","☸","♈","♉","♊","♋","♌","♍",
|
||||||
|
"♎","♏","♐","♑","♒","♓","🙰","🙵","●","❍","■","□","◻","❏","❐","⬪","⬧",
|
||||||
|
"◆","❖","⬥","⌧","⍓","⌘","❀","✿","❝","❞","▯"
|
||||||
|
};
|
||||||
|
|
||||||
|
int main( void )
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
while ( (ch=getchar()) != EOF )
|
||||||
|
{
|
||||||
|
if ( (ch >= 0x20) && (ch < 0x80) )
|
||||||
|
printf(asciitab[ch-0x20]);
|
||||||
|
else putchar(ch);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
21
zfs-rootfs.patch
Normal file
21
zfs-rootfs.patch
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
diff --git a/src/zfs-utils/zfs-utils.initcpio.hook b/src/zfs-utils/zfs-utils.initcpio.hook
|
||||||
|
index 09d081f..4337e23 100644
|
||||||
|
--- a/src/zfs-utils/zfs-utils.initcpio.hook
|
||||||
|
+++ b/src/zfs-utils/zfs-utils.initcpio.hook
|
||||||
|
@@ -53,6 +53,7 @@ zfs_mount_handler () {
|
||||||
|
fi
|
||||||
|
|
||||||
|
local node="$1"
|
||||||
|
+ local rootmnt=$(zfs get -H -o value mountpoint "${ZFS_DATASET}")
|
||||||
|
local tab_file="${node}/etc/fstab"
|
||||||
|
local zfs_datasets="$(zfs list -H -o name -t filesystem -r ${ZFS_DATASET})"
|
||||||
|
|
||||||
|
@@ -73,7 +74,7 @@ zfs_mount_handler () {
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
- mount -t zfs -o "zfsutil,${rwopt_exp}" "${dataset}" "${node}${mountpoint}"
|
||||||
|
+ mount -t zfs -o "zfsutil,${rwopt_exp}" "${dataset}" "${node}/${mountpoint##${rootmnt}}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
71
zimagekver.c
Normal file
71
zimagekver.c
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if ( argc < 2 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"No file provided!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
FILE *k;
|
||||||
|
if ( !(k = fopen(argv[1],"r")) )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Could not open file: %s\n",strerror(errno));
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
/* seek to fields */
|
||||||
|
if ( fseek(k,0x24,SEEK_SET) == -1 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Could not seek in file for header: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
fclose(k);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
/* read important info */
|
||||||
|
unsigned sig = 0, start = 0, end = 0;
|
||||||
|
fread(&sig,4,1,k);
|
||||||
|
fread(&start,4,1,k);
|
||||||
|
fread(&end,4,1,k);
|
||||||
|
if ( sig != 0x016f2818 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Bad magic %08x, not a valid zImage\n",sig);
|
||||||
|
fclose(k);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Search for Linux version at end, we need to find "DTOK" followed
|
||||||
|
by "Linux version". This normally starts 64 bytes after the zImage.
|
||||||
|
*/
|
||||||
|
if ( fseek(k,end+0x40,SEEK_SET) == -1 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"Could not seek in file for version string: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
fclose(k);
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
char dtok[4] = "";
|
||||||
|
fread(dtok,1,4,k);
|
||||||
|
if ( strncmp(dtok,"DTOK",4) )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Expected \"DTOK\", got \"%.4s\"\n",dtok);
|
||||||
|
fclose(k);
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
char kver[128] = "";
|
||||||
|
fgets(kver,128,k);
|
||||||
|
fclose(k);
|
||||||
|
if ( strncmp(kver,"Linux version ",14) )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Expected \"Linux version \", got \"%.14s\"\n",
|
||||||
|
kver);
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
/* get the actual version string and print it */
|
||||||
|
char kernver[128] = "";
|
||||||
|
sscanf(kver,"Linux version %s",kernver);
|
||||||
|
printf("%s\n",kernver);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue